@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
|
@@ -12,18 +12,26 @@ import { Import } from "./Import.js";
|
|
|
12
12
|
import { SnippetDeclarations } from "./SnippetDeclarations.js";
|
|
13
13
|
import { Type } from "./Type.js";
|
|
14
14
|
import { objectInitializer } from "./objectInitializer.js";
|
|
15
|
+
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
16
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
15
17
|
/**
|
|
16
18
|
* Abstract base class for IdentifierType and LiteralType.
|
|
19
|
+
*
|
|
20
|
+
* ConstantTermT is the type of sh:defaultValue, sh:hasValue, and sh:in.
|
|
21
|
+
* RuntimeTermT is the type of values at runtime.
|
|
22
|
+
*
|
|
23
|
+
* The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:defaultValue et al.
|
|
17
24
|
*/
|
|
18
25
|
export class TermType extends Type {
|
|
19
26
|
defaultValue;
|
|
20
|
-
equalsFunction =
|
|
27
|
+
equalsFunction = `${syntheticNamePrefix}booleanEquals`;
|
|
21
28
|
hasValues;
|
|
22
29
|
in_;
|
|
23
30
|
mutable = false;
|
|
24
31
|
nodeKinds;
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
typeof = "object";
|
|
33
|
+
constructor({ defaultValue, hasValues, in_, nodeKinds, }) {
|
|
34
|
+
super();
|
|
27
35
|
this.defaultValue = defaultValue;
|
|
28
36
|
this.hasValues = hasValues;
|
|
29
37
|
this.in_ = in_;
|
|
@@ -34,26 +42,26 @@ export class TermType extends Type {
|
|
|
34
42
|
const conversions = [];
|
|
35
43
|
if (this.nodeKinds.has("Literal")) {
|
|
36
44
|
conversions.push({
|
|
37
|
-
conversionExpression: (value) => `rdfLiteral.toRdf(${value}, ${objectInitializer({ dataFactory:
|
|
45
|
+
conversionExpression: (value) => `rdfLiteral.toRdf(${value}, ${objectInitializer({ dataFactory: "dataFactory" })})`,
|
|
38
46
|
sourceTypeCheckExpression: (value) => `typeof ${value} === "boolean"`,
|
|
39
47
|
sourceTypeName: "boolean",
|
|
40
48
|
}, {
|
|
41
|
-
conversionExpression: (value) => `rdfLiteral.toRdf(${value}, ${objectInitializer({ dataFactory:
|
|
49
|
+
conversionExpression: (value) => `rdfLiteral.toRdf(${value}, ${objectInitializer({ dataFactory: "dataFactory" })})`,
|
|
42
50
|
sourceTypeCheckExpression: (value) => `typeof ${value} === "object" && ${value} instanceof Date`,
|
|
43
51
|
sourceTypeName: "Date",
|
|
44
52
|
}, {
|
|
45
|
-
conversionExpression: (value) => `rdfLiteral.toRdf(${value}, ${objectInitializer({ dataFactory:
|
|
53
|
+
conversionExpression: (value) => `rdfLiteral.toRdf(${value}, ${objectInitializer({ dataFactory: "dataFactory" })})`,
|
|
46
54
|
sourceTypeCheckExpression: (value) => `typeof ${value} === "number"`,
|
|
47
55
|
sourceTypeName: "number",
|
|
48
56
|
}, {
|
|
49
|
-
conversionExpression: (value) =>
|
|
57
|
+
conversionExpression: (value) => `dataFactory.literal(${value})`,
|
|
50
58
|
sourceTypeCheckExpression: (value) => `typeof ${value} === "string"`,
|
|
51
59
|
sourceTypeName: "string",
|
|
52
60
|
});
|
|
53
61
|
}
|
|
54
62
|
this.defaultValue.ifJust((defaultValue) => {
|
|
55
63
|
conversions.push({
|
|
56
|
-
conversionExpression: () =>
|
|
64
|
+
conversionExpression: () => rdfjsTermExpression(defaultValue),
|
|
57
65
|
sourceTypeCheckExpression: (value) => `typeof ${value} === "undefined"`,
|
|
58
66
|
sourceTypeName: "undefined",
|
|
59
67
|
});
|
|
@@ -68,17 +76,21 @@ export class TermType extends Type {
|
|
|
68
76
|
get discriminatorProperty() {
|
|
69
77
|
return Maybe.of({
|
|
70
78
|
name: "termType",
|
|
79
|
+
ownValues: [...this.nodeKinds],
|
|
80
|
+
descendantValues: [],
|
|
71
81
|
type: "string",
|
|
72
|
-
values: [...this.nodeKinds],
|
|
73
82
|
});
|
|
74
83
|
}
|
|
84
|
+
get graphqlName() {
|
|
85
|
+
throw new Error("not implemented");
|
|
86
|
+
}
|
|
75
87
|
get jsonName() {
|
|
76
88
|
invariant(this.nodeKinds.has("Literal") &&
|
|
77
89
|
(this.nodeKinds.has("BlankNode") || this.nodeKinds.has("NamedNode")), "IdentifierType and LiteralType should override");
|
|
78
|
-
return `{ readonly "@id": string, readonly termType: ${[...this.nodeKinds]
|
|
90
|
+
return new Type.JsonName(`{ readonly "@id": string, readonly termType: ${[...this.nodeKinds]
|
|
79
91
|
.filter((nodeKind) => nodeKind !== "Literal")
|
|
80
92
|
.map((nodeKind) => `"${nodeKind}"`)
|
|
81
|
-
.join(" | ")} } | { readonly "@language"
|
|
93
|
+
.join(" | ")} } | { readonly "@language"?: string, readonly "@type"?: string, readonly "@value": string, readonly termType: "Literal" }`);
|
|
82
94
|
}
|
|
83
95
|
get name() {
|
|
84
96
|
return `(${[...this.nodeKinds]
|
|
@@ -92,13 +104,13 @@ export class TermType extends Type {
|
|
|
92
104
|
let valueToNodeKind;
|
|
93
105
|
switch (nodeKind) {
|
|
94
106
|
case "BlankNode":
|
|
95
|
-
valueToNodeKind =
|
|
107
|
+
valueToNodeKind = `dataFactory.blankNode(${variables.value}["@id"].substring(2))`;
|
|
96
108
|
break;
|
|
97
109
|
case "Literal":
|
|
98
|
-
valueToNodeKind =
|
|
110
|
+
valueToNodeKind = `dataFactory.literal(${variables.value}["@value"], typeof ${variables.value}["@language"] !== "undefined" ? ${variables.value}["@language"] : (typeof ${variables.value}["@type"] !== "undefined" ? dataFactory.namedNode(${variables.value}["@type"]) : undefined))`;
|
|
99
111
|
break;
|
|
100
112
|
case "NamedNode":
|
|
101
|
-
valueToNodeKind =
|
|
113
|
+
valueToNodeKind = `dataFactory.namedNode(${variables.value}["@id"])`;
|
|
102
114
|
break;
|
|
103
115
|
default:
|
|
104
116
|
throw new RangeError(nodeKind);
|
|
@@ -108,31 +120,54 @@ export class TermType extends Type {
|
|
|
108
120
|
: `((${variables.value}.termType === "${nodeKind}") ? (${valueToNodeKind}) : (${expression}))`;
|
|
109
121
|
}, "");
|
|
110
122
|
}
|
|
111
|
-
fromRdfExpression(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
//
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
fromRdfExpression(parameters) {
|
|
124
|
+
// invariant(
|
|
125
|
+
// this.nodeKinds.has("Literal") &&
|
|
126
|
+
// (this.nodeKinds.has("BlankNode") || this.nodeKinds.has("NamedNode")),
|
|
127
|
+
// "IdentifierType and LiteralType should override",
|
|
128
|
+
// );
|
|
129
|
+
const chain = this.fromRdfExpressionChain(parameters);
|
|
130
|
+
const { variables } = parameters;
|
|
131
|
+
return [
|
|
132
|
+
variables.resourceValues,
|
|
133
|
+
chain.defaultValue,
|
|
134
|
+
chain.hasValues,
|
|
135
|
+
chain.languageIn,
|
|
136
|
+
chain.valueTo,
|
|
137
|
+
]
|
|
138
|
+
.filter((_) => typeof _ !== "undefined")
|
|
139
|
+
.join(".");
|
|
140
|
+
}
|
|
141
|
+
fromRdfExpressionChain({ variables, }) {
|
|
142
|
+
let valueToExpression = "purify.Either.of<Error, rdfjs.BlankNode | rdfjs.Literal | rdfjs.NamedNode>(value.toTerm())";
|
|
143
|
+
if (this.nodeKinds.size < 3) {
|
|
144
|
+
const eitherTypeParameters = `<Error, ${this.name}>`;
|
|
145
|
+
valueToExpression = `${valueToExpression}.chain(term => {
|
|
146
|
+
switch (term.termType) {
|
|
147
|
+
${[...this.nodeKinds].map((nodeKind) => `case "${nodeKind}":`).join("\n")} return purify.Either.of${eitherTypeParameters}(term);
|
|
148
|
+
default: return purify.Left${eitherTypeParameters}(new rdfjsResource.Resource.MistypedValueError(${objectInitializer({ actualValue: "term", expectedValueType: JSON.stringify(this.name), focusResource: variables.resource, predicate: variables.predicate })}));
|
|
149
|
+
}})`;
|
|
121
150
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
151
|
+
return {
|
|
152
|
+
defaultValue: this.defaultValue
|
|
153
|
+
.map((defaultValue) => `map(values => values.length > 0 ? values : new rdfjsResource.Resource.Value(${objectInitializer({ subject: variables.resource, predicate: variables.predicate, object: rdfjsTermExpression(defaultValue) })}).toValues())`)
|
|
154
|
+
.extract(),
|
|
155
|
+
hasValues: this.hasValues.length > 0
|
|
156
|
+
? `chain(values => {
|
|
157
|
+
for (const hasValue of [${this.hasValues.map(rdfjsTermExpression).join(", ")}]) {
|
|
158
|
+
const findResult = values.find(value => value.toTerm().equals(hasValue));
|
|
159
|
+
if (findResult.isLeft()) {
|
|
160
|
+
return findResult;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return purify.Either.of<Error, rdfjsResource.Resource.Values<rdfjsResource.Resource.Value>>(values);
|
|
164
|
+
})`
|
|
165
|
+
: undefined,
|
|
166
|
+
valueTo: `chain(values => values.chainMap(value => ${valueToExpression}))`,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
graphqlResolveExpression(_parameters) {
|
|
170
|
+
throw new Error("not implemented");
|
|
136
171
|
}
|
|
137
172
|
hashStatements({ variables, }) {
|
|
138
173
|
return [
|
|
@@ -140,6 +175,9 @@ export class TermType extends Type {
|
|
|
140
175
|
`${variables.hasher}.update(${variables.value}.value);`,
|
|
141
176
|
];
|
|
142
177
|
}
|
|
178
|
+
jsonUiSchemaElement() {
|
|
179
|
+
return Maybe.empty();
|
|
180
|
+
}
|
|
143
181
|
jsonZodSchema({ variables, }) {
|
|
144
182
|
invariant(this.nodeKinds.has("Literal") &&
|
|
145
183
|
(this.nodeKinds.has("BlankNode") || this.nodeKinds.has("NamedNode")), "IdentifierType and LiteralType should override");
|
|
@@ -159,7 +197,7 @@ export class TermType extends Type {
|
|
|
159
197
|
})
|
|
160
198
|
.join(", ")}])`;
|
|
161
199
|
}
|
|
162
|
-
snippetDeclarations(features) {
|
|
200
|
+
snippetDeclarations({ features, }) {
|
|
163
201
|
const snippetDeclarations = [];
|
|
164
202
|
if (features.has("equals")) {
|
|
165
203
|
snippetDeclarations.push(SnippetDeclarations.booleanEquals);
|
|
@@ -168,13 +206,13 @@ export class TermType extends Type {
|
|
|
168
206
|
}
|
|
169
207
|
sparqlWherePatterns(parameters) {
|
|
170
208
|
switch (parameters.context) {
|
|
171
|
-
case "
|
|
209
|
+
case "object":
|
|
172
210
|
return this.defaultValue
|
|
173
211
|
.map(() => [
|
|
174
212
|
`{ patterns: [${super.sparqlWherePatterns(parameters).join(", ")}], type: "optional" }`,
|
|
175
213
|
])
|
|
176
214
|
.orDefault(super.sparqlWherePatterns(parameters));
|
|
177
|
-
case "
|
|
215
|
+
case "subject":
|
|
178
216
|
return super.sparqlWherePatterns(parameters);
|
|
179
217
|
}
|
|
180
218
|
}
|
|
@@ -203,7 +241,7 @@ export class TermType extends Type {
|
|
|
203
241
|
}
|
|
204
242
|
toRdfExpression({ variables, }) {
|
|
205
243
|
return this.defaultValue
|
|
206
|
-
.map((defaultValue) => `!${variables.value}.equals(${
|
|
244
|
+
.map((defaultValue) => `!${variables.value}.equals(${rdfjsTermExpression(defaultValue)}) ? ${variables.value} : undefined`)
|
|
207
245
|
.orDefault(variables.value);
|
|
208
246
|
}
|
|
209
247
|
useImports() {
|
|
@@ -213,33 +251,16 @@ export class TermType extends Type {
|
|
|
213
251
|
}
|
|
214
252
|
return imports;
|
|
215
253
|
}
|
|
216
|
-
/**
|
|
217
|
-
* Filter the rdfjsResource.Resource.Values to those that are relevant to the type.
|
|
218
|
-
*
|
|
219
|
-
* This is done before
|
|
220
|
-
*/
|
|
221
|
-
propertyFilterRdfResourceValuesExpression({ variables, }) {
|
|
222
|
-
return variables.resourceValues;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Convert an rdfjsResource.Resource.Value to a value of this type.
|
|
226
|
-
* @param variables
|
|
227
|
-
* @protected
|
|
228
|
-
*/
|
|
229
|
-
propertyFromRdfResourceValueExpression({ variables, }) {
|
|
230
|
-
invariant(this.nodeKinds.has("Literal") &&
|
|
231
|
-
(this.nodeKinds.has("BlankNode") || this.nodeKinds.has("NamedNode")), "IdentifierType and LiteralType should override");
|
|
232
|
-
let expression = `purify.Either.of(${variables.resourceValue}.toTerm())`;
|
|
233
|
-
if (this.nodeKinds.size < 3) {
|
|
234
|
-
expression = `${expression}.chain(term => {
|
|
235
|
-
switch (term.termType) {
|
|
236
|
-
${[...this.nodeKinds].map((nodeKind) => `case "${nodeKind}":`).join("\n")} return purify.Either.of(term);
|
|
237
|
-
default: return purify.Left(new rdfjsResource.Resource.MistypedValueError(${objectInitializer({ actualValue: "term", expectedValueType: JSON.stringify(this.name), focusResource: variables.resource, predicate: variables.predicate })}));
|
|
238
|
-
}})`;
|
|
239
|
-
}
|
|
240
|
-
return expression;
|
|
241
|
-
}
|
|
242
254
|
}
|
|
255
|
+
__decorate([
|
|
256
|
+
Memoize()
|
|
257
|
+
], TermType.prototype, "conversions", null);
|
|
258
|
+
__decorate([
|
|
259
|
+
Memoize()
|
|
260
|
+
], TermType.prototype, "discriminatorProperty", null);
|
|
261
|
+
__decorate([
|
|
262
|
+
Memoize()
|
|
263
|
+
], TermType.prototype, "jsonName", null);
|
|
243
264
|
__decorate([
|
|
244
265
|
Memoize()
|
|
245
266
|
], TermType.prototype, "name", null);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as ast from "../../ast/index.js";
|
|
2
2
|
import type { Generator } from "../Generator.js";
|
|
3
3
|
export declare class TsGenerator implements Generator {
|
|
4
|
+
private readonly typeFactory;
|
|
4
5
|
generate(ast_: ast.Ast): string;
|
|
5
|
-
private
|
|
6
|
+
private addStatements;
|
|
6
7
|
}
|
|
7
8
|
//# sourceMappingURL=TsGenerator.d.ts.map
|
|
@@ -3,23 +3,22 @@ import * as ast from "../../ast/index.js";
|
|
|
3
3
|
import { ObjectType } from "./ObjectType.js";
|
|
4
4
|
import { ObjectUnionType } from "./ObjectUnionType.js";
|
|
5
5
|
import { TypeFactory } from "./TypeFactory.js";
|
|
6
|
+
import { graphqlSchemaVariableStatement } from "./graphqlSchemaVariableStatement.js";
|
|
7
|
+
import { objectSetDeclarations } from "./objectSetDeclarations.js";
|
|
6
8
|
export class TsGenerator {
|
|
9
|
+
typeFactory = new TypeFactory();
|
|
7
10
|
generate(ast_) {
|
|
8
|
-
const sortedAstObjectTypes = ast.ObjectType.toposort(ast_.objectTypes);
|
|
9
11
|
const project = new Project({
|
|
10
12
|
useInMemoryFileSystem: true,
|
|
11
13
|
});
|
|
12
14
|
const sourceFile = project.createSourceFile("generated.ts");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.addDeclarations({
|
|
17
|
-
objectTypes: sortedAstObjectTypes.flatMap((astObjectType) => {
|
|
18
|
-
const type = typeFactory.createTypeFromAstType(astObjectType);
|
|
15
|
+
this.addStatements({
|
|
16
|
+
objectTypes: ast.ObjectType.toposort(ast_.objectTypes).flatMap((astObjectType) => {
|
|
17
|
+
const type = this.typeFactory.createTypeFromAstType(astObjectType);
|
|
19
18
|
return type instanceof ObjectType ? [type] : [];
|
|
20
19
|
}),
|
|
21
20
|
objectUnionTypes: ast_.objectUnionTypes.flatMap((astObjectUnionType) => {
|
|
22
|
-
const type = typeFactory.createTypeFromAstType(astObjectUnionType);
|
|
21
|
+
const type = this.typeFactory.createTypeFromAstType(astObjectUnionType);
|
|
23
22
|
return type instanceof ObjectUnionType ? [type] : [];
|
|
24
23
|
}),
|
|
25
24
|
sourceFile,
|
|
@@ -27,9 +26,12 @@ export class TsGenerator {
|
|
|
27
26
|
sourceFile.saveSync();
|
|
28
27
|
return project.getFileSystem().readFileSync(sourceFile.getFilePath());
|
|
29
28
|
}
|
|
30
|
-
|
|
29
|
+
addStatements({ objectTypes, objectUnionTypes, sourceFile, }) {
|
|
31
30
|
// sourceFile.addStatements(this.configuration.dataFactoryImport);
|
|
32
|
-
sourceFile.addStatements(
|
|
31
|
+
sourceFile.addStatements([
|
|
32
|
+
'import { DataFactory as dataFactory, StoreFactory as _DatasetFactory } from "n3";',
|
|
33
|
+
"const datasetFactory: rdfjs.DatasetCoreFactory = new _DatasetFactory();",
|
|
34
|
+
]);
|
|
33
35
|
const declaredTypes = [
|
|
34
36
|
...objectTypes,
|
|
35
37
|
...objectUnionTypes,
|
|
@@ -58,20 +60,32 @@ export class TsGenerator {
|
|
|
58
60
|
// Deduplicate and add snippet declarations
|
|
59
61
|
const addedSnippetDeclarations = new Set();
|
|
60
62
|
for (const declaredType of declaredTypes) {
|
|
61
|
-
for (const snippetDeclaration of declaredType.snippetDeclarations(
|
|
63
|
+
for (const snippetDeclaration of declaredType.snippetDeclarations({
|
|
64
|
+
features: declaredType.features,
|
|
65
|
+
recursionStack: [],
|
|
66
|
+
})) {
|
|
62
67
|
if (!addedSnippetDeclarations.has(snippetDeclaration)) {
|
|
63
68
|
sourceFile.addStatements([snippetDeclaration]);
|
|
64
69
|
addedSnippetDeclarations.add(snippetDeclaration);
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
|
-
// Add type declarations
|
|
69
73
|
for (const objectType of objectTypes) {
|
|
70
74
|
sourceFile.addStatements(objectType.declarations);
|
|
71
75
|
}
|
|
72
76
|
for (const objectUnionType of objectUnionTypes) {
|
|
73
77
|
sourceFile.addStatements(objectUnionType.declarations);
|
|
74
78
|
}
|
|
79
|
+
const objectTypesSortedByName = objectTypes.toSorted((left, right) => left.name.localeCompare(right.name));
|
|
80
|
+
const objectUnionTypesSortedByName = objectUnionTypes.toSorted((left, right) => left.name.localeCompare(right.name));
|
|
81
|
+
sourceFile.addStatements(objectSetDeclarations({
|
|
82
|
+
objectTypes: objectTypesSortedByName,
|
|
83
|
+
objectUnionTypes: objectUnionTypesSortedByName,
|
|
84
|
+
}));
|
|
85
|
+
sourceFile.addVariableStatements(graphqlSchemaVariableStatement({
|
|
86
|
+
objectTypes: objectTypesSortedByName,
|
|
87
|
+
objectUnionTypes: objectUnionTypesSortedByName,
|
|
88
|
+
}).toList());
|
|
75
89
|
}
|
|
76
90
|
}
|
|
77
91
|
//# sourceMappingURL=TsGenerator.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Maybe } from "purify-ts";
|
|
1
|
+
import type { Maybe } from "purify-ts";
|
|
3
2
|
import type { TsFeature } from "../../enums/index.js";
|
|
4
3
|
import type { Import } from "./Import.js";
|
|
5
4
|
/**
|
|
@@ -12,33 +11,38 @@ export declare abstract class Type {
|
|
|
12
11
|
* Expressions that convert a source type or types to this type. It should include the type itself.
|
|
13
12
|
*/
|
|
14
13
|
abstract readonly conversions: readonly Type.Conversion[];
|
|
14
|
+
/**
|
|
15
|
+
* A property that discriminates sub-types of this type e.g., termType on RDF/JS terms.
|
|
16
|
+
*/
|
|
17
|
+
abstract readonly discriminatorProperty: Maybe<Type.DiscriminatorProperty>;
|
|
15
18
|
/**
|
|
16
19
|
* A function (reference or declaration) that compares two property values of this type, returning a
|
|
17
|
-
* EqualsResult.
|
|
20
|
+
* $EqualsResult.
|
|
18
21
|
*/
|
|
19
22
|
abstract readonly equalsFunction: string;
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
24
|
+
* GraphQL-compatible version of the type.
|
|
22
25
|
*/
|
|
23
|
-
abstract readonly
|
|
26
|
+
abstract readonly graphqlName: Type.GraphqlName;
|
|
27
|
+
/**
|
|
28
|
+
* JSON-compatible version of the type.
|
|
29
|
+
*/
|
|
30
|
+
abstract readonly jsonName: Type.JsonName;
|
|
24
31
|
/**
|
|
25
32
|
* Is a value of this type mutable?
|
|
26
33
|
*/
|
|
27
34
|
abstract readonly mutable: boolean;
|
|
28
35
|
/**
|
|
29
|
-
*
|
|
36
|
+
* TypeScript name of the type.
|
|
30
37
|
*/
|
|
31
38
|
abstract readonly name: string;
|
|
32
|
-
protected readonly dataFactoryVariable: string;
|
|
33
|
-
constructor({ dataFactoryVariable, }: {
|
|
34
|
-
dataFactoryVariable: string;
|
|
35
|
-
});
|
|
36
39
|
/**
|
|
37
|
-
*
|
|
40
|
+
* JavaScript typeof the type.
|
|
38
41
|
*/
|
|
39
|
-
|
|
42
|
+
abstract readonly typeof: "boolean" | "object" | "number" | "string";
|
|
40
43
|
/**
|
|
41
|
-
* An expression that converts
|
|
44
|
+
* An expression that converts this type's JSON type to a value of this type. It doesn't return a purify.Either because the JSON has
|
|
45
|
+
* already been validated and converted to the expected JSON type with Zod.
|
|
42
46
|
*/
|
|
43
47
|
abstract fromJsonExpression(parameters: {
|
|
44
48
|
variables: {
|
|
@@ -46,18 +50,36 @@ export declare abstract class Type {
|
|
|
46
50
|
};
|
|
47
51
|
}): string;
|
|
48
52
|
/**
|
|
49
|
-
* An expression that converts a rdfjsResource.Resource.Values to
|
|
50
|
-
*
|
|
53
|
+
* An expression that converts a purify.Either<Error, rdfjsResource.Resource.Values<rdfjsResource.Resource.Value>> to
|
|
54
|
+
* (1) a purify.Either<Error, rdfjsResource.Resource.Values<this type>> if this is an item type (identifier, object, et al.) or
|
|
55
|
+
* (2) a purify.Either<Error, cardinality type> if this is a cardinality type
|
|
56
|
+
*
|
|
57
|
+
* Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
|
|
58
|
+
* to be considered valid. Similar
|
|
59
|
+
*
|
|
60
|
+
* Values may also need to be sorted. For example, applying sh:languageIn should sort the values in the order of the specified languages so that the first value
|
|
61
|
+
* (if it exists) is always of the first specified language -- a common situation when sh:maxCount is 1.
|
|
51
62
|
*/
|
|
52
63
|
abstract fromRdfExpression(parameters: {
|
|
53
64
|
variables: {
|
|
54
65
|
context: string;
|
|
66
|
+
ignoreRdfType?: boolean;
|
|
55
67
|
languageIn: string;
|
|
68
|
+
objectSet: string;
|
|
56
69
|
predicate: string;
|
|
57
70
|
resource: string;
|
|
58
71
|
resourceValues: string;
|
|
59
72
|
};
|
|
60
73
|
}): string;
|
|
74
|
+
/**
|
|
75
|
+
* An expression that resolves a value of this type in the GraphQL server.
|
|
76
|
+
*/
|
|
77
|
+
abstract graphqlResolveExpression(parameters: {
|
|
78
|
+
variables: {
|
|
79
|
+
args: string;
|
|
80
|
+
value: string;
|
|
81
|
+
};
|
|
82
|
+
}): string;
|
|
61
83
|
/**
|
|
62
84
|
* Statements that use hasher.update to hash a property value of this type.
|
|
63
85
|
*/
|
|
@@ -71,15 +93,22 @@ export declare abstract class Type {
|
|
|
71
93
|
/**
|
|
72
94
|
* Element object for a JSON Forms UI schema.
|
|
73
95
|
*/
|
|
74
|
-
jsonUiSchemaElement(
|
|
96
|
+
abstract jsonUiSchemaElement(parameters: {
|
|
75
97
|
variables: {
|
|
76
98
|
scopePrefix: string;
|
|
77
99
|
};
|
|
78
100
|
}): Maybe<string>;
|
|
79
101
|
/**
|
|
80
|
-
* Zod schema for the JSON
|
|
102
|
+
* Zod schema for the JSON type of this type.
|
|
103
|
+
*
|
|
104
|
+
* This method is called in two contexts:
|
|
105
|
+
* "property": from a ShaclProperty, while generating the z.object properties of an ObjectType
|
|
106
|
+
* "type": from another Type e.g., an OptionType or UnionType
|
|
107
|
+
*
|
|
108
|
+
* z.lazy() should only be returned for "property".
|
|
81
109
|
*/
|
|
82
110
|
abstract jsonZodSchema(parameters: {
|
|
111
|
+
context: "property" | "type";
|
|
83
112
|
variables: {
|
|
84
113
|
zod: string;
|
|
85
114
|
};
|
|
@@ -92,18 +121,22 @@ export declare abstract class Type {
|
|
|
92
121
|
*
|
|
93
122
|
* The generator deduplicates snippet declarations across all types before adding them to the source.
|
|
94
123
|
*/
|
|
95
|
-
snippetDeclarations(
|
|
124
|
+
abstract snippetDeclarations(parameters: {
|
|
125
|
+
features: Set<TsFeature>;
|
|
126
|
+
recursionStack: Type[];
|
|
127
|
+
}): readonly string[];
|
|
96
128
|
/**
|
|
97
129
|
* An array of SPARQL.js CONSTRUCT template triples for a value of this type, as strings (so they can incorporate runtime calls).
|
|
98
130
|
*
|
|
99
131
|
* This method is called in two contexts:
|
|
100
|
-
* (1)
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* Term types with no additional
|
|
104
|
-
*/
|
|
105
|
-
sparqlConstructTemplateTriples({ context, variables, }: {
|
|
106
|
-
|
|
132
|
+
* (1) When an instance of the type is an "object" of a property.
|
|
133
|
+
* This method should return a BGP (variables.subject, variables.predicate, variables.object) and recursively call itself with the variables.object as a "subject" context.
|
|
134
|
+
* (2) When an instance of the type is a "subject".
|
|
135
|
+
* For example, ListType calls this method to with the item variable as a subject in order to chain additional patterns on items. Term types with no additional patterns should return an empty array.
|
|
136
|
+
*/
|
|
137
|
+
sparqlConstructTemplateTriples({ allowIgnoreRdfType, context, variables, }: {
|
|
138
|
+
allowIgnoreRdfType: boolean;
|
|
139
|
+
context: "object";
|
|
107
140
|
variables: {
|
|
108
141
|
object: string;
|
|
109
142
|
predicate: string;
|
|
@@ -111,7 +144,8 @@ export declare abstract class Type {
|
|
|
111
144
|
variablePrefix: string;
|
|
112
145
|
};
|
|
113
146
|
} | {
|
|
114
|
-
|
|
147
|
+
allowIgnoreRdfType: boolean;
|
|
148
|
+
context: "subject";
|
|
115
149
|
variables: {
|
|
116
150
|
subject: string;
|
|
117
151
|
variablePrefix: string;
|
|
@@ -122,17 +156,21 @@ export declare abstract class Type {
|
|
|
122
156
|
*
|
|
123
157
|
* See note in sparqlConstructTemplateTriples re: how this method is used.
|
|
124
158
|
*/
|
|
125
|
-
sparqlWherePatterns({ context, variables, }: {
|
|
126
|
-
|
|
159
|
+
sparqlWherePatterns({ allowIgnoreRdfType, context, variables, }: {
|
|
160
|
+
allowIgnoreRdfType: boolean;
|
|
161
|
+
context: "object";
|
|
127
162
|
variables: {
|
|
163
|
+
languageIn: string;
|
|
128
164
|
object: string;
|
|
129
165
|
predicate: string;
|
|
130
166
|
subject: string;
|
|
131
167
|
variablePrefix: string;
|
|
132
168
|
};
|
|
133
169
|
} | {
|
|
134
|
-
|
|
170
|
+
allowIgnoreRdfType: boolean;
|
|
171
|
+
context: "subject";
|
|
135
172
|
variables: {
|
|
173
|
+
languageIn: string;
|
|
136
174
|
subject: string;
|
|
137
175
|
variablePrefix: string;
|
|
138
176
|
};
|
|
@@ -162,8 +200,9 @@ export declare abstract class Type {
|
|
|
162
200
|
/**
|
|
163
201
|
* Imports necessary to use this type.
|
|
164
202
|
*/
|
|
165
|
-
useImports(
|
|
166
|
-
|
|
203
|
+
abstract useImports(parameters: {
|
|
204
|
+
features: Set<TsFeature>;
|
|
205
|
+
}): readonly Import[];
|
|
167
206
|
}
|
|
168
207
|
export declare namespace Type {
|
|
169
208
|
interface Conversion {
|
|
@@ -173,7 +212,36 @@ export declare namespace Type {
|
|
|
173
212
|
}
|
|
174
213
|
interface DiscriminatorProperty {
|
|
175
214
|
readonly name: string;
|
|
176
|
-
readonly
|
|
215
|
+
readonly ownValues: readonly string[];
|
|
216
|
+
readonly descendantValues: readonly string[];
|
|
217
|
+
}
|
|
218
|
+
class JsonName {
|
|
219
|
+
/**
|
|
220
|
+
* Is the type optional in JSON? Equivalent to ? in TypeScript or | undefined.
|
|
221
|
+
*/
|
|
222
|
+
readonly optional: boolean;
|
|
223
|
+
/**
|
|
224
|
+
* The name of the type when it's required i.e. -- so it should never include "| undefined".
|
|
225
|
+
*/
|
|
226
|
+
readonly requiredName: string;
|
|
227
|
+
constructor(requiredName: string, parameters?: {
|
|
228
|
+
optional: boolean;
|
|
229
|
+
});
|
|
230
|
+
toString(): string;
|
|
231
|
+
}
|
|
232
|
+
class GraphqlName {
|
|
233
|
+
/**
|
|
234
|
+
* Is the type nullable in GraphQL?
|
|
235
|
+
*/
|
|
236
|
+
readonly nullable: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* The name of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
|
|
239
|
+
*/
|
|
240
|
+
readonly nullableName: string;
|
|
241
|
+
constructor(nullableName: string, parameters?: {
|
|
242
|
+
nullable: boolean;
|
|
243
|
+
});
|
|
244
|
+
toString(): string;
|
|
177
245
|
}
|
|
178
246
|
}
|
|
179
247
|
//# sourceMappingURL=Type.d.ts.map
|