hono-takibi 0.11.0 → 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 +21 -0
- package/dist/cli.js +3 -3
- package/dist/core/docs/index.js +1 -1
- package/dist/core/hooks/index.d.ts +50 -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-CpzC5kSm.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-6j2Z-MPl.js → hooks-DI1jbIMJ.js} +213 -90
- package/dist/{openapi-DhxrYmuQ.js → openapi-4tjo-yX9.js} +7 -4
- package/dist/{openapi-CzAVsFDt.js → openapi-DQRxq2_O.js} +10 -19
- package/dist/{rpc-D_eeOVGa.js → rpc-C_Lq1F7-.js} +3 -2
- package/dist/{shared-BJ4A07Yx.js → shared-CHGm83qW.js} +4 -4
- package/dist/{utils-DEFpxBMu.js → utils-BtWoIX8v.js} +1 -1
- package/dist/vite-plugin/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -312,6 +312,27 @@ paths:
|
|
|
312
312
|
x-pagination: true
|
|
313
313
|
```
|
|
314
314
|
|
|
315
|
+
### Generated hooks
|
|
316
|
+
|
|
317
|
+
Every GET operation yields a key getter, an options factory, and a hook; every other method yields a mutation key getter, a `mutationOptions` factory, and a mutation hook.
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
getUsersKey() // ['users'] — one per path prefix
|
|
321
|
+
getUsersIdQueryKey(args) // ['users', '/users/:id', args] — header params are left out
|
|
322
|
+
getItemsInfiniteQueryKey(args) // ['items', '/items', 'infinite', args]
|
|
323
|
+
getPostUsersMutationKey() // ['users', '/users', 'POST']
|
|
324
|
+
|
|
325
|
+
useUsersId(args, { query: { staleTime: 1_000 }, options: { headers } }, queryClient)
|
|
326
|
+
usePostUsers({ mutation: { mutationKey: ['custom'], onSuccess } }, queryClient)
|
|
327
|
+
```
|
|
328
|
+
|
|
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.
|
|
331
|
+
- `options.options` is Hono's `ClientRequestOptions` (headers, fetch, init).
|
|
332
|
+
- The trailing argument is the framework's own: a `QueryClient` (an accessor of one in Solid and Svelte), or `{ injector }` in Angular.
|
|
333
|
+
- Vue hooks accept `Ref` / getter arguments and re-key the query when they change.
|
|
334
|
+
- SWR mutations revalidate only their own key; pass `swrKey: getGetUsersKey()` to revalidate the list instead.
|
|
335
|
+
|
|
315
336
|
## Test & Mock Generation
|
|
316
337
|
|
|
317
338
|
### Test Generation
|
package/dist/cli.js
CHANGED
|
@@ -69,9 +69,9 @@ function runConfigPass(configPath, reload) {
|
|
|
69
69
|
return Effect.gen(function* () {
|
|
70
70
|
const [{ readConfig }, { parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob }] = yield* Effect.promise(() => Promise.all([
|
|
71
71
|
import("./index.js"),
|
|
72
|
-
import("./openapi-
|
|
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-
|
|
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 };
|
|
@@ -17,6 +17,14 @@ declare const HOOK_CONFIGS: {
|
|
|
17
17
|
readonly useInfiniteQueryOptionsType: 'SWRInfiniteConfiguration';
|
|
18
18
|
};
|
|
19
19
|
readonly 'tanstack-query': {
|
|
20
|
+
readonly errorType: "DefaultError";
|
|
21
|
+
readonly hookTail: {
|
|
22
|
+
readonly name: 'queryClient';
|
|
23
|
+
readonly query: 'QueryClient';
|
|
24
|
+
readonly infinite: 'QueryClient';
|
|
25
|
+
readonly mutation: 'QueryClient';
|
|
26
|
+
readonly imports: readonly ['QueryClient'];
|
|
27
|
+
};
|
|
20
28
|
readonly packageName: '@tanstack/react-query';
|
|
21
29
|
readonly frameworkName: 'TanStack Query';
|
|
22
30
|
readonly hookPrefix: 'use';
|
|
@@ -35,6 +43,14 @@ declare const HOOK_CONFIGS: {
|
|
|
35
43
|
readonly useSuspenseQueryOptionsType: 'UseSuspenseQueryOptions';
|
|
36
44
|
};
|
|
37
45
|
readonly 'preact-query': {
|
|
46
|
+
readonly errorType: "DefaultError";
|
|
47
|
+
readonly hookTail: {
|
|
48
|
+
readonly name: 'queryClient';
|
|
49
|
+
readonly query: 'QueryClient';
|
|
50
|
+
readonly infinite: 'QueryClient';
|
|
51
|
+
readonly mutation: 'QueryClient';
|
|
52
|
+
readonly imports: readonly ['QueryClient'];
|
|
53
|
+
};
|
|
38
54
|
readonly packageName: '@tanstack/preact-query';
|
|
39
55
|
readonly frameworkName: 'Preact Query';
|
|
40
56
|
readonly hookPrefix: 'use';
|
|
@@ -53,6 +69,14 @@ declare const HOOK_CONFIGS: {
|
|
|
53
69
|
readonly useSuspenseQueryOptionsType: 'UseSuspenseQueryOptions';
|
|
54
70
|
};
|
|
55
71
|
readonly 'solid-query': {
|
|
72
|
+
readonly errorType: "DefaultError";
|
|
73
|
+
readonly hookTail: {
|
|
74
|
+
readonly name: 'queryClient';
|
|
75
|
+
readonly query: '()=>QueryClient';
|
|
76
|
+
readonly infinite: '()=>QueryClient';
|
|
77
|
+
readonly mutation: '()=>QueryClient';
|
|
78
|
+
readonly imports: readonly ['QueryClient'];
|
|
79
|
+
};
|
|
56
80
|
readonly packageName: '@tanstack/solid-query';
|
|
57
81
|
readonly frameworkName: 'Solid Query';
|
|
58
82
|
readonly hookPrefix: 'create';
|
|
@@ -69,6 +93,14 @@ declare const HOOK_CONFIGS: {
|
|
|
69
93
|
readonly unwrapOptionsAccessor: true;
|
|
70
94
|
};
|
|
71
95
|
readonly 'vue-query': {
|
|
96
|
+
readonly errorType: "DefaultError";
|
|
97
|
+
readonly hookTail: {
|
|
98
|
+
readonly name: 'queryClient';
|
|
99
|
+
readonly query: 'QueryClient';
|
|
100
|
+
readonly infinite: 'QueryClient';
|
|
101
|
+
readonly mutation: 'QueryClient';
|
|
102
|
+
readonly imports: readonly ['QueryClient'];
|
|
103
|
+
};
|
|
72
104
|
readonly packageName: '@tanstack/vue-query';
|
|
73
105
|
readonly frameworkName: 'Vue Query';
|
|
74
106
|
readonly hookPrefix: 'use';
|
|
@@ -82,6 +114,14 @@ declare const HOOK_CONFIGS: {
|
|
|
82
114
|
readonly useInfiniteQueryOptionsType: 'UseInfiniteQueryOptions';
|
|
83
115
|
};
|
|
84
116
|
readonly 'svelte-query': {
|
|
117
|
+
readonly errorType: "DefaultError";
|
|
118
|
+
readonly hookTail: {
|
|
119
|
+
readonly name: 'queryClient';
|
|
120
|
+
readonly query: '()=>QueryClient';
|
|
121
|
+
readonly infinite: '()=>QueryClient';
|
|
122
|
+
readonly mutation: '()=>QueryClient';
|
|
123
|
+
readonly imports: readonly ['QueryClient'];
|
|
124
|
+
};
|
|
85
125
|
readonly packageName: '@tanstack/svelte-query';
|
|
86
126
|
readonly frameworkName: 'Svelte Query';
|
|
87
127
|
readonly hookPrefix: 'create';
|
|
@@ -91,11 +131,20 @@ declare const HOOK_CONFIGS: {
|
|
|
91
131
|
readonly useQueryOptionsType: 'CreateQueryOptions';
|
|
92
132
|
readonly useMutationOptionsType: 'CreateMutationOptions';
|
|
93
133
|
readonly hasQueryOptionsHelper: true;
|
|
134
|
+
readonly hasMutationOptionsHelper: true;
|
|
94
135
|
readonly infiniteQueryFn: 'createInfiniteQuery';
|
|
95
136
|
readonly useInfiniteQueryOptionsType: 'CreateInfiniteQueryOptions';
|
|
96
137
|
readonly hasInfiniteQueryOptionsHelper: true;
|
|
97
138
|
};
|
|
98
139
|
readonly 'angular-query': {
|
|
140
|
+
readonly errorType: "DefaultError";
|
|
141
|
+
readonly hookTail: {
|
|
142
|
+
readonly name: 'injectOptions';
|
|
143
|
+
readonly query: 'InjectQueryOptions';
|
|
144
|
+
readonly infinite: 'InjectInfiniteQueryOptions';
|
|
145
|
+
readonly mutation: 'InjectMutationOptions';
|
|
146
|
+
readonly imports: readonly ['InjectQueryOptions', 'InjectInfiniteQueryOptions', 'InjectMutationOptions'];
|
|
147
|
+
};
|
|
99
148
|
readonly packageName: '@tanstack/angular-query-experimental';
|
|
100
149
|
readonly frameworkName: 'Angular Query';
|
|
101
150
|
readonly hookPrefix: 'inject';
|
|
@@ -104,7 +153,7 @@ declare const HOOK_CONFIGS: {
|
|
|
104
153
|
readonly useQueryOptionsType: 'CreateQueryOptions';
|
|
105
154
|
readonly useMutationOptionsType: 'CreateMutationOptions';
|
|
106
155
|
readonly hasQueryOptionsHelper: true;
|
|
107
|
-
readonly hasMutationOptionsHelper:
|
|
156
|
+
readonly hasMutationOptionsHelper: true;
|
|
108
157
|
readonly hasInfiniteQueryOptionsHelper: true;
|
|
109
158
|
readonly infiniteQueryFn: 'injectInfiniteQuery';
|
|
110
159
|
readonly useInfiniteQueryOptionsType: 'CreateInfiniteQueryOptions';
|
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,16 +1,28 @@
|
|
|
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
|
|
7
|
+
function makeHookTail(tail, kind) {
|
|
8
|
+
return tail ? {
|
|
9
|
+
sig: `,${tail.name}?:${tail[kind]}`,
|
|
10
|
+
arg: `,${tail.name}`
|
|
11
|
+
} : {
|
|
12
|
+
sig: "",
|
|
13
|
+
arg: ""
|
|
14
|
+
};
|
|
15
|
+
}
|
|
7
16
|
function wrapOptionsType(optionsType, unwrapAccessor) {
|
|
8
17
|
return unwrapAccessor ? `ReturnType<${optionsType}>` : optionsType;
|
|
9
18
|
}
|
|
10
19
|
const QUERY_OMIT_KEYS = `'queryKey'|'queryFn'`;
|
|
11
20
|
const INFINITE_OMIT_KEYS = `'queryKey'|'queryFn'|'initialPageParam'|'getNextPageParam'`;
|
|
12
|
-
|
|
13
|
-
|
|
21
|
+
const MUTATION_OMIT_KEYS = `'mutationFn'`;
|
|
22
|
+
const VUE_QUERY_MEMBER = `{queryKey:unknown}`;
|
|
23
|
+
const VUE_MUTATION_MEMBER = `{mutationFn?:unknown}`;
|
|
24
|
+
function omitInjectedKeys(optionsType, keys, vueMember) {
|
|
25
|
+
return `Omit<${vueMember ? `Extract<${optionsType},${vueMember}>` : optionsType},${keys}>`;
|
|
14
26
|
}
|
|
15
27
|
function makeHookName(method, pathStr, prefix) {
|
|
16
28
|
const funcName = methodPath(method, pathStr);
|
|
@@ -29,31 +41,46 @@ function makeResponseTypeFromClient(clientName, method, pathStr) {
|
|
|
29
41
|
function makeArgsType(clientName, method, pathStr) {
|
|
30
42
|
return `InferRequestType<${makeTypeAccess(clientName, method, pathStr)}>`;
|
|
31
43
|
}
|
|
44
|
+
function queryNameMethod(method) {
|
|
45
|
+
return method === "get" ? "" : method;
|
|
46
|
+
}
|
|
32
47
|
function makeQueryKeyGetterName(method, pathStr, isSWR) {
|
|
33
48
|
if (isSWR) return `get${capitalize(methodPath(method, pathStr))}Key`;
|
|
34
|
-
return `get${capitalize(methodPath(
|
|
49
|
+
return `get${capitalize(methodPath(queryNameMethod(method), pathStr))}QueryKey`;
|
|
50
|
+
}
|
|
51
|
+
function makeMutationKeyGetterName(method, pathStr, isSWR) {
|
|
52
|
+
if (isSWR) return `get${capitalize(methodPath(method, pathStr))}Key`;
|
|
53
|
+
return `get${capitalize(methodPath(method, pathStr))}MutationKey`;
|
|
54
|
+
}
|
|
55
|
+
function makeMutationKeyGetterCode(keyGetterName, method, honoPath) {
|
|
56
|
+
return `export function ${keyGetterName}(){return['${honoPath.replace(/^\//u, "").split("/")[0]}','${honoPath}','${method.toUpperCase()}']as const}`;
|
|
35
57
|
}
|
|
36
58
|
function makeInfiniteQueryKeyGetterName(method, pathStr, isSWR) {
|
|
37
59
|
if (isSWR) return `get${capitalize(methodPath(method, pathStr))}InfiniteKey`;
|
|
38
|
-
return `get${capitalize(methodPath(
|
|
60
|
+
return `get${capitalize(methodPath(queryNameMethod(method), pathStr))}InfiniteQueryKey`;
|
|
39
61
|
}
|
|
40
|
-
function
|
|
62
|
+
function vueReactiveKey(keyCall) {
|
|
63
|
+
return `computed(()=>${keyCall})`;
|
|
64
|
+
}
|
|
65
|
+
function makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeader = false, method = "get") {
|
|
41
66
|
const prefix = honoPath.replace(/^\//u, "").split("/")[0];
|
|
67
|
+
const methodKey = method === "get" ? "" : `,'${method.toUpperCase()}'`;
|
|
42
68
|
if (config.isVueQuery) {
|
|
43
|
-
if (hasArgs) return `export function ${keyGetterName}(args:MaybeRefOrGetter<${argsType}>){${hasHeader ? "const{header:_,...keyArgs}=toValue(args);return" : "return"}['${prefix}','${honoPath}',${hasHeader ? "keyArgs" : "args"}]as const}`;
|
|
44
|
-
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}`;
|
|
45
71
|
}
|
|
46
|
-
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`}}`;
|
|
47
|
-
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}`;
|
|
48
74
|
}
|
|
49
|
-
function makeInfiniteQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeader = false) {
|
|
75
|
+
function makeInfiniteQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeader = false, method = "get") {
|
|
50
76
|
const prefix = honoPath.replace(/^\//u, "").split("/")[0];
|
|
77
|
+
const methodKey = method === "get" ? "" : `,'${method.toUpperCase()}'`;
|
|
51
78
|
if (config.isVueQuery) {
|
|
52
|
-
if (hasArgs) return `export function ${keyGetterName}(args:MaybeRefOrGetter<${argsType}>){${hasHeader ? "const{header:_,...keyArgs}=toValue(args);return" : "return"}['${prefix}','${honoPath}',${hasHeader ? "keyArgs" : "args"}
|
|
53
|
-
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}`;
|
|
54
81
|
}
|
|
55
|
-
if (hasArgs) return `export function ${keyGetterName}(args:${argsType}){${hasHeader ? `const{header:_,...keyArgs}=args;return['${prefix}','${honoPath}',
|
|
56
|
-
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}`;
|
|
57
84
|
}
|
|
58
85
|
/**
|
|
59
86
|
* Generates the query options factory.
|
|
@@ -62,19 +89,29 @@ function makeInfiniteQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPa
|
|
|
62
89
|
* (when the framework provides the helper) or a plain `{queryKey, queryFn}` literal.
|
|
63
90
|
* `queryFn` inlines `parseResponse(client.x.$y(...))` directly so no fetcher wrapper is needed.
|
|
64
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
|
+
*
|
|
65
99
|
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-options
|
|
66
100
|
*/
|
|
67
|
-
function makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, config) {
|
|
101
|
+
function makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, config) {
|
|
68
102
|
const queryKeyCall = hasArgs ? `${keyGetterName}(args)` : `${keyGetterName}()`;
|
|
69
103
|
const queryFnSig = config.hasQueryOptionsHelper ? "{signal}" : "{signal}:QueryFunctionContext";
|
|
70
104
|
if (config.isVueQuery && hasArgs) {
|
|
71
|
-
const
|
|
105
|
+
const fetcherCall = `parseResponse(${runtimeAccess}(toValue(args),{...options,init:{...options?.init,signal}}))`;
|
|
106
|
+
const bodyContent = `queryKey:${vueReactiveKey(queryKeyCall)},queryFn(${queryFnSig}){return ${fetcherCall}}`;
|
|
72
107
|
return `export function ${optionsGetterName}(args:MaybeRefOrGetter<${argsType}>,options?:ClientRequestOptions){return ${config.hasQueryOptionsHelper ? `queryOptions({${bodyContent}})` : `{${bodyContent}}`}}`;
|
|
73
108
|
}
|
|
74
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}}))`}}`;
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
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}}`;
|
|
78
115
|
}
|
|
79
116
|
function makeGetRequestArgsField(hasArgs, argsType) {
|
|
80
117
|
return hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
|
|
@@ -87,24 +124,32 @@ function makePaginationParam(hasArgs, argsType, responseType) {
|
|
|
87
124
|
}
|
|
88
125
|
function makeInfiniteQueryOptionsGetterCode(optionsGetterName, infiniteKeyGetterName, hasArgs, argsType, runtimeAccess, responseType, config) {
|
|
89
126
|
const queryKeyCall = hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`;
|
|
90
|
-
const
|
|
127
|
+
const queryKeyType = `ReturnType<typeof ${infiniteKeyGetterName}>`;
|
|
128
|
+
const queryFnSig = config.isVueQuery ? "{pageParam,signal}:QueryFunctionContext<readonly unknown[],TPageParam>" : `{pageParam,signal}:QueryFunctionContext<${queryKeyType},TPageParam>`;
|
|
91
129
|
const requestArgsCall = makeRequestArgsCall(hasArgs);
|
|
92
130
|
if (config.hasInfiniteQueryOptionsHelper) {
|
|
93
131
|
const paginationParam = makePaginationParam(hasArgs, argsType, responseType);
|
|
94
|
-
if (config.isVueQuery && hasArgs)
|
|
132
|
+
if (config.isVueQuery && hasArgs) {
|
|
133
|
+
const fetcherCall = `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...options,init:{...options?.init,signal}}))`;
|
|
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`}})}`;
|
|
135
|
+
}
|
|
95
136
|
const body = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`;
|
|
96
|
-
|
|
97
|
-
|
|
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}}`;
|
|
98
141
|
}
|
|
99
142
|
const vuePaginationParam = `pagination:{${makeGetRequestArgsField(hasArgs, argsType)}}`;
|
|
100
|
-
if (config.isVueQuery && hasArgs)
|
|
143
|
+
if (config.isVueQuery && hasArgs) {
|
|
144
|
+
const fetcherCall = `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...options,init:{...options?.init,signal}}))`;
|
|
145
|
+
return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${vuePaginationParam},options?:ClientRequestOptions){return {${`queryKey:${vueReactiveKey(queryKeyCall)},queryFn(${queryFnSig}){return ${fetcherCall}}`}}}`;
|
|
146
|
+
}
|
|
101
147
|
const bodyContent = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...options,init:{...options?.init,signal}}))`}}`;
|
|
102
148
|
if (hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:${argsType},${vuePaginationParam},options?:ClientRequestOptions){return {${bodyContent}}}`;
|
|
103
149
|
return `export function ${optionsGetterName}<TPageParam=unknown>(${vuePaginationParam},options?:ClientRequestOptions){return {${bodyContent}}}`;
|
|
104
150
|
}
|
|
105
|
-
function makeMutationOptionsGetterCode(optionsGetterName, hasArgs, argsType, runtimeAccess,
|
|
106
|
-
const
|
|
107
|
-
const inlineKey = `['${honoPath.replace(/^\//u, "").split("/")[0]}','${honoPath}','${methodUpper}']as const`;
|
|
151
|
+
function makeMutationOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, hasNoContent, config) {
|
|
152
|
+
const inlineKey = `${keyGetterName}()`;
|
|
108
153
|
const errorType = config.errorType ?? "unknown";
|
|
109
154
|
const tErrorGeneric = config.hasMutationOptionsHelper ? `<TError=${errorType},TOnMutateResult=unknown>` : "";
|
|
110
155
|
const typeArgs = `<${hasNoContent ? `${responseType}|undefined` : responseType},TError,${hasArgs ? argsType : "void"},TOnMutateResult>`;
|
|
@@ -135,23 +180,27 @@ function makeSWRQueryHookCode(hookName, keyGetterName, hasArgs, argsType, runtim
|
|
|
135
180
|
* - fetcher: async function returning data
|
|
136
181
|
* - options: SWRInfiniteConfiguration
|
|
137
182
|
*/
|
|
138
|
-
function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, errorType = "unknown") {
|
|
183
|
+
function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, errorType = "unknown", method = "get") {
|
|
139
184
|
const argsSig = hasArgs ? `args:${argsType},` : "";
|
|
140
185
|
const tErrorGeneric = `<TError=${errorType}>`;
|
|
141
186
|
const keyCall = hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`;
|
|
142
187
|
const loaderKeyType = `readonly[...${`ReturnType<typeof ${infiniteKeyGetterName}>`},number]`;
|
|
143
|
-
|
|
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)}`;
|
|
144
191
|
}
|
|
145
192
|
/**
|
|
146
|
-
* Generates a query hook
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
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.
|
|
155
204
|
*
|
|
156
205
|
* The queryFn calls the Hono client (`client.x.$y`) directly rather than importing a
|
|
157
206
|
* generated `rpc` fetcher. This is not about layering aesthetics (regenerated codegen
|
|
@@ -159,35 +208,45 @@ function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsT
|
|
|
159
208
|
* only on `hono/client` + the client, generatable in isolation — and keeps the response
|
|
160
209
|
* type, request call, and `signal` injection all derived from that one client, so hook
|
|
161
210
|
* inference never becomes coupled to a separate fetcher's signature.
|
|
211
|
+
* @see https://tanstack.com/query/latest/docs/framework/react/guides/query-options
|
|
162
212
|
* @see https://tanstack.com/query/latest/docs/framework/react/typescript#typing-query-options
|
|
163
213
|
*/
|
|
164
|
-
function makeQueryHookCode(hookName, keyGetterName, runtimeAccess, hasArgs, argsType, responseType, config) {
|
|
214
|
+
function makeQueryHookCode(hookName, keyGetterName, optionsGetterName, runtimeAccess, hasArgs, argsType, responseType, config) {
|
|
165
215
|
const generics = `<TData=${responseType},TError=${config.errorType ?? "unknown"}>`;
|
|
166
|
-
const
|
|
167
|
-
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`;
|
|
218
|
+
const optionsType = `{query?:${omitInjectedKeys(wrapOptionsType(`${config.useQueryOptionsType}<${optionsTypeArgs}>`, config.unwrapOptionsAccessor), QUERY_OMIT_KEYS, config.isVueQuery ? VUE_QUERY_MEMBER : void 0)};options?:ClientRequestOptions}`;
|
|
168
219
|
const keyCall = hasArgs ? `${keyGetterName}(args)` : `${keyGetterName}()`;
|
|
220
|
+
const tail = makeHookTail(config.hookTail, "query");
|
|
169
221
|
if (config.useThunk) {
|
|
170
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
|
+
}
|
|
171
227
|
const svelteKeyCall = hasArgs ? `${keyGetterName}(args())` : `${keyGetterName}()`;
|
|
172
228
|
const fetcherCall = hasArgs ? `parseResponse(${runtimeAccess}(args(),{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`;
|
|
173
|
-
return `export function ${hookName}${generics}(${argsSig}options?:()=>${optionsType}){return ${config.queryFn}(()=>{const{query,options:clientOptions}=options?.()??{};return{...query,queryKey:${svelteKeyCall},queryFn({signal}:QueryFunctionContext){return ${fetcherCall}}}})}`;
|
|
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})}`;
|
|
174
230
|
}
|
|
175
231
|
if (config.isVueQuery) {
|
|
176
232
|
const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
|
|
177
233
|
const fetcherCall = hasArgs ? `parseResponse(${runtimeAccess}(toValue(args),{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`;
|
|
178
|
-
|
|
234
|
+
const vueKeyCall = hasArgs ? vueReactiveKey(keyCall) : keyCall;
|
|
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})}`;
|
|
179
236
|
}
|
|
180
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
|
+
}
|
|
181
242
|
const fetcherCall = hasArgs ? `parseResponse(${runtimeAccess}(args,{...clientOptions,init:{...clientOptions?.init,signal}}))` : `parseResponse(${runtimeAccess}(undefined,{...clientOptions,init:{...clientOptions?.init,signal}}))`;
|
|
182
|
-
return `export function ${hookName}${generics}(${argsSig}options?:${optionsType}){const{query:queryOptions,options:clientOptions}=options??{};return ${config.queryFn}({...queryOptions,queryKey:${keyCall},queryFn({signal}:QueryFunctionContext){return ${fetcherCall}}})}`;
|
|
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})}`;
|
|
183
244
|
}
|
|
184
245
|
/**
|
|
185
246
|
* Builds the inline body for an infinite query hook (queryKey + queryFn + optional pagination).
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* assignable to the hook's wide generic options type — same cause as the non-infinite hooks,
|
|
190
|
-
* 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`.
|
|
191
250
|
*
|
|
192
251
|
* `isVueQuery` drops `:QueryFunctionContext` from `queryFn` — `useInfiniteQuery({...})` provides
|
|
193
252
|
* contextual typing for `signal: AbortSignal`, so the annotation is redundant and breaks
|
|
@@ -200,34 +259,46 @@ function makeInfiniteHookBody(keyCall, fetcherCall, useHelper, queryKeyType, isV
|
|
|
200
259
|
function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterName, infiniteOptionsGetterName, hasArgs, argsType, responseType, config) {
|
|
201
260
|
const errorType = config.errorType ?? "unknown";
|
|
202
261
|
const useHelper = config.hasInfiniteQueryOptionsHelper === true;
|
|
203
|
-
const
|
|
262
|
+
const useFactory = useHelper && !config.isVueQuery;
|
|
263
|
+
const generics = `<TData=${`InfiniteData<${responseType}>`},TError=${errorType},TPageParam=unknown>`;
|
|
204
264
|
const queryKeyType = `ReturnType<typeof ${infiniteKeyGetterName}>`;
|
|
205
|
-
const queryOptionsType = omitInjectedKeys(wrapOptionsType(`${config.useInfiniteQueryOptionsType}<${responseType},TError,TData,${queryKeyType},TPageParam>`, config.unwrapOptionsAccessor), useHelper ? INFINITE_OMIT_KEYS : QUERY_OMIT_KEYS, config.isVueQuery);
|
|
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);
|
|
206
266
|
const optionsType = useHelper ? `{query?:${queryOptionsType};options?:ClientRequestOptions}` : `{query:${queryOptionsType};options?:ClientRequestOptions}`;
|
|
207
267
|
const requestArgsCall = makeRequestArgsCall(hasArgs);
|
|
208
268
|
const paginationParam = makePaginationParam(hasArgs, argsType, responseType);
|
|
209
269
|
const paginationSig = useHelper ? `${paginationParam},` : "";
|
|
210
270
|
const vuePaginationParam = `pagination:{${makeGetRequestArgsField(hasArgs, argsType)}}`;
|
|
271
|
+
const tail = makeHookTail(config.hookTail, "infinite");
|
|
211
272
|
if (config.isVueQuery && useHelper) {
|
|
212
273
|
const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
|
|
213
274
|
const optionsCall = hasArgs ? `${infiniteOptionsGetterName}(args,pagination,clientOptions)` : `${infiniteOptionsGetterName}(pagination,clientOptions)`;
|
|
214
|
-
return `export function ${hookName}${generics}(${argsSig}${paginationParam},options?:${optionsType}){const{query:queryOptions,options:clientOptions}=options??{};return ${config.infiniteQueryFn}({...queryOptions,...${optionsCall}})}`;
|
|
275
|
+
return `export function ${hookName}${generics}(${argsSig}${paginationParam},options?:${optionsType}${tail.sig}){const{query:queryOptions,options:clientOptions}=options??{};return ${config.infiniteQueryFn}({...queryOptions,...${optionsCall}}${tail.arg})}`;
|
|
215
276
|
}
|
|
216
277
|
if (config.useThunk) {
|
|
217
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
|
+
}
|
|
218
283
|
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args()")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
219
284
|
const optionsTypeSig = useHelper ? `options?:()=>${optionsType}` : `options:()=>${optionsType}`;
|
|
220
285
|
const destructure = useHelper ? `options?.()??{}` : "options()";
|
|
221
|
-
return `export function ${hookName}${generics}(${argsSig}${paginationSig}${optionsTypeSig}){return ${config.infiniteQueryFn}(()=>{const{query,options:clientOptions}=${destructure};return{...query,${body}}})}`;
|
|
286
|
+
return `export function ${hookName}${generics}(${argsSig}${paginationSig}${optionsTypeSig}${tail.sig}){return ${config.infiniteQueryFn}(()=>{const{query,options:clientOptions}=${destructure};return{...query,${body}}}${tail.arg})}`;
|
|
222
287
|
}
|
|
223
288
|
if (config.isVueQuery) {
|
|
224
289
|
const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
|
|
225
|
-
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType, true);
|
|
226
|
-
return `export function ${hookName}${generics}(${argsSig}${vuePaginationParam},options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.infiniteQueryFn}({...queryOptions,${body}})}`;
|
|
290
|
+
const body = makeInfiniteHookBody(hasArgs ? vueReactiveKey(`${infiniteKeyGetterName}(args)`) : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType, true);
|
|
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})}`;
|
|
227
292
|
}
|
|
228
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
|
+
}
|
|
229
298
|
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
230
|
-
|
|
299
|
+
const optionsTypeSig = useHelper ? `options?:${optionsType}` : `options:${optionsType}`;
|
|
300
|
+
const destructure = useHelper ? "options??{}" : "options";
|
|
301
|
+
return `export function ${hookName}${generics}(${argsSig}${paginationSig}${optionsTypeSig}${tail.sig}){const{query:queryOptions,options:clientOptions}=${destructure};return ${config.infiniteQueryFn}({...queryOptions,${body}}${tail.arg})}`;
|
|
231
302
|
}
|
|
232
303
|
/**
|
|
233
304
|
* Generates prefix key getter function code.
|
|
@@ -260,7 +331,7 @@ function makeSWRHeader(importPath, clientName, hasQuery, hasMutation, hasAnyArgs
|
|
|
260
331
|
const lines = [];
|
|
261
332
|
if (hasQuery) {
|
|
262
333
|
lines.push("import useSWR from'swr'", "import useSWRImmutable from'swr/immutable'", "import type{Key,SWRConfiguration}from'swr'");
|
|
263
|
-
if (hasInfiniteQuery) lines.push("import useSWRInfinite from'swr/infinite'", "import type{SWRInfiniteConfiguration
|
|
334
|
+
if (hasInfiniteQuery) lines.push("import useSWRInfinite from'swr/infinite'", "import type{SWRInfiniteConfiguration}from'swr/infinite'");
|
|
264
335
|
} else if (hasMutation) lines.push("import type{Key}from'swr'");
|
|
265
336
|
if (hasMutation) lines.push("import useSWRMutation from'swr/mutation'", "import type{SWRMutationConfiguration}from'swr/mutation'");
|
|
266
337
|
const honoTypeImports = ["ClientRequestOptions", ...hasAnyArgs || hasInfiniteQuery ? ["InferRequestType"] : []];
|
|
@@ -275,29 +346,31 @@ function makeSWRHeader(importPath, clientName, hasQuery, hasMutation, hasAnyArgs
|
|
|
275
346
|
* - fetcher: (_: Key, { arg }) => Promise<Data>
|
|
276
347
|
* - options: SWRMutationConfiguration
|
|
277
348
|
*/
|
|
278
|
-
function makeSWRMutationHookCode(hookName,
|
|
349
|
+
function makeSWRMutationHookCode(hookName, keyCall, hasArgs, argsType, responseType, runtimeAccess, hasNoContent, errorType = "unknown") {
|
|
279
350
|
const variablesType = hasArgs ? argsType : "undefined";
|
|
280
351
|
const responseTypeWithUndefined = hasNoContent ? `${responseType}|undefined` : responseType;
|
|
281
352
|
const tErrorGeneric = `<TError=${errorType}>`;
|
|
282
|
-
const optionsSig = `options?:{mutation?:${`SWRMutationConfiguration<${responseTypeWithUndefined},TError,Key,${variablesType}>`}&{swrKey?:Key};options?:ClientRequestOptions}`;
|
|
283
|
-
if (hasArgs) return `export function ${hookName}${tErrorGeneric}(${optionsSig}){const{mutation:mutationOptions,options:clientOptions}=options??{};const{swrKey:customKey,...restMutationOptions}=mutationOptions??{};const swrKey=customKey??${
|
|
284
|
-
return `export function ${hookName}${tErrorGeneric}(${optionsSig}){const{mutation:mutationOptions,options:clientOptions}=options??{};const{swrKey:customKey,...restMutationOptions}=mutationOptions??{};const swrKey=customKey??${
|
|
353
|
+
const optionsSig = `options?:{mutation?:${`SWRMutationConfiguration<${responseTypeWithUndefined},TError,Key,${variablesType}>`}&{swrKey?:Key;throwOnError?:boolean};options?:ClientRequestOptions}`;
|
|
354
|
+
if (hasArgs) return `export function ${hookName}${tErrorGeneric}(${optionsSig}){const{mutation:mutationOptions,options:clientOptions}=options??{};const{swrKey:customKey,...restMutationOptions}=mutationOptions??{};const swrKey=customKey??${keyCall};return{swrKey,...useSWRMutation(swrKey,async(_:Key,{arg}:{arg:${argsType}})=>parseResponse(${runtimeAccess}(arg,clientOptions)),restMutationOptions)}}`;
|
|
355
|
+
return `export function ${hookName}${tErrorGeneric}(${optionsSig}){const{mutation:mutationOptions,options:clientOptions}=options??{};const{swrKey:customKey,...restMutationOptions}=mutationOptions??{};const swrKey=customKey??${keyCall};return{swrKey,...useSWRMutation(swrKey,async()=>parseResponse(${runtimeAccess}(undefined,clientOptions)),restMutationOptions)}}`;
|
|
285
356
|
}
|
|
286
357
|
function makeMutationHookCode(hookName, optionsGetterName, hasArgs, argsType, responseType, config, hasNoContent) {
|
|
287
358
|
const variablesType = hasArgs ? argsType : "void";
|
|
288
359
|
const tErrorGeneric = `<TError=${config.errorType ?? "unknown"},TOnMutateResult=unknown>`;
|
|
289
360
|
const dataType = hasNoContent ? `${responseType}|undefined` : responseType;
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
361
|
+
const fullOptionsType = wrapOptionsType(`${config.useMutationOptionsType}<${dataType},TError,${variablesType},TOnMutateResult>`, config.unwrapOptionsAccessor);
|
|
362
|
+
const factoryCall = `${optionsGetterName}${config.hasMutationOptionsHelper ? "<TError,TOnMutateResult>" : ""}(clientOptions)`;
|
|
363
|
+
const tail = makeHookTail(config.hookTail, "mutation");
|
|
364
|
+
const optionsType = `{mutation?:${omitInjectedKeys(fullOptionsType, MUTATION_OMIT_KEYS, config.isVueQuery ? VUE_MUTATION_MEMBER : void 0)};options?:ClientRequestOptions}`;
|
|
365
|
+
if (config.useThunk) return `export function ${hookName}${tErrorGeneric}(options?:()=>${optionsType}${tail.sig}){return ${config.mutationFn}(()=>{const{mutation,options:clientOptions}=options?.()??{};const mutationDefaults=${factoryCall};return{...mutation,...mutationDefaults,mutationKey:mutation?.mutationKey??mutationDefaults.mutationKey}}${tail.arg})}`;
|
|
366
|
+
return `export function ${hookName}${tErrorGeneric}(options?:${optionsType}${tail.sig}){const{mutation:mutationOptions,options:clientOptions}=options??{};const mutationDefaults=${factoryCall};return ${config.mutationFn}({...mutationOptions,...mutationDefaults,mutationKey:mutationOptions?.mutationKey??mutationDefaults.mutationKey}${tail.arg})}`;
|
|
294
367
|
}
|
|
295
368
|
function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
296
369
|
const op = item[method];
|
|
297
370
|
if (!isOperationLike(op)) return null;
|
|
298
371
|
const hookName = makeHookName(method, pathStr, config.hookPrefix);
|
|
299
372
|
const hasArgs = operationHasArgs(item, op, deps);
|
|
300
|
-
const isQuery = method === "get";
|
|
373
|
+
const isQuery = method === "get" || method === "query";
|
|
301
374
|
const hasPagination = op["x-pagination"] === true;
|
|
302
375
|
const pathLevelParams = deps.toParameterLikes(item.parameters);
|
|
303
376
|
const opParams = deps.toParameterLikes(op.parameters);
|
|
@@ -311,12 +384,12 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
311
384
|
if (config.isSWR) {
|
|
312
385
|
if (isQuery) {
|
|
313
386
|
const keyGetterName = makeQueryKeyGetterName(method, pathStr, true);
|
|
314
|
-
const keyGetterCode = makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs);
|
|
387
|
+
const keyGetterCode = makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs, method);
|
|
315
388
|
const hookCode = makeSWRQueryHookCode(hookName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, config.queryFn, config.errorType);
|
|
316
389
|
const immutableHookName = `${config.hookPrefix}Immutable${capitalize(operationFileName)}`;
|
|
317
390
|
const immutableHookCode = config.immutableQueryFn ? makeSWRQueryHookCode(immutableHookName, keyGetterName, hasArgs, argsType, runtimeAccess, responseType, config.immutableQueryFn, config.errorType) : null;
|
|
318
391
|
const infiniteKeyGetterName = makeInfiniteQueryKeyGetterName(method, pathStr, true);
|
|
319
|
-
const infiniteKeyGetterCode = hasPagination ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs) : null;
|
|
392
|
+
const infiniteKeyGetterCode = hasPagination ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs, method) : null;
|
|
320
393
|
const infiniteHookName = `${config.hookPrefix}Infinite${capitalize(operationFileName)}`;
|
|
321
394
|
return {
|
|
322
395
|
code: [
|
|
@@ -324,7 +397,7 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
324
397
|
hookCode,
|
|
325
398
|
immutableHookCode,
|
|
326
399
|
infiniteKeyGetterCode,
|
|
327
|
-
hasPagination ? makeSWRInfiniteHookCode(infiniteHookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, config.errorType) : null
|
|
400
|
+
hasPagination ? makeSWRInfiniteHookCode(infiniteHookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, config.errorType, method) : null
|
|
328
401
|
].filter(Boolean).join("\n\n"),
|
|
329
402
|
isQuery: true,
|
|
330
403
|
hasArgs,
|
|
@@ -332,8 +405,9 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
332
405
|
operationFileName
|
|
333
406
|
};
|
|
334
407
|
}
|
|
408
|
+
const mutationKeyGetterName = makeMutationKeyGetterName(method, pathStr, true);
|
|
335
409
|
return {
|
|
336
|
-
code:
|
|
410
|
+
code: `${makeMutationKeyGetterCode(mutationKeyGetterName, method, honoPath)}\n\n${makeSWRMutationHookCode(hookName, `${mutationKeyGetterName}()`, hasArgs, argsType, responseType, runtimeAccess, hasNoContent, config.errorType)}`,
|
|
337
411
|
isQuery: false,
|
|
338
412
|
hasArgs,
|
|
339
413
|
hasInfinite: false,
|
|
@@ -341,29 +415,32 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
341
415
|
};
|
|
342
416
|
}
|
|
343
417
|
if (isQuery) {
|
|
344
|
-
const queryHookName = makeHookName(
|
|
345
|
-
const pathFuncName = methodPath(
|
|
418
|
+
const queryHookName = makeHookName(queryNameMethod(method), pathStr, config.hookPrefix);
|
|
419
|
+
const pathFuncName = methodPath(queryNameMethod(method), pathStr);
|
|
346
420
|
const keyGetterName = makeQueryKeyGetterName(method, pathStr);
|
|
347
|
-
const optionsGetterName = `get${capitalize(
|
|
348
|
-
const keyGetterCode = makeQueryKeyGetterCode(keyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs);
|
|
349
|
-
const optionsGetterCode = makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, argsType, runtimeAccess, config);
|
|
350
|
-
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);
|
|
351
425
|
const infiniteKeyGetterName = makeInfiniteQueryKeyGetterName(method, pathStr);
|
|
352
|
-
const infiniteOptionsGetterName = `get${capitalize(
|
|
426
|
+
const infiniteOptionsGetterName = `get${capitalize(pathFuncName)}InfiniteQueryOptions`;
|
|
353
427
|
const { infiniteQueryFn, useInfiniteQueryOptionsType } = config;
|
|
354
428
|
const hasInfinite = !!(infiniteQueryFn && useInfiniteQueryOptionsType) && hasPagination;
|
|
355
|
-
const infiniteKeyGetterCode = hasInfinite ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs) : null;
|
|
429
|
+
const infiniteKeyGetterCode = hasInfinite ? makeInfiniteQueryKeyGetterCode(infiniteKeyGetterName, hasArgs, argsType, honoPath, config, hasHeaderArgs, method) : null;
|
|
356
430
|
const infiniteOptionsGetterCode = hasInfinite ? makeInfiniteQueryOptionsGetterCode(infiniteOptionsGetterName, infiniteKeyGetterName, hasArgs, argsType, runtimeAccess, responseType, {
|
|
357
431
|
...config.isVueQuery ? { isVueQuery: true } : {},
|
|
358
|
-
...config.hasInfiniteQueryOptionsHelper ? { hasInfiniteQueryOptionsHelper: true } : {}
|
|
432
|
+
...config.hasInfiniteQueryOptionsHelper ? { hasInfiniteQueryOptionsHelper: true } : {},
|
|
433
|
+
...config.errorType ? { errorType: config.errorType } : {}
|
|
359
434
|
}) : null;
|
|
360
435
|
const suspenseHookName = `${config.hookPrefix}Suspense${capitalize(pathFuncName)}`;
|
|
361
|
-
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, {
|
|
362
437
|
queryFn: config.suspenseQueryFn,
|
|
363
438
|
useQueryOptionsType: config.useSuspenseQueryOptionsType,
|
|
364
439
|
...config.useThunk ? { useThunk: true } : {},
|
|
365
440
|
...config.isVueQuery ? { isVueQuery: true } : {},
|
|
441
|
+
...config.hasQueryOptionsHelper ? { hasQueryOptionsHelper: true } : {},
|
|
366
442
|
...config.errorType ? { errorType: config.errorType } : {},
|
|
443
|
+
...config.hookTail ? { hookTail: config.hookTail } : {},
|
|
367
444
|
...config.unwrapOptionsAccessor ? { unwrapOptionsAccessor: true } : {}
|
|
368
445
|
}) : null;
|
|
369
446
|
const infiniteHookName = `${config.hookPrefix}Infinite${capitalize(pathFuncName)}`;
|
|
@@ -374,6 +451,7 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
374
451
|
...config.isVueQuery ? { isVueQuery: true } : {},
|
|
375
452
|
...config.hasInfiniteQueryOptionsHelper ? { hasInfiniteQueryOptionsHelper: true } : {},
|
|
376
453
|
...config.errorType ? { errorType: config.errorType } : {},
|
|
454
|
+
...config.hookTail ? { hookTail: config.hookTail } : {},
|
|
377
455
|
...config.unwrapOptionsAccessor ? { unwrapOptionsAccessor: true } : {}
|
|
378
456
|
}) : null;
|
|
379
457
|
const suspenseInfiniteHookName = `${config.hookPrefix}SuspenseInfinite${capitalize(pathFuncName)}`;
|
|
@@ -391,6 +469,7 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
391
469
|
useInfiniteQueryOptionsType: config.useSuspenseInfiniteQueryOptionsType,
|
|
392
470
|
...config.useThunk ? { useThunk: true } : {},
|
|
393
471
|
...config.isVueQuery ? { isVueQuery: true } : {},
|
|
472
|
+
...config.hookTail ? { hookTail: config.hookTail } : {},
|
|
394
473
|
...config.hasInfiniteQueryOptionsHelper ? { hasInfiniteQueryOptionsHelper: true } : {},
|
|
395
474
|
...config.errorType ? { errorType: config.errorType } : {},
|
|
396
475
|
...config.unwrapOptionsAccessor ? { unwrapOptionsAccessor: true } : {}
|
|
@@ -403,8 +482,9 @@ function makeHookCode(pathStr, method, item, deps, config, clientName) {
|
|
|
403
482
|
};
|
|
404
483
|
}
|
|
405
484
|
const optionsGetterName = `get${capitalize(methodPath(method, pathStr))}MutationOptions`;
|
|
485
|
+
const mutationKeyGetterName = makeMutationKeyGetterName(method, pathStr);
|
|
406
486
|
return {
|
|
407
|
-
code: `${makeMutationOptionsGetterCode(optionsGetterName, hasArgs, argsType, runtimeAccess,
|
|
487
|
+
code: `${makeMutationKeyGetterCode(mutationKeyGetterName, method, honoPath)}\n\n${makeMutationOptionsGetterCode(optionsGetterName, mutationKeyGetterName, hasArgs, argsType, runtimeAccess, responseType, hasNoContent, config)}\n\n${makeMutationHookCode(hookName, optionsGetterName, hasArgs, argsType, responseType, config, hasNoContent)}`,
|
|
408
488
|
isQuery: false,
|
|
409
489
|
hasArgs,
|
|
410
490
|
hasInfinite: false,
|
|
@@ -422,7 +502,8 @@ function makeHookCodes(paths, deps, config, clientName) {
|
|
|
422
502
|
"options",
|
|
423
503
|
"head",
|
|
424
504
|
"patch",
|
|
425
|
-
"trace"
|
|
505
|
+
"trace",
|
|
506
|
+
"query"
|
|
426
507
|
].map((method) => {
|
|
427
508
|
const result = makeHookCode(p, method, pathItem, deps, config, clientName);
|
|
428
509
|
return result ? {
|
|
@@ -457,20 +538,24 @@ function makeHeader(importPath, clientName, hasQuery, hasMutation, hasAnyArgs, c
|
|
|
457
538
|
...hasInfiniteQuery && config.hasInfiniteQueryOptionsHelper ? ["infiniteQueryOptions"] : [],
|
|
458
539
|
...hasMutation && config.hasMutationOptionsHelper ? ["mutationOptions"] : []
|
|
459
540
|
];
|
|
541
|
+
const needsQueryFnContext = hasQuery && !config.hasQueryOptionsHelper || hasInfiniteQuery;
|
|
460
542
|
const typeImports = [
|
|
461
|
-
...hasQuery ? [config.useQueryOptionsType
|
|
543
|
+
...hasQuery ? [config.useQueryOptionsType] : [],
|
|
544
|
+
...needsQueryFnContext ? ["QueryFunctionContext"] : [],
|
|
462
545
|
...hasQuery && config.useSuspenseQueryOptionsType ? [config.useSuspenseQueryOptionsType] : [],
|
|
463
546
|
...hasInfiniteQuery && config.useInfiniteQueryOptionsType ? [config.useInfiniteQueryOptionsType] : [],
|
|
464
547
|
...hasInfiniteQuery && config.useSuspenseInfiniteQueryOptionsType ? [config.useSuspenseInfiniteQueryOptionsType] : [],
|
|
465
|
-
...hasInfiniteQuery
|
|
466
|
-
...hasMutation ? [config.useMutationOptionsType] : []
|
|
548
|
+
...hasInfiniteQuery ? ["InfiniteData"] : [],
|
|
549
|
+
...hasMutation ? [config.useMutationOptionsType] : [],
|
|
550
|
+
...config.errorType ? [config.errorType] : [],
|
|
551
|
+
...config.hookTail?.imports ?? []
|
|
467
552
|
];
|
|
468
553
|
const needsVueImports = config.isVueQuery && hasQueryWithArgs;
|
|
469
554
|
const honoTypeImports = ["ClientRequestOptions", ...hasAnyArgs || hasInfiniteQuery ? ["InferRequestType"] : []];
|
|
470
555
|
return `${[
|
|
471
556
|
...queryImports.length > 0 ? [`import{${queryImports.join(",")}}from'${config.packageName}'`] : [],
|
|
472
|
-
...typeImports.length > 0 ? [`import type{${typeImports.join(",")}}from'${config.packageName}'`] : [],
|
|
473
|
-
...needsVueImports ? ["import{toValue}from'vue'", "import type{MaybeRefOrGetter}from'vue'"] : [],
|
|
557
|
+
...typeImports.length > 0 ? [`import type{${[...new Set(typeImports)].join(",")}}from'${config.packageName}'`] : [],
|
|
558
|
+
...needsVueImports ? ["import{computed,toValue}from'vue'", "import type{MaybeRefOrGetter}from'vue'"] : [],
|
|
474
559
|
`import type{${honoTypeImports.join(",")}}from'hono/client'`,
|
|
475
560
|
`import{parseResponse}from'hono/client'`,
|
|
476
561
|
`import{${clientName}}from'${importPath}'`
|
|
@@ -517,6 +602,21 @@ function makeQueryHooks(openAPI, output, importPath, config, split, clientName =
|
|
|
517
602
|
}
|
|
518
603
|
//#endregion
|
|
519
604
|
//#region src/core/hooks/index.ts
|
|
605
|
+
const DEFAULT_ERROR = "DefaultError";
|
|
606
|
+
const QUERY_CLIENT_TAIL = {
|
|
607
|
+
name: "queryClient",
|
|
608
|
+
query: "QueryClient",
|
|
609
|
+
infinite: "QueryClient",
|
|
610
|
+
mutation: "QueryClient",
|
|
611
|
+
imports: ["QueryClient"]
|
|
612
|
+
};
|
|
613
|
+
const QUERY_CLIENT_ACCESSOR_TAIL = {
|
|
614
|
+
name: "queryClient",
|
|
615
|
+
query: "()=>QueryClient",
|
|
616
|
+
infinite: "()=>QueryClient",
|
|
617
|
+
mutation: "()=>QueryClient",
|
|
618
|
+
imports: ["QueryClient"]
|
|
619
|
+
};
|
|
520
620
|
const HOOK_CONFIGS = {
|
|
521
621
|
swr: {
|
|
522
622
|
packageName: "swr",
|
|
@@ -532,6 +632,8 @@ const HOOK_CONFIGS = {
|
|
|
532
632
|
useInfiniteQueryOptionsType: "SWRInfiniteConfiguration"
|
|
533
633
|
},
|
|
534
634
|
"tanstack-query": {
|
|
635
|
+
errorType: DEFAULT_ERROR,
|
|
636
|
+
hookTail: QUERY_CLIENT_TAIL,
|
|
535
637
|
packageName: "@tanstack/react-query",
|
|
536
638
|
frameworkName: "TanStack Query",
|
|
537
639
|
hookPrefix: "use",
|
|
@@ -550,6 +652,8 @@ const HOOK_CONFIGS = {
|
|
|
550
652
|
useSuspenseQueryOptionsType: "UseSuspenseQueryOptions"
|
|
551
653
|
},
|
|
552
654
|
"preact-query": {
|
|
655
|
+
errorType: DEFAULT_ERROR,
|
|
656
|
+
hookTail: QUERY_CLIENT_TAIL,
|
|
553
657
|
packageName: "@tanstack/preact-query",
|
|
554
658
|
frameworkName: "Preact Query",
|
|
555
659
|
hookPrefix: "use",
|
|
@@ -568,6 +672,8 @@ const HOOK_CONFIGS = {
|
|
|
568
672
|
useSuspenseQueryOptionsType: "UseSuspenseQueryOptions"
|
|
569
673
|
},
|
|
570
674
|
"solid-query": {
|
|
675
|
+
errorType: DEFAULT_ERROR,
|
|
676
|
+
hookTail: QUERY_CLIENT_ACCESSOR_TAIL,
|
|
571
677
|
packageName: "@tanstack/solid-query",
|
|
572
678
|
frameworkName: "Solid Query",
|
|
573
679
|
hookPrefix: "create",
|
|
@@ -584,6 +690,8 @@ const HOOK_CONFIGS = {
|
|
|
584
690
|
unwrapOptionsAccessor: true
|
|
585
691
|
},
|
|
586
692
|
"vue-query": {
|
|
693
|
+
errorType: DEFAULT_ERROR,
|
|
694
|
+
hookTail: QUERY_CLIENT_TAIL,
|
|
587
695
|
packageName: "@tanstack/vue-query",
|
|
588
696
|
frameworkName: "Vue Query",
|
|
589
697
|
hookPrefix: "use",
|
|
@@ -597,6 +705,8 @@ const HOOK_CONFIGS = {
|
|
|
597
705
|
useInfiniteQueryOptionsType: "UseInfiniteQueryOptions"
|
|
598
706
|
},
|
|
599
707
|
"svelte-query": {
|
|
708
|
+
errorType: DEFAULT_ERROR,
|
|
709
|
+
hookTail: QUERY_CLIENT_ACCESSOR_TAIL,
|
|
600
710
|
packageName: "@tanstack/svelte-query",
|
|
601
711
|
frameworkName: "Svelte Query",
|
|
602
712
|
hookPrefix: "create",
|
|
@@ -606,11 +716,24 @@ const HOOK_CONFIGS = {
|
|
|
606
716
|
useQueryOptionsType: "CreateQueryOptions",
|
|
607
717
|
useMutationOptionsType: "CreateMutationOptions",
|
|
608
718
|
hasQueryOptionsHelper: true,
|
|
719
|
+
hasMutationOptionsHelper: true,
|
|
609
720
|
infiniteQueryFn: "createInfiniteQuery",
|
|
610
721
|
useInfiniteQueryOptionsType: "CreateInfiniteQueryOptions",
|
|
611
722
|
hasInfiniteQueryOptionsHelper: true
|
|
612
723
|
},
|
|
613
724
|
"angular-query": {
|
|
725
|
+
errorType: DEFAULT_ERROR,
|
|
726
|
+
hookTail: {
|
|
727
|
+
name: "injectOptions",
|
|
728
|
+
query: "InjectQueryOptions",
|
|
729
|
+
infinite: "InjectInfiniteQueryOptions",
|
|
730
|
+
mutation: "InjectMutationOptions",
|
|
731
|
+
imports: [
|
|
732
|
+
"InjectQueryOptions",
|
|
733
|
+
"InjectInfiniteQueryOptions",
|
|
734
|
+
"InjectMutationOptions"
|
|
735
|
+
]
|
|
736
|
+
},
|
|
614
737
|
packageName: "@tanstack/angular-query-experimental",
|
|
615
738
|
frameworkName: "Angular Query",
|
|
616
739
|
hookPrefix: "inject",
|
|
@@ -619,7 +742,7 @@ const HOOK_CONFIGS = {
|
|
|
619
742
|
useQueryOptionsType: "CreateQueryOptions",
|
|
620
743
|
useMutationOptionsType: "CreateMutationOptions",
|
|
621
744
|
hasQueryOptionsHelper: true,
|
|
622
|
-
hasMutationOptionsHelper:
|
|
745
|
+
hasMutationOptionsHelper: true,
|
|
623
746
|
hasInfiniteQueryOptionsHelper: true,
|
|
624
747
|
infiniteQueryFn: "injectInfiniteQuery",
|
|
625
748
|
useInfiniteQueryOptionsType: "CreateInfiniteQueryOptions",
|
|
@@ -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 [];
|
|
@@ -12,30 +12,21 @@ import { getOpenAPI3 } from "@typespec/openapi3";
|
|
|
12
12
|
*
|
|
13
13
|
* @see https://apitools.dev/swagger-parser/docs/
|
|
14
14
|
*/
|
|
15
|
-
var openapi_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
-
OpenAPIError: () => OpenAPIError,
|
|
17
|
-
parseOpenAPI: () => parseOpenAPI
|
|
18
|
-
});
|
|
19
|
-
/** The document could not be read, compiled or parsed into an OpenAPI object. */
|
|
15
|
+
var openapi_exports = /* @__PURE__ */ __exportAll({ parseOpenAPI: () => parseOpenAPI });
|
|
20
16
|
var OpenAPIError = class extends Data.TaggedError("OpenAPIError") {};
|
|
21
|
-
/** Parses `input` into an OpenAPI document. */
|
|
22
17
|
function parseOpenAPI(input) {
|
|
23
18
|
return Effect.tryPromise({
|
|
24
|
-
try: () =>
|
|
19
|
+
try: async () => {
|
|
20
|
+
if (!input.endsWith(".tsp")) return await SwaggerParser.bundle(input);
|
|
21
|
+
const program = await compile(NodeHost, path.resolve(input), { noEmit: true });
|
|
22
|
+
if (program.diagnostics.length > 0) throw new Error(`TypeSpec compile failed:\n${program.diagnostics.map((d) => d.message).join("\n")}`);
|
|
23
|
+
const [record] = await getOpenAPI3(program);
|
|
24
|
+
const document = record && ("document" in record ? record.document : record.versions[0]?.document);
|
|
25
|
+
if (!document) throw new Error(`TypeSpec emitted no OpenAPI document: ${input}`);
|
|
26
|
+
return document;
|
|
27
|
+
},
|
|
25
28
|
catch: (error) => new OpenAPIError({ message: error instanceof Error ? error.message : String(error) })
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
|
-
async function readOpenAPI(input) {
|
|
29
|
-
if (typeof input === "string" && input.endsWith(".tsp")) {
|
|
30
|
-
const program = await compile(NodeHost, path.resolve(input), { noEmit: true });
|
|
31
|
-
if (program.diagnostics.length > 0) {
|
|
32
|
-
const errors = program.diagnostics.map((d) => d.message).join("\n");
|
|
33
|
-
throw new Error(`TypeSpec compile failed:\n${errors}`);
|
|
34
|
-
}
|
|
35
|
-
const [record] = await getOpenAPI3(program);
|
|
36
|
-
return "document" in record ? record.document : record.versions[0].document;
|
|
37
|
-
}
|
|
38
|
-
return await SwaggerParser.bundle(input);
|
|
39
|
-
}
|
|
40
31
|
//#endregion
|
|
41
32
|
export { parseOpenAPI as n, openapi_exports as t };
|
|
@@ -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-
|
|
5
|
-
import { n as parseOpenAPI } from "../openapi-
|
|
6
|
-
import { n as cleanSplitOutputs, r as makeJob, t as appEntryOutput } from "../shared-
|
|
4
|
+
import { z as isRecord } from "../utils-BtWoIX8v.js";
|
|
5
|
+
import { n as parseOpenAPI } from "../openapi-DQRxq2_O.js";
|
|
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";
|