@shaclmate/compiler 4.0.38 → 4.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/dist/ShapesGraphToAstTransformer.js +12 -12
  2. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +24 -24
  3. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -4
  4. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +16 -16
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
  7. package/dist/ast/AbstractCollectionType.d.ts +1 -1
  8. package/dist/ast/AbstractCompoundType.d.ts +1 -1
  9. package/dist/ast/AbstractCompoundType.js +15 -15
  10. package/dist/ast/AbstractContainerType.d.ts +1 -1
  11. package/dist/ast/AbstractContainerType.js +15 -15
  12. package/dist/ast/AbstractLazyObjectType.d.ts +1 -1
  13. package/dist/ast/AbstractTermType.d.ts +1 -1
  14. package/dist/ast/BlankNodeType.d.ts +1 -1
  15. package/dist/ast/BlankNodeType.js +1 -1
  16. package/dist/ast/DefaultValueType.d.ts +1 -1
  17. package/dist/ast/DefaultValueType.js +2 -2
  18. package/dist/ast/IdentifierType.d.ts +1 -1
  19. package/dist/ast/IdentifierType.js +1 -1
  20. package/dist/ast/IntersectionType.d.ts +1 -1
  21. package/dist/ast/IntersectionType.js +3 -3
  22. package/dist/ast/IriType.d.ts +1 -1
  23. package/dist/ast/IriType.js +1 -1
  24. package/dist/ast/LazyObjectOptionType.d.ts +1 -1
  25. package/dist/ast/LazyObjectOptionType.js +1 -1
  26. package/dist/ast/LazyObjectSetType.d.ts +1 -1
  27. package/dist/ast/LazyObjectSetType.js +1 -1
  28. package/dist/ast/LazyObjectType.d.ts +1 -1
  29. package/dist/ast/LazyObjectType.js +1 -1
  30. package/dist/ast/ListType.d.ts +1 -1
  31. package/dist/ast/ListType.js +16 -16
  32. package/dist/ast/LiteralType.d.ts +1 -1
  33. package/dist/ast/LiteralType.js +1 -1
  34. package/dist/ast/ObjectCompoundType.js +3 -3
  35. package/dist/ast/ObjectType.d.ts +1 -1
  36. package/dist/ast/ObjectType.js +16 -16
  37. package/dist/ast/OptionType.d.ts +1 -1
  38. package/dist/ast/OptionType.js +1 -1
  39. package/dist/ast/SetType.d.ts +1 -1
  40. package/dist/ast/SetType.js +1 -1
  41. package/dist/ast/TermType.d.ts +1 -1
  42. package/dist/ast/TermType.js +1 -1
  43. package/dist/ast/Type.js +15 -15
  44. package/dist/ast/UnionType.d.ts +1 -1
  45. package/dist/ast/UnionType.js +3 -3
  46. package/dist/generators/transformAstToLabeledPropertyGraph.js +10 -10
  47. package/dist/generators/ts/AbstractCollectionType.d.ts +2 -6
  48. package/dist/generators/ts/AbstractCollectionType.js +16 -15
  49. package/dist/generators/ts/AbstractContainerType.d.ts +7 -11
  50. package/dist/generators/ts/AbstractContainerType.js +35 -36
  51. package/dist/generators/ts/AbstractDateType.d.ts +4 -4
  52. package/dist/generators/ts/AbstractDateType.js +2 -2
  53. package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
  54. package/dist/generators/ts/AbstractLazyObjectType.d.ts +14 -17
  55. package/dist/generators/ts/AbstractLazyObjectType.js +26 -38
  56. package/dist/generators/ts/AbstractLiteralType.d.ts +1 -5
  57. package/dist/generators/ts/AbstractLiteralType.js +7 -6
  58. package/dist/generators/ts/AbstractNumericType.d.ts +2 -2
  59. package/dist/generators/ts/AbstractNumericType.js +3 -3
  60. package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
  61. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  62. package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -6
  63. package/dist/generators/ts/AbstractPrimitiveType.js +9 -10
  64. package/dist/generators/ts/AbstractTermType.d.ts +1 -5
  65. package/dist/generators/ts/AbstractTermType.js +3 -17
  66. package/dist/generators/ts/AbstractType.d.ts +22 -15
  67. package/dist/generators/ts/AbstractType.js +18 -8
  68. package/dist/generators/ts/BigDecimalType.d.ts +2 -2
  69. package/dist/generators/ts/BigDecimalType.js +3 -3
  70. package/dist/generators/ts/BigIntType.d.ts +1 -1
  71. package/dist/generators/ts/BigIntType.js +3 -3
  72. package/dist/generators/ts/BlankNodeType.d.ts +4 -4
  73. package/dist/generators/ts/BlankNodeType.js +12 -12
  74. package/dist/generators/ts/BooleanType.d.ts +3 -3
  75. package/dist/generators/ts/BooleanType.js +11 -6
  76. package/dist/generators/ts/DateTimeType.d.ts +1 -1
  77. package/dist/generators/ts/DateTimeType.js +1 -1
  78. package/dist/generators/ts/DateType.d.ts +1 -1
  79. package/dist/generators/ts/DateType.js +1 -1
  80. package/dist/generators/ts/DefaultValueType.d.ts +3 -7
  81. package/dist/generators/ts/DefaultValueType.js +17 -21
  82. package/dist/generators/ts/FloatType.d.ts +1 -1
  83. package/dist/generators/ts/FloatType.js +1 -1
  84. package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
  85. package/dist/generators/ts/GraphqlSchema.js +4 -4
  86. package/dist/generators/ts/IdentifierType.d.ts +4 -4
  87. package/dist/generators/ts/IdentifierType.js +14 -14
  88. package/dist/generators/ts/IntType.d.ts +1 -1
  89. package/dist/generators/ts/IntType.js +1 -1
  90. package/dist/generators/ts/IriType.d.ts +4 -2
  91. package/dist/generators/ts/IriType.js +27 -22
  92. package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
  93. package/dist/generators/ts/LazyObjectOptionType.js +7 -7
  94. package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
  95. package/dist/generators/ts/LazyObjectSetType.js +6 -6
  96. package/dist/generators/ts/LazyObjectType.d.ts +1 -1
  97. package/dist/generators/ts/LazyObjectType.js +5 -5
  98. package/dist/generators/ts/ListType.d.ts +5 -6
  99. package/dist/generators/ts/ListType.js +24 -25
  100. package/dist/generators/ts/LiteralType.d.ts +3 -2
  101. package/dist/generators/ts/LiteralType.js +14 -7
  102. package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +24 -24
  103. package/dist/generators/ts/ObjectType.js +350 -0
  104. package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
  105. package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +54 -64
  106. package/dist/generators/ts/OptionType.d.ts +2 -6
  107. package/dist/generators/ts/OptionType.js +12 -18
  108. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -8
  109. package/dist/generators/ts/SetType.d.ts +1 -1
  110. package/dist/generators/ts/SetType.js +1 -1
  111. package/dist/generators/ts/Snippets.d.ts +1 -0
  112. package/dist/generators/ts/Snippets.js +7 -0
  113. package/dist/generators/ts/SparqlObjectSetType.js +2 -2
  114. package/dist/generators/ts/StringType.d.ts +3 -3
  115. package/dist/generators/ts/StringType.js +11 -6
  116. package/dist/generators/ts/TermType.d.ts +3 -3
  117. package/dist/generators/ts/TermType.js +13 -13
  118. package/dist/generators/ts/TsGenerator.js +12 -9
  119. package/dist/generators/ts/Type.d.ts +4 -5
  120. package/dist/generators/ts/TypeFactory.d.ts +7 -8
  121. package/dist/generators/ts/TypeFactory.js +79 -80
  122. package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +40 -15
  123. package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +328 -135
  124. package/dist/generators/ts/ZodGenerator.js +7 -9
  125. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +13 -13
  126. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +11 -14
  127. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +3 -2
  128. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +24 -15
  129. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +3 -6
  130. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +20 -12
  131. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
  132. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_createFunctionDeclaration.js → _ObjectType/ObjectType_createFunctionDeclaration.js} +6 -6
  133. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
  134. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +5 -5
  135. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
  136. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -3
  137. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
  138. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +3 -3
  139. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  140. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  141. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  142. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +3 -3
  143. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
  144. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js → _ObjectType/ObjectType_fromJsonFunctionDeclaration.js} +4 -4
  145. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
  146. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js} +7 -31
  147. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
  148. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
  149. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
  150. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
  151. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
  152. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
  153. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
  154. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js → _ObjectType/ObjectType_hashFunctionDeclarations.js} +8 -8
  155. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
  156. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_interfaceDeclaration.js → _ObjectType/ObjectType_interfaceDeclaration.js} +5 -5
  157. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
  158. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js → _ObjectType/ObjectType_isTypeFunctionDeclaration.js} +3 -3
  159. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
  160. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
  161. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
  162. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +2 -2
  163. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
  164. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js → _ObjectType/ObjectType_jsonTypeAliasDeclaration.js} +2 -2
  165. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
  166. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
  167. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
  168. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
  169. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
  170. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +14 -0
  171. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
  172. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
  173. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
  174. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
  175. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  176. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js → _ObjectType/ObjectType_toJsonFunctionDeclaration.js} +4 -4
  177. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  178. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
  179. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
  180. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +6 -6
  181. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  182. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  183. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  184. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
  185. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +2 -6
  186. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +24 -28
  187. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
  188. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/identifierTypeDeclarations.js +4 -2
  189. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +2 -2
  190. package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +1 -1
  191. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +1 -1
  192. package/dist/generators/ts/_snippets/snippets_IriSchema.js +2 -2
  193. package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +2 -2
  194. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
  195. package/dist/generators/ts/_snippets/snippets_StringSchema.js +2 -2
  196. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +1 -1
  197. package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
  198. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  199. package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.d.ts +3 -0
  200. package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.js +16 -0
  201. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +1 -1
  202. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
  203. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
  204. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +1 -1
  205. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +3 -3
  206. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +1 -1
  207. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +1 -1
  208. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +1 -1
  209. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +1 -1
  210. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +1 -1
  211. package/dist/generators/ts/_snippets/snippets_validateArray.js +1 -1
  212. package/dist/generators/ts/_snippets/snippets_validateMaybe.js +1 -1
  213. package/dist/generators/ts/tsComment.js +1 -1
  214. package/dist/input/generated.d.ts +1399 -1468
  215. package/dist/input/generated.js +518 -655
  216. package/package.json +4 -4
  217. package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
  218. package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
  219. package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
  220. package/dist/generators/ts/AnonymousUnionType.js +0 -59
  221. package/dist/generators/ts/NamedObjectType.js +0 -341
  222. package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
  223. package/dist/generators/ts/NamedUnionType.d.ts +0 -11
  224. package/dist/generators/ts/NamedUnionType.js +0 -13
  225. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
  226. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
  227. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
  228. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
  229. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  230. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  231. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  232. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  233. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  234. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  235. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  236. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  237. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
  238. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
  239. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
  240. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
  241. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  242. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  243. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  244. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
  245. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
  246. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
  247. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  248. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  249. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
  250. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  251. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  252. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
  253. package/dist/generators/ts/removeUndefined.d.ts +0 -2
  254. package/dist/generators/ts/removeUndefined.js +0 -17
  255. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
  256. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
