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

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
@@ -16,14 +16,16 @@ const getRoutePath = (path) => {
16
16
  dot: true
17
17
  });
18
18
  const next = hasParam(matches[3]) ? getRoutePath(matches[3]) : matches[3];
19
- return hasParam(path) ? `${prev}\:${param}${next}` : `${prev}${param}${next}`;
19
+ return hasParam(path) ? `${prev}:${param}${next}` : `${prev}${param}${next}`;
20
20
  };
21
21
  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
- }, "");
22
+ const splittedRoute = route.split("/");
23
+ let acc = "";
24
+ for (const [i, path] of splittedRoute.entries()) {
25
+ if (!path && i === 0) continue;
26
+ acc += path.includes("{") ? `/${getRoutePath(path)}` : `/${path}`;
27
+ }
28
+ return acc;
27
29
  };
28
30
 
29
31
  //#endregion
@@ -106,25 +108,28 @@ const generateHono = (verbOptions, options) => {
106
108
  * getHonoHandlers generates TypeScript code for the given verbs and reports
107
109
  * whether the code requires zValidator.
108
110
  */
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 += `
111
+ const getHonoHandlers = (...opts) => {
112
+ let code = "";
113
+ let hasZValidator = false;
114
+ for (const { handlerName, contextTypeName, verbOption, validator } of opts) {
115
+ let currentValidator = "";
116
+ if (validator) {
117
+ if (verbOption.headers) currentValidator += `zValidator('header', ${verbOption.operationName}Header),\n`;
118
+ if (verbOption.params.length > 0) currentValidator += `zValidator('param', ${verbOption.operationName}Params),\n`;
119
+ if (verbOption.queryParams) currentValidator += `zValidator('query', ${verbOption.operationName}QueryParams),\n`;
120
+ if (verbOption.body.definition) currentValidator += `zValidator('json', ${verbOption.operationName}Body),\n`;
121
+ if (validator !== "hono" && verbOption.response.originalSchema?.["200"]?.content?.["application/json"]) currentValidator += `zValidator('response', ${verbOption.operationName}Response),\n`;
122
+ }
123
+ code += `
120
124
  export const ${handlerName} = factory.createHandlers(
121
125
  ${currentValidator}async (c: ${contextTypeName}) => {
122
126
 
123
127
  },
124
128
  );`;
125
- hasZValidator ||= currentValidator !== "";
129
+ hasZValidator ||= currentValidator !== "";
130
+ }
126
131
  return [code, hasZValidator];
127
- }, ["", false]);
132
+ };
128
133
  const getZvalidatorImports = (verbOptions, importPath, isHonoValidator) => {
129
134
  const specifiers = [];
130
135
  for (const { operationName, headers, params, queryParams, body, response } of verbOptions) {
@@ -137,29 +142,29 @@ const getZvalidatorImports = (verbOptions, importPath, isHonoValidator) => {
137
142
  return specifiers.length === 0 ? "" : `import {\n${specifiers.join(",\n")}\n} from '${importPath}'`;
138
143
  };
139
144
  const getVerbOptionGroupByTag = (verbOptions) => {
140
- return Object.values(verbOptions).reduce((acc, value) => {
145
+ const grouped = {};
146
+ for (const value of Object.values(verbOptions)) {
141
147
  const tag = value.tags[0];
142
- if (!acc[tag]) acc[tag] = [];
143
- acc[tag].push(value);
144
- return acc;
145
- }, {});
148
+ if (!grouped[tag]) grouped[tag] = [];
149
+ grouped[tag].push(value);
150
+ }
151
+ return grouped;
146
152
  };
147
153
  const generateHandlerFile = async ({ verbs, path, validatorModule, zodModule, contextModule }) => {
148
154
  const validator = validatorModule === "@hono/zod-validator" ? "hono" : validatorModule != void 0;
149
155
  if (fs.existsSync(path)) {
150
156
  const rawFile = await fs.readFile(path, "utf8");
151
157
  let content = rawFile;
152
- content += Object.values(verbs).reduce((acc, verbOption) => {
158
+ for (const verbOption of Object.values(verbs)) {
153
159
  const handlerName = `${verbOption.operationName}Handlers`;
154
160
  const contextTypeName = `${pascal(verbOption.operationName)}Context`;
155
- if (!rawFile.includes(handlerName)) acc += getHonoHandlers({
161
+ if (!rawFile.includes(handlerName)) content += getHonoHandlers({
156
162
  handlerName,
157
163
  contextTypeName,
158
164
  verbOption,
159
165
  validator
160
166
  })[0];
161
- return acc;
162
- }, "");
167
+ }
163
168
  return content;
164
169
  }
165
170
  const [handlerCode, hasZValidator] = getHonoHandlers(...Object.values(verbs).map((verbOption) => ({
@@ -227,7 +232,7 @@ const getContext = (verbOption) => {
227
232
  const definition = param?.definition.split(":")[1];
228
233
  return { definition: `${name}${param?.required ?? false ? "" : "?"}:${definition}` };
229
234
  }).map((property) => property.definition).join(",\n ")},\n },`;
230
- const queryType = verbOption.queryParams ? `query: ${verbOption.queryParams?.schema.name},` : "";
235
+ const queryType = verbOption.queryParams ? `query: ${verbOption.queryParams.schema.name},` : "";
231
236
  const bodyType = verbOption.body.definition ? `json: ${verbOption.body.definition},` : "";
232
237
  const hasIn = !!paramType || !!queryType || !!bodyType;
233
238
  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} } }` : ""}>`;
