@niscorp/strata 0.1.1 → 0.1.4
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/CHANGELOG.md +83 -0
- package/DESIGN.md +7 -3
- package/README.md +19 -4
- package/dist/check/index.cjs +23 -217
- package/dist/check/index.cjs.map +1 -1
- package/dist/check/index.js +2 -2
- package/dist/{chunk-MY3TGSV3.js → chunk-4BLHBVSC.js} +15 -4
- package/dist/chunk-4BLHBVSC.js.map +1 -0
- package/dist/{chunk-U5CPF4LQ.js → chunk-5KTXEN43.js} +3 -3
- package/dist/{chunk-U5CPF4LQ.js.map → chunk-5KTXEN43.js.map} +1 -1
- package/dist/{chunk-EGFF63GA.js → chunk-AKKWEXO2.js} +2 -2
- package/dist/{chunk-EGFF63GA.js.map → chunk-AKKWEXO2.js.map} +1 -1
- package/dist/chunk-ATHZ7HT5.cjs +18 -0
- package/dist/chunk-ATHZ7HT5.cjs.map +1 -0
- package/dist/chunk-CL5DF2IQ.cjs +192 -0
- package/dist/chunk-CL5DF2IQ.cjs.map +1 -0
- package/dist/chunk-IHYBGLNW.cjs +161 -0
- package/dist/chunk-IHYBGLNW.cjs.map +1 -0
- package/dist/chunk-KNBS3AJZ.cjs +223 -0
- package/dist/chunk-KNBS3AJZ.cjs.map +1 -0
- package/dist/{chunk-ICWKTTKN.js → chunk-OLDORFOQ.js} +12 -7
- package/dist/chunk-OLDORFOQ.js.map +1 -0
- package/dist/{chunk-HMT7HHFJ.js → chunk-WU3OJHVZ.js} +4 -4
- package/dist/{chunk-HMT7HHFJ.js.map → chunk-WU3OJHVZ.js.map} +1 -1
- package/dist/chunk-YXFEJJMC.cjs +136 -0
- package/dist/chunk-YXFEJJMC.cjs.map +1 -0
- package/dist/index.cjs +75 -325
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/node/index.cjs +14 -477
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +5 -5
- package/dist/{plan-BEIlXVUt.d.cts → plan-CxuteSH1.d.cts} +2 -2
- package/dist/{plan-BAewc8DG.d.ts → plan-mFmdh0qT.d.ts} +2 -2
- package/dist/postgres/index.cjs +36 -206
- package/dist/postgres/index.cjs.map +1 -1
- package/dist/postgres/index.d.cts +7 -2
- package/dist/postgres/index.d.ts +7 -2
- package/dist/postgres/index.js +24 -12
- package/dist/postgres/index.js.map +1 -1
- package/dist/upgrade/index.cjs +19 -229
- package/dist/upgrade/index.cjs.map +1 -1
- package/dist/upgrade/index.js +3 -3
- package/package.json +3 -2
- package/dist/chunk-ICWKTTKN.js.map +0 -1
- package/dist/chunk-MY3TGSV3.js.map +0 -1
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkKNBS3AJZ_cjs = require('./chunk-KNBS3AJZ.cjs');
|
|
4
|
+
var chunkATHZ7HT5_cjs = require('./chunk-ATHZ7HT5.cjs');
|
|
5
|
+
|
|
6
|
+
// src/upgrade/index.ts
|
|
7
|
+
var keyOf = (doc) => `${doc.kind}:${doc.id}`;
|
|
8
|
+
var sortKeys = (value) => {
|
|
9
|
+
if (Array.isArray(value)) return value.map(sortKeys);
|
|
10
|
+
if (typeof value !== "object" || value === null) return value;
|
|
11
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([k, v]) => [k, sortKeys(v)]));
|
|
12
|
+
};
|
|
13
|
+
var sameJson = (a, b) => JSON.stringify(sortKeys(a)) === JSON.stringify(sortKeys(b));
|
|
14
|
+
var changedStrings = (before, after) => {
|
|
15
|
+
const found = /* @__PURE__ */ new Set();
|
|
16
|
+
const visit = (a, b) => {
|
|
17
|
+
if (JSON.stringify(a) === JSON.stringify(b)) return;
|
|
18
|
+
if (typeof a === "string") {
|
|
19
|
+
found.add(a);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (Array.isArray(a)) {
|
|
23
|
+
a.forEach((item, i) => visit(item, Array.isArray(b) ? b[i] : void 0));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (typeof a === "object" && a !== null) {
|
|
27
|
+
for (const [k, v] of Object.entries(a)) visit(v, typeof b === "object" && b !== null && !Array.isArray(b) ? Reflect.get(b, k) : void 0);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
visit(before, after);
|
|
31
|
+
return [...found].filter((s) => s.length >= 4);
|
|
32
|
+
};
|
|
33
|
+
var planSourceUpgrade = async (options) => {
|
|
34
|
+
const { upgrader, stamp, documents, schemas, describe } = options;
|
|
35
|
+
const seen = /* @__PURE__ */ new Set();
|
|
36
|
+
const planned = [];
|
|
37
|
+
const untouched = [];
|
|
38
|
+
const problems = [];
|
|
39
|
+
for (const doc of documents) {
|
|
40
|
+
const key = keyOf(doc);
|
|
41
|
+
if (seen.has(key)) throw new chunkATHZ7HT5_cjs.StrataError("INVALID_SEQUENCE", `Two artifacts are both ${key} \u2014 an artifact needs one identity to be planned.`);
|
|
42
|
+
seen.add(key);
|
|
43
|
+
const result = upgrader.upgrade(doc.document, { kind: doc.kind, stamp });
|
|
44
|
+
if (sameJson(result.document, doc.document)) {
|
|
45
|
+
untouched.push(key);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
planned.push({
|
|
49
|
+
kind: doc.kind,
|
|
50
|
+
id: doc.id,
|
|
51
|
+
...doc.file === void 0 ? {} : { file: doc.file },
|
|
52
|
+
applied: result.applied,
|
|
53
|
+
changes: chunkKNBS3AJZ_cjs.diffJson(doc.document, result.document),
|
|
54
|
+
expected: result.document
|
|
55
|
+
});
|
|
56
|
+
const schema = schemas?.[doc.kind];
|
|
57
|
+
if (schema !== void 0) {
|
|
58
|
+
const checked = await schema["~standard"].validate(result.document);
|
|
59
|
+
if (checked.issues !== void 0) {
|
|
60
|
+
problems.push(`${key}: the migrated artifact does not pass ${doc.kind}'s current schema \u2014 ${checked.issues.slice(0, 2).map((i) => i.message).join("; ")}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const from = stamp;
|
|
65
|
+
const to = upgrader.stamp;
|
|
66
|
+
const migrations = Object.entries(to).flatMap(
|
|
67
|
+
([id, n]) => Array.from({ length: Math.max(0, n - (from[id] ?? 0)) }, (_, i) => `${id}/${(from[id] ?? 0) + i + 1}`)
|
|
68
|
+
);
|
|
69
|
+
return {
|
|
70
|
+
from,
|
|
71
|
+
to,
|
|
72
|
+
migrations: migrations.map((ref) => ({ ref, description: describe(ref) })),
|
|
73
|
+
documents: planned.sort((a, b) => keyOf(a) < keyOf(b) ? -1 : 1),
|
|
74
|
+
untouched: untouched.sort(),
|
|
75
|
+
problems
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
var verifySourceUpgrade = (options) => {
|
|
79
|
+
const { plan, upgrader, documents } = options;
|
|
80
|
+
const now = new Map(documents.map((d) => [keyOf(d), d]));
|
|
81
|
+
const lines = [];
|
|
82
|
+
for (const want of plan.documents) {
|
|
83
|
+
const key = keyOf(want);
|
|
84
|
+
const got = now.get(key);
|
|
85
|
+
if (got === void 0) {
|
|
86
|
+
lines.push({ ok: false, text: `${key} is gone \u2014 the plan expected it rewritten, not removed` });
|
|
87
|
+
} else if (sameJson(got.document, want.expected)) {
|
|
88
|
+
lines.push({ ok: true, text: `${key} matches its migrated JSON` });
|
|
89
|
+
} else {
|
|
90
|
+
lines.push({ ok: false, text: `${key} does not match its migrated JSON yet`, detail: chunkKNBS3AJZ_cjs.diffJson(got.document, want.expected, 12) });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
for (const key of plan.untouched) {
|
|
94
|
+
const got = now.get(key);
|
|
95
|
+
if (got === void 0) {
|
|
96
|
+
lines.push({ ok: false, text: `${key} is gone \u2014 no migration asked for that` });
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const again = upgrader.upgrade(got.document, { kind: got.kind, stamp: plan.from });
|
|
100
|
+
if (!sameJson(again.document, got.document)) {
|
|
101
|
+
lines.push({ ok: false, text: `${key} was not in the plan, but the migrations would change it now`, detail: chunkKNBS3AJZ_cjs.diffJson(got.document, again.document, 12) });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const known = /* @__PURE__ */ new Set([...plan.documents.map(keyOf), ...plan.untouched]);
|
|
105
|
+
for (const key of now.keys()) {
|
|
106
|
+
if (!known.has(key)) lines.push({ ok: false, text: `${key} is new since the plan \u2014 plan again so it is checked too` });
|
|
107
|
+
}
|
|
108
|
+
const ok = lines.every((l) => l.ok);
|
|
109
|
+
if (ok) lines.push({ ok: true, text: `${plan.untouched.length} artifact(s) no migration touches, still untouched` });
|
|
110
|
+
return { ok, lines };
|
|
111
|
+
};
|
|
112
|
+
var renderReport = (plan, expectedPathOf) => {
|
|
113
|
+
const stamp = (s) => Object.entries(s).map(([k, v]) => `${k} ${v}`).join(", ");
|
|
114
|
+
const out = [
|
|
115
|
+
"# strata upgrade",
|
|
116
|
+
"",
|
|
117
|
+
`The source is written at **${stamp(plan.from)}**; the installed grammars are at **${stamp(plan.to)}**.`,
|
|
118
|
+
"",
|
|
119
|
+
"## Migrations",
|
|
120
|
+
"",
|
|
121
|
+
...plan.migrations.map((m) => `- \`${m.ref}\` \u2014 ${m.description}`),
|
|
122
|
+
""
|
|
123
|
+
];
|
|
124
|
+
if (plan.problems.length > 0) {
|
|
125
|
+
out.push("## Stop: a migration is wrong", "", "These artifacts would not pass their current schema after migrating \u2014 no edit can make `verify` pass. Fix the migration, then plan again.", "", ...plan.problems.map((p) => `- ${p}`), "");
|
|
126
|
+
}
|
|
127
|
+
if (plan.documents.length === 0) {
|
|
128
|
+
out.push("## Nothing to edit", "", `No artifact changes (${plan.untouched.length} checked). Run \`verify\` to move the lock.`, "");
|
|
129
|
+
} else {
|
|
130
|
+
out.push(
|
|
131
|
+
`## ${plan.documents.length} artifact(s) to edit`,
|
|
132
|
+
"",
|
|
133
|
+
"Edit each so that it serialises to EXACTLY its expected JSON (key order aside) \u2014 then run `verify`. Only what is listed changes; every other artifact must stay as it is.",
|
|
134
|
+
""
|
|
135
|
+
);
|
|
136
|
+
for (const doc of plan.documents) {
|
|
137
|
+
out.push(
|
|
138
|
+
`### \`${doc.id}\` (${doc.kind})`,
|
|
139
|
+
"",
|
|
140
|
+
doc.file === void 0 ? "" : `- **File:** \`${doc.file}\``,
|
|
141
|
+
doc.lookIn === void 0 || doc.lookIn.length === 0 ? "" : `- **Look in:** ${doc.lookIn.map((f) => `\`${f}\``).join(", ")} \u2014 where the changing values are written`,
|
|
142
|
+
`- **Migrations:** ${doc.applied.map((r) => `\`${r}\``).join(", ")}`,
|
|
143
|
+
`- **Expected JSON:** \`${expectedPathOf(doc)}\``,
|
|
144
|
+
"- **Changes:**",
|
|
145
|
+
"",
|
|
146
|
+
"```",
|
|
147
|
+
...doc.changes,
|
|
148
|
+
"```",
|
|
149
|
+
""
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return out.filter((line, i, all) => !(line === "" && all[i - 1] === "")).join("\n");
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
exports.changedStrings = changedStrings;
|
|
157
|
+
exports.planSourceUpgrade = planSourceUpgrade;
|
|
158
|
+
exports.renderReport = renderReport;
|
|
159
|
+
exports.verifySourceUpgrade = verifySourceUpgrade;
|
|
160
|
+
//# sourceMappingURL=chunk-IHYBGLNW.cjs.map
|
|
161
|
+
//# sourceMappingURL=chunk-IHYBGLNW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/upgrade/index.ts"],"names":["StrataError","diffJson"],"mappings":";;;;;;AAqDA,IAAM,KAAA,GAAQ,CAAC,GAAA,KAA8C,CAAA,EAAG,IAAI,IAAI,CAAA,CAAA,EAAI,IAAI,EAAE,CAAA,CAAA;AAElF,IAAM,QAAA,GAAW,CAAC,KAAA,KAA4B;AAC5C,EAAA,IA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AI,IAAA,KAAS,MAAA,GAAY,EAAA,GAAK,CAAA,cAAA,EAAiB,IAAI,IAAI,CAAA,EAAA,CAAA;AAAA,QACrG,GAAA,CAAI,WAAW,MAAA,IAAa,GAAA,CAAI,OAAO,MAAA,KAAW,CAAA,GAAI,KAAK,CAAA,eAAA,EAAkB,GAAA,CAAI,OAAO,GAAA,CAAI,CAAC,MAAM,CAAA,EAAA,EAAK,CAAC,IAAI,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,6CAAA,CAAA;AAAA,QAA4C,CAAA,kBAAA,EAAqB,GAAA,CAAI,OAAA,CAAQ,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,EAAA,EAAK,CAAC,CAAA,EAAA,CAAI,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,QAAI,CAAA,uBAAA,EAA0B,cAAA,CAAe,GAAG,CAAC,CAAA,EAAA,CAAA;AAAA,QAAM,gBAAA;AAAA,QAAkB,EAAA;AAAA,QAAI,KAAA;AAAA,QAAO,GAAG,GAAA,CAAI,OAAA;AAAA,QAAS,KAAA;AAAA,QAAO;AAAA,OAAE;AAAA,IACxV;AAAA,EACF;AACA,EAAA,OAAO,IAAI,MAAA,CAAO,CAAC,IAAA,EAAM,CAAA,EAAG,QAAQ,EAAE,IAAA,KAAS,EAAA,IAAM,GAAA,CAAI,IAAI,CAAC,CAAA,KAAM,EAAA,CAAG,CAAA,CAAE,KAAK,IAAI,CAAA;AACpF","file":"chunk-IHYBGLNW.cjs","sourcesContent":["import type { Stamp, Upgrader } from '../documents';\nimport { diffJson, type GrammarSchema } from '../check';\nimport { StrataError } from '../errors';\n\n// ═══════════════════════════════════════════════════════════════\n// @niscorp/strata/upgrade — artifacts in an app's SOURCE, brought forward.\n//\n// Rows and submissions are upgraded where they are read. Source files are\n// different: they are TypeScript, written by people, and rewriting them by\n// machine means a codemod that would have to understand every way a person\n// can write an object. So strata does not edit them. It works out, from the\n// migrations, EXACTLY what each artifact must become — and then checks that\n// whoever did the editing (a person, an agent) landed on it, byte for byte.\n//\n// plan the lock says the source is written at stamp S; the installed\n// grammars are ahead. Every artifact is upgraded from S: the ones\n// that change get their expected JSON and a diff; the rest are noted.\n// (edit) anyone — the report says which artifact, which migration, what\n// changes, and where the expected JSON is.\n// verify the edited source, read again: every planned artifact equals its\n// expected JSON; every other one is still one no migration touches.\n// Then — and only then — the lock moves.\n//\n// Pure: documents in, plans out. `@niscorp/strata/node` does the files.\n// ═══════════════════════════════════════════════════════════════\n\nexport type SourceDocument = { kind: string; id: string; document: unknown; file?: string };\n\nexport type PlannedDocument = {\n kind: string;\n id: string;\n file?: string;\n // Files that contain what changes — the artifact's own file names only where\n // its id is written; the layout it imports is often where the edit goes.\n lookIn?: readonly string[];\n applied: readonly string[];\n changes: readonly string[];\n expected: unknown;\n};\n\nexport type SourcePlan = {\n from: Stamp;\n to: Stamp;\n migrations: readonly { ref: string; description: string }[];\n // Artifacts the migrations change — the whole to-do list.\n documents: readonly PlannedDocument[];\n // Artifacts no pending migration touches (by kind:id) — verify checks they stay that way.\n untouched: readonly string[];\n // An expected document that does not pass its kind's current schema: the\n // MIGRATION is wrong, and no edit could make verify pass. Fix it first.\n problems: readonly string[];\n};\n\nconst keyOf = (doc: { kind: string; id: string }): string => `${doc.kind}:${doc.id}`;\n\nconst sortKeys = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(sortKeys);\n if (typeof value !== 'object' || value === null) return value;\n return Object.fromEntries(Object.entries(value).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([k, v]) => [k, sortKeys(v)]));\n};\n// Equal as JSON: key order is how a person happened to write the object, not content.\nconst sameJson = (a: unknown, b: unknown): boolean => JSON.stringify(sortKeys(a)) === JSON.stringify(sortKeys(b));\n\n// The string values a migration removes or rewrites — what to search the\n// source for to find where an edit goes.\nexport const changedStrings = (before: unknown, after: unknown): string[] => {\n const found = new Set<string>();\n const visit = (a: unknown, b: unknown): void => {\n if (JSON.stringify(a) === JSON.stringify(b)) return;\n if (typeof a === 'string') {\n found.add(a);\n return;\n }\n if (Array.isArray(a)) {\n a.forEach((item, i) => visit(item, Array.isArray(b) ? b[i] : undefined));\n return;\n }\n if (typeof a === 'object' && a !== null) {\n for (const [k, v] of Object.entries(a)) visit(v, typeof b === 'object' && b !== null && !Array.isArray(b) ? Reflect.get(b, k) : undefined);\n }\n };\n visit(before, after);\n return [...found].filter((s) => s.length >= 4);\n};\n\nexport const planSourceUpgrade = async (options: {\n upgrader: Upgrader;\n stamp: Stamp;\n documents: readonly SourceDocument[];\n schemas?: Readonly<Record<string, GrammarSchema>>;\n // Every migration the upgrader would run from `stamp`, for the report — the\n // host passes the grammar sequences' descriptions.\n describe: (ref: string) => string;\n}): Promise<SourcePlan> => {\n const { upgrader, stamp, documents, schemas, describe } = options;\n const seen = new Set<string>();\n const planned: PlannedDocument[] = [];\n const untouched: string[] = [];\n const problems: string[] = [];\n\n for (const doc of documents) {\n const key = keyOf(doc);\n if (seen.has(key)) throw new StrataError('INVALID_SEQUENCE', `Two artifacts are both ${key} — an artifact needs one identity to be planned.`);\n seen.add(key);\n const result = upgrader.upgrade(doc.document, { kind: doc.kind, stamp });\n if (sameJson(result.document, doc.document)) {\n untouched.push(key);\n continue;\n }\n planned.push({\n kind: doc.kind,\n id: doc.id,\n ...(doc.file === undefined ? {} : { file: doc.file }),\n applied: result.applied,\n changes: diffJson(doc.document, result.document),\n expected: result.document,\n });\n const schema = schemas?.[doc.kind];\n if (schema !== undefined) {\n const checked = await schema['~standard'].validate(result.document);\n if (checked.issues !== undefined) {\n problems.push(`${key}: the migrated artifact does not pass ${doc.kind}'s current schema — ${checked.issues.slice(0, 2).map((i) => i.message).join('; ')}`);\n }\n }\n }\n\n // Every migration between the lock and the installed grammars — markers\n // included, which change no artifact but still move the version.\n const from = stamp;\n const to = upgrader.stamp;\n const migrations = Object.entries(to).flatMap(([id, n]) =>\n Array.from({ length: Math.max(0, n - (from[id] ?? 0)) }, (_, i) => `${id}/${(from[id] ?? 0) + i + 1}`),\n );\n return {\n from,\n to,\n migrations: migrations.map((ref) => ({ ref, description: describe(ref) })),\n documents: planned.sort((a, b) => (keyOf(a) < keyOf(b) ? -1 : 1)),\n untouched: untouched.sort(),\n problems,\n };\n};\n\nexport type VerifyResult = {\n ok: boolean;\n lines: readonly { ok: boolean; text: string; detail?: readonly string[] }[];\n};\n\n// The edited source against the plan. `upgrader` still reads from the plan's\n// `from` stamp: an artifact the plan left untouched must still be one no\n// pending migration would change.\nexport const verifySourceUpgrade = (options: { plan: SourcePlan; upgrader: Upgrader; documents: readonly SourceDocument[] }): VerifyResult => {\n const { plan, upgrader, documents } = options;\n const now = new Map(documents.map((d) => [keyOf(d), d]));\n const lines: { ok: boolean; text: string; detail?: readonly string[] }[] = [];\n\n for (const want of plan.documents) {\n const key = keyOf(want);\n const got = now.get(key);\n if (got === undefined) {\n lines.push({ ok: false, text: `${key} is gone — the plan expected it rewritten, not removed` });\n } else if (sameJson(got.document, want.expected)) {\n lines.push({ ok: true, text: `${key} matches its migrated JSON` });\n } else {\n lines.push({ ok: false, text: `${key} does not match its migrated JSON yet`, detail: diffJson(got.document, want.expected, 12) });\n }\n }\n for (const key of plan.untouched) {\n const got = now.get(key);\n if (got === undefined) {\n lines.push({ ok: false, text: `${key} is gone — no migration asked for that` });\n continue;\n }\n const again = upgrader.upgrade(got.document, { kind: got.kind, stamp: plan.from });\n if (!sameJson(again.document, got.document)) {\n lines.push({ ok: false, text: `${key} was not in the plan, but the migrations would change it now`, detail: diffJson(got.document, again.document, 12) });\n }\n }\n const known = new Set([...plan.documents.map(keyOf), ...plan.untouched]);\n for (const key of now.keys()) {\n if (!known.has(key)) lines.push({ ok: false, text: `${key} is new since the plan — plan again so it is checked too` });\n }\n const ok = lines.every((l) => l.ok);\n if (ok) lines.push({ ok: true, text: `${plan.untouched.length} artifact(s) no migration touches, still untouched` });\n return { ok, lines };\n};\n\n// The report a person — or an agent — works from.\nexport const renderReport = (plan: SourcePlan, expectedPathOf: (doc: PlannedDocument) => string): string => {\n const stamp = (s: Stamp): string => Object.entries(s).map(([k, v]) => `${k} ${v}`).join(', ');\n const out: string[] = [\n '# strata upgrade',\n '',\n `The source is written at **${stamp(plan.from)}**; the installed grammars are at **${stamp(plan.to)}**.`,\n '',\n '## Migrations',\n '',\n ...plan.migrations.map((m) => `- \\`${m.ref}\\` — ${m.description}`),\n '',\n ];\n if (plan.problems.length > 0) {\n out.push('## Stop: a migration is wrong', '', 'These artifacts would not pass their current schema after migrating — no edit can make `verify` pass. Fix the migration, then plan again.', '', ...plan.problems.map((p) => `- ${p}`), '');\n }\n if (plan.documents.length === 0) {\n out.push('## Nothing to edit', '', `No artifact changes (${plan.untouched.length} checked). Run \\`verify\\` to move the lock.`, '');\n } else {\n out.push(\n `## ${plan.documents.length} artifact(s) to edit`,\n '',\n 'Edit each so that it serialises to EXACTLY its expected JSON (key order aside) — then run `verify`. Only what is listed changes; every other artifact must stay as it is.',\n '',\n );\n for (const doc of plan.documents) {\n out.push(`### \\`${doc.id}\\` (${doc.kind})`, '', doc.file === undefined ? '' : `- **File:** \\`${doc.file}\\``,\n doc.lookIn === undefined || doc.lookIn.length === 0 ? '' : `- **Look in:** ${doc.lookIn.map((f) => `\\`${f}\\``).join(', ')} — where the changing values are written`, `- **Migrations:** ${doc.applied.map((r) => `\\`${r}\\``).join(', ')}`, `- **Expected JSON:** \\`${expectedPathOf(doc)}\\``, '- **Changes:**', '', '```', ...doc.changes, '```', '');\n }\n }\n return out.filter((line, i, all) => !(line === '' && all[i - 1] === '')).join('\\n');\n};\n"]}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkATHZ7HT5_cjs = require('./chunk-ATHZ7HT5.cjs');
|
|
4
|
+
|
|
5
|
+
// src/check/index.ts
|
|
6
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7
|
+
var byKey = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
8
|
+
var sortKeys = (value) => {
|
|
9
|
+
if (Array.isArray(value)) return value.map(sortKeys);
|
|
10
|
+
if (!isRecord(value)) return value;
|
|
11
|
+
return Object.fromEntries(Object.entries(value).sort(byKey).map(([k, v]) => [k, sortKeys(v)]));
|
|
12
|
+
};
|
|
13
|
+
var NAMED = /* @__PURE__ */ new Set(["properties", "patternProperties", "$defs", "definitions", "dependentSchemas"]);
|
|
14
|
+
var DATA = /* @__PURE__ */ new Set(["const", "enum", "default", "examples"]);
|
|
15
|
+
var normalize = (value) => {
|
|
16
|
+
if (Array.isArray(value)) return value.map(normalize);
|
|
17
|
+
if (!isRecord(value)) return value;
|
|
18
|
+
return Object.fromEntries(
|
|
19
|
+
Object.entries(value).filter(([key]) => key !== "description" && key !== "$schema").sort(byKey).map(([key, v]) => [key, NAMED.has(key) && isRecord(v) ? namedSchemas(v, normalize) : DATA.has(key) ? sortKeys(v) : normalize(v)])
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
var namedSchemas = (map, each) => Object.fromEntries(Object.entries(map).sort(byKey).map(([name, schema]) => [name, each(schema)]));
|
|
23
|
+
var snapshotOf = (sequence, schemas) => {
|
|
24
|
+
const declared = Object.keys(sequence.documents ?? {}).map((k) => `${sequence.id}/${k}`);
|
|
25
|
+
const given = Object.keys(schemas);
|
|
26
|
+
const missing = declared.filter((k) => !given.includes(k));
|
|
27
|
+
const extra = given.filter((k) => !declared.includes(k));
|
|
28
|
+
if (missing.length > 0 || extra.length > 0) {
|
|
29
|
+
throw new chunkATHZ7HT5_cjs.StrataError("UNKNOWN_KIND", `The schemas for ${sequence.id} do not match its kinds.`, [
|
|
30
|
+
...missing.map((k) => `no schema for ${k}`),
|
|
31
|
+
...extra.map((k) => `${k} is not a kind of ${sequence.id}`)
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
const kinds = {};
|
|
35
|
+
for (const kind of [...declared].sort()) {
|
|
36
|
+
const schema = schemas[kind];
|
|
37
|
+
if (schema !== void 0) kinds[kind] = sortKeys(schema["~standard"].jsonSchema.input({ target: "draft-2020-12" }));
|
|
38
|
+
}
|
|
39
|
+
return { sequence: sequence.id, version: sequence.migrations.length, kinds };
|
|
40
|
+
};
|
|
41
|
+
var snapshotText = (snapshot) => `${JSON.stringify(sortKeys(snapshot), null, 2)}
|
|
42
|
+
`;
|
|
43
|
+
var diffLines = (a, b, path, out, limit, canon = normalize, sets = true) => {
|
|
44
|
+
if (out.length >= limit) return;
|
|
45
|
+
if (JSON.stringify(a) === JSON.stringify(b)) return;
|
|
46
|
+
if (isRecord(a) && isRecord(b)) {
|
|
47
|
+
for (const key of [.../* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)])].sort()) {
|
|
48
|
+
const at = path === "" ? key : `${path}.${key}`;
|
|
49
|
+
const before = a[key];
|
|
50
|
+
const after = b[key];
|
|
51
|
+
if (!(key in a)) out.push(`+ ${at}`);
|
|
52
|
+
else if (!(key in b)) out.push(`- ${at}`);
|
|
53
|
+
else if (sets && key === "prefixItems" && Array.isArray(before) && Array.isArray(after)) diffPositions(before, after, at, out, limit, canon);
|
|
54
|
+
else diffLines(before, after, at, out, limit, canon, sets);
|
|
55
|
+
if (out.length >= limit) return;
|
|
56
|
+
}
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (Array.isArray(a) && Array.isArray(b) && !sets && a.length === b.length) {
|
|
60
|
+
a.forEach((item, i) => diffLines(item, b[i], `${path}[${i}]`, out, limit, canon, sets));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
64
|
+
const text = (v) => JSON.stringify(canon(v));
|
|
65
|
+
const label = (v) => isRecord(v) && isRecord(v["properties"]) ? Object.keys(v["properties"]).join(",") : (text(v) ?? "").slice(0, 50);
|
|
66
|
+
const onlyA = a.filter((x) => !b.some((y) => text(y) === text(x)));
|
|
67
|
+
const onlyB = b.filter((y) => !a.some((x) => text(x) === text(y)));
|
|
68
|
+
const byLabel = new Map(onlyB.map((y) => [label(y), y]));
|
|
69
|
+
for (const x of onlyA) {
|
|
70
|
+
const partner = byLabel.get(label(x));
|
|
71
|
+
if (partner !== void 0) {
|
|
72
|
+
diffLines(x, partner, `${path}[${label(x)}]`, out, limit, canon, sets);
|
|
73
|
+
byLabel.delete(label(x));
|
|
74
|
+
} else {
|
|
75
|
+
out.push(`- ${path}[${label(x)}]`);
|
|
76
|
+
}
|
|
77
|
+
if (out.length >= limit) return;
|
|
78
|
+
}
|
|
79
|
+
for (const [name] of byLabel) {
|
|
80
|
+
out.push(`+ ${path}[${name}]`);
|
|
81
|
+
if (out.length >= limit) return;
|
|
82
|
+
}
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
out.push(`~ ${path || "(root)"}: ${JSON.stringify(a)?.slice(0, 60)} \u2192 ${JSON.stringify(b)?.slice(0, 60)}`);
|
|
86
|
+
};
|
|
87
|
+
var diffPositions = (a, b, path, out, limit, canon) => {
|
|
88
|
+
for (let i = 0; i < Math.max(a.length, b.length); i += 1) {
|
|
89
|
+
if (out.length >= limit) return;
|
|
90
|
+
if (i >= a.length) out.push(`+ ${path}[${i}]`);
|
|
91
|
+
else if (i >= b.length) out.push(`- ${path}[${i}]`);
|
|
92
|
+
else diffLines(a[i], b[i], `${path}[${i}]`, out, limit, canon, true);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var REF_PREFIX = /^#\/(\$defs|definitions)\//;
|
|
96
|
+
var respell = (value) => {
|
|
97
|
+
let node = value;
|
|
98
|
+
const anyOf = node["anyOf"];
|
|
99
|
+
if (!("type" in node) && Array.isArray(anyOf) && anyOf.length > 0 && anyOf.every((m) => isRecord(m) && Object.keys(m).length === 1 && typeof m["type"] === "string")) {
|
|
100
|
+
const { anyOf: _union, ...rest } = node;
|
|
101
|
+
node = { ...rest, type: anyOf.map((m) => isRecord(m) ? m["type"] : void 0) };
|
|
102
|
+
}
|
|
103
|
+
const type = node["type"];
|
|
104
|
+
if (Array.isArray(type)) {
|
|
105
|
+
const types = [...new Set(type.map(String))].sort();
|
|
106
|
+
node = { ...node, type: types.length === 1 ? types[0] : types };
|
|
107
|
+
}
|
|
108
|
+
const allOf = node["allOf"];
|
|
109
|
+
const only = Array.isArray(allOf) && allOf.length === 1 ? allOf[0] : void 0;
|
|
110
|
+
if (!("$ref" in node) && isRecord(only) && Object.keys(only).length === 1 && typeof only["$ref"] === "string") {
|
|
111
|
+
const { allOf: _wrapper, ...rest } = node;
|
|
112
|
+
node = { ...rest, $ref: only["$ref"] };
|
|
113
|
+
}
|
|
114
|
+
return node;
|
|
115
|
+
};
|
|
116
|
+
var schemaChildren = (node) => Object.entries(node).flatMap(
|
|
117
|
+
([key, child]) => key === "$ref" || DATA.has(key) ? [] : NAMED.has(key) && isRecord(child) ? Object.values(child) : [child]
|
|
118
|
+
);
|
|
119
|
+
var canonical = (recorded) => {
|
|
120
|
+
const schema = normalize(recorded);
|
|
121
|
+
if (!isRecord(schema)) return schema;
|
|
122
|
+
const defs = {
|
|
123
|
+
...isRecord(schema["definitions"]) ? schema["definitions"] : {},
|
|
124
|
+
...isRecord(schema["$defs"]) ? schema["$defs"] : {}
|
|
125
|
+
};
|
|
126
|
+
const { $defs: _defs, definitions: _definitions, ...body } = schema;
|
|
127
|
+
const target = (ref) => ref === "#" ? { key: "#", node: body } : { key: ref, node: defs[ref.replace(REF_PREFIX, "")] };
|
|
128
|
+
const recursive = /* @__PURE__ */ new Set();
|
|
129
|
+
const findCycles = (value, stack) => {
|
|
130
|
+
if (Array.isArray(value)) {
|
|
131
|
+
for (const item of value) findCycles(item, stack);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!isRecord(value)) return;
|
|
135
|
+
const node = respell(value);
|
|
136
|
+
for (const child of schemaChildren(node)) findCycles(child, stack);
|
|
137
|
+
const ref = node["$ref"];
|
|
138
|
+
if (typeof ref !== "string") return;
|
|
139
|
+
const { key, node: next } = target(ref);
|
|
140
|
+
if (stack.includes(key)) recursive.add(key);
|
|
141
|
+
else findCycles(next, [...stack, key]);
|
|
142
|
+
};
|
|
143
|
+
findCycles(body, ["#"]);
|
|
144
|
+
const names = /* @__PURE__ */ new Map();
|
|
145
|
+
const named = {};
|
|
146
|
+
const nameOf = (key, node) => {
|
|
147
|
+
const known = names.get(key);
|
|
148
|
+
if (known !== void 0) return known;
|
|
149
|
+
const name = `d${names.size}`;
|
|
150
|
+
names.set(key, name);
|
|
151
|
+
named[name] = emit(node);
|
|
152
|
+
return name;
|
|
153
|
+
};
|
|
154
|
+
const emit = (value) => {
|
|
155
|
+
if (Array.isArray(value)) return value.map(emit);
|
|
156
|
+
if (!isRecord(value)) return value;
|
|
157
|
+
const node = respell(value);
|
|
158
|
+
const rest = Object.fromEntries(
|
|
159
|
+
Object.entries(node).filter(([key2]) => key2 !== "$ref").sort(byKey).map(([key2, child]) => [key2, NAMED.has(key2) && isRecord(child) ? namedSchemas(child, emit) : DATA.has(key2) ? child : emit(child)])
|
|
160
|
+
);
|
|
161
|
+
const ref = node["$ref"];
|
|
162
|
+
if (typeof ref !== "string") return rest;
|
|
163
|
+
const { key, node: next } = target(ref);
|
|
164
|
+
const referred = recursive.has(key) ? { $ref: `#/$defs/${nameOf(key, next)}` } : emit(next);
|
|
165
|
+
return Object.keys(rest).length > 0 ? { ...rest, allOf: [referred] } : referred;
|
|
166
|
+
};
|
|
167
|
+
const root = recursive.has("#") ? { $ref: `#/$defs/${nameOf("#", body)}` } : emit(body);
|
|
168
|
+
return Object.keys(named).length === 0 ? root : sortKeys({ ...isRecord(root) ? root : { allOf: [root] }, $defs: named });
|
|
169
|
+
};
|
|
170
|
+
var compareSnapshot = (recorded, current) => {
|
|
171
|
+
if (recorded === void 0) return { status: "missing" };
|
|
172
|
+
const changes = [];
|
|
173
|
+
for (const kind of [.../* @__PURE__ */ new Set([...Object.keys(recorded.kinds), ...Object.keys(current.kinds)])].sort()) {
|
|
174
|
+
const lines = [];
|
|
175
|
+
if (!(kind in recorded.kinds)) lines.push("+ (a new kind)");
|
|
176
|
+
else if (!(kind in current.kinds)) lines.push("- (the kind is gone)");
|
|
177
|
+
else diffLines(canonical(recorded.kinds[kind]), canonical(current.kinds[kind]), "", lines, 12);
|
|
178
|
+
if (lines.length > 0) changes.push({ kind, lines });
|
|
179
|
+
}
|
|
180
|
+
return changes.length === 0 ? { status: "same" } : { status: "changed", changes };
|
|
181
|
+
};
|
|
182
|
+
var issueText = (issue) => {
|
|
183
|
+
const path = (issue.path ?? []).map((p) => typeof p === "object" ? String(p.key) : String(p)).join(".");
|
|
184
|
+
return `${path === "" ? "" : `${path}: `}${issue.message}`;
|
|
185
|
+
};
|
|
186
|
+
var diffJson = (a, b, limit = 20) => {
|
|
187
|
+
const out = [];
|
|
188
|
+
diffLines(a, b, "", out, limit, sortKeys, false);
|
|
189
|
+
return out;
|
|
190
|
+
};
|
|
191
|
+
var checkCorpus = async (upgrader, schemas, documents) => {
|
|
192
|
+
const failures = [];
|
|
193
|
+
let passed = 0;
|
|
194
|
+
for (const doc of documents) {
|
|
195
|
+
const schema = schemas[doc.kind];
|
|
196
|
+
if (schema === void 0) {
|
|
197
|
+
failures.push({ id: doc.id, kind: doc.kind, reason: `no schema for ${doc.kind}` });
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
let upgraded;
|
|
201
|
+
try {
|
|
202
|
+
upgraded = upgrader.upgrade(doc.document, { kind: doc.kind, stamp: doc.stamp }).document;
|
|
203
|
+
} catch (error) {
|
|
204
|
+
failures.push({ id: doc.id, kind: doc.kind, reason: error instanceof Error ? error.message.split("\n")[0] ?? error.message : String(error) });
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const result = await schema["~standard"].validate(upgraded);
|
|
208
|
+
if (result.issues !== void 0) {
|
|
209
|
+
failures.push({ id: doc.id, kind: doc.kind, reason: result.issues.slice(0, 3).map(issueText).join("; ") });
|
|
210
|
+
} else {
|
|
211
|
+
passed += 1;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return { passed, failures };
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
exports.checkCorpus = checkCorpus;
|
|
218
|
+
exports.compareSnapshot = compareSnapshot;
|
|
219
|
+
exports.diffJson = diffJson;
|
|
220
|
+
exports.snapshotOf = snapshotOf;
|
|
221
|
+
exports.snapshotText = snapshotText;
|
|
222
|
+
//# sourceMappingURL=chunk-KNBS3AJZ.cjs.map
|
|
223
|
+
//# sourceMappingURL=chunk-KNBS3AJZ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/check/index.ts"],"names":["StrataError","key"],"mappings":";;;;;AAyCA,IAAM,QAAA,GAAW,CAAC,KAAA,KAChB,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA,IAAQ,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AAErE,IAAM,KAAA,GAAQ,CAAC,CAAC,CAAC,CAAA,EAAsB,CAAC,CAAC,CAAA,KAAkC,CAAA,GAAI,CAAA,GAAI,EAAA,GAAK,CAAA,GAAI,IAAI,CAAA,GAAI,CAAA;AAIpG,IAAM,QAAA,GAAW,CAAC,KAAA,KAA4B;AAC5C,EAAA,IAAI,MAAM,OAAA,CAAQ,KAAK,GAAG,OAAO,KAAA,CAAM,IAAI,QAAQ,CAAA;AACnD,EAAA,IAAI,CAAC,QAAA,CAAS,KAAK,CAAA,EAAG,OAAO,KAAA;AAC7B,EAAA,OAAO,MAAA,CAAO,YAAY,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,CAAE,IAAA,CAAK,KAAK,CAAA,CAAE,GAAA,CAAI,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KAAM,CAAC,GAAG,QAAA,CAAS,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/F,CAAA;AAKA,IAAM,KAAA,uBAAY,GAAA,CAAI,CAAC,cAAc,mBAAA,EAA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AI,SAAS,CAAA,CAAE,IAAA,CAAK,IAAI,CAAA,EAAG,CAAA;AAAA,IAC3G,CAAA,MAAO;AACL,MAAA,MAAA,IAAU,CAAA;AAAA,IACZ;AAAA,EACF;AACA,EAAA,OAAO,EAAE,QAAQ,QAAA,EAAS;AAC5B","file":"chunk-KNBS3AJZ.cjs","sourcesContent":["import type { Sequence } from '../schema';\nimport type { Stamp, Upgrader } from '../documents';\nimport { StrataError } from '../errors';\n\n// ═══════════════════════════════════════════════════════════════\n// @niscorp/strata/check — the gate a grammar change has to pass.\n//\n// Two questions, both mechanical:\n//\n// 1. SNAPSHOT — did a kind's schema change without the grammar gaining a\n// migration? Each kind's JSON Schema, taken through the schema's OWN\n// Standard JSON Schema hook, is recorded per grammar version. Same version,\n// different schema: something changed that older readers were never told.\n// Append a migration (an empty marker is enough for an addition — strict\n// readers still have to refuse the newer documents), then record the new\n// version.\n//\n// 2. CORPUS — does every real document ever captured, at the stamp it was\n// captured at, still upgrade to the current grammar and pass the current\n// strict schema? This is the judge: a snapshot only says something moved,\n// the corpus says whether old documents survive it. No JSON Schema diff\n// tool is trusted to decide compatibility.\n//\n// Pure: no files, no process. A host reads and writes snapshots where it keeps\n// them (nisc's own live in the repo's `strata/` directory).\n// ═══════════════════════════════════════════════════════════════\n\ntype Issue = { message: string; path?: readonly (PropertyKey | { key: PropertyKey })[] };\ntype StandardResult = { value: unknown; issues?: undefined } | { issues: readonly Issue[] };\n\n// Any validator implementing Standard Schema + Standard JSON Schema (Zod ≥ 4.2,\n// Valibot, ArkType). Structural: strata depends on none of them.\nexport type GrammarSchema = {\n '~standard': {\n validate: (value: unknown) => StandardResult | Promise<StandardResult>;\n jsonSchema: { input: (options: { target: string }) => Record<string, unknown> };\n };\n};\n\nexport type Snapshot = { sequence: string; version: number; kinds: Readonly<Record<string, unknown>> };\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst byKey = ([a]: [string, unknown], [b]: [string, unknown]): number => (a < b ? -1 : a > b ? 1 : 0);\n\n// Sorted keys, nothing else — for documents, where every key (a `description`\n// too) is content, and for a snapshot file, which keeps what the validator wrote.\nconst sortKeys = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(sortKeys);\n if (!isRecord(value)) return value;\n return Object.fromEntries(Object.entries(value).sort(byKey).map(([k, v]) => [k, sortKeys(v)]));\n};\n\n// Where a schema's keys are NAMES, not keywords — a field called `description`\n// or an op called `$ref` is grammar — and where its values are instance data\n// rather than schemas.\nconst NAMED = new Set(['properties', 'patternProperties', '$defs', 'definitions', 'dependentSchemas']);\nconst DATA = new Set(['const', 'enum', 'default', 'examples']);\n\n// A schema without its prose: the `description` KEYWORD is documentation, and\n// rewording a `.describe()` must not demand a migration. `$schema` is the same\n// everywhere. Applied when comparing, never to what is recorded — so what the\n// gate ignores can change without touching a snapshot file.\nconst normalize = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(normalize);\n if (!isRecord(value)) return value;\n return Object.fromEntries(\n Object.entries(value)\n .filter(([key]) => key !== 'description' && key !== '$schema')\n .sort(byKey)\n .map(([key, v]) => [key, NAMED.has(key) && isRecord(v) ? namedSchemas(v, normalize) : DATA.has(key) ? sortKeys(v) : normalize(v)]),\n );\n};\n\n// A name → schema map, each schema through `each`, the names untouched.\nconst namedSchemas = (map: Record<string, unknown>, each: (schema: unknown) => unknown): Record<string, unknown> =>\n Object.fromEntries(Object.entries(map).sort(byKey).map(([name, schema]) => [name, each(schema)]));\n\n// The grammar as it stands: every kind it declares, as JSON Schema — as the\n// validator wrote it, keys sorted. `schemas` must cover exactly the sequence's\n// kinds — a kind without a schema cannot be checked, and a schema without a\n// kind belongs to some other grammar.\nexport const snapshotOf = (sequence: Sequence, schemas: Readonly<Record<string, GrammarSchema>>): Snapshot => {\n const declared = Object.keys(sequence.documents ?? {}).map((k) => `${sequence.id}/${k}`);\n const given = Object.keys(schemas);\n const missing = declared.filter((k) => !given.includes(k));\n const extra = given.filter((k) => !declared.includes(k));\n if (missing.length > 0 || extra.length > 0) {\n throw new StrataError('UNKNOWN_KIND', `The schemas for ${sequence.id} do not match its kinds.`, [\n ...missing.map((k) => `no schema for ${k}`),\n ...extra.map((k) => `${k} is not a kind of ${sequence.id}`),\n ]);\n }\n const kinds: Record<string, unknown> = {};\n for (const kind of [...declared].sort()) {\n const schema = schemas[kind];\n if (schema !== undefined) kinds[kind] = sortKeys(schema['~standard'].jsonSchema.input({ target: 'draft-2020-12' }));\n }\n return { sequence: sequence.id, version: sequence.migrations.length, kinds };\n};\n\n// Stable text for a snapshot file: sorted keys, two-space indent, newline.\nexport const snapshotText = (snapshot: Snapshot): string => `${JSON.stringify(sortKeys(snapshot), null, 2)}\n`;\n\n// Schema arrays are compared as sets (`sets`) — all but a tuple's `prefixItems`,\n// see `diffPositions`; a document's arrays by position — `layout.children[1]` is\n// how a person finds the thing that changed.\nconst diffLines = (a: unknown, b: unknown, path: string, out: string[], limit: number, canon: (v: unknown) => unknown = normalize, sets = true): void => {\n if (out.length >= limit) return;\n if (JSON.stringify(a) === JSON.stringify(b)) return;\n if (isRecord(a) && isRecord(b)) {\n for (const key of [...new Set([...Object.keys(a), ...Object.keys(b)])].sort()) {\n const at = path === '' ? key : `${path}.${key}`;\n const before = a[key];\n const after = b[key];\n if (!(key in a)) out.push(`+ ${at}`);\n else if (!(key in b)) out.push(`- ${at}`);\n else if (sets && key === 'prefixItems' && Array.isArray(before) && Array.isArray(after)) diffPositions(before, after, at, out, limit, canon);\n else diffLines(before, after, at, out, limit, canon, sets);\n if (out.length >= limit) return;\n }\n return;\n }\n if (Array.isArray(a) && Array.isArray(b) && !sets && a.length === b.length) {\n a.forEach((item, i) => diffLines(item, b[i], `${path}[${i}]`, out, limit, canon, sets));\n return;\n }\n if (Array.isArray(a) && Array.isArray(b)) {\n // Schema arrays are SETS more often than sequences — a union's `anyOf`, a\n // `required` list, an `enum` — and one added branch shifts every index\n // after it. Match elements by what they describe (an object schema by its\n // property names — for Prism's union, the op), report the ones on one side\n // only, and diff the ones that changed in place.\n const text = (v: unknown): string => JSON.stringify(canon(v));\n const label = (v: unknown): string =>\n isRecord(v) && isRecord(v['properties']) ? Object.keys(v['properties']).join(',') : (text(v) ?? '').slice(0, 50);\n const onlyA = a.filter((x) => !b.some((y) => text(y) === text(x)));\n const onlyB = b.filter((y) => !a.some((x) => text(x) === text(y)));\n const byLabel = new Map(onlyB.map((y) => [label(y), y]));\n for (const x of onlyA) {\n const partner = byLabel.get(label(x));\n if (partner !== undefined) {\n diffLines(x, partner, `${path}[${label(x)}]`, out, limit, canon, sets);\n byLabel.delete(label(x));\n } else {\n out.push(`- ${path}[${label(x)}]`);\n }\n if (out.length >= limit) return;\n }\n for (const [name] of byLabel) {\n out.push(`+ ${path}[${name}]`);\n if (out.length >= limit) return;\n }\n return;\n }\n out.push(`~ ${path || '(root)'}: ${JSON.stringify(a)?.slice(0, 60)} → ${JSON.stringify(b)?.slice(0, 60)}`);\n};\n\n// A tuple's `prefixItems` is the one schema array that is a SEQUENCE: position\n// is the grammar, so [string, number] and [number, string] are different tuples\n// and a document valid for one is not for the other. Compared place by place;\n// what sits IN a place is a schema again, its own arrays sets as ever.\nconst diffPositions = (a: readonly unknown[], b: readonly unknown[], path: string, out: string[], limit: number, canon: (v: unknown) => unknown): void => {\n for (let i = 0; i < Math.max(a.length, b.length); i += 1) {\n if (out.length >= limit) return;\n if (i >= a.length) out.push(`+ ${path}[${i}]`);\n else if (i >= b.length) out.push(`- ${path}[${i}]`);\n else diffLines(a[i], b[i], `${path}[${i}]`, out, limit, canon, true);\n }\n};\n\n// ── canonical form ──────────────────────────────────────────────\n//\n// A snapshot records what the validator WROTE, and validators spell one schema\n// many ways: they name and inline definitions as they please (zod numbers them\n// in visit order, and 4.3 and 4.4 visit differently), write a described\n// reference as `allOf: [{ $ref }]` or as `$ref`, and a union of bare types as\n// `anyOf: [{ type }, …]` or `type: […]`. None of that is the grammar, so a\n// comparison reads both sides in one spelling: every definition inlined unless\n// it is recursive, the recursive ones renamed by first use, and every schema\n// identity above written one way. A snapshot FILE stays what the validator\n// wrote — only the comparison is canonical.\n\nconst REF_PREFIX = /^#\\/(\\$defs|definitions)\\//;\n\n// One spelling for the equivalences the node itself can show.\nconst respell = (value: Record<string, unknown>): Record<string, unknown> => {\n let node = value;\n const anyOf = node['anyOf'];\n if (!('type' in node) && Array.isArray(anyOf) && anyOf.length > 0 && anyOf.every((m) => isRecord(m) && Object.keys(m).length === 1 && typeof m['type'] === 'string')) {\n const { anyOf: _union, ...rest } = node;\n node = { ...rest, type: anyOf.map((m) => (isRecord(m) ? m['type'] : undefined)) };\n }\n const type = node['type'];\n if (Array.isArray(type)) {\n const types = [...new Set(type.map(String))].sort();\n node = { ...node, type: types.length === 1 ? types[0] : types };\n }\n const allOf = node['allOf'];\n const only: unknown = Array.isArray(allOf) && allOf.length === 1 ? allOf[0] : undefined;\n if (!('$ref' in node) && isRecord(only) && Object.keys(only).length === 1 && typeof only['$ref'] === 'string') {\n const { allOf: _wrapper, ...rest } = node;\n node = { ...rest, $ref: only['$ref'] };\n }\n return node;\n};\n\n// A schema node's own children — keyword values, and each schema of a name\n// map — but never the names, and never instance data.\nconst schemaChildren = (node: Record<string, unknown>): unknown[] =>\n Object.entries(node).flatMap(([key, child]) =>\n key === '$ref' || DATA.has(key) ? [] : NAMED.has(key) && isRecord(child) ? Object.values(child) : [child],\n );\n\nconst canonical = (recorded: unknown): unknown => {\n const schema = normalize(recorded);\n if (!isRecord(schema)) return schema;\n const defs: Record<string, unknown> = {\n ...(isRecord(schema['definitions']) ? schema['definitions'] : {}),\n ...(isRecord(schema['$defs']) ? schema['$defs'] : {}),\n };\n const { $defs: _defs, definitions: _definitions, ...body } = schema;\n const target = (ref: string): { key: string; node: unknown } =>\n ref === '#' ? { key: '#', node: body } : { key: ref, node: defs[ref.replace(REF_PREFIX, '')] };\n\n // Which targets are reached from inside their own expansion: those, and\n // only those, stay definitions.\n const recursive = new Set<string>();\n const findCycles = (value: unknown, stack: readonly string[]): void => {\n if (Array.isArray(value)) {\n for (const item of value) findCycles(item, stack);\n return;\n }\n if (!isRecord(value)) return;\n const node = respell(value);\n for (const child of schemaChildren(node)) findCycles(child, stack);\n const ref = node['$ref'];\n if (typeof ref !== 'string') return;\n const { key, node: next } = target(ref);\n if (stack.includes(key)) recursive.add(key);\n else findCycles(next, [...stack, key]);\n };\n findCycles(body, ['#']);\n\n const names = new Map<string, string>();\n const named: Record<string, unknown> = {};\n const nameOf = (key: string, node: unknown): string => {\n const known = names.get(key);\n if (known !== undefined) return known;\n const name = `d${names.size}`;\n names.set(key, name);\n named[name] = emit(node);\n return name;\n };\n const emit = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(emit);\n if (!isRecord(value)) return value;\n const node = respell(value);\n const rest: Record<string, unknown> = Object.fromEntries(\n Object.entries(node)\n .filter(([key]) => key !== '$ref')\n .sort(byKey)\n .map(([key, child]) => [key, NAMED.has(key) && isRecord(child) ? namedSchemas(child, emit) : DATA.has(key) ? child : emit(child)]),\n );\n const ref = node['$ref'];\n if (typeof ref !== 'string') return rest;\n const { key, node: next } = target(ref);\n const referred = recursive.has(key) ? { $ref: `#/$defs/${nameOf(key, next)}` } : emit(next);\n return Object.keys(rest).length > 0 ? { ...rest, allOf: [referred] } : referred;\n };\n\n const root = recursive.has('#') ? { $ref: `#/$defs/${nameOf('#', body)}` } : emit(body);\n return Object.keys(named).length === 0 ? root : sortKeys({ ...(isRecord(root) ? root : { allOf: [root] }), $defs: named });\n};\n\nexport type SnapshotComparison =\n | { status: 'same' }\n | { status: 'missing' }\n | { status: 'changed'; changes: readonly { kind: string; lines: readonly string[] }[] };\n\n// `recorded` is the snapshot kept for the grammar's CURRENT version (or\n// undefined if none was kept). Changed means: a migration is owed. Both sides\n// are read in canonical form, so a validator's respelling is not a change.\nexport const compareSnapshot = (recorded: Snapshot | undefined, current: Snapshot): SnapshotComparison => {\n if (recorded === undefined) return { status: 'missing' };\n const changes: { kind: string; lines: string[] }[] = [];\n for (const kind of [...new Set([...Object.keys(recorded.kinds), ...Object.keys(current.kinds)])].sort()) {\n const lines: string[] = [];\n if (!(kind in recorded.kinds)) lines.push('+ (a new kind)');\n else if (!(kind in current.kinds)) lines.push('- (the kind is gone)');\n else diffLines(canonical(recorded.kinds[kind]), canonical(current.kinds[kind]), '', lines, 12);\n if (lines.length > 0) changes.push({ kind, lines });\n }\n return changes.length === 0 ? { status: 'same' } : { status: 'changed', changes };\n};\n\n// ── the corpus ──────────────────────────────────────────────────\n\nexport type CorpusDocument = { id: string; kind: string; stamp: Stamp; document: unknown };\nexport type CorpusFailure = { id: string; kind: string; reason: string };\nexport type CorpusReport = { passed: number; failures: readonly CorpusFailure[] };\n\nconst issueText = (issue: Issue): string => {\n const path = (issue.path ?? []).map((p) => (typeof p === 'object' ? String(p.key) : String(p))).join('.');\n return `${path === '' ? '' : `${path}: `}${issue.message}`;\n};\n\n// What differs between two JSON values, as short lines (`+ a.b`, `- c`,\n// `~ d: 1 → 2`) — for a report a person or an agent acts on.\nexport const diffJson = (a: unknown, b: unknown, limit = 20): string[] => {\n const out: string[] = [];\n diffLines(a, b, '', out, limit, sortKeys, false);\n return out;\n};\n\n// Every document, upgraded from its stamp, must pass the current schema of its kind.\nexport const checkCorpus = async (\n upgrader: Upgrader,\n schemas: Readonly<Record<string, GrammarSchema>>,\n documents: readonly CorpusDocument[],\n): Promise<CorpusReport> => {\n const failures: CorpusFailure[] = [];\n let passed = 0;\n for (const doc of documents) {\n const schema = schemas[doc.kind];\n if (schema === undefined) {\n failures.push({ id: doc.id, kind: doc.kind, reason: `no schema for ${doc.kind}` });\n continue;\n }\n let upgraded: unknown;\n try {\n upgraded = upgrader.upgrade(doc.document, { kind: doc.kind, stamp: doc.stamp }).document;\n } catch (error) {\n failures.push({ id: doc.id, kind: doc.kind, reason: error instanceof Error ? error.message.split('\\n')[0] ?? error.message : String(error) });\n continue;\n }\n const result = await schema['~standard'].validate(upgraded);\n if (result.issues !== undefined) {\n failures.push({ id: doc.id, kind: doc.kind, reason: result.issues.slice(0, 3).map(issueText).join('; ') });\n } else {\n passed += 1;\n }\n }\n return { passed, failures };\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { prepare, orderPending } from './chunk-
|
|
2
|
-
import { StrataError } from './chunk-
|
|
1
|
+
import { prepare, orderPending } from './chunk-5KTXEN43.js';
|
|
2
|
+
import { StrataError } from './chunk-AKKWEXO2.js';
|
|
3
3
|
|
|
4
4
|
// src/documents.ts
|
|
5
5
|
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -39,7 +39,7 @@ var createUpgrader = async (sequences, options) => {
|
|
|
39
39
|
if (tables.length > 0) {
|
|
40
40
|
throw new StrataError(
|
|
41
41
|
"WRONG_OWNER",
|
|
42
|
-
"Documents are upgraded by grammar sequences; these own tables and belong to a database's ledger (`migrate`).",
|
|
42
|
+
"Documents are upgraded by grammar sequences; these own tables and belong to a database's ledger (`migrate`). If one of them is a grammar, declare its `documents` \u2014 a sequence with no `documents` and no document step is read as owning tables.",
|
|
43
43
|
tables.map((s) => s.id)
|
|
44
44
|
);
|
|
45
45
|
}
|
|
@@ -54,6 +54,11 @@ var createUpgrader = async (sequences, options) => {
|
|
|
54
54
|
];
|
|
55
55
|
if (unknown.length > 0) throw new StrataError("UNKNOWN_KIND", "A document kind is named that no sequence declares.", unknown);
|
|
56
56
|
const stamp = Object.fromEntries(grammars.map((s) => [s.id, s.migrations.length]));
|
|
57
|
+
const ownIds = new Set(grammars.map((s) => s.id));
|
|
58
|
+
const stampAfter = (given) => {
|
|
59
|
+
const others = Object.entries(given ?? {}).filter(([id]) => !ownIds.has(id));
|
|
60
|
+
return others.length === 0 ? stamp : { ...stamp, ...Object.fromEntries(others) };
|
|
61
|
+
};
|
|
57
62
|
const locate = (document, kind) => {
|
|
58
63
|
if (!kinds.has(kind)) throw new StrataError("UNKNOWN_KIND", `No sequence declares the document kind "${kind}".`, [...kinds.keys()]);
|
|
59
64
|
const found = [];
|
|
@@ -82,7 +87,7 @@ var createUpgrader = async (sequences, options) => {
|
|
|
82
87
|
const upgrade = (document, { kind, stamp: given }) => {
|
|
83
88
|
if (!isRecord(document)) throw new StrataError("STEP_FAILED", `A ${kind} document must be a JSON object.`);
|
|
84
89
|
if (!kinds.has(kind)) throw new StrataError("UNKNOWN_KIND", `No sequence declares the document kind "${kind}".`, [...kinds.keys()]);
|
|
85
|
-
if (!behind(given)) return { document, stamp, applied: [] };
|
|
90
|
+
if (!behind(given)) return { document, stamp: stampAfter(given), applied: [] };
|
|
86
91
|
const done = new Set(grammars.flatMap((s) => s.migrations.filter((m) => m.n <= positionOf(given, s.id)).map((m) => m.ref)));
|
|
87
92
|
const { pending, stuck } = orderPending(
|
|
88
93
|
grammars.map((s) => ({ waiting: s.migrations.filter((m) => !done.has(m.ref)) })),
|
|
@@ -119,11 +124,11 @@ var createUpgrader = async (sequences, options) => {
|
|
|
119
124
|
for (const step of migration.steps) if (step.kind === "document") runStep(migration, step.at, step.transform);
|
|
120
125
|
applied.push(migration.ref);
|
|
121
126
|
}
|
|
122
|
-
return { document: current, stamp, applied };
|
|
127
|
+
return { document: current, stamp: stampAfter(given), applied };
|
|
123
128
|
};
|
|
124
129
|
return { stamp, upgrade, locate, behind };
|
|
125
130
|
};
|
|
126
131
|
|
|
127
132
|
export { createUpgrader };
|
|
128
|
-
//# sourceMappingURL=chunk-
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
133
|
+
//# sourceMappingURL=chunk-OLDORFOQ.js.map
|
|
134
|
+
//# sourceMappingURL=chunk-OLDORFOQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/documents.ts"],"names":[],"mappings":";;;;AAqDA,IAAM,QAAA,GAAW,CAAC,KAAA,KAChB,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,IAAA,IAAQ,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA;AA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,CAAA;AAAA,IAC5B;AACA,IAAA,OAAO,EAAE,QAAA,EAAU,OAAA,EAAS,OAAO,UAAA,CAAW,KAAK,GAAG,OAAA,EAAQ;AAAA,EAChE,CAAA;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,MAAA,EAAQ,MAAA,EAAO;AAC1C","file":"chunk-OLDORFOQ.js","sourcesContent":["import { prepare, orderPending, type PreparedMigration, type PreparedSequence } from './plan';\nimport type { DocumentKind, Sequence } from './schema';\nimport { StrataError } from './errors';\n\n// ═══════════════════════════════════════════════════════════════\n// Documents — the JSON a grammar describes, wherever it is kept.\n//\n// A document carries a STAMP: for each grammar sequence, how far along that\n// sequence the writer was (`{ \"nisc.nova\": 3, \"nisc.prism\": 1 }`). Upgrading\n// runs every document migration the stamp has not seen, in the ledger's order,\n// and hands back the document with a current stamp. The same function serves a\n// row read at boot, a submission at intake and a file in an app's source tree:\n// the document does not care where it was kept.\n//\n// NESTING IS THE GRAMMAR'S, NOT THE MIGRATION'S. A kind declares where other\n// documents sit inside it (its embeddings: nova's layout holds layouts at\n// `children`, `children[]`, `then`, `else`, `do`; an action holds a layout and\n// Prism configs). The walker finds every document of a step's kind at any\n// depth and rewrites each on its own, deepest first. A transform only ever sees\n// ONE node — so migrations stay flat, and a Prism config can express them\n// without recursion of its own.\n// ═══════════════════════════════════════════════════════════════\n\nexport type Stamp = Readonly<Record<string, number>>;\n\n// Where a document sits: the path from the root (keys and indexes) and its kind.\nexport type Location = { path: readonly (string | number)[]; kind: string; value: Record<string, unknown> };\n\n// The injected evaluator — nova's `transform` socket, the same shape: under moss\n// it is Prism's `evaluate`, and a migration runs exactly the way an endpoint does.\nexport type Transform = (config: unknown, source: unknown) => unknown;\n\nexport type UpgradeResult = {\n document: Record<string, unknown>;\n // What to store with the document: current on every grammar the upgrader was\n // given, and the document's entries for any other grammar kept as they were.\n stamp: Stamp;\n // What ran, in order — empty when the document was already current.\n applied: readonly string[];\n};\n\nexport type Upgrader = {\n // The stamp a document written NOW carries.\n stamp: Stamp;\n upgrade: (document: unknown, options: { kind: string; stamp?: Stamp | null }) => UpgradeResult;\n // Every document inside `document` (itself included), by kind — what the\n // walker sees. For a page that shows it, and for a check that asserts it.\n locate: (document: unknown, kind: string) => Location[];\n // Is a document at this stamp behind the code (true), current (false)? Throws\n // TOO_NEW if it is ahead.\n behind: (stamp: Stamp | null | undefined) => boolean;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst pathText = (path: readonly (string | number)[]): string =>\n path.reduce<string>((text, key) => (typeof key === 'number' ? `${text}[${key}]` : text === '' ? key : `${text}.${key}`), '');\n\n// One embedding pattern, applied to one value: every (relative path, value)\n// the pattern reaches. `key` descends, `*` crosses a record's values, and a\n// `[]` suffix crosses the array found there.\nconst reach = (value: unknown, pattern: string): { path: (string | number)[]; value: unknown }[] => {\n let frontier: { path: (string | number)[]; value: unknown }[] = [{ path: [], value }];\n for (const segment of pattern.split('.')) {\n const array = segment.endsWith('[]');\n const key = array ? segment.slice(0, -2) : segment;\n const next: { path: (string | number)[]; value: unknown }[] = [];\n for (const at of frontier) {\n if (!isRecord(at.value)) continue;\n const found: { path: (string | number)[]; value: unknown }[] =\n key === '*'\n ? Object.entries(at.value).map(([k, v]) => ({ path: [...at.path, k], value: v }))\n : key in at.value\n ? [{ path: [...at.path, key], value: at.value[key] }]\n : [];\n for (const f of found) {\n if (!array) next.push(f);\n else if (Array.isArray(f.value)) f.value.forEach((item, i) => next.push({ path: [...f.path, i], value: item }));\n }\n }\n frontier = next;\n }\n return frontier;\n};\n\nconst getAt = (root: unknown, path: readonly (string | number)[]): unknown =>\n path.reduce<unknown>((at, key) => {\n if (typeof key === 'number') return Array.isArray(at) ? at[key] : undefined;\n return isRecord(at) ? at[key] : undefined;\n }, root);\n\nconst setAt = (root: unknown, path: readonly (string | number)[], value: unknown): unknown => {\n const [head, ...rest] = path;\n if (head === undefined) return value;\n if (typeof head === 'number' && Array.isArray(root)) return root.map((item, i) => (i === head ? setAt(item, rest, value) : item));\n if (typeof head === 'string' && isRecord(root)) return { ...root, [head]: setAt(root[head], rest, value) };\n return root;\n};\n\nexport const createUpgrader = async (sequences: readonly Sequence[], options: { transform: Transform }): Promise<Upgrader> => {\n const prepared = await prepare(sequences);\n const tables = prepared.filter((s) => !s.grammar);\n if (tables.length > 0) {\n // A sequence is read as a grammar by what it declares (plan.ts). One with\n // nothing but markers and no `documents` reads as owning tables, so the\n // refusal says how a grammar says it is one — `migrate` alone would send a\n // kit's markers to a database's ledger.\n throw new StrataError(\n 'WRONG_OWNER',\n 'Documents are upgraded by grammar sequences; these own tables and belong to a database\\'s ledger (`migrate`). If one of them is a grammar, declare its `documents` — a sequence with no `documents` and no document step is read as owning tables.',\n tables.map((s) => s.id),\n );\n }\n const grammars: readonly PreparedSequence[] = prepared;\n\n const kinds = new Map<string, DocumentKind>();\n for (const sequence of grammars) {\n for (const [name, kind] of Object.entries(sequence.documents)) kinds.set(`${sequence.id}/${name}`, kind);\n }\n const unknown = [\n ...grammars.flatMap((s) => s.migrations.flatMap((m) => m.steps.flatMap((step) => (step.kind === 'document' && !kinds.has(step.at) ? [`${m.ref} rewrites ${step.at}`] : [])))),\n ...[...kinds].flatMap(([ref, kind]) => Object.entries(kind.embeds ?? {}).flatMap(([path, target]) => (kinds.has(target) ? [] : [`${ref} embeds ${target} at ${path}`]))),\n ];\n if (unknown.length > 0) throw new StrataError('UNKNOWN_KIND', 'A document kind is named that no sequence declares.', unknown);\n\n const stamp: Stamp = Object.fromEntries(grammars.map((s) => [s.id, s.migrations.length]));\n\n // The stamp a document carries once this code has read it: this code's\n // position on every grammar it was given and — as they were — the document's\n // own entries for grammars it was not. Those record code this reader lacks (a\n // kit it does not have); dropping them would let code that does have the\n // grammar run its migrations over the document a second time.\n const ownIds = new Set(grammars.map((s) => s.id));\n const stampAfter = (given: Stamp | null | undefined): Stamp => {\n const others = Object.entries(given ?? {}).filter(([id]) => !ownIds.has(id));\n return others.length === 0 ? stamp : { ...stamp, ...Object.fromEntries(others) };\n };\n\n const locate = (document: unknown, kind: string): Location[] => {\n if (!kinds.has(kind)) throw new StrataError('UNKNOWN_KIND', `No sequence declares the document kind \"${kind}\".`, [...kinds.keys()]);\n const found: Location[] = [];\n const visit = (value: unknown, at: string, path: (string | number)[]): void => {\n if (!isRecord(value)) return;\n found.push({ path, kind: at, value });\n for (const [pattern, target] of Object.entries(kinds.get(at)?.embeds ?? {})) {\n for (const hit of reach(value, pattern)) visit(hit.value, target, [...path, ...hit.path]);\n }\n };\n visit(document, kind, []);\n return found;\n };\n\n const positionOf = (given: Stamp | null | undefined, id: string): number => given?.[id] ?? 0;\n\n const behind = (given: Stamp | null | undefined): boolean => {\n const ahead = grammars.filter((s) => positionOf(given, s.id) > s.migrations.length);\n if (ahead.length > 0) {\n throw new StrataError(\n 'TOO_NEW',\n 'This document was written by newer code than this — reading it would be guessing.',\n ahead.map((s) => `${s.id}: the document is at ${positionOf(given, s.id)}, this code knows ${s.migrations.length}`),\n );\n }\n return grammars.some((s) => positionOf(given, s.id) < s.migrations.length);\n };\n\n const upgrade = (document: unknown, { kind, stamp: given }: { kind: string; stamp?: Stamp | null }): UpgradeResult => {\n if (!isRecord(document)) throw new StrataError('STEP_FAILED', `A ${kind} document must be a JSON object.`);\n if (!kinds.has(kind)) throw new StrataError('UNKNOWN_KIND', `No sequence declares the document kind \"${kind}\".`, [...kinds.keys()]);\n if (!behind(given)) return { document, stamp: stampAfter(given), applied: [] };\n\n // What this document has seen: everything up to its stamp, per sequence.\n // A sequence it has never heard of starts at 0 — a document written before\n // a grammar existed simply has none of its migrations yet.\n const done = new Set(grammars.flatMap((s) => s.migrations.filter((m) => m.n <= positionOf(given, s.id)).map((m) => m.ref)));\n const { pending, stuck } = orderPending(\n grammars.map((s) => ({ waiting: s.migrations.filter((m) => !done.has(m.ref)) })),\n done,\n );\n if (stuck.length > 0) throw new StrataError('CYCLE', 'Document migrations wait on each other and can never run.', stuck.map((m) => m.ref));\n\n let current: Record<string, unknown> = document;\n const applied: string[] = [];\n const runStep = (migration: PreparedMigration, at: string, transform: unknown): void => {\n // Deepest first: a parent's rewrite sees its children already rewritten,\n // and replacing a child never moves the path to its parent.\n const targets = locate(current, kind)\n .filter((l) => l.kind === at)\n .sort((a, b) => b.path.length - a.path.length);\n for (const target of targets) {\n // The value NOW, not when the targets were found: a child rewritten a\n // moment ago lives in `current`, and the parent must see — and keep — it.\n const value = getAt(current, target.path);\n let rewritten: unknown;\n try {\n rewritten = options.transform(transform, { document: value, path: pathText(target.path) });\n } catch (cause) {\n throw new StrataError(\n 'STEP_FAILED',\n `${migration.ref} (\"${migration.description}\") failed on the ${at} at ${pathText(target.path) || '(root)'}.`,\n [cause instanceof Error ? cause.message : String(cause)],\n { cause },\n );\n }\n if (!isRecord(rewritten)) {\n throw new StrataError('STEP_FAILED', `${migration.ref} turned the ${at} at ${pathText(target.path) || '(root)'} into something that is not a document.`, [\n JSON.stringify(rewritten)?.slice(0, 200) ?? String(rewritten),\n ]);\n }\n const next = setAt(current, target.path, rewritten);\n if (isRecord(next)) current = next;\n }\n };\n for (const migration of pending) {\n for (const step of migration.steps) if (step.kind === 'document') runStep(migration, step.at, step.transform);\n applied.push(migration.ref);\n }\n return { document: current, stamp: stampAfter(given), applied };\n };\n\n return { stamp, upgrade, locate, behind };\n};\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { diffJson } from './chunk-
|
|
2
|
-
import { StrataError } from './chunk-
|
|
1
|
+
import { diffJson } from './chunk-4BLHBVSC.js';
|
|
2
|
+
import { StrataError } from './chunk-AKKWEXO2.js';
|
|
3
3
|
|
|
4
4
|
// src/upgrade/index.ts
|
|
5
5
|
var keyOf = (doc) => `${doc.kind}:${doc.id}`;
|
|
@@ -152,5 +152,5 @@ var renderReport = (plan, expectedPathOf) => {
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
export { changedStrings, planSourceUpgrade, renderReport, verifySourceUpgrade };
|
|
155
|
-
//# sourceMappingURL=chunk-
|
|
156
|
-
//# sourceMappingURL=chunk-
|
|
155
|
+
//# sourceMappingURL=chunk-WU3OJHVZ.js.map
|
|
156
|
+
//# sourceMappingURL=chunk-WU3OJHVZ.js.map
|