@shaclmate/compiler 4.0.39 → 4.0.40

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 (163) hide show
  1. package/dist/generators/ts/AbstractCollectionType.d.ts +1 -1
  2. package/dist/generators/ts/AbstractCollectionType.js +10 -10
  3. package/dist/generators/ts/AbstractContainerType.d.ts +4 -5
  4. package/dist/generators/ts/AbstractContainerType.js +4 -5
  5. package/dist/generators/ts/AbstractDateType.d.ts +3 -3
  6. package/dist/generators/ts/AbstractDateType.js +2 -2
  7. package/dist/generators/ts/AbstractLazyObjectType.d.ts +8 -8
  8. package/dist/generators/ts/AbstractLazyObjectType.js +19 -19
  9. package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
  10. package/dist/generators/ts/AbstractNumericType.js +3 -3
  11. package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
  12. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  13. package/dist/generators/ts/AbstractPrimitiveType.js +2 -2
  14. package/dist/generators/ts/AbstractTermType.js +2 -2
  15. package/dist/generators/ts/AbstractType.d.ts +15 -10
  16. package/dist/generators/ts/AbstractType.js +6 -1
  17. package/dist/generators/ts/BigDecimalType.d.ts +1 -1
  18. package/dist/generators/ts/BigDecimalType.js +2 -2
  19. package/dist/generators/ts/BigIntType.js +2 -2
  20. package/dist/generators/ts/BlankNodeType.d.ts +3 -3
  21. package/dist/generators/ts/BlankNodeType.js +11 -11
  22. package/dist/generators/ts/BooleanType.d.ts +2 -2
  23. package/dist/generators/ts/BooleanType.js +10 -5
  24. package/dist/generators/ts/DefaultValueType.d.ts +1 -1
  25. package/dist/generators/ts/DefaultValueType.js +8 -9
  26. package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
  27. package/dist/generators/ts/GraphqlSchema.js +4 -4
  28. package/dist/generators/ts/IdentifierType.d.ts +3 -3
  29. package/dist/generators/ts/IdentifierType.js +13 -13
  30. package/dist/generators/ts/IriType.d.ts +2 -2
  31. package/dist/generators/ts/IriType.js +17 -17
  32. package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -0
  33. package/dist/generators/ts/LazyObjectOptionType.js +6 -6
  34. package/dist/generators/ts/LazyObjectSetType.js +5 -5
  35. package/dist/generators/ts/LazyObjectType.js +4 -4
  36. package/dist/generators/ts/ListType.d.ts +4 -5
  37. package/dist/generators/ts/ListType.js +3 -4
  38. package/dist/generators/ts/LiteralType.d.ts +1 -1
  39. package/dist/generators/ts/LiteralType.js +5 -5
  40. package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +23 -24
  41. package/dist/generators/ts/ObjectType.js +350 -0
  42. package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
  43. package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +50 -58
  44. package/dist/generators/ts/OptionType.d.ts +1 -1
  45. package/dist/generators/ts/OptionType.js +10 -10
  46. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -8
  47. package/dist/generators/ts/SparqlObjectSetType.js +2 -2
  48. package/dist/generators/ts/StringType.d.ts +2 -2
  49. package/dist/generators/ts/StringType.js +10 -5
  50. package/dist/generators/ts/TermType.d.ts +2 -2
  51. package/dist/generators/ts/TermType.js +12 -12
  52. package/dist/generators/ts/TsGenerator.js +12 -9
  53. package/dist/generators/ts/Type.d.ts +4 -5
  54. package/dist/generators/ts/TypeFactory.d.ts +7 -8
  55. package/dist/generators/ts/TypeFactory.js +61 -62
  56. package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +33 -5
  57. package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +262 -58
  58. package/dist/generators/ts/ZodGenerator.js +7 -9
  59. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +6 -6
  60. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +3 -3
  61. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +1 -1
  62. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +8 -8
  63. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +1 -5
  64. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +15 -10
  65. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
  66. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_createFunctionDeclaration.js → _ObjectType/ObjectType_createFunctionDeclaration.js} +6 -6
  67. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
  68. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +4 -4
  69. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
  70. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -3
  71. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
  72. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +3 -3
  73. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  74. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  75. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  76. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +3 -3
  77. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
  78. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js → _ObjectType/ObjectType_fromJsonFunctionDeclaration.js} +4 -4
  79. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
  80. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js} +4 -4
  81. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
  82. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
  83. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
  84. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
  85. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
  86. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
  87. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
  88. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js → _ObjectType/ObjectType_hashFunctionDeclarations.js} +6 -6
  89. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
  90. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_interfaceDeclaration.js → _ObjectType/ObjectType_interfaceDeclaration.js} +4 -4
  91. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
  92. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js → _ObjectType/ObjectType_isTypeFunctionDeclaration.js} +3 -3
  93. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
  94. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
  95. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
  96. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +2 -2
  97. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
  98. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js → _ObjectType/ObjectType_jsonTypeAliasDeclaration.js} +2 -2
  99. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
  100. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
  101. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
  102. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
  103. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
  104. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +14 -0
  105. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
  106. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
  107. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
  108. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
  109. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  110. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js → _ObjectType/ObjectType_toJsonFunctionDeclaration.js} +4 -4
  111. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  112. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
  113. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
  114. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +6 -6
  115. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  116. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  117. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  118. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
  119. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +7 -7
  120. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
  121. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/identifierTypeDeclarations.js +4 -2
  122. package/dist/input/generated.d.ts +2 -2
  123. package/dist/input/generated.js +2 -2
  124. package/package.json +4 -4
  125. package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
  126. package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
  127. package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
  128. package/dist/generators/ts/AnonymousUnionType.js +0 -59
  129. package/dist/generators/ts/NamedObjectType.js +0 -342
  130. package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
  131. package/dist/generators/ts/NamedUnionType.d.ts +0 -11
  132. package/dist/generators/ts/NamedUnionType.js +0 -13
  133. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
  134. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
  135. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
  136. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
  137. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  138. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  139. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  140. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  141. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  142. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  143. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  144. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  145. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
  146. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
  147. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
  148. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
  149. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  150. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  151. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  152. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
  153. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
  154. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
  155. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  156. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  157. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
  158. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  159. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  160. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
  161. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
  162. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
  163. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +0 -0
