@shaclmate/compiler 4.0.39 → 4.0.41

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 (211) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +0 -8
  2. package/dist/ShapesGraphToAstTransformer.js +5 -85
  3. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
  4. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +0 -16
  6. package/dist/ast/AbstractCompoundType.d.ts +2 -1
  7. package/dist/ast/AbstractCompoundType.js +1 -1
  8. package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
  9. package/dist/ast/Ast.d.ts +1 -3
  10. package/dist/ast/ListType.d.ts +1 -1
  11. package/dist/ast/ListType.js +1 -1
  12. package/dist/ast/ObjectType.d.ts +0 -12
  13. package/dist/ast/ObjectType.js +0 -78
  14. package/dist/generators/AstJsonGenerator.js +7 -3
  15. package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
  16. package/dist/generators/ts/AbstractCollectionType.d.ts +5 -12
  17. package/dist/generators/ts/AbstractCollectionType.js +9 -68
  18. package/dist/generators/ts/AbstractContainerType.d.ts +4 -6
  19. package/dist/generators/ts/AbstractContainerType.js +5 -9
  20. package/dist/generators/ts/AbstractDateType.d.ts +6 -3
  21. package/dist/generators/ts/AbstractDateType.js +7 -2
  22. package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
  23. package/dist/generators/ts/AbstractIdentifierType.js +3 -0
  24. package/dist/generators/ts/AbstractLazyObjectType.d.ts +9 -9
  25. package/dist/generators/ts/AbstractLazyObjectType.js +30 -19
  26. package/dist/generators/ts/AbstractLiteralType.d.ts +1 -0
  27. package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
  28. package/dist/generators/ts/AbstractNumericType.js +9 -9
  29. package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
  30. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  31. package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -0
  32. package/dist/generators/ts/AbstractPrimitiveType.js +2 -2
  33. package/dist/generators/ts/AbstractTermType.d.ts +1 -2
  34. package/dist/generators/ts/AbstractTermType.js +3 -5
  35. package/dist/generators/ts/AbstractType.d.ts +61 -26
  36. package/dist/generators/ts/AbstractType.js +37 -17
  37. package/dist/generators/ts/BigDecimalType.d.ts +5 -1
  38. package/dist/generators/ts/BigDecimalType.js +6 -3
  39. package/dist/generators/ts/BigIntType.d.ts +3 -1
  40. package/dist/generators/ts/BigIntType.js +3 -3
  41. package/dist/generators/ts/BlankNodeType.d.ts +3 -3
  42. package/dist/generators/ts/BlankNodeType.js +13 -13
  43. package/dist/generators/ts/BooleanType.d.ts +5 -3
  44. package/dist/generators/ts/BooleanType.js +11 -6
  45. package/dist/generators/ts/DefaultValueType.d.ts +40 -2
  46. package/dist/generators/ts/DefaultValueType.js +14 -12
  47. package/dist/generators/ts/FloatType.d.ts +3 -1
  48. package/dist/generators/ts/FloatType.js +1 -1
  49. package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
  50. package/dist/generators/ts/GraphqlSchema.js +6 -6
  51. package/dist/generators/ts/IdentifierType.d.ts +3 -3
  52. package/dist/generators/ts/IdentifierType.js +19 -17
  53. package/dist/generators/ts/IntType.d.ts +3 -1
  54. package/dist/generators/ts/IntType.js +1 -1
  55. package/dist/generators/ts/IriType.d.ts +2 -2
  56. package/dist/generators/ts/IriType.js +21 -19
  57. package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -0
  58. package/dist/generators/ts/LazyObjectOptionType.js +14 -10
  59. package/dist/generators/ts/LazyObjectSetType.js +14 -8
  60. package/dist/generators/ts/LazyObjectType.js +9 -6
  61. package/dist/generators/ts/ListType.d.ts +13 -5
  62. package/dist/generators/ts/ListType.js +48 -12
  63. package/dist/generators/ts/LiteralType.d.ts +5 -1
  64. package/dist/generators/ts/LiteralType.js +11 -8
  65. package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +19 -34
  66. package/dist/generators/ts/ObjectType.js +282 -0
  67. package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
  68. package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +52 -60
  69. package/dist/generators/ts/OptionType.d.ts +6 -2
  70. package/dist/generators/ts/OptionType.js +20 -15
  71. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -11
  72. package/dist/generators/ts/SetType.d.ts +16 -1
  73. package/dist/generators/ts/SetType.js +80 -2
  74. package/dist/generators/ts/Snippets.d.ts +3 -1
  75. package/dist/generators/ts/Snippets.js +18 -4
  76. package/dist/generators/ts/SparqlObjectSetType.js +2 -2
  77. package/dist/generators/ts/StringType.d.ts +5 -3
  78. package/dist/generators/ts/StringType.js +15 -6
  79. package/dist/generators/ts/TermType.d.ts +6 -2
  80. package/dist/generators/ts/TermType.js +15 -12
  81. package/dist/generators/ts/TsGenerator.d.ts +1 -1
  82. package/dist/generators/ts/TsGenerator.js +60 -32
  83. package/dist/generators/ts/Type.d.ts +4 -5
  84. package/dist/generators/ts/TypeFactory.d.ts +7 -8
  85. package/dist/generators/ts/TypeFactory.js +62 -76
  86. package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +36 -11
  87. package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +296 -105
  88. package/dist/generators/ts/ZodGenerator.d.ts +1 -1
  89. package/dist/generators/ts/ZodGenerator.js +21 -16
  90. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +9 -6
  91. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +3 -3
  92. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +9 -13
  93. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +22 -39
  94. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +1 -5
  95. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +18 -13
  96. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
  97. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +44 -0
  98. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
  99. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +3 -7
  100. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
  101. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -6
  102. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
  103. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +2 -5
  104. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  105. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +2 -6
  106. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  107. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -24
  108. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
  109. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +18 -0
  110. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
  111. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +51 -0
  112. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
  113. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
  114. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
  115. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
  116. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
  117. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
  118. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
  119. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +41 -0
  120. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
  121. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +12 -0
  122. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
  123. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +20 -0
  124. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
  125. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
  126. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
  127. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +5 -11
  128. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
  129. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +9 -0
  130. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
  131. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -6
  132. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
  133. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
  134. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
  135. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +12 -0
  136. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
  137. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
  138. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
  139. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
  140. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  141. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +20 -0
  142. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  143. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
  144. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
  145. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +7 -14
  146. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  147. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  148. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  149. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
  150. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +12 -12
  151. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
  152. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +16 -0
  153. package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
  154. package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
  155. package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
  156. package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
  157. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
  158. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
  159. package/dist/input/generated.d.ts +758 -117
  160. package/dist/input/generated.js +636 -128
  161. package/package.json +4 -6
  162. package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
  163. package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
  164. package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
  165. package/dist/generators/ts/AnonymousUnionType.js +0 -59
  166. package/dist/generators/ts/NamedObjectType.js +0 -342
  167. package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
  168. package/dist/generators/ts/NamedUnionType.d.ts +0 -11
  169. package/dist/generators/ts/NamedUnionType.js +0 -13
  170. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
  171. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +0 -65
  172. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
  173. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
  174. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
  175. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  176. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  177. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  178. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +0 -43
  179. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  180. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
  181. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  182. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  183. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  184. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  185. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
  186. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +0 -45
  187. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
  188. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +0 -16
  189. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
  190. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +0 -17
  191. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
  192. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  193. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  194. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +0 -16
  195. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  196. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
  197. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
  198. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
  199. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  200. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +0 -41
  201. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  202. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
  203. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  204. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  205. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
  206. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +0 -25
  207. package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
  208. package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
  209. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
  210. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
  211. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +0 -0
