hono-takibi 0.27.0 → 0.28.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
@@ -5,7 +5,7 @@ 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.27.0";
8
+ var version = "0.28.0";
9
9
  var description = "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi";
10
10
  // src/cli/index.ts
11
11
  const COMMAND_NAME = "hono-takibi";
@@ -41,7 +41,7 @@ function runJobs(config) {
41
41
  const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob, openAPI3, packageRoots }] = yield* Effect.promise(() => Promise.all([
42
42
  import("./openapi-tYYvoKiU.js").then((n) => n.t),
43
43
  import("./format-BF7SbaMP.js").then((n) => n.r),
44
- import("./shared-Ba1iJE80.js").then((n) => n.o)
44
+ import("./shared-CyBkG8gM.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-Ba1iJE80.js").then((n) => n.o));
82
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-CyBkG8gM.js").then((n) => n.o));
83
83
  const inputDirectory = path.dirname(path.resolve(config.input));
84
84
  return {
85
85
  inputDirectory,
@@ -208,8 +208,8 @@ function generate(args) {
208
208
  if (input !== void 0 && output !== void 0) {
209
209
  const [{ parseOpenAPI }, { takibi }, { openAPI3 }] = yield* Effect.promise(() => Promise.all([
210
210
  import("./openapi-tYYvoKiU.js").then((n) => n.t),
211
- import("./core-DWz4JxmP.js").then((n) => n.t),
212
- import("./shared-Ba1iJE80.js").then((n) => n.o)
211
+ import("./core-D141ZWzp.js").then((n) => n.t),
212
+ import("./shared-CyBkG8gM.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));
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
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, a as hasRequestBodyContent, d as isHttpMethod, g as isMediaWithSchema, i as hasNumericConstraint, k as isRefObject, p as isInlineMedia, s as isCallbacks, tt as TEXT_MEDIA_TYPE, v as isOpenAPIPaths, x as isParameter, y as isOperation } from "./guard-BH6yBr0M.js";
3
3
  import { i as GenerateError, n as fmt } from "./format-BF7SbaMP.js";
4
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-CDLiYepO.js";
5
- import { A as resolvePathItem, C as makeCallback, D as makeRouteProperties, E as makeRouteEntries, O as makeWebhookEntries, S as zodToOpenAPI, T as makeRef, _ as descendantsWhere, a as responsesCode, b as parseSource, c as headersCode, d as makeExportConst, f as makeImports, g as declarationOf, h as ast, i as schemasCode, k as resolveParameter, 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 identifierNames, w as makePathItem, x as textOf, y as parseModule } from "./openapi-DqpjdjTv.js";
5
+ import { A as resolvePathItem, C as makeCallback, D as makeRouteProperties, E as makeRouteEntries, O as makeWebhookEntries, S as zodToOpenAPI, T as makeRef, _ as descendantsWhere, a as responsesCode, b as parseSource, c as headersCode, d as makeExportConst, f as makeImports, g as declarationOf, h as ast, i as schemasCode, k as resolveParameter, 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 identifierNames, w as makePathItem, x as textOf, y as parseModule } from "./openapi-imhqgahL.js";
6
6
  import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-GDi7a_Ep.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";
@@ -1 +1 @@
1
- export { t as zodOpenAPIHono } from "../../../openapi-DqpjdjTv.js";
1
+ export { t as zodOpenAPIHono } from "../../../openapi-imhqgahL.js";
@@ -2206,6 +2206,8 @@ function zodToOpenAPI(schema, meta, options) {
2206
2206
  type: others.length === 0 ? first : [first, ...others]
2207
2207
  }, void 0, childOptions);
2208
2208
  })();
2209
+ const notIsBigint = normalizeTypes(schema.type).includes("integer") && (schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint");
2210
+ const notLiteral = (value) => typeof value === "number" && notIsBigint && Number.isInteger(value) ? schema.format === "bigint" ? `BigInt(${value})` : `${value}n` : JSON.stringify(value);
2209
2211
  const typePredicates = {
2210
2212
  string: `(val) => typeof val !== 'string'`,
2211
2213
  number: `(val) => typeof val !== 'number'`,
@@ -2216,7 +2218,7 @@ function zodToOpenAPI(schema, meta, options) {
2216
2218
  null: "(val) => val !== null"
2217
2219
  };
2218
2220
  if (typeof schema.not === "object" && schema.not.$ref !== void 0) return done(`${notBase}.refine((val) => !${makeRef(schema.not.$ref)}.safeParse(val).success${notErrorArg})`, schema);
2219
- if (typeof schema.not === "object" && "const" in schema.not) return done(`${notBase}.refine(${`(val) => val !== ${JSON.stringify(schema.not.const)}`}${notErrorArg})`, schema);
2221
+ if (typeof schema.not === "object" && "const" in schema.not) return done(`${notBase}.refine(${`(val) => val !== ${notLiteral(schema.not.const)}`}${notErrorArg})`, schema);
2220
2222
  const not = schema.not;
2221
2223
  if (typeof not === "object" && not !== null) {
2222
2224
  const onlyKeys = Object.keys(not);
@@ -2231,8 +2233,12 @@ function zodToOpenAPI(schema, meta, options) {
2231
2233
  const predicates = not.type.map((t) => typePredicates[t]).filter((v) => v !== void 0);
2232
2234
  if (predicates.length > 0) return done(`${notBase}.refine(${`(val) => ${predicates.map((v) => `(${v.replace(/^\(val\) => /u, "")})`).join(" && ")}`}${notErrorArg})`, schema);
2233
2235
  }
2234
- if (isPureEnum && Array.isArray(not.enum)) return done(`${notBase}.refine(${`(val) => !${JSON.stringify(not.enum)}.includes(val)`}${notErrorArg})`, schema);
2235
- if (onlyKeys.length === 1 && onlyKeys[0] === "const") return done(`${notBase}.refine(${`(val) => val !== ${JSON.stringify(not.const)}`}${notErrorArg})`, schema);
2236
+ if (isPureEnum && Array.isArray(not.enum)) {
2237
+ const members = notIsBigint ? not.enum.filter((member) => typeof member !== "number" || Number.isInteger(member)) : not.enum;
2238
+ if (members.length === 0) return done(notBase, schema);
2239
+ return done(`${notBase}.refine(${`(val) => !${`[${members.map(notLiteral).join(",")}]`}.includes(val)`}${notErrorArg})`, schema);
2240
+ }
2241
+ if (onlyKeys.length === 1 && onlyKeys[0] === "const") return done(`${notBase}.refine(${`(val) => val !== ${notLiteral(not.const)}`}${notErrorArg})`, schema);
2236
2242
  if (onlyKeys.length === 0) return done(`z.never(${notErrorArg.slice(1)})`, schema);
2237
2243
  return done(`${notBase}.refine((val) => !${zodToOpenAPI(not, void 0, childOptions)}.safeParse(val).success${notErrorArg})`, schema);
2238
2244
  }
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
2
2
  import { J as HOOK_LIBRARIES, U as COMPONENT_NAMES } from "./guard-BH6yBr0M.js";
3
3
  import { i as GenerateError } from "./format-BF7SbaMP.js";
4
- 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-DWz4JxmP.js";
4
+ 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-D141ZWzp.js";
5
5
  import { a as unlink, i as readdir, t as exists } from "./file-Bip_L0oR.js";
6
6
  import { t as hooks } from "./hooks-CKIK30qr.js";
7
7
  import { t as docs } from "./docs-CDFG1tXT.js";
@@ -1,9 +1,9 @@
1
1
  import { O as isRecord, Z as INPUT_EXTENSIONS } from "../guard-BH6yBr0M.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-DWz4JxmP.js";
4
+ import { C as isInsideDirectory, S as appEntryOutput } from "../core-D141ZWzp.js";
5
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-Ba1iJE80.js";
6
+ import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-CyBkG8gM.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.27.0",
3
+ "version": "0.28.0",
4
4
  "description": "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi",
5
5
  "keywords": [
6
6
  "hono",