@shaclmate/compiler 4.0.33 → 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 +34 -31
  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 +563 -2082
  206. package/package.json +2 -2
  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
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
10
- import { code } from "./ts-poet-wrapper.js";
10
+ import { code, joinCode } from "./ts-poet-wrapper.js";
11
11
  export class AbstractPrimitiveType extends AbstractLiteralType {
12
12
  datatype;
13
13
  equalsFunction = code `${this.reusables.snippets.strictEquals}`;
@@ -17,28 +17,23 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
17
17
  this.datatype = datatype;
18
18
  this.primitiveIn = primitiveIn;
19
19
  }
20
- get conversions() {
21
- return [
22
- {
23
- conversionExpression: (value) => value,
24
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "${this.typeofs[0]}"`,
25
- sourceTypeName: this.name,
26
- sourceTypeof: this.typeofs[0],
27
- },
28
- ];
29
- }
30
20
  get discriminantProperty() {
31
21
  return Maybe.empty();
32
22
  }
23
+ get schemaObject() {
24
+ return {
25
+ ...super.schemaObject,
26
+ in: this.primitiveIn.length > 0
27
+ ? code `[${joinCode(this.primitiveIn.map((in_) => this.literalExpression(in_)), { on: ", " })}] as const`
28
+ : undefined,
29
+ };
30
+ }
33
31
  fromJsonExpression({ variables, }) {
34
32
  return variables.value;
35
33
  }
36
34
  graphqlResolveExpression({ variables, }) {
37
35
  return variables.value;
38
36
  }
39
- hashStatements({ variables, }) {
40
- return [code `${variables.hasher}.update(${variables.value}.toString());`];
41
- }
42
37
  jsonType() {
43
38
  return new AbstractLiteralType.JsonType(this.name);
44
39
  }
@@ -46,9 +41,6 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
46
41
  return variables.value;
47
42
  }
48
43
  }
49
- __decorate([
50
- Memoize()
51
- ], AbstractPrimitiveType.prototype, "conversions", null);
52
44
  __decorate([
53
45
  Memoize()
54
46
  ], AbstractPrimitiveType.prototype, "jsonType", null);
@@ -3,6 +3,7 @@ import { NodeKind } from "@shaclmate/shacl-ast";
3
3
  import { Maybe } from "purify-ts";
4
4
  import { AbstractType } from "./AbstractType.js";
5
5
  import type { Type } from "./Type.js";
6
+ import type { Typeof } from "./Typeof.js";
6
7
  import { type Code } from "./ts-poet-wrapper.js";
7
8
  /**
8
9
  * Abstract base class for IdentifierType and LiteralType.
@@ -17,24 +18,27 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
17
18
  readonly equalsFunction: Code;
18
19
  readonly graphqlArgs: AbstractType["graphqlArgs"];
19
20
  readonly hasValues: readonly ConstantTermT[];
21
+ readonly hashFunction: Code;
20
22
  readonly in_: readonly ConstantTermT[];
21
23
  readonly mutable: boolean;
22
24
  abstract readonly nodeKinds: ReadonlySet<NodeKind>;
23
25
  readonly recursive = false;
24
- readonly typeofs: AbstractType["typeofs"];
26
+ readonly typeofs: readonly Typeof[];
25
27
  constructor({ hasValues, in_, ...superParameters }: {
26
28
  hasValues: readonly ConstantTermT[];
27
29
  in_: readonly ConstantTermT[];
28
30
  } & ConstructorParameters<typeof AbstractType>[0]);
29
31
  get constrained(): boolean;
30
- get conversions(): readonly AbstractType.Conversion[];
31
32
  get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
32
33
  get schema(): Code;
34
+ protected get schemaObject(): {
35
+ in: Code | undefined;
36
+ kind: Code;
37
+ };
33
38
  get termTypes(): ReadonlySet<"BlankNode" | "Literal" | "NamedNode">;
34
39
  get toRdfResourceValueTypes(): Set<"BlankNode" | "Literal" | "NamedNode">;
35
40
  get valueSparqlConstructTriplesFunction(): Code;
36
41
  fromRdfResourceValuesExpression(parameters: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
37
- hashStatements({ variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
38
42
  jsonUiSchemaElement(): Maybe<Code>;
39
43
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
40
44
  toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
@@ -55,7 +59,7 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
55
59
  };
56
60
  }
57
61
  export declare namespace AbstractTermType {
58
- type Conversion = AbstractType.Conversion;
62
+ type ConversionFunction = AbstractType.ConversionFunction;
59
63
  type DiscriminantProperty = AbstractType.DiscriminantProperty;
60
64
  const GraphqlType: typeof AbstractType.GraphqlType;
61
65
  type GraphqlType = AbstractType.GraphqlType;
@@ -5,7 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { NodeKind } from "@shaclmate/shacl-ast";
8
- import { Maybe, NonEmptyList } from "purify-ts";
8
+ import { Maybe } from "purify-ts";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractType } from "./AbstractType.js";
11
11
  import { removeUndefined } from "./removeUndefined.js";
@@ -23,12 +23,11 @@ export class AbstractTermType extends AbstractType {
23
23
  equalsFunction = code `${this.reusables.snippets.booleanEquals}`;
24
24
  graphqlArgs = Maybe.empty();
25
25
  hasValues;
26
+ hashFunction = code `${this.reusables.snippets.hashTerm}`;
26
27
  in_;
27
28
  mutable = false;
28
29
  recursive = false;
29
- typeofs = NonEmptyList([
30
- "object",
31
- ]);
30
+ typeofs = ["object"];
32
31
  constructor({ hasValues, in_, ...superParameters }) {
33
32
  super(superParameters);
34
33
  this.hasValues = hasValues;
@@ -37,44 +36,6 @@ export class AbstractTermType extends AbstractType {
37
36
  get constrained() {
38
37
  return this.hasValues.length > 0 || this.in_.length > 0;
39
38
  }
40
- get conversions() {
41
- const conversions = [];
42
- if (this.nodeKinds.has("Literal")) {
43
- conversions.push({
44
- conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.bigint(${value})`,
45
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "bigint"`,
46
- sourceTypeName: code `bigint`,
47
- sourceTypeof: "bigint",
48
- }, {
49
- conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.boolean(${value})`,
50
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "boolean"`,
51
- sourceTypeName: code `boolean`,
52
- sourceTypeof: "boolean",
53
- }, {
54
- conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.date(${value})`,
55
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof Date`,
56
- sourceTypeName: code `Date`,
57
- sourceTypeof: "object",
58
- }, {
59
- conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.number(${value})`,
60
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "number"`,
61
- sourceTypeName: code `number`,
62
- sourceTypeof: "number",
63
- }, {
64
- conversionExpression: (value) => code `${this.reusables.snippets.literalFactory}.string(${value})`,
65
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "string"`,
66
- sourceTypeName: code `string`,
67
- sourceTypeof: "string",
68
- });
69
- }
70
- conversions.push({
71
- conversionExpression: (value) => value,
72
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
73
- sourceTypeName: this.name,
74
- sourceTypeof: "object",
75
- });
76
- return conversions;
77
- }
78
39
  get discriminantProperty() {
79
40
  return Maybe.of({
80
41
  descendantValues: [],
@@ -87,6 +48,14 @@ export class AbstractTermType extends AbstractType {
87
48
  get schema() {
88
49
  return code `${removeUndefined(this.schemaObject)}`;
89
50
  }
51
+ get schemaObject() {
52
+ return {
53
+ ...super.schemaObject,
54
+ in: this.in_.length > 0
55
+ ? code `[${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}] as const`
56
+ : undefined,
57
+ };
58
+ }
90
59
  get termTypes() {
91
60
  return new Set([...this.nodeKinds].map(NodeKind.toTermType));
92
61
  }
@@ -112,12 +81,6 @@ export class AbstractTermType extends AbstractType {
112
81
  chain.valueTo,
113
82
  ].filter((_) => _ !== undefined), { on: "." });
114
83
  }
115
- hashStatements({ variables, }) {
116
- return [
117
- code `${variables.hasher}.update(${variables.value}.termType);`,
118
- code `${variables.hasher}.update(${variables.value}.value);`,
119
- ];
120
- }
121
84
  jsonUiSchemaElement() {
122
85
  return Maybe.empty();
123
86
  }
@@ -161,9 +124,6 @@ chain(values => ${this.reusables.imports.Either}.sequence([${joinCode(this.hasVa
161
124
  };
162
125
  }
163
126
  }
164
- __decorate([
165
- Memoize()
166
- ], AbstractTermType.prototype, "conversions", null);
167
127
  __decorate([
168
128
  Memoize()
169
129
  ], AbstractTermType.prototype, "discriminantProperty", null);
@@ -1,24 +1,31 @@
1
- import type { Maybe, NonEmptyList } from "purify-ts";
1
+ import type { Maybe } from "purify-ts";
2
2
  import type { Logger } from "ts-log";
3
3
  import type { Reusables } from "./Reusables.js";
4
4
  import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
5
+ import type { TsGenerator } from "./TsGenerator.js";
5
6
  import type { Typeof } from "./Typeof.js";
6
7
  import { type Code } from "./ts-poet-wrapper.js";
7
8
  /**
8
9
  * Abstract base class all types.
9
10
  */
10
11
  export declare abstract class AbstractType {
12
+ protected readonly configuration: TsGenerator.Configuration;
11
13
  protected readonly logger: Logger;
12
14
  protected readonly reusables: Reusables;
13
- protected readonly rdfjsTermExpression: (parameters: Parameters<typeof rdfjsTermExpression>[0]) => Code;
14
15
  /**
15
16
  * Comment from rdfs:comment.
16
17
  */
17
18
  readonly comment: Maybe<string>;
18
19
  /**
19
- * Expressions that convert a source type or types to this type. It should include the type itself.
20
+ * Function that converts one or more source types to this type and returns Either<Error, ThisType>.
21
+ *
22
+ * The function takes two parameters:
23
+ * - an instance of this.schemaType
24
+ * - a value with one of the source types
25
+ *
26
+ * The source types should include this type.
20
27
  */
21
- abstract readonly conversions: readonly AbstractType.Conversion[];
28
+ abstract readonly conversionFunction: AbstractType.ConversionFunction;
22
29
  /**
23
30
  * The declaration of named types.
24
31
  */
@@ -52,7 +59,11 @@ export declare abstract class AbstractType {
52
59
  */
53
60
  abstract readonly graphqlType: AbstractType.GraphqlType;
54
61
  /**
55
- * Type discriminator.
62
+ * A function (reference or declaration) that takes a Hasher and a value of this type, calls hasher.update on the value, and returns the Hasher.
63
+ */
64
+ abstract readonly hashFunction: Code;
65
+ /**
66
+ * Type discriminant.
56
67
  */
57
68
  abstract readonly kind: string;
58
69
  /**
@@ -86,7 +97,7 @@ export declare abstract class AbstractType {
86
97
  /**
87
98
  * JavaScript typeof(s) the type.
88
99
  */
89
- abstract readonly typeofs: NonEmptyList<Typeof>;
100
+ abstract readonly typeofs: readonly Typeof[];
90
101
  /**
91
102
  * A ValueSparqlConstructTriplesFunction (reference or declaration) that returns an array of sparqljs.Triple's for a property value of this type.
92
103
  *
@@ -110,8 +121,9 @@ export declare abstract class AbstractType {
110
121
  * - variablePrefix: string prefix to use for new variables
111
122
  */
112
123
  abstract readonly valueSparqlWherePatternsFunction: Code;
113
- constructor({ comment, label, logger, reusables, }: {
124
+ constructor({ comment, configuration, label, logger, reusables, }: {
114
125
  comment: Maybe<string>;
126
+ configuration: TsGenerator.Configuration;
115
127
  label: Maybe<string>;
116
128
  logger: Logger;
117
129
  reusables: Reusables;
@@ -175,16 +187,6 @@ export declare abstract class AbstractType {
175
187
  value: Code;
176
188
  };
177
189
  }): Code;
178
- /**
179
- * Statements that use hasher.update to hash a property value of this type.
180
- */
181
- abstract hashStatements(parameters: {
182
- depth: number;
183
- variables: {
184
- hasher: Code;
185
- value: Code;
186
- };
187
- }): readonly Code[];
188
190
  /**
189
191
  * Zod schema for the JSON type of this type.
190
192
  *
@@ -250,13 +252,15 @@ export declare abstract class AbstractType {
250
252
  value: Code;
251
253
  };
252
254
  }): Code;
255
+ protected readonly rdfjsTermExpression: (parameters: Parameters<typeof rdfjsTermExpression>[0]) => Code;
253
256
  }
254
257
  export declare namespace AbstractType {
255
- interface Conversion {
256
- readonly conversionExpression: (value: Code) => Code;
257
- readonly sourceTypeCheckExpression: (value: Code) => Code;
258
- readonly sourceTypeName: Code | string;
259
- readonly sourceTypeof: Typeof;
258
+ interface ConversionFunction {
259
+ readonly code: Code;
260
+ readonly sourceTypes: {
261
+ readonly name: Code | string;
262
+ readonly typeof: Typeof;
263
+ }[];
260
264
  }
261
265
  interface DiscriminantProperty {
262
266
  readonly descendantValues: readonly DiscriminantProperty.Value[];
@@ -12,9 +12,9 @@ import { code, literalOf } from "./ts-poet-wrapper.js";
12
12
  * Abstract base class all types.
13
13
  */
14
14
  export class AbstractType {
15
+ configuration;
15
16
  logger;
16
17
  reusables;
17
- rdfjsTermExpression;
18
18
  /**
19
19
  * Comment from rdfs:comment.
20
20
  */
@@ -23,8 +23,9 @@ export class AbstractType {
23
23
  * Label from rdfs:label.
24
24
  */
25
25
  label;
26
- constructor({ comment, label, logger, reusables, }) {
26
+ constructor({ comment, configuration, label, logger, reusables, }) {
27
27
  this.comment = comment;
28
+ this.configuration = configuration;
28
29
  this.label = label;
29
30
  this.logger = logger;
30
31
  this.reusables = reusables;
@@ -43,6 +44,7 @@ export class AbstractType {
43
44
  kind: code `${literalOf(this.kind.substring(0, this.kind.length - "Type".length))} as const`,
44
45
  };
45
46
  }
47
+ rdfjsTermExpression;
46
48
  }
47
49
  (function (AbstractType) {
48
50
  class GraphqlType {
@@ -17,7 +17,7 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
17
17
  })[];
18
18
  recursive: boolean;
19
19
  } & ConstructorParameters<typeof AbstractType>[0]);
20
- get conversions(): readonly AbstractType.Conversion[];
20
+ get conversionFunction(): AbstractType.ConversionFunction;
21
21
  get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
22
22
  get members(): readonly AbstractUnionType.Member<MemberTypeT>[];
23
23
  get mutable(): boolean;
@@ -34,6 +34,7 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
34
34
  protected get inlineJsonType(): AbstractType.JsonType;
35
35
  protected get inlineName(): Code;
36
36
  protected get inlineToJsonFunction(): Code;
37
+ protected get inlineHashFunction(): Code;
37
38
  protected get inlineToRdfResourceValuesFunction(): Code;
38
39
  protected get inlineToStringFunction(): Code;
39
40
  protected get inlineValueSparqlConstructTriplesFunction(): Code;
@@ -43,7 +44,6 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
43
44
  members: Code;
44
45
  };
45
46
  jsonUiSchemaElement(): Maybe<Code>;
46
- protected inlineHashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
47
47
  private readonly lazyMembers;
48
48
  }
49
49
  type Discriminant = ExtrinsicDiscriminant | HybridDiscriminant | IntrinsicDiscriminant | TypeofDiscriminant;
@@ -4,12 +4,11 @@ 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";
11
11
  import { removeUndefined } from "./removeUndefined.js";
12
- import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
13
12
  import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
14
13
  export class AbstractUnionType extends AbstractType {
15
14
  discriminant;
@@ -130,29 +129,21 @@ export class AbstractUnionType extends AbstractType {
130
129
  };
131
130
  });
132
131
  }
133
- get conversions() {
134
- switch (this.discriminant.kind) {
135
- case "extrinsic":
136
- case "hybrid":
137
- case "intrinsic":
138
- return [
132
+ get conversionFunction() {
133
+ return {
134
+ code: code `${this.reusables.snippets.convertToUnion}`,
135
+ sourceTypes: this.discriminant.kind === "typeof"
136
+ ? this.members.map(({ primaryDiscriminantValue, type }) => ({
137
+ name: type.name,
138
+ typeof: primaryDiscriminantValue,
139
+ }))
140
+ : [
139
141
  {
140
- conversionExpression: (value) => value,
141
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
142
- sourceTypeName: this.name,
143
- sourceTypeof: "object",
142
+ name: this.name,
143
+ typeof: "object",
144
144
  },
145
- ];
146
- case "typeof":
147
- return this.members.map(({ primaryDiscriminantValue, type, typeCheck }) => ({
148
- conversionExpression: (value) => value,
149
- sourceTypeCheckExpression: (value) => typeCheck(value),
150
- sourceTypeName: type.name,
151
- sourceTypeof: primaryDiscriminantValue,
152
- }));
153
- default:
154
- throw this.discriminant;
155
- }
145
+ ],
146
+ };
156
147
  }
157
148
  get discriminantProperty() {
158
149
  switch (this.discriminant.kind) {
@@ -215,7 +206,7 @@ export class AbstractUnionType extends AbstractType {
215
206
  return set;
216
207
  }
217
208
  get typeofs() {
218
- return NonEmptyList.fromArray(this.members.flatMap((member) => member.type.typeofs)).unsafeCoerce();
209
+ return [...new Set(this.members.flatMap((member) => member.type.typeofs))];
219
210
  }
220
211
  get inlineEqualsFunction() {
221
212
  return code `\
@@ -228,6 +219,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
228
219
  })`;
229
220
  }
230
221
  get inlineFilterFunction() {
222
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
231
223
  return code `\
232
224
  ((filter: ${this.filterType}, value: ${this.name}) => {
233
225
  ${joinCode([
@@ -249,6 +241,7 @@ if (filter.on?.[${literalOf(primaryDiscriminantValue)}] !== undefined && ${typeC
249
241
  })`;
250
242
  }
251
243
  get inlineFilterType() {
244
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
252
245
  return code `\
253
246
  {
254
247
  ${this.identifierType.map((identifierType) => code `readonly ${syntheticNamePrefix}identifier?: ${identifierType.filterType};`).orDefault(code ``)}
@@ -395,6 +388,13 @@ ${joinCode(this.members.map(({ jsonType, jsonTypeCheck, type, unwrap, wrap }) =>
395
388
  ${joinCode(this.members.map(({ typeCheck, typeToJsonExpression, unwrap, wrap }) => code `if (${typeCheck(code `value`)}) { return ${wrap(typeToJsonExpression(unwrap(code `value`)))}; }`))}
396
389
 
397
390
  throw new Error("unable to serialize to JSON");
391
+ })`;
392
+ }
393
+ get inlineHashFunction() {
394
+ return code `\
395
+ (<HasherT extends ${this.reusables.snippets.Hasher}>(hasher: HasherT, value: ${this.name}): HasherT => {
396
+ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `value`)}) { return ${type.hashFunction}(hasher, ${unwrap(code `value`)}); }`))}
397
+ return hasher;
398
398
  })`;
399
399
  }
400
400
  get inlineToRdfResourceValuesFunction() {
@@ -469,22 +469,11 @@ unionPatterns.push({ patterns: ${type.valueSparqlWherePatternsFunction}({ ...oth
469
469
  jsonUiSchemaElement() {
470
470
  return Maybe.empty();
471
471
  }
472
- inlineHashStatements({ depth, variables, }) {
473
- return this.members.map(({ type, unwrap, typeCheck }) => code `if (${typeCheck(variables.value)}) { ${joinCode(type
474
- .hashStatements({
475
- depth: depth + 1,
476
- variables: {
477
- hasher: variables.hasher,
478
- value: unwrap(variables.value),
479
- },
480
- })
481
- .concat())} }`);
482
- }
483
472
  lazyMembers;
484
473
  }
485
474
  __decorate([
486
475
  Memoize()
487
- ], AbstractUnionType.prototype, "conversions", null);
476
+ ], AbstractUnionType.prototype, "conversionFunction", null);
488
477
  __decorate([
489
478
  Memoize()
490
479
  ], AbstractUnionType.prototype, "discriminantProperty", null);
@@ -11,13 +11,13 @@ export declare class AnonymousUnionType extends AbstractUnionType<Type> {
11
11
  get filterFunction(): Code;
12
12
  get filterType(): Code;
13
13
  get graphqlType(): AbstractType.GraphqlType;
14
+ get hashFunction(): Code;
14
15
  get name(): Code;
15
16
  get valueSparqlConstructTriplesFunction(): Code;
16
17
  get valueSparqlWherePatternsFunction(): Code;
17
18
  fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
18
19
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
19
20
  graphqlResolveExpression(_parameters: Parameters<AbstractType["graphqlResolveExpression"]>[0]): Code;
20
- hashStatements(parameters: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
21
21
  jsonSchema(_parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
22
22
  jsonType(): AbstractType.JsonType;
23
23
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
@@ -17,6 +17,9 @@ export class AnonymousUnionType extends AbstractUnionType {
17
17
  get graphqlType() {
18
18
  throw new Error("GraphQL doesn't support scalar unions");
19
19
  }
20
+ get hashFunction() {
21
+ return this.inlineHashFunction;
22
+ }
20
23
  get name() {
21
24
  return this.inlineName;
22
25
  }
@@ -36,9 +39,6 @@ export class AnonymousUnionType extends AbstractUnionType {
36
39
  graphqlResolveExpression(_parameters) {
37
40
  throw new Error("not implemented");
38
41
  }
39
- hashStatements(parameters) {
40
- return this.inlineHashStatements(parameters);
41
- }
42
42
  jsonSchema(_parameters) {
43
43
  return this.inlineJsonSchema;
44
44
  }
@@ -1,19 +1,21 @@
1
+ import type { Literal } from "@rdfjs/types";
1
2
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
2
3
  import { type Code } from "./ts-poet-wrapper.js";
3
4
  export declare class BigDecimalType extends AbstractLiteralType {
5
+ readonly name: Code;
6
+ readonly conversionFunction: AbstractLiteralType.ConversionFunction;
4
7
  readonly filterFunction: Code;
5
8
  readonly filterType: Code;
9
+ readonly hashFunction: Code;
6
10
  readonly kind = "BigDecimalType";
7
- readonly name: Code;
8
11
  readonly schemaType: Code;
9
12
  readonly valueSparqlWherePatternsFunction: Code;
10
- get conversions(): readonly AbstractLiteralType.Conversion[];
11
13
  get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
12
14
  fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
13
15
  graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
14
- hashStatements({ variables, }: Parameters<AbstractLiteralType["hashStatements"]>[0]): readonly Code[];
15
16
  jsonSchema(): Code;
16
17
  jsonType(): AbstractLiteralType.JsonType;
18
+ literalExpression(literal: Literal): Code;
17
19
  toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
18
20
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractLiteralType["toRdfResourceValuesExpression"]>[0]): Code;
19
21
  protected fromRdfExpressionChain({ variables, }: Parameters<AbstractLiteralType["fromRdfExpressionChain"]>[0]): ReturnType<AbstractLiteralType["fromRdfExpressionChain"]>;
@@ -6,48 +6,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Memoize } from "typescript-memoize";
8
8
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
9
- import { code } from "./ts-poet-wrapper.js";
9
+ import { code, literalOf } from "./ts-poet-wrapper.js";
10
10
  export class BigDecimalType extends AbstractLiteralType {
11
+ name = code `${this.reusables.imports.BigDecimal}`;
12
+ conversionFunction = {
13
+ code: code `${this.reusables.snippets.convertToBigDecimal}`,
14
+ sourceTypes: [
15
+ {
16
+ name: code `${this.reusables.imports.BigDecimal}`,
17
+ typeof: "object",
18
+ },
19
+ ],
20
+ };
11
21
  filterFunction = code `${this.reusables.snippets.filterBigDecimal}`;
12
22
  filterType = code `${this.reusables.snippets.NumericFilter}<${this.reusables.imports.BigDecimal}>`;
23
+ hashFunction = code `${this.reusables.snippets.hashBigDecimal}`;
13
24
  kind = "BigDecimalType";
14
- name = code `${this.reusables.imports.BigDecimal}`;
15
25
  schemaType = code `${this.reusables.snippets.NumericSchema}<${this.reusables.imports.BigDecimal}>`;
16
26
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.bigDecimalSparqlWherePatterns}`;
17
- get conversions() {
18
- return [
19
- // {
20
- // conversionExpression: (value) =>
21
- // code`new ${this.reusables.imports.BigDecimal}(${value}.toString())`,
22
- // sourceTypeCheckExpression: (value) =>
23
- // code`typeof ${value} === "bigint"`,
24
- // sourceTypeName: code`bigint`,
25
- // sourceTypeof: "bigint",
26
- // },
27
- {
28
- conversionExpression: (value) => value,
29
- sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
30
- sourceTypeName: code `${this.reusables.imports.BigDecimal}`,
31
- sourceTypeof: "object",
32
- },
33
- // {
34
- // conversionExpression: (value) =>
35
- // code`new ${this.reusables.imports.BigDecimal}(${value})`,
36
- // sourceTypeCheckExpression: (value) =>
37
- // code`typeof ${value} === "number"`,
38
- // sourceTypeName: code`number`,
39
- // sourceTypeof: "number",
40
- // },
41
- // {
42
- // conversionExpression: (value) =>
43
- // code`new ${this.reusables.imports.BigDecimal}(${value})`,
44
- // sourceTypeCheckExpression: (value) =>
45
- // code`typeof ${value} === "string"`,
46
- // sourceTypeName: code`string`,
47
- // sourceTypeof: "string",
48
- // },
49
- ];
50
- }
51
27
  get graphqlType() {
52
28
  return new AbstractLiteralType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
53
29
  }
@@ -57,15 +33,15 @@ export class BigDecimalType extends AbstractLiteralType {
57
33
  graphqlResolveExpression({ variables, }) {
58
34
  return code `${variables.value}.toFixed()`;
59
35
  }
60
- hashStatements({ variables, }) {
61
- return [code `${variables.hasher}.update(${variables.value}.toFixed());`];
62
- }
63
36
  jsonSchema() {
64
37
  return code `${this.reusables.imports.z}.string()`;
65
38
  }
66
39
  jsonType() {
67
40
  return new AbstractLiteralType.JsonType("string");
68
41
  }
42
+ literalExpression(literal) {
43
+ return code `new ${this.reusables.imports.BigDecimal}(${literalOf(literal.value)})`;
44
+ }
69
45
  toJsonExpression({ variables, }) {
70
46
  return code `${variables.value}.toFixed()`;
71
47
  }
@@ -79,9 +55,6 @@ export class BigDecimalType extends AbstractLiteralType {
79
55
  };
80
56
  }
81
57
  }
82
- __decorate([
83
- Memoize()
84
- ], BigDecimalType.prototype, "conversions", null);
85
58
  __decorate([
86
59
  Memoize()
87
60
  ], BigDecimalType.prototype, "graphqlType", null);
@@ -1,16 +1,15 @@
1
- import { NonEmptyList } from "purify-ts";
1
+ import type { Literal } from "@rdfjs/types";
2
2
  import { AbstractNumericType } from "./AbstractNumericType.js";
3
3
  import { type Code } from "./ts-poet-wrapper.js";
4
4
  export declare class BigIntType extends AbstractNumericType<bigint> {
5
5
  readonly kind = "BigIntType";
6
- readonly typeofs: NonEmptyList<"bigint">;
6
+ readonly typeofs: "bigint"[];
7
7
  get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
8
- get conversions(): readonly AbstractNumericType.Conversion[];
9
8
  fromJsonExpression({ variables, }: Parameters<AbstractNumericType<bigint>["fromJsonExpression"]>[0]): Code;
10
9
  jsonSchema(_parameters: Parameters<AbstractNumericType<bigint>["jsonSchema"]>[0]): Code;
11
10
  jsonType(): AbstractNumericType.JsonType;
11
+ literalExpression(literal: bigint | Literal): Code;
12
12
  toJsonExpression({ variables, }: Parameters<AbstractNumericType<bigint>["toJsonExpression"]>[0]): Code;
13
13
  protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractNumericType<bigint>["fromRdfResourceValueExpression"]>[0]): Code;
14
- protected literalOf(value: bigint): string;
15
14
  }
16
15
  //# sourceMappingURL=BigIntType.d.ts.map