hono-takibi 0.17.0 → 0.18.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
@@ -9,7 +9,7 @@
9
9
  From one document it can generate:
10
10
 
11
11
  - [Zod](https://zod.dev/) schemas and [@hono/zod-openapi](https://hono.dev/examples/zod-openapi) route definitions
12
- - App entry, handler stubs and test files
12
+ - App entry and handler stubs
13
13
  - RPC client and hooks for SWR, TanStack Query, Preact / Solid / Vue / Svelte / Angular Query
14
14
  - Mock server, TypeScript types and API reference docs
15
15
 
package/dist/cli.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
  import { NodeRuntime, NodeServices } from "@effect/platform-node";
3
3
  import { Console, Effect, FileSystem, Option, Path, Ref, Schema, Stream } from "effect";
4
- import { Argument, CliError, Command, Flag } from "effect/unstable/cli";
4
+ import { Argument, CliError, Command, Flag } from "effect/cli";
5
5
  //#region package.json
6
- var version = "0.17.0";
6
+ var version = "0.18.0";
7
7
  var description = "Hono Takibi is a code generator from OpenAPI to @hono/zod-openapi";
8
8
  //#endregion
9
9
  //#region src/cli/index.ts
@@ -46,12 +46,13 @@ function loadConfig(configPath, reload) {
46
46
  }
47
47
  function runJobs(config) {
48
48
  return Effect.gen(function* () {
49
- const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob }] = yield* Effect.promise(() => Promise.all([
49
+ const [{ parseOpenAPI }, { FormatOptions }, { cleanSplitOutputs, makeJob, packageRoots }] = yield* Effect.promise(() => Promise.all([
50
50
  import("./openapi-DQRxq2_O.js").then((n) => n.t),
51
51
  import("./format-CuHABcKC.js").then((n) => n.r),
52
- import("./shared-CU8tD0KG.js").then((n) => n.i)
52
+ import("./shared-CMgxc-KQ.js").then((n) => n.a)
53
53
  ]));
54
- const jobs = makeJob(yield* parseOpenAPI(config.input), config);
54
+ const openAPI = yield* parseOpenAPI(config.input);
55
+ const jobs = makeJob(openAPI, config, yield* packageRoots(openAPI, config));
55
56
  yield* cleanSplitOutputs(jobs.filter((job) => job.split).map((job) => job.output));
56
57
  return (yield* Effect.forEach(jobs, (job) => job.run(job.output), { concurrency: "unbounded" }).pipe(Effect.provideService(FormatOptions, config.format ?? {}))).filter((message) => message !== "").join("\n");
57
58
  });
@@ -86,7 +87,7 @@ function reportJobs(config, previous) {
86
87
  onFailure: (error) => Console.error(`❌ ${error.message}`),
87
88
  onSuccess: (report) => Console.log(report)
88
89
  }));
89
- const { outsideSources } = yield* Effect.promise(() => import("./shared-CU8tD0KG.js").then((n) => n.i));
90
+ const { outsideSources } = yield* Effect.promise(() => import("./shared-CMgxc-KQ.js").then((n) => n.a));
90
91
  const inputDirectory = path.dirname(path.resolve(config.input));
91
92
  return {
92
93
  inputDirectory,
@@ -213,7 +214,7 @@ function generate(args) {
213
214
  })]
214
215
  });
215
216
  if (input !== void 0 && output !== void 0) {
216
- const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-B31BC8gp.js").then((n) => n.t)]));
217
+ const [{ parseOpenAPI }, { takibi }] = yield* Effect.promise(() => Promise.all([import("./openapi-DQRxq2_O.js").then((n) => n.t), import("./core-BuSZBtYC.js").then((n) => n.t)]));
217
218
  return yield* Console.log(yield* takibi(yield* parseOpenAPI(input), output));
218
219
  }
219
220
  const resolvedConfig = configPath ?? DEFAULT_CONFIG_FILE;
@@ -0,0 +1,42 @@
1
+ //#region src/constants/index.ts
2
+ /** The kinds of the OpenAPI Components Object, in declaration and config-field order. */
3
+ const COMPONENT_NAMES = [
4
+ "schemas",
5
+ "responses",
6
+ "parameters",
7
+ "examples",
8
+ "requestBodies",
9
+ "headers",
10
+ "securitySchemes",
11
+ "links",
12
+ "callbacks",
13
+ "pathItems",
14
+ "mediaTypes"
15
+ ];
16
+ /** The query libraries the hooks are generated for, each a config key of its own. */
17
+ const HOOK_LIBRARIES = [
18
+ "swr",
19
+ "tanstack-query",
20
+ "preact-query",
21
+ "solid-query",
22
+ "vue-query",
23
+ "svelte-query",
24
+ "angular-query"
25
+ ];
26
+ /**
27
+ * The HTTP methods an OpenAPI path item can hold, in the order the specification lists
28
+ * them: OpenAPI 3.2 adds `query`. Operations of one path are generated in this order.
29
+ */
30
+ const HTTP_METHODS = [
31
+ "get",
32
+ "put",
33
+ "post",
34
+ "delete",
35
+ "options",
36
+ "head",
37
+ "patch",
38
+ "trace",
39
+ "query"
40
+ ];
41
+ //#endregion
42
+ export { HOOK_LIBRARIES as n, HTTP_METHODS as r, COMPONENT_NAMES as t };
@@ -1,2 +1,2 @@
1
- import { t as docs } from "../../docs-BxfKU8TG.js";
1
+ import { t as docs } from "../../docs-DJps1WGq.js";
2
2
  export { docs };
