@shaclmate/compiler 4.0.7 → 4.0.9

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 (306) hide show
  1. package/dist/Compiler.d.ts +1 -4
  2. package/dist/Compiler.js +1 -5
  3. package/dist/ShapesGraphToAstTransformer.d.ts +2 -11
  4. package/dist/ShapesGraphToAstTransformer.js +25 -27
  5. package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.d.ts +3 -0
  6. package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.js +5 -0
  7. package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.d.ts +4 -0
  8. package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +27 -0
  9. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +74 -19
  10. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.d.ts +1 -1
  11. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +45 -91
  12. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +11 -0
  13. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +146 -0
  14. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +7 -0
  15. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +182 -0
  16. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +9 -7
  17. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +3 -5
  18. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +33 -10
  19. package/dist/ast/AbstractCompoundType.d.ts +26 -8
  20. package/dist/ast/AbstractCompoundType.js +84 -16
  21. package/dist/ast/AbstractContainerType.d.ts +2 -4
  22. package/dist/ast/AbstractContainerType.js +3 -4
  23. package/dist/ast/AbstractLazyObjectType.d.ts +1 -0
  24. package/dist/ast/AbstractLazyObjectType.js +3 -0
  25. package/dist/ast/AbstractTermType.d.ts +1 -0
  26. package/dist/ast/AbstractTermType.js +1 -0
  27. package/dist/ast/AbstractType.d.ts +16 -1
  28. package/dist/ast/AbstractType.js +11 -1
  29. package/dist/ast/Ast.d.ts +4 -4
  30. package/dist/ast/BlankNodeType.d.ts +1 -1
  31. package/dist/ast/DefaultValueType.d.ts +1 -2
  32. package/dist/ast/DefaultValueType.js +2 -0
  33. package/dist/ast/IdentifierType.d.ts +1 -1
  34. package/dist/ast/IntersectionType.d.ts +7 -2
  35. package/dist/ast/IntersectionType.js +8 -0
  36. package/dist/ast/ListType.d.ts +2 -9
  37. package/dist/ast/ListType.js +1 -9
  38. package/dist/ast/LiteralType.d.ts +1 -0
  39. package/dist/ast/LiteralType.js +26 -0
  40. package/dist/ast/ObjectCompoundType.d.ts +12 -0
  41. package/dist/ast/ObjectCompoundType.js +88 -0
  42. package/dist/ast/ObjectIntersectionType.d.ts +3 -7
  43. package/dist/ast/ObjectIntersectionType.js +1 -7
  44. package/dist/ast/ObjectType.d.ts +14 -31
  45. package/dist/ast/ObjectType.js +41 -73
  46. package/dist/ast/ObjectUnionType.d.ts +3 -7
  47. package/dist/ast/ObjectUnionType.js +1 -7
  48. package/dist/ast/OptionType.d.ts +1 -2
  49. package/dist/ast/OptionType.js +2 -0
  50. package/dist/ast/SetType.d.ts +1 -2
  51. package/dist/ast/SetType.js +2 -0
  52. package/dist/ast/Type.d.ts +1 -4
  53. package/dist/ast/Type.js +0 -6
  54. package/dist/ast/UnionType.d.ts +11 -6
  55. package/dist/ast/UnionType.js +6 -4
  56. package/dist/ast/index.d.ts +1 -2
  57. package/dist/ast/index.js +1 -2
  58. package/dist/generators/json/AstJsonGenerator.js +16 -14
  59. package/dist/generators/ts/AbstractCollectionType.js +8 -10
  60. package/dist/generators/ts/AbstractContainerType.d.ts +8 -3
  61. package/dist/generators/ts/AbstractContainerType.js +9 -2
  62. package/dist/generators/ts/AbstractDateType.d.ts +2 -2
  63. package/dist/generators/ts/AbstractDateType.js +2 -2
  64. package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
  65. package/dist/generators/ts/AbstractIdentifierType.js +1 -1
  66. package/dist/generators/ts/AbstractLazyObjectType.d.ts +11 -8
  67. package/dist/generators/ts/AbstractLazyObjectType.js +19 -14
  68. package/dist/generators/ts/AbstractNamedUnionType.d.ts +33 -0
  69. package/dist/generators/ts/AbstractNamedUnionType.js +193 -0
  70. package/dist/generators/ts/AbstractNumericType.d.ts +2 -2
  71. package/dist/generators/ts/AbstractNumericType.js +3 -3
  72. package/dist/generators/ts/AbstractTermType.d.ts +7 -4
  73. package/dist/generators/ts/AbstractTermType.js +7 -4
  74. package/dist/generators/ts/AbstractType.d.ts +29 -14
  75. package/dist/generators/ts/AbstractUnionType.d.ts +80 -0
  76. package/dist/generators/ts/AbstractUnionType.js +514 -0
  77. package/dist/generators/ts/AnonymousUnionType.d.ts +26 -0
  78. package/dist/generators/ts/AnonymousUnionType.js +56 -0
  79. package/dist/generators/ts/BigDecimalType.d.ts +3 -3
  80. package/dist/generators/ts/BigDecimalType.js +3 -3
  81. package/dist/generators/ts/BlankNodeType.d.ts +1 -1
  82. package/dist/generators/ts/BlankNodeType.js +1 -1
  83. package/dist/generators/ts/BooleanType.d.ts +2 -2
  84. package/dist/generators/ts/BooleanType.js +2 -2
  85. package/dist/generators/ts/DefaultValueType.d.ts +4 -4
  86. package/dist/generators/ts/DefaultValueType.js +14 -13
  87. package/dist/generators/ts/IdentifierType.d.ts +1 -1
  88. package/dist/generators/ts/IdentifierType.js +1 -1
  89. package/dist/generators/ts/IriType.d.ts +1 -1
  90. package/dist/generators/ts/IriType.js +1 -1
  91. package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
  92. package/dist/generators/ts/LazyObjectOptionType.js +9 -9
  93. package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
  94. package/dist/generators/ts/LazyObjectSetType.js +7 -7
  95. package/dist/generators/ts/LazyObjectType.d.ts +1 -1
  96. package/dist/generators/ts/LazyObjectType.js +7 -8
  97. package/dist/generators/ts/ListType.d.ts +8 -7
  98. package/dist/generators/ts/ListType.js +14 -13
  99. package/dist/generators/ts/LiteralType.d.ts +1 -1
  100. package/dist/generators/ts/LiteralType.js +2 -2
  101. package/dist/generators/ts/NamedObjectUnionType.d.ts +35 -0
  102. package/dist/generators/ts/NamedObjectUnionType.js +221 -0
  103. package/dist/generators/ts/NamedUnionType.d.ts +11 -0
  104. package/dist/generators/ts/NamedUnionType.js +13 -0
  105. package/dist/generators/ts/ObjectType.d.ts +34 -25
  106. package/dist/generators/ts/ObjectType.js +62 -52
  107. package/dist/generators/ts/OptionType.d.ts +4 -4
  108. package/dist/generators/ts/OptionType.js +10 -10
  109. package/dist/generators/ts/SetType.d.ts +4 -4
  110. package/dist/generators/ts/SetType.js +13 -11
  111. package/dist/generators/ts/StringType.d.ts +2 -2
  112. package/dist/generators/ts/StringType.js +2 -2
  113. package/dist/generators/ts/TermType.d.ts +1 -1
  114. package/dist/generators/ts/TermType.js +2 -2
  115. package/dist/generators/ts/TsGenerator.js +23 -15
  116. package/dist/generators/ts/Type.d.ts +4 -3
  117. package/dist/generators/ts/TypeFactory.d.ts +7 -5
  118. package/dist/generators/ts/TypeFactory.js +117 -90
  119. package/dist/generators/ts/ZodGenerator.js +6 -6
  120. package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +3 -3
  121. package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.d.ts → DiscriminantProperty.d.ts} +14 -14
  122. package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.js → DiscriminantProperty.js} +10 -10
  123. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +2 -2
  124. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +2 -2
  125. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +2 -2
  126. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +7 -4
  127. package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.js +8 -8
  128. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  129. package/dist/generators/ts/_ObjectType/{ObjectType_sparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +6 -5
  130. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  131. package/dist/generators/ts/_ObjectType/{ObjectType_sparqlWherePatternsFunctionDeclarations.js → ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -5
  132. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
  133. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +20 -0
  134. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
  135. package/dist/generators/ts/_ObjectType/{ObjectType_fromRdfFunctionDeclaration.js → ObjectType_fromRdfResourceFunctionDeclaration.js} +6 -7
  136. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
  137. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +20 -0
  138. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +2 -2
  139. package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.d.ts +5 -0
  140. package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.js +19 -0
  141. package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.d.ts +5 -0
  142. package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.js +38 -0
  143. package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +5 -0
  144. package/dist/generators/ts/_ObjectType/{ObjectType_propertiesFromRdfFunctionDeclaration.js → ObjectType_propertiesFromRdfResourceFunctionDeclaration.js} +16 -15
  145. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +1 -2
  146. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
  147. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +5 -0
  148. package/dist/generators/ts/_ObjectType/{ObjectType_toRdfFunctionOrMethodDeclaration.js → ObjectType_toRdfResourceFunctionOrMethodDeclaration.js} +10 -8
  149. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  150. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +13 -0
  151. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  152. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +15 -0
  153. package/dist/generators/ts/_ObjectType/Property.d.ts +2 -2
  154. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +2 -2
  155. package/dist/generators/ts/_ObjectType/ShaclProperty.js +6 -6
  156. package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.d.ts +2 -0
  157. package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.js +12 -0
  158. package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.d.ts +2 -0
  159. package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.js +14 -0
  160. package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.d.ts +2 -0
  161. package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +15 -0
  162. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.d.ts +2 -0
  163. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +17 -0
  164. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.d.ts +2 -0
  165. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +15 -0
  166. package/dist/generators/ts/_snippets/snippets_PropertyPath.d.ts +5 -0
  167. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +35 -0
  168. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +2 -2
  169. package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.d.ts +2 -0
  170. package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.js +7 -0
  171. package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.d.ts +2 -0
  172. package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.js +16 -0
  173. package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.d.ts +2 -0
  174. package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.js +13 -0
  175. package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.d.ts +2 -0
  176. package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.js +16 -0
  177. package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +2 -2
  178. package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +2 -2
  179. package/dist/generators/ts/_snippets/snippets_booleanEquals.js +1 -1
  180. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +2 -2
  181. package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +2 -2
  182. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +2 -2
  183. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +1 -1
  184. package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +2 -2
  185. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +2 -2
  186. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
  187. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
  188. package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +2 -2
  189. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +2 -2
  190. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +2 -2
  191. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +2 -3
  192. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +2 -2
  193. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +2 -2
  194. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +4 -3
  195. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +4 -3
  196. package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +3 -2
  197. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +2 -2
  198. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
  199. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -2
  200. package/dist/generators/ts/graphqlSchemaVariableStatement.js +4 -4
  201. package/dist/generators/ts/imports.d.ts +1 -1
  202. package/dist/generators/ts/imports.js +1 -1
  203. package/dist/generators/ts/objectSetDeclarations.d.ts +3 -3
  204. package/dist/generators/ts/objectSetDeclarations.js +15 -15
  205. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +3 -3
  206. package/dist/generators/ts/objectSetInterfaceDeclaration.js +2 -2
  207. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +3 -3
  208. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +16 -17
  209. package/dist/generators/ts/snippets.d.ts +10 -6
  210. package/dist/generators/ts/snippets.js +20 -12
  211. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +3 -3
  212. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +7 -8
  213. package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +2 -2
  214. package/dist/generators/ts/synthesizeUberObjectUnionType.js +9 -4
  215. package/dist/input/NodeShape.d.ts +5 -6
  216. package/dist/input/NodeShape.js +19 -22
  217. package/dist/input/Ontology.d.ts +4 -4
  218. package/dist/input/Ontology.js +10 -10
  219. package/dist/input/PropertyShape.d.ts +4 -4
  220. package/dist/input/PropertyShape.js +10 -10
  221. package/dist/input/ShapesGraph.d.ts +3 -2
  222. package/dist/input/ShapesGraph.js +13 -8
  223. package/dist/input/generated.d.ts +2551 -2040
  224. package/dist/input/generated.js +2806 -2346
  225. package/package.json +3 -5
  226. package/dist/_ShapesGraphToAstTransformer/CurieFactory.d.ts +0 -16
  227. package/dist/_ShapesGraphToAstTransformer/CurieFactory.js +0 -45
  228. package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +0 -3
  229. package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.js +0 -2
  230. package/dist/_ShapesGraphToAstTransformer/index.d.ts +0 -6
  231. package/dist/_ShapesGraphToAstTransformer/index.js +0 -6
  232. package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.d.ts +0 -5
  233. package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.js +0 -9
  234. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +0 -11
  235. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +0 -338
  236. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.d.ts +0 -12
  237. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.js +0 -31
  238. package/dist/ast/AbstractObjectCompoundType.d.ts +0 -45
  239. package/dist/ast/AbstractObjectCompoundType.js +0 -180
  240. package/dist/ast/Curie.d.ts +0 -21
  241. package/dist/ast/Curie.js +0 -29
  242. package/dist/ast/PlaceholderType.d.ts +0 -15
  243. package/dist/ast/PlaceholderType.js +0 -19
  244. package/dist/generators/codeName.d.ts +0 -6
  245. package/dist/generators/codeName.js +0 -66
  246. package/dist/generators/ts/AbstractDeclaredType.d.ts +0 -23
  247. package/dist/generators/ts/AbstractDeclaredType.js +0 -17
  248. package/dist/generators/ts/ObjectUnionType.d.ts +0 -65
  249. package/dist/generators/ts/ObjectUnionType.js +0 -257
  250. package/dist/generators/ts/UnionType.d.ts +0 -40
  251. package/dist/generators/ts/UnionType.js +0 -527
  252. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.d.ts +0 -4
  253. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.js +0 -66
  254. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.d.ts +0 -5
  255. package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.d.ts +0 -5
  256. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  257. package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts +0 -5
  258. package/dist/generators/ts/_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.d.ts +0 -5
  259. package/dist/generators/ts/_ObjectUnionType/MemberType.d.ts +0 -34
  260. package/dist/generators/ts/_ObjectUnionType/MemberType.js +0 -105
  261. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.d.ts +0 -5
  262. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.js +0 -29
  263. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.d.ts +0 -4
  264. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.js +0 -19
  265. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.d.ts +0 -4
  266. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.js +0 -10
  267. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.d.ts +0 -5
  268. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js +0 -19
  269. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.d.ts +0 -5
  270. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js +0 -20
  271. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.d.ts +0 -5
  272. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.js +0 -18
  273. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.d.ts +0 -5
  274. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.js +0 -28
  275. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.d.ts +0 -4
  276. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.js +0 -9
  277. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.d.ts +0 -5
  278. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.js +0 -13
  279. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.d.ts +0 -5
  280. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js +0 -10
  281. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
  282. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js +0 -14
  283. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.d.ts +0 -4
  284. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.js +0 -37
  285. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  286. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js +0 -15
  287. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  288. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js +0 -35
  289. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.d.ts +0 -5
  290. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js +0 -26
  291. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.d.ts +0 -5
  292. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.js +0 -43
  293. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.d.ts +0 -4
  294. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.js +0 -10
  295. package/dist/generators/ts/_snippets/snippets_FromRdfOptions.d.ts +0 -2
  296. package/dist/generators/ts/_snippets/snippets_FromRdfOptions.js +0 -5
  297. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.d.ts +0 -2
  298. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.js +0 -5
  299. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.d.ts +0 -2
  300. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.js +0 -6
  301. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.d.ts +0 -2
  302. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.js +0 -12
  303. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.d.ts +0 -2
  304. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.js +0 -6
  305. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.d.ts +0 -2
  306. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.js +0 -15
@@ -4,10 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { code } from "ts-poet";
8
7
  import { Memoize } from "typescript-memoize";
9
8
  import { AbstractTermType } from "./AbstractTermType.js";
10
9
  import { imports } from "./imports.js";
10
+ import { code } from "./ts-poet-wrapper.js";
11
11
  export class AbstractIdentifierType extends AbstractTermType {
12
12
  graphqlType = new AbstractTermType.GraphqlType(code `${imports.GraphQLString}`);
13
13
  toStringFunction = // Re-export rdfjsResource.Resource.Identifier.toString
@@ -1,7 +1,7 @@
1
1
  import { Maybe, NonEmptyList } from "purify-ts";
2
2
  import { AbstractType } from "./AbstractType.js";
3
+ import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
3
4
  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";
@@ -13,6 +13,8 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
13
13
  readonly partialPropertyName: string;
14
14
  readonly rawName: Code;
15
15
  };
16
+ readonly abstract = false;
17
+ readonly declaration: Maybe<Code>;
16
18
  readonly discriminantProperty: AbstractType["discriminantProperty"];
17
19
  readonly mutable = false;
18
20
  readonly typeofs: NonEmptyList<"object">;
@@ -27,10 +29,11 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
27
29
  get filterType(): Code;
28
30
  get graphqlType(): AbstractType.GraphqlType;
29
31
  get name(): Code;
32
+ get recursive(): boolean;
30
33
  get schema(): Code;
31
34
  get schemaType(): Code;
32
- get sparqlConstructTriplesFunction(): Code;
33
- get sparqlWherePatternsFunction(): Code;
35
+ get valueSparqlConstructTriplesFunction(): Code;
36
+ get valueSparqlWherePatternsFunction(): Code;
34
37
  protected get schemaObject(): {
35
38
  partial: Code;
36
39
  kind: Code;
@@ -40,17 +43,17 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
40
43
  jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
41
44
  jsonZodSchema(parameters: Parameters<AbstractType["jsonZodSchema"]>[0]): Code;
42
45
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
43
- toRdfExpression({ variables, }: Parameters<AbstractType["toRdfExpression"]>[0]): Code;
44
- protected resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }: {
45
- resolvedObjectUnionType: ObjectUnionType;
46
- partialObjectUnionType: ObjectUnionType;
46
+ toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
47
+ protected resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }: {
48
+ resolvedNamedObjectUnionType: NamedObjectUnionType;
49
+ partialNamedObjectUnionType: NamedObjectUnionType;
47
50
  variables: {
48
51
  resolvedObjectUnion: Code;
49
52
  };
50
53
  }): Code;
51
54
  }
