@yahoo/uds-create-config 5.78.0 → 5.80.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.
Files changed (49) hide show
  1. package/dist/configs/CanvasConfig.d.ts +1 -1
  2. package/dist/configs/react-native-system.d.ts +1 -1
  3. package/dist/configs/react-native-system.js +1 -1
  4. package/dist/configs/system.d.ts +1 -1
  5. package/dist/configs/system.js +3 -1
  6. package/dist/entities/system/{LinkedSystem.d.ts → Source.d.ts} +19 -11
  7. package/dist/entities/system/{LinkedSystem.js → Source.js} +127 -130
  8. package/dist/entities/system/component-module.js +2 -2
  9. package/dist/entities/system/copy-plan.js +5 -2
  10. package/dist/entities/system/css-motion-reach.js +6 -6
  11. package/dist/entities/system/link-declaration.d.ts +6 -68
  12. package/dist/entities/system/link-declaration.js +30 -4
  13. package/dist/entities/system/link-plan.d.ts +2 -2
  14. package/dist/entities/system/link-plan.js +44 -15
  15. package/dist/entities/system/motion-variants.js +2 -2
  16. package/dist/framework/Config.d.ts +44 -24
  17. package/dist/framework/Config.js +140 -41
  18. package/dist/framework/defineConfig.d.ts +3 -3
  19. package/dist/framework/defineEntity.d.ts +4 -3
  20. package/dist/framework/defineEntity.js +2 -1
  21. package/dist/framework/derived-mutations.d.ts +1 -1
  22. package/dist/framework/derived-mutations.js +1 -1
  23. package/dist/framework/inline-sources.js +2 -2
  24. package/dist/framework/registry.d.ts +13 -7
  25. package/dist/framework/registry.js +3 -2
  26. package/dist/framework/retired-fields.d.ts +33 -0
  27. package/dist/framework/retired-fields.js +148 -0
  28. package/dist/framework/schema-version.d.ts +1 -1
  29. package/dist/framework/schema-version.js +5 -5
  30. package/dist/framework/schemas.js +1 -1
  31. package/dist/framework/signature.js +4 -1
  32. package/dist/framework/source-integrity.d.ts +2 -2
  33. package/dist/framework/source-integrity.js +2 -2
  34. package/dist/framework/sources.d.ts +3 -3
  35. package/dist/framework/sources.js +1 -1
  36. package/dist/framework/utils/field-schema.js +7 -2
  37. package/dist/framework/utils/refs.d.ts +1 -1
  38. package/dist/framework/utils/refs.js +1 -1
  39. package/dist/index.d.ts +4 -3
  40. package/dist/index.js +4 -3
  41. package/dist/migrations/2.0.0/v1-artifact.d.ts +1 -1
  42. package/dist/migrations/20261105185042_sources_stored.d.ts +19 -0
  43. package/dist/migrations/20261105185042_sources_stored.js +125 -0
  44. package/dist/spec/links.d.ts +1 -1
  45. package/dist/spec/links.js +1 -1
  46. package/dist/tsconfig.tsbuildinfo +1 -1
  47. package/package.json +2 -2
  48. package/dist/framework/authored-at.d.ts +0 -31
  49. package/dist/framework/authored-at.js +0 -73
