@shaclmate/compiler 4.0.96 → 4.0.98
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/_ShapesGraphToAstTransformer/synthesizePartialAstStructType.d.ts +6 -0
- package/dist/_ShapesGraphToAstTransformer/synthesizePartialAstStructType.js +38 -0
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.js +114 -145
- package/dist/_ShapesGraphToAstTransformer/transformShapeNodeConstraintToAstType.d.ts +7 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeNodeConstraintToAstType.js +13 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstStructType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstStructType.js +0 -52
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +2 -0
- package/dist/ast/StructCompoundType.d.ts +3 -2
- package/dist/ast/StructCompoundType.js +29 -46
- package/dist/ast/StructDiscriminatedUnionType.d.ts +5 -1
- package/dist/ast/StructIntersectionType.d.ts +4 -1
- package/dist/generators/ts/AbstractLazyType.js +4 -4
- package/dist/generators/ts/AbstractStructuredType.js +2 -2
- package/dist/generators/ts/Imports.d.ts +1 -0
- package/dist/generators/ts/Imports.js +1 -0
- package/dist/generators/ts/IriType.js +13 -3
- package/dist/generators/ts/ObjectDiscriminatedUnionType.d.ts +7 -4
- package/dist/generators/ts/ObjectDiscriminatedUnionType.js +18 -2
- package/dist/generators/ts/ObjectIntersectionType.d.ts +7 -4
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +21 -10
- package/dist/generators/ts/Snippets.d.ts +7 -6
- package/dist/generators/ts/Snippets.js +41 -34
- package/dist/generators/ts/TypeFactory.js +19 -33
- package/dist/generators/ts/_ObjectIntersectionType/ObjectIntersectionType_fromJsonObjectFunction.js +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.js +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonObjectFunction.js +7 -2
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonObjectFunction.js +1 -1
- package/dist/generators/ts/_snippets/snippets_FromJsonFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_FromJsonFunction.js +28 -0
- package/dist/generators/ts/_snippets/snippets_ToJsonFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ToJsonFunction.js +3 -0
- package/dist/generators/ts/_snippets/snippets_arrayFromJsonArray.js +1 -1
- package/dist/generators/ts/_snippets/snippets_arrayToJsonArray.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_bigIntToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanFromJsonBoolean.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +2 -4
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +1 -2
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteral.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteral.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteralIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriLiteralIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_dateFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateTimeFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateTimeToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueFromJsonValue.js +1 -1
- package/dist/generators/ts/_snippets/snippets_floatFromJsonNumber.js +1 -1
- package/dist/generators/ts/_snippets/snippets_floatFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierToJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_intFromJsonNumber.js +1 -1
- package/dist/generators/ts/_snippets/snippets_intFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_iriFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_iriFromJsonString.js +2 -2
- package/dist/generators/ts/_snippets/snippets_iriFromString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriFromString.js +76 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonObject.js +6 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriLiteralFromJsonString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_langStringFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_langStringToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_listFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_listToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_literalFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_literalToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeFromJsonValue.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeToJsonValue.js +1 -1
- package/dist/generators/ts/_snippets/snippets_primitiveToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_stringFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_stringFromJsonString.js +1 -1
- package/dist/generators/ts/_snippets/snippets_termFromJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_termToJsonObject.js +1 -1
- package/dist/generators/ts/_snippets/snippets_typedLiteralToJsonObject.js +1 -1
- package/dist/input/input.shaclmate.d.ts +2474 -2124
- package/dist/input/input.shaclmate.js +558 -1292
- package/dist/input/input.shaclmate.ttl +9 -5
- package/package.json +20 -16
- package/dist/generators/ts/_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_schemaExpression.d.ts +0 -4
- package/dist/generators/ts/_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_schemaExpression.js +0 -37
- package/dist/generators/ts/_snippets/snippets_FromJsonObjectFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_FromJsonObjectFunction.js +0 -21
- package/dist/generators/ts/_snippets/snippets_FromJsonValueFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_FromJsonValueFunction.js +0 -21
- package/dist/generators/ts/_snippets/snippets_ToJsonObjectFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_ToJsonObjectFunction.js +0 -3
- package/dist/generators/ts/_snippets/snippets_ToJsonValueFunction.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_ToJsonValueFunction.js +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToInIri.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToInIri.js +0 -11
- package/dist/generators/ts/_snippets/snippets_convertToInIriIdentifierProperty.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToInIriIdentifierProperty.js +0 -17
|
@@ -37,13 +37,13 @@ export class AbstractLazyType extends AbstractType {
|
|
|
37
37
|
get fromJsonObjectFunction() {
|
|
38
38
|
return new InlineCallable(code `(jsonObject, fromJsonObjectOptions) => ${this.partialType.fromJsonObjectFunction.annotatedUsage}(jsonObject, { ...fromJsonObjectOptions, schema: fromJsonObjectOptions.schema.partialType })
|
|
39
39
|
.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromJsonObjectOptions` } })} }))`, {
|
|
40
|
-
type: code `${this.reusables.snippets.
|
|
40
|
+
type: code `${this.reusables.snippets.FromJsonFunction}<${this.jsonObjectType.expression}, ${this.expression}, ${this.schema}>`,
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
get fromJsonValueFunction() {
|
|
44
44
|
return new InlineCallable(code `(jsonValue, fromJsonValueOptions) => ${this.partialType.fromJsonValueFunction.annotatedUsage}(jsonValue, { ...fromJsonValueOptions, schema: fromJsonValueOptions.schema.partialType })
|
|
45
45
|
.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: ${this.resolverFunctionExpression({ variables: { factoryFunctionOptions: code `fromJsonValueOptions` } })} }))`, {
|
|
46
|
-
type: code `${this.reusables.snippets.
|
|
46
|
+
type: code `${this.reusables.snippets.FromJsonFunction}<${this.jsonValueType.expression}, ${this.expression}, ${this.schema}>`,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
get fromRdfResourceValuesFunction() {
|
|
@@ -92,12 +92,12 @@ export class AbstractLazyType extends AbstractType {
|
|
|
92
92
|
}
|
|
93
93
|
get toJsonObjectFunction() {
|
|
94
94
|
return new InlineCallable(code `(value) => ${this.partialType.toJsonObjectFunction.unannotatedUsage}(value.${this.runtimeClass.partialPropertyName})`, {
|
|
95
|
-
type: code `${this.reusables.snippets.
|
|
95
|
+
type: code `${this.reusables.snippets.ToJsonFunction}<${this.expression}, ${this.jsonValueType.expression}>`,
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
get toJsonValueFunction() {
|
|
99
99
|
return new InlineCallable(code `(value) => ${this.partialType.toJsonValueFunction.unannotatedUsage}(value.${this.runtimeClass.partialPropertyName})`, {
|
|
100
|
-
type: code `${this.reusables.snippets.
|
|
100
|
+
type: code `${this.reusables.snippets.ToJsonFunction}<${this.expression}, ${this.jsonValueType.expression}>`,
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
get toRdfResourceValueTypes() {
|
|
@@ -151,7 +151,7 @@ export class AbstractStructuredType extends AbstractType {
|
|
|
151
151
|
return code `${this.reusables.snippets.FilterFunction}<${this.filterType}, ${this.expression}>`;
|
|
152
152
|
}
|
|
153
153
|
fromJsonObjectFunctionType() {
|
|
154
|
-
return code `${this.reusables.snippets.
|
|
154
|
+
return code `${this.reusables.snippets.FromJsonFunction}<${this.jsonObjectType.expression}, ${this.expression}, undefined>`;
|
|
155
155
|
}
|
|
156
156
|
fromRdfResourceValuesFunctionType() {
|
|
157
157
|
return code `${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.schemaType}>`;
|
|
@@ -210,7 +210,7 @@ export class AbstractStructuredType extends AbstractType {
|
|
|
210
210
|
return staticModuleDeclarations;
|
|
211
211
|
}
|
|
212
212
|
toJsonObjectFunctionType() {
|
|
213
|
-
return code `${this.reusables.snippets.
|
|
213
|
+
return code `${this.reusables.snippets.ToJsonFunction}<${this.expression}, ${this.jsonObjectType.expression}>`;
|
|
214
214
|
}
|
|
215
215
|
toLoggableFunctionType() {
|
|
216
216
|
return code `${this.reusables.snippets.ToLoggableFunction}<${this.expression}>`;
|
|
@@ -36,6 +36,7 @@ export declare class Imports {
|
|
|
36
36
|
readonly NTriplesTerm: import("ts-poet/build/Import.js").Import;
|
|
37
37
|
readonly Quad: import("ts-poet/build/Import.js").Import;
|
|
38
38
|
readonly Quad_Graph: import("ts-poet/build/Import.js").Import;
|
|
39
|
+
readonly PrefixMap: import("ts-poet/build/Import.js").Import;
|
|
39
40
|
readonly RdfxResourcePropertyPath: import("ts-poet/build/Import.js").Import;
|
|
40
41
|
readonly Resource: import("ts-poet/build/Import.js").Import;
|
|
41
42
|
readonly ResourceSet: import("ts-poet/build/Import.js").Import;
|
|
@@ -37,6 +37,7 @@ export class Imports {
|
|
|
37
37
|
NTriplesTerm = imp("NTriplesTerm@@rdfx/string");
|
|
38
38
|
Quad = imp("t:Quad@@rdfjs/types");
|
|
39
39
|
Quad_Graph = imp("t:Quad_Graph@@rdfjs/types");
|
|
40
|
+
PrefixMap = imp("t:PrefixMap@@rdfx/collection");
|
|
40
41
|
RdfxResourcePropertyPath = imp("PropertyPath:RdfxResourcePropertyPath@@rdfx/resource");
|
|
41
42
|
Resource = imp("Resource@@rdfx/resource");
|
|
42
43
|
ResourceSet = imp("ResourceSet@@rdfx/resource");
|
|
@@ -19,10 +19,20 @@ export class IriType extends AbstractIdentifierType {
|
|
|
19
19
|
schemaType = code `${this.reusables.snippets.IriSchema}<${this.valueTypeExpression}>`;
|
|
20
20
|
valueSparqlWherePatternsFunction = new ReferenceCallable(this.reusables.snippets.iriSparqlWherePatterns);
|
|
21
21
|
get fromJsonValueFunction() {
|
|
22
|
-
|
|
22
|
+
if (this.in_.length > 0) {
|
|
23
|
+
return new ReferenceCallable(code `${this.reusables.snippets.iriLiteralFromJsonString}<${this.valueTypeExpression}>`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
return new ReferenceCallable(this.reusables.snippets.iriFromJsonString);
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
get fromJsonObjectFunction() {
|
|
25
|
-
|
|
30
|
+
if (this.in_.length > 0) {
|
|
31
|
+
return new ReferenceCallable(code `${this.reusables.snippets.iriLiteralFromJsonObject}<${this.valueTypeExpression}>`);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
return new ReferenceCallable(this.reusables.snippets.iriFromJsonObject);
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
get toJsonValueFunction() {
|
|
28
38
|
return new ReferenceCallable(code `${this.reusables.snippets.iriToJsonString}<${this.valueTypeExpression}>`);
|
|
@@ -53,7 +63,7 @@ export class IriType extends AbstractIdentifierType {
|
|
|
53
63
|
invariant(this.jsTypes.length === 1);
|
|
54
64
|
return Maybe.of({
|
|
55
65
|
code: this.in_.length > 0
|
|
56
|
-
? code `${this.reusables.snippets.
|
|
66
|
+
? code `${this.reusables.snippets.convertToIriLiteral}<${this.valueTypeExpression}>`
|
|
57
67
|
: code `${this.reusables.snippets.convertToIri}`,
|
|
58
68
|
sourceTypes: [
|
|
59
69
|
{
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import type { Maybe } from "purify-ts";
|
|
2
|
-
import { ObjectDiscriminatedUnionType_schemaExpression } from "./_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_schemaExpression.js";
|
|
3
2
|
import { AbstractDiscriminatedUnionType } from "./AbstractDiscriminatedUnionType.js";
|
|
4
3
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
5
4
|
import type { Callable } from "./Callable.js";
|
|
6
5
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
7
6
|
import type { IriType } from "./IriType.js";
|
|
7
|
+
import type { ObjectIntersectionType } from "./ObjectIntersectionType.js";
|
|
8
8
|
import type { ObjectType } from "./ObjectType.js";
|
|
9
9
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
10
|
-
export declare class ObjectDiscriminatedUnionType extends AbstractDiscriminatedUnionType<
|
|
11
|
-
protected schemaExpression: typeof ObjectDiscriminatedUnionType_schemaExpression;
|
|
10
|
+
export declare class ObjectDiscriminatedUnionType extends AbstractDiscriminatedUnionType<ObjectDiscriminatedUnionType.MemberType> {
|
|
12
11
|
readonly identifierType: BlankNodeType | IdentifierType | IriType;
|
|
13
12
|
readonly kind = "ObjectDiscriminatedUnion";
|
|
14
13
|
constructor({ identifierType, ...superParameters }: {
|
|
15
14
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
16
|
-
} & ConstructorParameters<typeof AbstractDiscriminatedUnionType<
|
|
15
|
+
} & ConstructorParameters<typeof AbstractDiscriminatedUnionType<ObjectDiscriminatedUnionType.MemberType>>[0]);
|
|
17
16
|
get focusSparqlConstructTriplesFunction(): Callable;
|
|
18
17
|
get focusSparqlWherePatternsFunction(): Callable;
|
|
19
18
|
get fromRdfResourceFunction(): Callable;
|
|
19
|
+
get fromRdfTypeVariables(): readonly Code[];
|
|
20
20
|
get identifierTypeAlias(): Code;
|
|
21
21
|
get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
|
|
22
22
|
get sparqlConstructQueryFunction(): Callable;
|
|
@@ -26,4 +26,7 @@ export declare class ObjectDiscriminatedUnionType extends AbstractDiscriminatedU
|
|
|
26
26
|
protected get inlineExpression(): Code;
|
|
27
27
|
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
28
28
|
}
|
|
29
|
+
export declare namespace ObjectDiscriminatedUnionType {
|
|
30
|
+
type MemberType = ObjectDiscriminatedUnionType | ObjectIntersectionType | ObjectType;
|
|
31
|
+
}
|
|
29
32
|
//# sourceMappingURL=ObjectDiscriminatedUnionType.d.ts.map
|
|
@@ -10,7 +10,6 @@ import { ObjectDiscriminatedUnionType_focusSparqlConstructTriplesFunction } from
|
|
|
10
10
|
import { ObjectDiscriminatedUnionType_focusSparqlWherePatternsFunction } from "./_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_focusSparqlWherePatternsFunction.js";
|
|
11
11
|
import { ObjectDiscriminatedUnionType_fromRdfResourceFunction } from "./_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_fromRdfResourceFunction.js";
|
|
12
12
|
import { ObjectDiscriminatedUnionType_graphqlTypeExpression } from "./_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_graphqlTypeExpression.js";
|
|
13
|
-
import { ObjectDiscriminatedUnionType_schemaExpression } from "./_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_schemaExpression.js";
|
|
14
13
|
import { ObjectDiscriminatedUnionType_toRdfResourceFunction } from "./_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_toRdfResourceFunction.js";
|
|
15
14
|
import { ObjectDiscriminatedUnionType_typeGuardFunction } from "./_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_typeGuardFunction.js";
|
|
16
15
|
import { ObjectType_identifierTypeDeclarations } from "./_ObjectType/ObjectType_identifierTypeDeclarations.js";
|
|
@@ -21,7 +20,6 @@ import { AbstractDiscriminatedUnionType } from "./AbstractDiscriminatedUnionType
|
|
|
21
20
|
import { DeclaredCallable } from "./DeclaredCallable.js";
|
|
22
21
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
23
22
|
export class ObjectDiscriminatedUnionType extends AbstractDiscriminatedUnionType {
|
|
24
|
-
schemaExpression = ObjectDiscriminatedUnionType_schemaExpression;
|
|
25
23
|
identifierType;
|
|
26
24
|
kind = "ObjectDiscriminatedUnion";
|
|
27
25
|
constructor({ identifierType, ...superParameters }) {
|
|
@@ -37,6 +35,21 @@ export class ObjectDiscriminatedUnionType extends AbstractDiscriminatedUnionType
|
|
|
37
35
|
get fromRdfResourceFunction() {
|
|
38
36
|
return ObjectDiscriminatedUnionType_fromRdfResourceFunction.call(this);
|
|
39
37
|
}
|
|
38
|
+
get fromRdfTypeVariables() {
|
|
39
|
+
return this.members.flatMap((member) => {
|
|
40
|
+
switch (member.type.kind) {
|
|
41
|
+
case "Object":
|
|
42
|
+
return member.type.fromRdfTypeVariable.toList();
|
|
43
|
+
case "ObjectDiscriminatedUnion":
|
|
44
|
+
return member.type.fromRdfTypeVariables;
|
|
45
|
+
case "ObjectIntersection":
|
|
46
|
+
return [];
|
|
47
|
+
default:
|
|
48
|
+
member.type;
|
|
49
|
+
throw new RangeError("should never reach this point");
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
40
53
|
get identifierTypeAlias() {
|
|
41
54
|
return this.name.map((name) => code `${name}.Identifier`).unsafeCoerce();
|
|
42
55
|
}
|
|
@@ -121,6 +134,9 @@ __decorate([
|
|
|
121
134
|
__decorate([
|
|
122
135
|
Memoize()
|
|
123
136
|
], ObjectDiscriminatedUnionType.prototype, "fromRdfResourceFunction", null);
|
|
137
|
+
__decorate([
|
|
138
|
+
Memoize()
|
|
139
|
+
], ObjectDiscriminatedUnionType.prototype, "fromRdfTypeVariables", null);
|
|
124
140
|
__decorate([
|
|
125
141
|
Memoize()
|
|
126
142
|
], ObjectDiscriminatedUnionType.prototype, "identifierTypeAlias", null);
|
|
@@ -10,7 +10,7 @@ import type { IdentifierType } from "./IdentifierType.js";
|
|
|
10
10
|
import type { IriType } from "./IriType.js";
|
|
11
11
|
import type { ObjectType } from "./ObjectType.js";
|
|
12
12
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
13
|
-
export declare class ObjectIntersectionType extends AbstractIntersectionType<
|
|
13
|
+
export declare class ObjectIntersectionType extends AbstractIntersectionType<ObjectIntersectionType.MemberType> {
|
|
14
14
|
protected fromJsonObjectFunctionExpression: typeof ObjectIntersectionType_fromJsonObjectFunctionExpression;
|
|
15
15
|
protected fromJsonObjectFunctionType: typeof ObjectIntersectionType_fromJsonObjectFunctionType;
|
|
16
16
|
protected fromRdfResourceValuesFunctionExpression: typeof ObjectIntersectionType_fromRdfResourceValuesFunctionExpression;
|
|
@@ -22,7 +22,7 @@ export declare class ObjectIntersectionType extends AbstractIntersectionType<Obj
|
|
|
22
22
|
readonly kind = "ObjectIntersection";
|
|
23
23
|
constructor({ identifierType, ...superParameters }: {
|
|
24
24
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
25
|
-
} & ConstructorParameters<typeof AbstractIntersectionType<
|
|
25
|
+
} & ConstructorParameters<typeof AbstractIntersectionType<ObjectIntersectionType.MemberType>>[0]);
|
|
26
26
|
get _fromRdfResourceFunction(): Callable;
|
|
27
27
|
get _toRdfResourceFunction(): Callable;
|
|
28
28
|
get createFunction(): Callable;
|
|
@@ -31,8 +31,8 @@ export declare class ObjectIntersectionType extends AbstractIntersectionType<Obj
|
|
|
31
31
|
get focusSparqlWherePatternsFunction(): Callable;
|
|
32
32
|
get fromRdfResourceFunction(): Callable;
|
|
33
33
|
get identifierTypeAlias(): Code;
|
|
34
|
-
get jsonObjectType(): AbstractIntersectionType<
|
|
35
|
-
get jsonValueType(): AbstractIntersectionType<
|
|
34
|
+
get jsonObjectType(): AbstractIntersectionType<ObjectIntersectionType.MemberType>["jsonObjectType"];
|
|
35
|
+
get jsonValueType(): AbstractIntersectionType<ObjectIntersectionType.MemberType>["jsonValueType"];
|
|
36
36
|
get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
|
|
37
37
|
get sparqlConstructQueryFunction(): Callable;
|
|
38
38
|
get sparqlConstructQueryStringFunction(): Callable;
|
|
@@ -41,4 +41,7 @@ export declare class ObjectIntersectionType extends AbstractIntersectionType<Obj
|
|
|
41
41
|
protected get createUnsafeFunction(): Callable;
|
|
42
42
|
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
43
43
|
}
|
|
44
|
+
export declare namespace ObjectIntersectionType {
|
|
45
|
+
type MemberType = ObjectIntersectionType | ObjectType;
|
|
46
|
+
}
|
|
44
47
|
//# sourceMappingURL=ObjectIntersectionType.d.ts.map
|
|
@@ -4,10 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Maybe } from "purify-ts";
|
|
8
7
|
import { Memoize } from "typescript-memoize";
|
|
9
8
|
import { AbstractObjectSetType } from "./AbstractObjectSetType.js";
|
|
10
|
-
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
9
|
+
import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
|
|
11
10
|
export class RdfjsDatasetObjectSetType extends AbstractObjectSetType {
|
|
12
11
|
get declaration() {
|
|
13
12
|
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
@@ -87,30 +86,42 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
87
86
|
}`,
|
|
88
87
|
// objectsSync has per-object type logic, not just forwarding
|
|
89
88
|
];
|
|
90
|
-
const runtimeObjectType = (
|
|
91
|
-
|
|
89
|
+
const runtimeObjectType = (namedObjectType, options) => {
|
|
90
|
+
let fromRdfTypeVariables;
|
|
91
|
+
switch (namedObjectType.kind) {
|
|
92
|
+
case "Object":
|
|
93
|
+
fromRdfTypeVariables =
|
|
94
|
+
namedObjectType.fromRdfTypeVariable.toList();
|
|
95
|
+
break;
|
|
96
|
+
case "ObjectDiscriminatedUnion":
|
|
97
|
+
fromRdfTypeVariables = namedObjectType.fromRdfTypeVariables;
|
|
98
|
+
break;
|
|
99
|
+
case "ObjectIntersection":
|
|
100
|
+
fromRdfTypeVariables = [];
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return code `{ filter: ${(options?.filterFunction ?? namedObjectType.filterFunction).annotatedUsage}, fromRdfResource: ${namedObjectType.expression}.fromRdfResource, fromRdfTypes: ${arrayOf(...fromRdfTypeVariables)} }`;
|
|
92
104
|
};
|
|
93
105
|
switch (namedObjectType.kind) {
|
|
94
106
|
case "Object": {
|
|
95
107
|
return delegatingMethods.concat(code `\
|
|
96
108
|
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.expression}[]> {
|
|
97
|
-
return this.#objectsSync<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType
|
|
109
|
+
return this.#objectsSync<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType)}, query);
|
|
98
110
|
}`);
|
|
99
111
|
}
|
|
100
112
|
case "ObjectDiscriminatedUnion":
|
|
101
113
|
return delegatingMethods.concat(code `\
|
|
102
114
|
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.expression}[]> {
|
|
103
115
|
return this.#objectDiscriminatedUnionsSync<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>([
|
|
104
|
-
${joinCode(namedObjectType.members.map((member) => runtimeObjectType(
|
|
116
|
+
${joinCode(namedObjectType.members.map((member) => runtimeObjectType(member.type, {
|
|
117
|
+
filterFunction: namedObjectType.filterFunction,
|
|
118
|
+
})), { on: ", " })}
|
|
105
119
|
], query);
|
|
106
120
|
}`);
|
|
107
121
|
case "ObjectIntersection":
|
|
108
122
|
return delegatingMethods.concat(code `\
|
|
109
123
|
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.expression}[]> {
|
|
110
|
-
return this.#objectsSync<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType
|
|
111
|
-
expression: namedObjectType.expression,
|
|
112
|
-
fromRdfTypeVariable: Maybe.empty(),
|
|
113
|
-
})}, query);
|
|
124
|
+
return this.#objectsSync<${namedObjectType.expression}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType)}, query);
|
|
114
125
|
}`);
|
|
115
126
|
default:
|
|
116
127
|
namedObjectType;
|
|
@@ -30,8 +30,7 @@ export declare class Snippets {
|
|
|
30
30
|
get FilterFunction(): Snippet;
|
|
31
31
|
get FocusSparqlConstructTriplesFunction(): Snippet;
|
|
32
32
|
get FocusSparqlWherePatternsFunction(): Snippet;
|
|
33
|
-
get
|
|
34
|
-
get FromJsonValueFunction(): Snippet;
|
|
33
|
+
get FromJsonFunction(): Snippet;
|
|
35
34
|
get FromRdfResourceFunction(): Snippet;
|
|
36
35
|
get FromRdfResourceValuesFunction(): Snippet;
|
|
37
36
|
get HashFunction(): Snippet;
|
|
@@ -70,8 +69,7 @@ export declare class Snippets {
|
|
|
70
69
|
get TermFilter(): Snippet;
|
|
71
70
|
get TermJsonObject(): Snippet;
|
|
72
71
|
get TermSchema(): Snippet;
|
|
73
|
-
get
|
|
74
|
-
get ToJsonValueFunction(): Snippet;
|
|
72
|
+
get ToJsonFunction(): Snippet;
|
|
75
73
|
get ToLoggableFunction(): Snippet;
|
|
76
74
|
get ToRdfResourceFunction(): Snippet;
|
|
77
75
|
get ToRdfResourceValuesFunction(): Snippet;
|
|
@@ -120,10 +118,10 @@ export declare class Snippets {
|
|
|
120
118
|
get convertToBlankNodeIdentifierProperty(): Snippet;
|
|
121
119
|
get convertToIdentifier(): Snippet;
|
|
122
120
|
get convertToIdentifierProperty(): Snippet;
|
|
123
|
-
get convertToInIri(): Snippet;
|
|
124
|
-
get convertToInIriIdentifierProperty(): Snippet;
|
|
125
121
|
get convertToIri(): Snippet;
|
|
126
122
|
get convertToIriIdentifierProperty(): Snippet;
|
|
123
|
+
get convertToIriLiteral(): Snippet;
|
|
124
|
+
get convertToIriLiteralIdentifierProperty(): Snippet;
|
|
127
125
|
get convertToLangString(): Snippet;
|
|
128
126
|
get convertToLazy(): Snippet;
|
|
129
127
|
get convertToLazyOption(): Snippet;
|
|
@@ -191,6 +189,9 @@ export declare class Snippets {
|
|
|
191
189
|
get iriFromJsonObject(): Snippet;
|
|
192
190
|
get iriFromJsonString(): Snippet;
|
|
193
191
|
get iriFromRdfResourceValues(): Snippet;
|
|
192
|
+
get iriFromString(): Snippet;
|
|
193
|
+
get iriLiteralFromJsonObject(): Snippet;
|
|
194
|
+
get iriLiteralFromJsonString(): Snippet;
|
|
194
195
|
get iriSparqlWherePatterns(): Snippet;
|
|
195
196
|
get iriToJsonObject(): Snippet;
|
|
196
197
|
get iriToJsonString(): Snippet;
|
|
@@ -24,8 +24,7 @@ import { snippets_EqualsResult } from "./_snippets/snippets_EqualsResult.js";
|
|
|
24
24
|
import { snippets_FilterFunction } from "./_snippets/snippets_FilterFunction.js";
|
|
25
25
|
import { snippets_FocusSparqlConstructTriplesFunction } from "./_snippets/snippets_FocusSparqlConstructTriplesFunction.js";
|
|
26
26
|
import { snippets_FocusSparqlWherePatternsFunction } from "./_snippets/snippets_FocusSparqlWherePatternsFunction.js";
|
|
27
|
-
import {
|
|
28
|
-
import { snippets_FromJsonValueFunction } from "./_snippets/snippets_FromJsonValueFunction.js";
|
|
27
|
+
import { snippets_FromJsonFunction } from "./_snippets/snippets_FromJsonFunction.js";
|
|
29
28
|
import { snippets_FromRdfResourceFunction } from "./_snippets/snippets_FromRdfResourceFunction.js";
|
|
30
29
|
import { snippets_FromRdfResourceValuesFunction } from "./_snippets/snippets_FromRdfResourceValuesFunction.js";
|
|
31
30
|
import { snippets_HashFunction } from "./_snippets/snippets_HashFunction.js";
|
|
@@ -64,8 +63,7 @@ import { snippets_StringSchema } from "./_snippets/snippets_StringSchema.js";
|
|
|
64
63
|
import { snippets_TermFilter } from "./_snippets/snippets_TermFilter.js";
|
|
65
64
|
import { snippets_TermJsonObject } from "./_snippets/snippets_TermJsonObject.js";
|
|
66
65
|
import { snippets_TermSchema } from "./_snippets/snippets_TermSchema.js";
|
|
67
|
-
import {
|
|
68
|
-
import { snippets_ToJsonValueFunction } from "./_snippets/snippets_ToJsonValueFunction.js";
|
|
66
|
+
import { snippets_ToJsonFunction } from "./_snippets/snippets_ToJsonFunction.js";
|
|
69
67
|
import { snippets_ToLoggableFunction } from "./_snippets/snippets_ToLoggableFunction.js";
|
|
70
68
|
import { snippets_ToRdfResourceFunction } from "./_snippets/snippets_ToRdfResourceFunction.js";
|
|
71
69
|
import { snippets_ToRdfResourceValuesFunction } from "./_snippets/snippets_ToRdfResourceValuesFunction.js";
|
|
@@ -114,10 +112,10 @@ import { snippets_convertToBlankNode } from "./_snippets/snippets_convertToBlank
|
|
|
114
112
|
import { snippets_convertToBlankNodeIdentifierProperty } from "./_snippets/snippets_convertToBlankNodeIdentifierProperty.js";
|
|
115
113
|
import { snippets_convertToIdentifier } from "./_snippets/snippets_convertToIdentifier.js";
|
|
116
114
|
import { snippets_convertToIdentifierProperty } from "./_snippets/snippets_convertToIdentifierProperty.js";
|
|
117
|
-
import { snippets_convertToInIri } from "./_snippets/snippets_convertToInIri.js";
|
|
118
|
-
import { snippets_convertToInIriIdentifierProperty } from "./_snippets/snippets_convertToInIriIdentifierProperty.js";
|
|
119
115
|
import { snippets_convertToIri } from "./_snippets/snippets_convertToIri.js";
|
|
120
116
|
import { snippets_convertToIriIdentifierProperty } from "./_snippets/snippets_convertToIriIdentifierProperty.js";
|
|
117
|
+
import { snippets_convertToIriLiteral } from "./_snippets/snippets_convertToIriLiteral.js";
|
|
118
|
+
import { snippets_convertToIriLiteralIdentifierProperty } from "./_snippets/snippets_convertToIriLiteralIdentifierProperty.js";
|
|
121
119
|
import { snippets_convertToLangString } from "./_snippets/snippets_convertToLangString.js";
|
|
122
120
|
import { snippets_convertToLazy } from "./_snippets/snippets_convertToLazy.js";
|
|
123
121
|
import { snippets_convertToLazyOption } from "./_snippets/snippets_convertToLazyOption.js";
|
|
@@ -185,6 +183,9 @@ import { snippets_intFromRdfResourceValues } from "./_snippets/snippets_intFromR
|
|
|
185
183
|
import { snippets_iriFromJsonObject } from "./_snippets/snippets_iriFromJsonObject.js";
|
|
186
184
|
import { snippets_iriFromJsonString } from "./_snippets/snippets_iriFromJsonString.js";
|
|
187
185
|
import { snippets_iriFromRdfResourceValues } from "./_snippets/snippets_iriFromRdfResourceValues.js";
|
|
186
|
+
import { snippets_iriFromString } from "./_snippets/snippets_iriFromString.js";
|
|
187
|
+
import { snippets_iriLiteralFromJsonObject } from "./_snippets/snippets_iriLiteralFromJsonObject.js";
|
|
188
|
+
import { snippets_iriLiteralFromJsonString } from "./_snippets/snippets_iriLiteralFromJsonString.js";
|
|
188
189
|
import { snippets_iriSparqlWherePatterns } from "./_snippets/snippets_iriSparqlWherePatterns.js";
|
|
189
190
|
import { snippets_iriToJsonObject } from "./_snippets/snippets_iriToJsonObject.js";
|
|
190
191
|
import { snippets_iriToJsonString } from "./_snippets/snippets_iriToJsonString.js";
|
|
@@ -313,11 +314,8 @@ export class Snippets {
|
|
|
313
314
|
get FocusSparqlWherePatternsFunction() {
|
|
314
315
|
return this.snippet(snippets_FocusSparqlWherePatternsFunction);
|
|
315
316
|
}
|
|
316
|
-
get
|
|
317
|
-
return this.snippet(
|
|
318
|
-
}
|
|
319
|
-
get FromJsonValueFunction() {
|
|
320
|
-
return this.snippet(snippets_FromJsonValueFunction);
|
|
317
|
+
get FromJsonFunction() {
|
|
318
|
+
return this.snippet(snippets_FromJsonFunction);
|
|
321
319
|
}
|
|
322
320
|
get FromRdfResourceFunction() {
|
|
323
321
|
return this.snippet(snippets_FromRdfResourceFunction);
|
|
@@ -433,11 +431,8 @@ export class Snippets {
|
|
|
433
431
|
get TermSchema() {
|
|
434
432
|
return this.snippet(snippets_TermSchema);
|
|
435
433
|
}
|
|
436
|
-
get
|
|
437
|
-
return this.snippet(
|
|
438
|
-
}
|
|
439
|
-
get ToJsonValueFunction() {
|
|
440
|
-
return this.snippet(snippets_ToJsonValueFunction);
|
|
434
|
+
get ToJsonFunction() {
|
|
435
|
+
return this.snippet(snippets_ToJsonFunction);
|
|
441
436
|
}
|
|
442
437
|
get ToLoggableFunction() {
|
|
443
438
|
return this.snippet(snippets_ToLoggableFunction);
|
|
@@ -583,18 +578,18 @@ export class Snippets {
|
|
|
583
578
|
get convertToIdentifierProperty() {
|
|
584
579
|
return this.snippet(snippets_convertToIdentifierProperty);
|
|
585
580
|
}
|
|
586
|
-
get convertToInIri() {
|
|
587
|
-
return this.snippet(snippets_convertToInIri);
|
|
588
|
-
}
|
|
589
|
-
get convertToInIriIdentifierProperty() {
|
|
590
|
-
return this.snippet(snippets_convertToInIriIdentifierProperty);
|
|
591
|
-
}
|
|
592
581
|
get convertToIri() {
|
|
593
582
|
return this.snippet(snippets_convertToIri);
|
|
594
583
|
}
|
|
595
584
|
get convertToIriIdentifierProperty() {
|
|
596
585
|
return this.snippet(snippets_convertToIriIdentifierProperty);
|
|
597
586
|
}
|
|
587
|
+
get convertToIriLiteral() {
|
|
588
|
+
return this.snippet(snippets_convertToIriLiteral);
|
|
589
|
+
}
|
|
590
|
+
get convertToIriLiteralIdentifierProperty() {
|
|
591
|
+
return this.snippet(snippets_convertToIriLiteralIdentifierProperty);
|
|
592
|
+
}
|
|
598
593
|
get convertToLangString() {
|
|
599
594
|
return this.snippet(snippets_convertToLangString);
|
|
600
595
|
}
|
|
@@ -796,6 +791,15 @@ export class Snippets {
|
|
|
796
791
|
get iriFromRdfResourceValues() {
|
|
797
792
|
return this.snippet(snippets_iriFromRdfResourceValues);
|
|
798
793
|
}
|
|
794
|
+
get iriFromString() {
|
|
795
|
+
return this.snippet(snippets_iriFromString);
|
|
796
|
+
}
|
|
797
|
+
get iriLiteralFromJsonObject() {
|
|
798
|
+
return this.snippet(snippets_iriLiteralFromJsonObject);
|
|
799
|
+
}
|
|
800
|
+
get iriLiteralFromJsonString() {
|
|
801
|
+
return this.snippet(snippets_iriLiteralFromJsonString);
|
|
802
|
+
}
|
|
799
803
|
get iriSparqlWherePatterns() {
|
|
800
804
|
return this.snippet(snippets_iriSparqlWherePatterns);
|
|
801
805
|
}
|
|
@@ -1119,10 +1123,7 @@ __decorate([
|
|
|
1119
1123
|
], Snippets.prototype, "FocusSparqlWherePatternsFunction", null);
|
|
1120
1124
|
__decorate([
|
|
1121
1125
|
Memoize()
|
|
1122
|
-
], Snippets.prototype, "
|
|
1123
|
-
__decorate([
|
|
1124
|
-
Memoize()
|
|
1125
|
-
], Snippets.prototype, "FromJsonValueFunction", null);
|
|
1126
|
+
], Snippets.prototype, "FromJsonFunction", null);
|
|
1126
1127
|
__decorate([
|
|
1127
1128
|
Memoize()
|
|
1128
1129
|
], Snippets.prototype, "FromRdfResourceFunction", null);
|
|
@@ -1239,10 +1240,7 @@ __decorate([
|
|
|
1239
1240
|
], Snippets.prototype, "TermSchema", null);
|
|
1240
1241
|
__decorate([
|
|
1241
1242
|
Memoize()
|
|
1242
|
-
], Snippets.prototype, "
|
|
1243
|
-
__decorate([
|
|
1244
|
-
Memoize()
|
|
1245
|
-
], Snippets.prototype, "ToJsonValueFunction", null);
|
|
1243
|
+
], Snippets.prototype, "ToJsonFunction", null);
|
|
1246
1244
|
__decorate([
|
|
1247
1245
|
Memoize()
|
|
1248
1246
|
], Snippets.prototype, "ToLoggableFunction", null);
|
|
@@ -1389,16 +1387,16 @@ __decorate([
|
|
|
1389
1387
|
], Snippets.prototype, "convertToIdentifierProperty", null);
|
|
1390
1388
|
__decorate([
|
|
1391
1389
|
Memoize()
|
|
1392
|
-
], Snippets.prototype, "
|
|
1390
|
+
], Snippets.prototype, "convertToIri", null);
|
|
1393
1391
|
__decorate([
|
|
1394
1392
|
Memoize()
|
|
1395
|
-
], Snippets.prototype, "
|
|
1393
|
+
], Snippets.prototype, "convertToIriIdentifierProperty", null);
|
|
1396
1394
|
__decorate([
|
|
1397
1395
|
Memoize()
|
|
1398
|
-
], Snippets.prototype, "
|
|
1396
|
+
], Snippets.prototype, "convertToIriLiteral", null);
|
|
1399
1397
|
__decorate([
|
|
1400
1398
|
Memoize()
|
|
1401
|
-
], Snippets.prototype, "
|
|
1399
|
+
], Snippets.prototype, "convertToIriLiteralIdentifierProperty", null);
|
|
1402
1400
|
__decorate([
|
|
1403
1401
|
Memoize()
|
|
1404
1402
|
], Snippets.prototype, "convertToLangString", null);
|
|
@@ -1600,6 +1598,15 @@ __decorate([
|
|
|
1600
1598
|
__decorate([
|
|
1601
1599
|
Memoize()
|
|
1602
1600
|
], Snippets.prototype, "iriFromRdfResourceValues", null);
|
|
1601
|
+
__decorate([
|
|
1602
|
+
Memoize()
|
|
1603
|
+
], Snippets.prototype, "iriFromString", null);
|
|
1604
|
+
__decorate([
|
|
1605
|
+
Memoize()
|
|
1606
|
+
], Snippets.prototype, "iriLiteralFromJsonObject", null);
|
|
1607
|
+
__decorate([
|
|
1608
|
+
Memoize()
|
|
1609
|
+
], Snippets.prototype, "iriLiteralFromJsonString", null);
|
|
1603
1610
|
__decorate([
|
|
1604
1611
|
Memoize()
|
|
1605
1612
|
], Snippets.prototype, "iriSparqlWherePatterns", null);
|
|
@@ -86,23 +86,12 @@ export class TypeFactory {
|
|
|
86
86
|
return cachedType;
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
const objectDiscriminatedUnionIdentifierType = this.createIdentifierType(ast.StructCompoundType.identifierType(astType));
|
|
89
|
+
const objectDiscriminatedUnionIdentifierType = this.createIdentifierType(ast.StructCompoundType.identifierType(astType).unsafeCoerce());
|
|
90
90
|
const objectDiscriminatedUnionTypeName = astType.name.map((name) => this.tsName(name));
|
|
91
91
|
const objectDiscriminatedUnionType = new ObjectDiscriminatedUnionType({
|
|
92
92
|
...this.constructorParameters,
|
|
93
93
|
comment: astType.comment,
|
|
94
|
-
identifierProperty:
|
|
95
|
-
astType.members.every((member) => {
|
|
96
|
-
switch (member.type.kind) {
|
|
97
|
-
case "DiscriminatedUnion":
|
|
98
|
-
return member.type.members.every((member) => member.type.identifierField.isJust());
|
|
99
|
-
case "Struct":
|
|
100
|
-
return member.type.identifierField.isJust();
|
|
101
|
-
default:
|
|
102
|
-
member.type;
|
|
103
|
-
throw new Error("should never reach this point");
|
|
104
|
-
}
|
|
105
|
-
})
|
|
94
|
+
identifierProperty: ast.StructCompoundType.hasIdentifierField(astType)
|
|
106
95
|
? Maybe.of(new ObjectType.IdentifierProperty({
|
|
107
96
|
...this.constructorParameters,
|
|
108
97
|
name: `${this.configuration.syntheticNamePrefix}identifier`,
|
|
@@ -112,10 +101,16 @@ export class TypeFactory {
|
|
|
112
101
|
: Maybe.empty(),
|
|
113
102
|
identifierType: objectDiscriminatedUnionIdentifierType,
|
|
114
103
|
label: astType.label,
|
|
115
|
-
members:
|
|
116
|
-
|
|
117
|
-
type
|
|
118
|
-
|
|
104
|
+
members: astType.members.map((member) => {
|
|
105
|
+
const type = this.createType(member.type);
|
|
106
|
+
invariant(type.kind === "ObjectDiscriminatedUnion" ||
|
|
107
|
+
type.kind === "ObjectIntersection" ||
|
|
108
|
+
type.kind === "Object", type.kind);
|
|
109
|
+
return {
|
|
110
|
+
discriminantValue: Maybe.empty(),
|
|
111
|
+
type: type,
|
|
112
|
+
};
|
|
113
|
+
}),
|
|
119
114
|
name: objectDiscriminatedUnionTypeName,
|
|
120
115
|
recursive: astType.recursive,
|
|
121
116
|
shapeIdentifier: astType.shapeIdentifier,
|
|
@@ -132,23 +127,12 @@ export class TypeFactory {
|
|
|
132
127
|
return cachedType;
|
|
133
128
|
}
|
|
134
129
|
}
|
|
135
|
-
const objectIntersectionIdentifierType = this.createIdentifierType(ast.StructCompoundType.identifierType(astType));
|
|
130
|
+
const objectIntersectionIdentifierType = this.createIdentifierType(ast.StructCompoundType.identifierType(astType).unsafeCoerce());
|
|
136
131
|
const objectIntersectionTypeName = astType.name.map((name) => this.tsName(name));
|
|
137
132
|
const objectIntersectionType = new ObjectIntersectionType({
|
|
138
133
|
...this.constructorParameters,
|
|
139
134
|
comment: astType.comment,
|
|
140
|
-
identifierProperty:
|
|
141
|
-
astType.members.every((member) => {
|
|
142
|
-
switch (member.type.kind) {
|
|
143
|
-
case "Intersection":
|
|
144
|
-
return member.type.members.every((member) => member.type.identifierField.isJust());
|
|
145
|
-
case "Struct":
|
|
146
|
-
return member.type.identifierField.isJust();
|
|
147
|
-
default:
|
|
148
|
-
member.type;
|
|
149
|
-
throw new Error("should never reach this point");
|
|
150
|
-
}
|
|
151
|
-
})
|
|
135
|
+
identifierProperty: ast.StructCompoundType.hasIdentifierField(astType)
|
|
152
136
|
? Maybe.of(new ObjectType.IdentifierProperty({
|
|
153
137
|
...this.constructorParameters,
|
|
154
138
|
name: `${this.configuration.syntheticNamePrefix}identifier`,
|
|
@@ -158,9 +142,11 @@ export class TypeFactory {
|
|
|
158
142
|
: Maybe.empty(),
|
|
159
143
|
identifierType: objectIntersectionIdentifierType,
|
|
160
144
|
label: astType.label,
|
|
161
|
-
members:
|
|
162
|
-
type
|
|
163
|
-
|
|
145
|
+
members: astType.members.map((member) => {
|
|
146
|
+
const type = this.createType(member.type);
|
|
147
|
+
invariant(type.kind === "ObjectIntersection" || type.kind === "Object", type.kind);
|
|
148
|
+
return { type };
|
|
149
|
+
}),
|
|
164
150
|
name: objectIntersectionTypeName,
|
|
165
151
|
recursive: astType.recursive,
|
|
166
152
|
shapeIdentifier: astType.shapeIdentifier,
|
package/dist/generators/ts/_ObjectIntersectionType/ObjectIntersectionType_fromJsonObjectFunction.js
CHANGED
|
@@ -10,6 +10,6 @@ ${member.type.fromJsonObjectFunction.unannotatedUsage}(jsonObject).${memberI + 1
|
|
|
10
10
|
.toList()), { on: "," })} }) ${")".repeat(this.members.length)}`;
|
|
11
11
|
}
|
|
12
12
|
export function ObjectIntersectionType_fromJsonObjectFunctionType() {
|
|
13
|
-
return code `${this.reusables.snippets.
|
|
13
|
+
return code `${this.reusables.snippets.FromJsonFunction}<${this.jsonObjectType.expression}, ${this.discriminatedType.map((discriminatedType) => discriminatedType.expression).orDefault(this.expression)}, undefined>`;
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=ObjectIntersectionType_fromJsonObjectFunction.js.map
|
|
@@ -108,7 +108,7 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
|
|
|
108
108
|
conversionFunction = code `${this.reusables.snippets.convertToBlankNodeIdentifierProperty}`;
|
|
109
109
|
}
|
|
110
110
|
else if (this.type.in_.length > 0) {
|
|
111
|
-
conversionFunction = code `${this.reusables.snippets.
|
|
111
|
+
conversionFunction = code `${this.reusables.snippets.convertToIriLiteralIdentifierProperty}<${joinCode(this.type.in_.map((in_) => code `${literalOf(in_.value)}`), { on: " | " })}>`;
|
|
112
112
|
}
|
|
113
113
|
else {
|
|
114
114
|
conversionFunction = code `${this.reusables.snippets.convertToIriIdentifierProperty}`;
|
|
@@ -10,10 +10,15 @@ export function ObjectType_fromJsonObjectFunctionExpression() {
|
|
|
10
10
|
};
|
|
11
11
|
const propertyInitializers = this.properties.flatMap((property) => property.fromJsonObjectInitializer({ variables }).toList());
|
|
12
12
|
invariant(propertyInitializers.length > 0);
|
|
13
|
+
let optionsParameter = optionsVariable;
|
|
14
|
+
this.name.ifNothing(() => {
|
|
15
|
+
optionsParameter = code `${optionsParameter}: Parameters<${ObjectType_fromJsonObjectFunctionType.call(this)}>[1]`;
|
|
16
|
+
});
|
|
17
|
+
optionsParameter = code `${optionsParameter} = {}`;
|
|
13
18
|
return code `\
|
|
14
|
-
(${variables.jsonObject}, ${
|
|
19
|
+
(${variables.jsonObject}, ${optionsParameter}) => ${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyInitializers, { on: "," })} }).chain(${this.createFunction.annotatedUsage})`;
|
|
15
20
|
}
|
|
16
21
|
export function ObjectType_fromJsonObjectFunctionType() {
|
|
17
|
-
return code `${this.reusables.snippets.
|
|
22
|
+
return code `${this.reusables.snippets.FromJsonFunction}<${this.jsonObjectType.expression}, ${this.discriminatedType.map((discriminatedType) => discriminatedType.expression).orDefault(this.expression)}, undefined>`;
|
|
18
23
|
}
|
|
19
24
|
//# sourceMappingURL=ObjectType_fromJsonObjectFunction.js.map
|
|
@@ -11,6 +11,6 @@ export function ObjectType_toJsonObjectFunctionExpression() {
|
|
|
11
11
|
.toList()), { on: "," })} }))`;
|
|
12
12
|
}
|
|
13
13
|
export function ObjectType_toJsonObjectFunctionType() {
|
|
14
|
-
return code `${this.reusables.snippets.
|
|
14
|
+
return code `${this.reusables.snippets.ToJsonFunction}<${this.expression}, ${this.jsonObjectType.expression}>`;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=ObjectType_toJsonObjectFunction.js.map
|