hono-takibi 0.9.60 → 0.9.70
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 +0 -24
- package/dist/cli/index.d.ts +27 -22
- package/dist/cli/index.js +170 -82
- package/dist/config/index.d.ts +74 -10
- package/dist/config/index.js +226 -4
- package/dist/core/components/callbacks.d.ts +34 -0
- package/dist/core/components/callbacks.js +55 -0
- package/dist/core/components/examples.d.ts +34 -0
- package/dist/core/components/examples.js +55 -0
- package/dist/core/components/headers.d.ts +44 -0
- package/dist/core/components/headers.js +76 -0
- package/dist/core/components/index.d.ts +16 -0
- package/dist/core/components/index.js +18 -0
- package/dist/core/components/links.d.ts +34 -0
- package/dist/core/components/links.js +55 -0
- package/dist/core/components/parameters.d.ts +44 -0
- package/dist/core/components/parameters.js +76 -0
- package/dist/core/components/requestBodies.d.ts +41 -0
- package/dist/core/components/requestBodies.js +73 -0
- package/dist/core/components/responses.d.ts +41 -0
- package/dist/core/components/responses.js +73 -0
- package/dist/core/components/schemas.d.ts +37 -0
- package/dist/core/components/schemas.js +75 -0
- package/dist/core/components/securitySchemes.d.ts +34 -0
- package/dist/core/components/securitySchemes.js +55 -0
- package/dist/core/index.d.ts +10 -0
- package/dist/core/index.js +11 -0
- package/dist/core/route/index.d.ts +55 -0
- package/dist/core/route/index.js +103 -0
- package/dist/core/rpc/index.d.ts +8 -0
- package/dist/core/rpc/index.js +494 -0
- package/dist/core/{takibi.d.ts → takibi/index.d.ts} +19 -14
- package/dist/core/takibi/index.js +71 -0
- package/dist/core/type/index.d.ts +39 -0
- package/dist/core/type/index.js +144 -0
- package/dist/format/index.d.ts +1 -7
- package/dist/format/index.js +11 -19
- package/dist/generator/zod-openapi-hono/app/index.d.ts +1 -1
- package/dist/generator/zod-openapi-hono/app/index.js +18 -13
- package/dist/generator/zod-openapi-hono/openapi/components/callbacks.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/callbacks.js +19 -0
- package/dist/generator/zod-openapi-hono/openapi/components/examples.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/examples.js +11 -0
- package/dist/generator/zod-openapi-hono/openapi/components/headers.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/headers.js +30 -0
- package/dist/generator/zod-openapi-hono/openapi/components/index.d.ts +16 -3
- package/dist/generator/zod-openapi-hono/openapi/components/index.js +26 -29
- package/dist/generator/zod-openapi-hono/openapi/components/links.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/links.js +12 -0
- package/dist/generator/zod-openapi-hono/openapi/components/parameters.d.ts +10 -0
- package/dist/generator/zod-openapi-hono/openapi/components/parameters.js +40 -0
- package/dist/generator/zod-openapi-hono/openapi/components/request-bodies.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/request-bodies.js +12 -0
- package/dist/generator/zod-openapi-hono/openapi/components/responses.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/responses.js +9 -0
- package/dist/generator/zod-openapi-hono/openapi/components/schemas.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/schemas.js +19 -0
- package/dist/generator/zod-openapi-hono/openapi/components/securitySchemes.d.ts +2 -0
- package/dist/generator/zod-openapi-hono/openapi/components/securitySchemes.js +11 -0
- package/dist/generator/zod-openapi-hono/openapi/index.d.ts +64 -4
- package/dist/generator/zod-openapi-hono/openapi/index.js +36 -9
- package/dist/generator/zod-openapi-hono/openapi/{route/route.d.ts → routes/create-route.d.ts} +1 -1
- package/dist/generator/zod-openapi-hono/openapi/routes/create-route.js +37 -0
- package/dist/generator/zod-openapi-hono/openapi/routes/index.d.ts +5 -0
- package/dist/generator/zod-openapi-hono/openapi/routes/index.js +42 -0
- package/dist/generator/zod-to-openapi/index.d.ts +46 -2
- package/dist/generator/zod-to-openapi/index.js +189 -73
- package/dist/generator/zod-to-openapi/type/index.d.ts +2 -0
- package/dist/generator/zod-to-openapi/type/index.js +17 -0
- package/dist/generator/zod-to-openapi/z/enum.js +30 -15
- package/dist/generator/zod-to-openapi/z/index.d.ts +0 -1
- package/dist/generator/zod-to-openapi/z/index.js +0 -1
- package/dist/generator/zod-to-openapi/z/integer.js +47 -69
- package/dist/generator/zod-to-openapi/z/number.js +43 -72
- package/dist/generator/zod-to-openapi/z/object.js +11 -2
- package/dist/generator/zod-to-openapi/z/string.d.ts +1 -21
- package/dist/generator/zod-to-openapi/z/string.js +22 -43
- package/dist/helper/ast.d.ts +96 -0
- package/dist/helper/ast.js +297 -0
- package/dist/helper/barell.d.ts +3 -0
- package/dist/helper/barell.js +7 -0
- package/dist/helper/code.d.ts +27 -0
- package/dist/helper/code.js +68 -0
- package/dist/helper/core.d.ts +41 -0
- package/dist/helper/core.js +63 -0
- package/dist/helper/exports.d.ts +9 -0
- package/dist/helper/exports.js +29 -0
- package/dist/helper/handler.d.ts +16 -0
- package/dist/helper/handler.js +101 -0
- package/dist/helper/index.d.ts +9 -4
- package/dist/helper/index.js +8 -4
- package/dist/helper/openapi.d.ts +135 -0
- package/dist/helper/openapi.js +505 -0
- package/dist/helper/schema.d.ts +20 -0
- package/dist/helper/schema.js +66 -0
- package/dist/helper/type.d.ts +3 -0
- package/dist/helper/type.js +147 -0
- package/dist/helper/wrap.d.ts +58 -2
- package/dist/helper/wrap.js +163 -16
- package/dist/openapi/index.d.ts +372 -152
- package/dist/openapi/index.js +66 -27
- package/dist/utils/index.d.ts +70 -124
- package/dist/utils/index.js +117 -228
- package/dist/vite-plugin/index.d.ts +41 -0
- package/dist/vite-plugin/index.js +356 -324
- package/package.json +21 -17
- package/dist/core/route.d.ts +0 -7
- package/dist/core/route.js +0 -98
- package/dist/core/rpc.d.ts +0 -13
- package/dist/core/rpc.js +0 -357
- package/dist/core/schema.d.ts +0 -27
- package/dist/core/schema.js +0 -115
- package/dist/core/takibi.js +0 -183
- package/dist/generator/zod-openapi-hono/openapi/route/index.d.ts +0 -2
- package/dist/generator/zod-openapi-hono/openapi/route/index.js +0 -47
- package/dist/generator/zod-openapi-hono/openapi/route/params/index.d.ts +0 -3
- package/dist/generator/zod-openapi-hono/openapi/route/params/index.js +0 -3
- package/dist/generator/zod-openapi-hono/openapi/route/params/params-object.d.ts +0 -17
- package/dist/generator/zod-openapi-hono/openapi/route/params/params-object.js +0 -33
- package/dist/generator/zod-openapi-hono/openapi/route/params/query-parameter.d.ts +0 -14
- package/dist/generator/zod-openapi-hono/openapi/route/params/query-parameter.js +0 -24
- package/dist/generator/zod-openapi-hono/openapi/route/params/request-parameter.d.ts +0 -14
- package/dist/generator/zod-openapi-hono/openapi/route/params/request-parameter.js +0 -51
- package/dist/generator/zod-openapi-hono/openapi/route/request/body/index.d.ts +0 -10
- package/dist/generator/zod-openapi-hono/openapi/route/request/body/index.js +0 -31
- package/dist/generator/zod-openapi-hono/openapi/route/response/index.d.ts +0 -14
- package/dist/generator/zod-openapi-hono/openapi/route/response/index.js +0 -86
- package/dist/generator/zod-openapi-hono/openapi/route/route.js +0 -34
- package/dist/generator/zod-to-openapi/z/array.d.ts +0 -50
- package/dist/generator/zod-to-openapi/z/array.js +0 -68
- package/dist/helper/docs.d.ts +0 -14
- package/dist/helper/docs.js +0 -15
- package/dist/helper/properties-schema.d.ts +0 -46
- package/dist/helper/properties-schema.js +0 -61
- package/dist/helper/resolve-schemas-dependencies.d.ts +0 -13
- package/dist/helper/resolve-schemas-dependencies.js +0 -57
- package/dist/helper/zod-to-openapi-schema.d.ts +0 -14
- package/dist/helper/zod-to-openapi-schema.js +0 -30
- package/dist/typespec/index.d.ts +0 -33
- package/dist/typespec/index.js +0 -52
package/README.md
CHANGED
|
@@ -230,30 +230,6 @@ That’s it — set `input`, choose one of the two patterns, and (optionally) ad
|
|
|
230
230
|
|
|
231
231
|

