@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
|
@@ -3,14 +3,17 @@ import TermSet from "@rdfjs/term-set";
|
|
|
3
3
|
import { rdf, xsd } from "@tpluscode/rdf-ns-builders";
|
|
4
4
|
import { Maybe } from "purify-ts";
|
|
5
5
|
import { fromRdf } from "rdf-literal";
|
|
6
|
+
import { invariant } from "ts-invariant";
|
|
7
|
+
import { Scope } from "ts-morph";
|
|
6
8
|
import { logger } from "../../logger.js";
|
|
7
9
|
import { BooleanType } from "./BooleanType.js";
|
|
8
10
|
import { DateTimeType } from "./DateTimeType.js";
|
|
9
11
|
import { DateType } from "./DateType.js";
|
|
12
|
+
import { FloatType } from "./FloatType.js";
|
|
10
13
|
import { IdentifierType } from "./IdentifierType.js";
|
|
14
|
+
import { IntType } from "./IntType.js";
|
|
11
15
|
import { ListType } from "./ListType.js";
|
|
12
16
|
import { LiteralType } from "./LiteralType.js";
|
|
13
|
-
import { NumberType } from "./NumberType.js";
|
|
14
17
|
import { ObjectType } from "./ObjectType.js";
|
|
15
18
|
import { ObjectUnionType } from "./ObjectUnionType.js";
|
|
16
19
|
import { OptionType } from "./OptionType.js";
|
|
@@ -18,42 +21,163 @@ import { SetType } from "./SetType.js";
|
|
|
18
21
|
import { StringType } from "./StringType.js";
|
|
19
22
|
import { TermType } from "./TermType.js";
|
|
20
23
|
import { UnionType } from "./UnionType.js";
|
|
24
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
21
25
|
import { tsName } from "./tsName.js";
|
|
22
|
-
function objectTypeNeedsIdentifierPrefixProperty(objectType) {
|
|
23
|
-
return objectType.identifierMintingStrategy
|
|
24
|
-
.map((identifierMintingStrategy) => {
|
|
25
|
-
switch (identifierMintingStrategy) {
|
|
26
|
-
case "blankNode":
|
|
27
|
-
return false;
|
|
28
|
-
case "sha256":
|
|
29
|
-
case "uuidv4":
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
.orDefault(false);
|
|
34
|
-
}
|
|
35
26
|
export class TypeFactory {
|
|
36
27
|
cachedObjectTypePropertiesByIdentifier = new TermMap();
|
|
37
28
|
cachedObjectTypesByIdentifier = new TermMap();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
cachedObjectUnionTypesByIdentifier = new TermMap();
|
|
30
|
+
createObjectTypeFromAstType(astType) {
|
|
31
|
+
{
|
|
32
|
+
const cachedObjectType = this.cachedObjectTypesByIdentifier.get(astType.name.identifier);
|
|
33
|
+
if (cachedObjectType) {
|
|
34
|
+
return cachedObjectType;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const identifierType = new IdentifierType({
|
|
38
|
+
defaultValue: Maybe.empty(),
|
|
39
|
+
hasValues: [],
|
|
40
|
+
in_: astType.identifierIn,
|
|
41
|
+
nodeKinds: astType.identifierNodeKinds,
|
|
42
|
+
});
|
|
43
|
+
const staticModuleName = astType.childObjectTypes.length > 0
|
|
44
|
+
? `${tsName(astType.name)}Static`
|
|
45
|
+
: tsName(astType.name);
|
|
46
|
+
const objectType = new ObjectType({
|
|
47
|
+
abstract: astType.abstract,
|
|
48
|
+
comment: astType.comment,
|
|
49
|
+
declarationType: astType.tsObjectDeclarationType,
|
|
50
|
+
export_: astType.export,
|
|
51
|
+
extern: astType.extern,
|
|
52
|
+
features: astType.tsFeatures,
|
|
53
|
+
fromRdfType: astType.fromRdfType,
|
|
54
|
+
imports: astType.tsImports,
|
|
55
|
+
label: astType.label,
|
|
56
|
+
lazyAncestorObjectTypes: () => astType.ancestorObjectTypes.map((astType) => this.createObjectTypeFromAstType(astType)),
|
|
57
|
+
lazyChildObjectTypes: () => astType.childObjectTypes.map((astType) => this.createObjectTypeFromAstType(astType)),
|
|
58
|
+
lazyDescendantObjectTypes: () => astType.descendantObjectTypes.map((astType) => this.createObjectTypeFromAstType(astType)),
|
|
59
|
+
lazyParentObjectTypes: () => astType.parentObjectTypes.map((astType) => this.createObjectTypeFromAstType(astType)),
|
|
60
|
+
lazyProperties: (objectType) => {
|
|
61
|
+
const properties = astType.properties
|
|
62
|
+
.toSorted((left, right) => {
|
|
63
|
+
if (left.order < right.order) {
|
|
64
|
+
return -1;
|
|
65
|
+
}
|
|
66
|
+
if (left.order > right.order) {
|
|
67
|
+
return 1;
|
|
68
|
+
}
|
|
69
|
+
return tsName(left.name).localeCompare(tsName(right.name));
|
|
70
|
+
})
|
|
71
|
+
.map((astProperty) => this.createObjectTypePropertyFromAstProperty({
|
|
72
|
+
astObjectTypeProperty: astProperty,
|
|
73
|
+
objectType,
|
|
74
|
+
}));
|
|
75
|
+
// Type discriminator property
|
|
76
|
+
const typeDiscriminatorOwnValue = !astType.abstract
|
|
77
|
+
? objectType.discriminatorValue
|
|
78
|
+
: undefined;
|
|
79
|
+
const typeDiscriminatorDescendantValues = new Set();
|
|
80
|
+
for (const descendantObjectType of objectType.descendantObjectTypes) {
|
|
81
|
+
if (!descendantObjectType.abstract) {
|
|
82
|
+
typeDiscriminatorDescendantValues.add(descendantObjectType.discriminatorValue);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (typeDiscriminatorOwnValue ||
|
|
86
|
+
typeDiscriminatorDescendantValues.size > 0) {
|
|
87
|
+
properties.splice(0, 0, new ObjectType.TypeDiscriminatorProperty({
|
|
88
|
+
abstract: astType.abstract,
|
|
89
|
+
name: `${syntheticNamePrefix}type`,
|
|
90
|
+
initializer: objectType.discriminatorValue,
|
|
91
|
+
objectType,
|
|
92
|
+
override: objectType.parentObjectTypes.length > 0,
|
|
93
|
+
type: new ObjectType.TypeDiscriminatorProperty.Type({
|
|
94
|
+
descendantValues: [...typeDiscriminatorDescendantValues].sort(),
|
|
95
|
+
mutable: false,
|
|
96
|
+
ownValues: typeDiscriminatorOwnValue
|
|
97
|
+
? [typeDiscriminatorOwnValue]
|
|
98
|
+
: [],
|
|
99
|
+
}),
|
|
100
|
+
visibility: "public",
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
// Some ObjectTypes have an identifierPrefix property, depending on their identifier minting strategy.
|
|
104
|
+
if (objectTypeNeedsIdentifierPrefixProperty(astType)) {
|
|
105
|
+
properties.splice(0, 0, new ObjectType.IdentifierPrefixProperty({
|
|
106
|
+
own: !astType.ancestorObjectTypes.some(objectTypeNeedsIdentifierPrefixProperty),
|
|
107
|
+
name: `${syntheticNamePrefix}identifierPrefix`,
|
|
108
|
+
objectType,
|
|
109
|
+
type: new StringType({
|
|
110
|
+
defaultValue: Maybe.empty(),
|
|
111
|
+
hasValues: [],
|
|
112
|
+
in_: [],
|
|
113
|
+
languageIn: [],
|
|
114
|
+
primitiveDefaultValue: Maybe.empty(),
|
|
115
|
+
primitiveIn: [],
|
|
116
|
+
}),
|
|
117
|
+
visibility: "protected",
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
// Every ObjectType has an identifier property. Some are abstract.
|
|
121
|
+
properties.splice(0, 0, new ObjectType.IdentifierProperty({
|
|
122
|
+
abstract: astType.abstract,
|
|
123
|
+
classGetAccessorScope: (() => {
|
|
124
|
+
if (astType.abstract) {
|
|
125
|
+
return Maybe.empty();
|
|
126
|
+
}
|
|
127
|
+
if (astType.identifierMintingStrategy.isJust() ||
|
|
128
|
+
astType.ancestorObjectTypes.some((ancestorObjectType) => ancestorObjectType.identifierMintingStrategy.isJust())) {
|
|
129
|
+
return Maybe.of(Scope.Public);
|
|
130
|
+
}
|
|
131
|
+
return Maybe.empty();
|
|
132
|
+
})(),
|
|
133
|
+
classPropertyDeclarationVisibility: (() => {
|
|
134
|
+
if (astType.abstract) {
|
|
135
|
+
// If the type is abstract, don't declare an identifier property.
|
|
136
|
+
return Maybe.empty();
|
|
137
|
+
}
|
|
138
|
+
if (astType.ancestorObjectTypes.some((ancestorObjectType) => !ancestorObjectType.abstract)) {
|
|
139
|
+
// If the type has a non-abstract ancestor, that ancestor will declare the identifier property.
|
|
140
|
+
return Maybe.empty();
|
|
141
|
+
}
|
|
142
|
+
if (astType.descendantObjectTypes.some((descendantObjectType) => !descendantObjectType.abstract)) {
|
|
143
|
+
// If the type has a non-abstract descendant, declare the identifier property for it.
|
|
144
|
+
return Maybe.of("protected");
|
|
145
|
+
}
|
|
146
|
+
return Maybe.of("private");
|
|
147
|
+
})(),
|
|
148
|
+
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
149
|
+
identifierPrefixPropertyName: `${syntheticNamePrefix}identifierPrefix`,
|
|
150
|
+
name: `${syntheticNamePrefix}identifier`,
|
|
151
|
+
objectType,
|
|
152
|
+
override: astType.parentObjectTypes.length > 0,
|
|
153
|
+
type: identifierType,
|
|
154
|
+
typeAlias: `${staticModuleName}.${syntheticNamePrefix}Identifier`,
|
|
155
|
+
visibility: "public",
|
|
156
|
+
}));
|
|
157
|
+
return properties;
|
|
158
|
+
},
|
|
159
|
+
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
160
|
+
name: tsName(astType.name),
|
|
161
|
+
staticModuleName,
|
|
162
|
+
synthetic: astType.synthetic,
|
|
163
|
+
toRdfTypes: astType.toRdfTypes,
|
|
164
|
+
});
|
|
165
|
+
this.cachedObjectTypesByIdentifier.set(astType.name.identifier, objectType);
|
|
166
|
+
return objectType;
|
|
41
167
|
}
|
|
42
168
|
createTypeFromAstType(astType) {
|
|
43
169
|
switch (astType.kind) {
|
|
44
170
|
case "IdentifierType":
|
|
45
171
|
return new IdentifierType({
|
|
46
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
47
172
|
defaultValue: astType.defaultValue,
|
|
48
173
|
hasValues: astType.hasValues,
|
|
49
|
-
in_: astType.in_,
|
|
174
|
+
in_: astType.in_.filter((_) => _.termType === "NamedNode"),
|
|
50
175
|
nodeKinds: astType.nodeKinds,
|
|
51
176
|
});
|
|
52
177
|
case "IntersectionType":
|
|
53
178
|
throw new Error("not implemented");
|
|
54
179
|
case "ListType": {
|
|
55
180
|
return new ListType({
|
|
56
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
57
181
|
identifierNodeKind: astType.identifierNodeKind,
|
|
58
182
|
itemType: this.createTypeFromAstType(astType.itemType),
|
|
59
183
|
mutable: astType.mutable.orDefault(false),
|
|
@@ -78,7 +202,6 @@ export class TypeFactory {
|
|
|
78
202
|
const datatype = [...datatypes][0];
|
|
79
203
|
if (datatype.equals(xsd.boolean)) {
|
|
80
204
|
return new BooleanType({
|
|
81
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
82
205
|
defaultValue: astType.defaultValue,
|
|
83
206
|
hasValues: astType.hasValues,
|
|
84
207
|
languageIn: [],
|
|
@@ -93,7 +216,6 @@ export class TypeFactory {
|
|
|
93
216
|
}
|
|
94
217
|
if (datatype.equals(xsd.date) || datatype.equals(xsd.dateTime)) {
|
|
95
218
|
return new (datatype.equals(xsd.date) ? DateType : DateTimeType)({
|
|
96
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
97
219
|
defaultValue: astType.defaultValue,
|
|
98
220
|
hasValues: astType.hasValues,
|
|
99
221
|
in_: astType.in_,
|
|
@@ -106,45 +228,26 @@ export class TypeFactory {
|
|
|
106
228
|
.filter((value) => typeof value === "object" && value instanceof Date),
|
|
107
229
|
});
|
|
108
230
|
}
|
|
109
|
-
for (const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
xsd.decimal,
|
|
126
|
-
xsd.double,
|
|
127
|
-
xsd.float,
|
|
128
|
-
]) {
|
|
129
|
-
if (datatype.equals(numberDatatype)) {
|
|
130
|
-
return new NumberType({
|
|
131
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
132
|
-
defaultValue: astType.defaultValue,
|
|
133
|
-
hasValues: astType.hasValues,
|
|
134
|
-
in_: astType.in_,
|
|
135
|
-
languageIn: [],
|
|
136
|
-
primitiveDefaultValue: astType.defaultValue
|
|
137
|
-
.map((value) => fromRdf(value, true))
|
|
138
|
-
.filter((value) => typeof value === "number"),
|
|
139
|
-
primitiveIn: astType.in_
|
|
140
|
-
.map((value) => fromRdf(value, true))
|
|
141
|
-
.filter((value) => typeof value === "number"),
|
|
142
|
-
});
|
|
231
|
+
for (const [floatOrInt, numberDatatypes_] of Object.entries(numberDatatypes)) {
|
|
232
|
+
for (const numberDatatype of numberDatatypes_) {
|
|
233
|
+
if (datatype.equals(numberDatatype)) {
|
|
234
|
+
return new (floatOrInt === "float" ? FloatType : IntType)({
|
|
235
|
+
defaultValue: astType.defaultValue,
|
|
236
|
+
hasValues: astType.hasValues,
|
|
237
|
+
in_: astType.in_,
|
|
238
|
+
languageIn: [],
|
|
239
|
+
primitiveDefaultValue: astType.defaultValue
|
|
240
|
+
.map((value) => fromRdf(value, true))
|
|
241
|
+
.filter((value) => typeof value === "number"),
|
|
242
|
+
primitiveIn: astType.in_
|
|
243
|
+
.map((value) => fromRdf(value, true))
|
|
244
|
+
.filter((value) => typeof value === "number"),
|
|
245
|
+
});
|
|
246
|
+
}
|
|
143
247
|
}
|
|
144
248
|
}
|
|
145
249
|
if (datatype.equals(xsd.anyURI) || datatype.equals(xsd.string)) {
|
|
146
250
|
return new StringType({
|
|
147
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
148
251
|
defaultValue: astType.defaultValue,
|
|
149
252
|
hasValues: astType.hasValues,
|
|
150
253
|
languageIn: [],
|
|
@@ -167,7 +270,6 @@ export class TypeFactory {
|
|
|
167
270
|
logger.debug("literal type has no datatypes");
|
|
168
271
|
}
|
|
169
272
|
return new LiteralType({
|
|
170
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
171
273
|
defaultValue: astType.defaultValue,
|
|
172
274
|
hasValues: astType.hasValues,
|
|
173
275
|
in_: astType.in_,
|
|
@@ -179,205 +281,167 @@ export class TypeFactory {
|
|
|
179
281
|
case "ObjectType":
|
|
180
282
|
return this.createObjectTypeFromAstType(astType);
|
|
181
283
|
case "ObjectUnionType":
|
|
182
|
-
return
|
|
183
|
-
comment: astType.comment,
|
|
184
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
185
|
-
export_: astType.export,
|
|
186
|
-
features: astType.tsFeatures,
|
|
187
|
-
label: astType.label,
|
|
188
|
-
memberTypes: astType.memberTypes
|
|
189
|
-
.map((astType) => this.createTypeFromAstType(astType))
|
|
190
|
-
.filter((memberType) => memberType instanceof ObjectType),
|
|
191
|
-
name: tsName(astType.name),
|
|
192
|
-
});
|
|
284
|
+
return this.createObjectUnionTypeFromAstType(astType);
|
|
193
285
|
case "OptionType":
|
|
194
286
|
return new OptionType({
|
|
195
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
196
287
|
itemType: this.createTypeFromAstType(astType.itemType),
|
|
197
288
|
});
|
|
198
289
|
case "PlaceholderType":
|
|
199
290
|
throw new Error(astType.kind);
|
|
200
291
|
case "SetType":
|
|
201
292
|
return new SetType({
|
|
202
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
203
293
|
itemType: this.createTypeFromAstType(astType.itemType),
|
|
204
294
|
mutable: astType.mutable.orDefault(false),
|
|
205
295
|
minCount: astType.minCount,
|
|
206
296
|
});
|
|
207
297
|
case "TermType":
|
|
208
298
|
return new TermType({
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
nodeKinds: astType.nodeKinds,
|
|
299
|
+
defaultValue: astType["defaultValue"],
|
|
300
|
+
hasValues: astType["hasValues"],
|
|
301
|
+
in_: astType["in_"],
|
|
302
|
+
nodeKinds: astType["nodeKinds"],
|
|
214
303
|
});
|
|
215
304
|
case "UnionType":
|
|
216
305
|
return new UnionType({
|
|
217
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
218
306
|
memberTypes: astType.memberTypes.map((astType) => this.createTypeFromAstType(astType)),
|
|
219
307
|
});
|
|
220
308
|
}
|
|
221
309
|
}
|
|
222
|
-
|
|
310
|
+
createObjectTypePropertyFromAstProperty({ astObjectTypeProperty, objectType, }) {
|
|
223
311
|
{
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
return
|
|
312
|
+
const cachedProperty = this.cachedObjectTypePropertiesByIdentifier.get(astObjectTypeProperty.name.identifier);
|
|
313
|
+
if (cachedProperty) {
|
|
314
|
+
return cachedProperty;
|
|
227
315
|
}
|
|
228
316
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
317
|
+
let property;
|
|
318
|
+
const name = tsName(astObjectTypeProperty.name);
|
|
319
|
+
if (astObjectTypeProperty.stubType.isJust()) {
|
|
320
|
+
const resolvedType = this.createTypeFromAstType(astObjectTypeProperty.type);
|
|
321
|
+
let lazyType;
|
|
322
|
+
const stubType = this.createTypeFromAstType(astObjectTypeProperty.stubType.unsafeCoerce());
|
|
323
|
+
if (resolvedType instanceof OptionType) {
|
|
324
|
+
invariant(resolvedType.itemType instanceof ObjectType ||
|
|
325
|
+
resolvedType.itemType instanceof ObjectUnionType, `lazy property ${name} on ${objectType.name} has ${resolvedType.kind} ${resolvedType.itemType.kind} items`);
|
|
326
|
+
invariant(stubType instanceof OptionType, `lazy property ${name} on ${objectType.name} has ${stubType.kind} stubs`);
|
|
327
|
+
lazyType = new ObjectType.LazyShaclProperty.OptionalObjectType({
|
|
328
|
+
resolvedType,
|
|
329
|
+
stubType,
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
else if (resolvedType instanceof SetType) {
|
|
333
|
+
invariant(resolvedType.itemType instanceof ObjectType ||
|
|
334
|
+
resolvedType.itemType instanceof ObjectUnionType, `lazy property ${name} on ${objectType.name} has ${resolvedType.kind} ${resolvedType.itemType.kind} items`);
|
|
335
|
+
invariant(stubType instanceof SetType, `lazy property ${name} on ${objectType.name} has ${stubType.kind} stubs`);
|
|
336
|
+
lazyType = new ObjectType.LazyShaclProperty.ObjectSetType({
|
|
337
|
+
resolvedType,
|
|
338
|
+
stubType,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
invariant(resolvedType instanceof ObjectType ||
|
|
343
|
+
resolvedType instanceof ObjectUnionType, `lazy property ${name} on ${objectType.name} has ${resolvedType.kind}`);
|
|
344
|
+
invariant(stubType instanceof ObjectType || stubType instanceof ObjectUnionType, `lazy property ${name} on ${objectType.name} has ${stubType.kind} stubs`);
|
|
345
|
+
lazyType = new ObjectType.LazyShaclProperty.RequiredObjectType({
|
|
346
|
+
resolvedType,
|
|
347
|
+
stubType,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
property = new ObjectType.LazyShaclProperty({
|
|
351
|
+
comment: astObjectTypeProperty.comment,
|
|
352
|
+
description: astObjectTypeProperty.description,
|
|
353
|
+
label: astObjectTypeProperty.label,
|
|
354
|
+
objectType,
|
|
355
|
+
name,
|
|
356
|
+
path: astObjectTypeProperty.path.iri,
|
|
357
|
+
type: lazyType,
|
|
358
|
+
visibility: astObjectTypeProperty.visibility,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
property = new ObjectType.EagerShaclProperty({
|
|
363
|
+
comment: astObjectTypeProperty.comment,
|
|
364
|
+
description: astObjectTypeProperty.description,
|
|
365
|
+
label: astObjectTypeProperty.label,
|
|
366
|
+
mutable: astObjectTypeProperty.mutable.orDefault(false),
|
|
367
|
+
objectType,
|
|
368
|
+
name,
|
|
369
|
+
path: astObjectTypeProperty.path.iri,
|
|
370
|
+
recursive: !!astObjectTypeProperty.recursive,
|
|
371
|
+
type: this.createTypeFromAstType(astObjectTypeProperty.type),
|
|
372
|
+
visibility: astObjectTypeProperty.visibility,
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
this.cachedObjectTypePropertiesByIdentifier.set(astObjectTypeProperty.name.identifier, property);
|
|
376
|
+
return property;
|
|
377
|
+
}
|
|
378
|
+
createObjectUnionTypeFromAstType(astType) {
|
|
379
|
+
{
|
|
380
|
+
const cachedObjectUnionType = this.cachedObjectUnionTypesByIdentifier.get(astType.name.identifier);
|
|
381
|
+
if (cachedObjectUnionType) {
|
|
382
|
+
return cachedObjectUnionType;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
const memberTypes = astType.memberTypes
|
|
386
|
+
.map((astType) => this.createTypeFromAstType(astType))
|
|
387
|
+
.filter((memberType) => memberType instanceof ObjectType);
|
|
388
|
+
const memberIdentifierTypeNodeKinds = new Set();
|
|
389
|
+
const memberIdentifierTypesIn = new TermSet();
|
|
390
|
+
for (const memberType of memberTypes) {
|
|
391
|
+
for (const nodeKind of memberType.identifierType.nodeKinds) {
|
|
392
|
+
memberIdentifierTypeNodeKinds.add(nodeKind);
|
|
393
|
+
}
|
|
394
|
+
for (const in_ of memberType.identifierType.in_) {
|
|
395
|
+
memberIdentifierTypesIn.add(in_);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const objectUnionType = new ObjectUnionType({
|
|
238
399
|
comment: astType.comment,
|
|
239
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
240
|
-
declarationType: astType.tsObjectDeclarationType,
|
|
241
400
|
export_: astType.export,
|
|
242
|
-
extern: astType.extern,
|
|
243
401
|
features: astType.tsFeatures,
|
|
244
|
-
|
|
245
|
-
|
|
402
|
+
identifierType: new IdentifierType({
|
|
403
|
+
defaultValue: Maybe.empty(),
|
|
404
|
+
hasValues: [],
|
|
405
|
+
in_: [...memberIdentifierTypesIn],
|
|
406
|
+
nodeKinds: memberIdentifierTypeNodeKinds,
|
|
407
|
+
}),
|
|
246
408
|
label: astType.label,
|
|
247
|
-
|
|
248
|
-
lazyDescendantObjectTypes: () => astType.descendantObjectTypes.map((astType) => this.createObjectTypeFromAstType(astType)),
|
|
249
|
-
lazyParentObjectTypes: () => astType.parentObjectTypes.map((astType) => this.createObjectTypeFromAstType(astType)),
|
|
250
|
-
lazyProperties: () => {
|
|
251
|
-
const properties = astType.properties
|
|
252
|
-
.toSorted((left, right) => {
|
|
253
|
-
if (left.order < right.order) {
|
|
254
|
-
return -1;
|
|
255
|
-
}
|
|
256
|
-
if (left.order > right.order) {
|
|
257
|
-
return 1;
|
|
258
|
-
}
|
|
259
|
-
return tsName(left.name).localeCompare(tsName(right.name));
|
|
260
|
-
})
|
|
261
|
-
.map((astProperty) => this.createObjectTypePropertyFromAstProperty(astType, astProperty));
|
|
262
|
-
const lazyMutable = () => properties.some((property) => property.mutable || property.type.mutable);
|
|
263
|
-
// Type discriminator property
|
|
264
|
-
const typeDiscriminatorValues = new Set();
|
|
265
|
-
if (!astType.abstract) {
|
|
266
|
-
typeDiscriminatorValues.add(objectType.discriminatorValue);
|
|
267
|
-
}
|
|
268
|
-
for (const descendantObjectType of objectType.descendantObjectTypes) {
|
|
269
|
-
if (!descendantObjectType.abstract) {
|
|
270
|
-
typeDiscriminatorValues.add(descendantObjectType.discriminatorValue);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (typeDiscriminatorValues.size > 0) {
|
|
274
|
-
properties.splice(0, 0, new ObjectType.TypeDiscriminatorProperty({
|
|
275
|
-
abstract: astType.abstract,
|
|
276
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
277
|
-
name: astType.tsTypeDiscriminatorPropertyName,
|
|
278
|
-
objectType: {
|
|
279
|
-
declarationType: astType.tsObjectDeclarationType,
|
|
280
|
-
features: astType.tsFeatures,
|
|
281
|
-
mutable: lazyMutable,
|
|
282
|
-
},
|
|
283
|
-
override: objectType.parentObjectTypes.length > 0,
|
|
284
|
-
type: new ObjectType.TypeDiscriminatorProperty.Type({
|
|
285
|
-
mutable: false,
|
|
286
|
-
values: [...typeDiscriminatorValues].sort(),
|
|
287
|
-
}),
|
|
288
|
-
visibility: "public",
|
|
289
|
-
value: objectType.discriminatorValue,
|
|
290
|
-
}));
|
|
291
|
-
}
|
|
292
|
-
// Some ObjectTypes have an identifierPrefix property, depending on their identifier minting strategy.
|
|
293
|
-
if (objectTypeNeedsIdentifierPrefixProperty(astType)) {
|
|
294
|
-
properties.splice(0, 0, new ObjectType.IdentifierPrefixProperty({
|
|
295
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
296
|
-
own: !astType.ancestorObjectTypes.some(objectTypeNeedsIdentifierPrefixProperty),
|
|
297
|
-
name: astType.tsIdentifierPrefixPropertyName,
|
|
298
|
-
objectType: {
|
|
299
|
-
declarationType: astType.tsObjectDeclarationType,
|
|
300
|
-
features: astType.tsFeatures,
|
|
301
|
-
mutable: lazyMutable,
|
|
302
|
-
},
|
|
303
|
-
type: new StringType({
|
|
304
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
305
|
-
defaultValue: Maybe.empty(),
|
|
306
|
-
hasValues: [],
|
|
307
|
-
in_: [],
|
|
308
|
-
languageIn: [],
|
|
309
|
-
primitiveDefaultValue: Maybe.empty(),
|
|
310
|
-
primitiveIn: [],
|
|
311
|
-
}),
|
|
312
|
-
visibility: "protected",
|
|
313
|
-
}));
|
|
314
|
-
}
|
|
315
|
-
// Every ObjectType has an identifier property. Some are abstract.
|
|
316
|
-
properties.splice(0, 0, new ObjectType.IdentifierProperty({
|
|
317
|
-
abstract: astType.abstract,
|
|
318
|
-
classDeclarationVisibility: (() => {
|
|
319
|
-
if (astType.abstract) {
|
|
320
|
-
// If the type is abstract, don't declare an identifier property.
|
|
321
|
-
return Maybe.empty();
|
|
322
|
-
}
|
|
323
|
-
if (astType.ancestorObjectTypes.some((ancestorObjectType) => !ancestorObjectType.abstract)) {
|
|
324
|
-
// If the type has a non-abstract ancestor, that ancestor will declare the identifier property.
|
|
325
|
-
return Maybe.empty();
|
|
326
|
-
}
|
|
327
|
-
if (astType.descendantObjectTypes.some((descendantObjectType) => !descendantObjectType.abstract)) {
|
|
328
|
-
// If the type has a non-abstract descendant, declare the identifier property for it.
|
|
329
|
-
return Maybe.of("protected");
|
|
330
|
-
}
|
|
331
|
-
return Maybe.of("private");
|
|
332
|
-
})(),
|
|
333
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
334
|
-
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
335
|
-
name: astType.tsIdentifierPropertyName,
|
|
336
|
-
objectType: {
|
|
337
|
-
declarationType: astType.tsObjectDeclarationType,
|
|
338
|
-
features: astType.tsFeatures,
|
|
339
|
-
mutable: lazyMutable,
|
|
340
|
-
},
|
|
341
|
-
override: astType.parentObjectTypes.length > 0,
|
|
342
|
-
type: identifierType,
|
|
343
|
-
visibility: "public",
|
|
344
|
-
}));
|
|
345
|
-
return properties;
|
|
346
|
-
},
|
|
347
|
-
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
409
|
+
memberTypes,
|
|
348
410
|
name: tsName(astType.name),
|
|
349
|
-
toRdfTypes: astType.toRdfTypes,
|
|
350
411
|
});
|
|
351
|
-
this.
|
|
352
|
-
return
|
|
412
|
+
this.cachedObjectUnionTypesByIdentifier.set(astType.name.identifier, objectUnionType);
|
|
413
|
+
return objectUnionType;
|
|
353
414
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
415
|
+
}
|
|
416
|
+
function objectTypeNeedsIdentifierPrefixProperty(objectType) {
|
|
417
|
+
return objectType.identifierMintingStrategy
|
|
418
|
+
.map((identifierMintingStrategy) => {
|
|
419
|
+
switch (identifierMintingStrategy) {
|
|
420
|
+
case "blankNode":
|
|
421
|
+
return false;
|
|
422
|
+
case "sha256":
|
|
423
|
+
case "uuidv4":
|
|
424
|
+
return true;
|
|
360
425
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
dataFactoryVariable: this.dataFactoryVariable,
|
|
364
|
-
description: astObjectTypeProperty.description,
|
|
365
|
-
label: astObjectTypeProperty.label,
|
|
366
|
-
mutable: astObjectTypeProperty.mutable.orDefault(false),
|
|
367
|
-
objectType: {
|
|
368
|
-
declarationType: astObjectType.tsObjectDeclarationType,
|
|
369
|
-
features: astObjectType.tsFeatures,
|
|
370
|
-
mutable: () => {
|
|
371
|
-
throw new Error("not implemented");
|
|
372
|
-
},
|
|
373
|
-
},
|
|
374
|
-
name: tsName(astObjectTypeProperty.name),
|
|
375
|
-
path: astObjectTypeProperty.path.iri,
|
|
376
|
-
type: this.createTypeFromAstType(astObjectTypeProperty.type),
|
|
377
|
-
visibility: astObjectTypeProperty.visibility,
|
|
378
|
-
});
|
|
379
|
-
this.cachedObjectTypePropertiesByIdentifier.set(astObjectTypeProperty.name.identifier, property);
|
|
380
|
-
return property;
|
|
381
|
-
}
|
|
426
|
+
})
|
|
427
|
+
.orDefault(false);
|
|
382
428
|
}
|
|
429
|
+
const numberDatatypes = {
|
|
430
|
+
float: [xsd.decimal, xsd.double, xsd.float],
|
|
431
|
+
int: [
|
|
432
|
+
xsd.byte,
|
|
433
|
+
xsd.int,
|
|
434
|
+
xsd.integer,
|
|
435
|
+
xsd.long,
|
|
436
|
+
xsd.negativeInteger,
|
|
437
|
+
xsd.nonNegativeInteger,
|
|
438
|
+
xsd.nonPositiveInteger,
|
|
439
|
+
xsd.positiveInteger,
|
|
440
|
+
xsd.short,
|
|
441
|
+
xsd.unsignedByte,
|
|
442
|
+
xsd.unsignedInt,
|
|
443
|
+
xsd.unsignedLong,
|
|
444
|
+
xsd.unsignedShort,
|
|
445
|
+
],
|
|
446
|
+
};
|
|
383
447
|
//# sourceMappingURL=TypeFactory.js.map
|
|
@@ -1,32 +1,36 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import type { TsFeature } from "../../enums/index.js";
|
|
3
2
|
import type { Import } from "./Import.js";
|
|
4
3
|
import { Type } from "./Type.js";
|
|
5
4
|
export declare class UnionType extends Type {
|
|
5
|
+
private readonly _discriminator;
|
|
6
|
+
private readonly memberTypes;
|
|
7
|
+
private _name?;
|
|
6
8
|
readonly kind = "UnionType";
|
|
7
|
-
readonly
|
|
8
|
-
constructor({ memberTypes, name,
|
|
9
|
+
readonly typeof = "object";
|
|
10
|
+
constructor({ memberTypes, name, }: {
|
|
9
11
|
memberTypes: readonly Type[];
|
|
10
12
|
name?: string;
|
|
11
13
|
});
|
|
12
|
-
private _name?;
|
|
13
|
-
get name(): string;
|
|
14
14
|
get conversions(): readonly Type.Conversion[];
|
|
15
15
|
get discriminatorProperty(): Maybe<Type.DiscriminatorProperty>;
|
|
16
16
|
get equalsFunction(): string;
|
|
17
|
-
get
|
|
17
|
+
get graphqlName(): Type.GraphqlName;
|
|
18
|
+
get jsonName(): Type.JsonName;
|
|
18
19
|
get mutable(): boolean;
|
|
19
|
-
|
|
20
|
-
private get memberTypeTraits();
|
|
20
|
+
get name(): string;
|
|
21
21
|
fromJsonExpression({ variables, }: Parameters<Type["fromJsonExpression"]>[0]): string;
|
|
22
|
-
fromRdfExpression(
|
|
22
|
+
fromRdfExpression({ variables, }: Parameters<Type["fromRdfExpression"]>[0]): string;
|
|
23
|
+
graphqlResolveExpression(_parameters: Parameters<Type["graphqlResolveExpression"]>[0]): string;
|
|
23
24
|
hashStatements({ depth, variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
25
|
+
jsonUiSchemaElement(): Maybe<string>;
|
|
24
26
|
jsonZodSchema({ variables, }: Parameters<Type["jsonZodSchema"]>[0]): ReturnType<Type["jsonZodSchema"]>;
|
|
27
|
+
snippetDeclarations(parameters: Parameters<Type["snippetDeclarations"]>[0]): readonly string[];
|
|
25
28
|
sparqlConstructTemplateTriples(parameters: Parameters<Type["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
26
29
|
sparqlWherePatterns(parameters: Parameters<Type["sparqlWherePatterns"]>[0]): readonly string[];
|
|
27
30
|
toJsonExpression({ variables, }: Parameters<Type["toJsonExpression"]>[0]): string;
|
|
28
31
|
toRdfExpression({ variables, }: Parameters<Type["toRdfExpression"]>[0]): string;
|
|
29
|
-
useImports(
|
|
32
|
+
useImports(parameters: Parameters<Type["useImports"]>[0]): readonly Import[];
|
|
33
|
+
private discriminatorVariable;
|
|
30
34
|
private ternaryExpression;
|
|
31
35
|
}
|
|
32
36
|
//# sourceMappingURL=UnionType.d.ts.map
|