@@ -1,7 +1,7 @@
1
1
  import { Maybe } from "purify-ts";
2
2
  import { AbstractType } from "./AbstractType.js";
3
- import type { NamedObjectType } from "./NamedObjectType.js";
4
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
+ import type { ObjectType } from "./ObjectType.js";
4
+ import type { ObjectUnionType } from "./ObjectUnionType.js";
5
5
  import type { OptionType } from "./OptionType.js";
6
6
  import type { SetType } from "./SetType.js";
7
7
  import { type Code } from "./ts-poet-wrapper.js";
@@ -16,6 +16,7 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
16
16
  readonly declaration: Maybe<Code>;
17
17
  readonly discriminantProperty: AbstractType["discriminantProperty"];
18
18
  readonly mutable = false;
19
+ readonly referencesObjectType = true;
19
20
  readonly typeofs: "object"[];
20
21
  readonly validationFunction: Maybe<Code>;
21
22
  constructor({ partialType, resolveType, ...superParameters }: {
@@ -23,41 +24,37 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
23
24
  resolveType: ResolveTypeT;
24
25
  } & ConstructorParameters<typeof AbstractType>[0]);
25
26
  get equalsFunction(): Code;
26
- get hashFunction(): Code;
27
+ get expression(): Code;
27
28
  get filterFunction(): Code;
