@openapi-qraft/tanstack-query-react-plugin 2.5.0-beta.0 → 2.5.0-beta.2
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 +20 -0
- package/dist/ts-factory/getServiceFactory.js +24 -16
- 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 +4 -4
- package/src/ts-factory/getServiceFactory.ts +56 -34
- 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,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
|
]
|
|
@@ -2,13 +2,18 @@ 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';
|
|
5
6
|
import { createInfiniteQueryOptionsArgumentExamplePropertyAssignmentNodes } from './createUseInfiniteQueryOperationTSDocExample.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 createUseSuspenseInfiniteQueryOperationTSDocExample = (
|
|
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
|
|
|
@@ -37,12 +42,16 @@ export const createUseSuspenseInfiniteQueryOperationTSDocExample = (
|
|
|
37
42
|
},
|
|
38
43
|
[
|
|
39
44
|
factory.createObjectLiteralExpression(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
[
|
|
46
|
+
queryableWriteOperations &&
|
|
47
|
+
createOperationMethodBodyParametersExampleNode(operation),
|
|
48
|
+
...createOperationMethodParametersExampleNodes({
|
|
49
|
+
...operation,
|
|
50
|
+
parameters: operation.parameters?.filter((parameter) =>
|
|
51
|
+
parameter.in === 'query' ? parameter.required : true
|
|
52
|
+
),
|
|
53
|
+
}),
|
|
54
|
+
].filter((node) => !!node),
|
|
46
55
|
true
|
|
47
56
|
),
|
|
48
57
|
factory.createObjectLiteralExpression(
|
|
@@ -3,6 +3,7 @@ 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';
|
|
6
7
|
import {
|
|
7
8
|
createCombinedResultsForEachExpression,
|
|
8
9
|
createCombineFunction,
|
|
@@ -13,7 +14,8 @@ import { createOperationMethodCallExpressionExampleNode } from './lib/createOper
|
|
|
13
14
|
|
|
14
15
|
export const createUseSuspenseQueriesOperationTSDocExample = (
|
|
15
16
|
operation: ServiceOperation,
|
|
16
|
-
serviceVariableName: string
|
|
17
|
+
serviceVariableName: string,
|
|
18
|
+
options: Pick<ServiceFactoryOptions, 'queryableWriteOperations'>
|
|
17
19
|
) => {
|
|
18
20
|
const factory = ts.factory;
|
|
19
21
|
|
|
@@ -46,7 +48,11 @@ export const createUseSuspenseQueriesOperationTSDocExample = (
|
|
|
46
48
|
[
|
|
47
49
|
factory.createPropertyAssignment(
|
|
48
50
|
factory.createIdentifier('queries'),
|
|
49
|
-
createQueriesArrayExpression(
|
|
51
|
+
createQueriesArrayExpression(
|
|
52
|
+
operation,
|
|
53
|
+
factory,
|
|
54
|
+
options
|
|
55
|
+
)
|
|
50
56
|
),
|
|
51
57
|
],
|
|
52
58
|
true
|
|
@@ -95,7 +101,11 @@ export const createUseSuspenseQueriesOperationTSDocExample = (
|
|
|
95
101
|
),
|
|
96
102
|
factory.createPropertyAssignment(
|
|
97
103
|
factory.createIdentifier('queries'),
|
|
98
|
-
createQueriesArrayExpression(
|
|
104
|
+
createQueriesArrayExpression(
|
|
105
|
+
operation,
|
|
106
|
+
factory,
|
|
107
|
+
options
|
|
108
|
+
)
|
|
99
109
|
),
|
|
100
110
|
],
|
|
101
111
|
true
|
|
@@ -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 createUseSuspenseQueryOperationTSDocExample = (
|
|
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 with Suspense support.',
|
|
@@ -18,8 +23,8 @@ export const createUseSuspenseQueryOperationTSDocExample = (
|
|
|
18
23
|
];
|
|
19
24
|
|
|
20
25
|
if (
|
|
21
|
-
!operation.parameters?.
|
|
22
|
-
|
|
26
|
+
!operation.parameters?.some((parameter) => parameter.required) &&
|
|
27
|
+
!(queryableWriteOperations && operation.requestBody?.required)
|
|
23
28
|
) {
|
|
24
29
|
example.push(
|
|
25
30
|
'@example Suspense Query without parameters',
|
|
@@ -43,7 +48,10 @@ export const createUseSuspenseQueryOperationTSDocExample = (
|
|
|
43
48
|
);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
if (
|
|
51
|
+
if (
|
|
52
|
+
operation.parameters?.length ||
|
|
53
|
+
(queryableWriteOperations && operation.requestBody)
|
|
54
|
+
) {
|
|
47
55
|
const factory = ts.factory;
|
|
48
56
|
|
|
49
57
|
example.push(
|
|
@@ -60,7 +68,11 @@ export const createUseSuspenseQueryOperationTSDocExample = (
|
|
|
60
68
|
},
|
|
61
69
|
[
|
|
62
70
|
factory.createObjectLiteralExpression(
|
|
63
|
-
|
|
71
|
+
[
|
|
72
|
+
queryableWriteOperations &&
|
|
73
|
+
createOperationMethodBodyParametersExampleNode(operation),
|
|
74
|
+
...createOperationMethodParametersExampleNodes(operation),
|
|
75
|
+
].filter((node) => !!node),
|
|
64
76
|
true
|
|
65
77
|
),
|
|
66
78
|
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ServiceOperation } from '@openapi-qraft/plugin/lib/open-api/OpenAPIService';
|
|
2
|
+
import { factory } from 'typescript';
|
|
3
|
+
|
|
4
|
+
export const createOperationMethodBodyParametersExampleNode = (
|
|
5
|
+
operation: ServiceOperation,
|
|
6
|
+
bodyVariableName = 'queryBody'
|
|
7
|
+
) =>
|
|
8
|
+
operation.requestBody
|
|
9
|
+
? factory.createPropertyAssignment(
|
|
10
|
+
factory.createIdentifier('body'),
|
|
11
|
+
factory.createIdentifier(bodyVariableName)
|
|
12
|
+
)
|
|
13
|
+
: undefined;
|