@shaclmate/compiler 4.0.39 → 4.0.40
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/generators/ts/AbstractCollectionType.d.ts +1 -1
- package/dist/generators/ts/AbstractCollectionType.js +10 -10
- package/dist/generators/ts/AbstractContainerType.d.ts +4 -5
- package/dist/generators/ts/AbstractContainerType.js +4 -5
- package/dist/generators/ts/AbstractDateType.d.ts +3 -3
- package/dist/generators/ts/AbstractDateType.js +2 -2
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +8 -8
- package/dist/generators/ts/AbstractLazyObjectType.js +19 -19
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractNumericType.js +3 -3
- package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
- package/dist/generators/ts/AbstractObjectSetType.js +2 -2
- package/dist/generators/ts/AbstractPrimitiveType.js +2 -2
- package/dist/generators/ts/AbstractTermType.js +2 -2
- package/dist/generators/ts/AbstractType.d.ts +15 -10
- package/dist/generators/ts/AbstractType.js +6 -1
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigDecimalType.js +2 -2
- package/dist/generators/ts/BigIntType.js +2 -2
- package/dist/generators/ts/BlankNodeType.d.ts +3 -3
- package/dist/generators/ts/BlankNodeType.js +11 -11
- package/dist/generators/ts/BooleanType.d.ts +2 -2
- package/dist/generators/ts/BooleanType.js +10 -5
- package/dist/generators/ts/DefaultValueType.d.ts +1 -1
- package/dist/generators/ts/DefaultValueType.js +8 -9
- package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
- package/dist/generators/ts/GraphqlSchema.js +4 -4
- package/dist/generators/ts/IdentifierType.d.ts +3 -3
- package/dist/generators/ts/IdentifierType.js +13 -13
- package/dist/generators/ts/IriType.d.ts +2 -2
- package/dist/generators/ts/IriType.js +17 -17
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -0
- package/dist/generators/ts/LazyObjectOptionType.js +6 -6
- package/dist/generators/ts/LazyObjectSetType.js +5 -5
- package/dist/generators/ts/LazyObjectType.js +4 -4
- package/dist/generators/ts/ListType.d.ts +4 -5
- package/dist/generators/ts/ListType.js +3 -4
- package/dist/generators/ts/LiteralType.d.ts +1 -1
- package/dist/generators/ts/LiteralType.js +5 -5
- package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +23 -24
- package/dist/generators/ts/ObjectType.js +350 -0
- package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
- package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +50 -58
- package/dist/generators/ts/OptionType.d.ts +1 -1
- package/dist/generators/ts/OptionType.js +10 -10
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -8
- package/dist/generators/ts/SparqlObjectSetType.js +2 -2
- package/dist/generators/ts/StringType.d.ts +2 -2
- package/dist/generators/ts/StringType.js +10 -5
- package/dist/generators/ts/TermType.d.ts +2 -2
- package/dist/generators/ts/TermType.js +12 -12
- package/dist/generators/ts/TsGenerator.js +12 -9
- package/dist/generators/ts/Type.d.ts +4 -5
- package/dist/generators/ts/TypeFactory.d.ts +7 -8
- package/dist/generators/ts/TypeFactory.js +61 -62
- package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +33 -5
- package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +262 -58
- package/dist/generators/ts/ZodGenerator.js +7 -9
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +6 -6
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +3 -3
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +1 -1
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +8 -8
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +1 -5
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +15 -10
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_createFunctionDeclaration.js → _ObjectType/ObjectType_createFunctionDeclaration.js} +6 -6
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js → _ObjectType/ObjectType_fromJsonFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js → _ObjectType/ObjectType_hashFunctionDeclarations.js} +6 -6
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_interfaceDeclaration.js → _ObjectType/ObjectType_interfaceDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js → _ObjectType/ObjectType_isTypeFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js → _ObjectType/ObjectType_jsonTypeAliasDeclaration.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +14 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js → _ObjectType/ObjectType_toJsonFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +6 -6
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +7 -7
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/identifierTypeDeclarations.js +4 -2
- package/dist/input/generated.d.ts +2 -2
- package/dist/input/generated.js +2 -2
- package/package.json +4 -4
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
- package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
- package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
- package/dist/generators/ts/AnonymousUnionType.js +0 -59
- package/dist/generators/ts/NamedObjectType.js +0 -342
- package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
- package/dist/generators/ts/NamedUnionType.d.ts +0 -11
- package/dist/generators/ts/NamedUnionType.js +0 -13
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +0 -0
|
@@ -6,44 +6,38 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { PropertyPath } from "@rdfx/resource";
|
|
8
8
|
import { pascalCase } from "change-case";
|
|
9
|
-
import { Maybe } from "purify-ts";
|
|
10
9
|
import { Memoize } from "typescript-memoize";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
|
|
15
|
-
import { AbstractType } from "./AbstractType.js";
|
|
10
|
+
import { ObjectType_objectSetMethodNames } from "./_ObjectType/ObjectType_objectSetMethodNames.js";
|
|
11
|
+
import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
12
|
+
import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
16
13
|
import { singleEntryRecord } from "./singleEntryRecord.js";
|
|
17
14
|
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
kind = "NamedObjectUnion";
|
|
22
|
-
synthetic;
|
|
23
|
-
constructor({ identifierType, synthetic, ...superParameters }) {
|
|
24
|
-
super({ ...superParameters, identifierType: Maybe.of(identifierType) });
|
|
25
|
-
this.#identifierType = identifierType;
|
|
26
|
-
this.synthetic = synthetic;
|
|
27
|
-
}
|
|
28
|
-
get graphqlType() {
|
|
29
|
-
return new AbstractType.GraphqlType(code `${this._name}.GraphQL`, this.reusables);
|
|
30
|
-
}
|
|
15
|
+
import { UnionType } from "./UnionType.js";
|
|
16
|
+
export class ObjectUnionType extends UnionType {
|
|
17
|
+
kind = "ObjectUnion";
|
|
31
18
|
get identifierTypeAlias() {
|
|
32
|
-
return code `${
|
|
19
|
+
return this.alias.map((alias) => code `${alias}.Identifier`).unsafeCoerce();
|
|
33
20
|
}
|
|
34
21
|
get objectSetMethodNames() {
|
|
35
|
-
return
|
|
22
|
+
return this.alias
|
|
23
|
+
.map((alias) => ObjectType_objectSetMethodNames.call({
|
|
24
|
+
alias,
|
|
36
25
|
configuration: this.configuration,
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
}))
|
|
27
|
+
.unsafeCoerce();
|
|
39
28
|
}
|
|
40
29
|
get schema() {
|
|
41
|
-
return
|
|
30
|
+
return this.alias
|
|
31
|
+
.map((alias) => code `${alias}.schema`)
|
|
32
|
+
.orDefault(super.schema);
|
|
42
33
|
}
|
|
43
34
|
get schemaType() {
|
|
44
|
-
return
|
|
35
|
+
return this.alias
|
|
36
|
+
.map(() => code `typeof ${this.schema}`)
|
|
37
|
+
.orDefault(super.schemaType);
|
|
45
38
|
}
|
|
46
39
|
get staticModuleDeclarations() {
|
|
40
|
+
const alias = this.alias.unsafeCoerce();
|
|
47
41
|
return {
|
|
48
42
|
...super.staticModuleDeclarations,
|
|
49
43
|
...this.identifierTypeDeclarations,
|
|
@@ -53,18 +47,18 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
53
47
|
...this.graphqlTypeVariableStatement,
|
|
54
48
|
...this.isTypeFunctionDeclaration,
|
|
55
49
|
...this.schemaVariableStatement,
|
|
56
|
-
...
|
|
50
|
+
...ObjectType_sparqlConstructQueryFunctionDeclaration.call({
|
|
51
|
+
alias,
|
|
57
52
|
configuration: this.configuration,
|
|
58
53
|
filterType: this.filterType,
|
|
59
|
-
name: this.name,
|
|
60
54
|
reusables: this.reusables,
|
|
61
55
|
})
|
|
62
56
|
.map((code_) => singleEntryRecord(`sparqlConstructQuery`, code_))
|
|
63
57
|
.orDefault({}),
|
|
64
|
-
...
|
|
58
|
+
...ObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
|
|
59
|
+
alias,
|
|
65
60
|
configuration: this.configuration,
|
|
66
61
|
filterType: this.filterType,
|
|
67
|
-
name: this.name,
|
|
68
62
|
reusables: this.reusables,
|
|
69
63
|
})
|
|
70
64
|
.map((code_) => singleEntryRecord(`sparqlConstructQueryString`, code_))
|
|
@@ -78,7 +72,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
78
72
|
}
|
|
79
73
|
return singleEntryRecord(`focusSparqlConstructTriples`, code `\
|
|
80
74
|
export function focusSparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${this.reusables.imports.NamedNode} | ${this.reusables.imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${this.reusables.imports.sparqljs}.Triple[] {
|
|
81
|
-
return [${joinCode(this.members.map((member) => code `...${member.type.
|
|
75
|
+
return [${joinCode(this.members.map((member) => code `...${member.type.alias.unsafeCoerce()}.focusSparqlConstructTriples({ filter: filter?.on?.${member.type.alias.unsafeCoerce()}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.alias.unsafeCoerce())}\` }).concat()`), { on: ", " })}];
|
|
82
76
|
}`);
|
|
83
77
|
}
|
|
84
78
|
get focusSparqlWherePatternsFunctionDeclaration() {
|
|
@@ -91,18 +85,18 @@ ${joinCode([
|
|
|
91
85
|
code `let patterns: ${this.reusables.snippets.SparqlPattern}[] = [];`,
|
|
92
86
|
code `\
|
|
93
87
|
if (focusIdentifier.termType === "Variable") {
|
|
94
|
-
patterns = patterns.concat(${this
|
|
88
|
+
patterns = patterns.concat(${this.identifierType.unsafeCoerce().valueSparqlWherePatternsFunction}({
|
|
95
89
|
filter: filter?.${this.configuration.syntheticNamePrefix}identifier,
|
|
96
90
|
ignoreRdfType: false,
|
|
97
91
|
preferredLanguages,
|
|
98
92
|
propertyPatterns: [],
|
|
99
|
-
schema: ${this
|
|
93
|
+
schema: ${this.identifierType.unsafeCoerce().schema},
|
|
100
94
|
valueVariable: focusIdentifier,
|
|
101
95
|
variablePrefix,
|
|
102
96
|
}));
|
|
103
97
|
}`,
|
|
104
98
|
code `patterns.push({ patterns: [${joinCode(this.members.map((member) => code `${{
|
|
105
|
-
patterns: code `${member.type.
|
|
99
|
+
patterns: code `${member.type.alias.unsafeCoerce()}.focusSparqlWherePatterns({ filter: filter?.on?.${member.type.alias.unsafeCoerce()}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.alias.unsafeCoerce())}\` }).concat()`,
|
|
106
100
|
type: literalOf("group"),
|
|
107
101
|
}}`), { on: ", " })}], type: "union" });`,
|
|
108
102
|
code `return patterns;`,
|
|
@@ -113,10 +107,11 @@ if (focusIdentifier.termType === "Variable") {
|
|
|
113
107
|
if (!this.configuration.features.has("Object.fromRdf")) {
|
|
114
108
|
return {};
|
|
115
109
|
}
|
|
110
|
+
const alias = this.alias.unsafeCoerce();
|
|
116
111
|
return singleEntryRecord(`fromRdfResource`, code `\
|
|
117
|
-
export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<${
|
|
112
|
+
export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<${alias}> = (resource, options) =>
|
|
118
113
|
${this.members.reduce((expression, member) => {
|
|
119
|
-
const memberTypeExpression = code `(${member.type.
|
|
114
|
+
const memberTypeExpression = code `(${member.type.alias.unsafeCoerce()}.fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${this.reusables.imports.Either}<Error, ${alias}>)`;
|
|
120
115
|
return expression !== null
|
|
121
116
|
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
122
117
|
: memberTypeExpression;
|
|
@@ -129,11 +124,12 @@ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}
|
|
|
129
124
|
if (this.synthetic) {
|
|
130
125
|
return {};
|
|
131
126
|
}
|
|
127
|
+
const alias = this.alias.unsafeCoerce();
|
|
132
128
|
return singleEntryRecord(`GraphQL`, code `\
|
|
133
129
|
export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
|
|
134
130
|
description: this.comment.map(JSON.stringify).extract(),
|
|
135
|
-
name:
|
|
136
|
-
resolveType: code `(value: ${
|
|
131
|
+
name: alias,
|
|
132
|
+
resolveType: code `(value: ${alias}) => value.${this.configuration.syntheticNamePrefix}type`,
|
|
137
133
|
types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
|
|
138
134
|
}});`);
|
|
139
135
|
}
|
|
@@ -142,22 +138,23 @@ export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
|
|
|
142
138
|
return {};
|
|
143
139
|
}
|
|
144
140
|
return singleEntryRecord(`Identifier`, code `\
|
|
145
|
-
export type Identifier = ${this
|
|
141
|
+
export type Identifier = ${this.identifierType.unsafeCoerce().expression};
|
|
146
142
|
export namespace Identifier {
|
|
147
|
-
export const parse = ${this
|
|
148
|
-
export const stringify = ${this
|
|
143
|
+
export const parse = ${this.identifierType.unsafeCoerce().parseFunction};
|
|
144
|
+
export const stringify = ${this.identifierType.unsafeCoerce().stringifyFunction};
|
|
149
145
|
}`);
|
|
150
146
|
}
|
|
151
147
|
get isTypeFunctionDeclaration() {
|
|
152
148
|
if (!this.configuration.features.has("Object.type")) {
|
|
153
149
|
return {};
|
|
154
150
|
}
|
|
155
|
-
|
|
151
|
+
const alias = this.alias.unsafeCoerce();
|
|
152
|
+
if (alias === `${this.configuration.syntheticNamePrefix}Object`) {
|
|
156
153
|
return {};
|
|
157
154
|
}
|
|
158
|
-
return singleEntryRecord(`is${
|
|
159
|
-
export function is${
|
|
160
|
-
return ${joinCode(this.members.map((member) => code `${member.type.
|
|
155
|
+
return singleEntryRecord(`is${alias}`, code `\
|
|
156
|
+
export function is${alias}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${alias} {
|
|
157
|
+
return ${joinCode(this.members.map((member) => code `${member.type.alias.unsafeCoerce()}.is${member.type.alias.unsafeCoerce()}(object)`), { on: " || " })};
|
|
161
158
|
}`);
|
|
162
159
|
}
|
|
163
160
|
get schemaVariableStatement() {
|
|
@@ -191,7 +188,7 @@ export namespace Identifier {
|
|
|
191
188
|
if (!memberTypesWithProperty.every((value) => value)) {
|
|
192
189
|
continue;
|
|
193
190
|
}
|
|
194
|
-
property.schema.ifJust(propertySchema => {
|
|
191
|
+
property.schema.ifJust((propertySchema) => {
|
|
195
192
|
propertiesObject.push(code `${property.name}: ${propertySchema}`);
|
|
196
193
|
});
|
|
197
194
|
}
|
|
@@ -202,30 +199,25 @@ export const schema = { ${joinCode(super.schemaInitializers.concat(code `propert
|
|
|
202
199
|
if (!this.configuration.features.has("Object.toRdf")) {
|
|
203
200
|
return {};
|
|
204
201
|
}
|
|
202
|
+
const alias = this.alias.unsafeCoerce();
|
|
205
203
|
return singleEntryRecord(`toRdfResource`, code `\
|
|
206
|
-
export const toRdfResource: ${this.reusables.snippets.ToRdfResourceFunction}<${
|
|
204
|
+
export const toRdfResource: ${this.reusables.snippets.ToRdfResourceFunction}<${alias}> = (object, options) => {
|
|
207
205
|
${joinCode(this.members
|
|
208
|
-
.map((member) => code `if (${member.type.
|
|
206
|
+
.map((member) => code `if (${member.type.alias.unsafeCoerce()}.is${member.type.alias.unsafeCoerce()}(object)) { return ${member.type.alias.unsafeCoerce()}.toRdfResource(object, options); }`)
|
|
209
207
|
.concat(code `throw new Error("unrecognized type");`))}
|
|
210
208
|
};`);
|
|
211
209
|
}
|
|
212
|
-
graphqlResolveExpression({ variables, }) {
|
|
213
|
-
return variables.value;
|
|
214
|
-
}
|
|
215
210
|
}
|
|
216
211
|
__decorate([
|
|
217
212
|
Memoize()
|
|
218
|
-
],
|
|
219
|
-
__decorate([
|
|
220
|
-
Memoize()
|
|
221
|
-
], NamedObjectUnionType.prototype, "identifierTypeAlias", null);
|
|
213
|
+
], ObjectUnionType.prototype, "identifierTypeAlias", null);
|
|
222
214
|
__decorate([
|
|
223
215
|
Memoize()
|
|
224
|
-
],
|
|
216
|
+
], ObjectUnionType.prototype, "objectSetMethodNames", null);
|
|
225
217
|
__decorate([
|
|
226
218
|
Memoize()
|
|
227
|
-
],
|
|
219
|
+
], ObjectUnionType.prototype, "schema", null);
|
|
228
220
|
__decorate([
|
|
229
221
|
Memoize()
|
|
230
|
-
],
|
|
231
|
-
//# sourceMappingURL=
|
|
222
|
+
], ObjectUnionType.prototype, "schemaType", null);
|
|
223
|
+
//# sourceMappingURL=ObjectUnionType.js.map
|
|
@@ -8,12 +8,12 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
|
|
|
8
8
|
readonly typeofs: "object"[];
|
|
9
9
|
get conversionFunction(): Maybe<AbstractContainerType.ConversionFunction>;
|
|
10
10
|
get equalsFunction(): Code;
|
|
11
|
+
get expression(): Code;
|
|
11
12
|
get filterFunction(): Code;
|
|
12
13
|
get filterType(): Code;
|
|
13
14
|
get graphqlType(): AbstractContainerType.GraphqlType;
|
|
14
15
|
get hashFunction(): Code;
|
|
15
16
|
get mutable(): boolean;
|
|
16
|
-
get name(): Code;
|
|
17
17
|
get schemaType(): Code;
|
|
18
18
|
get validationFunction(): Maybe<Code>;
|
|
19
19
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
@@ -20,10 +20,10 @@ export class OptionType extends AbstractContainerType {
|
|
|
20
20
|
return Maybe.of({
|
|
21
21
|
code: code `${this.reusables.snippets.convertToMaybe}(${itemConversionFunction.code})`,
|
|
22
22
|
sourceTypes: itemConversionFunction.sourceTypes.concat({
|
|
23
|
-
|
|
23
|
+
expression: this.expression,
|
|
24
24
|
typeof: "object",
|
|
25
25
|
}, {
|
|
26
|
-
|
|
26
|
+
expression: code `undefined`,
|
|
27
27
|
typeof: "undefined",
|
|
28
28
|
}),
|
|
29
29
|
});
|
|
@@ -31,8 +31,11 @@ export class OptionType extends AbstractContainerType {
|
|
|
31
31
|
get equalsFunction() {
|
|
32
32
|
return code `((left, right) => ${this.reusables.snippets.maybeEquals}(left, right, ${this.itemType.equalsFunction}))`;
|
|
33
33
|
}
|
|
34
|
+
get expression() {
|
|
35
|
+
return code `${this.reusables.imports.Maybe}<${this.itemType.expression}>`;
|
|
36
|
+
}
|
|
34
37
|
get filterFunction() {
|
|
35
|
-
return code `${this.reusables.snippets.filterMaybe}<${this.itemType.
|
|
38
|
+
return code `${this.reusables.snippets.filterMaybe}<${this.itemType.expression}, ${this.itemType.filterType}>(${this.itemType.filterFunction})`;
|
|
36
39
|
}
|
|
37
40
|
get filterType() {
|
|
38
41
|
return code `${this.reusables.snippets.MaybeFilter}<${this.itemType.filterType}>`;
|
|
@@ -49,9 +52,6 @@ export class OptionType extends AbstractContainerType {
|
|
|
49
52
|
get mutable() {
|
|
50
53
|
return this.itemType.mutable;
|
|
51
54
|
}
|
|
52
|
-
get name() {
|
|
53
|
-
return code `${this.reusables.imports.Maybe}<${this.itemType.name}>`;
|
|
54
|
-
}
|
|
55
55
|
get schemaType() {
|
|
56
56
|
return code `${this.reusables.snippets.MaybeSchema}<${this.itemType.schemaType}>`;
|
|
57
57
|
}
|
|
@@ -73,7 +73,7 @@ export class OptionType extends AbstractContainerType {
|
|
|
73
73
|
}
|
|
74
74
|
fromRdfResourceValuesExpression(parameters) {
|
|
75
75
|
const { variables } = parameters;
|
|
76
|
-
return code `${this.itemType.fromRdfResourceValuesExpression(parameters)}.map(values => values.length > 0 ? values.map(value => ${this.reusables.imports.Maybe}.of(value)) : ${this.reusables.imports.Resource}.Values.fromValue<${this.reusables.imports.Maybe}<${this.itemType.
|
|
76
|
+
return code `${this.itemType.fromRdfResourceValuesExpression(parameters)}.map(values => values.length > 0 ? values.map(value => ${this.reusables.imports.Maybe}.of(value)) : ${this.reusables.imports.Resource}.Values.fromValue<${this.reusables.imports.Maybe}<${this.itemType.expression}>>({ focusResource: ${variables.resource}, propertyPath: ${variables.propertyPath}, value: ${this.reusables.imports.Maybe}.empty() }))`;
|
|
77
77
|
}
|
|
78
78
|
graphqlResolveExpression(parameters) {
|
|
79
79
|
return code `${this.itemType.graphqlResolveExpression(parameters)}.extractNullable()`;
|
|
@@ -114,6 +114,9 @@ __decorate([
|
|
|
114
114
|
__decorate([
|
|
115
115
|
Memoize()
|
|
116
116
|
], OptionType.prototype, "equalsFunction", null);
|
|
117
|
+
__decorate([
|
|
118
|
+
Memoize()
|
|
119
|
+
], OptionType.prototype, "expression", null);
|
|
117
120
|
__decorate([
|
|
118
121
|
Memoize()
|
|
119
122
|
], OptionType.prototype, "filterFunction", null);
|
|
@@ -126,9 +129,6 @@ __decorate([
|
|
|
126
129
|
__decorate([
|
|
127
130
|
Memoize()
|
|
128
131
|
], OptionType.prototype, "hashFunction", null);
|
|
129
|
-
__decorate([
|
|
130
|
-
Memoize()
|
|
131
|
-
], OptionType.prototype, "name", null);
|
|
132
132
|
__decorate([
|
|
133
133
|
Memoize()
|
|
134
134
|
], OptionType.prototype, "schemaType", null);
|
|
@@ -56,7 +56,7 @@ async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${
|
|
|
56
56
|
}`,
|
|
57
57
|
// objectSync
|
|
58
58
|
code `\
|
|
59
|
-
${methodSignatures.object.name}Sync(${methodSignatures.object.parameters}): ${this.reusables.imports.Either}<Error, ${namedObjectType.
|
|
59
|
+
${methodSignatures.object.name}Sync(${methodSignatures.object.parameters}): ${this.reusables.imports.Either}<Error, ${namedObjectType.expression}> {
|
|
60
60
|
return this.${methodSignatures.objects.name}Sync({ identifiers: [identifier], preferredLanguages: options?.preferredLanguages }).map(objects => objects[0]);
|
|
61
61
|
}`,
|
|
62
62
|
// objectCount
|
|
@@ -90,19 +90,19 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
90
90
|
const fromRdfTypes = namedObjectType.fromRdfTypeVariable
|
|
91
91
|
.toList()
|
|
92
92
|
.concat(namedObjectType.descendantFromRdfTypeVariables);
|
|
93
|
-
return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.
|
|
93
|
+
return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.expression}.fromRdfResource, fromRdfTypes: ${fromRdfTypes.length > 0 ? code `[${joinCode(fromRdfTypes, { on: ", " })}]` : "[]"} }`;
|
|
94
94
|
};
|
|
95
95
|
switch (namedObjectType.kind) {
|
|
96
|
-
case "
|
|
96
|
+
case "Object": {
|
|
97
97
|
return delegatingMethods.concat(code `\
|
|
98
|
-
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.
|
|
99
|
-
return this.#objectsSync<${namedObjectType.
|
|
98
|
+
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.expression}[]> {
|
|
99
|
+
return this.#objectsSync<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType.filterFunction, namedObjectType)}, query);
|
|
100
100
|
}`);
|
|
101
101
|
}
|
|
102
|
-
case "
|
|
102
|
+
case "ObjectUnion":
|
|
103
103
|
return delegatingMethods.concat(code `\
|
|
104
|
-
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.
|
|
105
|
-
return this.#objectUnionsSync<${namedObjectType.
|
|
104
|
+
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.expression}[]> {
|
|
105
|
+
return this.#objectUnionsSync<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>([
|
|
106
106
|
${joinCode(namedObjectType.members.map((member) => runtimeObjectType(namedObjectType.filterFunction, member.type)), { on: ", " })}
|
|
107
107
|
], query);
|
|
108
108
|
}`);
|
|
@@ -42,7 +42,7 @@ ${joinCode([...this.namedObjectTypes, ...this.namedObjectUnionTypes].flatMap((na
|
|
|
42
42
|
const methodSignatures = this.methodSignatures(namedObjectType, {
|
|
43
43
|
queryT: `${syntheticNamePrefix}SparqlObjectSet.Query`,
|
|
44
44
|
});
|
|
45
|
-
const runtimeObjectType = namedObjectType.
|
|
45
|
+
const runtimeObjectType = namedObjectType.expression;
|
|
46
46
|
return [
|
|
47
47
|
code `\
|
|
48
48
|
async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${methodSignatures.object.returnType} {
|
|
@@ -58,7 +58,7 @@ async ${methodSignatures.objectIdentifiers.name}(${methodSignatures.objectIdenti
|
|
|
58
58
|
}`,
|
|
59
59
|
code `\
|
|
60
60
|
async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}): ${methodSignatures.objects.returnType} {
|
|
61
|
-
return this.#objects<${namedObjectType.
|
|
61
|
+
return this.#objects<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType}, query);
|
|
62
62
|
}`,
|
|
63
63
|
];
|
|
64
64
|
}), { on: "\n\n" })}
|
|
@@ -7,10 +7,10 @@ export declare class StringType extends AbstractPrimitiveType<string> {
|
|
|
7
7
|
readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
|
|
8
8
|
readonly hashFunction: Code;
|
|
9
9
|
readonly kind = "String";
|
|
10
|
-
readonly schemaType: Code;
|
|
11
10
|
readonly typeofs: "string"[];
|
|
12
11
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
13
|
-
get
|
|
12
|
+
get expression(): Code;
|
|
13
|
+
get schemaType(): Code;
|
|
14
14
|
jsonSchema(_parameters: Parameters<AbstractPrimitiveType<string>["jsonSchema"]>[0]): Code;
|
|
15
15
|
literalExpression(literal: Literal | string): Code;
|
|
16
16
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
@@ -14,14 +14,16 @@ export class StringType extends AbstractPrimitiveType {
|
|
|
14
14
|
graphqlType = new AbstractPrimitiveType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
|
|
15
15
|
hashFunction = code `${this.reusables.snippets.hashString}`;
|
|
16
16
|
kind = "String";
|
|
17
|
-
schemaType = code `${this.reusables.snippets.StringSchema}<${this.name}>`;
|
|
18
17
|
typeofs = ["string"];
|
|
19
18
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.stringSparqlWherePatterns}`;
|
|
20
|
-
get
|
|
19
|
+
get expression() {
|
|
21
20
|
if (this.primitiveIn.length > 0) {
|
|
22
|
-
return `${this.primitiveIn.map((value) => `"${value}"`).join(" | ")}`;
|
|
21
|
+
return code `${this.primitiveIn.map((value) => `"${value}"`).join(" | ")}`;
|
|
23
22
|
}
|
|
24
|
-
return `string`;
|
|
23
|
+
return code `string`;
|
|
24
|
+
}
|
|
25
|
+
get schemaType() {
|
|
26
|
+
return code `${this.reusables.snippets.StringSchema}<${this.expression}>`;
|
|
25
27
|
}
|
|
26
28
|
jsonSchema(_parameters) {
|
|
27
29
|
switch (this.primitiveIn.length) {
|
|
@@ -48,5 +50,8 @@ export class StringType extends AbstractPrimitiveType {
|
|
|
48
50
|
}
|
|
49
51
|
__decorate([
|
|
50
52
|
Memoize()
|
|
51
|
-
], StringType.prototype, "
|
|
53
|
+
], StringType.prototype, "expression", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
Memoize()
|
|
56
|
+
], StringType.prototype, "schemaType", null);
|
|
52
57
|
//# sourceMappingURL=StringType.js.map
|
|
@@ -14,12 +14,12 @@ export declare class TermType<ConstantTermT extends Literal | NamedNode = Litera
|
|
|
14
14
|
constructor({ nodeKinds, ...superParameters }: ConstructorParameters<typeof AbstractTermType<ConstantTermT, RuntimeTermT>>[0] & {
|
|
15
15
|
nodeKinds: ReadonlySet<NodeKind>;
|
|
16
16
|
});
|
|
17
|
+
get expression(): Code;
|
|
17
18
|
get graphqlType(): AbstractTermType.GraphqlType;
|
|
18
|
-
get name(): Code;
|
|
19
19
|
fromJsonExpression({ variables, }: Parameters<AbstractTermType["fromJsonExpression"]>[0]): Code;
|
|
20
20
|
graphqlResolveExpression(_parameters: Parameters<AbstractTermType["graphqlResolveExpression"]>[0]): Code;
|
|
21
|
-
jsonType(): AbstractTermType.JsonType;
|
|
22
21
|
jsonSchema(_parameters: Parameters<AbstractTermType["jsonSchema"]>[0]): Code;
|
|
22
|
+
jsonType(): AbstractTermType.JsonType;
|
|
23
23
|
toJsonExpression({ variables, }: Parameters<AbstractTermType["toJsonExpression"]>[0]): Code;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=TermType.d.ts.map
|
|
@@ -25,10 +25,7 @@ export class TermType extends AbstractTermType {
|
|
|
25
25
|
invariant(this.nodeKinds.has("Literal") &&
|
|
26
26
|
(this.nodeKinds.has("BlankNode") || this.nodeKinds.has("IRI")), "should be IdentifierType or LiteralType");
|
|
27
27
|
}
|
|
28
|
-
get
|
|
29
|
-
throw new Error("not implemented");
|
|
30
|
-
}
|
|
31
|
-
get name() {
|
|
28
|
+
get expression() {
|
|
32
29
|
return code `(${joinCode([...this.nodeKinds]
|
|
33
30
|
.map((nodeKind) => {
|
|
34
31
|
switch (nodeKind) {
|
|
@@ -45,8 +42,11 @@ export class TermType extends AbstractTermType {
|
|
|
45
42
|
})
|
|
46
43
|
.map((import_) => code `${import_}`), { on: " | " })})`;
|
|
47
44
|
}
|
|
45
|
+
get graphqlType() {
|
|
46
|
+
throw new Error("not implemented");
|
|
47
|
+
}
|
|
48
48
|
fromJsonExpression({ variables, }) {
|
|
49
|
-
return code `${this.reusables.imports.Either}.of<Error, ${this.
|
|
49
|
+
return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${[
|
|
50
50
|
...this.nodeKinds,
|
|
51
51
|
].reduce((expression, nodeKind) => {
|
|
52
52
|
let valueToNodeKind;
|
|
@@ -71,12 +71,6 @@ export class TermType extends AbstractTermType {
|
|
|
71
71
|
graphqlResolveExpression(_parameters) {
|
|
72
72
|
throw new Error("not implemented");
|
|
73
73
|
}
|
|
74
|
-
jsonType() {
|
|
75
|
-
return new AbstractTermType.JsonType(code `{ readonly "@id": string, readonly termType: ${[...this.nodeKinds]
|
|
76
|
-
.filter((nodeKind) => nodeKind !== "Literal")
|
|
77
|
-
.map((nodeKind) => `"${NodeKind.toTermType(nodeKind)}"`)
|
|
78
|
-
.join(" | ")} } | { readonly "@language"?: string, readonly "@type"?: string, readonly "@value": string, readonly termType: "Literal" }`);
|
|
79
|
-
}
|
|
80
74
|
jsonSchema(_parameters) {
|
|
81
75
|
return code `${this.reusables.imports.z}.discriminatedUnion("termType", [${joinCode([...this.nodeKinds].map((nodeKind) => {
|
|
82
76
|
switch (nodeKind) {
|
|
@@ -90,6 +84,12 @@ export class TermType extends AbstractTermType {
|
|
|
90
84
|
}
|
|
91
85
|
}), { on: "," })}])`;
|
|
92
86
|
}
|
|
87
|
+
jsonType() {
|
|
88
|
+
return new AbstractTermType.JsonType(code `{ readonly "@id": string, readonly termType: ${[...this.nodeKinds]
|
|
89
|
+
.filter((nodeKind) => nodeKind !== "Literal")
|
|
90
|
+
.map((nodeKind) => `"${NodeKind.toTermType(nodeKind)}"`)
|
|
91
|
+
.join(" | ")} } | { readonly "@language"?: string, readonly "@type"?: string, readonly "@value": string, readonly termType: "Literal" }`);
|
|
92
|
+
}
|
|
93
93
|
toJsonExpression({ variables, }) {
|
|
94
94
|
return [...this.nodeKinds].reduce((expression, nodeKind) => {
|
|
95
95
|
let valueToNodeKind;
|
|
@@ -114,7 +114,7 @@ export class TermType extends AbstractTermType {
|
|
|
114
114
|
}
|
|
115
115
|
__decorate([
|
|
116
116
|
Memoize()
|
|
117
|
-
], TermType.prototype, "
|
|
117
|
+
], TermType.prototype, "expression", null);
|
|
118
118
|
__decorate([
|
|
119
119
|
Memoize()
|
|
120
120
|
], TermType.prototype, "jsonType", null);
|
|
@@ -5,8 +5,8 @@ import { BlankNodeType } from "./BlankNodeType.js";
|
|
|
5
5
|
import { GraphqlSchema } from "./GraphqlSchema.js";
|
|
6
6
|
import { IdentifierType } from "./IdentifierType.js";
|
|
7
7
|
import { IriType } from "./IriType.js";
|
|
8
|
-
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
9
8
|
import { ObjectSetType } from "./ObjectSetType.js";
|
|
9
|
+
import { ObjectUnionType } from "./ObjectUnionType.js";
|
|
10
10
|
import { RdfjsDatasetObjectSetType } from "./RdfjsDatasetObjectSetType.js";
|
|
11
11
|
import { Reusables } from "./Reusables.js";
|
|
12
12
|
import { SparqlObjectSetType } from "./SparqlObjectSetType.js";
|
|
@@ -42,23 +42,23 @@ export class TsGenerator {
|
|
|
42
42
|
}
|
|
43
43
|
declarations = declarations.concat(typeFactory.createType(astNamedUnionType).declaration.toList());
|
|
44
44
|
}
|
|
45
|
-
const namedObjectTypesToposorted = ast.ObjectType.toposort(ast_.namedObjectTypes).map((astObjectType) => typeFactory.
|
|
45
|
+
const namedObjectTypesToposorted = ast.ObjectType.toposort(ast_.namedObjectTypes).map((astObjectType) => typeFactory.createObjectType(astObjectType));
|
|
46
46
|
const namedObjectUnionTypesToposorted = ast_.namedUnionTypes
|
|
47
47
|
.filter((_) => _.isObjectUnionType())
|
|
48
|
-
.map((astObjectUnionType) => typeFactory.
|
|
48
|
+
.map((astObjectUnionType) => typeFactory.createObjectUnionType(astObjectUnionType));
|
|
49
49
|
for (const namedObjectType of namedObjectTypesToposorted) {
|
|
50
50
|
declarations = declarations.concat(namedObjectType.declaration.toList());
|
|
51
51
|
}
|
|
52
52
|
for (const namedObjectUnionType of namedObjectUnionTypesToposorted) {
|
|
53
53
|
declarations = declarations.concat(namedObjectUnionType.declaration.toList());
|
|
54
54
|
}
|
|
55
|
-
const namedObjectTypesNameSorted = namedObjectTypesToposorted.toSorted((left, right) => left.
|
|
56
|
-
const namedObjectUnionTypesNameSorted = namedObjectUnionTypesToposorted.toSorted((left, right) => left.
|
|
55
|
+
const namedObjectTypesNameSorted = namedObjectTypesToposorted.toSorted((left, right) => left.alias.unsafeCoerce().localeCompare(right.alias.unsafeCoerce()));
|
|
56
|
+
const namedObjectUnionTypesNameSorted = namedObjectUnionTypesToposorted.toSorted((left, right) => left.alias.unsafeCoerce().localeCompare(right.alias.unsafeCoerce()));
|
|
57
57
|
switch (namedObjectTypesNameSorted.length) {
|
|
58
58
|
case 0:
|
|
59
59
|
break;
|
|
60
60
|
case 1:
|
|
61
|
-
declarations.push(code `type ${configuration.syntheticNamePrefix}Object = ${namedObjectTypesNameSorted[0].
|
|
61
|
+
declarations.push(code `type ${configuration.syntheticNamePrefix}Object = ${namedObjectTypesNameSorted[0].expression};`);
|
|
62
62
|
break;
|
|
63
63
|
default: {
|
|
64
64
|
const uberObjectUnionType = this.synthesizeUberObjectUnionType({
|
|
@@ -127,6 +127,7 @@ export class TsGenerator {
|
|
|
127
127
|
let identifierType;
|
|
128
128
|
if (nodeKinds.size === 2) {
|
|
129
129
|
identifierType = new IdentifierType({
|
|
130
|
+
alias: Maybe.empty(),
|
|
130
131
|
comment: Maybe.empty(),
|
|
131
132
|
configuration,
|
|
132
133
|
label: Maybe.empty(),
|
|
@@ -138,6 +139,7 @@ export class TsGenerator {
|
|
|
138
139
|
switch ([...nodeKinds][0]) {
|
|
139
140
|
case "BlankNode":
|
|
140
141
|
identifierType = new BlankNodeType({
|
|
142
|
+
alias: Maybe.empty(),
|
|
141
143
|
comment: Maybe.empty(),
|
|
142
144
|
configuration,
|
|
143
145
|
label: Maybe.empty(),
|
|
@@ -147,6 +149,7 @@ export class TsGenerator {
|
|
|
147
149
|
break;
|
|
148
150
|
case "IRI":
|
|
149
151
|
identifierType = new IriType({
|
|
152
|
+
alias: Maybe.empty(),
|
|
150
153
|
comment: Maybe.empty(),
|
|
151
154
|
configuration,
|
|
152
155
|
hasValues: [],
|
|
@@ -158,17 +161,17 @@ export class TsGenerator {
|
|
|
158
161
|
break;
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
|
-
return new
|
|
164
|
+
return new ObjectUnionType({
|
|
165
|
+
alias: Maybe.of(`${configuration.syntheticNamePrefix}Object`),
|
|
162
166
|
comment: Maybe.empty(),
|
|
163
167
|
configuration,
|
|
164
|
-
identifierType,
|
|
168
|
+
identifierType: Maybe.of(identifierType),
|
|
165
169
|
label: Maybe.empty(),
|
|
166
170
|
logger: this.logger,
|
|
167
171
|
members: filteredNamedObjectTypes.map((namedObjectType) => ({
|
|
168
172
|
discriminantValue: Maybe.empty(),
|
|
169
173
|
type: namedObjectType,
|
|
170
174
|
})),
|
|
171
|
-
name: `${configuration.syntheticNamePrefix}Object`,
|
|
172
175
|
recursive: false,
|
|
173
176
|
reusables,
|
|
174
177
|
synthetic: true,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AnonymousUnionType } from "./AnonymousUnionType.js";
|
|
2
1
|
import type { BigDecimalType } from "./BigDecimalType.js";
|
|
3
2
|
import type { BigIntType } from "./BigIntType.js";
|
|
4
3
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
@@ -15,12 +14,12 @@ import type { LazyObjectSetType } from "./LazyObjectSetType.js";
|
|
|
15
14
|
import type { LazyObjectType } from "./LazyObjectType.js";
|
|
16
15
|
import type { ListType } from "./ListType.js";
|
|
17
16
|
import type { LiteralType } from "./LiteralType.js";
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
20
|
-
import type { NamedUnionType } from "./NamedUnionType.js";
|
|
17
|
+
import type { ObjectType } from "./ObjectType.js";
|
|
18
|
+
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
21
19
|
import type { OptionType } from "./OptionType.js";
|
|
22
20
|
import type { SetType } from "./SetType.js";
|
|
23
21
|
import type { StringType } from "./StringType.js";
|
|
24
22
|
import type { TermType } from "./TermType.js";
|
|
25
|
-
|
|
23
|
+
import type { UnionType } from "./UnionType.js";
|
|
24
|
+
export type Type = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | DefaultValueType<DefaultValueType.ItemType> | FloatType | IdentifierType | IntType | IriType | LazyObjectOptionType | LazyObjectSetType | LazyObjectType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | OptionType<OptionType.ItemType> | SetType<SetType.ItemType> | StringType | TermType | UnionType<Type>;
|
|
26
25
|
//# sourceMappingURL=Type.d.ts.map
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import type { Literal, NamedNode } from "@rdfjs/types";
|
|
2
2
|
import type { Logger } from "ts-log";
|
|
3
3
|
import * as ast from "../../ast/index.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
7
|
-
import { NamedUnionType } from "./NamedUnionType.js";
|
|
4
|
+
import { ObjectType } from "./ObjectType.js";
|
|
5
|
+
import { ObjectUnionType } from "./ObjectUnionType.js";
|
|
8
6
|
import type { Reusables } from "./Reusables.js";
|
|
9
7
|
import type { TsGenerator } from "./TsGenerator.js";
|
|
10
8
|
import type { Type } from "./Type.js";
|
|
9
|
+
import { UnionType } from "./UnionType.js";
|
|
11
10
|
export declare class TypeFactory {
|
|
12
11
|
private readonly configuration;
|
|
13
12
|
private readonly logger;
|
|
14
13
|
private readonly reusables;
|
|
15
|
-
private
|
|
14
|
+
private cachedObjectUnionTypesByShapeIdentifier;
|
|
16
15
|
private cachedObjectTypePropertiesByShapeIdentifier;
|
|
17
16
|
private cachedObjectTypesByShapeIdentifier;
|
|
18
17
|
constructor({ configuration, logger, reusables, }: {
|
|
@@ -20,12 +19,12 @@ export declare class TypeFactory {
|
|
|
20
19
|
logger: Logger;
|
|
21
20
|
reusables: Reusables;
|
|
22
21
|
});
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
createObjectType(astType: ast.ObjectType): ObjectType;
|
|
23
|
+
createObjectUnionType(astType: ast.ObjectUnionType): ObjectUnionType;
|
|
25
24
|
createType(astType: ast.Type, parameters?: {
|
|
26
25
|
defaultValue?: Literal | NamedNode;
|
|
27
26
|
}): Type;
|
|
28
|
-
createUnionType(astType: ast.UnionType):
|
|
27
|
+
createUnionType(astType: ast.UnionType): ObjectUnionType | UnionType<Type>;
|
|
29
28
|
private createBlankNodeType;
|
|
30
29
|
private createDefaultValueType;
|
|
31
30
|
private createIdentifierType;
|