@shaclmate/compiler 4.0.90 → 4.0.91
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/ObjectType.d.ts +7 -6
- package/dist/generators/ts/ObjectType.js +19 -18
- package/dist/generators/ts/TypeFactory.js +12 -2
- 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/input/input.shaclmate.d.ts +45 -18
- package/dist/input/input.shaclmate.js +54 -32
- package/package.json +4 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { NamedNode } from "@rdfjs/types";
|
|
2
1
|
import { Maybe } from "purify-ts";
|
|
3
2
|
import { ObjectType_DiscriminantProperty } from "./_ObjectType/ObjectType_DiscriminantProperty.js";
|
|
4
3
|
import { ObjectType_IdentifierProperty } from "./_ObjectType/ObjectType_IdentifierProperty.js";
|
|
5
4
|
import type { ObjectType_Property } from "./_ObjectType/ObjectType_Property.js";
|
|
5
|
+
import { ObjectType_RdfTypeProperty } from "./_ObjectType/ObjectType_RdfTypeProperty.js";
|
|
6
6
|
import { ObjectType_ShaclProperty } from "./_ObjectType/ObjectType_ShaclProperty.js";
|
|
7
7
|
import { AbstractType } from "./AbstractType.js";
|
|
8
8
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
@@ -11,10 +11,8 @@ import type { IriType } from "./IriType.js";
|
|
|
11
11
|
import type { Type } from "./Type.js";
|
|
12
12
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
13
13
|
export declare class ObjectType extends AbstractType {
|
|
14
|
-
protected readonly toRdfTypes: readonly NamedNode[];
|
|
15
14
|
readonly discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
|
|
16
15
|
readonly extern: boolean;
|
|
17
|
-
readonly fromRdfType: Maybe<NamedNode>;
|
|
18
16
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
19
17
|
readonly identifierType: BlankNodeType | IdentifierType | IriType;
|
|
20
18
|
readonly jsTypes: readonly [{
|
|
@@ -22,20 +20,20 @@ export declare class ObjectType extends AbstractType {
|
|
|
22
20
|
readonly typeof: "object";
|
|
23
21
|
}];
|
|
24
22
|
readonly kind = "Object";
|
|
23
|
+
readonly rdfTypeProperty: Maybe<ObjectType.RdfTypeProperty>;
|
|
25
24
|
readonly recursive: boolean;
|
|
26
25
|
readonly synthetic: boolean;
|
|
27
26
|
readonly validationFunction: Maybe<Code>;
|
|
28
|
-
constructor({ discriminantProperty, extern,
|
|
27
|
+
constructor({ discriminantProperty, extern, identifierType, lazyProperties, rdfTypeProperty, recursive, synthetic, ...superParameters }: {
|
|
29
28
|
discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
|
|
30
29
|
comment: Maybe<string>;
|
|
31
30
|
extern: boolean;
|
|
32
|
-
fromRdfType: Maybe<NamedNode>;
|
|
33
31
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
34
32
|
label: Maybe<string>;
|
|
35
33
|
lazyProperties: (objectType: ObjectType) => readonly ObjectType.Property[];
|
|
34
|
+
rdfTypeProperty: Maybe<ObjectType.RdfTypeProperty>;
|
|
36
35
|
recursive: boolean;
|
|
37
36
|
synthetic: boolean;
|
|
38
|
-
toRdfTypes: readonly NamedNode[];
|
|
39
37
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
40
38
|
get conversionFunction(): Maybe<AbstractType.ConversionFunction>;
|
|
41
39
|
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
@@ -53,6 +51,7 @@ export declare class ObjectType extends AbstractType {
|
|
|
53
51
|
get properties(): readonly ObjectType.Property[];
|
|
54
52
|
get referencesNamedType(): boolean;
|
|
55
53
|
get schemaExpression(): Code;
|
|
54
|
+
get schemaVariable(): Maybe<Code>;
|
|
56
55
|
get schemaType(): Code;
|
|
57
56
|
get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
|
|
58
57
|
get toRdfjsResourceType(): Code;
|
|
@@ -102,5 +101,7 @@ export declare namespace ObjectType {
|
|
|
102
101
|
type ShaclProperty<TypeT extends Type> = ObjectType_ShaclProperty<TypeT>;
|
|
103
102
|
const DiscriminantProperty: typeof ObjectType_DiscriminantProperty;
|
|
104
103
|
type DiscriminantProperty = ObjectType_DiscriminantProperty;
|
|
104
|
+
const RdfTypeProperty: typeof ObjectType_RdfTypeProperty;
|
|
105
|
+
type RdfTypeProperty = ObjectType_RdfTypeProperty;
|
|
105
106
|
}
|
|
106
107
|
//# sourceMappingURL=ObjectType.d.ts.map
|
|
@@ -27,6 +27,7 @@ import { ObjectType_jsonSchemaExpression } from "./_ObjectType/ObjectType_jsonSc
|
|
|
27
27
|
import { ObjectType_jsonTypeExpression } from "./_ObjectType/ObjectType_jsonTypeExpression.js";
|
|
28
28
|
import { ObjectType_jsonUiSchemaFunctionExpression } from "./_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js";
|
|
29
29
|
import { ObjectType_objectSetMethodNames } from "./_ObjectType/ObjectType_objectSetMethodNames.js";
|
|
30
|
+
import { ObjectType_RdfTypeProperty } from "./_ObjectType/ObjectType_RdfTypeProperty.js";
|
|
30
31
|
import { ObjectType_ShaclProperty } from "./_ObjectType/ObjectType_ShaclProperty.js";
|
|
31
32
|
import { ObjectType_schemaExpression } from "./_ObjectType/ObjectType_schemaExpression.js";
|
|
32
33
|
import { ObjectType_schemaTypeExpression } from "./_ObjectType/ObjectType_schemaTypeExpression.js";
|
|
@@ -42,30 +43,28 @@ import { ObjectType_valueSparqlWherePatternsFunctionExpression } from "./_Object
|
|
|
42
43
|
import { AbstractType } from "./AbstractType.js";
|
|
43
44
|
import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
|
|
44
45
|
export class ObjectType extends AbstractType {
|
|
45
|
-
toRdfTypes;
|
|
46
46
|
discriminantProperty;
|
|
47
47
|
extern;
|
|
48
|
-
fromRdfType;
|
|
49
48
|
graphqlArgs = Maybe.empty();
|
|
50
49
|
identifierType;
|
|
51
50
|
jsTypes = [
|
|
52
51
|
{ instanceof: "Object", typeof: "object" },
|
|
53
52
|
];
|
|
54
53
|
kind = "Object";
|
|
54
|
+
rdfTypeProperty;
|
|
55
55
|
recursive;
|
|
56
56
|
synthetic;
|
|
57
57
|
validationFunction = Maybe.empty();
|
|
58
|
-
constructor({ discriminantProperty, extern,
|
|
58
|
+
constructor({ discriminantProperty, extern, identifierType, lazyProperties, rdfTypeProperty, recursive, synthetic, ...superParameters }) {
|
|
59
59
|
super(superParameters);
|
|
60
60
|
this.discriminantProperty = discriminantProperty;
|
|
61
61
|
this.extern = extern;
|
|
62
|
-
this.fromRdfType = fromRdfType;
|
|
63
62
|
this.identifierType = identifierType;
|
|
64
63
|
// Lazily initialize some members in getters to avoid recursive construction
|
|
65
64
|
this.lazyProperties = lazyProperties;
|
|
65
|
+
this.rdfTypeProperty = rdfTypeProperty;
|
|
66
66
|
this.recursive = recursive;
|
|
67
67
|
this.synthetic = synthetic;
|
|
68
|
-
this.toRdfTypes = toRdfTypes;
|
|
69
68
|
}
|
|
70
69
|
get conversionFunction() {
|
|
71
70
|
if (this.name.isJust()) {
|
|
@@ -260,9 +259,9 @@ export class ObjectType extends AbstractType {
|
|
|
260
259
|
.orDefaultLazy(() => code `((values, options) => values.chainMap(value => value.toResource().chain(resource => ${ObjectType_fromRdfResourceFunctionExpression.call(this)}(resource, options))))`);
|
|
261
260
|
}
|
|
262
261
|
get fromRdfTypeVariable() {
|
|
263
|
-
return this.
|
|
264
|
-
.map((name) => code `${name}.schema.fromRdfType`)
|
|
265
|
-
.orDefaultLazy(() => this.rdfjsTermExpression(fromRdfType)));
|
|
262
|
+
return this.rdfTypeProperty.map((rdfTypeProperty) => this.name
|
|
263
|
+
.map((name) => code `${name}.schema.properties.${rdfTypeProperty.name}.fromRdfType`)
|
|
264
|
+
.orDefaultLazy(() => this.rdfjsTermExpression(rdfTypeProperty.fromRdfType)));
|
|
266
265
|
}
|
|
267
266
|
get graphqlType() {
|
|
268
267
|
return new AbstractType.GraphqlType(this.name
|
|
@@ -306,6 +305,9 @@ export class ObjectType extends AbstractType {
|
|
|
306
305
|
get schemaExpression() {
|
|
307
306
|
return ObjectType_schemaExpression.call(this);
|
|
308
307
|
}
|
|
308
|
+
get schemaVariable() {
|
|
309
|
+
return this.name.map((name) => code `${name}.schema`);
|
|
310
|
+
}
|
|
309
311
|
get schemaType() {
|
|
310
312
|
return this.name
|
|
311
313
|
.map((name) => code `${name}.Schema`)
|
|
@@ -369,12 +371,9 @@ export class ObjectType extends AbstractType {
|
|
|
369
371
|
.orDefaultLazy(() => ObjectType_toJsonFunctionExpression.call(this));
|
|
370
372
|
}
|
|
371
373
|
get toRdfTypesVariable() {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return Maybe.of(this.name
|
|
376
|
-
.map((name) => code `${name}.schema.toRdfTypes`)
|
|
377
|
-
.orDefaultLazy(() => code `${arrayOf(...this.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)))}`));
|
|
374
|
+
return this.rdfTypeProperty.map((rdfTypeProperty) => this.schemaVariable
|
|
375
|
+
.map((schemaVariable) => code `${schemaVariable}.properties.${rdfTypeProperty.name}.toRdfTypes`)
|
|
376
|
+
.orDefaultLazy(() => code `${arrayOf(...rdfTypeProperty.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)))}`));
|
|
378
377
|
}
|
|
379
378
|
get toStringFunction() {
|
|
380
379
|
return this.name
|
|
@@ -382,7 +381,7 @@ export class ObjectType extends AbstractType {
|
|
|
382
381
|
.orDefaultLazy(() => ObjectType_toStringFunctionExpression.call(this));
|
|
383
382
|
}
|
|
384
383
|
get inlineExpression() {
|
|
385
|
-
return code `{ ${joinCode(this.properties.
|
|
384
|
+
return code `{ ${joinCode(this.properties.flatMap((property) => property.declaration.toList()), { on: "\n\n" })} }`;
|
|
386
385
|
}
|
|
387
386
|
fromJsonExpression({ variables, }) {
|
|
388
387
|
// Assumes the JSON object has been recursively validated already.
|
|
@@ -434,9 +433,7 @@ export class ObjectType extends AbstractType {
|
|
|
434
433
|
return code `${this.reusables.snippets.compactRecord}({${joinCode(this.properties.flatMap((property) => property
|
|
435
434
|
.toStringInitializer({
|
|
436
435
|
variables: {
|
|
437
|
-
|
|
438
|
-
variables: { object: variables.value },
|
|
439
|
-
}),
|
|
436
|
+
object: variables.value,
|
|
440
437
|
},
|
|
441
438
|
})
|
|
442
439
|
.toList()), { on: "," })}})`;
|
|
@@ -485,6 +482,9 @@ __decorate([
|
|
|
485
482
|
__decorate([
|
|
486
483
|
Memoize()
|
|
487
484
|
], ObjectType.prototype, "schemaExpression", null);
|
|
485
|
+
__decorate([
|
|
486
|
+
Memoize()
|
|
487
|
+
], ObjectType.prototype, "schemaVariable", null);
|
|
488
488
|
__decorate([
|
|
489
489
|
Memoize()
|
|
490
490
|
], ObjectType.prototype, "schemaType", null);
|
|
@@ -528,5 +528,6 @@ __decorate([
|
|
|
528
528
|
ObjectType.IdentifierProperty = ObjectType_IdentifierProperty;
|
|
529
529
|
ObjectType.ShaclProperty = ObjectType_ShaclProperty;
|
|
530
530
|
ObjectType.DiscriminantProperty = ObjectType_DiscriminantProperty;
|
|
531
|
+
ObjectType.RdfTypeProperty = ObjectType_RdfTypeProperty;
|
|
531
532
|
})(ObjectType || (ObjectType = {}));
|
|
532
533
|
//# sourceMappingURL=ObjectType.js.map
|
|
@@ -56,13 +56,20 @@ export class TypeFactory {
|
|
|
56
56
|
reusables: this.reusables,
|
|
57
57
|
value: name,
|
|
58
58
|
}));
|
|
59
|
+
const rdfTypeProperty = astType.fromRdfType.map((fromRdfType) => new ObjectType.RdfTypeProperty({
|
|
60
|
+
configuration: this.configuration,
|
|
61
|
+
fromRdfType,
|
|
62
|
+
logger: this.logger,
|
|
63
|
+
objectType: { name: astType.name },
|
|
64
|
+
reusables: this.reusables,
|
|
65
|
+
toRdfTypes: astType.toRdfTypes,
|
|
66
|
+
}));
|
|
59
67
|
const identifierType = this.createIdentifierType(astType.identifierType);
|
|
60
68
|
const objectType = new ObjectType({
|
|
61
69
|
discriminantProperty,
|
|
62
70
|
comment: astType.comment,
|
|
63
71
|
configuration: this.configuration,
|
|
64
72
|
extern: astType.extern,
|
|
65
|
-
fromRdfType: astType.fromRdfType,
|
|
66
73
|
identifierType,
|
|
67
74
|
label: astType.label,
|
|
68
75
|
lazyProperties: (objectType) => {
|
|
@@ -83,6 +90,9 @@ export class TypeFactory {
|
|
|
83
90
|
discriminantProperty.ifJust((discriminantProperty) => {
|
|
84
91
|
properties.splice(0, 0, discriminantProperty);
|
|
85
92
|
});
|
|
93
|
+
rdfTypeProperty.ifJust((rdfTypeProperty) => {
|
|
94
|
+
properties.splice(0, 0, rdfTypeProperty);
|
|
95
|
+
});
|
|
86
96
|
properties.splice(0, 0, new ObjectType.IdentifierProperty({
|
|
87
97
|
configuration: this.configuration,
|
|
88
98
|
logger: this.logger,
|
|
@@ -95,11 +105,11 @@ export class TypeFactory {
|
|
|
95
105
|
},
|
|
96
106
|
logger: this.logger,
|
|
97
107
|
name: astType.name.map((name) => this.tsName(name, { synthetic: astType.synthetic })),
|
|
108
|
+
rdfTypeProperty,
|
|
98
109
|
recursive: astType.recursive,
|
|
99
110
|
reusables: this.reusables,
|
|
100
111
|
shapeIdentifier: astType.shapeIdentifier,
|
|
101
112
|
synthetic: astType.synthetic,
|
|
102
|
-
toRdfTypes: astType.toRdfTypes,
|
|
103
113
|
});
|
|
104
114
|
this.cachedObjectTypesByShapeIdentifier.set(astType.shapeIdentifier, objectType);
|
|
105
115
|
return objectType;
|
|
@@ -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
|