hono-takibi 0.29.0 → 0.30.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 { Z as INPUT_EXTENSIONS, m as isInputPath } from "./guard-D-yHkxqE.js";
2
+ import { _ as isInputPath, et as INPUT_EXTENSIONS } from "./guard-BNQ9WfOm.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.29.0";
8
+ var version = "0.30.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";
@@ -39,9 +39,9 @@ function loadConfig(configPath, reload) {
39
39
  function runJobs(config) {
40
40
  return Effect.gen(function* () {
41
41
  const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob, openAPI3, packageRoots }] = yield* Effect.promise(() => Promise.all([
42
- import("./openapi-tYYvoKiU.js").then((n) => n.t),
42
+ import("./openapi-DCo11_TE.js").then((n) => n.t),
43
43
  import("./format-BF7SbaMP.js").then((n) => n.r),
44
- import("./shared-BNo1Lr1g.js").then((n) => n.o)
44
+ import("./shared-BBl5tC8y.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-BNo1Lr1g.js").then((n) => n.o));
82
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-BBl5tC8y.js").then((n) => n.o));
83
83
  const inputDirectory = path.dirname(path.resolve(config.input));
84
84
  return {
85
85
  inputDirectory,
@@ -207,9 +207,9 @@ function generate(args) {
207
207
  });
208
208
  if (input !== void 0 && output !== void 0) {
209
209
  const [{ parseOpenAPI }, { takibi }, { openAPI3 }] = yield* Effect.promise(() => Promise.all([
210
- import("./openapi-tYYvoKiU.js").then((n) => n.t),
211
- import("./core-BFsWwAXx.js").then((n) => n.t),
212
- import("./shared-BNo1Lr1g.js").then((n) => n.o)
210
+ import("./openapi-DCo11_TE.js").then((n) => n.t),
211
+ import("./core-C-wH_UxC.js").then((n) => n.t),
212
+ import("./shared-BBl5tC8y.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,3 +1,3 @@
1
- import { t as OpenAPI } from "../../index-DvZscmYm.js";
1
+ import { t as OpenAPI } from "../../index-DN54hj9W.js";
2
2
  import { Effect } from "effect";
3
3
  export declare function docs(openAPI: OpenAPI, output: string, entry?: string, basePath?: string, curl?: boolean, baseUrl?: string): Effect.Effect<string, import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
@@ -1 +1 @@
1
- export { t as docs } from "../../docs-MRoh0U3g.js";
1
+ export { t as docs } from "../../docs-CDp93aXs.js";
@@ -1,6 +1,6 @@
1
- import { t as OpenAPI } from "../../index-DvZscmYm.js";
1
+ import { t as OpenAPI } from "../../index-DN54hj9W.js";
2
2
  import { n as GenerateError, t as FormatError } from "../../index-sZ1C8djg.js";
3
- import { t as Grouping } from "../../index-8HyUtaew.js";
3
+ import { t as Grouping } from "../../index-nkUsldwj.js";
4
4
  declare const HOOK_CONFIGS: {
5
5
  readonly swr: {
6
6
  readonly packageName: 'swr';
@@ -1 +1 @@
1
- export { t as hooks } from "../../hooks-Cu1bRToh.js";
1
+ export { t as hooks } from "../../hooks-JLvbNojU.js";
@@ -1,6 +1,6 @@
1
- import { t as OpenAPI } from "../../index-DvZscmYm.js";
1
+ import { t as OpenAPI } from "../../index-DN54hj9W.js";
2
2
  import { n as GenerateError, t as FormatError } from "../../index-sZ1C8djg.js";
3
- import { t as Grouping } from "../../index-8HyUtaew.js";
3
+ import { t as Grouping } from "../../index-nkUsldwj.js";
4
4
  import { Effect } from "effect";
5
5
  /**
6
6
  * Generates RPC client wrapper functions from OpenAPI specification.
@@ -1,7 +1,7 @@
1
- import { O as isRecord, Y as HTTP_METHODS, b as isOperationLike, v as isOpenAPIPaths } from "../../guard-D-yHkxqE.js";
1
+ import { C as isOperationLike, Q as HTTP_METHODS, j as isRecord, x as isOpenAPIPaths } from "../../guard-BNQ9WfOm.js";
2
2
  import { i as GenerateError } from "../../format-BF7SbaMP.js";
3
- import { _ as routeName, u as makeInferRequestType } from "../../utils-Kv3B0qkM.js";
4
- import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "../../rpc-CVE9_EnW.js";
3
+ import { _ as routeName, u as makeInferRequestType } from "../../utils-BhQ-YVD3.js";
4
+ import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "../../rpc-B7PiQ1sR.js";
5
5
  import { t as emit } from "../../emit-CqkT9T4Q.js";
6
6
  import { Effect } from "effect";
7
7
  import { dirname } from "node:path";
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-DvZscmYm.js";
1
+ import { t as OpenAPI } from "../../index-DN54hj9W.js";
2
2
  import { t as FormatError } from "../../index-sZ1C8djg.js";
3
3
  import { Effect } from "effect";
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { N as isSchemaArray, S as isParameterArray, d as isHttpMethod, g as isMediaWithSchema, j as isRequestBody, o as isBinaryFile, v as isOpenAPIPaths, x as isParameter, y as isOperation, z as isStringRef } from "../../guard-D-yHkxqE.js";
2
- import { d as makeSafeKey, v as statusCodeToNumber, y as toIdentifierPascalCase } from "../../utils-Kv3B0qkM.js";
1
+ import { H as isStringRef, I as isSchemaArray, P as isRequestBody, S as isOperation, T as isParameterArray, l as isBinaryFile, m as isHttpMethod, w as isParameter, x as isOpenAPIPaths, y as isMediaWithSchema } from "../../guard-BNQ9WfOm.js";
2
+ import { d as makeSafeKey, v as statusCodeToNumber, y as toIdentifierPascalCase } from "../../utils-BhQ-YVD3.js";
3
3
  import { t as emit } from "../../emit-CqkT9T4Q.js";
4
4
  import { Effect } from "effect";
5
5
  import path from "node:path";
@@ -1,13 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
- import { D as isPathItemRef, E as isPathItemEntry, I as isSecurityArray, L as isSecurityScheme, N as isSchemaArray, P as isSchemaObject, Q as JSON_MEDIA_TYPE, T as isPathItem, U as COMPONENT_NAMES, V as isValidIdent, W as COMPONENT_REF_PREFIX, Y as HTTP_METHODS, d as isHttpMethod, g as isMediaWithSchema, i as hasRequestBodyContent, k as isRefObject, p as isInlineMedia, r as hasNumericConstraint, s as isCallbacks, tt as TEXT_MEDIA_TYPE, v as isOpenAPIPaths, x as isParameter, y as isOperation } from "./guard-D-yHkxqE.js";
2
+ import { A as isPathItemRef, B as isSecurityScheme, I as isSchemaArray, K as COMPONENT_NAMES, L as isSchemaObject, M as isRefObject, O as isPathItem, Q as HTTP_METHODS, S as isOperation, W as isValidIdent, a as hasNumericConstraint, g as isInlineMedia, it as TEXT_MEDIA_TYPE, k as isPathItemEntry, m as isHttpMethod, o as hasRequestBodyContent, q as COMPONENT_REF_PREFIX, tt as JSON_MEDIA_TYPE, u as isCallbacks, w as isParameter, x as isOpenAPIPaths, y as isMediaWithSchema, z as isSecurityArray } from "./guard-BNQ9WfOm.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, d as makeSafeKey, f as makeStringLiteral, h as renderNamedImport, l as makeBarrel, p as normalizeTypes, r as cyclicNodes, v as statusCodeToNumber, x as uncapitalizeWord, y as toIdentifierPascalCase } from "./utils-Kv3B0qkM.js";
5
- import { A as resolveParameter, C as zodToOpenAPI, D as makeRouteEntries, E as makeRef, O as makeRouteProperties, S as textOf, T as makePathItem, _ as declarationOf, a as responsesCode, b as parseModule, c as headersCode, d as makeConst, f as makeExportConst, g as ast, h as analyzeCircularSchemas, i as schemasCode, j as resolvePathItem, k as makeWebhookEntries, l as makeSplitSchemaFile, m as makeModuleSpec, n as routeCode, o as requestBodiesCode, p as makeImports, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, v as descendantsWhere, w as makeCallback, x as parseSource, y as identifierNames } from "./openapi-D9J3Kaij.js";
6
- import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-CVE9_EnW.js";
4
+ import { S as zodToOpenAPISchema, _ as routeName, a as ensureSuffix, b as uncapitalize, c as escapeRegexLiteral, d as makeSafeKey, f as makeStringLiteral, h as renderNamedImport, l as makeBarrel, p as normalizeTypes, r as cyclicNodes, v as statusCodeToNumber, x as uncapitalizeWord, y as toIdentifierPascalCase } from "./utils-BhQ-YVD3.js";
5
+ import { A as resolveParameter, C as zodToOpenAPI, D as makeRouteEntries, E as makeRef, O as makeRouteProperties, S as textOf, T as makePathItem, _ as declarationOf, a as responsesCode, b as parseModule, c as headersCode, d as makeConst, f as makeExportConst, g as ast, h as analyzeCircularSchemas, i as schemasCode, j as resolvePathItem, k as makeWebhookEntries, l as makeSplitSchemaFile, m as makeModuleSpec, n as routeCode, o as requestBodiesCode, p as makeImports, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, v as descendantsWhere, w as makeCallback, x as parseSource, y as identifierNames } from "./openapi-Bk4KBGJZ.js";
6
+ import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-B7PiQ1sR.js";
7
7
  import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-Bip_L0oR.js";
8
8
  import { t as emit } from "./emit-CqkT9T4Q.js";
9
- import { t as hooks } from "./hooks-Cu1bRToh.js";
10
- import { t as docs } from "./docs-MRoh0U3g.js";
9
+ import { t as hooks } from "./hooks-JLvbNojU.js";
10
+ import { t as docs } from "./docs-CDp93aXs.js";
11
11
  import { rpc } from "./core/rpc/index.js";
12
12
  import { type } from "./core/type/index.js";
13
13
  import { Effect } from "effect";
@@ -1,5 +1,5 @@
1
- import { $ as MULTIPART_MEDIA_TYPE, N as isSchemaArray, O as isRecord, Y as HTTP_METHODS, k as isRefObject } from "./guard-D-yHkxqE.js";
2
- import { i as decodePercent, s as escapeHtml } from "./utils-Kv3B0qkM.js";
1
+ import { I as isSchemaArray, M as isRefObject, Q as HTTP_METHODS, j as isRecord, nt as MULTIPART_MEDIA_TYPE } from "./guard-BNQ9WfOm.js";
2
+ import { i as decodePercent, s as escapeHtml } from "./utils-BhQ-YVD3.js";
3
3
  import { n as mkdir, o as writeFile } from "./file-Bip_L0oR.js";
4
4
  import { Effect } from "effect";
5
5
  import path from "node:path";
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../../index-DvZscmYm.js";
1
+ import { t as OpenAPI } from "../../../index-DN54hj9W.js";
2
2
  export declare function zodOpenAPIHono(document: OpenAPI, options?: {
3
3
  readonly readonly?: boolean;
4
4
  readonly exportSchemas?: boolean;
@@ -1 +1 @@
1
- export { t as zodOpenAPIHono } from "../../../openapi-D9J3Kaij.js";
1
+ export { t as zodOpenAPIHono } from "../../../openapi-Bk4KBGJZ.js";
@@ -126,6 +126,32 @@ function isRefOnly(s) {
126
126
  return s.$ref !== void 0 && Object.keys(s).length === 1;
127
127
  }
128
128
  /**
129
+ * The keywords that say something about a value without constraining it: the JSON Schema
130
+ * 2020-12 §9 annotations, OpenAPI's own (`example`, `externalDocs`, `xml`) and `nullable`,
131
+ * which the caller reads as `null` being allowed. An `allOf` member of these alone describes
132
+ * the intersection and validates nothing: emitted as a schema it is `z.any()`, and
133
+ * `X.and(z.any())` is `any` (#420).
134
+ */
135
+ const ANNOTATION_KEYWORDS = /* @__PURE__ */ new Set([
136
+ "title",
137
+ "description",
138
+ "default",
139
+ "deprecated",
140
+ "readOnly",
141
+ "writeOnly",
142
+ "example",
143
+ "examples",
144
+ "externalDocs",
145
+ "xml",
146
+ "$comment",
147
+ "nullable"
148
+ ]);
149
+ /** Whether a schema carries annotations alone: no type, and no keyword that validates. */
150
+ function isAnnotationOnly(schema) {
151
+ const keys = Object.keys(schema);
152
+ return keys.length > 0 && keys.every((key) => ANNOTATION_KEYWORDS.has(key));
153
+ }
154
+ /**
129
155
  * OpenAPI 3.2 §4.25: `discriminator` "MUST NOT change the validation outcome of the
130
156
  * schema". A branch can therefore be routed by key only when the key alone already
131
157
  * decides it: a bare object head that requires the discriminating property and pins it
@@ -297,7 +323,22 @@ function isUntypedObject(schema) {
297
323
  */
298
324
  function isBinaryFile(schema) {
299
325
  const types = Array.isArray(schema.type) ? schema.type : [schema.type];
300
- return schema.format === "binary" && types.includes("string") && schema.contentEncoding === void 0 && schema.contentMediaType === void 0 && schema.contentSchema === void 0 && schema["x-codec"] === void 0;
326
+ return schema.format === "binary" && types.includes("string") && (schema.contentEncoding === void 0 || schema.contentEncoding === "binary") && schema.contentSchema === void 0 && schema["x-codec"] === void 0;
327
+ }
328
+ /**
329
+ * The MIME types a file is restricted to, what `z.file().mime()` takes: its
330
+ * `contentMediaType`, and the ones an `anyOf` of members that each name one carries, which
331
+ * is how `z.toJSONSchema()` writes `.mime([...])`. `undefined` when the schema names none.
332
+ */
333
+ function fileMimeTypes(schema) {
334
+ const own = schema.contentMediaType === void 0 ? [] : [schema.contentMediaType];
335
+ const listed = hasMimeAlternatives(schema) ? schema.anyOf.flatMap((member) => typeof member.contentMediaType === "string" ? [member.contentMediaType] : []) : [];
336
+ const types = [.../* @__PURE__ */ new Set([...own, ...listed])];
337
+ return types.length > 0 ? types : void 0;
338
+ }
339
+ /** Whether a schema's `anyOf` is a list of MIME types alone: `[{contentMediaType}, ...]`. */
340
+ function hasMimeAlternatives(schema) {
341
+ return schema.anyOf !== void 0 && schema.anyOf.length > 0 && schema.anyOf.every((member) => typeof member.contentMediaType === "string" && Object.keys(member).length === 1);
301
342
  }
302
343
  /**
303
344
  * Whether a `time` takes an offset. `time` is an RFC 3339 full-time, `12:34:56Z` or
@@ -336,4 +377,4 @@ function hasNoContentResponse(operation) {
336
377
  function isInheritedName(parameter) {
337
378
  return parameter.in !== "path" && parameter.name in Object.prototype;
338
379
  }
339
- export { MULTIPART_MEDIA_TYPE as $, isRefOnly as A, isUntypedObject as B, isParameterObject as C, isPathItemRef as D, isPathItemEntry as E, isSchemaProperty as F, COMPONENT_SUFFIXES as G, ARROW_FUNCTION_PATTERN as H, isSecurityArray as I, HOOK_LIBRARIES as J, FORM_MEDIA_TYPES as K, isSecurityScheme as L, isResponses as M, isSchemaArray as N, isRecord as O, isSchemaObject as P, JSON_MEDIA_TYPE as Q, isSingleSchema as R, isParameterArray as S, isPathItem as T, COMPONENT_NAMES as U, isValidIdent as V, COMPONENT_REF_PREFIX as W, IDENTIFIER_PATTERN as X, HTTP_METHODS as Y, INPUT_EXTENSIONS as Z, isOffsetTime as _, hasTypelessConstraint as a, isOperationLike as b, isDiscriminableBranch as c, isHttpMethod as d, OCTET_STREAM_MEDIA_TYPE as et, isInheritedName as f, isMediaWithSchema as g, isMedia as h, hasRequestBodyContent as i, isRequestBody as j, isRefObject as k, isExamplesInput as l, isInputPath as m, hasNoUserChain as n, isBinaryFile as o, isInlineMedia as p, FORM_URLENCODED_MEDIA_TYPE as q, hasNumericConstraint as r, isCallbacks as s, hasNoContentResponse as t, TEXT_MEDIA_TYPE as tt, isHeader as u, isOpenAPIPaths as v, isParameterRef as w, isParameter as x, isOperation as y, isStringRef as z };
380
+ export { IDENTIFIER_PATTERN as $, isPathItemRef as A, isSecurityScheme as B, isOperationLike as C, isParameterRef as D, isParameterObject as E, isResponses as F, ARROW_FUNCTION_PATTERN as G, isStringRef as H, isSchemaArray as I, COMPONENT_SUFFIXES as J, COMPONENT_NAMES as K, isSchemaObject as L, isRefObject as M, isRefOnly as N, isPathItem as O, isRequestBody as P, HTTP_METHODS as Q, isSchemaProperty as R, isOperation as S, isParameterArray as T, isUntypedObject as U, isSingleSchema as V, isValidIdent as W, FORM_URLENCODED_MEDIA_TYPE as X, FORM_MEDIA_TYPES as Y, HOOK_LIBRARIES as Z, isInputPath as _, hasNumericConstraint as a, isOffsetTime as b, isAnnotationOnly as c, isDiscriminableBranch as d, INPUT_EXTENSIONS as et, isExamplesInput as f, isInlineMedia as g, isInheritedName as h, hasNoUserChain as i, TEXT_MEDIA_TYPE as it, isRecord as j, isPathItemEntry as k, isBinaryFile as l, isHttpMethod as m, hasMimeAlternatives as n, MULTIPART_MEDIA_TYPE as nt, hasRequestBodyContent as o, isHeader as p, COMPONENT_REF_PREFIX as q, hasNoContentResponse as r, OCTET_STREAM_MEDIA_TYPE as rt, hasTypelessConstraint as s, fileMimeTypes as t, JSON_MEDIA_TYPE as tt, isCallbacks as u, isMedia as v, isParameter as w, isOpenAPIPaths as x, isMediaWithSchema as y, isSecurityArray as z };
@@ -1,7 +1,7 @@
1
- import { O as isRecord, Y as HTTP_METHODS, b as isOperationLike, t as hasNoContentResponse, v as isOpenAPIPaths } from "./guard-D-yHkxqE.js";
1
+ import { C as isOperationLike, Q as HTTP_METHODS, j as isRecord, r as hasNoContentResponse, x as isOpenAPIPaths } from "./guard-BNQ9WfOm.js";
2
2
  import { i as GenerateError } from "./format-BF7SbaMP.js";
3
- import { _ as routeName, n as capitalize, y as toIdentifierPascalCase } from "./utils-Kv3B0qkM.js";
4
- import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "./rpc-CVE9_EnW.js";
3
+ import { _ as routeName, n as capitalize, y as toIdentifierPascalCase } from "./utils-BhQ-YVD3.js";
4
+ import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "./rpc-B7PiQ1sR.js";
5
5
  import { t as emit } from "./emit-CqkT9T4Q.js";
6
6
  import { Effect } from "effect";
7
7
  import path from "node:path";
@@ -365,6 +365,7 @@ type Schema$1 = {
365
365
  readonly 'x-enum-message'?: string;
366
366
  readonly 'x-minLength-message'?: string;
367
367
  readonly 'x-maxLength-message'?: string;
368
+ readonly 'x-contentMediaType-message'?: string;
368
369
  readonly 'x-minItems-message'?: string;
369
370
  readonly 'x-maxItems-message'?: string;
370
371
  readonly 'x-minProperties-message'?: string;
@@ -1,5 +1,5 @@
1
1
  import "./index-DqcEtGVl.js";
2
- import "./index-DvZscmYm.js";
2
+ import "./index-DN54hj9W.js";
3
3
  import { Effect } from "effect";
4
4
  /**
5
5
  * The group an operation belongs to. Every operation belongs to one: the resource its path
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { J as HOOK_LIBRARIES, U as COMPONENT_NAMES, X as IDENTIFIER_PATTERN, m as isInputPath } from "./guard-D-yHkxqE.js";
1
+ import { $ as IDENTIFIER_PATTERN, K as COMPONENT_NAMES, Z as HOOK_LIBRARIES, _ as isInputPath } from "./guard-BNQ9WfOm.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";
@@ -1,5 +1,5 @@
1
- import { A as isRefOnly, B as isUntypedObject, D as isPathItemRef, E as isPathItemEntry, G as COMPONENT_SUFFIXES$1, H as ARROW_FUNCTION_PATTERN, K as FORM_MEDIA_TYPES, M as isResponses, N as isSchemaArray, O as isRecord, P as isSchemaObject, R as isSingleSchema, T as isPathItem, U as COMPONENT_NAMES, V as isValidIdent, W as COMPONENT_REF_PREFIX, Y as HTTP_METHODS, _ as isOffsetTime, a as hasTypelessConstraint, c as isDiscriminableBranch, f as isInheritedName, h as isMedia, k as isRefObject, l as isExamplesInput, n as hasNoUserChain, o as isBinaryFile, s as isCallbacks, u as isHeader, w as isParameterRef, x as isParameter, y as isOperation } from "./guard-D-yHkxqE.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-Kv3B0qkM.js";
1
+ import { A as isPathItemRef, D as isParameterRef, F as isResponses, G as ARROW_FUNCTION_PATTERN, I as isSchemaArray, J as COMPONENT_SUFFIXES$1, K as COMPONENT_NAMES, L as isSchemaObject, M as isRefObject, N as isRefOnly, O as isPathItem, Q as HTTP_METHODS, S as isOperation, U as isUntypedObject, V as isSingleSchema, W as isValidIdent, Y as FORM_MEDIA_TYPES, b as isOffsetTime, c as isAnnotationOnly, d as isDiscriminableBranch, f as isExamplesInput, h as isInheritedName, i as hasNoUserChain, j as isRecord, k as isPathItemEntry, l as isBinaryFile, n as hasMimeAlternatives, p as isHeader, q as COMPONENT_REF_PREFIX, s as hasTypelessConstraint, t as fileMimeTypes, u as isCallbacks, v as isMedia, w as isParameter } from "./guard-BNQ9WfOm.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-BhQ-YVD3.js";
3
3
  import path from "node:path";
4
4
  import { parseSync, rawTransferSupported, visitorKeys } from "oxc-parser";
5
5
  // src/helper/wire.ts
@@ -1028,6 +1028,71 @@ const SCHEMA_OBJECT_KEYS = /* @__PURE__ */ new Set([
1028
1028
  function isSchemaObjectKey(key) {
1029
1029
  return SCHEMA_OBJECT_KEYS.has(key) || key.startsWith("x-");
1030
1030
  }
1031
+ const TYPE_NAMES = /* @__PURE__ */ new Set([
1032
+ "integer",
1033
+ "number",
1034
+ "string",
1035
+ "boolean",
1036
+ "object",
1037
+ "null",
1038
+ "array"
1039
+ ]);
1040
+ function isTypeName(value) {
1041
+ return typeof value === "string" && TYPE_NAMES.has(value);
1042
+ }
1043
+ /**
1044
+ * What each Schema Object key's value is: the type `.openapi()` and `param.schema` take for
1045
+ * it. A value of another type does not type-check once written (#419) — a `minimum` written
1046
+ * as text (`"'created_at' - 21 days"`, Revolut), a `discriminator` without its
1047
+ * `propertyName` — so it is left out, as a key the Schema Object has not is. `exclusiveMinimum`
1048
+ * and `exclusiveMaximum` are numbers in 3.1 and booleans in 3.0; `type` is a type name or a
1049
+ * list of them. A key absent here (`default`, `example`, `const`) takes any value.
1050
+ */
1051
+ const SCHEMA_OBJECT_VALUE_TYPES = {
1052
+ $ref: (v) => typeof v === "string",
1053
+ discriminator: (v) => isRecord(v) && typeof v.propertyName === "string",
1054
+ readOnly: (v) => typeof v === "boolean",
1055
+ writeOnly: (v) => typeof v === "boolean",
1056
+ deprecated: (v) => typeof v === "boolean",
1057
+ uniqueItems: (v) => typeof v === "boolean",
1058
+ nullable: (v) => typeof v === "boolean",
1059
+ xml: isRecord,
1060
+ externalDocs: (v) => isRecord(v) && typeof v.url === "string",
1061
+ type: (v) => isTypeName(v) || Array.isArray(v) && v.length > 0 && v.every(isTypeName),
1062
+ format: (v) => typeof v === "string",
1063
+ description: (v) => typeof v === "string",
1064
+ title: (v) => typeof v === "string",
1065
+ pattern: (v) => typeof v === "string",
1066
+ contentMediaType: (v) => typeof v === "string",
1067
+ contentEncoding: (v) => typeof v === "string",
1068
+ multipleOf: (v) => typeof v === "number",
1069
+ maximum: (v) => typeof v === "number",
1070
+ minimum: (v) => typeof v === "number",
1071
+ exclusiveMaximum: (v) => typeof v === "number" || typeof v === "boolean",
1072
+ exclusiveMinimum: (v) => typeof v === "number" || typeof v === "boolean",
1073
+ maxLength: (v) => typeof v === "number",
1074
+ minLength: (v) => typeof v === "number",
1075
+ maxItems: (v) => typeof v === "number",
1076
+ minItems: (v) => typeof v === "number",
1077
+ maxProperties: (v) => typeof v === "number",
1078
+ minProperties: (v) => typeof v === "number",
1079
+ required: Array.isArray,
1080
+ enum: Array.isArray,
1081
+ allOf: Array.isArray,
1082
+ oneOf: Array.isArray,
1083
+ anyOf: Array.isArray,
1084
+ prefixItems: Array.isArray,
1085
+ items: isRecord,
1086
+ not: isRecord,
1087
+ propertyNames: isRecord,
1088
+ additionalProperties: (v) => typeof v === "boolean" || isRecord(v),
1089
+ properties: isRecord
1090
+ };
1091
+ /** Whether a Schema Object key's value has the type the key takes. */
1092
+ function hasSchemaObjectValueType(key, value) {
1093
+ const check = SCHEMA_OBJECT_VALUE_TYPES[key];
1094
+ return check === void 0 || check(value);
1095
+ }
1031
1096
  const SCHEMA_VALUED_KEYS = /* @__PURE__ */ new Set([
1032
1097
  "items",
1033
1098
  "not",
@@ -1042,19 +1107,17 @@ const SCHEMA_LIST_KEYS = /* @__PURE__ */ new Set([
1042
1107
  ]);
1043
1108
  const SCHEMA_MAP_KEYS = /* @__PURE__ */ new Set(["properties"]);
1044
1109
  /**
1045
- * A schema as a Schema Object for the document: only the keys a Schema Object has, at
1046
- * every level. `items` as a boolean or a tuple, and `not` as a boolean, are JSON Schema
1047
- * shapes the Schema Object has not; a `required` member YAML read as a literal (`null`,
1048
- * `true`) is a string; a 3.0-style `examples` map is its values. The output is what
1049
- * `.openapi()` is handed, so nothing in it may fail to type-check.
1110
+ * A schema as a Schema Object for the document: only the keys a Schema Object has, each
1111
+ * with a value of the type it takes, at every level. A `required` member YAML read as a
1112
+ * literal (`null`, `true`) is a string; a 3.0-style `examples` map is its values. The output
1113
+ * is what `.openapi()` is handed, so nothing in it may fail to type-check.
1050
1114
  */
1051
1115
  function pruneSchemaObject(schema) {
1052
1116
  if (!isRecord(schema)) return schema;
1053
1117
  const pruned = {};
1054
1118
  for (const [key, value] of Object.entries(schema)) {
1055
1119
  if (value === void 0 || !isSchemaObjectKey(key)) continue;
1056
- if (key === "items" && (typeof value === "boolean" || Array.isArray(value))) continue;
1057
- if (key === "not" && typeof value === "boolean") continue;
1120
+ if (!hasSchemaObjectValueType(key, value)) continue;
1058
1121
  if (key === "required" && Array.isArray(value)) {
1059
1122
  pruned[key] = value.map((v) => typeof v === "string" ? v : String(v));
1060
1123
  continue;
@@ -1065,7 +1128,11 @@ function pruneSchemaObject(schema) {
1065
1128
  continue;
1066
1129
  }
1067
1130
  if (key === "discriminator" && isRecord(value)) {
1068
- pruned[key] = Object.fromEntries(Object.entries(value).filter(([k]) => k === "propertyName" || k === "mapping"));
1131
+ const mapping = isRecord(value.mapping) ? Object.entries(value.mapping).filter(([, v]) => typeof v === "string") : void 0;
1132
+ pruned[key] = {
1133
+ propertyName: value.propertyName,
1134
+ ...mapping === void 0 ? {} : { mapping: Object.fromEntries(mapping) }
1135
+ };
1069
1136
  continue;
1070
1137
  }
1071
1138
  if (SCHEMA_VALUED_KEYS.has(key)) {
@@ -1148,6 +1215,7 @@ const zodExpressedProps = /* @__PURE__ */ new Set([
1148
1215
  "x-dependentSchemas-message",
1149
1216
  "x-minLength-message",
1150
1217
  "x-maxLength-message",
1218
+ "x-contentMediaType-message",
1151
1219
  "x-minItems-message",
1152
1220
  "x-maxItems-message",
1153
1221
  "x-minProperties-message",
@@ -1471,7 +1539,14 @@ function wrap(zod, schema, meta, options) {
1471
1539
  ].filter((v) => v !== void 0) : [];
1472
1540
  const openapiSchema = args ? JSON.stringify(args) : void 0;
1473
1541
  const openapiSchemaBody = openapiSchema?.startsWith("{") && openapiSchema?.endsWith("}") ? openapiSchema.slice(1, -1) : openapiSchema;
1474
- const fileMetaProps = isFile ? [isNullable ? "type:[\"string\",\"null\"]" : "type:\"string\"", "format:\"binary\""] : [];
1542
+ const fileMimes = isFile ? fileMimeTypes(schema) : void 0;
1543
+ const fileMetaProps = isFile ? [
1544
+ isNullable ? "type:[\"string\",\"null\"]" : "type:\"string\"",
1545
+ "format:\"binary\"",
1546
+ ...typeof schema.minLength === "number" ? [`minLength:${schema.minLength}`] : [],
1547
+ ...typeof schema.maxLength === "number" ? [`maxLength:${schema.maxLength}`] : [],
1548
+ ...fileMimes === void 0 ? [] : [`anyOf:${JSON.stringify(fileMimes.map((contentMediaType) => ({ contentMediaType })))}`]
1549
+ ] : [];
1475
1550
  const timeMetaProps = schema.format === "time" && schema["x-isoOffset"] !== false && typeList.includes("string") && schema.contentEncoding === void 0 && schema.contentMediaType === void 0 && schema.contentSchema === void 0 && hasNoUserChain(schema) ? ["format:\"time\""] : [];
1476
1551
  const bigintMetaProps = isBigintInteger ? [
1477
1552
  isNullable ? "type:[\"integer\",\"null\"]" : "type:\"integer\"",
@@ -1958,7 +2033,7 @@ function number(schema) {
1958
2033
  const base = wantsCoerce && !isFloat32 && !isFloat64 ? `z.coerce.number(${baseErrorArg})` : isFloat32 ? `z.float32(${baseErrorArg})` : isFloat64 ? `z.float64(${baseErrorArg})` : `z.number(${baseErrorArg})`;
1959
2034
  const { arg: minErrorArg, part: minErrorPart, exclusiveArg: exMinErrorArg, exclusivePart: exMinErrorPart } = makeBoundErrorArgs(schema, "minimum", errorMessage);
1960
2035
  const minimum = (() => {
1961
- if (schema.minimum !== void 0) {
2036
+ if (typeof schema.minimum === "number") {
1962
2037
  if (schema.minimum === 0 && schema.exclusiveMinimum === true) return `.positive(${exMinErrorArg})`;
1963
2038
  if (schema.minimum === 0 && schema.exclusiveMinimum === false) return `.nonnegative(${minErrorArg})`;
1964
2039
  if (schema.exclusiveMinimum === true) return `.gt(${schema.minimum}${exMinErrorPart})`;
@@ -1968,7 +2043,7 @@ function number(schema) {
1968
2043
  })();
1969
2044
  const { arg: maxErrorArg, part: maxErrorPart, exclusiveArg: exMaxErrorArg, exclusivePart: exMaxErrorPart } = makeBoundErrorArgs(schema, "maximum", errorMessage);
1970
2045
  const maximum = (() => {
1971
- if (schema.maximum !== void 0) {
2046
+ if (typeof schema.maximum === "number") {
1972
2047
  if (schema.maximum === 0 && schema.exclusiveMaximum === true) return `.negative(${exMaxErrorArg})`;
1973
2048
  if (schema.maximum === 0 && schema.exclusiveMaximum === false) return `.nonpositive(${maxErrorArg})`;
1974
2049
  if (schema.exclusiveMaximum === true) return `.lt(${schema.maximum}${exMaxErrorPart})`;
@@ -1982,7 +2057,7 @@ function number(schema) {
1982
2057
  base,
1983
2058
  minimum,
1984
2059
  maximum,
1985
- schema.multipleOf !== void 0 ? `.multipleOf(${schema.multipleOf}${multipleOfErrorArg})` : void 0
2060
+ typeof schema.multipleOf === "number" ? `.multipleOf(${schema.multipleOf}${multipleOfErrorArg})` : void 0
1986
2061
  ].filter((v) => v !== void 0).join("");
1987
2062
  return wirePipe ? `z.coerce.number(${baseErrorArg}).pipe(${innerChain})` : innerChain;
1988
2063
  }
@@ -2174,7 +2249,7 @@ function string(schema, options) {
2174
2249
  const enc = schema.contentEncoding;
2175
2250
  const mediaType = schema.contentMediaType;
2176
2251
  const contentSchema = schema.contentSchema;
2177
- if ((enc !== void 0 || mediaType !== void 0 || contentSchema !== void 0) && !hashBase) return `${(() => {
2252
+ if ((enc !== void 0 || mediaType !== void 0 || contentSchema !== void 0) && !hashBase && !isBinaryFile(schema)) return `${(() => {
2178
2253
  if (enc === "base64") return "z.base64()";
2179
2254
  if (enc === "base64url") return "z.base64url()";
2180
2255
  return "z.string()";
@@ -2239,6 +2314,10 @@ function string(schema, options) {
2239
2314
  const maxLengthMessage = schema["x-maxLength-message"] ?? errorMessage;
2240
2315
  const maxLengthMessagePart = maxLengthMessage ? `,${error(maxLengthMessage)}` : "";
2241
2316
  const isFixedLength = schema.minLength !== void 0 && schema.maxLength !== void 0 && schema.minLength === schema.maxLength;
2317
+ const mimeTypes = isBinaryFile(schema) ? fileMimeTypes(schema) : void 0;
2318
+ const mimeMessage = schema["x-contentMediaType-message"] ?? errorMessage;
2319
+ const mimeMessagePart = mimeMessage ? `,${error(mimeMessage)}` : "";
2320
+ const mime = mimeTypes === void 0 ? void 0 : `.mime(${JSON.stringify(mimeTypes.length === 1 ? mimeTypes[0] : mimeTypes)}${mimeMessagePart})`;
2242
2321
  const includes = schema["x-includes"] !== void 0 ? `.includes(${JSON.stringify(schema["x-includes"])})` : void 0;
2243
2322
  const startsWith = schema["x-startsWith"] !== void 0 ? `.startsWith(${JSON.stringify(schema["x-startsWith"])})` : void 0;
2244
2323
  const endsWith = schema["x-endsWith"] !== void 0 ? `.endsWith(${JSON.stringify(schema["x-endsWith"])})` : void 0;
@@ -2254,6 +2333,7 @@ function string(schema, options) {
2254
2333
  isFixedLength ? `.length(${schema.minLength}${lengthMessagePart})` : void 0,
2255
2334
  !isFixedLength && schema.minLength !== void 0 ? `.min(${schema.minLength}${minLengthMessagePart})` : void 0,
2256
2335
  !isFixedLength && schema.maxLength !== void 0 ? `.max(${schema.maxLength}${maxLengthMessagePart})` : void 0,
2336
+ mime,
2257
2337
  includes,
2258
2338
  startsWith,
2259
2339
  endsWith,
@@ -2338,17 +2418,17 @@ function zodToOpenAPI(schema, meta, options) {
2338
2418
  ...schema.required ? { required: schema.required } : {}
2339
2419
  }] : schema.allOf;
2340
2420
  if (effectiveAllOf.length === 0) return done("z.any()", schema);
2341
- const nullable = schema.nullable === true || (Array.isArray(schema.type) ? schema.type.includes("null") : schema.type === "null") || effectiveAllOf.some((s) => s.type === "null" || s.nullable === true && Object.keys(s).length === 1);
2421
+ const nullable = schema.nullable === true || (Array.isArray(schema.type) ? schema.type.includes("null") : schema.type === "null") || effectiveAllOf.some((s) => s.type === "null" || s.nullable === true && isAnnotationOnly(s));
2342
2422
  const nonNull = effectiveAllOf.filter((s) => !(s.type === "null" || s.nullable === true && Object.keys(s).length === 1)).map((s) => inheritedBase(s, childOptions?.schemas) ?? s);
2343
- if (nonNull.length === 0) return done("z.any()", {
2423
+ const members = nonNull.filter((s) => !isAnnotationOnly(s));
2424
+ const emitted = {
2425
+ ...nonNull.filter(isAnnotationOnly).reduce((acc, s) => Object.assign(acc, s), {}),
2344
2426
  ...schema,
2345
2427
  nullable
2346
- });
2347
- const schemas = nonNull.map(child);
2348
- if (schemas.length === 1 && nonNull.every(isRefOnly) && Object.keys(schema).every((k) => k === "allOf" || k === "nullable" || k === "type")) return done(schemas[0], {
2349
- ...schema,
2350
- nullable
2351
- }, true);
2428
+ };
2429
+ if (members.length === 0) return done("z.any()", emitted);
2430
+ const schemas = members.map(child);
2431
+ if (schemas.length === 1 && members.every(isRefOnly) && Object.keys(schema).every((k) => k === "allOf" || k === "nullable" || k === "type")) return done(schemas[0], emitted, true);
2352
2432
  const z = schemas.reduce((acc, s, i) => i === 0 ? s : `${acc}.and(${s})`);
2353
2433
  const allOfMessage = schema["x-allOf-message"] ?? schema["x-error-message"];
2354
2434
  const unevalCheck = makeUnevaluatedPropertiesCheck({
@@ -2359,16 +2439,10 @@ function zodToOpenAPI(schema, meta, options) {
2359
2439
  const isArrow = allOfMessage ? ARROW_FUNCTION_PATTERN.test(allOfMessage) : false;
2360
2440
  const msgExpr = allOfMessage ? isArrow ? `(${allOfMessage})(issue)` : JSON.stringify(allOfMessage) : void 0;
2361
2441
  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}")}}}`;
2362
- })()}${unevalCheck ? `;(${unevalCheck})(ctx)` : ""}}).pipe(Schema)})()`, {
2363
- ...schema,
2364
- nullable
2365
- });
2366
- return done(z, {
2367
- ...schema,
2368
- nullable
2369
- }, schemas.length === 1 && nonNull.every(isRefOnly));
2442
+ })()}${unevalCheck ? `;(${unevalCheck})(ctx)` : ""}}).pipe(Schema)})()`, emitted);
2443
+ return done(z, emitted, schemas.length === 1 && members.every(isRefOnly));
2370
2444
  }
2371
- if (schema.anyOf !== void 0) {
2445
+ if (schema.anyOf !== void 0 && !(isBinaryFile(schema) && hasMimeAlternatives(schema))) {
2372
2446
  if (schema.anyOf.length === 0) return done("z.any()", schema);
2373
2447
  const anyOfSchemas = schema.anyOf.map(child);
2374
2448
  const anyOfMessage = schema["x-implication-message"] ?? schema["x-anyOf-message"] ?? schema["x-error-message"];
@@ -0,0 +1,96 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
+ import { j as isRecord } from "./guard-BNQ9WfOm.js";
3
+ import { Data, Effect } from "effect";
4
+ import path from "node:path";
5
+ import net from "node:net";
6
+ import SwaggerParser from "@apidevtools/swagger-parser";
7
+ // src/openapi/index.ts
8
+ /**
9
+ * Uses `bundle()` to resolve external $refs while preserving internal ones.
10
+ * This enables variable references (e.g., `UserSchema`) instead of duplicated inline schemas,
11
+ * supports circular references via `z.lazy()`, and allows dependency-aware topological sorting.
12
+ *
13
+ * @see https://apitools.dev/swagger-parser/docs/
14
+ */
15
+ var openapi_exports = /* @__PURE__ */ __exportAll({
16
+ CONNECT_ATTEMPT_TIMEOUT_MS: () => CONNECT_ATTEMPT_TIMEOUT_MS,
17
+ parseOpenAPI: () => parseOpenAPI
18
+ });
19
+ var OpenAPIError = class extends Data.TaggedError("OpenAPIError") {};
20
+ /**
21
+ * How long one connection attempt is given before the next address is tried, in
22
+ * milliseconds. Node's default is 250 ms: a host with an AAAA record is connected to with
23
+ * happy eyeballs, so where IPv6 is unreachable an IPv4 handshake slower than that is cut off,
24
+ * the IPv6 attempt fails at once, and the download ends in `ETIMEDOUT` where `curl` and
25
+ * `fetch` succeed (#395, Hetzner, Unleash). A handshake across a continent takes under a
26
+ * second; two also cover a SYN lost once, which Linux resends after one.
27
+ */
28
+ const CONNECT_ATTEMPT_TIMEOUT_MS = 2e3;
29
+ /**
30
+ * `run`, with every connection attempt it makes given {@link CONNECT_ATTEMPT_TIMEOUT_MS} at
31
+ * least. The ref parser pins a download to the addresses it validated and takes no option for
32
+ * the attempt timeout, so the process-wide default is raised for the duration and put back
33
+ * afterwards; one set higher (`--network-family-autoselection-attempt-timeout`) is kept.
34
+ */
35
+ async function withPatientConnect(run) {
36
+ const previous = net.getDefaultAutoSelectFamilyAttemptTimeout();
37
+ if (previous >= 2e3) return run();
38
+ net.setDefaultAutoSelectFamilyAttemptTimeout(CONNECT_ATTEMPT_TIMEOUT_MS);
39
+ try {
40
+ return await run();
41
+ } finally {
42
+ net.setDefaultAutoSelectFamilyAttemptTimeout(previous);
43
+ }
44
+ }
45
+ /** The end of swagger-parser's message for a document with neither `paths` nor `webhooks`. */
46
+ const INVALID_DEFINITION = "is not a valid Openapi API definition";
47
+ /**
48
+ * The document as written, read by the ref parser swagger-parser extends: its static `parse`
49
+ * reads one file or URL as JSON or YAML and checks nothing about OpenAPI.
50
+ */
51
+ async function readDocument(input) {
52
+ const base = Object.getPrototypeOf(SwaggerParser);
53
+ if (typeof base !== "function" || !("parse" in base) || typeof base.parse !== "function") throw new TypeError("The ref parser swagger-parser extends has no parse");
54
+ const document = await Reflect.apply(base.parse, base, [input]);
55
+ return isRecord(document) ? document : {};
56
+ }
57
+ /**
58
+ * The document, bundled. swagger-parser rejects a 3.1 document with neither `paths` nor
59
+ * `webhooks` as "not a valid Openapi API definition", though OpenAPI 3.1 asks for one of
60
+ * `paths`, `components` and `webhooks`: a document of components alone is a shared schema
61
+ * library (#417). Such a document is read and handed over again with an empty `paths`, which
62
+ * says the same.
63
+ */
64
+ async function bundle(input) {
65
+ try {
66
+ return await SwaggerParser.bundle(input);
67
+ } catch (error) {
68
+ if (!(error instanceof SyntaxError && error.message.endsWith(INVALID_DEFINITION))) throw error;
69
+ const document = await readDocument(input);
70
+ if (!(typeof document.openapi === "string" && document.openapi.startsWith("3.1") && document.paths === void 0 && document.webhooks === void 0 && isRecord(document.components))) throw error;
71
+ return SwaggerParser.bundle(input, {
72
+ ...document,
73
+ paths: {}
74
+ }, {});
75
+ }
76
+ }
77
+ function parseOpenAPI(input) {
78
+ return Effect.tryPromise({
79
+ try: async () => {
80
+ if (!input.endsWith(".tsp")) return await withPatientConnect(() => bundle(input));
81
+ const [{ compile, NodeHost }, { getOpenAPI3 }] = await Promise.all([import("@typespec/compiler"), import("@typespec/openapi3")]);
82
+ const program = await compile(NodeHost, path.resolve(input), { noEmit: true });
83
+ if (program.diagnostics.length > 0) throw new Error(`TypeSpec compile failed:\n${program.diagnostics.map((d) => d.message).join("\n")}`);
84
+ const [record] = await getOpenAPI3(program);
85
+ const document = record && ("document" in record ? record.document : record.versions[0]?.document);
86
+ if (!document) throw new Error(`TypeSpec emitted no OpenAPI document: ${input}`);
87
+ return document;
88
+ },
89
+ catch: (error) => {
90
+ if (!(error instanceof Error)) return new OpenAPIError({ message: String(error) });
91
+ const code = "ioErrorCode" in error ? error.ioErrorCode : void 0;
92
+ return new OpenAPIError({ message: (!error.message.trim() || error.message.trimEnd().endsWith(":")) && typeof code === "string" && code ? `${error.message}${code}` : error.message });
93
+ }
94
+ });
95
+ }
96
+ export { parseOpenAPI as n, openapi_exports as t };
@@ -1,4 +1,4 @@
1
- import { C as isParameterObject, F as isSchemaProperty, K as FORM_MEDIA_TYPES, O as isRecord, Q as JSON_MEDIA_TYPE, V as isValidIdent, b as isOperationLike, k as isRefObject } from "./guard-D-yHkxqE.js";
1
+ import { C as isOperationLike, E as isParameterObject, M as isRefObject, R as isSchemaProperty, W as isValidIdent, Y as FORM_MEDIA_TYPES, j as isRecord, tt as JSON_MEDIA_TYPE } from "./guard-BNQ9WfOm.js";
2
2
  // src/helper/group.ts
3
3
  const RESERVED = /* @__PURE__ */ new Set([
4
4
  "arguments",
@@ -1,11 +1,11 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
- import { J as HOOK_LIBRARIES, U as COMPONENT_NAMES } from "./guard-D-yHkxqE.js";
2
+ import { K as COMPONENT_NAMES, Z as HOOK_LIBRARIES } from "./guard-BNQ9WfOm.js";
3
3
  import { i as GenerateError } from "./format-BF7SbaMP.js";
4
- import { u as normalizeOpenAPI } from "./openapi-D9J3Kaij.js";
5
- 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-BFsWwAXx.js";
4
+ import { u as normalizeOpenAPI } from "./openapi-Bk4KBGJZ.js";
5
+ 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-C-wH_UxC.js";
6
6
  import { a as unlink, i as readdir, t as exists } from "./file-Bip_L0oR.js";
7
- import { t as hooks } from "./hooks-Cu1bRToh.js";
8
- import { t as docs } from "./docs-MRoh0U3g.js";
7
+ import { t as hooks } from "./hooks-JLvbNojU.js";
8
+ import { t as docs } from "./docs-CDp93aXs.js";
9
9
  import { rpc } from "./core/rpc/index.js";
10
10
  import { type } from "./core/type/index.js";
11
11
  import { Effect, FileSystem, Schema } from "effect";
@@ -1,4 +1,4 @@
1
- import { H as ARROW_FUNCTION_PATTERN, X as IDENTIFIER_PATTERN } from "./guard-D-yHkxqE.js";
1
+ import { $ as IDENTIFIER_PATTERN, G as ARROW_FUNCTION_PATTERN } from "./guard-BNQ9WfOm.js";
2
2
  // src/utils/index.ts
3
3
  /**
4
4
  * Normalize a JSON Schema `type` value into an array of type strings.
@@ -1,9 +1,9 @@
1
- import { O as isRecord, Z as INPUT_EXTENSIONS } from "../guard-D-yHkxqE.js";
1
+ import { et as INPUT_EXTENSIONS, j as isRecord } from "../guard-BNQ9WfOm.js";
2
2
  import { parseConfig } from "../index.js";
3
3
  import { t as FormatOptions } from "../format-BF7SbaMP.js";
4
- import { C as isInsideDirectory, S as appEntryOutput } from "../core-BFsWwAXx.js";
5
- import { n as parseOpenAPI } from "../openapi-tYYvoKiU.js";
6
- import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BNo1Lr1g.js";
4
+ import { C as isInsideDirectory, S as appEntryOutput } from "../core-C-wH_UxC.js";
5
+ import { n as parseOpenAPI } from "../openapi-DCo11_TE.js";
6
+ import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-BBl5tC8y.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.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",
@@ -56,20 +56,20 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@apidevtools/swagger-parser": "^13.1.0",
59
- "@effect/platform-node": "4.0.6",
59
+ "@effect/platform-node": "4.1.2",
60
60
  "@typespec/compiler": "^1.17.0",
61
61
  "@typespec/openapi3": "^1.17.0",
62
- "effect": "4.0.6",
63
- "oxc-parser": "^0.155.0",
64
- "oxfmt": "^0.74.0"
62
+ "effect": "4.1.2",
63
+ "oxc-parser": "^0.157.0",
64
+ "oxfmt": "^0.75.0"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@faker-js/faker": "^10.6.0",
68
68
  "@hono/zod-openapi": "^1.6.3",
69
- "@types/node": "^26.6.5",
69
+ "@types/node": "^26.6.6",
70
70
  "@typespec/http": "^1.17.0",
71
71
  "@typespec/rest": "^0.87.0",
72
- "hono": "^4.13.13",
72
+ "hono": "^4.13.16",
73
73
  "typescript": "^7.0.2",
74
74
  "zod": "^4.6.7"
75
75
  },
@@ -1,34 +0,0 @@
1
- import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
- import { Data, Effect } from "effect";
3
- import path from "node:path";
4
- import SwaggerParser from "@apidevtools/swagger-parser";
5
- // src/openapi/index.ts
6
- /**
7
- * Uses `bundle()` to resolve external $refs while preserving internal ones.
8
- * This enables variable references (e.g., `UserSchema`) instead of duplicated inline schemas,
9
- * supports circular references via `z.lazy()`, and allows dependency-aware topological sorting.
10
- *
11
- * @see https://apitools.dev/swagger-parser/docs/
12
- */
13
- var openapi_exports = /* @__PURE__ */ __exportAll({ parseOpenAPI: () => parseOpenAPI });
14
- var OpenAPIError = class extends Data.TaggedError("OpenAPIError") {};
15
- function parseOpenAPI(input) {
16
- return Effect.tryPromise({
17
- try: async () => {
18
- if (!input.endsWith(".tsp")) return await SwaggerParser.bundle(input);
19
- const [{ compile, NodeHost }, { getOpenAPI3 }] = await Promise.all([import("@typespec/compiler"), import("@typespec/openapi3")]);
20
- const program = await compile(NodeHost, path.resolve(input), { noEmit: true });
21
- if (program.diagnostics.length > 0) throw new Error(`TypeSpec compile failed:\n${program.diagnostics.map((d) => d.message).join("\n")}`);
22
- const [record] = await getOpenAPI3(program);
23
- const document = record && ("document" in record ? record.document : record.versions[0]?.document);
24
- if (!document) throw new Error(`TypeSpec emitted no OpenAPI document: ${input}`);
25
- return document;
26
- },
27
- catch: (error) => {
28
- if (!(error instanceof Error)) return new OpenAPIError({ message: String(error) });
29
- const code = "ioErrorCode" in error ? error.ioErrorCode : void 0;
30
- return new OpenAPIError({ message: (!error.message.trim() || error.message.trimEnd().endsWith(":")) && typeof code === "string" && code ? `${error.message}${code}` : error.message });
31
- }
32
- });
33
- }
34
- export { parseOpenAPI as n, openapi_exports as t };