@shaclmate/compiler 4.0.56 → 4.0.59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.js +5 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +3 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstStructType.js +1 -1
- package/dist/ast/AbstractCompoundType.d.ts +3 -3
- package/dist/ast/AbstractCompoundType.js +1 -1
- package/dist/ast/AbstractContainerType.d.ts +2 -2
- package/dist/ast/AbstractContainerType.js +1 -1
- package/dist/ast/AbstractLazyType.d.ts +2 -2
- package/dist/ast/{UnionType.d.ts → DiscriminatedUnionType.d.ts} +7 -7
- package/dist/ast/{UnionType.js → DiscriminatedUnionType.js} +9 -8
- package/dist/ast/ListType.d.ts +2 -2
- package/dist/ast/ListType.js +1 -1
- package/dist/ast/StructCompoundType.d.ts +2 -2
- package/dist/ast/StructCompoundType.js +1 -1
- package/dist/ast/StructDiscriminatedUnionType.d.ts +4 -0
- package/dist/ast/StructDiscriminatedUnionType.js +2 -0
- package/dist/ast/StructType.js +1 -1
- package/dist/ast/Type.d.ts +2 -2
- package/dist/ast/Type.js +1 -1
- package/dist/ast/index.d.ts +2 -2
- package/dist/ast/index.js +2 -2
- package/dist/generators/transformAstToLabeledPropertyGraph.js +2 -2
- package/dist/generators/ts/AbstractCollectionType.d.ts +2 -2
- package/dist/generators/ts/AbstractContainerType.d.ts +5 -5
- package/dist/generators/ts/AbstractContainerType.js +2 -2
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractLazyType.d.ts +8 -8
- package/dist/generators/ts/AbstractLazyType.js +9 -9
- package/dist/generators/ts/AbstractLiteralType.d.ts +2 -2
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractObjectSetType.d.ts +4 -4
- package/dist/generators/ts/AbstractObjectSetType.js +4 -3
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -2
- package/dist/generators/ts/AbstractTermType.d.ts +2 -2
- package/dist/generators/ts/AbstractType.d.ts +15 -75
- package/dist/generators/ts/AbstractType.js +6 -63
- package/dist/generators/ts/AbstractTypedLiteralType.d.ts +2 -2
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +4 -4
- package/dist/generators/ts/DefaultValueType.js +2 -2
- package/dist/generators/ts/{UnionType.d.ts → DiscriminatedUnionType.d.ts} +6 -6
- package/dist/generators/ts/{UnionType.js → DiscriminatedUnionType.js} +31 -31
- package/dist/generators/ts/FloatType.d.ts +1 -1
- package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
- package/dist/generators/ts/GraphqlSchema.js +5 -4
- package/dist/generators/ts/IntType.d.ts +1 -1
- package/dist/generators/ts/LazyOptionType.d.ts +3 -3
- package/dist/generators/ts/ListType.d.ts +3 -3
- package/dist/generators/ts/ListType.js +2 -2
- package/dist/generators/ts/{ObjectUnionType.d.ts → ObjectDiscriminatedUnionType.d.ts} +4 -4
- package/dist/generators/ts/{ObjectUnionType.js → ObjectDiscriminatedUnionType.js} +8 -8
- package/dist/generators/ts/ObjectSetType.js +1 -1
- package/dist/generators/ts/ObjectType.d.ts +11 -11
- package/dist/generators/ts/ObjectType.js +6 -6
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -5
- package/dist/generators/ts/SparqlObjectSetType.js +4 -1
- package/dist/generators/ts/StringType.d.ts +1 -1
- package/dist/generators/ts/TsGenerator.d.ts +1 -1
- package/dist/generators/ts/TsGenerator.js +19 -19
- package/dist/generators/ts/Type.d.ts +3 -3
- package/dist/generators/ts/TypeFactory.d.ts +5 -5
- package/dist/generators/ts/TypeFactory.js +16 -16
- package/dist/generators/ts/ZodGenerator.js +5 -5
- package/dist/generators/ts/_AbstractType/AbstractType_ConversionFunction.d.ts +10 -0
- package/dist/generators/ts/_AbstractType/AbstractType_ConversionFunction.js +2 -0
- package/dist/generators/ts/_AbstractType/AbstractType_DiscriminantProperty.d.ts +9 -0
- package/dist/generators/ts/_AbstractType/AbstractType_DiscriminantProperty.js +2 -0
- package/dist/generators/ts/_AbstractType/AbstractType_GraphqlType.d.ts +18 -0
- package/dist/generators/ts/_AbstractType/AbstractType_GraphqlType.js +33 -0
- package/dist/generators/ts/_AbstractType/AbstractType_JsType.d.ts +34 -0
- package/dist/generators/ts/_AbstractType/AbstractType_JsType.js +16 -0
- package/dist/generators/ts/_AbstractType/AbstractType_JsonType.d.ts +16 -0
- package/dist/generators/ts/_AbstractType/AbstractType_JsonType.js +31 -0
- package/dist/generators/ts/_ObjectType/{AbstractProperty.d.ts → ObjectType_AbstractProperty.d.ts} +2 -2
- package/dist/generators/ts/_ObjectType/{AbstractProperty.js → ObjectType_AbstractProperty.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.d.ts +45 -0
- package/dist/generators/ts/_ObjectType/{DiscriminantProperty.js → ObjectType_DiscriminantProperty.js} +12 -9
- package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.d.ts +43 -0
- package/dist/generators/ts/_ObjectType/{IdentifierProperty.js → ObjectType_IdentifierProperty.js} +11 -11
- package/dist/generators/ts/_ObjectType/ObjectType_Property.d.ts +6 -0
- package/dist/generators/ts/_ObjectType/ObjectType_Property.js +2 -0
- package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.d.ts +53 -0
- package/dist/generators/ts/_ObjectType/{ShaclProperty.js → ObjectType_ShaclProperty.js} +10 -10
- package/package.json +34 -24
- package/dist/ast/StructUnionType.d.ts +0 -4
- package/dist/ast/StructUnionType.js +0 -2
- package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +0 -45
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +0 -43
- package/dist/generators/ts/_ObjectType/Property.d.ts +0 -6
- package/dist/generators/ts/_ObjectType/Property.js +0 -2
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +0 -53
|
@@ -161,11 +161,11 @@ export function transformPropertyShapeToAstStructTypeField({ propertyShape, stru
|
|
|
161
161
|
switch (astResolveType.kind) {
|
|
162
162
|
case "Struct":
|
|
163
163
|
return Either.of(astResolveType);
|
|
164
|
-
case "
|
|
164
|
+
case "DiscriminatedUnion":
|
|
165
165
|
if (
|
|
166
166
|
// This check relies on .members being populated, which may not happen in cycles
|
|
167
167
|
astResolveType.members.length > 0 &&
|
|
168
|
-
!astResolveType.
|
|
168
|
+
!astResolveType.isStructDiscriminatedUnionType()) {
|
|
169
169
|
return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind} with non-StructType members`));
|
|
170
170
|
}
|
|
171
171
|
return Either.of(astResolveType);
|
|
@@ -207,8 +207,8 @@ export function transformPropertyShapeToAstStructTypeField({ propertyShape, stru
|
|
|
207
207
|
case "Struct":
|
|
208
208
|
astPartialItemType = astItemType;
|
|
209
209
|
break;
|
|
210
|
-
case "
|
|
211
|
-
if (!astItemType.
|
|
210
|
+
case "DiscriminatedUnion":
|
|
211
|
+
if (!astItemType.isStructDiscriminatedUnionType()) {
|
|
212
212
|
return Left(new Error(`${propertyShape} partial type cannot be a ${astItemType.kind} with non-StructType members`));
|
|
213
213
|
}
|
|
214
214
|
astPartialItemType = astItemType;
|
|
@@ -227,7 +227,7 @@ export function transformPropertyShapeToAstStructTypeField({ propertyShape, stru
|
|
|
227
227
|
case "Identifier":
|
|
228
228
|
case "Iri":
|
|
229
229
|
case "Struct":
|
|
230
|
-
case "
|
|
230
|
+
case "DiscriminatedUnion":
|
|
231
231
|
astType = new ast.LazyType({
|
|
232
232
|
...astAbstractTypeProperties,
|
|
233
233
|
partialType: astPartialItemType,
|
|
@@ -25,7 +25,7 @@ export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
|
25
25
|
}
|
|
26
26
|
else if (xoneConstraintShapes.length > 0) {
|
|
27
27
|
memberShapes = xoneConstraintShapes;
|
|
28
|
-
compoundTypeKind = "
|
|
28
|
+
compoundTypeKind = "DiscriminatedUnion";
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
return Either.of(Maybe.empty());
|
|
@@ -34,7 +34,7 @@ export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
|
34
34
|
const memberDiscriminantValues = new Set();
|
|
35
35
|
const compoundType = new (compoundTypeKind === "Intersection"
|
|
36
36
|
? ast.IntersectionType
|
|
37
|
-
: ast.
|
|
37
|
+
: ast.DiscriminatedUnionType)({
|
|
38
38
|
comment: shape.comment,
|
|
39
39
|
label: shape.label,
|
|
40
40
|
name: shapeAstTypeName(shape),
|
|
@@ -61,7 +61,7 @@ export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
|
61
61
|
return Left(new Error(`${shape} has duplicate ${compoundTypeKind} member type: ${memberType}`));
|
|
62
62
|
}
|
|
63
63
|
let memberDiscriminantValue;
|
|
64
|
-
if (compoundTypeKind === "
|
|
64
|
+
if (compoundTypeKind === "DiscriminatedUnion") {
|
|
65
65
|
if (memberShape.$type === "NodeShape") {
|
|
66
66
|
memberDiscriminantValue =
|
|
67
67
|
memberShape.discriminantValue.extract();
|
|
@@ -20,7 +20,7 @@ function isStructTypeFieldRequired(field) {
|
|
|
20
20
|
return false;
|
|
21
21
|
case "Set":
|
|
22
22
|
return field.type.minCount > 0;
|
|
23
|
-
case "
|
|
23
|
+
case "DiscriminatedUnion":
|
|
24
24
|
return field.type.members.every((member) => isStructTypeFieldRequired({ type: member.type }));
|
|
25
25
|
case "BlankNode":
|
|
26
26
|
case "Identifier":
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { NodeKind } from "@shaclmate/shacl-ast";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
3
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
4
|
+
import type { DiscriminatedUnionType } from "./DiscriminatedUnionType.js";
|
|
4
5
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
5
6
|
import type { IntersectionType } from "./IntersectionType.js";
|
|
6
7
|
import type { IriType } from "./IriType.js";
|
|
@@ -9,7 +10,6 @@ import type { LiteralType } from "./LiteralType.js";
|
|
|
9
10
|
import type { StructType } from "./StructType.js";
|
|
10
11
|
import type { TermType } from "./TermType.js";
|
|
11
12
|
import type { Type } from "./Type.js";
|
|
12
|
-
import type { UnionType } from "./UnionType.js";
|
|
13
13
|
/**
|
|
14
14
|
* A compound of types, such as an intersection or union.
|
|
15
15
|
*
|
|
@@ -21,7 +21,7 @@ export declare abstract class AbstractCompoundType<MemberT extends AbstractCompo
|
|
|
21
21
|
/**
|
|
22
22
|
* Type discriminant
|
|
23
23
|
*/
|
|
24
|
-
abstract readonly kind: "Intersection" | "
|
|
24
|
+
abstract readonly kind: "Intersection" | "DiscriminatedUnion";
|
|
25
25
|
/**
|
|
26
26
|
* Was this type synthesized or did it come from SHACL?
|
|
27
27
|
*/
|
|
@@ -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 | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType | DiscriminatedUnionType;
|
|
43
43
|
function isMemberType(type: Type): type is MemberType;
|
|
44
44
|
}
|
|
45
45
|
//# sourceMappingURL=AbstractCompoundType.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { NodeKind } from "@shaclmate/shacl-ast";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
3
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
4
|
+
import type { DiscriminatedUnionType } from "./DiscriminatedUnionType.js";
|
|
4
5
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
5
6
|
import type { IntersectionType } from "./IntersectionType.js";
|
|
6
7
|
import type { IriType } from "./IriType.js";
|
|
@@ -9,7 +10,6 @@ import type { LiteralType } from "./LiteralType.js";
|
|
|
9
10
|
import type { StructType } from "./StructType.js";
|
|
10
11
|
import type { TermType } from "./TermType.js";
|
|
11
12
|
import { Type } from "./Type.js";
|
|
12
|
-
import type { UnionType } from "./UnionType.js";
|
|
13
13
|
/**
|
|
14
14
|
* Abstract base class for types that contain other types e.g., ListType, OptionType, SetType.
|
|
15
15
|
*/
|
|
@@ -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 | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType | DiscriminatedUnionType;
|
|
42
42
|
function isItemType(type: Type): type is ItemType;
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=AbstractContainerType.d.ts.map
|
|
@@ -2,8 +2,8 @@ import type { NodeKind } from "@shaclmate/shacl-ast";
|
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
3
|
import type { OptionType } from "./OptionType.js";
|
|
4
4
|
import type { SetType } from "./SetType.js";
|
|
5
|
+
import type { StructDiscriminatedUnionType } from "./StructDiscriminatedUnionType.js";
|
|
5
6
|
import type { StructType } from "./StructType.js";
|
|
6
|
-
import type { StructUnionType } from "./StructUnionType.js";
|
|
7
7
|
/**
|
|
8
8
|
* Abstract base class of LazyOptionType, LazySetType, and LazyType.
|
|
9
9
|
*/
|
|
@@ -110,7 +110,7 @@ export declare abstract class AbstractLazyType<PartialTypeT extends AbstractLazy
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
export declare namespace AbstractLazyType {
|
|
113
|
-
type ItemTypeConstraint = StructType |
|
|
113
|
+
type ItemTypeConstraint = StructType | StructDiscriminatedUnionType;
|
|
114
114
|
type PartialTypeConstraint = ItemTypeConstraint | OptionType<ItemTypeConstraint> | SetType<ItemTypeConstraint>;
|
|
115
115
|
type ResolveTypeConstraint = PartialTypeConstraint;
|
|
116
116
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { StructDiscriminatedUnionType } from "./StructDiscriminatedUnionType.js";
|
|
4
4
|
/**
|
|
5
5
|
* A disjunction/union of types, corresponding to an sh:xone.
|
|
6
6
|
*/
|
|
7
|
-
export declare class
|
|
8
|
-
readonly kind = "
|
|
9
|
-
|
|
7
|
+
export declare class DiscriminatedUnionType<MemberTypeT extends DiscriminatedUnionType.MemberType = DiscriminatedUnionType.MemberType> extends AbstractCompoundType<DiscriminatedUnionType.Member<MemberTypeT>, MemberTypeT> {
|
|
8
|
+
readonly kind = "DiscriminatedUnion";
|
|
9
|
+
isStructDiscriminatedUnionType(): this is StructDiscriminatedUnionType;
|
|
10
10
|
toJSON(): {
|
|
11
11
|
members: {
|
|
12
12
|
discriminantValue: string | number | undefined;
|
|
@@ -20,11 +20,11 @@ export declare class UnionType<MemberTypeT extends UnionType.MemberType = UnionT
|
|
|
20
20
|
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
export declare namespace
|
|
24
|
-
interface Member<TypeT extends
|
|
23
|
+
export declare namespace DiscriminatedUnionType {
|
|
24
|
+
interface Member<TypeT extends DiscriminatedUnionType.MemberType> extends AbstractCompoundType.Member<TypeT> {
|
|
25
25
|
readonly discriminantValue: Maybe<number | string>;
|
|
26
26
|
}
|
|
27
27
|
type MemberType = AbstractCompoundType.MemberType;
|
|
28
28
|
const isMemberType: typeof AbstractCompoundType.isMemberType;
|
|
29
29
|
}
|
|
30
|
-
//# sourceMappingURL=
|
|
30
|
+
//# sourceMappingURL=DiscriminatedUnionType.d.ts.map
|
|
@@ -2,12 +2,13 @@ import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* A disjunction/union of types, corresponding to an sh:xone.
|
|
4
4
|
*/
|
|
5
|
-
export class
|
|
6
|
-
kind = "
|
|
7
|
-
|
|
5
|
+
export class DiscriminatedUnionType extends AbstractCompoundType {
|
|
6
|
+
kind = "DiscriminatedUnion";
|
|
7
|
+
isStructDiscriminatedUnionType() {
|
|
8
8
|
return (this.members.length > 0 &&
|
|
9
9
|
this.members.every((member) => member.type.kind === "Struct" ||
|
|
10
|
-
(member.type.kind === "
|
|
10
|
+
(member.type.kind === "DiscriminatedUnion" &&
|
|
11
|
+
member.type.isStructDiscriminatedUnionType())));
|
|
11
12
|
}
|
|
12
13
|
toJSON() {
|
|
13
14
|
return {
|
|
@@ -21,7 +22,7 @@ export class UnionType extends AbstractCompoundType {
|
|
|
21
22
|
};
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
|
-
(function (
|
|
25
|
-
|
|
26
|
-
})(
|
|
27
|
-
//# sourceMappingURL=
|
|
25
|
+
(function (DiscriminatedUnionType) {
|
|
26
|
+
DiscriminatedUnionType.isMemberType = AbstractCompoundType.isMemberType;
|
|
27
|
+
})(DiscriminatedUnionType || (DiscriminatedUnionType = {}));
|
|
28
|
+
//# sourceMappingURL=DiscriminatedUnionType.js.map
|
package/dist/ast/ListType.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
|
2
2
|
import type { IdentifierNodeKind } from "@shaclmate/shacl-ast";
|
|
3
3
|
import { AbstractCollectionType } from "./AbstractCollectionType.js";
|
|
4
4
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
5
|
+
import type { DiscriminatedUnionType } from "./DiscriminatedUnionType.js";
|
|
5
6
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
6
7
|
import type { IntersectionType } from "./IntersectionType.js";
|
|
7
8
|
import type { IriType } from "./IriType.js";
|
|
@@ -9,7 +10,6 @@ import type { LiteralType } from "./LiteralType.js";
|
|
|
9
10
|
import type { StructType } from "./StructType.js";
|
|
10
11
|
import type { TermType } from "./TermType.js";
|
|
11
12
|
import type { Type } from "./Type.js";
|
|
12
|
-
import type { UnionType } from "./UnionType.js";
|
|
13
13
|
/**
|
|
14
14
|
* An ordered sequence of items with zero or one values of an item type.
|
|
15
15
|
*
|
|
@@ -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 | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType | DiscriminatedUnionType;
|
|
42
42
|
function isItemType(type: Type): type is ItemType;
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=ListType.d.ts.map
|
package/dist/ast/ListType.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BlankNodeType } from "./BlankNodeType.js";
|
|
2
2
|
import { IdentifierType } from "./IdentifierType.js";
|
|
3
3
|
import { IriType } from "./IriType.js";
|
|
4
|
+
import type { StructDiscriminatedUnionType } from "./StructDiscriminatedUnionType.js";
|
|
4
5
|
import type { StructIntersectionType } from "./StructIntersectionType.js";
|
|
5
6
|
import type { StructType } from "./StructType.js";
|
|
6
|
-
|
|
7
|
-
export type StructCompoundType = StructIntersectionType | StructUnionType;
|
|
7
|
+
export type StructCompoundType = StructIntersectionType | StructDiscriminatedUnionType;
|
|
8
8
|
export declare namespace StructCompoundType {
|
|
9
9
|
function identifierType(objectCompoundType: StructCompoundType): BlankNodeType | IdentifierType | IriType;
|
|
10
10
|
function memberStructTypes(objectCompoundType: StructCompoundType): readonly StructType[];
|
|
@@ -58,7 +58,7 @@ export var StructCompoundType;
|
|
|
58
58
|
memberStructTypes_.push(member.type);
|
|
59
59
|
break;
|
|
60
60
|
case "Intersection":
|
|
61
|
-
case "
|
|
61
|
+
case "DiscriminatedUnion": {
|
|
62
62
|
invariant(member.type.kind === objectCompoundType.kind);
|
|
63
63
|
memberStructTypes_.push(...memberStructTypes(member.type));
|
|
64
64
|
break;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DiscriminatedUnionType } from "./DiscriminatedUnionType.js";
|
|
2
|
+
import type { StructType } from "./StructType.js";
|
|
3
|
+
export type StructDiscriminatedUnionType = DiscriminatedUnionType<DiscriminatedUnionType<StructType> | StructType>;
|
|
4
|
+
//# sourceMappingURL=StructDiscriminatedUnionType.d.ts.map
|
package/dist/ast/StructType.js
CHANGED
package/dist/ast/Type.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
2
2
|
import type { DefaultValueType } from "./DefaultValueType.js";
|
|
3
|
+
import type { DiscriminatedUnionType } from "./DiscriminatedUnionType.js";
|
|
3
4
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
4
5
|
import type { IntersectionType } from "./IntersectionType.js";
|
|
5
6
|
import type { IriType } from "./IriType.js";
|
|
@@ -12,8 +13,7 @@ import type { OptionType } from "./OptionType.js";
|
|
|
12
13
|
import type { SetType } from "./SetType.js";
|
|
13
14
|
import type { StructType } from "./StructType.js";
|
|
14
15
|
import type { TermType } from "./TermType.js";
|
|
15
|
-
|
|
16
|
-
export type Type = BlankNodeType | DefaultValueType | IdentifierType | IntersectionType | IriType | LazyOptionType | LazySetType | LazyType | ListType | LiteralType | StructType | OptionType | SetType | TermType | UnionType;
|
|
16
|
+
export type Type = BlankNodeType | DefaultValueType | IdentifierType | IntersectionType | IriType | LazyOptionType | LazySetType | LazyType | ListType | LiteralType | StructType | OptionType | SetType | TermType | DiscriminatedUnionType;
|
|
17
17
|
export declare namespace Type {
|
|
18
18
|
function equals(left: Type, right: Type): boolean;
|
|
19
19
|
}
|
package/dist/ast/Type.js
CHANGED
package/dist/ast/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./Ast.js";
|
|
2
2
|
export * from "./BlankNodeType.js";
|
|
3
3
|
export * from "./DefaultValueType.js";
|
|
4
|
+
export * from "./DiscriminatedUnionType.js";
|
|
4
5
|
export * from "./IdentifierType.js";
|
|
5
6
|
export * from "./IntersectionType.js";
|
|
6
7
|
export * from "./IriType.js";
|
|
@@ -12,10 +13,9 @@ export * from "./LiteralType.js";
|
|
|
12
13
|
export * from "./OptionType.js";
|
|
13
14
|
export * from "./SetType.js";
|
|
14
15
|
export * from "./StructCompoundType.js";
|
|
16
|
+
export * from "./StructDiscriminatedUnionType.js";
|
|
15
17
|
export * from "./StructIntersectionType.js";
|
|
16
18
|
export * from "./StructType.js";
|
|
17
|
-
export * from "./StructUnionType.js";
|
|
18
19
|
export * from "./TermType.js";
|
|
19
20
|
export * from "./Type.js";
|
|
20
|
-
export * from "./UnionType.js";
|
|
21
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ast/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from "./Ast.js";
|
|
2
2
|
export * from "./BlankNodeType.js";
|
|
3
3
|
export * from "./DefaultValueType.js";
|
|
4
|
+
export * from "./DiscriminatedUnionType.js";
|
|
4
5
|
export * from "./IdentifierType.js";
|
|
5
6
|
export * from "./IntersectionType.js";
|
|
6
7
|
export * from "./IriType.js";
|
|
@@ -12,10 +13,9 @@ export * from "./LiteralType.js";
|
|
|
12
13
|
export * from "./OptionType.js";
|
|
13
14
|
export * from "./SetType.js";
|
|
14
15
|
export * from "./StructCompoundType.js";
|
|
16
|
+
export * from "./StructDiscriminatedUnionType.js";
|
|
15
17
|
export * from "./StructIntersectionType.js";
|
|
16
18
|
export * from "./StructType.js";
|
|
17
|
-
export * from "./StructUnionType.js";
|
|
18
19
|
export * from "./TermType.js";
|
|
19
20
|
export * from "./Type.js";
|
|
20
|
-
export * from "./UnionType.js";
|
|
21
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -32,7 +32,7 @@ export function transformAstToLabeledPropertyGraph(ast) {
|
|
|
32
32
|
switch (itemType.kind) {
|
|
33
33
|
case "Intersection":
|
|
34
34
|
case "Struct":
|
|
35
|
-
case "
|
|
35
|
+
case "DiscriminatedUnion":
|
|
36
36
|
if (itemType.name.isJust()) {
|
|
37
37
|
relationships.push({
|
|
38
38
|
id: namedObjectTypeProperty.shapeIdentifier.toString(),
|
|
@@ -56,7 +56,7 @@ export function transformAstToLabeledPropertyGraph(ast) {
|
|
|
56
56
|
properties: properties,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
|
-
else if (namedType.kind === "
|
|
59
|
+
else if (namedType.kind === "DiscriminatedUnion") {
|
|
60
60
|
nodes.push({
|
|
61
61
|
id: typeId(namedType),
|
|
62
62
|
label: typeName(namedType),
|
|
@@ -27,11 +27,11 @@ export declare abstract class AbstractCollectionType<ItemTypeT extends AbstractC
|
|
|
27
27
|
export declare namespace AbstractCollectionType {
|
|
28
28
|
type ConversionFunction = AbstractContainerType.ConversionFunction;
|
|
29
29
|
type DiscriminantProperty = AbstractContainerType.DiscriminantProperty;
|
|
30
|
-
const GraphqlType: typeof import("./
|
|
30
|
+
const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
31
31
|
type GraphqlType = AbstractContainerType.GraphqlType;
|
|
32
32
|
const isItemType: typeof AbstractContainerType.isItemType;
|
|
33
33
|
type ItemType = AbstractContainerType.ItemType;
|
|
34
|
-
const JsonType: typeof import("./
|
|
34
|
+
const JsonType: typeof import("./_AbstractType/AbstractType_JsonType.js").AbstractType_JsonType;
|
|
35
35
|
type JsonType = AbstractContainerType.JsonType;
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=AbstractCollectionType.d.ts.map
|
|
@@ -6,6 +6,7 @@ import type { BlankNodeType } from "./BlankNodeType.js";
|
|
|
6
6
|
import type { BooleanType } from "./BooleanType.js";
|
|
7
7
|
import type { DateTimeType } from "./DateTimeType.js";
|
|
8
8
|
import type { DateType } from "./DateType.js";
|
|
9
|
+
import type { DiscriminatedUnionType } from "./DiscriminatedUnionType.js";
|
|
9
10
|
import type { FloatType } from "./FloatType.js";
|
|
10
11
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
11
12
|
import type { IntType } from "./IntType.js";
|
|
@@ -13,13 +14,12 @@ import type { IriType } from "./IriType.js";
|
|
|
13
14
|
import type { LangStringType } from "./LangStringType.js";
|
|
14
15
|
import type { ListType } from "./ListType.js";
|
|
15
16
|
import type { LiteralType } from "./LiteralType.js";
|
|
17
|
+
import type { ObjectDiscriminatedUnionType } from "./ObjectDiscriminatedUnionType.js";
|
|
16
18
|
import type { ObjectType } from "./ObjectType.js";
|
|
17
|
-
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
18
19
|
import type { StringType } from "./StringType.js";
|
|
19
20
|
import type { TermType } from "./TermType.js";
|
|
20
21
|
import type { Type } from "./Type.js";
|
|
21
22
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
22
|
-
import type { UnionType } from "./UnionType.js";
|
|
23
23
|
/**
|
|
24
24
|
* Abstract base class for types that contain other types e.g., ListType, OptionType, SetType.
|
|
25
25
|
*/
|
|
@@ -44,11 +44,11 @@ export declare abstract class AbstractContainerType<ItemTypeT extends AbstractCo
|
|
|
44
44
|
export declare namespace AbstractContainerType {
|
|
45
45
|
type ConversionFunction = AbstractType.ConversionFunction;
|
|
46
46
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
47
|
-
const GraphqlType: typeof
|
|
47
|
+
const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
48
48
|
type GraphqlType = AbstractType.GraphqlType;
|
|
49
|
-
type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | LangStringType | ListType<ListType.ItemType> | LiteralType |
|
|
49
|
+
type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | LangStringType | ListType<ListType.ItemType> | LiteralType | ObjectDiscriminatedUnionType | ObjectType | StringType | TermType | DiscriminatedUnionType<Type>;
|
|
50
50
|
function isItemType(type: Type): type is ItemType;
|
|
51
|
-
const JsonType: typeof
|
|
51
|
+
const JsonType: typeof import("./_AbstractType/AbstractType_JsonType.js").AbstractType_JsonType;
|
|
52
52
|
type JsonType = AbstractType.JsonType;
|
|
53
53
|
}
|
|
54
54
|
//# sourceMappingURL=AbstractContainerType.d.ts.map
|
|
@@ -78,10 +78,10 @@ __decorate([
|
|
|
78
78
|
case "List":
|
|
79
79
|
case "Literal":
|
|
80
80
|
case "Object":
|
|
81
|
-
case "
|
|
81
|
+
case "ObjectDiscriminatedUnion":
|
|
82
82
|
case "String":
|
|
83
83
|
case "Term":
|
|
84
|
-
case "
|
|
84
|
+
case "DiscriminatedUnion":
|
|
85
85
|
return true;
|
|
86
86
|
case "DefaultValue":
|
|
87
87
|
case "LazyOption":
|
|
@@ -11,7 +11,7 @@ export declare abstract class AbstractIdentifierType<IdentifierT extends BlankNo
|
|
|
11
11
|
abstract readonly nodeKinds: ReadonlySet<IdentifierNodeKind>;
|
|
12
12
|
abstract readonly parseFunction: Code;
|
|
13
13
|
readonly stringifyFunction: Code;
|
|
14
|
-
get graphqlType(): import("./
|
|
14
|
+
get graphqlType(): import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
15
15
|
graphqlResolveExpression({ variables: { value }, }: Parameters<AbstractTermType["graphqlResolveExpression"]>[0]): Code;
|
|
16
16
|
}
|
|
17
17
|
export declare namespace AbstractIdentifierType {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
|
+
import type { ObjectDiscriminatedUnionType } from "./ObjectDiscriminatedUnionType.js";
|
|
3
4
|
import type { ObjectType } from "./ObjectType.js";
|
|
4
|
-
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
5
5
|
import type { OptionType } from "./OptionType.js";
|
|
6
6
|
import type { SetType } from "./SetType.js";
|
|
7
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
@@ -45,23 +45,23 @@ export declare abstract class AbstractLazyType<PartialTypeT extends AbstractLazy
|
|
|
45
45
|
partialType: ObjectTypeT;
|
|
46
46
|
resolveType: ObjectTypeT;
|
|
47
47
|
}): Code;
|
|
48
|
-
protected
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
protected resolvedObjectDiscriminatedUnionTypeToPartialObjectDiscriminatedUnionTypeConversion({ resolvedObjectDiscriminatedUnionType, partialObjectDiscriminatedUnionType, variables, }: {
|
|
49
|
+
resolvedObjectDiscriminatedUnionType: ObjectDiscriminatedUnionType;
|
|
50
|
+
partialObjectDiscriminatedUnionType: ObjectDiscriminatedUnionType;
|
|
51
51
|
variables: {
|
|
52
|
-
|
|
52
|
+
resolvedObjectDiscriminatedUnion: Code;
|
|
53
53
|
};
|
|
54
54
|
}): Code;
|
|
55
55
|
}
|
|
56
56
|
export declare namespace AbstractLazyType {
|
|
57
|
-
type ItemTypeConstraint = ObjectType |
|
|
57
|
+
type ItemTypeConstraint = ObjectType | ObjectDiscriminatedUnionType;
|
|
58
58
|
type PartialTypeConstraint = ItemTypeConstraint | OptionType<ItemTypeConstraint> | SetType<ItemTypeConstraint>;
|
|
59
59
|
type ResolveTypeConstraint = PartialTypeConstraint;
|
|
60
60
|
type ConversionFunction = AbstractType.ConversionFunction;
|
|
61
61
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
62
|
-
const GraphqlType: typeof
|
|
62
|
+
const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
63
63
|
type GraphqlType = AbstractType.GraphqlType;
|
|
64
|
-
const JsonType: typeof
|
|
64
|
+
const JsonType: typeof import("./_AbstractType/AbstractType_JsonType.js").AbstractType_JsonType;
|
|
65
65
|
type JsonType = AbstractType.JsonType;
|
|
66
66
|
}
|
|
67
67
|
//# sourceMappingURL=AbstractLazyType.d.ts.map
|
|
@@ -107,8 +107,8 @@ export class AbstractLazyType extends AbstractType {
|
|
|
107
107
|
if (partialType.kind === "Object") {
|
|
108
108
|
return code `${partialType.name.unsafeCoerce()}.createUnsafe`;
|
|
109
109
|
}
|
|
110
|
-
invariant(partialType.kind === "
|
|
111
|
-
invariant(resolveType.kind === "
|
|
110
|
+
invariant(partialType.kind === "ObjectDiscriminatedUnion");
|
|
111
|
+
invariant(resolveType.kind === "ObjectDiscriminatedUnion");
|
|
112
112
|
invariant(partialType.members.length === resolveType.members.length);
|
|
113
113
|
const caseBlocks = resolveType.members.map(({ discriminantValues }, memberI) => {
|
|
114
114
|
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.name.unsafeCoerce()}.createUnsafe(resolved);`;
|
|
@@ -116,14 +116,14 @@ export class AbstractLazyType extends AbstractType {
|
|
|
116
116
|
caseBlocks.push(code `default: resolved satisfies never; throw new Error("unrecognized type");`);
|
|
117
117
|
return code `((resolved: ${resolveType.expression}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
|
|
118
118
|
}
|
|
119
|
-
|
|
120
|
-
invariant(
|
|
121
|
-
|
|
122
|
-
const caseBlocks =
|
|
123
|
-
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${
|
|
119
|
+
resolvedObjectDiscriminatedUnionTypeToPartialObjectDiscriminatedUnionTypeConversion({ resolvedObjectDiscriminatedUnionType, partialObjectDiscriminatedUnionType, variables, }) {
|
|
120
|
+
invariant(resolvedObjectDiscriminatedUnionType.members.length ===
|
|
121
|
+
partialObjectDiscriminatedUnionType.members.length);
|
|
122
|
+
const caseBlocks = resolvedObjectDiscriminatedUnionType.members.map(({ discriminantValues }, memberI) => {
|
|
123
|
+
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialObjectDiscriminatedUnionType.members[memberI].type.name.unsafeCoerce()}.create(${variables.resolvedObjectDiscriminatedUnion});`;
|
|
124
124
|
});
|
|
125
|
-
caseBlocks.push(code `default: ${variables.
|
|
126
|
-
return code `switch (${variables.
|
|
125
|
+
caseBlocks.push(code `default: ${variables.resolvedObjectDiscriminatedUnion} satisfies never; throw new Error("unrecognized type");`);
|
|
126
|
+
return code `switch (${variables.resolvedObjectDiscriminatedUnion}.${resolvedObjectDiscriminatedUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
__decorate([
|
|
@@ -16,10 +16,10 @@ export declare abstract class AbstractLiteralType extends AbstractTermType<Liter
|
|
|
16
16
|
export declare namespace AbstractLiteralType {
|
|
17
17
|
type ConversionFunction = AbstractTermType.ConversionFunction;
|
|
18
18
|
type DiscriminantProperty = AbstractTermType.DiscriminantProperty;
|
|
19
|
-
const GraphqlType: typeof import("./
|
|
19
|
+
const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
|
|
20
20
|
type GraphqlType = AbstractTermType.GraphqlType;
|
|
21
21
|
type JsType = AbstractTermType.JsType;
|
|
22
|
-
const JsonType: typeof import("./
|
|
22
|
+
const JsonType: typeof import("./_AbstractType/AbstractType_JsonType.js").AbstractType_JsonType;
|
|
23
23
|
type JsonType = AbstractTermType.JsonType;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=AbstractLiteralType.d.ts.map
|
|
@@ -13,7 +13,7 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
|
|
|
13
13
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
14
14
|
}
|
|
15
15
|
export declare namespace AbstractNumericType {
|
|
16
|
-
const JsonType: typeof import("./
|
|
16
|
+
const JsonType: typeof import("./_AbstractType/AbstractType_JsonType.js").AbstractType_JsonType;
|
|
17
17
|
type JsonType = AbstractPrimitiveType.JsonType;
|
|
18
18
|
}
|
|
19
19
|
//# sourceMappingURL=AbstractNumericType.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Maybe } from "purify-ts";
|
|
2
2
|
import type { Logger } from "ts-log";
|
|
3
|
+
import type { ObjectDiscriminatedUnionType } from "./ObjectDiscriminatedUnionType.js";
|
|
3
4
|
import type { ObjectType } from "./ObjectType.js";
|
|
4
|
-
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
5
5
|
import type { Reusables } from "./Reusables.js";
|
|
6
6
|
import type { TsGenerator } from "./TsGenerator.js";
|
|
7
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
@@ -10,12 +10,12 @@ export declare abstract class AbstractObjectSetType {
|
|
|
10
10
|
protected readonly logger: Logger;
|
|
11
11
|
protected readonly reusables: Reusables;
|
|
12
12
|
protected readonly namedObjectTypes: readonly ObjectType[];
|
|
13
|
-
protected readonly
|
|
14
|
-
constructor({ configuration, logger, namedObjectTypes,
|
|
13
|
+
protected readonly namedObjectDiscriminatedUnionTypes: readonly ObjectDiscriminatedUnionType[];
|
|
14
|
+
constructor({ configuration, logger, namedObjectTypes, namedObjectDiscriminatedUnionTypes, reusables, }: {
|
|
15
15
|
configuration: TsGenerator.Configuration;
|
|
16
16
|
logger: Logger;
|
|
17
17
|
namedObjectTypes: readonly ObjectType[];
|
|
18
|
-
|
|
18
|
+
namedObjectDiscriminatedUnionTypes: readonly ObjectDiscriminatedUnionType[];
|
|
19
19
|
reusables: Reusables;
|
|
20
20
|
});
|
|
21
21
|
abstract readonly declaration: Code;
|
|
@@ -4,12 +4,13 @@ export class AbstractObjectSetType {
|
|
|
4
4
|
logger;
|
|
5
5
|
reusables;
|
|
6
6
|
namedObjectTypes;
|
|
7
|
-
|
|
8
|
-
constructor({ configuration, logger, namedObjectTypes,
|
|
7
|
+
namedObjectDiscriminatedUnionTypes;
|
|
8
|
+
constructor({ configuration, logger, namedObjectTypes, namedObjectDiscriminatedUnionTypes, reusables, }) {
|
|
9
9
|
this.configuration = configuration;
|
|
10
10
|
this.logger = logger;
|
|
11
11
|
this.namedObjectTypes = namedObjectTypes;
|
|
12
|
-
this.
|
|
12
|
+
this.namedObjectDiscriminatedUnionTypes =
|
|
13
|
+
namedObjectDiscriminatedUnionTypes;
|
|
13
14
|
this.reusables = reusables;
|
|
14
15
|
}
|
|
15
16
|
methodSignatures(namedObjectType, options) {
|