@@ -7,7 +7,6 @@ import { Maybe } from "purify-ts";
7
7
  import reservedTsIdentifiers_ from "reserved-identifiers";
8
8
  import { invariant } from "ts-invariant";
9
9
  import * as ast from "../../ast/index.js";
10
- import { AnonymousUnionType } from "./AnonymousUnionType.js";
11
10
  import { BigDecimalType } from "./BigDecimalType.js";
12
11
  import { BigIntType } from "./BigIntType.js";
13
12
  import { BlankNodeType } from "./BlankNodeType.js";
@@ -24,19 +23,18 @@ import { LazyObjectSetType } from "./LazyObjectSetType.js";
24
23
  import { LazyObjectType } from "./LazyObjectType.js";
25
24
  import { ListType } from "./ListType.js";
26
25
  import { LiteralType } from "./LiteralType.js";
27
- import { NamedObjectType } from "./NamedObjectType.js";
28
- import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
29
- import { NamedUnionType } from "./NamedUnionType.js";
26
+ import { ObjectType } from "./ObjectType.js";
27
+ import { ObjectUnionType } from "./ObjectUnionType.js";
30
28
  import { OptionType } from "./OptionType.js";
31
29
  import { SetType } from "./SetType.js";
32
30
  import { StringType } from "./StringType.js";
33
31
  import { TermType } from "./TermType.js";
