@openapi-qraft/tanstack-query-react-plugin 2.4.1 → 2.5.0-beta.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/CHANGELOG.md +17 -0
- package/dist/generateCode.d.ts +2 -2
- package/dist/generateCode.d.ts.map +1 -1
- package/dist/generateCode.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -3
- package/dist/plugin.js.map +1 -1
- package/dist/ts-factory/getIndexFactory.d.ts +2 -2
- package/dist/ts-factory/getIndexFactory.d.ts.map +1 -1
- package/dist/ts-factory/getIndexFactory.js.map +1 -1
- package/dist/ts-factory/getServiceFactory.d.ts +3 -2
- package/dist/ts-factory/getServiceFactory.d.ts.map +1 -1
- package/dist/ts-factory/getServiceFactory.js +127 -52
- package/dist/ts-factory/getServiceFactory.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.js +12 -12
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.js +10 -10
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.js +5 -5
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js +11 -11
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js +2 -2
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js +8 -8
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js +5 -5
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js +19 -19
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js +7 -7
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js +5 -5
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.js +2 -2
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js +15 -15
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js +9 -9
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.js +2 -2
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js.map +1 -1
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.js +8 -8
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.js +10 -5
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.js +9 -3
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.d.ts +3 -2
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.js +15 -6
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.js +11 -5
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.js +10 -5
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.js +3 -3
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.js +11 -5
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.d.ts +3 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.js +5 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.js.map +1 -0
- package/package.json +3 -3
- package/src/generateCode.ts +5 -5
- package/src/plugin.ts +11 -3
- package/src/ts-factory/getIndexFactory.ts +2 -2
- package/src/ts-factory/getServiceFactory.ts +262 -90
- package/src/ts-factory/tsdoc/createOperationMethodTSDocExample.ts +17 -8
- package/src/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.ts +16 -7
- package/src/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.ts +19 -3
- package/src/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.ts +40 -10
- package/src/ts-factory/tsdoc/createUseQueryOperationTSDocExample.ts +17 -5
- package/src/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.ts +16 -7
- package/src/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.ts +13 -3
- package/src/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.ts +17 -5
- package/src/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.ts +13 -0
|
@@ -2,9 +2,10 @@ import ts from 'typescript';
|
|
|
2
2
|
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
3
3
|
import { astToString } from '../astToString.js';
|
|
4
4
|
import { createInfiniteQueryOptionsArgumentExamplePropertyAssignmentNodes } from './createUseInfiniteQueryOperationTSDocExample.js';
|
|
5
|
+
import { createOperationMethodBodyParametersExampleNode } from './lib/createOperationMethodBodyParametersExampleNode.js';
|
|
5
6
|
import { createOperationMethodCallExpressionExampleNode } from './lib/createOperationMethodCallExpressionExampleNode.js';
|
|
6
7
|
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
7
|
-
export const createUseSuspenseInfiniteQueryOperationTSDocExample = (operation, serviceVariableName) => {
|
|
8
|
+
export const createUseSuspenseInfiniteQueryOperationTSDocExample = (operation, serviceVariableName, { queryableWriteOperations, }) => {
|
|
8
9
|
const factory = ts.factory;
|
|
9
10
|
const commonTSDoc = [
|
|
10
11
|
'Performs asynchronous data fetching with support for infinite scrolling scenarios.',
|
|
@@ -24,10 +25,14 @@ export const createUseSuspenseInfiniteQueryOperationTSDocExample = (operation, s
|
|
|
24
25
|
serviceVariableName,
|
|
25
26
|
operationMethodName: 'useSuspenseInfiniteQuery',
|
|
26
27
|
}, [
|
|
27
|
-
factory.createObjectLiteralExpression(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
factory.createObjectLiteralExpression([
|
|
29
|
+
queryableWriteOperations &&
|
|
30
|
+
createOperationMethodBodyParametersExampleNode(operation),
|
|
31
|
+
...createOperationMethodParametersExampleNodes({
|
|
32
|
+
...operation,
|
|
33
|
+
parameters: operation.parameters?.filter((parameter) => parameter.in === 'query' ? parameter.required : true),
|
|
34
|
+
}),
|
|
35
|
+
].filter((node) => !!node), true),
|
|
31
36
|
factory.createObjectLiteralExpression(createInfiniteQueryOptionsArgumentExamplePropertyAssignmentNodes(operation), true),
|
|
32
37
|
])))
|
|
33
38
|
.trim()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUseSuspenseInfiniteQueryOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"createUseSuspenseInfiniteQueryOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gEAAgE,EAAE,MAAM,kDAAkD,CAAC;AACpI,OAAO,EAAE,8CAA8C,EAAE,MAAM,yDAAyD,CAAC;AACzH,OAAO,EAAE,8CAA8C,EAAE,MAAM,yDAAyD,CAAC;AACzH,OAAO,EAAE,2CAA2C,EAAE,MAAM,sDAAsD,CAAC;AAEnH,MAAM,CAAC,MAAM,mDAAmD,GAAG,CACjE,SAA2B,EAC3B,mBAA2B,EAC3B,EACE,wBAAwB,GACgC,EAChD,EAAE;IACZ,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAE3B,MAAM,WAAW,GAAG;QAClB,oFAAoF;QACpF,8EAA8E;QAC9E,0FAA0F;QAC1F,EAAE;QACF,GAAG,0BAA0B,CAAC,SAAS,CAAC;QACxC,8IAA8I;QAC9I,EAAE;KACH,CAAC;IAEF,OAAO;QACL,GAAG,WAAW;QACd,kCAAkC;QAClC,OAAO;QACP,GAAG,CACD,6CAA6C;YAC7C,WAAW,CACT,8CAA8C,CAC5C,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,0BAA0B;aAChD,EACD;gBACE,OAAO,CAAC,6BAA6B,CACnC;oBACE,wBAAwB;wBACtB,8CAA8C,CAAC,SAAS,CAAC;oBAC3D,GAAG,2CAA2C,CAAC;wBAC7C,GAAG,SAAS;wBACZ,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CACrD,SAAS,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CACrD;qBACF,CAAC;iBACH,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAC1B,IAAI,CACL;gBACD,OAAO,CAAC,6BAA6B,CACnC,gEAAgE,CAC9D,SAAS,CACV,EACD,IAAI,CACL;aACF,CACF,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;QACd,EAAE;QACF,oBAAoB;QACpB,yCAAyC;QACzC,KAAK;KACN,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/OpenAPIService';
|
|
2
|
-
|
|
2
|
+
import { ServiceFactoryOptions } from '../getServiceFactory.js';
|
|
3
|
+
export declare const createUseSuspenseQueriesOperationTSDocExample: (operation: ServiceOperation, serviceVariableName: string, options: Pick<ServiceFactoryOptions, "queryableWriteOperations">) => string[];
|
|
3
4
|
//# sourceMappingURL=createUseSuspenseQueriesOperationTSDocExample.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUseSuspenseQueriesOperationTSDocExample.d.ts","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;
|
|
1
|
+
{"version":3,"file":"createUseSuspenseQueriesOperationTSDocExample.d.ts","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAK1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAShE,eAAO,MAAM,6CAA6C,cAC7C,gBAAgB,uBACN,MAAM,WAClB,IAAI,CAAC,qBAAqB,EAAE,0BAA0B,CAAC,aAiHjE,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc
|
|
|
4
4
|
import { astToString } from '../astToString.js';
|
|
5
5
|
import { createCombinedResultsForEachExpression, createCombineFunction, createQueriesArrayExpression, createResultsForEachExpression, } from './createUseQueriesOperationTSDocExample.js';
|
|
6
6
|
import { createOperationMethodCallExpressionExampleNode } from './lib/createOperationMethodCallExpressionExampleNode.js';
|
|
7
|
-
export const createUseSuspenseQueriesOperationTSDocExample = (operation, serviceVariableName) => {
|
|
7
|
+
export const createUseSuspenseQueriesOperationTSDocExample = (operation, serviceVariableName, options) => {
|
|
8
8
|
const factory = ts.factory;
|
|
9
9
|
const example = [
|
|
10
10
|
'Allows you to execute multiple asynchronous data fetching operations concurrently with Suspense support.',
|
|
@@ -21,7 +21,7 @@ export const createUseSuspenseQueriesOperationTSDocExample = (operation, service
|
|
|
21
21
|
operationMethodName: 'useSuspenseQueries',
|
|
22
22
|
}, [
|
|
23
23
|
factory.createObjectLiteralExpression([
|
|
24
|
-
factory.createPropertyAssignment(factory.createIdentifier('queries'), createQueriesArrayExpression(operation, factory)),
|
|
24
|
+
factory.createPropertyAssignment(factory.createIdentifier('queries'), createQueriesArrayExpression(operation, factory, options)),
|
|
25
25
|
], true),
|
|
26
26
|
])),
|
|
27
27
|
], ts.NodeFlags.Const)),
|
|
@@ -40,7 +40,7 @@ export const createUseSuspenseQueriesOperationTSDocExample = (operation, service
|
|
|
40
40
|
}, [
|
|
41
41
|
factory.createObjectLiteralExpression([
|
|
42
42
|
factory.createPropertyAssignment(factory.createIdentifier('combine'), createCombineFunction(factory)),
|
|
43
|
-
factory.createPropertyAssignment(factory.createIdentifier('queries'), createQueriesArrayExpression(operation, factory)),
|
|
43
|
+
factory.createPropertyAssignment(factory.createIdentifier('queries'), createQueriesArrayExpression(operation, factory, options)),
|
|
44
44
|
], true),
|
|
45
45
|
])),
|
|
46
46
|
], ts.NodeFlags.Const)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUseSuspenseQueriesOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"createUseSuspenseQueriesOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,sCAAsC,EACtC,qBAAqB,EACrB,4BAA4B,EAC5B,8BAA8B,GAC/B,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,8CAA8C,EAAE,MAAM,yDAAyD,CAAC;AAEzH,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAC3D,SAA2B,EAC3B,mBAA2B,EAC3B,OAAgE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mB;oBACnB,mBAAmB,EAAE,oBAAoB;iBAC1C,EACD;oBACE,OAAO,CAAC,6BAA6B,CACnC;wBACE,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACnC,qBAAqB,CAAC,OAAO,CAAC,CAC/B;wBACD,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,EACnC,4BAA4B,CAC1B,SAAS,EACT,OAAO,EACP,OAAO,CACR,CACF;qBACF,EACD,IAAI,CACL;iBACF,CACF,CACF;aACF,EACD,EAAE,CAAC,SAAS,CAAC,KAAK,CACnB,CACF;YACD,sCAAsC,CACpC,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,gBAAgB,CAAC,EAC5C,OAAO,CACR;SACF,CAAC;aACC,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;QACd,KAAK;KACN,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/OpenAPIService';
|
|
2
|
-
|
|
2
|
+
import { ServiceFactoryOptions } from '../getServiceFactory.js';
|
|
3
|
+
export declare const createUseSuspenseQueryOperationTSDocExample: (operation: ServiceOperation, serviceVariableName: string, { queryableWriteOperations, }: Pick<ServiceFactoryOptions, "queryableWriteOperations">) => string[];
|
|
3
4
|
//# sourceMappingURL=createUseSuspenseQueryOperationTSDocExample.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUseSuspenseQueryOperationTSDocExample.d.ts","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;
|
|
1
|
+
{"version":3,"file":"createUseSuspenseQueryOperationTSDocExample.d.ts","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAIrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,eAAO,MAAM,2CAA2C,cAC3C,gBAAgB,uBACN,MAAM,iCAGxB,IAAI,CAAC,qBAAqB,EAAE,0BAA0B,CAAC,aA0E3D,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
3
3
|
import { astToString } from '../astToString.js';
|
|
4
|
+
import { createOperationMethodBodyParametersExampleNode } from './lib/createOperationMethodBodyParametersExampleNode.js';
|
|
4
5
|
import { createOperationMethodCallExpressionExampleNode } from './lib/createOperationMethodCallExpressionExampleNode.js';
|
|
5
6
|
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
6
|
-
export const createUseSuspenseQueryOperationTSDocExample = (operation, serviceVariableName) => {
|
|
7
|
+
export const createUseSuspenseQueryOperationTSDocExample = (operation, serviceVariableName, { queryableWriteOperations, }) => {
|
|
7
8
|
const example = [
|
|
8
9
|
'Performs asynchronous data fetching with Suspense support.',
|
|
9
10
|
'Similar to useQuery but integrates with React Suspense for loading states.',
|
|
@@ -11,8 +12,8 @@ export const createUseSuspenseQueryOperationTSDocExample = (operation, serviceVa
|
|
|
11
12
|
...createOperationCommonTSDoc(operation),
|
|
12
13
|
'@see {@link https://openapi-qraft.github.io/openapi-qraft/docs/hooks/useSuspenseQuery|`useSuspenseQuery(...)` documentation}',
|
|
13
14
|
];
|
|
14
|
-
if (!operation.parameters?.
|
|
15
|
-
|
|
15
|
+
if (!operation.parameters?.some((parameter) => parameter.required) &&
|
|
16
|
+
!(queryableWriteOperations && operation.requestBody?.required)) {
|
|
16
17
|
example.push('@example Suspense Query without parameters', '```ts', ...('const data = ' +
|
|
17
18
|
astToString(createOperationMethodCallExpressionExampleNode(operation, {
|
|
18
19
|
serviceVariableName,
|
|
@@ -21,14 +22,19 @@ export const createUseSuspenseQueryOperationTSDocExample = (operation, serviceVa
|
|
|
21
22
|
.trim()
|
|
22
23
|
.split('\n'), '```');
|
|
23
24
|
}
|
|
24
|
-
if (operation.parameters?.length
|
|
25
|
+
if (operation.parameters?.length ||
|
|
26
|
+
(queryableWriteOperations && operation.requestBody)) {
|
|
25
27
|
const factory = ts.factory;
|
|
26
28
|
example.push('@example Suspense Query with parameters', '```ts', ...('const data = ' +
|
|
27
29
|
astToString(createOperationMethodCallExpressionExampleNode(operation, {
|
|
28
30
|
serviceVariableName,
|
|
29
31
|
operationMethodName: 'useSuspenseQuery',
|
|
30
32
|
}, [
|
|
31
|
-
factory.createObjectLiteralExpression(
|
|
33
|
+
factory.createObjectLiteralExpression([
|
|
34
|
+
queryableWriteOperations &&
|
|
35
|
+
createOperationMethodBodyParametersExampleNode(operation),
|
|
36
|
+
...createOperationMethodParametersExampleNodes(operation),
|
|
37
|
+
].filter((node) => !!node), true),
|
|
32
38
|
])))
|
|
33
39
|
.trim()
|
|
34
40
|
.split('\n'), '```');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createUseSuspenseQueryOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"createUseSuspenseQueryOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAA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B,mBAAmB,EAAE,kBAAkB;aACxC,EACD;gBACE,OAAO,CAAC,6BAA6B,CACnC;oBACE,wBAAwB;wBACtB,8CAA8C,CAAC,SAAS,CAAC;oBAC3D,GAAG,2CAA2C,CAAC,SAAS,CAAC;iBAC1D,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAC1B,IAAI,CACL;aACF,CACF,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC,EACd,KAAK,CACN,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/OpenAPIService';
|
|
2
|
+
export declare const createOperationMethodBodyParametersExampleNode: (operation: ServiceOperation, bodyVariableName?: string) => import("typescript").PropertyAssignment | undefined;
|
|
3
|
+
//# sourceMappingURL=createOperationMethodBodyParametersExampleNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOperationMethodBodyParametersExampleNode.d.ts","sourceRoot":"","sources":["../../../../src/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAGrF,eAAO,MAAM,8CAA8C,cAC9C,gBAAgB,mFAQd,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { factory } from 'typescript';
|
|
2
|
+
export const createOperationMethodBodyParametersExampleNode = (operation, bodyVariableName = 'queryBody') => operation.requestBody
|
|
3
|
+
? factory.createPropertyAssignment(factory.createIdentifier('body'), factory.createIdentifier(bodyVariableName))
|
|
4
|
+
: undefined;
|
|
5
|
+
//# sourceMappingURL=createOperationMethodBodyParametersExampleNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOperationMethodBodyParametersExampleNode.js","sourceRoot":"","sources":["../../../../src/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,CAAC,MAAM,8CAA8C,GAAG,CAC5D,SAA2B,EAC3B,gBAAgB,GAAG,WAAW,EAC9B,EAAE,CACF,SAAS,CAAC,WAAW;IACnB,CAAC,CAAC,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAChC,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAC3C;IACH,CAAC,CAAC,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/tanstack-query-react-plugin",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-beta.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.build.json",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@openapi-qraft/plugin": "^2.
|
|
38
|
+
"@openapi-qraft/plugin": "^2.5.0-beta.1",
|
|
39
39
|
"typescript": "^5.6.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@openapi-qraft/eslint-config": "1.0.1",
|
|
43
|
-
"@openapi-qraft/tanstack-query-react-types": "2.
|
|
43
|
+
"@openapi-qraft/tanstack-query-react-types": "2.5.0-beta.1",
|
|
44
44
|
"@openapi-qraft/test-fixtures": "1.0.1",
|
|
45
45
|
"@openapi-qraft/ts-factory-code-generator": "1.0.2",
|
|
46
46
|
"camelcase": "^8.0.0",
|
package/src/generateCode.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { getCreatePredefinedParametersRequestFnFactory } from './ts-factory/getC
|
|
|
12
12
|
import { getIndexFactory } from './ts-factory/getIndexFactory.js';
|
|
13
13
|
import {
|
|
14
14
|
getServiceFactory,
|
|
15
|
-
|
|
15
|
+
ServiceFactoryOptions,
|
|
16
16
|
} from './ts-factory/getServiceFactory.js';
|
|
17
17
|
import { getServiceIndexFactory } from './ts-factory/getServiceIndexFactory.js';
|
|
18
18
|
|
|
@@ -32,7 +32,7 @@ export const generateCode = async ({
|
|
|
32
32
|
}: {
|
|
33
33
|
spinner: Ora;
|
|
34
34
|
services: OpenAPIService[];
|
|
35
|
-
serviceImports:
|
|
35
|
+
serviceImports: ServiceFactoryOptions;
|
|
36
36
|
output: OutputOptions;
|
|
37
37
|
}) => {
|
|
38
38
|
return [
|
|
@@ -59,7 +59,7 @@ const composeServicesDirPath = (
|
|
|
59
59
|
const generateServices = async (
|
|
60
60
|
spinner: Ora,
|
|
61
61
|
services: OpenAPIService[],
|
|
62
|
-
serviceImports:
|
|
62
|
+
serviceImports: ServiceFactoryOptions,
|
|
63
63
|
output: OutputOptions
|
|
64
64
|
) => {
|
|
65
65
|
const servicesDir = composeServicesDirPath(output);
|
|
@@ -178,7 +178,7 @@ const generateClient = async (spinner: Ora, output: OutputOptions) => {
|
|
|
178
178
|
|
|
179
179
|
const generateCreatePredefinedParametersRequestFn = async (
|
|
180
180
|
spinner: Ora,
|
|
181
|
-
serviceImports:
|
|
181
|
+
serviceImports: ServiceFactoryOptions,
|
|
182
182
|
output: OutputOptions
|
|
183
183
|
) => {
|
|
184
184
|
spinner.start('Generating "createPredefinedParametersRequestFn"');
|
|
@@ -217,7 +217,7 @@ const generateCreatePredefinedParametersRequestFn = async (
|
|
|
217
217
|
|
|
218
218
|
const generateIndex = async (
|
|
219
219
|
spinner: Ora,
|
|
220
|
-
serviceImports:
|
|
220
|
+
serviceImports: ServiceFactoryOptions,
|
|
221
221
|
output: OutputOptions
|
|
222
222
|
) => {
|
|
223
223
|
spinner.start('Generating index');
|
package/src/plugin.ts
CHANGED
|
@@ -29,9 +29,12 @@ export const plugin: QraftCommandPlugin = {
|
|
|
29
29
|
.option(
|
|
30
30
|
'--export-openapi-types [bool]',
|
|
31
31
|
"Add an export statement of the generated OpenAPI document types from the `./index.ts' file. Useful for sharing types within your project.",
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
parseBooleanOption
|
|
33
|
+
)
|
|
34
|
+
.option(
|
|
35
|
+
'--queryable-write-operations [bool]',
|
|
36
|
+
'Enable generation of query hooks (useQuery, useSuspenseQuery, etc.) for writable HTTP methods like POST, PUT, PATCH. By default, only mutation hooks are generated for writable operations.',
|
|
37
|
+
parseBooleanOption
|
|
35
38
|
)
|
|
36
39
|
.action(async ({ spinner, output, args, services, schema }, resolve) => {
|
|
37
40
|
return void (await generateCode({
|
|
@@ -39,6 +42,7 @@ export const plugin: QraftCommandPlugin = {
|
|
|
39
42
|
services,
|
|
40
43
|
serviceImports: {
|
|
41
44
|
openapiTypesImportPath: args.openapiTypesImportPath,
|
|
45
|
+
queryableWriteOperations: args.queryableWriteOperations,
|
|
42
46
|
},
|
|
43
47
|
output: {
|
|
44
48
|
...output,
|
|
@@ -59,3 +63,7 @@ export const plugin: QraftCommandPlugin = {
|
|
|
59
63
|
});
|
|
60
64
|
},
|
|
61
65
|
};
|
|
66
|
+
|
|
67
|
+
function parseBooleanOption(arg: string) {
|
|
68
|
+
return arg?.toLowerCase() !== 'false';
|
|
69
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ServiceFactoryOptions } from './getServiceFactory.js';
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { maybeResolveImport } from '../lib/maybeResolveImport.js';
|
|
4
4
|
|
|
@@ -9,7 +9,7 @@ export const getIndexFactory = ({
|
|
|
9
9
|
}: {
|
|
10
10
|
servicesDirName: string;
|
|
11
11
|
explicitImportExtensions: '.js' | '.ts' | undefined;
|
|
12
|
-
} & Partial<Pick<
|
|
12
|
+
} & Partial<Pick<ServiceFactoryOptions, 'openapiTypesImportPath'>>) => {
|
|
13
13
|
const factory = ts.factory;
|
|
14
14
|
const importExtension = explicitImportExtensions ?? '';
|
|
15
15
|
|