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

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-D8l0hbLo.cjs");
2
+ const require_route_map = require("./route-map-CrmTV7B_.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-CnQV3Vwj.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-CA8qoJHZ.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-D8l0hbLo.cjs");
2
+ const require_route_map = require("./route-map-CrmTV7B_.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
@@ -106,6 +106,11 @@ type SchemaNode = {
106
106
  nullable?: true;
107
107
  model: string;
108
108
  refinements?: number;
109
+ } | {
110
+ kind: 'union';
111
+ nullable?: true;
112
+ options: SchemaNode[];
113
+ refinements?: number;
109
114
  } | {
110
115
  kind: string;
111
116
  nullable?: true;
@@ -241,6 +246,7 @@ interface SchemaChange {
241
246
  */
242
247
  path: string;
243
248
  summary: string;
249
+ detail?: string;
244
250
  }
245
251
  /**
246
252
  * What changed between two versions of one schema, and whether it breaks the
package/dist/index.d.mts CHANGED
@@ -106,6 +106,11 @@ type SchemaNode = {
106
106
  nullable?: true;
107
107
  model: string;
108
108
  refinements?: number;
109
+ } | {
110
+ kind: 'union';
111
+ nullable?: true;
112
+ options: SchemaNode[];
113
+ refinements?: number;
109
114
  } | {
110
115
  kind: string;
111
116
  nullable?: true;
@@ -241,6 +246,7 @@ interface SchemaChange {
241
246
  */
242
247
  path: string;
243
248
  summary: string;
249
+ detail?: string;
244
250
  }
245
251
  /**
246
252
  * What changed between two versions of one schema, and whether it breaks the
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-CnQV3Vwj.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-CA8qoJHZ.mjs";
2
2
  import { walkApi } from "kizunajs/generator";
3
3
  //#region src/api-notices.ts
4
4
  const readSunset = (route) => {
@@ -38,12 +38,29 @@ 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
40
  const modelOf = (schema) => schema.kind === "model" ? schema.model : void 0;
41
+ const optionsOf = (schema) => schema.kind === "union" ? schema.options : void 0;
41
42
  /**
42
- * What a reader sees when the kinds differ, so `array` reads as `array<string>`.
43
+ * Whether every value `narrow` allows is one `wide` allows too. A union holds
44
+ * whatever one of its options holds.
45
+ */
46
+ const holds = (wide, narrow) => {
47
+ const narrowOptions = optionsOf(narrow);
48
+ if (narrowOptions) return narrowOptions.every((option) => holds(wide, option));
49
+ const wideOptions = optionsOf(wide);
50
+ if (wideOptions && wide.kind !== narrow.kind) return wideOptions.some((option) => holds(option, narrow));
51
+ if (wide.kind !== narrow.kind || modelOf(wide) !== modelOf(narrow)) return false;
52
+ if (narrow.nullable === true && wide.nullable !== true) return false;
53
+ return diffSchemas(narrow, wide, "request").every((change) => !change.breaking);
54
+ };
55
+ /**
56
+ * What a reader sees when the kinds differ, so `array` reads as `array<string>` and a union as `string | number`.
43
57
  */
44
58
  const describeKind = (schema) => {
45
59
  const element = elementOf(schema);
46
- return element ? `array<${describeKind(element)}>` : modelOf(schema) ?? schema.kind;
60
+ if (element) return `array<${describeKind(element)}>`;
61
+ const options = optionsOf(schema);
62
+ if (options) return options.map(describeKind).join(" | ");
63
+ return modelOf(schema) ?? schema.kind;
47
64
  };
48
65
  /**
49
66
  * What changed between two versions of one schema, and whether it breaks the
@@ -61,11 +78,25 @@ const diffSchemas = (before, after, direction, path = "") => {
61
78
  path,
62
79
  summary: `${path || "the body"} is gone`
63
80
  }];
64
- if (before.kind !== after.kind || modelOf(before) !== modelOf(after)) return [{
65
- breaking: true,
66
- path,
67
- summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
68
- }];
81
+ const kindChanged = before.kind !== after.kind || modelOf(before) !== modelOf(after);
82
+ const bothUnions = optionsOf(before) !== void 0 && optionsOf(after) !== void 0;
83
+ if (kindChanged || bothUnions) {
84
+ const label = path || "the body";
85
+ const widened = holds(after, before);
86
+ const narrowed = holds(before, after);
87
+ if (!kindChanged && widened && narrowed) return [];
88
+ if (direction === "request" ? widened : narrowed) return [{
89
+ breaking: false,
90
+ path,
91
+ summary: `${label} ${direction === "request" ? "widens" : "narrows"} from ${describeKind(before)} to ${describeKind(after)}`,
92
+ detail: "the generated client type changes, the HTTP surface does not"
93
+ }];
94
+ return [{
95
+ breaking: true,
96
+ path,
97
+ summary: `${label} is ${describeKind(after)} instead of ${describeKind(before)}`
98
+ }];
99
+ }
69
100
  const changes = [];
70
101
  const wasNullable = before.nullable === true;
71
102
  const isNullable = after.nullable === true;
@@ -212,6 +243,12 @@ const toSchemaNode = (schema, inside = []) => {
212
243
  values: (def.values ?? []).map(String).sort(),
213
244
  ...carry
214
245
  };
246
+ if (def.type === "union") return {
247
+ kind: "union",
248
+ ...nullability,
249
+ options: options.map((option) => toSchemaNode(option, inside)),
250
+ ...carry
251
+ };
215
252
  return {
216
253
  kind: def.type ?? "unknown",
217
254
  ...nullability,
@@ -384,7 +421,8 @@ const diffSnapshots = (before, after, options = {}) => {
384
421
  for (const [direction, label, was, now] of inputs) for (const change of diffSchemas(was, now, direction, label)) changes.push({
385
422
  level: change.breaking ? "breaking" : "changed",
386
423
  key,
387
- summary: `${httpLabel(arrived, key)} ${change.summary}`
424
+ summary: `${httpLabel(arrived, key)} ${change.summary}`,
425
+ ...change.detail === void 0 ? {} : { detail: change.detail }
388
426
  });
389
427
  for (const [status, was] of Object.entries(gone.responses)) {
390
428
  if (!(status in arrived.responses)) continue;
@@ -392,7 +430,8 @@ const diffSnapshots = (before, after, options = {}) => {
392
430
  for (const change of diffSchemas(was ?? void 0, now ?? void 0, "response", status)) changes.push({
393
431
  level: change.breaking ? "breaking" : "changed",
394
432
  key,
395
- summary: `${httpLabel(arrived, key)} ${change.summary}`
433
+ summary: `${httpLabel(arrived, key)} ${change.summary}`,
434
+ ...change.detail === void 0 ? {} : { detail: change.detail }
396
435
  });
397
436
  }
398
437
  if (gone.hidden !== true && arrived.hidden === true) changes.push({
@@ -61,12 +61,29 @@ 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
63
  const modelOf = (schema) => schema.kind === "model" ? schema.model : void 0;
64
+ const optionsOf = (schema) => schema.kind === "union" ? schema.options : void 0;
64
65
  /**
65
- * What a reader sees when the kinds differ, so `array` reads as `array<string>`.
66
+ * Whether every value `narrow` allows is one `wide` allows too. A union holds
67
+ * whatever one of its options holds.
68
+ */
69
+ const holds = (wide, narrow) => {
70
+ const narrowOptions = optionsOf(narrow);
71
+ if (narrowOptions) return narrowOptions.every((option) => holds(wide, option));
72
+ const wideOptions = optionsOf(wide);
73
+ if (wideOptions && wide.kind !== narrow.kind) return wideOptions.some((option) => holds(option, narrow));
74
+ if (wide.kind !== narrow.kind || modelOf(wide) !== modelOf(narrow)) return false;
75
+ if (narrow.nullable === true && wide.nullable !== true) return false;
76
+ return diffSchemas(narrow, wide, "request").every((change) => !change.breaking);
77
+ };
78
+ /**
79
+ * What a reader sees when the kinds differ, so `array` reads as `array<string>` and a union as `string | number`.
66
80
  */
67
81
  const describeKind = (schema) => {
68
82
  const element = elementOf(schema);
69
- return element ? `array<${describeKind(element)}>` : modelOf(schema) ?? schema.kind;
83
+ if (element) return `array<${describeKind(element)}>`;
84
+ const options = optionsOf(schema);
85
+ if (options) return options.map(describeKind).join(" | ");
86
+ return modelOf(schema) ?? schema.kind;
70
87
  };
71
88
  /**
72
89
  * What changed between two versions of one schema, and whether it breaks the
@@ -84,11 +101,25 @@ const diffSchemas = (before, after, direction, path = "") => {
84
101
  path,
85
102
  summary: `${path || "the body"} is gone`
86
103
  }];
87
- if (before.kind !== after.kind || modelOf(before) !== modelOf(after)) return [{
88
- breaking: true,
89
- path,
90
- summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
91
- }];
104
+ const kindChanged = before.kind !== after.kind || modelOf(before) !== modelOf(after);
105
+ const bothUnions = optionsOf(before) !== void 0 && optionsOf(after) !== void 0;
106
+ if (kindChanged || bothUnions) {
107
+ const label = path || "the body";
108
+ const widened = holds(after, before);
109
+ const narrowed = holds(before, after);
110
+ if (!kindChanged && widened && narrowed) return [];
111
+ if (direction === "request" ? widened : narrowed) return [{
112
+ breaking: false,
113
+ path,
114
+ summary: `${label} ${direction === "request" ? "widens" : "narrows"} from ${describeKind(before)} to ${describeKind(after)}`,
115
+ detail: "the generated client type changes, the HTTP surface does not"
116
+ }];
117
+ return [{
118
+ breaking: true,
119
+ path,
120
+ summary: `${label} is ${describeKind(after)} instead of ${describeKind(before)}`
121
+ }];
122
+ }
92
123
  const changes = [];
93
124
  const wasNullable = before.nullable === true;
94
125
  const isNullable = after.nullable === true;
@@ -235,6 +266,12 @@ const toSchemaNode = (schema, inside = []) => {
235
266
  values: (def.values ?? []).map(String).sort(),
236
267
  ...carry
237
268
  };
269
+ if (def.type === "union") return {
270
+ kind: "union",
271
+ ...nullability,
272
+ options: options.map((option) => toSchemaNode(option, inside)),
273
+ ...carry
274
+ };
238
275
  return {
239
276
  kind: def.type ?? "unknown",
240
277
  ...nullability,
@@ -407,7 +444,8 @@ const diffSnapshots = (before, after, options = {}) => {
407
444
  for (const [direction, label, was, now] of inputs) for (const change of diffSchemas(was, now, direction, label)) changes.push({
408
445
  level: change.breaking ? "breaking" : "changed",
409
446
  key,
410
- summary: `${httpLabel(arrived, key)} ${change.summary}`
447
+ summary: `${httpLabel(arrived, key)} ${change.summary}`,
448
+ ...change.detail === void 0 ? {} : { detail: change.detail }
411
449
  });
412
450
  for (const [status, was] of Object.entries(gone.responses)) {
413
451
  if (!(status in arrived.responses)) continue;
@@ -415,7 +453,8 @@ const diffSnapshots = (before, after, options = {}) => {
415
453
  for (const change of diffSchemas(was ?? void 0, now ?? void 0, "response", status)) changes.push({
416
454
  level: change.breaking ? "breaking" : "changed",
417
455
  key,
418
- summary: `${httpLabel(arrived, key)} ${change.summary}`
456
+ summary: `${httpLabel(arrived, key)} ${change.summary}`,
457
+ ...change.detail === void 0 ? {} : { detail: change.detail }
419
458
  });
420
459
  }
421
460
  if (gone.hidden !== true && arrived.hidden === true) changes.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizunajs/cli",
3
- "version": "2.0.0-beta.34",
3
+ "version": "2.0.0-beta.35",
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.34",
64
+ "kizunajs": "2.0.0-beta.35",
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.34",
70
+ "kizunajs": "2.0.0-beta.35",
71
71
  "tsdown": "^0.21.10",
72
72
  "zod": "^4.6.7"
73
73
  },