hono-takibi 0.18.0 → 0.19.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,19 +1,16 @@
1
1
  #!/usr/bin/env node
2
+ import { l as INPUT_EXTENSIONS } from "./constants-Bz8YiPum.js";
2
3
  import { NodeRuntime, NodeServices } from "@effect/platform-node";
3
4
  import { Console, Effect, FileSystem, Option, Path, Ref, Schema, Stream } from "effect";
4
5
  import { Argument, CliError, Command, Flag } from "effect/cli";
5
6
  //#region package.json
6
- var version = "0.18.0";
7
+ var version = "0.19.0";
7
8
  var description = "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi";
8
9
  //#endregion
9
10
  //#region src/cli/index.ts
10
11
  const COMMAND_NAME = "hono-takibi";
11
12
  const DEFAULT_CONFIG_FILE = "hono-takibi.config.ts";
12
- const DocumentPathSchema = Schema.String.pipe(Schema.refine(Schema.is(Schema.TemplateLiteral([Schema.String, Schema.Literals([
13
- ".yaml",
14
- ".json",
15
- ".tsp"
16
- ])])), { message: "an OpenAPI (.yaml, .json) or TypeSpec (.tsp) document" })).annotate({
13
+ const DocumentPathSchema = Schema.String.pipe(Schema.refine(Schema.is(Schema.TemplateLiteral([Schema.String, Schema.Literals(INPUT_EXTENSIONS)])), { message: "an OpenAPI (.yaml, .json) or TypeSpec (.tsp) document" })).annotate({
17
14
  title: "Input document",
18
15
  description: "OpenAPI or TypeSpec document the one-shot mode generates from.",
19
16
  examples: [
@@ -33,11 +30,6 @@ const commandLine = {
33
30
  config: Flag.File("config", { mustExist: true }).pipe(Flag.withAlias("c"), Flag.withDescription(`Config file to run (default: ./${DEFAULT_CONFIG_FILE})`), Flag.withMetavar("file"), Flag.optional),
34
31
  watch: Flag.Boolean("watch").pipe(Flag.withAlias("w"), Flag.withDescription("Rerun the config on every change to its documents or itself"), Flag.withDefault(false))
35
32
  };
36
- const INPUT_EXTENSIONS = [
37
- ".yaml",
38
- ".json",
39
- ".tsp"
40
- ];
41
33
  function loadConfig(configPath, reload) {
42
34
  return Effect.gen(function* () {
43
35
  const { readConfig } = yield* Effect.promise(() => import("./index.js"));
@@ -49,7 +41,7 @@ function runJobs(config) {
49
41
  const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob, packageRoots }] = yield* Effect.promise(() => Promise.all([
50
42
  import("./openapi-DQRxq2_O.js").then((n) => n.t),
51
43
  import("./format-CuHABcKC.js").then((n) => n.r),
52
- import("./shared-CMgxc-KQ.js").then((n) => n.a)
44
+ import("./shared-DBOBTH7X.js").then((n) => n.a)
53
45
  ]));
54
46
  const openAPI = yield* parseOpenAPI(config.input);
55
47
  const jobs = makeJob(openAPI, config, yield* packageRoots(openAPI, config));
@@ -87,7 +79,7 @@ function reportJobs(config, previous) {
87
79
  onFailure: (error) => Console.error(`❌ ${error.message}`),
88
80
  onSuccess: (report) => Console.log(report)
89
81
  }));
90
- const { outsideSources } = yield* Effect.promise(() => import("./shared-CMgxc-KQ.js").then((n) => n.a));
82
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-DBOBTH7X.js").then((n) => n.a));
91
83
  const inputDirectory = path.dirname(path.resolve(config.input));
92
84
  return {
93
85
  inputDirectory,
@@ -214,7 +206,7 @@ function generate(args) {
214
206
  })]
215
207
  });
216
208
  if (input !== void 0 && output !== void 0) {
217
- const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-BuSZBtYC.js").then((n) => n.t)]));
209
+ const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-CHLeBQ6y.js").then((n) => n.t)]));
218
210
  return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output));
219
211
  }
220
212
  const resolvedConfig = configPath ?? DEFAULT_CONFIG_FILE;
@@ -0,0 +1,81 @@
1
+ //#region src/constants/index.ts
2
+ /** The kinds of the OpenAPI Components Object, in declaration and config-field order. */
3
+ const COMPONENT_NAMES = [
4
+ "schemas",
5
+ "responses",
6
+ "parameters",
7
+ "examples",
8
+ "requestBodies",
9
+ "headers",
10
+ "securitySchemes",
11
+ "links",
12
+ "callbacks",
13
+ "pathItems",
14
+ "mediaTypes"
15
+ ];
16
+ /** The extensions of an input document: OpenAPI as YAML or JSON, or a TypeSpec entry. */
17
+ const INPUT_EXTENSIONS = [
18
+ ".yaml",
19
+ ".json",
20
+ ".tsp"
21
+ ];
22
+ /** A JavaScript identifier that can be written bare: as a binding, or a key or member access. */
23
+ const IDENTIFIER_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;
24
+ /**
25
+ * A message option written as an arrow function, `(issue) => ...`, rather than as text.
26
+ * Such a message is spliced into the generated code as an expression instead of a string.
27
+ */
28
+ const ARROW_FUNCTION_PATTERN = /^\s*\(.*?\)\s*=>/u;
29
+ /** The media type of a JSON body, the default of a request or response body. */
30
+ const JSON_MEDIA_TYPE = "application/json";
31
+ /** The media type of a plain-text body. */
32
+ const TEXT_MEDIA_TYPE = "text/plain";
33
+ /** The media type of a URL-encoded form body. */
34
+ const FORM_URLENCODED_MEDIA_TYPE = "application/x-www-form-urlencoded";
35
+ /** The media type of a multipart form body. */
36
+ const MULTIPART_MEDIA_TYPE = "multipart/form-data";
37
+ /** The media type of an opaque binary body. */
38
+ const OCTET_STREAM_MEDIA_TYPE = "application/octet-stream";
39
+ /** The media types of a form body: every field arrives as text, or as a file. */
40
+ const FORM_MEDIA_TYPES = ["application/x-www-form-urlencoded", "multipart/form-data"];
41
+ /** The `$ref` prefix of each kind of component: `#/components/schemas/` for `schemas`. */
42
+ const COMPONENT_REF_PREFIX = {
43
+ schemas: "#/components/schemas/",
44
+ responses: "#/components/responses/",
45
+ parameters: "#/components/parameters/",
46
+ examples: "#/components/examples/",
47
+ requestBodies: "#/components/requestBodies/",
48
+ headers: "#/components/headers/",
49
+ securitySchemes: "#/components/securitySchemes/",
50
+ links: "#/components/links/",
51
+ callbacks: "#/components/callbacks/",
52
+ pathItems: "#/components/pathItems/",
53
+ mediaTypes: "#/components/mediaTypes/"
54
+ };
55
+ /** The query libraries the hooks are generated for, each a config key of its own. */
56
+ const HOOK_LIBRARIES = [
57
+ "swr",
58
+ "tanstack-query",
59
+ "preact-query",
60
+ "solid-query",
61
+ "vue-query",
62
+ "svelte-query",
63
+ "angular-query"
64
+ ];
65
+ /**
66
+ * The HTTP methods an OpenAPI path item can hold, in the order the specification lists
67
+ * them: OpenAPI 3.2 adds `query`. Operations of one path are generated in this order.
68
+ */
69
+ const HTTP_METHODS = [
70
+ "get",
71
+ "put",
72
+ "post",
73
+ "delete",
74
+ "options",
75
+ "head",
76
+ "patch",
77
+ "trace",
78
+ "query"
79
+ ];
80
+ //#endregion
81
+ export { FORM_URLENCODED_MEDIA_TYPE as a, IDENTIFIER_PATTERN as c, MULTIPART_MEDIA_TYPE as d, OCTET_STREAM_MEDIA_TYPE as f, FORM_MEDIA_TYPES as i, INPUT_EXTENSIONS as l, COMPONENT_NAMES as n, HOOK_LIBRARIES as o, TEXT_MEDIA_TYPE as p, COMPONENT_REF_PREFIX as r, HTTP_METHODS as s, ARROW_FUNCTION_PATTERN as t, JSON_MEDIA_TYPE as u };
@@ -1,2 +1,2 @@
1
- import { t as docs } from "../../docs-DJps1WGq.js";
1
+ import { t as docs } from "../../docs-y1jSJoJg.js";
2
2
  export { docs };
@@ -1,2 +1,2 @@
1
- import { t as hooks } from "../../hooks-CQMtSLZv.js";
1
+ import { t as hooks } from "../../hooks-xBFksKgW.js";
2
2
  export { hooks };
@@ -1,8 +1,8 @@
1
- import { r as HTTP_METHODS } from "../../constants-DlWc79pw.js";
1
+ import { s as HTTP_METHODS } from "../../constants-Bz8YiPum.js";
2
2
  import { i as GenerateError } from "../../format-CuHABcKC.js";
3
- import { D as isOpenAPIPaths, L as isRecord, f as methodPath, k as isOperationLike, l as makeInferRequestType } from "../../utils-7HBCrio0.js";
3
+ import { L as isOpenAPIPaths, f as methodPath, l as makeInferRequestType, q as isRecord, z as isOperationLike } from "../../utils-BCaOY0bs.js";
4
4
  import { t as emit } from "../../emit-uwlZZeRM.js";
