hono-takibi 0.9.9999 → 0.9.99992
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/hooks/index.js +1 -1
- package/dist/core/type/index.js +2 -2
- package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
- package/dist/{hooks-Dk7Z5hMb.js → hooks-CkiatAe9.js} +33 -20
- package/dist/index.js +1 -1
- package/dist/{openapi-Lc8kequ9.js → openapi-8ZYAMj_e.js} +14 -10
- package/dist/{shared-siQoLLJc.js → shared-DRGflwP5.js} +44 -14
- package/dist/vite-plugin/index.js +1 -1
- package/package.json +4 -7
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-CkiatAe9.js";
|
|
2
2
|
export { hooks };
|
package/dist/core/type/index.js
CHANGED
|
@@ -163,7 +163,7 @@ function makeParameterSchema(parameter) {
|
|
|
163
163
|
}
|
|
164
164
|
function makeSchemaTypeString(schema, components, visited) {
|
|
165
165
|
if (!schema) return "unknown";
|
|
166
|
-
if (schema.$ref) return visited.has(schema.$ref) ? "unknown" : makeRefTypeString(schema.$ref, components, new Set([...visited, schema.$ref]));
|
|
166
|
+
if (schema.$ref) return visited.has(schema.$ref) ? "unknown" : makeRefTypeString(schema.$ref, components, /* @__PURE__ */ new Set([...visited, schema.$ref]));
|
|
167
167
|
if (schema.oneOf && schema.oneOf.length > 0) return schema.oneOf.map((s) => makeSchemaTypeString(s, components, visited)).join("|");
|
|
168
168
|
if (schema.anyOf && schema.anyOf.length > 0) return schema.anyOf.map((s) => makeSchemaTypeString(s, components, visited)).join("|");
|
|
169
169
|
if (schema.allOf && schema.allOf.length > 0) return makeAllOfTypeString(schema.allOf, components, visited);
|
|
@@ -228,7 +228,7 @@ function makeAllOfTypeString(allOf, components, visited) {
|
|
|
228
228
|
}
|
|
229
229
|
function makePropertyMap(schema, components, visited) {
|
|
230
230
|
if (schema.$ref && visited.has(schema.$ref)) return /* @__PURE__ */ new Map();
|
|
231
|
-
const nextVisited = schema.$ref ? new Set([...visited, schema.$ref]) : visited;
|
|
231
|
+
const nextVisited = schema.$ref ? /* @__PURE__ */ new Set([...visited, schema.$ref]) : visited;
|
|
232
232
|
const resolved = makeResolvedSchema(schema, components);
|
|
233
233
|
const fromAllOf = new Map(resolved.allOf && resolved.allOf.length > 0 ? resolved.allOf.flatMap((subSchema) => [...makePropertyMap(subSchema, components, nextVisited).entries()]) : []);
|
|
234
234
|
if (!resolved.properties) return fromAllOf;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as zodOpenAPIHono } from "../../../openapi-
|
|
1
|
+
import { t as zodOpenAPIHono } from "../../../openapi-8ZYAMj_e.js";
|
|
2
2
|
export { zodOpenAPIHono };
|
|
@@ -77,17 +77,21 @@ function makeQueryOptionsGetterCode(optionsGetterName, keyGetterName, hasArgs, a
|
|
|
77
77
|
}
|
|
78
78
|
function makeInfiniteQueryOptionsGetterCode(optionsGetterName, infiniteKeyGetterName, hasArgs, argsType, runtimeAccess, responseType, config) {
|
|
79
79
|
const queryKeyCall = hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`;
|
|
80
|
+
const queryFnSig = `{pageParam,signal}:QueryFunctionContext<${`ReturnType<typeof ${infiniteKeyGetterName}>`},TPageParam>`;
|
|
81
|
+
const getRequestArgsField = hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
|
|
82
|
+
const requestArgsCall = (argsExpr) => hasArgs ? `pagination.getRequestArgs(${argsExpr},pageParam)` : `pagination.getRequestArgs(pageParam)`;
|
|
80
83
|
if (config.hasInfiniteQueryOptionsHelper) {
|
|
81
|
-
const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null}`;
|
|
82
|
-
if (config.isVueQuery && hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${`queryKey:${queryKeyCall},queryFn({
|
|
83
|
-
const body = `queryKey:${queryKeyCall},queryFn({
|
|
84
|
+
const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null;${getRequestArgsField}}`;
|
|
85
|
+
if (config.isVueQuery && hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${`queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`}})}`;
|
|
86
|
+
const body = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...options,init:{...options?.init,signal}}))`}},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam`;
|
|
84
87
|
if (hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:${argsType},${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${body}})}`;
|
|
85
88
|
return `export function ${optionsGetterName}<TPageParam=unknown>(${paginationParam},options?:ClientRequestOptions){return infiniteQueryOptions({${body}})}`;
|
|
86
89
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return `export function ${optionsGetterName}(options?:ClientRequestOptions){return {${bodyContent}}}`;
|
|
90
|
+
const vuePaginationParam = `pagination:{${getRequestArgsField}}`;
|
|
91
|
+
if (config.isVueQuery && hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:MaybeRefOrGetter<${argsType}>,${vuePaginationParam},options?:ClientRequestOptions){return {${`queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...options,init:{...options?.init,signal}}))`}}`}}}`;
|
|
92
|
+
const bodyContent = `queryKey:${queryKeyCall},queryFn(${queryFnSig}){return ${`parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...options,init:{...options?.init,signal}}))`}}`;
|
|
93
|
+
if (hasArgs) return `export function ${optionsGetterName}<TPageParam=unknown>(args:${argsType},${vuePaginationParam},options?:ClientRequestOptions){return {${bodyContent}}}`;
|
|
94
|
+
return `export function ${optionsGetterName}<TPageParam=unknown>(${vuePaginationParam},options?:ClientRequestOptions){return {${bodyContent}}}`;
|
|
91
95
|
}
|
|
92
96
|
function makeMutationOptionsGetterCode(optionsGetterName, hasArgs, argsType, runtimeAccess, method, honoPath, responseType, hasNoContent, config) {
|
|
93
97
|
const methodUpper = method.toUpperCase();
|
|
@@ -123,7 +127,10 @@ function makeSWRQueryHookCode(hookName, keyGetterName, hasArgs, argsType, runtim
|
|
|
123
127
|
*/
|
|
124
128
|
function makeSWRInfiniteHookCode(hookName, infiniteKeyGetterName, hasArgs, argsType, responseType, runtimeAccess, errorType = "unknown") {
|
|
125
129
|
const argsSig = hasArgs ? `args:${argsType},` : "";
|
|
126
|
-
|
|
130
|
+
const tErrorGeneric = `<TError=${errorType}>`;
|
|
131
|
+
const keyCall = hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`;
|
|
132
|
+
const loaderKeyType = `readonly[...${`ReturnType<typeof ${infiniteKeyGetterName}>`},number]`;
|
|
133
|
+
return `export function ${hookName}${tErrorGeneric}(${argsSig}${`options:{swr?:${`SWRInfiniteConfiguration<${responseType},TError>&{swrKey?:(index:number,previousPageData:${responseType}|null)=>${loaderKeyType}}`};options?:ClientRequestOptions;pagination:{${hasArgs ? `getRequestArgs:(args:${argsType},index:number)=>${argsType}` : `getRequestArgs:(index:number)=>${argsType}`}}}`}){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(hasArgs ? 4 : 3)}index]:${loaderKeyType}`})=>parseResponse(${runtimeAccess}(${hasArgs ? `pagination.getRequestArgs(args,index)` : `pagination.getRequestArgs(index)`},clientOptions)),restSwrOptions)}`;
|
|
127
134
|
}
|
|
128
135
|
/**
|
|
129
136
|
* Generates a query hook with inline queryKey + queryFn. The hook builds its own
|
|
@@ -194,8 +201,8 @@ function makeSuspenseQueryHookCode(hookName, keyGetterName, runtimeAccess, hasAr
|
|
|
194
201
|
* contextual typing for `signal: AbortSignal`, so the annotation is redundant and breaks
|
|
195
202
|
* Vue Query's narrow per-call queryKey inference.
|
|
196
203
|
*/
|
|
197
|
-
function makeInfiniteHookBody(keyCall, fetcherCall, useHelper, isVueQuery = false) {
|
|
198
|
-
const base = `queryKey:${keyCall},queryFn(${isVueQuery ? "{signal}" :
|
|
204
|
+
function makeInfiniteHookBody(keyCall, fetcherCall, useHelper, queryKeyType, isVueQuery = false) {
|
|
205
|
+
const base = `queryKey:${keyCall},queryFn(${isVueQuery ? "{pageParam,signal}" : `{pageParam,signal}:QueryFunctionContext<${queryKeyType},TPageParam>`}){return ${fetcherCall}}`;
|
|
199
206
|
return useHelper ? `${base},initialPageParam:pagination.initialPageParam,getNextPageParam:pagination.getNextPageParam` : base;
|
|
200
207
|
}
|
|
201
208
|
function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterName, infiniteOptionsGetterName, hasArgs, argsType, responseType, config) {
|
|
@@ -205,8 +212,11 @@ function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterNam
|
|
|
205
212
|
const queryKeyType = `ReturnType<typeof ${infiniteKeyGetterName}>`;
|
|
206
213
|
const queryOptionsType = `${config.useInfiniteQueryOptionsType}<${responseType},TError,TData,${queryKeyType},TPageParam>`;
|
|
207
214
|
const optionsType = useHelper ? `{query?:${queryOptionsType};options?:ClientRequestOptions}` : `{query:${queryOptionsType};options?:ClientRequestOptions}`;
|
|
208
|
-
const
|
|
215
|
+
const getRequestArgsField = hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
|
|
216
|
+
const requestArgsCall = (argsExpr) => hasArgs ? `pagination.getRequestArgs(${argsExpr},pageParam)` : `pagination.getRequestArgs(pageParam)`;
|
|
217
|
+
const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null;${getRequestArgsField}}`;
|
|
209
218
|
const paginationSig = useHelper ? `${paginationParam},` : "";
|
|
219
|
+
const vuePaginationParam = `pagination:{${getRequestArgsField}}`;
|
|
210
220
|
if (config.isVueQuery && useHelper) {
|
|
211
221
|
const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
|
|
212
222
|
const optionsCall = hasArgs ? `${infiniteOptionsGetterName}(args,pagination,clientOptions)` : `${infiniteOptionsGetterName}(pagination,clientOptions)`;
|
|
@@ -214,18 +224,18 @@ function makeInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterNam
|
|
|
214
224
|
}
|
|
215
225
|
if (config.useThunk) {
|
|
216
226
|
const argsSig = hasArgs ? `args:()=>${argsType},` : "";
|
|
217
|
-
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`,
|
|
227
|
+
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args()")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
218
228
|
const optionsTypeSig = useHelper ? `options?:()=>${optionsType}` : `options:()=>${optionsType}`;
|
|
219
229
|
const destructure = useHelper ? `options?.()??{}` : "options()";
|
|
220
230
|
return `export function ${hookName}${generics}(${argsSig}${paginationSig}${optionsTypeSig}){return ${config.infiniteQueryFn}(()=>{const{query,options:clientOptions}=${destructure};return{...query,${body}}})}`;
|
|
221
231
|
}
|
|
222
232
|
if (config.isVueQuery) {
|
|
223
233
|
const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
|
|
224
|
-
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`,
|
|
225
|
-
return `export function ${hookName}${generics}(${argsSig}options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.infiniteQueryFn}({...queryOptions,${body}})}`;
|
|
234
|
+
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType, true);
|
|
235
|
+
return `export function ${hookName}${generics}(${argsSig}${vuePaginationParam},options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.infiniteQueryFn}({...queryOptions,${body}})}`;
|
|
226
236
|
}
|
|
227
237
|
const argsSig = hasArgs ? `args:${argsType},` : "";
|
|
228
|
-
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`,
|
|
238
|
+
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
229
239
|
return `export function ${hookName}${generics}(${argsSig}${paginationSig}${useHelper ? `options?:${optionsType}` : `options:${optionsType}`}){const{query:queryOptions,options:clientOptions}=${useHelper ? "options??{}" : "options"};return ${config.infiniteQueryFn}({...queryOptions,${body}})}`;
|
|
230
240
|
}
|
|
231
241
|
function makeSuspenseInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyGetterName, infiniteOptionsGetterName, hasArgs, argsType, responseType, config) {
|
|
@@ -235,8 +245,11 @@ function makeSuspenseInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyG
|
|
|
235
245
|
const queryKeyType = `ReturnType<typeof ${infiniteKeyGetterName}>`;
|
|
236
246
|
const queryOptionsType = `${config.useSuspenseInfiniteQueryOptionsType}<${responseType},TError,TData,${queryKeyType},TPageParam>`;
|
|
237
247
|
const optionsType = useHelper ? `{query?:${queryOptionsType};options?:ClientRequestOptions}` : `{query:${queryOptionsType};options?:ClientRequestOptions}`;
|
|
238
|
-
const
|
|
248
|
+
const getRequestArgsField = hasArgs ? `getRequestArgs:(args:${argsType},pageParam:unknown)=>${argsType}` : `getRequestArgs:(pageParam:unknown)=>${argsType}`;
|
|
249
|
+
const requestArgsCall = (argsExpr) => hasArgs ? `pagination.getRequestArgs(${argsExpr},pageParam)` : `pagination.getRequestArgs(pageParam)`;
|
|
250
|
+
const paginationParam = `pagination:{initialPageParam:TPageParam;getNextPageParam:(lastPage:${responseType},allPages:${responseType}[],lastPageParam:TPageParam)=>TPageParam|undefined|null;${getRequestArgsField}}`;
|
|
239
251
|
const paginationSig = useHelper ? `${paginationParam},` : "";
|
|
252
|
+
const vuePaginationParam = `pagination:{${getRequestArgsField}}`;
|
|
240
253
|
if (config.isVueQuery && useHelper) {
|
|
241
254
|
const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
|
|
242
255
|
const optionsCall = hasArgs ? `${infiniteOptionsGetterName}(args,pagination,clientOptions)` : `${infiniteOptionsGetterName}(pagination,clientOptions)`;
|
|
@@ -244,18 +257,18 @@ function makeSuspenseInfiniteQueryHookCode(hookName, runtimeAccess, infiniteKeyG
|
|
|
244
257
|
}
|
|
245
258
|
if (config.useThunk) {
|
|
246
259
|
const argsSig = hasArgs ? `args:()=>${argsType},` : "";
|
|
247
|
-
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`,
|
|
260
|
+
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args())` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args()")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
248
261
|
const optionsTypeSig = useHelper ? `options?:()=>${optionsType}` : `options:()=>${optionsType}`;
|
|
249
262
|
const destructure = useHelper ? `options?.()??{}` : "options()";
|
|
250
263
|
return `export function ${hookName}${generics}(${argsSig}${paginationSig}${optionsTypeSig}){return ${config.suspenseInfiniteQueryFn}(()=>{const{query,options:clientOptions}=${destructure};return{...query,${body}}})}`;
|
|
251
264
|
}
|
|
252
265
|
if (config.isVueQuery) {
|
|
253
266
|
const argsSig = hasArgs ? `args:MaybeRefOrGetter<${argsType}>,` : "";
|
|
254
|
-
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`,
|
|
255
|
-
return `export function ${hookName}${generics}(${argsSig}options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.suspenseInfiniteQueryFn}({...queryOptions,${body}})}`;
|
|
267
|
+
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("toValue(args)")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType, true);
|
|
268
|
+
return `export function ${hookName}${generics}(${argsSig}${vuePaginationParam},options:${optionsType}){const{query:queryOptions,options:clientOptions}=options;return ${config.suspenseInfiniteQueryFn}({...queryOptions,${body}})}`;
|
|
256
269
|
}
|
|
257
270
|
const argsSig = hasArgs ? `args:${argsType},` : "";
|
|
258
|
-
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`,
|
|
271
|
+
const body = makeInfiniteHookBody(hasArgs ? `${infiniteKeyGetterName}(args)` : `${infiniteKeyGetterName}()`, `parseResponse(${runtimeAccess}(${requestArgsCall("args")},{...clientOptions,init:{...clientOptions?.init,signal}}))`, useHelper, queryKeyType);
|
|
259
272
|
return `export function ${hookName}${generics}(${argsSig}${paginationSig}${useHelper ? `options?:${optionsType}` : `options:${optionsType}`}){const{query:queryOptions,options:clientOptions}=${useHelper ? "options??{}" : "options"};return ${config.suspenseInfiniteQueryFn}({...queryOptions,${body}})}`;
|
|
260
273
|
}
|
|
261
274
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readConfig } from "./config/index.js";
|
|
3
3
|
import { r as setFormatOptions } from "./emit-CFR63U4L.js";
|
|
4
|
-
import { n as parseOpenAPI, r as takibi, t as makeJob } from "./shared-
|
|
4
|
+
import { n as parseOpenAPI, r as takibi, t as makeJob } from "./shared-DRGflwP5.js";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
//#region src/cli/index.ts
|
|
@@ -47,7 +47,7 @@ function makeImports(code, fromFile, components, split = false, honoExtras = [])
|
|
|
47
47
|
const grouped = Array.from(code.matchAll(SCAN), (m) => m[1]).filter((name) => Boolean(name) && !defined.has(name)).reduce((acc, name) => {
|
|
48
48
|
const kind = classifyRef(name);
|
|
49
49
|
if (!kind) return acc;
|
|
50
|
-
return new Map(acc).set(kind, new Set([...acc.get(kind) ?? [], name]));
|
|
50
|
+
return new Map(acc).set(kind, /* @__PURE__ */ new Set([...acc.get(kind) ?? [], name]));
|
|
51
51
|
}, /* @__PURE__ */ new Map());
|
|
52
52
|
const needsCreateRoute = code.includes("createRoute(");
|
|
53
53
|
const needsZ = code.includes("z.");
|
|
@@ -358,7 +358,7 @@ function makePathItem(pathItem) {
|
|
|
358
358
|
//#endregion
|
|
359
359
|
//#region src/helper/wrap.ts
|
|
360
360
|
function wrap(zod, schema, meta, options) {
|
|
361
|
-
const unsupportedProps = new Set([
|
|
361
|
+
const unsupportedProps = /* @__PURE__ */ new Set([
|
|
362
362
|
"$recursiveRef",
|
|
363
363
|
"$recursiveAnchor",
|
|
364
364
|
"optional",
|
|
@@ -395,7 +395,8 @@ function wrap(zod, schema, meta, options) {
|
|
|
395
395
|
if (typeof v === "string") return JSON.stringify(v);
|
|
396
396
|
return JSON.stringify(v);
|
|
397
397
|
};
|
|
398
|
-
const
|
|
398
|
+
const isNullable = schema.nullable === true || (Array.isArray(schema.type) ? schema.type.includes("null") : schema.type === "null");
|
|
399
|
+
const n = isNullable ? `${zod}.nullable()` : zod;
|
|
399
400
|
const d = schema.default !== void 0 ? `${n}.default(${formatLiteral(schema.default)})` : n;
|
|
400
401
|
const pf = schema["x-prefault"] !== void 0 ? `${d}.prefault(${formatLiteral(schema["x-prefault"])})` : d;
|
|
401
402
|
const c = schema["x-catch"] !== void 0 ? `${pf}.catch(${formatLiteral(schema["x-catch"])})` : pf;
|
|
@@ -406,7 +407,7 @@ function wrap(zod, schema, meta, options) {
|
|
|
406
407
|
const codec = schema["x-codec"];
|
|
407
408
|
const replaced = preprocess ?? transform ?? pipe ?? codec ?? superRefineChain;
|
|
408
409
|
const z = schema["x-brand"] ? `${replaced}.brand<"${schema["x-brand"]}">()` : replaced;
|
|
409
|
-
const zodExpressedProps = new Set([
|
|
410
|
+
const zodExpressedProps = /* @__PURE__ */ new Set([
|
|
410
411
|
"type",
|
|
411
412
|
"format",
|
|
412
413
|
"default",
|
|
@@ -556,9 +557,12 @@ function wrap(zod, schema, meta, options) {
|
|
|
556
557
|
return `${JSON.stringify(key)}:${JSON.stringify(value)}`;
|
|
557
558
|
}).join(",")}}`;
|
|
558
559
|
};
|
|
560
|
+
const typeList = Array.isArray(schema.type) ? schema.type : schema.type !== void 0 ? [schema.type] : [];
|
|
561
|
+
const fileMetaProps = schema.format === "binary" && typeList.includes("string") && schema.contentEncoding === void 0 && schema.contentMediaType === void 0 && schema.contentSchema === void 0 && schema["x-codec"] === void 0 ? [isNullable ? "type:[\"string\",\"null\"]" : "type:\"string\"", "format:\"binary\""] : [];
|
|
559
562
|
const result = [
|
|
560
563
|
meta?.parameters ? `param:${serializeParam(meta.parameters)}` : void 0,
|
|
561
564
|
...headerMetaProps,
|
|
565
|
+
...fileMetaProps,
|
|
562
566
|
openapiSchemaBody && openapiSchemaBody.length > 0 ? openapiSchemaBody : void 0
|
|
563
567
|
].filter((v) => v !== void 0);
|
|
564
568
|
if (meta?.parameters || meta?.headers) {
|
|
@@ -1220,12 +1224,12 @@ const FORMAT_STRING = {
|
|
|
1220
1224
|
toUpperCase: "toUpperCase()",
|
|
1221
1225
|
trim: "trim()"
|
|
1222
1226
|
};
|
|
1223
|
-
const TRANSFORM_FORMATS = new Set([
|
|
1227
|
+
const TRANSFORM_FORMATS = /* @__PURE__ */ new Set([
|
|
1224
1228
|
"toLowerCase",
|
|
1225
1229
|
"toUpperCase",
|
|
1226
1230
|
"trim"
|
|
1227
1231
|
]);
|
|
1228
|
-
const DATE_FORMATS = new Set(["date", "date-time"]);
|
|
1232
|
+
const DATE_FORMATS = /* @__PURE__ */ new Set(["date", "date-time"]);
|
|
1229
1233
|
const EMAIL_PATTERN_PRESET = {
|
|
1230
1234
|
html5: "html5Email",
|
|
1231
1235
|
rfc5322: "rfc5322Email",
|
|
@@ -1670,7 +1674,7 @@ function tarjanConnect(name, deps, var2name, state) {
|
|
|
1670
1674
|
const indices = new Map(state.indices).set(name, currentIndex);
|
|
1671
1675
|
const lowLinks = new Map(state.lowLinks).set(name, currentIndex);
|
|
1672
1676
|
const stack = [...state.stack, name];
|
|
1673
|
-
const onStack = new Set([...state.onStack, name]);
|
|
1677
|
+
const onStack = /* @__PURE__ */ new Set([...state.onStack, name]);
|
|
1674
1678
|
const initialState = {
|
|
1675
1679
|
...state,
|
|
1676
1680
|
indices,
|
|
@@ -1734,7 +1738,7 @@ function analyzeCircularSchemas(schemas, schemaNames, readonly) {
|
|
|
1734
1738
|
return [n, extractIdentifiers(code, varNameSet).filter((v) => v !== selfVar)];
|
|
1735
1739
|
}));
|
|
1736
1740
|
const cyclicSchemas = findCyclicSchemas(schemaNames, depsMap);
|
|
1737
|
-
const extendedCyclicSchemas = new Set([...cyclicSchemas, ...[...cyclicSchemas].flatMap((n) => (depsMap.get(n) ?? []).map((v) => varNameToName.get(v)).filter((x) => x !== void 0))]);
|
|
1741
|
+
const extendedCyclicSchemas = /* @__PURE__ */ new Set([...cyclicSchemas, ...[...cyclicSchemas].flatMap((n) => (depsMap.get(n) ?? []).map((v) => varNameToName.get(v)).filter((x) => x !== void 0))]);
|
|
1738
1742
|
return {
|
|
1739
1743
|
zSchemaMap,
|
|
1740
1744
|
depsMap,
|
|
@@ -1801,12 +1805,12 @@ function topoSort(decls) {
|
|
|
1801
1805
|
if (!decl) return state;
|
|
1802
1806
|
const withTemp = {
|
|
1803
1807
|
...state,
|
|
1804
|
-
temp: new Set([...state.temp, key])
|
|
1808
|
+
temp: /* @__PURE__ */ new Set([...state.temp, key])
|
|
1805
1809
|
};
|
|
1806
1810
|
const afterRefs = decl.refs.map((ref) => findByName(ref)).filter((d) => d !== void 0).reduce((s, d) => visit(makeKey(d.kind, d.name), s), withTemp);
|
|
1807
1811
|
return {
|
|
1808
1812
|
sorted: [...afterRefs.sorted, decl],
|
|
1809
|
-
perm: new Set([...afterRefs.perm, key]),
|
|
1813
|
+
perm: /* @__PURE__ */ new Set([...afterRefs.perm, key]),
|
|
1810
1814
|
temp: new Set([...afterRefs.temp].filter((t) => t !== key))
|
|
1811
1815
|
};
|
|
1812
1816
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as fmt, t as emit } from "./emit-CFR63U4L.js";
|
|
2
2
|
import { a as writeFile, i as unlink, n as readFile, r as readdir, t as mkdir } from "./fsp-BXry-Hx5.js";
|
|
3
3
|
import { I as statusCodeToNumber, L as toIdentifierPascalCase, M as methodPath, O as escapeRegexLiteral, P as renderNamedImport, R as uncapitalize, T as ensureSuffix, b as isSecurityScheme, i as isMediaWithSchema, k as makeBarrel, l as isParameter, n as isHttpMethod, p as isRefObject, s as isOperation, t as isContentBody, y as isSecurityArray, z as zodToOpenAPISchema } from "./guard-zvkMUVYD.js";
|
|
4
|
-
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-
|
|
5
|
-
import { t as hooks } from "./hooks-
|
|
4
|
+
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-8ZYAMj_e.js";
|
|
5
|
+
import { t as hooks } from "./hooks-CkiatAe9.js";
|
|
6
6
|
import { t as docs } from "./docs-380Wcu6a.js";
|
|
7
7
|
import { rpc } from "./core/rpc/index.js";
|
|
8
8
|
import { type } from "./core/type/index.js";
|
|
@@ -560,6 +560,40 @@ const PROPERTY_NAME_TO_FAKER = {
|
|
|
560
560
|
count: "faker.number.int({ min: 0, max: 1000 })",
|
|
561
561
|
age: "faker.number.int({ min: 1, max: 120 })"
|
|
562
562
|
};
|
|
563
|
+
const hasNumericConstraint = (schema) => schema.minimum !== void 0 || schema.maximum !== void 0 || schema.exclusiveMinimum !== void 0 || schema.exclusiveMaximum !== void 0 || schema.multipleOf !== void 0;
|
|
564
|
+
function numericRange(schema, integer) {
|
|
565
|
+
const step = integer ? 1 : 0;
|
|
566
|
+
const min = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum + step : schema.exclusiveMinimum === true && schema.minimum !== void 0 ? schema.minimum + step : schema.minimum;
|
|
567
|
+
const max = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum - step : schema.exclusiveMaximum === true && schema.maximum !== void 0 ? schema.maximum - step : schema.maximum;
|
|
568
|
+
return {
|
|
569
|
+
...min !== void 0 ? { min } : {},
|
|
570
|
+
...max !== void 0 ? { max } : {},
|
|
571
|
+
...schema.multipleOf !== void 0 ? { multipleOf: schema.multipleOf } : {}
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
function numericFaker(schema, range) {
|
|
575
|
+
if (schema.type === "integer" && (schema.format === "int64" || schema.format === "bigint")) return `faker.number.bigInt({ min: ${range.min ?? 0}n, max: ${range.max ?? 9007199254740991}n })`;
|
|
576
|
+
if (schema.type === "integer") {
|
|
577
|
+
const defaultMin = schema.format === "int32" ? -2147483648 : 1;
|
|
578
|
+
const defaultMax = schema.format === "int32" ? 2147483647 : 1e3;
|
|
579
|
+
return `faker.number.int({ ${[
|
|
580
|
+
`min: ${range.min ?? defaultMin}`,
|
|
581
|
+
`max: ${range.max ?? defaultMax}`,
|
|
582
|
+
...range.multipleOf !== void 0 ? [`multipleOf: ${range.multipleOf}`] : []
|
|
583
|
+
].join(", ")} })`;
|
|
584
|
+
}
|
|
585
|
+
const defaultMax = schema.format === "double" ? 1e6 : 1e3;
|
|
586
|
+
const fractionDigits = schema.format === "double" ? 4 : 2;
|
|
587
|
+
return `faker.number.float({ ${(range.multipleOf !== void 0 ? [
|
|
588
|
+
`min: ${range.min ?? 1}`,
|
|
589
|
+
`max: ${range.max ?? defaultMax}`,
|
|
590
|
+
`multipleOf: ${range.multipleOf}`
|
|
591
|
+
] : [
|
|
592
|
+
`min: ${range.min ?? 1}`,
|
|
593
|
+
`max: ${range.max ?? defaultMax}`,
|
|
594
|
+
`fractionDigits: ${fractionDigits}`
|
|
595
|
+
]).join(", ")} })`;
|
|
596
|
+
}
|
|
563
597
|
function schemaToFaker(schema, propertyName, options = {}) {
|
|
564
598
|
if (options.useExamples && schema.example !== void 0) return JSON.stringify(schema.example);
|
|
565
599
|
if (schema.const !== void 0) return `${JSON.stringify(schema.const)} as const`;
|
|
@@ -588,6 +622,7 @@ function schemaToFaker(schema, propertyName, options = {}) {
|
|
|
588
622
|
}
|
|
589
623
|
const union = schema.oneOf && schema.oneOf.length > 0 ? schema.oneOf : schema.anyOf && schema.anyOf.length > 0 ? schema.anyOf : void 0;
|
|
590
624
|
if (union) return `faker.helpers.arrayElement([${union.map((s) => schemaToFaker(s, propertyName, options)).join(", ")}])`;
|
|
625
|
+
if ((schema.type === "integer" || schema.type === "number") && hasNumericConstraint(schema)) return numericFaker(schema, numericRange(schema, schema.type === "integer"));
|
|
591
626
|
if (schema.format && FORMAT_TO_FAKER[schema.format]) return FORMAT_TO_FAKER[schema.format];
|
|
592
627
|
if (propertyName && PROPERTY_NAME_TO_FAKER[propertyName]) {
|
|
593
628
|
const hint = PROPERTY_NAME_TO_FAKER[propertyName];
|
|
@@ -598,12 +633,7 @@ function schemaToFaker(schema, propertyName, options = {}) {
|
|
|
598
633
|
if (schema.pattern) return `faker.helpers.fromRegExp(/${escapeRegexLiteral(schema.pattern)}/)`;
|
|
599
634
|
return `faker.string.alpha({ length: { min: ${schema.minLength ?? 5}, max: ${schema.maxLength ?? 20} } })`;
|
|
600
635
|
}
|
|
601
|
-
if (schema.type === "integer" || schema.type === "number")
|
|
602
|
-
const min = schema.minimum ?? 1;
|
|
603
|
-
const max = schema.maximum ?? 1e3;
|
|
604
|
-
if (schema.type === "integer") return `faker.number.int({ min: ${min}, max: ${max} })`;
|
|
605
|
-
return `faker.number.float({ min: ${min}, max: ${max}, fractionDigits: 2 })`;
|
|
606
|
-
}
|
|
636
|
+
if (schema.type === "integer" || schema.type === "number") return numericFaker(schema, numericRange(schema, schema.type === "integer"));
|
|
607
637
|
return TYPE_TO_FAKER[schema.type];
|
|
608
638
|
}
|
|
609
639
|
return "undefined";
|
|
@@ -1115,7 +1145,7 @@ function extractTestCases(spec) {
|
|
|
1115
1145
|
} : void 0;
|
|
1116
1146
|
const bodyRefs = jsonBodySchema ? collectSchemaRefs(jsonBodySchema, spec.components?.schemas) : [];
|
|
1117
1147
|
const paramRefs = resolvedParams.flatMap((p) => collectSchemaRefs(p.schema, spec.components?.schemas));
|
|
1118
|
-
const usedSchemaRefs = [
|
|
1148
|
+
const usedSchemaRefs = [.../* @__PURE__ */ new Set([...bodyRefs, ...paramRefs])];
|
|
1119
1149
|
const responseKeys = Object.keys(operation.responses || {});
|
|
1120
1150
|
const successStatus = responseKeys.filter((s) => s.startsWith("2")).map((s) => Number.parseInt(s, 10)).toSorted((a, b) => a - b)[0] ?? 200;
|
|
1121
1151
|
const errorStatuses = responseKeys.filter((s) => (s.startsWith("4") || s.startsWith("5")) && s !== "default").map((s) => Number.parseInt(s, 10)).toSorted((a, b) => a - b);
|
|
@@ -1177,7 +1207,7 @@ function topologicalOrder(usedSchemaNames, schemas) {
|
|
|
1177
1207
|
if (visited.has(name) || !usedSchemaNames.has(name) || visiting.has(name)) return [];
|
|
1178
1208
|
const nextVisiting = new Set(visiting).add(name);
|
|
1179
1209
|
const schema = schemas[name];
|
|
1180
|
-
const depOrder = schema ? collectSchemaRefs(schema, schemas, new Set([name])).flatMap((dep) => {
|
|
1210
|
+
const depOrder = schema ? collectSchemaRefs(schema, schemas, /* @__PURE__ */ new Set([name])).flatMap((dep) => {
|
|
1181
1211
|
const subOrder = visit(dep, visited, nextVisiting);
|
|
1182
1212
|
for (const n of subOrder) visited.add(n);
|
|
1183
1213
|
return subOrder;
|
|
@@ -1778,7 +1808,7 @@ function extractMockFunctions(file, code) {
|
|
|
1778
1808
|
* Returns a map of route identifier (e.g., "GET /users") to block info
|
|
1779
1809
|
* including text and source positions for removal.
|
|
1780
1810
|
*/
|
|
1781
|
-
const DESCRIBE_MODIFIERS = new Set([
|
|
1811
|
+
const DESCRIBE_MODIFIERS = /* @__PURE__ */ new Set([
|
|
1782
1812
|
"skip",
|
|
1783
1813
|
"only",
|
|
1784
1814
|
"skipIf",
|
|
@@ -1843,7 +1873,7 @@ function mergeTestFile(existingCode, generatedCode) {
|
|
|
1843
1873
|
* `vite-plus/test`) would leave duplicate framework imports.
|
|
1844
1874
|
*/
|
|
1845
1875
|
function filterTestFrameworkImports(mergedImports, generatedFile) {
|
|
1846
|
-
const TEST_FRAMEWORK_MODULES = new Set([
|
|
1876
|
+
const TEST_FRAMEWORK_MODULES = /* @__PURE__ */ new Set([
|
|
1847
1877
|
"vitest",
|
|
1848
1878
|
"bun:test",
|
|
1849
1879
|
"vite-plus/test"
|
|
@@ -1966,9 +1996,9 @@ function makeMergedHandlers(handlers) {
|
|
|
1966
1996
|
if (existing) handlerMap.set(handler.fileName, {
|
|
1967
1997
|
...handler,
|
|
1968
1998
|
contents: [...existing.contents, ...handler.contents],
|
|
1969
|
-
routeNames: Array.from(new Set([...existing.routeNames, ...handler.routeNames])),
|
|
1999
|
+
routeNames: Array.from(/* @__PURE__ */ new Set([...existing.routeNames, ...handler.routeNames])),
|
|
1970
2000
|
needsFaker: existing.needsFaker || handler.needsFaker,
|
|
1971
|
-
usedRefs: new Set([...existing.usedRefs, ...handler.usedRefs])
|
|
2001
|
+
usedRefs: /* @__PURE__ */ new Set([...existing.usedRefs, ...handler.usedRefs])
|
|
1972
2002
|
});
|
|
1973
2003
|
else handlerMap.set(handler.fileName, handler);
|
|
1974
2004
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseConfig } from "../config/index.js";
|
|
2
2
|
import { r as setFormatOptions } from "../emit-CFR63U4L.js";
|
|
3
3
|
import { f as isRecord } from "../guard-zvkMUVYD.js";
|
|
4
|
-
import { n as parseOpenAPI, t as makeJob } from "../shared-
|
|
4
|
+
import { n as parseOpenAPI, t as makeJob } from "../shared-DRGflwP5.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import fsp from "node:fs/promises";
|
|
7
7
|
//#region src/vite-plugin/index.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono-takibi",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.99992",
|
|
4
4
|
"description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hono",
|
|
@@ -53,24 +53,21 @@
|
|
|
53
53
|
"import": "./dist/core/docs/index.js"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"publishConfig": {
|
|
57
|
-
"access": "public"
|
|
58
|
-
},
|
|
59
56
|
"dependencies": {
|
|
60
57
|
"@apidevtools/swagger-parser": "^12.1.0",
|
|
61
58
|
"@typespec/compiler": "^1.13.0",
|
|
62
59
|
"@typespec/openapi3": "^1.13.0",
|
|
63
|
-
"oxfmt": "^0.
|
|
60
|
+
"oxfmt": "^0.56.0",
|
|
64
61
|
"ts-morph": "^28.0.0",
|
|
65
62
|
"typescript": "^6.0.3",
|
|
66
63
|
"zod": "^4.4.3"
|
|
67
64
|
},
|
|
68
65
|
"devDependencies": {
|
|
69
|
-
"@types/node": "^
|
|
66
|
+
"@types/node": "^26.0.0",
|
|
70
67
|
"@typespec/http": "^1.13.0",
|
|
71
68
|
"@typespec/rest": "^0.83.0",
|
|
72
69
|
"@typespec/versioning": "^0.83.0",
|
|
73
|
-
"tsdown": "0.22.
|
|
70
|
+
"tsdown": "0.22.3"
|
|
74
71
|
},
|
|
75
72
|
"scripts": {
|
|
76
73
|
"build": "tsdown"
|