@orval/hono 8.0.0-rc.1 → 8.0.0-rc.3

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.
@@ -9,4 +9,4 @@ declare const generateExtraFiles: ClientExtraFilesBuilder;
9
9
  declare const builder: () => () => ClientGeneratorsBuilder;
10
10
  //#endregion
11
11
  export { builder, builder as default, generateExtraFiles, generateHono, getHonoDependencies, getHonoFooter, getHonoHeader };
12
- //# sourceMappingURL=index.d.ts.map
12
+ //# sourceMappingURL=index.d.mts.map
@@ -1,7 +1,6 @@
1
1
  import { camel, generateMutatorImports, getFileInfo, getOrvalGeneratedTypes, getParamsInPath, jsDoc, kebab, pascal, sanitize, upath } from "@orval/core";
2
2
  import { generateZod } from "@orval/zod";
3
3
  import fs from "fs-extra";
4
- import "openapi3-ts/oas30";
5
4
 
6
5
  //#region src/route.ts
7
6
  const hasParam = (path) => /[^{]*{[\w*_-]*}.*/.test(path);
@@ -16,14 +15,16 @@ const getRoutePath = (path) => {
16
15
  dot: true
17
16
  });
18
17
  const next = hasParam(matches[3]) ? getRoutePath(matches[3]) : matches[3];
19
- return hasParam(path) ? `${prev}\:${param}${next}` : `${prev}${param}${next}`;
18
+ return hasParam(path) ? `${prev}:${param}${next}` : `${prev}${param}${next}`;
20
19
  };
21
20
  const getRoute = (route) => {
22
- return route.split("/").reduce((acc, path, i) => {
23
- if (!path && !i) return acc;
24
- if (!path.includes("{")) return `${acc}/${path}`;
25
- return `${acc}/${getRoutePath(path)}`;
26
- }, "");
21
+ const splittedRoute = route.split("/");
22
+ let acc = "";
23
+ for (const [i, path] of splittedRoute.entries()) {
24
+ if (!path && i === 0) continue;
25
+ acc += path.includes("{") ? `/${getRoutePath(path)}` : `/${path}`;
26
+ }
27
+ return acc;
27
28
  };
28
29
 
29
30
  //#endregion
