hono-takibi 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,7 +50,7 @@ npx hono-takibi
50
50
 
51
51
  ```
52
52
  DESCRIPTION
53
- Generate @hono/zod-openapi code from OpenAPI or TypeSpec
53
+ Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi
54
54
 
55
55
  USAGE
56
56
  hono-takibi [flags] [<input>]
@@ -293,9 +293,8 @@ Supported: SWR, TanStack Query, Preact Query, Solid Query, Vue Query, Svelte Que
293
293
  export default defineConfig({
294
294
  input: 'openapi.yaml',
295
295
  'tanstack-query': {
296
- output: './src/tanstack-query',
296
+ output: './src/tanstack-query.ts',
297
297
  import: '../lib',
298
- split: true,
299
298
  client: 'client',
300
299
  },
301
300
  })
@@ -401,10 +400,12 @@ export default defineConfig({
401
400
 
402
401
  Some options are mutually exclusive: `output` ↔ `routes`, `template.define` ↔ `routes`, `components.output` ↔ per-type components, `template.define` ↔ `routeHandler`.
403
402
 
404
- Every generator needs its own `output` path, and a `split` directory belongs to the
405
- generator — its `.ts` files are removed before each run, so keep hand-written code
406
- elsewhere. `basePath`, `client` and `import` are checked here because they are spliced
407
- into the generated code verbatim.
403
+ Every generator needs its own `output` path. `routes`, `webhooks` and the
404
+ `components.*` sections take `split`, and a split directory belongs to the generator —
405
+ its `.ts` files are removed before each run, so keep hand-written code elsewhere. Every
406
+ other generator, `rpc` and the client hooks included, writes a single file. `basePath`,
407
+ `client` and `import` are checked here because they are spliced into the generated code
408
+ verbatim.
408
409
 
409
410
  ```ts
410
411
  import { defineConfig } from 'hono-takibi'
@@ -525,54 +526,46 @@ export default defineConfig({
525
526
  },
526
527
 
527
528
  rpc: {
528
- output: './src/rpc',
529
+ output: './src/rpc.ts',
529
530
  import: '../lib',
530
- split: true,
531
531
  client: 'client',
532
532
  parseResponse: true,
533
533
  docs: false, // operation summary/description as JSDoc
534
534
  },
535
535
 
536
536
  swr: {
537
- output: './src/swr',
537
+ output: './src/swr.ts',
538
538
  import: '../lib',
539
- split: true,
540
539
  client: 'client',
541
540
  },
542
541
  'tanstack-query': {
543
- output: './src/tanstack-query',
542
+ output: './src/tanstack-query.ts',
544
543
  import: '../lib',
545
- split: true,
546
544
  client: 'client',
547
545
  },
548
546
  'preact-query': {
549
- output: './src/preact-query',
547
+ output: './src/preact-query.ts',
550
548
  import: '../lib',
551
- split: true,
552
549
  client: 'client',
553
550
  },
554
551
  'solid-query': {
555
- output: './src/solid-query',
552
+ output: './src/solid-query.ts',
556
553
  import: '../lib',
557
- split: true,
558
554
  client: 'client',
559
555
  },
560
556
  'vue-query': {
561
- output: './src/vue-query',
557
+ output: './src/vue-query.ts',
562
558
  import: '../lib',
563
- split: true,
564
559
  client: 'client',
565
560
  },
566
561
  'svelte-query': {
567
- output: './src/svelte-query',
562
+ output: './src/svelte-query.ts',
568
563
  import: '../lib',
569
- split: true,
570
564
  client: 'client',
571
565
  },
572
566
  'angular-query': {
573
- output: './src/angular-query',
567
+ output: './src/angular-query.ts',
574
568
  import: '../lib',
575
- split: true,
576
569
  client: 'client',
577
570
  },
578
571
 
package/dist/cli.js CHANGED
@@ -13,39 +13,29 @@ const DocumentPathSchema = Schema.String.pipe(Schema.refine(Schema.is(Schema.Tem
13
13
  ".yaml",
14
14
  ".json",
15
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
- };
16
+ ])])), { message: "an OpenAPI (.yaml, .json) or TypeSpec (.tsp) document" })).annotate({
17
+ title: "Input document",
18
+ description: "OpenAPI or TypeSpec document the one-shot mode generates from.",
19
+ examples: [
20
+ "openapi.yaml",
21
+ "./spec/openapi.json",
22
+ "./spec/main.tsp"
23
+ ]
24
+ });
25
+ const TypeScriptPathSchema = Schema.String.pipe(Schema.refine(Schema.is(Schema.TemplateLiteral([Schema.String, ".ts"])), { message: "a TypeScript file path ending in .ts" })).annotate({
26
+ title: "Routes output file",
27
+ description: "TypeScript file the one-shot mode writes the generated routes to.",
28
+ examples: ["./src/routes.ts", "src/api/routes.ts"]
29
+ });
40
30
  /**
41
31
  * The command line itself: what `hono-takibi` accepts, what each piece means, and the
42
32
  * schema every value is decoded through before {@link generate} ever sees it.
43
33
  */
