@shaclmate/compiler 2.0.22 → 2.0.23
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/ShapesGraphToAstTransformer.d.ts +1 -0
- package/dist/ShapesGraphToAstTransformer.js +56 -12
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +2 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +122 -129
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +2 -2
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +2 -2
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +127 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +3 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +2 -3
- package/dist/ast/Ast.d.ts +0 -1
- package/dist/ast/Curie.d.ts +14 -0
- package/dist/ast/Curie.js +21 -0
- package/dist/ast/IdentifierType.d.ts +3 -2
- package/dist/ast/ListType.d.ts +2 -1
- package/dist/ast/LiteralType.d.ts +1 -1
- package/dist/ast/Name.d.ts +40 -5
- package/dist/ast/ObjectCompositeType.d.ts +11 -0
- package/dist/ast/ObjectType.d.ts +18 -13
- package/dist/ast/ObjectUnionType.d.ts +0 -11
- package/dist/ast/OptionType.d.ts +2 -2
- package/dist/ast/SetType.d.ts +2 -2
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +19 -3
- package/dist/generators/ts/BooleanType.d.ts +3 -1
- package/dist/generators/ts/BooleanType.js +11 -2
- package/dist/generators/ts/DateTimeType.d.ts +8 -7
- package/dist/generators/ts/DateTimeType.js +31 -7
- package/dist/generators/ts/DateType.d.ts +5 -2
- package/dist/generators/ts/DateType.js +15 -1
- package/dist/generators/ts/DeclaredType.d.ts +2 -2
- package/dist/generators/ts/DeclaredType.js +2 -2
- package/dist/generators/ts/FloatType.d.ts +6 -0
- package/dist/generators/ts/FloatType.js +18 -0
- package/dist/generators/ts/IdentifierType.d.ts +12 -7
- package/dist/generators/ts/IdentifierType.js +94 -6
- package/dist/generators/ts/Import.d.ts +2 -0
- package/dist/generators/ts/Import.js +10 -0
- package/dist/generators/ts/IntType.d.ts +6 -0
- package/dist/generators/ts/IntType.js +18 -0
- package/dist/generators/ts/ListType.d.ts +15 -12
- package/dist/generators/ts/ListType.js +98 -57
- package/dist/generators/ts/LiteralType.d.ts +10 -9
- package/dist/generators/ts/LiteralType.js +13 -2
- package/dist/generators/ts/NumberType.d.ts +2 -1
- package/dist/generators/ts/NumberType.js +7 -2
- package/dist/generators/ts/ObjectType.d.ts +66 -43
- package/dist/generators/ts/ObjectType.js +144 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +49 -8
- package/dist/generators/ts/ObjectUnionType.js +290 -97
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +60 -34
- package/dist/generators/ts/PrimitiveType.d.ts +4 -4
- package/dist/generators/ts/PrimitiveType.js +18 -3
- package/dist/generators/ts/SetType.d.ts +16 -12
- package/dist/generators/ts/SetType.js +69 -40
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +215 -101
- package/dist/generators/ts/StringType.d.ts +3 -1
- package/dist/generators/ts/StringType.js +14 -2
- package/dist/generators/ts/TermType.d.ts +22 -14
- package/dist/generators/ts/TermType.js +53 -25
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +23 -12
- package/dist/generators/ts/Type.d.ts +89 -31
- package/dist/generators/ts/Type.js +57 -54
- package/dist/generators/ts/TypeFactory.d.ts +4 -5
- package/dist/generators/ts/TypeFactory.js +290 -226
- package/dist/generators/ts/UnionType.d.ts +14 -10
- package/dist/generators/ts/UnionType.js +319 -142
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +30 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +46 -47
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +152 -124
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +87 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +237 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +39 -44
- package/dist/generators/ts/_ObjectType/Property.js +1 -10
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +108 -85
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
- package/dist/generators/ts/_ObjectType/classDeclaration.js +6 -5
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +5 -4
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +5 -4
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +37 -0
- package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
- package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
- package/dist/generators/ts/_ObjectType/index.js +9 -7
- package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +152 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +3 -2
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +103 -35
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +15 -13
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
- package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
- package/dist/generators/ts/objectSetDeclarations.js +59 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
- package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
- package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
- package/dist/generators/ts/rdfjsTermExpression.js +57 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
- package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
- package/dist/generators/ts/syntheticNamePrefix.js +2 -0
- package/dist/generators/ts/tsName.js +27 -13
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
- package/dist/input/NodeShape.d.ts +6 -8
- package/dist/input/NodeShape.js +20 -44
- package/dist/input/Ontology.d.ts +0 -3
- package/dist/input/Ontology.js +0 -9
- package/dist/input/PropertyPath.d.ts +6 -5
- package/dist/input/PropertyPath.js +14 -22
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -4
- package/dist/input/generated.d.ts +923 -105
- package/dist/input/generated.js +1865 -969
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
- package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
1
|
import { invariant } from "ts-invariant";
|
|
3
|
-
import { rdfjsTermExpression } from "./_ObjectType/rdfjsTermExpression.js";
|
|
4
2
|
import { objectInitializer } from "./objectInitializer.js";
|
|
5
3
|
/**
|
|
6
4
|
* Abstract base class for generating TypeScript expressions and statemenst in the TypeScript generator.
|
|
@@ -8,46 +6,19 @@ import { objectInitializer } from "./objectInitializer.js";
|
|
|
8
6
|
* Subclasses are used for both property types (c.f., property* methods) and node/object types.
|
|
9
7
|
*/
|
|
10
8
|
export class Type {
|
|
11
|
-
dataFactoryVariable;
|
|
12
|
-
constructor({ dataFactoryVariable, }) {
|
|
13
|
-
this.dataFactoryVariable = dataFactoryVariable;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* A property that discriminates sub-types of this type e.g., termType on RDF/JS terms.
|
|
17
|
-
*/
|
|
18
|
-
get discriminatorProperty() {
|
|
19
|
-
return Maybe.empty();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Element object for a JSON Forms UI schema.
|
|
23
|
-
*/
|
|
24
|
-
jsonUiSchemaElement(_parameters) {
|
|
25
|
-
return Maybe.empty();
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Reusable function, type, and other declarations that are not particular to this type but that type-specific code
|
|
29
|
-
* relies on. For example, the equals function/method of ObjectType has a custom return type that's the same across all
|
|
30
|
-
* ObjectType's. Instead of re-declaring the return type anonymously on every equals function, declare a named type
|
|
31
|
-
* as a snippet and reference it.
|
|
32
|
-
*
|
|
33
|
-
* The generator deduplicates snippet declarations across all types before adding them to the source.
|
|
34
|
-
*/
|
|
35
|
-
snippetDeclarations(_features) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
9
|
/**
|
|
39
10
|
* An array of SPARQL.js CONSTRUCT template triples for a value of this type, as strings (so they can incorporate runtime calls).
|
|
40
11
|
*
|
|
41
12
|
* This method is called in two contexts:
|
|
42
|
-
* (1)
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* Term types with no additional
|
|
13
|
+
* (1) When an instance of the type is an "object" of a property.
|
|
14
|
+
* This method should return a BGP (variables.subject, variables.predicate, variables.object) and recursively call itself with the variables.object as a "subject" context.
|
|
15
|
+
* (2) When an instance of the type is a "subject".
|
|
16
|
+
* For example, ListType calls this method to with the item variable as a subject in order to chain additional patterns on items. Term types with no additional patterns should return an empty array.
|
|
46
17
|
*/
|
|
47
|
-
sparqlConstructTemplateTriples({ context, variables, }) {
|
|
18
|
+
sparqlConstructTemplateTriples({ allowIgnoreRdfType, context, variables, }) {
|
|
48
19
|
switch (context) {
|
|
49
|
-
case "
|
|
50
|
-
const objectPrefix =
|
|
20
|
+
case "object": {
|
|
21
|
+
const objectPrefix = "dataFactory.variable!(";
|
|
51
22
|
const objectSuffix = ")";
|
|
52
23
|
invariant(variables.object.startsWith(objectPrefix));
|
|
53
24
|
invariant(variables.object.endsWith(objectSuffix));
|
|
@@ -58,14 +29,15 @@ export class Type {
|
|
|
58
29
|
subject: variables.subject,
|
|
59
30
|
}),
|
|
60
31
|
].concat(this.sparqlConstructTemplateTriples({
|
|
61
|
-
|
|
32
|
+
allowIgnoreRdfType,
|
|
33
|
+
context: "subject",
|
|
62
34
|
variables: {
|
|
63
35
|
subject: variables.object,
|
|
64
36
|
variablePrefix: variables.object.substring(objectPrefix.length, variables.object.length - objectSuffix.length),
|
|
65
37
|
},
|
|
66
38
|
}));
|
|
67
39
|
}
|
|
68
|
-
case "
|
|
40
|
+
case "subject":
|
|
69
41
|
return [];
|
|
70
42
|
}
|
|
71
43
|
}
|
|
@@ -74,10 +46,10 @@ export class Type {
|
|
|
74
46
|
*
|
|
75
47
|
* See note in sparqlConstructTemplateTriples re: how this method is used.
|
|
76
48
|
*/
|
|
77
|
-
sparqlWherePatterns({ context, variables, }) {
|
|
49
|
+
sparqlWherePatterns({ allowIgnoreRdfType, context, variables, }) {
|
|
78
50
|
switch (context) {
|
|
79
|
-
case "
|
|
80
|
-
const objectPrefix =
|
|
51
|
+
case "object": {
|
|
52
|
+
const objectPrefix = "dataFactory.variable!(";
|
|
81
53
|
const objectSuffix = ")";
|
|
82
54
|
invariant(variables.object.startsWith(objectPrefix));
|
|
83
55
|
invariant(variables.object.endsWith(objectSuffix));
|
|
@@ -91,28 +63,59 @@ export class Type {
|
|
|
91
63
|
type: '"bgp"',
|
|
92
64
|
}),
|
|
93
65
|
].concat(this.sparqlWherePatterns({
|
|
94
|
-
|
|
66
|
+
allowIgnoreRdfType,
|
|
67
|
+
context: "subject",
|
|
95
68
|
variables: {
|
|
96
69
|
subject: variables.object,
|
|
97
70
|
variablePrefix: variables.object.substring(objectPrefix.length, variables.object.length - objectSuffix.length),
|
|
98
71
|
},
|
|
99
72
|
}));
|
|
100
73
|
}
|
|
101
|
-
case "
|
|
74
|
+
case "subject":
|
|
102
75
|
return [];
|
|
103
76
|
}
|
|
104
77
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
78
|
+
}
|
|
79
|
+
(function (Type) {
|
|
80
|
+
class JsonName {
|
|
81
|
+
/**
|
|
82
|
+
* Is the type optional in JSON? Equivalent to ? in TypeScript or | undefined.
|
|
83
|
+
*/
|
|
84
|
+
optional;
|
|
85
|
+
/**
|
|
86
|
+
* The name of the type when it's required i.e. -- so it should never include "| undefined".
|
|
87
|
+
*/
|
|
88
|
+
requiredName;
|
|
89
|
+
constructor(requiredName, parameters) {
|
|
90
|
+
this.optional = !!parameters?.optional;
|
|
91
|
+
this.requiredName = requiredName;
|
|
92
|
+
}
|
|
93
|
+
toString() {
|
|
94
|
+
return this.optional
|
|
95
|
+
? `(${this.requiredName}) | undefined`
|
|
96
|
+
: this.requiredName;
|
|
97
|
+
}
|
|
110
98
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
Type.JsonName = JsonName;
|
|
100
|
+
class GraphqlName {
|
|
101
|
+
/**
|
|
102
|
+
* Is the type nullable in GraphQL?
|
|
103
|
+
*/
|
|
104
|
+
nullable;
|
|
105
|
+
/**
|
|
106
|
+
* The name of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
|
|
107
|
+
*/
|
|
108
|
+
nullableName;
|
|
109
|
+
constructor(nullableName, parameters) {
|
|
110
|
+
this.nullable = !!parameters?.nullable;
|
|
111
|
+
this.nullableName = nullableName;
|
|
112
|
+
}
|
|
113
|
+
toString() {
|
|
114
|
+
return this.nullable
|
|
115
|
+
? this.nullableName
|
|
116
|
+
: `new graphql.GraphQLNonNull(${this.nullableName})`;
|
|
117
|
+
}
|
|
116
118
|
}
|
|
117
|
-
|
|
119
|
+
Type.GraphqlName = GraphqlName;
|
|
120
|
+
})(Type || (Type = {}));
|
|
118
121
|
//# sourceMappingURL=Type.js.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type * as ast from "../../ast/index.js";
|
|
2
|
+
import { ObjectType } from "./ObjectType.js";
|
|
2
3
|
import type { Type } from "./Type.js";
|
|
3
4
|
export declare class TypeFactory {
|
|
4
5
|
private cachedObjectTypePropertiesByIdentifier;
|
|
5
6
|
private cachedObjectTypesByIdentifier;
|
|
6
|
-
private
|
|
7
|
-
|
|
8
|
-
dataFactoryVariable: string;
|
|
9
|
-
});
|
|
7
|
+
private cachedObjectUnionTypesByIdentifier;
|
|
8
|
+
createObjectTypeFromAstType(astType: ast.ObjectType): ObjectType;
|
|
10
9
|
createTypeFromAstType(astType: ast.Type): Type;
|
|
11
|
-
private createObjectTypeFromAstType;
|
|
12
10
|
private createObjectTypePropertyFromAstProperty;
|
|
11
|
+
private createObjectUnionTypeFromAstType;
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=TypeFactory.d.ts.map
|