@@ -1,6 +1,6 @@
1
1
  import { t as OpenAPI } from "../../index-tsPqeV6H.js";
2
2
  import { n as GenerateError, t as FormatError } from "../../index-D_gf3Xzx.js";
3
- import { t as Grouping } from "../../index-DKui1bHG.js";
3
+ import { t as Grouping } from "../../index-Dn5Bw8ov.js";
4
4
  //#region src/core/hooks/index.d.ts
5
5
  declare const HOOK_CONFIGS: {
6
6
  readonly swr: {
@@ -1,2 +1,2 @@
1
- import { t as hooks } from "../../hooks-sH69j0o0.js";
1
+ import { t as hooks } from "../../hooks-CQMtSLZv.js";
2
2
  export { hooks };
@@ -1,6 +1,6 @@
1
1
  import { t as OpenAPI } from "../../index-tsPqeV6H.js";
2
2
  import { n as GenerateError, t as FormatError } from "../../index-D_gf3Xzx.js";
3
- import { t as Grouping } from "../../index-DKui1bHG.js";
3
+ import { t as Grouping } from "../../index-Dn5Bw8ov.js";
4
4
  import { Effect } from "effect";
5
5
  //#region src/core/rpc/index.d.ts
6
6
  /**
@@ -1,7 +1,8 @@
1
+ import { r as HTTP_METHODS } from "../../constants-DlWc79pw.js";
1
2
  import { i as GenerateError } from "../../format-CuHABcKC.js";
2
- import { A as isOperationLike, O as isOpenAPIPaths, R as isRecord, f as methodPath, l as makeInferRequestType } from "../../utils-BvdDxide.js";
3
- import { t as emit } from "../../emit-CSV6od97.js";
4
- import { a as parsePathItem, i as operationHasArgs, o as groupClientName, r as makeOperationDeps, t as formatPath } from "../../rpc-BvVFjspk.js";
3
+ import { D as isOpenAPIPaths, L as isRecord, f as methodPath, k as isOperationLike, l as makeInferRequestType } from "../../utils-7HBCrio0.js";
4
+ import { t as emit } from "../../emit-uwlZZeRM.js";
5
+ import { a as parsePathItem, c as operationTags, i as operationHasArgs, o as groupClientName, r as makeOperationDeps, t as formatPath } from "../../rpc-Bl9hcXCo.js";
5
6
  import { Effect } from "effect";
6
7
  import { dirname } from "node:path";
7
8
  //#region src/core/rpc/index.ts
@@ -41,24 +42,10 @@ function makeOperationCode(path, method, item, base, useParseResponse, hasBasePa
41
42
  client: deps.client
42
43
  };
43
44
  }
44
- function operationTags(operation) {
45
- const tags = "tags" in operation ? operation.tags : void 0;
46
- return Array.isArray(tags) ? tags.filter((tag) => typeof tag === "string") : void 0;
47
- }
48
45
  function makeOperationCodes(paths, deps, useParseResponse, hasBasePath, docs, grouping) {
49
46
  return Object.entries(paths).filter((entry) => isRecord(entry[1])).flatMap(([p, rawItem]) => {
50
47
  const pathItem = parsePathItem(rawItem);
51
- return [
52
- "get",
53
- "put",
54
- "post",
55
- "delete",
56
- "options",
57
- "head",
58
- "patch",
59
- "trace",
60
- "query"
61
- ].map((method) => makeOperationCode(p, method, pathItem, deps, useParseResponse, hasBasePath, docs, grouping)).filter((item) => item !== null);
48
+ return HTTP_METHODS.map((method) => makeOperationCode(p, method, pathItem, deps, useParseResponse, hasBasePath, docs, grouping)).filter((item) => item !== null);
62
49
  });
63
50
  }
64
51
  function makeHeader(importPath, needsInferRequestType, clientNames, useParseResponse) {
@@ -1,5 +1,5 @@
1
- import { D as isMediaWithSchema, M as isParameterArray, O as isOpenAPIPaths, T as isHttpMethod, U as isSchemaArray, V as isRequestBody, Y as isStringRef, g as statusCodeToNumber, j as isParameter, k as isOperation, u as makeSafeKey } from "../../utils-BvdDxide.js";
2
- import { t as emit } from "../../emit-CSV6od97.js";
1
+ import { A as isParameter, B as isRequestBody, D as isOpenAPIPaths, E as isMediaWithSchema, H as isSchemaArray, J as isStringRef, O as isOperation, g as statusCodeToNumber, j as isParameterArray, u as makeSafeKey, w as isHttpMethod } from "../../utils-7HBCrio0.js";
2
+ import { t as emit } from "../../emit-uwlZZeRM.js";
3
3
  import { Effect } from "effect";
4
4
  import path from "node:path";
5
5
  //#region src/core/type/index.ts