Compare commits

..

12 Commits

Author SHA1 Message Date
github-actions[bot]
11f9ed7507 chore: update versions (#2739)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @nhost/dashboard@1.17.0

### Minor Changes

- 77fba27: fix: postgres version validation when activating ai in ai
settings page
-   ac6d1b6: feat: use name instead of awsName

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-05 11:07:59 +01:00
David Barroso
ac6d1b6e01 feat (dashboard): use name instead of awsName (#2745) 2024-06-05 10:55:42 +01:00
Zephyr (David B.M.)
77fba27d12 fix (dashboard): validate postgres version in ai service settings page (#2735) 2024-05-31 12:38:36 +02:00
github-actions[bot]
7163854767 chore: update versions (#2724)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @nhost/apollo@7.1.2

### Patch Changes

-   @nhost/nhost-js@3.1.5

## @nhost/react-apollo@12.0.2

### Patch Changes

-   @nhost/apollo@7.1.2
-   @nhost/react@3.5.2

## @nhost/react-urql@9.0.2

### Patch Changes

-   @nhost/react@3.5.2

## @nhost/hasura-auth-js@2.5.2

### Patch Changes

- a03fb2c: fix: deep clone machine context to prevent mutations in
nested objects during initial session setup

## @nhost/nextjs@2.1.16

### Patch Changes

-   @nhost/react@3.5.2

## @nhost/nhost-js@3.1.5

### Patch Changes

-   Updated dependencies [a03fb2c]
    -   @nhost/hasura-auth-js@2.5.2

## @nhost/react@3.5.2

### Patch Changes

-   @nhost/nhost-js@3.1.5

## @nhost/vue@2.6.2

### Patch Changes

-   @nhost/nhost-js@3.1.5

## @nhost/docs@2.13.0

### Minor Changes

-   6fb0cc2: fix: minor improvements to compute resources' docs
-   66bd450: chore: various improvements

## @nhost/dashboard@1.16.3

### Patch Changes

- 87a37cf: fix: remove unnecessary isPlatform check from verify button
disable logic on custom domains
    -   @nhost/react-apollo@12.0.2
    -   @nhost/nextjs@2.1.16

## @nhost-examples/cli@0.3.7

### Patch Changes

-   @nhost/nhost-js@3.1.5

## @nhost-examples/codegen-react-apollo@0.4.7

### Patch Changes

-   @nhost/react@3.5.2
-   @nhost/react-apollo@12.0.2

## @nhost-examples/codegen-react-query@0.4.7

### Patch Changes

-   @nhost/react@3.5.2

## @nhost-examples/codegen-react-urql@0.3.7

### Patch Changes

-   @nhost/react@3.5.2
-   @nhost/react-urql@9.0.2

## @nhost-examples/multi-tenant-one-to-many@2.2.7

### Patch Changes

-   @nhost/nhost-js@3.1.5

## @nhost-examples/nextjs@0.3.7

### Patch Changes

-   @nhost/react@3.5.2
-   @nhost/react-apollo@12.0.2
-   @nhost/nextjs@2.1.16

## @nhost-examples/node-storage@0.2.7

### Patch Changes

-   @nhost/nhost-js@3.1.5

## @nhost-examples/nextjs-server-components@0.4.7

### Patch Changes

-   @nhost/nhost-js@3.1.5

## @nhost-examples/react-apollo@0.8.7

### Patch Changes

-   @nhost/react@3.5.2
-   @nhost/react-apollo@12.0.2

## @nhost-examples/react-gqty@1.2.7

### Patch Changes

-   @nhost/react@3.5.2

## @nhost-examples/vue-apollo@0.6.7

### Patch Changes

-   @nhost/nhost-js@3.1.5
-   @nhost/apollo@7.1.2
-   @nhost/vue@2.6.2

## @nhost-examples/vue-quickstart@0.2.7

### Patch Changes

-   @nhost/apollo@7.1.2
-   @nhost/vue@2.6.2

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-31 10:25:11 +01:00
David Barroso
66bd4504d7 chore (docs): various improvements (#2738)
- Adds references to custom domains in social signin methods
- a short note to remind users to update the SDK instantiation when
using custom domains
- added a sample function to generate custom jwts
2024-05-31 11:22:11 +02:00
Hassan Ben Jobrane
a03fb2cf82 fix(hasura-auth-js): deep clone machine context to avoid mutating nested objects (#2736)
fixes https://github.com/nhost/nhost/issues/2732
2024-05-31 10:20:18 +01:00
Hassan Ben Jobrane
87a37cfc08 fix(dashboard): remove isPlatform check from verify button disable logic (#2737) 2024-05-31 09:54:55 +01:00
David Barroso
6fb0cc27aa fix (docs): improvements to compute resources (#2723) 2024-05-23 16:19:36 +02:00
github-actions[bot]
2c33051f83 chore: update versions (#2719)
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @nhost/apollo@7.1.1

### Patch Changes

-   @nhost/nhost-js@3.1.4

## @nhost/react-apollo@12.0.1

### Patch Changes

-   @nhost/apollo@7.1.1
-   @nhost/react@3.5.1

## @nhost/react-urql@9.0.1

### Patch Changes

-   @nhost/react@3.5.1

## @nhost/hasura-auth-js@2.5.1

### Patch Changes

- f4f0353: fix: improve environment/browser detection to support React
Native
- defffd8: fix: resolve issue where `/token` endpoint is called with an
empty token during sign-in

## @nhost/nextjs@2.1.15

### Patch Changes

-   @nhost/react@3.5.1

## @nhost/nhost-js@3.1.4

### Patch Changes

-   Updated dependencies [f4f0353]
-   Updated dependencies [defffd8]
    -   @nhost/hasura-auth-js@2.5.1

## @nhost/react@3.5.1

### Patch Changes

-   @nhost/nhost-js@3.1.4

## @nhost/vue@2.6.1

### Patch Changes

-   @nhost/nhost-js@3.1.4

## @nhost/dashboard@1.16.2

### Patch Changes

- a9413af: fix: update `GetAllWorkspacesAndProjects` query polling to
use exponential backoff
    -   @nhost/react-apollo@12.0.1
    -   @nhost/nextjs@2.1.15

## @nhost-examples/cli@0.3.6

### Patch Changes

-   @nhost/nhost-js@3.1.4

## @nhost-examples/codegen-react-apollo@0.4.6

### Patch Changes

-   @nhost/react@3.5.1
-   @nhost/react-apollo@12.0.1

## @nhost-examples/codegen-react-query@0.4.6

### Patch Changes

-   @nhost/react@3.5.1

## @nhost-examples/codegen-react-urql@0.3.6

### Patch Changes

-   @nhost/react@3.5.1
-   @nhost/react-urql@9.0.1

## @nhost-examples/multi-tenant-one-to-many@2.2.6

### Patch Changes

-   @nhost/nhost-js@3.1.4

## @nhost-examples/nextjs@0.3.6

### Patch Changes

-   @nhost/react@3.5.1
-   @nhost/react-apollo@12.0.1
-   @nhost/nextjs@2.1.15

## @nhost-examples/node-storage@0.2.6

### Patch Changes

-   @nhost/nhost-js@3.1.4

## @nhost-examples/nextjs-server-components@0.4.6

### Patch Changes

-   @nhost/nhost-js@3.1.4

## @nhost-examples/react-apollo@0.8.6

### Patch Changes

-   @nhost/react@3.5.1
-   @nhost/react-apollo@12.0.1

## @nhost-examples/react-gqty@1.2.6

### Patch Changes

-   @nhost/react@3.5.1

## @nhost-examples/vue-apollo@0.6.6

### Patch Changes

-   @nhost/nhost-js@3.1.4
-   @nhost/apollo@7.1.1
-   @nhost/vue@2.6.1

## @nhost-examples/vue-quickstart@0.2.6

### Patch Changes

-   @nhost/apollo@7.1.1
-   @nhost/vue@2.6.1

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-21 15:23:32 +01:00
Hassan Ben Jobrane
a9413af6e0 fix: update GetAllWorkspacesAndProjects query polling to use exp backoff (#2718) 2024-05-21 13:44:38 +01:00
Hassan Ben Jobrane
f4f0353f2e fix(hasura-auth-js): resolve social sign-in issue in React Native (#2716)
fix https://github.com/nhost/nhost/issues/2216
2024-05-20 19:13:13 +01:00
Hassan Ben Jobrane
defffd8bc4 fix: update internal-client to use payload.token instead of payload.token.data (#2717) 2024-05-20 19:05:21 +01:00
86 changed files with 763 additions and 89 deletions

View File

@@ -1,5 +1,28 @@
# @nhost/dashboard
## 1.17.0
### Minor Changes
- 77fba27: fix: postgres version validation when activating ai in ai settings page
- ac6d1b6: feat: use name instead of awsName
## 1.16.3
### Patch Changes
- 87a37cf: fix: remove unnecessary isPlatform check from verify button disable logic on custom domains
- @nhost/react-apollo@12.0.2
- @nhost/nextjs@2.1.16
## 1.16.2
### Patch Changes
- a9413af: fix: update `GetAllWorkspacesAndProjects` query polling to use exponential backoff
- @nhost/react-apollo@12.0.1
- @nhost/nextjs@2.1.15
## 1.16.1
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/dashboard",
"version": "1.16.1",
"version": "1.17.0",
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",

View File

@@ -32,8 +32,7 @@ import { FormProvider, useForm } from 'react-hook-form';
import { toast } from 'react-hot-toast';
import * as Yup from 'yup';
import { DisableAIServiceConfirmationDialog } from './DisableAIServiceConfirmationDialog';
const MIN_POSTGRES_VERSION_SUPPORTING_AI = '14.6-20231018-1';
import { isPostgresVersionValidForAI } from '@/features/ai/settings/utils/isPostgresVersionValidForAI';
const validationSchema = Yup.object({
version: Yup.object({
@@ -165,7 +164,7 @@ export default function AISettings() {
]);
const toggleAIService = async (enabled: boolean) => {
if (postgresVersion < MIN_POSTGRES_VERSION_SUPPORTING_AI) {
if (!isPostgresVersionValidForAI(postgresVersion)) {
toast.error(
'In order to enable the AI service you need to update your database version to 14.6-20231018-1 or newer.',
{
@@ -495,3 +494,4 @@ export default function AISettings() {
</Box>
);
}

View File

@@ -0,0 +1 @@
export { default as isPostgresVersionValidForAI } from './isPostgresVersionValidForAI';

View File

@@ -0,0 +1,22 @@
import { test, vi } from 'vitest';
import isPostgresVersionValidForAI from './isPostgresVersionValidForAI';
beforeEach(() => {
vi.resetModules();
});
test('greater than minimum version, minor version with two digits, should be valid', () => {
const postgresVersion = '14.11-20240515-1';
expect(isPostgresVersionValidForAI(postgresVersion)).toBe(true);
});
test('less than minimum version, should be invalid', () => {
const postgresVersion = '14.6-20221110-1';
expect(isPostgresVersionValidForAI(postgresVersion)).toBe(false);
});
test('equal to minimum version, should be valid', () => {
const postgresVersion = '14.6-20231018-1';
expect(isPostgresVersionValidForAI(postgresVersion)).toBe(true);
});

View File

@@ -0,0 +1,18 @@
/**
* Check if the given postgres version is valid for enabling AI in the project
*
* @param postgresVersion - Postgres version used in the project.
* @returns Whether is valid for enabling AI.
*/
export default function isPostgresVersionValidForAI(
postgresVersion: string,
): boolean {
const MIN_POSTGRES_VERSION_SUPPORTING_AI = '14.6-20231018-1';
if (/^14\.6-/.test(postgresVersion)) {
return postgresVersion >= MIN_POSTGRES_VERSION_SUPPORTING_AI;
}
// Note: No need to account for versions less than 14.6
return true;
}

View File

@@ -5,7 +5,9 @@ import { useGetAnnouncementsQuery } from '@/utils/__generated__/graphql';
import formatDistance from 'date-fns/formatDistance';
export default function Announcements() {
const { data, loading, error } = useGetAnnouncementsQuery();
const { data, loading, error } = useGetAnnouncementsQuery({
fetchPolicy: 'cache-first',
});
const announcements = data?.announcements || [];

View File

@@ -108,7 +108,7 @@ export default function useCurrentWorkspaceAndProject(): UseCurrentWorkspaceAndP
id: null,
countryCode: null,
city: null,
awsName: null,
name: null,
domain: null,
},
createdAt: new Date().toISOString(),

View File

@@ -31,7 +31,7 @@ afterEach(() => {
const region: ProjectFragment['region'] = {
id: '1',
awsName: 'eu-west-1',
name: 'eu-west-1',
domain: 'nhost.run',
city: 'Dublin',
countryCode: 'IE',

View File

@@ -89,7 +89,7 @@ export default function generateAppServiceUrl(
const constructedDomain = [
subdomain,
service,
region?.awsName,
region?.name,
region?.domain || 'nhost.run',
]
.filter(Boolean)

View File

@@ -165,7 +165,7 @@ export default function AuthDomain() {
<VerifyDomain
recordType="CNAME"
hostname={auth_fqdn}
value={`lb.${currentProject.region.awsName}.${currentProject.region.domain}.`}
value={`lb.${currentProject.region.name}.${currentProject.region.domain}.`}
onHostNameVerified={() => setIsVerified(true)}
/>
</div>

View File

@@ -167,7 +167,7 @@ export default function HasuraDomain() {
<VerifyDomain
recordType="CNAME"
hostname={hasura_fqdn}
value={`lb.${currentProject.region.awsName}.${currentProject.region.domain}.`}
value={`lb.${currentProject.region.name}.${currentProject.region.domain}.`}
onHostNameVerified={() => setIsVerified(true)}
/>
</div>

View File

@@ -162,7 +162,7 @@ export default function RunServicePortDomain({
<VerifyDomain
recordType="CNAME"
hostname={runServicePortFQDN}
value={`lb.${currentProject.region.awsName}.${currentProject.region.domain}.`}
value={`lb.${currentProject.region.name}.${currentProject.region.domain}.`}
onHostNameVerified={() => setIsVerified(true)}
/>
</div>

View File

@@ -169,7 +169,7 @@ export default function ServerlessFunctionsDomain() {
<VerifyDomain
recordType="CNAME"
hostname={functions_fqdn}
value={`lb.${currentProject.region.awsName}.${currentProject.region.domain}.`}
value={`lb.${currentProject.region.name}.${currentProject.region.domain}.`}
onHostNameVerified={() => setIsVerified(true)}
/>
</div>

View File

@@ -131,7 +131,7 @@ export default function VerifyDomain({
</div>
{isPlatform ? (
<Button
disabled={loading || !hostname || isPlatform}
disabled={loading || !hostname}
onClick={handleVerifyDomain}
className="mt-4 sm:absolute sm:bottom-0 sm:right-0 sm:mt-0"
>

View File

@@ -101,7 +101,7 @@ export default function SystemEnvironmentVariableSettings() {
const systemEnvironmentVariables = [
{ key: 'NHOST_SUBDOMAIN', value: currentProject.subdomain },
{ key: 'NHOST_REGION', value: currentProject.region.awsName },
{ key: 'NHOST_REGION', value: currentProject.region.name },
{
key: 'NHOST_HASURA_URL',
value:

View File

@@ -7,7 +7,7 @@ export default function OverviewProjectInfo() {
const { currentProject } = useCurrentWorkspaceAndProject();
const { region, subdomain } = currentProject || {};
const isRegionAvailable =
region?.awsName && region?.countryCode && region?.city;
region?.name && region?.countryCode && region?.city;
return (
<div className="grid grid-flow-row content-start gap-6">
@@ -17,7 +17,7 @@ export default function OverviewProjectInfo() {
<div className="grid grid-flow-row gap-3">
<InfoCard
title="Region"
value={region?.awsName}
value={region?.name}
customValue={
region?.countryCode &&
region?.city && (
@@ -30,7 +30,7 @@ export default function OverviewProjectInfo() {
/>
<Text className="truncate text-sm font-medium">
{region.city} ({region.awsName})
{region.city} ({region.name})
</Text>
</div>
)

View File

@@ -190,7 +190,7 @@ export default function ServiceForm({
image:
values.image.length > 0
? values.image
: `registry.${currentProject.region.awsName}.${currentProject.region.domain}/${newServiceID}`,
: `registry.${currentProject.region.name}.${currentProject.region.domain}/${newServiceID}`,
},
},
},
@@ -361,7 +361,7 @@ export default function ServiceForm({
{isPlatform && serviceID && serviceImage && (
<InfoCard
title="Private registry"
value={`registry.${currentProject.region.awsName}.${currentProject.region.domain}/${serviceID}`}
value={`registry.${currentProject.region.name}.${currentProject.region.domain}/${serviceID}`}
/>
)}

View File

@@ -43,7 +43,7 @@ export default function PortsFormSection() {
const getPortURL = (_port: string | number, subdomain: string) => {
const port = Number(_port) > 0 ? Number(_port) : '[port]';
return `https://${subdomain}-${port}.svc.${currentProject?.region.awsName}.${currentProject?.region.domain}`;
return `https://${subdomain}-${port}.svc.${currentProject?.region.name}.${currentProject?.region.domain}`;
};
return (

View File

@@ -35,7 +35,7 @@ export default function ServiceDetailsDialog({
const getPortURL = (_port: string | number) => {
const port = Number(_port) > 0 ? Number(_port) : '[port]';
return `https://${subdomain}-${port}.svc.${currentProject?.region.awsName}.${currentProject?.region.domain}`;
return `https://${subdomain}-${port}.svc.${currentProject?.region.name}.${currentProject?.region.domain}`;
};
return (
@@ -44,7 +44,7 @@ export default function ServiceDetailsDialog({
<Text color="secondary">Private registry</Text>
<InfoCard
title=""
value={`registry.${currentProject.region.awsName}.${currentProject.region.domain}/${serviceID}`}
value={`registry.${currentProject.region.name}.${currentProject.region.domain}/${serviceID}`}
/>
</div>

View File

@@ -39,7 +39,7 @@ fragment Project on apps {
region {
id
countryCode
awsName
name
domain
city
}

View File

@@ -7,41 +7,55 @@ import { Button } from '@/components/ui/v2/Button';
import { Text } from '@/components/ui/v2/Text';
import { WorkspaceAndProjectList } from '@/features/projects/common/components/WorkspaceAndProjectList';
import { WorkspaceSidebar } from '@/features/projects/common/components/WorkspaceSidebar';
import { useGetAllWorkspacesAndProjectsQuery } from '@/utils/__generated__/graphql';
import {
useGetAllWorkspacesAndProjectsQuery,
type GetAllWorkspacesAndProjectsQuery,
} from '@/utils/__generated__/graphql';
import { NetworkStatus } from '@apollo/client';
import { darken } from '@mui/system';
import { useUserData } from '@nhost/nextjs';
import NavLink from 'next/link';
import type { ReactElement } from 'react';
import { useEffect } from 'react';
import { useState, type ReactElement } from 'react';
export default function IndexPage() {
const user = useUserData();
const { data, loading, startPolling, stopPolling } =
const [, setPollInterval] = useState(1_000);
// keep polling for workspaces until there is a workspace available.
// We do this because when a user signs up a workspace is created automatically
// and the serverless function can take some time to complete.
const { data, startPolling, stopPolling, networkStatus } =
useGetAllWorkspacesAndProjectsQuery({
skip: !user,
notifyOnNetworkStatusChange: true,
onError: () => {
// When there's an error (graphql, network error) apply an exponential backoff strategy
setPollInterval((prevInterval) => {
const newInterval = Math.min(60_000, prevInterval * 2);
startPolling(newInterval);
return newInterval;
});
},
onCompleted: (queryData: GetAllWorkspacesAndProjectsQuery) => {
if (!queryData?.workspaces.length) {
setPollInterval(1000);
startPolling(1000);
} else {
setPollInterval(0);
stopPolling();
}
},
});
// keep showing loading indicator while polling
const loading = networkStatus === NetworkStatus.loading;
const numberOfProjects = data?.workspaces.reduce(
(projectCount, currentWorkspace) =>
projectCount + currentWorkspace.projects.length,
0,
);
// keep polling for workspaces until there is a workspace available.
// We do this because when a user signs up a workspace is created automatically
// and the serverless function can take some time to complete.
useEffect(() => {
startPolling(1000);
}, [startPolling]);
useEffect(() => {
if (!data?.workspaces.length) {
return;
}
stopPolling();
}, [data?.workspaces, stopPolling]);
if ((!data && loading) || !user) {
return <LoadingScreen />;
}

View File

@@ -50,7 +50,7 @@ export const mockApplication: Project = {
appStates: [],
subdomain: '',
region: {
awsName: 'us-east-1',
name: 'us-east-1',
city: 'New York',
countryCode: 'US',
id: '1',

View File

@@ -2657,6 +2657,12 @@ export type ConfigUserRoleComparisonExp = {
_nin?: InputMaybe<Array<Scalars['ConfigUserRole']>>;
};
export type ContainerError = {
__typename?: 'ContainerError';
lastError: LastError;
name: Scalars['String'];
};
/** Boolean expression to compare columns of type "Int". All fields are combined with logical 'AND'. */
export type Int_Comparison_Exp = {
_eq?: InputMaybe<Scalars['Int']>;
@@ -2683,6 +2689,13 @@ export type InvoiceSummary = {
items: Array<InvoiceItem>;
};
export type LastError = {
__typename?: 'LastError';
exitCode: Scalars['Int'];
message: Scalars['String'];
reason: Scalars['String'];
};
export type Log = {
__typename?: 'Log';
log: Scalars['String'];
@@ -2695,6 +2708,33 @@ export type Metrics = {
value: Scalars['float64'];
};
export type ProjectStatusResponse = {
__typename?: 'ProjectStatusResponse';
services: Array<ServiceStatus>;
};
export type ReplicaStatus = {
__typename?: 'ReplicaStatus';
date: Scalars['Timestamp'];
errors: Array<ContainerError>;
ready: Scalars['Boolean'];
};
export enum ServiceState {
Error = 'Error',
None = 'None',
Running = 'Running',
UpdateError = 'UpdateError',
Updating = 'Updating'
}
export type ServiceStatus = {
__typename?: 'ServiceStatus';
name: Scalars['String'];
replicas: Array<ReplicaStatus>;
state: ServiceState;
};
export type StatsLiveApps = {
__typename?: 'StatsLiveApps';
appID: Array<Scalars['uuid']>;
@@ -15948,6 +15988,7 @@ export type Query_Root = {
getLogsVolume: Metrics;
getPostgresVolumeCapacity: Metrics;
getPostgresVolumeUsage: Metrics;
getProjectStatus: ProjectStatusResponse;
/**
* Returns list of label values for a given label within a range of time.
*
@@ -16801,6 +16842,11 @@ export type Query_RootGetPostgresVolumeUsageArgs = {
};
export type Query_RootGetProjectStatusArgs = {
appID: Scalars['String'];
};
export type Query_RootGetServiceLabelValuesArgs = {
appID: Scalars['String'];
};
@@ -17427,6 +17473,7 @@ export type Regions = {
domain: Scalars['String'];
id: Scalars['uuid'];
isGdprCompliant: Scalars['Boolean'];
name: Scalars['String'];
/** An object relationship */
region_type: Region_Type;
/** An array relationship */
@@ -17804,6 +17851,7 @@ export type Regions_Bool_Exp = {
domain?: InputMaybe<String_Comparison_Exp>;
id?: InputMaybe<Uuid_Comparison_Exp>;
isGdprCompliant?: InputMaybe<Boolean_Comparison_Exp>;
name?: InputMaybe<String_Comparison_Exp>;
region_type?: InputMaybe<Region_Type_Bool_Exp>;
regions_allowed_workspaces?: InputMaybe<Regions_Allowed_Workspace_Bool_Exp>;
regions_allowed_workspaces_aggregate?: InputMaybe<Regions_Allowed_Workspace_Aggregate_Bool_Exp>;
@@ -17831,6 +17879,7 @@ export type Regions_Insert_Input = {
domain?: InputMaybe<Scalars['String']>;
id?: InputMaybe<Scalars['uuid']>;
isGdprCompliant?: InputMaybe<Scalars['Boolean']>;
name?: InputMaybe<Scalars['String']>;
region_type?: InputMaybe<Region_Type_Obj_Rel_Insert_Input>;
regions_allowed_workspaces?: InputMaybe<Regions_Allowed_Workspace_Arr_Rel_Insert_Input>;
type?: InputMaybe<Region_Type_Enum>;
@@ -17847,6 +17896,7 @@ export type Regions_Max_Fields = {
description?: Maybe<Scalars['String']>;
domain?: Maybe<Scalars['String']>;
id?: Maybe<Scalars['uuid']>;
name?: Maybe<Scalars['String']>;
updatedAt?: Maybe<Scalars['timestamptz']>;
};
@@ -17859,6 +17909,7 @@ export type Regions_Max_Order_By = {
description?: InputMaybe<Order_By>;
domain?: InputMaybe<Order_By>;
id?: InputMaybe<Order_By>;
name?: InputMaybe<Order_By>;
updatedAt?: InputMaybe<Order_By>;
};
@@ -17872,6 +17923,7 @@ export type Regions_Min_Fields = {
description?: Maybe<Scalars['String']>;
domain?: Maybe<Scalars['String']>;
id?: Maybe<Scalars['uuid']>;
name?: Maybe<Scalars['String']>;
updatedAt?: Maybe<Scalars['timestamptz']>;
};
@@ -17884,6 +17936,7 @@ export type Regions_Min_Order_By = {
description?: InputMaybe<Order_By>;
domain?: InputMaybe<Order_By>;
id?: InputMaybe<Order_By>;
name?: InputMaybe<Order_By>;
updatedAt?: InputMaybe<Order_By>;
};
@@ -17924,6 +17977,7 @@ export type Regions_Order_By = {
domain?: InputMaybe<Order_By>;
id?: InputMaybe<Order_By>;
isGdprCompliant?: InputMaybe<Order_By>;
name?: InputMaybe<Order_By>;
region_type?: InputMaybe<Region_Type_Order_By>;
regions_allowed_workspaces_aggregate?: InputMaybe<Regions_Allowed_Workspace_Aggregate_Order_By>;
type?: InputMaybe<Order_By>;
@@ -17956,6 +18010,8 @@ export enum Regions_Select_Column {
/** column name */
IsGdprCompliant = 'isGdprCompliant',
/** column name */
Name = 'name',
/** column name */
Type = 'type',
/** column name */
UpdatedAt = 'updatedAt'
@@ -17988,6 +18044,7 @@ export type Regions_Set_Input = {
domain?: InputMaybe<Scalars['String']>;
id?: InputMaybe<Scalars['uuid']>;
isGdprCompliant?: InputMaybe<Scalars['Boolean']>;
name?: InputMaybe<Scalars['String']>;
type?: InputMaybe<Region_Type_Enum>;
updatedAt?: InputMaybe<Scalars['timestamptz']>;
};
@@ -18011,6 +18068,7 @@ export type Regions_Stream_Cursor_Value_Input = {
domain?: InputMaybe<Scalars['String']>;
id?: InputMaybe<Scalars['uuid']>;
isGdprCompliant?: InputMaybe<Scalars['Boolean']>;
name?: InputMaybe<Scalars['String']>;
type?: InputMaybe<Region_Type_Enum>;
updatedAt?: InputMaybe<Scalars['timestamptz']>;
};
@@ -18036,6 +18094,8 @@ export enum Regions_Update_Column {
/** column name */
IsGdprCompliant = 'isGdprCompliant',
/** column name */
Name = 'name',
/** column name */
Type = 'type',
/** column name */
UpdatedAt = 'updatedAt'
@@ -22765,7 +22825,7 @@ export type DeleteApplicationMutation = { __typename?: 'mutation_root', deleteAp
export type GetAllWorkspacesAndProjectsQueryVariables = Exact<{ [key: string]: never; }>;
export type GetAllWorkspacesAndProjectsQuery = { __typename?: 'query_root', workspaces: Array<{ __typename?: 'workspaces', id: any, name: string, slug: string, creatorUserId?: any | null, workspaceMembers: Array<{ __typename?: 'workspaceMembers', id: any, type: string, user: { __typename?: 'users', id: any, email?: any | null, displayName: string } }>, projects: Array<{ __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, awsName: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null }> }> };
export type GetAllWorkspacesAndProjectsQuery = { __typename?: 'query_root', workspaces: Array<{ __typename?: 'workspaces', id: any, name: string, slug: string, creatorUserId?: any | null, workspaceMembers: Array<{ __typename?: 'workspaceMembers', id: any, type: string, user: { __typename?: 'users', id: any, email?: any | null, displayName: string } }>, projects: Array<{ __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, name: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null }> }> };
export type GetAppPlanAndGlobalPlansAppFragment = { __typename?: 'apps', id: any, subdomain: string, workspace: { __typename?: 'workspaces', id: any, paymentMethods: Array<{ __typename?: 'paymentMethods', id: any }> }, plan: { __typename?: 'plans', id: any, name: string } };
@@ -22822,7 +22882,7 @@ export type GetWorkspaceAndProjectQueryVariables = Exact<{
}>;
export type GetWorkspaceAndProjectQuery = { __typename?: 'query_root', workspaces: Array<{ __typename?: 'workspaces', id: any, name: string, slug: string, creatorUserId?: any | null, workspaceMembers: Array<{ __typename?: 'workspaceMembers', id: any, type: string, user: { __typename?: 'users', id: any, email?: any | null, displayName: string } }>, projects: Array<{ __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, awsName: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null }> }> };
export type GetWorkspaceAndProjectQuery = { __typename?: 'query_root', workspaces: Array<{ __typename?: 'workspaces', id: any, name: string, slug: string, creatorUserId?: any | null, workspaceMembers: Array<{ __typename?: 'workspaceMembers', id: any, type: string, user: { __typename?: 'users', id: any, email?: any | null, displayName: string } }>, projects: Array<{ __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, name: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null }> }> };
export type InsertApplicationMutationVariables = Exact<{
app: Apps_Insert_Input;
@@ -23014,9 +23074,9 @@ export type GetFilesAggregateQuery = { __typename?: 'query_root', filesAggregate
export type AppStateHistoryFragment = { __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any };
export type ProjectFragment = { __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, awsName: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null };
export type ProjectFragment = { __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, name: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null };
export type WorkspaceFragment = { __typename?: 'workspaces', id: any, name: string, slug: string, creatorUserId?: any | null, workspaceMembers: Array<{ __typename?: 'workspaceMembers', id: any, type: string, user: { __typename?: 'users', id: any, email?: any | null, displayName: string } }>, projects: Array<{ __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, awsName: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null }> };
export type WorkspaceFragment = { __typename?: 'workspaces', id: any, name: string, slug: string, creatorUserId?: any | null, workspaceMembers: Array<{ __typename?: 'workspaceMembers', id: any, type: string, user: { __typename?: 'users', id: any, email?: any | null, displayName: string } }>, projects: Array<{ __typename?: 'apps', id: any, slug: string, name: string, repositoryProductionBranch: string, subdomain: string, createdAt: any, desiredState: number, nhostBaseFolder: string, config?: { __typename?: 'ConfigConfig', observability: { __typename?: 'ConfigObservability', grafana: { __typename?: 'ConfigGrafana', adminPassword: string } }, hasura: { __typename?: 'ConfigHasura', adminSecret: string, settings?: { __typename?: 'ConfigHasuraSettings', enableConsole?: boolean | null } | null }, ai?: { __typename?: 'ConfigAI', version?: string | null } | null } | null, featureFlags: Array<{ __typename?: 'featureFlags', description: string, id: any, name: string, value: string }>, appStates: Array<{ __typename?: 'appStateHistory', id: any, appId: any, message?: string | null, stateId: number, createdAt: any }>, region: { __typename?: 'regions', id: any, countryCode: string, name: string, domain: string, city: string }, plan: { __typename?: 'plans', id: any, name: string, price: number, isFree: boolean, featureMaxDbSize: number }, githubRepository?: { __typename?: 'githubRepositories', fullName: string } | null, deployments: Array<{ __typename?: 'deployments', id: any, commitSHA: string, commitMessage?: string | null, commitUserName?: string | null, deploymentStartedAt?: any | null, deploymentEndedAt?: any | null, commitUserAvatarUrl?: string | null, deploymentStatus?: string | null }>, creator?: { __typename?: 'users', id: any, email?: any | null, displayName: string } | null }> };
export type GithubRepositoryFragment = { __typename?: 'githubRepositories', id: any, name: string, fullName: string, private: boolean, githubAppInstallation: { __typename?: 'githubAppInstallations', id: any, accountLogin?: string | null, accountType?: string | null, accountAvatarUrl?: string | null } };
@@ -23559,7 +23619,7 @@ export const ProjectFragmentDoc = gql`
region {
id
countryCode
awsName
name
domain
city
}

View File

@@ -1,5 +1,12 @@
# @nhost/docs
## 2.13.0
### Minor Changes
- 6fb0cc2: fix: minor improvements to compute resources' docs
- 66bd450: chore: various improvements
## 2.12.0
### Minor Changes

View File

@@ -0,0 +1,176 @@
---
title: Custom JWTs
description: Creating custom JWTs
icon: ghost
---
In some cases it is necessary to act on behalf of a user. While the Auth service doesn't allow that it is not difficult to implement such functionality as a serverless function. Below you can find an example of a function that can generate a valid access token for your application with customized values. For details read the docstring in the function itself.
Feel free to adapt to your needs.
### Dependencies
```
npm install jsonwebtoken
```
### Function
Create a file under `functions` (for instance `/functions/custom-jwts.ts`), with the following contents:
```js
import { Request, Response } from 'express'
import process from 'process'
import jwt from 'jsonwebtoken'
// function to extract jwt from the request
const getJwt = (req: Request): string | null => {
const authHeader = req.headers.authorization
if (!authHeader) {
return null
}
const parts = authHeader.split(' ')
if (parts.length !== 2) {
return null
}
const [scheme, token] = parts
if (!/^Bearer$/i.test(scheme)) {
return null
}
return token
}
// validate jwt token is valid and caller is either an admin or an operator
const jwtIsAuthorized = (req: Request, key: string): string => {
const token = getJwt(req)
if (!token) {
return ""
}
try {
const decoded = jwt.verify(token, key)
const claims = decoded['https://hasura.io/jwt/claims']
if ( !claims || !claims['x-hasura-allowed-roles'] ) {
return ""
}
if (
claims['x-hasura-allowed-roles'].includes('admin') ||
claims['x-hasura-allowed-roles'].includes('operator')
) {
return decoded.sub
}
return ""
} catch (e) {
return ""
}
}
/*
This is a sample function that generates a JWT token to impersonate users.
Authorization:
- send a valid JWT token with the request. The token should have the `admin` or `operator` role.
- send the `x-hasura-admin-secret` header with the request
Body:
A json object with the following keys:
- `userId` (string): the user id for which the token is generated
- `defaultRole` (string): the default role for the userId
- `allowedRoles` (array of strings): the roles that the userId can assume
Returns:
A json object with the following keys:
- `accessToken` (string) - The generated access token
In addition to the typical JWT claims generated by Nhost, the token generated by this function will have the following claims:
- `x-hasura-on-behalf-of`: the user id of the caller or `admin` if the caller used the `x-hasura-admin-secret` header
You are free to modify this function to suit your needs.
*/
export default (req: Request, res: Response) => {
let authorizedCaller = ""
if (req.headers['x-hasura-admin-secret'] === process.env.HASURA_GRAPHQL_ADMIN_SECRET) {
authorizedCaller = "admin"
}
const jwtSecret = JSON.parse(process.env.NHOST_JWT_SECRET)
if (!authorizedCaller) {
authorizedCaller = jwtIsAuthorized(req, jwtSecret.key)
}
if (!authorizedCaller) {
return res.status(401).json({ message: 'Unauthorized' })
}
// extract from json in the body
const {userId, defaultRole, allowedRoles} = req.body
if (!userId || !defaultRole || !allowedRoles) {
return res.status(400).json({ message: 'Bad request' })
}
let token = jwt.sign({
"exp": Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour
"https://hasura.io/jwt/claims": {
"x-hasura-allowed-roles": allowedRoles,
"x-hasura-default-role": defaultRole,
"x-hasura-user-id": userId,
"x-hasura-user-is-anonymous": "false",
"x-hasura-on-behalf-of": authorizedCaller
},
"iat": Math.floor(Date.now() / 1000),
"iss": "custom-lambda",
"sub": userId,
}, jwtSecret.key);
res.status(200).json(
{
accessToken: token,
},
)
}
```
Now you can call it like:
```
curl -X POST \
-H "Content-Type: application/json" \
-H "x-hasura-admin-secret: nhost-admin-secret" \
-d '{"userId": "FFAB5354-C5EB-42C1-8BC3-AD21D2297883", "defaultRole": "user", "allowedRoles": ["user", "me"]}' \
https://local.functions.nhost.run/v1/custom-jwt
{"accessToken":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTcxNDIyMTMsImh0dHBzOi8vaGFzdXJhLmlvL2p3dC9jbGFpbXMiOnsieC1oYXN1cmEtYWxsb3dlZC1yb2xlcyI6WyJ1c2VyIiwibWUiXSwieC1oYXN1cmEtZGVmYXVsdC1yb2xlIjoidXNlciIsIngtaGFzdXJhLXVzZXItaWQiOiJGRkFCNTM1NC1DNUVCLTQyQzEtOEJDMy1BRDIxRDIyOTc4ODMiLCJ4LWhhc3VyYS11c2VyLWlzLWFub255bW91cyI6ImZhbHNlIiwieC1oYXN1cmEtb24tYmVoYWxmLW9mIjoiYWRtaW4ifSwiaWF0IjoxNzE3MTM4NjEzLCJpc3MiOiJjdXN0b20tbGFtYmRhIiwic3ViIjoiRkZBQjUzNTQtQzVFQi00MkMxLThCQzMtQUQyMUQyMjk3ODgzIn0.bRhzJvXMdkQA8aXPH95uMT17WHED2rSRq3gE21Vp3Ak"}
```
The new token should be a valid token for your application with the custom values requested:
```json
{
"exp": 1717141288,
"https://hasura.io/jwt/claims": {
"x-hasura-allowed-roles": [
"a",
"b"
],
"x-hasura-default-role": "user",
"x-hasura-user-id": "FFAB5354-C5EB-42C1-8BC3-AD21D2297883",
"x-hasura-user-is-anonymous": "false",
"x-hasura-on-behalf-of": "admin"
},
"iat": 1717137688,
"iss": "custom-lambda",
"sub": "FFAB5354-C5EB-42C1-8BC3-AD21D2297883"
}
```

View File

@@ -93,3 +93,7 @@ nhost.auth.signIn({
provider: 'apple'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -41,3 +41,7 @@ nhost.auth.signIn({
provider: 'discord'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -64,3 +64,7 @@ nhost.auth.signIn({
provider: 'facebook'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -49,3 +49,7 @@ nhost.auth.signIn({
provider: "github",
});
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -73,3 +73,7 @@ nhost.auth.signIn({
provider: 'google'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -64,3 +64,7 @@ nhost.auth.signIn({
provider: 'linkedin'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -49,3 +49,7 @@ nhost.auth.signIn({
provider: 'spotify'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -43,3 +43,7 @@ nhost.auth.signIn({
provider: 'twitch'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -63,3 +63,7 @@ nhost.auth.signIn({
provider: 'workos'
})
```
<Note>
To use your own domain for the callback URL refer to the [custom domains](/platform/custom-domains) documentation.
</Note>

View File

@@ -16,7 +16,7 @@ In case your Postgres service is not meeting your performance expectations, you
4. Evaluate the usage of indexes in your database. Identify queries that could benefit from additional indexes and strategically add them to improve query performance.
5. Increase the disk size to increase [disk performance](/platform/compute-resources#disk-performance). Keep in mind increasing the disk size isn't reversible and increasing the memory of the service may yield better results. This is mostly useful when your data is very volatile and the postgres cache can't work effectively. Only attempt to increase disk for performance reasons if your reads and writes are very high and increasing memory isn't effective.
5. If the problem is related to IOPS, consider increasing [disk performance](/platform/compute-resources#disk-performance).
By implementing these steps, you can effectively address performance concerns and enhance the overall performance of your Postgres service.

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

View File

Before

Width:  |  Height:  |  Size: 241 KiB

After

Width:  |  Height:  |  Size: 241 KiB

View File

@@ -134,7 +134,8 @@
"guides/auth/sign-in-phone-number",
"guides/auth/sign-in-webauthn",
"guides/auth/elevated-permissions",
"guides/auth/email-templates"
"guides/auth/email-templates",
"guides/auth/custom-jwts"
]
},
{

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/docs",
"version": "2.12.0",
"version": "2.13.0",
"private": true,
"scripts": {
"start": "mintlify dev"

View File

@@ -72,6 +72,28 @@ To setup dedicated resources for your project, you can either use the Dashboard
</Tab>
</Tabs>
### Bursting with Dedicated Compute
When using dedicated compute we allow your application to use more than its alloted CPU resources if those resources are available. This means what we are calling dedicated compute is, in fact, guaranteed compute. For instance:
<div align="center">
<img width="300" src="/images/platform/compute-resources/guaranteed-resources.png" alt="resource allocation" />
</div>
In the graph above we can see three applications assigned to the same node, each with its own dedicated compute (the solid lines block). However, all applications are allowed to use the non-solid region of compute as long as the rest of the projects are not using it:
<div align="center">
<img width="300" src="/images/platform/compute-resources/resource-utilization.png" alt="resource utilization" />
</div>
Above we can see three different scenarios:
- In scenario A the green application is barely using its alloted CPU so if the other applications need it, they can borrow it.
- Similarly, in scenario B the green application can borrow resources if it needs it from other applications if those aren't using them.
- In the case all applications need to use all of their resources, nobody can steal from each other as resources are guaranteed per application.
This borrowing of resources is convenient in case of short and unexpected bursts, however, as those are not guaranteed you shouldn't rely on them for sustained usage.
## Disk Performance
By default disks are provisioned with a capacity for 3000 IOPS and 125 Mbps of throughput. If you need higher performance don't hesitate to contact us.

View File

@@ -18,7 +18,7 @@ The following examples assume we are configuring custom domains at `*.custom-dom
1. Add a CNAME record in your DNS provider for each of the services you want a custom domain for, and click "Verify". The verification might take a few seconds to succeed.
2. Once the verification succeeds, click "Save" to update your project.
![Custom Domains](./images/platform/custom-domains/custom-domains.png)
![Custom Domains](./images/platform/custom-domains/custom-domains-dashboard.png)
</Tab>
@@ -62,3 +62,16 @@ fqdn = ['my-service.custom-domain.com']
</Tab>
</Tabs>
<Note>
After configuring your custom domains don't forget to update your Nhost client to make use of them. For instance, when using our [SDK](/reference/javascript/nhost-js/nhost-client):
```js
const nhost = new NhostClient({
authUrl: 'https://auth.custom-domain.com/v1',
storageUrl: 'https://subdomain.storage.region.nhost.run/v1',
graphqlUrl: 'https://hasura.custom-domain.com/v1/graphql',
functionsUrl: 'https://functions.custom-domain.com/v1'
})
```
</Note>

View File

@@ -1,5 +1,17 @@
# @nhost-examples/cli
## 0.3.7
### Patch Changes
- @nhost/nhost-js@3.1.5
## 0.3.6
### Patch Changes
- @nhost/nhost-js@3.1.4
## 0.3.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/cli",
"version": "0.3.5",
"version": "0.3.7",
"main": "src/index.mjs",
"private": true,
"scripts": {

View File

@@ -1,5 +1,19 @@
# @nhost-examples/codegen-react-apollo
## 0.4.7
### Patch Changes
- @nhost/react@3.5.2
- @nhost/react-apollo@12.0.2
## 0.4.6
### Patch Changes
- @nhost/react@3.5.1
- @nhost/react-apollo@12.0.1
## 0.4.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/codegen-react-apollo",
"version": "0.4.5",
"version": "0.4.7",
"private": true,
"scripts": {
"codegen": "graphql-codegen",

View File

@@ -1,5 +1,17 @@
# @nhost-examples/codegen-react-query
## 0.4.7
### Patch Changes
- @nhost/react@3.5.2
## 0.4.6
### Patch Changes
- @nhost/react@3.5.1
## 0.4.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/codegen-react-query",
"version": "0.4.5",
"version": "0.4.7",
"private": true,
"scripts": {
"codegen": "graphql-codegen",

View File

@@ -1,5 +1,19 @@
# @nhost-examples/react-urql
## 0.3.7
### Patch Changes
- @nhost/react@3.5.2
- @nhost/react-urql@9.0.2
## 0.3.6
### Patch Changes
- @nhost/react@3.5.1
- @nhost/react-urql@9.0.1
## 0.3.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@nhost-examples/codegen-react-urql",
"private": true,
"version": "0.3.5",
"version": "0.3.7",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",

View File

@@ -1,5 +1,17 @@
# @nhost-examples/multi-tenant-one-to-many
## 2.2.7
### Patch Changes
- @nhost/nhost-js@3.1.5
## 2.2.6
### Patch Changes
- @nhost/nhost-js@3.1.4
## 2.2.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@nhost-examples/multi-tenant-one-to-many",
"private": true,
"version": "2.2.5",
"version": "2.2.7",
"description": "",
"main": "index.js",
"scripts": {},

View File

@@ -1,5 +1,21 @@
# @nhost-examples/nextjs
## 0.3.7
### Patch Changes
- @nhost/react@3.5.2
- @nhost/react-apollo@12.0.2
- @nhost/nextjs@2.1.16
## 0.3.6
### Patch Changes
- @nhost/react@3.5.1
- @nhost/react-apollo@12.0.1
- @nhost/nextjs@2.1.15
## 0.3.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/nextjs",
"version": "0.3.5",
"version": "0.3.7",
"private": true,
"scripts": {
"dev": "next dev",

View File

@@ -1,5 +1,17 @@
# @nhost-examples/node-storage
## 0.2.7
### Patch Changes
- @nhost/nhost-js@3.1.5
## 0.2.6
### Patch Changes
- @nhost/nhost-js@3.1.4
## 0.2.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/node-storage",
"version": "0.2.5",
"version": "0.2.7",
"private": true,
"description": "This is an example of how to use the Storage with Node.js",
"main": "src/index.mjs",

View File

@@ -1,5 +1,17 @@
# @nhost-examples/nextjs-server-components
## 0.4.7
### Patch Changes
- @nhost/nhost-js@3.1.5
## 0.4.6
### Patch Changes
- @nhost/nhost-js@3.1.4
## 0.4.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/nextjs-server-components",
"version": "0.4.5",
"version": "0.4.7",
"private": true,
"scripts": {
"dev": "next dev",

View File

@@ -1,5 +1,19 @@
# @nhost-examples/react-apollo
## 0.8.7
### Patch Changes
- @nhost/react@3.5.2
- @nhost/react-apollo@12.0.2
## 0.8.6
### Patch Changes
- @nhost/react@3.5.1
- @nhost/react-apollo@12.0.1
## 0.8.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/react-apollo",
"version": "0.8.5",
"version": "0.8.7",
"private": true,
"dependencies": {
"@apollo/client": "^3.9.9",

View File

@@ -1,5 +1,17 @@
# @nhost-examples/react-gqty
## 1.2.7
### Patch Changes
- @nhost/react@3.5.2
## 1.2.6
### Patch Changes
- @nhost/react@3.5.1
## 1.2.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@nhost-examples/react-gqty",
"private": true,
"version": "1.2.5",
"version": "1.2.7",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -1,5 +1,21 @@
# @nhost-examples/vue-apollo
## 0.6.7
### Patch Changes
- @nhost/nhost-js@3.1.5
- @nhost/apollo@7.1.2
- @nhost/vue@2.6.2
## 0.6.6
### Patch Changes
- @nhost/nhost-js@3.1.4
- @nhost/apollo@7.1.1
- @nhost/vue@2.6.1
## 0.6.5
### Patch Changes

View File

@@ -1,7 +1,7 @@
{
"name": "@nhost-examples/vue-apollo",
"private": true,
"version": "0.6.5",
"version": "0.6.7",
"scripts": {
"dev": "vite",
"build": "vite build",

View File

@@ -1,5 +1,19 @@
# @nhost-examples/vue-quickstart
## 0.2.7
### Patch Changes
- @nhost/apollo@7.1.2
- @nhost/vue@2.6.2
## 0.2.6
### Patch Changes
- @nhost/apollo@7.1.1
- @nhost/vue@2.6.1
## 0.2.5
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost-examples/vue-quickstart",
"version": "0.2.5",
"version": "0.2.7",
"private": true,
"scripts": {
"build": "vite build",

24
flake.lock generated
View File

@@ -5,11 +5,11 @@
"systems": "systems"
},
"locked": {
"lastModified": 1705309234,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
@@ -20,11 +20,11 @@
},
"nix-filter": {
"locked": {
"lastModified": 1705332318,
"narHash": "sha256-kcw1yFeJe9N4PjQji9ZeX47jg0p9A0DuU4djKvg1a7I=",
"lastModified": 1710156097,
"narHash": "sha256-1Wvk8UP7PXdf8bCCaEoMnOT1qe5/Duqgj+rL8sRQsSM=",
"owner": "numtide",
"repo": "nix-filter",
"rev": "3449dc925982ad46246cfc36469baf66e1b64f17",
"rev": "3342559a24e85fc164b295c3444e8a139924675b",
"type": "github"
},
"original": {
@@ -40,11 +40,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1709722688,
"narHash": "sha256-ng5a9klcxohFhs9xfNAcZWTveM4SlMWoRoWDYyXoECE=",
"lastModified": 1716813459,
"narHash": "sha256-kPV0JcxBO3krxLeGEAsk5tZ7GUo+DStD2Cg78iGm4v0=",
"owner": "nhost",
"repo": "nixops",
"rev": "919e405ab485c099a42d44a2936cab2d3b1bd444",
"rev": "981affa7a17fd064bb5096ccfec8ddd98b115ef5",
"type": "github"
},
"original": {
@@ -55,11 +55,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1708943256,
"narHash": "sha256-K9VeHrhXsigdhNMZ8hqAk7jtRy4ollqhkYYNZqbfssg=",
"lastModified": 1716715802,
"narHash": "sha256-usk0vE7VlxPX8jOavrtpOqphdfqEQpf9lgedlY/r66c=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "fcea2b6260dd566c28c894b4207a5f2b56c2cba3",
"rev": "e2dd4e18cc1c7314e24154331bae07df76eb582f",
"type": "github"
},
"original": {

View File

@@ -1,5 +1,17 @@
# @nhost/apollo
## 7.1.2
### Patch Changes
- @nhost/nhost-js@3.1.5
## 7.1.1
### Patch Changes
- @nhost/nhost-js@3.1.4
## 7.1.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/apollo",
"version": "7.1.0",
"version": "7.1.2",
"description": "Nhost Apollo Client library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,19 @@
# @nhost/react-apollo
## 12.0.2
### Patch Changes
- @nhost/apollo@7.1.2
- @nhost/react@3.5.2
## 12.0.1
### Patch Changes
- @nhost/apollo@7.1.1
- @nhost/react@3.5.1
## 12.0.0
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-apollo",
"version": "12.0.0",
"version": "12.0.2",
"description": "Nhost React Apollo client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,17 @@
# @nhost/react-urql
## 9.0.2
### Patch Changes
- @nhost/react@3.5.2
## 9.0.1
### Patch Changes
- @nhost/react@3.5.1
## 9.0.0
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react-urql",
"version": "9.0.0",
"version": "9.0.2",
"description": "Nhost React URQL client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,18 @@
# @nhost/hasura-auth-js
## 2.5.2
### Patch Changes
- a03fb2c: fix: deep clone machine context to prevent mutations in nested objects during initial session setup
## 2.5.1
### Patch Changes
- f4f0353: fix: improve environment/browser detection to support React Native
- defffd8: fix: resolve issue where `/token` endpoint is called with an empty token during sign-in
## 2.5.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/hasura-auth-js",
"version": "2.5.0",
"version": "2.5.2",
"description": "Hasura-auth client",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,11 @@
import { interpret } from 'xstate'
import { AuthInterpreter, AuthMachine, AuthMachineOptions, createAuthMachine } from './machines'
import {
AuthContext,
AuthInterpreter,
AuthMachine,
AuthMachineOptions,
createAuthMachine
} from './machines'
import { NhostSession } from './types'
import { isBrowser } from './utils'
@@ -60,8 +66,8 @@ export class AuthClient {
if (type === 'broadcast_token') {
const existingToken = this.interpreter?.getSnapshot().context.refreshToken.value
if (this.interpreter && payload.token.data !== existingToken) {
this.interpreter.send('TRY_TOKEN', { token: payload.token.data })
if (this.interpreter && payload.token && payload.token !== existingToken) {
this.interpreter.send('TRY_TOKEN', { token: payload.token })
}
}
})
@@ -87,7 +93,17 @@ export class AuthClient {
initialSession,
interpreter
}: { interpreter?: AuthInterpreter; initialSession?: NhostSession; devTools?: boolean } = {}) {
const context = { ...this.machine.context }
// Create a deep copy of the machine context to ensure that nested objects (such as accessToken and refreshToken) are not mutated in the original context.
const context: AuthContext = {
...this.machine.context,
accessToken: {
...this.machine.context.accessToken
},
refreshToken: {
...this.machine.context.refreshToken
}
}
if (initialSession) {
context.user = initialSession.user
context.refreshToken.value = initialSession.refreshToken ?? null

View File

@@ -1 +1,2 @@
export const isBrowser = () => typeof window !== 'undefined'
export const isBrowser = () =>
typeof window !== 'undefined' && typeof window.location !== 'undefined'

View File

@@ -1,5 +1,17 @@
# @nhost/nextjs
## 2.1.16
### Patch Changes
- @nhost/react@3.5.2
## 2.1.15
### Patch Changes
- @nhost/react@3.5.1
## 2.1.14
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nextjs",
"version": "2.1.14",
"version": "2.1.16",
"description": "Nhost NextJS library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,20 @@
# @nhost/nhost-js
## 3.1.5
### Patch Changes
- Updated dependencies [a03fb2c]
- @nhost/hasura-auth-js@2.5.2
## 3.1.4
### Patch Changes
- Updated dependencies [f4f0353]
- Updated dependencies [defffd8]
- @nhost/hasura-auth-js@2.5.1
## 3.1.3
### Patch Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/nhost-js",
"version": "3.1.3",
"version": "3.1.5",
"description": "Nhost JavaScript SDK",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,17 @@
# @nhost/react
## 3.5.2
### Patch Changes
- @nhost/nhost-js@3.1.5
## 3.5.1
### Patch Changes
- @nhost/nhost-js@3.1.4
## 3.5.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/react",
"version": "3.5.0",
"version": "3.5.2",
"description": "Nhost React library",
"license": "MIT",
"keywords": [

View File

@@ -1,5 +1,17 @@
# @nhost/vue
## 2.6.2
### Patch Changes
- @nhost/nhost-js@3.1.5
## 2.6.1
### Patch Changes
- @nhost/nhost-js@3.1.4
## 2.6.0
### Minor Changes

View File

@@ -1,6 +1,6 @@
{
"name": "@nhost/vue",
"version": "2.6.0",
"version": "2.6.2",
"description": "Nhost Vue library",
"license": "MIT",
"keywords": [