@openapi-qraft/react 1.7.0 → 1.8.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/CHANGELOG.md +6 -0
- package/dist/QraftContext.d.ts +1 -1
- package/dist/ServiceOperation.d.ts +1 -1
- package/dist/ServiceOperation.d.ts.map +1 -1
- package/dist/callbacks/mutationFn.js +2 -2
- package/dist/callbacks/mutationFn.js.map +1 -1
- package/dist/callbacks/operationInvokeFn.d.ts +9 -0
- package/dist/callbacks/operationInvokeFn.d.ts.map +1 -0
- package/dist/callbacks/operationInvokeFn.js +21 -0
- package/dist/callbacks/operationInvokeFn.js.map +1 -0
- package/dist/callbacks/queryFn.d.ts.map +1 -1
- package/dist/callbacks/queryFn.js +4 -2
- package/dist/callbacks/queryFn.js.map +1 -1
- package/dist/callbacks/useInfiniteQuery.js +1 -1
- package/dist/callbacks/useInfiniteQuery.js.map +1 -1
- package/dist/callbacks/useQueries.js +1 -1
- package/dist/callbacks/useQueries.js.map +1 -1
- package/dist/callbacks/useQuery.js +1 -1
- package/dist/callbacks/useQuery.js.map +1 -1
- package/dist/callbacks/useSuspenseInfiniteQuery.js +1 -1
- package/dist/callbacks/useSuspenseInfiniteQuery.js.map +1 -1
- package/dist/callbacks/useSuspenseQueries.js +1 -1
- package/dist/callbacks/useSuspenseQueries.js.map +1 -1
- package/dist/callbacks/useSuspenseQuery.js +1 -1
- package/dist/callbacks/useSuspenseQuery.js.map +1 -1
- package/dist/lib/callQueryClientFetchMethod.js +3 -3
- package/dist/lib/callQueryClientFetchMethod.js.map +1 -1
- package/dist/lib/callQueryClientMethodWithMutationFilters.js +2 -2
- package/dist/lib/callQueryClientMethodWithMutationFilters.js.map +1 -1
- package/dist/lib/callQueryClientMethodWithQueryFilters.js +2 -2
- package/dist/lib/callQueryClientMethodWithQueryFilters.js.map +1 -1
- package/dist/lib/callQueryClientMethodWithQueryKey.js +1 -1
- package/dist/lib/callQueryClientMethodWithQueryKey.js.map +1 -1
- package/dist/lib/composeMutationKey.d.ts +1 -1
- package/dist/lib/composeMutationKey.d.ts.map +1 -1
- package/dist/lib/composeMutationKey.js +1 -1
- package/dist/lib/composeMutationKey.js.map +1 -1
- package/dist/lib/createRecursiveProxy.d.ts +6 -0
- package/dist/lib/createRecursiveProxy.d.ts.map +1 -1
- package/dist/lib/createRecursiveProxy.js +7 -0
- package/dist/lib/createRecursiveProxy.js.map +1 -1
- package/dist/lib/requestFn.d.ts +26 -3
- package/dist/lib/requestFn.d.ts.map +1 -1
- package/dist/lib/requestFn.js +27 -3
- package/dist/lib/requestFn.js.map +1 -1
- package/dist/lib/useComposeUseQueryOptions.js +2 -2
- package/dist/lib/useComposeUseQueryOptions.js.map +1 -1
- package/dist/lib/useQueryClient.d.ts.map +1 -1
- package/dist/lib/useQueryClient.js +1 -2
- package/dist/lib/useQueryClient.js.map +1 -1
- package/dist/qraftAPIClient.d.ts +4 -16
- package/dist/qraftAPIClient.d.ts.map +1 -1
- package/dist/qraftAPIClient.js +28 -9
- package/dist/qraftAPIClient.js.map +1 -1
- package/dist/service-operation/ServiceOperationKey.d.ts +1 -1
- package/dist/service-operation/ServiceOperationKey.d.ts.map +1 -1
- package/dist/service-operation/ServiceOperationMutationFn.d.ts +27 -0
- package/dist/service-operation/ServiceOperationMutationFn.d.ts.map +1 -1
- package/dist/service-operation/ServiceOperationQueryFn.d.ts +47 -0
- package/dist/service-operation/ServiceOperationQueryFn.d.ts.map +1 -1
- package/package.json +9 -4
- package/src/QraftContext.ts +1 -1
- package/src/ServiceOperation.ts +1 -1
- package/src/callbacks/mutationFn.ts +2 -2
- package/src/callbacks/operationInvokeFn.ts +45 -0
- package/src/callbacks/queryFn.ts +11 -6
- package/src/callbacks/useInfiniteQuery.ts +1 -1
- package/src/callbacks/useQueries.ts +1 -1
- package/src/callbacks/useQuery.ts +1 -1
- package/src/callbacks/useSuspenseInfiniteQuery.ts +1 -1
- package/src/callbacks/useSuspenseQueries.ts +1 -1
- package/src/callbacks/useSuspenseQuery.ts +1 -1
- package/src/lib/callQueryClientFetchMethod.ts +3 -3
- package/src/lib/callQueryClientMethodWithMutationFilters.ts +2 -2
- package/src/lib/callQueryClientMethodWithQueryFilters.ts +2 -2
- package/src/lib/callQueryClientMethodWithQueryKey.ts +1 -1
- package/src/lib/composeMutationKey.ts +6 -8
- package/src/lib/createRecursiveProxy.ts +7 -0
- package/src/lib/requestFn.ts +31 -5
- package/src/lib/useComposeUseQueryOptions.ts +2 -2
- package/src/lib/useQueryClient.ts +3 -2
- package/src/qraftAPIClient.ts +39 -39
- package/src/service-operation/ServiceOperationKey.ts +1 -1
- package/src/service-operation/ServiceOperationMutationFn.ts +58 -0
- package/src/service-operation/ServiceOperationQueryFn.ts +110 -0
|
@@ -8,8 +8,7 @@ import { QraftContext } from '../QraftContext.js';
|
|
|
8
8
|
* @param queryClient If not provided, will be taken this instance
|
|
9
9
|
*/
|
|
10
10
|
export function useQueryClient(qraftOptions, queryClient) {
|
|
11
|
-
const queryClientByContext = useContext(qraftOptions?.context ?? QraftContext)
|
|
12
|
-
?.queryClient;
|
|
11
|
+
const queryClientByContext = useContext(qraftOptions?.context ?? QraftContext)?.queryClient;
|
|
13
12
|
return useQueryClientTanstack(queryClient ?? queryClientByContext);
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=useQueryClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQueryClient.js","sourceRoot":"","sources":["../../src/lib/useQueryClient.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAEL,cAAc,IAAI,sBAAsB,GACzC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,YAA4C,EAC5C,WAAoC;IAEpC,MAAM,oBAAoB,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"useQueryClient.js","sourceRoot":"","sources":["../../src/lib/useQueryClient.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAEnC,OAAO,EAEL,cAAc,IAAI,sBAAsB,GACzC,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,YAA4C,EAC5C,WAAoC;IAEpC,MAAM,oBAAoB,GAAG,UAAU,CACrC,YAAY,EAAE,OAAO,IAAI,YAAY,CACtC,EAAE,WAAW,CAAC;IAEf,OAAO,sBAAsB,CAAC,WAAW,IAAI,oBAAoB,CAAC,CAAC;AACrE,CAAC"}
|
package/dist/qraftAPIClient.d.ts
CHANGED
|
@@ -4,33 +4,21 @@ import type { QraftContextValue } from './QraftContext.js';
|
|
|
4
4
|
export interface QraftClientOptions {
|
|
5
5
|
context?: Context<QraftContextValue>;
|
|
6
6
|
}
|
|
7
|
-
export declare const qraftAPIClient: <Services extends
|
|
8
|
-
type
|
|
7
|
+
export declare const qraftAPIClient: <Services extends ServicesBaseDeclaration<Services>, Callbacks extends ServicesCallbacks>(services: ServicesDeclaration<Services>, callbacks: Callbacks, options?: QraftClientOptions) => Services;
|
|
8
|
+
type ServicesBaseDeclaration<Services> = {
|
|
9
9
|
[service in keyof Services]: {
|
|
10
10
|
[method in keyof Services[service]]: {
|
|
11
11
|
schema: OperationSchema;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
type ServicesDeclaration<Services extends
|
|
15
|
+
type ServicesDeclaration<Services extends ServicesBaseDeclaration<Services>> = {
|
|
16
16
|
[service in keyof Services]: {
|
|
17
17
|
[method in keyof Services[service]]: {
|
|
18
18
|
schema: Services[service][method]['schema'];
|
|
19
19
|
};
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
type ServicesCallbacks = Record<string, (...rest: any[]) =>
|
|
23
|
-
type ServicesCallbacksFilter<Services extends ServicesOutput<Services>, Callbacks> = Services extends {
|
|
24
|
-
[serviceName in keyof Services]: {
|
|
25
|
-
[method in keyof Services[serviceName]]: {
|
|
26
|
-
schema: OperationSchema;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
} ? {
|
|
30
|
-
[serviceName in keyof Services]: {
|
|
31
|
-
[method in keyof Services[serviceName]]: Pick<Services[serviceName][method], FilterKeys<keyof Services[serviceName][method], Callbacks | 'schema' | 'types'>>;
|
|
32
|
-
};
|
|
33
|
-
} : never;
|
|
34
|
-
type FilterKeys<T, K> = K extends T ? K : never;
|
|
22
|
+
type ServicesCallbacks = Record<string, (...rest: any[]) => unknown>;
|
|
35
23
|
export {};
|
|
36
24
|
//# sourceMappingURL=qraftAPIClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qraftAPIClient.d.ts","sourceRoot":"","sources":["../src/qraftAPIClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"qraftAPIClient.d.ts","sourceRoot":"","sources":["../src/qraftAPIClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAIrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED,eAAO,MAAM,cAAc,qKAMf,kBAAkB,aA8B7B,CAAC;AAuCF,KAAK,uBAAuB,CAAC,QAAQ,IAAI;KACtC,OAAO,IAAI,MAAM,QAAQ,GAAG;SAC1B,MAAM,IAAI,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG;YAAE,MAAM,EAAE,eAAe,CAAA;SAAE;KACjE;CACF,CAAC;AAEF,KAAK,mBAAmB,CAAC,QAAQ,SAAS,uBAAuB,CAAC,QAAQ,CAAC,IAAI;KAC5E,OAAO,IAAI,MAAM,QAAQ,GAAG;SAC1B,MAAM,IAAI,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG;YACnC,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC;SAC7C;KACF;CACF,CAAC;AAEF,KAAK,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,CAAC"}
|
package/dist/qraftAPIClient.js
CHANGED
|
@@ -1,24 +1,43 @@
|
|
|
1
1
|
import { createRecursiveProxy } from './lib/createRecursiveProxy.js';
|
|
2
2
|
export const qraftAPIClient = (services, callbacks, options) => {
|
|
3
|
-
return createRecursiveProxy((getPath, key)
|
|
3
|
+
return createRecursiveProxy(function getCallback(getPath, key) {
|
|
4
4
|
if (getPath.length !== 2 || key !== 'schema')
|
|
5
|
-
return;
|
|
5
|
+
return; // todo::maybe return callback?
|
|
6
6
|
const serviceOperation = getByPath(services, getPath);
|
|
7
7
|
if (!isServiceOperation(serviceOperation))
|
|
8
8
|
throw new Error(`Service operation not found: ${getPath.join('.')}`);
|
|
9
9
|
return serviceOperation.schema;
|
|
10
|
-
}, (applyPath, args)
|
|
11
|
-
const path = applyPath
|
|
10
|
+
}, function applyCallback(applyPath, args) {
|
|
11
|
+
const { path, callbackName } = extractCallbackDetails(applyPath);
|
|
12
|
+
if (!(callbackName in callbacks))
|
|
13
|
+
throw new Error(`Function ${callbackName} is not supported`);
|
|
12
14
|
const serviceOperation = getByPath(services, path);
|
|
13
15
|
if (!isServiceOperation(serviceOperation))
|
|
14
16
|
throw new Error(`Service operation not found: ${path.join('.')}`);
|
|
15
|
-
|
|
16
|
-
const functionName = applyPath[applyPath.length - 1];
|
|
17
|
-
if (!(functionName in callbacks))
|
|
18
|
-
throw new Error(`Function ${functionName} is not supported`);
|
|
19
|
-
return callbacks[functionName](options, serviceOperation.schema, args);
|
|
17
|
+
return callbacks[callbackName](options, serviceOperation.schema, args);
|
|
20
18
|
}, []);
|
|
21
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Extracts Callback details from the applyPath
|
|
22
|
+
* @param applyPath
|
|
23
|
+
*/
|
|
24
|
+
function extractCallbackDetails(applyPath) {
|
|
25
|
+
// <service>.<operation>()
|
|
26
|
+
if (applyPath.length === 2) {
|
|
27
|
+
return {
|
|
28
|
+
path: applyPath,
|
|
29
|
+
callbackName: 'operationInvokeFn',
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// <service>.<operation>.<method>()
|
|
34
|
+
return {
|
|
35
|
+
path: applyPath.slice(0, -1),
|
|
36
|
+
// The last arg is for instance `.useMutation` or `.useQuery()`
|
|
37
|
+
callbackName: applyPath[applyPath.length - 1],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
22
41
|
function isServiceOperation(input) {
|
|
23
42
|
return input !== null && typeof input === 'object' && 'schema' in input;
|
|
24
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qraftAPIClient.js","sourceRoot":"","sources":["../src/qraftAPIClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"qraftAPIClient.js","sourceRoot":"","sources":["../src/qraftAPIClient.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAQrE,MAAM,CAAC,MAAM,cAAc,GAAG,CAI5B,QAAuC,EACvC,SAAoB,EACpB,OAA4B,EAClB,EAAE;IACZ,OAAO,oBAAoB,CACzB,SAAS,WAAW,CAAC,OAAO,EAAE,GAAG;QAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI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D,YAAY,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;SAC9C,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CACzB,KAAc;IAEd,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,CAAC;AAC1E,CAAC;AAED,SAAS,SAAS,CAAC,GAA4B,EAAE,IAAc;IAC7D,OAAO,IAAI,CAAC,MAAM,CAAU,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QACvC,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG;YAC9C,OAAO,GAAG,CAAC,GAAuB,CAAC,CAAC;IACxC,CAAC,EAAE,GAAG,CAAC,CAAC;AACV,CAAC"}
|
|
@@ -12,5 +12,5 @@ export type ServiceOperationInfiniteQueryKey<S extends {
|
|
|
12
12
|
url: string;
|
|
13
13
|
method: string;
|
|
14
14
|
}, T> = ServiceOperationBaseQueryKey<S, true, T>;
|
|
15
|
-
export type ServiceOperationMutationKey<S extends Record<'url' | 'method', string>, T
|
|
15
|
+
export type ServiceOperationMutationKey<S extends Record<'url' | 'method', string>, T> = NonNullable<T> extends never ? [S] : [S, T];
|
|
16
16
|
//# sourceMappingURL=ServiceOperationKey.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOperationKey.d.ts","sourceRoot":"","sources":["../../src/service-operation/ServiceOperationKey.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,4BAA4B,CACtC,CAAC,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACzC,QAAQ,SAAS,OAAO,EACxB,CAAC,IACC,CAAC,CAAC,GAAG;IAAE,QAAQ,EAAE,QAAQ,CAAA;CAAE,EAAE,CAAC,CAAC,CAAC;AAEpC,MAAM,MAAM,wBAAwB,CAClC,CAAC,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M,CAAC,EAC1C,CAAC,IACC,WAAW,CAAC,CAAC,CAAC,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
interface QueryFnBaseUrlOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Base URL to use for the request
|
|
4
|
+
* @example 'https://api.example.com'
|
|
5
|
+
*/
|
|
6
|
+
baseUrl: string;
|
|
7
|
+
}
|
|
8
|
+
interface ServiceOperationMutationFnOptionsBase<TBody, TParams> {
|
|
9
|
+
parameters: TParams;
|
|
10
|
+
body: TBody;
|
|
11
|
+
}
|
|
12
|
+
interface ServiceOperationMutationFnOptions<TBody, TParams> extends ServiceOperationMutationFnOptionsBase<TBody, TParams> {
|
|
13
|
+
baseUrl?: never;
|
|
14
|
+
}
|
|
15
|
+
interface ServiceOperationMutationFnOptionsWithBaseUrl<TBody, TParams> extends ServiceOperationMutationFnOptionsBase<TBody, TParams>, QueryFnBaseUrlOptions {
|
|
16
|
+
}
|
|
1
17
|
export interface ServiceOperationMutationFn<TSchema extends {
|
|
2
18
|
url: string;
|
|
3
19
|
method: string;
|
|
4
20
|
}, TBody, TData, TParams> {
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Use `<service>.<operation>(...)` instead.
|
|
23
|
+
*/
|
|
5
24
|
mutationFn(client: (schema: TSchema, options: {
|
|
6
25
|
parameters: TParams;
|
|
7
26
|
body: TBody;
|
|
@@ -9,6 +28,9 @@ export interface ServiceOperationMutationFn<TSchema extends {
|
|
|
9
28
|
parameters: TParams;
|
|
10
29
|
body: TBody;
|
|
11
30
|
}): TData;
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use `<service>.<operation>(...)` instead.
|
|
33
|
+
*/
|
|
12
34
|
mutationFn(client: (schema: TSchema, options: {
|
|
13
35
|
parameters: TParams;
|
|
14
36
|
body: TBody;
|
|
@@ -16,5 +38,10 @@ export interface ServiceOperationMutationFn<TSchema extends {
|
|
|
16
38
|
parameters: TParams;
|
|
17
39
|
body: TBody;
|
|
18
40
|
}): Promise<TData>;
|
|
41
|
+
<TOptions extends ServiceOperationMutationFnOptions<TBody, TParams>>(options: TOptions, client: (schema: TSchema, options: TOptions) => TData): TData;
|
|
42
|
+
<TOptions extends ServiceOperationMutationFnOptionsWithBaseUrl<TBody, TParams>>(options: TOptions, client: (schema: TSchema, options: TOptions) => TData): TData;
|
|
43
|
+
<TOptions extends ServiceOperationMutationFnOptions<TBody, TParams>>(options: TOptions, client: (schema: TSchema, options: TOptions) => Promise<TData>): Promise<TData>;
|
|
44
|
+
<TOptions extends ServiceOperationMutationFnOptionsWithBaseUrl<TBody, TParams>>(options: TOptions, client: (schema: TSchema, options: TOptions) => Promise<TData>): Promise<TData>;
|
|
19
45
|
}
|
|
46
|
+
export {};
|
|
20
47
|
//# sourceMappingURL=ServiceOperationMutationFn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOperationMutationFn.d.ts","sourceRoot":"","sources":["../../src/service-operation/ServiceOperationMutationFn.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,0BAA0B,CACzC,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,KAAK,EACL,KAAK,EACL,OAAO;IAEP,UAAU,CACR,MAAM,EAAE,CACN,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,KACE,KAAK,EACV,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,GACA,KAAK,CAAC;IAET,UAAU,CACR,MAAM,EAAE,CACN,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,KACE,OAAO,CAAC,KAAK,CAAC,EACnB,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,GACA,OAAO,CAAC,KAAK,CAAC,CAAC;CACnB"}
|
|
1
|
+
{"version":3,"file":"ServiceOperationMutationFn.d.ts","sourceRoot":"","sources":["../../src/service-operation/ServiceOperationMutationFn.ts"],"names":[],"mappings":"AAAA,UAAU,qBAAqB;IAC7B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,qCAAqC,CAAC,KAAK,EAAE,OAAO;IAC5D,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC;CACb;AAED,UAAU,iCAAiC,CAAC,KAAK,EAAE,OAAO,CACxD,SAAQ,qCAAqC,CAAC,KAAK,EAAE,OAAO,CAAC;IAC7D,OAAO,CAAC,EAAE,KAAK,CAAC;CACjB;AAED,UAAU,4CAA4C,CAAC,KAAK,EAAE,OAAO,CACnE,SAAQ,qCAAqC,CAAC,KAAK,EAAE,OAAO,CAAC,EAC3D,qBAAqB;CAAG;AAE5B,MAAM,WAAW,0BAA0B,CACzC,OAAO,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAC/C,KAAK,EACL,KAAK,EACL,OAAO;IAEP;;OAEG;IACH,UAAU,CACR,MAAM,EAAE,CACN,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,KACE,KAAK,EACV,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,GACA,KAAK,CAAC;IAET;;OAEG;IACH,UAAU,CACR,MAAM,EAAE,CACN,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,KACE,OAAO,CAAC,KAAK,CAAC,EACnB,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,IAAI,EAAE,KAAK,CAAC;KACb,GACA,OAAO,CAAC,KAAK,CAAC,CAAC;IAElB,CAAC,QAAQ,SAAS,iCAAiC,CAAC,KAAK,EAAE,OAAO,CAAC,EACjE,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,KAAK,KAAK,GACpD,KAAK,CAAC;IAET,CACE,QAAQ,SAAS,4CAA4C,CAC3D,KAAK,EACL,OAAO,CACR,EAED,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,KAAK,KAAK,GACpD,KAAK,CAAC;IAET,CAAC,QAAQ,SAAS,iCAAiC,CAAC,KAAK,EAAE,OAAO,CAAC,EACjE,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,KAAK,CAAC,GAC7D,OAAO,CAAC,KAAK,CAAC,CAAC;IAElB,CACE,QAAQ,SAAS,4CAA4C,CAC3D,KAAK,EACL,OAAO,CACR,EAED,OAAO,EAAE,QAAQ,EACjB,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC,KAAK,CAAC,GAC7D,OAAO,CAAC,KAAK,CAAC,CAAC;CACnB"}
|
|
@@ -6,27 +6,74 @@ interface QueryFnOptionsBase<TMeta extends Record<string, any>, TSignal extends
|
|
|
6
6
|
interface QueryFnOptionsByParameters<TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends QueryFnOptionsBase<TMeta, TSignal> {
|
|
7
7
|
parameters: TParams;
|
|
8
8
|
queryKey?: never;
|
|
9
|
+
baseUrl?: never;
|
|
10
|
+
}
|
|
11
|
+
interface QueryFnOptionsByParametersWithBaseUrl<TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends QueryFnOptionsBase<TMeta, TSignal>, QueryFnBaseUrlOptions {
|
|
12
|
+
parameters: TParams;
|
|
13
|
+
queryKey?: never;
|
|
9
14
|
}
|
|
10
15
|
interface QueryFnOptionsByQueryKey<TSchema extends {
|
|
11
16
|
url: string;
|
|
12
17
|
method: string;
|
|
13
18
|
}, TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends QueryFnOptionsBase<TMeta, TSignal> {
|
|
14
19
|
queryKey: ServiceOperationQueryKey<TSchema, TParams>;
|
|
20
|
+
parameters?: never;
|
|
21
|
+
baseUrl?: never;
|
|
22
|
+
}
|
|
23
|
+
interface QueryFnOptionsByQueryKeyWithBaseUrl<TSchema extends {
|
|
24
|
+
url: string;
|
|
25
|
+
method: string;
|
|
26
|
+
}, TParams, TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal> extends QueryFnOptionsBase<TMeta, TSignal>, QueryFnBaseUrlOptions {
|
|
27
|
+
queryKey: ServiceOperationQueryKey<TSchema, TParams>;
|
|
28
|
+
parameters?: never;
|
|
29
|
+
}
|
|
30
|
+
interface QueryFnBaseUrlOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Base URL to use for the request
|
|
33
|
+
* @example 'https://api.example.com'
|
|
34
|
+
*/
|
|
35
|
+
baseUrl: string;
|
|
15
36
|
}
|
|
16
37
|
export interface ServiceOperationQueryFn<TSchema extends {
|
|
17
38
|
url: string;
|
|
18
39
|
method: string;
|
|
19
40
|
}, TData, TParams> {
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Use `<service>.<operation>(...)` instead.
|
|
43
|
+
*/
|
|
20
44
|
queryFn<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByParameters<TParams, TMeta, TSignal> | QueryFnOptionsByQueryKey<TSchema, TParams, TMeta, TSignal>, client: (schema: TSchema, options: {
|
|
21
45
|
parameters: TParams;
|
|
22
46
|
signal?: TSignal;
|
|
23
47
|
meta?: TMeta;
|
|
24
48
|
}) => TData): TData;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `<service>.<operation>(...)` instead.
|
|
51
|
+
*/
|
|
25
52
|
queryFn<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByParameters<TParams, TMeta, TSignal> | QueryFnOptionsByQueryKey<TSchema, TParams, TMeta, TSignal>, client: (schema: TSchema, options: {
|
|
26
53
|
parameters: TParams;
|
|
27
54
|
signal?: TSignal;
|
|
28
55
|
meta?: TMeta;
|
|
29
56
|
}) => Promise<TData>): Promise<TData>;
|
|
57
|
+
<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByParameters<TParams, TMeta, TSignal> | QueryFnOptionsByQueryKey<TSchema, TParams, TMeta, TSignal>, client: (schema: TSchema, options: {
|
|
58
|
+
parameters: TParams;
|
|
59
|
+
signal?: TSignal;
|
|
60
|
+
meta?: TMeta;
|
|
61
|
+
}) => TData): TData;
|
|
62
|
+
<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByParametersWithBaseUrl<TParams, TMeta, TSignal> | QueryFnOptionsByQueryKeyWithBaseUrl<TSchema, TParams, TMeta, TSignal>, client: (schema: TSchema, options: {
|
|
63
|
+
parameters: TParams;
|
|
64
|
+
signal?: TSignal;
|
|
65
|
+
meta?: TMeta;
|
|
66
|
+
} & QueryFnBaseUrlOptions) => TData): TData;
|
|
67
|
+
<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByParameters<TParams, TMeta, TSignal> | QueryFnOptionsByQueryKey<TSchema, TParams, TMeta, TSignal>, client: (schema: TSchema, options: {
|
|
68
|
+
parameters: TParams;
|
|
69
|
+
signal?: TSignal;
|
|
70
|
+
meta?: TMeta;
|
|
71
|
+
}) => Promise<TData>): Promise<TData>;
|
|
72
|
+
<TMeta extends Record<string, any>, TSignal extends AbortSignal = AbortSignal>(options: QueryFnOptionsByParametersWithBaseUrl<TParams, TMeta, TSignal> | QueryFnOptionsByQueryKeyWithBaseUrl<TSchema, TParams, TMeta, TSignal>, client: (schema: TSchema, options: {
|
|
73
|
+
parameters: TParams;
|
|
74
|
+
signal?: TSignal;
|
|
75
|
+
meta?: TMeta;
|
|
76
|
+
} & QueryFnBaseUrlOptions) => Promise<TData>): Promise<TData>;
|
|
30
77
|
}
|
|
31
78
|
export {};
|
|
32
79
|
//# sourceMappingURL=ServiceOperationQueryFn.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServiceOperationQueryFn.d.ts","sourceRoot":"","sources":["../../src/service-operation/ServiceOperationQueryFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE,UAAU,kBAAkB,CAC1B,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW;IAEzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,KAAK,CAAC;CACd;AAED,UAAU,0BAA0B,CAClC,OAAO,EACP,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW,CACzC,SAAQ,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC;IAC1C,UAAU,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ServiceOperationQueryFn.d.ts","sourceRoot":"","sources":["../../src/service-operation/ServiceOperationQueryFn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEzE,UAAU,kBAAkB,CAC1B,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,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AAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,KAAK,CAAC;KACd,KACE,OAAO,CAAC,KAAK,CAAC,GAClB,OAAO,CAAC,KAAK,CAAC,CAAC;IAElB,CACE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjC,OAAO,SAAS,WAAW,GAAG,WAAW,EAEzC,OAAO,EACH,qCAAqC,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,GAC9D,mCAAmC,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,EACzE,MAAM,EAAE,CACN,MAAM,EAAE,OAAO,EACf,OAAO,EAAE;QACP,UAAU,EAAE,OAAO,CAAC;QACpB,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,KAAK,CAAC;KACd,GAAG,qBAAqB,KACtB,OAAO,CAAC,KAAK,CAAC,GAClB,OAAO,CAAC,KAAK,CAAC,CAAC;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "API client for React, providing type-safe requests and dynamic Tanstack Query React Hooks via a modular, Proxy-based architecture.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "rimraf dist/ && tsc --project tsconfig.build.json",
|
|
@@ -8,14 +8,17 @@
|
|
|
8
8
|
"test": "vitest run",
|
|
9
9
|
"test:coverage": "vitest run --coverage",
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
|
-
"
|
|
12
|
-
"generate-
|
|
11
|
+
"lint": "eslint",
|
|
12
|
+
"generate-qraft": "openapi-qraft --plugin tanstack-query-react ../test-fixtures/openapi.json --clean -o src/tests/fixtures/api --openapi-types-import-path '../../openapi.js' --explicit-import-extensions --filter-services '/approval_policies/**,/entities/**,/files/**,!/internal/**' && prettier --write src/tests/fixtures/api/**/*.ts",
|
|
13
|
+
"generate-types": "openapi-qraft-typescript ../test-fixtures/openapi.json -o src/tests/fixtures/openapi.ts"
|
|
13
14
|
},
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": false,
|
|
16
17
|
"devDependencies": {
|
|
17
|
-
"@openapi-qraft/cli": "~1.
|
|
18
|
+
"@openapi-qraft/cli": "~1.8.0",
|
|
19
|
+
"@openapi-qraft/eslint-config": "~1.0.0",
|
|
18
20
|
"@openapi-qraft/openapi-typescript": "^1.0.0",
|
|
21
|
+
"@openapi-qraft/test-fixtures": "~1.0.0",
|
|
19
22
|
"@tanstack/react-query": "^5.17.3",
|
|
20
23
|
"@testing-library/jest-dom": "^5.17.0",
|
|
21
24
|
"@testing-library/react": "^13.4.0",
|
|
@@ -23,6 +26,8 @@
|
|
|
23
26
|
"@types/react": "^18.2.47",
|
|
24
27
|
"@vitejs/plugin-react": "latest",
|
|
25
28
|
"@vitest/coverage-v8": "^1.1.3",
|
|
29
|
+
"eslint": "^9.0.0",
|
|
30
|
+
"globals": "^15.0.0",
|
|
26
31
|
"jsdom": "latest",
|
|
27
32
|
"msw": "^2.0.12",
|
|
28
33
|
"prettier": "^3.1.1",
|
package/src/QraftContext.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { OperationSchema, RequestFnPayload } from './lib/requestFn.js';
|
|
|
8
8
|
|
|
9
9
|
interface QraftContextValueBase {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Base URL to use for the request
|
|
12
12
|
* @example 'https://api.example.com'
|
|
13
13
|
*/
|
|
14
14
|
baseUrl?: string;
|
package/src/ServiceOperation.ts
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { OperationSchema } from '../lib/requestFn.js';
|
|
2
|
+
import type { QraftClientOptions } from '../qraftAPIClient.js';
|
|
3
|
+
import { ServiceOperationMutationFn } from '../service-operation/ServiceOperationMutationFn.js';
|
|
4
|
+
import { ServiceOperationQueryFn } from '../service-operation/ServiceOperationQueryFn.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Called when <service>.<operation>(...) is invoked.
|
|
8
|
+
*/
|
|
9
|
+
export const operationInvokeFn: <
|
|
10
|
+
TSchema extends OperationSchema,
|
|
11
|
+
TBody,
|
|
12
|
+
TData,
|
|
13
|
+
TParams,
|
|
14
|
+
>(
|
|
15
|
+
qraftOptions: QraftClientOptions | undefined,
|
|
16
|
+
schema: TSchema,
|
|
17
|
+
args:
|
|
18
|
+
| Parameters<ServiceOperationQueryFn<TSchema, TData, TParams>>
|
|
19
|
+
| Parameters<ServiceOperationMutationFn<TSchema, TBody, TData, TParams>>
|
|
20
|
+
) => Promise<TData> = (_, schema, args) => {
|
|
21
|
+
const queryOperationMethods = ['get', 'head', 'options'] as const; // todo::make it shared
|
|
22
|
+
|
|
23
|
+
const isQueryOperationType = queryOperationMethods.includes(
|
|
24
|
+
schema.method as (typeof queryOperationMethods)[number]
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const [options, client] = args;
|
|
28
|
+
|
|
29
|
+
const invokeSchema =
|
|
30
|
+
isQueryOperationType && 'queryKey' in options
|
|
31
|
+
? options.queryKey![0]
|
|
32
|
+
: schema;
|
|
33
|
+
|
|
34
|
+
const invokeParameters =
|
|
35
|
+
isQueryOperationType && 'queryKey' in options
|
|
36
|
+
? options.queryKey![1]
|
|
37
|
+
: 'parameters' in options
|
|
38
|
+
? options.parameters
|
|
39
|
+
: undefined;
|
|
40
|
+
|
|
41
|
+
return client(invokeSchema, {
|
|
42
|
+
...options,
|
|
43
|
+
parameters: invokeParameters,
|
|
44
|
+
} as never);
|
|
45
|
+
};
|
package/src/callbacks/queryFn.ts
CHANGED
|
@@ -12,10 +12,15 @@ export const queryFn: <
|
|
|
12
12
|
) => Promise<TData> = (_, schema, args) => {
|
|
13
13
|
const [options, client] = args;
|
|
14
14
|
|
|
15
|
-
return client(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
return client(
|
|
16
|
+
options && 'queryKey' in options ? options.queryKey![0] : schema,
|
|
17
|
+
{
|
|
18
|
+
parameters:
|
|
19
|
+
options && 'queryKey' in options
|
|
20
|
+
? options.queryKey![1]
|
|
21
|
+
: options.parameters,
|
|
22
|
+
meta: options.meta,
|
|
23
|
+
signal: options.signal,
|
|
24
|
+
}
|
|
25
|
+
) as Promise<never>;
|
|
21
26
|
};
|
|
@@ -23,7 +23,7 @@ export const useInfiniteQuery: <
|
|
|
23
23
|
>
|
|
24
24
|
) => UseInfiniteQueryResult<TData, TError> = (qraftOptions, schema, args) => {
|
|
25
25
|
return useInfiniteQueryBase(
|
|
26
|
-
// @ts-expect-error
|
|
26
|
+
// @ts-expect-error - Too complex to type...
|
|
27
27
|
...useComposeUseQueryOptions(qraftOptions, schema, args, true)
|
|
28
28
|
) as never;
|
|
29
29
|
};
|
|
@@ -19,7 +19,7 @@ export const useQuery: <TData = unknown, TError = DefaultError>(
|
|
|
19
19
|
>
|
|
20
20
|
) => UseQueryResult<TData, TError> = (qraftOptions, schema, args) => {
|
|
21
21
|
return useQueryTanstack(
|
|
22
|
-
// @ts-expect-error
|
|
22
|
+
// @ts-expect-error - Too complex to type
|
|
23
23
|
...useComposeUseQueryOptions(qraftOptions, schema, args, false)
|
|
24
24
|
) as never;
|
|
25
25
|
};
|
|
@@ -23,7 +23,7 @@ export const useSuspenseQuery: <
|
|
|
23
23
|
>
|
|
24
24
|
) => UseQueryResult<TData, TError> = (qraftOptions, schema, args) => {
|
|
25
25
|
return useSuspenseQueryTanstack(
|
|
26
|
-
// @ts-expect-error
|
|
26
|
+
// @ts-expect-error - Too complex to type
|
|
27
27
|
...useComposeUseQueryOptions(qraftOptions, schema, args, false)
|
|
28
28
|
) as never;
|
|
29
29
|
};
|
|
@@ -40,7 +40,7 @@ export function callQueryClientMethodWithQueryKey<
|
|
|
40
40
|
const queryFn =
|
|
41
41
|
options.queryFn ??
|
|
42
42
|
(requestFn
|
|
43
|
-
? // @ts-expect-error
|
|
43
|
+
? // @ts-expect-error - Not inferring the correct type for `queryFn`
|
|
44
44
|
function ({ queryKey: [, queryParams], signal, meta, pageParam }) {
|
|
45
45
|
return requestFn(schema, {
|
|
46
46
|
parameters: infinite
|
|
@@ -54,7 +54,7 @@ export function callQueryClientMethodWithQueryKey<
|
|
|
54
54
|
: undefined);
|
|
55
55
|
|
|
56
56
|
if (parameters) {
|
|
57
|
-
// @ts-expect-error
|
|
57
|
+
// @ts-expect-error - Too complex union to type
|
|
58
58
|
return queryClient[queryFilterMethod]({
|
|
59
59
|
...options,
|
|
60
60
|
// Event if queryFn is undefined, it will override the default queryFn from `setQueryDefaults(...)`
|
|
@@ -65,7 +65,7 @@ export function callQueryClientMethodWithQueryKey<
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// @ts-expect-error
|
|
68
|
+
// @ts-expect-error - Too complex union to type
|
|
69
69
|
return queryClient[queryFilterMethod]({ ...options, queryFn });
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -23,10 +23,10 @@ export function callQueryClientMethodWithMutationFilters<
|
|
|
23
23
|
`queryClient is invalid, ${queryFilterMethod} method does not exist`
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
// @ts-expect-error
|
|
26
|
+
// @ts-expect-error - Too complex to type
|
|
27
27
|
return queryClient[queryFilterMethod](
|
|
28
28
|
composeMutationFilters(schema, filters as never),
|
|
29
|
-
// @ts-expect-error
|
|
29
|
+
// @ts-expect-error - Argument types are too complex
|
|
30
30
|
...args.slice(1, -1)
|
|
31
31
|
);
|
|
32
32
|
}
|
|
@@ -23,10 +23,10 @@ export function callQueryClientMethodWithQueryFilters<
|
|
|
23
23
|
`queryClient is invalid, ${queryFilterMethod} method does not exist`
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
// @ts-expect-error
|
|
26
|
+
// @ts-expect-error - Too complex to type
|
|
27
27
|
return queryClient[queryFilterMethod](
|
|
28
28
|
composeQueryFilters(schema, filters as never),
|
|
29
|
-
// @ts-expect-error
|
|
29
|
+
// @ts-expect-error - Argument types are too complex
|
|
30
30
|
...args.slice(1, -1)
|
|
31
31
|
);
|
|
32
32
|
}
|
|
@@ -31,7 +31,7 @@ export function callQueryClientMethodWithQueryKey<
|
|
|
31
31
|
? composeInfiniteQueryKey(schema, parameters)
|
|
32
32
|
: composeQueryKey(schema, parameters);
|
|
33
33
|
|
|
34
|
-
// @ts-expect-error
|
|
34
|
+
// @ts-expect-error - Too complex to type
|
|
35
35
|
return queryClient[queryFilterMethod](queryKey, ...args.slice(1, -1));
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -5,10 +5,7 @@ import type { OperationSchema } from './requestFn.js';
|
|
|
5
5
|
* Omit `body` or `requestBody` from mutation parameters if exists
|
|
6
6
|
* and return the rest of the parameters
|
|
7
7
|
*/
|
|
8
|
-
export function composeMutationKey<
|
|
9
|
-
TSchema extends OperationSchema,
|
|
10
|
-
TParams = undefined,
|
|
11
|
-
>(
|
|
8
|
+
export function composeMutationKey<TSchema extends OperationSchema>(
|
|
12
9
|
schema: TSchema,
|
|
13
10
|
parameters: undefined
|
|
14
11
|
): ServiceOperationMutationKey<TSchema, undefined>;
|
|
@@ -36,10 +33,11 @@ export function omitMutationPayload<T>(params: T) {
|
|
|
36
33
|
throw new Error('`params` must be object');
|
|
37
34
|
|
|
38
35
|
if ('body' in params || 'requestBody' in params) {
|
|
39
|
-
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
const {
|
|
37
|
+
body: _,
|
|
38
|
+
requestBody: __,
|
|
39
|
+
...paramsRest
|
|
40
|
+
} = params as Record<'body' | 'requestBody', unknown>;
|
|
43
41
|
return paramsRest;
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -5,6 +5,13 @@ type ProxyApplyCallback = (path: string[], args: unknown[]) => unknown;
|
|
|
5
5
|
*/
|
|
6
6
|
type ProxyGetCallback = (path: string[], key: string) => unknown | undefined;
|
|
7
7
|
|
|
8
|
+
// todo::rename to `qraftRecursiveProxy` with deprecated `createRecursiveProxy`
|
|
9
|
+
/**
|
|
10
|
+
* Creates a recursive proxy that calls the `getCallback` and `applyCallback` functions
|
|
11
|
+
* @param getCallback The callback to call when a proxy property is accessed
|
|
12
|
+
* @param applyCallback The callback to call when a proxy is called as a function
|
|
13
|
+
* @param path The current path of the proxy
|
|
14
|
+
*/
|
|
8
15
|
export function createRecursiveProxy(
|
|
9
16
|
getCallback: ProxyGetCallback,
|
|
10
17
|
applyCallback: ProxyApplyCallback,
|