Skip to content

Commit

Permalink
Merge upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sync Fork committed Jan 27, 2024
1 parent fb25e06 commit b50a6e9
Show file tree
Hide file tree
Showing 21 changed files with 181 additions and 25 deletions.
7 changes: 7 additions & 0 deletions dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "1.6.4",
"version": "1.6.5",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down
11 changes: 10 additions & 1 deletion dashboard/src/components/ui/v2/ErrorToast/ErrorToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<AnimatePresence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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).',
Expand All @@ -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),
};
}
Expand All @@ -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),
};
}, {});
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/cli/configuration-overlays.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Configuration Overlays
description: description
description: Learn how to use Configuration Overlays
icon: circles-overlap
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/cli/local-development.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Local Development
description: description
description: Learn how to start a development instance of Nhost
icon: code
---

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/cli/migrate-config.mdx
Original file line number Diff line number Diff line change
@@ -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
---

Expand Down
4 changes: 2 additions & 2 deletions docs/guides/cli/multiple-projects.mdx
Original file line number Diff line number Diff line change
@@ -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
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/cli/seeds.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: 'Seeds'
description: description
description: Learn about using seeds to populate your local database
icon: peapod
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/run/cli-deployments.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: CLI & CI Deployments
description: description
description: Learn how to deploy your Run services using the CLI
icon: rocket-launch
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/run/configuration.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Configuration
description: Configure
description: Learn how to configure a Run service
icon: gear
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/run/health-checks.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Healthchecks
description: description
description: Learn how to enable healthchecks for your services
icon: heart-pulse
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/run/networking.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Networking
description: descriptioon
description: Learn how networking works with Run
icon: network-wired
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/run/registry.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Registry
description: registru
description: Learn how to use a private registry for your images
icon: box-archive
---

Expand Down
2 changes: 1 addition & 1 deletion docs/guides/run/resources.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Resources
description: description
description: Learn about compute resources
icon: gauge-max
---

Expand Down
8 changes: 8 additions & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
]
},
Expand Down
10 changes: 5 additions & 5 deletions docs/product/functions.mdx
Original file line number Diff line number Diff line change
@@ -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.

<Tip>For more sophisticated use-cases and control over the runtime, use [Nhost Run](/product/run).</Tip>
<Tip>
For more sophisticated use-cases and control over the runtime, use [Nhost Run](/product/run).
</Tip>

## Hello World

Expand All @@ -21,7 +23,5 @@ Deploying functions is as easy as pushing your code!
## Additional Resources

<CardGroup cols={2}>
<Card title="Learn how to use Functions" href="/guides/functions/getting-started">
</Card>
<Card title="Learn how to use Functions" href="/guides/functions/overview"></Card>
</CardGroup>

70 changes: 70 additions & 0 deletions docs/reference/javascript/functions/call.mdx
Original file line number Diff line number Diff line change
@@ -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: '[email protected]',
name: 'Joe Doe'
})
```

## Parameters

---

**<span className="parameter-name">url</span>** <span className="optional-status">required</span> <code>string</code>

---

**<span className="parameter-name">body</span>** <span className="optional-status">optional</span> <code>null &#124; TBody</code>

---

**<span className="parameter-name">config</span>** <span className="optional-status">optional</span> <code>NhostFunctionCallConfig</code>

---

## Examples

### Without generic types

```ts
await nhost.functions.call('send-welcome-email', {
email: '[email protected]',
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<Data, Body, ErrorMessage>(
'send-welcome-email',
{ email: '[email protected]', 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)
```
31 changes: 31 additions & 0 deletions docs/reference/javascript/functions/create-functions-client.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: createFunctionsClient()
sidebarTitle: createFunctionsClient()
---

Creates a client for Functions from either a subdomain or a URL

## Parameters

---

**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`NhostClientConstructorParams`](/reference/javascript/nhost-js/types/nhost-client-constructor-params)

| Property | Type | Required | Notes |
| :----------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------ | :------: | :--------------------------------------------------------------------------------------------------------------------------------------- |
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | <code>string</code> | | When set, the admin secret is sent as a header, `x-hasura-admin-secret`, for all requests to GraphQL, Storage, and Serverless Functions. |
| <span className="parameter-name"><span className="light-grey">params.</span>functionsUrl</span> | <code>string</code> | | |
| <span className="parameter-name"><span className="light-grey">params.</span>storageUrl</span> | <code>string</code> | | |
| <span className="parameter-name"><span className="light-grey">params.</span>graphqlUrl</span> | <code>string</code> | | |
| <span className="parameter-name"><span className="light-grey">params.</span>authUrl</span> | <code>string</code> | | |
| <span className="parameter-name"><span className="light-grey">params.</span>region</span> | <code>string</code> | | Project region (e.g. `eu-central-1`) Project region is not required during local development (when `subdomain` is `localhost`) |
| <span className="parameter-name"><span className="light-grey">params.</span>subdomain</span> | <code>string</code> | | Project subdomain (e.g. `ieingiwnginwnfnegqwvdqwdwq`) Use `localhost` during local development |
| <span className="parameter-name"><span className="light-grey">params.</span>devTools</span> | <code>boolean</code> | | Activate devTools e.g. the ability to connect to the xstate inspector |
| <span className="parameter-name"><span className="light-grey">params.</span>autoSignIn</span> | <code>boolean</code> | | When set to true, will parse the url on startup to check if it contains a refresh token to start the session with |
| <span className="parameter-name"><span className="light-grey">params.</span>autoRefreshToken</span> | <code>boolean</code> | | When set to true, will automatically refresh token before it expires |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorage</span> | [`ClientStorage`](/reference/javascript/nhost-js/types/client-storage) | | Object where the refresh token will be persisted and read locally. |
| <span className="parameter-name"><span className="light-grey">params.</span>clientStorageType</span> | [`ClientStorageType`](/reference/javascript/nhost-js/types/client-storage-type) | | Define a way to get information about the refresh token and its exipration date. |
| <span className="parameter-name"><span className="light-grey">params.</span>refreshIntervalTime</span> | <code>number</code> | | Time interval until token refreshes, in seconds |
| <span className="parameter-name"><span className="light-grey">params.</span>start</span> | <code>boolean</code> | | |

---
13 changes: 13 additions & 0 deletions docs/reference/javascript/functions/nhost-functions-client.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: NhostFunctionsClient
---

# `NhostFunctionsClient`

## Parameters

---

**<span className="parameter-name">params</span>** <span className="optional-status">required</span> <code>NhostFunctionsConstructorParams</code>

---
18 changes: 18 additions & 0 deletions docs/reference/javascript/functions/set-access-token.mdx
Original file line number Diff line number Diff line change
@@ -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

---

**<span className="parameter-name">accessToken</span>** <span className="optional-status">required</span> <code>undefined &#124; string</code>

---

0 comments on commit b50a6e9

Please sign in to comment.