5
- import { a as parsePathItem, c as operationTags, i as operationHasArgs, o as groupClientName, r as makeOperationDeps, t as formatPath } from "../../rpc-Bl9hcXCo.js";
5
+ import { a as groupClientName, i as parsePathItem, n as makeOperationDeps, r as operationHasArgs, s as operationTags, t as formatPath } from "../../rpc-b2oph6wk.js";
6
6
  import { Effect } from "effect";
7
7
  import { dirname } from "node:path";
8
8
  //#region src/core/rpc/index.ts
@@ -1,4 +1,5 @@
1
- import { A as isParameter, B as isRequestBody, D as isOpenAPIPaths, E as isMediaWithSchema, H as isSchemaArray, J as isStringRef, O as isOperation, g as statusCodeToNumber, j as isParameterArray, u as makeSafeKey, w as isHttpMethod } from "../../utils-7HBCrio0.js";
1
+ import "../../constants-Bz8YiPum.js";
2
+ import { B as isParameter, F as isMediaWithSchema, L as isOpenAPIPaths, Q as isSchemaArray, R as isOperation, V as isParameterArray, X as isRequestBody, g as statusCodeToNumber, it as isStringRef, j as isHttpMethod, u as makeSafeKey } from "../../utils-BCaOY0bs.js";
2
3
  import { t as emit } from "../../emit-uwlZZeRM.js";
3
4
  import { Effect } from "effect";
4
5
  import path from "node:path";
@@ -1,13 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { r as HTTP_METHODS, t as COMPONENT_NAMES } from "./constants-DlWc79pw.js";
2
+ import { n as COMPONENT_NAMES, p as TEXT_MEDIA_TYPE, r as COMPONENT_REF_PREFIX, s as HTTP_METHODS, u as JSON_MEDIA_TYPE } from "./constants-Bz8YiPum.js";
3
3
  import { i as GenerateError, n as fmt } from "./format-CuHABcKC.js";
4
- import { A as isParameter, D as isOpenAPIPaths, E as isMediaWithSchema, F as isPathItemEntry, G as isSecurityArray, H as isSchemaArray, I as isPathItemRef, K as isSecurityScheme, N as isParameterRef, O as isOperation, P as isPathItem, R as isRefObject, U as isSchemaObject, _ as toIdentifierPascalCase, b as zodToOpenAPISchema, c as makeBarrel, d as makeStringLiteral, f as methodPath, g as statusCodeToNumber, i as ensureSuffix, m as renderNamedImport, p as normalizeTypes, r as cyclicNodes, u as makeSafeKey, v as uncapitalize, w as isHttpMethod, x as isCallbacks, y as uncapitalizeWord } from "./utils-7HBCrio0.js";
5
- import { C as warnUnroutablePath, S as makeRequest, _ as makeCallback, a as responsesCode, b as makePathItem, c as headersCode, d as makeExportConst, f as makeImports, g as zodToOpenAPI, h as ast, i as schemasCode, l as makeSplitSchemaFile, m as analyzeCircularSchemas, n as routeCode, o as requestBodiesCode, p as makeModuleSpec, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as makeConst, v as makeCallbacks, x as makeRef, y as makeOperationResponses } from "./openapi-DsC_M1Um.js";
4
+ import { $ as isSchemaObject, B as isParameter, D as isCallbacks, F as isMediaWithSchema, G as isPathItemEntry, J as isRefObject, K as isPathItemRef, L as isOpenAPIPaths, N as isInlineMedia, Q as isSchemaArray, R as isOperation, T as hasRequestBodyContent, U as isParameterRef, W as isPathItem, _ as toIdentifierPascalCase, at as isValidIdent, b as zodToOpenAPISchema, c as makeBarrel, d as makeStringLiteral, f as methodPath, g as statusCodeToNumber, i as ensureSuffix, j as isHttpMethod, m as renderNamedImport, nt as isSecurityScheme, p as normalizeTypes, r as cyclicNodes, tt as isSecurityArray, u as makeSafeKey, v as uncapitalize, w as hasNumericConstraint, y as uncapitalizeWord } from "./utils-BCaOY0bs.js";
5
+ import { C as warnUnroutablePath, S as makeRequest, _ as makeCallback, a as responsesCode, b as makePathItem, c as headersCode, d as makeExportConst, f as makeImports, g as zodToOpenAPI, h as ast, i as schemasCode, l as makeSplitSchemaFile, m as analyzeCircularSchemas, n as routeCode, o as requestBodiesCode, p as makeModuleSpec, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as makeConst, v as makeCallbacks, x as makeRef, y as makeOperationResponses } from "./openapi-BlxQC7Xn.js";
6
6
  import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-K6j5IJXi.js";
7
7
  import { t as emit } from "./emit-uwlZZeRM.js";
8
- import { o as groupClientName, s as isGroupName } from "./rpc-Bl9hcXCo.js";
9
- import { t as hooks } from "./hooks-CQMtSLZv.js";
10
- import { t as docs } from "./docs-DJps1WGq.js";
8
+ import { a as groupClientName, o as isGroupName } from "./rpc-b2oph6wk.js";
9
+ import { t as hooks } from "./hooks-xBFksKgW.js";
10
+ import { t as docs } from "./docs-y1jSJoJg.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";
@@ -303,9 +303,6 @@ function exampleLiteral(schema) {
303
303
  }
304
304
  if (typeof example === "boolean") return isAccepted("boolean") ? `${example}${asConst}` : void 0;
305
305
  }
306
- function hasNumericConstraint(schema) {
307
- return schema.minimum !== void 0 || schema.maximum !== void 0 || schema.exclusiveMinimum !== void 0 || schema.exclusiveMaximum !== void 0 || schema.multipleOf !== void 0;
308
- }
309
306
  function shiftBound(bound, step) {
310
307
  return Number((bound + step).toFixed(12));
311
308
  }
