@shaclmate/compiler 2.0.22 → 2.0.24
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 +6 -5
- package/dist/ShapesGraphToAstTransformer.js +61 -17
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +2 -0
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +2 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +15 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +5 -5
- package/dist/_ShapesGraphToAstTransformer/index.js +5 -5
- 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/transformPropertyShapeToAstObjectTypeProperty.js +175 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +185 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +32 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +46 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +12 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +24 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +14 -0
- 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 -4
- package/dist/ast/SetType.d.ts +2 -7
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +26 -4
- package/dist/generators/ts/BooleanType.d.ts +4 -2
- package/dist/generators/ts/BooleanType.js +12 -3
- package/dist/generators/ts/DateTimeType.d.ts +9 -8
- package/dist/generators/ts/DateTimeType.js +32 -8
- 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 +17 -7
- package/dist/generators/ts/IdentifierType.js +112 -18
- 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 +113 -61
- package/dist/generators/ts/LiteralType.d.ts +17 -9
- package/dist/generators/ts/LiteralType.js +92 -17
- package/dist/generators/ts/NumberType.d.ts +3 -2
- package/dist/generators/ts/NumberType.js +8 -3
- package/dist/generators/ts/ObjectType.d.ts +65 -43
- package/dist/generators/ts/ObjectType.js +143 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +50 -8
- package/dist/generators/ts/ObjectUnionType.js +303 -101
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +62 -34
- package/dist/generators/ts/PrimitiveType.d.ts +23 -5
- package/dist/generators/ts/PrimitiveType.js +34 -6
- package/dist/generators/ts/SetType.d.ts +17 -13
- package/dist/generators/ts/SetType.js +76 -44
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +226 -101
- package/dist/generators/ts/StringType.d.ts +4 -2
- package/dist/generators/ts/StringType.js +20 -8
- package/dist/generators/ts/TermType.d.ts +29 -33
- package/dist/generators/ts/TermType.js +89 -68
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +26 -12
- package/dist/generators/ts/Type.d.ts +100 -32
- package/dist/generators/ts/Type.js +58 -54
- package/dist/generators/ts/TypeFactory.d.ts +12 -5
- package/dist/generators/ts/TypeFactory.js +380 -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 +31 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +59 -46
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +198 -140
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +100 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +315 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +47 -46
- 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 +120 -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 +22 -17
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +26 -13
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +8 -5
- 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 +49 -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 +144 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +6 -5
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +109 -37
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +33 -24
- 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 +5 -5
- package/dist/input/PropertyPath.js +14 -24
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -8
- package/dist/input/generated.d.ts +967 -107
- package/dist/input/generated.js +2548 -1046
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +0 -13
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +0 -200
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +0 -29
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +0 -43
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +0 -14
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +0 -21
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +0 -60
- 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
|
@@ -0,0 +1,315 @@
|
|
|
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 "ts-morph";
|
|
9
|
+
import { Memoize } from "typescript-memoize";
|
|
10
|
+
import { invariant } from "ts-invariant";
|
|
11
|
+
import { Import } from "../Import.js";
|
|
12
|
+
import { SnippetDeclarations } from "../SnippetDeclarations.js";
|
|
13
|
+
import { Type as _Type } from "../Type.js";
|
|
14
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
15
|
+
import { ShaclProperty } from "./ShaclProperty.js";
|
|
16
|
+
function stubObjectUnionTypeToResolvedObjectUnionTypeSwitchStatement({ resolvedObjectUnionType, stubObjectUnionType, variables, }) {
|
|
17
|
+
invariant(resolvedObjectUnionType.memberTypes.length ===
|
|
18
|
+
stubObjectUnionType.memberTypes.length);
|
|
19
|
+
const caseBlocks = resolvedObjectUnionType.memberTypes.map((resolvedObjectType, objectTypeI) => {
|
|
20
|
+
return `${resolvedObjectType.discriminatorPropertyValues.map((discriminatorPropertyValue) => `case "${discriminatorPropertyValue}":`).join("\n")} return ${stubObjectUnionType.memberTypes[objectTypeI].newExpression({ parameters: variables.value })};`;
|
|
21
|
+
});
|
|
22
|
+
caseBlocks.push(`default: ${variables.value} satisfies never; throw new Error("unrecognized type");`);
|
|
23
|
+
return `switch (${variables.value}.${resolvedObjectUnionType.discriminatorProperty.unsafeCoerce().name}) { ${caseBlocks.join("\n")} }`;
|
|
24
|
+
}
|
|
25
|
+
export class LazyShaclProperty extends ShaclProperty {
|
|
26
|
+
mutable = false;
|
|
27
|
+
recursive = false;
|
|
28
|
+
get graphqlField() {
|
|
29
|
+
const args = this.type.graphqlArgs;
|
|
30
|
+
const argsVariable = args.isJust() ? "args" : "_args";
|
|
31
|
+
return Maybe.of({
|
|
32
|
+
args,
|
|
33
|
+
description: this.comment.map(JSON.stringify),
|
|
34
|
+
name: this.name,
|
|
35
|
+
resolve: `async (source, ${argsVariable}) => ${this.type.graphqlResolveExpression({ variables: { args: argsVariable, value: `source.${this.name}` } })}`,
|
|
36
|
+
type: this.type.graphqlName.toString(),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
__decorate([
|
|
41
|
+
Memoize()
|
|
42
|
+
], LazyShaclProperty.prototype, "graphqlField", null);
|
|
43
|
+
(function (LazyShaclProperty) {
|
|
44
|
+
class Type extends _Type {
|
|
45
|
+
discriminatorProperty = Maybe.empty();
|
|
46
|
+
mutable = false;
|
|
47
|
+
typeof = "object";
|
|
48
|
+
resolvedType;
|
|
49
|
+
runtimeClass;
|
|
50
|
+
stubType;
|
|
51
|
+
constructor({ stubType, resolvedType, runtimeClass, }) {
|
|
52
|
+
super();
|
|
53
|
+
this.stubType = stubType;
|
|
54
|
+
this.resolvedType = resolvedType;
|
|
55
|
+
this.runtimeClass = runtimeClass;
|
|
56
|
+
}
|
|
57
|
+
get conversions() {
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
conversionExpression: (value) => value,
|
|
61
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object" && ${value} instanceof ${this.runtimeClass.rawName}`,
|
|
62
|
+
sourceTypeName: this.name,
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
get equalsFunction() {
|
|
67
|
+
return `((left, right) => ${this.stubType.equalsFunction}(left.${this.runtimeClass.stubPropertyName}, right.${this.runtimeClass.stubPropertyName}))`;
|
|
68
|
+
}
|
|
69
|
+
get graphqlName() {
|
|
70
|
+
return this.resolvedType.graphqlName;
|
|
71
|
+
}
|
|
72
|
+
hashStatements({ depth, variables, }) {
|
|
73
|
+
return this.stubType.hashStatements({
|
|
74
|
+
depth: depth + 1,
|
|
75
|
+
variables: {
|
|
76
|
+
...variables,
|
|
77
|
+
value: `${variables.value}.${this.runtimeClass.stubPropertyName}`,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
get jsonName() {
|
|
82
|
+
return this.stubType.jsonName;
|
|
83
|
+
}
|
|
84
|
+
jsonUiSchemaElement(parameters) {
|
|
85
|
+
return this.stubType.jsonUiSchemaElement(parameters);
|
|
86
|
+
}
|
|
87
|
+
jsonZodSchema(parameters) {
|
|
88
|
+
return this.stubType.jsonZodSchema(parameters);
|
|
89
|
+
}
|
|
90
|
+
get name() {
|
|
91
|
+
return this.runtimeClass.name;
|
|
92
|
+
}
|
|
93
|
+
snippetDeclarations(parameters) {
|
|
94
|
+
return this.stubType
|
|
95
|
+
.snippetDeclarations(parameters)
|
|
96
|
+
.concat(this.resolvedType.snippetDeclarations(parameters))
|
|
97
|
+
.concat(this.runtimeClass.snippetDeclaration);
|
|
98
|
+
}
|
|
99
|
+
sparqlConstructTemplateTriples(parameters) {
|
|
100
|
+
return this.stubType.sparqlConstructTemplateTriples(parameters);
|
|
101
|
+
}
|
|
102
|
+
sparqlWherePatterns(parameters) {
|
|
103
|
+
return this.stubType.sparqlWherePatterns(parameters);
|
|
104
|
+
}
|
|
105
|
+
toJsonExpression({ variables, }) {
|
|
106
|
+
return this.stubType.toJsonExpression({
|
|
107
|
+
variables: {
|
|
108
|
+
value: `${variables.value}.${this.runtimeClass.stubPropertyName}`,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
toRdfExpression({ variables, }) {
|
|
113
|
+
return this.stubType.toRdfExpression({
|
|
114
|
+
variables: {
|
|
115
|
+
...variables,
|
|
116
|
+
value: `${variables.value}.${this.runtimeClass.stubPropertyName}`,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
useImports(parameters) {
|
|
121
|
+
return this.resolvedType.useImports(parameters).concat(Import.PURIFY);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
__decorate([
|
|
125
|
+
Memoize()
|
|
126
|
+
], Type.prototype, "equalsFunction", null);
|
|
127
|
+
LazyShaclProperty.Type = Type;
|
|
128
|
+
class ObjectSetType extends Type {
|
|
129
|
+
constructor({ resolvedType, stubType, }) {
|
|
130
|
+
super({
|
|
131
|
+
resolvedType,
|
|
132
|
+
runtimeClass: {
|
|
133
|
+
name: `${syntheticNamePrefix}LazyObjectSet<${resolvedType.itemType.identifierTypeAlias}, ${resolvedType.itemType.name}, ${stubType.itemType.name}>`,
|
|
134
|
+
rawName: `${syntheticNamePrefix}LazyObjectSet`,
|
|
135
|
+
snippetDeclaration: SnippetDeclarations.LazyObjectSet,
|
|
136
|
+
stubPropertyName: "stubs",
|
|
137
|
+
},
|
|
138
|
+
stubType,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
get conversions() {
|
|
142
|
+
const conversions = super.conversions.concat();
|
|
143
|
+
if (this.stubType.itemType.kind === "ObjectType") {
|
|
144
|
+
conversions.push({
|
|
145
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ${value}.map(object => ${this.stubType.itemType.newExpression({ parameters: "object" })}), resolver: async () => purify.Either.of(${value} as readonly ${this.resolvedType.itemType.name}[]) })`,
|
|
146
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
147
|
+
sourceTypeName: `readonly ${this.resolvedType.itemType.name}[]`,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else if (this.resolvedType.itemType.kind === "ObjectUnionType" &&
|
|
151
|
+
this.stubType.itemType.kind === "ObjectUnionType" &&
|
|
152
|
+
this.resolvedType.itemType.memberTypes.length ===
|
|
153
|
+
this.stubType.itemType.memberTypes.length) {
|
|
154
|
+
conversions.push({
|
|
155
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ${value}.map(object => { ${stubObjectUnionTypeToResolvedObjectUnionTypeSwitchStatement({ resolvedObjectUnionType: this.resolvedType.itemType, stubObjectUnionType: this.stubType.itemType, variables: { value: "object" } })} }), resolver: async () => purify.Either.of(${value} as readonly ${this.resolvedType.itemType.name}[]) })`,
|
|
156
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
157
|
+
sourceTypeName: `readonly ${this.resolvedType.itemType.name}[]`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
conversions.push({
|
|
161
|
+
conversionExpression: () => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: [], resolver: async () => { throw new Error("should never be called"); } })`,
|
|
162
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "undefined"`,
|
|
163
|
+
sourceTypeName: "undefined",
|
|
164
|
+
});
|
|
165
|
+
return conversions;
|
|
166
|
+
}
|
|
167
|
+
fromJsonExpression(parameters) {
|
|
168
|
+
return `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ${this.stubType.fromJsonExpression(parameters)}, resolver: () => Promise.resolve(purify.Left(new Error("unable to resolve identifiers deserialized from JSON"))) })`;
|
|
169
|
+
}
|
|
170
|
+
fromRdfExpression(parameters) {
|
|
171
|
+
const { variables } = parameters;
|
|
172
|
+
return `${this.stubType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.stubPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}, resolver: (identifiers) => ${variables.objectSet}.${this.resolvedType.itemType.objectSetMethodNames.objects}({ where: { identifiers, type: "identifiers" }}) })))`;
|
|
173
|
+
}
|
|
174
|
+
get graphqlArgs() {
|
|
175
|
+
return Maybe.of({
|
|
176
|
+
limit: {
|
|
177
|
+
type: "graphql.GraphQLInt",
|
|
178
|
+
},
|
|
179
|
+
offset: {
|
|
180
|
+
type: "graphql.GraphQLInt",
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
graphqlResolveExpression({ variables, }) {
|
|
185
|
+
return `(await ${variables.value}.resolve({ limit: ${variables.args}.limit, offset: ${variables.args}.offset })).unsafeCoerce()`;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
__decorate([
|
|
189
|
+
Memoize()
|
|
190
|
+
], ObjectSetType.prototype, "conversions", null);
|
|
191
|
+
__decorate([
|
|
192
|
+
Memoize()
|
|
193
|
+
], ObjectSetType.prototype, "graphqlArgs", null);
|
|
194
|
+
LazyShaclProperty.ObjectSetType = ObjectSetType;
|
|
195
|
+
class SingleObjectType extends Type {
|
|
196
|
+
fromJsonExpression(parameters) {
|
|
197
|
+
return `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ${this.stubType.fromJsonExpression(parameters)}, resolver: (identifier) => Promise.resolve(purify.Left(new Error(\`unable to resolve identifier \${rdfjsResource.Resource.Identifier.toString(identifier)} deserialized from JSON\`))) })`;
|
|
198
|
+
}
|
|
199
|
+
get graphqlArgs() {
|
|
200
|
+
return Maybe.empty();
|
|
201
|
+
}
|
|
202
|
+
graphqlResolveExpression({ variables, }) {
|
|
203
|
+
return `(await ${variables.value}.resolve()).unsafeCoerce()`;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
class OptionalObjectType extends SingleObjectType {
|
|
207
|
+
constructor({ resolvedType, stubType, }) {
|
|
208
|
+
super({
|
|
209
|
+
resolvedType,
|
|
210
|
+
runtimeClass: {
|
|
211
|
+
name: `${syntheticNamePrefix}LazyOptionalObject<${resolvedType.itemType.identifierTypeAlias}, ${resolvedType.itemType.name}, ${stubType.itemType.name}>`,
|
|
212
|
+
rawName: `${syntheticNamePrefix}LazyOptionalObject`,
|
|
213
|
+
snippetDeclaration: SnippetDeclarations.LazyOptionalObject,
|
|
214
|
+
stubPropertyName: "stub",
|
|
215
|
+
},
|
|
216
|
+
stubType,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
get conversions() {
|
|
220
|
+
const conversions = super.conversions.concat();
|
|
221
|
+
if (this.stubType.itemType.kind === "ObjectType") {
|
|
222
|
+
conversions.push({
|
|
223
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ${value}.map(object => ${this.stubType.itemType.newExpression({ parameters: "object" })}), resolver: async () => purify.Either.of((${value} as purify.Maybe<${this.resolvedType.itemType.name}>).unsafeCoerce()) })`,
|
|
224
|
+
sourceTypeCheckExpression: (value) => `purify.Maybe.isMaybe(${value})`,
|
|
225
|
+
sourceTypeName: `purify.Maybe<${this.resolvedType.itemType.name}>`,
|
|
226
|
+
}, {
|
|
227
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: purify.Maybe.of(${this.stubType.itemType.newExpression({ parameters: value })}), resolver: async () => purify.Either.of(${value} as ${this.resolvedType.itemType.name}) })`,
|
|
228
|
+
// Don't check instanceof value since the ObjectUnionType may be an interface
|
|
229
|
+
// Rely on the fact that this will be the last type check on an object
|
|
230
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
231
|
+
sourceTypeName: this.resolvedType.itemType.name,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
else if (this.resolvedType.itemType.kind === "ObjectUnionType" &&
|
|
235
|
+
this.stubType.itemType.kind === "ObjectUnionType" &&
|
|
236
|
+
this.resolvedType.itemType.memberTypes.length ===
|
|
237
|
+
this.stubType.itemType.memberTypes.length) {
|
|
238
|
+
const maybeMap = `.map(object => { ${stubObjectUnionTypeToResolvedObjectUnionTypeSwitchStatement({ resolvedObjectUnionType: this.resolvedType.itemType, stubObjectUnionType: this.stubType.itemType, variables: { value: "object" } })} })`;
|
|
239
|
+
conversions.push({
|
|
240
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ${value}${maybeMap}, resolver: async () => purify.Either.of((${value} as purify.Maybe<${this.resolvedType.itemType.name}>).unsafeCoerce()) })`,
|
|
241
|
+
sourceTypeCheckExpression: (value) => `purify.Maybe.isMaybe(${value})`,
|
|
242
|
+
sourceTypeName: `purify.Maybe<${this.resolvedType.itemType.name}>`,
|
|
243
|
+
}, {
|
|
244
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: purify.Maybe.of(${value})${maybeMap}, resolver: async () => purify.Either.of(${value} as ${this.resolvedType.itemType.name}) })`,
|
|
245
|
+
// Don't check instanceof value since the ObjectUnionType may be an interface
|
|
246
|
+
// Rely on the fact that this will be the last type check on an object
|
|
247
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
248
|
+
sourceTypeName: this.resolvedType.itemType.name,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
conversions.push({
|
|
252
|
+
conversionExpression: () => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: purify.Maybe.empty(), resolver: async () => { throw new Error("should never be called"); } })`,
|
|
253
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "undefined"`,
|
|
254
|
+
sourceTypeName: "undefined",
|
|
255
|
+
});
|
|
256
|
+
return conversions;
|
|
257
|
+
}
|
|
258
|
+
fromRdfExpression(parameters) {
|
|
259
|
+
const { variables } = parameters;
|
|
260
|
+
return `${this.stubType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.stubPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}, resolver: (identifier) => ${variables.objectSet}.${this.resolvedType.itemType.objectSetMethodNames.object}(identifier) })))`;
|
|
261
|
+
}
|
|
262
|
+
graphqlResolveExpression(parameters) {
|
|
263
|
+
return `${super.graphqlResolveExpression(parameters)}.extractNullable()`;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
__decorate([
|
|
267
|
+
Memoize()
|
|
268
|
+
], OptionalObjectType.prototype, "conversions", null);
|
|
269
|
+
LazyShaclProperty.OptionalObjectType = OptionalObjectType;
|
|
270
|
+
class RequiredObjectType extends SingleObjectType {
|
|
271
|
+
constructor({ resolvedType, stubType, }) {
|
|
272
|
+
super({
|
|
273
|
+
resolvedType,
|
|
274
|
+
runtimeClass: {
|
|
275
|
+
name: `${syntheticNamePrefix}LazyRequiredObject<${resolvedType.identifierTypeAlias}, ${resolvedType.name}, ${stubType.name}>`,
|
|
276
|
+
rawName: `${syntheticNamePrefix}LazyRequiredObject`,
|
|
277
|
+
snippetDeclaration: SnippetDeclarations.LazyRequiredObject,
|
|
278
|
+
stubPropertyName: "stub",
|
|
279
|
+
},
|
|
280
|
+
stubType,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
get conversions() {
|
|
284
|
+
const conversions = super.conversions.concat();
|
|
285
|
+
if (this.stubType.kind === "ObjectType") {
|
|
286
|
+
conversions.push({
|
|
287
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ${this.stubType.newExpression({ parameters: value })}, resolver: async () => purify.Either.of(${value} as ${this.resolvedType.name}) })`,
|
|
288
|
+
// Don't check instanceof value since the ObjectType may be an interface
|
|
289
|
+
// Rely on the fact that this will be the last type check on an object
|
|
290
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
291
|
+
sourceTypeName: this.resolvedType.name,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
else if (this.resolvedType.kind === "ObjectUnionType" &&
|
|
295
|
+
this.stubType.kind === "ObjectUnionType" &&
|
|
296
|
+
this.resolvedType.memberTypes.length ===
|
|
297
|
+
this.stubType.memberTypes.length) {
|
|
298
|
+
conversions.push({
|
|
299
|
+
conversionExpression: (value) => `new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}: ((object: ${this.resolvedType.name}) => { ${stubObjectUnionTypeToResolvedObjectUnionTypeSwitchStatement({ resolvedObjectUnionType: this.resolvedType, stubObjectUnionType: this.stubType, variables: { value: "object" } })} })(${value}), resolver: async () => purify.Either.of(${value} as ${this.resolvedType.name}) })`,
|
|
300
|
+
// Don't check instanceof value since the ObjectUnionType may be an interface
|
|
301
|
+
// Rely on the fact that this will be the last type check on an object
|
|
302
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
303
|
+
sourceTypeName: this.resolvedType.name,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return conversions;
|
|
307
|
+
}
|
|
308
|
+
fromRdfExpression(parameters) {
|
|
309
|
+
const { variables } = parameters;
|
|
310
|
+
return `${this.stubType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.stubPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.stubPropertyName}, resolver: (identifier) => ${variables.objectSet}.${this.resolvedType.objectSetMethodNames.object}(identifier) })))`;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
LazyShaclProperty.RequiredObjectType = RequiredObjectType;
|
|
314
|
+
})(LazyShaclProperty || (LazyShaclProperty = {}));
|
|
315
|
+
//# sourceMappingURL=LazyShaclProperty.js.map
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import type { BlankNode, Literal, NamedNode, Variable } from "@rdfjs/types";
|
|
2
1
|
import type { Maybe } from "purify-ts";
|
|
3
2
|
import { type GetAccessorDeclarationStructure, type OptionalKind, type PropertyDeclarationStructure, type PropertySignatureStructure, Scope } from "ts-morph";
|
|
4
|
-
import type { PropertyVisibility
|
|
3
|
+
import type { PropertyVisibility } from "../../../enums/index.js";
|
|
5
4
|
import type { Import } from "../Import.js";
|
|
5
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
6
6
|
import type { Type } from "../Type.js";
|
|
7
|
-
export declare abstract class Property<TypeT extends {
|
|
8
|
-
readonly mutable: boolean;
|
|
9
|
-
readonly name: string;
|
|
10
|
-
}> {
|
|
11
|
-
/**
|
|
12
|
-
* Optional get accessor to include in a class declaration of the object type.
|
|
13
|
-
*/
|
|
14
|
-
abstract readonly classGetAccessorDeclaration: Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
15
|
-
/**
|
|
16
|
-
* Optional property declaration to include in a class declaration of the object type.
|
|
17
|
-
*/
|
|
18
|
-
abstract readonly classPropertyDeclaration: Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
7
|
+
export declare abstract class Property<TypeT extends Pick<Type, "mutable" | "name">> {
|
|
19
8
|
/**
|
|
20
9
|
* Optional property to include in the parameters object of a class constructor.
|
|
21
10
|
*/
|
|
22
11
|
abstract readonly constructorParametersPropertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
23
12
|
/**
|
|
24
|
-
* Function declaration that takes two values of the property and compares them, returning
|
|
13
|
+
* Function declaration that takes two values of the property and compares them, returning an $EqualsResult.
|
|
25
14
|
*/
|
|
26
|
-
abstract readonly equalsFunction: string
|
|
15
|
+
abstract readonly equalsFunction: Maybe<string>;
|
|
27
16
|
/**
|
|
28
|
-
*
|
|
17
|
+
* Optional get accessor to include in a class declaration of the object type.
|
|
18
|
+
*/
|
|
19
|
+
abstract readonly getAccessorDeclaration: Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
20
|
+
/**
|
|
21
|
+
* GraphQL.js field definition.
|
|
29
22
|
*/
|
|
30
|
-
abstract readonly
|
|
23
|
+
abstract readonly graphqlField: Maybe<{
|
|
24
|
+
args: Maybe<Record<string, {
|
|
25
|
+
type: string;
|
|
26
|
+
}>>;
|
|
27
|
+
description: Maybe<string>;
|
|
28
|
+
name: string;
|
|
29
|
+
resolve: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}>;
|
|
31
32
|
/**
|
|
32
33
|
* Signature of the property when serialized to JSON (the type of toJsonObjectMember).
|
|
33
34
|
*/
|
|
@@ -41,14 +42,17 @@ export declare abstract class Property<TypeT extends {
|
|
|
41
42
|
*/
|
|
42
43
|
readonly name: string;
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
-
* relies on. For example, the equals function/method of ObjectType has a custom return type that's the same across all
|
|
46
|
-
* ObjectType's. Instead of re-declaring the return type anonymously on every equals function, declare a named type
|
|
47
|
-
* as a snippet and reference it.
|
|
48
|
-
*
|
|
49
|
-
* The generator deduplicates snippet declarations across all types before adding them to the source.
|
|
45
|
+
* Optional property declaration to include in a class declaration of the object type.
|
|
50
46
|
*/
|
|
51
|
-
abstract readonly
|
|
47
|
+
abstract readonly propertyDeclaration: Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
48
|
+
/**
|
|
49
|
+
* Signature of the property in an interface version of the object.
|
|
50
|
+
*/
|
|
51
|
+
abstract readonly propertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
52
|
+
/**
|
|
53
|
+
* Is the property's type the ObjectType or does its type indirectly reference the ObjectType?
|
|
54
|
+
*/
|
|
55
|
+
abstract readonly recursive: boolean;
|
|
52
56
|
/**
|
|
53
57
|
* Property type
|
|
54
58
|
. */
|
|
@@ -57,16 +61,10 @@ export declare abstract class Property<TypeT extends {
|
|
|
57
61
|
* Property visibility: private, protected, public.
|
|
58
62
|
*/
|
|
59
63
|
readonly visibility: PropertyVisibility;
|
|
60
|
-
protected readonly
|
|
61
|
-
|
|
62
|
-
readonly declarationType: TsObjectDeclarationType;
|
|
63
|
-
readonly features: Set<TsFeature>;
|
|
64
|
-
readonly mutable: () => boolean;
|
|
65
|
-
};
|
|
66
|
-
constructor({ dataFactoryVariable, name, objectType, type, visibility, }: {
|
|
67
|
-
dataFactoryVariable: string;
|
|
64
|
+
protected readonly objectType: ObjectType;
|
|
65
|
+
constructor({ name, objectType, type, visibility, }: {
|
|
68
66
|
name: string;
|
|
69
|
-
objectType:
|
|
67
|
+
objectType: ObjectType;
|
|
70
68
|
type: TypeT;
|
|
71
69
|
visibility: PropertyVisibility;
|
|
72
70
|
});
|
|
@@ -76,11 +74,12 @@ export declare abstract class Property<TypeT extends {
|
|
|
76
74
|
abstract get declarationImports(): readonly Import[];
|
|
77
75
|
protected static visibilityToScope(visibility: PropertyVisibility): Scope | undefined;
|
|
78
76
|
/**
|
|
79
|
-
* Statements to assign the parameter of described by constructorParametersPropertySignature to a class member.
|
|
77
|
+
* Statements to assign the parameter of described by constructorParametersPropertySignature to a class or interface member.
|
|
80
78
|
*/
|
|
81
|
-
abstract
|
|
79
|
+
abstract constructorStatements(parameters: {
|
|
82
80
|
variables: {
|
|
83
81
|
parameter: string;
|
|
82
|
+
parameters: string;
|
|
84
83
|
};
|
|
85
84
|
}): readonly string[];
|
|
86
85
|
/**
|
|
@@ -92,12 +91,13 @@ export declare abstract class Property<TypeT extends {
|
|
|
92
91
|
};
|
|
93
92
|
}): readonly string[];
|
|
94
93
|
/**
|
|
95
|
-
* Statements to deserialize
|
|
94
|
+
* Statements to deserialize this property on the given rdfjsResource.Resource to a typed value of the property.
|
|
96
95
|
*/
|
|
97
96
|
abstract fromRdfStatements(parameters: {
|
|
98
97
|
variables: {
|
|
99
98
|
context: string;
|
|
100
99
|
languageIn: string;
|
|
100
|
+
objectSet: string;
|
|
101
101
|
resource: string;
|
|
102
102
|
};
|
|
103
103
|
}): readonly string[];
|
|
@@ -105,14 +105,6 @@ export declare abstract class Property<TypeT extends {
|
|
|
105
105
|
* Statements to hash this property using a hasher instance.
|
|
106
106
|
*/
|
|
107
107
|
abstract hashStatements(parameters: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
108
|
-
/**
|
|
109
|
-
* Companion to classConstructorStatements with a similar purpose in an interface's create() function.
|
|
110
|
-
*/
|
|
111
|
-
abstract interfaceConstructorStatements(parameters: {
|
|
112
|
-
variables: {
|
|
113
|
-
parameter: string;
|
|
114
|
-
};
|
|
115
|
-
}): readonly string[];
|
|
116
108
|
/**
|
|
117
109
|
* Element object (usually a control https://jsonforms.io/docs/uischema/controls) for a JSON Forms UI schema.
|
|
118
110
|
*/
|
|
@@ -132,6 +124,15 @@ export declare abstract class Property<TypeT extends {
|
|
|
132
124
|
readonly key: string;
|
|
133
125
|
readonly schema: string;
|
|
134
126
|
}>;
|
|
127
|
+
/**
|
|
128
|
+
* Reusable function, type, and other declarations that are not particular to this property but that property-specific code
|
|
129
|
+
* relies on. For example, the equals function/method of ObjectType has a custom return type that's the same across all
|
|
130
|
+
* ObjectType's. Instead of re-declaring the return type anonymously on every equals function, declare a named type
|
|
131
|
+
* as a snippet and reference it.
|
|
132
|
+
*
|
|
133
|
+
* The generator deduplicates snippet declarations across all types before adding them to the source.
|
|
134
|
+
*/
|
|
135
|
+
abstract snippetDeclarations(parameters: Parameters<Type["snippetDeclarations"]>[0]): readonly string[];
|
|
135
136
|
/**
|
|
136
137
|
* An array of SPARQL.js CONSTRUCT template triples for this property as strings (so they can incorporate runtime calls).
|
|
137
138
|
*/
|
|
@@ -146,6 +147,7 @@ export declare abstract class Property<TypeT extends {
|
|
|
146
147
|
*/
|
|
147
148
|
abstract sparqlWherePatterns(parameters: {
|
|
148
149
|
variables: {
|
|
150
|
+
languageIn: string;
|
|
149
151
|
subject: string;
|
|
150
152
|
variablePrefix: string;
|
|
151
153
|
};
|
|
@@ -164,6 +166,5 @@ export declare abstract class Property<TypeT extends {
|
|
|
164
166
|
abstract toRdfStatements(parameters: {
|
|
165
167
|
variables: Omit<Parameters<Type["toRdfExpression"]>[0]["variables"], "predicate">;
|
|
166
168
|
}): readonly string[];
|
|
167
|
-
protected rdfjsTermExpression(rdfjsTerm: Omit<BlankNode, "equals"> | Omit<Literal, "equals"> | Omit<NamedNode, "equals"> | Omit<Variable, "equals">): string;
|
|
168
169
|
}
|
|
169
170
|
//# sourceMappingURL=Property.d.ts.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Scope, } from "ts-morph";
|
|
2
|
-
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
3
2
|
export class Property {
|
|
4
3
|
/**
|
|
5
4
|
* TypeScript identifier-safe name of the property.
|
|
@@ -13,10 +12,8 @@ export class Property {
|
|
|
13
12
|
* Property visibility: private, protected, public.
|
|
14
13
|
*/
|
|
15
14
|
visibility;
|
|
16
|
-
dataFactoryVariable;
|
|
17
15
|
objectType;
|
|
18
|
-
constructor({
|
|
19
|
-
this.dataFactoryVariable = dataFactoryVariable;
|
|
16
|
+
constructor({ name, objectType, type, visibility, }) {
|
|
20
17
|
this.name = name;
|
|
21
18
|
this.objectType = objectType;
|
|
22
19
|
this.type = type;
|
|
@@ -32,11 +29,5 @@ export class Property {
|
|
|
32
29
|
return undefined;
|
|
33
30
|
}
|
|
34
31
|
}
|
|
35
|
-
rdfjsTermExpression(rdfjsTerm) {
|
|
36
|
-
return rdfjsTermExpression({
|
|
37
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
38
|
-
rdfjsTerm,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
32
|
}
|
|
42
33
|
//# sourceMappingURL=Property.js.map
|
|
@@ -1,44 +1,39 @@
|
|
|
1
1
|
import type * as rdfjs from "@rdfjs/types";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
import type { GetAccessorDeclarationStructure, OptionalKind, PropertyDeclarationStructure, PropertySignatureStructure } from "ts-morph";
|
|
4
|
-
import type { IdentifierType } from "../IdentifierType.js";
|
|
5
4
|
import type { Import } from "../Import.js";
|
|
6
5
|
import type { Type } from "../Type.js";
|
|
7
6
|
import { Property } from "./Property.js";
|
|
8
|
-
export declare class ShaclProperty extends Property<
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
constructor({ comment, description, label, mutable, path, ...superParameters }: {
|
|
7
|
+
export declare abstract class ShaclProperty<TypeT extends Type> extends Property<TypeT> {
|
|
8
|
+
protected readonly comment: Maybe<string>;
|
|
9
|
+
protected readonly description: Maybe<string>;
|
|
10
|
+
protected readonly label: Maybe<string>;
|
|
11
|
+
readonly path: rdfjs.NamedNode;
|
|
12
|
+
constructor({ comment, description, label, path, ...superParameters }: {
|
|
15
13
|
comment: Maybe<string>;
|
|
16
14
|
description: Maybe<string>;
|
|
17
15
|
label: Maybe<string>;
|
|
18
|
-
mutable: boolean;
|
|
19
16
|
path: rdfjs.NamedNode;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
get classGetAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
23
|
-
get classPropertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
17
|
+
} & ConstructorParameters<typeof Property<TypeT>>[0]);
|
|
18
|
+
get equalsFunction(): Maybe<string>;
|
|
24
19
|
get constructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
get
|
|
20
|
+
constructorStatements({ variables, }: Parameters<Property<TypeT>["constructorStatements"]>[0]): readonly string[];
|
|
21
|
+
fromJsonStatements({ variables, }: Parameters<Property<TypeT>["fromJsonStatements"]>[0]): readonly string[];
|
|
22
|
+
get getAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
23
|
+
hashStatements(parameters: Parameters<Property<TypeT>["hashStatements"]>[0]): readonly string[];
|
|
28
24
|
get jsonPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
toRdfStatements({ variables, }: Parameters<Property<Type>["toRdfStatements"]>[0]): readonly string[];
|
|
25
|
+
jsonUiSchemaElement({ variables, }: Parameters<Property<TypeT>["jsonUiSchemaElement"]>[0]): Maybe<string>;
|
|
26
|
+
jsonZodSchema(parameters: Parameters<Property<TypeT>["jsonZodSchema"]>[0]): ReturnType<Property<TypeT>["jsonZodSchema"]>;
|
|
27
|
+
get propertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
28
|
+
get declarationImports(): readonly Import[];
|
|
29
|
+
get propertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
30
|
+
snippetDeclarations(parameters: Parameters<Property<Type>["snippetDeclarations"]>[0]): readonly string[];
|
|
31
|
+
fromRdfStatements({ variables, }: Parameters<Property<TypeT>["fromRdfStatements"]>[0]): readonly string[];
|
|
32
|
+
sparqlConstructTemplateTriples({ variables, }: Parameters<Property<TypeT>["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
33
|
+
sparqlWherePatterns({ variables, }: Parameters<Property<TypeT>["sparqlWherePatterns"]>[0]): readonly string[];
|
|
34
|
+
toJsonObjectMember(parameters: Parameters<Property<TypeT>["toJsonObjectMember"]>[0]): Maybe<string>;
|
|
35
|
+
toRdfStatements({ variables, }: Parameters<Property<TypeT>["toRdfStatements"]>[0]): readonly string[];
|
|
36
|
+
protected get declarationComment(): string | undefined;
|
|
37
|
+
protected get predicate(): string;
|
|
43
38
|
}
|
|
44
39
|
//# sourceMappingURL=ShaclProperty.d.ts.map
|