@kizunajs/cli 2.0.0-beta.33 → 2.0.0-beta.34

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/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_route_map = require("./route-map-CGZ5VfE9.cjs");
2
+ const require_route_map = require("./route-map-D8l0hbLo.cjs");
3
3
  let kizunajs_generator = require("kizunajs/generator");
4
4
  let node_path = require("node:path");
5
5
  let node_fs = require("node:fs");
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, d as diffSnapshots, f as formatChange, h as snapshotTarget, i as readSnapshot, l as writeFiles, m as snapshotPathFor, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes } from "./route-map-pLtv53AW.mjs";
2
+ import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, d as diffSnapshots, f as formatChange, h as snapshotTarget, i as readSnapshot, l as writeFiles, m as snapshotPathFor, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes } from "./route-map-CnQV3Vwj.mjs";
3
3
  import { walkApi } from "kizunajs/generator";
4
4
  import { dirname, relative, resolve } from "node:path";
5
5
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_route_map = require("./route-map-CGZ5VfE9.cjs");
2
+ const require_route_map = require("./route-map-D8l0hbLo.cjs");
3
3
  let kizunajs_generator = require("kizunajs/generator");
4
4
  //#region src/api-notices.ts
5
5
  const readSunset = (route) => {
package/dist/index.d.cts CHANGED
@@ -101,6 +101,11 @@ type SchemaNode = {
101
101
  nullable?: true;
102
102
  values: string[];
103
103
  refinements?: number;
104
+ } | {
105
+ kind: 'model';
106
+ nullable?: true;
107
+ model: string;
108
+ refinements?: number;
104
109
  } | {
105
110
  kind: string;
106
111
  nullable?: true;
package/dist/index.d.mts CHANGED
@@ -101,6 +101,11 @@ type SchemaNode = {
101
101
  nullable?: true;
102
102
  values: string[];
103
103
  refinements?: number;
104
+ } | {
105
+ kind: 'model';
106
+ nullable?: true;
107
+ model: string;
108
+ refinements?: number;
104
109
  } | {
105
110
  kind: string;
106
111
  nullable?: true;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, f as formatChange, g as diffSchemas, l as writeFiles, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes, u as diffApis } from "./route-map-pLtv53AW.mjs";
1
+ import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, f as formatChange, g as diffSchemas, l as writeFiles, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes, u as diffApis } from "./route-map-CnQV3Vwj.mjs";
2
2
  import { walkApi } from "kizunajs/generator";
3
3
  //#region src/api-notices.ts
4
4
  const readSunset = (route) => {
@@ -1,6 +1,6 @@
1
1
  import { createJiti } from "jiti";
2
2
  import { apiEntries } from "kizunajs";
3
- import { deriveToolNames, flattenJobs, readDef, readObjectShape, resolveResponseBody, toToolName, unwrapOptionalWrappers, walkApi } from "kizunajs/generator";
3
+ import { deriveToolNames, flattenJobs, readDef, readMetaId, readModelSchema, readObjectShape, resolveResponseBody, toToolName, unwrapOptionalWrappers, walkApi } from "kizunajs/generator";
4
4
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
5
5
  import { parse, stringify } from "yaml";
6
6
  import { flattenRoutes } from "kizunajs/adapter";
@@ -37,12 +37,13 @@ const joinPath = (parent, key) => parent === "" ? key : `${parent}.${key}`;
37
37
  const fieldsOf = (schema) => schema.kind === "object" ? schema.fields : void 0;
38
38
  const elementOf = (schema) => schema.kind === "array" ? schema.element : void 0;
39
39
  const valuesOf = (schema) => schema.kind === "enum" ? schema.values : void 0;
40
+ const modelOf = (schema) => schema.kind === "model" ? schema.model : void 0;
40
41
  /**
41
42
  * What a reader sees when the kinds differ, so `array` reads as `array<string>`.
42
43
  */
43
44
  const describeKind = (schema) => {
44
45
  const element = elementOf(schema);
45
- return element ? `array<${describeKind(element)}>` : schema.kind;
46
+ return element ? `array<${describeKind(element)}>` : modelOf(schema) ?? schema.kind;
46
47
  };
47
48
  /**
48
49
  * What changed between two versions of one schema, and whether it breaks the
@@ -60,7 +61,7 @@ const diffSchemas = (before, after, direction, path = "") => {
60
61
  path,
61
62
  summary: `${path || "the body"} is gone`
62
63
  }];
63
- if (before.kind !== after.kind) return [{
64
+ if (before.kind !== after.kind || modelOf(before) !== modelOf(after)) return [{
64
65
  breaking: true,
65
66
  path,
66
67
  summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
@@ -155,26 +156,36 @@ const refinementCount = (schema) => {
155
156
  return custom === 0 ? void 0 : custom;
156
157
  };
157
158
  /**
158
- * A Zod schema reduced to the shape a comparison reads.
159
+ * A Zod schema reduced to the shape a comparison reads. A model that holds
160
+ * itself is written out once, and inside itself as a reference by its title.
161
+ *
162
+ * `inside` is the objects the walk is in, so it can tell when it has gone round.
159
163
  */
160
- const toSchemaNode = (schema) => {
164
+ const toSchemaNode = (schema, inside = []) => {
161
165
  const { inner, nullable } = unwrapOptionalWrappers(schema);
162
166
  const def = readDef(inner);
167
+ const nullability = nullable ? { nullable: true } : {};
168
+ const identity = readModelSchema(inner) ?? inner;
169
+ if (inside.includes(identity)) return {
170
+ kind: "model",
171
+ ...nullability,
172
+ model: readMetaId(inner) ?? ""
173
+ };
163
174
  const options = def.type === "union" ? def.options ?? [] : [];
164
175
  const nonNull = options.filter((option) => readDef(option).type !== "null");
165
176
  if (nonNull.length === 1 && options.length > 1) return {
166
- ...toSchemaNode(nonNull[0]),
177
+ ...toSchemaNode(nonNull[0], inside),
167
178
  nullable: true
168
179
  };
169
- const nullability = nullable ? { nullable: true } : {};
170
180
  const refinements = refinementCount(inner);
171
181
  const carry = refinements === void 0 ? {} : { refinements };
172
182
  const shape = readObjectShape(inner);
173
183
  if (shape) {
174
184
  const fields = {};
185
+ const within = [...inside, identity];
175
186
  for (const [key, field] of Object.entries(shape)) fields[key] = {
176
187
  optional: unwrapOptionalWrappers(field).optional,
177
- schema: toSchemaNode(field)
188
+ schema: toSchemaNode(field, within)
178
189
  };
179
190
  return {
180
191
  kind: "object",
@@ -186,7 +197,7 @@ const toSchemaNode = (schema) => {
186
197
  if (def.type === "array" && def.element) return {
187
198
  kind: "array",
188
199
  ...nullability,
189
- element: toSchemaNode(def.element),
200
+ element: toSchemaNode(def.element, inside),
190
201
  ...carry
191
202
  };
192
203
  if (def.type === "enum") return {
@@ -60,12 +60,13 @@ const joinPath = (parent, key) => parent === "" ? key : `${parent}.${key}`;
60
60
  const fieldsOf = (schema) => schema.kind === "object" ? schema.fields : void 0;
61
61
  const elementOf = (schema) => schema.kind === "array" ? schema.element : void 0;
62
62
  const valuesOf = (schema) => schema.kind === "enum" ? schema.values : void 0;
63
+ const modelOf = (schema) => schema.kind === "model" ? schema.model : void 0;
63
64
  /**
64
65
  * What a reader sees when the kinds differ, so `array` reads as `array<string>`.
65
66
  */
66
67
  const describeKind = (schema) => {
67
68
  const element = elementOf(schema);
68
- return element ? `array<${describeKind(element)}>` : schema.kind;
69
+ return element ? `array<${describeKind(element)}>` : modelOf(schema) ?? schema.kind;
69
70
  };
70
71
  /**
71
72
  * What changed between two versions of one schema, and whether it breaks the
@@ -83,7 +84,7 @@ const diffSchemas = (before, after, direction, path = "") => {
83
84
  path,
84
85
  summary: `${path || "the body"} is gone`
85
86
  }];
86
- if (before.kind !== after.kind) return [{
87
+ if (before.kind !== after.kind || modelOf(before) !== modelOf(after)) return [{
87
88
  breaking: true,
88
89
  path,
89
90
  summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
@@ -178,26 +179,36 @@ const refinementCount = (schema) => {
178
179
  return custom === 0 ? void 0 : custom;
179
180
  };
180
181
  /**
181
- * A Zod schema reduced to the shape a comparison reads.
182
+ * A Zod schema reduced to the shape a comparison reads. A model that holds
183
+ * itself is written out once, and inside itself as a reference by its title.
184
+ *
185
+ * `inside` is the objects the walk is in, so it can tell when it has gone round.
182
186
  */
183
- const toSchemaNode = (schema) => {
187
+ const toSchemaNode = (schema, inside = []) => {
184
188
  const { inner, nullable } = (0, kizunajs_generator.unwrapOptionalWrappers)(schema);
185
189
  const def = (0, kizunajs_generator.readDef)(inner);
190
+ const nullability = nullable ? { nullable: true } : {};
191
+ const identity = (0, kizunajs_generator.readModelSchema)(inner) ?? inner;
192
+ if (inside.includes(identity)) return {
193
+ kind: "model",
194
+ ...nullability,
195
+ model: (0, kizunajs_generator.readMetaId)(inner) ?? ""
196
+ };
186
197
  const options = def.type === "union" ? def.options ?? [] : [];
187
198
  const nonNull = options.filter((option) => (0, kizunajs_generator.readDef)(option).type !== "null");
188
199
  if (nonNull.length === 1 && options.length > 1) return {
189
- ...toSchemaNode(nonNull[0]),
200
+ ...toSchemaNode(nonNull[0], inside),
190
201
  nullable: true
191
202
  };
192
- const nullability = nullable ? { nullable: true } : {};
193
203
  const refinements = refinementCount(inner);
194
204
  const carry = refinements === void 0 ? {} : { refinements };
195
205
  const shape = (0, kizunajs_generator.readObjectShape)(inner);
196
206
  if (shape) {
197
207
  const fields = {};
208
+ const within = [...inside, identity];
198
209
  for (const [key, field] of Object.entries(shape)) fields[key] = {
199
210
  optional: (0, kizunajs_generator.unwrapOptionalWrappers)(field).optional,
200
- schema: toSchemaNode(field)
211
+ schema: toSchemaNode(field, within)
201
212
  };
202
213
  return {
203
214
  kind: "object",
@@ -209,7 +220,7 @@ const toSchemaNode = (schema) => {
209
220
  if (def.type === "array" && def.element) return {
210
221
  kind: "array",
211
222
  ...nullability,
212
- element: toSchemaNode(def.element),
223
+ element: toSchemaNode(def.element, inside),
213
224
  ...carry
214
225
  };
215
226
  if (def.type === "enum") return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizunajs/cli",
3
- "version": "2.0.0-beta.33",
3
+ "version": "2.0.0-beta.34",
4
4
  "description": "Command line tooling for Kizuna.js",
5
5
  "keywords": [
6
6
  "kizunajs",
@@ -61,13 +61,13 @@
61
61
  "yaml": "^2.9.1"
62
62
  },
63
63
  "peerDependencies": {
64
- "kizunajs": "2.0.0-beta.33",
64
+ "kizunajs": "2.0.0-beta.34",
65
65
  "zod": "^4.0.0"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/node": "^24.19.2",
69
69
  "@types/react": "^19.3.0",
70
- "kizunajs": "2.0.0-beta.33",
70
+ "kizunajs": "2.0.0-beta.34",
71
71
  "tsdown": "^0.21.10",
72
72
  "zod": "^4.6.7"
73
73
  },