hono-takibi 0.18.0 → 0.20.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 +6 -14
- package/dist/constants-Bz8YiPum.js +81 -0
- package/dist/core/docs/index.js +1 -1
- package/dist/core/hooks/index.d.ts +1 -1
- package/dist/core/hooks/index.js +1 -1
- package/dist/core/rpc/index.d.ts +1 -1
- package/dist/core/rpc/index.js +3 -3
- package/dist/core/type/index.js +2 -1
- package/dist/{core-BuSZBtYC.js → core-D-vKEwJs.js} +157 -115
- package/dist/{docs-DJps1WGq.js → docs-NIDBdFyt.js} +12 -12
- package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
- package/dist/{hooks-CQMtSLZv.js → hooks-GhEZu5l6.js} +3 -3
- package/dist/index-CMoB1dLg.d.ts +12 -0
- package/dist/index.js +3 -7
- package/dist/{openapi-DsC_M1Um.js → openapi-C2BSoZRM.js} +45 -100
- package/dist/{rpc-Bl9hcXCo.js → rpc-D_ka_cCX.js} +62 -23
- package/dist/{shared-CMgxc-KQ.js → shared-_h_FDhSi.js} +4 -4
- package/dist/{utils-7HBCrio0.js → utils-vw99OasL.js} +94 -14
- package/dist/vite-plugin/index.js +5 -4
- package/package.json +1 -1
- package/dist/constants-DlWc79pw.js +0 -42
- package/dist/index-Dn5Bw8ov.d.ts +0 -11
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.
|
|
7
|
+
var version = "0.20.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-
|
|
44
|
+
import("./shared-_h_FDhSi.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-
|
|
82
|
+
const { outsideSources } = yield* Effect.promise(() => import("./shared-_h_FDhSi.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-
|
|
209
|
+
const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-D-vKEwJs.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 };
|
package/dist/core/docs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as docs } from "../../docs-
|
|
1
|
+
import { t as docs } from "../../docs-NIDBdFyt.js";
|
|
2
2
|
export { docs };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as OpenAPI } from "../../index-tsPqeV6H.js";
|
|
2
2
|
import { n as GenerateError, t as FormatError } from "../../index-D_gf3Xzx.js";
|
|
3
|
-
import { t as Grouping } from "../../index-
|
|
3
|
+
import { t as Grouping } from "../../index-CMoB1dLg.js";
|
|
4
4
|
//#region src/core/hooks/index.d.ts
|
|
5
5
|
declare const HOOK_CONFIGS: {
|
|
6
6
|
readonly swr: {
|
package/dist/core/hooks/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as hooks } from "../../hooks-
|
|
1
|
+
import { t as hooks } from "../../hooks-GhEZu5l6.js";
|
|
2
2
|
export { hooks };
|
package/dist/core/rpc/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as OpenAPI } from "../../index-tsPqeV6H.js";
|
|
2
2
|
import { n as GenerateError, t as FormatError } from "../../index-D_gf3Xzx.js";
|
|
3
|
-
import { t as Grouping } from "../../index-
|
|
3
|
+
import { t as Grouping } from "../../index-CMoB1dLg.js";
|
|
4
4
|
import { Effect } from "effect";
|
|
5
5
|
//#region src/core/rpc/index.d.ts
|
|
6
6
|
/**
|
package/dist/core/rpc/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as HTTP_METHODS } from "../../constants-Bz8YiPum.js";
|
|
2
2
|
import { i as GenerateError } from "../../format-CuHABcKC.js";
|
|
3
|
-
import {
|
|
3
|
+
import { L as isOpenAPIPaths, f as methodPath, l as makeInferRequestType, q as isRecord, z as isOperationLike } from "../../utils-vw99OasL.js";
|
|
4
4
|
import { t as emit } from "../../emit-uwlZZeRM.js";
|
|
5
|
-
import {
|
|
5
|
+
import { i as parsePathItem, l as operationTags, n as makeOperationDeps, r as operationHasArgs, s as groupClientName, t as formatPath } from "../../rpc-D_ka_cCX.js";
|
|
6
6
|
import { Effect } from "effect";
|
|
7
7
|
import { dirname } from "node:path";
|
|
8
8
|
//#region src/core/rpc/index.ts
|
package/dist/core/type/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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-vw99OasL.js";
|
|
2
3
|
import { t as emit } from "../../emit-uwlZZeRM.js";
|
|
3
4
|
import { Effect } from "effect";
|
|
4
5
|
import path from "node:path";
|