@kizunajs/cli 2.0.0-beta.1 → 2.0.0-beta.10
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 +32 -12
- package/dist/cli.mjs +32 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +71 -20
- package/dist/index.d.mts +71 -20
- package/dist/index.mjs +1 -1
- package/dist/{route-map-D7cBgYmT.mjs → route-map-C484dhbj.mjs} +243 -141
- package/dist/{route-map-DW2UUkD_.cjs → route-map-I400Eb9_.cjs} +265 -139
- package/package.json +6 -4
package/dist/cli.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_route_map = require("./route-map-
|
|
3
|
-
let node_fs = require("node:fs");
|
|
2
|
+
const require_route_map = require("./route-map-I400Eb9_.cjs");
|
|
4
3
|
let node_path = require("node:path");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
5
|
let node_util = require("node:util");
|
|
6
6
|
//#region src/cli.ts
|
|
7
7
|
const usage = `Usage: kizuna <command> [options]
|
|
@@ -24,6 +24,8 @@ generate:
|
|
|
24
24
|
diff:
|
|
25
25
|
--against <ref> The git ref to compare against. Default: main
|
|
26
26
|
Exits 1 when a change breaks callers.
|
|
27
|
+
--from <path> Compare two snapshots directly, with no git and no
|
|
28
|
+
--to <path> config. Pass both.
|
|
27
29
|
`;
|
|
28
30
|
const COMMANDS = [
|
|
29
31
|
"generate",
|
|
@@ -56,23 +58,32 @@ const loadOrDie = async (configPath) => {
|
|
|
56
58
|
if (!config) die(`No config found at ${displayPath(configPath)}. A kizuna config default-exports its \`defineConfig(...)\` call.`);
|
|
57
59
|
return config;
|
|
58
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* A client writes where its config says, not where the command was run from,
|
|
63
|
+
* so `kizuna generate --config apps/api/kizuna.config.ts` lands the same files
|
|
64
|
+
* wherever it is invoked.
|
|
65
|
+
*/
|
|
66
|
+
const besideConfig = (configPath, clients) => clients.map((client) => ({
|
|
67
|
+
...client,
|
|
68
|
+
output: (0, node_path.resolve)((0, node_path.dirname)(configPath), client.output)
|
|
69
|
+
}));
|
|
59
70
|
const runGenerate = async (values) => {
|
|
60
71
|
const configPath = configPathFrom(values.config);
|
|
72
|
+
const config = await loadOrDie(configPath);
|
|
73
|
+
const typesOutput = values.types ?? config.typesOutput;
|
|
74
|
+
if (typesOutput === void 0) die(`${displayPath(configPath)} declares no \`typescript.outputFile\`, which is where the \`Config\` is written. Add one, or pass --types.`);
|
|
75
|
+
const typesPath = (0, node_path.resolve)((0, node_path.dirname)(configPath), typesOutput);
|
|
61
76
|
let types;
|
|
62
77
|
try {
|
|
63
|
-
types = require_route_map.generateConfigTypes((0, node_fs.readFileSync)(configPath, "utf8"), configPath);
|
|
78
|
+
types = require_route_map.generateConfigTypes((0, node_fs.readFileSync)(configPath, "utf8"), configPath, typesPath);
|
|
64
79
|
} catch (error) {
|
|
65
80
|
if (error instanceof require_route_map.ConfigSyntaxError) die(`${displayPath(configPath)}: ${error.message}`);
|
|
66
81
|
throw error;
|
|
67
82
|
}
|
|
68
|
-
const config = await loadOrDie(configPath);
|
|
69
|
-
const typesOutput = values.types ?? config.typesOutput;
|
|
70
|
-
if (typesOutput === void 0) die(`${displayPath(configPath)} declares no \`typescript.outputFile\`, which is where the \`Config\` is written. Add one, or pass --types.`);
|
|
71
|
-
const typesPath = (0, node_path.resolve)((0, node_path.dirname)(configPath), typesOutput);
|
|
72
83
|
const typesCurrent = (0, node_fs.existsSync)(typesPath) ? (0, node_fs.readFileSync)(typesPath, "utf8") : void 0;
|
|
73
84
|
const typesBehind = typesCurrent !== types;
|
|
74
85
|
if (values.check) {
|
|
75
|
-
const stale = require_route_map.checkClients(config.api, config.clients);
|
|
86
|
+
const stale = require_route_map.checkClients(config.api, [...besideConfig(configPath, config.clients), require_route_map.snapshotTarget(configPath)]);
|
|
76
87
|
if (!typesBehind && stale.length === 0) {
|
|
77
88
|
process.stdout.write("Everything kizuna generates is up to date.\n");
|
|
78
89
|
return;
|
|
@@ -82,7 +93,7 @@ const runGenerate = async (values) => {
|
|
|
82
93
|
process.exit(1);
|
|
83
94
|
}
|
|
84
95
|
if (typesBehind) (0, node_fs.writeFileSync)(typesPath, types);
|
|
85
|
-
const written = require_route_map.writeClients(config.api, config.clients);
|
|
96
|
+
const written = require_route_map.writeClients(config.api, [...besideConfig(configPath, config.clients), require_route_map.snapshotTarget(configPath)]);
|
|
86
97
|
const changed = [...typesBehind ? [displayPath(typesPath)] : [], ...written.filter((client) => client.changed).map((client) => displayPath(client.output))];
|
|
87
98
|
process.stdout.write(changed.length > 0 ? `Wrote:\n${changed.map((file) => ` ${file}`).join("\n")}\n` : "Everything was already up to date.\n");
|
|
88
99
|
};
|
|
@@ -91,8 +102,15 @@ const runRoutes = async (values) => {
|
|
|
91
102
|
process.stdout.write(values.json ? `${JSON.stringify(entries, null, 2)}\n` : `${require_route_map.formatRoutes(entries)}\n`);
|
|
92
103
|
};
|
|
93
104
|
const runDiff = async (values) => {
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
let changes;
|
|
106
|
+
if (values.from !== void 0 || values.to !== void 0) {
|
|
107
|
+
if (values.from === void 0 || values.to === void 0) die("Pass --from and --to together, or neither.");
|
|
108
|
+
changes = require_route_map.diffSnapshots(require_route_map.readSnapshot(values.from), require_route_map.readSnapshot(values.to));
|
|
109
|
+
} else {
|
|
110
|
+
const configPath = configPathFrom(values.config);
|
|
111
|
+
const config = await loadOrDie(configPath);
|
|
112
|
+
changes = require_route_map.diffAgainst(values.against ?? "main", require_route_map.snapshotPathFor(configPath), config.diff);
|
|
113
|
+
}
|
|
96
114
|
if (values.json) process.stdout.write(`${JSON.stringify(changes, null, 2)}\n`);
|
|
97
115
|
else if (changes.length === 0) process.stdout.write("Nothing callers depend on has moved.\n");
|
|
98
116
|
else process.stdout.write(`${changes.map((change) => require_route_map.formatChange(change)).join("\n\n")}\n`);
|
|
@@ -109,7 +127,9 @@ const main = async () => {
|
|
|
109
127
|
config: { type: "string" },
|
|
110
128
|
types: { type: "string" },
|
|
111
129
|
json: { type: "boolean" },
|
|
112
|
-
against: { type: "string" }
|
|
130
|
+
against: { type: "string" },
|
|
131
|
+
from: { type: "string" },
|
|
132
|
+
to: { type: "string" }
|
|
113
133
|
},
|
|
114
134
|
strict: true
|
|
115
135
|
});
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as
|
|
3
|
-
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, d as diffSnapshots, f as formatChange, h as snapshotTarget, i as readSnapshot, l as writeClients, m as snapshotPathFor, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkClients, t as formatRoutes } from "./route-map-C484dhbj.mjs";
|
|
4
3
|
import { dirname, relative, resolve } from "node:path";
|
|
4
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { parseArgs } from "node:util";
|
|
6
6
|
//#region src/cli.ts
|
|
7
7
|
const usage = `Usage: kizuna <command> [options]
|
|
@@ -24,6 +24,8 @@ generate:
|
|
|
24
24
|
diff:
|
|
25
25
|
--against <ref> The git ref to compare against. Default: main
|
|
26
26
|
Exits 1 when a change breaks callers.
|
|
27
|
+
--from <path> Compare two snapshots directly, with no git and no
|
|
28
|
+
--to <path> config. Pass both.
|
|
27
29
|
`;
|
|
28
30
|
const COMMANDS = [
|
|
29
31
|
"generate",
|
|
@@ -56,23 +58,32 @@ const loadOrDie = async (configPath) => {
|
|
|
56
58
|
if (!config) die(`No config found at ${displayPath(configPath)}. A kizuna config default-exports its \`defineConfig(...)\` call.`);
|
|
57
59
|
return config;
|
|
58
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* A client writes where its config says, not where the command was run from,
|
|
63
|
+
* so `kizuna generate --config apps/api/kizuna.config.ts` lands the same files
|
|
64
|
+
* wherever it is invoked.
|
|
65
|
+
*/
|
|
66
|
+
const besideConfig = (configPath, clients) => clients.map((client) => ({
|
|
67
|
+
...client,
|
|
68
|
+
output: resolve(dirname(configPath), client.output)
|
|
69
|
+
}));
|
|
59
70
|
const runGenerate = async (values) => {
|
|
60
71
|
const configPath = configPathFrom(values.config);
|
|
72
|
+
const config = await loadOrDie(configPath);
|
|
73
|
+
const typesOutput = values.types ?? config.typesOutput;
|
|
74
|
+
if (typesOutput === void 0) die(`${displayPath(configPath)} declares no \`typescript.outputFile\`, which is where the \`Config\` is written. Add one, or pass --types.`);
|
|
75
|
+
const typesPath = resolve(dirname(configPath), typesOutput);
|
|
61
76
|
let types;
|
|
62
77
|
try {
|
|
63
|
-
types = generateConfigTypes(readFileSync(configPath, "utf8"), configPath);
|
|
78
|
+
types = generateConfigTypes(readFileSync(configPath, "utf8"), configPath, typesPath);
|
|
64
79
|
} catch (error) {
|
|
65
80
|
if (error instanceof ConfigSyntaxError) die(`${displayPath(configPath)}: ${error.message}`);
|
|
66
81
|
throw error;
|
|
67
82
|
}
|
|
68
|
-
const config = await loadOrDie(configPath);
|
|
69
|
-
const typesOutput = values.types ?? config.typesOutput;
|
|
70
|
-
if (typesOutput === void 0) die(`${displayPath(configPath)} declares no \`typescript.outputFile\`, which is where the \`Config\` is written. Add one, or pass --types.`);
|
|
71
|
-
const typesPath = resolve(dirname(configPath), typesOutput);
|
|
72
83
|
const typesCurrent = existsSync(typesPath) ? readFileSync(typesPath, "utf8") : void 0;
|
|
73
84
|
const typesBehind = typesCurrent !== types;
|
|
74
85
|
if (values.check) {
|
|
75
|
-
const stale = checkClients(config.api, config.clients);
|
|
86
|
+
const stale = checkClients(config.api, [...besideConfig(configPath, config.clients), snapshotTarget(configPath)]);
|
|
76
87
|
if (!typesBehind && stale.length === 0) {
|
|
77
88
|
process.stdout.write("Everything kizuna generates is up to date.\n");
|
|
78
89
|
return;
|
|
@@ -82,7 +93,7 @@ const runGenerate = async (values) => {
|
|
|
82
93
|
process.exit(1);
|
|
83
94
|
}
|
|
84
95
|
if (typesBehind) writeFileSync(typesPath, types);
|
|
85
|
-
const written = writeClients(config.api, config.clients);
|
|
96
|
+
const written = writeClients(config.api, [...besideConfig(configPath, config.clients), snapshotTarget(configPath)]);
|
|
86
97
|
const changed = [...typesBehind ? [displayPath(typesPath)] : [], ...written.filter((client) => client.changed).map((client) => displayPath(client.output))];
|
|
87
98
|
process.stdout.write(changed.length > 0 ? `Wrote:\n${changed.map((file) => ` ${file}`).join("\n")}\n` : "Everything was already up to date.\n");
|
|
88
99
|
};
|
|
@@ -91,8 +102,15 @@ const runRoutes = async (values) => {
|
|
|
91
102
|
process.stdout.write(values.json ? `${JSON.stringify(entries, null, 2)}\n` : `${formatRoutes(entries)}\n`);
|
|
92
103
|
};
|
|
93
104
|
const runDiff = async (values) => {
|
|
94
|
-
|
|
95
|
-
|
|
105
|
+
let changes;
|
|
106
|
+
if (values.from !== void 0 || values.to !== void 0) {
|
|
107
|
+
if (values.from === void 0 || values.to === void 0) die("Pass --from and --to together, or neither.");
|
|
108
|
+
changes = diffSnapshots(readSnapshot(values.from), readSnapshot(values.to));
|
|
109
|
+
} else {
|
|
110
|
+
const configPath = configPathFrom(values.config);
|
|
111
|
+
const config = await loadOrDie(configPath);
|
|
112
|
+
changes = diffAgainst(values.against ?? "main", snapshotPathFor(configPath), config.diff);
|
|
113
|
+
}
|
|
96
114
|
if (values.json) process.stdout.write(`${JSON.stringify(changes, null, 2)}\n`);
|
|
97
115
|
else if (changes.length === 0) process.stdout.write("Nothing callers depend on has moved.\n");
|
|
98
116
|
else process.stdout.write(`${changes.map((change) => formatChange(change)).join("\n\n")}\n`);
|
|
@@ -109,7 +127,9 @@ const main = async () => {
|
|
|
109
127
|
config: { type: "string" },
|
|
110
128
|
types: { type: "string" },
|
|
111
129
|
json: { type: "boolean" },
|
|
112
|
-
against: { type: "string" }
|
|
130
|
+
against: { type: "string" },
|
|
131
|
+
from: { type: "string" },
|
|
132
|
+
to: { type: "string" }
|
|
113
133
|
},
|
|
114
134
|
strict: true
|
|
115
135
|
});
|
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-I400Eb9_.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
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _$kizunajs from "kizunajs";
|
|
2
|
-
import { ApiDefinition, ClientTarget } from "kizunajs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
2
|
+
import { ApiDefinition, ClientTarget, DiffSettings } from "kizunajs";
|
|
5
3
|
//#region src/load-config.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* One api a config declares, with everything generated from it. A config that
|
|
@@ -15,6 +13,10 @@ interface LoadedApi {
|
|
|
15
13
|
* Where `kizuna generate` writes the `Config`, when the config says.
|
|
16
14
|
*/
|
|
17
15
|
typesOutput: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* What else `kizuna diff` treats as breaking.
|
|
18
|
+
*/
|
|
19
|
+
diff: DiffSettings;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Imports a config module with jiti, so a `.ts` config works without a build
|
|
@@ -69,6 +71,31 @@ declare const apiNotices: (contract: _$kizunajs.ApiDefinition, options: {
|
|
|
69
71
|
*/
|
|
70
72
|
declare const formatNotice: (notice: Notice) => string;
|
|
71
73
|
//#endregion
|
|
74
|
+
//#region src/snapshot.d.ts
|
|
75
|
+
/**
|
|
76
|
+
* A schema reduced to what a comparison needs: its kind, its fields, and the
|
|
77
|
+
* values it accepts when it is closed.
|
|
78
|
+
*/
|
|
79
|
+
type SchemaNode = {
|
|
80
|
+
kind: 'object';
|
|
81
|
+
fields: Record<string, {
|
|
82
|
+
optional: boolean;
|
|
83
|
+
schema: SchemaNode;
|
|
84
|
+
}>;
|
|
85
|
+
refinements?: number;
|
|
86
|
+
} | {
|
|
87
|
+
kind: 'array';
|
|
88
|
+
element: SchemaNode;
|
|
89
|
+
refinements?: number;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'enum';
|
|
92
|
+
values: string[];
|
|
93
|
+
refinements?: number;
|
|
94
|
+
} | {
|
|
95
|
+
kind: string;
|
|
96
|
+
refinements?: number;
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
72
99
|
//#region src/diff-apis.d.ts
|
|
73
100
|
/**
|
|
74
101
|
* How much a change asks of the people already calling an API.
|
|
@@ -86,13 +113,38 @@ interface Change {
|
|
|
86
113
|
*/
|
|
87
114
|
detail?: string;
|
|
88
115
|
}
|
|
116
|
+
interface DiffOptions {
|
|
117
|
+
/**
|
|
118
|
+
* Report a job key that is gone. A job answers `POST /jobs/run` by its
|
|
119
|
+
* dotted key, so this matters once something outside your own code
|
|
120
|
+
* dispatches them.
|
|
121
|
+
*
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
124
|
+
jobs?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Report an MCP tool a model can no longer call.
|
|
127
|
+
*
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
tools?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Treat a renamed dotted key, such as `users.getUser` becoming
|
|
133
|
+
* `users.fetchUser`, as breaking. The key names the method on a generated
|
|
134
|
+
* client, so a rename breaks anyone building an SDK on one and leaves the
|
|
135
|
+
* HTTP surface untouched.
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
dottedKeys?: boolean;
|
|
140
|
+
}
|
|
89
141
|
/**
|
|
90
|
-
* What changed between two apis,
|
|
142
|
+
* What changed between two apis, for a caller holding both in memory.
|
|
91
143
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
144
|
+
* `kizuna diff` reads snapshots instead, so it never has to load the other
|
|
145
|
+
* side's code.
|
|
94
146
|
*/
|
|
95
|
-
declare const diffApis: (before: ApiDefinition, after: ApiDefinition) => Change[];
|
|
147
|
+
declare const diffApis: (before: ApiDefinition, after: ApiDefinition, options?: DiffOptions) => Change[];
|
|
96
148
|
/**
|
|
97
149
|
* One block per change, ready to print: the level, the summary, and the
|
|
98
150
|
* detail indented beneath it.
|
|
@@ -150,8 +202,11 @@ declare class ConfigSyntaxError extends Error {}
|
|
|
150
202
|
* Read from the config's syntax rather than by running it: the generated file
|
|
151
203
|
* imports the same names the config did, and a config that loads is not a
|
|
152
204
|
* prerequisite for typing the routes it serves.
|
|
205
|
+
*
|
|
206
|
+
* `outputPath` is what the imports are written relative to. Left out, they stay
|
|
207
|
+
* relative to the config.
|
|
153
208
|
*/
|
|
154
|
-
declare const generateConfigTypes: (configSource: string, fileName?: string) => string;
|
|
209
|
+
declare const generateConfigTypes: (configSource: string, fileName?: string, outputPath?: string) => string;
|
|
155
210
|
//#endregion
|
|
156
211
|
//#region src/diff-schemas.d.ts
|
|
157
212
|
/**
|
|
@@ -173,29 +228,25 @@ interface SchemaChange {
|
|
|
173
228
|
* What changed between two versions of one schema, and whether it breaks the
|
|
174
229
|
* people already calling the route.
|
|
175
230
|
*/
|
|
176
|
-
declare const diffSchemas: (before:
|
|
231
|
+
declare const diffSchemas: (before: SchemaNode | undefined, after: SchemaNode | undefined, direction: Direction, path?: string) => SchemaChange[];
|
|
177
232
|
//#endregion
|
|
178
233
|
//#region src/diff-against.d.ts
|
|
179
|
-
interface DiffAgainstOptions {
|
|
234
|
+
interface DiffAgainstOptions extends DiffOptions {
|
|
180
235
|
/**
|
|
181
|
-
*
|
|
236
|
+
* Where a relative path is resolved from.
|
|
182
237
|
*
|
|
183
238
|
* @default process.cwd()
|
|
184
239
|
*/
|
|
185
240
|
cwd?: string;
|
|
186
241
|
}
|
|
187
242
|
/**
|
|
188
|
-
* Compares
|
|
243
|
+
* Compares a snapshot against the same file at a git ref.
|
|
189
244
|
*
|
|
190
|
-
* The ref is
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* its source.
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* const changes = await diffAgainst('main', './src/contract.ts');
|
|
245
|
+
* The ref is read with `git show`, so nothing is checked out, installed or
|
|
246
|
+
* executed for the other side. A snapshot written a year ago compares fine
|
|
247
|
+
* against one written today.
|
|
197
248
|
*/
|
|
198
|
-
declare const diffAgainst: (ref: string,
|
|
249
|
+
declare const diffAgainst: (ref: string, snapshotPath: string, options?: DiffAgainstOptions) => Change[];
|
|
199
250
|
//#endregion
|
|
200
251
|
//#region src/route-map.d.ts
|
|
201
252
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as _$kizunajs from "kizunajs";
|
|
2
|
-
import { ApiDefinition, ClientTarget } from "kizunajs";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
|
|
2
|
+
import { ApiDefinition, ClientTarget, DiffSettings } from "kizunajs";
|
|
5
3
|
//#region src/load-config.d.ts
|
|
6
4
|
/**
|
|
7
5
|
* One api a config declares, with everything generated from it. A config that
|
|
@@ -15,6 +13,10 @@ interface LoadedApi {
|
|
|
15
13
|
* Where `kizuna generate` writes the `Config`, when the config says.
|
|
16
14
|
*/
|
|
17
15
|
typesOutput: string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* What else `kizuna diff` treats as breaking.
|
|
18
|
+
*/
|
|
19
|
+
diff: DiffSettings;
|
|
18
20
|
}
|
|
19
21
|
/**
|
|
20
22
|
* Imports a config module with jiti, so a `.ts` config works without a build
|
|
@@ -69,6 +71,31 @@ declare const apiNotices: (contract: _$kizunajs.ApiDefinition, options: {
|
|
|
69
71
|
*/
|
|
70
72
|
declare const formatNotice: (notice: Notice) => string;
|
|
71
73
|
//#endregion
|
|
74
|
+
//#region src/snapshot.d.ts
|
|
75
|
+
/**
|
|
76
|
+
* A schema reduced to what a comparison needs: its kind, its fields, and the
|
|
77
|
+
* values it accepts when it is closed.
|
|
78
|
+
*/
|
|
79
|
+
type SchemaNode = {
|
|
80
|
+
kind: 'object';
|
|
81
|
+
fields: Record<string, {
|
|
82
|
+
optional: boolean;
|
|
83
|
+
schema: SchemaNode;
|
|
84
|
+
}>;
|
|
85
|
+
refinements?: number;
|
|
86
|
+
} | {
|
|
87
|
+
kind: 'array';
|
|
88
|
+
element: SchemaNode;
|
|
89
|
+
refinements?: number;
|
|
90
|
+
} | {
|
|
91
|
+
kind: 'enum';
|
|
92
|
+
values: string[];
|
|
93
|
+
refinements?: number;
|
|
94
|
+
} | {
|
|
95
|
+
kind: string;
|
|
96
|
+
refinements?: number;
|
|
97
|
+
};
|
|
98
|
+
//#endregion
|
|
72
99
|
//#region src/diff-apis.d.ts
|
|
73
100
|
/**
|
|
74
101
|
* How much a change asks of the people already calling an API.
|
|
@@ -86,13 +113,38 @@ interface Change {
|
|
|
86
113
|
*/
|
|
87
114
|
detail?: string;
|
|
88
115
|
}
|
|
116
|
+
interface DiffOptions {
|
|
117
|
+
/**
|
|
118
|
+
* Report a job key that is gone. A job answers `POST /jobs/run` by its
|
|
119
|
+
* dotted key, so this matters once something outside your own code
|
|
120
|
+
* dispatches them.
|
|
121
|
+
*
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
124
|
+
jobs?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Report an MCP tool a model can no longer call.
|
|
127
|
+
*
|
|
128
|
+
* @default false
|
|
129
|
+
*/
|
|
130
|
+
tools?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Treat a renamed dotted key, such as `users.getUser` becoming
|
|
133
|
+
* `users.fetchUser`, as breaking. The key names the method on a generated
|
|
134
|
+
* client, so a rename breaks anyone building an SDK on one and leaves the
|
|
135
|
+
* HTTP surface untouched.
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
dottedKeys?: boolean;
|
|
140
|
+
}
|
|
89
141
|
/**
|
|
90
|
-
* What changed between two apis,
|
|
142
|
+
* What changed between two apis, for a caller holding both in memory.
|
|
91
143
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
144
|
+
* `kizuna diff` reads snapshots instead, so it never has to load the other
|
|
145
|
+
* side's code.
|
|
94
146
|
*/
|
|
95
|
-
declare const diffApis: (before: ApiDefinition, after: ApiDefinition) => Change[];
|
|
147
|
+
declare const diffApis: (before: ApiDefinition, after: ApiDefinition, options?: DiffOptions) => Change[];
|
|
96
148
|
/**
|
|
97
149
|
* One block per change, ready to print: the level, the summary, and the
|
|
98
150
|
* detail indented beneath it.
|
|
@@ -150,8 +202,11 @@ declare class ConfigSyntaxError extends Error {}
|
|
|
150
202
|
* Read from the config's syntax rather than by running it: the generated file
|
|
151
203
|
* imports the same names the config did, and a config that loads is not a
|
|
152
204
|
* prerequisite for typing the routes it serves.
|
|
205
|
+
*
|
|
206
|
+
* `outputPath` is what the imports are written relative to. Left out, they stay
|
|
207
|
+
* relative to the config.
|
|
153
208
|
*/
|
|
154
|
-
declare const generateConfigTypes: (configSource: string, fileName?: string) => string;
|
|
209
|
+
declare const generateConfigTypes: (configSource: string, fileName?: string, outputPath?: string) => string;
|
|
155
210
|
//#endregion
|
|
156
211
|
//#region src/diff-schemas.d.ts
|
|
157
212
|
/**
|
|
@@ -173,29 +228,25 @@ interface SchemaChange {
|
|
|
173
228
|
* What changed between two versions of one schema, and whether it breaks the
|
|
174
229
|
* people already calling the route.
|
|
175
230
|
*/
|
|
176
|
-
declare const diffSchemas: (before:
|
|
231
|
+
declare const diffSchemas: (before: SchemaNode | undefined, after: SchemaNode | undefined, direction: Direction, path?: string) => SchemaChange[];
|
|
177
232
|
//#endregion
|
|
178
233
|
//#region src/diff-against.d.ts
|
|
179
|
-
interface DiffAgainstOptions {
|
|
234
|
+
interface DiffAgainstOptions extends DiffOptions {
|
|
180
235
|
/**
|
|
181
|
-
*
|
|
236
|
+
* Where a relative path is resolved from.
|
|
182
237
|
*
|
|
183
238
|
* @default process.cwd()
|
|
184
239
|
*/
|
|
185
240
|
cwd?: string;
|
|
186
241
|
}
|
|
187
242
|
/**
|
|
188
|
-
* Compares
|
|
243
|
+
* Compares a snapshot against the same file at a git ref.
|
|
189
244
|
*
|
|
190
|
-
* The ref is
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
* its source.
|
|
194
|
-
*
|
|
195
|
-
* @example
|
|
196
|
-
* const changes = await diffAgainst('main', './src/contract.ts');
|
|
245
|
+
* The ref is read with `git show`, so nothing is checked out, installed or
|
|
246
|
+
* executed for the other side. A snapshot written a year ago compares fine
|
|
247
|
+
* against one written today.
|
|
197
248
|
*/
|
|
198
|
-
declare const diffAgainst: (ref: string,
|
|
249
|
+
declare const diffAgainst: (ref: string, snapshotPath: string, options?: DiffAgainstOptions) => Change[];
|
|
199
250
|
//#endregion
|
|
200
251
|
//#region src/route-map.d.ts
|
|
201
252
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, f as formatChange, g as diffSchemas, l as writeClients, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkClients, t as formatRoutes, u as diffApis } from "./route-map-C484dhbj.mjs";
|
|
2
2
|
import { createGenerator } from "kizunajs/generator";
|
|
3
3
|
//#region src/api-notices.ts
|
|
4
4
|
const readSunset = (route) => {
|