44
34
  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))
35
+ 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),
36
+ 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),
37
+ 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),
38
+ 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
39
  };
50
40
  /** Extensions a change has to carry to be worth regenerating for. */
51
41
  const INPUT_EXTENSIONS = [
@@ -71,7 +61,7 @@ function runConfigPass(configPath, reload) {
71
61
  import("./index.js"),
72
62
  import("./openapi-DQRxq2_O.js").then((n) => n.t),
73
63
  import("./format-Bm9LZ_ki.js").then((n) => n.r),
74
- import("./shared-CHGm83qW.js").then((n) => n.i)
64
+ import("./shared-BTyk3wSO.js").then((n) => n.i)
75
65
  ]));
76
66
  const config = yield* readConfig(configPath, reload);
77
67
  const jobs = makeJob(yield* parseOpenAPI(config.input), config);
@@ -163,49 +153,22 @@ function generate(args) {
163
153
  const input = Option.getOrUndefined(args.input);
164
154
  const output = Option.getOrUndefined(args.output);
165
155
  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
- });
175
- }
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
- }
156
+ const conflict = [
157
+ [configPath !== void 0 && (input !== void 0 || output !== void 0), "--config cannot be combined with <input> or --output. A config file already names its own input and outputs."],
158
+ [input !== void 0 && output === void 0, "<input> requires -o <output.ts>."],
159
+ [output !== void 0 && input === void 0, "-o <output.ts> requires an <input> document."],
160
+ [args.watch && (input !== void 0 || output !== void 0), "--watch runs a config file, so it cannot be combined with <input> or --output."]
161
+ ].find(([rejected]) => rejected)?.[1];
162
+ if (conflict !== void 0) return yield* new CliError.ShowHelp({
163
+ commandPath: [COMMAND_NAME],
164
+ errors: [new CliError.UserError({
165
+ cause: new Error(conflict),
166
+ userMessage: conflict
167
+ })]
168
+ });
206
169
  if (input !== void 0 && output !== void 0) {
207
- const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-Binj-uPh.js").then((n) => n.t)]));
208
- return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output, ONE_SHOT_COMPONENTS));
170
+ const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-Zb9XMy-3.js").then((n) => n.t)]));
171
+ return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output));
209
172
  }
210
173
  const resolvedConfig = configPath ?? DEFAULT_CONFIG_FILE;
211
174
  if (args.watch) return yield* watchConfig(resolvedConfig, yield* reportConfigPass(resolvedConfig, false));
@@ -225,53 +188,34 @@ function generate(args) {
225
188
  /**
226
189
  * The `hono-takibi` command: parsing, validation, `--help`, `--version` and shell
227
190
  * 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"
245
- }
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
191
  *
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.
192
+ * `description` is the manifest's, so the sentence `--help` prints and the one npm shows
193
+ * cannot drift apart — {@link honoTakibi} is already reading that file for `--version`.
259
194
  */
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));
195
+ function makeCli(description) {
196
+ return Command.make(COMMAND_NAME, commandLine, generate).pipe(Command.withDescription(description), Command.withExamples([
197
+ {
198
+ command: "hono-takibi openapi.yaml -o src/routes.ts",
199
+ description: "Generate a single routes file"
200
+ },
201
+ {
202
+ command: "hono-takibi",
203
+ description: `Run every generator declared in ./${DEFAULT_CONFIG_FILE}`
204
+ },
205
+ {
206
+ command: "hono-takibi --config config/api.config.ts",
207
+ description: "Run a config file from another location"
208
+ },
209
+ {
210
+ command: "hono-takibi --watch",
211
+ description: "Rerun on every change to the input documents or the config"
212
+ }
213
+ ]));
271
214
  }