28
29
  get filterType(): Code;
29
30
  get graphqlType(): AbstractType.GraphqlType;
30
- get name(): Code;
31
+ get hashFunction(): Code;
31
32
  get recursive(): boolean;
32
- get schema(): Code;
33
33
  get schemaType(): Code;
34
34
  get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
35
35
  get valueSparqlConstructTriplesFunction(): Code;
36
36
  get valueSparqlWherePatternsFunction(): Code;
37
- protected get schemaObject(): {
38
- partial: Code;
39
- kind: Code;
40
- };
37
+ protected get schemaInitializers(): readonly Code[];
41
38
  jsonSchema(parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
42
39
  jsonType(parameters?: Parameters<AbstractType["jsonType"]>[0]): AbstractType.JsonType;
43
40
  jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
44
41
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
45
42
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
46
43
  toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
47
- protected resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }: {
48
- resolvedNamedObjectUnionType: NamedObjectUnionType;
49
- partialNamedObjectUnionType: NamedObjectUnionType;
50
- variables: {
51
- resolvedObjectUnion: Code;
52
- };
53
- }): Code;
54
44
  protected resolveToPartialFunction<ObjectTypeT extends AbstractLazyObjectType.ObjectTypeConstraint>({ partialType, resolveType, }: {
55
45
  partialType: ObjectTypeT;
56
46
  resolveType: ObjectTypeT;
57
47
  }): Code;
48
+ protected resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }: {
49
+ resolvedObjectUnionType: ObjectUnionType;
50
+ partialObjectUnionType: ObjectUnionType;
51
+ variables: {
52
+ resolvedObjectUnion: Code;
53
+ };
54
+ }): Code;
58
55
  }
