@seamapi/react 4.10.0 → 4.11.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 -2
- package/dist/elements.js +2 -2
- package/dist/elements.js.map +1 -1
- package/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.d.ts +1 -1
- package/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.js.map +1 -1
- package/lib/seam/index.d.ts +1 -0
- package/lib/seam/index.js +1 -0
- package/lib/seam/index.js.map +1 -1
- package/lib/seam/use-seam-infinite-query.d.ts +13 -0
- package/lib/seam/use-seam-infinite-query.js +42 -0
- package/lib/seam/use-seam-infinite-query.js.map +1 -0
- package/lib/seam/use-seam-mutation-without-workspace.d.ts +4 -3
- package/lib/seam/use-seam-mutation-without-workspace.js +1 -1
- package/lib/seam/use-seam-mutation-without-workspace.js.map +1 -1
- package/lib/seam/use-seam-mutation.d.ts +5 -3
- package/lib/seam/use-seam-mutation.js.map +1 -1
- package/lib/seam/use-seam-query-without-workspace.d.ts +4 -3
- package/lib/seam/use-seam-query-without-workspace.js.map +1 -1
- package/lib/seam/use-seam-query.d.ts +4 -2
- package/lib/seam/use-seam-query.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.tsx +2 -2
- package/src/lib/seam/index.ts +1 -0
- package/src/lib/seam/use-seam-infinite-query.ts +95 -0
- package/src/lib/seam/use-seam-mutation-without-workspace.ts +6 -3
- package/src/lib/seam/use-seam-mutation.ts +16 -2
- package/src/lib/seam/use-seam-query-without-workspace.ts +5 -2
- package/src/lib/seam/use-seam-query.ts +15 -1
- package/src/lib/version.ts +1 -1
|
@@ -10,6 +10,6 @@ export declare const NestedCreateAccessCodeForm: (props: CreateAccessCodeFormPro
|
|
|
10
10
|
export declare function CreateAccessCodeForm({ className, onBack, deviceId, onSuccess, }: CreateAccessCodeFormProps): JSX.Element | null;
|
|
11
11
|
export declare function useResponseErrors(): {
|
|
12
12
|
responseErrors: ResponseErrors | null;
|
|
13
|
-
handleResponseError: (error: SeamHttpApiError) => void;
|
|
13
|
+
handleResponseError: (error: SeamHttpApiError | Error) => void;
|
|
14
14
|
resetResponseErrors: () => void;
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateAccessCodeForm.js","sourceRoot":"","sources":["../../../../src/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,2BAA2B,GAE5B,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAA;AACrF,OAAO,EAEL,uBAAuB,GACxB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EACL,cAAc,GAGf,MAAM,yCAAyC,CAAA;AAOhD,MAAM,CAAC,MAAM,0BAA0B,GACrC,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;AAE/C,MAAM,UAAU,oBAAoB,CAAC,EACnC,SAAS,EACT,MAAM,EACN,QAAQ,EACR,SAAS,GACiB;IAC1B,qBAAqB,CAAC,sBAAsB,CAAC,CAAA;IAE7C,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;QAC3B,SAAS,EAAE,QAAQ;KACpB,CAAC,CAAA;IAEF,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QACnB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,CACL,KAAC,OAAO,IACN,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,MAAM,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,YAAY,EAAE,CAAC;YAC1B,MAAM,CACJ;gBACE,IAAI;gBACJ,IAAI;gBACJ,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,SAAS,EAAE,SAAS;gBACpB,OAAO,EAAE,OAAO;aACjB,EACD;gBACE,SAAS;gBACT,OAAO,EAAE,mBAAmB;aAC7B,CACF,CAAA;YAED,OAAM;QACR,CAAC;QAED,MAAM,CACJ;YACE,IAAI;YACJ,IAAI;YACJ,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,EACD;YACE,SAAS;YACT,OAAO,EAAE,mBAAmB;SAC7B,CACF,CAAA;IACH,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,iBAAiB;IAK/B,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAG1C,IAAI,CAAC,CAAA;IAEf,MAAM,mBAAmB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"CreateAccessCodeForm.js","sourceRoot":"","sources":["../../../../src/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,2BAA2B,GAE5B,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAA;AACrF,OAAO,EAEL,uBAAuB,GACxB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,EACL,cAAc,GAGf,MAAM,yCAAyC,CAAA;AAOhD,MAAM,CAAC,MAAM,0BAA0B,GACrC,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;AAE/C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CAAC,CAAC,CAAC;aAClD,CAAC,CAAA;YACF,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACrC,iBAAiB,CAAC;oBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;iBACvB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;QAED,iBAAiB,CAAC;YAChB,OAAO,EAAE,CAAC,CAAC,oBAAoB;SAChC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,MAAM,mBAAmB,GAAG,GAAS,EAAE;QACrC,iBAAiB,CAAC,IAAI,CAAC,CAAA;IACzB,CAAC,CAAA;IAED,OAAO;QACL,cAAc;QACd,mBAAmB;QACnB,mBAAmB;KACpB,CAAA;AACH,CAAC;AAED,MAAM,CAAC,GAAG;IACR,oBAAoB,EAAE,gDAAgD;CACvE,CAAA"}
|
package/lib/seam/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './devices/use-device-providers.js';
|
|
|
12
12
|
export * from './devices/use-devices.js';
|
|
13
13
|
export * from './SeamProvider.js';
|
|
14
14
|
export * from './use-seam-client.js';
|
|
15
|
+
export * from './use-seam-infinite-query.js';
|
|
15
16
|
export * from './use-seam-mutation.js';
|
|
16
17
|
export * from './use-seam-mutation-without-workspace.js';
|
|
17
18
|
export * from './use-seam-query.js';
|
package/lib/seam/index.js
CHANGED
|
@@ -12,6 +12,7 @@ export * from './devices/use-device-providers.js';
|
|
|
12
12
|
export * from './devices/use-devices.js';
|
|
13
13
|
export * from './SeamProvider.js';
|
|
14
14
|
export * from './use-seam-client.js';
|
|
15
|
+
export * from './use-seam-infinite-query.js';
|
|
15
16
|
export * from './use-seam-mutation.js';
|
|
16
17
|
export * from './use-seam-mutation-without-workspace.js';
|
|
17
18
|
export * from './use-seam-query.js';
|
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,0CAA0C,CAAA;AACxD,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,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,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,0CAA0C,CAAA;AACxD,cAAc,qBAAqB,CAAA;AACnC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uCAAuC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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 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
|
+
interface QueryData<T extends SeamHttpEndpointPaginatedQueryPaths> {
|
|
8
|
+
data: Awaited<ReturnType<SeamHttpEndpoints[T]>>;
|
|
9
|
+
nextPageCursor: SeamPageCursor | null;
|
|
10
|
+
}
|
|
11
|
+
type QueryError<T extends SeamHttpEndpointPaginatedQueryPaths> = Error | SeamHttpApiError | SeamHttpInvalidInputError | (QueryData<T>['data'] extends ActionAttempt ? SeamActionAttemptFailedError<QueryData<T>['data']> | SeamActionAttemptTimeoutError<QueryData<T>['data']> : never);
|
|
12
|
+
type QueryOptions<X, Y> = Omit<UseInfiniteQueryOptions<X, Y>, 'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
return useInfiniteQuery({
|
|
6
|
+
enabled: client != null,
|
|
7
|
+
...options,
|
|
8
|
+
queryKey: [
|
|
9
|
+
...queryKeyPrefixes,
|
|
10
|
+
...endpointPath.split('/').filter((v) => v !== ''),
|
|
11
|
+
parameters,
|
|
12
|
+
],
|
|
13
|
+
initialPageParam: null,
|
|
14
|
+
getNextPageParam: (lastPage) => lastPage.nextPageCursor,
|
|
15
|
+
queryFn: async ({ pageParam }) => {
|
|
16
|
+
if (client == null)
|
|
17
|
+
return {
|
|
18
|
+
data: [],
|
|
19
|
+
nextPageCursor: null,
|
|
20
|
+
};
|
|
21
|
+
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
22
|
+
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
23
|
+
const endpoint = client[endpointPath];
|
|
24
|
+
const request = endpoint(parameters, options);
|
|
25
|
+
const pages = client.createPaginator(request);
|
|
26
|
+
if (pageParam == null) {
|
|
27
|
+
const [data, { nextPageCursor }] = await pages.firstPage();
|
|
28
|
+
return {
|
|
29
|
+
data: data,
|
|
30
|
+
nextPageCursor,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// Type assertion is needed for pageParam since the Seam API expects a branded PageCursor type.
|
|
34
|
+
const [data, { nextPageCursor }] = await pages.nextPage(pageParam);
|
|
35
|
+
return {
|
|
36
|
+
data: data,
|
|
37
|
+
nextPageCursor,
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=use-seam-infinite-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-seam-infinite-query.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-infinite-query.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,gBAAgB,GAGjB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AA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CAAA;YACD,OAAO;gBACL,IAAI,EAAE,IAAiD;gBACvD,cAAc;aACf,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceMutationPaths } from '@seamapi/http/connect';
|
|
1
|
+
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceMutationPaths, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
2
|
import { type UseMutationOptions, type UseMutationResult } from '@tanstack/react-query';
|
|
3
3
|
export type UseSeamMutationWithoutWorkspaceVariables<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> = Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[0];
|
|
4
|
-
export type UseSeamMutationWithoutWorkspaceResult<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> = UseMutationResult<MutationData<T>,
|
|
5
|
-
export declare function
|
|
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
6
|
type MutationData<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> = Awaited<ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>>;
|
|
7
|
+
type MutationError = Error | SeamHttpApiError | SeamHttpInvalidInputError;
|
|
7
8
|
type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>;
|
|
8
9
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMutation, } from '@tanstack/react-query';
|
|
2
2
|
import { NullSeamClientError, useSeamClient } from '../../lib/seam/use-seam-client.js';
|
|
3
|
-
export function
|
|
3
|
+
export function useSeamMutationWithoutWorkspace(endpointPath, options = {}) {
|
|
4
4
|
const { endpointClient: client } = useSeamClient();
|
|
5
5
|
return useMutation({
|
|
6
6
|
...options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-mutation-without-workspace.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-mutation-without-workspace.ts"],"names":[],"mappings":"
|
|
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,8 +1,10 @@
|
|
|
1
|
-
import type { SeamHttpApiError, SeamHttpEndpointMutationPaths, SeamHttpEndpoints } from '@seamapi/http/connect';
|
|
1
|
+
import type { SeamActionAttemptFailedError, SeamActionAttemptTimeoutError, SeamHttpApiError, SeamHttpEndpointMutationPaths, SeamHttpEndpoints, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
|
+
import type { ActionAttempt } from '@seamapi/types/connect';
|
|
2
3
|
import { type UseMutationOptions, type UseMutationResult } from '@tanstack/react-query';
|
|
3
4
|
export type UseSeamMutationVariables<T extends SeamHttpEndpointMutationPaths> = Parameters<SeamHttpEndpoints[T]>[0];
|
|
4
|
-
export type UseSeamMutationResult<T extends SeamHttpEndpointMutationPaths> = UseMutationResult<MutationData<T>,
|
|
5
|
-
export declare function useSeamMutation<T extends SeamHttpEndpointMutationPaths>(endpointPath: T, options?: Parameters<SeamHttpEndpoints[T]>[1] & MutationOptions<MutationData<T>,
|
|
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>;
|
|
6
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);
|
|
7
9
|
type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>;
|
|
8
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-mutation.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-mutation.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceQueryPaths } from '@seamapi/http/connect';
|
|
1
|
+
import type { SeamHttpApiError, SeamHttpEndpointsWithoutWorkspace, SeamHttpEndpointWithoutWorkspaceQueryPaths, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
2
|
import { type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
|
|
3
3
|
export type UseSeamQueryWithoutWorkspaceParameters<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[0];
|
|
4
|
-
export type UseSeamQueryWithoutWorkspaceResult<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = UseQueryResult<QueryData<T>,
|
|
5
|
-
export declare function useSeamQueryWithoutWorkspace<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths>(endpointPath: T, parameters?: UseSeamQueryWithoutWorkspaceParameters<T>, options?: Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[1] & QueryOptions<QueryData<T>,
|
|
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
6
|
type QueryData<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = Awaited<ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>>;
|
|
7
|
+
type QueryError = Error | SeamHttpApiError | SeamHttpInvalidInputError;
|
|
7
8
|
type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>;
|
|
8
9
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-query-without-workspace.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-query-without-workspace.ts"],"names":[],"mappings":"
|
|
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,EACL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAU3D,MAAM,UAAU,4BAA4B,CAG1C,YAAe,EACf,UAAsD,EACtD,UAC2C,EAAE;IAE7C,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"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { SeamHttpApiError, SeamHttpEndpointQueryPaths, SeamHttpEndpoints } from '@seamapi/http/connect';
|
|
1
|
+
import type { SeamActionAttemptFailedError, SeamActionAttemptTimeoutError, SeamHttpApiError, SeamHttpEndpointQueryPaths, SeamHttpEndpoints, SeamHttpInvalidInputError } from '@seamapi/http/connect';
|
|
2
|
+
import type { ActionAttempt } from '@seamapi/types/connect';
|
|
2
3
|
import { type UseQueryOptions, type UseQueryResult } from '@tanstack/react-query';
|
|
3
4
|
export type UseSeamQueryParameters<T extends SeamHttpEndpointQueryPaths> = Parameters<SeamHttpEndpoints[T]>[0];
|
|
4
|
-
export type UseSeamQueryResult<T extends SeamHttpEndpointQueryPaths> = UseQueryResult<QueryData<T>,
|
|
5
|
+
export type UseSeamQueryResult<T extends SeamHttpEndpointQueryPaths> = UseQueryResult<QueryData<T>, QueryError<T>>;
|
|
5
6
|
export declare function useSeamQuery<T extends SeamHttpEndpointQueryPaths>(endpointPath: T, parameters?: UseSeamQueryParameters<T>, options?: Parameters<SeamHttpEndpoints[T]>[1] & QueryOptions<QueryData<T>, SeamHttpApiError>): UseSeamQueryResult<T>;
|
|
6
7
|
type QueryData<T extends SeamHttpEndpointQueryPaths> = Awaited<ReturnType<SeamHttpEndpoints[T]>>;
|
|
8
|
+
type QueryError<T extends SeamHttpEndpointQueryPaths> = Error | SeamHttpApiError | SeamHttpInvalidInputError | (QueryData<T> extends ActionAttempt ? SeamActionAttemptFailedError<QueryData<T>> | SeamActionAttemptTimeoutError<QueryData<T>> : never);
|
|
7
9
|
type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>;
|
|
8
10
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-seam-query.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-seam-query.js","sourceRoot":"","sources":["../../src/lib/seam/use-seam-query.ts"],"names":[],"mappings":"AASA,OAAO,EACL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAQ3D,MAAM,UAAU,YAAY,CAC1B,YAAe,EACf,UAAsC,EACtC,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.11.1";
|
|
2
2
|
export default seamapiReactVersion;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamapi/react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.1",
|
|
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.40.
|
|
148
|
+
"@seamapi/http": "^1.40.1",
|
|
149
149
|
"@seamapi/types": "^1.395.3",
|
|
150
150
|
"@storybook/addon-designs": "^7.0.1",
|
|
151
151
|
"@storybook/addon-essentials": "^7.0.2",
|
|
@@ -145,7 +145,7 @@ function useSubmitCreateAccessCode(params: {
|
|
|
145
145
|
|
|
146
146
|
export function useResponseErrors(): {
|
|
147
147
|
responseErrors: ResponseErrors | null
|
|
148
|
-
handleResponseError: (error: SeamHttpApiError) => void
|
|
148
|
+
handleResponseError: (error: SeamHttpApiError | Error) => void
|
|
149
149
|
resetResponseErrors: () => void
|
|
150
150
|
} {
|
|
151
151
|
const [responseErrors, setResponseErrors] = useState<Record<
|
|
@@ -153,7 +153,7 @@ export function useResponseErrors(): {
|
|
|
153
153
|
string | undefined
|
|
154
154
|
> | null>(null)
|
|
155
155
|
|
|
156
|
-
const handleResponseError = (error: SeamHttpApiError): void => {
|
|
156
|
+
const handleResponseError = (error: SeamHttpApiError | Error): void => {
|
|
157
157
|
if (isSeamHttpInvalidInputError(error)) {
|
|
158
158
|
const errors = shake({
|
|
159
159
|
code: error.getValidationErrorMessages('code')[0],
|
package/src/lib/seam/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './devices/use-device-providers.js'
|
|
|
12
12
|
export * from './devices/use-devices.js'
|
|
13
13
|
export * from './SeamProvider.js'
|
|
14
14
|
export * from './use-seam-client.js'
|
|
15
|
+
export * from './use-seam-infinite-query.js'
|
|
15
16
|
export * from './use-seam-mutation.js'
|
|
16
17
|
export * from './use-seam-mutation-without-workspace.js'
|
|
17
18
|
export * from './use-seam-query.js'
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SeamActionAttemptFailedError,
|
|
3
|
+
SeamActionAttemptTimeoutError,
|
|
4
|
+
SeamHttpApiError,
|
|
5
|
+
SeamHttpEndpointPaginatedQueryPaths,
|
|
6
|
+
SeamHttpEndpoints,
|
|
7
|
+
SeamHttpInvalidInputError,
|
|
8
|
+
SeamHttpRequest,
|
|
9
|
+
SeamPageCursor,
|
|
10
|
+
} from '@seamapi/http/connect'
|
|
11
|
+
import type { ActionAttempt } from '@seamapi/types/connect'
|
|
12
|
+
import {
|
|
13
|
+
useInfiniteQuery,
|
|
14
|
+
type UseInfiniteQueryOptions,
|
|
15
|
+
type UseInfiniteQueryResult,
|
|
16
|
+
} from '@tanstack/react-query'
|
|
17
|
+
|
|
18
|
+
import { useSeamClient } from 'lib/seam/use-seam-client.js'
|
|
19
|
+
|
|
20
|
+
export type UseSeamInfiniteQueryParameters<
|
|
21
|
+
T extends SeamHttpEndpointPaginatedQueryPaths,
|
|
22
|
+
> = Parameters<SeamHttpEndpoints[T]>[0]
|
|
23
|
+
|
|
24
|
+
export type UseSeamInfiniteQueryResult<
|
|
25
|
+
T extends SeamHttpEndpointPaginatedQueryPaths,
|
|
26
|
+
> = UseInfiniteQueryResult<QueryData<T>, QueryError<T>>
|
|
27
|
+
|
|
28
|
+
export function useSeamInfiniteQuery<
|
|
29
|
+
T extends SeamHttpEndpointPaginatedQueryPaths,
|
|
30
|
+
>(
|
|
31
|
+
endpointPath: T,
|
|
32
|
+
parameters?: UseSeamInfiniteQueryParameters<T>,
|
|
33
|
+
options: Parameters<SeamHttpEndpoints[T]>[1] &
|
|
34
|
+
QueryOptions<QueryData<T>, QueryError<T>> = {}
|
|
35
|
+
): UseSeamInfiniteQueryResult<T> {
|
|
36
|
+
const { endpointClient: client, queryKeyPrefixes } = useSeamClient()
|
|
37
|
+
return useInfiniteQuery({
|
|
38
|
+
enabled: client != null,
|
|
39
|
+
...options,
|
|
40
|
+
queryKey: [
|
|
41
|
+
...queryKeyPrefixes,
|
|
42
|
+
...endpointPath.split('/').filter((v) => v !== ''),
|
|
43
|
+
parameters,
|
|
44
|
+
],
|
|
45
|
+
initialPageParam: null,
|
|
46
|
+
getNextPageParam: (lastPage) => lastPage.nextPageCursor,
|
|
47
|
+
queryFn: async ({ pageParam }) => {
|
|
48
|
+
if (client == null)
|
|
49
|
+
return {
|
|
50
|
+
data: [] as Awaited<ReturnType<SeamHttpEndpoints[T]>>,
|
|
51
|
+
nextPageCursor: null,
|
|
52
|
+
}
|
|
53
|
+
// Using @ts-expect-error over any is preferred, but not possible here because TypeScript will run out of memory.
|
|
54
|
+
// Type assertion is needed here for performance reasons. The types are correct at runtime.
|
|
55
|
+
const endpoint = client[endpointPath] as (...args: any) => any
|
|
56
|
+
const request = endpoint(parameters, options)
|
|
57
|
+
const pages = client.createPaginator(request as SeamHttpRequest<any, any>)
|
|
58
|
+
if (pageParam == null) {
|
|
59
|
+
const [data, { nextPageCursor }] = await pages.firstPage()
|
|
60
|
+
return {
|
|
61
|
+
data: data as Awaited<ReturnType<SeamHttpEndpoints[T]>>,
|
|
62
|
+
nextPageCursor,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Type assertion is needed for pageParam since the Seam API expects a branded PageCursor type.
|
|
66
|
+
const [data, { nextPageCursor }] = await pages.nextPage(
|
|
67
|
+
pageParam as SeamPageCursor
|
|
68
|
+
)
|
|
69
|
+
return {
|
|
70
|
+
data: data as Awaited<ReturnType<SeamHttpEndpoints[T]>>,
|
|
71
|
+
nextPageCursor,
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
interface QueryData<T extends SeamHttpEndpointPaginatedQueryPaths> {
|
|
78
|
+
data: Awaited<ReturnType<SeamHttpEndpoints[T]>>
|
|
79
|
+
nextPageCursor: SeamPageCursor | null
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type QueryError<T extends SeamHttpEndpointPaginatedQueryPaths> =
|
|
83
|
+
| Error
|
|
84
|
+
| SeamHttpApiError
|
|
85
|
+
| SeamHttpInvalidInputError
|
|
86
|
+
| (QueryData<T>['data'] extends ActionAttempt
|
|
87
|
+
?
|
|
88
|
+
| SeamActionAttemptFailedError<QueryData<T>['data']>
|
|
89
|
+
| SeamActionAttemptTimeoutError<QueryData<T>['data']>
|
|
90
|
+
: never)
|
|
91
|
+
|
|
92
|
+
type QueryOptions<X, Y> = Omit<
|
|
93
|
+
UseInfiniteQueryOptions<X, Y>,
|
|
94
|
+
'queryKey' | 'queryFn' | 'initialPageParam' | 'getNextPageParam'
|
|
95
|
+
>
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
SeamHttpApiError,
|
|
3
3
|
SeamHttpEndpointsWithoutWorkspace,
|
|
4
4
|
SeamHttpEndpointWithoutWorkspaceMutationPaths,
|
|
5
|
+
SeamHttpInvalidInputError,
|
|
5
6
|
} from '@seamapi/http/connect'
|
|
6
7
|
import {
|
|
7
8
|
useMutation,
|
|
@@ -19,18 +20,18 @@ export type UseSeamMutationWithoutWorkspaceResult<
|
|
|
19
20
|
T extends SeamHttpEndpointWithoutWorkspaceMutationPaths,
|
|
20
21
|
> = UseMutationResult<
|
|
21
22
|
MutationData<T>,
|
|
22
|
-
|
|
23
|
+
MutationError,
|
|
23
24
|
UseSeamMutationWithoutWorkspaceVariables<T>
|
|
24
25
|
>
|
|
25
26
|
|
|
26
|
-
export function
|
|
27
|
+
export function useSeamMutationWithoutWorkspace<
|
|
27
28
|
T extends SeamHttpEndpointWithoutWorkspaceMutationPaths,
|
|
28
29
|
>(
|
|
29
30
|
endpointPath: T,
|
|
30
31
|
options: Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[1] &
|
|
31
32
|
MutationOptions<
|
|
32
33
|
MutationData<T>,
|
|
33
|
-
|
|
34
|
+
MutationError,
|
|
34
35
|
UseSeamMutationWithoutWorkspaceVariables<T>
|
|
35
36
|
> = {}
|
|
36
37
|
): UseSeamMutationWithoutWorkspaceResult<T> {
|
|
@@ -50,4 +51,6 @@ export function UseSeamMutationWithoutWorkspace<
|
|
|
50
51
|
type MutationData<T extends SeamHttpEndpointWithoutWorkspaceMutationPaths> =
|
|
51
52
|
Awaited<ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>>
|
|
52
53
|
|
|
54
|
+
type MutationError = Error | SeamHttpApiError | SeamHttpInvalidInputError
|
|
55
|
+
|
|
53
56
|
type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
SeamActionAttemptFailedError,
|
|
3
|
+
SeamActionAttemptTimeoutError,
|
|
2
4
|
SeamHttpApiError,
|
|
3
5
|
SeamHttpEndpointMutationPaths,
|
|
4
6
|
SeamHttpEndpoints,
|
|
7
|
+
SeamHttpInvalidInputError,
|
|
5
8
|
} from '@seamapi/http/connect'
|
|
9
|
+
import type { ActionAttempt } from '@seamapi/types/connect'
|
|
6
10
|
import {
|
|
7
11
|
useMutation,
|
|
8
12
|
type UseMutationOptions,
|
|
@@ -17,7 +21,7 @@ export type UseSeamMutationVariables<T extends SeamHttpEndpointMutationPaths> =
|
|
|
17
21
|
export type UseSeamMutationResult<T extends SeamHttpEndpointMutationPaths> =
|
|
18
22
|
UseMutationResult<
|
|
19
23
|
MutationData<T>,
|
|
20
|
-
|
|
24
|
+
MutationError<T>,
|
|
21
25
|
UseSeamMutationVariables<T>
|
|
22
26
|
>
|
|
23
27
|
|
|
@@ -26,7 +30,7 @@ export function useSeamMutation<T extends SeamHttpEndpointMutationPaths>(
|
|
|
26
30
|
options: Parameters<SeamHttpEndpoints[T]>[1] &
|
|
27
31
|
MutationOptions<
|
|
28
32
|
MutationData<T>,
|
|
29
|
-
|
|
33
|
+
MutationError<T>,
|
|
30
34
|
UseSeamMutationVariables<T>
|
|
31
35
|
> = {}
|
|
32
36
|
): UseSeamMutationResult<T> {
|
|
@@ -47,4 +51,14 @@ type MutationData<T extends SeamHttpEndpointMutationPaths> = Awaited<
|
|
|
47
51
|
ReturnType<SeamHttpEndpoints[T]>
|
|
48
52
|
>
|
|
49
53
|
|
|
54
|
+
type MutationError<T extends SeamHttpEndpointMutationPaths> =
|
|
55
|
+
| Error
|
|
56
|
+
| SeamHttpApiError
|
|
57
|
+
| SeamHttpInvalidInputError
|
|
58
|
+
| (MutationData<T> extends ActionAttempt
|
|
59
|
+
?
|
|
60
|
+
| SeamActionAttemptFailedError<MutationData<T>>
|
|
61
|
+
| SeamActionAttemptTimeoutError<MutationData<T>>
|
|
62
|
+
: never)
|
|
63
|
+
|
|
50
64
|
type MutationOptions<X, Y, Z> = Omit<UseMutationOptions<X, Y, Z>, 'mutationFn'>
|
|
@@ -2,6 +2,7 @@ import type {
|
|
|
2
2
|
SeamHttpApiError,
|
|
3
3
|
SeamHttpEndpointsWithoutWorkspace,
|
|
4
4
|
SeamHttpEndpointWithoutWorkspaceQueryPaths,
|
|
5
|
+
SeamHttpInvalidInputError,
|
|
5
6
|
} from '@seamapi/http/connect'
|
|
6
7
|
import {
|
|
7
8
|
useQuery,
|
|
@@ -17,7 +18,7 @@ export type UseSeamQueryWithoutWorkspaceParameters<
|
|
|
17
18
|
|
|
18
19
|
export type UseSeamQueryWithoutWorkspaceResult<
|
|
19
20
|
T extends SeamHttpEndpointWithoutWorkspaceQueryPaths,
|
|
20
|
-
> = UseQueryResult<QueryData<T>,
|
|
21
|
+
> = UseQueryResult<QueryData<T>, QueryError>
|
|
21
22
|
|
|
22
23
|
export function useSeamQueryWithoutWorkspace<
|
|
23
24
|
T extends SeamHttpEndpointWithoutWorkspaceQueryPaths,
|
|
@@ -25,7 +26,7 @@ export function useSeamQueryWithoutWorkspace<
|
|
|
25
26
|
endpointPath: T,
|
|
26
27
|
parameters?: UseSeamQueryWithoutWorkspaceParameters<T>,
|
|
27
28
|
options: Parameters<SeamHttpEndpointsWithoutWorkspace[T]>[1] &
|
|
28
|
-
QueryOptions<QueryData<T>,
|
|
29
|
+
QueryOptions<QueryData<T>, QueryError> = {}
|
|
29
30
|
): UseSeamQueryWithoutWorkspaceResult<T> {
|
|
30
31
|
const { endpointClient: client, queryKeyPrefixes } = useSeamClient()
|
|
31
32
|
return useQuery({
|
|
@@ -50,4 +51,6 @@ type QueryData<T extends SeamHttpEndpointWithoutWorkspaceQueryPaths> = Awaited<
|
|
|
50
51
|
ReturnType<SeamHttpEndpointsWithoutWorkspace[T]>
|
|
51
52
|
>
|
|
52
53
|
|
|
54
|
+
type QueryError = Error | SeamHttpApiError | SeamHttpInvalidInputError
|
|
55
|
+
|
|
53
56
|
type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
SeamActionAttemptFailedError,
|
|
3
|
+
SeamActionAttemptTimeoutError,
|
|
2
4
|
SeamHttpApiError,
|
|
3
5
|
SeamHttpEndpointQueryPaths,
|
|
4
6
|
SeamHttpEndpoints,
|
|
7
|
+
SeamHttpInvalidInputError,
|
|
5
8
|
} from '@seamapi/http/connect'
|
|
9
|
+
import type { ActionAttempt } from '@seamapi/types/connect'
|
|
6
10
|
import {
|
|
7
11
|
useQuery,
|
|
8
12
|
type UseQueryOptions,
|
|
@@ -15,7 +19,7 @@ export type UseSeamQueryParameters<T extends SeamHttpEndpointQueryPaths> =
|
|
|
15
19
|
Parameters<SeamHttpEndpoints[T]>[0]
|
|
16
20
|
|
|
17
21
|
export type UseSeamQueryResult<T extends SeamHttpEndpointQueryPaths> =
|
|
18
|
-
UseQueryResult<QueryData<T>,
|
|
22
|
+
UseQueryResult<QueryData<T>, QueryError<T>>
|
|
19
23
|
|
|
20
24
|
export function useSeamQuery<T extends SeamHttpEndpointQueryPaths>(
|
|
21
25
|
endpointPath: T,
|
|
@@ -46,4 +50,14 @@ type QueryData<T extends SeamHttpEndpointQueryPaths> = Awaited<
|
|
|
46
50
|
ReturnType<SeamHttpEndpoints[T]>
|
|
47
51
|
>
|
|
48
52
|
|
|
53
|
+
type QueryError<T extends SeamHttpEndpointQueryPaths> =
|
|
54
|
+
| Error
|
|
55
|
+
| SeamHttpApiError
|
|
56
|
+
| SeamHttpInvalidInputError
|
|
57
|
+
| (QueryData<T> extends ActionAttempt
|
|
58
|
+
?
|
|
59
|
+
| SeamActionAttemptFailedError<QueryData<T>>
|
|
60
|
+
| SeamActionAttemptTimeoutError<QueryData<T>>
|
|
61
|
+
: never)
|
|
62
|
+
|
|
49
63
|
type QueryOptions<X, Y> = Omit<UseQueryOptions<X, Y>, 'queryKey' | 'queryFn'>
|
package/src/lib/version.ts
CHANGED