@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,31 +1,32 @@
|
|
|
1
|
-
import type { IdentifierType } from "generators/ts/IdentifierType.js";
|
|
2
|
-
import type { Import } from "generators/ts/Import.js";
|
|
3
1
|
import { Maybe } from "purify-ts";
|
|
4
2
|
import { type GetAccessorDeclarationStructure, type OptionalKind, type PropertyDeclarationStructure, type PropertySignatureStructure } from "ts-morph";
|
|
3
|
+
import type { IdentifierType } from "../IdentifierType.js";
|
|
4
|
+
import type { Import } from "../Import.js";
|
|
5
5
|
import type { StringType } from "../StringType.js";
|
|
6
6
|
import { Property } from "./Property.js";
|
|
7
7
|
export declare class IdentifierPrefixProperty extends Property<StringType> {
|
|
8
|
-
readonly equalsFunction = "strictEquals";
|
|
9
|
-
readonly mutable = false;
|
|
10
8
|
private readonly own;
|
|
9
|
+
readonly declarationImports: readonly Import[];
|
|
10
|
+
readonly equalsFunction = "$strictEquals";
|
|
11
|
+
readonly graphqlField: Property<StringType>["graphqlField"];
|
|
12
|
+
readonly propertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
13
|
+
readonly jsonPropertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
14
|
+
readonly mutable = false;
|
|
15
|
+
readonly recursive = false;
|
|
11
16
|
constructor({ own, ...superParameters }: {
|
|
12
17
|
own: boolean;
|
|
13
18
|
type: StringType;
|
|
14
19
|
} & ConstructorParameters<typeof Property>[0]);
|
|
15
|
-
get classGetAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
16
|
-
get classPropertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
17
20
|
get constructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
18
|
-
|
|
19
|
-
get interfacePropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
20
|
-
get jsonPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
21
|
-
get snippetDeclarations(): readonly string[];
|
|
22
|
-
classConstructorStatements({ variables, }: Parameters<Property<IdentifierType>["classConstructorStatements"]>[0]): readonly string[];
|
|
21
|
+
constructorStatements({ variables, }: Parameters<Property<IdentifierType>["constructorStatements"]>[0]): readonly string[];
|
|
23
22
|
fromJsonStatements(): readonly string[];
|
|
24
23
|
fromRdfStatements(): readonly string[];
|
|
24
|
+
get getAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
25
25
|
hashStatements(): readonly string[];
|
|
26
|
-
interfaceConstructorStatements(): readonly string[];
|
|
27
26
|
jsonUiSchemaElement(): Maybe<string>;
|
|
28
27
|
jsonZodSchema(): ReturnType<Property<IdentifierType>["jsonZodSchema"]>;
|
|
28
|
+
get propertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
29
|
+
snippetDeclarations(): readonly string[];
|
|
29
30
|
sparqlConstructTemplateTriples(): readonly string[];
|
|
30
31
|
sparqlWherePatterns(): readonly string[];
|
|
31
32
|
toJsonObjectMember(): Maybe<string>;
|
|
@@ -2,37 +2,22 @@ import { Maybe } from "purify-ts";
|
|
|
2
2
|
import { invariant } from "ts-invariant";
|
|
3
3
|
import { Scope, } from "ts-morph";
|
|
4
4
|
import { SnippetDeclarations } from "../SnippetDeclarations.js";
|
|
5
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
6
|
import { Property } from "./Property.js";
|
|
6
7
|
export class IdentifierPrefixProperty extends Property {
|
|
7
|
-
equalsFunction = "strictEquals";
|
|
8
|
-
mutable = false;
|
|
9
8
|
own;
|
|
9
|
+
declarationImports = [];
|
|
10
|
+
equalsFunction = `${syntheticNamePrefix}strictEquals`;
|
|
11
|
+
graphqlField = Maybe.empty();
|
|
12
|
+
propertySignature = Maybe.empty();
|
|
13
|
+
jsonPropertySignature = Maybe.empty();
|
|
14
|
+
mutable = false;
|
|
15
|
+
recursive = false;
|
|
10
16
|
constructor({ own, ...superParameters }) {
|
|
11
17
|
super(superParameters);
|
|
12
18
|
invariant(this.visibility === "protected");
|
|
13
19
|
this.own = own;
|
|
14
20
|
}
|
|
15
|
-
get classGetAccessorDeclaration() {
|
|
16
|
-
return Maybe.of({
|
|
17
|
-
leadingTrivia: `protected ${!this.own ? "override " : ""}`,
|
|
18
|
-
name: this.name,
|
|
19
|
-
returnType: this.type.name,
|
|
20
|
-
statements: [
|
|
21
|
-
`return (typeof this._${this.name} !== "undefined") ? this._${this.name} : \`urn:shaclmate:\${this.type}:\``,
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
get classPropertyDeclaration() {
|
|
26
|
-
return this.own
|
|
27
|
-
? Maybe.of({
|
|
28
|
-
hasQuestionToken: true,
|
|
29
|
-
isReadonly: true,
|
|
30
|
-
name: `_${this.name}`,
|
|
31
|
-
scope: Scope.Protected,
|
|
32
|
-
type: this.type.name,
|
|
33
|
-
})
|
|
34
|
-
: Maybe.empty();
|
|
35
|
-
}
|
|
36
21
|
get constructorParametersPropertySignature() {
|
|
37
22
|
return Maybe.of({
|
|
38
23
|
hasQuestionToken: true,
|
|
@@ -41,28 +26,17 @@ export class IdentifierPrefixProperty extends Property {
|
|
|
41
26
|
type: this.type.name,
|
|
42
27
|
});
|
|
43
28
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const snippetDeclarations = [];
|
|
55
|
-
if (this.objectType.features.has("equals")) {
|
|
56
|
-
snippetDeclarations.push(SnippetDeclarations.strictEquals);
|
|
29
|
+
constructorStatements({ variables, }) {
|
|
30
|
+
switch (this.objectType.declarationType) {
|
|
31
|
+
case "class":
|
|
32
|
+
return this.propertyDeclaration
|
|
33
|
+
.map((propertyDeclaration) => [
|
|
34
|
+
`this.${propertyDeclaration.name} = ${variables.parameter};`,
|
|
35
|
+
])
|
|
36
|
+
.orDefault([]);
|
|
37
|
+
case "interface":
|
|
38
|
+
return [];
|
|
57
39
|
}
|
|
58
|
-
return snippetDeclarations;
|
|
59
|
-
}
|
|
60
|
-
classConstructorStatements({ variables, }) {
|
|
61
|
-
return this.classPropertyDeclaration
|
|
62
|
-
.map((classPropertyDeclaration) => [
|
|
63
|
-
`this.${classPropertyDeclaration.name} = ${variables.parameter};`,
|
|
64
|
-
])
|
|
65
|
-
.orDefault([]);
|
|
66
40
|
}
|
|
67
41
|
fromJsonStatements() {
|
|
68
42
|
return [];
|
|
@@ -70,10 +44,17 @@ export class IdentifierPrefixProperty extends Property {
|
|
|
70
44
|
fromRdfStatements() {
|
|
71
45
|
return [];
|
|
72
46
|
}
|
|
73
|
-
|
|
74
|
-
return
|
|
47
|
+
get getAccessorDeclaration() {
|
|
48
|
+
return Maybe.of({
|
|
49
|
+
leadingTrivia: `protected ${!this.own ? "override " : ""}`,
|
|
50
|
+
name: this.name,
|
|
51
|
+
returnType: this.type.name,
|
|
52
|
+
statements: [
|
|
53
|
+
`return (typeof this._${this.name} !== "undefined") ? this._${this.name} : \`urn:shaclmate:\${this.${syntheticNamePrefix}type}:\``,
|
|
54
|
+
],
|
|
55
|
+
});
|
|
75
56
|
}
|
|
76
|
-
|
|
57
|
+
hashStatements() {
|
|
77
58
|
return [];
|
|
78
59
|
}
|
|
79
60
|
jsonUiSchemaElement() {
|
|
@@ -82,6 +63,24 @@ export class IdentifierPrefixProperty extends Property {
|
|
|
82
63
|
jsonZodSchema() {
|
|
83
64
|
return Maybe.empty();
|
|
84
65
|
}
|
|
66
|
+
get propertyDeclaration() {
|
|
67
|
+
return this.own
|
|
68
|
+
? Maybe.of({
|
|
69
|
+
hasQuestionToken: true,
|
|
70
|
+
isReadonly: true,
|
|
71
|
+
name: `_${this.name}`,
|
|
72
|
+
scope: Scope.Protected,
|
|
73
|
+
type: this.type.name,
|
|
74
|
+
})
|
|
75
|
+
: Maybe.empty();
|
|
76
|
+
}
|
|
77
|
+
snippetDeclarations() {
|
|
78
|
+
const snippetDeclarations = [];
|
|
79
|
+
if (this.objectType.features.has("equals")) {
|
|
80
|
+
snippetDeclarations.push(SnippetDeclarations.strictEquals);
|
|
81
|
+
}
|
|
82
|
+
return snippetDeclarations;
|
|
83
|
+
}
|
|
85
84
|
sparqlConstructTemplateTriples() {
|
|
86
85
|
return [];
|
|
87
86
|
}
|
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import type { GetAccessorDeclarationStructure, OptionalKind, PropertyDeclarationStructure, PropertySignatureStructure } from "ts-morph";
|
|
2
|
+
import type { GetAccessorDeclarationStructure, OptionalKind, PropertyDeclarationStructure, PropertySignatureStructure, Scope } from "ts-morph";
|
|
3
3
|
import type { IdentifierMintingStrategy, PropertyVisibility } from "../../../enums/index.js";
|
|
4
4
|
import type { IdentifierType } from "../IdentifierType.js";
|
|
5
5
|
import { Import } from "../Import.js";
|
|
6
6
|
import { Property } from "./Property.js";
|
|
7
7
|
export declare class IdentifierProperty extends Property<IdentifierType> {
|
|
8
|
-
readonly
|
|
9
|
-
readonly
|
|
10
|
-
readonly mutable = false;
|
|
11
|
-
private readonly classDeclarationVisibility;
|
|
8
|
+
private readonly classGetAccessorScope;
|
|
9
|
+
private readonly classPropertyDeclarationVisibility;
|
|
12
10
|
private readonly identifierMintingStrategy;
|
|
11
|
+
private readonly identifierPrefixPropertyName;
|
|
13
12
|
private readonly override;
|
|
14
|
-
|
|
13
|
+
private readonly typeAlias;
|
|
14
|
+
readonly abstract: boolean;
|
|
15
|
+
readonly equalsFunction = "$booleanEquals";
|
|
16
|
+
readonly mutable = false;
|
|
17
|
+
readonly recursive = false;
|
|
18
|
+
constructor({ abstract, classGetAccessorScope, classPropertyDeclarationVisibility, identifierMintingStrategy, identifierPrefixPropertyName, override, typeAlias, ...superParameters }: {
|
|
15
19
|
abstract: boolean;
|
|
16
|
-
|
|
20
|
+
classGetAccessorScope: Maybe<Scope>;
|
|
21
|
+
classPropertyDeclarationVisibility: Maybe<PropertyVisibility>;
|
|
17
22
|
identifierMintingStrategy: Maybe<IdentifierMintingStrategy>;
|
|
23
|
+
identifierPrefixPropertyName: string;
|
|
18
24
|
override: boolean;
|
|
19
25
|
type: IdentifierType;
|
|
26
|
+
typeAlias: string;
|
|
20
27
|
} & ConstructorParameters<typeof Property>[0]);
|
|
21
|
-
get classGetAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
22
|
-
get classPropertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
23
28
|
get constructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
24
29
|
get declarationImports(): readonly Import[];
|
|
25
|
-
get
|
|
30
|
+
get getAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
31
|
+
get graphqlField(): Property<IdentifierType>["graphqlField"];
|
|
26
32
|
get jsonPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
27
|
-
|
|
28
|
-
classConstructorStatements({ variables, }: Parameters<Property<IdentifierType>["classConstructorStatements"]>[0]): readonly string[];
|
|
33
|
+
constructorStatements({ variables, }: Parameters<Property<IdentifierType>["constructorStatements"]>[0]): readonly string[];
|
|
29
34
|
fromJsonStatements({ variables, }: Parameters<Property<IdentifierType>["fromJsonStatements"]>[0]): readonly string[];
|
|
30
35
|
fromRdfStatements({ variables, }: Parameters<Property<IdentifierType>["fromRdfStatements"]>[0]): readonly string[];
|
|
31
36
|
hashStatements({ variables, }: Parameters<Property<IdentifierType>["hashStatements"]>[0]): readonly string[];
|
|
32
|
-
interfaceConstructorStatements({ variables, }: Parameters<Property<IdentifierType>["interfaceConstructorStatements"]>[0]): readonly string[];
|
|
33
37
|
jsonUiSchemaElement({ variables, }: Parameters<Property<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<string>;
|
|
34
38
|
jsonZodSchema({ variables, }: Parameters<Property<IdentifierType>["jsonZodSchema"]>[0]): ReturnType<Property<IdentifierType>["jsonZodSchema"]>;
|
|
39
|
+
get propertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
40
|
+
get propertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
41
|
+
snippetDeclarations(): readonly string[];
|
|
35
42
|
sparqlConstructTemplateTriples(): readonly string[];
|
|
36
43
|
sparqlWherePatterns(): readonly string[];
|
|
37
44
|
toJsonObjectMember({ variables, }: Parameters<Property<IdentifierType>["toJsonObjectMember"]>[0]): Maybe<string>;
|
|
@@ -3,92 +3,31 @@ import { Maybe } from "purify-ts";
|
|
|
3
3
|
import { invariant } from "ts-invariant";
|
|
4
4
|
import { Import } from "../Import.js";
|
|
5
5
|
import { SnippetDeclarations } from "../SnippetDeclarations.js";
|
|
6
|
+
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
7
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
6
8
|
import { Property } from "./Property.js";
|
|
7
9
|
export class IdentifierProperty extends Property {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
mutable = false;
|
|
11
|
-
classDeclarationVisibility;
|
|
10
|
+
classGetAccessorScope;
|
|
11
|
+
classPropertyDeclarationVisibility;
|
|
12
12
|
identifierMintingStrategy;
|
|
13
|
+
identifierPrefixPropertyName;
|
|
13
14
|
override;
|
|
14
|
-
|
|
15
|
+
typeAlias;
|
|
16
|
+
abstract;
|
|
17
|
+
equalsFunction = `${syntheticNamePrefix}booleanEquals`;
|
|
18
|
+
mutable = false;
|
|
19
|
+
recursive = false;
|
|
20
|
+
constructor({ abstract, classGetAccessorScope, classPropertyDeclarationVisibility, identifierMintingStrategy, identifierPrefixPropertyName, override, typeAlias, ...superParameters }) {
|
|
15
21
|
super(superParameters);
|
|
16
22
|
invariant(this.visibility === "public");
|
|
17
23
|
this.abstract = abstract;
|
|
18
|
-
this.
|
|
24
|
+
this.classGetAccessorScope = classGetAccessorScope;
|
|
25
|
+
this.classPropertyDeclarationVisibility =
|
|
26
|
+
classPropertyDeclarationVisibility;
|
|
19
27
|
this.identifierMintingStrategy = identifierMintingStrategy;
|
|
28
|
+
this.identifierPrefixPropertyName = identifierPrefixPropertyName;
|
|
20
29
|
this.override = override;
|
|
21
|
-
|
|
22
|
-
get classGetAccessorDeclaration() {
|
|
23
|
-
if (this.abstract) {
|
|
24
|
-
return Maybe.empty();
|
|
25
|
-
}
|
|
26
|
-
if (this.identifierMintingStrategy.isNothing()) {
|
|
27
|
-
return Maybe.empty();
|
|
28
|
-
}
|
|
29
|
-
let memoizeMintedIdentifier;
|
|
30
|
-
let mintIdentifier;
|
|
31
|
-
switch (this.identifierMintingStrategy.unsafeCoerce()) {
|
|
32
|
-
case "blankNode":
|
|
33
|
-
memoizeMintedIdentifier = true;
|
|
34
|
-
mintIdentifier = "dataFactory.blankNode()";
|
|
35
|
-
break;
|
|
36
|
-
case "sha256":
|
|
37
|
-
// If the object is mutable don't memoize the minted identifier, since the hash will change if the object mutates.
|
|
38
|
-
memoizeMintedIdentifier = !this.objectType.mutable();
|
|
39
|
-
mintIdentifier =
|
|
40
|
-
"dataFactory.namedNode(`${this.identifierPrefix}${this.hashShaclProperties(sha256.create())}`)";
|
|
41
|
-
break;
|
|
42
|
-
case "uuidv4":
|
|
43
|
-
memoizeMintedIdentifier = true;
|
|
44
|
-
mintIdentifier =
|
|
45
|
-
"dataFactory.namedNode(`${this.identifierPrefix}${uuid.v4()}`)";
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
return Maybe.of({
|
|
49
|
-
leadingTrivia: this.override ? "override " : undefined,
|
|
50
|
-
name: this.name,
|
|
51
|
-
returnType: this.type.name,
|
|
52
|
-
statements: [
|
|
53
|
-
memoizeMintedIdentifier
|
|
54
|
-
? `if (typeof this._${this.name} === "undefined") { this._${this.name} = ${mintIdentifier}; } return this._${this.name};`
|
|
55
|
-
: `return (typeof this._${this.name} !== "undefined") ? this._${this.name} : ${mintIdentifier}`,
|
|
56
|
-
],
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
get classPropertyDeclaration() {
|
|
60
|
-
if (this.abstract) {
|
|
61
|
-
// Abstract version of the accessor
|
|
62
|
-
// Work around a ts-morph bug that puts the override keyword before the abstract keyword
|
|
63
|
-
return Maybe.of({
|
|
64
|
-
hasOverrideKeyword: this.abstract && this.override ? undefined : this.override,
|
|
65
|
-
isAbstract: this.abstract && this.override ? undefined : this.abstract,
|
|
66
|
-
isReadonly: true,
|
|
67
|
-
leadingTrivia: this.abstract && this.override ? "abstract override " : undefined,
|
|
68
|
-
name: this.name,
|
|
69
|
-
type: this.type.name,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
// See note in TypeFactory re: the logic of whether to declare the identifier in the class or not.
|
|
73
|
-
if (!this.classDeclarationVisibility.isJust()) {
|
|
74
|
-
return Maybe.empty();
|
|
75
|
-
}
|
|
76
|
-
if (this.identifierMintingStrategy.isJust()) {
|
|
77
|
-
// Mutable _identifier property that will be lazily initialized by the getter to mint the identifier
|
|
78
|
-
return Maybe.of({
|
|
79
|
-
name: `_${this.name}`,
|
|
80
|
-
scope: this.classDeclarationVisibility
|
|
81
|
-
.map(Property.visibilityToScope)
|
|
82
|
-
.unsafeCoerce(),
|
|
83
|
-
type: `${this.type.name} | undefined`,
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// Immutable, public identifier property, no getter
|
|
87
|
-
return Maybe.of({
|
|
88
|
-
isReadonly: true,
|
|
89
|
-
name: this.name,
|
|
90
|
-
type: this.type.name,
|
|
91
|
-
});
|
|
30
|
+
this.typeAlias = typeAlias;
|
|
92
31
|
}
|
|
93
32
|
get constructorParametersPropertySignature() {
|
|
94
33
|
if (this.objectType.declarationType === "class" && this.abstract) {
|
|
@@ -125,11 +64,54 @@ export class IdentifierProperty extends Property {
|
|
|
125
64
|
}
|
|
126
65
|
return imports;
|
|
127
66
|
}
|
|
128
|
-
get
|
|
67
|
+
get getAccessorDeclaration() {
|
|
68
|
+
if (this.classGetAccessorScope.isNothing()) {
|
|
69
|
+
return Maybe.empty();
|
|
70
|
+
}
|
|
71
|
+
invariant(this.classGetAccessorScope.unsafeCoerce() === "public");
|
|
72
|
+
if (this.identifierMintingStrategy.isJust()) {
|
|
73
|
+
let memoizeMintedIdentifier;
|
|
74
|
+
let mintIdentifier;
|
|
75
|
+
switch (this.identifierMintingStrategy.unsafeCoerce()) {
|
|
76
|
+
case "blankNode":
|
|
77
|
+
memoizeMintedIdentifier = true;
|
|
78
|
+
mintIdentifier = "dataFactory.blankNode()";
|
|
79
|
+
break;
|
|
80
|
+
case "sha256":
|
|
81
|
+
// If the object is mutable don't memoize the minted identifier, since the hash will change if the object mutates.
|
|
82
|
+
memoizeMintedIdentifier = !this.objectType.mutable;
|
|
83
|
+
mintIdentifier = `dataFactory.namedNode(\`\${this.${this.identifierPrefixPropertyName}}\${this.${syntheticNamePrefix}hashShaclProperties(sha256.create())}\`)`;
|
|
84
|
+
break;
|
|
85
|
+
case "uuidv4":
|
|
86
|
+
memoizeMintedIdentifier = true;
|
|
87
|
+
mintIdentifier = `dataFactory.namedNode(\`\${this.${this.identifierPrefixPropertyName}}\${uuid.v4()}\`)`;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
return Maybe.of({
|
|
91
|
+
leadingTrivia: this.override ? "override " : undefined,
|
|
92
|
+
name: this.name,
|
|
93
|
+
returnType: this.typeAlias,
|
|
94
|
+
statements: [
|
|
95
|
+
memoizeMintedIdentifier
|
|
96
|
+
? `if (typeof this._${this.name} === "undefined") { this._${this.name} = ${mintIdentifier}; } return this._${this.name};`
|
|
97
|
+
: `return (typeof this._${this.name} !== "undefined") ? this._${this.name} : ${mintIdentifier}`,
|
|
98
|
+
],
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
invariant(this.propertyDeclaration.isNothing());
|
|
129
102
|
return Maybe.of({
|
|
130
|
-
|
|
103
|
+
leadingTrivia: this.override ? "override " : undefined,
|
|
131
104
|
name: this.name,
|
|
132
|
-
|
|
105
|
+
returnType: this.typeAlias,
|
|
106
|
+
statements: [`return super.${this.name} as ${this.typeAlias}`],
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
get graphqlField() {
|
|
110
|
+
invariant(this.name.startsWith(syntheticNamePrefix));
|
|
111
|
+
return Maybe.of({
|
|
112
|
+
name: `_${this.name.substring(syntheticNamePrefix.length)}`,
|
|
113
|
+
resolve: `(source) => ${this.typeAlias}.toString(source.${this.name})`,
|
|
114
|
+
type: this.type.graphqlName.toString(),
|
|
133
115
|
});
|
|
134
116
|
}
|
|
135
117
|
get jsonPropertySignature() {
|
|
@@ -139,38 +121,45 @@ export class IdentifierProperty extends Property {
|
|
|
139
121
|
type: "string",
|
|
140
122
|
});
|
|
141
123
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
snippetDeclarations.push(SnippetDeclarations.booleanEquals);
|
|
146
|
-
}
|
|
147
|
-
return snippetDeclarations;
|
|
148
|
-
}
|
|
149
|
-
classConstructorStatements({ variables, }) {
|
|
150
|
-
if (this.abstract) {
|
|
151
|
-
return [];
|
|
152
|
-
}
|
|
153
|
-
if (this.classPropertyDeclaration.isNothing()) {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
|
-
const classPropertyDeclaration = this.classPropertyDeclaration.unsafeCoerce();
|
|
124
|
+
constructorStatements({ variables, }) {
|
|
125
|
+
let lhs;
|
|
126
|
+
const statements = [];
|
|
157
127
|
const typeConversions = this.type.conversions;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
128
|
+
switch (this.objectType.declarationType) {
|
|
129
|
+
case "class": {
|
|
130
|
+
if (this.abstract) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
if (this.propertyDeclaration.isNothing()) {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
const propertyDeclaration = this.propertyDeclaration.unsafeCoerce();
|
|
137
|
+
if (typeConversions.length === 1) {
|
|
138
|
+
return [`this.${propertyDeclaration.name} = ${variables.parameter};`];
|
|
139
|
+
}
|
|
140
|
+
lhs = `this.${propertyDeclaration.name}`;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
case "interface":
|
|
144
|
+
if (typeConversions.length === 1) {
|
|
145
|
+
return [`const ${this.name} = ${variables.parameter};`];
|
|
146
|
+
}
|
|
147
|
+
lhs = this.name;
|
|
148
|
+
statements.push(`let ${this.name}: ${this.typeAlias};`);
|
|
149
|
+
break;
|
|
162
150
|
}
|
|
163
|
-
const
|
|
164
|
-
for (const conversion of
|
|
151
|
+
const conversionBranches = [];
|
|
152
|
+
for (const conversion of typeConversions) {
|
|
165
153
|
invariant(conversion.sourceTypeName !== "undefined");
|
|
166
|
-
|
|
154
|
+
conversionBranches.push(`if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { ${lhs} = ${conversion.conversionExpression(variables.parameter)}; }`);
|
|
167
155
|
}
|
|
168
|
-
if (
|
|
169
|
-
|
|
156
|
+
if (lhs.startsWith("this._")) {
|
|
157
|
+
conversionBranches.push(`if (typeof ${variables.parameter} === "undefined") { }`);
|
|
170
158
|
}
|
|
171
159
|
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
conversionBranches.push(`{ ${lhs} = (${variables.parameter}) satisfies never;\n }`);
|
|
161
|
+
statements.push(conversionBranches.join(" else "));
|
|
162
|
+
return statements;
|
|
174
163
|
}
|
|
175
164
|
fromJsonStatements({ variables, }) {
|
|
176
165
|
return [
|
|
@@ -182,30 +171,20 @@ export class IdentifierProperty extends Property {
|
|
|
182
171
|
// Treat sh:in as a union of the IRIs
|
|
183
172
|
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
184
173
|
return [
|
|
185
|
-
`let ${this.name}: ${this.
|
|
186
|
-
`switch (${variables.resource}.identifier.value) { ${this.type.in_.map((iri) => `case "${iri.value}": ${this.name} = ${
|
|
174
|
+
`let ${this.name}: ${this.typeAlias};`,
|
|
175
|
+
`switch (${variables.resource}.identifier.value) { ${this.type.in_.map((iri) => `case "${iri.value}": ${this.name} = ${rdfjsTermExpression(iri)}; break;`).join(" ")} default: return purify.Left(new rdfjsResource.Resource.MistypedValueError({ actualValue: ${variables.resource}.identifier, expectedValueType: ${JSON.stringify(this.type.name)}, focusResource: ${variables.resource}, predicate: ${rdfjsTermExpression(rdf.subject)} })); }`,
|
|
187
176
|
];
|
|
188
177
|
}
|
|
189
|
-
|
|
178
|
+
const statements = [];
|
|
179
|
+
if (this.type.isNamedNodeKind) {
|
|
180
|
+
statements.push(`if (${variables.resource}.identifier.termType !== "NamedNode") { return purify.Left(new rdfjsResource.Resource.MistypedValueError({ actualValue: ${variables.resource}.identifier, expectedValueType: ${JSON.stringify(this.type.name)}, focusResource: ${variables.resource}, predicate: ${rdfjsTermExpression(rdf.subject)} })); }`);
|
|
181
|
+
}
|
|
182
|
+
statements.push(`const ${this.name}: ${this.typeAlias} = ${variables.resource}.identifier;`);
|
|
183
|
+
return statements;
|
|
190
184
|
}
|
|
191
185
|
hashStatements({ variables, }) {
|
|
192
186
|
return [`${variables.hasher}.update(${variables.value}.value);`];
|
|
193
187
|
}
|
|
194
|
-
interfaceConstructorStatements({ variables, }) {
|
|
195
|
-
const typeConversions = this.type.conversions;
|
|
196
|
-
if (typeConversions.length === 1) {
|
|
197
|
-
return [`const ${this.name} = ${variables.parameter};`];
|
|
198
|
-
}
|
|
199
|
-
const statements = [`let ${this.name}: ${this.type.name};`];
|
|
200
|
-
const conversionBranches = [];
|
|
201
|
-
for (const conversion of this.type.conversions) {
|
|
202
|
-
conversionBranches.push(`if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { ${this.name} = ${conversion.conversionExpression(variables.parameter)}; }`);
|
|
203
|
-
}
|
|
204
|
-
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
205
|
-
conversionBranches.push(`{ ${this.name} =( ${variables.parameter}) as never;\n }`);
|
|
206
|
-
statements.push(conversionBranches.join(" else "));
|
|
207
|
-
return statements;
|
|
208
|
-
}
|
|
209
188
|
jsonUiSchemaElement({ variables, }) {
|
|
210
189
|
return Maybe.of(`{ label: "Identifier", scope: \`\${${variables.scopePrefix}}/properties/${this.jsonPropertySignature.unsafeCoerce().name}\`, type: "Control" }`);
|
|
211
190
|
}
|
|
@@ -224,6 +203,55 @@ export class IdentifierProperty extends Property {
|
|
|
224
203
|
schema,
|
|
225
204
|
});
|
|
226
205
|
}
|
|
206
|
+
get propertyDeclaration() {
|
|
207
|
+
if (this.abstract) {
|
|
208
|
+
// Abstract version of the accessor
|
|
209
|
+
// Work around a ts-morph bug that puts the override keyword before the abstract keyword
|
|
210
|
+
return Maybe.of({
|
|
211
|
+
hasOverrideKeyword: this.abstract && this.override ? undefined : this.override,
|
|
212
|
+
isAbstract: this.abstract && this.override ? undefined : this.abstract,
|
|
213
|
+
isReadonly: true,
|
|
214
|
+
leadingTrivia: this.abstract && this.override ? "abstract override " : undefined,
|
|
215
|
+
name: this.name,
|
|
216
|
+
type: this.typeAlias,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
// See note in TypeFactory re: the logic of whether to declare the identifier in the class or not.
|
|
220
|
+
if (!this.classPropertyDeclarationVisibility.isJust()) {
|
|
221
|
+
return Maybe.empty();
|
|
222
|
+
}
|
|
223
|
+
if (this.identifierMintingStrategy.isJust()) {
|
|
224
|
+
// Mutable _identifier property that will be lazily initialized by the getter to mint the identifier
|
|
225
|
+
return Maybe.of({
|
|
226
|
+
hasQuestionToken: true,
|
|
227
|
+
name: `_${this.name}`,
|
|
228
|
+
scope: this.classPropertyDeclarationVisibility
|
|
229
|
+
.map(Property.visibilityToScope)
|
|
230
|
+
.unsafeCoerce(),
|
|
231
|
+
type: `${this.typeAlias}`,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
// Immutable, public identifier property, no getter
|
|
235
|
+
return Maybe.of({
|
|
236
|
+
isReadonly: true,
|
|
237
|
+
name: this.name,
|
|
238
|
+
type: this.typeAlias,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
get propertySignature() {
|
|
242
|
+
return Maybe.of({
|
|
243
|
+
isReadonly: true,
|
|
244
|
+
name: this.name,
|
|
245
|
+
type: this.typeAlias,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
snippetDeclarations() {
|
|
249
|
+
const snippetDeclarations = [];
|
|
250
|
+
if (this.objectType.features.has("equals")) {
|
|
251
|
+
snippetDeclarations.push(SnippetDeclarations.booleanEquals);
|
|
252
|
+
}
|
|
253
|
+
return snippetDeclarations;
|
|
254
|
+
}
|
|
227
255
|
sparqlConstructTemplateTriples() {
|
|
228
256
|
return [];
|
|
229
257
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import "ts-morph";
|
|
3
|
+
import type { TsFeature } from "../../../enums/TsFeature.js";
|
|
4
|
+
import { Import } from "../Import.js";
|
|
5
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
6
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
7
|
+
import type { OptionType } from "../OptionType.js";
|
|
8
|
+
import type { SetType } from "../SetType.js";
|
|
9
|
+
import { Type as _Type } from "../Type.js";
|
|
10
|
+
import { ShaclProperty } from "./ShaclProperty.js";
|
|
11
|
+
export declare class LazyShaclProperty<LazyTypeT extends LazyShaclProperty.Type<ResolvedTypeT, StubTypeT>, ResolvedTypeT extends LazyShaclProperty.Type.ResolvedTypeConstraint, StubTypeT extends LazyShaclProperty.Type.StubTypeConstraint> extends ShaclProperty<LazyTypeT> {
|
|
12
|
+
readonly mutable = false;
|
|
13
|
+
readonly recursive = false;
|
|
14
|
+
get graphqlField(): ShaclProperty<LazyShaclProperty.Type<StubTypeT, ResolvedTypeT>>["graphqlField"];
|
|
15
|
+
}
|
|
16
|
+
export declare namespace LazyShaclProperty {
|
|
17
|
+
export abstract class Type<ResolvedTypeT extends Type.ResolvedTypeConstraint, StubTypeT extends Type.StubTypeConstraint> extends _Type {
|
|
18
|
+
readonly discriminatorProperty: _Type["discriminatorProperty"];
|
|
19
|
+
readonly mutable = false;
|
|
20
|
+
readonly typeof = "object";
|
|
21
|
+
protected readonly resolvedType: ResolvedTypeT;
|
|
22
|
+
protected readonly runtimeClass: {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly rawName: string;
|
|
25
|
+
readonly snippetDeclaration: string;
|
|
26
|
+
readonly stubPropertyName: string;
|
|
27
|
+
};
|
|
28
|
+
protected readonly stubType: StubTypeT;
|
|
29
|
+
constructor({ stubType, resolvedType, runtimeClass, }: {
|
|
30
|
+
stubType: StubTypeT;
|
|
31
|
+
resolvedType: ResolvedTypeT;
|
|
32
|
+
runtimeClass: Type<ResolvedTypeT, StubTypeT>["runtimeClass"];
|
|
33
|
+
});
|
|
34
|
+
get conversions(): readonly _Type.Conversion[];
|
|
35
|
+
get equalsFunction(): string;
|
|
36
|
+
get graphqlName(): _Type.GraphqlName;
|
|
37
|
+
graphqlResolveExpression({ variables, }: Parameters<_Type["graphqlResolveExpression"]>[0]): string;
|
|
38
|
+
hashStatements({ depth, variables, }: Parameters<_Type["hashStatements"]>[0]): readonly string[];
|
|
39
|
+
get jsonName(): _Type.JsonName;
|
|
40
|
+
jsonUiSchemaElement(parameters: Parameters<_Type["jsonUiSchemaElement"]>[0]): Maybe<string>;
|
|
41
|
+
jsonZodSchema(parameters: Parameters<_Type["jsonZodSchema"]>[0]): string;
|
|
42
|
+
get name(): string;
|
|
43
|
+
snippetDeclarations(parameters: Parameters<_Type["snippetDeclarations"]>[0]): readonly string[];
|
|
44
|
+
sparqlConstructTemplateTriples(parameters: Parameters<_Type["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
45
|
+
sparqlWherePatterns(parameters: Parameters<_Type["sparqlWherePatterns"]>[0]): readonly string[];
|
|
46
|
+
toJsonExpression({ variables, }: Parameters<_Type["toJsonExpression"]>[0]): string;
|
|
47
|
+
toRdfExpression({ variables, }: Parameters<_Type["toRdfExpression"]>[0]): string;
|
|
48
|
+
useImports(parameters: {
|
|
49
|
+
features: Set<TsFeature>;
|
|
50
|
+
}): readonly Import[];
|
|
51
|
+
}
|
|
52
|
+
export namespace Type {
|
|
53
|
+
type ResolvedTypeConstraint = ObjectType | ObjectUnionType | OptionType<ObjectType | ObjectUnionType> | SetType<ObjectType | ObjectUnionType>;
|
|
54
|
+
type StubTypeConstraint = ResolvedTypeConstraint;
|
|
55
|
+
}
|
|
56
|
+
export class ObjectSetType<ResolvedTypeT extends SetType<ObjectType | ObjectUnionType>, StubTypeT extends SetType<ObjectType | ObjectUnionType>> extends Type<ResolvedTypeT, StubTypeT> {
|
|
57
|
+
constructor({ resolvedType, stubType, }: {
|
|
58
|
+
resolvedType: ResolvedTypeT;
|
|
59
|
+
stubType: StubTypeT;
|
|
60
|
+
});
|
|
61
|
+
get conversions(): readonly _Type.Conversion[];
|
|
62
|
+
fromJsonExpression(parameters: Parameters<_Type["fromJsonExpression"]>[0]): string;
|
|
63
|
+
fromRdfExpression(parameters: Parameters<_Type["fromRdfExpression"]>[0]): string;
|
|
64
|
+
}
|
|
65
|
+
abstract class SingleObjectType<ResolvedTypeT extends Exclude<Type.ResolvedTypeConstraint, SetType<ObjectType | ObjectUnionType>>, StubTypeT extends Exclude<Type.StubTypeConstraint, SetType<ObjectType | ObjectUnionType>>> extends Type<ResolvedTypeT, StubTypeT> {
|
|
66
|
+
fromJsonExpression(parameters: Parameters<_Type["fromJsonExpression"]>[0]): string;
|
|
67
|
+
}
|
|
68
|
+
export class OptionalObjectType<ResolvedTypeT extends OptionType<ObjectType | ObjectUnionType>, StubTypeT extends OptionType<ObjectType | ObjectUnionType>> extends SingleObjectType<ResolvedTypeT, StubTypeT> {
|
|
69
|
+
constructor({ resolvedType, stubType, }: {
|
|
70
|
+
resolvedType: ResolvedTypeT;
|
|
71
|
+
stubType: StubTypeT;
|
|
72
|
+
});
|
|
73
|
+
get conversions(): readonly _Type.Conversion[];
|
|
74
|
+
fromRdfExpression(parameters: Parameters<_Type["fromRdfExpression"]>[0]): string;
|
|
75
|
+
graphqlResolveExpression(parameters: Parameters<_Type["graphqlResolveExpression"]>[0]): string;
|
|
76
|
+
}
|
|
77
|
+
export class RequiredObjectType<ResolvedTypeT extends ObjectType | ObjectUnionType, StubTypeT extends ObjectType | ObjectUnionType> extends SingleObjectType<ResolvedTypeT, StubTypeT> {
|
|
78
|
+
constructor({ resolvedType, stubType, }: {
|
|
79
|
+
resolvedType: ResolvedTypeT;
|
|
80
|
+
stubType: StubTypeT;
|
|
81
|
+
});
|
|
82
|
+
get conversions(): readonly _Type.Conversion[];
|
|
83
|
+
fromRdfExpression(parameters: Parameters<_Type["fromRdfExpression"]>[0]): string;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=LazyShaclProperty.d.ts.map
|