@shaclmate/compiler 4.0.98 → 4.0.99
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 +2 -1
- package/dist/generators/ts/AbstractCollectionType.js +10 -5
- package/dist/generators/ts/AbstractCompoundType.d.ts +11 -8
- package/dist/generators/ts/AbstractCompoundType.js +5 -2
- package/dist/generators/ts/AbstractContainerType.d.ts +11 -11
- package/dist/generators/ts/AbstractContainerType.js +21 -15
- package/dist/generators/ts/AbstractDateType.d.ts +7 -6
- package/dist/generators/ts/AbstractDateType.js +16 -6
- package/dist/generators/ts/AbstractDiscriminatedUnionType.d.ts +2 -3
- package/dist/generators/ts/AbstractDiscriminatedUnionType.js +25 -7
- package/dist/generators/ts/AbstractIntersectionType.d.ts +2 -2
- package/dist/generators/ts/AbstractIntersectionType.js +19 -8
- package/dist/generators/ts/AbstractLazyType.d.ts +23 -23
- package/dist/generators/ts/AbstractLazyType.js +21 -19
- package/dist/generators/ts/AbstractNumericType.d.ts +4 -3
- package/dist/generators/ts/AbstractNumericType.js +12 -7
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -2
- package/dist/generators/ts/AbstractPrimitiveType.js +4 -4
- package/dist/generators/ts/AbstractTermType.d.ts +17 -16
- package/dist/generators/ts/AbstractTermType.js +21 -11
- package/dist/generators/ts/AbstractType.d.ts +6 -15
- package/dist/generators/ts/AbstractType.js +14 -33
- package/dist/generators/ts/AbstractTypedLiteralType.d.ts +2 -1
- package/dist/generators/ts/AbstractTypedLiteralType.js +20 -2
- package/dist/generators/ts/BigDecimalType.d.ts +12 -11
- package/dist/generators/ts/BigDecimalType.js +28 -11
- package/dist/generators/ts/BigIntType.js +6 -6
- package/dist/generators/ts/BlankNodeType.d.ts +11 -10
- package/dist/generators/ts/BlankNodeType.js +27 -10
- package/dist/generators/ts/BooleanType.d.ts +6 -5
- package/dist/generators/ts/BooleanType.js +18 -8
- package/dist/generators/ts/Callable.d.ts +2 -2
- package/dist/generators/ts/DateTimeType.d.ts +6 -6
- package/dist/generators/ts/DateTimeType.js +6 -6
- package/dist/generators/ts/DateType.d.ts +6 -6
- package/dist/generators/ts/DateType.js +6 -6
- package/dist/generators/ts/DefaultValueType.d.ts +2 -2
- package/dist/generators/ts/DefaultValueType.js +18 -8
- package/dist/generators/ts/FloatType.js +4 -4
- package/dist/generators/ts/IdentifierType.d.ts +11 -10
- package/dist/generators/ts/IdentifierType.js +27 -10
- package/dist/generators/ts/IntType.js +4 -4
- package/dist/generators/ts/IriType.d.ts +5 -5
- package/dist/generators/ts/IriType.js +27 -22
- package/dist/generators/ts/LangStringType.d.ts +10 -10
- package/dist/generators/ts/LangStringType.js +21 -13
- package/dist/generators/ts/ListType.js +7 -7
- package/dist/generators/ts/LiteralType.d.ts +10 -10
- package/dist/generators/ts/LiteralType.js +21 -13
- package/dist/generators/ts/ObjectType.d.ts +13 -15
- package/dist/generators/ts/ObjectType.js +32 -9
- package/dist/generators/ts/OptionType.d.ts +2 -1
- package/dist/generators/ts/OptionType.js +16 -11
- package/dist/generators/ts/SetType.d.ts +2 -1
- package/dist/generators/ts/SetType.js +22 -10
- package/dist/generators/ts/Snippets.d.ts +1 -0
- package/dist/generators/ts/Snippets.js +7 -0
- package/dist/generators/ts/StringType.d.ts +6 -6
- package/dist/generators/ts/StringType.js +20 -17
- package/dist/generators/ts/TermType.d.ts +7 -7
- package/dist/generators/ts/TermType.js +18 -13
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromJsonObjectFunction.js +1 -1
- package/dist/generators/ts/_AbstractType/AbstractType_JsonType.d.ts +39 -16
- package/dist/generators/ts/_AbstractType/AbstractType_JsonType.js +49 -33
- package/dist/generators/ts/_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_focusSparqlWherePatternsFunction.js +1 -1
- package/dist/generators/ts/_ObjectIntersectionType/ObjectIntersectionType_fromRdfResourceValuesFunction.js +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.d.ts +4 -7
- package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.js +1 -3
- package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.d.ts +0 -1
- package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.js +0 -1
- package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.d.ts +3 -2
- package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.js +30 -10
- package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.d.ts +3 -2
- package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.js +26 -10
- package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.d.ts +3 -2
- package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.js +46 -22
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunction.js +1 -1
- package/package.json +2 -2
- package/dist/generators/ts/AbstractStructuredType.d.ts +0 -71
- package/dist/generators/ts/AbstractStructuredType.js +0 -273
- package/dist/generators/ts/ReferenceCallable.d.ts +0 -14
- package/dist/generators/ts/ReferenceCallable.js +0 -16
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.d.ts +0 -5
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.js +0 -11
- package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +0 -15
- package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +0 -15
|
@@ -7,10 +7,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
8
|
import { invariant } from "ts-invariant";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
|
-
import {
|
|
10
|
+
import { AbstractBuiltinType } from "./AbstractBuiltinType.js";
|
|
11
11
|
import { InlineCallable } from "./InlineCallable.js";
|
|
12
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
12
13
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
13
|
-
export class AbstractLazyType extends
|
|
14
|
+
export class AbstractLazyType extends AbstractBuiltinType {
|
|
14
15
|
discriminatedType = Maybe.empty();
|
|
15
16
|
mutable = false;
|
|
16
17
|
partialType;
|
|
@@ -37,13 +38,13 @@ export class AbstractLazyType extends AbstractType {
|
|
|
37
38
|
get fromJsonObjectFunction() {
|
|
38
39
|
return new InlineCallable(code `(jsonObject, fromJsonObjectOptions) => ${this.partialType.fromJsonObjectFunction.annotatedUsage}(jsonObject, { ...fromJsonObjectOptions, schema: fromJsonObjectOptions.schema.partialType })
|
|
39
40
|
.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromJsonObjectOptions` } })} }))`, {
|
|
40
|
-
type: code `${this.reusables.snippets.FromJsonFunction}<${this.jsonObjectType.expression}, ${this.expression}, ${this.schema}>`,
|
|
41
|
+
type: code `${this.reusables.snippets.FromJsonFunction}<${this.jsonObjectType.expression}, ${this.expression}, ${this.schema.expression}>`,
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
get fromJsonValueFunction() {
|
|
44
45
|
return new InlineCallable(code `(jsonValue, fromJsonValueOptions) => ${this.partialType.fromJsonValueFunction.annotatedUsage}(jsonValue, { ...fromJsonValueOptions, schema: fromJsonValueOptions.schema.partialType })
|
|
45
46
|
.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromJsonValueOptions` } })} }))`, {
|
|
46
|
-
type: code `${this.reusables.snippets.FromJsonFunction}<${this.jsonValueType.expression}, ${this.expression}, ${this.schema}>`,
|
|
47
|
+
type: code `${this.reusables.snippets.FromJsonFunction}<${this.jsonValueType.expression}, ${this.expression}, ${this.schema.expression}>`,
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
get fromRdfResourceValuesFunction() {
|
|
@@ -51,7 +52,7 @@ export class AbstractLazyType extends AbstractType {
|
|
|
51
52
|
(values, fromRdfResourceValuesOptions) =>
|
|
52
53
|
${this.partialType.fromRdfResourceValuesFunction.annotatedUsage}(values, { ...fromRdfResourceValuesOptions, schema: fromRdfResourceValuesOptions.schema.partialType })
|
|
53
54
|
.map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromRdfResourceValuesOptions` } })} })))`, {
|
|
54
|
-
type: code `${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.
|
|
55
|
+
type: code `${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.schema.type.expression}>`,
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
get graphqlType() {
|
|
@@ -84,12 +85,6 @@ export class AbstractLazyType extends AbstractType {
|
|
|
84
85
|
get referencesNamedType() {
|
|
85
86
|
return this.partialType.referencesNamedType;
|
|
86
87
|
}
|
|
87
|
-
get schemaType() {
|
|
88
|
-
return code `${{
|
|
89
|
-
kind: this.kind,
|
|
90
|
-
partialType: this.partialType.schemaType,
|
|
91
|
-
}}`;
|
|
92
|
-
}
|
|
93
88
|
get toJsonObjectFunction() {
|
|
94
89
|
return new InlineCallable(code `(value) => ${this.partialType.toJsonObjectFunction.unannotatedUsage}(value.${this.runtimeClass.partialPropertyName})`, {
|
|
95
90
|
type: code `${this.reusables.snippets.ToJsonFunction}<${this.expression}, ${this.jsonValueType.expression}>`,
|
|
@@ -105,16 +100,23 @@ export class AbstractLazyType extends AbstractType {
|
|
|
105
100
|
}
|
|
106
101
|
get valueSparqlConstructTriplesFunction() {
|
|
107
102
|
return new InlineCallable(code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlConstructTriplesFunction.annotatedUsage}({ ...otherParameters, schema: schema.partialType }))`, {
|
|
108
|
-
type: code `${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.
|
|
103
|
+
type: code `${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schema.type.expression}>`,
|
|
109
104
|
});
|
|
110
105
|
}
|
|
111
106
|
get valueSparqlWherePatternsFunction() {
|
|
112
107
|
return new InlineCallable(code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction.annotatedUsage}({ ...otherParameters, schema: schema.partialType }))`, {
|
|
113
|
-
type: code `${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.
|
|
108
|
+
type: code `${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schema.type.expression}>`,
|
|
114
109
|
});
|
|
115
110
|
}
|
|
116
|
-
get
|
|
117
|
-
return
|
|
111
|
+
get schema() {
|
|
112
|
+
return new SchemaObject({
|
|
113
|
+
properties: {
|
|
114
|
+
...super.schema.properties,
|
|
115
|
+
partialType: code `get partialType() { return ${this.partialType.schema.expression}; }`,
|
|
116
|
+
},
|
|
117
|
+
type: new SchemaObject.BuiltinType(code `${this.reusables.snippets.LazySchema}<${this.partialType.schema.type.expression}>`),
|
|
118
|
+
variable: super.schema.variable,
|
|
119
|
+
});
|
|
118
120
|
}
|
|
119
121
|
toLoggableExpression({ variables, }) {
|
|
120
122
|
return this.partialType.toLoggableExpression({
|
|
@@ -189,16 +191,16 @@ __decorate([
|
|
|
189
191
|
__decorate([
|
|
190
192
|
Memoize()
|
|
191
193
|
], AbstractLazyType.prototype, "jsTypes", null);
|
|
192
|
-
__decorate([
|
|
193
|
-
Memoize()
|
|
194
|
-
], AbstractLazyType.prototype, "schemaType", null);
|
|
195
194
|
__decorate([
|
|
196
195
|
Memoize()
|
|
197
196
|
], AbstractLazyType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
198
197
|
__decorate([
|
|
199
198
|
Memoize()
|
|
200
199
|
], AbstractLazyType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
200
|
+
__decorate([
|
|
201
|
+
Memoize()
|
|
202
|
+
], AbstractLazyType.prototype, "schema", null);
|
|
201
203
|
(function (AbstractLazyType) {
|
|
202
|
-
AbstractLazyType.GraphqlType =
|
|
204
|
+
AbstractLazyType.GraphqlType = AbstractBuiltinType.GraphqlType;
|
|
203
205
|
})(AbstractLazyType || (AbstractLazyType = {}));
|
|
204
206
|
//# sourceMappingURL=AbstractLazyType.js.map
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
2
|
+
import { BuiltinCallable } from "./BuiltinCallable.js";
|
|
2
3
|
import type { Callable } from "./Callable.js";
|
|
3
|
-
import {
|
|
4
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
4
5
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
5
6
|
/**
|
|
6
7
|
* Abstract base class for TypeScript numeric types (bigint | number).
|
|
7
8
|
*/
|
|
8
9
|
export declare abstract class AbstractNumericType<ValueT extends bigint | number> extends AbstractPrimitiveType<ValueT> {
|
|
9
|
-
readonly hashFunction:
|
|
10
|
+
readonly hashFunction: BuiltinCallable;
|
|
10
11
|
abstract readonly kind: "BigInt" | "Float" | "Int";
|
|
11
12
|
get filterFunction(): Callable;
|
|
12
13
|
get filterType(): Code;
|
|
13
|
-
get
|
|
14
|
+
get schema(): SchemaObject<SchemaObject.BuiltinType>;
|
|
14
15
|
get valueSparqlWherePatternsFunction(): Callable;
|
|
15
16
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
16
17
|
}
|
|
@@ -6,24 +6,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Memoize } from "typescript-memoize";
|
|
8
8
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
9
|
-
import {
|
|
9
|
+
import { BuiltinCallable } from "./BuiltinCallable.js";
|
|
10
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
10
11
|
import { code } from "./ts-poet-wrapper.js";
|
|
11
12
|
/**
|
|
12
13
|
* Abstract base class for TypeScript numeric types (bigint | number).
|
|
13
14
|
*/
|
|
14
15
|
export class AbstractNumericType extends AbstractPrimitiveType {
|
|
15
|
-
hashFunction = new
|
|
16
|
+
hashFunction = new BuiltinCallable(this.reusables.snippets.hashNumeric);
|
|
16
17
|
get filterFunction() {
|
|
17
|
-
return new
|
|
18
|
+
return new BuiltinCallable(code `${this.reusables.snippets.filterNumeric}<${this.expression}>`);
|
|
18
19
|
}
|
|
19
20
|
get filterType() {
|
|
20
21
|
return code `${this.reusables.snippets.NumericFilter}<${this.expression}>`;
|
|
21
22
|
}
|
|
22
|
-
get
|
|
23
|
-
return
|
|
23
|
+
get schema() {
|
|
24
|
+
return new SchemaObject({
|
|
25
|
+
properties: super.schema.properties,
|
|
26
|
+
type: new SchemaObject.BuiltinType(code `${this.reusables.snippets.NumericSchema}<${this.expression}>`),
|
|
27
|
+
variable: super.schema.variable,
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
30
|
get valueSparqlWherePatternsFunction() {
|
|
26
|
-
return new
|
|
31
|
+
return new BuiltinCallable(code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.expression}>`);
|
|
27
32
|
}
|
|
28
33
|
toRdfResourceValuesExpression({ variables, }) {
|
|
29
34
|
return code `[${this.reusables.snippets.literalFactory}.${this.jsTypes[0].typeof}(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
|
|
@@ -37,7 +42,7 @@ __decorate([
|
|
|
37
42
|
], AbstractNumericType.prototype, "filterType", null);
|
|
38
43
|
__decorate([
|
|
39
44
|
Memoize()
|
|
40
|
-
], AbstractNumericType.prototype, "
|
|
45
|
+
], AbstractNumericType.prototype, "schema", null);
|
|
41
46
|
__decorate([
|
|
42
47
|
Memoize()
|
|
43
48
|
], AbstractNumericType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Primitive } from "@rdfx/literal";
|
|
2
2
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
3
3
|
import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
|
|
4
|
-
import {
|
|
4
|
+
import { BuiltinCallable } from "./BuiltinCallable.js";
|
|
5
5
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
6
6
|
/**
|
|
7
7
|
* Abstract base class of typed literals whose datatype corresponds to a JavaScript primitive type.
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class AbstractPrimitiveType<ValueT extends Primitive> extends AbstractTypedLiteralType<ValueT> {
|
|
10
10
|
protected abstract readonly decodedIn: readonly ValueT[];
|
|
11
|
-
readonly equalsFunction:
|
|
11
|
+
readonly equalsFunction: BuiltinCallable;
|
|
12
12
|
get toJsonObjectFunction(): AbstractTypedLiteralType<ValueT>["toJsonObjectFunction"];
|
|
13
13
|
get toJsonValueFunction(): AbstractTypedLiteralType<ValueT>["toJsonValueFunction"];
|
|
14
14
|
protected get inlineExpression(): Code;
|
|
@@ -7,18 +7,18 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Memoize } from "typescript-memoize";
|
|
8
8
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
9
9
|
import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
|
|
10
|
-
import {
|
|
10
|
+
import { BuiltinCallable } from "./BuiltinCallable.js";
|
|
11
11
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
12
12
|
/**
|
|
13
13
|
* Abstract base class of typed literals whose datatype corresponds to a JavaScript primitive type.
|
|
14
14
|
*/
|
|
15
15
|
export class AbstractPrimitiveType extends AbstractTypedLiteralType {
|
|
16
|
-
equalsFunction = new
|
|
16
|
+
equalsFunction = new BuiltinCallable(this.reusables.snippets.strictEquals);
|
|
17
17
|
get toJsonObjectFunction() {
|
|
18
|
-
return new
|
|
18
|
+
return new BuiltinCallable(code `${this.reusables.snippets.primitiveToJsonObject}<${this.expression}>(${this.rdfjsTermExpression(this.datatype)})`);
|
|
19
19
|
}
|
|
20
20
|
get toJsonValueFunction() {
|
|
21
|
-
return new
|
|
21
|
+
return new BuiltinCallable(code `${this.reusables.snippets.primitiveToJsonValue}<${this.expression}>`);
|
|
22
22
|
}
|
|
23
23
|
get inlineExpression() {
|
|
24
24
|
if (this.in_.length > 0) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
|
|
2
2
|
import { NodeKind } from "@shaclmate/shacl-ast";
|
|
3
|
-
import {
|
|
3
|
+
import { AbstractBuiltinType } from "./AbstractBuiltinType.js";
|
|
4
|
+
import { BuiltinCallable } from "./BuiltinCallable.js";
|
|
4
5
|
import type { Callable } from "./Callable.js";
|
|
5
|
-
import {
|
|
6
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
6
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
7
8
|
/**
|
|
8
9
|
* Abstract base class for all types that are terms in RDF (i.e., identifiers, literals).
|
|
@@ -12,27 +13,27 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
12
13
|
*
|
|
13
14
|
* The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
|
|
14
15
|
*/
|
|
15
|
-
export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends
|
|
16
|
-
readonly equalsFunction:
|
|
17
|
-
readonly graphqlArgs:
|
|
16
|
+
export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends AbstractBuiltinType {
|
|
17
|
+
readonly equalsFunction: BuiltinCallable;
|
|
18
|
+
readonly graphqlArgs: AbstractBuiltinType["graphqlArgs"];
|
|
18
19
|
readonly hasValues: readonly ConstantTermT[];
|
|
19
|
-
readonly hashFunction:
|
|
20
|
+
readonly hashFunction: BuiltinCallable;
|
|
20
21
|
readonly in_: readonly ConstantTermT[];
|
|
21
22
|
readonly mutable: boolean;
|
|
22
23
|
abstract readonly nodeKinds: ReadonlySet<NodeKind>;
|
|
23
24
|
readonly recursive = false;
|
|
24
|
-
readonly validationFunction:
|
|
25
|
+
readonly validationFunction: AbstractBuiltinType["validationFunction"];
|
|
25
26
|
constructor({ hasValues, in_, ...superParameters }: {
|
|
26
27
|
hasValues: readonly ConstantTermT[];
|
|
27
28
|
in_: readonly ConstantTermT[];
|
|
28
|
-
} & ConstructorParameters<typeof
|
|
29
|
+
} & ConstructorParameters<typeof AbstractBuiltinType>[0]);
|
|
29
30
|
get referencesNamedType(): boolean;
|
|
30
31
|
get termTypes(): ReadonlySet<"BlankNode" | "Literal" | "NamedNode">;
|
|
31
32
|
get toRdfResourceValueTypes(): ReadonlySet<"BlankNode" | "Literal" | "NamedNode">;
|
|
32
33
|
get valueSparqlConstructTriplesFunction(): Callable;
|
|
33
|
-
|
|
34
|
-
toRdfResourceValuesExpression({ variables, }: Parameters<
|
|
35
|
-
toStringExpression({ variables, }: Parameters<
|
|
34
|
+
get schema(): SchemaObject<SchemaObject.AbstractType | SchemaObject.BuiltinType>;
|
|
35
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractBuiltinType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
36
|
+
toStringExpression({ variables, }: Parameters<AbstractBuiltinType["toStringExpression"]>[0]): Code;
|
|
36
37
|
/**
|
|
37
38
|
* An expression that converts a compile-time RDF/JS term into a runtime TypeScript value.
|
|
38
39
|
*
|
|
@@ -41,11 +42,11 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
41
42
|
valueExpression(term: ConstantTermT): Code;
|
|
42
43
|
}
|
|
43
44
|
export declare namespace AbstractTermType {
|
|
44
|
-
type ConversionFunction =
|
|
45
|
-
type DiscriminatedType =
|
|
45
|
+
type ConversionFunction = AbstractBuiltinType.ConversionFunction;
|
|
46
|
+
type DiscriminatedType = AbstractBuiltinType.DiscriminatedType;
|
|
46
47
|
const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
47
|
-
type GraphqlType =
|
|
48
|
-
type JsType =
|
|
49
|
-
type JsonType =
|
|
48
|
+
type GraphqlType = AbstractBuiltinType.GraphqlType;
|
|
49
|
+
type JsType = AbstractBuiltinType.JsType;
|
|
50
|
+
type JsonType = AbstractBuiltinType.JsonType;
|
|
50
51
|
}
|
|
51
52
|
//# sourceMappingURL=AbstractTermType.d.ts.map
|
|
@@ -7,9 +7,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { NodeKind } from "@shaclmate/shacl-ast";
|
|
8
8
|
import { Maybe } from "purify-ts";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
|
-
import {
|
|
10
|
+
import { AbstractBuiltinType } from "./AbstractBuiltinType.js";
|
|
11
|
+
import { BuiltinCallable } from "./BuiltinCallable.js";
|
|
11
12
|
import { InlineCallable } from "./InlineCallable.js";
|
|
12
|
-
import {
|
|
13
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
13
14
|
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
14
15
|
/**
|
|
15
16
|
* Abstract base class for all types that are terms in RDF (i.e., identifiers, literals).
|
|
@@ -19,11 +20,11 @@ import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
|
19
20
|
*
|
|
20
21
|
* The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
|
|
21
22
|
*/
|
|
22
|
-
export class AbstractTermType extends
|
|
23
|
-
equalsFunction = new
|
|
23
|
+
export class AbstractTermType extends AbstractBuiltinType {
|
|
24
|
+
equalsFunction = new BuiltinCallable(this.reusables.snippets.booleanEquals);
|
|
24
25
|
graphqlArgs = Maybe.empty();
|
|
25
26
|
hasValues;
|
|
26
|
-
hashFunction = new
|
|
27
|
+
hashFunction = new BuiltinCallable(this.reusables.snippets.hashTerm);
|
|
27
28
|
in_;
|
|
28
29
|
mutable = false;
|
|
29
30
|
recursive = false;
|
|
@@ -45,15 +46,21 @@ export class AbstractTermType extends AbstractType {
|
|
|
45
46
|
get valueSparqlConstructTriplesFunction() {
|
|
46
47
|
return new InlineCallable(code `((_: object) => [])`);
|
|
47
48
|
}
|
|
48
|
-
get
|
|
49
|
-
|
|
49
|
+
get schema() {
|
|
50
|
+
const thisProperties = {};
|
|
50
51
|
if (this.hasValues.length > 0) {
|
|
51
|
-
|
|
52
|
+
thisProperties["hasValues"] =
|
|
53
|
+
code `hasValues: ${arrayOf(...this.hasValues.map((hasValue) => this.rdfjsTermExpression(hasValue)))}`;
|
|
52
54
|
}
|
|
53
55
|
if (this.in_.length > 0) {
|
|
54
|
-
|
|
56
|
+
thisProperties["in"] =
|
|
57
|
+
code `in: ${arrayOf(...this.in_.map((in_) => this.valueExpression(in_)))} as const`;
|
|
55
58
|
}
|
|
56
|
-
return
|
|
59
|
+
return new SchemaObject({
|
|
60
|
+
properties: { ...super.schema.properties, ...thisProperties },
|
|
61
|
+
type: new SchemaObject.AbstractType("AbstractTermType"),
|
|
62
|
+
variable: super.schema.variable,
|
|
63
|
+
});
|
|
57
64
|
}
|
|
58
65
|
toRdfResourceValuesExpression({ variables, }) {
|
|
59
66
|
return code `[${variables.value}]`;
|
|
@@ -79,7 +86,10 @@ __decorate([
|
|
|
79
86
|
__decorate([
|
|
80
87
|
Memoize()
|
|
81
88
|
], AbstractTermType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
89
|
+
__decorate([
|
|
90
|
+
Memoize()
|
|
91
|
+
], AbstractTermType.prototype, "schema", null);
|
|
82
92
|
(function (AbstractTermType) {
|
|
83
|
-
AbstractTermType.GraphqlType =
|
|
93
|
+
AbstractTermType.GraphqlType = AbstractBuiltinType.GraphqlType;
|
|
84
94
|
})(AbstractTermType || (AbstractTermType = {}));
|
|
85
95
|
//# sourceMappingURL=AbstractTermType.js.map
|
|
@@ -7,6 +7,7 @@ import type { AbstractType_JsonType, AbstractType_JsonTypeFactory } from "./_Abs
|
|
|
7
7
|
import { AbstractType_JsType } from "./_AbstractType/AbstractType_JsType.js";
|
|
8
8
|
import { AbstractConstruct } from "./AbstractConstruct.js";
|
|
9
9
|
import type { Callable } from "./Callable.js";
|
|
10
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
10
11
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
11
12
|
/**
|
|
12
13
|
* Abstract base class all types.
|
|
@@ -126,9 +127,9 @@ export declare abstract class AbstractType extends AbstractConstruct {
|
|
|
126
127
|
*/
|
|
127
128
|
abstract readonly referencesNamedType: boolean;
|
|
128
129
|
/**
|
|
129
|
-
* TypeScript
|
|
130
|
+
* TypeScript object describing this type, for runtime use.
|
|
130
131
|
*/
|
|
131
|
-
|
|
132
|
+
get schema(): SchemaObject<SchemaObject.Type>;
|
|
132
133
|
/**
|
|
133
134
|
* Identifier of the shape this type was derived from.
|
|
134
135
|
*/
|
|
@@ -147,7 +148,7 @@ export declare abstract class AbstractType extends AbstractConstruct {
|
|
|
147
148
|
abstract readonly toRdfResourceValueTypes: ReadonlySet<"BlankNode" | "NamedNode" | "Literal">;
|
|
148
149
|
/**
|
|
149
150
|
* Function that takes
|
|
150
|
-
* - a schema of this.
|
|
151
|
+
* - a schema of this.schema.type
|
|
151
152
|
* - a value of this.type
|
|
152
153
|
*
|
|
153
154
|
* and validates the value against the schema, returning
|
|
@@ -163,7 +164,7 @@ export declare abstract class AbstractType extends AbstractConstruct {
|
|
|
163
164
|
* The function takes a parameters object with the following parameters:
|
|
164
165
|
* - filter: an instance of filterType | undefined
|
|
165
166
|
* - ignoreRdfType: boolean
|
|
166
|
-
* - schema: instance of this.
|
|
167
|
+
* - schema: instance of this.schema.type
|
|
167
168
|
* - valueVariable: rdfjs.Variable of the value of this type
|
|
168
169
|
* - variablePrefix: string prefix to use for new variables
|
|
169
170
|
*/
|
|
@@ -175,7 +176,7 @@ export declare abstract class AbstractType extends AbstractConstruct {
|
|
|
175
176
|
* - filter: an instance of filterType | undefined
|
|
176
177
|
* - preferredLanguages: array of preferred language code (strings) | undefined
|
|
177
178
|
* - propertyPatterns: array of sparqljs.Pattern's for the property; may be empty
|
|
178
|
-
* - schema: instance of this.
|
|
179
|
+
* - schema: instance of this.schema.type
|
|
179
180
|
* - valueVariable: rdfjs.Variable of the value of this type
|
|
180
181
|
* - variablePrefix: string prefix to use for new variables
|
|
181
182
|
*/
|
|
@@ -193,15 +194,6 @@ export declare abstract class AbstractType extends AbstractConstruct {
|
|
|
193
194
|
* Expression of this type. If the type has a name it will be that name (a reference). Otherwise it will be the .inlineExpression.
|
|
194
195
|
*/
|
|
195
196
|
get expression(): Code;
|
|
196
|
-
/**
|
|
197
|
-
* TypeScript object describing this type, for runtime use.
|
|
198
|
-
*/
|
|
199
|
-
get schema(): Code;
|
|
200
|
-
get schemaVariable(): Maybe<Code>;
|
|
201
|
-
/**
|
|
202
|
-
* Helper to compose the result of schema along the type hierarchy.
|
|
203
|
-
*/
|
|
204
|
-
protected get schemaInitializers(): readonly Code[];
|
|
205
197
|
/**
|
|
206
198
|
* An expression that resolves a value of this type in the GraphQL server.
|
|
207
199
|
*/
|
|
@@ -247,7 +239,6 @@ export declare abstract class AbstractType extends AbstractConstruct {
|
|
|
247
239
|
value: Code;
|
|
248
240
|
};
|
|
249
241
|
}): Code;
|
|
250
|
-
protected schemaExpression(): Code;
|
|
251
242
|
protected staticModuleDeclarations(_name: string): Record<string, Code>;
|
|
252
243
|
}
|
|
253
244
|
export declare namespace AbstractType {
|
|
@@ -10,6 +10,7 @@ import { AbstractType_ConversionFunction } from "./_AbstractType/AbstractType_Co
|
|
|
10
10
|
import { AbstractType_GraphqlType } from "./_AbstractType/AbstractType_GraphqlType.js";
|
|
11
11
|
import { AbstractType_JsType } from "./_AbstractType/AbstractType_JsType.js";
|
|
12
12
|
import { AbstractConstruct } from "./AbstractConstruct.js";
|
|
13
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
13
14
|
import { code, def, joinCode, literalOf, } from "./ts-poet-wrapper.js";
|
|
14
15
|
import { tsComment } from "./tsComment.js";
|
|
15
16
|
/**
|
|
@@ -24,6 +25,18 @@ export class AbstractType extends AbstractConstruct {
|
|
|
24
25
|
* Name for this type.
|
|
25
26
|
*/
|
|
26
27
|
name;
|
|
28
|
+
/**
|
|
29
|
+
* TypeScript object describing this type, for runtime use.
|
|
30
|
+
*/
|
|
31
|
+
get schema() {
|
|
32
|
+
return new SchemaObject({
|
|
33
|
+
properties: {
|
|
34
|
+
kind: code `kind: ${literalOf(this.kind)}`,
|
|
35
|
+
},
|
|
36
|
+
type: new SchemaObject.AbstractType(this.kind),
|
|
37
|
+
variable: this.name.map((name) => code `${name}.schema`),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
27
40
|
/**
|
|
28
41
|
* Identifier of the shape this type was derived from.
|
|
29
42
|
*/
|
|
@@ -68,34 +81,11 @@ ${joinCode(staticModuleDeclarations
|
|
|
68
81
|
.map((name) => code `${name}`)
|
|
69
82
|
.orDefaultLazy(() => this.inlineExpression);
|
|
70
83
|
}
|
|
71
|
-
/**
|
|
72
|
-
* TypeScript object describing this type, for runtime use.
|
|
73
|
-
*/
|
|
74
|
-
get schema() {
|
|
75
|
-
return this.name
|
|
76
|
-
.map((name) => code `${name}.schema`)
|
|
77
|
-
.orDefaultLazy(() => this.schemaExpression());
|
|
78
|
-
}
|
|
79
|
-
get schemaVariable() {
|
|
80
|
-
if (!this.configuration.features.has("Object.schema")) {
|
|
81
|
-
return Maybe.empty();
|
|
82
|
-
}
|
|
83
|
-
return this.name.map((name) => code `${name}.schema`);
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Helper to compose the result of schema along the type hierarchy.
|
|
87
|
-
*/
|
|
88
|
-
get schemaInitializers() {
|
|
89
|
-
return [code `kind: ${literalOf(this.kind)} as const`];
|
|
90
|
-
}
|
|
91
|
-
schemaExpression() {
|
|
92
|
-
return code `{ ${joinCode(this.schemaInitializers.concat(), { on: ", " })} }`;
|
|
93
|
-
}
|
|
94
84
|
staticModuleDeclarations(_name) {
|
|
95
85
|
const staticModuleDeclarations = {};
|
|
96
86
|
if (this.configuration.features.has("Object.schema")) {
|
|
97
87
|
staticModuleDeclarations["schema"] =
|
|
98
|
-
code `export const schema = ${this.
|
|
88
|
+
code `export const schema = ${this.schema.literalExpression};`;
|
|
99
89
|
staticModuleDeclarations["Schema"] =
|
|
100
90
|
code `export type Schema = typeof schema;`;
|
|
101
91
|
}
|
|
@@ -108,15 +98,6 @@ __decorate([
|
|
|
108
98
|
__decorate([
|
|
109
99
|
Memoize()
|
|
110
100
|
], AbstractType.prototype, "expression", null);
|
|
111
|
-
__decorate([
|
|
112
|
-
Memoize()
|
|
113
|
-
], AbstractType.prototype, "schema", null);
|
|
114
|
-
__decorate([
|
|
115
|
-
Memoize()
|
|
116
|
-
], AbstractType.prototype, "schemaVariable", null);
|
|
117
|
-
__decorate([
|
|
118
|
-
Memoize()
|
|
119
|
-
], AbstractType.prototype, "schemaExpression", null);
|
|
120
101
|
(function (AbstractType) {
|
|
121
102
|
let ConversionFunction;
|
|
122
103
|
(function (ConversionFunction) {
|
|
@@ -2,6 +2,7 @@ import type { Literal, NamedNode } from "@rdfjs/types";
|
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
4
4
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
5
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
5
6
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
6
7
|
/**
|
|
7
8
|
* Abstract base class of all types that are typed literals in RDF. In RDF every literal is either
|
|
@@ -15,7 +16,7 @@ export declare abstract class AbstractTypedLiteralType<ValueT> extends AbstractL
|
|
|
15
16
|
constructor({ datatype, ...superParameters }: {
|
|
16
17
|
datatype: NamedNode;
|
|
17
18
|
} & ConstructorParameters<typeof AbstractLiteralType>[0]);
|
|
18
|
-
|
|
19
|
+
get schema(): SchemaObject<SchemaObject.AbstractType | SchemaObject.BuiltinType>;
|
|
19
20
|
graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
20
21
|
abstract valueExpression(literal: Literal | ValueT): Code;
|
|
21
22
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
1
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { Memoize } from "typescript-memoize";
|
|
2
9
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
3
10
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
11
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
4
12
|
import { code } from "./ts-poet-wrapper.js";
|
|
5
13
|
/**
|
|
6
14
|
* Abstract base class of all types that are typed literals in RDF. In RDF every literal is either
|
|
@@ -24,13 +32,23 @@ export class AbstractTypedLiteralType extends AbstractLiteralType {
|
|
|
24
32
|
super(superParameters);
|
|
25
33
|
this.datatype = datatype;
|
|
26
34
|
}
|
|
27
|
-
get
|
|
28
|
-
return
|
|
35
|
+
get schema() {
|
|
36
|
+
return new SchemaObject({
|
|
37
|
+
properties: {
|
|
38
|
+
...super.schema.properties,
|
|
39
|
+
datatype: code `datatype: ${this.rdfjsTermExpression(this.datatype)}`,
|
|
40
|
+
},
|
|
41
|
+
type: new SchemaObject.AbstractType("AbstractTypedLiteralType"),
|
|
42
|
+
variable: super.schema.variable,
|
|
43
|
+
});
|
|
29
44
|
}
|
|
30
45
|
graphqlResolveExpression({ variables, }) {
|
|
31
46
|
return variables.value;
|
|
32
47
|
}
|
|
33
48
|
}
|
|
49
|
+
__decorate([
|
|
50
|
+
Memoize()
|
|
51
|
+
], AbstractTypedLiteralType.prototype, "schema", null);
|
|
34
52
|
(function (AbstractTypedLiteralType) {
|
|
35
53
|
AbstractTypedLiteralType.GraphqlType = AbstractTermType.GraphqlType;
|
|
36
54
|
})(AbstractTypedLiteralType || (AbstractTypedLiteralType = {}));
|
|
@@ -2,29 +2,30 @@ import type { Literal } from "@rdfjs/types";
|
|
|
2
2
|
import type { Decimal } from "decimal.js";
|
|
3
3
|
import { Maybe } from "purify-ts";
|
|
4
4
|
import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
|
|
5
|
-
import {
|
|
5
|
+
import { BuiltinCallable } from "./BuiltinCallable.js";
|
|
6
|
+
import { SchemaObject } from "./SchemaObject.js";
|
|
6
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
7
8
|
export declare class BigDecimalType extends AbstractTypedLiteralType<Decimal> {
|
|
8
9
|
protected readonly inlineExpression: Code;
|
|
9
|
-
readonly jsonValueType: AbstractTypedLiteralType.JsonType;
|
|
10
10
|
readonly jsTypes: readonly [{
|
|
11
11
|
readonly className: Code;
|
|
12
12
|
readonly instanceof: "class";
|
|
13
13
|
readonly typeof: "object";
|
|
14
14
|
}];
|
|
15
15
|
readonly conversionFunction: Maybe<AbstractTypedLiteralType.ConversionFunction>;
|
|
16
|
-
readonly filterFunction:
|
|
16
|
+
readonly filterFunction: BuiltinCallable;
|
|
17
17
|
readonly filterType: Code;
|
|
18
|
-
readonly
|
|
19
|
-
readonly
|
|
20
|
-
readonly fromRdfResourceValuesFunction:
|
|
18
|
+
readonly fromJsonObjectFunction: BuiltinCallable;
|
|
19
|
+
readonly fromJsonValueFunction: BuiltinCallable;
|
|
20
|
+
readonly fromRdfResourceValuesFunction: BuiltinCallable;
|
|
21
21
|
readonly graphqlType: import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
22
|
-
readonly hashFunction:
|
|
22
|
+
readonly hashFunction: BuiltinCallable;
|
|
23
|
+
readonly jsonValueType: AbstractTypedLiteralType.JsonType;
|
|
23
24
|
readonly kind = "BigDecimal";
|
|
24
|
-
readonly
|
|
25
|
-
readonly toJsonValueFunction:
|
|
26
|
-
readonly
|
|
27
|
-
|
|
25
|
+
readonly toJsonObjectFunction: BuiltinCallable;
|
|
26
|
+
readonly toJsonValueFunction: BuiltinCallable;
|
|
27
|
+
readonly valueSparqlWherePatternsFunction: BuiltinCallable;
|
|
28
|
+
get schema(): SchemaObject<SchemaObject.BuiltinType>;
|
|
28
29
|
graphqlResolveExpression({ variables, }: Parameters<AbstractTypedLiteralType<Decimal>["graphqlResolveExpression"]>[0]): Code;
|
|
29
30
|
toLoggableExpression({ variables, }: Parameters<AbstractTypedLiteralType<Decimal>["toLoggableExpression"]>[0]): Code;
|
|
30
31
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractTypedLiteralType<Decimal>["toRdfResourceValuesExpression"]>[0]): Code;
|