hono-takibi 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import { l as INPUT_EXTENSIONS } from "./constants-Bz8YiPum.js";
3
- import { NodeRuntime, NodeServices } from "@effect/platform-node";
3
+ import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
4
+ import * as NodeServices from "@effect/platform-node/NodeServices";
4
5
  import { Console, Effect, FileSystem, Option, Path, Ref, Schema, Stream } from "effect";
5
6
  import { Argument, CliError, Command, Flag } from "effect/cli";
6
7
  //#region package.json
7
- var version = "0.21.0";
8
+ var version = "0.22.0";
8
9
  var description = "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi";
9
10
  //#endregion
10
11
  //#region src/cli/index.ts
@@ -39,9 +40,9 @@ function loadConfig(configPath, reload) {
39
40
  function runJobs(config) {
40
41
  return Effect.gen(function* () {
41
42
  const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob, packageRoots }] = yield* Effect.promise(() => Promise.all([
42
- import("./openapi-DQRxq2_O.js").then((n) => n.t),
43
+ import("./openapi-DEZCoJlc.js").then((n) => n.t),
43
44
  import("./format-CuHABcKC.js").then((n) => n.r),
44
- import("./shared-COpMVRhG.js").then((n) => n.a)
45
+ import("./shared-C9-30gJ4.js").then((n) => n.a)
45
46
  ]));
46
47
  const openAPI = yield* parseOpenAPI(config.input);
47
48
  const jobs = makeJob(openAPI, config, yield* packageRoots(openAPI, config));
@@ -79,7 +80,7 @@ function reportJobs(config, previous) {
79
80
  onFailure: (error) => Console.error(`❌ ${error.message}`),
80
81
  onSuccess: (report) => Console.log(report)
81
82
  }));
82
- const { outsideSources } = yield* Effect.promise(() => import("./shared-COpMVRhG.js").then((n) => n.a));
83
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-C9-30gJ4.js").then((n) => n.a));
83
84
  const inputDirectory = path.dirname(path.resolve(config.input));
84
85
  return {
85
86
  inputDirectory,
@@ -206,7 +207,7 @@ function generate(args) {
206
207
  })]
207
208
  });
208
209
  if (input !== void 0 && output !== void 0) {
209
- const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-BDhKAR3A.js").then((n) => n.t)]));
210
+ const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DEZCoJlc.js").then((n) => n.t), import("./core-DmIVe-SP.js").then((n) => n.t)]));
210
211
  return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output));
211
212
  }
212
213
  const resolvedConfig = configPath ?? DEFAULT_CONFIG_FILE;
@@ -1,2 +1,2 @@
1
- import { t as docs } from "../../docs-Im22cNpx.js";
1
+ import { t as docs } from "../../docs-CtXltNLT.js";
2
2
  export { docs };
@@ -1,5 +1,5 @@
1
1
  import "../../constants-Bz8YiPum.js";
2
- import { B as isParameter, F as isMediaWithSchema, L as isOpenAPIPaths, Q as isSchemaArray, R as isOperation, V as isParameterArray, X as isRequestBody, g as statusCodeToNumber, it as isStringRef, j as isHttpMethod, u as makeSafeKey } from "../../utils-vw99OasL.js";
2
+ import { B as isParameter, F as isMediaWithSchema, L as isOpenAPIPaths, Q as isSchemaArray, R as isOperation, V as isParameterArray, X as isRequestBody, _ as toIdentifierPascalCase, g as statusCodeToNumber, it as isStringRef, j as isHttpMethod, u as makeSafeKey } from "../../utils-vw99OasL.js";
3
3
  import { t as emit } from "../../emit-uwlZZeRM.js";
4
4
  import { Effect } from "effect";
5
5
  import path from "node:path";
@@ -9,19 +9,49 @@ import path from "node:path";
9
9
  */
10
10
  const DEEP_READONLY_TYPE = "type DeepReadonly<T>=T extends(infer R)[]?readonly DeepReadonly<R>[]:T extends object?{readonly[K in keyof T]:DeepReadonly<T[K]>}:T;";
11
11
  /**
12
+ * The type names the declaration file uses for itself and for what it refers to; a
13
+ * component schema that would take one of them is given another name.
14
+ */
15
+ const RESERVED_TYPE_NAMES = /* @__PURE__ */ new Set(["DeepReadonly", "File"]);
16
+ /**
12
17
  * Generates TypeScript type declarations from OpenAPI specification.
13
18
  */
14
19
  function type(openAPI, output, readonly) {
15
- const schemaType = makeHonoSchemaType(openAPI);
20
+ const aliases = {
21
+ components: openAPI.components,
22
+ names: /* @__PURE__ */ new Map(),
23
+ bodies: /* @__PURE__ */ new Map(),
24
+ taken: new Set(RESERVED_TYPE_NAMES)
25
+ };
26
+ const schemaType = makeHonoSchemaType(openAPI, aliases);
16
27
  const wrappedType = readonly ? `DeepReadonly<${schemaType}>` : schemaType;
17
- const dts = `${readonly ? DEEP_READONLY_TYPE : ""}declare const routes:import('@hono/zod-openapi').OpenAPIHono<import('hono/types').Env,${wrappedType},'/'>\nexport default routes\n`;
28
+ const dts = `${readonly ? DEEP_READONLY_TYPE : ""}${[...aliases.bodies].map(([name, body]) => `type ${name}=${body};`).join("")}declare const routes:import('@hono/zod-openapi').OpenAPIHono<import('hono/types').Env,${wrappedType},'/'>\nexport default routes\n`;
18
29
  return Effect.gen(function* () {
19
30
  yield* emit(dts, path.dirname(output), output);
20
31
  return `Generated type code written to ${output}`;
21
32
  });
22
33
  }
