@_linked/core 2.28.3 → 2.29.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 +70 -0
- package/README.md +113 -1
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/ontologies/linked-core.d.ts +2 -0
- package/lib/esm/ontologies/linked-core.js +10 -0
- package/lib/esm/ontologies/linked-core.js.map +1 -1
- package/lib/esm/ontologies/shacl.d.ts +1 -0
- package/lib/esm/ontologies/shacl.js +2 -0
- package/lib/esm/ontologies/shacl.js.map +1 -1
- package/lib/esm/queries/MutationQuery.js +17 -1
- package/lib/esm/queries/MutationQuery.js.map +1 -1
- package/lib/esm/shapes/SHACL.d.ts +15 -2
- package/lib/esm/shapes/SHACL.js.map +1 -1
- package/lib/esm/shapes/singleOwnerConstraint.d.ts +27 -0
- package/lib/esm/shapes/singleOwnerConstraint.js +89 -0
- package/lib/esm/shapes/singleOwnerConstraint.js.map +1 -0
- package/lib/esm/shapes/syncShapes.js +50 -11
- package/lib/esm/shapes/syncShapes.js.map +1 -1
- package/lib/esm/sparql/SparqlDataset.d.ts +9 -1
- package/lib/esm/sparql/SparqlDataset.js +19 -0
- package/lib/esm/sparql/SparqlDataset.js.map +1 -1
- package/lib/esm/sparql/irToAlgebra.d.ts +34 -6
- package/lib/esm/sparql/irToAlgebra.js +271 -42
- package/lib/esm/sparql/irToAlgebra.js.map +1 -1
- package/lib/esm/sparql/ownedLinkCheck.d.ts +50 -0
- package/lib/esm/sparql/ownedLinkCheck.js +142 -0
- package/lib/esm/sparql/ownedLinkCheck.js.map +1 -0
- package/lib/esm/utils/Package.js +8 -0
- package/lib/esm/utils/Package.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.29.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#328](https://github.com/linked-fw/core/pull/328) [`c6fa4ef`](https://github.com/linked-fw/core/commit/c6fa4efbe105cb4af276c6d81fbb923e337ff182) Thanks [@flyon](https://github.com/flyon)! - Owned (`contains`) values:
|
|
8
|
+
- re-sending the current `{id}` is now a no-op, where before it deleted that node's own triples;
|
|
9
|
+
- an array overwrite keeps the ids it sends again and deletes only the ones left out; a set
|
|
10
|
+
modification that removes and re-adds the same id leaves that node alone;
|
|
11
|
+
- deleting a subject, by id or in bulk (`.all()`, `.where(...)`), now deletes its immediately-owned
|
|
12
|
+
children (every `contains` property that declares a `shape`), as documented. The `dependent`
|
|
13
|
+
cascade below them now only visits the dependent shapes the deleted shape can reach through its
|
|
14
|
+
owned properties, so a shape that owns only non-dependent values pays no cascade cost;
|
|
15
|
+
- a `contains` property without a value shape only deletes `dependent`-typed values;
|
|
16
|
+
- linking a node of the wrong class into an owned property that declares a shape is refused before
|
|
17
|
+
anything is written (one `SELECT` per mutation that links owned ids, none otherwise).
|
|
18
|
+
|
|
19
|
+
Shape sync now also writes one generated SHACL NodeShape per `contains` property with a value
|
|
20
|
+
shape, at `<property shape IRI>.singleOwner`, written only by the class that declares the property.
|
|
21
|
+
It limits each value of that predicate to one owner (`sh:targetObjectsOf <p>` plus an
|
|
22
|
+
`sh:inversePath <p>` property with `sh:maxCount 1`) and is marked `core:generated true`, with no
|
|
23
|
+
`sh:targetClass`, so catalog readers can skip it. The declaring shape owns these through a new
|
|
24
|
+
`core:generatedShape` edge, so sync still sends two requests per shape: the delete removes them and
|
|
25
|
+
the create writes them nested. A removed or renamed accessor's constraint goes with the next sync.
|
|
26
|
+
Core does not enforce the constraint on write; run a SHACL validator against the persisted shapes.
|
|
27
|
+
|
|
28
|
+
New exports and meta-model terms:
|
|
29
|
+
- `singleOwnerShapeIri(propertyShapeIri)`, `singleOwnerProperties(nodeShape)` and
|
|
30
|
+
`buildSingleOwnerConstraints(nodeShape, shapeIri)` from `@_linked/core`, to recompute the
|
|
31
|
+
generated shapes' IRIs and data;
|
|
32
|
+
- `NodeShape.targetObjectsOf` (`sh:targetObjectsOf`), `NodeShape.generated` (`core:generated`) and
|
|
33
|
+
`NodeShape.generatedShapes` (`core:generatedShape`, `contains`);
|
|
34
|
+
- `shacl.targetObjectsOf` (`@_linked/core/ontologies/shacl`), `coreOntology.generated` and
|
|
35
|
+
`coreOntology.generatedShape` (`@_linked/core/ontologies/linked-core`).
|
|
36
|
+
|
|
37
|
+
See the README section "Owned properties (`contains` / `dependent`)".
|
|
38
|
+
|
|
39
|
+
**Behaviour changes.** Check these before upgrading:
|
|
40
|
+
- **Deletes now delete owned children.** `@_linked/schema` declares `Thing.image` as `contains`,
|
|
41
|
+
so deleting any schema-derived entity (by id or in bulk) now deletes its linked `ImageObject`s,
|
|
42
|
+
including ones linked by `{id}`. If your data shares one image between several entities through
|
|
43
|
+
`image`, deleting one of them deletes the shared image. Link shared images through a property
|
|
44
|
+
that does not own them.
|
|
45
|
+
- **Linked `{id}`s are class-checked.** Linking an existing node by `{id}` into an owned property
|
|
46
|
+
(any property on a `contains` predicate that declares a shape) is refused when the node is typed
|
|
47
|
+
and none of its types is the shape's class, a registered sub-shape's class, or `sh:class`. A node
|
|
48
|
+
typed only with a subclass that has no registered shape is refused. To accept it, register a shape
|
|
49
|
+
for that subclass (extending the value shape), or declare `sh:class`. Untyped or not-yet-existing
|
|
50
|
+
ids are allowed.
|
|
51
|
+
- **Plain properties on a `contains` predicate are checked too.** Ownership is decided per
|
|
52
|
+
predicate across the registry, so a property *without* `contains` whose predicate another shape
|
|
53
|
+
declares `contains` is class-checked as well (and a replace through it deletes the old value).
|
|
54
|
+
Example: an application shape that declares `schema:image` without `contains`, while
|
|
55
|
+
`@_linked/schema` declares `Thing.image` as `contains`. To resolve a refusal, link a node of the
|
|
56
|
+
value shape's class (or a registered sub-shape's class), register a shape for the node's
|
|
57
|
+
subclass, declare `sh:class` on the property, or use a predicate that no shape owns.
|
|
58
|
+
- **Shape-less `contains` properties keep non-dependent old values.** A `contains` property without
|
|
59
|
+
a value shape (a polymorphic slot such as `sh:path`) no longer deletes the old value's own triples
|
|
60
|
+
on replace or remove. A non-dependent old value is now left in place and may orphan.
|
|
61
|
+
|
|
62
|
+
## 2.28.4
|
|
63
|
+
|
|
64
|
+
### Patch Changes
|
|
65
|
+
|
|
66
|
+
- [#326](https://github.com/linked-fw/core/pull/326) [`4596a60`](https://github.com/linked-fw/core/commit/4596a6020e3caab7f4cad0b88ae9098ea3b1dce2) Thanks [@flyon](https://github.com/flyon)! - Lowering a create or update no longer deletes the `shape` key from the caller's nested values.
|
|
67
|
+
`LiveQueryStore` lowers an executed mutation a second time to derive its effects, and a nested value
|
|
68
|
+
of a property that declares no shape (a property shape's `sh:path` when it is not a plain IRI) could
|
|
69
|
+
then no longer be validated: it logged `could not derive the effects of a mutation; live queries were
|
|
70
|
+
not refetched ShapeValidationError: Cannot validate the value of 'path'` and skipped the live-query
|
|
71
|
+
refetch. `syncShape` / `syncShapes` hit this for every shape with an inverse, sequence or alternative path.
|
|
72
|
+
|
|
3
73
|
## 2.28.3
|
|
4
74
|
|
|
5
75
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -246,7 +246,8 @@ removing the link leaves the referenced node untouched. Two optional flags let y
|
|
|
246
246
|
**`contains: true` on an object property** — the edge asserts *exclusive ownership* of the
|
|
247
247
|
value. Whenever that edge goes away, the owned node is deleted with it:
|
|
248
248
|
|
|
249
|
-
- `parent.delete()` deletes the owned child (and its owned sub-tree).
|
|
249
|
+
- `parent.delete()` deletes the owned child (and its owned sub-tree). So do the bulk deletes,
|
|
250
|
+
`DeleteBuilder.from(Parent).all()` and `.where(...)`.
|
|
250
251
|
- `update({ownedProp: newValue})` **replaces** the owned node — the old one is deleted, not
|
|
251
252
|
orphaned.
|
|
252
253
|
- `update({ownedProp: {remove: [x]}})` deletes `x` itself, not just the link.
|
|
@@ -263,6 +264,117 @@ export class Person extends Shape {
|
|
|
263
264
|
}
|
|
264
265
|
```
|
|
265
266
|
|
|
267
|
+
**Replace versus patch in place.** A plain nested object on a `contains` property is a
|
|
268
|
+
*replace*: a new node is created and the old one is deleted. To change the owned node itself,
|
|
269
|
+
update it directly:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
// Replace: creates a new ImageObject, deletes the old one.
|
|
273
|
+
await Person.update({avatar: {contentUrl: 'https://cdn.example.org/b.png'}}).for(personId);
|
|
274
|
+
|
|
275
|
+
// Patch in place: the same ImageObject keeps its id and its other fields.
|
|
276
|
+
await ImageObject.update({contentUrl: 'https://cdn.example.org/b.png'}).for(avatarId);
|
|
277
|
+
|
|
278
|
+
// Re-sending the current id is a no-op: the edge and the node are left as they are.
|
|
279
|
+
await Person.update({avatar: {id: avatarId}}).for(personId);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
The same holds for an array overwrite of a `contains` set: ids you send again are kept, ids you
|
|
283
|
+
leave out are deleted. `{id: current, ...fields}` is a nested create with a predefined id, not a
|
|
284
|
+
patch: it deletes all of that node's triples and writes the new ones.
|
|
285
|
+
|
|
286
|
+
**Linking an existing node by `{id}`** is allowed, e.g. upload an image first, then attach it with
|
|
287
|
+
`{avatar: {id: uploadedId}}`. The link transfers ownership: the linked node is deleted when it is
|
|
288
|
+
replaced, removed, or when the owner is deleted.
|
|
289
|
+
|
|
290
|
+
Because of that, core checks the class of every id linked into a property that owns its value and
|
|
291
|
+
declares a `shape`. Ownership is decided per predicate: a property owns its value when any
|
|
292
|
+
registered shape declares its predicate `contains`, so a plain property that shares such a
|
|
293
|
+
predicate is checked too (a replace through it deletes the old value just the same). A link is
|
|
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`:
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
Cannot link <https://my.app/alice> into the contains property "avatar" of <…/shape/my-pkg/Person>:
|
|
299
|
+
it is typed <https://example.org/Person>, but "avatar" only owns instances of <https://schema.org/ImageObject>. …
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Ids that do not exist yet, or have no `rdf:type`, are allowed, so upload-then-attach works in
|
|
303
|
+
either write order. The check runs in `SparqlDataset` (one `SELECT` per mutation that links owned
|
|
304
|
+
ids, none otherwise). Plain references on predicates no shape owns are never checked. A node
|
|
305
|
+
whose type comes from a subclass that has no registered shape is refused unless the store also
|
|
306
|
+
holds the expected type (an RDFS-inferring store adds it); register a shape for that class, or
|
|
307
|
+
declare `sh:class`, to accept it.
|
|
308
|
+
|
|
309
|
+
Two limits: an id linked while it is untyped, and typed as something else later, is not caught.
|
|
310
|
+
Nor is a node typed by another request between the check's `SELECT` and the `UPDATE` that
|
|
311
|
+
follows it: the two are separate requests, not one transaction. Raw SPARQL updates bypass the
|
|
312
|
+
check altogether. SHACL validation of `sh:class` is the backstop for all three.
|
|
313
|
+
|
|
314
|
+
**What a delete removes.** `parent.delete()` deletes the immediately-owned children of every
|
|
315
|
+
`contains` property that declares a `shape`; `dependent` extends the cascade further down. The bulk
|
|
316
|
+
deletes (`.all()`, `.where(...)`) remove the same owned children and cascade for every matched
|
|
317
|
+
subject (they do not delete incoming references to the subjects, which a delete by id does). A
|
|
318
|
+
`contains` property *without* a `shape` (a polymorphic slot such as `sh:path`, whose value may be a
|
|
319
|
+
shared predicate IRI) only ever deletes `dependent`-typed values; a non-dependent old value is
|
|
320
|
+
left in place.
|
|
321
|
+
|
|
322
|
+
Subject deletes and replaces decide ownership differently. A subject delete (by id or in bulk)
|
|
323
|
+
uses the deleted shape's *own* `contains` properties. Replace, set-remove and the class check use
|
|
324
|
+
the registry-wide predicate rule above. So a plain property on a predicate that another shape
|
|
325
|
+
declares `contains` deletes its old value on replace, but not when its subject is deleted.
|
|
326
|
+
Whether ownership should be decided per property everywhere is an open design question. The
|
|
327
|
+
cascade into `dependent` descendants only emits blocks for the dependent shapes the deleted
|
|
328
|
+
shape can reach through its owned properties, so deleting a shape that owns only non-dependent
|
|
329
|
+
values costs one extra block per owned property. The walk follows only the `contains` properties
|
|
330
|
+
the reached shapes declare: an owned edge that none of those shapes declares is not followed,
|
|
331
|
+
and the node behind it is left in place rather than deleted.
|
|
332
|
+
|
|
333
|
+
Non-owning references to an owned node, through other properties or from other subjects, are
|
|
334
|
+
allowed. They are not cleaned up: after the owner is deleted they dangle. The same holds when two
|
|
335
|
+
subjects own one node (an `{id}` linked into a second owner, which breaks the single-owner rule
|
|
336
|
+
below): deleting either owner deletes the node, and the other owner's edge dangles.
|
|
337
|
+
|
|
338
|
+
**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 that declares a `shape` (simple paths only;
|
|
340
|
+
a shape-less slot may hold a shared IRI, so it is left out). It is written only by the class that
|
|
341
|
+
declares the property, at the property shape's IRI plus `.singleOwner`: `Thing.image` gets one
|
|
342
|
+
constraint at `Thing`, not one per subclass. It is marked `core:generated true` and has no
|
|
343
|
+
`sh:targetClass`, so catalog readers can skip it, and it is never registered in memory. For
|
|
344
|
+
`Thing.image`:
|
|
345
|
+
|
|
346
|
+
```turtle
|
|
347
|
+
<…/shape/my-pkg/Thing/image.singleOwner> a sh:NodeShape ;
|
|
348
|
+
core:generated true ;
|
|
349
|
+
sh:targetObjectsOf schema:image ;
|
|
350
|
+
sh:property <…/Thing/image.singleOwner/owners> .
|
|
351
|
+
|
|
352
|
+
<…/Thing/image.singleOwner/owners> a sh:PropertyShape ;
|
|
353
|
+
rdfs:label "owners" ;
|
|
354
|
+
sh:maxCount 1 ;
|
|
355
|
+
sh:path [ sh:inversePath schema:image ] .
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
(The inverse path node is stored with a deterministic IRI, `…/owners/inv`, not as a blank node.)
|
|
359
|
+
The declaring shape owns its generated shapes through `core:generatedShape`, a `contains` edge:
|
|
360
|
+
`<…/Thing> core:generatedShape <…/Thing/image.singleOwner>`. Syncing a shape is still two
|
|
361
|
+
requests: deleting the shape deletes the generated shapes with it (their own triples, property
|
|
362
|
+
shapes and path nodes, never the predicate IRI), and the create writes the current ones nested in
|
|
363
|
+
the same request. A removed or renamed accessor therefore loses its constraint, a pruned shape
|
|
364
|
+
takes its constraints with it, and a NodeShape the shape does not own is never touched.
|
|
365
|
+
`singleOwnerShapeIri`, `singleOwnerProperties` and `buildSingleOwnerConstraints` are exported if
|
|
366
|
+
you need to recompute them.
|
|
367
|
+
|
|
368
|
+
Each constraint counts owners through its own predicate only. A node owned through two different
|
|
369
|
+
`contains` predicates (`schema:image` from one subject, `ex:attachments` from another) is not
|
|
370
|
+
reported. That needs overlapping value shapes, and the class check already refuses a wrongly
|
|
371
|
+
typed link.
|
|
372
|
+
|
|
373
|
+
> **Not enforced on write.** Core does not check the single-owner rule, or `sh:class` on
|
|
374
|
+
> non-owning references, when it writes. The default Fuseki setup does not validate SHACL on
|
|
375
|
+
> write either: a dataset exposes only query, update and graph-store services. Run a SHACL
|
|
376
|
+
> validator (Jena SHACL, pySHACL, …) against the persisted shapes to enforce them.
|
|
377
|
+
|
|
266
378
|
**`dependent: true` on a shape** — marks the shape's *instances* as having no independent
|
|
267
379
|
existence, so they are cascade-deleted when reached through a `contains` edge from a parent
|
|
268
380
|
being deleted. Use it for structural nodes that are only ever owned (e.g. list cells, path
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './shapes/index.js';
|
|
2
2
|
import './live.js';
|
|
3
3
|
export { syncShapes, syncShape } from './shapes/syncShapes.js';
|
|
4
|
+
export { singleOwnerShapeIri, singleOwnerProperties, buildSingleOwnerConstraints, } from './shapes/singleOwnerConstraint.js';
|
|
4
5
|
export { rdfList } from './shapes/List.js';
|
|
5
6
|
export { serializePathToNodeData } from './shapes/serializePathToNodeData.js';
|
|
6
7
|
export { Shape } from './shapes/Shape.js';
|
package/lib/esm/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import './shapes/index.js';
|
|
|
8
8
|
// Registers the live-query store so `query.live()` works (side effects only).
|
|
9
9
|
import './live.js';
|
|
10
10
|
export { syncShapes, syncShape } from './shapes/syncShapes.js';
|
|
11
|
+
export { singleOwnerShapeIri, singleOwnerProperties, buildSingleOwnerConstraints, } from './shapes/singleOwnerConstraint.js';
|
|
11
12
|
export { rdfList } from './shapes/List.js';
|
|
12
13
|
export { serializePathToNodeData } from './shapes/serializePathToNodeData.js';
|
|
13
14
|
// Core public API surface (documented as root imports in the README).
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,0DAA0D;AAC1D,OAAO,mBAAmB,CAAC;AAC3B,8EAA8E;AAC9E,OAAO,WAAW,CAAC;AACnB,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAC,OAAO,EAAC,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAC,uBAAuB,EAAC,MAAM,qCAAqC,CAAC;AAC5E,sEAAsE;AACtE,OAAO,EAAC,KAAK,EAAC,MAAM,mBAAmB,CAAC;AACxC,kEAAkE;AAClE,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAQnF,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,2CAA2C;AAC3C,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE/C,OAAO,EACL,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAC,sBAAsB,EAAC,MAAM,4BAA4B,CAAC;AAElE,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAEzE,sBAAsB;AACtB,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAM/C,+BAA+B;AAC/B,OAAO,EAAC,UAAU,EAAE,UAAU,EAAC,MAAM,yBAAyB,CAAC;AAG/D,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAGrE,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAGzD,8CAA8C;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAe3C,sEAAsE;AACtE,OAAO,EACL,cAAc,EACd,WAAW,GACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAWxC,0FAA0F;AAC1F,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAEhE,mDAAmD;AACnD,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,0BAA0B,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 every shape core defines (side effects only).\nimport './shapes/index.js';\n// Registers the live-query store so `query.live()` works (side effects only).\nimport './live.js';\nexport {syncShapes, syncShape} from './shapes/syncShapes.js';\nexport {rdfList} from './shapes/List.js';\nexport {serializePathToNodeData} from './shapes/serializePathToNodeData.js';\n// Core public API surface (documented as root imports in the README).\nexport {Shape} from './shapes/Shape.js';\n// SHACL-aligned validation of plain data objects against a shape.\nexport {validate, assertValid, ShapeValidationError} from './shapes/validation.js';\nexport type {\n ValidationReport,\n ValidationResult,\n ValidationMode,\n ValidateOptions,\n ValidatableShape,\n} from './shapes/validation.js';\nexport {LinkedStorage} from './utils/LinkedStorage.js';\n// New dynamic query building API (Phase 2)\nexport {SelectBuilder, QueryBuilder} from './queries/QueryBuilder.js';\nexport {lower} from './queries/lower.js';\nexport type {LowerableQuery} from './queries/lower.js';\nexport {fromJSON} from './queries/fromJSON.js';\nexport type {QueryJSON} from './queries/fromJSON.js';\nexport {\n getQueryContext,\n setQueryContext,\n subscribeQueryContext,\n PendingQueryContext,\n UnresolvedContextError,\n} from './queries/QueryContext.js';\nexport {subscribeQueryDispatch} from './queries/queryDispatch.js';\nexport type {QueryDispatchEvent, QueryDispatchListener} from './queries/queryDispatch.js';\nexport {\n CONTEXT_REF_KEY,\n encodeContextRef,\n isContextRefJSON,\n resolveContextId,\n} from './queries/ContextRef.js';\nexport type {ContextRefJSON} from './queries/ContextRef.js';\nexport {PropertyPath, walkPropertyPath} from './queries/PropertyPath.js';\n\n// Phase 3a — FieldSet\nexport {FieldSet} from './queries/FieldSet.js';\nexport type {FieldSetEntry, FieldSetInput, FieldSetJSON, FieldSetFieldJSON} from './queries/FieldSet.js';\n\n// Phase 4 — Serialization types\nexport type {QueryBuilderJSON} from './queries/QueryBuilder.js';\n\n// Phase 3b — Mutation builders\nexport {AskBuilder, isAskQuery} from './queries/AskBuilder.js';\nexport type {AskSpec} from './queries/AskBuilder.js';\nexport type {AskQuery, AskQueryJSON, RawAskInput} from './queries/AskQuery.js';\nexport {CountBuilder, isCountQuery} from './queries/CountBuilder.js';\nexport type {CountSpec} from './queries/CountBuilder.js';\nexport type {CountQuery, CountQueryJSON, RawCountInput} from './queries/CountQuery.js';\nexport {CreateBuilder} from './queries/CreateBuilder.js';\nexport {UpdateBuilder} from './queries/UpdateBuilder.js';\nexport {DeleteBuilder} from './queries/DeleteBuilder.js';\nexport type {DeleteId} from './queries/DeleteBuilder.js';\n\n// Expressions — computed fields and functions\nexport {ExpressionNode} from './expressions/ExpressionNode.js';\nexport type {ExpressionInput, PropertyRefMap} from './expressions/ExpressionNode.js';\nexport {Expr} from './expressions/Expr.js';\nexport type {\n ExpressionUpdateProxy,\n ExpressionUpdateResult,\n BaseExpressionMethods,\n NumericExpressionMethods,\n StringExpressionMethods,\n DateExpressionMethods,\n BooleanExpressionMethods,\n} from './expressions/ExpressionMethods.js';\n\n// Phase 5 — Component query integration\nexport type {LinkedComponentInterface, QueryComponentLike} from './queries/SelectQuery.js';\n\n\n// Mutation DSL-JSON serialization (create/update/delete to/from JSON)\nexport {\n encodeNodeData,\n encodeValue,\n} from './queries/MutationSerialization.js';\nexport {\n decodeNodeData,\n lowerMutationJSON,\n} from './queries/lowerMutationJSON.js';\nexport type {\n MutationJSON,\n CreateMutationJSON,\n UpdateMutationJSON,\n DeleteMutationJSON,\n MutationValueJSON,\n MutationNodeDataJSON,\n} from './queries/MutationSerialization.js';\n\n\n// Live-query dependency helpers — what a query reads and a mutation writes, as predicates\nexport {queryDependencies, mutationEffects} from './queries/queryDependencies.js';\nexport type {QueryDependencies, MutationEffects} from './queries/queryDependencies.js';\nexport {findPropertyShapeById} from './shapes/nodeShapeData.js';\n\n// Live queries — see documentation/live-queries.md\nexport {LiveQueryStore, getLiveQueryStore, resetLiveQueryStore, publishChange, invalidate} from './live/LiveQueryStore.js';\nexport type {ChangeEvent} from './live/changes.js';\nexport type {\n LiveQuery,\n LiveState,\n LiveStatus,\n LiveListener,\n LiveQueryOptions,\n LiveQueryStoreOptions,\n} from './live/LiveQueryStore.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":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D,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAGrE,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAGzD,8CAA8C;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,iCAAiC,CAAC;AAE/D,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAe3C,sEAAsE;AACtE,OAAO,EACL,cAAc,EACd,WAAW,GACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,cAAc,EACd,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAWxC,0FAA0F;AAC1F,OAAO,EAAC,iBAAiB,EAAE,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAElF,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAEhE,mDAAmD;AACnD,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,0BAA0B,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 every shape core defines (side effects only).\nimport './shapes/index.js';\n// Registers the live-query store so `query.live()` works (side effects only).\nimport './live.js';\nexport {syncShapes, syncShape} from './shapes/syncShapes.js';\nexport {\n singleOwnerShapeIri,\n singleOwnerProperties,\n buildSingleOwnerConstraints,\n} from './shapes/singleOwnerConstraint.js';\nexport {rdfList} from './shapes/List.js';\nexport {serializePathToNodeData} from './shapes/serializePathToNodeData.js';\n// Core public API surface (documented as root imports in the README).\nexport {Shape} from './shapes/Shape.js';\n// SHACL-aligned validation of plain data objects against a shape.\nexport {validate, assertValid, ShapeValidationError} from './shapes/validation.js';\nexport type {\n ValidationReport,\n ValidationResult,\n ValidationMode,\n ValidateOptions,\n ValidatableShape,\n} from './shapes/validation.js';\nexport {LinkedStorage} from './utils/LinkedStorage.js';\n// New dynamic query building API (Phase 2)\nexport {SelectBuilder, QueryBuilder} from './queries/QueryBuilder.js';\nexport {lower} from './queries/lower.js';\nexport type {LowerableQuery} from './queries/lower.js';\nexport {fromJSON} from './queries/fromJSON.js';\nexport type {QueryJSON} from './queries/fromJSON.js';\nexport {\n getQueryContext,\n setQueryContext,\n subscribeQueryContext,\n PendingQueryContext,\n UnresolvedContextError,\n} from './queries/QueryContext.js';\nexport {subscribeQueryDispatch} from './queries/queryDispatch.js';\nexport type {QueryDispatchEvent, QueryDispatchListener} from './queries/queryDispatch.js';\nexport {\n CONTEXT_REF_KEY,\n encodeContextRef,\n isContextRefJSON,\n resolveContextId,\n} from './queries/ContextRef.js';\nexport type {ContextRefJSON} from './queries/ContextRef.js';\nexport {PropertyPath, walkPropertyPath} from './queries/PropertyPath.js';\n\n// Phase 3a — FieldSet\nexport {FieldSet} from './queries/FieldSet.js';\nexport type {FieldSetEntry, FieldSetInput, FieldSetJSON, FieldSetFieldJSON} from './queries/FieldSet.js';\n\n// Phase 4 — Serialization types\nexport type {QueryBuilderJSON} from './queries/QueryBuilder.js';\n\n// Phase 3b — Mutation builders\nexport {AskBuilder, isAskQuery} from './queries/AskBuilder.js';\nexport type {AskSpec} from './queries/AskBuilder.js';\nexport type {AskQuery, AskQueryJSON, RawAskInput} from './queries/AskQuery.js';\nexport {CountBuilder, isCountQuery} from './queries/CountBuilder.js';\nexport type {CountSpec} from './queries/CountBuilder.js';\nexport type {CountQuery, CountQueryJSON, RawCountInput} from './queries/CountQuery.js';\nexport {CreateBuilder} from './queries/CreateBuilder.js';\nexport {UpdateBuilder} from './queries/UpdateBuilder.js';\nexport {DeleteBuilder} from './queries/DeleteBuilder.js';\nexport type {DeleteId} from './queries/DeleteBuilder.js';\n\n// Expressions — computed fields and functions\nexport {ExpressionNode} from './expressions/ExpressionNode.js';\nexport type {ExpressionInput, PropertyRefMap} from './expressions/ExpressionNode.js';\nexport {Expr} from './expressions/Expr.js';\nexport type {\n ExpressionUpdateProxy,\n ExpressionUpdateResult,\n BaseExpressionMethods,\n NumericExpressionMethods,\n StringExpressionMethods,\n DateExpressionMethods,\n BooleanExpressionMethods,\n} from './expressions/ExpressionMethods.js';\n\n// Phase 5 — Component query integration\nexport type {LinkedComponentInterface, QueryComponentLike} from './queries/SelectQuery.js';\n\n\n// Mutation DSL-JSON serialization (create/update/delete to/from JSON)\nexport {\n encodeNodeData,\n encodeValue,\n} from './queries/MutationSerialization.js';\nexport {\n decodeNodeData,\n lowerMutationJSON,\n} from './queries/lowerMutationJSON.js';\nexport type {\n MutationJSON,\n CreateMutationJSON,\n UpdateMutationJSON,\n DeleteMutationJSON,\n MutationValueJSON,\n MutationNodeDataJSON,\n} from './queries/MutationSerialization.js';\n\n\n// Live-query dependency helpers — what a query reads and a mutation writes, as predicates\nexport {queryDependencies, mutationEffects} from './queries/queryDependencies.js';\nexport type {QueryDependencies, MutationEffects} from './queries/queryDependencies.js';\nexport {findPropertyShapeById} from './shapes/nodeShapeData.js';\n\n// Live queries — see documentation/live-queries.md\nexport {LiveQueryStore, getLiveQueryStore, resetLiveQueryStore, publishChange, invalidate} from './live/LiveQueryStore.js';\nexport type {ChangeEvent} from './live/changes.js';\nexport type {\n LiveQuery,\n LiveState,\n LiveStatus,\n LiveListener,\n LiveQueryOptions,\n LiveQueryStoreOptions,\n} from './live/LiveQueryStore.js';\n"]}
|
|
@@ -39,6 +39,14 @@ const PathNode = ns('PathNode');
|
|
|
39
39
|
// app — NOT the CN-proprietary `code:` vocab, which describes source-code structure.
|
|
40
40
|
const displayRank = ns('displayRank');
|
|
41
41
|
const displayHidden = ns('displayHidden');
|
|
42
|
+
// Provenance marker: a NodeShape core generates at sync time from another shape's code
|
|
43
|
+
// (today the `<propertyShape>.singleOwner` constraint derived from `contains`), rather than one a
|
|
44
|
+
// developer declared. Catalog readers skip shapes with `core:generated true`.
|
|
45
|
+
const generated = ns('generated');
|
|
46
|
+
// Ownership edge from a NodeShape to the shapes core generated from it at sync time (the
|
|
47
|
+
// single-owner constraint of each `contains` property). It is `contains`, so deleting the
|
|
48
|
+
// shape deletes them, and sync writes them nested in the shape's own create.
|
|
49
|
+
const generatedShape = ns('generatedShape');
|
|
42
50
|
export const coreOntology = {
|
|
43
51
|
Package,
|
|
44
52
|
ShapeClass,
|
|
@@ -52,5 +60,7 @@ export const coreOntology = {
|
|
|
52
60
|
PathNode,
|
|
53
61
|
displayRank,
|
|
54
62
|
displayHidden,
|
|
63
|
+
generated,
|
|
64
|
+
generatedShape,
|
|
55
65
|
};
|
|
56
66
|
//# sourceMappingURL=linked-core.js.map
|
|
@@ -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,C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AC;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 cascade follows this edge (composition).\n// dependent — shape characteristic: instances may be deleted when reached via a `contains` edge.\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"]}
|
|
@@ -68,6 +68,7 @@ export declare const shacl: {
|
|
|
68
68
|
Shape: NodeReferenceValue;
|
|
69
69
|
targetClass: NodeReferenceValue;
|
|
70
70
|
targetNode: NodeReferenceValue;
|
|
71
|
+
targetObjectsOf: NodeReferenceValue;
|
|
71
72
|
BlankNode: NodeReferenceValue;
|
|
72
73
|
IRI: NodeReferenceValue;
|
|
73
74
|
Literal: NodeReferenceValue;
|
|
@@ -24,6 +24,7 @@ const prefix = ns('prefix');
|
|
|
24
24
|
const PropertyShape = ns('PropertyShape');
|
|
25
25
|
const targetClass = ns('targetClass');
|
|
26
26
|
const targetNode = ns('targetNode');
|
|
27
|
+
const targetObjectsOf = ns('targetObjectsOf');
|
|
27
28
|
const node = ns('node');
|
|
28
29
|
const nodeKind = ns('nodeKind');
|
|
29
30
|
const Shape = ns('Shape');
|
|
@@ -114,6 +115,7 @@ export const shacl = {
|
|
|
114
115
|
Shape,
|
|
115
116
|
targetClass,
|
|
116
117
|
targetNode,
|
|
118
|
+
targetObjectsOf,
|
|
117
119
|
BlankNode,
|
|
118
120
|
IRI,
|
|
119
121
|
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,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,EAAE,CAAC,aAAa,CAAC,CAAC;AACtC,MAAM,SAAS,GAAG,EAAE,CAAC,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IAAI;IACJ,SAAS;IACT,QAAQ;IACR,SAAS;IACT,iBAAiB;IACjB,IAAI;IACJ,MAAM;IACN,QAAQ;IACR,aAAa;IACb,KAAK;IACL,WAAW;IACX,UAAU;IACV,SAAS;IACT,GAAG;IACH,OAAO;IACP,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZ,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,YAAY;IACZ,KAAK;IACL,KAAK;IACL,MAAM;IACN,iBAAiB;IACjB,UAAU;IACV,QAAQ;IACR,gBAAgB;IAChB,YAAY;IACZ,YAAY;IACZ,SAAS;IACT,YAAY;IACZ,YAAY;IACZ,SAAS;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 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 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,EAA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AA+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,3 +1,14 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
1
12
|
import { QueryFactory, } from './QueryFactory.js';
|
|
2
13
|
import { getPropertyShapes } from '../shapes/nodeShapeData.js';
|
|
3
14
|
import { resolveShapeConstructor } from '../utils/ShapeClass.js';
|
|
@@ -228,7 +239,12 @@ export class MutationQueryFactory extends QueryFactory {
|
|
|
228
239
|
if (value.shape.shape.id !== valueShape.id) {
|
|
229
240
|
throw new Error(`The property 'shape' is reserved in LINCD and should not be used here in this way. The ${propShape.label} property already defines the shape of the value as ${propShape.label}. If you want to use a different shape, use the 'shape' key in the @objectProperty decorator.`);
|
|
230
241
|
}
|
|
231
|
-
|
|
242
|
+
// Drop it from a copy, never from the caller's object: the same data
|
|
243
|
+
// is lowered again after the mutation ran (LiveQueryStore derives the
|
|
244
|
+
// mutation's effects from it), and without its `shape` key the value
|
|
245
|
+
// can no longer be validated.
|
|
246
|
+
const { shape: _shape } = value, rest = __rest(value, ["shape"]);
|
|
247
|
+
value = rest;
|
|
232
248
|
}
|
|
233
249
|
if (this.isSetModification(value, propShape)) {
|
|
234
250
|
return this.convertSetModification(value, propShape);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationQuery.js","sourceRoot":"","sources":["../../../src/queries/MutationQuery.ts"],"names":[],"mappings":"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pD,oFAAoF;QACpF,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACjG,CAAC;IAES,qBAAqB,CAC7B,KAAwB;QAExB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACrB,OAAO,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAES,4BAA4B,CACpC,CAAwB;QAExB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,EAAC,EAAE,EAAE,CAAC,EAAC,CAAC;QACjB,CAAC;aAAM,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,GAAiB;QAC9C,OAAO,EAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAC,CAAC;IACtB,CAAC;CACF","sourcesContent":["import {\n type LiteralUpdateValue,\n type NodeDescriptionValue,\n NodeReferenceValue,\n type PropUpdateValue,\n QueryFactory,\n type SetModification,\n type SetModificationValue,\n type SinglePropertyUpdateValue,\n type UpdateNodePropertyValue,\n type UpdatePartial,\n} from './QueryFactory.js';\nimport {getPropertyShapes} from '../shapes/nodeShapeData.js';\nimport type {NodeShapeData, PropertyShapeData} from '../shapes/SHACL.js';\nimport {Shape, type ShapeConstructor} from '../shapes/Shape.js';\nimport {resolveShapeConstructor} from '../utils/ShapeClass.js';\nimport {isExpressionNode, ExpressionNode} from '../expressions/ExpressionNode.js';\nimport {createProxiedPathBuilder} from './ProxiedPathBuilder.js';\nimport {asContextRef} from './QueryContext.js';\nimport {\n assertValid,\n undeclaredPropertyMessage,\n type ValidationMode,\n} from '../shapes/validation.js';\n\nexport type NodeId = {id: string} | string;\n\n/** Options for {@link MutationQueryFactory.describe}. */\nexport interface DescribeOptions {\n /** Create data may carry a top-level `id`; update data may not. */\n allowTopLevelId?: boolean;\n /**\n * Validate the data against the shape before normalizing, throwing a\n * `ShapeValidationError` with every violation. Omit to skip validation\n * (normalization-only, e.g. when the caller has already validated).\n */\n validate?: ValidationMode;\n}\n\nexport class MutationQueryFactory extends QueryFactory {\n /**\n * Normalize raw create/update data into a {@link NodeDescriptionValue} — the\n * IR-free step shared by `toJSON()` and `lower()`. Kept on this base (which\n * imports no IR) so the builders can normalize for serialization without\n * pulling the canonical-IR pipeline.\n *\n * This is also the single validation gate: pass `validate` and the resolved\n * data is checked against the shape first, so `toJSON()`, `lower()` and\n * `exec()` reject exactly the same input. See `shapes/validation`.\n */\n describe(\n shape: NodeShapeData,\n data: unknown,\n options: DescribeOptions = {},\n ): NodeDescriptionValue {\n return this.convertUpdateObject(data as any, shape, options);\n }\n\n /** Normalize delete ids (strings / `{id}`) to `NodeReferenceValue[]` (IR-free). */\n normalizeNodeRefs(ids: NodeId[] | NodeId): NodeReferenceValue[] {\n return this.convertNodeReferences(ids);\n }\n\n protected convertUpdateObject(\n obj,\n shape: NodeShapeData,\n {allowTopLevelId = false, validate}: DescribeOptions = {},\n ): NodeDescriptionValue {\n let resolved;\n if (typeof obj === 'object' && !(obj instanceof Date) && obj !== null) {\n if (!allowTopLevelId && 'id' in obj) {\n throw new Error(\n 'You cannot use id in the top level of an update object',\n );\n }\n resolved = obj;\n } else if (typeof obj === 'function') {\n // A shape authored in a project exists only as metadata, so it has no authored\n // class. `getOrCreateShapeAdapter` derives a constructor from that metadata --\n // which is the documented return leg of the shape round trip (see\n // registerRuntimeShape). Resolving with `getShapeClass` alone made every runtime shape\n // fail here with \"Shape class not found\".\n const shapeClass = shape.id ? resolveShapeConstructor(shape.id) : undefined;\n if (!shapeClass) {\n throw new Error(`Shape class not found for ${shape.id || 'unknown'}`);\n }\n const proxy = createProxiedPathBuilder(shapeClass);\n const result = obj(proxy);\n if (typeof result !== 'object' || result === null) {\n throw new Error('Update function must return an object');\n }\n // Validate what the callback produced, not the callback itself.\n resolved = result;\n } else {\n throw new Error('Invalid update object');\n }\n if (validate) {\n assertValid(shape, resolved, {mode: validate});\n }\n return this.convertNodeDescription(resolved, shape);\n }\n\n protected isSetModification(obj, shape) {\n let hasAdd = obj.add;\n let hasRemove = obj.remove;\n let numKeysExpected = (hasAdd ? 1 : 0) + (hasRemove ? 1 : 0);\n let numKeys = Object.getOwnPropertyNames(obj).length;\n // A set modification is ONLY add/remove keys. Mixing them with other keys\n // (e.g. {add:[…], name:'x'}) must NOT be silently treated as a set mod —\n // that dropped the sibling fields. Require an exact key-count match for\n // both add and remove (mirrors isSetModificationValue).\n return (hasAdd || hasRemove) && numKeysExpected === numKeys;\n }\n\n protected convertSetModification(\n obj: SetModification<any>,\n shape: PropertyShapeData,\n ): SetModificationValue {\n if (!obj.add && !obj.remove) {\n throw new Error('Set modification should have either add or remove key');\n }\n const res: SetModificationValue = {};\n if (obj.add) {\n res.$add = this.convertSetAddValue(obj.add, shape);\n }\n if (obj.remove) {\n res.$remove = this.convertSetRemoveValue(obj.remove, shape);\n }\n return res;\n }\n\n protected convertSetRemoveValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): NodeReferenceValue[] {\n //the user can either pass an array of node references or a single node reference\n //either way we should return an array of node reference values\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertSingleRemoveValue(o, shape));\n } else {\n return [this.convertSingleRemoveValue(obj, shape)];\n }\n }\n\n protected convertSetAddValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): UpdatePartial[] {\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertUpdateValue(o, shape) as UpdatePartial);\n } else {\n return [this.convertUpdateValue(obj, shape) as UpdatePartial];\n }\n }\n\n protected convertSingleRemoveValue(\n value,\n shape: PropertyShapeData,\n ): NodeReferenceValue {\n const ctx = asContextRef(value);\n if (ctx) {\n return ctx as unknown as NodeReferenceValue;\n }\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n throw new Error(\n `Invalid value for ${shape.label}.$remove. Expected an object with an id as key: {id:string}`,\n );\n }\n }\n\n protected convertNodeDescription(\n inputObj: Record<string, unknown>,\n shape: NodeShapeData,\n ): NodeDescriptionValue {\n // Shallow-copy so we never mutate the caller's object\n const obj = {...inputObj};\n const props = getPropertyShapes(shape, true);\n const fields: UpdateNodePropertyValue[] = [];\n let id;\n if ('__id' in obj) {\n //if the object has a __id key, then we should use that in the result\n id = obj.__id.toString();\n //but we should not include it in the fields\n delete obj.__id;\n } else if ('id' in obj) {\n //if the object has an id key alongside other data properties,\n //treat it as a nested create with a predefined ID\n id = String(obj.id);\n delete obj.id;\n }\n for (var key in obj) {\n let propShape = props.find((p) => p.label === key);\n if (!propShape) {\n // Also reported as an `sh:ClosedConstraintComponent` violation when the\n // caller validates; kept here because normalization cannot build a field\n // without a property shape (`describe()` may run without validation).\n throw Error(undeclaredPropertyMessage(key, shape));\n } else {\n fields.push(this.createNodePropertyValue(obj[key], propShape));\n }\n }\n const res: NodeDescriptionValue = {\n fields,\n shape,\n };\n if (id) {\n res.__id = id;\n }\n\n return res;\n }\n\n protected createNodePropertyValue(\n value,\n propShape: PropertyShapeData,\n ): UpdateNodePropertyValue {\n return {\n prop: propShape,\n val: this.convertUpdateValue(value, propShape),\n } as UpdateNodePropertyValue;\n }\n\n protected convertUpdateValue(\n value,\n propShape?: PropertyShapeData,\n allowArrays: boolean = true,\n ): PropUpdateValue {\n // ExpressionNode → pass through as-is (will be converted to IRExpression by IRMutation)\n if (isExpressionNode(value)) {\n return value as unknown as PropUpdateValue;\n }\n\n // Query-context reference → preserve the live ref (do NOT collapse to {id},\n // which would read an unresolved `.id` as undefined). Handles both an unset\n // PendingQueryContext and a resolved context shape; both serialize as a {@ctx}\n // marker and are resolved — or throw — at lowering time.\n {\n const ctx = asContextRef(value);\n if (ctx) return ctx as unknown as PropUpdateValue;\n }\n\n //single value which will\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n ) {\n return value as LiteralUpdateValue;\n }\n\n //if multiple items are given as value of this prop\n if (Array.isArray(value)) {\n if (!allowArrays) {\n throw new Error('Nested arrays are not allowed as values of keys');\n }\n //then convert each value, but disallow nested arrays moving forward\n return value.map((o) => {\n return this.convertUpdateValue(o, propShape, false);\n }) as SinglePropertyUpdateValue[];\n } else if (typeof value === 'undefined') {\n return value;\n } else if (value === null) {\n //unsetting a value with null is also possible. But we pass it as undefined in the query object\n return undefined;\n } else if (typeof value === 'object') {\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n let valueShape: NodeShapeData = null;\n if (propShape.valueShape) {\n const shapeClass = resolveShapeConstructor(propShape.valueShape);\n valueShape = shapeClass?.shape || null;\n if (!valueShape) {\n throw new Error(\n `Shape class not found for ${propShape.valueShape.id}`,\n );\n }\n }\n //pass the value shape of the property as the node shape of this value\n if (!propShape.valueShape) {\n //It's possible to define the shape of the value in the value itself for properties who do not define the shape in their objectProperty\n if (value.shape) {\n if (!value.shape.shape) {\n throw new Error(\n `The value of property \"shape\" is invalid and should be a class that extends Shape.`,\n );\n }\n valueShape = (value.shape as typeof Shape).shape;\n } else {\n //TODO: not sure if this should be an error. Does every @linkedObject need to define the shape of the values?\n // If not, then how do we continue? because currently we use the value shape to look up further property shapes\n throw new Error(\n `Cannot update properties with plain objects if the shape of the values is not known. Make sure get/set ${propShape.parentNodeShape.label}.${propShape.label} defines the 'shape' key in its @objectProperty decorator.`,\n );\n }\n }\n //never keep a shape key in the value object\n if (value.shape) {\n //double check that IF a shape value is provided, that it matches the shape from the @objectProperty decorator\n if ((value.shape as typeof Shape).shape.id !== valueShape.id) {\n throw new Error(\n `The property 'shape' is reserved in LINCD and should not be used here in this way. The ${propShape.label} property already defines the shape of the value as ${propShape.label}. If you want to use a different shape, use the 'shape' key in the @objectProperty decorator.`,\n );\n }\n delete value.shape;\n }\n\n if (this.isSetModification(value, propShape)) {\n return this.convertSetModification(value, propShape);\n } else {\n return this.convertNodeDescription(value, valueShape);\n }\n }\n }\n throw new Error(`Unsupported update value type: ${typeof value}`);\n }\n\n protected isNodeReference(obj): obj is NodeReferenceValue {\n //check if obj is an object with only an id property\n //if additional data properties are present, it's a nested create with predefined ID\n return typeof obj === 'object' && obj !== null && 'id' in obj && Object.keys(obj).length === 1;\n }\n\n protected convertNodeReferences(\n input: NodeId[] | NodeId,\n ): NodeReferenceValue[] {\n if (Array.isArray(input)) {\n return input.map((o) => {\n return this.convertNodeReferenceOrString(o);\n });\n } else {\n return [this.convertNodeReferenceOrString(input)];\n }\n }\n\n protected convertNodeReferenceOrString(\n o: {id: string} | string,\n ): NodeReferenceValue {\n if (typeof o === 'string') {\n return {id: o};\n } else if (this.isNodeReference(o)) {\n return this.convertNodeReference(o);\n } else {\n throw new Error(`Invalid node reference: ${JSON.stringify(o)}`);\n }\n }\n\n protected convertNodeReference(obj: {id: string}): NodeReferenceValue {\n return {id: obj.id};\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MutationQuery.js","sourceRoot":"","sources":["../../../src/queries/MutationQuery.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAKL,YAAY,GAMb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAG7D,OAAO,EAAC,uBAAuB,E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GAAG;QAC3B,oDAAoD;QACpD,oFAAoF;QACpF,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IACjG,CAAC;IAES,qBAAqB,CAC7B,KAAwB;QAExB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACrB,OAAO,IAAI,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC;YAC9C,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAES,4BAA4B,CACpC,CAAwB;QAExB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,EAAC,EAAE,EAAE,CAAC,EAAC,CAAC;QACjB,CAAC;aAAM,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,GAAiB;QAC9C,OAAO,EAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAC,CAAC;IACtB,CAAC;CACF","sourcesContent":["import {\n type LiteralUpdateValue,\n type NodeDescriptionValue,\n NodeReferenceValue,\n type PropUpdateValue,\n QueryFactory,\n type SetModification,\n type SetModificationValue,\n type SinglePropertyUpdateValue,\n type UpdateNodePropertyValue,\n type UpdatePartial,\n} from './QueryFactory.js';\nimport {getPropertyShapes} from '../shapes/nodeShapeData.js';\nimport type {NodeShapeData, PropertyShapeData} from '../shapes/SHACL.js';\nimport {Shape, type ShapeConstructor} from '../shapes/Shape.js';\nimport {resolveShapeConstructor} from '../utils/ShapeClass.js';\nimport {isExpressionNode, ExpressionNode} from '../expressions/ExpressionNode.js';\nimport {createProxiedPathBuilder} from './ProxiedPathBuilder.js';\nimport {asContextRef} from './QueryContext.js';\nimport {\n assertValid,\n undeclaredPropertyMessage,\n type ValidationMode,\n} from '../shapes/validation.js';\n\nexport type NodeId = {id: string} | string;\n\n/** Options for {@link MutationQueryFactory.describe}. */\nexport interface DescribeOptions {\n /** Create data may carry a top-level `id`; update data may not. */\n allowTopLevelId?: boolean;\n /**\n * Validate the data against the shape before normalizing, throwing a\n * `ShapeValidationError` with every violation. Omit to skip validation\n * (normalization-only, e.g. when the caller has already validated).\n */\n validate?: ValidationMode;\n}\n\nexport class MutationQueryFactory extends QueryFactory {\n /**\n * Normalize raw create/update data into a {@link NodeDescriptionValue} — the\n * IR-free step shared by `toJSON()` and `lower()`. Kept on this base (which\n * imports no IR) so the builders can normalize for serialization without\n * pulling the canonical-IR pipeline.\n *\n * This is also the single validation gate: pass `validate` and the resolved\n * data is checked against the shape first, so `toJSON()`, `lower()` and\n * `exec()` reject exactly the same input. See `shapes/validation`.\n */\n describe(\n shape: NodeShapeData,\n data: unknown,\n options: DescribeOptions = {},\n ): NodeDescriptionValue {\n return this.convertUpdateObject(data as any, shape, options);\n }\n\n /** Normalize delete ids (strings / `{id}`) to `NodeReferenceValue[]` (IR-free). */\n normalizeNodeRefs(ids: NodeId[] | NodeId): NodeReferenceValue[] {\n return this.convertNodeReferences(ids);\n }\n\n protected convertUpdateObject(\n obj,\n shape: NodeShapeData,\n {allowTopLevelId = false, validate}: DescribeOptions = {},\n ): NodeDescriptionValue {\n let resolved;\n if (typeof obj === 'object' && !(obj instanceof Date) && obj !== null) {\n if (!allowTopLevelId && 'id' in obj) {\n throw new Error(\n 'You cannot use id in the top level of an update object',\n );\n }\n resolved = obj;\n } else if (typeof obj === 'function') {\n // A shape authored in a project exists only as metadata, so it has no authored\n // class. `getOrCreateShapeAdapter` derives a constructor from that metadata --\n // which is the documented return leg of the shape round trip (see\n // registerRuntimeShape). Resolving with `getShapeClass` alone made every runtime shape\n // fail here with \"Shape class not found\".\n const shapeClass = shape.id ? resolveShapeConstructor(shape.id) : undefined;\n if (!shapeClass) {\n throw new Error(`Shape class not found for ${shape.id || 'unknown'}`);\n }\n const proxy = createProxiedPathBuilder(shapeClass);\n const result = obj(proxy);\n if (typeof result !== 'object' || result === null) {\n throw new Error('Update function must return an object');\n }\n // Validate what the callback produced, not the callback itself.\n resolved = result;\n } else {\n throw new Error('Invalid update object');\n }\n if (validate) {\n assertValid(shape, resolved, {mode: validate});\n }\n return this.convertNodeDescription(resolved, shape);\n }\n\n protected isSetModification(obj, shape) {\n let hasAdd = obj.add;\n let hasRemove = obj.remove;\n let numKeysExpected = (hasAdd ? 1 : 0) + (hasRemove ? 1 : 0);\n let numKeys = Object.getOwnPropertyNames(obj).length;\n // A set modification is ONLY add/remove keys. Mixing them with other keys\n // (e.g. {add:[…], name:'x'}) must NOT be silently treated as a set mod —\n // that dropped the sibling fields. Require an exact key-count match for\n // both add and remove (mirrors isSetModificationValue).\n return (hasAdd || hasRemove) && numKeysExpected === numKeys;\n }\n\n protected convertSetModification(\n obj: SetModification<any>,\n shape: PropertyShapeData,\n ): SetModificationValue {\n if (!obj.add && !obj.remove) {\n throw new Error('Set modification should have either add or remove key');\n }\n const res: SetModificationValue = {};\n if (obj.add) {\n res.$add = this.convertSetAddValue(obj.add, shape);\n }\n if (obj.remove) {\n res.$remove = this.convertSetRemoveValue(obj.remove, shape);\n }\n return res;\n }\n\n protected convertSetRemoveValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): NodeReferenceValue[] {\n //the user can either pass an array of node references or a single node reference\n //either way we should return an array of node reference values\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertSingleRemoveValue(o, shape));\n } else {\n return [this.convertSingleRemoveValue(obj, shape)];\n }\n }\n\n protected convertSetAddValue(\n obj: UpdatePartial | UpdatePartial[],\n shape: PropertyShapeData,\n ): UpdatePartial[] {\n if (Array.isArray(obj)) {\n return obj.map((o) => this.convertUpdateValue(o, shape) as UpdatePartial);\n } else {\n return [this.convertUpdateValue(obj, shape) as UpdatePartial];\n }\n }\n\n protected convertSingleRemoveValue(\n value,\n shape: PropertyShapeData,\n ): NodeReferenceValue {\n const ctx = asContextRef(value);\n if (ctx) {\n return ctx as unknown as NodeReferenceValue;\n }\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n throw new Error(\n `Invalid value for ${shape.label}.$remove. Expected an object with an id as key: {id:string}`,\n );\n }\n }\n\n protected convertNodeDescription(\n inputObj: Record<string, unknown>,\n shape: NodeShapeData,\n ): NodeDescriptionValue {\n // Shallow-copy so we never mutate the caller's object\n const obj = {...inputObj};\n const props = getPropertyShapes(shape, true);\n const fields: UpdateNodePropertyValue[] = [];\n let id;\n if ('__id' in obj) {\n //if the object has a __id key, then we should use that in the result\n id = obj.__id.toString();\n //but we should not include it in the fields\n delete obj.__id;\n } else if ('id' in obj) {\n //if the object has an id key alongside other data properties,\n //treat it as a nested create with a predefined ID\n id = String(obj.id);\n delete obj.id;\n }\n for (var key in obj) {\n let propShape = props.find((p) => p.label === key);\n if (!propShape) {\n // Also reported as an `sh:ClosedConstraintComponent` violation when the\n // caller validates; kept here because normalization cannot build a field\n // without a property shape (`describe()` may run without validation).\n throw Error(undeclaredPropertyMessage(key, shape));\n } else {\n fields.push(this.createNodePropertyValue(obj[key], propShape));\n }\n }\n const res: NodeDescriptionValue = {\n fields,\n shape,\n };\n if (id) {\n res.__id = id;\n }\n\n return res;\n }\n\n protected createNodePropertyValue(\n value,\n propShape: PropertyShapeData,\n ): UpdateNodePropertyValue {\n return {\n prop: propShape,\n val: this.convertUpdateValue(value, propShape),\n } as UpdateNodePropertyValue;\n }\n\n protected convertUpdateValue(\n value,\n propShape?: PropertyShapeData,\n allowArrays: boolean = true,\n ): PropUpdateValue {\n // ExpressionNode → pass through as-is (will be converted to IRExpression by IRMutation)\n if (isExpressionNode(value)) {\n return value as unknown as PropUpdateValue;\n }\n\n // Query-context reference → preserve the live ref (do NOT collapse to {id},\n // which would read an unresolved `.id` as undefined). Handles both an unset\n // PendingQueryContext and a resolved context shape; both serialize as a {@ctx}\n // marker and are resolved — or throw — at lowering time.\n {\n const ctx = asContextRef(value);\n if (ctx) return ctx as unknown as PropUpdateValue;\n }\n\n //single value which will\n if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n value instanceof Date\n ) {\n return value as LiteralUpdateValue;\n }\n\n //if multiple items are given as value of this prop\n if (Array.isArray(value)) {\n if (!allowArrays) {\n throw new Error('Nested arrays are not allowed as values of keys');\n }\n //then convert each value, but disallow nested arrays moving forward\n return value.map((o) => {\n return this.convertUpdateValue(o, propShape, false);\n }) as SinglePropertyUpdateValue[];\n } else if (typeof value === 'undefined') {\n return value;\n } else if (value === null) {\n //unsetting a value with null is also possible. But we pass it as undefined in the query object\n return undefined;\n } else if (typeof value === 'object') {\n if (this.isNodeReference(value)) {\n return this.convertNodeReference(value);\n } else {\n let valueShape: NodeShapeData = null;\n if (propShape.valueShape) {\n const shapeClass = resolveShapeConstructor(propShape.valueShape);\n valueShape = shapeClass?.shape || null;\n if (!valueShape) {\n throw new Error(\n `Shape class not found for ${propShape.valueShape.id}`,\n );\n }\n }\n //pass the value shape of the property as the node shape of this value\n if (!propShape.valueShape) {\n //It's possible to define the shape of the value in the value itself for properties who do not define the shape in their objectProperty\n if (value.shape) {\n if (!value.shape.shape) {\n throw new Error(\n `The value of property \"shape\" is invalid and should be a class that extends Shape.`,\n );\n }\n valueShape = (value.shape as typeof Shape).shape;\n } else {\n //TODO: not sure if this should be an error. Does every @linkedObject need to define the shape of the values?\n // If not, then how do we continue? because currently we use the value shape to look up further property shapes\n throw new Error(\n `Cannot update properties with plain objects if the shape of the values is not known. Make sure get/set ${propShape.parentNodeShape.label}.${propShape.label} defines the 'shape' key in its @objectProperty decorator.`,\n );\n }\n }\n //never keep a shape key in the value object\n if (value.shape) {\n //double check that IF a shape value is provided, that it matches the shape from the @objectProperty decorator\n if ((value.shape as typeof Shape).shape.id !== valueShape.id) {\n throw new Error(\n `The property 'shape' is reserved in LINCD and should not be used here in this way. The ${propShape.label} property already defines the shape of the value as ${propShape.label}. If you want to use a different shape, use the 'shape' key in the @objectProperty decorator.`,\n );\n }\n // Drop it from a copy, never from the caller's object: the same data\n // is lowered again after the mutation ran (LiveQueryStore derives the\n // mutation's effects from it), and without its `shape` key the value\n // can no longer be validated.\n const {shape: _shape, ...rest} = value;\n value = rest;\n }\n\n if (this.isSetModification(value, propShape)) {\n return this.convertSetModification(value, propShape);\n } else {\n return this.convertNodeDescription(value, valueShape);\n }\n }\n }\n throw new Error(`Unsupported update value type: ${typeof value}`);\n }\n\n protected isNodeReference(obj): obj is NodeReferenceValue {\n //check if obj is an object with only an id property\n //if additional data properties are present, it's a nested create with predefined ID\n return typeof obj === 'object' && obj !== null && 'id' in obj && Object.keys(obj).length === 1;\n }\n\n protected convertNodeReferences(\n input: NodeId[] | NodeId,\n ): NodeReferenceValue[] {\n if (Array.isArray(input)) {\n return input.map((o) => {\n return this.convertNodeReferenceOrString(o);\n });\n } else {\n return [this.convertNodeReferenceOrString(input)];\n }\n }\n\n protected convertNodeReferenceOrString(\n o: {id: string} | string,\n ): NodeReferenceValue {\n if (typeof o === 'string') {\n return {id: o};\n } else if (this.isNodeReference(o)) {\n return this.convertNodeReference(o);\n } else {\n throw new Error(`Invalid node reference: ${JSON.stringify(o)}`);\n }\n }\n\n protected convertNodeReference(obj: {id: string}): NodeReferenceValue {\n return {id: obj.id};\n }\n}\n"]}
|
|
@@ -113,8 +113,21 @@ 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
|
-
* and the
|
|
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.
|
|
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.
|
|
127
|
+
*
|
|
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.
|
|
118
131
|
*/
|
|
119
132
|
contains?: boolean;
|
|
120
133
|
}
|