@7nohe/openapi-react-query-codegen 1.3.0 → 1.4.0
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/dist/createUseQuery.mjs +2 -8
- package/dist/generate.mjs +5 -3
- package/package.json +3 -2
package/dist/createUseQuery.mjs
CHANGED
|
@@ -122,7 +122,7 @@ export function createQueryHook({ queryString, suffix, responseDataType, request
|
|
|
122
122
|
.flatMap((param) => extractPropertiesFromObjectParam(param).map((p) => ts.factory.createShorthandPropertyAssignment(ts.factory.createIdentifier(p.name))))),
|
|
123
123
|
ts.factory.createIdentifier("queryKey"),
|
|
124
124
|
]
|
|
125
|
-
: [])),
|
|
125
|
+
: [ts.factory.createIdentifier("queryKey")])),
|
|
126
126
|
ts.factory.createPropertyAssignment(ts.factory.createIdentifier("queryFn"), ts.factory.createArrowFunction(undefined, undefined, [], undefined, EqualsOrGreaterThanToken, ts.factory.createAsExpression(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(className), ts.factory.createIdentifier(methodName)), undefined, method.getParameters().length
|
|
127
127
|
? [
|
|
128
128
|
ts.factory.createObjectLiteralExpression(method
|
|
@@ -191,16 +191,10 @@ function createQueryKeyFnExport(queryKey, method) {
|
|
|
191
191
|
// override key is used to allow the user to override the the queryKey values
|
|
192
192
|
const overrideKey = ts.factory.createParameterDeclaration(undefined, undefined, ts.factory.createIdentifier("queryKey"), QuestionToken, ts.factory.createTypeReferenceNode("Array<unknown>", []));
|
|
193
193
|
return ts.factory.createVariableStatement([ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
|
|
194
|
-
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(getQueryKeyFnName(queryKey)), undefined, undefined, ts.factory.createArrowFunction(undefined, undefined, params ? [params, overrideKey] : [], undefined, EqualsOrGreaterThanToken, queryKeyFn(queryKey, method))),
|
|
194
|
+
ts.factory.createVariableDeclaration(ts.factory.createIdentifier(getQueryKeyFnName(queryKey)), undefined, undefined, ts.factory.createArrowFunction(undefined, undefined, params ? [params, overrideKey] : [overrideKey], undefined, EqualsOrGreaterThanToken, queryKeyFn(queryKey, method))),
|
|
195
195
|
], ts.NodeFlags.Const));
|
|
196
196
|
}
|
|
197
197
|
function queryKeyFn(queryKey, method) {
|
|
198
|
-
const params = getRequestParamFromMethod(method);
|
|
199
|
-
if (!params) {
|
|
200
|
-
return ts.factory.createArrayLiteralExpression([
|
|
201
|
-
ts.factory.createIdentifier(queryKey),
|
|
202
|
-
]);
|
|
203
|
-
}
|
|
204
198
|
return ts.factory.createArrayLiteralExpression([
|
|
205
199
|
ts.factory.createIdentifier(queryKey),
|
|
206
200
|
ts.factory.createSpreadElement(ts.factory.createParenthesizedExpression(ts.factory.createBinaryExpression(ts.factory.createIdentifier("queryKey"), ts.factory.createToken(ts.SyntaxKind.QuestionQuestionToken), method.getParameters().length
|
package/dist/generate.mjs
CHANGED
|
@@ -12,10 +12,12 @@ export async function generate(options, version) {
|
|
|
12
12
|
debug: formattedOptions.debug,
|
|
13
13
|
dryRun: false,
|
|
14
14
|
exportCore: true,
|
|
15
|
-
|
|
15
|
+
output: {
|
|
16
|
+
format: formattedOptions.format,
|
|
17
|
+
lint: formattedOptions.lint,
|
|
18
|
+
path: openApiOutputPath,
|
|
19
|
+
},
|
|
16
20
|
input: formattedOptions.input,
|
|
17
|
-
lint: formattedOptions.lint,
|
|
18
|
-
output: openApiOutputPath,
|
|
19
21
|
request: formattedOptions.request,
|
|
20
22
|
schemas: {
|
|
21
23
|
export: !formattedOptions.noSchemas,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@7nohe/openapi-react-query-codegen",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "OpenAPI React Query Codegen",
|
|
5
5
|
"bin": {
|
|
6
6
|
"openapi-rq": "dist/cli.mjs"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"author": "Daiki Urata (@7nohe)",
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@hey-api/openapi-ts": "0.
|
|
34
|
+
"@hey-api/openapi-ts": "0.45.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@biomejs/biome": "^1.7.2",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"lefthook": "^1.6.10",
|
|
43
43
|
"rimraf": "^5.0.5",
|
|
44
44
|
"ts-morph": "^22.0.0",
|
|
45
|
+
"ts-node": "^10.9.2",
|
|
45
46
|
"typescript": "^5.3.3",
|
|
46
47
|
"vitest": "^1.5.0"
|
|
47
48
|
},
|