@openapi-qraft/tanstack-query-react-plugin 2.4.1 → 2.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/generateCode.d.ts +2 -2
- package/dist/generateCode.d.ts.map +1 -1
- package/dist/generateCode.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -3
- package/dist/plugin.js.map +1 -1
- package/dist/ts-factory/getIndexFactory.d.ts +2 -2
- package/dist/ts-factory/getIndexFactory.d.ts.map +1 -1
- package/dist/ts-factory/getIndexFactory.js.map +1 -1
- package/dist/ts-factory/getServiceFactory.d.ts +3 -2
- package/dist/ts-factory/getServiceFactory.d.ts.map +1 -1
- package/dist/ts-factory/getServiceFactory.js +127 -52
- package/dist/ts-factory/getServiceFactory.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationCancelQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.js +12 -12
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchInfiniteQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.js +10 -10
- package/dist/ts-factory/service-operation.generated/ServiceOperationFetchQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetInfiniteQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueriesData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.js +5 -5
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js +11 -11
- package/dist/ts-factory/service-operation.generated/ServiceOperationGetQueryState.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js +2 -2
- package/dist/ts-factory/service-operation.generated/ServiceOperationInvalidateQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsFetchingQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationIsMutatingQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationMutationFn.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationQueryFn.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationRefetchQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationRemoveQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationResetQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js +8 -8
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetInfiniteQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueriesData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js +5 -5
- package/dist/ts-factory/service-operation.generated/ServiceOperationSetQueryData.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js +19 -19
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseInfiniteQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsFetchingQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js +3 -3
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseIsMutating.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js +7 -7
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutation.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js +5 -5
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseMutationState.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.js +2 -2
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js +15 -15
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js +9 -9
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseInfiniteQuery.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.js +2 -2
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQueries.js.map +1 -1
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js +6 -6
- package/dist/ts-factory/service-operation.generated/ServiceOperationUseSuspenseQuery.js.map +1 -1
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.js +8 -8
- package/dist/ts-factory/tsdoc/createOperationMethodTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.js +10 -5
- package/dist/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.js +9 -3
- package/dist/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.d.ts +3 -2
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.js +15 -6
- package/dist/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.js +11 -5
- package/dist/ts-factory/tsdoc/createUseQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.js +10 -5
- package/dist/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.js +3 -3
- package/dist/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.d.ts +2 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.d.ts.map +1 -1
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.js +11 -5
- package/dist/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.js.map +1 -1
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.d.ts +3 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.d.ts.map +1 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.js +5 -0
- package/dist/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.js.map +1 -0
- package/package.json +3 -3
- package/src/generateCode.ts +5 -5
- package/src/plugin.ts +11 -3
- package/src/ts-factory/getIndexFactory.ts +2 -2
- package/src/ts-factory/getServiceFactory.ts +262 -90
- package/src/ts-factory/tsdoc/createOperationMethodTSDocExample.ts +17 -8
- package/src/ts-factory/tsdoc/createUseInfiniteQueryOperationTSDocExample.ts +16 -7
- package/src/ts-factory/tsdoc/createUseIsFetchingOperationTSDocExample.ts +19 -3
- package/src/ts-factory/tsdoc/createUseQueriesOperationTSDocExample.ts +40 -10
- package/src/ts-factory/tsdoc/createUseQueryOperationTSDocExample.ts +17 -5
- package/src/ts-factory/tsdoc/createUseSuspenseInfiniteQueryOperationTSDocExample.ts +16 -7
- package/src/ts-factory/tsdoc/createUseSuspenseQueriesOperationTSDocExample.ts +13 -3
- package/src/ts-factory/tsdoc/createUseSuspenseQueryOperationTSDocExample.ts +17 -5
- package/src/ts-factory/tsdoc/lib/createOperationMethodBodyParametersExampleNode.ts +13 -0
|
@@ -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
|
]
|
|
@@ -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;
|