@atolis-hq/corum 0.1.65 → 0.1.66

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.
@@ -25,12 +25,29 @@ export function rewriteIdPrefix(id, oldPrefix, newPrefix) {
25
25
  return newPrefix + id.slice(oldPrefix.length);
26
26
  return null;
27
27
  }
28
+ /** True when `suffix` is one or more `section.name` pairs. */
29
+ function hasOwnedChildShape(suffix) {
30
+ const segments = suffix.split('.');
31
+ return segments.length >= 2 && segments.length % 2 === 0;
32
+ }
28
33
  /**
29
34
  * Resolve a (possibly retired) ID to a live ID through the alias map.
30
35
  * Live node wins outright; exact hits and longest dot-boundary prefix
31
36
  * rewrites are applied to fixpoint with a cycle guard. An unresolved ID is
32
37
  * returned unchanged — the caller decides what that means (genuinely new
33
38
  * node, unknown node, …).
39
+ *
40
+ * Prefix rewrites apply only when the unmatched suffix has owned-child shape:
41
+ * `section.name` pairs (an even number of segments, at least two), e.g.
42
+ * `fields.x`. An independent root that merely shares a retired prefix
43
+ * (`orders.Schema.foo.bar` after `foo` → `baz`) has a one-segment suffix and is
44
+ * left unchanged. Shape is checked on the ID only, so retired children that do
45
+ * not exist in the graph yet still resolve.
46
+ *
47
+ * Known ambiguity: an independent root whose suffix happens to look like an
48
+ * owned child (`orders.Schema.foo.fields.bar`) is indistinguishable by shape
49
+ * and still resolves through the prefix (to `orders.Schema.baz.fields.bar`).
50
+ * Ownership really comes from `parentId`, which bare IDs do not carry.
34
51
  */
35
52
  export function resolveAlias(graph, aliasMap, id) {
36
53
  const seen = new Set();
@@ -45,7 +62,8 @@ export function resolveAlias(graph, aliasMap, id) {
45
62
  id = exact;
46
63
  continue;
47
64
  }
48
- // Longest dot-boundary prefix with a mapping.
65
+ // Longest dot-boundary prefix with a mapping whose unmatched suffix has
66
+ // owned-child shape (see resolveAlias docs).
49
67
  let prefix = id;
50
68
  let rewritten;
51
69
  for (;;) {
@@ -54,7 +72,7 @@ export function resolveAlias(graph, aliasMap, id) {
54
72
  break;
55
73
  prefix = prefix.slice(0, dot);
56
74
  const mapped = aliasMap.get(prefix);
57
- if (mapped !== undefined) {
75
+ if (mapped !== undefined && hasOwnedChildShape(id.slice(prefix.length + 1))) {
58
76
  rewritten = mapped + id.slice(prefix.length);
59
77
  break;
60
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/corum",
3
- "version": "0.1.65",
3
+ "version": "0.1.66",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",