hono-takibi 0.11.1 → 0.12.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/README.md +1 -0
- package/dist/cli.js +2 -2
- package/dist/core/docs/index.js +1 -1
- package/dist/core/hooks/index.js +1 -1
- package/dist/core/rpc/index.js +4 -3
- package/dist/core/type/index.js +1 -1
- package/dist/{core-BtueRJN7.js → core-Binj-uPh.js} +13 -9
- package/dist/{docs-C1_fNNJ-.js → docs-Bo4-6xBy.js} +3 -2
- package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
- package/dist/{hooks-CZkcozjK.js → hooks-DI1jbIMJ.js} +96 -54
- package/dist/{openapi-DhxrYmuQ.js → openapi-4tjo-yX9.js} +7 -4
- package/dist/{rpc-D_eeOVGa.js → rpc-C_Lq1F7-.js} +3 -2
- package/dist/{shared-BgsMAfDf.js → shared-CHGm83qW.js} +4 -4
- package/dist/{utils-DEFpxBMu.js → utils-BtWoIX8v.js} +1 -1
- package/dist/vite-plugin/index.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -327,6 +327,7 @@ usePostUsers({ mutation: { mutationKey: ['custom'], onSuccess } }, queryClient)
|
|
|
327
327
|
```
|
|
328
328
|
|
|
329
329
|
- `options.query` is the library's options type without `queryKey` / `queryFn` (the hook supplies both); `options.mutation` leaves out `mutationFn`, and a `mutationKey` you pass wins over the generated one.
|
|
330
|
+
- Query hooks spread their options factory, so `useUsersId(args, { query })` is `useQuery({ ...getUsersIdQueryOptions(args), ...query })`. The factories take the hooks' `<TData, TError>` (and `TPageParam` for infinite queries) for that reason; leave them off and a direct `getUsersIdQueryOptions(args)` call keeps the default types, ready for `prefetchQuery` / `getQueryData`. Vue Query hooks keep the inline form instead.
|
|
330
331
|
- `options.options` is Hono's `ClientRequestOptions` (headers, fetch, init).
|
|
331
332
|
- The trailing argument is the framework's own: a `QueryClient` (an accessor of one in Solid and Svelte), or `{ injector }` in Angular.
|
|
332
333
|
- Vue hooks accept `Ref` / getter arguments and re-key the query when they change.
|
package/dist/cli.js
CHANGED
|
@@ -71,7 +71,7 @@ function runConfigPass(configPath, reload) {
|
|
|
71
71
|
import("./index.js"),
|
|
72
72
|
import("./openapi-DQRxq2_O.js").then((n) => n.t),
|
|
73
73
|
import("./format-Bm9LZ_ki.js").then((n) => n.r),
|
|
74
|
-
import("./shared-
|
|
74
|
+
import("./shared-CHGm83qW.js").then((n) => n.i)
|
|
75
75
|
]));
|
|
76
76
|
const config = yield* readConfig(configPath, reload);
|
|
77
77
|
const jobs = makeJob(yield* parseOpenAPI(config.input), config);
|
|
@@ -204,7 +204,7 @@ function generate(args) {
|
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
206
|
if (input !== void 0 && output !== void 0) {
|
|
207
|
-
const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-
|
|
207
|
+
const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-Binj-uPh.js").then((n) => n.t)]));
|
|
208
208
|
return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output, ONE_SHOT_COMPONENTS));
|
|
209
209
|
}
|
|
210
210
|
const resolvedConfig = configPath ?? DEFAULT_CONFIG_FILE;
|
package/dist/core/docs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as docs } from "../../docs-
|
|
1
|
+
import { t as docs } from "../../docs-Bo4-6xBy.js";
|
|
2
2
|
export { docs };
|
package/dist/core/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as hooks } from "../../hooks-
|
|
1
|
+
import { t as hooks } from "../../hooks-DI1jbIMJ.js";
|
|
2
2
|
export { hooks };
|
package/dist/core/rpc/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as methodPath, j as isOperationLike, k as isOpenAPIPaths, l as makeInferRequestType, z as isRecord } from "../../utils-
|
|
1
|
+
import { f as methodPath, j as isOperationLike, k as isOpenAPIPaths, l as makeInferRequestType, z as isRecord } from "../../utils-BtWoIX8v.js";
|
|
2
2
|
import { t as emit } from "../../emit-B_3fXoto.js";
|
|
3
|
-
import { a as parsePathItem, i as operationHasArgs, o as resolveSplitOutDir, r as makeOperationDeps, s as GenerateError, t as formatPath } from "../../rpc-
|
|
3
|
+
import { a as parsePathItem, i as operationHasArgs, o as resolveSplitOutDir, r as makeOperationDeps, s as GenerateError, t as formatPath } from "../../rpc-C_Lq1F7-.js";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
6
|
//#region src/core/rpc/index.ts
|
|
@@ -45,7 +45,8 @@ function makeOperationCodes(paths, deps, useParseResponse, hasBasePath, docs) {
|
|
|
45
45
|
"options",
|
|
46
46
|
"head",
|
|
47
47
|
"patch",
|
|
48
|
-
"trace"
|
|
48
|
+
"trace",
|
|
49
|
+
"query"
|
|
49
50
|
].map((method) => {
|
|
50
51
|
const result = makeOperationCode(p, method, pathItem, deps, useParseResponse, hasBasePath, docs);
|
|
51
52
|
return result ? {
|
package/dist/core/type/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as isOperation, D as isMediaWithSchema, H as isRequestBody, M as isParameter, N as isParameterArray, T as isHttpMethod, W as isSchemaArray, X as isStringRef, g as statusCodeToNumber, k as isOpenAPIPaths, u as makeSafeKey } from "../../utils-
|
|
1
|
+
import { A as isOperation, D as isMediaWithSchema, H as isRequestBody, M as isParameter, N as isParameterArray, T as isHttpMethod, W as isSchemaArray, X as isStringRef, g as statusCodeToNumber, k as isOpenAPIPaths, u as makeSafeKey } from "../../utils-BtWoIX8v.js";
|
|
2
2
|
import { t as emit } from "../../emit-B_3fXoto.js";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
import path from "node:path";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-CwKqigE9.js";
|
|
3
3
|
import { n as fmt } from "./format-Bm9LZ_ki.js";
|
|
4
|
-
import { A as isOperation, B as isRefObject, D as isMediaWithSchema, F as isParameterRef, G as isSchemaObject, I as isPathItem, J as isSecurityScheme, L as isPathItemEntry, M as isParameter, R as isPathItemRef, S as isContentBody, T as isHttpMethod, W as isSchemaArray, _ as toIdentifierPascalCase, b as zodToOpenAPISchema, c as makeBarrel, d as makeStringLiteral, f as methodPath, g as statusCodeToNumber, i as ensureSuffix, m as renderNamedImport, p as normalizeTypes, q as isSecurityArray, r as cyclicNodes, u as makeSafeKey, v as uncapitalize, x as isCallbacks, y as uncapitalizeWord } from "./utils-
|
|
4
|
+
import { A as isOperation, B as isRefObject, D as isMediaWithSchema, F as isParameterRef, G as isSchemaObject, I as isPathItem, J as isSecurityScheme, L as isPathItemEntry, M as isParameter, R as isPathItemRef, S as isContentBody, T as isHttpMethod, W as isSchemaArray, _ as toIdentifierPascalCase, b as zodToOpenAPISchema, c as makeBarrel, d as makeStringLiteral, f as methodPath, g as statusCodeToNumber, i as ensureSuffix, m as renderNamedImport, p as normalizeTypes, q as isSecurityArray, r as cyclicNodes, u as makeSafeKey, v as uncapitalize, x as isCallbacks, y as uncapitalizeWord } from "./utils-BtWoIX8v.js";
|
|
5
5
|
import { t as emit } from "./emit-B_3fXoto.js";
|
|
6
|
-
import { s as GenerateError } from "./rpc-
|
|
7
|
-
import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-
|
|
8
|
-
import { t as hooks } from "./hooks-
|
|
9
|
-
import { t as docs } from "./docs-
|
|
6
|
+
import { s as GenerateError } from "./rpc-C_Lq1F7-.js";
|
|
7
|
+
import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-4tjo-yX9.js";
|
|
8
|
+
import { t as hooks } from "./hooks-DI1jbIMJ.js";
|
|
9
|
+
import { t as docs } from "./docs-Bo4-6xBy.js";
|
|
10
10
|
import { rpc } from "./core/rpc/index.js";
|
|
11
11
|
import { type } from "./core/type/index.js";
|
|
12
12
|
import { Effect } from "effect";
|
|
@@ -774,7 +774,8 @@ function filterToJsonContentTypes(openapi) {
|
|
|
774
774
|
"patch",
|
|
775
775
|
"options",
|
|
776
776
|
"head",
|
|
777
|
-
"trace"
|
|
777
|
+
"trace",
|
|
778
|
+
"query"
|
|
778
779
|
].includes(k)) return [k, v];
|
|
779
780
|
if (!hasRequestBodyContent(v)) return [k, v];
|
|
780
781
|
const jsonContent = v.requestBody.content["application/json"];
|
|
@@ -1185,7 +1186,8 @@ function route(openAPI, routes, components, readonly) {
|
|
|
1185
1186
|
"patch",
|
|
1186
1187
|
"options",
|
|
1187
1188
|
"head",
|
|
1188
|
-
"trace"
|
|
1189
|
+
"trace",
|
|
1190
|
+
"query"
|
|
1189
1191
|
].flatMap((method) => {
|
|
1190
1192
|
const operation = resolved[method];
|
|
1191
1193
|
if (!operation?.responses) return [];
|
|
@@ -1566,7 +1568,8 @@ function defineEntries(openapi, readonly) {
|
|
|
1566
1568
|
"patch",
|
|
1567
1569
|
"options",
|
|
1568
1570
|
"head",
|
|
1569
|
-
"trace"
|
|
1571
|
+
"trace",
|
|
1572
|
+
"query"
|
|
1570
1573
|
].flatMap((method) => {
|
|
1571
1574
|
const operation = resolved[method];
|
|
1572
1575
|
if (!operation?.responses) return [];
|
|
@@ -2550,7 +2553,8 @@ function webhooks(openAPI, webhooks, components, readonly) {
|
|
|
2550
2553
|
"patch",
|
|
2551
2554
|
"options",
|
|
2552
2555
|
"head",
|
|
2553
|
-
"trace"
|
|
2556
|
+
"trace",
|
|
2557
|
+
"query"
|
|
2554
2558
|
].filter((m) => pathItem[m]?.responses).flatMap((method) => {
|
|
2555
2559
|
const operation = pathItem[method];
|
|
2556
2560
|
if (!operation) return [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as mkdir, o as writeFile } from "./file-CwKqigE9.js";
|
|
2
|
-
import { B as isRefObject, E as isMedia, G as isSchemaObject, H as isRequestBody, J as isSecurityScheme, O as isOAuthFlowValue, U as isResponses, W as isSchemaArray, k as isOpenAPIPaths, o as escapeHtml, q as isSecurityArray, z as isRecord } from "./utils-
|
|
2
|
+
import { B as isRefObject, E as isMedia, G as isSchemaObject, H as isRequestBody, J as isSecurityScheme, O as isOAuthFlowValue, U as isResponses, W as isSchemaArray, k as isOpenAPIPaths, o as escapeHtml, q as isSecurityArray, z as isRecord } from "./utils-BtWoIX8v.js";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { STATUS_CODES } from "node:http";
|
|
@@ -12,7 +12,8 @@ const HTTP_METHODS = [
|
|
|
12
12
|
"options",
|
|
13
13
|
"head",
|
|
14
14
|
"patch",
|
|
15
|
-
"trace"
|
|
15
|
+
"trace",
|
|
16
|
+
"query"
|
|
16
17
|
];
|
|
17
18
|
const MAX_SCHEMA_DEPTH = 50;
|
|
18
19
|
function toSlug(text) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as zodOpenAPIHono } from "../../../openapi-
|
|
1
|
+
import { t as zodOpenAPIHono } from "../../../openapi-4tjo-yX9.js";
|
|
2
2
|
export { zodOpenAPIHono };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as toIdentifierPascalCase, f as methodPath, j as isOperationLike, k as isOpenAPIPaths, n as capitalize, z as isRecord } from "./utils-
|
|
1
|
+
import { _ as toIdentifierPascalCase, f as methodPath, j as isOperationLike, k as isOpenAPIPaths, n as capitalize, z as isRecord } from "./utils-BtWoIX8v.js";
|
|
2
2
|
import { t as emit } from "./emit-B_3fXoto.js";
|
|
3
|
-
import { a as parsePathItem, i as operationHasArgs, n as hasNoContentResponse, o as resolveSplitOutDir, r as makeOperationDeps, s as GenerateError, t as formatPath } from "./rpc-
|
|
3
|
+
import { a as parsePathItem, i as operationHasArgs, n as hasNoContentResponse, o as resolveSplitOutDir, r as makeOperationDeps, s as GenerateError, t as formatPath } from "./rpc-C_Lq1F7-.js";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
//#region src/helper/query.ts
|
|
@@ -41,9 +41,12 @@ function makeResponseTypeFromClient(clientName, method, pathStr) {
|
|
|
41
41
|
function makeArgsType(clientName, method, pathStr) {
|
|
42
42
|
return `InferRequestType<${makeTypeAccess(clientName, method, pathStr)}>`;
|
|
43
43
|
}
|
|
44
|
+
function queryNameMethod(method) {
|
|
45
|
+
return method === "get" ? "" : method;
|
|
46
|
+
}
|
|
44
47
|
function makeQueryKeyGetterName(method, pathStr, isSWR) {
|
|
45
48
|
if (isSWR) return `get${capitalize(methodPath(method, pathStr))}Key`;
|
|
46
|
-
return `get${capitalize(methodPath(
|
|
49
|
+
return `get${capitalize(methodPath(queryNameMethod(method), pathStr))}QueryKey`;
|
|
47
50
|
}
|
|
48
51
|
function makeMutationKeyGetterName(method, pathStr, isSWR) {
|
|
49
52
|
if (isSWR) return `get${capitalize(methodPath(method, pathStr))}Key`;
|
|
@@ -54,28 +57,30 @@ function makeMutationKeyGetterCode(keyGetterName, method, honoPath) {
|
|
|
54
57
|
}
|
|
55
58
|
function makeInfiniteQueryKeyGetterName(method, pathStr, isSWR) {
|
|
56
59
|
if (isSWR) return `get${capitalize(methodPath(method, pathStr))}InfiniteKey`;
|
|
57
|
-
return `get${capitalize(methodPath(
|
|
60
|
+
return `get${capitalize(methodPath(queryNameMethod(method), pathStr))}InfiniteQueryKey`;
|
|
58
61
|
}
|
|
59
62
|
function vueReactiveKey(keyCall) {
|
|
60
63
|
return `computed(()=>${keyCall})`;
|
|
61
64
|
}
|
|
62
|
-
function makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeader = false) {
|
|
65
|
+
function makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeader = false, method = "get") {
|
|
63
66
|
const prefix = honoPath.replace(/^\//u, "").split("/")[0];
|
|
67
|
+
const methodKey = method === "get" ? "" : `,'${method.toUpperCase()}'`;
|
|
64
68
|
if (config.isVueQuery) {
|
|
65
|
-
if (hasArgs) return `export function ${keyGetterName}(args:MaybeRefOrGetter<${argsType}>){${hasHeader ? "const{header:_,...keyArgs}=toValue(args);return" : "return"}['${prefix}','${honoPath}',${hasHeader ? "keyArgs" : "toValue(args)"}]as const}`;
|
|
66
|
-
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}']as const}`;
|
|
69
|
+
if (hasArgs) return `export function ${keyGetterName}(args:MaybeRefOrGetter<${argsType}>){${hasHeader ? "const{header:_,...keyArgs}=toValue(args);return" : "return"}['${prefix}','${honoPath}'${methodKey},${hasHeader ? "keyArgs" : "toValue(args)"}]as const}`;
|
|
70
|
+
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}'${methodKey}]as const}`;
|
|
67
71
|
}
|
|
68
|
-
if (hasArgs) return `export function ${keyGetterName}(args:${argsType}){${hasHeader ? `const{header:_,...keyArgs}=args;return['${prefix}','${honoPath}',keyArgs]as const` : `return['${prefix}','${honoPath}',args]as const`}}`;
|
|
69
|
-
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}']as const}`;
|
|
72
|
+
if (hasArgs) return `export function ${keyGetterName}(args:${argsType}){${hasHeader ? `const{header:_,...keyArgs}=args;return['${prefix}','${honoPath}'${methodKey},keyArgs]as const` : `return['${prefix}','${honoPath}'${methodKey},args]as const`}}`;
|
|
73
|
+
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}'${methodKey}]as const}`;
|
|
70
74
|
}
|
|
71
|
-
function makeInfiniteQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeader = false) {
|
|
75
|
+
function makeInfiniteQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeader = false, method = "get") {
|
|
72
76
|
const prefix = honoPath.replace(/^\//u, "").split("/")[0];
|
|
77
|
+
const methodKey = method === "get" ? "" : `,'${method.toUpperCase()}'`;
|
|
73
78
|
if (config.isVueQuery) {
|
|
74
|
-
if (hasArgs) return `export function ${keyGetterName}(args:MaybeRefOrGetter<${argsType}>){${hasHeader ? "const{header:_,...keyArgs}=toValue(args);return" : "return"}['${prefix}','${honoPath}','infinite',${hasHeader ? "keyArgs" : "toValue(args)"}]as const}`;
|
|
75
|
-
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}','infinite']as const}`;
|
|
79
|
+
if (hasArgs) return `export function ${keyGetterName}(args:MaybeRefOrGetter<${argsType}>){${hasHeader ? "const{header:_,...keyArgs}=toValue(args);return" : "return"}['${prefix}','${honoPath}'${methodKey},'infinite',${hasHeader ? "keyArgs" : "toValue(args)"}]as const}`;
|
|
80
|
+
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}'${methodKey},'infinite']as const}`;
|
|
76
81
|
}
|
|
77
|
-
if (hasArgs) return `export function ${keyGetterName}(args:${argsType}){${hasHeader ? `const{header:_,...keyArgs}=args;return['${prefix}','${honoPath}','infinite',keyArgs]as const` : `return['${prefix}','${honoPath}','infinite',args]as const`}}`;
|
|
78
|
-
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}','infinite']as const}`;
|
|
82
|
+
if (hasArgs) return `export function ${keyGetterName}(args:${argsType}){${hasHeader ? `const{header:_,...keyArgs}=args;return['${prefix}','${honoPath}'${methodKey},'infinite',keyArgs]as const` : `return['${prefix}','${honoPath}'${methodKey},'infinite',args]as const`}}`;
|
|
83
|
+
return `export function ${keyGetterName}(){return['${prefix}','${honoPath}'${methodKey},'infinite']as const}`;
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
86
|
* Generates the query options factory.
|
|
@@ -84,9 +89,16 @@ function makeInfiniteQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPa
|
|
|
84
89
|
* (when the framework provides the helper) or a plain `{queryKey, queryFn}` literal.
|
|
85
90
|
* `queryFn` inlines `parseResponse(client.x.$y(...))` directly so no fetcher wrapper is needed.
|
|
86
91
|
*
|
|
92
|
+
* With the helper the factory is the single place the request is written: the hooks spread it
|
|
93
|
+
* (`{...getXQueryOptions<TData,TError>(...), ...query}`), the shape the TanStack docs recommend.
|
|
94
|
+
* That needs the factory to carry the hooks' generics — `queryOptions()` bakes `TError` and
|
|
95
|
+
* `TData` into its result (`retry`, `select`, ...), so a factory pinned to the defaults is not
|
|
96
|
+
* assignable to a hook whose caller picks them. Left unset, `<TData, TError>` fall back to the
|
|
97
|
+
* defaults, so a direct `getXQueryOptions()` call keeps its previous type.
|
|
98
|
+
*
|
|
87
99
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-options
|
|
88
100
|
*/
|
|
89
|
-
function makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, config) {
|
|
101
|
+
function makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, config) {
|
|
90
102
|
const queryKeyCall = hasArgs ? `${keyGetterName}(args)` : `${keyGetterName}()`;
|
|
91
103
|
const queryFnSig = config.hasQueryOptionsHelper ? "{signal}" : "{signal}:QueryFunctionContext";
|
|
92
104
|
if (config.isVueQuery && hasArgs) {
|
|
@@ -95,9 +107,11 @@ function makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, a
|
|
|
95
107
|
return `export function ${optionsGetterName}(args:MaybeRefOrGetter<${argsType}>,options?:ClientRequestOptions){return ${config.hasQueryOptionsHelper ? `queryOptions({${bodyContent}})` : `{${bodyContent}}`}}`;
|
|
96
108
|
}
|
|
97
109
|
const bodyContent = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${hasArgs ? `parseResponse(${runtimeAccess}(args,{...options,init:{...options?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...options,init:{...options?.init,signal}}))`}}`;
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
110
|
+
const carriesHookGenerics = config.hasQueryOptionsHelper === true && !config.isVueQuery;
|
|
111
|
+
const generics = carriesHookGenerics ? `<TData=${responseType},TError=${config.errorType ?? "unknown"}>` : "";
|
|
112
|
+
const returnExpr = carriesHookGenerics ? `queryOptions<${responseType},TError,TData,ReturnType<typeof ${keyGetterName}>>({${bodyContent}})` : config.hasQueryOptionsHelper ? `queryOptions({${bodyContent}})` : `{${bodyContent}}`;
|
|
113
|
+
if (hasArgs) return `export function ${optionsGetterName}${generics}(args:${argsType},options?:ClientRequestOptions){return ${returnExpr}}`;
|
|
114
|
+
return `export function ${optionsGetterName}${generics}(options?:ClientRequestOptions){return ${returnExpr}}`;
|
|
101
115
|
}
|
|
102
116
|
function makeGetRequestArgsField(hasArgs, argsType) {
|
|
103
117
|
return hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
|
|
@@ -120,8 +134,10 @@ function makeInfiniteQueryOptionsGetterCode(optionsGetterName, infiniteKeyGetter
|
|
|
120
134
|
return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${`queryKey:${vueReactiveKey(queryKeyCall)},queryFn(${queryFnSig}){return ${fetcherCall}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`}})}`;
|
|
121
135
|
}
|
|
122
136
|
const body = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`;
|
|
123
|
-
|
|
124
|
-
|
|
137
|
+
const generics = `<TData=InfiniteData<${responseType}>,TError=${config.errorType ?? "unknown"},TPageParam=unknown>`;
|
|
138
|
+
const helperCall = `infiniteQueryOptions<${responseType},TError,TData,${queryKeyType},TPageParam>({${body}})`;
|
|
139
|
+
if (hasArgs) return `export function ${optionsGetterName}${generics}(args:${argsType},${paginationParam},options?:ClientRequestOptions){return ${helperCall}}`;
|
|
140
|
+
return `export function ${optionsGetterName}${generics}(${paginationParam},options?:ClientRequestOptions){return ${helperCall}}`;
|
|
125
141
|
}
|
|
126
142
|
const vuePaginationParam = `pagination:{${makeGetRequestArgsField(hasArgs, argsType)}}`;
|
|
127
143
|
if (config.isVueQuery && hasArgs) {
|
|
@@ -164,23 +180,27 @@ function makeSWRQueryHookCode(hookName, keyGetterName, hasArgs, argsType, runtim
|
|
|
164
180
|
* - fetcher: async function returning data
|
|
165
181
|
* - options: SWRInfiniteConfiguration
|
|
166
182
|
*/
|
|
167
|
-
function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, errorType = "unknown") {
|
|
183
|
+
function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, errorType = "unknown", method = "get") {
|
|
168
184
|
const argsSig = hasArgs ? `args:${argsType},` : "";
|
|
169
185
|
const tErrorGeneric = `<TError=${errorType}>`;
|
|
170
186
|
const keyCall = hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`;
|
|
171
187
|
const loaderKeyType = `readonly[...${`ReturnType<typeof ${infiniteKeyGetterName}>`},number]`;
|
|
172
|
-
|
|
188
|
+
const optionsSig = `options:{swr?:${`SWRInfiniteConfiguration<${responseType},TError>&{swrKey?:(index:number,previousPageData:${responseType}|null)=>${loaderKeyType}|null}`};options?:ClientRequestOptions;pagination:{${hasArgs ? `getRequestArgs:(args:${argsType},index:number)=>${argsType}` : `getRequestArgs:(index:number)=>${argsType}`}}}`;
|
|
189
|
+
const leadingKeyParts = (hasArgs ? 4 : 3) + (method === "get" ? 0 : 1);
|
|
190
|
+
return `export function ${hookName}${tErrorGeneric}(${argsSig}${optionsSig}){const{swr:swrOptions,options:clientOptions,pagination}=options;const{swrKey:customKeyLoader,...restSwrOptions}=swrOptions??{};const keyLoader=customKeyLoader??((index:number)=>[...${keyCall},index]as const);return useSWRInfinite(keyLoader,(${`[${",".repeat(leadingKeyParts)}index]:${loaderKeyType}`})=>parseResponse(${runtimeAccess}(${hasArgs ? `pagination.getRequestArgs(args,index)` : `pagination.getRequestArgs(index)`},clientOptions)),restSwrOptions)}`;
|
|
173
191
|
}
|
|
174
192
|
/**
|
|
175
|
-
* Generates a query hook
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
193
|
+
* Generates a query hook (regular or suspense).
|
|
194
|
+
*
|
|
195
|
+
* With the framework's `queryOptions()` helper the hook spreads the matching factory —
|
|
196
|
+
* `{...getXQueryOptions<TData,TError>(args, clientOptions), ...query}` — so the request is
|
|
197
|
+
* written once and the caller's options override it, the way the TanStack docs recommend.
|
|
198
|
+
* The factory has to carry the hook's `<TData, TError>` for that spread to type-check:
|
|
199
|
+
* `queryOptions()` bakes both into its result (`retry`, `select`, ...), and the hook's
|
|
200
|
+
* options type pins `TQueryKey` to the factory's literal tuple for the same reason.
|
|
201
|
+
*
|
|
202
|
+
* Without the helper (Vue) the hook inlines queryKey + queryFn instead: Vue Query's
|
|
203
|
+
* `MaybeRefDeep` option types don't take the branded factory, so it keeps the plain form.
|
|
184
204
|
*
|
|
185
205
|
* The queryFn calls the Hono client (`client.x.$y`) directly rather than importing a
|
|
186
206
|
* generated `rpc` fetcher. This is not about layering aesthetics (regenerated codegen
|
|
@@ -188,16 +208,22 @@ function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsT
|
|
|
188
208
|
* only on `hono/client` + the client, generatable in isolation — and keeps the response
|
|
189
209
|
* type, request call, and `signal` injection all derived from that one client, so hook
|
|
190
210
|
* inference never becomes coupled to a separate fetcher's signature.
|
|
211
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-options
|
|
191
212
|
* @see https://tanstack.com/query/latest/docs/framework/react/typescript#typing-query-options
|
|
192
213
|
*/
|
|
193
|
-
function makeQueryHookCode(hookName, keyGetterName, runtimeAccess, hasArgs, argsType, responseType, config) {
|
|
214
|
+
function makeQueryHookCode(hookName, keyGetterName, optionsGetterName, runtimeAccess, hasArgs, argsType, responseType, config) {
|
|
194
215
|
const generics = `<TData=${responseType},TError=${config.errorType ?? "unknown"}>`;
|
|
195
|
-
const
|
|
216
|
+
const useFactory = config.hasQueryOptionsHelper === true && !config.isVueQuery;
|
|
217
|
+
const optionsTypeArgs = config.isVueQuery ? `${responseType},TError,TData,${responseType},ReturnType<typeof ${keyGetterName}>` : useFactory ? `${responseType},TError,TData,ReturnType<typeof ${keyGetterName}>` : `${responseType},TError,TData`;
|
|
196
218
|
const optionsType = `{query?:${omitInjectedKeys(wrapOptionsType(`${config.useQueryOptionsType}<${optionsTypeArgs}>`, config.unwrapOptionsAccessor), QUERY_OMIT_KEYS, config.isVueQuery ? VUE_QUERY_MEMBER : void 0)};options?:ClientRequestOptions}`;
|
|
197
219
|
const keyCall = hasArgs ? `${keyGetterName}(args)` : `${keyGetterName}()`;
|
|
198
220
|
const tail = makeHookTail(config.hookTail, "query");
|
|
199
221
|
if (config.useThunk) {
|
|
200
222
|
const argsSig = hasArgs ? `args:()=>${argsType},` : "";
|
|
223
|
+
if (useFactory) {
|
|
224
|
+
const factoryCall = hasArgs ? `${optionsGetterName}<TData,TError>(args(),clientOptions)` : `${optionsGetterName}<TData,TError>(clientOptions)`;
|
|
225
|
+
return `export function ${hookName}${generics}(${argsSig}options?:()=>${optionsType}${tail.sig}){return ${config.queryFn}(()=>{const{query,options:clientOptions}=options?.()??{};return{...${factoryCall},...query}}${tail.arg})}`;
|
|
226
|
+
}
|
|
201
227
|
const svelteKeyCall = hasArgs ? `${keyGetterName}(args())` : `${keyGetterName}()`;
|
|
202
228
|
const fetcherCall = hasArgs ? `parseResponse(${runtimeAccess}(args(),{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`;
|
|
203
229
|
return `export function ${hookName}${generics}(${argsSig}options?:()=>${optionsType}${tail.sig}){return ${config.queryFn}(()=>{const{query,options:clientOptions}=options?.()??{};return{...query,queryKey:${svelteKeyCall},queryFn({signal}:QueryFunctionContext){return ${fetcherCall}}}}${tail.arg})}`;
|
|
@@ -209,16 +235,18 @@ function makeQueryHookCode(hookName, keyGetterName, runtimeAccess, hasArgs, args
|
|
|
209
235
|
return `export function ${hookName}${generics}(${argsSig}options?:${optionsType}${tail.sig}){const{query:queryOptions,options:clientOptions}=options??{};return ${config.queryFn}({...queryOptions,queryKey:${vueKeyCall},queryFn({signal}){return ${fetcherCall}}}${tail.arg})}`;
|
|
210
236
|
}
|
|
211
237
|
const argsSig = hasArgs ? `args:${argsType},` : "";
|
|
238
|
+
if (useFactory) {
|
|
239
|
+
const factoryCall = hasArgs ? `${optionsGetterName}<TData,TError>(args,clientOptions)` : `${optionsGetterName}<TData,TError>(clientOptions)`;
|
|
240
|
+
return `export function ${hookName}${generics}(${argsSig}options?:${optionsType}${tail.sig}){const{query:queryOptions,options:clientOptions}=options??{};return ${config.queryFn}({...${factoryCall},...queryOptions}${tail.arg})}`;
|
|
241
|
+
}
|
|
212
242
|
const fetcherCall = hasArgs ? `parseResponse(${runtimeAccess}(args,{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`;
|
|
213
243
|
return `export function ${hookName}${generics}(${argsSig}options?:${optionsType}${tail.sig}){const{query:queryOptions,options:clientOptions}=options??{};return ${config.queryFn}({...queryOptions,queryKey:${keyCall},queryFn({signal}:QueryFunctionContext){return ${fetcherCall}}}${tail.arg})}`;
|
|
214
244
|
}
|
|
215
245
|
/**
|
|
216
246
|
* Builds the inline body for an infinite query hook (queryKey + queryFn + optional pagination).
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* assignable to the hook's wide generic options type — same cause as the non-infinite hooks,
|
|
221
|
-
* not specific to the suspense variant.
|
|
247
|
+
* Used where the hook cannot spread the `infiniteQueryOptions(...)` factory: Vue (no helper,
|
|
248
|
+
* and the helper's `MaybeRefDeep<TPageParam>` doesn't narrow from a generic parameter).
|
|
249
|
+
* Helper-backed frameworks spread the generic factory instead — see `makeInfiniteQueryHookCode`.
|
|
222
250
|
*
|
|
223
251
|
* `isVueQuery` drops `:QueryFunctionContext` from `queryFn` — `useInfiniteQuery({...})` provides
|
|
224
252
|
* contextual typing for `signal: AbortSignal`, so the annotation is redundant and breaks
|
|
@@ -231,6 +259,7 @@ function makeInfiniteHookBody(keyCall, fetcherCall, useHelper, queryKeyType, isV
|
|
|
231
259
|
function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterName, infiniteOptionsGetterName, hasArgs, argsType, responseType, config) {
|
|
232
260
|
const errorType = config.errorType ?? "unknown";
|
|
233
261
|
const useHelper = config.hasInfiniteQueryOptionsHelper === true;
|
|
262
|
+
const useFactory = useHelper && !config.isVueQuery;
|
|
234
263
|
const generics = `<TData=${`InfiniteData<${responseType}>`},TError=${errorType},TPageParam=unknown>`;
|
|
235
264
|
const queryKeyType = `ReturnType<typeof ${infiniteKeyGetterName}>`;
|
|
236
265
|
const queryOptionsType = omitInjectedKeys(wrapOptionsType(`${config.useInfiniteQueryOptionsType}<${responseType},TError,TData,${queryKeyType},TPageParam>`, config.unwrapOptionsAccessor), useHelper ? INFINITE_OMIT_KEYS : QUERY_OMIT_KEYS, config.isVueQuery ? VUE_QUERY_MEMBER : void 0);
|
|
@@ -247,6 +276,10 @@ function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterNam
|
|
|
247
276
|
}
|
|
248
277
|
if (config.useThunk) {
|
|
249
278
|
const argsSig = hasArgs ? `args:()=>${argsType},` : "";
|
|
279
|
+
if (useFactory) {
|
|
280
|
+
const factoryCall = hasArgs ? `${infiniteOptionsGetterName}<TData,TError,TPageParam>(args(),pagination,clientOptions)` : `${infiniteOptionsGetterName}<TData,TError,TPageParam>(pagination,clientOptions)`;
|
|
281
|
+
return `export function ${hookName}${generics}(${argsSig}${paginationSig}options?:()=>${optionsType}${tail.sig}){return ${config.infiniteQueryFn}(()=>{const{query,options:clientOptions}=options?.()??{};return{...${factoryCall},...query}}${tail.arg})}`;
|
|
282
|
+
}
|
|
250
283
|
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args()")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
251
284
|
const optionsTypeSig = useHelper ? `options?:()=>${optionsType}` : `options:()=>${optionsType}`;
|
|
252
285
|
const destructure = useHelper ? `options?.()??{}` : "options()";
|
|
@@ -258,6 +291,10 @@ function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterNam
|
|
|
258
291
|
return `export function ${hookName}${generics}(${argsSig}${vuePaginationParam},options:${optionsType}${tail.sig}){const{query:queryOptions,options:clientOptions}=options;return ${config.infiniteQueryFn}({...queryOptions,${body}}${tail.arg})}`;
|
|
259
292
|
}
|
|
260
293
|
const argsSig = hasArgs ? `args:${argsType},` : "";
|
|
294
|
+
if (useFactory) {
|
|
295
|
+
const factoryCall = hasArgs ? `${infiniteOptionsGetterName}<TData,TError,TPageParam>(args,pagination,clientOptions)` : `${infiniteOptionsGetterName}<TData,TError,TPageParam>(pagination,clientOptions)`;
|
|
296
|
+
return `export function ${hookName}${generics}(${argsSig}${paginationSig}options?:${optionsType}${tail.sig}){const{query:queryOptions,options:clientOptions}=options??{};return ${config.infiniteQueryFn}({...${factoryCall},...queryOptions}${tail.arg})}`;
|
|
297
|
+
}
|
|
261
298
|
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
262
299
|
const optionsTypeSig = useHelper ? `options?:${optionsType}` : `options:${optionsType}`;
|
|
263
300
|
const destructure = useHelper ? "options??{}" : "options";
|
|
@@ -333,7 +370,7 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
333
370
|
if (!isOperationLike(op)) return null;
|
|
334
371
|
const hookName = makeHookName(method, pathStr, config.hookPrefix);
|
|
335
372
|
const hasArgs = operationHasArgs(item, op, deps);
|
|
336
|
-
const isQuery = method === "get";
|
|
373
|
+
const isQuery = method === "get" || method === "query";
|
|
337
374
|
const hasPagination = op["x-pagination"] === true;
|
|
338
375
|
const pathLevelParams = deps.toParameterLikes(item.parameters);
|
|
339
376
|
const opParams = deps.toParameterLikes(op.parameters);
|
|
@@ -347,12 +384,12 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
347
384
|
if (config.isSWR) {
|
|
348
385
|
if (isQuery) {
|
|
349
386
|
const keyGetterName = makeQueryKeyGetterName(method, pathStr, true);
|
|
350
|
-
const keyGetterCode = makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs);
|
|
387
|
+
const keyGetterCode = makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs, method);
|
|
351
388
|
const hookCode = makeSWRQueryHookCode(hookName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, config.queryFn, config.errorType);
|
|
352
389
|
const immutableHookName = `${config.hookPrefix}Immutable${capitalize(operationFileName)}`;
|
|
353
390
|
const immutableHookCode = config.immutableQueryFn ? makeSWRQueryHookCode(immutableHookName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, config.immutableQueryFn, config.errorType) : null;
|
|
354
391
|
const infiniteKeyGetterName = makeInfiniteQueryKeyGetterName(method, pathStr, true);
|
|
355
|
-
const infiniteKeyGetterCode = hasPagination ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs) : null;
|
|
392
|
+
const infiniteKeyGetterCode = hasPagination ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs, method) : null;
|
|
356
393
|
const infiniteHookName = `${config.hookPrefix}Infinite${capitalize(operationFileName)}`;
|
|
357
394
|
return {
|
|
358
395
|
code: [
|
|
@@ -360,7 +397,7 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
360
397
|
hookCode,
|
|
361
398
|
immutableHookCode,
|
|
362
399
|
infiniteKeyGetterCode,
|
|
363
|
-
hasPagination ? makeSWRInfiniteHookCode(infiniteHookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, config.errorType) : null
|
|
400
|
+
hasPagination ? makeSWRInfiniteHookCode(infiniteHookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, config.errorType, method) : null
|
|
364
401
|
].filter(Boolean).join("\n\n"),
|
|
365
402
|
isQuery: true,
|
|
366
403
|
hasArgs,
|
|
@@ -378,28 +415,30 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
378
415
|
};
|
|
379
416
|
}
|
|
380
417
|
if (isQuery) {
|
|
381
|
-
const queryHookName = makeHookName(
|
|
382
|
-
const pathFuncName = methodPath(
|
|
418
|
+
const queryHookName = makeHookName(queryNameMethod(method), pathStr, config.hookPrefix);
|
|
419
|
+
const pathFuncName = methodPath(queryNameMethod(method), pathStr);
|
|
383
420
|
const keyGetterName = makeQueryKeyGetterName(method, pathStr);
|
|
384
|
-
const optionsGetterName = `get${capitalize(
|
|
385
|
-
const keyGetterCode = makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs);
|
|
386
|
-
const optionsGetterCode = makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, config);
|
|
387
|
-
const hookCode = makeQueryHookCode(queryHookName, keyGetterName, runtimeAccess, hasArgs, argsType, responseType, config);
|
|
421
|
+
const optionsGetterName = `get${capitalize(pathFuncName)}QueryOptions`;
|
|
422
|
+
const keyGetterCode = makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs, method);
|
|
423
|
+
const optionsGetterCode = makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, config);
|
|
424
|
+
const hookCode = makeQueryHookCode(queryHookName, keyGetterName, optionsGetterName, runtimeAccess, hasArgs, argsType, responseType, config);
|
|
388
425
|
const infiniteKeyGetterName = makeInfiniteQueryKeyGetterName(method, pathStr);
|
|
389
|
-
const infiniteOptionsGetterName = `get${capitalize(
|
|
426
|
+
const infiniteOptionsGetterName = `get${capitalize(pathFuncName)}InfiniteQueryOptions`;
|
|
390
427
|
const { infiniteQueryFn, useInfiniteQueryOptionsType } = config;
|
|
391
428
|
const hasInfinite = !!(infiniteQueryFn && useInfiniteQueryOptionsType) && hasPagination;
|
|
392
|
-
const infiniteKeyGetterCode = hasInfinite ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs) : null;
|
|
429
|
+
const infiniteKeyGetterCode = hasInfinite ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs, method) : null;
|
|
393
430
|
const infiniteOptionsGetterCode = hasInfinite ? makeInfiniteQueryOptionsGetterCode(infiniteOptionsGetterName, infiniteKeyGetterName, hasArgs, argsType, runtimeAccess, responseType, {
|
|
394
431
|
...config.isVueQuery ? { isVueQuery: true } : {},
|
|
395
|
-
...config.hasInfiniteQueryOptionsHelper ? { hasInfiniteQueryOptionsHelper: true } : {}
|
|
432
|
+
...config.hasInfiniteQueryOptionsHelper ? { hasInfiniteQueryOptionsHelper: true } : {},
|
|
433
|
+
...config.errorType ? { errorType: config.errorType } : {}
|
|
396
434
|
}) : null;
|
|
397
435
|
const suspenseHookName = `${config.hookPrefix}Suspense${capitalize(pathFuncName)}`;
|
|
398
|
-
const suspenseHookCode = config.suspenseQueryFn && config.useSuspenseQueryOptionsType ? makeQueryHookCode(suspenseHookName, keyGetterName, runtimeAccess, hasArgs, argsType, responseType, {
|
|
436
|
+
const suspenseHookCode = config.suspenseQueryFn && config.useSuspenseQueryOptionsType ? makeQueryHookCode(suspenseHookName, keyGetterName, optionsGetterName, runtimeAccess, hasArgs, argsType, responseType, {
|
|
399
437
|
queryFn: config.suspenseQueryFn,
|
|
400
438
|
useQueryOptionsType: config.useSuspenseQueryOptionsType,
|
|
401
439
|
...config.useThunk ? { useThunk: true } : {},
|
|
402
440
|
...config.isVueQuery ? { isVueQuery: true } : {},
|
|
441
|
+
...config.hasQueryOptionsHelper ? { hasQueryOptionsHelper: true } : {},
|
|
403
442
|
...config.errorType ? { errorType: config.errorType } : {},
|
|
404
443
|
...config.hookTail ? { hookTail: config.hookTail } : {},
|
|
405
444
|
...config.unwrapOptionsAccessor ? { unwrapOptionsAccessor: true } : {}
|
|
@@ -463,7 +502,8 @@ function makeHookCodes(paths, deps, config, clientName) {
|
|
|
463
502
|
"options",
|
|
464
503
|
"head",
|
|
465
504
|
"patch",
|
|
466
|
-
"trace"
|
|
505
|
+
"trace",
|
|
506
|
+
"query"
|
|
467
507
|
].map((method) => {
|
|
468
508
|
const result = makeHookCode(p, method, pathItem, deps, config, clientName);
|
|
469
509
|
return result ? {
|
|
@@ -498,8 +538,10 @@ function makeHeader(importPath, clientName, hasQuery, hasMutation, hasAnyArgs, c
|
|
|
498
538
|
...hasInfiniteQuery && config.hasInfiniteQueryOptionsHelper ? ["infiniteQueryOptions"] : [],
|
|
499
539
|
...hasMutation && config.hasMutationOptionsHelper ? ["mutationOptions"] : []
|
|
500
540
|
];
|
|
541
|
+
const needsQueryFnContext = hasQuery && !config.hasQueryOptionsHelper || hasInfiniteQuery;
|
|
501
542
|
const typeImports = [
|
|
502
|
-
...hasQuery ? [config.useQueryOptionsType
|
|
543
|
+
...hasQuery ? [config.useQueryOptionsType] : [],
|
|
544
|
+
...needsQueryFnContext ? ["QueryFunctionContext"] : [],
|
|
503
545
|
...hasQuery && config.useSuspenseQueryOptionsType ? [config.useSuspenseQueryOptionsType] : [],
|
|
504
546
|
...hasInfiniteQuery && config.useInfiniteQueryOptionsType ? [config.useInfiniteQueryOptionsType] : [],
|
|
505
547
|
...hasInfiniteQuery && config.useSuspenseInfiniteQueryOptionsType ? [config.useSuspenseInfiniteQueryOptionsType] : [],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as isOperation, B as isRefObject, C as isDiscriminableBranch, E as isMedia, F as isParameterRef, G as isSchemaObject, I as isPathItem, L as isPathItemEntry, M as isParameter, R as isPathItemRef, U as isResponses, V as isRefOnly, W as isSchemaArray, Y as isSingleSchema, _ as toIdentifierPascalCase, a as error, b as zodToOpenAPISchema, f as methodPath, h as requestParamsArray, i as ensureSuffix, m as renderNamedImport, p as normalizeTypes, r as cyclicNodes, s as escapeRegexLiteral, t as baseError, u as makeSafeKey, v as uncapitalize, w as isHeader, x as isCallbacks, z as isRecord } from "./utils-
|
|
1
|
+
import { A as isOperation, B as isRefObject, C as isDiscriminableBranch, E as isMedia, F as isParameterRef, G as isSchemaObject, I as isPathItem, L as isPathItemEntry, M as isParameter, R as isPathItemRef, U as isResponses, V as isRefOnly, W as isSchemaArray, Y as isSingleSchema, _ as toIdentifierPascalCase, a as error, b as zodToOpenAPISchema, f as methodPath, h as requestParamsArray, i as ensureSuffix, m as renderNamedImport, p as normalizeTypes, r as cyclicNodes, s as escapeRegexLiteral, t as baseError, u as makeSafeKey, v as uncapitalize, w as isHeader, x as isCallbacks, z as isRecord } from "./utils-BtWoIX8v.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { ts } from "ts-morph";
|
|
4
4
|
//#region src/helper/code.ts
|
|
@@ -201,7 +201,8 @@ function makeCallbacks(callbacks, readonly) {
|
|
|
201
201
|
"options",
|
|
202
202
|
"head",
|
|
203
203
|
"patch",
|
|
204
|
-
"trace"
|
|
204
|
+
"trace",
|
|
205
|
+
"query"
|
|
205
206
|
];
|
|
206
207
|
const makeMethodsCode = (record) => methods.map((method) => {
|
|
207
208
|
const operation = record[method];
|
|
@@ -2325,7 +2326,8 @@ function routeCode(openapi, readonly) {
|
|
|
2325
2326
|
"patch",
|
|
2326
2327
|
"options",
|
|
2327
2328
|
"head",
|
|
2328
|
-
"trace"
|
|
2329
|
+
"trace",
|
|
2330
|
+
"query"
|
|
2329
2331
|
].flatMap((method) => {
|
|
2330
2332
|
const operation = resolved[method];
|
|
2331
2333
|
if (!operation?.responses) return [];
|
|
@@ -2387,7 +2389,8 @@ function webhookCode(openapi, readonly) {
|
|
|
2387
2389
|
"patch",
|
|
2388
2390
|
"options",
|
|
2389
2391
|
"head",
|
|
2390
|
-
"trace"
|
|
2392
|
+
"trace",
|
|
2393
|
+
"query"
|
|
2391
2394
|
].filter((m) => pathItem[m]?.responses).flatMap((method) => {
|
|
2392
2395
|
const operation = pathItem[method];
|
|
2393
2396
|
if (!operation) return [];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as isRefObject, K as isSchemaProperty, P as isParameterObject, Z as isValidIdent, j as isOperationLike, z as isRecord } from "./utils-
|
|
1
|
+
import { B as isRefObject, K as isSchemaProperty, P as isParameterObject, Z as isValidIdent, j as isOperationLike, z as isRecord } from "./utils-BtWoIX8v.js";
|
|
2
2
|
import { Data } from "effect";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
//#region src/error/index.ts
|
|
@@ -118,7 +118,8 @@ function parsePathItem(rawItem) {
|
|
|
118
118
|
options: isOperationLike(rawItem.options) ? rawItem.options : void 0,
|
|
119
119
|
head: isOperationLike(rawItem.head) ? rawItem.head : void 0,
|
|
120
120
|
patch: isOperationLike(rawItem.patch) ? rawItem.patch : void 0,
|
|
121
|
-
trace: isOperationLike(rawItem.trace) ? rawItem.trace : void 0
|
|
121
|
+
trace: isOperationLike(rawItem.trace) ? rawItem.trace : void 0,
|
|
122
|
+
query: isOperationLike(rawItem.query) ? rawItem.query : void 0
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
function makeOperationDeps(clientName, componentsParameters, componentsRequestBodies) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { a as unlink, i as readdir } from "./file-CwKqigE9.js";
|
|
3
|
-
import { s as GenerateError } from "./rpc-
|
|
4
|
-
import { _ as links, a as defineTemplate, b as callbacks, c as mock, d as responses, f as requestBodies, g as mediaTypes, h as components, i as template, l as securitySchemes, m as parameters, n as webhooks, o as takibi, p as pathItems, r as test, s as route, u as schemas, v as headers, y as examples } from "./core-
|
|
5
|
-
import { t as hooks } from "./hooks-
|
|
6
|
-
import { t as docs } from "./docs-
|
|
3
|
+
import { s as GenerateError } from "./rpc-C_Lq1F7-.js";
|
|
4
|
+
import { _ as links, a as defineTemplate, b as callbacks, c as mock, d as responses, f as requestBodies, g as mediaTypes, h as components, i as template, l as securitySchemes, m as parameters, n as webhooks, o as takibi, p as pathItems, r as test, s as route, u as schemas, v as headers, y as examples } from "./core-Binj-uPh.js";
|
|
5
|
+
import { t as hooks } from "./hooks-DI1jbIMJ.js";
|
|
6
|
+
import { t as docs } from "./docs-Bo4-6xBy.js";
|
|
7
7
|
import { rpc } from "./core/rpc/index.js";
|
|
8
8
|
import { type } from "./core/type/index.js";
|
|
9
9
|
import { Effect, Schema } from "effect";
|
|
@@ -3,7 +3,7 @@ function isRecord(v) {
|
|
|
3
3
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4
4
|
}
|
|
5
5
|
function isHttpMethod(method) {
|
|
6
|
-
return method === "get" || method === "put" || method === "post" || method === "delete" || method === "patch" || method === "options" || method === "head" || method === "trace";
|
|
6
|
+
return method === "get" || method === "put" || method === "post" || method === "delete" || method === "patch" || method === "options" || method === "head" || method === "trace" || method === "query";
|
|
7
7
|
}
|
|
8
8
|
function isValidIdent(str) {
|
|
9
9
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u.test(str);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { parseConfig } from "../index.js";
|
|
2
2
|
import { t as fileSystemLayer } from "../file-CwKqigE9.js";
|
|
3
3
|
import { t as FormatOptions } from "../format-Bm9LZ_ki.js";
|
|
4
|
-
import { z as isRecord } from "../utils-
|
|
4
|
+
import { z as isRecord } from "../utils-BtWoIX8v.js";
|
|
5
5
|
import { n as parseOpenAPI } from "../openapi-DQRxq2_O.js";
|
|
6
|
-
import { n as cleanSplitOutputs, r as makeJob, t as appEntryOutput } from "../shared-
|
|
6
|
+
import { n as cleanSplitOutputs, r as makeJob, t as appEntryOutput } from "../shared-CHGm83qW.js";
|
|
7
7
|
import { Effect, FileSystem, Option, Result } from "effect";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import crypto from "node:crypto";
|