@shaclmate/compiler 4.0.32 → 4.0.34

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 (220) hide show
  1. package/dist/Compiler.d.ts +0 -3
  2. package/dist/Compiler.js +0 -2
  3. package/dist/ShapesGraphToAstTransformer.d.ts +1 -4
  4. package/dist/ShapesGraphToAstTransformer.js +1 -5
  5. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -3
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -7
  7. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -1
  8. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +1 -3
  9. package/dist/ast/AbstractCompoundType.d.ts +6 -4
  10. package/dist/ast/AbstractCompoundType.js +4 -37
  11. package/dist/ast/ObjectType.d.ts +1 -7
  12. package/dist/ast/ObjectType.js +1 -6
  13. package/dist/generators/ts/AbstractCollectionType.d.ts +8 -8
  14. package/dist/generators/ts/AbstractCollectionType.js +28 -111
  15. package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
  16. package/dist/generators/ts/AbstractDateType.d.ts +4 -9
  17. package/dist/generators/ts/AbstractDateType.js +2 -29
  18. package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
  19. package/dist/generators/ts/AbstractIdentifierType.js +0 -17
  20. package/dist/generators/ts/AbstractLazyObjectType.d.ts +8 -5
  21. package/dist/generators/ts/AbstractLazyObjectType.js +21 -21
  22. package/dist/generators/ts/AbstractLiteralType.d.ts +11 -3
  23. package/dist/generators/ts/AbstractLiteralType.js +1 -1
  24. package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
  25. package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
  26. package/dist/generators/ts/AbstractNumericType.d.ts +9 -8
  27. package/dist/generators/ts/AbstractNumericType.js +18 -11
  28. package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -4
  29. package/dist/generators/ts/AbstractPrimitiveType.js +9 -17
  30. package/dist/generators/ts/AbstractTermType.d.ts +8 -4
  31. package/dist/generators/ts/AbstractTermType.js +11 -51
  32. package/dist/generators/ts/AbstractType.d.ts +26 -22
  33. package/dist/generators/ts/AbstractType.js +4 -2
  34. package/dist/generators/ts/AbstractUnionType.d.ts +2 -2
  35. package/dist/generators/ts/AbstractUnionType.js +25 -36
  36. package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
  37. package/dist/generators/ts/AnonymousUnionType.js +3 -3
  38. package/dist/generators/ts/BigDecimalType.d.ts +5 -3
  39. package/dist/generators/ts/BigDecimalType.js +15 -42
  40. package/dist/generators/ts/BigIntType.d.ts +3 -4
  41. package/dist/generators/ts/BigIntType.js +5 -16
  42. package/dist/generators/ts/BlankNodeType.d.ts +7 -7
  43. package/dist/generators/ts/BlankNodeType.js +14 -2
  44. package/dist/generators/ts/BooleanType.d.ts +6 -8
  45. package/dist/generators/ts/BooleanType.js +18 -11
  46. package/dist/generators/ts/DateTimeType.d.ts +5 -1
  47. package/dist/generators/ts/DateTimeType.js +15 -13
  48. package/dist/generators/ts/DateType.d.ts +5 -1
  49. package/dist/generators/ts/DateType.js +16 -14
  50. package/dist/generators/ts/DefaultValueType.d.ts +5 -6
  51. package/dist/generators/ts/DefaultValueType.js +30 -64
  52. package/dist/generators/ts/FloatType.d.ts +3 -3
  53. package/dist/generators/ts/FloatType.js +5 -5
  54. package/dist/generators/ts/IdentifierType.d.ts +6 -6
  55. package/dist/generators/ts/IdentifierType.js +22 -2
  56. package/dist/generators/ts/IntType.d.ts +3 -3
  57. package/dist/generators/ts/IntType.js +5 -5
  58. package/dist/generators/ts/IriType.d.ts +17 -12
  59. package/dist/generators/ts/IriType.js +39 -29
  60. package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
  61. package/dist/generators/ts/LazyObjectOptionType.js +23 -44
  62. package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
  63. package/dist/generators/ts/LazyObjectSetType.js +19 -29
  64. package/dist/generators/ts/LazyObjectType.d.ts +1 -1
  65. package/dist/generators/ts/LazyObjectType.js +17 -25
  66. package/dist/generators/ts/LiteralType.d.ts +5 -3
  67. package/dist/generators/ts/LiteralType.js +25 -12
  68. package/dist/generators/ts/NamedObjectType.d.ts +6 -9
  69. package/dist/generators/ts/NamedObjectType.js +33 -29
  70. package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
  71. package/dist/generators/ts/NamedObjectUnionType.js +21 -14
  72. package/dist/generators/ts/OptionType.d.ts +4 -4
  73. package/dist/generators/ts/OptionType.js +22 -45
  74. package/dist/generators/ts/Reusables.d.ts +3 -1
  75. package/dist/generators/ts/Reusables.js +2 -1
  76. package/dist/generators/ts/SetType.d.ts +0 -1
  77. package/dist/generators/ts/SetType.js +4 -22
  78. package/dist/generators/ts/SnippetFactory.d.ts +2 -0
  79. package/dist/generators/ts/Snippets.d.ts +40 -8
  80. package/dist/generators/ts/Snippets.js +235 -30
  81. package/dist/generators/ts/StringType.d.ts +6 -9
  82. package/dist/generators/ts/StringType.js +17 -16
  83. package/dist/generators/ts/TermType.d.ts +1 -4
  84. package/dist/generators/ts/TermType.js +14 -8
  85. package/dist/generators/ts/TsGenerator.d.ts +14 -1
  86. package/dist/generators/ts/TsGenerator.js +41 -12
  87. package/dist/generators/ts/TypeFactory.d.ts +8 -4
  88. package/dist/generators/ts/TypeFactory.js +73 -49
  89. package/dist/generators/ts/ZodGenerator.js +6 -3
  90. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +27 -20
  91. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +4 -2
  92. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +7 -7
  93. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -9
  94. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +6 -6
  95. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +35 -39
  96. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +35 -27
  97. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
  98. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
  99. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
  100. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +7 -16
  101. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +26 -32
  102. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
  103. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
  104. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +2 -3
  105. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +6 -8
  106. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +1 -2
  107. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
  108. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
  109. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
  110. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
  111. package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +2 -0
  112. package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.js +1 -1
  113. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -2
  114. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
  115. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
  116. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
  117. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -2
  118. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
  119. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +14 -18
  120. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
  121. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
  122. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +7 -7
  123. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +22 -30
  124. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
  125. package/dist/generators/ts/_snippets/snippets_HashFunction.d.ts +3 -0
  126. package/dist/generators/ts/_snippets/snippets_HashFunction.js +4 -0
  127. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +34 -24
  128. package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +3 -0
  129. package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +6 -0
  130. package/dist/generators/ts/_snippets/snippets_convertToBlankNode.d.ts +3 -0
  131. package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +11 -0
  132. package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.d.ts +3 -0
  133. package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.js +17 -0
  134. package/dist/generators/ts/_snippets/snippets_convertToBoolean.d.ts +3 -0
  135. package/dist/generators/ts/_snippets/snippets_convertToBoolean.js +6 -0
  136. package/dist/generators/ts/_snippets/snippets_convertToDate.d.ts +3 -0
  137. package/dist/generators/ts/_snippets/snippets_convertToDate.js +6 -0
  138. package/dist/generators/ts/_snippets/snippets_convertToDateTime.d.ts +3 -0
  139. package/dist/generators/ts/_snippets/snippets_convertToDateTime.js +6 -0
  140. package/dist/generators/ts/_snippets/snippets_convertToIdentifier.d.ts +3 -0
  141. package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +13 -0
  142. package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.d.ts +3 -0
  143. package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +21 -0
  144. package/dist/generators/ts/_snippets/snippets_convertToIri.d.ts +3 -0
  145. package/dist/generators/ts/_snippets/snippets_convertToIri.js +11 -0
  146. package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts +3 -0
  147. package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +17 -0
  148. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +3 -0
  149. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +15 -0
  150. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +3 -0
  151. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +31 -0
  152. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +3 -0
  153. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +25 -0
  154. package/dist/generators/ts/_snippets/snippets_convertToLiteral.d.ts +3 -0
  155. package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +13 -0
  156. package/dist/generators/ts/_snippets/snippets_convertToMaybe.d.ts +3 -0
  157. package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +19 -0
  158. package/dist/generators/ts/_snippets/snippets_convertToMutableArray.d.ts +3 -0
  159. package/dist/generators/ts/_snippets/snippets_convertToMutableArray.js +14 -0
  160. package/dist/generators/ts/_snippets/snippets_convertToNumeric.d.ts +3 -0
  161. package/dist/generators/ts/_snippets/snippets_convertToNumeric.js +6 -0
  162. package/dist/generators/ts/_snippets/snippets_convertToObject.d.ts +3 -0
  163. package/dist/generators/ts/_snippets/snippets_convertToObject.js +6 -0
  164. package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.d.ts +3 -0
  165. package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.js +14 -0
  166. package/dist/generators/ts/_snippets/snippets_convertToString.d.ts +3 -0
  167. package/dist/generators/ts/_snippets/snippets_convertToString.js +6 -0
  168. package/dist/generators/ts/_snippets/snippets_convertToTerm.d.ts +3 -0
  169. package/dist/generators/ts/_snippets/snippets_convertToTerm.js +6 -0
  170. package/dist/generators/ts/_snippets/snippets_convertToUnion.d.ts +3 -0
  171. package/dist/generators/ts/_snippets/snippets_convertToUnion.js +6 -0
  172. package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.d.ts +3 -0
  173. package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +11 -0
  174. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  175. package/dist/generators/ts/_snippets/snippets_hashArray.d.ts +3 -0
  176. package/dist/generators/ts/_snippets/snippets_hashArray.js +11 -0
  177. package/dist/generators/ts/_snippets/snippets_hashBigDecimal.d.ts +3 -0
  178. package/dist/generators/ts/_snippets/snippets_hashBigDecimal.js +7 -0
  179. package/dist/generators/ts/_snippets/snippets_hashBoolean.d.ts +3 -0
  180. package/dist/generators/ts/_snippets/snippets_hashBoolean.js +7 -0
  181. package/dist/generators/ts/_snippets/snippets_hashDate.d.ts +3 -0
  182. package/dist/generators/ts/_snippets/snippets_hashDate.js +7 -0
  183. package/dist/generators/ts/_snippets/snippets_hashDateTime.d.ts +3 -0
  184. package/dist/generators/ts/_snippets/snippets_hashDateTime.js +7 -0
  185. package/dist/generators/ts/_snippets/snippets_hashMaybe.d.ts +3 -0
  186. package/dist/generators/ts/_snippets/snippets_hashMaybe.js +11 -0
  187. package/dist/generators/ts/_snippets/snippets_hashNumeric.d.ts +3 -0
  188. package/dist/generators/ts/_snippets/snippets_hashNumeric.js +7 -0
  189. package/dist/generators/ts/_snippets/snippets_hashString.d.ts +3 -0
  190. package/dist/generators/ts/_snippets/snippets_hashString.js +7 -0
  191. package/dist/generators/ts/_snippets/snippets_hashTerm.d.ts +3 -0
  192. package/dist/generators/ts/_snippets/snippets_hashTerm.js +12 -0
  193. package/dist/generators/ts/_snippets/snippets_toIsoDateString.d.ts +3 -0
  194. package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -0
  195. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +1 -1
  196. package/dist/generators/ts/graphqlSchemaVariableStatement.js +7 -4
  197. package/dist/generators/ts/objectSetDeclarations.js +4 -34
  198. package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -1
  199. package/dist/generators/ts/objectSetMethodSignatures.js +2 -2
  200. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
  201. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
  202. package/dist/input/ShapesGraph.d.ts +5 -8
  203. package/dist/input/ShapesGraph.js +5 -6
  204. package/dist/input/generated.d.ts +171 -226
  205. package/dist/input/generated.js +565 -2068
  206. package/package.json +6 -6
  207. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +0 -6
  208. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +0 -67
  209. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +0 -3
  210. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +0 -6
  211. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +0 -3
  212. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +0 -6
  213. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +0 -3
  214. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +0 -6
  215. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +0 -3
  216. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +0 -6
  217. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +0 -3
  218. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +0 -6
  219. package/dist/generators/ts/syntheticNamePrefix.d.ts +0 -2
  220. package/dist/generators/ts/syntheticNamePrefix.js +0 -2
