@shaclmate/compiler 4.0.52 → 4.0.53
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/AbstractContainerType.d.ts +2 -1
- package/dist/generators/ts/AbstractContainerType.js +1 -0
- package/dist/generators/ts/AbstractDateType.d.ts +8 -8
- package/dist/generators/ts/AbstractDateType.js +7 -16
- package/dist/generators/ts/AbstractLiteralType.d.ts +3 -4
- package/dist/generators/ts/AbstractLiteralType.js +3 -5
- package/dist/generators/ts/AbstractNumericType.d.ts +0 -2
- package/dist/generators/ts/AbstractNumericType.js +1 -20
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -13
- package/dist/generators/ts/AbstractPrimitiveType.js +22 -19
- package/dist/generators/ts/AbstractTypedLiteralType.d.ts +32 -0
- package/dist/generators/ts/AbstractTypedLiteralType.js +36 -0
- package/dist/generators/ts/BigDecimalType.d.ts +4 -2
- package/dist/generators/ts/BigDecimalType.js +6 -11
- package/dist/generators/ts/BigIntType.js +20 -9
- package/dist/generators/ts/BooleanType.d.ts +0 -2
- package/dist/generators/ts/BooleanType.js +0 -15
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +4 -4
- package/dist/generators/ts/DateType.d.ts +1 -2
- package/dist/generators/ts/DateType.js +4 -4
- package/dist/generators/ts/DefaultValueType.d.ts +3 -0
- package/dist/generators/ts/LangStringType.d.ts +31 -0
- package/dist/generators/ts/LangStringType.js +67 -0
- package/dist/generators/ts/ListType.d.ts +2 -1
- package/dist/generators/ts/ListType.js +1 -0
- package/dist/generators/ts/LiteralType.d.ts +4 -0
- package/dist/generators/ts/LiteralType.js +5 -0
- package/dist/generators/ts/Snippets.d.ts +4 -1
- package/dist/generators/ts/Snippets.js +28 -7
- package/dist/generators/ts/StringType.d.ts +5 -2
- package/dist/generators/ts/StringType.js +9 -17
- package/dist/generators/ts/Type.d.ts +2 -1
- package/dist/generators/ts/TypeFactory.js +32 -81
- package/dist/generators/ts/UnionType.d.ts +1 -1
- package/dist/generators/ts/_snippets/snippets_LangStringSchema.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_LangStringSchema.js +4 -0
- package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +1 -0
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToLangString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLangString.js +15 -0
- package/dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.js +5 -0
- package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +1 -1
- package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.js +4 -1
- package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +2 -2
- package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +1 -1
- package/dist/generators/ts/rdfjsTermExpression.js +1 -0
- package/dist/input/input.shaclmate.js +3 -3
- package/package.json +19 -8
- package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.js +0 -9
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Literal } from "@rdfjs/types";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
4
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
5
|
+
export declare class LangStringType extends AbstractLiteralType {
|
|
6
|
+
private readonly languageIn;
|
|
7
|
+
protected readonly inlineExpression: Code;
|
|
8
|
+
readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
|
|
9
|
+
readonly filterFunction: Code;
|
|
10
|
+
readonly filterType: Code;
|
|
11
|
+
readonly fromRdfResourceValuesFunction: Code;
|
|
12
|
+
readonly jsTypes: readonly [{
|
|
13
|
+
readonly instanceof: "Object";
|
|
14
|
+
readonly typeof: "object";
|
|
15
|
+
}];
|
|
16
|
+
readonly kind = "LangString";
|
|
17
|
+
readonly schemaType: Code;
|
|
18
|
+
readonly valueSparqlWherePatternsFunction: Code;
|
|
19
|
+
constructor({ languageIn, ...superParameters }: {
|
|
20
|
+
languageIn: readonly string[];
|
|
21
|
+
} & ConstructorParameters<typeof AbstractLiteralType>[0]);
|
|
22
|
+
get graphqlType(): AbstractLiteralType.GraphqlType;
|
|
23
|
+
protected get schemaInitializers(): readonly Code[];
|
|
24
|
+
fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
|
|
25
|
+
graphqlResolveExpression(_parameters: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
26
|
+
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractLiteralType["jsonSchema"]>[0]): Code;
|
|
27
|
+
jsonType(parameters?: Parameters<AbstractLiteralType["jsonType"]>[0]): AbstractLiteralType.JsonType;
|
|
28
|
+
literalValueExpression(literal: Literal): Code;
|
|
29
|
+
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=LangStringType.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
3
|
+
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
4
|
+
export class LangStringType extends AbstractLiteralType {
|
|
5
|
+
languageIn;
|
|
6
|
+
inlineExpression = code `${this.reusables.imports.Literal}`;
|
|
7
|
+
conversionFunction = Maybe.of({
|
|
8
|
+
code: code `${this.reusables.snippets.convertToLangString}`,
|
|
9
|
+
sourceTypes: [
|
|
10
|
+
{
|
|
11
|
+
expression: code `${this.reusables.imports.Literal}`,
|
|
12
|
+
jsType: { instanceof: "Object", typeof: "object" },
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
});
|
|
16
|
+
filterFunction = code `${this.reusables.snippets.filterLiteral}`;
|
|
17
|
+
filterType = code `${this.reusables.snippets.LiteralFilter}`;
|
|
18
|
+
fromRdfResourceValuesFunction = code `${this.reusables.snippets.langStringFromRdfResourceValues}`;
|
|
19
|
+
jsTypes = [
|
|
20
|
+
{ instanceof: "Object", typeof: "object" },
|
|
21
|
+
];
|
|
22
|
+
kind = "LangString";
|
|
23
|
+
schemaType = code `${this.reusables.snippets.LangStringSchema}`;
|
|
24
|
+
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.langStringSparqlWherePatterns}`;
|
|
25
|
+
constructor({ languageIn, ...superParameters }) {
|
|
26
|
+
super(superParameters);
|
|
27
|
+
this.languageIn = languageIn;
|
|
28
|
+
}
|
|
29
|
+
get graphqlType() {
|
|
30
|
+
throw new Error("not implemented");
|
|
31
|
+
}
|
|
32
|
+
get schemaInitializers() {
|
|
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
|
+
if (this.languageIn.length > 0) {
|
|
38
|
+
initializers = initializers.concat(code `languageIn: ${arrayOf(...this.languageIn)}`);
|
|
39
|
+
}
|
|
40
|
+
return initializers;
|
|
41
|
+
}
|
|
42
|
+
fromJsonExpression({ variables, }) {
|
|
43
|
+
return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${this.reusables.imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"]))`;
|
|
44
|
+
}
|
|
45
|
+
graphqlResolveExpression(_parameters) {
|
|
46
|
+
throw new Error("not implemented");
|
|
47
|
+
}
|
|
48
|
+
jsonSchema({ includeDiscriminantProperty, }) {
|
|
49
|
+
const discriminantProperty = includeDiscriminantProperty
|
|
50
|
+
? code `, termType: ${this.reusables.imports.z}.literal("Literal")`
|
|
51
|
+
: "";
|
|
52
|
+
return code `${this.reusables.imports.z}.object({ "@language": ${this.reusables.imports.z}.string()${discriminantProperty}, "@value": ${this.reusables.imports.z}.string() })`;
|
|
53
|
+
}
|
|
54
|
+
jsonType(parameters) {
|
|
55
|
+
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
56
|
+
? `, readonly termType: "Literal"`
|
|
57
|
+
: "";
|
|
58
|
+
return new AbstractLiteralType.JsonType(code `{ readonly "@language": string${discriminantProperty}, readonly "@value": string }`);
|
|
59
|
+
}
|
|
60
|
+
literalValueExpression(literal) {
|
|
61
|
+
return this.rdfjsTermExpression(literal);
|
|
62
|
+
}
|
|
63
|
+
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
64
|
+
return code `{ "@language": ${variables.value}.language${includeDiscriminantProperty ? `, "termType": "Literal" as const` : ""}, "@value": ${variables.value}.value }`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=LangStringType.js.map
|
|
@@ -11,6 +11,7 @@ import type { FloatType } from "./FloatType.js";
|
|
|
11
11
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
12
12
|
import type { IntType } from "./IntType.js";
|
|
13
13
|
import type { IriType } from "./IriType.js";
|
|
14
|
+
import type { LangStringType } from "./LangStringType.js";
|
|
14
15
|
import type { LiteralType } from "./LiteralType.js";
|
|
15
16
|
import type { ObjectType } from "./ObjectType.js";
|
|
16
17
|
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
@@ -43,7 +44,7 @@ export declare class ListType<ItemTypeT extends ListType.ItemType> extends Abstr
|
|
|
43
44
|
toStringExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toStringExpression"]>[0]): Code;
|
|
44
45
|
}
|
|
45
46
|
export declare namespace ListType {
|
|
46
|
-
type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
|
|
47
|
+
type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | LangStringType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
|
|
47
48
|
function isItemType(type: Type): type is ItemType;
|
|
48
49
|
}
|
|
49
50
|
//# sourceMappingURL=ListType.d.ts.map
|
|
@@ -3,6 +3,7 @@ import { Maybe } from "purify-ts";
|
|
|
3
3
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
4
4
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
5
5
|
export declare class LiteralType extends AbstractLiteralType {
|
|
6
|
+
private readonly languageIn;
|
|
6
7
|
protected readonly inlineExpression: Code;
|
|
7
8
|
readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
|
|
8
9
|
readonly filterFunction: Code;
|
|
@@ -15,6 +16,9 @@ export declare class LiteralType extends AbstractLiteralType {
|
|
|
15
16
|
readonly kind = "Literal";
|
|
16
17
|
readonly schemaType: Code;
|
|
17
18
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
19
|
+
constructor({ languageIn, ...superParameters }: {
|
|
20
|
+
languageIn: readonly string[];
|
|
21
|
+
} & ConstructorParameters<typeof AbstractLiteralType>[0]);
|
|
18
22
|
get graphqlType(): AbstractLiteralType.GraphqlType;
|
|
19
23
|
protected get schemaInitializers(): readonly Code[];
|
|
20
24
|
fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
|
|
@@ -3,6 +3,7 @@ import { Maybe } from "purify-ts";
|
|
|
3
3
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
4
4
|
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
5
5
|
export class LiteralType extends AbstractLiteralType {
|
|
6
|
+
languageIn;
|
|
6
7
|
inlineExpression = code `${this.reusables.imports.Literal}`;
|
|
7
8
|
conversionFunction = Maybe.of({
|
|
8
9
|
code: code `${this.reusables.snippets.convertToLiteral}`,
|
|
@@ -30,6 +31,10 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
30
31
|
kind = "Literal";
|
|
31
32
|
schemaType = code `${this.reusables.snippets.LiteralSchema}`;
|
|
32
33
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.literalSparqlWherePatterns}`;
|
|
34
|
+
constructor({ languageIn, ...superParameters }) {
|
|
35
|
+
super(superParameters);
|
|
36
|
+
this.languageIn = languageIn;
|
|
37
|
+
}
|
|
33
38
|
get graphqlType() {
|
|
34
39
|
throw new Error("not implemented");
|
|
35
40
|
}
|
|
@@ -35,6 +35,7 @@ export declare class Snippets {
|
|
|
35
35
|
get IdentifierSet(): Snippet;
|
|
36
36
|
get IriFilter(): Snippet;
|
|
37
37
|
get IriSchema(): Snippet;
|
|
38
|
+
get LangStringSchema(): Snippet;
|
|
38
39
|
get Lazy(): Snippet;
|
|
39
40
|
get LazyOption(): Snippet;
|
|
40
41
|
get LazySet(): Snippet;
|
|
@@ -81,6 +82,7 @@ export declare class Snippets {
|
|
|
81
82
|
get convertToIdentifierProperty(): Snippet;
|
|
82
83
|
get convertToIri(): Snippet;
|
|
83
84
|
get convertToIriIdentifierProperty(): Snippet;
|
|
85
|
+
get convertToLangString(): Snippet;
|
|
84
86
|
get convertToLazy(): Snippet;
|
|
85
87
|
get convertToLazyOption(): Snippet;
|
|
86
88
|
get convertToLazySet(): Snippet;
|
|
@@ -93,7 +95,6 @@ export declare class Snippets {
|
|
|
93
95
|
get dateFromRdfResourceValues(): Snippet;
|
|
94
96
|
get dateSparqlWherePatterns(): Snippet;
|
|
95
97
|
get dateTimeFromRdfResourceValues(): Snippet;
|
|
96
|
-
get decodeBigDecimalLiteral(): Snippet;
|
|
97
98
|
get deduplicateSparqlPatterns(): Snippet;
|
|
98
99
|
get defaultValueFromRdfResourceValues(): Snippet;
|
|
99
100
|
get defaultValueSparqlWherePatterns(): Snippet;
|
|
@@ -128,6 +129,8 @@ export declare class Snippets {
|
|
|
128
129
|
get intFromRdfResourceValues(): Snippet;
|
|
129
130
|
get iriFromRdfResourceValues(): Snippet;
|
|
130
131
|
get iriSparqlWherePatterns(): Snippet;
|
|
132
|
+
get langStringFromRdfResourceValues(): Snippet;
|
|
133
|
+
get langStringSparqlWherePatterns(): Snippet;
|
|
131
134
|
get liftSparqlPatterns(): Snippet;
|
|
132
135
|
get listFromRdfResourceValues(): Snippet;
|
|
133
136
|
get listSparqlConstructTriples(): Snippet;
|
|
@@ -34,6 +34,7 @@ import { snippets_convertToIdentifier } from "./_snippets/snippets_convertToIden
|
|
|
34
34
|
import { snippets_convertToIdentifierProperty } from "./_snippets/snippets_convertToIdentifierProperty.js";
|
|
35
35
|
import { snippets_convertToIri } from "./_snippets/snippets_convertToIri.js";
|
|
36
36
|
import { snippets_convertToIriIdentifierProperty } from "./_snippets/snippets_convertToIriIdentifierProperty.js";
|
|
37
|
+
import { snippets_convertToLangString } from "./_snippets/snippets_convertToLangString.js";
|
|
37
38
|
import { snippets_convertToLazy } from "./_snippets/snippets_convertToLazy.js";
|
|
38
39
|
import { snippets_convertToLazyOption } from "./_snippets/snippets_convertToLazyOption.js";
|
|
39
40
|
import { snippets_convertToLazySet } from "./_snippets/snippets_convertToLazySet.js";
|
|
@@ -49,7 +50,6 @@ import { snippets_dateEquals } from "./_snippets/snippets_dateEquals.js";
|
|
|
49
50
|
import { snippets_dateFromRdfResourceValues } from "./_snippets/snippets_dateFromRdfResourceValues.js";
|
|
50
51
|
import { snippets_dateSparqlWherePatterns } from "./_snippets/snippets_dateSparqlWherePatterns.js";
|
|
51
52
|
import { snippets_dateTimeFromRdfResourceValues } from "./_snippets/snippets_dateTimeFromRdfResourceValues.js";
|
|
52
|
-
import { snippets_decodeBigDecimalLiteral } from "./_snippets/snippets_decodeBigDecimalLiteral.js";
|
|
53
53
|
import { snippets_deduplicateSparqlPatterns } from "./_snippets/snippets_deduplicateSparqlPatterns.js";
|
|
54
54
|
import { snippets_defaultValueFromRdfResourceValues } from "./_snippets/snippets_defaultValueFromRdfResourceValues.js";
|
|
55
55
|
import { snippets_defaultValueSparqlWherePatterns } from "./_snippets/snippets_defaultValueSparqlWherePatterns.js";
|
|
@@ -96,11 +96,14 @@ import { snippets_identityValidationFunction } from "./_snippets/snippets_identi
|
|
|
96
96
|
import { snippets_intFromRdfResourceValues } from "./_snippets/snippets_intFromRdfResourceValues.js";
|
|
97
97
|
import { snippets_iriFromRdfResourceValues } from "./_snippets/snippets_iriFromRdfResourceValues.js";
|
|
98
98
|
import { snippets_iriSparqlWherePatterns } from "./_snippets/snippets_iriSparqlWherePatterns.js";
|
|
99
|
+
import { snippets_LangStringSchema } from "./_snippets/snippets_LangStringSchema.js";
|
|
99
100
|
import { snippets_Lazy } from "./_snippets/snippets_Lazy.js";
|
|
100
101
|
import { snippets_LazyOption } from "./_snippets/snippets_LazyOption.js";
|
|
101
102
|
import { snippets_LazySet } from "./_snippets/snippets_LazySet.js";
|
|
102
103
|
import { snippets_LiteralFilter } from "./_snippets/snippets_LiteralFilter.js";
|
|
103
104
|
import { snippets_LiteralSchema } from "./_snippets/snippets_LiteralSchema.js";
|
|
105
|
+
import { snippets_langStringFromRdfResourceValues } from "./_snippets/snippets_langStringFromRdfResourceValues.js";
|
|
106
|
+
import { snippets_langStringSparqlWherePatterns } from "./_snippets/snippets_langStringSparqlWherePatterns.js";
|
|
104
107
|
import { snippets_liftSparqlPatterns } from "./_snippets/snippets_liftSparqlPatterns.js";
|
|
105
108
|
import { snippets_listFromRdfResourceValues } from "./_snippets/snippets_listFromRdfResourceValues.js";
|
|
106
109
|
import { snippets_listSparqlConstructTriples } from "./_snippets/snippets_listSparqlConstructTriples.js";
|
|
@@ -247,6 +250,9 @@ export class Snippets {
|
|
|
247
250
|
get IriSchema() {
|
|
248
251
|
return this.snippet(snippets_IriSchema);
|
|
249
252
|
}
|
|
253
|
+
get LangStringSchema() {
|
|
254
|
+
return this.snippet(snippets_LangStringSchema);
|
|
255
|
+
}
|
|
250
256
|
get Lazy() {
|
|
251
257
|
return this.snippet(snippets_Lazy);
|
|
252
258
|
}
|
|
@@ -385,6 +391,9 @@ export class Snippets {
|
|
|
385
391
|
get convertToIriIdentifierProperty() {
|
|
386
392
|
return this.snippet(snippets_convertToIriIdentifierProperty);
|
|
387
393
|
}
|
|
394
|
+
get convertToLangString() {
|
|
395
|
+
return this.snippet(snippets_convertToLangString);
|
|
396
|
+
}
|
|
388
397
|
get convertToLazy() {
|
|
389
398
|
return this.snippet(snippets_convertToLazy);
|
|
390
399
|
}
|
|
@@ -421,9 +430,6 @@ export class Snippets {
|
|
|
421
430
|
get dateTimeFromRdfResourceValues() {
|
|
422
431
|
return this.snippet(snippets_dateTimeFromRdfResourceValues);
|
|
423
432
|
}
|
|
424
|
-
get decodeBigDecimalLiteral() {
|
|
425
|
-
return this.snippet(snippets_decodeBigDecimalLiteral);
|
|
426
|
-
}
|
|
427
433
|
get deduplicateSparqlPatterns() {
|
|
428
434
|
return this.snippet(snippets_deduplicateSparqlPatterns);
|
|
429
435
|
}
|
|
@@ -542,6 +548,12 @@ export class Snippets {
|
|
|
542
548
|
get iriSparqlWherePatterns() {
|
|
543
549
|
return this.snippet(snippets_iriSparqlWherePatterns);
|
|
544
550
|
}
|
|
551
|
+
get langStringFromRdfResourceValues() {
|
|
552
|
+
return this.snippet(snippets_langStringFromRdfResourceValues);
|
|
553
|
+
}
|
|
554
|
+
get langStringSparqlWherePatterns() {
|
|
555
|
+
return this.snippet(snippets_langStringSparqlWherePatterns);
|
|
556
|
+
}
|
|
545
557
|
get liftSparqlPatterns() {
|
|
546
558
|
return this.snippet(snippets_liftSparqlPatterns);
|
|
547
559
|
}
|
|
@@ -767,6 +779,9 @@ __decorate([
|
|
|
767
779
|
__decorate([
|
|
768
780
|
Memoize()
|
|
769
781
|
], Snippets.prototype, "IriSchema", null);
|
|
782
|
+
__decorate([
|
|
783
|
+
Memoize()
|
|
784
|
+
], Snippets.prototype, "LangStringSchema", null);
|
|
770
785
|
__decorate([
|
|
771
786
|
Memoize()
|
|
772
787
|
], Snippets.prototype, "Lazy", null);
|
|
@@ -905,6 +920,9 @@ __decorate([
|
|
|
905
920
|
__decorate([
|
|
906
921
|
Memoize()
|
|
907
922
|
], Snippets.prototype, "convertToIriIdentifierProperty", null);
|
|
923
|
+
__decorate([
|
|
924
|
+
Memoize()
|
|
925
|
+
], Snippets.prototype, "convertToLangString", null);
|
|
908
926
|
__decorate([
|
|
909
927
|
Memoize()
|
|
910
928
|
], Snippets.prototype, "convertToLazy", null);
|
|
@@ -941,9 +959,6 @@ __decorate([
|
|
|
941
959
|
__decorate([
|
|
942
960
|
Memoize()
|
|
943
961
|
], Snippets.prototype, "dateTimeFromRdfResourceValues", null);
|
|
944
|
-
__decorate([
|
|
945
|
-
Memoize()
|
|
946
|
-
], Snippets.prototype, "decodeBigDecimalLiteral", null);
|
|
947
962
|
__decorate([
|
|
948
963
|
Memoize()
|
|
949
964
|
], Snippets.prototype, "deduplicateSparqlPatterns", null);
|
|
@@ -1043,6 +1058,12 @@ __decorate([
|
|
|
1043
1058
|
__decorate([
|
|
1044
1059
|
Memoize()
|
|
1045
1060
|
], Snippets.prototype, "iriSparqlWherePatterns", null);
|
|
1061
|
+
__decorate([
|
|
1062
|
+
Memoize()
|
|
1063
|
+
], Snippets.prototype, "langStringFromRdfResourceValues", null);
|
|
1064
|
+
__decorate([
|
|
1065
|
+
Memoize()
|
|
1066
|
+
], Snippets.prototype, "langStringSparqlWherePatterns", null);
|
|
1046
1067
|
__decorate([
|
|
1047
1068
|
Memoize()
|
|
1048
1069
|
], Snippets.prototype, "liftSparqlPatterns", null);
|
|
@@ -2,6 +2,7 @@ import type { Literal } from "@rdfjs/types";
|
|
|
2
2
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
3
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
4
|
export declare class StringType extends AbstractPrimitiveType<string> {
|
|
5
|
+
private readonly languageIn;
|
|
5
6
|
readonly filterFunction: Code;
|
|
6
7
|
readonly filterType: Code;
|
|
7
8
|
readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
|
|
@@ -11,11 +12,13 @@ export declare class StringType extends AbstractPrimitiveType<string> {
|
|
|
11
12
|
}];
|
|
12
13
|
readonly kind = "String";
|
|
13
14
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
15
|
+
constructor({ languageIn, ...superParameters }: {
|
|
16
|
+
languageIn: readonly string[];
|
|
17
|
+
} & ConstructorParameters<typeof AbstractPrimitiveType<string>>[0]);
|
|
14
18
|
get fromRdfResourceValuesFunction(): Code;
|
|
15
19
|
get schemaType(): Code;
|
|
16
|
-
protected get inlineExpression(): Code;
|
|
17
20
|
protected get schemaInitializers(): readonly Code[];
|
|
18
|
-
jsonSchema(
|
|
21
|
+
jsonSchema(parameters: Parameters<AbstractPrimitiveType<string>["jsonSchema"]>[0]): Code;
|
|
19
22
|
literalValueExpression(literal: Literal | string): Code;
|
|
20
23
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
21
24
|
}
|
|
@@ -9,6 +9,7 @@ import { Memoize } from "typescript-memoize";
|
|
|
9
9
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
10
10
|
import { arrayOf, code, literalOf } from "./ts-poet-wrapper.js";
|
|
11
11
|
export class StringType extends AbstractPrimitiveType {
|
|
12
|
+
languageIn;
|
|
12
13
|
filterFunction = code `${this.reusables.snippets.filterString}`;
|
|
13
14
|
filterType = code `${this.reusables.snippets.StringFilter}`;
|
|
14
15
|
graphqlType = new AbstractPrimitiveType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
|
|
@@ -20,18 +21,16 @@ export class StringType extends AbstractPrimitiveType {
|
|
|
20
21
|
];
|
|
21
22
|
kind = "String";
|
|
22
23
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.stringSparqlWherePatterns}`;
|
|
24
|
+
constructor({ languageIn, ...superParameters }) {
|
|
25
|
+
super(superParameters);
|
|
26
|
+
this.languageIn = languageIn;
|
|
27
|
+
}
|
|
23
28
|
get fromRdfResourceValuesFunction() {
|
|
24
29
|
return code `${this.reusables.snippets.stringFromRdfResourceValues}<${this.expression}>`;
|
|
25
30
|
}
|
|
26
31
|
get schemaType() {
|
|
27
32
|
return code `${this.reusables.snippets.StringSchema}<${this.expression}>`;
|
|
28
33
|
}
|
|
29
|
-
get inlineExpression() {
|
|
30
|
-
if (this.primitiveIn.length > 0) {
|
|
31
|
-
return code `${this.primitiveIn.map((value) => `"${value}"`).join(" | ")}`;
|
|
32
|
-
}
|
|
33
|
-
return code `string`;
|
|
34
|
-
}
|
|
35
34
|
get schemaInitializers() {
|
|
36
35
|
let initializers = super.schemaInitializers;
|
|
37
36
|
if (this.languageIn.length > 0) {
|
|
@@ -39,15 +38,11 @@ export class StringType extends AbstractPrimitiveType {
|
|
|
39
38
|
}
|
|
40
39
|
return initializers;
|
|
41
40
|
}
|
|
42
|
-
jsonSchema(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return code `${this.reusables.imports.z}.string()`;
|
|
46
|
-
case 1:
|
|
47
|
-
return code `${this.reusables.imports.z}.literal(${this.primitiveIn[0]})`;
|
|
48
|
-
default:
|
|
49
|
-
return code `${this.reusables.imports.z}.enum(${arrayOf(...this.primitiveIn)})`;
|
|
41
|
+
jsonSchema(parameters) {
|
|
42
|
+
if (this.decodedIn.length > 1) {
|
|
43
|
+
return code `${this.reusables.imports.z}.enum(${arrayOf(...this.decodedIn)})`;
|
|
50
44
|
}
|
|
45
|
+
return super.jsonSchema(parameters);
|
|
51
46
|
}
|
|
52
47
|
literalValueExpression(literal) {
|
|
53
48
|
return code `${literalOf(typeof literal === "string" ? literal : literal.value)}`;
|
|
@@ -62,7 +57,4 @@ __decorate([
|
|
|
62
57
|
__decorate([
|
|
63
58
|
Memoize()
|
|
64
59
|
], StringType.prototype, "schemaType", null);
|
|
65
|
-
__decorate([
|
|
66
|
-
Memoize()
|
|
67
|
-
], StringType.prototype, "inlineExpression", null);
|
|
68
60
|
//# sourceMappingURL=StringType.js.map
|
|
@@ -9,6 +9,7 @@ import type { FloatType } from "./FloatType.js";
|
|
|
9
9
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
10
10
|
import type { IntType } from "./IntType.js";
|
|
11
11
|
import type { IriType } from "./IriType.js";
|
|
12
|
+
import type { LangStringType } from "./LangStringType.js";
|
|
12
13
|
import type { LazyOptionType } from "./LazyOptionType.js";
|
|
13
14
|
import type { LazySetType } from "./LazySetType.js";
|
|
14
15
|
import type { LazyType } from "./LazyType.js";
|
|
@@ -21,5 +22,5 @@ import type { SetType } from "./SetType.js";
|
|
|
21
22
|
import type { StringType } from "./StringType.js";
|
|
22
23
|
import type { TermType } from "./TermType.js";
|
|
23
24
|
import type { UnionType } from "./UnionType.js";
|
|
24
|
-
export type Type = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | DefaultValueType<DefaultValueType.ItemType> | FloatType | IdentifierType | IntType | IriType | LazyOptionType | LazySetType | LazyType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | OptionType<OptionType.ItemType> | SetType<SetType.ItemType> | StringType | TermType | UnionType<Type>;
|
|
25
|
+
export type Type = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | DefaultValueType<DefaultValueType.ItemType> | FloatType | IdentifierType | IntType | IriType | LangStringType | LazyOptionType | LazySetType | LazyType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | OptionType<OptionType.ItemType> | SetType<SetType.ItemType> | StringType | TermType | UnionType<Type>;
|
|
25
26
|
//# sourceMappingURL=Type.d.ts.map
|
|
@@ -18,6 +18,7 @@ import { FloatType } from "./FloatType.js";
|
|
|
18
18
|
import { IdentifierType } from "./IdentifierType.js";
|
|
19
19
|
import { IntType } from "./IntType.js";
|
|
20
20
|
import { IriType } from "./IriType.js";
|
|
21
|
+
import { LangStringType } from "./LangStringType.js";
|
|
21
22
|
import { LazyOptionType } from "./LazyOptionType.js";
|
|
22
23
|
import { LazySetType } from "./LazySetType.js";
|
|
23
24
|
import { LazyType } from "./LazyType.js";
|
|
@@ -321,114 +322,64 @@ export class TypeFactory {
|
|
|
321
322
|
}
|
|
322
323
|
if (datatypes.size === 1) {
|
|
323
324
|
const datatype = [...datatypes][0];
|
|
325
|
+
const typeParameters = {
|
|
326
|
+
comment: astType.comment,
|
|
327
|
+
configuration: this.configuration,
|
|
328
|
+
datatype,
|
|
329
|
+
hasValues: astType.hasValues,
|
|
330
|
+
in_: astType.in_,
|
|
331
|
+
label: astType.label,
|
|
332
|
+
languageIn: astType.languageIn,
|
|
333
|
+
logger: this.logger,
|
|
334
|
+
name: astType.name.map((name) => this.tsName(name)),
|
|
335
|
+
reusables: this.reusables,
|
|
336
|
+
shapeIdentifier: astType.shapeIdentifier,
|
|
337
|
+
};
|
|
338
|
+
if (datatype.equals(rdf.langString)) {
|
|
339
|
+
return new LangStringType(typeParameters);
|
|
340
|
+
}
|
|
324
341
|
const datatypeDefinition = literalDatatypeDefinitions[datatype.value];
|
|
325
342
|
if (datatypeDefinition) {
|
|
326
343
|
switch (datatypeDefinition.kind) {
|
|
327
344
|
case "bigdecimal":
|
|
328
345
|
return new BigDecimalType({
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
hasValues: astType.hasValues,
|
|
332
|
-
in_: astType.in_,
|
|
333
|
-
label: astType.label,
|
|
334
|
-
languageIn: [],
|
|
335
|
-
logger: this.logger,
|
|
336
|
-
name: astType.name.map((name) => this.tsName(name)),
|
|
337
|
-
reusables: this.reusables,
|
|
338
|
-
shapeIdentifier: astType.shapeIdentifier,
|
|
346
|
+
...typeParameters,
|
|
347
|
+
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeBigDecimalLiteral(value).unsafeCoerce()),
|
|
339
348
|
});
|
|
340
349
|
case "bigint":
|
|
341
350
|
return new BigIntType({
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
datatype,
|
|
345
|
-
hasValues: astType.hasValues,
|
|
346
|
-
in_: astType.in_,
|
|
347
|
-
label: astType.label,
|
|
348
|
-
languageIn: [],
|
|
349
|
-
logger: this.logger,
|
|
350
|
-
name: astType.name.map((name) => this.tsName(name)),
|
|
351
|
-
primitiveIn: astType.in_.map((value) => LiteralDecoder.decodeBigIntLiteral(value).unsafeCoerce()),
|
|
352
|
-
reusables: this.reusables,
|
|
353
|
-
shapeIdentifier: astType.shapeIdentifier,
|
|
351
|
+
...typeParameters,
|
|
352
|
+
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeBigIntLiteral(value).unsafeCoerce()),
|
|
354
353
|
});
|
|
355
354
|
case "boolean":
|
|
356
355
|
return new BooleanType({
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
datatype,
|
|
360
|
-
hasValues: astType.hasValues,
|
|
361
|
-
label: astType.label,
|
|
362
|
-
languageIn: [],
|
|
363
|
-
in_: astType.in_,
|
|
364
|
-
logger: this.logger,
|
|
365
|
-
name: astType.name.map((name) => this.tsName(name)),
|
|
366
|
-
primitiveIn: astType.in_.map((value) => LiteralDecoder.decodeBooleanLiteral(value).unsafeCoerce()),
|
|
367
|
-
reusables: this.reusables,
|
|
368
|
-
shapeIdentifier: astType.shapeIdentifier,
|
|
356
|
+
...typeParameters,
|
|
357
|
+
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeBooleanLiteral(value).unsafeCoerce()),
|
|
369
358
|
});
|
|
370
359
|
case "date":
|
|
371
360
|
case "datetime":
|
|
372
361
|
return new (datatypeDefinition.kind === "date" ? DateType : DateTimeType)({
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
datatype,
|
|
376
|
-
hasValues: astType.hasValues,
|
|
377
|
-
in_: astType.in_,
|
|
378
|
-
label: astType.label,
|
|
379
|
-
languageIn: [],
|
|
380
|
-
logger: this.logger,
|
|
381
|
-
name: astType.name.map((name) => this.tsName(name)),
|
|
382
|
-
primitiveIn: astType.in_.map((value) => (datatypeDefinition.kind === "date"
|
|
362
|
+
...typeParameters,
|
|
363
|
+
decodedIn: astType.in_.map((value) => (datatypeDefinition.kind === "date"
|
|
383
364
|
? LiteralDecoder.decodeDateLiteral
|
|
384
365
|
: LiteralDecoder.decodeDateTimeLiteral)(value).unsafeCoerce()),
|
|
385
|
-
reusables: this.reusables,
|
|
386
|
-
shapeIdentifier: astType.shapeIdentifier,
|
|
387
366
|
});
|
|
388
367
|
case "float":
|
|
389
368
|
case "int":
|
|
390
369
|
return new (datatypeDefinition.kind === "float" ? FloatType : IntType)({
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
datatype,
|
|
394
|
-
hasValues: astType.hasValues,
|
|
395
|
-
in_: astType.in_,
|
|
396
|
-
label: astType.label,
|
|
397
|
-
languageIn: [],
|
|
398
|
-
logger: this.logger,
|
|
399
|
-
name: astType.name.map((name) => this.tsName(name)),
|
|
400
|
-
primitiveIn: astType.in_.map((value) => (datatypeDefinition.kind === "float"
|
|
370
|
+
...typeParameters,
|
|
371
|
+
decodedIn: astType.in_.map((value) => (datatypeDefinition.kind === "float"
|
|
401
372
|
? LiteralDecoder.decodeFloatLiteral
|
|
402
373
|
: LiteralDecoder.decodeIntLiteral)(value).unsafeCoerce()),
|
|
403
|
-
reusables: this.reusables,
|
|
404
|
-
shapeIdentifier: astType.shapeIdentifier,
|
|
405
374
|
});
|
|
406
375
|
case "string":
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
datatype,
|
|
412
|
-
hasValues: astType.hasValues,
|
|
413
|
-
in_: astType.in_,
|
|
414
|
-
label: astType.label,
|
|
415
|
-
languageIn: astType.languageIn,
|
|
416
|
-
logger: this.logger,
|
|
417
|
-
name: astType.name.map((name) => this.tsName(name)),
|
|
418
|
-
primitiveIn: astType.in_.map((value) => value.value),
|
|
419
|
-
reusables: this.reusables,
|
|
420
|
-
shapeIdentifier: astType.shapeIdentifier,
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
break;
|
|
376
|
+
return new StringType({
|
|
377
|
+
...typeParameters,
|
|
378
|
+
decodedIn: astType.in_.map((value) => LiteralDecoder.decodeStringLiteral(value).unsafeCoerce()),
|
|
379
|
+
});
|
|
424
380
|
}
|
|
425
381
|
}
|
|
426
|
-
|
|
427
|
-
// Drop down
|
|
428
|
-
}
|
|
429
|
-
else {
|
|
430
|
-
this.logger.warn("unrecognized literal datatype: %s", datatype.value);
|
|
431
|
-
}
|
|
382
|
+
this.logger.warn("unrecognized literal datatype: %s", datatype.value);
|
|
432
383
|
}
|
|
433
384
|
else if (datatypes.size > 0) {
|
|
434
385
|
this.logger.warn("literal type has multiple datatypes: %s", JSON.stringify([...datatypes].map((datatype) => datatype.value)));
|
|
@@ -112,7 +112,7 @@ export declare namespace Discriminant {
|
|
|
112
112
|
export declare namespace AbstractUnionType {
|
|
113
113
|
interface Member<TypeT extends Type> {
|
|
114
114
|
readonly discriminantValues: readonly AbstractType.DiscriminantProperty.Value[];
|
|
115
|
-
readonly jsonType: Code
|
|
115
|
+
readonly jsonType: Code;
|
|
116
116
|
readonly jsonTypeCheck: (instance: Code) => Code;
|
|
117
117
|
readonly primaryDiscriminantValue: AbstractType.DiscriminantProperty.Value;
|
|
118
118
|
readonly type: TypeT;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_LangStringSchema = ({ snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}LangStringSchema`, code `\
|
|
3
|
+
type ${syntheticNamePrefix}LangStringSchema = Omit<${snippets.LiteralSchema}, "kind"> & { readonly kind: "LangString"; };`);
|
|
4
|
+
//# sourceMappingURL=snippets_LangStringSchema.js.map
|
|
@@ -3,6 +3,7 @@ export const snippets_RdfVocabularies = ({ imports, syntheticNamePrefix, }) => c
|
|
|
3
3
|
namespace ${syntheticNamePrefix}RdfVocabularies {
|
|
4
4
|
export const rdf = {
|
|
5
5
|
first: ${imports.dataFactory}.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#first"),
|
|
6
|
+
langString: ${imports.dataFactory}.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"),
|
|
6
7
|
nil: ${imports.dataFactory}.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"),
|
|
7
8
|
rest: ${imports.dataFactory}.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"),
|
|
8
9
|
subject: ${imports.dataFactory}.namedNode("http://www.w3.org/1999/02/22-rdf-syntax-ns#subject"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
2
|
export const snippets_bigDecimalFromRdfResourceValues = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}bigDecimalFromRdfResourceValues`, code `\
|
|
3
3
|
function ${syntheticNamePrefix}bigDecimalFromRdfResourceValues(values: ${imports.Resource}.Values, options: Parameters<${snippets.FromRdfResourceValuesFunction}<${imports.BigDecimal}, ${snippets.NumericSchema}<${imports.BigDecimal}>>>[1]): ${imports.Either}<Error, ${imports.Resource}.Values<${imports.BigDecimal}>> {
|
|
4
|
-
return ${snippets.termLikeFromRdfResourceValues}(values, options).chain(values => values.chainMap(value => value.
|
|
4
|
+
return ${snippets.termLikeFromRdfResourceValues}(values, options).chain(values => values.chainMap(value => value.toBigDecimal(options.schema.in)));
|
|
5
5
|
}`);
|
|
6
6
|
//# sourceMappingURL=snippets_bigDecimalFromRdfResourceValues.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
2
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
3
|
+
export const snippets_convertToLangString = ({ imports, rdfjsTermExpression, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToLangString`, code `\
|
|
4
|
+
function ${syntheticNamePrefix}convertToLangString(value: ${imports.Literal}): ${imports.Either}<Error, ${imports.Literal}> {
|
|
5
|
+
if (!value.datatype.equals(${rdfjsTermExpression(rdf.langString)})) {
|
|
6
|
+
return ${imports.Left}(new Error(\`expected Literal to have rdf:langString datatype, not \${value.datatype.value}\`));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (value.language.length === 0) {
|
|
10
|
+
return ${imports.Left}(new Error("expected Literal to have non-empty language"));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return ${imports.Either}.of(value);
|
|
14
|
+
}`);
|
|
15
|
+
//# sourceMappingURL=snippets_convertToLangString.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
2
|
+
export const snippets_langStringFromRdfResourceValues = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}langStringFromRdfResourceValues`, code `\
|
|
3
|
+
function ${syntheticNamePrefix}langStringFromRdfResourceValues(values: ${imports.Resource}.Values, options: Parameters<${snippets.FromRdfResourceValuesFunction}<${imports.Literal}, ${snippets.LangStringSchema}>>[1]): ${imports.Either}<Error, ${imports.Resource}.Values<${imports.Literal}>> {
|
|
4
|
+
return ${snippets.termLikeFromRdfResourceValues}(values, options).chain(values => values.chainMap(value => value.toLangString(options.schema.in)));
|
|
5
|
+
}`);
|
|
6
|
+
//# sourceMappingURL=snippets_langStringFromRdfResourceValues.js.map
|