@shaclmate/shacl-ast 4.0.12 → 4.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/dist/index.d.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  export * from "./Curie.js";
2
2
  export * from "./CurieFactory.js";
3
+ export { NodeShape, Ontology, PropertyGroup, PropertyShape, Shape, } from "./generated.js";
3
4
  export * from "./IdentifierNodeKind.js";
4
5
  export * from "./NodeKind.js";
5
- export * from "./NodeShape.js";
6
- export * from "./Ontology.js";
7
- export * from "./OntologyLike.js";
8
- export * from "./PropertyGroup.js";
9
- export * from "./PropertyShape.js";
10
- export * from "./Shape.js";
11
6
  export * from "./ShapesGraph.js";
12
7
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,12 +1,7 @@
1
1
  export * from "./Curie.js";
2
2
  export * from "./CurieFactory.js";
3
+ export { NodeShape, Ontology, PropertyGroup, PropertyShape, Shape, } from "./generated.js";
3
4
  export * from "./IdentifierNodeKind.js";
4
5
  export * from "./NodeKind.js";
5
- export * from "./NodeShape.js";
6
- export * from "./Ontology.js";
7
- export * from "./OntologyLike.js";
8
- export * from "./PropertyGroup.js";
9
- export * from "./PropertyShape.js";
10
- export * from "./Shape.js";
11
6
  export * from "./ShapesGraph.js";
12
7
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -50,5 +50,5 @@
50
50
  },
51
51
  "type": "module",
52
52
  "types": "./dist/index.d.ts",
53
- "version": "4.0.12"
53
+ "version": "4.0.14"
54
54
  }
