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