@kizunajs/cli 2.0.0-beta.17 → 2.0.0-beta.18
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 +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +1 -1
- package/dist/{route-map-C0CF82bw.cjs → route-map-BHe__KDP.cjs} +34 -7
- package/dist/{route-map-BPi-Oj1o.mjs → route-map-C0K0orUw.mjs} +34 -7
- package/package.json +3 -3
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_route_map = require("./route-map-
|
|
2
|
+
const require_route_map = require("./route-map-BHe__KDP.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-
|
|
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-C0K0orUw.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-
|
|
2
|
+
const require_route_map = require("./route-map-BHe__KDP.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
|
@@ -76,11 +76,12 @@ declare const formatNotice: (notice: Notice) => string;
|
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/snapshot.d.ts
|
|
78
78
|
/**
|
|
79
|
-
* A schema reduced to what a comparison needs: its kind,
|
|
80
|
-
* values it accepts when it is closed.
|
|
79
|
+
* A schema reduced to what a comparison needs: its kind, whether it accepts
|
|
80
|
+
* `null`, its fields, and the values it accepts when it is closed.
|
|
81
81
|
*/
|
|
82
82
|
type SchemaNode = {
|
|
83
83
|
kind: 'object';
|
|
84
|
+
nullable?: true;
|
|
84
85
|
fields: Record<string, {
|
|
85
86
|
optional: boolean;
|
|
86
87
|
schema: SchemaNode;
|
|
@@ -88,14 +89,17 @@ type SchemaNode = {
|
|
|
88
89
|
refinements?: number;
|
|
89
90
|
} | {
|
|
90
91
|
kind: 'array';
|
|
92
|
+
nullable?: true;
|
|
91
93
|
element: SchemaNode;
|
|
92
94
|
refinements?: number;
|
|
93
95
|
} | {
|
|
94
96
|
kind: 'enum';
|
|
97
|
+
nullable?: true;
|
|
95
98
|
values: string[];
|
|
96
99
|
refinements?: number;
|
|
97
100
|
} | {
|
|
98
101
|
kind: string;
|
|
102
|
+
nullable?: true;
|
|
99
103
|
refinements?: number;
|
|
100
104
|
};
|
|
101
105
|
//#endregion
|
package/dist/index.d.mts
CHANGED
|
@@ -76,11 +76,12 @@ declare const formatNotice: (notice: Notice) => string;
|
|
|
76
76
|
//#endregion
|
|
77
77
|
//#region src/snapshot.d.ts
|
|
78
78
|
/**
|
|
79
|
-
* A schema reduced to what a comparison needs: its kind,
|
|
80
|
-
* values it accepts when it is closed.
|
|
79
|
+
* A schema reduced to what a comparison needs: its kind, whether it accepts
|
|
80
|
+
* `null`, its fields, and the values it accepts when it is closed.
|
|
81
81
|
*/
|
|
82
82
|
type SchemaNode = {
|
|
83
83
|
kind: 'object';
|
|
84
|
+
nullable?: true;
|
|
84
85
|
fields: Record<string, {
|
|
85
86
|
optional: boolean;
|
|
86
87
|
schema: SchemaNode;
|
|
@@ -88,14 +89,17 @@ type SchemaNode = {
|
|
|
88
89
|
refinements?: number;
|
|
89
90
|
} | {
|
|
90
91
|
kind: 'array';
|
|
92
|
+
nullable?: true;
|
|
91
93
|
element: SchemaNode;
|
|
92
94
|
refinements?: number;
|
|
93
95
|
} | {
|
|
94
96
|
kind: 'enum';
|
|
97
|
+
nullable?: true;
|
|
95
98
|
values: string[];
|
|
96
99
|
refinements?: number;
|
|
97
100
|
} | {
|
|
98
101
|
kind: string;
|
|
102
|
+
nullable?: true;
|
|
99
103
|
refinements?: number;
|
|
100
104
|
};
|
|
101
105
|
//#endregion
|
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-
|
|
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-C0K0orUw.mjs";
|
|
2
2
|
import { walkApi } from "kizunajs/generator";
|
|
3
3
|
//#region src/api-notices.ts
|
|
4
4
|
const readSunset = (route) => {
|
|
@@ -82,10 +82,25 @@ const diffSchemas = (before, after, direction, path = "") => {
|
|
|
82
82
|
path,
|
|
83
83
|
summary: `${path || "the body"} is gone`
|
|
84
84
|
}];
|
|
85
|
+
if (before.kind !== after.kind) return [{
|
|
86
|
+
breaking: true,
|
|
87
|
+
path,
|
|
88
|
+
summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
|
|
89
|
+
}];
|
|
85
90
|
const changes = [];
|
|
91
|
+
const wasNullable = before.nullable === true;
|
|
92
|
+
const isNullable = after.nullable === true;
|
|
93
|
+
if (wasNullable !== isNullable) changes.push({
|
|
94
|
+
breaking: direction === (isNullable ? "response" : "request"),
|
|
95
|
+
path,
|
|
96
|
+
summary: isNullable ? `${path || "the body"} can now be null` : `${path || "the body"} can no longer be null`
|
|
97
|
+
});
|
|
86
98
|
const beforeElement = elementOf(before);
|
|
87
99
|
const afterElement = elementOf(after);
|
|
88
|
-
if (beforeElement && afterElement)
|
|
100
|
+
if (beforeElement && afterElement) {
|
|
101
|
+
changes.push(...diffSchemas(beforeElement, afterElement, direction, `${path}[]`));
|
|
102
|
+
return changes;
|
|
103
|
+
}
|
|
89
104
|
const beforeFields = fieldsOf(before);
|
|
90
105
|
const afterFields = fieldsOf(after);
|
|
91
106
|
if (beforeFields && afterFields) {
|
|
@@ -105,6 +120,11 @@ const diffSchemas = (before, after, direction, path = "") => {
|
|
|
105
120
|
path: here,
|
|
106
121
|
summary: `${here} is no longer optional`
|
|
107
122
|
});
|
|
123
|
+
if (!existing.optional && field.optional) changes.push({
|
|
124
|
+
breaking: direction === "response",
|
|
125
|
+
path: here,
|
|
126
|
+
summary: direction === "response" ? `${here} may now be left out` : `${here} is now optional`
|
|
127
|
+
});
|
|
108
128
|
changes.push(...diffSchemas(existing.schema, field.schema, direction, here));
|
|
109
129
|
}
|
|
110
130
|
for (const key of Object.keys(beforeFields)) {
|
|
@@ -118,11 +138,6 @@ const diffSchemas = (before, after, direction, path = "") => {
|
|
|
118
138
|
}
|
|
119
139
|
return changes;
|
|
120
140
|
}
|
|
121
|
-
if (before.kind !== after.kind) return [{
|
|
122
|
-
breaking: true,
|
|
123
|
-
path,
|
|
124
|
-
summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
|
|
125
|
-
}];
|
|
126
141
|
const was = valuesOf(before);
|
|
127
142
|
const now = valuesOf(after);
|
|
128
143
|
if (was && now) {
|
|
@@ -165,8 +180,15 @@ const refinementCount = (schema) => {
|
|
|
165
180
|
* A Zod schema reduced to the shape a comparison reads.
|
|
166
181
|
*/
|
|
167
182
|
const toSchemaNode = (schema) => {
|
|
168
|
-
const { inner } = (0, kizunajs_generator.unwrapOptionalWrappers)(schema);
|
|
183
|
+
const { inner, nullable } = (0, kizunajs_generator.unwrapOptionalWrappers)(schema);
|
|
169
184
|
const def = (0, kizunajs_generator.readDef)(inner);
|
|
185
|
+
const options = def.type === "union" ? def.options ?? [] : [];
|
|
186
|
+
const nonNull = options.filter((option) => (0, kizunajs_generator.readDef)(option).type !== "null");
|
|
187
|
+
if (nonNull.length === 1 && options.length > 1) return {
|
|
188
|
+
...toSchemaNode(nonNull[0]),
|
|
189
|
+
nullable: true
|
|
190
|
+
};
|
|
191
|
+
const nullability = nullable ? { nullable: true } : {};
|
|
170
192
|
const refinements = refinementCount(inner);
|
|
171
193
|
const carry = refinements === void 0 ? {} : { refinements };
|
|
172
194
|
const shape = (0, kizunajs_generator.readObjectShape)(inner);
|
|
@@ -178,27 +200,32 @@ const toSchemaNode = (schema) => {
|
|
|
178
200
|
};
|
|
179
201
|
return {
|
|
180
202
|
kind: "object",
|
|
203
|
+
...nullability,
|
|
181
204
|
fields,
|
|
182
205
|
...carry
|
|
183
206
|
};
|
|
184
207
|
}
|
|
185
208
|
if (def.type === "array" && def.element) return {
|
|
186
209
|
kind: "array",
|
|
210
|
+
...nullability,
|
|
187
211
|
element: toSchemaNode(def.element),
|
|
188
212
|
...carry
|
|
189
213
|
};
|
|
190
214
|
if (def.type === "enum") return {
|
|
191
215
|
kind: "enum",
|
|
216
|
+
...nullability,
|
|
192
217
|
values: Object.values(def.entries ?? {}).map(String).sort(),
|
|
193
218
|
...carry
|
|
194
219
|
};
|
|
195
220
|
if (def.type === "literal") return {
|
|
196
221
|
kind: "enum",
|
|
222
|
+
...nullability,
|
|
197
223
|
values: (def.values ?? []).map(String).sort(),
|
|
198
224
|
...carry
|
|
199
225
|
};
|
|
200
226
|
return {
|
|
201
227
|
kind: def.type ?? "unknown",
|
|
228
|
+
...nullability,
|
|
202
229
|
...carry
|
|
203
230
|
};
|
|
204
231
|
};
|
|
@@ -59,10 +59,25 @@ const diffSchemas = (before, after, direction, path = "") => {
|
|
|
59
59
|
path,
|
|
60
60
|
summary: `${path || "the body"} is gone`
|
|
61
61
|
}];
|
|
62
|
+
if (before.kind !== after.kind) return [{
|
|
63
|
+
breaking: true,
|
|
64
|
+
path,
|
|
65
|
+
summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
|
|
66
|
+
}];
|
|
62
67
|
const changes = [];
|
|
68
|
+
const wasNullable = before.nullable === true;
|
|
69
|
+
const isNullable = after.nullable === true;
|
|
70
|
+
if (wasNullable !== isNullable) changes.push({
|
|
71
|
+
breaking: direction === (isNullable ? "response" : "request"),
|
|
72
|
+
path,
|
|
73
|
+
summary: isNullable ? `${path || "the body"} can now be null` : `${path || "the body"} can no longer be null`
|
|
74
|
+
});
|
|
63
75
|
const beforeElement = elementOf(before);
|
|
64
76
|
const afterElement = elementOf(after);
|
|
65
|
-
if (beforeElement && afterElement)
|
|
77
|
+
if (beforeElement && afterElement) {
|
|
78
|
+
changes.push(...diffSchemas(beforeElement, afterElement, direction, `${path}[]`));
|
|
79
|
+
return changes;
|
|
80
|
+
}
|
|
66
81
|
const beforeFields = fieldsOf(before);
|
|
67
82
|
const afterFields = fieldsOf(after);
|
|
68
83
|
if (beforeFields && afterFields) {
|
|
@@ -82,6 +97,11 @@ const diffSchemas = (before, after, direction, path = "") => {
|
|
|
82
97
|
path: here,
|
|
83
98
|
summary: `${here} is no longer optional`
|
|
84
99
|
});
|
|
100
|
+
if (!existing.optional && field.optional) changes.push({
|
|
101
|
+
breaking: direction === "response",
|
|
102
|
+
path: here,
|
|
103
|
+
summary: direction === "response" ? `${here} may now be left out` : `${here} is now optional`
|
|
104
|
+
});
|
|
85
105
|
changes.push(...diffSchemas(existing.schema, field.schema, direction, here));
|
|
86
106
|
}
|
|
87
107
|
for (const key of Object.keys(beforeFields)) {
|
|
@@ -95,11 +115,6 @@ const diffSchemas = (before, after, direction, path = "") => {
|
|
|
95
115
|
}
|
|
96
116
|
return changes;
|
|
97
117
|
}
|
|
98
|
-
if (before.kind !== after.kind) return [{
|
|
99
|
-
breaking: true,
|
|
100
|
-
path,
|
|
101
|
-
summary: `${path || "the body"} is ${describeKind(after)} instead of ${describeKind(before)}`
|
|
102
|
-
}];
|
|
103
118
|
const was = valuesOf(before);
|
|
104
119
|
const now = valuesOf(after);
|
|
105
120
|
if (was && now) {
|
|
@@ -142,8 +157,15 @@ const refinementCount = (schema) => {
|
|
|
142
157
|
* A Zod schema reduced to the shape a comparison reads.
|
|
143
158
|
*/
|
|
144
159
|
const toSchemaNode = (schema) => {
|
|
145
|
-
const { inner } = unwrapOptionalWrappers(schema);
|
|
160
|
+
const { inner, nullable } = unwrapOptionalWrappers(schema);
|
|
146
161
|
const def = readDef(inner);
|
|
162
|
+
const options = def.type === "union" ? def.options ?? [] : [];
|
|
163
|
+
const nonNull = options.filter((option) => readDef(option).type !== "null");
|
|
164
|
+
if (nonNull.length === 1 && options.length > 1) return {
|
|
165
|
+
...toSchemaNode(nonNull[0]),
|
|
166
|
+
nullable: true
|
|
167
|
+
};
|
|
168
|
+
const nullability = nullable ? { nullable: true } : {};
|
|
147
169
|
const refinements = refinementCount(inner);
|
|
148
170
|
const carry = refinements === void 0 ? {} : { refinements };
|
|
149
171
|
const shape = readObjectShape(inner);
|
|
@@ -155,27 +177,32 @@ const toSchemaNode = (schema) => {
|
|
|
155
177
|
};
|
|
156
178
|
return {
|
|
157
179
|
kind: "object",
|
|
180
|
+
...nullability,
|
|
158
181
|
fields,
|
|
159
182
|
...carry
|
|
160
183
|
};
|
|
161
184
|
}
|
|
162
185
|
if (def.type === "array" && def.element) return {
|
|
163
186
|
kind: "array",
|
|
187
|
+
...nullability,
|
|
164
188
|
element: toSchemaNode(def.element),
|
|
165
189
|
...carry
|
|
166
190
|
};
|
|
167
191
|
if (def.type === "enum") return {
|
|
168
192
|
kind: "enum",
|
|
193
|
+
...nullability,
|
|
169
194
|
values: Object.values(def.entries ?? {}).map(String).sort(),
|
|
170
195
|
...carry
|
|
171
196
|
};
|
|
172
197
|
if (def.type === "literal") return {
|
|
173
198
|
kind: "enum",
|
|
199
|
+
...nullability,
|
|
174
200
|
values: (def.values ?? []).map(String).sort(),
|
|
175
201
|
...carry
|
|
176
202
|
};
|
|
177
203
|
return {
|
|
178
204
|
kind: def.type ?? "unknown",
|
|
205
|
+
...nullability,
|
|
179
206
|
...carry
|
|
180
207
|
};
|
|
181
208
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizunajs/cli",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.18",
|
|
4
4
|
"description": "Command line tooling for Kizuna.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kizunajs",
|
|
@@ -61,11 +61,11 @@
|
|
|
61
61
|
"yaml": "^2.8.4"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"kizunajs": "2.0.0-beta.
|
|
64
|
+
"kizunajs": "2.0.0-beta.18",
|
|
65
65
|
"zod": "^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"kizunajs": "2.0.0-beta.
|
|
68
|
+
"kizunajs": "2.0.0-beta.18",
|
|
69
69
|
"@types/node": "^24",
|
|
70
70
|
"@types/react": "^19.2.18",
|
|
71
71
|
"tsdown": "^0.21.0",
|