@shaclmate/compiler 4.0.32 → 4.0.34
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/Compiler.d.ts +0 -3
- package/dist/Compiler.js +0 -2
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -4
- package/dist/ShapesGraphToAstTransformer.js +1 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +1 -3
- package/dist/ast/AbstractCompoundType.d.ts +6 -4
- package/dist/ast/AbstractCompoundType.js +4 -37
- package/dist/ast/ObjectType.d.ts +1 -7
- package/dist/ast/ObjectType.js +1 -6
- package/dist/generators/ts/AbstractCollectionType.d.ts +8 -8
- package/dist/generators/ts/AbstractCollectionType.js +28 -111
- package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
- package/dist/generators/ts/AbstractDateType.d.ts +4 -9
- package/dist/generators/ts/AbstractDateType.js +2 -29
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
- package/dist/generators/ts/AbstractIdentifierType.js +0 -17
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +8 -5
- package/dist/generators/ts/AbstractLazyObjectType.js +21 -21
- package/dist/generators/ts/AbstractLiteralType.d.ts +11 -3
- package/dist/generators/ts/AbstractLiteralType.js +1 -1
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
- package/dist/generators/ts/AbstractNumericType.d.ts +9 -8
- package/dist/generators/ts/AbstractNumericType.js +18 -11
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -4
- package/dist/generators/ts/AbstractPrimitiveType.js +9 -17
- package/dist/generators/ts/AbstractTermType.d.ts +8 -4
- package/dist/generators/ts/AbstractTermType.js +11 -51
- package/dist/generators/ts/AbstractType.d.ts +26 -22
- package/dist/generators/ts/AbstractType.js +4 -2
- package/dist/generators/ts/AbstractUnionType.d.ts +2 -2
- package/dist/generators/ts/AbstractUnionType.js +25 -36
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +3 -3
- package/dist/generators/ts/BigDecimalType.d.ts +5 -3
- package/dist/generators/ts/BigDecimalType.js +15 -42
- package/dist/generators/ts/BigIntType.d.ts +3 -4
- package/dist/generators/ts/BigIntType.js +5 -16
- package/dist/generators/ts/BlankNodeType.d.ts +7 -7
- package/dist/generators/ts/BlankNodeType.js +14 -2
- package/dist/generators/ts/BooleanType.d.ts +6 -8
- package/dist/generators/ts/BooleanType.js +18 -11
- package/dist/generators/ts/DateTimeType.d.ts +5 -1
- package/dist/generators/ts/DateTimeType.js +15 -13
- package/dist/generators/ts/DateType.d.ts +5 -1
- package/dist/generators/ts/DateType.js +16 -14
- package/dist/generators/ts/DefaultValueType.d.ts +5 -6
- package/dist/generators/ts/DefaultValueType.js +30 -64
- package/dist/generators/ts/FloatType.d.ts +3 -3
- package/dist/generators/ts/FloatType.js +5 -5
- package/dist/generators/ts/IdentifierType.d.ts +6 -6
- package/dist/generators/ts/IdentifierType.js +22 -2
- package/dist/generators/ts/IntType.d.ts +3 -3
- package/dist/generators/ts/IntType.js +5 -5
- package/dist/generators/ts/IriType.d.ts +17 -12
- package/dist/generators/ts/IriType.js +39 -29
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectOptionType.js +23 -44
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +19 -29
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +17 -25
- package/dist/generators/ts/LiteralType.d.ts +5 -3
- package/dist/generators/ts/LiteralType.js +25 -12
- package/dist/generators/ts/NamedObjectType.d.ts +6 -9
- package/dist/generators/ts/NamedObjectType.js +33 -29
- package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
- package/dist/generators/ts/NamedObjectUnionType.js +21 -14
- package/dist/generators/ts/OptionType.d.ts +4 -4
- package/dist/generators/ts/OptionType.js +22 -45
- package/dist/generators/ts/Reusables.d.ts +3 -1
- package/dist/generators/ts/Reusables.js +2 -1
- package/dist/generators/ts/SetType.d.ts +0 -1
- package/dist/generators/ts/SetType.js +4 -22
- package/dist/generators/ts/SnippetFactory.d.ts +2 -0
- package/dist/generators/ts/Snippets.d.ts +40 -8
- package/dist/generators/ts/Snippets.js +235 -30
- package/dist/generators/ts/StringType.d.ts +6 -9
- package/dist/generators/ts/StringType.js +17 -16
- package/dist/generators/ts/TermType.d.ts +1 -4
- package/dist/generators/ts/TermType.js +14 -8
- package/dist/generators/ts/TsGenerator.d.ts +14 -1
- package/dist/generators/ts/TsGenerator.js +41 -12
- package/dist/generators/ts/TypeFactory.d.ts +8 -4
- package/dist/generators/ts/TypeFactory.js +73 -49
- package/dist/generators/ts/ZodGenerator.js +6 -3
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +27 -20
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +4 -2
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -9
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +6 -6
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +35 -39
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +35 -27
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +7 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +26 -32
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +6 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +2 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +14 -18
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +22 -30
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
- package/dist/generators/ts/_snippets/snippets_HashFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_HashFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +34 -24
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +21 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +15 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +31 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +25 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +19 -0
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +11 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_hashArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashArray.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashString.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.js +12 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +1 -1
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +7 -4
- package/dist/generators/ts/objectSetDeclarations.js +4 -34
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -1
- package/dist/generators/ts/objectSetMethodSignatures.js +2 -2
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
- package/dist/input/ShapesGraph.d.ts +5 -8
- package/dist/input/ShapesGraph.js +5 -6
- package/dist/input/generated.d.ts +171 -226
- package/dist/input/generated.js +565 -2068
- package/package.json +6 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +0 -67
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +0 -6
- package/dist/generators/ts/syntheticNamePrefix.d.ts +0 -2
- package/dist/generators/ts/syntheticNamePrefix.js +0 -2
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { NodeKind } from "@shaclmate/shacl-ast";
|
|
8
8
|
import { camelCase } from "change-case";
|
|
9
|
-
import { Maybe
|
|
9
|
+
import { Maybe } from "purify-ts";
|
|
10
10
|
import { Memoize } from "typescript-memoize";
|
|
11
11
|
import { DiscriminantProperty as _DiscriminantProperty } from "./_NamedObjectType/DiscriminantProperty.js";
|
|
12
12
|
import { IdentifierProperty as _IdentifierProperty } from "./_NamedObjectType/IdentifierProperty.js";
|
|
@@ -40,12 +40,10 @@ import { NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration } from "
|
|
|
40
40
|
import { NamedObjectType_valueSparqlWherePatternsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js";
|
|
41
41
|
import { ShaclProperty as _ShaclProperty } from "./_NamedObjectType/ShaclProperty.js";
|
|
42
42
|
import { AbstractType } from "./AbstractType.js";
|
|
43
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
44
43
|
import { code, def, joinCode } from "./ts-poet-wrapper.js";
|
|
45
44
|
export class NamedObjectType extends AbstractType {
|
|
46
45
|
toRdfTypes;
|
|
47
46
|
extern;
|
|
48
|
-
features;
|
|
49
47
|
fromRdfType;
|
|
50
48
|
graphqlArgs = Maybe.empty();
|
|
51
49
|
identifierType;
|
|
@@ -53,11 +51,10 @@ export class NamedObjectType extends AbstractType {
|
|
|
53
51
|
name;
|
|
54
52
|
recursive;
|
|
55
53
|
synthetic;
|
|
56
|
-
typeofs =
|
|
57
|
-
constructor({ extern,
|
|
54
|
+
typeofs = ["object"];
|
|
55
|
+
constructor({ extern, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, name, recursive, synthetic, toRdfTypes, ...superParameters }) {
|
|
58
56
|
super(superParameters);
|
|
59
57
|
this.extern = extern;
|
|
60
|
-
this.features = features;
|
|
61
58
|
this.fromRdfType = fromRdfType;
|
|
62
59
|
this.identifierType = identifierType;
|
|
63
60
|
// Lazily initialize some members in getters to avoid recursive construction
|
|
@@ -81,22 +78,23 @@ export class NamedObjectType extends AbstractType {
|
|
|
81
78
|
get childObjectTypes() {
|
|
82
79
|
return this.lazyChildObjectTypes();
|
|
83
80
|
}
|
|
84
|
-
get
|
|
85
|
-
return
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
get conversionFunction() {
|
|
82
|
+
return {
|
|
83
|
+
code: code `${this.reusables.snippets.convertToObject}`,
|
|
84
|
+
sourceTypes: [
|
|
85
|
+
{
|
|
86
|
+
name: this.name,
|
|
87
|
+
typeof: "object",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
93
91
|
}
|
|
94
92
|
get declaration() {
|
|
95
93
|
const declarations = [];
|
|
96
94
|
if (!this.extern) {
|
|
97
95
|
const staticModuleDeclarations = [];
|
|
98
96
|
declarations.push(NamedObjectType_interfaceDeclaration.call(this));
|
|
99
|
-
staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionDeclaration.
|
|
97
|
+
staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionDeclaration.call(this).toList(), ...NamedObjectType_hashFunctionDeclarations.call(this));
|
|
100
98
|
const jsonModuleDeclarations = [
|
|
101
99
|
...NamedObjectType_jsonParseFunctionDeclaration.call(this).toList(),
|
|
102
100
|
...NamedObjectType_jsonSchemaFunctionDeclaration.call(this).toList(),
|
|
@@ -106,17 +104,17 @@ export class NamedObjectType extends AbstractType {
|
|
|
106
104
|
? [
|
|
107
105
|
code `export namespace Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`,
|
|
108
106
|
]
|
|
109
|
-
: []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.
|
|
110
|
-
|
|
107
|
+
: []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfTypeVariableStatement.call(this).toList(), NamedObjectType_isTypeFunctionDeclaration.call(this), NamedObjectType_schemaVariableStatement.call(this), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
|
|
108
|
+
configuration: this.configuration,
|
|
111
109
|
filterType: this.filterType,
|
|
112
110
|
name: this.name,
|
|
113
111
|
reusables: this.reusables,
|
|
114
|
-
})
|
|
115
|
-
|
|
112
|
+
}).toList(), ...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
|
|
113
|
+
configuration: this.configuration,
|
|
116
114
|
filterType: this.filterType,
|
|
117
115
|
name: this.name,
|
|
118
116
|
reusables: this.reusables,
|
|
119
|
-
})
|
|
117
|
+
}).toList(), ...NamedObjectType_toJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_toRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_toStringFunctionDeclarations.call(this), ...NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.call(this).toList());
|
|
120
118
|
if (staticModuleDeclarations.length > 0) {
|
|
121
119
|
declarations.push(code `\
|
|
122
120
|
export namespace ${def(this.name)} {
|
|
@@ -161,6 +159,9 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
161
159
|
get graphqlType() {
|
|
162
160
|
return new AbstractType.GraphqlType(code `${this.name}.GraphQL`, this.reusables);
|
|
163
161
|
}
|
|
162
|
+
get hashFunction() {
|
|
163
|
+
return code `${this.name}.hash`;
|
|
164
|
+
}
|
|
164
165
|
get identifierTypeAlias() {
|
|
165
166
|
return code `${this.name}.Identifier`;
|
|
166
167
|
}
|
|
@@ -168,7 +169,10 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
168
169
|
return this.properties.some((property) => property.mutable);
|
|
169
170
|
}
|
|
170
171
|
get objectSetMethodNames() {
|
|
171
|
-
return NamedObjectType_objectSetMethodNames.call(
|
|
172
|
+
return NamedObjectType_objectSetMethodNames.call({
|
|
173
|
+
configuration: this.configuration,
|
|
174
|
+
name: this.name,
|
|
175
|
+
});
|
|
172
176
|
}
|
|
173
177
|
get parentObjectTypes() {
|
|
174
178
|
return this.lazyParentObjectTypes();
|
|
@@ -218,9 +222,6 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
218
222
|
graphqlResolveExpression({ variables, }) {
|
|
219
223
|
return variables.value;
|
|
220
224
|
}
|
|
221
|
-
hashStatements({ variables, }) {
|
|
222
|
-
return [code `${this.name}.hash(${variables.value}, ${variables.hasher});`];
|
|
223
|
-
}
|
|
224
225
|
jsonSchema({ context, }) {
|
|
225
226
|
let expression = code `${this.name}.Json.schema()`;
|
|
226
227
|
if (context === "property" &&
|
|
@@ -238,12 +239,12 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
238
239
|
toJsonExpression({ variables, }) {
|
|
239
240
|
return code `${this.name}.toJson(${variables.value})`;
|
|
240
241
|
}
|
|
241
|
-
toStringExpression({ variables, }) {
|
|
242
|
-
return code `${this.name}.${syntheticNamePrefix}toString(${variables.value})`;
|
|
243
|
-
}
|
|
244
242
|
toRdfResourceValuesExpression({ variables, }) {
|
|
245
243
|
return code `[${this.name}.toRdfResource(${variables.value}, { graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
|
|
246
244
|
}
|
|
245
|
+
toStringExpression({ variables, }) {
|
|
246
|
+
return code `${this.name}.${this.configuration.syntheticNamePrefix}toString(${variables.value})`;
|
|
247
|
+
}
|
|
247
248
|
lazyAncestorObjectTypes;
|
|
248
249
|
lazyChildObjectTypes;
|
|
249
250
|
lazyDescendantObjectTypes;
|
|
@@ -262,7 +263,7 @@ __decorate([
|
|
|
262
263
|
], NamedObjectType.prototype, "childObjectTypes", null);
|
|
263
264
|
__decorate([
|
|
264
265
|
Memoize()
|
|
265
|
-
], NamedObjectType.prototype, "
|
|
266
|
+
], NamedObjectType.prototype, "conversionFunction", null);
|
|
266
267
|
__decorate([
|
|
267
268
|
Memoize()
|
|
268
269
|
], NamedObjectType.prototype, "descendantFromRdfTypeVariables", null);
|
|
@@ -293,6 +294,9 @@ __decorate([
|
|
|
293
294
|
__decorate([
|
|
294
295
|
Memoize()
|
|
295
296
|
], NamedObjectType.prototype, "graphqlType", null);
|
|
297
|
+
__decorate([
|
|
298
|
+
Memoize()
|
|
299
|
+
], NamedObjectType.prototype, "hashFunction", null);
|
|
296
300
|
__decorate([
|
|
297
301
|
Memoize()
|
|
298
302
|
], NamedObjectType.prototype, "identifierTypeAlias", null);
|
|
@@ -9,8 +9,10 @@ export declare class NamedObjectUnionType extends AbstractNamedUnionType<NamedOb
|
|
|
9
9
|
#private;
|
|
10
10
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
11
11
|
readonly kind = "NamedObjectUnionType";
|
|
12
|
-
|
|
12
|
+
readonly synthetic: boolean;
|
|
13
|
+
constructor({ identifierType, synthetic, ...superParameters }: {
|
|
13
14
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
15
|
+
synthetic: boolean;
|
|
14
16
|
} & Omit<ConstructorParameters<typeof AbstractNamedUnionType<NamedObjectType>>[0], "identifierType">);
|
|
15
17
|
get graphqlType(): AbstractType.GraphqlType;
|
|
16
18
|
get identifierTypeAlias(): Code;
|
|
@@ -14,15 +14,16 @@ import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from ".
|
|
|
14
14
|
import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
|
|
15
15
|
import { AbstractType } from "./AbstractType.js";
|
|
16
16
|
import { singleEntryRecord } from "./singleEntryRecord.js";
|
|
17
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
18
17
|
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
19
18
|
export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
20
19
|
#identifierType;
|
|
21
20
|
graphqlArgs = Maybe.empty();
|
|
22
21
|
kind = "NamedObjectUnionType";
|
|
23
|
-
|
|
22
|
+
synthetic;
|
|
23
|
+
constructor({ identifierType, synthetic, ...superParameters }) {
|
|
24
24
|
super({ ...superParameters, identifierType: Maybe.of(identifierType) });
|
|
25
25
|
this.#identifierType = identifierType;
|
|
26
|
+
this.synthetic = synthetic;
|
|
26
27
|
}
|
|
27
28
|
get graphqlType() {
|
|
28
29
|
return new AbstractType.GraphqlType(code `${this._name}.GraphQL`, this.reusables);
|
|
@@ -31,7 +32,10 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
31
32
|
return code `${this.name}.Identifier`;
|
|
32
33
|
}
|
|
33
34
|
get objectSetMethodNames() {
|
|
34
|
-
return NamedObjectType_objectSetMethodNames.call(
|
|
35
|
+
return NamedObjectType_objectSetMethodNames.call({
|
|
36
|
+
configuration: this.configuration,
|
|
37
|
+
name: this.name,
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
get schema() {
|
|
37
41
|
return code `${this.name}.schema`;
|
|
@@ -50,7 +54,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
50
54
|
...this.isTypeFunctionDeclaration,
|
|
51
55
|
...this.schemaVariableStatement,
|
|
52
56
|
...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
|
|
53
|
-
|
|
57
|
+
configuration: this.configuration,
|
|
54
58
|
filterType: this.filterType,
|
|
55
59
|
name: this.name,
|
|
56
60
|
reusables: this.reusables,
|
|
@@ -58,7 +62,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
58
62
|
.map((code_) => singleEntryRecord(`sparqlConstructQuery`, code_))
|
|
59
63
|
.orDefault({}),
|
|
60
64
|
...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
|
|
61
|
-
|
|
65
|
+
configuration: this.configuration,
|
|
62
66
|
filterType: this.filterType,
|
|
63
67
|
name: this.name,
|
|
64
68
|
reusables: this.reusables,
|
|
@@ -69,7 +73,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
75
|
get focusSparqlConstructTriplesFunctionDeclaration() {
|
|
72
|
-
if (!this.features.has("sparql")) {
|
|
76
|
+
if (!this.configuration.features.has("sparql")) {
|
|
73
77
|
return {};
|
|
74
78
|
}
|
|
75
79
|
return singleEntryRecord(`focusSparqlConstructTriples`, code `\
|
|
@@ -78,7 +82,7 @@ export function focusSparqlConstructTriples({ filter, focusIdentifier, variableP
|
|
|
78
82
|
}`);
|
|
79
83
|
}
|
|
80
84
|
get focusSparqlWherePatternsFunctionDeclaration() {
|
|
81
|
-
if (!this.features.has("sparql")) {
|
|
85
|
+
if (!this.configuration.features.has("sparql")) {
|
|
82
86
|
return {};
|
|
83
87
|
}
|
|
84
88
|
return singleEntryRecord(`focusSparqlWherePatterns`, code `\
|
|
@@ -88,7 +92,7 @@ ${joinCode([
|
|
|
88
92
|
code `\
|
|
89
93
|
if (focusIdentifier.termType === "Variable") {
|
|
90
94
|
patterns = patterns.concat(${this.#identifierType.valueSparqlWherePatternsFunction}({
|
|
91
|
-
filter: filter?.${syntheticNamePrefix}identifier,
|
|
95
|
+
filter: filter?.${this.configuration.syntheticNamePrefix}identifier,
|
|
92
96
|
ignoreRdfType: false,
|
|
93
97
|
preferredLanguages,
|
|
94
98
|
propertyPatterns: [],
|
|
@@ -106,7 +110,7 @@ if (focusIdentifier.termType === "Variable") {
|
|
|
106
110
|
}`);
|
|
107
111
|
}
|
|
108
112
|
get fromRdfResourceFunctionDeclaration() {
|
|
109
|
-
if (!this.features.has("rdf")) {
|
|
113
|
+
if (!this.configuration.features.has("rdf")) {
|
|
110
114
|
return {};
|
|
111
115
|
}
|
|
112
116
|
return singleEntryRecord(`fromRdfResource`, code `\
|
|
@@ -119,14 +123,17 @@ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}
|
|
|
119
123
|
}, null)};`);
|
|
120
124
|
}
|
|
121
125
|
get graphqlTypeVariableStatement() {
|
|
122
|
-
if (!this.features.has("graphql")) {
|
|
126
|
+
if (!this.configuration.features.has("graphql")) {
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
if (this.synthetic) {
|
|
123
130
|
return {};
|
|
124
131
|
}
|
|
125
132
|
return singleEntryRecord(`GraphQL`, code `\
|
|
126
133
|
export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
|
|
127
134
|
description: this.comment.map(JSON.stringify).extract(),
|
|
128
135
|
name: this.name,
|
|
129
|
-
resolveType: code `(value: ${this.name}) => value.${syntheticNamePrefix}type`,
|
|
136
|
+
resolveType: code `(value: ${this.name}) => value.${this.configuration.syntheticNamePrefix}type`,
|
|
130
137
|
types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
|
|
131
138
|
}});`);
|
|
132
139
|
}
|
|
@@ -139,11 +146,11 @@ export namespace Identifier {
|
|
|
139
146
|
}`);
|
|
140
147
|
}
|
|
141
148
|
get isTypeFunctionDeclaration() {
|
|
142
|
-
if (this._name === `${syntheticNamePrefix}Object`) {
|
|
149
|
+
if (this._name === `${this.configuration.syntheticNamePrefix}Object`) {
|
|
143
150
|
return {};
|
|
144
151
|
}
|
|
145
152
|
return singleEntryRecord(`is${this._name}`, code `\
|
|
146
|
-
export function is${this._name}(object: ${syntheticNamePrefix}Object): object is ${this.name} {
|
|
153
|
+
export function is${this._name}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${this.name} {
|
|
147
154
|
return ${joinCode(this.members.map((member) => code `${member.type.name}.is${member.type.name}(object)`), { on: " || " })};
|
|
148
155
|
}`);
|
|
149
156
|
}
|
|
@@ -185,7 +192,7 @@ ${{
|
|
|
185
192
|
}} as const;`);
|
|
186
193
|
}
|
|
187
194
|
get toRdfResourceFunctionDeclaration() {
|
|
188
|
-
if (!this.features.has("rdf")) {
|
|
195
|
+
if (!this.configuration.features.has("rdf")) {
|
|
189
196
|
return {};
|
|
190
197
|
}
|
|
191
198
|
return singleEntryRecord(`toRdfResource`, code `\
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { Maybe
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractContainerType } from "./AbstractContainerType.js";
|
|
3
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
4
|
export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends AbstractContainerType<ItemTypeT> {
|
|
5
5
|
readonly discriminantProperty: Maybe<AbstractContainerType.DiscriminantProperty>;
|
|
6
6
|
readonly graphqlArgs: AbstractContainerType<ItemTypeT>["graphqlArgs"];
|
|
7
7
|
readonly kind = "OptionType";
|
|
8
|
-
readonly typeofs:
|
|
9
|
-
get
|
|
8
|
+
readonly typeofs: "object"[];
|
|
9
|
+
get conversionFunction(): AbstractContainerType.ConversionFunction;
|
|
10
10
|
get equalsFunction(): Code;
|
|
11
11
|
get filterFunction(): Code;
|
|
12
|
+
get hashFunction(): Code;
|
|
12
13
|
get filterType(): Code;
|
|
13
14
|
get graphqlType(): AbstractContainerType.GraphqlType;
|
|
14
15
|
get mutable(): boolean;
|
|
@@ -23,7 +24,6 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
|
|
|
23
24
|
fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
|
|
24
25
|
fromRdfResourceValuesExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
25
26
|
graphqlResolveExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;
|
|
26
|
-
hashStatements({ depth, variables, }: Parameters<AbstractContainerType<ItemTypeT>["hashStatements"]>[0]): readonly Code[];
|
|
27
27
|
jsonType(parameters?: Parameters<AbstractContainerType<ItemTypeT>["jsonType"]>[0]): AbstractContainerType.JsonType;
|
|
28
28
|
jsonUiSchemaElement(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
29
29
|
jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
|
|
@@ -4,45 +4,29 @@ 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
|
|
7
|
+
import { Maybe } from "purify-ts";
|
|
8
8
|
import { invariant } from "ts-invariant";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
|
-
import { AbstractCollectionType } from "./AbstractCollectionType.js";
|
|
11
10
|
import { AbstractContainerType } from "./AbstractContainerType.js";
|
|
12
11
|
import { codeEquals } from "./codeEquals.js";
|
|
13
|
-
import { code,
|
|
12
|
+
import { code, literalOf } from "./ts-poet-wrapper.js";
|
|
14
13
|
export class OptionType extends AbstractContainerType {
|
|
15
14
|
discriminantProperty = Maybe.empty();
|
|
16
15
|
graphqlArgs = Maybe.empty();
|
|
17
16
|
kind = "OptionType";
|
|
18
|
-
typeofs =
|
|
19
|
-
get
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
// Unless itemType is a list, it should only have a conversion from undefined if it has a
|
|
34
|
-
// defaultValue. Per the CST->AST transformation logic, a type with a defaultValue
|
|
35
|
-
// should never be wrapped in an OptionType.
|
|
36
|
-
invariant(!conversions.some((conversion) => conversion.sourceTypeof === "undefined") || this.itemType instanceof AbstractCollectionType);
|
|
37
|
-
if (!conversions.some((conversion) => conversion.sourceTypeof === "undefined")) {
|
|
38
|
-
conversions.push({
|
|
39
|
-
conversionExpression: () => code `${this.reusables.imports.Maybe}.empty()`,
|
|
40
|
-
sourceTypeCheckExpression: (value) => code `${value} === undefined`,
|
|
41
|
-
sourceTypeName: code `undefined`,
|
|
42
|
-
sourceTypeof: "undefined",
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return conversions;
|
|
17
|
+
typeofs = ["object"];
|
|
18
|
+
get conversionFunction() {
|
|
19
|
+
const itemConversionFunction = this.itemType.conversionFunction;
|
|
20
|
+
return {
|
|
21
|
+
code: code `${this.reusables.snippets.convertToMaybe}(${itemConversionFunction.code})`,
|
|
22
|
+
sourceTypes: itemConversionFunction.sourceTypes.concat({
|
|
23
|
+
name: this.name,
|
|
24
|
+
typeof: "object",
|
|
25
|
+
}, {
|
|
26
|
+
name: code `undefined`,
|
|
27
|
+
typeof: "undefined",
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
46
30
|
}
|
|
47
31
|
get equalsFunction() {
|
|
48
32
|
return code `((left, right) => ${this.reusables.snippets.maybeEquals}(left, right, ${this.itemType.equalsFunction}))`;
|
|
@@ -50,6 +34,9 @@ export class OptionType extends AbstractContainerType {
|
|
|
50
34
|
get filterFunction() {
|
|
51
35
|
return code `${this.reusables.snippets.filterMaybe}<${this.itemType.name}, ${this.itemType.filterType}>(${this.itemType.filterFunction})`;
|
|
52
36
|
}
|
|
37
|
+
get hashFunction() {
|
|
38
|
+
return code `${this.reusables.snippets.hashMaybe}(${this.itemType.hashFunction})`;
|
|
39
|
+
}
|
|
53
40
|
get filterType() {
|
|
54
41
|
return code `${this.reusables.snippets.MaybeFilter}<${this.itemType.filterType}>`;
|
|
55
42
|
}
|
|
@@ -97,19 +84,6 @@ export class OptionType extends AbstractContainerType {
|
|
|
97
84
|
graphqlResolveExpression(parameters) {
|
|
98
85
|
return code `${this.itemType.graphqlResolveExpression(parameters)}.extractNullable()`;
|
|
99
86
|
}
|
|
100
|
-
hashStatements({ depth, variables, }) {
|
|
101
|
-
return [
|
|
102
|
-
code `${variables.value}.ifJust((value${depth}) => { ${joinCode(this.itemType
|
|
103
|
-
.hashStatements({
|
|
104
|
-
depth: depth + 1,
|
|
105
|
-
variables: {
|
|
106
|
-
hasher: variables.hasher,
|
|
107
|
-
value: code `value${depth}`,
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
.concat())} });`,
|
|
111
|
-
];
|
|
112
|
-
}
|
|
113
87
|
jsonType(parameters) {
|
|
114
88
|
const itemTypeJsonType = this.itemType.jsonType(parameters);
|
|
115
89
|
invariant(!itemTypeJsonType.optional);
|
|
@@ -142,13 +116,16 @@ export class OptionType extends AbstractContainerType {
|
|
|
142
116
|
}
|
|
143
117
|
__decorate([
|
|
144
118
|
Memoize()
|
|
145
|
-
], OptionType.prototype, "
|
|
119
|
+
], OptionType.prototype, "conversionFunction", null);
|
|
146
120
|
__decorate([
|
|
147
121
|
Memoize()
|
|
148
122
|
], OptionType.prototype, "equalsFunction", null);
|
|
149
123
|
__decorate([
|
|
150
124
|
Memoize()
|
|
151
125
|
], OptionType.prototype, "filterFunction", null);
|
|
126
|
+
__decorate([
|
|
127
|
+
Memoize()
|
|
128
|
+
], OptionType.prototype, "hashFunction", null);
|
|
152
129
|
__decorate([
|
|
153
130
|
Memoize()
|
|
154
131
|
], OptionType.prototype, "filterType", null);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Logger } from "ts-log";
|
|
2
2
|
import { Imports } from "./Imports.js";
|
|
3
3
|
import { Snippets } from "./Snippets.js";
|
|
4
|
+
import type { TsGenerator } from "./TsGenerator.js";
|
|
4
5
|
export declare class Reusables {
|
|
5
6
|
readonly imports: Imports;
|
|
6
7
|
readonly snippets: Snippets;
|
|
7
|
-
constructor({ logger }: {
|
|
8
|
+
constructor({ configuration, logger, }: {
|
|
9
|
+
configuration: TsGenerator.Configuration;
|
|
8
10
|
logger: Logger;
|
|
9
11
|
});
|
|
10
12
|
}
|
|
@@ -3,9 +3,10 @@ import { Snippets } from "./Snippets.js";
|
|
|
3
3
|
export class Reusables {
|
|
4
4
|
imports;
|
|
5
5
|
snippets;
|
|
6
|
-
constructor({ logger }) {
|
|
6
|
+
constructor({ configuration, logger, }) {
|
|
7
7
|
this.imports = new Imports();
|
|
8
8
|
this.snippets = new Snippets({
|
|
9
|
+
configuration,
|
|
9
10
|
imports: this.imports,
|
|
10
11
|
logger,
|
|
11
12
|
});
|
|
@@ -3,7 +3,6 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
3
3
|
export declare class SetType<ItemTypeT extends SetType.ItemType> extends AbstractCollectionType<ItemTypeT> {
|
|
4
4
|
readonly graphqlArgs: AbstractCollectionType<ItemTypeT>["graphqlArgs"];
|
|
5
5
|
readonly kind = "SetType";
|
|
6
|
-
get conversions(): readonly AbstractCollectionType.Conversion[];
|
|
7
6
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
8
7
|
get valueSparqlWherePatternsFunction(): Code;
|
|
9
8
|
fromRdfResourceValuesExpression(parameters: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
@@ -11,18 +11,6 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
|
11
11
|
export class SetType extends AbstractCollectionType {
|
|
12
12
|
graphqlArgs = Maybe.empty();
|
|
13
13
|
kind = "SetType";
|
|
14
|
-
get conversions() {
|
|
15
|
-
const conversions = [];
|
|
16
|
-
if (this.minCount === 0n) {
|
|
17
|
-
conversions.push({
|
|
18
|
-
conversionExpression: () => code `[]`,
|
|
19
|
-
sourceTypeCheckExpression: (value) => code `${value} === undefined`,
|
|
20
|
-
sourceTypeName: code `undefined`,
|
|
21
|
-
sourceTypeof: "undefined",
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return conversions.concat(super.conversions);
|
|
25
|
-
}
|
|
26
14
|
get valueSparqlConstructTriplesFunction() {
|
|
27
15
|
return code `${this.reusables.snippets.setSparqlConstructTriples}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlConstructTriplesFunction})`;
|
|
28
16
|
}
|
|
@@ -31,17 +19,11 @@ export class SetType extends AbstractCollectionType {
|
|
|
31
19
|
}
|
|
32
20
|
fromRdfResourceValuesExpression(parameters) {
|
|
33
21
|
const { variables } = parameters;
|
|
34
|
-
|
|
22
|
+
return joinCode([
|
|
35
23
|
this.itemType.fromRdfResourceValuesExpression(parameters),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
chain.push(code `chain(values => ${this.reusables.imports.NonEmptyList}.fromArray(values.toArray()).toEither(new Error(\`\${${variables.resource}.identifier} is an empty set\`)))`);
|
|
42
|
-
}
|
|
43
|
-
chain.push(code `map(valuesArray => ${this.reusables.imports.Resource}.Values.fromValue({ focusResource: ${variables.resource}, propertyPath: ${variables.propertyPath}, value: valuesArray }))`);
|
|
44
|
-
return joinCode(chain, { on: "." });
|
|
24
|
+
code `map(values => values.toArray()${this._mutable ? ".concat()" : ""})`,
|
|
25
|
+
code `map(valuesArray => ${this.reusables.imports.Resource}.Values.fromValue({ focusResource: ${variables.resource}, propertyPath: ${variables.propertyPath}, value: valuesArray }))`,
|
|
26
|
+
], { on: "." });
|
|
45
27
|
}
|
|
46
28
|
jsonType() {
|
|
47
29
|
const name = code `${!this.mutable ? "readonly " : ""}(${this.itemType.jsonType().name})[]`;
|
|
@@ -3,8 +3,10 @@ import type { Logger } from "ts-log";
|
|
|
3
3
|
import type { Imports } from "./Imports.js";
|
|
4
4
|
import type { Snippet } from "./Snippet.js";
|
|
5
5
|
import type { Snippets } from "./Snippets.js";
|
|
6
|
+
import type { TsGenerator } from "./TsGenerator.js";
|
|
6
7
|
import type { Code } from "./ts-poet-wrapper.js";
|
|
7
8
|
export type SnippetFactory = (parameters: {
|
|
9
|
+
configuration: TsGenerator.Configuration;
|
|
8
10
|
imports: Imports;
|
|
9
11
|
logger: Logger;
|
|
10
12
|
rdfjsTermExpression: (rdfjsTerm: Omit<BlankNode, "equals"> | Omit<Literal, "equals"> | Omit<NamedNode, "equals"> | Omit<Variable, "equals">) => Code;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Logger } from "ts-log";
|
|
2
2
|
import type { Imports } from "./Imports.js";
|
|
3
3
|
import type { Snippet } from "./Snippet.js";
|
|
4
|
+
import type { TsGenerator } from "./TsGenerator.js";
|
|
4
5
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
5
6
|
export declare class Snippets {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
private readonly configuration;
|
|
8
|
+
private readonly imports;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor({ configuration, imports, logger, }: {
|
|
11
|
+
configuration: TsGenerator.Configuration;
|
|
9
12
|
imports: Imports;
|
|
10
13
|
logger: Logger;
|
|
11
14
|
});
|
|
@@ -23,6 +26,7 @@ export declare class Snippets {
|
|
|
23
26
|
get FocusSparqlWherePatternsFunction(): Snippet;
|
|
24
27
|
get FromRdfResourceFunction(): Snippet;
|
|
25
28
|
get FromRdfResourceValuesFunction(): Snippet;
|
|
29
|
+
get HashFunction(): Snippet;
|
|
26
30
|
get Hasher(): Snippet;
|
|
27
31
|
get IdentifierFilter(): Snippet;
|
|
28
32
|
get IdentifierSchema(): Snippet;
|
|
@@ -63,6 +67,29 @@ export declare class Snippets {
|
|
|
63
67
|
get booleanEquals(): Snippet;
|
|
64
68
|
get booleanSparqlWherePatterns(): Snippet;
|
|
65
69
|
get compactRecord(): Snippet;
|
|
70
|
+
get convertToBigDecimal(): Snippet;
|
|
71
|
+
get convertToBlankNode(): Snippet;
|
|
72
|
+
get convertToBlankNodeIdentifierProperty(): Snippet;
|
|
73
|
+
get convertToBoolean(): Snippet;
|
|
74
|
+
get convertToDate(): Snippet;
|
|
75
|
+
get convertToDateTime(): Snippet;
|
|
76
|
+
get convertToIdentifier(): Snippet;
|
|
77
|
+
get convertToIdentifierProperty(): Snippet;
|
|
78
|
+
get convertToIri(): Snippet;
|
|
79
|
+
get convertToIriIdentifierProperty(): Snippet;
|
|
80
|
+
get convertToLazyObject(): Snippet;
|
|
81
|
+
get convertToLazyObjectOption(): Snippet;
|
|
82
|
+
get convertToLazyObjectSet(): Snippet;
|
|
83
|
+
get convertToLiteral(): Snippet;
|
|
84
|
+
get convertToMaybe(): Snippet;
|
|
85
|
+
get convertToMutableArray(): Snippet;
|
|
86
|
+
get convertToNumeric(): Snippet;
|
|
87
|
+
get convertToObject(): Snippet;
|
|
88
|
+
get convertToReadonlyArray(): Snippet;
|
|
89
|
+
get convertToString(): Snippet;
|
|
90
|
+
get convertToTerm(): Snippet;
|
|
91
|
+
get convertToUnion(): Snippet;
|
|
92
|
+
get convertWithDefaultValue(): Snippet;
|
|
66
93
|
get dateEquals(): Snippet;
|
|
67
94
|
get dateSparqlWherePatterns(): Snippet;
|
|
68
95
|
get decodeBigDecimalLiteral(): Snippet;
|
|
@@ -82,14 +109,18 @@ export declare class Snippets {
|
|
|
82
109
|
get filterTerm(): Snippet;
|
|
83
110
|
get fromRdfLanguageIn(): Snippet;
|
|
84
111
|
get fromRdfPreferredLanguages(): Snippet;
|
|
112
|
+
get hashArray(): Snippet;
|
|
113
|
+
get hashBigDecimal(): Snippet;
|
|
114
|
+
get hashBoolean(): Snippet;
|
|
115
|
+
get hashDate(): Snippet;
|
|
116
|
+
get hashDateTime(): Snippet;
|
|
117
|
+
get hashMaybe(): Snippet;
|
|
118
|
+
get hashNumeric(): Snippet;
|
|
119
|
+
get hashString(): Snippet;
|
|
120
|
+
get hashTerm(): Snippet;
|
|
85
121
|
get identifierSparqlWherePatterns(): Snippet;
|
|
86
122
|
get ifUsed(): Code[];
|
|
87
123
|
get iriSparqlWherePatterns(): Snippet;
|
|
88
|
-
get isReadonlyBigIntArray(): Snippet;
|
|
89
|
-
get isReadonlyBooleanArray(): Snippet;
|
|
90
|
-
get isReadonlyNumberArray(): Snippet;
|
|
91
|
-
get isReadonlyObjectArray(): Snippet;
|
|
92
|
-
get isReadonlyStringArray(): Snippet;
|
|
93
124
|
get liftSparqlPatterns(): Snippet;
|
|
94
125
|
get listSparqlConstructTriples(): Snippet;
|
|
95
126
|
get listSparqlWherePatterns(): Snippet;
|
|
@@ -119,6 +150,7 @@ export declare class Snippets {
|
|
|
119
150
|
get termFilterSparqlPatterns(): Snippet;
|
|
120
151
|
get termSchemaSparqlPatterns(): Snippet;
|
|
121
152
|
get termSparqlWherePatterns(): Snippet;
|
|
153
|
+
get toIsoDateString(): Snippet;
|
|
122
154
|
get wrap_FromRdfResourceFunction(): Snippet;
|
|
123
155
|
get wrap_ToRdfResourceFunction(): Snippet;
|
|
124
156
|
protected get snippets(): Snippets;
|