@@ -287,8 +292,8 @@ const generateZodFiles = async (verbOptions, output, context) => {
287
292
  const header = getHeader(output.override.header, context.specs[context.specKey].info);
288
293
  if (output.mode === "tags" || output.mode === "tags-split") {
289
294
  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, {
295
+ return (await Promise.all(Object.entries(groupByTags).map(async ([tag, verbs]) => {
296
+ const zods$1 = await Promise.all(verbs.map(async (verbOption) => generateZod(verbOption, {
292
297
  route: verbOption.route,
293
298
  pathRoute: verbOption.pathRoute,
294
299
  override: output.override,
@@ -300,21 +305,16 @@ const generateZodFiles = async (verbOptions, output, context) => {
300
305
  content: "",
301
306
  path: ""
302
307
  };
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`;
308
+ 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
309
  const zodPath$1 = output.mode === "tags" ? upath.join(dirname, `${kebab(tag)}.zod${extension}`) : upath.join(dirname, tag, tag + ".zod" + extension);
309
310
  content$1 += zods$1.map((zod) => zod.implementation).join("\n");
310
311
  return {
311
312
  content: content$1,
312
313
  path: zodPath$1
313
314
  };
314
- }));
315
- return Promise.all(builderContexts.filter((context$1) => context$1.content !== ""));
315
+ }))).filter((context$1) => context$1.content !== "");
316
316
  }
317
- const zods = await Promise.all(Object.values(verbOptions).map((verbOption) => generateZod(verbOption, {
317
+ const zods = await Promise.all(Object.values(verbOptions).map(async (verbOption) => generateZod(verbOption, {
318
318
  route: verbOption.route,
319
319
  pathRoute: verbOption.pathRoute,
320
320
  override: output.override,
@@ -322,11 +322,7 @@ const generateZodFiles = async (verbOptions, output, context) => {
322
322
  mock: output.mock,
323
323
  output: output.target
324
324
  }, 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`;
325
+ 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
326
  const zodPath = upath.join(dirname, `${filename}.zod${extension}`);
331
327
  content += zods.map((zod) => zod.implementation).join("\n");
332
328
  return [{
@@ -346,7 +342,7 @@ const generateZvalidator = (output, context) => {
346
342
  path: validatorPath
347
343
  };
348
344
  };
349
- const generateCompositeRoutes = async (verbOptions, output, context) => {
345
+ const generateCompositeRoutes = (verbOptions, output, context) => {
350
346
  const targetInfo = getFileInfo(output.target);
351
347
  const compositeRouteInfo = getFileInfo(output.override.hono.compositeRoute);
352
348
  const header = getHeader(output.override.header, context.specs[context.specKey].info);
@@ -358,12 +354,12 @@ const generateCompositeRoutes = async (verbOptions, output, context) => {
358
354
  if (output.override.hono.handlers) {
359
355
  const handlerFileInfo = getFileInfo(output.override.hono.handlers);
360
356
  ImportHandlersImplementation = importHandlers.map((verbOption) => verbOption.operationName).map((operationName) => {
361
- return `import { ${`${operationName}Handlers`} } from '${generateModuleSpecifier(compositeRouteInfo.path, upath.join(handlerFileInfo.dirname ?? "", `./${operationName}`))}';`;
357
+ return `import { ${`${operationName}Handlers`} } from '${generateModuleSpecifier(compositeRouteInfo.path, upath.join(handlerFileInfo.dirname, `./${operationName}`))}';`;
362
358
  }).join("\n");
363
359
  } else {
364
360
  const tags = importHandlers.map((verbOption) => kebab(verbOption.tags[0] ?? "default"));
365
361
  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';`;
362
+ 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
363
  }).join("\n");
368
364
  }
369
365
  return [{
@@ -385,12 +381,9 @@ const generateExtraFiles = async (verbOptions, output, context) => {
385
381
  if (output.schemas != void 0) schemaModule = getFileInfo(output.schemas).dirname;
386
382
  else if (output.mode === "single") schemaModule = path;
387
383
  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
- ]);
384
+ const contexts = generateContextFiles(verbOptions, output, context, schemaModule);
385
+ const compositeRoutes = output.override.hono.compositeRoute ? generateCompositeRoutes(verbOptions, output, context) : [];
386
+ const [handlers, zods] = await Promise.all([generateHandlerFiles(verbOptions, output, validator.path), generateZodFiles(verbOptions, output, context)]);
394
387
  return [
395
388
  ...handlers,
396
389
  ...contexts,
@@ -411,4 +404,4 @@ var src_default = builder;
411
404
 
412
405
  //#endregion
413
406
  export { builder, src_default as default, generateExtraFiles, generateHono, getHonoDependencies, getHonoFooter, getHonoHeader };
414
- //# sourceMappingURL=index.js.map
407
+ //# 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 ContextSpecs,\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 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 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 // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\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\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: 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(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: 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 = (\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 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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AAED,MAAa,sBAAsB;AAEnC,kBAAe"}
package/package.json CHANGED
@@ -1,28 +1,29 @@
1
1
  {
2
2
  "name": "@orval/hono",
3
- "version": "8.0.0-rc.1",
3
+ "version": "8.0.0-rc.2",
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.2",
26
+ "@orval/zod": "8.0.0-rc.2",
26
27
  "fs-extra": "^11.3.2",
27
28
  "openapi3-ts": "4.5.0",
28
29
  "remeda": "^2.32.0"
@@ -30,10 +31,10 @@
30
31
  "devDependencies": {
31
32
  "@hono/zod-validator": "^0.7.4",
32
33
  "@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"
34
+ "eslint": "9.39.1",
35
+ "rimraf": "6.1.0",
36
+ "tsdown": "0.16.4",
37
+ "typescript": "5.9.3"
37
38
  },
38
- "stableVersion": "8.0.0-rc.0"
39
+ "stableVersion": "8.0.0-rc.1"
39
40
  }
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,GAC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