59
56
  export declare namespace AbstractLazyObjectType {
60
- type ObjectTypeConstraint = NamedObjectType | NamedObjectUnionType;
57
+ type ObjectTypeConstraint = ObjectType | ObjectUnionType;
61
58
  type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
62
59
  type ResolveTypeConstraint = PartialTypeConstraint;
63
60
  type ConversionFunction = AbstractType.ConversionFunction;
@@ -8,7 +8,6 @@ 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
- import { removeUndefined } from "./removeUndefined.js";
12
11
  import { code, joinCode } from "./ts-poet-wrapper.js";
13
12
  export class AbstractLazyObjectType extends AbstractType {
14
13
  partialType;
@@ -16,6 +15,7 @@ export class AbstractLazyObjectType extends AbstractType {
16
15
  declaration = Maybe.empty();
17
16
  discriminantProperty = Maybe.empty();
18
17
  mutable = false;
18
+ referencesObjectType = true;
19
19
  typeofs = ["object"];
20
20
  validationFunction = Maybe.empty();
21
21
  constructor({ partialType, resolveType, ...superParameters }) {
@@ -26,11 +26,11 @@ export class AbstractLazyObjectType extends AbstractType {
26
26
  get equalsFunction() {
27
27
  return code `((left, right) => ${this.partialType.equalsFunction}(left.${this.runtimeClass.partialPropertyName}, right.${this.runtimeClass.partialPropertyName}))`;
28
28
  }
29
- get hashFunction() {
30
- return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
29
+ get expression() {
30
+ return this.runtimeClass.name;
31
31
  }
32
32
  get filterFunction() {
33
- return code `((filter: ${this.filterType}, value: ${this.name}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
33
+ return code `((filter: ${this.filterType}, value: ${this.expression}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
34
34
  }
35
35
  get filterType() {
36
36
  return this.partialType.filterType;
@@ -38,38 +38,29 @@ export class AbstractLazyObjectType extends AbstractType {
38
38
  get graphqlType() {
39
39
  return this.resolveType.graphqlType;
40
40
  }
41
- get name() {
42
- return this.runtimeClass.name;
41
+ get hashFunction() {
42
+ return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
43
43
  }
44
44
  get recursive() {
45
45
  return this.partialType.recursive;
46
46
  }
47
- get schema() {
48
- return code `${removeUndefined(this.schemaObject)}`;
49
- }
50
47
  get schemaType() {
51
48
  return code `${{
52
49
  kind: this.kind,
53
50
  partialType: this.partialType.schemaType,
54
- resolveType: this.resolveType.schemaType,
55
51
  }}`;
56
52
  }
57
53
  get toRdfResourceValueTypes() {
58
54
  return this.partialType.toRdfResourceValueTypes;
59
55
  }
60
56
  get valueSparqlConstructTriplesFunction() {
61
- return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.partial() }))`;
57
+ return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.partialType }))`;
62
58
  }
63
59
  get valueSparqlWherePatternsFunction() {
64
- return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partial() }))`;
60
+ return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partialType }))`;
65
61
  }
66
- get schemaObject() {
67
- return {
68
- ...super.schemaObject,
69
- partial: code `() => (${this.partialType.schema})`,
70
- // Commenting out to reduce schema size
71
- // resolved: code`() => (${this.resolveType.schema})`,
72
- };
62
+ get schemaInitializers() {
63
+ return super.schemaInitializers.concat(code `get partialType() { return ${this.partialType.schema}; }`);
73
64
  }
74
65
  jsonSchema(parameters) {
75
66
  return this.partialType.jsonSchema(parameters);
@@ -102,41 +93,38 @@ export class AbstractLazyObjectType extends AbstractType {
102
93
  },
103
94
  });
104
95
  }
105
- resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }) {
106
- invariant(resolvedNamedObjectUnionType.members.length ===
107
- partialNamedObjectUnionType.members.length);
108
- const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
109
- return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.name}.create(${variables.resolvedObjectUnion});`;
110
- });
111
- caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
112
- return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
113
- }
114
96
  resolveToPartialFunction({ partialType, resolveType, }) {
115
- if (partialType.kind === "NamedObjectType") {
116
- return code `${partialType.name}.createUnsafe`;
97
+ if (partialType.kind === "Object") {
98
+ return code `${partialType.alias.unsafeCoerce()}.createUnsafe`;
117
99
  }
118
- invariant(partialType.kind === "NamedObjectUnionType");
119
- invariant(resolveType.kind === "NamedObjectUnionType");
100
+ invariant(partialType.kind === "ObjectUnion");
101
+ invariant(resolveType.kind === "ObjectUnion");
120
102
  invariant(partialType.members.length === resolveType.members.length);
121
103
  const caseBlocks = resolveType.members.map(({ discriminantValues }, memberI) => {
122
- return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.name}.createUnsafe(resolved);`;
104
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.alias.unsafeCoerce()}.createUnsafe(resolved);`;
123
105
  });
124
106
  caseBlocks.push(code `default: resolved satisfies never; throw new Error("unrecognized type");`);
125
- return code `((resolved: ${resolveType.name}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
107
+ return code `((resolved: ${resolveType.expression}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
108
+ }
109
+ resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }) {
110
+ invariant(resolvedObjectUnionType.members.length ===
111
+ partialObjectUnionType.members.length);
112
+ const caseBlocks = resolvedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
113
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialObjectUnionType.members[memberI].type.alias.unsafeCoerce()}.create(${variables.resolvedObjectUnion});`;
114
+ });
115
+ caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
116
+ return code `switch (${variables.resolvedObjectUnion}.${resolvedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
126
117
  }
127
118
  }
128
119
  __decorate([
129
120
  Memoize()
130
121
  ], AbstractLazyObjectType.prototype, "equalsFunction", null);
131
- __decorate([
132
- Memoize()
133
- ], AbstractLazyObjectType.prototype, "hashFunction", null);
134
122
  __decorate([
135
123
  Memoize()
136
124
  ], AbstractLazyObjectType.prototype, "filterFunction", null);
137
125
  __decorate([
138
126
  Memoize()
139
- ], AbstractLazyObjectType.prototype, "schema", null);
127
+ ], AbstractLazyObjectType.prototype, "hashFunction", null);
140
128
  __decorate([
141
129
  Memoize()
142
130
  ], AbstractLazyObjectType.prototype, "schemaType", null);
@@ -8,11 +8,7 @@ export declare abstract class AbstractLiteralType extends AbstractTermType<Liter
8
8
  languageIn: readonly string[];
9
9
  } & ConstructorParameters<typeof AbstractTermType<Literal, Literal>>[0]);
10
10
  get constrained(): boolean;
11
- protected get schemaObject(): {
12
- languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
13
- in: Code | undefined;
14
- kind: Code;
15
- };
11
+ protected get schemaInitializers(): readonly Code[];
16
12
  /**
17
13
  * An expression that converts a compile-time RDF/JS Literal into a runtime TypeScript literal.
18
14
  *
@@ -1,5 +1,5 @@
1
1
  import { AbstractTermType } from "./AbstractTermType.js";
2
- import { code, literalOf } from "./ts-poet-wrapper.js";
2
+ import { arrayOf, code } from "./ts-poet-wrapper.js";
3
3
  export class AbstractLiteralType extends AbstractTermType {
4
4
  languageIn;
5
5
  nodeKinds = nodeKinds;
@@ -10,11 +10,12 @@ export class AbstractLiteralType extends AbstractTermType {
10
10
  get constrained() {
11
11
  return super.constrained || this.languageIn.length > 0;
12
12
  }
13
- get schemaObject() {
14
- return {
15
- ...super.schemaObject,
16
- languageIn: this.languageIn.length > 0 ? this.languageIn.map(literalOf) : undefined,
17
- };
13
+ get schemaInitializers() {
14
+ let initializers = super.schemaInitializers;
15
+ if (this.languageIn.length > 0) {
16
+ initializers = initializers.concat(code `languageIn: ${arrayOf(...this.languageIn)}`);
17
+ }
18
+ return initializers;
18
19
  }
19
20
  fromRdfResourceValuesExpressionChain({ variables, }) {
20
21
  return {
@@ -5,10 +5,10 @@ import { type Code } from "./ts-poet-wrapper.js";
5
5
  */
6
6
  export declare abstract class AbstractNumericType<ValueT extends bigint | number> extends AbstractPrimitiveType<ValueT> {
7
7
  readonly hashFunction: Code;
8
- abstract readonly kind: "BigIntType" | "FloatType" | "IntType";
8
+ abstract readonly kind: "BigInt" | "Float" | "Int";
9
9
  get filterFunction(): Code;
10
10
  get filterType(): Code;
11
- get name(): Code | string;
11
+ get expression(): Code;
12
12
  get schemaType(): Code;
13
13
  get valueSparqlWherePatternsFunction(): Code;
14
14
  jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
@@ -18,11 +18,11 @@ export class AbstractNumericType extends AbstractPrimitiveType {
18
18
  get filterType() {
19
19
  return code `${this.reusables.snippets.NumericFilter}<${this.typeofs[0]}>`;
20
20
  }
21
- get name() {
21
+ get expression() {
22
22
  if (this.primitiveIn.length > 0) {
23
23
  return code `${joinCode(this.primitiveIn.map((value) => this.literalExpression(value)), { on: " | " })}`;
24
24
  }
25
- return this.typeofs[0];
25
+ return code `${this.typeofs[0]}`;
26
26
  }
27
27
  get schemaType() {
28
28
  return code `${this.reusables.snippets.NumericSchema}<${this.typeofs[0]}>`;
@@ -62,7 +62,7 @@ __decorate([
62
62
  ], AbstractNumericType.prototype, "filterType", null);
63
63
  __decorate([
64
64
  Memoize()
65
- ], AbstractNumericType.prototype, "name", null);
65
+ ], AbstractNumericType.prototype, "expression", null);
66
66
  __decorate([
67
67
  Memoize()
68
68
  ], AbstractNumericType.prototype, "schemaType", null);
@@ -1,6 +1,7 @@
1
+ import type { Maybe } from "purify-ts";
1
2
  import type { Logger } from "ts-log";
2
- import type { NamedObjectType } from "./NamedObjectType.js";
3
- import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
+ import type { ObjectType } from "./ObjectType.js";
4
+ import type { ObjectUnionType } from "./ObjectUnionType.js";
4
5
  import type { Reusables } from "./Reusables.js";
5
6
  import type { TsGenerator } from "./TsGenerator.js";
6
7
  import { type Code } from "./ts-poet-wrapper.js";
@@ -8,25 +9,25 @@ export declare abstract class AbstractObjectSetType {
8
9
  protected readonly configuration: TsGenerator.Configuration;
9
10
  protected readonly logger: Logger;
10
11
  protected readonly reusables: Reusables;
11
- protected readonly namedObjectTypes: readonly NamedObjectType[];
12
- protected readonly namedObjectUnionTypes: readonly NamedObjectUnionType[];
12
+ protected readonly namedObjectTypes: readonly ObjectType[];
13
+ protected readonly namedObjectUnionTypes: readonly ObjectUnionType[];
13
14
  constructor({ configuration, logger, namedObjectTypes, namedObjectUnionTypes, reusables, }: {
14
15
  configuration: TsGenerator.Configuration;
15
16
  logger: Logger;
16
- namedObjectTypes: readonly NamedObjectType[];
17
- namedObjectUnionTypes: readonly NamedObjectUnionType[];
17
+ namedObjectTypes: readonly ObjectType[];
18
+ namedObjectUnionTypes: readonly ObjectUnionType[];
18
19
  reusables: Reusables;
19
20
  });
20
21
  abstract readonly declaration: Code;
21
22
  protected methodSignatures(namedObjectType: {
23
+ readonly alias: Maybe<string>;
22
24
  readonly filterType: Code;
23
25
  readonly identifierTypeAlias: Code;
24
- readonly objectSetMethodNames: NamedObjectType.ObjectSetMethodNames;
25
- readonly name: string;
26
+ readonly objectSetMethodNames: ObjectType.ObjectSetMethodNames;
26
27
  }, options?: {
27
28
  parameterNamePrefix?: string;
28
29
  queryT?: string;
29
- }): Readonly<Record<keyof NamedObjectType.ObjectSetMethodNames, {
30
+ }): Readonly<Record<keyof ObjectType.ObjectSetMethodNames, {
30
31
  readonly name: string;
31
32
  readonly parameters: Code;
32
33
  readonly returnType: Code;
@@ -21,7 +21,7 @@ export class AbstractObjectSetType {
21
21
  object: {
22
22
  name: methodNames.object,
23
23
  parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
24
- returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.name}>>`,
24
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.alias.unsafeCoerce()}>>`,
25
25
  },
26
26
  objectCount: {
27
27
  name: methodNames.objectCount,
@@ -36,7 +36,7 @@ export class AbstractObjectSetType {
36
36
  objects: {
37
37
  name: methodNames.objects,
38
38
  parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
39
- returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]>>`,
39
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.alias.unsafeCoerce()}[]>>`,
40
40
  },
41
41
  };
42
42
  }
@@ -6,18 +6,14 @@ export declare abstract class AbstractPrimitiveType<ValueT extends bigint | bool
6
6
  protected readonly datatype: NamedNode;
7
7
  readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
8
8
  readonly equalsFunction: Code;
9
- abstract readonly kind: "BigIntType" | "BooleanType" | "DateTimeType" | "DateType" | "FloatType" | "IntType" | "NumberType" | "StringType";
9
+ abstract readonly kind: "BigInt" | "Boolean" | "DateTime" | "Date" | "Float" | "Int" | "NumberType" | "String";
10
10
  readonly primitiveIn: readonly ValueT[];
11
11
  constructor({ datatype, primitiveIn, ...superParameters }: {
12
12
  datatype: NamedNode;
13
13
  primitiveIn: readonly ValueT[];
14
14
  } & ConstructorParameters<typeof AbstractLiteralType>[0]);
15
15
  get discriminantProperty(): Maybe<AbstractLiteralType.DiscriminantProperty>;
16
- protected get schemaObject(): {
17
- in: Code | undefined;
18
- languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
19
- kind: Code;
20
- };
16
+ protected get schemaInitializers(): readonly Code[];
21
17
  fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
22
18
  graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
23
19
  jsonType(): AbstractLiteralType.JsonType;
@@ -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, joinCode } from "./ts-poet-wrapper.js";
10
+ import { arrayOf, code } from "./ts-poet-wrapper.js";
11
11
  export class AbstractPrimitiveType extends AbstractLiteralType {
12
12
  datatype;
13
13
  conversionFunction = Maybe.empty();
@@ -21,22 +21,21 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
21
21
  get discriminantProperty() {
22
22
  return Maybe.empty();
23
23
  }
24
- get schemaObject() {
25
- return {
26
- ...super.schemaObject,
27
- in: this.primitiveIn.length > 0
28
- ? code `[${joinCode(this.primitiveIn.map((in_) => this.literalExpression(in_)), { on: ", " })}] as const`
29
- : undefined,
30
- };
24
+ get schemaInitializers() {
25
+ let initializers = super.schemaInitializers;
26
+ if (this.primitiveIn.length > 0) {
27
+ initializers = initializers.concat(code `in: ${arrayOf(...this.primitiveIn.map((in_) => this.literalExpression(in_)))}`);
28
+ }
29
+ return initializers;
31
30
  }
32
31
  fromJsonExpression({ variables, }) {
33
- return code `${this.reusables.imports.Either}.of<Error, ${this.name}>(${variables.value})`;
32
+ return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${variables.value})`;
34
33
  }
