@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
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
2
|
import { Import } from "./Import.js";
|
|
3
3
|
import { Type } from "./Type.js";
|
|
4
|
-
export declare class OptionType extends Type {
|
|
5
|
-
readonly
|
|
4
|
+
export declare class OptionType<ItemTypeT extends Type> extends Type {
|
|
5
|
+
readonly discriminatorProperty: Maybe<Type.DiscriminatorProperty>;
|
|
6
|
+
readonly itemType: ItemTypeT;
|
|
6
7
|
readonly kind = "OptionType";
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
readonly typeof = "object";
|
|
9
|
+
constructor({ itemType }: {
|
|
10
|
+
itemType: ItemTypeT;
|
|
9
11
|
});
|
|
10
12
|
get conversions(): readonly Type.Conversion[];
|
|
11
13
|
get equalsFunction(): string;
|
|
12
|
-
get
|
|
14
|
+
get graphqlName(): Type.GraphqlName;
|
|
15
|
+
get jsonName(): Type.JsonName;
|
|
13
16
|
get mutable(): boolean;
|
|
14
17
|
get name(): string;
|
|
15
18
|
fromJsonExpression({ variables, }: Parameters<Type["fromJsonExpression"]>[0]): string;
|
|
16
19
|
fromRdfExpression(parameters: Parameters<Type["fromRdfExpression"]>[0]): string;
|
|
20
|
+
graphqlResolveExpression(parameters: Parameters<Type["graphqlResolveExpression"]>[0]): string;
|
|
17
21
|
hashStatements({ depth, variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
18
22
|
jsonUiSchemaElement(parameters: Parameters<Type["jsonUiSchemaElement"]>[0]): ReturnType<Type["jsonUiSchemaElement"]>;
|
|
19
23
|
jsonZodSchema(parameters: Parameters<Type["jsonZodSchema"]>[0]): ReturnType<Type["jsonZodSchema"]>;
|
|
20
|
-
snippetDeclarations(
|
|
21
|
-
sparqlConstructTemplateTriples(
|
|
22
|
-
sparqlWherePatterns(
|
|
24
|
+
snippetDeclarations(parameters: Parameters<Type["snippetDeclarations"]>[0]): readonly string[];
|
|
25
|
+
sparqlConstructTemplateTriples(parameters: Parameters<Type["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
26
|
+
sparqlWherePatterns(parameters: Parameters<Type["sparqlWherePatterns"]>[0]): readonly string[];
|
|
23
27
|
toJsonExpression({ variables, }: Parameters<Type["toJsonExpression"]>[0]): string;
|
|
24
28
|
toRdfExpression({ variables, }: Parameters<Type["toRdfExpression"]>[0]): string;
|
|
25
|
-
useImports(
|
|
29
|
+
useImports(parameters: Parameters<Type["useImports"]>[0]): readonly Import[];
|
|
26
30
|
}
|
|
27
31
|
//# sourceMappingURL=OptionType.d.ts.map
|
|
@@ -5,14 +5,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Memoize } from "typescript-memoize";
|
|
8
|
+
import { Maybe } from "purify-ts";
|
|
9
|
+
import { invariant } from "ts-invariant";
|
|
8
10
|
import { Import } from "./Import.js";
|
|
9
11
|
import { SnippetDeclarations } from "./SnippetDeclarations.js";
|
|
10
12
|
import { Type } from "./Type.js";
|
|
13
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
11
14
|
export class OptionType extends Type {
|
|
15
|
+
discriminatorProperty = Maybe.empty();
|
|
12
16
|
itemType;
|
|
13
17
|
kind = "OptionType";
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
typeof = "object";
|
|
19
|
+
constructor({ itemType }) {
|
|
20
|
+
super();
|
|
16
21
|
this.itemType = itemType;
|
|
17
22
|
}
|
|
18
23
|
get conversions() {
|
|
@@ -38,10 +43,19 @@ export class OptionType extends Type {
|
|
|
38
43
|
return conversions;
|
|
39
44
|
}
|
|
40
45
|
get equalsFunction() {
|
|
41
|
-
return `((left, right) => maybeEquals(left, right, ${this.itemType.equalsFunction}))`;
|
|
46
|
+
return `((left, right) => ${syntheticNamePrefix}maybeEquals(left, right, ${this.itemType.equalsFunction}))`;
|
|
47
|
+
}
|
|
48
|
+
get graphqlName() {
|
|
49
|
+
invariant(!this.itemType.graphqlName.nullable);
|
|
50
|
+
return new Type.GraphqlName(this.itemType.graphqlName.toString(), {
|
|
51
|
+
nullable: true,
|
|
52
|
+
});
|
|
42
53
|
}
|
|
43
54
|
get jsonName() {
|
|
44
|
-
|
|
55
|
+
invariant(!this.itemType.jsonName.optional);
|
|
56
|
+
return new Type.JsonName(this.itemType.jsonName.toString(), {
|
|
57
|
+
optional: true,
|
|
58
|
+
});
|
|
45
59
|
}
|
|
46
60
|
get mutable() {
|
|
47
61
|
return this.itemType.mutable;
|
|
@@ -52,23 +66,27 @@ export class OptionType extends Type {
|
|
|
52
66
|
fromJsonExpression({ variables, }) {
|
|
53
67
|
const expression = `purify.Maybe.fromNullable(${variables.value})`;
|
|
54
68
|
const itemFromJsonExpression = this.itemType.fromJsonExpression({
|
|
55
|
-
variables: { value: "
|
|
69
|
+
variables: { value: "item" },
|
|
56
70
|
});
|
|
57
|
-
return itemFromJsonExpression === "
|
|
71
|
+
return itemFromJsonExpression === "item"
|
|
58
72
|
? expression
|
|
59
|
-
: `${expression}.map(
|
|
73
|
+
: `${expression}.map(item => (${itemFromJsonExpression}))`;
|
|
60
74
|
}
|
|
61
75
|
fromRdfExpression(parameters) {
|
|
62
|
-
|
|
76
|
+
const { variables } = parameters;
|
|
77
|
+
return `${this.itemType.fromRdfExpression(parameters)}.map(values => values.length > 0 ? values.map(value => purify.Maybe.of(value)) : rdfjsResource.Resource.Values.fromValue<purify.Maybe<${this.itemType.name}>>({ object: purify.Maybe.empty(), predicate: ${variables.predicate}, subject: ${variables.resource} }))`;
|
|
78
|
+
}
|
|
79
|
+
graphqlResolveExpression(parameters) {
|
|
80
|
+
return `${this.itemType.graphqlResolveExpression(parameters)}.extractNullable()`;
|
|
63
81
|
}
|
|
64
82
|
hashStatements({ depth, variables, }) {
|
|
65
83
|
return [
|
|
66
|
-
`${variables.value}.ifJust((
|
|
84
|
+
`${variables.value}.ifJust((value${depth}) => { ${this.itemType
|
|
67
85
|
.hashStatements({
|
|
68
86
|
depth: depth + 1,
|
|
69
87
|
variables: {
|
|
70
88
|
hasher: variables.hasher,
|
|
71
|
-
value: `
|
|
89
|
+
value: `value${depth}`,
|
|
72
90
|
},
|
|
73
91
|
})
|
|
74
92
|
.join("\n")} })`,
|
|
@@ -80,56 +98,66 @@ export class OptionType extends Type {
|
|
|
80
98
|
jsonZodSchema(parameters) {
|
|
81
99
|
return `${this.itemType.jsonZodSchema(parameters)}.optional()`;
|
|
82
100
|
}
|
|
83
|
-
snippetDeclarations(
|
|
101
|
+
snippetDeclarations(parameters) {
|
|
84
102
|
const snippetDeclarations = this.itemType
|
|
85
|
-
.snippetDeclarations(
|
|
103
|
+
.snippetDeclarations(parameters)
|
|
86
104
|
.concat();
|
|
87
|
-
if (features.has("equals")) {
|
|
105
|
+
if (parameters.features.has("equals")) {
|
|
88
106
|
snippetDeclarations.push(SnippetDeclarations.maybeEquals);
|
|
89
107
|
}
|
|
90
108
|
return snippetDeclarations;
|
|
91
109
|
}
|
|
92
|
-
sparqlConstructTemplateTriples(
|
|
93
|
-
switch (context) {
|
|
94
|
-
case "
|
|
95
|
-
return super.sparqlConstructTemplateTriples(
|
|
96
|
-
case "
|
|
97
|
-
return this.itemType.sparqlConstructTemplateTriples(
|
|
98
|
-
context,
|
|
99
|
-
variables,
|
|
100
|
-
});
|
|
110
|
+
sparqlConstructTemplateTriples(parameters) {
|
|
111
|
+
switch (parameters.context) {
|
|
112
|
+
case "object":
|
|
113
|
+
return super.sparqlConstructTemplateTriples(parameters);
|
|
114
|
+
case "subject":
|
|
115
|
+
return this.itemType.sparqlConstructTemplateTriples(parameters);
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
|
-
sparqlWherePatterns(
|
|
104
|
-
switch (context) {
|
|
105
|
-
case "
|
|
106
|
-
const patterns =
|
|
118
|
+
sparqlWherePatterns(parameters) {
|
|
119
|
+
switch (parameters.context) {
|
|
120
|
+
case "object": {
|
|
121
|
+
const patterns = this.itemType.sparqlWherePatterns(parameters);
|
|
107
122
|
if (patterns.length === 0) {
|
|
108
123
|
return [];
|
|
109
124
|
}
|
|
110
125
|
return [`{ patterns: [${patterns.join(", ")}], type: "optional" }`];
|
|
111
126
|
}
|
|
112
|
-
case "
|
|
113
|
-
|
|
127
|
+
case "subject": {
|
|
128
|
+
throw new Error("should never be called");
|
|
129
|
+
// return this.itemType.sparqlWherePatterns(parameters);
|
|
114
130
|
}
|
|
115
131
|
}
|
|
116
132
|
}
|
|
117
133
|
toJsonExpression({ variables, }) {
|
|
118
|
-
return `${variables.value}.map(
|
|
134
|
+
return `${variables.value}.map(item => (${this.itemType.toJsonExpression({ variables: { value: "item" } })})).extract()`;
|
|
119
135
|
}
|
|
120
136
|
toRdfExpression({ variables, }) {
|
|
121
137
|
const itemTypeToRdfExpression = this.itemType.toRdfExpression({
|
|
122
|
-
variables: { ...variables, value: "
|
|
138
|
+
variables: { ...variables, value: "value" },
|
|
123
139
|
});
|
|
124
|
-
if (itemTypeToRdfExpression === "
|
|
140
|
+
if (itemTypeToRdfExpression === "value") {
|
|
125
141
|
return variables.value;
|
|
126
142
|
}
|
|
127
|
-
return `${variables.value}.map((
|
|
143
|
+
return `${variables.value}.map((value) => ${itemTypeToRdfExpression})`;
|
|
128
144
|
}
|
|
129
|
-
useImports(
|
|
130
|
-
return [...this.itemType.useImports(
|
|
145
|
+
useImports(parameters) {
|
|
146
|
+
return [...this.itemType.useImports(parameters), Import.PURIFY];
|
|
131
147
|
}
|
|
132
148
|
}
|
|
149
|
+
__decorate([
|
|
150
|
+
Memoize()
|
|
151
|
+
], OptionType.prototype, "conversions", null);
|
|
152
|
+
__decorate([
|
|
153
|
+
Memoize()
|
|
154
|
+
], OptionType.prototype, "equalsFunction", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
Memoize()
|
|
157
|
+
], OptionType.prototype, "graphqlName", null);
|
|
158
|
+
__decorate([
|
|
159
|
+
Memoize()
|
|
160
|
+
], OptionType.prototype, "jsonName", null);
|
|
133
161
|
__decorate([
|
|
134
162
|
Memoize()
|
|
135
163
|
], OptionType.prototype, "name", null);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import type { TsFeature } from "../../enums/index.js";
|
|
3
2
|
import { LiteralType } from "./LiteralType.js";
|
|
4
|
-
import
|
|
3
|
+
import { Type } from "./Type.js";
|
|
5
4
|
export declare abstract class PrimitiveType<ValueT extends boolean | Date | string | number> extends LiteralType {
|
|
6
5
|
readonly equalsFunction: string;
|
|
7
6
|
readonly primitiveDefaultValue: Maybe<ValueT>;
|
|
@@ -11,11 +10,30 @@ export declare abstract class PrimitiveType<ValueT extends boolean | Date | stri
|
|
|
11
10
|
primitiveIn: readonly ValueT[];
|
|
12
11
|
} & ConstructorParameters<typeof LiteralType>[0]);
|
|
13
12
|
get discriminatorProperty(): Maybe<Type.DiscriminatorProperty>;
|
|
14
|
-
get jsonName():
|
|
13
|
+
get jsonName(): Type.JsonName;
|
|
15
14
|
fromJsonExpression({ variables, }: Parameters<Type["fromJsonExpression"]>[0]): string;
|
|
15
|
+
protected fromRdfExpressionChain({ variables, }: Parameters<Type["fromRdfExpression"]>[0]): {
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
hasValues?: string;
|
|
18
|
+
languageIn?: string;
|
|
19
|
+
valueTo?: string;
|
|
20
|
+
};
|
|
21
|
+
graphqlResolveExpression({ variables, }: Parameters<Type["graphqlResolveExpression"]>[0]): string;
|
|
16
22
|
hashStatements({ variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
17
|
-
snippetDeclarations(features:
|
|
23
|
+
snippetDeclarations({ features, }: Parameters<Type["snippetDeclarations"]>[0]): readonly string[];
|
|
24
|
+
sparqlWherePatterns(parameters: Parameters<Type["sparqlWherePatterns"]>[0]): readonly string[];
|
|
18
25
|
toJsonExpression({ variables, }: Parameters<Type["toJsonExpression"]>[0]): string;
|
|
19
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Convert an rdfjsResource.Resource.Value to a value of this type.
|
|
28
|
+
* @param variables
|
|
29
|
+
* @protected
|
|
30
|
+
*/
|
|
31
|
+
protected abstract fromRdfResourceValueExpression({ variables, }: {
|
|
32
|
+
variables: {
|
|
33
|
+
predicate: string;
|
|
34
|
+
resource: string;
|
|
35
|
+
resourceValue: string;
|
|
36
|
+
};
|
|
37
|
+
}): string;
|
|
20
38
|
}
|
|
21
39
|
//# sourceMappingURL=PrimitiveType.d.ts.map
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
1
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { Memoize } from "typescript-memoize";
|
|
2
9
|
import { LiteralType } from "./LiteralType.js";
|
|
3
10
|
import { SnippetDeclarations } from "./SnippetDeclarations.js";
|
|
11
|
+
import { Type } from "./Type.js";
|
|
12
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
4
13
|
export class PrimitiveType extends LiteralType {
|
|
5
|
-
equalsFunction =
|
|
14
|
+
equalsFunction = `${syntheticNamePrefix}strictEquals`;
|
|
6
15
|
primitiveDefaultValue;
|
|
7
16
|
primitiveIn;
|
|
8
17
|
constructor({ primitiveDefaultValue, primitiveIn, ...superParameters }) {
|
|
@@ -14,26 +23,45 @@ export class PrimitiveType extends LiteralType {
|
|
|
14
23
|
return Maybe.empty();
|
|
15
24
|
}
|
|
16
25
|
get jsonName() {
|
|
17
|
-
return this.name;
|
|
26
|
+
return new Type.JsonName(this.name);
|
|
18
27
|
}
|
|
19
28
|
fromJsonExpression({ variables, }) {
|
|
20
29
|
return variables.value;
|
|
21
30
|
}
|
|
31
|
+
fromRdfExpressionChain({ variables, }) {
|
|
32
|
+
return {
|
|
33
|
+
...super.fromRdfExpressionChain({ variables }),
|
|
34
|
+
languageIn: undefined,
|
|
35
|
+
valueTo: `chain(values => values.chainMap(value => ${this.fromRdfResourceValueExpression({
|
|
36
|
+
variables: {
|
|
37
|
+
predicate: variables.predicate,
|
|
38
|
+
resource: variables.resource,
|
|
39
|
+
resourceValue: "value",
|
|
40
|
+
},
|
|
41
|
+
})}))`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
graphqlResolveExpression({ variables, }) {
|
|
45
|
+
return variables.value;
|
|
46
|
+
}
|
|
22
47
|
hashStatements({ variables, }) {
|
|
23
48
|
return [`${variables.hasher}.update(${variables.value}.toString());`];
|
|
24
49
|
}
|
|
25
|
-
snippetDeclarations(features) {
|
|
50
|
+
snippetDeclarations({ features, }) {
|
|
26
51
|
const snippetDeclarations = [];
|
|
27
52
|
if (features.has("equals")) {
|
|
28
53
|
snippetDeclarations.push(SnippetDeclarations.strictEquals);
|
|
29
54
|
}
|
|
30
55
|
return snippetDeclarations;
|
|
31
56
|
}
|
|
57
|
+
sparqlWherePatterns(parameters) {
|
|
58
|
+
return super.sparqlWherePatterns({ ...parameters, ignoreLanguageIn: true });
|
|
59
|
+
}
|
|
32
60
|
toJsonExpression({ variables, }) {
|
|
33
61
|
return variables.value;
|
|
34
62
|
}
|
|
35
|
-
propertyFilterRdfResourceValuesExpression({ variables, }) {
|
|
36
|
-
return variables.resourceValues;
|
|
37
|
-
}
|
|
38
63
|
}
|
|
64
|
+
__decorate([
|
|
65
|
+
Memoize()
|
|
66
|
+
], PrimitiveType.prototype, "jsonName", null);
|
|
39
67
|
//# sourceMappingURL=PrimitiveType.js.map
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
2
|
import type { Import } from "./Import.js";
|
|
3
3
|
import { Type } from "./Type.js";
|
|
4
|
-
export declare class SetType extends Type {
|
|
5
|
-
readonly
|
|
6
|
-
readonly
|
|
7
|
-
private readonly minCount;
|
|
4
|
+
export declare class SetType<ItemTypeT extends Type> extends Type {
|
|
5
|
+
readonly discriminatorProperty: Maybe<Type.DiscriminatorProperty>;
|
|
6
|
+
readonly itemType: ItemTypeT;
|
|
8
7
|
private readonly _mutable;
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
private readonly minCount;
|
|
9
|
+
readonly kind = "SetType";
|
|
10
|
+
readonly typeof = "object";
|
|
11
|
+
constructor({ itemType, minCount, mutable, }: {
|
|
12
|
+
itemType: ItemTypeT;
|
|
11
13
|
mutable: boolean;
|
|
12
14
|
minCount: number;
|
|
13
15
|
});
|
|
14
16
|
get conversions(): readonly Type.Conversion[];
|
|
15
17
|
get equalsFunction(): string;
|
|
16
|
-
get
|
|
18
|
+
get graphqlName(): Type.GraphqlName;
|
|
19
|
+
get jsonName(): Type.JsonName;
|
|
17
20
|
get mutable(): boolean;
|
|
18
21
|
get name(): string;
|
|
19
22
|
fromJsonExpression({ variables, }: Parameters<Type["fromJsonExpression"]>[0]): string;
|
|
20
|
-
fromRdfExpression(
|
|
23
|
+
fromRdfExpression(parameters: Parameters<Type["fromRdfExpression"]>[0]): string;
|
|
24
|
+
graphqlResolveExpression({ variables, }: Parameters<Type["graphqlResolveExpression"]>[0]): string;
|
|
21
25
|
hashStatements({ depth, variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
22
26
|
jsonUiSchemaElement(parameters: Parameters<Type["jsonUiSchemaElement"]>[0]): ReturnType<Type["jsonUiSchemaElement"]>;
|
|
23
27
|
jsonZodSchema(parameters: Parameters<Type["jsonZodSchema"]>[0]): ReturnType<Type["jsonZodSchema"]>;
|
|
24
|
-
snippetDeclarations(
|
|
25
|
-
sparqlConstructTemplateTriples(
|
|
26
|
-
sparqlWherePatterns(
|
|
28
|
+
snippetDeclarations(parameters: Parameters<Type["snippetDeclarations"]>[0]): readonly string[];
|
|
29
|
+
sparqlConstructTemplateTriples(parameters: Parameters<Type["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
30
|
+
sparqlWherePatterns(parameters: Parameters<Type["sparqlWherePatterns"]>[0]): readonly string[];
|
|
27
31
|
toJsonExpression({ variables, }: Parameters<Type["toJsonExpression"]>[0]): string;
|
|
28
32
|
toRdfExpression({ variables, }: Parameters<Type["toRdfExpression"]>[0]): string;
|
|
29
|
-
useImports(
|
|
33
|
+
useImports(parameters: Parameters<Type["useImports"]>[0]): readonly Import[];
|
|
30
34
|
}
|
|
31
35
|
//# sourceMappingURL=SetType.d.ts.map
|
|
@@ -4,18 +4,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
+
import { Maybe } from "purify-ts";
|
|
7
8
|
import { invariant } from "ts-invariant";
|
|
8
9
|
import { Memoize } from "typescript-memoize";
|
|
9
10
|
import { SnippetDeclarations } from "./SnippetDeclarations.js";
|
|
10
11
|
import { Type } from "./Type.js";
|
|
11
|
-
import {
|
|
12
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
12
13
|
export class SetType extends Type {
|
|
14
|
+
discriminatorProperty = Maybe.empty();
|
|
13
15
|
itemType;
|
|
14
|
-
kind = "SetType";
|
|
15
|
-
minCount;
|
|
16
16
|
_mutable;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
minCount;
|
|
18
|
+
kind = "SetType";
|
|
19
|
+
typeof = "object";
|
|
20
|
+
constructor({ itemType, minCount, mutable, }) {
|
|
21
|
+
super();
|
|
19
22
|
this.itemType = itemType;
|
|
20
23
|
this.minCount = minCount;
|
|
21
24
|
invariant(this.minCount >= 0);
|
|
@@ -30,8 +33,11 @@ export class SetType extends Type {
|
|
|
30
33
|
sourceTypeName: "undefined",
|
|
31
34
|
});
|
|
32
35
|
conversions.push({
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
// Defensive copy
|
|
37
|
+
conversionExpression: (value) => `${value}${this.mutable ? ".concat()" : ""}`,
|
|
38
|
+
// Array.isArray doesn't narrow correctly
|
|
39
|
+
// sourceTypeCheckExpression: (value) => `Array.isArray(${value})`,
|
|
40
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
35
41
|
sourceTypeName: `readonly (${this.itemType.name})[]`,
|
|
36
42
|
});
|
|
37
43
|
}
|
|
@@ -45,10 +51,17 @@ export class SetType extends Type {
|
|
|
45
51
|
return conversions;
|
|
46
52
|
}
|
|
47
53
|
get equalsFunction() {
|
|
48
|
-
return `((left, right) => arrayEquals(left, right, ${this.itemType.equalsFunction}))`;
|
|
54
|
+
return `((left, right) => ${syntheticNamePrefix}arrayEquals(left, right, ${this.itemType.equalsFunction}))`;
|
|
55
|
+
}
|
|
56
|
+
get graphqlName() {
|
|
57
|
+
return new Type.GraphqlName(`new graphql.GraphQLList(${this.itemType.graphqlName})`);
|
|
49
58
|
}
|
|
50
59
|
get jsonName() {
|
|
51
|
-
|
|
60
|
+
const name = `readonly (${this.itemType.jsonName})[]`;
|
|
61
|
+
if (this.minCount === 0) {
|
|
62
|
+
return new Type.JsonName(name, { optional: true });
|
|
63
|
+
}
|
|
64
|
+
return new Type.JsonName(name);
|
|
52
65
|
}
|
|
53
66
|
get mutable() {
|
|
54
67
|
return this._mutable || this.itemType.mutable;
|
|
@@ -68,29 +81,35 @@ export class SetType extends Type {
|
|
|
68
81
|
expression = `purify.NonEmptyList.fromArray(${expression}).unsafeCoerce()`;
|
|
69
82
|
}
|
|
70
83
|
const itemFromJsonExpression = this.itemType.fromJsonExpression({
|
|
71
|
-
variables: { value: "
|
|
84
|
+
variables: { value: "item" },
|
|
72
85
|
});
|
|
73
|
-
return itemFromJsonExpression === "
|
|
86
|
+
return itemFromJsonExpression === "item"
|
|
74
87
|
? expression
|
|
75
|
-
: `${expression}.map(
|
|
88
|
+
: `${expression}.map(item => (${itemFromJsonExpression}))`;
|
|
76
89
|
}
|
|
77
|
-
fromRdfExpression(
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
fromRdfExpression(parameters) {
|
|
91
|
+
const { variables } = parameters;
|
|
92
|
+
const chain = [this.itemType.fromRdfExpression(parameters)];
|
|
93
|
+
if (this.minCount === 0 || this._mutable) {
|
|
94
|
+
chain.push(`map(values => values.toArray()${this._mutable ? ".concat()" : ""})`);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
chain.push(`chain(values => purify.NonEmptyList.fromArray(values.toArray()).toEither(new Error(\`\${rdfjsResource.Resource.Identifier.toString(${variables.resource}.identifier)} is an empty set\`)))`);
|
|
83
98
|
}
|
|
84
|
-
|
|
99
|
+
chain.push(`map(valuesArray => rdfjsResource.Resource.Values.fromValue({ object: valuesArray , predicate: ${variables.predicate}, subject: ${variables.resource} }))`);
|
|
100
|
+
return chain.join(".");
|
|
101
|
+
}
|
|
102
|
+
graphqlResolveExpression({ variables, }) {
|
|
103
|
+
return variables.value;
|
|
85
104
|
}
|
|
86
105
|
hashStatements({ depth, variables, }) {
|
|
87
106
|
return [
|
|
88
|
-
`for (const
|
|
107
|
+
`for (const item${depth} of ${variables.value}) { ${this.itemType
|
|
89
108
|
.hashStatements({
|
|
90
109
|
depth: depth + 1,
|
|
91
110
|
variables: {
|
|
92
111
|
hasher: variables.hasher,
|
|
93
|
-
value: `
|
|
112
|
+
value: `item${depth}`,
|
|
94
113
|
},
|
|
95
114
|
})
|
|
96
115
|
.join("\n")} }`,
|
|
@@ -104,32 +123,32 @@ export class SetType extends Type {
|
|
|
104
123
|
if (this.minCount > 0) {
|
|
105
124
|
schema = `${schema}.nonempty().min(${this.minCount})`;
|
|
106
125
|
}
|
|
126
|
+
else {
|
|
127
|
+
schema = `${schema}.default(() => [])`;
|
|
128
|
+
}
|
|
107
129
|
return schema;
|
|
108
130
|
}
|
|
109
|
-
snippetDeclarations(
|
|
131
|
+
snippetDeclarations(parameters) {
|
|
110
132
|
const snippetDeclarations = this.itemType
|
|
111
|
-
.snippetDeclarations(
|
|
133
|
+
.snippetDeclarations(parameters)
|
|
112
134
|
.concat();
|
|
113
|
-
if (features.has("equals")) {
|
|
135
|
+
if (parameters.features.has("equals")) {
|
|
114
136
|
snippetDeclarations.push(SnippetDeclarations.arrayEquals);
|
|
115
137
|
}
|
|
116
138
|
return snippetDeclarations;
|
|
117
139
|
}
|
|
118
|
-
sparqlConstructTemplateTriples(
|
|
119
|
-
switch (context) {
|
|
120
|
-
case "
|
|
121
|
-
return super.sparqlConstructTemplateTriples(
|
|
122
|
-
case "
|
|
123
|
-
return this.itemType.sparqlConstructTemplateTriples(
|
|
124
|
-
context,
|
|
125
|
-
variables,
|
|
126
|
-
});
|
|
140
|
+
sparqlConstructTemplateTriples(parameters) {
|
|
141
|
+
switch (parameters.context) {
|
|
142
|
+
case "object":
|
|
143
|
+
return super.sparqlConstructTemplateTriples(parameters);
|
|
144
|
+
case "subject":
|
|
145
|
+
return this.itemType.sparqlConstructTemplateTriples(parameters);
|
|
127
146
|
}
|
|
128
147
|
}
|
|
129
|
-
sparqlWherePatterns(
|
|
130
|
-
switch (context) {
|
|
131
|
-
case "
|
|
132
|
-
const patterns =
|
|
148
|
+
sparqlWherePatterns(parameters) {
|
|
149
|
+
switch (parameters.context) {
|
|
150
|
+
case "object": {
|
|
151
|
+
const patterns = this.itemType.sparqlWherePatterns(parameters);
|
|
133
152
|
if (patterns.length === 0) {
|
|
134
153
|
return [];
|
|
135
154
|
}
|
|
@@ -137,23 +156,36 @@ export class SetType extends Type {
|
|
|
137
156
|
? patterns
|
|
138
157
|
: [`{ patterns: [${patterns.join(", ")}], type: "optional" }`];
|
|
139
158
|
}
|
|
140
|
-
case "
|
|
141
|
-
|
|
159
|
+
case "subject": {
|
|
160
|
+
throw new Error("should never be called");
|
|
161
|
+
// return this.itemType.sparqlWherePatterns(parameters);
|
|
142
162
|
}
|
|
143
163
|
}
|
|
144
164
|
}
|
|
145
165
|
toJsonExpression({ variables, }) {
|
|
146
|
-
return `${variables.value}.map(
|
|
166
|
+
return `${variables.value}.map(item => (${this.itemType.toJsonExpression({ variables: { value: "item" } })}))`;
|
|
147
167
|
}
|
|
148
168
|
toRdfExpression({ variables, }) {
|
|
149
|
-
return `${variables.value}.map((
|
|
150
|
-
variables: { ...variables, value: "
|
|
169
|
+
return `${variables.value}.map((item) => ${this.itemType.toRdfExpression({
|
|
170
|
+
variables: { ...variables, value: "item" },
|
|
151
171
|
})})`;
|
|
152
172
|
}
|
|
153
|
-
useImports(
|
|
154
|
-
return this.itemType.useImports(
|
|
173
|
+
useImports(parameters) {
|
|
174
|
+
return this.itemType.useImports(parameters);
|
|
155
175
|
}
|
|
156
176
|
}
|
|
177
|
+
__decorate([
|
|
178
|
+
Memoize()
|
|
179
|
+
], SetType.prototype, "conversions", null);
|
|
180
|
+
__decorate([
|
|
181
|
+
Memoize()
|
|
182
|
+
], SetType.prototype, "equalsFunction", null);
|
|
183
|
+
__decorate([
|
|
184
|
+
Memoize()
|
|
185
|
+
], SetType.prototype, "graphqlName", null);
|
|
186
|
+
__decorate([
|
|
187
|
+
Memoize()
|
|
188
|
+
], SetType.prototype, "jsonName", null);
|
|
157
189
|
__decorate([
|
|
158
190
|
Memoize()
|
|
159
191
|
], SetType.prototype, "name", null);
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
export declare namespace SnippetDeclarations {
|
|
2
|
-
const arrayEquals = "
|
|
3
|
-
const booleanEquals = "/**\n * Compare two objects with equals(other: T): boolean methods and return an EqualsResult.\n */\nexport function booleanEquals<T extends { equals: (other: T) => boolean }>(\n left: T,\n right: T,\n): EqualsResult {\n return EqualsResult.fromBooleanEqualsResult(\n left,\n right,\n left.equals(right),\n );\n}";
|
|
4
|
-
const dateEquals = "/**\n * Compare two Dates and return an EqualsResult.\n */\nexport function dateEquals(left: Date, right: Date): EqualsResult {\n return EqualsResult.fromBooleanEqualsResult(\n left,\n right,\n left.getTime() === right.getTime(),\n );\n}";
|
|
5
|
-
const EqualsResult = "export type EqualsResult = purify.Either
|
|
6
|
-
const maybeEquals = "export function maybeEquals<T>(\n leftMaybe: purify.Maybe<T>,\n rightMaybe: purify.Maybe<T>,\n valueEquals: (left: T, right: T) => boolean | EqualsResult,\n): EqualsResult {\n if (leftMaybe.isJust()) {\n if (rightMaybe.isJust()) {\n return EqualsResult.fromBooleanEqualsResult(\n leftMaybe,\n rightMaybe,\n valueEquals(leftMaybe.unsafeCoerce(), rightMaybe.unsafeCoerce()),\n );\n }\n return purify.Left({\n left: leftMaybe.unsafeCoerce(),\n type: \"RightNull\",\n });\n }\n\n if (rightMaybe.isJust()) {\n return purify.Left({\n right: rightMaybe.unsafeCoerce(),\n type: \"LeftNull\",\n });\n }\n\n return EqualsResult.Equal;\n}
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
2
|
+
const arrayEquals = "/**\n * Compare two arrays element-wise with the provided elementEquals function.\n */ \nexport function $arrayEquals<T>(\n leftArray: readonly T[],\n rightArray: readonly T[],\n elementEquals: (left: T, right: T) => boolean | $EqualsResult,\n): $EqualsResult {\n if (leftArray.length !== rightArray.length) {\n return purify.Left({\n left: leftArray,\n right: rightArray,\n type: \"ArrayLength\",\n });\n }\n\n for (\n let leftElementIndex = 0;\n leftElementIndex < leftArray.length;\n leftElementIndex++\n ) {\n const leftElement = leftArray[leftElementIndex];\n\n const rightUnequals: $EqualsResult.Unequal[] = [];\n for (\n let rightElementIndex = 0;\n rightElementIndex < rightArray.length;\n rightElementIndex++\n ) {\n const rightElement = rightArray[rightElementIndex];\n\n const leftElementEqualsRightElement =\n $EqualsResult.fromBooleanEqualsResult(\n leftElement,\n rightElement,\n elementEquals(leftElement, rightElement),\n );\n if (leftElementEqualsRightElement.isRight()) {\n break; // left element === right element, break out of the right iteration\n }\n rightUnequals.push(\n leftElementEqualsRightElement.extract() as $EqualsResult.Unequal,\n );\n }\n\n if (rightUnequals.length === rightArray.length) {\n // All right elements were unequal to the left element\n return purify.Left({\n left: {\n array: leftArray,\n element: leftElement,\n elementIndex: leftElementIndex,\n },\n right: {\n array: rightArray,\n unequals: rightUnequals,\n },\n type: \"ArrayElement\",\n });\n }\n // Else there was a right element equal to the left element, continue to the next left element\n }\n\n return $EqualsResult.Equal;\n}\n";
|
|
3
|
+
const booleanEquals = "/**\n * Compare two objects with equals(other: T): boolean methods and return an $EqualsResult.\n */\nexport function $booleanEquals<T extends { equals: (other: T) => boolean }>(\n left: T,\n right: T,\n): $EqualsResult {\n return $EqualsResult.fromBooleanEqualsResult(\n left,\n right,\n left.equals(right),\n );\n}";
|
|
4
|
+
const dateEquals = "/**\n * Compare two Dates and return an $EqualsResult.\n */\nexport function $dateEquals(left: Date, right: Date): $EqualsResult {\n return $EqualsResult.fromBooleanEqualsResult(\n left,\n right,\n left.getTime() === right.getTime(),\n );\n}";
|
|
5
|
+
const EqualsResult = "export type $EqualsResult = purify.Either<$EqualsResult.Unequal, true>;\n\nexport namespace $EqualsResult {\n export const Equal: $EqualsResult = purify.Either.of<Unequal, true>(true);\n\n export function fromBooleanEqualsResult(\n left: any,\n right: any,\n equalsResult: boolean | $EqualsResult,\n ): $EqualsResult {\n if (typeof equalsResult !== \"boolean\") {\n return equalsResult;\n }\n\n if (equalsResult) {\n return Equal;\n }\n\n return purify.Left({ left, right, type: \"BooleanEquals\" });\n }\n\n export type Unequal =\n | {\n readonly left: {\n readonly array: readonly any[];\n readonly element: any;\n readonly elementIndex: number;\n };\n readonly right: {\n readonly array: readonly any[];\n readonly unequals: readonly Unequal[];\n };\n readonly type: \"ArrayElement\";\n }\n | {\n readonly left: readonly any[];\n readonly right: readonly any[];\n readonly type: \"ArrayLength\";\n }\n | {\n readonly left: any;\n readonly right: any;\n readonly type: \"BooleanEquals\";\n }\n | {\n readonly left: any;\n readonly right: any;\n readonly type: \"LeftError\";\n }\n | {\n readonly right: any;\n readonly type: \"LeftNull\";\n }\n | {\n readonly left: bigint | boolean | number | string;\n readonly right: bigint | boolean | number | string;\n readonly type: \"Primitive\";\n }\n | {\n readonly left: any;\n readonly right: any;\n readonly propertyName: string;\n readonly propertyValuesUnequal: Unequal;\n readonly type: \"Property\";\n }\n | {\n readonly left: any;\n readonly right: any;\n readonly type: \"RightError\";\n }\n | {\n readonly left: any;\n readonly type: \"RightNull\";\n };\n} \n";
|
|
6
|
+
const maybeEquals = "export function $maybeEquals<T>(\n leftMaybe: purify.Maybe<T>,\n rightMaybe: purify.Maybe<T>,\n valueEquals: (left: T, right: T) => boolean | $EqualsResult,\n): $EqualsResult {\n if (leftMaybe.isJust()) {\n if (rightMaybe.isJust()) {\n return $EqualsResult.fromBooleanEqualsResult(\n leftMaybe,\n rightMaybe,\n valueEquals(leftMaybe.unsafeCoerce(), rightMaybe.unsafeCoerce()),\n );\n }\n return purify.Left({\n left: leftMaybe.unsafeCoerce(),\n type: \"RightNull\",\n });\n }\n\n if (rightMaybe.isJust()) {\n return purify.Left({\n right: rightMaybe.unsafeCoerce(),\n type: \"LeftNull\",\n });\n }\n\n return $EqualsResult.Equal;\n}";
|
|
7
|
+
const LazyObjectSet = "/**\n * Type of lazy properties that return a set of objects. This is a class instead of an interface so it can be instanceof'd elsewhere.\n */\nexport class $LazyObjectSet<ObjectIdentifierT extends rdfjs.BlankNode | rdfjs.NamedNode, ResolvedObjectT extends { $identifier: ObjectIdentifierT }, StubObjectT extends { $identifier: ObjectIdentifierT }> {\n private readonly resolver: (identifiers: readonly ObjectIdentifierT[]) => Promise<purify.Either<Error, readonly ResolvedObjectT[]>>;\n readonly stubs: readonly StubObjectT[];\n\n constructor({ resolver, stubs }: {\n resolver: (identifiers: readonly ObjectIdentifierT[]) => Promise<purify.Either<Error, readonly ResolvedObjectT[]>>,\n stubs: readonly StubObjectT[]\n }) {\n this.resolver = resolver;\n this.stubs = stubs;\n }\n\n async resolve(options?: { limit?: number; offset?: number }): Promise<purify.Either<Error, readonly ResolvedObjectT[]>> {\n if (this.stubs.length === 0) {\n return purify.Either.of([]);\n }\n\n const limit = options?.limit ?? Number.MAX_SAFE_INTEGER;\n if (limit <= 0) {\n return purify.Either.of([]);\n }\n\n let offset = options?.offset ?? 0;\n if (offset < 0) {\n offset = 0;\n }\n\n return await this.resolver(this.stubs.slice(offset, offset + limit).map(stub => stub.$identifier));\n }\n}";
|
|
8
|
+
const LazyOptionalObject = "/**\n * Type of lazy properties that return a single optional object. This is a class instead of an interface so it can be instanceof'd elsewhere.\n */\nexport class $LazyOptionalObject<ObjectIdentifierT extends rdfjs.BlankNode | rdfjs.NamedNode, ResolvedObjectT extends { $identifier: ObjectIdentifierT }, StubObjectT extends { $identifier: ObjectIdentifierT }> {\n private readonly resolver: (identifier: ObjectIdentifierT) => Promise<purify.Either<Error, ResolvedObjectT>>;\n readonly stub: purify.Maybe<StubObjectT>;\n\n constructor({ resolver, stub }: {\n resolver: (identifier: ObjectIdentifierT) => Promise<purify.Either<Error, ResolvedObjectT>>,\n stub: purify.Maybe<StubObjectT>\n }) {\n this.resolver = resolver;\n this.stub = stub;\n }\n\n async resolve(): Promise<purify.Either<Error, purify.Maybe<ResolvedObjectT>>> {\n if (this.stub.isNothing()) {\n return purify.Either.of(purify.Maybe.empty());\n }\n return (await this.resolver(this.stub.unsafeCoerce().$identifier)).map(purify.Maybe.of);\n }\n}";
|
|
9
|
+
const LazyRequiredObject = "/**\n * Type of lazy properties that return a single required object. This is a class instead of an interface so it can be instanceof'd elsewhere.\n */\nexport class $LazyRequiredObject<ObjectIdentifierT extends rdfjs.BlankNode | rdfjs.NamedNode, ResolvedObjectT extends { $identifier: ObjectIdentifierT }, StubObjectT extends { $identifier: ObjectIdentifierT }> {\n private readonly resolver: (identifier: ObjectIdentifierT) => Promise<purify.Either<Error, ResolvedObjectT>>;\n readonly stub: StubObjectT;\n\n constructor({ resolver, stub }: {\n resolver: (identifier: ObjectIdentifierT) => Promise<purify.Either<Error, ResolvedObjectT>>,\n stub: StubObjectT\n }) {\n this.resolver = resolver;\n this.stub = stub;\n }\n\n resolve(): Promise<purify.Either<Error, ResolvedObjectT>> {\n return this.resolver(this.stub.$identifier);\n }\n}";
|
|
10
|
+
const RdfVocabularies = "export namespace $RdfVocabularies {\n export namespace rdf {\n export const first = dataFactory.namedNode(\"http://www.w3.org/1999/02/22-rdf-syntax-ns#first\");\n export const nil = dataFactory.namedNode(\"http://www.w3.org/1999/02/22-rdf-syntax-ns#nil\");\n export const rest = dataFactory.namedNode(\"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest\");\n export const subject = dataFactory.namedNode(\"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject\");\n export const type = dataFactory.namedNode(\"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\");\n }\n\n export namespace rdfs {\n export const subClassOf = dataFactory.namedNode(\"http://www.w3.org/2000/01/rdf-schema#subClassOf\");\n }\n\n export namespace xsd {\n export const boolean = dataFactory.namedNode(\"http://www.w3.org/2001/XMLSchema#boolean\");\n export const date = dataFactory.namedNode(\"http://www.w3.org/2001/XMLSchema#date\");\n export const dateTime = dataFactory.namedNode(\"http://www.w3.org/2001/XMLSchema#dateTime\");\n export const integer = dataFactory.namedNode(\"http://www.w3.org/2001/XMLSchema#integer\");\n }\n}";
|
|
11
|
+
const sparqlInstancesOfPattern = "/**\n * A sparqljs.Pattern that's the equivalent of ?subject rdf:type/rdfs:subClassOf* ?rdfType .\n */\nexport function $sparqlInstancesOfPattern({ rdfType, subject }: { rdfType: rdfjs.NamedNode, subject: sparqljs.Triple[\"subject\"] }): sparqljs.Pattern {\n return {\n triples: [\n {\n subject,\n predicate: {\n items: [\n $RdfVocabularies.rdf.type,\n {\n items: [$RdfVocabularies.rdfs.subClassOf],\n pathType: \"*\",\n type: \"path\",\n },\n ],\n pathType: \"/\",\n type: \"path\",\n },\n object: rdfType,\n },\n ],\n type: \"bgp\",\n };\n}";
|
|
12
|
+
const strictEquals = "/**\n * Compare two values for strict equality (===), returning an $EqualsResult rather than a boolean.\n */\nexport function $strictEquals<T extends bigint | boolean | number | string>(\n left: T,\n right: T,\n): $EqualsResult {\n return $EqualsResult.fromBooleanEqualsResult(left, right, left === right);\n}";
|
|
13
|
+
const UnwrapL = "type $UnwrapL<T> = T extends purify.Either<infer L, any> ? L : never";
|
|
14
|
+
const UnwrapR = "type $UnwrapR<T> = T extends purify.Either<any, infer R> ? R : never";
|
|
10
15
|
}
|
|
11
16
|
//# sourceMappingURL=SnippetDeclarations.d.ts.map
|