@openapi-qraft/tanstack-query-react-plugin 2.5.0-beta.0 → 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 +7 -0
- package/dist/ts-factory/getServiceFactory.js +17 -13
- package/dist/ts-factory/getServiceFactory.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/ts-factory/getServiceFactory.ts +27 -16
- 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,EAChE,EAAE;IACF,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAE3B,MAAM,OAAO,GAAa;QACxB,0GAA0G;QAC1G,8EAA8E;QAC9E,EAAE;QACF,GAAG,0BAA0B,CAAC,SAAS,CAAC;QACxC,kIAAkI;QAElI,oCAAoC;QACpC,OAAO;QACP,GAAG,WAAW,CAAC;YACb,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,OAAO,CAAC,6BAA6B,CACnC;gBACE,OAAO,CAAC,yBAAyB,CAC/B,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,OAAO,CAAC,CAAC,EAC7D,SAAS,EACT,SAAS,EACT,8CAA8C,CAC5C,SAAS,EACT;oBACE,mBAAmB;oBACnB,mBAAmB,EAAE,oBAAoB;iBAC1C,EACD;oBACE,OAAO,CAAC,6BAA6B,CACnC;wBACE,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,8BAA8B,CAC5B,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC,EACtC,OAAO,CACR;SACF,CAAC;aACC,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;QACd,KAAK;QAEL,iDAAiD;QACjD,OAAO;QACP,GAAG,WAAW,CAAC;YACb,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,OAAO,CAAC,6BAA6B,CACnC;gBACE,OAAO,CAAC,yBAAyB,CAC/B,OAAO,CAAC,gBAAgB,CACtB,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,gBAAgB,CAAC,CAC7C,EACD,SAAS,EACT,SAAS,EACT,8CAA8C,CAC5C,SAAS,EACT;oBACE,mBAAmB;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,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,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,2CAA2C,GAAG,CACzD,SAA2B,EAC3B,mBAA2B,EAC3B,EACE,wBAAwB,GACgC,EAC1D,EAAE;IACF,MAAM,OAAO,GAAa;QACxB,4DAA4D;QAC5D,4EAA4E;QAC5E,EAAE;QACF,GAAG,0BAA0B,CAAC,SAAS,CAAC;QACxC,8HAA8H;KAC/H,CAAC;IAEF,IACE,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC;QAC9D,CAAC,CAAC,wBAAwB,IAAI,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,EAC9D,CAAC;QACD,OAAO,CAAC,IAAI,CACV,4CAA4C,EAC5C,OAAO,EACP,GAAG,CACD,eAAe;YACf,WAAW,CACT,8CAA8C,CAC5C,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,kBAAkB;aACxC,EACD,SAAS,CACV,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC,EACd,KAAK,CACN,CAAC;IACJ,CAAC;IAED,IACE,SAAS,CAAC,UAAU,EAAE,MAAM;QAC5B,CAAC,wBAAwB,IAAI,SAAS,CAAC,WAAW,CAAC,EACnD,CAAC;QACD,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;QAE3B,OAAO,CAAC,IAAI,CACV,yCAAyC,EACzC,OAAO,EACP,GAAG,CACD,eAAe;YACf,WAAW,CACT,8CAA8C,CAC5C,SAAS,EACT;gBACE,mBAAmB;gBACnB,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.5.0-beta.
|
|
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.5.0-beta.
|
|
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.5.0-beta.
|
|
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",
|
|
@@ -135,11 +135,13 @@ const getServiceInterfaceOperationFactory = (
|
|
|
135
135
|
) => {
|
|
136
136
|
const operationMethodNodes = getMethodSignatureNodes(
|
|
137
137
|
isReadOnlyOperation(operation)
|
|
138
|
-
? createServicesQueryOperationNodes()
|
|
138
|
+
? createServicesQueryOperationNodes({ omitOperationQueryFnNodes: false })
|
|
139
139
|
: options.queryableWriteOperations
|
|
140
140
|
? [
|
|
141
|
+
...createServicesQueryOperationNodes({
|
|
142
|
+
omitOperationQueryFnNodes: true,
|
|
143
|
+
}),
|
|
141
144
|
...createServicesMutationOperationNodes(),
|
|
142
|
-
...createServicesQueryOperationNodes(),
|
|
143
145
|
]
|
|
144
146
|
: createServicesMutationOperationNodes()
|
|
145
147
|
);
|
|
@@ -155,7 +157,8 @@ const getServiceInterfaceOperationFactory = (
|
|
|
155
157
|
{
|
|
156
158
|
serviceVariableName: service.variableName,
|
|
157
159
|
operationMethodName: node.name.text,
|
|
158
|
-
}
|
|
160
|
+
},
|
|
161
|
+
options
|
|
159
162
|
);
|
|
160
163
|
// Query and Mutation methods (hooks and QueryClient methods)
|
|
161
164
|
ts.addSyntheticLeadingComment(
|
|
@@ -722,7 +725,11 @@ const getOperationSecuritySchemas = (
|
|
|
722
725
|
Object.keys(security).map((securitySchemaName) => securitySchemaName)
|
|
723
726
|
);
|
|
724
727
|
|
|
725
|
-
const createServicesQueryOperationNodes = (
|
|
728
|
+
const createServicesQueryOperationNodes = ({
|
|
729
|
+
omitOperationQueryFnNodes,
|
|
730
|
+
}: {
|
|
731
|
+
omitOperationQueryFnNodes: boolean;
|
|
732
|
+
}) => [
|
|
726
733
|
...createServiceOperationCancelQueriesNodes(),
|
|
727
734
|
...createServiceOperationUseQueryNodes(),
|
|
728
735
|
...createServiceOperationFetchInfiniteQueryNodes(),
|
|
@@ -733,7 +740,7 @@ const createServicesQueryOperationNodes = () => [
|
|
|
733
740
|
...createServiceOperationGetQueryStateNodes(),
|
|
734
741
|
...createServiceOperationInvalidateQueriesNodes(),
|
|
735
742
|
...createServiceOperationIsFetchingQueriesNodes(),
|
|
736
|
-
...createServiceOperationQueryFnNodes(),
|
|
743
|
+
...(omitOperationQueryFnNodes ? [] : createServiceOperationQueryFnNodes()),
|
|
737
744
|
...createServiceOperationRefetchQueriesNodes(),
|
|
738
745
|
...createServiceOperationRemoveQueriesNodes(),
|
|
739
746
|
...createServiceOperationResetQueriesNodes(),
|
|
@@ -780,17 +787,21 @@ const getModuleTypeImports = (
|
|
|
780
787
|
operations: ServiceOperation[],
|
|
781
788
|
options: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
782
789
|
) => {
|
|
783
|
-
const nodes = [
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
790
|
+
const nodes = [];
|
|
791
|
+
|
|
792
|
+
const hasReadOnlyOperations = operations.some(isReadOnlyOperation);
|
|
793
|
+
|
|
794
|
+
if (hasReadOnlyOperations || options.queryableWriteOperations) {
|
|
795
|
+
nodes.push(
|
|
796
|
+
...createServicesQueryOperationNodes({
|
|
797
|
+
omitOperationQueryFnNodes: !hasReadOnlyOperations,
|
|
798
|
+
})
|
|
799
|
+
);
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
if (operations.some((operation) => !isReadOnlyOperation(operation))) {
|
|
803
|
+
nodes.push(...createServicesMutationOperationNodes());
|
|
804
|
+
}
|
|
794
805
|
|
|
795
806
|
return nodes
|
|
796
807
|
.map((node) =>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/OpenAPIService';
|
|
2
|
+
import { ServiceFactoryOptions } from '../getServiceFactory.js';
|
|
2
3
|
import { createUseInfiniteQueryOperationTSDocExample } from './createUseInfiniteQueryOperationTSDocExample.js';
|
|
3
4
|
import { createUseIsFetchingOperationTSDocExample } from './createUseIsFetchingOperationTSDocExample.js';
|
|
4
5
|
import { createUseIsMutatingOperationTSDocExample } from './createUseIsMutatingOperationTSDocExample.js';
|
|
@@ -18,18 +19,21 @@ export const createOperationMethodTSDocExample = (
|
|
|
18
19
|
}: {
|
|
19
20
|
serviceVariableName: string;
|
|
20
21
|
operationMethodName: string;
|
|
21
|
-
}
|
|
22
|
+
},
|
|
23
|
+
options: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
22
24
|
) => {
|
|
23
25
|
switch (operationMethodName) {
|
|
24
26
|
case 'useQuery':
|
|
25
27
|
return createUseQueryOperationTSDocExample(
|
|
26
28
|
operation,
|
|
27
|
-
serviceVariableName
|
|
29
|
+
serviceVariableName,
|
|
30
|
+
options
|
|
28
31
|
);
|
|
29
32
|
case 'useSuspenseQuery':
|
|
30
33
|
return createUseSuspenseQueryOperationTSDocExample(
|
|
31
34
|
operation,
|
|
32
|
-
serviceVariableName
|
|
35
|
+
serviceVariableName,
|
|
36
|
+
options
|
|
33
37
|
);
|
|
34
38
|
case 'useMutation':
|
|
35
39
|
return createUseMutationOperationTSDocExample(
|
|
@@ -39,17 +43,20 @@ export const createOperationMethodTSDocExample = (
|
|
|
39
43
|
case 'useInfiniteQuery':
|
|
40
44
|
return createUseInfiniteQueryOperationTSDocExample(
|
|
41
45
|
operation,
|
|
42
|
-
serviceVariableName
|
|
46
|
+
serviceVariableName,
|
|
47
|
+
options
|
|
43
48
|
);
|
|
44
49
|
case 'useSuspenseInfiniteQuery':
|
|
45
50
|
return createUseSuspenseInfiniteQueryOperationTSDocExample(
|
|
46
51
|
operation,
|
|
47
|
-
serviceVariableName
|
|
52
|
+
serviceVariableName,
|
|
53
|
+
options
|
|
48
54
|
);
|
|
49
55
|
case 'useIsFetching':
|
|
50
56
|
return createUseIsFetchingOperationTSDocExample(
|
|
51
57
|
operation,
|
|
52
|
-
serviceVariableName
|
|
58
|
+
serviceVariableName,
|
|
59
|
+
options
|
|
53
60
|
);
|
|
54
61
|
case 'useIsMutating':
|
|
55
62
|
return createUseIsMutatingOperationTSDocExample(
|
|
@@ -64,12 +71,14 @@ export const createOperationMethodTSDocExample = (
|
|
|
64
71
|
case 'useQueries':
|
|
65
72
|
return createUseQueriesOperationTSDocExample(
|
|
66
73
|
operation,
|
|
67
|
-
serviceVariableName
|
|
74
|
+
serviceVariableName,
|
|
75
|
+
options
|
|
68
76
|
);
|
|
69
77
|
case 'useSuspenseQueries':
|
|
70
78
|
return createUseSuspenseQueriesOperationTSDocExample(
|
|
71
79
|
operation,
|
|
72
|
-
serviceVariableName
|
|
80
|
+
serviceVariableName,
|
|
81
|
+
options
|
|
73
82
|
);
|
|
74
83
|
default:
|
|
75
84
|
return undefined;
|
|
@@ -3,12 +3,17 @@ import camelcase from 'camelcase';
|
|
|
3
3
|
import ts from 'typescript';
|
|
4
4
|
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
5
5
|
import { astToString } from '../astToString.js';
|
|
6
|
+
import { ServiceFactoryOptions } from '../getServiceFactory.js';
|
|
7
|
+
import { createOperationMethodBodyParametersExampleNode } from './lib/createOperationMethodBodyParametersExampleNode.js';
|
|
6
8
|
import { createOperationMethodCallExpressionExampleNode } from './lib/createOperationMethodCallExpressionExampleNode.js';
|
|
7
9
|
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
8
10
|
|
|
9
11
|
export const createUseInfiniteQueryOperationTSDocExample = (
|
|
10
12
|
operation: ServiceOperation,
|
|
11
|
-
serviceVariableName: string
|
|
13
|
+
serviceVariableName: string,
|
|
14
|
+
{
|
|
15
|
+
queryableWriteOperations,
|
|
16
|
+
}: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
12
17
|
): string[] => {
|
|
13
18
|
const factory = ts.factory;
|
|
14
19
|
|
|
@@ -36,12 +41,16 @@ export const createUseInfiniteQueryOperationTSDocExample = (
|
|
|
36
41
|
},
|
|
37
42
|
[
|
|
38
43
|
factory.createObjectLiteralExpression(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
[
|
|
45
|
+
queryableWriteOperations &&
|
|
46
|
+
createOperationMethodBodyParametersExampleNode(operation),
|
|
47
|
+
...createOperationMethodParametersExampleNodes({
|
|
48
|
+
...operation,
|
|
49
|
+
parameters: operation.parameters?.filter((parameter) =>
|
|
50
|
+
parameter.in === 'query' ? parameter.required : true
|
|
51
|
+
),
|
|
52
|
+
}),
|
|
53
|
+
].filter((node) => !!node),
|
|
45
54
|
true
|
|
46
55
|
),
|
|
47
56
|
factory.createObjectLiteralExpression(
|
|
@@ -3,12 +3,17 @@ import camelcase from 'camelcase';
|
|
|
3
3
|
import ts from 'typescript';
|
|
4
4
|
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
5
5
|
import { astToString } from '../astToString.js';
|
|
6
|
+
import { ServiceFactoryOptions } from '../getServiceFactory.js';
|
|
7
|
+
import { createOperationMethodBodyParametersExampleNode } from './lib/createOperationMethodBodyParametersExampleNode.js';
|
|
6
8
|
import { createOperationMethodCallExpressionExampleNode } from './lib/createOperationMethodCallExpressionExampleNode.js';
|
|
7
9
|
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
8
10
|
|
|
9
11
|
export const createUseIsFetchingOperationTSDocExample = (
|
|
10
12
|
operation: ServiceOperation,
|
|
11
|
-
serviceVariableName: string
|
|
13
|
+
serviceVariableName: string,
|
|
14
|
+
{
|
|
15
|
+
queryableWriteOperations,
|
|
16
|
+
}: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
12
17
|
) => {
|
|
13
18
|
const example: string[] = [
|
|
14
19
|
'Monitors the number of queries currently fetching, matching the provided filters.',
|
|
@@ -37,7 +42,10 @@ export const createUseIsFetchingOperationTSDocExample = (
|
|
|
37
42
|
'```',
|
|
38
43
|
];
|
|
39
44
|
|
|
40
|
-
if (
|
|
45
|
+
if (
|
|
46
|
+
operation.parameters?.length ||
|
|
47
|
+
(queryableWriteOperations && operation.requestBody)
|
|
48
|
+
) {
|
|
41
49
|
const factory = ts.factory;
|
|
42
50
|
|
|
43
51
|
example.push(
|
|
@@ -62,7 +70,15 @@ export const createUseIsFetchingOperationTSDocExample = (
|
|
|
62
70
|
factory.createPropertyAssignment(
|
|
63
71
|
factory.createIdentifier('parameters'),
|
|
64
72
|
factory.createObjectLiteralExpression(
|
|
65
|
-
|
|
73
|
+
[
|
|
74
|
+
queryableWriteOperations &&
|
|
75
|
+
createOperationMethodBodyParametersExampleNode(
|
|
76
|
+
operation
|
|
77
|
+
),
|
|
78
|
+
...createOperationMethodParametersExampleNodes(
|
|
79
|
+
operation
|
|
80
|
+
),
|
|
81
|
+
].filter((node) => !!node),
|
|
66
82
|
true
|
|
67
83
|
)
|
|
68
84
|
),
|
|
@@ -3,12 +3,15 @@ import camelcase from 'camelcase';
|
|
|
3
3
|
import ts from 'typescript';
|
|
4
4
|
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
5
5
|
import { astToString } from '../astToString.js';
|
|
6
|
+
import { ServiceFactoryOptions } from '../getServiceFactory.js';
|
|
7
|
+
import { createOperationMethodBodyParametersExampleNode } from './lib/createOperationMethodBodyParametersExampleNode.js';
|
|
6
8
|
import { createOperationMethodCallExpressionExampleNode } from './lib/createOperationMethodCallExpressionExampleNode.js';
|
|
7
9
|
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
8
10
|
|
|
9
11
|
export const createUseQueriesOperationTSDocExample = (
|
|
10
12
|
operation: ServiceOperation,
|
|
11
|
-
serviceVariableName: string
|
|
13
|
+
serviceVariableName: string,
|
|
14
|
+
options: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
12
15
|
) => {
|
|
13
16
|
const factory = ts.factory;
|
|
14
17
|
|
|
@@ -40,7 +43,11 @@ export const createUseQueriesOperationTSDocExample = (
|
|
|
40
43
|
[
|
|
41
44
|
factory.createPropertyAssignment(
|
|
42
45
|
factory.createIdentifier('queries'),
|
|
43
|
-
createQueriesArrayExpression(
|
|
46
|
+
createQueriesArrayExpression(
|
|
47
|
+
operation,
|
|
48
|
+
factory,
|
|
49
|
+
options
|
|
50
|
+
)
|
|
44
51
|
),
|
|
45
52
|
],
|
|
46
53
|
true
|
|
@@ -89,7 +96,11 @@ export const createUseQueriesOperationTSDocExample = (
|
|
|
89
96
|
),
|
|
90
97
|
factory.createPropertyAssignment(
|
|
91
98
|
factory.createIdentifier('queries'),
|
|
92
|
-
createQueriesArrayExpression(
|
|
99
|
+
createQueriesArrayExpression(
|
|
100
|
+
operation,
|
|
101
|
+
factory,
|
|
102
|
+
options
|
|
103
|
+
)
|
|
93
104
|
),
|
|
94
105
|
],
|
|
95
106
|
true
|
|
@@ -116,20 +127,39 @@ export const createUseQueriesOperationTSDocExample = (
|
|
|
116
127
|
|
|
117
128
|
export const createQueriesArrayExpression = (
|
|
118
129
|
operation: ServiceOperation,
|
|
119
|
-
factory: ts.NodeFactory
|
|
130
|
+
factory: ts.NodeFactory,
|
|
131
|
+
{
|
|
132
|
+
queryableWriteOperations,
|
|
133
|
+
}: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
120
134
|
): ts.ArrayLiteralExpression => {
|
|
121
135
|
return factory.createArrayLiteralExpression(
|
|
122
136
|
[
|
|
123
137
|
factory.createObjectLiteralExpression(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
138
|
+
[
|
|
139
|
+
queryableWriteOperations &&
|
|
140
|
+
createOperationMethodBodyParametersExampleNode(
|
|
141
|
+
operation,
|
|
142
|
+
'queryBody1'
|
|
143
|
+
),
|
|
144
|
+
...createOperationMethodParametersExampleNodes(
|
|
145
|
+
operation,
|
|
146
|
+
(parameter) => camelcase(`${parameter.name}-1`)
|
|
147
|
+
),
|
|
148
|
+
].filter((node) => !!node),
|
|
127
149
|
true
|
|
128
150
|
),
|
|
129
151
|
factory.createObjectLiteralExpression(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
[
|
|
153
|
+
queryableWriteOperations &&
|
|
154
|
+
createOperationMethodBodyParametersExampleNode(
|
|
155
|
+
operation,
|
|
156
|
+
'queryBody2'
|
|
157
|
+
),
|
|
158
|
+
...createOperationMethodParametersExampleNodes(
|
|
159
|
+
operation,
|
|
160
|
+
(parameter) => camelcase(`${parameter.name}-2`)
|
|
161
|
+
),
|
|
162
|
+
].filter((node) => !!node),
|
|
133
163
|
true
|
|
134
164
|
),
|
|
135
165
|
],
|
|
@@ -2,12 +2,17 @@ import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/OpenAPIServ
|
|
|
2
2
|
import ts from 'typescript';
|
|
3
3
|
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
4
4
|
import { astToString } from '../astToString.js';
|
|
5
|
+
import { ServiceFactoryOptions } from '../getServiceFactory.js';
|
|
6
|
+
import { createOperationMethodBodyParametersExampleNode } from './lib/createOperationMethodBodyParametersExampleNode.js';
|
|
5
7
|
import { createOperationMethodCallExpressionExampleNode } from './lib/createOperationMethodCallExpressionExampleNode.js';
|
|
6
8
|
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
7
9
|
|
|
8
10
|
export const createUseQueryOperationTSDocExample = (
|
|
9
11
|
operation: ServiceOperation,
|
|
10
|
-
serviceVariableName: string
|
|
12
|
+
serviceVariableName: string,
|
|
13
|
+
{
|
|
14
|
+
queryableWriteOperations,
|
|
15
|
+
}: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
11
16
|
) => {
|
|
12
17
|
const example: string[] = [
|
|
13
18
|
'Performs asynchronous data fetching, manages loading states and error handling.',
|
|
@@ -17,8 +22,8 @@ export const createUseQueryOperationTSDocExample = (
|
|
|
17
22
|
];
|
|
18
23
|
|
|
19
24
|
if (
|
|
20
|
-
!operation.parameters?.
|
|
21
|
-
|
|
25
|
+
!operation.parameters?.some((parameter) => parameter.required) &&
|
|
26
|
+
!(queryableWriteOperations && operation.requestBody?.required)
|
|
22
27
|
) {
|
|
23
28
|
example.push(
|
|
24
29
|
'@example Query without parameters',
|
|
@@ -42,7 +47,10 @@ export const createUseQueryOperationTSDocExample = (
|
|
|
42
47
|
);
|
|
43
48
|
}
|
|
44
49
|
|
|
45
|
-
if (
|
|
50
|
+
if (
|
|
51
|
+
operation.parameters?.length ||
|
|
52
|
+
(queryableWriteOperations && operation.requestBody)
|
|
53
|
+
) {
|
|
46
54
|
const factory = ts.factory;
|
|
47
55
|
|
|
48
56
|
example.push(
|
|
@@ -59,7 +67,11 @@ export const createUseQueryOperationTSDocExample = (
|
|
|
59
67
|
},
|
|
60
68
|
[
|
|
61
69
|
factory.createObjectLiteralExpression(
|
|
62
|
-
|
|
70
|
+
[
|
|
71
|
+
queryableWriteOperations &&
|
|
72
|
+
createOperationMethodBodyParametersExampleNode(operation),
|
|
73
|
+
...createOperationMethodParametersExampleNodes(operation),
|
|
74
|
+
].filter((node) => !!node),
|
|
63
75
|
true
|
|
64
76
|
),
|
|
65
77
|
]
|