hono-takibi 0.9.99998 → 0.10.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.
Files changed (33) hide show
  1. package/README.md +79 -2
  2. package/dist/cli.js +285 -103
  3. package/dist/core/docs/index.d.ts +3 -10
  4. package/dist/core/docs/index.js +1 -1
  5. package/dist/core/hooks/index.d.ts +9 -11
  6. package/dist/core/hooks/index.js +1 -1
  7. package/dist/core/rpc/index.d.ts +5 -19
  8. package/dist/core/rpc/index.js +27 -48
  9. package/dist/core/type/index.d.ts +4 -15
  10. package/dist/core/type/index.js +10 -18
  11. package/dist/{shared-Zyc06ZL_.js → core-BdG_5KX8.js} +689 -1374
  12. package/dist/{docs-D0ZoEuTk.js → docs-MzhmjfNS.js} +24 -30
  13. package/dist/emit-B_3fXoto.js +13 -0
  14. package/dist/file-CwKqigE9.js +55 -0
  15. package/dist/format-Bm9LZ_ki.js +41 -0
  16. package/dist/generator/zod-openapi-hono/openapi/index.d.ts +1 -1
  17. package/dist/generator/zod-openapi-hono/openapi/index.js +1 -1
  18. package/dist/{hooks-BMBBxGkd.js → hooks-iffNFEYy.js} +107 -165
  19. package/dist/index-6-_xlYFY.d.ts +17 -0
  20. package/dist/{index-BDBsbJIq.d.ts → index-B2QvGO4j.d.ts} +32 -31
  21. package/dist/index-wD0wV6VQ.d.ts +12 -0
  22. package/dist/index.d.ts +1215 -1172
  23. package/dist/index.js +582 -208
  24. package/dist/{openapi-DvDCtFfn.js → openapi-B2CqQVWF.js} +62 -90
  25. package/dist/openapi-CzAVsFDt.js +41 -0
  26. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  27. package/dist/{rpc-BefI0iar.js → rpc-B95CYct5.js} +19 -7
  28. package/dist/shared-Ck7P2pO5.js +295 -0
  29. package/dist/{utils-D1npWaGs.js → utils-BDa05U34.js} +31 -41
  30. package/dist/vite-plugin/index.js +184 -138
  31. package/package.json +15 -19
  32. package/dist/emit-rUfH9f6q.js +0 -50
  33. package/dist/fsp-BxW8iutq.js +0 -71
package/README.md CHANGED
@@ -13,12 +13,14 @@
13
13
  - RPC client, mock server, TypeScript types