@@ -4,10 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { NonEmptyList } from "purify-ts";
8
7
  import { Memoize } from "typescript-memoize";
9
8
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
10
- import { code, literalOf } from "./ts-poet-wrapper.js";
9
+ import { code } from "./ts-poet-wrapper.js";
11
10
  export class AbstractDateType extends AbstractPrimitiveType {
12
11
  equalsFunction = code `${this.reusables.snippets.dateEquals}`;
13
12
  filterFunction = code `${this.reusables.snippets.filterDate}`;
@@ -16,33 +15,10 @@ export class AbstractDateType extends AbstractPrimitiveType {
16
15
  name = "Date";
17
16
  schemaType = code `${this.reusables.snippets.DateSchema}`;
18
17
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.dateSparqlWherePatterns}`;
19
- typeofs = NonEmptyList(["object"]);
20
- get conversions() {
21
- return [
22
- {
23
- conversionExpression: (value) => value,
24
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof Date`,
25
- sourceTypeName: this.name,
26
- sourceTypeof: "object",
27
- },
28
- ];
29
- }
30
- get schemaObject() {
31
- return {
32
- ...super.schemaObject,
33
- in: this.primitiveIn.length > 0
34
- ? this.primitiveIn.map((inValue) => code `new Date(${literalOf(inValue.toISOString())})`)
35
- : undefined,
36
- };
37
- }
18
+ typeofs = ["object"];
38
19
  fromJsonExpression({ variables, }) {
39
20
  return code `new Date(${variables.value})`;
40
21
  }