35
34
  graphqlResolveExpression({ variables, }) {
36
35
  return variables.value;
37
36
  }
38
37
  jsonType() {
39
- return new AbstractLiteralType.JsonType(this.name);
38
+ return new AbstractLiteralType.JsonType(this.expression);
40
39
  }
41
40
  toJsonExpression({ variables, }) {
42
41
  return variables.value;
@@ -23,6 +23,7 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
23
23
  readonly mutable: boolean;
24
24
  abstract readonly nodeKinds: ReadonlySet<NodeKind>;
25
25
  readonly recursive = false;
26
+ readonly referencesObjectType = false;
26
27
  readonly typeofs: readonly Typeof[];
27
28
  readonly validationFunction: Maybe<Code>;
28
29
  constructor({ hasValues, in_, ...superParameters }: {
@@ -31,11 +32,6 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
31
32
  } & ConstructorParameters<typeof AbstractType>[0]);
32
33
  get constrained(): boolean;
33
34
  get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
34
- get schema(): Code;
35
- protected get schemaObject(): {
36
- in: Code | undefined;
37
- kind: Code;
38
- };
39
35
  get termTypes(): ReadonlySet<"BlankNode" | "Literal" | "NamedNode">;
40
36
  get toRdfResourceValueTypes(): Set<"BlankNode" | "Literal" | "NamedNode">;
41
37
  get valueSparqlConstructTriplesFunction(): Code;
@@ -8,7 +8,6 @@ import { NodeKind } from "@shaclmate/shacl-ast";
8
8
  import { Maybe } from "purify-ts";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractType } from "./AbstractType.js";