@@ -596,7 +593,7 @@ function schemaValue(schema, propertyName, options = {}) {
596
593
  */
597
594
  function getNonExistentValue(schema, schemas) {
598
595
  if (!schema) return "__non_existent__";
599
- const resolved = schema.$ref && schemas ? schemas[schema.$ref.replace("#/components/schemas/", "")] ?? schema : schema;
596
+ const resolved = schema.$ref && schemas ? schemas[schema.$ref.replace(COMPONENT_REF_PREFIX.schemas, "")] ?? schema : schema;
600
597
  const types = normalizeTypes(resolved.type);
601
598
  const primary = TYPE_PRIORITY.find((t) => types.includes(t));
602
599
  if (primary === "integer" || primary === "number") return "-1";
@@ -1533,7 +1530,7 @@ function capitalizeFirst(name) {
1533
1530
  return `${name.charAt(0).toUpperCase()}${name.slice(1)}`;
1534
1531
  }
1535
1532
  function makeBasePathAccess(basePath) {
1536
- return basePath.split("/").filter((segment) => segment !== "").map((segment) => /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(segment) ? `.${segment}` : `['${segment.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}']`).join("");
1533
+ return basePath.split("/").filter((segment) => segment !== "").map((segment) => isValidIdent(segment) ? `.${segment}` : `['${segment.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}']`).join("");
1537
1534
  }
1538
1535
  function makeBaseUrl(baseUrl) {
1539
1536
  if (typeof baseUrl === "string") return {
@@ -2042,12 +2039,6 @@ function extractSecurityInfo(opSecurity, globalSecurity, securitySchemes) {
2042
2039
  return [];
2043
2040
  })).filter((requirement) => requirement.length > 0);
2044
2041
  }
2045
- function hasRequestBodyContent(operation) {
2046
- if (typeof operation !== "object" || operation === null) return false;
2047
- if (!("requestBody" in operation)) return false;
2048
- if (typeof operation.requestBody !== "object" || operation.requestBody === null) return false;
2049
- return "content" in operation.requestBody;
2050
- }
2051
2042
  /**
2052
2043
  * Filter OpenAPI spec to only include JSON content types for request bodies.
2053
2044
  * This is needed because @hono/zod-openapi doesn't correctly handle multiple content types.
@@ -2057,13 +2048,13 @@ function filterToJsonContentTypes(openapi) {
2057
2048
  return [path, Object.fromEntries(Object.entries(pathItem).map(([k, v]) => {
2058
2049
  if (!HTTP_METHODS.some((method) => method === k)) return [k, v];
2059
2050
  if (!hasRequestBodyContent(v)) return [k, v];
2060
- const jsonContent = v.requestBody.content["application/json"];
2051
+ const jsonContent = v.requestBody.content[JSON_MEDIA_TYPE];
2061
2052
  if (!jsonContent) return [k, v];
2062
2053
  return [k, {
2063
2054
  ...v,
2064
2055
  requestBody: {
2065
2056
  ...v.requestBody,
2066
- content: { "application/json": jsonContent }
2057
+ content: { [JSON_MEDIA_TYPE]: jsonContent }
2067
2058
  }
2068
2059
  }];
2069
2060
  }))];
@@ -2145,7 +2136,7 @@ function extractMediaExample(media, components) {
2145
2136
  }
2146
2137
  function jsonMediaType(content) {
2147
2138
  const types = Object.keys(content ?? {});
2148
- return types.includes("application/json") ? "application/json" : types.find((type) => /^application\/(?:[\w.-]+\+)?json(?:;|$)/u.test(type));
2139
+ return types.includes("application/json") ? JSON_MEDIA_TYPE : types.find((type) => /^application\/(?:[\w.-]+\+)?json(?:;|$)/u.test(type));
2149
2140
  }
2150
2141
  function isBigintSchema(schema) {
2151
2142
  return normalizeTypes(schema.type).includes("integer") && (schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint");
@@ -2174,9 +2165,6 @@ function exampleCode(example, schema, schemas) {
2174
2165
  if (example !== null && typeof example === "object") return `{${Object.entries(example).map(([key, value]) => `${JSON.stringify(key)}:${exampleCode(value, memberSchema(resolved, key, schemas), schemas)}`).join(",")}}`;
2175
2166
  return JSON.stringify(example);
2176
2167
  }
2177
- function isInlineMedia(media) {
2178
- return !("$ref" in media);
2179
- }
2180
2168
  function resolveMedia(media, components, seen = /* @__PURE__ */ new Set()) {
2181
2169
  if (media === void 0) return void 0;
2182
2170
  if (isInlineMedia(media)) return media;
@@ -2187,7 +2175,7 @@ function resolveMedia(media, components, seen = /* @__PURE__ */ new Set()) {
2187
2175
  function describeResponse(key, response, components, useExamples) {
2188
2176
  const jsonType = jsonMediaType(response.content);
2189
2177
  const jsonMedia = resolveMedia(jsonType ? response.content?.[jsonType] : void 0, components);
2190
- const textMedia = resolveMedia(response.content?.["text/plain"], components);
2178
+ const textMedia = resolveMedia(response.content?.[TEXT_MEDIA_TYPE], components);
2191
2179
  const jsonSchema = jsonMedia && isMediaWithSchema(jsonMedia) ? jsonMedia.schema : void 0;
2192
2180
  return {
2193
2181
  key: /^[1-5]xx$/iu.test(key) ? key.toUpperCase() : key,
@@ -2247,7 +2235,7 @@ function makeRawHandlerBody(statusExpr, response, payload) {
2247
2235
  const type = makeStringLiteral(response.jsonType ?? "application/json");
2248
2236
  return `return preferResponse(${statusExpr}, JSON.stringify(${payload.data}), ${type})`;
2249
2237
  }
2250
- if (payload.kind === "text") return `return preferResponse(${statusExpr}, String(${payload.data}), 'text/plain')`;
2238
+ if (payload.kind === "text") return `return preferResponse(${statusExpr}, String(${payload.data}), ${makeStringLiteral(TEXT_MEDIA_TYPE)})`;
2251
2239
  return `return preferResponse(${statusExpr}, null)`;
2252
2240
  }
2253
2241
  const PREFER_HELPERS = `// Reads Prism's \`Prefer: code=<status>, example=<name>\` header (or the \`__code\` /
@@ -2363,7 +2351,7 @@ function makeMock(openapi, basePath, options = {}) {
2363
2351
  const unauthorizedPayload = unauthorizedResponse ? responsePayload(unauthorizedResponse, unauthorizedResponse.example, schemas, fakerOptions, allRefs) : void 0;
2364
2352
  const authCheck = makeAuthCheck(security, operation.responses?.[String(401)] === void 0 ? void 0 : unauthorizedPayload === void 0 || unauthorizedPayload.kind === "none" ? `return c.json({ message: 'Unauthorized' }, 401)` : makeHandlerBody(401, unauthorizedResponse, unauthorizedPayload));
2365
2353
  const pathParams = [...resolvedPathItems.get(p)?.parameters ?? [], ...operation.parameters ?? []].flatMap((rawParam) => {
2366
- const resolved = rawParam.$ref ? openapi.components?.parameters?.[rawParam.$ref.replace("#/components/parameters/", "")] ?? rawParam : rawParam;
2354
+ const resolved = rawParam.$ref ? openapi.components?.parameters?.[rawParam.$ref.replace(COMPONENT_REF_PREFIX.parameters, "")] ?? rawParam : rawParam;
2367
2355
  if (!(isParameter(resolved) && resolved.in === "path")) return [];
2368
2356
  return [{
2369
2357
  name: resolved.name,
@@ -1,5 +1,5 @@
1
- import { r as HTTP_METHODS } from "./constants-DlWc79pw.js";
2
- import { H as isSchemaArray, L as isRecord, R as isRefObject, o as escapeHtml } from "./utils-7HBCrio0.js";
1
+ import { d as MULTIPART_MEDIA_TYPE, s as HTTP_METHODS } from "./constants-Bz8YiPum.js";
2
+ import { J as isRefObject, Q as isSchemaArray, o as escapeHtml, q as isRecord } from "./utils-BCaOY0bs.js";
3
3
  import { n as mkdir, o as writeFile } from "./file-K6j5IJXi.js";
4
4
  import { Effect } from "effect";
5
5
  import path from "node:path";
@@ -19,8 +19,8 @@ const MAX_REF_EXPANSIONS = 1e3;
19
19
  * Past the limit the schema is still named and linked, just not expanded.
20
20
  */
21
21
  const MAX_EXPANSIONS_PER_RECURSIVE_REF = 2;
22
- const FORM_URLENCODED = "application/x-www-form-urlencoded";
23
- const MULTIPART = "multipart/form-data";
22
+ /** A `${NAME}` placeholder a curl example leaves for the shell to expand. */
23
+ const SHELL_VARIABLE_PATTERN = /\$\{[A-Z_]+\}/u;
24
24
  const MULTIPART_BOUNDARY = "boundary";
25
25
  const SLUG_STRIP = /[^\p{L}\p{N}\p{M} -鿿＀-￯ -]/gu;
26
26
  function toSlug(text) {
@@ -157,7 +157,7 @@ function pickJsonMedia(content, doc) {
157
157
  */
158
158
  function pickMedia(content, doc) {
159
159
  const all = listMedia(content, doc);
160
- return pickJsonMedia(content, doc) ?? all.find(({ mediaType }) => baseMediaType(mediaType) === FORM_URLENCODED) ?? all.find(({ mediaType }) => baseMediaType(mediaType) === MULTIPART) ?? all.find(({ media }) => hasPayload(media)) ?? all[0];
160
+ return pickJsonMedia(content, doc) ?? all.find(({ mediaType }) => baseMediaType(mediaType) === "application/x-www-form-urlencoded") ?? all.find(({ mediaType }) => baseMediaType(mediaType) === "multipart/form-data") ?? all.find(({ media }) => hasPayload(media)) ?? all[0];
161
161
  }
162
162
  /**
163
163
  * Escapes a value for a Markdown table cell: `|` would close the cell and a
@@ -575,7 +575,7 @@ function shellQuoteAnsi(value) {
575
575
  return `$'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'").replaceAll("\r", "\\r").replaceAll("\n", "\\n")}'`;
576
576
  }
577
577
  function shellArg(value, quoteBraces) {
578
- if (/\$\{[A-Z_]+\}/u.test(value)) return shellQuoteWithVars(value);
578
+ if (SHELL_VARIABLE_PATTERN.test(value)) return shellQuoteWithVars(value);
579
579
  return /^[\w\-./:~%=@+,{}]+$/u.test(value) && !(quoteBraces && value.includes("{")) ? value : shellQuote(value);
580
580
  }
581
581
  function toParamString(value) {
@@ -751,12 +751,12 @@ function makeSampleBodyArgs(picked, doc, curl) {
751
751
  if (example === void 0) return [];
752
752
  return [`-d ${shellQuote(indentJsonBody(JSON.stringify(example, null, 2)))}`];
753
753
  }
754
- if (mediaType === FORM_URLENCODED) {
754
+ if (mediaType === "application/x-www-form-urlencoded") {
755
755
  if (!isRecord(example)) return [];
756
756
  const pairs = Object.entries(example).map(([key, value]) => encodePair(key, value));
757
757
  return pairs.length > 0 ? [`-d ${shellQuote(pairs.join("&"))}`] : [];
758
758
  }
759
- if (mediaType === MULTIPART) {
759
+ if (mediaType === "multipart/form-data") {
760
760
  if (!isRecord(example)) return [];
761
761
  const properties = (media.schema ? derefSchema(media.schema, doc, /* @__PURE__ */ new Set()) : void 0)?.schema.properties ?? {};
762
762
  const entries = Object.entries(example);
@@ -786,8 +786,8 @@ function makeCodeSample(endpoint, doc, options) {
786
786
  const method = endpoint.method.toUpperCase();
787
787
  const picked = !curl && (method === "GET" || method === "HEAD") ? void 0 : getBodyMedia(operation, doc);
788
788
  const bodyArgs = makeSampleBodyArgs(picked, doc, curl);
789
- const isMultipart = picked !== void 0 && baseMediaType(picked.mediaType) === MULTIPART;
790
- const contentType = !picked ? void 0 : !isMultipart ? picked.mediaType : curl || bodyArgs.length === 0 ? void 0 : `${MULTIPART}; boundary=${MULTIPART_BOUNDARY}`;
789
+ const isMultipart = picked !== void 0 && baseMediaType(picked.mediaType) === "multipart/form-data";
790
+ const contentType = !picked ? void 0 : !isMultipart ? picked.mediaType : curl || bodyArgs.length === 0 ? void 0 : `${MULTIPART_MEDIA_TYPE}; boundary=${MULTIPART_BOUNDARY}`;
791
791
  const accept = acceptedMediaType(operation, doc);
792
792
  const cookies = [...params.filter((p) => p.in === "cookie").flatMap((p) => serializeCookieParameter(p, makeParameterExample(p, doc))), ...credentials.cookies];
793
793
  const headers = [
@@ -796,7 +796,7 @@ function makeCodeSample(endpoint, doc, options) {
796
796
  ...credentials.headers,
797
797
  ...params.filter((p) => p.in === "header" && !isReservedHeader(p.name)).map((p) => `${p.name}: ${serializeHeaderValue(makeParameterExample(p, doc), p.explode)}`),
798
798
  ...cookies.length > 0 ? [`Cookie: ${cookies.join("; ")}`] : []
799
- ].map((header) => /\$\{[A-Z_]+\}/u.test(header) ? `-H ${shellQuoteWithVars(header)}` : `-H ${shellQuote(header)}`);
799
+ ].map((header) => SHELL_VARIABLE_PATTERN.test(header) ? `-H ${shellQuoteWithVars(header)}` : `-H ${shellQuote(header)}`);
800
800
  const query = [...params.filter((p) => p.in === "query").flatMap((p) => serializeQueryParameter(p, makeParameterExample(p, doc))), ...credentials.query];
801
801
  const allParams = endpointParameters(endpoint, doc);
802
802
  const samplePath = endpoint.path.replaceAll(/\{([^{}]+)\}/gu, (placeholder, name) => {
@@ -868,7 +868,7 @@ function makeBodyParameterBlock(operation, doc) {
868
868
  return [
869
869
  "> Body parameter",
870
870
  "",
871
- ...isJsonMediaType(mediaType) ? makeFence(JSON.stringify(example, null, 2), "json") : mediaType === FORM_URLENCODED || mediaType === MULTIPART ? makeFence(toYaml(example), "yaml") : typeof example === "string" ? makeFence(example, "text") : makeFence(JSON.stringify(example, null, 2), "json"),
871
+ ...isJsonMediaType(mediaType) ? makeFence(JSON.stringify(example, null, 2), "json") : mediaType === "application/x-www-form-urlencoded" || mediaType === "multipart/form-data" ? makeFence(toYaml(example), "yaml") : typeof example === "string" ? makeFence(example, "text") : makeFence(JSON.stringify(example, null, 2), "json"),
872
872
  ""
873
873
  ];
874
874
  }
@@ -1,2 +1,2 @@
1
- import { t as zodOpenAPIHono } from "../../../openapi-DsC_M1Um.js";
1
+ import { t as zodOpenAPIHono } from "../../../openapi-BlxQC7Xn.js";
2
2
  export { zodOpenAPIHono };
@@ -1,8 +1,8 @@
1
- import { r as HTTP_METHODS } from "./constants-DlWc79pw.js";
1
+ import { s as HTTP_METHODS } from "./constants-Bz8YiPum.js";
2
2
  import { i as GenerateError } from "./format-CuHABcKC.js";
3
- import { D as isOpenAPIPaths, L as isRecord, _ as toIdentifierPascalCase, f as methodPath, k as isOperationLike, n as capitalize } from "./utils-7HBCrio0.js";
3
+ import { L as isOpenAPIPaths, _ as toIdentifierPascalCase, f as methodPath, n as capitalize, q as isRecord, x as hasNoContentResponse, z as isOperationLike } from "./utils-BCaOY0bs.js";
4
4
  import { t as emit } from "./emit-uwlZZeRM.js";
5
- import { a as parsePathItem, c as operationTags, i as operationHasArgs, n as hasNoContentResponse, o as groupClientName, r as makeOperationDeps, t as formatPath } from "./rpc-Bl9hcXCo.js";
5
+ import { a as groupClientName, i as parsePathItem, n as makeOperationDeps, r as operationHasArgs, s as operationTags, t as formatPath } from "./rpc-b2oph6wk.js";
6
6
  import { Effect } from "effect";
7
7
  import path from "node:path";
8
8
  //#region src/helper/query.ts
package/dist/index.js CHANGED
@@ -1,14 +1,10 @@
1
- import { n as HOOK_LIBRARIES, t as COMPONENT_NAMES } from "./constants-DlWc79pw.js";
1
+ import { c as IDENTIFIER_PATTERN, l as INPUT_EXTENSIONS, n as COMPONENT_NAMES, o as HOOK_LIBRARIES } from "./constants-Bz8YiPum.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";
5
5
  //#region src/config/index.ts
6
6
  const ConfigSchema = Schema.Struct({
7
- input: Schema.declare(Schema.is(Schema.TemplateLiteral([Schema.String, Schema.Literals([
8
- ".yaml",
9
- ".json",
10
- ".tsp"
11
- ])])), { message: "must be .yaml | .json | .tsp" }).annotate({
7
+ input: Schema.declare(Schema.is(Schema.TemplateLiteral([Schema.String, Schema.Literals(INPUT_EXTENSIONS)])), { message: "must be .yaml | .json | .tsp" }).annotate({
12
8
  title: "Input document",
13
9
  description: "OpenAPI or TypeSpec entry document that every generator reads.",
14
10
  examples: [
@@ -357,7 +353,7 @@ const ConfigSchema = Schema.Struct({
357
353
  description: "The module of yours that exports the environment object, written into the client file as it stands: `@/env`, `../env`. Such a module validates its exports (t3-env, valibot, zod), so the property is there and no `/` fallback is written.",
358
354
  examples: ["@/env", "../env"]
359
355
  }),
360
- name: Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/u, { message: "must be a JavaScript identifier" })).pipe(Schema.withDecodingDefault(Effect.succeed("env"))).annotate({
356
+ name: Schema.String.check(Schema.isPattern(IDENTIFIER_PATTERN, { message: "must be a JavaScript identifier" })).pipe(Schema.withDecodingDefault(Effect.succeed("env"))).annotate({
361
357
  title: "Environment export name",
362
358
  description: "The named export of `import` that is the environment object, `env` when left out.",
363
359
  examples: ["env"]
@@ -1,9 +1,8 @@
1
- import { r as HTTP_METHODS } from "./constants-DlWc79pw.js";
2
- import { A as isParameter, C as isHeader, F as isPathItemEntry, H as isSchemaArray, I as isPathItemRef, L as isRecord, N as isParameterRef, O as isOperation, P as isPathItem, R as isRefObject, S as isDiscriminableBranch, T as isMedia, U as isSchemaObject, V as isResponses, _ as toIdentifierPascalCase, a as error, b as zodToOpenAPISchema, f as methodPath, h as requestParamsArray, i as ensureSuffix, m as renderNamedImport, p as normalizeTypes, q as isSingleSchema, r as cyclicNodes, s as escapeRegexLiteral, t as baseError, u as makeSafeKey, v as uncapitalize, x as isCallbacks, z as isRefOnly } from "./utils-7HBCrio0.js";
1
+ import { i as FORM_MEDIA_TYPES, r as COMPONENT_REF_PREFIX, s as HTTP_METHODS, t as ARROW_FUNCTION_PATTERN } from "./constants-Bz8YiPum.js";
2
+ import { $ as isSchemaObject, A as isHeader, B as isParameter, C as hasNotProperty, D as isCallbacks, E as hasTypelessConstraint, G as isPathItemEntry, I as isOffsetTime, J as isRefObject, K as isPathItemRef, M as isInheritedName, O as isDiscriminableBranch, P as isMedia, Q as isSchemaArray, R as isOperation, S as hasNoUserChain, U as isParameterRef, W as isPathItem, Y as isRefOnly, Z as isResponses, _ as toIdentifierPascalCase, a as error, at as isValidIdent, b as zodToOpenAPISchema, d as makeStringLiteral, f as methodPath, h as requestParamsArray, i as ensureSuffix, k as isExamplesInput, m as renderNamedImport, p as normalizeTypes, q as isRecord, r as cyclicNodes, rt as isSingleSchema, s as escapeRegexLiteral, t as baseError, u as makeSafeKey, v as uncapitalize } from "./utils-BCaOY0bs.js";
3
3
  import path from "node:path";
4
4
  import { ts } from "ts-morph";
5
5
  //#region src/helper/wire.ts
6
- const SCHEMA_REF_PREFIX = "#/components/schemas/";
7
6
  const INTEGER_TEXT = String.raw`/^-?\d+$/`;
8
7
  const NUMBER_TEXT = String.raw`/^-?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$/`;
9
8
  const READ_NUMBER = `(val)=>(typeof val==='string'&&${`${NUMBER_TEXT}.test(val)&&(!${INTEGER_TEXT}.test(val)||Number.isSafeInteger(Number(val)))`}?Number(val):val)`;
@@ -22,8 +21,8 @@ const ALL_SCALARS = [
22
21
  const WIRE_NULL = "(val)=>(val==='null'?null:val)";
23
22
  /** Looks a `#/components/schemas/<name>` reference up; anything else is not resolved. */
24
23
  function resolveSchemaRef(ref, schemas) {
25
- if (!ref.startsWith(SCHEMA_REF_PREFIX)) return void 0;
26
- const name = ref.slice(21);
24
+ if (!ref.startsWith(COMPONENT_REF_PREFIX.schemas)) return void 0;
25
+ const name = ref.slice(COMPONENT_REF_PREFIX.schemas.length);
27
26
  if (name.includes("/")) return void 0;
28
27
  return schemas?.[decodeURIComponent(name)];
29
28
  }
@@ -487,10 +486,6 @@ function nullReading(schema, schemas) {
487
486
  * `__proto__` the prototype itself. Nothing on the wire is either, so both are read as absent.
488
487
  */
489
488
  const WIRE_INHERITED = "(val)=>(typeof val==='function'||val===Object.prototype?undefined:val)";
490
- /** Whether a parameter is named like something every object inherits. */
491
- function isInheritedName(parameter) {
492
- return parameter.in !== "path" && parameter.name in Object.prototype;
493
- }
494
489
  /**
495
490
  * `allowEmptyValue: true` lets a query parameter be sent with no value, `?page=`, to say
496
491
  * the same as leaving it out. Text that holds nothing is then read as absent, so that a
@@ -510,47 +505,47 @@ function isEmptyAbsent(parameter, schemas) {
510
505
  function makeRef($ref) {
511
506
  const COMPONENT_SUFFIX_MAP = [
512
507
  {
513
- prefix: "#/components/schemas/",
508
+ prefix: COMPONENT_REF_PREFIX.schemas,
514
509
  suffix: "Schema"
515
510
  },
516
511
  {
517
- prefix: "#/components/parameters/",
512
+ prefix: COMPONENT_REF_PREFIX.parameters,
518
513
  suffix: "ParamsSchema"
519
514
  },
520
515
  {
521
- prefix: "#/components/headers/",
516
+ prefix: COMPONENT_REF_PREFIX.headers,
522
517
  suffix: "HeaderSchema"
523
518
  },
524
519
  {
525
- prefix: "#/components/securitySchemes/",
520
+ prefix: COMPONENT_REF_PREFIX.securitySchemes,
526
521
  suffix: "SecurityScheme"
527
522
  },
528
523
  {
529
- prefix: "#/components/requestBodies/",
524
+ prefix: COMPONENT_REF_PREFIX.requestBodies,
530
525
  suffix: "RequestBody"
531
526
  },
532
527
  {
533
- prefix: "#/components/responses/",
528
+ prefix: COMPONENT_REF_PREFIX.responses,
534
529
  suffix: "Response"
535
530
  },
536
531
  {
537
- prefix: "#/components/examples/",
532
+ prefix: COMPONENT_REF_PREFIX.examples,
538
533
  suffix: "Example"
539
534
  },
540
535
  {
541
- prefix: "#/components/links/",
536
+ prefix: COMPONENT_REF_PREFIX.links,
542
537
  suffix: "Link"
543
538
  },
544
539
  {
545
- prefix: "#/components/callbacks/",
540
+ prefix: COMPONENT_REF_PREFIX.callbacks,
546
541
  suffix: "Callback"
547
542
  },
548
543
  {
549
- prefix: "#/components/pathItems/",
544
+ prefix: COMPONENT_REF_PREFIX.pathItems,
550
545
  suffix: "PathItem"
551
546
  },
552
547
  {
553
- prefix: "#/components/mediaTypes/",
548
+ prefix: COMPONENT_REF_PREFIX.mediaTypes,
554
549
  suffix: "MediaTypeSchema"
555
550
  }
556
551
  ];
@@ -651,10 +646,10 @@ function makeCallbacks(callbacks, readonly) {
651
646
  function makeContent(content, readonly, request) {
652
647
  return Object.freeze(Object.entries(content).map(([contentType, mediaOrRef]) => {
653
648
  const key = /^[A-Za-z0-9!#$&^_+\-./*;= ]+$/u.test(contentType) ? `'${contentType}'` : JSON.stringify(contentType);
654
- if (isRefObject(mediaOrRef)) return mediaOrRef.$ref.startsWith("#/components/mediaTypes/") ? `${key}:{schema:${makeRef(mediaOrRef.$ref)}}` : `${key}:${makeRef(mediaOrRef.$ref)}`;
649
+ if (isRefObject(mediaOrRef)) return mediaOrRef.$ref.startsWith(COMPONENT_REF_PREFIX.mediaTypes) ? `${key}:{schema:${makeRef(mediaOrRef.$ref)}}` : `${key}:${makeRef(mediaOrRef.$ref)}`;
655
650
  if (isMedia(mediaOrRef)) {
656
651
  const mediaType = contentType.toLowerCase();
657
- return `${key}:${makeMedia(mediaOrRef, readonly, request !== void 0 && (mediaType.startsWith("application/x-www-form-urlencoded") || mediaType.startsWith("multipart/form-data")) ? request : void 0)}`;
652
+ return `${key}:${makeMedia(mediaOrRef, readonly, request !== void 0 && FORM_MEDIA_TYPES.some((formType) => mediaType.startsWith(formType)) ? request : void 0)}`;
658
653
  }
659
654
  }).filter((v) => v !== void 0));
660
655
  }
@@ -842,12 +837,6 @@ function makePathItem(pathItem) {
842
837
  }
843
838
  //#endregion
844
839
  //#region src/helper/wrap.ts
845
- function hasNotProperty(v) {
846
- return typeof v === "object" && v !== null && "not" in v;
847
- }
848
- function isExamplesInput(v) {
849
- return typeof v === "object" && v !== null && !Array.isArray(v) && Object.values(v).every((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry));
850
- }
851
840
  const zodExpressedProps = /* @__PURE__ */ new Set([
852
841
  "type",
853
842
  "format",
@@ -989,9 +978,6 @@ const decorationProps = /* @__PURE__ */ new Set([
989
978
  function undecorated(schema) {
990
979
  return Object.entries(schema).reduce((kept, [key, value]) => zodExpressedProps.has(key) && !decorationProps.has(key) ? Object.assign(kept, { [key]: value }) : kept, {});
991
980
  }
992
- function hasNoUserChain(schema) {
993
- return schema["x-preprocess"] === void 0 && schema["x-transform"] === void 0 && schema["x-pipe"] === void 0 && schema["x-codec"] === void 0;
994
- }
995
981
  function serializeParam(param) {
996
982
  return `{${Object.entries(param).filter(([, value]) => value !== void 0).map(([key, value]) => {
997
983
  if (key === "examples" && isExamplesInput(value)) return `"examples":${makeExamples(value)}`;
@@ -1128,47 +1114,6 @@ function wrap(zod, schema, meta, options) {
1128
1114
  }
1129
1115
  //#endregion
1130
1116
  //#region src/helper/zod.ts
1131
- const TYPELESS_KEYWORDS = [
1132
- "required",
1133
- "properties",
1134
- "additionalProperties",
1135
- "patternProperties",
1136
- "propertyNames",
1137
- "minProperties",
1138
- "maxProperties",
1139
- "dependentRequired",
1140
- "dependentSchemas",
1141
- "unevaluatedProperties",
1142
- "minItems",
1143
- "maxItems",
1144
- "uniqueItems",
1145
- "items",
1146
- "prefixItems",
1147
- "contains",
1148
- "minContains",
1149
- "maxContains",
1150
- "unevaluatedItems",
1151
- "minLength",
1152
- "maxLength",
1153
- "pattern",
1154
- "minimum",
1155
- "maximum",
1156
- "exclusiveMinimum",
1157
- "exclusiveMaximum",
1158
- "multipleOf",
1159
- "enum",
1160
- "const",
1161
- "allOf",
1162
- "anyOf",
1163
- "oneOf",
1164
- "not",
1165
- "if",
1166
- "then",
1167
- "else"
1168
- ];
1169
- function hasTypelessConstraint(schema) {
1170
- return TYPELESS_KEYWORDS.some((k) => schema[k] !== void 0);
1171
- }
1172
1117
  function pickMessage(schema, slot) {
1173
1118
  const value = schema[slot];
1174
1119
  return typeof value === "string" ? JSON.stringify(value) : void 0;
@@ -1507,7 +1452,7 @@ function _enum(schema) {
1507
1452
  const outerLit = (v, suffix) => {
1508
1453
  const arg = suffix ?? errorArg;
1509
1454
  if (v === null) return `z.literal(null${arg})`;
1510
- if (typeof v === "string") return `z.literal('${v.replaceAll("'", "\\'")}'${arg})`;
1455
+ if (typeof v === "string") return `z.literal(${makeStringLiteral(v)}${arg})`;
1511
1456
  if (typeof v === "number" && isBigint && Number.isInteger(v)) return `z.literal(${v}n${arg})`;
1512
1457
  if (typeof v === "number" || typeof v === "boolean") return `z.literal(${String(v)}${arg})`;
1513
1458
  return `z.custom<${JSON.stringify(v)}>()`;
@@ -1717,7 +1662,7 @@ function object(schema, options) {
1717
1662
  const dependentRequired = schema.dependentRequired ? Object.entries(schema.dependentRequired).map(([key, deps]) => {
1718
1663
  const stmts = deps.map((d) => {
1719
1664
  const msg = dependentRequiredMessage ?? errorMessage ?? `requires "${d}" when "${key}" present`;
1720
- const msgExpr = /^\s*\(.*?\)\s*=>/u.test(msg) ? `(${msg})({code:'custom',path:[${JSON.stringify(d)}],input:o})` : JSON.stringify(msg);
1665
+ const msgExpr = ARROW_FUNCTION_PATTERN.test(msg) ? `(${msg})({code:'custom',path:[${JSON.stringify(d)}],input:o})` : JSON.stringify(msg);
1721
1666
  return `if(!Object.hasOwn(o,${JSON.stringify(d)})){ctx.addIssue({code:'custom',message:${msgExpr},path:[${JSON.stringify(d)}]})}`;
1722
1667
  }).join(";");
1723
1668
  return `.superRefine((o,ctx)=>{if(!Object.hasOwn(o,${JSON.stringify(key)})){return}${stmts}})`;
@@ -1793,13 +1738,6 @@ const EMAIL_PATTERN_PRESET = {
1793
1738
  unicode: "unicodeEmail"
1794
1739
  };
1795
1740
  /**
1796
- * Whether a `time` takes an offset. `time` is an RFC 3339 full-time, `12:34:56Z` or
1797
- * `12:34:56+09:00`, and `z.iso.time()` takes neither. `x-isoOffset: false` asks for that.
1798
- */
1799
- function isOffsetTime(schema) {
1800
- return schema.format === "time" && schema["x-isoOffset"] !== false;
1801
- }
1802
- /**
1803
1741
  * The text of a `time` that may end in an offset, as the source of a pattern. The time
1804
1742
  * itself is what `z.iso.time()` reads, seconds optional unless a precision is asked for. No
1805
1743
  * part of it can be matched two ways, so the pattern does not backtrack.
@@ -1866,9 +1804,11 @@ function string(schema, options) {
1866
1804
  const mt = mediaType ? mediaType.toLowerCase() : "";
1867
1805
  const isBinary = /^(image|audio|video)\//u.test(mt) || mt === "application/octet-stream";
1868
1806
  const isJson = mt.length > 0 && mt.includes("json");
1869
- if (isBinary) return ".transform((val)=>typeof atob===\"function\"?Uint8Array.from(atob(val),(c)=>c.charCodeAt(0)):new Uint8Array(Buffer.from(val,\"base64\")))";
1870
- if (isJson) return `.transform((val,ctx)=>{try{const s=typeof atob==="function"?atob(val):Buffer.from(val,"base64").toString("utf8");return JSON.parse(s)}catch(e){ctx.addIssue(${errorMessage ? `{code:"custom",message:${JSON.stringify(errorMessage)},params:{cause:e instanceof Error?e.message:String(e)}}` : "{code:\"custom\",params:{cause:e instanceof Error?e.message:String(e)}}"});return z.NEVER}})`;
1871
- return ".transform((val)=>typeof atob===\"function\"?atob(val):Buffer.from(val,\"base64\").toString(\"utf8\"))";
1807
+ const bytesExpr = `Uint8Array.from(atob(${enc === "base64url" ? "val.replace(/-/g,\"+\").replace(/_/g,\"/\")" : "val"}),(char)=>char.charCodeAt(0))`;
1808
+ const textExpr = `new TextDecoder().decode(${bytesExpr})`;
1809
+ if (isBinary) return `.transform((val)=>${bytesExpr})`;
1810
+ if (isJson) return `.transform((val,ctx)=>{try{return JSON.parse(${textExpr})}catch(err){ctx.addIssue(${errorMessage ? `{code:"custom",message:${JSON.stringify(errorMessage)},params:{cause:err instanceof Error?err.message:String(err)}}` : "{code:\"custom\",params:{cause:err instanceof Error?err.message:String(err)}}"});return z.NEVER}})`;
1811
+ return `.transform((val)=>${textExpr})`;
1872
1812
  })()}${contentSchema ? `.pipe(${zodToOpenAPI(contentSchema, void 0, options)})` : ""}`;
1873
1813
  const format = schema.format && Object.hasOwn(FORMAT_STRING, schema.format) ? FORMAT_STRING[schema.format] : void 0;
1874
1814
  const isTransformFormat = !!(schema.format && TRANSFORM_FORMATS.has(schema.format));
@@ -2038,7 +1978,7 @@ function zodToOpenAPI(schema, meta, options) {
2038
1978
  allOf: effectiveAllOf
2039
1979
  }, (s) => zodToOpenAPI(s, void 0, childOptions), schema["x-error-message"]);
2040
1980
  if (allOfMessage || unevalCheck) return done(`(()=>{const Schema=${z};return z.unknown().check((ctx)=>{${(() => {
2041
- const isArrow = allOfMessage ? /^\s*\(.*?\)\s*=>/u.test(allOfMessage) : false;
1981
+ const isArrow = allOfMessage ? ARROW_FUNCTION_PATTERN.test(allOfMessage) : false;
2042
1982
  const msgExpr = allOfMessage ? isArrow ? `(${allOfMessage})(issue)` : JSON.stringify(allOfMessage) : void 0;
2043
1983
  const pushArg = msgExpr ? `{...issue,input:issue.input,message:${msgExpr}}` : "{...issue,input:issue.input}";
2044
1984
  return `const result=Schema.safeParse(ctx.value);if(!result.success){for(const issue of result.error.issues){${[
@@ -2082,7 +2022,7 @@ function zodToOpenAPI(schema, meta, options) {
2082
2022
  const discriminator = schema.discriminator?.propertyName;
2083
2023
  const oneOfMessage = schema["x-oneOf-message"] ?? schema["x-error-message"];
2084
2024
  const oneOfErrorArg = oneOfMessage ? `,${error(oneOfMessage)}` : "";
2085
- const branches = schema.oneOf.map((s) => s.$ref === void 0 ? s : isRefOnly(s) && s.$ref.startsWith("#/components/schemas/") ? options?.schemas?.[decodeURIComponent(s.$ref.slice(21))] : void 0);
2025
+ const branches = schema.oneOf.map((s) => s.$ref === void 0 ? s : isRefOnly(s) && s.$ref.startsWith(COMPONENT_REF_PREFIX.schemas) ? options?.schemas?.[decodeURIComponent(s.$ref.slice(COMPONENT_REF_PREFIX.schemas.length))] : void 0);
2086
2026
  const literalsPerBranch = branches.map((branch) => {
2087
2027
  if (discriminator === void 0 || branch === void 0) return void 0;
2088
2028
  if (!isDiscriminableBranch(branch, discriminator)) return void 0;
@@ -2094,7 +2034,7 @@ function zodToOpenAPI(schema, meta, options) {
2094
2034
  const isDiscriminated = discriminator !== void 0 && branches.length >= 2 && literalsPerBranch.every((values) => values !== void 0) && new Set(literals).size === literals.length;
2095
2035
  const alwaysMatching = branches.filter((branch) => branch !== void 0 && branch.allOf === void 0 && branch.anyOf === void 0 && branch.oneOf === void 0 && branch.not === void 0 && branch["x-refine"] === void 0 && branch["x-superRefine"] === void 0 && branch.type === "object" && !(Array.isArray(branch.required) && branch.required.length > 0) && !(typeof branch.minProperties === "number" && branch.minProperties > 0));
2096
2036
  if (!isDiscriminated && alwaysMatching.length >= 2) console.warn(`oneOf rejects every payload: ${alwaysMatching.length} branches accept {}, so no input matches exactly one. Add a discriminator (a required literal property per branch plus \`discriminator\`), or use anyOf if the branches are meant to overlap.`);
2097
- return done(isDiscriminated ? `z.discriminatedUnion('${discriminator}',[${oneOfSchemas.join(",")}]${oneOfErrorArg})` : `z.xor([${oneOfSchemas.join(",")}]${oneOfErrorArg})`, schema);
2037
+ return done(isDiscriminated ? `z.discriminatedUnion(${makeStringLiteral(discriminator)},[${oneOfSchemas.join(",")}]${oneOfErrorArg})` : `z.xor([${oneOfSchemas.join(",")}]${oneOfErrorArg})`, schema);
2098
2038
  }
2099
2039
  if (schema.not !== void 0) {
2100
2040
  const notMessage = schema["x-not-message"] ?? schema["x-error-message"];
@@ -2343,8 +2283,8 @@ function findDiscriminatedBranches(schemas, schemaNames) {
2343
2283
  const discriminator = schema?.discriminator?.propertyName;
2344
2284
  if (discriminator === void 0 || schema?.oneOf === void 0) return [];
2345
2285
  return schema.oneOf.flatMap((branch) => {
2346
- if (!(isRefOnly(branch) && branch.$ref?.startsWith("#/components/schemas/"))) return [];
2347
- const name = decodeURIComponent(branch.$ref.slice(21));
2286
+ if (!(isRefOnly(branch) && branch.$ref?.startsWith(COMPONENT_REF_PREFIX.schemas))) return [];
2287
+ const name = decodeURIComponent(branch.$ref.slice(COMPONENT_REF_PREFIX.schemas.length));
2348
2288
  const target = schemas[name];
2349
2289
  return target && isDiscriminableBranch(target, discriminator) ? [name] : [];
2350
2290
  });
@@ -2535,9 +2475,9 @@ function makeTypeString(schema, selfTypeName, cyclicGroup, readonly) {
2535
2475
  if (schema.oneOf && schema.oneOf.length > 0) return makeUnionTypeString(schema.oneOf, selfTypeName, cyclicGroup, "|", readonly);
2536
2476
  if (schema.anyOf && schema.anyOf.length > 0) return makeUnionTypeString(schema.anyOf, selfTypeName, cyclicGroup, "|", readonly);
2537
2477
  if (schema.allOf && schema.allOf.length > 0) return makeUnionTypeString(schema.allOf, selfTypeName, cyclicGroup, "&", readonly);
2538
- if (schema.enum && schema.enum.length > 0) return schema.enum.map((v) => typeof v === "string" ? `'${v}'` : String(v)).join("|");
2478
+ if (schema.enum && schema.enum.length > 0) return schema.enum.map((v) => typeof v === "string" ? makeStringLiteral(v) : String(v)).join("|");
2539
2479
  if (schema.const !== void 0) {
2540
- if (typeof schema.const === "string") return `'${schema.const}'`;
2480
+ if (typeof schema.const === "string") return makeStringLiteral(schema.const);
2541
2481
  if (typeof schema.const === "number" || typeof schema.const === "boolean") return String(schema.const);
2542
2482
  return JSON.stringify(schema.const);
2543
2483
  }
@@ -2623,7 +2563,7 @@ function makeObjectTypeString(schema, selfTypeName, cyclicGroup, readonly) {
2623
2563
  return `{${Object.entries(properties).map(([key, propSchema]) => {
2624
2564
  const propType = makeTypeString(propSchema, selfTypeName, cyclicGroup, readonly);
2625
2565
  const isRequired = requiredSet.has(key);
2626
- const safeKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u.test(key) ? key : `'${key}'`;
2566
+ const safeKey = isValidIdent(key) ? key : makeStringLiteral(key);
2627
2567
  return `${readonlyPrefix}${safeKey}${isRequired ? "" : "?"}:${propType}`;
2628
2568
  }).join(";")}}`;
2629
2569
  }
@@ -1,4 +1,5 @@
1
- import { L as isRecord, M as isParameterObject, R as isRefObject, W as isSchemaProperty, Y as isValidIdent, k as isOperationLike } from "./utils-7HBCrio0.js";
1
+ import { i as FORM_MEDIA_TYPES, u as JSON_MEDIA_TYPE } from "./constants-Bz8YiPum.js";
2
+ import { H as isParameterObject, J as isRefObject, at as isValidIdent, et as isSchemaProperty, q as isRecord, z as isOperationLike } from "./utils-BCaOY0bs.js";
2
3
  //#region src/helper/group.ts
3
4
  const RESERVED = /* @__PURE__ */ new Set([
4
5
  "api",
@@ -50,7 +51,7 @@ const RESERVED = /* @__PURE__ */ new Set([
50
51
  * or the generated app has taken.
51
52
  */
52
53
  function isGroupName(name) {
53
- return name !== void 0 && /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(name) && !RESERVED.has(name) && !name.startsWith("__") && !name.endsWith("Route") && !name.endsWith("Handler");
54
+ return name !== void 0 && isValidIdent(name) && !RESERVED.has(name) && !name.startsWith("__") && !name.endsWith("Route") && !name.endsWith("Handler");
54
55
  }
55
56
  /** The string tags of an operation, as a {@link Grouping} reads them. */
56
57
  function operationTags(operation) {
@@ -109,21 +110,13 @@ function formatPath(p, hasBasePath) {
109
110
  hasBracket
110
111
  };
111
112
  }
112
- function hasNoContentResponse(operation) {
113
- const responses = operation.responses;
114
- if (!isRecord(responses)) return false;
115
- return Object.keys(responses).some((status) => {
116
- const code = Number.parseInt(status, 10);
117
- return !Number.isNaN(code) && [204, 205].includes(code);
118
- });
119
- }
120
113
  function refRequestBodyName(refLike) {
121
114
  const m = (typeof refLike === "string" ? refLike : isRefObject(refLike) ? refLike.$ref : void 0)?.match(/^#\/components\/requestBodies\/(.+)$/u);
122
115
  return m ? m[1] : void 0;
123
116
  }
124
117
  function pickAllBodyInfoFromContent(content) {
125
118
  if (!isRecord(content)) return void 0;
126
- const formContentTypes = /* @__PURE__ */ new Set(["multipart/form-data", "application/x-www-form-urlencoded"]);
119
+ const formContentTypes = new Set(FORM_MEDIA_TYPES);
127
120
  const isFormContentType = (ct) => formContentTypes.has(ct.split(";")[0].trim());
128
121
  const validEntries = Object.entries(content).filter(([, mediaObj]) => isRecord(mediaObj) && isSchemaProperty(mediaObj) && isRecord(mediaObj.schema));
129
122
  const formInfos = validEntries.filter(([contentType]) => isFormContentType(contentType)).map(([contentType]) => ({ contentType }));
@@ -144,7 +137,7 @@ function makePickAllBodyInfo(componentsRequestBodies) {
144
137
  if (isRecord(resolved) && isRecord(resolved.content)) return pickAllBodyInfoFromContent(resolved.content);
145
138
  if (resolved !== void 0) return {
146
139
  form: [],
147
- json: [{ contentType: "application/json" }]
140
+ json: [{ contentType: JSON_MEDIA_TYPE }]
148
141
  };
149
142
  return;
150
143
  }
@@ -180,4 +173,4 @@ function operationHasArgs(item, operation, deps) {
180
173
  return hasParams || hasBody;
181
174
  }
182
175
  //#endregion
183
- export { parsePathItem as a, operationTags as c, operationHasArgs as i, hasNoContentResponse as n, groupClientName as o, makeOperationDeps as r, isGroupName as s, formatPath as t };
176
+ export { groupClientName as a, parsePathItem as i, makeOperationDeps as n, isGroupName as o, operationHasArgs as r, operationTags as s, formatPath as t };
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
- import { n as HOOK_LIBRARIES, t as COMPONENT_NAMES } from "./constants-DlWc79pw.js";
2
+ import { n as COMPONENT_NAMES, o as HOOK_LIBRARIES } from "./constants-Bz8YiPum.js";
3
3
  import { i as GenerateError } from "./format-CuHABcKC.js";
4
4
  import { a as unlink, i as readdir, t as exists } from "./file-K6j5IJXi.js";
5
- import { C as appEntryImport, E as isInsideDirectory, S as appEntryFile, T as generatedImport, _ 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 appEntryOutput, x as handlerGroupOf, y as callbacks } from "./core-BuSZBtYC.js";
6
- import { t as hooks } from "./hooks-CQMtSLZv.js";
7
- import { t as docs } from "./docs-DJps1WGq.js";
5
+ import { C as appEntryImport, E as isInsideDirectory, S as appEntryFile, T as generatedImport, _ 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 appEntryOutput, x as handlerGroupOf, y as callbacks } from "./core-CHLeBQ6y.js";
6
+ import { t as hooks } from "./hooks-xBFksKgW.js";
7
+ import { t as docs } from "./docs-y1jSJoJg.js";
8
8
  import { rpc } from "./core/rpc/index.js";
9
9
  import { type } from "./core/type/index.js";
10
10
  import { Effect, FileSystem, Schema } from "effect";
@@ -1,4 +1,4 @@
1
- import { r as HTTP_METHODS } from "./constants-DlWc79pw.js";
1
+ import { c as IDENTIFIER_PATTERN, r as COMPONENT_REF_PREFIX, s as HTTP_METHODS, t as ARROW_FUNCTION_PATTERN } from "./constants-Bz8YiPum.js";
2
2
  //#region src/guard/index.ts
3
3
  function isRecord(v) {
4
4
  return typeof v === "object" && v !== null && !Array.isArray(v);
@@ -7,7 +7,7 @@ function isHttpMethod(method) {
7
7
  return HTTP_METHODS.some((candidate) => candidate === method);
8
8
  }
9
9
  function isValidIdent(str) {
10
- return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u.test(str);
10
+ return IDENTIFIER_PATTERN.test(str);
11
11
  }
12
12
  function isOpenAPIPaths(v) {
13
13
  if (typeof v !== "object" || v === null || Array.isArray(v)) return false;
@@ -41,10 +41,10 @@ function isDiscriminableBranch(branch, discriminator) {
41
41
  return Array.isArray(property.enum) && property.enum.length > 0 && property.enum.every((v) => typeof v === "string");
42
42
  }
43
43
  function isParameterRef(ref) {
44
- return ref.startsWith("#/components/parameters/");
44
+ return ref.startsWith(COMPONENT_REF_PREFIX.parameters);
45
45
  }
46
46
  function isPathItemRef(ref) {
47
- return ref.startsWith("#/components/pathItems/");
47
+ return ref.startsWith(COMPONENT_REF_PREFIX.pathItems);
48
48
  }
49
49
  function isParameterObject(v) {
50
50
  if (typeof v !== "object" || v === null || Array.isArray(v)) return false;
@@ -124,6 +124,87 @@ function isResponses(v) {
124
124
  if (typeof v !== "object" || v === null || Array.isArray(v)) return false;
125
125
  return "$ref" in v || "description" in v || "content" in v || "headers" in v || "links" in v;
126
126
  }
127
+ const TYPELESS_KEYWORDS = [
128
+ "required",
129
+ "properties",
130
+ "additionalProperties",
131
+ "patternProperties",
132
+ "propertyNames",
133
+ "minProperties",
134
+ "maxProperties",
135
+ "dependentRequired",
136
+ "dependentSchemas",
137
+ "unevaluatedProperties",
138
+ "minItems",
139
+ "maxItems",
140
+ "uniqueItems",
141
+ "items",
142
+ "prefixItems",
143
+ "contains",
144
+ "minContains",
145
+ "maxContains",
146
+ "unevaluatedItems",
147
+ "minLength",
148
+ "maxLength",
149
+ "pattern",
150
+ "minimum",
151
+ "maximum",
152
+ "exclusiveMinimum",
153
+ "exclusiveMaximum",
154
+ "multipleOf",
155
+ "enum",
156
+ "const",
157
+ "allOf",
158
+ "anyOf",
159
+ "oneOf",
160
+ "not",
161
+ "if",
162
+ "then",
163
+ "else"
164
+ ];
165
+ function hasTypelessConstraint(schema) {
166
+ return TYPELESS_KEYWORDS.some((k) => schema[k] !== void 0);
167
+ }
168
+ /**
169
+ * Whether a `time` takes an offset. `time` is an RFC 3339 full-time, `12:34:56Z` or
170
+ * `12:34:56+09:00`, and `z.iso.time()` takes neither. `x-isoOffset: false` asks for that.
171
+ */
172
+ function isOffsetTime(schema) {
173
+ return schema.format === "time" && schema["x-isoOffset"] !== false;
174
+ }
175
+ function hasNumericConstraint(schema) {
176
+ return schema.minimum !== void 0 || schema.maximum !== void 0 || schema.exclusiveMinimum !== void 0 || schema.exclusiveMaximum !== void 0 || schema.multipleOf !== void 0;
177
+ }
178
+ function hasNotProperty(v) {
179
+ return typeof v === "object" && v !== null && "not" in v;
180
+ }
181
+ function isExamplesInput(v) {
182
+ return typeof v === "object" && v !== null && !Array.isArray(v) && Object.values(v).every((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry));
183
+ }
184
+ function hasNoUserChain(schema) {
185
+ return schema["x-preprocess"] === void 0 && schema["x-transform"] === void 0 && schema["x-pipe"] === void 0 && schema["x-codec"] === void 0;
186
+ }
187
+ function hasRequestBodyContent(operation) {
188
+ if (typeof operation !== "object" || operation === null) return false;
189
+ if (!("requestBody" in operation)) return false;
190
+ if (typeof operation.requestBody !== "object" || operation.requestBody === null) return false;
191
+ return "content" in operation.requestBody;
192
+ }
193
+ function isInlineMedia(media) {
194
+ return !("$ref" in media);
195
+ }
196
+ function hasNoContentResponse(operation) {
197
+ const responses = operation.responses;
198
+ if (!isRecord(responses)) return false;
199
+ return Object.keys(responses).some((status) => {
200
+ const code = Number.parseInt(status, 10);
201
+ return !Number.isNaN(code) && [204, 205].includes(code);
202
+ });
203
+ }
204
+ /** Whether a parameter is named like something every object inherits. */
205
+ function isInheritedName(parameter) {
206
+ return parameter.in !== "path" && parameter.name in Object.prototype;
207
+ }
127
208
  //#endregion
128
209
  //#region src/utils/index.ts
129
210
  /**
@@ -175,7 +256,7 @@ function requestParamsArray(parameters, gather = {}) {
175
256
  */
176
257
  function makeSafeKey(key) {
177
258
  if (key === "__proto__") return "['__proto__']";
178
- if (/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(key)) return key;
259
+ if (IDENTIFIER_PATTERN.test(key)) return key;
179
260
  return makeStringLiteral(key);
180
261
  }
181
262
  /**
@@ -388,7 +469,7 @@ function makeBarrel(value) {
388
469
  * ```
389
470
  */
390
471
  function error(message) {
391
- if (/^\s*\(.*?\)\s*=>/u.test(message)) return `{error:${message}}`;
472
+ if (ARROW_FUNCTION_PATTERN.test(message)) return `{error:${message}}`;
392
473
  return `{error:${JSON.stringify(message)}}`;
393
474
  }
394
475
  /**
@@ -466,4 +547,4 @@ function cyclicNodes(deps) {
466
547
  return result;
467
548
  }
468
549
  //#endregion
469
- export { isParameter as A, isRequestBody as B, isHeader as C, isOpenAPIPaths as D, isMediaWithSchema as E, isPathItemEntry as F, isSecurityArray as G, isSchemaArray as H, isPathItemRef as I, isStringRef as J, isSecurityScheme as K, isRecord as L, isParameterObject as M, isParameterRef as N, isOperation as O, isPathItem as P, isRefObject as R, isDiscriminableBranch as S, isMedia as T, isSchemaObject as U, isResponses as V, isSchemaProperty as W, isValidIdent as Y, toIdentifierPascalCase as _, error as a, zodToOpenAPISchema as b, makeBarrel as c, makeStringLiteral as d, methodPath as f, statusCodeToNumber as g, requestParamsArray as h, ensureSuffix as i, isParameterArray as j, isOperationLike as k, makeInferRequestType as l, renderNamedImport as m, capitalize as n, escapeHtml as o, normalizeTypes as p, isSingleSchema as q, cyclicNodes as r, escapeRegexLiteral as s, baseError as t, makeSafeKey as u, uncapitalize as v, isHttpMethod as w, isCallbacks as x, uncapitalizeWord as y, isRefOnly as z };
550
+ export { isSchemaObject as $, isHeader as A, isParameter as B, hasNotProperty as C, isCallbacks as D, hasTypelessConstraint as E, isMediaWithSchema as F, isPathItemEntry as G, isParameterObject as H, isOffsetTime as I, isRefObject as J, isPathItemRef as K, isOpenAPIPaths as L, isInheritedName as M, isInlineMedia as N, isDiscriminableBranch as O, isMedia as P, isSchemaArray as Q, isOperation as R, hasNoUserChain as S, hasRequestBodyContent as T, isParameterRef as U, isParameterArray as V, isPathItem as W, isRequestBody as X, isRefOnly as Y, isResponses as Z, toIdentifierPascalCase as _, error as a, isValidIdent as at, zodToOpenAPISchema as b, makeBarrel as c, makeStringLiteral as d, isSchemaProperty as et, methodPath as f, statusCodeToNumber as g, requestParamsArray as h, ensureSuffix as i, isStringRef as it, isHttpMethod as j, isExamplesInput as k, makeInferRequestType as l, renderNamedImport as m, capitalize as n, isSecurityScheme as nt, escapeHtml as o, normalizeTypes as p, isRecord as q, cyclicNodes as r, isSingleSchema as rt, escapeRegexLiteral as s, baseError as t, isSecurityArray as tt, makeSafeKey as u, uncapitalize as v, hasNumericConstraint as w, hasNoContentResponse as x, uncapitalizeWord as y, isOperationLike as z };
@@ -1,9 +1,10 @@
1
+ import { l as INPUT_EXTENSIONS } from "../constants-Bz8YiPum.js";
1
2
  import { parseConfig } from "../index.js";
2
3
  import { t as FormatOptions } from "../format-CuHABcKC.js";
3
- import { L as isRecord } from "../utils-7HBCrio0.js";
4
- import { E as isInsideDirectory, w as appEntryOutput } from "../core-BuSZBtYC.js";
4
+ import { q as isRecord } from "../utils-BCaOY0bs.js";
5
+ import { E as isInsideDirectory, w as appEntryOutput } from "../core-CHLeBQ6y.js";
5
6
  import { n as parseOpenAPI } from "../openapi-DQRxq2_O.js";
6
- import { i as packageRoots, n as makeJob, r as outsideSources, t as cleanSplitOutputs } from "../shared-CMgxc-KQ.js";
7
+ import { i as packageRoots, n as makeJob, r as outsideSources, t as cleanSplitOutputs } from "../shared-DBOBTH7X.js";
7
8
  import { Effect, FileSystem, Option, Result } from "effect";
8
9
  import path from "node:path";
9
10
  import crypto from "node:crypto";
@@ -42,7 +43,7 @@ function debounce(delayMilliseconds, callback) {
42
43
  return wrappedFunction;
43
44
  }
44
45
  function isWatchedInputFile(filePath) {
45
- return filePath.endsWith(".yaml") || filePath.endsWith(".json") || filePath.endsWith(".tsp");
46
+ return INPUT_EXTENSIONS.some((extension) => filePath.endsWith(extension));
46
47
  }
47
48
  /**
48
49
  * `stat`, or `null` when the path cannot be read.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-takibi",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",
@@ -1,42 +0,0 @@
1
- //#region src/constants/index.ts
2
- /** The kinds of the OpenAPI Components Object, in declaration and config-field order. */
3
- const COMPONENT_NAMES = [
4
- "schemas",
5
- "responses",
6
- "parameters",
7
- "examples",
8
- "requestBodies",
9
- "headers",
10
- "securitySchemes",
11
- "links",
12
- "callbacks",
13
- "pathItems",
14
- "mediaTypes"
15
- ];
16
- /** The query libraries the hooks are generated for, each a config key of its own. */
17
- const HOOK_LIBRARIES = [
18
- "swr",
19
- "tanstack-query",
20
- "preact-query",
21
- "solid-query",
22
- "vue-query",
23
- "svelte-query",
24
- "angular-query"
25
- ];
26
- /**
27
- * The HTTP methods an OpenAPI path item can hold, in the order the specification lists
28
- * them: OpenAPI 3.2 adds `query`. Operations of one path are generated in this order.
29
- */
30
- const HTTP_METHODS = [
31
- "get",
32
- "put",
33
- "post",
34
- "delete",
35
- "options",
36
- "head",
37
- "patch",
38
- "trace",
39
- "query"
40
- ];
41
- //#endregion
42
- export { HOOK_LIBRARIES as n, HTTP_METHODS as r, COMPONENT_NAMES as t };