52
55
  export declare namespace AbstractLazyObjectType {
53
- type ObjectTypeConstraint = ObjectType | ObjectUnionType;
56
+ type ObjectTypeConstraint = ObjectType | NamedObjectUnionType;
54
57
  type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
55
58
  type ResolveTypeConstraint = PartialTypeConstraint;
56
59
  type Conversion = AbstractType.Conversion;
@@ -14,6 +14,8 @@ export class AbstractLazyObjectType extends AbstractType {
14
14
  partialType;
15
15
  resolveType;
16
16
  runtimeClass;
17
+ abstract = false;
18
+ declaration = Maybe.empty();
17
19
  discriminantProperty = Maybe.empty();
18
20
  mutable = false;
19
21
  typeofs = NonEmptyList(["object"]);
@@ -48,6 +50,9 @@ export class AbstractLazyObjectType extends AbstractType {
48
50
  get name() {
49
51
  return this.runtimeClass.name;
50
52
  }
53
+ get recursive() {
54
+ return this.partialType.recursive;
55
+ }
51
56
  get schema() {
52
57
  return code `${removeUndefined(this.schemaObject)}`;
53
58
  }
@@ -58,11 +63,11 @@ export class AbstractLazyObjectType extends AbstractType {
58
63
  resolveType: this.resolveType.schemaType,
59
64
  }}`;
60
65
  }
61
- get sparqlConstructTriplesFunction() {
62
- return code `(({ schema, ...otherParameters }) => ${this.partialType.sparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.partial() }))`;
66
+ get valueSparqlConstructTriplesFunction() {
67
+ return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.partial() }))`;
63
68
  }
