hono-takibi 0.11.1 → 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
  })
@@ -327,6 +326,7 @@ usePostUsers({ mutation: { mutationKey: ['custom'], onSuccess } }, queryClient)
327
326
  ```
328
327
 
329
328
  - `options.query` is the library's options type without `queryKey` / `queryFn` (the hook supplies both); `options.mutation` leaves out `mutationFn`, and a `mutationKey` you pass wins over the generated one.
329
+ - Query hooks spread their options factory, so `useUsersId(args, { query })` is `useQuery({ ...getUsersIdQueryOptions(args), ...query })`. The factories take the hooks' `<TData, TError>` (and `TPageParam` for infinite queries) for that reason; leave them off and a direct `getUsersIdQueryOptions(args)` call keeps the default types, ready for `prefetchQuery` / `getQueryData`. Vue Query hooks keep the inline form instead.
330
330
  - `options.options` is Hono's `ClientRequestOptions` (headers, fetch, init).
331
331
  - The trailing argument is the framework's own: a `QueryClient` (an accessor of one in Solid and Svelte), or `{ injector }` in Angular.
332
332
  - Vue hooks accept `Ref` / getter arguments and re-key the query when they change.
@@ -400,10 +400,12 @@ export default defineConfig({
400
400
 
401
401
  Some options are mutually exclusive: `output` ↔ `routes`, `template.define` ↔ `routes`, `components.output` ↔ per-type components, `template.define` ↔ `routeHandler`.
402
402
 
403
- Every generator needs its own `output` path, and a `split` directory belongs to the
404
- generator — its `.ts` files are removed before each run, so keep hand-written code
405
- elsewhere. `basePath`, `client` and `import` are checked here because they are spliced
406
- 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.
407
409
 
408
410
  ```ts
409
411
  import { defineConfig } from 'hono-takibi'
@@ -524,54 +526,46 @@ export default defineConfig({
524
526
  },
525
527
 
526
528
  rpc: {
527
- output: './src/rpc',
529
+ output: './src/rpc.ts',
528
530
  import: '../lib',
529
- split: true,
530
531
  client: 'client',
531
532
  parseResponse: true,
532
533
  docs: false, // operation summary/description as JSDoc
533
534
  },
534
535
 
535
536
  swr: {
536
- output: './src/swr',
537
+ output: './src/swr.ts',
537
538
  import: '../lib',
538
- split: true,
539
539
  client: 'client',
540
540
  },
541
541
  'tanstack-query': {
542
- output: './src/tanstack-query',
542
+ output: './src/tanstack-query.ts',
543
543
  import: '../lib',
544
- split: true,
545
544
  client: 'client',
546
545
  },
547
546
  'preact-query': {
548
- output: './src/preact-query',
547
+ output: './src/preact-query.ts',
549
548
  import: '../lib',
550
- split: true,
551
549
  client: 'client',
552
550
  },
553
551
  'solid-query': {
554
- output: './src/solid-query',
552
+ output: './src/solid-query.ts',
555
553
  import: '../lib',
556
- split: true,
557
554
  client: 'client',
558
555
  },
559
556
  'vue-query': {
560
- output: './src/vue-query',
557
+ output: './src/vue-query.ts',
561
558
  import: '../lib',
562
- split: true,
563
559
  client: 'client',
564
560
  },
565
561
  'svelte-query': {
566
- output: './src/svelte-query',
562
+ output: './src/svelte-query.ts',
567
563
  import: '../lib',
568
- split: true,
569
564
  client: 'client',
570
565
  },
571
566
  'angular-query': {
572
- output: './src/angular-query',
567
+ output: './src/angular-query.ts',
573
568
  import: '../lib',
574
- split: true,
575
569
  client: 'client',
576
570
  },
577
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-BgsMAfDf.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-BtueRJN7.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,2 +1,2 @@
1
- import { t as docs } from "../../docs-C1_fNNJ-.js";
1
+ import { t as docs } from "../../docs-Bo4-6xBy.js";
2
2
  export { docs };
@@ -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-CZkcozjK.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
- import { f as methodPath, j as isOperationLike, k as isOpenAPIPaths, l as makeInferRequestType, z as isRecord } from "../../utils-DEFpxBMu.js";
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-D_eeOVGa.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.
@@ -45,15 +45,9 @@ function makeOperationCodes(paths, deps, useParseResponse, hasBasePath, docs) {
45
45
  "options",
46
46
  "head",
47
47
  "patch",
48
- "trace"
49
- ].map((method) => {
50
- const result = makeOperationCode(p, method, pathItem, deps, useParseResponse, hasBasePath, docs);
51
- return result ? {
52
- funcName: methodPath(method, p),
53
- code: result.code,
54
- hasArgs: result.hasArgs
55
- } : null;
56
- }).filter((item) => item !== null);
48
+ "trace",
49
+ "query"
50
+ ].map((method) => makeOperationCode(p, method, pathItem, deps, useParseResponse, hasBasePath, docs)).filter((item) => item !== null);
57
51
  });
58
52
  }
