@shaclmate/compiler 4.0.57 → 4.0.60

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.
Files changed (95) hide show
  1. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.js +5 -5
  2. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +3 -3
  3. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstStructType.js +1 -1
  4. package/dist/ast/AbstractCompoundType.d.ts +3 -3
  5. package/dist/ast/AbstractCompoundType.js +1 -1
  6. package/dist/ast/AbstractContainerType.d.ts +2 -2
  7. package/dist/ast/AbstractContainerType.js +1 -1
  8. package/dist/ast/AbstractLazyType.d.ts +2 -2
  9. package/dist/ast/{UnionType.d.ts → DiscriminatedUnionType.d.ts} +7 -7
  10. package/dist/ast/{UnionType.js → DiscriminatedUnionType.js} +9 -8
  11. package/dist/ast/ListType.d.ts +2 -2
  12. package/dist/ast/ListType.js +1 -1
  13. package/dist/ast/StructCompoundType.d.ts +2 -2
  14. package/dist/ast/StructCompoundType.js +1 -1
  15. package/dist/ast/StructDiscriminatedUnionType.d.ts +4 -0
  16. package/dist/ast/StructDiscriminatedUnionType.js +2 -0
  17. package/dist/ast/StructType.js +1 -1
  18. package/dist/ast/Type.d.ts +2 -2
  19. package/dist/ast/Type.js +1 -1
  20. package/dist/ast/index.d.ts +2 -2
  21. package/dist/ast/index.js +2 -2
  22. package/dist/generators/transformAstToLabeledPropertyGraph.js +2 -2
  23. package/dist/generators/ts/AbstractCollectionType.d.ts +2 -2
  24. package/dist/generators/ts/AbstractContainerType.d.ts +5 -5
  25. package/dist/generators/ts/AbstractContainerType.js +2 -2
  26. package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
  27. package/dist/generators/ts/AbstractLazyType.d.ts +8 -8
  28. package/dist/generators/ts/AbstractLazyType.js +9 -9
  29. package/dist/generators/ts/AbstractLiteralType.d.ts +2 -2
  30. package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
  31. package/dist/generators/ts/AbstractObjectSetType.d.ts +4 -4
  32. package/dist/generators/ts/AbstractObjectSetType.js +4 -3
  33. package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -2
  34. package/dist/generators/ts/AbstractTermType.d.ts +2 -2
  35. package/dist/generators/ts/AbstractType.d.ts +15 -75
  36. package/dist/generators/ts/AbstractType.js +6 -63
  37. package/dist/generators/ts/AbstractTypedLiteralType.d.ts +2 -2
  38. package/dist/generators/ts/BigDecimalType.d.ts +1 -1
  39. package/dist/generators/ts/BigIntType.d.ts +1 -1
  40. package/dist/generators/ts/BooleanType.d.ts +1 -1
  41. package/dist/generators/ts/DateTimeType.d.ts +1 -1
  42. package/dist/generators/ts/DateType.d.ts +1 -1
  43. package/dist/generators/ts/DefaultValueType.d.ts +4 -4
  44. package/dist/generators/ts/DefaultValueType.js +2 -2
  45. package/dist/generators/ts/{UnionType.d.ts → DiscriminatedUnionType.d.ts} +6 -6
  46. package/dist/generators/ts/{UnionType.js → DiscriminatedUnionType.js} +31 -31
  47. package/dist/generators/ts/FloatType.d.ts +1 -1
  48. package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
  49. package/dist/generators/ts/GraphqlSchema.js +5 -4
  50. package/dist/generators/ts/IntType.d.ts +1 -1
  51. package/dist/generators/ts/LazyOptionType.d.ts +3 -3
  52. package/dist/generators/ts/ListType.d.ts +3 -3
  53. package/dist/generators/ts/ListType.js +2 -2
  54. package/dist/generators/ts/{ObjectUnionType.d.ts → ObjectDiscriminatedUnionType.d.ts} +4 -4
  55. package/dist/generators/ts/{ObjectUnionType.js → ObjectDiscriminatedUnionType.js} +8 -8
  56. package/dist/generators/ts/ObjectSetType.js +1 -1
  57. package/dist/generators/ts/ObjectType.d.ts +11 -11
  58. package/dist/generators/ts/ObjectType.js +6 -6
  59. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -5
  60. package/dist/generators/ts/SparqlObjectSetType.js +4 -1
  61. package/dist/generators/ts/StringType.d.ts +1 -1
  62. package/dist/generators/ts/TsGenerator.d.ts +1 -1
  63. package/dist/generators/ts/TsGenerator.js +19 -19
  64. package/dist/generators/ts/Type.d.ts +3 -3
  65. package/dist/generators/ts/TypeFactory.d.ts +5 -5
  66. package/dist/generators/ts/TypeFactory.js +16 -16
  67. package/dist/generators/ts/ZodGenerator.js +5 -5
  68. package/dist/generators/ts/_AbstractType/AbstractType_ConversionFunction.d.ts +10 -0
  69. package/dist/generators/ts/_AbstractType/AbstractType_ConversionFunction.js +2 -0
  70. package/dist/generators/ts/_AbstractType/AbstractType_DiscriminantProperty.d.ts +9 -0
  71. package/dist/generators/ts/_AbstractType/AbstractType_DiscriminantProperty.js +2 -0
  72. package/dist/generators/ts/_AbstractType/AbstractType_GraphqlType.d.ts +18 -0
  73. package/dist/generators/ts/_AbstractType/AbstractType_GraphqlType.js +33 -0
  74. package/dist/generators/ts/_AbstractType/AbstractType_JsType.d.ts +34 -0
  75. package/dist/generators/ts/_AbstractType/AbstractType_JsType.js +16 -0
  76. package/dist/generators/ts/_AbstractType/AbstractType_JsonType.d.ts +16 -0
  77. package/dist/generators/ts/_AbstractType/AbstractType_JsonType.js +31 -0
  78. package/dist/generators/ts/_ObjectType/{AbstractProperty.d.ts → ObjectType_AbstractProperty.d.ts} +2 -2
  79. package/dist/generators/ts/_ObjectType/{AbstractProperty.js → ObjectType_AbstractProperty.js} +2 -2
  80. package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.d.ts +45 -0
  81. package/dist/generators/ts/_ObjectType/{DiscriminantProperty.js → ObjectType_DiscriminantProperty.js} +12 -9
  82. package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.d.ts +43 -0
  83. package/dist/generators/ts/_ObjectType/{IdentifierProperty.js → ObjectType_IdentifierProperty.js} +11 -11
  84. package/dist/generators/ts/_ObjectType/ObjectType_Property.d.ts +6 -0
  85. package/dist/generators/ts/_ObjectType/ObjectType_Property.js +2 -0
  86. package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.d.ts +53 -0
  87. package/dist/generators/ts/_ObjectType/{ShaclProperty.js → ObjectType_ShaclProperty.js} +10 -10
  88. package/package.json +34 -24
  89. package/dist/ast/StructUnionType.d.ts +0 -4
  90. package/dist/ast/StructUnionType.js +0 -2
  91. package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +0 -45
  92. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +0 -43
  93. package/dist/generators/ts/_ObjectType/Property.d.ts +0 -6
  94. package/dist/generators/ts/_ObjectType/Property.js +0 -2
  95. 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 "Union":
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.isStructUnionType()) {
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 "Union":
211
- if (!astItemType.isStructUnionType()) {
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 "Union":
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 = "Union";
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.UnionType)({
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 === "Union") {
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 "Union":
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" | "Union";
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 | UnionType;
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
@@ -65,7 +65,7 @@ __decorate([
65
65
  case "Literal":
66
66
  case "Struct":
67
67
  case "Term":
68
- case "Union":
68
+ case "DiscriminatedUnion":
69
69
  return true;
70
70
  case "DefaultValue":
71
71
  case "LazyOption":
@@ -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 | UnionType;
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
@@ -47,7 +47,7 @@ export class AbstractContainerType extends AbstractType {
47
47
  case "Literal":
48
48
  case "Struct":
49
49
  case "Term":
50
- case "Union":
50
+ case "DiscriminatedUnion":
51
51
  return true;
52
52
  case "DefaultValue":
53
53
  case "LazyOption":
@@ -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 | StructUnionType;
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 { StructUnionType } from "./StructUnionType.js";
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 UnionType<MemberTypeT extends UnionType.MemberType = UnionType.MemberType> extends AbstractCompoundType<UnionType.Member<MemberTypeT>, MemberTypeT> {
8
- readonly kind = "Union";
9
- isStructUnionType(): this is StructUnionType;
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 UnionType {
24
- interface Member<TypeT extends UnionType.MemberType> extends AbstractCompoundType.Member<TypeT> {
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=UnionType.d.ts.map
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 UnionType extends AbstractCompoundType {
6
- kind = "Union";
7
- isStructUnionType() {
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 === "Union" && member.type.isStructUnionType())));
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 (UnionType) {
25
- UnionType.isMemberType = AbstractCompoundType.isMemberType;
26
- })(UnionType || (UnionType = {}));
27
- //# sourceMappingURL=UnionType.js.map
25
+ (function (DiscriminatedUnionType) {
26
+ DiscriminatedUnionType.isMemberType = AbstractCompoundType.isMemberType;
27
+ })(DiscriminatedUnionType || (DiscriminatedUnionType = {}));
28
+ //# sourceMappingURL=DiscriminatedUnionType.js.map
@@ -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 | UnionType;
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
@@ -40,7 +40,7 @@ export class ListType extends AbstractCollectionType {
40
40
  case "Literal":
41
41
  case "Struct":
42
42
  case "Term":
43
- case "Union":
43
+ case "DiscriminatedUnion":
44
44
  return true;
45
45
  case "DefaultValue":
46
46
  case "LazyOption":
@@ -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
- import type { StructUnionType } from "./StructUnionType.js";
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 "Union": {
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
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StructDiscriminatedUnionType.js.map
@@ -260,7 +260,7 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
260
260
  return false;
261
261
  }
262
262
  case "Intersection":
263
- case "Union": {
263
+ case "DiscriminatedUnion": {
264
264
  if (DEBUG) {
265
265
  process.stderr.write(`recurse into ${currentFieldType}`);
266
266
  }
@@ -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
- import type { UnionType } from "./UnionType.js";
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
@@ -31,7 +31,7 @@ export var Type;
31
31
  return left.equals(right);
32
32
  case "Term":
33
33
  return left.equals(right);
34
- case "Union":
34
+ case "DiscriminatedUnion":
35
35
  return left.equals(right);
36
36
  case "Set":
37
37
  return left.equals(right);
@@ -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 "Union":
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 === "Union") {
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("./AbstractType.js").AbstractType.GraphqlType;
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("./AbstractType.js").AbstractType.JsonType;
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 AbstractType.GraphqlType;
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 | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
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 AbstractType.JsonType;
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 "ObjectUnion":
81
+ case "ObjectDiscriminatedUnion":
82
82
  case "String":
83
83
  case "Term":
84
- case "Union":
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("./AbstractType.js").AbstractType.GraphqlType;
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 resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }: {
49
- resolvedObjectUnionType: ObjectUnionType;
50
- partialObjectUnionType: ObjectUnionType;
48
+ protected resolvedObjectDiscriminatedUnionTypeToPartialObjectDiscriminatedUnionTypeConversion({ resolvedObjectDiscriminatedUnionType, partialObjectDiscriminatedUnionType, variables, }: {
49
+ resolvedObjectDiscriminatedUnionType: ObjectDiscriminatedUnionType;
50
+ partialObjectDiscriminatedUnionType: ObjectDiscriminatedUnionType;
51
51
  variables: {
52
- resolvedObjectUnion: Code;
52
+ resolvedObjectDiscriminatedUnion: Code;
53
53
  };
54
54
  }): Code;
55
55
  }
56
56
  export declare namespace AbstractLazyType {
57
- type ItemTypeConstraint = ObjectType | ObjectUnionType;
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 AbstractType.GraphqlType;
62
+ const GraphqlType: typeof import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
63
63
  type GraphqlType = AbstractType.GraphqlType;
64
- const JsonType: typeof AbstractType.JsonType;
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 === "ObjectUnion");
111
- invariant(resolveType.kind === "ObjectUnion");
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
- resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }) {
120
- invariant(resolvedObjectUnionType.members.length ===
121
- partialObjectUnionType.members.length);
122
- const caseBlocks = resolvedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
123
- return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialObjectUnionType.members[memberI].type.name.unsafeCoerce()}.create(${variables.resolvedObjectUnion});`;
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.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
126
- return code `switch (${variables.resolvedObjectUnion}.${resolvedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
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("./AbstractType.js").AbstractType.GraphqlType;
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("./AbstractType.js").AbstractType.JsonType;
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("./AbstractType.js").AbstractType.JsonType;
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 namedObjectUnionTypes: readonly ObjectUnionType[];
14
- constructor({ configuration, logger, namedObjectTypes, namedObjectUnionTypes, reusables, }: {
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
- namedObjectUnionTypes: readonly ObjectUnionType[];
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
- namedObjectUnionTypes;
8
- constructor({ configuration, logger, namedObjectTypes, namedObjectUnionTypes, reusables, }) {
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.namedObjectUnionTypes = namedObjectUnionTypes;
12
+ this.namedObjectDiscriminatedUnionTypes =
13
+ namedObjectDiscriminatedUnionTypes;
13
14
  this.reusables = reusables;
14
15
  }
15
16
  methodSignatures(namedObjectType, options) {