@@ -14,6 +14,10 @@ export class AbstractType {
14
14
  configuration;
15
15
  logger;
16
16
  reusables;
17
+ /**
18
+ * Alias for this type.
19
+ */
20
+ alias;
17
21
  /**
18
22
  * Comment from rdfs:comment.
19
23
  */
@@ -22,7 +26,8 @@ export class AbstractType {
22
26
  * Label from rdfs:label.
23
27
  */
24
28
  label;
25
- constructor({ comment, configuration, label, logger, reusables, }) {
29
+ constructor({ alias, comment, configuration, label, logger, reusables, }) {
30
+ this.alias = alias;
26
31
  this.comment = comment;
27
32
  this.configuration = configuration;
28
33
  this.label = label;
@@ -58,47 +63,62 @@ __decorate([
58
63
  */
59
64
  nullable;
60
65
  /**
61
- * The name of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
66
+ * The expression of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
62
67
  */
63
- nullableName;
68
+ nullableExpression;
64
69
  reusables;
65
- constructor(nullableName, reusables, options) {
70
+ constructor(nullableExpression, reusables, options) {
66
71
  this.nullable = !!options?.nullable;
67
- this.nullableName = nullableName;
72
+ this.nullableExpression = nullableExpression;
68
73
  this.reusables = reusables;
69
74
  }
70
- get name() {
75
+ get expression() {
71
76
  return this.nullable
72
- ? this.nullableName
73
- : code `new ${this.reusables.imports.GraphQLNonNull}(${this.nullableName})`;
77
+ ? this.nullableExpression
78
+ : code `new ${this.reusables.imports.GraphQLNonNull}(${this.nullableExpression})`;
74
79
  }
75
80
  }
76
81
  __decorate([
77
82
  Memoize()
78
- ], GraphqlType.prototype, "name", null);
83
+ ], GraphqlType.prototype, "expression", null);
79
84
  AbstractType.GraphqlType = GraphqlType;
85
+ let JsType;
86
+ (function (JsType) {
87
+ function equals(left, right) {
88
+ if (left.typeof !== right.typeof) {
89
+ return false;
90
+ }
91
+ if (left.typeof === "object" &&
92
+ right.typeof === "object" &&
93
+ left.instanceof !== right.instanceof) {
94
+ return false;
95
+ }
96
+ return true;
97
+ }
98
+ JsType.equals = equals;
99
+ })(JsType = AbstractType.JsType || (AbstractType.JsType = {}));
80
100
  class JsonType {
81
101
  /**
82
102
  * Is the type optional in JSON? Equivalent to ? in TypeScript or | undefined.
83
103
  */
84
104
  optional;
85
105
  /**
86
- * The name of the type when it's required i.e. -- so it should never include "| undefined".
106
+ * The expression of the type when it's required i.e. -- so it should never include "| undefined".
87
107
  */
88
- requiredName;
89
- constructor(requiredName, parameters) {
108
+ requiredExpression;
109
+ constructor(requiredExpression, parameters) {
90
110
  this.optional = !!parameters?.optional;
91
- this.requiredName = requiredName;
111
+ this.requiredExpression = requiredExpression;
92
112
  }
93
- get name() {
113
+ get expression() {
94
114
  return this.optional
95
- ? code `(${this.requiredName}) | undefined`
96
- : this.requiredName;
115
+ ? code `(${this.requiredExpression}) | undefined`
116
+ : this.requiredExpression;
97
117
  }
98
118
  }
99
119
  __decorate([
100
120
  Memoize()
101
- ], JsonType.prototype, "name", null);
121
+ ], JsonType.prototype, "expression", null);
102
122
  AbstractType.JsonType = JsonType;
103
123
  })(AbstractType || (AbstractType = {}));
104
124
  //# sourceMappingURL=AbstractType.js.map
@@ -3,11 +3,15 @@ import { Maybe } from "purify-ts";
3
3
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
4
4
  import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare class BigDecimalType extends AbstractLiteralType {
6
- readonly name: Code;
7
6
  readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
7
+ readonly expression: Code;
8
8
  readonly filterFunction: Code;
9
9
  readonly filterType: Code;
10
10
  readonly hashFunction: Code;
11
+ readonly jsTypes: readonly [{
12
+ readonly instanceof: "Object";
13
+ readonly typeof: "object";
14
+ }];
11
15
  readonly kind = "BigDecimal";
12
16
  readonly schemaType: Code;
13
17
  readonly valueSparqlWherePatternsFunction: Code;
@@ -9,11 +9,14 @@ import { Memoize } from "typescript-memoize";
9
9
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
10
10
  import { code, literalOf } from "./ts-poet-wrapper.js";
11
11
  export class BigDecimalType extends AbstractLiteralType {
12
- name = code `${this.reusables.imports.BigDecimal}`;
13
12
  conversionFunction = Maybe.empty();
13
+ expression = code `${this.reusables.imports.BigDecimal}`;
14
14
  filterFunction = code `${this.reusables.snippets.filterBigDecimal}`;
15
15
  filterType = code `${this.reusables.snippets.NumericFilter}<${this.reusables.imports.BigDecimal}>`;
16
16
  hashFunction = code `${this.reusables.snippets.hashBigDecimal}`;
17
+ jsTypes = [
18
+ { instanceof: "Object", typeof: "object" },
19
+ ];
17
20
  kind = "BigDecimal";
18
21
  schemaType = code `${this.reusables.snippets.NumericSchema}<${this.reusables.imports.BigDecimal}>`;
19
22
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.bigDecimalSparqlWherePatterns}`;
@@ -21,7 +24,7 @@ export class BigDecimalType extends AbstractLiteralType {
21
24
  return new AbstractLiteralType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
22
25
  }
23
26
  fromJsonExpression({ variables, }) {
24
- return code `${this.reusables.imports.Either}.encase<Error, ${this.name}>(() => new ${this.name}(${variables.value}))`;
27
+ return code `${this.reusables.imports.Either}.encase<Error, ${this.expression}>(() => new ${this.expression}(${variables.value}))`;
25
28
  }
26
29
  graphqlResolveExpression({ variables, }) {
27
30
  return code `${variables.value}.toFixed()`;
@@ -30,7 +33,7 @@ export class BigDecimalType extends AbstractLiteralType {
30
33
  return code `${this.reusables.imports.z}.string()`;
31
34
  }
32
35
  jsonType() {
33
- return new AbstractLiteralType.JsonType("string");
36
+ return new AbstractLiteralType.JsonType(code `string`);
34
37
  }
35
38
  literalExpression(literal) {
36
39
  return code `new ${this.reusables.imports.BigDecimal}(${literalOf(literal.value)})`;
@@ -2,8 +2,10 @@ 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
+ readonly jsTypes: {
6
+ readonly typeof: "bigint";
7
+ }[];
5
8
  readonly kind = "BigInt";
6
- readonly typeofs: "bigint"[];
7
9
  get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
8
10
  fromJsonExpression({ variables, }: Parameters<AbstractNumericType<bigint>["fromJsonExpression"]>[0]): Code;
9
11
  jsonSchema(_parameters: Parameters<AbstractNumericType<bigint>["jsonSchema"]>[0]): Code;
@@ -9,17 +9,17 @@ import { Memoize } from "typescript-memoize";
9
9
  import { AbstractNumericType } from "./AbstractNumericType.js";
10
10
  import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
11
11
  export class BigIntType extends AbstractNumericType {
12
+ jsTypes = [{ typeof: "bigint" }];
12
13
  kind = "BigInt";
13
- typeofs = ["bigint"];
14
14
  get graphqlType() {
15
15
  return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLBigInt}`, this.reusables);
16
16
  }
17
17
  fromJsonExpression({ variables, }) {
18
18
  let expression = code `BigInt(${variables.value})`;
19
19
  if (this.primitiveIn.length > 0) {
20
- expression = code `${expression} as ${this.name}`;
20
+ expression = code `${expression} as ${this.expression}`;
21
21
  }
22
- return code `${this.reusables.imports.Either}.encase<Error, ${this.name}>(() => ${expression})`;
22
+ return code `${this.reusables.imports.Either}.encase<Error, ${this.expression}>(() => ${expression})`;
23
23
  }
24
24
  jsonSchema(_parameters) {
25
25
  switch (this.primitiveIn.length) {
@@ -3,19 +3,19 @@ import { Maybe } from "purify-ts";
3
3
  import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
4
4
  import { type Code } from "./ts-poet-wrapper.js";
5
5
  export declare class BlankNodeType extends AbstractIdentifierType<BlankNode> {
6
+ readonly expression: Code;
6
7
  readonly conversionFunction: Maybe<AbstractIdentifierType.ConversionFunction>;
7
8
  readonly filterFunction: Code;
8
9
  readonly filterType: Code;
9
- readonly parseFunction: Code;
10
10
  readonly kind = "BlankNode";
11
- readonly name: Code;
12
11
  readonly nodeKinds: ReadonlySet<"BlankNode">;
12
+ readonly parseFunction: Code;
13
13
  readonly schemaType: Code;
14
14
  readonly valueSparqlWherePatternsFunction: Code;
15
15
  constructor(superParameters: Omit<ConstructorParameters<typeof AbstractIdentifierType<BlankNode>>[0], "hasValues" | "in_">);
16
16
  fromJsonExpression({ variables, }: Parameters<AbstractIdentifierType<BlankNode>["fromJsonExpression"]>[0]): Code;
17
- jsonType(parameters?: Parameters<AbstractIdentifierType<BlankNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
18
17
  jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractIdentifierType<BlankNode>["jsonSchema"]>[0]): Code;
18
+ jsonType(parameters?: Parameters<AbstractIdentifierType<BlankNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
19
19
  toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractIdentifierType<BlankNode>["toJsonExpression"]>[0]): Code;
20
20
  protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractIdentifierType<BlankNode>["fromRdfResourceValuesExpressionChain"]>[0]): {
21
21
  valueTo: Code;
@@ -9,25 +9,25 @@ import { Memoize } from "typescript-memoize";
9
9
  import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
10
10
  import { code } from "./ts-poet-wrapper.js";
11
11
  export class BlankNodeType extends AbstractIdentifierType {
12
+ expression = code `${this.reusables.imports.BlankNode}`;
12
13
  conversionFunction = Maybe.of({
13
14
  code: code `${this.reusables.snippets.convertToBlankNode}`,
14
15
  sourceTypes: [
15
16
  {
16
- name: code `${this.reusables.imports.BlankNode}`,
17
- typeof: "object",
17
+ expression: code `${this.reusables.imports.BlankNode}`,
18
+ jsType: this.jsTypes[0],
18
19
  },
19
20
  {
20
- name: "undefined",
21
- typeof: "undefined",
21
+ expression: code `undefined`,
22
+ jsType: { typeof: "undefined" },
22
23
  },
23
24
  ],
24
25
  });
25
26
  filterFunction = code `${this.reusables.snippets.filterBlankNode}`;
26
27
  filterType = code `${this.reusables.snippets.BlankNodeFilter}`;
27
- parseFunction = code `${this.reusables.snippets.parseBlankNode};`;
28
28
  kind = "BlankNode";
29
- name = code `${this.reusables.imports.BlankNode}`;
30
29
  nodeKinds = nodeKinds;
30
+ parseFunction = code `${this.reusables.snippets.parseBlankNode};`;
31
31
  schemaType = code `${this.reusables.snippets.BlankNodeSchema}`;
32
32
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.blankNodeSparqlWherePatterns}`;
33
33
  constructor(superParameters) {
@@ -38,13 +38,7 @@ export class BlankNodeType extends AbstractIdentifierType {
38
38
  });
39
39
  }
40
40
  fromJsonExpression({ variables, }) {
41
- return code `${this.reusables.imports.Either}.of<Error, ${this.name}>(${this.reusables.imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2)))`;
42
- }
43
- jsonType(parameters) {
44
- const discriminantProperty = parameters?.includeDiscriminantProperty
45
- ? `, readonly termType: "BlankNode"`
46
- : "";
47
- return new AbstractIdentifierType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
41
+ return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${this.reusables.imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2)))`;
48
42
  }
49
43
  jsonSchema({ includeDiscriminantProperty, }) {
50
44
  const discriminantProperty = includeDiscriminantProperty
@@ -52,6 +46,12 @@ export class BlankNodeType extends AbstractIdentifierType {
52
46
  : "";
53
47
  return code `${this.reusables.imports.z}.object({ "@id": ${this.reusables.imports.z}.string().min(1)${discriminantProperty} })`;
54
48
  }
49
+ jsonType(parameters) {
50
+ const discriminantProperty = parameters?.includeDiscriminantProperty
51
+ ? `, readonly termType: "BlankNode"`
52
+ : "";
53
+ return new AbstractIdentifierType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
54
+ }
55
55
  toJsonExpression({ includeDiscriminantProperty, variables, }) {
56
56
  const discriminantProperty = includeDiscriminantProperty
57
57
  ? code `, termType: ${variables.value}.termType`
@@ -6,11 +6,13 @@ export declare class BooleanType extends AbstractPrimitiveType<boolean> {
6
6
  readonly filterType: Code;
7
7
  readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
8
8
  readonly hashFunction: Code;
9
+ readonly jsTypes: readonly [{
10
+ readonly typeof: "boolean";
11
+ }];
9
12
  readonly kind = "Boolean";
10
- readonly schemaType: Code;
11
- readonly typeofs: "boolean"[];
12
13
  readonly valueSparqlWherePatternsFunction: Code;
13
- get name(): string;
14
+ get expression(): Code;
15
+ get schemaType(): Code;
14
16
  jsonSchema(_parameters: Parameters<AbstractPrimitiveType<number>["jsonSchema"]>[0]): Code;
15
17
  literalExpression(literal: boolean | Literal): Code;
16
18
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<boolean>["toRdfResourceValuesExpression"]>[0]): Code;
@@ -13,15 +13,17 @@ export class BooleanType extends AbstractPrimitiveType {
13
13
  filterType = code `${this.reusables.snippets.BooleanFilter}`;
14
14
  graphqlType = new AbstractPrimitiveType.GraphqlType(code `${this.reusables.imports.GraphQLBoolean}`, this.reusables);
15
15
  hashFunction = code `${this.reusables.snippets.hashBoolean}`;
16
+ jsTypes = [{ typeof: "boolean" }];
16
17
  kind = "Boolean";
17
- schemaType = code `${this.reusables.snippets.BooleanSchema}<${this.name}>`;
18
- typeofs = ["boolean"];
19
18
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.booleanSparqlWherePatterns}`;
20
- get name() {
19
+ get expression() {
21
20
  if (this.primitiveIn.length > 0) {
22
- return `${this.primitiveIn.map((value) => value.toString()).join(" | ")}`;
21
+ return code `${this.primitiveIn.map((value) => value.toString()).join(" | ")}`;
23
22
  }
24
- return `boolean`;
23
+ return code `boolean`;
24
+ }
25
+ get schemaType() {
26
+ return code `${this.reusables.snippets.BooleanSchema}<${this.expression}>`;
25
27
  }
26
28
  jsonSchema(_parameters) {
27
29
  if (this.primitiveIn.length === 1) {
@@ -46,5 +48,8 @@ export class BooleanType extends AbstractPrimitiveType {
46
48
  }
47
49
  __decorate([
48
50
  Memoize()
49
- ], BooleanType.prototype, "name", null);
51
+ ], BooleanType.prototype, "expression", null);
52
+ __decorate([
53
+ Memoize()
54
+ ], BooleanType.prototype, "schemaType", null);
50
55
  //# sourceMappingURL=BooleanType.js.map
@@ -10,20 +10,58 @@ export declare class DefaultValueType<ItemTypeT extends DefaultValueType.ItemTyp
10
10
  readonly discriminantProperty: Maybe<AbstractType.DiscriminantProperty>;
11
11
  readonly graphqlArgs: AbstractType["graphqlArgs"];
12
12
  readonly kind = "DefaultValue";
13
- readonly typeofs: "object"[];
13
+ readonly jsTypes: readonly AbstractType.JsType[] | readonly [{
14
+ readonly instanceof: "Object";
15
+ readonly typeof: "object";
16
+ }] | {
17
+ readonly typeof: "bigint";
18
+ }[] | readonly [{
19
+ readonly typeof: "boolean";
20
+ }] | readonly [{
21
+ readonly instanceof: "Date";
22
+ readonly typeof: "object";
23
+ }] | readonly [{
24
+ readonly instanceof: "Date";
25
+ readonly typeof: "object";
26
+ }] | readonly [{
27
+ readonly typeof: "number";
28
+ }] | readonly [{
29
+ readonly instanceof: "Object";
30
+ readonly typeof: "object";
31
+ }] | readonly [{
32
+ readonly typeof: "number";
33
+ }] | readonly [{
34
+ readonly instanceof: "Object";
35
+ readonly typeof: "object";
36
+ }] | readonly [{
37
+ readonly instanceof: "Object";
38
+ readonly typeof: "object";
39
+ }] | readonly [{
40
+ readonly instanceof: "Object";
41
+ readonly typeof: "object";
42
+ }] | readonly [{
43
+ readonly typeof: "string";
44
+ }] | readonly [{
45
+ readonly instanceof: "Array";
46
+ readonly typeof: "object";
47
+ }] | readonly [{
48
+ readonly instanceof: "Object";
49
+ readonly typeof: "object";
50
+ }];
14
51
  readonly validationFunction: Maybe<Code>;
15
52
  constructor({ defaultValue, ...superParameters }: {
16
53
  defaultValue: Literal | NamedNode;
17
54
  } & ConstructorParameters<typeof AbstractContainerType<ItemTypeT>>[0]);
18
55
  get conversionFunction(): Maybe<AbstractContainerType.ConversionFunction>;
19
56
  get equalsFunction(): Code;
57
+ get expression(): Code;
20
58
  get filterFunction(): Code;
21
59
  get filterType(): Code;
22
60
  get graphqlType(): AbstractContainerType.GraphqlType;
23
61
  get hashFunction(): Code;
24
62
  get mutable(): boolean;
25
- get name(): Code | string;
26
63
  get schemaType(): Code;
64
+ get toRdfResourceValueTypes(): AbstractContainerType<ItemTypeT>["toRdfResourceValueTypes"];
27
65
  get valueSparqlConstructTriplesFunction(): Code;
28
66
  get valueSparqlWherePatternsFunction(): Code;
29
67
  protected get schemaInitializers(): Code[];
@@ -14,7 +14,7 @@ export class DefaultValueType extends AbstractContainerType {
14
14
  discriminantProperty = Maybe.empty();
15
15
  graphqlArgs = Maybe.empty();
16
16
  kind = "DefaultValue";
17
- typeofs = ["object"];
17
+ jsTypes = this.itemType.jsTypes;
18
18
  validationFunction = this.itemType.validationFunction;
19
19
  constructor({ defaultValue, ...superParameters }) {
20
20
  super(superParameters);
@@ -25,16 +25,19 @@ export class DefaultValueType extends AbstractContainerType {
25
25
  return Maybe.of({
26
26
  code: code `${this.reusables.snippets.convertWithDefaultValue}(${itemConversionFunction.code}, ${this.defaultValueExpression})`,
27
27
  sourceTypes: itemConversionFunction.sourceTypes
28
- .filter((sourceType) => sourceType.typeof !== "undefined")
28
+ .filter((sourceType) => sourceType.jsType.typeof !== "undefined")
29
29
  .concat({
30
- name: "undefined",
31
- typeof: "undefined",
30
+ expression: code `undefined`,
31
+ jsType: { typeof: "undefined" },
32
32
  }),
33
33
  });
34
34
  }
35
35
  get equalsFunction() {
36
36
  return this.itemType.equalsFunction;
37
37
  }
38
+ get expression() {
39
+ return this.itemType.expression;
40
+ }
38
41
  get filterFunction() {
39
42
  return this.itemType.filterFunction;
40
43
  }
@@ -50,11 +53,11 @@ export class DefaultValueType extends AbstractContainerType {
50
53
  get mutable() {
51
54
  return this.itemType.mutable;
52
55
  }
53
- get name() {
54
- return this.itemType.name;
55
- }
56
56
  get schemaType() {
57
- return code `${this.reusables.snippets.DefaultValueSchema}<${this.itemType.name}, ${this.itemType.schemaType}>`;
57
+ return code `${this.reusables.snippets.DefaultValueSchema}<${this.itemType.expression}, ${this.itemType.schemaType}>`;
58
+ }
59
+ get toRdfResourceValueTypes() {
60
+ return this.itemType.toRdfResourceValueTypes;
58
61
  }
59
62
  get valueSparqlConstructTriplesFunction() {
60
63
  return this.itemType.valueSparqlConstructTriplesFunction;
@@ -72,11 +75,10 @@ export class DefaultValueType extends AbstractContainerType {
72
75
  case "Literal":
73
76
  case "Term":
74
77
  return this.rdfjsTermExpression(this.defaultValue);
75
- case "AnonymousUnion":
76
78
  case "List":
77
- case "NamedObjectType":
78
- case "NamedObjectUnion":
79
- case "NamedUnion":
79
+ case "Object":
80
+ case "ObjectUnion":
81
+ case "Union":
80
82
  throw new RangeError(`not implemented ${this.itemType.kind}`);
81
83
  }
82
84
  invariant(this.defaultValue.termType === "Literal");
@@ -2,8 +2,10 @@ 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 FloatType extends AbstractNumericType<number> {
5
+ readonly jsTypes: readonly [{
6
+ readonly typeof: "number";
7
+ }];
5
8
  readonly kind = "Float";
6
- readonly typeofs: "number"[];
7
9
  get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
8
10
  literalExpression(literal: Literal | number): Code;
9
11
  protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractNumericType<number>["fromRdfResourceValueExpression"]>[0]): Code;
@@ -9,8 +9,8 @@ import { Memoize } from "typescript-memoize";
9
9
  import { AbstractNumericType } from "./AbstractNumericType.js";
10
10
  import { code } from "./ts-poet-wrapper.js";
11
11
  export class FloatType extends AbstractNumericType {
12
+ jsTypes = [{ typeof: "number" }];
12
13
  kind = "Float";
13
- typeofs = ["number"];
14
14
  get graphqlType() {
15
15
  return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLFloat}`, this.reusables);
16
16
  }
@@ -1,6 +1,6 @@
1
1
  import type { Logger } from "ts-log";
2
- import type { NamedObjectType } from "./NamedObjectType.js";
3
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
2
+ import type { ObjectType } from "./ObjectType.js";
3
+ import type { ObjectUnionType } from "./ObjectUnionType.js";
4
4
  import type { Reusables } from "./Reusables.js";
5
5
  import type { TsGenerator } from "./TsGenerator.js";
6
6
  import { type Code } from "./ts-poet-wrapper.js";
@@ -12,8 +12,8 @@ export declare class GraphqlSchema {
12
12
  constructor({ configuration, namedObjectTypes, namedObjectUnionTypes, reusables, }: {
13
13
  configuration: TsGenerator.Configuration;
14
14
  logger: Logger;
15
- namedObjectTypes: readonly NamedObjectType[];
16
- namedObjectUnionTypes: readonly NamedObjectUnionType[];
15
+ namedObjectTypes: readonly ObjectType[];
16
+ namedObjectUnionTypes: readonly ObjectUnionType[];
17
17
  reusables: Reusables;
18
18
  });
19
19
  get declaration(): Code;
@@ -28,11 +28,11 @@ export const graphqlSchema = new ${this.reusables.imports.GraphQLSchema}({ query
28
28
  },
29
29
  },
30
30
  resolve: code `\
31
- async (_source, args: { identifier: string }, { objectSet }): Promise<${namedObjectType.name}> =>
32
- (await ${this.reusables.imports.EitherAsync}<Error, ${namedObjectType.name}>(async ({ liftEither }) =>
31
+ async (_source, args: { identifier: string }, { objectSet }): Promise<${namedObjectType.expression}> =>
32
+ (await ${this.reusables.imports.EitherAsync}<Error, ${namedObjectType.expression}>(async ({ liftEither }) =>
33
33
  liftEither(await objectSet.${namedObjectType.objectSetMethodNames.object}(await liftEither(${namedObjectType.identifierTypeAlias}.parse(args.identifier))))
34
34
  )).unsafeCoerce()`,
35
- type: namedObjectType.graphqlType.name,
35
+ type: namedObjectType.graphqlType.expression,
36
36
  };
37
37
  fields[namedObjectType.objectSetMethodNames.objectIdentifiers] = {
38
38
  args: {
@@ -61,8 +61,8 @@ export const graphqlSchema = new ${this.reusables.imports.GraphQLSchema}({ query
61
61
  },
62
62
  },
63
63
  resolve: code `\
64
- async (_source, args: { identifiers: readonly string[] | null; limit: number | null; offset: number | null; }, { objectSet }): Promise<readonly ${namedObjectType.name}[]> =>
65
- (await ${this.reusables.imports.EitherAsync}<Error, readonly ${namedObjectType.name}[]>(async ({ liftEither }) => {
64
+ async (_source, args: { identifiers: readonly string[] | null; limit: number | null; offset: number | null; }, { objectSet }): Promise<readonly ${namedObjectType.expression}[]> =>
65
+ (await ${this.reusables.imports.EitherAsync}<Error, readonly ${namedObjectType.expression}[]>(async ({ liftEither }) => {
66
66
  let filter: ${namedObjectType.filterType} | undefined;
67
67
  if (args.identifiers) {
68
68
  const identifiers: ${namedObjectType.identifierTypeAlias}[] = [];
@@ -73,7 +73,7 @@ export const graphqlSchema = new ${this.reusables.imports.GraphQLSchema}({ query
73
73
  }
74
74
  return await liftEither(await objectSet.${namedObjectType.objectSetMethodNames.objects}({ filter, limit: args.limit !== null ? args.limit : undefined, offset: args.offset !== null ? args.offset : undefined }));
75
75
  })).unsafeCoerce()`,
76
- type: code `new ${this.reusables.imports.GraphQLNonNull}(new ${this.reusables.imports.GraphQLList}(${namedObjectType.graphqlType.name}))`,
76
+ type: code `new ${this.reusables.imports.GraphQLNonNull}(new ${this.reusables.imports.GraphQLList}(${namedObjectType.graphqlType.expression}))`,
77
77
  };
78
78
  fields[namedObjectType.objectSetMethodNames.objectCount] = {
79
79
  resolve: code `\
@@ -4,19 +4,19 @@ import { Maybe } from "purify-ts";
4
4
  import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
5
5
  import { type Code } from "./ts-poet-wrapper.js";
6
6
  export declare class IdentifierType extends AbstractIdentifierType<BlankNode | NamedNode> {
7
+ readonly expression: Code;
7
8
  readonly conversionFunction: Maybe<AbstractIdentifierType.ConversionFunction>;
8
9
  readonly filterFunction: Code;
9
10
  readonly filterType: Code;
10
- readonly parseFunction: Code;
11
11
  readonly kind = "Identifier";
12
- readonly name: Code;
13
12
  readonly nodeKinds: ReadonlySet<IdentifierNodeKind>;
13
+ readonly parseFunction: Code;
14
14
  readonly schemaType: Code;
15
15
  readonly valueSparqlWherePatternsFunction: Code;
16
16
  constructor(parameters: Omit<ConstructorParameters<typeof AbstractIdentifierType<BlankNode | NamedNode>>[0], "hasValues" | "in_">);
17
17
  fromJsonExpression({ variables, }: Parameters<AbstractIdentifierType<BlankNode | NamedNode>["fromJsonExpression"]>[0]): Code;
18
- jsonType(parameters?: Parameters<AbstractIdentifierType<BlankNode | NamedNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
19
18
  jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractIdentifierType<BlankNode | NamedNode>["jsonSchema"]>[0]): Code;
19
+ jsonType(parameters?: Parameters<AbstractIdentifierType<BlankNode | NamedNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
20
20
  toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractIdentifierType<BlankNode | NamedNode>["toJsonExpression"]>[0]): Code;
21
21
  protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractIdentifierType<BlankNode | NamedNode>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractIdentifierType<BlankNode | NamedNode>["fromRdfResourceValuesExpressionChain"]>;
22
22
  }
@@ -10,33 +10,35 @@ import { Memoize } from "typescript-memoize";
10
10
  import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
11
11
  import { arrayOf, code } from "./ts-poet-wrapper.js";
12
12
  export class IdentifierType extends AbstractIdentifierType {
13
+ expression = code `(${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode})`;
13
14
  conversionFunction = Maybe.of({
14
15
  code: code `${this.reusables.snippets.convertToIdentifier}`,
15
16
  sourceTypes: [
16
17
  {
17
- name: code `${this.reusables.imports.BlankNode}`,
18
- typeof: "object",
18
+ expression: code `${this.reusables.imports.BlankNode}`,
19
+ jsType: this.jsTypes[0],
19
20
  },
20
21
  {
21
- name: code `${this.reusables.imports.NamedNode}`,
22
- typeof: "object",
22
+ expression: code `${this.reusables.imports.NamedNode}`,
23
+ jsType: this.jsTypes[0],
23
24
  },
24
25
  {
25
- name: "string",
26
- typeof: "string",
26
+ // To NamedNode
27
+ expression: code `string`,
28
+ jsType: { typeof: "string" },
27
29
  },
28
30
  {
29
- name: "undefined",
30
- typeof: "undefined",
31
+ // To BlankNode
32
+ expression: code `undefined`,
33
+ jsType: { typeof: "undefined" },
31
34
  },
32
35
  ],
33
36
  });
34
37
  filterFunction = code `${this.reusables.snippets.filterIdentifier}`;
35
38
  filterType = code `${this.reusables.snippets.IdentifierFilter}`;
36
- parseFunction = code `${this.reusables.snippets.parseIdentifier};`;
37
39
  kind = "Identifier";
38
- name = code `(${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode})`;
39
40
  nodeKinds = nodeKinds;
41
+ parseFunction = code `${this.reusables.snippets.parseIdentifier};`;
40
42
  schemaType = code `${this.reusables.snippets.IdentifierSchema}`;
41
43
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.identifierSparqlWherePatterns}`;
42
44
  constructor(parameters) {
@@ -47,13 +49,7 @@ export class IdentifierType extends AbstractIdentifierType {
47
49
  });
48
50
  }
49
51
  fromJsonExpression({ variables, }) {
50
- return code `${this.reusables.imports.Either}.of<Error, ${this.name}>((${variables.value}["@id"].startsWith("_:") ? ${this.reusables.imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2)) : ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"])))`;
51
- }
52
- jsonType(parameters) {
53
- const discriminantProperty = parameters?.includeDiscriminantProperty
54
- ? `, readonly termType: "BlankNode" | "NamedNode"`
55
- : "";
56
- return new AbstractIdentifierType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
52
+ return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>((${variables.value}["@id"].startsWith("_:") ? ${this.reusables.imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2)) : ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"])))`;
57
53
  }
58
54
  jsonSchema({ includeDiscriminantProperty, }) {
59
55
  const discriminantProperty = includeDiscriminantProperty
@@ -61,6 +57,12 @@ export class IdentifierType extends AbstractIdentifierType {
61
57
  : "";
62
58
  return code `${this.reusables.imports.z}.object({ "@id": ${this.reusables.imports.z}.string().min(1)${discriminantProperty} })`;
63
59
  }
60
+ jsonType(parameters) {
61
+ const discriminantProperty = parameters?.includeDiscriminantProperty
62
+ ? `, readonly termType: "BlankNode" | "NamedNode"`
63
+ : "";
64
+ return new AbstractIdentifierType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
65
+ }
64
66
  toJsonExpression({ includeDiscriminantProperty, variables, }) {
65
67
  const discriminantProperty = includeDiscriminantProperty
66
68
  ? code `, termType: ${variables.value}.termType as ${[...this.nodeKinds].map((nodeKind) => `"${NodeKind.toTermType(nodeKind)}"`).join(" | ")}`
@@ -2,8 +2,10 @@ 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 IntType extends AbstractNumericType<number> {
5
+ readonly jsTypes: readonly [{
6
+ readonly typeof: "number";
7
+ }];
5
8
  readonly kind = "Int";
6
- readonly typeofs: "number"[];
7
9
  get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
8
10
  literalExpression(literal: Literal | number): Code;
9
11
  protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractNumericType<number>["fromRdfResourceValueExpression"]>[0]): Code;