@shaclmate/compiler 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/Compiler.d.ts +15 -0
- package/Compiler.js +20 -0
- package/ShapesGraphToAstTransformer.d.ts +18 -23
- package/ShapesGraphToAstTransformer.js +21 -447
- package/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +3 -0
- package/_ShapesGraphToAstTransformer/NodeShapeAstType.js +2 -0
- package/_ShapesGraphToAstTransformer/index.d.ts +10 -0
- package/_ShapesGraphToAstTransformer/index.js +10 -0
- package/_ShapesGraphToAstTransformer/pickLiteral.d.ts +4 -0
- package/_ShapesGraphToAstTransformer/pickLiteral.js +18 -0
- package/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.d.ts +4 -0
- package/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.js +26 -0
- package/_ShapesGraphToAstTransformer/shapeAstName.d.ts +5 -0
- package/_ShapesGraphToAstTransformer/shapeAstName.js +28 -0
- package/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +6 -0
- package/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +165 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +13 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +198 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +12 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +29 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +12 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +43 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +6 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +31 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +14 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +21 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +16 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +58 -0
- package/ast/Ast.d.ts +5 -0
- package/ast/CompositeType.d.ts +13 -0
- package/ast/CompositeType.js +2 -0
- package/ast/IdentifierType.d.ts +3 -6
- package/ast/IntersectionType.d.ts +2 -2
- package/ast/ListType.d.ts +53 -0
- package/ast/ListType.js +2 -0
- package/ast/LiteralType.d.ts +4 -3
- package/ast/Name.d.ts +1 -0
- package/ast/ObjectCompositeType.d.ts +22 -0
- package/ast/ObjectCompositeType.js +2 -0
- package/ast/ObjectIntersectionType.d.ts +8 -0
- package/ast/ObjectIntersectionType.js +2 -0
- package/ast/ObjectType.d.ts +91 -19
- package/ast/ObjectType.js +26 -1
- package/ast/ObjectUnionType.d.ts +19 -0
- package/ast/ObjectUnionType.js +2 -0
- package/ast/PlaceholderType.d.ts +7 -0
- package/ast/PlaceholderType.js +2 -0
- package/ast/SetType.d.ts +1 -1
- package/ast/TermType.d.ts +11 -0
- package/ast/TermType.js +2 -0
- package/ast/Type.d.ts +11 -3
- package/ast/UnionType.d.ts +3 -3
- package/ast/index.d.ts +6 -3
- package/ast/index.js +6 -3
- package/enums/MintingStrategy.d.ts +5 -0
- package/enums/MintingStrategy.js +2 -0
- package/enums/PropertyVisibility.d.ts +2 -0
- package/enums/PropertyVisibility.js +2 -0
- package/enums/TsFeature.d.ts +5 -0
- package/enums/TsFeature.js +16 -0
- package/enums/TsObjectDeclarationType.d.ts +5 -0
- package/enums/TsObjectDeclarationType.js +2 -0
- package/enums/index.d.ts +5 -0
- package/enums/index.js +5 -0
- package/generators/Generator.d.ts +5 -0
- package/generators/Generator.js +2 -0
- package/generators/index.d.ts +2 -2
- package/generators/index.js +2 -2
- package/generators/json/AstJsonGenerator.d.ts +4 -5
- package/generators/json/AstJsonGenerator.js +31 -22
- package/generators/ts/BooleanType.d.ts +7 -3
- package/generators/ts/BooleanType.js +58 -4
- package/generators/ts/DateTimeType.d.ts +17 -0
- package/generators/ts/DateTimeType.js +58 -0
- package/generators/ts/DeclaredType.d.ts +17 -0
- package/generators/ts/DeclaredType.js +10 -0
- package/generators/ts/IdentifierType.d.ts +7 -17
- package/generators/ts/IdentifierType.js +69 -60
- package/generators/ts/Import.d.ts +18 -0
- package/generators/ts/Import.js +59 -0
- package/generators/ts/ListType.d.ts +18 -8
- package/generators/ts/ListType.js +197 -43
- package/generators/ts/LiteralType.d.ts +13 -11
- package/generators/ts/LiteralType.js +36 -51
- package/generators/ts/NumberType.d.ts +7 -3
- package/generators/ts/NumberType.js +55 -4
- package/generators/ts/ObjectType.d.ts +47 -25
- package/generators/ts/ObjectType.js +222 -49
- package/generators/ts/ObjectUnionType.d.ts +58 -0
- package/generators/ts/ObjectUnionType.js +481 -0
- package/generators/ts/OptionType.d.ts +12 -4
- package/generators/ts/OptionType.js +65 -16
- package/generators/ts/PrimitiveType.d.ts +15 -5
- package/generators/ts/PrimitiveType.js +20 -29
- package/generators/ts/SetType.d.ts +12 -4
- package/generators/ts/SetType.js +103 -29
- package/generators/ts/StringType.d.ts +8 -3
- package/generators/ts/StringType.js +57 -3
- package/generators/ts/TermType.d.ts +52 -0
- package/generators/ts/TermType.js +234 -0
- package/generators/ts/TsGenerator.d.ts +4 -12
- package/generators/ts/TsGenerator.js +44 -100
- package/generators/ts/Type.d.ts +107 -46
- package/generators/ts/Type.js +78 -61
- package/generators/ts/TypeFactory.d.ts +4 -5
- package/generators/ts/TypeFactory.js +212 -89
- package/generators/ts/UnionType.d.ts +19 -6
- package/generators/ts/UnionType.js +230 -120
- package/generators/ts/_ObjectType/IdentifierProperty.d.ts +27 -7
- package/generators/ts/_ObjectType/IdentifierProperty.js +143 -31
- package/generators/ts/_ObjectType/Property.d.ts +125 -9
- package/generators/ts/_ObjectType/Property.js +25 -3
- package/generators/ts/_ObjectType/ShaclProperty.d.ts +23 -5
- package/generators/ts/_ObjectType/ShaclProperty.js +100 -26
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +24 -6
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +75 -13
- package/generators/ts/_ObjectType/classDeclaration.d.ts +2 -1
- package/generators/ts/_ObjectType/classDeclaration.js +79 -111
- package/generators/ts/_ObjectType/createFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/createFunctionDeclaration.js +60 -0
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.d.ts +2 -1
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.js +12 -20
- package/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.d.ts +11 -0
- package/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +70 -0
- package/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +78 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +91 -0
- package/generators/ts/_ObjectType/hashFunctionDeclaration.d.ts +3 -3
- package/generators/ts/_ObjectType/hashFunctionDeclaration.js +11 -55
- package/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.d.ts +11 -0
- package/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.js +64 -0
- package/generators/ts/_ObjectType/index.d.ts +8 -2
- package/generators/ts/_ObjectType/index.js +8 -2
- package/generators/ts/_ObjectType/interfaceDeclaration.d.ts +3 -2
- package/generators/ts/_ObjectType/interfaceDeclaration.js +11 -2
- package/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +19 -0
- package/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +31 -0
- package/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +37 -0
- package/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +6 -0
- package/generators/ts/{rdfjsTermExpression.js → _ObjectType/rdfjsTermExpression.js} +3 -1
- package/generators/ts/_ObjectType/sparqlFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +101 -0
- package/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +19 -0
- package/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.d.ts +10 -0
- package/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +59 -0
- package/generators/ts/_ObjectType/toJsonReturnType.d.ts +3 -0
- package/generators/ts/_ObjectType/toJsonReturnType.js +19 -0
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +3 -2
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +11 -45
- package/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.d.ts +10 -0
- package/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +67 -0
- package/generators/ts/objectInitializer.d.ts +2 -0
- package/generators/ts/objectInitializer.js +14 -0
- package/generators/ts/tsComment.d.ts +5 -0
- package/generators/ts/tsComment.js +11 -0
- package/generators/ts/tsName.d.ts +1 -1
- package/generators/ts/tsName.js +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/input/NodeShape.d.ts +46 -0
- package/input/NodeShape.js +165 -0
- package/input/Ontology.d.ts +13 -0
- package/input/Ontology.js +30 -0
- package/input/PropertyShape.d.ts +15 -0
- package/input/PropertyShape.js +34 -0
- package/input/Shape.d.ts +4 -0
- package/input/Shape.js +2 -0
- package/input/ShapesGraph.d.ts +9 -0
- package/input/ShapesGraph.js +50 -0
- package/input/ancestorClassIris.d.ts +4 -0
- package/input/ancestorClassIris.js +21 -0
- package/input/descendantClassIris.d.ts +4 -0
- package/input/descendantClassIris.js +21 -0
- package/input/generated.d.ts +274 -0
- package/input/generated.js +1420 -0
- package/input/index.d.ts +7 -0
- package/input/index.js +7 -0
- package/input/tsFeatures.d.ts +10 -0
- package/input/tsFeatures.js +42 -0
- package/package.json +14 -8
- package/ast/MintingStrategy.d.ts +0 -8
- package/ast/MintingStrategy.js +0 -9
- package/generators/ts/Configuration.d.ts +0 -29
- package/generators/ts/Configuration.js +0 -40
- package/generators/ts/IntersectionType.d.ts +0 -14
- package/generators/ts/IntersectionType.js +0 -26
- package/generators/ts/RdfjsTermType.d.ts +0 -25
- package/generators/ts/RdfjsTermType.js +0 -46
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.d.ts +0 -4
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.js +0 -72
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.d.ts +0 -4
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.js +0 -46
- package/generators/ts/rdfjsTermExpression.d.ts +0 -5
- package/vocabularies/dashDataset.d.ts +0 -3
- package/vocabularies/dashDataset.js +0 -2370
- package/vocabularies/index.d.ts +0 -2
- package/vocabularies/index.js +0 -2
- package/vocabularies/shaclmate.d.ts +0 -15
- package/vocabularies/shaclmate.js +0 -6
package/input/index.d.ts
ADDED
package/input/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type * as rdfjs from "@rdfjs/types";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { TsFeature } from "../enums/index.js";
|
|
4
|
+
type TsFeatureIri = rdfjs.NamedNode<"http://minorg.github.io/shaclmate/ns#_TsFeature_Create" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Equals" | "http://minorg.github.io/shaclmate/ns#_TsFeature_FromJson" | "http://minorg.github.io/shaclmate/ns#_TsFeature_FromRdf" | "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonSchema" | "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonUiSchema" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Hash" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Sparql" | "http://minorg.github.io/shaclmate/ns#_TsFeature_ToJson" | "http://minorg.github.io/shaclmate/ns#_TsFeature_ToRdf">;
|
|
5
|
+
export declare function tsFeatures(generated: {
|
|
6
|
+
readonly tsFeatureExcludes: readonly TsFeatureIri[];
|
|
7
|
+
readonly tsFeatureIncludes: readonly TsFeatureIri[];
|
|
8
|
+
}): Maybe<Set<TsFeature>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=tsFeatures.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { TsFeature } from "../enums/index.js";
|
|
3
|
+
function iriToTsFeature(iri) {
|
|
4
|
+
switch (iri.value) {
|
|
5
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_Create":
|
|
6
|
+
return "create";
|
|
7
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_Equals":
|
|
8
|
+
return "equals";
|
|
9
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_FromJson":
|
|
10
|
+
return "fromJson";
|
|
11
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_FromRdf":
|
|
12
|
+
return "fromRdf";
|
|
13
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_Hash":
|
|
14
|
+
return "hash";
|
|
15
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonSchema":
|
|
16
|
+
return "jsonSchema";
|
|
17
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonUiSchema":
|
|
18
|
+
return "jsonUiSchema";
|
|
19
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_Sparql":
|
|
20
|
+
return "sparql";
|
|
21
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_ToJson":
|
|
22
|
+
return "toJson";
|
|
23
|
+
case "http://minorg.github.io/shaclmate/ns#_TsFeature_ToRdf":
|
|
24
|
+
return "toRdf";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function tsFeatures(generated) {
|
|
28
|
+
const tsFeatureIncludes = generated.tsFeatureIncludes.map(iriToTsFeature);
|
|
29
|
+
const tsFeatureExcludes = generated.tsFeatureExcludes.map(iriToTsFeature);
|
|
30
|
+
if (tsFeatureIncludes.length > 0) {
|
|
31
|
+
return Maybe.of(new Set(tsFeatureIncludes));
|
|
32
|
+
}
|
|
33
|
+
if (tsFeatureExcludes.length > 0) {
|
|
34
|
+
const tsFeatures = new Set(TsFeature.MEMBERS);
|
|
35
|
+
for (const tsFeatureExclude of tsFeatureExcludes) {
|
|
36
|
+
tsFeatures.delete(tsFeatureExclude);
|
|
37
|
+
}
|
|
38
|
+
return Maybe.of(tsFeatures);
|
|
39
|
+
}
|
|
40
|
+
return Maybe.empty();
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=tsFeatures.js.map
|
package/package.json
CHANGED
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@shaclmate/shacl-ast": "2.0.
|
|
3
|
+
"@shaclmate/shacl-ast": "2.0.14",
|
|
4
4
|
"@rdfjs/prefix-map": "^0.1.2",
|
|
5
5
|
"@rdfjs/term-map": "^2.0.2",
|
|
6
6
|
"@rdfjs/term-set": "^2.0.3",
|
|
7
7
|
"@rdfjs/types": "^1.1.0",
|
|
8
8
|
"@sindresorhus/base62": "^0.1.0",
|
|
9
9
|
"@tpluscode/rdf-ns-builders": "^4.3.0",
|
|
10
|
-
"@types/n3": "^1.21.1",
|
|
11
10
|
"@types/rdfjs__prefix-map": "^0.1.5",
|
|
12
11
|
"@types/rdfjs__term-map": "^2.0.10",
|
|
13
12
|
"@types/rdfjs__term-set": "^2.0.9",
|
|
13
|
+
"@types/toposort": "2.0.7",
|
|
14
14
|
"change-case": "^5.4.4",
|
|
15
|
-
"n3": "^1.21.3",
|
|
16
15
|
"pino": "^9.1.0",
|
|
17
16
|
"reserved-identifiers": "^1.0.0",
|
|
17
|
+
"toposort": "2.0.2",
|
|
18
18
|
"ts-invariant": "^0.10.3",
|
|
19
19
|
"ts-morph": "^24.0.0",
|
|
20
20
|
"typescript-memoize": "^1.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@shaclmate/runtime": "2.0.
|
|
23
|
+
"@shaclmate/runtime": "2.0.14",
|
|
24
|
+
"oxigraph": "^0.4.0"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
26
27
|
"*.d.ts",
|
|
27
28
|
"*.js",
|
|
29
|
+
"_ShapesGraphToAstTransformer/*.d.ts",
|
|
30
|
+
"_ShapesGraphToAstTransformer/*.js",
|
|
28
31
|
"ast/*.d.ts",
|
|
29
32
|
"ast/*.js",
|
|
33
|
+
"enums/*.d.ts",
|
|
34
|
+
"enums/*.js",
|
|
30
35
|
"generators/*.d.ts",
|
|
31
36
|
"generators/*.js",
|
|
32
37
|
"generators/json/*.d.ts",
|
|
@@ -35,8 +40,8 @@
|
|
|
35
40
|
"generators/ts/*.js",
|
|
36
41
|
"generators/ts/_ObjectType/*.d.ts",
|
|
37
42
|
"generators/ts/_ObjectType/*.js",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
43
|
+
"input/*.d.ts",
|
|
44
|
+
"input/*.js"
|
|
40
45
|
],
|
|
41
46
|
"main": "index.js",
|
|
42
47
|
"license": "Apache-2.0",
|
|
@@ -59,7 +64,8 @@
|
|
|
59
64
|
"test:coverage": "biome check && vitest run --coverage",
|
|
60
65
|
"test:watch": "vitest watch",
|
|
61
66
|
"unlink": "npm unlink -g @shaclmate/compiler",
|
|
62
|
-
"watch": "tsc -w --preserveWatchOutput"
|
|
67
|
+
"watch": "tsc -w --preserveWatchOutput",
|
|
68
|
+
"watch:noEmit": "tsc --noEmit -w --preserveWatchOutput"
|
|
63
69
|
},
|
|
64
70
|
"repository": {
|
|
65
71
|
"type": "git",
|
|
@@ -67,5 +73,5 @@
|
|
|
67
73
|
},
|
|
68
74
|
"type": "module",
|
|
69
75
|
"types": "index.d.ts",
|
|
70
|
-
"version": "2.0.
|
|
76
|
+
"version": "2.0.14"
|
|
71
77
|
}
|
package/ast/MintingStrategy.d.ts
DELETED
package/ast/MintingStrategy.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TypeScript enum corresponding to shaclmate:mintingStrategy, for simpler manipulation.
|
|
3
|
-
*/
|
|
4
|
-
export var MintingStrategy;
|
|
5
|
-
(function (MintingStrategy) {
|
|
6
|
-
MintingStrategy[MintingStrategy["SHA256"] = 1] = "SHA256";
|
|
7
|
-
MintingStrategy[MintingStrategy["UUIDv4"] = 2] = "UUIDv4";
|
|
8
|
-
})(MintingStrategy || (MintingStrategy = {}));
|
|
9
|
-
//# sourceMappingURL=MintingStrategy.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
|
|
2
|
-
import type { Maybe } from "purify-ts";
|
|
3
|
-
import { Type } from "./Type.js";
|
|
4
|
-
/**
|
|
5
|
-
* Abstract base class for IdentifierType and LiteralType.
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class RdfjsTermType<RdfjsTermT extends BlankNode | Literal | NamedNode> extends Type {
|
|
8
|
-
readonly defaultValue: Maybe<RdfjsTermT>;
|
|
9
|
-
readonly hasValue: Maybe<RdfjsTermT>;
|
|
10
|
-
abstract readonly kind: "IdentifierType" | "LiteralType";
|
|
11
|
-
constructor({ defaultValue, hasValue, ...superParameters }: {
|
|
12
|
-
defaultValue: Maybe<RdfjsTermT>;
|
|
13
|
-
hasValue: Maybe<RdfjsTermT>;
|
|
14
|
-
} & ConstructorParameters<typeof Type>[0]);
|
|
15
|
-
equalsFunction(): string;
|
|
16
|
-
fromRdfExpression({ variables, }: Parameters<Type["fromRdfExpression"]>[0]): string;
|
|
17
|
-
propertySparqlGraphPatternExpression({ variables, }: Parameters<Type["propertySparqlGraphPatternExpression"]>[0]): Type.SparqlGraphPatternExpression;
|
|
18
|
-
toRdfExpression({ variables, }: Parameters<Type["toRdfExpression"]>[0]): string;
|
|
19
|
-
protected abstract fromRdfResourceValueExpression({ variables, }: {
|
|
20
|
-
variables: {
|
|
21
|
-
resourceValue: string;
|
|
22
|
-
};
|
|
23
|
-
}): string;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=RdfjsTermType.d.ts.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { Type } from "./Type.js";
|
|
2
|
-
import { rdfjsTermExpression } from "./rdfjsTermExpression";
|
|
3
|
-
/**
|
|
4
|
-
* Abstract base class for IdentifierType and LiteralType.
|
|
5
|
-
*/
|
|
6
|
-
export class RdfjsTermType extends Type {
|
|
7
|
-
constructor({ defaultValue, hasValue, ...superParameters }) {
|
|
8
|
-
super(superParameters);
|
|
9
|
-
this.defaultValue = defaultValue;
|
|
10
|
-
this.hasValue = hasValue;
|
|
11
|
-
}
|
|
12
|
-
equalsFunction() {
|
|
13
|
-
return "purifyHelpers.Equatable.booleanEquals";
|
|
14
|
-
}
|
|
15
|
-
fromRdfExpression({ variables, }) {
|
|
16
|
-
const chain = [`${variables.resourceValues}.head()`];
|
|
17
|
-
this.hasValue.ifJust((hasValue) => {
|
|
18
|
-
chain.push(`chain<rdfjsResource.Resource.ValueError, ${this.name}>(_identifier => _identifier.equals(${rdfjsTermExpression(hasValue, this.configuration)}) ? purify.Either.of(_identifier) : purify.Left(new rdfjsResource.Resource.MistypedValueError({ actualValue: _identifier, expectedValueType: "${hasValue.termType}", focusResource: ${variables.resource}, predicate: ${variables.predicate})))`);
|
|
19
|
-
});
|
|
20
|
-
this.defaultValue.ifJust((defaultValue) => {
|
|
21
|
-
chain.push(`alt(purify.Either.of(new rdfjsResource.Resource.Value({ subject: ${variables.resource}, predicate: ${variables.predicate}, object: ${rdfjsTermExpression(defaultValue, this.configuration)} })))`);
|
|
22
|
-
});
|
|
23
|
-
chain.push(`chain(value => ${this.fromRdfResourceValueExpression({
|
|
24
|
-
variables: { resourceValue: "value" },
|
|
25
|
-
})})`);
|
|
26
|
-
return chain.join(".");
|
|
27
|
-
}
|
|
28
|
-
propertySparqlGraphPatternExpression({ variables, }) {
|
|
29
|
-
let expression = super
|
|
30
|
-
.propertySparqlGraphPatternExpression({
|
|
31
|
-
variables,
|
|
32
|
-
})
|
|
33
|
-
.toSparqlGraphPatternExpression()
|
|
34
|
-
.toString();
|
|
35
|
-
if (this.defaultValue.isJust()) {
|
|
36
|
-
expression = `sparqlBuilder.GraphPattern.optional(${expression})`;
|
|
37
|
-
}
|
|
38
|
-
return new Type.SparqlGraphPatternExpression(expression);
|
|
39
|
-
}
|
|
40
|
-
toRdfExpression({ variables, }) {
|
|
41
|
-
return this.defaultValue
|
|
42
|
-
.map((defaultValue) => `!${variables.value}.equals(${rdfjsTermExpression(defaultValue, this.configuration)}) ? ${variables.value} : undefined`)
|
|
43
|
-
.orDefault(variables.value);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=RdfjsTermType.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type FunctionDeclarationStructure } from "ts-morph";
|
|
2
|
-
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
-
export declare function fromRdfFunctionDeclaration(this: ObjectType): FunctionDeclarationStructure;
|
|
4
|
-
//# sourceMappingURL=fromRdfFunctionDeclaration.d.ts.map
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { StructureKind } from "ts-morph";
|
|
2
|
-
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
3
|
-
const variables = {
|
|
4
|
-
ignoreRdfType: "ignoreRdfType",
|
|
5
|
-
options: "_options",
|
|
6
|
-
resource: "resource",
|
|
7
|
-
};
|
|
8
|
-
export function fromRdfFunctionDeclaration() {
|
|
9
|
-
this.ensureAtMostOneSuperObjectType();
|
|
10
|
-
const propertiesByName = {};
|
|
11
|
-
let statements = [];
|
|
12
|
-
this.rdfType.ifJust((rdfType) => {
|
|
13
|
-
statements.push(`if (!${variables.options}?.${variables.ignoreRdfType} && !${variables.resource}.isInstanceOf(${rdfjsTermExpression(rdfType, this.configuration)})) { return purify.Left(new rdfjsResource.Resource.ValueError({ focusResource: ${variables.resource}, message: \`\${rdfjsResource.Resource.Identifier.toString(${variables.resource}.identifier)} has unexpected RDF type\`, predicate: ${rdfjsTermExpression(rdfType, this.configuration)} })); }`);
|
|
14
|
-
});
|
|
15
|
-
for (const ancestorObjectType of this.ancestorObjectTypes) {
|
|
16
|
-
for (const property of ancestorObjectType.properties) {
|
|
17
|
-
if (property.fromRdfStatements({ variables }).length > 0) {
|
|
18
|
-
propertiesByName[property.name] = {
|
|
19
|
-
initializer: `_super.${property.name}`,
|
|
20
|
-
type: property.type.name,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
for (const property of this.properties) {
|
|
26
|
-
const propertyFromRdfStatements = property.fromRdfStatements({
|
|
27
|
-
variables,
|
|
28
|
-
});
|
|
29
|
-
if (propertyFromRdfStatements.length > 0) {
|
|
30
|
-
propertiesByName[property.name] = {
|
|
31
|
-
type: property.type.name,
|
|
32
|
-
};
|
|
33
|
-
statements.push(...propertyFromRdfStatements);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
let construction = `{ ${Object.entries(propertiesByName)
|
|
37
|
-
.map(([name, { initializer }]) => initializer ? `${name}: ${initializer}` : name)
|
|
38
|
-
.join(", ")} }`;
|
|
39
|
-
let returnType = `{ ${Object.entries(propertiesByName)
|
|
40
|
-
.map(([name, { type }]) => `${name}: ${type}`)
|
|
41
|
-
.join(", ")} }`;
|
|
42
|
-
if (this.configuration.objectTypeDeclarationType === "class" &&
|
|
43
|
-
!this.abstract) {
|
|
44
|
-
construction = `new ${this.name}(${construction})`;
|
|
45
|
-
returnType = this.name;
|
|
46
|
-
}
|
|
47
|
-
statements.push(`return purify.Either.of(${construction})`);
|
|
48
|
-
if (this.parentObjectTypes.length > 0) {
|
|
49
|
-
statements = [
|
|
50
|
-
`return ${this.parentObjectTypes[0].name}.fromRdf(${variables.resource}, { ${variables.ignoreRdfType}: true }).chain(_super => { ${statements.join("\n")} })`,
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
isExported: true,
|
|
55
|
-
kind: StructureKind.Function,
|
|
56
|
-
name: "fromRdf",
|
|
57
|
-
parameters: [
|
|
58
|
-
{
|
|
59
|
-
name: variables.resource,
|
|
60
|
-
type: this.rdfjsResourceType().name,
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
hasQuestionToken: true,
|
|
64
|
-
name: variables.options,
|
|
65
|
-
type: `{ ${variables.ignoreRdfType}?: boolean }`,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
returnType: `purify.Either<rdfjsResource.Resource.ValueError, ${returnType}>`,
|
|
69
|
-
statements,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=fromRdfFunctionDeclaration.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type ClassDeclarationStructure } from "ts-morph";
|
|
2
|
-
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
-
export declare function sparqlGraphPatternsClassDeclaration(this: ObjectType): ClassDeclarationStructure;
|
|
4
|
-
//# sourceMappingURL=sparqlGraphPatternsClassDeclaration.d.ts.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { StructureKind } from "ts-morph";
|
|
2
|
-
import { rdfjsTermExpression } from "../rdfjsTermExpression";
|
|
3
|
-
const ignoreRdfTypeVariable = "ignoreRdfType";
|
|
4
|
-
const optionsVariable = "_options";
|
|
5
|
-
const subjectVariable = "subject";
|
|
6
|
-
export function sparqlGraphPatternsClassDeclaration() {
|
|
7
|
-
this.ensureAtMostOneSuperObjectType();
|
|
8
|
-
const constructorStatements = [];
|
|
9
|
-
if (this.parentObjectTypes.length > 0) {
|
|
10
|
-
constructorStatements.push(`super(${subjectVariable}, { ignoreRdfType: true });`);
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
constructorStatements.push(`super(${subjectVariable});`);
|
|
14
|
-
}
|
|
15
|
-
this.rdfType.ifJust((rdfType) => constructorStatements.push(`if (!${optionsVariable}?.${ignoreRdfTypeVariable}) { this.add(...new sparqlBuilder.RdfTypeGraphPatterns(${subjectVariable}, ${rdfjsTermExpression(rdfType, this.configuration)})); }`));
|
|
16
|
-
for (const property of this.properties) {
|
|
17
|
-
property
|
|
18
|
-
.sparqlGraphPatternExpression()
|
|
19
|
-
.ifJust((sparqlGraphPattern) => constructorStatements.push(`this.add(${sparqlGraphPattern});`));
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
ctors: [
|
|
23
|
-
{
|
|
24
|
-
parameters: [
|
|
25
|
-
{
|
|
26
|
-
name: subjectVariable,
|
|
27
|
-
type: "sparqlBuilder.ResourceGraphPatterns.SubjectParameter",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
hasQuestionToken: true,
|
|
31
|
-
name: optionsVariable,
|
|
32
|
-
type: `{ ${ignoreRdfTypeVariable}?: boolean }`,
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
statements: constructorStatements,
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
extends: this.parentObjectTypes.length > 0
|
|
39
|
-
? `${this.parentObjectTypes[0].name}.SparqlGraphPatterns`
|
|
40
|
-
: "sparqlBuilder.ResourceGraphPatterns",
|
|
41
|
-
isExported: true,
|
|
42
|
-
kind: StructureKind.Class,
|
|
43
|
-
name: "SparqlGraphPatterns",
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=sparqlGraphPatternsClassDeclaration.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
|
|
2
|
-
export declare function rdfjsTermExpression(rdfjsTerm: BlankNode | Literal | NamedNode, { dataFactoryVariable }: {
|
|
3
|
-
dataFactoryVariable: string;
|
|
4
|
-
}): string;
|
|
5
|
-
//# sourceMappingURL=rdfjsTermExpression.d.ts.map
|