hono-takibi 0.9.9996 → 0.9.9998
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 +155 -144
- package/dist/config/index.d.ts +573 -541
- package/dist/config/index.js +126 -251
- package/dist/core/docs/index.d.ts +1 -1
- package/dist/core/docs/index.js +1 -1
- package/dist/core/hooks/index.d.ts +122 -0
- package/dist/core/hooks/index.js +2 -0
- package/dist/core/rpc/index.d.ts +1 -1
- package/dist/core/rpc/index.js +2 -3
- package/dist/core/type/index.d.ts +1 -1
- package/dist/core/type/index.js +2 -6
- package/dist/{docs-BAt1_N22.js → docs-380Wcu6a.js} +19 -18
- package/dist/generator/zod-openapi-hono/openapi/index.d.ts +1 -1
- package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
- package/dist/{utils-Dhc0-ra6.js → guard-zvkMUVYD.js} +135 -12
- package/dist/{query-nt-tOucg.js → hooks-Dk7Z5hMb.js} +139 -15
- package/dist/{index-D8guYWoV.d.ts → index-BFnCNZSw.d.ts} +6 -6
- package/dist/index.js +6 -64
- package/dist/{openapi-DNST00z0.js → openapi-Lc8kequ9.js} +219 -207
- package/dist/{rpc-BzPo2tZf.js → rpc-CepeggWU.js} +1 -1
- package/dist/{openapi-DwwK7GTc.js → shared-siQoLLJc.js} +606 -37
- package/dist/vite-plugin/index.js +29 -215
- package/package.json +13 -39
- package/dist/core/angular-query/index.d.ts +0 -13
- package/dist/core/angular-query/index.js +0 -21
- package/dist/core/preact-query/index.d.ts +0 -13
- package/dist/core/preact-query/index.js +0 -24
- package/dist/core/solid-query/index.d.ts +0 -13
- package/dist/core/solid-query/index.js +0 -20
- package/dist/core/svelte-query/index.d.ts +0 -13
- package/dist/core/svelte-query/index.js +0 -20
- package/dist/core/swr/index.d.ts +0 -13
- package/dist/core/swr/index.js +0 -19
- package/dist/core/tanstack-query/index.d.ts +0 -13
- package/dist/core/tanstack-query/index.js +0 -24
- package/dist/core/vue-query/index.d.ts +0 -13
- package/dist/core/vue-query/index.js +0 -18
- package/dist/guard-BSZ8ezEv.js +0 -83
package/README.md
CHANGED
|
@@ -36,9 +36,7 @@ import { defineConfig } from 'hono-takibi/config'
|
|
|
36
36
|
|
|
37
37
|
export default defineConfig({
|
|
38
38
|
input: 'openapi.yaml',
|
|
39
|
-
'
|
|
40
|
-
output: './src/routes.ts',
|
|
41
|
-
},
|
|
39
|
+
output: './src/routes.ts',
|
|
42
40
|
})
|
|
43
41
|
```
|
|
44
42
|
|
|
@@ -127,13 +125,11 @@ Generate a complete app structure with handler stubs and test files:
|
|
|
127
125
|
```ts
|
|
128
126
|
export default defineConfig({
|
|
129
127
|
input: 'openapi.yaml',
|
|
130
|
-
'
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
testFramework: 'bun', // "vitest" (default) | "vite-plus" | "bun"
|
|
136
|
-
},
|
|
128
|
+
output: './src/routes.ts',
|
|
129
|
+
template: {
|
|
130
|
+
test: true,
|
|
131
|
+
pathAlias: '@/',
|
|
132
|
+
testFramework: 'bun', // "vitest" (default) | "vite-plus" | "bun"
|
|
137
133
|
},
|
|
138
134
|
})
|
|
139
135
|
```
|
|
@@ -201,6 +197,34 @@ export const api = app.openapi(getHealthRoute, getHealthRouteHandler)
|
|
|
201
197
|
export default app
|
|
202
198
|
```
|
|
203
199
|
|
|
200
|
+
#### `define: true`
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
export default defineConfig({
|
|
204
|
+
input: 'openapi.yaml',
|
|
205
|
+
output: './src/index.ts',
|
|
206
|
+
template: { define: true },
|
|
207
|
+
})
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
// src/routes/users.ts
|
|
212
|
+
export const getUsersIdRoute = defineOpenAPIRoute({
|
|
213
|
+
route: createRoute({
|
|
214
|
+
method: 'get',
|
|
215
|
+
path: '/users/{id}',
|
|
216
|
+
request: { params: z.object({ id: z.string() }) },
|
|
217
|
+
responses: {
|
|
218
|
+
200: { description: 'ok', content: { 'application/json': { schema: UserSchema } } },
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
handler: async (c) => {},
|
|
222
|
+
addRoute: true,
|
|
223
|
+
})
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Component schemas go to `components/index.ts` (override with `components.output`). Set `template.output` to change the route directory (default `./src/routes`).
|
|
227
|
+
|
|
204
228
|
## Client Library Integrations
|
|
205
229
|
|
|
206
230
|
Supported: SWR, TanStack Query, Preact Query, Solid Query, Vue Query, Svelte Query, Angular Query, RPC Client.
|
|
@@ -210,7 +234,7 @@ export default defineConfig({
|
|
|
210
234
|
input: 'openapi.yaml',
|
|
211
235
|
'tanstack-query': {
|
|
212
236
|
output: './src/tanstack-query',
|
|
213
|
-
import: '../
|
|
237
|
+
import: '../lib',
|
|
214
238
|
split: true,
|
|
215
239
|
client: 'client',
|
|
216
240
|
},
|
|
@@ -237,7 +261,7 @@ export default defineConfig({
|
|
|
237
261
|
input: 'openapi.yaml',
|
|
238
262
|
test: {
|
|
239
263
|
output: './src/test.ts',
|
|
240
|
-
import: '
|
|
264
|
+
import: '.',
|
|
241
265
|
testFramework: 'bun', // "vitest" (default) | "vite-plus" | "bun"
|
|
242
266
|
},
|
|
243
267
|
})
|
|
@@ -256,7 +280,7 @@ export default defineConfig({
|
|
|
256
280
|
|
|
257
281
|
### API Reference Docs
|
|
258
282
|
|
|
259
|
-
Generate API reference Markdown with [hono-cli](https://github.com/honojs/cli) `hono request` commands
|
|
283
|
+
Generate API reference Markdown with [hono-cli](https://github.com/honojs/cli) `hono request` commands:
|
|
260
284
|
|
|
261
285
|
```ts
|
|
262
286
|
export default defineConfig({
|
|
@@ -268,7 +292,7 @@ export default defineConfig({
|
|
|
268
292
|
})
|
|
269
293
|
```
|
|
270
294
|
|
|
271
|
-
|
|
295
|
+
Set `curl: true` with `baseUrl` to generate `curl` commands for a running server:
|
|
272
296
|
|
|
273
297
|
```ts
|
|
274
298
|
export default defineConfig({
|
|
@@ -283,207 +307,194 @@ export default defineConfig({
|
|
|
283
307
|
|
|
284
308
|
## Full Config Reference
|
|
285
309
|
|
|
310
|
+
Some options are mutually exclusive: `output` ↔ `routes`, `components.output` ↔ per-type components, `template.define` ↔ `routeHandler`.
|
|
311
|
+
|
|
286
312
|
```ts
|
|
287
|
-
// hono-takibi.config.ts
|
|
288
313
|
import { defineConfig } from 'hono-takibi/config'
|
|
289
314
|
|
|
290
315
|
export default defineConfig({
|
|
291
|
-
// OpenAPI spec file (.yaml, .json, or .tsp)
|
|
292
316
|
input: 'openapi.yaml',
|
|
293
|
-
|
|
294
|
-
// Base path prefix for all routes
|
|
295
317
|
basePath: '/api',
|
|
318
|
+
// format: {}, // oxfmt FormatConfig
|
|
319
|
+
|
|
320
|
+
output: './src/routes.ts', // single-file mode; with template.define, the app entry (required)
|
|
321
|
+
readonly: true,
|
|
322
|
+
|
|
323
|
+
template: {
|
|
324
|
+
test: true,
|
|
325
|
+
routeHandler: false, // true: RouteHandler exports
|
|
326
|
+
define: false, // true: defineOpenAPIRoute output
|
|
327
|
+
// output: './src/routes', // define mode dir (default ./src/routes)
|
|
328
|
+
pathAlias: '@/',
|
|
329
|
+
testFramework: 'vitest', // "vitest" | "vite-plus" | "bun"
|
|
330
|
+
},
|
|
296
331
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
332
|
+
exportSchemas: true,
|
|
333
|
+
exportSchemasTypes: true,
|
|
334
|
+
exportResponses: true,
|
|
335
|
+
exportParameters: true,
|
|
336
|
+
exportParametersTypes: true,
|
|
337
|
+
exportExamples: true,
|
|
338
|
+
exportRequestBodies: true,
|
|
339
|
+
exportHeaders: true,
|
|
340
|
+
exportHeadersTypes: true,
|
|
341
|
+
exportSecuritySchemes: true,
|
|
342
|
+
exportLinks: true,
|
|
343
|
+
exportCallbacks: true,
|
|
344
|
+
exportPathItems: true,
|
|
345
|
+
exportMediaTypes: true,
|
|
346
|
+
exportMediaTypesTypes: true,
|
|
347
|
+
|
|
348
|
+
routes: {
|
|
349
|
+
output: './src/routes',
|
|
350
|
+
split: true,
|
|
351
|
+
import: '@packages/routes',
|
|
352
|
+
},
|
|
314
353
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
exportMediaTypes: true,
|
|
330
|
-
exportMediaTypesTypes: true,
|
|
331
|
-
|
|
332
|
-
// Split routes into separate files
|
|
333
|
-
routes: {
|
|
334
|
-
output: './src/routes',
|
|
354
|
+
webhooks: {
|
|
355
|
+
output: './src/webhooks',
|
|
356
|
+
split: true,
|
|
357
|
+
import: '@packages/webhooks',
|
|
358
|
+
},
|
|
359
|
+
|
|
360
|
+
// `output` (single file) and the per-type fields below (split) are mutually exclusive.
|
|
361
|
+
// `exportTypes` applies only to schemas / parameters / headers / mediaTypes.
|
|
362
|
+
components: {
|
|
363
|
+
output: './src/components/index.ts',
|
|
364
|
+
|
|
365
|
+
schemas: {
|
|
366
|
+
output: './src/schemas',
|
|
367
|
+
exportTypes: true,
|
|
335
368
|
split: true,
|
|
336
|
-
import: '
|
|
369
|
+
import: '../schemas',
|
|
337
370
|
},
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
webhooks: {
|
|
341
|
-
output: './src/webhooks',
|
|
371
|
+
responses: {
|
|
372
|
+
output: './src/responses',
|
|
342
373
|
split: true,
|
|
343
|
-
import: '
|
|
374
|
+
import: '../responses',
|
|
344
375
|
},
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
output: './src/callbacks',
|
|
393
|
-
split: true,
|
|
394
|
-
import: '../callbacks',
|
|
395
|
-
},
|
|
396
|
-
pathItems: {
|
|
397
|
-
output: './src/pathItems',
|
|
398
|
-
split: true,
|
|
399
|
-
import: '../pathItems',
|
|
400
|
-
},
|
|
401
|
-
mediaTypes: {
|
|
402
|
-
output: './src/mediaTypes',
|
|
403
|
-
exportTypes: true,
|
|
404
|
-
split: true,
|
|
405
|
-
import: '../mediaTypes',
|
|
406
|
-
},
|
|
376
|
+
parameters: {
|
|
377
|
+
output: './src/parameters',
|
|
378
|
+
exportTypes: true,
|
|
379
|
+
split: true,
|
|
380
|
+
import: '../parameters',
|
|
381
|
+
},
|
|
382
|
+
examples: {
|
|
383
|
+
output: './src/examples',
|
|
384
|
+
split: true,
|
|
385
|
+
import: '../examples',
|
|
386
|
+
},
|
|
387
|
+
requestBodies: {
|
|
388
|
+
output: './src/requestBodies',
|
|
389
|
+
split: true,
|
|
390
|
+
import: '../requestBodies',
|
|
391
|
+
},
|
|
392
|
+
headers: {
|
|
393
|
+
output: './src/headers',
|
|
394
|
+
exportTypes: true,
|
|
395
|
+
split: true,
|
|
396
|
+
import: '../headers',
|
|
397
|
+
},
|
|
398
|
+
securitySchemes: {
|
|
399
|
+
output: './src/securitySchemes',
|
|
400
|
+
split: true,
|
|
401
|
+
import: '../securitySchemes',
|
|
402
|
+
},
|
|
403
|
+
links: {
|
|
404
|
+
output: './src/links',
|
|
405
|
+
split: true,
|
|
406
|
+
import: '../links',
|
|
407
|
+
},
|
|
408
|
+
callbacks: {
|
|
409
|
+
output: './src/callbacks',
|
|
410
|
+
split: true,
|
|
411
|
+
import: '../callbacks',
|
|
412
|
+
},
|
|
413
|
+
pathItems: {
|
|
414
|
+
output: './src/pathItems',
|
|
415
|
+
split: true,
|
|
416
|
+
import: '../pathItems',
|
|
417
|
+
},
|
|
418
|
+
mediaTypes: {
|
|
419
|
+
output: './src/mediaTypes',
|
|
420
|
+
exportTypes: true,
|
|
421
|
+
split: true,
|
|
422
|
+
import: '../mediaTypes',
|
|
407
423
|
},
|
|
408
424
|
},
|
|
409
425
|
|
|
410
|
-
// TypeScript type generation
|
|
411
426
|
type: {
|
|
412
427
|
output: './src/types.ts',
|
|
413
428
|
readonly: true,
|
|
414
429
|
},
|
|
415
430
|
|
|
416
|
-
// RPC client generation
|
|
417
431
|
rpc: {
|
|
418
432
|
output: './src/rpc',
|
|
419
|
-
import: '../
|
|
433
|
+
import: '../lib',
|
|
420
434
|
split: true,
|
|
421
|
-
client: 'client',
|
|
422
|
-
parseResponse: true,
|
|
435
|
+
client: 'client',
|
|
436
|
+
parseResponse: true,
|
|
437
|
+
docs: false, // operation summary/description as JSDoc
|
|
423
438
|
},
|
|
424
439
|
|
|
425
|
-
// Client library integrations (SWR, TanStack Query, Preact Query, Solid Query, Vue Query, Svelte Query, Angular Query)
|
|
426
440
|
swr: {
|
|
427
441
|
output: './src/swr',
|
|
428
|
-
import: '../
|
|
442
|
+
import: '../lib',
|
|
429
443
|
split: true,
|
|
430
444
|
client: 'client',
|
|
431
445
|
},
|
|
432
446
|
'tanstack-query': {
|
|
433
447
|
output: './src/tanstack-query',
|
|
434
|
-
import: '../
|
|
448
|
+
import: '../lib',
|
|
435
449
|
split: true,
|
|
436
450
|
client: 'client',
|
|
437
451
|
},
|
|
438
452
|
'preact-query': {
|
|
439
453
|
output: './src/preact-query',
|
|
440
|
-
import: '../
|
|
454
|
+
import: '../lib',
|
|
441
455
|
split: true,
|
|
442
456
|
client: 'client',
|
|
443
457
|
},
|
|
444
458
|
'solid-query': {
|
|
445
459
|
output: './src/solid-query',
|
|
446
|
-
import: '../
|
|
460
|
+
import: '../lib',
|
|
447
461
|
split: true,
|
|
448
462
|
client: 'client',
|
|
449
463
|
},
|
|
450
464
|
'vue-query': {
|
|
451
465
|
output: './src/vue-query',
|
|
452
|
-
import: '../
|
|
466
|
+
import: '../lib',
|
|
453
467
|
split: true,
|
|
454
468
|
client: 'client',
|
|
455
469
|
},
|
|
456
470
|
'svelte-query': {
|
|
457
471
|
output: './src/svelte-query',
|
|
458
|
-
import: '../
|
|
472
|
+
import: '../lib',
|
|
459
473
|
split: true,
|
|
460
474
|
client: 'client',
|
|
461
475
|
},
|
|
462
476
|
'angular-query': {
|
|
463
477
|
output: './src/angular-query',
|
|
464
|
-
import: '../
|
|
478
|
+
import: '../lib',
|
|
465
479
|
split: true,
|
|
466
480
|
client: 'client',
|
|
467
481
|
},
|
|
468
482
|
|
|
469
|
-
// Test generation
|
|
470
483
|
test: {
|
|
471
484
|
output: './src/test.ts',
|
|
472
|
-
import: '
|
|
473
|
-
testFramework: 'vitest', // "vitest"
|
|
485
|
+
import: '.',
|
|
486
|
+
testFramework: 'vitest', // "vitest" | "vite-plus" | "bun"
|
|
474
487
|
},
|
|
475
488
|
|
|
476
|
-
// Mock server generation
|
|
477
489
|
mock: {
|
|
478
490
|
output: './src/mock.ts',
|
|
479
491
|
},
|
|
480
492
|
|
|
481
|
-
// API reference docs generation
|
|
482
493
|
docs: {
|
|
483
494
|
output: './docs/api.md',
|
|
484
|
-
entry: 'src/index.ts',
|
|
485
|
-
curl: false, // true:
|
|
486
|
-
baseUrl: 'http://localhost:3000',
|
|
495
|
+
entry: 'src/index.ts',
|
|
496
|
+
curl: false, // true: curl commands (requires baseUrl); false: hono request
|
|
497
|
+
baseUrl: 'http://localhost:3000',
|
|
487
498
|
},
|
|
488
499
|
})
|
|
489
500
|
```
|