@@ -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
- * `'linked-system'`, so a config whose source kind is named anything else got its link edges filed
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 (\`linked-system/link\` with \`onLinked: 'take'\`), or make the link that only reaches ${one ? "it" : "them"} \`hybrid\`, so it uses what this system already has.`
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 `linked-system/copy`, which marks it with where it came from. */
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");
@@ -894,7 +896,65 @@ var Config = class Config {
894
896
  * was registered into this instance. `undefined` for a kind this config doesn't know. The single
895
897
  * accessor every internal read routes through. */
896
898
  entityOf(kind) {
897
- 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;
898
958
  }
899
959
  /** Every key a style rule's layer bag takes that a kind owns, with the kind that owns it. See
900
960
  * {@link LayerKey}. */
@@ -956,12 +1016,16 @@ var Config = class Config {
956
1016
  *
957
1017
  * The single-op half of {@link run}, which is the door a caller uses.
958
1018
  */
959
- dispatch(op, id) {
960
- const { kind } = op;
1019
+ dispatch(written, id) {
1020
+ const kind = this.currentKind(written.kind);
1021
+ const op = kind === written.kind ? written : {
1022
+ ...written,
1023
+ kind
1024
+ };
961
1025
  const verb = opVerb(op);
962
1026
  const entry = kind === "config" ? configSchemas(this.name)[verb] : this.entityOf(kind)?.schemas[verb];
963
1027
  if (!entry?.handler) reject("UNSUPPORTED", `${kind} has no ${verb} operation`);
964
- const input = this.wholeBodyShorthand(kind, verb, op);
1028
+ const input = this.underCurrentFields(kind, verb, this.wholeBodyShorthand(kind, verb, op));
965
1029
  let schema = resolveInputSchema(entry.input, {
966
1030
  config: this,
967
1031
  body: input.data
@@ -973,6 +1037,30 @@ var Config = class Config {
973
1037
  return this.named(produced, { id });
974
1038
  }
975
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
+ /**
976
1064
  * A whole-body op's input with a bare ref put in the kind's primary field, so an op takes the same
977
1065
  * shorthand `apply` does (`wholeBodyChange`): `Token.ref('x@ds')` is a token body at either door.
978
1066
  * Anything else is handed back as it came.
@@ -1269,7 +1357,7 @@ var Config = class Config {
1269
1357
  * in.
1270
1358
  *
1271
1359
  * Checked rather than assumed. "The slug namespace is flat" is a property of the ref grammar, and
1272
- * nothing was making the data honour it: a config declaring `linkedSystems: { ds }` and
1360
+ * nothing was making the data honour it: a config declaring `sources: { ds }` and
1273
1361
  * `linkedPackages: { ds }` registered clean, `sourceSlugs()` answered `['ds', 'ds']`, and every read
1274
1362
  * through `@ds` picked a winner. Unreachable while a config declares one source kind, and the first
1275
1363
  * thing to go wrong the day it declares two — which is exactly what `sources` exists to allow.
@@ -1329,7 +1417,7 @@ var Config = class Config {
1329
1417
  * `apply` and {@link run} are two doors on one wall. A {@link Patch} is one of the framework's own
1330
1418
  * verbs (`create`, `update`, `rename`, `sub-update`, …) with its body already in stored shape, and
1331
1419
  * `apply` performs exactly that one and records it. A {@link ConfigOp} is anything the catalog
1332
- * addresses — those same verbs, and custom ops such as `linked-system/copy` that decompose into
1420
+ * addresses — those same verbs, and custom ops such as `source/copy` that decompose into
1333
1421
  * several patches — and `run` parses its input against the op's own schema and hands it to the op's
1334
1422
  * handler, which for a standard verb is a call to `apply`. So `apply` is what a handler and a
1335
1423
  * replay call, and `run` is what a caller calls: a tool, an editor gesture, a commit. A caller
@@ -1351,7 +1439,8 @@ var Config = class Config {
1351
1439
  * A delete records more than one patch when items declare they cannot outlive the target
1352
1440
  * ({@link EntityKind.structuralBody}): a delete per dependent, leaves first, then the target, as
1353
1441
  * one changeset. `id` then names the first of them and the changeset. */
1354
- apply(patch, id) {
1442
+ apply(written, id) {
1443
+ const patch = this.patchUnderCurrentKind(written);
1355
1444
  const dependents = this.structuralDependentsOf({ patch });
1356
1445
  if (dependents.length === 0) return this.applyRecorded(patch, id);
1357
1446
  const since = this.state.pending.length;
@@ -1365,7 +1454,8 @@ var Config = class Config {
1365
1454
  * patch as it was recorded, since a recorded delete's cascade was recorded beside it, ahead of it.
1366
1455
  * Deleting again what the base gained since would remove it with no patch saying so.
1367
1456
  */
1368
- applyRecorded(patch, id) {
1457
+ applyRecorded(written, id) {
1458
+ const patch = this.patchUnderCurrentKind(written);
1369
1459
  const deferred = this.state.deferredInvariants;
1370
1460
  if (deferred?.open) deferred.kinds.add(patch.kind);
1371
1461
  const applied = this.applyPatch(patch, id, !deferred?.open);
@@ -1420,7 +1510,8 @@ var Config = class Config {
1420
1510
  }
1421
1511
  }
1422
1512
  /** {@link apply}, with the kind's invariants judged now or left to the batch that called this. */
1423
- applyPatch(patch, id, checked) {
1513
+ applyPatch(written, id, checked) {
1514
+ const patch = this.patchUnderCurrentKind(written);
1424
1515
  const snapshot = this.computeApply(this.state.snapshot, patch, "write", checked);
1425
1516
  const sourceIdentity = this.entityOf(patch.kind)?.sourceIdentity;
1426
1517
  let { recorded, sources, sourceStates } = this.state;
@@ -1469,7 +1560,7 @@ var Config = class Config {
1469
1560
  */
1470
1561
  applyAll(requested) {
1471
1562
  if (requested.length === 0) return this;
1472
- const patches = this.withStructuralDependents(requested);
1563
+ const patches = this.withStructuralDependents(requested.map((patch) => this.patchUnderCurrentKind(patch)));
1473
1564
  const changeset = patches.length > 1 ? crypto.randomUUID() : void 0;
1474
1565
  const stampOf = (patch) => stamp(patch, void 0, changeset);
1475
1566
  const touched = new Set(patches.map((patch) => patch.kind));
@@ -1949,7 +2040,8 @@ var Config = class Config {
1949
2040
  }));
1950
2041
  }
1951
2042
  /** The next snapshot for one patch, validated. Pure in `snapshot`; reads metadata off `this`. */
1952
- computeApply(snapshot, incoming, mode = "write", checked = true) {
2043
+ computeApply(snapshot, written, mode = "write", checked = true) {
2044
+ const incoming = this.patchAsItLands(this.patchUnderCurrentKind(written), snapshot);
1953
2045
  const unitChange = incoming.kind === "style-property" && incoming.operation === "update" ? {
1954
2046
  path: incoming.path,
1955
2047
  was: stylePropNumberUnit(this.viewOf(snapshot), incoming.path)
@@ -2204,10 +2296,14 @@ var Config = class Config {
2204
2296
  }
2205
2297
  const parsed = updateSchema.safeParse(checked);
2206
2298
  if (!parsed.success) rejectInvalid(context, parsed.error);
2207
- const delta = {
2299
+ const parsedDelta = {
2208
2300
  ...parsed.data,
2209
2301
  ...reveals
2210
2302
  };
2303
+ const delta = entry.retiredFields ? withoutClearsInsideClears({
2304
+ delta: parsedDelta,
2305
+ retired: entry.retiredFields
2306
+ }) : parsedDelta;
2211
2307
  const touched = touchedFields(delta, isField);
2212
2308
  if (extension) {
2213
2309
  const resolved = this.at(snapshot).resolveExtension({
@@ -2955,7 +3051,8 @@ var Config = class Config {
2955
3051
  });
2956
3052
  return new Entity(path, withComputed, [...entry.fieldKeys, ...Object.keys(computed)]);
2957
3053
  }
2958
- resolve(kind, path) {
3054
+ resolve(written, path) {
3055
+ const kind = this.currentKind(written);
2959
3056
  const cache = this.caches.entities;
2960
3057
  const key = `${kind}\u0000${path}`;
2961
3058
  const cached = cache.get(key);
@@ -3371,13 +3468,13 @@ var Config = class Config {
3371
3468
  * accessor name, then by the item's slug:
3372
3469
  *
3373
3470
  * ```ts
3374
- * Config.registerSources({ linkedSystems: { yos: yahooOs } })
3471
+ * Config.registerSources({ sources: { yos: yahooOs } })
3375
3472
  * ```
3376
3473
  *
3377
- * The same two levels `register` takes (`{ linkedSystems: { yos: LinkedSystem.item(…) } }`) and the
3474
+ * The same two levels `register` takes (`{ sources: { yos: Source.item(…) } }`) and the
3378
3475
  * same two `fromJSON(json, { sources })` takes, so one gesture — declare a source, then hand
3379
3476
  * over what it resolved to — reads identically at all three. A flat `{ yos }` said nothing about
3380
- * which collection `yos` came from, which is fine while `linked-system` is the only source kind and
3477
+ * which collection `yos` came from, which is fine while `source` is the only source kind and
3381
3478
  * wrong the day there is a second.
3382
3479
  *
3383
3480
  * Immutable like every other authoring step: the sources ride on the derived config, and every later
@@ -3547,7 +3644,7 @@ var Config = class Config {
3547
3644
  *
3548
3645
  * Answers the slug, which is the kind-agnostic half and therefore the half that belongs here. Turning
3549
3646
  * a slug into the typed pin behind it is the source kind's own business (`sourceOfGroup` beside
3550
- * `LinkedSystem`) — a `Config` method could only hand back a bare `Entity`, and the rule above would
3647
+ * `Source`) — a `Config` method could only hand back a bare `Entity`, and the rule above would
3551
3648
  * then be stated once per source kind instead of once.
3552
3649
  */
3553
3650
  groupSource({ kind, groupPath }) {
@@ -3646,7 +3743,7 @@ var Config = class Config {
3646
3743
  * stores, so refusing on that shape would lock a pointer we declared. See `borrowedSlug`.
3647
3744
  */
3648
3745
  /**
3649
- * The pin whose `link` declaration covers `kind:path` and whose source has a row there, so the build
3746
+ * The pin whose `options.include` covers `kind:path` and whose source has a row there, so the build
3650
3747
  * mints the source's row at the path on its next pass. `undefined` when no declaration covers the
3651
3748
  * path, or the declaring source is attached and lacks it. A source that isn't attached is taken at
3652
3749
  * its declaration's word.
@@ -3750,16 +3847,17 @@ var Config = class Config {
3750
3847
  path,
3751
3848
  overlay: null
3752
3849
  });
3753
- const field = Object.keys(write({
3754
- accessor,
3755
- path,
3756
- overlay: null
3757
- }))[0]?.split(".")[0];
3758
- return field ? { [field]: null } : write({
3850
+ const clear = write({
3759
3851
  accessor,
3760
3852
  path,
3761
3853
  overlay: null
3762
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 };
3763
3861
  }
3764
3862
  /**
3765
3863
  * Every path a declared source's declaration says something about, with the accessor resolved to the
@@ -3790,7 +3888,7 @@ var Config = class Config {
3790
3888
  return found;
3791
3889
  }
3792
3890
  /**
3793
- * Whether one of a declared source's paths is adopted here — covered by the pin's `link`.
3891
+ * Whether one of a declared source's paths is adopted here — covered by the pin's `options.include`.
3794
3892
  *
3795
3893
  * The question a spelling turns on: an adopted path is addressed bare, because the build mints a
3796
3894
  * row for it at the path the source spells, and everything else is addressed qualified. The two are
@@ -4717,7 +4815,7 @@ var Config = class Config {
4717
4815
  }
4718
4816
  if (collides) rejectCollisions(derivation.collisions);
4719
4817
  if (stranded.length === 0) return;
4720
- reject("REFERRERS_BLOCK", `Cannot ${action} — it would take away ${stranded.join("; ")}. Copy what is used first (\`linked-system/copy\`), or break the link keeping its values (\`linked-system/break\` with \`keep: true\`).`);
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\`).`);
4721
4819
  }
4722
4820
  /**
4723
4821
  * Whether every directive of `pin` that names `target` sits on a path that no longer derives through
@@ -5732,7 +5830,7 @@ var Config = class Config {
5732
5830
  * in which fields they set are different sources, and collapsing them would share one cache entry.
5733
5831
  *
5734
5832
  * Derived rather than spelled, which is what makes it right for kinds nobody has written — it covers
5735
- * whatever fields a kind actually declares instead of the three `linked-system` happens to have. The
5833
+ * whatever fields a kind actually declares instead of the three `source` happens to have. The
5736
5834
  * key it replaces was `${systemId}@${version}`, which a repo-local source cannot state at all;
5737
5835
  * that is the case the walk using it had to pre-skip.
5738
5836
  */
@@ -5760,7 +5858,7 @@ var Config = class Config {
5760
5858
  *
5761
5859
  * A row borrowed or copied through a pin is asked of that pin's source in turn, so a system linked
5762
5860
  * to a system linked to a foundation answers with the foundation. A row a materialized artifact
5763
- * flattened to a literal has no pointer left, so the pin whose `link` declaration covers the path
5861
+ * flattened to a literal has no pointer left, so the pin whose `options.include` covers the path
5764
5862
  * stands in, provided the row still reads as the source's ({@link matchesSource}); one the
5765
5863
  * publisher changed is its own, and so is a linked row this config lays a value of its own over: the
5766
5864
  * Bridge's `spectrum/blue/0` points at Yahoo OS's with the Bridge's colours on it, which is the
@@ -5803,7 +5901,7 @@ var Config = class Config {
5803
5901
  }
5804
5902
  }
5805
5903
  /**
5806
- * The pin whose `link` declaration covers `kind:path` while the row there still reads as that
5904
+ * The pin whose `options.include` covers `kind:path` while the row there still reads as that
5807
5905
  * source's: how a row a materialized artifact flattened to a literal is traced back to the pin it
5808
5906
  * came through. `undefined` when no declaration covers it, or the row differs from the source's.
5809
5907
  */
@@ -5872,8 +5970,8 @@ var Config = class Config {
5872
5970
  return this.sourceKinds().find((kind) => this.storedBody(kind, slug) !== void 0);
5873
5971
  }
5874
5972
  /**
5875
- * Every source kind by the accessor name its config type declares it under — `linkedSystems` →
5876
- * `linked-system`.
5973
+ * Every source kind by the accessor name its config type declares it under — `sources` →
5974
+ * `source`.
5877
5975
  *
5878
5976
  * The accessor name is what every source-shaped argument is keyed by ({@link AttachedSources},
5879
5977
  * `register`, `Config.load`'s resolvers), because it's the name an author writes, where the kind is
@@ -6045,7 +6143,8 @@ var Config = class Config {
6045
6143
  * {@link retired} answers true for. Both answers are cached per snapshot, so either is safe in a dep
6046
6144
  * array.
6047
6145
  */
6048
- list(kind, opts) {
6146
+ list(written, opts) {
6147
+ const kind = this.currentKind(written);
6049
6148
  const all = this.allOf(kind);
6050
6149
  if (opts?.retired !== false) return all;
6051
6150
  const cache = this.caches.activeLists;
@@ -6221,9 +6320,9 @@ var Config = class Config {
6221
6320
  * every sourced ref dangles, and emitters, integrity checks and memos all read exactly there.
6222
6321
  *
6223
6322
  * `sources` is keyed the way every other source-shaped argument is — by the source kind's accessor
6224
- * name, `{ linkedSystems: resolver }` — so the resolver set, the declaration, and
6323
+ * name, `{ sources: resolver }` — so the resolver set, the declaration, and
6225
6324
  * {@link registerSources} all spell the same key. Each resolver is the kind's own
6226
- * (`LinkedSystemResolver`), and its answer is validated against the schemas that kind declares.
6325
+ * (`SystemSourceResolver`), and its answer is validated against the schemas that kind declares.
6227
6326
  *
6228
6327
  * Reads the source entities off a throwaway bare parse, resolves them all, then hydrates once with
6229
6328
  * whatever came back attached. The bare parse is cheap and is what lets a resolver be handed the
@@ -6436,7 +6535,7 @@ var Config = class Config {
6436
6535
  * links from the provided sources. A declared `linkedKind` with no provided source throws. */
6437
6536
  hydrateFrom(stored, options) {
6438
6537
  const claimed = schemaVersionOf(stored);
6439
- if (claimed > 20261104151013) throw new SchemaVersionTooNew(claimed);
6538
+ if (claimed > 20261105185042) throw new SchemaVersionTooNew(claimed);
6440
6539
  const wire = upgradeSerializedConfig(stored);
6441
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.`);
6442
6541
  const leftover = wire.options;
@@ -6787,9 +6886,9 @@ function extensionChange(entry, kind, path, raw, validate = false) {
6787
6886
  function itemChange(entry, kind, path, raw, validate = false) {
6788
6887
  const body = isRef(raw) || isComposedValue(raw) || typeof raw !== "object" || raw === null ? { [entry.primaryField]: raw } : raw;
6789
6888
  let def = validate === "author" && entry.authoredBody ? entry.authoredBody(body) : body;
6790
- if (validate === "author" && entry.authoredAt) def = storedFromAuthored({
6889
+ if (validate === "author" && entry.retiredFields) def = foldRetiredFields({
6791
6890
  body: def,
6792
- authoredAt: entry.authoredAt
6891
+ retired: entry.retiredFields
6793
6892
  });
6794
6893
  if (validate) {
6795
6894
  const parsed = wholeBodySchema(entry)?.safeParse(def);
@@ -77,7 +77,7 @@ type RecordFor<E> = E extends {
77
77
  * by a thunk yielding the config type each one resolves to.
78
78
  *
79
79
  * ```ts
80
- * sources: { linkedSystems: () => System }
80
+ * sources: { sources: () => System }
81
81
  * ```
82
82
  *
83
83
  * One word for one thing: the declaration here, `Config.registerSources`, `Config.load`'s resolvers,
@@ -85,11 +85,11 @@ type RecordFor<E> = E extends {
85
85
  * key it by the same accessor name `register` uses.
86
86
  *
87
87
  * Keyed by the KIND rather than by a slug, because the slugs are that kind's item paths:
88
- * `linkedSystems: { yos: …, ds: … }` declares the slugs `yos` and `ds` that a ref qualifies with. So
88
+ * `sources: { yos: …, ds: … }` declares the slugs `yos` and `ds` that a ref qualifies with. So
89
89
  * the declaration says which collection those names come from, and cardinality follows from the data —
90
90
  * a system editor has n items, a design file has 1, same kind and same reader.
91
91
  *
92
- * A THUNK because of self-reference: `sources: { linkedSystems: System }` sits inside the call that
92
+ * A THUNK because of self-reference: `sources: { sources: System }` sits inside the call that
93
93
  * produces `System`, where the binding is not initialised yet.
94
94
  *
95
95
  * **TYPING ONLY, and deliberately so.** What it buys is that a resolver is handed that kind's own
@@ -1,10 +1,10 @@
1
1
  import { Entity } from "./Entity.js";
2
2
  import { ExtendableRef, Ref } from "./utils/refs.js";
3
3
  import { TraverseOptions } from "./ref-graph.js";
4
- import { AuthoredAt } from "./authored-at.js";
5
4
  import { CreateInput, FieldsSchema } from "./utils/field-schema.js";
6
5
  import { FieldsCtx, UserSchemas } from "./schemas.js";
7
6
  import { SubEntityClass } from "./defineSubEntity.js";
7
+ import { RetiredFields } from "./retired-fields.js";
8
8
  import { BulkOverlayWrite, BulkQuery, SourceOverlay, SourceResolutionSchemas } from "./sources.js";
9
9
  import { AuthoredValueForm, ComputedFields, EntityKind, Linkable, SourceType } from "./registry.js";
10
10
  import { PathOf } from "./registered.js";
@@ -335,8 +335,9 @@ declare function defineEntity<F extends FieldsSchema, G extends FieldsSchema = z
335
335
  mentionFields?: readonly string[]; /** Cross-item rules the kind holds — see {@link EntityKind.invariants}. */
336
336
  invariants?: (config: Config) => string[]; /** See {@link EntityKind.structuralBody}. */
337
337
  structuralBody?: (data: unknown) => Record<string, unknown>; /** See {@link EntityKind.authoredBody}. */
338
- authoredBody?: (data: Record<string, unknown>) => Record<string, unknown>; /** See {@link EntityKind.authoredAt}. */
339
- authoredAt?: AuthoredAt;
338
+ authoredBody?: (data: Record<string, unknown>) => Record<string, unknown>; /** See {@link EntityKind.retiredFields}. */
339
+ retiredFields?: RetiredFields; /** See {@link EntityKind.retiredKinds}. */
340
+ retiredKinds?: readonly string[];
340
341
  /**
341
342
  * For a source kind that can be resolved: the two schemas its resolutions are validated against —
342
343
  * `{ resolved, unavailable }`. Declare it alongside `sourceIdentity` for a kind a config lists in its
@@ -137,7 +137,8 @@ function defineEntity(spec) {
137
137
  invariants: spec.invariants,
138
138
  structuralBody: spec.structuralBody,
139
139
  authoredBody: spec.authoredBody,
140
- authoredAt: spec.authoredAt,
140
+ retiredFields: spec.retiredFields,
141
+ retiredKinds: spec.retiredKinds,
141
142
  sourceType: spec.sourceType,
142
143
  answeredHere: spec.answeredHere
143
144
  });
@@ -9,7 +9,7 @@
9
9
  * ship writable-in-name-only — the config takes the patch, the file it came from never learns of it.
10
10
  *
11
11
  * Derived from a PROBE kind, not from a real config, because this vocabulary is a property of the
12
- * FRAMEWORK. An entity's own custom ops (`linked-system`'s `link`, a canvas `element-insert`) mean
12
+ * FRAMEWORK. An entity's own custom ops (`source`'s `link`, a canvas `element-insert`) mean
13
13
  * whatever that entity says and carry a handler to match, so they are absent by construction rather
14
14
  * than filtered out — nothing else is obliged to implement them.
15
15
  *
@@ -12,7 +12,7 @@ import { z } from "zod";
12
12
  * ship writable-in-name-only — the config takes the patch, the file it came from never learns of it.
13
13
  *
14
14
  * Derived from a PROBE kind, not from a real config, because this vocabulary is a property of the
15
- * FRAMEWORK. An entity's own custom ops (`linked-system`'s `link`, a canvas `element-insert`) mean
15
+ * FRAMEWORK. An entity's own custom ops (`source`'s `link`, a canvas `element-insert`) mean
16
16
  * whatever that entity says and carry a handler to match, so they are absent by construction rather
17
17
  * than filtered out — nothing else is obliged to implement them.
18
18
  *
@@ -10,7 +10,7 @@ import { kindBorrowable } from "./registry.js";
10
10
  * its readers somewhere `link` refuses to go.
11
11
  *
12
12
  * **A borrowable kind** — a `style-property`, a component. The ref can become ours, but only by being
13
- * copied first, so `linked-system/copy` is the fix. What this must not say is that we have no entity
13
+ * copied first, so `source/copy` is the fix. What this must not say is that we have no entity
14
14
  * at the path: we may well have one, and it is simply not the entity this ref names. A local `bg`
15
15
  * that happens to share a name with theirs is a different declaration, and quietly repointing at it
16
16
  * would change what every callsite means.
@@ -243,7 +243,7 @@ function rewrittenBody({ body, kind, config, slug, options }) {
243
243
  /**
244
244
  * Every item and group body of `config`, rewritten by {@link inlineSourcedRefs}.
245
245
  *
246
- * `linked-system` is skipped: the pins are not values that inline, and they stay — provenance is
246
+ * `source` is skipped: the pins are not values that inline, and they stay — provenance is
247
247
  * information a consumer's tooling still wants for attribution and upgrade detection. Deleting one is
248
248
  * the pin's own `delete`, once nothing refers through it.
249
249
  *
@@ -1,6 +1,6 @@
1
- import { AuthoredAt } from "./authored-at.js";
2
1
  import { DerivedOp, SchemaEntry } from "./schemas.js";
3
2
  import { SubEntityClass } from "./defineSubEntity.js";
3
+ import { RetiredFields } from "./retired-fields.js";
4
4
  import { BulkOverlayWrite, BulkQuery, SourceOverlay, SourceResolutionSchemas } from "./sources.js";
5
5
  import { Config } from "./Config.js";
6
6
  import { z } from "zod";
@@ -13,7 +13,7 @@ import { z } from "zod";
13
13
  interface ComputedInput {
14
14
  readonly member: Record<string, unknown>;
15
15
  readonly config: Config;
16
- /** Identity, so a field that defaults to it can say so (`LinkedSystem.displayName`). */
16
+ /** Identity, so a field that defaults to it can say so (`Source.displayName`). */
17
17
  readonly path: string;
18
18
  }
19
19
  /**
@@ -380,12 +380,18 @@ interface EntityKind {
380
380
  */
381
381
  readonly authoredBody?: (data: Record<string, unknown>) => Record<string, unknown>;
382
382
  /**
383
- * Stored fields an author writes elsewhere in the body, each mapped to the dotted path it is
384
- * authored at (`{ link: 'options.include' }`). `register` folds the authored path into the field,
385
- * the config emitter writes the field back at the path, and a checkout's writer lands a patch at
386
- * whichever of the two the file spells. See `framework/authored-at.ts`.
383
+ * Names this kind was stored and addressed under before a rename (`['source']` for
384
+ * `source`). An op, a patch or a read that names one is taken as naming this kind, so a caller
385
+ * written against the old name keeps working. Stored data is renamed by the migration that renamed
386
+ * the kind.
387
387
  */
388
- readonly authoredAt?: AuthoredAt;
388
+ readonly retiredKinds?: readonly string[];
389
+ /**
390
+ * Fields this kind stores under a new path, each retired dotted path mapped to the current one
391
+ * (`{ link: 'options.include' }`). A body `register` takes, an op's data and a checkout's file may
392
+ * still spell the retired path. See `framework/retired-fields.ts`.
393
+ */
394
+ readonly retiredFields?: RetiredFields;
389
395
  /**
390
396
  * Rewrite one name wherever this kind's data holds it as a key — the cascade half of
391
397
  * {@link nameEdges}, applied by `Config.apply`'s rename alongside `rewriteRefs`.
@@ -30,7 +30,7 @@ function titleCase(kind) {
30
30
  return kind.split(/[-_]/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
31
31
  }
32
32
  function buildKind(spec) {
33
- const { name, prepareLinkedBody, rebaseLinkedBody, layerKeys, fields, groupFields, subEntities = {}, computed, label, labelPlural, schemas: userSchemas, derived, sourceIdentity, sourceOrigin, authoredRefs, linkable, localGroupFields, emergentGroups, singleton = false, bareMember, sourceResolution, bulkAdopts, bulkExcludes, bulkOverlay, bulkDirectives, bulkOverlayWrite, nameEdges, rewriteName, styleBags, uniqueLeaves, parts, authoredValue, mentionFields, invariants, structuralBody, authoredBody, authoredAt, sourceType, answeredHere } = spec;
33
+ const { name, prepareLinkedBody, rebaseLinkedBody, layerKeys, fields, groupFields, subEntities = {}, computed, label, labelPlural, schemas: userSchemas, derived, sourceIdentity, sourceOrigin, authoredRefs, linkable, localGroupFields, emergentGroups, singleton = false, bareMember, sourceResolution, bulkAdopts, bulkExcludes, bulkOverlay, bulkDirectives, bulkOverlayWrite, nameEdges, rewriteName, styleBags, uniqueLeaves, parts, authoredValue, mentionFields, invariants, structuralBody, authoredBody, retiredFields, retiredKinds, sourceType, answeredHere } = spec;
34
34
  const allComputed = {
35
35
  sources: ({ member, config }) => sourceSlugs(member, config),
36
36
  borrowedFrom: ({ config, path }) => config.borrowedFrom(name, path),
@@ -85,7 +85,8 @@ function buildKind(spec) {
85
85
  ...invariants ? { invariants } : {},
86
86
  ...structuralBody ? { structuralBody } : {},
87
87
  ...authoredBody ? { authoredBody } : {},
88
- ...authoredAt ? { authoredAt } : {},
88
+ ...retiredFields ? { retiredFields } : {},
89
+ ...retiredKinds?.length ? { retiredKinds } : {},
89
90
  ...sourceType ? { sourceType } : {},
90
91
  ...answeredHere ? { answeredHere: true } : {}
91
92
  };
@@ -0,0 +1,33 @@
1
+ //#region src/framework/retired-fields.d.ts
2
+ /**
3
+ * A field a kind stores under a new path, still taken under the one it had: a source stores what it
4
+ * includes as `options.include`, and `link` is its retired spelling. Declared by the kind
5
+ * (`EntityKind.retiredFields`, retired path → current path), and read where a body or a delta is
6
+ * written: `register` folds an authored body, an op's data is renamed before it is parsed, and a
7
+ * checkout's writer lands a write at whichever path the file spells.
8
+ *
9
+ * A body or a delta that spells both is refused, since the two are one value.
10
+ */
11
+ /** Retired dotted path → the dotted path the field is stored at now. */
12
+ type RetiredFields = Readonly<Record<string, string>>;
13
+ /** A whole body with each retired field moved to the path it's stored at now. */
14
+ declare function foldRetiredFields({
15
+ body,
16
+ retired
17
+ }: {
18
+ readonly body: Record<string, unknown>;
19
+ readonly retired: RetiredFields;
20
+ }): Record<string, unknown>;
21
+ /**
22
+ * A field-path delta with each key that names a retired field, or a path inside one, renamed to
23
+ * the path the field is stored at now: `{ link: '*' }` → `{ 'options.include': '*' }`.
24
+ */
25
+ declare function deltaUnderCurrentFields({
26
+ delta,
27
+ retired
28
+ }: {
29
+ readonly delta: Record<string, unknown>;
30
+ readonly retired: RetiredFields;
31
+ }): Record<string, unknown>;
32
+ //#endregion
33
+ export { RetiredFields, deltaUnderCurrentFields, foldRetiredFields };