41
- hashStatements({ variables, }) {
42
- return [
43
- code `${variables.hasher}.update(${variables.value}.toISOString());`,
44
- ];
45
- }
46
22
  jsonType() {
47
23
  return new AbstractPrimitiveType.JsonType(code `string`);
48
24
  }
@@ -60,9 +36,6 @@ export class AbstractDateType extends AbstractPrimitiveType {
60
36
  };
61
37
  }
62
38
  }
63
- __decorate([
64
- Memoize()
65
- ], AbstractDateType.prototype, "conversions", null);
66
39
  __decorate([
67
40
  Memoize()
68
41
  ], AbstractDateType.prototype, "jsonType", null);
@@ -7,8 +7,11 @@ export declare abstract class AbstractIdentifierType<IdentifierT extends BlankNo
7
7
  abstract readonly nodeKinds: ReadonlySet<IdentifierNodeKind>;
8
8
  abstract readonly parseFunction: Code;
9
9
  readonly stringifyFunction: Code;
10
- get conversions(): readonly AbstractTermType.Conversion[];
11
10
  get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
12
11
  graphqlResolveExpression({ variables: { value }, }: Parameters<AbstractTermType["graphqlResolveExpression"]>[0]): Code;
13
12
  }
13
+ export declare namespace AbstractIdentifierType {
14
+ type ConversionFunction = AbstractTermType.ConversionFunction;
15
+ type JsonType = AbstractTermType.JsonType;
16
+ }
14
17
  //# sourceMappingURL=AbstractIdentifierType.d.ts.map