14
14
  - API reference docs with [hono-cli](https://github.com/honojs/cli) commands
15
15
 
16
+ ## Quick Start
17
+
18
+ ### Installation
19
+
16
20
  ```bash
17
21
  npm install -D hono-takibi
18
22
  ```
19
23
 
20
- ## Quick Start
21
-
22
24
  ### CLI
23
25
 
24
26
  ```bash
@@ -42,6 +44,65 @@ export default defineConfig({
42
44
  npx hono-takibi
43
45
  ```
44
46
 
47
+ ### CLI Reference
48
+
49
+ `hono-takibi --help`:
50
+
51
+ ```
52
+ DESCRIPTION
53
+ Generate @hono/zod-openapi code from OpenAPI or TypeSpec
54
+
55
+ USAGE
56
+ hono-takibi [flags] [<input>]
57
+
58
+ ARGUMENTS
59
+ input input.{yaml,json,tsp} OpenAPI (.yaml, .json) or TypeSpec (.tsp) document to generate from (optional)
60
+
61
+ FLAGS
62
+ --output, -o output.ts TypeScript file the generated routes are written to
63
+ --config, -c file Config file to run (default: ./hono-takibi.config.ts)
64
+ --watch, -w Rerun the config on every change to its documents or itself
65
+
66
+ GLOBAL FLAGS
67
+ --help, -h Show help information
68
+ --version, -v Show version information
69
+ --wizard Start wizard mode for a command
70
+ --completions <bash|zsh|fish|sh> Print shell completion script (choices: bash, zsh, fish, sh)
71
+ --log-level <all|trace|debug|info|warn|warning|error|fatal|none> Sets the minimum log level (choices: all, trace, debug, info, warn, warning, error, fatal, none)
72
+
73
+ EXAMPLES
74
+ # Generate a single routes file
75
+ hono-takibi openapi.yaml -o src/routes.ts
76
+
77
+ # Run every generator declared in ./hono-takibi.config.ts
78
+ hono-takibi
79
+
80
+ # Run a config file from another location
81
+ hono-takibi --config config/api.config.ts
82
+
83
+ # Rerun on every change to the input documents or the config
84
+ hono-takibi --watch
85
+ ```
86
+
87
+ With an `<input>` the CLI writes a single routes file, and `-o` is required. With no
88
+ `<input>` it runs the config file, which opts in the routes, components, webhooks,
89
+ types, mock, docs, test and tanstack-query generators. Paths inside a config file
90
+ resolve against the current directory, so `--config` names where the config lives, not
91
+ where its outputs land.
92
+
93
+ ### Watch mode
94
+
95
+ ```bash
96
+ npx hono-takibi --watch
97
+ ```
98
+
99
+ Reruns the config on every change to the input documents or to the config itself, and
100
+ keeps watching when a run fails. Pairs with `template`: add an operation and its handler
101
+ stub appears, while the code already written into the existing handlers stays put.
102
+
103
+ The whole directory holding the input document is watched, so a TypeSpec entry that
104
+ imports its siblings and an external `$ref` both trigger a rerun.
105
+
45
106
  ### Example
46
107
 
47
108
  input:
@@ -308,6 +369,11 @@ export default defineConfig({
308
369
 
309
370
  Some options are mutually exclusive: `output` ↔ `routes`, `template.define` ↔ `routes`, `components.output` ↔ per-type components, `template.define` ↔ `routeHandler`.
310
371
 
372
+ Every generator needs its own `output` path, and a `split` directory belongs to the
373
+ generator — its `.ts` files are removed before each run, so keep hand-written code
374
+ elsewhere. `basePath`, `client` and `import` are checked here because they are spliced
375
+ into the generated code verbatim.
376
+
311
377
  ```ts
312
378
  import { defineConfig } from 'hono-takibi'
313
379
 
@@ -927,6 +993,17 @@ If you find any issues with the generated code or have suggestions for improveme
927
993
  - Open an issue at [GitHub Issues](https://github.com/nakita628/hono-takibi/issues)
928
994
  - Submit a pull request with your improvements
929
995
 
996
+ Lint and tests run from the repo root:
997
+
998
+ ```bash
999
+ pnpm check # format, lint, type checks, then `pnpm lint`
1000
+ pnpm lint # what the Lint workflow runs
1001
+ pnpm lint:actions # actionlint (syntax) and zizmor (security) over .github/workflows, when installed
1002
+ pnpm test # unit tests, then the generated cases under test/
1003
+ ```
1004
+
1005
+ `actionlint` and `zizmor` are not npm packages: install them with `pipx install actionlint-py` and `pipx install zizmor` to run them locally; without them the script only prints a note. The Lint workflow always runs both.
1006
+
930
1007
  ## License
931
1008
 
932
1009
  Distributed under the MIT License. See [LICENSE](https://github.com/nakita628/hono-takibi?tab=MIT-1-ov-file) for more information.
package/dist/cli.js CHANGED
@@ -1,115 +1,297 @@
1
1
  #!/usr/bin/env node
2
- import { readConfig } from "./index.js";
3
- import { r as setFormatOptions } from "./emit-rUfH9f6q.js";
4
- import { n as parseOpenAPI, r as takibi, t as makeJob } from "./shared-Zyc06ZL_.js";
5
- import { existsSync } from "node:fs";
6
- import { resolve } from "node:path";
2
+ import * as NodeRuntime from "@effect/platform-node/NodeRuntime";
3
+ import * as NodeServices from "@effect/platform-node/NodeServices";
4
+ import { Console, Effect, FileSystem, Option, Ref, Result, Runtime, Schema, Stream } from "effect";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { Argument, CliError, CliOutput, Command, Flag } from "effect/unstable/cli";
7
8
  //#region src/cli/index.ts
8
- const HELP_TEXT = `Usage: hono-takibi <input.{yaml,json,tsp}> -o <output.ts>
9
-
10
- Options:
11
- -h, --help display help for command`;
12
- function isYamlOrJsonOrTsp(i) {
13
- return i.endsWith(".yaml") || i.endsWith(".json") || i.endsWith(".tsp");
9
+ const COMMAND_NAME = "hono-takibi";
10
+ /** Config file `hono-takibi` picks up from the working directory when `--config` is omitted. */
11
+ 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" }));
17
+ const TypeScriptPathSchema = Schema.String.pipe(Schema.refine(Schema.is(Schema.TemplateLiteral([Schema.String, ".ts"])), { message: "a TypeScript file path ending in .ts" }));
18
+ /**
19
+ * One-shot mode generates routes only; every component export stays off. The
20
+ * config file is what turns those on, one field at a time.
21
+ */
22
+ const ONE_SHOT_COMPONENTS = {
23
+ readonly: false,
24
+ exportSchemas: false,
25
+ exportSchemasTypes: false,
26
+ exportResponses: false,
27
+ exportParameters: false,
28
+ exportParametersTypes: false,
29
+ exportExamples: false,
30
+ exportRequestBodies: false,
31
+ exportHeaders: false,
32
+ exportHeadersTypes: false,
33
+ exportSecuritySchemes: false,
34
+ exportLinks: false,
35
+ exportCallbacks: false,
36
+ exportPathItems: false,
37
+ exportMediaTypes: false,
38
+ exportMediaTypesTypes: false
39
+ };
40
+ /**
41
+ * The command line itself: what `hono-takibi` accepts, what each piece means, and the
42
+ * schema every value is decoded through before {@link generate} ever sees it.
43
+ */
44
+ const commandLine = {
45
+ input: Argument.file("input", { mustExist: true }).pipe(Argument.withSchema(DocumentPathSchema), Argument.withDescription("OpenAPI (.yaml, .json) or TypeSpec (.tsp) document to generate from"), Argument.withMetavar("input.{yaml,json,tsp}"), Argument.optional),
46
+ output: Flag.string("output").pipe(Flag.withAlias("o"), Flag.withSchema(TypeScriptPathSchema), Flag.withDescription("TypeScript file the generated routes are written to"), Flag.withMetavar("output.ts"), Flag.optional),
47
+ 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),
48
+ watch: Flag.boolean("watch").pipe(Flag.withAlias("w"), Flag.withDescription("Rerun the config on every change to its documents or itself"), Flag.withDefault(false))
49
+ };
50
+ /** Extensions a change has to carry to be worth regenerating for. */
51
+ const INPUT_EXTENSIONS = [
52
+ ".yaml",
53
+ ".json",
54
+ ".tsp"
55
+ ];
56
+ /**
57
+ * One pass over a config file: read it, parse the document it names, and run every
58
+ * generator it opts into.
59
+ *
60
+ * `reload` is for the passes after the first, where the config file may have been edited
61
+ * since it was imported.
62
+ *
63
+ * The generator pipeline pulls in the OpenAPI parser, the TypeSpec compiler and ts-morph.
64
+ * `--help`, `--version`, `--completions` and every rejected command line must not pay for
65
+ * that, so it is loaded here rather than at module scope. After the first pass the loader
66
+ * answers from cache, so a watch tick pays nothing.
67
+ */
68
+ function runConfigPass(configPath, reload) {
69
+ return Effect.gen(function* () {
70
+ const [{ readConfig }, { parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob }] = yield* Effect.promise(() => Promise.all([
71
+ import("./index.js"),
72
+ import("./openapi-CzAVsFDt.js").then((n) => n.t),
73
+ import("./format-Bm9LZ_ki.js").then((n) => n.r),
74
+ import("./shared-Ck7P2pO5.js").then((n) => n.i)
75
+ ]));
76
+ const config = yield* readConfig(configPath, reload);
77
+ const jobs = makeJob(yield* parseOpenAPI(config.input), config);
78
+ yield* cleanSplitOutputs(jobs.filter((job) => job.split).map((job) => job.output));
79
+ return {
80
+ config,
81
+ report: (yield* Effect.all(jobs.map((job) => job.run(job.output)), { concurrency: "unbounded" }).pipe(Effect.provideService(FormatOptions, config.format ?? {}))).filter((message) => message !== "").join("\n")
82
+ };
83
+ });
84
+ }
85
+ /**
86
+ * A pass whose failure is printed rather than raised, so the watch loop survives it, and
87
+ * which answers with the input directory the config now names.
88
+ *
89
+ * `undefined` means the pass did not get far enough to say — the config is missing, will
90
+ * not import, or does not validate. The loop keeps watching the config either way.
91
+ */
92
+ function reportConfigPass(configPath, reload) {
93
+ return Effect.gen(function* () {
94
+ const result = yield* Effect.result(runConfigPass(configPath, reload));
95
+ if (Result.isFailure(result)) {
96
+ yield* Console.error(`❌ ${result.failure.message}`);
97
+ return;
98
+ }
99
+ yield* Console.log(result.success.report);
100
+ return path.dirname(path.resolve(process.cwd(), result.success.config.input));
101
+ });
102
+ }
103
+ /**
104
+ * Watches the config, and the input documents when a pass has said where they are, until
105
+ * the answer changes — then hands the new directory back so {@link watchConfig} restarts.
106
+ *
107
+ * `runForEachWhile` is what ends the round: a pass that reports a different directory
108
+ * returns `false`, and the directory it reported is in the `Ref` for the caller. The
109
+ * `Ref` is what carries a value out of a stream that otherwise only returns `void`.
110
+ */
111
+ function watchRound(configPath, inputDirectory) {
112
+ return Effect.gen(function* () {
113
+ const fs = yield* FileSystem.FileSystem;
114
+ const configFile = path.basename(configPath);
115
+ const nextDirectory = yield* Ref.make(inputDirectory);
116
+ const configEvents = fs.watch(path.dirname(configPath)).pipe(Stream.filter((event) => event.path === configFile));
117
+ yield* (inputDirectory === void 0 ? configEvents : Stream.merge(fs.watch(inputDirectory, { recursive: true }).pipe(Stream.filter((event) => INPUT_EXTENSIONS.some((extension) => event.path.endsWith(extension)))), configEvents)).pipe(Stream.debounce("200 millis"), Stream.runForEachWhile(() => reportConfigPass(configPath, true).pipe(Effect.tap((directory) => Ref.set(nextDirectory, directory ?? inputDirectory)), Effect.map((directory) => directory === void 0 || directory === inputDirectory))));
118
+ return yield* Ref.get(nextDirectory);
119
+ });
14
120
  }
15
- function isTs(o) {
16
- return o.endsWith(".ts");
121
+ /**
122
+ * Regenerates on every change to the input documents or the config, until interrupted.
123
+ *
124
+ * Two watchers, because two things can invalidate the output. The input document's
125
+ * directory is watched recursively — a TypeSpec entry imports its siblings and a `$ref`
126
+ * can point at one, so the file named by `input` is rarely the only one that matters. The
127
+ * config file is watched through its directory rather than directly, so an editor that
128
+ * saves by renaming does not take the watcher down with it.
129
+ *
130
+ * `WatchEvent.path` is relative to the directory it came from, which is why each stream
131
+ * is filtered before the merge rather than after.
132
+ *
133
+ * `debounce` collapses the burst an editor emits on save into one pass — a plain write
134
+ * already reports twice. Generated files are `.ts` and `.md`, so a pass cannot trigger
135
+ * the next one.
136
+ *
137
+ * `inputDirectory` is `undefined` until a pass has read a config far enough to name one;
138
+ * only the config is watched until then, which is what keeps a config that does not
139
+ * validate at startup from ending the command the caller asked to keep running.
140
+ */
141
+ function watchConfig(configPath, inputDirectory) {
142
+ return Effect.gen(function* () {
143
+ yield* Console.log(inputDirectory === void 0 ? `\n👀 Watching ${configPath} — Ctrl-C to stop` : `\n👀 Watching ${inputDirectory} and ${configPath} — Ctrl-C to stop`);
144
+ return yield* watchConfig(configPath, yield* watchRound(configPath, inputDirectory));
145
+ });
17
146
  }
18
- function parseCli(args) {
19
- const input = args[0];
20
- const oIdx = args.indexOf("-o");
21
- const output = oIdx !== -1 ? args[oIdx + 1] : void 0;
22
- if (!(input && output && isYamlOrJsonOrTsp(input) && isTs(output))) return {
23
- ok: false,
24
- error: HELP_TEXT
25
- };
26
- return {
27
- ok: true,
28
- value: {
29
- input,
30
- output
147
+ /**
148
+ * Everything the command does once the command line has parsed.
149
+ *
150
+ * It resolves to one of two modes and nothing else: an `<input>` with an `-o` writes a
151
+ * single routes file, and anything else runs a config file — which is what opts in the
152
+ * routes, components, webhooks, types, mock, docs, test and tanstack-query generators.
153
+ * `--config` and `<input>` are mutually exclusive, and each of `<input>` / `--output` is
154
+ * meaningless without the other.
155
+ *
156
+ * Everything past the guard clauses fails with something carrying a `message`, so the
157
+ * single `mapError` at the end is where all of it turns into rendered CLI output. The
158
+ * `FileSystem` the generators write through comes from the environment the caller
159
+ * provides.
160
+ */
161
+ function generate(args) {
162
+ return Effect.gen(function* () {
163
+ const input = Option.getOrUndefined(args.input);
164
+ const output = Option.getOrUndefined(args.output);
165
+ const configPath = Option.getOrUndefined(args.config);
166
+ if (configPath !== void 0 && (input !== void 0 || output !== void 0)) {
167
+ const message = "--config cannot be combined with <input> or --output. A config file already names its own input and outputs.";
168
+ return yield* new CliError.ShowHelp({
169
+ commandPath: [COMMAND_NAME],
170
+ errors: [new CliError.UserError({
171
+ cause: /* @__PURE__ */ new Error(message),
172
+ userMessage: message
173
+ })]
174
+ });
31
175
  }
32
- };
176
+ if (input !== void 0 && output === void 0) {
177
+ const message = "<input> requires -o <output.ts>.";
178
+ return yield* new CliError.ShowHelp({
179
+ commandPath: [COMMAND_NAME],
180
+ errors: [new CliError.UserError({
181
+ cause: /* @__PURE__ */ new Error(message),
182
+ userMessage: message
183
+ })]
184
+ });
185
+ }
186
+ if (output !== void 0 && input === void 0) {
187
+ const message = "-o <output.ts> requires an <input> document.";
188
+ return yield* new CliError.ShowHelp({
189
+ commandPath: [COMMAND_NAME],
190
+ errors: [new CliError.UserError({
191
+ cause: /* @__PURE__ */ new Error(message),
192
+ userMessage: message
193
+ })]
194
+ });
195
+ }
196
+ if (args.watch && (input !== void 0 || output !== void 0)) {
197
+ const message = "--watch runs a config file, so it cannot be combined with <input> or --output.";
198
+ return yield* new CliError.ShowHelp({
199
+ commandPath: [COMMAND_NAME],
200
+ errors: [new CliError.UserError({
201
+ cause: /* @__PURE__ */ new Error(message),
202
+ userMessage: message
203
+ })]
204
+ });
205
+ }
206
+ if (input !== void 0 && output !== void 0) {
207
+ const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-CzAVsFDt.js").then((n) => n.t), import("./core-BdG_5KX8.js").then((n) => n.t)]));
208
+ return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output, ONE_SHOT_COMPONENTS));
209
+ }
210
+ const resolvedConfig = configPath ?? DEFAULT_CONFIG_FILE;
211
+ if (args.watch) return yield* watchConfig(resolvedConfig, yield* reportConfigPass(resolvedConfig, false));
212
+ const first = yield* runConfigPass(resolvedConfig, false).pipe(Effect.mapError((error) => configPath === void 0 && error._tag === "ConfigError" && error.notFound === true ? new CliError.ShowHelp({
213
+ commandPath: [COMMAND_NAME],
214
+ errors: [new CliError.UserError({
215
+ cause: error,
216
+ userMessage: error.message
217
+ })]
218
+ }) : error));
219
+ yield* Console.log(first.report);
220
+ }).pipe(Effect.mapError((error) => CliError.isCliError(error) ? error : new CliError.UserError({
221
+ cause: error,
222
+ userMessage: error.message
223
+ })));
33
224
  }
34
- async function honoTakibi() {
35
- const args = process.argv.slice(2);
36
- if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) return {
37
- ok: true,
38
- value: HELP_TEXT
39
- };
40
- const abs = resolve(process.cwd(), "hono-takibi.config.ts");
41
- if (!existsSync(abs)) {
42
- const cliResult = parseCli(args);
43
- if (!cliResult.ok) return {
44
- ok: false,
45
- error: cliResult.error
46
- };
47
- const { input, output } = cliResult.value;
48
- const openAPIResult = await parseOpenAPI(input);
49
- if (!openAPIResult.ok) return {
50
- ok: false,
51
- error: openAPIResult.error
52
- };
53
- const openAPI = openAPIResult.value;
54
- const takibiResult = await takibi(openAPI, output, {
55
- readonly: false,
56
- exportSchemas: false,
57
- exportSchemasTypes: false,
58
- exportResponses: false,
59
- exportParameters: false,
60
- exportParametersTypes: false,
61
- exportExamples: false,
62
- exportRequestBodies: false,
63
- exportHeaders: false,
64
- exportHeadersTypes: false,
65
- exportSecuritySchemes: false,
66
- exportLinks: false,
67
- exportCallbacks: false,
68
- exportPathItems: false,
69
- exportMediaTypes: false,
70
- exportMediaTypesTypes: false
71
- });
72
- if (!takibiResult.ok) return {
73
- ok: false,
74
- error: takibiResult.error
75
- };
76
- return {
77
- ok: true,
78
- value: takibiResult.value
79
- };
225
+ /**
226
+ * The `hono-takibi` command: parsing, validation, `--help`, `--version` and shell
227
+ * completions are owned by `effect/unstable/cli`, {@link generate} is the rest.
228
+ */
229
+ const cli = Command.make(COMMAND_NAME, commandLine, generate).pipe(Command.withDescription("Generate @hono/zod-openapi code from OpenAPI or TypeSpec"), Command.withExamples([
230
+ {
231
+ command: "hono-takibi openapi.yaml -o src/routes.ts",
232
+ description: "Generate a single routes file"
233
+ },
234
+ {
235
+ command: "hono-takibi",
236
+ description: `Run every generator declared in ./${DEFAULT_CONFIG_FILE}`
237
+ },
238
+ {
239
+ command: "hono-takibi --config config/api.config.ts",
240
+ description: "Run a config file from another location"
241
+ },
242
+ {
243
+ command: "hono-takibi --watch",
244
+ description: "Rerun on every change to the input documents or the config"
80
245
  }
81
- const readConfigResult = await readConfig();
82
- if (!readConfigResult.ok) return {
83
- ok: false,
84
- error: readConfigResult.error
85
- };
86
- const config = readConfigResult.value;
87
- if (config.format) setFormatOptions(config.format);
88
- const openAPIResult = await parseOpenAPI(config.input);
89
- if (!openAPIResult.ok) return {
90
- ok: false,
91
- error: openAPIResult.error
92
- };
93
- const openAPI = openAPIResult.value;
94
- const jobs = makeJob(openAPI, config);
95
- const results = await Promise.all(jobs.map((job) => job.run(job.output)));
96
- const e = results.find((result) => !result.ok);
97
- if (e) return e;
98
- return {
99
- ok: true,
100
- value: results.map((result) => result.ok ? result.value : "").filter((v) => v !== "").join("\n")
101
- };
246
+ ]));
247
+ /**
248
+ * Runs `hono-takibi` against an argument list.
249
+ *
250
+ * `entryUrl` is the `import.meta.url` of the executable, and `--version` is read from the
251
+ * `package.json` beside it. The entry has to supply that: it is the only module whose
252
+ * depth is the same in source and in the bundle (`src/index.ts` and the `dist/cli.js` it
253
+ * is packed into both sit one directory below the manifest), so a relative URL written
254
+ * anywhere else resolves to two different files.
255
+ *
256
+ * A manifest that is missing or malformed is a broken install, so it fails rather than
257
+ * reporting a placeholder version — but through the error channel, which prints a
258
+ * sentence instead of an unhandled `SchemaError` and its whole AST.
259
+ */
260
+ function honoTakibi(argv, entryUrl) {
261
+ return Effect.gen(function* () {
262
+ const manifestPath = fileURLToPath(new URL("../package.json", entryUrl));
263
+ const source = yield* (yield* FileSystem.FileSystem).readFileString(manifestPath);
264
+ const manifest = yield* Effect.try({
265
+ try: () => JSON.parse(source),
266
+ catch: (cause) => new Error(`${manifestPath} is not valid JSON`, { cause })
267
+ });
268
+ const { version } = yield* Schema.decodeUnknownEffect(Schema.Struct({ version: Schema.String }))(manifest);
269
+ return yield* Command.runWith(cli, { version })(argv);
270
+ }).pipe(Effect.catchIf((error) => !CliError.isCliError(error), reportBrokenInstall));
271
+ }
272
+ /**
273
+ * The version could not be read: the manifest beside the entry is missing, is not JSON,
274
+ * or carries no `version`. That is a broken install, not anything the caller typed.
275
+ *
276
+ * `Command.runWith` renders the errors raised inside the command, but this one is raised
277
+ * before it runs. So it is rendered here through the same formatter — the `ERROR` block
278
+ * every other failure prints — and marked as already reported, so `runMain` does not
279
+ * print it a second time in its own shape.
280
+ */
281
+ function reportBrokenInstall(cause) {
282
+ return Effect.gen(function* () {
283
+ const error = new CliError.UserError({
284
+ cause,
285
+ userMessage: `Cannot read the version from package.json: ${cause.message}`
286
+ });
287
+ error[Runtime.errorReported] = false;
288
+ const formatter = yield* CliOutput.Formatter;
289
+ yield* Console.error(formatter.formatError(error));
290
+ return yield* error;
291
+ });
102
292
  }
103
293
  //#endregion
104
294
  //#region src/index.ts
105
- honoTakibi().then((result) => {
106
- if (result.ok) {
107
- console.log(result.value);
108
- process.exit(0);
109
- } else {
110
- console.error(result.error);
111
- process.exit(1);
112
- }
113
- });
295
+ NodeRuntime.runMain(honoTakibi(process.argv.slice(2), import.meta.url).pipe(Effect.provide(NodeServices.layer)));
114
296
  //#endregion
115
297
  export {};
@@ -1,13 +1,6 @@
1
- import { t as OpenAPI } from "../../index-BDBsbJIq.js";
1
+ import { t as OpenAPI } from "../../index-B2QvGO4j.js";
2
+ import { Effect } from "effect";
2
3
  //#region src/core/docs/index.d.ts
3
- declare function docs(openAPI: OpenAPI, output: string, entry?: string, basePath?: string, curl?: boolean, baseUrl?: string): Promise<{
4
- readonly value?: never;
5
- readonly ok: false;
6
- readonly error: string;
7
- } | {
8
- readonly error?: never;
9
- readonly ok: true;
10
- readonly value: `Generated docs written to ${string}`;
11
- }>;
4
+ declare function docs(openAPI: OpenAPI, output: string, entry?: string, basePath?: string, curl?: boolean, baseUrl?: string): Effect.Effect<string, import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
12
5
  //#endregion
13
6
  export { docs };
@@ -1,2 +1,2 @@
1
- import { t as docs } from "../../docs-D0ZoEuTk.js";
1
+ import { t as docs } from "../../docs-MzhmjfNS.js";
2
2
  export { docs };
@@ -1,4 +1,6 @@
1
- import { t as OpenAPI } from "../../index-BDBsbJIq.js";
1
+ import { t as OpenAPI } from "../../index-B2QvGO4j.js";
2
+ import { t as FormatError } from "../../index-wD0wV6VQ.js";
3
+ import { t as GenerateError } from "../../index-6-_xlYFY.js";
2
4
  //#region src/core/hooks/index.d.ts
3
5
  declare const HOOK_CONFIGS: {
4
6
  readonly swr: {
@@ -57,12 +59,14 @@ declare const HOOK_CONFIGS: {
57
59
  readonly queryFn: 'createQuery';
58
60
  readonly mutationFn: 'createMutation';
59
61
  readonly useThunk: true;
60
- readonly useQueryOptionsType: 'CreateQueryOptions';
62
+ readonly useQueryOptionsType: 'UndefinedInitialDataOptions';
61
63
  readonly useMutationOptionsType: 'CreateMutationOptions';
62
64
  readonly hasQueryOptionsHelper: true;
65
+ readonly hasMutationOptionsHelper: true;
63
66
  readonly infiniteQueryFn: 'createInfiniteQuery';
64
- readonly useInfiniteQueryOptionsType: 'CreateInfiniteQueryOptions';
67
+ readonly useInfiniteQueryOptionsType: 'UndefinedInitialDataInfiniteOptions';
65
68
  readonly hasInfiniteQueryOptionsHelper: true;
69
+ readonly unwrapOptionsAccessor: true;
66
70
  };
67
71
  readonly 'vue-query': {
68
72
  readonly packageName: '@tanstack/vue-query';
@@ -72,6 +76,7 @@ declare const HOOK_CONFIGS: {
72
76
  readonly mutationFn: 'useMutation';
73
77
  readonly useQueryOptionsType: 'UseQueryOptions';
74
78
  readonly useMutationOptionsType: 'UseMutationOptions';
79
+ readonly hasMutationOptionsHelper: true;
75
80
  readonly isVueQuery: true;
76
81
  readonly infiniteQueryFn: 'useInfiniteQuery';
77
82
  readonly useInfiniteQueryOptionsType: 'UseInfiniteQueryOptions';
@@ -109,13 +114,6 @@ declare const HOOK_CONFIGS: {
109
114
  declare function hooks(openAPI: OpenAPI, output: string, importPath: string, library: keyof typeof HOOK_CONFIGS, options?: {
110
115
  readonly split?: boolean;
111
116
  readonly clientName?: string;
112
- }): Promise<{
113
- readonly value?: never;
114
- readonly ok: false;
115
- readonly error: string;
116
- } | {
117
- readonly ok: true;
118
- readonly value: `Generated ${string} hooks written to ${string}`;
119
- }>;
117
+ }): import("effect/Effect").Effect<string, FormatError | GenerateError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
120
118
  //#endregion
121
119
  export { hooks };
@@ -1,2 +1,2 @@
1
- import { t as hooks } from "../../hooks-BMBBxGkd.js";
1
+ import { t as hooks } from "../../hooks-iffNFEYy.js";
2
2
  export { hooks };
@@ -1,25 +1,11 @@
1
- import { t as OpenAPI } from "../../index-BDBsbJIq.js";
1
+ import { t as OpenAPI } from "../../index-B2QvGO4j.js";
2
+ import { t as FormatError } from "../../index-wD0wV6VQ.js";
3
+ import { t as GenerateError } from "../../index-6-_xlYFY.js";
4
+ import { Effect } from "effect";
2
5
  //#region src/core/rpc/index.d.ts
3
6
  /**
4
7
  * Generates RPC client wrapper functions from OpenAPI specification.
5
- *
6
- * @param openAPI - Parsed OpenAPI specification
7
- * @param output - Output file path or directory
8
- * @param importPath - Import path for the Hono client
9
- * @param split - Whether to split into multiple files (one per operation)
10
- * @param clientName - Name of the client export (default: 'client')
11
- * @param useParseResponse - Whether to wrap calls with parseResponse
12
- * @param basePath - Base path for the app (e.g. '/api')
13
- * @param docs - When true, prepend operation summary/description as JSDoc
14
- * @returns Promise resolving to success message or error
15
8
  */
16
- declare function rpc(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string, useParseResponse?: boolean, basePath?: string, docs?: boolean): Promise<{
17
- readonly value?: never;
18
- readonly ok: false;
19
- readonly error: string;
20
- } | {
21
- readonly ok: true;
22
- readonly value: `Generated rpc code written to ${string}`;
23
- }>;
9
+ declare function rpc(openAPI: OpenAPI, output: string, importPath: string, split?: boolean, clientName?: string, useParseResponse?: boolean, basePath?: string, docs?: boolean): Effect.Effect<string, FormatError | GenerateError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
24
10
  //#endregion
25
11
  export { rpc };