@_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.
- package/CHANGELOG.md +67 -0
- package/README.md +107 -60
- package/lib/esm/ontologies/linked-core.js +3 -2
- package/lib/esm/ontologies/linked-core.js.map +1 -1
- package/lib/esm/ontologies/shacl.d.ts +3 -0
- package/lib/esm/ontologies/shacl.js +6 -0
- package/lib/esm/ontologies/shacl.js.map +1 -1
- package/lib/esm/queries/IRMutation.js +1 -1
- package/lib/esm/queries/IRMutation.js.map +1 -1
- package/lib/esm/queries/IntermediateRepresentation.d.ts +0 -5
- package/lib/esm/queries/IntermediateRepresentation.js.map +1 -1
- package/lib/esm/queries/MutationQuery.js +0 -15
- package/lib/esm/queries/MutationQuery.js.map +1 -1
- package/lib/esm/queries/MutationSerialization.d.ts +6 -5
- package/lib/esm/queries/MutationSerialization.js +1 -9
- package/lib/esm/queries/MutationSerialization.js.map +1 -1
- package/lib/esm/queries/QueryFactory.d.ts +0 -6
- package/lib/esm/queries/QueryFactory.js.map +1 -1
- package/lib/esm/queries/lowerMutationJSON.js +1 -6
- package/lib/esm/queries/lowerMutationJSON.js.map +1 -1
- package/lib/esm/shapes/List.class.d.ts +3 -3
- package/lib/esm/shapes/List.class.js +3 -3
- package/lib/esm/shapes/List.class.js.map +1 -1
- package/lib/esm/shapes/List.d.ts +0 -1
- package/lib/esm/shapes/List.js.map +1 -1
- package/lib/esm/shapes/PathList.d.ts +24 -0
- package/lib/esm/shapes/PathList.js +60 -0
- package/lib/esm/shapes/PathList.js.map +1 -0
- package/lib/esm/shapes/PathNode.d.ts +8 -9
- package/lib/esm/shapes/PathNode.js +20 -14
- package/lib/esm/shapes/PathNode.js.map +1 -1
- package/lib/esm/shapes/SHACL.d.ts +15 -13
- package/lib/esm/shapes/SHACL.js +8 -0
- package/lib/esm/shapes/SHACL.js.map +1 -1
- package/lib/esm/shapes/index.d.ts +1 -0
- package/lib/esm/shapes/index.js +1 -0
- package/lib/esm/shapes/index.js.map +1 -1
- package/lib/esm/shapes/nodeShapeData.d.ts +4 -1
- package/lib/esm/shapes/nodeShapeData.js.map +1 -1
- package/lib/esm/shapes/serializePathToNodeData.d.ts +12 -11
- package/lib/esm/shapes/serializePathToNodeData.js +12 -11
- package/lib/esm/shapes/serializePathToNodeData.js.map +1 -1
- package/lib/esm/shapes/singleOwnerConstraint.d.ts +5 -7
- package/lib/esm/shapes/singleOwnerConstraint.js +65 -21
- package/lib/esm/shapes/singleOwnerConstraint.js.map +1 -1
- package/lib/esm/shapes/syncShapes.js +2 -2
- package/lib/esm/shapes/syncShapes.js.map +1 -1
- package/lib/esm/shapes/validation.js +2 -2
- package/lib/esm/shapes/validation.js.map +1 -1
- package/lib/esm/sparql/irToAlgebra.d.ts +15 -33
- package/lib/esm/sparql/irToAlgebra.js +680 -431
- package/lib/esm/sparql/irToAlgebra.js.map +1 -1
- package/lib/esm/sparql/ownedLinkCheck.d.ts +6 -10
- package/lib/esm/sparql/ownedLinkCheck.js +10 -11
- package/lib/esm/sparql/ownedLinkCheck.js.map +1 -1
- package/lib/esm/utils/Package.d.ts +3 -2
- package/lib/esm/utils/Package.js +21 -8
- package/lib/esm/utils/Package.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,72 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.32.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#338](https://github.com/linked-fw/core/pull/338) [`83e9a51`](https://github.com/linked-fw/core/commit/83e9a519593c92448bb1492af92a3701d46d9750) Thanks [@flyon](https://github.com/flyon)! - Ownership of `contains` values is now decided **per property**, everywhere. Until now a property owned its values when *any* registered shape declared its predicate `contains`, so a plain property on such a predicate (say a user shape's `schema:image`, which `@_linked/schema` declares `contains` on `Thing.image`) deleted its old value on replace and class-checked links.
|
|
8
|
+
|
|
9
|
+
**A plain property on a predicate another shape declares `contains` no longer deletes or class-checks.** Replacing, unsetting or set-removing its value only changes the edge; deleting its subject leaves the value in place; linking any `{id}` through it is allowed. To keep the old behaviour for such a property, declare `contains: true` (with a `shape`) on it.
|
|
10
|
+
|
|
11
|
+
**Deleting an owner deletes everything it owns.** The cleanup walks shapes, not predicates: from the owner's shape it follows that shape's `contains` properties to their value shapes, then their `contains` properties, and so on. Deeper owned values now go with their owner even when their shape is not `dependent` (before, only `dependent`-typed descendants were deleted below the first level). When a value is typed with a registered sub-shape of the declared value shape, the `contains` properties that sub-shape adds are followed too, from nodes of that class only. Such a property is not followed through the parent (warned once with the cause) when the sub-shape has no `targetClass`, shares it with a super-shape, or shares it with another shape that holds the same predicate as a plain property through a simple path. A copy of a sub-shape that adds nothing (same class, or no `targetClass`) is skipped silently.
|
|
12
|
+
|
|
13
|
+
Recursion: a shape owning its own kind (list cells, replies) is followed to any depth; any other cycle is followed hop by hop, each hop checked against the declaring class, for at most `MAX_OWNED_RECURSION` (4) re-entries per path — deeper values are left in place. `rdf:nil` is never deleted. A delete whose owned walk exceeds `OWNED_BRANCH_WARNING` (64) branches logs a warning. Both constants are exported from `@_linked/core/sparql/irToAlgebra`.
|
|
14
|
+
|
|
15
|
+
**`contains` without a `shape` now throws** when the class is decorated: the walk needs a value shape to follow. Add the value's `shape`, or drop `contains` — a blank value is deleted through a blank-capable `nodeKind` without it. Core's own `PropertyShape.path` and the shape-less `PathNode` slots no longer declare `contains`.
|
|
16
|
+
|
|
17
|
+
**`dependent` is deprecated** and has no effect. It is still accepted, and shape sync still persists it as `core:dependent`. Core's own shapes no longer declare it.
|
|
18
|
+
|
|
19
|
+
**The generated single-owner constraint counts only owners of the declaring class.** `sh:maxCount 1` (every subject counted) becomes a qualified count over the declaring `targetClass` and every registered sub-shape's class, so a plain reference from another class conforms:
|
|
20
|
+
|
|
21
|
+
```turtle
|
|
22
|
+
<…/Thing/image.singleOwner/owners> sh:path [ sh:inversePath schema:image ] ;
|
|
23
|
+
sh:qualifiedValueShape [ sh:or ( [ sh:class schema:Thing ] [ sh:class ex:Project ] ) ] ;
|
|
24
|
+
sh:qualifiedMaxCount 1 .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
With one class the qualified shape is `[ sh:class C ]`. A declaring shape without `targetClass` gets no constraint (sync warns once). Re-sync to rewrite stored constraints. New metamodel accessors: `PropertyShape.qualifiedValueShape`, `PropertyShape.qualifiedMaxCount`, `NodeShape.class`, `NodeShape.orShapes` (`sh:or`), and the `shacl.qualifiedValueShape` / `qualifiedMaxCount` / `or` terms.
|
|
28
|
+
|
|
29
|
+
**Removed:** `collectContainment` and `buildOwnedCascade` (exported from `@_linked/core/sparql/irToAlgebra`), which implemented the predicate rule, and the `sharedPredicate` field of `OwnedLink`. Nothing replaces them; to ask whether a property owns its value, read its own `contains`.
|
|
30
|
+
|
|
31
|
+
**No longer done:** the next sync no longer deletes the IRI-named path nodes versions before 2.30 wrote; it leaves them unreferenced.
|
|
32
|
+
|
|
33
|
+
See README "Owned properties" and `docs/architecture/owned-values.md`.
|
|
34
|
+
|
|
35
|
+
## 2.31.0
|
|
36
|
+
|
|
37
|
+
### Minor Changes
|
|
38
|
+
|
|
39
|
+
- [#336](https://github.com/linked-fw/core/pull/336) [`742d0a2`](https://github.com/linked-fw/core/commit/742d0a24496a84cdb6c14cb8eb6b9e705998df33) Thanks [@flyon](https://github.com/flyon)! - A nested create is now written as a blank node when the **property** that holds it allows blank nodes through its `nodeKind`. This replaces the `__blank: true` node-data key added in 2.30.0, which is removed.
|
|
40
|
+
|
|
41
|
+
**Minting follows the property's `nodeKind`:**
|
|
42
|
+
|
|
43
|
+
| `nodeKind` | nested value without an id | with an id |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| unset, `shacl.IRI` (the `objectProperty` default), `shacl.IRIOrLiteral` | IRI (as before) | IRI |
|
|
46
|
+
| `shacl.BlankNodeOrIRI` | blank node | IRI |
|
|
47
|
+
| `shacl.BlankNode`, `shacl.BlankNodeOrLiteral` | blank node | error |
|
|
48
|
+
| `shacl.Literal` | error | error |
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
@objectProperty({path: ex.geo, shape: GeoPoint, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI})
|
|
52
|
+
declare geo: GeoPoint;
|
|
53
|
+
|
|
54
|
+
// <place1> ex:geo _:b0 . _:b0 ex:lat "52.1" .
|
|
55
|
+
await Place.create({geo: {lat: '52.1'}}).withId(place1);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
A blank node is written with its field triples only, without `rdf:type`. Nothing about it is sent in DSL-JSON: the side that runs the mutation decides from its own shapes. **Upgrade the side that lowers mutations (the server) first:** a 2.30.x server lowering DSL-JSON from this version writes complex `sh:path` values as IRI nodes again, since the `__blank` key it read is no longer sent.
|
|
59
|
+
|
|
60
|
+
**Blank values are deleted with what holds them.** Deleting the subject (by id, `.all()`, `.where()`), replacing or unsetting the property, deleting or replacing an owned (`contains`) child, and the containment cascade delete the blank value and the blank nodes below it, following only blank-capable properties. Only blank nodes are deleted, never an IRI the structure refers to, and `contains` is no longer needed for it. This replaces the `contains`-based blank-node cleanup of 2.30.0 and the bulk deletes' blank-node cleanup.
|
|
61
|
+
|
|
62
|
+
**Refused with an error** (not supported yet): an `update` / `upsert` / `updateWhere` whose new value would be a blank node, and an id of the form `_:…` used to link, `update().for()` or delete by id.
|
|
63
|
+
|
|
64
|
+
**Shape sync is unchanged.** `PropertyShape.path` and the path operator slots are declared `shacl.BlankNodeOrIRI`, and path lists use a new `PathList` shape (`@_linked/core/shapes/PathList`), so sync writes the same blank `sh:path` structure as 2.30.0, byte for byte (pinned by a test against the 2.30.0 output). `PathNode.alternativePath` now declares `PathList` as its value shape; `List`, `rdfList()` and `sh:in` lists are unchanged.
|
|
65
|
+
|
|
66
|
+
**Removed:** `__blank` on `NodeDescriptionValue`, `IRNodeData.blank`, and the `__blank` DSL-JSON key. Only shape sync used it. A `__blank` key in mutation data is now rejected as an undeclared property.
|
|
67
|
+
|
|
68
|
+
See README "Blank-node values (`nodeKind`)" and `docs/architecture/owned-values.md`.
|
|
69
|
+
|
|
3
70
|
## 2.30.1
|
|
4
71
|
|
|
5
72
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -252,6 +252,11 @@ value. Whenever that edge goes away, the owned node is deleted with it:
|
|
|
252
252
|
orphaned.
|
|
253
253
|
- `update({ownedProp: {remove: [x]}})` deletes `x` itself, not just the link.
|
|
254
254
|
|
|
255
|
+
Ownership belongs to the property, not to its predicate. A plain property of another shape on
|
|
256
|
+
the same predicate (say `ex:avatar` without `contains`) is a reference: replacing it or deleting
|
|
257
|
+
its subject never deletes the value, and it is not class-checked. A `contains` property needs a
|
|
258
|
+
`shape`; declaring one without it throws when the class is decorated.
|
|
259
|
+
|
|
255
260
|
```typescript
|
|
256
261
|
@linkedShape
|
|
257
262
|
export class Person extends Shape {
|
|
@@ -287,12 +292,10 @@ patch: it deletes all of that node's triples and writes the new ones.
|
|
|
287
292
|
`{avatar: {id: uploadedId}}`. The link transfers ownership: the linked node is deleted when it is
|
|
288
293
|
replaced, removed, or when the owner is deleted.
|
|
289
294
|
|
|
290
|
-
Because of that, core checks the class of every id linked into a property that
|
|
291
|
-
declares a `shape`.
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
refused, and nothing is written, when the store already types the node and none of its types is
|
|
295
|
-
the shape's `targetClass`, a registered sub-shape's `targetClass`, or the property's `sh:class`:
|
|
295
|
+
Because of that, core checks the class of every id linked into a `contains` property that
|
|
296
|
+
declares a `shape`. A link is refused, and nothing is written, when the store already types the
|
|
297
|
+
node and none of its types is the shape's `targetClass`, a registered sub-shape's `targetClass`, or
|
|
298
|
+
the property's `sh:class`:
|
|
296
299
|
|
|
297
300
|
```
|
|
298
301
|
Cannot link <https://my.app/alice> into the contains property "avatar" of <…/shape/my-pkg/Person>:
|
|
@@ -301,7 +304,7 @@ it is typed <https://example.org/Person>, but "avatar" only owns instances of <h
|
|
|
301
304
|
|
|
302
305
|
Ids that do not exist yet, or have no `rdf:type`, are allowed, so upload-then-attach works in
|
|
303
306
|
either write order. The check runs in `SparqlDataset` (one `SELECT` per mutation that links owned
|
|
304
|
-
ids, none otherwise). Plain references
|
|
307
|
+
ids, none otherwise). Plain references are never checked. A node
|
|
305
308
|
whose type comes from a subclass that has no registered shape is refused unless the store also
|
|
306
309
|
holds the expected type (an RDFS-inferring store adds it); register a shape for that class, or
|
|
307
310
|
declare `sh:class`, to accept it.
|
|
@@ -311,24 +314,31 @@ Nor is a node typed by another request between the check's `SELECT` and the `UPD
|
|
|
311
314
|
follows it: the two are separate requests, not one transaction. Raw SPARQL updates bypass the
|
|
312
315
|
check altogether. SHACL validation of `sh:class` is the backstop for all three.
|
|
313
316
|
|
|
314
|
-
**What a delete removes.**
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
317
|
+
**What a delete removes.** Deleting an owner deletes everything it owns (see the recursion
|
|
318
|
+
limit below): the values of its `contains` properties (own and inherited), the values *their* shapes own, and so on. A
|
|
319
|
+
replace or set-remove does the same below the old value. The walk follows the shapes, not the
|
|
320
|
+
predicates: from the owner's shape it follows that shape's `contains` properties to their value
|
|
321
|
+
shapes, then those shapes' `contains` properties. When a value is typed with a registered
|
|
322
|
+
sub-shape of the declared value shape, the `contains` properties the sub-shape adds are followed
|
|
323
|
+
too, but only from nodes of that sub-shape's class (`?img a ex:Photo . ?img ex:thumbnail ?t`).
|
|
324
|
+
The class must tell those nodes apart: an added property is not followed through the parent
|
|
325
|
+
(core warns once) when the sub-shape has no `targetClass`, shares it with one of its
|
|
326
|
+
super-shapes, or shares it with another shape that holds the same predicate as a plain property
|
|
327
|
+
(through a simple path). Another shape that merely shares the class, without that predicate,
|
|
328
|
+
changes nothing. A copy of a sub-shape that adds nothing of its own, with the same class (a
|
|
329
|
+
"profile") or with no `targetClass` at all, is skipped silently: its parent's entry covers it.
|
|
330
|
+
When a sub-shape redeclares an inherited `contains` property without `contains`, the inherited
|
|
331
|
+
ownership still applies.
|
|
332
|
+
|
|
333
|
+
Recursion has a limit. A shape that owns its own kind (a list cell owning the next cell through
|
|
334
|
+
`rdf:rest`, a comment owning its replies) is followed to any depth (`rdf:rest*`). Any other cycle
|
|
335
|
+
(A owns B owns A, or a sub-shape's property leading back into its own kind) is followed hop by
|
|
336
|
+
hop, each hop checked against the class that declares it, for at most `MAX_OWNED_RECURSION` (4)
|
|
337
|
+
re-entries per path; values deeper than that are left in place, and so is anything behind an
|
|
338
|
+
untyped node on such a cycle. `rdf:nil`, the end of every list, is never deleted.
|
|
339
|
+
|
|
340
|
+
The bulk deletes (`.all()`, `.where(...)`) remove the same subtree for every matched subject; they
|
|
341
|
+
do not delete incoming references to the subjects, which a delete by id does.
|
|
332
342
|
|
|
333
343
|
Non-owning references to an owned node, through other properties or from other subjects, are
|
|
334
344
|
allowed. They are not cleaned up: after the owner is deleted they dangle. The same holds when two
|
|
@@ -336,12 +346,13 @@ subjects own one node (an `{id}` linked into a second owner, which breaks the si
|
|
|
336
346
|
below): deleting either owner deletes the node, and the other owner's edge dangles.
|
|
337
347
|
|
|
338
348
|
**The single-owner constraint.** An owned node has at most one owner. Shape sync persists this as
|
|
339
|
-
one generated SHACL NodeShape per `contains` property
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
`Thing.image
|
|
349
|
+
one generated SHACL NodeShape per `contains` property (simple paths only). It is written only by
|
|
350
|
+
the class that declares the property, at the property shape's IRI plus `.singleOwner`:
|
|
351
|
+
`Thing.image` gets one constraint at `Thing`, not one per subclass. It is marked `core:generated
|
|
352
|
+
true` and has no `sh:targetClass`, so catalog readers can skip it, and it is never registered in
|
|
353
|
+
memory. It counts only subjects of the declaring class and of every registered sub-shape's class,
|
|
354
|
+
so a plain reference through the same predicate from another class is allowed. For `Thing.image`,
|
|
355
|
+
with a registered `Project extends Thing`:
|
|
345
356
|
|
|
346
357
|
```turtle
|
|
347
358
|
<…/shape/my-pkg/Thing/image.singleOwner> a sh:NodeShape ;
|
|
@@ -351,33 +362,32 @@ constraint at `Thing`, not one per subclass. It is marked `core:generated true`
|
|
|
351
362
|
|
|
352
363
|
<…/Thing/image.singleOwner/owners> a sh:PropertyShape ;
|
|
353
364
|
rdfs:label "owners" ;
|
|
354
|
-
sh:
|
|
355
|
-
sh:
|
|
365
|
+
sh:path [ sh:inversePath schema:image ] ;
|
|
366
|
+
sh:qualifiedValueShape [ sh:or ( [ sh:class schema:Thing ] [ sh:class ex:Project ] ) ] ;
|
|
367
|
+
sh:qualifiedMaxCount 1 .
|
|
356
368
|
```
|
|
357
369
|
|
|
370
|
+
The classes are listed because `sh:class` matches a subclass instance only through
|
|
371
|
+
`rdfs:subClassOf` triples, which a dataset without inference lacks. With one class the qualified
|
|
372
|
+
shape is `[ sh:class C ]`. Sub-shapes registered only in another process are missing until a
|
|
373
|
+
process that knows them syncs; a declaring shape without `targetClass` gets no constraint (sync
|
|
374
|
+
logs it once). Versions before this one wrote `sh:maxCount 1` (every subject counted); the next
|
|
375
|
+
sync rewrites the constraint.
|
|
376
|
+
|
|
358
377
|
The inverse path is stored as an untyped blank node, as is every complex `sh:path` shape sync
|
|
359
378
|
writes (inverse, alternative, sequence, `*`/`+`/`?`): an IRI in `sh:path` is a predicate path to a
|
|
360
|
-
SHACL validator.
|
|
361
|
-
|
|
362
|
-
unreferenced
|
|
379
|
+
SHACL validator. Nothing marks them: `PropertyShape.path` and the path operator slots are
|
|
380
|
+
declared `sh:BlankNodeOrIRI`, see [Blank-node values](#blank-node-values-nodekind). Versions before 2.30 wrote IRI-named, typed path nodes (`…/owners/inv`, `…/region/seq/0`). The
|
|
381
|
+
next sync writes blank nodes and leaves those behind, unreferenced; re-create the dataset, or
|
|
382
|
+
delete them by IRI prefix (`…/owners/inv`, `…/seq/…`), to remove them.
|
|
363
383
|
|
|
364
|
-
|
|
365
|
-
DELETE { ?n ?p ?o } WHERE {
|
|
366
|
-
?n a <https://linked.cm/ont/core/PathNode> ; ?p ?o .
|
|
367
|
-
FILTER(isIRI(?n)) FILTER NOT EXISTS { ?x ?y ?n }
|
|
368
|
-
}
|
|
369
|
-
```
|
|
370
|
-
Read a stored path's structure in the same query that finds it (`?ps sh:path ?p .
|
|
384
|
+
Read a stored path's structure in the same query that finds it (`?ps sh:path ?p .
|
|
371
385
|
?p sh:inversePath ?x`): a blank node's label is not stable across queries.
|
|
372
386
|
|
|
373
|
-
Nested node-data in a `create` may carry `__blank: true` to be written that way: a fresh blank
|
|
374
|
-
node with only its field triples and no `rdf:type`. It is meant for RDF syntax such as SHACL
|
|
375
|
-
paths, has no id (combining it with `__id`/`id` throws), cannot be the created root, and is
|
|
376
|
-
refused in `update`/`upsert`, whose INSERT runs once per WHERE solution.
|
|
377
387
|
The declaring shape owns its generated shapes through `core:generatedShape`, a `contains` edge:
|
|
378
388
|
`<…/Thing> core:generatedShape <…/Thing/image.singleOwner>`. Syncing a shape is still two
|
|
379
389
|
requests: deleting the shape deletes the generated shapes with it (their own triples, property
|
|
380
|
-
shapes and blank path nodes, never the predicate IRI), and the create writes the current ones nested in
|
|
390
|
+
shapes and their blank path and qualified-shape nodes, never the predicate IRI), and the create writes the current ones nested in
|
|
381
391
|
the same request. A removed or renamed accessor therefore loses its constraint, a pruned shape
|
|
382
392
|
takes its constraints with it, and a NodeShape the shape does not own is never touched.
|
|
383
393
|
`singleOwnerShapeIri`, `singleOwnerProperties` and `buildSingleOwnerConstraints` are exported if
|
|
@@ -393,21 +403,58 @@ typed link.
|
|
|
393
403
|
> write either: a dataset exposes only query, update and graph-store services. Run a SHACL
|
|
394
404
|
> validator (Jena SHACL, pySHACL, …) against the persisted shapes to enforce them.
|
|
395
405
|
|
|
396
|
-
**`dependent: true` on a shape**
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
406
|
+
**`dependent: true` on a shape** is deprecated and has no effect: every node a `contains` property
|
|
407
|
+
reaches is deleted with its owner, whether or not its shape is `dependent`. It is still accepted,
|
|
408
|
+
and shape sync still persists it (`core:dependent`).
|
|
409
|
+
|
|
410
|
+
### Blank-node values (`nodeKind`)
|
|
411
|
+
|
|
412
|
+
Every node core writes is IRI-named unless the **property** that holds it says otherwise. A
|
|
413
|
+
nested create is written as a blank node when its property's `nodeKind` allows blank nodes:
|
|
414
|
+
|
|
415
|
+
| `nodeKind` of the property | nested value without an id | with an id |
|
|
416
|
+
|---|---|---|
|
|
417
|
+
| unset, `shacl.IRI` (the `objectProperty` default), `shacl.IRIOrLiteral` | IRI (minted) | IRI |
|
|
418
|
+
| `shacl.BlankNodeOrIRI` | blank node | IRI |
|
|
419
|
+
| `shacl.BlankNode` | blank node | error |
|
|
420
|
+
| `shacl.BlankNodeOrLiteral` | blank node | error |
|
|
421
|
+
| `shacl.Literal` | error | error |
|
|
402
422
|
|
|
403
423
|
```typescript
|
|
404
|
-
@linkedShape
|
|
405
|
-
export class
|
|
424
|
+
@linkedShape
|
|
425
|
+
export class Place extends Shape {
|
|
426
|
+
static targetClass = ex.Place;
|
|
427
|
+
|
|
428
|
+
@objectProperty({path: ex.geo, shape: GeoPoint, maxCount: 1, nodeKind: shacl.BlankNodeOrIRI})
|
|
429
|
+
declare geo: GeoPoint;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// <place1> ex:geo _:b0 . _:b0 ex:lat "52.1" .
|
|
433
|
+
await Place.create({geo: {lat: '52.1'}}).withId(place1);
|
|
406
434
|
```
|
|
407
435
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
436
|
+
A blank node is written with its field triples only, without `rdf:type`: its shape is the one the
|
|
437
|
+
property declares. Nothing about it travels in DSL-JSON; the side that runs the mutation decides
|
|
438
|
+
from its own copy of the shape. Core uses this for SHACL paths: `PropertyShape.path`, the
|
|
439
|
+
`PathNode` slots and `PathList.first` / `.rest` are `sh:BlankNodeOrIRI`, so a predicate path (an
|
|
440
|
+
`{id}`) stays an IRI and every operator node and list cell becomes a blank node.
|
|
441
|
+
|
|
442
|
+
A blank value goes with what holds it. Deleting the subject (by id, `.all()`, `.where()`),
|
|
443
|
+
replacing or unsetting the property, and deleting or replacing an owned (`contains`) value at any
|
|
444
|
+
depth delete the blank value and the blank nodes below it, following only blank-capable properties.
|
|
445
|
+
Only blank nodes are deleted: an IRI the structure refers to (`schema:image` in
|
|
446
|
+
`[ sh:inversePath schema:image ]`, an entity a list lists) is never touched, nor is a blank node
|
|
447
|
+
reached through one. `contains` is not needed for this.
|
|
448
|
+
|
|
449
|
+
Not supported yet, and refused with an error rather than written wrongly:
|
|
450
|
+
|
|
451
|
+
- an `update` / `upsert` / `updateWhere` whose new value would be a blank node (its INSERT runs
|
|
452
|
+
once per WHERE solution, so the node would be written several times). Create it with its
|
|
453
|
+
parent, or give it an id under `sh:BlankNodeOrIRI`;
|
|
454
|
+
- addressing a blank node by id: linking `{id: '_:b0'}`, `update().for('_:b0')`, deleting
|
|
455
|
+
`{id: '_:b0'}`. Change it through the property that holds it.
|
|
456
|
+
|
|
457
|
+
A select returns a blank value as its store label (Fuseki: `b0`), valid only within that result.
|
|
411
458
|
|
|
412
459
|
## Queries: Create, Select, Update, Delete
|
|
413
460
|
|
|
@@ -988,7 +1035,7 @@ const deleted = await Person.delete({id: 'https://my.app/node1'});
|
|
|
988
1035
|
// Delete multiple nodes
|
|
989
1036
|
const deleted = await Person.delete([{id: 'https://my.app/node1'}, {id: 'https://my.app/node2'}]);
|
|
990
1037
|
|
|
991
|
-
// Delete all instances of a shape (with blank
|
|
1038
|
+
// Delete all instances of a shape (with their blank-node values)
|
|
992
1039
|
await Person.deleteAll();
|
|
993
1040
|
|
|
994
1041
|
// Conditional delete
|
|
@@ -21,8 +21,9 @@ const usesShapeClass = ns('usesShapeClass');
|
|
|
21
21
|
const editInline = ns('editInline');
|
|
22
22
|
const isExtending = ns('isExtending');
|
|
23
23
|
// Containment / lifecycle vocabulary.
|
|
24
|
-
// contains — property characteristic: the
|
|
25
|
-
//
|
|
24
|
+
// contains — property characteristic: the subject owns the value through this property
|
|
25
|
+
// (composition); the owned walk follows it.
|
|
26
|
+
// dependent — shape characteristic, deprecated: no effect (persisted for older shapes).
|
|
26
27
|
// PathNode — class for SHACL property-path operator nodes (sh:inversePath/alternativePath/…).
|
|
27
28
|
const contains = ns('contains');
|
|
28
29
|
const dependent = ns('dependent');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linked-core.js","sourceRoot":"","sources":["../../../src/ontologies/linked-core.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAE1C,sFAAsF;AACtF,wCAAwC;AACxC,qDAAqD;AACrD,6FAA6F;AAC7F,gGAAgG;AAChG,oEAAoE;AACpE,MAAM,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,6BAA6B,CAAC,CAAC;AACjE,MAAM,CAAC,MAAM,KAAK,GAAuB,EAAE,CAAC,EAAE,CAAC,CAAC;AAChD,6FAA6F;AAC7F,0FAA0F;AAC1F,oEAAoE;AACpE,MAAM,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AACpC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAE7B,MAAM,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAC9B,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;AACpC,MAAM,YAAY,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC;AACxC,MAAM,cAAc,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;AACpC,MAAM,cA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AiG;AACjG,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAChC,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;AAClC,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAEhC,oFAAoF;AACpF,oFAAoF;AACpF,mFAAmF;AACnF,oFAAoF;AACpF,mFAAmF;AACnF,0EAA0E;AAC1E,EAAE;AACF,mFAAmF;AACnF,kFAAkF;AAClF,qFAAqF;AACrF,MAAM,WAAW,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,aAAa,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;AAE1C,uFAAuF;AACvF,kGAAkG;AAClG,8EAA8E;AAC9E,MAAM,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC;AAElC,yFAAyF;AACzF,0FAA0F;AAC1F,6EAA6E;AAC7E,MAAM,cAAc,GAAG,EAAE,CAAC,gBAAgB,CAAC,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,OAAO;IACP,UAAU;IACV,YAAY;IACZ,MAAM,EAAE,cAAc;IACtB,cAAc;IACd,UAAU;IACV,WAAW;IACX,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,WAAW;IACX,aAAa;IACb,SAAS;IACT,cAAc;CACf,CAAC","sourcesContent":["import type {NodeReferenceValue} from '../utils/NodeReference.js';\nimport {createNameSpace} from '../utils/NameSpace.js';\nimport {Prefix} from '../utils/Prefix.js';\n\n// The @_linked/core framework vocabulary. First-party ontology IRIs follow Create Now\n// arch-02 §\"Public ontology namespace\":\n// https://linked.cm/ont/{ontologySlug}/{localName}\n// where ontologySlug defaults to the owning package's publicSlug (`@_linked/core` -> `core`)\n// and the prefix label equals the ontologySlug. Previously `https://linked.cm/ont/linked-core/`\n// (prefix `linked_core`), a leftover of a reverted slug derivation.\nexport const ns = createNameSpace('https://linked.cm/ont/core/');\nexport const _self: NodeReferenceValue = ns('');\n// @deprecated prefix alias: keeps `linked_core:` prefixed names resolving (to the NEW IRIs).\n// It does not make the old full IRIs match. Registered BEFORE `core` because the last add\n// wins for IRI -> prefix compaction, so output always uses `core:`.\nPrefix.add('linked_core', _self.id);\nPrefix.add('core', _self.id);\n\nconst Package = ns('Package');\nconst ShapeClass = ns('ShapeClass');\nconst definesShape = ns('definesShape');\nconst moduleProperty = ns('module');\nconst usesShapeClass = ns('usesShapeClass');\nconst editInline = ns('editInline');\nconst isExtending = ns('isExtending');\n\n// Containment / lifecycle vocabulary.\n// contains — property characteristic: the subject owns the value through this property\n// (composition); the owned walk follows it.\n// dependent — shape characteristic, deprecated: no effect (persisted for older shapes).\n// PathNode — class for SHACL property-path operator nodes (sh:inversePath/alternativePath/…).\nconst contains = ns('contains');\nconst dependent = ns('dependent');\nconst PathNode = ns('PathNode');\n\n// Display vocabulary. SHACL has `sh:order` and `sh:group`, which say how properties\n// are arranged; it has no way to say how *important* a property is, which is what a\n// renderer needs when it can only show one, three or six of them. `displayRank` is\n// that: a single linear rank per property, lower = more important, from which every\n// truncated context (\"show the top 3\") derives. `displayHidden` removes a property\n// from generic rendering without changing its cardinality or its meaning.\n//\n// Placement is deliberate (backlog-029): this is an ecosystem SHACL extension that\n// materializes onto the pure `sh:NodeShape` and therefore travels with an ejected\n// app — NOT the CN-proprietary `code:` vocab, which describes source-code structure.\nconst displayRank = ns('displayRank');\nconst displayHidden = ns('displayHidden');\n\n// Provenance marker: a NodeShape core generates at sync time from another shape's code\n// (today the `<propertyShape>.singleOwner` constraint derived from `contains`), rather than one a\n// developer declared. Catalog readers skip shapes with `core:generated true`.\nconst generated = ns('generated');\n\n// Ownership edge from a NodeShape to the shapes core generated from it at sync time (the\n// single-owner constraint of each `contains` property). It is `contains`, so deleting the\n// shape deletes them, and sync writes them nested in the shape's own create.\nconst generatedShape = ns('generatedShape');\n\nexport const coreOntology = {\n Package,\n ShapeClass,\n definesShape,\n module: moduleProperty,\n usesShapeClass,\n editInline,\n isExtending,\n contains,\n dependent,\n PathNode,\n displayRank,\n displayHidden,\n generated,\n generatedShape,\n};\n"]}
|
|
@@ -69,6 +69,9 @@ export declare const shacl: {
|
|
|
69
69
|
targetClass: NodeReferenceValue;
|
|
70
70
|
targetNode: NodeReferenceValue;
|
|
71
71
|
targetObjectsOf: NodeReferenceValue;
|
|
72
|
+
qualifiedValueShape: NodeReferenceValue;
|
|
73
|
+
qualifiedMaxCount: NodeReferenceValue;
|
|
74
|
+
or: NodeReferenceValue;
|
|
72
75
|
BlankNode: NodeReferenceValue;
|
|
73
76
|
IRI: NodeReferenceValue;
|
|
74
77
|
Literal: NodeReferenceValue;
|
|
@@ -25,6 +25,9 @@ const PropertyShape = ns('PropertyShape');
|
|
|
25
25
|
const targetClass = ns('targetClass');
|
|
26
26
|
const targetNode = ns('targetNode');
|
|
27
27
|
const targetObjectsOf = ns('targetObjectsOf');
|
|
28
|
+
const qualifiedValueShape = ns('qualifiedValueShape');
|
|
29
|
+
const qualifiedMaxCount = ns('qualifiedMaxCount');
|
|
30
|
+
const or = ns('or');
|
|
28
31
|
const node = ns('node');
|
|
29
32
|
const nodeKind = ns('nodeKind');
|
|
30
33
|
const Shape = ns('Shape');
|
|
@@ -116,6 +119,9 @@ export const shacl = {
|
|
|
116
119
|
targetClass,
|
|
117
120
|
targetNode,
|
|
118
121
|
targetObjectsOf,
|
|
122
|
+
qualifiedValueShape,
|
|
123
|
+
qualifiedMaxCount,
|
|
124
|
+
or,
|
|
119
125
|
BlankNode,
|
|
120
126
|
IRI,
|
|
121
127
|
Literal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shacl.js","sourceRoot":"","sources":["../../../src/ontologies/shacl.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAEtD,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAC3C,MAAM,CA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IACT,OAAO;IACP,UAAU;IACV,gBAAgB;IAChB,QAAQ;IACR,gBAAgB;IAChB,SAAS;IACT,WAAW;IACX,cAAc;IACd,UAAU;IACV,KAAK;IACL,OAAO;IACP,aAAa;IACb,MAAM;IACN,SAAS;IACT,yBAAyB;IACzB,wBAAwB;IACxB,uBAAuB;IACvB,2BAA2B;IAC3B,4BAA4B;IAC5B,4BAA4B;IAC5B,2BAA2B;IAC3B,2BAA2B;IAC3B,+BAA+B;IAC/B,+BAA+B;IAC/B,+BAA+B;IAC/B,+BAA+B;IAC/B,0BAA0B;IAC1B,qBAAqB;IACrB,2BAA2B;IAC3B,yBAAyB;IACzB,OAAO;IACP,IAAI;IACJ,cAAc;IACd,MAAM;IACN,eAAe;IACf,WAAW;IACX,cAAc;IACd,aAAa;IACb,aAAa;CACd,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} from '../utils/NodeReference.js';\nimport {Prefix} from '../utils/Prefix.js';\nimport {createNameSpace} from '../utils/NameSpace.js';\n\nconst base = 'http://www.w3.org/ns/shacl#';\nexport const _ontologyResource: NodeReferenceValue = {id: base};\nPrefix.add('shacl', base);\n\nexport const ns = createNameSpace(base);\n\n//add your ontology nodes here\nconst _class = ns('class');\nconst datatype = ns('datatype');\nconst declare = ns('declare');\nconst _in = ns('in');\nconst maxCount = ns('maxCount');\nconst minCount = ns('minCount');\nconst inList = ns('inList');\nconst name = ns('name');\nconst description = ns('description');\nconst NodeShape = ns('NodeShape');\nconst optional = ns('optional');\nconst Parameter = ns('Parameter');\nconst PrefixDeclaration = ns('PrefixDeclaration');\nconst path = ns('path');\nconst property = ns('property');\nconst prefix = ns('prefix');\nconst PropertyShape = ns('PropertyShape');\nconst targetClass = ns('targetClass');\nconst targetNode = ns('targetNode');\nconst targetObjectsOf = ns('targetObjectsOf');\nconst node = ns('node');\nconst nodeKind = ns('nodeKind');\nconst Shape = ns('Shape');\n\nconst equals = ns('equals');\nconst disjoint = ns('disjoint');\nconst hasValue = ns('hasValue');\nconst defaultValue = ns('defaultValue');\nconst order = ns('order');\nconst group = ns('group');\nconst closed = ns('closed');\nconst ignoredProperties = ns('ignoredProperties');\n\nconst alternativePath = ns('alternativePath');\nconst inversePath = ns('inversePath');\nconst zeroOrMorePath = ns('zeroOrMorePath');\nconst oneOrMorePath = ns('oneOrMorePath');\nconst zeroOrOnePath = ns('zeroOrOnePath');\n\nconst BlankNode = ns('BlankNode');\nconst IRI = ns('IRI');\nconst Literal = ns('Literal');\nconst BlankNodeOrIRI = ns('BlankNodeOrIRI');\nconst BlankNodeOrLiteral = ns('BlankNodeOrLiteral');\nconst IRIOrLiteral = ns('IRIOrLiteral');\n\nexport const languageIn = ns('languageIn');\nexport const lessThan = ns('lessThan');\nexport const lessThanOrEquals = ns('lessThanOrEquals');\nexport const maxExclusive = ns('maxExclusive');\nexport const maxInclusive = ns('maxInclusive');\nexport const maxLength = ns('maxLength');\nexport const minExclusive = ns('minExclusive');\nexport const minInclusive = ns('minInclusive');\nexport const minLength = ns('minLength');\nexport const pattern = ns('pattern');\nexport const uniqueLang = ns('uniqueLang');\nexport const ValidationReport = ns('ValidationReport');\nexport const conforms = ns('conforms');\nexport const ValidationResult = ns('ValidationResult');\nexport const focusNode = ns('focusNode');\nexport const sourceShape = ns('sourceShape');\nexport const resultSeverity = ns('resultSeverity');\nexport const resultPath = ns('resultPath');\nexport const value = ns('value');\n/** `sh:message` — a custom message declared on a shape or constraint. */\nexport const message = ns('message');\n/** `sh:resultMessage` — the message carried by a validation result. */\nexport const resultMessage = ns('resultMessage');\n/** `sh:detail` — links a validation result to the results that explain it. */\nexport const detail = ns('detail');\nexport const Violation = ns('Violation');\nexport const AbstractResult = ns('AbstractResult');\nexport const sourceConstraintComponent = ns('sourceConstraintComponent');\nexport const ClassConstraintComponent = ns('ClassConstraintComponent');\nexport const NodeConstraintComponent = ns('NodeConstraintComponent');\nexport const DatatypeConstraintComponent = ns('DatatypeConstraintComponent');\nexport const MinLengthConstraintComponent = ns('MinLengthConstraintComponent');\nexport const MaxLengthConstraintComponent = ns('MaxLengthConstraintComponent');\nexport const MinInclusiveConstraintComponent = ns('MinInclusiveConstraintComponent');\nexport const MaxInclusiveConstraintComponent = ns('MaxInclusiveConstraintComponent');\nexport const MinExclusiveConstraintComponent = ns('MinExclusiveConstraintComponent');\nexport const MaxExclusiveConstraintComponent = ns('MaxExclusiveConstraintComponent');\nexport const PatternConstraintComponent = ns('PatternConstraintComponent');\nexport const InConstraintComponent = ns('InConstraintComponent');\nexport const MinCountConstraintComponent = ns('MinCountConstraintComponent');\nexport const MaxCountConstraintComponent = ns('MaxCountConstraintComponent');\nexport const NodeKindConstraintComponent = ns('NodeKindConstraintComponent');\nexport const ClosedConstraintComponent = ns('ClosedConstraintComponent');\nexport const Warning = ns('Warning');\nexport const Info = ns('Info');\nexport const result = ns('result');\n\n//make sure every node is also exported here\nexport const shacl = {\n class: _class,\n datatype,\n declare,\n in: _in,\n maxCount,\n minCount,\n name,\n description,\n node,\n NodeShape,\n optional,\n Parameter,\n PrefixDeclaration,\n path,\n prefix,\n property,\n PropertyShape,\n Shape,\n targetClass,\n targetNode,\n targetObjectsOf,\n BlankNode,\n IRI,\n Literal,\n BlankNodeOrIRI,\n BlankNodeOrLiteral,\n IRIOrLiteral,\n nodeKind,\n inList,\n equals,\n disjoint,\n hasValue,\n defaultValue,\n order,\n group,\n closed,\n ignoredProperties,\n languageIn,\n lessThan,\n lessThanOrEquals,\n maxExclusive,\n maxInclusive,\n maxLength,\n minExclusive,\n minInclusive,\n minLength,\n pattern,\n uniqueLang,\n ValidationReport,\n conforms,\n ValidationResult,\n focusNode,\n sourceShape,\n resultSeverity,\n resultPath,\n value,\n message,\n resultMessage,\n detail,\n Violation,\n sourceConstraintComponent,\n ClassConstraintComponent,\n NodeConstraintComponent,\n DatatypeConstraintComponent,\n MinLengthConstraintComponent,\n MaxLengthConstraintComponent,\n MinCountConstraintComponent,\n MaxCountConstraintComponent,\n MinInclusiveConstraintComponent,\n MaxInclusiveConstraintComponent,\n MinExclusiveConstraintComponent,\n MaxExclusiveConstraintComponent,\n PatternConstraintComponent,\n InConstraintComponent,\n NodeKindConstraintComponent,\n ClosedConstraintComponent,\n Warning,\n Info,\n AbstractResult,\n result,\n alternativePath,\n inversePath,\n zeroOrMorePath,\n oneOrMorePath,\n zeroOrOnePath,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"shacl.js","sourceRoot":"","sources":["../../../src/ontologies/shacl.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAEtD,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAuB,EAAC,EAAE,EAAE,IAAI,EAAC,CAAC;AAChE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAE1B,MAAM,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;AAExC,8BAA8B;AAC9B,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC;AAC3B,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAChC,MAAM,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAC9B,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AACrB,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAChC,MAAM,QAAQ,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;AAChC,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;AACxB,MAAM,WAAW,GAAG,EA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ACf,WAAW;IACX,cAAc;IACd,aAAa;IACb,aAAa;CACd,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} from '../utils/NodeReference.js';\nimport {Prefix} from '../utils/Prefix.js';\nimport {createNameSpace} from '../utils/NameSpace.js';\n\nconst base = 'http://www.w3.org/ns/shacl#';\nexport const _ontologyResource: NodeReferenceValue = {id: base};\nPrefix.add('shacl', base);\n\nexport const ns = createNameSpace(base);\n\n//add your ontology nodes here\nconst _class = ns('class');\nconst datatype = ns('datatype');\nconst declare = ns('declare');\nconst _in = ns('in');\nconst maxCount = ns('maxCount');\nconst minCount = ns('minCount');\nconst inList = ns('inList');\nconst name = ns('name');\nconst description = ns('description');\nconst NodeShape = ns('NodeShape');\nconst optional = ns('optional');\nconst Parameter = ns('Parameter');\nconst PrefixDeclaration = ns('PrefixDeclaration');\nconst path = ns('path');\nconst property = ns('property');\nconst prefix = ns('prefix');\nconst PropertyShape = ns('PropertyShape');\nconst targetClass = ns('targetClass');\nconst targetNode = ns('targetNode');\nconst targetObjectsOf = ns('targetObjectsOf');\nconst qualifiedValueShape = ns('qualifiedValueShape');\nconst qualifiedMaxCount = ns('qualifiedMaxCount');\nconst or = ns('or');\nconst node = ns('node');\nconst nodeKind = ns('nodeKind');\nconst Shape = ns('Shape');\n\nconst equals = ns('equals');\nconst disjoint = ns('disjoint');\nconst hasValue = ns('hasValue');\nconst defaultValue = ns('defaultValue');\nconst order = ns('order');\nconst group = ns('group');\nconst closed = ns('closed');\nconst ignoredProperties = ns('ignoredProperties');\n\nconst alternativePath = ns('alternativePath');\nconst inversePath = ns('inversePath');\nconst zeroOrMorePath = ns('zeroOrMorePath');\nconst oneOrMorePath = ns('oneOrMorePath');\nconst zeroOrOnePath = ns('zeroOrOnePath');\n\nconst BlankNode = ns('BlankNode');\nconst IRI = ns('IRI');\nconst Literal = ns('Literal');\nconst BlankNodeOrIRI = ns('BlankNodeOrIRI');\nconst BlankNodeOrLiteral = ns('BlankNodeOrLiteral');\nconst IRIOrLiteral = ns('IRIOrLiteral');\n\nexport const languageIn = ns('languageIn');\nexport const lessThan = ns('lessThan');\nexport const lessThanOrEquals = ns('lessThanOrEquals');\nexport const maxExclusive = ns('maxExclusive');\nexport const maxInclusive = ns('maxInclusive');\nexport const maxLength = ns('maxLength');\nexport const minExclusive = ns('minExclusive');\nexport const minInclusive = ns('minInclusive');\nexport const minLength = ns('minLength');\nexport const pattern = ns('pattern');\nexport const uniqueLang = ns('uniqueLang');\nexport const ValidationReport = ns('ValidationReport');\nexport const conforms = ns('conforms');\nexport const ValidationResult = ns('ValidationResult');\nexport const focusNode = ns('focusNode');\nexport const sourceShape = ns('sourceShape');\nexport const resultSeverity = ns('resultSeverity');\nexport const resultPath = ns('resultPath');\nexport const value = ns('value');\n/** `sh:message` — a custom message declared on a shape or constraint. */\nexport const message = ns('message');\n/** `sh:resultMessage` — the message carried by a validation result. */\nexport const resultMessage = ns('resultMessage');\n/** `sh:detail` — links a validation result to the results that explain it. */\nexport const detail = ns('detail');\nexport const Violation = ns('Violation');\nexport const AbstractResult = ns('AbstractResult');\nexport const sourceConstraintComponent = ns('sourceConstraintComponent');\nexport const ClassConstraintComponent = ns('ClassConstraintComponent');\nexport const NodeConstraintComponent = ns('NodeConstraintComponent');\nexport const DatatypeConstraintComponent = ns('DatatypeConstraintComponent');\nexport const MinLengthConstraintComponent = ns('MinLengthConstraintComponent');\nexport const MaxLengthConstraintComponent = ns('MaxLengthConstraintComponent');\nexport const MinInclusiveConstraintComponent = ns('MinInclusiveConstraintComponent');\nexport const MaxInclusiveConstraintComponent = ns('MaxInclusiveConstraintComponent');\nexport const MinExclusiveConstraintComponent = ns('MinExclusiveConstraintComponent');\nexport const MaxExclusiveConstraintComponent = ns('MaxExclusiveConstraintComponent');\nexport const PatternConstraintComponent = ns('PatternConstraintComponent');\nexport const InConstraintComponent = ns('InConstraintComponent');\nexport const MinCountConstraintComponent = ns('MinCountConstraintComponent');\nexport const MaxCountConstraintComponent = ns('MaxCountConstraintComponent');\nexport const NodeKindConstraintComponent = ns('NodeKindConstraintComponent');\nexport const ClosedConstraintComponent = ns('ClosedConstraintComponent');\nexport const Warning = ns('Warning');\nexport const Info = ns('Info');\nexport const result = ns('result');\n\n//make sure every node is also exported here\nexport const shacl = {\n class: _class,\n datatype,\n declare,\n in: _in,\n maxCount,\n minCount,\n name,\n description,\n node,\n NodeShape,\n optional,\n Parameter,\n PrefixDeclaration,\n path,\n prefix,\n property,\n PropertyShape,\n Shape,\n targetClass,\n targetNode,\n targetObjectsOf,\n qualifiedValueShape,\n qualifiedMaxCount,\n or,\n BlankNode,\n IRI,\n Literal,\n BlankNodeOrIRI,\n BlankNodeOrLiteral,\n IRIOrLiteral,\n nodeKind,\n inList,\n equals,\n disjoint,\n hasValue,\n defaultValue,\n order,\n group,\n closed,\n ignoredProperties,\n languageIn,\n lessThan,\n lessThanOrEquals,\n maxExclusive,\n maxInclusive,\n maxLength,\n minExclusive,\n minInclusive,\n minLength,\n pattern,\n uniqueLang,\n ValidationReport,\n conforms,\n ValidationResult,\n focusNode,\n sourceShape,\n resultSeverity,\n resultPath,\n value,\n message,\n resultMessage,\n detail,\n Violation,\n sourceConstraintComponent,\n ClassConstraintComponent,\n NodeConstraintComponent,\n DatatypeConstraintComponent,\n MinLengthConstraintComponent,\n MaxLengthConstraintComponent,\n MinCountConstraintComponent,\n MaxCountConstraintComponent,\n MinInclusiveConstraintComponent,\n MaxInclusiveConstraintComponent,\n MinExclusiveConstraintComponent,\n MaxExclusiveConstraintComponent,\n PatternConstraintComponent,\n InConstraintComponent,\n NodeKindConstraintComponent,\n ClosedConstraintComponent,\n Warning,\n Info,\n AbstractResult,\n result,\n alternativePath,\n inversePath,\n zeroOrMorePath,\n oneOrMorePath,\n zeroOrOnePath,\n};\n"]}
|
|
@@ -84,7 +84,7 @@ const toFieldUpdate = (field, collector) => {
|
|
|
84
84
|
};
|
|
85
85
|
};
|
|
86
86
|
const toNodeData = (description, collector) => {
|
|
87
|
-
return Object.assign(
|
|
87
|
+
return Object.assign({ shape: description.shape.id, fields: description.fields.map((f) => toFieldUpdate(f, collector)) }, (description.__id ? { id: description.__id } : {}));
|
|
88
88
|
};
|
|
89
89
|
/** Builds an IRCreateMutation from a create factory's internal description. */
|
|
90
90
|
export const buildCanonicalCreateMutationIR = (query) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IRMutation.js","sourceRoot":"","sources":["../../../src/queries/IRMutation.ts"],"names":[],"mappings":"AACA,OAAO,EAML,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,gBAAgB,EAAE,qBAAqB,EAAC,MAAM,kCAAkC,CAAC;AAiBzF,OAAO,EAAC,uBAAuB,EAAC,MAAM,cAAc,CAAC;AAmBrD;;;GAGG;AACH,MAAM,wBAAwB,GAAG,CAC/B,OAA6B,EAC7B,OAAe,EACT,EAAE;;IACR,KAAK,MAAM,KAAK,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,EAAE,EAAE,CAAC;QAC1C,iFAAiF;QACjF,4CAA4C;QAC5C,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,+DAA+D,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,OAAO,KAAK;gBAC9F,6FAA6F;gBAC7F,4EAA4E;gBAC5E,mDAAmD,CACtD,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAOF,MAAM,eAAe,GAAG,CAAC,KAAyB,EAAsB,EAAE,CAAC,CAAC;IAC1E,EAAE,EAAE,KAAK,CAAC,EAAE;CACb,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,KAA2B,EAA0B,EAAE;IAChF,OAAO;QACL,G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,SAAS,GAAG,wBAAwB,EAAE,CAAC;IAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAClD,uBACE,IAAI,EAAE,cAAc,EACpB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,EACrB,IAAI,EACJ,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,KAAK,CAAC,aAAa,IAC/B,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC/B,CAAC,CAAC,EAAC,iBAAiB,EAAE,SAAS,CAAC,QAAQ,EAAC;QACzC,CAAC,CAAC,EAAE,CAAC,EACP;AACJ,CAAC,CAAC","sourcesContent":["import type {NodeShapeData} from '../shapes/SHACL.js';\nimport {\n type NodeDescriptionValue,\n NodeReferenceValue,\n type PropUpdateValue,\n type SetModificationValue,\n type SinglePropertyUpdateValue,\n isSetModificationValue,\n} from './QueryFactory.js';\nimport {isExpressionNode, resolveExpressionRefs} from '../expressions/ExpressionNode.js';\nimport type {\n IRCreateMutation,\n IRDeleteMutation,\n IRDeleteAllMutation,\n IRDeleteWhereMutation,\n IRUpdateWhereMutation,\n IRFieldValue,\n IRNodeData,\n IRFieldUpdate,\n IRSetModificationValue,\n IRUpdateMutation,\n IRUpsertMutation,\n IRExpression,\n IRGraphPattern,\n IRTraversalPattern,\n} from './IntermediateRepresentation.js';\nimport {createTraversalResolver} from './IRLower.js';\n\ntype CreateMutationInput = {\n shape: NodeShapeData;\n description: NodeDescriptionValue;\n};\n\ntype UpdateMutationInput = {\n id: string;\n shape: NodeShapeData;\n updates: NodeDescriptionValue;\n};\n\ntype UpsertMutationInput = {\n id: string;\n shape: NodeShapeData;\n updates: NodeDescriptionValue;\n};\n\n/**\n * Throws if any field of an upsert carries an expression. Named per offending property so\n * the caller is not left decoding an unbound-variable mystery further down the pipeline.\n */\nconst assertNoExpressionFields = (\n updates: NodeDescriptionValue,\n shapeId: string,\n): void => {\n for (const field of updates?.fields ?? []) {\n // Mirrors how `toSingleFieldValue` recognises an expression, so the guard cannot\n // drift from the lowering it is protecting.\n if (isExpressionNode(field.val)) {\n throw new Error(\n `upsert does not support expression-valued fields (property \"${field.prop.id}\" of ${shapeId}). ` +\n `An expression reads the node's current value, which does not exist when upsert creates it, ` +\n `and the property would be silently skipped. Pass a concrete value, or use ` +\n `update().for({id}) if the node is known to exist.`,\n );\n }\n }\n};\n\ntype DeleteMutationInput = {\n shape: NodeShapeData;\n ids: NodeReferenceValue[];\n};\n\nconst toNodeReference = (value: NodeReferenceValue): NodeReferenceValue => ({\n id: value.id,\n});\n\nconst toSetModification = (value: SetModificationValue): IRSetModificationValue => {\n return {\n add: value.$add\n ? value.$add.map((item) => toFieldValue(item as unknown as PropUpdateValue))\n : undefined,\n remove: value.$remove ? value.$remove.map((item) => toNodeReference(item)) : undefined,\n };\n};\n\n/** Alias used as the mutation subject for expression ref resolution. */\nconst MUTATION_SUBJECT_ALIAS = '__mutation_subject__';\n\nexport type TraversalCollector = {\n resolve: (fromAlias: string, propertyShapeId: string) => string;\n patterns: IRTraversalPattern[];\n};\n\n/**\n * Create a traversal collector for mutation expressions. Uses `__trav_N__` alias\n * prefixes to avoid collision with query aliases (a0, a1...) and the mutation\n * subject placeholder. Delegates to the shared createTraversalResolver factory.\n */\nexport function createTraversalCollector(): TraversalCollector {\n let counter = 0;\n return createTraversalResolver(\n () => `__trav_${counter++}__`,\n (from, to, property): IRTraversalPattern => ({from, property, to}),\n );\n}\n\nconst toSingleFieldValue = (\n value: SinglePropertyUpdateValue,\n collector?: TraversalCollector,\n): IRFieldValue => {\n if (value === undefined) {\n return undefined;\n }\n\n // ExpressionNode → resolve refs and extract IRExpression\n if (isExpressionNode(value)) {\n return resolveExpressionRefs(\n value.ir,\n value._refs,\n MUTATION_SUBJECT_ALIAS,\n // In mutation context, all property segments are on the subject entity.\n // For single-segment refs (e.g. p.age), the property_expr already has the property as its .property.\n // For multi-segment refs (e.g. p.bestFriend.name), this creates intermediate traversals.\n collector\n ? collector.resolve\n : (_fromAlias, _propertyShapeId) => {\n // No collector provided — multi-segment traversals cannot be resolved.\n return MUTATION_SUBJECT_ALIAS;\n },\n );\n }\n\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n ) {\n return value;\n }\n\n if ('id' in (value as NodeReferenceValue)) {\n return toNodeReference(value as NodeReferenceValue);\n }\n\n return toNodeData(value as NodeDescriptionValue);\n};\n\nconst toFieldValue = (\n value: PropUpdateValue,\n collector?: TraversalCollector,\n): IRFieldValue => {\n if (Array.isArray(value)) {\n return value.map((item) => toSingleFieldValue(item, collector));\n }\n\n if (isSetModificationValue(value)) {\n return toSetModification(value);\n }\n\n return toSingleFieldValue(value, collector);\n};\n\nconst toFieldUpdate = (\n field: NodeDescriptionValue['fields'][number],\n collector?: TraversalCollector,\n): IRFieldUpdate => {\n return {\n property: field.prop.id,\n value: toFieldValue(field.val, collector),\n };\n};\n\nconst toNodeData = (\n description: NodeDescriptionValue,\n collector?: TraversalCollector,\n): IRNodeData => {\n return {\n shape: description.shape.id,\n fields: description.fields.map((f) => toFieldUpdate(f, collector)),\n ...(description.__id ? {id: description.__id} : {}),\n ...(description.__blank ? {blank: true as const} : {}),\n };\n};\n\n/** Builds an IRCreateMutation from a create factory's internal description. */\nexport const buildCanonicalCreateMutationIR = (\n query: CreateMutationInput,\n): IRCreateMutation => {\n return {\n kind: 'create',\n shape: query.shape.id,\n data: toNodeData(query.description),\n };\n};\n\n/** Builds an IRUpdateMutation from an update factory's internal description. */\nexport const buildCanonicalUpdateMutationIR = (\n query: UpdateMutationInput,\n): IRUpdateMutation => {\n const collector = createTraversalCollector();\n const data = toNodeData(query.updates, collector);\n return {\n kind: 'update',\n shape: query.shape.id,\n id: query.id,\n data,\n ...(collector.patterns.length > 0\n ? {traversalPatterns: collector.patterns}\n : {}),\n };\n};\n\n/**\n * Builds an IRUpsertMutation — an update that also asserts the node's type, so it is\n * correct whether or not the node exists.\n *\n * Rejects expression-valued fields. An expression such as `age: p.age.plus(1)` lowers to\n * a BIND over the node's current value; when the node does not exist that ref is unbound,\n * and SPARQL drops any INSERT triple containing an unbound variable. The write would\n * report success and store nothing for that property — precisely the silent-wrong-write\n * this primitive exists to remove, so it is refused rather than documented.\n */\nexport const buildCanonicalUpsertMutationIR = (\n query: UpsertMutationInput,\n): IRUpsertMutation => {\n assertNoExpressionFields(query.updates, query.shape.id);\n const collector = createTraversalCollector();\n const data = toNodeData(query.updates, collector);\n return {\n kind: 'upsert',\n shape: query.shape.id,\n id: query.id,\n data,\n ...(collector.patterns.length > 0\n ? {traversalPatterns: collector.patterns}\n : {}),\n };\n};\n\n/** Builds an IRDeleteMutation from a delete factory's internal description. */\nexport const buildCanonicalDeleteMutationIR = (\n query: DeleteMutationInput,\n): IRDeleteMutation => {\n return {\n kind: 'delete',\n shape: query.shape.id,\n ids: query.ids.map((id) => ({id: id.id})),\n };\n};\n\ntype DeleteAllMutationInput = {\n shape: NodeShapeData;\n};\n\n/** Builds an IRDeleteAllMutation — delete all instances of a shape type. */\nexport const buildCanonicalDeleteAllMutationIR = (\n query: DeleteAllMutationInput,\n): IRDeleteAllMutation => {\n return {\n kind: 'delete_all',\n shape: query.shape.id,\n };\n};\n\ntype DeleteWhereMutationInput = {\n shape: NodeShapeData;\n where: IRExpression;\n wherePatterns: IRGraphPattern[];\n};\n\n/** Builds an IRDeleteWhereMutation — delete instances matching a condition. */\nexport const buildCanonicalDeleteWhereMutationIR = (\n query: DeleteWhereMutationInput,\n): IRDeleteWhereMutation => {\n return {\n kind: 'delete_where',\n shape: query.shape.id,\n where: query.where,\n wherePatterns: query.wherePatterns,\n };\n};\n\ntype UpdateWhereMutationInput = {\n shape: NodeShapeData;\n updates: NodeDescriptionValue;\n where?: IRExpression;\n wherePatterns?: IRGraphPattern[];\n};\n\n/** Builds an IRUpdateWhereMutation — update instances matching a condition or all. */\nexport const buildCanonicalUpdateWhereMutationIR = (\n query: UpdateWhereMutationInput,\n): IRUpdateWhereMutation => {\n const collector = createTraversalCollector();\n const data = toNodeData(query.updates, collector);\n return {\n kind: 'update_where',\n shape: query.shape.id,\n data,\n where: query.where,\n wherePatterns: query.wherePatterns,\n ...(collector.patterns.length > 0\n ? {traversalPatterns: collector.patterns}\n : {}),\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"IRMutation.js","sourceRoot":"","sources":["../../../src/queries/IRMutation.ts"],"names":[],"mappings":"AACA,OAAO,EAML,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,gBAAgB,EAAE,qBAAqB,EAAC,MAAM,kCAAkC,CAAC;AAiBzF,OAAO,EAAC,uBAAuB,EAAC,MAAM,cAAc,CAAC;AAmBrD;;;GAGG;AACH,MAAM,wBAAwB,GAAG,CAC/B,OAA6B,EAC7B,OAAe,EACT,EAAE;;IACR,KAAK,MAAM,KAAK,IAAI,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,EAAE,EAAE,CAAC;QAC1C,iFAAiF;QACjF,4CAA4C;QAC5C,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACb,+DAA+D,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,OAAO,KAAK;gBAC9F,6FAA6F;gBAC7F,4EAA4E;gBAC5E,mDAAmD,CACtD,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC;AAOF,MAAM,eAAe,GAAG,CAAC,KAAyB,EAAsB,EAAE,CAAC,CAAC;IAC1E,EAAE,EAAE,KAAK,CAAC,EAAE;CACb,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,CAAC,KAA2B,EAA0B,EAAE;IAChF,OAAO;QACL,GAAG,EAAE,KAAK,CAAC,IAAI;YACb,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,E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KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,KAAK,CAAC,aAAa,IAC/B,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC/B,CAAC,CAAC,EAAC,iBAAiB,EAAE,SAAS,CAAC,QAAQ,EAAC;QACzC,CAAC,CAAC,EAAE,CAAC,EACP;AACJ,CAAC,CAAC","sourcesContent":["import type {NodeShapeData} from '../shapes/SHACL.js';\nimport {\n type NodeDescriptionValue,\n NodeReferenceValue,\n type PropUpdateValue,\n type SetModificationValue,\n type SinglePropertyUpdateValue,\n isSetModificationValue,\n} from './QueryFactory.js';\nimport {isExpressionNode, resolveExpressionRefs} from '../expressions/ExpressionNode.js';\nimport type {\n IRCreateMutation,\n IRDeleteMutation,\n IRDeleteAllMutation,\n IRDeleteWhereMutation,\n IRUpdateWhereMutation,\n IRFieldValue,\n IRNodeData,\n IRFieldUpdate,\n IRSetModificationValue,\n IRUpdateMutation,\n IRUpsertMutation,\n IRExpression,\n IRGraphPattern,\n IRTraversalPattern,\n} from './IntermediateRepresentation.js';\nimport {createTraversalResolver} from './IRLower.js';\n\ntype CreateMutationInput = {\n shape: NodeShapeData;\n description: NodeDescriptionValue;\n};\n\ntype UpdateMutationInput = {\n id: string;\n shape: NodeShapeData;\n updates: NodeDescriptionValue;\n};\n\ntype UpsertMutationInput = {\n id: string;\n shape: NodeShapeData;\n updates: NodeDescriptionValue;\n};\n\n/**\n * Throws if any field of an upsert carries an expression. Named per offending property so\n * the caller is not left decoding an unbound-variable mystery further down the pipeline.\n */\nconst assertNoExpressionFields = (\n updates: NodeDescriptionValue,\n shapeId: string,\n): void => {\n for (const field of updates?.fields ?? []) {\n // Mirrors how `toSingleFieldValue` recognises an expression, so the guard cannot\n // drift from the lowering it is protecting.\n if (isExpressionNode(field.val)) {\n throw new Error(\n `upsert does not support expression-valued fields (property \"${field.prop.id}\" of ${shapeId}). ` +\n `An expression reads the node's current value, which does not exist when upsert creates it, ` +\n `and the property would be silently skipped. Pass a concrete value, or use ` +\n `update().for({id}) if the node is known to exist.`,\n );\n }\n }\n};\n\ntype DeleteMutationInput = {\n shape: NodeShapeData;\n ids: NodeReferenceValue[];\n};\n\nconst toNodeReference = (value: NodeReferenceValue): NodeReferenceValue => ({\n id: value.id,\n});\n\nconst toSetModification = (value: SetModificationValue): IRSetModificationValue => {\n return {\n add: value.$add\n ? value.$add.map((item) => toFieldValue(item as unknown as PropUpdateValue))\n : undefined,\n remove: value.$remove ? value.$remove.map((item) => toNodeReference(item)) : undefined,\n };\n};\n\n/** Alias used as the mutation subject for expression ref resolution. */\nconst MUTATION_SUBJECT_ALIAS = '__mutation_subject__';\n\nexport type TraversalCollector = {\n resolve: (fromAlias: string, propertyShapeId: string) => string;\n patterns: IRTraversalPattern[];\n};\n\n/**\n * Create a traversal collector for mutation expressions. Uses `__trav_N__` alias\n * prefixes to avoid collision with query aliases (a0, a1...) and the mutation\n * subject placeholder. Delegates to the shared createTraversalResolver factory.\n */\nexport function createTraversalCollector(): TraversalCollector {\n let counter = 0;\n return createTraversalResolver(\n () => `__trav_${counter++}__`,\n (from, to, property): IRTraversalPattern => ({from, property, to}),\n );\n}\n\nconst toSingleFieldValue = (\n value: SinglePropertyUpdateValue,\n collector?: TraversalCollector,\n): IRFieldValue => {\n if (value === undefined) {\n return undefined;\n }\n\n // ExpressionNode → resolve refs and extract IRExpression\n if (isExpressionNode(value)) {\n return resolveExpressionRefs(\n value.ir,\n value._refs,\n MUTATION_SUBJECT_ALIAS,\n // In mutation context, all property segments are on the subject entity.\n // For single-segment refs (e.g. p.age), the property_expr already has the property as its .property.\n // For multi-segment refs (e.g. p.bestFriend.name), this creates intermediate traversals.\n collector\n ? collector.resolve\n : (_fromAlias, _propertyShapeId) => {\n // No collector provided — multi-segment traversals cannot be resolved.\n return MUTATION_SUBJECT_ALIAS;\n },\n );\n }\n\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n ) {\n return value;\n }\n\n if ('id' in (value as NodeReferenceValue)) {\n return toNodeReference(value as NodeReferenceValue);\n }\n\n return toNodeData(value as NodeDescriptionValue);\n};\n\nconst toFieldValue = (\n value: PropUpdateValue,\n collector?: TraversalCollector,\n): IRFieldValue => {\n if (Array.isArray(value)) {\n return value.map((item) => toSingleFieldValue(item, collector));\n }\n\n if (isSetModificationValue(value)) {\n return toSetModification(value);\n }\n\n return toSingleFieldValue(value, collector);\n};\n\nconst toFieldUpdate = (\n field: NodeDescriptionValue['fields'][number],\n collector?: TraversalCollector,\n): IRFieldUpdate => {\n return {\n property: field.prop.id,\n value: toFieldValue(field.val, collector),\n };\n};\n\nconst toNodeData = (\n description: NodeDescriptionValue,\n collector?: TraversalCollector,\n): IRNodeData => {\n return {\n shape: description.shape.id,\n fields: description.fields.map((f) => toFieldUpdate(f, collector)),\n ...(description.__id ? {id: description.__id} : {}),\n };\n};\n\n/** Builds an IRCreateMutation from a create factory's internal description. */\nexport const buildCanonicalCreateMutationIR = (\n query: CreateMutationInput,\n): IRCreateMutation => {\n return {\n kind: 'create',\n shape: query.shape.id,\n data: toNodeData(query.description),\n };\n};\n\n/** Builds an IRUpdateMutation from an update factory's internal description. */\nexport const buildCanonicalUpdateMutationIR = (\n query: UpdateMutationInput,\n): IRUpdateMutation => {\n const collector = createTraversalCollector();\n const data = toNodeData(query.updates, collector);\n return {\n kind: 'update',\n shape: query.shape.id,\n id: query.id,\n data,\n ...(collector.patterns.length > 0\n ? {traversalPatterns: collector.patterns}\n : {}),\n };\n};\n\n/**\n * Builds an IRUpsertMutation — an update that also asserts the node's type, so it is\n * correct whether or not the node exists.\n *\n * Rejects expression-valued fields. An expression such as `age: p.age.plus(1)` lowers to\n * a BIND over the node's current value; when the node does not exist that ref is unbound,\n * and SPARQL drops any INSERT triple containing an unbound variable. The write would\n * report success and store nothing for that property — precisely the silent-wrong-write\n * this primitive exists to remove, so it is refused rather than documented.\n */\nexport const buildCanonicalUpsertMutationIR = (\n query: UpsertMutationInput,\n): IRUpsertMutation => {\n assertNoExpressionFields(query.updates, query.shape.id);\n const collector = createTraversalCollector();\n const data = toNodeData(query.updates, collector);\n return {\n kind: 'upsert',\n shape: query.shape.id,\n id: query.id,\n data,\n ...(collector.patterns.length > 0\n ? {traversalPatterns: collector.patterns}\n : {}),\n };\n};\n\n/** Builds an IRDeleteMutation from a delete factory's internal description. */\nexport const buildCanonicalDeleteMutationIR = (\n query: DeleteMutationInput,\n): IRDeleteMutation => {\n return {\n kind: 'delete',\n shape: query.shape.id,\n ids: query.ids.map((id) => ({id: id.id})),\n };\n};\n\ntype DeleteAllMutationInput = {\n shape: NodeShapeData;\n};\n\n/** Builds an IRDeleteAllMutation — delete all instances of a shape type. */\nexport const buildCanonicalDeleteAllMutationIR = (\n query: DeleteAllMutationInput,\n): IRDeleteAllMutation => {\n return {\n kind: 'delete_all',\n shape: query.shape.id,\n };\n};\n\ntype DeleteWhereMutationInput = {\n shape: NodeShapeData;\n where: IRExpression;\n wherePatterns: IRGraphPattern[];\n};\n\n/** Builds an IRDeleteWhereMutation — delete instances matching a condition. */\nexport const buildCanonicalDeleteWhereMutationIR = (\n query: DeleteWhereMutationInput,\n): IRDeleteWhereMutation => {\n return {\n kind: 'delete_where',\n shape: query.shape.id,\n where: query.where,\n wherePatterns: query.wherePatterns,\n };\n};\n\ntype UpdateWhereMutationInput = {\n shape: NodeShapeData;\n updates: NodeDescriptionValue;\n where?: IRExpression;\n wherePatterns?: IRGraphPattern[];\n};\n\n/** Builds an IRUpdateWhereMutation — update instances matching a condition or all. */\nexport const buildCanonicalUpdateWhereMutationIR = (\n query: UpdateWhereMutationInput,\n): IRUpdateWhereMutation => {\n const collector = createTraversalCollector();\n const data = toNodeData(query.updates, collector);\n return {\n kind: 'update_where',\n shape: query.shape.id,\n data,\n where: query.where,\n wherePatterns: query.wherePatterns,\n ...(collector.patterns.length > 0\n ? {traversalPatterns: collector.patterns}\n : {}),\n };\n};\n"]}
|
|
@@ -280,11 +280,6 @@ export type IRNodeData = {
|
|
|
280
280
|
shape: string;
|
|
281
281
|
fields: IRFieldUpdate[];
|
|
282
282
|
id?: string;
|
|
283
|
-
/**
|
|
284
|
-
* A nested node written as a fresh blank node with only its field triples: no IRI, no
|
|
285
|
-
* `rdf:type` (see `NodeDescriptionValue.__blank`). Never set together with `id`.
|
|
286
|
-
*/
|
|
287
|
-
blank?: true;
|
|
288
283
|
};
|
|
289
284
|
export type IRFieldUpdate = {
|
|
290
285
|
property: string;
|