@openapi-qraft/tanstack-query-react-plugin 1.11.0-beta.2 → 1.11.0-beta.4
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 +12 -0
- package/dist/ts-factory/getClientFactory.d.ts +1 -1
- package/dist/ts-factory/getClientFactory.d.ts.map +1 -1
- package/dist/ts-factory/getClientFactory.js +1 -46
- package/dist/ts-factory/getClientFactory.js.map +1 -1
- package/dist/ts-factory/getServiceFactory.d.ts +1 -1
- package/package.json +5 -4
- package/src/__snapshots__/create-api-client.ts.snapshot.ts +1 -38
- package/src/ts-factory/getClientFactory.ts +4 -73
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @openapi-qraft/tanstack-query-react-plugin
|
|
2
2
|
|
|
3
|
+
## 1.11.0-beta.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @openapi-qraft/plugin@1.11.0-beta.4
|
|
8
|
+
|
|
9
|
+
## 1.11.0-beta.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- @openapi-qraft/plugin@1.11.0-beta.3
|
|
14
|
+
|
|
3
15
|
## 1.11.0-beta.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -3,6 +3,6 @@ type Options = {
|
|
|
3
3
|
servicesDirName: string;
|
|
4
4
|
explicitImportExtensions: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare const getClientFactory: (options: Options) => (ts.ImportDeclaration | ts.
|
|
6
|
+
export declare const getClientFactory: (options: Options) => (ts.ImportDeclaration | ts.FunctionDeclaration)[];
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=getClientFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClientFactory.d.ts","sourceRoot":"","sources":["../../src/ts-factory/getClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,OAAO,
|
|
1
|
+
{"version":3,"file":"getClientFactory.d.ts","sourceRoot":"","sources":["../../src/ts-factory/getClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,KAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,OAAO,sDAKhD,CAAC"}
|
|
@@ -2,7 +2,6 @@ import ts from 'typescript';
|
|
|
2
2
|
export const getClientFactory = (options) => {
|
|
3
3
|
return [
|
|
4
4
|
...getClientImportsFactory(options),
|
|
5
|
-
getCallbacksVariableFactory(),
|
|
6
5
|
getCreateClientFunctionFactory(),
|
|
7
6
|
];
|
|
8
7
|
};
|
|
@@ -12,7 +11,7 @@ const getClientImportsFactory = ({ servicesDirName, explicitImportExtensions, })
|
|
|
12
11
|
factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
13
12
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('qraftAPIClient')),
|
|
14
13
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('QraftClientOptions')),
|
|
15
|
-
|
|
14
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier('callbacks')),
|
|
16
15
|
])), factory.createStringLiteral('@openapi-qraft/react'), undefined),
|
|
17
16
|
factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
18
17
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('services')),
|
|
@@ -20,12 +19,6 @@ const getClientImportsFactory = ({ servicesDirName, explicitImportExtensions, })
|
|
|
20
19
|
])), factory.createStringLiteral(`./${servicesDirName}/index${explicitImportExtensions ? '.js' : ''}`), undefined),
|
|
21
20
|
];
|
|
22
21
|
};
|
|
23
|
-
const getCallbacksVariableFactory = () => {
|
|
24
|
-
const factory = ts.factory;
|
|
25
|
-
return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
|
|
26
|
-
factory.createVariableDeclaration(factory.createIdentifier('callbacks'), undefined, undefined, factory.createObjectLiteralExpression(serviceCallbacks.map((propertyName) => factory.createShorthandPropertyAssignment(factory.createIdentifier(propertyName), undefined)), true)),
|
|
27
|
-
], ts.NodeFlags.Const));
|
|
28
|
-
};
|
|
29
22
|
const getCreateClientFunctionFactory = () => {
|
|
30
23
|
const factory = ts.factory;
|
|
31
24
|
return factory.createFunctionDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword)], undefined, factory.createIdentifier('createAPIClient'), undefined, [
|
|
@@ -41,42 +34,4 @@ const getCreateClientFunctionFactory = () => {
|
|
|
41
34
|
])),
|
|
42
35
|
], true));
|
|
43
36
|
};
|
|
44
|
-
// todo::make callbacks type-safe
|
|
45
|
-
const serviceCallbacks = [
|
|
46
|
-
'getInfiniteQueryData',
|
|
47
|
-
'getInfiniteQueryKey',
|
|
48
|
-
'getMutationKey',
|
|
49
|
-
'getQueryData',
|
|
50
|
-
'getQueriesData',
|
|
51
|
-
'getQueryKey',
|
|
52
|
-
'mutationFn',
|
|
53
|
-
'queryFn',
|
|
54
|
-
'setInfiniteQueryData',
|
|
55
|
-
'setQueryData',
|
|
56
|
-
'setQueriesData',
|
|
57
|
-
'useInfiniteQuery',
|
|
58
|
-
'useMutation',
|
|
59
|
-
'useQuery',
|
|
60
|
-
'useSuspenseQuery',
|
|
61
|
-
'useSuspenseInfiniteQuery',
|
|
62
|
-
'useMutationState',
|
|
63
|
-
'useIsMutating',
|
|
64
|
-
'useQueries',
|
|
65
|
-
'useSuspenseQueries',
|
|
66
|
-
'invalidateQueries',
|
|
67
|
-
'cancelQueries',
|
|
68
|
-
'resetQueries',
|
|
69
|
-
'removeQueries',
|
|
70
|
-
'refetchQueries',
|
|
71
|
-
'isFetching',
|
|
72
|
-
'isMutating',
|
|
73
|
-
'useIsFetching',
|
|
74
|
-
'fetchQuery',
|
|
75
|
-
'prefetchQuery',
|
|
76
|
-
'fetchInfiniteQuery',
|
|
77
|
-
'prefetchInfiniteQuery',
|
|
78
|
-
'getQueryState',
|
|
79
|
-
'getInfiniteQueryState',
|
|
80
|
-
'operationInvokeFn',
|
|
81
|
-
];
|
|
82
37
|
//# sourceMappingURL=getClientFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getClientFactory.js","sourceRoot":"","sources":["../../src/ts-factory/getClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAO5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,EAAE;IACnD,OAAO;QACL,GAAG,uBAAuB,CAAC,OAAO,CAAC;QACnC,
|
|
1
|
+
{"version":3,"file":"getClientFactory.js","sourceRoot":"","sources":["../../src/ts-factory/getClientFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAO5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAE,EAAE;IACnD,OAAO;QACL,GAAG,uBAAuB,CAAC,OAAO,CAAC;QACnC,8BAA8B,EAAE;KACjC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,EAC/B,eAAe,EACf,wBAAwB,GAChB,EAAE,EAAE;IACZ,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAE3B,OAAO;QACL,OAAO,CAAC,uBAAuB,CAC7B,SAAS,EACT,OAAO,CAAC,kBAAkB,CACxB,KAAK,EACL,SAAS,EACT,OAAO,CAAC,kBAAkB,CAAC;YACzB,OAAO,CAAC,qBAAqB,CAC3B,KAAK,EACL,SAAS,EACT,OAAO,CAAC,gBAAgB,CAAC,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D,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,EAC9C,SAAS,CACV,EACD,SAAS,CACV;KACF,EACD,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,EACpC,SAAS,CACV,EACD,OAAO,CAAC,WAAW,CACjB;QACE,OAAO,CAAC,qBAAqB,CAC3B,OAAO,CAAC,oBAAoB,CAC1B,OAAO,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,EAC1C;YACE,OAAO,CAAC,uBAAuB,CAC7B,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,EACpC,SAAS,CACV;YACD,OAAO,CAAC,mBAAmB,CACzB,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC,EACrC,SAAS,CACV;SACF,EACD;YACE,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC;YACpC,OAAO,CAAC,gBAAgB,CAAC,WAAW,CAAC;YACrC,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC;SACpC,CACF,CACF;KACF,EACD,IAAI,CACL,CACF,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -7,5 +7,5 @@ export type ServiceImportsFactoryOptions = {
|
|
|
7
7
|
export declare const getServiceFactory: (service: {
|
|
8
8
|
typeName: string;
|
|
9
9
|
variableName: string;
|
|
10
|
-
}, operations: ServiceOperation[], { openapiTypesImportPath, operationGenericsImportPath, }: ServiceImportsFactoryOptions) => (ts.ImportDeclaration | ts.
|
|
10
|
+
}, operations: ServiceOperation[], { openapiTypesImportPath, operationGenericsImportPath, }: ServiceImportsFactoryOptions) => (ts.ImportDeclaration | ts.InterfaceDeclaration | ts.VariableStatement)[];
|
|
11
11
|
//# sourceMappingURL=getServiceFactory.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openapi-qraft/tanstack-query-react-plugin",
|
|
3
|
-
"version": "1.11.0-beta.
|
|
3
|
+
"version": "1.11.0-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "tsc --project tsconfig.build.json",
|
|
7
7
|
"dev": "yarn build --watch",
|
|
8
8
|
"test": "vitest run",
|
|
9
9
|
"typecheck": "tsc --noEmit",
|
|
10
|
-
"lint": "eslint"
|
|
10
|
+
"lint": "eslint",
|
|
11
|
+
"clean": "rimraf dist/"
|
|
11
12
|
},
|
|
12
13
|
"publishConfig": {
|
|
13
14
|
"access": "public"
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@openapi-qraft/plugin": "^1.11.0-beta.
|
|
29
|
+
"@openapi-qraft/plugin": "^1.11.0-beta.4",
|
|
29
30
|
"typescript": "^5.3.3"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
@@ -3,45 +3,8 @@
|
|
|
3
3
|
* Do not make direct changes to the file.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { qraftAPIClient, QraftClientOptions,
|
|
6
|
+
import { qraftAPIClient, QraftClientOptions, callbacks } from "@openapi-qraft/react";
|
|
7
7
|
import { services, Services } from "./services/index.js";
|
|
8
|
-
const callbacks = {
|
|
9
|
-
getInfiniteQueryData,
|
|
10
|
-
getInfiniteQueryKey,
|
|
11
|
-
getMutationKey,
|
|
12
|
-
getQueryData,
|
|
13
|
-
getQueriesData,
|
|
14
|
-
getQueryKey,
|
|
15
|
-
mutationFn,
|
|
16
|
-
queryFn,
|
|
17
|
-
setInfiniteQueryData,
|
|
18
|
-
setQueryData,
|
|
19
|
-
setQueriesData,
|
|
20
|
-
useInfiniteQuery,
|
|
21
|
-
useMutation,
|
|
22
|
-
useQuery,
|
|
23
|
-
useSuspenseQuery,
|
|
24
|
-
useSuspenseInfiniteQuery,
|
|
25
|
-
useMutationState,
|
|
26
|
-
useIsMutating,
|
|
27
|
-
useQueries,
|
|
28
|
-
useSuspenseQueries,
|
|
29
|
-
invalidateQueries,
|
|
30
|
-
cancelQueries,
|
|
31
|
-
resetQueries,
|
|
32
|
-
removeQueries,
|
|
33
|
-
refetchQueries,
|
|
34
|
-
isFetching,
|
|
35
|
-
isMutating,
|
|
36
|
-
useIsFetching,
|
|
37
|
-
fetchQuery,
|
|
38
|
-
prefetchQuery,
|
|
39
|
-
fetchInfiniteQuery,
|
|
40
|
-
prefetchInfiniteQuery,
|
|
41
|
-
getQueryState,
|
|
42
|
-
getInfiniteQueryState,
|
|
43
|
-
operationInvokeFn
|
|
44
|
-
};
|
|
45
8
|
export function createAPIClient(options?: QraftClientOptions): Services {
|
|
46
9
|
return qraftAPIClient<Services, typeof callbacks>(services, callbacks, options);
|
|
47
10
|
}
|
|
@@ -8,7 +8,6 @@ type Options = {
|
|
|
8
8
|
export const getClientFactory = (options: Options) => {
|
|
9
9
|
return [
|
|
10
10
|
...getClientImportsFactory(options),
|
|
11
|
-
getCallbacksVariableFactory(),
|
|
12
11
|
getCreateClientFunctionFactory(),
|
|
13
12
|
];
|
|
14
13
|
};
|
|
@@ -36,12 +35,10 @@ const getClientImportsFactory = ({
|
|
|
36
35
|
undefined,
|
|
37
36
|
factory.createIdentifier('QraftClientOptions')
|
|
38
37
|
),
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
factory.createIdentifier(propertyName)
|
|
44
|
-
)
|
|
38
|
+
factory.createImportSpecifier(
|
|
39
|
+
false,
|
|
40
|
+
undefined,
|
|
41
|
+
factory.createIdentifier('callbacks')
|
|
45
42
|
),
|
|
46
43
|
])
|
|
47
44
|
),
|
|
@@ -74,33 +71,6 @@ const getClientImportsFactory = ({
|
|
|
74
71
|
];
|
|
75
72
|
};
|
|
76
73
|
|
|
77
|
-
const getCallbacksVariableFactory = () => {
|
|
78
|
-
const factory = ts.factory;
|
|
79
|
-
|
|
80
|
-
return factory.createVariableStatement(
|
|
81
|
-
undefined,
|
|
82
|
-
factory.createVariableDeclarationList(
|
|
83
|
-
[
|
|
84
|
-
factory.createVariableDeclaration(
|
|
85
|
-
factory.createIdentifier('callbacks'),
|
|
86
|
-
undefined,
|
|
87
|
-
undefined,
|
|
88
|
-
factory.createObjectLiteralExpression(
|
|
89
|
-
serviceCallbacks.map((propertyName) =>
|
|
90
|
-
factory.createShorthandPropertyAssignment(
|
|
91
|
-
factory.createIdentifier(propertyName),
|
|
92
|
-
undefined
|
|
93
|
-
)
|
|
94
|
-
),
|
|
95
|
-
true
|
|
96
|
-
)
|
|
97
|
-
),
|
|
98
|
-
],
|
|
99
|
-
ts.NodeFlags.Const
|
|
100
|
-
)
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
74
|
const getCreateClientFunctionFactory = () => {
|
|
105
75
|
const factory = ts.factory;
|
|
106
76
|
|
|
@@ -153,42 +123,3 @@ const getCreateClientFunctionFactory = () => {
|
|
|
153
123
|
)
|
|
154
124
|
);
|
|
155
125
|
};
|
|
156
|
-
|
|
157
|
-
// todo::make callbacks type-safe
|
|
158
|
-
const serviceCallbacks = [
|
|
159
|
-
'getInfiniteQueryData',
|
|
160
|
-
'getInfiniteQueryKey',
|
|
161
|
-
'getMutationKey',
|
|
162
|
-
'getQueryData',
|
|
163
|
-
'getQueriesData',
|
|
164
|
-
'getQueryKey',
|
|
165
|
-
'mutationFn',
|
|
166
|
-
'queryFn',
|
|
167
|
-
'setInfiniteQueryData',
|
|
168
|
-
'setQueryData',
|
|
169
|
-
'setQueriesData',
|
|
170
|
-
'useInfiniteQuery',
|
|
171
|
-
'useMutation',
|
|
172
|
-
'useQuery',
|
|
173
|
-
'useSuspenseQuery',
|
|
174
|
-
'useSuspenseInfiniteQuery',
|
|
175
|
-
'useMutationState',
|
|
176
|
-
'useIsMutating',
|
|
177
|
-
'useQueries',
|
|
178
|
-
'useSuspenseQueries',
|
|
179
|
-
'invalidateQueries',
|
|
180
|
-
'cancelQueries',
|
|
181
|
-
'resetQueries',
|
|
182
|
-
'removeQueries',
|
|
183
|
-
'refetchQueries',
|
|
184
|
-
'isFetching',
|
|
185
|
-
'isMutating',
|
|
186
|
-
'useIsFetching',
|
|
187
|
-
'fetchQuery',
|
|
188
|
-
'prefetchQuery',
|
|
189
|
-
'fetchInfiniteQuery',
|
|
190
|
-
'prefetchInfiniteQuery',
|
|
191
|
-
'getQueryState',
|
|
192
|
-
'getInfiniteQueryState',
|
|
193
|
-
'operationInvokeFn',
|
|
194
|
-
] as const;
|