59
53
  function makeHeader(importPath, needsInferRequestType, clientName, useParseResponse) {
@@ -62,7 +56,7 @@ function makeHeader(importPath, needsInferRequestType, clientName, useParseRespo
62
56
  /**
63
57
  * Generates RPC client wrapper functions from OpenAPI specification.
64
58
  */
65
- function rpc(openAPI, output, importPath, split, clientName = "client", useParseResponse, basePath, docs) {
59
+ function rpc(openAPI, output, importPath, clientName = "client", useParseResponse, basePath, docs) {
66
60
  return Effect.gen(function* () {
67
61
  const paths = openAPI.paths;
68
62
  if (!isOpenAPIPaths(paths)) return yield* new GenerateError({ message: "Invalid OpenAPI paths" });
@@ -70,20 +64,10 @@ function rpc(openAPI, output, importPath, split, clientName = "client", useParse
70
64
  const componentsParameters = openAPI.components?.parameters ?? {};
71
65
  const componentsRequestBodies = openAPI.components?.requestBodies ?? {};
72
66
  const operationCodes = makeOperationCodes(paths, makeOperationDeps(clientName, componentsParameters, componentsRequestBodies), useParseResponse, hasBasePath, docs);
73
- if (!split) {
74
- const body = operationCodes.map(({ code }) => code).join("\n\n");
75
- const code = `${makeHeader(importPath, operationCodes.some(({ hasArgs }) => hasArgs), clientName, useParseResponse)}${body}${operationCodes.length > 0 ? "\n" : ""}`;
76
- yield* emit(code, dirname(output), output);
77
- return `Generated rpc code written to ${output}`;
78
- }
79
- const { outDir, indexPath } = resolveSplitOutDir(output);
80
- const index = `${[...new Set(operationCodes.map(({ funcName }) => `export * from './${funcName}'`))].join("\n")}\n`;
81
- yield* Effect.all([...operationCodes.map(({ funcName, code, hasArgs }) => {
82
- const fileSrc = `${makeHeader(importPath, hasArgs, clientName, useParseResponse)}${code}\n`;
83
- const filePath = join(outDir, `${funcName}.ts`);
84
- return emit(fileSrc, dirname(filePath), filePath);
85
- }), emit(index, dirname(indexPath), indexPath)], { concurrency: "unbounded" });
86
- 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}`;
87
71
  });
88
72
  }
89
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
@@ -1,4 +1,4 @@
1
- import { A as isOperation, D as isMediaWithSchema, H as isRequestBody, M as isParameter, N as isParameterArray, T as isHttpMethod, W as isSchemaArray, X as isStringRef, g as statusCodeToNumber, k as isOpenAPIPaths, u as makeSafeKey } from "../../utils-DEFpxBMu.js";
1
+ import { A as isOperation, D as isMediaWithSchema, H as isRequestBody, M as isParameter, N as isParameterArray, T as isHttpMethod, W as isSchemaArray, X as isStringRef, g as statusCodeToNumber, k as isOpenAPIPaths, u as makeSafeKey } from "../../utils-BtWoIX8v.js";
2
2
  import { t as emit } from "../../emit-B_3fXoto.js";
3
3
  import { Effect } from "effect";
4
4
  import path from "node:path";
@@ -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";
@@ -1,12 +1,12 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
2
  import { i as readdir, n as mkdir, o as writeFile, r as readFile } from "./file-CwKqigE9.js";
3
3
  import { n as fmt } from "./format-Bm9LZ_ki.js";
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-DEFpxBMu.js";
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-D_eeOVGa.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-DhxrYmuQ.js";
8
- import { t as hooks } from "./hooks-CZkcozjK.js";
9
- import { t as docs } from "./docs-C1_fNNJ-.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
+ 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";
12
12
  import { Effect } from "effect";
@@ -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;
@@ -774,7 +780,8 @@ function filterToJsonContentTypes(openapi) {
774
780
  "patch",
775
781
  "options",
776
782
  "head",
777
- "trace"
783
+ "trace",
784
+ "query"
778
785
  ].includes(k)) return [k, v];
779
786
  if (!hasRequestBodyContent(v)) return [k, v];
780
787
  const jsonContent = v.requestBody.content["application/json"];
@@ -1185,7 +1192,8 @@ function route(openAPI, routes, components, readonly) {
1185
1192
  "patch",
1186
1193
  "options",
1187
1194
  "head",
1188
- "trace"
1195
+ "trace",
1196
+ "query"
1189
1197
  ].flatMap((method) => {
1190
1198
  const operation = resolved[method];
1191
1199
  if (!operation?.responses) return [];
@@ -1213,7 +1221,7 @@ function route(openAPI, routes, components, readonly) {
1213
1221
  }
1214
1222
  //#endregion
1215
1223
  //#region src/core/takibi/index.ts
1216
- function takibi(openAPI, output, componentsOptions) {
1224
+ function takibi(openAPI, output, componentsOptions = {}) {
1217
1225
  return Effect.gen(function* () {
1218
1226
  yield* emit(zodOpenAPIHono(openAPI, componentsOptions), path.dirname(output), output);
1219
1227
  return `🔥 Generated code written to ${output}`;
@@ -1566,7 +1574,8 @@ function defineEntries(openapi, readonly) {
1566
1574
  "patch",
1567
1575
  "options",
1568
1576
  "head",
1569
- "trace"
1577
+ "trace",
1578
+ "query"
1570
1579
  ].flatMap((method) => {
1571
1580
  const operation = resolved[method];
1572
1581
  if (!operation?.responses) return [];
@@ -2550,7 +2559,8 @@ function webhooks(openAPI, webhooks, components, readonly) {
2550
2559
  "patch",
2551
2560
  "options",
2552
2561
  "head",
2553
- "trace"
2562
+ "trace",
2563
+ "query"
2554
2564
  ].filter((m) => pathItem[m]?.responses).flatMap((method) => {
2555
2565
  const operation = pathItem[method];
2556
2566
  if (!operation) return [];