Compare commits
28 Commits
release-20
...
@nhost/rea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90e8843314 | ||
|
|
aa5b360932 | ||
|
|
daa4b8b2ad | ||
|
|
a1c5c97a59 | ||
|
|
b338793d6d | ||
|
|
b1fb4b2400 | ||
|
|
f75e023672 | ||
|
|
8e78c1ff00 | ||
|
|
9cbb0b2986 | ||
|
|
363a3b92e5 | ||
|
|
6a078fc972 | ||
|
|
1091e9674a | ||
|
|
9738108d58 | ||
|
|
65951e1d1d | ||
|
|
b4af994a58 | ||
|
|
c6347e10bc | ||
|
|
278a641bc1 | ||
|
|
3320ddd8c8 | ||
|
|
bc9eff6e41 | ||
|
|
258c608882 | ||
|
|
ae84f269d4 | ||
|
|
0327250b19 | ||
|
|
7f56eabd24 | ||
|
|
be110df83a | ||
|
|
361e648daf | ||
|
|
8a72e20e3d | ||
|
|
125ec390ca | ||
|
|
7cc788a373 |
@@ -1,5 +0,0 @@
|
||||
---
|
||||
'@nhost/docs': patch
|
||||
---
|
||||
|
||||
added functions to custom domains documentation
|
||||
@@ -1,5 +1,24 @@
|
||||
# @nhost/dashboard
|
||||
|
||||
## 1.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/react-apollo@7.0.1
|
||||
- @nhost/nextjs@2.0.1
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- bc9eff6e4: chore: remove support for using backendUrl when instantiating the Nhost client
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/nextjs@2.0.0
|
||||
- @nhost/react-apollo@7.0.0
|
||||
|
||||
## 0.21.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/dashboard",
|
||||
"version": "0.21.1",
|
||||
"version": "1.0.1",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"preinstall": "npx only-allow pnpm",
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { ProjectFragment } from '@/utils/__generated__/graphql';
|
||||
import { test, vi } from 'vitest';
|
||||
import generateAppServiceUrl, {
|
||||
defaultLocalBackendSlugs,
|
||||
defaultRemoteBackendSlugs,
|
||||
} from './generateAppServiceUrl';
|
||||
|
||||
@@ -138,7 +137,7 @@ test('should be able to override the default remote backend slugs', () => {
|
||||
process.env.NEXT_PUBLIC_ENV = 'production';
|
||||
|
||||
expect(
|
||||
generateAppServiceUrl('test', region, 'hasura', defaultLocalBackendSlugs, {
|
||||
generateAppServiceUrl('test', region, 'hasura', {
|
||||
...defaultRemoteBackendSlugs,
|
||||
hasura: '/lorem-ipsum',
|
||||
}),
|
||||
@@ -187,24 +186,3 @@ test('should construct service URLs based on environment variables', () => {
|
||||
'https://localdev4.nhost.run/v1/functions',
|
||||
);
|
||||
});
|
||||
|
||||
test('should generate a basic subdomain with a custom port if provided', () => {
|
||||
process.env.NEXT_PUBLIC_NHOST_BACKEND_URL = `http://localhost:1338`;
|
||||
process.env.NEXT_PUBLIC_NHOST_PLATFORM = 'true';
|
||||
|
||||
expect(generateAppServiceUrl('test', region, 'auth')).toBe(
|
||||
`http://localhost:1338/v1/auth`,
|
||||
);
|
||||
|
||||
expect(generateAppServiceUrl('test', region, 'storage')).toBe(
|
||||
`http://localhost:1338/v1/files`,
|
||||
);
|
||||
|
||||
expect(generateAppServiceUrl('test', region, 'graphql')).toBe(
|
||||
`http://localhost:1338/v1/graphql`,
|
||||
);
|
||||
|
||||
expect(generateAppServiceUrl('test', region, 'functions')).toBe(
|
||||
`http://localhost:1338/v1/functions`,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -62,7 +62,6 @@ export default function generateAppServiceUrl(
|
||||
subdomain: string,
|
||||
region: ProjectFragment['region'],
|
||||
service: NhostService,
|
||||
localBackendSlugs = defaultLocalBackendSlugs,
|
||||
remoteBackendSlugs = defaultRemoteBackendSlugs,
|
||||
) {
|
||||
const IS_PLATFORM = isPlatform();
|
||||
@@ -87,12 +86,6 @@ export default function generateAppServiceUrl(
|
||||
return serviceUrls[service];
|
||||
}
|
||||
|
||||
// This is only used when running the dashboard locally against its own
|
||||
// backend.
|
||||
if (process.env.NEXT_PUBLIC_ENV === 'dev') {
|
||||
return `${process.env.NEXT_PUBLIC_NHOST_BACKEND_URL}${localBackendSlugs[service]}`;
|
||||
}
|
||||
|
||||
const constructedDomain = [
|
||||
subdomain,
|
||||
service,
|
||||
|
||||
@@ -16,7 +16,6 @@ import { useAppClient } from '@/features/projects/common/hooks/useAppClient';
|
||||
import { useCurrentWorkspaceAndProject } from '@/features/projects/common/hooks/useCurrentWorkspaceAndProject';
|
||||
import { useIsPlatform } from '@/features/projects/common/hooks/useIsPlatform';
|
||||
import {
|
||||
defaultLocalBackendSlugs,
|
||||
defaultRemoteBackendSlugs,
|
||||
generateAppServiceUrl,
|
||||
} from '@/features/projects/common/utils/generateAppServiceUrl';
|
||||
@@ -110,7 +109,6 @@ export default function SystemEnvironmentVariableSettings() {
|
||||
currentProject?.subdomain,
|
||||
currentProject?.region,
|
||||
'hasura',
|
||||
defaultLocalBackendSlugs,
|
||||
{ ...defaultRemoteBackendSlugs, hasura: '/console' },
|
||||
),
|
||||
},
|
||||
|
||||
@@ -11,7 +11,6 @@ import { Text } from '@/components/ui/v2/Text';
|
||||
import { useCurrentWorkspaceAndProject } from '@/features/projects/common/hooks/useCurrentWorkspaceAndProject';
|
||||
import { useIsPlatform } from '@/features/projects/common/hooks/useIsPlatform';
|
||||
import {
|
||||
defaultLocalBackendSlugs,
|
||||
defaultRemoteBackendSlugs,
|
||||
generateAppServiceUrl,
|
||||
} from '@/features/projects/common/utils/generateAppServiceUrl';
|
||||
@@ -39,7 +38,6 @@ export default function HasuraPage() {
|
||||
currentProject?.subdomain,
|
||||
currentProject?.region,
|
||||
'hasura',
|
||||
defaultLocalBackendSlugs,
|
||||
{ ...defaultRemoteBackendSlugs, hasura: '/console' },
|
||||
);
|
||||
|
||||
|
||||
10
dashboard/src/utils/env/env.ts
vendored
10
dashboard/src/utils/env/env.ts
vendored
@@ -5,16 +5,6 @@ export function isPlatform() {
|
||||
return process.env.NEXT_PUBLIC_NHOST_PLATFORM === 'true';
|
||||
}
|
||||
|
||||
/**
|
||||
* Backend URL for the locally running instance. This is only used when running
|
||||
* the Nhost Dashboard locally.
|
||||
*/
|
||||
export function getLocalBackendUrl() {
|
||||
return `http://localhost:${
|
||||
process.env.NEXT_PUBLIC_NHOST_LOCAL_SERVICES_PORT || '1337'
|
||||
}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin secret for Hasura.
|
||||
*/
|
||||
|
||||
@@ -9,16 +9,11 @@ import { NhostClient } from '@nhost/nextjs';
|
||||
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
const nhost = isPlatform()
|
||||
? new NhostClient({ backendUrl: process.env.NEXT_PUBLIC_NHOST_BACKEND_URL })
|
||||
: getAuthServiceUrl() &&
|
||||
getGraphqlServiceUrl() &&
|
||||
getStorageServiceUrl() &&
|
||||
getFunctionsServiceUrl()
|
||||
? new NhostClient({
|
||||
authUrl: getAuthServiceUrl(),
|
||||
graphqlUrl: getGraphqlServiceUrl(),
|
||||
storageUrl: getStorageServiceUrl(),
|
||||
functionsUrl: getFunctionsServiceUrl(),
|
||||
storageUrl: getStorageServiceUrl(),
|
||||
})
|
||||
: new NhostClient({ subdomain: 'local' });
|
||||
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost/docs
|
||||
|
||||
## 0.7.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2a04bc9e5: added functions to custom domains documentation
|
||||
|
||||
## 0.7.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/docs",
|
||||
"version": "0.7.3",
|
||||
"version": "0.7.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"docusaurus": "docusaurus",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost-examples/docker-compose
|
||||
|
||||
## 0.0.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a1c5c97a5: Clarify instructions for running the Nhost dashboard with Docker Compose
|
||||
|
||||
## 0.0.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -25,10 +25,12 @@ The following endpoints are now exposed:
|
||||
|
||||
## Running the Nhost dashboard locally
|
||||
|
||||
In order to use the Nhost dashboard, you need to run the [Hasura console locally from the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/commands/hasura_console/):
|
||||
In order for you to be able to make edits to the database from the Nhost dashboard, you need to run the [Hasura console locally from the Hasura CLI](https://hasura.io/docs/latest/hasura-cli/commands/hasura_console/):
|
||||
|
||||
```sh
|
||||
hasura console
|
||||
```
|
||||
|
||||
The Nhost Dashboard also requires the Hasura admin secret to `nhost-admin-secret`. This will change in the future. If you can't wait, don't hesitate to contribute.
|
||||
The Nhost Dashboard [uses](https://github.com/nhost/nhost/discussions/2398) the [Hasura migrations API](https://hasura.io/docs/latest/hasura-cli/commands/hasura_console/#options) in order to make edits to the database. It runs over port 9693 and is only accessible through running the Hasura console from the CLI. Because the Docker compose still only uses the graphql-engine Hasura Docker image and does not include the CLI image, that is why you need to run it locally. See https://github.com/nhost/nhost/issues/1220. Users are welcome to contibute a Docker compose that includes the CLI image to resolve this.
|
||||
|
||||
The Nhost Dashboard also requires the Hasura admin secret to `nhost-admin-secret` specified in the `.env` file.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost-examples/docker-compose",
|
||||
"version": "0.0.5",
|
||||
"version": "0.0.6",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"e2e": "vitest run"
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
# @nhost-examples/multi-tenant-one-to-many
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- bc9eff6e4: chore: remove support for using backendUrl when instantiating the Nhost client
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/nhost-js@3.0.0
|
||||
|
||||
## 1.0.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@nhost-examples/multi-tenant-one-to-many",
|
||||
"private": true,
|
||||
"version": "1.0.4",
|
||||
"version": "2.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NhostClient } from "@nhost/nhost-js";
|
||||
import { NhostClient } from '@nhost/nhost-js'
|
||||
|
||||
const nhost = new NhostClient({
|
||||
backendUrl: "http://localhost:1337",
|
||||
});
|
||||
subdomain: 'local'
|
||||
})
|
||||
|
||||
export { nhost };
|
||||
export { nhost }
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @nhost-examples/nextjs-server-components
|
||||
|
||||
## 0.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/nhost-js@3.0.1
|
||||
|
||||
## 0.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/nhost-js@3.0.0
|
||||
|
||||
## 0.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost-examples/nextjs-server-components",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch",
|
||||
"install-browsers": "pnpm dlx playwright@1.31.0 install --with-deps",
|
||||
"add-nhost-js": "pnpm add @nhost/nhost-js --ignore-workspace",
|
||||
"add-nhost-js": "pnpm add @nhost/nhost-js@2.2.18 --ignore-workspace",
|
||||
"test": "pnpm install-browsers && pnpm add-nhost-js && pnpm dlx playwright@1.31.0 test",
|
||||
"lint": "eslint .",
|
||||
"postinstall": "pnpm add-nhost-js"
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
# @nhost-examples/react-gqty
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- bc9eff6e4: chore: remove support for using backendUrl when instantiating the Nhost client
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/react@3.0.0
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@nhost-examples/react-gqty",
|
||||
"private": true,
|
||||
"version": "0.0.9",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { NhostClient } from '@nhost/react'
|
||||
|
||||
const nhost = new NhostClient({
|
||||
backendUrl: import.meta.env.VITE_NHOST_URL || 'http://localhost:1337'
|
||||
subdomain: import.meta.env.VITE_NHOST_SUBDOMAIN || 'local',
|
||||
region: import.meta.env.VITE_NHOST_REGION
|
||||
})
|
||||
|
||||
export { nhost }
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @nhost/apollo
|
||||
|
||||
## 6.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/nhost-js@3.0.1
|
||||
|
||||
## 6.0.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/nhost-js@3.0.0
|
||||
|
||||
## 5.2.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/apollo",
|
||||
"version": "5.2.22",
|
||||
"version": "6.0.1",
|
||||
"description": "Nhost Apollo Client library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
# @nhost/react-apollo
|
||||
|
||||
## 7.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/apollo@6.0.1
|
||||
- @nhost/react@3.0.1
|
||||
|
||||
## 7.0.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/react@3.0.0
|
||||
- @nhost/apollo@6.0.0
|
||||
|
||||
## 6.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/react-apollo",
|
||||
"version": "6.0.1",
|
||||
"version": "7.0.1",
|
||||
"description": "Nhost React Apollo client",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @nhost/react-urql
|
||||
|
||||
## 4.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/react@3.0.1
|
||||
|
||||
## 4.0.0
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/react@3.0.0
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/react-urql",
|
||||
"version": "3.0.1",
|
||||
"version": "4.0.1",
|
||||
"description": "Nhost React URQL client",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @nhost/hasura-auth-js
|
||||
|
||||
## 2.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b338793d6: Fix typo
|
||||
|
||||
## 2.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/hasura-auth-js",
|
||||
"version": "2.1.9",
|
||||
"version": "2.1.10",
|
||||
"description": "Hasura-auth client",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -633,7 +633,7 @@ export class HasuraAuthClient {
|
||||
* @example
|
||||
* ```ts
|
||||
* // if `x-hasura-company-id` exists as a custom claim
|
||||
* const companyId = nhost.auth.getHsauraClaim('company-id')
|
||||
* const companyId = nhost.auth.getHasuraClaim('company-id')
|
||||
* ```
|
||||
*
|
||||
* @param name Name of the variable. You don't have to specify `x-hasura-`.
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# @nhost/nextjs
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/react@3.0.1
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- bc9eff6e4: chore: remove support for using backendUrl when instantiating the Nhost client
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/react@3.0.0
|
||||
|
||||
## 1.13.40
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/nextjs",
|
||||
"version": "1.13.40",
|
||||
"version": "2.0.1",
|
||||
"description": "Nhost NextJS library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {
|
||||
AuthMachine,
|
||||
NHOST_REFRESH_TOKEN_KEY,
|
||||
NhostClient,
|
||||
NhostReactClientConstructorParams,
|
||||
NhostSession,
|
||||
NHOST_REFRESH_TOKEN_KEY,
|
||||
VanillaNhostClient
|
||||
} from '@nhost/react'
|
||||
import Cookies from 'js-cookie'
|
||||
@@ -29,27 +29,11 @@ export type CreateServerSideClientParams = Partial<
|
||||
* @returns instance of `NhostClient` that is ready to use on the server side (signed in or signed out)
|
||||
*/
|
||||
export const createServerSideClient = async (
|
||||
params: string | CreateServerSideClientParams,
|
||||
params: CreateServerSideClientParams,
|
||||
context: GetServerSidePropsContext
|
||||
): 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({
|
||||
...clientParams,
|
||||
...params,
|
||||
clientStorageType: 'custom',
|
||||
clientStorage: {
|
||||
getItem: (key) => {
|
||||
|
||||
@@ -41,12 +41,13 @@ import { createServerSideClient, CreateServerSideClientParams } from './create-s
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param backendUrl - URL of your Nhost application
|
||||
* @param subdomain - URL of your Nhost application
|
||||
* @param region - Region of your Nhost application
|
||||
* @param context - Next.js context
|
||||
* @returns Nhost session
|
||||
*/
|
||||
export const getNhostSession = async (
|
||||
params: string | CreateServerSideClientParams,
|
||||
params: CreateServerSideClientParams,
|
||||
context: GetServerSidePropsContext
|
||||
): Promise<NhostSession | null> => {
|
||||
const nhost = await createServerSideClient(params, context)
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
# @nhost/nhost-js
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b338793d6]
|
||||
- @nhost/hasura-auth-js@2.1.10
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- bc9eff6e4: chore: remove support for using backendUrl when instantiating the Nhost client
|
||||
|
||||
## 2.2.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/nhost-js",
|
||||
"version": "2.2.18",
|
||||
"version": "3.0.1",
|
||||
"description": "Nhost JavaScript SDK",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -7,10 +7,7 @@ import { NhostClientConstructorParams } from '../utils/types'
|
||||
* Creates a client for Auth from either a subdomain or a URL
|
||||
*/
|
||||
export function createAuthClient(params: NhostClientConstructorParams) {
|
||||
const authUrl =
|
||||
'subdomain' in params || 'backendUrl' in params
|
||||
? urlFromSubdomain(params, 'auth')
|
||||
: params.authUrl
|
||||
const authUrl = 'subdomain' in params ? urlFromSubdomain(params, 'auth') : params.authUrl
|
||||
|
||||
if (!authUrl) {
|
||||
throw new Error('Please provide `subdomain` or `authUrl`.')
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
*/
|
||||
export function createFunctionsClient(params: NhostClientConstructorParams) {
|
||||
const functionsUrl =
|
||||
'subdomain' in params || 'backendUrl' in params
|
||||
'subdomain' in params
|
||||
? urlFromSubdomain(params, 'functions')
|
||||
: params.functionsUrl
|
||||
|
||||
|
||||
@@ -6,10 +6,7 @@ import { NhostClientConstructorParams } from '../utils/types'
|
||||
* Creates a client for GraphQL from either a subdomain or a URL
|
||||
*/
|
||||
export function createGraphqlClient(params: NhostClientConstructorParams) {
|
||||
const graphqlUrl =
|
||||
'subdomain' in params || 'backendUrl' in params
|
||||
? urlFromSubdomain(params, 'graphql')
|
||||
: params.graphqlUrl
|
||||
const graphqlUrl = 'subdomain' in params ? urlFromSubdomain(params, 'graphql') : params.graphqlUrl
|
||||
|
||||
if (!graphqlUrl) {
|
||||
throw new Error('Please provide `subdomain` or `graphqlUrl`.')
|
||||
|
||||
@@ -7,10 +7,7 @@ import { NhostClientConstructorParams } from '../utils/types'
|
||||
* Creates a client for Storage from either a subdomain or a URL
|
||||
*/
|
||||
export function createStorageClient(params: NhostClientConstructorParams) {
|
||||
const storageUrl =
|
||||
'subdomain' in params || 'backendUrl' in params
|
||||
? urlFromSubdomain(params, 'storage')
|
||||
: params.storageUrl
|
||||
const storageUrl = 'subdomain' in params ? urlFromSubdomain(params, 'storage') : params.storageUrl
|
||||
|
||||
if (!storageUrl) {
|
||||
throw new Error('Please provide `subdomain` or `storageUrl`.')
|
||||
|
||||
@@ -5,25 +5,20 @@ export const LOCALHOST_REGEX =
|
||||
/^((?<protocol>http[s]?):\/\/)?(?<host>(localhost|local))(:(?<port>(\d+|__\w+__)))?$/
|
||||
|
||||
/**
|
||||
* \`backendUrl\` should now be used only when self-hosting
|
||||
* \`subdomain\` and `region` should be used instead when using the Nhost platform
|
||||
* \`subdomain\` and `region` should be used when running the Nhost platform
|
||||
*
|
||||
* @param backendOrSubdomain
|
||||
* @param subdomainAndRegion
|
||||
* @param service
|
||||
* @returns
|
||||
*/
|
||||
export function urlFromSubdomain(
|
||||
backendOrSubdomain: Pick<NhostClientConstructorParams, 'region' | 'subdomain' | 'backendUrl'>,
|
||||
subdomainAndRegion: Pick<NhostClientConstructorParams, 'region' | 'subdomain'>,
|
||||
service: string
|
||||
): string {
|
||||
const { backendUrl, subdomain, region } = backendOrSubdomain
|
||||
|
||||
if (backendUrl) {
|
||||
return `${backendUrl}/v1/${service}`
|
||||
}
|
||||
const { subdomain, region } = subdomainAndRegion
|
||||
|
||||
if (!subdomain) {
|
||||
throw new Error('Either `backendUrl` or `subdomain` must be set.')
|
||||
throw new Error('A `subdomain` must be set.')
|
||||
}
|
||||
|
||||
// check if subdomain is [http[s]://]localhost[:port] or [http[s]://]local[:port]
|
||||
|
||||
@@ -32,14 +32,6 @@ export interface ActionSuccessState {
|
||||
isSuccess: boolean
|
||||
}
|
||||
|
||||
export type BackendUrl = {
|
||||
/**
|
||||
* Nhost backend URL
|
||||
* Will be deprecated in a future release. Please look at 'subdomain' and 'region' instead.
|
||||
*/
|
||||
backendUrl: string
|
||||
}
|
||||
|
||||
export type Subdomain = {
|
||||
/**
|
||||
* Project subdomain (e.g. `ieingiwnginwnfnegqwvdqwdwq`)
|
||||
@@ -66,11 +58,8 @@ export type ServiceUrls = {
|
||||
functionsUrl?: string
|
||||
}
|
||||
|
||||
export type BackendOrSubdomain = BackendUrl | Subdomain
|
||||
|
||||
export interface NhostClientConstructorParams
|
||||
extends Partial<BackendUrl>,
|
||||
Partial<Subdomain>,
|
||||
extends Partial<Subdomain>,
|
||||
Partial<ServiceUrls>,
|
||||
Omit<NhostAuthConstructorParams, 'url'> {
|
||||
/**
|
||||
|
||||
@@ -2,20 +2,6 @@ import { describe, expect, it } from 'vitest'
|
||||
import { buildUrl, LOCALHOST_REGEX, urlFromSubdomain } from '../src/utils/helpers'
|
||||
|
||||
describe('urlFromParams', () => {
|
||||
describe('when using backendUrl', () => {
|
||||
it('should return the full url with the path "/v1/auth" concatenated', async () => {
|
||||
const url = urlFromSubdomain({ backendUrl: 'http://localhost' }, 'auth')
|
||||
|
||||
expect(url).toBe('http://localhost/v1/auth')
|
||||
})
|
||||
|
||||
it('should return the full url with the path "/v1/storage" concatenated', async () => {
|
||||
const url = urlFromSubdomain({ backendUrl: 'http://localhost:1337' }, 'storage')
|
||||
|
||||
expect(url).toBe('http://localhost:1337/v1/storage')
|
||||
})
|
||||
})
|
||||
|
||||
describe('using subdomain', () => {
|
||||
describe('other than "localhost" and a region', () => {
|
||||
it('should return the full authentication url', async () => {
|
||||
@@ -140,7 +126,9 @@ describe('buildUrl', () => {
|
||||
})
|
||||
|
||||
it('should handle missing parameters', () => {
|
||||
// @ts-ignore
|
||||
expect(() => buildUrl()).toThrow()
|
||||
// @ts-ignore
|
||||
expect(() => buildUrl('https://example.com')).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# @nhost/react
|
||||
|
||||
## 3.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/nhost-js@3.0.1
|
||||
|
||||
## 3.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- bc9eff6e4: chore: remove support for using backendUrl when instantiating the Nhost client
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/nhost-js@3.0.0
|
||||
|
||||
## 2.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/react",
|
||||
"version": "2.1.1",
|
||||
"version": "3.0.1",
|
||||
"description": "Nhost React library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
export type { BackendUrl, ErrorPayload, NhostSession, Subdomain, User } from '@nhost/nhost-js'
|
||||
export type { ErrorPayload, NhostSession, Subdomain, User } from '@nhost/nhost-js'
|
||||
export * from './client'
|
||||
export * from './components'
|
||||
export * from './provider'
|
||||
export * from './useAccessToken'
|
||||
export * from './useAddSecurityKey'
|
||||
export * from './useAuthInterpreter'
|
||||
export * from './useAuthenticated'
|
||||
export * from './useAuthenticationStatus'
|
||||
export * from './useAuthInterpreter'
|
||||
export * from './useChangeEmail'
|
||||
export * from './useChangePassword'
|
||||
export * from './useConfigMfa'
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
# @nhost/vue
|
||||
|
||||
## 2.0.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @nhost/nhost-js@3.0.1
|
||||
|
||||
## 2.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- bc9eff6e4: chore: remove support for using backendUrl when instantiating the Nhost client
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [bc9eff6e4]
|
||||
- @nhost/nhost-js@3.0.0
|
||||
|
||||
## 1.14.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@nhost/vue",
|
||||
"version": "1.14.1",
|
||||
"version": "2.0.1",
|
||||
"description": "Nhost Vue library",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
BackendUrl,
|
||||
NhostAuthConstructorParams,
|
||||
NhostClient as VanillaClient,
|
||||
removeParameterFromWindow,
|
||||
@@ -8,11 +7,10 @@ import {
|
||||
import { App, warn } from 'vue'
|
||||
import { DefaultNhostClient } from './useNhostClient'
|
||||
|
||||
export type { BackendUrl, ErrorPayload, NhostSession, Subdomain, User } from '@nhost/nhost-js'
|
||||
export type { ErrorPayload, NhostSession, Subdomain, User } from '@nhost/nhost-js'
|
||||
|
||||
export interface NhostVueClientConstructorParams
|
||||
extends Partial<BackendUrl>,
|
||||
Partial<Subdomain>,
|
||||
extends Partial<Subdomain>,
|
||||
Omit<NhostAuthConstructorParams, 'url' | 'start' | 'client'> {}
|
||||
|
||||
export class NhostClient extends VanillaClient {
|
||||
|
||||
71
pnpm-lock.yaml
generated
71
pnpm-lock.yaml
generated
@@ -1001,7 +1001,7 @@ importers:
|
||||
devDependencies:
|
||||
'@nhost/nhost-js':
|
||||
specifier: 2.2.18
|
||||
version: link:../../../packages/nhost-js
|
||||
version: 2.2.18(graphql@16.7.1)
|
||||
'@playwright/test':
|
||||
specifier: ^1.31.0
|
||||
version: 1.31.0
|
||||
@@ -1569,7 +1569,7 @@ importers:
|
||||
version: 3.1.1(graphql@16.7.1)
|
||||
isomorphic-unfetch:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0(encoding@0.1.13)
|
||||
version: 3.1.0
|
||||
devDependencies:
|
||||
'@nhost/docgen':
|
||||
specifier: workspace:*
|
||||
@@ -1650,7 +1650,7 @@ importers:
|
||||
version: link:../react
|
||||
isomorphic-unfetch:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0(encoding@0.1.13)
|
||||
version: 3.1.0
|
||||
js-cookie:
|
||||
specifier: ^3.0.1
|
||||
version: 3.0.1
|
||||
@@ -1687,7 +1687,7 @@ importers:
|
||||
version: link:../hasura-storage-js
|
||||
isomorphic-unfetch:
|
||||
specifier: ^3.1.0
|
||||
version: 3.1.0(encoding@0.1.13)
|
||||
version: 3.1.0
|
||||
devDependencies:
|
||||
'@nhost/docgen':
|
||||
specifier: workspace:*
|
||||
@@ -10600,6 +10600,54 @@ packages:
|
||||
dev: false
|
||||
optional: true
|
||||
|
||||
/@nhost/graphql-js@0.1.4(graphql@16.7.1):
|
||||
resolution: {integrity: sha512-IPHuGOf4iQrFsxG7Rh5jCCZzPCN9JkvldFww4Fz1lCVi9ZQNEaGaawIP5gBuBHeYIuALeaK1wVYKPc7vJ/euCA==}
|
||||
peerDependencies:
|
||||
graphql: 16.7.1
|
||||
dependencies:
|
||||
'@graphql-typed-document-node/core': 3.2.0(graphql@16.7.1)
|
||||
graphql: 16.7.1
|
||||
isomorphic-unfetch: 3.1.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: true
|
||||
|
||||
/@nhost/hasura-auth-js@2.1.9:
|
||||
resolution: {integrity: sha512-tZl6iArGBIuzaD9ZMCR4NUNxXneIj87c15nG0RWqzqScMAklQ0l9J52CLeE8NDPNFWFuwNLm2FBpnEz4YGJLVw==}
|
||||
dependencies:
|
||||
'@simplewebauthn/browser': 6.0.0
|
||||
fetch-ponyfill: 7.1.0
|
||||
js-cookie: 3.0.5
|
||||
jwt-decode: 3.1.2
|
||||
xstate: 4.38.2
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: true
|
||||
|
||||
/@nhost/hasura-storage-js@2.2.5:
|
||||
resolution: {integrity: sha512-IW0IwHlvuo9PxVQTXoQUE8LOpuOnjp+XlqgAKeatg1rY0MjJokcm4Xd0yLInAXfYBkK0r9pdKz7+RW+GDiYQ5g==}
|
||||
dependencies:
|
||||
fetch-ponyfill: 7.1.0
|
||||
form-data: 4.0.0
|
||||
xstate: 4.38.2
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: true
|
||||
|
||||
/@nhost/nhost-js@2.2.18(graphql@16.7.1):
|
||||
resolution: {integrity: sha512-aHn6p75fuG7SEUyB/yfX5TXtVTqwCT88zdN9Mmgo/8hnFOGV1XM7B4fxuGpNQCz18tG6kjM24tWx8EGXAEZ1sw==}
|
||||
peerDependencies:
|
||||
graphql: 16.7.1
|
||||
dependencies:
|
||||
'@nhost/graphql-js': 0.1.4(graphql@16.7.1)
|
||||
'@nhost/hasura-auth-js': 2.1.9
|
||||
'@nhost/hasura-storage-js': 2.2.5
|
||||
graphql: 16.7.1
|
||||
isomorphic-unfetch: 3.1.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: true
|
||||
|
||||
/@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1:
|
||||
resolution: {integrity: sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==}
|
||||
dependencies:
|
||||
@@ -11600,7 +11648,6 @@ packages:
|
||||
|
||||
/@simplewebauthn/browser@6.0.0:
|
||||
resolution: {integrity: sha512-gaXZmNfBPFawVZLhDPHkArCt0ttUbNSQSq24muyFmUi/QfJIhvQfQH7kfqIwlAXKqs79qpJ4RCYsRUjVj0Yl6w==}
|
||||
dev: false
|
||||
|
||||
/@simplewebauthn/typescript-types@6.0.0:
|
||||
resolution: {integrity: sha512-zBs5duUHwQ2CCnHckalMJycv8p2mfWGv+m9sI3WxnK3QR7Lw0/014zKkhC+Uygz5XSHuvPAxeMft6FbrP/OmtQ==}
|
||||
@@ -22305,7 +22352,6 @@ packages:
|
||||
node-fetch: 2.6.12(encoding@0.1.13)
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: false
|
||||
|
||||
/fetch-retry@5.0.3:
|
||||
resolution: {integrity: sha512-uJQyMrX5IJZkhoEUBQ3EjxkeiZkppBd5jS/fMTJmfZxLSiaQjv2zD0kTvuvkSH89uFvgSlB6ueGpjD3HWN7Bxw==}
|
||||
@@ -24838,7 +24884,7 @@ packages:
|
||||
- encoding
|
||||
dev: true
|
||||
|
||||
/isomorphic-unfetch@3.1.0(encoding@0.1.13):
|
||||
/isomorphic-unfetch@3.1.0:
|
||||
resolution: {integrity: sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==}
|
||||
dependencies:
|
||||
node-fetch: 2.6.7(encoding@0.1.13)
|
||||
@@ -24846,6 +24892,15 @@ packages:
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
|
||||
/isomorphic-unfetch@3.1.0(encoding@0.1.13):
|
||||
resolution: {integrity: sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==}
|
||||
dependencies:
|
||||
node-fetch: 2.6.12(encoding@0.1.13)
|
||||
unfetch: 4.2.0
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: true
|
||||
|
||||
/isomorphic-ws@5.0.0(ws@8.12.1):
|
||||
resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==}
|
||||
peerDependencies:
|
||||
@@ -25091,7 +25146,6 @@ packages:
|
||||
/js-cookie@3.0.5:
|
||||
resolution: {integrity: sha512-cEiJEAEoIbWfCZYKWhVwFuvPX1gETRYPw6LlaTKoxD3s2AkXzkCjnp6h0V77ozyqj0jakteJ4YqDJT830+lVGw==}
|
||||
engines: {node: '>=14'}
|
||||
dev: false
|
||||
|
||||
/js-levenshtein@1.1.6:
|
||||
resolution: {integrity: sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==}
|
||||
@@ -25421,7 +25475,6 @@ packages:
|
||||
|
||||
/jwt-decode@3.1.2:
|
||||
resolution: {integrity: sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==}
|
||||
dev: false
|
||||
|
||||
/keyv@3.1.0:
|
||||
resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==}
|
||||
|
||||
Reference in New Issue
Block a user