@shaclmate/shacl-ast 3.0.3 → 4.0.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/README.md CHANGED
@@ -11,7 +11,7 @@ Build an Abstract Syntax Tree (AST) of [Shapes Constraint Language (SHACL)](http
11
11
  ```ts
12
12
  import { ShapesGraph } from "@shaclmate/shacl-ast";
13
13
 
14
- const shapesGraph = ShapesGraph.fromDataset(testShapesGraph);
14
+ const shapesGraph = ShapesGraph.Factory.default_.createShapesGraph(testShapesGraphDataset);
15
15
  for (const nodeShape of shapesGraph.nodeShapes) {
16
16
  console.info("Node shape: ", nodeShape.node.value);
17
17
  for (const propertyShape of shapesGraph.propertyShapes) {
@@ -1,6 +1,6 @@
1
- import type { BlankNode, NamedNode } from "@rdfjs/types";
1
+ import type { NodeKind } from "./NodeKind.js";
2
2
  /**
3
3
  * TypeScript enum corresponding to sh:NodeKind, for simpler manipulation.
4
4
  */
5
- export type IdentifierNodeKind = (BlankNode | NamedNode)["termType"];
5
+ export type IdentifierNodeKind = Exclude<NodeKind, "Literal">;
6
6
  //# sourceMappingURL=IdentifierNodeKind.d.ts.map
@@ -1,6 +1,9 @@
1
- import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
2
1
  /**
3
2
  * TypeScript enum corresponding to sh:NodeKind, for simpler manipulation.
4
3
  */
5
- export type NodeKind = (BlankNode | NamedNode | Literal)["termType"];
4
+ export type NodeKind = "BlankNode" | "IRI" | "Literal";
5
+ export declare namespace NodeKind {
6
+ function fromTermType(termType: "BlankNode" | "Literal" | "NamedNode"): NodeKind;
7
+ function toTermType(nodeKind: NodeKind): "BlankNode" | "Literal" | "NamedNode";
8
+ }
6
9
  //# sourceMappingURL=NodeKind.d.ts.map
package/dist/NodeKind.js CHANGED
@@ -1,2 +1,12 @@
1
- export {};
1
+ export var NodeKind;
2
+ (function (NodeKind) {
3
+ function fromTermType(termType) {
4
+ return termType === "NamedNode" ? "IRI" : termType;
5
+ }
6
+ NodeKind.fromTermType = fromTermType;
7
+ function toTermType(nodeKind) {
8
+ return nodeKind === "IRI" ? "NamedNode" : nodeKind;
9
+ }
10
+ NodeKind.toTermType = toTermType;
11
+ })(NodeKind || (NodeKind = {}));
2
12
  //# sourceMappingURL=NodeKind.js.map
@@ -1,8 +1,8 @@
1
- import type { Maybe } from "purify-ts";
1
+ import { Either, type Maybe } from "purify-ts";
2
+ import type * as generated from "./generated.js";
2
3
  import type { OntologyLike } from "./OntologyLike.js";
3
4
  import { Shape } from "./Shape.js";
4
5
  import type { ShapesGraph } from "./ShapesGraph.js";
5
- import type * as generated from "./generated.js";
6
6
  export declare class NodeShape<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> extends Shape<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT> {
7
7
  readonly constraints: NodeShape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
8
8
  constructor(generatedShaclCoreNodeShape: Omit<generated.ShaclCoreNodeShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
@@ -13,7 +13,7 @@ export declare namespace NodeShape {
13
13
  private readonly generatedShaclCoreNodeShape;
14
14
  constructor(generatedShaclCoreNodeShape: Omit<generated.ShaclCoreNodeShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
15
15
  get closed(): Maybe<boolean>;
16
- get properties(): readonly PropertyShapeT[];
16
+ get properties(): Either<Error, readonly PropertyShapeT[]>;
17
17
  }
18
18
  }
19
19
  //# sourceMappingURL=NodeShape.d.ts.map
package/dist/NodeShape.js CHANGED
@@ -1,3 +1,12 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Either } from "purify-ts";
8
+ import { Resource } from "rdfjs-resource";
9
+ import { Memoize } from "typescript-memoize";
1
10
  import { Shape } from "./Shape.js";
2
11
  export class NodeShape extends Shape {
3
12
  constraints;
@@ -6,9 +15,12 @@ export class NodeShape extends Shape {
6
15
  this.constraints = new NodeShape.Constraints(generatedShaclCoreNodeShape, shapesGraph);
7
16
  }
8
17
  toString() {
9
- return `NodeShape(node=${this.identifier.value})`;
18
+ return `NodeShape(identifier=${Resource.Identifier.toString(this.identifier)})`;
10
19
  }
11
20
  }
21
+ __decorate([
22
+ Memoize()
23
+ ], NodeShape.prototype, "toString", null);
12
24
  (function (NodeShape) {
13
25
  class Constraints extends Shape.Constraints {
14
26
  generatedShaclCoreNodeShape;
@@ -20,9 +32,12 @@ export class NodeShape extends Shape {
20
32
  return this.generatedShaclCoreNodeShape.closed;
21
33
  }
22
34
  get properties() {
23
- return this.generatedShaclCoreNodeShape.properties.flatMap((identifier) => this.shapesGraph.propertyShapeByIdentifier(identifier).toList());
35
+ return Either.sequence(this.generatedShaclCoreNodeShape.properties.map((identifier) => this.shapesGraph.propertyShapeByIdentifier(identifier)));
24
36
  }
25
37
  }
38
+ __decorate([
39
+ Memoize()
40
+ ], Constraints.prototype, "properties", null);
26
41
  NodeShape.Constraints = Constraints;
27
42
  })(NodeShape || (NodeShape = {}));
28
43
  //# sourceMappingURL=NodeShape.js.map
@@ -1,6 +1,6 @@
1
1
  import type { BlankNode, NamedNode } from "@rdfjs/types";
2
- import type { OntologyLike } from "./OntologyLike.js";
3
2
  import type * as generated from "./generated.js";
3
+ import type { OntologyLike } from "./OntologyLike.js";
4
4
  export declare class Ontology implements OntologyLike {
5
5
  private readonly generatedOntology;
6
6
  constructor(generatedOntology: Omit<generated.OwlOntology, "$type">);
package/dist/Ontology.js CHANGED
@@ -1,3 +1,11 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Resource } from "rdfjs-resource";
8
+ import { Memoize } from "typescript-memoize";
1
9
  export class Ontology {
2
10
  generatedOntology;
3
11
  constructor(generatedOntology) {
@@ -7,7 +15,10 @@ export class Ontology {
7
15
  return this.generatedOntology.$identifier;
8
16
  }
9
17
  toString() {
10
- return `Ontology(node=${this.identifier.value})`;
18
+ return `Ontology(identifier=${Resource.Identifier.toString(this.identifier)})`;
11
19
  }
12
20
  }
21
+ __decorate([
22
+ Memoize()
23
+ ], Ontology.prototype, "toString", null);
13
24
  //# sourceMappingURL=Ontology.js.map
@@ -1,10 +1,11 @@
1
- import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
1
+ import type { BlankNode, NamedNode } from "@rdfjs/types";
2
2
  import type * as generated from "./generated.js";
3
3
  export declare class PropertyGroup {
4
4
  private readonly delegate;
5
5
  constructor(delegate: generated.ShaclCorePropertyGroup);
6
- get comments(): readonly Literal[];
6
+ get comments(): readonly string[];
7
7
  get identifier(): BlankNode | NamedNode;
8
- get labels(): readonly Literal[];
8
+ get labels(): readonly string[];
9
+ toString(): string;
9
10
  }
10
11
  //# sourceMappingURL=PropertyGroup.d.ts.map
@@ -1,3 +1,11 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Resource } from "rdfjs-resource";
8
+ import { Memoize } from "typescript-memoize";
1
9
  export class PropertyGroup {
2
10
  delegate;
3
11
  constructor(delegate) {
@@ -12,5 +20,11 @@ export class PropertyGroup {
12
20
  get labels() {
13
21
  return this.delegate.labels;
14
22
  }
23
+ toString() {
24
+ return `PropertyGroup(identifier=${Resource.Identifier.toString(this.identifier)})`;
25
+ }
15
26
  }
27
+ __decorate([
28
+ Memoize()
29
+ ], PropertyGroup.prototype, "toString", null);
16
30
  //# sourceMappingURL=PropertyGroup.js.map
@@ -1,18 +1,18 @@
1
1
  import type { Literal, NamedNode } from "@rdfjs/types";
2
- import type { Maybe } from "purify-ts";
2
+ import { Either, type Maybe } from "purify-ts";
3
+ import { PropertyPath } from "rdfjs-resource";
4
+ import type * as generated from "./generated.js";
3
5
  import type { OntologyLike } from "./OntologyLike.js";
4
- import type { PropertyPath } from "./PropertyPath.js";
5
6
  import { Shape } from "./Shape.js";
6
7
  import type { ShapesGraph } from "./ShapesGraph.js";
7
- import type * as generated from "./generated.js";
8
8
  export declare class PropertyShape<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> extends Shape<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT> {
9
9
  private readonly generatedShaclCorePropertyShape;
10
10
  readonly constraints: Shape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
11
11
  constructor(generatedShaclCorePropertyShape: Omit<generated.ShaclCorePropertyShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
12
12
  get defaultValue(): Maybe<Literal | NamedNode>;
13
- get descriptions(): readonly Literal[];
14
- get groups(): readonly PropertyGroupT[];
15
- get names(): readonly Literal[];
13
+ get descriptions(): readonly string[];
14
+ get groups(): Either<Error, readonly PropertyGroupT[]>;
15
+ get names(): readonly string[];
16
16
  get order(): Maybe<number>;
17
17
  get path(): PropertyPath;
18
18
  toString(): string;
@@ -1,3 +1,12 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Either } from "purify-ts";
8
+ import { PropertyPath, Resource } from "rdfjs-resource";
9
+ import { Memoize } from "typescript-memoize";
1
10
  import { Shape } from "./Shape.js";
2
11
  export class PropertyShape extends Shape {
3
12
  generatedShaclCorePropertyShape;
@@ -14,7 +23,7 @@ export class PropertyShape extends Shape {
14
23
  return this.generatedShaclCorePropertyShape.descriptions;
15
24
  }
16
25
  get groups() {
17
- return this.generatedShaclCorePropertyShape.groups.flatMap((identifier) => this.shapesGraph.propertyGroupByIdentifier(identifier).toList());
26
+ return Either.sequence(this.generatedShaclCorePropertyShape.groups.map((identifier) => this.shapesGraph.propertyGroupByIdentifier(identifier)));
18
27
  }
19
28
  get names() {
20
29
  return this.generatedShaclCorePropertyShape.names;
@@ -26,12 +35,16 @@ export class PropertyShape extends Shape {
26
35
  return this.generatedShaclCorePropertyShape.path;
27
36
  }
28
37
  toString() {
29
- const keyValues = [`node=${this.identifier.value}`];
30
- const path = this.path;
31
- if (path.kind === "PredicatePath") {
32
- keyValues.push(`path=${path.iri.value}`);
33
- }
34
- return `PropertyShape(${keyValues.join(", ")})`;
38
+ return `PropertyShape(${[
39
+ `identifier=${Resource.Identifier.toString(this.identifier)}`,
40
+ `path=${PropertyPath.$toString(this.path)}`,
41
+ ].join(", ")})`;
35
42
  }
36
43
  }
44
+ __decorate([
45
+ Memoize()
46
+ ], PropertyShape.prototype, "groups", null);
47
+ __decorate([
48
+ Memoize()
49
+ ], PropertyShape.prototype, "toString", null);
37
50
  //# sourceMappingURL=PropertyShape.js.map
package/dist/Shape.d.ts CHANGED
@@ -1,25 +1,25 @@
1
1
  import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
2
- import { Maybe } from "purify-ts";
2
+ import { Either, Maybe } from "purify-ts";
3
+ import type * as generated from "./generated.js";
3
4
  import type { NodeKind } from "./NodeKind.js";
4
5
  import type { OntologyLike } from "./OntologyLike.js";
5
6
  import type { ShapesGraph } from "./ShapesGraph.js";
6
- import type * as generated from "./generated.js";
7
7
  export declare abstract class Shape<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
8
8
  private readonly generatedShaclCoreShape;
9
9
  protected readonly shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
10
10
  abstract readonly constraints: Shape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
11
11
  constructor(generatedShaclCoreShape: Omit<generated.ShaclCoreShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
12
- get comments(): readonly Literal[];
12
+ get comments(): readonly string[];
13
13
  get identifier(): BlankNode | NamedNode;
14
- get isDefinedBy(): Maybe<OntologyT>;
15
- get labels(): readonly Literal[];
14
+ get isDefinedBy(): Either<Error, Maybe<OntologyT>>;
15
+ get labels(): readonly string[];
16
16
  }
17
17
  export declare namespace Shape {
18
18
  class Constraints<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
19
19
  private readonly generatedShaclCoreShape;
20
20
  protected readonly shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
21
21
  constructor(generatedShaclCoreShape: Omit<generated.ShaclCoreShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
22
- get and(): readonly ShapeT[];
22
+ get and(): Either<Error, readonly ShapeT[]>;
23
23
  get classes(): readonly NamedNode[];
24
24
  get datatype(): Maybe<NamedNode>;
25
25
  get hasValues(): readonly (Literal | NamedNode)[];
@@ -31,11 +31,11 @@ export declare namespace Shape {
31
31
  get minCount(): Maybe<number>;
32
32
  get minExclusive(): Maybe<Literal>;
33
33
  get minInclusive(): Maybe<Literal>;
34
- get nodeKinds(): Maybe<Set<NodeKind>>;
35
- get nodes(): readonly NodeShapeT[];
36
- get not(): readonly ShapeT[];
37
- get or(): readonly ShapeT[];
38
- get xone(): readonly ShapeT[];
34
+ get nodeKinds(): ReadonlySet<NodeKind>;
35
+ get nodes(): Either<Error, readonly NodeShapeT[]>;
36
+ get not(): Either<Error, readonly ShapeT[]>;
37
+ get or(): Either<Error, readonly ShapeT[]>;
38
+ get xone(): Either<Error, readonly ShapeT[]>;
39
39
  private shapeListTakingConstraint;
40
40
  }
41
41
  }
package/dist/Shape.js CHANGED
@@ -1,4 +1,11 @@
1
- import { Maybe } from "purify-ts";
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Either, Maybe } from "purify-ts";
8
+ import { Memoize } from "typescript-memoize";
2
9
  export class Shape {
3
10
  generatedShaclCoreShape;
4
11
  shapesGraph;
@@ -15,28 +22,33 @@ export class Shape {
15
22
  get isDefinedBy() {
16
23
  if (this.generatedShaclCoreShape.isDefinedBy.isJust()) {
17
24
  // If there's an rdfs:isDefinedBy statement on the shape then don't fall back to anything else
18
- return this.shapesGraph.ontologyByIdentifier(this.generatedShaclCoreShape.isDefinedBy.unsafeCoerce());
25
+ return this.shapesGraph
26
+ .ontologyByIdentifier(this.generatedShaclCoreShape.isDefinedBy.unsafeCoerce())
27
+ .map(Maybe.of);
19
28
  }
20
29
  // No rdfs:isDefinedBy statement on the shape
21
30
  const ontologies = this.shapesGraph.ontologies;
22
31
  if (ontologies.length === 1) {
23
32
  // If there's a single ontology in the shapes graph, consider the shape a part of the ontology
24
- return Maybe.of(ontologies[0]);
33
+ return Either.of(Maybe.of(ontologies[0]));
25
34
  }
26
35
  if (this.identifier.termType === "NamedNode") {
27
36
  const prefixOntologies = ontologies.filter((ontology) => ontology.identifier.termType === "NamedNode" &&
28
37
  this.identifier.value.startsWith(ontology.identifier.value));
29
38
  if (prefixOntologies.length === 1) {
30
39
  // If there's a single ontology whose IRI is a prefix of this shape's IRI, consider the shape a part of the ontology
31
- return Maybe.of(prefixOntologies[0]);
40
+ return Either.of(Maybe.of(prefixOntologies[0]));
32
41
  }
33
42
  }
34
- return Maybe.empty();
43
+ return Either.of(Maybe.empty());
35
44
  }
36
45
  get labels() {
37
46
  return this.generatedShaclCoreShape.labels;
38
47
  }
39
48
  }
49
+ __decorate([
50
+ Memoize()
51
+ ], Shape.prototype, "isDefinedBy", null);
40
52
  (function (Shape) {
41
53
  class Constraints {
42
54
  generatedShaclCoreShape;
@@ -82,7 +94,8 @@ export class Shape {
82
94
  return this.generatedShaclCoreShape.minInclusive;
83
95
  }
84
96
  get nodeKinds() {
85
- return this.generatedShaclCoreShape.nodeKind.chain((iri) => {
97
+ return this.generatedShaclCoreShape.nodeKind
98
+ .map((iri) => {
86
99
  const nodeKinds = new Set();
87
100
  switch (iri.value) {
88
101
  case "http://www.w3.org/ns/shacl#BlankNode":
@@ -90,31 +103,32 @@ export class Shape {
90
103
  break;
91
104
  case "http://www.w3.org/ns/shacl#BlankNodeOrIRI":
92
105
  nodeKinds.add("BlankNode");
93
- nodeKinds.add("NamedNode");
106
+ nodeKinds.add("IRI");
94
107
  break;
95
108
  case "http://www.w3.org/ns/shacl#BlankNodeOrLiteral":
96
109
  nodeKinds.add("BlankNode");
97
110
  nodeKinds.add("Literal");
98
111
  break;
99
112
  case "http://www.w3.org/ns/shacl#IRI":
100
- nodeKinds.add("NamedNode");
113
+ nodeKinds.add("IRI");
101
114
  break;
102
115
  case "http://www.w3.org/ns/shacl#IRIOrLiteral":
116
+ nodeKinds.add("IRI");
103
117
  nodeKinds.add("Literal");
104
- nodeKinds.add("NamedNode");
105
118
  break;
106
119
  case "http://www.w3.org/ns/shacl#Literal":
107
120
  nodeKinds.add("Literal");
108
121
  break;
109
122
  }
110
- return nodeKinds.size > 0 ? Maybe.of(nodeKinds) : Maybe.empty();
111
- });
123
+ return nodeKinds;
124
+ })
125
+ .orDefault(new Set([]));
112
126
  }
113
127
  get nodes() {
114
- return this.generatedShaclCoreShape.nodes.flatMap((identifier) => this.shapesGraph.nodeShapeByIdentifier(identifier).toList());
128
+ return Either.sequence(this.generatedShaclCoreShape.nodes.map((identifier) => this.shapesGraph.nodeShapeByIdentifier(identifier)));
115
129
  }
116
130
  get not() {
117
- return this.generatedShaclCoreShape.not.flatMap((identifier) => this.shapesGraph.shapeByIdentifier(identifier).toList());
131
+ return Either.sequence(this.generatedShaclCoreShape.not.map((identifier) => this.shapesGraph.shapeByIdentifier(identifier)));
118
132
  }
119
133
  get or() {
120
134
  return this.shapeListTakingConstraint(this.generatedShaclCoreShape.or);
@@ -123,9 +137,27 @@ export class Shape {
123
137
  return this.shapeListTakingConstraint(this.generatedShaclCoreShape.xone);
124
138
  }
125
139
  shapeListTakingConstraint(identifiers) {
126
- return identifiers.flatMap((identifiers) => identifiers.flatMap((identifier) => this.shapesGraph.shapeByIdentifier(identifier).toList()));
140
+ return Either.sequence(identifiers.flatMap((identifiers) => identifiers.map((identifier) => this.shapesGraph.shapeByIdentifier(identifier))));
127
141
  }
128
142
  }
143
+ __decorate([
144
+ Memoize()
145
+ ], Constraints.prototype, "and", null);
146
+ __decorate([
147
+ Memoize()
148
+ ], Constraints.prototype, "nodeKinds", null);
149
+ __decorate([
150
+ Memoize()
151
+ ], Constraints.prototype, "nodes", null);
152
+ __decorate([
153
+ Memoize()
154
+ ], Constraints.prototype, "not", null);
155
+ __decorate([
156
+ Memoize()
157
+ ], Constraints.prototype, "or", null);
158
+ __decorate([
159
+ Memoize()
160
+ ], Constraints.prototype, "xone", null);
129
161
  Shape.Constraints = Constraints;
130
162
  })(Shape || (Shape = {}));
131
163
  //# sourceMappingURL=Shape.js.map
@@ -1,12 +1,84 @@
1
- import type { BlankNode, NamedNode } from "@rdfjs/types";
2
- import type { Maybe } from "purify-ts";
1
+ import TermMap from "@rdfjs/term-map";
2
+ import type { BlankNode, DatasetCore, NamedNode } from "@rdfjs/types";
3
+ import { Either } from "purify-ts";
4
+ import { Resource } from "rdfjs-resource";
5
+ import { NodeShape } from "./NodeShape.js";
6
+ import { Ontology } from "./Ontology.js";
3
7
  import type { OntologyLike } from "./OntologyLike.js";
4
- export interface ShapesGraph<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
5
- readonly ontologies: readonly OntologyT[];
6
- nodeShapeByIdentifier(identifier: BlankNode | NamedNode): Maybe<NodeShapeT>;
7
- ontologyByIdentifier(identifier: BlankNode | NamedNode): Maybe<OntologyT>;
8
- propertyGroupByIdentifier(identifier: BlankNode | NamedNode): Maybe<PropertyGroupT>;
9
- propertyShapeByIdentifier(identifier: BlankNode | NamedNode): Maybe<PropertyShapeT>;
10
- shapeByIdentifier(identifier: BlankNode | NamedNode): Maybe<ShapeT>;
8
+ import { PropertyGroup } from "./PropertyGroup.js";
9
+ import { PropertyShape } from "./PropertyShape.js";
10
+ import type { Shape } from "./Shape.js";
11
+ export declare class ShapesGraph<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
12
+ private readonly nodeShapesByIdentifier;
13
+ private readonly ontologiesByIdentifier;
14
+ private readonly propertyGroupsByIdentifier;
15
+ private readonly propertyShapesByIdentifier;
16
+ constructor(parameters: {
17
+ nodeShapesByIdentifier: TermMap<BlankNode | NamedNode, NodeShapeT>;
18
+ ontologiesByIdentifier: TermMap<BlankNode | NamedNode, OntologyT>;
19
+ propertyGroupsByIdentifier: TermMap<BlankNode | NamedNode, PropertyGroupT>;
20
+ propertyShapesByIdentifier: TermMap<BlankNode | NamedNode, PropertyShapeT>;
21
+ });
22
+ get nodeShapes(): readonly NodeShapeT[];
23
+ nodeShapeByIdentifier(identifier: BlankNode | NamedNode): Either<Error, NodeShapeT>;
24
+ get ontologies(): readonly OntologyT[];
25
+ ontologyByIdentifier(identifier: BlankNode | NamedNode): Either<Error, OntologyT>;
26
+ propertyGroupByIdentifier(identifier: BlankNode | NamedNode): Either<Error, PropertyGroupT>;
27
+ get propertyGroups(): readonly PropertyGroupT[];
28
+ propertyShapeByIdentifier(identifier: BlankNode | NamedNode): Either<Error, PropertyShapeT>;
29
+ get propertyShapes(): readonly PropertyShapeT[];
30
+ shapeByIdentifier(identifier: BlankNode | NamedNode): Either<Error, ShapeT>;
31
+ }
32
+ export declare namespace ShapesGraph {
33
+ export abstract class Factory<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
34
+ protected preferredLanguages: readonly string[];
35
+ constructor(parameters?: {
36
+ preferredLanguages?: readonly string[];
37
+ });
38
+ createShapesGraph({ dataset, ignoreUndefinedShapes, }: {
39
+ dataset: DatasetCore;
40
+ ignoreUndefinedShapes?: boolean;
41
+ }): Either<Error, ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>>;
42
+ protected abstract createNodeShape(parameters: {
43
+ resource: Resource;
44
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
45
+ }): Either<Error, NodeShapeT>;
46
+ protected abstract createOntology(parameters: {
47
+ resource: Resource;
48
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
49
+ }): Either<Error, OntologyT>;
50
+ protected abstract createPropertyGroup(parameters: {
51
+ resource: Resource;
52
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
53
+ }): Either<Error, PropertyGroupT>;
54
+ protected abstract createPropertyShape(parameters: {
55
+ resource: Resource;
56
+ shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
57
+ }): Either<Error, PropertyShapeT>;
58
+ }
59
+ type DefaultNodeShape = NodeShape<any, Ontology, PropertyGroup, DefaultPropertyShape, DefaultShape>;
60
+ type DefaultPropertyShape = PropertyShape<DefaultNodeShape, Ontology, PropertyGroup, any, DefaultShape>;
61
+ type DefaultShape = Shape<DefaultNodeShape, Ontology, PropertyGroup, DefaultPropertyShape, any>;
62
+ type DefaultShapesGraph = ShapesGraph<DefaultNodeShape, Ontology, PropertyGroup, DefaultPropertyShape, DefaultShape>;
63
+ class DefaultFactory extends Factory<DefaultNodeShape, Ontology, PropertyGroup, DefaultPropertyShape, DefaultShape> {
64
+ protected createNodeShape({ resource, shapesGraph, }: {
65
+ resource: Resource;
66
+ shapesGraph: DefaultShapesGraph;
67
+ }): Either<Error, NodeShape<DefaultNodeShape, Ontology, PropertyGroup, DefaultPropertyShape, DefaultShape>>;
68
+ protected createOntology({ resource, }: {
69
+ resource: Resource;
70
+ shapesGraph: DefaultShapesGraph;
71
+ }): Either<Error, Ontology>;
72
+ protected createPropertyGroup({ resource, }: {
73
+ resource: Resource;
74
+ shapesGraph: DefaultShapesGraph;
75
+ }): Either<Error, PropertyGroup>;
76
+ protected createPropertyShape({ resource, shapesGraph, }: {
77
+ resource: Resource;
78
+ shapesGraph: DefaultShapesGraph;
79
+ }): Either<Error, DefaultPropertyShape>;
80
+ }
81
+ export function create(parameters: Parameters<DefaultFactory["createShapesGraph"]>[0]): Either<Error, DefaultShapesGraph>;
82
+ export {};
11
83
  }
12
84
  //# sourceMappingURL=ShapesGraph.d.ts.map