64
- get sparqlWherePatternsFunction() {
65
- return code `(({ schema, ...otherParameters }) => ${this.partialType.sparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partial() }))`;
69
+ get valueSparqlWherePatternsFunction() {
70
+ return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partial() }))`;
66
71
  }
67
72
  get schemaObject() {
68
73
  return {
@@ -97,22 +102,22 @@ export class AbstractLazyObjectType extends AbstractType {
97
102
  },
98
103
  });
99
104
  }
100
- toRdfExpression({ variables, }) {
101
- return this.partialType.toRdfExpression({
105
+ toRdfResourceValuesExpression({ variables, }) {
106
+ return this.partialType.toRdfResourceValuesExpression({
102
107
  variables: {
103
108
  ...variables,
104
109
  value: code `${variables.value}.${this.runtimeClass.partialPropertyName}`,
105
110
  },
106
111
  });
107
112
  }
108
- resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }) {
109
- invariant(resolvedObjectUnionType.memberTypes.length ===
110
- partialObjectUnionType.memberTypes.length);
111
- const caseBlocks = resolvedObjectUnionType.memberTypes.map((resolvedObjectType, objectTypeI) => {
112
- return code `${resolvedObjectType.discriminantPropertyValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialObjectUnionType.memberTypes[objectTypeI].newExpression({ parameters: variables.resolvedObjectUnion })};`;
113
+ resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }) {
114
+ invariant(resolvedNamedObjectUnionType.members.length ===
115
+ partialNamedObjectUnionType.members.length);
116
+ const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
117
+ return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.newExpression({ parameters: variables.resolvedObjectUnion })};`;
113
118
  });