@@ -9,20 +9,6 @@ import { AbstractTermType } from "./AbstractTermType.js";
9
9
  import { code } from "./ts-poet-wrapper.js";
10
10
  export class AbstractIdentifierType extends AbstractTermType {
11
11
  stringifyFunction = code `${this.reusables.imports.NTriplesTerm}.stringify`;
12
- get conversions() {
13
- const conversions = super.conversions.concat();
14
- if (this.nodeKinds.has("IRI")) {
15
- conversions.push({
16
- conversionExpression: (value) => code `${this.reusables.imports.dataFactory}.namedNode(${value})`,
17
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "string"`,
18
- sourceTypeName: this.in_.length > 0
19
- ? code `${this.in_.map((iri) => `"${iri.value}"`).join(" | ")}`
20
- : code `string`,
21
- sourceTypeof: "string",
22
- });
23
- }
24
- return conversions;
25
- }
26
12
  get graphqlType() {
27
13
  return new AbstractTermType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
28
14
  }
@@ -30,9 +16,6 @@ export class AbstractIdentifierType extends AbstractTermType {
30
16
  return code `${this.reusables.imports.NTriplesTerm}.stringify(${value})`;
31
17
  }
32
18
  }
33
- __decorate([
34
- Memoize()
35
- ], AbstractIdentifierType.prototype, "conversions", null);
36
19
  __decorate([
37
20
  Memoize()
38
21
  ], AbstractIdentifierType.prototype, "graphqlType", null);
@@ -1,4 +1,4 @@
1
- import { Maybe, NonEmptyList } from "purify-ts";
1
+ import { Maybe } from "purify-ts";
2
2
  import { AbstractType } from "./AbstractType.js";
3
3
  import type { NamedObjectType } from "./NamedObjectType.js";
4
4
  import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
@@ -16,13 +16,13 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
16
16
  readonly declaration: Maybe<Code>;
17
17
  readonly discriminantProperty: AbstractType["discriminantProperty"];
18
18
  readonly mutable = false;
19
- readonly typeofs: NonEmptyList<"object">;
19
+ readonly typeofs: "object"[];
20
20
  constructor({ partialType, resolveType, ...superParameters }: {
21
21
  partialType: PartialTypeT;
22
22
  resolveType: ResolveTypeT;
23
23
  } & ConstructorParameters<typeof AbstractType>[0]);
24
- get conversions(): readonly AbstractType.Conversion[];
25
24
  get equalsFunction(): Code;
25
+ get hashFunction(): Code;
26
26
  get filterFunction(): Code;
27
27
  get filterType(): Code;
28
28
  get graphqlType(): AbstractType.GraphqlType;
@@ -37,7 +37,6 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
37
37
  partial: Code;
38
38
  kind: Code;
39
39
  };
40
- hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
41
40
  jsonSchema(parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
42
41
  jsonType(parameters?: Parameters<AbstractType["jsonType"]>[0]): AbstractType.JsonType;
43
42
  jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
@@ -51,12 +50,16 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
51
50
  resolvedObjectUnion: Code;
52
51
  };
53
52
  }): Code;
53
+ protected resolveToPartialFunction<ObjectTypeT extends AbstractLazyObjectType.ObjectTypeConstraint>({ partialType, resolveType, }: {
54
+ partialType: ObjectTypeT;
55
+ resolveType: ObjectTypeT;
56
+ }): Code;
54
57
  }
55
58
  export declare namespace AbstractLazyObjectType {
56
59
  type ObjectTypeConstraint = NamedObjectType | NamedObjectUnionType;
57
60
  type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
58
61
  type ResolveTypeConstraint = PartialTypeConstraint;
59
- type Conversion = AbstractType.Conversion;
62
+ type ConversionFunction = AbstractType.ConversionFunction;
60
63
  type DiscriminantProperty = AbstractType.DiscriminantProperty;
61
64
  const GraphqlType: typeof AbstractType.GraphqlType;
62
65
  type GraphqlType = AbstractType.GraphqlType;
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { Maybe, NonEmptyList } from "purify-ts";
7
+ import { Maybe } from "purify-ts";
8
8
  import { invariant } from "ts-invariant";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractType } from "./AbstractType.js";
@@ -16,25 +16,18 @@ export class AbstractLazyObjectType extends AbstractType {
16
16
  declaration = Maybe.empty();
17
17
  discriminantProperty = Maybe.empty();
18
18
  mutable = false;
19
- typeofs = NonEmptyList(["object"]);
19
+ typeofs = ["object"];
20
20
  constructor({ partialType, resolveType, ...superParameters }) {
21
21
  super(superParameters);
22
22
  this.partialType = partialType;
23
23
  this.resolveType = resolveType;
24
24
  }
25
- get conversions() {
26
- return [
27
- {
28
- conversionExpression: (value) => value,
29
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof ${this.runtimeClass.rawName}`,
30
- sourceTypeName: this.name,
31
- sourceTypeof: "object",
32
- },
33
- ];
34
- }
35
25
  get equalsFunction() {
36
26
  return code `((left, right) => ${this.partialType.equalsFunction}(left.${this.runtimeClass.partialPropertyName}, right.${this.runtimeClass.partialPropertyName}))`;
37
27
  }
28
+ get hashFunction() {
29
+ return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
30
+ }
38
31
  get filterFunction() {
39
32
  return code `((filter: ${this.filterType}, value: ${this.name}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
40
33
  }
@@ -77,15 +70,6 @@ export class AbstractLazyObjectType extends AbstractType {
77
70
  // resolved: code`() => (${this.resolveType.schema})`,
78
71
  };
79
72
  }
80
- hashStatements({ depth, variables, }) {
81
- return this.partialType.hashStatements({
82
- depth: depth + 1,
83
- variables: {
84
- ...variables,
85
- value: code `${variables.value}.${this.runtimeClass.partialPropertyName}`,
86
- },
87
- });
88
- }
89
73
  jsonSchema(parameters) {
90
74
  return this.partialType.jsonSchema(parameters);
91
75
  }
@@ -126,10 +110,26 @@ export class AbstractLazyObjectType extends AbstractType {
126
110
  caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
127
111
  return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
128
112
  }
113
+ resolveToPartialFunction({ partialType, resolveType, }) {
114
+ if (partialType.kind === "NamedObjectType") {
115
+ return code `${partialType.name}.createUnsafe`;
116
+ }
117
+ invariant(partialType.kind === "NamedObjectUnionType");
118
+ invariant(resolveType.kind === "NamedObjectUnionType");
119
+ invariant(partialType.members.length === resolveType.members.length);
120
+ const caseBlocks = resolveType.members.map(({ discriminantValues }, memberI) => {
121
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.name}.createUnsafe(resolved);`;
122
+ });
123
+ caseBlocks.push(code `default: resolved satisfies never; throw new Error("unrecognized type");`);
124
+ return code `((resolved: ${resolveType.name}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
125
+ }
129
126
  }
130
127
  __decorate([
131
128
  Memoize()
132
129
  ], AbstractLazyObjectType.prototype, "equalsFunction", null);
130
+ __decorate([
131
+ Memoize()
132
+ ], AbstractLazyObjectType.prototype, "hashFunction", null);
133
133
  __decorate([
134
134
  Memoize()
135
135
  ], AbstractLazyObjectType.prototype, "filterFunction", null);
@@ -1,20 +1,28 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
2
  import { AbstractTermType } from "./AbstractTermType.js";
3
+ import { type Code } from "./ts-poet-wrapper.js";
3
4
  export declare abstract class AbstractLiteralType extends AbstractTermType<Literal, Literal> {
4
- readonly nodeKinds: ReadonlySet<"Literal">;
5
5
  protected readonly languageIn: readonly string[];
6
+ readonly nodeKinds: ReadonlySet<"Literal">;
6
7
  constructor({ languageIn, ...superParameters }: {
7
8
  languageIn: readonly string[];
8
9
  } & ConstructorParameters<typeof AbstractTermType<Literal, Literal>>[0]);
9
10
  get constrained(): boolean;
10
11
  protected get schemaObject(): {
11
12
  languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
12
- kind: import("ts-poet/build/Code.js").Code;
13
+ in: Code | undefined;
14
+ kind: Code;
13
15
  };
16
+ /**
17
+ * An expression that converts a compile-time RDF/JS Literal into a runtime TypeScript literal.
18
+ *
19
+ * For example, a string would be converted to "thestring".
20
+ */
21
+ abstract literalExpression(literal: Literal): Code;
14
22
  protected fromRdfExpressionChain({ variables, }: Parameters<AbstractTermType<Literal, Literal>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractTermType<Literal, Literal>["fromRdfExpressionChain"]>;
15
23
  }
16
24
  export declare namespace AbstractLiteralType {
17
- type Conversion = AbstractTermType.Conversion;
25
+ type ConversionFunction = AbstractTermType.ConversionFunction;
18
26
  type DiscriminantProperty = AbstractTermType.DiscriminantProperty;
19
27
  const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
20
28
  type GraphqlType = AbstractTermType.GraphqlType;
@@ -1,8 +1,8 @@
1
1
  import { AbstractTermType } from "./AbstractTermType.js";
2
2
  import { code, literalOf } from "./ts-poet-wrapper.js";
3
3
  export class AbstractLiteralType extends AbstractTermType {
4
- nodeKinds = nodeKinds;
5
4
  languageIn;
5
+ nodeKinds = nodeKinds;
6
6
  constructor({ languageIn, ...superParameters }) {
7
7
  super(superParameters);
8
8
  this.languageIn = languageIn;
@@ -1,20 +1,18 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { AbstractType } from "./AbstractType.js";
3
3
  import { AbstractUnionType } from "./AbstractUnionType.js";
4
- import type { TsFeature } from "./TsFeature.js";
5
4
  import type { Type } from "./Type.js";
6
5
  import { type Code } from "./ts-poet-wrapper.js";
7
6
  export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> extends AbstractUnionType<MemberTypeT> {
8
7
  protected readonly _name: string;
9
- readonly features: ReadonlySet<TsFeature>;
10
- constructor({ features, name, ...superParameters }: {
11
- features: ReadonlySet<TsFeature>;
8
+ constructor({ name, ...superParameters }: {
12
9
  name: string;
13
10
  } & ConstructorParameters<typeof AbstractUnionType<MemberTypeT>>[0]);
14
11
  get declaration(): Maybe<Code>;
15
12
  get equalsFunction(): Code;
16
13
  get filterFunction(): Code;
17
14
  get filterType(): Code;
15
+ get hashFunction(): Code;
18
16
  get jsonSchemaFunctionDeclaration(): Code;
19
17
  get jsonTypeAliasDeclaration(): Code;
20
18
  get name(): string;
@@ -23,7 +21,6 @@ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> e
23
21
  protected get staticModuleDeclarations(): Record<string, Code>;
24
22
  fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
25
23
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
26
- hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
27
24
  jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
28
25
  jsonType(): AbstractType.JsonType;
29
26
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
@@ -8,14 +8,11 @@ import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractType } from "./AbstractType.js";
10
10
  import { AbstractUnionType } from "./AbstractUnionType.js";
11
- import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
12
11
  import { code, def, joinCode } from "./ts-poet-wrapper.js";
13
12
  export class AbstractNamedUnionType extends AbstractUnionType {
14
13
  _name;
15
- features;
16
- constructor({ features, name, ...superParameters }) {
14
+ constructor({ name, ...superParameters }) {
17
15
  super(superParameters);
18
- this.features = features;
19
16
  this._name = name;
20
17
  }
21
18
  get declaration() {
@@ -34,10 +31,7 @@ ${joinCode(staticModuleDeclarations
34
31
  return Maybe.of(joinCode(declarations, { on: "\n\n" }));
35
32
  }
36
33
  get equalsFunction() {
37
- if (this.features.has("equals")) {
38
- return code `${this.name}.equals`;
39
- }
40
- return this.inlineEqualsFunction;
34
+ return code `${this.name}.equals`;
41
35
  }
42
36
  get filterFunction() {
43
37
  return code `${this.name}.filter`;
@@ -45,6 +39,9 @@ ${joinCode(staticModuleDeclarations
45
39
  get filterType() {
46
40
  return code `${this.name}.Filter`;
47
41
  }
42
+ get hashFunction() {
43
+ return code `${this.name}.hash`;
44
+ }
48
45
  get jsonSchemaFunctionDeclaration() {
49
46
  const meta = {
50
47
  // id: this.name,
@@ -64,20 +61,14 @@ ${joinCode(staticModuleDeclarations
64
61
  return this._name;
65
62
  }
66
63
  get valueSparqlConstructTriplesFunction() {
67
- if (this.features.has("sparql")) {
68
- return code `${this.name}.valueSparqlConstructTriples`;
69
- }
70
- return this.inlineValueSparqlConstructTriplesFunction;
64
+ return code `${this.name}.valueSparqlConstructTriples`;
71
65
  }
72
66
  get valueSparqlWherePatternsFunction() {
73
- if (this.features.has("sparql")) {
74
- return code `${this.name}.valueSparqlWherePatterns`;
75
- }
76
- return this.inlineValueSparqlWherePatternsFunction;
67
+ return code `${this.name}.valueSparqlWherePatterns`;
77
68
  }
78
69
  get staticModuleDeclarations() {
79
70
  const staticModuleDeclarations = {};
80
- if (this.features.has("equals")) {
71
+ if (this.configuration.features.has("equals")) {
81
72
  staticModuleDeclarations[`equals`] =
82
73
  code `export const equals = ${this.inlineEqualsFunction};`;
83
74
  }
@@ -85,11 +76,11 @@ ${joinCode(staticModuleDeclarations
85
76
  code `export type Filter = ${this.inlineFilterType};`;
86
77
  staticModuleDeclarations[`filter`] =
87
78
  code `export const filter = ${this.inlineFilterFunction};`;
88
- if (this.features.has("hash")) {
79
+ if (this.configuration.features.has("hash")) {
89
80
  staticModuleDeclarations[`hash`] =
90
- code `export function hash<HasherT extends ${this.reusables.snippets.Hasher}>(value: ${this._name}, hasher: HasherT): HasherT { ${this.inlineHashStatements({ depth: 0, variables: { hasher: code `hasher`, value: code `value` } })} return hasher; }`;
81
+ code `export const hash = ${this.inlineHashFunction};`;
91
82
  }
92
- if (this.features.has("json")) {
83
+ if (this.configuration.features.has("json")) {
93
84
  staticModuleDeclarations[`Json`] = code `\
94
85
  ${this.jsonTypeAliasDeclaration}
95
86
 
@@ -107,74 +98,49 @@ export namespace Json {
107
98
  staticModuleDeclarations[`toJson`] =
108
99
  code `export const toJson = ${this.inlineToJsonFunction};`;
109
100
  }
110
- if (this.features.has("rdf")) {
101
+ if (this.configuration.features.has("rdf")) {
111
102
  staticModuleDeclarations[`fromRdfResourceValues`] =
112
103
  code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.name}> = ${this.inlineFromRdfResourceValuesFunction};`;
113
104
  staticModuleDeclarations[`toRdfResourceValues`] =
114
105
  code `export const toRdfResourceValues = ${this.inlineToRdfResourceValuesFunction};`;
115
106
  }
116
- if (this.features.has("sparql")) {
107
+ if (this.configuration.features.has("sparql")) {
117
108
  staticModuleDeclarations[`valueSparqlConstructTriples`] =
118
109
  code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
119
110
  staticModuleDeclarations[`valueSparqlWherePatterns`] =
120
111
  code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
121
112
  }
113
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
122
114
  staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
123
115
  code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
124
116
  return staticModuleDeclarations;
125
117
  }
126
118
  fromJsonExpression({ variables, }) {
127
- if (this.features.has("json")) {
128
- return code `${this.name}.fromJson(${variables.value})`;
129
- }
130
- return code `${this.inlineFromJsonFunction}(${variables.value})`;
119
+ return code `${this.name}.fromJson(${variables.value})`;
131
120
  }
132
121
  fromRdfResourceValuesExpression({ variables, }) {
133
122
  const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
134
- if (this.features.has("rdf")) {
135
- return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
136
- }
137
- return code `${this.inlineFromRdfResourceValuesFunction}(${resourceValuesVariable}, ${otherVariables})`;
138
- }
139
- hashStatements({ depth, variables, }) {
140
- if (this.features.has("hash")) {
141
- return [
142
- code `${this.name}.hash(${variables.value}, ${variables.hasher});`,
143
- ];
144
- }
145
- return this.inlineHashStatements({ depth, variables });
123
+ return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
146
124
  }
147
125
  jsonSchema({ context, }) {
148
- if (this.features.has("json")) {
149
- const expression = code `${this.name}.Json.schema()`;
150
- if (context === "property" && this.recursive) {
151
- return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.name}.Json> => ${expression})`;
152
- }
153
- return expression;
126
+ const expression = code `${this.name}.Json.schema()`;
127
+ if (context === "property" && this.recursive) {
128
+ return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.name}.Json> => ${expression})`;
154
129
  }
155
- return this.inlineJsonSchema;
130
+ return expression;
156
131
  }
157
132
  jsonType() {
158
- if (this.features.has("json")) {
159
- return new AbstractType.JsonType(`${this.name}.Json`);
160
- }
161
- return this.inlineJsonType;
133
+ return new AbstractType.JsonType(`${this.name}.Json`);
162
134
  }
163
135
  toJsonExpression({ variables, }) {
164
- if (this.features.has("json")) {
165
- return code `${this.name}.toJson(${variables.value})`;
166
- }
167
- return code `${this.inlineToJsonFunction}(${variables.value})`;
136
+ return code `${this.name}.toJson(${variables.value})`;
168
137
  }
169
138
  toRdfResourceValuesExpression({ variables, }) {
170
139
  const { value: valueVariable, ...otherVariables } = variables;
171
- if (this.features.has("rdf")) {
172
- return code `${this.name}.toRdfResourceValues(${valueVariable}, ${otherVariables})`;
173
- }
174
- return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
140
+ return code `${this.name}.toRdfResourceValues(${valueVariable}, ${otherVariables})`;
175
141
  }
176
142
  toStringExpression({ variables, }) {
177
- return code `${this.name}.${syntheticNamePrefix}toString(${variables.value})`;
143
+ return code `${this.name}.${this.configuration.syntheticNamePrefix}toString(${variables.value})`;
178
144
  }
179
145
  }
180
146
  __decorate([
@@ -189,6 +155,9 @@ __decorate([
189
155
  __decorate([
190
156
  Memoize()
191
157
  ], AbstractNamedUnionType.prototype, "filterType", null);
158
+ __decorate([
159
+ Memoize()
160
+ ], AbstractNamedUnionType.prototype, "hashFunction", null);
192
161
  __decorate([
193
162
  Memoize()
194
163
  ], AbstractNamedUnionType.prototype, "name", null);
@@ -4,17 +4,20 @@ import { type Code } from "./ts-poet-wrapper.js";
4
4
  * Abstract base class for TypeScript numeric types (bigint | number).
5
5
  */
6
6
  export declare abstract class AbstractNumericType<ValueT extends bigint | number> extends AbstractPrimitiveType<ValueT> {
7
+ readonly hashFunction: Code;
7
8
  abstract readonly kind: "BigIntType" | "FloatType" | "IntType";
9
+ get conversionFunction(): {
10
+ code: Code;
11
+ sourceTypes: {
12
+ name: string | Code;
13
+ typeof: import("./Typeof.js").Typeof;
14
+ }[];
15
+ };
8
16
  get filterFunction(): Code;
9
17
  get filterType(): Code;
10
- get name(): string;
18
+ get name(): Code | string;
11
19
  get schemaType(): Code;
12
20
  get valueSparqlWherePatternsFunction(): Code;
13
- protected get schemaObject(): {
14
- in: Code[] | undefined;
15
- languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
16
- kind: Code;
17
- };
18
21
  jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
19
22
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
20
23
  protected fromRdfExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>;
@@ -23,10 +26,8 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
23
26
  value: Code;
24
27
  };
25
28
  }): Code;
26
- protected abstract literalOf(value: ValueT): string;
27
29
  }
28
30
  export declare namespace AbstractNumericType {
29
- type Conversion = AbstractPrimitiveType.Conversion;
30
31
  const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
31
32
  type JsonType = AbstractPrimitiveType.JsonType;
32
33
  }
@@ -11,6 +11,18 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
11
11
  * Abstract base class for TypeScript numeric types (bigint | number).
12
12
  */
13
13
  export class AbstractNumericType extends AbstractPrimitiveType {
14
+ hashFunction = code `${this.reusables.snippets.hashNumeric}`;
15
+ get conversionFunction() {
16
+ return {
17
+ code: code `${this.reusables.snippets.convertToNumeric}<${this.name}>`,
18
+ sourceTypes: [
19
+ {
20
+ name: this.name,
21
+ typeof: this.typeofs[0],
22
+ },
23
+ ],
24
+ };
25
+ }
14
26
  get filterFunction() {
15
27
  return code `${this.reusables.snippets.filterNumeric}<${this.typeofs[0]}>`;
16
28
  }
@@ -19,7 +31,7 @@ export class AbstractNumericType extends AbstractPrimitiveType {
19
31
  }
20
32
  get name() {
21
33
  if (this.primitiveIn.length > 0) {
22
- return `${this.primitiveIn.map((value) => this.literalOf(value)).join(" | ")}`;
34
+ return code `${joinCode(this.primitiveIn.map((value) => this.literalExpression(value)), { on: " | " })}`;
23
35
  }
24
36
  return this.typeofs[0];
25
37
  }
@@ -29,22 +41,14 @@ export class AbstractNumericType extends AbstractPrimitiveType {
29
41
  get valueSparqlWherePatternsFunction() {
30
42
  return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.typeofs[0]}>`;
