hono-takibi 0.32.6 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import { _ as isInputPath, tt as INPUT_EXTENSIONS } from "./guard-Rvg4ztIZ.js";
2
+ import { nt as INPUT_EXTENSIONS, v as isInputPath } from "./guard-ngBos42D.js";
3
3
  import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
4
4
  import * as NodeServices from "@effect/platform-node/NodeServices";
5
5
  import { Console, Effect, FileSystem, Option, Path, Ref, Schema, Stream } from "effect";
6
6
  import { Argument, CliError, Command, Flag } from "effect/cli";
7
7
  // package.json
8
- var version = "0.32.6";
8
+ var version = "0.33.0";
9
9
  var description = "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi";
10
10
  // src/cli/index.ts
11
11
  const COMMAND_NAME = "hono-takibi";
@@ -41,7 +41,7 @@ function runJobs(config) {
41
41
  const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob, openAPI3, packageRoots }] = yield* Effect.promise(() => Promise.all([
42
42
  import("./openapi-BxSVfs_l.js").then((n) => n.t),
43
43
  import("./format-BF7SbaMP.js").then((n) => n.r),
44
- import("./shared-BmIHrl_h.js").then((n) => n.o)
44
+ import("./shared-DJ1zD5Rg.js").then((n) => n.o)
45
45
  ]));
46
46
  const openAPI = yield* openAPI3(yield* parseOpenAPI(config.input), config.input);
47
47
  const jobs = makeJob(openAPI, config, yield* packageRoots(openAPI, config));
@@ -79,7 +79,7 @@ function reportJobs(config, previous) {
79
79
  onFailure: (error) => Console.error(`❌ ${error.message}`),
80
80
  onSuccess: (report) => Console.log(report)
81
81
  }));
82
- const { outsideSources } = yield* Effect.promise(() => import("./shared-BmIHrl_h.js").then((n) => n.o));
82
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-DJ1zD5Rg.js").then((n) => n.o));
83
83
  const inputDirectory = path.dirname(path.resolve(config.input));
84
84
  return {
85
85
  inputDirectory,
@@ -208,8 +208,8 @@ function generate(args) {
208
208
  if (input !== void 0 && output !== void 0) {
209
209
  const [{ parseOpenAPI }, { takibi }, { openAPI3 }] = yield* Effect.promise(() => Promise.all([
210
210
  import("./openapi-BxSVfs_l.js").then((n) => n.t),
211
- import("./core-CT8AnDwr.js").then((n) => n.t),
212
- import("./shared-BmIHrl_h.js").then((n) => n.o)
211
+ import("./core-D9NtmI5f.js").then((n) => n.t),
212
+ import("./shared-DJ1zD5Rg.js").then((n) => n.o)
213
213
  ]));
214
214
  const document = yield* openAPI3(yield* parseOpenAPI(input), input);
215
215
  return yield* Console.log(yield* takibi(document, output));
@@ -1 +1 @@
1
- export { t as docs } from "../../docs-DC7Q_-PY.js";
1
+ export { t as docs } from "../../docs-hKJj12Gm.js";
@@ -1 +1 @@
1
- export { t as hooks } from "../../hooks-B2Fcpr_z.js";
1
+ export { t as hooks } from "../../hooks-CSMf3pkH.js";
@@ -1,8 +1,8 @@
1
- import { $ as HTTP_METHODS, C as isOperationLike, M as isRecord, x as isOpenAPIPaths } from "../../guard-Rvg4ztIZ.js";
1
+ import { N as isRecord, S as isOpenAPIPaths, et as HTTP_METHODS, w as isOperationLike } from "../../guard-ngBos42D.js";
2
2
  import { t as emit } from "../../emit-8SmO5pHF.js";
3
3
  import { i as GenerateError } from "../../format-BF7SbaMP.js";
4
- import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "../../rpc-yhnsv_ji.js";
5
- import { _ as routeName, u as makeInferRequestType } from "../../utils-yHmzthJJ.js";
4
+ import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "../../rpc-DALShbf3.js";
5
+ import { _ as routeName, u as makeInferRequestType } from "../../utils-BeXPKXuG.js";
6
6
  import { Effect } from "effect";
7
7
  import { dirname } from "node:path";
8
8
  // src/core/rpc/index.ts
@@ -1,6 +1,6 @@
1
- import { F as isRequestBody, L as isSchemaArray, S as isOperation, T as isParameterArray, U as isStringRef, j as isPresent, l as isBinaryFile, m as isHttpMethod, w as isParameter, x as isOpenAPIPaths, y as isMediaWithSchema } from "../../guard-Rvg4ztIZ.js";
1
+ import { C as isOperation, E as isParameterArray, I as isRequestBody, M as isPresent, R as isSchemaArray, S as isOpenAPIPaths, T as isParameter, W as isStringRef, b as isMediaWithSchema, h as isHttpMethod, u as isBinaryFile } from "../../guard-ngBos42D.js";
2
2
  import { t as emit } from "../../emit-8SmO5pHF.js";
3
- import { d as makeSafeKey, v as statusCodeToNumber, y as toIdentifierPascalCase } from "../../utils-yHmzthJJ.js";
3
+ import { d as makeSafeKey, v as statusCodeToNumber, y as toIdentifierPascalCase } from "../../utils-BeXPKXuG.js";
4
4
  import { Effect } from "effect";
5
5
  import path from "node:path";
6
6
  // src/core/type/index.ts
@@ -1,15 +1,15 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
- import { $ as HTTP_METHODS, G as isValidIdent, M as isRecord, O as isPathItem, S as isOperation, k as isPathItemEntry, m as isHttpMethod, q as COMPONENT_NAMES, u as isCallbacks, x as isOpenAPIPaths } from "./guard-Rvg4ztIZ.js";
2
+ import { A as isPathItemEntry, C as isOperation, J as COMPONENT_NAMES, K as isValidIdent, N as isRecord, S as isOpenAPIPaths, d as isCallbacks, et as HTTP_METHODS, h as isHttpMethod, k as isPathItem } from "./guard-ngBos42D.js";
3
3
  import { i as GenerateError, n as fmt } from "./format-BF7SbaMP.js";
4
- import { S as zodToOpenAPISchema, _ as routeName, a as ensureSuffix, b as uncapitalize, c as escapeRegexLiteral, h as renderNamedImport, l as makeBarrel, x as uncapitalizeWord, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
5
- import { C as makePathItem, D as makeWebhookEntries, E as makeRouteProperties, O as resolveParameter, S as makeCallback, T as makeRouteEntries, _ as identifierNames, a as requestBodiesCode, b as textOf, c as makeSplitSchemaFile, d as makeImports, f as makeModuleSpec, g as descendantsWhere, h as declarationOf, i as responsesCode, k as resolvePathItem, l as makeConst, m as ast, n as componentsCode, o as parametersCode, p as analyzeCircularSchemas, r as schemasCode, s as headersCode, u as makeExportConst, v as parseModule, w as makeRef, x as zodToOpenAPI, y as parseSource } from "./routes-936pvd-W.js";
6
- import { t as zodOpenAPIHono } from "./openapi-DWSCULWR.js";
7
- import { t as makeMock } from "./mock-Db6ltVgv.js";
8
- import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-yhnsv_ji.js";
4
+ import { _ as routeName, a as ensureSuffix, b as uncapitalize, c as escapeRegexLiteral, h as renderNamedImport, l as makeBarrel, x as zodToOpenAPISchema, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
5
+ import { C as makePathItem, D as makeWebhookEntries, E as makeRouteProperties, O as resolveParameter, S as makeCallback, T as makeRouteEntries, _ as identifierNames, a as requestBodiesCode, b as textOf, c as makeSplitSchemaFile, d as makeImports, f as makeModuleSpec, g as descendantsWhere, h as declarationOf, i as responsesCode, k as resolvePathItem, l as makeConst, m as ast, n as componentsCode, o as parametersCode, p as analyzeCircularSchemas, r as schemasCode, s as headersCode, u as makeExportConst, v as parseModule, w as makeRef, x as zodToOpenAPI, y as parseSource } from "./routes-Cg-imktp.js";
6
+ import { t as zodOpenAPIHono } from "./openapi-CitBEjdx.js";
7
+ import { t as makeMock } from "./mock-CvrfyklR.js";
8
+ import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-DALShbf3.js";
9
9
  import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-hO_bjDys.js";
10
10
  import { t as emit } from "./emit-8SmO5pHF.js";
11
- import { t as hooks } from "./hooks-B2Fcpr_z.js";
12
- import { t as docs } from "./docs-DC7Q_-PY.js";
11
+ import { t as hooks } from "./hooks-CSMf3pkH.js";
12
+ import { t as docs } from "./docs-hKJj12Gm.js";
13
13
  import { rpc } from "./core/rpc/index.js";
14
14
  import { type } from "./core/type/index.js";
15
15
  import { Effect } from "effect";
@@ -719,22 +719,47 @@ function sanitizeHandlerSegment(segment) {
719
719
  return segment.replaceAll(/\{([^}]+)\}/gu, "$1").replaceAll(/[^0-9A-Za-z._-]/gu, "_").replaceAll(/^[._-]+|[._-]+$/gu, "").replaceAll(/__+/gu, "_").replaceAll(/[-._](\w)/gu, (_, char) => char.toUpperCase());
720
720
  }
721
721
  /**
722
- * Derives the handler file name for an operation: the first tag (lower camel case) when
723
- * present, otherwise the first path segment (`/` → `__root`).
722
+ * A tag or a path segment in kebab case: every run of what is no letter or digit is a word
723
+ * break, and so is a change of case, an acronym being one word. `Real-Time Events` as
724
+ * `real-time-events`, `userAPIKeys` as `user-api-keys`, `{org_id}` as `org-id`.
724
725
  */
725
- function makeHandlerFileName(path, tags) {
726
- const tagName = uncapitalizeWord(sanitizeHandlerSegment(tags?.[0] ?? ""));
727
- const pathName = sanitizeHandlerSegment(path.replace(/^\/+/u, "").split("/")[0] ?? "");
728
- return `${tagName !== "" ? tagName : pathName !== "" ? pathName : "__root"}.ts`;
726
+ function kebabHandlerSegment(segment) {
727
+ return segment.replaceAll(/\{([^}]+)\}/gu, "$1").replaceAll(/[^0-9A-Za-z]+/gu, "-").replaceAll(/([a-z0-9])([A-Z])/gu, "$1-$2").replaceAll(/([A-Z])([A-Z][a-z])/gu, "$1-$2").replaceAll(/^-+|-+$/gu, "").toLowerCase();
729
728
  }
730
729
  /**
731
- * The group an operation belongs to: the name of the handler file it is written to, the
732
- * first tag or else the first segment of the path, `/v2-public/ping` as `v2Public`, and the
733
- * root `/` as `__root`. A segment that is a word of the language is prefixed the same way,
734
- * `/delete` as `__delete`.
730
+ * The name a handler file goes by in code, whatever the case of the file: the base name with
731
+ * its hyphens read as word breaks, `real-time-events.ts` as `realTimeEvents`. A file named in
732
+ * camel case goes by its base name as it is. The export of an inline handler file
733
+ * (`realTimeEventsHandler`) and its group are made of this name.
735
734
  */
736
- function handlerGroupOf(path, tags) {
737
- return groupNameOf(makeHandlerFileName(path, tags).replace(/\.ts$/u, ""));
735
+ function handlerNameOf(fileName) {
736
+ return basename(fileName, ".ts").replaceAll(/-+([0-9A-Za-z_]?)/gu, (_, char) => char.toUpperCase());
737
+ }
738
+ /**
739
+ * Derives the handler file name for an operation, in kebab case: the first segment of its
740
+ * path (`/` → `__root`), `/real-time-events/{id}` as `real-time-events.ts`. The tags of the
741
+ * operation say nothing of the file.
742
+ */
743
+ function makeHandlerFileName(path) {
744
+ const name = kebabHandlerSegment(path.replace(/^\/+/u, "").split("/")[0] ?? "");
745
+ return `${name !== "" ? name : "__root"}.ts`;
746
+ }
747
+ /**
748
+ * The group of the handler file an operation is written to: the name that file goes by in
749
+ * code, `real-time-events.ts` as `realTimeEvents`, and the root `/` as `__root`. A name that
750
+ * is a word of the language is prefixed the same way, `/delete` as `__delete`.
751
+ */
752
+ function handlerGroupOf(path) {
753
+ return groupNameOf(handlerNameOf(makeHandlerFileName(path)));
754
+ }
755
+ /**
756
+ * The group of a path where the app registers the routes itself and no handler file stands
757
+ * for the group: the first segment in camel case as it is written, `/v2-public/ping` as
758
+ * `v2Public`, with the same prefix for the root and for a word of the language.
759
+ */
760
+ function pathGroupOf(path) {
761
+ const name = sanitizeHandlerSegment(path.replace(/^\/+/u, "").split("/")[0] ?? "");
762
+ return groupNameOf(name !== "" ? name : "__root");
738
763
  }
739
764
  function isTsFileName(file) {
740
765
  return file.endsWith(".ts");
@@ -765,15 +790,17 @@ function scanExistingHandlerFiles(handlerPath, collect) {
765
790
  }
766
791
  /**
767
792
  * Picks the file a generated export goes to: the file that already holds it, else the
768
- * expected name when that file exists, else an existing file whose name matches
769
- * case-insensitively (case-insensitive filesystems), else the expected name.
793
+ * expected name when that file exists, else an existing file that goes by the same name in
794
+ * code whatever its case (`realTimeEvents.ts` for `real-time-events.ts`, and a file that
795
+ * differs by case alone, as on a case-insensitive filesystem), else the expected name. A
796
+ * project whose files were written in camel case keeps them.
770
797
  */
771
798
  function resolveHandlerFileName(expected, key, existing) {
772
799
  const located = existing.locations.get(key);
773
800
  if (located) return located;
774
801
  if (existing.fileNames.includes(expected)) return expected;
775
- const lower = expected.toLowerCase();
776
- return existing.fileNames.find((file) => file.toLowerCase() === lower) ?? expected;
802
+ const name = handlerNameOf(expected).toLowerCase();
803
+ return existing.fileNames.find((file) => handlerNameOf(file).toLowerCase() === name) ?? expected;
777
804
  }
778
805
  /**
779
806
  * Files the scan found codegen keys in but that hold no route of the current spec. They are
@@ -798,24 +825,24 @@ function makePaths(output, pathAlias, routeImport) {
798
825
  importFrom: routeImport ?? (aliasPrefix ? `${aliasPrefix}/${routeModuleName}` : `../${routeModuleName}`)
799
826
  };
800
827
  }
801
- function makeHandlerInfo(paths, path, method, operation, existing, member, body) {
828
+ function makeHandlerInfo(paths, path, method, existing, member, body) {
802
829
  const routeId = routeName(method, path, paths);
803
830
  return {
804
- fileName: resolveHandlerFileName(makeHandlerFileName(path, operation.tags), `${routeId}${member}`, existing),
831
+ fileName: resolveHandlerFileName(makeHandlerFileName(path), `${routeId}${member}`, existing),
805
832
  contents: [body(routeId)],
806
833
  routeNames: [`${routeId}Route`]
807
834
  };
808
835
  }
809
- function makeInlineStubHandlerInfo(paths, path, method, operation, existing) {
810
- return makeHandlerInfo(paths, path, method, operation, existing, "Route", (routeId) => `.openapi(${routeId}Route,(c)=>{})`);
836
+ function makeInlineStubHandlerInfo(paths, path, method, existing) {
837
+ return makeHandlerInfo(paths, path, method, existing, "Route", (routeId) => `.openapi(${routeId}Route,(c)=>{})`);
811
838
  }
812
839
  function makeInlineStubFileContent(handler, importFrom) {
813
- const exportName = `${basename(handler.fileName, ".ts")}Handler`;
840
+ const exportName = `${handlerNameOf(handler.fileName)}Handler`;
814
841
  const routeImports = [...new Set(handler.routeNames)].join(", ");
815
842
  return `${`import { OpenAPIHono } from '@hono/zod-openapi'\n${routeImports ? `import { ${routeImports} } from '${importFrom}';` : ""}`}\n\nconst app = new OpenAPIHono()\n\nexport const ${exportName} = app\n${handler.contents.join("\n")}`;
816
843
  }
817
- function makeStubHandlerInfo(paths, path, method, operation, existing) {
818
- return makeHandlerInfo(paths, path, method, operation, existing, "RouteHandler", (routeId) => `export const ${routeId}RouteHandler:RouteHandler<typeof ${routeId}Route>=async(c)=>{}`);
844
+ function makeStubHandlerInfo(paths, path, method, existing) {
845
+ return makeHandlerInfo(paths, path, method, existing, "RouteHandler", (routeId) => `export const ${routeId}RouteHandler:RouteHandler<typeof ${routeId}Route>=async(c)=>{}`);
819
846
  }
820
847
  function makeMergedHandlers(handlers) {
821
848
  const handlerMap = /* @__PURE__ */ new Map();
@@ -879,7 +906,7 @@ function zodOpenAPIHonoHandler(openapi, output, pathAlias, routeImport, routeHan
879
906
  const paths = openapi.paths;
880
907
  const { handlerPath, importFrom } = makePaths(output, pathAlias, routeImport);
881
908
  const existing = yield* scanExistingHandlerFiles(handlerPath, routeHandler ? (code) => collectExportedNames(code, "RouteHandler") : collectInlineRouteNames);
882
- const specHandlers = makeMergedHandlers(Object.entries(paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method, operation]) => routeHandler ? makeStubHandlerInfo(paths, path, method, operation, existing) : makeInlineStubHandlerInfo(paths, path, method, operation, existing))));
909
+ const specHandlers = makeMergedHandlers(Object.entries(paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method]) => routeHandler ? makeStubHandlerInfo(paths, path, method, existing) : makeInlineStubHandlerInfo(paths, path, method, existing))));
883
910
  const handlers = [...specHandlers, ...makeOrphanHandlers(existing, specHandlers.map((handler) => handler.fileName))];
884
911
  yield* mkdir(handlerPath);
885
912
  yield* Effect.all([...handlers.map((handler) => writeHandler({
@@ -899,7 +926,7 @@ function resolveInlineHandlerFileNames(openapi, output, pathAlias, routeImport)
899
926
  return Effect.gen(function* () {
900
927
  const { handlerPath } = makePaths(output, pathAlias, routeImport);
901
928
  const existing = yield* scanExistingHandlerFiles(handlerPath, collectInlineRouteNames);
902
- const fileNames = Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method, operation]) => resolveHandlerFileName(makeHandlerFileName(path, operation.tags), `${routeName(method, path, openapi.paths)}Route`, existing)));
929
+ const fileNames = Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method]) => resolveHandlerFileName(makeHandlerFileName(path), `${routeName(method, path, openapi.paths)}Route`, existing)));
903
930
  return [...new Set(fileNames)];
