@smthrs/plan 0.0.0-stage → 1.0.0-rc.12
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 +185 -0
- package/LICENSE +21 -0
- package/README.md +230 -2
- package/THIRD_PARTY_NOTICES.md +48 -0
- package/dist/cjs/CachePolicy.d.ts +131 -0
- package/dist/cjs/CachePolicy.d.ts.map +1 -0
- package/dist/cjs/CachePolicy.js +50 -0
- package/dist/cjs/CachePolicy.js.map +7 -0
- package/dist/cjs/Effects.d.ts +258 -0
- package/dist/cjs/Effects.d.ts.map +1 -0
- package/dist/cjs/Effects.js +76 -0
- package/dist/cjs/Effects.js.map +7 -0
- package/dist/cjs/FileSet.d.ts +366 -0
- package/dist/cjs/FileSet.d.ts.map +1 -0
- package/dist/cjs/FileSet.js +196 -0
- package/dist/cjs/FileSet.js.map +7 -0
- package/dist/cjs/GraphBuildError.d.ts +120 -0
- package/dist/cjs/GraphBuildError.d.ts.map +1 -0
- package/dist/cjs/GraphBuildError.js +71 -0
- package/dist/cjs/GraphBuildError.js.map +7 -0
- package/dist/cjs/KeyMaterial.d.ts +107 -0
- package/dist/cjs/KeyMaterial.d.ts.map +1 -0
- package/dist/cjs/KeyMaterial.js +64 -0
- package/dist/cjs/KeyMaterial.js.map +7 -0
- package/dist/cjs/Node.d.ts +677 -0
- package/dist/cjs/Node.d.ts.map +1 -0
- package/dist/cjs/Node.js +229 -0
- package/dist/cjs/Node.js.map +7 -0
- package/dist/cjs/Placement.d.ts +117 -0
- package/dist/cjs/Placement.d.ts.map +1 -0
- package/dist/cjs/Placement.js +46 -0
- package/dist/cjs/Placement.js.map +7 -0
- package/dist/cjs/Plan.d.ts +489 -0
- package/dist/cjs/Plan.d.ts.map +1 -0
- package/dist/cjs/Plan.js +511 -0
- package/dist/cjs/Plan.js.map +7 -0
- package/dist/cjs/PlanDiff.d.ts +77 -0
- package/dist/cjs/PlanDiff.d.ts.map +1 -0
- package/dist/cjs/PlanDiff.js +149 -0
- package/dist/cjs/PlanDiff.js.map +7 -0
- package/dist/cjs/Planned.d.ts +121 -0
- package/dist/cjs/Planned.d.ts.map +1 -0
- package/dist/cjs/Planned.js +72 -0
- package/dist/cjs/Planned.js.map +7 -0
- package/dist/cjs/Repetition.d.ts +31 -0
- package/dist/cjs/Repetition.d.ts.map +1 -0
- package/dist/cjs/Repetition.js +36 -0
- package/dist/cjs/Repetition.js.map +7 -0
- package/dist/cjs/Scheduling.d.ts +89 -0
- package/dist/cjs/Scheduling.d.ts.map +1 -0
- package/dist/cjs/Scheduling.js +76 -0
- package/dist/cjs/Scheduling.js.map +7 -0
- package/dist/cjs/StepKey.d.ts +354 -0
- package/dist/cjs/StepKey.d.ts.map +1 -0
- package/dist/cjs/StepKey.js +313 -0
- package/dist/cjs/StepKey.js.map +7 -0
- package/dist/cjs/index.d.ts +91 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +59 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/internal/ConflictAnnotation.d.ts +59 -0
- package/dist/cjs/internal/ConflictAnnotation.d.ts.map +1 -0
- package/dist/cjs/internal/ConflictAnnotation.js +247 -0
- package/dist/cjs/internal/ConflictAnnotation.js.map +7 -0
- package/dist/cjs/internal/EffectCandidates.d.ts +19 -0
- package/dist/cjs/internal/EffectCandidates.d.ts.map +1 -0
- package/dist/cjs/internal/EffectCandidates.js +92 -0
- package/dist/cjs/internal/EffectCandidates.js.map +7 -0
- package/dist/cjs/internal/JsonMirror.d.ts +34 -0
- package/dist/cjs/internal/JsonMirror.d.ts.map +1 -0
- package/dist/cjs/internal/JsonMirror.js +195 -0
- package/dist/cjs/internal/JsonMirror.js.map +7 -0
- package/dist/cjs/internal/SchemaIdentity.d.ts +140 -0
- package/dist/cjs/internal/SchemaIdentity.d.ts.map +1 -0
- package/dist/cjs/internal/SchemaIdentity.js +718 -0
- package/dist/cjs/internal/SchemaIdentity.js.map +7 -0
- package/dist/cjs/internal/effects.d.ts +245 -0
- package/dist/cjs/internal/effects.d.ts.map +1 -0
- package/dist/cjs/internal/effects.js +290 -0
- package/dist/cjs/internal/effects.js.map +7 -0
- package/dist/cjs/internal/node.d.ts +526 -0
- package/dist/cjs/internal/node.d.ts.map +1 -0
- package/dist/cjs/internal/node.js +313 -0
- package/dist/cjs/internal/node.js.map +7 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/test/PlanFixtures.d.ts +127 -0
- package/dist/cjs/test/PlanFixtures.d.ts.map +1 -0
- package/dist/cjs/test/PlanFixtures.js +59 -0
- package/dist/cjs/test/PlanFixtures.js.map +7 -0
- package/dist/esm/CachePolicy.d.ts +131 -0
- package/dist/esm/CachePolicy.d.ts.map +1 -0
- package/dist/esm/CachePolicy.js +117 -0
- package/dist/esm/CachePolicy.js.map +1 -0
- package/dist/esm/Effects.d.ts +258 -0
- package/dist/esm/Effects.d.ts.map +1 -0
- package/dist/esm/Effects.js +178 -0
- package/dist/esm/Effects.js.map +1 -0
- package/dist/esm/FileSet.d.ts +366 -0
- package/dist/esm/FileSet.d.ts.map +1 -0
- package/dist/esm/FileSet.js +398 -0
- package/dist/esm/FileSet.js.map +1 -0
- package/dist/esm/GraphBuildError.d.ts +120 -0
- package/dist/esm/GraphBuildError.d.ts.map +1 -0
- package/dist/esm/GraphBuildError.js +145 -0
- package/dist/esm/GraphBuildError.js.map +1 -0
- package/dist/esm/KeyMaterial.d.ts +107 -0
- package/dist/esm/KeyMaterial.d.ts.map +1 -0
- package/dist/esm/KeyMaterial.js +92 -0
- package/dist/esm/KeyMaterial.js.map +1 -0
- package/dist/esm/Node.d.ts +677 -0
- package/dist/esm/Node.d.ts.map +1 -0
- package/dist/esm/Node.js +586 -0
- package/dist/esm/Node.js.map +1 -0
- package/dist/esm/Placement.d.ts +117 -0
- package/dist/esm/Placement.d.ts.map +1 -0
- package/dist/esm/Placement.js +65 -0
- package/dist/esm/Placement.js.map +1 -0
- package/dist/esm/Plan.d.ts +489 -0
- package/dist/esm/Plan.d.ts.map +1 -0
- package/dist/esm/Plan.js +718 -0
- package/dist/esm/Plan.js.map +1 -0
- package/dist/esm/PlanDiff.d.ts +77 -0
- package/dist/esm/PlanDiff.d.ts.map +1 -0
- package/dist/esm/PlanDiff.js +205 -0
- package/dist/esm/PlanDiff.js.map +1 -0
- package/dist/esm/Planned.d.ts +121 -0
- package/dist/esm/Planned.d.ts.map +1 -0
- package/dist/esm/Planned.js +147 -0
- package/dist/esm/Planned.js.map +1 -0
- package/dist/esm/Repetition.d.ts +31 -0
- package/dist/esm/Repetition.d.ts.map +1 -0
- package/dist/esm/Repetition.js +24 -0
- package/dist/esm/Repetition.js.map +1 -0
- package/dist/esm/Scheduling.d.ts +89 -0
- package/dist/esm/Scheduling.d.ts.map +1 -0
- package/dist/esm/Scheduling.js +82 -0
- package/dist/esm/Scheduling.js.map +1 -0
- package/dist/esm/StepKey.d.ts +354 -0
- package/dist/esm/StepKey.d.ts.map +1 -0
- package/dist/esm/StepKey.js +503 -0
- package/dist/esm/StepKey.js.map +1 -0
- package/dist/esm/index.d.ts +91 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +91 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal/ConflictAnnotation.d.ts +59 -0
- package/dist/esm/internal/ConflictAnnotation.d.ts.map +1 -0
- package/dist/esm/internal/ConflictAnnotation.js +332 -0
- package/dist/esm/internal/ConflictAnnotation.js.map +1 -0
- package/dist/esm/internal/EffectCandidates.d.ts +19 -0
- package/dist/esm/internal/EffectCandidates.d.ts.map +1 -0
- package/dist/esm/internal/EffectCandidates.js +86 -0
- package/dist/esm/internal/EffectCandidates.js.map +1 -0
- package/dist/esm/internal/JsonMirror.d.ts +34 -0
- package/dist/esm/internal/JsonMirror.d.ts.map +1 -0
- package/dist/esm/internal/JsonMirror.js +204 -0
- package/dist/esm/internal/JsonMirror.js.map +1 -0
- package/dist/esm/internal/SchemaIdentity.d.ts +140 -0
- package/dist/esm/internal/SchemaIdentity.d.ts.map +1 -0
- package/dist/esm/internal/SchemaIdentity.js +1002 -0
- package/dist/esm/internal/SchemaIdentity.js.map +1 -0
- package/dist/esm/internal/effects.d.ts +245 -0
- package/dist/esm/internal/effects.d.ts.map +1 -0
- package/dist/esm/internal/effects.js +459 -0
- package/dist/esm/internal/effects.js.map +1 -0
- package/dist/esm/internal/node.d.ts +526 -0
- package/dist/esm/internal/node.d.ts.map +1 -0
- package/dist/esm/internal/node.js +565 -0
- package/dist/esm/internal/node.js.map +1 -0
- package/dist/esm/test/PlanFixtures.d.ts +127 -0
- package/dist/esm/test/PlanFixtures.d.ts.map +1 -0
- package/dist/esm/test/PlanFixtures.js +60 -0
- package/dist/esm/test/PlanFixtures.js.map +1 -0
- package/docs/README.md +167 -0
- package/docs/api.md +1485 -0
- package/docs/concepts/authoring-ast.md +204 -0
- package/docs/concepts/effects-and-conflicts.md +135 -0
- package/docs/concepts/plan-value.md +168 -0
- package/docs/concepts/step-keys.md +179 -0
- package/docs/guides/author-a-node-graph.md +182 -0
- package/docs/guides/compile-a-plan.md +146 -0
- package/docs/guides/declare-file-effects.md +143 -0
- package/docs/guides/diff-two-plans.md +310 -0
- package/docs/installation.md +75 -0
- package/docs/quickstart.md +128 -0
- package/docs/testing.md +73 -0
- package/docs/troubleshooting.md +314 -0
- package/package.json +255 -3
- package/src/CachePolicy.ts +143 -0
- package/src/Effects.ts +302 -0
- package/src/FileSet.ts +493 -0
- package/src/GraphBuildError.ts +156 -0
- package/src/KeyMaterial.ts +111 -0
- package/src/Node.ts +969 -0
- package/src/Placement.ts +99 -0
- package/src/Plan.ts +911 -0
- package/src/PlanDiff.ts +244 -0
- package/src/Planned.ts +208 -0
- package/src/Repetition.ts +33 -0
- package/src/Scheduling.ts +154 -0
- package/src/StepKey.ts +736 -0
- package/src/index.ts +103 -0
- package/src/internal/ConflictAnnotation.ts +374 -0
- package/src/internal/EffectCandidates.ts +89 -0
- package/src/internal/JsonMirror.ts +255 -0
- package/src/internal/SchemaIdentity.ts +1096 -0
- package/src/internal/effects.ts +543 -0
- package/src/internal/node.ts +859 -0
- package/src/test/PlanFixtures.ts +76 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rebuildable candidate index for the compiler's existing overlap predicate.
|
|
3
|
+
* Exact paths and tree prefixes share a trie keyed by case-folded segments, the
|
|
4
|
+
* form FileSet.overlaps compares. A plain string is a literal path there, even
|
|
5
|
+
* one holding `*`. Globs stay conservative: their exclusions and pair semantics
|
|
6
|
+
* are decided by FileSet.overlaps, never here.
|
|
7
|
+
* Nothing in this index becomes persisted plan or key material.
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
import * as FileSet from "../FileSet.ts";
|
|
12
|
+
/**
|
|
13
|
+
* Selects possible producers in declaration order; callers retain the final
|
|
14
|
+
* FileSet.overlaps check for every selected pair.
|
|
15
|
+
* @since 0.1.0
|
|
16
|
+
* @private
|
|
17
|
+
*/
|
|
18
|
+
export declare const make: (produced: ReadonlyArray<ReadonlyArray<FileSet.Entry>>) => (entries: ReadonlyArray<FileSet.Entry>) => ReadonlyArray<number>;
|
|
19
|
+
//# sourceMappingURL=EffectCandidates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EffectCandidates.d.ts","sourceRoot":"","sources":["../../../src/internal/EffectCandidates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAgBxC;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,UAAU,aAAa,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MA0BhE,SAAS,aAAa,CAAC,OAAO,CAAC,KAAK,CAAC,KAAG,aAAa,CAAC,MAAM,CA6BrE,CAAA"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rebuildable candidate index for the compiler's existing overlap predicate.
|
|
3
|
+
* Exact paths and tree prefixes share a trie keyed by case-folded segments, the
|
|
4
|
+
* form FileSet.overlaps compares. A plain string is a literal path there, even
|
|
5
|
+
* one holding `*`. Globs stay conservative: their exclusions and pair semantics
|
|
6
|
+
* are decided by FileSet.overlaps, never here.
|
|
7
|
+
* Nothing in this index becomes persisted plan or key material.
|
|
8
|
+
* @since 0.1.0
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
import * as FileSet from "../FileSet.js";
|
|
12
|
+
const branch = () => ({ children: new Map(), exact: new Set(), trees: new Set() });
|
|
13
|
+
const add = (target, values) => {
|
|
14
|
+
for (const value of values)
|
|
15
|
+
target.add(value);
|
|
16
|
+
};
|
|
17
|
+
/** A Glob has no single trie position, so it stays conservative. */
|
|
18
|
+
const patternLike = (entry) => typeof entry !== "string" && entry._tag === "Glob";
|
|
19
|
+
const ordered = (values) => Array.from(values).sort((left, right) => left - right);
|
|
20
|
+
/**
|
|
21
|
+
* Selects possible producers in declaration order; callers retain the final
|
|
22
|
+
* FileSet.overlaps check for every selected pair.
|
|
23
|
+
* @since 0.1.0
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
export const make = (produced) => {
|
|
27
|
+
const root = branch();
|
|
28
|
+
const all = new Set();
|
|
29
|
+
const globs = new Set();
|
|
30
|
+
for (let owner = 0; owner < produced.length; owner++) {
|
|
31
|
+
for (const entry of produced[owner]) {
|
|
32
|
+
all.add(owner);
|
|
33
|
+
if (patternLike(entry)) {
|
|
34
|
+
globs.add(owner);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
const path = typeof entry === "string" ? entry : entry.path;
|
|
38
|
+
let current = root;
|
|
39
|
+
for (const segment of FileSet.folded(path).split("/")) {
|
|
40
|
+
let child = current.children.get(segment);
|
|
41
|
+
if (child === undefined) {
|
|
42
|
+
child = branch();
|
|
43
|
+
current.children.set(segment, child);
|
|
44
|
+
}
|
|
45
|
+
current = child;
|
|
46
|
+
}
|
|
47
|
+
const owners = typeof entry === "string" ? current.exact : current.trees;
|
|
48
|
+
owners.add(owner);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return (entries) => {
|
|
52
|
+
const found = new Set();
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
// A glob can overlap every other glob/tree; literal matches and
|
|
55
|
+
// exclusions remain the final predicate's responsibility as well.
|
|
56
|
+
if (patternLike(entry))
|
|
57
|
+
return ordered(all);
|
|
58
|
+
add(found, globs);
|
|
59
|
+
const path = typeof entry === "string" ? entry : entry.path;
|
|
60
|
+
let current = root;
|
|
61
|
+
for (const segment of FileSet.folded(path).split("/")) {
|
|
62
|
+
current = current.children.get(segment);
|
|
63
|
+
if (current === undefined)
|
|
64
|
+
break;
|
|
65
|
+
add(found, current.trees);
|
|
66
|
+
}
|
|
67
|
+
if (current === undefined)
|
|
68
|
+
continue;
|
|
69
|
+
add(found, current.exact);
|
|
70
|
+
if (typeof entry === "string")
|
|
71
|
+
continue;
|
|
72
|
+
const stack = Array.from(current.children.values());
|
|
73
|
+
while (stack.length > 0) {
|
|
74
|
+
const descendant = stack.pop();
|
|
75
|
+
add(found, descendant.exact);
|
|
76
|
+
add(found, descendant.trees);
|
|
77
|
+
for (const child of descendant.children.values())
|
|
78
|
+
stack.push(child);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Original declaration order controls annotations, conflict precedence,
|
|
82
|
+
// and cycle diagnostics, irrespective of trie or Set traversal order.
|
|
83
|
+
return ordered(found);
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=EffectCandidates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EffectCandidates.js","sourceRoot":"","sources":["../../../src/internal/EffectCandidates.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAQxC,MAAM,MAAM,GAAG,GAAW,EA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K,CAAC,GAAG,CAAC,EAAE,CAAC;gBACtD,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;gBACvC,IAAI,OAAO,KAAK,SAAS;oBAAE,MAAK;gBAChC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;YAC3B,CAAC;YACD,IAAI,OAAO,KAAK,SAAS;gBAAE,SAAQ;YACnC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;YACzB,IAAI,OAAO,KAAK,KAAK,QAAQ;gBAAE,SAAQ;YACvC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;YACnD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxB,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,EAAG,CAAA;gBAC/B,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;gBAC5B,GAAG,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;gBAC5B,KAAK,MAAM,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,MAAM,EAAE;oBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACrE,CAAC;QACH,CAAC;QACD,wEAAwE;QACxE,sEAAsE;QACtE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["/**\n * Rebuildable candidate index for the compiler's existing overlap predicate.\n * Exact paths and tree prefixes share a trie keyed by case-folded segments, the\n * form FileSet.overlaps compares. A plain string is a literal path there, even\n * one holding `*`. Globs stay conservative: their exclusions and pair semantics\n * are decided by FileSet.overlaps, never here.\n * Nothing in this index becomes persisted plan or key material.\n * @since 0.1.0\n * @private\n */\n\nimport * as FileSet from \"../FileSet.ts\"\n\ninterface Branch {\n readonly children: Map<string, Branch>\n readonly exact: Set<number>\n readonly trees: Set<number>\n}\n\nconst branch = (): Branch => ({ children: new Map(), exact: new Set(), trees: new Set() })\nconst add = (target: Set<number>, values: ReadonlySet<number>): void => {\n for (const value of values) target.add(value)\n}\n/** A Glob has no single trie position, so it stays conservative. */\nconst patternLike = (entry: FileSet.Entry): entry is FileSet.Glob => typeof entry !== \"string\" && entry._tag === \"Glob\"\nconst ordered = (values: ReadonlySet<number>): Array<number> => Array.from(values).sort((left, right) => left - right)\n\n/**\n * Selects possible producers in declaration order; callers retain the final\n * FileSet.overlaps check for every selected pair.\n * @since 0.1.0\n * @private\n */\nexport const make = (produced: ReadonlyArray<ReadonlyArray<FileSet.Entry>>) => {\n const root = branch()\n const all = new Set<number>()\n const globs = new Set<number>()\n for (let owner = 0; owner < produced.length; owner++) {\n for (const entry of produced[owner]!) {\n all.add(owner)\n if (patternLike(entry)) {\n globs.add(owner)\n continue\n }\n const path = typeof entry === \"string\" ? entry : entry.path\n let current = root\n for (const segment of FileSet.folded(path).split(\"/\")) {\n let child = current.children.get(segment)\n if (child === undefined) {\n child = branch()\n current.children.set(segment, child)\n }\n current = child\n }\n const owners = typeof entry === \"string\" ? current.exact : current.trees\n owners.add(owner)\n }\n }\n\n return (entries: ReadonlyArray<FileSet.Entry>): ReadonlyArray<number> => {\n const found = new Set<number>()\n for (const entry of entries) {\n // A glob can overlap every other glob/tree; literal matches and\n // exclusions remain the final predicate's responsibility as well.\n if (patternLike(entry)) return ordered(all)\n add(found, globs)\n const path = typeof entry === \"string\" ? entry : entry.path\n let current: Branch | undefined = root\n for (const segment of FileSet.folded(path).split(\"/\")) {\n current = current.children.get(segment)\n if (current === undefined) break\n add(found, current.trees)\n }\n if (current === undefined) continue\n add(found, current.exact)\n if (typeof entry === \"string\") continue\n const stack = Array.from(current.children.values())\n while (stack.length > 0) {\n const descendant = stack.pop()!\n add(found, descendant.exact)\n add(found, descendant.trees)\n for (const child of descendant.children.values()) stack.push(child)\n }\n }\n // Original declaration order controls annotations, conflict precedence,\n // and cycle diagnostics, irrespective of trie or Set traversal order.\n return ordered(found)\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inert JSON mirror of a value: what `JSON.stringify` would see, as data.
|
|
3
|
+
*
|
|
4
|
+
* The AST stores payloads this way, the plan compiler stores key material this
|
|
5
|
+
* way, and a plan diff compares declarations this way, so all three share the
|
|
6
|
+
* one walk. A planned value is the only member with no JSON meaning of its
|
|
7
|
+
* own, and each caller decides what it becomes.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
import * as Planned from "../Planned.ts";
|
|
13
|
+
/**
|
|
14
|
+
* Clones the JSON mirror of the input, so {@link module:StepKey.content} over
|
|
15
|
+
* the clone and the input produce the same key and the clone holds only inert
|
|
16
|
+
* JSON data. The walk uses an explicit stack, memoizes shared references and
|
|
17
|
+
* cycles, honors callable `toJSON`, omits object members without a JSON
|
|
18
|
+
* representation, and writes `null` for those values in arrays.
|
|
19
|
+
*
|
|
20
|
+
* `toJSON` receives the key canonical serialization passes it: the member
|
|
21
|
+
* name, the array index, or `""` at the root. Its replacement is therefore
|
|
22
|
+
* memoized per source and key, since one shared source may serialize
|
|
23
|
+
* differently at two positions. A source met again inside its own
|
|
24
|
+
* replacement reuses that replacement, so a cycle through `toJSON` clones as
|
|
25
|
+
* a cycle whatever key it recurs at.
|
|
26
|
+
*
|
|
27
|
+
* A planned value becomes whatever `plannedValue` returns for it. Refusals
|
|
28
|
+
* throw a {@link GraphBuildError} naming the member's path.
|
|
29
|
+
*
|
|
30
|
+
* @since 0.1.0
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
export declare const jsonMirror: (input: unknown, plannedValue: (value: unknown, reference: Planned.Reference) => unknown) => unknown;
|
|
34
|
+
//# sourceMappingURL=JsonMirror.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonMirror.d.ts","sourceRoot":"","sources":["../../../src/internal/JsonMirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAqFxC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU,GACrB,OAAO,OAAO,EACd,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,KAAK,OAAO,KACtE,OAqIF,CAAA"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The inert JSON mirror of a value: what `JSON.stringify` would see, as data.
|
|
3
|
+
*
|
|
4
|
+
* The AST stores payloads this way, the plan compiler stores key material this
|
|
5
|
+
* way, and a plan diff compares declarations this way, so all three share the
|
|
6
|
+
* one walk. A planned value is the only member with no JSON meaning of its
|
|
7
|
+
* own, and each caller decides what it becomes.
|
|
8
|
+
*
|
|
9
|
+
* @since 0.1.0
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
import { GraphBuildError } from "../GraphBuildError.js";
|
|
13
|
+
import * as Planned from "../Planned.js";
|
|
14
|
+
/** The chain read outwards, root first: the array the refusals report. */
|
|
15
|
+
const clonePath = (path) => {
|
|
16
|
+
const keys = [];
|
|
17
|
+
for (let current = path; current !== undefined; current = current.parent)
|
|
18
|
+
keys.push(current.key);
|
|
19
|
+
return keys.reverse();
|
|
20
|
+
};
|
|
21
|
+
const payloadError = (at, reason) => {
|
|
22
|
+
const path = clonePath(at);
|
|
23
|
+
return new GraphBuildError({
|
|
24
|
+
code: "invalid_payload",
|
|
25
|
+
node: "payload",
|
|
26
|
+
path,
|
|
27
|
+
message: `Plan payload at ${path.length === 0 ? "$" : `$.${path.join(".")}`} ${reason}`
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const cyclicPayloadError = (at) => {
|
|
31
|
+
const path = clonePath(at);
|
|
32
|
+
return new GraphBuildError({
|
|
33
|
+
code: "cyclic_payload",
|
|
34
|
+
node: "payload",
|
|
35
|
+
path,
|
|
36
|
+
message: `Plan payload at ${path.length === 0 ? "$" : `$.${path.join(".")}`} has a toJSON method that returns itself`
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const inheritedDataProperty = (value, key) => {
|
|
40
|
+
let current = value;
|
|
41
|
+
while (current !== null) {
|
|
42
|
+
const descriptor = Object.getOwnPropertyDescriptor(current, key);
|
|
43
|
+
if (descriptor !== undefined) {
|
|
44
|
+
return "value" in descriptor ? { kind: "data", value: descriptor.value } : { kind: "accessor" };
|
|
45
|
+
}
|
|
46
|
+
current = Object.getPrototypeOf(current);
|
|
47
|
+
}
|
|
48
|
+
return { kind: "missing" };
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Clones the JSON mirror of the input, so {@link module:StepKey.content} over
|
|
52
|
+
* the clone and the input produce the same key and the clone holds only inert
|
|
53
|
+
* JSON data. The walk uses an explicit stack, memoizes shared references and
|
|
54
|
+
* cycles, honors callable `toJSON`, omits object members without a JSON
|
|
55
|
+
* representation, and writes `null` for those values in arrays.
|
|
56
|
+
*
|
|
57
|
+
* `toJSON` receives the key canonical serialization passes it: the member
|
|
58
|
+
* name, the array index, or `""` at the root. Its replacement is therefore
|
|
59
|
+
* memoized per source and key, since one shared source may serialize
|
|
60
|
+
* differently at two positions. A source met again inside its own
|
|
61
|
+
* replacement reuses that replacement, so a cycle through `toJSON` clones as
|
|
62
|
+
* a cycle whatever key it recurs at.
|
|
63
|
+
*
|
|
64
|
+
* A planned value becomes whatever `plannedValue` returns for it. Refusals
|
|
65
|
+
* throw a {@link GraphBuildError} naming the member's path.
|
|
66
|
+
*
|
|
67
|
+
* @since 0.1.0
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
export const jsonMirror = (input, plannedValue) => {
|
|
71
|
+
const missing = Symbol("missing JSON representation");
|
|
72
|
+
const seen = new WeakMap();
|
|
73
|
+
const replacedAt = new WeakMap();
|
|
74
|
+
const open = new Map();
|
|
75
|
+
let result;
|
|
76
|
+
const frames = [];
|
|
77
|
+
/** Resolves one member, opening a frame when it is an unseen container. */
|
|
78
|
+
const enter = (initial, place, path) => {
|
|
79
|
+
let current = initial;
|
|
80
|
+
const key = path === undefined ? "" : path.key;
|
|
81
|
+
const replacements = [];
|
|
82
|
+
const resolving = new WeakSet();
|
|
83
|
+
const finish = (member) => {
|
|
84
|
+
for (const replacement of replacements) {
|
|
85
|
+
let byKey = replacedAt.get(replacement);
|
|
86
|
+
if (byKey === undefined)
|
|
87
|
+
replacedAt.set(replacement, byKey = new Map());
|
|
88
|
+
byKey.set(key, member);
|
|
89
|
+
}
|
|
90
|
+
place(member);
|
|
91
|
+
};
|
|
92
|
+
while (true) {
|
|
93
|
+
const reference = Planned.reference(current);
|
|
94
|
+
if (reference !== undefined) {
|
|
95
|
+
finish(plannedValue(current, reference));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const kind = typeof current;
|
|
99
|
+
if (current === null || (kind !== "object" && kind !== "function")) {
|
|
100
|
+
finish(kind === "undefined" || kind === "symbol" ? missing : current);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const source = current;
|
|
104
|
+
if (seen.has(source)) {
|
|
105
|
+
finish(seen.get(source));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (resolving.has(source)) {
|
|
109
|
+
throw cyclicPayloadError(path);
|
|
110
|
+
}
|
|
111
|
+
const toJSON = inheritedDataProperty(source, "toJSON");
|
|
112
|
+
if (toJSON.kind === "accessor") {
|
|
113
|
+
throw payloadError(path, "has an accessor-backed toJSON member");
|
|
114
|
+
}
|
|
115
|
+
if (toJSON.kind === "data" && typeof toJSON.value === "function") {
|
|
116
|
+
const byKey = replacedAt.get(source);
|
|
117
|
+
if (byKey !== undefined && byKey.has(key)) {
|
|
118
|
+
finish(byKey.get(key));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (open.has(source)) {
|
|
122
|
+
finish(open.get(source));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
resolving.add(source);
|
|
126
|
+
replacements.push(source);
|
|
127
|
+
current = Reflect.apply(toJSON.value, source, [key]);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (kind === "function") {
|
|
131
|
+
seen.set(source, missing);
|
|
132
|
+
finish(missing);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const prototype = Object.getPrototypeOf(source);
|
|
136
|
+
if (!Array.isArray(source) && prototype !== Object.prototype && prototype !== null) {
|
|
137
|
+
throw payloadError(path, "has an unsupported prototype and no data-valued toJSON method");
|
|
138
|
+
}
|
|
139
|
+
const container = current;
|
|
140
|
+
const descriptors = Object.getOwnPropertyDescriptors(container);
|
|
141
|
+
const output = Array.isArray(container)
|
|
142
|
+
? []
|
|
143
|
+
: Object.create(null);
|
|
144
|
+
seen.set(container, output);
|
|
145
|
+
finish(output);
|
|
146
|
+
frames.push({
|
|
147
|
+
source: container,
|
|
148
|
+
output,
|
|
149
|
+
descriptors,
|
|
150
|
+
keys: Array.isArray(container)
|
|
151
|
+
? undefined
|
|
152
|
+
: Reflect.ownKeys(descriptors).filter((key) => typeof key === "string" && descriptors[key].enumerable === true),
|
|
153
|
+
path,
|
|
154
|
+
replaced: replacements,
|
|
155
|
+
index: 0
|
|
156
|
+
});
|
|
157
|
+
for (const replacement of replacements)
|
|
158
|
+
open.set(replacement, output);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
enter(input, (member) => {
|
|
163
|
+
result = member === missing ? undefined : member;
|
|
164
|
+
}, undefined);
|
|
165
|
+
while (frames.length > 0) {
|
|
166
|
+
const frame = frames[frames.length - 1];
|
|
167
|
+
if (frame.index >= (frame.keys ?? frame.source).length) {
|
|
168
|
+
frames.pop();
|
|
169
|
+
for (const replacement of frame.replaced)
|
|
170
|
+
open.delete(replacement);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const position = frame.index;
|
|
174
|
+
frame.index = position + 1;
|
|
175
|
+
if (frame.keys === undefined) {
|
|
176
|
+
const members = frame.output;
|
|
177
|
+
const descriptor = frame.descriptors[String(position)];
|
|
178
|
+
if (descriptor !== undefined && !("value" in descriptor)) {
|
|
179
|
+
throw payloadError({ parent: frame.path, key: String(position) }, "is an accessor");
|
|
180
|
+
}
|
|
181
|
+
enter(descriptor === undefined ? undefined : descriptor.value, (member) => {
|
|
182
|
+
members.push(member === missing ? null : member);
|
|
183
|
+
}, { parent: frame.path, key: String(position) });
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const key = frame.keys[position];
|
|
187
|
+
const descriptor = frame.descriptors[key];
|
|
188
|
+
if (!("value" in descriptor))
|
|
189
|
+
throw payloadError({ parent: frame.path, key }, "is an accessor");
|
|
190
|
+
enter(descriptor.value, (member) => {
|
|
191
|
+
if (member === missing)
|
|
192
|
+
return;
|
|
193
|
+
Object.defineProperty(frame.output, key, {
|
|
194
|
+
configurable: true,
|
|
195
|
+
enumerable: true,
|
|
196
|
+
value: member,
|
|
197
|
+
writable: true
|
|
198
|
+
});
|
|
199
|
+
}, { parent: frame.path, key });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return result;
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=JsonMirror.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonMirror.js","sourceRoot":"","sources":["../../../src/internal/JsonMirror.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,OAAO,MAAM,eAAe,CAAA;AAqCxC,0EAA0E;AAC1E,MAAM,SAAS,GAAG,CAAC,IAAe,EAAyB,EAAE;IAC3D,MAAM,IAAI,GAAkB,EAAE,CAAA;IAC9B,KAAK,IAAI,OAAO,GAAG,IA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,IAAI,CAAC,CAAC,OAAO,IAAI,UAAU,CAAC;gBAAE,MAAM,YAAY,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAA;YAC/F,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE;gBACjC,IAAI,MAAM,KAAK,OAAO;oBAAE,OAAM;gBAC9B,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE;oBACvC,YAAY,EAAE,IAAI;oBAClB,UAAU,EAAE,IAAI;oBAChB,KAAK,EAAE,MAAM;oBACb,QAAQ,EAAE,IAAI;iBACf,CAAC,CAAA;YACJ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["/**\n * The inert JSON mirror of a value: what `JSON.stringify` would see, as data.\n *\n * The AST stores payloads this way, the plan compiler stores key material this\n * way, and a plan diff compares declarations this way, so all three share the\n * one walk. A planned value is the only member with no JSON meaning of its\n * own, and each caller decides what it becomes.\n *\n * @since 0.1.0\n * @private\n */\n\nimport { GraphBuildError } from \"../GraphBuildError.ts\"\nimport * as Planned from \"../Planned.ts\"\n\n/**\n * One container being cloned: the object walked, the clone being filled, and\n * the member position the walk has reached. `keys` is `undefined` for an\n * array, whose members are positional.\n *\n * @since 0.1.0\n * @private\n */\ninterface CloneFrame {\n readonly source: Record<string, unknown> | ReadonlyArray<unknown>\n readonly output: Record<string, unknown> | Array<unknown>\n readonly descriptors: PropertyDescriptorMap\n readonly keys: ReadonlyArray<string> | undefined\n readonly path: ClonePath\n /** Sources whose callable `toJSON` resolved to this container. */\n readonly replaced: ReadonlyArray<object>\n index: number\n}\n\n/**\n * Where the walk stands, as a link to its parent rather than a copy of the\n * whole path. Payload depth is bounded only by the caller, and copying the\n * path at each member made a clone cost memory quadratic in that depth: a\n * 20,000-deep payload held 20,000 live frames whose paths together ran to\n * hundreds of millions of entries, several gigabytes, for a result that is\n * linear. The path is read only to name a member in a refusal, so it stays a\n * chain here and is flattened at the throw.\n *\n * `undefined` is the root, whose path is empty.\n *\n * @since 0.1.0\n * @private\n */\ntype ClonePath = { readonly parent: ClonePath; readonly key: string } | undefined\n\n/** The chain read outwards, root first: the array the refusals report. */\nconst clonePath = (path: ClonePath): ReadonlyArray<string> => {\n const keys: Array<string> = []\n for (let current = path; current !== undefined; current = current.parent) keys.push(current.key)\n return keys.reverse()\n}\n\nconst payloadError = (at: ClonePath, reason: string): GraphBuildError => {\n const path = clonePath(at)\n return new GraphBuildError({\n code: \"invalid_payload\",\n node: \"payload\",\n path,\n message: `Plan payload at ${path.length === 0 ? \"$\" : `$.${path.join(\".\")}`} ${reason}`\n })\n}\n\nconst cyclicPayloadError = (at: ClonePath): GraphBuildError => {\n const path = clonePath(at)\n return new GraphBuildError({\n code: \"cyclic_payload\",\n node: \"payload\",\n path,\n message: `Plan payload at ${\n path.length === 0 ? \"$\" : `$.${path.join(\".\")}`\n } has a toJSON method that returns itself`\n })\n}\n\nconst inheritedDataProperty = (\n value: object,\n key: PropertyKey\n):\n | { readonly kind: \"data\"; readonly value: unknown }\n | { readonly kind: \"accessor\" }\n | { readonly kind: \"missing\" } =>\n{\n let current: object | null = value\n while (current !== null) {\n const descriptor = Object.getOwnPropertyDescriptor(current, key)\n if (descriptor !== undefined) {\n return \"value\" in descriptor ? { kind: \"data\", value: descriptor.value } : { kind: \"accessor\" }\n }\n current = Object.getPrototypeOf(current) as object | null\n }\n return { kind: \"missing\" }\n}\n\n/**\n * Clones the JSON mirror of the input, so {@link module:StepKey.content} over\n * the clone and the input produce the same key and the clone holds only inert\n * JSON data. The walk uses an explicit stack, memoizes shared references and\n * cycles, honors callable `toJSON`, omits object members without a JSON\n * representation, and writes `null` for those values in arrays.\n *\n * `toJSON` receives the key canonical serialization passes it: the member\n * name, the array index, or `\"\"` at the root. Its replacement is therefore\n * memoized per source and key, since one shared source may serialize\n * differently at two positions. A source met again inside its own\n * replacement reuses that replacement, so a cycle through `toJSON` clones as\n * a cycle whatever key it recurs at.\n *\n * A planned value becomes whatever `plannedValue` returns for it. Refusals\n * throw a {@link GraphBuildError} naming the member's path.\n *\n * @since 0.1.0\n * @private\n */\nexport const jsonMirror = (\n input: unknown,\n plannedValue: (value: unknown, reference: Planned.Reference) => unknown\n): unknown => {\n const missing = Symbol(\"missing JSON representation\")\n const seen = new WeakMap<object, unknown>()\n const replacedAt = new WeakMap<object, Map<string, unknown>>()\n const open = new Map<object, unknown>()\n let result: unknown\n const frames: Array<CloneFrame> = []\n /** Resolves one member, opening a frame when it is an unseen container. */\n const enter = (\n initial: unknown,\n place: (member: unknown | typeof missing) => void,\n path: ClonePath\n ): void => {\n let current = initial\n const key = path === undefined ? \"\" : path.key\n const replacements: Array<object> = []\n const resolving = new WeakSet<object>()\n const finish = (member: unknown | typeof missing): void => {\n for (const replacement of replacements) {\n let byKey = replacedAt.get(replacement)\n if (byKey === undefined) replacedAt.set(replacement, byKey = new Map())\n byKey.set(key, member)\n }\n place(member)\n }\n while (true) {\n const reference = Planned.reference(current)\n if (reference !== undefined) {\n finish(plannedValue(current, reference))\n return\n }\n const kind = typeof current\n if (current === null || (kind !== \"object\" && kind !== \"function\")) {\n finish(kind === \"undefined\" || kind === \"symbol\" ? missing : current)\n return\n }\n const source = current as object\n if (seen.has(source)) {\n finish(seen.get(source))\n return\n }\n if (resolving.has(source)) {\n throw cyclicPayloadError(path)\n }\n const toJSON = inheritedDataProperty(source, \"toJSON\")\n if (toJSON.kind === \"accessor\") {\n throw payloadError(path, \"has an accessor-backed toJSON member\")\n }\n if (toJSON.kind === \"data\" && typeof toJSON.value === \"function\") {\n const byKey = replacedAt.get(source)\n if (byKey !== undefined && byKey.has(key)) {\n finish(byKey.get(key))\n return\n }\n if (open.has(source)) {\n finish(open.get(source))\n return\n }\n resolving.add(source)\n replacements.push(source)\n current = Reflect.apply(toJSON.value, source, [key])\n continue\n }\n if (kind === \"function\") {\n seen.set(source, missing)\n finish(missing)\n return\n }\n const prototype = Object.getPrototypeOf(source)\n if (!Array.isArray(source) && prototype !== Object.prototype && prototype !== null) {\n throw payloadError(path, \"has an unsupported prototype and no data-valued toJSON method\")\n }\n const container = current as Record<string, unknown> | ReadonlyArray<unknown>\n const descriptors = Object.getOwnPropertyDescriptors(container) as PropertyDescriptorMap\n const output: Record<string, unknown> | Array<unknown> = Array.isArray(container)\n ? []\n : Object.create(null) as Record<string, unknown>\n seen.set(container, output)\n finish(output)\n frames.push({\n source: container,\n output,\n descriptors,\n keys: Array.isArray(container)\n ? undefined\n : Reflect.ownKeys(descriptors).filter((key): key is string =>\n typeof key === \"string\" && descriptors[key]!.enumerable === true\n ),\n path,\n replaced: replacements,\n index: 0\n })\n for (const replacement of replacements) open.set(replacement, output)\n return\n }\n }\n enter(input, (member) => {\n result = member === missing ? undefined : member\n }, undefined)\n while (frames.length > 0) {\n const frame = frames[frames.length - 1]!\n if (frame.index >= (frame.keys ?? frame.source as ReadonlyArray<unknown>).length) {\n frames.pop()\n for (const replacement of frame.replaced) open.delete(replacement)\n continue\n }\n const position = frame.index\n frame.index = position + 1\n if (frame.keys === undefined) {\n const members = frame.output as Array<unknown>\n const descriptor = frame.descriptors[String(position)]\n if (descriptor !== undefined && !(\"value\" in descriptor)) {\n throw payloadError({ parent: frame.path, key: String(position) }, \"is an accessor\")\n }\n enter(descriptor === undefined ? undefined : descriptor.value, (member) => {\n members.push(member === missing ? null : member)\n }, { parent: frame.path, key: String(position) })\n } else {\n const key = frame.keys[position]!\n const descriptor = frame.descriptors[key]!\n if (!(\"value\" in descriptor)) throw payloadError({ parent: frame.path, key }, \"is an accessor\")\n enter(descriptor.value, (member) => {\n if (member === missing) return\n Object.defineProperty(frame.output, key, {\n configurable: true,\n enumerable: true,\n value: member,\n writable: true\n })\n }, { parent: frame.path, key })\n }\n }\n return result\n}\n"]}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The schema identity projection: the JSON-Schema-shaped document a schema
|
|
3
|
+
* contributes to a step key.
|
|
4
|
+
*
|
|
5
|
+
* A call node folds what its callee accepts and produces into the material a
|
|
6
|
+
* step key is derived from, and a catch node folds its filter the same way. A
|
|
7
|
+
* projection that printed differently under another `effect` release would
|
|
8
|
+
* re-key every recorded step in every journal at once. `effect` is a peer
|
|
9
|
+
* range, so the application picks the release; the projection therefore
|
|
10
|
+
* cannot be the installed `Schema.toJsonSchemaDocument`. `effect@4.0.4`
|
|
11
|
+
* already changed what that emitter prints for `Schema.Int`, `isMinLength`,
|
|
12
|
+
* `isPattern`, repeated bounds, `oneOf` unions and shared definitions.
|
|
13
|
+
*
|
|
14
|
+
* This module owns the bytes instead. It reads the schema through two public
|
|
15
|
+
* functions, `Schema.toCodecJson` and `Schema.toRepresentation`, and prints
|
|
16
|
+
* the result with the emitter and the check fragments fixed below, which
|
|
17
|
+
* reproduce `Schema.toJsonSchemaDocument(schema, options)` of
|
|
18
|
+
* `effect@4.0.0-rc.115` for both values of `onExcessProperty`.
|
|
19
|
+
*
|
|
20
|
+
* It is for identity only. Where a JSON Schema is shown to a model or a
|
|
21
|
+
* person, the installed emitter is the right one.
|
|
22
|
+
*
|
|
23
|
+
* What still moves an identity, by design: a release that changes a schema's
|
|
24
|
+
* JSON codec or its representation changes what the schema accepts on the
|
|
25
|
+
* wire. Three limits follow from what the representation carries:
|
|
26
|
+
*
|
|
27
|
+
* - A built-in check contributes the constraint its id and payload name. A
|
|
28
|
+
* `toJsonSchema` annotation passed to a built-in check constructor is not
|
|
29
|
+
* consulted; one on a `makeFilter` check is.
|
|
30
|
+
* - A built-in check this module does not list falls back to the installed
|
|
31
|
+
* check's own `toJsonSchema` annotation.
|
|
32
|
+
* - `Schema.brand` is not part of the representation from `effect@4.0.4` on.
|
|
33
|
+
* Under rc.115 a schema that takes a definition (an `identifier` or a
|
|
34
|
+
* recursive schema) and appeared both branded and unbranded in one document
|
|
35
|
+
* got two definitions; it now gets one.
|
|
36
|
+
*
|
|
37
|
+
* Provenance: {@link fromRepresentation} and its helpers are adapted from
|
|
38
|
+
* `effect@4.0.0-rc.115` (MIT, Copyright (c) 2023 Effectful Technologies Inc;
|
|
39
|
+
* the notice is in this package's `THIRD_PARTY_NOTICES.md`), files
|
|
40
|
+
* `src/internal/schema/toJsonSchemaDocument.ts`, `src/JsonSchema.ts`
|
|
41
|
+
* (`rewriteRefs`), `src/JsonPointer.ts` and `src/SchemaAST.ts` (`isJson`).
|
|
42
|
+
* Changes: `onExcessProperty` is the only option; one root; a built-in
|
|
43
|
+
* check's fragment comes from {@link builtinChecks}, not from
|
|
44
|
+
* the installed annotation; an approximate check result contributes its
|
|
45
|
+
* schema.
|
|
46
|
+
*
|
|
47
|
+
* @since 1.0.0
|
|
48
|
+
*/
|
|
49
|
+
import type * as JsonSchema from "effect/JsonSchema";
|
|
50
|
+
import * as Schema from "effect/Schema";
|
|
51
|
+
import type * as SchemaAST from "effect/SchemaAST";
|
|
52
|
+
import * as SchemaRepresentation from "effect/SchemaRepresentation";
|
|
53
|
+
/**
|
|
54
|
+
* The document a schema's identity is: exactly what rc.115 returned from
|
|
55
|
+
* `Schema.toJsonSchemaDocument`, key order included.
|
|
56
|
+
*
|
|
57
|
+
* @since 1.0.0
|
|
58
|
+
* @private
|
|
59
|
+
*/
|
|
60
|
+
export type Document = JsonSchema.Document<"draft-2020-12">;
|
|
61
|
+
/**
|
|
62
|
+
* How an object schema treats a key it does not declare, which is the one
|
|
63
|
+
* emitter option a declaration's identity is taken under. It has rc.115's
|
|
64
|
+
* meaning and rc.115's default: `"ignore"` leaves such keys open, `"error"`
|
|
65
|
+
* closes them.
|
|
66
|
+
*
|
|
67
|
+
* @since 1.0.0
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
export interface Options {
|
|
71
|
+
readonly onExcessProperty?: "ignore" | "error" | undefined;
|
|
72
|
+
}
|
|
73
|
+
declare const SchemaIdentityError_base: Schema.Class<SchemaIdentityError, Schema.TaggedStruct<"@smthrs/plan/SchemaIdentityError", {
|
|
74
|
+
readonly message: Schema.String;
|
|
75
|
+
}>, import("effect/Cause").YieldableError>;
|
|
76
|
+
/**
|
|
77
|
+
* A schema a step key cannot be derived from: one with no JSON Schema form or
|
|
78
|
+
* no representation, or one whose built-in check the installed `effect`
|
|
79
|
+
* describes differently from the releases this package supports. The message
|
|
80
|
+
* is the one `effect@4.0.0-rc.115` gave for the same schema, where it gave one.
|
|
81
|
+
*
|
|
82
|
+
* @since 1.0.0
|
|
83
|
+
* @category errors
|
|
84
|
+
*/
|
|
85
|
+
export declare class SchemaIdentityError extends SchemaIdentityError_base {
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The ids {@link builtinChecks} lists, for the test that holds the list
|
|
89
|
+
* against the checks the installed `effect` can revive.
|
|
90
|
+
*
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
export declare const builtinCheckIds: ReadonlyArray<string>;
|
|
95
|
+
/**
|
|
96
|
+
* Prints a representation document as the JSON Schema document rc.115
|
|
97
|
+
* printed for it under the same options.
|
|
98
|
+
*
|
|
99
|
+
* Reserved for {@link schemaIdentity} and for the tests that hand it a
|
|
100
|
+
* representation no schema produces.
|
|
101
|
+
*
|
|
102
|
+
* @since 1.0.0
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
export declare const fromRepresentation: (document: SchemaRepresentation.Document, options?: Options) => Document;
|
|
106
|
+
/**
|
|
107
|
+
* The identity a schema contributes: a pure function of the schema and the
|
|
108
|
+
* option, and of nothing the installed `effect` release prints. It takes the
|
|
109
|
+
* place of `Schema.toJsonSchemaDocument(schema, options)` wherever the
|
|
110
|
+
* document is hashed, compared or pinned.
|
|
111
|
+
*
|
|
112
|
+
* Throws what rc.115 threw for a schema with no JSON Schema form: more than
|
|
113
|
+
* one rest element, a record key that is neither a string nor a template, a
|
|
114
|
+
* `toJsonSchema` annotation that throws.
|
|
115
|
+
*
|
|
116
|
+
* @since 1.0.0
|
|
117
|
+
* @private
|
|
118
|
+
*/
|
|
119
|
+
export declare const schemaIdentity: (schema: Schema.Top, options?: Options) => Document;
|
|
120
|
+
/**
|
|
121
|
+
* The representation identity of a schema AST: what
|
|
122
|
+
* `SchemaRepresentation.toJson(SchemaRepresentation.toRepresentation(ast))`
|
|
123
|
+
* returned under `effect@4.0.0-rc.115`, key order included. A sealed action's
|
|
124
|
+
* step key hashes it, so it must not move with the installed `effect`.
|
|
125
|
+
*
|
|
126
|
+
* The installed release encodes the representation; this writes back the six
|
|
127
|
+
* check ids renamed after rc.115. One difference cannot be undone: from
|
|
128
|
+
* `effect@4.0.4` on, `Schema.brand` is not part of the AST, so the `brands`
|
|
129
|
+
* annotation rc.115 wrote is absent and a declaration with a brand re-keys
|
|
130
|
+
* once.
|
|
131
|
+
*
|
|
132
|
+
* Throws what rc.115 threw for an AST with no representation, such as one
|
|
133
|
+
* whose check carries no `representation` annotation.
|
|
134
|
+
*
|
|
135
|
+
* @since 1.0.0
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
export declare const representationIdentity: (ast: SchemaAST.AST) => Schema.Json;
|
|
139
|
+
export {};
|
|
140
|
+
//# sourceMappingURL=SchemaIdentity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SchemaIdentity.d.ts","sourceRoot":"","sources":["../../../src/internal/SchemaIdentity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,KAAK,KAAK,UAAU,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,oBAAoB,MAAM,6BAA6B,CAAA;AAiBnE;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAA;AAE3D;;;;;;;;GAQG;AACH,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAA;CAC3D;;;;AAED;;;;;;;;GAQG;AACH,qBAAa,mBAAoB,SAAQ,wBAEvC;CAAG;AA2VL;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,MAAM,CAA6B,CAAA;AAyM/E;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,oBAAoB,CAAC,QAAQ,EAAE,UAAU,OAAO,KAAG,QAuV/F,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,CAAC,GAAG,EAAE,UAAU,OAAO,KAAG,QACW,CAAA;AAkDlF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,SAAS,CAAC,GAAG,KAAG,MAAM,CAAC,IACyB,CAAA"}
|