@shaclmate/compiler 4.0.90 → 4.0.92
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/AbstractNumericType.d.ts +1 -0
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +0 -7
- package/dist/generators/ts/AbstractPrimitiveType.js +0 -7
- package/dist/generators/ts/BigDecimalType.d.ts +6 -8
- package/dist/generators/ts/BigDecimalType.js +27 -10
- package/dist/generators/ts/BigIntType.d.ts +2 -0
- package/dist/generators/ts/BigIntType.js +26 -0
- package/dist/generators/ts/BooleanType.d.ts +2 -0
- package/dist/generators/ts/BooleanType.js +2 -0
- package/dist/generators/ts/DefaultValueType.d.ts +2 -1
- package/dist/generators/ts/FloatType.d.ts +2 -0
- package/dist/generators/ts/FloatType.js +2 -0
- package/dist/generators/ts/IntType.d.ts +2 -0
- package/dist/generators/ts/IntType.js +2 -0
- package/dist/generators/ts/ObjectType.d.ts +7 -6
- package/dist/generators/ts/ObjectType.js +19 -18
- package/dist/generators/ts/Snippets.d.ts +2 -0
- package/dist/generators/ts/Snippets.js +14 -0
- package/dist/generators/ts/StringType.d.ts +3 -1
- package/dist/generators/ts/StringType.js +5 -3
- package/dist/generators/ts/TypeFactory.js +12 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_conversionFunctionExpression.js +2 -0
- package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.d.ts +39 -21
- package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.js +1 -13
- package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.d.ts +14 -22
- package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.js +27 -29
- package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.d.ts +19 -14
- package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.js +24 -12
- package/dist/generators/ts/_ObjectType/ObjectType_Property.d.ts +2 -1
- package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.d.ts +37 -0
- package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.js +118 -0
- package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.d.ts +21 -17
- package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.js +26 -8
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.js +6 -9
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +11 -2
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionExpression.js +1 -12
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionExpression.js +8 -46
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +7 -3
- package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +1 -7
- package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +0 -3
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +1 -3
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.js +1 -8
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +5 -0
- package/dist/generators/ts/_snippets/snippets_convertToBigInt.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBigInt.js +5 -0
- package/dist/input/input.shaclmate.d.ts +45 -18
- package/dist/input/input.shaclmate.js +54 -32
- package/package.json +8 -2
|
@@ -4,8 +4,8 @@ import type { Reusables } from "../Reusables.js";
|
|
|
4
4
|
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
5
5
|
import type { TsGenerator } from "../TsGenerator.js";
|
|
6
6
|
import type { Type } from "../Type.js";
|
|
7
|
-
import {
|
|
8
|
-
export declare abstract class ObjectType_AbstractProperty
|
|
7
|
+
import type { Code } from "../ts-poet-wrapper.js";
|
|
8
|
+
export declare abstract class ObjectType_AbstractProperty {
|
|
9
9
|
protected readonly configuration: TsGenerator.Configuration;
|
|
10
10
|
protected readonly logger: Logger;
|
|
11
11
|
protected readonly objectType: {
|
|
@@ -22,7 +22,7 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
22
22
|
/**
|
|
23
23
|
* Property declaration to include in the type declaration of the ObjectType.
|
|
24
24
|
*/
|
|
25
|
-
abstract readonly declaration: Code
|
|
25
|
+
abstract readonly declaration: Maybe<Code>;
|
|
26
26
|
/**
|
|
27
27
|
* Optional property in the ObjectType's filter.
|
|
28
28
|
*/
|
|
@@ -47,7 +47,7 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
47
47
|
*
|
|
48
48
|
* Only specified if different from declaration.
|
|
49
49
|
*/
|
|
50
|
-
abstract readonly hashFunctionParameter: Code
|
|
50
|
+
abstract readonly hashFunctionParameter: Maybe<Code>;
|
|
51
51
|
/**
|
|
52
52
|
* zod object key: schema.
|
|
53
53
|
*/
|
|
@@ -83,11 +83,7 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
83
83
|
* TypeScript type describing .schema.
|
|
84
84
|
*/
|
|
85
85
|
abstract readonly schemaType: Maybe<Code>;
|
|
86
|
-
|
|
87
|
-
* Property type
|
|
88
|
-
. */
|
|
89
|
-
readonly type: TypeT;
|
|
90
|
-
constructor({ configuration, logger, name, objectType, reusables, type, }: {
|
|
86
|
+
constructor({ configuration, logger, name, objectType, reusables, }: {
|
|
91
87
|
configuration: TsGenerator.Configuration;
|
|
92
88
|
logger: Logger;
|
|
93
89
|
name: string;
|
|
@@ -95,22 +91,36 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
95
91
|
readonly name: Maybe<string>;
|
|
96
92
|
};
|
|
97
93
|
reusables: Reusables;
|
|
98
|
-
type: TypeT;
|
|
99
94
|
});
|
|
100
95
|
/**
|
|
101
|
-
*
|
|
96
|
+
* Initializer (name: value) from a constructor parameter.
|
|
102
97
|
*/
|
|
103
|
-
|
|
98
|
+
abstract constructorInitializer(parameters: {
|
|
104
99
|
variables: {
|
|
105
|
-
|
|
100
|
+
parameters: Code;
|
|
106
101
|
};
|
|
107
|
-
}): Code
|
|
102
|
+
}): Maybe<Code>;
|
|
108
103
|
/**
|
|
109
|
-
*
|
|
104
|
+
* An expression that compares two values of this property, returning a $EqualsResult.
|
|
110
105
|
*/
|
|
111
|
-
abstract
|
|
106
|
+
abstract equalsExpression(parameters: {
|
|
112
107
|
variables: {
|
|
113
|
-
|
|
108
|
+
leftObject: Code;
|
|
109
|
+
rightObject: Code;
|
|
110
|
+
};
|
|
111
|
+
}): Maybe<Code>;
|
|
112
|
+
/**
|
|
113
|
+
* Expression to filter this property using an instance of the ObjectType's filter.
|
|
114
|
+
*
|
|
115
|
+
* Parameters:
|
|
116
|
+
* variables: runtime variables
|
|
117
|
+
* - filter: an instance of the object's filterType or undefined
|
|
118
|
+
* - object: an instance of the object
|
|
119
|
+
*/
|
|
120
|
+
abstract filterExpression(parameters: {
|
|
121
|
+
variables: {
|
|
122
|
+
filter: Code;
|
|
123
|
+
object: Code;
|
|
114
124
|
};
|
|
115
125
|
}): Maybe<Code>;
|
|
116
126
|
/**
|
|
@@ -136,7 +146,7 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
136
146
|
abstract hashStatements(parameters: {
|
|
137
147
|
variables: {
|
|
138
148
|
hasher: Code;
|
|
139
|
-
|
|
149
|
+
object: Code;
|
|
140
150
|
};
|
|
141
151
|
}): readonly Code[];
|
|
142
152
|
/**
|
|
@@ -154,6 +164,7 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
154
164
|
* variables: runtime variables
|
|
155
165
|
* - filter: an instance of the object's filterType or undefined
|
|
156
166
|
* - focusIdentifier: identifier (rdfjs.NamedNode or rdfjs.Variable) of the object that is the focus of the patterns
|
|
167
|
+
* - ignoreRdfType: whether the RDF type of objects/object unions should be ignored
|
|
157
168
|
* - variablePrefix: prefix to use for new SPARQL variables
|
|
158
169
|
*
|
|
159
170
|
* Returns a (runtime) array of sparqljs.Triple.
|
|
@@ -162,6 +173,7 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
162
173
|
variables: {
|
|
163
174
|
filter: Code;
|
|
164
175
|
focusIdentifier: Code;
|
|
176
|
+
ignoreRdfType: Code;
|
|
165
177
|
variablePrefix: Code;
|
|
166
178
|
};
|
|
167
179
|
}): Maybe<Code>;
|
|
@@ -172,6 +184,8 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
172
184
|
* variables: (at runtime)
|
|
173
185
|
* - filter: an instance of the object's filterType or undefined
|
|
174
186
|
* - focusIdentifier: identifier (rdfjs.NamedNode or rdfjs.Variable) of the object that is the focus of the patterns
|
|
187
|
+
* - ignoreRdfType: whether the RDF type of objects/object unions should be ignored
|
|
188
|
+
* - schema: an instance of the object's schema if available
|
|
175
189
|
* - preferredLanguages: array of preferred language code (strings)
|
|
176
190
|
* - variablePrefix: prefix to use for new SPARQL variables
|
|
177
191
|
*
|
|
@@ -183,7 +197,9 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
183
197
|
variables: {
|
|
184
198
|
filter: Code;
|
|
185
199
|
focusIdentifier: Code;
|
|
200
|
+
ignoreRdfType: Code;
|
|
186
201
|
preferredLanguages: Code;
|
|
202
|
+
schema: Maybe<Code>;
|
|
187
203
|
variablePrefix: Code;
|
|
188
204
|
};
|
|
189
205
|
}): Maybe<{
|
|
@@ -195,21 +211,23 @@ export declare abstract class ObjectType_AbstractProperty<TypeT extends Pick<Typ
|
|
|
195
211
|
*/
|
|
196
212
|
abstract toJsonInitializer(parameters: {
|
|
197
213
|
variables: {
|
|
198
|
-
|
|
214
|
+
object: Code;
|
|
199
215
|
};
|
|
200
216
|
}): Maybe<Code>;
|
|
201
217
|
/**
|
|
202
218
|
* Statements to serialize this property to an RDF resource.
|
|
203
219
|
*/
|
|
204
220
|
abstract toRdfRdfResourceValuesStatements(parameters: {
|
|
205
|
-
variables: Omit<Parameters<Type["toRdfResourceValuesExpression"]>[0]["variables"], "propertyPath"
|
|
221
|
+
variables: Omit<Parameters<Type["toRdfResourceValuesExpression"]>[0]["variables"], "propertyPath" | "value"> & {
|
|
222
|
+
object: Code;
|
|
223
|
+
};
|
|
206
224
|
}): readonly Code[];
|
|
207
225
|
/**
|
|
208
226
|
* Initializer (name: value) to serialize this property to a human-readable string (toString).
|
|
209
227
|
*/
|
|
210
228
|
abstract toStringInitializer(parameters: {
|
|
211
229
|
variables: {
|
|
212
|
-
|
|
230
|
+
object: Code;
|
|
213
231
|
};
|
|
214
232
|
}): Maybe<Code>;
|
|
215
233
|
protected readonly rdfjsTermExpression: (parameters: Parameters<typeof rdfjsTermExpression>[0]) => Code;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
2
|
-
import { code } from "../ts-poet-wrapper.js";
|
|
3
2
|
export class ObjectType_AbstractProperty {
|
|
4
3
|
configuration;
|
|
5
4
|
logger;
|
|
@@ -9,29 +8,18 @@ export class ObjectType_AbstractProperty {
|
|
|
9
8
|
* TypeScript identifier-safe name of the property.
|
|
10
9
|
*/
|
|
11
10
|
name;
|
|
12
|
-
|
|
13
|
-
* Property type
|
|
14
|
-
. */
|
|
15
|
-
type;
|
|
16
|
-
constructor({ configuration, logger, name, objectType, reusables, type, }) {
|
|
11
|
+
constructor({ configuration, logger, name, objectType, reusables, }) {
|
|
17
12
|
this.configuration = configuration;
|
|
18
13
|
this.logger = logger;
|
|
19
14
|
this.name = name;
|
|
20
15
|
this.objectType = objectType;
|
|
21
16
|
this.reusables = reusables;
|
|
22
|
-
this.type = type;
|
|
23
17
|
this.rdfjsTermExpression = rdfjsTermExpression.bind({
|
|
24
18
|
imports: this.reusables.imports,
|
|
25
19
|
logger: this.logger,
|
|
26
20
|
snippets: this.reusables.snippets,
|
|
27
21
|
});
|
|
28
22
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Expression to access the value of this property on an object instance. May evaluate a thunk.
|
|
31
|
-
*/
|
|
32
|
-
accessExpression({ variables }) {
|
|
33
|
-
return code `${variables.object}.${this.name}`;
|
|
34
|
-
}
|
|
35
23
|
rdfjsTermExpression;
|
|
36
24
|
}
|
|
37
25
|
//# sourceMappingURL=ObjectType_AbstractProperty.js.map
|
|
@@ -1,45 +1,37 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
3
|
import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
|
|
4
|
-
export declare class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty
|
|
5
|
-
readonly constructorParameter: ObjectType_AbstractProperty
|
|
6
|
-
readonly
|
|
7
|
-
readonly
|
|
8
|
-
readonly graphqlField: ObjectType_AbstractProperty<ObjectType_DiscriminantProperty.Type>["graphqlField"];
|
|
9
|
-
readonly hashFunctionParameter: Code;
|
|
4
|
+
export declare class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty {
|
|
5
|
+
readonly constructorParameter: ObjectType_AbstractProperty["constructorParameter"];
|
|
6
|
+
readonly filterProperty: ObjectType_AbstractProperty["filterProperty"];
|
|
7
|
+
readonly graphqlField: ObjectType_AbstractProperty["graphqlField"];
|
|
10
8
|
readonly kind = "Discriminant";
|
|
11
9
|
readonly mutable = false;
|
|
12
10
|
readonly recursive = false;
|
|
13
11
|
readonly value: string;
|
|
14
12
|
constructor({ configuration, value, ...superParameters }: {
|
|
15
13
|
value: string;
|
|
16
|
-
} & Omit<ConstructorParameters<typeof ObjectType_AbstractProperty>[0], "name"
|
|
14
|
+
} & Omit<ConstructorParameters<typeof ObjectType_AbstractProperty>[0], "name">);
|
|
15
|
+
get declaration(): Maybe<Code>;
|
|
16
|
+
get hashFunctionParameter(): Maybe<Code>;
|
|
17
17
|
get jsonName(): string;
|
|
18
|
-
get jsonSchema(): ObjectType_AbstractProperty
|
|
18
|
+
get jsonSchema(): ObjectType_AbstractProperty["jsonSchema"];
|
|
19
19
|
get jsonSignature(): Maybe<Code>;
|
|
20
20
|
get schema(): Maybe<Code>;
|
|
21
21
|
get schemaType(): Maybe<Code>;
|
|
22
22
|
get values(): readonly string[];
|
|
23
23
|
private get constValue();
|
|
24
24
|
constructorInitializer(): Maybe<Code>;
|
|
25
|
+
equalsExpression(): Maybe<Code>;
|
|
26
|
+
filterExpression(): Maybe<Code>;
|
|
25
27
|
fromJsonInitializer(): Maybe<Code>;
|
|
26
28
|
fromRdfResourceValuesInitializer(): Maybe<Code>;
|
|
27
|
-
hashStatements({ variables, }: Parameters<ObjectType_AbstractProperty
|
|
28
|
-
jsonUiSchemaElement({ variables, }: Parameters<ObjectType_AbstractProperty
|
|
29
|
+
hashStatements({ variables, }: Parameters<ObjectType_AbstractProperty["hashStatements"]>[0]): readonly Code[];
|
|
30
|
+
jsonUiSchemaElement({ variables, }: Parameters<ObjectType_AbstractProperty["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
29
31
|
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
30
|
-
sparqlWherePatternsExpression(): ReturnType<ObjectType_AbstractProperty
|
|
31
|
-
toJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty
|
|
32
|
+
sparqlWherePatternsExpression(): ReturnType<ObjectType_AbstractProperty["sparqlWherePatternsExpression"]>;
|
|
33
|
+
toJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["toJsonInitializer"]>[0]): Maybe<Code>;
|
|
32
34
|
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
33
35
|
toStringInitializer(): Maybe<Code>;
|
|
34
36
|
}
|
|
35
|
-
export declare namespace ObjectType_DiscriminantProperty {
|
|
36
|
-
class Type {
|
|
37
|
-
readonly value: string;
|
|
38
|
-
readonly filterFunction: Code;
|
|
39
|
-
readonly mutable = false;
|
|
40
|
-
constructor(value: string);
|
|
41
|
-
get expression(): Code;
|
|
42
|
-
get schema(): Code;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
37
|
//# sourceMappingURL=ObjectType_DiscriminantProperty.d.ts.map
|
|
@@ -10,10 +10,8 @@ import { code, literalOf } from "../ts-poet-wrapper.js";
|
|
|
10
10
|
import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
|
|
11
11
|
export class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty {
|
|
12
12
|
constructorParameter = Maybe.empty();
|
|
13
|
-
declaration = code `readonly ${this.name}: ${this.type.expression};`;
|
|
14
13
|
filterProperty = Maybe.empty();
|
|
15
14
|
graphqlField = Maybe.empty();
|
|
16
|
-
hashFunctionParameter = code `readonly ${this.name}?: ${this.type.expression};`;
|
|
17
15
|
kind = "Discriminant";
|
|
18
16
|
mutable = false;
|
|
19
17
|
recursive = false;
|
|
@@ -23,10 +21,15 @@ export class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty
|
|
|
23
21
|
...superParameters,
|
|
24
22
|
configuration,
|
|
25
23
|
name: configuration.objectDiscriminantProperty.name,
|
|
26
|
-
type: new ObjectType_DiscriminantProperty.Type(value),
|
|
27
24
|
});
|
|
28
25
|
this.value = value;
|
|
29
26
|
}
|
|
27
|
+
get declaration() {
|
|
28
|
+
return Maybe.of(code `readonly ${this.name}: ${literalOf(this.value)};`);
|
|
29
|
+
}
|
|
30
|
+
get hashFunctionParameter() {
|
|
31
|
+
return Maybe.of(code `readonly ${this.name}?: ${literalOf(this.value)};`);
|
|
32
|
+
}
|
|
30
33
|
get jsonName() {
|
|
31
34
|
return this.configuration.objectDiscriminantProperty.jsonName;
|
|
32
35
|
}
|
|
@@ -37,7 +40,7 @@ export class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty
|
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
42
|
get jsonSignature() {
|
|
40
|
-
return Maybe.of(code `readonly "${this.jsonName}": ${this.
|
|
43
|
+
return Maybe.of(code `readonly "${this.jsonName}": ${literalOf(this.value)}`);
|
|
41
44
|
}
|
|
42
45
|
get schema() {
|
|
43
46
|
return Maybe.of(code `${{ kind: this.kind, value: this.value }}`);
|
|
@@ -54,6 +57,12 @@ export class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty
|
|
|
54
57
|
constructorInitializer() {
|
|
55
58
|
return Maybe.empty();
|
|
56
59
|
}
|
|
60
|
+
equalsExpression() {
|
|
61
|
+
return Maybe.empty();
|
|
62
|
+
}
|
|
63
|
+
filterExpression() {
|
|
64
|
+
return Maybe.empty();
|
|
65
|
+
}
|
|
57
66
|
fromJsonInitializer() {
|
|
58
67
|
return Maybe.empty();
|
|
59
68
|
}
|
|
@@ -62,7 +71,7 @@ export class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty
|
|
|
62
71
|
}
|
|
63
72
|
hashStatements({ variables, }) {
|
|
64
73
|
return [
|
|
65
|
-
code `if (${variables.
|
|
74
|
+
code `if (${variables.object}.${this.name}) { ${variables.hasher}.update(${variables.object}.${this.name}); }`,
|
|
66
75
|
];
|
|
67
76
|
}
|
|
68
77
|
jsonUiSchemaElement({ variables, }) {
|
|
@@ -76,7 +85,7 @@ export class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty
|
|
|
76
85
|
return Maybe.empty();
|
|
77
86
|
}
|
|
78
87
|
toJsonInitializer({ variables, }) {
|
|
79
|
-
return Maybe.of(code `"${this.jsonName}": ${variables.
|
|
88
|
+
return Maybe.of(code `"${this.jsonName}": ${variables.object}.${this.name}`);
|
|
80
89
|
}
|
|
81
90
|
toRdfRdfResourceValuesStatements() {
|
|
82
91
|
return [];
|
|
@@ -85,6 +94,12 @@ export class ObjectType_DiscriminantProperty extends ObjectType_AbstractProperty
|
|
|
85
94
|
return Maybe.empty();
|
|
86
95
|
}
|
|
87
96
|
}
|
|
97
|
+
__decorate([
|
|
98
|
+
Memoize()
|
|
99
|
+
], ObjectType_DiscriminantProperty.prototype, "declaration", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
Memoize()
|
|
102
|
+
], ObjectType_DiscriminantProperty.prototype, "hashFunctionParameter", null);
|
|
88
103
|
__decorate([
|
|
89
104
|
Memoize()
|
|
90
105
|
], ObjectType_DiscriminantProperty.prototype, "jsonName", null);
|
|
@@ -97,27 +112,10 @@ __decorate([
|
|
|
97
112
|
__decorate([
|
|
98
113
|
Memoize()
|
|
99
114
|
], ObjectType_DiscriminantProperty.prototype, "values", null);
|
|
100
|
-
(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.value = value;
|
|
107
|
-
}
|
|
108
|
-
get expression() {
|
|
109
|
-
return code `${literalOf(this.value)}`;
|
|
110
|
-
}
|
|
111
|
-
get schema() {
|
|
112
|
-
throw new Error("should never be called");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
__decorate([
|
|
116
|
-
Memoize()
|
|
117
|
-
], Type.prototype, "expression", null);
|
|
118
|
-
__decorate([
|
|
119
|
-
Memoize()
|
|
120
|
-
], Type.prototype, "schema", null);
|
|
121
|
-
ObjectType_DiscriminantProperty.Type = Type;
|
|
122
|
-
})(ObjectType_DiscriminantProperty || (ObjectType_DiscriminantProperty = {}));
|
|
115
|
+
__decorate([
|
|
116
|
+
Memoize()
|
|
117
|
+
], ObjectType_DiscriminantProperty.prototype, "equalsExpression", null);
|
|
118
|
+
__decorate([
|
|
119
|
+
Memoize()
|
|
120
|
+
], ObjectType_DiscriminantProperty.prototype, "filterExpression", null);
|
|
123
121
|
//# sourceMappingURL=ObjectType_DiscriminantProperty.js.map
|
|
@@ -4,40 +4,45 @@ import type { IdentifierType } from "../IdentifierType.js";
|
|
|
4
4
|
import type { IriType } from "../IriType.js";
|
|
5
5
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
6
6
|
import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
|
|
7
|
-
export declare class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty
|
|
7
|
+
export declare class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
8
8
|
readonly kind = "Identifier";
|
|
9
9
|
readonly mutable = false;
|
|
10
10
|
readonly recursive = false;
|
|
11
|
+
readonly type: BlankNodeType | IdentifierType | IriType;
|
|
12
|
+
constructor({ type, ...superParameters }: {
|
|
13
|
+
type: BlankNodeType | IdentifierType | IriType;
|
|
14
|
+
} & ConstructorParameters<typeof ObjectType_AbstractProperty>[0]);
|
|
11
15
|
get constructorParameter(): Maybe<{
|
|
12
16
|
hasQuestionToken: boolean;
|
|
13
17
|
signature: Code;
|
|
14
18
|
}>;
|
|
15
|
-
get declaration(): Code
|
|
19
|
+
get declaration(): Maybe<Code>;
|
|
20
|
+
equalsExpression({ variables, }: Parameters<ObjectType_AbstractProperty["equalsExpression"]>[0]): Maybe<Code>;
|
|
16
21
|
get filterProperty(): Maybe<{
|
|
17
22
|
name: string;
|
|
18
23
|
type: Code;
|
|
19
24
|
}>;
|
|
20
|
-
|
|
21
|
-
get
|
|
22
|
-
get
|
|
25
|
+
filterExpression({ variables, }: Parameters<ObjectType_AbstractProperty["filterExpression"]>[0]): Maybe<Code>;
|
|
26
|
+
get graphqlField(): ObjectType_AbstractProperty["graphqlField"];
|
|
27
|
+
get hashFunctionParameter(): Maybe<Code>;
|
|
28
|
+
get jsonSchema(): ObjectType_AbstractProperty["jsonSchema"];
|
|
23
29
|
get jsonSignature(): Maybe<Code>;
|
|
24
30
|
get schema(): Maybe<Code>;
|
|
25
31
|
get schemaType(): Maybe<Code>;
|
|
26
32
|
private get typeExpression();
|
|
27
33
|
private get typeSchemaVariable();
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
jsonUiSchemaElement({ variables, }: Parameters<ObjectType_AbstractProperty<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
34
|
+
constructorInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["constructorInitializer"]>[0]): Maybe<Code>;
|
|
35
|
+
fromJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["fromJsonInitializer"]>[0]): Maybe<Code>;
|
|
36
|
+
fromRdfResourceValuesInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["fromRdfResourceValuesInitializer"]>[0]): Maybe<Code>;
|
|
37
|
+
hashStatements({ variables, }: Parameters<ObjectType_AbstractProperty["hashStatements"]>[0]): readonly Code[];
|
|
38
|
+
jsonUiSchemaElement({ variables, }: Parameters<ObjectType_AbstractProperty["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
34
39
|
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
35
|
-
sparqlWherePatternsExpression({ variables, }: Parameters<ObjectType_AbstractProperty
|
|
40
|
+
sparqlWherePatternsExpression({ variables, }: Parameters<ObjectType_AbstractProperty["sparqlWherePatternsExpression"]>[0]): Maybe<{
|
|
36
41
|
condition: Code;
|
|
37
42
|
patterns: Code;
|
|
38
43
|
}>;
|
|
39
|
-
toJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty
|
|
44
|
+
toJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["toJsonInitializer"]>[0]): Maybe<Code>;
|
|
40
45
|
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
41
|
-
toStringInitializer(
|
|
46
|
+
toStringInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["toStringInitializer"]>[0]): Maybe<Code>;
|
|
42
47
|
}
|
|
43
48
|
//# sourceMappingURL=ObjectType_IdentifierProperty.d.ts.map
|
|
@@ -15,6 +15,11 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
15
15
|
kind = "Identifier";
|
|
16
16
|
mutable = false;
|
|
17
17
|
recursive = false;
|
|
18
|
+
type;
|
|
19
|
+
constructor({ type, ...superParameters }) {
|
|
20
|
+
super(superParameters);
|
|
21
|
+
this.type = type;
|
|
22
|
+
}
|
|
18
23
|
get constructorParameter() {
|
|
19
24
|
let hasQuestionToken = false;
|
|
20
25
|
const typeExpressions = [code `(() => ${this.typeExpression})`];
|
|
@@ -33,7 +38,14 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
40
|
get declaration() {
|
|
36
|
-
return code `readonly ${this.name}: () => ${this.typeExpression}
|
|
41
|
+
return Maybe.of(code `readonly ${this.name}: () => ${this.typeExpression};`);
|
|
42
|
+
}
|
|
43
|
+
equalsExpression({ variables, }) {
|
|
44
|
+
return Maybe.of(code `${this.reusables.snippets.propertyEquals}(
|
|
45
|
+
{ equalsFunction: ${this.type.equalsFunction}, name: ${literalOf(this.name)} },
|
|
46
|
+
[left, ${variables.leftObject}.${this.name}()],
|
|
47
|
+
[right, ${variables.rightObject}.${this.name}()],
|
|
48
|
+
)`);
|
|
37
49
|
}
|
|
38
50
|
get filterProperty() {
|
|
39
51
|
return Maybe.of({
|
|
@@ -41,6 +53,9 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
41
53
|
type: this.type.filterType,
|
|
42
54
|
});
|
|
43
55
|
}
|
|
56
|
+
filterExpression({ variables, }) {
|
|
57
|
+
return Maybe.of(code `${this.type.filterFunction}(${variables.filter}.${this.name}, ${variables.object}.${this.name}())`);
|
|
58
|
+
}
|
|
44
59
|
get graphqlField() {
|
|
45
60
|
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
46
61
|
invariant(this.name.startsWith(syntheticNamePrefix));
|
|
@@ -48,12 +63,12 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
48
63
|
args: Maybe.empty(),
|
|
49
64
|
description: Maybe.empty(),
|
|
50
65
|
name: `_${this.name.substring(syntheticNamePrefix.length)}`,
|
|
51
|
-
resolve: code `(source) => ${this.type.stringifyFunction}(
|
|
66
|
+
resolve: code `(source) => ${this.type.stringifyFunction}(source.${this.name}())`,
|
|
52
67
|
type: this.type.graphqlType.expression,
|
|
53
68
|
});
|
|
54
69
|
}
|
|
55
70
|
get hashFunctionParameter() {
|
|
56
|
-
return code `readonly ${this.name}?: () => ${this.typeExpression}
|
|
71
|
+
return Maybe.of(code `readonly ${this.name}?: () => ${this.typeExpression};`);
|
|
57
72
|
}
|
|
58
73
|
get jsonSchema() {
|
|
59
74
|
let schema;
|
|
@@ -95,9 +110,6 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
95
110
|
.map((name) => code `${name}.schema.properties.${this.name}.type`)
|
|
96
111
|
.orDefaultLazy(() => this.type.schema);
|
|
97
112
|
}
|
|
98
|
-
accessExpression({ variables, }) {
|
|
99
|
-
return code `${variables.object}.${this.name}()`;
|
|
100
|
-
}
|
|
101
113
|
constructorInitializer({ variables, }) {
|
|
102
114
|
const nodeKinds = this.type.nodeKinds;
|
|
103
115
|
let conversionFunction;
|
|
@@ -131,7 +143,7 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
131
143
|
}
|
|
132
144
|
hashStatements({ variables, }) {
|
|
133
145
|
return [
|
|
134
|
-
code `if (${variables.
|
|
146
|
+
code `if (${variables.object}.${this.name}) { ${variables.hasher}.update(${variables.object}.${this.name}().value); }`,
|
|
135
147
|
];
|
|
136
148
|
}
|
|
137
149
|
jsonUiSchemaElement({ variables, }) {
|
|
@@ -159,9 +171,9 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
159
171
|
const valueToNodeKinds = nodeKinds.map((nodeKind) => {
|
|
160
172
|
switch (nodeKind) {
|
|
161
173
|
case "BlankNode":
|
|
162
|
-
return code `\`_:\${${variables.
|
|
174
|
+
return code `\`_:\${${variables.object}.${this.name}().value}\``;
|
|
163
175
|
case "IRI":
|
|
164
|
-
return code `${variables.
|
|
176
|
+
return code `${variables.object}.${this.name}().value`;
|
|
165
177
|
default:
|
|
166
178
|
throw new RangeError(nodeKind);
|
|
167
179
|
}
|
|
@@ -170,13 +182,13 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
170
182
|
return Maybe.of(code `"@id": ${valueToNodeKinds[0]}`);
|
|
171
183
|
}
|
|
172
184
|
invariant(valueToNodeKinds.length === 2);
|
|
173
|
-
return Maybe.of(code `"@id": ${variables.
|
|
185
|
+
return Maybe.of(code `"@id": ${variables.object}.${this.name}().termType === "${NodeKind.toTermType(nodeKinds[0])}" ? ${valueToNodeKinds[0]} : ${valueToNodeKinds[1]}`);
|
|
174
186
|
}
|
|
175
187
|
toRdfRdfResourceValuesStatements() {
|
|
176
188
|
return [];
|
|
177
189
|
}
|
|
178
|
-
toStringInitializer(
|
|
179
|
-
return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression(
|
|
190
|
+
toStringInitializer({ variables, }) {
|
|
191
|
+
return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression({ variables: { value: code `${variables.object}.${this.name}()` } })}`);
|
|
180
192
|
}
|
|
181
193
|
}
|
|
182
194
|
__decorate([
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Type } from "../Type.js";
|
|
2
2
|
import type { ObjectType_DiscriminantProperty } from "./ObjectType_DiscriminantProperty.js";
|
|
3
3
|
import type { ObjectType_IdentifierProperty } from "./ObjectType_IdentifierProperty.js";
|
|
4
|
+
import type { ObjectType_RdfTypeProperty } from "./ObjectType_RdfTypeProperty.js";
|
|
4
5
|
import type { ObjectType_ShaclProperty } from "./ObjectType_ShaclProperty.js";
|
|
5
|
-
export type ObjectType_Property = ObjectType_IdentifierProperty | ObjectType_ShaclProperty<Type> | ObjectType_DiscriminantProperty;
|
|
6
|
+
export type ObjectType_Property = ObjectType_IdentifierProperty | ObjectType_ShaclProperty<Type> | ObjectType_DiscriminantProperty | ObjectType_RdfTypeProperty;
|
|
6
7
|
//# sourceMappingURL=ObjectType_Property.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
|
|
5
|
+
export declare class ObjectType_RdfTypeProperty extends ObjectType_AbstractProperty {
|
|
6
|
+
readonly constructorParameter: ObjectType_AbstractProperty["constructorParameter"];
|
|
7
|
+
readonly declaration: ObjectType_AbstractProperty["declaration"];
|
|
8
|
+
readonly filterProperty: ObjectType_AbstractProperty["filterProperty"];
|
|
9
|
+
readonly fromRdfType: NamedNode;
|
|
10
|
+
readonly graphqlField: ObjectType_AbstractProperty["graphqlField"];
|
|
11
|
+
readonly hashFunctionParameter: ObjectType_AbstractProperty["hashFunctionParameter"];
|
|
12
|
+
readonly jsonSchema: ObjectType_AbstractProperty["jsonSchema"];
|
|
13
|
+
readonly jsonSignature: ObjectType_AbstractProperty["jsonSignature"];
|
|
14
|
+
readonly kind = "RdfType";
|
|
15
|
+
readonly mutable = false;
|
|
16
|
+
readonly recursive = false;
|
|
17
|
+
readonly toRdfTypes: readonly NamedNode[];
|
|
18
|
+
constructor({ configuration, fromRdfType, toRdfTypes, ...superParameters }: {
|
|
19
|
+
fromRdfType: NamedNode;
|
|
20
|
+
toRdfTypes: readonly NamedNode[];
|
|
21
|
+
} & Omit<ConstructorParameters<typeof ObjectType_AbstractProperty>[0], "name">);
|
|
22
|
+
get schema(): Maybe<Code>;
|
|
23
|
+
get schemaType(): Maybe<Code>;
|
|
24
|
+
constructorInitializer(): Maybe<Code>;
|
|
25
|
+
equalsExpression(): Maybe<Code>;
|
|
26
|
+
filterExpression(): Maybe<Code>;
|
|
27
|
+
fromJsonInitializer(): Maybe<Code>;
|
|
28
|
+
fromRdfResourceValuesInitializer(): Maybe<Code>;
|
|
29
|
+
hashStatements(): readonly Code[];
|
|
30
|
+
jsonUiSchemaElement(): Maybe<Code>;
|
|
31
|
+
sparqlConstructTriplesExpression({ variables, }: Parameters<ObjectType_AbstractProperty["sparqlConstructTriplesExpression"]>[0]): Maybe<Code>;
|
|
32
|
+
sparqlWherePatternsExpression({ variables, }: Parameters<ObjectType_AbstractProperty["sparqlWherePatternsExpression"]>[0]): ReturnType<ObjectType_AbstractProperty["sparqlWherePatternsExpression"]>;
|
|
33
|
+
toJsonInitializer(): Maybe<Code>;
|
|
34
|
+
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
35
|
+
toStringInitializer(): Maybe<Code>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ObjectType_RdfTypeProperty.d.ts.map
|