904
931
  });
905
932
  }
@@ -916,7 +943,7 @@ function defineOpenAPIRouteHandler(openapi, output, componentsOutput, pathAlias,
916
943
  const handlerPath = baseDir === "." ? "routes" : `${baseDir}/routes`;
917
944
  const existing = yield* scanExistingHandlerFiles(handlerPath, (code) => collectExportedNames(code, "Route"));
918
945
  const specHandlers = defineEntries(openapi, readonly).reduce((acc, entry) => {
919
- const fileName = resolveHandlerFileName(makeHandlerFileName(entry.path, entry.tags), `${entry.name}Route`, existing);
946
+ const fileName = resolveHandlerFileName(makeHandlerFileName(entry.path), `${entry.name}Route`, existing);
920
947
  const prev = acc.get(fileName);
921
948
  return new Map(acc).set(fileName, {
922
949
  fileName,
@@ -1389,7 +1416,7 @@ function takibi(openAPI, output, componentsOptions = {}) {
1389
1416
  // src/generator/zod-openapi-hono/app/index.ts
1390
1417
  /** The handler files the operations of a document are written to, in document order. */
1391
1418
  function handlerFilesOf(openapi) {
1392
- return [...new Set(Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).flatMap(([method, operation]) => isHttpMethod(method) && isOperation(operation) ? [makeHandlerFileName(path, operation.tags)] : [])))];
1419
+ return [...new Set(Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).flatMap(([method, operation]) => isHttpMethod(method) && isOperation(operation) ? [makeHandlerFileName(path)] : [])))];
1393
1420
  }
1394
1421
  /**
1395
1422
  * The groups of a split app, in the order their first route stands in the document: the
@@ -1402,7 +1429,7 @@ function handlerFilesOf(openapi) {
1402
1429
  */
1403
1430
  function appGroups(openapi, inline, inlineHandlerFileNames, split) {
1404
1431
  if (!split) return [];
1405
- const names = inline ? (inlineHandlerFileNames ?? handlerFilesOf(openapi)).map((file) => groupNameOf(basename(file, ".ts"))) : Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.keys(pathItem).flatMap((method) => isHttpMethod(method) ? [handlerGroupOf(path)] : []));
1432
+ const names = inline ? (inlineHandlerFileNames ?? handlerFilesOf(openapi)).map((file) => groupNameOf(handlerNameOf(file))) : Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.keys(pathItem).flatMap((method) => isHttpMethod(method) ? [pathGroupOf(path)] : []));
1406
1433
  return [...new Set(names)];
1407
1434
  }
1408
1435
  /**
@@ -1443,7 +1470,7 @@ function app(openapi, output, basePath, pathAlias, routeImport, routeHandler = f
1443
1470
  importSection,
1444
1471
  appInit,
1445
1472
  ...groups.map((name) => {
1446
- const routes = [...new Set(routeMappings.filter(({ path }) => handlerGroupOf(path) === name).map(({ routeName }) => routeName))];
1473
+ const routes = [...new Set(routeMappings.filter(({ path }) => pathGroupOf(path) === name).map(({ routeName }) => routeName))];
1447
1474
  return `export const ${name}=${appVar}.openapiRoutes([${routes.join(",")}] as const)`;
1448
1475
  }),
1449
1476
  appExport
@@ -1457,18 +1484,16 @@ function app(openapi, output, basePath, pathAlias, routeImport, routeHandler = f
1457
1484
  }
1458
1485
  if (!routeHandler) {
1459
1486
  const handlerFileNames = inlineHandlerFileNames ?? handlerFilesOf(openapi);
1460
- const handlerExportNames = handlerFileNames.map((fileName) => `${basename(fileName, ".ts")}Handler`);
1487
+ const files = [...new Set(handlerFileNames.map(handlerNameOf))];
1488
+ const handlerExportNames = files.map((file) => `${file}Handler`);
1461
1489
  const handlerModule = handlerModuleOverride ?? (aliasPrefix ? `${aliasPrefix}/handlers` : "./handlers");
1462
1490
  const importSection = [honoImport, handlerExportNames.length > 0 ? `import{${handlerExportNames.join(",")}}from'${handlerModule}'` : ""].filter(Boolean).join("\n");
1463
- if (split) {
1464
- const files = handlerFileNames.map((file) => basename(file, ".ts"));
1465
- return [
1466
- importSection,
1467
- appInit,
1468
- ...groups.map((name) => `export const ${name}=${appVar}${files.filter((file) => groupNameOf(file) === name).map((file) => `.route('/',${file}Handler)`).join("")}`),
1469
- appExport
1470
- ].join("\n\n");
1471
- }
1491
+ if (split) return [
1492
+ importSection,
1493
+ appInit,
1494
+ ...groups.map((name) => `export const ${name}=${appVar}${files.filter((file) => groupNameOf(file) === name).map((file) => `.route('/',${file}Handler)`).join("")}`),
1495
+ appExport
1496
+ ].join("\n\n");
1472
1497
  return [
1473
1498
  importSection,
1474
1499
  appInit,
@@ -1495,7 +1520,7 @@ function app(openapi, output, basePath, pathAlias, routeImport, routeHandler = f
1495
1520
  return [
1496
1521
  importSection,
1497
1522
  appInit,
1498
- ...groups.map((name) => `export const ${name}=${appVar}${routeMappings.filter(({ path }) => handlerGroupOf(path) === name).map(({ routeName, handlerName }) => `.openapi(${routeName},${handlerName})`).join("\n")}`),
1523
+ ...groups.map((name) => `export const ${name}=${appVar}${routeMappings.filter(({ path }) => pathGroupOf(path) === name).map(({ routeName, handlerName }) => `.openapi(${routeName},${handlerName})`).join("\n")}`),
1499
1524
  appExport
1500
1525
  ].join("\n\n");
1501
1526
  }
@@ -1576,4 +1601,4 @@ var core_exports = /* @__PURE__ */ __exportAll({
1576
1601
  type: () => type,
1577
1602
  webhooks: () => webhooks
1578
1603
  });
1579
- export { isInsideDirectory as C, makeGeneratedImport as E, appEntryOutput as S, makeAppEntryImport as T, headers as _, takibi as a, client as b, securitySchemes as c, requestBodies as d, pathItems as f, links as g, mediaTypes as h, defineTemplate as i, schemas as l, components as m, webhooks as n, route as o, parameters as p, template as r, mock as s, core_exports as t, responses as u, examples as v, makeAppEntryFile as w, handlerGroupOf as x, callbacks as y };
1604
+ export { appEntryOutput as C, makeGeneratedImport as D, makeAppEntryImport as E, pathGroupOf as S, makeAppEntryFile as T, headers as _, takibi as a, client as b, securitySchemes as c, requestBodies as d, pathItems as f, links as g, mediaTypes as h, defineTemplate as i, schemas as l, components as m, webhooks as n, route as o, parameters as p, template as r, mock as s, core_exports as t, responses as u, examples as v, isInsideDirectory as w, handlerGroupOf as x, callbacks as y };
@@ -1,6 +1,6 @@
1
1
  import { n as mkdir, o as writeFile } from "./file-hO_bjDys.js";