@@ -106,25 +107,28 @@ const generateHono = (verbOptions, options) => {
106
107
  * getHonoHandlers generates TypeScript code for the given verbs and reports
107
108
  * whether the code requires zValidator.
108
109
  */
109
- const getHonoHandlers = (...opts) => opts.reduce(([code, hasZValidator], opts$1) => {
110
- const { handlerName, contextTypeName, verbOption, validator } = opts$1;
111
- let currentValidator = "";
112
- if (validator) {
113
- if (verbOption.headers) currentValidator += `zValidator('header', ${verbOption.operationName}Header),\n`;
114
- if (verbOption.params.length > 0) currentValidator += `zValidator('param', ${verbOption.operationName}Params),\n`;
115
- if (verbOption.queryParams) currentValidator += `zValidator('query', ${verbOption.operationName}QueryParams),\n`;
116
- if (verbOption.body.definition) currentValidator += `zValidator('json', ${verbOption.operationName}Body),\n`;
117
- if (validator !== "hono" && verbOption.response.originalSchema?.["200"]?.content?.["application/json"]) currentValidator += `zValidator('response', ${verbOption.operationName}Response),\n`;
118
- }
119
- code += `
110
+ const getHonoHandlers = (...opts) => {
111
+ let code = "";
112
+ let hasZValidator = false;
113
+ for (const { handlerName, contextTypeName, verbOption, validator } of opts) {
114
+ let currentValidator = "";
115
+ if (validator) {
116
+ if (verbOption.headers) currentValidator += `zValidator('header', ${verbOption.operationName}Header),\n`;
117
+ if (verbOption.params.length > 0) currentValidator += `zValidator('param', ${verbOption.operationName}Params),\n`;
118
+ if (verbOption.queryParams) currentValidator += `zValidator('query', ${verbOption.operationName}QueryParams),\n`;
119
+ if (verbOption.body.definition) currentValidator += `zValidator('json', ${verbOption.operationName}Body),\n`;
120
+ if (validator !== "hono" && verbOption.response.originalSchema?.["200"]?.content?.["application/json"]) currentValidator += `zValidator('response', ${verbOption.operationName}Response),\n`;
121
+ }
122
+ code += `
120
123
  export const ${handlerName} = factory.createHandlers(
121
124
  ${currentValidator}async (c: ${contextTypeName}) => {
122
125
 
123
126
  },
124
127
  );`;
125
- hasZValidator ||= currentValidator !== "";
128
+ hasZValidator ||= currentValidator !== "";
129
+ }
126
130
  return [code, hasZValidator];
127
- }, ["", false]);
131
+ };
128
132
  const getZvalidatorImports = (verbOptions, importPath, isHonoValidator) => {
129
133
  const specifiers = [];
130
134
  for (const { operationName, headers, params, queryParams, body, response } of verbOptions) {
@@ -137,29 +141,29 @@ const getZvalidatorImports = (verbOptions, importPath, isHonoValidator) => {
137
141
  return specifiers.length === 0 ? "" : `import {\n${specifiers.join(",\n")}\n} from '${importPath}'`;
138
142
  };
139
143
  const getVerbOptionGroupByTag = (verbOptions) => {
140
- return Object.values(verbOptions).reduce((acc, value) => {
144
+ const grouped = {};
145
+ for (const value of Object.values(verbOptions)) {
141
146
  const tag = value.tags[0];
142
- if (!acc[tag]) acc[tag] = [];
143
- acc[tag].push(value);
144
- return acc;
145
- }, {});
147
+ if (!grouped[tag]) grouped[tag] = [];
148
+ grouped[tag].push(value);
149
+ }
150
+ return grouped;
146
151
  };
147
152
  const generateHandlerFile = async ({ verbs, path, validatorModule, zodModule, contextModule }) => {
148
153
  const validator = validatorModule === "@hono/zod-validator" ? "hono" : validatorModule != void 0;
149
154
  if (fs.existsSync(path)) {
150
155
  const rawFile = await fs.readFile(path, "utf8");
151
156
  let content = rawFile;
152
- content += Object.values(verbs).reduce((acc, verbOption) => {
157
+ for (const verbOption of Object.values(verbs)) {
153
158
  const handlerName = `${verbOption.operationName}Handlers`;
154
159
  const contextTypeName = `${pascal(verbOption.operationName)}Context`;
155
- if (!rawFile.includes(handlerName)) acc += getHonoHandlers({
160
+ if (!rawFile.includes(handlerName)) content += getHonoHandlers({
156
161
  handlerName,
157
162
  contextTypeName,
158
163
  verbOption,
159
164
  validator
160
165
  })[0];
161
- return acc;
162
- }, "");
166
+ }
163
167
  return content;
164
168
  }
165
169
  const [handlerCode, hasZValidator] = getHonoHandlers(...Object.values(verbs).map((verbOption) => ({
@@ -227,7 +231,7 @@ const getContext = (verbOption) => {
227
231
  const definition = param?.definition.split(":")[1];
228
232
  return { definition: `${name}${param?.required ?? false ? "" : "?"}:${definition}` };
229
233
  }).map((property) => property.definition).join(",\n ")},\n },`;
230
- const queryType = verbOption.queryParams ? `query: ${verbOption.queryParams?.schema.name},` : "";
234
+ const queryType = verbOption.queryParams ? `query: ${verbOption.queryParams.schema.name},` : "";
231
235
  const bodyType = verbOption.body.definition ? `json: ${verbOption.body.definition},` : "";
232
236
  const hasIn = !!paramType || !!queryType || !!bodyType;
233
237
  return `export type ${pascal(verbOption.operationName)}Context<E extends Env = any> = Context<E, '${getRoute(verbOption.pathRoute)}'${hasIn ? `, { in: { ${paramType}${queryType}${bodyType} }, out: { ${paramType}${queryType}${bodyType} } }` : ""}>`;
@@ -256,7 +260,7 @@ const generateContextFile = ({ path, verbs, schemaModule }) => {
256
260
  return content;
257
261
  };
258
262
  const generateContextFiles = (verbOptions, output, context, schemaModule) => {
259
- const header = getHeader(output.override.header, context.specs[context.specKey].info);
263
+ const header = getHeader(output.override.header, context.spec.info);
260
264
  const { extension, dirname, filename } = getFileInfo(output.target);
261
265
  if (output.mode === "tags" || output.mode === "tags-split") {
262
266
  const groupByTags = getVerbOptionGroupByTag(verbOptions);
@@ -284,11 +288,11 @@ const generateContextFiles = (verbOptions, output, context, schemaModule) => {
284
288
  };
285
289
  const generateZodFiles = async (verbOptions, output, context) => {
286
290
  const { extension, dirname, filename } = getFileInfo(output.target);
287
- const header = getHeader(output.override.header, context.specs[context.specKey].info);
291
+ const header = getHeader(output.override.header, context.spec.info);
288
292
  if (output.mode === "tags" || output.mode === "tags-split") {
289
293
  const groupByTags = getVerbOptionGroupByTag(verbOptions);
290
- const builderContexts = await Promise.all(Object.entries(groupByTags).map(async ([tag, verbs]) => {
291
- const zods$1 = await Promise.all(verbs.map((verbOption) => generateZod(verbOption, {
294
+ return (await Promise.all(Object.entries(groupByTags).map(async ([tag, verbs]) => {
295
+ const zods$1 = await Promise.all(verbs.map(async (verbOption) => generateZod(verbOption, {
292
296
  route: verbOption.route,
293
297
  pathRoute: verbOption.pathRoute,
294
298
  override: output.override,
@@ -300,21 +304,16 @@ const generateZodFiles = async (verbOptions, output, context) => {
300
304
  content: "",
301
305
  path: ""
302
306
  };
303
- const allMutators$1 = zods$1.reduce((acc, z) => {
304
- for (const mutator of z.mutators ?? []) acc[mutator.name] = mutator;
305
- return acc;
306
- }, {});
307
- let content$1 = `${header}import { z as zod } from 'zod';\n${generateMutatorImports({ mutators: Object.values(allMutators$1) })}\n`;
307
+ let content$1 = `${header}import { z as zod } from 'zod';\n${generateMutatorImports({ mutators: new Map(zods$1.flatMap((z) => z.mutators ?? []).map((m) => [m.name, m])).values().toArray() })}\n`;
308
308
  const zodPath$1 = output.mode === "tags" ? upath.join(dirname, `${kebab(tag)}.zod${extension}`) : upath.join(dirname, tag, tag + ".zod" + extension);
309
309
  content$1 += zods$1.map((zod) => zod.implementation).join("\n");
310
310
  return {
311
311
  content: content$1,
312
312
  path: zodPath$1
313
313
  };
314
- }));
315
- return Promise.all(builderContexts.filter((context$1) => context$1.content !== ""));
314
+ }))).filter((context$1) => context$1.content !== "");
316
315
  }
317
- const zods = await Promise.all(Object.values(verbOptions).map((verbOption) => generateZod(verbOption, {
316
+ const zods = await Promise.all(Object.values(verbOptions).map(async (verbOption) => generateZod(verbOption, {
318
317
  route: verbOption.route,
319
318
  pathRoute: verbOption.pathRoute,
320
319
  override: output.override,
@@ -322,11 +321,7 @@ const generateZodFiles = async (verbOptions, output, context) => {
322
321
  mock: output.mock,
323
322
  output: output.target
324
323
  }, output.client)));
325
- const allMutators = zods.reduce((acc, z) => {
326
- for (const mutator of z.mutators ?? []) acc[mutator.name] = mutator;
327
- return acc;
328
- }, {});
329
- let content = `${header}import { z as zod } from 'zod';\n${generateMutatorImports({ mutators: Object.values(allMutators) })}\n`;
324
+ let content = `${header}import { z as zod } from 'zod';\n${generateMutatorImports({ mutators: new Map(zods.flatMap((z) => z.mutators ?? []).map((m) => [m.name, m])).values().toArray() })}\n`;
330
325
  const zodPath = upath.join(dirname, `${filename}.zod${extension}`);
331
326
  content += zods.map((zod) => zod.implementation).join("\n");
332
327
  return [{
@@ -335,7 +330,7 @@ const generateZodFiles = async (verbOptions, output, context) => {
335
330
  }];
336
331
  };
337
332
  const generateZvalidator = (output, context) => {
338
- const header = getHeader(output.override.header, context.specs[context.specKey].info);
333
+ const header = getHeader(output.override.header, context.spec.info);
339
334
  let validatorPath = output.override.hono.validatorOutputPath;
340
335
  if (!output.override.hono.validatorOutputPath) {
341
336
  const { extension, dirname, filename } = getFileInfo(output.target);
@@ -346,10 +341,10 @@ const generateZvalidator = (output, context) => {
346
341
  path: validatorPath
347
342
  };
348
343
  };
349
- const generateCompositeRoutes = async (verbOptions, output, context) => {
344
+ const generateCompositeRoutes = (verbOptions, output, context) => {
350
345
  const targetInfo = getFileInfo(output.target);
351
346
  const compositeRouteInfo = getFileInfo(output.override.hono.compositeRoute);
352
- const header = getHeader(output.override.header, context.specs[context.specKey].info);
347
+ const header = getHeader(output.override.header, context.spec.info);
353
348
  const routes = Object.values(verbOptions).map((verbOption) => {
354
349
  return generateHonoRoute(verbOption, verbOption.pathRoute);
355
350
  }).join(";");
@@ -358,12 +353,12 @@ const generateCompositeRoutes = async (verbOptions, output, context) => {
358
353
  if (output.override.hono.handlers) {
359
354
  const handlerFileInfo = getFileInfo(output.override.hono.handlers);
360
355
  ImportHandlersImplementation = importHandlers.map((verbOption) => verbOption.operationName).map((operationName) => {
361
- return `import { ${`${operationName}Handlers`} } from '${generateModuleSpecifier(compositeRouteInfo.path, upath.join(handlerFileInfo.dirname ?? "", `./${operationName}`))}';`;
356
+ return `import { ${`${operationName}Handlers`} } from '${generateModuleSpecifier(compositeRouteInfo.path, upath.join(handlerFileInfo.dirname, `./${operationName}`))}';`;
362
357
  }).join("\n");
363
358
  } else {
364
359
  const tags = importHandlers.map((verbOption) => kebab(verbOption.tags[0] ?? "default"));
365
360
  ImportHandlersImplementation = tags.filter((t, i) => tags.indexOf(t) === i).map((tag) => {
366
- return `import {\n${importHandlers.filter((verbOption) => verbOption.tags[0] === tag).map((verbOption) => ` ${verbOption.operationName}Handlers`).join(`, \n`)}\n} from '${generateModuleSpecifier(compositeRouteInfo.path, upath.join(targetInfo.dirname ?? "", tag))}/${tag}.handlers';`;
361
+ return `import {\n${importHandlers.filter((verbOption) => verbOption.tags[0] === tag).map((verbOption) => ` ${verbOption.operationName}Handlers`).join(`, \n`)}\n} from '${generateModuleSpecifier(compositeRouteInfo.path, upath.join(targetInfo.dirname, tag))}/${tag}.handlers';`;
367
362
  }).join("\n");
368
363
  }
369
364
  return [{
@@ -385,12 +380,9 @@ const generateExtraFiles = async (verbOptions, output, context) => {
385
380
  if (output.schemas != void 0) schemaModule = getFileInfo(output.schemas).dirname;
386
381
  else if (output.mode === "single") schemaModule = path;
387
382
  else schemaModule = `${pathWithoutExtension}.schemas`;
388
- const [handlers, contexts, zods, compositeRoutes] = await Promise.all([
389
- generateHandlerFiles(verbOptions, output, validator.path),
390
- generateContextFiles(verbOptions, output, context, schemaModule),
391
- generateZodFiles(verbOptions, output, context),
392
- output.override.hono.compositeRoute ? generateCompositeRoutes(verbOptions, output, context) : []
393
- ]);
383
+ const contexts = generateContextFiles(verbOptions, output, context, schemaModule);
384
+ const compositeRoutes = output.override.hono.compositeRoute ? generateCompositeRoutes(verbOptions, output, context) : [];
385
+ const [handlers, zods] = await Promise.all([generateHandlerFiles(verbOptions, output, validator.path), generateZodFiles(verbOptions, output, context)]);
394
386
  return [
395
387
  ...handlers,
396
388
  ...contexts,
@@ -411,4 +403,4 @@ var src_default = builder;
411
403
 
412
404
  //#endregion
413
405
  export { builder, src_default as default, generateExtraFiles, generateHono, getHonoDependencies, getHonoFooter, getHonoHeader };
414
- //# sourceMappingURL=index.js.map
406
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["HONO_DEPENDENCIES: GeneratorDependency[]","ret: string","getHonoHeader: ClientHeaderBuilder","handlers: string","tag","getHonoFooter: ClientFooterBuilder","generateHono: ClientBuilder","grouped: Record<string, GeneratorVerbOptions[]>","handlerPath","imports: GeneratorImport[]","path","zods","content","zodPath","context","ImportHandlersImplementation: string","generateExtraFiles: ClientExtraFilesBuilder","schemaModule: string","honoClientBuilder: ClientGeneratorsBuilder"],"sources":["../src/route.ts","../src/index.ts"],"sourcesContent":["import { sanitize } from '@orval/core';\n\nconst hasParam = (path: string): boolean => /[^{]*{[\\w*_-]*}.*/.test(path);\n\nconst getRoutePath = (path: string): string => {\n const matches = /([^{]*){?([\\w*_-]*)}?(.*)/.exec(path);\n if (!matches?.length) return path; // impossible due to regexp grouping here, but for TS\n\n const prev = matches[1];\n const param = sanitize(matches[2], {\n es5keyword: true,\n underscore: true,\n dash: true,\n dot: true,\n });\n const next = hasParam(matches[3]) ? getRoutePath(matches[3]) : matches[3];\n\n return hasParam(path) ? `${prev}:${param}${next}` : `${prev}${param}${next}`;\n};\n\nexport const getRoute = (route: string) => {\n const splittedRoute = route.split('/');\n\n let acc = '';\n for (const [i, path] of splittedRoute.entries()) {\n if (!path && i === 0) continue;\n\n acc += path.includes('{') ? `/${getRoutePath(path)}` : `/${path}`;\n }\n\n return acc;\n};\n","import {\n camel,\n type ClientBuilder,\n type ClientExtraFilesBuilder,\n type ClientFooterBuilder,\n type ClientGeneratorsBuilder,\n type ClientHeaderBuilder,\n type ContextSpec,\n generateMutatorImports,\n type GeneratorDependency,\n type GeneratorImport,\n type GeneratorVerbOptions,\n getFileInfo,\n getOrvalGeneratedTypes,\n getParamsInPath,\n jsDoc,\n kebab,\n type NormalizedMutator,\n type NormalizedOutputOptions,\n type OpenApiInfoObject,\n pascal,\n sanitize,\n upath,\n} from '@orval/core';\nimport { generateZod } from '@orval/zod';\nimport fs from 'fs-extra';\n\nimport { getRoute } from './route';\n\nconst ZVALIDATOR_SOURCE = fs\n .readFileSync(upath.join(import.meta.dirname, 'zValidator.ts'))\n .toString('utf8');\n\nconst HONO_DEPENDENCIES: GeneratorDependency[] = [\n {\n exports: [\n {\n name: 'Hono',\n values: true,\n },\n {\n name: 'Context',\n },\n {\n name: 'Env',\n },\n ],\n dependency: 'hono',\n },\n];\n\n/**\n * generateModuleSpecifier generates the specifier that _from_ would use to\n * import _to_. This is syntactical and does not validate the paths.\n *\n * @param from The filesystem path to the importer.\n * @param to If a filesystem path, it and _from_ must be use the same frame of\n * reference, such as process.cwd() or both be absolute. If only one is\n * absolute, the other must be relative to process.cwd().\n *\n * Otherwise, treated as a package name and returned directly.\n *\n * @return A module specifier that can be used at _from_ to import _to_. It is\n * extensionless to conform with the rest of orval.\n */\nconst generateModuleSpecifier = (from: string, to: string) => {\n if (to.startsWith('.') || upath.isAbsolute(to)) {\n // One of \"/foo/bar\", \"./foo/bar\", \"../foo/bar\", etc.\n let ret: string;\n ret = upath.relativeSafe(upath.dirname(from), to);\n ret = ret.replace(/\\.ts$/, '');\n ret = ret.replaceAll(upath.separator, '/');\n return ret;\n }\n\n // Not a relative or absolute file path. Import as-is.\n return to;\n};\n\nexport const getHonoDependencies = () => HONO_DEPENDENCIES;\n\nexport const getHonoHeader: ClientHeaderBuilder = ({\n verbOptions,\n output,\n tag,\n clientImplementation,\n}) => {\n const targetInfo = getFileInfo(output.target);\n\n let handlers: string;\n\n const importHandlers = Object.values(verbOptions).filter((verbOption) =>\n clientImplementation.includes(`${verbOption.operationName}Handlers`),\n );\n\n if (output.override.hono.handlers) {\n const handlerFileInfo = getFileInfo(output.override.hono.handlers);\n handlers = importHandlers\n .map((verbOption) => {\n const isTagMode =\n output.mode === 'tags' || output.mode === 'tags-split';\n const tag = kebab(verbOption.tags[0] ?? 'default');\n\n const handlersPath = upath.relativeSafe(\n upath.join(targetInfo.dirname, isTagMode ? tag : ''),\n upath.join(handlerFileInfo.dirname, `./${verbOption.operationName}`),\n );\n\n return `import { ${verbOption.operationName}Handlers } from '${handlersPath}';`;\n })\n .join('\\n');\n } else {\n const importHandlerNames = importHandlers\n .map((verbOption) => ` ${verbOption.operationName}Handlers`)\n .join(`, \\n`);\n\n handlers = `import {\\n${importHandlerNames}\\n} from './${tag ?? targetInfo.filename}.handlers';`;\n }\n\n return `${handlers}\\n\\n\nconst app = new Hono()\\n\\n`;\n};\n\nexport const getHonoFooter: ClientFooterBuilder = () => 'export default app';\n\nconst generateHonoRoute = (\n { operationName, verb }: GeneratorVerbOptions,\n pathRoute: string,\n) => {\n const path = getRoute(pathRoute);\n\n return `\napp.${verb.toLowerCase()}('${path}',...${operationName}Handlers)`;\n};\n\nexport const generateHono: ClientBuilder = (verbOptions, options) => {\n if (options.override.hono.compositeRoute) {\n return {\n implementation: '',\n imports: [],\n };\n }\n\n const routeImplementation = generateHonoRoute(verbOptions, options.pathRoute);\n\n return {\n implementation: routeImplementation ? `${routeImplementation}\\n\\n` : '',\n imports: [\n ...verbOptions.params.flatMap((param) => param.imports),\n ...verbOptions.body.imports,\n ...(verbOptions.queryParams\n ? [\n {\n name: verbOptions.queryParams.schema.name,\n },\n ]\n : []),\n ],\n };\n};\n\n/**\n * getHonoHandlers generates TypeScript code for the given verbs and reports\n * whether the code requires zValidator.\n */\nconst getHonoHandlers = (\n ...opts: {\n handlerName: string;\n contextTypeName: string;\n verbOption: GeneratorVerbOptions;\n validator: boolean | 'hono' | NormalizedMutator;\n }[]\n): [\n /** The combined TypeScript handler code snippets. */\n handlerCode: string,\n /** Whether any of the handler code snippets requires importing zValidator. */\n hasZValidator: boolean,\n] => {\n let code = '';\n let hasZValidator = false;\n\n for (const { handlerName, contextTypeName, verbOption, validator } of opts) {\n let currentValidator = '';\n\n if (validator) {\n if (verbOption.headers) {\n currentValidator += `zValidator('header', ${verbOption.operationName}Header),\\n`;\n }\n if (verbOption.params.length > 0) {\n currentValidator += `zValidator('param', ${verbOption.operationName}Params),\\n`;\n }\n if (verbOption.queryParams) {\n currentValidator += `zValidator('query', ${verbOption.operationName}QueryParams),\\n`;\n }\n if (verbOption.body.definition) {\n currentValidator += `zValidator('json', ${verbOption.operationName}Body),\\n`;\n }\n if (\n validator !== 'hono' &&\n verbOption.response.originalSchema?.['200']?.content?.[\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n 'application/json'\n ]\n ) {\n currentValidator += `zValidator('response', ${verbOption.operationName}Response),\\n`;\n }\n }\n\n code += `\nexport const ${handlerName} = factory.createHandlers(\n${currentValidator}async (c: ${contextTypeName}) => {\n\n },\n);`;\n\n hasZValidator ||= currentValidator !== '';\n }\n\n return [code, hasZValidator];\n};\n\nconst getZvalidatorImports = (\n verbOptions: GeneratorVerbOptions[],\n importPath: string,\n isHonoValidator: boolean,\n) => {\n const specifiers = [];\n\n for (const {\n operationName,\n headers,\n params,\n queryParams,\n body,\n response,\n } of verbOptions) {\n if (headers) {\n specifiers.push(`${operationName}Header`);\n }\n\n if (params.length > 0) {\n specifiers.push(`${operationName}Params`);\n }\n\n if (queryParams) {\n specifiers.push(`${operationName}QueryParams`);\n }\n\n if (body.definition) {\n specifiers.push(`${operationName}Body`);\n }\n\n if (\n !isHonoValidator &&\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n response.originalSchema?.['200']?.content?.['application/json'] !=\n undefined\n ) {\n specifiers.push(`${operationName}Response`);\n }\n }\n\n return specifiers.length === 0\n ? ''\n : `import {\\n${specifiers.join(',\\n')}\\n} from '${importPath}'`;\n};\n\nconst getVerbOptionGroupByTag = (\n verbOptions: Record<string, GeneratorVerbOptions>,\n) => {\n const grouped: Record<string, GeneratorVerbOptions[]> = {};\n\n for (const value of Object.values(verbOptions)) {\n const tag = value.tags[0];\n // this is not always false\n // TODO look into types\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!grouped[tag]) {\n grouped[tag] = [];\n }\n grouped[tag].push(value);\n }\n\n return grouped;\n};\n\nconst generateHandlerFile = async ({\n verbs,\n path,\n validatorModule,\n zodModule,\n contextModule,\n}: {\n verbs: GeneratorVerbOptions[];\n path: string;\n validatorModule?: string;\n zodModule: string;\n contextModule: string;\n}) => {\n const validator =\n validatorModule === '@hono/zod-validator'\n ? ('hono' as const)\n : validatorModule != undefined;\n\n const isExist = fs.existsSync(path);\n\n if (isExist) {\n const rawFile = await fs.readFile(path, 'utf8');\n let content = rawFile;\n\n for (const verbOption of Object.values(verbs)) {\n const handlerName = `${verbOption.operationName}Handlers`;\n const contextTypeName = `${pascal(verbOption.operationName)}Context`;\n\n if (!rawFile.includes(handlerName)) {\n content += getHonoHandlers({\n handlerName,\n contextTypeName,\n verbOption,\n validator,\n })[0];\n }\n }\n\n return content;\n }\n\n const [handlerCode, hasZValidator] = getHonoHandlers(\n ...Object.values(verbs).map((verbOption) => ({\n handlerName: `${verbOption.operationName}Handlers`,\n contextTypeName: `${pascal(verbOption.operationName)}Context`,\n verbOption,\n validator,\n })),\n );\n\n const imports = [\"import { createFactory } from 'hono/factory';\"];\n\n if (hasZValidator && validatorModule != undefined) {\n imports.push(\n `import { zValidator } from '${generateModuleSpecifier(path, validatorModule)}';`,\n );\n }\n\n imports.push(\n `import { ${Object.values(verbs)\n .map((verb) => `${pascal(verb.operationName)}Context`)\n .join(',\\n')} } from '${generateModuleSpecifier(path, contextModule)}';`,\n );\n\n if (hasZValidator) {\n imports.push(\n getZvalidatorImports(\n Object.values(verbs),\n generateModuleSpecifier(path, zodModule),\n validatorModule === '@hono/zod-validator',\n ),\n );\n }\n\n return `${imports.filter((imp) => imp !== '').join('\\n')}\n\nconst factory = createFactory();${handlerCode}`;\n};\n\nconst generateHandlerFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n validatorModule: string,\n) => {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n // This function _does not control_ where the .zod and .context modules land.\n // That determination is made elsewhere and this function must implement the\n // same conventions.\n\n if (output.override.hono.handlers) {\n // One file per operation in the user-provided directory.\n return Promise.all(\n Object.values(verbOptions).map(async (verbOption) => {\n const tag = kebab(verbOption.tags[0] ?? 'default');\n\n const path = upath.join(\n output.override.hono.handlers ?? '',\n `./${verbOption.operationName}` + extension,\n );\n\n return {\n content: await generateHandlerFile({\n path,\n verbs: [verbOption],\n validatorModule,\n zodModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.zod`)\n : upath.join(dirname, tag, tag + '.zod'),\n contextModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.context`)\n : upath.join(dirname, tag, tag + '.context'),\n }),\n path,\n };\n }),\n );\n }\n\n if (output.mode === 'tags' || output.mode === 'tags-split') {\n // One file per operation _tag_ under dirname.\n const groupByTags = getVerbOptionGroupByTag(verbOptions);\n\n return Promise.all(\n Object.entries(groupByTags).map(async ([tag, verbs]) => {\n const handlerPath =\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.handlers${extension}`)\n : upath.join(dirname, tag, tag + '.handlers' + extension);\n\n return {\n content: await generateHandlerFile({\n path: handlerPath,\n verbs,\n validatorModule,\n zodModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.zod`)\n : upath.join(dirname, tag, tag + '.zod'),\n contextModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.context`)\n : upath.join(dirname, tag, tag + '.context'),\n }),\n path: handlerPath,\n };\n }),\n );\n }\n\n // One file with all operations.\n const handlerPath = upath.join(dirname, `${filename}.handlers${extension}`);\n\n return [\n {\n content: await generateHandlerFile({\n path: handlerPath,\n verbs: Object.values(verbOptions),\n validatorModule,\n zodModule: upath.join(dirname, `${filename}.zod`),\n contextModule: upath.join(dirname, `${filename}.context`),\n }),\n path: handlerPath,\n },\n ];\n};\n\nconst getContext = (verbOption: GeneratorVerbOptions) => {\n let paramType = '';\n if (verbOption.params.length > 0) {\n const params = getParamsInPath(verbOption.pathRoute).map((name) => {\n const param = verbOption.params.find(\n (p) => p.name === sanitize(camel(name), { es5keyword: true }),\n );\n const definition = param?.definition.split(':')[1];\n const required = param?.required ?? false;\n return {\n definition: `${name}${required ? '' : '?'}:${definition}`,\n };\n });\n paramType = `param: {\\n ${params\n .map((property) => property.definition)\n .join(',\\n ')},\\n },`;\n }\n\n const queryType = verbOption.queryParams\n ? `query: ${verbOption.queryParams.schema.name},`\n : '';\n const bodyType = verbOption.body.definition\n ? `json: ${verbOption.body.definition},`\n : '';\n const hasIn = !!paramType || !!queryType || !!bodyType;\n\n return `export type ${pascal(\n verbOption.operationName,\n )}Context<E extends Env = any> = Context<E, '${getRoute(\n verbOption.pathRoute,\n )}'${\n hasIn\n ? `, { in: { ${paramType}${queryType}${bodyType} }, out: { ${paramType}${queryType}${bodyType} } }`\n : ''\n }>`;\n};\n\nconst getHeader = (\n option: false | ((info: OpenApiInfoObject) => string | string[]),\n info: OpenApiInfoObject,\n): string => {\n if (!option) {\n return '';\n }\n\n const header = option(info);\n\n return Array.isArray(header) ? jsDoc({ description: header }) : header;\n};\n\nconst generateContextFile = ({\n path,\n verbs,\n schemaModule,\n}: {\n path: string;\n verbs: GeneratorVerbOptions[];\n schemaModule: string;\n}) => {\n let content = `import type { Context, Env } from 'hono';\\n\\n`;\n\n const contexts = verbs.map((verb) => getContext(verb));\n\n const imps = new Set(\n verbs\n .flatMap((verb) => {\n const imports: GeneratorImport[] = [];\n if (verb.params.length > 0) {\n imports.push(...verb.params.flatMap((param) => param.imports));\n }\n\n if (verb.queryParams) {\n imports.push({\n name: verb.queryParams.schema.name,\n });\n }\n\n if (verb.body.definition) {\n imports.push(...verb.body.imports);\n }\n\n return imports;\n })\n .map((imp) => imp.name)\n .filter((imp) => contexts.some((context) => context.includes(imp))),\n );\n\n if (contexts.some((context) => context.includes('NonReadonly<'))) {\n content += getOrvalGeneratedTypes();\n content += '\\n';\n }\n\n if (imps.size > 0) {\n content += `import type {\\n${[...imps]\n .toSorted()\n .join(\n ',\\n ',\n )}\\n} from '${generateModuleSpecifier(path, schemaModule)}';\\n\\n`;\n }\n\n content += contexts.join('\\n');\n\n return content;\n};\n\nconst generateContextFiles = (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpec,\n schemaModule: string,\n) => {\n const header = getHeader(output.override.header, context.spec.info);\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n if (output.mode === 'tags' || output.mode === 'tags-split') {\n const groupByTags = getVerbOptionGroupByTag(verbOptions);\n\n return Object.entries(groupByTags).map(([tag, verbs]) => {\n const path =\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.context${extension}`)\n : upath.join(dirname, tag, tag + '.context' + extension);\n const code = generateContextFile({\n verbs,\n path,\n schemaModule: schemaModule,\n });\n return { content: `${header}${code}`, path };\n });\n }\n\n const path = upath.join(dirname, `${filename}.context${extension}`);\n const code = generateContextFile({\n verbs: Object.values(verbOptions),\n path,\n schemaModule: schemaModule,\n });\n\n return [\n {\n content: `${header}${code}`,\n path,\n },\n ];\n};\n\nconst generateZodFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpec,\n) => {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n const header = getHeader(output.override.header, context.spec.info);\n\n if (output.mode === 'tags' || output.mode === 'tags-split') {\n const groupByTags = getVerbOptionGroupByTag(verbOptions);\n\n const builderContexts = await Promise.all(\n Object.entries(groupByTags).map(async ([tag, verbs]) => {\n const zods = await Promise.all(\n verbs.map(async (verbOption) =>\n generateZod(\n verbOption,\n {\n route: verbOption.route,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target,\n },\n output.client,\n ),\n ),\n );\n\n if (zods.every((z) => z.implementation === '')) {\n return {\n content: '',\n path: '',\n };\n }\n\n const allMutators = new Map(\n zods.flatMap((z) => z.mutators ?? []).map((m) => [m.name, m]),\n )\n .values()\n .toArray();\n\n const mutatorsImports = generateMutatorImports({\n mutators: allMutators,\n });\n\n let content = `${header}import { z as zod } from 'zod';\\n${mutatorsImports}\\n`;\n\n const zodPath =\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.zod${extension}`)\n : upath.join(dirname, tag, tag + '.zod' + extension);\n\n content += zods.map((zod) => zod.implementation).join('\\n');\n\n return {\n content,\n path: zodPath,\n };\n }),\n );\n\n return builderContexts.filter((context) => context.content !== '');\n }\n\n const zods = await Promise.all(\n Object.values(verbOptions).map(async (verbOption) =>\n generateZod(\n verbOption,\n {\n route: verbOption.route,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target,\n },\n output.client,\n ),\n ),\n );\n\n const allMutators = new Map(\n zods.flatMap((z) => z.mutators ?? []).map((m) => [m.name, m]),\n )\n .values()\n .toArray();\n\n const mutatorsImports = generateMutatorImports({\n mutators: allMutators,\n });\n\n let content = `${header}import { z as zod } from 'zod';\\n${mutatorsImports}\\n`;\n\n const zodPath = upath.join(dirname, `${filename}.zod${extension}`);\n\n content += zods.map((zod) => zod.implementation).join('\\n');\n\n return [\n {\n content,\n path: zodPath,\n },\n ];\n};\n\nconst generateZvalidator = (\n output: NormalizedOutputOptions,\n context: ContextSpec,\n) => {\n const header = getHeader(output.override.header, context.spec.info);\n\n let validatorPath = output.override.hono.validatorOutputPath;\n if (!output.override.hono.validatorOutputPath) {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n validatorPath = upath.join(dirname, `${filename}.validator${extension}`);\n }\n\n return {\n content: `${header}${ZVALIDATOR_SOURCE}`,\n path: validatorPath,\n };\n};\n\nconst generateCompositeRoutes = (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpec,\n) => {\n const targetInfo = getFileInfo(output.target);\n const compositeRouteInfo = getFileInfo(output.override.hono.compositeRoute);\n\n const header = getHeader(output.override.header, context.spec.info);\n\n const routes = Object.values(verbOptions)\n .map((verbOption) => {\n return generateHonoRoute(verbOption, verbOption.pathRoute);\n })\n .join(';');\n\n const importHandlers = Object.values(verbOptions);\n\n let ImportHandlersImplementation: string;\n if (output.override.hono.handlers) {\n const handlerFileInfo = getFileInfo(output.override.hono.handlers);\n const operationNames = importHandlers.map(\n (verbOption) => verbOption.operationName,\n );\n\n ImportHandlersImplementation = operationNames\n .map((operationName) => {\n const importHandlerName = `${operationName}Handlers`;\n\n const handlersPath = generateModuleSpecifier(\n compositeRouteInfo.path,\n upath.join(handlerFileInfo.dirname, `./${operationName}`),\n );\n\n return `import { ${importHandlerName} } from '${handlersPath}';`;\n })\n .join('\\n');\n } else {\n const tags = importHandlers.map((verbOption) =>\n kebab(verbOption.tags[0] ?? 'default'),\n );\n const uniqueTags = tags.filter((t, i) => tags.indexOf(t) === i);\n\n ImportHandlersImplementation = uniqueTags\n .map((tag) => {\n const importHandlerNames = importHandlers\n .filter((verbOption) => verbOption.tags[0] === tag)\n .map((verbOption) => ` ${verbOption.operationName}Handlers`)\n .join(`, \\n`);\n\n const handlersPath = generateModuleSpecifier(\n compositeRouteInfo.path,\n upath.join(targetInfo.dirname, tag),\n );\n\n return `import {\\n${importHandlerNames}\\n} from '${handlersPath}/${tag}.handlers';`;\n })\n .join('\\n');\n }\n\n const honoImport = `import { Hono } from 'hono';`;\n const honoInitialization = `\\nconst app = new Hono()`;\n const honoAppExport = `\\nexport default app`;\n\n const content = `${header}${honoImport}\n${ImportHandlersImplementation}\n${honoInitialization}\n${routes}\n${honoAppExport}\n`;\n\n return [\n {\n content,\n path: output.override.hono.compositeRoute || '',\n },\n ];\n};\n\nexport const generateExtraFiles: ClientExtraFilesBuilder = async (\n verbOptions,\n output,\n context,\n) => {\n const { path, pathWithoutExtension } = getFileInfo(output.target);\n const validator = generateZvalidator(output, context);\n let schemaModule: string;\n\n if (output.schemas != undefined) {\n schemaModule = getFileInfo(output.schemas).dirname;\n } else if (output.mode === 'single') {\n schemaModule = path;\n } else {\n schemaModule = `${pathWithoutExtension}.schemas`;\n }\n\n const contexts = generateContextFiles(\n verbOptions,\n output,\n context,\n schemaModule,\n );\n const compositeRoutes = output.override.hono.compositeRoute\n ? generateCompositeRoutes(verbOptions, output, context)\n : [];\n const [handlers, zods] = await Promise.all([\n generateHandlerFiles(verbOptions, output, validator.path),\n generateZodFiles(verbOptions, output, context),\n ]);\n\n return [\n ...handlers,\n ...contexts,\n ...zods,\n ...(output.override.hono.validator &&\n output.override.hono.validator !== 'hono'\n ? [validator]\n : []),\n ...compositeRoutes,\n ];\n};\n\nconst honoClientBuilder: ClientGeneratorsBuilder = {\n client: generateHono,\n dependencies: getHonoDependencies,\n header: getHonoHeader,\n footer: getHonoFooter,\n extraFiles: generateExtraFiles,\n};\n\nexport const builder = () => () => honoClientBuilder;\n\nexport default builder;\n"],"mappings":";;;;;AAEA,MAAM,YAAY,SAA0B,oBAAoB,KAAK,KAAK;AAE1E,MAAM,gBAAgB,SAAyB;CAC7C,MAAM,UAAU,4BAA4B,KAAK,KAAK;AACtD,KAAI,CAAC,SAAS,OAAQ,QAAO;CAE7B,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ,SAAS,QAAQ,IAAI;EACjC,YAAY;EACZ,YAAY;EACZ,MAAM;EACN,KAAK;EACN,CAAC;CACF,MAAM,OAAO,SAAS,QAAQ,GAAG,GAAG,aAAa,QAAQ,GAAG,GAAG,QAAQ;AAEvE,QAAO,SAAS,KAAK,GAAG,GAAG,KAAK,GAAG,QAAQ,SAAS,GAAG,OAAO,QAAQ;;AAGxE,MAAa,YAAY,UAAkB;CACzC,MAAM,gBAAgB,MAAM,MAAM,IAAI;CAEtC,IAAI,MAAM;AACV,MAAK,MAAM,CAAC,GAAG,SAAS,cAAc,SAAS,EAAE;AAC/C,MAAI,CAAC,QAAQ,MAAM,EAAG;AAEtB,SAAO,KAAK,SAAS,IAAI,GAAG,IAAI,aAAa,KAAK,KAAK,IAAI;;AAG7D,QAAO;;;;;ACDT,MAAM,oBAAoB,GACvB,aAAa,MAAM,KAAK,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAC9D,SAAS,OAAO;AAEnB,MAAMA,oBAA2C,CAC/C;CACE,SAAS;EACP;GACE,MAAM;GACN,QAAQ;GACT;EACD,EACE,MAAM,WACP;EACD,EACE,MAAM,OACP;EACF;CACD,YAAY;CACb,CACF;;;;;;;;;;;;;;;AAgBD,MAAM,2BAA2B,MAAc,OAAe;AAC5D,KAAI,GAAG,WAAW,IAAI,IAAI,MAAM,WAAW,GAAG,EAAE;EAE9C,IAAIC;AACJ,QAAM,MAAM,aAAa,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,CAE+D,GAAG,IAAI;IACvE,CACD,KAAK,KAAK;;AAcf,QAAO,CACL;EACE,SATY,GAAG;EACnB,6BAA6B;;;EAE7B,OAAO;;;;EAOH,MAAM,OAAO,SAAS,KAAK,kBAAkB;EAC9C,CACF;;AAGH,MAAaC,qBAA8C,OACzD,aACA,QACA,YACG;CACH,MAAM,EAAE,MAAM,yBAAyB,YAAY,OAAO,OAAO;CACjE,MAAM,YAAY,mBAAmB,QAAQ,QAAQ;CACrD,IAAIC;AAEJ,KAAI,OAAO,WAAW,OACpB,gBAAe,YAAY,OAAO,QAAQ,CAAC;UAClC,OAAO,SAAS,SACzB,gBAAe;KAEf,gBAAe,GAAG,qBAAqB;CAGzC,MAAM,WAAW,qBACf,aACA,QACA,SACA,aACD;CACD,MAAM,kBAAkB,OAAO,SAAS,KAAK,iBACzC,wBAAwB,aAAa,QAAQ,QAAQ,GACrD,EAAE;CACN,MAAM,CAAC,UAAU,QAAQ,MAAM,QAAQ,IAAI,CACzC,qBAAqB,aAAa,QAAQ,UAAU,KAAK,EACzD,iBAAiB,aAAa,QAAQ,QAAQ,CAC/C,CAAC;AAEF,QAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;EACH,GAAI,OAAO,SAAS,KAAK,aACzB,OAAO,SAAS,KAAK,cAAc,SAC/B,CAAC,UAAU,GACX,EAAE;EACN,GAAG;EACJ;;AAGH,MAAMC,oBAA6C;CACjD,QAAQ;CACR,cAAc;CACd,QAAQ;CACR,QAAQ;CACR,YAAY;CACb;AAED,MAAa,sBAAsB;AAEnC,kBAAe"}
package/package.json CHANGED
@@ -1,39 +1,39 @@
1
1
  {
2
2
  "name": "@orval/hono",
3
- "version": "8.0.0-rc.1",
3
+ "version": "8.0.0-rc.3",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "import": {
8
- "types": "./dist/index.d.ts",
9
- "import": "./dist/index.js"
8
+ "types": "./dist/index.d.mts",
9
+ "import": "./dist/index.mjs"
10
10
  }
11
11
  },
12
12
  "files": [
13
13
  "dist",
14
- "!dist/**/*.d.ts.map"
14
+ "!dist/**/*.d.ts.map",
15
+ "!dist/**/*.d.mts.map"
15
16
  ],
16
17
  "scripts": {
17
- "build": "tsdown --config-loader unconfig",
18
- "dev": "tsdown --config-loader unconfig --watch src",
18
+ "build": "tsdown --config-loader unrun",
19
+ "dev": "tsdown --config-loader unrun --watch src",
19
20
  "lint": "tsc --noEmit src/zValidator.ts && eslint .",
20
21
  "clean": "rimraf .turbo dist",
21
22
  "nuke": "rimraf .turbo dist node_modules"
22
23
  },
23
24
  "dependencies": {
24
- "@orval/core": "8.0.0-rc.1",
25
- "@orval/zod": "8.0.0-rc.1",
25
+ "@orval/core": "8.0.0-rc.3",
26
+ "@orval/zod": "8.0.0-rc.3",
26
27
  "fs-extra": "^11.3.2",
27
- "openapi3-ts": "4.5.0",
28
28
  "remeda": "^2.32.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@hono/zod-validator": "^0.7.4",
32
32
  "@types/fs-extra": "^11.0.4",
33
- "eslint": "^9.38.0",
34
- "rimraf": "^6.0.1",
35
- "tsdown": "^0.15.9",
36
- "typescript": "^5.9.3"
33
+ "eslint": "9.39.1",
34
+ "rimraf": "6.1.0",
35
+ "tsdown": "0.16.4",
36
+ "typescript": "5.9.3"
37
37
  },
38
- "stableVersion": "8.0.0-rc.0"
38
+ "stableVersion": "8.0.0-rc.2"
39
39
  }
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["HONO_DEPENDENCIES: GeneratorDependency[]","ret: string","getHonoHeader: ClientHeaderBuilder","handlers: string","tag","getHonoFooter: ClientFooterBuilder","generateHono: ClientBuilder","opts","handlerPath","imports: GeneratorImport[]","path","zods","allMutators","content","zodPath","context","ImportHandlersImplementation: string","generateExtraFiles: ClientExtraFilesBuilder","schemaModule: string","honoClientBuilder: ClientGeneratorsBuilder"],"sources":["../src/route.ts","../src/index.ts"],"sourcesContent":["import { sanitize } from '@orval/core';\n\nconst hasParam = (path: string): boolean => /[^{]*{[\\w*_-]*}.*/.test(path);\n\nconst getRoutePath = (path: string): string => {\n const matches = /([^{]*){?([\\w*_-]*)}?(.*)/.exec(path);\n if (!matches?.length) return path; // impossible due to regexp grouping here, but for TS\n\n const prev = matches[1];\n const param = sanitize(matches[2], {\n es5keyword: true,\n underscore: true,\n dash: true,\n dot: true,\n });\n const next = hasParam(matches[3]) ? getRoutePath(matches[3]) : matches[3];\n\n return hasParam(path) ? `${prev}\\:${param}${next}` : `${prev}${param}${next}`;\n};\n\nexport const getRoute = (route: string) => {\n const splittedRoute = route.split('/');\n\n return splittedRoute.reduce((acc, path, i) => {\n if (!path && !i) {\n return acc;\n }\n\n if (!path.includes('{')) {\n return `${acc}/${path}`;\n }\n\n return `${acc}/${getRoutePath(path)}`;\n }, '');\n};\n","import {\n camel,\n type ClientBuilder,\n type ClientExtraFilesBuilder,\n type ClientFooterBuilder,\n type ClientGeneratorsBuilder,\n type ClientHeaderBuilder,\n type ContextSpecs,\n generateMutatorImports,\n type GeneratorDependency,\n type GeneratorImport,\n type GeneratorMutator,\n type GeneratorVerbOptions,\n getFileInfo,\n getOrvalGeneratedTypes,\n getParamsInPath,\n jsDoc,\n kebab,\n type NormalizedMutator,\n type NormalizedOutputOptions,\n pascal,\n sanitize,\n upath,\n} from '@orval/core';\nimport { generateZod } from '@orval/zod';\nimport fs from 'fs-extra';\nimport { type InfoObject } from 'openapi3-ts/oas30';\n\nimport { getRoute } from './route';\n\nconst ZVALIDATOR_SOURCE = fs\n .readFileSync(upath.join(import.meta.dirname, 'zValidator.ts'))\n .toString('utf8');\n\nconst HONO_DEPENDENCIES: GeneratorDependency[] = [\n {\n exports: [\n {\n name: 'Hono',\n values: true,\n },\n {\n name: 'Context',\n },\n {\n name: 'Env',\n },\n ],\n dependency: 'hono',\n },\n];\n\n/**\n * generateModuleSpecifier generates the specifier that _from_ would use to\n * import _to_. This is syntactical and does not validate the paths.\n *\n * @param from The filesystem path to the importer.\n * @param to If a filesystem path, it and _from_ must be use the same frame of\n * reference, such as process.cwd() or both be absolute. If only one is\n * absolute, the other must be relative to process.cwd().\n *\n * Otherwise, treated as a package name and returned directly.\n *\n * @return A module specifier that can be used at _from_ to import _to_. It is\n * extensionless to conform with the rest of orval.\n */\nconst generateModuleSpecifier = (from: string, to: string) => {\n if (to.startsWith('.') || upath.isAbsolute(to)) {\n // One of \"/foo/bar\", \"./foo/bar\", \"../foo/bar\", etc.\n let ret: string;\n ret = upath.relativeSafe(upath.dirname(from), to);\n ret = ret.replace(/\\.ts$/, '');\n ret = ret.replaceAll(upath.separator, '/');\n return ret;\n }\n\n // Not a relative or absolute file path. Import as-is.\n return to;\n};\n\nexport const getHonoDependencies = () => HONO_DEPENDENCIES;\n\nexport const getHonoHeader: ClientHeaderBuilder = ({\n verbOptions,\n output,\n tag,\n clientImplementation,\n}) => {\n const targetInfo = getFileInfo(output.target);\n\n let handlers: string;\n\n const importHandlers = Object.values(verbOptions).filter((verbOption) =>\n clientImplementation.includes(`${verbOption.operationName}Handlers`),\n );\n\n if (output.override.hono.handlers) {\n const handlerFileInfo = getFileInfo(output.override.hono.handlers);\n handlers = importHandlers\n .map((verbOption) => {\n const isTagMode =\n output.mode === 'tags' || output.mode === 'tags-split';\n const tag = kebab(verbOption.tags[0] ?? 'default');\n\n const handlersPath = upath.relativeSafe(\n upath.join(targetInfo.dirname, isTagMode ? tag : ''),\n upath.join(handlerFileInfo.dirname, `./${verbOption.operationName}`),\n );\n\n return `import { ${verbOption.operationName}Handlers } from '${handlersPath}';`;\n })\n .join('\\n');\n } else {\n const importHandlerNames = importHandlers\n .map((verbOption) => ` ${verbOption.operationName}Handlers`)\n .join(`, \\n`);\n\n handlers = `import {\\n${importHandlerNames}\\n} from './${tag ?? targetInfo.filename}.handlers';`;\n }\n\n return `${handlers}\\n\\n\nconst app = new Hono()\\n\\n`;\n};\n\nexport const getHonoFooter: ClientFooterBuilder = () => 'export default app';\n\nconst generateHonoRoute = (\n { operationName, verb }: GeneratorVerbOptions,\n pathRoute: string,\n) => {\n const path = getRoute(pathRoute);\n\n return `\napp.${verb.toLowerCase()}('${path}',...${operationName}Handlers)`;\n};\n\nexport const generateHono: ClientBuilder = (verbOptions, options) => {\n if (options.override.hono.compositeRoute) {\n return {\n implementation: '',\n imports: [],\n };\n }\n\n const routeImplementation = generateHonoRoute(verbOptions, options.pathRoute);\n\n return {\n implementation: routeImplementation ? `${routeImplementation}\\n\\n` : '',\n imports: [\n ...verbOptions.params.flatMap((param) => param.imports),\n ...verbOptions.body.imports,\n ...(verbOptions.queryParams\n ? [\n {\n name: verbOptions.queryParams.schema.name,\n },\n ]\n : []),\n ],\n };\n};\n\n/**\n * getHonoHandlers generates TypeScript code for the given verbs and reports\n * whether the code requires zValidator.\n */\nconst getHonoHandlers = (\n ...opts: {\n handlerName: string;\n contextTypeName: string;\n verbOption: GeneratorVerbOptions;\n validator: boolean | 'hono' | NormalizedMutator;\n }[]\n): [\n /** The combined TypeScript handler code snippets. */\n handlerCode: string,\n /** Whether any of the handler code snippets requires importing zValidator. */\n hasZValidator: boolean,\n] =>\n opts.reduce<[string, boolean]>(\n ([code, hasZValidator], opts) => {\n const { handlerName, contextTypeName, verbOption, validator } = opts;\n\n let currentValidator = '';\n\n if (validator) {\n if (verbOption.headers) {\n currentValidator += `zValidator('header', ${verbOption.operationName}Header),\\n`;\n }\n if (verbOption.params.length > 0) {\n currentValidator += `zValidator('param', ${verbOption.operationName}Params),\\n`;\n }\n if (verbOption.queryParams) {\n currentValidator += `zValidator('query', ${verbOption.operationName}QueryParams),\\n`;\n }\n if (verbOption.body.definition) {\n currentValidator += `zValidator('json', ${verbOption.operationName}Body),\\n`;\n }\n if (\n validator !== 'hono' &&\n verbOption.response.originalSchema?.['200']?.content?.[\n 'application/json'\n ]\n ) {\n currentValidator += `zValidator('response', ${verbOption.operationName}Response),\\n`;\n }\n }\n\n code += `\nexport const ${handlerName} = factory.createHandlers(\n${currentValidator}async (c: ${contextTypeName}) => {\n\n },\n);`;\n hasZValidator ||= currentValidator !== '';\n\n return [code, hasZValidator];\n },\n ['', false],\n );\n\nconst getZvalidatorImports = (\n verbOptions: GeneratorVerbOptions[],\n importPath: string,\n isHonoValidator: boolean,\n) => {\n const specifiers = [];\n\n for (const {\n operationName,\n headers,\n params,\n queryParams,\n body,\n response,\n } of verbOptions) {\n if (headers) {\n specifiers.push(`${operationName}Header`);\n }\n\n if (params.length > 0) {\n specifiers.push(`${operationName}Params`);\n }\n\n if (queryParams) {\n specifiers.push(`${operationName}QueryParams`);\n }\n\n if (body.definition) {\n specifiers.push(`${operationName}Body`);\n }\n\n if (\n !isHonoValidator &&\n response.originalSchema?.['200']?.content?.['application/json'] !=\n undefined\n ) {\n specifiers.push(`${operationName}Response`);\n }\n }\n\n return specifiers.length === 0\n ? ''\n : `import {\\n${specifiers.join(',\\n')}\\n} from '${importPath}'`;\n};\n\nconst getVerbOptionGroupByTag = (\n verbOptions: Record<string, GeneratorVerbOptions>,\n) => {\n return Object.values(verbOptions).reduce<\n Record<string, GeneratorVerbOptions[]>\n >((acc, value) => {\n const tag = value.tags[0];\n if (!acc[tag]) {\n acc[tag] = [];\n }\n acc[tag].push(value);\n return acc;\n }, {});\n};\n\nconst generateHandlerFile = async ({\n verbs,\n path,\n validatorModule,\n zodModule,\n contextModule,\n}: {\n verbs: GeneratorVerbOptions[];\n path: string;\n validatorModule?: string;\n zodModule: string;\n contextModule: string;\n}) => {\n const validator =\n validatorModule === '@hono/zod-validator'\n ? ('hono' as const)\n : validatorModule != undefined;\n\n const isExist = fs.existsSync(path);\n\n if (isExist) {\n const rawFile = await fs.readFile(path, 'utf8');\n let content = rawFile;\n\n content += Object.values(verbs).reduce((acc, verbOption) => {\n const handlerName = `${verbOption.operationName}Handlers`;\n const contextTypeName = `${pascal(verbOption.operationName)}Context`;\n\n if (!rawFile.includes(handlerName)) {\n acc += getHonoHandlers({\n handlerName,\n contextTypeName,\n verbOption,\n validator,\n })[0];\n }\n\n return acc;\n }, '');\n\n return content;\n }\n\n const [handlerCode, hasZValidator] = getHonoHandlers(\n ...Object.values(verbs).map((verbOption) => ({\n handlerName: `${verbOption.operationName}Handlers`,\n contextTypeName: `${pascal(verbOption.operationName)}Context`,\n verbOption,\n validator,\n })),\n );\n\n const imports = [\"import { createFactory } from 'hono/factory';\"];\n\n if (hasZValidator && validatorModule != undefined) {\n imports.push(\n `import { zValidator } from '${generateModuleSpecifier(path, validatorModule)}';`,\n );\n }\n\n imports.push(\n `import { ${Object.values(verbs)\n .map((verb) => `${pascal(verb.operationName)}Context`)\n .join(',\\n')} } from '${generateModuleSpecifier(path, contextModule)}';`,\n );\n\n if (hasZValidator) {\n imports.push(\n getZvalidatorImports(\n Object.values(verbs),\n generateModuleSpecifier(path, zodModule),\n validatorModule === '@hono/zod-validator',\n ),\n );\n }\n\n return `${imports.filter((imp) => imp !== '').join('\\n')}\n\nconst factory = createFactory();${handlerCode}`;\n};\n\nconst generateHandlerFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n validatorModule: string,\n) => {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n // This function _does not control_ where the .zod and .context modules land.\n // That determination is made elsewhere and this function must implement the\n // same conventions.\n\n if (output.override.hono.handlers) {\n // One file per operation in the user-provided directory.\n return Promise.all(\n Object.values(verbOptions).map(async (verbOption) => {\n const tag = kebab(verbOption.tags[0] ?? 'default');\n\n const path = upath.join(\n output.override.hono.handlers ?? '',\n `./${verbOption.operationName}` + extension,\n );\n\n return {\n content: await generateHandlerFile({\n path,\n verbs: [verbOption],\n validatorModule,\n zodModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.zod`)\n : upath.join(dirname, tag, tag + '.zod'),\n contextModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.context`)\n : upath.join(dirname, tag, tag + '.context'),\n }),\n path,\n };\n }),\n );\n }\n\n if (output.mode === 'tags' || output.mode === 'tags-split') {\n // One file per operation _tag_ under dirname.\n const groupByTags = getVerbOptionGroupByTag(verbOptions);\n\n return Promise.all(\n Object.entries(groupByTags).map(async ([tag, verbs]) => {\n const handlerPath =\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.handlers${extension}`)\n : upath.join(dirname, tag, tag + '.handlers' + extension);\n\n return {\n content: await generateHandlerFile({\n path: handlerPath,\n verbs,\n validatorModule,\n zodModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.zod`)\n : upath.join(dirname, tag, tag + '.zod'),\n contextModule:\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.context`)\n : upath.join(dirname, tag, tag + '.context'),\n }),\n path: handlerPath,\n };\n }),\n );\n }\n\n // One file with all operations.\n const handlerPath = upath.join(dirname, `${filename}.handlers${extension}`);\n\n return [\n {\n content: await generateHandlerFile({\n path: handlerPath,\n verbs: Object.values(verbOptions),\n validatorModule,\n zodModule: upath.join(dirname, `${filename}.zod`),\n contextModule: upath.join(dirname, `${filename}.context`),\n }),\n path: handlerPath,\n },\n ];\n};\n\nconst getContext = (verbOption: GeneratorVerbOptions) => {\n let paramType = '';\n if (verbOption.params.length > 0) {\n const params = getParamsInPath(verbOption.pathRoute).map((name) => {\n const param = verbOption.params.find(\n (p) => p.name === sanitize(camel(name), { es5keyword: true }),\n );\n const definition = param?.definition.split(':')[1];\n const required = param?.required ?? false;\n return {\n definition: `${name}${required ? '' : '?'}:${definition}`,\n };\n });\n paramType = `param: {\\n ${params\n .map((property) => property.definition)\n .join(',\\n ')},\\n },`;\n }\n\n const queryType = verbOption.queryParams\n ? `query: ${verbOption.queryParams?.schema.name},`\n : '';\n const bodyType = verbOption.body.definition\n ? `json: ${verbOption.body.definition},`\n : '';\n const hasIn = !!paramType || !!queryType || !!bodyType;\n\n return `export type ${pascal(\n verbOption.operationName,\n )}Context<E extends Env = any> = Context<E, '${getRoute(\n verbOption.pathRoute,\n )}'${\n hasIn\n ? `, { in: { ${paramType}${queryType}${bodyType} }, out: { ${paramType}${queryType}${bodyType} } }`\n : ''\n }>`;\n};\n\nconst getHeader = (\n option: false | ((info: InfoObject) => string | string[]),\n info: InfoObject,\n): string => {\n if (!option) {\n return '';\n }\n\n const header = option(info);\n\n return Array.isArray(header) ? jsDoc({ description: header }) : header;\n};\n\nconst generateContextFile = ({\n path,\n verbs,\n schemaModule,\n}: {\n path: string;\n verbs: GeneratorVerbOptions[];\n schemaModule: string;\n}) => {\n let content = `import type { Context, Env } from 'hono';\\n\\n`;\n\n const contexts = verbs.map((verb) => getContext(verb));\n\n const imps = new Set(\n verbs\n .flatMap((verb) => {\n const imports: GeneratorImport[] = [];\n if (verb.params.length > 0) {\n imports.push(...verb.params.flatMap((param) => param.imports));\n }\n\n if (verb.queryParams) {\n imports.push({\n name: verb.queryParams.schema.name,\n });\n }\n\n if (verb.body.definition) {\n imports.push(...verb.body.imports);\n }\n\n return imports;\n })\n .map((imp) => imp.name)\n .filter((imp) => contexts.some((context) => context.includes(imp))),\n );\n\n if (contexts.some((context) => context.includes('NonReadonly<'))) {\n content += getOrvalGeneratedTypes();\n content += '\\n';\n }\n\n if (imps.size > 0) {\n content += `import type {\\n${[...imps]\n .toSorted()\n .join(\n ',\\n ',\n )}\\n} from '${generateModuleSpecifier(path, schemaModule)}';\\n\\n`;\n }\n\n content += contexts.join('\\n');\n\n return content;\n};\n\nconst generateContextFiles = (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n schemaModule: string,\n) => {\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n if (output.mode === 'tags' || output.mode === 'tags-split') {\n const groupByTags = getVerbOptionGroupByTag(verbOptions);\n\n return Object.entries(groupByTags).map(([tag, verbs]) => {\n const path =\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.context${extension}`)\n : upath.join(dirname, tag, tag + '.context' + extension);\n const code = generateContextFile({\n verbs,\n path,\n schemaModule: schemaModule,\n });\n return { content: `${header}${code}`, path };\n });\n }\n\n const path = upath.join(dirname, `${filename}.context${extension}`);\n const code = generateContextFile({\n verbs: Object.values(verbOptions),\n path,\n schemaModule: schemaModule,\n });\n\n return [\n {\n content: `${header}${code}`,\n path,\n },\n ];\n};\n\nconst generateZodFiles = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n\n if (output.mode === 'tags' || output.mode === 'tags-split') {\n const groupByTags = getVerbOptionGroupByTag(verbOptions);\n\n const builderContexts = await Promise.all(\n Object.entries(groupByTags).map(async ([tag, verbs]) => {\n const zods = await Promise.all(\n verbs.map((verbOption) =>\n generateZod(\n verbOption,\n {\n route: verbOption.route,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target!,\n },\n output.client,\n ),\n ),\n );\n\n if (zods.every((z) => z.implementation === '')) {\n return {\n content: '',\n path: '',\n };\n }\n\n const allMutators = zods.reduce<Record<string, GeneratorMutator>>(\n (acc, z) => {\n for (const mutator of z.mutators ?? []) {\n acc[mutator.name] = mutator;\n }\n return acc;\n },\n {},\n );\n\n const mutatorsImports = generateMutatorImports({\n mutators: Object.values(allMutators),\n });\n\n let content = `${header}import { z as zod } from 'zod';\\n${mutatorsImports}\\n`;\n\n const zodPath =\n output.mode === 'tags'\n ? upath.join(dirname, `${kebab(tag)}.zod${extension}`)\n : upath.join(dirname, tag, tag + '.zod' + extension);\n\n content += zods.map((zod) => zod.implementation).join('\\n');\n\n return {\n content,\n path: zodPath,\n };\n }),\n );\n\n return Promise.all(\n builderContexts.filter((context) => context.content !== ''),\n );\n }\n\n const zods = await Promise.all(\n Object.values(verbOptions).map((verbOption) =>\n generateZod(\n verbOption,\n {\n route: verbOption.route,\n pathRoute: verbOption.pathRoute,\n override: output.override,\n context,\n mock: output.mock,\n output: output.target!,\n },\n output.client,\n ),\n ),\n );\n\n const allMutators = zods.reduce<Record<string, GeneratorMutator>>(\n (acc, z) => {\n for (const mutator of z.mutators ?? []) {\n acc[mutator.name] = mutator;\n }\n return acc;\n },\n {},\n );\n\n const mutatorsImports = generateMutatorImports({\n mutators: Object.values(allMutators),\n });\n\n let content = `${header}import { z as zod } from 'zod';\\n${mutatorsImports}\\n`;\n\n const zodPath = upath.join(dirname, `${filename}.zod${extension}`);\n\n content += zods.map((zod) => zod.implementation).join('\\n');\n\n return [\n {\n content,\n path: zodPath,\n },\n ];\n};\n\nconst generateZvalidator = (\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n\n let validatorPath = output.override.hono.validatorOutputPath;\n if (!output.override.hono.validatorOutputPath) {\n const { extension, dirname, filename } = getFileInfo(output.target);\n\n validatorPath = upath.join(dirname, `${filename}.validator${extension}`);\n }\n\n return {\n content: `${header}${ZVALIDATOR_SOURCE}`,\n path: validatorPath,\n };\n};\n\nconst generateCompositeRoutes = async (\n verbOptions: Record<string, GeneratorVerbOptions>,\n output: NormalizedOutputOptions,\n context: ContextSpecs,\n) => {\n const targetInfo = getFileInfo(output.target);\n const compositeRouteInfo = getFileInfo(output.override.hono.compositeRoute);\n\n const header = getHeader(\n output.override.header,\n context.specs[context.specKey].info,\n );\n\n const routes = Object.values(verbOptions)\n .map((verbOption) => {\n return generateHonoRoute(verbOption, verbOption.pathRoute);\n })\n .join(';');\n\n const importHandlers = Object.values(verbOptions);\n\n let ImportHandlersImplementation: string;\n if (output.override.hono.handlers) {\n const handlerFileInfo = getFileInfo(output.override.hono.handlers);\n const operationNames = importHandlers.map(\n (verbOption) => verbOption.operationName,\n );\n\n ImportHandlersImplementation = operationNames\n .map((operationName) => {\n const importHandlerName = `${operationName}Handlers`;\n\n const handlersPath = generateModuleSpecifier(\n compositeRouteInfo.path,\n upath.join(handlerFileInfo.dirname ?? '', `./${operationName}`),\n );\n\n return `import { ${importHandlerName} } from '${handlersPath}';`;\n })\n .join('\\n');\n } else {\n const tags = importHandlers.map((verbOption) =>\n kebab(verbOption.tags[0] ?? 'default'),\n );\n const uniqueTags = tags.filter((t, i) => tags.indexOf(t) === i);\n\n ImportHandlersImplementation = uniqueTags\n .map((tag) => {\n const importHandlerNames = importHandlers\n .filter((verbOption) => verbOption.tags[0] === tag)\n .map((verbOption) => ` ${verbOption.operationName}Handlers`)\n .join(`, \\n`);\n\n const handlersPath = generateModuleSpecifier(\n compositeRouteInfo.path,\n upath.join(targetInfo.dirname ?? '', tag),\n );\n\n return `import {\\n${importHandlerNames}\\n} from '${handlersPath}/${tag}.handlers';`;\n })\n .join('\\n');\n }\n\n const honoImport = `import { Hono } from 'hono';`;\n const honoInitialization = `\\nconst app = new Hono()`;\n const honoAppExport = `\\nexport default app`;\n\n const content = `${header}${honoImport}\n${ImportHandlersImplementation}\n${honoInitialization}\n${routes}\n${honoAppExport}\n`;\n\n return [\n {\n content,\n path: output.override.hono.compositeRoute || '',\n },\n ];\n};\n\nexport const generateExtraFiles: ClientExtraFilesBuilder = async (\n verbOptions,\n output,\n context,\n) => {\n const { path, pathWithoutExtension } = getFileInfo(output.target);\n const validator = generateZvalidator(output, context);\n let schemaModule: string;\n\n if (output.schemas != undefined) {\n schemaModule = getFileInfo(output.schemas).dirname;\n } else if (output.mode === 'single') {\n schemaModule = path;\n } else {\n schemaModule = `${pathWithoutExtension}.schemas`;\n }\n\n const [handlers, contexts, zods, compositeRoutes] = await Promise.all([\n generateHandlerFiles(verbOptions, output, validator.path),\n generateContextFiles(verbOptions, output, context, schemaModule),\n generateZodFiles(verbOptions, output, context),\n output.override.hono.compositeRoute\n ? generateCompositeRoutes(verbOptions, output, context)\n : [],\n ]);\n\n return [\n ...handlers,\n ...contexts,\n ...zods,\n ...(output.override.hono.validator &&\n output.override.hono.validator !== 'hono'\n ? [validator]\n : []),\n ...compositeRoutes,\n ];\n};\n\nconst honoClientBuilder: ClientGeneratorsBuilder = {\n client: generateHono,\n dependencies: getHonoDependencies,\n header: getHonoHeader,\n footer: getHonoFooter,\n extraFiles: generateExtraFiles,\n};\n\nexport const builder = () => () => honoClientBuilder;\n\nexport default builder;\n"],"mappings":";;;;;;AAEA,MAAM,YAAY,SAA0B,oBAAoB,KAAK,KAAK;AAE1E,MAAM,gBAAgB,SAAyB;CAC7C,MAAM,UAAU,4BAA4B,KAAK,KAAK;AACtD,KAAI,CAAC,SAAS,OAAQ,QAAO;CAE7B,MAAM,OAAO,QAAQ;CACrB,MAAM,QAAQ,SAAS,QAAQ,IAAI;EACjC,YAAY;EACZ,YAAY;EACZ,MAAM;EACN,KAAK;EACN,CAAC;CACF,MAAM,OAAO,SAAS,QAAQ,GAAG,GAAG,aAAa,QAAQ,GAAG,GAAG,QAAQ;AAEvE,QAAO,SAAS,KAAK,GAAG,GAAG,KAAK,IAAI,QAAQ,SAAS,GAAG,OAAO,QAAQ;;AAGzE,MAAa,YAAY,UAAkB;AAGzC,QAFsB,MAAM,MAAM,IAAI,CAEjB,QAAQ,KAAK,MAAM,MAAM;AAC5C,MAAI,CAAC,QAAQ,CAAC,EACZ,QAAO;AAGT,MAAI,CAAC,KAAK,SAAS,IAAI,CACrB,QAAO,GAAG,IAAI,GAAG;AAGnB,SAAO,GAAG,IAAI,GAAG,aAAa,KAAK;IAClC,GAAG;;;;;ACHR,MAAM,oBAAoB,GACvB,aAAa,MAAM,KAAK,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAC9D,SAAS,OAAO;AAEnB,MAAMA,oBAA2C,CAC/C;CACE,SAAS;EACP;GACE,MAAM;GACN,QAAQ;GACT;EACD,EACE,MAAM,WACP;EACD,EACE,MAAM,OACP;EACF;CACD,YAAY;CACb,CACF;;;;;;;;;;;;;;;AAgBD,MAAM,2BAA2B,MAAc,OAAe;AAC5D,KAAI,GAAG,WAAW,IAAI,IAAI,MAAM,WAA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