@shaclmate/compiler 4.0.69 → 4.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generators/ts/AbstractCollectionType.d.ts +1 -1
- package/dist/generators/ts/AbstractCollectionType.js +6 -6
- package/dist/generators/ts/AbstractContainerType.d.ts +0 -2
- package/dist/generators/ts/AbstractContainerType.js +0 -2
- package/dist/generators/ts/AbstractLazyType.d.ts +1 -2
- package/dist/generators/ts/AbstractLazyType.js +1 -2
- package/dist/generators/ts/AbstractLiteralType.d.ts +0 -7
- package/dist/generators/ts/AbstractPrimitiveType.js +19 -6
- package/dist/generators/ts/AbstractTermType.d.ts +6 -3
- package/dist/generators/ts/AbstractTermType.js +11 -16
- package/dist/generators/ts/AbstractType.d.ts +11 -9
- package/dist/generators/ts/AbstractType.js +51 -2
- package/dist/generators/ts/AbstractTypedLiteralType.d.ts +3 -6
- package/dist/generators/ts/AbstractTypedLiteralType.js +1 -11
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigDecimalType.js +1 -1
- package/dist/generators/ts/BigIntType.d.ts +2 -1
- package/dist/generators/ts/BigIntType.js +11 -5
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.js +1 -1
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +1 -1
- package/dist/generators/ts/DefaultValueType.js +4 -4
- package/dist/generators/ts/DiscriminatedUnionType.d.ts +2 -4
- package/dist/generators/ts/DiscriminatedUnionType.js +20 -56
- package/dist/generators/ts/FloatType.d.ts +1 -1
- package/dist/generators/ts/FloatType.js +1 -1
- package/dist/generators/ts/IntType.d.ts +1 -1
- package/dist/generators/ts/IntType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +2 -0
- package/dist/generators/ts/IriType.js +43 -11
- package/dist/generators/ts/LangStringType.d.ts +1 -1
- package/dist/generators/ts/LangStringType.js +1 -4
- package/dist/generators/ts/LiteralType.d.ts +1 -1
- package/dist/generators/ts/LiteralType.js +1 -4
- package/dist/generators/ts/ObjectDiscriminatedUnionType.d.ts +1 -2
- package/dist/generators/ts/ObjectDiscriminatedUnionType.js +2 -11
- package/dist/generators/ts/ObjectType.d.ts +3 -3
- package/dist/generators/ts/ObjectType.js +134 -124
- package/dist/generators/ts/OptionType.d.ts +1 -1
- package/dist/generators/ts/OptionType.js +6 -6
- package/dist/generators/ts/StringType.d.ts +1 -1
- package/dist/generators/ts/StringType.js +10 -3
- package/dist/generators/ts/TypeFactory.js +7 -29
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.js +4 -5
- package/package.json +8 -8
|
@@ -35,9 +35,6 @@ export class DefaultValueType extends AbstractContainerType {
|
|
|
35
35
|
get equalsFunction() {
|
|
36
36
|
return this.itemType.equalsFunction;
|
|
37
37
|
}
|
|
38
|
-
get expression() {
|
|
39
|
-
return this.itemType.expression;
|
|
40
|
-
}
|
|
41
38
|
get filterFunction() {
|
|
42
39
|
return this.itemType.filterFunction;
|
|
43
40
|
}
|
|
@@ -68,6 +65,9 @@ export class DefaultValueType extends AbstractContainerType {
|
|
|
68
65
|
get valueSparqlWherePatternsFunction() {
|
|
69
66
|
return code `${this.reusables.snippets.defaultValueSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
|
|
70
67
|
}
|
|
68
|
+
get inlineExpression() {
|
|
69
|
+
return this.itemType.expression;
|
|
70
|
+
}
|
|
71
71
|
get schemaInitializers() {
|
|
72
72
|
return super.schemaInitializers.concat(code `defaultValue: ${this.rdfjsTermExpression(this.defaultValue)}`);
|
|
73
73
|
}
|
|
@@ -85,7 +85,7 @@ export class DefaultValueType extends AbstractContainerType {
|
|
|
85
85
|
throw new RangeError(`not implemented ${this.itemType.kind}`);
|
|
86
86
|
}
|
|
87
87
|
invariant(this.defaultValue.termType === "Literal");
|
|
88
|
-
return this.itemType.
|
|
88
|
+
return this.itemType.valueExpression(this.defaultValue);
|
|
89
89
|
}
|
|
90
90
|
fromJsonExpression(parameters) {
|
|
91
91
|
return this.itemType.fromJsonExpression(parameters);
|
|
@@ -22,10 +22,9 @@ export declare class DiscriminatedUnionType<MemberTypeT extends Type> extends Ab
|
|
|
22
22
|
synthetic: boolean;
|
|
23
23
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
24
24
|
get conversionFunction(): Maybe<AbstractType.ConversionFunction>;
|
|
25
|
-
get declaration(): Maybe<Code>;
|
|
26
25
|
get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
|
|
27
26
|
get equalsFunction(): Code;
|
|
28
|
-
get
|
|
27
|
+
protected get inlineExpression(): Code;
|
|
29
28
|
get filterFunction(): Code;
|
|
30
29
|
get filterType(): Code;
|
|
31
30
|
get fromRdfResourceValuesFunction(): Code;
|
|
@@ -37,13 +36,12 @@ export declare class DiscriminatedUnionType<MemberTypeT extends Type> extends Ab
|
|
|
37
36
|
get members(): readonly DiscriminatedUnionType.Member<MemberTypeT>[];
|
|
38
37
|
get mutable(): boolean;
|
|
39
38
|
get referencesNamedType(): boolean;
|
|
40
|
-
get schema(): Code;
|
|
41
39
|
get schemaType(): Code;
|
|
42
40
|
get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
|
|
43
41
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
44
42
|
get valueSparqlWherePatternsFunction(): Code;
|
|
45
43
|
protected get schemaInitializers(): readonly Code[];
|
|
46
|
-
protected
|
|
44
|
+
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
47
45
|
fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
|
|
48
46
|
graphqlResolveExpression({ variables, }: {
|
|
49
47
|
variables: {
|
|
@@ -24,7 +24,7 @@ import { DiscriminatedUnionType_toStringFunctionExpression } from "./_Discrimina
|
|
|
24
24
|
import { DiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression } from "./_DiscriminatedUnionType/DiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.js";
|
|
25
25
|
import { DiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression } from "./_DiscriminatedUnionType/DiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.js";
|
|
26
26
|
import { AbstractType } from "./AbstractType.js";
|
|
27
|
-
import { code,
|
|
27
|
+
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
28
28
|
export class DiscriminatedUnionType extends AbstractType {
|
|
29
29
|
discriminant;
|
|
30
30
|
graphqlArgs = Maybe.empty();
|
|
@@ -143,26 +143,6 @@ export class DiscriminatedUnionType extends AbstractType {
|
|
|
143
143
|
],
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
|
-
get declaration() {
|
|
147
|
-
const name = this.name.extract();
|
|
148
|
-
if (!name) {
|
|
149
|
-
return Maybe.empty();
|
|
150
|
-
}
|
|
151
|
-
const declarations = [];
|
|
152
|
-
if (this.configuration.features.has("Object.type")) {
|
|
153
|
-
declarations.push(code `export type ${def(name)} = ${DiscriminatedUnionType_inlineExpression.call(this)};`);
|
|
154
|
-
}
|
|
155
|
-
const staticModuleDeclarations = Object.entries(this.staticModuleDeclarations);
|
|
156
|
-
if (staticModuleDeclarations.length > 0) {
|
|
157
|
-
declarations.push(code `\
|
|
158
|
-
export namespace ${def(name)} {
|
|
159
|
-
${joinCode(staticModuleDeclarations
|
|
160
|
-
.sort((left, right) => left[0].localeCompare(right[0]))
|
|
161
|
-
.map((_) => _[1]), { on: "\n\n" })}
|
|
162
|
-
}`);
|
|
163
|
-
}
|
|
164
|
-
return Maybe.of(joinCode(declarations, { on: "\n\n" }));
|
|
165
|
-
}
|
|
166
146
|
get discriminantProperty() {
|
|
167
147
|
switch (this.discriminant.kind) {
|
|
168
148
|
case "Extrinsic":
|
|
@@ -194,10 +174,8 @@ ${joinCode(staticModuleDeclarations
|
|
|
194
174
|
.map((name) => code `${name}.equals`)
|
|
195
175
|
.orDefault(DiscriminatedUnionType_equalsFunctionExpression.call(this));
|
|
196
176
|
}
|
|
197
|
-
get
|
|
198
|
-
return this
|
|
199
|
-
.map((name) => code `${name}`)
|
|
200
|
-
.orDefault(DiscriminatedUnionType_inlineExpression.call(this));
|
|
177
|
+
get inlineExpression() {
|
|
178
|
+
return DiscriminatedUnionType_inlineExpression.call(this);
|
|
201
179
|
}
|
|
202
180
|
get filterFunction() {
|
|
203
181
|
return this.name
|
|
@@ -267,11 +245,6 @@ ${joinCode(staticModuleDeclarations
|
|
|
267
245
|
return (this.name.isJust() ||
|
|
268
246
|
this.members.some((member) => member.type.referencesNamedType));
|
|
269
247
|
}
|
|
270
|
-
get schema() {
|
|
271
|
-
return this.name
|
|
272
|
-
.map((name) => code `${name}.schema`)
|
|
273
|
-
.orDefault(this.schemaExpression);
|
|
274
|
-
}
|
|
275
248
|
get schemaType() {
|
|
276
249
|
return this.name
|
|
277
250
|
.map(() => code `typeof ${this.schema}`)
|
|
@@ -302,29 +275,30 @@ ${joinCode(staticModuleDeclarations
|
|
|
302
275
|
type: type.schema,
|
|
303
276
|
}}`), { on: "," })} }`);
|
|
304
277
|
}
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
278
|
+
staticModuleDeclarations(name) {
|
|
279
|
+
const staticModuleDeclarations = {
|
|
280
|
+
...super.staticModuleDeclarations(name),
|
|
281
|
+
};
|
|
308
282
|
if (this.configuration.features.has("Object.equals")) {
|
|
309
|
-
staticModuleDeclarations[
|
|
283
|
+
staticModuleDeclarations["equals"] =
|
|
310
284
|
code `export const equals = ${DiscriminatedUnionType_equalsFunctionExpression.call(this)};`;
|
|
311
285
|
}
|
|
312
286
|
if (this.configuration.features.has("Object.filter")) {
|
|
313
|
-
staticModuleDeclarations[
|
|
287
|
+
staticModuleDeclarations["Filter"] =
|
|
314
288
|
code `export type Filter = ${DiscriminatedUnionType_filterTypeExpression.call(this)};`;
|
|
315
|
-
staticModuleDeclarations[
|
|
289
|
+
staticModuleDeclarations["filter"] =
|
|
316
290
|
code `export const filter = ${DiscriminatedUnionType_filterFunctionExpression.call(this)};`;
|
|
317
291
|
}
|
|
318
292
|
if (this.configuration.features.has("Object.hash")) {
|
|
319
|
-
staticModuleDeclarations[
|
|
293
|
+
staticModuleDeclarations["hash"] =
|
|
320
294
|
code `export const hash = ${DiscriminatedUnionType_hashFunctionExpression.call(this)};`;
|
|
321
295
|
}
|
|
322
296
|
if (this.configuration.features.has("Object.JSON.type")) {
|
|
323
|
-
staticModuleDeclarations[
|
|
297
|
+
staticModuleDeclarations["Json.type"] =
|
|
324
298
|
code `${this.jsonTypeAliasDeclaration}`;
|
|
325
299
|
}
|
|
326
300
|
if (this.configuration.features.has("Object.JSON.schema")) {
|
|
327
|
-
staticModuleDeclarations[
|
|
301
|
+
staticModuleDeclarations["Json.namespace"] = code `\
|
|
328
302
|
export namespace Json {
|
|
329
303
|
${this.jsonSchemaFunctionDeclaration}
|
|
330
304
|
|
|
@@ -336,29 +310,25 @@ export namespace Json {
|
|
|
336
310
|
}`;
|
|
337
311
|
}
|
|
338
312
|
if (this.configuration.features.has("Object.fromJson")) {
|
|
339
|
-
staticModuleDeclarations[
|
|
313
|
+
staticModuleDeclarations["fromJson"] =
|
|
340
314
|
code `export const fromJson = ${DiscriminatedUnionType_fromJsonFunctionExpression.call(this)};`;
|
|
341
315
|
}
|
|
342
316
|
if (this.configuration.features.has("Object.fromRdf")) {
|
|
343
|
-
staticModuleDeclarations[
|
|
317
|
+
staticModuleDeclarations["fromRdfResourceValues"] =
|
|
344
318
|
code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${name}, ${this.schemaType}> = ${DiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.call(this)};`;
|
|
345
319
|
}
|
|
346
|
-
if (this.configuration.features.has("Object.schema")) {
|
|
347
|
-
staticModuleDeclarations["schema"] =
|
|
348
|
-
code `export const schema = ${this.schemaExpression}`;
|
|
349
|
-
}
|
|
350
320
|
if (this.configuration.features.has("Object.toJson")) {
|
|
351
|
-
staticModuleDeclarations[
|
|
321
|
+
staticModuleDeclarations["toJson"] =
|
|
352
322
|
code `export const toJson = ${DiscriminatedUnionType_toJsonFunctionExpression.call(this)};`;
|
|
353
323
|
}
|
|
354
324
|
if (this.configuration.features.has("Object.toRdf")) {
|
|
355
|
-
staticModuleDeclarations[
|
|
325
|
+
staticModuleDeclarations["toRdfResourceValues"] =
|
|
356
326
|
code `export const toRdfResourceValues = ${DiscriminatedUnionType_toRdfResourceValuesFunctionExpression.call(this)};`;
|
|
357
327
|
}
|
|
358
328
|
if (this.configuration.features.has("Object.SPARQL")) {
|
|
359
|
-
staticModuleDeclarations[
|
|
329
|
+
staticModuleDeclarations["valueSparqlConstructTriples"] =
|
|
360
330
|
code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${DiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.call(this)};`;
|
|
361
|
-
staticModuleDeclarations[
|
|
331
|
+
staticModuleDeclarations["valueSparqlWherePatterns"] =
|
|
362
332
|
code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${DiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.call(this)};`;
|
|
363
333
|
}
|
|
364
334
|
if (this.configuration.features.has("Object.toString")) {
|
|
@@ -406,9 +376,6 @@ export namespace Json {
|
|
|
406
376
|
__decorate([
|
|
407
377
|
Memoize()
|
|
408
378
|
], DiscriminatedUnionType.prototype, "conversionFunction", null);
|
|
409
|
-
__decorate([
|
|
410
|
-
Memoize()
|
|
411
|
-
], DiscriminatedUnionType.prototype, "declaration", null);
|
|
412
379
|
__decorate([
|
|
413
380
|
Memoize()
|
|
414
381
|
], DiscriminatedUnionType.prototype, "discriminantProperty", null);
|
|
@@ -417,7 +384,7 @@ __decorate([
|
|
|
417
384
|
], DiscriminatedUnionType.prototype, "equalsFunction", null);
|
|
418
385
|
__decorate([
|
|
419
386
|
Memoize()
|
|
420
|
-
], DiscriminatedUnionType.prototype, "
|
|
387
|
+
], DiscriminatedUnionType.prototype, "inlineExpression", null);
|
|
421
388
|
__decorate([
|
|
422
389
|
Memoize()
|
|
423
390
|
], DiscriminatedUnionType.prototype, "filterFunction", null);
|
|
@@ -442,9 +409,6 @@ __decorate([
|
|
|
442
409
|
__decorate([
|
|
443
410
|
Memoize()
|
|
444
411
|
], DiscriminatedUnionType.prototype, "mutable", null);
|
|
445
|
-
__decorate([
|
|
446
|
-
Memoize()
|
|
447
|
-
], DiscriminatedUnionType.prototype, "schema", null);
|
|
448
412
|
__decorate([
|
|
449
413
|
Memoize()
|
|
450
414
|
], DiscriminatedUnionType.prototype, "schemaType", null);
|
|
@@ -8,6 +8,6 @@ export declare class FloatType extends AbstractNumericType<number> {
|
|
|
8
8
|
readonly kind = "Float";
|
|
9
9
|
get fromRdfResourceValuesFunction(): Code;
|
|
10
10
|
get graphqlType(): import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
11
|
-
|
|
11
|
+
valueExpression(literal: Literal | number): Code;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=FloatType.d.ts.map
|
|
@@ -17,7 +17,7 @@ export class FloatType extends AbstractNumericType {
|
|
|
17
17
|
get graphqlType() {
|
|
18
18
|
return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLFloat}`, this.reusables);
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
valueExpression(literal) {
|
|
21
21
|
return code `${typeof literal === "number" ? literal : LiteralDecoder.decodeFloatLiteral(literal).unsafeCoerce()}`;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -8,6 +8,6 @@ export declare class IntType extends AbstractNumericType<number> {
|
|
|
8
8
|
readonly kind = "Int";
|
|
9
9
|
get fromRdfResourceValuesFunction(): Code;
|
|
10
10
|
get graphqlType(): import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
11
|
-
|
|
11
|
+
valueExpression(literal: Literal | number): Code;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=IntType.d.ts.map
|
|
@@ -17,7 +17,7 @@ export class IntType extends AbstractNumericType {
|
|
|
17
17
|
get graphqlType() {
|
|
18
18
|
return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLInt}`, this.reusables);
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
valueExpression(literal) {
|
|
21
21
|
return code `${typeof literal === "number" ? literal : LiteralDecoder.decodeIntLiteral(literal).unsafeCoerce()}`;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -13,7 +13,9 @@ export declare class IriType extends AbstractIdentifierType<NamedNode> {
|
|
|
13
13
|
get fromRdfResourceValuesFunction(): Code;
|
|
14
14
|
get parseFunction(): Code;
|
|
15
15
|
protected get inlineExpression(): Code;
|
|
16
|
+
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
16
17
|
protected get schemaInitializers(): readonly Code[];
|
|
18
|
+
protected get inlineValueTypeExpression(): Code;
|
|
17
19
|
private get valueTypeExpression();
|
|
18
20
|
fromJsonExpression({ variables, }: Parameters<AbstractIdentifierType<NamedNode>["fromJsonExpression"]>[0]): Code;
|
|
19
21
|
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractIdentifierType<NamedNode>["jsonSchema"]>[0]): Code;
|
|
@@ -8,7 +8,7 @@ import { Maybe } from "purify-ts";
|
|
|
8
8
|
import { invariant } from "ts-invariant";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
|
|
11
|
-
import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
|
|
11
|
+
import { arrayOf, code, joinCode, literalOf, } from "./ts-poet-wrapper.js";
|
|
12
12
|
export class IriType extends AbstractIdentifierType {
|
|
13
13
|
filterFunction = code `${this.reusables.snippets.filterIri}`;
|
|
14
14
|
filterType = code `${this.reusables.snippets.IriFilter}`;
|
|
@@ -43,21 +43,45 @@ export class IriType extends AbstractIdentifierType {
|
|
|
43
43
|
}
|
|
44
44
|
get inlineExpression() {
|
|
45
45
|
if (this.in_.length > 0) {
|
|
46
|
-
return code `${this.reusables.imports.NamedNode}<${this.
|
|
46
|
+
return code `${this.reusables.imports.NamedNode}<${this.inlineValueTypeExpression}>`;
|
|
47
47
|
}
|
|
48
48
|
return code `${this.reusables.imports.NamedNode}`;
|
|
49
49
|
}
|
|
50
|
+
staticModuleDeclarations(name) {
|
|
51
|
+
if (this.in_.length === 0) {
|
|
52
|
+
return super.staticModuleDeclarations(name);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
...super.staticModuleDeclarations(name),
|
|
56
|
+
inValues: code `const inValues = ${arrayOf(...this.in_.map((in_) => in_.value))} as const;`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
50
59
|
get schemaInitializers() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
initializers = initializers.concat(code `in: ${arrayOf(...this.in_.map((in_) => this.rdfjsTermExpression(in_)))}`);
|
|
60
|
+
if (this.in_.length === 0 || this.name.isNothing()) {
|
|
61
|
+
return super.schemaInitializers;
|
|
54
62
|
}
|
|
63
|
+
let initializers = [code `kind: ${literalOf(this.kind)} as const`];
|
|
64
|
+
if (this.hasValues.length > 0) {
|
|
65
|
+
initializers = initializers.concat(code `hasValues: ${arrayOf(...this.hasValues.map((hasValue) => this.rdfjsTermExpression(hasValue)))}`);
|
|
66
|
+
}
|
|
67
|
+
initializers = initializers.concat(code `in: inValues.map(inValue => ${this.reusables.imports.dataFactory}.namedNode(inValue))`, code `inValues`);
|
|
55
68
|
return initializers;
|
|
56
69
|
}
|
|
70
|
+
get inlineValueTypeExpression() {
|
|
71
|
+
if (this.in_.length === 0) {
|
|
72
|
+
return code `string`;
|
|
73
|
+
}
|
|
74
|
+
const name = this.name.extract();
|
|
75
|
+
if (name && this.configuration.features.has("Object.schema")) {
|
|
76
|
+
// Reuse the type from schema to cut down code
|
|
77
|
+
return code `(typeof ${name}.schema)["inValues"][number]`;
|
|
78
|
+
}
|
|
79
|
+
return code `(${this.in_.map((in_) => `"${in_.value}"`).join(" | ")})`;
|
|
80
|
+
}
|
|
57
81
|
get valueTypeExpression() {
|
|
58
|
-
return this.
|
|
59
|
-
|
|
60
|
-
|
|
82
|
+
return this.name
|
|
83
|
+
.map((name) => code `${name}["value"]`)
|
|
84
|
+
.orDefaultLazy(() => this.inlineValueTypeExpression);
|
|
61
85
|
}
|
|
62
86
|
fromJsonExpression({ variables, }) {
|
|
63
87
|
return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"]))`;
|
|
@@ -65,9 +89,14 @@ export class IriType extends AbstractIdentifierType {
|
|
|
65
89
|
jsonSchema({ includeDiscriminantProperty, }) {
|
|
66
90
|
let idSchema;
|
|
67
91
|
if (this.in_.length > 0) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
92
|
+
const name = this.name.extract();
|
|
93
|
+
if (name && this.configuration.features.has("Object.schema")) {
|
|
94
|
+
// Reuse the type from schema to cut down code
|
|
95
|
+
idSchema = code `${this.reusables.imports.z}.enum(${name}.schema.in.map(_ => _.value))`;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
idSchema = code `${this.reusables.imports.z}.enum(${arrayOf(...this.in_.map((iri) => iri.value))})`;
|
|
99
|
+
}
|
|
71
100
|
}
|
|
72
101
|
else {
|
|
73
102
|
idSchema = code `${this.reusables.imports.z}.string().min(1)`;
|
|
@@ -102,6 +131,9 @@ __decorate([
|
|
|
102
131
|
__decorate([
|
|
103
132
|
Memoize()
|
|
104
133
|
], IriType.prototype, "inlineExpression", null);
|
|
134
|
+
__decorate([
|
|
135
|
+
Memoize()
|
|
136
|
+
], IriType.prototype, "inlineValueTypeExpression", null);
|
|
105
137
|
__decorate([
|
|
106
138
|
Memoize()
|
|
107
139
|
], IriType.prototype, "valueTypeExpression", null);
|
|
@@ -25,7 +25,7 @@ export declare class LangStringType extends AbstractLiteralType {
|
|
|
25
25
|
graphqlResolveExpression(_parameters: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
26
26
|
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractLiteralType["jsonSchema"]>[0]): Code;
|
|
27
27
|
jsonType(parameters?: Parameters<AbstractLiteralType["jsonType"]>[0]): AbstractLiteralType.JsonType;
|
|
28
|
-
|
|
28
|
+
valueExpression(literal: Literal): Code;
|
|
29
29
|
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=LangStringType.d.ts.map
|
|
@@ -31,9 +31,6 @@ export class LangStringType extends AbstractLiteralType {
|
|
|
31
31
|
}
|
|
32
32
|
get schemaInitializers() {
|
|
33
33
|
let initializers = super.schemaInitializers;
|
|
34
|
-
if (this.in_.length > 0) {
|
|
35
|
-
initializers = initializers.concat(code `in: ${arrayOf(...this.in_.map((in_) => this.rdfjsTermExpression(in_)))}`);
|
|
36
|
-
}
|
|
37
34
|
if (this.languageIn.length > 0) {
|
|
38
35
|
initializers = initializers.concat(code `languageIn: ${arrayOf(...this.languageIn)}`);
|
|
39
36
|
}
|
|
@@ -57,7 +54,7 @@ export class LangStringType extends AbstractLiteralType {
|
|
|
57
54
|
: "";
|
|
58
55
|
return new AbstractLiteralType.JsonType(code `{ readonly "@language": string${discriminantProperty}, readonly "@value": string }`);
|
|
59
56
|
}
|
|
60
|
-
|
|
57
|
+
valueExpression(literal) {
|
|
61
58
|
return this.rdfjsTermExpression(literal);
|
|
62
59
|
}
|
|
63
60
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
@@ -25,7 +25,7 @@ export declare class LiteralType extends AbstractLiteralType {
|
|
|
25
25
|
graphqlResolveExpression(_parameters: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
26
26
|
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractLiteralType["jsonSchema"]>[0]): Code;
|
|
27
27
|
jsonType(parameters?: Parameters<AbstractLiteralType["jsonType"]>[0]): AbstractLiteralType.JsonType;
|
|
28
|
-
|
|
28
|
+
valueExpression(literal: Literal): Code;
|
|
29
29
|
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=LiteralType.d.ts.map
|
|
@@ -40,9 +40,6 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
40
40
|
}
|
|
41
41
|
get schemaInitializers() {
|
|
42
42
|
let initializers = super.schemaInitializers;
|
|
43
|
-
if (this.in_.length > 0) {
|
|
44
|
-
initializers = initializers.concat(code `in: ${arrayOf(...this.in_.map((in_) => this.rdfjsTermExpression(in_)))}`);
|
|
45
|
-
}
|
|
46
43
|
if (this.languageIn.length > 0) {
|
|
47
44
|
initializers = initializers.concat(code `languageIn: ${arrayOf(...this.languageIn)}`);
|
|
48
45
|
}
|
|
@@ -66,7 +63,7 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
66
63
|
: "";
|
|
67
64
|
return new AbstractLiteralType.JsonType(code `{ readonly "@language"?: string${discriminantProperty}, readonly "@type"?: string, readonly "@value": string }`);
|
|
68
65
|
}
|
|
69
|
-
|
|
66
|
+
valueExpression(literal) {
|
|
70
67
|
return this.rdfjsTermExpression(literal);
|
|
71
68
|
}
|
|
72
69
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
@@ -6,9 +6,8 @@ export declare class ObjectDiscriminatedUnionType extends DiscriminatedUnionType
|
|
|
6
6
|
readonly kind = "ObjectDiscriminatedUnion";
|
|
7
7
|
get identifierTypeAlias(): Code;
|
|
8
8
|
get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
|
|
9
|
-
get schema(): Code;
|
|
10
9
|
get schemaType(): Code;
|
|
11
10
|
get typeGuardFunction(): Maybe<Code>;
|
|
12
|
-
protected
|
|
11
|
+
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=ObjectDiscriminatedUnionType.d.ts.map
|
|
@@ -33,11 +33,6 @@ export class ObjectDiscriminatedUnionType extends DiscriminatedUnionType {
|
|
|
33
33
|
}))
|
|
34
34
|
.unsafeCoerce();
|
|
35
35
|
}
|
|
36
|
-
get schema() {
|
|
37
|
-
return this.name
|
|
38
|
-
.map((name) => code `${name}.schema`)
|
|
39
|
-
.orDefault(super.schema);
|
|
40
|
-
}
|
|
41
36
|
get schemaType() {
|
|
42
37
|
return this.name
|
|
43
38
|
.map(() => code `typeof ${this.schema}`)
|
|
@@ -49,10 +44,9 @@ export class ObjectDiscriminatedUnionType extends DiscriminatedUnionType {
|
|
|
49
44
|
}
|
|
50
45
|
return this.name.map((name) => code `${name}.is${name}`);
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
const name = this.name.unsafeCoerce();
|
|
47
|
+
staticModuleDeclarations(name) {
|
|
54
48
|
return {
|
|
55
|
-
...super.staticModuleDeclarations,
|
|
49
|
+
...super.staticModuleDeclarations(name),
|
|
56
50
|
...ObjectDiscriminatedUnionType_identifierTypeDeclarations.call(this),
|
|
57
51
|
...ObjectDiscriminatedUnionType_focusSparqlConstructTriplesFunctionDeclaration.call(this),
|
|
58
52
|
...ObjectDiscriminatedUnionType_focusSparqlWherePatternsFunctionDeclaration.call(this),
|
|
@@ -86,9 +80,6 @@ __decorate([
|
|
|
86
80
|
__decorate([
|
|
87
81
|
Memoize()
|
|
88
82
|
], ObjectDiscriminatedUnionType.prototype, "objectSetMethodNames", null);
|
|
89
|
-
__decorate([
|
|
90
|
-
Memoize()
|
|
91
|
-
], ObjectDiscriminatedUnionType.prototype, "schema", null);
|
|
92
83
|
__decorate([
|
|
93
84
|
Memoize()
|
|
94
85
|
], ObjectDiscriminatedUnionType.prototype, "schemaType", null);
|
|
@@ -38,9 +38,9 @@ export declare class ObjectType extends AbstractType {
|
|
|
38
38
|
toRdfTypes: readonly NamedNode[];
|
|
39
39
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
40
40
|
get conversionFunction(): Maybe<AbstractType.ConversionFunction>;
|
|
41
|
+
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
41
42
|
get declaration(): Maybe<Code>;
|
|
42
43
|
get equalsFunction(): Code;
|
|
43
|
-
get expression(): Code;
|
|
44
44
|
get filterFunction(): Code;
|
|
45
45
|
get filterType(): Code;
|
|
46
46
|
get fromRdfResourceValuesFunction(): Code;
|
|
@@ -52,7 +52,7 @@ export declare class ObjectType extends AbstractType {
|
|
|
52
52
|
get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
|
|
53
53
|
get properties(): readonly ObjectType.Property[];
|
|
54
54
|
get referencesNamedType(): boolean;
|
|
55
|
-
get
|
|
55
|
+
get schemaExpression(): Code;
|
|
56
56
|
get schemaType(): Code;
|
|
57
57
|
get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
|
|
58
58
|
get toRdfjsResourceType(): Code;
|
|
@@ -72,7 +72,7 @@ export declare class ObjectType extends AbstractType {
|
|
|
72
72
|
protected get toJsonFunction(): Code;
|
|
73
73
|
protected get toRdfTypesVariable(): Maybe<Code>;
|
|
74
74
|
protected get toStringFunction(): Code;
|
|
75
|
-
|
|
75
|
+
protected get inlineExpression(): Code;
|
|
76
76
|
fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
|
|
77
77
|
graphqlResolveExpression({ variables, }: {
|
|
78
78
|
variables: {
|