@_linked/core 2.34.0 → 2.36.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 (98) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +54 -0
  3. package/lib/esm/index.d.ts +5 -1
  4. package/lib/esm/index.js +6 -0
  5. package/lib/esm/index.js.map +1 -1
  6. package/lib/esm/live/LiveQueryStore.d.ts +22 -0
  7. package/lib/esm/live/LiveQueryStore.js +88 -20
  8. package/lib/esm/live/LiveQueryStore.js.map +1 -1
  9. package/lib/esm/live/changes.d.ts +9 -1
  10. package/lib/esm/live/changes.js +7 -2
  11. package/lib/esm/live/changes.js.map +1 -1
  12. package/lib/esm/live/keys.d.ts +6 -0
  13. package/lib/esm/live/keys.js +10 -1
  14. package/lib/esm/live/keys.js.map +1 -1
  15. package/lib/esm/live/matcher.d.ts +4 -1
  16. package/lib/esm/live/matcher.js +10 -5
  17. package/lib/esm/live/matcher.js.map +1 -1
  18. package/lib/esm/queries/AskBuilder.d.ts +6 -0
  19. package/lib/esm/queries/AskBuilder.js +14 -0
  20. package/lib/esm/queries/AskBuilder.js.map +1 -1
  21. package/lib/esm/queries/CountBuilder.d.ts +6 -0
  22. package/lib/esm/queries/CountBuilder.js +14 -0
  23. package/lib/esm/queries/CountBuilder.js.map +1 -1
  24. package/lib/esm/queries/CreateBuilder.d.ts +4 -0
  25. package/lib/esm/queries/CreateBuilder.js +15 -1
  26. package/lib/esm/queries/CreateBuilder.js.map +1 -1
  27. package/lib/esm/queries/DeleteBuilder.d.ts +4 -0
  28. package/lib/esm/queries/DeleteBuilder.js +15 -1
  29. package/lib/esm/queries/DeleteBuilder.js.map +1 -1
  30. package/lib/esm/queries/FieldSet.d.ts +17 -0
  31. package/lib/esm/queries/FieldSet.js +110 -22
  32. package/lib/esm/queries/FieldSet.js.map +1 -1
  33. package/lib/esm/queries/IRLower.js +3 -2
  34. package/lib/esm/queries/IRLower.js.map +1 -1
  35. package/lib/esm/queries/IRMutation.js +15 -14
  36. package/lib/esm/queries/IRMutation.js.map +1 -1
  37. package/lib/esm/queries/MutationQuery.js +3 -2
  38. package/lib/esm/queries/MutationQuery.js.map +1 -1
  39. package/lib/esm/queries/MutationSerialization.js +2 -2
  40. package/lib/esm/queries/MutationSerialization.js.map +1 -1
  41. package/lib/esm/queries/PropertyPath.js +4 -3
  42. package/lib/esm/queries/PropertyPath.js.map +1 -1
  43. package/lib/esm/queries/QueryBuilder.d.ts +7 -0
  44. package/lib/esm/queries/QueryBuilder.js +42 -4
  45. package/lib/esm/queries/QueryBuilder.js.map +1 -1
  46. package/lib/esm/queries/QueryContext.js +2 -0
  47. package/lib/esm/queries/QueryContext.js.map +1 -1
  48. package/lib/esm/queries/SelectQuery.js +8 -3
  49. package/lib/esm/queries/SelectQuery.js.map +1 -1
  50. package/lib/esm/queries/UpdateBuilder.d.ts +4 -0
  51. package/lib/esm/queries/UpdateBuilder.js +15 -1
  52. package/lib/esm/queries/UpdateBuilder.js.map +1 -1
  53. package/lib/esm/queries/fromJSON.d.ts +12 -1
  54. package/lib/esm/queries/fromJSON.js +5 -1
  55. package/lib/esm/queries/fromJSON.js.map +1 -1
  56. package/lib/esm/queries/lower.js +12 -5
  57. package/lib/esm/queries/lower.js.map +1 -1
  58. package/lib/esm/queries/queryDependencies.js +14 -10
  59. package/lib/esm/queries/queryDependencies.js.map +1 -1
  60. package/lib/esm/queries/resolveShape.js +16 -3
  61. package/lib/esm/queries/resolveShape.js.map +1 -1
  62. package/lib/esm/shapes/Shape.js +2 -1
  63. package/lib/esm/shapes/Shape.js.map +1 -1
  64. package/lib/esm/shapes/nodeShapeData.js +7 -10
  65. package/lib/esm/shapes/nodeShapeData.js.map +1 -1
  66. package/lib/esm/shapes/registerRuntimeShape.js +3 -1
  67. package/lib/esm/shapes/registerRuntimeShape.js.map +1 -1
  68. package/lib/esm/shapes/syncShapes.d.ts +6 -2
  69. package/lib/esm/shapes/syncShapes.js +16 -9
  70. package/lib/esm/shapes/syncShapes.js.map +1 -1
  71. package/lib/esm/shapes/validation.js +10 -6
  72. package/lib/esm/shapes/validation.js.map +1 -1
  73. package/lib/esm/sparql/irToAlgebra.js +117 -52
  74. package/lib/esm/sparql/irToAlgebra.js.map +1 -1
  75. package/lib/esm/sparql/ownedLinkCheck.js +6 -1
  76. package/lib/esm/sparql/ownedLinkCheck.js.map +1 -1
  77. package/lib/esm/utils/LinkedStorage.d.ts +7 -0
  78. package/lib/esm/utils/LinkedStorage.js +39 -12
  79. package/lib/esm/utils/LinkedStorage.js.map +1 -1
  80. package/lib/esm/utils/ShapeCatalog.d.ts +57 -0
  81. package/lib/esm/utils/ShapeCatalog.js +86 -0
  82. package/lib/esm/utils/ShapeCatalog.js.map +1 -0
  83. package/lib/esm/utils/ShapeClass.d.ts +73 -8
  84. package/lib/esm/utils/ShapeClass.js +245 -66
  85. package/lib/esm/utils/ShapeClass.js.map +1 -1
  86. package/lib/esm/utils/linkedError.d.ts +35 -0
  87. package/lib/esm/utils/linkedError.js +52 -0
  88. package/lib/esm/utils/linkedError.js.map +1 -0
  89. package/lib/esm/utils/registryCache.d.ts +15 -0
  90. package/lib/esm/utils/registryCache.js +50 -0
  91. package/lib/esm/utils/registryCache.js.map +1 -0
  92. package/lib/esm/utils/sharedState.d.ts +25 -0
  93. package/lib/esm/utils/sharedState.js +34 -0
  94. package/lib/esm/utils/sharedState.js.map +1 -0
  95. package/lib/esm/utils/unresolvedShape.d.ts +42 -0
  96. package/lib/esm/utils/unresolvedShape.js +68 -0
  97. package/lib/esm/utils/unresolvedShape.js.map +1 -0
  98. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ShapeClass.js","sourceRoot":"","sources":["../../../src/utils/ShapeClass.ts"],"names":[],"mappings":";AACA,sFAAsF;AACtF,6FAA6F;AAC7F,sFAAsF;AACtF,wFAAwF;AACxF,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,gBAAgB,GA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AAE,EAAE;QACnC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,EAAE;YACvC,OAAO,aAAa,CAAC,SAAS,YAAY,QAAQ,CAAC;QACrD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAS,2BAA2B,CAAC,YAAY;IAC/C,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE;QACxC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE;YAC5C,OAAO,CACL,eAAe,KAAK,UAAU;gBAC9B,UAAU,CAAC,SAAS,YAAY,eAAe,CAChD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,MAAM,CAAC,KAAsC;IACpD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5C,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,WAAW,CAAC,KAAmB;IACtC,uCAAuC;IACvC,OAAO,CACL,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC;QACvC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import {type Shape, type ShapeConstructor} from '../shapes/Shape.js';\n// Namespace import, read at CALL time rather than captured at module-evaluation time.\n// `getOrCreateShapeAdapter` subclasses `Shape` at runtime, and under some import orders this\n// module finishes evaluating before `Shape.js` does — a named import captured then is\n// permanently `undefined`, and the subclass fails with \"Class extends value undefined\".\nimport * as ShapeModule from '../shapes/Shape.js';\nimport {\n getPropertyShape,\n type NodeShapeData,\n type PropertyShapeData,\n} from '../shapes/nodeShapeData.js';\nimport type {NodeShapeWire} from '../shapes/nodeShapeWire.js';\nimport type {ICoreIterable} from '../interfaces/ICoreIterable.js';\nimport type {NodeReferenceValue} from './NodeReference.js';\n\nconst resolveTargetClassId = (\n targetClass?: NodeReferenceValue | null,\n): string | null => {\n if (!targetClass) return null;\n return targetClass.id ?? null;\n};\n\n/**\n * The shape registries live on `globalThis`, not in module scope.\n *\n * A module can evaluate more than once in one process, and in a built app it does: an\n * app's backend is assembled from two graphs, one loaded by the bundler from `src/` and\n * one resolved by Node to `lib/esm/`. A module-scope `Map` then exists twice — shapes\n * register into one copy and every lookup reads the other, which finds nothing.\n *\n * The symptom never mentions module identity. It is `Invalid property key: projectSlug.\n * The shape Project does not have a registered property with this name` for a property\n * that is declared correctly two files away, because validation ran on the copy the\n * decorators never reached. See docs/reports/043-module-identity-in-the-backend.md.\n *\n * Sharing the state makes duplication harmless rather than merely absent: the graphs\n * still hold two copies of this module, but only one registry. `LinkedStorage` already\n * keeps its instance counter here; this keeps the data itself.\n */\nconst shapeRegistryGlobal: any =\n typeof globalThis !== 'undefined' ? globalThis : ({} as any);\n\n/**\n * Counts DISTINCT physical copies of this module, not evaluations of it.\n *\n * The difference matters. A bare `count++` here is incremented by Vite's HMR every time\n * the module is re-evaluated in the same process, against the same `globalThis` — so a\n * developer who edits a file a few times sees a count of 4 and goes hunting a\n * dual-resolution problem that does not exist. Recording a token per copy and counting\n * the tokens survives re-evaluation: HMR replaces the module, and its token with it.\n */\nconst copyToken: object = {};\nconst copies: Set<object> = (shapeRegistryGlobal.__linkedShapeRegistryCopies ??= new Set());\ncopies.add(copyToken);\n\n/**\n * More than one copy of this module means shapes register into one registry and are\n * looked up in another, and the resulting failures never mention module identity — they\n * say a declared property is not declared, or that a pinned shape has no pin.\n *\n * Reported rather than thrown. A throw from a library module at import time breaks\n * tooling that legitimately loads a module twice, and the shared state above means a\n * second copy is survivable: it is a correctness hazard for anything holding a class\n * reference, not an immediate failure. So this says so, once, as loudly as a log can.\n */\nif (copies.size > 1) {\n console.error(\n `[linked] ${copies.size} copies of @_linked/core's shape registry have loaded in ` +\n `this process. They share one registry, so lookups still resolve — but each copy ` +\n `has its own \\`Shape\\` base class, so \\`instanceof\\` comparisons across them are ` +\n `false and adapters built by one copy do not satisfy the other. This is a module ` +\n `resolution problem: part of the app is reaching this package by a path that ` +\n `resolves to its source and part by one that resolves to its build output.`,\n );\n}\n\n/**\n * One shared container, created by whichever copy evaluates first.\n *\n * `registryVersion` belongs here too: every derived cache in this module is keyed on it,\n * so a version that is not shared would let one copy's writes leave another copy's caches\n * looking valid. The caches themselves stay per-copy — they are rebuilt whenever the\n * shared version moves past them.\n */\nconst registryState: {\n nodeShapeToShapeClass: Map<string, typeof Shape>;\n nodeShapeRegistry: Map<string, NodeShapeData>;\n shapeAdapters: Map<string, typeof Shape>;\n registryVersion: number;\n} = (shapeRegistryGlobal.__linkedShapeRegistry ??= {\n nodeShapeToShapeClass: new Map(),\n nodeShapeRegistry: new Map(),\n shapeAdapters: new Map(),\n registryVersion: 0,\n});\n\n/** How many distinct copies of this module are loaded. One is expected. */\nexport function getShapeRegistryInstanceCount(): number {\n return copies.size;\n}\n\nlet subShapesCache: Map<string, (typeof Shape)[]> = new Map();\nlet mostSpecificSubShapesCache: Map<string, (typeof Shape)[]> = new Map();\nconst nodeShapeToShapeClass = registryState.nodeShapeToShapeClass;\nconst warnedDuplicateBases = new Set<string>();\n\n/**\n * The PRIMARY shape registry: node-shape IRI → its metadata.\n *\n * Every shape is here — those declared by a `@linkedShape` class and those known only\n * as data (a project-authored shape read from the graph). `nodeShapeToShapeClass` above\n * is the SECONDARY registry, holding only the shapes that have a TypeScript class, and\n * exists for the few callers that genuinely need a class (a `ShapeProvider` lookup, a\n * typed accessor). Query lowering, predicate resolution and containment all read\n * metadata, so they use this map and work identically for both kinds of shape.\n */\nconst nodeShapeRegistry = registryState.nodeShapeRegistry;\n\n/** Version the sub-shape caches above were filled at. */\nlet subShapesCacheVersion = -1;\n\n/**\n * The current registration version — a monotonic counter, bumped on every write.\n *\n * Every derived cache in this module, and in `irToAlgebra`, is keyed on it. It replaces\n * two earlier invalidation strategies that were both unsound: a `setTimeout(…, 0)` cache\n * clear (which missed anything registered later in the same session) and comparing the\n * registry SIZE (which silently reuses a stale cache when a registration and a removal\n * coincide, or when a shape is re-registered in place).\n *\n * It lives on the shared state, not in module scope: a cache keyed on a per-copy version\n * would look valid after another copy had written.\n */\nexport function getRegistryVersion(): number {\n return registryState.registryVersion;\n}\n\n/** Reverse index parentIri → direct child IRIs, rebuilt when the registry changes. */\nlet childIndex: Map<string, string[]> | null = null;\nlet childIndexVersion = -1;\n\nfunction getChildIndex(): Map<string, string[]> {\n if (childIndex && childIndexVersion === registryState.registryVersion) return childIndex;\n const index = new Map<string, string[]>();\n nodeShapeRegistry.forEach((shape, id) => {\n const parent = shape.extends?.id;\n if (!parent) return;\n const siblings = index.get(parent);\n if (siblings) siblings.push(id);\n else index.set(parent, [id]);\n });\n childIndex = index;\n childIndexVersion = registryState.registryVersion;\n return index;\n}\n\nfunction invalidateRegistryCaches() {\n registryState.registryVersion++;\n subShapesCache.clear();\n mostSpecificSubShapesCache.clear();\n childIndex = null;\n targetClassIndex = null;\n}\n\n/** Drop the adapter for a shape whose metadata was replaced. */\nfunction invalidateShapeAdapter(id: string) {\n shapeAdapters.delete(id);\n}\n\n/**\n * Register a shape known only as data — no TypeScript class is created.\n *\n * This is the return leg of the round trip: `@linkedShape` is class → metadata,\n * `syncShapes` is metadata → RDF, and this is RDF → metadata. Idempotent: re-registering\n * the same IRI replaces the metadata (a shape edited in the builder), which is why cache\n * invalidation cannot be keyed on registry size.\n */\nexport function registerNodeShape(nodeShape: NodeShapeData): void {\n if (!nodeShape?.id) return;\n nodeShapeRegistry.set(nodeShape.id, nodeShape);\n invalidateShapeAdapter(nodeShape.id);\n invalidateRegistryCaches();\n}\n\n/** The metadata for a node-shape IRI, whether or not it has a TypeScript class. */\nexport function getNodeShape(\n nodeShape: NodeReferenceValue | {id: string} | string,\n): NodeShapeData | undefined {\n const id = typeof nodeShape === 'string' ? nodeShape : nodeShape?.id;\n if (!id) return undefined;\n return nodeShapeRegistry.get(id);\n}\n\n/** Every registered shape's metadata, keyed by node-shape IRI. */\nexport function getAllNodeShapes(): ReadonlyMap<string, NodeShapeData> {\n return nodeShapeRegistry;\n}\n\n/**\n * Lazily-built constructors for shapes that exist only as data.\n *\n * The builder entry points (`QueryBuilder`, `CreateBuilder`, `UpdateBuilder`,\n * `DeleteBuilder` via `resolveShape`) take a `ShapeConstructor` and instantiate result\n * proxies from it, so they need *a* class. Rather than have every caller hand-roll one —\n * which is what `create-now-js`'s `registerRuntimeShape` used to do, losing `extends` and\n * every value constraint on the way — core derives one on demand from the registered\n * metadata and caches it.\n *\n * These adapters are deliberately NOT in `nodeShapeToShapeClass`: `getShapeClass` keeps\n * telling the truth about which shapes have a real, authored class. An adapter carries\n * the metadata verbatim, so nothing is lost, and inheritance is read from\n * `nodeShape.extends` (not from the adapter's prototype, which is always `Shape`).\n */\nconst shapeAdapters = registryState.shapeAdapters;\n\n/**\n * A constructor for a shape known only as data, created on first use.\n *\n * Returns undefined when the IRI is not registered at all. Prefer `getShapeClass` when\n * you specifically need an authored class; use this when you need *something*\n * constructor-shaped to drive the query builders.\n */\nexport function getOrCreateShapeAdapter(\n nodeShape: NodeShapeData | string,\n): typeof Shape | undefined {\n const data =\n typeof nodeShape === 'string' ? nodeShapeRegistry.get(nodeShape) : nodeShape;\n if (!data?.id) return undefined;\n\n const authored = nodeShapeToShapeClass.get(data.id);\n if (authored) return authored;\n\n const cached = shapeAdapters.get(data.id);\n // Re-registering a shape replaces its metadata, so an adapter built from the old\n // object must not be reused.\n if (cached && cached.shape === data) return cached;\n\n class RuntimeShape extends ShapeModule.Shape {\n static shape = data as NodeShapeData;\n static targetClass = (data as NodeShapeData).targetClass ?? null;\n }\n Object.defineProperty(RuntimeShape, 'name', {\n value: (data as NodeShapeData).label || 'RuntimeShape',\n });\n shapeAdapters.set(data.id, RuntimeShape);\n return RuntimeShape;\n}\n\n/** Anything that can identify a shape: its metadata, its class, or its IRI. */\nexport type ShapeLike = NodeShapeData | typeof Shape | Function | string;\n\n/** Resolve a ShapeLike to node-shape metadata, or undefined if it isn't a shape. */\nfunction toNodeShapeData(shape: ShapeLike): NodeShapeData | undefined {\n if (!shape) return undefined;\n if (typeof shape === 'string') return nodeShapeRegistry.get(shape);\n const asData = shape as NodeShapeData;\n // NodeShapeData is a plain object with an id; a Shape class is a function.\n if (typeof shape === 'object' && typeof asData.id === 'string') {\n return nodeShapeRegistry.get(asData.id) ?? asData;\n }\n const asClass = shape as typeof Shape;\n const shapeData = asClass?.shape;\n if (shapeData?.id) return nodeShapeRegistry.get(shapeData.id) ?? shapeData;\n return undefined;\n}\n\nconst warnedUnresolvedExtends = new Set<string>();\n\n/**\n * Every shape the given shape extends, most specific first.\n *\n * THE canonical inheritance walk — `getPropertyShapes(shape, true)` delegates to it, so\n * there is exactly one answer to \"what does this shape extend\". Two earlier walks\n * disagreed (one over the prototype chain, one over `extends`) and that divergence, not\n * either strategy, was the bug: `selectAll` listed labels from one and resolved them\n * through the other, so an inherited property became unresolvable and the query proxy\n * threw.\n *\n * Strategy is chosen by what is available:\n *\n * - **A class-backed shape walks its prototype chain.** This is authoritative and\n * includes the framework `Shape` root, whose own property shapes (`label`, `type`) are\n * genuinely inherited. `applyLinkedShape` deliberately does NOT record `extends` for\n * that root — it is not a domain shape and must not appear as an `extends` triple in\n * materialized SHACL — so the data alone cannot see it.\n * - **A shape known only as data walks `extends` through the registry.** This is what\n * makes inheritance work for a project-authored shape with no class, which the\n * prototype chain cannot express.\n *\n * `extends` is a REFERENCE, so a parent that was never registered ends the walk. The\n * prototype chain has no such failure mode, so it warns once per shape rather than\n * throwing — this runs on read paths.\n */\nexport function getSuperShapes(shape: ShapeLike): NodeShapeData[] {\n const start = toNodeShapeData(shape);\n const chain: NodeShapeData[] = [];\n if (!start) return chain;\n\n // Class-backed: the prototype chain is the authority.\n const startClass = nodeShapeToShapeClass.get(start.id);\n if (startClass) {\n let current: typeof Shape | undefined = startClass;\n while (current) {\n const parent = Object.getPrototypeOf(current) as typeof Shape | undefined;\n if (!parent?.shape) break;\n chain.push(parent.shape);\n if ((parent as unknown) === (ShapeModule.Shape as unknown)) break;\n current = parent;\n }\n return chain;\n }\n\n const seen = new Set<string>([start.id]);\n let current: NodeShapeData | undefined = start;\n while (current?.extends?.id) {\n const parentId = current.extends.id;\n if (seen.has(parentId)) break; // cycle guard — malformed data must not hang a read\n seen.add(parentId);\n const parent = nodeShapeRegistry.get(parentId);\n if (!parent) {\n if (!warnedUnresolvedExtends.has(current.id)) {\n warnedUnresolvedExtends.add(current.id);\n console.warn(\n `[linked] Shape '${current.id}' extends '${parentId}', which is not registered. ` +\n `Inherited properties from it are unavailable. Register the parent shape first ` +\n `(import its module, or register its metadata before the child).`,\n );\n }\n break;\n }\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\n/** Every shape that extends the given shape, transitively. Most specific last. */\nexport function getSubShapes(shape: ShapeLike): NodeShapeData[] {\n const start = toNodeShapeData(shape);\n if (!start) return [];\n const index = getChildIndex();\n const out: NodeShapeData[] = [];\n const seen = new Set<string>([start.id]);\n const queue = [start.id];\n while (queue.length) {\n const current = queue.shift()!;\n for (const childId of index.get(current) ?? []) {\n if (seen.has(childId)) continue;\n seen.add(childId);\n const child = nodeShapeRegistry.get(childId);\n if (child) {\n out.push(child);\n queue.push(childId);\n }\n }\n }\n return out;\n}\n\n/** True when `a` extends `b` (strictly — a shape is not a sub-shape of itself). */\nexport function isSubShapeOf(a: ShapeLike, b: ShapeLike): boolean {\n const target = toNodeShapeData(b);\n if (!target) return false;\n return getSuperShapes(a).some((superShape) => superShape.id === target.id);\n}\n\n/**\n * The fields of a shape the targetClass lookups read. Both `NodeShapeData` and its wire\n * form satisfy it, so a caller holding a shape catalog never has to convert it first.\n */\ntype ShapeHeader = Pick<NodeShapeData, 'id' | 'targetClass' | 'extends'>;\n\n/**\n * Every shape `shape` extends, most specific first — resolving each parent in `local`\n * before the registry.\n *\n * `local` is a caller's own set of shapes (a project's catalog), which may hold shapes the\n * registry has never seen, or newer versions of ones it has. The catalog is the authority\n * for what it holds; once the chain leaves it, the registry knows the rest.\n */\nfunction superShapesWithin(\n shape: ShapeHeader,\n local?: ReadonlyMap<string, ShapeHeader>,\n): ShapeHeader[] {\n if (!local) return getSuperShapes(shape as NodeShapeData);\n const chain: ShapeHeader[] = [];\n const seen = new Set<string>([shape.id]);\n let current: ShapeHeader = shape;\n while (current.extends?.id) {\n const parentId = current.extends.id;\n if (seen.has(parentId)) break; // cycle guard — malformed data must not hang a read\n seen.add(parentId);\n const parent = local.get(parentId);\n if (!parent) {\n const registered = nodeShapeRegistry.get(parentId);\n if (registered) chain.push(registered, ...getSuperShapes(registered));\n break;\n }\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\nfunction indexShapes<S extends ShapeHeader>(shapes: Iterable<S>): Map<string, S> {\n const index = new Map<string, S>();\n for (const shape of shapes) if (shape?.id) index.set(shape.id, shape);\n return index;\n}\n\nfunction targetClassIdWithin(\n shape: ShapeLike | NodeShapeWire | {id: string},\n local?: ReadonlyMap<string, ShapeHeader>,\n): string | undefined {\n if (!shape) return undefined;\n if (typeof shape === 'function') {\n // A class's static targetClass is inherited through the prototype chain for free.\n const asClass = shape as typeof Shape;\n if (asClass.targetClass?.id) return asClass.targetClass.id;\n if (!asClass.shape?.id) return undefined;\n shape = asClass.shape;\n }\n const id = typeof shape === 'string' ? shape : shape.id;\n if (!id) return undefined;\n const given = typeof shape === 'string' ? undefined : (shape as ShapeHeader);\n const own =\n given?.targetClass?.id ??\n local?.get(id)?.targetClass?.id ??\n getShapeClass(id)?.targetClass?.id ??\n nodeShapeRegistry.get(id)?.targetClass?.id;\n if (own) return own;\n // A data-only shape's targetClass is not inherited for free, so walk `extends`.\n const start = local?.get(id) ?? (given?.extends ? given : nodeShapeRegistry.get(id) ?? given);\n if (!start) return undefined;\n return superShapesWithin(start, local).find((s) => s.targetClass?.id)?.targetClass?.id;\n}\n\n/**\n * The class a shape's instances are typed with: its own `targetClass`, else the first one\n * found through what it extends. `undefined` when there is none anywhere in the chain.\n *\n * Accepts a shape IRI, a `{id}` reference, a shape's metadata (data or wire form) or a shape\n * class. Pass `shapes` to resolve the shape — and what it extends — in that set before the\n * registry; a project's catalog may hold shapes the registry does not.\n */\nexport function getTargetClassId(\n shape: ShapeLike | NodeShapeWire | {id: string},\n shapes?: Iterable<NodeShapeData | NodeShapeWire>,\n): string | undefined {\n return targetClassIdWithin(shape, shapes ? indexShapes(shapes) : undefined);\n}\n\n/**\n * The least specific candidates (the roots), by id. A candidate that extends another\n * candidate (directly or further up) is dropped: a relation to `Person` with `Person` and\n * `Employee extends Person` both targeting it means `Person` — a relation never upgrades\n * itself to a sub-shape; declare `sh:node` to ask for one. What remains are unrelated roots\n * the data does not choose between; they sort by id alone — never by depth or by\n * registration or catalog order — so the choice is stable and visibly arbitrary. If that\n * would drop every candidate (an `extends` cycle), all of them are kept, by id.\n */\nfunction leastSpecific<S extends ShapeHeader>(\n candidates: S[],\n local?: ReadonlyMap<string, ShapeHeader>,\n): S[] {\n const ids = new Set(candidates.map((c) => c.id));\n const byId = (a: S, b: S) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);\n const roots = candidates.filter(\n (candidate) => !superShapesWithin(candidate, local).some((parent) => ids.has(parent.id)),\n );\n // An `extends` cycle makes each member extend another, so the filter can leave nothing.\n // Malformed data must not turn a relation into \"no shape\" silently: keep every candidate\n // instead, by id, and let the caller's ambiguity handling (warn) apply.\n return (roots.length ? roots : [...candidates]).sort(byId);\n}\n\n/** targetClass IRI → registered shapes targeting it, ordered. Rebuilt when the registry changes. */\nlet targetClassIndex: Map<string, NodeShapeData[]> | null = null;\nlet targetClassIndexVersion = -1;\n\nfunction getTargetClassIndex(): Map<string, NodeShapeData[]> {\n if (targetClassIndex && targetClassIndexVersion === registryState.registryVersion) {\n return targetClassIndex;\n }\n const index = new Map<string, NodeShapeData[]>();\n nodeShapeRegistry.forEach((shape) => {\n const classId = targetClassIdWithin(shape);\n if (!classId) return;\n const shapes = index.get(classId);\n if (shapes) shapes.push(shape);\n else index.set(classId, [shape]);\n });\n index.forEach((shapes, classId) => index.set(classId, leastSpecific(shapes)));\n targetClassIndex = index;\n targetClassIndexVersion = registryState.registryVersion;\n return index;\n}\n\n/**\n * The least specific shapes whose effective targetClass (own, or inherited through\n * `extends`) is exactly `classIri`, sorted by id. A matching shape that extends another\n * match is left out, so one entry means the class has one root shape and more than one\n * means unrelated roots compete for it. Sub-shapes are never chosen for a class alone.\n *\n * With no `shapes`, the candidates are the registered shapes. Pass `shapes` to choose among\n * that set only — the registry also holds compiled framework shapes, and a project's\n * `schema:Person` relation should resolve to the project's shape, not to one a framework\n * package happens to register for the same class. Inheritance is still resolved through\n * the registry when a candidate extends a shape outside the set.\n */\nexport function getShapesForTargetClass(classIri: string): NodeShapeData[];\nexport function getShapesForTargetClass<S extends NodeShapeData | NodeShapeWire>(\n classIri: string,\n shapes: Iterable<S>,\n): S[];\nexport function getShapesForTargetClass(\n classIri: string,\n shapes?: Iterable<NodeShapeData | NodeShapeWire>,\n): (NodeShapeData | NodeShapeWire)[] {\n if (!classIri) return [];\n if (!shapes) return [...(getTargetClassIndex().get(classIri) ?? [])];\n const local = indexShapes(shapes);\n const candidates = [...local.values()].filter(\n (shape) => targetClassIdWithin(shape, local) === classIri,\n );\n return leastSpecific(candidates, local);\n}\n\nexport function addNodeShapeToShapeClass(\n nodeShape: NodeShapeData,\n shapeClass: typeof Shape,\n) {\n if (!nodeShape?.id) {\n return;\n }\n // Dev guardrail for IDENTITY duplication. Shape URIs embed `constructor.name`\n // (getNodeShapeUri). If a bundler emits >1 copy of a framework package, the copies\n // are renamed `Person`→`Person2`/`3`, so a mangled URI registers alongside the clean\n // one — the exact failure that silently breaks cross-runtime shape lookup (`Person3`\n // on the FE ≠ `Person` on the backend). Warn ONCE per base so a build-config\n // regression (e.g. a dropped `optimizeDeps.exclude`) surfaces loudly instead of\n // no-op'ing a query at forward time.\n //\n // This used to be dev-only, on the reasoning that production is minified and\n // the check would false-fire. It does not: full minification renames a class\n // to something like `za`, so `base === id` and nothing fires. What DOES fire\n // is the case worth catching — a bundler appending a digit to disambiguate\n // `BackendAPIStore` from the ontology term of the same name, which is exactly\n // the collision that breaks shape lookup, and it only happens in a production\n // build. Suppressing the warning there hid it from the one place it occurs.\n {\n const id = nodeShape.id;\n const base = id.replace(/\\d+$/, '');\n const existing = nodeShapeToShapeClass.get(base);\n if (base !== id && existing && !warnedDuplicateBases.has(base)) {\n // A real duplicate is the SAME logical shape (same targetClass) registered under\n // a mangled name; a legit digit-suffixed sibling (e.g. `OAuth2` vs `OAuth`)\n // targets a different class. Warn only when they match (or targetClass is absent).\n const newTarget = (shapeClass as any).targetClass?.id;\n const existingTarget = (existing as any).targetClass?.id;\n if (!newTarget || !existingTarget || newTarget === existingTarget) {\n warnedDuplicateBases.add(base);\n console.warn(\n `[linked] Shape identity duplication: '${id}' registered alongside '${base}'. ` +\n `A bundler emitted >1 copy of this package — cross-runtime shape lookup will ` +\n `break. Check the cli vite-config single-instance levers (optimizeDeps.exclude ` +\n `/ ssr.noExternal).`,\n );\n }\n }\n }\n nodeShapeToShapeClass.set(nodeShape.id, shapeClass);\n // The class-backed shape goes into the primary registry too, so metadata consumers\n // see one map regardless of how a shape was declared. This also bumps the version,\n // which invalidates every derived cache immediately rather than on a next-tick timer.\n registerNodeShape(nodeShape);\n}\n\n/**\n * The constructor for a shape IRI — an authored class if there is one, otherwise one\n * derived from the registered metadata.\n *\n * This is what the query layer wants in every case, and `getShapeClass` alone is not:\n * it answers `undefined` for a shape that exists only as data, which is every shape\n * authored in a project. Five call sites used to spell this fallback out by hand, in\n * four different ways.\n *\n * `getShapeClass` is NOT consulted first. `getOrCreateShapeAdapter` already returns the\n * authored class when one exists, and a class-backed shape is always mirrored into the\n * primary registry, so the adapter path cannot miss a shape `getShapeClass` would find.\n */\nexport function resolveShapeConstructor(\n nodeShape: NodeReferenceValue | {id: string} | string,\n): ShapeConstructor | undefined {\n const id = typeof nodeShape === 'string' ? nodeShape : nodeShape?.id;\n if (!id) return undefined;\n // SAFETY: both paths yield a concrete subclass of Shape with a static .shape —\n // i.e. a ShapeConstructor. Same cast getShapeClass documents.\n return getOrCreateShapeAdapter(id) as unknown as ShapeConstructor | undefined;\n}\n\nexport function getShapeClass(\n nodeShape: NodeReferenceValue | {id: string} | string,\n): ShapeConstructor | undefined {\n const id = typeof nodeShape === 'string' ? nodeShape : nodeShape?.id;\n if (!id) {\n return undefined;\n }\n // SAFETY: The map stores `typeof Shape` (abstract), but registered shapes are always\n // concrete subclasses with a constructor and static .shape — i.e. ShapeConstructor.\n return nodeShapeToShapeClass.get(id) as unknown as ShapeConstructor | undefined;\n}\n\n/**\n * Returns all registered shape classes (keyed by NodeShape URI).\n */\nexport function getAllShapeClasses(): Map<string, typeof Shape> {\n return nodeShapeToShapeClass;\n}\n\n/**\n * Returns all the sub shapes of the given shape\n * That is all the shapes that extend this shape\n * @param shape\n */\n\nexport function getSubShapesClasses(\n shape: typeof Shape | (typeof Shape)[],\n _internalKey?: string,\n): (typeof Shape)[] {\n let key = _internalKey || getKey(shape);\n if (subShapesCacheVersion !== registryState.registryVersion) {\n subShapesCache.clear();\n mostSpecificSubShapesCache.clear();\n subShapesCacheVersion = registryState.registryVersion;\n }\n if (!subShapesCache.has(key)) {\n //apply the hasSuperclass function to the shape\n let filterFunction = applyFnToShapeOrArray(shape, hasSubClass);\n //filter and then sort the results based on their inheritance (most specific classes first, so we use hasSuperClass for the sorting)\n subShapesCache.set(\n key,\n filterShapeClasses(filterFunction).sort((a, b) => {\n return hasSubClass(a, b) ? 1 : -1;\n }),\n );\n }\n //return a copy of the array to prevent it from being modified\n return [...subShapesCache.get(key)];\n}\n\n/**\n * Returns all the superclasses of the given shape\n * That is all the shapes that it extends.\n * Results are sorted from most specific to least specific\n * @param shape\n */\nexport function getSuperShapesClasses(\n shape: typeof Shape | (typeof Shape)[],\n): (typeof Shape)[] {\n //apply the hasSuperclass function to the shape\n let filterFunction = applyFnToShapeOrArray(shape, hasSuperClass);\n //filter and then sort the results based on their inheritance\n return filterShapeClasses(filterFunction).sort((a, b) => {\n return hasSubClass(a, b) ? 1 : -1;\n });\n}\n\nexport function getPropertyShapeByLabel(\n shapeClass: typeof Shape,\n label: string,\n): PropertyShapeData | undefined {\n if (!shapeClass.shape) return undefined;\n return getPropertyShape(shapeClass.shape, label, true);\n}\n\n/**\n * True when `a` extends `b`.\n *\n * Inheritance is read from `nodeShape.extends` (data), not from the JS prototype chain.\n * `applyLinkedShape` derives `extends` FROM the prototype chain, so for a class-backed\n * shape the two agree — but only the data form also works for a shape that has no\n * class, which is the whole point. The prototype comparison is kept as a fallback for\n * classes that are not registered as shapes at all (an abstract intermediate class).\n */\nexport function hasSuperClass(a: ShapeLike, b: ShapeLike) {\n if (!a || !b) return false;\n const aData = toNodeShapeData(a);\n const bData = toNodeShapeData(b);\n if (aData && bData) return isSubShapeOf(aData, bData);\n return typeof a === 'function' && typeof b === 'function'\n ? (a as Function).prototype instanceof (b as Function)\n : false;\n}\n\n/** True when `b` extends `a` — the mirror of {@link hasSuperClass}. */\nexport function hasSubClass(a: ShapeLike, b: ShapeLike) {\n return hasSuperClass(b, a);\n}\n\nfunction applyFnToShapeOrArray(shape, filterFn) {\n if (Array.isArray(shape)) {\n return (shapeClass) => {\n //returns true if one of the given shapes extends the shapeClass passed as argument\n return (shape as Function[]).some((s) => filterFn(s, shapeClass));\n };\n } else {\n //first argument will be the given shape class, second argument will be each stored shape class in the map\n //will filter down where the given shape extends the stored shape\n return filterFn.bind(null, shape);\n }\n}\n\nfunction filterShapeClasses(filterFn) {\n let result = [];\n nodeShapeToShapeClass.forEach((shapeClass) => {\n if (filterFn(shapeClass)) {\n result.push(shapeClass);\n }\n });\n return result;\n}\n\nexport function getLeastSpecificShapeClasses(shapes: ICoreIterable<Shape>) {\n let shapeClasses = shapes.map((shape) =>\n getShapeClass(shape.nodeShape.id),\n );\n return filterShapesToLeastSpecific(shapeClasses);\n}\n\nexport function getMostSpecificSubShapes(\n shape: typeof Shape | (typeof Shape)[],\n): (typeof Shape)[] {\n if (!Array.isArray(shape)) {\n shape = [shape];\n }\n //get the subshapes of the given shapes\n let key = shape.map((s) => s.name).join(',');\n if (subShapesCacheVersion !== registryState.registryVersion) {\n subShapesCache.clear();\n mostSpecificSubShapesCache.clear();\n subShapesCacheVersion = registryState.registryVersion;\n }\n if (!mostSpecificSubShapesCache.has(key)) {\n //get the subshapes of the given shapes\n let subShapes: (typeof Shape)[] = getSubShapesClasses(shape, key);\n //filter them down to the most specific ones (that are not extended by any other shape)\n mostSpecificSubShapesCache.set(key, filterShapesToMostSpecific(subShapes));\n }\n return mostSpecificSubShapesCache.get(key);\n}\n\n/**\n * Filters out all shapes that are extended by any other shape in the given set/array\n * @param subShapes\n */\nfunction filterShapesToMostSpecific(subShapes) {\n return subShapes.filter((subShape) => {\n return !subShapes.some((otherSubShape) => {\n return otherSubShape.prototype instanceof subShape;\n });\n });\n}\n\n/**\n * Filters out all shapes that extend any other shape in the given set/array\n * @param shapeClasses\n */\nfunction filterShapesToLeastSpecific(shapeClasses) {\n return shapeClasses.filter((shapeClass) => {\n return !shapeClasses.some((otherShapeClass) => {\n return (\n otherShapeClass !== shapeClass &&\n shapeClass.prototype instanceof otherShapeClass\n );\n });\n });\n}\n\nfunction getKey(shape: typeof Shape | (typeof Shape)[]) {\n return Array.isArray(shape)\n ? shape.map((s) => getShapeKey(s)).join(',')\n : getShapeKey(shape);\n}\n\nfunction getShapeKey(shape: typeof Shape) {\n //return a unique string for each shape\n return (\n resolveTargetClassId(shape.targetClass) ||\n shape.name + shape.prototype.constructor.toString().substring(0, 80)\n );\n}\n"]}
