@shaclmate/shacl-ast 2.0.13 → 2.0.14

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/Factory.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import type { Either } from "purify-ts";
2
+ import type { Resource } from "rdfjs-resource";
3
+ import type { OntologyLike } from "./OntologyLike.js";
4
+ import type { ShapesGraph } from "./ShapesGraph.js";
5
+ export interface Factory<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
6
+ nodeShapeFromRdf(parameters: {
7
+ resource: Resource;
8
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
9
+ }): Either<Error, NodeShapeT>;
10
+ ontologyFromRdf(parameters: {
11
+ resource: Resource;
12
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
13
+ }): Either<Error, OntologyT>;
14
+ propertyGroupFromRdf(parameters: {
15
+ resource: Resource;
16
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
17
+ }): Either<Error, PropertyGroupT>;
18
+ propertyShapeFromRdf(parameters: {
19
+ resource: Resource;
20
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
21
+ }): Either<Error, PropertyShapeT>;
22
+ }
23
+ //# sourceMappingURL=Factory.d.ts.map
package/Factory.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Factory.js.map
package/NodeKind.d.ts CHANGED
@@ -1,9 +1,6 @@
1
+ import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
1
2
  /**
2
3
  * TypeScript enum corresponding to sh:NodeKind, for simpler manipulation.
3
4
  */
4
- export declare enum NodeKind {
5
- BLANK_NODE = 1,
6
- IRI = 2,
7
- LITERAL = 3
8
- }
5
+ export type NodeKind = (BlankNode | NamedNode | Literal)["termType"];
9
6
  //# sourceMappingURL=NodeKind.d.ts.map
package/NodeKind.js CHANGED
@@ -1,10 +1,2 @@
1
- /**
2
- * TypeScript enum corresponding to sh:NodeKind, for simpler manipulation.
3
- */
4
- export var NodeKind;
5
- (function (NodeKind) {
6
- NodeKind[NodeKind["BLANK_NODE"] = 1] = "BLANK_NODE";
7
- NodeKind[NodeKind["IRI"] = 2] = "IRI";
8
- NodeKind[NodeKind["LITERAL"] = 3] = "LITERAL";
9
- })(NodeKind || (NodeKind = {}));
1
+ export {};
10
2
  //# sourceMappingURL=NodeKind.js.map
package/NodeShape.d.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  import type { Maybe } from "purify-ts";
2
- import type { Resource } from "rdfjs-resource";
3
- import type { PropertyShape } from "./PropertyShape.js";
2
+ import type { OntologyLike } from "./OntologyLike.js";
4
3
  import { Shape } from "./Shape.js";
5
4
  import type { ShapesGraph } from "./ShapesGraph.js";
