hono-takibi 0.9.994 → 0.9.996
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/README.md +5 -5
- package/dist/config/index.d.ts +10 -11
- package/dist/config/index.js +10 -5
- package/dist/core/docs/index.js +1 -1
- package/dist/core/rpc/index.js +4 -4
- package/dist/core/svelte-query/index.js +1 -1
- package/dist/core/swr/index.js +1 -1
- package/dist/core/tanstack-query/index.js +1 -1
- package/dist/core/type/index.js +3 -3
- package/dist/core/vue-query/index.js +1 -1
- package/dist/{core-BlUaJE2n.js → core-CaXcQRYE.js} +0 -1
- package/dist/{docs-Da_MOdAe.js → docs-BnLvHynR.js} +1 -1
- package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
- package/dist/{hono-rpc-BOLdCVD_.js → hono-rpc-CvPU8S0M.js} +11 -12
- package/dist/index.js +5 -5
- package/dist/{openapi-BZ9b1y3X.js → openapi-Bq_Z1BrA.js} +240 -249
- package/dist/{openapi-BBy6frF3.js → openapi-CSP6nmmf.js} +61 -30
- package/dist/{query-CArUJxE4.js → query-BVXAozkk.js} +4 -4
- package/dist/vite-plugin/index.js +34 -72
- package/package.json +4 -4
- /package/dist/{guard-BabA4f3q.js → guard-BzaK5_qz.js} +0 -0
- /package/dist/{utils-B9bUHU9P.js → utils-BqOCY-3W.js} +0 -0
package/README.md
CHANGED
|
@@ -196,7 +196,7 @@ export default defineConfig({
|
|
|
196
196
|
template: {
|
|
197
197
|
test: true,
|
|
198
198
|
pathAlias: '@/',
|
|
199
|
-
|
|
199
|
+
testFramework: 'bun', // "vitest" (default) | "vite-plus" | "bun"
|
|
200
200
|
},
|
|
201
201
|
},
|
|
202
202
|
})
|
|
@@ -206,7 +206,7 @@ This generates:
|
|
|
206
206
|
|
|
207
207
|
- `src/index.ts` - App entry point with route registrations
|
|
208
208
|
- `src/handlers/*.ts` - Handler stubs for each resource
|
|
209
|
-
- `src/handlers/*.test.ts` - Test files with `@faker-js/faker` mock data (imports from `vitest` or `bun:test`)
|
|
209
|
+
- `src/handlers/*.test.ts` - Test files with `@faker-js/faker` mock data (imports from `vitest`, `vite-plus/test`, or `bun:test`)
|
|
210
210
|
|
|
211
211
|
Re-running after updating your OpenAPI spec is safe — your hand-written handler logic and test customizations are preserved. Only new routes are added as stubs.
|
|
212
212
|
|
|
@@ -300,7 +300,7 @@ export default defineConfig({
|
|
|
300
300
|
test: {
|
|
301
301
|
output: './src/test.ts',
|
|
302
302
|
import: '../index',
|
|
303
|
-
|
|
303
|
+
testFramework: 'bun', // "vitest" (default) | "vite-plus" | "bun"
|
|
304
304
|
},
|
|
305
305
|
})
|
|
306
306
|
```
|
|
@@ -387,7 +387,7 @@ export default defineConfig({
|
|
|
387
387
|
test: true, // Generate test files
|
|
388
388
|
routeHandler: false, // false: inline .openapi() (default), true: RouteHandler exports
|
|
389
389
|
pathAlias: '@/', // TypeScript path alias for imports
|
|
390
|
-
|
|
390
|
+
testFramework: 'vitest', // "vitest" (default) | "vite-plus" | "bun" — test import source
|
|
391
391
|
},
|
|
392
392
|
|
|
393
393
|
// Export options (OpenAPI Components Object)
|
|
@@ -528,7 +528,7 @@ export default defineConfig({
|
|
|
528
528
|
test: {
|
|
529
529
|
output: './src/test.ts',
|
|
530
530
|
import: '../index', // Import path for the app instance
|
|
531
|
-
|
|
531
|
+
testFramework: 'vitest', // "vitest" (default) | "vite-plus" | "bun" — test import source
|
|
532
532
|
},
|
|
533
533
|
|
|
534
534
|
// Mock server generation
|
package/dist/config/index.d.ts
CHANGED
|
@@ -13,8 +13,9 @@ declare const ConfigSchema: z.ZodReadonly<z.ZodPipe<z.ZodObject<{
|
|
|
13
13
|
test: z.ZodDefault<z.ZodBoolean>;
|
|
14
14
|
routeHandler: z.ZodDefault<z.ZodBoolean>;
|
|
15
15
|
pathAlias: z.ZodExactOptional<z.ZodString>;
|
|
16
|
-
|
|
16
|
+
testFramework: z.ZodExactOptional<z.ZodDefault<z.ZodEnum<{
|
|
17
17
|
vitest: "vitest";
|
|
18
|
+
"vite-plus": "vite-plus";
|
|
18
19
|
bun: "bun";
|
|
19
20
|
}>>>;
|
|
20
21
|
}, z.core.$strip>>;
|
|
@@ -143,8 +144,9 @@ declare const ConfigSchema: z.ZodReadonly<z.ZodPipe<z.ZodObject<{
|
|
|
143
144
|
test: z.ZodExactOptional<z.ZodObject<{
|
|
144
145
|
output: z.ZodString;
|
|
145
146
|
import: z.ZodString;
|
|
146
|
-
|
|
147
|
+
testFramework: z.ZodExactOptional<z.ZodDefault<z.ZodEnum<{
|
|
147
148
|
vitest: "vitest";
|
|
149
|
+
"vite-plus": "vite-plus";
|
|
148
150
|
bun: "bun";
|
|
149
151
|
}>>>;
|
|
150
152
|
}, z.core.$strip>>;
|
|
@@ -165,7 +167,7 @@ declare const ConfigSchema: z.ZodReadonly<z.ZodPipe<z.ZodObject<{
|
|
|
165
167
|
test: boolean;
|
|
166
168
|
routeHandler: boolean;
|
|
167
169
|
pathAlias?: string;
|
|
168
|
-
|
|
170
|
+
testFramework?: "vitest" | "vite-plus" | "bun";
|
|
169
171
|
};
|
|
170
172
|
exportSchemas?: boolean;
|
|
171
173
|
exportSchemasTypes?: boolean;
|
|
@@ -295,7 +297,7 @@ declare const ConfigSchema: z.ZodReadonly<z.ZodPipe<z.ZodObject<{
|
|
|
295
297
|
test?: {
|
|
296
298
|
output: string;
|
|
297
299
|
import: string;
|
|
298
|
-
|
|
300
|
+
testFramework?: "vitest" | "vite-plus" | "bun";
|
|
299
301
|
};
|
|
300
302
|
mock?: {
|
|
301
303
|
output: string;
|
|
@@ -317,7 +319,7 @@ declare const ConfigSchema: z.ZodReadonly<z.ZodPipe<z.ZodObject<{
|
|
|
317
319
|
test: boolean;
|
|
318
320
|
routeHandler: boolean;
|
|
319
321
|
pathAlias?: string;
|
|
320
|
-
|
|
322
|
+
testFramework?: "vitest" | "vite-plus" | "bun";
|
|
321
323
|
};
|
|
322
324
|
exportSchemas?: boolean;
|
|
323
325
|
exportSchemasTypes?: boolean;
|
|
@@ -444,7 +446,7 @@ declare const ConfigSchema: z.ZodReadonly<z.ZodPipe<z.ZodObject<{
|
|
|
444
446
|
test?: {
|
|
445
447
|
output: string;
|
|
446
448
|
import: string;
|
|
447
|
-
|
|
449
|
+
testFramework?: "vitest" | "vite-plus" | "bun";
|
|
448
450
|
};
|
|
449
451
|
mock?: {
|
|
450
452
|
output: string;
|
|
@@ -478,9 +480,6 @@ declare function readConfig(): Promise<{
|
|
|
478
480
|
readonly ok: false;
|
|
479
481
|
readonly error: string;
|
|
480
482
|
}>;
|
|
481
|
-
/**
|
|
482
|
-
* Helper to define a config with full type completion.
|
|
483
|
-
*/
|
|
484
483
|
declare function defineConfig(config: ConfigInput): Readonly<{
|
|
485
484
|
input: `${string}.yaml` | `${string}.json` | `${string}.tsp`;
|
|
486
485
|
basePath?: string;
|
|
@@ -492,7 +491,7 @@ declare function defineConfig(config: ConfigInput): Readonly<{
|
|
|
492
491
|
test?: boolean | undefined;
|
|
493
492
|
routeHandler?: boolean | undefined;
|
|
494
493
|
pathAlias?: string;
|
|
495
|
-
|
|
494
|
+
testFramework?: "vitest" | "vite-plus" | "bun" | undefined;
|
|
496
495
|
};
|
|
497
496
|
exportSchemas?: boolean;
|
|
498
497
|
exportSchemasTypes?: boolean;
|
|
@@ -619,7 +618,7 @@ declare function defineConfig(config: ConfigInput): Readonly<{
|
|
|
619
618
|
test?: {
|
|
620
619
|
output: string;
|
|
621
620
|
import: string;
|
|
622
|
-
|
|
621
|
+
testFramework?: "vitest" | "vite-plus" | "bun" | undefined;
|
|
623
622
|
};
|
|
624
623
|
mock?: {
|
|
625
624
|
output: string;
|
package/dist/config/index.js
CHANGED
|
@@ -16,7 +16,11 @@ const ConfigSchema = z.object({
|
|
|
16
16
|
test: z.boolean().default(false),
|
|
17
17
|
routeHandler: z.boolean().default(false),
|
|
18
18
|
pathAlias: z.string().exactOptional(),
|
|
19
|
-
|
|
19
|
+
testFramework: z.enum([
|
|
20
|
+
"vitest",
|
|
21
|
+
"vite-plus",
|
|
22
|
+
"bun"
|
|
23
|
+
]).default("vitest").exactOptional()
|
|
20
24
|
}).exactOptional(),
|
|
21
25
|
exportSchemas: z.boolean().exactOptional(),
|
|
22
26
|
exportSchemasTypes: z.boolean().exactOptional(),
|
|
@@ -143,7 +147,11 @@ const ConfigSchema = z.object({
|
|
|
143
147
|
test: z.object({
|
|
144
148
|
output: z.string(),
|
|
145
149
|
import: z.string(),
|
|
146
|
-
|
|
150
|
+
testFramework: z.enum([
|
|
151
|
+
"vitest",
|
|
152
|
+
"vite-plus",
|
|
153
|
+
"bun"
|
|
154
|
+
]).default("vitest").exactOptional()
|
|
147
155
|
}).exactOptional(),
|
|
148
156
|
mock: z.object({ output: z.string() }).exactOptional(),
|
|
149
157
|
docs: z.object({
|
|
@@ -242,9 +250,6 @@ async function readConfig() {
|
|
|
242
250
|
};
|
|
243
251
|
}
|
|
244
252
|
}
|
|
245
|
-
/**
|
|
246
|
-
* Helper to define a config with full type completion.
|
|
247
|
-
*/
|
|
248
253
|
function defineConfig(config) {
|
|
249
254
|
return config;
|
|
250
255
|
}
|
package/dist/core/docs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as makeDocs, t as docs } from "../../docs-
|
|
1
|
+
import { n as makeDocs, t as docs } from "../../docs-BnLvHynR.js";
|
|
2
2
|
export { docs, makeDocs };
|
package/dist/core/rpc/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as core } from "../../core-
|
|
4
|
-
import { a as parsePathItem, i as operationHasArgs, o as resolveSplitOutDir, r as makeOperationDeps, t as formatPath } from "../../hono-rpc-
|
|
1
|
+
import { a as makeInferRequestType, s as methodPath } from "../../utils-BqOCY-3W.js";
|
|
2
|
+
import { c as isOperationLike, f as isRecord, o as isOpenAPIPaths } from "../../guard-BzaK5_qz.js";
|
|
3
|
+
import { t as core } from "../../core-CaXcQRYE.js";
|
|
4
|
+
import { a as parsePathItem, i as operationHasArgs, o as resolveSplitOutDir, r as makeOperationDeps, t as formatPath } from "../../hono-rpc-CvPU8S0M.js";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
//#region src/core/rpc/index.ts
|
|
7
7
|
const makeOperationCode = (pathStr, method, item, deps, useParseResponse, hasBasePath) => {
|
package/dist/core/swr/index.js
CHANGED
package/dist/core/type/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { t as core } from "../../core-
|
|
1
|
+
import { o as makeSafeKey } from "../../utils-BqOCY-3W.js";
|
|
2
|
+
import { b as isStringRef, g as isSchemaArray, i as isMediaWithSchema, l as isParameter, m as isRequestBody, n as isHttpMethod, s as isOperation, u as isParameterArray } from "../../guard-BzaK5_qz.js";
|
|
3
|
+
import { t as core } from "../../core-CaXcQRYE.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
//#region src/core/type/index.ts
|
|
6
6
|
/**
|
|
@@ -61,7 +61,6 @@ async function fmt(input) {
|
|
|
61
61
|
}
|
|
62
62
|
//#endregion
|
|
63
63
|
//#region src/helper/core.ts
|
|
64
|
-
/** Formats code, creates directory, and writes the file. */
|
|
65
64
|
async function core(code, dir, output) {
|
|
66
65
|
const [fmtResult, mkdirResult] = await Promise.all([fmt(code), mkdir(dir)]);
|
|
67
66
|
if (!fmtResult.ok) return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isOAuthFlowValue, f as isRecord, h as isResponses, m as isRequestBody, p as isRefObject, r as isMedia, v as isSecurityArray, y as isSecurityScheme } from "./guard-
|
|
1
|
+
import { a as isOAuthFlowValue, f as isRecord, h as isResponses, m as isRequestBody, p as isRefObject, r as isMedia, v as isSecurityArray, y as isSecurityScheme } from "./guard-BzaK5_qz.js";
|
|
2
2
|
import { a as writeFile, t as mkdir } from "./fsp-Bv1yR6UV.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { STATUS_CODES } from "node:http";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as zodOpenAPIHono } from "../../../openapi-
|
|
1
|
+
import { t as zodOpenAPIHono } from "../../../openapi-Bq_Z1BrA.js";
|
|
2
2
|
export { zodOpenAPIHono };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as isSchemaProperty, c as isOperationLike, d as isParameterObject, f as isRecord, p as isRefObject, x as isValidIdent } from "./guard-
|
|
1
|
+
import { _ as isSchemaProperty, c as isOperationLike, d as isParameterObject, f as isRecord, p as isRefObject, x as isValidIdent } from "./guard-BzaK5_qz.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
//#region src/helper/hono-rpc.ts
|
|
4
4
|
/**
|
|
@@ -30,9 +30,8 @@ function formatPath(p, hasBasePath) {
|
|
|
30
30
|
hasBracket: false
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
const hasTrailingSlash = p !== "/" && p.endsWith("/");
|
|
34
33
|
const segs = p.replace(/^\/+/, "").split("/").filter(Boolean);
|
|
35
|
-
if (
|
|
34
|
+
if (p !== "/" && p.endsWith("/")) segs.push("index");
|
|
36
35
|
const honoSegs = segs.map((seg) => seg.replace(/\{([^}]+)\}/g, ":$1"));
|
|
37
36
|
const firstBracketIdx = honoSegs.findIndex((seg) => !isValidIdent(seg));
|
|
38
37
|
const hasBracket = firstBracketIdx !== -1;
|
|
@@ -68,7 +67,6 @@ function makeResolveParameter(componentsParameters) {
|
|
|
68
67
|
function makeToParameterLikes(resolveParam) {
|
|
69
68
|
return (arr) => Array.isArray(arr) ? arr.map((x) => resolveParam(x)).filter((param) => param !== void 0) : [];
|
|
70
69
|
}
|
|
71
|
-
const NO_CONTENT_STATUS_CODES = [204, 205];
|
|
72
70
|
/**
|
|
73
71
|
* Check if operation has No Content response (204 or 205).
|
|
74
72
|
*/
|
|
@@ -77,10 +75,13 @@ function hasNoContentResponse(op) {
|
|
|
77
75
|
if (!isRecord(responses)) return false;
|
|
78
76
|
return Object.keys(responses).some((status) => {
|
|
79
77
|
const code = Number.parseInt(status, 10);
|
|
80
|
-
return !Number.isNaN(code) &&
|
|
78
|
+
return !Number.isNaN(code) && [204, 205].includes(code);
|
|
81
79
|
});
|
|
82
80
|
}
|
|
83
81
|
/**
|
|
82
|
+
* All body info grouped by type.
|
|
83
|
+
*/
|
|
84
|
+
/**
|
|
84
85
|
* Extract requestBody name from $ref.
|
|
85
86
|
*/
|
|
86
87
|
function refRequestBodyName(refLike) {
|
|
@@ -108,9 +109,9 @@ function pickAllBodyInfoFromContent(content) {
|
|
|
108
109
|
*/
|
|
109
110
|
function makePickAllBodyInfo(componentsRequestBodies) {
|
|
110
111
|
return (op) => {
|
|
111
|
-
const
|
|
112
|
-
if (!isRecord(
|
|
113
|
-
const refName = refRequestBodyName(
|
|
112
|
+
const requestBody = op.requestBody;
|
|
113
|
+
if (!isRecord(requestBody)) return void 0;
|
|
114
|
+
const refName = refRequestBodyName(requestBody);
|
|
114
115
|
if (refName) {
|
|
115
116
|
const resolved = componentsRequestBodies[refName];
|
|
116
117
|
if (isRecord(resolved) && isRecord(resolved.content)) return pickAllBodyInfoFromContent(resolved.content);
|
|
@@ -120,7 +121,7 @@ function makePickAllBodyInfo(componentsRequestBodies) {
|
|
|
120
121
|
};
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
|
-
return pickAllBodyInfoFromContent(
|
|
124
|
+
return pickAllBodyInfoFromContent(requestBody.content);
|
|
124
125
|
};
|
|
125
126
|
}
|
|
126
127
|
/**
|
|
@@ -163,9 +164,7 @@ function makeOperationDeps(clientName, componentsParameters, componentsRequestBo
|
|
|
163
164
|
* Check if operation has arguments (parameters or body).
|
|
164
165
|
*/
|
|
165
166
|
function operationHasArgs(item, op, deps) {
|
|
166
|
-
const
|
|
167
|
-
const opParams = deps.toParameterLikes(op.parameters);
|
|
168
|
-
const allParams = [...pathLevelParams, ...opParams];
|
|
167
|
+
const allParams = [...deps.toParameterLikes(item.parameters), ...deps.toParameterLikes(op.parameters)];
|
|
169
168
|
const hasParams = allParams.filter((p) => p.in === "path").length > 0 || allParams.filter((p) => p.in === "query").length > 0 || allParams.filter((p) => p.in === "header").length > 0 || allParams.filter((p) => p.in === "cookie").length > 0;
|
|
170
169
|
const allBodyInfo = deps.pickAllBodyInfo(op);
|
|
171
170
|
const hasBody = allBodyInfo !== void 0 && (allBodyInfo.form.length > 0 || allBodyInfo.json.length > 0);
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { readConfig } from "./config/index.js";
|
|
3
|
-
import { r as setFormatOptions } from "./core-
|
|
4
|
-
import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "./openapi-
|
|
5
|
-
import { t as docs } from "./docs-
|
|
3
|
+
import { r as setFormatOptions } from "./core-CaXcQRYE.js";
|
|
4
|
+
import { _ as examples, a as takibi, c as securitySchemes, d as requestBodies, f as pathItems, g as headers, h as links, i as template, l as schemas, m as mediaTypes, n as webhooks, o as route, p as parameters, r as test, s as mock, t as parseOpenAPI, u as responses, v as callbacks } from "./openapi-CSP6nmmf.js";
|
|
5
|
+
import { t as docs } from "./docs-BnLvHynR.js";
|
|
6
6
|
import { rpc } from "./core/rpc/index.js";
|
|
7
7
|
import { svelteQuery } from "./core/svelte-query/index.js";
|
|
8
8
|
import { swr } from "./core/swr/index.js";
|
|
@@ -133,13 +133,13 @@ async function honoTakibi() {
|
|
|
133
133
|
config["tanstack-query"] ? tanstackQuery(openAPI, config["tanstack-query"].output, config["tanstack-query"].import, config["tanstack-query"].split ?? false, config["tanstack-query"].client ?? "client") : Promise.resolve(void 0),
|
|
134
134
|
config["svelte-query"] ? svelteQuery(openAPI, config["svelte-query"].output, config["svelte-query"].import, config["svelte-query"].split ?? false, config["svelte-query"].client ?? "client") : Promise.resolve(void 0),
|
|
135
135
|
config["vue-query"] ? vueQuery(openAPI, config["vue-query"].output, config["vue-query"].import, config["vue-query"].split ?? false, config["vue-query"].client ?? "client") : Promise.resolve(void 0),
|
|
136
|
-
config.test ? test(openAPI, config.test.output, config.test.import, config.basePath ?? "/", config.test.
|
|
136
|
+
config.test ? test(openAPI, config.test.output, config.test.import, config.basePath ?? "/", config.test.testFramework) : Promise.resolve(void 0),
|
|
137
137
|
config.mock ? mock(openAPI, config.mock.output, config.basePath ?? "/", config["zod-openapi"]?.readonly) : Promise.resolve(void 0),
|
|
138
138
|
config.docs ? docs(openAPI, config.docs.output, config.docs.entry, config.basePath ?? "/", config.docs.curl, config.docs.baseUrl) : Promise.resolve(void 0),
|
|
139
139
|
(() => {
|
|
140
140
|
if (!config["zod-openapi"]?.template) return Promise.resolve(void 0);
|
|
141
141
|
if (!(config["zod-openapi"]?.output ?? config["zod-openapi"]?.routes?.output)) return Promise.resolve(void 0);
|
|
142
|
-
return template(openAPI, config["zod-openapi"]?.output ?? config["zod-openapi"]?.routes?.output ?? "src/routes/index.ts", config["zod-openapi"]?.template.test, config.basePath ?? "/", config["zod-openapi"]?.template.pathAlias, config["zod-openapi"]?.routes?.import, config["zod-openapi"]?.template.routeHandler, config["zod-openapi"]?.template.
|
|
142
|
+
return template(openAPI, config["zod-openapi"]?.output ?? config["zod-openapi"]?.routes?.output ?? "src/routes/index.ts", config["zod-openapi"]?.template.test, config.basePath ?? "/", config["zod-openapi"]?.template.pathAlias, config["zod-openapi"]?.routes?.import, config["zod-openapi"]?.template.routeHandler, config["zod-openapi"]?.template.testFramework);
|
|
143
143
|
})()
|
|
144
144
|
]);
|
|
145
145
|
const values = [];
|