2
- import { $ as HTTP_METHODS, L as isSchemaArray, M as isRecord, N as isRefObject, rt as MULTIPART_MEDIA_TYPE } from "./guard-Rvg4ztIZ.js";
3
- import { i as decodePercent, s as escapeHtml } from "./utils-yHmzthJJ.js";
2
+ import { N as isRecord, P as isRefObject, R as isSchemaArray, et as HTTP_METHODS, it as MULTIPART_MEDIA_TYPE } from "./guard-ngBos42D.js";
3
+ import { i as decodePercent, s as escapeHtml } from "./utils-BeXPKXuG.js";
4
4
  import { Effect } from "effect";
5
5
  import path from "node:path";
6
6
  import { STATUS_CODES } from "node:http";
@@ -1,7 +1,7 @@
1
1
  import { parseConfig } from "../index.js";
2
2
  import { t as FormatOptions } from "../format-BF7SbaMP.js";
3
3
  import { n as parseOpenAPI } from "../openapi-BxSVfs_l.js";
4
- import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BmIHrl_h.js";
4
+ import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-DJ1zD5Rg.js";
5
5
  import * as NodeServices from "@effect/platform-node/NodeServices";
6
6
  import { Effect } from "effect";
7
7
  // src/generate/index.ts
@@ -1 +1 @@
1
- export { t as makeMock } from "../../mock-Db6ltVgv.js";
1
+ export { t as makeMock } from "../../mock-CvrfyklR.js";
@@ -1 +1 @@
1
- export { t as zodOpenAPIHono } from "../../../openapi-DWSCULWR.js";
1
+ export { t as zodOpenAPIHono } from "../../../openapi-CitBEjdx.js";
@@ -386,4 +386,4 @@ function hasNoContentResponse(operation) {
386
386
  function isInheritedName(parameter) {
387
387
  return parameter.in !== "path" && parameter.name in Object.prototype;
388
388
  }
389
- export { HTTP_METHODS as $, isPathItemRef as A, isSecurityArray as B, isOperationLike as C, isParameterRef as D, isParameterObject as E, isRequestBody as F, isValidIdent as G, isSingleSchema as H, isResponses as I, COMPONENT_REF_PREFIX as J, ARROW_FUNCTION_PATTERN as K, isSchemaArray as L, isRecord as M, isRefObject as N, isPathItem as O, isRefOnly as P, HOOK_LIBRARIES as Q, isSchemaObject as R, isOperation as S, isParameterArray as T, isStringRef as U, isSecurityScheme as V, isUntypedObject as W, FORM_MEDIA_TYPES as X, COMPONENT_SUFFIXES as Y, FORM_URLENCODED_MEDIA_TYPE as Z, isInputPath as _, hasNumericConstraint as a, TEXT_MEDIA_TYPE as at, isOffsetTime as b, isAnnotationOnly as c, isDiscriminableBranch as d, IDENTIFIER_PATTERN as et, isExamplesInput as f, isInlineMedia as g, isInheritedName as h, hasNoUserChain as i, OCTET_STREAM_MEDIA_TYPE as it, isPresent as j, isPathItemEntry as k, isBinaryFile as l, isHttpMethod as m, hasMimeAlternatives as n, JSON_MEDIA_TYPE as nt, hasRequestBodyContent as o, isHeader as p, COMPONENT_NAMES as q, hasNoContentResponse as r, MULTIPART_MEDIA_TYPE as rt, hasTypelessConstraint as s, fileMimeTypes as t, INPUT_EXTENSIONS as tt, isCallbacks as u, isMedia as v, isParameter as w, isOpenAPIPaths as x, isMediaWithSchema as y, isSchemaProperty as z };
389
+ export { HOOK_LIBRARIES as $, isPathItemEntry as A, isSchemaProperty as B, isOperation as C, isParameterObject as D, isParameterArray as E, isRefOnly as F, isUntypedObject as G, isSecurityScheme as H, isRequestBody as I, COMPONENT_NAMES as J, isValidIdent as K, isResponses as L, isPresent as M, isRecord as N, isParameterRef as O, isRefObject as P, FORM_URLENCODED_MEDIA_TYPE as Q, isSchemaArray as R, isOpenAPIPaths as S, isParameter as T, isSingleSchema as U, isSecurityArray as V, isStringRef as W, COMPONENT_SUFFIXES as X, COMPONENT_REF_PREFIX as Y, FORM_MEDIA_TYPES as Z, isInlineMedia as _, hasNoUserChain as a, OCTET_STREAM_MEDIA_TYPE as at, isMediaWithSchema as b, hasTypelessConstraint as c, isCallbacks as d, HTTP_METHODS as et, isDiscriminableBranch as f, isInheritedName as g, isHttpMethod as h, hasNoContentResponse as i, MULTIPART_MEDIA_TYPE as it, isPathItemRef as j, isPathItem as k, isAnnotationOnly as l, isHeader as m, fileMimeTypes as n, INPUT_EXTENSIONS as nt, hasNumericConstraint as o, TEXT_MEDIA_TYPE as ot, isExamplesInput as p, ARROW_FUNCTION_PATTERN as q, hasMimeAlternatives as r, JSON_MEDIA_TYPE as rt, hasRequestBodyContent as s, ANNOTATION_KEYWORDS as t, IDENTIFIER_PATTERN as tt, isBinaryFile as u, isInputPath as v, isOperationLike as w, isOffsetTime as x, isMedia as y, isSchemaObject as z };
@@ -1,8 +1,8 @@
1
- import { $ as HTTP_METHODS, C as isOperationLike, M as isRecord, r as hasNoContentResponse, x as isOpenAPIPaths } from "./guard-Rvg4ztIZ.js";
1
+ import { N as isRecord, S as isOpenAPIPaths, et as HTTP_METHODS, i as hasNoContentResponse, w as isOperationLike } from "./guard-ngBos42D.js";
2
2
  import { t as emit } from "./emit-8SmO5pHF.js";
3
3
  import { i as GenerateError } from "./format-BF7SbaMP.js";
4
- import { _ as routeName, n as capitalize, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
5
- import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "./rpc-yhnsv_ji.js";
4
+ import { _ as routeName, n as capitalize, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
5
+ import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "./rpc-DALShbf3.js";
6
6
  import { Effect } from "effect";
7
7
  import path from "node:path";
8
8
  // src/helper/query.ts
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Q as HOOK_LIBRARIES, _ as isInputPath, et as IDENTIFIER_PATTERN, q as COMPONENT_NAMES } from "./guard-Rvg4ztIZ.js";
1
+ import { $ as HOOK_LIBRARIES, J as COMPONENT_NAMES, tt as IDENTIFIER_PATTERN, v as isInputPath } from "./guard-ngBos42D.js";
2
2
  import { Effect, FileSystem, Schema, SchemaIssue, SchemaTransformation } from "effect";
3
3
  import { posix, resolve } from "node:path";
4
4
  import { pathToFileURL } from "node:url";
@@ -44,14 +44,14 @@ const ConfigSchema = Schema.Struct({
44
44
  })),
45
45
  template: Schema.optionalKey(Schema.Union([Schema.Struct({
46
46
  define: Schema.Literal(true).annotate({ description: "Emit `defineOpenAPIRoute({ route, handler })` entries. Derives `routes/` next to the app entry, so it cannot be combined with `routes` or per-type component outputs." }),
47
- split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public` — or, where the handlers register their routes themselves (`routeHandler: false`), the handler file the app mounts, which goes by the first tag. The root belongs to no group." }),
47
+ split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public`. The tags of an operation do not divide the routes. The root belongs to no group." }),
48
48
  test: Schema.optionalKey(Schema.Never.annotate({ message: "test was removed: hono-takibi no longer generates test files. The `.test.ts` files a previous run wrote are yours to keep or delete." })),
49
49
  pathAlias: Schema.optionalKey(Schema.Never.annotate({ message: "pathAlias was moved to the top level: it applies to every generated file of this package, not only to the scaffold." })),
50
50
  testFramework: Schema.optionalKey(Schema.Never.annotate({ message: "testFramework was removed: hono-takibi no longer generates test files." }))
51
51
  }), Schema.Struct({
52
52
  define: Schema.Literal(false).pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Scaffold app and handler files (default)." }),
53
53
  routeHandler: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Emit the `app.openapi()` pattern with `RouteHandler` type exports. When false, handlers import the app and register routes inline." }),
54
- split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public` — or, where the handlers register their routes themselves (`routeHandler: false`), the handler file the app mounts, which goes by the first tag. The root belongs to no group." }),
54
+ split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public`. The tags of an operation do not divide the routes. The root belongs to no group." }),
55
55
  test: Schema.optionalKey(Schema.Never.annotate({ message: "test was removed: hono-takibi no longer generates test files. The `.test.ts` files a previous run wrote are yours to keep or delete." })),
56
56
  pathAlias: Schema.optionalKey(Schema.Never.annotate({ message: "pathAlias was moved to the top level: it applies to every generated file of this package, not only to the scaffold." })),
57
57
  testFramework: Schema.optionalKey(Schema.Never.annotate({ message: "testFramework was removed: hono-takibi no longer generates test files." }))
@@ -1,6 +1,6 @@
1
- import { $ as HTTP_METHODS, A as isPathItemRef, B as isSecurityArray, J as COMPONENT_REF_PREFIX, L as isSchemaArray, N as isRefObject, R as isSchemaObject, S as isOperation, V as isSecurityScheme, a as hasNumericConstraint, at as TEXT_MEDIA_TYPE, g as isInlineMedia, j as isPresent, k as isPathItemEntry, m as isHttpMethod, nt as JSON_MEDIA_TYPE, o as hasRequestBodyContent, w as isParameter, y as isMediaWithSchema } from "./guard-Rvg4ztIZ.js";
2
- import { _ as routeName, a as ensureSuffix, d as makeSafeKey, f as makeStringLiteral, p as normalizeTypes, r as cyclicNodes, v as statusCodeToNumber, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
3
- import { n as componentsCode, t as routeCode } from "./routes-936pvd-W.js";
1
+ import { A as isPathItemEntry, C as isOperation, H as isSecurityScheme, M as isPresent, P as isRefObject, R as isSchemaArray, T as isParameter, V as isSecurityArray, Y as COMPONENT_REF_PREFIX, _ as isInlineMedia, b as isMediaWithSchema, et as HTTP_METHODS, h as isHttpMethod, j as isPathItemRef, o as hasNumericConstraint, ot as TEXT_MEDIA_TYPE, rt as JSON_MEDIA_TYPE, s as hasRequestBodyContent, z as isSchemaObject } from "./guard-ngBos42D.js";
2
+ import { _ as routeName, a as ensureSuffix, d as makeSafeKey, f as makeStringLiteral, p as normalizeTypes, r as cyclicNodes, v as statusCodeToNumber, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
3
+ import { n as componentsCode, t as routeCode } from "./routes-Cg-imktp.js";
4
4
  // src/helper/faker.ts
5
5
  const FORMAT_TO_FAKER = {
6
6
  date: "faker.date.past().toISOString().slice(0, 10)",
@@ -1,6 +1,6 @@
1
- import { $ as HTTP_METHODS, M as isRecord, Y as COMPONENT_SUFFIXES, q as COMPONENT_NAMES } from "./guard-Rvg4ztIZ.js";
2
- import { a as ensureSuffix, i as decodePercent, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
3
- import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-936pvd-W.js";
1
+ import { J as COMPONENT_NAMES, N as isRecord, X as COMPONENT_SUFFIXES, et as HTTP_METHODS } from "./guard-ngBos42D.js";
2
+ import { a as ensureSuffix, i as decodePercent, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
3
+ import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-Cg-imktp.js";
4
4
  // src/helper/names.ts
5
5
  /**
6
6
  * Renames the components whose identifiers would collide, and every `$ref` to them.
@@ -1,5 +1,5 @@
1
- import { $ as HTTP_METHODS, A as isPathItemRef, D as isParameterRef, G as isValidIdent, H as isSingleSchema, I as isResponses, J as COMPONENT_REF_PREFIX, K as ARROW_FUNCTION_PATTERN, L as isSchemaArray, M as isRecord, N as isRefObject, O as isPathItem, P as isRefOnly, R as isSchemaObject, S as isOperation, W as isUntypedObject, X as FORM_MEDIA_TYPES, Y as COMPONENT_SUFFIXES$1, b as isOffsetTime, c as isAnnotationOnly, d as isDiscriminableBranch, f as isExamplesInput, h as isInheritedName, i as hasNoUserChain, j as isPresent, k as isPathItemEntry, l as isBinaryFile, n as hasMimeAlternatives, p as isHeader, q as COMPONENT_NAMES, s as hasTypelessConstraint, t as fileMimeTypes, u as isCallbacks, v as isMedia, w as isParameter } from "./guard-Rvg4ztIZ.js";
2
- import { S as zodToOpenAPISchema, _ as routeName, a as ensureSuffix, b as uncapitalize, c as escapeRegexLiteral, d as makeSafeKey, f as makeStringLiteral, g as requestParamsArray, h as renderNamedImport, i as decodePercent, m as regexLiteral, o as error, p as normalizeTypes, r as cyclicNodes, t as baseError, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
1
+ import { A as isPathItemEntry, C as isOperation, F as isRefOnly, G as isUntypedObject, J as COMPONENT_NAMES, K as isValidIdent, L as isResponses, M as isPresent, N as isRecord, O as isParameterRef, P as isRefObject, R as isSchemaArray, T as isParameter, U as isSingleSchema, X as COMPONENT_SUFFIXES$1, Y as COMPONENT_REF_PREFIX, Z as FORM_MEDIA_TYPES, a as hasNoUserChain, c as hasTypelessConstraint, d as isCallbacks, et as HTTP_METHODS, f as isDiscriminableBranch, g as isInheritedName, j as isPathItemRef, k as isPathItem, l as isAnnotationOnly, m as isHeader, n as fileMimeTypes, p as isExamplesInput, q as ARROW_FUNCTION_PATTERN, r as hasMimeAlternatives, t as ANNOTATION_KEYWORDS, u as isBinaryFile, x as isOffsetTime, y as isMedia, z as isSchemaObject } from "./guard-ngBos42D.js";
2
+ import { _ as routeName, a as ensureSuffix, b as uncapitalize, c as escapeRegexLiteral, d as makeSafeKey, f as makeStringLiteral, g as requestParamsArray, h as renderNamedImport, i as decodePercent, m as regexLiteral, o as error, p as normalizeTypes, r as cyclicNodes, t as baseError, x as zodToOpenAPISchema, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
3
3
  import path from "node:path";
4
4
  import { parseSync, rawTransferSupported, visitorKeys } from "oxc-parser";
5
5
  // src/helper/wire.ts
@@ -1556,6 +1556,113 @@ function typeOf(value) {
1556
1556
  if (Array.isArray(value)) return "array";
1557
1557
  if (isRecord(value)) return "object";
1558
1558
  }
1559
+ /**
1560
+ * A schema without the vendor extensions the emitter turns into Zod (`x-error-message`,
1561
+ * `x-catch`, `x-stringbool`), at every level: they say how the schema is emitted, not what
1562
+ * it is, and the document does not carry them. An extension the emitter does not know stays.
1563
+ */
1564
+ function withoutEmitterExtensions(schema) {
1565
+ if (!isRecord(schema)) return schema;
1566
+ return Object.fromEntries(Object.entries(schema).flatMap(([key, value]) => {
1567
+ if (key.startsWith("x-") && zodExpressedProps.has(key)) return [];
1568
+ if (SCHEMA_VALUED_KEYS.has(key)) return [[key, withoutEmitterExtensions(value)]];
1569
+ if (SCHEMA_LIST_KEYS.has(key) && Array.isArray(value)) return [[key, value.map((sub) => withoutEmitterExtensions(sub))]];
1570
+ if ((SCHEMA_MAP_KEYS.has(key) || key === "patternProperties") && isRecord(value)) return [[key, Object.fromEntries(Object.entries(value).map(([name, sub]) => [name, withoutEmitterExtensions(sub)]))]];
1571
+ return [[key, value]];
1572
+ }));
1573
+ }
1574
+ /**
1575
+ * A list of schemas as the literal the document is handed: every reference written out as
1576
+ * the component it names, since the document defines a component only where a route uses
1577
+ * it, and only what a Schema Object has. It states the `anyOf` / `oneOf` written beside the
1578
+ * combinator a schema is emitted as (#469), which nothing in the emitted schema renders.
1579
+ */
1580
+ function schemaList(list, schemas) {
1581
+ return schemaLiteral(list.map((sub) => pruneSchemaObject(withoutEmitterExtensions(inlineSchemaRefs(sub, schemas)), true)));
1582
+ }
1583
+ /**
1584
+ * What a value is read by: the schema itself, the component a reference names, the members
1585
+ * of its `allOf`, and the branch of a `oneOf` / `anyOf` that takes the value. A schema with a
1586
+ * user chain hands out what the chain does, which nothing here can tell, so it reads nothing.
1587
+ */
1588
+ function readersOf(schema, value, schemas, reading = /* @__PURE__ */ new Set()) {
1589
+ if (!hasNoUserChain(schema)) return [];
1590
+ if (schema.$ref !== void 0) {
1591
+ const target = reading.has(schema.$ref) ? void 0 : resolveSchemaRef(schema.$ref, schemas);
1592
+ if (target === void 0) return [];
1593
+ const { $ref: _ref, ...beside } = schema;
1594
+ return readersOf({
1595
+ ...target,
1596
+ ...beside
1597
+ }, value, schemas, /* @__PURE__ */ new Set([...reading, schema.$ref]));
1598
+ }
1599
+ const branch = (schema.oneOf ?? schema.anyOf)?.find((candidate) => conformDefault(candidate, value, schemas, reading).ok);
1600
+ return [
1601
+ schema,
1602
+ ...(schema.allOf ?? []).flatMap((member) => readersOf(member, value, schemas, reading)),
1603
+ ...branch === void 0 ? [] : readersOf(branch, value, schemas, reading)
1604
+ ];
1605
+ }
1606
+ /**
1607
+ * A value as the literal of its schema, at every level (#491). JSON has one kind of number,
1608
+ * and an `int64` / `uint64` / `bigint` integer is emitted as a bigint, so a number such a
1609
+ * schema reads is written as one — `{"n":1n}`, `[1n,2n]` — wherever it stands in an object or
1610
+ * an array; a `date` is written as the `Date` it names. Everything else is its JSON. `bigint`
1611
+ * says whether the literal holds a bigint, which no document can.
1612
+ */
1613
+ function valueLiteral(schema, value, schemas) {
1614
+ if (value === void 0) return {
1615
+ code: "undefined",
1616
+ bigint: false
1617
+ };
1618
+ if (value === null || typeof value === "boolean") return {
1619
+ code: JSON.stringify(value),
1620
+ bigint: false
1621
+ };
1622
+ const readers = readersOf(schema, value, schemas);
1623
+ if (typeof value === "number") {
1624
+ const format = Number.isInteger(value) ? readers.find((reader) => normalizeTypes(reader.type).includes("integer") && (reader.format === "int64" || reader.format === "uint64" || reader.format === "bigint"))?.format : void 0;
1625
+ if (format === void 0) return {
1626
+ code: `${value}`,
1627
+ bigint: false
1628
+ };
1629
+ return {
1630
+ code: format === "bigint" ? `BigInt(${value})` : `${value}n`,
1631
+ bigint: true
1632
+ };
1633
+ }
1634
+ if (typeof value === "string") return {
1635
+ code: readers.some((reader) => reader.type === "date") ? `new Date(${JSON.stringify(value)})` : JSON.stringify(value),
1636
+ bigint: false
1637
+ };
1638
+ if (Array.isArray(value)) {
1639
+ const items = readers.map((reader) => reader.items).find((item) => item !== void 0 && typeof item !== "boolean" && !isSchemaArray(item));
1640
+ const members = value.map((member) => items === void 0 || typeof items === "boolean" || isSchemaArray(items) ? valueLiteral({}, member, schemas) : valueLiteral(items, member, schemas));
1641
+ return {
1642
+ code: `[${members.map((member) => member.code).join(",")}]`,
1643
+ bigint: members.some((member) => member.bigint)
1644
+ };
1645
+ }
1646
+ if (isRecord(value)) {
1647
+ const members = Object.entries(value).flatMap(([key, member]) => {
1648
+ if (member === void 0) return [];
1649
+ const additional = readers.map((reader) => reader.additionalProperties).find((sub) => typeof sub === "object");
1650
+ const literal = valueLiteral(readers.map((reader) => reader.properties?.[key]).find((sub) => sub !== void 0) ?? (typeof additional === "object" ? additional : void 0) ?? {}, member, schemas);
1651
+ return [{
1652
+ code: `${JSON.stringify(key)}:${literal.code}`,
1653
+ bigint: literal.bigint
1654
+ }];
1655
+ });
1656
+ return {
1657
+ code: `{${members.map((member) => member.code).join(",")}}`,
1658
+ bigint: members.some((member) => member.bigint)
1659
+ };
1660
+ }
1661
+ return {
1662
+ code: JSON.stringify(value),
1663
+ bigint: false
1664
+ };
1665
+ }
1559
1666
  function wrap(zod, schema, meta, options) {
1560
1667
  const typeList = Array.isArray(schema.type) ? schema.type : schema.type !== void 0 ? [schema.type] : [];
1561
1668
  const formatLiteral = (v) => {
@@ -1571,6 +1678,7 @@ function wrap(zod, schema, meta, options) {
1571
1678
  if (schema.type === "date" && typeof v === "string") return `new Date(${JSON.stringify(v)})`;
1572
1679
  if ((v === "true" || v === "false") && ((schema.enum?.includes(v) ?? false) || schema.const === v)) return JSON.stringify(v);
1573
1680
  if (typeList.includes("boolean") && (v === "true" || v === "false")) return v;
1681
+ if (Array.isArray(v) || isRecord(v)) return valueLiteral(schema, v, options?.schemas).code;
1574
1682
  return JSON.stringify(v);
1575
1683
  };
1576
1684
  const parameter = meta?.parameters && meta.parameters.required === void 0 && meta.parameters.in !== "path" ? {
@@ -1583,13 +1691,29 @@ function wrap(zod, schema, meta, options) {
1583
1691
  const conformed = conformDefault(schema, schema.default, options?.schemas);
1584
1692
  const defaultValue = conformed.ok ? conformed.value : void 0;
1585
1693
  const droppedDefault = schema.default !== void 0 && !conformed.ok;
1586
- const isNullable = schema.nullable === true || typeList.includes("null") || defaultValue === null;
1694
+ const documentedDefault = defaultValue === void 0 ? schema["x-prefault"] : defaultValue;
1695
+ const statedDefault = documentedDefault !== void 0 && valueLiteral(schema, documentedDefault, options?.schemas).bigint ? documentedDefault : void 0;
1696
+ const isNullable = schema.nullable === true || typeList.includes("null") || defaultValue === null || schema["x-prefault"] === null || schema["x-catch"] === null;
1697
+ const catchDocument = (() => {
1698
+ if (schema["x-catch"] === void 0 || !hasNoUserChain(schema)) return void 0;
1699
+ const source = withoutEmitterExtensions(inlineSchemaRefs(schema, options?.schemas));
1700
+ if (!isRecord(source)) return void 0;
1701
+ const declared = Array.isArray(source.type) ? source.type.filter((type) => typeof type === "string") : typeof source.type === "string" ? [source.type] : isUntypedObject(schema) ? ["object"] : [];
1702
+ if (declared.length === 0) return void 0;
1703
+ const types = isNullable && !declared.includes("null") ? [...declared, "null"] : declared;
1704
+ const [only, ...others] = types;
1705
+ const { nullable: _nullable, ...rest } = source;
1706
+ return {
1707
+ ...rest,
1708
+ type: others.length === 0 ? only : types
1709
+ };
1710
+ })();
1587
1711
  const build = (core) => {
1588
1712
  const typed = isNullable ? `${acceptBothArities(core)}.nullable()` : acceptBothArities(core);
1589
1713
  const n = options?.nullRead === "first" ? `z.preprocess(${WIRE_NULL},${typed})` : options?.nullRead === "last" ? `((schema)=>z.union([schema,z.preprocess(${WIRE_NULL},schema)]))(${typed})` : typed;
1590
1714
  const defaulted = defaultValue !== void 0 ? `${n}.default(${formatLiteral(defaultValue)})` : n;
1591
1715
  const pf = schema["x-prefault"] !== void 0 ? `${defaulted}.prefault(${formatLiteral(schema["x-prefault"])})` : defaulted;
1592
- const caught = schema["x-catch"] !== void 0 ? `${pf}.catch(${formatLiteral(schema["x-catch"])})` : pf;
1716
+ const caught = schema["x-catch"] === void 0 ? pf : catchDocument === void 0 && hasNoUserChain(schema) ? `(()=>{const Schema=${pf};return z.preprocess((val: z.input<typeof Schema>)=>Schema.safeParse(val).success?val:${formatLiteral(schema["x-catch"])},Schema)})()` : `${pf}.catch(${formatLiteral(schema["x-catch"])})`;
1593
1717
  const superRefineChain = `${`${schema["x-readonly"] === true ? `${caught}.readonly()` : caught}${schema["x-refine"] ?? ""}`}${schema["x-superRefine"] ?? ""}`;
1594
1718
  const preprocess = schema["x-preprocess"];
1595
1719
  const transform = schema["x-transform"];
@@ -1614,7 +1738,9 @@ function wrap(zod, schema, meta, options) {
1614
1738
  const args = pruneSchemaObject(Object.fromEntries([
1615
1739
  ...Object.entries(schema).filter(([k, v]) => isSchemaObjectKey(k) && !(zodExpressedProps.has(k) || k === "required" && typeof v === "boolean" || headerDupKeys.has(k))),
1616
1740
  ...droppedDefault && !isBigintInteger ? [["default", schema.default]] : [],
1617
- ...typeof schema.pattern === "string" && (isFile || regexLiteral(schema.pattern) === void 0) ? [["pattern", schema.pattern]] : []
1741
+ ...statedDefault !== void 0 && !isBigintInteger && !droppedDefault ? [["default", statedDefault]] : [],
1742
+ ...typeof schema.pattern === "string" && (isFile || regexLiteral(schema.pattern) === void 0) ? [["pattern", schema.pattern]] : [],
1743
+ ...schema.$ref === void 0 && meta?.parameters === void 0 && isRecord(schema.not) ? [["not", withoutEmitterExtensions(inlineSchemaRefs(schema.not, options?.schemas))]] : []
1618
1744
  ]));
1619
1745
  const headerMetaProps = meta?.headers ? [
1620
1746
  meta.headers.description ? `description:${JSON.stringify(meta.headers.description)}` : void 0,
@@ -1660,15 +1786,25 @@ function wrap(zod, schema, meta, options) {
1660
1786
  const inside = absent(build(around(`${zod}.openapi({param:${makeSerializedParam(parameter)}})`)));
1661
1787
  return parameter.required === true ? inside : `${inside}.exactOptional()`;
1662
1788
  }
1789
+ const catchMetaProps = (() => {
1790
+ if (catchDocument === void 0) return void 0;
1791
+ return schemaLiteral(pruneSchemaObject(Object.fromEntries(Object.entries(catchDocument).flatMap(([key, value]) => {
1792
+ if (headerDupKeys.has(key)) return [];
1793
+ if (isBigintInteger && key === "const") return "enum" in catchDocument ? [] : [["enum", [value]]];
1794
+ return [[key, value]];
1795
+ })), true)).slice(1, -1);
1796
+ })();
1663
1797
  const result = [
1664
1798
  parameter ? `param:${makeSerializedParam(parameter)}` : void 0,
1665
1799
  ...headerMetaProps,
1666
1800
  meta?.headers && meta.headers.required !== true ? "param:{required:false}" : void 0,
1667
- ...fileMetaProps,
1668
- ...timeMetaProps,
1669
- ...bigintMetaProps,
1670
- ...patternMetaProps,
1671
- openapiSchemaBody && openapiSchemaBody.length > 0 ? openapiSchemaBody : void 0
1801
+ ...catchMetaProps === void 0 ? [
1802
+ ...fileMetaProps,
1803
+ ...timeMetaProps,
1804
+ ...bigintMetaProps,
1805
+ ...patternMetaProps,
1806
+ openapiSchemaBody && openapiSchemaBody.length > 0 ? openapiSchemaBody : void 0
1807
+ ] : [catchMetaProps]
1672
1808
  ].filter((v) => v !== void 0);
1673
1809
  if (meta?.parameters || meta?.headers) {
1674
1810
  if (meta.parameters?.required === true || meta.headers?.required === true) return result.length === 0 ? z : `${z}.openapi({${result.join(",")}})`;
@@ -1896,6 +2032,117 @@ function requiresObject(schema, schemas, seen = []) {
1896
2032
  if (union !== void 0) return union.length > 0 && union.every((branch) => requiresObject(branch, schemas, seen));
1897
2033
  return isUntypedObject(schema);
1898
2034
  }
2035
+ function declaredTypes(schema) {
2036
+ return normalizeTypes(schema.type).filter((type) => type !== "null");
2037
+ }
2038
+ function isValueOfType(value, type) {
2039
+ switch (type) {
2040
+ case "string": return typeof value === "string";
2041
+ case "number": return typeof value === "number";
2042
+ case "integer": return typeof value === "number" && Number.isInteger(value);
2043
+ case "boolean": return typeof value === "boolean";
2044
+ case "array": return Array.isArray(value);
2045
+ case "object": return typeof value === "object" && value !== null && !Array.isArray(value);
2046
+ case "date": return false;
2047
+ default: return false;
2048
+ }
2049
+ }
2050
+ function admitsOnlyTypes(schema, declared, schemas, seen = []) {
2051
+ if (schema.$ref !== void 0) {
2052
+ if (seen.includes(schema.$ref)) return true;
2053
+ const target = resolveSchemaRef(schema.$ref, schemas);
2054
+ return target === void 0 ? true : admitsOnlyTypes(target, declared, schemas, [...seen, schema.$ref]);
2055
+ }
2056
+ const types = declaredTypes(schema);
2057
+ if (types.length > 0) return types.every((type) => declared.includes(type) || type === "integer" && declared.includes("number"));
2058
+ if (normalizeTypes(schema.type).length > 0) return true;
2059
+ const values = Array.isArray(schema.enum) ? schema.enum : schema.const !== void 0 ? [schema.const] : void 0;
2060
+ if (values !== void 0) return values.every((value) => value === null || declared.some((type) => isValueOfType(value, type)));
2061
+ if (schema.allOf !== void 0) return schema.allOf.some((member) => admitsOnlyTypes(member, declared, schemas, seen));
2062
+ const union = schema.anyOf ?? schema.oneOf;
2063
+ if (union !== void 0) return union.length > 0 && union.every((branch) => admitsOnlyTypes(branch, declared, schemas, seen));
2064
+ return declared.includes("object") && isUntypedObject(schema);
2065
+ }
2066
+ const KEYWORDS_OF_TYPE = {
2067
+ string: /* @__PURE__ */ new Set([
2068
+ "minLength",
2069
+ "maxLength",
2070
+ "pattern"
2071
+ ]),
2072
+ number: /* @__PURE__ */ new Set([
2073
+ "minimum",
2074
+ "maximum",
2075
+ "exclusiveMinimum",
2076
+ "exclusiveMaximum",
2077
+ "multipleOf"
2078
+ ]),
2079
+ integer: /* @__PURE__ */ new Set([
2080
+ "minimum",
2081
+ "maximum",
2082
+ "exclusiveMinimum",
2083
+ "exclusiveMaximum",
2084
+ "multipleOf"
2085
+ ]),
2086
+ boolean: /* @__PURE__ */ new Set(),
2087
+ object: /* @__PURE__ */ new Set(),
2088
+ array: /* @__PURE__ */ new Set([
2089
+ "minItems",
2090
+ "maxItems",
2091
+ "items"
2092
+ ])
2093
+ };
2094
+ function canTakeType(member, type) {
2095
+ if (member.type !== void 0 || member.$ref !== void 0 || member.enum !== void 0 || member.const !== void 0) return false;
2096
+ const keys = Object.keys(member).filter((key) => !ANNOTATION_KEYWORDS.has(key) && !/^x-.+-message$/u.test(key));
2097
+ const combinators = /* @__PURE__ */ new Set([
2098
+ "allOf",
2099
+ "anyOf",
2100
+ "oneOf",
2101
+ "not"
2102
+ ]);
2103
+ if (keys.length > 0 && keys.every((key) => combinators.has(key))) return true;
2104
+ const own = KEYWORDS_OF_TYPE[type];
2105
+ return own !== void 0 && keys.every((key) => own.has(key));
2106
+ }
2107
+ function narrowToDeclaredType(schema, schemas) {
2108
+ const declared = declaredTypes(schema);
2109
+ const [single, ...others] = declared;
2110
+ if (single === void 0) return schema;
2111
+ const typeSchema = { type: others.length === 0 ? single : [single, ...others] };
2112
+ const settled = (member) => admitsOnlyTypes(member, declared, schemas);
2113
+ const takes = (member) => others.length === 0 && canTakeType(member, single);
2114
+ const objectOnly = others.length === 0 && single === "object";
2115
+ const hasShape = schema.properties !== void 0 && Object.keys(schema.properties).length > 0 || Array.isArray(schema.required) && schema.required.length > 0;
2116
+ if (schema.allOf !== void 0) {
2117
+ if (objectOnly && schema.properties !== void 0) return schema;
2118
+ const members = schema.allOf.map((member) => !settled(member) && !isAnnotationOnly(member) && takes(member) ? {
2119
+ ...member,
2120
+ type: single
2121
+ } : member);
2122
+ if (members.some(settled)) return members.every((member, index) => member === schema.allOf?.[index]) ? schema : {
2123
+ ...schema,
2124
+ allOf: members
2125
+ };
2126
+ return {
2127
+ ...schema,
2128
+ allOf: [typeSchema, ...members]
2129
+ };
2130
+ }
2131
+ const key = schema.anyOf !== void 0 ? "anyOf" : schema.oneOf !== void 0 ? "oneOf" : void 0;
2132
+ if (key === void 0) return schema;
2133
+ const branches = schema[key] ?? [];
2134
+ if (branches.length === 0) return schema;
2135
+ if (objectOnly && hasShape && !(normalizeTypes(schema.type).includes("null") && branches.some((branch) => canAdmitNullOrUndefined(branch, schemas) || branch.nullable === true || normalizeTypes(branch.type).includes("null") || branch.default !== void 0 || branch["x-prefault"] !== void 0 || branch["x-catch"] !== void 0))) return schema;
2136
+ if (branches.every(settled)) return schema;
2137
+ const typed = (branch) => takes(branch) ? {
2138
+ ...branch,
2139
+ ...typeSchema
2140
+ } : { allOf: [typeSchema, branch] };
2141
+ return {
2142
+ ...schema,
2143
+ [key]: branches.map((branch) => settled(branch) ? branch : typed(branch))
2144
+ };
2145
+ }
1899
2146
  function canAcceptObject(schema, schemas, seen = []) {
1900
2147
  if (typeof schema === "boolean") return schema;
1901
2148
  if (schema.$ref !== void 0) {
@@ -1948,6 +2195,120 @@ function emitsStrippingObject(schema, schemas, seen = []) {
1948
2195
  if (union !== void 0) return union.some((branch) => emitsStrippingObject(branch, schemas, seen));
1949
2196
  return isUntypedObject(schema) && isStrippingObject(schema);
1950
2197
  }
2198
+ function resolveOperand(schema, schemas, seen = []) {
2199
+ if (schema.$ref === void 0) return schema;
2200
+ if (seen.includes(schema.$ref)) return void 0;
2201
+ if (!hasNoUserChain(schema) || schema["x-catch"] !== void 0) return void 0;
2202
+ const target = resolveSchemaRef(schema.$ref, schemas);
2203
+ return target === void 0 ? void 0 : resolveOperand(target, schemas, [...seen, schema.$ref]);
2204
+ }
2205
+ function emitsStrictObject(schema) {
2206
+ return schema.additionalProperties === false && hasNoUserChain(schema) && schema["x-catch"] === void 0 && schema.allOf === void 0 && schema.anyOf === void 0 && schema.oneOf === void 0 && schema.enum === void 0 && schema.const === void 0 && (normalizeTypes(schema.type).includes("object") || isUntypedObject(schema));
2207
+ }
2208
+ function leaksUnrecognizedKeys(schema, schemas, seen = []) {
2209
+ if (!hasNoUserChain(schema) || schema["x-catch"] !== void 0) return false;
2210
+ if (schema.$ref !== void 0) {
2211
+ if (seen.includes(schema.$ref)) return false;
2212
+ const target = resolveSchemaRef(schema.$ref, schemas);
2213
+ return target === void 0 ? false : leaksUnrecognizedKeys(target, schemas, [...seen, schema.$ref]);
2214
+ }
2215
+ if (schema.allOf !== void 0) {
2216
+ const [only, ...others] = schema.allOf.filter((member) => member.type !== "null" && !isAnnotationOnly(member));
2217
+ return only !== void 0 && others.length === 0 ? leaksUnrecognizedKeys(only, schemas, seen) : false;
2218
+ }
2219
+ if (schema.anyOf !== void 0) return schema.anyOf.some((branch) => leaksUnrecognizedKeys(branch, schemas, seen));
2220
+ if (schema.oneOf !== void 0) return discriminatedBranches(schema, schemas) !== void 0 && schema.oneOf.some((branch) => leaksUnrecognizedKeys(branch, schemas, seen));
2221
+ return emitsStrictObject(schema);
2222
+ }
2223
+ const parseSync$1 = (zod, value) => `${zod}.safeParse(${value})`;
2224
+ const parseAsync = (zod, value) => `(await ${zod}.safeParseAsync(${value}))`;
2225
+ function undeclaredKeysStmt(schema) {
2226
+ const ownKeys = Object.keys(schema.properties ?? {});
2227
+ const patterns = Object.keys(schema.patternProperties ?? {});
2228
+ const undeclared = [...ownKeys.length > 0 ? [`!${JSON.stringify(ownKeys)}.includes(k)`] : [], ...patterns.length > 0 ? [`!${JSON.stringify(patterns)}.some((p)=>new RegExp(p).test(k))`] : []];
2229
+ const message = pickMessage(schema, "x-additionalProperties-message");
2230
+ const report = `ctx.issues.push({code:"custom",path:[k],input:o${message === void 0 ? "" : `,message:${message}`}})`;
2231
+ return `for(const k of Object.keys(o)){${undeclared.length === 0 ? report : `if(${undeclared.join("&&")}){${report}}`}}`;
2232
+ }
2233
+ function isStrictObjectOperand(schema) {
2234
+ return emitsStrictObject(schema) && declaredTypes(schema).length <= 1;
2235
+ }
2236
+ function discriminatedKeysStmt(schema, schemas) {
2237
+ const discriminator = schema.discriminator?.propertyName;
2238
+ const branches = discriminatedBranches(schema, schemas);
2239
+ if (discriminator === void 0 || branches === void 0) return void 0;
2240
+ const strict = branches.filter(({ branch }) => leaksUnrecognizedKeys(branch, schemas));
2241
+ if (strict.length === 0) return void 0;
2242
+ if (!strict.every(({ branch }) => isStrictObjectOperand(branch) && branch.patternProperties === void 0 && branch["x-additionalProperties-message"] === void 0)) return void 0;
2243
+ const keysByValue = Object.fromEntries(strict.flatMap(({ branch }) => {
2244
+ const property = branch.properties?.[discriminator];
2245
+ return (typeof property?.const === "string" ? [property.const] : (property?.enum ?? []).filter((value) => typeof value === "string")).map((value) => [value, Object.keys(branch.properties ?? {})]);
2246
+ }));
2247
+ return `{const own:{readonly [k:string]:readonly string[]}=${JSON.stringify(keysByValue)};const d=String(Reflect.get(o,${JSON.stringify(discriminator)}));const keys=Object.hasOwn(own,d)?own[d]:undefined;if(keys!==undefined){for(const k of Object.keys(o)){if(!keys.includes(k)){ctx.issues.push({code:"custom",path:[k],input:o})}}}}`;
2248
+ }
2249
+ function strictOperandKind(schema, schemas) {
2250
+ const resolved = resolveOperand(schema, schemas);
2251
+ if (resolved === void 0) return { kind: "none" };
2252
+ if (isStrictObjectOperand(resolved)) return {
2253
+ kind: "statement",
2254
+ statement: undeclaredKeysStmt(resolved)
2255
+ };
2256
+ if (!leaksUnrecognizedKeys(schema, schemas)) return { kind: "none" };
2257
+ const discriminated = hasNoUserChain(resolved) ? discriminatedKeysStmt(resolved, schemas) : void 0;
2258
+ return discriminated === void 0 ? { kind: "ask" } : {
2259
+ kind: "statement",
2260
+ statement: discriminated
2261
+ };
2262
+ }
2263
+ function isAskedOperand(schema, schemas) {
2264
+ return strictOperandKind(schema, schemas).kind === "ask";
2265
+ }
2266
+ function makeStrictOperandCheck(operands, schemas) {
2267
+ const kinds = operands.map(({ schema, zod }) => ({
2268
+ zod,
2269
+ ...strictOperandKind(schema, schemas)
2270
+ }));
2271
+ const stmts = (parse) => kinds.flatMap((operand) => {
2272
+ if (operand.kind === "none") return [];
2273
+ if (operand.kind === "statement") return [operand.statement];
2274
+ return [`{const result=${parse(operand.zod, "o")};if(!result.success&&result.error.issues.every((issue)=>issue.code==='unrecognized_keys'&&issue.path.length===0)){for(const issue of result.error.issues){if(issue.code==='unrecognized_keys'){for(const k of issue.keys){ctx.issues.push({code:"custom",path:[k],input:o,message:issue.message})}}}}}`];
2275
+ });
2276
+ const sync = stmts(parseSync$1);
2277
+ if (sync.length === 0) return void 0;
2278
+ const guard = `const o=ctx.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;`;
2279
+ return {
2280
+ sync: `(ctx)=>{${guard}${sync.join(";")}}`,
2281
+ ...kinds.some((operand) => operand.kind === "ask") ? { async: `async(ctx)=>{${guard}${stmts(parseAsync).join(";")}}` } : {}
2282
+ };
2283
+ }
2284
+ function makeParentStrictCheck(schema) {
2285
+ if (schema.additionalProperties !== false) return void 0;
2286
+ return { sync: `(ctx)=>{const o=ctx.value;if(typeof o!=='object'||o===null||Array.isArray(o))return;${undeclaredKeysStmt(schema)}}` };
2287
+ }
2288
+ function reportSibling(message) {
2289
+ return `ctx.issues.push({code:"custom",input:val${message === void 0 ? "" : ARROW_FUNCTION_PATTERN.test(message) ? `,message:(${message})({code:'custom',path:[],input:val})` : `,message:${JSON.stringify(message)}`}})`;
2290
+ }
2291
+ function makeSiblingCombinatorCheck(schema, keys, recurse) {
2292
+ const errorMessage = schema["x-error-message"];
2293
+ const stmts = (parse) => keys.flatMap((key) => {
2294
+ if (key === "anyOf") {
2295
+ const branches = (schema.anyOf ?? []).map((sub) => `${parse(recurse(sub), "val")}.success`);
2296
+ const message = schema["x-implication-message"] ?? schema["x-anyOf-message"] ?? errorMessage;
2297
+ return branches.length === 0 ? [] : [`if(!(${branches.join("||")})){${reportSibling(message)}}`];
2298
+ }
2299
+ if (key === "oneOf") {
2300
+ const branches = (schema.oneOf ?? []).map((sub) => `(${parse(recurse(sub), "val")}.success?1:0)`);
2301
+ return branches.length === 0 ? [] : [`if((${branches.join("+")})!==1){${reportSibling(schema["x-oneOf-message"] ?? errorMessage)}}`];
2302
+ }
2303
+ return schema.not === void 0 ? [] : [`if(${parse(recurse(schema.not), "val")}.success){${reportSibling(schema["x-not-message"] ?? errorMessage)}}`];
2304
+ });
2305
+ const sync = stmts(parseSync$1);
2306
+ if (sync.length === 0) return void 0;
2307
+ return {
2308
+ sync: `(ctx)=>{const val=ctx.value;${sync.join(";")}}`,
2309
+ async: `async(ctx)=>{const val=ctx.value;${stmts(parseAsync).join(";")}}`
2310
+ };
2311
+ }
1951
2312
  function emitObjectShapeCheck(schema, recurse) {
1952
2313
  const checks = makeObjectChecks(schema, recurse, (issue) => `ctx.issues.push({...${issue},input:val})`);
1953
2314
  if (checks.length === 0) return void 0;
@@ -2559,9 +2920,14 @@ function string(schema, options) {
2559
2920
  return `${makeValidationBase()}${postTrim}${postLower}${postUpper}${postNormalize}${refinements}`;
2560
2921
  }
2561
2922
  // src/generator/zod-to-openapi/index.ts
2562
- function withUnevaluatedCheck(zod, unevalCheck) {
2563
- if (unevalCheck === "") return zod;
2564
- return `(()=>{const Schema=${zod};return z.preprocess((val: z.input<typeof Schema>,ctx)=>{(${unevalCheck})(ctx);return val},Schema)})()`;
2923
+ function withRawCheck(zod, check, declarations = []) {
2924
+ const raw = typeof check === "string" ? { sync: check } : check;
2925
+ if (raw === void 0 || raw.sync === "") return zod;
2926
+ if (raw.async === void 0) return withRawStatements(zod, `(${raw.sync})(ctx)`, declarations);
2927
+ return `(()=>{${declarations.join("")}const Schema=${zod};return z.preprocess((val: z.input<typeof Schema>,ctx)=>{const reported=ctx.issues.length;try{(${raw.sync})(ctx)}catch(error){if(!(error instanceof z.core.$ZodAsyncError))throw error;ctx.issues.length=reported;return (${raw.async})(ctx).then(()=>val)}return val},Schema)})()`;
2928
+ }
2929
+ function withRawStatements(zod, statements, declarations = []) {
2930
+ return `(()=>{${declarations.join("")}const Schema=${zod};return z.preprocess((val: z.input<typeof Schema>,ctx)=>{${statements};return val},Schema)})()`;
2565
2931
  }
2566
2932
  function hasOwnWrapping(branch) {
2567
2933
  return branch.nullable === true || normalizeTypes(branch.type).includes("null") || branch.default !== void 0 || branch["x-prefault"] !== void 0 || branch["x-catch"] !== void 0;
@@ -2592,8 +2958,28 @@ function zodToOpenAPI(schema, meta, options) {
2592
2958
  })();
2593
2959
  const isJson = wire === void 0 || options?.json === true;
2594
2960
  const isBigintFormat = normalizeTypes(schema.type).includes("integer") && (schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint") && schema["x-coerce"] !== true;
2595
- const done = (zod, emitted, named = false) => {
2596
- const component = named && !isTriedSeveralWays;
2961
+ const isMimeAnyOf = isBinaryFile(schema) && hasMimeAlternatives(schema);
2962
+ const hasAnyOf = schema.anyOf !== void 0 && !isMimeAnyOf;
2963
+ const emittedCombinator = schema.$ref !== void 0 ? void 0 : schema.allOf !== void 0 ? "allOf" : hasAnyOf ? "anyOf" : schema.oneOf !== void 0 ? "oneOf" : void 0;
2964
+ const siblings = emittedCombinator === void 0 ? [] : [
2965
+ ...emittedCombinator === "allOf" && hasAnyOf && (schema.anyOf ?? []).length > 0 ? ["anyOf"] : [],
2966
+ ...emittedCombinator !== "oneOf" && schema.oneOf !== void 0 && schema.oneOf.length > 0 ? ["oneOf"] : [],
2967
+ ...schema.not === void 0 ? [] : ["not"]
2968
+ ];
2969
+ const parentStrict = emittedCombinator === void 0 ? void 0 : makeParentStrictCheck(schema);
2970
+ const isWrapped = siblings.length > 0 || parentStrict !== void 0;
2971
+ const withSiblings = (zod) => {
2972
+ if (!isWrapped) return zod;
2973
+ const checked = withRawCheck(withRawCheck(zod, makeSiblingCombinatorCheck(schema, siblings, (s) => zodToOpenAPI(s, void 0, childOptions))), parentStrict);
2974
+ const stated = [...siblings.flatMap((key) => {
2975
+ const list = key === "not" ? void 0 : schema[key];
2976
+ return list === void 0 ? [] : [`${key}:${schemaList(list, childOptions?.schemas)}`];
2977
+ }), ...parentStrict === void 0 ? [] : ["additionalProperties:false"]];
2978
+ return stated.length === 0 ? checked : `${checked}.openapi({${stated.join(",")}})`;
2979
+ };
2980
+ const done = (emittedZod, emitted, isNamed = false) => {
2981
+ const zod = withSiblings(emittedZod);
2982
+ const component = isNamed && !isWrapped && !isTriedSeveralWays;
2597
2983
  const isFormArray = effective?.form === true && normalizeTypes(emitted.type).includes("array");
2598
2984
  const nullInside = nullRead === "last" && wire !== void 0 && emitted.nullable !== true && !normalizeTypes(emitted.type).includes("null");
2599
2985
  const around = wire !== void 0 ? (core) => wire(core, component, nullInside) : isFormArray ? (core) => `z.preprocess(${FORM_ARITY},${core})` : void 0;
@@ -2610,6 +2996,15 @@ function zodToOpenAPI(schema, meta, options) {
2610
2996
  };
2611
2997
  const child = (s) => childOptions?.coerce !== true && isRefOnly(s) ? makeRef(s.$ref ?? "") : zodToOpenAPI(s, void 0, childOptions);
2612
2998
  const referenced = (s) => childOptions?.coerce !== true && s.$ref ? makeRef(s.$ref) : zodToOpenAPI(s, void 0, childOptions);
2999
+ const intersected = (branch, shapeZ) => {
3000
+ const branchZ = child(branch);
3001
+ const isAsked = isAskedOperand(branch, childOptions?.schemas);
3002
+ const operand = isAsked ? "Operand" : branchZ;
3003
+ return withRawCheck(`${operand}.and(${shapeZ})`, makeStrictOperandCheck([{
3004
+ schema: branch,
3005
+ zod: operand
3006
+ }], childOptions?.schemas), isAsked ? [`const Operand=${branchZ};`] : []);
3007
+ };
2613
3008
  const conformMerged = (coreSchema, shapeSchema, value) => {
2614
3009
  const core = conformDefault(coreSchema, value, childOptions?.schemas);
2615
3010
  const shape = conformDefault(shapeSchema, value, childOptions?.schemas);
@@ -2638,23 +3033,32 @@ function zodToOpenAPI(schema, meta, options) {
2638
3033
  type: rest.length === 0 ? first : [first, ...rest]
2639
3034
  };
2640
3035
  if (canAdmitNullOrUndefined(coreSchema, childOptions?.schemas)) return null;
2641
- const andZ = `${child(coreSchema)}.and(${shapeZ})`;
3036
+ const andZ = intersected(coreSchema, shapeZ);
2642
3037
  const distributed = shapeHasProperties ? andZ : `${andZ}.superRefine(${shapeRefine})`;
2643
3038
  const mergedDefault = branch.default === void 0 ? void 0 : conformMerged(coreSchema, shapeSchema, branch.default);
2644
3039
  const mergedPrefault = branch["x-prefault"] === void 0 ? void 0 : conformMerged(coreSchema, shapeSchema, branch["x-prefault"]);
2645
3040
  const defaultIsNull = mergedDefault !== void 0 && mergedDefault.ok && mergedDefault.value === null;
2646
3041
  const nullable = branch.nullable === true || normalizeTypes(branch.type).includes("null") || defaultIsNull;
3042
+ const literalOf = (value) => valueLiteral({ allOf: [coreSchema, shapeSchema] }, value, childOptions?.schemas);
2647
3043
  let out = distributed;
2648
3044
  if (nullable) out = `${out}.nullable()`;
2649
- if (mergedDefault?.ok) out = `${out}.default(${JSON.stringify(mergedDefault.value)})`;
2650
- if (mergedPrefault?.ok) out = `${out}.prefault(${JSON.stringify(mergedPrefault.value)})`;
3045
+ if (mergedDefault?.ok) {
3046
+ const literal = literalOf(mergedDefault.value);
3047
+ out = `${out}.default(${literal.code})`;
3048
+ if (literal.bigint) out = `${out}.openapi({default:${JSON.stringify(mergedDefault.value)}})`;
3049
+ }
3050
+ if (mergedPrefault?.ok) {
3051
+ const literal = literalOf(mergedPrefault.value);
3052
+ out = `${out}.prefault(${literal.code})`;
3053
+ if (literal.bigint && !mergedDefault?.ok) out = `${out}.openapi({default:${JSON.stringify(mergedPrefault.value)}})`;
3054
+ }
2651
3055
  return out;
2652
3056
  };
2653
3057
  const distribute = (branch, shapeZ, shapeRefine, shapeHasProperties, shapeSchema) => {
2654
3058
  if (shapeRefine === void 0) return child(branch);
2655
3059
  if (requiresObject(branch, childOptions?.schemas)) {
2656
3060
  if (canAdmitNullOrUndefined(branch, childOptions?.schemas) || hasOwnWrapping(branch)) return distributeAdmitting(branch, shapeZ, shapeRefine, shapeHasProperties, shapeSchema);
2657
- const andZ = `${child(branch)}.and(${shapeZ})`;
3061
+ const andZ = intersected(branch, shapeZ);
2658
3062
  return shapeHasProperties ? andZ : `${andZ}.superRefine(${shapeRefine})`;
2659
3063
  }
2660
3064
  if (!canAcceptObject(branch, childOptions?.schemas)) return child(branch);
@@ -2665,7 +3069,7 @@ function zodToOpenAPI(schema, meta, options) {
2665
3069
  if (parts.some((part) => part === null)) return null;
2666
3070
  const message = branch["x-implication-message"] ?? branch["x-anyOf-message"] ?? branch["x-error-message"];
2667
3071
  const branchUnevalCheck = makeUnevaluatedPropertiesCheck(branch, (s) => zodToOpenAPI(s, void 0, childOptions), branch["x-error-message"], childOptions?.schemas, { anyOf: true });
2668
- return wrap(withUnevaluatedCheck(`z.union([${parts.join(",")}]${message ? `,${error(message)}` : ""})`, branchUnevalCheck), branch, void 0, childOptions?.schemas === void 0 ? {} : { schemas: childOptions.schemas });
3072
+ return wrap(withRawCheck(`z.union([${parts.join(",")}]${message ? `,${error(message)}` : ""})`, branchUnevalCheck), branch, void 0, childOptions?.schemas === void 0 ? {} : { schemas: childOptions.schemas });
2669
3073
  }
2670
3074
  if (branch.oneOf !== void 0) {
2671
3075
  if (branch.oneOf.length === 0) return child(branch);
@@ -2673,7 +3077,7 @@ function zodToOpenAPI(schema, meta, options) {
2673
3077
  if (parts.some((part) => part === null)) return null;
2674
3078
  const message = branch["x-oneOf-message"] ?? branch["x-error-message"];
2675
3079
  const branchUnevalCheck = makeUnevaluatedPropertiesCheck(branch, (s) => zodToOpenAPI(s, void 0, childOptions), branch["x-error-message"], childOptions?.schemas, { oneOf: true });
2676
- return wrap(withUnevaluatedCheck(`z.xor([${parts.join(",")}]${message ? `,${error(message)}` : ""})`, branchUnevalCheck), branch, void 0, childOptions?.schemas === void 0 ? {} : { schemas: childOptions.schemas });
3080
+ return wrap(withRawCheck(`z.xor([${parts.join(",")}]${message ? `,${error(message)}` : ""})`, branchUnevalCheck), branch, void 0, childOptions?.schemas === void 0 ? {} : { schemas: childOptions.schemas });
2677
3081
  }
2678
3082
  if (normalizeTypes(branch.type).filter((type) => type !== "null").length > 1) return null;
2679
3083
  return emitsStrippingObject(branch, childOptions?.schemas) ? null : `${child(branch)}.superRefine(${shapeRefine})`;
@@ -2703,6 +3107,10 @@ function zodToOpenAPI(schema, meta, options) {
2703
3107
  }
2704
3108
  return done(makeRef(schema.$ref), schema, true);
2705
3109
  }
3110
+ if (!isMimeAnyOf) {
3111
+ const narrowed = narrowToDeclaredType(schema, options?.schemas);
3112
+ if (narrowed !== schema) return zodToOpenAPI(narrowed, meta, options);
3113
+ }
2706
3114
  if (schema.allOf !== void 0) {
2707
3115
  const hasShape = schema.properties !== void 0 && Object.keys(schema.properties).length > 0 || Array.isArray(schema.required) && schema.required.length > 0;
2708
3116
  const objectOnly = normalizeTypes(schema.type).includes("object") && normalizeTypes(schema.type).every((type) => type === "object" || type === "null");
@@ -2737,7 +3145,10 @@ function zodToOpenAPI(schema, meta, options) {
2737
3145
  const isBareRef = schemas.length === 1 && members.every(isRefOnly) && Object.keys(schema).every((k) => k === "allOf" || k === "nullable" || k === "type");
2738
3146
  const [only] = schemas;
2739
3147
  if (isBareRef && only !== void 0) return done(only, emitted, true);
2740
- const z = schemas.reduce((acc, s, i) => i === 0 ? s : `${acc}.and(${s})`);
3148
+ const isAsked = members.map((member) => schemas.length > 1 && isAskedOperand(member, childOptions?.schemas));
3149
+ const operands = schemas.map((s, index) => isAsked[index] === true ? `Member${index}` : s);
3150
+ const declarations = schemas.flatMap((s, index) => isAsked[index] === true ? [`const Member${index}=${s};`] : []);
3151
+ const z = operands.reduce((acc, s, i) => i === 0 ? s : `${acc}.and(${s})`);
2741
3152
  const shaped = (() => {
2742
3153
  if (shapeSchema === void 0 || shapeMember) return z;
2743
3154
  if (members.some((member) => !canAcceptObject(member, childOptions?.schemas))) return z;
@@ -2747,23 +3158,27 @@ function zodToOpenAPI(schema, meta, options) {
2747
3158
  if (member === void 0) continue;
2748
3159
  const distributed = distribute(member, shapeZ, shapeRefine, schema.properties !== void 0, shapeSchema);
2749
3160
  if (distributed === null || distributed === schemas[index]) continue;
2750
- return schemas.map((s, position) => position === index ? distributed : s).reduce((acc, s, i) => i === 0 ? s : `${acc}.and(${s})`);
3161
+ return operands.map((s, position) => position === index ? distributed : s).reduce((acc, s, i) => i === 0 ? s : `${acc}.and(${s})`);
2751
3162
  }
2752
- return shapeCheck === void 0 ? z : `z.unknown().check(${shapeCheck}).pipe(${z})`;
3163
+ return withRawCheck(z, shapeCheck);
2753
3164
  })();
3165
+ const strictCheck = schemas.length > 1 ? makeStrictOperandCheck(members.map((member, index) => ({
3166
+ schema: member,
3167
+ zod: operands[index] ?? ""
3168
+ })), childOptions?.schemas) : void 0;
2754
3169
  const allOfMessage = schema["x-allOf-message"] ?? schema["x-error-message"];
2755
3170
  const unevalCheck = makeUnevaluatedPropertiesCheck({
2756
3171
  ...schema,
2757
3172
  allOf: effectiveAllOf
2758
3173
  }, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"], childOptions?.schemas, {});
2759
- if (allOfMessage || unevalCheck) return done(`(()=>{const Schema=${shaped};return z.unknown().check((ctx)=>{${(() => {
3174
+ if (allOfMessage || unevalCheck) return done(withRawCheck(withRawStatements(shaped, `${(() => {
2760
3175
  const isArrow = allOfMessage ? ARROW_FUNCTION_PATTERN.test(allOfMessage) : false;
2761
3176
  const msgExpr = allOfMessage ? isArrow ? `(${allOfMessage})(issue)` : JSON.stringify(allOfMessage) : void 0;
2762
3177
  return `const result=Schema.safeParse(ctx.value);if(!result.success){for(const issue of result.error.issues){${makeIssueForwarding(msgExpr ? `{...issue,input:issue.input,message:${msgExpr}}` : "{...issue,input:issue.input}")}}}`;
2763
- })()}${unevalCheck ? `;(${unevalCheck})(ctx)` : ""}}).pipe(Schema)})()`, emitted);
2764
- return done(shaped, emitted, schemas.length === 1 && members.every(isRefOnly));
3178
+ })()}${unevalCheck ? `;(${unevalCheck})(ctx)` : ""}`), strictCheck, declarations), emitted);
3179
+ return done(withRawCheck(shaped, strictCheck, declarations), emitted, schemas.length === 1 && members.every(isRefOnly));
2765
3180
  }
2766
- if (schema.anyOf !== void 0 && !(isBinaryFile(schema) && hasMimeAlternatives(schema))) {
3181
+ if (schema.anyOf !== void 0 && !isMimeAnyOf) {
2767
3182
  if (schema.anyOf.length === 0) return done("z.any()", schema);
2768
3183
  const anyOfSchemas = schema.anyOf.map(child);
2769
3184
  const anyOfMessage = schema["x-implication-message"] ?? schema["x-anyOf-message"] ?? schema["x-error-message"];
@@ -2780,21 +3195,24 @@ function zodToOpenAPI(schema, meta, options) {
2780
3195
  const branchesRequireObject = schema.anyOf.every((branch) => requiresObject(branch, childOptions?.schemas));
2781
3196
  const branchesAdmitNullOrUndefined = (schema.type === void 0 || normalizeTypes(schema.type).includes("null")) && schema.anyOf.some((branch) => canAdmitNullOrUndefined(branch, childOptions?.schemas) || hasOwnWrapping(branch));
2782
3197
  if ((objectOnly || branchesRequireObject) && !branchesAdmitNullOrUndefined) {
2783
- const andZ = `${unionZ}.and(${zodToOpenAPI(shapeSchema, void 0, childOptions)})`;
2784
- if (schema.properties === void 0) {
2785
- const shapeCheck = emitObjectShapeCheck(shapeSchema, child);
2786
- return done(withUnevaluatedCheck(shapeCheck === void 0 ? andZ : `z.unknown().check(${shapeCheck}).pipe(${andZ})`, unevalCheck), schema);
2787
- }
2788
- return done(withUnevaluatedCheck(andZ, unevalCheck), schema);
3198
+ const shapeZ = zodToOpenAPI(shapeSchema, void 0, childOptions);
3199
+ const union = { anyOf: schema.anyOf };
3200
+ const isAsked = isAskedOperand(union, childOptions?.schemas);
3201
+ const operand = isAsked ? "Operand" : unionZ;
3202
+ const andZ = withRawCheck(`${operand}.and(${shapeZ})`, makeStrictOperandCheck([{
3203
+ schema: union,
3204
+ zod: operand
3205
+ }], childOptions?.schemas), isAsked ? [`const Operand=${unionZ};`] : []);
3206
+ if (schema.properties === void 0) return done(withRawCheck(withRawCheck(andZ, emitObjectShapeCheck(shapeSchema, child)), unevalCheck), schema);
3207
+ return done(withRawCheck(andZ, unevalCheck), schema);
2789
3208
  }
2790
3209
  const shapeZ = zodToOpenAPI(shapeSchema, void 0, childOptions);
2791
3210
  const shapeRefine = emitObjectShapeRefine(shapeSchema, child);
2792
3211
  const distributed = schema.anyOf.map((branch) => distribute(branch, shapeZ, shapeRefine, schema.properties !== void 0, shapeSchema));
2793
- if (!distributed.some((part) => part === null)) return done(withUnevaluatedCheck(`z.union([${distributed.join(",")}]${anyOfErrorArg})`, unevalCheck), schema);
2794
- const shapeCheck = emitObjectShapeCheck(shapeSchema, child);
2795
- return done(withUnevaluatedCheck(shapeCheck === void 0 ? unionZ : `z.unknown().check(${shapeCheck}).pipe(${unionZ})`, unevalCheck), schema);
3212
+ if (!distributed.some((part) => part === null)) return done(withRawCheck(`z.union([${distributed.join(",")}]${anyOfErrorArg})`, unevalCheck), schema);
3213
+ return done(withRawCheck(withRawCheck(unionZ, emitObjectShapeCheck(shapeSchema, child)), unevalCheck), schema);
2796
3214
  }
2797
- return done(withUnevaluatedCheck(unionZ, unevalCheck), schema);
3215
+ return done(withRawCheck(unionZ, unevalCheck), schema);
2798
3216
  }
2799
3217
  if (schema.oneOf !== void 0) {
2800
3218
  if (schema.oneOf.length === 0) return done("z.any()", schema);
@@ -2814,21 +3232,27 @@ function zodToOpenAPI(schema, meta, options) {
2814
3232
  const branchesRequireObject = schema.oneOf.every((branch) => requiresObject(branch, childOptions?.schemas));
2815
3233
  const branchesAdmitNullOrUndefined = (schema.type === void 0 || normalizeTypes(schema.type).includes("null")) && schema.oneOf.some((branch) => canAdmitNullOrUndefined(branch, childOptions?.schemas) || hasOwnWrapping(branch));
2816
3234
  if ((objectOnly || branchesRequireObject) && !branchesAdmitNullOrUndefined) {
2817
- const andZ = `${z}.and(${zodToOpenAPI(shapeSchema, void 0, childOptions)})`;
2818
- if (schema.properties === void 0) {
2819
- const shapeCheck = emitObjectShapeCheck(shapeSchema, child);
2820
- return done(withUnevaluatedCheck(shapeCheck === void 0 ? andZ : `z.unknown().check(${shapeCheck}).pipe(${andZ})`, unevalCheck), schema);
2821
- }
2822
- return done(withUnevaluatedCheck(andZ, unevalCheck), schema);
3235
+ const shapeZ = zodToOpenAPI(shapeSchema, void 0, childOptions);
3236
+ const union = {
3237
+ oneOf: schema.oneOf,
3238
+ ...schema.discriminator === void 0 ? {} : { discriminator: schema.discriminator }
3239
+ };
3240
+ const isAsked = isAskedOperand(union, childOptions?.schemas);
3241
+ const operand = isAsked ? "Operand" : z;
3242
+ const andZ = withRawCheck(`${operand}.and(${shapeZ})`, makeStrictOperandCheck([{
3243
+ schema: union,
3244
+ zod: operand
3245
+ }], childOptions?.schemas), isAsked ? [`const Operand=${z};`] : []);
3246
+ if (schema.properties === void 0) return done(withRawCheck(withRawCheck(andZ, emitObjectShapeCheck(shapeSchema, child)), unevalCheck), schema);
3247
+ return done(withRawCheck(andZ, unevalCheck), schema);
2823
3248
  }
2824
3249
  const shapeZ = zodToOpenAPI(shapeSchema, void 0, childOptions);
2825
3250
  const shapeRefine = emitObjectShapeRefine(shapeSchema, child);
2826
3251
  const distributed = schema.oneOf.map((branch) => distribute(branch, shapeZ, shapeRefine, schema.properties !== void 0, shapeSchema));
2827
- if (!distributed.some((part) => part === null)) return done(withUnevaluatedCheck(`z.xor([${distributed.join(",")}]${oneOfErrorArg})`, unevalCheck), schema);
2828
- const shapeCheck = emitObjectShapeCheck(shapeSchema, child);
2829
- return done(withUnevaluatedCheck(shapeCheck === void 0 ? z : `z.unknown().check(${shapeCheck}).pipe(${z})`, unevalCheck), schema);
3252
+ if (!distributed.some((part) => part === null)) return done(withRawCheck(`z.xor([${distributed.join(",")}]${oneOfErrorArg})`, unevalCheck), schema);
3253
+ return done(withRawCheck(withRawCheck(z, emitObjectShapeCheck(shapeSchema, child)), unevalCheck), schema);
2830
3254
  }
2831
- return done(withUnevaluatedCheck(z, unevalCheck), schema);
3255
+ return done(withRawCheck(z, unevalCheck), schema);
2832
3256
  }
2833
3257
  if (schema.not !== void 0) {
2834
3258
  const notMessage = schema["x-not-message"] ?? schema["x-error-message"];
@@ -1,4 +1,4 @@
1
- import { C as isOperationLike, E as isParameterObject, G as isValidIdent, M as isRecord, N as isRefObject, X as FORM_MEDIA_TYPES, nt as JSON_MEDIA_TYPE, z as isSchemaProperty } from "./guard-Rvg4ztIZ.js";
1
+ import { B as isSchemaProperty, D as isParameterObject, K as isValidIdent, N as isRecord, P as isRefObject, Z as FORM_MEDIA_TYPES, rt as JSON_MEDIA_TYPE, w as isOperationLike } from "./guard-ngBos42D.js";
2
2
  // src/helper/group.ts
3
3
  const RESERVED = /* @__PURE__ */ new Set([
4
4
  "arguments",
@@ -1,13 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
- import { Q as HOOK_LIBRARIES, q as COMPONENT_NAMES } from "./guard-Rvg4ztIZ.js";
3
- import { C as isInsideDirectory, E as makeGeneratedImport, S as appEntryOutput, T as makeAppEntryImport, _ as headers, a as takibi, b as client, c as securitySchemes, d as requestBodies, f as pathItems, g as links, h as mediaTypes, i as defineTemplate, l as schemas, m as components, n as webhooks, o as route, p as parameters, r as template, s as mock, u as responses, v as examples, w as makeAppEntryFile, x as handlerGroupOf, y as callbacks } from "./core-CT8AnDwr.js";
4
- import { t as docs } from "./docs-DC7Q_-PY.js";
5
- import { t as hooks } from "./hooks-B2Fcpr_z.js";
2
+ import { $ as HOOK_LIBRARIES, J as COMPONENT_NAMES } from "./guard-ngBos42D.js";
3
+ import { C as appEntryOutput, D as makeGeneratedImport, E as makeAppEntryImport, S as pathGroupOf, T as makeAppEntryFile, _ as headers, a as takibi, b as client, c as securitySchemes, d as requestBodies, f as pathItems, g as links, h as mediaTypes, i as defineTemplate, l as schemas, m as components, n as webhooks, o as route, p as parameters, r as template, s as mock, u as responses, v as examples, w as isInsideDirectory, x as handlerGroupOf, y as callbacks } from "./core-D9NtmI5f.js";
4
+ import { t as docs } from "./docs-hKJj12Gm.js";
5
+ import { t as hooks } from "./hooks-CSMf3pkH.js";
6
6
  import { rpc } from "./core/rpc/index.js";
7
7
  import { type } from "./core/type/index.js";
8
8
  import { i as GenerateError } from "./format-BF7SbaMP.js";
9
9
  import { a as unlink, i as readdir, t as exists } from "./file-hO_bjDys.js";
10
- import { n as normalizeOpenAPI } from "./openapi-DWSCULWR.js";
10
+ import { n as normalizeOpenAPI } from "./openapi-CitBEjdx.js";
11
11
  import { Effect, FileSystem, Schema } from "effect";
12
12
  import path from "node:path";
13
13
  import SwaggerParser from "@apidevtools/swagger-parser";
@@ -280,7 +280,7 @@ function makeJob(openAPI, config, packageRoot = () => void 0) {
280
280
  const appOutput = appEntryOutput(config);
281
281
  const isSplit = config.template?.split === true;
282
282
  const isInline = config.template?.define === false && !config.template.routeHandler;
283
- const grouping = isSplit ? isInline ? handlerGroupOf : (endpoint) => handlerGroupOf(endpoint) : void 0;
283
+ const grouping = isSplit ? isInline ? (endpoint) => handlerGroupOf(endpoint) : (endpoint) => pathGroupOf(endpoint) : void 0;
284
284
  const generatedClient = config.client;
285
285
  const clientBarrel = (() => {
286
286
  const output = generatedClient?.output;
@@ -1,4 +1,4 @@
1
- import { K as ARROW_FUNCTION_PATTERN, et as IDENTIFIER_PATTERN } from "./guard-Rvg4ztIZ.js";
1
+ import { q as ARROW_FUNCTION_PATTERN, tt as IDENTIFIER_PATTERN } from "./guard-ngBos42D.js";
2
2
  // src/utils/index.ts
3
3
  /**
4
4
  * Normalize a JSON Schema `type` value into an array of type strings.
@@ -347,13 +347,6 @@ function uncapitalize(text) {
347
347
  return text.charAt(0).toLowerCase() + text.slice(1);
348
348
  }
349
349
  /**
350
- * Lower-cases the leading word of a PascalCase identifier, keeping an acronym whole:
351
- * `Users` → `users`, `APIKeys` → `apiKeys`, `ZodOpenAPIHono` → `zodOpenAPIHono`.
352
- */
353
- function uncapitalizeWord(text) {
354
- return text.replace(/^[A-Z]+(?=[A-Z][a-z]|[^A-Za-z]|$)|^[A-Z]/u, (m) => m.toLowerCase());
355
- }
356
- /**
357
350
  * Converts the first character of a string to uppercase.
358
351
  *
359
352
  * @example
@@ -518,4 +511,4 @@ function cyclicNodes(deps) {
518
511
  for (const node of deps.keys()) if (!indices.has(node)) connect(node);
519
512
  return result;
520
513
  }
521
- export { zodToOpenAPISchema as S, routeName as _, ensureSuffix as a, uncapitalize as b, escapeRegexLiteral as c, makeSafeKey as d, makeStringLiteral as f, requestParamsArray as g, renderNamedImport as h, decodePercent as i, makeBarrel as l, regexLiteral as m, capitalize as n, error as o, normalizeTypes as p, cyclicNodes as r, escapeHtml as s, baseError as t, makeInferRequestType as u, statusCodeToNumber as v, uncapitalizeWord as x, toIdentifierPascalCase as y };
514
+ export { routeName as _, ensureSuffix as a, uncapitalize as b, escapeRegexLiteral as c, makeSafeKey as d, makeStringLiteral as f, requestParamsArray as g, renderNamedImport as h, decodePercent as i, makeBarrel as l, regexLiteral as m, capitalize as n, error as o, normalizeTypes as p, cyclicNodes as r, escapeHtml as s, baseError as t, makeInferRequestType as u, statusCodeToNumber as v, zodToOpenAPISchema as x, toIdentifierPascalCase as y };
@@ -1,9 +1,9 @@
1
1
  import { parseConfig } from "../index.js";
2
- import { M as isRecord, tt as INPUT_EXTENSIONS } from "../guard-Rvg4ztIZ.js";
2
+ import { N as isRecord, nt as INPUT_EXTENSIONS } from "../guard-ngBos42D.js";
3
3
  import { t as FormatOptions } from "../format-BF7SbaMP.js";
4
- import { C as isInsideDirectory, S as appEntryOutput } from "../core-CT8AnDwr.js";
4
+ import { C as appEntryOutput, w as isInsideDirectory } from "../core-D9NtmI5f.js";
5
5
  import { n as parseOpenAPI } from "../openapi-BxSVfs_l.js";
6
- import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BmIHrl_h.js";
6
+ import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-DJ1zD5Rg.js";
7
7
  import { Effect, FileSystem, Option, Result } from "effect";
8
8
  import path from "node:path";
9
9
  import crypto from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.32.6",
3
+ "version": "0.33.0",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",