272
215
  /**
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.
216
+ * The manifest could not be read: the `package.json` beside the entry is missing, is not
217
+ * JSON, or carries no `version` / `description`. That is a broken install, not anything
218
+ * the caller typed.
275
219
  *
276
220
  * `Command.runWith` renders the errors raised inside the command, but this one is raised
277
221
  * before it runs. So it is rendered here through the same formatter — the `ERROR` block
@@ -282,7 +226,7 @@ function reportBrokenInstall(cause) {
282
226
  return Effect.gen(function* () {
283
227
  const error = new CliError.UserError({
284
228
  cause,
285
- userMessage: `Cannot read the version from package.json: ${cause.message}`
229
+ userMessage: `Cannot read the version and description from package.json: ${cause.message}`
286
230
  });
287
231
  error[Runtime.errorReported] = false;
288
232
  const formatter = yield* CliOutput.Formatter;
@@ -290,6 +234,45 @@ function reportBrokenInstall(cause) {
290
234
  return yield* error;
291
235
  });
292
236
  }
237
+ /**
238
+ * Runs `hono-takibi` against an argument list.
239
+ *
240
+ * `entryUrl` is the `import.meta.url` of the executable, and both `--version` and the
241
+ * description `--help` prints are read from the `package.json` beside it. The entry has
242
+ * to supply that URL: it is the only module whose
243
+ * depth is the same in source and in the bundle (`src/index.ts` and the `dist/cli.js` it
244
+ * is packed into both sit one directory below the manifest), so a relative URL written
245
+ * anywhere else resolves to two different files.
246
+ *
247
+ * A manifest that is missing or malformed is a broken install, so it fails rather than
248
+ * reporting a placeholder version — but through the error channel, which prints a
249
+ * sentence instead of an unhandled `SchemaError` and its whole AST. One `Schema.Struct`
250
+ * is what says which fields have to be there for the command to describe itself.
251
+ */
252
+ function honoTakibi(argv, entryUrl) {
253
+ return Effect.gen(function* () {
254
+ const manifestPath = fileURLToPath(new URL("../package.json", entryUrl));
255
+ const source = yield* (yield* FileSystem.FileSystem).readFileString(manifestPath);
256
+ const manifest = yield* Effect.try({
257
+ try: () => JSON.parse(source),
258
+ catch: (cause) => new Error(`${manifestPath} is not valid JSON`, { cause })
259
+ });
260
+ const { version, description } = yield* Schema.decodeUnknownEffect(Schema.Struct({
261
+ version: Schema.String.annotate({
262
+ description: "What `--version` prints.",
263
+ examples: ["1.2.3"]
264
+ }),
265
+ description: Schema.String.annotate({
266
+ description: "The sentence `--help` prints under DESCRIPTION.",
267
+ examples: ["Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi"]
268
+ })
269
+ }).annotate({
270
+ title: "Package manifest",
271
+ description: "The fields `hono-takibi` reads from the package.json beside its entry."
272
+ }))(manifest);
273
+ return yield* Command.runWith(makeCli(description), { version })(argv);
274
+ }).pipe(Effect.catchIf((error) => !CliError.isCliError(error), reportBrokenInstall));
275
+ }
293
276
  //#endregion
294
277
  //#region src/index.ts
295
278
  NodeRuntime.runMain(honoTakibi(process.argv.slice(2), import.meta.url).pipe(Effect.provide(NodeServices.layer)));
@@ -1,6 +1,5 @@
1
- import { t as OpenAPI } from "../../index-Dw-w92xu.js";
1
+ import { t as OpenAPI } from "../../index-tsPqeV6H.js";
2
2
  import { Effect } from "effect";
3
3
  //#region src/core/docs/index.d.ts
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>;
5
- //#endregion
6
- export { docs };
4
+ export 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>;
5
+ //#endregion
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-Dw-w92xu.js";
1
+ import { t as OpenAPI } from "../../index-tsPqeV6H.js";
2
2
  import { t as FormatError } from "../../index-wD0wV6VQ.js";
