@seamapi/react 4.9.1 → 4.10.0
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 -2
- package/dist/elements.js +8731 -9043
- package/dist/elements.js.map +1 -1
- package/lib/seam/SeamQueryProvider.d.ts +7 -1
- package/lib/seam/SeamQueryProvider.js +47 -3
- package/lib/seam/SeamQueryProvider.js.map +1 -1
- package/lib/seam/index.d.ts +2 -0
- package/lib/seam/index.js +2 -0
- package/lib/seam/index.js.map +1 -1
- package/lib/seam/use-seam-client.d.ts +3 -1
- package/lib/seam/use-seam-client.js +56 -18
- package/lib/seam/use-seam-client.js.map +1 -1
- package/lib/seam/use-seam-mutation-without-workspace.d.ts +8 -0
- package/lib/seam/use-seam-mutation-without-workspace.js +17 -0
- package/lib/seam/use-seam-mutation-without-workspace.js.map +1 -0
- package/lib/seam/use-seam-query-without-workspace.d.ts +8 -0
- package/lib/seam/use-seam-query-without-workspace.js +23 -0
- package/lib/seam/use-seam-query-without-workspace.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +2 -2
- package/src/lib/seam/SeamQueryProvider.tsx +86 -3
- package/src/lib/seam/index.ts +2 -0
- package/src/lib/seam/use-seam-client.ts +94 -23
- package/src/lib/seam/use-seam-mutation-without-workspace.ts +53 -0
- package/src/lib/seam/use-seam-query-without-workspace.ts +53 -0
- package/src/lib/version.ts +1 -1
|
@@ -8,9 +8,11 @@ export interface SeamQueryContext {
|
|
|
8
8
|
publishableKey?: string | undefined;
|
|
9
9
|
userIdentifierKey?: string | undefined;
|
|
10
10
|
clientSessionToken?: string | undefined;
|
|
11
|
+
consoleSessionToken?: string | undefined;
|
|
12
|
+
workspaceId?: string | undefined;
|
|
11
13
|
queryKeyPrefix?: string | undefined;
|
|
12
14
|
}
|
|
13
|
-
export type SeamQueryProviderProps = SeamQueryProviderPropsWithClient | SeamQueryProviderPropsWithPublishableKey | SeamQueryProviderPropsWithClientSessionToken;
|
|
15
|
+
export type SeamQueryProviderProps = SeamQueryProviderPropsWithClient | SeamQueryProviderPropsWithPublishableKey | SeamQueryProviderPropsWithClientSessionToken | SeamQueryProviderPropsWithConsoleSessionToken;
|
|
14
16
|
export interface SeamQueryProviderPropsWithClient extends SeamQueryProviderBaseProps {
|
|
15
17
|
client: SeamHttp;
|
|
16
18
|
queryKeyPrefix: string;
|
|
@@ -22,6 +24,10 @@ export interface SeamQueryProviderPropsWithPublishableKey extends SeamQueryProvi
|
|
|
22
24
|
export interface SeamQueryProviderPropsWithClientSessionToken extends SeamQueryProviderBaseProps, SeamQueryProviderClientOptions {
|
|
23
25
|
clientSessionToken: string;
|
|
24
26
|
}
|
|
27
|
+
export interface SeamQueryProviderPropsWithConsoleSessionToken extends SeamQueryProviderBaseProps, SeamQueryProviderClientOptions {
|
|
28
|
+
consoleSessionToken: string;
|
|
29
|
+
workspaceId?: string | undefined;
|
|
30
|
+
}
|
|
25
31
|
interface SeamQueryProviderBaseProps extends PropsWithChildren {
|
|
26
32
|
queryClient?: QueryClient | undefined;
|
|
27
33
|
onSessionUpdate?: (client: SeamHttp) => void;
|
|
@@ -8,15 +8,17 @@ export function SeamQueryProvider({ children, onSessionUpdate = () => { }, query
|
|
|
8
8
|
const context = createSeamQueryContextValue(props);
|
|
9
9
|
if (context.client == null &&
|
|
10
10
|
context.publishableKey == null &&
|
|
11
|
-
context.clientSessionToken == null
|
|
11
|
+
context.clientSessionToken == null &&
|
|
12
|
+
context.consoleSessionToken == null) {
|
|
12
13
|
return defaultSeamQueryContextValue;
|
|
13
14
|
}
|
|
14
15
|
return context;
|
|
15
16
|
}, [props]);
|
|
16
17
|
if (value.client == null &&
|
|
17
18
|
value.publishableKey == null &&
|
|
18
|
-
value.clientSessionToken == null
|
|
19
|
-
|
|
19
|
+
value.clientSessionToken == null &&
|
|
20
|
+
value.consoleSessionToken == null) {
|
|
21
|
+
throw new Error(`Must provide either a Seam client, clientSessionToken, publishableKey or consoleSessionToken.`);
|
|
20
22
|
}
|
|
21
23
|
const { Provider } = seamContext;
|
|
22
24
|
const queryClientFromContext = useContext(QueryClientContext);
|
|
@@ -77,6 +79,16 @@ const createSeamQueryContextValue = (options) => {
|
|
|
77
79
|
endpointClient: null,
|
|
78
80
|
};
|
|
79
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
|
+
}
|
|
80
92
|
return { client: null, endpointClient: null };
|
|
81
93
|
};
|
|
82
94
|
const defaultSeamQueryContextValue = createDefaultSeamQueryContextValue();
|
|
@@ -108,6 +120,12 @@ const isSeamQueryProviderPropsWithPublishableKey = (props) => {
|
|
|
108
120
|
if ('clientSessionToken' in props && props.clientSessionToken != null) {
|
|
109
121
|
throw new InvalidSeamQueryProviderProps('The clientSessionToken prop cannot be used with the publishableKey prop.');
|
|
110
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
|
+
}
|
|
111
129
|
return true;
|
|
112
130
|
};
|
|
113
131
|
const isSeamQueryProviderPropsWithClientSessionToken = (props) => {
|
|
@@ -125,6 +143,32 @@ const isSeamQueryProviderPropsWithClientSessionToken = (props) => {
|
|
|
125
143
|
if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
|
|
126
144
|
throw new InvalidSeamQueryProviderProps('The userIdentifierKey prop cannot be used with the clientSessionToken prop.');
|
|
127
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
|
+
}
|
|
128
172
|
return true;
|
|
129
173
|
};
|
|
130
174
|
class InvalidSeamQueryProviderProps extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SeamQueryProvider.js","sourceRoot":"","sources":["../../src/lib/seam/SeamQueryProvider.tsx"],"names":[],"mappings":";AAKA,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,mB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
|
|
14
14
|
export * from './use-seam-client.js';
|
|
15
15
|
export * from './use-seam-mutation.js';
|
|
16
|
+
export * from './use-seam-mutation-without-workspace.js';
|
|
16
17
|
export * from './use-seam-query.js';
|
|
17
18
|
export * from './use-seam-query-result.js';
|
|
19
|
+
export * from './use-seam-query-without-workspace.js';
|
package/lib/seam/index.js
CHANGED
|
@@ -13,6 +13,8 @@ export * from './devices/use-devices.js';
|
|
|
13
13
|
export * from './SeamProvider.js';
|
|
14
14
|
export * from './use-seam-client.js';
|
|
15
15
|
export * from './use-seam-mutation.js';
|
|
16
|
+
export * from './use-seam-mutation-without-workspace.js';
|
|
16
17
|
export * from './use-seam-query.js';
|
|
17
18
|
export * from './use-seam-query-result.js';
|
|
19
|
+
export * from './use-seam-query-without-workspace.js';
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
package/lib/seam/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/seam/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,0CAA0C,CAAA;AACxD,cAAc,0CAA0C,CAAA;AACxD,cAAc,iDAAiD,CAAA;AAC/D,cAAc,0CAA0C,CAAA;AACxD,cAAc,yCAAyC,CAAA;AACvD,cAAc,kDAAkD,CAAA;AAChE,cAAc,+CAA+C,CAAA;AAC7D,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/seam/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,0CAA0C,CAAA;AACxD,cAAc,0CAA0C,CAAA;AACxD,cAAc,iDAAiD,CAAA;AAC/D,cAAc,0CAA0C,CAAA;AACxD,cAAc,yCAAyC,CAAA;AACvD,cAAc,kDAAkD,CAAA;AAChE,cAAc,+CAA+C,CAAA;AAC7D,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0CAA0C,CAAA;AACxD,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,CAAA"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { SeamHttp, SeamHttpEndpoints } from '@seamapi/http/connect';
|
|
1
|
+
import { SeamHttp, SeamHttpEndpoints, SeamHttpEndpointsWithoutWorkspace, SeamHttpWithoutWorkspace } from '@seamapi/http/connect';
|
|
2
2
|
export declare function useSeamClient(): {
|
|
3
3
|
client: SeamHttp | null;
|
|
4
4
|
endpointClient: SeamHttpEndpoints | null;
|
|
5
|
+
clientWithoutWorkspace: SeamHttpWithoutWorkspace | null;
|
|
6
|
+
endpointClientWithoutWorkspace: SeamHttpEndpointsWithoutWorkspace | null;
|
|
5
7
|
queryKeyPrefixes: string[];
|
|
6
8
|
isPending: boolean;
|
|
7
9
|
isError: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { SeamHttp, SeamHttpEndpoints } from '@seamapi/http/connect';
|
|
1
|
+
import { SeamHttp, SeamHttpEndpoints, SeamHttpEndpointsWithoutWorkspace, SeamHttpWithoutWorkspace, } from '@seamapi/http/connect';
|
|
2
2
|
import { useQuery } from '@tanstack/react-query';
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
import { useSeamQueryContext } from './SeamQueryProvider.js';
|
|
6
6
|
export function useSeamClient() {
|
|
7
|
-
const { client, clientOptions, publishableKey, clientSessionToken, queryKeyPrefix, ...context } = useSeamQueryContext();
|
|
7
|
+
const { client, clientOptions, publishableKey, clientSessionToken, consoleSessionToken, workspaceId, queryKeyPrefix, ...context } = useSeamQueryContext();
|
|
8
8
|
const userIdentifierKey = useUserIdentifierKeyOrFingerprint(clientSessionToken != null ? '' : context.userIdentifierKey);
|
|
9
9
|
const { isPending, isError, error, data } = useQuery({
|
|
10
10
|
queryKey: [
|
|
@@ -20,32 +20,64 @@ export function useSeamClient() {
|
|
|
20
20
|
],
|
|
21
21
|
queryFn: async () => {
|
|
22
22
|
if (client != null)
|
|
23
|
-
return
|
|
23
|
+
return {
|
|
24
|
+
client,
|
|
25
|
+
endpointClient: SeamHttpEndpoints.fromClient(client.client),
|
|
26
|
+
clientWithoutWorkspace: null,
|
|
27
|
+
endpointClientWithoutWorkspace: null,
|
|
28
|
+
};
|
|
24
29
|
if (clientSessionToken != null) {
|
|
25
|
-
const
|
|
26
|
-
return
|
|
27
|
-
|
|
28
|
-
SeamHttpEndpoints.fromClient(
|
|
29
|
-
|
|
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
|
+
};
|
|
30
37
|
}
|
|
31
|
-
if (publishableKey
|
|
32
|
-
|
|
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
|
+
};
|
|
33
46
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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.');
|
|
39
67
|
},
|
|
40
68
|
});
|
|
41
69
|
return {
|
|
42
|
-
client: data?.
|
|
43
|
-
endpointClient: data?.
|
|
70
|
+
client: data?.client ?? null,
|
|
71
|
+
endpointClient: data?.endpointClient ?? null,
|
|
72
|
+
clientWithoutWorkspace: data?.clientWithoutWorkspace ?? null,
|
|
73
|
+
endpointClientWithoutWorkspace: data?.endpointClientWithoutWorkspace ?? null,
|
|
44
74
|
queryKeyPrefixes: getQueryKeyPrefixes({
|
|
45
75
|
queryKeyPrefix,
|
|
46
76
|
userIdentifierKey,
|
|
47
77
|
publishableKey,
|
|
48
78
|
clientSessionToken,
|
|
79
|
+
consoleSessionToken,
|
|
80
|
+
workspaceId,
|
|
49
81
|
}),
|
|
50
82
|
isPending,
|
|
51
83
|
isError,
|
|
@@ -81,7 +113,7 @@ This is not recommended because the client session is now bound to this machine
|
|
|
81
113
|
globalThis.localStorage?.setItem('seam_user_fingerprint', fingerprint);
|
|
82
114
|
return fingerprint;
|
|
83
115
|
}
|
|
84
|
-
const getQueryKeyPrefixes = ({ queryKeyPrefix, userIdentifierKey, publishableKey, clientSessionToken, }) => {
|
|
116
|
+
const getQueryKeyPrefixes = ({ queryKeyPrefix, userIdentifierKey, publishableKey, clientSessionToken, consoleSessionToken, workspaceId, }) => {
|
|
85
117
|
const seamPrefix = 'seam';
|
|
86
118
|
if (queryKeyPrefix != null)
|
|
87
119
|
return [seamPrefix, queryKeyPrefix];
|
|
@@ -91,6 +123,12 @@ const getQueryKeyPrefixes = ({ queryKeyPrefix, userIdentifierKey, publishableKey
|
|
|
91
123
|
if (publishableKey != null && userIdentifierKey != null) {
|
|
92
124
|
return [seamPrefix, publishableKey, userIdentifierKey];
|
|
93
125
|
}
|
|
126
|
+
if (consoleSessionToken != null) {
|
|
127
|
+
if (workspaceId != null) {
|
|
128
|
+
return [seamPrefix, consoleSessionToken, workspaceId];
|
|
129
|
+
}
|
|
130
|
+
return [seamPrefix, consoleSessionToken, 'without_workspace'];
|
|
131
|
+
}
|
|
94
132
|
return [seamPrefix];
|
|
95
133
|
};
|
|
96
134
|
//# sourceMappingURL=use-seam-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-client.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,IAA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,UAAU,EAAE,cAAc,CAAC,CAAA;IAE/D,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;QAC/B,OAAO,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAA;IACzC,CAAC;IAED,IAAI,cAAc,IAAI,IAAI,IAAI,iBAAiB,IAAI,IAAI,EAAE,CAAC;QACxD,OAAO,CAAC,UAAU,EAAE,cAAc,EAAE,iBAAiB,CAAC,CAAA;IACxD,CAAC;IAED,IAAI,mBAAmB,IAAI,IAAI,EAAE,CAAC;QAChC,IAAI,WAAW,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO,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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceMutationPaths } 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>, SeamHttpApiError, UseSeamMutationWithoutWorkspaceVariables<T>>;
|
|
5
|
+
export declare function UseSeamMutationWithoutWorkspace<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths>(endpointPath: T, options?: Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[1] & MutationOptions<MutationData<T>, SeamHttpApiError, UseSeamMutationWithoutWorkspaceVariables<T>>): UseSeamMutationWithoutWorkspaceResult<T>;
|
|
6
|
+
type MutationData<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> = Awaited<ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>>;
|
|
7
|
+
type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-seam-mutation-without-workspace.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-mutation-without-workspace.ts"],"names":[],"mappings":"AAKA,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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceQueryPaths } from '@seamapi/http/connect';
|
|
2
|
+
import { 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>, SeamHttpApiError>;
|
|
5
|
+
export declare function useSeamQueryWithoutWorkspace<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths>(endpointPath: T, parameters?: UseSeamQueryWithoutWorkspaceParameters<T>, options?: Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[1] & QueryOptions<QueryData<T>, SeamHttpApiError>): UseSeamQueryWithoutWorkspaceResult<T>;
|
|
6
|
+
type QueryData<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = Awaited<ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>>;
|
|
7
|
+
type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
return useQuery({
|
|
6
|
+
enabled: client != null,
|
|
7
|
+
...options,
|
|
8
|
+
queryKey: [
|
|
9
|
+
...queryKeyPrefixes,
|
|
10
|
+
...endpointPath.split('/').filter((v) => v !== ''),
|
|
11
|
+
parameters,
|
|
12
|
+
],
|
|
13
|
+
queryFn: async () => {
|
|
14
|
+
if (client == null)
|
|
15
|
+
return null;
|
|
16
|
+
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
17
|
+
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
18
|
+
const endpoint = client[endpointPath];
|
|
19
|
+
return await endpoint(parameters, options);
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=use-seam-query-without-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-seam-query-without-workspace.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-query-without-workspace.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAU3D,MAAM,UAAU,4BAA4B,CAG1C,YAAe,EACf,UAAsD,EACtD,UACiD,EAAE;IAEnD,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAA;IACpE,OAAO,QAAQ,CAAC;QACd,OAAO,EAAE,MAAM,IAAI,IAAI;QACvB,GAAG,OAAO;QACV,QAAQ,EAAE;YACR,GAAG,gBAAgB;YACnB,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;YAClD,UAAU;SACX;QACD,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;AACJ,CAAC"}
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const seamapiReactVersion = "4.
|
|
1
|
+
declare const seamapiReactVersion = "4.10.0";
|
|
2
2
|
export default seamapiReactVersion;
|
package/lib/version.js
CHANGED
package/lib/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/lib/version.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/lib/version.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG,QAAQ,CAAA;AAEpC,eAAe,mBAAmB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamapi/react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "Seam Components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"@rxfork/r2wc-react-to-web-component": "^2.4.0",
|
|
146
146
|
"@seamapi/fake-devicedb": "^1.6.1",
|
|
147
147
|
"@seamapi/fake-seam-connect": "^1.76.0",
|
|
148
|
-
"@seamapi/http": "^1.
|
|
148
|
+
"@seamapi/http": "^1.40.0",
|
|
149
149
|
"@seamapi/types": "^1.395.3",
|
|
150
150
|
"@storybook/addon-designs": "^7.0.1",
|
|
151
151
|
"@storybook/addon-essentials": "^7.0.2",
|
|
@@ -25,6 +25,8 @@ export interface SeamQueryContext {
|
|
|
25
25
|
publishableKey?: string | undefined
|
|
26
26
|
userIdentifierKey?: string | undefined
|
|
27
27
|
clientSessionToken?: string | undefined
|
|
28
|
+
consoleSessionToken?: string | undefined
|
|
29
|
+
workspaceId?: string | undefined
|
|
28
30
|
queryKeyPrefix?: string | undefined
|
|
29
31
|
}
|
|
30
32
|
|
|
@@ -32,6 +34,7 @@ export type SeamQueryProviderProps =
|
|
|
32
34
|
| SeamQueryProviderPropsWithClient
|
|
33
35
|
| SeamQueryProviderPropsWithPublishableKey
|
|
34
36
|
| SeamQueryProviderPropsWithClientSessionToken
|
|
37
|
+
| SeamQueryProviderPropsWithConsoleSessionToken
|
|
35
38
|
|
|
36
39
|
export interface SeamQueryProviderPropsWithClient
|
|
37
40
|
extends SeamQueryProviderBaseProps {
|
|
@@ -52,6 +55,13 @@ export interface SeamQueryProviderPropsWithClientSessionToken
|
|
|
52
55
|
clientSessionToken: string
|
|
53
56
|
}
|
|
54
57
|
|
|
58
|
+
export interface SeamQueryProviderPropsWithConsoleSessionToken
|
|
59
|
+
extends SeamQueryProviderBaseProps,
|
|
60
|
+
SeamQueryProviderClientOptions {
|
|
61
|
+
consoleSessionToken: string
|
|
62
|
+
workspaceId?: string | undefined
|
|
63
|
+
}
|
|
64
|
+
|
|
55
65
|
interface SeamQueryProviderBaseProps extends PropsWithChildren {
|
|
56
66
|
queryClient?: QueryClient | undefined
|
|
57
67
|
onSessionUpdate?: (client: SeamHttp) => void
|
|
@@ -74,7 +84,8 @@ export function SeamQueryProvider({
|
|
|
74
84
|
if (
|
|
75
85
|
context.client == null &&
|
|
76
86
|
context.publishableKey == null &&
|
|
77
|
-
context.clientSessionToken == null
|
|
87
|
+
context.clientSessionToken == null &&
|
|
88
|
+
context.consoleSessionToken == null
|
|
78
89
|
) {
|
|
79
90
|
return defaultSeamQueryContextValue
|
|
80
91
|
}
|
|
@@ -84,10 +95,11 @@ export function SeamQueryProvider({
|
|
|
84
95
|
if (
|
|
85
96
|
value.client == null &&
|
|
86
97
|
value.publishableKey == null &&
|
|
87
|
-
value.clientSessionToken == null
|
|
98
|
+
value.clientSessionToken == null &&
|
|
99
|
+
value.consoleSessionToken == null
|
|
88
100
|
) {
|
|
89
101
|
throw new Error(
|
|
90
|
-
`Must provide either a Seam client, clientSessionToken, or
|
|
102
|
+
`Must provide either a Seam client, clientSessionToken, publishableKey or consoleSessionToken.`
|
|
91
103
|
)
|
|
92
104
|
}
|
|
93
105
|
|
|
@@ -177,6 +189,17 @@ const createSeamQueryContextValue = (
|
|
|
177
189
|
}
|
|
178
190
|
}
|
|
179
191
|
|
|
192
|
+
if (isSeamQueryProviderPropsWithConsoleSessionToken(options)) {
|
|
193
|
+
const { consoleSessionToken, workspaceId, ...clientOptions } = options
|
|
194
|
+
return {
|
|
195
|
+
consoleSessionToken,
|
|
196
|
+
workspaceId,
|
|
197
|
+
clientOptions,
|
|
198
|
+
client: null,
|
|
199
|
+
endpointClient: null,
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
180
203
|
return { client: null, endpointClient: null }
|
|
181
204
|
}
|
|
182
205
|
|
|
@@ -229,6 +252,18 @@ const isSeamQueryProviderPropsWithPublishableKey = (
|
|
|
229
252
|
)
|
|
230
253
|
}
|
|
231
254
|
|
|
255
|
+
if ('consoleSessionToken' in props && props.consoleSessionToken != null) {
|
|
256
|
+
throw new InvalidSeamQueryProviderProps(
|
|
257
|
+
'The consoleSessionToken prop cannot be used with the publishableKey prop.'
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if ('workspaceId' in props && props.workspaceId != null) {
|
|
262
|
+
throw new InvalidSeamQueryProviderProps(
|
|
263
|
+
'The workspaceId prop cannot be used with the publishableKey prop.'
|
|
264
|
+
)
|
|
265
|
+
}
|
|
266
|
+
|
|
232
267
|
return true
|
|
233
268
|
}
|
|
234
269
|
|
|
@@ -259,6 +294,54 @@ const isSeamQueryProviderPropsWithClientSessionToken = (
|
|
|
259
294
|
)
|
|
260
295
|
}
|
|
261
296
|
|
|
297
|
+
if ('consoleSessionToken' in props && props.consoleSessionToken != null) {
|
|
298
|
+
throw new InvalidSeamQueryProviderProps(
|
|
299
|
+
'The consoleSessionToken prop cannot be used with the clientSessionToken prop.'
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if ('workspaceId' in props && props.workspaceId != null) {
|
|
304
|
+
throw new InvalidSeamQueryProviderProps(
|
|
305
|
+
'The workspaceId prop cannot be used with the clientSessionToken prop.'
|
|
306
|
+
)
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return true
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const isSeamQueryProviderPropsWithConsoleSessionToken = (
|
|
313
|
+
props: SeamQueryProviderProps
|
|
314
|
+
): props is SeamQueryProviderPropsWithConsoleSessionToken &
|
|
315
|
+
SeamQueryProviderClientOptions => {
|
|
316
|
+
if (!('consoleSessionToken' in props)) return false
|
|
317
|
+
|
|
318
|
+
const { consoleSessionToken } = props
|
|
319
|
+
if (consoleSessionToken == null) return false
|
|
320
|
+
|
|
321
|
+
if ('client' in props && props.client != null) {
|
|
322
|
+
throw new InvalidSeamQueryProviderProps(
|
|
323
|
+
'The client prop cannot be used with the publishableKey prop.'
|
|
324
|
+
)
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if ('clientSessionToken' in props && props.clientSessionToken != null) {
|
|
328
|
+
throw new InvalidSeamQueryProviderProps(
|
|
329
|
+
'The clientSessionToken prop cannot be used with the publishableKey prop.'
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
if ('publishableKey' in props && props.publishableKey != null) {
|
|
334
|
+
throw new InvalidSeamQueryProviderProps(
|
|
335
|
+
'The publishableKey prop cannot be used with the consoleSessionToken prop.'
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
if ('userIdentifierKey' in props && props.userIdentifierKey != null) {
|
|
340
|
+
throw new InvalidSeamQueryProviderProps(
|
|
341
|
+
'The userIdentifierKey prop cannot be used with the consoleSessionToken prop.'
|
|
342
|
+
)
|
|
343
|
+
}
|
|
344
|
+
|
|
262
345
|
return true
|
|
263
346
|
}
|
|
264
347
|
|
package/src/lib/seam/index.ts
CHANGED
|
@@ -13,5 +13,7 @@ export * from './devices/use-devices.js'
|
|
|
13
13
|
export * from './SeamProvider.js'
|
|
14
14
|
export * from './use-seam-client.js'
|
|
15
15
|
export * from './use-seam-mutation.js'
|
|
16
|
+
export * from './use-seam-mutation-without-workspace.js'
|
|
16
17
|
export * from './use-seam-query.js'
|
|
17
18
|
export * from './use-seam-query-result.js'
|
|
19
|
+
export * from './use-seam-query-without-workspace.js'
|