@_linked/core 2.17.0 → 2.18.0-next.20260829125240

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.18.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#205](https://github.com/linked-cm/core/pull/205) [`48ecb4d`](https://github.com/linked-cm/core/commit/48ecb4dbdc20471bf19a4c4cc9d58ef90f5cd1b1) Thanks [@flyon](https://github.com/flyon)! - Expose the meta-model's SHACL constraint table via `getPropertyShapeTerms()` /
8
+ `getPropertyShapeTerm(label)`, so an alternative serializer can look up each constraint's
9
+ predicate, datatype and node kind rather than hard-coding its own copy.
10
+
11
+ Purely additive — `buildPropertyShapeData` is unchanged. Create Now's code→RDF shape sync uses
12
+ this to emit the full SHACL constraint set (pattern, `sh:in`, ranges, lengths, class) instead of
13
+ the five it previously enumerated by hand.
14
+
3
15
  ## 2.17.0
4
16
 
5
17
  ### Minor Changes
@@ -0,0 +1,36 @@
1
+ import '../utils/Package.js';
2
+ /**
3
+ * How ONE SHACL constraint of a `sh:PropertyShape` is written to RDF: which predicate
4
+ * it uses and (when the meta-model pins one) which literal datatype / node kind.
5
+ */
6
+ export interface PropertyShapeTerm {
7
+ /**
8
+ * The constraint's name as used by the decorator config and by `PropertyShapeData`
9
+ * — e.g. `pattern`, `minLength`, `in`. (A few `PropertyShapeData` fields carry a
10
+ * disambiguating suffix — `equalsConstraint`, `hasValueConstraint` — the LABEL is
11
+ * always the bare SHACL name, `equals` / `hasValue`.)
12
+ */
13
+ label: string;
14
+ /** The predicate IRI the constraint serializes to, e.g. `sh:pattern`. */
15
+ predicate: string;
16
+ /** Fixed literal datatype IRI, when the meta-model pins one (e.g. `xsd:integer` for `sh:minLength`). */
17
+ datatype?: string;
18
+ /** `sh:IRI` or `sh:Literal`, when the meta-model pins one (absent for the generic `sh:hasValue`). */
19
+ nodeKind?: string;
20
+ }
21
+ /**
22
+ * The SHACL constraints a `sh:PropertyShape` can carry, keyed by label — derived from the
23
+ * core meta-model (`PropertyShape.shape`, set up in `utils/Package.ts`) rather than from a
24
+ * hand-kept list, so a constraint added to the meta-model is immediately known here.
25
+ *
26
+ * This is the seam for **alternative serializers**: code that writes SHACL by a route other
27
+ * than the create pipeline (e.g. raw SPARQL `INSERT DATA`) can look up the predicate and the
28
+ * literal datatype for a constraint instead of re-deriving them. Constraints whose meta-model
29
+ * path is a complex property path are omitted (they have no single predicate).
30
+ *
31
+ * Requires the meta-model to have been set up (importing `@_linked/core` or `utils/Package`
32
+ * does that). The result is cached once non-empty.
33
+ */
34
+ export declare function getPropertyShapeTerms(): ReadonlyMap<string, PropertyShapeTerm>;
35
+ /** Lookup of a single constraint by label — see {@link getPropertyShapeTerms}. */
36
+ export declare function getPropertyShapeTerm(label: string): PropertyShapeTerm | undefined;
@@ -0,0 +1,49 @@
1
+ /*
2
+ * This Source Code Form is subject to the terms of the Mozilla Public
3
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
4
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
5
+ */
6
+ import '../utils/Package.js'; // side effect: sets up the meta-model this table reads
7
+ import { isPathRef } from '../paths/PropertyPathExpr.js';
8
+ import { PropertyShape } from './SHACL.js';
9
+ let cached;
10
+ /**
11
+ * The SHACL constraints a `sh:PropertyShape` can carry, keyed by label — derived from the
12
+ * core meta-model (`PropertyShape.shape`, set up in `utils/Package.ts`) rather than from a
13
+ * hand-kept list, so a constraint added to the meta-model is immediately known here.
14
+ *
15
+ * This is the seam for **alternative serializers**: code that writes SHACL by a route other
16
+ * than the create pipeline (e.g. raw SPARQL `INSERT DATA`) can look up the predicate and the
17
+ * literal datatype for a constraint instead of re-deriving them. Constraints whose meta-model
18
+ * path is a complex property path are omitted (they have no single predicate).
19
+ *
20
+ * Requires the meta-model to have been set up (importing `@_linked/core` or `utils/Package`
21
+ * does that). The result is cached once non-empty.
22
+ */
23
+ export function getPropertyShapeTerms() {
24
+ var _a, _b, _c, _d;
25
+ if (cached && cached.size)
26
+ return cached;
27
+ const map = new Map();
28
+ for (const ps of (_b = (_a = PropertyShape.shape) === null || _a === void 0 ? void 0 : _a.propertyShapes) !== null && _b !== void 0 ? _b : []) {
29
+ // Only single-predicate paths describe a constraint; skip complex paths.
30
+ if (!ps.path || !isPathRef(ps.path))
31
+ continue;
32
+ const predicate = typeof ps.path === 'string' ? ps.path : ps.path.id;
33
+ if (!predicate)
34
+ continue;
35
+ map.set(ps.label, {
36
+ label: ps.label,
37
+ predicate,
38
+ datatype: (_c = ps.datatype) === null || _c === void 0 ? void 0 : _c.id,
39
+ nodeKind: (_d = ps.nodeKind) === null || _d === void 0 ? void 0 : _d.id,
40
+ });
41
+ }
42
+ cached = map;
43
+ return map;
44
+ }
45
+ /** Lookup of a single constraint by label — see {@link getPropertyShapeTerms}. */
46
+ export function getPropertyShapeTerm(label) {
47
+ return getPropertyShapeTerms().get(label);
48
+ }
49
+ //# sourceMappingURL=propertyShapeTerms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"propertyShapeTerms.js","sourceRoot":"","sources":["../../../src/shapes/propertyShapeTerms.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,qBAAqB,CAAC,CAAC,uDAAuD;AACrF,OAAO,EAAC,SAAS,EAAC,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAsBzC,IAAI,MAAkD,CAAC;AAEvD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB;;IACnC,IAAI,MAAM,IAAI,MAAM,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;IACzC,MAAM,GAAG,GAAG,IAAI,GAAG,EAA6B,CAAC;IACjD,KAAK,MAAM,EAAE,IAAI,MAAA,MAAA,aAAa,CAAC,KAAK,0CAAE,cAAc,mCAAI,EAAE,EAAE,CAAC;QAC3D,yEAAyE;QACzE,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC;YAAE,SAAS;QAC9C,MAAM,SAAS,GAAG,OAAO,EAAE,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACrE,IAAI,CAAC,SAAS;YAAE,SAAS;QACzB,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE;YAChB,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,SAAS;YACT,QAAQ,EAAE,MAAA,EAAE,CAAC,QAAQ,0CAAE,EAAE;YACzB,QAAQ,EAAE,MAAA,EAAE,CAAC,QAAQ,0CAAE,EAAE;SAC1B,CAAC,CAAC;IACL,CAAC;IACD,MAAM,GAAG,GAAG,CAAC;IACb,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,qBAAqB,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_linked/core",
3
- "version": "2.17.0",
3
+ "version": "2.18.0-next.20260829125240",
4
4
  "license": "MIT",
5
5
  "linkedPackage": true,
6
6
  "type": "module",