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