Compare commits
27 Commits
@nhost/rea
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e21de3819 | ||
|
|
a7f3599fb1 | ||
|
|
c789102189 | ||
|
|
b638173181 | ||
|
|
d65df02adb | ||
|
|
4f9287562e | ||
|
|
58f82f9aad | ||
|
|
38462c45b6 | ||
|
|
8e03ed43b7 | ||
|
|
b4d52debff | ||
|
|
287e48a51a | ||
|
|
9370e06b68 | ||
|
|
d5b775c630 | ||
|
|
ea8e1df8da | ||
|
|
ced8100168 | ||
|
|
36d6db526c | ||
|
|
fb53e94193 | ||
|
|
165ff16cdc | ||
|
|
e3ef4a0188 | ||
|
|
0dc01a99e9 | ||
|
|
0e782b8e99 | ||
|
|
3e9d864899 | ||
|
|
73e4702a1a | ||
|
|
93cc6bc1cf | ||
|
|
2d1185f7ec | ||
|
|
c6d4c5e943 | ||
|
|
0a536ccfda |
@@ -21,10 +21,10 @@ The database is managed via the Hasura Console where you can manage the database
|
|||||||
|
|
||||||
Hasura Console is where you manage your database. This is where you create and manage tables, schemas, and data.
|
Hasura Console is where you manage your database. This is where you create and manage tables, schemas, and data.
|
||||||
|
|
||||||
1) Open the Hasura Console by clicking on **GraphQL** in the top menu in the Nhost Dashboard.
|
1. Open the Hasura Console by clicking on **GraphQL** in the top menu in the Nhost Dashboard.
|
||||||
2) Click **Open Hasura Console** at the top right of the page.
|
2. Click **Open Hasura Console** at the top right of the page.
|
||||||
3) Copy the **admin secret**, and click **Open Hasura**.
|
3. Copy the **admin secret**, and click **Open Hasura**.
|
||||||
4) Use the **admin secret** to sign in.
|
4. Use the **admin secret** to sign in.
|
||||||
|
|
||||||
<video width="99%" autoPlay muted loop controls="true">
|
<video width="99%" autoPlay muted loop controls="true">
|
||||||
<source src="/videos/open-hasura-console.mp4" type="video/mp4" />
|
<source src="/videos/open-hasura-console.mp4" type="video/mp4" />
|
||||||
@@ -131,6 +131,21 @@ To track database changes, use the [Nhost CLI](/platform/cli) to develop locally
|
|||||||
|
|
||||||
Learn how to [get started with Nhost CLI](/platform/overview/get-started-with-nhost-cli).
|
Learn how to [get started with Nhost CLI](/platform/overview/get-started-with-nhost-cli).
|
||||||
|
|
||||||
|
## Seed Data
|
||||||
|
|
||||||
|
Seed data is a way of automatically adding data to your database using SQL when a new environment is created. This is, for the moment, only applicable when you're using the [Nhost CLI](/platform/cli) to develop locally. When you're running `nhost up` for the first time, seed data is added.
|
||||||
|
|
||||||
|
In the future, seed data will also be added to new preview environments.
|
||||||
|
|
||||||
|
Seed data should be located in `nhost/seeds/default/` and are executed in alphabetical order.
|
||||||
|
|
||||||
|
**Example:** Two seed scripts with countries and products.
|
||||||
|
|
||||||
|
```text
|
||||||
|
nhost/seeds/default/001-countries.sql
|
||||||
|
nhost/seeds/default/002-products.sql
|
||||||
|
```
|
||||||
|
|
||||||
## Backups
|
## Backups
|
||||||
|
|
||||||
Databases on [Pro and Enterprise plans](https://nhost.io/pricing) are backed up automatically.
|
Databases on [Pro and Enterprise plans](https://nhost.io/pricing) are backed up automatically.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ Launch the development environment for your app. Once the environment is up, the
|
|||||||
|
|
||||||
- Apply database migrations.
|
- Apply database migrations.
|
||||||
- Apply the Hasura metadata.
|
- Apply the Hasura metadata.
|
||||||
- Apply seed data.
|
- Apply [seed data](/platform/database#seed-data).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nhost up
|
nhost up
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ nhost.auth.signOut()
|
|||||||
nhost.auth.signOut()
|
nhost.auth.signOut()
|
||||||
```
|
```
|
||||||
|
|
||||||
### Sign out the user from all decvices
|
### Sign out the user from all devices
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
nhost.auth.signOut({ all: true })
|
nhost.auth.signOut({ all: true })
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: createMultipleFilesUploadMachine()
|
|||||||
sidebar_label: createMultipleFilesUploadMachine()
|
sidebar_label: createMultipleFilesUploadMachine()
|
||||||
slug: /reference/javascript/storage/create-multiple-files-upload-machine
|
slug: /reference/javascript/storage/create-multiple-files-upload-machine
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L28
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L37
|
||||||
---
|
---
|
||||||
|
|
||||||
# `createMultipleFilesUploadMachine()`
|
# `createMultipleFilesUploadMachine()`
|
||||||
|
|||||||
@@ -27,6 +27,6 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storag
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">\_\_namedParameters</span>** <span className="optional-status">required</span> `Partial<StorageUploadParams>`
|
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> `Partial<StorageUploadParams>`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: uploadMultipleFilesPromise()
|
|||||||
sidebar_label: uploadMultipleFilesPromise()
|
sidebar_label: uploadMultipleFilesPromise()
|
||||||
slug: /reference/javascript/storage/upload-multiple-files-promise
|
slug: /reference/javascript/storage/upload-multiple-files-promise
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/promises/multiple-files-upload.ts#L45
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/promises/multiple-files-upload.ts#L46
|
||||||
---
|
---
|
||||||
|
|
||||||
# `uploadMultipleFilesPromise()`
|
# `uploadMultipleFilesPromise()`
|
||||||
@@ -23,14 +23,15 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storag
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">service</span>** <span className="optional-status">required</span> `Interpreter<MultipleFilesUploadContext, any, { type: "ADD", files: File | Array<File> } | { type: "UPLOAD", url: string, bucketId: string, accessToken: string, adminSecret: string } | { type: "UPLOAD_PROGRESS", additions: number } | { type: "UPLOAD_DONE" } | { type: "UPLOAD_ERROR" } | { type: "CANCEL" } | { type: "REMOVE" } | { type: "CLEAR" }, { value: any, context: MultipleFilesUploadContext }, ResolveTypegenMeta<Typegen0, { type: "ADD", files: File | Array<File> } | { type: "UPLOAD", url: string, bucketId: string, accessToken: string, adminSecret: string } | { type: "UPLOAD_PROGRESS", additions: number } | { type: "UPLOAD_DONE" } | { type: "UPLOAD_ERROR" } | { type: "CANCEL" } | { type: "REMOVE" } | { type: "CLEAR" }, BaseActionObject, ServiceMap>>`
|
**<span className="parameter-name">service</span>** <span className="optional-status">required</span> `Interpreter<MultipleFilesUploadContext, any, { type: "ADD", files: AnyFileList, bucketId: string } | { type: "UPLOAD", url: string, files: AnyFileList, bucketId: string, accessToken: string, adminSecret: string } | { type: "UPLOAD_PROGRESS", additions: number } | { type: "UPLOAD_DONE" } | { type: "UPLOAD_ERROR" } | { type: "CANCEL" } | { type: "REMOVE" } | { type: "CLEAR" }, { value: any, context: MultipleFilesUploadContext }, ResolveTypegenMeta<Typegen0, { type: "ADD", files: AnyFileList, bucketId: string } | { type: "UPLOAD", url: string, files: AnyFileList, bucketId: string, accessToken: string, adminSecret: string } | { type: "UPLOAD_PROGRESS", additions: number } | { type: "UPLOAD_DONE" } | { type: "UPLOAD_ERROR" } | { type: "CANCEL" } | { type: "REMOVE" } | { type: "CLEAR" }, BaseActionObject, ServiceMap>>`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">options</span>** <span className="optional-status">required</span> [`UploadMultipleFilesActionParams`](/reference/docgen/javascript/storage/types/upload-multiple-files-action-params)
|
**<span className="parameter-name">params</span>** <span className="optional-status">optional</span> [`UploadMultipleFilesActionParams`](/reference/docgen/javascript/storage/types/upload-multiple-files-action-params)
|
||||||
|
|
||||||
| Property | Type | Required | Notes |
|
| Property | Type | Required | Notes |
|
||||||
| :------------------------------------------------------------------------------------------- | :------- | :------: | :---- |
|
| :------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------ | :------: | :---- |
|
||||||
| <span className="parameter-name"><span className="light-grey">options.</span>bucketId</span> | `string` | | |
|
| <span className="parameter-name"><span className="light-grey">params.</span>bucketId</span> | `string` | | |
|
||||||
|
| <span className="parameter-name"><span className="light-grey">params.</span>files</span> | [`AnyFileList`](/reference/docgen/javascript/storage/types/any-file-list) | | |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
# ⚠️ AUTO-GENERATED CONTENT. DO NOT EDIT THIS FILE DIRECTLY! ⚠️
|
||||||
|
title: AnyFileList
|
||||||
|
sidebar_label: AnyFileList
|
||||||
|
description: No description provided.
|
||||||
|
displayed_sidebar: referenceSidebar
|
||||||
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L9
|
||||||
|
---
|
||||||
|
|
||||||
|
# `AnyFileList`
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type AnyFileList = File | Array<File> | FileList
|
||||||
|
```
|
||||||
@@ -4,7 +4,7 @@ title: MultipleFilesUploadContext
|
|||||||
sidebar_label: MultipleFilesUploadContext
|
sidebar_label: MultipleFilesUploadContext
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L9
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L11
|
||||||
---
|
---
|
||||||
|
|
||||||
# `MultipleFilesUploadContext`
|
# `MultipleFilesUploadContext`
|
||||||
|
|||||||
@@ -4,17 +4,18 @@ title: MultipleFilesUploadEvents
|
|||||||
sidebar_label: MultipleFilesUploadEvents
|
sidebar_label: MultipleFilesUploadEvents
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L16
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L18
|
||||||
---
|
---
|
||||||
|
|
||||||
# `MultipleFilesUploadEvents`
|
# `MultipleFilesUploadEvents`
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type MultipleFilesUploadEvents =
|
type MultipleFilesUploadEvents =
|
||||||
| { type: 'ADD'; files: File | Array<File> }
|
| { type: 'ADD'; files: AnyFileList; bucketId: string }
|
||||||
| {
|
| {
|
||||||
type: 'UPLOAD'
|
type: 'UPLOAD'
|
||||||
url: string
|
url: string
|
||||||
|
files: AnyFileList
|
||||||
bucketId: string
|
bucketId: string
|
||||||
accessToken: string
|
accessToken: string
|
||||||
adminSecret: string
|
adminSecret: string
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: MultipleFilesUploadMachine
|
|||||||
sidebar_label: MultipleFilesUploadMachine
|
sidebar_label: MultipleFilesUploadMachine
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L26
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storage-js/src/packages/hasura-storage-js/src/machines/multiple-files-upload.ts#L35
|
||||||
---
|
---
|
||||||
|
|
||||||
# `MultipleFilesUploadMachine`
|
# `MultipleFilesUploadMachine`
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/hasura-storag
|
|||||||
# `UploadMultipleFilesActionParams`
|
# `UploadMultipleFilesActionParams`
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type UploadMultipleFilesActionParams = () => { bucketId: string }
|
type UploadMultipleFilesActionParams = () => { bucketId: string, files: [AnyFileList](/reference/docgen/javascript/storage/types/any-file-list) }
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: useFileUploadItem()
|
|||||||
sidebar_label: useFileUploadItem()
|
sidebar_label: useFileUploadItem()
|
||||||
slug: /reference/nextjs/use-file-upload-item
|
slug: /reference/nextjs/use-file-upload-item
|
||||||
description: Use the hook `useFileUploadItem` to control the file upload of a file in a multiple file upload.
|
description: Use the hook `useFileUploadItem` to control the file upload of a file in a multiple file upload.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L59
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L61
|
||||||
---
|
---
|
||||||
|
|
||||||
# `useFileUploadItem()`
|
# `useFileUploadItem()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: useFileUpload()
|
|||||||
sidebar_label: useFileUpload()
|
sidebar_label: useFileUpload()
|
||||||
slug: /reference/nextjs/use-file-upload
|
slug: /reference/nextjs/use-file-upload
|
||||||
description: Use the hook `useFileUpload` to upload a file.
|
description: Use the hook `useFileUpload` to upload a file.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L129
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L142
|
||||||
---
|
---
|
||||||
|
|
||||||
# `useFileUpload()`
|
# `useFileUpload()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: useMultipleFilesUpload()
|
|||||||
sidebar_label: useMultipleFilesUpload()
|
sidebar_label: useMultipleFilesUpload()
|
||||||
slug: /reference/nextjs/use-multiple-files-upload
|
slug: /reference/nextjs/use-multiple-files-upload
|
||||||
description: Use the hook `useFileUpload` to upload multiple files.
|
description: Use the hook `useFileUpload` to upload multiple files.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useMultipleFilesUpload.ts#L52
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useMultipleFilesUpload.ts#L55
|
||||||
---
|
---
|
||||||
|
|
||||||
# `useMultipleFilesUpload()`
|
# `useMultipleFilesUpload()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: FileUploadHookResult
|
|||||||
sidebar_label: FileUploadHookResult
|
sidebar_label: FileUploadHookResult
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L14
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L16
|
||||||
---
|
---
|
||||||
|
|
||||||
# `FileUploadHookResult`
|
# `FileUploadHookResult`
|
||||||
@@ -67,11 +67,11 @@ Returns the name of the file.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(file: File) => void`
|
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: StorageUploadParams) => void`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(file: File) => Promise<UploadFileHandlerResult>`
|
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: Partial<StorageUploadParams>) => Promise<UploadFileHandlerResult>`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ Returns `true` when all the files have been successfully uploaded.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(files: Array<File>) => void`
|
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: Required<Pick<UploadMultipleFilesActionParams, "files">> & UploadMultipleFilesActionParams) => void`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(options: UploadMultipleFilesActionParams) => Promise<MultipleFilesHandlerResult>`
|
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: UploadMultipleFilesActionParams) => Promise<MultipleFilesHandlerResult>`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: useFileUploadItem()
|
|||||||
sidebar_label: useFileUploadItem()
|
sidebar_label: useFileUploadItem()
|
||||||
slug: /reference/react/use-file-upload-item
|
slug: /reference/react/use-file-upload-item
|
||||||
description: Use the hook `useFileUploadItem` to control the file upload of a file in a multiple file upload.
|
description: Use the hook `useFileUploadItem` to control the file upload of a file in a multiple file upload.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L59
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L61
|
||||||
---
|
---
|
||||||
|
|
||||||
# `useFileUploadItem()`
|
# `useFileUploadItem()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: useFileUpload()
|
|||||||
sidebar_label: useFileUpload()
|
sidebar_label: useFileUpload()
|
||||||
slug: /reference/react/use-file-upload
|
slug: /reference/react/use-file-upload
|
||||||
description: Use the hook `useFileUpload` to upload a file.
|
description: Use the hook `useFileUpload` to upload a file.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L129
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L142
|
||||||
---
|
---
|
||||||
|
|
||||||
# `useFileUpload()`
|
# `useFileUpload()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: useMultipleFilesUpload()
|
|||||||
sidebar_label: useMultipleFilesUpload()
|
sidebar_label: useMultipleFilesUpload()
|
||||||
slug: /reference/react/use-multiple-files-upload
|
slug: /reference/react/use-multiple-files-upload
|
||||||
description: Use the hook `useFileUpload` to upload multiple files.
|
description: Use the hook `useFileUpload` to upload multiple files.
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useMultipleFilesUpload.ts#L52
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useMultipleFilesUpload.ts#L55
|
||||||
---
|
---
|
||||||
|
|
||||||
# `useMultipleFilesUpload()`
|
# `useMultipleFilesUpload()`
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ title: FileUploadHookResult
|
|||||||
sidebar_label: FileUploadHookResult
|
sidebar_label: FileUploadHookResult
|
||||||
description: No description provided.
|
description: No description provided.
|
||||||
displayed_sidebar: referenceSidebar
|
displayed_sidebar: referenceSidebar
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L14
|
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/react/src/useFileUpload.ts#L16
|
||||||
---
|
---
|
||||||
|
|
||||||
# `FileUploadHookResult`
|
# `FileUploadHookResult`
|
||||||
@@ -67,11 +67,11 @@ Returns the name of the file.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(file: File) => void`
|
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: StorageUploadParams) => void`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(file: File) => Promise<UploadFileHandlerResult>`
|
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: Partial<StorageUploadParams>) => Promise<UploadFileHandlerResult>`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -49,11 +49,11 @@ Returns `true` when all the files have been successfully uploaded.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(files: Array<File>) => void`
|
**<span className="parameter-name">add</span>** <span className="optional-status">required</span> `(params: Required<Pick<UploadMultipleFilesActionParams, "files">> & UploadMultipleFilesActionParams) => void`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(options: UploadMultipleFilesActionParams) => Promise<MultipleFilesHandlerResult>`
|
**<span className="parameter-name">upload</span>** <span className="optional-status">required</span> `(params: UploadMultipleFilesActionParams) => Promise<MultipleFilesHandlerResult>`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# React-Apollo example
|
# React-Apollo example
|
||||||
|
|
||||||
|
## See this example live
|
||||||
|
|
||||||
|
Visit our demo application on [react-apollo.example.nhost.io](https://react-apollo.example.nhost.io)
|
||||||
|
|
||||||
## Get started
|
## Get started
|
||||||
|
|
||||||
1. Clone the repository
|
1. Clone the repository
|
||||||
@@ -22,7 +26,7 @@ pnpm install
|
|||||||
nhost dev
|
nhost dev
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Terminal 2: Start React App
|
4. Terminal 2: Start the React application
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
pnpm run dev
|
pnpm run dev
|
||||||
|
|||||||
@@ -50,6 +50,22 @@ object_relationships:
|
|||||||
using:
|
using:
|
||||||
foreign_key_constraint_on: bucket_id
|
foreign_key_constraint_on: bucket_id
|
||||||
insert_permissions:
|
insert_permissions:
|
||||||
|
- permission:
|
||||||
|
check:
|
||||||
|
size:
|
||||||
|
_lt: 1024000
|
||||||
|
columns:
|
||||||
|
- is_uploaded
|
||||||
|
- size
|
||||||
|
- bucket_id
|
||||||
|
- etag
|
||||||
|
- mime_type
|
||||||
|
- name
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
- id
|
||||||
|
- uploaded_by_user_id
|
||||||
|
role: anonymous
|
||||||
- permission:
|
- permission:
|
||||||
check: {}
|
check: {}
|
||||||
columns:
|
columns:
|
||||||
@@ -65,6 +81,20 @@ insert_permissions:
|
|||||||
- uploaded_by_user_id
|
- uploaded_by_user_id
|
||||||
role: user
|
role: user
|
||||||
select_permissions:
|
select_permissions:
|
||||||
|
- permission:
|
||||||
|
columns:
|
||||||
|
- is_uploaded
|
||||||
|
- size
|
||||||
|
- bucket_id
|
||||||
|
- etag
|
||||||
|
- mime_type
|
||||||
|
- name
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
- id
|
||||||
|
- uploaded_by_user_id
|
||||||
|
filter: {}
|
||||||
|
role: anonymous
|
||||||
- permission:
|
- permission:
|
||||||
columns:
|
columns:
|
||||||
- is_uploaded
|
- is_uploaded
|
||||||
@@ -80,6 +110,21 @@ select_permissions:
|
|||||||
filter: {}
|
filter: {}
|
||||||
role: user
|
role: user
|
||||||
update_permissions:
|
update_permissions:
|
||||||
|
- permission:
|
||||||
|
check: {}
|
||||||
|
columns:
|
||||||
|
- is_uploaded
|
||||||
|
- size
|
||||||
|
- bucket_id
|
||||||
|
- etag
|
||||||
|
- mime_type
|
||||||
|
- name
|
||||||
|
- created_at
|
||||||
|
- updated_at
|
||||||
|
- id
|
||||||
|
- uploaded_by_user_id
|
||||||
|
filter: {}
|
||||||
|
role: anonymous
|
||||||
- permission:
|
- permission:
|
||||||
check: {}
|
check: {}
|
||||||
columns:
|
columns:
|
||||||
@@ -95,3 +140,12 @@ update_permissions:
|
|||||||
- uploaded_by_user_id
|
- uploaded_by_user_id
|
||||||
filter: {}
|
filter: {}
|
||||||
role: user
|
role: user
|
||||||
|
delete_permissions:
|
||||||
|
- permission:
|
||||||
|
backend_only: false
|
||||||
|
filter: {}
|
||||||
|
role: anonymous
|
||||||
|
- permission:
|
||||||
|
backend_only: false
|
||||||
|
filter: {}
|
||||||
|
role: user
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export const StoragePage: React.FC = () => {
|
|||||||
<Dropzone
|
<Dropzone
|
||||||
onDrop={([file]) => {
|
onDrop={([file]) => {
|
||||||
console.log('accepted file', file)
|
console.log('accepted file', file)
|
||||||
upload(file)
|
upload({ file })
|
||||||
}}
|
}}
|
||||||
onReject={(additions) => console.log('rejected files', additions)}
|
onReject={(additions) => console.log('rejected files', additions)}
|
||||||
multiple={false}
|
multiple={false}
|
||||||
@@ -163,7 +163,7 @@ export const StoragePage: React.FC = () => {
|
|||||||
<Dropzone
|
<Dropzone
|
||||||
onDrop={(additions) => {
|
onDrop={(additions) => {
|
||||||
console.log('accepted files', additions)
|
console.log('accepted files', additions)
|
||||||
add(additions)
|
add({ files: additions })
|
||||||
}}
|
}}
|
||||||
onReject={(additions) => console.log('rejected files', additions)}
|
onReject={(additions) => console.log('rejected files', additions)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useProviderLink } from '@nhost/react'
|
|||||||
import AuthLink from './AuthLink'
|
import AuthLink from './AuthLink'
|
||||||
|
|
||||||
export default function OauthLinks() {
|
export default function OauthLinks() {
|
||||||
const { github, google, facebook } = useProviderLink()
|
const { github, google, facebook } = useProviderLink({ redirectTo: window.location.origin })
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AuthLink leftIcon={<FaGithub />} link={github} color="#333">
|
<AuthLink leftIcon={<FaGithub />} link={github} color="#333">
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ if (devTools) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const nhost = new NhostClient({
|
const nhost = new NhostClient({
|
||||||
backendUrl: import.meta.env.VITE_NHOST_URL || 'http://localhost:1337',
|
subdomain: import.meta.env.VITE_NHOST_SUBDOMAIN || 'localhost:1337',
|
||||||
|
region: import.meta.env.VITE_NHOST_REGION,
|
||||||
devTools
|
devTools
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -18,15 +18,14 @@ export const EmailPassword: React.FC = () => {
|
|||||||
() => password && password !== confirmPassword && 'Should match the given password',
|
() => password && password !== confirmPassword && 'Should match the given password',
|
||||||
[password, confirmPassword]
|
[password, confirmPassword]
|
||||||
)
|
)
|
||||||
const options = useMemo(
|
|
||||||
() => ({ displayName: `${firstName} ${lastName}`, metadata: { firstName, lastName } }),
|
|
||||||
[firstName, lastName]
|
|
||||||
)
|
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { signUpEmailPassword } = useSignUpEmailPassword(options)
|
const { signUpEmailPassword } = useSignUpEmailPassword()
|
||||||
|
|
||||||
const signUp = async () => {
|
const signUp = async () => {
|
||||||
const result = await signUpEmailPassword(email, password, { metadata: { firstName, lastName } })
|
const result = await signUpEmailPassword(email, password, {
|
||||||
|
metadata: { firstName, lastName, displayName: `${firstName} ${lastName}` },
|
||||||
|
redirectTo: window.location.origin
|
||||||
|
})
|
||||||
if (result.isError) {
|
if (result.isError) {
|
||||||
showNotification({
|
showNotification({
|
||||||
color: 'red',
|
color: 'red',
|
||||||
|
|||||||
3
examples/react-apollo/vercel.json
Normal file
3
examples/react-apollo/vercel.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"rewrites": [{ "source": "/(.*)", "destination": "/" }]
|
||||||
|
}
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/apollo
|
# @nhost/apollo
|
||||||
|
|
||||||
|
## 0.5.20
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@1.4.4
|
||||||
|
|
||||||
## 0.5.19
|
## 0.5.19
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/apollo",
|
"name": "@nhost/apollo",
|
||||||
"version": "0.5.19",
|
"version": "0.5.20",
|
||||||
"description": "Nhost Apollo Client library",
|
"description": "Nhost Apollo Client library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @nhost/hasura-storage-js
|
# @nhost/hasura-storage-js
|
||||||
|
|
||||||
|
## 0.5.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 4f928756: Extend file upload parameters
|
||||||
|
|
||||||
|
- `bucketId` is available everywhere as an option
|
||||||
|
- It is possible to pass files as a parameter on a multiple `upload`, making the `add` action optional.
|
||||||
|
- The `add` and `upload` actions of multiple file upload accepts both a `File`, an array of `File` items, and a `FileList`
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/hasura-storage-js",
|
"name": "@nhost/hasura-storage-js",
|
||||||
"version": "0.4.0",
|
"version": "0.5.0",
|
||||||
"description": "Hasura-storage client",
|
"description": "Hasura-storage client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -156,9 +156,9 @@ export const createFileUploadMachine = () =>
|
|||||||
type: 'UPLOAD_ERROR',
|
type: 'UPLOAD_ERROR',
|
||||||
error: {
|
error: {
|
||||||
status: response?.status ?? 0,
|
status: response?.status ?? 0,
|
||||||
message: response?.data.error?.message || message,
|
message: response?.data?.error?.message || message,
|
||||||
// TODO errors from hasura-storage are not codified
|
// TODO errors from hasura-storage are not codified
|
||||||
error: response?.data.error?.message || message
|
error: response?.data?.error?.message || message
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ const { pure, sendParent } = actions
|
|||||||
|
|
||||||
export type FileItemRef = ActorRefFrom<FileUploadMachine>
|
export type FileItemRef = ActorRefFrom<FileUploadMachine>
|
||||||
|
|
||||||
|
export type AnyFileList = File | File[] | FileList
|
||||||
|
|
||||||
export type MultipleFilesUploadContext = {
|
export type MultipleFilesUploadContext = {
|
||||||
progress: number | null
|
progress: number | null
|
||||||
files: FileItemRef[]
|
files: FileItemRef[]
|
||||||
@@ -14,8 +16,15 @@ export type MultipleFilesUploadContext = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type MultipleFilesUploadEvents =
|
export type MultipleFilesUploadEvents =
|
||||||
| { type: 'ADD'; files: File | File[] }
|
| { type: 'ADD'; files: AnyFileList; bucketId?: string }
|
||||||
| { type: 'UPLOAD'; url: string; bucketId?: string; accessToken?: string; adminSecret?: string }
|
| {
|
||||||
|
type: 'UPLOAD'
|
||||||
|
url: string
|
||||||
|
files?: AnyFileList
|
||||||
|
bucketId?: string
|
||||||
|
accessToken?: string
|
||||||
|
adminSecret?: string
|
||||||
|
}
|
||||||
| { type: 'UPLOAD_PROGRESS'; additions: number }
|
| { type: 'UPLOAD_PROGRESS'; additions: number }
|
||||||
| { type: 'UPLOAD_DONE' }
|
| { type: 'UPLOAD_DONE' }
|
||||||
| { type: 'UPLOAD_ERROR' }
|
| { type: 'UPLOAD_ERROR' }
|
||||||
@@ -42,7 +51,7 @@ export const createMultipleFilesUploadMachine = () => {
|
|||||||
},
|
},
|
||||||
initial: 'idle',
|
initial: 'idle',
|
||||||
on: {
|
on: {
|
||||||
UPLOAD: { cond: 'hasFileToDownload', target: 'uploading' },
|
UPLOAD: { cond: 'hasFileToDownload', actions: 'addItem', target: 'uploading' },
|
||||||
ADD: { actions: 'addItem' },
|
ADD: { actions: 'addItem' },
|
||||||
REMOVE: { actions: 'removeItem' }
|
REMOVE: { actions: 'removeItem' }
|
||||||
},
|
},
|
||||||
@@ -83,8 +92,8 @@ export const createMultipleFilesUploadMachine = () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
guards: {
|
guards: {
|
||||||
hasFileToDownload: (context) =>
|
hasFileToDownload: (context, event) =>
|
||||||
context.files.some((ref) => ref.getSnapshot()!.matches('idle')),
|
context.files.some((ref) => ref.getSnapshot()!.matches('idle')) || !!event.files,
|
||||||
isAllUploaded: (context) =>
|
isAllUploaded: (context) =>
|
||||||
context.files.every((item) => item.getSnapshot()?.matches('uploaded')),
|
context.files.every((item) => item.getSnapshot()?.matches('uploaded')),
|
||||||
isAllUploadedOrError: (context) =>
|
isAllUploadedOrError: (context) =>
|
||||||
@@ -118,8 +127,14 @@ export const createMultipleFilesUploadMachine = () => {
|
|||||||
resetLoaded: assign({ loaded: (_) => 0 }),
|
resetLoaded: assign({ loaded: (_) => 0 }),
|
||||||
startProgress: assign({ progress: (_) => 0 }),
|
startProgress: assign({ progress: (_) => 0 }),
|
||||||
resetProgress: assign({ progress: (_) => null }),
|
resetProgress: assign({ progress: (_) => null }),
|
||||||
addItem: assign((context, { files }) => {
|
addItem: assign((context, { files, bucketId }) => {
|
||||||
const additions = Array.isArray(files) ? files : [files]
|
const additions = files
|
||||||
|
? Array.isArray(files)
|
||||||
|
? files // File[]
|
||||||
|
: 'length' in files // FileList
|
||||||
|
? Array.from(files)
|
||||||
|
: [files] // File
|
||||||
|
: [] // No file
|
||||||
const total = context.total + additions.reduce((agg, curr) => agg + curr.size, 0)
|
const total = context.total + additions.reduce((agg, curr) => agg + curr.size, 0)
|
||||||
const progress = Math.round((context.loaded * 100) / total)
|
const progress = Math.round((context.loaded * 100) / total)
|
||||||
return {
|
return {
|
||||||
@@ -139,7 +154,7 @@ export const createMultipleFilesUploadMachine = () => {
|
|||||||
sendDestroy: sendParent('REMOVE')
|
sendDestroy: sendParent('REMOVE')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.withContext({ ...INITIAL_FILE_CONTEXT, file }),
|
.withContext({ ...INITIAL_FILE_CONTEXT, file, bucketId }),
|
||||||
{ sync: true }
|
{ sync: true }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
export interface Typegen0 {
|
export interface Typegen0 {
|
||||||
'@@xstate/typegen': true
|
'@@xstate/typegen': true
|
||||||
eventsCausingActions: {
|
eventsCausingActions: {
|
||||||
addItem: 'ADD'
|
addItem: 'UPLOAD' | 'ADD'
|
||||||
removeItem: 'REMOVE'
|
removeItem: 'REMOVE'
|
||||||
clearList: 'CLEAR'
|
clearList: 'CLEAR'
|
||||||
incrementProgress: 'UPLOAD_PROGRESS'
|
incrementProgress: 'UPLOAD_PROGRESS'
|
||||||
|
|||||||
@@ -40,18 +40,15 @@ export interface FileUploadState extends UploadFileHandlerResult, UploadProgress
|
|||||||
export const uploadFilePromise = async (
|
export const uploadFilePromise = async (
|
||||||
nhost: NhostClientReturnType,
|
nhost: NhostClientReturnType,
|
||||||
interpreter: FileItemRef | InterpreterFrom<FileUploadMachine>,
|
interpreter: FileItemRef | InterpreterFrom<FileUploadMachine>,
|
||||||
{ file, bucketId, id, name }: Partial<StorageUploadParams>
|
params: Partial<StorageUploadParams>
|
||||||
): Promise<UploadFileHandlerResult> =>
|
): Promise<UploadFileHandlerResult> =>
|
||||||
new Promise<UploadFileHandlerResult>((resolve) => {
|
new Promise<UploadFileHandlerResult>((resolve) => {
|
||||||
interpreter.send({
|
interpreter.send({
|
||||||
type: 'UPLOAD',
|
type: 'UPLOAD',
|
||||||
url: nhost.storage.url,
|
url: nhost.storage.url,
|
||||||
file,
|
|
||||||
accessToken: nhost.auth.getAccessToken(),
|
accessToken: nhost.auth.getAccessToken(),
|
||||||
adminSecret: nhost.adminSecret,
|
adminSecret: nhost.adminSecret,
|
||||||
bucketId,
|
...params
|
||||||
id,
|
|
||||||
name
|
|
||||||
})
|
})
|
||||||
interpreter.subscribe((s) => {
|
interpreter.subscribe((s) => {
|
||||||
if (s.matches('error')) {
|
if (s.matches('error')) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { InterpreterFrom } from 'xstate'
|
import { InterpreterFrom } from 'xstate'
|
||||||
|
|
||||||
import { FileItemRef, MultipleFilesUploadMachine } from '../machines'
|
import { AnyFileList, FileItemRef, MultipleFilesUploadMachine } from '../machines'
|
||||||
import { NhostClientReturnType } from '../utils/types'
|
import { NhostClientReturnType } from '../utils/types'
|
||||||
|
|
||||||
export interface MultipleUploadProgressState {
|
export interface MultipleUploadProgressState {
|
||||||
@@ -39,22 +39,23 @@ export interface MultipleFilesUploadState
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type UploadMultipleFilesActionParams = {
|
export type UploadMultipleFilesActionParams = {
|
||||||
|
files?: AnyFileList
|
||||||
bucketId?: string
|
bucketId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const uploadMultipleFilesPromise = async (
|
export const uploadMultipleFilesPromise = async (
|
||||||
nhost: NhostClientReturnType,
|
nhost: NhostClientReturnType,
|
||||||
service: InterpreterFrom<MultipleFilesUploadMachine>,
|
service: InterpreterFrom<MultipleFilesUploadMachine>,
|
||||||
options: UploadMultipleFilesActionParams = { bucketId: 'default' }
|
params?: UploadMultipleFilesActionParams
|
||||||
): Promise<MultipleFilesHandlerResult> =>
|
): Promise<MultipleFilesHandlerResult> =>
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
const { bucketId } = options
|
|
||||||
service.send({
|
service.send({
|
||||||
type: 'UPLOAD',
|
type: 'UPLOAD',
|
||||||
url: nhost.storage.url,
|
url: nhost.storage.url,
|
||||||
bucketId,
|
|
||||||
accessToken: nhost.auth.getAccessToken(),
|
accessToken: nhost.auth.getAccessToken(),
|
||||||
adminSecret: nhost.adminSecret
|
adminSecret: nhost.adminSecret,
|
||||||
|
bucketId: params?.bucketId,
|
||||||
|
files: params?.files
|
||||||
})
|
})
|
||||||
service.onTransition((s) => {
|
service.onTransition((s) => {
|
||||||
if (s.matches('error')) {
|
if (s.matches('error')) {
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @nhost/nextjs
|
# @nhost/nextjs
|
||||||
|
|
||||||
|
## 1.6.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [4f928756]
|
||||||
|
- @nhost/react@0.11.0
|
||||||
|
- @nhost/nhost-js@1.4.4
|
||||||
|
|
||||||
## 1.5.0
|
## 1.5.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nextjs",
|
"name": "@nhost/nextjs",
|
||||||
"version": "1.5.0",
|
"version": "1.6.0",
|
||||||
"description": "Nhost NextJS library",
|
"description": "Nhost NextJS library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @nhost/nhost-js
|
# @nhost/nhost-js
|
||||||
|
|
||||||
|
## 1.4.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [4f928756]
|
||||||
|
- @nhost/hasura-storage-js@0.5.0
|
||||||
|
|
||||||
## 1.4.3
|
## 1.4.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nhost-js",
|
"name": "@nhost/nhost-js",
|
||||||
"version": "1.4.3",
|
"version": "1.4.4",
|
||||||
"description": "Nhost JavaScript SDK",
|
"description": "Nhost JavaScript SDK",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# @nhost/react-apollo
|
# @nhost/react-apollo
|
||||||
|
|
||||||
|
## 4.6.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [4f928756]
|
||||||
|
- @nhost/react@0.11.0
|
||||||
|
- @nhost/apollo@0.5.20
|
||||||
|
|
||||||
## 4.5.0
|
## 4.5.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-apollo",
|
"name": "@nhost/react-apollo",
|
||||||
"version": "4.5.0",
|
"version": "4.6.0",
|
||||||
"description": "Nhost React Apollo client",
|
"description": "Nhost React Apollo client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @nhost/react-auth
|
# @nhost/react-auth
|
||||||
|
|
||||||
|
## 3.4.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [4f928756]
|
||||||
|
- @nhost/react@0.11.0
|
||||||
|
|
||||||
## 3.3.0
|
## 3.3.0
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-auth",
|
"name": "@nhost/react-auth",
|
||||||
"version": "3.3.0",
|
"version": "3.4.0",
|
||||||
"description": "Nhost React client",
|
"description": "Nhost React client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
# @nhost/react
|
# @nhost/react
|
||||||
|
|
||||||
|
## 0.11.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- 4f928756: Extend file upload parameters
|
||||||
|
|
||||||
|
- `bucketId` is available everywhere as an option
|
||||||
|
- It is possible to pass files as a parameter on a multiple `upload`, making the `add` action optional.
|
||||||
|
- The `add` and `upload` actions of multiple file upload accepts both a `File`, an array of `File` items, and a `FileList`
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [4f928756]
|
||||||
|
- @nhost/hasura-storage-js@0.5.0
|
||||||
|
- @nhost/nhost-js@1.4.4
|
||||||
|
|
||||||
## 0.10.0
|
## 0.10.0
|
||||||
|
|
||||||
### Minor Changes
|
### Minor Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react",
|
"name": "@nhost/react",
|
||||||
"version": "0.10.0",
|
"version": "0.11.0",
|
||||||
"description": "Nhost React library",
|
"description": "Nhost React library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -5,22 +5,24 @@ import {
|
|||||||
FileItemRef,
|
FileItemRef,
|
||||||
FileUploadMachine,
|
FileUploadMachine,
|
||||||
FileUploadState,
|
FileUploadState,
|
||||||
|
StorageUploadParams,
|
||||||
UploadFileHandlerResult,
|
UploadFileHandlerResult,
|
||||||
uploadFilePromise
|
uploadFilePromise
|
||||||
} from '@nhost/hasura-storage-js'
|
} from '@nhost/hasura-storage-js'
|
||||||
import { useInterpret, useSelector } from '@xstate/react'
|
import { useInterpret, useSelector } from '@xstate/react'
|
||||||
|
|
||||||
import { useNhostClient } from './useNhostClient'
|
import { useNhostClient } from './useNhostClient'
|
||||||
|
|
||||||
export interface FileUploadHookResult extends FileUploadState {
|
export interface FileUploadHookResult extends FileUploadState {
|
||||||
/**
|
/**
|
||||||
* Add the file without uploading it.
|
* Add the file without uploading it.
|
||||||
*/
|
*/
|
||||||
add: (file: File) => void
|
add: (params: StorageUploadParams) => void
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload the file given as a parameter, or that has been previously added.
|
* Upload the file given as a parameter, or that has been previously added.
|
||||||
*/
|
*/
|
||||||
upload: (file?: File) => Promise<UploadFileHandlerResult>
|
upload: (params: Partial<StorageUploadParams>) => Promise<UploadFileHandlerResult>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the ongoing upload.
|
* Cancel the ongoing upload.
|
||||||
@@ -61,11 +63,21 @@ export const useFileUploadItem = (
|
|||||||
): FileUploadHookResult => {
|
): FileUploadHookResult => {
|
||||||
const nhost = useNhostClient()
|
const nhost = useNhostClient()
|
||||||
|
|
||||||
const add = (file: File) => {
|
const add = (params: StorageUploadParams) => {
|
||||||
ref.send({ type: 'ADD', file })
|
ref.send({
|
||||||
|
type: 'ADD',
|
||||||
|
file: params.file,
|
||||||
|
bucketId: params.bucketId || bucketId
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const upload = (file?: File) => uploadFilePromise(nhost, ref, { file, bucketId, id, name })
|
const upload = (params: Partial<StorageUploadParams>) =>
|
||||||
|
uploadFilePromise(nhost, ref, {
|
||||||
|
file: params.file,
|
||||||
|
bucketId: params.bucketId || bucketId,
|
||||||
|
id,
|
||||||
|
name
|
||||||
|
})
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
ref.send('CANCEL')
|
ref.send('CANCEL')
|
||||||
@@ -106,15 +118,16 @@ export const useFileUploadItem = (
|
|||||||
* @example
|
* @example
|
||||||
* ```tsx
|
* ```tsx
|
||||||
* const { add,
|
* const { add,
|
||||||
upload,
|
* upload,
|
||||||
cancel,
|
* cancel,
|
||||||
isUploaded,
|
* isUploaded,
|
||||||
isUploading,
|
* isUploading,
|
||||||
isError,
|
* isError,
|
||||||
progress,
|
* progress,
|
||||||
id,
|
* id,
|
||||||
bucketId,
|
* bucketId,
|
||||||
name } = useFileUpload();
|
* name
|
||||||
|
* } = useFileUpload();
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* const handleFormSubmit = async (e) => {
|
* const handleFormSubmit = async (e) => {
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ export interface MultipleFilesHookResult extends MultipleFilesUploadState {
|
|||||||
/**
|
/**
|
||||||
* Add one or multiple files to add to the list of files to upload.
|
* Add one or multiple files to add to the list of files to upload.
|
||||||
*/
|
*/
|
||||||
add: (files: File[]) => void
|
add: (
|
||||||
|
params: Required<Pick<UploadMultipleFilesActionParams, 'files'>> &
|
||||||
|
UploadMultipleFilesActionParams
|
||||||
|
) => void
|
||||||
/**
|
/**
|
||||||
* Upload the files that has been previously added to the list.
|
* Upload the files that has been previously added to the list.
|
||||||
*/
|
*/
|
||||||
upload: (options?: UploadMultipleFilesActionParams) => Promise<MultipleFilesHandlerResult>
|
upload: (params?: UploadMultipleFilesActionParams) => Promise<MultipleFilesHandlerResult>
|
||||||
/**
|
/**
|
||||||
* Cancel the ongoing upload. The files that have been successfully uploaded will not be deleted from the server.
|
* Cancel the ongoing upload. The files that have been successfully uploaded will not be deleted from the server.
|
||||||
*/
|
*/
|
||||||
@@ -38,8 +41,8 @@ export interface MultipleFilesHookResult extends MultipleFilesUploadState {
|
|||||||
* ```tsx
|
* ```tsx
|
||||||
* const { upload, add, clear, progress, isUploaded, isUploading, files, isError, cancel } = useMultipleFilesUpload()
|
* const { upload, add, clear, progress, isUploaded, isUploading, files, isError, cancel } = useMultipleFilesUpload()
|
||||||
*
|
*
|
||||||
* const addFile = async (file: File) => {
|
* const addFile = async (files: File | File[] | FileList) => {
|
||||||
* add(file)
|
* add({ files })
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* const handleSubmit = async (e) => {
|
* const handleSubmit = async (e) => {
|
||||||
@@ -61,12 +64,15 @@ export const useMultipleFilesUpload = (): MultipleFilesHookResult => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const add = (files: File | File[]) => {
|
const add = (
|
||||||
service.send('ADD', { files })
|
params: Required<Pick<UploadMultipleFilesActionParams, 'files'>> &
|
||||||
|
UploadMultipleFilesActionParams
|
||||||
|
) => {
|
||||||
|
service.send({ type: 'ADD', ...params })
|
||||||
}
|
}
|
||||||
|
|
||||||
const upload = (options: UploadMultipleFilesActionParams = { bucketId: 'default' }) =>
|
const upload = (params?: UploadMultipleFilesActionParams) =>
|
||||||
uploadMultipleFilesPromise(nhost, service, options)
|
uploadMultipleFilesPromise(nhost, service, params)
|
||||||
|
|
||||||
const cancel = () => {
|
const cancel = () => {
|
||||||
service.send('CANCEL')
|
service.send('CANCEL')
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/vue
|
# @nhost/vue
|
||||||
|
|
||||||
|
## 0.3.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@1.4.4
|
||||||
|
|
||||||
## 0.3.3
|
## 0.3.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/vue",
|
"name": "@nhost/vue",
|
||||||
"version": "0.3.3",
|
"version": "0.3.4",
|
||||||
"description": "Nhost Vue library",
|
"description": "Nhost Vue library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"outputs": ["dist/**", "umd/**", "build/**", ".next"]
|
"outputs": ["dist/**", "umd/**", "build/**", ".next"]
|
||||||
},
|
},
|
||||||
|
"@nhost-examples/react-apollo#build": {
|
||||||
|
"dependsOn": ["^build", "$VITE_NHOST_SUBDOMAIN", "$VITE_NHOST_REGION"],
|
||||||
|
"outputs": ["dist/**"]
|
||||||
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"dependsOn": ["^build"],
|
"dependsOn": ["^build"],
|
||||||
"outputs": ["coverage/**"]
|
"outputs": ["coverage/**"]
|
||||||
|
|||||||
Reference in New Issue
Block a user