@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
@@ -17,12 +17,12 @@ export declare abstract class AbstractCollectionType<ItemTypeT extends AbstractC
17
17
  } & ConstructorParameters<typeof AbstractContainerType<ItemTypeT>>[0]);
18
18
  get conversionFunction(): Maybe<AbstractType.ConversionFunction>;
19
19
  get equalsFunction(): Code;
20
+ get expression(): Code;
20
21
  get filterFunction(): Code;
21
22
  get filterType(): Code;
22
23
  get graphqlType(): AbstractContainerType.GraphqlType;
23
24
  get hashFunction(): Code;
24
25
  get mutable(): boolean;
25
- get name(): Code;
26
26
  get schemaType(): Code;
27
27
  get validationFunction(): Maybe<Code>;
28
28
  protected get schemaInitializers(): readonly Code[];
@@ -31,13 +31,13 @@ export class AbstractCollectionType extends AbstractContainerType {
31
31
  const itemConversionFunction = this.itemType.conversionFunction.orDefault(this.itemConversionFunctionDefault);
32
32
  const sourceTypes = [
33
33
  {
34
- name: code `readonly (${joinCode(itemConversionFunction.sourceTypes.map((itemSourceType) => code `${itemSourceType.name}`), { on: " | " })})[]`,
34
+ expression: code `readonly (${joinCode(itemConversionFunction.sourceTypes.map((itemSourceType) => code `${itemSourceType.expression}`), { on: " | " })})[]`,
35
35
  typeof: "object",
36
36
  },
37
37
  ];
38
38
  if (this.minCount === 0n) {
39
39
  sourceTypes.push({
40
- name: "undefined",
40
+ expression: code `undefined`,
41
41
  typeof: "undefined",
42
42
  });
43
43
  }
@@ -49,8 +49,11 @@ export class AbstractCollectionType extends AbstractContainerType {
49
49
  get equalsFunction() {
50
50
  return code `((left, right) => ${this.reusables.snippets.arrayEquals}(left, right, ${this.itemType.equalsFunction}))`;
51
51
  }
52
+ get expression() {
53
+ return code `${!this._mutable ? "readonly " : ""}(${this.itemType.expression})[]`;
54
+ }
52
55
  get filterFunction() {
53
- return code `${this.reusables.snippets.filterArray}<${this.itemType.name}, ${this.itemType.filterType}>(${this.itemType.filterFunction})`;
56
+ return code `${this.reusables.snippets.filterArray}<${this.itemType.expression}, ${this.itemType.filterType}>(${this.itemType.filterFunction})`;
54
57
  }
55
58
  get filterType() {
56
59
  return code `${this.reusables.snippets.CollectionFilter}<${this.itemType.filterType}>`;
@@ -64,9 +67,6 @@ export class AbstractCollectionType extends AbstractContainerType {
64
67
  get mutable() {
65
68
  return this._mutable || this.itemType.mutable;
66
69
  }
67
- get name() {
68
- return code `${!this._mutable ? "readonly " : ""}(${this.itemType.name})[]`;
69
- }
70
70
  get schemaType() {
71
71
  return code `${this.reusables.snippets.CollectionSchema}<${this.itemType.schemaType}>`;
72
72
  }
@@ -85,7 +85,7 @@ export class AbstractCollectionType extends AbstractContainerType {
85
85
  if (this.minCount === 0n) {
86
86
  expression = code `(${expression} ?? [])`;
87
87
  }
88
- return code `${this.reusables.imports.Either}.sequence<Error, ${this.itemType.name}>(${expression}.map(item => (${this.itemType.fromJsonExpression({
88
+ return code `${this.reusables.imports.Either}.sequence<Error, ${this.itemType.expression}>(${expression}.map(item => (${this.itemType.fromJsonExpression({
89
89
  variables: { value: code `item` },
90
90
  })})))`;
91
91
  }
@@ -118,6 +118,9 @@ __decorate([
118
118
  __decorate([
119
119
  Memoize()
120
120
  ], AbstractCollectionType.prototype, "equalsFunction", null);
121
+ __decorate([
122
+ Memoize()
123
+ ], AbstractCollectionType.prototype, "expression", null);
121
124
  __decorate([
122
125
  Memoize()
123
126
  ], AbstractCollectionType.prototype, "filterFunction", null);
@@ -130,9 +133,6 @@ __decorate([
130
133
  __decorate([
131
134
  Memoize()
132
135
  ], AbstractCollectionType.prototype, "hashFunction", null);
133
- __decorate([
134
- Memoize()
135
- ], AbstractCollectionType.prototype, "name", null);
136
136
  __decorate([
137
137
  Memoize()
138
138
  ], AbstractCollectionType.prototype, "schemaType", null);
@@ -1,6 +1,5 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { AbstractType } from "./AbstractType.js";
3
- import type { AnonymousUnionType } from "./AnonymousUnionType.js";
4
3
  import type { BigDecimalType } from "./BigDecimalType.js";
5
4
  import type { BigIntType } from "./BigIntType.js";
6
5
  import type { BlankNodeType } from "./BlankNodeType.js";
@@ -13,13 +12,13 @@ import type { IntType } from "./IntType.js";
13
12
  import type { IriType } from "./IriType.js";
14
13
  import type { ListType } from "./ListType.js";
15
14
  import type { LiteralType } from "./LiteralType.js";
16
- import type { NamedObjectType } from "./NamedObjectType.js";
17
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
18
- import type { NamedUnionType } from "./NamedUnionType.js";
15
+ import type { ObjectType } from "./ObjectType.js";
16
+ import type { ObjectUnionType } from "./ObjectUnionType.js";
19
17
  import type { StringType } from "./StringType.js";
20
18
  import type { TermType } from "./TermType.js";
21
19
  import type { Type } from "./Type.js";
22
20
  import { type Code } from "./ts-poet-wrapper.js";
21
+ import type { UnionType } from "./UnionType.js";
23
22
  /**
24
23
  * Abstract base class for types that contain other types e.g., ListType, OptionType, SetType.
25
24
  */
@@ -47,7 +46,7 @@ export declare namespace AbstractContainerType {
47
46
  type DiscriminantProperty = AbstractType.DiscriminantProperty;
48
47
  const GraphqlType: typeof AbstractType.GraphqlType;
49
48
  type GraphqlType = AbstractType.GraphqlType;
50
- type ItemType = AnonymousUnionType | BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | NamedObjectUnionType | NamedUnionType | NamedObjectType | StringType | TermType;
49
+ type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
51
50
  function isItemType(type: Type): type is ItemType;
52
51
  const JsonType: typeof AbstractType.JsonType;
53
52
  type JsonType = AbstractType.JsonType;
@@ -37,7 +37,7 @@ export class AbstractContainerType extends AbstractType {
37
37
  code: code `${this.reusables.snippets.identityConversionFunction}`,
38
38
  sourceTypes: [
39
39
  {
40
- name: this.itemType.name,
40
+ expression: this.itemType.expression,
41
41
  typeof: this.itemType.typeofs[0],
42
42
  },
43
43
  ],
@@ -67,7 +67,6 @@ __decorate([
67
67
  AbstractContainerType.GraphqlType = AbstractType.GraphqlType;
68
68
  function isItemType(type) {
69
69
  switch (type.kind) {
70
- case "AnonymousUnion":
71
70
  case "BigDecimal":
72
71
  case "BigInt":
73
72
  case "BlankNode":
@@ -80,11 +79,11 @@ __decorate([
80
79
  case "Iri":
81
80
  case "List":
82
81
  case "Literal":
83
- case "NamedObjectUnion":
84
- case "NamedUnion":
85
- case "NamedObjectType":
82
+ case "Object":
83
+ case "ObjectUnion":
86
84
  case "String":
87
85
  case "Term":
86
+ case "Union":
88
87
  return true;
89
88
  case "DefaultValue":
90
89
  case "LazyObjectOption":
@@ -2,23 +2,23 @@ import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
2
2
  import { type Code } from "./ts-poet-wrapper.js";
3
3
  export declare abstract class AbstractDateType extends AbstractPrimitiveType<Date> {
4
4
  readonly equalsFunction: Code;
5
+ readonly expression: Code;
5
6
  readonly filterFunction: Code;
6
7
  readonly filterType: Code;
7
8
  abstract readonly kind: "DateTime" | "Date";
8
9
  readonly mutable = false;
9
- readonly name = "Date";
10
10
  readonly schemaType: Code;
11
- readonly valueSparqlWherePatternsFunction: Code;
12
11
  readonly typeofs: "object"[];
12
+ readonly valueSparqlWherePatternsFunction: Code;
13
13
  fromJsonExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromJsonExpression"]>[0]): Code;
14
14
  jsonType(): AbstractPrimitiveType.JsonType;
15
15
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["toRdfResourceValuesExpression"]>[0]): Code;
16
- protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<Date>["fromRdfResourceValuesExpressionChain"]>;
17
16
  protected abstract fromRdfResourceValueExpression(variables: {
18
17
  variables: {
19
18
  value: Code;
20
19
  };
21
20
  }): Code;
21
+ protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<Date>["fromRdfResourceValuesExpressionChain"]>;
22
22
  }
23
23
  export declare namespace AbstractDateType {
24
24
  type ConversionFunction = AbstractPrimitiveType.ConversionFunction;
@@ -9,13 +9,13 @@ import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
9
9
  import { code } from "./ts-poet-wrapper.js";
10
10
  export class AbstractDateType extends AbstractPrimitiveType {
11
11
  equalsFunction = code `${this.reusables.snippets.dateEquals}`;
12
+ expression = code `Date`;
12
13
  filterFunction = code `${this.reusables.snippets.filterDate}`;
13
14
  filterType = code `${this.reusables.snippets.DateFilter}`;
14
15
  mutable = false;
15
- name = "Date";
16
16
  schemaType = code `${this.reusables.snippets.DateSchema}`;
17
- valueSparqlWherePatternsFunction = code `${this.reusables.snippets.dateSparqlWherePatterns}`;
18
17
  typeofs = ["object"];
18
+ valueSparqlWherePatternsFunction = code `${this.reusables.snippets.dateSparqlWherePatterns}`;
19
19
  fromJsonExpression({ variables, }) {
20
20
  return code `${this.reusables.imports.Either}.of<Error, Date>(new Date(${variables.value}))`;
21
21
  }
@@ -1,7 +1,7 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { AbstractType } from "./AbstractType.js";
3
- import type { NamedObjectType } from "./NamedObjectType.js";
4
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
+ 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";
@@ -24,17 +24,17 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
24
24
  resolveType: ResolveTypeT;
25
25
  } & ConstructorParameters<typeof AbstractType>[0]);
26
26
  get equalsFunction(): Code;
27
+ get expression(): Code;
27
28
  get filterFunction(): Code;
28
29
  get filterType(): Code;
29
30
  get graphqlType(): AbstractType.GraphqlType;
30
31
  get hashFunction(): Code;
31
- get name(): Code;
32
32
  get recursive(): boolean;
33
- protected get schemaInitializers(): readonly Code[];
34
33
  get schemaType(): Code;
35
34
  get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
36
35
  get valueSparqlConstructTriplesFunction(): Code;
37
36
  get valueSparqlWherePatternsFunction(): Code;
37
+ protected get schemaInitializers(): readonly Code[];
38
38
  jsonSchema(parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
39
39
  jsonType(parameters?: Parameters<AbstractType["jsonType"]>[0]): AbstractType.JsonType;
40
40
  jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
@@ -45,16 +45,16 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
45
45
  partialType: ObjectTypeT;
46
46
  resolveType: ObjectTypeT;
47
47
  }): Code;
48
- protected resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }: {
49
- resolvedNamedObjectUnionType: NamedObjectUnionType;
50
- partialNamedObjectUnionType: NamedObjectUnionType;
48
+ protected resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }: {
49
+ resolvedObjectUnionType: ObjectUnionType;
50
+ partialObjectUnionType: ObjectUnionType;
51
51
  variables: {
52
52
  resolvedObjectUnion: Code;
53
53
  };
54
54
  }): Code;
55
55
  }
56
56
  export declare namespace AbstractLazyObjectType {
57
- type ObjectTypeConstraint = NamedObjectType | NamedObjectUnionType;
57
+ type ObjectTypeConstraint = ObjectType | ObjectUnionType;
58
58
  type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
59
59
  type ResolveTypeConstraint = PartialTypeConstraint;
60
60
  type ConversionFunction = AbstractType.ConversionFunction;
@@ -26,8 +26,11 @@ export class AbstractLazyObjectType extends AbstractType {
26
26
  get equalsFunction() {
27
27
  return code `((left, right) => ${this.partialType.equalsFunction}(left.${this.runtimeClass.partialPropertyName}, right.${this.runtimeClass.partialPropertyName}))`;
28
28
  }
29
+ get expression() {
30
+ return this.runtimeClass.name;
31
+ }
29
32
  get filterFunction() {
30
- return code `((filter: ${this.filterType}, value: ${this.name}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
33
+ return code `((filter: ${this.filterType}, value: ${this.expression}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
31
34
  }
32
35
  get filterType() {
33
36
  return this.partialType.filterType;
@@ -38,15 +41,9 @@ export class AbstractLazyObjectType extends AbstractType {
38
41
  get hashFunction() {
39
42
  return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
40
43
  }
41
- get name() {
42
- return this.runtimeClass.name;
43
- }
44
44
  get recursive() {
45
45
  return this.partialType.recursive;
46
46
  }
47
- get schemaInitializers() {
48
- return super.schemaInitializers.concat(code `get partialType() { return ${this.partialType.schema}; }`);
49
- }
50
47
  get schemaType() {
51
48
  return code `${{
52
49
  kind: this.kind,
@@ -62,6 +59,9 @@ export class AbstractLazyObjectType extends AbstractType {
62
59
  get valueSparqlWherePatternsFunction() {
63
60
  return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partialType }))`;
64
61
  }
62
+ get schemaInitializers() {
63
+ return super.schemaInitializers.concat(code `get partialType() { return ${this.partialType.schema}; }`);
64
+ }
65
65
  jsonSchema(parameters) {
66
66
  return this.partialType.jsonSchema(parameters);
67
67
  }
@@ -94,26 +94,26 @@ export class AbstractLazyObjectType extends AbstractType {
94
94
  });
95
95
  }
96
96
  resolveToPartialFunction({ partialType, resolveType, }) {
97
- if (partialType.kind === "NamedObjectType") {
98
- return code `${partialType.name}.createUnsafe`;
97
+ if (partialType.kind === "Object") {
98
+ return code `${partialType.alias.unsafeCoerce()}.createUnsafe`;
99
99
  }
100
- invariant(partialType.kind === "NamedObjectUnion");
101
- invariant(resolveType.kind === "NamedObjectUnion");
100
+ invariant(partialType.kind === "ObjectUnion");
101
+ invariant(resolveType.kind === "ObjectUnion");
102
102
  invariant(partialType.members.length === resolveType.members.length);
103
103
  const caseBlocks = resolveType.members.map(({ discriminantValues }, memberI) => {
104
- return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.name}.createUnsafe(resolved);`;
104
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.alias.unsafeCoerce()}.createUnsafe(resolved);`;
105
105
  });
106
106
  caseBlocks.push(code `default: resolved satisfies never; throw new Error("unrecognized type");`);
107
- return code `((resolved: ${resolveType.name}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
107
+ return code `((resolved: ${resolveType.expression}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
108
108
  }
109
- resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }) {
110
- invariant(resolvedNamedObjectUnionType.members.length ===
111
- partialNamedObjectUnionType.members.length);
112
- const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
113
- return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.name}.create(${variables.resolvedObjectUnion});`;
109
+ resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }) {
110
+ invariant(resolvedObjectUnionType.members.length ===
111
+ partialObjectUnionType.members.length);
112
+ const caseBlocks = resolvedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
113
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialObjectUnionType.members[memberI].type.alias.unsafeCoerce()}.create(${variables.resolvedObjectUnion});`;
114
114
  });
115
115
  caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
116
- return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
116
+ return code `switch (${variables.resolvedObjectUnion}.${resolvedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
117
117
  }
118
118
  }
119
119
  __decorate([
@@ -8,7 +8,7 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
8
8
  abstract readonly kind: "BigInt" | "Float" | "Int";
9
9
  get filterFunction(): Code;
10
10
  get filterType(): Code;
11
- get name(): Code | string;
11
+ get expression(): Code;
12
12
  get schemaType(): Code;
13
13
  get valueSparqlWherePatternsFunction(): Code;
14
14
  jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
@@ -18,11 +18,11 @@ export class AbstractNumericType extends AbstractPrimitiveType {
18
18
  get filterType() {
19
19
  return code `${this.reusables.snippets.NumericFilter}<${this.typeofs[0]}>`;
20
20
  }
21
- get name() {
21
+ get expression() {
22
22
  if (this.primitiveIn.length > 0) {
23
23
  return code `${joinCode(this.primitiveIn.map((value) => this.literalExpression(value)), { on: " | " })}`;
24
24
  }
25
- return this.typeofs[0];
25
+ return code `${this.typeofs[0]}`;
26
26
  }
27
27
  get schemaType() {
28
28
  return code `${this.reusables.snippets.NumericSchema}<${this.typeofs[0]}>`;
@@ -62,7 +62,7 @@ __decorate([
62
62
  ], AbstractNumericType.prototype, "filterType", null);
63
63
  __decorate([
64
64
  Memoize()
65
- ], AbstractNumericType.prototype, "name", null);
65
+ ], AbstractNumericType.prototype, "expression", null);
66
66
  __decorate([
67
67
  Memoize()
68
68
  ], AbstractNumericType.prototype, "schemaType", null);
@@ -1,6 +1,7 @@
1
+ import type { Maybe } from "purify-ts";
1
2
  import type { Logger } from "ts-log";
2
- import type { NamedObjectType } from "./NamedObjectType.js";
3
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
+ import type { ObjectType } from "./ObjectType.js";
4
+ import type { ObjectUnionType } from "./ObjectUnionType.js";
4
5
  import type { Reusables } from "./Reusables.js";
5
6
  import type { TsGenerator } from "./TsGenerator.js";
6
7
  import { type Code } from "./ts-poet-wrapper.js";
@@ -8,25 +9,25 @@ export declare abstract class AbstractObjectSetType {
8
9
  protected readonly configuration: TsGenerator.Configuration;
9
10
  protected readonly logger: Logger;
10
11
  protected readonly reusables: Reusables;
11
- protected readonly namedObjectTypes: readonly NamedObjectType[];
12
- protected readonly namedObjectUnionTypes: readonly NamedObjectUnionType[];
12
+ protected readonly namedObjectTypes: readonly ObjectType[];
13
+ protected readonly namedObjectUnionTypes: readonly ObjectUnionType[];
13
14
  constructor({ configuration, logger, namedObjectTypes, namedObjectUnionTypes, reusables, }: {
14
15
  configuration: TsGenerator.Configuration;
15
16
  logger: Logger;
16
- namedObjectTypes: readonly NamedObjectType[];
17
- namedObjectUnionTypes: readonly NamedObjectUnionType[];
17
+ namedObjectTypes: readonly ObjectType[];
18
+ namedObjectUnionTypes: readonly ObjectUnionType[];
18
19
  reusables: Reusables;
19
20
  });
20
21
  abstract readonly declaration: Code;
21
22
  protected methodSignatures(namedObjectType: {
23
+ readonly alias: Maybe<string>;
22
24
  readonly filterType: Code;
23
25
  readonly identifierTypeAlias: Code;
24
- readonly objectSetMethodNames: NamedObjectType.ObjectSetMethodNames;
25
- readonly name: string;
26
+ readonly objectSetMethodNames: ObjectType.ObjectSetMethodNames;
26
27
  }, options?: {
27
28
  parameterNamePrefix?: string;
28
29
  queryT?: string;
29
- }): Readonly<Record<keyof NamedObjectType.ObjectSetMethodNames, {
30
+ }): Readonly<Record<keyof ObjectType.ObjectSetMethodNames, {
30
31
  readonly name: string;
31
32
  readonly parameters: Code;
32
33
  readonly returnType: Code;
@@ -21,7 +21,7 @@ export class AbstractObjectSetType {
21
21
  object: {
22
22
  name: methodNames.object,
23
23
  parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
24
- returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.name}>>`,
24
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.alias.unsafeCoerce()}>>`,
25
25
  },
26
26
  objectCount: {
27
27
  name: methodNames.objectCount,
@@ -36,7 +36,7 @@ export class AbstractObjectSetType {
36
36
  objects: {
37
37
  name: methodNames.objects,
38
38
  parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
39
- returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]>>`,
39
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.alias.unsafeCoerce()}[]>>`,
40
40
  },
41
41
  };
42
42
  }
@@ -29,13 +29,13 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
29
29
  return initializers;
30
30
  }
31
31
  fromJsonExpression({ variables, }) {
32
- return code `${this.reusables.imports.Either}.of<Error, ${this.name}>(${variables.value})`;
32
+ return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${variables.value})`;
33
33
  }
34
34
  graphqlResolveExpression({ variables, }) {
35
35
  return variables.value;
36
36
  }
37
37
  jsonType() {
38
- return new AbstractLiteralType.JsonType(this.name);
38
+ return new AbstractLiteralType.JsonType(this.expression);
39
39
  }
40
40
  toJsonExpression({ variables, }) {
41
41
  return variables.value;
@@ -95,11 +95,11 @@ export class AbstractTermType extends AbstractType {
95
95
  valueToExpression = code `value.toTerm([${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}])`;
96
96
  }
97
97
  else if (this.nodeKinds.size < 3) {
98
- const eitherTypeParameters = code `<Error, ${this.name}>`;
98
+ const eitherTypeParameters = code `<Error, ${this.expression}>`;
99
99
  valueToExpression = code `value.toTerm().chain(term => {
100
100
  switch (term.termType) {
101
101
  ${[...this.nodeKinds].map((nodeKind) => `case "${NodeKind.toTermType(nodeKind)}":`).join("\n")} return ${this.reusables.imports.Either}.of${eitherTypeParameters}(term);
102
- default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.name}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
102
+ default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.expression}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
103
103
  }})`;
104
104
  }
105
105
  else {
@@ -12,6 +12,10 @@ export declare abstract class AbstractType {
12
12
  protected readonly configuration: TsGenerator.Configuration;
13
13
  protected readonly logger: Logger;
14
14
  protected readonly reusables: Reusables;
15
+ /**
16
+ * Alias for this type.
17
+ */
18
+ readonly alias: Maybe<string>;
15
19
  /**
16
20
  * Comment from rdfs:comment.
17
21
  */
@@ -39,6 +43,10 @@ export declare abstract class AbstractType {
39
43
  * $EqualsResult.
40
44
  */
41
45
  abstract readonly equalsFunction: Code;
46
+ /**
47
+ * TypeScript type expression.
48
+ */
49
+ abstract readonly expression: Code;
42
50
  /**
43
51
  * A function (reference or declaration) that takes a filter of filterType (below) and a value of this type
44
52
  * and returns true if the value passes the filter.
@@ -74,10 +82,6 @@ export declare abstract class AbstractType {
74
82
  * Is a value of this type mutable?
75
83
  */
76
84
  abstract readonly mutable: boolean;
77
- /**
78
- * TypeScript name of the type.
79
- */
80
- abstract readonly name: Code | string;
81
85
  /**
82
86
  * Does this type directly or indirectly reference itself?
83
87
  */
@@ -133,7 +137,8 @@ export declare abstract class AbstractType {
133
137
  * - variablePrefix: string prefix to use for new variables
134
138
  */
135
139
  abstract readonly valueSparqlWherePatternsFunction: Code;
136
- constructor({ comment, configuration, label, logger, reusables, }: {
140
+ constructor({ alias, comment, configuration, label, logger, reusables, }: {
141
+ alias: Maybe<string>;
137
142
  comment: Maybe<string>;
138
143
  configuration: TsGenerator.Configuration;
139
144
  label: Maybe<string>;
@@ -160,7 +165,7 @@ export declare abstract class AbstractType {
160
165
  * An expression that converts a Either<Error, rdfjsResource.Resource.Values> to a
161
166
  * Either<Error, rdfjsResource.Resource.Values<this type>>.
162
167
  *
163
- * These expressions are used to deserialize property values in an NamedObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
168
+ * These expressions are used to deserialize property values in an ObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
164
169
  * that has a type parameter of this Type).
165
170
  *
166
171
  * Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
@@ -169,7 +174,7 @@ export declare abstract class AbstractType {
169
174
  * Values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
170
175
  * (if it exists) is always of the first preferred language.
171
176
  *
172
- * variables are runtime variables, most derived from the parameters of the NamedObjectType's fromRdf function:
177
+ * variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
173
178
  * context: unanticipated properties (...) passed to Object.fromRdf
174
179
  * graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
175
180
  * ignoreRdfType: whether the RDF type of objects/object unions should be ignored
@@ -204,7 +209,7 @@ export declare abstract class AbstractType {
204
209
  * Zod schema for the JSON type of this type.
205
210
  *
206
211
  * This method is called in two contexts:
207
- * "property": from a ShaclProperty, while generating the z.object properties of an NamedObjectType
212
+ * "property": from a ShaclProperty, while generating the z.object properties of an ObjectType
208
213
  * "type": from another Type e.g., an OptionType or UnionType
209
214
  *
210
215
  * z.lazy() should only be returned for "property".
@@ -241,7 +246,7 @@ export declare abstract class AbstractType {
241
246
  * An expression that converts a property value of this type to a value or an array of values that can be .add'd to a Resource with
242
247
  * resource.add(predicate, convertedValue, graph)
243
248
  *
244
- * variables are runtime variables, most derived from the parameters of the NamedObjectType's fromRdf function:
249
+ * variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
245
250
  * graph: DefaultGraph | NamedNode | undefined to .add to; if undefined, add to the default graph
246
251
  * propertyPath: predicate path (NamedNode) or InversePath on a predicate path
247
252
  * resource: the Resource to .add to
@@ -271,7 +276,7 @@ export declare namespace AbstractType {
271
276
  interface ConversionFunction {
272
277
  readonly code: Code;
273
278
  readonly sourceTypes: {
274
- readonly name: Code | string;
279
+ readonly expression: Code;
275
280
  readonly typeof: Typeof;
276
281
  }[];
277
282
  }
@@ -14,6 +14,10 @@ export class AbstractType {
14
14
  configuration;
15
15
  logger;
16
16
  reusables;
17
+ /**
18
+ * Alias for this type.
19
+ */
20
+ alias;
17
21
  /**
18
22
  * Comment from rdfs:comment.
19
23
  */
@@ -22,7 +26,8 @@ export class AbstractType {
22
26
  * Label from rdfs:label.
23
27
  */
24
28
  label;
25
- constructor({ comment, configuration, label, logger, reusables, }) {
29
+ constructor({ alias, comment, configuration, label, logger, reusables, }) {
30
+ this.alias = alias;
26
31
  this.comment = comment;
27
32
  this.configuration = configuration;
28
33
  this.label = label;
@@ -3,8 +3,8 @@ import { Maybe } from "purify-ts";
3
3
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
4
4
  import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare class BigDecimalType extends AbstractLiteralType {
6
- readonly name: Code;
7
6
  readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
7
+ readonly expression: Code;
8
8
  readonly filterFunction: Code;
9
9
  readonly filterType: Code;
10
10
  readonly hashFunction: Code;
@@ -9,8 +9,8 @@ import { Memoize } from "typescript-memoize";
9
9
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
10
10
  import { code, literalOf } from "./ts-poet-wrapper.js";
11
11
  export class BigDecimalType extends AbstractLiteralType {
12
- name = code `${this.reusables.imports.BigDecimal}`;
13
12
  conversionFunction = Maybe.empty();
13
+ expression = code `${this.reusables.imports.BigDecimal}`;
14
14
  filterFunction = code `${this.reusables.snippets.filterBigDecimal}`;
15
15
  filterType = code `${this.reusables.snippets.NumericFilter}<${this.reusables.imports.BigDecimal}>`;
16
16
  hashFunction = code `${this.reusables.snippets.hashBigDecimal}`;
@@ -21,7 +21,7 @@ export class BigDecimalType extends AbstractLiteralType {
21
21
  return new AbstractLiteralType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
22
22
  }
23
23
  fromJsonExpression({ variables, }) {
24
- return code `${this.reusables.imports.Either}.encase<Error, ${this.name}>(() => new ${this.name}(${variables.value}))`;
24
+ return code `${this.reusables.imports.Either}.encase<Error, ${this.expression}>(() => new ${this.expression}(${variables.value}))`;
25
25
  }
26
26
  graphqlResolveExpression({ variables, }) {
27
27
  return code `${variables.value}.toFixed()`;
@@ -17,9 +17,9 @@ export class BigIntType extends AbstractNumericType {
17
17
  fromJsonExpression({ variables, }) {
18
18
  let expression = code `BigInt(${variables.value})`;
19
19
  if (this.primitiveIn.length > 0) {
20
- expression = code `${expression} as ${this.name}`;
20
+ expression = code `${expression} as ${this.expression}`;
21
21
  }
22
- return code `${this.reusables.imports.Either}.encase<Error, ${this.name}>(() => ${expression})`;
22
+ return code `${this.reusables.imports.Either}.encase<Error, ${this.expression}>(() => ${expression})`;
23
23
  }
24
24
  jsonSchema(_parameters) {
25
25
  switch (this.primitiveIn.length) {
@@ -4,18 +4,18 @@ import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
4
4
  import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare class BlankNodeType extends AbstractIdentifierType<BlankNode> {
6
6
  readonly conversionFunction: Maybe<AbstractIdentifierType.ConversionFunction>;
7
+ readonly expression: Code;
7
8
  readonly filterFunction: Code;
8
9
  readonly filterType: Code;
9
- readonly parseFunction: Code;
10
10
  readonly kind = "BlankNode";
11
- readonly name: Code;
12
11
  readonly nodeKinds: ReadonlySet<"BlankNode">;
12
+ readonly parseFunction: Code;
13
13
  readonly schemaType: Code;
14
14
  readonly valueSparqlWherePatternsFunction: Code;
15
15
  constructor(superParameters: Omit<ConstructorParameters<typeof AbstractIdentifierType<BlankNode>>[0], "hasValues" | "in_">);
16
16
  fromJsonExpression({ variables, }: Parameters<AbstractIdentifierType<BlankNode>["fromJsonExpression"]>[0]): Code;
17
- jsonType(parameters?: Parameters<AbstractIdentifierType<BlankNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
18
17
  jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractIdentifierType<BlankNode>["jsonSchema"]>[0]): Code;
18
+ jsonType(parameters?: Parameters<AbstractIdentifierType<BlankNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
19
19
  toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractIdentifierType<BlankNode>["toJsonExpression"]>[0]): Code;
20
20
  protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractIdentifierType<BlankNode>["fromRdfResourceValuesExpressionChain"]>[0]): {
21
21
  valueTo: Code;