@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
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
SeamHttpApiError,
|
|
5
5
|
ThermostatsHeatCoolBody,
|
|
6
6
|
} from '@seamapi/http/connect'
|
|
7
|
+
import { NullSeamClientError, useSeamClient } from '@seamapi/react-query'
|
|
7
8
|
import type { ActionAttempt, Device } from '@seamapi/types/connect'
|
|
8
9
|
import {
|
|
9
10
|
useMutation,
|
|
@@ -17,7 +18,6 @@ import {
|
|
|
17
18
|
getHeatingSetPointCelsius,
|
|
18
19
|
getHeatingSetPointFahrenheit,
|
|
19
20
|
} from 'lib/seam/thermostats/unit-conversion.js'
|
|
20
|
-
import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
|
|
21
21
|
|
|
22
22
|
export type UseHeatCoolThermostatParams = never
|
|
23
23
|
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
SeamHttpApiError,
|
|
5
5
|
ThermostatsHeatBody,
|
|
6
6
|
} from '@seamapi/http/connect'
|
|
7
|
+
import { NullSeamClientError, useSeamClient } from '@seamapi/react-query'
|
|
7
8
|
import type { ActionAttempt, Device } from '@seamapi/types/connect'
|
|
8
9
|
import {
|
|
9
10
|
useMutation,
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
getHeatingSetPointCelsius,
|
|
16
17
|
getHeatingSetPointFahrenheit,
|
|
17
18
|
} from 'lib/seam/thermostats/unit-conversion.js'
|
|
18
|
-
import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
|
|
19
19
|
|
|
20
20
|
export type UseHeatThermostatParams = never
|
|
21
21
|
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
SeamHttpApiError,
|
|
5
5
|
ThermostatsSetFanModeBody,
|
|
6
6
|
} from '@seamapi/http/connect'
|
|
7
|
+
import { NullSeamClientError, useSeamClient } from '@seamapi/react-query'
|
|
7
8
|
import type { ActionAttempt, Device } from '@seamapi/types/connect'
|
|
8
9
|
import {
|
|
9
10
|
useMutation,
|
|
@@ -11,8 +12,6 @@ import {
|
|
|
11
12
|
useQueryClient,
|
|
12
13
|
} from '@tanstack/react-query'
|
|
13
14
|
|
|
14
|
-
import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
|
|
15
|
-
|
|
16
15
|
export type UseSetThermostatFanModeParams = never
|
|
17
16
|
|
|
18
17
|
export type UseSetThermostatFanModeData = undefined
|
|
@@ -4,6 +4,7 @@ import type {
|
|
|
4
4
|
SeamHttpApiError,
|
|
5
5
|
ThermostatsOffBody,
|
|
6
6
|
} from '@seamapi/http/connect'
|
|
7
|
+
import { NullSeamClientError, useSeamClient } from '@seamapi/react-query'
|
|
7
8
|
import type { ActionAttempt, Device } from '@seamapi/types/connect'
|
|
8
9
|
import {
|
|
9
10
|
useMutation,
|
|
@@ -11,8 +12,6 @@ import {
|
|
|
11
12
|
useQueryClient,
|
|
12
13
|
} from '@tanstack/react-query'
|
|
13
14
|
|
|
14
|
-
import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
|
|
15
|
-
|
|
16
15
|
export type UseSetThermostatOffParams = never
|
|
17
16
|
|
|
18
17
|
export type UseSetThermostatOffData = undefined
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
SeamHttpApiError,
|
|
3
3
|
ThermostatsUpdateClimatePresetBody,
|
|
4
4
|
} from '@seamapi/http/connect'
|
|
5
|
+
import { NullSeamClientError, useSeamClient } from '@seamapi/react-query'
|
|
5
6
|
import {
|
|
6
7
|
useMutation,
|
|
7
8
|
type UseMutationResult,
|
|
@@ -13,7 +14,6 @@ import type {
|
|
|
13
14
|
ThermostatDevice,
|
|
14
15
|
} from 'lib/seam/thermostats/thermostat-device.js'
|
|
15
16
|
import { fahrenheitToCelsius } from 'lib/seam/thermostats/unit-conversion.js'
|
|
16
|
-
import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
|
|
17
17
|
|
|
18
18
|
export type UseUpdateThermostatClimatePresetParams = never
|
|
19
19
|
export type UseUpdateThermostatClimatePresetData = undefined
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { useSeamQueryContext } from '@seamapi/react-query'
|
|
1
2
|
import { useEffect, useLayoutEffect } from 'react'
|
|
2
3
|
|
|
3
4
|
import { useClientSession } from 'lib/seam/client-sessions/use-client-session.js'
|
|
4
|
-
import { useSeamQueryContext } from 'lib/seam/SeamQueryProvider.js'
|
|
5
5
|
|
|
6
6
|
import type { TelemetryClient } from './client.js'
|
|
7
7
|
import { useTelemetryContext } from './TelemetryProvider.js'
|
package/src/lib/version.ts
CHANGED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { SeamHttp, SeamHttpEndpoints, SeamHttpOptionsWithClientSessionToken } from '@seamapi/http/connect';
|
|
2
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
-
import { type PropsWithChildren } from 'react';
|
|
4
|
-
export interface SeamQueryContext {
|
|
5
|
-
client: SeamHttp | null;
|
|
6
|
-
endpointClient: SeamHttpEndpoints | null;
|
|
7
|
-
clientOptions?: SeamQueryProviderClientOptions | undefined;
|
|
8
|
-
publishableKey?: string | undefined;
|
|
9
|
-
userIdentifierKey?: string | undefined;
|
|
10
|
-
clientSessionToken?: string | undefined;
|
|
11
|
-
consoleSessionToken?: string | undefined;
|
|
12
|
-
workspaceId?: string | undefined;
|
|
13
|
-
queryKeyPrefix?: string | undefined;
|
|
14
|
-
}
|
|
15
|
-
export type SeamQueryProviderProps = SeamQueryProviderPropsWithClient | SeamQueryProviderPropsWithPublishableKey | SeamQueryProviderPropsWithClientSessionToken | SeamQueryProviderPropsWithConsoleSessionToken;
|
|
16
|
-
export interface SeamQueryProviderPropsWithClient extends SeamQueryProviderBaseProps {
|
|
17
|
-
client: SeamHttp;
|
|
18
|
-
queryKeyPrefix: string;
|
|
19
|
-
}
|
|
20
|
-
export interface SeamQueryProviderPropsWithPublishableKey extends SeamQueryProviderBaseProps, SeamQueryProviderClientOptions {
|
|
21
|
-
publishableKey: string;
|
|
22
|
-
userIdentifierKey?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface SeamQueryProviderPropsWithClientSessionToken extends SeamQueryProviderBaseProps, SeamQueryProviderClientOptions {
|
|
25
|
-
clientSessionToken: string;
|
|
26
|
-
}
|
|
27
|
-
export interface SeamQueryProviderPropsWithConsoleSessionToken extends SeamQueryProviderBaseProps, SeamQueryProviderClientOptions {
|
|
28
|
-
consoleSessionToken: string;
|
|
29
|
-
workspaceId?: string | undefined;
|
|
30
|
-
}
|
|
31
|
-
interface SeamQueryProviderBaseProps extends PropsWithChildren {
|
|
32
|
-
queryClient?: QueryClient | undefined;
|
|
33
|
-
onSessionUpdate?: (client: SeamHttp) => void;
|
|
34
|
-
}
|
|
35
|
-
type SeamClientOptions = SeamHttpOptionsWithClientSessionToken;
|
|
36
|
-
export type SeamQueryProviderClientOptions = Pick<SeamClientOptions, 'endpoint' | 'isUndocumentedApiEnabled'>;
|
|
37
|
-
export declare function SeamQueryProvider({ children, onSessionUpdate, queryClient, ...props }: SeamQueryProviderProps): JSX.Element;
|
|
38
|
-
export declare const seamContext: import("react").Context<SeamQueryContext>;
|
|
39
|
-
export declare function useSeamQueryContext(): SeamQueryContext;
|
|
40
|
-
export {};
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { QueryClient, QueryClientContext, QueryClientProvider, } from '@tanstack/react-query';
|
|
3
|
-
import { createContext, useContext, useEffect, useMemo, } from 'react';
|
|
4
|
-
import { useSeamClient } from './use-seam-client.js';
|
|
5
|
-
const defaultQueryClient = new QueryClient();
|
|
6
|
-
export function SeamQueryProvider({ children, onSessionUpdate = () => { }, queryClient, ...props }) {
|
|
7
|
-
const value = useMemo(() => {
|
|
8
|
-
const context = createSeamQueryContextValue(props);
|
|
9
|
-
if (context.client == null &&
|
|
10
|
-
context.publishableKey == null &&
|
|
11
|
-
context.clientSessionToken == null &&
|
|
12
|
-
context.consoleSessionToken == null) {
|
|
13
|
-
return defaultSeamQueryContextValue;
|
|
14
|
-
}
|
|
15
|
-
return context;
|
|
16
|
-
}, [props]);
|
|
17
|
-
if (value.client == null &&
|
|
18
|
-
value.publishableKey == null &&
|
|
19
|
-
value.clientSessionToken == null &&
|
|
20
|
-
value.consoleSessionToken == null) {
|
|
21
|
-
throw new Error(`Must provide either a Seam client, clientSessionToken, publishableKey or consoleSessionToken.`);
|
|
22
|
-
}
|
|
23
|
-
const { Provider } = seamContext;
|
|
24
|
-
const queryClientFromContext = useContext(QueryClientContext);
|
|
25
|
-
if (queryClientFromContext != null &&
|
|
26
|
-
queryClient != null &&
|
|
27
|
-
queryClientFromContext !== queryClient) {
|
|
28
|
-
throw new Error('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.');
|
|
29
|
-
}
|
|
30
|
-
return (_jsx(QueryClientProvider, { client: queryClientFromContext ?? queryClient ?? defaultQueryClient, children: _jsx(Provider, { value: value, children: _jsx(Session, { onSessionUpdate: onSessionUpdate, children: children }) }) }));
|
|
31
|
-
}
|
|
32
|
-
function Session({ onSessionUpdate, children, }) {
|
|
33
|
-
const { client } = useSeamClient();
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (client != null)
|
|
36
|
-
onSessionUpdate(client);
|
|
37
|
-
}, [onSessionUpdate, client]);
|
|
38
|
-
return _jsx(_Fragment, { children: children });
|
|
39
|
-
}
|
|
40
|
-
const createDefaultSeamQueryContextValue = () => {
|
|
41
|
-
try {
|
|
42
|
-
if (globalThis.seam == null) {
|
|
43
|
-
return { client: null, endpointClient: null };
|
|
44
|
-
}
|
|
45
|
-
return createSeamQueryContextValue(globalThis.seam);
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
// eslint-disable-next-line no-console
|
|
49
|
-
console.warn(err);
|
|
50
|
-
return { client: null, endpointClient: null };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const createSeamQueryContextValue = (options) => {
|
|
54
|
-
if (isSeamQueryProviderPropsWithClient(options)) {
|
|
55
|
-
if (options.queryKeyPrefix == null) {
|
|
56
|
-
throw new InvalidSeamQueryProviderProps('The client prop must be used with a queryKeyPrefix prop.');
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
...options,
|
|
60
|
-
endpointClient: null,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (isSeamQueryProviderPropsWithClientSessionToken(options)) {
|
|
64
|
-
const { clientSessionToken, ...clientOptions } = options;
|
|
65
|
-
return {
|
|
66
|
-
clientSessionToken,
|
|
67
|
-
clientOptions,
|
|
68
|
-
client: null,
|
|
69
|
-
endpointClient: null,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (isSeamQueryProviderPropsWithPublishableKey(options)) {
|
|
73
|
-
const { publishableKey, userIdentifierKey, ...clientOptions } = options;
|
|
74
|
-
return {
|
|
75
|
-
publishableKey,
|
|
76
|
-
userIdentifierKey,
|
|
77
|
-
clientOptions,
|
|
78
|
-
client: null,
|
|
79
|
-
endpointClient: null,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
if (isSeamQueryProviderPropsWithConsoleSessionToken(options)) {
|
|
83
|
-
const { consoleSessionToken, workspaceId, ...clientOptions } = options;
|
|
84
|
-
return {
|
|
85
|
-
consoleSessionToken,
|
|
86
|
-
workspaceId,
|
|
87
|
-
clientOptions,
|
|
88
|
-
client: null,
|
|
89
|
-
endpointClient: null,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
return { client: null, endpointClient: null };
|
|
93
|
-
};
|
|
94
|
-
const defaultSeamQueryContextValue = createDefaultSeamQueryContextValue();
|
|
95
|
-
export const seamContext = createContext(defaultSeamQueryContextValue);
|
|
96
|
-
export function useSeamQueryContext() {
|
|
97
|
-
return useContext(seamContext);
|
|
98
|
-
}
|
|
99
|
-
const isSeamQueryProviderPropsWithClient = (props) => {
|
|
100
|
-
if (!('client' in props))
|
|
101
|
-
return false;
|
|
102
|
-
const { client, ...otherProps } = props;
|
|
103
|
-
if (client == null)
|
|
104
|
-
return false;
|
|
105
|
-
const otherNonNullProps = Object.values(otherProps).filter((v) => v != null);
|
|
106
|
-
if (otherNonNullProps.length > 0) {
|
|
107
|
-
throw new InvalidSeamQueryProviderProps(`The client prop cannot be used with ${otherNonNullProps.join(' or ')}.`);
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
};
|
|
111
|
-
const isSeamQueryProviderPropsWithPublishableKey = (props) => {
|
|
112
|
-
if (!('publishableKey' in props))
|
|
113
|
-
return false;
|
|
114
|
-
const { publishableKey } = props;
|
|
115
|
-
if (publishableKey == null)
|
|
116
|
-
return false;
|
|
117
|
-
if ('client' in props && props.client != null) {
|
|
118
|
-
throw new InvalidSeamQueryProviderProps('The client prop cannot be used with the publishableKey prop.');
|
|
119
|
-
}
|
|
120
|
-
if ('clientSessionToken' in props && props.clientSessionToken != null) {
|
|
121
|
-
throw new InvalidSeamQueryProviderProps('The clientSessionToken prop cannot be used with the publishableKey prop.');
|
|
122
|
-
}
|
|
123
|
-
if ('consoleSessionToken' in props && props.consoleSessionToken != null) {
|
|
124
|
-
throw new InvalidSeamQueryProviderProps('The consoleSessionToken prop cannot be used with the publishableKey prop.');
|
|
125
|
-
}
|
|
126
|
-
if ('workspaceId' in props && props.workspaceId != null) {
|
|
127
|
-
throw new InvalidSeamQueryProviderProps('The workspaceId prop cannot be used with the publishableKey prop.');
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
130
|
-
};
|
|
131
|
-
const isSeamQueryProviderPropsWithClientSessionToken = (props) => {
|
|
132
|
-
if (!('clientSessionToken' in props))
|
|
133
|
-
return false;
|
|
134
|
-
const { clientSessionToken } = props;
|
|
135
|
-
if (clientSessionToken == null)
|
|
136
|
-
return false;
|
|
137
|
-
if ('client' in props && props.client != null) {
|
|
138
|
-
throw new InvalidSeamQueryProviderProps('The client prop cannot be used with the clientSessionToken prop.');
|
|
139
|
-
}
|
|
140
|
-
if ('publishableKey' in props && props.publishableKey != null) {
|
|
141
|
-
throw new InvalidSeamQueryProviderProps('The publishableKey prop cannot be used with the clientSessionToken prop.');
|
|
142
|
-
}
|
|
143
|
-
if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
|
|
144
|
-
throw new InvalidSeamQueryProviderProps('The userIdentifierKey prop cannot be used with the clientSessionToken prop.');
|
|
145
|
-
}
|
|
146
|
-
if ('consoleSessionToken' in props && props.consoleSessionToken != null) {
|
|
147
|
-
throw new InvalidSeamQueryProviderProps('The consoleSessionToken prop cannot be used with the clientSessionToken prop.');
|
|
148
|
-
}
|
|
149
|
-
if ('workspaceId' in props && props.workspaceId != null) {
|
|
150
|
-
throw new InvalidSeamQueryProviderProps('The workspaceId prop cannot be used with the clientSessionToken prop.');
|
|
151
|
-
}
|
|
152
|
-
return true;
|
|
153
|
-
};
|
|
154
|
-
const isSeamQueryProviderPropsWithConsoleSessionToken = (props) => {
|
|
155
|
-
if (!('consoleSessionToken' in props))
|
|
156
|
-
return false;
|
|
157
|
-
const { consoleSessionToken } = props;
|
|
158
|
-
if (consoleSessionToken == null)
|
|
159
|
-
return false;
|
|
160
|
-
if ('client' in props && props.client != null) {
|
|
161
|
-
throw new InvalidSeamQueryProviderProps('The client prop cannot be used with the publishableKey prop.');
|
|
162
|
-
}
|
|
163
|
-
if ('clientSessionToken' in props && props.clientSessionToken != null) {
|
|
164
|
-
throw new InvalidSeamQueryProviderProps('The clientSessionToken prop cannot be used with the publishableKey prop.');
|
|
165
|
-
}
|
|
166
|
-
if ('publishableKey' in props && props.publishableKey != null) {
|
|
167
|
-
throw new InvalidSeamQueryProviderProps('The publishableKey prop cannot be used with the consoleSessionToken prop.');
|
|
168
|
-
}
|
|
169
|
-
if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
|
|
170
|
-
throw new InvalidSeamQueryProviderProps('The userIdentifierKey prop cannot be used with the consoleSessionToken prop.');
|
|
171
|
-
}
|
|
172
|
-
return true;
|
|
173
|
-
};
|
|
174
|
-
class InvalidSeamQueryProviderProps extends Error {
|
|
175
|
-
constructor(message) {
|
|
176
|
-
super(`SeamQueryProvider received invalid props: ${message}`);
|
|
177
|
-
this.name = this.constructor.name;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
//# sourceMappingURL=SeamQueryProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SeamQueryProvider.js","sourceRoot":"","sources":["../../src/lib/seam/SeamQueryProvider.tsx"],"names":[],"mappings":";AAKA,OAAO,EACL,WAAW,EACX,kBAAkB,E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E,OAAO,KAAK,CAAA;IAE7C,IAAI,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAC9C,MAAM,IAAI,6BAA6B,CACrC,8DAA8D,CAC/D,CAAA;IACH,CAAC;IAED,IAAI,oBAAoB,IAAI,KAAK,IAAI,KAAK,CAAC,kBAAkB,IAAI,IAAI,EAAE,CAAC;QACtE,MAAM,IAAI,6BAA6B,CACrC,0EAA0E,CAC3E,CAAA;IACH,CAAC;IAED,IAAI,gBAAgB,IAAI,KAAK,IAAI,KAAK,CAAC,cAAc,IAAI,IAAI,EAAE,CAAC;QAC9D,MAAM,IAAI,6BAA6B,CACrC,2EAA2E,CAC5E,CAAA;IACH,CAAC;IAED,IAAI,mBAAmB,IAAI,KAAK,IAAI,KAAK,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;QACpE,MAAM,IAAI,6BAA6B,CACrC,8EAA8E,CAC/E,CAAA;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,6BAA8B,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,6CAA6C,OAAO,EAAE,CAAC,CAAA;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;IACnC,CAAC;CACF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SeamHttp, SeamHttpEndpoints, SeamHttpEndpointsWithoutWorkspace, SeamHttpWithoutWorkspace } from '@seamapi/http/connect';
|
|
2
|
-
export declare function useSeamClient(): {
|
|
3
|
-
client: SeamHttp | null;
|
|
4
|
-
endpointClient: SeamHttpEndpoints | null;
|
|
5
|
-
clientWithoutWorkspace: SeamHttpWithoutWorkspace | null;
|
|
6
|
-
endpointClientWithoutWorkspace: SeamHttpEndpointsWithoutWorkspace | null;
|
|
7
|
-
queryKeyPrefixes: string[];
|
|
8
|
-
isPending: boolean;
|
|
9
|
-
isError: boolean;
|
|
10
|
-
error: unknown;
|
|
11
|
-
};
|
|
12
|
-
export declare class NullSeamClientError extends Error {
|
|
13
|
-
constructor();
|
|
14
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { SeamHttp, SeamHttpEndpoints, SeamHttpEndpointsWithoutWorkspace, SeamHttpWithoutWorkspace, } from '@seamapi/http/connect';
|
|
2
|
-
import { useQuery } from '@tanstack/react-query';
|
|
3
|
-
import { useEffect } from 'react';
|
|
4
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
5
|
-
import { useSeamQueryContext } from './SeamQueryProvider.js';
|
|
6
|
-
export function useSeamClient() {
|
|
7
|
-
const { client, clientOptions, publishableKey, clientSessionToken, consoleSessionToken, workspaceId, queryKeyPrefix, ...context } = useSeamQueryContext();
|
|
8
|
-
const userIdentifierKey = useUserIdentifierKeyOrFingerprint(clientSessionToken != null ? '' : context.userIdentifierKey);
|
|
9
|
-
const { isPending, isError, error, data } = useQuery({
|
|
10
|
-
queryKey: [
|
|
11
|
-
...getQueryKeyPrefixes({ queryKeyPrefix }),
|
|
12
|
-
'client',
|
|
13
|
-
{
|
|
14
|
-
client,
|
|
15
|
-
clientOptions,
|
|
16
|
-
publishableKey,
|
|
17
|
-
userIdentifierKey,
|
|
18
|
-
clientSessionToken,
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
queryFn: async () => {
|
|
22
|
-
if (client != null)
|
|
23
|
-
return {
|
|
24
|
-
client,
|
|
25
|
-
endpointClient: SeamHttpEndpoints.fromClient(client.client),
|
|
26
|
-
clientWithoutWorkspace: null,
|
|
27
|
-
endpointClientWithoutWorkspace: null,
|
|
28
|
-
};
|
|
29
|
-
if (clientSessionToken != null) {
|
|
30
|
-
const seam = SeamHttp.fromClientSessionToken(clientSessionToken, clientOptions);
|
|
31
|
-
return {
|
|
32
|
-
client: seam,
|
|
33
|
-
endpointClient: SeamHttpEndpoints.fromClient(seam.client),
|
|
34
|
-
clientWithoutWorkspace: null,
|
|
35
|
-
endpointClientWithoutWorkspace: null,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
if (publishableKey != null) {
|
|
39
|
-
const seam = await SeamHttp.fromPublishableKey(publishableKey, userIdentifierKey, clientOptions);
|
|
40
|
-
return {
|
|
41
|
-
client: seam,
|
|
42
|
-
endpointClient: SeamHttpEndpoints.fromClient(seam.client),
|
|
43
|
-
clientWithoutWorkspace: null,
|
|
44
|
-
endpointClientWithoutWorkspace: null,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
if (consoleSessionToken != null) {
|
|
48
|
-
const clientWithoutWorkspace = SeamHttpWithoutWorkspace.fromConsoleSessionToken(consoleSessionToken);
|
|
49
|
-
const endpointClientWithoutWorkspace = SeamHttpEndpointsWithoutWorkspace.fromClient(clientWithoutWorkspace.client);
|
|
50
|
-
if (workspaceId == null) {
|
|
51
|
-
return {
|
|
52
|
-
client: null,
|
|
53
|
-
endpointClient: null,
|
|
54
|
-
clientWithoutWorkspace,
|
|
55
|
-
endpointClientWithoutWorkspace,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const seam = SeamHttp.fromConsoleSessionToken(consoleSessionToken, workspaceId, clientOptions);
|
|
59
|
-
return {
|
|
60
|
-
client: seam,
|
|
61
|
-
endpointClient: SeamHttpEndpoints.fromClient(seam.client),
|
|
62
|
-
clientWithoutWorkspace,
|
|
63
|
-
endpointClientWithoutWorkspace,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
throw new Error('Missing either a client, publishableKey, clientSessionToken, or consoleSessionToken.');
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
return {
|
|
70
|
-
client: data?.client ?? null,
|
|
71
|
-
endpointClient: data?.endpointClient ?? null,
|
|
72
|
-
clientWithoutWorkspace: data?.clientWithoutWorkspace ?? null,
|
|
73
|
-
endpointClientWithoutWorkspace: data?.endpointClientWithoutWorkspace ?? null,
|
|
74
|
-
queryKeyPrefixes: getQueryKeyPrefixes({
|
|
75
|
-
queryKeyPrefix,
|
|
76
|
-
userIdentifierKey,
|
|
77
|
-
publishableKey,
|
|
78
|
-
clientSessionToken,
|
|
79
|
-
consoleSessionToken,
|
|
80
|
-
workspaceId,
|
|
81
|
-
}),
|
|
82
|
-
isPending,
|
|
83
|
-
isError,
|
|
84
|
-
error,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
export class NullSeamClientError extends Error {
|
|
88
|
-
constructor() {
|
|
89
|
-
super([
|
|
90
|
-
'Attempted to use a null Seam client.',
|
|
91
|
-
'Either a hook using useSeamClient was called outside of a SeamProvider or SeamQueryProvider,',
|
|
92
|
-
'or there was an error when creating the Seam client in useSeamClient,',
|
|
93
|
-
'or useSeamClient is still loading the client.',
|
|
94
|
-
].join(' '));
|
|
95
|
-
this.name = this.constructor.name;
|
|
96
|
-
Error.captureStackTrace(this, this.constructor);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
function useUserIdentifierKeyOrFingerprint(userIdentifierKey) {
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (userIdentifierKey != null)
|
|
102
|
-
return;
|
|
103
|
-
// eslint-disable-next-line no-console
|
|
104
|
-
console.warn(`Using an automatically generated fingerprint for the Seam userIdentifierKey!
|
|
105
|
-
The user interface will show warnings when using a fingerprint.
|
|
106
|
-
This is not recommended because the client session is now bound to this machine and is effectively ephemeral.`);
|
|
107
|
-
}, [userIdentifierKey]);
|
|
108
|
-
if (userIdentifierKey != null) {
|
|
109
|
-
return userIdentifierKey;
|
|
110
|
-
}
|
|
111
|
-
const fingerprint = globalThis.localStorage?.getItem('seam_user_fingerprint') ??
|
|
112
|
-
`fingerprint_${uuidv4()}`;
|
|
113
|
-
globalThis.localStorage?.setItem('seam_user_fingerprint', fingerprint);
|
|
114
|
-
return fingerprint;
|
|
115
|
-
}
|
|
116
|
-
const getQueryKeyPrefixes = ({ queryKeyPrefix, userIdentifierKey, publishableKey, clientSessionToken, consoleSessionToken, workspaceId, }) => {
|
|
117
|
-
const seamPrefix = 'seam';
|
|
118
|
-
if (queryKeyPrefix != null)
|
|
119
|
-
return [seamPrefix, queryKeyPrefix];
|
|
120
|
-
if (clientSessionToken != null) {
|
|
121
|
-
return [seamPrefix, clientSessionToken];
|
|
122
|
-
}
|
|
123
|
-
if (publishableKey != null && userIdentifierKey != null) {
|
|
124
|
-
return [seamPrefix, publishableKey, userIdentifierKey];
|
|
125
|
-
}
|
|
126
|
-
if (consoleSessionToken != null) {
|
|
127
|
-
if (workspaceId != null) {
|
|
128
|
-
return [seamPrefix, consoleSessionToken, workspaceId];
|
|
129
|
-
}
|
|
130
|
-
return [seamPrefix, consoleSessionToken, 'without_workspace'];
|
|
131
|
-
}
|
|
132
|
-
return [seamPrefix];
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=use-seam-client.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-client.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,iCAAiC,EACjC,wBAAwB,GACzB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAA;AAEnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAE5D,MAAM,UAAU,aAAa;IAU3B,MAAM,EACJ,MAAM,EACN,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,GAAG,OAAO,EACX,GAAG,mBAAmB,EAAE,CAAA;IACzB,MAAM,iBAAiB,GAAG,iCAAiC,CACzD,kBAAkB,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAi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,CAAC,UAAU,EAAE,mBAAmB,EAAE,WAAW,CAAC,CAAA;QACvD,CAAC;QAED,OAAO,CAAC,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,CAAC,CAAA;IAC/D,CAAC;IAED,OAAO,CAAC,UAAU,CAAC,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { SeamActionAttemptFailedError, SeamActionAttemptTimeoutError, SeamHttpApiError, SeamHttpEndpointPaginatedQueryPaths, SeamHttpEndpoints, SeamHttpInvalidInputError, SeamPageCursor } from '@seamapi/http/connect';
|
|
2
|
-
import type { ActionAttempt } from '@seamapi/types/connect';
|
|
3
|
-
import { type QueryKey, type UseInfiniteQueryOptions, type UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
4
|
-
export type UseSeamInfiniteQueryParameters<T extends SeamHttpEndpointPaginatedQueryPaths> = Parameters<SeamHttpEndpoints[T]>[0];
|
|
5
|
-
export type UseSeamInfiniteQueryResult<T extends SeamHttpEndpointPaginatedQueryPaths> = UseInfiniteQueryResult<QueryData<T>, QueryError<T>>;
|
|
6
|
-
export declare function useSeamInfiniteQuery<T extends SeamHttpEndpointPaginatedQueryPaths>(endpointPath: T, parameters?: UseSeamInfiniteQueryParameters<T>, options?: Parameters<SeamHttpEndpoints[T]>[1] & QueryOptions<QueryData<T>, QueryError<T>>): UseSeamInfiniteQueryResult<T> & {
|
|
7
|
-
queryKey: QueryKey;
|
|
8
|
-
};
|
|
9
|
-
interface QueryData<T extends SeamHttpEndpointPaginatedQueryPaths> {
|
|
10
|
-
data: Awaited<ReturnType<SeamHttpEndpoints[T]>>;
|
|
11
|
-
nextPageCursor: SeamPageCursor | null;
|
|
12
|
-
}
|
|
13
|
-
type QueryError<T extends SeamHttpEndpointPaginatedQueryPaths> = Error | SeamHttpApiError | SeamHttpInvalidInputError | (QueryData<T>['data'] extends ActionAttempt ? SeamActionAttemptFailedError<QueryData<T>['data']> | SeamActionAttemptTimeoutError<QueryData<T>['data']> : never);
|
|
14
|
-
type QueryOptions<X, Y> = Omit<UseInfiniteQueryOptions<X, Y>, 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'>;
|
|
15
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { useInfiniteQuery, } from '@tanstack/react-query';
|
|
2
|
-
import { useSeamClient } from '../../lib/seam/use-seam-client.js';
|
|
3
|
-
export function useSeamInfiniteQuery(endpointPath, parameters = {}, options = {}) {
|
|
4
|
-
const { endpointClient: client, queryKeyPrefixes } = useSeamClient();
|
|
5
|
-
if ('page_cursor' in (parameters ?? {})) {
|
|
6
|
-
throw new Error('Cannot use page_cursor with useSeamInfiniteQuery');
|
|
7
|
-
}
|
|
8
|
-
const queryKey = [
|
|
9
|
-
...queryKeyPrefixes,
|
|
10
|
-
...endpointPath.split('/').filter((v) => v !== ''),
|
|
11
|
-
parameters ?? {},
|
|
12
|
-
];
|
|
13
|
-
const result = useInfiniteQuery({
|
|
14
|
-
enabled: client != null,
|
|
15
|
-
...options,
|
|
16
|
-
queryKey,
|
|
17
|
-
initialPageParam: null,
|
|
18
|
-
getNextPageParam: (lastPage) => lastPage.nextPageCursor,
|
|
19
|
-
queryFn: async ({ pageParam }) => {
|
|
20
|
-
if (client == null)
|
|
21
|
-
return {
|
|
22
|
-
data: [],
|
|
23
|
-
nextPageCursor: null,
|
|
24
|
-
};
|
|
25
|
-
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
26
|
-
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
27
|
-
const endpoint = client[endpointPath];
|
|
28
|
-
const request = endpoint(parameters, options);
|
|
29
|
-
const pages = client.createPaginator(request);
|
|
30
|
-
if (pageParam == null) {
|
|
31
|
-
const [data, { nextPageCursor }] = await pages.firstPage();
|
|
32
|
-
return {
|
|
33
|
-
data: data,
|
|
34
|
-
nextPageCursor,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
// Type assertion is needed for pageParam since the Seam API expects a branded PageCursor type.
|
|
38
|
-
const [data, { nextPageCursor }] = await pages.nextPage(pageParam);
|
|
39
|
-
return {
|
|
40
|
-
data: data,
|
|
41
|
-
nextPageCursor,
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
return { ...result, queryKey };
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=use-seam-infinite-query.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-infinite-query.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-infinite-query.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,gBAAgB,GAGjB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAU3D,MAAM,UAAU,oBAAoB,CAGlC,YAAe,EACf,aAAgD,EAAE,EAClD,UAC8C,EAAE;IAEhD,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAA;IAEpE,IAAI,aAAa,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAA;IACrE,CAAC;IAED,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,gBAAgB,CAAC;QAC9B,OAAO,EAAE,MAAM,IAAI,IAAI;QACvB,GAAG,OAAO;QACV,QAAQ;QACR,gBAAgB,EAAE,IAAI;QACtB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,cAAc;QACvD,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YAC/B,IAAI,MAAM,IAAI,IAAI;gBAChB,OAAO;oBACL,IAAI,EAAE,EAA+C;oBACrD,cAAc,EAAE,IAAI;iBACrB,CAAA;YACH,iHAAiH;YACjH,2FAA2F;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAA0B,CAAA;YAC9D,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;YAC7C,MAAM,KAAK,GAAG,MAAM,CAAC,eAAe,CAAC,OAAoC,CAAC,CAAA;YAC1E,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,CAAC,GAAG,MAAM,KAAK,CAAC,SAAS,EAAE,CAAA;gBAC1D,OAAO;oBACL,IAAI,EAAE,IAAiD;oBACvD,cAAc;iBACf,CAAA;YACH,CAAC;YACD,+FAA+F;YAC/F,MAAM,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,CAAC,GAAG,MAAM,KAAK,CAAC,QAAQ,CACrD,SAA2B,CAC5B,CAAA;YACD,OAAO;gBACL,IAAI,EAAE,IAAiD;gBACvD,cAAc;aACf,CAAA;QACH,CAAC;KACF,CAAC,CAAA;IACF,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,CAAA;AAChC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceMutationPaths, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
|
-
import { type UseMutationOptions, type UseMutationResult } from '@tanstack/react-query';
|
|
3
|
-
export type UseSeamMutationWithoutWorkspaceVariables<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> = Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[0];
|
|
4
|
-
export type UseSeamMutationWithoutWorkspaceResult<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> = UseMutationResult<MutationData<T>, MutationError, UseSeamMutationWithoutWorkspaceVariables<T>>;
|
|
5
|
-
export declare function useSeamMutationWithoutWorkspace<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths>(endpointPath: T, options?: Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[1] & MutationOptions<MutationData<T>, MutationError, UseSeamMutationWithoutWorkspaceVariables<T>>): UseSeamMutationWithoutWorkspaceResult<T>;
|
|
6
|
-
type MutationData<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> = Awaited<ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>>;
|
|
7
|
-
type MutationError = Error | SeamHttpApiError | SeamHttpInvalidInputError;
|
|
8
|
-
type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>;
|
|
9
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useMutation, } from '@tanstack/react-query';
|
|
2
|
-
import { NullSeamClientError, useSeamClient } from '../../lib/seam/use-seam-client.js';
|
|
3
|
-
export function useSeamMutationWithoutWorkspace(endpointPath, options = {}) {
|
|
4
|
-
const { endpointClient: client } = useSeamClient();
|
|
5
|
-
return useMutation({
|
|
6
|
-
...options,
|
|
7
|
-
mutationFn: async (variables) => {
|
|
8
|
-
if (client === null)
|
|
9
|
-
throw new NullSeamClientError();
|
|
10
|
-
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
11
|
-
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
12
|
-
const endpoint = client[endpointPath];
|
|
13
|
-
return await endpoint(variables, options);
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=use-seam-mutation-without-workspace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-mutation-without-workspace.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-mutation-without-workspace.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAchF,MAAM,UAAU,+BAA+B,CAG7C,YAAe,EACf,UAKM,EAAE;IAER,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClD,OAAO,WAAW,CAAC;QACjB,GAAG,OAAO;QACV,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YACpD,iHAAiH;YACjH,2FAA2F;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAmC,CAAA;YACvE,OAAO,MAAM,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC3C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { SeamActionAttemptFailedError, SeamActionAttemptTimeoutError, SeamHttpApiError, SeamHttpEndpointMutationPaths, SeamHttpEndpoints, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
|
-
import type { ActionAttempt } from '@seamapi/types/connect';
|
|
3
|
-
import { type UseMutationOptions, type UseMutationResult } from '@tanstack/react-query';
|
|
4
|
-
export type UseSeamMutationVariables<T extends SeamHttpEndpointMutationPaths> = Parameters<SeamHttpEndpoints[T]>[0];
|
|
5
|
-
export type UseSeamMutationResult<T extends SeamHttpEndpointMutationPaths> = UseMutationResult<MutationData<T>, MutationError<T>, UseSeamMutationVariables<T>>;
|
|
6
|
-
export declare function useSeamMutation<T extends SeamHttpEndpointMutationPaths>(endpointPath: T, options?: Parameters<SeamHttpEndpoints[T]>[1] & MutationOptions<MutationData<T>, MutationError<T>, UseSeamMutationVariables<T>>): UseSeamMutationResult<T>;
|
|
7
|
-
type MutationData<T extends SeamHttpEndpointMutationPaths> = Awaited<ReturnType<SeamHttpEndpoints[T]>>;
|
|
8
|
-
type MutationError<T extends SeamHttpEndpointMutationPaths> = Error | SeamHttpApiError | SeamHttpInvalidInputError | (MutationData<T> extends ActionAttempt ? SeamActionAttemptFailedError<MutationData<T>> | SeamActionAttemptTimeoutError<MutationData<T>> : never);
|
|
9
|
-
type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>;
|
|
10
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useMutation, } from '@tanstack/react-query';
|
|
2
|
-
import { NullSeamClientError, useSeamClient } from '../../lib/seam/use-seam-client.js';
|
|
3
|
-
export function useSeamMutation(endpointPath, options = {}) {
|
|
4
|
-
const { endpointClient: client } = useSeamClient();
|
|
5
|
-
return useMutation({
|
|
6
|
-
...options,
|
|
7
|
-
mutationFn: async (variables) => {
|
|
8
|
-
if (client === null)
|
|
9
|
-
throw new NullSeamClientError();
|
|
10
|
-
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
11
|
-
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
12
|
-
const endpoint = client[endpointPath];
|
|
13
|
-
return await endpoint(variables, options);
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=use-seam-mutation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-mutation.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-mutation.ts"],"names":[],"mappings":"AASA,OAAO,EACL,WAAW,GAGZ,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAYhF,MAAM,UAAU,eAAe,CAC7B,YAAe,EACf,UAKM,EAAE;IAER,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClD,OAAO,WAAW,CAAC;QACjB,GAAG,OAAO;QACV,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YACpD,iHAAiH;YACjH,2FAA2F;YAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,YAAY,CAAmC,CAAA;YACvE,OAAO,MAAM,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC3C,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|