@@ -1,19 +0,0 @@
1
- import { Either, type Maybe } from "purify-ts";
2
- import type * as generated from "./generated.js";
3
- import type { OntologyLike } from "./OntologyLike.js";
4
- import { Shape } from "./Shape.js";
5
- import type { ShapesGraph } from "./ShapesGraph.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(generatedNodeShape: Omit<generated.NodeShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
9
- toString(): string;
10
- }
11
- export declare namespace NodeShape {
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 generatedNodeShape;
14
- constructor(generatedNodeShape: Omit<generated.NodeShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
15
- get closed(): Maybe<boolean>;
16
- get properties(): Either<Error, readonly PropertyShapeT[]>;
17
- }
18
- }
19
- //# sourceMappingURL=NodeShape.d.ts.map
package/dist/NodeShape.js DELETED
@@ -1,43 +0,0 @@
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";
10
- import { Shape } from "./Shape.js";
11
- export class NodeShape extends Shape {
12
- constraints;
13
- constructor(generatedNodeShape, shapesGraph) {
14
- super(generatedNodeShape, shapesGraph);
15
- this.constraints = new NodeShape.Constraints(generatedNodeShape, shapesGraph);
16
- }
17
- toString() {
18
- return `NodeShape(identifier=${Resource.Identifier.toString(this.identifier)})`;
19
- }
20
- }
21
- __decorate([
22
- Memoize()
23
- ], NodeShape.prototype, "toString", null);
24
- (function (NodeShape) {
25
- class Constraints extends Shape.Constraints {
26
- generatedNodeShape;
27
- constructor(generatedNodeShape, shapesGraph) {
28
- super(generatedNodeShape, shapesGraph);
29
- this.generatedNodeShape = generatedNodeShape;
30
- }
31
- get closed() {
32
- return this.generatedNodeShape.closed;
33
- }
34
- get properties() {
35
- return Either.sequence(this.generatedNodeShape.properties.map((identifier) => this.shapesGraph.propertyShapeByIdentifier(identifier)));
36
- }
37
- }
38
- __decorate([
39
- Memoize()
40
- ], Constraints.prototype, "properties", null);
41
- NodeShape.Constraints = Constraints;
42
- })(NodeShape || (NodeShape = {}));
43
- //# sourceMappingURL=NodeShape.js.map
@@ -1,10 +0,0 @@
1
- import type { BlankNode, NamedNode } from "@rdfjs/types";
2
- import type * as generated from "./generated.js";
3
- import type { OntologyLike } from "./OntologyLike.js";
4
- export declare class Ontology implements OntologyLike {
5
- private readonly generatedOntology;
6
- constructor(generatedOntology: Omit<generated.Ontology, "$type">);
7
- get identifier(): BlankNode | NamedNode;
8
- toString(): string;
9
- }
10
- //# sourceMappingURL=Ontology.d.ts.map
package/dist/Ontology.js DELETED
@@ -1,24 +0,0 @@
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";
9
- export class Ontology {
10
- generatedOntology;
11
- constructor(generatedOntology) {
12
- this.generatedOntology = generatedOntology;
13
- }
14
- get identifier() {
15
- return this.generatedOntology.$identifier;
16
- }
17
- toString() {
18
- return `Ontology(identifier=${Resource.Identifier.toString(this.identifier)})`;
19
- }
20
- }
21
- __decorate([
22
- Memoize()
23
- ], Ontology.prototype, "toString", null);
24
- //# sourceMappingURL=Ontology.js.map
@@ -1,8 +0,0 @@
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
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=OntologyLike.js.map
@@ -1,11 +0,0 @@
1
- import type { BlankNode, NamedNode } from "@rdfjs/types";
2
- import type * as generated from "./generated.js";
3
- export declare class PropertyGroup {
4
- private readonly delegate;
5
- constructor(delegate: generated.PropertyGroup);
6
- get comments(): readonly string[];
7
- get identifier(): BlankNode | NamedNode;
8
- get labels(): readonly string[];
9
- toString(): string;
10
- }
11
- //# sourceMappingURL=PropertyGroup.d.ts.map
@@ -1,30 +0,0 @@
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";
9
- export class PropertyGroup {
10
- delegate;
11
- constructor(delegate) {
12
- this.delegate = delegate;
13
- }
14
- get comments() {
15
- return this.delegate.comments;
16
- }
17
- get identifier() {
18
- return this.delegate.$identifier;
19
- }
20
- get labels() {
21
- return this.delegate.labels;
22
- }
23
- toString() {
24
- return `PropertyGroup(identifier=${Resource.Identifier.toString(this.identifier)})`;
25
- }
26
- }
27
- __decorate([
28
- Memoize()
29
- ], PropertyGroup.prototype, "toString", null);
30
- //# sourceMappingURL=PropertyGroup.js.map
@@ -1,20 +0,0 @@
1
- import type { Literal, NamedNode } from "@rdfjs/types";
2
- import { Either, type Maybe } from "purify-ts";
3
- import { PropertyPath } from "rdfjs-resource";
4
- import type * as generated from "./generated.js";
5
- import type { OntologyLike } from "./OntologyLike.js";
6
- import { Shape } from "./Shape.js";
7
- import type { ShapesGraph } from "./ShapesGraph.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 generatedPropertyShape;
10
- readonly constraints: Shape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
11
- constructor(generatedPropertyShape: Omit<generated.PropertyShape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
12
- get defaultValue(): Maybe<Literal | NamedNode>;
13
- get descriptions(): readonly string[];
14
- get groups(): Either<Error, readonly PropertyGroupT[]>;
15
- get names(): readonly string[];
16
- get order(): Maybe<number>;
17
- get path(): PropertyPath;
18
- toString(): string;
19
- }
20
- //# sourceMappingURL=PropertyShape.d.ts.map
@@ -1,50 +0,0 @@
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";
10
- import { Shape } from "./Shape.js";
11
- export class PropertyShape extends Shape {
12
- generatedPropertyShape;
13
- constraints;
14
- constructor(generatedPropertyShape, shapesGraph) {
15
- super(generatedPropertyShape, shapesGraph);
16
- this.generatedPropertyShape = generatedPropertyShape;
17
- this.constraints = new Shape.Constraints(generatedPropertyShape, shapesGraph);
18
- }
19
- get defaultValue() {
20
- return this.generatedPropertyShape.defaultValue;
21
- }
22
- get descriptions() {
23
- return this.generatedPropertyShape.descriptions;
24
- }
25
- get groups() {
26
- return Either.sequence(this.generatedPropertyShape.groups.map((identifier) => this.shapesGraph.propertyGroupByIdentifier(identifier)));
27
- }
28
- get names() {
29
- return this.generatedPropertyShape.names;
30
- }
31
- get order() {
32
- return this.generatedPropertyShape.order;
33
- }
34
- get path() {
35
- return this.generatedPropertyShape.path;
36
- }
37
- toString() {
38
- return `PropertyShape(${[
39
- `identifier=${Resource.Identifier.toString(this.identifier)}`,
40
- `path=${PropertyPath.toString(this.path)}`,
41
- ].join(", ")})`;
42
- }
43
- }
44
- __decorate([
45
- Memoize()
46
- ], PropertyShape.prototype, "groups", null);
47
- __decorate([
48
- Memoize()
49
- ], PropertyShape.prototype, "toString", null);
50
- //# sourceMappingURL=PropertyShape.js.map
package/dist/Shape.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
2
- import { Either, Maybe } from "purify-ts";
3
- import type * as generated from "./generated.js";
4
- import type { NodeKind } from "./NodeKind.js";
5
- import type { OntologyLike } from "./OntologyLike.js";
6
- import type { ShapesGraph } from "./ShapesGraph.js";
7
- export declare abstract class Shape<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
8
- private readonly generatedShape;
9
- protected readonly shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
10
- abstract readonly constraints: Shape.Constraints<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
11
- constructor(generatedShape: Omit<generated.Shape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
12
- get comments(): readonly string[];
13
- get identifier(): BlankNode | NamedNode;
14
- get isDefinedBy(): Either<Error, Maybe<OntologyT>>;
15
- get labels(): readonly string[];
16
- }
17
- export declare namespace Shape {
18
- class Constraints<NodeShapeT extends ShapeT, OntologyT extends OntologyLike, PropertyGroupT, PropertyShapeT extends ShapeT, ShapeT> {
19
- private readonly generatedShape;
20
- protected readonly shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>;
21
- constructor(generatedShape: Omit<generated.Shape, "$type">, shapesGraph: ShapesGraph<NodeShapeT, OntologyT, PropertyGroupT, PropertyShapeT, ShapeT>);
22
- get and(): Either<Error, readonly ShapeT[]>;
23
- get classes(): readonly NamedNode[];
24
- get datatype(): Maybe<NamedNode>;
25
- get hasValues(): readonly (Literal | NamedNode)[];
26
- get in_(): readonly (Literal | NamedNode)[];
27
- get languageIn(): readonly string[];
28
- get maxCount(): Maybe<number>;
29
- get maxExclusive(): Maybe<Literal>;
30
- get maxInclusive(): Maybe<Literal>;
31
- get minCount(): Maybe<number>;
32
- get minExclusive(): Maybe<Literal>;
33
- get minInclusive(): Maybe<Literal>;
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
- private shapeListTakingConstraint;
40
- }
41
- }
42
- //# sourceMappingURL=Shape.d.ts.map
package/dist/Shape.js DELETED
@@ -1,163 +0,0 @@
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";
9
- export class Shape {
10
- generatedShape;
11
- shapesGraph;
12
- constructor(generatedShape, shapesGraph) {
13
- this.generatedShape = generatedShape;
14
- this.shapesGraph = shapesGraph;
15
- }
16
- get comments() {
17
- return this.generatedShape.comments;
18
- }
19
- get identifier() {
20
- return this.generatedShape.$identifier;
21
- }
22
- get isDefinedBy() {
23
- if (this.generatedShape.isDefinedBy.isJust()) {
24
- // If there's an rdfs:isDefinedBy statement on the shape then don't fall back to anything else
25
- return this.shapesGraph
26
- .ontologyByIdentifier(this.generatedShape.isDefinedBy.unsafeCoerce())
27
- .map(Maybe.of);
28
- }
29
- // No rdfs:isDefinedBy statement on the shape
30
- const ontologies = this.shapesGraph.ontologies;
31
- if (ontologies.length === 1) {
32
- // If there's a single ontology in the shapes graph, consider the shape a part of the ontology
33
- return Either.of(Maybe.of(ontologies[0]));
34
- }
35
- if (this.identifier.termType === "NamedNode") {
36
- const prefixOntologies = ontologies.filter((ontology) => ontology.identifier.termType === "NamedNode" &&
37
- this.identifier.value.startsWith(ontology.identifier.value));
38
- if (prefixOntologies.length === 1) {
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
40
- return Either.of(Maybe.of(prefixOntologies[0]));
41
- }
42
- }
43
- return Either.of(Maybe.empty());
44
- }
45
- get labels() {
46
- return this.generatedShape.labels;
47
- }
48
- }
49
- __decorate([
50
- Memoize()
51
- ], Shape.prototype, "isDefinedBy", null);
52
- (function (Shape) {
53
- class Constraints {
54
- generatedShape;
55
- shapesGraph;
56
- constructor(generatedShape, shapesGraph) {
57
- this.generatedShape = generatedShape;
58
- this.shapesGraph = shapesGraph;
59
- }
60
- get and() {
61
- return this.shapeListTakingConstraint(this.generatedShape.and);
62
- }
63
- get classes() {
64
- return this.generatedShape.classes;
65
- }
66
- get datatype() {
67
- return this.generatedShape.datatype;
68
- }
69
- get hasValues() {
70
- return this.generatedShape.hasValues;
71
- }
72
- get in_() {
73
- return this.generatedShape.in_.orDefault([]);
74
- }
75
- get languageIn() {
76
- return this.generatedShape.languageIn.orDefault([]);
77
- }
78
- get maxCount() {
79
- return this.generatedShape.maxCount;
80
- }
81
- get maxExclusive() {
82
- return this.generatedShape.maxExclusive;
83
- }
84
- get maxInclusive() {
85
- return this.generatedShape.maxInclusive;
86
- }
87
- get minCount() {
88
- return this.generatedShape.minCount;
89
- }
90
- get minExclusive() {
91
- return this.generatedShape.minExclusive;
92
- }
93
- get minInclusive() {
94
- return this.generatedShape.minInclusive;
95
- }
96
- get nodeKinds() {
97
- return this.generatedShape.nodeKind
98
- .map((iri) => {
99
- const nodeKinds = new Set();
100
- switch (iri.value) {
101
- case "http://www.w3.org/ns/shacl#BlankNode":
102
- nodeKinds.add("BlankNode");
103
- break;
104
- case "http://www.w3.org/ns/shacl#BlankNodeOrIRI":
105
- nodeKinds.add("BlankNode");
106
- nodeKinds.add("IRI");
107
- break;
108
- case "http://www.w3.org/ns/shacl#BlankNodeOrLiteral":
109
- nodeKinds.add("BlankNode");
110
- nodeKinds.add("Literal");
111
- break;
112
- case "http://www.w3.org/ns/shacl#IRI":
113
- nodeKinds.add("IRI");
114
- break;
115
- case "http://www.w3.org/ns/shacl#IRIOrLiteral":
116
- nodeKinds.add("IRI");
117
- nodeKinds.add("Literal");
118
- break;
119
- case "http://www.w3.org/ns/shacl#Literal":
120
- nodeKinds.add("Literal");
121
- break;
122
- }
123
- return nodeKinds;
124
- })
125
- .orDefault(new Set([]));
126
- }
127
- get nodes() {
128
- return Either.sequence(this.generatedShape.nodes.map((identifier) => this.shapesGraph.nodeShapeByIdentifier(identifier)));
129
- }
130
- get not() {
131
- return Either.sequence(this.generatedShape.not.map((identifier) => this.shapesGraph.shapeByIdentifier(identifier)));
132
- }
133
- get or() {
134
- return this.shapeListTakingConstraint(this.generatedShape.or);
135
- }
136
- get xone() {
137
- return this.shapeListTakingConstraint(this.generatedShape.xone);
138
- }
139
- shapeListTakingConstraint(identifiers) {
140
- return Either.sequence(identifiers.flatMap((identifiers) => identifiers.map((identifier) => this.shapesGraph.shapeByIdentifier(identifier))));
141
- }
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);
161
- Shape.Constraints = Constraints;
162
- })(Shape || (Shape = {}));
163
- //# sourceMappingURL=Shape.js.map