diff --git a/dashboard/CHANGELOG.md b/dashboard/CHANGELOG.md index 261f26f60d..d3024a9e7a 100644 --- a/dashboard/CHANGELOG.md +++ b/dashboard/CHANGELOG.md @@ -1,5 +1,12 @@ # @nhost/dashboard +## 1.6.5 + +### Patch Changes + +- ba73bb4: fix: update ErrorToast component to show the internal graphql error +- d5337ff: fix: utilize accumulator in the creation of validation schema within data grid utils + ## 1.6.4 ### Patch Changes diff --git a/dashboard/package.json b/dashboard/package.json index 5243b803b6..514a3195ce 100644 --- a/dashboard/package.json +++ b/dashboard/package.json @@ -1,6 +1,6 @@ { "name": "@nhost/dashboard", - "version": "1.6.4", + "version": "1.6.5", "private": true, "scripts": { "preinstall": "npx only-allow pnpm", diff --git a/dashboard/src/components/ui/v2/ErrorToast/ErrorToast.tsx b/dashboard/src/components/ui/v2/ErrorToast/ErrorToast.tsx index 5fc3381a98..fc8b27428c 100644 --- a/dashboard/src/components/ui/v2/ErrorToast/ErrorToast.tsx +++ b/dashboard/src/components/ui/v2/ErrorToast/ErrorToast.tsx @@ -46,7 +46,16 @@ export default function ErrorToast({ error, }; - const msg = error?.graphQLErrors?.at(0)?.message || errorMessage; + const internalError = error?.graphQLErrors?.at(0)?.extensions?.internal as { + error: { + message: string; + }; + }; + + const msg = + internalError?.error?.message || + error?.graphQLErrors?.at(0).message || + errorMessage; return ( diff --git a/dashboard/src/features/database/dataGrid/utils/validationSchemaHelpers/validationSchemaHelpers.ts b/dashboard/src/features/database/dataGrid/utils/validationSchemaHelpers/validationSchemaHelpers.ts index d83ccfe54c..e3f47760d2 100644 --- a/dashboard/src/features/database/dataGrid/utils/validationSchemaHelpers/validationSchemaHelpers.ts +++ b/dashboard/src/features/database/dataGrid/utils/validationSchemaHelpers/validationSchemaHelpers.ts @@ -114,7 +114,7 @@ export function createDynamicValidationSchema( ['time', 'timetz', 'interval'].includes(column.specificType) ) { return { - ...schema, + ...currentSchema, [column.id]: createTextValidationSchema(details).matches( /^\d{2}:\d{2}(:\d{2})?$/, 'This is not a valid time (e.g: HH:MM:SS / HH:MM).', @@ -124,14 +124,14 @@ export function createDynamicValidationSchema( if (column.type === 'date') { return { - ...schema, + ...currentSchema, [column.id]: createDateValidationSchema(details), }; } if (column.type === 'boolean') { return { - ...schema, + ...currentSchema, [column.id]: createBooleanValidationSchema(details), }; } @@ -141,13 +141,13 @@ export function createDynamicValidationSchema( (column.specificType === 'jsonb' || column.specificType === 'json') ) { return { - ...schema, + ...currentSchema, [column.id]: createJSONValidationSchema(details), }; } return { - ...schema, + ...currentSchema, [column.id]: createTextValidationSchema(details), }; }, {}); diff --git a/docs/guides/cli/configuration-overlays.mdx b/docs/guides/cli/configuration-overlays.mdx index fac9ecddea..19aa6d067c 100644 --- a/docs/guides/cli/configuration-overlays.mdx +++ b/docs/guides/cli/configuration-overlays.mdx @@ -1,6 +1,6 @@ --- title: Configuration Overlays -description: description +description: Learn how to use Configuration Overlays icon: circles-overlap --- diff --git a/docs/guides/cli/local-development.mdx b/docs/guides/cli/local-development.mdx index f47e3509ff..4232d6bba1 100644 --- a/docs/guides/cli/local-development.mdx +++ b/docs/guides/cli/local-development.mdx @@ -1,6 +1,6 @@ --- title: Local Development -description: description +description: Learn how to start a development instance of Nhost icon: code --- diff --git a/docs/guides/cli/migrate-config.mdx b/docs/guides/cli/migrate-config.mdx index 3f2e6b2fa8..08af31344c 100644 --- a/docs/guides/cli/migrate-config.mdx +++ b/docs/guides/cli/migrate-config.mdx @@ -1,6 +1,6 @@ --- -title: Migrate Existing Projects -description: description +title: Migrate to Nhost Config +description: Learn how to migrate old projects to use the new configuration file icon: arrow-down-to-bracket --- diff --git a/docs/guides/cli/multiple-projects.mdx b/docs/guides/cli/multiple-projects.mdx index 5c2661f084..f11b73ce4b 100644 --- a/docs/guides/cli/multiple-projects.mdx +++ b/docs/guides/cli/multiple-projects.mdx @@ -1,6 +1,6 @@ --- -title: 'Running multiple projects at the same time' -description: 'description' +title: 'Running Multiple Projects' +description: Learn how to run multiple Nhost projects locally icon: clone --- diff --git a/docs/guides/cli/seeds.mdx b/docs/guides/cli/seeds.mdx index 600f670f83..9381b93543 100644 --- a/docs/guides/cli/seeds.mdx +++ b/docs/guides/cli/seeds.mdx @@ -1,6 +1,6 @@ --- title: 'Seeds' -description: description +description: Learn about using seeds to populate your local database icon: peapod --- diff --git a/docs/guides/run/cli-deployments.mdx b/docs/guides/run/cli-deployments.mdx index 66e276e407..d466755bd8 100644 --- a/docs/guides/run/cli-deployments.mdx +++ b/docs/guides/run/cli-deployments.mdx @@ -1,6 +1,6 @@ --- title: CLI & CI Deployments -description: description +description: Learn how to deploy your Run services using the CLI icon: rocket-launch --- diff --git a/docs/guides/run/configuration.mdx b/docs/guides/run/configuration.mdx index b0a2e70552..3e60a89236 100644 --- a/docs/guides/run/configuration.mdx +++ b/docs/guides/run/configuration.mdx @@ -1,6 +1,6 @@ --- title: Configuration -description: Configure +description: Learn how to configure a Run service icon: gear --- diff --git a/docs/guides/run/health-checks.mdx b/docs/guides/run/health-checks.mdx index 796b2380b1..f9b8e4ac49 100644 --- a/docs/guides/run/health-checks.mdx +++ b/docs/guides/run/health-checks.mdx @@ -1,6 +1,6 @@ --- title: Healthchecks -description: description +description: Learn how to enable healthchecks for your services icon: heart-pulse --- diff --git a/docs/guides/run/networking.mdx b/docs/guides/run/networking.mdx index 892e8a860e..df5f55f91d 100644 --- a/docs/guides/run/networking.mdx +++ b/docs/guides/run/networking.mdx @@ -1,6 +1,6 @@ --- title: Networking -description: descriptioon +description: Learn how networking works with Run icon: network-wired --- diff --git a/docs/guides/run/registry.mdx b/docs/guides/run/registry.mdx index bfc820b763..5f9b193590 100644 --- a/docs/guides/run/registry.mdx +++ b/docs/guides/run/registry.mdx @@ -1,6 +1,6 @@ --- title: Registry -description: registru +description: Learn how to use a private registry for your images icon: box-archive --- diff --git a/docs/guides/run/resources.mdx b/docs/guides/run/resources.mdx index c0595b5c08..e08c2ceebd 100644 --- a/docs/guides/run/resources.mdx +++ b/docs/guides/run/resources.mdx @@ -1,6 +1,6 @@ --- title: Resources -description: description +description: Learn about compute resources icon: gauge-max --- diff --git a/docs/mint.json b/docs/mint.json index 7cd825ca93..3b85c409ba 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -335,6 +335,14 @@ "reference/javascript/graphql/set-access-token", "reference/javascript/graphql/request" ] + }, + { + "group": "Functions ", + "pages": [ + "reference/javascript/functions/create-functions-client", + "reference/javascript/functions/call", + "reference/javascript/functions/set-access-token" + ] } ] }, diff --git a/docs/product/functions.mdx b/docs/product/functions.mdx index b0bcd89024..cece70efa9 100644 --- a/docs/product/functions.mdx +++ b/docs/product/functions.mdx @@ -1,12 +1,14 @@ --- title: Functions -description: Server-side code that works as API endpoints +description: Server-side code that works as API endpoints icon: code --- Nhost Functions are server-side JavaScript or TypeScript functions that are a great option for handling things like Event Triggers for async workflows, as well as to integrate with external service providers like Stripe or Slack. -For more sophisticated use-cases and control over the runtime, use [Nhost Run](/product/run). + + For more sophisticated use-cases and control over the runtime, use [Nhost Run](/product/run). + ## Hello World @@ -21,7 +23,5 @@ Deploying functions is as easy as pushing your code! ## Additional Resources - - + - diff --git a/docs/reference/javascript/functions/call.mdx b/docs/reference/javascript/functions/call.mdx new file mode 100644 index 0000000000..4b7c1d27ba --- /dev/null +++ b/docs/reference/javascript/functions/call.mdx @@ -0,0 +1,70 @@ +--- +title: call() +sidebarTitle: call() +--- + +Use `nhost.functions.call` to call (sending a POST request to) a serverless function. Use generic +types to specify the expected response data, request body and error message. + +```ts +await nhost.functions.call('send-welcome-email', { + email: 'joe@example.com', + name: 'Joe Doe' +}) +``` + +## Parameters + +--- + +**url** required string + +--- + +**body** optional null | TBody + +--- + +**config** optional NhostFunctionCallConfig + +--- + +## Examples + +### Without generic types + +```ts +await nhost.functions.call('send-welcome-email', { + email: 'joe@example.com', + name: 'Joe Doe' +}) +``` + +### Using generic types + +```ts +type Data = { + message: string +} + +type Body = { + email: string + name: string +} + +type ErrorMessage = { + details: string +} + +// The function will only accept a body of type `Body` +const { res, error } = await nhost.functions.call( + 'send-welcome-email', + { email: 'joe@example.com', name: 'Joe Doe' } +) + +// Now the response data is typed as `Data` +console.log(res?.data.message) + +// Now the error message is typed as `ErrorMessage` +console.log(error?.message.details) +``` diff --git a/docs/reference/javascript/functions/create-functions-client.mdx b/docs/reference/javascript/functions/create-functions-client.mdx new file mode 100644 index 0000000000..c4020f603b --- /dev/null +++ b/docs/reference/javascript/functions/create-functions-client.mdx @@ -0,0 +1,31 @@ +--- +title: createFunctionsClient() +sidebarTitle: createFunctionsClient() +--- + +Creates a client for Functions from either a subdomain or a URL + +## Parameters + +--- + +**params** required [`NhostClientConstructorParams`](/reference/javascript/nhost-js/types/nhost-client-constructor-params) + +| Property | Type | Required | Notes | +| :----------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------ | :------: | :--------------------------------------------------------------------------------------------------------------------------------------- | +| params.adminSecret | string | | When set, the admin secret is sent as a header, `x-hasura-admin-secret`, for all requests to GraphQL, Storage, and Serverless Functions. | +| params.functionsUrl | string | | | +| params.storageUrl | string | | | +| params.graphqlUrl | string | | | +| params.authUrl | string | | | +| params.region | string | | Project region (e.g. `eu-central-1`) Project region is not required during local development (when `subdomain` is `localhost`) | +| params.subdomain | string | | Project subdomain (e.g. `ieingiwnginwnfnegqwvdqwdwq`) Use `localhost` during local development | +| params.devTools | boolean | | Activate devTools e.g. the ability to connect to the xstate inspector | +| params.autoSignIn | boolean | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with | +| params.autoRefreshToken | boolean | | When set to true, will automatically refresh token before it expires | +| params.clientStorage | [`ClientStorage`](/reference/javascript/nhost-js/types/client-storage) | | Object where the refresh token will be persisted and read locally. | +| params.clientStorageType | [`ClientStorageType`](/reference/javascript/nhost-js/types/client-storage-type) | | Define a way to get information about the refresh token and its exipration date. | +| params.refreshIntervalTime | number | | Time interval until token refreshes, in seconds | +| params.start | boolean | | | + +--- diff --git a/docs/reference/javascript/functions/nhost-functions-client.mdx b/docs/reference/javascript/functions/nhost-functions-client.mdx new file mode 100644 index 0000000000..07c9d3d720 --- /dev/null +++ b/docs/reference/javascript/functions/nhost-functions-client.mdx @@ -0,0 +1,13 @@ +--- +title: NhostFunctionsClient +--- + +# `NhostFunctionsClient` + +## Parameters + +--- + +**params** required NhostFunctionsConstructorParams + +--- diff --git a/docs/reference/javascript/functions/set-access-token.mdx b/docs/reference/javascript/functions/set-access-token.mdx new file mode 100644 index 0000000000..d137f70484 --- /dev/null +++ b/docs/reference/javascript/functions/set-access-token.mdx @@ -0,0 +1,18 @@ +--- +title: setAccessToken() +sidebarTitle: setAccessToken() +--- + +Use `nhost.functions.setAccessToken` to a set an access token to be used in subsequent functions requests. Note that if you're signin in users with `nhost.auth.signIn()` the access token will be set automatically. + +```ts +nhost.functions.setAccessToken('some-access-token') +``` + +## Parameters + +--- + +**accessToken** required undefined | string + +---