31
43
  }
32
- get schemaObject() {
33
- return {
34
- ...super.schemaObject,
35
- in: this.primitiveIn.length > 0
36
- ? this.primitiveIn.map((_) => code `${this.literalOf(_)}`)
37
- : undefined,
38
- };
39
- }
40
44
  jsonSchema(_parameters) {
41
45
  switch (this.primitiveIn.length) {
42
46
  case 0:
43
47
  return code `${this.reusables.imports.z}.${this.typeofs[0]}()`;
44
48
  case 1:
45
- return code `${this.reusables.imports.z}.literal(${this.literalOf(this.primitiveIn[0])})`;
49
+ return code `${this.reusables.imports.z}.literal(${this.literalExpression(this.primitiveIn[0])})`;
46
50
  default:
47
- return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalOf(value)})`), { on: "," })}])`;
51
+ return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalExpression(value)})`), { on: "," })}])`;
48
52
  }
49
53
  }
50
54
  toRdfResourceValuesExpression({ variables, }) {
@@ -61,6 +65,9 @@ export class AbstractNumericType extends AbstractPrimitiveType {
61
65
  };
62
66
  }
63
67
  }
68
+ __decorate([
69
+ Memoize()
70
+ ], AbstractNumericType.prototype, "conversionFunction", null);
64
71
  __decorate([
65
72
  Memoize()
66
73
  ], AbstractNumericType.prototype, "filterFunction", null);