1
+ {"version":3,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AAU;gBAC9B,UAAU,CAAC,SAAS,YAAY,eAAe,CAChD,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,MAAM,CAAC,KAAsC;IACpD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5C,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,WAAW,CAAC,KAAmB;IACtC,uCAAuC;IACvC,OAAO,CACL,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC;QACvC,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CACrE,CAAC;AACJ,CAAC","sourcesContent":["import {type Shape, type ShapeConstructor} from '../shapes/Shape.js';\n// Namespace import, read at CALL time rather than captured at module-evaluation time.\n// `getOrCreateShapeAdapter` subclasses `Shape` at runtime, and under some import orders this\n// module finishes evaluating before `Shape.js` does — a named import captured then is\n// permanently `undefined`, and the subclass fails with \"Class extends value undefined\".\nimport * as ShapeModule from '../shapes/Shape.js';\nimport {\n getPropertyShape,\n type NodeShapeData,\n type PropertyShapeData,\n} from '../shapes/nodeShapeData.js';\nimport type {NodeShapeWire} from '../shapes/nodeShapeWire.js';\nimport type {ICoreIterable} from '../interfaces/ICoreIterable.js';\nimport type {NodeReferenceValue} from './NodeReference.js';\nimport type {ShapeCatalog} from './ShapeCatalog.js';\nimport {RegistryCache} from './registryCache.js';\n\nexport {RegistryCache};\n\nconst resolveTargetClassId = (\n targetClass?: NodeReferenceValue | null,\n): string | null => {\n if (!targetClass) return null;\n return targetClass.id ?? null;\n};\n\n/**\n * The shape registries live on `globalThis`, not in module scope.\n *\n * A module can evaluate more than once in one process, and in a built app it does: an\n * app's backend is assembled from two graphs, one loaded by the bundler from `src/` and\n * one resolved by Node to `lib/esm/`. A module-scope `Map` then exists twice — shapes\n * register into one copy and every lookup reads the other, which finds nothing.\n *\n * The symptom never mentions module identity. It is `Invalid property key: projectSlug.\n * The shape Project does not have a registered property with this name` for a property\n * that is declared correctly two files away, because validation ran on the copy the\n * decorators never reached. See docs/reports/043-module-identity-in-the-backend.md.\n *\n * Sharing the state makes duplication harmless rather than merely absent: the graphs\n * still hold two copies of this module, but only one registry. `LinkedStorage` already\n * keeps its instance counter here; this keeps the data itself.\n */\nconst shapeRegistryGlobal: any =\n typeof globalThis !== 'undefined' ? globalThis : ({} as any);\n\n/**\n * Counts DISTINCT physical copies of this module, not evaluations of it.\n *\n * The difference matters. A bare `count++` here is incremented by Vite's HMR every time\n * the module is re-evaluated in the same process, against the same `globalThis` — so a\n * developer who edits a file a few times sees a count of 4 and goes hunting a\n * dual-resolution problem that does not exist. Recording a token per copy and counting\n * the tokens survives re-evaluation: HMR replaces the module, and its token with it.\n */\nconst copyToken: object = {};\nconst copies: Set<object> = (shapeRegistryGlobal.__linkedShapeRegistryCopies ??= new Set());\ncopies.add(copyToken);\n\n/**\n * More than one copy of this module means shapes register into one registry and are\n * looked up in another, and the resulting failures never mention module identity — they\n * say a declared property is not declared, or that a pinned shape has no pin.\n *\n * Reported rather than thrown. A throw from a library module at import time breaks\n * tooling that legitimately loads a module twice, and the shared state above means a\n * second copy is survivable: it is a correctness hazard for anything holding a class\n * reference, not an immediate failure. So this says so, once, as loudly as a log can.\n */\nif (copies.size > 1) {\n console.error(\n `[linked] ${copies.size} copies of @_linked/core's shape registry have loaded in ` +\n `this process. They share one registry, so lookups still resolve — but each copy ` +\n `has its own \\`Shape\\` base class, so \\`instanceof\\` comparisons across them are ` +\n `false and adapters built by one copy do not satisfy the other. This is a module ` +\n `resolution problem: part of the app is reaching this package by a path that ` +\n `resolves to its source and part by one that resolves to its build output.`,\n );\n}\n\n/**\n * One shared container, created by whichever copy evaluates first.\n *\n * `registryVersion` belongs here too: every derived cache in this module is keyed on it,\n * so a version that is not shared would let one copy's writes leave another copy's caches\n * looking valid. The caches themselves stay per-copy — they are rebuilt whenever the\n * shared version moves past them.\n */\nconst registryState: {\n nodeShapeToShapeClass: Map<string, typeof Shape>;\n nodeShapeRegistry: Map<string, NodeShapeData>;\n shapeAdapters: Map<string, typeof Shape>;\n registryVersion: number;\n /**\n * The catalog `withShapeCatalog` made current, or undefined for the global registry.\n * Shared like the rest, so a scope opened by one copy of this module is seen by another.\n */\n activeCatalog: ShapeCatalog | undefined;\n} = (shapeRegistryGlobal.__linkedShapeRegistry ??= {\n nodeShapeToShapeClass: new Map(),\n nodeShapeRegistry: new Map(),\n shapeAdapters: new Map(),\n registryVersion: 0,\n activeCatalog: undefined,\n});\n// A container created by an older copy has no slot yet; give it one so every read below\n// sees the same object layout.\nif (!('activeCatalog' in (registryState as object))) registryState.activeCatalog = undefined;\n\n/** How many distinct copies of this module are loaded. One is expected. */\nexport function getShapeRegistryInstanceCount(): number {\n return copies.size;\n}\n\n// ---------------------------------------------------------------------------\n// The active shape catalog\n// ---------------------------------------------------------------------------\n\n/**\n * Run `fn` with `catalog` as the shapes every registry accessor reads; `undefined` means\n * the global registry (explicitly — it does not inherit an outer catalog).\n *\n * Synchronous on purpose: it works the same in the browser and in Node, with no\n * AsyncLocalStorage. Scopes nest, the previous catalog is restored in `finally`, and fn's\n * value is returned unchanged. A promise returned by fn is not awaited, so its\n * continuation runs outside the scope. That is why builders and IRs capture their catalog\n * and every place that picks one up later re-enters it (see docs/architecture/runtime-instances.md).\n */\nexport function withShapeCatalog<T>(catalog: ShapeCatalog | undefined, fn: () => T): T {\n const previous = registryState.activeCatalog;\n if (previous === catalog) return fn();\n registryState.activeCatalog = catalog;\n try {\n const result = fn();\n if (result instanceof Promise) warnPromiseInScope();\n return result;\n } finally {\n registryState.activeCatalog = previous;\n }\n}\n\n/**\n * Run `fn` with no catalog active, without the promise warning: for core's own calls into a\n * dataset, whose asynchronous continuation is meant to run outside any catalog. @internal\n */\nexport function outsideShapeCatalog<T>(fn: () => T): T {\n const previous = registryState.activeCatalog;\n if (previous === undefined) return fn();\n registryState.activeCatalog = undefined;\n try {\n return fn();\n } finally {\n registryState.activeCatalog = previous;\n }\n}\n\nlet warnedPromiseInScope = false;\n\n/**\n * A scope ends when `fn` returns, so the continuation of a promise `fn` returns runs outside\n * it. Said once, outside production. A builder (a thenable, not a Promise) is the intended\n * return value: it captured the catalog and re-enters it.\n */\nfunction warnPromiseInScope(): void {\n if (warnedPromiseInScope) return;\n const env = (globalThis as {process?: {env?: Record<string, string | undefined>}}).process?.env;\n if (env?.NODE_ENV === 'production') return;\n warnedPromiseInScope = true;\n console.warn(\n '[linked] withShapeCatalog(catalog, fn): fn returned a promise. The scope ended when fn ' +\n 'returned, so code after its first await runs outside the catalog. Build the query inside ' +\n 'the scope and await it outside — a builder keeps its catalog.',\n );\n}\n\n/** The catalog of the current `withShapeCatalog` scope, or undefined for the global registry. */\nexport function getActiveShapeCatalog(): ShapeCatalog | undefined {\n return registryState.activeCatalog;\n}\n\n/**\n * The catalog a builder, a FieldSet or an IR captured — undefined means the global registry.\n * Reads the object's `catalog` field, which builders keep as a getter and IRs as a\n * non-enumerable property, so neither appears in `toJSON` or a JSON round trip.\n */\nexport function catalogOf(queryOrIr: object | null | undefined): ShapeCatalog | undefined {\n return (queryOrIr as {catalog?: ShapeCatalog} | null | undefined)?.catalog;\n}\n\n/**\n * Record `catalog` on an IR object as a non-enumerable `catalog` field, so the code that\n * compiles it later (often after an `await`) re-enters the catalog it was lowered in.\n * Nothing is written for the global registry: an IR without the field compiles globally.\n * @internal\n */\nexport function attachCatalog<T extends object>(\n ir: T,\n catalog: ShapeCatalog | undefined = registryState.activeCatalog,\n): T {\n if (catalog !== undefined) {\n Object.defineProperty(ir, 'catalog', {\n value: catalog,\n enumerable: false,\n configurable: true,\n writable: true,\n });\n }\n return ir;\n}\n\n/**\n * Process-unique ids for catalogs, for live-query template keys. On `globalThis`, like the\n * registry, so two copies of core give one catalog the same id.\n */\nconst keyState: {keys: WeakMap<object, number>; next: number} =\n (shapeRegistryGlobal.__linkedShapeCatalogKeys ??= {keys: new WeakMap(), next: 1});\n\n/** 0 for the global registry, else a process-unique id for the catalog. */\nexport function shapeCatalogKey(catalog: ShapeCatalog | undefined): number {\n if (catalog === undefined) return 0;\n let key = keyState.keys.get(catalog);\n if (key === undefined) {\n key = keyState.next++;\n keyState.keys.set(catalog, key);\n }\n return key;\n}\n\n/** The catalog of an adapter class a catalog built, keyed on the class. */\nconst adapterCatalogs = new WeakMap<Function, ShapeCatalog>();\n\n/**\n * The catalog a builder made from `shape` captures.\n *\n * Inside a scope: the active catalog when the root is an IRI (`shape` undefined) or a\n * shape the catalog holds; otherwise none. A class the active catalog does not hold is\n * authored code (CN's own shapes, built by CN code while a project scope is active) and\n * must lower against the global registry. Outside a scope: the catalog that built the\n * adapter class, if it is one, else none.\n * @internal\n */\nexport function captureCatalog(\n shape?: {shape?: {id?: string}} | Function | null,\n): ShapeCatalog | undefined {\n const active = registryState.activeCatalog;\n if (shape === undefined || shape === null) return active;\n if (active !== undefined) {\n const id = (shape as {shape?: {id?: string}}).shape?.id;\n if (id && active.has(id)) return active;\n }\n return typeof shape === 'function' ? adapterCatalogs.get(shape) : undefined;\n}\n\n/**\n * Throw when a registry write is attempted inside a catalog scope. A catalog is\n * immutable, and a write meant for it would land in the global registry instead.\n * @internal\n */\nexport function assertNoActiveCatalog(): void {\n if (registryState.activeCatalog !== undefined) {\n throw new Error(\n 'Cannot register shapes while a ShapeCatalog is active. Register outside ' +\n 'withShapeCatalog, or build a new catalog with ShapeCatalog.from().',\n );\n }\n}\n\n/** What a catalog holds, as the accessors below read it. Plain fields: any copy can read them. */\ntype CatalogContents = {\n readonly nodeShapes: ReadonlyMap<string, NodeShapeData>;\n readonly shapeClasses: ReadonlyMap<string, typeof Shape>;\n};\n\nfunction contentsOf(catalog: ShapeCatalog): CatalogContents {\n return catalog as unknown as CatalogContents;\n}\n\nconst subShapesCache = new RegistryCache<string, (typeof Shape)[]>();\nconst mostSpecificSubShapesCache = new RegistryCache<string, (typeof Shape)[]>();\nconst nodeShapeToShapeClass = registryState.nodeShapeToShapeClass;\nconst warnedDuplicateBases = new Set<string>();\n\n/**\n * The PRIMARY shape registry: node-shape IRI → its metadata.\n *\n * Every shape is here — those declared by a `@linkedShape` class and those known only\n * as data (a project-authored shape read from the graph). `nodeShapeToShapeClass` above\n * is the SECONDARY registry, holding only the shapes that have a TypeScript class, and\n * exists for the few callers that genuinely need a class (a `ShapeProvider` lookup, a\n * typed accessor). Query lowering, predicate resolution and containment all read\n * metadata, so they use this map and work identically for both kinds of shape.\n */\nconst nodeShapeRegistry = registryState.nodeShapeRegistry;\n\n/**\n * The shapes the accessors read: the active catalog's (its shapes plus core's built-ins),\n * else the global registry. One shared read and a null check on the global path.\n */\nfunction activeNodeShapes(): ReadonlyMap<string, NodeShapeData> {\n const catalog = registryState.activeCatalog;\n return catalog === undefined ? nodeShapeRegistry : contentsOf(catalog).nodeShapes;\n}\n\n/** The authored classes the accessors read: the catalog's built-ins, else every registered class. */\nfunction activeShapeClasses(): ReadonlyMap<string, typeof Shape> {\n const catalog = registryState.activeCatalog;\n return catalog === undefined ? nodeShapeToShapeClass : contentsOf(catalog).shapeClasses;\n}\n\n/**\n * The current registration version — a monotonic counter, bumped on every write.\n *\n * Every derived cache in this module, and in `irToAlgebra`, is keyed on it. It replaces\n * two earlier invalidation strategies that were both unsound: a `setTimeout(…, 0)` cache\n * clear (which missed anything registered later in the same session) and comparing the\n * registry SIZE (which silently reuses a stale cache when a registration and a removal\n * coincide, or when a shape is re-registered in place).\n *\n * It lives on the shared state, not in module scope: a cache keyed on a per-copy version\n * would look valid after another copy had written.\n */\nexport function getRegistryVersion(): number {\n return registryState.registryVersion;\n}\n\n/** Reverse index parentIri → direct child IRIs, rebuilt when the registry changes. */\nconst childIndex = new RegistryCache<string, string[]>((index) => {\n activeNodeShapes().forEach((shape, id) => {\n const parent = shape.extends?.id;\n if (!parent) return;\n const siblings = index.get(parent);\n if (siblings) siblings.push(id);\n else index.set(parent, [id]);\n });\n});\n\nfunction getChildIndex(): Map<string, string[]> {\n return childIndex.get();\n}\n\n// Every derived cache is a RegistryCache keyed on this version, so bumping it is the\n// whole invalidation.\nfunction invalidateRegistryCaches() {\n registryState.registryVersion++;\n}\n\n/** Drop the adapter for a shape whose metadata was replaced. */\nfunction invalidateShapeAdapter(id: string) {\n shapeAdapters.delete(id);\n}\n\n/**\n * Register a shape known only as data — no TypeScript class is created.\n *\n * This is the return leg of the round trip: `@linkedShape` is class → metadata,\n * `syncShapes` is metadata → RDF, and this is RDF → metadata. Idempotent: re-registering\n * the same IRI replaces the metadata (a shape edited in the builder), which is why cache\n * invalidation cannot be keyed on registry size.\n */\nexport function registerNodeShape(nodeShape: NodeShapeData): void {\n assertNoActiveCatalog();\n if (!nodeShape?.id) return;\n nodeShapeRegistry.set(nodeShape.id, nodeShape);\n invalidateShapeAdapter(nodeShape.id);\n invalidateRegistryCaches();\n}\n\n/** The metadata for a node-shape IRI, whether or not it has a TypeScript class. */\nexport function getNodeShape(\n nodeShape: NodeReferenceValue | {id: string} | string,\n): NodeShapeData | undefined {\n const id = typeof nodeShape === 'string' ? nodeShape : nodeShape?.id;\n if (!id) return undefined;\n return activeNodeShapes().get(id);\n}\n\n/**\n * Every registered shape's metadata, keyed by node-shape IRI. Inside a catalog scope:\n * exactly the catalog's shapes plus core's built-ins.\n */\nexport function getAllNodeShapes(): ReadonlyMap<string, NodeShapeData> {\n return activeNodeShapes();\n}\n\n/**\n * Lazily-built constructors for shapes that exist only as data.\n *\n * The builder entry points (`QueryBuilder`, `CreateBuilder`, `UpdateBuilder`,\n * `DeleteBuilder` via `resolveShape`) take a `ShapeConstructor` and instantiate result\n * proxies from it, so they need *a* class. Rather than have every caller hand-roll one —\n * which is what `create-now-js`'s `registerRuntimeShape` used to do, losing `extends` and\n * every value constraint on the way — core derives one on demand from the registered\n * metadata and caches it.\n *\n * These adapters are deliberately NOT in `nodeShapeToShapeClass`: `getShapeClass` keeps\n * telling the truth about which shapes have a real, authored class. An adapter carries\n * the metadata verbatim, so nothing is lost, and inheritance is read from\n * `nodeShape.extends` (not from the adapter's prototype, which is always `Shape`).\n */\nconst shapeAdapters = registryState.shapeAdapters;\n\n/**\n * A constructor for a shape known only as data, created on first use.\n *\n * Returns undefined when the IRI is not registered at all. Prefer `getShapeClass` when\n * you specifically need an authored class; use this when you need *something*\n * constructor-shaped to drive the query builders.\n */\n/** Adapters built inside a catalog: one map per catalog, keyed by IRI. */\nconst catalogAdapters = new WeakMap<object, Map<string, typeof Shape>>();\n\nexport function getOrCreateShapeAdapter(\n nodeShape: NodeShapeData | string,\n): typeof Shape | undefined {\n const catalog = registryState.activeCatalog;\n const shapes = catalog === undefined ? nodeShapeRegistry : contentsOf(catalog).nodeShapes;\n const data = typeof nodeShape === 'string' ? shapes.get(nodeShape) : nodeShape;\n if (!data?.id) return undefined;\n\n const authored = (\n catalog === undefined ? nodeShapeToShapeClass : contentsOf(catalog).shapeClasses\n ).get(data.id);\n if (authored) return authored;\n\n let adapters: Map<string, typeof Shape> | undefined = shapeAdapters;\n if (catalog !== undefined) {\n adapters = catalogAdapters.get(catalog);\n if (!adapters) catalogAdapters.set(catalog, (adapters = new Map()));\n }\n const cached = adapters.get(data.id);\n // Re-registering a shape replaces its metadata, so an adapter built from the old\n // object must not be reused.\n if (cached && cached.shape === data) return cached;\n\n class RuntimeShape extends ShapeModule.Shape {\n static shape = data as NodeShapeData;\n static targetClass = (data as NodeShapeData).targetClass ?? null;\n }\n Object.defineProperty(RuntimeShape, 'name', {\n value: (data as NodeShapeData).label || 'RuntimeShape',\n });\n adapters.set(data.id, RuntimeShape);\n if (catalog !== undefined) adapterCatalogs.set(RuntimeShape, catalog);\n return RuntimeShape;\n}\n\n/** Anything that can identify a shape: its metadata, its class, or its IRI. */\nexport type ShapeLike = NodeShapeData | typeof Shape | Function | string;\n\n/** Resolve a ShapeLike to node-shape metadata, or undefined if it isn't a shape. */\nfunction toNodeShapeData(shape: ShapeLike): NodeShapeData | undefined {\n if (!shape) return undefined;\n const shapes = activeNodeShapes();\n if (typeof shape === 'string') return shapes.get(shape);\n const asData = shape as NodeShapeData;\n // NodeShapeData is a plain object with an id; a Shape class is a function.\n if (typeof shape === 'object' && typeof asData.id === 'string') {\n return shapes.get(asData.id) ?? asData;\n }\n const asClass = shape as typeof Shape;\n const shapeData = asClass?.shape;\n if (shapeData?.id) return shapes.get(shapeData.id) ?? shapeData;\n return undefined;\n}\n\nconst warnedUnresolvedExtends = new Set<string>();\n\n/**\n * Every shape the given shape extends, most specific first.\n *\n * THE canonical inheritance walk — `getPropertyShapes(shape, true)` delegates to it, so\n * there is exactly one answer to \"what does this shape extend\". Two earlier walks\n * disagreed (one over the prototype chain, one over `extends`) and that divergence, not\n * either strategy, was the bug: `selectAll` listed labels from one and resolved them\n * through the other, so an inherited property became unresolvable and the query proxy\n * threw.\n *\n * Strategy is chosen by what is available:\n *\n * - **A class-backed shape walks its prototype chain.** This is authoritative and\n * includes the framework `Shape` root, whose own property shapes (`label`, `type`) are\n * genuinely inherited. `applyLinkedShape` deliberately does NOT record `extends` for\n * that root — it is not a domain shape and must not appear as an `extends` triple in\n * materialized SHACL — so the data alone cannot see it.\n * - **A shape known only as data walks `extends` through the registry.** This is what\n * makes inheritance work for a project-authored shape with no class, which the\n * prototype chain cannot express.\n *\n * `extends` is a REFERENCE, so a parent that was never registered ends the walk. The\n * prototype chain has no such failure mode, so it warns once per shape rather than\n * throwing — this runs on read paths.\n */\nexport function getSuperShapes(shape: ShapeLike): NodeShapeData[] {\n const start = toNodeShapeData(shape);\n const chain: NodeShapeData[] = [];\n if (!start) return chain;\n\n // Class-backed: the prototype chain is the authority.\n const shapes = activeNodeShapes();\n const startClass = activeShapeClasses().get(start.id);\n if (startClass) {\n let current: typeof Shape | undefined = startClass;\n while (current) {\n const parent = Object.getPrototypeOf(current) as typeof Shape | undefined;\n if (!parent?.shape) break;\n chain.push(parent.shape);\n if ((parent as unknown) === (ShapeModule.Shape as unknown)) break;\n current = parent;\n }\n return chain;\n }\n\n const seen = new Set<string>([start.id]);\n let current: NodeShapeData | undefined = start;\n while (current?.extends?.id) {\n const parentId = current.extends.id;\n if (seen.has(parentId)) break; // cycle guard — malformed data must not hang a read\n seen.add(parentId);\n const parent = shapes.get(parentId);\n if (!parent) {\n if (!warnedUnresolvedExtends.has(current.id)) {\n warnedUnresolvedExtends.add(current.id);\n console.warn(\n `[linked] Shape '${current.id}' extends '${parentId}', which is not registered. ` +\n `Inherited properties from it are unavailable. Register the parent shape first ` +\n `(import its module, or register its metadata before the child).`,\n );\n }\n break;\n }\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\n/** Every shape that extends the given shape, transitively. Most specific last. */\nexport function getSubShapes(shape: ShapeLike): NodeShapeData[] {\n const start = toNodeShapeData(shape);\n if (!start) return [];\n const index = getChildIndex();\n const shapes = activeNodeShapes();\n const out: NodeShapeData[] = [];\n const seen = new Set<string>([start.id]);\n const queue = [start.id];\n while (queue.length) {\n const current = queue.shift()!;\n for (const childId of index.get(current) ?? []) {\n if (seen.has(childId)) continue;\n seen.add(childId);\n const child = shapes.get(childId);\n if (child) {\n out.push(child);\n queue.push(childId);\n }\n }\n }\n return out;\n}\n\n/** True when `a` extends `b` (strictly — a shape is not a sub-shape of itself). */\nexport function isSubShapeOf(a: ShapeLike, b: ShapeLike): boolean {\n const target = toNodeShapeData(b);\n if (!target) return false;\n return getSuperShapes(a).some((superShape) => superShape.id === target.id);\n}\n\n/**\n * The fields of a shape the targetClass lookups read. Both `NodeShapeData` and its wire\n * form satisfy it, so a caller holding a shape catalog never has to convert it first.\n */\ntype ShapeHeader = Pick<NodeShapeData, 'id' | 'targetClass' | 'extends'>;\n\n/**\n * Every shape `shape` extends, most specific first — resolving each parent in `local`\n * before the registry.\n *\n * `local` is a caller's own set of shapes (a project's catalog), which may hold shapes the\n * registry has never seen, or newer versions of ones it has. The catalog is the authority\n * for what it holds; once the chain leaves it, the registry knows the rest.\n */\nfunction superShapesWithin(\n shape: ShapeHeader,\n local?: ReadonlyMap<string, ShapeHeader>,\n): ShapeHeader[] {\n if (!local) return getSuperShapes(shape as NodeShapeData);\n const chain: ShapeHeader[] = [];\n const seen = new Set<string>([shape.id]);\n let current: ShapeHeader = shape;\n while (current.extends?.id) {\n const parentId = current.extends.id;\n if (seen.has(parentId)) break; // cycle guard — malformed data must not hang a read\n seen.add(parentId);\n const parent = local.get(parentId);\n if (!parent) {\n const registered = activeNodeShapes().get(parentId);\n if (registered) chain.push(registered, ...getSuperShapes(registered));\n break;\n }\n chain.push(parent);\n current = parent;\n }\n return chain;\n}\n\nfunction indexShapes<S extends ShapeHeader>(shapes: Iterable<S>): Map<string, S> {\n const index = new Map<string, S>();\n for (const shape of shapes) if (shape?.id) index.set(shape.id, shape);\n return index;\n}\n\nfunction targetClassIdWithin(\n shape: ShapeLike | NodeShapeWire | {id: string},\n local?: ReadonlyMap<string, ShapeHeader>,\n): string | undefined {\n if (!shape) return undefined;\n if (typeof shape === 'function') {\n // A class's static targetClass is inherited through the prototype chain for free.\n const asClass = shape as typeof Shape;\n if (asClass.targetClass?.id) return asClass.targetClass.id;\n if (!asClass.shape?.id) return undefined;\n shape = asClass.shape;\n }\n const id = typeof shape === 'string' ? shape : shape.id;\n if (!id) return undefined;\n const given = typeof shape === 'string' ? undefined : (shape as ShapeHeader);\n const shapes = activeNodeShapes();\n const own =\n given?.targetClass?.id ??\n local?.get(id)?.targetClass?.id ??\n getShapeClass(id)?.targetClass?.id ??\n shapes.get(id)?.targetClass?.id;\n if (own) return own;\n // A data-only shape's targetClass is not inherited for free, so walk `extends`.\n const start = local?.get(id) ?? (given?.extends ? given : shapes.get(id) ?? given);\n if (!start) return undefined;\n return superShapesWithin(start, local).find((s) => s.targetClass?.id)?.targetClass?.id;\n}\n\n/**\n * The class a shape's instances are typed with: its own `targetClass`, else the first one\n * found through what it extends. `undefined` when there is none anywhere in the chain.\n *\n * Accepts a shape IRI, a `{id}` reference, a shape's metadata (data or wire form) or a shape\n * class. Pass `shapes` to resolve the shape — and what it extends — in that set before the\n * registry; a project's catalog may hold shapes the registry does not.\n */\nexport function getTargetClassId(\n shape: ShapeLike | NodeShapeWire | {id: string},\n shapes?: Iterable<NodeShapeData | NodeShapeWire>,\n): string | undefined {\n return targetClassIdWithin(shape, shapes ? indexShapes(shapes) : undefined);\n}\n\n/**\n * The least specific candidates (the roots), by id. A candidate that extends another\n * candidate (directly or further up) is dropped: a relation to `Person` with `Person` and\n * `Employee extends Person` both targeting it means `Person` — a relation never upgrades\n * itself to a sub-shape; declare `sh:node` to ask for one. What remains are unrelated roots\n * the data does not choose between; they sort by id alone — never by depth or by\n * registration or catalog order — so the choice is stable and visibly arbitrary. If that\n * would drop every candidate (an `extends` cycle), all of them are kept, by id.\n */\nfunction leastSpecific<S extends ShapeHeader>(\n candidates: S[],\n local?: ReadonlyMap<string, ShapeHeader>,\n): S[] {\n const ids = new Set(candidates.map((c) => c.id));\n const byId = (a: S, b: S) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);\n const roots = candidates.filter(\n (candidate) => !superShapesWithin(candidate, local).some((parent) => ids.has(parent.id)),\n );\n // An `extends` cycle makes each member extend another, so the filter can leave nothing.\n // Malformed data must not turn a relation into \"no shape\" silently: keep every candidate\n // instead, by id, and let the caller's ambiguity handling (warn) apply.\n return (roots.length ? roots : [...candidates]).sort(byId);\n}\n\n/** targetClass IRI → registered shapes targeting it, ordered. Rebuilt when the registry changes. */\nconst targetClassIndex = new RegistryCache<string, NodeShapeData[]>((index) => {\n activeNodeShapes().forEach((shape) => {\n const classId = targetClassIdWithin(shape);\n if (!classId) return;\n const shapes = index.get(classId);\n if (shapes) shapes.push(shape);\n else index.set(classId, [shape]);\n });\n index.forEach((shapes, classId) => index.set(classId, leastSpecific(shapes)));\n});\n\nfunction getTargetClassIndex(): Map<string, NodeShapeData[]> {\n return targetClassIndex.get();\n}\n\n/**\n * The least specific shapes whose effective targetClass (own, or inherited through\n * `extends`) is exactly `classIri`, sorted by id. A matching shape that extends another\n * match is left out, so one entry means the class has one root shape and more than one\n * means unrelated roots compete for it. Sub-shapes are never chosen for a class alone.\n *\n * With no `shapes`, the candidates are the registered shapes. Pass `shapes` to choose among\n * that set only — the registry also holds compiled framework shapes, and a project's\n * `schema:Person` relation should resolve to the project's shape, not to one a framework\n * package happens to register for the same class. Inheritance is still resolved through\n * the registry when a candidate extends a shape outside the set.\n */\nexport function getShapesForTargetClass(classIri: string): NodeShapeData[];\nexport function getShapesForTargetClass<S extends NodeShapeData | NodeShapeWire>(\n classIri: string,\n shapes: Iterable<S>,\n): S[];\nexport function getShapesForTargetClass(\n classIri: string,\n shapes?: Iterable<NodeShapeData | NodeShapeWire>,\n): (NodeShapeData | NodeShapeWire)[] {\n if (!classIri) return [];\n if (!shapes) return [...(getTargetClassIndex().get(classIri) ?? [])];\n const local = indexShapes(shapes);\n const candidates = [...local.values()].filter(\n (shape) => targetClassIdWithin(shape, local) === classIri,\n );\n return leastSpecific(candidates, local);\n}\n\nexport function addNodeShapeToShapeClass(\n nodeShape: NodeShapeData,\n shapeClass: typeof Shape,\n) {\n assertNoActiveCatalog();\n if (!nodeShape?.id) {\n return;\n }\n // Dev guardrail for IDENTITY duplication. Shape URIs embed `constructor.name`\n // (getNodeShapeUri). If a bundler emits >1 copy of a framework package, the copies\n // are renamed `Person`→`Person2`/`3`, so a mangled URI registers alongside the clean\n // one — the exact failure that silently breaks cross-runtime shape lookup (`Person3`\n // on the FE ≠ `Person` on the backend). Warn ONCE per base so a build-config\n // regression (e.g. a dropped `optimizeDeps.exclude`) surfaces loudly instead of\n // no-op'ing a query at forward time.\n //\n // This used to be dev-only, on the reasoning that production is minified and\n // the check would false-fire. It does not: full minification renames a class\n // to something like `za`, so `base === id` and nothing fires. What DOES fire\n // is the case worth catching — a bundler appending a digit to disambiguate\n // `BackendAPIStore` from the ontology term of the same name, which is exactly\n // the collision that breaks shape lookup, and it only happens in a production\n // build. Suppressing the warning there hid it from the one place it occurs.\n {\n const id = nodeShape.id;\n const base = id.replace(/\\d+$/, '');\n const existing = nodeShapeToShapeClass.get(base);\n if (base !== id && existing && !warnedDuplicateBases.has(base)) {\n // A real duplicate is the SAME logical shape (same targetClass) registered under\n // a mangled name; a legit digit-suffixed sibling (e.g. `OAuth2` vs `OAuth`)\n // targets a different class. Warn only when they match (or targetClass is absent).\n const newTarget = (shapeClass as any).targetClass?.id;\n const existingTarget = (existing as any).targetClass?.id;\n if (!newTarget || !existingTarget || newTarget === existingTarget) {\n warnedDuplicateBases.add(base);\n console.warn(\n `[linked] Shape identity duplication: '${id}' registered alongside '${base}'. ` +\n `A bundler emitted >1 copy of this package — cross-runtime shape lookup will ` +\n `break. Check the cli vite-config single-instance levers (optimizeDeps.exclude ` +\n `/ ssr.noExternal).`,\n );\n }\n }\n }\n nodeShapeToShapeClass.set(nodeShape.id, shapeClass);\n // The class-backed shape goes into the primary registry too, so metadata consumers\n // see one map regardless of how a shape was declared. This also bumps the version,\n // which invalidates every derived cache immediately rather than on a next-tick timer.\n registerNodeShape(nodeShape);\n}\n\n/**\n * The constructor for a shape IRI — an authored class if there is one, otherwise one\n * derived from the registered metadata.\n *\n * This is what the query layer wants in every case, and `getShapeClass` alone is not:\n * it answers `undefined` for a shape that exists only as data, which is every shape\n * authored in a project. Five call sites used to spell this fallback out by hand, in\n * four different ways.\n *\n * `getShapeClass` is NOT consulted first. `getOrCreateShapeAdapter` already returns the\n * authored class when one exists, and a class-backed shape is always mirrored into the\n * primary registry, so the adapter path cannot miss a shape `getShapeClass` would find.\n */\nexport function resolveShapeConstructor(\n nodeShape: NodeReferenceValue | {id: string} | string,\n): ShapeConstructor | undefined {\n const id = typeof nodeShape === 'string' ? nodeShape : nodeShape?.id;\n if (!id) return undefined;\n // SAFETY: both paths yield a concrete subclass of Shape with a static .shape —\n // i.e. a ShapeConstructor. Same cast getShapeClass documents.\n return getOrCreateShapeAdapter(id) as unknown as ShapeConstructor | undefined;\n}\n\n/**\n * The constructor the query layer resolves an IRI to. In the global registry it is\n * `getShapeClass` (authored classes only, as always). Inside a catalog, where every shape\n * but core's built-ins is data, it is the catalog's constructor for any shape it holds.\n * @internal\n */\nexport function getQueryShapeClass(\n nodeShape: NodeReferenceValue | {id: string} | string,\n): ShapeConstructor | undefined {\n return registryState.activeCatalog === undefined\n ? getShapeClass(nodeShape)\n : resolveShapeConstructor(nodeShape);\n}\n\nexport function getShapeClass(\n nodeShape: NodeReferenceValue | {id: string} | string,\n): ShapeConstructor | undefined {\n const id = typeof nodeShape === 'string' ? nodeShape : nodeShape?.id;\n if (!id) {\n return undefined;\n }\n // SAFETY: The map stores `typeof Shape` (abstract), but registered shapes are always\n // concrete subclasses with a constructor and static .shape — i.e. ShapeConstructor.\n return activeShapeClasses().get(id) as unknown as ShapeConstructor | undefined;\n}\n\n/** The class registered globally for an IRI, whatever catalog is active. @internal */\nexport function getRegisteredShapeClass(id: string): typeof Shape | undefined {\n return nodeShapeToShapeClass.get(id);\n}\n\n/**\n * Returns all registered shape classes (keyed by NodeShape URI). Inside a catalog scope:\n * core's built-in classes only — a catalog holds no other class.\n */\nexport function getAllShapeClasses(): Map<string, typeof Shape> {\n return activeShapeClasses() as Map<string, typeof Shape>;\n}\n\n/**\n * Returns all the sub shapes of the given shape\n * That is all the shapes that extend this shape\n * @param shape\n */\n\nexport function getSubShapesClasses(\n shape: typeof Shape | (typeof Shape)[],\n _internalKey?: string,\n): (typeof Shape)[] {\n let key = _internalKey || getKey(shape);\n const cache = subShapesCache.get();\n if (!cache.has(key)) {\n //apply the hasSuperclass function to the shape\n let filterFunction = applyFnToShapeOrArray(shape, hasSubClass);\n //filter and then sort the results based on their inheritance (most specific classes first, so we use hasSuperClass for the sorting)\n cache.set(\n key,\n filterShapeClasses(filterFunction).sort((a, b) => {\n return hasSubClass(a, b) ? 1 : -1;\n }),\n );\n }\n //return a copy of the array to prevent it from being modified\n return [...cache.get(key)!];\n}\n\n/**\n * Returns all the superclasses of the given shape\n * That is all the shapes that it extends.\n * Results are sorted from most specific to least specific\n * @param shape\n */\nexport function getSuperShapesClasses(\n shape: typeof Shape | (typeof Shape)[],\n): (typeof Shape)[] {\n //apply the hasSuperclass function to the shape\n let filterFunction = applyFnToShapeOrArray(shape, hasSuperClass);\n //filter and then sort the results based on their inheritance\n return filterShapeClasses(filterFunction).sort((a, b) => {\n return hasSubClass(a, b) ? 1 : -1;\n });\n}\n\nexport function getPropertyShapeByLabel(\n shapeClass: typeof Shape,\n label: string,\n): PropertyShapeData | undefined {\n if (!shapeClass.shape) return undefined;\n return getPropertyShape(shapeClass.shape, label, true);\n}\n\n/**\n * True when `a` extends `b`.\n *\n * Inheritance is read from `nodeShape.extends` (data), not from the JS prototype chain.\n * `applyLinkedShape` derives `extends` FROM the prototype chain, so for a class-backed\n * shape the two agree — but only the data form also works for a shape that has no\n * class, which is the whole point. The prototype comparison is kept as a fallback for\n * classes that are not registered as shapes at all (an abstract intermediate class).\n */\nexport function hasSuperClass(a: ShapeLike, b: ShapeLike) {\n if (!a || !b) return false;\n const aData = toNodeShapeData(a);\n const bData = toNodeShapeData(b);\n if (aData && bData) return isSubShapeOf(aData, bData);\n return typeof a === 'function' && typeof b === 'function'\n ? (a as Function).prototype instanceof (b as Function)\n : false;\n}\n\n/** True when `b` extends `a` — the mirror of {@link hasSuperClass}. */\nexport function hasSubClass(a: ShapeLike, b: ShapeLike) {\n return hasSuperClass(b, a);\n}\n\nfunction applyFnToShapeOrArray(shape, filterFn) {\n if (Array.isArray(shape)) {\n return (shapeClass) => {\n //returns true if one of the given shapes extends the shapeClass passed as argument\n return (shape as Function[]).some((s) => filterFn(s, shapeClass));\n };\n } else {\n //first argument will be the given shape class, second argument will be each stored shape class in the map\n //will filter down where the given shape extends the stored shape\n return filterFn.bind(null, shape);\n }\n}\n\nfunction filterShapeClasses(filterFn) {\n let result = [];\n activeShapeClasses().forEach((shapeClass) => {\n if (filterFn(shapeClass)) {\n result.push(shapeClass);\n }\n });\n return result;\n}\n\nexport function getLeastSpecificShapeClasses(shapes: ICoreIterable<Shape>) {\n let shapeClasses = shapes.map((shape) =>\n getQueryShapeClass(shape.nodeShape.id),\n );\n return filterShapesToLeastSpecific(shapeClasses);\n}\n\nexport function getMostSpecificSubShapes(\n shape: typeof Shape | (typeof Shape)[],\n): (typeof Shape)[] {\n if (!Array.isArray(shape)) {\n shape = [shape];\n }\n //get the subshapes of the given shapes\n let key = shape.map((s) => s.name).join(',');\n const cache = mostSpecificSubShapesCache.get();\n if (!cache.has(key)) {\n //get the subshapes of the given shapes\n let subShapes: (typeof Shape)[] = getSubShapesClasses(shape, key);\n //filter them down to the most specific ones (that are not extended by any other shape)\n cache.set(key, filterShapesToMostSpecific(subShapes));\n }\n return cache.get(key)!;\n}\n\n/**\n * Filters out all shapes that are extended by any other shape in the given set/array\n * @param subShapes\n */\nfunction filterShapesToMostSpecific(subShapes) {\n return subShapes.filter((subShape) => {\n return !subShapes.some((otherSubShape) => {\n return otherSubShape.prototype instanceof subShape;\n });\n });\n}\n\n/**\n * Filters out all shapes that extend any other shape in the given set/array\n * @param shapeClasses\n */\nfunction filterShapesToLeastSpecific(shapeClasses) {\n return shapeClasses.filter((shapeClass) => {\n return !shapeClasses.some((otherShapeClass) => {\n return (\n otherShapeClass !== shapeClass &&\n shapeClass.prototype instanceof otherShapeClass\n );\n });\n });\n}\n\nfunction getKey(shape: typeof Shape | (typeof Shape)[]) {\n return Array.isArray(shape)\n ? shape.map((s) => getShapeKey(s)).join(',')\n : getShapeKey(shape);\n}\n\nfunction getShapeKey(shape: typeof Shape) {\n //return a unique string for each shape\n return (\n resolveTargetClassId(shape.targetClass) ||\n shape.name + shape.prototype.constructor.toString().substring(0, 80)\n );\n}\n"]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Error identity that survives a second copy of the module that defines the error.
3
+ *
4
+ * `err instanceof RemoteDatasetError` is false when the error was thrown by one copy of
5
+ * `@_linked/server` and the class was imported from another: each copy has its own class.
6
+ * A branded class instead carries a brand, `Symbol.for('<pkg>:<ClassName>')`, on its
7
+ * prototype. Every copy of the class carries the same symbol, so {@link isLinkedError} can
8
+ * recognise an error from any copy. The brand is read along the error's prototype chain, so a
9
+ * subclass instance matches its base class, as with `instanceof`.
10
+ *
11
+ * The convention is the symbol keys, not this module: two copies of core brand and check
12
+ * the same keys. See https://github.com/linked-fw/cli/blob/main/docs/architecture/shared-state-and-error-brands.md.
13
+ */
14
+ type ErrorClass = abstract new (...args: never[]) => Error;
15
+ /**
16
+ * Brand an error class so {@link isLinkedError} matches its instances from any copy of the
17
+ * defining module. Call it once, right after the class declaration.
18
+ *
19
+ * @param Cls The error class.
20
+ * @param pkg The defining package's npm name, e.g. `'@_linked/server'`.
21
+ * @param name The class name. Passed explicitly because a minifier may rename the class.
22
+ * @returns The class, for `export const X = brandLinkedError(class X ..., pkg, 'X')` use.
23
+ */
24
+ export declare function brandLinkedError<C extends ErrorClass>(Cls: C, pkg: string, name: string): C;
25
+ /**
26
+ * `err instanceof Cls`, extended to instances of `Cls` from another copy of its module.
27
+ *
28
+ * Falls back to plain `instanceof` for a class that is not branded. A subclass that is not
29
+ * branded itself does not inherit its base's brand for this check: it would otherwise match
30
+ * every instance of the base.
31
+ */
32
+ export declare function isLinkedError<C extends ErrorClass>(err: unknown, Cls: C): err is InstanceType<C>;
33
+ /** The brand symbol for a class: `Symbol.for('<pkg>:<name>')`. */
34
+ export declare function linkedErrorBrand(pkg: string, name: string): symbol;
35
+ export {};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Error identity that survives a second copy of the module that defines the error.
3
+ *
4
+ * `err instanceof RemoteDatasetError` is false when the error was thrown by one copy of
5
+ * `@_linked/server` and the class was imported from another: each copy has its own class.
6
+ * A branded class instead carries a brand, `Symbol.for('<pkg>:<ClassName>')`, on its
7
+ * prototype. Every copy of the class carries the same symbol, so {@link isLinkedError} can
8
+ * recognise an error from any copy. The brand is read along the error's prototype chain, so a
9
+ * subclass instance matches its base class, as with `instanceof`.
10
+ *
11
+ * The convention is the symbol keys, not this module: two copies of core brand and check
12
+ * the same keys. See https://github.com/linked-fw/cli/blob/main/docs/architecture/shared-state-and-error-brands.md.
13
+ */
14
+ /** Static key on a branded class whose value is the class's brand symbol. */
15
+ const LINKED_ERROR_BRAND = Symbol.for('@_linked/core:errorBrand');
16
+ /**
17
+ * Brand an error class so {@link isLinkedError} matches its instances from any copy of the
18
+ * defining module. Call it once, right after the class declaration.
19
+ *
20
+ * @param Cls The error class.
21
+ * @param pkg The defining package's npm name, e.g. `'@_linked/server'`.
22
+ * @param name The class name. Passed explicitly because a minifier may rename the class.
23
+ * @returns The class, for `export const X = brandLinkedError(class X ..., pkg, 'X')` use.
24
+ */
25
+ export function brandLinkedError(Cls, pkg, name) {
26
+ const brand = linkedErrorBrand(pkg, name);
27
+ Object.defineProperty(Cls, LINKED_ERROR_BRAND, { value: brand, configurable: true });
28
+ Object.defineProperty(Cls.prototype, brand, { value: true, configurable: true });
29
+ return Cls;
30
+ }
31
+ /**
32
+ * `err instanceof Cls`, extended to instances of `Cls` from another copy of its module.
33
+ *
34
+ * Falls back to plain `instanceof` for a class that is not branded. A subclass that is not
35
+ * branded itself does not inherit its base's brand for this check: it would otherwise match
36
+ * every instance of the base.
37
+ */
38
+ export function isLinkedError(err, Cls) {
39
+ if (err instanceof Cls)
40
+ return true;
41
+ if (err === null || (typeof err !== 'object' && typeof err !== 'function'))
42
+ return false;
43
+ if (!Object.prototype.hasOwnProperty.call(Cls, LINKED_ERROR_BRAND))
44
+ return false;
45
+ const brand = Cls[LINKED_ERROR_BRAND];
46
+ return err[brand] === true;
47
+ }
48
+ /** The brand symbol for a class: `Symbol.for('<pkg>:<name>')`. */
49
+ export function linkedErrorBrand(pkg, name) {
50
+ return Symbol.for(`${pkg}:${name}`);
51
+ }
52
+ //# sourceMapp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MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Error identity that survives a second copy of the module that defines the error.\n *\n * `err instanceof RemoteDatasetError` is false when the error was thrown by one copy of\n * `@_linked/server` and the class was imported from another: each copy has its own class.\n * A branded class instead carries a brand, `Symbol.for('<pkg>:<ClassName>')`, on its\n * prototype. Every copy of the class carries the same symbol, so {@link isLinkedError} can\n * recognise an error from any copy. The brand is read along the error's prototype chain, so a\n * subclass instance matches its base class, as with `instanceof`.\n *\n * The convention is the symbol keys, not this module: two copies of core brand and check\n * the same keys. See https://github.com/linked-fw/cli/blob/main/docs/architecture/shared-state-and-error-brands.md.\n */\n\n/** Static key on a branded class whose value is the class's brand symbol. */\nconst LINKED_ERROR_BRAND = Symbol.for('@_linked/core:errorBrand');\n\ntype ErrorClass = abstract new (...args: never[]) => Error;\n\n/**\n * Brand an error class so {@link isLinkedError} matches its instances from any copy of the\n * defining module. Call it once, right after the class declaration.\n *\n * @param Cls The error class.\n * @param pkg The defining package's npm name, e.g. `'@_linked/server'`.\n * @param name The class name. Passed explicitly because a minifier may rename the class.\n * @returns The class, for `export const X = brandLinkedError(class X ..., pkg, 'X')` use.\n */\nexport function brandLinkedError<C extends ErrorClass>(Cls: C, pkg: string, name: string): C {\n const brand = linkedErrorBrand(pkg, name);\n Object.defineProperty(Cls, LINKED_ERROR_BRAND, {value: brand, configurable: true});\n Object.defineProperty(Cls.prototype, brand, {value: true, configurable: true});\n return Cls;\n}\n\n/**\n * `err instanceof Cls`, extended to instances of `Cls` from another copy of its module.\n *\n * Falls back to plain `instanceof` for a class that is not branded. A subclass that is not\n * branded itself does not inherit its base's brand for this check: it would otherwise match\n * every instance of the base.\n */\nexport function isLinkedError<C extends ErrorClass>(err: unknown, Cls: C): err is InstanceType<C> {\n if (err instanceof Cls) return true;\n if (err === null || (typeof err !== 'object' && typeof err !== 'function')) return false;\n if (!Object.prototype.hasOwnProperty.call(Cls, LINKED_ERROR_BRAND)) return false;\n const brand = (Cls as unknown as Record<symbol, symbol>)[LINKED_ERROR_BRAND];\n return (err as Record<symbol, unknown>)[brand] === true;\n}\n\n/** The brand symbol for a class: `Symbol.for('<pkg>:<name>')`. */\nexport function linkedErrorBrand(pkg: string, name: string): symbol {\n return Symbol.for(`${pkg}:${name}`);\n}\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * A cache derived from the shape registry: one map for the global registry, rebuilt when
3
+ * its version moves, and one per catalog, kept in a WeakMap on the catalog object. A
4
+ * catalog is immutable, so its map needs no version and lives as long as the catalog does.
5
+ * `fill`, when given, populates a fresh map. @internal
6
+ */
7
+ export declare class RegistryCache<K, V> {
8
+ private readonly fill?;
9
+ private globalMap;
10
+ private globalVersion;
11
+ private readonly byCatalog;
12
+ constructor(fill?: (map: Map<K, V>) => void);
13
+ /** The map for the active catalog (or the global registry). */
14
+ get(): Map<K, V>;
15
+ }
@@ -0,0 +1,50 @@
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ /**
7
+ * The registry-derived cache, in a module with no imports so the modules that
8
+ * `ShapeClass.ts` imports (and that import it back) can create caches at evaluation.
9
+ *
10
+ * It reads the shared registry container `ShapeClass.ts` puts on `globalThis`
11
+ * (`__linkedShapeRegistry`); the first `get()` always runs after that module evaluated.
12
+ */
13
+ const shapeRegistryGlobal = typeof globalThis !== 'undefined' ? globalThis : {};
14
+ let registryState;
15
+ /**
16
+ * A cache derived from the shape registry: one map for the global registry, rebuilt when
17
+ * its version moves, and one per catalog, kept in a WeakMap on the catalog object. A
18
+ * catalog is immutable, so its map needs no version and lives as long as the catalog does.
19
+ * `fill`, when given, populates a fresh map. @internal
20
+ */
21
+ export class RegistryCache {
22
+ constructor(fill) {
23
+ this.fill = fill;
24
+ this.globalMap = new Map();
25
+ this.globalVersion = -1;
26
+ this.byCatalog = new WeakMap();
27
+ }
28
+ /** The map for the active catalog (or the global registry). */
29
+ get() {
30
+ var _a, _b;
31
+ const state = (registryState !== null && registryState !== void 0 ? registryState : (registryState = shapeRegistryGlobal.__linkedShapeRegistry));
32
+ const catalog = state.activeCatalog;
33
+ if (catalog === undefined) {
34
+ if (this.globalVersion !== state.registryVersion) {
35
+ this.globalMap = new Map();
36
+ this.globalVersion = state.registryVersion;
37
+ (_a = this.fill) === null || _a === void 0 ? void 0 : _a.call(this, this.globalMap);
38
+ }
39
+ return this.globalMap;
40
+ }
41
+ let map = this.byCatalog.get(catalog);
42
+ if (!map) {
43
+ map = new Map();
44
+ this.byCatalog.set(catalog, map);
45
+ (_b = this.fill) === null || _b === void 0 ? void 0 : _b.call(this, map);
46
+ }
47
+ return map;
48
+ }
49
+ }
50
+ //# sourceMappingURL=registryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registryCache.js","sourceRoot":"","sources":["../../../src/utils/registryCache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,MAAM,mBAAmB,GACvB,OAAO,UAAU,KAAK,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAE,EAAU,CAAC;AAE/D,IAAI,aAAuF,CAAC;AAE5F;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAKxB,YAA6B,IAA+B;QAA/B,SAAI,GAAJ,IAAI,CAA2B;QAJpD,cAAS,GAAG,IAAI,GAAG,EAAQ,CAAC;QAC5B,kBAAa,GAAG,CAAC,CAAC,CAAC;QACV,cAAS,GAAG,IAAI,OAAO,EAAqB,CAAC;IAEC,CAAC;IAEhE,+DAA+D;IAC/D,GAAG;;QACD,MAAM,KAAK,GAAG,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,IAAb,aAAa,GAAK,mBAAmB,CAAC,qBAAqB,EAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC;QACpC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,IAAI,CAAC,aAAa,KAAK,KAAK,CAAC,eAAe,EAAE,CAAC;gBACjD,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;gBAC3B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,eAAe,CAAC;gBAC3C,MAAA,IAAI,CAAC,IAAI,qDAAG,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9B,CAAC;YACD,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;QACD,IAAI,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;YAChB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YACjC,MAAA,IAAI,CAAC,IAAI,qDAAG,GAAG,CAAC,CAAC;QACnB,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["/*\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at https://mozilla.org/MPL/2.0/.\n */\n\n/**\n * The registry-derived cache, in a module with no imports so the modules that\n * `ShapeClass.ts` imports (and that import it back) can create caches at evaluation.\n *\n * It reads the shared registry container `ShapeClass.ts` puts on `globalThis`\n * (`__linkedShapeRegistry`); the first `get()` always runs after that module evaluated.\n */\n\nconst shapeRegistryGlobal: any =\n typeof globalThis !== 'undefined' ? globalThis : ({} as any);\n\nlet registryState: {registryVersion: number; activeCatalog: object | undefined} | undefined;\n\n/**\n * A cache derived from the shape registry: one map for the global registry, rebuilt when\n * its version moves, and one per catalog, kept in a WeakMap on the catalog object. A\n * catalog is immutable, so its map needs no version and lives as long as the catalog does.\n * `fill`, when given, populates a fresh map. @internal\n */\nexport class RegistryCache<K, V> {\n private globalMap = new Map<K, V>();\n private globalVersion = -1;\n private readonly byCatalog = new WeakMap<object, Map<K, V>>();\n\n constructor(private readonly fill?: (map: Map<K, V>) => void) {}\n\n /** The map for the active catalog (or the global registry). */\n get(): Map<K, V> {\n const state = (registryState ??= shapeRegistryGlobal.__linkedShapeRegistry);\n const catalog = state.activeCatalog;\n if (catalog === undefined) {\n if (this.globalVersion !== state.registryVersion) {\n this.globalMap = new Map();\n this.globalVersion = state.registryVersion;\n this.fill?.(this.globalMap);\n }\n return this.globalMap;\n }\n let map = this.byCatalog.get(catalog);\n if (!map) {\n map = new Map();\n this.byCatalog.set(catalog, map);\n this.fill?.(map);\n }\n return map;\n }\n}\n"]}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Module state that survives a second copy of the module.
3
+ *
4
+ * A framework module can be evaluated more than once in one process: under `linked start`
5
+ * once by Vite's SSR module runner and once by Node, and in a browser when two bundles each
6
+ * carry a copy. A module-scope variable then exists twice, and a value one caller writes is
7
+ * invisible to a caller that reached the other copy. `sharedState` keeps the value on
8
+ * `globalThis` under `Symbol.for('<pkg>:<name>')`, created by whichever copy asks first, so
9
+ * every copy reads and writes the same object.
10
+ *
11
+ * Put a module's state in one container object and mutate it, rather than storing a primitive:
12
+ * the container is shared, a primitive read into a local is not.
13
+ *
14
+ * The container outlives any one version of the module. A newer copy that adds a field must
15
+ * tolerate a container an older copy created without it (fill the gap, don't assume it).
16
+ *
17
+ * See https://github.com/linked-fw/cli/blob/main/docs/architecture/shared-state-and-error-brands.md.
18
+ *
19
+ * @param pkg The package's npm name, e.g. `'@_linked/server-utils'`.
20
+ * @param name What the state is, unique within the package, e.g. `'Server.proxy'`.
21
+ * @param init Creates the initial value; called once per process, by the first copy.
22
+ */
23
+ export declare function sharedState<T extends object>(pkg: string, name: string, init: () => T): T;
24
+ /** The `globalThis` key {@link sharedState} uses: `Symbol.for('<pkg>:<name>')`. */
25
+ export declare function sharedStateKey(pkg: string, name: string): symbol;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Module state that survives a second copy of the module.
3
+ *
4
+ * A framework module can be evaluated more than once in one process: under `linked start`
5
+ * once by Vite's SSR module runner and once by Node, and in a browser when two bundles each
6
+ * carry a copy. A module-scope variable then exists twice, and a value one caller writes is
7
+ * invisible to a caller that reached the other copy. `sharedState` keeps the value on
8
+ * `globalThis` under `Symbol.for('<pkg>:<name>')`, created by whichever copy asks first, so
9
+ * every copy reads and writes the same object.
10
+ *
11
+ * Put a module's state in one container object and mutate it, rather than storing a primitive:
12
+ * the container is shared, a primitive read into a local is not.
13
+ *
14
+ * The container outlives any one version of the module. A newer copy that adds a field must
15
+ * tolerate a container an older copy created without it (fill the gap, don't assume it).
16
+ *
17
+ * See https://github.com/linked-fw/cli/blob/main/docs/architecture/shared-state-and-error-brands.md.
18
+ *
19
+ * @param pkg The package's npm name, e.g. `'@_linked/server-utils'`.
20
+ * @param name What the state is, unique within the package, e.g. `'Server.proxy'`.
21
+ * @param init Creates the initial value; called once per process, by the first copy.
22
+ */
23
+ export function sharedState(pkg, name, init) {
24
+ const key = sharedStateKey(pkg, name);
25
+ const store = globalThis;
26
+ if (!(key in store))
27
+ store[key] = init();
28
+ return store[key];
29
+ }
30
+ /** The `globalThis` key {@link sharedState} uses: `Symbol.for('<pkg>:<name>')`. */
31
+ export function sharedStateKey(pkg, name) {
32
+ return Symbol.for(`${pkg}:${name}`);
33
+ }
34
+ //# sourceMappingURL=sharedState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharedState.js","sourceRoot":"","sources":["../../../src/utils/sharedState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,WAAW,CAAmB,GAAW,EAAE,IAAY,EAAE,IAAa;IACpF,MAAM,GAAG,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACtC,MAAM,KAAK,GAAG,UAAgD,CAAC;IAC/D,IAAI,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC;QAAE,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC;IACzC,OAAO,KAAK,CAAC,GAAG,CAAM,CAAC;AACzB,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,IAAY;IACtD,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC","sourcesContent":["/**\n * Module state that survives a second copy of the module.\n *\n * A framework module can be evaluated more than once in one process: under `linked start`\n * once by Vite's SSR module runner and once by Node, and in a browser when two bundles each\n * carry a copy. A module-scope variable then exists twice, and a value one caller writes is\n * invisible to a caller that reached the other copy. `sharedState` keeps the value on\n * `globalThis` under `Symbol.for('<pkg>:<name>')`, created by whichever copy asks first, so\n * every copy reads and writes the same object.\n *\n * Put a module's state in one container object and mutate it, rather than storing a primitive:\n * the container is shared, a primitive read into a local is not.\n *\n * The container outlives any one version of the module. A newer copy that adds a field must\n * tolerate a container an older copy created without it (fill the gap, don't assume it).\n *\n * See https://github.com/linked-fw/cli/blob/main/docs/architecture/shared-state-and-error-brands.md.\n *\n * @param pkg The package's npm name, e.g. `'@_linked/server-utils'`.\n * @param name What the state is, unique within the package, e.g. `'Server.proxy'`.\n * @param init Creates the initial value; called once per process, by the first copy.\n */\nexport function sharedState<T extends object>(pkg: string, name: string, init: () => T): T {\n const key = sharedStateKey(pkg, name);\n const store = globalThis as unknown as Record<symbol, unknown>;\n if (!(key in store)) store[key] = init();\n return store[key] as T;\n}\n\n/** The `globalThis` key {@link sharedState} uses: `Symbol.for('<pkg>:<name>')`. */\nexport function sharedStateKey(pkg: string, name: string): symbol {\n return Symbol.for(`${pkg}:${name}`);\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import type { NodeShapeData, PropertyShapeData } from '../shapes/nodeShapeData.js';
2
+ /**
3
+ * Where an unresolved shape was met: the shape IRI that could not be resolved and, when a
4
+ * property pointed at it, that property and the shape that declares it. `catalog` is the
5
+ * active catalog's `name`, absent in the global registry or for an unnamed catalog.
6
+ */
7
+ export interface UnresolvedShapeDetails {
8
+ shapeIri: string;
9
+ property?: string;
10
+ propertyIri?: string;
11
+ ownerShapeIri?: string;
12
+ catalog?: string;
13
+ }
14
+ /**
15
+ * The error core throws when a shape IRI does not resolve, carrying the IRIs as fields so a
16
+ * host can map it without parsing the message. It stays a plain `Error` (`name` is
17
+ * `'Error'`): only the message and the fields are added.
18
+ */
19
+ export declare class UnresolvedShapeError extends Error implements UnresolvedShapeDetails {
20
+ readonly shapeIri: string;
21
+ readonly property?: string;
22
+ readonly propertyIri?: string;
23
+ readonly ownerShapeIri?: string;
24
+ readonly catalog?: string;
25
+ constructor(message: string, details: UnresolvedShapeDetails);
26
+ }
27
+ /**
28
+ * The details for a property whose value shape does not resolve. The owner is the property's
29
+ * `parentNodeShape`, or `owner` when the caller knows it better (a path walk).
30
+ */
31
+ export declare function unresolvedValueShapeDetails(ps: PropertyShapeData, owner?: NodeShapeData): UnresolvedShapeDetails;
32
+ /** The details for a shape named directly (a query's or mutation's own shape). */
33
+ export declare function topLevelDetails(shapeIri: string): UnresolvedShapeDetails;
34
+ /**
35
+ * Why the shape is missing, in words: `property 'home' of '<owner>' points at it; catalog
36
+ * 'p1#main' does not hold it`. Each error keeps its own leading sentence and appends this.
37
+ */
38
+ export declare function describeUnresolved(details: UnresolvedShapeDetails): string;
39
+ /** `<prefix> (<why>)` as an {@link UnresolvedShapeError}. */
40
+ export declare function unresolvedShapeError(prefix: string, details: UnresolvedShapeDetails): UnresolvedShapeError;
41
+ /** The error for a property whose `valueShape` does not resolve. */
42
+ export declare function unresolvedValueShapeError(prefix: string, ps: PropertyShapeData, owner?: NodeShapeData): UnresolvedShapeError;