|
|
232
232
|
|
|
233
|
-
|
|
234
|
-
## AI Prompt Example
|
|
235
|
-
|
|
236
|
-
```sh
|
|
237
|
-
Generate one **OpenAPI 3.x+** YAML (prefer **3.1.0**).
|
|
238
|
-
|
|
239
|
-
Rules:
|
|
240
|
-
- Use only `components.schemas` (no other `components`).
|
|
241
|
-
- Never include `parameters:`.
|
|
242
|
-
- No path params; all inputs in `requestBody` (`application/json`) with `$ref: '#/components/schemas/*'`.
|
|
243
|
-
- All responses use `application/json` with `$ref: '#/components/schemas/*'`.
|
|
244
|
-
- POST-only action routes: `/resource/create|get|search|update|delete`.
|
|
245
|
-
- No inline schemas in `paths`.
|
|
246
|
-
|
|
247
|
-
Fill, then generate:
|
|
248
|
-
- title / version / tags
|
|
249
|
-
- resources & fields
|
|
250
|
-
- ops per resource: create / get / search / update / delete
|
|
251
|
-
|
|
252
|
-
**Output format (strict):**
|
|
253
|
-
- Return a **single fenced code block** labeled `yaml` that contains **only** the YAML.
|
|
254
|
-
- No text before or after the code block.
|
|
255
|
-
```
|
|
256
|
-
|
|
257
233
|
### ⚠️ WARNING: Potential Breaking Changes Without Notice
|
|
258
234
|
|
|
259
235
|
**This package is in active development and may introduce breaking changes without prior notice.**
|
package/dist/cli/index.d.ts
CHANGED
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* CLI entry point for
|
|
2
|
+
* Main CLI entry point for hono-takibi.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Processes command-line arguments or config file to generate TypeScript
|
|
5
|
+
* code from OpenAPI specifications. Supports both CLI mode and config file mode.
|
|
5
6
|
*
|
|
6
7
|
* ```mermaid
|
|
7
8
|
* flowchart TD
|
|
8
|
-
* A["Start
|
|
9
|
-
* B
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* H --> I
|
|
16
|
-
*
|
|
17
|
-
*
|
|
9
|
+
* A["Start"] --> B{"Args: --help/-h?"}
|
|
10
|
+
* B -->|Yes| C["Return help text"]
|
|
11
|
+
* B -->|No| D{"Config file exists?"}
|
|
12
|
+
* D -->|No| E["CLI Mode"]
|
|
13
|
+
* D -->|Yes| F["Config Mode"]
|
|
14
|
+
* E --> G["parseCli(args)"]
|
|
15
|
+
* G --> H["parseOpenAPI(input)"]
|
|
16
|
+
* H --> I["takibi(openAPI, ...)"]
|
|
17
|
+
* F --> J["config()"]
|
|
18
|
+
* J --> K["parseOpenAPI(config.input)"]
|
|
19
|
+
* K --> L["Generate all components"]
|
|
20
|
+
* L --> M["Return results"]
|
|
21
|
+
* I --> M
|
|
18
22
|
* ```
|
|
19
23
|
*
|
|
20
|
-
*
|
|
21
|
-
* - `--export-type` Export TypeScript type aliases
|
|
22
|
-
* - `--export-schema` Export Zod schema objects
|
|
23
|
-
* - `--template` Generate app file and handler stubs
|
|
24
|
-
* - `--test` Generate empty `*.test.ts` files
|
|
25
|
-
* - `--base-path <path>` API prefix (default: `/`)
|
|
26
|
-
* - `-h, --help` Show help and exit
|
|
24
|
+
* @returns Promise resolving to success with output message or error
|
|
27
25
|
*
|
|
28
|
-
* @
|
|
29
|
-
*
|
|
30
|
-
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* // CLI usage
|
|
29
|
+
* const result = await honoTakibi()
|
|
30
|
+
* if (result.ok) {
|
|
31
|
+
* console.log(result.value) // "Generated code written to routes.ts"
|
|
32
|
+
* } else {
|
|
33
|
+
* console.error(result.error)
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
31
36
|
*/
|
|
32
37
|
export declare function honoTakibi(): Promise<{
|
|
33
38
|
readonly ok: true;
|
package/dist/cli/index.js
CHANGED
|
@@ -1,118 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI module for hono-takibi.
|
|
3
|
+
*
|
|
4
|
+
* Provides the main entry point for the CLI tool that converts OpenAPI
|
|
5
|
+
* specifications to Hono routes with Zod validation.
|
|
6
|
+
*
|
|
7
|
+
* ```mermaid
|
|
8
|
+
* flowchart TD
|
|
9
|
+
* A["honoTakibi()"] --> B{"--help or -h?"}
|
|
10
|
+
* B -->|Yes| C["Return HELP_TEXT"]
|
|
11
|
+
* B -->|No| D{"hono-takibi.config.ts exists?"}
|
|
12
|
+
* D -->|No| E["Parse CLI args"]
|
|
13
|
+
* D -->|Yes| F["Load config file"]
|
|
14
|
+
* E --> G["parseOpenAPI(input)"]
|
|
15
|
+
* F --> G
|
|
16
|
+
* G --> H["takibi() + components"]
|
|
17
|
+
* H --> I["Return success/error"]
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @module cli
|
|
21
|
+
*/
|
|
1
22
|
import { existsSync } from 'node:fs';
|
|
2
23
|
import { resolve } from 'node:path';
|
|
3
|
-
import {
|
|
4
|
-
import { route } from '../core/
|
|
5
|
-
import {
|
|
6
|
-
import { schema } from '../core/schema.js';
|
|
7
|
-
import { takibi } from '../core/takibi.js';
|
|
8
|
-
// import { honoRpcWithSWR } from '../generator/swr/index.js'
|
|
24
|
+
import { loadConfig } from '../config/index.js';
|
|
25
|
+
import { callbacks, examples, headers, links, parameters, requestBodies, responses, route, rpc, schemas, securitySchemes, takibi, type, } from '../core/index.js';
|
|
26
|
+
import { parseOpenAPI } from '../openapi/index.js';
|
|
9
27
|
import { parseCli } from '../utils/index.js';
|
|
10
|
-
/**
|
|
11
|
-
* CLI usage help text shown when `-h`/`--help` is provided.
|
|
12
|
-
* Kept as a single template for easy updates and snapshot stability.
|
|
13
|
-
*/
|
|
14
28
|
const HELP_TEXT = `Usage: hono-takibi <input.{yaml,json,tsp}> -o <routes.ts> [options]
|
|
15
29
|
|
|
16
30
|
Options:
|
|
17
|
-
--export-
|
|
18
|
-
--export-
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
-
|
|
31
|
+
--export-schemas-types export schemas types
|
|
32
|
+
--export-schemas export schemas
|
|
33
|
+
--export-parameters-types export parameters types
|
|
34
|
+
--export-parameters export parameters
|
|
35
|
+
--export-security-schemes export securitySchemes
|
|
36
|
+
--export-request-bodies export requestBodies
|
|
37
|
+
--export-responses export responses
|
|
38
|
+
--export-headers-types export headers types
|
|
39
|
+
--export-headers export headers
|
|
40
|
+
--export-examples export examples
|
|
41
|
+
--export-links export links
|
|
42
|
+
--export-callbacks export callbacks
|
|
43
|
+
--template generate app file and handler stubs
|
|
44
|
+
--test generate empty *.test.ts files
|
|
45
|
+
--base-path <path> api prefix (default: /)
|
|
46
|
+
-h, --help display help for command`;
|
|
23
47
|
/**
|
|
24
|
-
* CLI entry point for
|
|
48
|
+
* Main CLI entry point for hono-takibi.
|
|
25
49
|
*
|
|
26
|
-
*
|
|
50
|
+
* Processes command-line arguments or config file to generate TypeScript
|
|
51
|
+
* code from OpenAPI specifications. Supports both CLI mode and config file mode.
|
|
27
52
|
*
|
|
28
53
|
* ```mermaid
|
|
29
54
|
* flowchart TD
|
|
30
|
-
* A["Start
|
|
31
|
-
* B
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* H --> I
|
|
38
|
-
*
|
|
39
|
-
*
|
|
55
|
+
* A["Start"] --> B{"Args: --help/-h?"}
|
|
56
|
+
* B -->|Yes| C["Return help text"]
|
|
57
|
+
* B -->|No| D{"Config file exists?"}
|
|
58
|
+
* D -->|No| E["CLI Mode"]
|
|
59
|
+
* D -->|Yes| F["Config Mode"]
|
|
60
|
+
* E --> G["parseCli(args)"]
|
|
61
|
+
* G --> H["parseOpenAPI(input)"]
|
|
62
|
+
* H --> I["takibi(openAPI, ...)"]
|
|
63
|
+
* F --> J["config()"]
|
|
64
|
+
* J --> K["parseOpenAPI(config.input)"]
|
|
65
|
+
* K --> L["Generate all components"]
|
|
66
|
+
* L --> M["Return results"]
|
|
67
|
+
* I --> M
|
|
40
68
|
* ```
|
|
41
69
|
*
|
|
42
|
-
*
|
|
43
|
-
* - `--export-type` Export TypeScript type aliases
|
|
44
|
-
* - `--export-schema` Export Zod schema objects
|
|
45
|
-
* - `--template` Generate app file and handler stubs
|
|
46
|
-
* - `--test` Generate empty `*.test.ts` files
|
|
47
|
-
* - `--base-path <path>` API prefix (default: `/`)
|
|
48
|
-
* - `-h, --help` Show help and exit
|
|
70
|
+
* @returns Promise resolving to success with output message or error
|
|
49
71
|
*
|
|
50
|
-
* @
|
|
51
|
-
*
|
|
52
|
-
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* // CLI usage
|
|
75
|
+
* const result = await honoTakibi()
|
|
76
|
+
* if (result.ok) {
|
|
77
|
+
* console.log(result.value) // "Generated code written to routes.ts"
|
|
78
|
+
* } else {
|
|
79
|
+
* console.error(result.error)
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
53
82
|
*/
|
|
54
83
|
export async function honoTakibi() {
|
|
55
|
-
/** Slice the arguments to remove the first two (node and script path) */
|
|
56
84
|
const args = process.argv.slice(2);
|
|
57
|
-
|
|
58
|
-
return
|
|
59
|
-
};
|
|
60
|
-
/** help */
|
|
61
|
-
if (isHelpRequested(args)) {
|
|
62
|
-
return {
|
|
63
|
-
ok: true,
|
|
64
|
-
value: HELP_TEXT,
|
|
65
|
-
};
|
|
85
|
+
if (args.length === 1 && (args[0] === '--help' || args[0] === '-h')) {
|
|
86
|
+
return { ok: true, value: HELP_TEXT };
|
|
66
87
|
}
|
|
67
88
|
const abs = resolve(process.cwd(), 'hono-takibi.config.ts');
|
|
68
|
-
/** If config file does not exist, parse CLI arguments */
|
|
69
89
|
if (!existsSync(abs)) {
|
|
70
90
|
const cliResult = parseCli(args);
|
|
71
91
|
if (!cliResult.ok)
|
|
72
92
|
return { ok: false, error: cliResult.error };
|
|
73
93
|
const cli = cliResult.value;
|
|
74
|
-
const
|
|
94
|
+
const { input, output, template, test, basePath, componentsOptions } = cli;
|
|
95
|
+
const openAPIResult = await parseOpenAPI(input);
|
|
96
|
+
if (!openAPIResult.ok)
|
|
97
|
+
return { ok: false, error: openAPIResult.error };
|
|
98
|
+
const openAPI = openAPIResult.value;
|
|
99
|
+
const takibiResult = await takibi(openAPI, output, template, test, basePath, componentsOptions);
|
|
75
100
|
if (!takibiResult.ok)
|
|
76
101
|
return { ok: false, error: takibiResult.error };
|
|
77
|
-
return {
|
|
78
|
-
ok: true,
|
|
79
|
-
value: takibiResult.value,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/** If config file exists, parse config file */
|
|
83
|
-
const configResult = await config();
|
|
84
|
-
if (!configResult.ok) {
|
|
85
|
-
return { ok: false, error: configResult.error };
|
|
102
|
+
return { ok: true, value: takibiResult.value };
|
|
86
103
|
}
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
const loadConfigResult = await loadConfig();
|
|
105
|
+
if (!loadConfigResult.ok)
|
|
106
|
+
return { ok: false, error: loadConfigResult.error };
|
|
107
|
+
const config = loadConfigResult.value;
|
|
108
|
+
const openAPIResult = await parseOpenAPI(config.input);
|
|
109
|
+
if (!openAPIResult.ok)
|
|
110
|
+
return { ok: false, error: openAPIResult.error };
|
|
111
|
+
const openAPI = openAPIResult.value;
|
|
112
|
+
const [takibiResult, schemaResult, parameterResult, headersResult, examplesResult, linksResult, callbacksResult, securitySchemesResult, requestBodiesResult, responsesResult, routeResult, typeResult, rpcResult,] = await Promise.all([
|
|
113
|
+
config['zod-openapi']?.output
|
|
114
|
+
? takibi(openAPI, config['zod-openapi'].output, false, false, '/', {
|
|
115
|
+
exportSchemasTypes: config['zod-openapi'].exportSchemasTypes ?? false,
|
|
116
|
+
exportSchemas: config['zod-openapi'].exportSchemas ?? false,
|
|
117
|
+
exportParametersTypes: config['zod-openapi'].exportParametersTypes ?? false,
|
|
118
|
+
exportParameters: config['zod-openapi'].exportParameters ?? false,
|
|
119
|
+
exportSecuritySchemes: config['zod-openapi'].exportSecuritySchemes ?? false,
|
|
120
|
+
exportRequestBodies: config['zod-openapi'].exportRequestBodies ?? false,
|
|
121
|
+
exportResponses: config['zod-openapi'].exportResponses ?? false,
|
|
122
|
+
exportHeadersTypes: config['zod-openapi'].exportHeadersTypes ?? false,
|
|
123
|
+
exportHeaders: config['zod-openapi'].exportHeaders ?? false,
|
|
124
|
+
exportExamples: config['zod-openapi'].exportExamples ?? false,
|
|
125
|
+
exportLinks: config['zod-openapi'].exportLinks ?? false,
|
|
126
|
+
exportCallbacks: config['zod-openapi'].exportCallbacks ?? false,
|
|
127
|
+
})
|
|
128
|
+
: Promise.resolve(undefined),
|
|
129
|
+
config['zod-openapi']?.components?.schemas
|
|
130
|
+
? schemas(openAPI.components?.schemas, config['zod-openapi']?.components?.schemas?.output, config['zod-openapi']?.components?.schemas?.split ?? false, config['zod-openapi']?.components?.schemas?.exportTypes ?? false)
|
|
131
|
+
: Promise.resolve(undefined),
|
|
132
|
+
config['zod-openapi']?.components?.parameters
|
|
133
|
+
? parameters(openAPI.components?.parameters, config['zod-openapi']?.components?.parameters?.output, config['zod-openapi']?.components?.parameters?.split ?? false, config['zod-openapi']?.components?.parameters?.exportTypes ?? false, config['zod-openapi']?.components)
|
|
134
|
+
: Promise.resolve(undefined),
|
|
135
|
+
config['zod-openapi']?.components?.headers
|
|
136
|
+
? headers(openAPI.components?.headers, config['zod-openapi']?.components?.headers?.output, config['zod-openapi']?.components?.headers?.split ?? false, config['zod-openapi']?.components?.headers?.exportTypes ?? false, config['zod-openapi']?.components)
|
|
137
|
+
: Promise.resolve(undefined),
|
|
138
|
+
config['zod-openapi']?.components?.examples
|
|
139
|
+
? examples(openAPI.components?.examples, config['zod-openapi']?.components?.examples?.output, config['zod-openapi']?.components?.examples?.split ?? false)
|
|
140
|
+
: Promise.resolve(undefined),
|
|
141
|
+
config['zod-openapi']?.components?.links
|
|
142
|
+
? links(openAPI.components?.links, config['zod-openapi']?.components?.links?.output, config['zod-openapi']?.components?.links?.split ?? false)
|
|
143
|
+
: Promise.resolve(undefined),
|
|
144
|
+
config['zod-openapi']?.components?.callbacks
|
|
145
|
+
? callbacks(openAPI.components?.callbacks, config['zod-openapi']?.components?.callbacks?.output, config['zod-openapi']?.components?.callbacks?.split ?? false)
|
|
146
|
+
: Promise.resolve(undefined),
|
|
147
|
+
config['zod-openapi']?.components?.securitySchemes
|
|
148
|
+
? securitySchemes(openAPI.components?.securitySchemes, config['zod-openapi']?.components?.securitySchemes?.output, config['zod-openapi']?.components?.securitySchemes?.split ?? false)
|
|
149
|
+
: Promise.resolve(undefined),
|
|
150
|
+
config['zod-openapi']?.components?.requestBodies
|
|
151
|
+
? requestBodies(openAPI.components?.requestBodies, config['zod-openapi']?.components?.requestBodies?.output, config['zod-openapi']?.components?.requestBodies?.split ?? false, config['zod-openapi']?.components)
|
|
152
|
+
: Promise.resolve(undefined),
|
|
153
|
+
config['zod-openapi']?.components?.responses
|
|
154
|
+
? responses(openAPI.components?.responses, config['zod-openapi']?.components?.responses?.output, config['zod-openapi']?.components?.responses?.split ?? false, config['zod-openapi']?.components)
|
|
155
|
+
: Promise.resolve(undefined),
|
|
156
|
+
config['zod-openapi']?.routes
|
|
157
|
+
? route(openAPI, config['zod-openapi'].routes, config['zod-openapi'].components)
|
|
158
|
+
: Promise.resolve(undefined),
|
|
159
|
+
config.type ? type(openAPI, config.type.output) : Promise.resolve(undefined),
|
|
160
|
+
config.rpc
|
|
161
|
+
? rpc(openAPI, config.rpc.output, config.rpc.import, config.rpc.split ?? false)
|
|
162
|
+
: Promise.resolve(undefined),
|
|
163
|
+
]);
|
|
93
164
|
if (takibiResult && !takibiResult.ok)
|
|
94
165
|
return { ok: false, error: takibiResult.error };
|
|
95
|
-
/** schema */
|
|
96
|
-
const schemaResult = c['zod-openapi']?.schema
|
|
97
|
-
? await schema(c.input, c['zod-openapi'].schema.output, c['zod-openapi'].schema.exportType ?? false, c['zod-openapi']?.schema.split ?? false)
|
|
98
|
-
: undefined;
|
|
99
166
|
if (schemaResult && !schemaResult.ok)
|
|
100
167
|
return { ok: false, error: schemaResult.error };
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
:
|
|
168
|
+
if (parameterResult && !parameterResult.ok)
|
|
169
|
+
return { ok: false, error: parameterResult.error };
|
|
170
|
+
if (headersResult && !headersResult.ok)
|
|
171
|
+
return { ok: false, error: headersResult.error };
|
|
172
|
+
if (examplesResult && !examplesResult.ok)
|
|
173
|
+
return { ok: false, error: examplesResult.error };
|
|
174
|
+
if (linksResult && !linksResult.ok)
|
|
175
|
+
return { ok: false, error: linksResult.error };
|
|
176
|
+
if (callbacksResult && !callbacksResult.ok)
|
|
177
|
+
return { ok: false, error: callbacksResult.error };
|
|
178
|
+
if (securitySchemesResult && !securitySchemesResult.ok)
|
|
179
|
+
return { ok: false, error: securitySchemesResult.error };
|
|
180
|
+
if (requestBodiesResult && !requestBodiesResult.ok)
|
|
181
|
+
return { ok: false, error: requestBodiesResult.error };
|
|
182
|
+
if (responsesResult && !responsesResult.ok)
|
|
183
|
+
return { ok: false, error: responsesResult.error };
|
|
105
184
|
if (routeResult && !routeResult.ok)
|
|
106
185
|
return { ok: false, error: routeResult.error };
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
? await rpc(c.input, c.rpc.output, c.rpc.import, c.rpc.split ?? false)
|
|
110
|
-
: undefined;
|
|
186
|
+
if (typeResult && !typeResult.ok)
|
|
187
|
+
return { ok: false, error: typeResult.error };
|
|
111
188
|
if (rpcResult && !rpcResult.ok)
|
|
112
189
|
return { ok: false, error: rpcResult.error };
|
|
113
|
-
const results = [
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
value
|
|
117
|
-
|
|
190
|
+
const results = [
|
|
191
|
+
takibiResult?.value,
|
|
192
|
+
schemaResult?.value,
|
|
193
|
+
parameterResult?.value,
|
|
194
|
+
headersResult?.value,
|
|
195
|
+
examplesResult?.value,
|
|
196
|
+
linksResult?.value,
|
|
197
|
+
callbacksResult?.value,
|
|
198
|
+
securitySchemesResult?.value,
|
|
199
|
+
requestBodiesResult?.value,
|
|
200
|
+
responsesResult?.value,
|
|
201
|
+
routeResult?.value,
|
|
202
|
+
typeResult?.value,
|
|
203
|
+
rpcResult?.value,
|
|
204
|
+
].filter((v) => v !== undefined);
|
|
205
|
+
return { ok: true, value: results.join('\n') };
|
|
118
206
|
}
|
package/dist/config/index.d.ts
CHANGED
|
@@ -2,26 +2,90 @@ type Config = {
|
|
|
2
2
|
readonly input: `${string}.yaml` | `${string}.json` | `${string}.tsp`;
|
|
3
3
|
readonly 'zod-openapi'?: {
|
|
4
4
|
readonly output?: `${string}.ts`;
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
5
|
+
readonly exportSchemas?: boolean;
|
|
6
|
+
readonly exportSchemasTypes?: boolean;
|
|
7
|
+
readonly exportParameters?: boolean;
|
|
8
|
+
readonly exportParametersTypes?: boolean;
|
|
9
|
+
readonly exportSecuritySchemes?: boolean;
|
|
10
|
+
readonly exportRequestBodies?: boolean;
|
|
11
|
+
readonly exportResponses?: boolean;
|
|
12
|
+
readonly exportHeaders?: boolean;
|
|
13
|
+
readonly exportHeadersTypes?: boolean;
|
|
14
|
+
readonly exportExamples?: boolean;
|
|
15
|
+
readonly exportLinks?: boolean;
|
|
16
|
+
readonly exportCallbacks?: boolean;
|
|
17
|
+
readonly routes?: {
|
|
8
18
|
readonly output: string | `${string}.ts`;
|
|
9
|
-
readonly exportType?: boolean;
|
|
10
19
|
readonly split?: boolean;
|
|
11
20
|
};
|
|
12
|
-
readonly
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
readonly components?: {
|
|
22
|
+
readonly schemas?: {
|
|
23
|
+
readonly output: string | `${string}.ts`;
|
|
24
|
+
readonly exportTypes?: boolean;
|
|
25
|
+
readonly split?: boolean;
|
|
26
|
+
readonly import?: string;
|
|
27
|
+
};
|
|
28
|
+
readonly parameters?: {
|
|
29
|
+
readonly output: string | `${string}.ts`;
|
|
30
|
+
readonly exportTypes?: boolean;
|
|
31
|
+
readonly split?: boolean;
|
|
32
|
+
readonly import?: string;
|
|
33
|
+
};
|
|
34
|
+
readonly securitySchemes?: {
|
|
35
|
+
readonly output: string | `${string}.ts`;
|
|
36
|
+
readonly split?: boolean;
|
|
37
|
+
readonly import?: string;
|
|
38
|
+
};
|
|
39
|
+
readonly requestBodies?: {
|
|
40
|
+
readonly output: string | `${string}.ts`;
|
|
41
|
+
readonly split?: boolean;
|
|
42
|
+
readonly import?: string;
|
|
43
|
+
};
|
|
44
|
+
readonly responses?: {
|
|
45
|
+
readonly output: string | `${string}.ts`;
|
|
46
|
+
readonly split?: boolean;
|
|
47
|
+
readonly import?: string;
|
|
48
|
+
};
|
|
49
|
+
readonly headers?: {
|
|
50
|
+
readonly output: string | `${string}.ts`;
|
|
51
|
+
readonly exportTypes?: boolean;
|
|
52
|
+
readonly split?: boolean;
|
|
53
|
+
readonly import?: string;
|
|
54
|
+
};
|
|
55
|
+
readonly examples?: {
|
|
56
|
+
readonly output: string | `${string}.ts`;
|
|
57
|
+
readonly split?: boolean;
|
|
58
|
+
readonly import?: string;
|
|
59
|
+
};
|
|
60
|
+
readonly links?: {
|
|
61
|
+
readonly output: string | `${string}.ts`;
|
|
62
|
+
readonly split?: boolean;
|
|
63
|
+
readonly import?: string;
|
|
64
|
+
};
|
|
65
|
+
readonly callbacks?: {
|
|
66
|
+
readonly output: string | `${string}.ts`;
|
|
67
|
+
readonly split?: boolean;
|
|
68
|
+
readonly import?: string;
|
|
69
|
+
};
|
|
16
70
|
};
|
|
17
71
|
};
|
|
72
|
+
readonly type?: {
|
|
73
|
+
readonly output: `${string}.ts`;
|
|
74
|
+
};
|
|
18
75
|
readonly rpc?: {
|
|
19
76
|
readonly output: string | `${string}.ts`;
|
|
20
77
|
readonly import: string;
|
|
21
78
|
readonly split?: boolean;
|
|
22
79
|
};
|
|
23
80
|
};
|
|
24
|
-
export declare function config
|
|
81
|
+
export declare function parseConfig(config: Config): {
|
|
82
|
+
readonly ok: true;
|
|
83
|
+
readonly value: Config;
|
|
84
|
+
} | {
|
|
85
|
+
readonly ok: false;
|
|
86
|
+
readonly error: string;
|
|
87
|
+
};
|
|
88
|
+
export declare function loadConfig(): Promise<{
|
|
25
89
|
readonly ok: true;
|
|
26
90
|
readonly value: Config;
|
|
27
91
|
} | {
|
|
@@ -33,5 +97,5 @@ export declare function config(): Promise<{
|
|
|
33
97
|
*
|
|
34
98
|
* @see config
|
|
35
99
|
*/
|
|
36
|
-
export declare function defineConfig(
|
|
100
|
+
export declare function defineConfig(config: Config): Config;
|
|
37
101
|
export {};
|