@seamapi/react 4.12.1 → 4.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -17
- package/dist/elements.js +9445 -9053
- package/dist/elements.js.map +1 -1
- package/dist/index.css +1 -0
- package/dist/index.css.map +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.min.css.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/seam/SeamProvider.d.ts +1 -1
- package/lib/seam/SeamProvider.js +1 -1
- package/lib/seam/SeamProvider.js.map +1 -1
- package/lib/seam/access-codes/use-access-code.js +1 -1
- package/lib/seam/access-codes/use-access-code.js.map +1 -1
- package/lib/seam/access-codes/use-access-codes.js +1 -1
- package/lib/seam/access-codes/use-access-codes.js.map +1 -1
- package/lib/seam/access-codes/use-create-access-code.d.ts +1 -1
- package/lib/seam/access-codes/use-create-access-code.js +1 -1
- package/lib/seam/access-codes/use-create-access-code.js.map +1 -1
- package/lib/seam/access-codes/use-delete-access-code.js +1 -1
- package/lib/seam/access-codes/use-delete-access-code.js.map +1 -1
- package/lib/seam/access-codes/use-generate-access-code-code.js +1 -1
- package/lib/seam/access-codes/use-generate-access-code-code.js.map +1 -1
- package/lib/seam/access-codes/use-update-access-code.js +1 -1
- package/lib/seam/access-codes/use-update-access-code.js.map +1 -1
- package/lib/seam/client-sessions/use-client-session.js +1 -1
- package/lib/seam/client-sessions/use-client-session.js.map +1 -1
- package/lib/seam/components/DeviceDetails/LockDeviceDetails.js +2 -23
- package/lib/seam/components/DeviceDetails/LockDeviceDetails.js.map +1 -1
- package/lib/seam/components/DeviceDetails/LockDeviceLockButtons.d.ts +11 -0
- package/lib/seam/components/DeviceDetails/LockDeviceLockButtons.js +68 -0
- package/lib/seam/components/DeviceDetails/LockDeviceLockButtons.js.map +1 -0
- package/lib/seam/components/SupportedDeviceTable/use-device-model.js +1 -1
- package/lib/seam/components/SupportedDeviceTable/use-device-model.js.map +1 -1
- package/lib/seam/components/SupportedDeviceTable/use-device-models.js +1 -1
- package/lib/seam/components/SupportedDeviceTable/use-device-models.js.map +1 -1
- package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js +1 -1
- package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js.map +1 -1
- package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js +1 -1
- package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js.map +1 -1
- package/lib/seam/connect-webviews/use-create-connect-webview.js +1 -1
- package/lib/seam/connect-webviews/use-create-connect-webview.js.map +1 -1
- package/lib/seam/connected-accounts/use-connected-account.js +1 -1
- package/lib/seam/connected-accounts/use-connected-account.js.map +1 -1
- package/lib/seam/devices/use-device-providers.js +1 -1
- package/lib/seam/devices/use-device-providers.js.map +1 -1
- package/lib/seam/devices/use-device.js +1 -1
- package/lib/seam/devices/use-device.js.map +1 -1
- package/lib/seam/devices/use-devices.js +1 -1
- package/lib/seam/devices/use-devices.js.map +1 -1
- package/lib/seam/devices/use-update-device-name.js +1 -1
- package/lib/seam/devices/use-update-device-name.js.map +1 -1
- package/lib/seam/events/use-events.js +1 -1
- package/lib/seam/events/use-events.js.map +1 -1
- package/lib/seam/index.d.ts +0 -6
- package/lib/seam/index.js +0 -6
- package/lib/seam/index.js.map +1 -1
- package/lib/seam/locks/use-lock-door.d.ts +17 -0
- package/lib/seam/locks/use-lock-door.js +60 -0
- package/lib/seam/locks/use-lock-door.js.map +1 -0
- package/lib/seam/locks/use-toggle-lock.js +1 -1
- package/lib/seam/locks/use-toggle-lock.js.map +1 -1
- package/lib/seam/locks/use-unlock-door.d.ts +17 -0
- package/lib/seam/locks/use-unlock-door.js +60 -0
- package/lib/seam/locks/use-unlock-door.js.map +1 -0
- package/lib/seam/noise-sensors/use-noise-thresholds.js +1 -1
- package/lib/seam/noise-sensors/use-noise-thresholds.js.map +1 -1
- package/lib/seam/thermostats/use-cool-thermostat.js +1 -1
- package/lib/seam/thermostats/use-cool-thermostat.js.map +1 -1
- package/lib/seam/thermostats/use-create-thermostat-climate-preset.js +1 -1
- package/lib/seam/thermostats/use-create-thermostat-climate-preset.js.map +1 -1
- package/lib/seam/thermostats/use-delete-thermostat-climate-preset.js +1 -1
- package/lib/seam/thermostats/use-delete-thermostat-climate-preset.js.map +1 -1
- package/lib/seam/thermostats/use-heat-cool-thermostat.js +1 -1
- package/lib/seam/thermostats/use-heat-cool-thermostat.js.map +1 -1
- package/lib/seam/thermostats/use-heat-thermostat.js +1 -1
- package/lib/seam/thermostats/use-heat-thermostat.js.map +1 -1
- package/lib/seam/thermostats/use-set-thermostat-fan-mode.js +1 -1
- package/lib/seam/thermostats/use-set-thermostat-fan-mode.js.map +1 -1
- package/lib/seam/thermostats/use-set-thermostat-off.js +1 -1
- package/lib/seam/thermostats/use-set-thermostat-off.js.map +1 -1
- package/lib/seam/thermostats/use-update-thermostat-climate-preset.js +1 -1
- package/lib/seam/thermostats/use-update-thermostat-climate-preset.js.map +1 -1
- package/lib/telemetry/hooks.js +1 -1
- package/lib/telemetry/hooks.js.map +1 -1
- package/lib/ui/DateTimePicker/DateTimePicker.d.ts +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -0
- package/src/lib/index.ts +0 -1
- package/src/lib/seam/SeamProvider.tsx +4 -4
- package/src/lib/seam/access-codes/use-access-code.ts +1 -1
- package/src/lib/seam/access-codes/use-access-codes.ts +1 -1
- package/src/lib/seam/access-codes/use-create-access-code.ts +2 -3
- package/src/lib/seam/access-codes/use-delete-access-code.ts +1 -2
- package/src/lib/seam/access-codes/use-generate-access-code-code.ts +1 -2
- package/src/lib/seam/access-codes/use-update-access-code.ts +1 -2
- package/src/lib/seam/client-sessions/use-client-session.ts +1 -1
- package/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx +7 -43
- package/src/lib/seam/components/DeviceDetails/LockDeviceLockButtons.tsx +137 -0
- package/src/lib/seam/components/SupportedDeviceTable/use-device-model.ts +1 -1
- package/src/lib/seam/components/SupportedDeviceTable/use-device-models.ts +1 -1
- package/src/lib/seam/components/SupportedDeviceTable/use-manufacturer.ts +1 -1
- package/src/lib/seam/components/SupportedDeviceTable/use-manufacturers.ts +1 -1
- package/src/lib/seam/connect-webviews/use-create-connect-webview.ts +1 -1
- package/src/lib/seam/connected-accounts/use-connected-account.ts +1 -1
- package/src/lib/seam/devices/use-device-providers.ts +1 -1
- package/src/lib/seam/devices/use-device.ts +1 -1
- package/src/lib/seam/devices/use-devices.ts +1 -1
- package/src/lib/seam/devices/use-update-device-name.ts +1 -2
- package/src/lib/seam/events/use-events.ts +1 -1
- package/src/lib/seam/index.ts +0 -6
- package/src/lib/seam/locks/use-lock-door.ts +101 -0
- package/src/lib/seam/locks/use-toggle-lock.ts +1 -2
- package/src/lib/seam/locks/use-unlock-door.ts +104 -0
- package/src/lib/seam/noise-sensors/use-noise-thresholds.ts +1 -1
- package/src/lib/seam/thermostats/use-cool-thermostat.ts +1 -1
- package/src/lib/seam/thermostats/use-create-thermostat-climate-preset.ts +1 -1
- package/src/lib/seam/thermostats/use-delete-thermostat-climate-preset.ts +1 -1
- package/src/lib/seam/thermostats/use-heat-cool-thermostat.ts +1 -1
- package/src/lib/seam/thermostats/use-heat-thermostat.ts +1 -1
- package/src/lib/seam/thermostats/use-set-thermostat-fan-mode.ts +1 -2
- package/src/lib/seam/thermostats/use-set-thermostat-off.ts +1 -2
- package/src/lib/seam/thermostats/use-update-thermostat-climate-preset.ts +1 -1
- package/src/lib/telemetry/hooks.ts +1 -1
- package/src/lib/version.ts +1 -1
- package/src/styles/_device-details.scss +1 -0
- package/lib/seam/SeamQueryProvider.d.ts +0 -40
- package/lib/seam/SeamQueryProvider.js +0 -180
- package/lib/seam/SeamQueryProvider.js.map +0 -1
- package/lib/seam/use-seam-client.d.ts +0 -14
- package/lib/seam/use-seam-client.js +0 -134
- package/lib/seam/use-seam-client.js.map +0 -1
- package/lib/seam/use-seam-infinite-query.d.ts +0 -15
- package/lib/seam/use-seam-infinite-query.js +0 -47
- package/lib/seam/use-seam-infinite-query.js.map +0 -1
- package/lib/seam/use-seam-mutation-without-workspace.d.ts +0 -9
- package/lib/seam/use-seam-mutation-without-workspace.js +0 -17
- package/lib/seam/use-seam-mutation-without-workspace.js.map +0 -1
- package/lib/seam/use-seam-mutation.d.ts +0 -10
- package/lib/seam/use-seam-mutation.js +0 -17
- package/lib/seam/use-seam-mutation.js.map +0 -1
- package/lib/seam/use-seam-query-without-workspace.d.ts +0 -11
- package/lib/seam/use-seam-query-without-workspace.js +0 -25
- package/lib/seam/use-seam-query-without-workspace.js.map +0 -1
- package/lib/seam/use-seam-query.d.ts +0 -12
- package/lib/seam/use-seam-query.js +0 -25
- package/lib/seam/use-seam-query.js.map +0 -1
- package/src/lib/seam/SeamQueryProvider.tsx +0 -356
- package/src/lib/seam/use-seam-client.ts +0 -225
- package/src/lib/seam/use-seam-infinite-query.ts +0 -103
- package/src/lib/seam/use-seam-mutation-without-workspace.ts +0 -56
- package/src/lib/seam/use-seam-mutation.ts +0 -64
- package/src/lib/seam/use-seam-query-without-workspace.ts +0 -59
- package/src/lib/seam/use-seam-query.ts +0 -66
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceQueryPaths, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
|
-
import { type QueryKey, type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
export type UseSeamQueryWithoutWorkspaceParameters<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[0];
|
|
4
|
-
export type UseSeamQueryWithoutWorkspaceResult<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = UseQueryResult<QueryData<T>, QueryError>;
|
|
5
|
-
export declare function useSeamQueryWithoutWorkspace<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths>(endpointPath: T, parameters?: UseSeamQueryWithoutWorkspaceParameters<T>, options?: Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[1] & QueryOptions<QueryData<T>, QueryError>): UseSeamQueryWithoutWorkspaceResult<T> & {
|
|
6
|
-
queryKey: QueryKey;
|
|
7
|
-
};
|
|
8
|
-
type QueryData<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = Awaited<ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>>;
|
|
9
|
-
type QueryError = Error | SeamHttpApiError | SeamHttpInvalidInputError;
|
|
10
|
-
type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>;
|
|
11
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useQuery, } from '@tanstack/react-query';
|
|
2
|
-
import { useSeamClient } from '../../lib/seam/use-seam-client.js';
|
|
3
|
-
export function useSeamQueryWithoutWorkspace(endpointPath, parameters = {}, options = {}) {
|
|
4
|
-
const { endpointClient: client, queryKeyPrefixes } = useSeamClient();
|
|
5
|
-
const queryKey = [
|
|
6
|
-
...queryKeyPrefixes,
|
|
7
|
-
...endpointPath.split('/').filter((v) => v !== ''),
|
|
8
|
-
parameters ?? {},
|
|
9
|
-
];
|
|
10
|
-
const result = useQuery({
|
|
11
|
-
enabled: client != null,
|
|
12
|
-
...options,
|
|
13
|
-
queryKey,
|
|
14
|
-
queryFn: async () => {
|
|
15
|
-
if (client == null)
|
|
16
|
-
return null;
|
|
17
|
-
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
18
|
-
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
19
|
-
const endpoint = client[endpointPath];
|
|
20
|
-
return await endpoint(parameters, options);
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
return { ...result, queryKey };
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=use-seam-query-without-workspace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-query-without-workspace.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-query-without-workspace.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAU3D,MAAM,UAAU,4BAA4B,CAG1C,YAAe,EACf,aAAwD,EAAE,EAC1D,UAC2C,EAAE;IAE7C,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAA;IACpE,MAAM,QAAQ,GAAG;QACf,GAAG,gBAAgB;QACnB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAClD,UAAU,IAAI,EAAE;KACjB,CAAA;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC;QACtB,OAAO,EAAE,MAAM,IAAI,IAAI;QACvB,GAAG,OAAO;QACV,QAAQ;QACR,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,MAAM,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAA;YAC/B,iHAAiH;YACjH,2FAA2F;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAmC,CAAA;YACvE,OAAO,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAC5C,CAAC;KACF,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAA;AAChC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { SeamActionAttemptFailedError, SeamActionAttemptTimeoutError, SeamHttpApiError, SeamHttpEndpointQueryPaths, SeamHttpEndpoints, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
|
-
import type { ActionAttempt } from '@seamapi/types/connect';
|
|
3
|
-
import { type QueryKey, type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
|
|
4
|
-
export type UseSeamQueryParameters<T extends SeamHttpEndpointQueryPaths> = Parameters<SeamHttpEndpoints[T]>[0];
|
|
5
|
-
export type UseSeamQueryResult<T extends SeamHttpEndpointQueryPaths> = UseQueryResult<QueryData<T>, QueryError<T>>;
|
|
6
|
-
export declare function useSeamQuery<T extends SeamHttpEndpointQueryPaths>(endpointPath: T, parameters?: UseSeamQueryParameters<T>, options?: Parameters<SeamHttpEndpoints[T]>[1] & QueryOptions<QueryData<T>, SeamHttpApiError>): UseSeamQueryResult<T> & {
|
|
7
|
-
queryKey: QueryKey;
|
|
8
|
-
};
|
|
9
|
-
type QueryData<T extends SeamHttpEndpointQueryPaths> = Awaited<ReturnType<SeamHttpEndpoints[T]>>;
|
|
10
|
-
type QueryError<T extends SeamHttpEndpointQueryPaths> = Error | SeamHttpApiError | SeamHttpInvalidInputError | (QueryData<T> extends ActionAttempt ? SeamActionAttemptFailedError<QueryData<T>> | SeamActionAttemptTimeoutError<QueryData<T>> : never);
|
|
11
|
-
type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>;
|
|
12
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useQuery, } from '@tanstack/react-query';
|
|
2
|
-
import { useSeamClient } from '../../lib/seam/use-seam-client.js';
|
|
3
|
-
export function useSeamQuery(endpointPath, parameters = {}, options = {}) {
|
|
4
|
-
const { endpointClient: client, queryKeyPrefixes } = useSeamClient();
|
|
5
|
-
const queryKey = [
|
|
6
|
-
...queryKeyPrefixes,
|
|
7
|
-
...endpointPath.split('/').filter((v) => v !== ''),
|
|
8
|
-
parameters ?? {},
|
|
9
|
-
];
|
|
10
|
-
const result = useQuery({
|
|
11
|
-
enabled: client != null,
|
|
12
|
-
...options,
|
|
13
|
-
queryKey,
|
|
14
|
-
queryFn: async () => {
|
|
15
|
-
if (client == null)
|
|
16
|
-
return null;
|
|
17
|
-
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
18
|
-
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
19
|
-
const endpoint = client[endpointPath];
|
|
20
|
-
return await endpoint(parameters, options);
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
return { ...result, queryKey };
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=use-seam-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-query.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-query.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQ3D,MAAM,UAAU,YAAY,CAC1B,YAAe,EACf,aAAwC,EAAE,EAC1C,UACiD,EAAE;IAEnD,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAA;IACpE,MAAM,QAAQ,GAAG;QACf,GAAG,gBAAgB;QACnB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QAClD,UAAU,IAAI,EAAE;KACjB,CAAA;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC;QACtB,OAAO,EAAE,MAAM,IAAI,IAAI;QACvB,GAAG,OAAO;QACV,QAAQ;QACR,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,MAAM,IAAI,IAAI;gBAAE,OAAO,IAAI,CAAA;YAC/B,iHAAiH;YACjH,2FAA2F;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAmC,CAAA;YACvE,OAAO,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAC5C,CAAC;KACF,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAA;AAChC,CAAC"}
|
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SeamHttp,
|
|
3
|
-
SeamHttpEndpoints,
|
|
4
|
-
SeamHttpOptionsWithClientSessionToken,
|
|
5
|
-
} from '@seamapi/http/connect'
|
|
6
|
-
import {
|
|
7
|
-
QueryClient,
|
|
8
|
-
QueryClientContext,
|
|
9
|
-
QueryClientProvider,
|
|
10
|
-
} from '@tanstack/react-query'
|
|
11
|
-
import {
|
|
12
|
-
createContext,
|
|
13
|
-
type PropsWithChildren,
|
|
14
|
-
useContext,
|
|
15
|
-
useEffect,
|
|
16
|
-
useMemo,
|
|
17
|
-
} from 'react'
|
|
18
|
-
|
|
19
|
-
import { useSeamClient } from './use-seam-client.js'
|
|
20
|
-
|
|
21
|
-
export interface SeamQueryContext {
|
|
22
|
-
client: SeamHttp | null
|
|
23
|
-
endpointClient: SeamHttpEndpoints | null
|
|
24
|
-
clientOptions?: SeamQueryProviderClientOptions | undefined
|
|
25
|
-
publishableKey?: string | undefined
|
|
26
|
-
userIdentifierKey?: string | undefined
|
|
27
|
-
clientSessionToken?: string | undefined
|
|
28
|
-
consoleSessionToken?: string | undefined
|
|
29
|
-
workspaceId?: string | undefined
|
|
30
|
-
queryKeyPrefix?: string | undefined
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type SeamQueryProviderProps =
|
|
34
|
-
| SeamQueryProviderPropsWithClient
|
|
35
|
-
| SeamQueryProviderPropsWithPublishableKey
|
|
36
|
-
| SeamQueryProviderPropsWithClientSessionToken
|
|
37
|
-
| SeamQueryProviderPropsWithConsoleSessionToken
|
|
38
|
-
|
|
39
|
-
export interface SeamQueryProviderPropsWithClient
|
|
40
|
-
extends SeamQueryProviderBaseProps {
|
|
41
|
-
client: SeamHttp
|
|
42
|
-
queryKeyPrefix: string
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface SeamQueryProviderPropsWithPublishableKey
|
|
46
|
-
extends SeamQueryProviderBaseProps,
|
|
47
|
-
SeamQueryProviderClientOptions {
|
|
48
|
-
publishableKey: string
|
|
49
|
-
userIdentifierKey?: string
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface SeamQueryProviderPropsWithClientSessionToken
|
|
53
|
-
extends SeamQueryProviderBaseProps,
|
|
54
|
-
SeamQueryProviderClientOptions {
|
|
55
|
-
clientSessionToken: string
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface SeamQueryProviderPropsWithConsoleSessionToken
|
|
59
|
-
extends SeamQueryProviderBaseProps,
|
|
60
|
-
SeamQueryProviderClientOptions {
|
|
61
|
-
consoleSessionToken: string
|
|
62
|
-
workspaceId?: string | undefined
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
interface SeamQueryProviderBaseProps extends PropsWithChildren {
|
|
66
|
-
queryClient?: QueryClient | undefined
|
|
67
|
-
onSessionUpdate?: (client: SeamHttp) => void
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
type SeamClientOptions = SeamHttpOptionsWithClientSessionToken
|
|
71
|
-
|
|
72
|
-
export type SeamQueryProviderClientOptions = Pick<
|
|
73
|
-
SeamClientOptions,
|
|
74
|
-
'endpoint' | 'isUndocumentedApiEnabled'
|
|
75
|
-
>
|
|
76
|
-
|
|
77
|
-
const defaultQueryClient = new QueryClient()
|
|
78
|
-
|
|
79
|
-
export function SeamQueryProvider({
|
|
80
|
-
children,
|
|
81
|
-
onSessionUpdate = () => {},
|
|
82
|
-
queryClient,
|
|
83
|
-
...props
|
|
84
|
-
}: SeamQueryProviderProps): JSX.Element {
|
|
85
|
-
const value = useMemo(() => {
|
|
86
|
-
const context = createSeamQueryContextValue(props)
|
|
87
|
-
if (
|
|
88
|
-
context.client == null &&
|
|
89
|
-
context.publishableKey == null &&
|
|
90
|
-
context.clientSessionToken == null &&
|
|
91
|
-
context.consoleSessionToken == null
|
|
92
|
-
) {
|
|
93
|
-
return defaultSeamQueryContextValue
|
|
94
|
-
}
|
|
95
|
-
return context
|
|
96
|
-
}, [props])
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
value.client == null &&
|
|
100
|
-
value.publishableKey == null &&
|
|
101
|
-
value.clientSessionToken == null &&
|
|
102
|
-
value.consoleSessionToken == null
|
|
103
|
-
) {
|
|
104
|
-
throw new Error(
|
|
105
|
-
`Must provide either a Seam client, clientSessionToken, publishableKey or consoleSessionToken.`
|
|
106
|
-
)
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const { Provider } = seamContext
|
|
110
|
-
const queryClientFromContext = useContext(QueryClientContext)
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
queryClientFromContext != null &&
|
|
114
|
-
queryClient != null &&
|
|
115
|
-
queryClientFromContext !== queryClient
|
|
116
|
-
) {
|
|
117
|
-
throw new Error(
|
|
118
|
-
'The QueryClient passed into SeamQueryProvider is different from the one in the existing QueryClientContext. Omit the queryClient prop from SeamProvider or SeamQueryProvider to use the existing QueryClient provided by the QueryClientProvider.'
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<QueryClientProvider
|
|
124
|
-
client={queryClientFromContext ?? queryClient ?? defaultQueryClient}
|
|
125
|
-
>
|
|
126
|
-
<Provider value={value}>
|
|
127
|
-
<Session onSessionUpdate={onSessionUpdate}>{children}</Session>
|
|
128
|
-
</Provider>
|
|
129
|
-
</QueryClientProvider>
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function Session({
|
|
134
|
-
onSessionUpdate,
|
|
135
|
-
children,
|
|
136
|
-
}: Required<Pick<SeamQueryProviderProps, 'onSessionUpdate'>> &
|
|
137
|
-
PropsWithChildren): JSX.Element | null {
|
|
138
|
-
const { client } = useSeamClient()
|
|
139
|
-
useEffect(() => {
|
|
140
|
-
if (client != null) onSessionUpdate(client)
|
|
141
|
-
}, [onSessionUpdate, client])
|
|
142
|
-
|
|
143
|
-
return <>{children}</>
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const createDefaultSeamQueryContextValue = (): SeamQueryContext => {
|
|
147
|
-
try {
|
|
148
|
-
if (globalThis.seam == null) {
|
|
149
|
-
return { client: null, endpointClient: null }
|
|
150
|
-
}
|
|
151
|
-
return createSeamQueryContextValue(globalThis.seam)
|
|
152
|
-
} catch (err) {
|
|
153
|
-
// eslint-disable-next-line no-console
|
|
154
|
-
console.warn(err)
|
|
155
|
-
return { client: null, endpointClient: null }
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const createSeamQueryContextValue = (
|
|
160
|
-
options: SeamQueryProviderProps
|
|
161
|
-
): SeamQueryContext => {
|
|
162
|
-
if (isSeamQueryProviderPropsWithClient(options)) {
|
|
163
|
-
if (options.queryKeyPrefix == null) {
|
|
164
|
-
throw new InvalidSeamQueryProviderProps(
|
|
165
|
-
'The client prop must be used with a queryKeyPrefix prop.'
|
|
166
|
-
)
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
...options,
|
|
170
|
-
endpointClient: null,
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (isSeamQueryProviderPropsWithClientSessionToken(options)) {
|
|
175
|
-
const { clientSessionToken, ...clientOptions } = options
|
|
176
|
-
return {
|
|
177
|
-
clientSessionToken,
|
|
178
|
-
clientOptions,
|
|
179
|
-
client: null,
|
|
180
|
-
endpointClient: null,
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (isSeamQueryProviderPropsWithPublishableKey(options)) {
|
|
185
|
-
const { publishableKey, userIdentifierKey, ...clientOptions } = options
|
|
186
|
-
return {
|
|
187
|
-
publishableKey,
|
|
188
|
-
userIdentifierKey,
|
|
189
|
-
clientOptions,
|
|
190
|
-
client: null,
|
|
191
|
-
endpointClient: null,
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (isSeamQueryProviderPropsWithConsoleSessionToken(options)) {
|
|
196
|
-
const { consoleSessionToken, workspaceId, ...clientOptions } = options
|
|
197
|
-
return {
|
|
198
|
-
consoleSessionToken,
|
|
199
|
-
workspaceId,
|
|
200
|
-
clientOptions,
|
|
201
|
-
client: null,
|
|
202
|
-
endpointClient: null,
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return { client: null, endpointClient: null }
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const defaultSeamQueryContextValue = createDefaultSeamQueryContextValue()
|
|
210
|
-
|
|
211
|
-
export const seamContext = createContext<SeamQueryContext>(
|
|
212
|
-
defaultSeamQueryContextValue
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
export function useSeamQueryContext(): SeamQueryContext {
|
|
216
|
-
return useContext(seamContext)
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const isSeamQueryProviderPropsWithClient = (
|
|
220
|
-
props: SeamQueryProviderProps
|
|
221
|
-
): props is SeamQueryProviderPropsWithClient => {
|
|
222
|
-
if (!('client' in props)) return false
|
|
223
|
-
|
|
224
|
-
const { client, ...otherProps } = props
|
|
225
|
-
if (client == null) return false
|
|
226
|
-
|
|
227
|
-
const otherNonNullProps = Object.values(otherProps).filter((v) => v != null)
|
|
228
|
-
if (otherNonNullProps.length > 0) {
|
|
229
|
-
throw new InvalidSeamQueryProviderProps(
|
|
230
|
-
`The client prop cannot be used with ${otherNonNullProps.join(' or ')}.`
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
return true
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const isSeamQueryProviderPropsWithPublishableKey = (
|
|
238
|
-
props: SeamQueryProviderProps
|
|
239
|
-
): props is SeamQueryProviderPropsWithPublishableKey &
|
|
240
|
-
SeamQueryProviderClientOptions => {
|
|
241
|
-
if (!('publishableKey' in props)) return false
|
|
242
|
-
|
|
243
|
-
const { publishableKey } = props
|
|
244
|
-
if (publishableKey == null) return false
|
|
245
|
-
|
|
246
|
-
if ('client' in props && props.client != null) {
|
|
247
|
-
throw new InvalidSeamQueryProviderProps(
|
|
248
|
-
'The client prop cannot be used with the publishableKey prop.'
|
|
249
|
-
)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if ('clientSessionToken' in props && props.clientSessionToken != null) {
|
|
253
|
-
throw new InvalidSeamQueryProviderProps(
|
|
254
|
-
'The clientSessionToken prop cannot be used with the publishableKey prop.'
|
|
255
|
-
)
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
if ('consoleSessionToken' in props && props.consoleSessionToken != null) {
|
|
259
|
-
throw new InvalidSeamQueryProviderProps(
|
|
260
|
-
'The consoleSessionToken prop cannot be used with the publishableKey prop.'
|
|
261
|
-
)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if ('workspaceId' in props && props.workspaceId != null) {
|
|
265
|
-
throw new InvalidSeamQueryProviderProps(
|
|
266
|
-
'The workspaceId prop cannot be used with the publishableKey prop.'
|
|
267
|
-
)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
return true
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const isSeamQueryProviderPropsWithClientSessionToken = (
|
|
274
|
-
props: SeamQueryProviderProps
|
|
275
|
-
): props is SeamQueryProviderPropsWithClientSessionToken &
|
|
276
|
-
SeamQueryProviderClientOptions => {
|
|
277
|
-
if (!('clientSessionToken' in props)) return false
|
|
278
|
-
|
|
279
|
-
const { clientSessionToken } = props
|
|
280
|
-
if (clientSessionToken == null) return false
|
|
281
|
-
|
|
282
|
-
if ('client' in props && props.client != null) {
|
|
283
|
-
throw new InvalidSeamQueryProviderProps(
|
|
284
|
-
'The client prop cannot be used with the clientSessionToken prop.'
|
|
285
|
-
)
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if ('publishableKey' in props && props.publishableKey != null) {
|
|
289
|
-
throw new InvalidSeamQueryProviderProps(
|
|
290
|
-
'The publishableKey prop cannot be used with the clientSessionToken prop.'
|
|
291
|
-
)
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
|
|
295
|
-
throw new InvalidSeamQueryProviderProps(
|
|
296
|
-
'The userIdentifierKey prop cannot be used with the clientSessionToken prop.'
|
|
297
|
-
)
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
if ('consoleSessionToken' in props && props.consoleSessionToken != null) {
|
|
301
|
-
throw new InvalidSeamQueryProviderProps(
|
|
302
|
-
'The consoleSessionToken prop cannot be used with the clientSessionToken prop.'
|
|
303
|
-
)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if ('workspaceId' in props && props.workspaceId != null) {
|
|
307
|
-
throw new InvalidSeamQueryProviderProps(
|
|
308
|
-
'The workspaceId prop cannot be used with the clientSessionToken prop.'
|
|
309
|
-
)
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return true
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const isSeamQueryProviderPropsWithConsoleSessionToken = (
|
|
316
|
-
props: SeamQueryProviderProps
|
|
317
|
-
): props is SeamQueryProviderPropsWithConsoleSessionToken &
|
|
318
|
-
SeamQueryProviderClientOptions => {
|
|
319
|
-
if (!('consoleSessionToken' in props)) return false
|
|
320
|
-
|
|
321
|
-
const { consoleSessionToken } = props
|
|
322
|
-
if (consoleSessionToken == null) return false
|
|
323
|
-
|
|
324
|
-
if ('client' in props && props.client != null) {
|
|
325
|
-
throw new InvalidSeamQueryProviderProps(
|
|
326
|
-
'The client prop cannot be used with the publishableKey prop.'
|
|
327
|
-
)
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if ('clientSessionToken' in props && props.clientSessionToken != null) {
|
|
331
|
-
throw new InvalidSeamQueryProviderProps(
|
|
332
|
-
'The clientSessionToken prop cannot be used with the publishableKey prop.'
|
|
333
|
-
)
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
if ('publishableKey' in props && props.publishableKey != null) {
|
|
337
|
-
throw new InvalidSeamQueryProviderProps(
|
|
338
|
-
'The publishableKey prop cannot be used with the consoleSessionToken prop.'
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
|
|
343
|
-
throw new InvalidSeamQueryProviderProps(
|
|
344
|
-
'The userIdentifierKey prop cannot be used with the consoleSessionToken prop.'
|
|
345
|
-
)
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return true
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
class InvalidSeamQueryProviderProps extends Error {
|
|
352
|
-
constructor(message: string) {
|
|
353
|
-
super(`SeamQueryProvider received invalid props: ${message}`)
|
|
354
|
-
this.name = this.constructor.name
|
|
355
|
-
}
|
|
356
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SeamHttp,
|
|
3
|
-
SeamHttpEndpoints,
|
|
4
|
-
SeamHttpEndpointsWithoutWorkspace,
|
|
5
|
-
SeamHttpWithoutWorkspace,
|
|
6
|
-
} from '@seamapi/http/connect'
|
|
7
|
-
import { useQuery } from '@tanstack/react-query'
|
|
8
|
-
import { useEffect } from 'react'
|
|
9
|
-
import { v4 as uuidv4 } from 'uuid'
|
|
10
|
-
|
|
11
|
-
import { useSeamQueryContext } from './SeamQueryProvider.js'
|
|
12
|
-
|
|
13
|
-
export function useSeamClient(): {
|
|
14
|
-
client: SeamHttp | null
|
|
15
|
-
endpointClient: SeamHttpEndpoints | null
|
|
16
|
-
clientWithoutWorkspace: SeamHttpWithoutWorkspace | null
|
|
17
|
-
endpointClientWithoutWorkspace: SeamHttpEndpointsWithoutWorkspace | null
|
|
18
|
-
queryKeyPrefixes: string[]
|
|
19
|
-
isPending: boolean
|
|
20
|
-
isError: boolean
|
|
21
|
-
error: unknown
|
|
22
|
-
} {
|
|
23
|
-
const {
|
|
24
|
-
client,
|
|
25
|
-
clientOptions,
|
|
26
|
-
publishableKey,
|
|
27
|
-
clientSessionToken,
|
|
28
|
-
consoleSessionToken,
|
|
29
|
-
workspaceId,
|
|
30
|
-
queryKeyPrefix,
|
|
31
|
-
...context
|
|
32
|
-
} = useSeamQueryContext()
|
|
33
|
-
const userIdentifierKey = useUserIdentifierKeyOrFingerprint(
|
|
34
|
-
clientSessionToken != null ? '' : context.userIdentifierKey
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
const { isPending, isError, error, data } = useQuery<{
|
|
38
|
-
client: SeamHttp | null
|
|
39
|
-
endpointClient: SeamHttpEndpoints | null
|
|
40
|
-
clientWithoutWorkspace: SeamHttpWithoutWorkspace | null
|
|
41
|
-
endpointClientWithoutWorkspace: SeamHttpEndpointsWithoutWorkspace | null
|
|
42
|
-
}>({
|
|
43
|
-
queryKey: [
|
|
44
|
-
...getQueryKeyPrefixes({ queryKeyPrefix }),
|
|
45
|
-
'client',
|
|
46
|
-
{
|
|
47
|
-
client,
|
|
48
|
-
clientOptions,
|
|
49
|
-
publishableKey,
|
|
50
|
-
userIdentifierKey,
|
|
51
|
-
clientSessionToken,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
queryFn: async () => {
|
|
55
|
-
if (client != null)
|
|
56
|
-
return {
|
|
57
|
-
client,
|
|
58
|
-
endpointClient: SeamHttpEndpoints.fromClient(client.client),
|
|
59
|
-
clientWithoutWorkspace: null,
|
|
60
|
-
endpointClientWithoutWorkspace: null,
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (clientSessionToken != null) {
|
|
64
|
-
const seam = SeamHttp.fromClientSessionToken(
|
|
65
|
-
clientSessionToken,
|
|
66
|
-
clientOptions
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
client: seam,
|
|
71
|
-
endpointClient: SeamHttpEndpoints.fromClient(seam.client),
|
|
72
|
-
clientWithoutWorkspace: null,
|
|
73
|
-
endpointClientWithoutWorkspace: null,
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (publishableKey != null) {
|
|
78
|
-
const seam = await SeamHttp.fromPublishableKey(
|
|
79
|
-
publishableKey,
|
|
80
|
-
userIdentifierKey,
|
|
81
|
-
clientOptions
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
client: seam,
|
|
86
|
-
endpointClient: SeamHttpEndpoints.fromClient(seam.client),
|
|
87
|
-
clientWithoutWorkspace: null,
|
|
88
|
-
endpointClientWithoutWorkspace: null,
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (consoleSessionToken != null) {
|
|
93
|
-
const clientWithoutWorkspace =
|
|
94
|
-
SeamHttpWithoutWorkspace.fromConsoleSessionToken(consoleSessionToken)
|
|
95
|
-
|
|
96
|
-
const endpointClientWithoutWorkspace =
|
|
97
|
-
SeamHttpEndpointsWithoutWorkspace.fromClient(
|
|
98
|
-
clientWithoutWorkspace.client
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
if (workspaceId == null) {
|
|
102
|
-
return {
|
|
103
|
-
client: null,
|
|
104
|
-
endpointClient: null,
|
|
105
|
-
clientWithoutWorkspace,
|
|
106
|
-
endpointClientWithoutWorkspace,
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const seam = SeamHttp.fromConsoleSessionToken(
|
|
111
|
-
consoleSessionToken,
|
|
112
|
-
workspaceId,
|
|
113
|
-
clientOptions
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
client: seam,
|
|
118
|
-
endpointClient: SeamHttpEndpoints.fromClient(seam.client),
|
|
119
|
-
clientWithoutWorkspace,
|
|
120
|
-
endpointClientWithoutWorkspace,
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
throw new Error(
|
|
125
|
-
'Missing either a client, publishableKey, clientSessionToken, or consoleSessionToken.'
|
|
126
|
-
)
|
|
127
|
-
},
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
return {
|
|
131
|
-
client: data?.client ?? null,
|
|
132
|
-
endpointClient: data?.endpointClient ?? null,
|
|
133
|
-
clientWithoutWorkspace: data?.clientWithoutWorkspace ?? null,
|
|
134
|
-
endpointClientWithoutWorkspace:
|
|
135
|
-
data?.endpointClientWithoutWorkspace ?? null,
|
|
136
|
-
queryKeyPrefixes: getQueryKeyPrefixes({
|
|
137
|
-
queryKeyPrefix,
|
|
138
|
-
userIdentifierKey,
|
|
139
|
-
publishableKey,
|
|
140
|
-
clientSessionToken,
|
|
141
|
-
consoleSessionToken,
|
|
142
|
-
workspaceId,
|
|
143
|
-
}),
|
|
144
|
-
isPending,
|
|
145
|
-
isError,
|
|
146
|
-
error,
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export class NullSeamClientError extends Error {
|
|
151
|
-
constructor() {
|
|
152
|
-
super(
|
|
153
|
-
[
|
|
154
|
-
'Attempted to use a null Seam client.',
|
|
155
|
-
'Either a hook using useSeamClient was called outside of a SeamProvider or SeamQueryProvider,',
|
|
156
|
-
'or there was an error when creating the Seam client in useSeamClient,',
|
|
157
|
-
'or useSeamClient is still loading the client.',
|
|
158
|
-
].join(' ')
|
|
159
|
-
)
|
|
160
|
-
this.name = this.constructor.name
|
|
161
|
-
Error.captureStackTrace(this, this.constructor)
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function useUserIdentifierKeyOrFingerprint(
|
|
166
|
-
userIdentifierKey: string | undefined
|
|
167
|
-
): string {
|
|
168
|
-
useEffect(() => {
|
|
169
|
-
if (userIdentifierKey != null) return
|
|
170
|
-
// eslint-disable-next-line no-console
|
|
171
|
-
console.warn(`Using an automatically generated fingerprint for the Seam userIdentifierKey!
|
|
172
|
-
The user interface will show warnings when using a fingerprint.
|
|
173
|
-
This is not recommended because the client session is now bound to this machine and is effectively ephemeral.`)
|
|
174
|
-
}, [userIdentifierKey])
|
|
175
|
-
|
|
176
|
-
if (userIdentifierKey != null) {
|
|
177
|
-
return userIdentifierKey
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
const fingerprint =
|
|
181
|
-
globalThis.localStorage?.getItem('seam_user_fingerprint') ??
|
|
182
|
-
`fingerprint_${uuidv4()}`
|
|
183
|
-
|
|
184
|
-
globalThis.localStorage?.setItem('seam_user_fingerprint', fingerprint)
|
|
185
|
-
|
|
186
|
-
return fingerprint
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const getQueryKeyPrefixes = ({
|
|
190
|
-
queryKeyPrefix,
|
|
191
|
-
userIdentifierKey,
|
|
192
|
-
publishableKey,
|
|
193
|
-
clientSessionToken,
|
|
194
|
-
consoleSessionToken,
|
|
195
|
-
workspaceId,
|
|
196
|
-
}: {
|
|
197
|
-
queryKeyPrefix: string | undefined
|
|
198
|
-
userIdentifierKey?: string
|
|
199
|
-
publishableKey?: string | undefined
|
|
200
|
-
clientSessionToken?: string | undefined
|
|
201
|
-
consoleSessionToken?: string | undefined
|
|
202
|
-
workspaceId?: string | undefined
|
|
203
|
-
}): string[] => {
|
|
204
|
-
const seamPrefix = 'seam'
|
|
205
|
-
|
|
206
|
-
if (queryKeyPrefix != null) return [seamPrefix, queryKeyPrefix]
|
|
207
|
-
|
|
208
|
-
if (clientSessionToken != null) {
|
|
209
|
-
return [seamPrefix, clientSessionToken]
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (publishableKey != null && userIdentifierKey != null) {
|
|
213
|
-
return [seamPrefix, publishableKey, userIdentifierKey]
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (consoleSessionToken != null) {
|
|
217
|
-
if (workspaceId != null) {
|
|
218
|
-
return [seamPrefix, consoleSessionToken, workspaceId]
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return [seamPrefix, consoleSessionToken, 'without_workspace']
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
return [seamPrefix]
|
|
225
|
-
}
|