@@ -1,4 +1,4 @@
1
- import type { NamedNode } from "@rdfjs/types";
1
+ import type { Literal, NamedNode } from "@rdfjs/types";
2
2
  import { Maybe } from "purify-ts";
3
3
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
4
4
  import { type Code } from "./ts-poet-wrapper.js";
@@ -11,16 +11,20 @@ export declare abstract class AbstractPrimitiveType<ValueT extends bigint | bool
11
11
  datatype: NamedNode;
12
12
  primitiveIn: readonly ValueT[];
13
13
  } & ConstructorParameters<typeof AbstractLiteralType>[0]);
14
- get conversions(): readonly AbstractPrimitiveType.Conversion[];
15
14
  get discriminantProperty(): Maybe<AbstractLiteralType.DiscriminantProperty>;
15
+ protected get schemaObject(): {
16
+ in: Code | undefined;
17
+ languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
18
+ kind: Code;
19
+ };
16
20
  fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
17
21
  graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
18
- hashStatements({ variables, }: Parameters<AbstractLiteralType["hashStatements"]>[0]): readonly Code[];
19
22
  jsonType(): AbstractLiteralType.JsonType;
23
+ abstract literalExpression(literal: Literal | ValueT): Code;
20
24
  toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
21
25
  }
22
26
  export declare namespace AbstractPrimitiveType {
23
- type Conversion = AbstractLiteralType.Conversion;
27
+ type ConversionFunction = AbstractLiteralType.ConversionFunction;
24
28
  type DiscriminantProperty = AbstractLiteralType.DiscriminantProperty;
25
29
  const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
26
30
  type GraphqlType = AbstractLiteralType.GraphqlType;