hono-takibi 0.9.99991 → 0.9.99992

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -163,7 +163,7 @@ function makeParameterSchema(parameter) {
163
163
  }
164
164
  function makeSchemaTypeString(schema, components, visited) {
165
165
  if (!schema) return "unknown";
166
- if (schema.$ref) return visited.has(schema.$ref) ? "unknown" : makeRefTypeString(schema.$ref, components, new Set([...visited, schema.$ref]));
166
+ if (schema.$ref) return visited.has(schema.$ref) ? "unknown" : makeRefTypeString(schema.$ref, components, /* @__PURE__ */ new Set([...visited, schema.$ref]));
167
167
  if (schema.oneOf && schema.oneOf.length > 0) return schema.oneOf.map((s) => makeSchemaTypeString(s, components, visited)).join("|");
168
168
  if (schema.anyOf && schema.anyOf.length > 0) return schema.anyOf.map((s) => makeSchemaTypeString(s, components, visited)).join("|");
169
169
  if (schema.allOf && schema.allOf.length > 0) return makeAllOfTypeString(schema.allOf, components, visited);
@@ -228,7 +228,7 @@ function makeAllOfTypeString(allOf, components, visited) {
228
228
  }
229
229
  function makePropertyMap(schema, components, visited) {
230
230
  if (schema.$ref && visited.has(schema.$ref)) return /* @__PURE__ */ new Map();
231
- const nextVisited = schema.$ref ? new Set([...visited, schema.$ref]) : visited;
231
+ const nextVisited = schema.$ref ? /* @__PURE__ */ new Set([...visited, schema.$ref]) : visited;
232
232
  const resolved = makeResolvedSchema(schema, components);
233
233
  const fromAllOf = new Map(resolved.allOf && resolved.allOf.length > 0 ? resolved.allOf.flatMap((subSchema) => [...makePropertyMap(subSchema, components, nextVisited).entries()]) : []);
234
234
  if (!resolved.properties) return fromAllOf;
@@ -1,2 +1,2 @@
1
- import { t as zodOpenAPIHono } from "../../../openapi-Lc8kequ9.js";
1
+ import { t as zodOpenAPIHono } from "../../../openapi-8ZYAMj_e.js";
2
2
  export { zodOpenAPIHono };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { readConfig } from "./config/index.js";
3
3
  import { r as setFormatOptions } from "./emit-CFR63U4L.js";
4
- import { n as parseOpenAPI, r as takibi, t as makeJob } from "./shared-B8mI7vUM.js";
4
+ import { n as parseOpenAPI, r as takibi, t as makeJob } from "./shared-DRGflwP5.js";
5
5
  import { existsSync } from "node:fs";
6
6
  import { resolve } from "node:path";
7
7
  //#region src/cli/index.ts
@@ -47,7 +47,7 @@ function makeImports(code, fromFile, components, split = false, honoExtras = [])
47
47
  const grouped = Array.from(code.matchAll(SCAN), (m) => m[1]).filter((name) => Boolean(name) && !defined.has(name)).reduce((acc, name) => {
48
48
  const kind = classifyRef(name);
49
49
  if (!kind) return acc;
50
- return new Map(acc).set(kind, new Set([...acc.get(kind) ?? [], name]));
50
+ return new Map(acc).set(kind, /* @__PURE__ */ new Set([...acc.get(kind) ?? [], name]));
51
51
  }, /* @__PURE__ */ new Map());
52
52
  const needsCreateRoute = code.includes("createRoute(");
53
53
  const needsZ = code.includes("z.");
@@ -358,7 +358,7 @@ function makePathItem(pathItem) {
358
358
  //#endregion
359
359
  //#region src/helper/wrap.ts
360
360
  function wrap(zod, schema, meta, options) {
361
- const unsupportedProps = new Set([
361
+ const unsupportedProps = /* @__PURE__ */ new Set([
362
362
  "$recursiveRef",
363
363
  "$recursiveAnchor",
364
364
  "optional",
@@ -395,7 +395,8 @@ function wrap(zod, schema, meta, options) {
395
395
  if (typeof v === "string") return JSON.stringify(v);
396
396
  return JSON.stringify(v);
397
397
  };
398
- const n = schema.nullable === true || (Array.isArray(schema.type) ? schema.type.includes("null") : schema.type === "null") ? `${zod}.nullable()` : zod;
398
+ const isNullable = schema.nullable === true || (Array.isArray(schema.type) ? schema.type.includes("null") : schema.type === "null");
399
+ const n = isNullable ? `${zod}.nullable()` : zod;
399
400
  const d = schema.default !== void 0 ? `${n}.default(${formatLiteral(schema.default)})` : n;
400
401
  const pf = schema["x-prefault"] !== void 0 ? `${d}.prefault(${formatLiteral(schema["x-prefault"])})` : d;
401
402
  const c = schema["x-catch"] !== void 0 ? `${pf}.catch(${formatLiteral(schema["x-catch"])})` : pf;
@@ -406,7 +407,7 @@ function wrap(zod, schema, meta, options) {
406
407
  const codec = schema["x-codec"];
407
408
  const replaced = preprocess ?? transform ?? pipe ?? codec ?? superRefineChain;
408
409
  const z = schema["x-brand"] ? `${replaced}.brand<"${schema["x-brand"]}">()` : replaced;
409
- const zodExpressedProps = new Set([
410
+ const zodExpressedProps = /* @__PURE__ */ new Set([
410
411
  "type",
411
412
  "format",
412
413
  "default",
@@ -556,9 +557,12 @@ function wrap(zod, schema, meta, options) {
556
557
  return `${JSON.stringify(key)}:${JSON.stringify(value)}`;
557
558
  }).join(",")}}`;
558
559
  };
560
+ const typeList = Array.isArray(schema.type) ? schema.type : schema.type !== void 0 ? [schema.type] : [];
561
+ const fileMetaProps = schema.format === "binary" && typeList.includes("string") && schema.contentEncoding === void 0 && schema.contentMediaType === void 0 && schema.contentSchema === void 0 && schema["x-codec"] === void 0 ? [isNullable ? "type:[\"string\",\"null\"]" : "type:\"string\"", "format:\"binary\""] : [];
559
562
  const result = [
560
563
  meta?.parameters ? `param:${serializeParam(meta.parameters)}` : void 0,
561
564
  ...headerMetaProps,
565
+ ...fileMetaProps,
562
566
  openapiSchemaBody && openapiSchemaBody.length > 0 ? openapiSchemaBody : void 0
563
567
  ].filter((v) => v !== void 0);
564
568
  if (meta?.parameters || meta?.headers) {
@@ -1220,12 +1224,12 @@ const FORMAT_STRING = {
1220
1224
  toUpperCase: "toUpperCase()",
1221
1225
  trim: "trim()"
1222
1226
  };
1223
- const TRANSFORM_FORMATS = new Set([
1227
+ const TRANSFORM_FORMATS = /* @__PURE__ */ new Set([
1224
1228
  "toLowerCase",
1225
1229
  "toUpperCase",
1226
1230
  "trim"
1227
1231
  ]);
1228
- const DATE_FORMATS = new Set(["date", "date-time"]);
1232
+ const DATE_FORMATS = /* @__PURE__ */ new Set(["date", "date-time"]);
1229
1233
  const EMAIL_PATTERN_PRESET = {
1230
1234
  html5: "html5Email",
1231
1235
  rfc5322: "rfc5322Email",
@@ -1670,7 +1674,7 @@ function tarjanConnect(name, deps, var2name, state) {
1670
1674
  const indices = new Map(state.indices).set(name, currentIndex);
1671
1675
  const lowLinks = new Map(state.lowLinks).set(name, currentIndex);
1672
1676
  const stack = [...state.stack, name];
1673
- const onStack = new Set([...state.onStack, name]);
1677
+ const onStack = /* @__PURE__ */ new Set([...state.onStack, name]);
1674
1678
  const initialState = {
1675
1679
  ...state,
1676
1680
  indices,
@@ -1734,7 +1738,7 @@ function analyzeCircularSchemas(schemas, schemaNames, readonly) {
1734
1738
  return [n, extractIdentifiers(code, varNameSet).filter((v) => v !== selfVar)];
1735
1739
  }));
1736
1740
  const cyclicSchemas = findCyclicSchemas(schemaNames, depsMap);
1737
- const extendedCyclicSchemas = new Set([...cyclicSchemas, ...[...cyclicSchemas].flatMap((n) => (depsMap.get(n) ?? []).map((v) => varNameToName.get(v)).filter((x) => x !== void 0))]);
1741
+ const extendedCyclicSchemas = /* @__PURE__ */ new Set([...cyclicSchemas, ...[...cyclicSchemas].flatMap((n) => (depsMap.get(n) ?? []).map((v) => varNameToName.get(v)).filter((x) => x !== void 0))]);
1738
1742
  return {
1739
1743
  zSchemaMap,
1740
1744
  depsMap,
@@ -1801,12 +1805,12 @@ function topoSort(decls) {
1801
1805
  if (!decl) return state;
1802
1806
  const withTemp = {
1803
1807
  ...state,
1804
- temp: new Set([...state.temp, key])
1808
+ temp: /* @__PURE__ */ new Set([...state.temp, key])
1805
1809
  };
1806
1810
  const afterRefs = decl.refs.map((ref) => findByName(ref)).filter((d) => d !== void 0).reduce((s, d) => visit(makeKey(d.kind, d.name), s), withTemp);
1807
1811
  return {
1808
1812
  sorted: [...afterRefs.sorted, decl],
1809
- perm: new Set([...afterRefs.perm, key]),
1813
+ perm: /* @__PURE__ */ new Set([...afterRefs.perm, key]),
1810
1814
  temp: new Set([...afterRefs.temp].filter((t) => t !== key))
1811
1815
  };
1812
1816
  };
@@ -1,7 +1,7 @@
1
1
  import { n as fmt, t as emit } from "./emit-CFR63U4L.js";
2
2
  import { a as writeFile, i as unlink, n as readFile, r as readdir, t as mkdir } from "./fsp-BXry-Hx5.js";
3
3
  import { I as statusCodeToNumber, L as toIdentifierPascalCase, M as methodPath, O as escapeRegexLiteral, P as renderNamedImport, R as uncapitalize, T as ensureSuffix, b as isSecurityScheme, i as isMediaWithSchema, k as makeBarrel, l as isParameter, n as isHttpMethod, p as isRefObject, s as isOperation, t as isContentBody, y as isSecurityArray, z as zodToOpenAPISchema } from "./guard-zvkMUVYD.js";
4
- import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-Lc8kequ9.js";
4
+ import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-8ZYAMj_e.js";
5
5
  import { t as hooks } from "./hooks-CkiatAe9.js";
6
6
  import { t as docs } from "./docs-380Wcu6a.js";
7
7
  import { rpc } from "./core/rpc/index.js";
@@ -560,6 +560,40 @@ const PROPERTY_NAME_TO_FAKER = {
560
560
  count: "faker.number.int({ min: 0, max: 1000 })",
561
561
  age: "faker.number.int({ min: 1, max: 120 })"
562
562
  };
563
+ const hasNumericConstraint = (schema) => schema.minimum !== void 0 || schema.maximum !== void 0 || schema.exclusiveMinimum !== void 0 || schema.exclusiveMaximum !== void 0 || schema.multipleOf !== void 0;
564
+ function numericRange(schema, integer) {
565
+ const step = integer ? 1 : 0;
566
+ const min = typeof schema.exclusiveMinimum === "number" ? schema.exclusiveMinimum + step : schema.exclusiveMinimum === true && schema.minimum !== void 0 ? schema.minimum + step : schema.minimum;
567
+ const max = typeof schema.exclusiveMaximum === "number" ? schema.exclusiveMaximum - step : schema.exclusiveMaximum === true && schema.maximum !== void 0 ? schema.maximum - step : schema.maximum;
568
+ return {
569
+ ...min !== void 0 ? { min } : {},
570
+ ...max !== void 0 ? { max } : {},
571
+ ...schema.multipleOf !== void 0 ? { multipleOf: schema.multipleOf } : {}
572
+ };
573
+ }
574
+ function numericFaker(schema, range) {
575
+ if (schema.type === "integer" && (schema.format === "int64" || schema.format === "bigint")) return `faker.number.bigInt({ min: ${range.min ?? 0}n, max: ${range.max ?? 9007199254740991}n })`;
576
+ if (schema.type === "integer") {
577
+ const defaultMin = schema.format === "int32" ? -2147483648 : 1;
578
+ const defaultMax = schema.format === "int32" ? 2147483647 : 1e3;
579
+ return `faker.number.int({ ${[
580
+ `min: ${range.min ?? defaultMin}`,
581
+ `max: ${range.max ?? defaultMax}`,
582
+ ...range.multipleOf !== void 0 ? [`multipleOf: ${range.multipleOf}`] : []
583
+ ].join(", ")} })`;
584
+ }
585
+ const defaultMax = schema.format === "double" ? 1e6 : 1e3;
586
+ const fractionDigits = schema.format === "double" ? 4 : 2;
587
+ return `faker.number.float({ ${(range.multipleOf !== void 0 ? [
588
+ `min: ${range.min ?? 1}`,
589
+ `max: ${range.max ?? defaultMax}`,
590
+ `multipleOf: ${range.multipleOf}`
591
+ ] : [
592
+ `min: ${range.min ?? 1}`,
593
+ `max: ${range.max ?? defaultMax}`,
594
+ `fractionDigits: ${fractionDigits}`
595
+ ]).join(", ")} })`;
596
+ }
563
597
  function schemaToFaker(schema, propertyName, options = {}) {
564
598
  if (options.useExamples && schema.example !== void 0) return JSON.stringify(schema.example);
565
599
  if (schema.const !== void 0) return `${JSON.stringify(schema.const)} as const`;
@@ -588,6 +622,7 @@ function schemaToFaker(schema, propertyName, options = {}) {
588
622
  }
589
623
  const union = schema.oneOf && schema.oneOf.length > 0 ? schema.oneOf : schema.anyOf && schema.anyOf.length > 0 ? schema.anyOf : void 0;
590
624
  if (union) return `faker.helpers.arrayElement([${union.map((s) => schemaToFaker(s, propertyName, options)).join(", ")}])`;
625
+ if ((schema.type === "integer" || schema.type === "number") && hasNumericConstraint(schema)) return numericFaker(schema, numericRange(schema, schema.type === "integer"));
591
626
  if (schema.format && FORMAT_TO_FAKER[schema.format]) return FORMAT_TO_FAKER[schema.format];
592
627
  if (propertyName && PROPERTY_NAME_TO_FAKER[propertyName]) {
593
628
  const hint = PROPERTY_NAME_TO_FAKER[propertyName];
@@ -598,12 +633,7 @@ function schemaToFaker(schema, propertyName, options = {}) {
598
633
  if (schema.pattern) return `faker.helpers.fromRegExp(/${escapeRegexLiteral(schema.pattern)}/)`;
599
634
  return `faker.string.alpha({ length: { min: ${schema.minLength ?? 5}, max: ${schema.maxLength ?? 20} } })`;
600
635
  }
601
- if (schema.type === "integer" || schema.type === "number") {
602
- const min = schema.minimum ?? 1;
603
- const max = schema.maximum ?? 1e3;
604
- if (schema.type === "integer") return `faker.number.int({ min: ${min}, max: ${max} })`;
605
- return `faker.number.float({ min: ${min}, max: ${max}, fractionDigits: 2 })`;
606
- }
636
+ if (schema.type === "integer" || schema.type === "number") return numericFaker(schema, numericRange(schema, schema.type === "integer"));
607
637
  return TYPE_TO_FAKER[schema.type];
608
638
  }
609
639
  return "undefined";
@@ -1115,7 +1145,7 @@ function extractTestCases(spec) {
1115
1145
  } : void 0;
1116
1146
  const bodyRefs = jsonBodySchema ? collectSchemaRefs(jsonBodySchema, spec.components?.schemas) : [];
1117
1147
  const paramRefs = resolvedParams.flatMap((p) => collectSchemaRefs(p.schema, spec.components?.schemas));
1118
- const usedSchemaRefs = [...new Set([...bodyRefs, ...paramRefs])];
1148
+ const usedSchemaRefs = [.../* @__PURE__ */ new Set([...bodyRefs, ...paramRefs])];
1119
1149
  const responseKeys = Object.keys(operation.responses || {});
1120
1150
  const successStatus = responseKeys.filter((s) => s.startsWith("2")).map((s) => Number.parseInt(s, 10)).toSorted((a, b) => a - b)[0] ?? 200;
1121
1151
  const errorStatuses = responseKeys.filter((s) => (s.startsWith("4") || s.startsWith("5")) && s !== "default").map((s) => Number.parseInt(s, 10)).toSorted((a, b) => a - b);
@@ -1177,7 +1207,7 @@ function topologicalOrder(usedSchemaNames, schemas) {
1177
1207
  if (visited.has(name) || !usedSchemaNames.has(name) || visiting.has(name)) return [];
1178
1208
  const nextVisiting = new Set(visiting).add(name);
1179
1209
  const schema = schemas[name];
1180
- const depOrder = schema ? collectSchemaRefs(schema, schemas, new Set([name])).flatMap((dep) => {
1210
+ const depOrder = schema ? collectSchemaRefs(schema, schemas, /* @__PURE__ */ new Set([name])).flatMap((dep) => {
1181
1211
  const subOrder = visit(dep, visited, nextVisiting);
1182
1212
  for (const n of subOrder) visited.add(n);
1183
1213
  return subOrder;
@@ -1778,7 +1808,7 @@ function extractMockFunctions(file, code) {
1778
1808
  * Returns a map of route identifier (e.g., "GET /users") to block info
1779
1809
  * including text and source positions for removal.
1780
1810
  */
1781
- const DESCRIBE_MODIFIERS = new Set([
1811
+ const DESCRIBE_MODIFIERS = /* @__PURE__ */ new Set([
1782
1812
  "skip",
1783
1813
  "only",
1784
1814
  "skipIf",
@@ -1843,7 +1873,7 @@ function mergeTestFile(existingCode, generatedCode) {
1843
1873
  * `vite-plus/test`) would leave duplicate framework imports.
1844
1874
  */
1845
1875
  function filterTestFrameworkImports(mergedImports, generatedFile) {
1846
- const TEST_FRAMEWORK_MODULES = new Set([
1876
+ const TEST_FRAMEWORK_MODULES = /* @__PURE__ */ new Set([
1847
1877
  "vitest",
1848
1878
  "bun:test",
1849
1879
  "vite-plus/test"
@@ -1966,9 +1996,9 @@ function makeMergedHandlers(handlers) {
1966
1996
  if (existing) handlerMap.set(handler.fileName, {
1967
1997
  ...handler,
1968
1998
  contents: [...existing.contents, ...handler.contents],
1969
- routeNames: Array.from(new Set([...existing.routeNames, ...handler.routeNames])),
1999
+ routeNames: Array.from(/* @__PURE__ */ new Set([...existing.routeNames, ...handler.routeNames])),
1970
2000
  needsFaker: existing.needsFaker || handler.needsFaker,
1971
- usedRefs: new Set([...existing.usedRefs, ...handler.usedRefs])
2001
+ usedRefs: /* @__PURE__ */ new Set([...existing.usedRefs, ...handler.usedRefs])
1972
2002
  });
1973
2003
  else handlerMap.set(handler.fileName, handler);
1974
2004
  }
@@ -1,7 +1,7 @@
1
1
  import { parseConfig } from "../config/index.js";
2
2
  import { r as setFormatOptions } from "../emit-CFR63U4L.js";
3
3
  import { f as isRecord } from "../guard-zvkMUVYD.js";
4
- import { n as parseOpenAPI, t as makeJob } from "../shared-B8mI7vUM.js";
4
+ import { n as parseOpenAPI, t as makeJob } from "../shared-DRGflwP5.js";
5
5
  import path from "node:path";
6
6
  import fsp from "node:fs/promises";
7
7
  //#region src/vite-plugin/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.9.99991",
3
+ "version": "0.9.99992",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",
@@ -53,24 +53,21 @@
53
53
  "import": "./dist/core/docs/index.js"
54
54
  }
55
55
  },
56
- "publishConfig": {
57
- "access": "public"
58
- },
59
56
  "dependencies": {
60
57
  "@apidevtools/swagger-parser": "^12.1.0",
61
58
  "@typespec/compiler": "^1.13.0",
62
59
  "@typespec/openapi3": "^1.13.0",
63
- "oxfmt": "^0.54.0",
60
+ "oxfmt": "^0.56.0",
64
61
  "ts-morph": "^28.0.0",
65
62
  "typescript": "^6.0.3",
66
63
  "zod": "^4.4.3"
67
64
  },
68
65
  "devDependencies": {
69
- "@types/node": "^25.9.3",
66
+ "@types/node": "^26.0.0",
70
67
  "@typespec/http": "^1.13.0",
71
68
  "@typespec/rest": "^0.83.0",
72
69
  "@typespec/versioning": "^0.83.0",
73
- "tsdown": "0.22.2"
70
+ "tsdown": "0.22.3"
74
71
  },
75
72
  "scripts": {
76
73
  "build": "tsdown"