11
- import { removeUndefined } from "./removeUndefined.js";
12
11
  import { code, joinCode } from "./ts-poet-wrapper.js";
13
12
  /**
14
13
  * Abstract base class for IdentifierType and LiteralType.
@@ -27,6 +26,7 @@ export class AbstractTermType extends AbstractType {
27
26
  in_;
28
27
  mutable = false;
29
28
  recursive = false;
29
+ referencesObjectType = false;
30
30
  typeofs = ["object"];
31
31
  validationFunction = Maybe.empty();
32
32
  constructor({ hasValues, in_, ...superParameters }) {
@@ -46,17 +46,6 @@ export class AbstractTermType extends AbstractType {
46
46
  type: "string",
47
47
  });
48
48
  }
49
- get schema() {
50
- return code `${removeUndefined(this.schemaObject)}`;
51
- }
52
- get schemaObject() {
53
- return {
54
- ...super.schemaObject,
55
- in: this.in_.length > 0
56
- ? code `[${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}] as const`
57
- : undefined,
58
- };
59
- }
60
49
  get termTypes() {
61
50
  return new Set([...this.nodeKinds].map(NodeKind.toTermType));
62
51
  }
@@ -106,11 +95,11 @@ export class AbstractTermType extends AbstractType {
106
95
  valueToExpression = code `value.toTerm([${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}])`;
107
96
  }
108
97
  else if (this.nodeKinds.size < 3) {
109
- const eitherTypeParameters = code `<Error, ${this.name}>`;
98
+ const eitherTypeParameters = code `<Error, ${this.expression}>`;
110
99
  valueToExpression = code `value.toTerm().chain(term => {
111
100
  switch (term.termType) {
112
101
  ${[...this.nodeKinds].map((nodeKind) => `case "${NodeKind.toTermType(nodeKind)}":`).join("\n")} return ${this.reusables.imports.Either}.of${eitherTypeParameters}(term);
113
- default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.name}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
102
+ default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.expression}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
114
103
  }})`;
115
104
  }
116
105
  else {
@@ -128,9 +117,6 @@ chain(values => ${this.reusables.imports.Either}.sequence([${joinCode(this.hasVa
128
117
  __decorate([
129
118
  Memoize()
130
119
  ], AbstractTermType.prototype, "discriminantProperty", null);
131
- __decorate([
132
- Memoize()
133
- ], AbstractTermType.prototype, "schema", null);
134
120
  __decorate([
135
121
  Memoize()
136
122
  ], AbstractTermType.prototype, "termTypes", null);
@@ -12,6 +12,10 @@ export declare abstract class AbstractType {
12
12
  protected readonly configuration: TsGenerator.Configuration;
13
13
  protected readonly logger: Logger;
14
14
  protected readonly reusables: Reusables;
15
+ /**
16
+ * Alias for this type.
17
+ */
18
+ readonly alias: Maybe<string>;
15
19
  /**
16
20
  * Comment from rdfs:comment.
17
21
  */