3
3
  import { t as GenerateError } from "../../index-6-_xlYFY.js";
4
4
  //#region src/core/hooks/index.d.ts
@@ -160,9 +160,9 @@ declare const HOOK_CONFIGS: {
160
160
  readonly useThunk: true;
161
161
  };
162
162
  };
163
- declare function hooks(openAPI: OpenAPI, output: string, importPath: string, library: keyof typeof HOOK_CONFIGS, options?: {
164
- readonly split?: boolean;
163
+ /** The client libraries `hooks` can generate for, named so a caller can hold one. */
164
+ export type HookLibrary = keyof typeof HOOK_CONFIGS;
165
+ export declare function hooks(openAPI: OpenAPI, output: string, importPath: string, library: HookLibrary, options?: {
165
166
  readonly clientName?: string;
166
167
  }): import("effect/Effect").Effect<string, FormatError | GenerateError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
167
- //#endregion
168
- export { hooks };
168
+ //#endregion
@@ -1,2 +1,2 @@
1
- import { t as hooks } from "../../hooks-DI1jbIMJ.js";
1
+ import { t as hooks } from "../../hooks-kkOg8Baa.js";
2
2
  export { hooks };
@@ -1,4 +1,4 @@
1
- import { t as OpenAPI } from "../../index-Dw-w92xu.js";
1
+ import { t as OpenAPI } from "../../index-tsPqeV6H.js";
2
2
  import { t as FormatError } from "../../index-wD0wV6VQ.js";
3
3
  import { t as GenerateError } from "../../index-6-_xlYFY.js";
4
4
  import { Effect } from "effect";
@@ -6,6 +6,5 @@ import { Effect } from "effect";
6
6
  /**
7
7
  * Generates RPC client wrapper functions from OpenAPI specification.
8
8
  */
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>;
10
- //#endregion
11
- export { rpc };
9
+ export declare function rpc(openAPI: OpenAPI, output: string, importPath: string, clientName?: string, useParseResponse?: boolean, basePath?: string, docs?: boolean): Effect.Effect<string, FormatError | GenerateError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
10
+ //#endregion
@@ -1,8 +1,8 @@
1
1
  import { f as methodPath, j as isOperationLike, k as isOpenAPIPaths, l as makeInferRequestType, z as isRecord } from "../../utils-BtWoIX8v.js";
2
2
  import { t as emit } from "../../emit-B_3fXoto.js";
3
- import { a as parsePathItem, i as operationHasArgs, o as resolveSplitOutDir, r as makeOperationDeps, s as GenerateError, t as formatPath } from "../../rpc-C_Lq1F7-.js";
3
+ import { a as parsePathItem, i as operationHasArgs, o as GenerateError, r as makeOperationDeps, t as formatPath } from "../../rpc-CQFRTmcC.js";
4
4
  import { Effect } from "effect";
5
- import { dirname, join } from "node:path";
5
+ import { dirname } from "node:path";
6
6
  //#region src/core/rpc/index.ts
7
7
  /**
8
8
  * Builds a JSDoc block from operation `summary` / `description` plus the HTTP route line.
@@ -47,14 +47,7 @@ function makeOperationCodes(paths, deps, useParseResponse, hasBasePath, docs) {
47
47
  "patch",
48
48
  "trace",
49
49
  "query"
50
- ].map((method) => {
51
- const result = makeOperationCode(p, method, pathItem, deps, useParseResponse, hasBasePath, docs);
52
- return result ? {
53
- funcName: methodPath(method, p),
54
- code: result.code,
55
- hasArgs: result.hasArgs
56
- } : null;
57
- }).filter((item) => item !== null);
50
+ ].map((method) => makeOperationCode(p, method, pathItem, deps, useParseResponse, hasBasePath, docs)).filter((item) => item !== null);
58
51
  });
59
52
  }
60
53
  function makeHeader(importPath, needsInferRequestType, clientName, useParseResponse) {
@@ -63,7 +56,7 @@ function makeHeader(importPath, needsInferRequestType, clientName, useParseRespo
63
56
  /**
64
57
  * Generates RPC client wrapper functions from OpenAPI specification.
65
58
  */
66
- function rpc(openAPI, output, importPath, split, clientName = "client", useParseResponse, basePath, docs) {
59
+ function rpc(openAPI, output, importPath, clientName = "client", useParseResponse, basePath, docs) {
67
60
  return Effect.gen(function* () {
68
61
  const paths = openAPI.paths;
69
62
  if (!isOpenAPIPaths(paths)) return yield* new GenerateError({ message: "Invalid OpenAPI paths" });
@@ -71,20 +64,10 @@ function rpc(openAPI, output, importPath, split, clientName = "client", useParse
71
64
  const componentsParameters = openAPI.components?.parameters ?? {};
72
65
  const componentsRequestBodies = openAPI.components?.requestBodies ?? {};
73
66
  const operationCodes = makeOperationCodes(paths, makeOperationDeps(clientName, componentsParameters, componentsRequestBodies), useParseResponse, hasBasePath, docs);
74
- if (!split) {
75
- const body = operationCodes.map(({ code }) => code).join("\n\n");
76
- const code = `${makeHeader(importPath, operationCodes.some(({ hasArgs }) => hasArgs), clientName, useParseResponse)}${body}${operationCodes.length > 0 ? "\n" : ""}`;
77
- yield* emit(code, dirname(output), output);
78
- return `Generated rpc code written to ${output}`;
79
- }
80
- const { outDir, indexPath } = resolveSplitOutDir(output);
81
- const index = `${[...new Set(operationCodes.map(({ funcName }) => `export * from './${funcName}'`))].join("\n")}\n`;
82
- yield* Effect.all([...operationCodes.map(({ funcName, code, hasArgs }) => {
83
- const fileSrc = `${makeHeader(importPath, hasArgs, clientName, useParseResponse)}${code}\n`;
84
- const filePath = join(outDir, `${funcName}.ts`);
85
- return emit(fileSrc, dirname(filePath), filePath);
86
- }), emit(index, dirname(indexPath), indexPath)], { concurrency: "unbounded" });
87
- return `Generated rpc code written to ${outDir}/*.ts (index.ts included)`;
67
+ const body = operationCodes.map(({ code }) => code).join("\n\n");
68
+ const code = `${makeHeader(importPath, operationCodes.some(({ hasArgs }) => hasArgs), clientName, useParseResponse)}${body}${operationCodes.length > 0 ? "\n" : ""}`;
69
+ yield* emit(code, dirname(output), output);
70
+ return `Generated rpc code written to ${output}`;
88
71
  });
89
72
  }
90
73
  //#endregion
@@ -1,10 +1,9 @@
1
- import { t as OpenAPI } from "../../index-Dw-w92xu.js";
1
+ import { t as OpenAPI } from "../../index-tsPqeV6H.js";
2
2
  import { t as FormatError } from "../../index-wD0wV6VQ.js";
3
3
  import { Effect } from "effect";
4
4
  //#region src/core/type/index.d.ts
5
5
  /**
6
6
  * Generates TypeScript type declarations from OpenAPI specification.
7
7
  */
8
- declare function type(openAPI: OpenAPI, output: `${string}.ts`, readonly?: boolean): Effect.Effect<string, FormatError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
9
- //#endregion
10
- export { type };
8
+ export declare function type(openAPI: OpenAPI, output: `${string}.ts`, readonly?: boolean): Effect.Effect<string, FormatError | import("effect/PlatformError").PlatformError, import("effect/FileSystem").FileSystem>;
9
+ //#endregion
@@ -184,7 +184,7 @@ const PRIMITIVE_TYPE_MAP = {
184
184
  };
185
185
  function makeSingleTypeString(schema, type, components, visited) {
186
186
  if (type === "string") return schema.format === "binary" ? "File" : "string";
187
- if (type === "number" || type === "integer") return schema.format === "int64" || schema.format === "bigint" ? "bigint" : "number";
187
+ if (type === "number" || type === "integer") return schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint" ? "bigint" : "number";
188
188
  if (type === "array") return makeArrayTypeString(schema, components, visited);
189
189
  if (type === "object") return makeObjectTypeString(schema, components, visited);
190
190
  return PRIMITIVE_TYPE_MAP[type] ?? "unknown";
@@ -3,9 +3,9 @@ import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-
3
3
  import { n as fmt } from "./format-Bm9LZ_ki.js";
4
4
  import { A as isOperation, B as isRefObject, D as isMediaWithSchema, F as isParameterRef, G as isSchemaObject, I as isPathItem, J as isSecurityScheme, L as isPathItemEntry, M as isParameter, R as isPathItemRef, S as isContentBody, T as isHttpMethod, W as isSchemaArray, _ as toIdentifierPascalCase, b as zodToOpenAPISchema, c as makeBarrel, d as makeStringLiteral, f as methodPath, g as statusCodeToNumber, i as ensureSuffix, m as renderNamedImport, p as normalizeTypes, q as isSecurityArray, r as cyclicNodes, u as makeSafeKey, v as uncapitalize, x as isCallbacks, y as uncapitalizeWord } from "./utils-BtWoIX8v.js";
5
5
  import { t as emit } from "./emit-B_3fXoto.js";
6
- import { s as GenerateError } from "./rpc-C_Lq1F7-.js";
7
- import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-4tjo-yX9.js";
8
- import { t as hooks } from "./hooks-DI1jbIMJ.js";
6
+ import { o as GenerateError } from "./rpc-CQFRTmcC.js";
7
+ import { S as makeModuleSpec, _ as makeRef, a as responsesCode, b as makeExportConst, c as headersCode, d as ast, f as zodToOpenAPI, g as makePathItem, h as makeOperationResponses, i as schemasCode, l as makeSplitSchemaFile, m as makeCallbacks, n as routeCode, o as requestBodiesCode, p as makeCallback, r as componentsCode, s as parametersCode, t as zodOpenAPIHono, u as analyzeCircularSchemas, v as makeRequest, x as makeImports, y as makeConst } from "./openapi-CK1nn2RJ.js";
8
+ import { t as hooks } from "./hooks-kkOg8Baa.js";
9
9
  import { t as docs } from "./docs-Bo4-6xBy.js";
10
10
  import { rpc } from "./core/rpc/index.js";
11
11
  import { type } from "./core/type/index.js";
@@ -41,6 +41,8 @@ const FORMAT_TO_FAKER = {
41
41
  byte: "btoa(faker.string.alphanumeric(10))",
42
42
  int32: "faker.number.int({ min: -2147483648, max: 2147483647 })",
43
43
  int64: "faker.number.bigInt({ min: 0n, max: 9007199254740991n })",
44
+ uint32: "faker.number.int({ min: 0, max: 4294967295 })",
45
+ uint64: "faker.number.bigInt({ min: 0n, max: 9007199254740991n })",
44
46
  bigint: "faker.number.bigInt({ min: 0n, max: 9007199254740991n })",
45
47
  float: "faker.number.float({ min: 0, max: 1000, fractionDigits: 2 })",
46
48
  double: "faker.number.float({ min: 0, max: 1000000, fractionDigits: 4 })",
@@ -63,6 +65,10 @@ const FORMAT_TO_FAKER = {
63
65
  duration: "`P${faker.number.int({ min: 1, max: 30 })}D`",
64
66
  e164: "faker.phone.number({ style: 'international' })",
65
67
  httpUrl: "faker.internet.url()",
68
+ creditCard: "faker.finance.creditCardNumber()",
69
+ currencyCode: "faker.helpers.arrayElement(['USD', 'EUR', 'JPY', 'GBP'])",
70
+ ksuid: "faker.string.alphanumeric(27)",
71
+ xid: "faker.string.fromCharacters('0123456789abcdefghijklmnopqrstuv', 20)",
66
72
  "uri-reference": "faker.internet.url()",
67
73
  iri: "faker.internet.url()",
68
74
  "iri-reference": "faker.internet.url()",
@@ -173,7 +179,7 @@ function exampleLiteral(schema) {
173
179
  return `${JSON.stringify(example)}${asConst}`;
174
180
  }
175
181
  if (typeof example === "number") {
176
- if (types.includes("integer") && (schema.format === "int64" || schema.format === "bigint")) return Number.isInteger(example) ? `${BigInt(example)}n` : void 0;
182
+ if (types.includes("integer") && (schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint")) return Number.isInteger(example) ? `${BigInt(example)}n` : void 0;
177
183
  if (!(isAccepted("number") || isAccepted("integer"))) return void 0;
178
184
  if (!(isAccepted("number") || Number.isInteger(example))) return void 0;
179
185
  return `${JSON.stringify(example)}${asConst}`;
@@ -194,7 +200,7 @@ function numericRange(schema, integer) {
194
200
  };
195
201
  }
196
202
  function numericFaker(schema, range) {
197
- if (schema.type === "integer" && (schema.format === "int64" || schema.format === "bigint")) return `faker.number.bigInt({ min: ${range.min ?? 0}n, max: ${range.max ?? 9007199254740991}n })`;
203
+ if (schema.type === "integer" && (schema.format === "int64" || schema.format === "uint64" || schema.format === "bigint")) return `faker.number.bigInt({ min: ${range.min ?? 0}n, max: ${range.max ?? 9007199254740991}n })`;
198
204
  if (schema.type === "integer") {
199
205
  const defaultMin = schema.format === "int32" ? -2147483648 : 1;
200
206
  const defaultMax = schema.format === "int32" ? 2147483647 : 1e3;
@@ -1215,7 +1221,7 @@ function route(openAPI, routes, components, readonly) {
1215
1221
  }
1216
1222
  //#endregion
1217
1223
  //#region src/core/takibi/index.ts
1218
- function takibi(openAPI, output, componentsOptions) {
1224
+ function takibi(openAPI, output, componentsOptions = {}) {
1219
1225
  return Effect.gen(function* () {
1220
1226
  yield* emit(zodOpenAPIHono(openAPI, componentsOptions), path.dirname(output), output);
1221
1227
  return `🔥 Generated code written to ${output}`;
@@ -1,22 +1,21 @@
1
- import { t as OpenAPI } from "../../../index-Dw-w92xu.js";
1
+ import { t as OpenAPI } from "../../../index-tsPqeV6H.js";
2
2
  //#region src/generator/zod-openapi-hono/openapi/index.d.ts
3
- declare function zodOpenAPIHono(openapi: OpenAPI, options: {
3
+ export declare function zodOpenAPIHono(openapi: OpenAPI, options?: {
4
4
  readonly readonly?: boolean;
5
- readonly exportSchemas: boolean;
6
- readonly exportSchemasTypes: boolean;
7
- readonly exportResponses: boolean;
8
- readonly exportParameters: boolean;
9
- readonly exportParametersTypes: boolean;
10
- readonly exportExamples: boolean;
11
- readonly exportRequestBodies: boolean;
12
- readonly exportHeaders: boolean;
13
- readonly exportHeadersTypes: boolean;
14
- readonly exportSecuritySchemes: boolean;
15
- readonly exportLinks: boolean;
16
- readonly exportCallbacks: boolean;
17
- readonly exportPathItems: boolean;
18
- readonly exportMediaTypes: boolean;
19
- readonly exportMediaTypesTypes: boolean;
5
+ readonly exportSchemas?: boolean;
6
+ readonly exportSchemasTypes?: boolean;
7
+ readonly exportResponses?: boolean;
8
+ readonly exportParameters?: boolean;
9
+ readonly exportParametersTypes?: boolean;
10
+ readonly exportExamples?: boolean;
11
+ readonly exportRequestBodies?: boolean;
12
+ readonly exportHeaders?: boolean;
13
+ readonly exportHeadersTypes?: boolean;
14
+ readonly exportSecuritySchemes?: boolean;
15
+ readonly exportLinks?: boolean;
16
+ readonly exportCallbacks?: boolean;
17
+ readonly exportPathItems?: boolean;
18
+ readonly exportMediaTypes?: boolean;
19
+ readonly exportMediaTypesTypes?: boolean;
20
20
  }): string;
21
- //#endregion
22
- export { zodOpenAPIHono };
21
+ //#endregion
@@ -1,2 +1,2 @@
1
- import { t as zodOpenAPIHono } from "../../../openapi-4tjo-yX9.js";
1
+ import { t as zodOpenAPIHono } from "../../../openapi-CK1nn2RJ.js";
2
2
  export { zodOpenAPIHono };