34
- import { code } from "./ts-poet-wrapper.js";
32
+ import { UnionType } from "./UnionType.js";
35
33
  export class TypeFactory {
36
34
  configuration;
37
35
  logger;
38
36
  reusables;
39
- cachedNamedObjectUnionTypesByShapeIdentifier = new TermMap();
37
+ cachedObjectUnionTypesByShapeIdentifier = new TermMap();
40
38
  cachedObjectTypePropertiesByShapeIdentifier = new TermMap();
41
39
  cachedObjectTypesByShapeIdentifier = new TermMap();
42
40
  constructor({ configuration, logger, reusables, }) {
@@ -44,7 +42,7 @@ export class TypeFactory {
44
42
  this.logger = logger;
45
43
  this.reusables = reusables;
46
44
  }
47
- createNamedObjectType(astType) {
45
+ createObjectType(astType) {
48
46
  {
49
47
  const cachedObjectType = this.cachedObjectTypesByShapeIdentifier.get(astType.shapeIdentifier);
50
48
  if (cachedObjectType) {
@@ -52,40 +50,38 @@ export class TypeFactory {
52
50
  }
53
51
  }
54
52
  const identifierType = this.createIdentifierType(astType.identifierType);
55
- const name = this.tsName(astType.name.unsafeCoerce(), {
56
- synthetic: astType.synthetic,
57
- });
58
- const namedObjectType = new NamedObjectType({
53
+ const objectType = new ObjectType({
54
+ alias: astType.name.map((name) => this.tsName(name, { synthetic: astType.synthetic })),
59
55
  comment: astType.comment,
60
56
  configuration: this.configuration,
61
57
  extern: astType.extern,
62
58
  fromRdfType: astType.fromRdfType,
63
59
  identifierType,
64
60
  label: astType.label,
65
- lazyAncestorObjectTypes: () => astType.ancestorObjectTypes.map((astType) => this.createNamedObjectType(astType)),
66
- lazyChildObjectTypes: () => astType.childObjectTypes.map((astType) => this.createNamedObjectType(astType)),
67
- lazyDescendantObjectTypes: () => astType.descendantObjectTypes.map((astType) => this.createNamedObjectType(astType)),
68
- lazyDiscriminantProperty: (namedObjectType) => {
61
+ lazyAncestorObjectTypes: () => astType.ancestorObjectTypes.map((astType) => this.createObjectType(astType)),
62
+ lazyChildObjectTypes: () => astType.childObjectTypes.map((astType) => this.createObjectType(astType)),
63
+ lazyDescendantObjectTypes: () => astType.descendantObjectTypes.map((astType) => this.createObjectType(astType)),
64
+ lazyDiscriminantProperty: (objectType) => {
69
65
  // Discriminant property
70
66
  const discriminantDescendantValues = new Set();
71
- for (const descendantObjectType of namedObjectType.descendantObjectTypes) {
67
+ for (const descendantObjectType of objectType.descendantObjectTypes) {
72
68
  discriminantDescendantValues.add(descendantObjectType.discriminantValue);
73
69
  }
74
- return new NamedObjectType.DiscriminantProperty({
70
+ return new ObjectType.DiscriminantProperty({
75
71
  configuration: this.configuration,
76
72
  logger: this.logger,
77
73
  name: `${this.configuration.syntheticNamePrefix}type`,
78
- namedObjectType,
74
+ objectType,
79
75
  reusables: this.reusables,
80
- type: new NamedObjectType.DiscriminantProperty.Type({
76
+ type: new ObjectType.DiscriminantProperty.Type({
81
77
  descendantValues: [...discriminantDescendantValues].sort(),
82
78
  mutable: false,
83
- ownValues: [namedObjectType.discriminantValue],
79
+ ownValues: [objectType.discriminantValue],
84
80
  }),
85
81
  });
86
82
  },
87
- lazyParentObjectTypes: () => astType.parentObjectTypes.map((astType) => this.createNamedObjectType(astType)),
88
- lazyProperties: (namedObjectType) => {
83
+ lazyParentObjectTypes: () => astType.parentObjectTypes.map((astType) => this.createObjectType(astType)),
84
+ lazyProperties: (objectType) => {
89
85
  const properties = astType.properties
90
86
  .toSorted((left, right) => {
91
87
  if (left.order < right.order) {
@@ -98,54 +94,52 @@ export class TypeFactory {
98
94
  })
99
95
  .map((astProperty) => this.createObjectTypeProperty({
100
96
  astObjectTypeProperty: astProperty,
101
- namedObjectType,
97
+ objectType,
102
98
  }));
103
- properties.splice(0, 0, namedObjectType._discriminantProperty);
104
- properties.splice(0, 0, new NamedObjectType.IdentifierProperty({
99
+ properties.splice(0, 0, objectType._discriminantProperty);
100
+ properties.splice(0, 0, new ObjectType.IdentifierProperty({
105
101
  configuration: this.configuration,
106
102
  logger: this.logger,
107
103
  name: `${this.configuration.syntheticNamePrefix}identifier`,
108
- namedObjectType,
104
+ objectType,
109
105
  reusables: this.reusables,
110
106
  type: identifierType,
111
- typeAlias: code `${name}.Identifier`,
112
107
  }));
113
108
  return properties;
114
109
  },
115
110
  logger: this.logger,
116
- name,
117
111
  recursive: astType.recursive,
118
112
  reusables: this.reusables,
119
113
  synthetic: astType.synthetic,
120
114
  toRdfTypes: astType.toRdfTypes,
121
115
  });
122
- this.cachedObjectTypesByShapeIdentifier.set(astType.shapeIdentifier, namedObjectType);
123
- return namedObjectType;
116
+ this.cachedObjectTypesByShapeIdentifier.set(astType.shapeIdentifier, objectType);
117
+ return objectType;
124
118
  }
125
- createNamedObjectUnionType(astType) {
119
+ createObjectUnionType(astType) {
126
120
  {
127
- const cachedNamedObjectUnionType = this.cachedNamedObjectUnionTypesByShapeIdentifier.get(astType.shapeIdentifier);
128
- if (cachedNamedObjectUnionType) {
129
- return cachedNamedObjectUnionType;
121
+ const cachedObjectUnionType = this.cachedObjectUnionTypesByShapeIdentifier.get(astType.shapeIdentifier);
122
+ if (cachedObjectUnionType) {
123
+ return cachedObjectUnionType;
130
124
  }
131
125
  }
132
- const namedObjectUnionType = new NamedObjectUnionType({
126
+ const objectUnionType = new ObjectUnionType({
127
+ alias: astType.name.map((name) => this.tsName(name)),
133
128
  comment: astType.comment,
134
129
  configuration: this.configuration,
135
- identifierType: this.createIdentifierType(ast.ObjectCompoundType.identifierType(astType)),
130
+ identifierType: Maybe.of(this.createIdentifierType(ast.ObjectCompoundType.identifierType(astType))),
136
131
  label: astType.label,
137
132
  logger: this.logger,
138
133
  members: ast.ObjectCompoundType.memberObjectTypes(astType).map((namedObjectType) => ({
139
134
  discriminantValue: Maybe.empty(),
140
- type: this.createNamedObjectType(namedObjectType),
135
+ type: this.createObjectType(namedObjectType),
141
136
  })),
142
- name: this.tsName(astType.name.unsafeCoerce()),
143
137
  recursive: astType.recursive,
144
138
  reusables: this.reusables,
145
139
  synthetic: astType.synthetic,
146
140
  });
147
- this.cachedNamedObjectUnionTypesByShapeIdentifier.set(astType.shapeIdentifier, namedObjectUnionType);
148
- return namedObjectUnionType;
141
+ this.cachedObjectUnionTypesByShapeIdentifier.set(astType.shapeIdentifier, objectUnionType);
142
+ return objectUnionType;
149
143
  }
150
144
  createType(astType, parameters) {
151
145
  switch (astType.kind) {
@@ -170,7 +164,7 @@ export class TypeFactory {
170
164
  case "Literal":
171
165
  return this.createLiteralType(astType, parameters);
172
166
  case "Object":
173
- return this.createNamedObjectType(astType);
167
+ return this.createObjectType(astType);
174
168
  case "Option":
175
169
  return this.createOptionType(astType);
176
170
  case "Set":
@@ -183,10 +177,10 @@ export class TypeFactory {
183
177
  }
184
178
  createUnionType(astType) {
185
179
  if (astType.isObjectUnionType()) {
186
- return this.createNamedObjectUnionType(astType);
180
+ return this.createObjectUnionType(astType);
187
181
  }
188
- return astType.name
189
- .map((name) => new NamedUnionType({
182
+ return new UnionType({
183
+ alias: astType.name.map((name) => this.tsName(name)),
190
184
  comment: astType.comment,
191
185
  configuration: this.configuration,
192
186
  identifierType: Maybe.empty(),
@@ -196,26 +190,14 @@ export class TypeFactory {
196
190
  discriminantValue: member.discriminantValue,
197
191
  type: this.createType(member.type),
198
192
  })),
199
- name,
200
193
  recursive: astType.recursive,
201
194
  reusables: this.reusables,
202
- }))
203
- .orDefaultLazy(() => new AnonymousUnionType({
204
- comment: astType.comment,
205
- configuration: this.configuration,
206
- label: astType.label,
207
- identifierType: Maybe.empty(),
208
- logger: this.logger,
209
- members: astType.members.map((member) => ({
210
- discriminantValue: member.discriminantValue,
211
- type: this.createType(member.type),
212
- })),
213
- recursive: astType.recursive,
214
- reusables: this.reusables,
215
- }));
195
+ synthetic: astType.synthetic,
196
+ });
216
197
  }
217
198
  createBlankNodeType(astType) {
218
199
  return new BlankNodeType({
200
+ alias: astType.name.map((name) => this.tsName(name)),
219
201
  comment: astType.comment,
220
202
  configuration: this.configuration,
221
203
  label: astType.label,
@@ -229,6 +211,7 @@ export class TypeFactory {
229
211
  });
230
212
  invariant(DefaultValueType.isItemType(itemType));
231
213
  return new DefaultValueType({
214
+ alias: astType.name.map((name) => this.tsName(name)),
232
215
  comment: astType.comment,
233
216
  configuration: this.configuration,
234
217
  defaultValue: astType.defaultValue,
@@ -244,6 +227,7 @@ export class TypeFactory {
244
227
  return this.createBlankNodeType(astType);
245
228
  case "Identifier":
246
229
  return new IdentifierType({
230
+ alias: astType.name.map((name) => this.tsName(name)),
247
231
  comment: astType.comment,
248
232
  configuration: this.configuration,
249
233
  label: astType.label,
@@ -256,6 +240,7 @@ export class TypeFactory {
256
240
  }
257
241
  createIriType(astType) {
258
242
  return new IriType({
243
+ alias: astType.name.map((name) => this.tsName(name)),
259
244
  comment: astType.comment,
260
245
  configuration: this.configuration,
261
246
  hasValues: astType.hasValues,
@@ -267,6 +252,7 @@ export class TypeFactory {
267
252
  }
268
253
  createLazyObjectOptionType(astType) {
269
254
  return new LazyObjectOptionType({
255
+ alias: astType.name.map((name) => this.tsName(name)),
270
256
  comment: astType.comment,
271
257
  configuration: this.configuration,
272
258
  label: astType.label,
@@ -278,6 +264,7 @@ export class TypeFactory {
278
264
  }
279
265
  createLazyObjectSetType(astType) {
280
266
  return new LazyObjectSetType({
267
+ alias: astType.name.map((name) => this.tsName(name)),
281
268
  comment: astType.comment,
282
269
  configuration: this.configuration,
283
270
  label: astType.label,
@@ -289,6 +276,7 @@ export class TypeFactory {
289
276
  }
290
277
  createLazyObjectType(astType) {
291
278
  return new LazyObjectType({
279
+ alias: astType.name.map((name) => this.tsName(name)),
292
280
  comment: astType.comment,
293
281
  configuration: this.configuration,
294
282
  label: astType.label,
@@ -302,6 +290,7 @@ export class TypeFactory {
302
290
  const itemType = this.createType(astType.itemType);
303
291
  invariant(ListType.isItemType(itemType));
304
292
  return new ListType({
293
+ alias: astType.name.map((name) => this.tsName(name)),
305
294
  comment: astType.comment,
306
295
  configuration: this.configuration,
307
296
  identifierNodeKind: astType.identifierNodeKind,
@@ -339,6 +328,7 @@ export class TypeFactory {
339
328
  switch (datatypeDefinition.kind) {
340
329
  case "bigdecimal":
341
330
  return new BigDecimalType({
331
+ alias: astType.name.map((name) => this.tsName(name)),
342
332
  comment: astType.comment,
343
333
  configuration: this.configuration,
344
334
  hasValues: astType.hasValues,
@@ -350,6 +340,7 @@ export class TypeFactory {
350
340
  });
351
341
  case "bigint":
352
342
  return new BigIntType({
343
+ alias: astType.name.map((name) => this.tsName(name)),
353
344
  comment: astType.comment,
354
345
  configuration: this.configuration,
355
346
  datatype,
@@ -363,6 +354,7 @@ export class TypeFactory {
363
354
  });
364
355
  case "boolean":
365
356
  return new BooleanType({
357
+ alias: astType.name.map((name) => this.tsName(name)),
366
358
  comment: astType.comment,
367
359
  configuration: this.configuration,
368
360
  datatype,
@@ -377,6 +369,7 @@ export class TypeFactory {
377
369
  case "date":
378
370
  case "datetime":
379
371
  return new (datatypeDefinition.kind === "date" ? DateType : DateTimeType)({
372
+ alias: astType.name.map((name) => this.tsName(name)),
380
373
  comment: astType.comment,
381
374
  configuration: this.configuration,
382
375
  datatype,
@@ -393,6 +386,7 @@ export class TypeFactory {
393
386
  case "float":
394
387
  case "int":
395
388
  return new (datatypeDefinition.kind === "float" ? FloatType : IntType)({
389
+ alias: astType.name.map((name) => this.tsName(name)),
396
390
  comment: astType.comment,
397
391
  configuration: this.configuration,
398
392
  datatype,
@@ -409,6 +403,7 @@ export class TypeFactory {
409
403
  case "string":
410
404
  if (!datatype.equals(rdf.langString)) {
411
405
  return new StringType({
406
+ alias: astType.name.map((name) => this.tsName(name)),
412
407
  comment: astType.comment,
413
408
  configuration: this.configuration,
414
409
  datatype,
@@ -438,6 +433,7 @@ export class TypeFactory {
438
433
  // // this.logger.debug("literal type has no datatypes");
439
434
  // }
440
435
  return new LiteralType({
436
+ alias: astType.name.map((name) => this.tsName(name)),
441
437
  comment: astType.comment,
442
438
  configuration: this.configuration,
443
439
  hasValues: astType.hasValues,
@@ -448,14 +444,14 @@ export class TypeFactory {
448
444
  reusables: this.reusables,
449
445
  });
450
446
  }
451
- createObjectTypeProperty({ astObjectTypeProperty, namedObjectType, }) {
447
+ createObjectTypeProperty({ astObjectTypeProperty, objectType, }) {
452
448
  {
453
449
  const cachedProperty = this.cachedObjectTypePropertiesByShapeIdentifier.get(astObjectTypeProperty.shapeIdentifier);
454
450
  if (cachedProperty) {
455
451
  return cachedProperty;
456
452
  }
457
453
  }
458
- const property = new NamedObjectType.ShaclProperty({
454
+ const property = new ObjectType.ShaclProperty({
459
455
  comment: astObjectTypeProperty.comment,
460
456
  configuration: this.configuration,
461
457
  description: astObjectTypeProperty.description,
@@ -463,7 +459,7 @@ export class TypeFactory {
463
459
  label: astObjectTypeProperty.label,
464
460
  logger: this.logger,
465
461
  mutable: astObjectTypeProperty.mutable,
466
- namedObjectType,
462
+ objectType,
467
463
  name: this.tsName(astObjectTypeProperty.name),
468
464
  path: astObjectTypeProperty.path,
469
465
  recursive: !!astObjectTypeProperty.recursive,
@@ -477,6 +473,7 @@ export class TypeFactory {
477
473
  const itemType = this.createType(astType.itemType);
478
474
  invariant(OptionType.isItemType(itemType));
479
475
  return new OptionType({
476
+ alias: astType.name.map((name) => this.tsName(name)),
480
477
  comment: astType.comment,
481
478
  configuration: this.configuration,
482
479
  itemType,
@@ -489,6 +486,7 @@ export class TypeFactory {
489
486
  const itemType = this.createType(astType.itemType);
490
487
  invariant(SetType.isItemType(itemType));
491
488
  return new SetType({
489
+ alias: astType.name.map((name) => this.tsName(name)),
492
490
  comment: astType.comment,
493
491
  configuration: this.configuration,
494
492
  itemType,
@@ -501,6 +499,7 @@ export class TypeFactory {
501
499
  }
502
500
  createTermType(astType) {
503
501
  return new TermType({
502
+ alias: astType.name.map((name) => this.tsName(name)),
504
503
  comment: astType.comment,
505
504
  configuration: this.configuration,
506
505
  hasValues: astType.hasValues,
@@ -6,26 +6,41 @@ import type { IriType } from "./IriType.js";
6
6
  import type { Type } from "./Type.js";
7
7
  import type { Typeof } from "./Typeof.js";
8
8
  import { type Code } from "./ts-poet-wrapper.js";
9
- export declare abstract class AbstractUnionType<MemberTypeT extends Type> extends AbstractType {
9
+ export declare class UnionType<MemberTypeT extends Type> extends AbstractType {
10
10
  private readonly discriminant;
11
- private readonly identifierType;
11
+ readonly graphqlArgs: AbstractType["graphqlArgs"];
12
+ readonly identifierType: Maybe<BlankNodeType | IdentifierType | IriType>;
13
+ readonly kind: "ObjectUnion" | "Union";
12
14
  readonly recursive: boolean;
15
+ readonly synthetic: boolean;
13
16
  readonly validationFunction: Maybe<Code>;
14
- constructor({ identifierType, members, recursive, ...superParameters }: {
17
+ constructor({ identifierType, members, recursive, synthetic, ...superParameters }: {
15
18
  identifierType: Maybe<BlankNodeType | IdentifierType | IriType>;
16
19
  members: readonly (Pick<AbstractUnionType.Member<MemberTypeT>, "type"> & {
17
20
  readonly discriminantValue: Maybe<number | string>;
18
21
  })[];
19
22
  recursive: boolean;
23
+ synthetic: boolean;
20
24
  } & ConstructorParameters<typeof AbstractType>[0]);
21
25
  get conversionFunction(): Maybe<AbstractType.ConversionFunction>;
26
+ get declaration(): Maybe<Code>;
22
27
  get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
28
+ get equalsFunction(): Code;
29
+ get filterFunction(): Code;
30
+ get filterType(): Code;
31
+ get graphqlType(): AbstractType.GraphqlType;
32
+ get hashFunction(): Code;
33
+ get jsonSchemaFunctionDeclaration(): Code;
34
+ get jsonTypeAliasDeclaration(): Code;
23
35
  get members(): readonly AbstractUnionType.Member<MemberTypeT>[];
24
36
  get mutable(): boolean;
37
+ get expression(): Code;
25
38
  get referencesObjectType(): boolean;
26
39
  get schemaType(): Code;
27
40
  get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
28
41
  get typeofs(): AbstractType["typeofs"];
42
+ get valueSparqlConstructTriplesFunction(): Code;
43
+ get valueSparqlWherePatternsFunction(): Code;
29
44
  protected get inlineEqualsFunction(): Code;
30
45
  protected get inlineFilterFunction(): Code;
31
46
  protected get inlineFilterType(): Code;
@@ -34,14 +49,27 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
34
49
  protected get inlineHashFunction(): Code;
35
50
  protected get inlineJsonSchema(): Code;
36
51
  protected get inlineJsonType(): AbstractType.JsonType;
37
- protected get inlineName(): Code;
52
+ protected get inlineExpression(): Code;
38
53
  protected get inlineToJsonFunction(): Code;
39
54
  protected get inlineToRdfResourceValuesFunction(): Code;
40
55
  protected get inlineToStringFunction(): Code;
41
56
  protected get inlineValueSparqlConstructTriplesFunction(): Code;
42
57
  protected get inlineValueSparqlWherePatternsFunction(): Code;
43
58
  protected get schemaInitializers(): readonly Code[];
59
+ protected get staticModuleDeclarations(): Record<string, Code>;
60
+ fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
61
+ fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
62
+ graphqlResolveExpression({ variables, }: {
63
+ variables: {
64
+ value: Code;
65
+ };
66
+ }): Code;
67
+ jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
68
+ jsonType(): AbstractType.JsonType;
44
69
  jsonUiSchemaElement(): Maybe<Code>;
70
+ toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
71
+ toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
72
+ toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
45
73
  private readonly lazyMembers;
46
74
  }
47
75
  type Discriminant = ExtrinsicDiscriminant | HybridDiscriminant | IntrinsicDiscriminant | TypeofDiscriminant;
@@ -93,4 +121,4 @@ export declare namespace AbstractUnionType {
93
121
  }
94
122
  }
95
123
  export {};
96
- //# sourceMappingURL=AbstractUnionType.d.ts.map
124
+ //# sourceMappingURL=UnionType.d.ts.map