@shaclmate/compiler 4.0.79 → 4.0.81
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/ast/AbstractCompoundType.d.ts +1 -1
- package/dist/ast/AbstractCompoundType.js +1 -1
- package/dist/ast/AbstractContainerType.d.ts +1 -1
- package/dist/ast/AbstractContainerType.js +1 -1
- package/dist/ast/ListType.d.ts +1 -1
- package/dist/ast/ListType.js +1 -1
- package/dist/ast/Type.d.ts +1 -1
- package/dist/ast/Type.js +2 -2
- package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
- package/dist/generators/ts/AbstractContainerType.js +2 -2
- package/dist/generators/ts/AbstractDiscriminatedUnionType.d.ts +74 -0
- package/dist/generators/ts/AbstractDiscriminatedUnionType.js +430 -0
- package/dist/generators/ts/DiscriminatedUnionType.d.ts +3 -71
- package/dist/generators/ts/DiscriminatedUnionType.js +2 -428
- package/dist/generators/ts/ListType.d.ts +1 -1
- package/dist/generators/ts/ListType.js +1 -1
- package/dist/generators/ts/ObjectDiscriminatedUnionType.d.ts +2 -3
- package/dist/generators/ts/ObjectDiscriminatedUnionType.js +2 -10
- package/dist/generators/ts/Type.d.ts +1 -1
- package/dist/generators/ts/TypeFactory.d.ts +1 -1
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_Discriminant.d.ts → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_Discriminant.d.ts} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_Discriminant.js +2 -0
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_conversionFunctionExpression.d.ts +6 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_conversionFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_conversionFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_equalsFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_equalsFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_equalsFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_filterFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_filterFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_filterFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_filterTypeExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_filterTypeExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_filterTypeExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromJsonFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_fromJsonFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromJsonFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_hashFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_hashFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_hashFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inferDiscriminant.d.ts +8 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_inferDiscriminant.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inferDiscriminant.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inlineExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_inlineExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inlineExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_jsonSchemaExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_jsonSchemaExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_jsonSchemaExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_jsonTypeLiteral.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_jsonTypeLiteral.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_jsonTypeLiteral.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_schemaTypeExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toJsonFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_toJsonFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toJsonFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toRdfResourceValuesFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_toRdfResourceValuesFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toRdfResourceValuesFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toStringFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_toStringFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toStringFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.js} +2 -2
- package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.d.ts +5 -0
- package/dist/generators/ts/{_DiscriminatedUnionType/DiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.js → _AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.js} +2 -2
- package/package.json +46 -44
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_Discriminant.js +0 -2
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_conversionFunctionExpression.d.ts +0 -6
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_equalsFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_filterFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_filterTypeExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_fromJsonFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_hashFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_inferDiscriminant.d.ts +0 -8
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_inlineExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_jsonSchemaExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_jsonTypeLiteral.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_schemaTypeExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_toJsonFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_toRdfResourceValuesFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_toStringFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.d.ts +0 -5
- package/dist/generators/ts/_DiscriminatedUnionType/DiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.d.ts +0 -5
|
@@ -39,7 +39,7 @@ export declare namespace AbstractCompoundType {
|
|
|
39
39
|
interface Member<TypeT extends MemberType> {
|
|
40
40
|
readonly type: TypeT;
|
|
41
41
|
}
|
|
42
|
-
type MemberType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType
|
|
42
|
+
type MemberType = BlankNodeType | DiscriminatedUnionType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType;
|
|
43
43
|
function isMemberType(type: Type): type is MemberType;
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=AbstractCompoundType.d.ts.map
|
|
@@ -58,6 +58,7 @@ __decorate([
|
|
|
58
58
|
function isMemberType(type) {
|
|
59
59
|
switch (type.kind) {
|
|
60
60
|
case "BlankNode":
|
|
61
|
+
case "DiscriminatedUnion":
|
|
61
62
|
case "Identifier":
|
|
62
63
|
case "Intersection":
|
|
63
64
|
case "Iri":
|
|
@@ -65,7 +66,6 @@ __decorate([
|
|
|
65
66
|
case "Literal":
|
|
66
67
|
case "Struct":
|
|
67
68
|
case "Term":
|
|
68
|
-
case "DiscriminatedUnion":
|
|
69
69
|
return true;
|
|
70
70
|
case "DefaultValue":
|
|
71
71
|
case "LazyOption":
|
|
@@ -38,7 +38,7 @@ export declare abstract class AbstractContainerType<ItemTypeT extends AbstractCo
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
export declare namespace AbstractContainerType {
|
|
41
|
-
type ItemType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType
|
|
41
|
+
type ItemType = BlankNodeType | DiscriminatedUnionType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType;
|
|
42
42
|
function isItemType(type: Type): type is ItemType;
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=AbstractContainerType.d.ts.map
|
|
@@ -40,6 +40,7 @@ export class AbstractContainerType extends AbstractType {
|
|
|
40
40
|
function isItemType(type) {
|
|
41
41
|
switch (type.kind) {
|
|
42
42
|
case "BlankNode":
|
|
43
|
+
case "DiscriminatedUnion":
|
|
43
44
|
case "Identifier":
|
|
44
45
|
case "Intersection":
|
|
45
46
|
case "Iri":
|
|
@@ -47,7 +48,6 @@ export class AbstractContainerType extends AbstractType {
|
|
|
47
48
|
case "Literal":
|
|
48
49
|
case "Struct":
|
|
49
50
|
case "Term":
|
|
50
|
-
case "DiscriminatedUnion":
|
|
51
51
|
return true;
|
|
52
52
|
case "DefaultValue":
|
|
53
53
|
case "LazyOption":
|
package/dist/ast/ListType.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class ListType<ItemTypeT extends ListType.ItemType = ListType.Ite
|
|
|
38
38
|
equals(other: ListType<ItemTypeT>): boolean;
|
|
39
39
|
}
|
|
40
40
|
export declare namespace ListType {
|
|
41
|
-
type ItemType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType
|
|
41
|
+
type ItemType = BlankNodeType | DiscriminatedUnionType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType;
|
|
42
42
|
function isItemType(type: Type): type is ItemType;
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=ListType.d.ts.map
|
package/dist/ast/ListType.js
CHANGED
|
@@ -33,6 +33,7 @@ export class ListType extends AbstractCollectionType {
|
|
|
33
33
|
function isItemType(type) {
|
|
34
34
|
switch (type.kind) {
|
|
35
35
|
case "BlankNode":
|
|
36
|
+
case "DiscriminatedUnion":
|
|
36
37
|
case "Identifier":
|
|
37
38
|
case "Intersection":
|
|
38
39
|
case "Iri":
|
|
@@ -40,7 +41,6 @@ export class ListType extends AbstractCollectionType {
|
|
|
40
41
|
case "Literal":
|
|
41
42
|
case "Struct":
|
|
42
43
|
case "Term":
|
|
43
|
-
case "DiscriminatedUnion":
|
|
44
44
|
return true;
|
|
45
45
|
case "DefaultValue":
|
|
46
46
|
case "LazyOption":
|
package/dist/ast/Type.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import type { OptionType } from "./OptionType.js";
|
|
|
13
13
|
import type { SetType } from "./SetType.js";
|
|
14
14
|
import type { StructType } from "./StructType.js";
|
|
15
15
|
import type { TermType } from "./TermType.js";
|
|
16
|
-
export type Type = BlankNodeType | DefaultValueType | IdentifierType | IntersectionType | IriType | LazyOptionType | LazySetType | LazyType | ListType | LiteralType | StructType | OptionType | SetType | TermType
|
|
16
|
+
export type Type = BlankNodeType | DefaultValueType | DiscriminatedUnionType | IdentifierType | IntersectionType | IriType | LazyOptionType | LazySetType | LazyType | ListType | LiteralType | StructType | OptionType | SetType | TermType;
|
|
17
17
|
export declare namespace Type {
|
|
18
18
|
function equals(left: Type, right: Type): boolean;
|
|
19
19
|
}
|
package/dist/ast/Type.js
CHANGED
|
@@ -9,6 +9,8 @@ export var Type;
|
|
|
9
9
|
return left.equals(right);
|
|
10
10
|
case "DefaultValue":
|
|
11
11
|
return left.equals(right);
|
|
12
|
+
case "DiscriminatedUnion":
|
|
13
|
+
return left.equals(right);
|
|
12
14
|
case "Identifier":
|
|
13
15
|
return left.equals(right);
|
|
14
16
|
case "Intersection":
|
|
@@ -31,8 +33,6 @@ export var Type;
|
|
|
31
33
|
return left.equals(right);
|
|
32
34
|
case "Term":
|
|
33
35
|
return left.equals(right);
|
|
34
|
-
case "DiscriminatedUnion":
|
|
35
|
-
return left.equals(right);
|
|
36
36
|
case "Set":
|
|
37
37
|
return left.equals(right);
|
|
38
38
|
}
|
|
@@ -44,7 +44,7 @@ export declare namespace AbstractContainerType {
|
|
|
44
44
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
45
45
|
const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
46
46
|
type GraphqlType = AbstractType.GraphqlType;
|
|
47
|
-
type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | LangStringType | ListType<ListType.ItemType> | LiteralType | ObjectDiscriminatedUnionType | ObjectType | StringType | TermType
|
|
47
|
+
type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | DiscriminatedUnionType | FloatType | IdentifierType | IntType | IriType | LangStringType | ListType<ListType.ItemType> | LiteralType | ObjectDiscriminatedUnionType | ObjectType | StringType | TermType;
|
|
48
48
|
function isItemType(type: Type): type is ItemType;
|
|
49
49
|
const JsonType: typeof import("./_AbstractType/AbstractType_JsonType.js").AbstractType_JsonType;
|
|
50
50
|
type JsonType = AbstractType.JsonType;
|
|
@@ -66,8 +66,9 @@ __decorate([
|
|
|
66
66
|
case "BigInt":
|
|
67
67
|
case "BlankNode":
|
|
68
68
|
case "Boolean":
|
|
69
|
-
case "DateTime":
|
|
70
69
|
case "Date":
|
|
70
|
+
case "DateTime":
|
|
71
|
+
case "DiscriminatedUnion":
|
|
71
72
|
case "Float":
|
|
72
73
|
case "Identifier":
|
|
73
74
|
case "Int":
|
|
@@ -79,7 +80,6 @@ __decorate([
|
|
|
79
80
|
case "ObjectDiscriminatedUnion":
|
|
80
81
|
case "String":
|
|
81
82
|
case "Term":
|
|
82
|
-
case "DiscriminatedUnion":
|
|
83
83
|
return true;
|
|
84
84
|
case "DefaultValue":
|
|
85
85
|
case "LazyOption":
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { AbstractDiscriminatedUnionType_Discriminant } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_Discriminant.js";
|
|
3
|
+
import { AbstractType } from "./AbstractType.js";
|
|
4
|
+
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
5
|
+
import type { IdentifierType } from "./IdentifierType.js";
|
|
6
|
+
import type { IriType } from "./IriType.js";
|
|
7
|
+
import type { Type } from "./Type.js";
|
|
8
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
9
|
+
export declare abstract class AbstractDiscriminatedUnionType<MemberTypeT extends Type> extends AbstractType {
|
|
10
|
+
protected readonly discriminant: AbstractDiscriminatedUnionType.Discriminant;
|
|
11
|
+
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
12
|
+
readonly identifierType: Maybe<BlankNodeType | IdentifierType | IriType>;
|
|
13
|
+
abstract readonly kind: "ObjectDiscriminatedUnion" | "DiscriminatedUnion";
|
|
14
|
+
readonly recursive: boolean;
|
|
15
|
+
readonly validationFunction: Maybe<Code>;
|
|
16
|
+
constructor({ identifierType, members, recursive, ...superParameters }: {
|
|
17
|
+
identifierType: Maybe<BlankNodeType | IdentifierType | IriType>;
|
|
18
|
+
members: readonly (Pick<AbstractDiscriminatedUnionType.Member<MemberTypeT>, "type"> & {
|
|
19
|
+
readonly discriminantValue: Maybe<number | string>;
|
|
20
|
+
})[];
|
|
21
|
+
recursive: boolean;
|
|
22
|
+
synthetic: boolean;
|
|
23
|
+
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
24
|
+
get conversionFunction(): Maybe<AbstractType.ConversionFunction>;
|
|
25
|
+
get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
|
|
26
|
+
get equalsFunction(): Code;
|
|
27
|
+
get filterFunction(): Code;
|
|
28
|
+
get filterType(): Code;
|
|
29
|
+
get fromRdfResourceValuesFunction(): Code;
|
|
30
|
+
get graphqlType(): AbstractType.GraphqlType;
|
|
31
|
+
get hashFunction(): Code;
|
|
32
|
+
get jsTypes(): AbstractType["jsTypes"];
|
|
33
|
+
get jsonSchemaFunctionDeclaration(): Code;
|
|
34
|
+
get jsonTypeAliasDeclaration(): Code;
|
|
35
|
+
get members(): readonly AbstractDiscriminatedUnionType.Member<MemberTypeT>[];
|
|
36
|
+
get mutable(): boolean;
|
|
37
|
+
get referencesNamedType(): boolean;
|
|
38
|
+
get schemaType(): Code;
|
|
39
|
+
get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
|
|
40
|
+
get valueSparqlConstructTriplesFunction(): Code;
|
|
41
|
+
get valueSparqlWherePatternsFunction(): Code;
|
|
42
|
+
protected get inlineExpression(): Code;
|
|
43
|
+
protected get schemaInitializers(): readonly Code[];
|
|
44
|
+
private get conversionFunctionExpression();
|
|
45
|
+
fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
|
|
46
|
+
graphqlResolveExpression({ variables, }: {
|
|
47
|
+
variables: {
|
|
48
|
+
value: Code;
|
|
49
|
+
};
|
|
50
|
+
}): Code;
|
|
51
|
+
jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
52
|
+
jsonType(): AbstractType.JsonType;
|
|
53
|
+
jsonUiSchemaElement(): Maybe<Code>;
|
|
54
|
+
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
55
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
56
|
+
toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
|
|
57
|
+
protected staticModuleDeclarations(name: string): Record<string, Code>;
|
|
58
|
+
private readonly lazyMembers;
|
|
59
|
+
}
|
|
60
|
+
export declare namespace AbstractDiscriminatedUnionType {
|
|
61
|
+
type Discriminant = AbstractDiscriminatedUnionType_Discriminant;
|
|
62
|
+
interface Member<TypeT extends Type> {
|
|
63
|
+
readonly discriminantValues: readonly AbstractType.DiscriminantProperty.Value[];
|
|
64
|
+
readonly jsonType: Code;
|
|
65
|
+
readonly jsonTypeCheck: (instance: Code) => Code;
|
|
66
|
+
readonly primaryDiscriminantValue: AbstractType.DiscriminantProperty.Value;
|
|
67
|
+
readonly type: TypeT;
|
|
68
|
+
readonly typeCheck: (instance: Code) => Code;
|
|
69
|
+
readonly typeToJsonExpression: (valueVariable: Code) => Code;
|
|
70
|
+
readonly unwrap: (instance: Code) => Code;
|
|
71
|
+
readonly wrap: (instance: Code) => Code;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=AbstractDiscriminatedUnionType.d.ts.map
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Maybe } from "purify-ts";
|
|
8
|
+
import { invariant } from "ts-invariant";
|
|
9
|
+
import { Memoize } from "typescript-memoize";
|
|
10
|
+
import { AbstractDiscriminatedUnionType_conversionFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_conversionFunctionExpression.js";
|
|
11
|
+
import { AbstractDiscriminatedUnionType_equalsFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_equalsFunctionExpression.js";
|
|
12
|
+
import { AbstractDiscriminatedUnionType_filterFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_filterFunctionExpression.js";
|
|
13
|
+
import { AbstractDiscriminatedUnionType_filterTypeExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_filterTypeExpression.js";
|
|
14
|
+
import { AbstractDiscriminatedUnionType_fromJsonFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromJsonFunctionExpression.js";
|
|
15
|
+
import { AbstractDiscriminatedUnionType_fromRdfResourceValuesFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.js";
|
|
16
|
+
import { AbstractDiscriminatedUnionType_hashFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_hashFunctionExpression.js";
|
|
17
|
+
import { AbstractDiscriminatedUnionType_inferDiscriminant } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inferDiscriminant.js";
|
|
18
|
+
import { AbstractDiscriminatedUnionType_inlineExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inlineExpression.js";
|
|
19
|
+
import { AbstractDiscriminatedUnionType_jsonSchemaExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_jsonSchemaExpression.js";
|
|
20
|
+
import { AbstractDiscriminatedUnionType_jsonTypeLiteral } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_jsonTypeLiteral.js";
|
|
21
|
+
import { AbstractDiscriminatedUnionType_schemaTypeExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.js";
|
|
22
|
+
import { AbstractDiscriminatedUnionType_toJsonFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toJsonFunctionExpression.js";
|
|
23
|
+
import { AbstractDiscriminatedUnionType_toRdfResourceValuesFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toRdfResourceValuesFunctionExpression.js";
|
|
24
|
+
import { AbstractDiscriminatedUnionType_toStringFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toStringFunctionExpression.js";
|
|
25
|
+
import { AbstractDiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.js";
|
|
26
|
+
import { AbstractDiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression } from "./_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.js";
|
|
27
|
+
import { AbstractType } from "./AbstractType.js";
|
|
28
|
+
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
29
|
+
export class AbstractDiscriminatedUnionType extends AbstractType {
|
|
30
|
+
discriminant;
|
|
31
|
+
graphqlArgs = Maybe.empty();
|
|
32
|
+
identifierType;
|
|
33
|
+
recursive;
|
|
34
|
+
validationFunction = Maybe.empty();
|
|
35
|
+
constructor({ identifierType, members, recursive, ...superParameters }) {
|
|
36
|
+
super(superParameters);
|
|
37
|
+
this.identifierType = identifierType;
|
|
38
|
+
invariant(members.length >= 2);
|
|
39
|
+
this.recursive = recursive;
|
|
40
|
+
this.discriminant = AbstractDiscriminatedUnionType_inferDiscriminant.call(this, members);
|
|
41
|
+
this.lazyMembers = () => members.map((member, memberI) => {
|
|
42
|
+
let discriminantValues;
|
|
43
|
+
switch (this.discriminant.kind) {
|
|
44
|
+
case "Extrinsic":
|
|
45
|
+
discriminantValues = [this.discriminant.memberValues[memberI]];
|
|
46
|
+
break;
|
|
47
|
+
case "Hybrid":
|
|
48
|
+
discriminantValues = this.discriminant.memberValues[memberI].values;
|
|
49
|
+
break;
|
|
50
|
+
case "Intrinsic": {
|
|
51
|
+
discriminantValues =
|
|
52
|
+
member.type.discriminantProperty.unsafeCoerce().values;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
case "Typeof":
|
|
56
|
+
discriminantValues = [this.discriminant.memberValues[memberI]];
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
throw this.discriminant;
|
|
60
|
+
}
|
|
61
|
+
invariant(discriminantValues.length > 0);
|
|
62
|
+
const typeCheck = (json) => (instance) => {
|
|
63
|
+
const discriminant = this.discriminant; // To get type narrowing to work
|
|
64
|
+
if (discriminant.kind === "Typeof") {
|
|
65
|
+
return code `(${joinCode(discriminantValues.map((discriminantValue) => code `typeof ${instance} === ${literalOf(discriminantValue)}`), { on: " || " })})`;
|
|
66
|
+
}
|
|
67
|
+
// Causes problems in mixed Object | other dicriminated unions
|
|
68
|
+
// if (discriminant.kind === "Intrinsic" && !json) {
|
|
69
|
+
// switch (member.type.kind) {
|
|
70
|
+
// case "Object":
|
|
71
|
+
// case "ObjectDiscriminatedUnion":
|
|
72
|
+
// return code`${member.type.name.unsafeCoerce()}.is${member.type.name.unsafeCoerce()}(${instance})`;
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
const discriminantName = json
|
|
76
|
+
? discriminant.jsonName
|
|
77
|
+
: discriminant.name;
|
|
78
|
+
return code `(${joinCode(discriminantValues.map((discriminantValue) => code `${instance}["${discriminantName}"] === ${literalOf(discriminantValue)}`), { on: " || " })})`;
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
discriminantValues,
|
|
82
|
+
jsonType: member.type.jsonType({
|
|
83
|
+
includeDiscriminantProperty: this.discriminant.kind === "Intrinsic" ||
|
|
84
|
+
(this.discriminant.kind === "Hybrid" &&
|
|
85
|
+
this.discriminant.memberValues[memberI].kind === "Intrinsic"),
|
|
86
|
+
}).expression,
|
|
87
|
+
jsonTypeCheck: typeCheck(true),
|
|
88
|
+
primaryDiscriminantValue: discriminantValues[0],
|
|
89
|
+
type: member.type,
|
|
90
|
+
typeCheck: typeCheck(false),
|
|
91
|
+
typeToJsonExpression: (valueVariable) => member.type.toJsonExpression({
|
|
92
|
+
includeDiscriminantProperty: this.discriminant.kind === "Intrinsic" ||
|
|
93
|
+
(this.discriminant.kind === "Hybrid" &&
|
|
94
|
+
this.discriminant.memberValues[memberI].kind === "Intrinsic"),
|
|
95
|
+
variables: { value: valueVariable },
|
|
96
|
+
}),
|
|
97
|
+
unwrap: (instance) => {
|
|
98
|
+
switch (this.discriminant.kind) {
|
|
99
|
+
case "Extrinsic":
|
|
100
|
+
return code `${instance}.value`;
|
|
101
|
+
case "Hybrid":
|
|
102
|
+
return this.discriminant.memberValues[memberI].kind ===
|
|
103
|
+
"Intrinsic"
|
|
104
|
+
? instance
|
|
105
|
+
: code `${instance}.value`;
|
|
106
|
+
case "Intrinsic":
|
|
107
|
+
case "Typeof":
|
|
108
|
+
return instance;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
wrap: (instance) => {
|
|
112
|
+
switch (this.discriminant.kind) {
|
|
113
|
+
case "Extrinsic":
|
|
114
|
+
return code `{ ${this.discriminant.name}: ${literalOf(discriminantValues[0])} as const, value: ${instance} }`;
|
|
115
|
+
case "Hybrid":
|
|
116
|
+
return this.discriminant.memberValues[memberI].kind ===
|
|
117
|
+
"Intrinsic"
|
|
118
|
+
? instance
|
|
119
|
+
: code `{ ${this.discriminant.name}: ${literalOf(discriminantValues[0])} as const, value: ${instance} }`;
|
|
120
|
+
case "Intrinsic":
|
|
121
|
+
case "Typeof":
|
|
122
|
+
return instance;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
get conversionFunction() {
|
|
129
|
+
if (this.conversionFunctionExpression.isNothing()) {
|
|
130
|
+
return this.conversionFunctionExpression;
|
|
131
|
+
}
|
|
132
|
+
return this.name
|
|
133
|
+
.map((name) => Maybe.of({
|
|
134
|
+
code: code `${name}.convert`,
|
|
135
|
+
sourceTypes: this.conversionFunctionExpression.extract().sourceTypes,
|
|
136
|
+
}))
|
|
137
|
+
.orDefault(this.conversionFunctionExpression);
|
|
138
|
+
}
|
|
139
|
+
get discriminantProperty() {
|
|
140
|
+
switch (this.discriminant.kind) {
|
|
141
|
+
case "Extrinsic":
|
|
142
|
+
return Maybe.of({
|
|
143
|
+
jsonName: this.discriminant.jsonName,
|
|
144
|
+
name: this.discriminant.name,
|
|
145
|
+
values: this.discriminant.memberValues,
|
|
146
|
+
});
|
|
147
|
+
case "Hybrid":
|
|
148
|
+
return Maybe.of({
|
|
149
|
+
jsonName: this.discriminant.jsonName,
|
|
150
|
+
name: "termType",
|
|
151
|
+
values: this.discriminant.memberValues.flatMap((_) => _.values),
|
|
152
|
+
});
|
|
153
|
+
case "Intrinsic":
|
|
154
|
+
return Maybe.of({
|
|
155
|
+
jsonName: this.discriminant.jsonName,
|
|
156
|
+
name: this.discriminant.name,
|
|
157
|
+
values: this.discriminant.memberValues,
|
|
158
|
+
});
|
|
159
|
+
case "Typeof":
|
|
160
|
+
return Maybe.empty();
|
|
161
|
+
default:
|
|
162
|
+
throw this.discriminant;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
get equalsFunction() {
|
|
166
|
+
return this.name
|
|
167
|
+
.map((name) => code `${name}.equals`)
|
|
168
|
+
.orDefault(AbstractDiscriminatedUnionType_equalsFunctionExpression.call(this));
|
|
169
|
+
}
|
|
170
|
+
get filterFunction() {
|
|
171
|
+
return this.name
|
|
172
|
+
.map((name) => code `${name}.filter`)
|
|
173
|
+
.orDefault(AbstractDiscriminatedUnionType_filterFunctionExpression.call(this));
|
|
174
|
+
}
|
|
175
|
+
get filterType() {
|
|
176
|
+
return this.name
|
|
177
|
+
.map((name) => code `${name}.Filter`)
|
|
178
|
+
.orDefault(AbstractDiscriminatedUnionType_filterTypeExpression.call(this));
|
|
179
|
+
}
|
|
180
|
+
get fromRdfResourceValuesFunction() {
|
|
181
|
+
return this.name
|
|
182
|
+
.map((name) => code `${name}.fromRdfResourceValues`)
|
|
183
|
+
.orDefault(AbstractDiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.call(this));
|
|
184
|
+
}
|
|
185
|
+
get graphqlType() {
|
|
186
|
+
const name = this.name.extract();
|
|
187
|
+
if (!name ||
|
|
188
|
+
!this.members.every((member) => member.type.kind === "Object")) {
|
|
189
|
+
throw new Error("not implemented");
|
|
190
|
+
}
|
|
191
|
+
return new AbstractType.GraphqlType(code `${name}.GraphQL`, this.reusables);
|
|
192
|
+
}
|
|
193
|
+
get hashFunction() {
|
|
194
|
+
return this.name
|
|
195
|
+
.map((name) => code `${name}.hash`)
|
|
196
|
+
.orDefault(AbstractDiscriminatedUnionType_hashFunctionExpression.call(this));
|
|
197
|
+
}
|
|
198
|
+
get jsTypes() {
|
|
199
|
+
const jsTypes = [];
|
|
200
|
+
for (const member of this.members) {
|
|
201
|
+
for (const memberJsType of member.type.jsTypes) {
|
|
202
|
+
if (!jsTypes.some((jsType) => AbstractType.JsType.equals(jsType, memberJsType))) {
|
|
203
|
+
jsTypes.push(memberJsType);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return jsTypes;
|
|
208
|
+
}
|
|
209
|
+
get jsonSchemaFunctionDeclaration() {
|
|
210
|
+
let expression = AbstractDiscriminatedUnionType_jsonSchemaExpression.call(this);
|
|
211
|
+
const meta = {
|
|
212
|
+
// id: this.name,
|
|
213
|
+
};
|
|
214
|
+
this.comment.ifJust((description) => {
|
|
215
|
+
meta["description"] = description;
|
|
216
|
+
});
|
|
217
|
+
this.label.ifJust((label) => {
|
|
218
|
+
meta["title"] = label;
|
|
219
|
+
});
|
|
220
|
+
if (Object.keys(meta).length > 0) {
|
|
221
|
+
expression = code `${expression}.meta(${meta})`;
|
|
222
|
+
}
|
|
223
|
+
return code `export const schema = () => ${expression};`;
|
|
224
|
+
}
|
|
225
|
+
get jsonTypeAliasDeclaration() {
|
|
226
|
+
return code `export type Json = ${AbstractDiscriminatedUnionType_jsonTypeLiteral.call(this).expression}`;
|
|
227
|
+
}
|
|
228
|
+
get members() {
|
|
229
|
+
return this.lazyMembers();
|
|
230
|
+
}
|
|
231
|
+
get mutable() {
|
|
232
|
+
return this.members.some((member) => member.type.mutable);
|
|
233
|
+
}
|
|
234
|
+
get referencesNamedType() {
|
|
235
|
+
return (this.name.isJust() ||
|
|
236
|
+
this.members.some((member) => member.type.referencesNamedType));
|
|
237
|
+
}
|
|
238
|
+
get schemaType() {
|
|
239
|
+
return this.name
|
|
240
|
+
.map(() => code `typeof ${this.schema}`)
|
|
241
|
+
.orDefault(AbstractDiscriminatedUnionType_schemaTypeExpression.call(this));
|
|
242
|
+
}
|
|
243
|
+
get toRdfResourceValueTypes() {
|
|
244
|
+
const set = new Set();
|
|
245
|
+
for (const member of this.members) {
|
|
246
|
+
for (const value of member.type.toRdfResourceValueTypes) {
|
|
247
|
+
set.add(value);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return set;
|
|
251
|
+
}
|
|
252
|
+
get valueSparqlConstructTriplesFunction() {
|
|
253
|
+
return this.name
|
|
254
|
+
.map((name) => code `${name}.valueSparqlConstructTriples`)
|
|
255
|
+
.orDefault(AbstractDiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.call(this));
|
|
256
|
+
}
|
|
257
|
+
get valueSparqlWherePatternsFunction() {
|
|
258
|
+
return this.name
|
|
259
|
+
.map((name) => code `${name}.valueSparqlWherePatterns`)
|
|
260
|
+
.orDefault(AbstractDiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.call(this));
|
|
261
|
+
}
|
|
262
|
+
get inlineExpression() {
|
|
263
|
+
return AbstractDiscriminatedUnionType_inlineExpression.call(this);
|
|
264
|
+
}
|
|
265
|
+
get schemaInitializers() {
|
|
266
|
+
return super.schemaInitializers.concat(code `members: { ${joinCode(this.members.map(({ discriminantValues, type, primaryDiscriminantValue }) => code `${literalOf(primaryDiscriminantValue)}: ${{
|
|
267
|
+
discriminantValues: discriminantValues,
|
|
268
|
+
type: type.schema,
|
|
269
|
+
}}`), { on: "," })} }`);
|
|
270
|
+
}
|
|
271
|
+
get conversionFunctionExpression() {
|
|
272
|
+
return AbstractDiscriminatedUnionType_conversionFunctionExpression.call(this);
|
|
273
|
+
}
|
|
274
|
+
fromJsonExpression({ variables, }) {
|
|
275
|
+
return code `${this.name.map((name) => code `${name}.fromJson`).orDefault(AbstractDiscriminatedUnionType_fromJsonFunctionExpression.call(this))}(${variables.value})`;
|
|
276
|
+
}
|
|
277
|
+
graphqlResolveExpression({ variables, }) {
|
|
278
|
+
return variables.value;
|
|
279
|
+
}
|
|
280
|
+
jsonSchema({ context, }) {
|
|
281
|
+
const expression = this.name
|
|
282
|
+
.map((name) => code `${name}.Json.schema()`)
|
|
283
|
+
.orDefault(AbstractDiscriminatedUnionType_jsonSchemaExpression.call(this));
|
|
284
|
+
if (context === "property" && this.recursive) {
|
|
285
|
+
return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.jsonType().expression}> => ${expression})`;
|
|
286
|
+
}
|
|
287
|
+
return expression;
|
|
288
|
+
}
|
|
289
|
+
jsonType() {
|
|
290
|
+
return this.name
|
|
291
|
+
.map((name) => new AbstractType.JsonType(code `${name}.Json`))
|
|
292
|
+
.orDefault(AbstractDiscriminatedUnionType_jsonTypeLiteral.call(this));
|
|
293
|
+
}
|
|
294
|
+
jsonUiSchemaElement() {
|
|
295
|
+
return Maybe.empty();
|
|
296
|
+
}
|
|
297
|
+
toJsonExpression({ variables, }) {
|
|
298
|
+
return code `${this.name.map((name) => code `${name}.toJson`).orDefault(AbstractDiscriminatedUnionType_toJsonFunctionExpression.call(this))}(${variables.value})`;
|
|
299
|
+
}
|
|
300
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
301
|
+
const { value: valueVariable, ...otherVariables } = variables;
|
|
302
|
+
return code `${this.name.map((name) => code `${name}.toRdfResourceValues`).orDefault(AbstractDiscriminatedUnionType_toRdfResourceValuesFunctionExpression.call(this))}(${valueVariable}, ${otherVariables})`;
|
|
303
|
+
}
|
|
304
|
+
toStringExpression({ variables, }) {
|
|
305
|
+
return code `${this.name.map((name) => code `${name}.${this.configuration.syntheticNamePrefix}toString`).orDefault(AbstractDiscriminatedUnionType_toStringFunctionExpression.call(this))}(${variables.value})`;
|
|
306
|
+
}
|
|
307
|
+
staticModuleDeclarations(name) {
|
|
308
|
+
const staticModuleDeclarations = {
|
|
309
|
+
...super.staticModuleDeclarations(name),
|
|
310
|
+
};
|
|
311
|
+
this.conversionFunctionExpression.ifJust((conversionFunction) => {
|
|
312
|
+
staticModuleDeclarations["convert"] =
|
|
313
|
+
code `export const convert = ${conversionFunction.code};`;
|
|
314
|
+
});
|
|
315
|
+
if (this.configuration.features.has("Object.equals")) {
|
|
316
|
+
staticModuleDeclarations["equals"] =
|
|
317
|
+
code `export const equals = ${AbstractDiscriminatedUnionType_equalsFunctionExpression.call(this)};`;
|
|
318
|
+
}
|
|
319
|
+
if (this.configuration.features.has("Object.filter")) {
|
|
320
|
+
staticModuleDeclarations["Filter"] =
|
|
321
|
+
code `export type Filter = ${AbstractDiscriminatedUnionType_filterTypeExpression.call(this)};`;
|
|
322
|
+
staticModuleDeclarations["filter"] =
|
|
323
|
+
code `export const filter = ${AbstractDiscriminatedUnionType_filterFunctionExpression.call(this)};`;
|
|
324
|
+
}
|
|
325
|
+
if (this.configuration.features.has("Object.hash")) {
|
|
326
|
+
staticModuleDeclarations["hash"] =
|
|
327
|
+
code `export const hash = ${AbstractDiscriminatedUnionType_hashFunctionExpression.call(this)};`;
|
|
328
|
+
}
|
|
329
|
+
if (this.configuration.features.has("Object.JSON.type")) {
|
|
330
|
+
staticModuleDeclarations["Json.type"] =
|
|
331
|
+
code `${this.jsonTypeAliasDeclaration}`;
|
|
332
|
+
}
|
|
333
|
+
if (this.configuration.features.has("Object.JSON.schema")) {
|
|
334
|
+
staticModuleDeclarations["Json.namespace"] = code `\
|
|
335
|
+
export namespace Json {
|
|
336
|
+
${this.jsonSchemaFunctionDeclaration}
|
|
337
|
+
|
|
338
|
+
export function parse(json: unknown): ${this.reusables.imports.Either}<Error, Json> {
|
|
339
|
+
const jsonSafeParseResult = schema().safeParse(json);
|
|
340
|
+
if (!jsonSafeParseResult.success) { return ${this.reusables.imports.Left}(jsonSafeParseResult.error); }
|
|
341
|
+
return ${this.reusables.imports.Right}(jsonSafeParseResult.data);
|
|
342
|
+
}
|
|
343
|
+
}`;
|
|
344
|
+
}
|
|
345
|
+
if (this.configuration.features.has("Object.fromJson")) {
|
|
346
|
+
staticModuleDeclarations["fromJson"] =
|
|
347
|
+
code `export const fromJson = ${AbstractDiscriminatedUnionType_fromJsonFunctionExpression.call(this)};`;
|
|
348
|
+
}
|
|
349
|
+
if (this.configuration.features.has("Object.fromRdf")) {
|
|
350
|
+
staticModuleDeclarations["fromRdfResourceValues"] =
|
|
351
|
+
code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${name}, ${this.schemaType}> = ${AbstractDiscriminatedUnionType_fromRdfResourceValuesFunctionExpression.call(this)};`;
|
|
352
|
+
}
|
|
353
|
+
if (this.configuration.features.has("Object.toJson")) {
|
|
354
|
+
staticModuleDeclarations["toJson"] =
|
|
355
|
+
code `export const toJson = ${AbstractDiscriminatedUnionType_toJsonFunctionExpression.call(this)};`;
|
|
356
|
+
}
|
|
357
|
+
if (this.configuration.features.has("Object.toRdf")) {
|
|
358
|
+
staticModuleDeclarations["toRdfResourceValues"] =
|
|
359
|
+
code `export const toRdfResourceValues = ${AbstractDiscriminatedUnionType_toRdfResourceValuesFunctionExpression.call(this)};`;
|
|
360
|
+
}
|
|
361
|
+
if (this.configuration.features.has("Object.SPARQL")) {
|
|
362
|
+
staticModuleDeclarations["valueSparqlConstructTriples"] =
|
|
363
|
+
code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${AbstractDiscriminatedUnionType_valueSparqlConstructTriplesFunctionExpression.call(this)};`;
|
|
364
|
+
staticModuleDeclarations["valueSparqlWherePatterns"] =
|
|
365
|
+
code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${AbstractDiscriminatedUnionType_valueSparqlWherePatternsFunctionExpression.call(this)};`;
|
|
366
|
+
}
|
|
367
|
+
if (this.configuration.features.has("Object.toString")) {
|
|
368
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
369
|
+
staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
|
|
370
|
+
code `export const ${syntheticNamePrefix}toString = ${AbstractDiscriminatedUnionType_toStringFunctionExpression.call(this)};`;
|
|
371
|
+
}
|
|
372
|
+
return staticModuleDeclarations;
|
|
373
|
+
}
|
|
374
|
+
lazyMembers;
|
|
375
|
+
}
|
|
376
|
+
__decorate([
|
|
377
|
+
Memoize()
|
|
378
|
+
], AbstractDiscriminatedUnionType.prototype, "conversionFunction", null);
|
|
379
|
+
__decorate([
|
|
380
|
+
Memoize()
|
|
381
|
+
], AbstractDiscriminatedUnionType.prototype, "discriminantProperty", null);
|
|
382
|
+
__decorate([
|
|
383
|
+
Memoize()
|
|
384
|
+
], AbstractDiscriminatedUnionType.prototype, "equalsFunction", null);
|
|
385
|
+
__decorate([
|
|
386
|
+
Memoize()
|
|
387
|
+
], AbstractDiscriminatedUnionType.prototype, "filterFunction", null);
|
|
388
|
+
__decorate([
|
|
389
|
+
Memoize()
|
|
390
|
+
], AbstractDiscriminatedUnionType.prototype, "filterType", null);
|
|
391
|
+
__decorate([
|
|
392
|
+
Memoize()
|
|
393
|
+
], AbstractDiscriminatedUnionType.prototype, "fromRdfResourceValuesFunction", null);
|
|
394
|
+
__decorate([
|
|
395
|
+
Memoize()
|
|
396
|
+
], AbstractDiscriminatedUnionType.prototype, "graphqlType", null);
|
|
397
|
+
__decorate([
|
|
398
|
+
Memoize()
|
|
399
|
+
], AbstractDiscriminatedUnionType.prototype, "hashFunction", null);
|
|
400
|
+
__decorate([
|
|
401
|
+
Memoize()
|
|
402
|
+
], AbstractDiscriminatedUnionType.prototype, "jsTypes", null);
|
|
403
|
+
__decorate([
|
|
404
|
+
Memoize()
|
|
405
|
+
], AbstractDiscriminatedUnionType.prototype, "members", null);
|
|
406
|
+
__decorate([
|
|
407
|
+
Memoize()
|
|
408
|
+
], AbstractDiscriminatedUnionType.prototype, "mutable", null);
|
|
409
|
+
__decorate([
|
|
410
|
+
Memoize()
|
|
411
|
+
], AbstractDiscriminatedUnionType.prototype, "schemaType", null);
|
|
412
|
+
__decorate([
|
|
413
|
+
Memoize()
|
|
414
|
+
], AbstractDiscriminatedUnionType.prototype, "toRdfResourceValueTypes", null);
|
|
415
|
+
__decorate([
|
|
416
|
+
Memoize()
|
|
417
|
+
], AbstractDiscriminatedUnionType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
418
|
+
__decorate([
|
|
419
|
+
Memoize()
|
|
420
|
+
], AbstractDiscriminatedUnionType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
421
|
+
__decorate([
|
|
422
|
+
Memoize()
|
|
423
|
+
], AbstractDiscriminatedUnionType.prototype, "inlineExpression", null);
|
|
424
|
+
__decorate([
|
|
425
|
+
Memoize()
|
|
426
|
+
], AbstractDiscriminatedUnionType.prototype, "conversionFunctionExpression", null);
|
|
427
|
+
__decorate([
|
|
428
|
+
Memoize()
|
|
429
|
+
], AbstractDiscriminatedUnionType.prototype, "jsonType", null);
|
|
430
|
+
//# sourceMappingURL=AbstractDiscriminatedUnionType.js.map
|