@yahoo/uds-create-config 5.77.2 → 5.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/CanvasConfig.d.ts +1 -1
- package/dist/configs/react-native-system.d.ts +1 -1
- package/dist/configs/react-native-system.js +1 -1
- package/dist/configs/system.d.ts +1 -1
- package/dist/configs/system.js +3 -1
- package/dist/entities/system/{LinkedSystem.d.ts → Source.d.ts} +19 -11
- package/dist/entities/system/{LinkedSystem.js → Source.js} +127 -130
- package/dist/entities/system/component-module.js +2 -2
- package/dist/entities/system/copy-plan.js +5 -2
- package/dist/entities/system/css-motion-reach.js +6 -6
- package/dist/entities/system/link-declaration.d.ts +6 -68
- package/dist/entities/system/link-declaration.js +30 -4
- package/dist/entities/system/link-plan.d.ts +2 -2
- package/dist/entities/system/link-plan.js +44 -15
- package/dist/entities/system/motion-variants.js +2 -2
- package/dist/framework/Config.d.ts +59 -24
- package/dist/framework/Config.js +170 -41
- package/dist/framework/affected.d.ts +38 -0
- package/dist/framework/affected.js +191 -0
- package/dist/framework/changes.d.ts +1 -1
- package/dist/framework/changes.js +2 -2
- package/dist/framework/defineConfig.d.ts +3 -3
- package/dist/framework/defineEntity.d.ts +4 -3
- package/dist/framework/defineEntity.js +2 -1
- package/dist/framework/derived-mutations.d.ts +1 -1
- package/dist/framework/derived-mutations.js +1 -1
- package/dist/framework/inline-sources.js +2 -2
- package/dist/framework/projections.d.ts +14 -1
- package/dist/framework/projections.js +24 -1
- package/dist/framework/registry.d.ts +13 -7
- package/dist/framework/registry.js +3 -2
- package/dist/framework/retired-fields.d.ts +33 -0
- package/dist/framework/retired-fields.js +148 -0
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/schemas.js +1 -1
- package/dist/framework/signature.js +4 -1
- package/dist/framework/source-integrity.d.ts +2 -2
- package/dist/framework/source-integrity.js +2 -2
- package/dist/framework/sources.d.ts +3 -3
- package/dist/framework/sources.js +1 -1
- package/dist/framework/utils/content-key.js +1 -1
- package/dist/framework/utils/field-schema.js +7 -2
- package/dist/framework/utils/refs.d.ts +1 -1
- package/dist/framework/utils/refs.js +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +6 -4
- package/dist/migrations/2.0.0/v1-artifact.d.ts +1 -1
- package/dist/migrations/20261105185042_sources_stored.d.ts +19 -0
- package/dist/migrations/20261105185042_sources_stored.js +125 -0
- package/dist/spec/links.d.ts +1 -1
- package/dist/spec/links.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/framework/authored-at.d.ts +0 -31
- package/dist/framework/authored-at.js +0 -73
package/dist/framework/Config.js
CHANGED
|
@@ -13,12 +13,12 @@ import { authoredBag, cssVar, declaresCssVariable, pinBodyStyleNumbers, stylePro
|
|
|
13
13
|
import { addressOf, editOp, inputOf, opVerb } from "./config-op.js";
|
|
14
14
|
import { isAuthoringPhantom, phantomsIn } from "./utils/authoring-phantom.js";
|
|
15
15
|
import { configSchemas } from "./config-ops.js";
|
|
16
|
-
import { storedFromAuthored } from "./authored-at.js";
|
|
17
16
|
import { isAuthored } from "./authoring.js";
|
|
18
17
|
import { Entity } from "./Entity.js";
|
|
19
18
|
import { inlineAllSources } from "./inline-sources.js";
|
|
20
19
|
import { CURRENT_SCHEMA_VERSION, SchemaVersionTooNew, schemaVersionOf, upgradeSerializedConfig } from "./schema-version.js";
|
|
21
20
|
import { stamp } from "./overlay.js";
|
|
21
|
+
import { deltaUnderCurrentFields, foldRetiredFields, keptThroughContainerWrite, withEmptiedContainersCleared, withoutClearsInsideClears } from "./retired-fields.js";
|
|
22
22
|
import { Snapshot } from "./snapshot.js";
|
|
23
23
|
import { parseResolution, resolutionSchema } from "./sources.js";
|
|
24
24
|
import { stableStringify } from "./utils/content-key.js";
|
|
@@ -58,12 +58,14 @@ function nameEdgeReaders(entities) {
|
|
|
58
58
|
}
|
|
59
59
|
/** {@link Config.layerKeys}, once per set of registered kinds, which every config built on one
|
|
60
60
|
* registration shares. */
|
|
61
|
+
/** Each retired kind name, by the entity map it was read off — see {@link Config.currentKind}. */
|
|
62
|
+
const retiredKindsByEntities = /* @__PURE__ */ new WeakMap();
|
|
61
63
|
const layerKeysByEntities = /* @__PURE__ */ new WeakMap();
|
|
62
64
|
/**
|
|
63
65
|
* The kinds whose items name an external source — what a `@slug` in a ref resolves against.
|
|
64
66
|
*
|
|
65
67
|
* Asked of the kinds rather than spelled, which is the whole point: `collectRefs` used to hardcode
|
|
66
|
-
* `'
|
|
68
|
+
* `'source'`, so a config whose source kind is named anything else got its link edges filed
|
|
67
69
|
* under a kind it does not declare — no delete-safety for its pins, no rename cascade. Derived, that
|
|
68
70
|
* is correct for the first time.
|
|
69
71
|
*/
|
|
@@ -239,7 +241,7 @@ function rejectCollisions(collisions) {
|
|
|
239
241
|
throw new ConfigRejection([{
|
|
240
242
|
code: "SOURCE_COLLISION",
|
|
241
243
|
collisions,
|
|
242
|
-
message: `This would leave ${collisions.length} ${one ? "path" : "paths"} offered by ${by} as different things, so neither applies: ${shown}${rest}. Take ${one ? "it" : "each"} from the system ${one ? "it" : "each"} should follow (\`
|
|
244
|
+
message: `This would leave ${collisions.length} ${one ? "path" : "paths"} offered by ${by} as different things, so neither applies: ${shown}${rest}. Take ${one ? "it" : "each"} from the system ${one ? "it" : "each"} should follow (\`source/link\` with \`onLinked: 'take'\`), or make the link that only reaches ${one ? "it" : "them"} \`hybrid\`, so it uses what this system already has.`
|
|
243
245
|
}]);
|
|
244
246
|
}
|
|
245
247
|
/** The snapshot a derived snapshot came from, while the parent holds a row derivation the child has
|
|
@@ -658,7 +660,7 @@ function isMintedAt(snapshot, ref) {
|
|
|
658
660
|
const held = snapshot.get(kind, path) ?? snapshot.group(kind, path);
|
|
659
661
|
return held !== void 0 && isMintedRow(held.toJSON());
|
|
660
662
|
}
|
|
661
|
-
/** Whether a body arrived through `
|
|
663
|
+
/** Whether a body arrived through `source/copy`, which marks it with where it came from. */
|
|
662
664
|
const isCopiedRow = (data) => isPlainObject(data) && typeof data.copiedFrom === "string";
|
|
663
665
|
/** Whether a refusal is authored invariants only — the issues a replay and a hydrate let stand. */
|
|
664
666
|
const customOnly = (error) => error.issues.every((issue) => issue.code === "custom");
|
|
@@ -740,6 +742,7 @@ var Config = class Config {
|
|
|
740
742
|
ownedKinds: /* @__PURE__ */ new Set(),
|
|
741
743
|
sources: /* @__PURE__ */ new Map(),
|
|
742
744
|
recorded: /* @__PURE__ */ new Map(),
|
|
745
|
+
baseRecorded: /* @__PURE__ */ new Map(),
|
|
743
746
|
sourceStates: /* @__PURE__ */ new Map(),
|
|
744
747
|
derived: /* @__PURE__ */ new Map(),
|
|
745
748
|
owner: void 0
|
|
@@ -882,6 +885,7 @@ var Config = class Config {
|
|
|
882
885
|
ownedKinds: meta.ownedKinds,
|
|
883
886
|
sources: meta.sources,
|
|
884
887
|
recorded: meta.recorded,
|
|
888
|
+
baseRecorded: meta.recorded,
|
|
885
889
|
sourceStates: meta.sourceStates,
|
|
886
890
|
derived: meta.derived,
|
|
887
891
|
snapshot: withEdges,
|
|
@@ -892,7 +896,65 @@ var Config = class Config {
|
|
|
892
896
|
* was registered into this instance. `undefined` for a kind this config doesn't know. The single
|
|
893
897
|
* accessor every internal read routes through. */
|
|
894
898
|
entityOf(kind) {
|
|
895
|
-
return this.state.entities.get(kind);
|
|
899
|
+
return this.state.entities.get(kind) ?? this.state.entities.get(this.currentKind(kind));
|
|
900
|
+
}
|
|
901
|
+
/** An op address (`linked-system/link`) with its kind segment named as the kind is now. */
|
|
902
|
+
currentAddress(address) {
|
|
903
|
+
const slash = address.indexOf("/");
|
|
904
|
+
if (slash <= 0) return address;
|
|
905
|
+
const kind = address.slice(0, slash);
|
|
906
|
+
const current = this.currentKind(kind);
|
|
907
|
+
return current === kind ? address : `${current}${address.slice(slash)}`;
|
|
908
|
+
}
|
|
909
|
+
/** `patch`, addressed to the kind it names now, with its data at the fields the kind has now. This
|
|
910
|
+
* is the patch as it is recorded, so it depends on nothing but the patch. */
|
|
911
|
+
patchUnderCurrentKind(patch) {
|
|
912
|
+
const kind = this.currentKind(patch.kind);
|
|
913
|
+
const addressed = kind === patch.kind ? patch : {
|
|
914
|
+
...patch,
|
|
915
|
+
kind
|
|
916
|
+
};
|
|
917
|
+
if (!("data" in addressed) || "field" in addressed) return addressed;
|
|
918
|
+
const data = this.underCurrentFields(kind, addressed.operation, { data: addressed.data }).data;
|
|
919
|
+
return data === addressed.data ? addressed : {
|
|
920
|
+
...addressed,
|
|
921
|
+
data
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* `patch` as it lands on `snapshot`: a whole write of a moved field's container keeps the value
|
|
926
|
+
* stored there ({@link keptThroughContainerWrite}). Judged at each landing rather than written into
|
|
927
|
+
* the recorded patch, so a replay onto a base that has changed the field since keeps that base's
|
|
928
|
+
* value, not the one stored when the patch was first applied.
|
|
929
|
+
*/
|
|
930
|
+
patchAsItLands(patch, snapshot) {
|
|
931
|
+
if (patch.operation !== "update" || !("data" in patch) || "field" in patch) return patch;
|
|
932
|
+
const retired = this.entityOf(patch.kind)?.retiredFields;
|
|
933
|
+
if (!retired || !isPlainObject(patch.data)) return patch;
|
|
934
|
+
const stored = snapshot.get(patch.kind, patch.path)?.toJSON();
|
|
935
|
+
const data = withEmptiedContainersCleared({
|
|
936
|
+
delta: keptThroughContainerWrite({
|
|
937
|
+
delta: patch.data,
|
|
938
|
+
retired,
|
|
939
|
+
stored
|
|
940
|
+
}),
|
|
941
|
+
retired,
|
|
942
|
+
stored
|
|
943
|
+
});
|
|
944
|
+
return data === patch.data ? patch : {
|
|
945
|
+
...patch,
|
|
946
|
+
data
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
/** `kind`, or the kind it names now when it's a retired name ({@link EntityKind.retiredKinds}). */
|
|
950
|
+
currentKind(kind) {
|
|
951
|
+
if (this.state.entities.has(kind)) return kind;
|
|
952
|
+
const cached = retiredKindsByEntities.get(this.state.entities);
|
|
953
|
+
if (cached) return cached.get(kind) ?? kind;
|
|
954
|
+
const retired = /* @__PURE__ */ new Map();
|
|
955
|
+
for (const [name, entity] of this.state.entities) for (const old of entity.retiredKinds ?? []) retired.set(old, name);
|
|
956
|
+
retiredKindsByEntities.set(this.state.entities, retired);
|
|
957
|
+
return retired.get(kind) ?? kind;
|
|
896
958
|
}
|
|
897
959
|
/** Every key a style rule's layer bag takes that a kind owns, with the kind that owns it. See
|
|
898
960
|
* {@link LayerKey}. */
|
|
@@ -954,12 +1016,16 @@ var Config = class Config {
|
|
|
954
1016
|
*
|
|
955
1017
|
* The single-op half of {@link run}, which is the door a caller uses.
|
|
956
1018
|
*/
|
|
957
|
-
dispatch(
|
|
958
|
-
const
|
|
1019
|
+
dispatch(written, id) {
|
|
1020
|
+
const kind = this.currentKind(written.kind);
|
|
1021
|
+
const op = kind === written.kind ? written : {
|
|
1022
|
+
...written,
|
|
1023
|
+
kind
|
|
1024
|
+
};
|
|
959
1025
|
const verb = opVerb(op);
|
|
960
1026
|
const entry = kind === "config" ? configSchemas(this.name)[verb] : this.entityOf(kind)?.schemas[verb];
|
|
961
1027
|
if (!entry?.handler) reject("UNSUPPORTED", `${kind} has no ${verb} operation`);
|
|
962
|
-
const input = this.wholeBodyShorthand(kind, verb, op);
|
|
1028
|
+
const input = this.underCurrentFields(kind, verb, this.wholeBodyShorthand(kind, verb, op));
|
|
963
1029
|
let schema = resolveInputSchema(entry.input, {
|
|
964
1030
|
config: this,
|
|
965
1031
|
body: input.data
|
|
@@ -971,6 +1037,30 @@ var Config = class Config {
|
|
|
971
1037
|
return this.named(produced, { id });
|
|
972
1038
|
}
|
|
973
1039
|
/**
|
|
1040
|
+
* An op's input with any field the kind has moved (`EntityKind.retiredFields`) written at its
|
|
1041
|
+
* current path: folded into a whole body, renamed in an update's delta. A member op addresses a
|
|
1042
|
+
* sub-collection, which no retired field names.
|
|
1043
|
+
*/
|
|
1044
|
+
underCurrentFields(kind, verb, input) {
|
|
1045
|
+
const retired = this.entityOf(kind)?.retiredFields;
|
|
1046
|
+
if (!retired || !isPlainObject(input.data)) return input;
|
|
1047
|
+
if (verb === "create" || verb === "replace") return {
|
|
1048
|
+
...input,
|
|
1049
|
+
data: foldRetiredFields({
|
|
1050
|
+
body: input.data,
|
|
1051
|
+
retired
|
|
1052
|
+
})
|
|
1053
|
+
};
|
|
1054
|
+
if (verb === "update") return {
|
|
1055
|
+
...input,
|
|
1056
|
+
data: deltaUnderCurrentFields({
|
|
1057
|
+
delta: input.data,
|
|
1058
|
+
retired
|
|
1059
|
+
})
|
|
1060
|
+
};
|
|
1061
|
+
return input;
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
974
1064
|
* A whole-body op's input with a bare ref put in the kind's primary field, so an op takes the same
|
|
975
1065
|
* shorthand `apply` does (`wholeBodyChange`): `Token.ref('x@ds')` is a token body at either door.
|
|
976
1066
|
* Anything else is handed back as it came.
|
|
@@ -1267,7 +1357,7 @@ var Config = class Config {
|
|
|
1267
1357
|
* in.
|
|
1268
1358
|
*
|
|
1269
1359
|
* Checked rather than assumed. "The slug namespace is flat" is a property of the ref grammar, and
|
|
1270
|
-
* nothing was making the data honour it: a config declaring `
|
|
1360
|
+
* nothing was making the data honour it: a config declaring `sources: { ds }` and
|
|
1271
1361
|
* `linkedPackages: { ds }` registered clean, `sourceSlugs()` answered `['ds', 'ds']`, and every read
|
|
1272
1362
|
* through `@ds` picked a winner. Unreachable while a config declares one source kind, and the first
|
|
1273
1363
|
* thing to go wrong the day it declares two — which is exactly what `sources` exists to allow.
|
|
@@ -1327,7 +1417,7 @@ var Config = class Config {
|
|
|
1327
1417
|
* `apply` and {@link run} are two doors on one wall. A {@link Patch} is one of the framework's own
|
|
1328
1418
|
* verbs (`create`, `update`, `rename`, `sub-update`, …) with its body already in stored shape, and
|
|
1329
1419
|
* `apply` performs exactly that one and records it. A {@link ConfigOp} is anything the catalog
|
|
1330
|
-
* addresses — those same verbs, and custom ops such as `
|
|
1420
|
+
* addresses — those same verbs, and custom ops such as `source/copy` that decompose into
|
|
1331
1421
|
* several patches — and `run` parses its input against the op's own schema and hands it to the op's
|
|
1332
1422
|
* handler, which for a standard verb is a call to `apply`. So `apply` is what a handler and a
|
|
1333
1423
|
* replay call, and `run` is what a caller calls: a tool, an editor gesture, a commit. A caller
|
|
@@ -1349,7 +1439,8 @@ var Config = class Config {
|
|
|
1349
1439
|
* A delete records more than one patch when items declare they cannot outlive the target
|
|
1350
1440
|
* ({@link EntityKind.structuralBody}): a delete per dependent, leaves first, then the target, as
|
|
1351
1441
|
* one changeset. `id` then names the first of them and the changeset. */
|
|
1352
|
-
apply(
|
|
1442
|
+
apply(written, id) {
|
|
1443
|
+
const patch = this.patchUnderCurrentKind(written);
|
|
1353
1444
|
const dependents = this.structuralDependentsOf({ patch });
|
|
1354
1445
|
if (dependents.length === 0) return this.applyRecorded(patch, id);
|
|
1355
1446
|
const since = this.state.pending.length;
|
|
@@ -1363,7 +1454,8 @@ var Config = class Config {
|
|
|
1363
1454
|
* patch as it was recorded, since a recorded delete's cascade was recorded beside it, ahead of it.
|
|
1364
1455
|
* Deleting again what the base gained since would remove it with no patch saying so.
|
|
1365
1456
|
*/
|
|
1366
|
-
applyRecorded(
|
|
1457
|
+
applyRecorded(written, id) {
|
|
1458
|
+
const patch = this.patchUnderCurrentKind(written);
|
|
1367
1459
|
const deferred = this.state.deferredInvariants;
|
|
1368
1460
|
if (deferred?.open) deferred.kinds.add(patch.kind);
|
|
1369
1461
|
const applied = this.applyPatch(patch, id, !deferred?.open);
|
|
@@ -1418,7 +1510,8 @@ var Config = class Config {
|
|
|
1418
1510
|
}
|
|
1419
1511
|
}
|
|
1420
1512
|
/** {@link apply}, with the kind's invariants judged now or left to the batch that called this. */
|
|
1421
|
-
applyPatch(
|
|
1513
|
+
applyPatch(written, id, checked) {
|
|
1514
|
+
const patch = this.patchUnderCurrentKind(written);
|
|
1422
1515
|
const snapshot = this.computeApply(this.state.snapshot, patch, "write", checked);
|
|
1423
1516
|
const sourceIdentity = this.entityOf(patch.kind)?.sourceIdentity;
|
|
1424
1517
|
let { recorded, sources, sourceStates } = this.state;
|
|
@@ -1467,7 +1560,7 @@ var Config = class Config {
|
|
|
1467
1560
|
*/
|
|
1468
1561
|
applyAll(requested) {
|
|
1469
1562
|
if (requested.length === 0) return this;
|
|
1470
|
-
const patches = this.withStructuralDependents(requested);
|
|
1563
|
+
const patches = this.withStructuralDependents(requested.map((patch) => this.patchUnderCurrentKind(patch)));
|
|
1471
1564
|
const changeset = patches.length > 1 ? crypto.randomUUID() : void 0;
|
|
1472
1565
|
const stampOf = (patch) => stamp(patch, void 0, changeset);
|
|
1473
1566
|
const touched = new Set(patches.map((patch) => patch.kind));
|
|
@@ -1947,7 +2040,8 @@ var Config = class Config {
|
|
|
1947
2040
|
}));
|
|
1948
2041
|
}
|
|
1949
2042
|
/** The next snapshot for one patch, validated. Pure in `snapshot`; reads metadata off `this`. */
|
|
1950
|
-
computeApply(snapshot,
|
|
2043
|
+
computeApply(snapshot, written, mode = "write", checked = true) {
|
|
2044
|
+
const incoming = this.patchAsItLands(this.patchUnderCurrentKind(written), snapshot);
|
|
1951
2045
|
const unitChange = incoming.kind === "style-property" && incoming.operation === "update" ? {
|
|
1952
2046
|
path: incoming.path,
|
|
1953
2047
|
was: stylePropNumberUnit(this.viewOf(snapshot), incoming.path)
|
|
@@ -2202,10 +2296,14 @@ var Config = class Config {
|
|
|
2202
2296
|
}
|
|
2203
2297
|
const parsed = updateSchema.safeParse(checked);
|
|
2204
2298
|
if (!parsed.success) rejectInvalid(context, parsed.error);
|
|
2205
|
-
const
|
|
2299
|
+
const parsedDelta = {
|
|
2206
2300
|
...parsed.data,
|
|
2207
2301
|
...reveals
|
|
2208
2302
|
};
|
|
2303
|
+
const delta = entry.retiredFields ? withoutClearsInsideClears({
|
|
2304
|
+
delta: parsedDelta,
|
|
2305
|
+
retired: entry.retiredFields
|
|
2306
|
+
}) : parsedDelta;
|
|
2209
2307
|
const touched = touchedFields(delta, isField);
|
|
2210
2308
|
if (extension) {
|
|
2211
2309
|
const resolved = this.at(snapshot).resolveExtension({
|
|
@@ -2953,7 +3051,8 @@ var Config = class Config {
|
|
|
2953
3051
|
});
|
|
2954
3052
|
return new Entity(path, withComputed, [...entry.fieldKeys, ...Object.keys(computed)]);
|
|
2955
3053
|
}
|
|
2956
|
-
resolve(
|
|
3054
|
+
resolve(written, path) {
|
|
3055
|
+
const kind = this.currentKind(written);
|
|
2957
3056
|
const cache = this.caches.entities;
|
|
2958
3057
|
const key = `${kind}\u0000${path}`;
|
|
2959
3058
|
const cached = cache.get(key);
|
|
@@ -3369,13 +3468,13 @@ var Config = class Config {
|
|
|
3369
3468
|
* accessor name, then by the item's slug:
|
|
3370
3469
|
*
|
|
3371
3470
|
* ```ts
|
|
3372
|
-
* Config.registerSources({
|
|
3471
|
+
* Config.registerSources({ sources: { yos: yahooOs } })
|
|
3373
3472
|
* ```
|
|
3374
3473
|
*
|
|
3375
|
-
* The same two levels `register` takes (`{
|
|
3474
|
+
* The same two levels `register` takes (`{ sources: { yos: Source.item(…) } }`) and the
|
|
3376
3475
|
* same two `fromJSON(json, { sources })` takes, so one gesture — declare a source, then hand
|
|
3377
3476
|
* over what it resolved to — reads identically at all three. A flat `{ yos }` said nothing about
|
|
3378
|
-
* which collection `yos` came from, which is fine while `
|
|
3477
|
+
* which collection `yos` came from, which is fine while `source` is the only source kind and
|
|
3379
3478
|
* wrong the day there is a second.
|
|
3380
3479
|
*
|
|
3381
3480
|
* Immutable like every other authoring step: the sources ride on the derived config, and every later
|
|
@@ -3545,7 +3644,7 @@ var Config = class Config {
|
|
|
3545
3644
|
*
|
|
3546
3645
|
* Answers the slug, which is the kind-agnostic half and therefore the half that belongs here. Turning
|
|
3547
3646
|
* a slug into the typed pin behind it is the source kind's own business (`sourceOfGroup` beside
|
|
3548
|
-
* `
|
|
3647
|
+
* `Source`) — a `Config` method could only hand back a bare `Entity`, and the rule above would
|
|
3549
3648
|
* then be stated once per source kind instead of once.
|
|
3550
3649
|
*/
|
|
3551
3650
|
groupSource({ kind, groupPath }) {
|
|
@@ -3644,7 +3743,7 @@ var Config = class Config {
|
|
|
3644
3743
|
* stores, so refusing on that shape would lock a pointer we declared. See `borrowedSlug`.
|
|
3645
3744
|
*/
|
|
3646
3745
|
/**
|
|
3647
|
-
* The pin whose `
|
|
3746
|
+
* The pin whose `options.include` covers `kind:path` and whose source has a row there, so the build
|
|
3648
3747
|
* mints the source's row at the path on its next pass. `undefined` when no declaration covers the
|
|
3649
3748
|
* path, or the declaring source is attached and lacks it. A source that isn't attached is taken at
|
|
3650
3749
|
* its declaration's word.
|
|
@@ -3748,16 +3847,17 @@ var Config = class Config {
|
|
|
3748
3847
|
path,
|
|
3749
3848
|
overlay: null
|
|
3750
3849
|
});
|
|
3751
|
-
const
|
|
3752
|
-
accessor,
|
|
3753
|
-
path,
|
|
3754
|
-
overlay: null
|
|
3755
|
-
}))[0]?.split(".")[0];
|
|
3756
|
-
return field ? { [field]: null } : write({
|
|
3850
|
+
const clear = write({
|
|
3757
3851
|
accessor,
|
|
3758
3852
|
path,
|
|
3759
3853
|
overlay: null
|
|
3760
3854
|
});
|
|
3855
|
+
const field = Object.keys(clear)[0]?.split(".")[0];
|
|
3856
|
+
if (!field) return clear;
|
|
3857
|
+
const sourceKind = this.sourceKindFor(slug);
|
|
3858
|
+
const body = sourceKind ? this.storedBody(sourceKind, slug) : void 0;
|
|
3859
|
+
const left = isPlainObject(body) ? applyPathDelta(body, clear, () => true)[field] : void 0;
|
|
3860
|
+
return isPlainObject(left) && Object.keys(left).length > 0 ? clear : { [field]: null };
|
|
3761
3861
|
}
|
|
3762
3862
|
/**
|
|
3763
3863
|
* Every path a declared source's declaration says something about, with the accessor resolved to the
|
|
@@ -3788,7 +3888,7 @@ var Config = class Config {
|
|
|
3788
3888
|
return found;
|
|
3789
3889
|
}
|
|
3790
3890
|
/**
|
|
3791
|
-
* Whether one of a declared source's paths is adopted here — covered by the pin's `
|
|
3891
|
+
* Whether one of a declared source's paths is adopted here — covered by the pin's `options.include`.
|
|
3792
3892
|
*
|
|
3793
3893
|
* The question a spelling turns on: an adopted path is addressed bare, because the build mints a
|
|
3794
3894
|
* row for it at the path the source spells, and everything else is addressed qualified. The two are
|
|
@@ -4715,7 +4815,7 @@ var Config = class Config {
|
|
|
4715
4815
|
}
|
|
4716
4816
|
if (collides) rejectCollisions(derivation.collisions);
|
|
4717
4817
|
if (stranded.length === 0) return;
|
|
4718
|
-
reject("REFERRERS_BLOCK", `Cannot ${action} — it would take away ${stranded.join("; ")}. Copy what is used first (\`
|
|
4818
|
+
reject("REFERRERS_BLOCK", `Cannot ${action} — it would take away ${stranded.join("; ")}. Copy what is used first (\`source/copy\`), or break the link keeping its values (\`source/break\` with \`keep: true\`).`);
|
|
4719
4819
|
}
|
|
4720
4820
|
/**
|
|
4721
4821
|
* Whether every directive of `pin` that names `target` sits on a path that no longer derives through
|
|
@@ -5730,7 +5830,7 @@ var Config = class Config {
|
|
|
5730
5830
|
* in which fields they set are different sources, and collapsing them would share one cache entry.
|
|
5731
5831
|
*
|
|
5732
5832
|
* Derived rather than spelled, which is what makes it right for kinds nobody has written — it covers
|
|
5733
|
-
* whatever fields a kind actually declares instead of the three `
|
|
5833
|
+
* whatever fields a kind actually declares instead of the three `source` happens to have. The
|
|
5734
5834
|
* key it replaces was `${systemId}@${version}`, which a repo-local source cannot state at all;
|
|
5735
5835
|
* that is the case the walk using it had to pre-skip.
|
|
5736
5836
|
*/
|
|
@@ -5758,7 +5858,7 @@ var Config = class Config {
|
|
|
5758
5858
|
*
|
|
5759
5859
|
* A row borrowed or copied through a pin is asked of that pin's source in turn, so a system linked
|
|
5760
5860
|
* to a system linked to a foundation answers with the foundation. A row a materialized artifact
|
|
5761
|
-
* flattened to a literal has no pointer left, so the pin whose `
|
|
5861
|
+
* flattened to a literal has no pointer left, so the pin whose `options.include` covers the path
|
|
5762
5862
|
* stands in, provided the row still reads as the source's ({@link matchesSource}); one the
|
|
5763
5863
|
* publisher changed is its own, and so is a linked row this config lays a value of its own over: the
|
|
5764
5864
|
* Bridge's `spectrum/blue/0` points at Yahoo OS's with the Bridge's colours on it, which is the
|
|
@@ -5801,7 +5901,7 @@ var Config = class Config {
|
|
|
5801
5901
|
}
|
|
5802
5902
|
}
|
|
5803
5903
|
/**
|
|
5804
|
-
* The pin whose `
|
|
5904
|
+
* The pin whose `options.include` covers `kind:path` while the row there still reads as that
|
|
5805
5905
|
* source's: how a row a materialized artifact flattened to a literal is traced back to the pin it
|
|
5806
5906
|
* came through. `undefined` when no declaration covers it, or the row differs from the source's.
|
|
5807
5907
|
*/
|
|
@@ -5870,8 +5970,8 @@ var Config = class Config {
|
|
|
5870
5970
|
return this.sourceKinds().find((kind) => this.storedBody(kind, slug) !== void 0);
|
|
5871
5971
|
}
|
|
5872
5972
|
/**
|
|
5873
|
-
* Every source kind by the accessor name its config type declares it under — `
|
|
5874
|
-
* `
|
|
5973
|
+
* Every source kind by the accessor name its config type declares it under — `sources` →
|
|
5974
|
+
* `source`.
|
|
5875
5975
|
*
|
|
5876
5976
|
* The accessor name is what every source-shaped argument is keyed by ({@link AttachedSources},
|
|
5877
5977
|
* `register`, `Config.load`'s resolvers), because it's the name an author writes, where the kind is
|
|
@@ -6043,7 +6143,8 @@ var Config = class Config {
|
|
|
6043
6143
|
* {@link retired} answers true for. Both answers are cached per snapshot, so either is safe in a dep
|
|
6044
6144
|
* array.
|
|
6045
6145
|
*/
|
|
6046
|
-
list(
|
|
6146
|
+
list(written, opts) {
|
|
6147
|
+
const kind = this.currentKind(written);
|
|
6047
6148
|
const all = this.allOf(kind);
|
|
6048
6149
|
if (opts?.retired !== false) return all;
|
|
6049
6150
|
const cache = this.caches.activeLists;
|
|
@@ -6219,9 +6320,9 @@ var Config = class Config {
|
|
|
6219
6320
|
* every sourced ref dangles, and emitters, integrity checks and memos all read exactly there.
|
|
6220
6321
|
*
|
|
6221
6322
|
* `sources` is keyed the way every other source-shaped argument is — by the source kind's accessor
|
|
6222
|
-
* name, `{
|
|
6323
|
+
* name, `{ sources: resolver }` — so the resolver set, the declaration, and
|
|
6223
6324
|
* {@link registerSources} all spell the same key. Each resolver is the kind's own
|
|
6224
|
-
* (`
|
|
6325
|
+
* (`SystemSourceResolver`), and its answer is validated against the schemas that kind declares.
|
|
6225
6326
|
*
|
|
6226
6327
|
* Reads the source entities off a throwaway bare parse, resolves them all, then hydrates once with
|
|
6227
6328
|
* whatever came back attached. The bare parse is cheap and is what lets a resolver be handed the
|
|
@@ -6332,6 +6433,34 @@ var Config = class Config {
|
|
|
6332
6433
|
});
|
|
6333
6434
|
}
|
|
6334
6435
|
/**
|
|
6436
|
+
* The branch as its base read it: no draft, and every source read the way the base read it.
|
|
6437
|
+
*
|
|
6438
|
+
* Replaying nothing over the base covers the snapshot. A pin the draft moved also left the
|
|
6439
|
+
* per-slug state answering for the new pin: its recorded closure gone and, once fetched, the new
|
|
6440
|
+
* version attached. So each moved slug gets the base's recorded closure back and loses that
|
|
6441
|
+
* attachment before the replay, which also re-derives the rows the old pin minted.
|
|
6442
|
+
*/
|
|
6443
|
+
withoutDraft() {
|
|
6444
|
+
const atBase = this.at(this.state.base);
|
|
6445
|
+
const moved = atBase.sourceSlugs().filter((slug) => atBase.sourceIdentityOf(slug) !== this.sourceIdentityOf(slug));
|
|
6446
|
+
let from = this;
|
|
6447
|
+
if (moved.length > 0) {
|
|
6448
|
+
const recorded = new Map(this.state.recorded);
|
|
6449
|
+
const sources = new Map(this.state.sources);
|
|
6450
|
+
for (const slug of moved) {
|
|
6451
|
+
sources.delete(slug);
|
|
6452
|
+
const held = this.state.baseRecorded.get(slug);
|
|
6453
|
+
if (held) recorded.set(slug, held);
|
|
6454
|
+
else recorded.delete(slug);
|
|
6455
|
+
}
|
|
6456
|
+
from = this.derive({
|
|
6457
|
+
recorded,
|
|
6458
|
+
sources
|
|
6459
|
+
});
|
|
6460
|
+
}
|
|
6461
|
+
return from.withDraft([]).config;
|
|
6462
|
+
}
|
|
6463
|
+
/**
|
|
6335
6464
|
* Retire the attachment for every slug a walk answered `unavailable` for.
|
|
6336
6465
|
*
|
|
6337
6466
|
* A resolve walk is total over the declared items of a source kind — `unavailable` is a legal answer
|
|
@@ -6406,7 +6535,7 @@ var Config = class Config {
|
|
|
6406
6535
|
* links from the provided sources. A declared `linkedKind` with no provided source throws. */
|
|
6407
6536
|
hydrateFrom(stored, options) {
|
|
6408
6537
|
const claimed = schemaVersionOf(stored);
|
|
6409
|
-
if (claimed >
|
|
6538
|
+
if (claimed > 20261105185042) throw new SchemaVersionTooNew(claimed);
|
|
6410
6539
|
const wire = upgradeSerializedConfig(stored);
|
|
6411
6540
|
if (!Array.isArray(wire.ownedKinds) || typeof wire.items !== "object" || wire.items === null) throw new ConfigFormatError(`Config "${stored.name ?? "system-config"}" cannot be hydrated: this is not a serialized config-v2 config (no "ownedKinds"/"items"). A pre-cutover build artifact converts through the registered cutover migration — import the config type's module (e.g. \`configs/system\`) before hydrating.`);
|
|
6412
6541
|
const leftover = wire.options;
|
|
@@ -6757,9 +6886,9 @@ function extensionChange(entry, kind, path, raw, validate = false) {
|
|
|
6757
6886
|
function itemChange(entry, kind, path, raw, validate = false) {
|
|
6758
6887
|
const body = isRef(raw) || isComposedValue(raw) || typeof raw !== "object" || raw === null ? { [entry.primaryField]: raw } : raw;
|
|
6759
6888
|
let def = validate === "author" && entry.authoredBody ? entry.authoredBody(body) : body;
|
|
6760
|
-
if (validate === "author" && entry.
|
|
6889
|
+
if (validate === "author" && entry.retiredFields) def = foldRetiredFields({
|
|
6761
6890
|
body: def,
|
|
6762
|
-
|
|
6891
|
+
retired: entry.retiredFields
|
|
6763
6892
|
});
|
|
6764
6893
|
if (validate) {
|
|
6765
6894
|
const parsed = wholeBodySchema(entry)?.safeParse(def);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Config } from "./Config.js";
|
|
2
|
+
import { Change } from "./changes.js";
|
|
3
|
+
|
|
4
|
+
//#region src/framework/affected.d.ts
|
|
5
|
+
type AffectedStatus = 'added' | 'removed' | 'changed';
|
|
6
|
+
interface AffectedEntity {
|
|
7
|
+
readonly kind: string;
|
|
8
|
+
/** The path on the draft, or on the base for an entity the draft removed. */
|
|
9
|
+
readonly path: string;
|
|
10
|
+
/** The path on the base, when the draft renamed the entity. */
|
|
11
|
+
readonly basePath?: string;
|
|
12
|
+
readonly status: AffectedStatus;
|
|
13
|
+
/** Whether the draft wrote this entity itself, rather than reaching it through a dependency. */
|
|
14
|
+
readonly direct: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The entities the draft wrote that lead here, as `kind:path` on the draft (on the base for one it
|
|
17
|
+
* removed). An entity the draft wrote names itself.
|
|
18
|
+
*/
|
|
19
|
+
readonly causes: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Every entity the draft changes as it resolves, in the order the changes reach them: each written
|
|
23
|
+
* entity, then what depends on it.
|
|
24
|
+
*
|
|
25
|
+
* `changes` is the draft read as what it changed (`changesOf`), already narrowed to the ones that
|
|
26
|
+
* stand. An entity both written and reached lists every cause.
|
|
27
|
+
*/
|
|
28
|
+
declare function affectedOf({
|
|
29
|
+
base,
|
|
30
|
+
draft,
|
|
31
|
+
changes
|
|
32
|
+
}: {
|
|
33
|
+
base: Config;
|
|
34
|
+
draft: Config;
|
|
35
|
+
changes: readonly Change[];
|
|
36
|
+
}): AffectedEntity[];
|
|
37
|
+
//#endregion
|
|
38
|
+
export { AffectedEntity, AffectedStatus, affectedOf };
|