23
- function makeHonoSchemaType(openAPI) {
24
- const { components } = openAPI;
34
+ /**
35
+ * The alias that stands for the component schema `schemaName`, written when it is not
36
+ * yet. The name is claimed before the body is written, so that a schema reaching
37
+ * itself finds its own name.
38
+ */
39
+ function aliasOf(schemaName, schema, aliases) {
40
+ const known = aliases.names.get(schemaName);
41
+ if (known !== void 0) return known;
42
+ const base = toIdentifierPascalCase(schemaName);
43
+ const name = aliases.taken.has(base) ? (() => {
44
+ let index = 2;
45
+ while (aliases.taken.has(`${base}${String(index)}`)) index += 1;
46
+ return `${base}${String(index)}`;
47
+ })() : base;
48
+ aliases.taken.add(name);
49
+ aliases.names.set(schemaName, name);
50
+ const body = makeSchemaTypeString(schema, aliases, /* @__PURE__ */ new Set([`#/components/schemas/${schemaName}`]));
51
+ aliases.bodies.set(name, body);
52
+ return name;
53
+ }
54
+ function makeHonoSchemaType(openAPI, aliases) {
25
55
  const paths = isOpenAPIPaths(openAPI.paths) ? openAPI.paths : {};
26
56
  const pathEntries = Object.entries(paths).flatMap(([openApiPath, pathItem]) => {
27
57
  const honoPath = makeHonoPath(openApiPath);
@@ -31,7 +61,7 @@ function makeHonoSchemaType(openAPI) {
31
61
  return isHttpMethod(method) && isOperation(op);
32
62
  }).map(([method, operation]) => ({
33
63
  method: `$${method}`,
34
- type: makeMethodType(operation, openApiPath, components, pathLevelParams)
64
+ type: makeMethodType(operation, openApiPath, aliases, pathLevelParams)
35
65
  }));
36
66
  return methods.length > 0 ? [{
37
67
  path: honoPath,
@@ -43,75 +73,76 @@ function makeHonoSchemaType(openAPI) {
43
73
  function makeHonoPath(openApiPath) {
44
74
  return openApiPath.replaceAll(/\{([^}]+)\}/gu, ":$1");
45
75
  }
46
- function makeMethodType(operation, openApiPath, components, pathLevelParams) {
47
- const inputType = makeInputType(operation, openApiPath, components, pathLevelParams);
48
- const outputTypes = makeOutputTypes(operation.responses, components, inputType);
76
+ function makeMethodType(operation, openApiPath, aliases, pathLevelParams) {
77
+ const inputType = makeInputType(operation, openApiPath, aliases, pathLevelParams);
78
+ const outputTypes = makeOutputTypes(operation.responses, aliases, inputType);
49
79
  return outputTypes.length === 0 ? `{input:${inputType};output:{};outputFormat:string;status:200}` : outputTypes.length === 1 ? outputTypes[0] : outputTypes.join("|");
50
80
  }
51
- function makeInputType(operation, openApiPath, components, pathLevelParams) {
81
+ function makeInputType(operation, openApiPath, aliases, pathLevelParams) {
82
+ const { components } = aliases;
52
83
  const pathLevelResolved = pathLevelParams.map((p) => makeResolvedParameter(p, components)).filter((p) => p !== void 0);
53
84
  const operationLevelResolved = (operation.parameters ?? []).map((p) => makeResolvedParameter(p, components)).filter((p) => p !== void 0);
54
85
  const operationParamNames = new Set(operationLevelResolved.map((p) => p.name));
55
86
  const resolvedParams = [...operationLevelResolved, ...pathLevelResolved.filter((p) => !operationParamNames.has(p.name))];
56
87
  const parts = [
57
- makePathParams(openApiPath).length > 0 ? makeParamPart(resolvedParams.filter((p) => p.in === "path"), components) : void 0,
58
- makeQueryPart(resolvedParams.filter((p) => p.in === "query"), components),
59
- makeHeaderPart(resolvedParams.filter((p) => p.in === "header"), components),
60
- makeCookiePart(resolvedParams.filter((p) => p.in === "cookie"), components),
61
- ...makeBodyParts(operation.requestBody, components)
88
+ makePathParams(openApiPath).length > 0 ? makeParamPart(resolvedParams.filter((p) => p.in === "path"), aliases) : void 0,
89
+ makeQueryPart(resolvedParams.filter((p) => p.in === "query"), aliases),
90
+ makeHeaderPart(resolvedParams.filter((p) => p.in === "header"), aliases),
91
+ makeCookiePart(resolvedParams.filter((p) => p.in === "cookie"), aliases),
92
+ ...makeBodyParts(operation.requestBody, aliases)
62
93
  ].filter((p) => p !== void 0);
63
94
  return parts.length === 0 ? "{}" : parts.join("&");
64
95
  }
65
96
  function makePathParams(openApiPath) {
66
97
  return [...openApiPath.matchAll(/\{([^}]+)\}/gu)].map((m) => m[1]);
67
98
  }
68
- function makeParamPart(params, components) {
99
+ function makeParamPart(params, aliases) {
69
100
  const props = params.map((p) => {
70
- return `${makeSafeKey(p.name)}:${makeSchemaTypeString(makeParameterSchema(p), components, /* @__PURE__ */ new Set())}`;
101
+ return `${makeSafeKey(p.name)}:${makeSchemaTypeString(makeParameterSchema(p), aliases, /* @__PURE__ */ new Set())}`;
71
102
  });
72
103
  return props.length > 0 ? `{param:{${props.join(";")}}}` : void 0;
73
104
  }
74
- function makeQueryPart(params, components) {
105
+ function makeQueryPart(params, aliases) {
75
106
  const props = params.map((p) => {
76
- const typeStr = makeSchemaTypeString(makeParameterSchema(p), components, /* @__PURE__ */ new Set());
107
+ const typeStr = makeSchemaTypeString(makeParameterSchema(p), aliases, /* @__PURE__ */ new Set());
77
108
  const safeKey = makeSafeKey(p.name);
78
109
  return p.required ? `${safeKey}:${typeStr}` : `${safeKey}?:${typeStr}|undefined`;
79
110
  });
80
111
  return props.length > 0 ? `{query:{${props.join(";")}}}` : void 0;
81
112
  }
82
- function makeHeaderPart(params, components) {
113
+ function makeHeaderPart(params, aliases) {
83
114
  const props = params.map((p) => {
84
- const typeStr = makeSchemaTypeString(makeParameterSchema(p), components, /* @__PURE__ */ new Set());
115
+ const typeStr = makeSchemaTypeString(makeParameterSchema(p), aliases, /* @__PURE__ */ new Set());
85
116
  const safeKey = makeSafeKey(p.name);
86
117
  return p.required ? `${safeKey}:${typeStr}` : `${safeKey}?:${typeStr}|undefined`;
87
118
  });
88
119
  return props.length > 0 ? `{header:{${props.join(";")}}}` : void 0;
89
120
  }
90
- function makeCookiePart(params, components) {
121
+ function makeCookiePart(params, aliases) {
91
122
  const props = params.map((p) => {
92
- const typeStr = makeSchemaTypeString(makeParameterSchema(p), components, /* @__PURE__ */ new Set());
123
+ const typeStr = makeSchemaTypeString(makeParameterSchema(p), aliases, /* @__PURE__ */ new Set());
93
124
  const safeKey = makeSafeKey(p.name);
94
125
  return p.required ? `${safeKey}:${typeStr}` : `${safeKey}?:${typeStr}|undefined`;
95
126
  });
96
127
  return props.length > 0 ? `{cookie:{${props.join(";")}}}` : void 0;
97
128
  }
98
- function makeBodyParts(requestBody, components) {
99
- const resolved = requestBody ? makeResolvedRequestBody(requestBody, components) : void 0;
129
+ function makeBodyParts(requestBody, aliases) {
130
+ const resolved = requestBody ? makeResolvedRequestBody(requestBody, aliases.components) : void 0;
100
131
  if (!resolved?.content) return [];
101
132
  const mediaEntries = Object.entries(resolved.content).filter((entry) => isMediaWithSchema(entry[1]));
102
133
  const classified = {
103
- jsonTypes: [...new Set(mediaEntries.filter(([mediaType]) => mediaType.includes("json") || mediaType.startsWith("application/") || mediaType.startsWith("text/")).map(([, media]) => makeSchemaTypeString(media.schema, components, /* @__PURE__ */ new Set())))],
104
- formTypes: [...new Set(mediaEntries.filter(([mediaType]) => mediaType.includes("form")).map(([, media]) => makeSchemaTypeString(media.schema, components, /* @__PURE__ */ new Set())))]
134
+ jsonTypes: [...new Set(mediaEntries.filter(([mediaType]) => mediaType.includes("json") || mediaType.startsWith("application/") || mediaType.startsWith("text/")).map(([, media]) => makeSchemaTypeString(media.schema, aliases, /* @__PURE__ */ new Set())))],
135
+ formTypes: [...new Set(mediaEntries.filter(([mediaType]) => mediaType.includes("form")).map(([, media]) => makeSchemaTypeString(media.schema, aliases, /* @__PURE__ */ new Set())))]
105
136
  };
106
137
  return [classified.jsonTypes.length > 0 ? `{json:${classified.jsonTypes.length === 1 ? classified.jsonTypes[0] : `(${classified.jsonTypes.join("|")})`}}` : void 0, classified.formTypes.length > 0 ? `{form:${classified.formTypes.length === 1 ? classified.formTypes[0] : `(${classified.formTypes.join("|")})`}}` : void 0].filter((p) => p !== void 0);
107
138
  }
108
- function makeOutputTypes(responses, components, inputType) {
139
+ function makeOutputTypes(responses, aliases, inputType) {
109
140
  return Object.entries(responses).flatMap(([statusCode, response]) => {
110
- const resolvedResponse = makeResolvedResponse(response, components);
141
+ const resolvedResponse = makeResolvedResponse(response, aliases.components);
111
142
  const status = statusCodeToNumber(statusCode);
112
143
  if (!resolvedResponse.content) return [`{input:${inputType};output:{};outputFormat:string;status:${status}}`];
113
144
  return Object.entries(resolvedResponse.content).filter((entry) => isMediaWithSchema(entry[1])).map(([mediaType, media]) => {
114
- return `{input:${inputType};output:${makeSchemaTypeString(media.schema, components, /* @__PURE__ */ new Set())};outputFormat:${isJsonMediaType(mediaType) ? "'json'" : "'text'"};status:${status}}`;
145
+ return `{input:${inputType};output:${makeSchemaTypeString(media.schema, aliases, /* @__PURE__ */ new Set())};outputFormat:${isJsonMediaType(mediaType) ? "'json'" : "'text'"};status:${status}}`;
115
146
  });
116
147
  });
117
148
  }
@@ -156,12 +187,12 @@ function makeParameterSchema(parameter) {
156
187
  }
157
188
  return parameter.schema ?? {};
158
189
  }
159
- function makeSchemaTypeString(schema, components, visited) {
190
+ function makeSchemaTypeString(schema, aliases, visited) {
160
191
  if (!schema) return "unknown";
161
- if (schema.$ref) return visited.has(schema.$ref) ? "unknown" : makeRefTypeString(schema.$ref, components, /* @__PURE__ */ new Set([...visited, schema.$ref]));
162
- if (schema.oneOf && schema.oneOf.length > 0) return schema.oneOf.map((s) => makeSchemaTypeString(s, components, visited)).join("|");
163
- if (schema.anyOf && schema.anyOf.length > 0) return schema.anyOf.map((s) => makeSchemaTypeString(s, components, visited)).join("|");
164
- if (schema.allOf && schema.allOf.length > 0) return makeAllOfTypeString(schema.allOf, components, visited);
192
+ if (schema.$ref) return makeRefTypeString(schema.$ref, aliases);
193
+ if (schema.oneOf && schema.oneOf.length > 0) return schema.oneOf.map((s) => makeSchemaTypeString(s, aliases, visited)).join("|");
194
+ if (schema.anyOf && schema.anyOf.length > 0) return schema.anyOf.map((s) => makeSchemaTypeString(s, aliases, visited)).join("|");
195
+ if (schema.allOf && schema.allOf.length > 0) return makeAllOfTypeString(schema.allOf, aliases, visited);
165
196
  const isBigintLiteral = (value) => typeof value === "number" && Number.isInteger(value) && (Array.isArray(schema.type) ? schema.type.includes("integer") : schema.type === "integer") && (schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint");
166
197
  if (schema.enum && schema.enum.length > 0) return schema.enum.map((v) => typeof v === "string" ? `'${v.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'` : isBigintLiteral(v) ? `${v}n` : String(v)).join("|");
167
198
  if (schema.const !== void 0) {
@@ -172,27 +203,32 @@ function makeSchemaTypeString(schema, components, visited) {
172
203
  }
173
204
  const types = makeNormalizedTypes(schema);
174
205
  const isNullable = schema.nullable === true || types.includes("null");
175
- const baseType = makeBaseTypeString(schema, types.filter((t) => t !== "null"), components, visited);
206
+ const baseType = makeBaseTypeString(schema, types.filter((t) => t !== "null"), aliases, visited);
176
207
  return isNullable ? `(${baseType}|null)` : baseType;
177
208
  }
178
209
  function makeNormalizedTypes(schema) {
179
210
  return schema.type ? Array.isArray(schema.type) ? schema.type : [schema.type] : ["object"];
180
211
  }
181
- function makeBaseTypeString(schema, types, components, visited) {
182
- return types.length > 1 ? types.map((t) => makeSingleTypeString(schema, t, components, visited)).join("|") : makeSingleTypeString(schema, types[0] ?? "object", components, visited);
212
+ function makeBaseTypeString(schema, types, aliases, visited) {
213
+ return types.length > 1 ? types.map((t) => makeSingleTypeString(schema, t, aliases, visited)).join("|") : makeSingleTypeString(schema, types[0] ?? "object", aliases, visited);
183
214
  }
184
215
  const PRIMITIVE_TYPE_MAP = {
185
216
  boolean: "boolean",
186
217
  null: "null"
187
218
  };
188
- function makeSingleTypeString(schema, type, components, visited) {
219
+ function makeSingleTypeString(schema, type, aliases, visited) {
189
220
  if (type === "string") return schema.format === "binary" ? "File" : "string";
190
221
  if (type === "number" || type === "integer") return schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint" ? "bigint" : "number";
191
- if (type === "array") return makeArrayTypeString(schema, components, visited);
192
- if (type === "object") return makeObjectTypeString(schema, components, visited);
222
+ if (type === "array") return makeArrayTypeString(schema, aliases, visited);
223
+ if (type === "object") return makeObjectTypeString(schema, aliases, visited);
193
224
  return PRIMITIVE_TYPE_MAP[type] ?? "unknown";
194
225
  }
195
- function makeRefTypeString(ref, components, visited) {
226
+ /**
227
+ * A `$ref` into `components.schemas` is the name of the alias that stands for the
228
+ * schema; any other reference, or one to a schema that is not there, is `unknown`.
229
+ */
230
+ function makeRefTypeString(ref, aliases) {
231
+ const { components } = aliases;
196
232
  if (!components) return "unknown";
197
233
  const parts = ref.split("/");
198
234
  const componentType = parts[2];
@@ -200,13 +236,13 @@ function makeRefTypeString(ref, components, visited) {
200
236
  if (!refName) return "unknown";
201
237
  if (componentType === "schemas" && components.schemas) {
202
238
  const schema = components.schemas[refName];
203
- return schema ? makeSchemaTypeString(schema, components, visited) : "unknown";
239
+ return schema ? aliasOf(refName, schema, aliases) : "unknown";
204
240
  }
205
241
  return "unknown";
206
242
  }
207
- function makeAllOfTypeString(allOf, components, visited) {
243
+ function makeAllOfTypeString(allOf, aliases, visited) {
208
244
  const mergedProps = allOf.reduce((acc, subSchema) => {
209
- const newProps = makePropertyMap(subSchema, components, visited);
245
+ const newProps = makePropertyMap(subSchema, aliases, visited);
210
246
  const result = new Map(acc);
211
247
  for (const [key, value] of newProps) {
212
248
  const existing = result.get(key);
@@ -223,15 +259,15 @@ function makeAllOfTypeString(allOf, components, visited) {
223
259
  return required ? `${safeKey}:${type}` : `${safeKey}?:${type}|undefined`;
224
260
  }).join(";")}}`;
225
261
  }
226
- function makePropertyMap(schema, components, visited) {
262
+ function makePropertyMap(schema, aliases, visited) {
227
263
  if (schema.$ref && visited.has(schema.$ref)) return /* @__PURE__ */ new Map();
228
264
  const nextVisited = schema.$ref ? /* @__PURE__ */ new Set([...visited, schema.$ref]) : visited;
229
- const resolved = makeResolvedSchema(schema, components);
230
- const fromAllOf = new Map(resolved.allOf && resolved.allOf.length > 0 ? resolved.allOf.flatMap((subSchema) => [...makePropertyMap(subSchema, components, nextVisited).entries()]) : []);
265
+ const resolved = makeResolvedSchema(schema, aliases.components);
266
+ const fromAllOf = new Map(resolved.allOf && resolved.allOf.length > 0 ? resolved.allOf.flatMap((subSchema) => [...makePropertyMap(subSchema, aliases, nextVisited).entries()]) : []);
231
267
  if (!resolved.properties) return fromAllOf;
232
268
  const requiredSet = new Set(Array.isArray(resolved.required) ? resolved.required : []);
233
269
  const currentProps = new Map(Object.entries(resolved.properties).map(([key, propSchema]) => {
234
- const propType = makeSchemaTypeString(propSchema, components, nextVisited);
270
+ const propType = makeSchemaTypeString(propSchema, aliases, nextVisited);
235
271
  const existing = fromAllOf.get(key);
236
272
  return [key, {
237
273
  type: propType,
@@ -240,26 +276,26 @@ function makePropertyMap(schema, components, visited) {
240
276
  }));
241
277
  return new Map([...fromAllOf, ...currentProps]);
242
278
  }
243
- function makeArrayTypeString(schema, components, visited) {
279
+ function makeArrayTypeString(schema, aliases, visited) {
244
280
  if (!schema.items) return "unknown[]";
245
281
  const items = schema.items;
246
282
  if (typeof items === "boolean") return items ? "unknown[]" : "[]";
247
- if (isSchemaArray(items)) return items.length > 1 ? `[${items.map((item) => makeSchemaTypeString(item, components, visited)).join(",")}]` : items[0] ? makeWrappedArrayType(makeSchemaTypeString(items[0], components, visited)) : "unknown[]";
248
- return makeWrappedArrayType(makeSchemaTypeString(items, components, visited));
283
+ if (isSchemaArray(items)) return items.length > 1 ? `[${items.map((item) => makeSchemaTypeString(item, aliases, visited)).join(",")}]` : items[0] ? makeWrappedArrayType(makeSchemaTypeString(items[0], aliases, visited)) : "unknown[]";
284
+ return makeWrappedArrayType(makeSchemaTypeString(items, aliases, visited));
249
285
  }
250
286
  function makeWrappedArrayType(typeStr) {
251
287
  return typeStr.includes("|") ? `(${typeStr})[]` : `${typeStr}[]`;
252
288
  }
253
- function makeObjectTypeString(schema, components, visited) {
289
+ function makeObjectTypeString(schema, aliases, visited) {
254
290
  const { properties, additionalProperties, required } = schema;
255
291
  if (!properties || Object.keys(properties).length === 0) {
256
292
  if (additionalProperties === false) return "{}";
257
- if (typeof additionalProperties === "object") return `{[x:string]:${makeSchemaTypeString(additionalProperties, components, visited)}}`;
293
+ if (typeof additionalProperties === "object") return `{[x:string]:${makeSchemaTypeString(additionalProperties, aliases, visited)}}`;
258
294
  return "{[x:string]:unknown}";
259
295
  }
260
296
  const requiredSet = new Set(Array.isArray(required) ? required : []);
261
297
  return `{${Object.entries(properties).map(([key, propSchema]) => {
262
- const propType = makeSchemaTypeString(propSchema, components, visited);
298
+ const propType = makeSchemaTypeString(propSchema, aliases, visited);
263
299
  const safeKey = makeSafeKey(key);
264
300
  return requiredSet.has(key) ? `${safeKey}:${propType}` : `${safeKey}?:${propType}|undefined`;
265
301
  }).join(";")}}`;
@@ -2,17 +2,16 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { n as COMPONENT_NAMES, p as TEXT_MEDIA_TYPE, r as COMPONENT_REF_PREFIX, s as HTTP_METHODS, u as JSON_MEDIA_TYPE } from "./constants-Bz8YiPum.js";
3
3
  import { i as GenerateError, n as fmt } from "./format-CuHABcKC.js";
4
4
  import { $ as isSchemaObject, B as isParameter, D as isCallbacks, F as isMediaWithSchema, G as isPathItemEntry, J as isRefObject, K as isPathItemRef, L as isOpenAPIPaths, N as isInlineMedia, Q as isSchemaArray, R as isOperation, T as hasRequestBodyContent, W as isPathItem, _ as toIdentifierPascalCase, at as isValidIdent, b as zodToOpenAPISchema, c as makeBarrel, d as makeStringLiteral, f as methodPath, g as statusCodeToNumber, i as ensureSuffix, j as isHttpMethod, m as renderNamedImport, nt as isSecurityScheme, p as normalizeTypes, r as cyclicNodes, s as escapeRegexLiteral, tt as isSecurityArray, u as makeSafeKey, v as uncapitalize, w as hasNumericConstraint, y as uncapitalizeWord } from "./utils-vw99OasL.js";
5
- import { C as resolveParameter, S as makeWebhookEntries, _ as makeCallback, a as responsesCode, b as makeRouteEntries, c as headersCode, d as makeExportConst, f as makeImports, g as zodToOpenAPI, h as ast, i as schemasCode, l as makeSplitSchemaFile, m as analyzeCircularSchemas, n as routeCode, o as requestBodiesCode, p as makeModuleSpec, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as makeConst, v as makePathItem, w as resolvePathItem, x as makeRouteProperties, y as makeRef } from "./openapi-BRK0691x.js";
5
+ import { A as resolvePathItem, C as makeCallback, D as makeRouteProperties, E as makeRouteEntries, O as makeWebhookEntries, S as zodToOpenAPI, T as makeRef, _ as descendantsWhere, a as responsesCode, b as parseSource, c as headersCode, d as makeExportConst, f as makeImports, g as declarationOf, h as ast, i as schemasCode, k as resolveParameter, l as makeSplitSchemaFile, m as analyzeCircularSchemas, n as routeCode, o as requestBodiesCode, p as makeModuleSpec, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as makeConst, v as identifierNames, w as makePathItem, x as textOf, y as parseModule } from "./openapi-OxNU2RgN.js";
6
6
  import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-Bgtv3nGI.js";
7
7
  import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-K6j5IJXi.js";
8
8
  import { t as emit } from "./emit-uwlZZeRM.js";
9
9
  import { t as hooks } from "./hooks-CR7angVC.js";
10
- import { t as docs } from "./docs-Im22cNpx.js";
10
+ import { t as docs } from "./docs-CtXltNLT.js";
11
11
  import { rpc } from "./core/rpc/index.js";
12
12
  import { type } from "./core/type/index.js";
13
13
  import { Effect } from "effect";
14
14
  import path, { basename, dirname, join, relative } from "node:path";
15
- import { Node, Project, SyntaxKind } from "ts-morph";
16
15
  //#region src/helper/faker.ts
17
16
  const FORMAT_TO_FAKER = {
18
17
  date: "faker.date.past().toISOString().slice(0, 10)",
@@ -647,17 +646,46 @@ function isInlineHandlerName(name) {
647
646
  return name.endsWith("Handler") && !name.endsWith("RouteHandler");
648
647
  }
649
648
  /**
650
- * Parses a code snippet into a temporary in-memory SourceFile for AST analysis.
649
+ * Parses a code snippet for AST analysis.
651
650
  */
652
651
  function parseSnippet(code) {
653
- return new Project({ useInMemoryFileSystem: true }).createSourceFile("snippet.ts", code);
652
+ return {
653
+ code,
654
+ ...parseSource(code)
655
+ };
656
+ }
657
+ function variableStatements(source) {
658
+ const { body } = source.program;
659
+ return body.flatMap((statement, index) => {
660
+ const { node, exported } = declarationOf(statement);
661
+ if (node.type !== "VariableDeclaration") return [];
662
+ return [{
663
+ declaration: node,
664
+ exported,
665
+ start: statement.start,
666
+ end: statement.end,
667
+ fullStart: index === 0 ? 0 : body[index - 1]?.end ?? 0,
668
+ text: textOf(source.code, statement)
669
+ }];
670
+ });
671
+ }
672
+ /**
673
+ * The name a declaration binds, as its source spells it: the identifier, or the whole
674
+ * pattern of a destructuring, without the type annotation.
675
+ */
676
+ function bindingName(source, id) {
677
+ if (id.type === "Identifier") return id.name;
678
+ return textOf(source.code, {
679
+ start: id.start,
680
+ end: id.typeAnnotation?.start ?? id.end
681
+ }).trimEnd();
654
682
  }
655
683
  /**
656
684
  * Returns the source position just after the last import declaration.
657
685
  * Returns 0 if there are no import declarations.
658
686
  */
659
- function getBodyStart(file) {
660
- return file.getImportDeclarations().at(-1)?.getEnd() ?? 0;
687
+ function getBodyStart(source) {
688
+ return source.program.body.filter((statement) => statement.type === "ImportDeclaration").at(-1)?.end ?? 0;
661
689
  }
662
690
  /**
663
691
  * Applies range operations (replacements/deletions) to source code.
@@ -670,15 +698,12 @@ function applyRangeOps(code, startPos, ops) {
670
698
  return [...ops.flatMap(([start, , repl], i) => [code.slice(cursors[i], start), repl]), code.slice(cursors.at(-1) ?? startPos)].join("");
671
699
  }
672
700
  /**
673
- * Creates a pair of in-memory source files for AST analysis.
674
- *
675
- * Centralizes Project creation to avoid redundant instances.
701
+ * The two files a merge reads: the one on disk and the one just generated.
676
702
  */
677
703
  function makeSourcePair(existingCode, generatedCode) {
678
- const project = new Project({ useInMemoryFileSystem: true });
679
704
  return {
680
- existingFile: project.createSourceFile("existing.ts", existingCode),
681
- generatedFile: project.createSourceFile("generated.ts", generatedCode)
705
+ existingFile: parseSnippet(existingCode),
706
+ generatedFile: parseSnippet(generatedCode)
682
707
  };
683
708
  }
684
709
  /**
@@ -687,11 +712,14 @@ function makeSourcePair(existingCode, generatedCode) {
687
712
  * Returns a Map from handler name to its VariableStatement AST node.
688
713
  * A "handler" is any exported variable whose name ends with `Handler`.
689
714
  */
690
- function collectExportedConsts(file, suffix) {
715
+ function collectExportedConsts(source, suffix) {
691
716
  const map = /* @__PURE__ */ new Map();
692
- for (const stmt of file.getVariableStatements()) {
693
- if (!stmt.isExported()) continue;
694
- for (const decl of stmt.getDeclarations()) if (decl.getName().endsWith(suffix)) map.set(decl.getName(), stmt);
717
+ for (const stmt of variableStatements(source)) {
718
+ if (!stmt.exported) continue;
719
+ for (const decl of stmt.declaration.declarations) {
720
+ const name = bindingName(source, decl.id);
721
+ if (name.endsWith(suffix)) map.set(name, stmt);
722
+ }
695
723
  }
696
724
  return map;
697
725
  }
@@ -713,43 +741,32 @@ function collectInlineRouteNames(code) {
713
741
  * `const app = new OpenAPIHono()` and the `function mockXxx() {…}` helpers the exported
714
742
  * handler statements depend on.
715
743
  */
716
- function collectSupportStatements(file) {
744
+ function collectSupportStatements(source) {
717
745
  const map = /* @__PURE__ */ new Map();
718
- for (const stmt of file.getStatements()) if (Node.isVariableStatement(stmt)) {
719
- if (stmt.isExported()) continue;
720
- for (const decl of stmt.getDeclarations()) map.set(decl.getName(), stmt.getText());
721
- } else if (Node.isFunctionDeclaration(stmt)) {
722
- const name = stmt.getName();
723
- if (name !== void 0 && !stmt.isExported()) map.set(name, stmt.getText());
746
+ for (const stmt of source.program.body) {
747
+ const { node, exported } = declarationOf(stmt);
748
+ if (exported) continue;
749
+ if (node.type === "VariableDeclaration") for (const decl of node.declarations) map.set(bindingName(source, decl.id), textOf(source.code, stmt));
750
+ else if ((node.type === "FunctionDeclaration" || node.type === "TSDeclareFunction") && node.id !== null) map.set(node.id.name, textOf(source.code, stmt));
724
751
  }
725
752
  return map;
726
753
  }
727
754
  /**
728
755
  * Lists every name a file declares at the top level, including imported bindings.
729
756
  */
730
- function collectDeclaredNames(file) {
757
+ function collectDeclaredNames(source) {
731
758
  const names = /* @__PURE__ */ new Set();
732
- for (const decl of file.getVariableDeclarations()) names.add(decl.getName());
733
- for (const fn of file.getFunctions()) {
734
- const name = fn.getName();
735
- if (name !== void 0) names.add(name);
736
- }
737
- for (const cls of file.getClasses()) {
738
- const name = cls.getName();
739
- if (name !== void 0) names.add(name);
740
- }
741
- for (const en of file.getEnums()) names.add(en.getName());
742
- for (const imp of file.getImportDeclarations()) {
743
- const def = imp.getDefaultImport();
744
- if (def) names.add(def.getText());
745
- const ns = imp.getNamespaceImport();
746
- if (ns) names.add(ns.getText());
747
- for (const named of imp.getNamedImports()) names.add((named.getAliasNode() ?? named.getNameNode()).getText());
759
+ for (const stmt of source.program.body) {
760
+ const { node } = declarationOf(stmt);
761
+ if (node.type === "VariableDeclaration") for (const decl of node.declarations) names.add(bindingName(source, decl.id));
762
+ else if ((node.type === "FunctionDeclaration" || node.type === "TSDeclareFunction" || node.type === "ClassDeclaration") && node.id !== null) names.add(node.id.name);
763
+ else if (node.type === "TSEnumDeclaration") names.add(node.id.name);
764
+ else if (node.type === "ImportDeclaration") for (const specifier of node.specifiers) names.add(specifier.local.name);
748
765
  }
749
766
  return names;
750
767
  }
751
768
  function collectIdentifiers(code) {
752
- return new Set(parseSnippet(code).getDescendantsOfKind(SyntaxKind.Identifier).map((id) => id.getText()));
769
+ return new Set(identifierNames(parseModule(code)));
753
770
  }
754
771
  /**
755
772
  * Picks the generated support declarations the merged handler body needs but the existing
@@ -798,28 +815,29 @@ function missingSupportStatements(existingFile, generatedFile, mergedBody) {
798
815
  */
799
816
  function mergeHandlerFile(existingCode, generatedCode) {
800
817
  const { existingFile, generatedFile } = makeSourcePair(existingCode, generatedCode);
818
+ if (existingFile.errors.length > 0) return existingCode;
801
819
  const existingHandlers = collectExportedConsts(existingFile, "Handler");
802
820
  const generatedHandlers = collectExportedConsts(generatedFile, "Handler");
803
821
  const generatedHasInline = [...generatedHandlers.keys()].some(isInlineHandlerName);
804
822
  const deleteOps = [...existingHandlers.entries()].filter(([name]) => !generatedHandlers.has(name) && (name.endsWith("RouteHandler") || generatedHasInline && isInlineHandlerName(name))).map(([, stmt]) => [
805
- stmt.getFullStart(),
806
- stmt.getEnd(),
823
+ stmt.fullStart,
824
+ stmt.end,
807
825
  ""
808
826
  ]);
809
827
  const mergeOps = [...existingHandlers.entries()].filter(([name]) => isInlineHandlerName(name) && generatedHandlers.has(name)).flatMap(([name, stmt]) => {
810
828
  const genStmt = generatedHandlers.get(name);
811
829
  if (!genStmt) return [];
812
- const merged = mergeInlineHandler(stmt.getText(), genStmt.getText());
813
- if (merged === stmt.getText()) return [];
830
+ const merged = mergeInlineHandler(stmt.text, genStmt.text);
831
+ if (merged === stmt.text) return [];
814
832
  return [[
815
- stmt.getStart(),
816
- stmt.getEnd(),
833
+ stmt.start,
834
+ stmt.end,
817
835
  merged
818
836
  ]];
819
837
  });
820
838
  const bodyStart = getBodyStart(existingFile);
821
839
  const body = applyRangeOps(existingCode, bodyStart, [...deleteOps, ...mergeOps].filter(([start]) => start >= bodyStart).toSorted(([a], [b]) => a - b)).replaceAll(/\n{3,}/gu, "\n\n");
822
- const newHandlerStatements = [...generatedHandlers.entries()].filter(([name]) => !existingHandlers.has(name)).map(([, stmt]) => stmt.getText());
840
+ const newHandlerStatements = [...generatedHandlers.entries()].filter(([name]) => !existingHandlers.has(name)).map(([, stmt]) => stmt.text);
823
841
  const mergedImports = mergeImports(existingFile, generatedFile);
824
842
  const supportStatements = missingSupportStatements(existingFile, generatedFile, `${body}\n${newHandlerStatements.join("\n")}`);
825
843
  return joinSections([
@@ -844,15 +862,16 @@ function mergeHandlerFile(existingCode, generatedCode) {
844
862
  */
845
863
  function mergeDefineFile(existingCode, generatedCode) {
846
864
  const { existingFile, generatedFile } = makeSourcePair(existingCode, generatedCode);
865
+ if (existingFile.errors.length > 0) return existingCode;
847
866
  const existingRoutes = collectExportedConsts(existingFile, "Route");
848
867
  const generatedRoutes = collectExportedConsts(generatedFile, "Route");
849
868
  const bodyStart = getBodyStart(existingFile);
850
869
  const body = applyRangeOps(existingCode, bodyStart, [...existingRoutes.entries()].filter(([name]) => !generatedRoutes.has(name)).map(([, stmt]) => [
851
- stmt.getFullStart(),
852
- stmt.getEnd(),
870
+ stmt.fullStart,
871
+ stmt.end,
853
872
  ""
854
873
  ]).filter(([start]) => start >= bodyStart).toSorted(([a], [b]) => a - b)).replaceAll(/\n{3,}/gu, "\n\n");
855
- const newRouteStatements = [...generatedRoutes.entries()].filter(([name]) => !existingRoutes.has(name)).map(([, stmt]) => stmt.getText());
874
+ const newRouteStatements = [...generatedRoutes.entries()].filter(([name]) => !existingRoutes.has(name)).map(([, stmt]) => stmt.text);
856
875
  return joinSections([
857
876
  mergeImports(existingFile, generatedFile, false).join("\n"),
858
877
  body.trim(),
@@ -876,32 +895,33 @@ const DEFAULT_ENTRY = { app: "app" };
876
895
  */
877
896
  function mergeAppFile(existingCode, generatedCode, names = DEFAULT_ENTRY) {
878
897
  const { existingFile, generatedFile } = makeSourcePair(existingCode, generatedCode);
879
- const generatedStatements = [...findOwnedStatements(generatedFile, names.app, /* @__PURE__ */ new Set())].toSorted(([, a], [, b]) => a.getStart() - b.getStart());
898
+ if (existingFile.errors.length > 0) return existingCode;
899
+ const generatedStatements = [...findOwnedStatements(generatedFile, names.app, /* @__PURE__ */ new Set())].toSorted(([, a], [, b]) => a.start - b.start);
880
900
  const existingOwned = findOwnedStatements(existingFile, names.app, new Set(generatedStatements.map(([name]) => name)));
881
901
  const generatedOwned = generatedStatements.map(([name, stmt]) => [
882
902
  name,
883
- stmt.getStart(),
884
- injectChainPrefix(stmt.getText(), extractChainPrefix(existingOwned.get(name)?.getText() ?? "", names.app), names.app)
903
+ stmt.start,
904
+ injectChainPrefix(stmt.text, extractChainPrefix(existingOwned.get(name)?.text ?? "", names.app), names.app)
885
905
  ]);
886
906
  const placed = placeOwned(generatedOwned, existingOwned);
887
907
  const bodyStart = getBodyStart(existingFile);
888
908
  const ops = [...existingOwned].flatMap(([name, stmt]) => {
889
909
  const text = placed.get(name);
890
910
  if (text !== void 0) return [[
891
- stmt.getStart(),
892
- stmt.getEnd(),
911
+ stmt.start,
912
+ stmt.end,
893
913
  text
894
914
  ]];
895
915
  return [[
896
- stmt.getFullStart(),
897
- stmt.getEnd(),
916
+ stmt.fullStart,
917
+ stmt.end,
898
918
  ""
899
919
  ]];
900
920
  }).filter(([start]) => start >= bodyStart).toSorted(([a], [b]) => a - b);
901
921
  const [firstStatement] = generatedStatements;
902
922
  const generatedOwnedText = firstStatement === void 0 ? void 0 : generatedStatements.map(([, stmt], index) => {
903
923
  const next = generatedStatements[index + 1]?.[1];
904
- const between = generatedCode.slice(stmt.getEnd(), next?.getStart());
924
+ const between = generatedCode.slice(stmt.end, next?.start);
905
925
  return `${generatedOwned[index]?.[2] ?? ""}${between}`;
906
926
  }).join("");
907
927
  const body = makeAppBody({
@@ -951,13 +971,14 @@ function ownedShape(app) {
951
971
  * it; one of a name the generator writes this time is the generator's also with a chain the
952
972
  * user put into it.
953
973
  */
954
- function findOwnedStatements(file, app, written) {
974
+ function findOwnedStatements(source, app, written) {
955
975
  const shape = ownedShape(app);
956
- return new Map(file.getVariableStatements().filter((stmt) => stmt.isExported() && stmt.getDeclarations().length === 1).flatMap((stmt) => {
957
- const [decl] = stmt.getDeclarations();
976
+ return new Map(variableStatements(source).filter((stmt) => stmt.exported && stmt.declaration.declarations.length === 1).flatMap((stmt) => {
977
+ const [decl] = stmt.declaration.declarations;
958
978
  if (decl === void 0) return [];
959
- const made = decl.getInitializer()?.getText() ?? "";
960
- return (written.has(decl.getName()) ? shape.chained : shape.written).test(made) ? [[decl.getName(), stmt]] : [];
979
+ const made = decl.init === null ? "" : textOf(source.code, decl.init);
980
+ const name = bindingName(source, decl.id);
981
+ return (written.has(name) ? shape.chained : shape.written).test(made) ? [[name, stmt]] : [];
961
982
  }));
962
983
  }
963
984
  function injectChainPrefix(generatedText, chainPrefix, app) {
@@ -1003,19 +1024,27 @@ function mergeImports(existingFile, generatedFile, dropStaleAutoNames = true) {
1003
1024
  const generatedImports = parseImportDeclarations(generatedFile);
1004
1025
  return [...mergeImportEntries([...filterExistingImports(existingImports, makeGeneratedImportIndex(generatedImports), dropStaleAutoNames), ...generatedImports]).entries()].flatMap(([spec, info]) => formatImportLine(spec, info));
1005
1026
  }
1006
- function parseImportDeclarations(file) {
1007
- return file.getImportDeclarations().map((d) => ({
1008
- moduleSpecifier: d.getModuleSpecifierValue(),
1009
- isTypeOnlyImport: d.isTypeOnly(),
1010
- defaultImport: d.getDefaultImport()?.getText(),
1011
- namespaceImport: d.getNamespaceImport()?.getText(),
1012
- namedImports: d.getNamedImports().map((n) => ({
1013
- name: n.getName(),
1014
- alias: n.getAliasNode()?.getText(),
1015
- isTypeOnly: n.isTypeOnly()
1016
- })),
1017
- isSideEffectOnly: d.getDefaultImport() === void 0 && d.getNamespaceImport() === void 0 && d.getNamedImports().length === 0
1018
- }));
1027
+ function parseImportDeclarations(source) {
1028
+ return source.program.body.filter((statement) => statement.type === "ImportDeclaration").map((d) => {
1029
+ const defaultImport = d.specifiers.find((specifier) => specifier.type === "ImportDefaultSpecifier");
1030
+ const namespaceImport = d.specifiers.find((specifier) => specifier.type === "ImportNamespaceSpecifier");
1031
+ const namedImports = d.specifiers.flatMap((specifier) => {
1032
+ if (specifier.type !== "ImportSpecifier") return [];
1033
+ return [{
1034
+ name: textOf(source.code, specifier.imported),
1035
+ alias: specifier.local.start === specifier.imported.start ? void 0 : specifier.local.name,
1036
+ isTypeOnly: specifier.importKind === "type"
1037
+ }];
1038
+ });
1039
+ return {
1040
+ moduleSpecifier: d.source.value,
1041
+ isTypeOnlyImport: d.importKind === "type",
1042
+ defaultImport: defaultImport?.local.name,
1043
+ namespaceImport: namespaceImport?.local.name,
1044
+ namedImports,
1045
+ isSideEffectOnly: d.specifiers.length === 0
1046
+ };
1047
+ });
1019
1048
  }
1020
1049
  /**
1021
1050
  * Builds canonical-path lookup tables for generated imports. Used to detect when an
@@ -1130,22 +1159,20 @@ function extractChainPrefix(apiStmtText, app) {
1130
1159
  * ordered by appearance in the source (left-to-right within the chain).
1131
1160
  */
1132
1161
  function extractOpenApiCalls(code) {
1133
- const calls = parseSnippet(code).getDescendantsOfKind(SyntaxKind.CallExpression).filter((call) => {
1134
- const expr = call.getExpression();
1135
- return Node.isPropertyAccessExpression(expr) && expr.getName() === "openapi";
1136
- }).toSorted((a, b) => {
1137
- const aExpr = a.getExpression();
1138
- const bExpr = b.getExpression();
1139
- return (Node.isPropertyAccessExpression(aExpr) ? aExpr.getNameNode().getStart() : 0) - (Node.isPropertyAccessExpression(bExpr) ? bExpr.getNameNode().getStart() : 0);
1140
- });
1162
+ const calls = descendantsWhere(parseModule(code), (node) => node.type === "CallExpression").flatMap((call) => {
1163
+ const { callee } = call;
1164
+ if (callee.type !== "MemberExpression" || callee.property.type !== "Identifier" || callee.property.name !== "openapi") return [];
1165
+ return [{
1166
+ call,
1167
+ name: callee.property
1168
+ }];
1169
+ }).toSorted((a, b) => a.name.start - b.name.start);
1141
1170
  const result = /* @__PURE__ */ new Map();
1142
- for (const call of calls) {
1143
- const expr = call.getExpression();
1144
- if (!Node.isPropertyAccessExpression(expr)) continue;
1145
- const arg = call.getArguments()[0];
1146
- if (!arg || !Node.isIdentifier(arg)) continue;
1147
- const dotPos = expr.getNameNode().getStart() - 1;
1148
- result.set(arg.getText(), code.slice(dotPos, call.getEnd()));
1171
+ for (const { call, name } of calls) {
1172
+ const [arg] = call.arguments;
1173
+ if (arg?.type !== "Identifier") continue;
1174
+ const dotPos = name.start - 1;
1175
+ result.set(arg.name, code.slice(dotPos, call.end));
1149
1176
  }
1150
1177
  return result;
1151
1178
  }
@@ -1176,6 +1203,20 @@ function mergeInlineHandler(existingText, generatedText) {
1176
1203
  * Returns a map of route identifier (e.g., "GET /users") to block info
1177
1204
  * including text and source positions for removal.
1178
1205
  */
1206
+ /** `export * from`, `export { … } from` and `export { … }`: what re-exports, not what declares. */
1207
+ function exportDeclarations(source) {
1208
+ return source.program.body.flatMap((statement) => {
1209
+ if (statement.type === "ExportAllDeclaration") return [{
1210
+ specifier: statement.source.value,
1211
+ text: textOf(source.code, statement)
1212
+ }];
1213
+ if (statement.type === "ExportNamedDeclaration" && statement.declaration === null) return [{
1214
+ specifier: statement.source?.value,
1215
+ text: textOf(source.code, statement)
1216
+ }];
1217
+ return [];
1218
+ });
1219
+ }
1179
1220
  /**
1180
1221
  * Merges the barrel file (index.ts) with the generated version.
1181
1222
  *
@@ -1185,11 +1226,12 @@ function mergeInlineHandler(existingText, generatedText) {
1185
1226
  */
1186
1227
  function mergeBarrelFile(existingCode, generatedCode) {
1187
1228
  const { existingFile, generatedFile } = makeSourcePair(existingCode, generatedCode);
1188
- const existingModules = new Set(existingFile.getExportDeclarations().map((d) => d.getModuleSpecifierValue()).filter((spec) => spec !== void 0).map((spec) => spec.replace(/\.(?:js|ts)$/u, "")));
1189
- const missingExports = generatedFile.getExportDeclarations().filter((d) => {
1190
- const spec = d.getModuleSpecifierValue();
1229
+ if (existingFile.errors.length > 0) return existingCode;
1230
+ const existingModules = new Set(exportDeclarations(existingFile).map((d) => d.specifier).filter((spec) => spec !== void 0).map((spec) => spec.replace(/\.(?:js|ts)$/u, "")));
1231
+ const missingExports = exportDeclarations(generatedFile).filter((d) => {
1232
+ const spec = d.specifier;
1191
1233
  return spec !== void 0 && !existingModules.has(spec.replace(/\.(?:js|ts)$/u, ""));
1192
- }).map((d) => d.getText());
1234
+ }).map((d) => d.text);
1193
1235
  if (missingExports.length === 0) return existingCode;
1194
1236
  const base = existingCode.trimEnd();
1195
1237
  return `${base ? `${base}\n` : ""}${missingExports.join("\n")}\n`;
@@ -10,8 +10,14 @@ const MAX_REF_HOPS = 10;
10
10
  const MAX_EXAMPLE_ITEMS = 10;
11
11
  /**
12
12
  * How many `$ref`s one table or one example may expand in total.
13
+ *
14
+ * The bound on the size of the document: every table and example of every operation
15
+ * expands what it refers to, so a document whose schemas all reach each other writes
16
+ * this many schemas into each of them. At 1000, 500 such schemas and 600 operations
17
+ * made a document too large for a string; a table or example that expands 50 schemas
18
+ * is past what anyone reads, and past that the schema is still named and linked.
13
19
  */
14
- const MAX_REF_EXPANSIONS = 1e3;
20
+ const MAX_REF_EXPANSIONS = 50;
15
21
  /**
16
22
  * How many times one table or one example expands the same recursive schema.
17
23
  * Cycle detection works per path, so schemas that reference each other would
@@ -19,6 +25,19 @@ const MAX_REF_EXPANSIONS = 1e3;
19
25
  * Past the limit the schema is still named and linked, just not expanded.
20
26
  */
21
27
  const MAX_EXPANSIONS_PER_RECURSIVE_REF = 2;
28
+ const documentCaches = /* @__PURE__ */ new WeakMap();
29
+ function cacheOf(doc) {
30
+ const found = documentCaches.get(doc);
31
+ if (found) return found;
32
+ const made = {
33
+ resolved: /* @__PURE__ */ new Map(),
34
+ outgoing: /* @__PURE__ */ new Map(),
35
+ recursive: /* @__PURE__ */ new Map(),
36
+ anchors: /* @__PURE__ */ new Map()
37
+ };
38
+ documentCaches.set(doc, made);
39
+ return made;
40
+ }
22
41
  /** A `${NAME}` placeholder a curl example leaves for the shell to expand. */
23
42
  const SHELL_VARIABLE_PATTERN = /\$\{[A-Z_]+\}/u;
24
43
  const MULTIPART_BOUNDARY = "boundary";
@@ -77,12 +96,15 @@ function pointerSegments(ref) {
77
96
  * (as a bundler emits them) resolve as well as those into `components`.
78
97
  */
79
98
  function resolveRef(ref, doc) {
99
+ const { resolved } = cacheOf(doc);
100
+ if (resolved.has(ref)) return resolved.get(ref);
80
101
  const segments = pointerSegments(ref);
81
- if (!segments) return void 0;
82
- return segments.reduce((node, segment) => {
102
+ const value = segments === void 0 ? void 0 : segments.reduce((node, segment) => {
83
103
  if (Array.isArray(node)) return node[Number(segment)];
84
104
  if (isRecord(node)) return Object.hasOwn(node, segment) ? node[segment] : void 0;
85
105
  }, doc);
106
+ resolved.set(ref, value);
107
+ return value;
86
108
  }
87
109
  /**
88
110
  * Follows a Reference Object until it reaches a value. Schemas go through
@@ -108,10 +130,15 @@ function componentSchemaName(ref) {
108
130
  * share it, so every one after the first gets a numeric suffix.
109
131
  */
110
132
  function schemaAnchor(name, doc) {
133
+ const { anchors } = cacheOf(doc);
134
+ const known = anchors.get(name);
135
+ if (known !== void 0) return known;
111
136
  const lower = name.toLowerCase();
112
137
  const schemas = doc.components?.schemas;
113
138
  const index = (isRecord(schemas) ? Object.keys(schemas).filter((key) => key.toLowerCase() === lower) : []).indexOf(name);
114
- return index > 0 ? `${lower}-${index}` : lower;
139
+ const anchor = index > 0 ? `${lower}-${index}` : lower;
140
+ anchors.set(name, anchor);
141
+ return anchor;
115
142
  }
116
143
  function makeSchemaLink(name, doc) {
117
144
  return `[${name}](#schema${schemaAnchor(name, doc)})`;
@@ -211,23 +238,41 @@ function collectRefs(node, found = /* @__PURE__ */ new Set()) {
211
238
  /**
212
239
  * Whether the schema a `$ref` names can reach itself again through `$ref`s.
213
240
  */
241
+ /** The `$ref`s held by the value a `$ref` names, walked once per document. */
242
+ function outgoingRefs(ref, doc) {
243
+ const { outgoing } = cacheOf(doc);
244
+ const known = outgoing.get(ref);
245
+ if (known !== void 0) return known;
246
+ const refs = collectRefs(resolveRef(ref, doc));
247
+ outgoing.set(ref, refs);
248
+ return refs;
249
+ }
250
+ /**
251
+ * Whether the schema a `$ref` names can reach itself again through `$ref`s.
252
+ *
253
+ * Answered once per document: the walk covers everything the schema reaches, and
254
+ * every table and example of every operation asks it of the same schemas.
255
+ */
214
256
  function isRecursiveRef(ref, doc) {
257
+ const { recursive } = cacheOf(doc);
258
+ const known = recursive.get(ref);
259
+ if (known !== void 0) return known;
215
260
  const seen = /* @__PURE__ */ new Set();
216
261
  const reaches = (current) => {
217
262
  if (seen.has(current)) return false;
218
263
  seen.add(current);
219
- return [...collectRefs(resolveRef(current, doc))].some((next) => next === ref || reaches(next));
264
+ return [...outgoingRefs(current, doc)].some((next) => next === ref || reaches(next));
220
265
  };
221
- return reaches(ref);
266
+ const result = reaches(ref);
267
+ recursive.set(ref, result);
268
+ return result;
222
269
  }
223
270
  function makeBudget(doc) {
224
271
  const counts = /* @__PURE__ */ new Map();
225
- const recursive = /* @__PURE__ */ new Map();
226
272
  const state = { left: MAX_REF_EXPANSIONS };
227
273
  return { take: (ref) => {
228
274
  const count = counts.get(ref) ?? 0;
229
- const isRecursive = recursive.get(ref) ?? isRecursiveRef(ref, doc);
230
- recursive.set(ref, isRecursive);
275
+ const isRecursive = isRecursiveRef(ref, doc);
231
276
  if (state.left <= 0) return false;
232
277
  if (isRecursive && count >= MAX_EXPANSIONS_PER_RECURSIVE_REF) return false;
233
278
  state.left -= 1;
@@ -1,2 +1,2 @@
1
- import { t as zodOpenAPIHono } from "../../../openapi-BRK0691x.js";
1
+ import { t as zodOpenAPIHono } from "../../../openapi-OxNU2RgN.js";
2
2
  export { zodOpenAPIHono };
@@ -2,8 +2,6 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { Data, Effect } from "effect";
3
3
  import path from "node:path";
4
4
  import SwaggerParser from "@apidevtools/swagger-parser";
5
- import { NodeHost, compile } from "@typespec/compiler";
6
- import { getOpenAPI3 } from "@typespec/openapi3";
7
5
  //#region src/openapi/index.ts
8
6
  /**
9
7
  * Uses `bundle()` to resolve external $refs while preserving internal ones.
@@ -18,6 +16,7 @@ function parseOpenAPI(input) {
18
16
  return Effect.tryPromise({
19
17
  try: async () => {
20
18
  if (!input.endsWith(".tsp")) return await SwaggerParser.bundle(input);
19
+ const [{ compile, NodeHost }, { getOpenAPI3 }] = await Promise.all([import("@typespec/compiler"), import("@typespec/openapi3")]);
21
20
  const program = await compile(NodeHost, path.resolve(input), { noEmit: true });
22
21
  if (program.diagnostics.length > 0) throw new Error(`TypeSpec compile failed:\n${program.diagnostics.map((d) => d.message).join("\n")}`);
23
22
  const [record] = await getOpenAPI3(program);
@@ -1,7 +1,7 @@
1
1
  import { i as FORM_MEDIA_TYPES, r as COMPONENT_REF_PREFIX, s as HTTP_METHODS, t as ARROW_FUNCTION_PATTERN } from "./constants-Bz8YiPum.js";
2
2
  import { $ as isSchemaObject, A as isHeader, B as isParameter, C as hasNotProperty, D as isCallbacks, E as hasTypelessConstraint, G as isPathItemEntry, I as isOffsetTime, J as isRefObject, K as isPathItemRef, M as isInheritedName, O as isDiscriminableBranch, P as isMedia, Q as isSchemaArray, R as isOperation, S as hasNoUserChain, U as isParameterRef, W as isPathItem, Y as isRefOnly, Z as isResponses, _ as toIdentifierPascalCase, a as error, at as isValidIdent, b as zodToOpenAPISchema, d as makeStringLiteral, f as methodPath, h as requestParamsArray, i as ensureSuffix, k as isExamplesInput, m as renderNamedImport, p as normalizeTypes, q as isRecord, r as cyclicNodes, rt as isSingleSchema, s as escapeRegexLiteral, t as baseError, u as makeSafeKey, v as uncapitalize } from "./utils-vw99OasL.js";
3
3
  import path from "node:path";
4
- import { ts } from "ts-morph";
4
+ import { parseSync, visitorKeys } from "oxc-parser";
5
5
  //#region src/helper/wire.ts
6
6
  const INTEGER_TEXT = String.raw`/^-?\d+$/`;
7
7
  const NUMBER_TEXT = String.raw`/^-?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/`;
@@ -2300,27 +2300,120 @@ function zodToOpenAPI(schema, meta, options) {
2300
2300
  return done("z.any()", schema);
2301
2301
  }
2302
2302
  //#endregion
2303
- //#region src/helper/ast.ts
2304
- function makeSourceFile(code) {
2305
- return ts.createSourceFile("temp.ts", code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
2306
- }
2307
- function getChildren(node) {
2308
- const syntaxChildren = node.getChildren();
2309
- if (syntaxChildren.length > 0) return syntaxChildren;
2310
- const semanticChildren = [];
2311
- ts.forEachChild(node, (child) => {
2312
- semanticChildren[semanticChildren.length] = child;
2303
+ //#region src/helper/syntax.ts
2304
+ /**
2305
+ * Parses a TypeScript module for reading. What a caller takes from the tree is a position,
2306
+ * a name or a kind; the text of a node is sliced from `code` by its position, so that what
2307
+ * is written back is the source as it was, comments included.
2308
+ *
2309
+ * A module that does not parse comes back with an empty tree and the errors that stopped
2310
+ * it: the parser recovers nothing past a syntax error. A caller that reads a file a hand
2311
+ * edit may have broken asks for the errors, and leaves such a file alone.
2312
+ */
2313
+ function parseSource(code) {
2314
+ const { program, errors } = parseSync("module.ts", code, {
2315
+ lang: "ts",
2316
+ sourceType: "module"
2313
2317
  });
2314
- return semanticChildren;
2315
- }
2316
- function collectIdentifiers(node) {
2317
- const identifiers = [];
2318
- const visit = (n) => {
2319
- if (ts.isIdentifier(n)) identifiers.push(n.text);
2320
- for (const child of getChildren(n)) visit(child);
2318
+ return {
2319
+ program,
2320
+ errors: errors.map((error) => error.message)
2321
2321
  };
2322
+ }
2323
+ /** The tree of a module known to parse, such as one the generator just wrote. */
2324
+ function parseModule(code) {
2325
+ return parseSource(code).program;
2326
+ }
2327
+ function textOf(code, node) {
2328
+ return code.slice(node.start, node.end);
2329
+ }
2330
+ function isNode(value) {
2331
+ return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string" && "start" in value;
2332
+ }
2333
+ /**
2334
+ * Calls `visit` on `node` and on every node under it, each child in the order the grammar
2335
+ * lists them. A node whose children the parser does not list is walked over its fields.
2336
+ */
2337
+ function walk(node, visit) {
2322
2338
  visit(node);
2323
- return identifiers;
2339
+ const keys = visitorKeys[node.type] ?? Object.keys(node).filter((key) => key !== "type" && key !== "parent");
2340
+ for (const key of keys) {
2341
+ const child = Reflect.get(node, key);
2342
+ if (Array.isArray(child)) {
2343
+ for (const item of child) if (isNode(item)) walk(item, visit);
2344
+ } else if (isNode(child)) walk(child, visit);
2345
+ }
2346
+ }
2347
+ /** The nodes under `node` that `is` picks out, in tree order, the node itself included. */
2348
+ function descendantsWhere(node, is) {
2349
+ const found = [];
2350
+ walk(node, (candidate) => {
2351
+ if (is(candidate)) found.push(candidate);
2352
+ });
2353
+ return found;
2354
+ }
2355
+ /**
2356
+ * The names of the identifiers under `node`, in source order, each occurrence counted: a
2357
+ * reference, a binding, a property name or a type name alike, as the TypeScript parser
2358
+ * counted them. Nothing inside a string, a template or a regular expression is one.
2359
+ */
2360
+ function identifierNames(node) {
2361
+ const found = [];
2362
+ walk(node, (candidate) => {
2363
+ if (candidate.type === "Identifier") found.push({
2364
+ name: candidate.name,
2365
+ start: candidate.start
2366
+ });
2367
+ });
2368
+ found.sort((a, b) => a.start - b.start);
2369
+ return found.map((entry) => entry.name);
2370
+ }
2371
+ /**
2372
+ * A top-level statement with its `export` taken off. TypeScript puts the modifier on the
2373
+ * statement, so `export const x = …` is a variable statement there and is read as the
2374
+ * variable declaration here, with `exported` telling the two apart. Default exports of a
2375
+ * function or class are declarations too; any other statement is itself.
2376
+ */
2377
+ function declarationOf(statement) {
2378
+ if (statement.type === "ExportNamedDeclaration" && statement.declaration !== null) return {
2379
+ node: statement.declaration,
2380
+ exported: true
2381
+ };
2382
+ if (statement.type === "ExportDefaultDeclaration" && (statement.declaration.type === "FunctionDeclaration" || statement.declaration.type === "ClassDeclaration")) return {
2383
+ node: statement.declaration,
2384
+ exported: true
2385
+ };
2386
+ return {
2387
+ node: statement,
2388
+ exported: false
2389
+ };
2390
+ }
2391
+ //#endregion
2392
+ //#region src/helper/ast.ts
2393
+ function declaredOf(statement) {
2394
+ const { node } = declarationOf(statement);
2395
+ if (node.type === "VariableDeclaration") {
2396
+ const [declaration] = node.declarations;
2397
+ if (declaration?.id.type !== "Identifier") return void 0;
2398
+ return {
2399
+ name: declaration.id.name,
2400
+ kind: "variable",
2401
+ statement,
2402
+ initializer: declaration.init ?? void 0
2403
+ };
2404
+ }
2405
+ if (node.type === "TSTypeAliasDeclaration") return {
2406
+ name: node.id.name,
2407
+ kind: "type",
2408
+ statement,
2409
+ initializer: void 0
2410
+ };
2411
+ if (node.type === "TSInterfaceDeclaration") return {
2412
+ name: node.id.name,
2413
+ kind: "interface",
2414
+ statement,
2415
+ initializer: void 0
2416
+ };
2324
2417
  }
2325
2418
  function findCyclicSchemas(names, deps) {
2326
2419
  const var2name = new Map(names.map((n) => [toIdentifierPascalCase(ensureSuffix(n, "Schema")), n]));
@@ -2347,12 +2440,11 @@ function analyzeCircularSchemas(schemas, schemaNames, readonly) {
2347
2440
  schemas,
2348
2441
  ...readonly === true ? { readonly: true } : {}
2349
2442
  })]));
2350
- const batchedSource = makeSourceFile(schemaNames.map((n) => `const ${toIdentifierPascalCase(ensureSuffix(n, "Schema"))} = ${zSchemaMap.get(n)}`).join("\n"));
2351
- const initializerIdentifiers = new Map(batchedSource.statements.flatMap((statement) => {
2352
- if (!ts.isVariableStatement(statement)) return [];
2353
- const declaration = statement.declarationList.declarations[0];
2354
- if (!(declaration && ts.isIdentifier(declaration.name) && declaration.initializer)) return [];
2355
- return [[declaration.name.text, collectIdentifiers(declaration.initializer)]];
2443
+ const batched = parseModule(schemaNames.map((n) => `const ${toIdentifierPascalCase(ensureSuffix(n, "Schema"))} = ${zSchemaMap.get(n)}`).join("\n"));
2444
+ const initializerIdentifiers = new Map(batched.body.flatMap((statement) => {
2445
+ const declared = declaredOf(statement);
2446
+ if (declared?.kind !== "variable" || declared.initializer === void 0) return [];
2447
+ return [[declared.name, identifierNames(declared.initializer)]];
2356
2448
  }));
2357
2449
  const depsMap = new Map(schemaNames.map((n) => {
2358
2450
  const selfVar = toIdentifierPascalCase(ensureSuffix(n, "Schema"));
@@ -2379,44 +2471,23 @@ function createDeclaration(name, fullText, refs, kind) {
2379
2471
  kind
2380
2472
  };
2381
2473
  }
2382
- function getDeclarationName(statement) {
2383
- if (ts.isVariableStatement(statement)) {
2384
- const declaration = statement.declarationList.declarations[0];
2385
- return declaration && ts.isIdentifier(declaration.name) ? declaration.name.text : void 0;
2386
- }
2387
- if (ts.isTypeAliasDeclaration(statement)) return statement.name.text;
2388
- if (ts.isInterfaceDeclaration(statement)) return statement.name.text;
2389
- }
2390
- function getDeclarationKind(statement) {
2391
- if (ts.isVariableStatement(statement)) return "variable";
2392
- if (ts.isTypeAliasDeclaration(statement)) return "type";
2393
- if (ts.isInterfaceDeclaration(statement)) return "interface";
2394
- }
2395
- function isLazySchema(statement) {
2396
- if (!ts.isVariableStatement(statement)) return false;
2397
- const declaration = statement.declarationList.declarations[0];
2398
- if (!declaration?.initializer) return false;
2399
- const initText = declaration.initializer.getText();
2400
- return /^z\.lazy\s*\(/u.test(initText);
2401
- }
2402
- function getStatementReferences(statement, declNames, selfName, selfKind) {
2403
- if (isLazySchema(statement)) return [];
2404
- const identifiers = collectIdentifiers(statement);
2474
+ function isLazySchema(code, declared) {
2475
+ if (declared.initializer === void 0) return false;
2476
+ return /^z\.lazy\s*\(/u.test(textOf(code, declared.initializer));
2477
+ }
2478
+ function getStatementReferences(code, declared, declNames, selfName, selfKind) {
2479
+ if (isLazySchema(code, declared)) return [];
2480
+ const identifiers = identifierNames(declared.statement);
2405
2481
  return [...new Set(identifiers.filter((id) => {
2406
2482
  if (!declNames.has(id)) return false;
2407
2483
  if (id === selfName && (selfKind === "type" || selfKind === "interface")) return true;
2408
2484
  return id !== selfName;
2409
2485
  }))];
2410
2486
  }
2411
- function parseStatements(sourceFile) {
2412
- const statements = sourceFile.statements.filter((s) => ts.isVariableStatement(s) || ts.isTypeAliasDeclaration(s) || ts.isInterfaceDeclaration(s));
2413
- const declNames = new Set(statements.map(getDeclarationName).filter((n) => n !== void 0));
2414
- return statements.map((statement) => {
2415
- const name = getDeclarationName(statement);
2416
- const kind = getDeclarationKind(statement);
2417
- if (!(name && kind)) return void 0;
2418
- return createDeclaration(name, statement.getText(sourceFile), getStatementReferences(statement, declNames, name, kind), kind);
2419
- }).filter((d) => d !== void 0);
2487
+ function parseStatements(code, program) {
2488
+ const declared = program.body.map(declaredOf).filter((d) => d !== void 0);
2489
+ const declNames = new Set(declared.map((d) => d.name));
2490
+ return declared.map((d) => createDeclaration(d.name, textOf(code, d.statement), getStatementReferences(code, d, declNames, d.name, d.kind), d.kind));
2420
2491
  }
2421
2492
  function makeKey(kind, name) {
2422
2493
  return `${kind}:${name}`;
@@ -2444,7 +2515,7 @@ function topoSort(decls) {
2444
2515
  return sorted;
2445
2516
  }
2446
2517
  function ast(code) {
2447
- const decls = parseStatements(makeSourceFile(code));
2518
+ const decls = parseStatements(code, parseModule(code));
2448
2519
  if (decls.length === 0) return code;
2449
2520
  return topoSort(decls).map((d) => d.fullText).join("\n\n");
2450
2521
  }
@@ -3022,4 +3093,4 @@ function zodOpenAPIHono(openapi, options = {}) {
3022
3093
  return `import{${routes.length > 0 || webhooks.length > 0 ? "createRoute,z" : "z"}}from'@hono/zod-openapi'\n\n${output}`;
3023
3094
  }
3024
3095
  //#endregion
3025
- export { resolveParameter as C, makeWebhookEntries as S, makeCallback as _, responsesCode as a, makeRouteEntries as b, headersCode as c, makeExportConst as d, makeImports as f, zodToOpenAPI as g, ast as h, schemasCode as i, makeSplitSchemaFile as l, analyzeCircularSchemas as m, routeCode as n, requestBodiesCode as o, makeModuleSpec as p, componentsCode as r, parametersCode as s, zodOpenAPIHono as t, makeConst as u, makePathItem as v, resolvePathItem as w, makeRouteProperties as x, makeRef as y };
3096
+ export { resolvePathItem as A, makeCallback as C, makeRouteProperties as D, makeRouteEntries as E, makeWebhookEntries as O, zodToOpenAPI as S, makeRef as T, descendantsWhere as _, responsesCode as a, parseSource as b, headersCode as c, makeExportConst as d, makeImports as f, declarationOf as g, ast as h, schemasCode as i, resolveParameter as k, makeSplitSchemaFile as l, analyzeCircularSchemas as m, routeCode as n, requestBodiesCode as o, makeModuleSpec as p, componentsCode as r, parametersCode as s, zodOpenAPIHono as t, makeConst as u, identifierNames as v, makePathItem as w, textOf as x, parseModule as y };
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { n as COMPONENT_NAMES, o as HOOK_LIBRARIES } from "./constants-Bz8YiPum.js";
3
3
  import { i as GenerateError } from "./format-CuHABcKC.js";
4
- import { C as isInsideDirectory, E as makeGeneratedImport, S as appEntryOutput, T as makeAppEntryImport, _ as headers, a as takibi, b as client, c as securitySchemes, d as requestBodies, f as pathItems, g as links, h as mediaTypes, i as defineTemplate, l as schemas, m as components, n as webhooks, o as route, p as parameters, r as template, s as mock, u as responses, v as examples, w as makeAppEntryFile, x as handlerGroupOf, y as callbacks } from "./core-BDhKAR3A.js";
4
+ import { C as isInsideDirectory, E as makeGeneratedImport, S as appEntryOutput, T as makeAppEntryImport, _ as headers, a as takibi, b as client, c as securitySchemes, d as requestBodies, f as pathItems, g as links, h as mediaTypes, i as defineTemplate, l as schemas, m as components, n as webhooks, o as route, p as parameters, r as template, s as mock, u as responses, v as examples, w as makeAppEntryFile, x as handlerGroupOf, y as callbacks } from "./core-DmIVe-SP.js";
5
5
  import { a as unlink, i as readdir, t as exists } from "./file-K6j5IJXi.js";
6
6
  import { t as hooks } from "./hooks-CR7angVC.js";
7
- import { t as docs } from "./docs-Im22cNpx.js";
7
+ import { t as docs } from "./docs-CtXltNLT.js";
8
8
  import { rpc } from "./core/rpc/index.js";
9
9
  import { type } from "./core/type/index.js";
10
10
  import { Effect, FileSystem, Schema } from "effect";
@@ -2,9 +2,9 @@ import { l as INPUT_EXTENSIONS } from "../constants-Bz8YiPum.js";
2
2
  import { parseConfig } from "../index.js";
3
3
  import { t as FormatOptions } from "../format-CuHABcKC.js";
4
4
  import { q as isRecord } from "../utils-vw99OasL.js";
5
- import { C as isInsideDirectory, S as appEntryOutput } from "../core-BDhKAR3A.js";
6
- import { n as parseOpenAPI } from "../openapi-DQRxq2_O.js";
7
- import { i as packageRoots, n as makeJob, r as outsideSources, t as cleanSplitOutputs } from "../shared-COpMVRhG.js";
5
+ import { C as isInsideDirectory, S as appEntryOutput } from "../core-DmIVe-SP.js";
6
+ import { n as parseOpenAPI } from "../openapi-DEZCoJlc.js";
7
+ import { i as packageRoots, n as makeJob, r as outsideSources, t as cleanSplitOutputs } from "../shared-C9-30gJ4.js";
8
8
  import { Effect, FileSystem, Option, Result } from "effect";
9
9
  import path from "node:path";
10
10
  import crypto from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",
@@ -60,8 +60,8 @@
60
60
  "@typespec/compiler": "^1.16.0",
61
61
  "@typespec/openapi3": "^1.16.0",
62
62
  "effect": "4.0.0",
63
- "oxfmt": "^0.71.0",
64
- "ts-morph": "^28.0.0"
63
+ "oxc-parser": "^0.154.0",
64
+ "oxfmt": "^0.71.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@faker-js/faker": "^10.6.0",