6
- export declare class NodeShape extends Shape {
7
- readonly constraints: NodeShape.Constraints;
8
- constructor(resource: Resource, shapesGraph: ShapesGraph);
5
+ import type * as generated from "./generated.js";
6
+ export declare class NodeShape<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> extends Shape<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT> {
7
+ readonly constraints: NodeShape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
8
+ constructor(generatedShaclCoreNodeShape: Omit<generated.ShaclCoreNodeShape, "type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
9
9
  toString(): string;
10
10
  }
11
11
  export declare namespace NodeShape {
12
- class Constraints extends Shape.Constraints {
12
+ class Constraints<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> extends Shape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT> {
13
+ private readonly generatedShaclCoreNodeShape;
14
+ constructor(generatedShaclCoreNodeShape: Omit<generated.ShaclCoreNodeShape, "type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
13
15
  get closed(): Maybe<boolean>;
14
- get properties(): readonly PropertyShape[];
16
+ get properties(): readonly PropertyShapeT[];
15
17
  }
16
18
  }
17
19
  //# sourceMappingURL=NodeShape.d.ts.map
package/NodeShape.js CHANGED
@@ -1,28 +1,24 @@
1
- import { sh } from "@tpluscode/rdf-ns-builders";
2
1
  import { Shape } from "./Shape.js";
3
2
  export class NodeShape extends Shape {
4
- constructor(resource, shapesGraph) {
5
- super(resource);
6
- this.constraints = new NodeShape.Constraints(resource, shapesGraph);
3
+ constructor(generatedShaclCoreNodeShape, shapesGraph) {
4
+ super(generatedShaclCoreNodeShape, shapesGraph);
5
+ this.constraints = new NodeShape.Constraints(generatedShaclCoreNodeShape, shapesGraph);
7
6
  }
8
7
  toString() {
9
- return `NodeShape(node=${this.resource.identifier.value})`;
8
+ return `NodeShape(node=${this.identifier.value})`;
10
9
  }
11
10
  }
12
11
  (function (NodeShape) {
13
12
  class Constraints extends Shape.Constraints {
13
+ constructor(generatedShaclCoreNodeShape, shapesGraph) {
14
+ super(generatedShaclCoreNodeShape, shapesGraph);
15
+ this.generatedShaclCoreNodeShape = generatedShaclCoreNodeShape;
16
+ }
14
17
  get closed() {
15
- return this.resource
16
- .value(sh.closed)
17
- .chain((value) => value.toBoolean())
18
- .toMaybe();
18
+ return this.generatedShaclCoreNodeShape.closed;
19
19
  }
20
20
  get properties() {
21
- return [...this.resource.values(sh.property)].flatMap((value) => value
22
- .toIdentifier()
23
- .toMaybe()
24
- .chain((shapeNode) => this.shapesGraph.propertyShapeByNode(shapeNode))
25
- .toList());
21
+ return this.generatedShaclCoreNodeShape.properties.flatMap((identifier) => this.shapesGraph.propertyShapeByIdentifier(identifier).toList());
26
22
  }
27
23
  }
28
24
  NodeShape.Constraints = Constraints;
package/Ontology.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { BlankNode, NamedNode } from "@rdfjs/types";
2
+ import type { OntologyLike } from "./OntologyLike.js";
3
+ import type * as generated from "./generated.js";
4
+ export declare class Ontology implements OntologyLike {
5
+ private readonly generatedOntology;
6
+ constructor(generatedOntology: Omit<generated.OwlOntology, "type">);
7
+ get identifier(): BlankNode | NamedNode;
8
+ toString(): string;
9
+ }
10
+ //# sourceMappingURL=Ontology.d.ts.map
package/Ontology.js ADDED
@@ -0,0 +1,12 @@
1
+ export class Ontology {
2
+ constructor(generatedOntology) {
3
+ this.generatedOntology = generatedOntology;
4
+ }
5
+ get identifier() {
6
+ return this.generatedOntology.identifier;
7
+ }
8
+ toString() {
9
+ return `Ontology(node=${this.identifier.value})`;
10
+ }
11
+ }
12
+ //# sourceMappingURL=Ontology.js.map
@@ -0,0 +1,8 @@
1
+ import type { BlankNode, NamedNode } from "@rdfjs/types";
2
+ /**
3
+ * Minimal interface for objects satisfying OntologyT.
4
+ */
5
+ export interface OntologyLike {
6
+ readonly identifier: BlankNode | NamedNode;
7
+ }
8
+ //# sourceMappingURL=OntologyLike.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=OntologyLike.js.map
@@ -1,9 +1,10 @@
1
- import type { Literal } from "@rdfjs/types";
2
- import type { Maybe } from "purify-ts";
3
- import type { Resource } from "rdfjs-resource";
1
+ import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
2
+ import type * as generated from "./generated.js";
4
3
  export declare class PropertyGroup {
5
- private readonly resource;
6
- constructor(resource: Resource);
7
- get label(): Maybe<Literal>;
4
+ private readonly delegate;
5
+ constructor(delegate: generated.ShaclCorePropertyGroup);
6
+ get comments(): readonly Literal[];
7
+ get identifier(): BlankNode | NamedNode;
8
+ get labels(): readonly Literal[];
8
9
  }
9
10
  //# sourceMappingURL=PropertyGroup.d.ts.map
package/PropertyGroup.js CHANGED
@@ -1,13 +1,15 @@
1
- import { rdfs } from "@tpluscode/rdf-ns-builders";
2
1
  export class PropertyGroup {
3
- constructor(resource) {
4
- this.resource = resource;
5
- }
6
- get label() {
7
- return this.resource
8
- .value(rdfs.label)
9
- .chain((value) => value.toLiteral())
10
- .toMaybe();
2
+ constructor(delegate) {
3
+ this.delegate = delegate;
4
+ }
5
+ get comments() {
6
+ return this.delegate.comments;
7
+ }
8
+ get identifier() {
9
+ return this.delegate.identifier;
10
+ }
11
+ get labels() {
12
+ return this.delegate.labels;
11
13
  }
12
14
  }
13
15
  //# sourceMappingURL=PropertyGroup.js.map
package/PropertyPath.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { NamedNode } from "@rdfjs/types";
2
- import { Either } from "purify-ts";
3
- import { Resource } from "rdfjs-resource";
2
+ import type * as purify from "purify-ts";
3
+ import type * as rdfjsResource from "rdfjs-resource";
4
4
  export interface AlternativePath {
5
5
  readonly kind: "AlternativePath";
6
6
  readonly members: readonly PropertyPath[];
@@ -31,6 +31,11 @@ export interface ZeroOrOnePath {
31
31
  }
32
32
  export type PropertyPath = AlternativePath | InversePath | OneOrMorePath | PredicatePath | SequencePath | ZeroOrMorePath | ZeroOrOnePath;
33
33
  export declare namespace PropertyPath {
34
- function fromResource(resource: Resource): Either<Error, PropertyPath>;
34
+ function fromRdf({ resource, }: {
35
+ [_index: string]: any;
36
+ ignoreRdfType?: boolean;
37
+ languageIn?: readonly string[];
38
+ resource: rdfjsResource.Resource;
39
+ }): purify.Either<rdfjsResource.Resource.ValueError, PropertyPath>;
35
40
  }
36
41
  //# sourceMappingURL=PropertyPath.d.ts.map
package/PropertyPath.js CHANGED
@@ -3,7 +3,7 @@ import { Either, Left } from "purify-ts";
3
3
  import { Resource } from "rdfjs-resource";
4
4
  export var PropertyPath;
5
5
  (function (PropertyPath) {
6
- function fromResource(resource) {
6
+ function fromRdf({ resource, }) {
7
7
  // Predicate path
8
8
  // sh:path ex:parent
9
9
  if (resource.identifier.termType === "NamedNode") {
@@ -16,9 +16,15 @@ export var PropertyPath;
16
16
  for (const value of values) {
17
17
  const memberResource = value.toResource().toMaybe();
18
18
  if (memberResource.isNothing()) {
19
- return Left(new Error("non-identifier in property path list"));
19
+ return Left(new Resource.ValueError({
20
+ focusResource: resource,
21
+ message: "non-identifier in property path list",
22
+ predicate: rdf.subject,
23
+ }));
20
24
  }
21
- const member = PropertyPath.fromResource(memberResource.unsafeCoerce());
25
+ const member = PropertyPath.fromRdf({
26
+ resource: memberResource.unsafeCoerce(),
27
+ });
22
28
  if (member.isLeft()) {
23
29
  return member;
24
30
  }
@@ -33,7 +39,11 @@ export var PropertyPath;
33
39
  case "NamedNode":
34
40
  break;
35
41
  default:
36
- return Left(new Error(`non-BlankNode/NamedNode property path object on path ${resource.identifier.value}: ${quad.object.termType} ${quad.object.value}`));
42
+ return Left(new Resource.ValueError({
43
+ focusResource: resource,
44
+ message: `non-BlankNode/NamedNode property path object on path ${resource.identifier.value}: ${quad.object.termType} ${quad.object.value}`,
45
+ predicate: quad.predicate,
46
+ }));
37
47
  }
38
48
  const objectResource = new Resource({
39
49
  dataset: resource.dataset,
@@ -50,14 +60,14 @@ export var PropertyPath;
50
60
  // Inverse path
51
61
  // sh:path: [ sh:inversePath ex:parent ]
52
62
  if (quad.predicate.equals(sh.inversePath)) {
53
- return PropertyPath.fromResource(objectResource).map((path) => ({
63
+ return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
54
64
  kind: "InversePath",
55
65
  path,
56
66
  }));
57
67
  }
58
68
  // One or more path
59
69
  if (quad.predicate.equals(sh.oneOrMorePath)) {
60
- return PropertyPath.fromResource(objectResource).map((path) => ({
70
+ return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
61
71
  kind: "OneOrMorePath",
62
72
  path,
63
73
  }));
@@ -72,20 +82,24 @@ export var PropertyPath;
72
82
  }
73
83
  // Zero or more path
74
84
  if (quad.predicate.equals(sh.zeroOrMorePath)) {
75
- return PropertyPath.fromResource(objectResource).map((path) => ({
85
+ return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
76
86
  kind: "ZeroOrMorePath",
77
87
  path,
78
88
  }));
79
89
  }
80
90
  if (quad.predicate.equals(sh.zeroOrOnePath)) {
81
- return PropertyPath.fromResource(objectResource).map((path) => ({
91
+ return PropertyPath.fromRdf({ resource: objectResource }).map((path) => ({
82
92
  kind: "ZeroOrOnePath",
83
93
  path,
84
94
  }));
85
95
  }
86
96
  }
87
- return Left(new Error(`unrecognized or ill-formed SHACL property path ${resource.identifier.value}`));
97
+ return Left(new Resource.ValueError({
98
+ focusResource: resource,
99
+ message: `unrecognized or ill-formed SHACL property path ${resource.identifier.value}`,
100
+ predicate: rdf.subject,
101
+ }));
88
102
  }
89
- PropertyPath.fromResource = fromResource;
103
+ PropertyPath.fromRdf = fromRdf;
90
104
  })(PropertyPath || (PropertyPath = {}));
91
105
  //# sourceMappingURL=PropertyPath.js.map
@@ -1,21 +1,20 @@
1
1
  import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
2
2
  import type { Maybe } from "purify-ts";
3
- import type { Resource } from "rdfjs-resource";
4
- import type { PropertyGroup } from "./PropertyGroup.js";
5
- import { PropertyPath } from "./PropertyPath.js";
3
+ import type { OntologyLike } from "./OntologyLike.js";
4
+ import type { PropertyPath } from "./PropertyPath.js";
6
5
  import { Shape } from "./Shape.js";
7
6
  import type { ShapesGraph } from "./ShapesGraph.js";
8
- export declare class PropertyShape extends Shape {
9
- private readonly shapesGraph;
10
- readonly constraints: Shape.Constraints;
11
- constructor(resource: Resource, shapesGraph: ShapesGraph);
7
+ import type * as generated from "./generated.js";
8
+ export declare class PropertyShape<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> extends Shape<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT> {
9
+ private readonly generatedShaclCorePropertyShape;
10
+ readonly constraints: Shape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
11
+ constructor(generatedShaclCorePropertyShape: Omit<generated.ShaclCorePropertyShape, "type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
12
12
  get defaultValue(): Maybe<BlankNode | Literal | NamedNode>;
13
- get editor(): Maybe<NamedNode>;
14
- get group(): Maybe<PropertyGroup>;
13
+ get descriptions(): readonly Literal[];
14
+ get groups(): readonly PropertyGroupT[];
15
+ get names(): readonly Literal[];
15
16
  get order(): Maybe<number>;
16
17
  get path(): PropertyPath;
17
- get singleLine(): Maybe<boolean>;
18
- get viewer(): Maybe<NamedNode>;
19
18
  toString(): string;
20
19
  }
21
20
  //# sourceMappingURL=PropertyShape.d.ts.map
package/PropertyShape.js CHANGED
@@ -1,58 +1,30 @@
1
- import { dash, sh } from "@tpluscode/rdf-ns-builders";
2
- import { PropertyPath } from "./PropertyPath.js";
3
1
  import { Shape } from "./Shape.js";
4
2
  export class PropertyShape extends Shape {
5
- constructor(resource, shapesGraph) {
6
- super(resource);
7
- this.shapesGraph = shapesGraph;
8
- this.constraints = new PropertyShape.Constraints(resource, shapesGraph);
3
+ constructor(generatedShaclCorePropertyShape, shapesGraph) {
4
+ super(generatedShaclCorePropertyShape, shapesGraph);
5
+ this.generatedShaclCorePropertyShape = generatedShaclCorePropertyShape;
6
+ this.constraints = new Shape.Constraints(generatedShaclCorePropertyShape, shapesGraph);
9
7
  }
10
8
  get defaultValue() {
11
- return this.resource
12
- .value(sh.defaultValue)
13
- .map((value) => value.toTerm())
14
- .toMaybe();
15
- }
16
- get editor() {
17
- return this.resource
18
- .value(dash.editor)
19
- .chain((value) => value.toIri())
20
- .toMaybe();
21
- }
22
- get group() {
23
- return this.resource
24
- .value(sh.group)
25
- .chain((value) => value.toIri())
26
- .toMaybe()
27
- .chain((node) => this.shapesGraph.propertyGroupByNode(node));
9
+ return this.generatedShaclCorePropertyShape.defaultValue;
10
+ }
11
+ get descriptions() {
12
+ return this.generatedShaclCorePropertyShape.descriptions;
13
+ }
14
+ get groups() {
15
+ return this.generatedShaclCorePropertyShape.groups.flatMap((identifier) => this.shapesGraph.propertyGroupByIdentifier(identifier).toList());
16
+ }
17
+ get names() {
18
+ return this.generatedShaclCorePropertyShape.names;
28
19
  }
29
20
  get order() {
30
- return this.resource
31
- .value(sh.maxCount)
32
- .chain((value) => value.toNumber())
33
- .toMaybe();
21
+ return this.generatedShaclCorePropertyShape.order;
34
22
  }
35
23
  get path() {
36
- return this.resource
37
- .value(sh.path)
38
- .chain((value) => value.toResource())
39
- .chain(PropertyPath.fromResource)
40
- .unsafeCoerce();
41
- }
42
- get singleLine() {
43
- return this.resource
44
- .value(dash.singleLine)
45
- .chain((value) => value.toBoolean())
46
- .toMaybe();
47
- }
48
- get viewer() {
49
- return this.resource
50
- .value(dash.viewer)
51
- .chain((value) => value.toIri())
52
- .toMaybe();
24
+ return this.generatedShaclCorePropertyShape.path;
53
25
  }
54
26
  toString() {
55
- const keyValues = [`node=${this.resource.identifier.value}`];
27
+ const keyValues = [`node=${this.identifier.value}`];
56
28
  const path = this.path;
57
29
  if (path.kind === "PredicatePath") {
58
30
  keyValues.push(`path=${path.iri.value}`);
@@ -0,0 +1,31 @@
1
+ import type { BlankNode, DatasetCore, DefaultGraph, NamedNode } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
3
+ import type { Factory } from "./Factory.js";
4
+ import type { OntologyLike } from "./OntologyLike.js";
5
+ export declare class RdfjsShapesGraph<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
6
+ readonly dataset: DatasetCore;
7
+ readonly node: BlankNode | DefaultGraph | NamedNode | null;
8
+ readonly nodeShapes: readonly NodeShapeT[];
9
+ readonly ontologies: readonly OntologyT[];
10
+ readonly propertyGroups: readonly PropertyGroupT[];
11
+ readonly propertyShapes: readonly PropertyShapeT[];
12
+ private readonly nodeShapesByIdentifier;
13
+ private readonly ontologiesByIdentifier;
14
+ private readonly propertyGroupsByIdentifier;
15
+ private readonly propertyShapesByIdentifier;
16
+ private readonly resourceSet;
17
+ constructor({ dataset, factory, }: {
18
+ dataset: DatasetCore;
19
+ factory: Factory<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
20
+ });
21
+ nodeShapeByIdentifier(nodeShapeNode: BlankNode | NamedNode): Maybe<NodeShapeT>;
22
+ ontologyByIdentifier(identifier: BlankNode | NamedNode): Maybe<OntologyT>;
23
+ propertyGroupByIdentifier(identifier: BlankNode | NamedNode): Maybe<PropertyGroupT>;
24
+ propertyShapeByIdentifier(identifier: BlankNode | NamedNode): Maybe<PropertyShapeT>;
25
+ shapeByIdentifier(identifier: BlankNode | NamedNode): Maybe<ShapeT>;
26
+ private readGraph;
27
+ private readOntologies;
28
+ private readPropertyGroups;
29
+ private readShapes;
30
+ }
31
+ //# sourceMappingURL=RdfjsShapesGraph.d.ts.map