@shaclmate/compiler 4.0.38 → 4.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ShapesGraphToAstTransformer.js +12 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +24 -24
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -4
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +16 -16
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
- package/dist/ast/AbstractCollectionType.d.ts +1 -1
- package/dist/ast/AbstractCompoundType.d.ts +1 -1
- package/dist/ast/AbstractCompoundType.js +15 -15
- package/dist/ast/AbstractContainerType.d.ts +1 -1
- package/dist/ast/AbstractContainerType.js +15 -15
- package/dist/ast/AbstractLazyObjectType.d.ts +1 -1
- package/dist/ast/AbstractTermType.d.ts +1 -1
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/BlankNodeType.js +1 -1
- package/dist/ast/DefaultValueType.d.ts +1 -1
- package/dist/ast/DefaultValueType.js +2 -2
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/IdentifierType.js +1 -1
- package/dist/ast/IntersectionType.d.ts +1 -1
- package/dist/ast/IntersectionType.js +3 -3
- package/dist/ast/IriType.d.ts +1 -1
- package/dist/ast/IriType.js +1 -1
- package/dist/ast/LazyObjectOptionType.d.ts +1 -1
- package/dist/ast/LazyObjectOptionType.js +1 -1
- package/dist/ast/LazyObjectSetType.d.ts +1 -1
- package/dist/ast/LazyObjectSetType.js +1 -1
- package/dist/ast/LazyObjectType.d.ts +1 -1
- package/dist/ast/LazyObjectType.js +1 -1
- package/dist/ast/ListType.d.ts +1 -1
- package/dist/ast/ListType.js +16 -16
- package/dist/ast/LiteralType.d.ts +1 -1
- package/dist/ast/LiteralType.js +1 -1
- package/dist/ast/ObjectCompoundType.js +3 -3
- package/dist/ast/ObjectType.d.ts +1 -1
- package/dist/ast/ObjectType.js +16 -16
- package/dist/ast/OptionType.d.ts +1 -1
- package/dist/ast/OptionType.js +1 -1
- package/dist/ast/SetType.d.ts +1 -1
- package/dist/ast/SetType.js +1 -1
- package/dist/ast/TermType.d.ts +1 -1
- package/dist/ast/TermType.js +1 -1
- package/dist/ast/Type.js +15 -15
- package/dist/ast/UnionType.d.ts +1 -1
- package/dist/ast/UnionType.js +3 -3
- package/dist/generators/transformAstToLabeledPropertyGraph.js +10 -10
- package/dist/generators/ts/AbstractCollectionType.d.ts +1 -5
- package/dist/generators/ts/AbstractCollectionType.js +6 -5
- package/dist/generators/ts/AbstractContainerType.d.ts +3 -6
- package/dist/generators/ts/AbstractContainerType.js +34 -34
- package/dist/generators/ts/AbstractDateType.d.ts +1 -1
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +7 -10
- package/dist/generators/ts/AbstractLazyObjectType.js +20 -32
- package/dist/generators/ts/AbstractLiteralType.d.ts +1 -5
- package/dist/generators/ts/AbstractLiteralType.js +7 -6
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -6
- package/dist/generators/ts/AbstractPrimitiveType.js +7 -8
- package/dist/generators/ts/AbstractTermType.d.ts +1 -5
- package/dist/generators/ts/AbstractTermType.js +1 -15
- package/dist/generators/ts/AbstractType.d.ts +7 -5
- package/dist/generators/ts/AbstractType.js +12 -7
- package/dist/generators/ts/AbstractUnionType.d.ts +7 -10
- package/dist/generators/ts/AbstractUnionType.js +70 -81
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +1 -1
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigDecimalType.js +1 -1
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +1 -1
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.js +2 -2
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +2 -6
- package/dist/generators/ts/DefaultValueType.js +12 -15
- package/dist/generators/ts/FloatType.d.ts +1 -1
- package/dist/generators/ts/FloatType.js +1 -1
- package/dist/generators/ts/IdentifierType.d.ts +1 -1
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IntType.d.ts +1 -1
- package/dist/generators/ts/IntType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +3 -1
- package/dist/generators/ts/IriType.js +22 -17
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +1 -1
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +1 -1
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +1 -1
- package/dist/generators/ts/ListType.d.ts +1 -1
- package/dist/generators/ts/ListType.js +24 -24
- package/dist/generators/ts/LiteralType.d.ts +2 -1
- package/dist/generators/ts/LiteralType.js +9 -2
- package/dist/generators/ts/NamedObjectType.d.ts +1 -0
- package/dist/generators/ts/NamedObjectType.js +2 -1
- package/dist/generators/ts/NamedObjectUnionType.d.ts +1 -1
- package/dist/generators/ts/NamedObjectUnionType.js +6 -8
- package/dist/generators/ts/NamedUnionType.d.ts +1 -1
- package/dist/generators/ts/NamedUnionType.js +1 -1
- package/dist/generators/ts/OptionType.d.ts +1 -5
- package/dist/generators/ts/OptionType.js +2 -8
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -1
- package/dist/generators/ts/SetType.d.ts +1 -1
- package/dist/generators/ts/SetType.js +1 -1
- package/dist/generators/ts/Snippets.d.ts +1 -0
- package/dist/generators/ts/Snippets.js +7 -0
- package/dist/generators/ts/StringType.d.ts +1 -1
- package/dist/generators/ts/StringType.js +2 -2
- package/dist/generators/ts/TermType.d.ts +1 -1
- package/dist/generators/ts/TermType.js +1 -1
- package/dist/generators/ts/TypeFactory.js +18 -18
- package/dist/generators/ts/ZodGenerator.js +1 -1
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +8 -11
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +16 -7
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +3 -27
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +2 -6
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +19 -23
- package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_IriSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_StringSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.js +16 -0
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +3 -3
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_validateArray.js +1 -1
- package/dist/generators/ts/_snippets/snippets_validateMaybe.js +1 -1
- package/dist/generators/ts/tsComment.js +1 -1
- package/dist/input/generated.d.ts +1397 -1466
- package/dist/input/generated.js +516 -653
- package/package.json +2 -2
- package/dist/generators/ts/removeUndefined.d.ts +0 -2
- package/dist/generators/ts/removeUndefined.js +0 -17
|
@@ -8,7 +8,6 @@ import { Maybe } from "purify-ts";
|
|
|
8
8
|
import { invariant } from "ts-invariant";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { AbstractType } from "./AbstractType.js";
|
|
11
|
-
import { removeUndefined } from "./removeUndefined.js";
|
|
12
11
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
13
12
|
export class AbstractLazyObjectType extends AbstractType {
|
|
14
13
|
partialType;
|
|
@@ -16,6 +15,7 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
16
15
|
declaration = Maybe.empty();
|
|
17
16
|
discriminantProperty = Maybe.empty();
|
|
18
17
|
mutable = false;
|
|
18
|
+
referencesObjectType = true;
|
|
19
19
|
typeofs = ["object"];
|
|
20
20
|
validationFunction = Maybe.empty();
|
|
21
21
|
constructor({ partialType, resolveType, ...superParameters }) {
|
|
@@ -26,9 +26,6 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
26
26
|
get equalsFunction() {
|
|
27
27
|
return code `((left, right) => ${this.partialType.equalsFunction}(left.${this.runtimeClass.partialPropertyName}, right.${this.runtimeClass.partialPropertyName}))`;
|
|
28
28
|
}
|
|
29
|
-
get hashFunction() {
|
|
30
|
-
return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
|
|
31
|
-
}
|
|
32
29
|
get filterFunction() {
|
|
33
30
|
return code `((filter: ${this.filterType}, value: ${this.name}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
|
|
34
31
|
}
|
|
@@ -38,38 +35,32 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
38
35
|
get graphqlType() {
|
|
39
36
|
return this.resolveType.graphqlType;
|
|
40
37
|
}
|
|
38
|
+
get hashFunction() {
|
|
39
|
+
return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
|
|
40
|
+
}
|
|
41
41
|
get name() {
|
|
42
42
|
return this.runtimeClass.name;
|
|
43
43
|
}
|
|
44
44
|
get recursive() {
|
|
45
45
|
return this.partialType.recursive;
|
|
46
46
|
}
|
|
47
|
-
get
|
|
48
|
-
return code
|
|
47
|
+
get schemaInitializers() {
|
|
48
|
+
return super.schemaInitializers.concat(code `get partialType() { return ${this.partialType.schema}; }`);
|
|
49
49
|
}
|
|
50
50
|
get schemaType() {
|
|
51
51
|
return code `${{
|
|
52
52
|
kind: this.kind,
|
|
53
53
|
partialType: this.partialType.schemaType,
|
|
54
|
-
resolveType: this.resolveType.schemaType,
|
|
55
54
|
}}`;
|
|
56
55
|
}
|
|
57
56
|
get toRdfResourceValueTypes() {
|
|
58
57
|
return this.partialType.toRdfResourceValueTypes;
|
|
59
58
|
}
|
|
60
59
|
get valueSparqlConstructTriplesFunction() {
|
|
61
|
-
return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.
|
|
60
|
+
return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.partialType }))`;
|
|
62
61
|
}
|
|
63
62
|
get valueSparqlWherePatternsFunction() {
|
|
64
|
-
return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.
|
|
65
|
-
}
|
|
66
|
-
get schemaObject() {
|
|
67
|
-
return {
|
|
68
|
-
...super.schemaObject,
|
|
69
|
-
partial: code `() => (${this.partialType.schema})`,
|
|
70
|
-
// Commenting out to reduce schema size
|
|
71
|
-
// resolved: code`() => (${this.resolveType.schema})`,
|
|
72
|
-
};
|
|
63
|
+
return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partialType }))`;
|
|
73
64
|
}
|
|
74
65
|
jsonSchema(parameters) {
|
|
75
66
|
return this.partialType.jsonSchema(parameters);
|
|
@@ -102,21 +93,12 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
102
93
|
},
|
|
103
94
|
});
|
|
104
95
|
}
|
|
105
|
-
resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }) {
|
|
106
|
-
invariant(resolvedNamedObjectUnionType.members.length ===
|
|
107
|
-
partialNamedObjectUnionType.members.length);
|
|
108
|
-
const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
|
|
109
|
-
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.name}.create(${variables.resolvedObjectUnion});`;
|
|
110
|
-
});
|
|
111
|
-
caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
|
|
112
|
-
return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
|
|
113
|
-
}
|
|
114
96
|
resolveToPartialFunction({ partialType, resolveType, }) {
|
|
115
97
|
if (partialType.kind === "NamedObjectType") {
|
|
116
98
|
return code `${partialType.name}.createUnsafe`;
|
|
117
99
|
}
|
|
118
|
-
invariant(partialType.kind === "
|
|
119
|
-
invariant(resolveType.kind === "
|
|
100
|
+
invariant(partialType.kind === "NamedObjectUnion");
|
|
101
|
+
invariant(resolveType.kind === "NamedObjectUnion");
|
|
120
102
|
invariant(partialType.members.length === resolveType.members.length);
|
|
121
103
|
const caseBlocks = resolveType.members.map(({ discriminantValues }, memberI) => {
|
|
122
104
|
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.name}.createUnsafe(resolved);`;
|
|
@@ -124,19 +106,25 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
124
106
|
caseBlocks.push(code `default: resolved satisfies never; throw new Error("unrecognized type");`);
|
|
125
107
|
return code `((resolved: ${resolveType.name}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
|
|
126
108
|
}
|
|
109
|
+
resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }) {
|
|
110
|
+
invariant(resolvedNamedObjectUnionType.members.length ===
|
|
111
|
+
partialNamedObjectUnionType.members.length);
|
|
112
|
+
const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
|
|
113
|
+
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.name}.create(${variables.resolvedObjectUnion});`;
|
|
114
|
+
});
|
|
115
|
+
caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
|
|
116
|
+
return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
|
|
117
|
+
}
|
|
127
118
|
}
|
|
128
119
|
__decorate([
|
|
129
120
|
Memoize()
|
|
130
121
|
], AbstractLazyObjectType.prototype, "equalsFunction", null);
|
|
131
|
-
__decorate([
|
|
132
|
-
Memoize()
|
|
133
|
-
], AbstractLazyObjectType.prototype, "hashFunction", null);
|
|
134
122
|
__decorate([
|
|
135
123
|
Memoize()
|
|
136
124
|
], AbstractLazyObjectType.prototype, "filterFunction", null);
|
|
137
125
|
__decorate([
|
|
138
126
|
Memoize()
|
|
139
|
-
], AbstractLazyObjectType.prototype, "
|
|
127
|
+
], AbstractLazyObjectType.prototype, "hashFunction", null);
|
|
140
128
|
__decorate([
|
|
141
129
|
Memoize()
|
|
142
130
|
], AbstractLazyObjectType.prototype, "schemaType", null);
|
|
@@ -8,11 +8,7 @@ export declare abstract class AbstractLiteralType extends AbstractTermType<Liter
|
|
|
8
8
|
languageIn: readonly string[];
|
|
9
9
|
} & ConstructorParameters<typeof AbstractTermType<Literal, Literal>>[0]);
|
|
10
10
|
get constrained(): boolean;
|
|
11
|
-
protected get
|
|
12
|
-
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
13
|
-
in: Code | undefined;
|
|
14
|
-
kind: Code;
|
|
15
|
-
};
|
|
11
|
+
protected get schemaInitializers(): readonly Code[];
|
|
16
12
|
/**
|
|
17
13
|
* An expression that converts a compile-time RDF/JS Literal into a runtime TypeScript literal.
|
|
18
14
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
2
|
-
import {
|
|
2
|
+
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
3
3
|
export class AbstractLiteralType extends AbstractTermType {
|
|
4
4
|
languageIn;
|
|
5
5
|
nodeKinds = nodeKinds;
|
|
@@ -10,11 +10,12 @@ export class AbstractLiteralType extends AbstractTermType {
|
|
|
10
10
|
get constrained() {
|
|
11
11
|
return super.constrained || this.languageIn.length > 0;
|
|
12
12
|
}
|
|
13
|
-
get
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
get schemaInitializers() {
|
|
14
|
+
let initializers = super.schemaInitializers;
|
|
15
|
+
if (this.languageIn.length > 0) {
|
|
16
|
+
initializers = initializers.concat(code `languageIn: ${arrayOf(...this.languageIn)}`);
|
|
17
|
+
}
|
|
18
|
+
return initializers;
|
|
18
19
|
}
|
|
19
20
|
fromRdfResourceValuesExpressionChain({ variables, }) {
|
|
20
21
|
return {
|
|
@@ -5,7 +5,7 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class AbstractNumericType<ValueT extends bigint | number> extends AbstractPrimitiveType<ValueT> {
|
|
7
7
|
readonly hashFunction: Code;
|
|
8
|
-
abstract readonly kind: "
|
|
8
|
+
abstract readonly kind: "BigInt" | "Float" | "Int";
|
|
9
9
|
get filterFunction(): Code;
|
|
10
10
|
get filterType(): Code;
|
|
11
11
|
get name(): Code | string;
|
|
@@ -6,18 +6,14 @@ export declare abstract class AbstractPrimitiveType<ValueT extends bigint | bool
|
|
|
6
6
|
protected readonly datatype: NamedNode;
|
|
7
7
|
readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
|
|
8
8
|
readonly equalsFunction: Code;
|
|
9
|
-
abstract readonly kind: "
|
|
9
|
+
abstract readonly kind: "BigInt" | "Boolean" | "DateTime" | "Date" | "Float" | "Int" | "NumberType" | "String";
|
|
10
10
|
readonly primitiveIn: readonly ValueT[];
|
|
11
11
|
constructor({ datatype, primitiveIn, ...superParameters }: {
|
|
12
12
|
datatype: NamedNode;
|
|
13
13
|
primitiveIn: readonly ValueT[];
|
|
14
14
|
} & ConstructorParameters<typeof AbstractLiteralType>[0]);
|
|
15
15
|
get discriminantProperty(): Maybe<AbstractLiteralType.DiscriminantProperty>;
|
|
16
|
-
protected get
|
|
17
|
-
in: Code | undefined;
|
|
18
|
-
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
19
|
-
kind: Code;
|
|
20
|
-
};
|
|
16
|
+
protected get schemaInitializers(): readonly Code[];
|
|
21
17
|
fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
|
|
22
18
|
graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
23
19
|
jsonType(): AbstractLiteralType.JsonType;
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
9
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
10
|
-
import {
|
|
10
|
+
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
11
11
|
export class AbstractPrimitiveType extends AbstractLiteralType {
|
|
12
12
|
datatype;
|
|
13
13
|
conversionFunction = Maybe.empty();
|
|
@@ -21,13 +21,12 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
|
|
|
21
21
|
get discriminantProperty() {
|
|
22
22
|
return Maybe.empty();
|
|
23
23
|
}
|
|
24
|
-
get
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
in: this.primitiveIn.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
24
|
+
get schemaInitializers() {
|
|
25
|
+
let initializers = super.schemaInitializers;
|
|
26
|
+
if (this.primitiveIn.length > 0) {
|
|
27
|
+
initializers = initializers.concat(code `in: ${arrayOf(...this.primitiveIn.map((in_) => this.literalExpression(in_)))}`);
|
|
28
|
+
}
|
|
29
|
+
return initializers;
|
|
31
30
|
}
|
|
32
31
|
fromJsonExpression({ variables, }) {
|
|
33
32
|
return code `${this.reusables.imports.Either}.of<Error, ${this.name}>(${variables.value})`;
|
|
@@ -23,6 +23,7 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
23
23
|
readonly mutable: boolean;
|
|
24
24
|
abstract readonly nodeKinds: ReadonlySet<NodeKind>;
|
|
25
25
|
readonly recursive = false;
|
|
26
|
+
readonly referencesObjectType = false;
|
|
26
27
|
readonly typeofs: readonly Typeof[];
|
|
27
28
|
readonly validationFunction: Maybe<Code>;
|
|
28
29
|
constructor({ hasValues, in_, ...superParameters }: {
|
|
@@ -31,11 +32,6 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
31
32
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
32
33
|
get constrained(): boolean;
|
|
33
34
|
get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
|
|
34
|
-
get schema(): Code;
|
|
35
|
-
protected get schemaObject(): {
|
|
36
|
-
in: Code | undefined;
|
|
37
|
-
kind: Code;
|
|
38
|
-
};
|
|
39
35
|
get termTypes(): ReadonlySet<"BlankNode" | "Literal" | "NamedNode">;
|
|
40
36
|
get toRdfResourceValueTypes(): Set<"BlankNode" | "Literal" | "NamedNode">;
|
|
41
37
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
@@ -8,7 +8,6 @@ import { NodeKind } from "@shaclmate/shacl-ast";
|
|
|
8
8
|
import { Maybe } from "purify-ts";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { AbstractType } from "./AbstractType.js";
|
|
11
|
-
import { removeUndefined } from "./removeUndefined.js";
|
|
12
11
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
13
12
|
/**
|
|
14
13
|
* Abstract base class for IdentifierType and LiteralType.
|
|
@@ -27,6 +26,7 @@ export class AbstractTermType extends AbstractType {
|
|
|
27
26
|
in_;
|
|
28
27
|
mutable = false;
|
|
29
28
|
recursive = false;
|
|
29
|
+
referencesObjectType = false;
|
|
30
30
|
typeofs = ["object"];
|
|
31
31
|
validationFunction = Maybe.empty();
|
|
32
32
|
constructor({ hasValues, in_, ...superParameters }) {
|
|
@@ -46,17 +46,6 @@ export class AbstractTermType extends AbstractType {
|
|
|
46
46
|
type: "string",
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
get schema() {
|
|
50
|
-
return code `${removeUndefined(this.schemaObject)}`;
|
|
51
|
-
}
|
|
52
|
-
get schemaObject() {
|
|
53
|
-
return {
|
|
54
|
-
...super.schemaObject,
|
|
55
|
-
in: this.in_.length > 0
|
|
56
|
-
? code `[${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}] as const`
|
|
57
|
-
: undefined,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
49
|
get termTypes() {
|
|
61
50
|
return new Set([...this.nodeKinds].map(NodeKind.toTermType));
|
|
62
51
|
}
|
|
@@ -128,9 +117,6 @@ chain(values => ${this.reusables.imports.Either}.sequence([${joinCode(this.hasVa
|
|
|
128
117
|
__decorate([
|
|
129
118
|
Memoize()
|
|
130
119
|
], AbstractTermType.prototype, "discriminantProperty", null);
|
|
131
|
-
__decorate([
|
|
132
|
-
Memoize()
|
|
133
|
-
], AbstractTermType.prototype, "schema", null);
|
|
134
120
|
__decorate([
|
|
135
121
|
Memoize()
|
|
136
122
|
], AbstractTermType.prototype, "termTypes", null);
|
|
@@ -83,9 +83,9 @@ export declare abstract class AbstractType {
|
|
|
83
83
|
*/
|
|
84
84
|
abstract readonly recursive: boolean;
|
|
85
85
|
/**
|
|
86
|
-
*
|
|
86
|
+
* Is this type an ObjectType or does it reference an object type?
|
|
87
87
|
*/
|
|
88
|
-
abstract readonly
|
|
88
|
+
abstract readonly referencesObjectType: boolean;
|
|
89
89
|
/**
|
|
90
90
|
* TypeScript type describing .schema.
|
|
91
91
|
*/
|
|
@@ -140,12 +140,14 @@ export declare abstract class AbstractType {
|
|
|
140
140
|
logger: Logger;
|
|
141
141
|
reusables: Reusables;
|
|
142
142
|
});
|
|
143
|
+
/**
|
|
144
|
+
* TypeScript object describing this type, for runtime use.
|
|
145
|
+
*/
|
|
146
|
+
get schema(): Code;
|
|
143
147
|
/**
|
|
144
148
|
* Helper to compose the result of schema along the type hierarchy.
|
|
145
149
|
*/
|
|
146
|
-
protected get
|
|
147
|
-
kind: Code;
|
|
148
|
-
};
|
|
150
|
+
protected get schemaInitializers(): readonly Code[];
|
|
149
151
|
/**
|
|
150
152
|
* An expression that converts this type's JSON type to an Either<Error, ThisType>.
|
|
151
153
|
*/
|
|
@@ -4,10 +4,9 @@ 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 { invariant } from "ts-invariant";
|
|
8
7
|
import { Memoize } from "typescript-memoize";
|
|
9
8
|
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
10
|
-
import { code, literalOf } from "./ts-poet-wrapper.js";
|
|
9
|
+
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
11
10
|
/**
|
|
12
11
|
* Abstract base class all types.
|
|
13
12
|
*/
|
|
@@ -35,17 +34,23 @@ export class AbstractType {
|
|
|
35
34
|
snippets: this.reusables.snippets,
|
|
36
35
|
});
|
|
37
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* TypeScript object describing this type, for runtime use.
|
|
39
|
+
*/
|
|
40
|
+
get schema() {
|
|
41
|
+
return code `{ ${joinCode(this.schemaInitializers.concat(), { on: ", " })} }`;
|
|
42
|
+
}
|
|
38
43
|
/**
|
|
39
44
|
* Helper to compose the result of schema along the type hierarchy.
|
|
40
45
|
*/
|
|
41
|
-
get
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
kind: code `${literalOf(this.kind.substring(0, this.kind.length - "Type".length))} as const`,
|
|
45
|
-
};
|
|
46
|
+
get schemaInitializers() {
|
|
47
|
+
return [code `kind: ${literalOf(this.kind)} as const`];
|
|
46
48
|
}
|
|
47
49
|
rdfjsTermExpression;
|
|
48
50
|
}
|
|
51
|
+
__decorate([
|
|
52
|
+
Memoize()
|
|
53
|
+
], AbstractType.prototype, "schema", null);
|
|
49
54
|
(function (AbstractType) {
|
|
50
55
|
class GraphqlType {
|
|
51
56
|
/**
|
|
@@ -22,7 +22,7 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
|
|
|
22
22
|
get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
|
|
23
23
|
get members(): readonly AbstractUnionType.Member<MemberTypeT>[];
|
|
24
24
|
get mutable(): boolean;
|
|
25
|
-
get
|
|
25
|
+
get referencesObjectType(): boolean;
|
|
26
26
|
get schemaType(): Code;
|
|
27
27
|
get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
|
|
28
28
|
get typeofs(): AbstractType["typeofs"];
|
|
@@ -40,32 +40,29 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
|
|
|
40
40
|
protected get inlineToStringFunction(): Code;
|
|
41
41
|
protected get inlineValueSparqlConstructTriplesFunction(): Code;
|
|
42
42
|
protected get inlineValueSparqlWherePatternsFunction(): Code;
|
|
43
|
-
protected get
|
|
44
|
-
kind: Code;
|
|
45
|
-
members: Code;
|
|
46
|
-
};
|
|
43
|
+
protected get schemaInitializers(): readonly Code[];
|
|
47
44
|
jsonUiSchemaElement(): Maybe<Code>;
|
|
48
45
|
private readonly lazyMembers;
|
|
49
46
|
}
|
|
50
47
|
type Discriminant = ExtrinsicDiscriminant | HybridDiscriminant | IntrinsicDiscriminant | TypeofDiscriminant;
|
|
51
48
|
type ExtrinsicDiscriminant = {
|
|
52
49
|
readonly jsonName: string;
|
|
53
|
-
readonly kind: "
|
|
50
|
+
readonly kind: "Extrinsic";
|
|
54
51
|
readonly memberValues: readonly AbstractType.DiscriminantProperty.Value[];
|
|
55
52
|
readonly name: string;
|
|
56
53
|
};
|
|
57
54
|
type HybridDiscriminant = {
|
|
58
55
|
readonly jsonName: string;
|
|
59
|
-
readonly kind: "
|
|
56
|
+
readonly kind: "Hybrid";
|
|
60
57
|
readonly memberValues: readonly {
|
|
61
|
-
readonly kind: "
|
|
58
|
+
readonly kind: "Extrinsic" | "Intrinsic";
|
|
62
59
|
readonly ownValues: readonly AbstractType.DiscriminantProperty.Value[];
|
|
63
60
|
}[];
|
|
64
61
|
readonly name: string;
|
|
65
62
|
};
|
|
66
63
|
type IntrinsicDiscriminant = {
|
|
67
64
|
readonly jsonName: string;
|
|
68
|
-
readonly kind: "
|
|
65
|
+
readonly kind: "Intrinsic";
|
|
69
66
|
readonly memberValues: readonly {
|
|
70
67
|
readonly descendantValues: readonly AbstractType.DiscriminantProperty.Value[];
|
|
71
68
|
readonly ownValues: readonly AbstractType.DiscriminantProperty.Value[];
|
|
@@ -73,7 +70,7 @@ type IntrinsicDiscriminant = {
|
|
|
73
70
|
readonly name: string;
|
|
74
71
|
};
|
|
75
72
|
type TypeofDiscriminant = {
|
|
76
|
-
readonly kind: "
|
|
73
|
+
readonly kind: "Typeof";
|
|
77
74
|
readonly memberValues: readonly Typeof[];
|
|
78
75
|
};
|
|
79
76
|
export declare namespace Discriminant {
|