@_linked/core 2.30.1 → 2.32.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 (59) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +107 -60
  3. package/lib/esm/ontologies/linked-core.js +3 -2
  4. package/lib/esm/ontologies/linked-core.js.map +1 -1
  5. package/lib/esm/ontologies/shacl.d.ts +3 -0
  6. package/lib/esm/ontologies/shacl.js +6 -0
  7. package/lib/esm/ontologies/shacl.js.map +1 -1
  8. package/lib/esm/queries/IRMutation.js +1 -1
  9. package/lib/esm/queries/IRMutation.js.map +1 -1
  10. package/lib/esm/queries/IntermediateRepresentation.d.ts +0 -5
  11. package/lib/esm/queries/IntermediateRepresentation.js.map +1 -1
  12. package/lib/esm/queries/MutationQuery.js +0 -15
  13. package/lib/esm/queries/MutationQuery.js.map +1 -1
  14. package/lib/esm/queries/MutationSerialization.d.ts +6 -5
  15. package/lib/esm/queries/MutationSerialization.js +1 -9
  16. package/lib/esm/queries/MutationSerialization.js.map +1 -1
  17. package/lib/esm/queries/QueryFactory.d.ts +0 -6
  18. package/lib/esm/queries/QueryFactory.js.map +1 -1
  19. package/lib/esm/queries/lowerMutationJSON.js +1 -6
  20. package/lib/esm/queries/lowerMutationJSON.js.map +1 -1
  21. package/lib/esm/shapes/List.class.d.ts +3 -3
  22. package/lib/esm/shapes/List.class.js +3 -3
  23. package/lib/esm/shapes/List.class.js.map +1 -1
  24. package/lib/esm/shapes/List.d.ts +0 -1
  25. package/lib/esm/shapes/List.js.map +1 -1
  26. package/lib/esm/shapes/PathList.d.ts +24 -0
  27. package/lib/esm/shapes/PathList.js +60 -0
  28. package/lib/esm/shapes/PathList.js.map +1 -0
  29. package/lib/esm/shapes/PathNode.d.ts +8 -9
  30. package/lib/esm/shapes/PathNode.js +20 -14
  31. package/lib/esm/shapes/PathNode.js.map +1 -1
  32. package/lib/esm/shapes/SHACL.d.ts +15 -13
  33. package/lib/esm/shapes/SHACL.js +8 -0
  34. package/lib/esm/shapes/SHACL.js.map +1 -1
  35. package/lib/esm/shapes/index.d.ts +1 -0
  36. package/lib/esm/shapes/index.js +1 -0
  37. package/lib/esm/shapes/index.js.map +1 -1
  38. package/lib/esm/shapes/nodeShapeData.d.ts +4 -1
  39. package/lib/esm/shapes/nodeShapeData.js.map +1 -1
  40. package/lib/esm/shapes/serializePathToNodeData.d.ts +12 -11
  41. package/lib/esm/shapes/serializePathToNodeData.js +12 -11
  42. package/lib/esm/shapes/serializePathToNodeData.js.map +1 -1
  43. package/lib/esm/shapes/singleOwnerConstraint.d.ts +5 -7
  44. package/lib/esm/shapes/singleOwnerConstraint.js +65 -21
  45. package/lib/esm/shapes/singleOwnerConstraint.js.map +1 -1
  46. package/lib/esm/shapes/syncShapes.js +2 -2
  47. package/lib/esm/shapes/syncShapes.js.map +1 -1
  48. package/lib/esm/shapes/validation.js +2 -2
  49. package/lib/esm/shapes/validation.js.map +1 -1
  50. package/lib/esm/sparql/irToAlgebra.d.ts +15 -33
  51. package/lib/esm/sparql/irToAlgebra.js +680 -431
  52. package/lib/esm/sparql/irToAlgebra.js.map +1 -1
  53. package/lib/esm/sparql/ownedLinkCheck.d.ts +6 -10
  54. package/lib/esm/sparql/ownedLinkCheck.js +10 -11
  55. package/lib/esm/sparql/ownedLinkCheck.js.map +1 -1
  56. package/lib/esm/utils/Package.d.ts +3 -2
  57. package/lib/esm/utils/Package.js +21 -8
  58. package/lib/esm/utils/Package.js.map +1 -1
  59. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/shapes/List.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,2FAA2F;AAC3F,yFAAyF;AACzF,wFAAwF;AACxF,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAC;AAEzC,OAAO,EAAC,IAAI,EAAC,CAAC;AASd;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CACrB,KAAU,EACV,IAAsB;IAEtB,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC;IACxB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAmB,EAAE;QAC3C,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,EAAC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,EAAC,CAAC;QAC1B,CAAC;QACD,MAAM,IAAI,GAAoB;YAC5B,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACf,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;SACnB,CAAC;QACF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","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// Registers List (together with the rest of the SHACL metamodel), so importing this module\n// on its own is enough to make List resolvable. The class lives in List.class.ts because\n// utils/Package.ts needs it by value and cannot import this module's registration path.\nimport '../utils/Package.js';\nimport {List} from './List.class.js';\nimport {rdf} from '../ontologies/rdf.js';\n\nexport {List};\n\n/**\n * Node-data for a single cell / the `rdf:nil` terminal. Accepted by the create pipeline.\n */\nexport type RdfListNodeData =\n | {id: string}\n | {shape: typeof List; first: unknown; rest: RdfListNodeData; __id?: string; __blank?: true};\n\n/**\n * Build the nested `List` node-data chain for an ordered `rdf:List`, terminating at `rdf:nil`.\n * Pass `opts.base` to mint deterministic cell ids (`{base}/0`, `{base}/1`, …); otherwise the\n * create pipeline mints ids. The empty list serializes to `rdf:nil`.\n *\n * @example Playlist.create({ tracks: rdfList([t1, t2, t3]) })\n */\nexport function rdfList<T>(\n items: T[],\n opts?: {base?: string},\n): RdfListNodeData {\n const base = opts?.base;\n const build = (i: number): RdfListNodeData => {\n if (i >= items.length) {\n return {id: rdf.nil.id};\n }\n const cell: RdfListNodeData = {\n shape: List,\n first: items[i],\n rest: build(i + 1),\n };\n if (base !== undefined) {\n cell.__id = `${base}/${i}`;\n }\n return cell;\n };\n return build(0);\n}\n"]}
