@shaclmate/compiler 2.0.12
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/ShapesGraphToAstTransformer.d.ts +32 -0
- package/ShapesGraphToAstTransformer.js +461 -0
- package/ast/Ast.d.ts +5 -0
- package/ast/Ast.js +2 -0
- package/ast/IdentifierType.d.ts +13 -0
- package/ast/IdentifierType.js +2 -0
- package/ast/IntersectionType.d.ts +9 -0
- package/ast/IntersectionType.js +2 -0
- package/ast/LiteralType.d.ts +13 -0
- package/ast/LiteralType.js +2 -0
- package/ast/MintingStrategy.d.ts +8 -0
- package/ast/MintingStrategy.js +9 -0
- package/ast/Name.d.ts +13 -0
- package/ast/Name.js +2 -0
- package/ast/ObjectType.d.ts +88 -0
- package/ast/ObjectType.js +2 -0
- package/ast/OptionType.d.ts +11 -0
- package/ast/OptionType.js +2 -0
- package/ast/SetType.d.ts +12 -0
- package/ast/SetType.js +2 -0
- package/ast/Type.d.ts +9 -0
- package/ast/Type.js +2 -0
- package/ast/UnionType.d.ts +9 -0
- package/ast/UnionType.js +2 -0
- package/ast/index.d.ts +10 -0
- package/ast/index.js +10 -0
- package/generators/index.d.ts +3 -0
- package/generators/index.js +3 -0
- package/generators/json/AstJsonGenerator.d.ts +7 -0
- package/generators/json/AstJsonGenerator.js +103 -0
- package/generators/json/index.d.ts +2 -0
- package/generators/json/index.js +2 -0
- package/generators/ts/BooleanType.d.ts +7 -0
- package/generators/ts/BooleanType.js +13 -0
- package/generators/ts/Configuration.d.ts +29 -0
- package/generators/ts/Configuration.js +40 -0
- package/generators/ts/IdentifierType.d.ts +23 -0
- package/generators/ts/IdentifierType.js +83 -0
- package/generators/ts/IntersectionType.d.ts +14 -0
- package/generators/ts/IntersectionType.js +26 -0
- package/generators/ts/ListType.d.ts +26 -0
- package/generators/ts/ListType.js +119 -0
- package/generators/ts/LiteralType.d.ts +14 -0
- package/generators/ts/LiteralType.js +61 -0
- package/generators/ts/NumberType.d.ts +7 -0
- package/generators/ts/NumberType.js +13 -0
- package/generators/ts/ObjectType.d.ts +71 -0
- package/generators/ts/ObjectType.js +160 -0
- package/generators/ts/OptionType.d.ts +17 -0
- package/generators/ts/OptionType.js +83 -0
- package/generators/ts/PrimitiveType.d.ts +11 -0
- package/generators/ts/PrimitiveType.js +41 -0
- package/generators/ts/RdfjsTermType.d.ts +25 -0
- package/generators/ts/RdfjsTermType.js +46 -0
- package/generators/ts/SetType.d.ts +19 -0
- package/generators/ts/SetType.js +76 -0
- package/generators/ts/StringType.d.ts +7 -0
- package/generators/ts/StringType.js +13 -0
- package/generators/ts/TsGenerator.d.ts +15 -0
- package/generators/ts/TsGenerator.js +119 -0
- package/generators/ts/Type.d.ts +108 -0
- package/generators/ts/Type.js +83 -0
- package/generators/ts/TypeFactory.d.ts +15 -0
- package/generators/ts/TypeFactory.js +198 -0
- package/generators/ts/UnionType.d.ts +18 -0
- package/generators/ts/UnionType.js +165 -0
- package/generators/ts/_ObjectType/IdentifierProperty.d.ts +23 -0
- package/generators/ts/_ObjectType/IdentifierProperty.js +82 -0
- package/generators/ts/_ObjectType/Property.d.ts +38 -0
- package/generators/ts/_ObjectType/Property.js +11 -0
- package/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -0
- package/generators/ts/_ObjectType/ShaclProperty.js +106 -0
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +29 -0
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +53 -0
- package/generators/ts/_ObjectType/classDeclaration.d.ts +4 -0
- package/generators/ts/_ObjectType/classDeclaration.js +154 -0
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.d.ts +4 -0
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.js +27 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.d.ts +4 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.js +72 -0
- package/generators/ts/_ObjectType/hashFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/hashFunctionDeclaration.js +64 -0
- package/generators/ts/_ObjectType/index.d.ts +12 -0
- package/generators/ts/_ObjectType/index.js +12 -0
- package/generators/ts/_ObjectType/interfaceDeclaration.d.ts +4 -0
- package/generators/ts/_ObjectType/interfaceDeclaration.js +12 -0
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.d.ts +4 -0
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.js +46 -0
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +4 -0
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +53 -0
- package/generators/ts/index.d.ts +2 -0
- package/generators/ts/index.js +2 -0
- package/generators/ts/rdfjsTermExpression.d.ts +5 -0
- package/generators/ts/rdfjsTermExpression.js +15 -0
- package/generators/ts/stringToValidTsIdentifier.d.ts +2 -0
- package/generators/ts/stringToValidTsIdentifier.js +14 -0
- package/generators/ts/tsName.d.ts +3 -0
- package/generators/ts/tsName.js +22 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/logger.d.ts +2 -0
- package/logger.js +8 -0
- package/package.json +71 -0
- package/vocabularies/dashDataset.d.ts +3 -0
- package/vocabularies/dashDataset.js +2370 -0
- package/vocabularies/index.d.ts +2 -0
- package/vocabularies/index.js +2 -0
- package/vocabularies/shaclmate.d.ts +15 -0
- package/vocabularies/shaclmate.js +6 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
+
import type { Maybe } from "purify-ts";
|
|
3
|
+
import type { NodeKind } from "shacl-ast";
|
|
4
|
+
import type { PredicatePath } from "shacl-ast";
|
|
5
|
+
import type { Name, Type } from ".";
|
|
6
|
+
import type { MintingStrategy } from "./MintingStrategy";
|
|
7
|
+
export interface ObjectType {
|
|
8
|
+
/**
|
|
9
|
+
* Classes generated from this type are abstract / cannot be instantiated themselves.
|
|
10
|
+
*
|
|
11
|
+
* Defaults to false.
|
|
12
|
+
*/
|
|
13
|
+
readonly abstract: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Ancestor (parents, their parents, ad nauseum) ObjectTypes of this ObjectType.
|
|
16
|
+
*
|
|
17
|
+
* Mutable to support cycle-handling logic in the transformer.
|
|
18
|
+
*/
|
|
19
|
+
readonly ancestorObjectTypes: ObjectType[];
|
|
20
|
+
/**
|
|
21
|
+
* Immediate child ObjectTypes of this ObjectType.
|
|
22
|
+
*
|
|
23
|
+
* Mutable to support cycle-handling logic in the transformer.
|
|
24
|
+
*/
|
|
25
|
+
readonly childObjectTypes: ObjectType[];
|
|
26
|
+
/**
|
|
27
|
+
* Descendant (children, their children, ad nauseum) ObjectTypes of this ObjectType.
|
|
28
|
+
*
|
|
29
|
+
* Mutable to support cycle-handling logic in the transformer.
|
|
30
|
+
*/
|
|
31
|
+
readonly descendantObjectTypes: ObjectType[];
|
|
32
|
+
/**
|
|
33
|
+
* Should generated code derived from this ObjectType be visible outside its module?
|
|
34
|
+
*
|
|
35
|
+
* Defaults to true.
|
|
36
|
+
*/
|
|
37
|
+
readonly export: boolean;
|
|
38
|
+
readonly kind: "ObjectType";
|
|
39
|
+
/**
|
|
40
|
+
* If the ObjectType is an RDF list, this is the type of rdf:first.
|
|
41
|
+
* https://www.w3.org/TR/rdf-schema/#ch_collectionvocab
|
|
42
|
+
*
|
|
43
|
+
* Mutable to support cycle-handling logic in the transformer.
|
|
44
|
+
*/
|
|
45
|
+
listItemType: Maybe<Type>;
|
|
46
|
+
/**
|
|
47
|
+
* Strategy for minting new object identifiers. If not specified, require an identifier on construction.
|
|
48
|
+
*/
|
|
49
|
+
readonly mintingStrategy: Maybe<MintingStrategy>;
|
|
50
|
+
/**
|
|
51
|
+
* Name of this ObjectType, usually derived from sh:name or shaclmate:name.
|
|
52
|
+
*/
|
|
53
|
+
readonly name: Name;
|
|
54
|
+
/**
|
|
55
|
+
* The RDF node kinds this ObjectType may be identified by.
|
|
56
|
+
*
|
|
57
|
+
* Used to associate instances with an RDF identifier.
|
|
58
|
+
*/
|
|
59
|
+
readonly nodeKinds: Set<NodeKind.BLANK_NODE | NodeKind.IRI>;
|
|
60
|
+
/**
|
|
61
|
+
* Immediate parent ObjectTypes of this Object types.
|
|
62
|
+
*
|
|
63
|
+
* Mutable to support cycle-handling logic in the transformer.
|
|
64
|
+
*/
|
|
65
|
+
readonly parentObjectTypes: ObjectType[];
|
|
66
|
+
/**
|
|
67
|
+
* Properties of this ObjectType.
|
|
68
|
+
*
|
|
69
|
+
* Mutable to support cycle-handling logic in the transformer.
|
|
70
|
+
*/
|
|
71
|
+
readonly properties: ObjectType.Property[];
|
|
72
|
+
/**
|
|
73
|
+
* The expected rdf:type of instances of this ObjectType.
|
|
74
|
+
*
|
|
75
|
+
* This is usually the identifier of an sh:NodeShape that is also an rdfs:Class (i.e., a node shape with implicit
|
|
76
|
+
* class targets).
|
|
77
|
+
*/
|
|
78
|
+
readonly rdfType: Maybe<NamedNode>;
|
|
79
|
+
}
|
|
80
|
+
export declare namespace ObjectType {
|
|
81
|
+
interface Property {
|
|
82
|
+
readonly inline: boolean;
|
|
83
|
+
readonly name: Name;
|
|
84
|
+
readonly path: PredicatePath;
|
|
85
|
+
readonly type: Type;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=ObjectType.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Type } from "./Type.js";
|
|
2
|
+
/**
|
|
3
|
+
* A type with zero or one values of an item type.
|
|
4
|
+
*
|
|
5
|
+
* This is a property with sh:minCount 0 and sh:maxCount 1.
|
|
6
|
+
*/
|
|
7
|
+
export interface OptionType {
|
|
8
|
+
readonly itemType: Type;
|
|
9
|
+
readonly kind: "OptionType";
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=OptionType.d.ts.map
|
package/ast/SetType.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Type } from "./Type.js";
|
|
2
|
+
/**
|
|
3
|
+
* A set of items of a specific type.
|
|
4
|
+
*
|
|
5
|
+
* This is a property with sh:maxCount != 1.
|
|
6
|
+
*/
|
|
7
|
+
export interface SetType {
|
|
8
|
+
readonly itemType: Type;
|
|
9
|
+
readonly kind: "SetType";
|
|
10
|
+
readonly minCount: number;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=SetType.d.ts.map
|
package/ast/SetType.js
ADDED
package/ast/Type.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { IdentifierType } from "./IdentifierType.js";
|
|
2
|
+
import type { IntersectionType } from "./IntersectionType.js";
|
|
3
|
+
import type { LiteralType } from "./LiteralType.js";
|
|
4
|
+
import type { ObjectType } from "./ObjectType.js";
|
|
5
|
+
import type { OptionType } from "./OptionType";
|
|
6
|
+
import type { SetType } from "./SetType";
|
|
7
|
+
import type { UnionType } from "./UnionType.js";
|
|
8
|
+
export type Type = IdentifierType | IntersectionType | LiteralType | ObjectType | OptionType | SetType | UnionType;
|
|
9
|
+
//# sourceMappingURL=Type.d.ts.map
|
package/ast/Type.js
ADDED
package/ast/UnionType.js
ADDED
package/ast/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./Ast.js";
|
|
2
|
+
export * from "./IdentifierType.js";
|
|
3
|
+
export * from "./IntersectionType";
|
|
4
|
+
export * from "./LiteralType.js";
|
|
5
|
+
export * from "./MintingStrategy.js";
|
|
6
|
+
export * from "./Name.js";
|
|
7
|
+
export * from "./ObjectType.js";
|
|
8
|
+
export * from "./UnionType";
|
|
9
|
+
export * from "./Type.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/ast/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./Ast.js";
|
|
2
|
+
export * from "./IdentifierType.js";
|
|
3
|
+
export * from "./IntersectionType";
|
|
4
|
+
export * from "./LiteralType.js";
|
|
5
|
+
export * from "./MintingStrategy.js";
|
|
6
|
+
export * from "./Name.js";
|
|
7
|
+
export * from "./ObjectType.js";
|
|
8
|
+
export * from "./UnionType";
|
|
9
|
+
export * from "./Type.js";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as shaclAst from "shacl-ast";
|
|
2
|
+
function nameToJson(name) {
|
|
3
|
+
return {
|
|
4
|
+
curie: name.curie.extract(),
|
|
5
|
+
identifier: termToJson(name.identifier),
|
|
6
|
+
shName: name.shName.extract(),
|
|
7
|
+
shaclmateName: name.shaclmateName.extract(),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function nodeKindToJson(nodeKind) {
|
|
11
|
+
switch (nodeKind) {
|
|
12
|
+
case shaclAst.NodeKind.BLANK_NODE:
|
|
13
|
+
return "BlankNode";
|
|
14
|
+
case shaclAst.NodeKind.IRI:
|
|
15
|
+
return "NamedNode";
|
|
16
|
+
case shaclAst.NodeKind.LITERAL:
|
|
17
|
+
return "Literal";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function termToJson(term) {
|
|
21
|
+
switch (term.termType) {
|
|
22
|
+
case "BlankNode":
|
|
23
|
+
return { termType: term.termType, value: term.value };
|
|
24
|
+
case "Literal":
|
|
25
|
+
return {
|
|
26
|
+
datatype: term.datatype.value,
|
|
27
|
+
language: term.language,
|
|
28
|
+
termType: term.termType,
|
|
29
|
+
value: term.value,
|
|
30
|
+
};
|
|
31
|
+
case "NamedNode":
|
|
32
|
+
return { termType: term.termType, value: term.value };
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`unsupported term type: ${term.termType}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function typeToJson(type) {
|
|
38
|
+
switch (type.kind) {
|
|
39
|
+
case "IdentifierType":
|
|
40
|
+
return {
|
|
41
|
+
hasValue: type.hasValue.map(termToJson).extract(),
|
|
42
|
+
kind: type.kind,
|
|
43
|
+
nodeKinds: [...type.nodeKinds].map(nodeKindToJson),
|
|
44
|
+
};
|
|
45
|
+
case "IntersectionType":
|
|
46
|
+
case "UnionType":
|
|
47
|
+
return {
|
|
48
|
+
kind: type.kind,
|
|
49
|
+
types: type.memberTypes.map((type) => typeToJson(type)),
|
|
50
|
+
};
|
|
51
|
+
case "LiteralType": {
|
|
52
|
+
return {
|
|
53
|
+
datatype: type.datatype.extract(),
|
|
54
|
+
hasValue: type.hasValue.map(termToJson).extract(),
|
|
55
|
+
kind: type.kind,
|
|
56
|
+
maxExclusive: type.maxExclusive.map(termToJson).extract(),
|
|
57
|
+
maxInclusive: type.maxInclusive.map(termToJson).extract(),
|
|
58
|
+
minExclusive: type.minExclusive.map(termToJson).extract(),
|
|
59
|
+
minInclusive: type.minInclusive.map(termToJson).extract(),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
case "ObjectType":
|
|
63
|
+
return {
|
|
64
|
+
kind: type.kind,
|
|
65
|
+
listItemType: type.listItemType.map(typeToJson).extract(),
|
|
66
|
+
name: nameToJson(type.name),
|
|
67
|
+
parentObjectTypes: type.parentObjectTypes.length > 0
|
|
68
|
+
? type.parentObjectTypes.map((type) => nameToJson(type.name))
|
|
69
|
+
: undefined,
|
|
70
|
+
nodeKinds: [...type.nodeKinds].map(nodeKindToJson),
|
|
71
|
+
rdfType: type.rdfType.map(termToJson).extract(),
|
|
72
|
+
};
|
|
73
|
+
case "OptionType":
|
|
74
|
+
return {
|
|
75
|
+
itemType: typeToJson(type.itemType),
|
|
76
|
+
kind: type.kind,
|
|
77
|
+
};
|
|
78
|
+
case "SetType":
|
|
79
|
+
return {
|
|
80
|
+
itemType: typeToJson(type.itemType),
|
|
81
|
+
kind: type.kind,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export class AstJsonGenerator {
|
|
86
|
+
constructor(ast) {
|
|
87
|
+
this.ast = ast;
|
|
88
|
+
}
|
|
89
|
+
generate() {
|
|
90
|
+
return JSON.stringify({
|
|
91
|
+
objectTypes: this.ast.objectTypes.map((objectType) => ({
|
|
92
|
+
kind: objectType.kind,
|
|
93
|
+
name: nameToJson(objectType.name),
|
|
94
|
+
properties: objectType.properties.map((property) => ({
|
|
95
|
+
name: nameToJson(property.name),
|
|
96
|
+
path: property.path.iri.value,
|
|
97
|
+
type: typeToJson(property.type),
|
|
98
|
+
})),
|
|
99
|
+
})),
|
|
100
|
+
}, undefined, 2);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=AstJsonGenerator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PrimitiveType } from "./PrimitiveType.js";
|
|
2
|
+
export declare class BooleanType extends PrimitiveType {
|
|
3
|
+
get name(): string;
|
|
4
|
+
fromRdfResourceValueExpression({ variables, }: Parameters<PrimitiveType["fromRdfResourceValueExpression"]>[0]): string;
|
|
5
|
+
hashStatements({ variables, }: Parameters<PrimitiveType["hashStatements"]>[0]): readonly string[];
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=BooleanType.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PrimitiveType } from "./PrimitiveType.js";
|
|
2
|
+
export class BooleanType extends PrimitiveType {
|
|
3
|
+
get name() {
|
|
4
|
+
return "boolean";
|
|
5
|
+
}
|
|
6
|
+
fromRdfResourceValueExpression({ variables, }) {
|
|
7
|
+
return `${variables.resourceValue}.toBoolean()`;
|
|
8
|
+
}
|
|
9
|
+
hashStatements({ variables, }) {
|
|
10
|
+
return [`${variables.hasher}.update(${variables.value}.toString());`];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=BooleanType.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
type Feature = "equals" | "fromRdf" | "hash" | "toRdf" | "sparql-graph-patterns";
|
|
2
|
+
export declare class Configuration {
|
|
3
|
+
readonly dataFactoryImport: string;
|
|
4
|
+
readonly dataFactoryVariable: string;
|
|
5
|
+
readonly features: Set<Feature>;
|
|
6
|
+
readonly objectTypeDeclarationType: "class" | "interface";
|
|
7
|
+
readonly objectTypeDiscriminatorPropertyName: string;
|
|
8
|
+
readonly objectTypeIdentifierPropertyName: string;
|
|
9
|
+
constructor(parameters?: {
|
|
10
|
+
dataFactoryImport?: string;
|
|
11
|
+
dataFactoryVariable?: string;
|
|
12
|
+
features?: Set<Feature>;
|
|
13
|
+
objectTypeDeclarationType?: "class" | "interface";
|
|
14
|
+
objectTypeIdentifierPropertyName?: string;
|
|
15
|
+
objectTypeDiscriminatorPropertyName?: string;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export declare namespace Configuration {
|
|
19
|
+
namespace Defaults {
|
|
20
|
+
const dataFactoryImport = "import { DataFactory as dataFactory } from \"n3\"";
|
|
21
|
+
const dataFactoryVariable = "dataFactory";
|
|
22
|
+
const features: Set<Feature>;
|
|
23
|
+
const objectTypeDeclarationType: "class";
|
|
24
|
+
const objectTypeDiscriminatorPropertyName = "type";
|
|
25
|
+
const objectTypeIdentifierPropertyName = "identifier";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=Configuration.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export class Configuration {
|
|
2
|
+
constructor(parameters) {
|
|
3
|
+
this.features = new Set(parameters?.features ? [...parameters.features] : []);
|
|
4
|
+
this.dataFactoryImport =
|
|
5
|
+
parameters?.dataFactoryImport ?? Configuration.Defaults.dataFactoryImport;
|
|
6
|
+
this.dataFactoryVariable =
|
|
7
|
+
parameters?.dataFactoryVariable ??
|
|
8
|
+
Configuration.Defaults.dataFactoryVariable;
|
|
9
|
+
if (this.features.size === 0) {
|
|
10
|
+
this.features = Configuration.Defaults.features;
|
|
11
|
+
}
|
|
12
|
+
this.objectTypeDeclarationType =
|
|
13
|
+
parameters?.objectTypeDeclarationType ??
|
|
14
|
+
Configuration.Defaults.objectTypeDeclarationType;
|
|
15
|
+
this.objectTypeIdentifierPropertyName =
|
|
16
|
+
parameters?.objectTypeIdentifierPropertyName ??
|
|
17
|
+
Configuration.Defaults.objectTypeIdentifierPropertyName;
|
|
18
|
+
this.objectTypeDiscriminatorPropertyName =
|
|
19
|
+
parameters?.objectTypeDiscriminatorPropertyName ??
|
|
20
|
+
Configuration.Defaults.objectTypeDiscriminatorPropertyName;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
(function (Configuration) {
|
|
24
|
+
let Defaults;
|
|
25
|
+
(function (Defaults) {
|
|
26
|
+
Defaults.dataFactoryImport = 'import { DataFactory as dataFactory } from "n3"';
|
|
27
|
+
Defaults.dataFactoryVariable = "dataFactory";
|
|
28
|
+
Defaults.features = new Set([
|
|
29
|
+
"equals",
|
|
30
|
+
"fromRdf",
|
|
31
|
+
"hash",
|
|
32
|
+
"toRdf",
|
|
33
|
+
"sparql-graph-patterns",
|
|
34
|
+
]);
|
|
35
|
+
Defaults.objectTypeDeclarationType = "class";
|
|
36
|
+
Defaults.objectTypeDiscriminatorPropertyName = "type";
|
|
37
|
+
Defaults.objectTypeIdentifierPropertyName = "identifier";
|
|
38
|
+
})(Defaults = Configuration.Defaults || (Configuration.Defaults = {}));
|
|
39
|
+
})(Configuration || (Configuration = {}));
|
|
40
|
+
//# sourceMappingURL=Configuration.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { NodeKind } from "shacl-ast";
|
|
4
|
+
import { RdfjsTermType } from "./RdfjsTermType.js";
|
|
5
|
+
import type { Type } from "./Type";
|
|
6
|
+
export declare class IdentifierType extends RdfjsTermType<BlankNode | NamedNode> {
|
|
7
|
+
readonly kind = "IdentifierType";
|
|
8
|
+
private readonly nodeKinds;
|
|
9
|
+
constructor({ nodeKinds, ...superParameters }: {
|
|
10
|
+
nodeKinds: Set<NodeKind.BLANK_NODE | NodeKind.IRI>;
|
|
11
|
+
} & ConstructorParameters<typeof RdfjsTermType<BlankNode | NamedNode>>[0]);
|
|
12
|
+
get conversions(): readonly Type.Conversion[];
|
|
13
|
+
get discriminatorProperty(): Maybe<Type.DiscriminatorProperty>;
|
|
14
|
+
get isNamedNodeKind(): boolean;
|
|
15
|
+
get name(): string;
|
|
16
|
+
hashStatements({ variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
17
|
+
protected fromRdfResourceValueExpression({ variables, }: {
|
|
18
|
+
variables: {
|
|
19
|
+
resourceValue: string;
|
|
20
|
+
};
|
|
21
|
+
}): string;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=IdentifierType.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
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 { Maybe } from "purify-ts";
|
|
8
|
+
import { NodeKind } from "shacl-ast";
|
|
9
|
+
import { invariant } from "ts-invariant";
|
|
10
|
+
import { Memoize } from "typescript-memoize";
|
|
11
|
+
import { RdfjsTermType } from "./RdfjsTermType.js";
|
|
12
|
+
import { rdfjsTermExpression } from "./rdfjsTermExpression";
|
|
13
|
+
export class IdentifierType extends RdfjsTermType {
|
|
14
|
+
constructor({ nodeKinds, ...superParameters }) {
|
|
15
|
+
super(superParameters);
|
|
16
|
+
this.kind = "IdentifierType";
|
|
17
|
+
this.nodeKinds = new Set([...nodeKinds]);
|
|
18
|
+
invariant(this.nodeKinds.size > 0);
|
|
19
|
+
}
|
|
20
|
+
get conversions() {
|
|
21
|
+
return this.defaultValue
|
|
22
|
+
.map((defaultValue) => [
|
|
23
|
+
{
|
|
24
|
+
conversionExpression: () => rdfjsTermExpression(defaultValue, this.configuration),
|
|
25
|
+
sourceTypeName: "undefined",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
conversionExpression: (value) => value,
|
|
29
|
+
sourceTypeCheck: (value) => `typeof ${value} === "object"`,
|
|
30
|
+
sourceTypeName: this.name,
|
|
31
|
+
},
|
|
32
|
+
])
|
|
33
|
+
.orDefault(super.conversions);
|
|
34
|
+
}
|
|
35
|
+
get discriminatorProperty() {
|
|
36
|
+
return Maybe.of({
|
|
37
|
+
name: "termType",
|
|
38
|
+
type: "string",
|
|
39
|
+
values: [...this.nodeKinds].map((nodeKind) => {
|
|
40
|
+
switch (nodeKind) {
|
|
41
|
+
case NodeKind.BLANK_NODE:
|
|
42
|
+
return "BlankNode";
|
|
43
|
+
case NodeKind.IRI:
|
|
44
|
+
return "NamedNode";
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
get isNamedNodeKind() {
|
|
50
|
+
return this.nodeKinds.size === 1 && this.nodeKinds.has(NodeKind.IRI);
|
|
51
|
+
}
|
|
52
|
+
get name() {
|
|
53
|
+
const names = [];
|
|
54
|
+
if (this.nodeKinds.has(NodeKind.BLANK_NODE)) {
|
|
55
|
+
names.push("rdfjs.BlankNode");
|
|
56
|
+
}
|
|
57
|
+
if (this.nodeKinds.has(NodeKind.IRI)) {
|
|
58
|
+
names.push("rdfjs.NamedNode");
|
|
59
|
+
}
|
|
60
|
+
return names.join(" | ");
|
|
61
|
+
}
|
|
62
|
+
hashStatements({ variables, }) {
|
|
63
|
+
return [
|
|
64
|
+
`${variables.hasher}.update(rdfjsResource.Resource.Identifier.toString(${variables.value}));`,
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
fromRdfResourceValueExpression({ variables, }) {
|
|
68
|
+
switch (this.name) {
|
|
69
|
+
case "rdfjs.BlankNode":
|
|
70
|
+
throw new Error("not implemented");
|
|
71
|
+
case "rdfjs.NamedNode":
|
|
72
|
+
return `${variables.resourceValue}.toIri()`;
|
|
73
|
+
case "rdfjs.BlankNode | rdfjs.NamedNode":
|
|
74
|
+
return `${variables.resourceValue}.toIdentifier()`;
|
|
75
|
+
default:
|
|
76
|
+
throw new Error(`not implemented: ${this.name}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
__decorate([
|
|
81
|
+
Memoize()
|
|
82
|
+
], IdentifierType.prototype, "name", null);
|
|
83
|
+
//# sourceMappingURL=IdentifierType.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Type } from "./Type.js";
|
|
2
|
+
export declare class IntersectionType extends Type {
|
|
3
|
+
readonly kind = "IntersectionType";
|
|
4
|
+
readonly memberTypes: readonly Type[];
|
|
5
|
+
constructor({ memberTypes, ...superParameters }: ConstructorParameters<typeof Type>[0] & {
|
|
6
|
+
memberTypes: readonly Type[];
|
|
7
|
+
});
|
|
8
|
+
get name(): string;
|
|
9
|
+
equalsFunction(): string;
|
|
10
|
+
fromRdfExpression(): string;
|
|
11
|
+
hashStatements(): readonly string[];
|
|
12
|
+
toRdfExpression(): string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=IntersectionType.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { invariant } from "ts-invariant";
|
|
2
|
+
import { Type } from "./Type.js";
|
|
3
|
+
export class IntersectionType extends Type {
|
|
4
|
+
constructor({ memberTypes, ...superParameters }) {
|
|
5
|
+
super(superParameters);
|
|
6
|
+
this.kind = "IntersectionType";
|
|
7
|
+
invariant(memberTypes.length >= 2);
|
|
8
|
+
this.memberTypes = memberTypes;
|
|
9
|
+
}
|
|
10
|
+
get name() {
|
|
11
|
+
return `(${this.memberTypes.map((type) => type.name).join(" & ")})`;
|
|
12
|
+
}
|
|
13
|
+
equalsFunction() {
|
|
14
|
+
throw new Error("Method not implemented.");
|
|
15
|
+
}
|
|
16
|
+
fromRdfExpression() {
|
|
17
|
+
throw new Error("Method not implemented.");
|
|
18
|
+
}
|
|
19
|
+
hashStatements() {
|
|
20
|
+
throw new Error("Method not implemented.");
|
|
21
|
+
}
|
|
22
|
+
toRdfExpression() {
|
|
23
|
+
throw new Error("Method not implemented.");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=IntersectionType.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { MintingStrategy } from "../../ast";
|
|
4
|
+
import { Type } from "./Type.js";
|
|
5
|
+
export declare class ListType extends Type {
|
|
6
|
+
readonly itemType: Type;
|
|
7
|
+
readonly kind = "ListType";
|
|
8
|
+
private readonly identifierNodeKind;
|
|
9
|
+
private readonly mintingStrategy;
|
|
10
|
+
private readonly rdfType;
|
|
11
|
+
constructor({ identifierNodeKind, itemType, mintingStrategy, rdfType, ...superParameters }: {
|
|
12
|
+
identifierNodeKind: ListType["identifierNodeKind"];
|
|
13
|
+
itemType: Type;
|
|
14
|
+
mintingStrategy: Maybe<MintingStrategy>;
|
|
15
|
+
rdfType: Maybe<NamedNode>;
|
|
16
|
+
} & ConstructorParameters<typeof Type>[0]);
|
|
17
|
+
get discriminatorProperty(): Maybe<Type.DiscriminatorProperty>;
|
|
18
|
+
get importStatements(): readonly string[];
|
|
19
|
+
get name(): string;
|
|
20
|
+
chainSparqlGraphPatternExpression({ variables, }: Parameters<Type["chainSparqlGraphPatternExpression"]>[0]): Maybe<Type.SparqlGraphPatternsExpression>;
|
|
21
|
+
equalsFunction(): string;
|
|
22
|
+
fromRdfExpression({ variables, }: Parameters<Type["fromRdfExpression"]>[0]): string;
|
|
23
|
+
hashStatements({ variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
24
|
+
toRdfExpression({ variables, }: Parameters<Type["toRdfExpression"]>[0]): string;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ListType.d.ts.map
|