114
119
  caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
115
- return code `switch (${variables.resolvedObjectUnion}.${resolvedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
120
+ return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
116
121
  }
117
122
  }
118
123
  __decorate([
@@ -129,10 +134,10 @@ __decorate([
129
134
  ], AbstractLazyObjectType.prototype, "schemaType", null);
130
135
  __decorate([
131
136
  Memoize()
132
- ], AbstractLazyObjectType.prototype, "sparqlConstructTriplesFunction", null);
137
+ ], AbstractLazyObjectType.prototype, "valueSparqlConstructTriplesFunction", null);
133
138
  __decorate([
134
139
  Memoize()
135
- ], AbstractLazyObjectType.prototype, "sparqlWherePatternsFunction", null);
140
+ ], AbstractLazyObjectType.prototype, "valueSparqlWherePatternsFunction", null);
136
141
  (function (AbstractLazyObjectType) {
137
142
  AbstractLazyObjectType.GraphqlType = AbstractType.GraphqlType;
138
143
  AbstractLazyObjectType.JsonType = AbstractType.JsonType;
@@ -0,0 +1,33 @@
1
+ import { Maybe } from "purify-ts";
2
+ import type { TsFeature } from "../../enums/TsFeature.js";
3
+ import { AbstractType } from "./AbstractType.js";
4
+ import { AbstractUnionType } from "./AbstractUnionType.js";
5
+ import type { Type } from "./Type.js";
6
+ import { type Code } from "./ts-poet-wrapper.js";
7
+ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> extends AbstractUnionType<MemberTypeT> {
8
+ protected readonly _name: string;
9
+ readonly features: ReadonlySet<TsFeature>;
10
+ constructor({ features, name, ...superParameters }: {
11
+ features: ReadonlySet<TsFeature>;
12
+ name: string;
13
+ } & ConstructorParameters<typeof AbstractUnionType<MemberTypeT>>[0]);
14
+ get declaration(): Maybe<Code>;
15
+ get equalsFunction(): Code;
16
+ get filterFunction(): Code;
17
+ get filterType(): Code;
18
+ get jsonTypeAliasDeclaration(): Code;
19
+ get jsonZodSchemaFunctionDeclaration(): Code;
20
+ get name(): string;
21
+ get staticModuleName(): string;
22
+ get valueSparqlConstructTriplesFunction(): Code;
23
+ get valueSparqlWherePatternsFunction(): Code;
24
+ protected get staticModuleDeclarations(): Record<string, Code>;
25
+ fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
26
+ fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
27
+ hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
28
+ jsonType(): AbstractType.JsonType;
29
+ jsonZodSchema({ context, }: Parameters<AbstractType["jsonZodSchema"]>[0]): Code;
30
+ toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
31
+ toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
32
+ }
33
+ //# sourceMappingURL=AbstractNamedUnionType.d.ts.map
@@ -0,0 +1,193 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { Maybe } from "purify-ts";
8
+ import { Memoize } from "typescript-memoize";
9
+ import { AbstractType } from "./AbstractType.js";
10
+ import { AbstractUnionType } from "./AbstractUnionType.js";
11
+ import { imports } from "./imports.js";
12
+ import { snippets } from "./snippets.js";
13
+ import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
14
+ import { code, def, joinCode } from "./ts-poet-wrapper.js";
15
+ export class AbstractNamedUnionType extends AbstractUnionType {
16
+ _name;
17
+ features;
18
+ constructor({ features, name, ...superParameters }) {
19
+ super(superParameters);
20
+ this.features = features;
21
+ this._name = name;
22
+ }
23
+ get declaration() {
24
+ const declarations = [
25
+ code `export type ${def(this._name)} = ${this.inlineName};`,
26
+ ];
27
+ const staticModuleDeclarations = Object.entries(this.staticModuleDeclarations);
28
+ if (staticModuleDeclarations.length > 0) {
29
+ declarations.push(code `\
30
+ export namespace ${def(this.staticModuleName)} {
31
+ ${joinCode(staticModuleDeclarations
32
+ .sort((left, right) => left[0].localeCompare(right[0]))
33
+ .map((_) => _[1]), { on: "\n\n" })}
34
+ }`);
35
+ }
36
+ return Maybe.of(joinCode(declarations, { on: "\n\n" }));
37
+ }
38
+ get equalsFunction() {
39
+ if (this.features.has("equals")) {
40
+ return code `${this.staticModuleName}.${syntheticNamePrefix}equals`;
41
+ }
42
+ return this.inlineEqualsFunction;
43
+ }
44
+ get filterFunction() {
45
+ return code `${this.staticModuleName}.${syntheticNamePrefix}filter`;
46
+ }
47
+ get filterType() {
48
+ return code `${this.staticModuleName}.${syntheticNamePrefix}Filter`;
49
+ }
50
+ get jsonTypeAliasDeclaration() {
51
+ return code `export type ${syntheticNamePrefix}Json = ${this.inlineJsonType.name}`;
52
+ }
53
+ get jsonZodSchemaFunctionDeclaration() {
54
+ return code `export const ${syntheticNamePrefix}jsonZodSchema = () => ${this.inlineJsonZodSchema};`;
55
+ }
56
+ get name() {
57
+ return this._name;
58
+ }
59
+ get staticModuleName() {
60
+ return this._name;
61
+ }
62
+ get valueSparqlConstructTriplesFunction() {
63
+ if (this.features.has("sparql")) {
64
+ return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlConstructTriples`;
65
+ }
66
+ return this.inlineValueSparqlConstructTriplesFunction;
67
+ }
68
+ get valueSparqlWherePatternsFunction() {
69
+ if (this.features.has("sparql")) {
70
+ return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlWherePatterns`;
71
+ }
72
+ return this.inlineValueSparqlWherePatternsFunction;
73
+ }
74
+ get staticModuleDeclarations() {
75
+ const staticModuleDeclarations = {};
76
+ if (this.features.has("equals")) {
77
+ staticModuleDeclarations[`${syntheticNamePrefix}equals`] =
78
+ code `export const ${syntheticNamePrefix}equals = ${this.inlineEqualsFunction};`;
79
+ }
80
+ staticModuleDeclarations[`${syntheticNamePrefix}Filter`] =
81
+ code `export type ${syntheticNamePrefix}Filter = ${this.inlineFilterType};`;
82
+ staticModuleDeclarations[`${syntheticNamePrefix}filter`] =
83
+ code `export const ${syntheticNamePrefix}filter = ${this.inlineFilterFunction};`;
84
+ if (this.features.has("hash")) {
85
+ staticModuleDeclarations[`${syntheticNamePrefix}hash`] =
86
+ code `export function ${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(value: ${this._name}, hasher: HasherT): HasherT { ${this.inlineHashStatements({ depth: 0, variables: { hasher: code `hasher`, value: code `value` } })} return hasher; }`;
87
+ }
88
+ if (this.features.has("json")) {
89
+ staticModuleDeclarations[`${syntheticNamePrefix}Json`] =
90
+ this.jsonTypeAliasDeclaration;
91
+ staticModuleDeclarations[`${syntheticNamePrefix}fromJson`] =
92
+ code `export const ${syntheticNamePrefix}fromJson = ${this.inlineFromJsonFunction};`;
93
+ staticModuleDeclarations[`${syntheticNamePrefix}jsonZodSchema`] =
94
+ this.jsonZodSchemaFunctionDeclaration;
95
+ staticModuleDeclarations[`${syntheticNamePrefix}parseJson`] = code `\
96
+ export function ${syntheticNamePrefix}parseJson(json: unknown): ${imports.Either}<Error, ${this.name}> {
97
+ const ${syntheticNamePrefix}jsonSafeParseResult = ${syntheticNamePrefix}jsonZodSchema().safeParse(json);
98
+ if (!${syntheticNamePrefix}jsonSafeParseResult.success) { return ${imports.Left}(${syntheticNamePrefix}jsonSafeParseResult.error); }
99
+ return ${imports.Right}(${syntheticNamePrefix}fromJson(${syntheticNamePrefix}jsonSafeParseResult.data));
100
+ }`;
101
+ staticModuleDeclarations[`${syntheticNamePrefix}toJson`] =
102
+ code `export const ${syntheticNamePrefix}toJson = ${this.inlineToJsonFunction};`;
103
+ }
104
+ if (this.features.has("rdf")) {
105
+ staticModuleDeclarations[`${syntheticNamePrefix}fromRdfResourceValues`] =
106
+ code `export const ${syntheticNamePrefix}fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${this.name}> = ${this.inlineFromRdfResourceValuesFunction};`;
107
+ staticModuleDeclarations[`${syntheticNamePrefix}toRdfResourceValues`] =
108
+ code `export const ${syntheticNamePrefix}toRdfResourceValues: ${snippets.ToRdfResourceValuesFunction}<${this.name}> = ${this.inlineToRdfResourceValuesFunction};`;
109
+ }
110
+ if (this.features.has("sparql")) {
111
+ staticModuleDeclarations[`${syntheticNamePrefix}valueSparqlConstructTriples`] =
112
+ code `export const ${syntheticNamePrefix}valueSparqlConstructTriples: ${snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
113
+ staticModuleDeclarations[`${syntheticNamePrefix}valueSparqlWherePatterns`] =
114
+ code `export const ${syntheticNamePrefix}valueSparqlWherePatterns: ${snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
115
+ }
116
+ return staticModuleDeclarations;
117
+ }
118
+ fromJsonExpression({ variables, }) {
119
+ if (this.features.has("json")) {
120
+ return code `${this.staticModuleName}.${syntheticNamePrefix}fromJson(${variables.value})`;
121
+ }
122
+ return code `${this.inlineFromJsonFunction}(${variables.value})`;
123
+ }
124
+ fromRdfResourceValuesExpression({ variables, }) {
125
+ const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
126
+ if (this.features.has("rdf")) {
127
+ return code `${this.staticModuleName}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
128
+ }
129
+ return code `${this.inlineFromRdfResourceValuesFunction}(${resourceValuesVariable}, ${otherVariables})`;
130
+ }
131
+ hashStatements({ depth, variables, }) {
132
+ if (this.features.has("hash")) {
133
+ return [
134
+ code `${this.staticModuleName}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
135
+ ];
136
+ }
137
+ return this.inlineHashStatements({ depth, variables });
138
+ }
139
+ jsonType() {
140
+ if (this.features.has("json")) {
141
+ return new AbstractType.JsonType(`${this.staticModuleName}.${syntheticNamePrefix}Json`);
142
+ }
143
+ return this.inlineJsonType;
144
+ }
145
+ jsonZodSchema({ context, }) {
146
+ if (this.features.has("json")) {
147
+ const expression = code `${this.staticModuleName}.${syntheticNamePrefix}jsonZodSchema()`;
148
+ if (context === "property" && this.recursive) {
149
+ return code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.staticModuleName}.${syntheticNamePrefix}Json> => ${expression})`;
150
+ }
151
+ return expression;
152
+ }
153
+ return this.inlineJsonZodSchema;
154
+ }
155
+ toJsonExpression({ variables, }) {
156
+ if (this.features.has("json")) {
157
+ return code `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
158
+ }
159
+ return code `${this.inlineToJsonFunction}(${variables.value})`;
160
+ }
161
+ toRdfResourceValuesExpression({ variables, }) {
162
+ const { value: valueVariable, ...otherVariables } = variables;
163
+ if (this.features.has("rdf")) {
164
+ return code `${this.staticModuleName}.${syntheticNamePrefix}toRdfResourceValues(${valueVariable}, ${otherVariables})`;
165
+ }
166
+ return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
167
+ }
168
+ }
169
+ __decorate([
170
+ Memoize()
171
+ ], AbstractNamedUnionType.prototype, "declaration", null);
172
+ __decorate([
173
+ Memoize()
174
+ ], AbstractNamedUnionType.prototype, "equalsFunction", null);
175
+ __decorate([
176
+ Memoize()
177
+ ], AbstractNamedUnionType.prototype, "filterFunction", null);
178
+ __decorate([
179
+ Memoize()
180
+ ], AbstractNamedUnionType.prototype, "filterType", null);
181
+ __decorate([
182
+ Memoize()
183
+ ], AbstractNamedUnionType.prototype, "name", null);
184
+ __decorate([
185
+ Memoize()
186
+ ], AbstractNamedUnionType.prototype, "valueSparqlConstructTriplesFunction", null);
187
+ __decorate([
188
+ Memoize()
189
+ ], AbstractNamedUnionType.prototype, "valueSparqlWherePatternsFunction", null);
190
+ __decorate([
191
+ Memoize()
192
+ ], AbstractNamedUnionType.prototype, "jsonType", null);
193
+ //# sourceMappingURL=AbstractNamedUnionType.js.map
@@ -9,14 +9,14 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
9
9
  get filterType(): Code;
10
10
  get name(): string;
11
11
  get schemaType(): Code;
12
- get sparqlWherePatternsFunction(): Code;
12
+ get valueSparqlWherePatternsFunction(): Code;
13
13
  protected get schemaObject(): {
14
14
  in: Code[] | undefined;
15
15
  languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
16
16
  kind: Code;
17
17
  };
18
18
  jsonZodSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonZodSchema"]>[0]): Code;
19
- toRdfExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfExpression"]>[0]): Code;
19
+ toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
20
20
  protected fromRdfExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>;
21
21
  protected abstract fromRdfResourceValueExpression(variables: {
22
22
  variables: {
@@ -29,7 +29,7 @@ export class AbstractNumericType extends AbstractPrimitiveType {
29
29
  get schemaType() {
30
30
  return code `${snippets.NumericSchema}<${this.typeofs[0]}>`;
31
31
  }
32
- get sparqlWherePatternsFunction() {
32
+ get valueSparqlWherePatternsFunction() {
33
33
  return code `${snippets.numericSparqlWherePatterns}<${this.typeofs[0]}>`;
34
34
  }
35
35
  get schemaObject() {
@@ -50,7 +50,7 @@ export class AbstractNumericType extends AbstractPrimitiveType {
50
50
  return code `${imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${imports.z}.literal(${this.literalOf(value)})`), { on: "," })}])`;
51
51
  }
52
52
  }
53
- toRdfExpression({ variables, }) {
53
+ toRdfResourceValuesExpression({ variables, }) {
54
54
  return code `[${snippets.literalFactory}.${this.typeofs[0]}(${variables.value}, ${rdfjsTermExpression(this.datatype)})]`;
55
55
  }
56
56
  fromRdfExpressionChain({ variables, }) {
@@ -78,7 +78,7 @@ __decorate([
78
78
  ], AbstractNumericType.prototype, "schemaType", null);
79
79
  __decorate([
80
80
  Memoize()
81
- ], AbstractNumericType.prototype, "sparqlWherePatternsFunction", null);
81
+ ], AbstractNumericType.prototype, "valueSparqlWherePatternsFunction", null);
82
82
  (function (AbstractNumericType) {
83
83
  AbstractNumericType.JsonType = AbstractPrimitiveType.JsonType;
84
84
  })(AbstractNumericType || (AbstractNumericType = {}));
@@ -13,12 +13,15 @@ import { type Code } from "./ts-poet-wrapper.js";
13
13
  * The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
14
14
  */
15
15
  export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends AbstractType {
16
+ readonly abstract = false;
17
+ readonly declaration: Maybe<Code>;
16
18
  readonly equalsFunction: Code;
17
19
  readonly graphqlArgs: AbstractType["graphqlArgs"];
18
20
  readonly hasValues: readonly ConstantTermT[];
19
21
  readonly in_: readonly ConstantTermT[];
20
22
  readonly mutable: boolean;
21
23
  abstract readonly nodeKinds: ReadonlySet<NodeKind>;
24
+ readonly recursive = false;
22
25
  readonly typeofs: AbstractType["typeofs"];
23
26
  constructor({ hasValues, in_, ...superParameters }: {
24
27
  hasValues: readonly ConstantTermT[];
@@ -28,11 +31,11 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
28
31
  get conversions(): readonly AbstractType.Conversion[];
29
32
  get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
30
33
  get schema(): Code;
31
- get sparqlConstructTriplesFunction(): Code;
32
- fromRdfExpression(parameters: Parameters<AbstractType["fromRdfExpression"]>[0]): Code;
34
+ get valueSparqlConstructTriplesFunction(): Code;
35
+ fromRdfResourceValuesExpression(parameters: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
33
36
  hashStatements({ variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
34
37
  jsonUiSchemaElement(): Maybe<Code>;
35
- toRdfExpression({ variables, }: Parameters<AbstractType["toRdfExpression"]>[0]): Code;
38
+ toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
36
39
  /**
37
40
  * The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
38
41
  *
@@ -42,7 +45,7 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
42
45
  *
43
46
  * Considering the sub-expressions as a record instead of an array allows them to be selectively overridden by subclasses.
44
47
  */
45
- protected fromRdfExpressionChain({ variables, }: Parameters<Type["fromRdfExpression"]>[0]): {
48
+ protected fromRdfExpressionChain({ variables, }: Parameters<Type["fromRdfResourceValuesExpression"]>[0]): {
46
49
  hasValues?: Code;
47
50
  languageIn?: Code;
48
51
  preferredLanguages?: Code;
@@ -22,11 +22,14 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
22
22
  * The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
23
23
  */
24
24
  export class AbstractTermType extends AbstractType {
25
+ abstract = false;
26
+ declaration = Maybe.empty();
25
27
  equalsFunction = code `${snippets.booleanEquals}`;
26
28
  graphqlArgs = Maybe.empty();
27
29
  hasValues;
28
30
  in_;
29
31
  mutable = false;
32
+ recursive = false;
30
33
  typeofs = NonEmptyList([
31
34
  "object",
32
35
  ]);
@@ -87,10 +90,10 @@ export class AbstractTermType extends AbstractType {
87
90
  get schema() {
88
91
  return code `${removeUndefined(this.schemaObject)}`;
89
92
  }
90
- get sparqlConstructTriplesFunction() {
93
+ get valueSparqlConstructTriplesFunction() {
91
94
  return code `((_: object) => [])`;
92
95
  }
93
- fromRdfExpression(parameters) {
96
+ fromRdfResourceValuesExpression(parameters) {
94
97
  // invariant(
95
98
  // this.nodeKinds.has("Literal") &&
96
99
  // (this.nodeKinds.has("BlankNode") || this.nodeKinds.has("NamedNode")),
@@ -115,7 +118,7 @@ export class AbstractTermType extends AbstractType {
115
118
  jsonUiSchemaElement() {
116
119
  return Maybe.empty();
117
120
  }
118
- toRdfExpression({ variables, }) {
121
+ toRdfResourceValuesExpression({ variables, }) {
119
122
  return code `[${variables.value}]`;
120
123
  }
121
124
  /**
@@ -163,7 +166,7 @@ __decorate([
163
166
  ], AbstractTermType.prototype, "schema", null);
164
167
  __decorate([
165
168
  Memoize()
166
- ], AbstractTermType.prototype, "sparqlConstructTriplesFunction", null);
169
+ ], AbstractTermType.prototype, "valueSparqlConstructTriplesFunction", null);
167
170
  (function (AbstractTermType) {
168
171
  AbstractTermType.GraphqlType = AbstractType.GraphqlType;
169
172
  AbstractTermType.JsonType = AbstractType.JsonType;
@@ -5,6 +5,10 @@ import { type Code } from "./ts-poet-wrapper.js";
5
5
  * Abstract base class all types.
6
6
  */
7
7
  export declare abstract class AbstractType {
8
+ /**
9
+ * Is the type abstract?
10
+ */
11
+ abstract readonly abstract: boolean;
8
12
  /**
9
13
  * Comment from rdfs:comment.
10
14
  */
@@ -13,6 +17,10 @@ export declare abstract class AbstractType {
13
17
  * Expressions that convert a source type or types to this type. It should include the type itself.
14
18
  */
15
19
  abstract readonly conversions: readonly AbstractType.Conversion[];
20
+ /**
21
+ * The declaration of named types.
22
+ */
23
+ abstract readonly declaration: Maybe<Code>;
16
24
  /**
17
25
  * A property that discriminates sub-types of this type e.g., termType on RDF/JS terms.
18
26
  */
@@ -57,6 +65,10 @@ export declare abstract class AbstractType {
57
65
  * TypeScript name of the type.
58
66
  */
59
67
  abstract readonly name: Code | string;
68
+ /**
69
+ * Does this type directly or indirectly reference itself?
70
+ */
71
+ abstract readonly recursive: boolean;
60
72
  /**
61
73
  * TypeScript object describing this type, for runtime use.
62
74
  */
@@ -66,20 +78,24 @@ export declare abstract class AbstractType {
66
78
  */
67
79
  abstract readonly schemaType: Code;
68
80
  /**
69
- * A SparqlConstructTriplesFunction (reference or declaration) that returns an array of sparqljs.Triple's for a property of this type.
81
+ * JavaScript typeof(s) the type.
82
+ */
83
+ abstract readonly typeofs: NonEmptyList<Typeof>;
84
+ /**
85
+ * A ValueSparqlConstructTriplesFunction (reference or declaration) that returns an array of sparqljs.Triple's for a property value of this type.
70
86
  *
71
- * The function takes a parameters object (type: SparqlConstructTriplesFunctionParameters) with the following parameters:
87
+ * The function takes a parameters object with the following parameters:
72
88
  * - filter: an instance of filterType | undefined
73
89
  * - ignoreRdfType: boolean
74
90
  * - schema: instance of this.schemaType
75
91
  * - valueVariable: rdfjs.Variable of the value of this type
76
92
  * - variablePrefix: string prefix to use for new variables
77
93
  */
78
- abstract readonly sparqlConstructTriplesFunction: Code;
94
+ abstract readonly valueSparqlConstructTriplesFunction: Code;
79
95
  /**
80
- * A SparqlWherePatternsFunction (reference or declaration) that returns an array of SparqlPattern's for a property of this type.
96
+ * A ValueSparqlWherePatternsFunction (reference or declaration) that returns an array of SparqlPattern's for a property value of this type.
81
97
  *
82
- * The function takes a parameters object (type: SparqlWherePatternsFunctionParameters) with the following parameters:
98
+ * The function takes a parameters object with the following parameters:
83
99
  * - filter: an instance of filterType | undefined
84
100
  * - preferredLanguages: array of preferred language code (strings) | undefined
85
101
  * - propertyPatterns: array of sparqljs.Pattern's for the property; may be empty
@@ -87,11 +103,7 @@ export declare abstract class AbstractType {
87
103
  * - valueVariable: rdfjs.Variable of the value of this type
88
104
  * - variablePrefix: string prefix to use for new variables
89
105
  */
90
- abstract readonly sparqlWherePatternsFunction: Code;
91
- /**
92
- * JavaScript typeof(s) the type.
93
- */
94
- abstract readonly typeofs: NonEmptyList<Typeof>;
106
+ abstract readonly valueSparqlWherePatternsFunction: Code;
95
107
  constructor({ comment, label, }: {
96
108
  comment: Maybe<string>;
97
109
  label: Maybe<string>;
@@ -134,7 +146,7 @@ export declare abstract class AbstractType {
134
146
  * resource: the Resource passed to Object.fromRdf
135
147
  * resourceValues: the Either<Error, rdfjsResource.Resource.Values> to be converted to values of this type
136
148
  */
137
- abstract fromRdfExpression(parameters: {
149
+ abstract fromRdfResourceValuesExpression(parameters: {
138
150
  variables: {
139
151
  context: Code;
140
152
  graph: Code;
@@ -213,7 +225,7 @@ export declare abstract class AbstractType {
213
225
  * resourceSet: ResourceSet for any new Resources needed while conversion (of e.g., nested objects)
214
226
  * value: value of this type, to be converted to (BlankNode | Literal | NamedNode | bigint | boolean | number | string) or an array of the same
215
227
  */
216
- abstract toRdfExpression(parameters: {
228
+ abstract toRdfResourceValuesExpression(parameters: {
217
229
  variables: {
218
230
  graph: Code;
219
231
  propertyPath: Code;
@@ -231,9 +243,12 @@ export declare namespace AbstractType {
231
243
  readonly sourceTypeof: Typeof;
232
244
  }
233
245
  interface DiscriminantProperty {
246
+ readonly descendantValues: readonly DiscriminantProperty.Value[];
234
247
  readonly name: string;
235
- readonly ownValues: readonly string[];
236
- readonly descendantValues: readonly string[];
248
+ readonly ownValues: readonly DiscriminantProperty.Value[];
249
+ }
250
+ namespace DiscriminantProperty {
251
+ type Value = number | string;
237
252
  }
238
253
  class GraphqlType {
239
254
  /**