Compare commits
26 Commits
@nhost/das
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e2ecb4d1e | ||
|
|
52ebbef762 | ||
|
|
82faa4ca0a | ||
|
|
d06a21764a | ||
|
|
8b54d290a5 | ||
|
|
4cfa6bbe1e | ||
|
|
614f213e26 | ||
|
|
4eebf51821 | ||
|
|
9a52298aa7 | ||
|
|
099eebe602 | ||
|
|
798e591b1d | ||
|
|
b48bc034ca | ||
|
|
f57819230b | ||
|
|
4b6df8b9d6 | ||
|
|
a2af5a674d | ||
|
|
c33c1fd6b9 | ||
|
|
041d9b98e3 | ||
|
|
e4b4940397 | ||
|
|
be91f4ed2a | ||
|
|
ec6ba846cf | ||
|
|
d8d8394b3b | ||
|
|
f051a121b2 | ||
|
|
6ed46ce2d4 | ||
|
|
bfb4c1a6cc | ||
|
|
e91de1088d | ||
|
|
ce1ee40dab |
@@ -1,5 +1,29 @@
|
|||||||
# @nhost/dashboard
|
# @nhost/dashboard
|
||||||
|
|
||||||
|
## 0.13.5
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/react-apollo@5.0.12
|
||||||
|
- @nhost/nextjs@1.13.17
|
||||||
|
|
||||||
|
## 0.13.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- b48bc034: fix(dashboard): disable new users
|
||||||
|
- 798e591b: fix(dashboard): show correct date in data grid
|
||||||
|
|
||||||
|
## 0.13.3
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- bfb4c1a6: chore(dashboard): remove `useAxios` property
|
||||||
|
- d8d8394b: Dashboard: allow to override hasura admin secret in docker
|
||||||
|
- Updated dependencies [ce1ee40d]
|
||||||
|
- @nhost/nextjs@1.13.16
|
||||||
|
- @nhost/react-apollo@5.0.11
|
||||||
|
|
||||||
## 0.13.2
|
## 0.13.2
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ ENV NEXT_PUBLIC_ENV dev
|
|||||||
ENV NEXT_PUBLIC_NHOST_PLATFORM false
|
ENV NEXT_PUBLIC_NHOST_PLATFORM false
|
||||||
|
|
||||||
# placeholders for URLs, will be replaced on runtime by entrypoint script
|
# placeholders for URLs, will be replaced on runtime by entrypoint script
|
||||||
|
ENV NEXT_PUBLIC_NHOST_ADMIN_SECRET __NEXT_PUBLIC_NHOST_ADMIN_SECRET__
|
||||||
ENV NEXT_PUBLIC_NHOST_AUTH_URL __NEXT_PUBLIC_NHOST_AUTH_URL__
|
ENV NEXT_PUBLIC_NHOST_AUTH_URL __NEXT_PUBLIC_NHOST_AUTH_URL__
|
||||||
ENV NEXT_PUBLIC_NHOST_FUNCTIONS_URL __NEXT_PUBLIC_NHOST_FUNCTIONS_URL__
|
ENV NEXT_PUBLIC_NHOST_FUNCTIONS_URL __NEXT_PUBLIC_NHOST_FUNCTIONS_URL__
|
||||||
ENV NEXT_PUBLIC_NHOST_GRAPHQL_URL __NEXT_PUBLIC_NHOST_GRAPHQL_URL__
|
ENV NEXT_PUBLIC_NHOST_GRAPHQL_URL __NEXT_PUBLIC_NHOST_GRAPHQL_URL__
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# read URLs from env variables (with defaults)
|
# read URLs from env variables (with defaults)
|
||||||
|
NEXT_PUBLIC_NHOST_ADMIN_SECRET="${NEXT_PUBLIC_NHOST_ADMIN_SECRET:-nhost-admin-secret}"
|
||||||
NEXT_PUBLIC_NHOST_AUTH_URL="${NEXT_PUBLIC_NHOST_AUTH_URL:-http://localhost:1337/v1/auth}"
|
NEXT_PUBLIC_NHOST_AUTH_URL="${NEXT_PUBLIC_NHOST_AUTH_URL:-http://localhost:1337/v1/auth}"
|
||||||
NEXT_PUBLIC_NHOST_FUNCTIONS_URL="${NEXT_PUBLIC_NHOST_FUNCTIONS_URL:-http://localhost:1337/v1/functions}"
|
NEXT_PUBLIC_NHOST_FUNCTIONS_URL="${NEXT_PUBLIC_NHOST_FUNCTIONS_URL:-http://localhost:1337/v1/functions}"
|
||||||
NEXT_PUBLIC_NHOST_GRAPHQL_URL="${NEXT_PUBLIC_NHOST_GRAPHQL_URL:-http://localhost:1337/v1/graphql}"
|
NEXT_PUBLIC_NHOST_GRAPHQL_URL="${NEXT_PUBLIC_NHOST_GRAPHQL_URL:-http://localhost:1337/v1/graphql}"
|
||||||
@@ -12,6 +13,7 @@ NEXT_PUBLIC_NHOST_HASURA_MIGRATIONS_API_URL="${NEXT_PUBLIC_NHOST_HASURA_MIGRATIO
|
|||||||
NEXT_PUBLIC_NHOST_HASURA_API_URL="${NEXT_PUBLIC_NHOST_HASURA_API_URL:-http://localhost:8080}"
|
NEXT_PUBLIC_NHOST_HASURA_API_URL="${NEXT_PUBLIC_NHOST_HASURA_API_URL:-http://localhost:8080}"
|
||||||
|
|
||||||
# replace placeholders
|
# replace placeholders
|
||||||
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_ADMIN_SECRET__~${NEXT_PUBLIC_NHOST_ADMIN_SECRET}~g" {} +
|
||||||
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_AUTH_URL__~${NEXT_PUBLIC_NHOST_AUTH_URL}~g" {} +
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_AUTH_URL__~${NEXT_PUBLIC_NHOST_AUTH_URL}~g" {} +
|
||||||
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_FUNCTIONS_URL__~${NEXT_PUBLIC_NHOST_FUNCTIONS_URL}~g" {} +
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_FUNCTIONS_URL__~${NEXT_PUBLIC_NHOST_FUNCTIONS_URL}~g" {} +
|
||||||
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_GRAPHQL_URL__~${NEXT_PUBLIC_NHOST_GRAPHQL_URL}~g" {} +
|
find dashboard -type f -exec sed -i "s~__NEXT_PUBLIC_NHOST_GRAPHQL_URL__~${NEXT_PUBLIC_NHOST_GRAPHQL_URL}~g" {} +
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/dashboard",
|
"name": "@nhost/dashboard",
|
||||||
"version": "0.13.2",
|
"version": "0.13.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
"@nhost/nextjs": "workspace:*",
|
"@nhost/nextjs": "workspace:*",
|
||||||
"@nhost/react-apollo": "workspace:*",
|
"@nhost/react-apollo": "workspace:*",
|
||||||
"@segment/snippet": "^4.15.3",
|
"@segment/snippet": "^4.15.3",
|
||||||
"@stripe/react-stripe-js": "^1.10.0",
|
"@stripe/react-stripe-js": "^2.0.0",
|
||||||
"@stripe/stripe-js": "^1.35.0",
|
"@stripe/stripe-js": "^1.35.0",
|
||||||
"@tailwindcss/forms": "^0.5.3",
|
"@tailwindcss/forms": "^0.5.3",
|
||||||
"@tanstack/react-query": "^4.16.1",
|
"@tanstack/react-query": "^4.16.1",
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export default function DataGridDateCell<TData extends object>({
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const { year, month, day, hour, minute, second } = getDateComponents(date, {
|
const { year, month, day, hour, minute, second } = getDateComponents(date, {
|
||||||
adjustTimezone: specificType === 'timetz' || specificType === 'timestamptz',
|
adjustTimezone: ['date', 'timetz', 'timestamptz'].includes(specificType),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { inputRef, focusCell, isEditing, cancelEditCell } =
|
const { inputRef, focusCell, isEditing, cancelEditCell } =
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ export function InviteAnnounce() {
|
|||||||
workspaceMemberInviteId: inviteId,
|
workspaceMemberInviteId: inviteId,
|
||||||
isAccepted: false,
|
isAccepted: false,
|
||||||
},
|
},
|
||||||
{ useAxios: false },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (ignoreError) {
|
if (ignoreError) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export default function DisableNewUsersSettings() {
|
|||||||
const form = useForm<DisableNewUsersFormValues>({
|
const form = useForm<DisableNewUsersFormValues>({
|
||||||
reValidateMode: 'onSubmit',
|
reValidateMode: 'onSubmit',
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
disabled: !!data?.config?.auth?.signUp?.enabled,
|
disabled: !data?.config?.auth?.signUp?.enabled,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ export function WorkspaceInvoices() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mt-18">
|
<div className="mt-18">
|
||||||
<div className="mx-auto max-w-3xl font-display grid grid-flow-row gap-2 justify-start">
|
<div className="mx-auto grid max-w-3xl grid-flow-row justify-start gap-2 font-display">
|
||||||
<Text className="font-medium text-lg">Invoices</Text>
|
<Text className="text-lg font-medium">Invoices</Text>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -23,7 +23,6 @@ export function WorkspaceInvoices() {
|
|||||||
const { res, error } = await nhost.functions.call(
|
const { res, error } = await nhost.functions.call(
|
||||||
'/stripe-create-portal',
|
'/stripe-create-portal',
|
||||||
{ workspaceId: currentWorkspace.id },
|
{ workspaceId: currentWorkspace.id },
|
||||||
{ useAxios: false },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/docs
|
# @nhost/docs
|
||||||
|
|
||||||
|
## 0.0.14
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- bfb4c1a6: fix(docs): restore autogenerated `@nhost/nhost-js` docs
|
||||||
|
|
||||||
## 0.0.13
|
## 0.0.13
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ In this section:
|
|||||||
- [Overview](/reference/javascript)
|
- [Overview](/reference/javascript)
|
||||||
- [Authentication](/reference/javascript/auth)
|
- [Authentication](/reference/javascript/auth)
|
||||||
- [Storage](/reference/javascript/storage)
|
- [Storage](/reference/javascript/storage)
|
||||||
- [Functions](/reference/javascript/functions)
|
- [Functions](/reference/javascript/nhost-js/functions)
|
||||||
- [GraphQL](/reference/javascript/graphql)
|
- [GraphQL](/reference/javascript/graphql)
|
||||||
|
|
||||||
### React
|
### React
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
---
|
|
||||||
title: call()
|
|
||||||
sidebar_label: call()
|
|
||||||
slug: /reference/javascript/functions/call
|
|
||||||
description: Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/index.ts#L55
|
|
||||||
---
|
|
||||||
|
|
||||||
# `call()`
|
|
||||||
|
|
||||||
## Overload 1 of 2
|
|
||||||
|
|
||||||
Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
|
||||||
|
|
||||||
:::caution Deprecated
|
|
||||||
Axios will be replaced by cross-fetch in the near future. Only the headers configuration will be kept.
|
|
||||||
:::
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">url</span>** <span className="optional-status">required</span> <code>string</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">data</span>** <span className="optional-status">optional</span> <code>D</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">config</span>** <span className="optional-status">optional</span> <code>AxiosRequestConfig<any> & { useAxios: "true" } & [`NhostFunctionCallConfig`](/reference/javascript/functions/types/nhost-function-call-config) & { useAxios: "true" }</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Overload 2 of 2
|
|
||||||
|
|
||||||
Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
|
||||||
|
|
||||||
```ts
|
|
||||||
await nhost.functions.call('send-welcome-email', {
|
|
||||||
email: 'joe@example.com',
|
|
||||||
name: 'Joe Doe'
|
|
||||||
})
|
|
||||||
```
|
|
||||||
|
|
||||||
### Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">url</span>** <span className="optional-status">required</span> <code>string</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">data</span>** <span className="optional-status">required</span> <code>D</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">config</span>** <span className="optional-status">optional</span> <code>[`NhostFunctionCallConfig`](/reference/javascript/functions/types/nhost-function-call-config) & { useAxios: "false" }</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
---
|
|
||||||
title: setAccessToken()
|
|
||||||
sidebar_label: setAccessToken()
|
|
||||||
slug: /reference/javascript/functions/set-access-token
|
|
||||||
description: 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.
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/index.ts#L155
|
|
||||||
---
|
|
||||||
|
|
||||||
# `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 | string</code>
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionsClient
|
|
||||||
sidebar_label: Functions
|
|
||||||
description: No description provided.
|
|
||||||
slug: /reference/javascript/functions
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/docs/docs/reference/javascript/functions/index.mdx
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionsClient`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">params</span>** <span className="optional-status">required</span> [`NhostFunctionsConstructorParams`](/reference/javascript/functions/types/nhost-functions-constructor-params)
|
|
||||||
|
|
||||||
| Property | Type | Required | Notes |
|
|
||||||
| :--------------------------------------------------------------------------------------------- | :------------------ | :------: | :---------------------------------------------------------------------------------------- |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">params.</span>url</span> | <code>string</code> | ✔️ | Serverless Functions endpoint. |
|
|
||||||
| <span className="parameter-name"><span className="light-grey">params.</span>adminSecret</span> | <code>string</code> | | Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all requests. |
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionCallConfig
|
|
||||||
sidebar_label: NhostFunctionCallConfig
|
|
||||||
description: Subset of RequestInit parameters that are supported by the functions client
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/types.ts#L41
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionCallConfig`
|
|
||||||
|
|
||||||
Subset of RequestInit parameters that are supported by the functions client
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">headers</span>** <span className="optional-status">optional</span> <code>Record<string, string></code>
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionCallResponse
|
|
||||||
sidebar_label: NhostFunctionCallResponse
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/types.ts#L15
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionCallResponse`
|
|
||||||
|
|
||||||
```ts
|
|
||||||
type NhostFunctionCallResponse =
|
|
||||||
| { res: { data: T; status: number; statusText: string }; error: null }
|
|
||||||
| { res: null; error: ErrorPayload }
|
|
||||||
```
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
title: NhostFunctionsConstructorParams
|
|
||||||
sidebar_label: NhostFunctionsConstructorParams
|
|
||||||
description: No description provided.
|
|
||||||
displayed_sidebar: referenceSidebar
|
|
||||||
custom_edit_url: https://github.com/nhost/nhost/edit/main/packages/nhost-js/src/clients/functions/types.ts#L4
|
|
||||||
---
|
|
||||||
|
|
||||||
# `NhostFunctionsConstructorParams`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">url</span>** <span className="optional-status">required</span> <code>string</code>
|
|
||||||
|
|
||||||
Serverless Functions endpoint.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**<span className="parameter-name">adminSecret</span>** <span className="optional-status">optional</span> <code>string</code>
|
|
||||||
|
|
||||||
Admin secret. When set, it is sent as an `x-hasura-admin-secret` header for all requests.
|
|
||||||
|
|
||||||
---
|
|
||||||
@@ -10,7 +10,7 @@ The Nhost JavaScript client is the primary way of interacting with your Nhost pr
|
|||||||
|
|
||||||
- [Authentication](/reference/javascript/auth)
|
- [Authentication](/reference/javascript/auth)
|
||||||
- [Storage](/reference/javascript/storage)
|
- [Storage](/reference/javascript/storage)
|
||||||
- [Functions](/reference/javascript/functions)
|
- [Functions](/reference/javascript/nhost-js/functions)
|
||||||
- [GraphQL](/reference/javascript/graphql)
|
- [GraphQL](/reference/javascript/graphql)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/docs",
|
"name": "@nhost/docs",
|
||||||
"version": "0.0.13",
|
"version": "0.0.14",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
|
|||||||
@@ -111,12 +111,12 @@ const sidebars = {
|
|||||||
label: 'Functions',
|
label: 'Functions',
|
||||||
link: {
|
link: {
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
id: 'reference/javascript/functions/index'
|
id: 'reference/docgen/javascript/nhost-js/content/nhost-functions-client/index'
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: 'autogenerated',
|
type: 'autogenerated',
|
||||||
dirName: 'reference/javascript/functions/content'
|
dirName: 'reference/docgen/javascript/nhost-js/content/nhost-functions-client/content'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# @nhost-examples/nextjs
|
# @nhost-examples/nextjs
|
||||||
|
|
||||||
|
## 0.1.8
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- ce1ee40d: fix(nextjs): allow `subdomain`, `region` and service URLs
|
||||||
|
- Updated dependencies [ce1ee40d]
|
||||||
|
- @nhost/nextjs@1.13.16
|
||||||
|
- @nhost/react@2.0.10
|
||||||
|
- @nhost/react-apollo@5.0.11
|
||||||
|
|
||||||
## 0.1.7
|
## 0.1.7
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
export * from './queries'
|
export * from './queries'
|
||||||
export const BACKEND_URL = 'http://127.0.0.1:1337'
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost-examples/nextjs",
|
"name": "@nhost-examples/nextjs",
|
||||||
"version": "0.1.7",
|
"version": "0.1.8",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { inspect } from '@xstate/inspect'
|
|||||||
import type { AppProps } from 'next/app'
|
import type { AppProps } from 'next/app'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import NavBar from '../components/NavBar'
|
import NavBar from '../components/NavBar'
|
||||||
import { BACKEND_URL } from '../helpers'
|
|
||||||
import '../styles/globals.css?inline'
|
import '../styles/globals.css?inline'
|
||||||
|
|
||||||
const devTools = typeof window !== 'undefined' && !!process.env.NEXT_PUBLIC_DEBUG
|
const devTools = typeof window !== 'undefined' && !!process.env.NEXT_PUBLIC_DEBUG
|
||||||
@@ -16,7 +15,7 @@ if (devTools) {
|
|||||||
iframe: false
|
iframe: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const nhost = new NhostClient({ backendUrl: BACKEND_URL, devTools })
|
const nhost = new NhostClient({ subdomain: 'localhost', devTools })
|
||||||
const title = 'Nhost with NextJs'
|
const title = 'Nhost with NextJs'
|
||||||
function MyApp({ Component, pageProps }: AppProps) {
|
function MyApp({ Component, pageProps }: AppProps) {
|
||||||
// * Monorepo-related. See: https://stackoverflow.com/questions/71843247/react-nextjs-type-error-component-cannot-be-used-as-a-jsx-component
|
// * Monorepo-related. See: https://stackoverflow.com/questions/71843247/react-nextjs-type-error-component-cannot-be-used-as-a-jsx-component
|
||||||
|
|||||||
@@ -4,10 +4,9 @@ import { Container, Title } from '@mantine/core'
|
|||||||
import { getNhostSession, NhostSession, useAccessToken } from '@nhost/nextjs'
|
import { getNhostSession, NhostSession, useAccessToken } from '@nhost/nextjs'
|
||||||
|
|
||||||
import { authProtected } from '../components/protected-route'
|
import { authProtected } from '../components/protected-route'
|
||||||
import { BACKEND_URL } from '../helpers'
|
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
const nhostSession = await getNhostSession(BACKEND_URL, context)
|
const nhostSession = await getNhostSession({ subdomain: 'localhost' }, context)
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
nhostSession
|
nhostSession
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ import { GetServerSideProps } from 'next'
|
|||||||
import { Container, Title } from '@mantine/core'
|
import { Container, Title } from '@mantine/core'
|
||||||
import { getNhostSession, NhostSession, useAccessToken, useAuthenticated } from '@nhost/nextjs'
|
import { getNhostSession, NhostSession, useAccessToken, useAuthenticated } from '@nhost/nextjs'
|
||||||
|
|
||||||
import { BACKEND_URL } from '../helpers'
|
|
||||||
|
|
||||||
export const getServerSideProps: GetServerSideProps = async (context) => {
|
export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
const nhostSession = await getNhostSession(BACKEND_URL, context)
|
const nhostSession = await getNhostSession({ subdomain: 'localhost' }, context)
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
nhostSession
|
nhostSession
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
# @nhost/apollo
|
# @nhost/apollo
|
||||||
|
|
||||||
|
## 5.1.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@2.1.1
|
||||||
|
|
||||||
|
## 5.1.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [bfb4c1a6]
|
||||||
|
- @nhost/nhost-js@2.1.0
|
||||||
|
|
||||||
## 5.0.9
|
## 5.0.9
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/apollo",
|
"name": "@nhost/apollo",
|
||||||
"version": "5.0.9",
|
"version": "5.1.1",
|
||||||
"description": "Nhost Apollo Client library",
|
"description": "Nhost Apollo Client library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,19 @@
|
|||||||
# @nhost/react-apollo
|
# @nhost/react-apollo
|
||||||
|
|
||||||
|
## 5.0.12
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/apollo@5.1.1
|
||||||
|
- @nhost/react@2.0.11
|
||||||
|
|
||||||
|
## 5.0.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/apollo@5.1.0
|
||||||
|
- @nhost/react@2.0.10
|
||||||
|
|
||||||
## 5.0.10
|
## 5.0.10
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-apollo",
|
"name": "@nhost/react-apollo",
|
||||||
"version": "5.0.10",
|
"version": "5.0.12",
|
||||||
"description": "Nhost React Apollo client",
|
"description": "Nhost React Apollo client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
# @nhost/react-urql
|
# @nhost/react-urql
|
||||||
|
|
||||||
|
## 2.0.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/react@2.0.11
|
||||||
|
|
||||||
|
## 2.0.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/react@2.0.10
|
||||||
|
|
||||||
## 2.0.9
|
## 2.0.9
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react-urql",
|
"name": "@nhost/react-urql",
|
||||||
"version": "2.0.9",
|
"version": "2.0.11",
|
||||||
"description": "Nhost React URQL client",
|
"description": "Nhost React URQL client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/graphql-js
|
# @nhost/graphql-js
|
||||||
|
|
||||||
|
## 0.1.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- bfb4c1a6: chore(sdk): remove deprecated `useAxios` property
|
||||||
|
|
||||||
## 0.0.5
|
## 0.0.5
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/graphql-js",
|
"name": "@nhost/graphql-js",
|
||||||
"version": "0.0.5",
|
"version": "0.1.0",
|
||||||
"description": "Nhost GraphQL client",
|
"description": "Nhost GraphQL client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -47,6 +47,4 @@ export type NhostGraphqlRequestResponse<T = unknown> =
|
|||||||
/** Subset of RequestInit parameters that are supported by the graphql client */
|
/** Subset of RequestInit parameters that are supported by the graphql client */
|
||||||
export interface NhostGraphqlRequestConfig {
|
export interface NhostGraphqlRequestConfig {
|
||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
/** @deprecated Axios has been replaced by cross-fetch. You should now remove this option. */
|
|
||||||
useAxios?: false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# @nhost/hasura-storage-js
|
# @nhost/hasura-storage-js
|
||||||
|
|
||||||
|
## 2.0.4
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- 614f213e: fix(hasura-storage-js): allow image transformation parameters in `getPresignedUrl`
|
||||||
|
|
||||||
## 2.0.3
|
## 2.0.3
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/hasura-storage-js",
|
"name": "@nhost/hasura-storage-js",
|
||||||
"version": "2.0.3",
|
"version": "2.0.4",
|
||||||
"description": "Hasura-storage client",
|
"description": "Hasura-storage client",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -47,6 +47,7 @@
|
|||||||
"e2e": "start-test e2e:backend http-get://localhost:9695 ci:test",
|
"e2e": "start-test e2e:backend http-get://localhost:9695 ci:test",
|
||||||
"ci:test": "vitest run",
|
"ci:test": "vitest run",
|
||||||
"e2e:backend": "nhost dev --no-browser",
|
"e2e:backend": "nhost dev --no-browser",
|
||||||
|
"test": "vitest --config ./vite.unit.config.js",
|
||||||
"test:watch": "vitest",
|
"test:watch": "vitest",
|
||||||
"test:coverage": "vitest run --coverage",
|
"test:coverage": "vitest run --coverage",
|
||||||
"prettier": "prettier --check src/",
|
"prettier": "prettier --check src/",
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ export class HasuraStorageClient {
|
|||||||
async getPresignedUrl(
|
async getPresignedUrl(
|
||||||
params: StorageGetPresignedUrlParams
|
params: StorageGetPresignedUrlParams
|
||||||
): Promise<StorageGetPresignedUrlResponse> {
|
): Promise<StorageGetPresignedUrlResponse> {
|
||||||
|
const { fileId, ...imageTransformationParams } = params
|
||||||
const { presignedUrl, error } = await this.api.getPresignedUrl(params)
|
const { presignedUrl, error } = await this.api.getPresignedUrl(params)
|
||||||
if (error) {
|
if (error) {
|
||||||
return { presignedUrl: null, error }
|
return { presignedUrl: null, error }
|
||||||
@@ -138,7 +139,18 @@ export class HasuraStorageClient {
|
|||||||
return { presignedUrl: null, error: new Error('Invalid file id') }
|
return { presignedUrl: null, error: new Error('Invalid file id') }
|
||||||
}
|
}
|
||||||
|
|
||||||
return { presignedUrl, error: null }
|
const urlWithTransformationParams = appendImageTransformationParameters(
|
||||||
|
presignedUrl.url,
|
||||||
|
imageTransformationParams
|
||||||
|
)
|
||||||
|
|
||||||
|
return {
|
||||||
|
presignedUrl: {
|
||||||
|
...presignedUrl,
|
||||||
|
url: urlWithTransformationParams
|
||||||
|
},
|
||||||
|
error: null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import { expect, test } from 'vitest'
|
||||||
|
import appendImageTransformationParameters from './appendImageTransformationParameters'
|
||||||
|
|
||||||
|
test('should append image transformation parameters to a simple URL', () => {
|
||||||
|
expect(
|
||||||
|
appendImageTransformationParameters('https://example.com/', {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
blur: 50,
|
||||||
|
quality: 80
|
||||||
|
})
|
||||||
|
).toBe('https://example.com/?w=100&h=100&b=50&q=80')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should append image transformation parameters to a URL with existing query parameters', () => {
|
||||||
|
expect(
|
||||||
|
appendImageTransformationParameters('https://example.com/?foo=bar', {
|
||||||
|
width: 100,
|
||||||
|
height: 100,
|
||||||
|
blur: 50,
|
||||||
|
quality: 80
|
||||||
|
})
|
||||||
|
).toBe('https://example.com/?foo=bar&w=100&h=100&b=50&q=80')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should not append falsy values', () => {
|
||||||
|
expect(
|
||||||
|
appendImageTransformationParameters('https://example.com/', {
|
||||||
|
width: undefined,
|
||||||
|
height: 100,
|
||||||
|
blur: undefined,
|
||||||
|
quality: 80
|
||||||
|
})
|
||||||
|
).toBe('https://example.com/?h=100&q=80')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should keep the original URL if no transformation parameters are provided', () => {
|
||||||
|
expect(appendImageTransformationParameters('https://example.com/', {})).toBe(
|
||||||
|
'https://example.com/'
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { StorageImageTransformationParams } from '../types'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends image transformation parameters to the URL. If the URL already
|
||||||
|
* contains query parameters, the transformation parameters are appended to
|
||||||
|
* the existing query parameters.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @param url - The URL to append the transformation parameters to.
|
||||||
|
* @param params - The image transformation parameters.
|
||||||
|
* @returns The URL with the transformation parameters appended.
|
||||||
|
*/
|
||||||
|
export default function appendImageTransformationParameters(
|
||||||
|
url: string,
|
||||||
|
params: StorageImageTransformationParams
|
||||||
|
): string {
|
||||||
|
const urlObject = new URL(url)
|
||||||
|
|
||||||
|
// create an object with the transformation parameters by using the first
|
||||||
|
// character of the parameter name as the key
|
||||||
|
const imageTransformationParams = Object.entries(params).reduce(
|
||||||
|
(accumulator, [key, value]) => ({ ...accumulator, [key.charAt(0)]: value }),
|
||||||
|
{} as Record<string, any>
|
||||||
|
)
|
||||||
|
|
||||||
|
// set the query parameters in the URL object
|
||||||
|
Object.entries(imageTransformationParams).forEach(([key, value]) => {
|
||||||
|
if (!value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
urlObject.searchParams.set(key, value)
|
||||||
|
})
|
||||||
|
|
||||||
|
return urlObject.toString()
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export { default as appendImageTransformationParameters } from './appendImageTransformationParameters'
|
||||||
@@ -1,13 +1,2 @@
|
|||||||
import { StorageImageTransformationParams } from './types'
|
export * from './appendImageTransformationParameters'
|
||||||
|
|
||||||
export * from './types'
|
export * from './types'
|
||||||
|
|
||||||
export const appendImageTransformationParameters = (
|
|
||||||
url: string,
|
|
||||||
params: StorageImageTransformationParams
|
|
||||||
): string => {
|
|
||||||
const queryParameters = Object.entries(params)
|
|
||||||
.map(([key, value]) => `${key.charAt(0)}=${value}`)
|
|
||||||
.join('&')
|
|
||||||
return queryParameters ? `${url}?${queryParameters}` : url
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -65,9 +65,7 @@ export interface StorageGetUrlParams extends StorageImageTransformationParams {
|
|||||||
fileId: string
|
fileId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO not implemented yet in hasura-storage
|
export interface StorageGetPresignedUrlParams extends StorageImageTransformationParams {
|
||||||
// export interface StorageGetPresignedUrlParams extends StorageImageTransformationParams {
|
|
||||||
export interface StorageGetPresignedUrlParams {
|
|
||||||
fileId: string
|
fileId: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
packages/hasura-storage-js/vite.unit.config.js
Normal file
15
packages/hasura-storage-js/vite.unit.config.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
|
||||||
|
import baseConfig from '../../config/vite.lib.config'
|
||||||
|
|
||||||
|
const PWD = process.env.PWD
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
...baseConfig,
|
||||||
|
test: {
|
||||||
|
...(baseConfig.test || {}),
|
||||||
|
testTimeout: 30000,
|
||||||
|
environment: 'node',
|
||||||
|
include: [`${PWD}/src/**/*.{spec,test}.{ts,tsx}`]
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -1,5 +1,18 @@
|
|||||||
# @nhost/nextjs
|
# @nhost/nextjs
|
||||||
|
|
||||||
|
## 1.13.17
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/react@2.0.11
|
||||||
|
|
||||||
|
## 1.13.16
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- ce1ee40d: fix(nextjs): allow `subdomain`, `region` and service URLs
|
||||||
|
- @nhost/react@2.0.10
|
||||||
|
|
||||||
## 1.13.15
|
## 1.13.15
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ import {
|
|||||||
} from '@nhost/nextjs'
|
} from '@nhost/nextjs'
|
||||||
|
|
||||||
export async function getServerSideProps(context: NextPageContext) {
|
export async function getServerSideProps(context: NextPageContext) {
|
||||||
const nhostSession = await getNhostSession('<Your Nhost Backend URL>', context)
|
const nhostSession = await getNhostSession(
|
||||||
|
{ subdomain: '<project_subdomain>', region: '<project_region>' },
|
||||||
|
context
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nextjs",
|
"name": "@nhost/nextjs",
|
||||||
"version": "1.13.15",
|
"version": "1.13.17",
|
||||||
"description": "Nhost NextJS library",
|
"description": "Nhost NextJS library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
AuthMachine,
|
AuthMachine,
|
||||||
NhostClient,
|
NhostClient,
|
||||||
|
NhostReactClientConstructorParams,
|
||||||
NhostSession,
|
NhostSession,
|
||||||
NHOST_REFRESH_TOKEN_KEY,
|
NHOST_REFRESH_TOKEN_KEY,
|
||||||
VanillaNhostClient
|
VanillaNhostClient
|
||||||
@@ -11,21 +12,42 @@ import { StateFrom } from 'xstate'
|
|||||||
import { waitFor } from 'xstate/lib/waitFor'
|
import { waitFor } from 'xstate/lib/waitFor'
|
||||||
import { NHOST_SESSION_KEY } from './utils'
|
import { NHOST_SESSION_KEY } from './utils'
|
||||||
|
|
||||||
|
export type CreateServerSideClientParams = Pick<
|
||||||
|
NhostReactClientConstructorParams,
|
||||||
|
'subdomain' | 'region' | 'authUrl' | 'functionsUrl' | 'graphqlUrl' | 'storageUrl'
|
||||||
|
>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an Nhost client that runs on the server side.
|
* Creates an Nhost client that runs on the server side.
|
||||||
* It will try to get the refesh token in cookies, or from the request URL
|
* It will try to get the refesh token in cookies, or from the request URL
|
||||||
* If a refresh token is found, it uses it to get an up to date access token (JWT) and a user session
|
* If a refresh token is found, it uses it to get an up to date access token (JWT) and a user session
|
||||||
* This method resolves when the authentication status is known eventually
|
* This method resolves when the authentication status is known eventually
|
||||||
* @param backendUrl
|
* @param config - An object containing connection information
|
||||||
* @param context
|
* @param context - Server side context
|
||||||
* @returns instance of `NhostClient` that is ready to use on the server side (signed in or signed out)
|
* @returns instance of `NhostClient` that is ready to use on the server side (signed in or signed out)
|
||||||
*/
|
*/
|
||||||
export const createServerSideClient = async (
|
export const createServerSideClient = async (
|
||||||
backendUrl: string,
|
params: string | CreateServerSideClientParams,
|
||||||
context: GetServerSidePropsContext
|
context: GetServerSidePropsContext
|
||||||
): Promise<NhostClient> => {
|
): Promise<NhostClient> => {
|
||||||
|
let clientParams: NhostReactClientConstructorParams
|
||||||
|
|
||||||
|
if (typeof params === 'string') {
|
||||||
|
console.warn(
|
||||||
|
'Deprecation Notice: Backend URL is no longer supported. Please use subdomain + region or individual service URLs.'
|
||||||
|
)
|
||||||
|
|
||||||
|
clientParams = {
|
||||||
|
backendUrl: params
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clientParams = {
|
||||||
|
...params
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const nhost = new VanillaNhostClient({
|
const nhost = new VanillaNhostClient({
|
||||||
backendUrl,
|
...clientParams,
|
||||||
clientStorageType: 'custom',
|
clientStorageType: 'custom',
|
||||||
clientStorage: {
|
clientStorage: {
|
||||||
getItem: (key) => {
|
getItem: (key) => {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { NhostSession } from '@nhost/react'
|
import { NhostSession } from '@nhost/react'
|
||||||
import { GetServerSidePropsContext } from 'next'
|
import { GetServerSidePropsContext } from 'next'
|
||||||
import { createServerSideClient } from './create-server-side-client'
|
import { createServerSideClient, CreateServerSideClientParams } from './create-server-side-client'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refreshes the access token if there is any and returns the Nhost session.
|
* Refreshes the access token if there is any and returns the Nhost session.
|
||||||
@@ -10,7 +10,10 @@ import { createServerSideClient } from './create-server-side-client'
|
|||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* export const getServerSideProps: GetServerSideProps = async (context) => {
|
* export const getServerSideProps: GetServerSideProps = async (context) => {
|
||||||
* const nhostSession = await getNhostSession(BACKEND_URL, context)
|
* const nhostSession = await getNhostSession(
|
||||||
|
* { subdomain: '<project_subdomain>', region: '<project_region>' },
|
||||||
|
* context
|
||||||
|
* )
|
||||||
*
|
*
|
||||||
* return {
|
* return {
|
||||||
* props: {
|
* props: {
|
||||||
@@ -25,7 +28,10 @@ import { createServerSideClient } from './create-server-side-client'
|
|||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* export async function getServerSideProps(context: GetServerSidePropsContext) { // or NextPageContext
|
* export async function getServerSideProps(context: GetServerSidePropsContext) { // or NextPageContext
|
||||||
* const nhostSession = await getNhostSession(BACKEND_URL, context)
|
* const nhostSession = await getNhostSession(
|
||||||
|
* { subdomain: '<project_subdomain>', region: '<project_region>' },
|
||||||
|
* context
|
||||||
|
* )
|
||||||
*
|
*
|
||||||
* return {
|
* return {
|
||||||
* props: {
|
* props: {
|
||||||
@@ -40,10 +46,10 @@ import { createServerSideClient } from './create-server-side-client'
|
|||||||
* @returns Nhost session
|
* @returns Nhost session
|
||||||
*/
|
*/
|
||||||
export const getNhostSession = async (
|
export const getNhostSession = async (
|
||||||
backendUrl: string,
|
params: string | CreateServerSideClientParams,
|
||||||
context: GetServerSidePropsContext
|
context: GetServerSidePropsContext
|
||||||
): Promise<NhostSession | null> => {
|
): Promise<NhostSession | null> => {
|
||||||
const nhost = await createServerSideClient(backendUrl, context)
|
const nhost = await createServerSideClient(params, context)
|
||||||
const { accessToken, refreshToken, user } = nhost.auth.client.interpreter!.getSnapshot().context
|
const { accessToken, refreshToken, user } = nhost.auth.client.interpreter!.getSnapshot().context
|
||||||
return nhost.auth.isAuthenticated()
|
return nhost.auth.isAuthenticated()
|
||||||
? {
|
? {
|
||||||
|
|||||||
@@ -1,5 +1,23 @@
|
|||||||
# @nhost/nhost-js
|
# @nhost/nhost-js
|
||||||
|
|
||||||
|
## 2.1.1
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [614f213e]
|
||||||
|
- @nhost/hasura-storage-js@2.0.4
|
||||||
|
|
||||||
|
## 2.1.0
|
||||||
|
|
||||||
|
### Minor Changes
|
||||||
|
|
||||||
|
- bfb4c1a6: chore(sdk): remove deprecated `useAxios` property
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [bfb4c1a6]
|
||||||
|
- @nhost/graphql-js@0.1.0
|
||||||
|
|
||||||
## 2.0.9
|
## 2.0.9
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
10
packages/nhost-js/nhost-js.docgen.json
Normal file
10
packages/nhost-js/nhost-js.docgen.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"title": "Nhost JS",
|
||||||
|
"path": "./.docgen/nhost-js.json",
|
||||||
|
"output": "../../docs/docs/reference/docgen/javascript/nhost-js",
|
||||||
|
"root": "reference/docgen/javascript/nhost-js",
|
||||||
|
"slug": "/reference/javascript/nhost-js",
|
||||||
|
"sidebarConfig": "referenceSidebar",
|
||||||
|
"baseEditUrl": "https://github.com/nhost/nhost/edit/main/packages",
|
||||||
|
"cleanup": true
|
||||||
|
}
|
||||||
25
packages/nhost-js/nhost-js.typedoc.json
Normal file
25
packages/nhost-js/nhost-js.typedoc.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://typedoc.org/schema.json",
|
||||||
|
"entryPoints": ["src/index.ts"],
|
||||||
|
"exclude": ["*.(spec|test).tsx?"],
|
||||||
|
"sort": ["source-order"],
|
||||||
|
"json": "./.docgen/nhost-js.json",
|
||||||
|
"name": "Nhost JS",
|
||||||
|
"readme": "none",
|
||||||
|
"githubPages": false,
|
||||||
|
"cleanOutputDir": false,
|
||||||
|
"excludeInternal": true,
|
||||||
|
"excludePrivate": true,
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "../..",
|
||||||
|
"paths": {
|
||||||
|
"@nhost/apollo": ["../../integrations/apollo/src/index.ts"],
|
||||||
|
"@nhost/hasura-auth-js": ["../hasura-auth-js/src/index.ts"],
|
||||||
|
"@nhost/hasura-storage-js": ["../hasura-storage-js/src/index.ts"],
|
||||||
|
"@nhost/nhost-js": ["../nhost-js/src/index.ts"],
|
||||||
|
"@nhost/nextjs": ["../nextjs/src/index.ts"],
|
||||||
|
"@nhost/react": ["../react/src/index.ts"],
|
||||||
|
"@nhost/react-apollo": ["../../integrations/react-apollo/src/index.ts"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/nhost-js",
|
"name": "@nhost/nhost-js",
|
||||||
"version": "2.0.9",
|
"version": "2.1.1",
|
||||||
"description": "Nhost JavaScript SDK",
|
"description": "Nhost JavaScript SDK",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -55,7 +55,9 @@
|
|||||||
"lint": "eslint . --ext .ts,.tsx",
|
"lint": "eslint . --ext .ts,.tsx",
|
||||||
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
"lint:fix": "eslint . --ext .ts,.tsx --fix",
|
||||||
"verify": "run-p prettier lint",
|
"verify": "run-p prettier lint",
|
||||||
"verify:fix": "run-p prettier:fix lint:fix"
|
"verify:fix": "run-p prettier:fix lint:fix",
|
||||||
|
"typedoc": "typedoc --options ./nhost-js.typedoc.json --tsconfig ./typedoc.tsconfig.json",
|
||||||
|
"docgen": "pnpm typedoc && docgen --config ./nhost-js.docgen.json"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nhost/graphql-js": "workspace:*",
|
"@nhost/graphql-js": "workspace:*",
|
||||||
@@ -64,6 +66,7 @@
|
|||||||
"isomorphic-unfetch": "^3.1.0"
|
"isomorphic-unfetch": "^3.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@nhost/docgen": "workspace:*",
|
||||||
"graphql": "16.6.0"
|
"graphql": "16.6.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -38,12 +38,6 @@ export class NhostFunctionsClient {
|
|||||||
this.adminSecret = adminSecret
|
this.adminSecret = adminSecret
|
||||||
}
|
}
|
||||||
|
|
||||||
async call<T = unknown, D = any>(
|
|
||||||
url: string,
|
|
||||||
data: D | null,
|
|
||||||
config?: NhostFunctionCallConfig
|
|
||||||
): Promise<NhostFunctionCallResponse<T>>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
* Use `nhost.functions.call` to call (sending a POST request to) a serverless function.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,6 +28,4 @@ export type NhostFunctionCallResponse<T = unknown> =
|
|||||||
/** Subset of RequestInit parameters that are supported by the functions client */
|
/** Subset of RequestInit parameters that are supported by the functions client */
|
||||||
export interface NhostFunctionCallConfig {
|
export interface NhostFunctionCallConfig {
|
||||||
headers?: Record<string, string>
|
headers?: Record<string, string>
|
||||||
/** @deprecated Axios has been replaced by cross-fetch. You should now remove this option. */
|
|
||||||
useAxios?: false
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { NhostClientConstructorParams } from '../utils/types'
|
|||||||
/**
|
/**
|
||||||
* Creates a client for Storage from either a subdomain or a URL
|
* Creates a client for Storage from either a subdomain or a URL
|
||||||
*/
|
*/
|
||||||
export function createStorageClient(params: NhostClientConstructorParams<undefined>) {
|
export function createStorageClient(params: NhostClientConstructorParams) {
|
||||||
const storageUrl =
|
const storageUrl =
|
||||||
'subdomain' in params || 'backendUrl' in params
|
'subdomain' in params || 'backendUrl' in params
|
||||||
? urlFromSubdomain(params, 'storage')
|
? urlFromSubdomain(params, 'storage')
|
||||||
|
|||||||
6
packages/nhost-js/typedoc.tsconfig.json
Normal file
6
packages/nhost-js/typedoc.tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"paths": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,18 @@
|
|||||||
# @nhost/react
|
# @nhost/react
|
||||||
|
|
||||||
|
## 2.0.11
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@2.1.1
|
||||||
|
|
||||||
|
## 2.0.10
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [bfb4c1a6]
|
||||||
|
- @nhost/nhost-js@2.1.0
|
||||||
|
|
||||||
## 2.0.9
|
## 2.0.9
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/react",
|
"name": "@nhost/react",
|
||||||
"version": "2.0.9",
|
"version": "2.0.11",
|
||||||
"description": "Nhost React library",
|
"description": "Nhost React library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
@@ -1,5 +1,18 @@
|
|||||||
# @nhost/vue
|
# @nhost/vue
|
||||||
|
|
||||||
|
## 1.13.17
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- @nhost/nhost-js@2.1.1
|
||||||
|
|
||||||
|
## 1.13.16
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [bfb4c1a6]
|
||||||
|
- @nhost/nhost-js@2.1.0
|
||||||
|
|
||||||
## 1.13.15
|
## 1.13.15
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@nhost/vue",
|
"name": "@nhost/vue",
|
||||||
"version": "1.13.15",
|
"version": "1.13.17",
|
||||||
"description": "Nhost Vue library",
|
"description": "Nhost Vue library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|||||||
27
pnpm-lock.yaml
generated
27
pnpm-lock.yaml
generated
@@ -113,7 +113,7 @@ importers:
|
|||||||
'@storybook/manager-webpack5': ^6.5.14
|
'@storybook/manager-webpack5': ^6.5.14
|
||||||
'@storybook/react': ^6.5.14
|
'@storybook/react': ^6.5.14
|
||||||
'@storybook/testing-library': ^0.0.13
|
'@storybook/testing-library': ^0.0.13
|
||||||
'@stripe/react-stripe-js': ^1.10.0
|
'@stripe/react-stripe-js': ^2.0.0
|
||||||
'@stripe/stripe-js': ^1.35.0
|
'@stripe/stripe-js': ^1.35.0
|
||||||
'@tailwindcss/forms': ^0.5.3
|
'@tailwindcss/forms': ^0.5.3
|
||||||
'@tanstack/react-query': ^4.16.1
|
'@tanstack/react-query': ^4.16.1
|
||||||
@@ -224,7 +224,7 @@ importers:
|
|||||||
'@nhost/nextjs': link:../packages/nextjs
|
'@nhost/nextjs': link:../packages/nextjs
|
||||||
'@nhost/react-apollo': link:../integrations/react-apollo
|
'@nhost/react-apollo': link:../integrations/react-apollo
|
||||||
'@segment/snippet': 4.15.3
|
'@segment/snippet': 4.15.3
|
||||||
'@stripe/react-stripe-js': 1.14.2_mljfwq7caaxrtdqn7u72ntpebq
|
'@stripe/react-stripe-js': 2.0.0_mljfwq7caaxrtdqn7u72ntpebq
|
||||||
'@stripe/stripe-js': 1.44.1
|
'@stripe/stripe-js': 1.44.1
|
||||||
'@tailwindcss/forms': 0.5.3_tailwindcss@3.2.1
|
'@tailwindcss/forms': 0.5.3_tailwindcss@3.2.1
|
||||||
'@tanstack/react-query': 4.16.1_biqbaboplfbrettd7655fr4n2y
|
'@tanstack/react-query': 4.16.1_biqbaboplfbrettd7655fr4n2y
|
||||||
@@ -1020,6 +1020,7 @@ importers:
|
|||||||
|
|
||||||
packages/nhost-js:
|
packages/nhost-js:
|
||||||
specifiers:
|
specifiers:
|
||||||
|
'@nhost/docgen': workspace:*
|
||||||
'@nhost/graphql-js': workspace:*
|
'@nhost/graphql-js': workspace:*
|
||||||
'@nhost/hasura-auth-js': workspace:*
|
'@nhost/hasura-auth-js': workspace:*
|
||||||
'@nhost/hasura-storage-js': workspace:*
|
'@nhost/hasura-storage-js': workspace:*
|
||||||
@@ -1031,6 +1032,7 @@ importers:
|
|||||||
'@nhost/hasura-storage-js': link:../hasura-storage-js
|
'@nhost/hasura-storage-js': link:../hasura-storage-js
|
||||||
isomorphic-unfetch: 3.1.0
|
isomorphic-unfetch: 3.1.0
|
||||||
devDependencies:
|
devDependencies:
|
||||||
|
'@nhost/docgen': link:../docgen
|
||||||
graphql: 16.6.0
|
graphql: 16.6.0
|
||||||
|
|
||||||
packages/react:
|
packages/react:
|
||||||
@@ -11546,10 +11548,10 @@ packages:
|
|||||||
resolve-from: 5.0.0
|
resolve-from: 5.0.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@stripe/react-stripe-js/1.14.2_mljfwq7caaxrtdqn7u72ntpebq:
|
/@stripe/react-stripe-js/2.0.0_mljfwq7caaxrtdqn7u72ntpebq:
|
||||||
resolution: {integrity: sha512-8dGBdSFldq6dyiYgv3r4tOwS5PGAO/446hodegSKlmWg7NkAl0McopszXJd11A9otGi47v5OzCsljyfHJgnLhw==}
|
resolution: {integrity: sha512-JEzZlVdJaU9g3sZIcgCUXfHqvmDGF2pBqDVWxTJLAhSBNARp5kyFEoTFQzeCdPwrq3D4ZMJVgc6i6mbUgiXsgQ==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@stripe/stripe-js': ^1.42.1
|
'@stripe/stripe-js': ^1.44.1
|
||||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0
|
react: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||||
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
|
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -15041,7 +15043,7 @@ packages:
|
|||||||
/axios/0.25.0_debug@4.3.4:
|
/axios/0.25.0_debug@4.3.4:
|
||||||
resolution: {integrity: sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==}
|
resolution: {integrity: sha512-cD8FOb0tRH3uuEe6+evtAbgJtfxr7ly3fQjYcMcuPlgkwVS9xboaVIpcDV+cYQe+yGykgwZCs1pzjntcGa6l5g==}
|
||||||
dependencies:
|
dependencies:
|
||||||
follow-redirects: 1.15.2_debug@4.3.4
|
follow-redirects: 1.15.2
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- debug
|
- debug
|
||||||
dev: true
|
dev: true
|
||||||
@@ -20301,19 +20303,6 @@ packages:
|
|||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
debug:
|
debug:
|
||||||
optional: true
|
optional: true
|
||||||
dev: false
|
|
||||||
|
|
||||||
/follow-redirects/1.15.2_debug@4.3.4:
|
|
||||||
resolution: {integrity: sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==}
|
|
||||||
engines: {node: '>=4.0'}
|
|
||||||
peerDependencies:
|
|
||||||
debug: '*'
|
|
||||||
peerDependenciesMeta:
|
|
||||||
debug:
|
|
||||||
optional: true
|
|
||||||
dependencies:
|
|
||||||
debug: 4.3.4
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/for-each/0.3.3:
|
/for-each/0.3.3:
|
||||||
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==}
|
||||||
|
|||||||
Reference in New Issue
Block a user