hono-takibi 0.32.7 → 0.33.1
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/docs/index.js +1 -1
- package/dist/core/hooks/index.js +1 -1
- package/dist/core/rpc/index.js +1 -1
- package/dist/core/type/index.js +1 -1
- package/dist/{core-DJqmOPWS.js → core-CajXzO16.js} +72 -47
- package/dist/{docs-DBwSKGaM.js → docs-hKJj12Gm.js} +1 -1
- 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/{hooks-CsA2SljZ.js → hooks-CSMf3pkH.js} +1 -1
- package/dist/index.js +2 -2
- package/dist/{mock-DhrSrJnW.js → mock-CvrfyklR.js} +2 -2
- package/dist/{openapi-B8_W08n6.js → openapi-BMJPrf4w.js} +113 -6
- package/dist/{routes-4irjKKsY.js → routes-Cg-imktp.js} +1 -1
- package/dist/{shared-BbFXOrwK.js → shared-BrQVwt_b.js} +5 -5
- package/dist/{utils-gcCWw1ZJ.js → utils-BeXPKXuG.js} +1 -8
- 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.
|
|
8
|
+
var version = "0.33.1";
|
|
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-BrQVwt_b.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-BrQVwt_b.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-CajXzO16.js").then((n) => n.t),
|
|
212
|
+
import("./shared-BrQVwt_b.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));
|
package/dist/core/docs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as docs } from "../../docs-
|
|
1
|
+
export { t as docs } from "../../docs-hKJj12Gm.js";
|
package/dist/core/hooks/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as hooks } from "../../hooks-
|
|
1
|
+
export { t as hooks } from "../../hooks-CSMf3pkH.js";
|
package/dist/core/rpc/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { N as isRecord, S as isOpenAPIPaths, et as HTTP_METHODS, w as isOperatio
|
|
|
2
2
|
import { t as emit } from "../../emit-8SmO5pHF.js";
|
|
3
3
|
import { i as GenerateError } from "../../format-BF7SbaMP.js";
|
|
4
4
|
import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "../../rpc-DALShbf3.js";
|
|
5
|
-
import { _ as routeName, u as makeInferRequestType } from "../../utils-
|
|
5
|
+
import { _ as routeName, u as makeInferRequestType } from "../../utils-BeXPKXuG.js";
|
|
6
6
|
import { Effect } from "effect";
|
|
7
7
|
import { dirname } from "node:path";
|
|
8
8
|
// src/core/rpc/index.ts
|
package/dist/core/type/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { C as isOperation, E as isParameterArray, I as isRequestBody, M as isPresent, R as isSchemaArray, S as isOpenAPIPaths, T as isParameter, W as isStringRef, b as isMediaWithSchema, h as isHttpMethod, u as isBinaryFile } from "../../guard-ngBos42D.js";
|
|
2
2
|
import { t as emit } from "../../emit-8SmO5pHF.js";
|
|
3
|
-
import { d as makeSafeKey, v as statusCodeToNumber, y as toIdentifierPascalCase } from "../../utils-
|
|
3
|
+
import { d as makeSafeKey, v as statusCodeToNumber, y as toIdentifierPascalCase } from "../../utils-BeXPKXuG.js";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
// src/core/type/index.ts
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
2
|
import { A as isPathItemEntry, C as isOperation, J as COMPONENT_NAMES, K as isValidIdent, N as isRecord, S as isOpenAPIPaths, d as isCallbacks, et as HTTP_METHODS, h as isHttpMethod, k as isPathItem } from "./guard-ngBos42D.js";
|
|
3
3
|
import { i as GenerateError, n as fmt } from "./format-BF7SbaMP.js";
|
|
4
|
-
import {
|
|
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-
|
|
4
|
+
import { _ as routeName, a as ensureSuffix, b as uncapitalize, c as escapeRegexLiteral, h as renderNamedImport, l as makeBarrel, x as zodToOpenAPISchema, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.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-Cg-imktp.js";
|
|
6
|
+
import { t as zodOpenAPIHono } from "./openapi-BMJPrf4w.js";
|
|
7
|
+
import { t as makeMock } from "./mock-CvrfyklR.js";
|
|
8
8
|
import { a as entryNames, c as makeGroupClientName, l as operationTags, o as freeName, s as groupNameOf } from "./rpc-DALShbf3.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";
|
|
11
|
-
import { t as hooks } from "./hooks-
|
|
12
|
-
import { t as docs } from "./docs-
|
|
11
|
+
import { t as hooks } from "./hooks-CSMf3pkH.js";
|
|
12
|
+
import { t as docs } from "./docs-hKJj12Gm.js";
|
|
13
13
|
import { rpc } from "./core/rpc/index.js";
|
|
14
14
|
import { type } from "./core/type/index.js";
|
|
15
15
|
import { Effect } from "effect";
|
|
@@ -719,22 +719,47 @@ function sanitizeHandlerSegment(segment) {
|
|
|
719
719
|
return segment.replaceAll(/\{([^}]+)\}/gu, "$1").replaceAll(/[^0-9A-Za-z._-]/gu, "_").replaceAll(/^[._-]+|[._-]+$/gu, "").replaceAll(/__+/gu, "_").replaceAll(/[-._](\w)/gu, (_, char) => char.toUpperCase());
|
|
720
720
|
}
|
|
721
721
|
/**
|
|
722
|
-
*
|
|
723
|
-
*
|
|
722
|
+
* A tag or a path segment in kebab case: every run of what is no letter or digit is a word
|
|
723
|
+
* break, and so is a change of case, an acronym being one word. `Real-Time Events` as
|
|
724
|
+
* `real-time-events`, `userAPIKeys` as `user-api-keys`, `{org_id}` as `org-id`.
|
|
724
725
|
*/
|
|
725
|
-
function
|
|
726
|
-
|
|
727
|
-
const pathName = sanitizeHandlerSegment(path.replace(/^\/+/u, "").split("/")[0] ?? "");
|
|
728
|
-
return `${tagName !== "" ? tagName : pathName !== "" ? pathName : "__root"}.ts`;
|
|
726
|
+
function kebabHandlerSegment(segment) {
|
|
727
|
+
return segment.replaceAll(/\{([^}]+)\}/gu, "$1").replaceAll(/[^0-9A-Za-z]+/gu, "-").replaceAll(/([a-z0-9])([A-Z])/gu, "$1-$2").replaceAll(/([A-Z])([A-Z][a-z])/gu, "$1-$2").replaceAll(/^-+|-+$/gu, "").toLowerCase();
|
|
729
728
|
}
|
|
730
729
|
/**
|
|
731
|
-
* The
|
|
732
|
-
*
|
|
733
|
-
*
|
|
734
|
-
*
|
|
730
|
+
* The name a handler file goes by in code, whatever the case of the file: the base name with
|
|
731
|
+
* its hyphens read as word breaks, `real-time-events.ts` as `realTimeEvents`. A file named in
|
|
732
|
+
* camel case goes by its base name as it is. The export of an inline handler file
|
|
733
|
+
* (`realTimeEventsHandler`) and its group are made of this name.
|
|
735
734
|
*/
|
|
736
|
-
function
|
|
737
|
-
return
|
|
735
|
+
function handlerNameOf(fileName) {
|
|
736
|
+
return basename(fileName, ".ts").replaceAll(/-+([0-9A-Za-z_]?)/gu, (_, char) => char.toUpperCase());
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Derives the handler file name for an operation, in kebab case: the first segment of its
|
|
740
|
+
* path (`/` → `__root`), `/real-time-events/{id}` as `real-time-events.ts`. The tags of the
|
|
741
|
+
* operation say nothing of the file.
|
|
742
|
+
*/
|
|
743
|
+
function makeHandlerFileName(path) {
|
|
744
|
+
const name = kebabHandlerSegment(path.replace(/^\/+/u, "").split("/")[0] ?? "");
|
|
745
|
+
return `${name !== "" ? name : "__root"}.ts`;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* The group of the handler file an operation is written to: the name that file goes by in
|
|
749
|
+
* code, `real-time-events.ts` as `realTimeEvents`, and the root `/` as `__root`. A name that
|
|
750
|
+
* is a word of the language is prefixed the same way, `/delete` as `__delete`.
|
|
751
|
+
*/
|
|
752
|
+
function handlerGroupOf(path) {
|
|
753
|
+
return groupNameOf(handlerNameOf(makeHandlerFileName(path)));
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* The group of a path where the app registers the routes itself and no handler file stands
|
|
757
|
+
* for the group: the first segment in camel case as it is written, `/v2-public/ping` as
|
|
758
|
+
* `v2Public`, with the same prefix for the root and for a word of the language.
|
|
759
|
+
*/
|
|
760
|
+
function pathGroupOf(path) {
|
|
761
|
+
const name = sanitizeHandlerSegment(path.replace(/^\/+/u, "").split("/")[0] ?? "");
|
|
762
|
+
return groupNameOf(name !== "" ? name : "__root");
|
|
738
763
|
}
|
|
739
764
|
function isTsFileName(file) {
|
|
740
765
|
return file.endsWith(".ts");
|
|
@@ -765,15 +790,17 @@ function scanExistingHandlerFiles(handlerPath, collect) {
|
|
|
765
790
|
}
|
|
766
791
|
/**
|
|
767
792
|
* Picks the file a generated export goes to: the file that already holds it, else the
|
|
768
|
-
* expected name when that file exists, else an existing file
|
|
769
|
-
* case
|
|
793
|
+
* expected name when that file exists, else an existing file that goes by the same name in
|
|
794
|
+
* code whatever its case (`realTimeEvents.ts` for `real-time-events.ts`, and a file that
|
|
795
|
+
* differs by case alone, as on a case-insensitive filesystem), else the expected name. A
|
|
796
|
+
* project whose files were written in camel case keeps them.
|
|
770
797
|
*/
|
|
771
798
|
function resolveHandlerFileName(expected, key, existing) {
|
|
772
799
|
const located = existing.locations.get(key);
|
|
773
800
|
if (located) return located;
|
|
774
801
|
if (existing.fileNames.includes(expected)) return expected;
|
|
775
|
-
const
|
|
776
|
-
return existing.fileNames.find((file) => file.toLowerCase() ===
|
|
802
|
+
const name = handlerNameOf(expected).toLowerCase();
|
|
803
|
+
return existing.fileNames.find((file) => handlerNameOf(file).toLowerCase() === name) ?? expected;
|
|
777
804
|
}
|
|
778
805
|
/**
|
|
779
806
|
* Files the scan found codegen keys in but that hold no route of the current spec. They are
|
|
@@ -798,24 +825,24 @@ function makePaths(output, pathAlias, routeImport) {
|
|
|
798
825
|
importFrom: routeImport ?? (aliasPrefix ? `${aliasPrefix}/${routeModuleName}` : `../${routeModuleName}`)
|
|
799
826
|
};
|
|
800
827
|
}
|
|
801
|
-
function makeHandlerInfo(paths, path, method,
|
|
828
|
+
function makeHandlerInfo(paths, path, method, existing, member, body) {
|
|
802
829
|
const routeId = routeName(method, path, paths);
|
|
803
830
|
return {
|
|
804
|
-
fileName: resolveHandlerFileName(makeHandlerFileName(path
|
|
831
|
+
fileName: resolveHandlerFileName(makeHandlerFileName(path), `${routeId}${member}`, existing),
|
|
805
832
|
contents: [body(routeId)],
|
|
806
833
|
routeNames: [`${routeId}Route`]
|
|
807
834
|
};
|
|
808
835
|
}
|
|
809
|
-
function makeInlineStubHandlerInfo(paths, path, method,
|
|
810
|
-
return makeHandlerInfo(paths, path, method,
|
|
836
|
+
function makeInlineStubHandlerInfo(paths, path, method, existing) {
|
|
837
|
+
return makeHandlerInfo(paths, path, method, existing, "Route", (routeId) => `.openapi(${routeId}Route,(c)=>{})`);
|
|
811
838
|
}
|
|
812
839
|
function makeInlineStubFileContent(handler, importFrom) {
|
|
813
|
-
const exportName = `${
|
|
840
|
+
const exportName = `${handlerNameOf(handler.fileName)}Handler`;
|
|
814
841
|
const routeImports = [...new Set(handler.routeNames)].join(", ");
|
|
815
842
|
return `${`import { OpenAPIHono } from '@hono/zod-openapi'\n${routeImports ? `import { ${routeImports} } from '${importFrom}';` : ""}`}\n\nconst app = new OpenAPIHono()\n\nexport const ${exportName} = app\n${handler.contents.join("\n")}`;
|
|
816
843
|
}
|
|
817
|
-
function makeStubHandlerInfo(paths, path, method,
|
|
818
|
-
return makeHandlerInfo(paths, path, method,
|
|
844
|
+
function makeStubHandlerInfo(paths, path, method, existing) {
|
|
845
|
+
return makeHandlerInfo(paths, path, method, existing, "RouteHandler", (routeId) => `export const ${routeId}RouteHandler:RouteHandler<typeof ${routeId}Route>=async(c)=>{}`);
|
|
819
846
|
}
|
|
820
847
|
function makeMergedHandlers(handlers) {
|
|
821
848
|
const handlerMap = /* @__PURE__ */ new Map();
|
|
@@ -879,7 +906,7 @@ function zodOpenAPIHonoHandler(openapi, output, pathAlias, routeImport, routeHan
|
|
|
879
906
|
const paths = openapi.paths;
|
|
880
907
|
const { handlerPath, importFrom } = makePaths(output, pathAlias, routeImport);
|
|
881
908
|
const existing = yield* scanExistingHandlerFiles(handlerPath, routeHandler ? (code) => collectExportedNames(code, "RouteHandler") : collectInlineRouteNames);
|
|
882
|
-
const specHandlers = makeMergedHandlers(Object.entries(paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method
|
|
909
|
+
const specHandlers = makeMergedHandlers(Object.entries(paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method]) => routeHandler ? makeStubHandlerInfo(paths, path, method, existing) : makeInlineStubHandlerInfo(paths, path, method, existing))));
|
|
883
910
|
const handlers = [...specHandlers, ...makeOrphanHandlers(existing, specHandlers.map((handler) => handler.fileName))];
|
|
884
911
|
yield* mkdir(handlerPath);
|
|
885
912
|
yield* Effect.all([...handlers.map((handler) => writeHandler({
|
|
@@ -899,7 +926,7 @@ function resolveInlineHandlerFileNames(openapi, output, pathAlias, routeImport)
|
|
|
899
926
|
return Effect.gen(function* () {
|
|
900
927
|
const { handlerPath } = makePaths(output, pathAlias, routeImport);
|
|
901
928
|
const existing = yield* scanExistingHandlerFiles(handlerPath, collectInlineRouteNames);
|
|
902
|
-
const fileNames = Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method
|
|
929
|
+
const fileNames = Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).filter((entry) => isHttpMethod(entry[0]) && isOperation(entry[1])).map(([method]) => resolveHandlerFileName(makeHandlerFileName(path), `${routeName(method, path, openapi.paths)}Route`, existing)));
|
|
903
930
|
return [...new Set(fileNames)];
|
|
904
931
|
});
|
|
905
932
|
}
|
|
@@ -916,7 +943,7 @@ function defineOpenAPIRouteHandler(openapi, output, componentsOutput, pathAlias,
|
|
|
916
943
|
const handlerPath = baseDir === "." ? "routes" : `${baseDir}/routes`;
|
|
917
944
|
const existing = yield* scanExistingHandlerFiles(handlerPath, (code) => collectExportedNames(code, "Route"));
|
|
918
945
|
const specHandlers = defineEntries(openapi, readonly).reduce((acc, entry) => {
|
|
919
|
-
const fileName = resolveHandlerFileName(makeHandlerFileName(entry.path
|
|
946
|
+
const fileName = resolveHandlerFileName(makeHandlerFileName(entry.path), `${entry.name}Route`, existing);
|
|
920
947
|
const prev = acc.get(fileName);
|
|
921
948
|
return new Map(acc).set(fileName, {
|
|
922
949
|
fileName,
|
|
@@ -1389,7 +1416,7 @@ function takibi(openAPI, output, componentsOptions = {}) {
|
|
|
1389
1416
|
// src/generator/zod-openapi-hono/app/index.ts
|
|
1390
1417
|
/** The handler files the operations of a document are written to, in document order. */
|
|
1391
1418
|
function handlerFilesOf(openapi) {
|
|
1392
|
-
return [...new Set(Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).flatMap(([method, operation]) => isHttpMethod(method) && isOperation(operation) ? [makeHandlerFileName(path
|
|
1419
|
+
return [...new Set(Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.entries(pathItem).flatMap(([method, operation]) => isHttpMethod(method) && isOperation(operation) ? [makeHandlerFileName(path)] : [])))];
|
|
1393
1420
|
}
|
|
1394
1421
|
/**
|
|
1395
1422
|
* The groups of a split app, in the order their first route stands in the document: the
|
|
@@ -1402,7 +1429,7 @@ function handlerFilesOf(openapi) {
|
|
|
1402
1429
|
*/
|
|
1403
1430
|
function appGroups(openapi, inline, inlineHandlerFileNames, split) {
|
|
1404
1431
|
if (!split) return [];
|
|
1405
|
-
const names = inline ? (inlineHandlerFileNames ?? handlerFilesOf(openapi)).map((file) => groupNameOf(
|
|
1432
|
+
const names = inline ? (inlineHandlerFileNames ?? handlerFilesOf(openapi)).map((file) => groupNameOf(handlerNameOf(file))) : Object.entries(openapi.paths).flatMap(([path, pathItem]) => Object.keys(pathItem).flatMap((method) => isHttpMethod(method) ? [pathGroupOf(path)] : []));
|
|
1406
1433
|
return [...new Set(names)];
|
|
1407
1434
|
}
|
|
1408
1435
|
/**
|
|
@@ -1443,7 +1470,7 @@ function app(openapi, output, basePath, pathAlias, routeImport, routeHandler = f
|
|
|
1443
1470
|
importSection,
|
|
1444
1471
|
appInit,
|
|
1445
1472
|
...groups.map((name) => {
|
|
1446
|
-
const routes = [...new Set(routeMappings.filter(({ path }) =>
|
|
1473
|
+
const routes = [...new Set(routeMappings.filter(({ path }) => pathGroupOf(path) === name).map(({ routeName }) => routeName))];
|
|
1447
1474
|
return `export const ${name}=${appVar}.openapiRoutes([${routes.join(",")}] as const)`;
|
|
1448
1475
|
}),
|
|
1449
1476
|
appExport
|
|
@@ -1457,18 +1484,16 @@ function app(openapi, output, basePath, pathAlias, routeImport, routeHandler = f
|
|
|
1457
1484
|
}
|
|
1458
1485
|
if (!routeHandler) {
|
|
1459
1486
|
const handlerFileNames = inlineHandlerFileNames ?? handlerFilesOf(openapi);
|
|
1460
|
-
const
|
|
1487
|
+
const files = [...new Set(handlerFileNames.map(handlerNameOf))];
|
|
1488
|
+
const handlerExportNames = files.map((file) => `${file}Handler`);
|
|
1461
1489
|
const handlerModule = handlerModuleOverride ?? (aliasPrefix ? `${aliasPrefix}/handlers` : "./handlers");
|
|
1462
1490
|
const importSection = [honoImport, handlerExportNames.length > 0 ? `import{${handlerExportNames.join(",")}}from'${handlerModule}'` : ""].filter(Boolean).join("\n");
|
|
1463
|
-
if (split)
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
appExport
|
|
1470
|
-
].join("\n\n");
|
|
1471
|
-
}
|
|
1491
|
+
if (split) return [
|
|
1492
|
+
importSection,
|
|
1493
|
+
appInit,
|
|
1494
|
+
...groups.map((name) => `export const ${name}=${appVar}${files.filter((file) => groupNameOf(file) === name).map((file) => `.route('/',${file}Handler)`).join("")}`),
|
|
1495
|
+
appExport
|
|
1496
|
+
].join("\n\n");
|
|
1472
1497
|
return [
|
|
1473
1498
|
importSection,
|
|
1474
1499
|
appInit,
|
|
@@ -1495,7 +1520,7 @@ function app(openapi, output, basePath, pathAlias, routeImport, routeHandler = f
|
|
|
1495
1520
|
return [
|
|
1496
1521
|
importSection,
|
|
1497
1522
|
appInit,
|
|
1498
|
-
...groups.map((name) => `export const ${name}=${appVar}${routeMappings.filter(({ path }) =>
|
|
1523
|
+
...groups.map((name) => `export const ${name}=${appVar}${routeMappings.filter(({ path }) => pathGroupOf(path) === name).map(({ routeName, handlerName }) => `.openapi(${routeName},${handlerName})`).join("\n")}`),
|
|
1499
1524
|
appExport
|
|
1500
1525
|
].join("\n\n");
|
|
1501
1526
|
}
|
|
@@ -1576,4 +1601,4 @@ var core_exports = /* @__PURE__ */ __exportAll({
|
|
|
1576
1601
|
type: () => type,
|
|
1577
1602
|
webhooks: () => webhooks
|
|
1578
1603
|
});
|
|
1579
|
-
export {
|
|
1604
|
+
export { appEntryOutput as C, makeGeneratedImport as D, makeAppEntryImport as E, pathGroupOf as S, makeAppEntryFile as T, headers as _, takibi as a, client as b, securitySchemes as c, requestBodies as d, pathItems as f, links as g, mediaTypes as h, defineTemplate as i, schemas as l, components as m, webhooks as n, route as o, parameters as p, template as r, mock as s, core_exports as t, responses as u, examples as v, isInsideDirectory as w, handlerGroupOf as x, callbacks as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as mkdir, o as writeFile } from "./file-hO_bjDys.js";
|
|
2
2
|
import { N as isRecord, P as isRefObject, R as isSchemaArray, et as HTTP_METHODS, it as MULTIPART_MEDIA_TYPE } from "./guard-ngBos42D.js";
|
|
3
|
-
import { i as decodePercent, s as escapeHtml } from "./utils-
|
|
3
|
+
import { i as decodePercent, s as escapeHtml } from "./utils-BeXPKXuG.js";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { STATUS_CODES } from "node:http";
|
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-BrQVwt_b.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-CvrfyklR.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as zodOpenAPIHono } from "../../../openapi-
|
|
1
|
+
export { t as zodOpenAPIHono } from "../../../openapi-BMJPrf4w.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { N as isRecord, S as isOpenAPIPaths, et as HTTP_METHODS, i as hasNoContentResponse, w as isOperationLike } from "./guard-ngBos42D.js";
|
|
2
2
|
import { t as emit } from "./emit-8SmO5pHF.js";
|
|
3
3
|
import { i as GenerateError } from "./format-BF7SbaMP.js";
|
|
4
|
-
import { _ as routeName, n as capitalize, y as toIdentifierPascalCase } from "./utils-
|
|
4
|
+
import { _ as routeName, n as capitalize, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
|
|
5
5
|
import { c as makeGroupClientName, i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, t as formatPath } from "./rpc-DALShbf3.js";
|
|
6
6
|
import { Effect } from "effect";
|
|
7
7
|
import path from "node:path";
|
package/dist/index.js
CHANGED
|
@@ -44,14 +44,14 @@ const ConfigSchema = Schema.Struct({
|
|
|
44
44
|
})),
|
|
45
45
|
template: Schema.optionalKey(Schema.Union([Schema.Struct({
|
|
46
46
|
define: Schema.Literal(true).annotate({ description: "Emit `defineOpenAPIRoute({ route, handler })` entries. Derives `routes/` next to the app entry, so it cannot be combined with `routes` or per-type component outputs." }),
|
|
47
|
-
split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public
|
|
47
|
+
split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public`. The tags of an operation do not divide the routes. The root belongs to no group." }),
|
|
48
48
|
test: Schema.optionalKey(Schema.Never.annotate({ message: "test was removed: hono-takibi no longer generates test files. The `.test.ts` files a previous run wrote are yours to keep or delete." })),
|
|
49
49
|
pathAlias: Schema.optionalKey(Schema.Never.annotate({ message: "pathAlias was moved to the top level: it applies to every generated file of this package, not only to the scaffold." })),
|
|
50
50
|
testFramework: Schema.optionalKey(Schema.Never.annotate({ message: "testFramework was removed: hono-takibi no longer generates test files." }))
|
|
51
51
|
}), Schema.Struct({
|
|
52
52
|
define: Schema.Literal(false).pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Scaffold app and handler files (default)." }),
|
|
53
53
|
routeHandler: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Emit the `app.openapi()` pattern with `RouteHandler` type exports. When false, handlers import the app and register routes inline." }),
|
|
54
|
-
split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public
|
|
54
|
+
split: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))).annotate({ description: "Divide the routes into groups, each exported under its name, and the rest as `api`. Every group is registered on the one app; what is divided is the type, so that a client of one group resolves the routes of that group and not of the whole application. A group is the first segment of the path, `/books` and `/books/{id}` as `books` and `/v2-public/ping` as `v2Public`. The tags of an operation do not divide the routes. The root belongs to no group." }),
|
|
55
55
|
test: Schema.optionalKey(Schema.Never.annotate({ message: "test was removed: hono-takibi no longer generates test files. The `.test.ts` files a previous run wrote are yours to keep or delete." })),
|
|
56
56
|
pathAlias: Schema.optionalKey(Schema.Never.annotate({ message: "pathAlias was moved to the top level: it applies to every generated file of this package, not only to the scaffold." })),
|
|
57
57
|
testFramework: Schema.optionalKey(Schema.Never.annotate({ message: "testFramework was removed: hono-takibi no longer generates test files." }))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as isPathItemEntry, C as isOperation, H as isSecurityScheme, M as isPresent, P as isRefObject, R as isSchemaArray, T as isParameter, V as isSecurityArray, Y as COMPONENT_REF_PREFIX, _ as isInlineMedia, b as isMediaWithSchema, et as HTTP_METHODS, h as isHttpMethod, j as isPathItemRef, o as hasNumericConstraint, ot as TEXT_MEDIA_TYPE, rt as JSON_MEDIA_TYPE, s as hasRequestBodyContent, z as isSchemaObject } from "./guard-ngBos42D.js";
|
|
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-
|
|
3
|
-
import { n as componentsCode, t as routeCode } from "./routes-
|
|
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-BeXPKXuG.js";
|
|
3
|
+
import { n as componentsCode, t as routeCode } from "./routes-Cg-imktp.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
|
-
import { J as COMPONENT_NAMES, N as isRecord, X as COMPONENT_SUFFIXES, et as HTTP_METHODS } from "./guard-ngBos42D.js";
|
|
2
|
-
import { a as ensureSuffix, i as decodePercent, y as toIdentifierPascalCase } from "./utils-
|
|
3
|
-
import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-
|
|
1
|
+
import { J as COMPONENT_NAMES, N as isRecord, X as COMPONENT_SUFFIXES, Y as COMPONENT_REF_PREFIX, et as HTTP_METHODS } from "./guard-ngBos42D.js";
|
|
2
|
+
import { a as ensureSuffix, i as decodePercent, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
|
|
3
|
+
import { D as makeWebhookEntries, n as componentsCode, t as routeCode } from "./routes-Cg-imktp.js";
|
|
4
4
|
// src/helper/names.ts
|
|
5
5
|
/**
|
|
6
6
|
* Renames the components whose identifiers would collide, and every `$ref` to them.
|
|
@@ -275,11 +275,118 @@ function resolveEmbeddedRefs(document) {
|
|
|
275
275
|
* The document as every generator reads it: the pointers of an embedded schema resource read
|
|
276
276
|
* against the resource, inline pointers written out where they stand, recursive ones declared
|
|
277
277
|
* as components, components whose names would make one identifier
|
|
278
|
-
* told apart,
|
|
279
|
-
* left out
|
|
278
|
+
* told apart, the Specification Extensions of the Paths, Responses and Callback Objects
|
|
279
|
+
* left out, and the parameters a path template names without declaring them declared. A
|
|
280
|
+
* document none of this touches comes back as it is.
|
|
280
281
|
*/
|
|
281
282
|
function normalizeOpenAPI(document) {
|
|
282
|
-
return withoutExtensions(uniqueComponentNames(inlinePointerRefs(hoistRecursivePointers(resolveEmbeddedRefs(document)))));
|
|
283
|
+
return withTemplateParameters(withoutExtensions(uniqueComponentNames(inlinePointerRefs(hoistRecursivePointers(resolveEmbeddedRefs(document))))));
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* The operations whose path template names a parameter that neither the operation nor its
|
|
287
|
+
* path item declares as `in: path`: `GET /users/{id}` with no `id` in `parameters` (#508).
|
|
288
|
+
* OpenAPI says every template expression MUST correspond to a path parameter, so such a
|
|
289
|
+
* document is invalid, but it is met (Knock).
|
|
290
|
+
*/
|
|
291
|
+
function undeclaredTemplateParameters(document) {
|
|
292
|
+
if (!isRecord(document.paths)) return [];
|
|
293
|
+
return Object.entries(document.paths).flatMap(([path, entry]) => {
|
|
294
|
+
const template = templateNames(path);
|
|
295
|
+
if (template.length === 0) return [];
|
|
296
|
+
const item = resolvedPathItem(entry, document);
|
|
297
|
+
if (item === void 0) return [];
|
|
298
|
+
const shared = declaredPathNames(item.parameters, document);
|
|
299
|
+
return HTTP_METHODS.flatMap((method) => {
|
|
300
|
+
const operation = item[method];
|
|
301
|
+
if (!isRecord(operation)) return [];
|
|
302
|
+
const declared = /* @__PURE__ */ new Set([...shared, ...declaredPathNames(operation.parameters, document)]);
|
|
303
|
+
const names = template.filter((name) => !declared.has(name));
|
|
304
|
+
return names.length === 0 ? [] : [{
|
|
305
|
+
path,
|
|
306
|
+
method,
|
|
307
|
+
names
|
|
308
|
+
}];
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The document with every parameter a path template names declared (#508): one that neither
|
|
314
|
+
* the operation nor its path item declares is added to the operation as a required string
|
|
315
|
+
* `in: path` parameter, which is what the template says of it. Hono types `param` from the
|
|
316
|
+
* path only when a route declares none, so a route that left one out took `undefined` or
|
|
317
|
+
* could not be given the segment; with the names taken from the template, the route, the
|
|
318
|
+
* client type and the URL agree.
|
|
319
|
+
*
|
|
320
|
+
* A path item that is a `$ref` has its operations in the component, which other paths may
|
|
321
|
+
* share: the parameters are added beside the `$ref`, to the path item, where an operation
|
|
322
|
+
* that declares one of its own still overrides it.
|
|
323
|
+
*/
|
|
324
|
+
function withTemplateParameters(document) {
|
|
325
|
+
const undeclared = undeclaredTemplateParameters(document);
|
|
326
|
+
if (undeclared.length === 0 || !isRecord(document.paths)) return document;
|
|
327
|
+
const paths = Object.fromEntries(Object.entries(document.paths).map(([path, item]) => {
|
|
328
|
+
const found = undeclared.filter((operation) => operation.path === path);
|
|
329
|
+
if (found.length === 0 || !isRecord(item)) return [path, item];
|
|
330
|
+
if (typeof item.$ref === "string") {
|
|
331
|
+
const names = [...new Set(found.flatMap((operation) => operation.names))];
|
|
332
|
+
return [path, {
|
|
333
|
+
...item,
|
|
334
|
+
parameters: withAdded(resolvedPathItem(item, document)?.parameters, names)
|
|
335
|
+
}];
|
|
336
|
+
}
|
|
337
|
+
return [path, {
|
|
338
|
+
...item,
|
|
339
|
+
...Object.fromEntries(found.map(({ method, names }) => {
|
|
340
|
+
const operation = item[method];
|
|
341
|
+
return [method, isRecord(operation) ? {
|
|
342
|
+
...operation,
|
|
343
|
+
parameters: withAdded(operation.parameters, names)
|
|
344
|
+
} : operation];
|
|
345
|
+
}))
|
|
346
|
+
}];
|
|
347
|
+
}));
|
|
348
|
+
const result = {
|
|
349
|
+
...document,
|
|
350
|
+
paths
|
|
351
|
+
};
|
|
352
|
+
return isOpenAPI(result) ? result : document;
|
|
353
|
+
}
|
|
354
|
+
function withAdded(parameters, names) {
|
|
355
|
+
return [...Array.isArray(parameters) ? parameters : [], ...names.map((name) => ({
|
|
356
|
+
name,
|
|
357
|
+
in: "path",
|
|
358
|
+
required: true,
|
|
359
|
+
schema: { type: "string" }
|
|
360
|
+
}))];
|
|
361
|
+
}
|
|
362
|
+
/** The names in the template expressions of a path, `id` for `/users/{id}`, each once. */
|
|
363
|
+
function templateNames(path) {
|
|
364
|
+
return [...new Set([...path.matchAll(/\{([^}]+)\}/gu)].flatMap((match) => match[1] ?? []))];
|
|
365
|
+
}
|
|
366
|
+
/** The path item of a `paths` entry, a `$ref` into `components.pathItems` resolved as the routes resolve it. */
|
|
367
|
+
function resolvedPathItem(item, document) {
|
|
368
|
+
if (!isRecord(item)) return void 0;
|
|
369
|
+
const ref = item.$ref;
|
|
370
|
+
if (typeof ref !== "string" || !ref.startsWith(COMPONENT_REF_PREFIX.pathItems)) return item;
|
|
371
|
+
const pathItems = isRecord(document.components) ? document.components.pathItems : void 0;
|
|
372
|
+
const component = isRecord(pathItems) ? pathItems[ref.slice(ref.lastIndexOf("/") + 1)] : void 0;
|
|
373
|
+
if (!isRecord(component)) return item;
|
|
374
|
+
const { $ref: _, ...siblings } = item;
|
|
375
|
+
return {
|
|
376
|
+
...component,
|
|
377
|
+
...siblings
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
/** The names of the `in: path` parameters of a `parameters` list, `$ref`s into `components.parameters` resolved. */
|
|
381
|
+
function declaredPathNames(parameters, document) {
|
|
382
|
+
if (!Array.isArray(parameters)) return [];
|
|
383
|
+
const components = isRecord(document.components) ? document.components.parameters : void 0;
|
|
384
|
+
return parameters.flatMap((parameter) => {
|
|
385
|
+
if (!isRecord(parameter)) return [];
|
|
386
|
+
const ref = parameter.$ref;
|
|
387
|
+
const resolved = "name" in parameter && "in" in parameter ? parameter : typeof ref === "string" && ref.startsWith(COMPONENT_REF_PREFIX.parameters) && isRecord(components) ? components[ref.slice(ref.lastIndexOf("/") + 1)] : void 0;
|
|
388
|
+
return isRecord(resolved) && resolved.in === "path" && typeof resolved.name === "string" ? [resolved.name] : [];
|
|
389
|
+
});
|
|
283
390
|
}
|
|
284
391
|
/**
|
|
285
392
|
* The document without the Specification Extensions (`x-` keys) of the Paths Object, of the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as isPathItemEntry, C as isOperation, F as isRefOnly, G as isUntypedObject, J as COMPONENT_NAMES, K as isValidIdent, L as isResponses, M as isPresent, N as isRecord, O as isParameterRef, P as isRefObject, R as isSchemaArray, T as isParameter, U as isSingleSchema, X as COMPONENT_SUFFIXES$1, Y as COMPONENT_REF_PREFIX, Z as FORM_MEDIA_TYPES, a as hasNoUserChain, c as hasTypelessConstraint, d as isCallbacks, et as HTTP_METHODS, f as isDiscriminableBranch, g as isInheritedName, j as isPathItemRef, k as isPathItem, l as isAnnotationOnly, m as isHeader, n as fileMimeTypes, p as isExamplesInput, q as ARROW_FUNCTION_PATTERN, r as hasMimeAlternatives, t as ANNOTATION_KEYWORDS, u as isBinaryFile, x as isOffsetTime, y as isMedia, z as isSchemaObject } from "./guard-ngBos42D.js";
|
|
2
|
-
import {
|
|
2
|
+
import { _ 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, x as zodToOpenAPISchema, y as toIdentifierPascalCase } from "./utils-BeXPKXuG.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { parseSync, rawTransferSupported, visitorKeys } from "oxc-parser";
|
|
5
5
|
// src/helper/wire.ts
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
2
|
import { $ as HOOK_LIBRARIES, J as COMPONENT_NAMES } from "./guard-ngBos42D.js";
|
|
3
|
-
import { C as
|
|
4
|
-
import { t as docs } from "./docs-
|
|
5
|
-
import { t as hooks } from "./hooks-
|
|
3
|
+
import { C as appEntryOutput, D as makeGeneratedImport, E as makeAppEntryImport, S as pathGroupOf, T as makeAppEntryFile, _ 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 isInsideDirectory, x as handlerGroupOf, y as callbacks } from "./core-CajXzO16.js";
|
|
4
|
+
import { t as docs } from "./docs-hKJj12Gm.js";
|
|
5
|
+
import { t as hooks } from "./hooks-CSMf3pkH.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-BMJPrf4w.js";
|
|
11
11
|
import { Effect, FileSystem, Schema } from "effect";
|
|
12
12
|
import path from "node:path";
|
|
13
13
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
@@ -280,7 +280,7 @@ function makeJob(openAPI, config, packageRoot = () => void 0) {
|
|
|
280
280
|
const appOutput = appEntryOutput(config);
|
|
281
281
|
const isSplit = config.template?.split === true;
|
|
282
282
|
const isInline = config.template?.define === false && !config.template.routeHandler;
|
|
283
|
-
const grouping = isSplit ? isInline ? handlerGroupOf : (endpoint) =>
|
|
283
|
+
const grouping = isSplit ? isInline ? (endpoint) => handlerGroupOf(endpoint) : (endpoint) => pathGroupOf(endpoint) : void 0;
|
|
284
284
|
const generatedClient = config.client;
|
|
285
285
|
const clientBarrel = (() => {
|
|
286
286
|
const output = generatedClient?.output;
|
|
@@ -347,13 +347,6 @@ function uncapitalize(text) {
|
|
|
347
347
|
return text.charAt(0).toLowerCase() + text.slice(1);
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
|
-
* Lower-cases the leading word of a PascalCase identifier, keeping an acronym whole:
|
|
351
|
-
* `Users` → `users`, `APIKeys` → `apiKeys`, `ZodOpenAPIHono` → `zodOpenAPIHono`.
|
|
352
|
-
*/
|
|
353
|
-
function uncapitalizeWord(text) {
|
|
354
|
-
return text.replace(/^[A-Z]+(?=[A-Z][a-z]|[^A-Za-z]|$)|^[A-Z]/u, (m) => m.toLowerCase());
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
350
|
* Converts the first character of a string to uppercase.
|
|
358
351
|
*
|
|
359
352
|
* @example
|
|
@@ -518,4 +511,4 @@ function cyclicNodes(deps) {
|
|
|
518
511
|
for (const node of deps.keys()) if (!indices.has(node)) connect(node);
|
|
519
512
|
return result;
|
|
520
513
|
}
|
|
521
|
-
export {
|
|
514
|
+
export { routeName as _, ensureSuffix as a, uncapitalize as b, escapeRegexLiteral as c, makeSafeKey as d, makeStringLiteral as f, requestParamsArray as g, renderNamedImport as h, decodePercent as i, makeBarrel as l, regexLiteral as m, capitalize as n, error as o, normalizeTypes as p, cyclicNodes as r, escapeHtml as s, baseError as t, makeInferRequestType as u, statusCodeToNumber as v, zodToOpenAPISchema as x, toIdentifierPascalCase as y };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { parseConfig } from "../index.js";
|
|
2
2
|
import { N as isRecord, nt as INPUT_EXTENSIONS } from "../guard-ngBos42D.js";
|
|
3
3
|
import { t as FormatOptions } from "../format-BF7SbaMP.js";
|
|
4
|
-
import { C as
|
|
4
|
+
import { C as appEntryOutput, w as isInsideDirectory } from "../core-CajXzO16.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-BrQVwt_b.js";
|
|
7
7
|
import { Effect, FileSystem, Option, Result } from "effect";
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import crypto from "node:crypto";
|