1
+ {"version":3,"file":"List.js","sourceRoot":"","sources":["../../../src/shapes/List.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,2FAA2F;AAC3F,yFAAyF;AACzF,wFAAwF;AACxF,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAC,IAAI,EAAC,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAC;AAEzC,OAAO,EAAC,IAAI,EAAC,CAAC;AASd;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CACrB,KAAU,EACV,IAAsB;IAEtB,MAAM,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC;IACxB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAmB,EAAE;QAC3C,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACtB,OAAO,EAAC,EAAE,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,EAAC,CAAC;QAC1B,CAAC;QACD,MAAM,IAAI,GAAoB;YAC5B,KAAK,EAAE,IAAI;YACX,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YACf,IAAI,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;SACnB,CAAC;QACF,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,IAAI,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,CAAC;QAC7B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IACF,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC","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// Registers List (together with the rest of the SHACL metamodel), so importing this module\n// on its own is enough to make List resolvable. The class lives in List.class.ts because\n// utils/Package.ts needs it by value and cannot import this module's registration path.\nimport '../utils/Package.js';\nimport {List} from './List.class.js';\nimport {rdf} from '../ontologies/rdf.js';\n\nexport {List};\n\n/**\n * Node-data for a single cell / the `rdf:nil` terminal. Accepted by the create pipeline.\n */\nexport type RdfListNodeData =\n | {id: string}\n | {shape: typeof List; first: unknown; rest: RdfListNodeData; __id?: string};\n\n/**\n * Build the nested `List` node-data chain for an ordered `rdf:List`, terminating at `rdf:nil`.\n * Pass `opts.base` to mint deterministic cell ids (`{base}/0`, `{base}/1`, …); otherwise the\n * create pipeline mints ids. The empty list serializes to `rdf:nil`.\n *\n * @example Playlist.create({ tracks: rdfList([t1, t2, t3]) })\n */\nexport function rdfList<T>(\n items: T[],\n opts?: {base?: string},\n): RdfListNodeData {\n const base = opts?.base;\n const build = (i: number): RdfListNodeData => {\n if (i >= items.length) {\n return {id: rdf.nil.id};\n }\n const cell: RdfListNodeData = {\n shape: List,\n first: items[i],\n rest: build(i + 1),\n };\n if (base !== undefined) {\n cell.__id = `${base}/${i}`;\n }\n return cell;\n };\n return build(0);\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { Shape } from './Shape.js';
2
+ /**
3
+ * A blank `rdf:List` cell of SHACL structure core writes: the members of a sequence path, the
4
+ * operand of `sh:alternativePath`, and the `sh:or` list of a generated single-owner constraint
5
+ * (`singleOwnerConstraint.ts`).
6
+ *
7
+ * Both properties are `sh:BlankNodeOrIRI`, so a cell written without an id is a blank node, and so
8
+ * is an operator node (`PathNode`) held by `first`. That keeps a sequence path a blank list, which
9
+ * SHACL §2.3.1 needs: an IRI as the `sh:path` value is a predicate path.
10
+ *
11
+ * It is a separate shape from `List` on purpose. `List.first` also holds literals (`sh:in`), so it
12
+ * cannot be declared node-only, and making `List.rest` blank-capable would turn the tail cells of
13
+ * every list built without ids into blank nodes. Both shapes target `rdf:List`; `List` is
14
+ * registered first, so a lookup by `rdf:List` still returns `List`.
15
+ */
16
+ export declare class PathList extends Shape {
17
+ static targetClass: import("../utils/NodeReference.js").NodeReferenceValue;
18
+ /**
19
+ * A predicate IRI, or an operator node (`PathNode`). Not `contains`: a predicate IRI is
20
+ * shared. The blank-node cascade follows it, because it is blank-capable.
21
+ */
22
+ get first(): unknown;
23
+ get rest(): PathList;
24
+ }
@@ -0,0 +1,60 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ /*
8
+ * This Source Code Form is subject to the terms of the Mozilla Public
9
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
10
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
11
+ */
12
+ import { linkedShape } from '../package.js';
13
+ import { Shape } from './Shape.js';
14
+ import { objectProperty } from './SHACL.js';
15
+ import { shacl } from '../ontologies/shacl.js';
16
+ import { rdf } from '../ontologies/rdf.js';
17
+ /**
18
+ * A blank `rdf:List` cell of SHACL structure core writes: the members of a sequence path, the
19
+ * operand of `sh:alternativePath`, and the `sh:or` list of a generated single-owner constraint
20
+ * (`singleOwnerConstraint.ts`).
21
+ *
22
+ * Both properties are `sh:BlankNodeOrIRI`, so a cell written without an id is a blank node, and so
23
+ * is an operator node (`PathNode`) held by `first`. That keeps a sequence path a blank list, which
24
+ * SHACL §2.3.1 needs: an IRI as the `sh:path` value is a predicate path.
25
+ *
26
+ * It is a separate shape from `List` on purpose. `List.first` also holds literals (`sh:in`), so it
27
+ * cannot be declared node-only, and making `List.rest` blank-capable would turn the tail cells of
28
+ * every list built without ids into blank nodes. Both shapes target `rdf:List`; `List` is
29
+ * registered first, so a lookup by `rdf:List` still returns `List`.
30
+ */
31
+ let PathList = class PathList extends Shape {
32
+ /**
33
+ * A predicate IRI, or an operator node (`PathNode`). Not `contains`: a predicate IRI is
34
+ * shared. The blank-node cascade follows it, because it is blank-capable.
35
+ */
36
+ get first() {
37
+ return null;
38
+ }
39
+ get rest() {
40
+ return null;
41
+ }
42
+ };
43
+ PathList.targetClass = rdf.List;
44
+ __decorate([
45
+ objectProperty({ path: rdf.first, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI })
46
+ ], PathList.prototype, "first", null);
47
+ __decorate([
48
+ objectProperty({
49
+ path: rdf.rest,
50
+ maxCount: 1,
51
+ shape: PathList,
52
+ contains: true,
53
+ nodeKind: shacl.BlankNodeOrIRI,
54
+ })
55
+ ], PathList.prototype, "rest", null);
56
+ PathList = __decorate([
57
+ linkedShape({ name: 'PathList' })
58
+ ], PathList);
59
+ export { PathList };
60
+ //# sourceMappingURL=PathList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PathList.js","sourceRoot":"","sources":["../../../src/shapes/PathList.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,GAAG,EAAC,MAAM,sBAAsB,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,KAAK;IAGjC;;;OAGG;IAEH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IASD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC;IACd,CAAC;;AApBM,oBAAW,GAAG,GAAG,CAAC,IAAI,AAAX,CAAY;AAO9B;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,cAAc,EAAC,CAAC;qCAG9E;AASD;IAPC,cAAc,CAAC;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,KAAK,CAAC,cAAc;KAC/B,CAAC;oCAGD;AArBU,QAAQ;IADpB,WAAW,CAAC,EAAC,IAAI,EAAE,UAAU,EAAC,CAAC;GACnB,QAAQ,CAsBpB","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 */\nimport {linkedShape} from '../package.js';\nimport {Shape} from './Shape.js';\nimport {objectProperty} from './SHACL.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {rdf} from '../ontologies/rdf.js';\n\n/**\n * A blank `rdf:List` cell of SHACL structure core writes: the members of a sequence path, the\n * operand of `sh:alternativePath`, and the `sh:or` list of a generated single-owner constraint\n * (`singleOwnerConstraint.ts`).\n *\n * Both properties are `sh:BlankNodeOrIRI`, so a cell written without an id is a blank node, and so\n * is an operator node (`PathNode`) held by `first`. That keeps a sequence path a blank list, which\n * SHACL §2.3.1 needs: an IRI as the `sh:path` value is a predicate path.\n *\n * It is a separate shape from `List` on purpose. `List.first` also holds literals (`sh:in`), so it\n * cannot be declared node-only, and making `List.rest` blank-capable would turn the tail cells of\n * every list built without ids into blank nodes. Both shapes target `rdf:List`; `List` is\n * registered first, so a lookup by `rdf:List` still returns `List`.\n */\n@linkedShape({name: 'PathList'})\nexport class PathList extends Shape {\n static targetClass = rdf.List;\n\n /**\n * A predicate IRI, or an operator node (`PathNode`). Not `contains`: a predicate IRI is\n * shared. The blank-node cascade follows it, because it is blank-capable.\n */\n @objectProperty({path: rdf.first, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI})\n get first(): unknown {\n return null;\n }\n\n @objectProperty({\n path: rdf.rest,\n maxCount: 1,\n shape: PathList,\n contains: true,\n nodeKind: shacl.BlankNodeOrIRI,\n })\n get rest(): PathList {\n return null;\n }\n}\n"]}
@@ -1,22 +1,21 @@
1
1
  import { Shape } from './Shape.js';
2
- import { List } from './List.js';
2
+ import { PathList } from './PathList.js';
3
3
  /**
4
4
  * Operator node for SHACL property paths that are NOT a simple predicate or a sequence:
5
5
  * inverse (`sh:inversePath`), alternative (`sh:alternativePath` → an `rdf:List`), and the
6
6
  * cardinality forms (`sh:zeroOrMorePath`/`sh:oneOrMorePath`/`sh:zeroOrOnePath`).
7
7
  *
8
- * Shape sync writes these as untyped blank nodes (`__blank`, see `serializePathToNodeData`): the
9
- * only form SHACL §2.3.1 defines, a blank node that is the subject of exactly one triple. Each
10
- * operator edge is `contains`, so the blank-node block of the containment cascade removes the
11
- * structure on delete/replace. The class stays `dependent` with its `core:PathNode` type for the
12
- * IRI-named, typed nodes earlier versions wrote: the typed cascade removes those on the next sync.
13
- * Operands are polymorphic (a predicate IRI, a nested `PathNode`, or a `List`), so no fixed
14
- * `valueShape` is declared except for `alternativePath`, which is always an `rdf:List`.
8
+ * Every slot is `sh:BlankNodeOrIRI`, as is `PropertyShape.path`, so an operator node written
9
+ * without an id is an untyped blank node: the only form SHACL §2.3.1 defines, a blank node that is
10
+ * the subject of exactly one triple (see `serializePathToNodeData`). The blank-node cascade
11
+ * follows these blank-capable slots on delete / replace, so they need no `contains`.
12
+ * Operands are polymorphic (a predicate IRI, a nested `PathNode`, or a `PathList`), so no fixed
13
+ * `valueShape` is declared except for `alternativePath`, which is always a `PathList`.
15
14
  */
16
15
  export declare class PathNode extends Shape {
17
16
  static targetClass: import("../utils/NodeReference.js").NodeReferenceValue;
18
17
  get inversePath(): unknown;
19
- get alternativePath(): List;
18
+ get alternativePath(): PathList;
20
19
  get zeroOrMorePath(): unknown;
21
20
  get oneOrMorePath(): unknown;
22
21
  get zeroOrOnePath(): unknown;
@@ -14,19 +14,19 @@ import { Shape } from './Shape.js';
14
14
  import { objectProperty } from './SHACL.js';
15
15
  import { shacl } from '../ontologies/shacl.js';
16
16
  import { coreOntology } from '../ontologies/linked-core.js';
17
- import { List } from './List.js';
17
+ import { PathList } from './PathList.js';
18
+ const BLANK_OR_IRI = shacl.BlankNodeOrIRI;
18
19
  /**
19
20
  * Operator node for SHACL property paths that are NOT a simple predicate or a sequence:
20
21
  * inverse (`sh:inversePath`), alternative (`sh:alternativePath` → an `rdf:List`), and the
21
22
  * cardinality forms (`sh:zeroOrMorePath`/`sh:oneOrMorePath`/`sh:zeroOrOnePath`).
22
23
  *
23
- * Shape sync writes these as untyped blank nodes (`__blank`, see `serializePathToNodeData`): the
24
- * only form SHACL §2.3.1 defines, a blank node that is the subject of exactly one triple. Each
25
- * operator edge is `contains`, so the blank-node block of the containment cascade removes the
26
- * structure on delete/replace. The class stays `dependent` with its `core:PathNode` type for the
27
- * IRI-named, typed nodes earlier versions wrote: the typed cascade removes those on the next sync.
28
- * Operands are polymorphic (a predicate IRI, a nested `PathNode`, or a `List`), so no fixed
29
- * `valueShape` is declared except for `alternativePath`, which is always an `rdf:List`.
24
+ * Every slot is `sh:BlankNodeOrIRI`, as is `PropertyShape.path`, so an operator node written
25
+ * without an id is an untyped blank node: the only form SHACL §2.3.1 defines, a blank node that is
26
+ * the subject of exactly one triple (see `serializePathToNodeData`). The blank-node cascade
27
+ * follows these blank-capable slots on delete / replace, so they need no `contains`.
28
+ * Operands are polymorphic (a predicate IRI, a nested `PathNode`, or a `PathList`), so no fixed
29
+ * `valueShape` is declared except for `alternativePath`, which is always a `PathList`.
30
30
  */
31
31
  // Named explicitly: the class shares its name with the ontology term coreOntology.PathNode,
32
32
  // and a bundler resolving that collision renames the class (PathNode2), which would change
@@ -50,22 +50,28 @@ let PathNode = class PathNode extends Shape {
50
50
  };
51
51
  PathNode.targetClass = coreOntology.PathNode;
52
52
  __decorate([
53
- objectProperty({ path: shacl.inversePath, maxCount: 1, contains: true })
53
+ objectProperty({ path: shacl.inversePath, maxCount: 1, nodeKind: BLANK_OR_IRI })
54
54
  ], PathNode.prototype, "inversePath", null);
55
55
  __decorate([
56
- objectProperty({ path: shacl.alternativePath, maxCount: 1, shape: List, contains: true })
56
+ objectProperty({
57
+ path: shacl.alternativePath,
58
+ maxCount: 1,
59
+ shape: PathList,
60
+ contains: true,
61
+ nodeKind: BLANK_OR_IRI,
62
+ })
57
63
  ], PathNode.prototype, "alternativePath", null);
58
64
  __decorate([
59
- objectProperty({ path: shacl.zeroOrMorePath, maxCount: 1, contains: true })
65
+ objectProperty({ path: shacl.zeroOrMorePath, maxCount: 1, nodeKind: BLANK_OR_IRI })
60
66
  ], PathNode.prototype, "zeroOrMorePath", null);
61
67
  __decorate([
62
- objectProperty({ path: shacl.oneOrMorePath, maxCount: 1, contains: true })
68
+ objectProperty({ path: shacl.oneOrMorePath, maxCount: 1, nodeKind: BLANK_OR_IRI })
63
69
  ], PathNode.prototype, "oneOrMorePath", null);
64
70
  __decorate([
65
- objectProperty({ path: shacl.zeroOrOnePath, maxCount: 1, contains: true })
71
+ objectProperty({ path: shacl.zeroOrOnePath, maxCount: 1, nodeKind: BLANK_OR_IRI })
66
72
  ], PathNode.prototype, "zeroOrOnePath", null);
67
73
  PathNode = __decorate([
68
- linkedShape({ name: 'PathNode', dependent: true })
74
+ linkedShape({ name: 'PathNode' })
69
75
  ], PathNode);
70
76
  export { PathNode };
71
77
  //# sourceMappingURL=PathNode.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PathNode.js","sourceRoot":"","sources":["../../../src/shapes/PathNode.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAC;AAE/B;;;;;;;;;;;;GAYG;AACH,4FAA4F;AAC5F,2FAA2F;AAC3F,mBAAmB;AAEZ,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,KAAK;IAIjC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC;IACd,CAAC;;AAzBM,oBAAW,GAAG,YAAY,CAAC,QAAQ,AAAxB,CAAyB;AAG3C;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;2CAGtE;AAGD;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,eAAe,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;+CAGvF;AAGD;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,cAAc,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;8CAGzE;AAGD;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;6CAGxE;AAGD;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC;6CAGxE;AA1BU,QAAQ;IADpB,WAAW,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;GACpC,QAAQ,CA2BpB","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 */\nimport {linkedShape} from '../package.js';\nimport {Shape} from './Shape.js';\nimport {objectProperty} from './SHACL.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {coreOntology} from '../ontologies/linked-core.js';\nimport {List} from './List.js';\n\n/**\n * Operator node for SHACL property paths that are NOT a simple predicate or a sequence:\n * inverse (`sh:inversePath`), alternative (`sh:alternativePath` → an `rdf:List`), and the\n * cardinality forms (`sh:zeroOrMorePath`/`sh:oneOrMorePath`/`sh:zeroOrOnePath`).\n *\n * Shape sync writes these as untyped blank nodes (`__blank`, see `serializePathToNodeData`): the\n * only form SHACL §2.3.1 defines, a blank node that is the subject of exactly one triple. Each\n * operator edge is `contains`, so the blank-node block of the containment cascade removes the\n * structure on delete/replace. The class stays `dependent` with its `core:PathNode` type for the\n * IRI-named, typed nodes earlier versions wrote: the typed cascade removes those on the next sync.\n * Operands are polymorphic (a predicate IRI, a nested `PathNode`, or a `List`), so no fixed\n * `valueShape` is declared except for `alternativePath`, which is always an `rdf:List`.\n */\n// Named explicitly: the class shares its name with the ontology term coreOntology.PathNode,\n// and a bundler resolving that collision renames the class (PathNode2), which would change\n// the shape's IRI.\n@linkedShape({name: 'PathNode', dependent: true})\nexport class PathNode extends Shape {\n static targetClass = coreOntology.PathNode;\n\n @objectProperty({path: shacl.inversePath, maxCount: 1, contains: true})\n get inversePath(): unknown {\n return null;\n }\n\n @objectProperty({path: shacl.alternativePath, maxCount: 1, shape: List, contains: true})\n get alternativePath(): List {\n return null;\n }\n\n @objectProperty({path: shacl.zeroOrMorePath, maxCount: 1, contains: true})\n get zeroOrMorePath(): unknown {\n return null;\n }\n\n @objectProperty({path: shacl.oneOrMorePath, maxCount: 1, contains: true})\n get oneOrMorePath(): unknown {\n return null;\n }\n\n @objectProperty({path: shacl.zeroOrOnePath, maxCount: 1, contains: true})\n get zeroOrOnePath(): unknown {\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"PathNode.js","sourceRoot":"","sources":["../../../src/shapes/PathNode.ts"],"names":[],"mappings":";;;;;;AAAA;;;;GAIG;AACH,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,YAAY,EAAC,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAEvC,MAAM,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,4FAA4F;AAC5F,2FAA2F;AAC3F,mBAAmB;AAEZ,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,KAAK;IAIjC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IASD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC;IACd,CAAC;;AA/BM,oBAAW,GAAG,YAAY,CAAC,QAAQ,AAAxB,CAAyB;AAG3C;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,WAAW,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC;2CAG9E;AASD;IAPC,cAAc,CAAC;QACd,IAAI,EAAE,KAAK,CAAC,eAAe;QAC3B,QAAQ,EAAE,CAAC;QACX,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,YAAY;KACvB,CAAC;+CAGD;AAGD;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,cAAc,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC;8CAGjF;AAGD;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC;6CAGhF;AAGD;IADC,cAAc,CAAC,EAAC,IAAI,EAAE,KAAK,CAAC,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC;6CAGhF;AAhCU,QAAQ;IADpB,WAAW,CAAC,EAAC,IAAI,EAAE,UAAU,EAAC,CAAC;GACnB,QAAQ,CAiCpB","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 */\nimport {linkedShape} from '../package.js';\nimport {Shape} from './Shape.js';\nimport {objectProperty} from './SHACL.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {coreOntology} from '../ontologies/linked-core.js';\nimport {PathList} from './PathList.js';\n\nconst BLANK_OR_IRI = shacl.BlankNodeOrIRI;\n\n/**\n * Operator node for SHACL property paths that are NOT a simple predicate or a sequence:\n * inverse (`sh:inversePath`), alternative (`sh:alternativePath` → an `rdf:List`), and the\n * cardinality forms (`sh:zeroOrMorePath`/`sh:oneOrMorePath`/`sh:zeroOrOnePath`).\n *\n * Every slot is `sh:BlankNodeOrIRI`, as is `PropertyShape.path`, so an operator node written\n * without an id is an untyped blank node: the only form SHACL §2.3.1 defines, a blank node that is\n * the subject of exactly one triple (see `serializePathToNodeData`). The blank-node cascade\n * follows these blank-capable slots on delete / replace, so they need no `contains`.\n * Operands are polymorphic (a predicate IRI, a nested `PathNode`, or a `PathList`), so no fixed\n * `valueShape` is declared except for `alternativePath`, which is always a `PathList`.\n */\n// Named explicitly: the class shares its name with the ontology term coreOntology.PathNode,\n// and a bundler resolving that collision renames the class (PathNode2), which would change\n// the shape's IRI.\n@linkedShape({name: 'PathNode'})\nexport class PathNode extends Shape {\n static targetClass = coreOntology.PathNode;\n\n @objectProperty({path: shacl.inversePath, maxCount: 1, nodeKind: BLANK_OR_IRI})\n get inversePath(): unknown {\n return null;\n }\n\n @objectProperty({\n path: shacl.alternativePath,\n maxCount: 1,\n shape: PathList,\n contains: true,\n nodeKind: BLANK_OR_IRI,\n })\n get alternativePath(): PathList {\n return null;\n }\n\n @objectProperty({path: shacl.zeroOrMorePath, maxCount: 1, nodeKind: BLANK_OR_IRI})\n get zeroOrMorePath(): unknown {\n return null;\n }\n\n @objectProperty({path: shacl.oneOrMorePath, maxCount: 1, nodeKind: BLANK_OR_IRI})\n get oneOrMorePath(): unknown {\n return null;\n }\n\n @objectProperty({path: shacl.zeroOrOnePath, maxCount: 1, nodeKind: BLANK_OR_IRI})\n get zeroOrOnePath(): unknown {\n return null;\n }\n}\n"]}
@@ -113,21 +113,23 @@ export interface ObjectPropertyShapeConfig extends PropertyShapeConfig {
113
113
  */
114
114
  shape?: typeof Shape | [string, string];
115
115
  /**
116
- * Marks this property as *containment* (composition): the value(s) are owned by the subject.
117
- * For replace, set-remove and the class check, ownership is decided per predicate across the
118
- * registry: another shape's property on this predicate owns its values too.
116
+ * Marks this property as *containment* (composition): the value(s) are owned by the subject
117
+ * through this property. Ownership is per property: a plain property of another shape on the
118
+ * same predicate is a reference and owns nothing. Requires `shape` (throws otherwise).
119
119
  *
120
- * - With a `shape`: replacing, unsetting or set-removing a value deletes the old node's own
121
- * triples; deleting the subject (by id or in bulk) deletes its immediate values; re-sent
122
- * `{id}`s are kept. Linking an existing node by `{id}` is class-checked: it is refused when
123
- * the node is typed and none of its types is the shape's class, a registered sub-shape's,
124
- * or `sh:class`.
125
- * - Without a `shape` (a polymorphic slot): only `dependent`-typed values are deleted.
126
- * - In both cases the cascade follows the edge to `dependent`-typed descendants.
120
+ * - Replacing, unsetting or set-removing a value deletes the old node's own triples and blank
121
+ * values, and its owned subtree; re-sent `{id}`s are kept.
122
+ * - Deleting the subject (by id or in bulk) deletes its owned subtree (recursion other than a
123
+ * shape owning its own kind stops after `MAX_OWNED_RECURSION` re-entries): the values
124
+ * of its `contains` properties, the values their shapes own in turn, and the extra `contains`
125
+ * values of registered sub-shapes (followed only from nodes of the sub-shape's class).
126
+ * - Linking an existing node by `{id}` is class-checked: it is refused when the node is typed
127
+ * and none of its types is the shape's class, a registered sub-shape's, or `sh:class`.
127
128
  *
128
- * With a `shape`, shape sync also persists a generated SHACL shape for this property (at its
129
- * property shape's IRI plus `.singleOwner`, written by the declaring class only) that limits
130
- * each value of the predicate to one owner. It is not enforced on write.
129
+ * Shape sync also persists a generated SHACL shape for this property (at its property shape's
130
+ * IRI plus `.singleOwner`, written by the declaring class only) that limits each value of the
131
+ * predicate to one owner of the declaring class or a registered sub-shape's class. It is not
132
+ * enforced on write.
131
133
  */
132
134
  contains?: boolean;
133
135
  }
@@ -238,6 +238,14 @@ export function createPropertyShape(config, propertyKey, defaultNodeKind = null,
238
238
  propertyShape.class = toNodeReference(config.class);
239
239
  }
240
240
  if (config.contains) {
241
+ // Ownership is walked shape by shape, so an owned value needs a shape to walk into. A
242
+ // polymorphic slot holding blank structure needs no `contains`: blank values are deleted
243
+ // through their blank-capable `nodeKind`.
244
+ if (!config.shape) {
245
+ throw new Error(`The contains property "${propertyKey}" needs a \`shape\`: ownership follows the value ` +
246
+ `shape to what it owns in turn. Declare the value's shape, or drop \`contains\` (a blank ` +
247
+ `value is deleted through a blank-capable \`nodeKind\` without it).`);
248
+ }
241
249
  propertyShape.contains = true;
242
250
  }
243
251
  if (config.equals) {
@@ -1 +1 @@
1
- {"version":3,"file":"SHACL.js","sourceRoot":"","sources":["../../../src/shapes/SHACL.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAA0B,eAAe,EAAC,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAC,KAAK,EAAwB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAC,KAAK,EAAC,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAC,2BAA2B,EAAC,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAC,qBAAqB,EAAkC,MAAM,mCAAmC,CAAC;AACzG,OAAO,EACL,uBAAuB,EACvB,gBAAgB,IAAI,oBAAoB,EACxC,gBAAgB,IAAI,oBAAoB,EACxC,kBAAkB,GAGnB,MAAM,oBAAoB,CAAC;AAK5B,2EAA2E;AAC3E,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAW,oBAAoB,CAAC;AAE7D;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,OAAO,WAAW;SACf,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,kDAAkD;SAC3E,OAAO,CAAC,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B,GAAG,IAAI,GAAG,EAA8C,CAAC;AACjF,MAAM,UAAU,oBAAoB,CAClC,WAAmB;IAEnB,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACtD,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACvC,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,WAAmB,EACnB,QAAwC,EACxC,EAAE;IACF,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QACzC,kBAAkB,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACrD,CAAC,CAAC","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 */\nimport {type NodeReferenceValue, toNodeReference} from '../utils/NodeReference.js';\nimport {Shape, type ShapeConstructor} from './Shape.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {warnOnReservedPropertyLabel} from '../queries/reservedQueryNames.js';\nimport {getShapeClass} from '../utils/ShapeClass.js';\nimport type {PathExpr} from '../paths/PropertyPathExpr.js';\nimport {normalizePropertyPath, type PropertyPathDecoratorInput} from '../paths/normalizePropertyPath.js';\nimport {\n createPropertyShapeData,\n getPropertyShape as getPropertyShapeData,\n addPropertyShape as addPropertyShapeData,\n clonePropertyShape,\n type NodeShapeData,\n type PropertyShapeData,\n} from './nodeShapeData.js';\n\n// Metadata types now live in nodeShapeData.js (plain objects); re-exported here for\n// existing importers of `NodeShape`/`PropertyShape`-adjacent types.\nexport type {NodeShapeData, PropertyShapeData, PropertyShapeResult} from './nodeShapeData.js';\n// Metadata operations (formerly NodeShape/PropertyShape instance methods).\nexport {\n getPropertyShapes,\n getUniquePropertyShapes,\n getPropertyShape,\n addPropertyShape,\n clonePropertyShape,\n propertyShapeToResult,\n nodeShapeEquals,\n createNodeShapeData,\n createPropertyShapeData,\n} from './nodeShapeData.js';\n\n/**\n * Default identity root for shape & package IRIs. Public/first-party packages\n * publish under `linked.cm` (arch-02 §Domains). Packages may override per-package\n * via `linkedPackage(name, { baseUri })` — CN injects a workspace-scoped root\n * (`{workspaceSlug}.id.create.now`) for private packages; first-party packages\n * keep this default.\n */\nexport const LINKED_DATA_ROOT: string = 'https://linked.cm/';\n\n/**\n * Derive the public package slug — the npm package **basename** with the\n * `@scope/` dropped, kebab-cased (arch-02 §Slug rules: `^[a-z0-9]+(?:-[a-z0-9]+)*$`).\n * The package name is the single source of truth; there is no separate slug.\n * `@_linked/core` → `core`, `@linked.cm/blog` → `blog`, `mypkg` → `mypkg`.\n *\n * Both first-party (`@_linked`) and community (`@linked.cm`) packages publish into\n * the one `linked.cm/{shape,pkg}` space, so the basename must be globally unique —\n * enforced by the registry, which reserves the (handful of) first-party names.\n */\nexport function packageNameToSlug(packageName: string): string {\n return packageName\n .replace(/^@[^/]+\\//, '') // drop the npm scope (@scope/), keep the basename\n .replace(/[^a-zA-Z0-9]+/g, '-') // any run of non-alphanumerics → single hyphen\n .replace(/^-+|-+$/g, '') // trim stray hyphens\n .toLowerCase();\n}\n\n/**\n * Where each package publishes its IRIs (the identity root). The slug is always\n * derived from the package name; only the root is configurable — `linkedPackage`\n * defaults it to `LINKED_DATA_ROOT` (linked.cm), and CN injects a workspace-scoped\n * root (`{workspaceSlug}.id.create.now`) for private packages.\n */\nconst packageBaseUri = new Map<string, string>();\n\n/** Record a package's publish root. Called by `linkedPackage()`. */\nexport function setPackagePublishConfig(\n packageName: string,\n config?: {baseUri?: string},\n): void {\n packageBaseUri.set(packageName, config?.baseUri ?? LINKED_DATA_ROOT);\n}\n\n/** Resolve a package's publish root, defaulting to linked.cm if undeclared. */\nfunction resolveBaseUri(packageName: string): string {\n return packageBaseUri.get(packageName) ?? LINKED_DATA_ROOT;\n}\n\n/** Public/first-party package IRI — arch-02: `{baseUri}pkg/{slug}`. */\nexport function getPackageUri(packageName: string): string {\n return `${resolveBaseUri(packageName)}pkg/${packageNameToSlug(packageName)}`;\n}\n\ntype NodeKindConfig = NodeReferenceValue | NodeReferenceValue[];\n\nexport type PropertyPathInput = PropertyPathDecoratorInput;\nexport type PropertyPathInputList = PropertyPathDecoratorInput;\n\nconst normalizeNodeKind = (\n nodeKind?: NodeKindConfig,\n defaultNodeKind?: NodeReferenceValue,\n): NodeReferenceValue | undefined => {\n if (!nodeKind) {\n return defaultNodeKind;\n }\n if (Array.isArray(nodeKind)) {\n const ids = nodeKind.map((entry) => entry?.id);\n const includesBlank = ids.includes(shacl.BlankNode.id);\n const includesNamed = ids.includes(shacl.IRI.id);\n const includesLiteral = ids.includes(shacl.Literal.id);\n if (includesBlank && includesNamed) {\n return shacl.BlankNodeOrIRI;\n }\n if (includesLiteral && includesNamed) {\n return shacl.IRIOrLiteral;\n }\n if (includesLiteral && includesBlank) {\n return shacl.BlankNodeOrLiteral;\n }\n return nodeKind[0];\n }\n return nodeKind;\n};\n\nexport interface NodeShapeConfig {\n /**\n * Set to true to close the shape. This means any target node of this shape\n * that has properties outside the defined properties of this shape is invalid.\n */\n closed?: boolean;\n /**\n * Optional list of properties that are also permitted in addition to those explicitly listed by this shape.\n */\n ignoredProperties?: NodeReferenceValue[];\n}\n\nexport interface LiteralPropertyShapeConfig extends PropertyShapeConfig {\n nodeKind?: NodeReferenceValue;\n /**\n * Values of the configured property must be less than the values of this 'lessThan' property.\n * Value is always a property IRI (pair constraint).\n */\n lessThan?: NodeReferenceValue;\n /**\n * Values of the configured property must be less than or equal the values of this 'lessThanOrEquals' property.\n * Value is always a property IRI (pair constraint).\n */\n lessThanOrEquals?: NodeReferenceValue;\n /**\n * All values of this property must be higher than this number\n */\n minExclusive?: number | string;\n /**\n * All values of this property must be higher than or equal this number\n */\n minInclusive?: number;\n /**\n * All values of this property must be lower than this number\n */\n maxExclusive?: number;\n /**\n * All values of this property must be lower than or equal this number\n */\n maxInclusive?: number;\n /**\n * All literal values of this property must at least be this long\n */\n minLength?: number;\n /**\n * All literal values of this property must at most be this long\n */\n maxLength?: number;\n /**\n * All literal values of this property must match this regular expression\n */\n pattern?: RegExp;\n /**\n * All literal values of this property must have one of these languages as their language tag\n */\n languageIn?: string[];\n /**\n * No pair of values may use the same language tag.\n */\n uniqueLang?: boolean;\n /**\n * Each literal value of this property must use this datatype\n */\n datatype?: NodeReferenceValue;\n /**\n * Each value of the property must occur in this set.\n * Use {id: '...'} for IRI nodes, or plain strings/numbers/booleans for literal values.\n */\n in?: (NodeReferenceValue | string | number | boolean)[];\n}\n\nexport interface ObjectPropertyShapeConfig extends PropertyShapeConfig {\n nodeKind?: NodeReferenceValue;\n /**\n * Each value of this property must have this class as its rdf:type\n */\n class?: NodeReferenceValue;\n /**\n * The shape that values of this property path need to confirm to.\n * You need to provide a class that extends Shape.\n */\n shape?: typeof Shape | [string, string];\n /**\n * Marks this property as *containment* (composition): the value(s) are owned by the subject.\n * For replace, set-remove and the class check, ownership is decided per predicate across the\n * registry: another shape's property on this predicate owns its values too.\n *\n * - With a `shape`: replacing, unsetting or set-removing a value deletes the old node's own\n * triples; deleting the subject (by id or in bulk) deletes its immediate values; re-sent\n * `{id}`s are kept. Linking an existing node by `{id}` is class-checked: it is refused when\n * the node is typed and none of its types is the shape's class, a registered sub-shape's,\n * or `sh:class`.\n * - Without a `shape` (a polymorphic slot): only `dependent`-typed values are deleted.\n * - In both cases the cascade follows the edge to `dependent`-typed descendants.\n *\n * With a `shape`, shape sync also persists a generated SHACL shape for this property (at its\n * property shape's IRI plus `.singleOwner`, written by the declaring class only) that limits\n * each value of the predicate to one owner. It is not enforced on write.\n */\n contains?: boolean;\n}\n\nexport interface PropertyShapeConfig {\n /**\n * The property path of this property shape.\n *\n * Four accepted forms, all equivalent where they overlap:\n *\n * - **An ontology term** — `documents.confidence`. The idiom for real shapes: it reuses the\n * ontology, so a namespace changes in one place. `createNameSpace` returns a `{id}` ref, so\n * the term IS the second form and is passed DIRECTLY — never `documents.confidence.id`,\n * which unwraps it back to a bare string.\n * - **A node reference** — `{id: 'https://example.org/vocab#startsAt'}`. What the first form\n * produces. Convenient in tests, or wherever an ontology module would be overkill.\n * - **A bare IRI or prefixed name** — `'https://example.org/vocab#startsAt'`, `'ex:startsAt'`.\n * - **A path expression** — `'ex:a/ex:b'`, `{seq: [...]}`, `{inv: ...}`, and the other\n * operators. An array is read as a sequence.\n *\n * A string is parsed as an expression only when it is not a bare absolute IRI: `ex:a/ex:b` is\n * a sequence, while the `/` inside `https://example.org/vocab#x` belongs to the IRI.\n */\n path: PropertyPathInputList;\n /**\n * Indicates that this property must exist.\n * Shorthand for minCount=1\n */\n required?: boolean;\n /**\n * Each value must be of this node type.\n */\n nodeKind?: NodeKindConfig;\n /**\n * Minimum number of values required\n */\n minCount?: number;\n /**\n * Maximum number of values allowed\n */\n maxCount?: number;\n /**\n * Values of the configured property must equal the values of this 'equals' property.\n * Value is always a property IRI (pair constraint).\n */\n equals?: NodeReferenceValue;\n /**\n * Values of the configured property must differ from the values of this 'disjoint' property.\n * Value is always a property IRI (pair constraint).\n */\n disjoint?: NodeReferenceValue;\n /**\n * At least one value of this property must equal the given value.\n * Use {id: '...'} for IRI nodes, or a plain string for literal values.\n */\n hasValue?: NodeReferenceValue | string | number | boolean;\n name?: string;\n description?: string;\n order?: number;\n group?: string;\n /**\n * Display importance, lower = more important (`core:displayRank`).\n * A renderer that can show only N properties shows the N lowest ranks.\n */\n displayRank?: number;\n /** Omit this property from generic rendering (`core:displayHidden`). */\n displayHidden?: boolean;\n /**\n * should correlate to the given datatype or class\n */\n defaultValue?: unknown;\n /**\n * Each value of the property must occur in this set.\n * Use {id: '...'} for IRI nodes, or plain strings for literal values.\n *\n * @example\n * in: ['ACTIVE', 'PENDING', 'CLOSED']\n * in: [{id: 'http://example.org/StatusA'}, {id: 'http://example.org/StatusB'}]\n */\n in?: (NodeReferenceValue | string | number | boolean)[];\n /**\n * Values of the configured property path are sorted by the values of this property path.\n */\n sortBy?: PropertyPathInputList;\n}\n\nconst EXPLICIT_NODE_KIND_SYMBOL = Symbol('explicitNodeKind');\nconst EXPLICIT_MIN_COUNT_SYMBOL = Symbol('explicitMinCount');\nconst EXPLICIT_MAX_COUNT_SYMBOL = Symbol('explicitMaxCount');\n\n/** Internal symbol-keyed flags on a PropertyShapeData object to track which fields were explicitly configured. */\ninterface ExplicitFlags {\n [EXPLICIT_NODE_KIND_SYMBOL]?: boolean;\n [EXPLICIT_MIN_COUNT_SYMBOL]?: boolean;\n [EXPLICIT_MAX_COUNT_SYMBOL]?: boolean;\n}\n\nexport interface ParameterConfig {\n optional?: number;\n}\n\n/**\n * Static-only DSL handle for the SHACL `sh:NodeShape` meta-shape.\n *\n * Never instantiated — a shape's metadata is a plain {@link NodeShapeData} object\n * (see nodeShapeData.js), and the instance methods that used to live here are now\n * free functions in that module. This class exists only to carry the meta-shape's\n * static `.shape` self-description and to serve as the DSL entry point for reading\n * and writing node-shape SHACL data (`NodeShape.create/select/delete`).\n */\nexport class NodeShape extends Shape {\n static targetClass = shacl.NodeShape;\n}\n\n/**\n * Static-only DSL handle for the SHACL `sh:PropertyShape` meta-shape.\n *\n * Never instantiated — property-shape metadata is a plain {@link PropertyShapeData}\n * object (see nodeShapeData.js). Exists only for its static `.shape` self-description\n * and as a DSL entry point (`PropertyShape.create/select`).\n */\nexport class PropertyShape extends Shape {\n static targetClass = shacl.PropertyShape;\n}\n\nconst connectValueShape = <\n Config extends LiteralPropertyShapeConfig | ObjectPropertyShapeConfig,\n>(\n config: Config,\n propertyKey: string,\n property: PropertyShapeData,\n) => {\n if ((config as ObjectPropertyShapeConfig).shape) {\n const shapeConfig = (config as ObjectPropertyShapeConfig).shape;\n\n if (Array.isArray(shapeConfig)) {\n const [packageName, shapeName] = shapeConfig;\n const nodeShapeUri = getNodeShapeUri(packageName, shapeName);\n property.valueShape = {id: nodeShapeUri};\n } else {\n const shapeClass = shapeConfig as typeof Shape;\n if (shapeClass.shape) {\n property.valueShape = {id: shapeClass.shape.id};\n } else {\n onShapeSetup(\n shapeConfig,\n (nodeShape: NodeShapeData) => {\n property.valueShape = {id: nodeShape.id};\n },\n propertyKey,\n );\n }\n }\n }\n};\n\n/**\n * The DSL-JSON where-clause combinators. A property may not be named after one,\n * because a condition key in those positions has no `{path}` escape (the key is a\n * bare string). See documentation/dsl-json.md (Reserved words).\n */\nconst RESERVED_PROPERTY_LABELS = new Set(['and', 'or', 'not']);\n\nexport function registerPropertyShape(\n shape: NodeShapeData,\n propertyShape: PropertyShapeData,\n) {\n if (RESERVED_PROPERTY_LABELS.has(propertyShape.label)) {\n throw new Error(\n `Property label '${propertyShape.label}' is reserved (a DSL-JSON boolean combinator) ` +\n `and cannot be used as a property name. See documentation/dsl-json.md (Reserved words).`,\n );\n }\n // Not fatal, but the author needs to hear it here rather than from the field tracer.\n warnOnReservedPropertyLabel(propertyShape.label, shape.label, shape.id);\n const inherited = getPropertyShapeData(shape, propertyShape.label, true);\n const existing = getPropertyShapeData(shape, propertyShape.label, false);\n if (!existing && inherited) {\n if (!(propertyShape as unknown as ExplicitFlags)[EXPLICIT_MIN_COUNT_SYMBOL]) {\n propertyShape.minCount = inherited.minCount;\n }\n if (!(propertyShape as unknown as ExplicitFlags)[EXPLICIT_MAX_COUNT_SYMBOL]) {\n propertyShape.maxCount = inherited.maxCount;\n }\n if (!(propertyShape as unknown as ExplicitFlags)[EXPLICIT_NODE_KIND_SYMBOL]) {\n propertyShape.nodeKind = inherited.nodeKind;\n }\n validateOverrideTightening(shape, inherited, propertyShape);\n }\n if (existing) {\n Object.assign(existing, propertyShape);\n return existing;\n }\n propertyShape.id = `${shape.id}/${propertyShape.label}`;\n addPropertyShapeData(shape, propertyShape);\n return propertyShape;\n}\n\nconst ATOMIC_NODE_KINDS = [\n shacl.BlankNode.id,\n shacl.IRI.id,\n shacl.Literal.id,\n];\n\nconst nodeKindToAtomics = (nodeKind?: NodeReferenceValue): Set<string> => {\n if (!nodeKind?.id) {\n return new Set();\n }\n switch (nodeKind.id) {\n case shacl.BlankNode.id:\n case shacl.IRI.id:\n case shacl.Literal.id:\n return new Set([nodeKind.id]);\n case shacl.BlankNodeOrIRI.id:\n return new Set([shacl.BlankNode.id, shacl.IRI.id]);\n case shacl.IRIOrLiteral.id:\n return new Set([shacl.IRI.id, shacl.Literal.id]);\n case shacl.BlankNodeOrLiteral.id:\n return new Set([shacl.BlankNode.id, shacl.Literal.id]);\n default:\n return new Set(ATOMIC_NODE_KINDS);\n }\n};\n\nconst throwOverrideError = (\n shape: NodeShapeData,\n propertyShape: PropertyShapeData,\n message: string,\n) => {\n throw new Error(\n `Invalid override for ${shape.label}.${propertyShape.label}: ${message}`,\n );\n};\n\nconst validateOverrideTightening = (\n shape: NodeShapeData,\n base: PropertyShapeData,\n override: PropertyShapeData,\n) => {\n if (\n typeof base.minCount === 'number' &&\n typeof override.minCount === 'number' &&\n override.minCount < base.minCount\n ) {\n throwOverrideError(\n shape,\n override,\n `minCount cannot be lowered (${base.minCount} -> ${override.minCount}).`,\n );\n }\n\n if (\n typeof base.maxCount === 'number' &&\n typeof override.maxCount === 'number' &&\n override.maxCount > base.maxCount\n ) {\n throwOverrideError(\n shape,\n override,\n `maxCount cannot be increased (${base.maxCount} -> ${override.maxCount}).`,\n );\n }\n\n if (base.nodeKind && override.nodeKind) {\n const baseKinds = nodeKindToAtomics(base.nodeKind);\n const overrideKinds = nodeKindToAtomics(override.nodeKind);\n const widensNodeKind = [...overrideKinds].some((kind) => !baseKinds.has(kind));\n if (widensNodeKind) {\n throwOverrideError(\n shape,\n override,\n `nodeKind cannot be widened (${base.nodeKind.id} -> ${override.nodeKind.id}).`,\n );\n }\n }\n};\n\nexport function createPropertyShape<\n Config extends LiteralPropertyShapeConfig | ObjectPropertyShapeConfig,\n>(\n config: Config,\n propertyKey: string,\n defaultNodeKind: NodeReferenceValue = null,\n shapeClass: typeof Shape | [string, string] = null,\n) {\n const propertyShape = createPropertyShapeData();\n propertyShape.path = normalizePropertyPath(config.path);\n propertyShape.label = propertyKey;\n\n if (config.name) {\n propertyShape.name = config.name;\n }\n if (config.description) {\n propertyShape.description = config.description;\n }\n\n if (config.required) {\n propertyShape.minCount = 1;\n } else if (config.minCount !== undefined) {\n propertyShape.minCount = config.minCount;\n }\n (propertyShape as unknown as ExplicitFlags)[EXPLICIT_MIN_COUNT_SYMBOL] =\n config.required === true || config.minCount !== undefined;\n\n if (config.maxCount !== undefined) {\n propertyShape.maxCount = config.maxCount;\n }\n (propertyShape as unknown as ExplicitFlags)[EXPLICIT_MAX_COUNT_SYMBOL] =\n config.maxCount !== undefined;\n if ((config as LiteralPropertyShapeConfig).datatype) {\n propertyShape.datatype = toNodeReference(\n (config as LiteralPropertyShapeConfig).datatype,\n );\n }\n\n if ((config as ObjectPropertyShapeConfig).class) {\n propertyShape.class = toNodeReference(\n (config as ObjectPropertyShapeConfig).class,\n );\n }\n\n if ((config as ObjectPropertyShapeConfig).contains) {\n propertyShape.contains = true;\n }\n\n if (config.equals) {\n propertyShape.equalsConstraint = toNodeReference(config.equals);\n }\n if (config.disjoint) {\n propertyShape.disjoint = toNodeReference(config.disjoint);\n }\n if ((config as LiteralPropertyShapeConfig).lessThan) {\n propertyShape.lessThan = toNodeReference((config as LiteralPropertyShapeConfig).lessThan);\n }\n if ((config as LiteralPropertyShapeConfig).lessThanOrEquals) {\n propertyShape.lessThanOrEquals = toNodeReference((config as LiteralPropertyShapeConfig).lessThanOrEquals);\n }\n // Value-range / string-length / pattern constraints (report 021 §3, G5). These are\n // recorded on the shape and serialized to SHACL; there is no DSL-side runtime\n // enforcement — they describe the shape for validators / introspection.\n {\n const lit = config as LiteralPropertyShapeConfig;\n if (lit.minInclusive !== undefined) propertyShape.minInclusive = lit.minInclusive;\n if (lit.maxInclusive !== undefined) propertyShape.maxInclusive = lit.maxInclusive;\n if (lit.minExclusive !== undefined) propertyShape.minExclusive = lit.minExclusive;\n if (lit.maxExclusive !== undefined) propertyShape.maxExclusive = lit.maxExclusive;\n if (lit.minLength !== undefined) propertyShape.minLength = lit.minLength;\n if (lit.maxLength !== undefined) propertyShape.maxLength = lit.maxLength;\n if (lit.pattern !== undefined) propertyShape.pattern = lit.pattern;\n }\n if (config.hasValue !== undefined) {\n const v = config.hasValue;\n propertyShape.hasValueConstraint = typeof v === 'object' && v !== null ? toNodeReference(v) : v;\n }\n if (config.defaultValue !== undefined) {\n propertyShape.defaultValue = config.defaultValue;\n }\n if (config.in) {\n propertyShape.in = config.in.map((entry) =>\n typeof entry === 'object' && entry !== null ? toNodeReference(entry) : entry,\n );\n }\n if (config.sortBy) {\n propertyShape.sortBy = normalizePropertyPath(config.sortBy);\n }\n // Arrangement + display metadata. `order` and `group` were declared on the config\n // but never copied onto the property shape, so a declared `sh:order` was silently\n // dropped and every renderer fell back to array position. Carried now, alongside\n // the two display terms.\n if (config.order !== undefined) propertyShape.order = config.order;\n if (config.group !== undefined) propertyShape.group = config.group;\n if (config.displayRank !== undefined) propertyShape.displayRank = config.displayRank;\n if (config.displayHidden !== undefined)\n propertyShape.displayHidden = config.displayHidden;\n\n propertyShape.nodeKind = normalizeNodeKind(config.nodeKind, defaultNodeKind);\n (propertyShape as unknown as ExplicitFlags)[EXPLICIT_NODE_KIND_SYMBOL] =\n config.nodeKind !== undefined;\n\n if (shapeClass) {\n onShapeSetup(shapeClass, (shape: NodeShapeData) => {\n connectValueShape(config, propertyKey, propertyShape);\n registerPropertyShape(shape, propertyShape);\n });\n }\n\n return propertyShape;\n}\n\nexport function onShapeSetup(\n shapeClass: typeof Shape | [string, string],\n callback: (shape: NodeShapeData) => void,\n propertyName?: string,\n waitForSuperShapes?: boolean,\n) {\n const cb = waitForSuperShapes\n ? (shape: NodeShapeData) => {\n const superClass = Object.getPrototypeOf(shapeClass) as typeof Shape;\n if (superClass.name === 'Shape') {\n callback(shape);\n return;\n }\n if (superClass.name === '') {\n console.error(\n `Shape ${shape.label} does not extend base class lincd/shapes/Shape. Make sure it extends Shape.`,\n );\n return;\n }\n onShapeSetup(\n superClass,\n () => {\n callback(shape);\n },\n propertyName,\n waitForSuperShapes,\n );\n }\n : callback;\n\n const safeCallback = (\n targetShapeClass: typeof Shape,\n innerCallback: (shape: NodeShapeData) => void,\n ) => {\n if (targetShapeClass.hasOwnProperty('shape')) {\n innerCallback((targetShapeClass as typeof Shape).shape);\n } else {\n if (!targetShapeClass['shapeCallbacks']) {\n targetShapeClass['shapeCallbacks'] = [];\n }\n targetShapeClass['shapeCallbacks'].push(innerCallback);\n }\n };\n\n if (Array.isArray(shapeClass)) {\n const [packageName, shapeName] = shapeClass;\n const nodeShapeId = getNodeShapeUri(packageName, shapeName);\n if (typeof document !== 'undefined') {\n window.addEventListener('load', () => {\n const resolved = getShapeClass(nodeShapeId);\n if (!resolved) {\n console.warn(\n `Could not find value shape (${packageName}/${shapeName}) for accessor get ${propertyName}(). Likely because it is not bundled.`,\n );\n return;\n }\n safeCallback(resolved as unknown as typeof Shape, cb);\n });\n } else {\n addNodeShapeCallback(nodeShapeId, cb);\n }\n } else {\n safeCallback(shapeClass, cb);\n }\n}\n\nconst _linkedProperty = <\n Config extends ObjectPropertyShapeConfig | LiteralPropertyShapeConfig,\n>(\n config: Config,\n defaultNodeKind: NodeReferenceValue = null,\n) => {\n return function (\n target: any,\n propertyKey: string,\n _descriptor: PropertyDescriptor,\n ) {\n createPropertyShape(config, propertyKey, defaultNodeKind, target.constructor);\n };\n};\n\nexport const literalProperty = (config: LiteralPropertyShapeConfig) => {\n return _linkedProperty<LiteralPropertyShapeConfig>(config, shacl.Literal);\n};\n\nexport const objectProperty = (config: ObjectPropertyShapeConfig) => {\n return _linkedProperty<ObjectPropertyShapeConfig>(config, shacl.IRI);\n};\n\nexport const linkedProperty = (\n config: ObjectPropertyShapeConfig | LiteralPropertyShapeConfig,\n) => {\n return _linkedProperty(config);\n};\n\nexport function disallowProperty(\n target: any,\n propertyKey: string,\n _descriptor: PropertyDescriptor,\n) {\n onShapeSetup(\n target.constructor,\n (shape: NodeShapeData) => {\n const superClass = Object.getPrototypeOf(target.constructor) as typeof Shape;\n const superNodeShape = superClass.shape;\n const superPropertyShape = getPropertyShapeData(\n superNodeShape,\n propertyKey,\n true,\n );\n if (!superPropertyShape) {\n console.warn(\n `Property ${propertyKey} not found in super class ${superClass.name} or any of its super classes. Does it have a property decorator? Cannot disallow property ${target.constructor.name}.${propertyKey}`,\n );\n return;\n }\n const clonedPropertyShape = clonePropertyShape(superPropertyShape);\n clonedPropertyShape.maxCount = 0;\n registerPropertyShape(shape, clonedPropertyShape);\n },\n '',\n true,\n );\n}\n\nexport function getNodeShapeUri(packageName: string, shapeName: string): string {\n // arch-02: `{baseUri}shape/{packageSlug}/{ShapeName}` — ShapeName kept PascalCase\n // (it is a class name, already URI-safe), packageSlug derived from the name.\n return `${resolveBaseUri(packageName)}shape/${packageNameToSlug(packageName)}/${shapeName}`;\n}\n\nconst nodeShapeCallbacks = new Map<string, ((shape: NodeShapeData) => void)[]>();\nexport function getAndClearCallbacks(\n nodeShapeId: string,\n): ((shape: NodeShapeData) => void)[] {\n const callbacks = nodeShapeCallbacks.get(nodeShapeId);\n nodeShapeCallbacks.delete(nodeShapeId);\n return callbacks;\n}\nexport const addNodeShapeCallback = (\n nodeShapeId: string,\n callback: (shape: NodeShapeData) => void,\n) => {\n if (!nodeShapeCallbacks.has(nodeShapeId)) {\n nodeShapeCallbacks.set(nodeShapeId, []);\n }\n nodeShapeCallbacks.get(nodeShapeId).push(callback);\n};\n"]}
1
+ {"version":3,"file":"SHACL.js","sourceRoot":"","sources":["../../../src/shapes/SHACL.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAA0B,eAAe,EAAC,MAAM,2BAA2B,CAAC;AACnF,OAAO,EAAC,KAAK,EAAwB,MAAM,YAAY,CAAC;AACxD,OAAO,EAAC,KAAK,EAAC,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,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QACzC,kBAAkB,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;IACD,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACrD,CAAC,CAAC","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 */\nimport {type NodeReferenceValue, toNodeReference} from '../utils/NodeReference.js';\nimport {Shape, type ShapeConstructor} from './Shape.js';\nimport {shacl} from '../ontologies/shacl.js';\nimport {warnOnReservedPropertyLabel} from '../queries/reservedQueryNames.js';\nimport {getShapeClass} from '../utils/ShapeClass.js';\nimport type {PathExpr} from '../paths/PropertyPathExpr.js';\nimport {normalizePropertyPath, type PropertyPathDecoratorInput} from '../paths/normalizePropertyPath.js';\nimport {\n createPropertyShapeData,\n getPropertyShape as getPropertyShapeData,\n addPropertyShape as addPropertyShapeData,\n clonePropertyShape,\n type NodeShapeData,\n type PropertyShapeData,\n} from './nodeShapeData.js';\n\n// Metadata types now live in nodeShapeData.js (plain objects); re-exported here for\n// existing importers of `NodeShape`/`PropertyShape`-adjacent types.\nexport type {NodeShapeData, PropertyShapeData, PropertyShapeResult} from './nodeShapeData.js';\n// Metadata operations (formerly NodeShape/PropertyShape instance methods).\nexport {\n getPropertyShapes,\n getUniquePropertyShapes,\n getPropertyShape,\n addPropertyShape,\n clonePropertyShape,\n propertyShapeToResult,\n nodeShapeEquals,\n createNodeShapeData,\n createPropertyShapeData,\n} from './nodeShapeData.js';\n\n/**\n * Default identity root for shape & package IRIs. Public/first-party packages\n * publish under `linked.cm` (arch-02 §Domains). Packages may override per-package\n * via `linkedPackage(name, { baseUri })` — CN injects a workspace-scoped root\n * (`{workspaceSlug}.id.create.now`) for private packages; first-party packages\n * keep this default.\n */\nexport const LINKED_DATA_ROOT: string = 'https://linked.cm/';\n\n/**\n * Derive the public package slug — the npm package **basename** with the\n * `@scope/` dropped, kebab-cased (arch-02 §Slug rules: `^[a-z0-9]+(?:-[a-z0-9]+)*$`).\n * The package name is the single source of truth; there is no separate slug.\n * `@_linked/core` → `core`, `@linked.cm/blog` → `blog`, `mypkg` → `mypkg`.\n *\n * Both first-party (`@_linked`) and community (`@linked.cm`) packages publish into\n * the one `linked.cm/{shape,pkg}` space, so the basename must be globally unique —\n * enforced by the registry, which reserves the (handful of) first-party names.\n */\nexport function packageNameToSlug(packageName: string): string {\n return packageName\n .replace(/^@[^/]+\\//, '') // drop the npm scope (@scope/), keep the basename\n .replace(/[^a-zA-Z0-9]+/g, '-') // any run of non-alphanumerics → single hyphen\n .replace(/^-+|-+$/g, '') // trim stray hyphens\n .toLowerCase();\n}\n\n/**\n * Where each package publishes its IRIs (the identity root). The slug is always\n * derived from the package name; only the root is configurable — `linkedPackage`\n * defaults it to `LINKED_DATA_ROOT` (linked.cm), and CN injects a workspace-scoped\n * root (`{workspaceSlug}.id.create.now`) for private packages.\n */\nconst packageBaseUri = new Map<string, string>();\n\n/** Record a package's publish root. Called by `linkedPackage()`. */\nexport function setPackagePublishConfig(\n packageName: string,\n config?: {baseUri?: string},\n): void {\n packageBaseUri.set(packageName, config?.baseUri ?? LINKED_DATA_ROOT);\n}\n\n/** Resolve a package's publish root, defaulting to linked.cm if undeclared. */\nfunction resolveBaseUri(packageName: string): string {\n return packageBaseUri.get(packageName) ?? LINKED_DATA_ROOT;\n}\n\n/** Public/first-party package IRI — arch-02: `{baseUri}pkg/{slug}`. */\nexport function getPackageUri(packageName: string): string {\n return `${resolveBaseUri(packageName)}pkg/${packageNameToSlug(packageName)}`;\n}\n\ntype NodeKindConfig = NodeReferenceValue | NodeReferenceValue[];\n\nexport type PropertyPathInput = PropertyPathDecoratorInput;\nexport type PropertyPathInputList = PropertyPathDecoratorInput;\n\nconst normalizeNodeKind = (\n nodeKind?: NodeKindConfig,\n defaultNodeKind?: NodeReferenceValue,\n): NodeReferenceValue | undefined => {\n if (!nodeKind) {\n return defaultNodeKind;\n }\n if (Array.isArray(nodeKind)) {\n const ids = nodeKind.map((entry) => entry?.id);\n const includesBlank = ids.includes(shacl.BlankNode.id);\n const includesNamed = ids.includes(shacl.IRI.id);\n const includesLiteral = ids.includes(shacl.Literal.id);\n if (includesBlank && includesNamed) {\n return shacl.BlankNodeOrIRI;\n }\n if (includesLiteral && includesNamed) {\n return shacl.IRIOrLiteral;\n }\n if (includesLiteral && includesBlank) {\n return shacl.BlankNodeOrLiteral;\n }\n return nodeKind[0];\n }\n return nodeKind;\n};\n\nexport interface NodeShapeConfig {\n /**\n * Set to true to close the shape. This means any target node of this shape\n * that has properties outside the defined properties of this shape is invalid.\n */\n closed?: boolean;\n /**\n * Optional list of properties that are also permitted in addition to those explicitly listed by this shape.\n */\n ignoredProperties?: NodeReferenceValue[];\n}\n\nexport interface LiteralPropertyShapeConfig extends PropertyShapeConfig {\n nodeKind?: NodeReferenceValue;\n /**\n * Values of the configured property must be less than the values of this 'lessThan' property.\n * Value is always a property IRI (pair constraint).\n */\n lessThan?: NodeReferenceValue;\n /**\n * Values of the configured property must be less than or equal the values of this 'lessThanOrEquals' property.\n * Value is always a property IRI (pair constraint).\n */\n lessThanOrEquals?: NodeReferenceValue;\n /**\n * All values of this property must be higher than this number\n */\n minExclusive?: number | string;\n /**\n * All values of this property must be higher than or equal this number\n */\n minInclusive?: number;\n /**\n * All values of this property must be lower than this number\n */\n maxExclusive?: number;\n /**\n * All values of this property must be lower than or equal this number\n */\n maxInclusive?: number;\n /**\n * All literal values of this property must at least be this long\n */\n minLength?: number;\n /**\n * All literal values of this property must at most be this long\n */\n maxLength?: number;\n /**\n * All literal values of this property must match this regular expression\n */\n pattern?: RegExp;\n /**\n * All literal values of this property must have one of these languages as their language tag\n */\n languageIn?: string[];\n /**\n * No pair of values may use the same language tag.\n */\n uniqueLang?: boolean;\n /**\n * Each literal value of this property must use this datatype\n */\n datatype?: NodeReferenceValue;\n /**\n * Each value of the property must occur in this set.\n * Use {id: '...'} for IRI nodes, or plain strings/numbers/booleans for literal values.\n */\n in?: (NodeReferenceValue | string | number | boolean)[];\n}\n\nexport interface ObjectPropertyShapeConfig extends PropertyShapeConfig {\n nodeKind?: NodeReferenceValue;\n /**\n * Each value of this property must have this class as its rdf:type\n */\n class?: NodeReferenceValue;\n /**\n * The shape that values of this property path need to confirm to.\n * You need to provide a class that extends Shape.\n */\n shape?: typeof Shape | [string, string];\n /**\n * Marks this property as *containment* (composition): the value(s) are owned by the subject\n * through this property. Ownership is per property: a plain property of another shape on the\n * same predicate is a reference and owns nothing. Requires `shape` (throws otherwise).\n *\n * - Replacing, unsetting or set-removing a value deletes the old node's own triples and blank\n * values, and its owned subtree; re-sent `{id}`s are kept.\n * - Deleting the subject (by id or in bulk) deletes its owned subtree (recursion other than a\n * shape owning its own kind stops after `MAX_OWNED_RECURSION` re-entries): the values\n * of its `contains` properties, the values their shapes own in turn, and the extra `contains`\n * values of registered sub-shapes (followed only from nodes of the sub-shape's class).\n * - Linking an existing node by `{id}` is class-checked: it is refused when the node is typed\n * and none of its types is the shape's class, a registered sub-shape's, or `sh:class`.\n *\n * Shape sync also persists a generated SHACL shape for this property (at its property shape's\n * IRI plus `.singleOwner`, written by the declaring class only) that limits each value of the\n * predicate to one owner of the declaring class or a registered sub-shape's class. It is not\n * enforced on write.\n */\n contains?: boolean;\n}\n\nexport interface PropertyShapeConfig {\n /**\n * The property path of this property shape.\n *\n * Four accepted forms, all equivalent where they overlap:\n *\n * - **An ontology term** — `documents.confidence`. The idiom for real shapes: it reuses the\n * ontology, so a namespace changes in one place. `createNameSpace` returns a `{id}` ref, so\n * the term IS the second form and is passed DIRECTLY — never `documents.confidence.id`,\n * which unwraps it back to a bare string.\n * - **A node reference** — `{id: 'https://example.org/vocab#startsAt'}`. What the first form\n * produces. Convenient in tests, or wherever an ontology module would be overkill.\n * - **A bare IRI or prefixed name** — `'https://example.org/vocab#startsAt'`, `'ex:startsAt'`.\n * - **A path expression** — `'ex:a/ex:b'`, `{seq: [...]}`, `{inv: ...}`, and the other\n * operators. An array is read as a sequence.\n *\n * A string is parsed as an expression only when it is not a bare absolute IRI: `ex:a/ex:b` is\n * a sequence, while the `/` inside `https://example.org/vocab#x` belongs to the IRI.\n */\n path: PropertyPathInputList;\n /**\n * Indicates that this property must exist.\n * Shorthand for minCount=1\n */\n required?: boolean;\n /**\n * Each value must be of this node type.\n */\n nodeKind?: NodeKindConfig;\n /**\n * Minimum number of values required\n */\n minCount?: number;\n /**\n * Maximum number of values allowed\n */\n maxCount?: number;\n /**\n * Values of the configured property must equal the values of this 'equals' property.\n * Value is always a property IRI (pair constraint).\n */\n equals?: NodeReferenceValue;\n /**\n * Values of the configured property must differ from the values of this 'disjoint' property.\n * Value is always a property IRI (pair constraint).\n */\n disjoint?: NodeReferenceValue;\n /**\n * At least one value of this property must equal the given value.\n * Use {id: '...'} for IRI nodes, or a plain string for literal values.\n */\n hasValue?: NodeReferenceValue | string | number | boolean;\n name?: string;\n description?: string;\n order?: number;\n group?: string;\n /**\n * Display importance, lower = more important (`core:displayRank`).\n * A renderer that can show only N properties shows the N lowest ranks.\n */\n displayRank?: number;\n /** Omit this property from generic rendering (`core:displayHidden`). */\n displayHidden?: boolean;\n /**\n * should correlate to the given datatype or class\n */\n defaultValue?: unknown;\n /**\n * Each value of the property must occur in this set.\n * Use {id: '...'} for IRI nodes, or plain strings for literal values.\n *\n * @example\n * in: ['ACTIVE', 'PENDING', 'CLOSED']\n * in: [{id: 'http://example.org/StatusA'}, {id: 'http://example.org/StatusB'}]\n */\n in?: (NodeReferenceValue | string | number | boolean)[];\n /**\n * Values of the configured property path are sorted by the values of this property path.\n */\n sortBy?: PropertyPathInputList;\n}\n\nconst EXPLICIT_NODE_KIND_SYMBOL = Symbol('explicitNodeKind');\nconst EXPLICIT_MIN_COUNT_SYMBOL = Symbol('explicitMinCount');\nconst EXPLICIT_MAX_COUNT_SYMBOL = Symbol('explicitMaxCount');\n\n/** Internal symbol-keyed flags on a PropertyShapeData object to track which fields were explicitly configured. */\ninterface ExplicitFlags {\n [EXPLICIT_NODE_KIND_SYMBOL]?: boolean;\n [EXPLICIT_MIN_COUNT_SYMBOL]?: boolean;\n [EXPLICIT_MAX_COUNT_SYMBOL]?: boolean;\n}\n\nexport interface ParameterConfig {\n optional?: number;\n}\n\n/**\n * Static-only DSL handle for the SHACL `sh:NodeShape` meta-shape.\n *\n * Never instantiated — a shape's metadata is a plain {@link NodeShapeData} object\n * (see nodeShapeData.js), and the instance methods that used to live here are now\n * free functions in that module. This class exists only to carry the meta-shape's\n * static `.shape` self-description and to serve as the DSL entry point for reading\n * and writing node-shape SHACL data (`NodeShape.create/select/delete`).\n */\nexport class NodeShape extends Shape {\n static targetClass = shacl.NodeShape;\n}\n\n/**\n * Static-only DSL handle for the SHACL `sh:PropertyShape` meta-shape.\n *\n * Never instantiated — property-shape metadata is a plain {@link PropertyShapeData}\n * object (see nodeShapeData.js). Exists only for its static `.shape` self-description\n * and as a DSL entry point (`PropertyShape.create/select`).\n */\nexport class PropertyShape extends Shape {\n static targetClass = shacl.PropertyShape;\n}\n\nconst connectValueShape = <\n Config extends LiteralPropertyShapeConfig | ObjectPropertyShapeConfig,\n>(\n config: Config,\n propertyKey: string,\n property: PropertyShapeData,\n) => {\n if ((config as ObjectPropertyShapeConfig).shape) {\n const shapeConfig = (config as ObjectPropertyShapeConfig).shape;\n\n if (Array.isArray(shapeConfig)) {\n const [packageName, shapeName] = shapeConfig;\n const nodeShapeUri = getNodeShapeUri(packageName, shapeName);\n property.valueShape = {id: nodeShapeUri};\n } else {\n const shapeClass = shapeConfig as typeof Shape;\n if (shapeClass.shape) {\n property.valueShape = {id: shapeClass.shape.id};\n } else {\n onShapeSetup(\n shapeConfig,\n (nodeShape: NodeShapeData) => {\n property.valueShape = {id: nodeShape.id};\n },\n propertyKey,\n );\n }\n }\n }\n};\n\n/**\n * The DSL-JSON where-clause combinators. A property may not be named after one,\n * because a condition key in those positions has no `{path}` escape (the key is a\n * bare string). See documentation/dsl-json.md (Reserved words).\n */\nconst RESERVED_PROPERTY_LABELS = new Set(['and', 'or', 'not']);\n\nexport function registerPropertyShape(\n shape: NodeShapeData,\n propertyShape: PropertyShapeData,\n) {\n if (RESERVED_PROPERTY_LABELS.has(propertyShape.label)) {\n throw new Error(\n `Property label '${propertyShape.label}' is reserved (a DSL-JSON boolean combinator) ` +\n `and cannot be used as a property name. See documentation/dsl-json.md (Reserved words).`,\n );\n }\n // Not fatal, but the author needs to hear it here rather than from the field tracer.\n warnOnReservedPropertyLabel(propertyShape.label, shape.label, shape.id);\n const inherited = getPropertyShapeData(shape, propertyShape.label, true);\n const existing = getPropertyShapeData(shape, propertyShape.label, false);\n if (!existing && inherited) {\n if (!(propertyShape as unknown as ExplicitFlags)[EXPLICIT_MIN_COUNT_SYMBOL]) {\n propertyShape.minCount = inherited.minCount;\n }\n if (!(propertyShape as unknown as ExplicitFlags)[EXPLICIT_MAX_COUNT_SYMBOL]) {\n propertyShape.maxCount = inherited.maxCount;\n }\n if (!(propertyShape as unknown as ExplicitFlags)[EXPLICIT_NODE_KIND_SYMBOL]) {\n propertyShape.nodeKind = inherited.nodeKind;\n }\n validateOverrideTightening(shape, inherited, propertyShape);\n }\n if (existing) {\n Object.assign(existing, propertyShape);\n return existing;\n }\n propertyShape.id = `${shape.id}/${propertyShape.label}`;\n addPropertyShapeData(shape, propertyShape);\n return propertyShape;\n}\n\nconst ATOMIC_NODE_KINDS = [\n shacl.BlankNode.id,\n shacl.IRI.id,\n shacl.Literal.id,\n];\n\nconst nodeKindToAtomics = (nodeKind?: NodeReferenceValue): Set<string> => {\n if (!nodeKind?.id) {\n return new Set();\n }\n switch (nodeKind.id) {\n case shacl.BlankNode.id:\n case shacl.IRI.id:\n case shacl.Literal.id:\n return new Set([nodeKind.id]);\n case shacl.BlankNodeOrIRI.id:\n return new Set([shacl.BlankNode.id, shacl.IRI.id]);\n case shacl.IRIOrLiteral.id:\n return new Set([shacl.IRI.id, shacl.Literal.id]);\n case shacl.BlankNodeOrLiteral.id:\n return new Set([shacl.BlankNode.id, shacl.Literal.id]);\n default:\n return new Set(ATOMIC_NODE_KINDS);\n }\n};\n\nconst throwOverrideError = (\n shape: NodeShapeData,\n propertyShape: PropertyShapeData,\n message: string,\n) => {\n throw new Error(\n `Invalid override for ${shape.label}.${propertyShape.label}: ${message}`,\n );\n};\n\nconst validateOverrideTightening = (\n shape: NodeShapeData,\n base: PropertyShapeData,\n override: PropertyShapeData,\n) => {\n if (\n typeof base.minCount === 'number' &&\n typeof override.minCount === 'number' &&\n override.minCount < base.minCount\n ) {\n throwOverrideError(\n shape,\n override,\n `minCount cannot be lowered (${base.minCount} -> ${override.minCount}).`,\n );\n }\n\n if (\n typeof base.maxCount === 'number' &&\n typeof override.maxCount === 'number' &&\n override.maxCount > base.maxCount\n ) {\n throwOverrideError(\n shape,\n override,\n `maxCount cannot be increased (${base.maxCount} -> ${override.maxCount}).`,\n );\n }\n\n if (base.nodeKind && override.nodeKind) {\n const baseKinds = nodeKindToAtomics(base.nodeKind);\n const overrideKinds = nodeKindToAtomics(override.nodeKind);\n const widensNodeKind = [...overrideKinds].some((kind) => !baseKinds.has(kind));\n if (widensNodeKind) {\n throwOverrideError(\n shape,\n override,\n `nodeKind cannot be widened (${base.nodeKind.id} -> ${override.nodeKind.id}).`,\n );\n }\n }\n};\n\nexport function createPropertyShape<\n Config extends LiteralPropertyShapeConfig | ObjectPropertyShapeConfig,\n>(\n config: Config,\n propertyKey: string,\n defaultNodeKind: NodeReferenceValue = null,\n shapeClass: typeof Shape | [string, string] = null,\n) {\n const propertyShape = createPropertyShapeData();\n propertyShape.path = normalizePropertyPath(config.path);\n propertyShape.label = propertyKey;\n\n if (config.name) {\n propertyShape.name = config.name;\n }\n if (config.description) {\n propertyShape.description = config.description;\n }\n\n if (config.required) {\n propertyShape.minCount = 1;\n } else if (config.minCount !== undefined) {\n propertyShape.minCount = config.minCount;\n }\n (propertyShape as unknown as ExplicitFlags)[EXPLICIT_MIN_COUNT_SYMBOL] =\n config.required === true || config.minCount !== undefined;\n\n if (config.maxCount !== undefined) {\n propertyShape.maxCount = config.maxCount;\n }\n (propertyShape as unknown as ExplicitFlags)[EXPLICIT_MAX_COUNT_SYMBOL] =\n config.maxCount !== undefined;\n if ((config as LiteralPropertyShapeConfig).datatype) {\n propertyShape.datatype = toNodeReference(\n (config as LiteralPropertyShapeConfig).datatype,\n );\n }\n\n if ((config as ObjectPropertyShapeConfig).class) {\n propertyShape.class = toNodeReference(\n (config as ObjectPropertyShapeConfig).class,\n );\n }\n\n if ((config as ObjectPropertyShapeConfig).contains) {\n // Ownership is walked shape by shape, so an owned value needs a shape to walk into. A\n // polymorphic slot holding blank structure needs no `contains`: blank values are deleted\n // through their blank-capable `nodeKind`.\n if (!(config as ObjectPropertyShapeConfig).shape) {\n throw new Error(\n `The contains property \"${propertyKey}\" needs a \\`shape\\`: ownership follows the value ` +\n `shape to what it owns in turn. Declare the value's shape, or drop \\`contains\\` (a blank ` +\n `value is deleted through a blank-capable \\`nodeKind\\` without it).`,\n );\n }\n propertyShape.contains = true;\n }\n\n if (config.equals) {\n propertyShape.equalsConstraint = toNodeReference(config.equals);\n }\n if (config.disjoint) {\n propertyShape.disjoint = toNodeReference(config.disjoint);\n }\n if ((config as LiteralPropertyShapeConfig).lessThan) {\n propertyShape.lessThan = toNodeReference((config as LiteralPropertyShapeConfig).lessThan);\n }\n if ((config as LiteralPropertyShapeConfig).lessThanOrEquals) {\n propertyShape.lessThanOrEquals = toNodeReference((config as LiteralPropertyShapeConfig).lessThanOrEquals);\n }\n // Value-range / string-length / pattern constraints (report 021 §3, G5). These are\n // recorded on the shape and serialized to SHACL; there is no DSL-side runtime\n // enforcement — they describe the shape for validators / introspection.\n {\n const lit = config as LiteralPropertyShapeConfig;\n if (lit.minInclusive !== undefined) propertyShape.minInclusive = lit.minInclusive;\n if (lit.maxInclusive !== undefined) propertyShape.maxInclusive = lit.maxInclusive;\n if (lit.minExclusive !== undefined) propertyShape.minExclusive = lit.minExclusive;\n if (lit.maxExclusive !== undefined) propertyShape.maxExclusive = lit.maxExclusive;\n if (lit.minLength !== undefined) propertyShape.minLength = lit.minLength;\n if (lit.maxLength !== undefined) propertyShape.maxLength = lit.maxLength;\n if (lit.pattern !== undefined) propertyShape.pattern = lit.pattern;\n }\n if (config.hasValue !== undefined) {\n const v = config.hasValue;\n propertyShape.hasValueConstraint = typeof v === 'object' && v !== null ? toNodeReference(v) : v;\n }\n if (config.defaultValue !== undefined) {\n propertyShape.defaultValue = config.defaultValue;\n }\n if (config.in) {\n propertyShape.in = config.in.map((entry) =>\n typeof entry === 'object' && entry !== null ? toNodeReference(entry) : entry,\n );\n }\n if (config.sortBy) {\n propertyShape.sortBy = normalizePropertyPath(config.sortBy);\n }\n // Arrangement + display metadata. `order` and `group` were declared on the config\n // but never copied onto the property shape, so a declared `sh:order` was silently\n // dropped and every renderer fell back to array position. Carried now, alongside\n // the two display terms.\n if (config.order !== undefined) propertyShape.order = config.order;\n if (config.group !== undefined) propertyShape.group = config.group;\n if (config.displayRank !== undefined) propertyShape.displayRank = config.displayRank;\n if (config.displayHidden !== undefined)\n propertyShape.displayHidden = config.displayHidden;\n\n propertyShape.nodeKind = normalizeNodeKind(config.nodeKind, defaultNodeKind);\n (propertyShape as unknown as ExplicitFlags)[EXPLICIT_NODE_KIND_SYMBOL] =\n config.nodeKind !== undefined;\n\n if (shapeClass) {\n onShapeSetup(shapeClass, (shape: NodeShapeData) => {\n connectValueShape(config, propertyKey, propertyShape);\n registerPropertyShape(shape, propertyShape);\n });\n }\n\n return propertyShape;\n}\n\nexport function onShapeSetup(\n shapeClass: typeof Shape | [string, string],\n callback: (shape: NodeShapeData) => void,\n propertyName?: string,\n waitForSuperShapes?: boolean,\n) {\n const cb = waitForSuperShapes\n ? (shape: NodeShapeData) => {\n const superClass = Object.getPrototypeOf(shapeClass) as typeof Shape;\n if (superClass.name === 'Shape') {\n callback(shape);\n return;\n }\n if (superClass.name === '') {\n console.error(\n `Shape ${shape.label} does not extend base class lincd/shapes/Shape. Make sure it extends Shape.`,\n );\n return;\n }\n onShapeSetup(\n superClass,\n () => {\n callback(shape);\n },\n propertyName,\n waitForSuperShapes,\n );\n }\n : callback;\n\n const safeCallback = (\n targetShapeClass: typeof Shape,\n innerCallback: (shape: NodeShapeData) => void,\n ) => {\n if (targetShapeClass.hasOwnProperty('shape')) {\n innerCallback((targetShapeClass as typeof Shape).shape);\n } else {\n if (!targetShapeClass['shapeCallbacks']) {\n targetShapeClass['shapeCallbacks'] = [];\n }\n targetShapeClass['shapeCallbacks'].push(innerCallback);\n }\n };\n\n if (Array.isArray(shapeClass)) {\n const [packageName, shapeName] = shapeClass;\n const nodeShapeId = getNodeShapeUri(packageName, shapeName);\n if (typeof document !== 'undefined') {\n window.addEventListener('load', () => {\n const resolved = getShapeClass(nodeShapeId);\n if (!resolved) {\n console.warn(\n `Could not find value shape (${packageName}/${shapeName}) for accessor get ${propertyName}(). Likely because it is not bundled.`,\n );\n return;\n }\n safeCallback(resolved as unknown as typeof Shape, cb);\n });\n } else {\n addNodeShapeCallback(nodeShapeId, cb);\n }\n } else {\n safeCallback(shapeClass, cb);\n }\n}\n\nconst _linkedProperty = <\n Config extends ObjectPropertyShapeConfig | LiteralPropertyShapeConfig,\n>(\n config: Config,\n defaultNodeKind: NodeReferenceValue = null,\n) => {\n return function (\n target: any,\n propertyKey: string,\n _descriptor: PropertyDescriptor,\n ) {\n createPropertyShape(config, propertyKey, defaultNodeKind, target.constructor);\n };\n};\n\nexport const literalProperty = (config: LiteralPropertyShapeConfig) => {\n return _linkedProperty<LiteralPropertyShapeConfig>(config, shacl.Literal);\n};\n\nexport const objectProperty = (config: ObjectPropertyShapeConfig) => {\n return _linkedProperty<ObjectPropertyShapeConfig>(config, shacl.IRI);\n};\n\nexport const linkedProperty = (\n config: ObjectPropertyShapeConfig | LiteralPropertyShapeConfig,\n) => {\n return _linkedProperty(config);\n};\n\nexport function disallowProperty(\n target: any,\n propertyKey: string,\n _descriptor: PropertyDescriptor,\n) {\n onShapeSetup(\n target.constructor,\n (shape: NodeShapeData) => {\n const superClass = Object.getPrototypeOf(target.constructor) as typeof Shape;\n const superNodeShape = superClass.shape;\n const superPropertyShape = getPropertyShapeData(\n superNodeShape,\n propertyKey,\n true,\n );\n if (!superPropertyShape) {\n console.warn(\n `Property ${propertyKey} not found in super class ${superClass.name} or any of its super classes. Does it have a property decorator? Cannot disallow property ${target.constructor.name}.${propertyKey}`,\n );\n return;\n }\n const clonedPropertyShape = clonePropertyShape(superPropertyShape);\n clonedPropertyShape.maxCount = 0;\n registerPropertyShape(shape, clonedPropertyShape);\n },\n '',\n true,\n );\n}\n\nexport function getNodeShapeUri(packageName: string, shapeName: string): string {\n // arch-02: `{baseUri}shape/{packageSlug}/{ShapeName}` — ShapeName kept PascalCase\n // (it is a class name, already URI-safe), packageSlug derived from the name.\n return `${resolveBaseUri(packageName)}shape/${packageNameToSlug(packageName)}/${shapeName}`;\n}\n\nconst nodeShapeCallbacks = new Map<string, ((shape: NodeShapeData) => void)[]>();\nexport function getAndClearCallbacks(\n nodeShapeId: string,\n): ((shape: NodeShapeData) => void)[] {\n const callbacks = nodeShapeCallbacks.get(nodeShapeId);\n nodeShapeCallbacks.delete(nodeShapeId);\n return callbacks;\n}\nexport const addNodeShapeCallback = (\n nodeShapeId: string,\n callback: (shape: NodeShapeData) => void,\n) => {\n if (!nodeShapeCallbacks.has(nodeShapeId)) {\n nodeShapeCallbacks.set(nodeShapeId, []);\n }\n nodeShapeCallbacks.get(nodeShapeId).push(callback);\n};\n"]}
@@ -1,3 +1,4 @@
1
1
  import './SHACL.js';
2
2
  import './List.js';
3
+ import './PathList.js';
3
4
  import './PathNode.js';
@@ -10,5 +10,6 @@
10
10
  // SHACL metamodel cannot decorate itself. List.js loads it; SHACL.js alone does not.
11
11
  import './SHACL.js';
12
12
  import './List.js';
13
+ import './PathList.js';
13
14
  import './PathNode.js';
14
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shapes/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qFAAqF;AACrF,mFAAmF;AACnF,EAAE;AACF,2FAA2F;AAC3F,qFAAqF;AACrF,OAAO,YAAY,CAAC;AACpB,OAAO,WAAW,CAAC;AACnB,OAAO,eAAe,CAAC","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// Loads every shape @_linked/core defines, for their registration side effects only.\n// Consumers: `import '@_linked/core/shapes/index'`. Nothing is exported from here.\n//\n// Shape, NodeShape, PropertyShape and List are registered by utils/Package.ts, because the\n// SHACL metamodel cannot decorate itself. List.js loads it; SHACL.js alone does not.\nimport './SHACL.js';\nimport './List.js';\nimport './PathNode.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shapes/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qFAAqF;AACrF,mFAAmF;AACnF,EAAE;AACF,2FAA2F;AAC3F,qFAAqF;AACrF,OAAO,YAAY,CAAC;AACpB,OAAO,WAAW,CAAC;AACnB,OAAO,eAAe,CAAC;AACvB,OAAO,eAAe,CAAC","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// Loads every shape @_linked/core defines, for their registration side effects only.\n// Consumers: `import '@_linked/core/shapes/index'`. Nothing is exported from here.\n//\n// Shape, NodeShape, PropertyShape and List are registered by utils/Package.ts, because the\n// SHACL metamodel cannot decorate itself. List.js loads it; SHACL.js alone does not.\nimport './SHACL.js';\nimport './List.js';\nimport './PathList.js';\nimport './PathNode.js';\n"]}
@@ -60,7 +60,10 @@ export interface NodeShapeData {
60
60
  description?: string;
61
61
  targetClass?: NodeReferenceValue;
62
62
  extends?: NodeReferenceValue;
63
- /** Composition marker: instances are dependent (cascade-deletable via `contains`). */
63
+ /**
64
+ * @deprecated No effect: every node a `contains` property reaches is deleted with its owner.
65
+ * Kept for shapes that declare it and persisted as `core:dependent`.
66
+ */
64
67
  dependent?: boolean;
65
68
  /** sh:closed — target nodes with undeclared properties are invalid. */
66
69
  closed?: boolean;