@openapi-qraft/tanstack-query-react-plugin 2.0.0-next.7 → 2.0.0-next.9
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 +18 -0
- package/dist/lib/createOperationCommonTSDoc.d.ts +3 -0
- package/dist/lib/createOperationCommonTSDoc.d.ts.map +1 -0
- package/dist/lib/createOperationCommonTSDoc.js +8 -0
- package/dist/lib/createOperationCommonTSDoc.js.map +1 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +0 -2
- package/dist/plugin.js.map +1 -1
- package/dist/ts-factory/getServiceFactory.d.ts +4 -3
- package/dist/ts-factory/getServiceFactory.d.ts.map +1 -1
- package/dist/ts-factory/getServiceFactory.js +247 -44
- package/dist/ts-factory/getServiceFactory.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js +38 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.js +89 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.js +48 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.js +34 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js +59 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.js +30 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js +62 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js +26 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.js +34 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js +36 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.js +35 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.js +62 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js +38 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.js +34 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js +38 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js +54 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js +55 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js +42 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js +138 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.js +34 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js +36 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js +81 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js +63 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.js +34 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js +93 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js +77 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.js +40 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.js.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.d.ts +4 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.d.ts.map +1 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js +52 -0
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js.map +1 -0
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.d.ts +6 -0
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.js +22 -0
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.js.map +1 -0
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.d.ts +3 -0
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.js +61 -0
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.js.map +1 -0
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.d.ts +3 -0
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.js +41 -0
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.js.map +1 -0
- package/dist/ts-factory/tsdoc/createUseIsMutatingOperationTSDocExample.d.ts +3 -0
- package/dist/ts-factory/tsdoc/createUseIsMutatingOperationTSDocExample.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/createUseIsMutatingOperationTSDocExample.js +41 -0
- package/dist/ts-factory/tsdoc/createUseIsMutatingOperationTSDocExample.js.map +1 -0
- package/dist/ts-factory/tsdoc/createUseMutationOperationTSDocExample.d.ts +3 -0
- package/dist/ts-factory/tsdoc/createUseMutationOperationTSDocExample.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/createUseMutationOperationTSDocExample.js +44 -0
- package/dist/ts-factory/tsdoc/createUseMutationOperationTSDocExample.js.map +1 -0
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.d.ts +3 -0
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.js +37 -0
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.js.map +1 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodExampleNodes.d.ts +7 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodExampleNodes.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodExampleNodes.js +8 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodExampleNodes.js.map +1 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodParametersExampleNodes.d.ts +4 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodParametersExampleNodes.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodParametersExampleNodes.js +31 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodParametersExampleNodes.js.map +1 -0
- package/package.json +9 -6
- package/src/lib/createOperationCommonTSDoc.ts +11 -0
- package/src/plugin.ts +0 -6
- package/src/ts-factory/getServiceFactory.ts +425 -91
- package/src/ts-factory/service-operation.generated/.gitkeep +0 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationCancelQueries.ts +171 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.ts +340 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationFetchQuery.ts +219 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.ts +134 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.ts +258 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationGetQueryData.ts +120 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationGetQueryState.ts +248 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.ts +137 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.ts +141 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.ts +151 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationMutationFn.ts +175 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationQueryFn.ts +278 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.ts +171 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.ts +141 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationResetQueries.ts +171 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.ts +201 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.ts +221 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationSetQueryData.ts +167 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.ts +534 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.ts +141 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.ts +151 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseMutation.ts +354 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseMutationState.ts +276 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseQueries.ts +191 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseQuery.ts +392 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.ts +299 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.ts +204 -0
- package/src/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.ts +212 -0
- package/src/ts-factory/tsdoc/createOperationMethodTSDocExample.ts +47 -0
- package/src/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.ts +146 -0
- package/src/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.ts +81 -0
- package/src/ts-factory/tsdoc/createUseIsMutatingOperationTSDocExample.ts +74 -0
- package/src/ts-factory/tsdoc/createUseMutationOperationTSDocExample.ts +88 -0
- package/src/ts-factory/tsdoc/createUseQueryOperationTSDocExample.ts +76 -0
- package/src/ts-factory/tsdoc/lib/createOperationMethodExampleNodes.ts +32 -0
- package/src/ts-factory/tsdoc/lib/createOperationMethodParametersExampleNodes.ts +66 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import camelcase from 'camelcase';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { astToString } from '../astToString.js';
|
|
4
|
+
import { createOperationMethodExampleNodes } from './lib/createOperationMethodExampleNodes.js';
|
|
5
|
+
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
6
|
+
export const createUseIsFetchingOperationTSDocExample = (operation, serviceVariableName) => {
|
|
7
|
+
const example = [
|
|
8
|
+
'Monitors the number of queries currently fetching, matching the provided filters.',
|
|
9
|
+
'Useful for creating loading indicators or performing actions based on active requests.',
|
|
10
|
+
'',
|
|
11
|
+
'@see {@link https://openapi-qraft.github.io/openapi-qraft/docs/hooks/useIsFetching|`useIsFetching(...)` documentation}',
|
|
12
|
+
'@example Checks the total number of queries fetching from the specified service method,',
|
|
13
|
+
'both normal and infinite. If no parameters are provided, no filtering is applied.',
|
|
14
|
+
'```ts',
|
|
15
|
+
...(`const ${camelcase(operation.name + '-total')} = ` +
|
|
16
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
17
|
+
serviceVariableName,
|
|
18
|
+
operationMethodName: 'useIsFetching',
|
|
19
|
+
}, undefined)))
|
|
20
|
+
.trim()
|
|
21
|
+
.split('\n'),
|
|
22
|
+
'```',
|
|
23
|
+
];
|
|
24
|
+
if (operation.parameters?.length) {
|
|
25
|
+
const factory = ts.factory;
|
|
26
|
+
example.push('@example Checks the number of normal queries fetching with the specified parameters.', '```ts', ...(`const ${camelcase(operation.name + '-by-parameters-total')} = ` +
|
|
27
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
28
|
+
serviceVariableName,
|
|
29
|
+
operationMethodName: 'useIsFetching',
|
|
30
|
+
}, [
|
|
31
|
+
factory.createObjectLiteralExpression([
|
|
32
|
+
factory.createPropertyAssignment(factory.createIdentifier('infinite'), factory.createFalse()),
|
|
33
|
+
factory.createPropertyAssignment(factory.createIdentifier('parameters'), factory.createObjectLiteralExpression(createOperationMethodParametersExampleNodes(operation), true)),
|
|
34
|
+
], true),
|
|
35
|
+
])))
|
|
36
|
+
.trim()
|
|
37
|
+
.split('\n'), '```');
|
|
38
|
+
}
|
|
39
|
+
return example;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=createUseIsFetchingOperationTSDocExample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUseIsFetchingOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,2CAA2C,EAAE,MAAM,sDAAsD,CAAC;AAEnH,MAAM,CAAC,MAAM,wCAAwC,GAAG,CACtD,SAA2B,EAC3B,mBAA2B,EAC3B,EAAE;IACF,MAAM,OAAO,GAAa;QACxB,mFAAmF;QACnF,wFAAwF;QACxF,EAAE;QACF,wHAAwH;QACxH,yFAAyF;QACzF,mFAAmF;QACnF,OAAO;QACP,GAAG,CACD,SAAS,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK;YAClD,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,eAAe;aACrC,EACD,SAAS,CACV,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;QACd,KAAK;KACN,CAAC;IAEF,IAAI,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;QAE3B,OAAO,CAAC,IAAI,CACV,sFAAsF,EACtF,OAAO,EACP,GAAG,CACD,SAAS,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,sBAAsB,CAAC,KAAK;YAChE,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,eAAe;aACrC,EACD;gBACE,OAAO,CAAC,6BAA6B,CACnC;oBACE,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,EACpC,OAAO,CAAC,WAAW,EAAE,CACtB;oBACD,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,6BAA6B,CACnC,2CAA2C,CAAC,SAAS,CAAC,EACtD,IAAI,CACL,CACF;iBACF,EACD,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 type { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/getServices';
|
|
2
|
+
export declare const createUseIsMutatingOperationTSDocExample: (operation: ServiceOperation, serviceVariableName: string) => string[];
|
|
3
|
+
//# sourceMappingURL=createUseIsMutatingOperationTSDocExample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUseIsMutatingOperationTSDocExample.d.ts","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseIsMutatingOperationTSDocExample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAQvF,eAAO,MAAM,wCAAwC,cACxC,gBAAgB,uBACN,MAAM,aA+D5B,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import camelcase from 'camelcase';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
4
|
+
import { astToString } from '../astToString.js';
|
|
5
|
+
import { createOperationMethodExampleNodes } from './lib/createOperationMethodExampleNodes.js';
|
|
6
|
+
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
7
|
+
export const createUseIsMutatingOperationTSDocExample = (operation, serviceVariableName) => {
|
|
8
|
+
const factory = ts.factory;
|
|
9
|
+
const example = [
|
|
10
|
+
'Returns the count of currently in-progress mutations.',
|
|
11
|
+
'',
|
|
12
|
+
...createOperationCommonTSDoc(operation),
|
|
13
|
+
'@see {@link https://openapi-qraft.github.io/openapi-qraft/docs/hooks/useIsMutating|`useIsMutating(...)` documentation}',
|
|
14
|
+
'@example Check how many mutations are currently in progress for the specified service method.',
|
|
15
|
+
'```ts',
|
|
16
|
+
...(`const ${camelcase(operation.name + '-total')} = ` +
|
|
17
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
18
|
+
serviceVariableName,
|
|
19
|
+
operationMethodName: 'useIsMutating',
|
|
20
|
+
}, undefined)))
|
|
21
|
+
.trim()
|
|
22
|
+
.split('\n'),
|
|
23
|
+
'```',
|
|
24
|
+
'@example Check how many mutations are currently in progress with the specified parameters.',
|
|
25
|
+
'```ts',
|
|
26
|
+
...(`const ${camelcase(operation.name + '-total')} = ` +
|
|
27
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
28
|
+
serviceVariableName,
|
|
29
|
+
operationMethodName: 'useIsMutating',
|
|
30
|
+
}, [
|
|
31
|
+
factory.createObjectLiteralExpression([
|
|
32
|
+
factory.createPropertyAssignment(factory.createIdentifier('parameters'), factory.createObjectLiteralExpression(createOperationMethodParametersExampleNodes(operation), true)),
|
|
33
|
+
], true),
|
|
34
|
+
])))
|
|
35
|
+
.trim()
|
|
36
|
+
.split('\n'),
|
|
37
|
+
'```',
|
|
38
|
+
];
|
|
39
|
+
return example;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=createUseIsMutatingOperationTSDocExample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUseIsMutatingOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseIsMutatingOperationTSDocExample.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;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,2CAA2C,EAAE,MAAM,sDAAsD,CAAC;AAEnH,MAAM,CAAC,MAAM,wCAAwC,GAAG,CACtD,SAA2B,EAC3B,mBAA2B,EAC3B,EAAE;IACF,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAE3B,MAAM,OAAO,GAAa;QACxB,uDAAuD;QACvD,EAAE;QACF,GAAG,0BAA0B,CAAC,SAAS,CAAC;QACxC,wHAAwH;QAExH,+FAA+F;QAC/F,OAAO;QACP,GAAG,CACD,SAAS,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK;YAClD,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,eAAe;aACrC,EACD,SAAS,CACV,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;QACd,KAAK;QAEL,4FAA4F;QAC5F,OAAO;QACP,GAAG,CACD,SAAS,SAAS,CAAC,SAAS,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK;YAClD,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,eAAe;aACrC,EACD;gBACE,OAAO,CAAC,6BAA6B,CACnC;oBACE,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,6BAA6B,CACnC,2CAA2C,CAAC,SAAS,CAAC,EACtD,IAAI,CACL,CACF;iBACF,EACD,IAAI,CACL;aACF,CACF,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;QACd,KAAK;KACN,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/getServices';
|
|
2
|
+
export declare const createUseMutationOperationTSDocExample: (operation: ServiceOperation, serviceVariableName: string) => string[];
|
|
3
|
+
//# sourceMappingURL=createUseMutationOperationTSDocExample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUseMutationOperationTSDocExample.d.ts","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseMutationOperationTSDocExample.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAMvF,eAAO,MAAM,sCAAsC,cACtC,gBAAgB,uBACN,MAAM,aA+E5B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { astToString } from '../astToString.js';
|
|
3
|
+
import { createOperationMethodExampleNodes } from './lib/createOperationMethodExampleNodes.js';
|
|
4
|
+
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
5
|
+
export const createUseMutationOperationTSDocExample = (operation, serviceVariableName) => {
|
|
6
|
+
const factory = ts.factory;
|
|
7
|
+
const example = [
|
|
8
|
+
'Enables performing asynchronous data mutation operations such as POST, PUT, PATCH, or DELETE requests.',
|
|
9
|
+
'Handles loading state, optimistic updates, and error handling.',
|
|
10
|
+
'',
|
|
11
|
+
'@see {@link https://openapi-qraft.github.io/openapi-qraft/docs/hooks/useMutation|`useMutation(...)` documentation}',
|
|
12
|
+
'@example Mutation with predefined parameters, e.g., for updating',
|
|
13
|
+
'```ts',
|
|
14
|
+
...('const { mutate, isPending } = ' +
|
|
15
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
16
|
+
serviceVariableName,
|
|
17
|
+
operationMethodName: 'useMutation',
|
|
18
|
+
}, [
|
|
19
|
+
factory.createObjectLiteralExpression(createOperationMethodParametersExampleNodes(operation), true),
|
|
20
|
+
])))
|
|
21
|
+
.trim()
|
|
22
|
+
.split('\n'),
|
|
23
|
+
'mutate(body);',
|
|
24
|
+
'```',
|
|
25
|
+
];
|
|
26
|
+
example.push('@example Mutation without predefined parameters, e.g., for creating', '```ts', ...('const { mutate, isPending } = ' +
|
|
27
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
28
|
+
serviceVariableName,
|
|
29
|
+
operationMethodName: 'useMutation',
|
|
30
|
+
}, undefined)))
|
|
31
|
+
.trim()
|
|
32
|
+
.split('\n'), ...astToString([
|
|
33
|
+
factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier('mutate'), undefined, [
|
|
34
|
+
factory.createObjectLiteralExpression([
|
|
35
|
+
factory.createPropertyAssignment(factory.createIdentifier('body'), factory.createIdentifier('bodyPayload')),
|
|
36
|
+
...createOperationMethodParametersExampleNodes(operation),
|
|
37
|
+
], true),
|
|
38
|
+
])),
|
|
39
|
+
])
|
|
40
|
+
.trim()
|
|
41
|
+
.split('\n'), '```');
|
|
42
|
+
return example;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=createUseMutationOperationTSDocExample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUseMutationOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseMutationOperationTSDocExample.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,2CAA2C,EAAE,MAAM,sDAAsD,CAAC;AAEnH,MAAM,CAAC,MAAM,sCAAsC,GAAG,CACpD,SAA2B,EAC3B,mBAA2B,EAC3B,EAAE;IACF,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAE3B,MAAM,OAAO,GAAa;QACxB,wGAAwG;QACxG,gEAAgE;QAChE,EAAE;QACF,oHAAoH;QACpH,kEAAkE;QAClE,OAAO;QACP,GAAG,CACD,gCAAgC;YAChC,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,aAAa;aACnC,EACD;gBACE,OAAO,CAAC,6BAA6B,CACnC,2CAA2C,CAAC,SAAS,CAAC,EACtD,IAAI,CACL;aACF,CACF,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;QACd,eAAe;QACf,KAAK;KACN,CAAC;IAEF,OAAO,CAAC,IAAI,CACV,qEAAqE,EACrE,OAAO,EACP,GAAG,CACD,gCAAgC;QAChC,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;YACE,mBAAmB;YACnB,mBAAmB,EAAE,aAAa;SACnC,EACD,SAAS,CACV,CACF,CACF;SACE,IAAI,EAAE;SACN,KAAK,CAAC,IAAI,CAAC,EACd,GAAG,WAAW,CAAC;QACb,OAAO,CAAC,yBAAyB,CAC/B,OAAO,CAAC,oBAAoB,CAC1B,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAClC,SAAS,EACT;YACE,OAAO,CAAC,6BAA6B,CACnC;gBACE,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAChC,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CACxC;gBACD,GAAG,2CAA2C,CAAC,SAAS,CAAC;aAC1D,EACD,IAAI,CACL;SACF,CACF,CACF;KACF,CAAC;SACC,IAAI,EAAE;SACN,KAAK,CAAC,IAAI,CAAC,EACd,KAAK,CACN,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/getServices';
|
|
2
|
+
export declare const createUseQueryOperationTSDocExample: (operation: ServiceOperation, serviceVariableName: string) => string[];
|
|
3
|
+
//# sourceMappingURL=createUseQueryOperationTSDocExample.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUseQueryOperationTSDocExample.d.ts","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseQueryOperationTSDocExample.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAOlF,eAAO,MAAM,mCAAmC,cACnC,gBAAgB,uBACN,MAAM,aAkE5B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import { createOperationCommonTSDoc } from '../../lib/createOperationCommonTSDoc.js';
|
|
3
|
+
import { astToString } from '../astToString.js';
|
|
4
|
+
import { createOperationMethodExampleNodes } from './lib/createOperationMethodExampleNodes.js';
|
|
5
|
+
import { createOperationMethodParametersExampleNodes } from './lib/createOperationMethodParametersExampleNodes.js';
|
|
6
|
+
export const createUseQueryOperationTSDocExample = (operation, serviceVariableName) => {
|
|
7
|
+
const example = [
|
|
8
|
+
'Performs asynchronous data fetching, manages loading states and error handling.',
|
|
9
|
+
'',
|
|
10
|
+
...createOperationCommonTSDoc(operation),
|
|
11
|
+
'@see {@link https://openapi-qraft.github.io/openapi-qraft/docs/hooks/useQuery|`useQuery(...)` documentation}',
|
|
12
|
+
];
|
|
13
|
+
if (!operation.parameters?.length ||
|
|
14
|
+
operation.parameters.every((parameter) => !parameter.required)) {
|
|
15
|
+
example.push('@example Query without parameters', '```ts', ...('const { data, isLoading } = ' +
|
|
16
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
17
|
+
serviceVariableName,
|
|
18
|
+
operationMethodName: 'useQuery',
|
|
19
|
+
}, undefined)))
|
|
20
|
+
.trim()
|
|
21
|
+
.split('\n'), '```');
|
|
22
|
+
}
|
|
23
|
+
if (operation.parameters?.length) {
|
|
24
|
+
const factory = ts.factory;
|
|
25
|
+
example.push('@example Query with parameters', '```ts', ...('const { data, isLoading } = ' +
|
|
26
|
+
astToString(createOperationMethodExampleNodes(operation, {
|
|
27
|
+
serviceVariableName,
|
|
28
|
+
operationMethodName: 'useQuery',
|
|
29
|
+
}, [
|
|
30
|
+
factory.createObjectLiteralExpression(createOperationMethodParametersExampleNodes(operation), true),
|
|
31
|
+
])))
|
|
32
|
+
.trim()
|
|
33
|
+
.split('\n'), '```');
|
|
34
|
+
}
|
|
35
|
+
return example;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=createUseQueryOperationTSDocExample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUseQueryOperationTSDocExample.js","sourceRoot":"","sources":["../../../src/ts-factory/tsdoc/createUseQueryOperationTSDocExample.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;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,2CAA2C,EAAE,MAAM,sDAAsD,CAAC;AAEnH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CACjD,SAA2B,EAC3B,mBAA2B,EAC3B,EAAE;IACF,MAAM,OAAO,GAAa;QACxB,iFAAiF;QACjF,EAAE;QACF,GAAG,0BAA0B,CAAC,SAAS,CAAC;QACxC,8GAA8G;KAC/G,CAAC;IAEF,IACE,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM;QAC7B,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,EAC9D,CAAC;QACD,OAAO,CAAC,IAAI,CACV,mCAAmC,EACnC,OAAO,EACP,GAAG,CACD,8BAA8B;YAC9B,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,UAAU;aAChC,EACD,SAAS,CACV,CACF,CACF;aACE,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC,EACd,KAAK,CACN,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QACjC,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;QAE3B,OAAO,CAAC,IAAI,CACV,gCAAgC,EAChC,OAAO,EACP,GAAG,CACD,8BAA8B;YAC9B,WAAW,CACT,iCAAiC,CAC/B,SAAS,EACT;gBACE,mBAAmB;gBACnB,mBAAmB,EAAE,UAAU;aAChC,EACD;gBACE,OAAO,CAAC,6BAA6B,CACnC,2CAA2C,CAAC,SAAS,CAAC,EACtD,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,7 @@
|
|
|
1
|
+
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/getServices';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
export declare const createOperationMethodExampleNodes: (operation: ServiceOperation, { serviceVariableName, operationMethodName, }: {
|
|
4
|
+
serviceVariableName: string;
|
|
5
|
+
operationMethodName: string;
|
|
6
|
+
}, nodes: ts.Expression[] | undefined) => ts.ExpressionStatement[];
|
|
7
|
+
//# sourceMappingURL=createOperationMethodExampleNodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOperationMethodExampleNodes.d.ts","sourceRoot":"","sources":["../../../../src/ts-factory/tsdoc/lib/createOperationMethodExampleNodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,eAAO,MAAM,iCAAiC,cACjC,gBAAgB,iDAIxB;IAAE,mBAAmB,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,SACxD,EAAE,CAAC,UAAU,EAAE,GAAG,SAAS,6BAsBnC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
export const createOperationMethodExampleNodes = (operation, { serviceVariableName, operationMethodName, }, nodes) => {
|
|
3
|
+
const factory = ts.factory;
|
|
4
|
+
return [
|
|
5
|
+
factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(factory.createIdentifier('qraft'), factory.createIdentifier(serviceVariableName)), factory.createIdentifier(operation.name)), factory.createIdentifier(operationMethodName)), undefined, nodes)),
|
|
6
|
+
];
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=createOperationMethodExampleNodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOperationMethodExampleNodes.js","sourceRoot":"","sources":["../../../../src/ts-factory/tsdoc/lib/createOperationMethodExampleNodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAC/C,SAA2B,EAC3B,EACE,mBAAmB,EACnB,mBAAmB,GAC0C,EAC/D,KAAkC,EAClC,EAAE;IACF,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAE3B,OAAO;QACL,OAAO,CAAC,yBAAyB,CAC/B,OAAO,CAAC,oBAAoB,CAC1B,OAAO,CAAC,8BAA8B,CACpC,OAAO,CAAC,8BAA8B,CACpC,OAAO,CAAC,8BAA8B,CACpC,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,EACjC,OAAO,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAC9C,EACD,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CACzC,EACD,OAAO,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,CAC9C,EACD,SAAS,EACT,KAAK,CACN,CACF;KACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/getServices';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
export declare const createOperationMethodParametersExampleNodes: (operation: ServiceOperation, transformOperationParameterIdentifier?: (operationParameter: NonNullable<ServiceOperation["parameters"]>[number]) => string) => ts.PropertyAssignment[];
|
|
4
|
+
//# sourceMappingURL=createOperationMethodParametersExampleNodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOperationMethodParametersExampleNodes.d.ts","sourceRoot":"","sources":["../../../../src/ts-factory/tsdoc/lib/createOperationMethodParametersExampleNodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAElF,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,eAAO,MAAM,2CAA2C,cAC3C,gBAAgB,0CACa,CACtC,kBAAkB,EAAE,WAAW,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,KACpE,MAAM,KACV,EAAE,CAAC,kBAAkB,EAwDvB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import camelcase from 'camelcase';
|
|
2
|
+
import ts from 'typescript';
|
|
3
|
+
export const createOperationMethodParametersExampleNodes = (operation, transformOperationParameterIdentifier) => {
|
|
4
|
+
if (!operation.parameters)
|
|
5
|
+
return [];
|
|
6
|
+
const parametersTypeList = operation.parameters
|
|
7
|
+
.map((parameter) => parameter.in)
|
|
8
|
+
.filter((parameterKind, index, array) => array.indexOf(parameterKind) === index);
|
|
9
|
+
const operationRequiredParameters = operation.parameters.filter((parameter) => parameter.required);
|
|
10
|
+
return parametersTypeList.reduce((acc, parameterKind) => {
|
|
11
|
+
let operationParameters = operationRequiredParameters.filter((parameter) => parameter.in === parameterKind);
|
|
12
|
+
if (!operationParameters.length) {
|
|
13
|
+
const operationParameter = operation.parameters?.find((parameter) => parameter.in === parameterKind);
|
|
14
|
+
if (operationParameter) {
|
|
15
|
+
operationParameters = [operationParameter];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (!operationParameters.length)
|
|
19
|
+
return acc;
|
|
20
|
+
const factory = ts.factory;
|
|
21
|
+
return [
|
|
22
|
+
...acc,
|
|
23
|
+
factory.createPropertyAssignment(factory.createIdentifier(parameterKind), factory.createObjectLiteralExpression(operationParameters.map((parameter) => factory.createPropertyAssignment(factory.createStringLiteral(parameter.name), parameter.example // todo:: add example type inferring
|
|
24
|
+
? factory.createStringLiteral(parameter.example)
|
|
25
|
+
: factory.createIdentifier(transformOperationParameterIdentifier
|
|
26
|
+
? transformOperationParameterIdentifier(parameter)
|
|
27
|
+
: camelcase(parameter.name)))), true)),
|
|
28
|
+
];
|
|
29
|
+
}, []);
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=createOperationMethodParametersExampleNodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOperationMethodParametersExampleNodes.js","sourceRoot":"","sources":["../../../../src/ts-factory/tsdoc/lib/createOperationMethodParametersExampleNodes.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,CAAC,MAAM,2CAA2C,GAAG,CACzD,SAA2B,EAC3B,qCAEW,EACc,EAAE;IAC3B,IAAI,CAAC,SAAS,CAAC,UAAU;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,kBAAkB,GAAG,SAAS,CAAC,UAAU;SAC5C,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;SAChC,MAAM,CACL,CAAC,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,KAAK,CACxE,CAAC;IAEJ,MAAM,2BAA2B,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,CAC7D,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAClC,CAAC;IAEF,OAAO,kBAAkB,CAAC,MAAM,CAC9B,CAAC,GAAG,EAAE,aAAa,EAAE,EAAE;QACrB,IAAI,mBAAmB,GAAG,2BAA2B,CAAC,MAAM,CAC1D,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,aAAa,CAC9C,CAAC;QAEF,IAAI,CAAC,mBAAmB,CAAC,MAAM,EAAE,CAAC;YAChC,MAAM,kBAAkB,GAAG,SAAS,CAAC,UAAU,EAAE,IAAI,CACnD,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,aAAa,CAC9C,CAAC;YACF,IAAI,kBAAkB,EAAE,CAAC;gBACvB,mBAAmB,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QAED,IAAI,CAAC,mBAAmB,CAAC,MAAM;YAAE,OAAO,GAAG,CAAC;QAE5C,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;QAE3B,OAAO;YACL,GAAG,GAAG;YACN,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,EACvC,OAAO,CAAC,6BAA6B,CACnC,mBAAmB,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CACpC,OAAO,CAAC,wBAAwB,CAC9B,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,IAAI,CAAC,EAC3C,SAAS,CAAC,OAAO,CAAC,oCAAoC;gBACpD,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,OAAO,CAAC;gBAChD,CAAC,CAAC,OAAO,CAAC,gBAAgB,CACtB,qCAAqC;oBACnC,CAAC,CAAC,qCAAqC,CAAC,SAAS,CAAC;oBAClD,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAC9B,CACN,CACF,EACD,IAAI,CACL,CACF;SACF,CAAC;IACJ,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/tanstack-query-react-plugin",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "tsc --project tsconfig.build.json",
|
|
7
|
+
"codegen": "yarn exec ./generate-ts-factory.mjs",
|
|
7
8
|
"dev": "yarn build --watch --noEmitOnError false",
|
|
8
9
|
"test": "vitest run",
|
|
9
10
|
"typecheck": "tsc --noEmit",
|
|
@@ -26,16 +27,18 @@
|
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
|
-
"@openapi-qraft/plugin": "^2.0.0-next.
|
|
30
|
-
"typescript": "^5.
|
|
30
|
+
"@openapi-qraft/plugin": "^2.0.0-next.9",
|
|
31
|
+
"typescript": "^5.6.2"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@openapi-qraft/eslint-config": "1.0.0",
|
|
34
35
|
"@openapi-qraft/test-fixtures": "1.0.0",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
36
|
+
"@openapi-qraft/ts-factory-code-generator": "1.0.0",
|
|
37
|
+
"camelcase": "^8.0.0",
|
|
38
|
+
"eslint": "^9.10.0",
|
|
39
|
+
"memfs": "^4.11.1",
|
|
37
40
|
"rimraf": "^5.0.10",
|
|
38
|
-
"vitest": "^1.
|
|
41
|
+
"vitest": "^1.6.0"
|
|
39
42
|
},
|
|
40
43
|
"files": [
|
|
41
44
|
"dist",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/getServices';
|
|
2
|
+
|
|
3
|
+
export const createOperationCommonTSDoc = (operation: ServiceOperation) => {
|
|
4
|
+
return [
|
|
5
|
+
operation.deprecated ? '@deprecated' : null,
|
|
6
|
+
operation.summary ? `@summary ${operation.summary}` : null,
|
|
7
|
+
operation.description ? `@description ${operation.description}` : null,
|
|
8
|
+
].filter((comment): comment is NonNullable<typeof comment> =>
|
|
9
|
+
Boolean(comment)
|
|
10
|
+
);
|
|
11
|
+
};
|
package/src/plugin.ts
CHANGED
|
@@ -26,17 +26,11 @@ export const plugin: QraftCommandPlugin = {
|
|
|
26
26
|
return arg?.toLowerCase() !== 'false';
|
|
27
27
|
}
|
|
28
28
|
)
|
|
29
|
-
.option(
|
|
30
|
-
'--operation-generics-import-path <path>',
|
|
31
|
-
'Path to operation generics file',
|
|
32
|
-
'@openapi-qraft/react'
|
|
33
|
-
)
|
|
34
29
|
.action(async ({ spinner, output, args, services, schema }, resolve) => {
|
|
35
30
|
return void (await generateCode({
|
|
36
31
|
spinner,
|
|
37
32
|
services,
|
|
38
33
|
serviceImports: {
|
|
39
|
-
operationGenericsImportPath: args.operationGenericsImportPath,
|
|
40
34
|
openapiTypesImportPath: args.openapiTypesImportPath,
|
|
41
35
|
},
|
|
42
36
|
output: {
|