hono-takibi 0.9.9995 → 0.9.9996

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.
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/angular-query/index.d.ts
4
4
  declare function angularQuery(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string): Promise<{
@@ -8,7 +8,6 @@ declare function angularQuery(openAPI: OpenAPI, output: string, importPath: stri
8
8
  } | {
9
9
  readonly ok: true;
10
10
  readonly value: `Generated ${string} hooks written to ${string}`;
11
- readonly error?: never;
12
11
  }>;
13
12
  //#endregion
14
13
  export { angularQuery };
@@ -1,4 +1,4 @@
1
- import { t as makeQueryHooks } from "../../query-l4vdT3u2.js";
1
+ import { t as makeQueryHooks } from "../../query-nt-tOucg.js";
2
2
  //#region src/core/angular-query/index.ts
3
3
  async function angularQuery(openAPI, output, importPath, split, clientName = "client") {
4
4
  return makeQueryHooks(openAPI, output, importPath, {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/docs/index.d.ts
4
4
  declare function docs(openAPI: OpenAPI, output: string, entry?: string, basePath?: string, curl?: boolean, baseUrl?: string): Promise<{
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/preact-query/index.d.ts
4
4
  declare function preactQuery(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string): Promise<{
@@ -8,7 +8,6 @@ declare function preactQuery(openAPI: OpenAPI, output: string, importPath: strin
8
8
  } | {
9
9
  readonly ok: true;
10
10
  readonly value: `Generated ${string} hooks written to ${string}`;
11
- readonly error?: never;
12
11
  }>;
13
12
  //#endregion
14
13
  export { preactQuery };
@@ -1,4 +1,4 @@
1
- import { t as makeQueryHooks } from "../../query-l4vdT3u2.js";
1
+ import { t as makeQueryHooks } from "../../query-nt-tOucg.js";
2
2
  //#region src/core/preact-query/index.ts
3
3
  async function preactQuery(openAPI, output, importPath, split, clientName = "client") {
4
4
  return makeQueryHooks(openAPI, output, importPath, {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/rpc/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/solid-query/index.d.ts
4
4
  declare function solidQuery(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string): Promise<{
@@ -8,7 +8,6 @@ declare function solidQuery(openAPI: OpenAPI, output: string, importPath: string
8
8
  } | {
9
9
  readonly ok: true;
10
10
  readonly value: `Generated ${string} hooks written to ${string}`;
11
- readonly error?: never;
12
11
  }>;
13
12
  //#endregion
14
13
  export { solidQuery };
@@ -1,4 +1,4 @@
1
- import { t as makeQueryHooks } from "../../query-l4vdT3u2.js";
1
+ import { t as makeQueryHooks } from "../../query-nt-tOucg.js";
2
2
  //#region src/core/solid-query/index.ts
3
3
  async function solidQuery(openAPI, output, importPath, split, clientName = "client") {
4
4
  return makeQueryHooks(openAPI, output, importPath, {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/svelte-query/index.d.ts
4
4
  declare function svelteQuery(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string): Promise<{
@@ -8,7 +8,6 @@ declare function svelteQuery(openAPI: OpenAPI, output: string, importPath: strin
8
8
  } | {
9
9
  readonly ok: true;
10
10
  readonly value: `Generated ${string} hooks written to ${string}`;
11
- readonly error?: never;
12
11
  }>;
13
12
  //#endregion
14
13
  export { svelteQuery };
@@ -1,4 +1,4 @@
1
- import { t as makeQueryHooks } from "../../query-l4vdT3u2.js";
1
+ import { t as makeQueryHooks } from "../../query-nt-tOucg.js";
2
2
  //#region src/core/svelte-query/index.ts
3
3
  async function svelteQuery(openAPI, output, importPath, split, clientName = "client") {
4
4
  return makeQueryHooks(openAPI, output, importPath, {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/swr/index.d.ts
4
4
  declare function swr(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string): Promise<{
@@ -8,7 +8,6 @@ declare function swr(openAPI: OpenAPI, output: string, importPath: string, split
8
8
  } | {
9
9
  readonly ok: true;
10
10
  readonly value: `Generated ${string} hooks written to ${string}`;
11
- readonly error?: never;
12
11
  }>;
13
12
  //#endregion
14
13
  export { swr };
@@ -1,4 +1,4 @@
1
- import { t as makeQueryHooks } from "../../query-l4vdT3u2.js";
1
+ import { t as makeQueryHooks } from "../../query-nt-tOucg.js";
2
2
  //#region src/core/swr/index.ts
3
3
  async function swr(openAPI, output, importPath, split, clientName = "client") {
4
4
  return makeQueryHooks(openAPI, output, importPath, {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/tanstack-query/index.d.ts
4
4
  declare function tanstackQuery(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string): Promise<{
@@ -8,7 +8,6 @@ declare function tanstackQuery(openAPI: OpenAPI, output: string, importPath: str
8
8
  } | {
9
9
  readonly ok: true;
10
10
  readonly value: `Generated ${string} hooks written to ${string}`;
11
- readonly error?: never;
12
11
  }>;
13
12
  //#endregion
14
13
  export { tanstackQuery };
@@ -1,4 +1,4 @@
1
- import { t as makeQueryHooks } from "../../query-l4vdT3u2.js";
1
+ import { t as makeQueryHooks } from "../../query-nt-tOucg.js";
2
2
  //#region src/core/tanstack-query/index.ts
3
3
  async function tanstackQuery(openAPI, output, importPath, split, clientName = "client") {
4
4
  return makeQueryHooks(openAPI, output, importPath, {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/type/index.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/core/vue-query/index.d.ts
4
4
  declare function vueQuery(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string): Promise<{
@@ -8,7 +8,6 @@ declare function vueQuery(openAPI: OpenAPI, output: string, importPath: string,
8
8
  } | {
9
9
  readonly ok: true;
10
10
  readonly value: `Generated ${string} hooks written to ${string}`;
11
- readonly error?: never;
12
11
  }>;
13
12
  //#endregion
14
13
  export { vueQuery };
@@ -1,4 +1,4 @@
1
- import { t as makeQueryHooks } from "../../query-l4vdT3u2.js";
1
+ import { t as makeQueryHooks } from "../../query-nt-tOucg.js";
2
2
  //#region src/core/vue-query/index.ts
3
3
  async function vueQuery(openAPI, output, importPath, split, clientName = "client") {
4
4
  return makeQueryHooks(openAPI, output, importPath, {
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../../index-ftN0v_bF.js";
1
+ import { t as OpenAPI } from "../../../index-D8guYWoV.js";
2
2
 
3
3
  //#region src/generator/zod-openapi-hono/openapi/index.d.ts
4
4
  declare function zodOpenAPIHono(openapi: OpenAPI, options: {
@@ -1,2 +1,2 @@
1
- import { t as zodOpenAPIHono } from "../../../openapi-BsDi2AmJ.js";
1
+ import { t as zodOpenAPIHono } from "../../../openapi-DNST00z0.js";
2
2
  export { zodOpenAPIHono };
@@ -30,7 +30,7 @@ type OpenAPI = BaseOpenAPI & {
30
30
  };
31
31
  readonly components?: Components;
32
32
  readonly security?: readonly {
33
- readonly [name: string]: readonly string[];
33
+ readonly [k: string]: readonly string[];
34
34
  }[];
35
35
  readonly tags?: {
36
36
  readonly name: string;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
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 { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "./openapi-BVizkubp.js";
5
4
  import { angularQuery } from "./core/angular-query/index.js";
5
+ import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "./openapi-DwwK7GTc.js";
6
6
  import { t as docs } from "./docs-BAt1_N22.js";
7
7
  import { preactQuery } from "./core/preact-query/index.js";
8
8
  import { rpc } from "./core/rpc/index.js";
@@ -147,10 +147,7 @@ async function honoTakibi() {
147
147
  })()
148
148
  ]);
149
149
  const e = results.find((result) => result && !result.ok);
150
- if (e && !e.ok) return {
151
- ok: false,
152
- error: e.error
153
- };
150
+ if (e) return e;
154
151
  return {
155
152
  ok: true,
156
153
  value: results.map((result) => result?.ok ? result.value : void 0).filter((v) => v !== void 0).join("\n")
@@ -220,7 +220,7 @@ function makeParameters(parameters, readonly) {
220
220
  ...isPrimitiveNumeric ? { coerce: true } : {},
221
221
  ...readonly === true ? { readonly: true } : {}
222
222
  });
223
- const z = isPrimitiveNumeric ? baseSchema : isStringWire && schema.type === "boolean" ? baseSchema.replace(/\bz\.boolean\(/g, "z.stringbool(").replace(/\.default\("true"\)/g, ".default(true)").replace(/\.default\("false"\)/g, ".default(false)") : isStringWire && schema.type === "date" ? `z.coerce.${baseSchema.replace("z.", "")}` : isStringWire && (schema.type === "object" || schema.type === "array") ? baseSchema.replace(/z\.(int\d*)\(\)((?:\.(?:min|max|gt|lt|positive|negative|nonnegative|nonpositive|multipleOf)\([^)]*\))*)/g, (_, type, constraints) => `z.coerce.number().pipe(z.${type}()${constraints})`).replace(/z\.bigint\(\)/g, "z.coerce.bigint()").replace(/z\.number\(\)/g, "z.coerce.number()").replace(/z\.boolean\(\)/g, "z.stringbool()").replace(/z\.date\(\)/g, "z.coerce.date()") : baseSchema;
223
+ const z = isPrimitiveNumeric ? baseSchema : isStringWire && schema.type === "boolean" ? baseSchema.replace(/\bz\.boolean\(/g, "z.stringbool(").replace(/\.default\("true"\)/g, ".default(true)").replace(/\.default\("false"\)/g, ".default(false)") : isStringWire && schema.type === "date" ? `z.coerce.${baseSchema.replace("z.", "")}` : isStringWire && (schema.type === "object" || schema.type === "array") ? baseSchema.replace(/z\.(int\d*)\(\)((?:\.(?:min|max|gt|lt|positive|negative|nonnegative|nonpositive|multipleOf)\([^)]*\))*)/g, (_, type, constraints) => type === "int" ? `z.coerce.number().int()${constraints}` : `z.coerce.number().pipe(z.${type}()${constraints})`).replace(/z\.bigint\(\)/g, "z.coerce.bigint()").replace(/z\.number\(\)/g, "z.coerce.number()").replace(/z\.boolean\(\)/g, "z.stringbool()").replace(/z\.date\(\)/g, "z.coerce.date()") : baseSchema;
224
224
  acc[param.in][makeSafeKey(param.name)] = z;
225
225
  return acc;
226
226
  }, {});
@@ -912,15 +912,16 @@ function integer(schema, options) {
912
912
  const coerce = options?.coerce;
913
913
  const errorMessage = schema["x-error-message"];
914
914
  const requiredMessage = schema["x-required-message"];
915
- const baseErrorArg = baseError(errorMessage, requiredMessage);
916
915
  const xCoerce = schema["x-coerce"] === true;
916
+ const wantsCoerce = coerce === true || xCoerce;
917
+ const baseErrorArg = baseError(errorMessage, wantsCoerce ? void 0 : requiredMessage);
917
918
  const isBigint = schema.format === "bigint";
918
919
  const isInt32 = schema.format === "int32";
919
920
  const isInt64 = schema.format === "int64";
920
- const wantsCoerce = coerce === true || xCoerce;
921
921
  const bigintBase = wantsCoerce && isBigint;
922
922
  const bigintPipe = wantsCoerce && isInt64;
923
- const numberPipe = wantsCoerce && !isBigint && !isInt64;
923
+ const numberPipe = wantsCoerce && isInt32;
924
+ const numberChain = wantsCoerce && !isBigint && !isInt64 && !isInt32;
924
925
  const base = bigintBase ? `z.coerce.bigint(${baseErrorArg})` : isInt32 ? `z.int32(${baseErrorArg})` : isInt64 ? `z.int64(${baseErrorArg})` : isBigint ? `z.bigint(${baseErrorArg})` : `z.int(${baseErrorArg})`;
925
926
  const lit = (n) => {
926
927
  if (schema.format === "bigint") return `BigInt(${n})`;
@@ -957,14 +958,23 @@ function integer(schema, options) {
957
958
  })();
958
959
  const multipleOfMessage = schema["x-multipleOf-message"] ?? errorMessage;
959
960
  const multipleOfErrorArg = multipleOfMessage ? `,${error(multipleOfMessage)}` : "";
961
+ const multipleOf = schema.multipleOf !== void 0 && typeof schema.multipleOf === "number" ? `.multipleOf(${lit(schema.multipleOf)}${multipleOfErrorArg})` : void 0;
960
962
  const innerChain = [
961
963
  base,
962
964
  minimum,
963
965
  maximum,
964
- schema.multipleOf !== void 0 && typeof schema.multipleOf === "number" ? `.multipleOf(${lit(schema.multipleOf)}${multipleOfErrorArg})` : void 0
966
+ multipleOf
965
967
  ].filter((v) => v !== void 0).join("");
966
- if (numberPipe) return `z.coerce.number().pipe(${innerChain})`;
967
- if (bigintPipe) return `z.coerce.bigint().pipe(${innerChain})`;
968
+ if (numberChain) {
969
+ const constraints = [
970
+ minimum,
971
+ maximum,
972
+ multipleOf
973
+ ].filter((v) => v !== void 0).join("");
974
+ return `z.coerce.number(${baseErrorArg}).int(${errorMessage ? error(errorMessage) : ""})${constraints}`;
975
+ }
976
+ if (numberPipe) return `z.coerce.number(${baseErrorArg}).pipe(${innerChain})`;
977
+ if (bigintPipe) return `z.coerce.bigint(${baseErrorArg}).pipe(${innerChain})`;
968
978
  return innerChain;
969
979
  }
970
980
  //#endregion
@@ -978,11 +988,11 @@ function number(schema, options) {
978
988
  const coerce = options?.coerce;
979
989
  const errorMessage = schema["x-error-message"];
980
990
  const requiredMessage = schema["x-required-message"];
981
- const baseErrorArg = baseError(errorMessage, requiredMessage);
982
991
  const xCoerce = schema["x-coerce"] === true;
992
+ const wantsCoerce = coerce === true || xCoerce;
993
+ const baseErrorArg = baseError(errorMessage, wantsCoerce ? void 0 : requiredMessage);
983
994
  const isFloat32 = schema.format === "float" || schema.format === "float32";
984
995
  const isFloat64 = schema.format === "float64" || schema.format === "double";
985
- const wantsCoerce = coerce === true || xCoerce;
986
996
  const wirePipe = wantsCoerce && (isFloat32 || isFloat64);
987
997
  const base = wantsCoerce && !isFloat32 && !isFloat64 ? `z.coerce.number(${baseErrorArg})` : isFloat32 ? `z.float32(${baseErrorArg})` : isFloat64 ? `z.float64(${baseErrorArg})` : `z.number(${baseErrorArg})`;
988
998
  const minimumMessage = schema["x-minimum-message"] ?? errorMessage;
@@ -1023,7 +1033,7 @@ function number(schema, options) {
1023
1033
  maximum,
1024
1034
  schema.multipleOf !== void 0 ? `.multipleOf(${schema.multipleOf}${multipleOfErrorArg})` : void 0
1025
1035
  ].filter((v) => v !== void 0).join("");
1026
- return wirePipe ? `z.coerce.number().pipe(${innerChain})` : innerChain;
1036
+ return wirePipe ? `z.coerce.number(${baseErrorArg}).pipe(${innerChain})` : innerChain;
1027
1037
  }
1028
1038
  //#endregion
1029
1039
  //#region src/generator/zod-to-openapi/z/object.ts
@@ -1186,8 +1196,8 @@ function makeFormatOptions(schema) {
1186
1196
  function string(schema, options) {
1187
1197
  const errorMessage = schema["x-error-message"];
1188
1198
  const requiredMessage = schema["x-required-message"];
1189
- const baseErrorArg = baseError(errorMessage, requiredMessage);
1190
1199
  const coerce = schema["x-coerce"] === true;
1200
+ const baseErrorArg = baseError(errorMessage, coerce ? void 0 : requiredMessage);
1191
1201
  const hashBase = (() => {
1192
1202
  if (schema.format !== "hash") return void 0;
1193
1203
  const algo = schema["x-hashAlg"];
@@ -1425,12 +1435,7 @@ function zodToOpenAPI(schema, meta, options) {
1425
1435
  const xCoerce = schema["x-coerce"] === true;
1426
1436
  const xStringbool = schema["x-stringbool"];
1427
1437
  if (xCoerce && xStringbool !== void 0) throw new Error("x-coerce and x-stringbool are mutually exclusive on a boolean schema. Remove one.");
1428
- const arg = (() => {
1429
- if (requiredMessage === void 0 && errorMessage === void 0) return "";
1430
- if (requiredMessage === void 0 && errorMessage !== void 0) return error(errorMessage);
1431
- if (requiredMessage !== void 0 && errorMessage === void 0) return `{error:(issue)=>issue.input===undefined?${JSON.stringify(requiredMessage)}:undefined}`;
1432
- return `{error:(issue)=>issue.input===undefined?${JSON.stringify(requiredMessage)}:${JSON.stringify(errorMessage)}}`;
1433
- })();
1438
+ const arg = baseError(errorMessage, xCoerce ? void 0 : requiredMessage);
1434
1439
  if (xStringbool !== void 0) {
1435
1440
  const opts = xStringbool === true ? null : xStringbool;
1436
1441
  const optsObj = opts ? {
@@ -2053,7 +2058,7 @@ function parametersCode(components, exportParameters, exportParametersTypes, rea
2053
2058
  const isStringWire = parameter.in === "query" || parameter.in === "path";
2054
2059
  const isPrimitiveNumeric = isStringWire && (schema?.type === "number" || schema?.type === "integer");
2055
2060
  const baseSchema = schema ? zodToOpenAPI(schema, { parameters: { ...parameter } }, isPrimitiveNumeric ? { coerce: true } : void 0) : "z.any()";
2056
- const z = isPrimitiveNumeric ? baseSchema : isStringWire && schema?.type === "boolean" ? baseSchema.replace(/\bz\.boolean\(/g, "z.stringbool(") : isStringWire && schema?.type === "date" ? `z.coerce.${baseSchema.replace("z.", "")}` : isStringWire && (schema?.type === "object" || schema?.type === "array") ? baseSchema.replace(/z\.(int\d*)\(\)((?:\.(?:min|max|gt|lt|positive|negative|nonnegative|nonpositive|multipleOf)\([^)]*\))*)/g, (_, type, constraints) => `z.coerce.number().pipe(z.${type}()${constraints})`).replace(/z\.bigint\(\)/g, "z.coerce.bigint()").replace(/z\.number\(\)/g, "z.coerce.number()").replace(/z\.boolean\(\)/g, "z.stringbool()").replace(/z\.date\(\)/g, "z.coerce.date()") : baseSchema;
2061
+ const z = isPrimitiveNumeric ? baseSchema : isStringWire && schema?.type === "boolean" ? baseSchema.replace(/\bz\.boolean\(/g, "z.stringbool(") : isStringWire && schema?.type === "date" ? `z.coerce.${baseSchema.replace("z.", "")}` : isStringWire && (schema?.type === "object" || schema?.type === "array") ? baseSchema.replace(/z\.(int\d*)\(\)((?:\.(?:min|max|gt|lt|positive|negative|nonnegative|nonpositive|multipleOf)\([^)]*\))*)/g, (_, type, constraints) => type === "int" ? `z.coerce.number().int()${constraints}` : `z.coerce.number().pipe(z.${type}()${constraints})`).replace(/z\.bigint\(\)/g, "z.coerce.bigint()").replace(/z\.number\(\)/g, "z.coerce.number()").replace(/z\.boolean\(\)/g, "z.stringbool()").replace(/z\.date\(\)/g, "z.coerce.date()") : baseSchema;
2057
2062
  return zodToOpenAPISchema(toIdentifierPascalCase(ensureSuffix(k, "ParamsSchema")), z, exportParameters, exportParametersTypes, true, readonly);
2058
2063
  }).join("\n\n");
2059
2064
  }
@@ -2,31 +2,12 @@ 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 { b as isSecurityScheme, i as isMediaWithSchema, n as isHttpMethod, p as isRefObject, s as isOperation, t as isContentBody, y as isSecurityArray } from "./guard-BSZ8ezEv.js";
4
4
  import { a as makeBarrel, c as methodPath, f as toIdentifierPascalCase, m as zodToOpenAPISchema, p as uncapitalize, r as ensureSuffix, u as renderNamedImport } from "./utils-Dhc0-ra6.js";
5
- import { _ as makeCallbacks, a as responsesCode, b as makeRef, c as headersCode, d as makeExportConst, f as makeImports, g as makeCallback, h as zodToOpenAPI, i as schemasCode, l as makeSplitSchemaFile, m as ast, n as routeCode, o as requestBodiesCode, p as analyzeCircularSchemas, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as makeConst, v as makeOperationResponses, x as makeRequest, y as makePathItem } from "./openapi-BsDi2AmJ.js";
5
+ import { _ as makeCallbacks, a as responsesCode, b as makeRef, c as headersCode, d as makeExportConst, f as makeImports, g as makeCallback, h as zodToOpenAPI, i as schemasCode, l as makeSplitSchemaFile, m as ast, n as routeCode, o as requestBodiesCode, p as analyzeCircularSchemas, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as makeConst, v as makeOperationResponses, x as makeRequest, y as makePathItem } from "./openapi-DNST00z0.js";
6
6
  import path from "node:path";
7
7
  import { Node, Project, SyntaxKind } from "ts-morph";
8
8
  import SwaggerParser from "@apidevtools/swagger-parser";
9
9
  import { NodeHost, compile } from "@typespec/compiler";
10
10
  import { getOpenAPI3 } from "@typespec/openapi3";
11
- //#region src/helper/exports.ts
12
- async function makeExports(value, suffix, output, readonly) {
13
- const keys = Object.keys(value);
14
- const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
15
- const indexCode = `${keys.sort().map((v) => `export * from './${uncapitalize(v)}'`).join("\n")}\n`;
16
- const asConst = readonly ? " as const" : "";
17
- const e = (await Promise.all([...keys.map((k) => {
18
- const v = value[k];
19
- const body = `export const ${toIdentifierPascalCase(ensureSuffix(k, suffix))} = ${JSON.stringify(v ?? {})}${asConst}\n`;
20
- const filePath = path.join(outDir, `${uncapitalize(k)}.ts`);
21
- return emit(body, path.dirname(filePath), filePath);
22
- }), emit(indexCode, path.dirname(path.join(outDir, "index.ts")), path.join(outDir, "index.ts"))])).find((result) => !result.ok);
23
- if (e) return e;
24
- return {
25
- ok: true,
26
- value: `Generated ${suffix} code written to ${outDir}/*.ts (index.ts included)`
27
- };
28
- }
29
- //#endregion
30
11
  //#region src/core/components/callbacks.ts
31
12
  async function callbacks(callbacks, output, split, components, readonly) {
32
13
  if (!callbacks) return {
@@ -89,17 +70,16 @@ async function examples(examples, output, split, readonly) {
89
70
  const asConst = readonly ? " as const" : "";
90
71
  if (split) {
91
72
  const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
92
- const indexCode = `${keys.sort().map((v) => `export * from './${uncapitalize(v)}.ts'`).join("\n")}\n`;
93
73
  const e = (await Promise.all([...keys.map((k) => {
94
74
  const v = examples[k];
95
75
  const name = toIdentifierPascalCase(ensureSuffix(k, "Example"));
96
76
  const filePath = path.join(outDir, `${uncapitalize(k)}.ts`);
97
77
  if (typeof v === "object" && v !== null && "$ref" in v && typeof v.$ref === "string") {
98
78
  const refName = makeRef(v.$ref);
99
- return emit(`import { ${refName} } from '${`./${uncapitalize(v.$ref.split("/").at(-1) ?? "")}.ts`}'\n\nexport const ${name} = ${refName}\n`, path.dirname(filePath), filePath);
79
+ return emit(`import { ${refName} } from '${`./${uncapitalize(v.$ref.split("/").at(-1) ?? "")}`}'\n\nexport const ${name} = ${refName}\n`, path.dirname(filePath), filePath);
100
80
  }
101
81
  return emit(`export const ${name} = ${JSON.stringify(v)}${asConst}\n`, path.dirname(filePath), filePath);
102
- }), emit(indexCode, path.dirname(path.join(outDir, "index.ts")), path.join(outDir, "index.ts"))])).find((result) => !result.ok);
82
+ }), emit(makeBarrel(examples), path.dirname(path.join(outDir, "index.ts")), path.join(outDir, "index.ts"))])).find((result) => !result.ok);
103
83
  if (e) return e;
104
84
  return {
105
85
  ok: true,
@@ -158,19 +138,24 @@ async function links(links, output, split, readonly) {
158
138
  ok: false,
159
139
  error: "No links found"
160
140
  };
161
- if (Object.keys(links).length === 0) return {
141
+ const keys = Object.keys(links);
142
+ if (keys.length === 0) return {
162
143
  ok: true,
163
144
  value: "No links found"
164
145
  };
165
146
  if (split) {
166
- const exportsResult = await makeExports(links, "Link", output, readonly);
167
- if (!exportsResult.ok) return {
168
- ok: false,
169
- error: exportsResult.error
170
- };
147
+ const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
148
+ const asConst = readonly ? " as const" : "";
149
+ const e = (await Promise.all([...keys.map((k) => {
150
+ const v = links[k];
151
+ const body = `export const ${toIdentifierPascalCase(ensureSuffix(k, "Link"))} = ${JSON.stringify(v ?? {})}${asConst}\n`;
152
+ const filePath = path.join(outDir, `${uncapitalize(k)}.ts`);
153
+ return emit(body, path.dirname(filePath), filePath);
154
+ }), emit(makeBarrel(links), path.dirname(path.join(outDir, "index.ts")), path.join(outDir, "index.ts"))])).find((result) => !result.ok);
155
+ if (e) return e;
171
156
  return {
172
157
  ok: true,
173
- value: exportsResult.value
158
+ value: `Generated Link code written to ${outDir}/*.ts (index.ts included)`
174
159
  };
175
160
  }
176
161
  const emitResult = await emit(makeExportConst(links, "Link", readonly), path.dirname(output), output);
@@ -198,7 +183,6 @@ async function mediaTypes(mediaTypes, output, split, readonly, components) {
198
183
  const importCode = renderNamedImport(["z"], "@hono/zod-openapi");
199
184
  if (split) {
200
185
  const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
201
- const indexCode = `${keys.sort().map((v) => `export * from './${uncapitalize(v)}.ts'`).join("\n")}\n`;
202
186
  const e = (await Promise.all([...keys.map((k) => {
203
187
  const v = mediaTypes[k];
204
188
  const name = toIdentifierPascalCase(ensureSuffix(k, "MediaTypeSchema"));
@@ -206,7 +190,7 @@ async function mediaTypes(mediaTypes, output, split, readonly, components) {
206
190
  if (typeof v === "object" && v !== null && "$ref" in v && v.$ref) return emit(makeImports(`export const ${name} = ${toIdentifierPascalCase(ensureSuffix(v.$ref.split("/").at(-1) ?? "", "MediaTypeSchema"))}\n`, filePath, components, split), path.dirname(filePath), filePath);
207
191
  if (typeof v === "object" && v !== null && "schema" in v) return emit(makeImports(zodToOpenAPISchema(name, zodToOpenAPI(v.schema), true, false, true, readonly), filePath, components, split), path.dirname(filePath), filePath);
208
192
  return emit(makeImports(`export const ${name} = z.unknown()\n`, filePath, components, split), path.dirname(filePath), filePath);
209
- }), emit(indexCode, path.dirname(path.join(outDir, "index.ts")), path.join(outDir, "index.ts"))])).find((result) => !result.ok);
193
+ }), emit(makeBarrel(mediaTypes), path.dirname(path.join(outDir, "index.ts")), path.join(outDir, "index.ts"))])).find((result) => !result.ok);
210
194
  if (e) return e;
211
195
  return {
212
196
  ok: true,
@@ -248,10 +232,7 @@ async function parameters(parameters, output, split, exportType, components, rea
248
232
  const filePath = path.join(outDir, `${uncapitalize(parameterName)}.ts`);
249
233
  return emit(makeImports(code, filePath, components, split), path.dirname(filePath), filePath);
250
234
  }), emit(makeBarrel(parameters), outDir, path.join(outDir, "index.ts"))])).find((result) => !result.ok);
251
- if (e && !e.ok) return {
252
- ok: false,
253
- error: e.error
254
- };
235
+ if (e) return e;
255
236
  return {
256
237
  ok: true,
257
238
  value: `Generated parameters code written to ${outDir}/*.ts (index.ts included)`
@@ -289,6 +270,7 @@ async function pathItems(components, pathItemsConfig, componentsConfig, readonly
289
270
  const asConst = readonly ? " as const" : "";
290
271
  const isPathItem = (v) => typeof v === "object" && v !== null && !("$ref" in v);
291
272
  return Object.entries(pathItems).flatMap(([k, pathItemOrRef]) => isPathItem(pathItemOrRef) ? [{
273
+ key: k,
292
274
  name: toIdentifierPascalCase(ensureSuffix(k, "PathItem")),
293
275
  code: `${makeConst(exportPathItems, k, "PathItem")}${makePathItem(pathItemOrRef)}${asConst}`
294
276
  }] : []);
@@ -307,15 +289,15 @@ async function pathItems(components, pathItemsConfig, componentsConfig, readonly
307
289
  };
308
290
  }
309
291
  const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
310
- const failed = (await Promise.all([...entries.map(async ({ name, code }) => {
311
- const filePath = `${outDir}/${uncapitalize(name)}.ts`;
292
+ const e = (await Promise.all([...entries.map(async ({ key, code }) => {
293
+ const filePath = `${outDir}/${uncapitalize(key)}.ts`;
312
294
  const result = await emit(makeImports(code, filePath, componentsConfig), path.dirname(filePath), filePath);
313
295
  return result.ok ? {
314
296
  ok: true,
315
297
  value: filePath
316
298
  } : result;
317
- }), emit(makeBarrel(Object.fromEntries(entries.map((e) => [e.name, null]))), outDir, `${outDir}/index.ts`)])).find((result) => !result.ok);
318
- if (failed) return failed;
299
+ }), emit(makeBarrel(Object.fromEntries(entries.map((e) => [e.key, null]))), outDir, `${outDir}/index.ts`)])).find((result) => !result.ok);
300
+ if (e) return e;
319
301
  return {
320
302
  ok: true,
321
303
  value: `Generated PathItem code written to ${outDir}/*.ts (index.ts included)`
@@ -375,10 +357,7 @@ async function responses(responses, output, split, components, readonly) {
375
357
  const filePath = path.join(outDir, `${uncapitalize(responseName)}.ts`);
376
358
  return emit(makeImports(code, filePath, components, split), path.dirname(filePath), filePath);
377
359
  }), emit(makeBarrel(responses), outDir, path.join(outDir, "index.ts"))])).find((result) => !result.ok);
378
- if (e && !e.ok) return {
379
- ok: false,
380
- error: e.error
381
- };
360
+ if (e) return e;
382
361
  return {
383
362
  ok: true,
384
363
  value: `Generated responses code written to ${outDir}/*.ts (index.ts included)`
@@ -437,19 +416,24 @@ async function securitySchemes(securitySchemes, output, split, readonly) {
437
416
  ok: false,
438
417
  error: "No securitySchemes found"
439
418
  };
440
- if (Object.keys(securitySchemes).length === 0) return {
419
+ const keys = Object.keys(securitySchemes);
420
+ if (keys.length === 0) return {
441
421
  ok: true,
442
422
  value: "No securitySchemes found"
443
423
  };
444
424
  if (split) {
445
- const exportsResult = await makeExports(securitySchemes, "SecurityScheme", output, readonly);
446
- if (!exportsResult.ok) return {
447
- ok: false,
448
- error: exportsResult.error
449
- };
425
+ const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
426
+ const asConst = readonly ? " as const" : "";
427
+ const e = (await Promise.all([...keys.map((k) => {
428
+ const v = securitySchemes[k];
429
+ const body = `export const ${toIdentifierPascalCase(ensureSuffix(k, "SecurityScheme"))} = ${JSON.stringify(v ?? {})}${asConst}\n`;
430
+ const filePath = path.join(outDir, `${uncapitalize(k)}.ts`);
431
+ return emit(body, path.dirname(filePath), filePath);
432
+ }), emit(makeBarrel(securitySchemes), path.dirname(path.join(outDir, "index.ts")), path.join(outDir, "index.ts"))])).find((result) => !result.ok);
433
+ if (e) return e;
450
434
  return {
451
435
  ok: true,
452
- value: exportsResult.value
436
+ value: `Generated SecurityScheme code written to ${outDir}/*.ts (index.ts included)`
453
437
  };
454
438
  }
455
439
  const emitResult = await emit(makeExportConst(securitySchemes, "SecurityScheme", readonly), path.dirname(output), output);
@@ -949,7 +933,7 @@ async function route(openAPI, routes, components, readonly) {
949
933
  };
950
934
  }
951
935
  const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
952
- const failed = (await Promise.all([...entries.map(async ({ name, code }) => {
936
+ const e = (await Promise.all([...entries.map(async ({ name, code }) => {
953
937
  const filePath = `${outDir}/${name}.ts`;
954
938
  const result = await emit(makeImports(code, filePath, components), path.dirname(filePath), filePath);
955
939
  return result.ok ? {
@@ -957,7 +941,7 @@ async function route(openAPI, routes, components, readonly) {
957
941
  value: filePath
958
942
  } : result;
959
943
  }), emit(makeBarrel(Object.fromEntries(entries.map((e) => [e.name, null]))), outDir, `${outDir}/index.ts`)])).find((result) => !result.ok);
960
- if (failed) return failed;
944
+ if (e) return e;
961
945
  return {
962
946
  ok: true,
963
947
  value: `Generated route code written to ${outDir}/*.ts (index.ts included)`
@@ -1831,11 +1815,8 @@ async function removeStaleFiles(handlerPath, generatedFileNames) {
1831
1815
  };
1832
1816
  }
1833
1817
  const staleFiles = readdirResult.value.filter((file) => file.endsWith(".ts") && !file.endsWith(".test.ts") && file !== "index.ts" && !generatedFileNames.has(file));
1834
- const firstError = (await Promise.all(staleFiles.flatMap((file) => [unlink(`${handlerPath}/${file}`), unlink(`${handlerPath}/${path.basename(file, ".ts")}.test.ts`)]))).find((r) => !r.ok);
1835
- if (firstError && !firstError.ok) return {
1836
- ok: false,
1837
- error: firstError.error
1838
- };
1818
+ const e = (await Promise.all(staleFiles.flatMap((file) => [unlink(`${handlerPath}/${file}`), unlink(`${handlerPath}/${path.basename(file, ".ts")}.test.ts`)]))).find((result) => !result.ok);
1819
+ if (e) return e;
1839
1820
  return {
1840
1821
  ok: true,
1841
1822
  value: void 0
@@ -1858,7 +1839,7 @@ async function zodOpenAPIHonoHandler(openapi, output, test = false, pathAlias, r
1858
1839
  ok: false,
1859
1840
  error: mkdirResult.error
1860
1841
  };
1861
- const firstError = (await Promise.all([...handlers.map(async (handler) => {
1842
+ const e = (await Promise.all([...handlers.map(async (handler) => {
1862
1843
  const fmtResult = await fmt(routeHandler ? makeStubFileContent(handler, importFrom) : makeInlineStubFileContent(handler, importFrom));
1863
1844
  if (!fmtResult.ok) return {
1864
1845
  ok: false,
@@ -1923,7 +1904,7 @@ async function zodOpenAPIHonoHandler(openapi, output, test = false, pathAlias, r
1923
1904
  value: void 0
1924
1905
  };
1925
1906
  })()])).find((result) => !result.ok);
1926
- if (firstError) return firstError;
1907
+ if (e) return e;
1927
1908
  const cleanupResult = await removeStaleFiles(handlerPath, new Set(handlers.map((h) => h.fileName)));
1928
1909
  if (!cleanupResult.ok) return {
1929
1910
  ok: false,
@@ -2149,7 +2130,7 @@ async function webhooks(openAPI, webhooks, components, readonly) {
2149
2130
  };
2150
2131
  }
2151
2132
  const outDir = path.join(path.dirname(output), path.basename(output, ".ts"));
2152
- const failed = (await Promise.all([...entries.map(async ({ name, code }) => {
2133
+ const e = (await Promise.all([...entries.map(async ({ name, code }) => {
2153
2134
  const filePath = `${outDir}/${name}.ts`;
2154
2135
  const result = await emit(makeImports(code, filePath, components), path.dirname(filePath), filePath);
2155
2136
  return result.ok ? {
@@ -2157,7 +2138,7 @@ async function webhooks(openAPI, webhooks, components, readonly) {
2157
2138
  value: filePath
2158
2139
  } : result;
2159
2140
  }), emit(makeBarrel(Object.fromEntries(entries.map((e) => [e.name, null]))), outDir, `${outDir}/index.ts`)])).find((result) => !result.ok);
2160
- if (failed) return failed;
2141
+ if (e) return e;
2161
2142
  return {
2162
2143
  ok: true,
2163
2144
  value: `Generated webhooks code written to ${outDir}/*.ts (index.ts included)`
@@ -549,10 +549,7 @@ async function makeQueryHooks(openAPI, output, importPath, config, split, client
549
549
  }),
550
550
  emit(index, path.dirname(indexPath), indexPath)
551
551
  ])).find((result) => !result.ok);
552
- if (e && !e.ok) return {
553
- ok: false,
554
- error: e.error
555
- };
552
+ if (e) return e;
556
553
  return {
557
554
  ok: true,
558
555
  value: `Generated ${config.frameworkName.toLowerCase().replace(/ /g, "-")} hooks written to ${outDir}/*.ts (index.ts included)`
@@ -1,8 +1,8 @@
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-BSZ8ezEv.js";
4
- import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "../openapi-BVizkubp.js";
5
4
  import { angularQuery } from "../core/angular-query/index.js";
5
+ import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "../openapi-DwwK7GTc.js";
6
6
  import { t as docs } from "../docs-BAt1_N22.js";
7
7
  import { preactQuery } from "../core/preact-query/index.js";
8
8
  import { rpc } from "../core/rpc/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.9.9995",
3
+ "version": "0.9.9996",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",