@@ -39,6 +43,10 @@ export declare abstract class AbstractType {
39
43
  * $EqualsResult.
40
44
  */
41
45
  abstract readonly equalsFunction: Code;
46
+ /**
47
+ * TypeScript type expression.
48
+ */
49
+ abstract readonly expression: Code;
42
50
  /**
43
51
  * A function (reference or declaration) that takes a filter of filterType (below) and a value of this type
44
52
  * and returns true if the value passes the filter.
@@ -74,18 +82,14 @@ export declare abstract class AbstractType {
74
82
  * Is a value of this type mutable?
75
83
  */
76
84
  abstract readonly mutable: boolean;
77
- /**
78
- * TypeScript name of the type.
79
- */
80
- abstract readonly name: Code | string;
81
85
  /**
82
86
  * Does this type directly or indirectly reference itself?
83
87
  */
84
88
  abstract readonly recursive: boolean;
85
89
  /**
86
- * TypeScript object describing this type, for runtime use.
90
+ * Is this type an ObjectType or does it reference an object type?
87
91
  */
88
- abstract readonly schema: Code;
92
+ abstract readonly referencesObjectType: boolean;
89
93
  /**
90
94
  * TypeScript type describing .schema.
91
95
  */
@@ -133,19 +137,22 @@ export declare abstract class AbstractType {
133
137
  * - variablePrefix: string prefix to use for new variables
134
138
  */
135
139
  abstract readonly valueSparqlWherePatternsFunction: Code;
136
- constructor({ comment, configuration, label, logger, reusables, }: {
140
+ constructor({ alias, comment, configuration, label, logger, reusables, }: {
141
+ alias: Maybe<string>;
137
142
  comment: Maybe<string>;
138
143
  configuration: TsGenerator.Configuration;
139
144
  label: Maybe<string>;
140
145
  logger: Logger;
141
146
  reusables: Reusables;
142
147
  });
148
+ /**
149
+ * TypeScript object describing this type, for runtime use.
150
+ */
151
+ get schema(): Code;
143
152
  /**
144
153
  * Helper to compose the result of schema along the type hierarchy.
145
154
  */
146
- protected get schemaObject(): {
147
- kind: Code;
148
- };
155
+ protected get schemaInitializers(): readonly Code[];
149
156
  /**
150
157
  * An expression that converts this type's JSON type to an Either<Error, ThisType>.
151
158
  */
@@ -158,7 +165,7 @@ export declare abstract class AbstractType {
158
165
  * An expression that converts a Either<Error, rdfjsResource.Resource.Values> to a
159
166
  * Either<Error, rdfjsResource.Resource.Values<this type>>.
160
167
  *
161
- * These expressions are used to deserialize property values in an NamedObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
168
+ * These expressions are used to deserialize property values in an ObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
162
169
  * that has a type parameter of this Type).
163
170
  *
164
171
  * Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
@@ -167,7 +174,7 @@ export declare abstract class AbstractType {
167
174
  * Values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
168
175
  * (if it exists) is always of the first preferred language.
169
176
  *
170
- * variables are runtime variables, most derived from the parameters of the NamedObjectType's fromRdf function:
177
+ * variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
171
178
  * context: unanticipated properties (...) passed to Object.fromRdf
172
179
  * graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
173
180
  * ignoreRdfType: whether the RDF type of objects/object unions should be ignored
@@ -202,7 +209,7 @@ export declare abstract class AbstractType {
202
209
  * Zod schema for the JSON type of this type.
203
210
  *
204
211
  * This method is called in two contexts:
205
- * "property": from a ShaclProperty, while generating the z.object properties of an NamedObjectType
212
+ * "property": from a ShaclProperty, while generating the z.object properties of an ObjectType
206
213
  * "type": from another Type e.g., an OptionType or UnionType
207
214
  *
208
215
  * z.lazy() should only be returned for "property".
@@ -239,7 +246,7 @@ export declare abstract class AbstractType {
239
246
  * An expression that converts a property value of this type to a value or an array of values that can be .add'd to a Resource with
240
247
  * resource.add(predicate, convertedValue, graph)
241
248
  *
242
- * variables are runtime variables, most derived from the parameters of the NamedObjectType's fromRdf function:
249
+ * variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
243
250
  * graph: DefaultGraph | NamedNode | undefined to .add to; if undefined, add to the default graph
244
251
  * propertyPath: predicate path (NamedNode) or InversePath on a predicate path
245
252
  * resource: the Resource to .add to
@@ -269,7 +276,7 @@ export declare namespace AbstractType {
269
276
  interface ConversionFunction {
270
277
  readonly code: Code;
271
278
  readonly sourceTypes: {
272
- readonly name: Code | string;
279
+ readonly expression: Code;
273
280
  readonly typeof: Typeof;
274
281
  }[];
275
282
  }