hono-takibi 0.32.1 → 0.32.2
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 +5 -5
- package/dist/{core-BErYCEq-.js → core-CK8YfM5b.js} +3 -3
- package/dist/generate/index.js +1 -1
- package/dist/generator/mock/index.js +1 -1
- package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
- package/dist/{mock-D2cCG7D7.js → mock-DlS0Lyq6.js} +1 -1
- package/dist/{openapi-B8oA5BKZ.js → openapi-BMI5cgyx.js} +1 -1
- package/dist/{routes-BaXZEgTP.js → routes-EQul_g44.js} +9 -2
- package/dist/{shared-BohdqQVB.js → shared-CxGcNKCd.js} +2 -2
- package/dist/vite-plugin/index.js +2 -2
- package/package.json +1 -1
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.32.
|
|
8
|
+
var version = "0.32.2";
|
|
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-BxSVfs_l.js").then((n) => n.t),
|
|
43
43
|
import("./format-BF7SbaMP.js").then((n) => n.r),
|
|
44
|
-
import("./shared-
|
|
44
|
+
import("./shared-CxGcNKCd.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-
|
|
82
|
+
const { outsideSources } = yield* Effect.promise(() => import("./shared-CxGcNKCd.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-BxSVfs_l.js").then((n) => n.t),
|
|
211
|
-
import("./core-
|
|
212
|
-
import("./shared-
|
|
211
|
+
import("./core-CK8YfM5b.js").then((n) => n.t),
|
|
212
|
+
import("./shared-CxGcNKCd.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,9 +2,9 @@ import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
|
2
2
|
import { $ as HTTP_METHODS, G as isValidIdent, M as isRecord, O as isPathItem, S as isOperation, k as isPathItemEntry, m as isHttpMethod, q as COMPONENT_NAMES, u as isCallbacks, x as isOpenAPIPaths } from "./guard-Rvg4ztIZ.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, h as renderNamedImport, l as makeBarrel, x as uncapitalizeWord, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
|
|
5
|
-
import { C as makePathItem, D as makeWebhookEntries, E as makeRouteProperties, O as resolveParameter, S as makeCallback, T as makeRouteEntries, _ as identifierNames, a as requestBodiesCode, b as textOf, c as makeSplitSchemaFile, d as makeImports, f as makeModuleSpec, g as descendantsWhere, h as declarationOf, i as responsesCode, k as resolvePathItem, l as makeConst, m as ast, n as componentsCode, o as parametersCode, p as analyzeCircularSchemas, r as schemasCode, s as headersCode, u as makeExportConst, v as parseModule, w as makeRef, x as zodToOpenAPI, y as parseSource } from "./routes-
|
|
6
|
-
import { t as zodOpenAPIHono } from "./openapi-
|
|
7
|
-
import { t as makeMock } from "./mock-
|
|
5
|
+
import { C as makePathItem, D as makeWebhookEntries, E as makeRouteProperties, O as resolveParameter, S as makeCallback, T as makeRouteEntries, _ as identifierNames, a as requestBodiesCode, b as textOf, c as makeSplitSchemaFile, d as makeImports, f as makeModuleSpec, g as descendantsWhere, h as declarationOf, i as responsesCode, k as resolvePathItem, l as makeConst, m as ast, n as componentsCode, o as parametersCode, p as analyzeCircularSchemas, r as schemasCode, s as headersCode, u as makeExportConst, v as parseModule, w as makeRef, x as zodToOpenAPI, y as parseSource } from "./routes-EQul_g44.js";
|
|
6
|
+
import { t as zodOpenAPIHono } from "./openapi-BMI5cgyx.js";
|
|
7
|
+
import { t as makeMock } from "./mock-DlS0Lyq6.js";
|
|
8
8
|
import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-yhnsv_ji.js";
|
|
9
9
|
import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-hO_bjDys.js";
|
|
10
10
|
import { t as emit } from "./emit-8SmO5pHF.js";
|
package/dist/generate/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseConfig } from "../index.js";
|
|
2
2
|
import { t as FormatOptions } from "../format-BF7SbaMP.js";
|
|
3
3
|
import { n as parseOpenAPI } from "../openapi-BxSVfs_l.js";
|
|
4
|
-
import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-
|
|
4
|
+
import { a as packageRoots, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-CxGcNKCd.js";
|
|
5
5
|
import * as NodeServices from "@effect/platform-node/NodeServices";
|
|
6
6
|
import { Effect } from "effect";
|
|
7
7
|
// src/generate/index.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as makeMock } from "../../mock-
|
|
1
|
+
export { t as makeMock } from "../../mock-DlS0Lyq6.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as zodOpenAPIHono } from "../../../openapi-
|
|
1
|
+
export { t as zodOpenAPIHono } from "../../../openapi-BMI5cgyx.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as HTTP_METHODS, A as isPathItemRef, B as isSecurityArray, J as COMPONENT_REF_PREFIX, L as isSchemaArray, N as isRefObject, R as isSchemaObject, S as isOperation, V as isSecurityScheme, a as hasNumericConstraint, at as TEXT_MEDIA_TYPE, g as isInlineMedia, j as isPresent, k as isPathItemEntry, m as isHttpMethod, nt as JSON_MEDIA_TYPE, o as hasRequestBodyContent, w as isParameter, y as isMediaWithSchema } from "./guard-Rvg4ztIZ.js";
|
|
2
2
|
import { _ as routeName, a as ensureSuffix, d as makeSafeKey, f as makeStringLiteral, p as normalizeTypes, r as cyclicNodes, v as statusCodeToNumber, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
|
|
3
|
-
import { n as componentsCode, t as routeCode } from "./routes-
|
|
3
|
+
import { n as componentsCode, t as routeCode } from "./routes-EQul_g44.js";
|
|
4
4
|
// src/helper/faker.ts
|
|
5
5
|
const FORMAT_TO_FAKER = {
|
|
6
6
|
date: "faker.date.past().toISOString().slice(0, 10)",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as HTTP_METHODS, M as isRecord, Y as COMPONENT_SUFFIXES, q as COMPONENT_NAMES } from "./guard-Rvg4ztIZ.js";
|
|
2
2
|
import { a as ensureSuffix, i as decodePercent, y as toIdentifierPascalCase } from "./utils-yHmzthJJ.js";
|
|
3
|
-
import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-
|
|
3
|
+
import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-EQul_g44.js";
|
|
4
4
|
// src/helper/names.ts
|
|
5
5
|
/**
|
|
6
6
|
* Renames the components whose identifiers would collide, and every `$ref` to them.
|
|
@@ -2107,7 +2107,8 @@ function object(schema, options) {
|
|
|
2107
2107
|
const elseOverride = elseMessage ? `,message:${JSON.stringify(elseMessage)}` : "";
|
|
2108
2108
|
const propertiesMessage = schema["x-properties-message"];
|
|
2109
2109
|
const needsLoose = schema.additionalProperties === void 0 && (schema.patternProperties !== void 0 || schema.propertyNames !== void 0 || schema.unevaluatedProperties !== void 0 || Object.keys(schema.properties ?? {}).length === 0);
|
|
2110
|
-
const
|
|
2110
|
+
const hasPatternProperties = schema.patternProperties !== void 0 && Object.keys(schema.patternProperties).length > 0;
|
|
2111
|
+
const objectType = schema.additionalProperties === true ? "looseObject" : schema.additionalProperties === false ? hasPatternProperties ? "looseObject" : "strictObject" : needsLoose ? "looseObject" : "object";
|
|
2111
2112
|
const propertiesCode = schema.properties ? Object.entries(schema.properties).map(([key, propSchema]) => {
|
|
2112
2113
|
const isRequired = Array.isArray(schema.required) && schema.required.includes(key);
|
|
2113
2114
|
return `${makeSafeKey(key)}:${zodToOpenAPI(propSchema, void 0, {
|
|
@@ -2137,6 +2138,12 @@ function object(schema, options) {
|
|
|
2137
2138
|
const zodSchema = zodToOpenAPI(propSchema, void 0, options);
|
|
2138
2139
|
return `.superRefine((o,ctx)=>{const regex=new RegExp(${JSON.stringify(pattern)});const Schema=${zodSchema};for(const [k,val] of Object.entries(o)){if(!regex.test(k)){continue}const result=Schema.safeParse(val);if(!result.success){for(const issue of result.error.issues){ctx.addIssue({...issue,path:[k,...issue.path]${patternPropertiesMessageOverride}})}}}})`;
|
|
2139
2140
|
}).join("") : "";
|
|
2141
|
+
const undeclaredKeys = schema.additionalProperties === false && hasPatternProperties ? (() => {
|
|
2142
|
+
const declaredKeys = Object.keys(schema.properties ?? {});
|
|
2143
|
+
const patterns = Object.keys(schema.patternProperties ?? {});
|
|
2144
|
+
const messageField = additionalPropertiesMessage !== void 0 ? `,message:${JSON.stringify(additionalPropertiesMessage)}` : "";
|
|
2145
|
+
return `.superRefine((o,ctx)=>{const keys=Object.keys(o).filter((k)=>${[...declaredKeys.length > 0 ? [`!${JSON.stringify(declaredKeys)}.includes(k)`] : [], `!${JSON.stringify(patterns)}.some((p)=>new RegExp(p).test(k))`].join("&&")});if(keys.length>0){ctx.addIssue({code:"unrecognized_keys",keys,input:o${messageField}})}})`;
|
|
2146
|
+
})() : "";
|
|
2140
2147
|
const dependentRequired = schema.dependentRequired ? Object.entries(schema.dependentRequired).map(([key, deps]) => {
|
|
2141
2148
|
const stmts = deps.map((dependency) => {
|
|
2142
2149
|
const msg = dependentRequiredMessage ?? errorMessage ?? `requires "${dependency}" when "${key}" present`;
|
|
@@ -2147,7 +2154,7 @@ function object(schema, options) {
|
|
|
2147
2154
|
}).join("") : "";
|
|
2148
2155
|
const dependentSchemasMessage = schema["x-dependentSchemas-message"] ?? schema["x-error-message"];
|
|
2149
2156
|
const dependentSchemasMessageField = dependentSchemasMessage !== void 0 ? `,message:${JSON.stringify(dependentSchemasMessage)}` : "";
|
|
2150
|
-
return `${base}${minProperties}${maxProperties}${propertyNames}${patternProperties}${dependentRequired}${schema.dependentSchemas ? Object.entries(schema.dependentSchemas).map(([key, subSchema]) => {
|
|
2157
|
+
return `${base}${undeclaredKeys}${minProperties}${maxProperties}${propertyNames}${patternProperties}${dependentRequired}${schema.dependentSchemas ? Object.entries(schema.dependentSchemas).map(([key, subSchema]) => {
|
|
2151
2158
|
const subZod = zodToOpenAPI(subSchema, void 0, options);
|
|
2152
2159
|
return `.superRefine((o,ctx)=>{if(!Object.hasOwn(o,${JSON.stringify(key)})){return}const Schema=${subZod};const result=Schema.safeParse(o);if(!result.success){for(const issue of result.error.issues){ctx.addIssue({...issue,path:issue.path${dependentSchemasMessageField}})}}})`;
|
|
2153
2160
|
}).join("") : ""}${(() => {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
2
|
import { Q as HOOK_LIBRARIES, q as COMPONENT_NAMES } from "./guard-Rvg4ztIZ.js";
|
|
3
|
-
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-
|
|
3
|
+
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-CK8YfM5b.js";
|
|
4
4
|
import { t as docs } from "./docs-DC7Q_-PY.js";
|
|
5
5
|
import { t as hooks } from "./hooks-B2Fcpr_z.js";
|
|
6
6
|
import { rpc } from "./core/rpc/index.js";
|
|
7
7
|
import { type } from "./core/type/index.js";
|
|
8
8
|
import { i as GenerateError } from "./format-BF7SbaMP.js";
|
|
9
9
|
import { a as unlink, i as readdir, t as exists } from "./file-hO_bjDys.js";
|
|
10
|
-
import { n as normalizeOpenAPI } from "./openapi-
|
|
10
|
+
import { n as normalizeOpenAPI } from "./openapi-BMI5cgyx.js";
|
|
11
11
|
import { Effect, FileSystem, Schema } from "effect";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { parseConfig } from "../index.js";
|
|
2
2
|
import { M as isRecord, tt as INPUT_EXTENSIONS } from "../guard-Rvg4ztIZ.js";
|
|
3
3
|
import { t as FormatOptions } from "../format-BF7SbaMP.js";
|
|
4
|
-
import { C as isInsideDirectory, S as appEntryOutput } from "../core-
|
|
4
|
+
import { C as isInsideDirectory, S as appEntryOutput } from "../core-CK8YfM5b.js";
|
|
5
5
|
import { n as parseOpenAPI } from "../openapi-BxSVfs_l.js";
|
|
6
|
-
import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-
|
|
6
|
+
import { a as packageRoots, i as outsideSources, n as makeJob, r as openAPI3, t as cleanSplitOutputs } from "../shared-CxGcNKCd.js";
|
|
7
7
|
import { Effect, FileSystem, Option, Result } from "effect";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import crypto from "node:crypto";
|