@shaclmate/compiler 3.0.4 → 4.0.0

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 (581) hide show
  1. package/dist/Compiler.d.ts +2 -3
  2. package/dist/Compiler.js +5 -8
  3. package/dist/Eithers.d.ts +14 -0
  4. package/dist/Eithers.js +67 -0
  5. package/dist/ShapesGraphToAstTransformer.d.ts +3 -8
  6. package/dist/ShapesGraphToAstTransformer.js +22 -23
  7. package/dist/_ShapesGraphToAstTransformer/CurieFactory.d.ts +16 -0
  8. package/dist/_ShapesGraphToAstTransformer/CurieFactory.js +45 -0
  9. package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +1 -1
  10. package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +1 -2
  11. package/dist/_ShapesGraphToAstTransformer/index.d.ts +1 -5
  12. package/dist/_ShapesGraphToAstTransformer/index.js +1 -5
  13. package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.d.ts +5 -0
  14. package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.js +28 -0
  15. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +5 -0
  16. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +8 -0
  17. package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.d.ts +5 -0
  18. package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.js +9 -0
  19. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.d.ts +8 -0
  20. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +175 -0
  21. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +3 -3
  22. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +302 -231
  23. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +6 -3
  24. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +168 -170
  25. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.d.ts +12 -0
  26. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.js +31 -0
  27. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.d.ts +10 -0
  28. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +141 -0
  29. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +5 -5
  30. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +92 -11
  31. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +3 -3
  32. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +8 -4
  33. package/dist/ast/AbstractCollectionType.d.ts +20 -0
  34. package/dist/ast/AbstractCollectionType.js +27 -0
  35. package/dist/ast/AbstractCompoundType.d.ts +23 -0
  36. package/dist/ast/AbstractCompoundType.js +39 -0
  37. package/dist/ast/AbstractContainerType.d.ts +36 -0
  38. package/dist/ast/AbstractContainerType.js +58 -0
  39. package/dist/ast/AbstractLazyObjectType.d.ts +25 -0
  40. package/dist/ast/AbstractLazyObjectType.js +30 -0
  41. package/dist/ast/AbstractObjectCompoundType.d.ts +45 -0
  42. package/dist/ast/AbstractObjectCompoundType.js +180 -0
  43. package/dist/ast/AbstractTermType.d.ts +24 -0
  44. package/dist/ast/AbstractTermType.js +41 -0
  45. package/dist/ast/AbstractType.d.ts +21 -0
  46. package/dist/ast/AbstractType.js +29 -0
  47. package/dist/ast/BlankNodeType.d.ts +11 -0
  48. package/dist/ast/BlankNodeType.js +17 -0
  49. package/dist/ast/Curie.d.ts +10 -3
  50. package/dist/ast/Curie.js +14 -6
  51. package/dist/ast/DefaultValueType.d.ts +26 -0
  52. package/dist/ast/DefaultValueType.js +41 -0
  53. package/dist/ast/IdentifierType.d.ts +5 -4
  54. package/dist/ast/IdentifierType.js +19 -1
  55. package/dist/ast/IntersectionType.d.ts +3 -3
  56. package/dist/ast/IntersectionType.js +7 -1
  57. package/dist/ast/IriType.d.ts +10 -0
  58. package/dist/ast/IriType.js +10 -0
  59. package/dist/ast/LazyObjectOptionType.d.ts +6 -0
  60. package/dist/ast/LazyObjectOptionType.js +5 -0
  61. package/dist/ast/LazyObjectSetType.d.ts +6 -0
  62. package/dist/ast/LazyObjectSetType.js +5 -0
  63. package/dist/ast/LazyObjectType.d.ts +5 -0
  64. package/dist/ast/LazyObjectType.js +5 -0
  65. package/dist/ast/ListType.d.ts +28 -24
  66. package/dist/ast/ListType.js +68 -1
  67. package/dist/ast/LiteralType.d.ts +13 -4
  68. package/dist/ast/LiteralType.js +24 -1
  69. package/dist/ast/ObjectIntersectionType.d.ts +3 -3
  70. package/dist/ast/ObjectIntersectionType.js +7 -1
  71. package/dist/ast/ObjectType.d.ts +79 -72
  72. package/dist/ast/ObjectType.js +402 -9
  73. package/dist/ast/ObjectUnionType.d.ts +3 -3
  74. package/dist/ast/ObjectUnionType.js +7 -1
  75. package/dist/ast/OptionType.d.ts +9 -4
  76. package/dist/ast/OptionType.js +17 -1
  77. package/dist/ast/PlaceholderType.d.ts +10 -2
  78. package/dist/ast/PlaceholderType.js +18 -1
  79. package/dist/ast/SetType.d.ts +12 -9
  80. package/dist/ast/SetType.js +32 -1
  81. package/dist/ast/TermType.d.ts +8 -13
  82. package/dist/ast/TermType.js +15 -1
  83. package/dist/ast/Type.d.ts +10 -4
  84. package/dist/ast/Type.js +47 -1
  85. package/dist/ast/UnionType.d.ts +7 -3
  86. package/dist/ast/UnionType.js +12 -1
  87. package/dist/ast/equals.d.ts +12 -0
  88. package/dist/ast/equals.js +65 -0
  89. package/dist/ast/index.d.ts +10 -2
  90. package/dist/ast/index.js +10 -2
  91. package/dist/generators/json/AstJsonGenerator.js +53 -49
  92. package/dist/generators/ts/AbstractCollectionType.d.ts +47 -0
  93. package/dist/generators/ts/AbstractCollectionType.js +235 -0
  94. package/dist/generators/ts/AbstractContainerType.d.ts +51 -0
  95. package/dist/generators/ts/AbstractContainerType.js +72 -0
  96. package/dist/generators/ts/AbstractDateType.d.ts +31 -0
  97. package/dist/generators/ts/AbstractDateType.js +71 -0
  98. package/dist/generators/ts/AbstractDeclaredType.d.ts +23 -0
  99. package/dist/generators/ts/AbstractDeclaredType.js +17 -0
  100. package/dist/generators/ts/AbstractIdentifierType.d.ts +14 -0
  101. package/dist/generators/ts/AbstractIdentifierType.js +38 -0
  102. package/dist/generators/ts/AbstractLazyObjectType.d.ts +63 -0
  103. package/dist/generators/ts/AbstractLazyObjectType.js +140 -0
  104. package/dist/generators/ts/AbstractLiteralType.d.ts +24 -0
  105. package/dist/generators/ts/AbstractLiteralType.js +36 -0
  106. package/dist/generators/ts/AbstractNumericType.d.ts +32 -0
  107. package/dist/generators/ts/AbstractNumericType.js +85 -0
  108. package/dist/generators/ts/AbstractPrimitiveType.d.ts +30 -0
  109. package/dist/generators/ts/AbstractPrimitiveType.js +60 -0
  110. package/dist/generators/ts/AbstractTermType.d.ts +60 -0
  111. package/dist/generators/ts/AbstractTermType.js +171 -0
  112. package/dist/generators/ts/AbstractType.d.ts +267 -0
  113. package/dist/generators/ts/AbstractType.js +85 -0
  114. package/dist/generators/ts/BigDecimalType.d.ts +21 -0
  115. package/dist/generators/ts/BigDecimalType.js +91 -0
  116. package/dist/generators/ts/BigIntType.d.ts +15 -0
  117. package/dist/generators/ts/BigIntType.js +49 -0
  118. package/dist/generators/ts/BlankNodeType.d.ts +26 -0
  119. package/dist/generators/ts/BlankNodeType.js +61 -0
  120. package/dist/generators/ts/BooleanType.d.ts +18 -10
  121. package/dist/generators/ts/BooleanType.js +28 -51
  122. package/dist/generators/ts/DateTimeType.d.ts +8 -22
  123. package/dist/generators/ts/DateTimeType.js +10 -89
  124. package/dist/generators/ts/DateType.d.ts +7 -8
  125. package/dist/generators/ts/DateType.js +11 -18
  126. package/dist/generators/ts/DefaultValueType.d.ts +48 -0
  127. package/dist/generators/ts/DefaultValueType.js +178 -0
  128. package/dist/generators/ts/FloatType.d.ts +9 -4
  129. package/dist/generators/ts/FloatType.js +13 -15
  130. package/dist/generators/ts/IdentifierType.d.ts +18 -16
  131. package/dist/generators/ts/IdentifierType.js +45 -172
  132. package/dist/generators/ts/IntType.d.ts +9 -4
  133. package/dist/generators/ts/IntType.js +13 -15
  134. package/dist/generators/ts/IriType.d.ts +24 -0
  135. package/dist/generators/ts/IriType.js +106 -0
  136. package/dist/generators/ts/LazyObjectOptionType.d.ts +31 -0
  137. package/dist/generators/ts/LazyObjectOptionType.js +87 -0
  138. package/dist/generators/ts/LazyObjectSetType.d.ts +15 -0
  139. package/dist/generators/ts/LazyObjectSetType.js +78 -0
  140. package/dist/generators/ts/LazyObjectType.d.ts +14 -0
  141. package/dist/generators/ts/LazyObjectType.js +59 -0
  142. package/dist/generators/ts/ListType.d.ts +33 -31
  143. package/dist/generators/ts/ListType.js +76 -271
  144. package/dist/generators/ts/LiteralType.d.ts +16 -18
  145. package/dist/generators/ts/LiteralType.js +35 -114
  146. package/dist/generators/ts/ObjectType.d.ts +60 -66
  147. package/dist/generators/ts/ObjectType.js +151 -190
  148. package/dist/generators/ts/ObjectUnionType.d.ts +38 -74
  149. package/dist/generators/ts/ObjectUnionType.js +144 -559
  150. package/dist/generators/ts/OptionType.d.ts +33 -27
  151. package/dist/generators/ts/OptionType.js +93 -83
  152. package/dist/generators/ts/SetType.d.ts +13 -32
  153. package/dist/generators/ts/SetType.js +27 -160
  154. package/dist/generators/ts/StringType.d.ts +19 -11
  155. package/dist/generators/ts/StringType.js +33 -53
  156. package/dist/generators/ts/TermType.d.ts +22 -56
  157. package/dist/generators/ts/TermType.js +67 -219
  158. package/dist/generators/ts/TsGenerator.d.ts +0 -1
  159. package/dist/generators/ts/TsGenerator.js +30 -71
  160. package/dist/generators/ts/Type.d.ts +24 -245
  161. package/dist/generators/ts/Type.js +1 -121
  162. package/dist/generators/ts/TypeFactory.d.ts +24 -15
  163. package/dist/generators/ts/TypeFactory.js +330 -400
  164. package/dist/generators/ts/Typeof.d.ts +2 -0
  165. package/dist/generators/ts/Typeof.js +2 -0
  166. package/dist/generators/ts/UnionType.d.ts +32 -28
  167. package/dist/generators/ts/UnionType.js +299 -230
  168. package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +191 -0
  169. package/dist/generators/ts/_ObjectType/AbstractProperty.js +49 -0
  170. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +22 -25
  171. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +34 -56
  172. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +38 -36
  173. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +238 -191
  174. package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.d.ts +4 -0
  175. package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.js +69 -0
  176. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
  177. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +52 -0
  178. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.d.ts +5 -0
  179. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.js +51 -0
  180. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +4 -0
  181. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +21 -0
  182. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +4 -0
  183. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.js +22 -0
  184. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
  185. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.js +13 -0
  186. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
  187. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.js +35 -0
  188. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.d.ts +4 -0
  189. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.js +73 -0
  190. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
  191. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +16 -0
  192. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +4 -0
  193. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +14 -0
  194. package/dist/generators/ts/_ObjectType/ObjectType_jsonFunctionDeclarations.d.ts +4 -0
  195. package/dist/generators/ts/_ObjectType/ObjectType_jsonFunctionDeclarations.js +122 -0
  196. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
  197. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +17 -0
  198. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +9 -0
  199. package/dist/generators/ts/_ObjectType/{objectSetMethodNames.js → ObjectType_objectSetMethodNames.js} +3 -3
  200. package/dist/generators/ts/_ObjectType/ObjectType_rdfFunctionDeclarations.d.ts +4 -0
  201. package/dist/generators/ts/_ObjectType/ObjectType_rdfFunctionDeclarations.js +132 -0
  202. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +4 -0
  203. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +10 -0
  204. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +6 -0
  205. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +12 -0
  206. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +6 -0
  207. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +10 -0
  208. package/dist/generators/ts/_ObjectType/ObjectType_sparqlFunctionDeclarations.d.ts +4 -0
  209. package/dist/generators/ts/_ObjectType/ObjectType_sparqlFunctionDeclarations.js +143 -0
  210. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.d.ts +5 -0
  211. package/dist/generators/ts/_ObjectType/{toJsonFunctionOrMethodDeclaration.js → ObjectType_toJsonFunctionOrMethodDeclaration.js} +18 -18
  212. package/dist/generators/ts/_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.d.ts +5 -0
  213. package/dist/generators/ts/_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.js +65 -0
  214. package/dist/generators/ts/_ObjectType/Property.d.ts +5 -168
  215. package/dist/generators/ts/_ObjectType/Property.js +1 -32
  216. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +41 -32
  217. package/dist/generators/ts/_ObjectType/ShaclProperty.js +178 -134
  218. package/dist/generators/ts/_ObjectType/TypeDiscriminantProperty.d.ts +48 -0
  219. package/dist/generators/ts/_ObjectType/TypeDiscriminantProperty.js +142 -0
  220. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +2 -5
  221. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +9 -44
  222. package/dist/generators/ts/_ObjectUnionType/MemberType.d.ts +34 -0
  223. package/dist/generators/ts/_ObjectUnionType/MemberType.js +105 -0
  224. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.d.ts +5 -0
  225. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.js +29 -0
  226. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.d.ts +4 -0
  227. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.js +19 -0
  228. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.d.ts +4 -0
  229. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.js +10 -0
  230. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.d.ts +5 -0
  231. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.js +18 -0
  232. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.d.ts +5 -0
  233. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.js +28 -0
  234. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.d.ts +4 -0
  235. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.js +9 -0
  236. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.d.ts +5 -0
  237. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.js +13 -0
  238. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonFunctionDeclarations.d.ts +4 -0
  239. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonFunctionDeclarations.js +50 -0
  240. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.d.ts +5 -0
  241. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js +10 -0
  242. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_rdfFunctionDeclarations.d.ts +4 -0
  243. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_rdfFunctionDeclarations.js +60 -0
  244. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.d.ts +4 -0
  245. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.js +37 -0
  246. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlFunctionDeclarations.d.ts +4 -0
  247. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlFunctionDeclarations.js +45 -0
  248. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.d.ts +4 -0
  249. package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.js +10 -0
  250. package/dist/generators/ts/_snippets/snippets_BlankNodeFilter.d.ts +2 -0
  251. package/dist/generators/ts/_snippets/snippets_BlankNodeFilter.js +6 -0
  252. package/dist/generators/ts/_snippets/snippets_BlankNodeSchema.d.ts +2 -0
  253. package/dist/generators/ts/_snippets/snippets_BlankNodeSchema.js +7 -0
  254. package/dist/generators/ts/_snippets/snippets_BooleanFilter.d.ts +2 -0
  255. package/dist/generators/ts/_snippets/snippets_BooleanFilter.js +7 -0
  256. package/dist/generators/ts/_snippets/snippets_BooleanSchema.d.ts +2 -0
  257. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +8 -0
  258. package/dist/generators/ts/_snippets/snippets_CollectionFilter.d.ts +2 -0
  259. package/dist/generators/ts/_snippets/snippets_CollectionFilter.js +8 -0
  260. package/dist/generators/ts/_snippets/snippets_CollectionSchema.d.ts +2 -0
  261. package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +9 -0
  262. package/dist/generators/ts/_snippets/snippets_DateFilter.d.ts +2 -0
  263. package/dist/generators/ts/_snippets/snippets_DateFilter.js +11 -0
  264. package/dist/generators/ts/_snippets/snippets_DateSchema.d.ts +2 -0
  265. package/dist/generators/ts/_snippets/snippets_DateSchema.js +8 -0
  266. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.d.ts +2 -0
  267. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +10 -0
  268. package/dist/generators/ts/_snippets/snippets_EqualsResult.d.ts +2 -0
  269. package/dist/generators/ts/_snippets/snippets_EqualsResult.js +65 -0
  270. package/dist/generators/ts/_snippets/snippets_FromRdfOptions.d.ts +2 -0
  271. package/dist/generators/ts/_snippets/snippets_FromRdfOptions.js +5 -0
  272. package/dist/generators/ts/_snippets/snippets_Hasher.d.ts +2 -0
  273. package/dist/generators/ts/_snippets/snippets_Hasher.js +4 -0
  274. package/dist/generators/ts/_snippets/snippets_IdentifierFilter.d.ts +2 -0
  275. package/dist/generators/ts/_snippets/snippets_IdentifierFilter.js +9 -0
  276. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.d.ts +2 -0
  277. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +7 -0
  278. package/dist/generators/ts/_snippets/snippets_IdentifierSet.d.ts +2 -0
  279. package/dist/generators/ts/_snippets/snippets_IdentifierSet.js +29 -0
  280. package/dist/generators/ts/_snippets/snippets_IriFilter.d.ts +2 -0
  281. package/dist/generators/ts/_snippets/snippets_IriFilter.js +8 -0
  282. package/dist/generators/ts/_snippets/snippets_IriSchema.d.ts +2 -0
  283. package/dist/generators/ts/_snippets/snippets_IriSchema.js +9 -0
  284. package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +2 -0
  285. package/dist/generators/ts/_snippets/snippets_LazyObject.js +24 -0
  286. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +2 -0
  287. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +27 -0
  288. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +2 -0
  289. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +42 -0
  290. package/dist/generators/ts/_snippets/snippets_LiteralFilter.d.ts +2 -0
  291. package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +9 -0
  292. package/dist/generators/ts/_snippets/snippets_LiteralSchema.d.ts +2 -0
  293. package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +10 -0
  294. package/dist/generators/ts/_snippets/snippets_MaybeFilter.d.ts +2 -0
  295. package/dist/generators/ts/_snippets/snippets_MaybeFilter.js +5 -0
  296. package/dist/generators/ts/_snippets/snippets_MaybeSchema.d.ts +2 -0
  297. package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +8 -0
  298. package/dist/generators/ts/_snippets/snippets_NumericFilter.d.ts +2 -0
  299. package/dist/generators/ts/_snippets/snippets_NumericFilter.js +11 -0
  300. package/dist/generators/ts/_snippets/snippets_NumericSchema.d.ts +2 -0
  301. package/dist/generators/ts/_snippets/snippets_NumericSchema.js +8 -0
  302. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.d.ts +2 -0
  303. package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.js +5 -0
  304. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.d.ts +2 -0
  305. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +42 -0
  306. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.d.ts +2 -0
  307. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +10 -0
  308. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.d.ts +2 -0
  309. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.js +6 -0
  310. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.d.ts +2 -0
  311. package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.js +12 -0
  312. package/dist/generators/ts/_snippets/snippets_SparqlFilterPattern.d.ts +2 -0
  313. package/dist/generators/ts/_snippets/snippets_SparqlFilterPattern.js +5 -0
  314. package/dist/generators/ts/_snippets/snippets_SparqlPattern.d.ts +2 -0
  315. package/dist/generators/ts/_snippets/snippets_SparqlPattern.js +6 -0
  316. package/dist/generators/ts/_snippets/snippets_SparqlPattern_isSolutionGenerating.d.ts +2 -0
  317. package/dist/generators/ts/_snippets/snippets_SparqlPattern_isSolutionGenerating.js +32 -0
  318. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.d.ts +2 -0
  319. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.js +6 -0
  320. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.d.ts +2 -0
  321. package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.js +15 -0
  322. package/dist/generators/ts/_snippets/snippets_StringFilter.d.ts +2 -0
  323. package/dist/generators/ts/_snippets/snippets_StringFilter.js +9 -0
  324. package/dist/generators/ts/_snippets/snippets_StringSchema.d.ts +2 -0
  325. package/dist/generators/ts/_snippets/snippets_StringSchema.js +8 -0
  326. package/dist/generators/ts/_snippets/snippets_TermFilter.d.ts +2 -0
  327. package/dist/generators/ts/_snippets/snippets_TermFilter.js +11 -0
  328. package/dist/generators/ts/_snippets/snippets_TermSchema.d.ts +2 -0
  329. package/dist/generators/ts/_snippets/snippets_TermSchema.js +9 -0
  330. package/dist/generators/ts/_snippets/snippets_UnwrapR.d.ts +2 -0
  331. package/dist/generators/ts/_snippets/snippets_UnwrapR.js +6 -0
  332. package/dist/generators/ts/_snippets/snippets_arrayEquals.d.ts +2 -0
  333. package/dist/generators/ts/_snippets/snippets_arrayEquals.js +71 -0
  334. package/dist/generators/ts/_snippets/snippets_arrayIntersection.d.ts +2 -0
  335. package/dist/generators/ts/_snippets/snippets_arrayIntersection.js +30 -0
  336. package/dist/generators/ts/_snippets/snippets_bigDecimalLiteral.d.ts +2 -0
  337. package/dist/generators/ts/_snippets/snippets_bigDecimalLiteral.js +12 -0
  338. package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.d.ts +2 -0
  339. package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +91 -0
  340. package/dist/generators/ts/_snippets/snippets_blankNodeFromString.d.ts +2 -0
  341. package/dist/generators/ts/_snippets/snippets_blankNodeFromString.js +11 -0
  342. package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.d.ts +2 -0
  343. package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +9 -0
  344. package/dist/generators/ts/_snippets/snippets_booleanEquals.d.ts +2 -0
  345. package/dist/generators/ts/_snippets/snippets_booleanEquals.js +18 -0
  346. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.d.ts +2 -0
  347. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +22 -0
  348. package/dist/generators/ts/_snippets/snippets_dateEquals.d.ts +2 -0
  349. package/dist/generators/ts/_snippets/snippets_dateEquals.js +15 -0
  350. package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.d.ts +2 -0
  351. package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +79 -0
  352. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.d.ts +2 -0
  353. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.js +11 -0
  354. package/dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.d.ts +2 -0
  355. package/dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.js +21 -0
  356. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.d.ts +2 -0
  357. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +13 -0
  358. package/dist/generators/ts/_snippets/snippets_filterArray.d.ts +2 -0
  359. package/dist/generators/ts/_snippets/snippets_filterArray.js +24 -0
  360. package/dist/generators/ts/_snippets/snippets_filterBigDecimal.d.ts +2 -0
  361. package/dist/generators/ts/_snippets/snippets_filterBigDecimal.js +29 -0
  362. package/dist/generators/ts/_snippets/snippets_filterBlankNode.d.ts +2 -0
  363. package/dist/generators/ts/_snippets/snippets_filterBlankNode.js +9 -0
  364. package/dist/generators/ts/_snippets/snippets_filterBoolean.d.ts +2 -0
  365. package/dist/generators/ts/_snippets/snippets_filterBoolean.js +12 -0
  366. package/dist/generators/ts/_snippets/snippets_filterDate.d.ts +2 -0
  367. package/dist/generators/ts/_snippets/snippets_filterDate.js +28 -0
  368. package/dist/generators/ts/_snippets/snippets_filterIdentifier.d.ts +2 -0
  369. package/dist/generators/ts/_snippets/snippets_filterIdentifier.js +17 -0
  370. package/dist/generators/ts/_snippets/snippets_filterIri.d.ts +2 -0
  371. package/dist/generators/ts/_snippets/snippets_filterIri.js +13 -0
  372. package/dist/generators/ts/_snippets/snippets_filterLiteral.d.ts +2 -0
  373. package/dist/generators/ts/_snippets/snippets_filterLiteral.js +10 -0
  374. package/dist/generators/ts/_snippets/snippets_filterMaybe.d.ts +2 -0
  375. package/dist/generators/ts/_snippets/snippets_filterMaybe.js +25 -0
  376. package/dist/generators/ts/_snippets/snippets_filterNumeric.d.ts +2 -0
  377. package/dist/generators/ts/_snippets/snippets_filterNumeric.js +28 -0
  378. package/dist/generators/ts/_snippets/snippets_filterString.d.ts +2 -0
  379. package/dist/generators/ts/_snippets/snippets_filterString.js +20 -0
  380. package/dist/generators/ts/_snippets/snippets_filterTerm.d.ts +2 -0
  381. package/dist/generators/ts/_snippets/snippets_filterTerm.js +26 -0
  382. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +2 -0
  383. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +17 -0
  384. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +2 -0
  385. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +25 -0
  386. package/dist/generators/ts/_snippets/snippets_identifierFromString.d.ts +2 -0
  387. package/dist/generators/ts/_snippets/snippets_identifierFromString.js +8 -0
  388. package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.d.ts +2 -0
  389. package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +36 -0
  390. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.d.ts +2 -0
  391. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +20 -0
  392. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +2 -0
  393. package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +7 -0
  394. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +2 -0
  395. package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +7 -0
  396. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +2 -0
  397. package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +7 -0
  398. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +2 -0
  399. package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +7 -0
  400. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +2 -0
  401. package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +7 -0
  402. package/dist/generators/ts/_snippets/snippets_liftSparqlPatterns.d.ts +2 -0
  403. package/dist/generators/ts/_snippets/snippets_liftSparqlPatterns.js +18 -0
  404. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.d.ts +2 -0
  405. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +43 -0
  406. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.d.ts +2 -0
  407. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +121 -0
  408. package/dist/generators/ts/_snippets/snippets_literalFactory.d.ts +2 -0
  409. package/dist/generators/ts/_snippets/snippets_literalFactory.js +5 -0
  410. package/dist/generators/ts/_snippets/snippets_literalSchemaSparqlPatterns.d.ts +2 -0
  411. package/dist/generators/ts/_snippets/snippets_literalSchemaSparqlPatterns.js +45 -0
  412. package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.d.ts +2 -0
  413. package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +10 -0
  414. package/dist/generators/ts/_snippets/snippets_maybeEquals.d.ts +2 -0
  415. package/dist/generators/ts/_snippets/snippets_maybeEquals.js +34 -0
  416. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.d.ts +2 -0
  417. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +10 -0
  418. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.d.ts +2 -0
  419. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +26 -0
  420. package/dist/generators/ts/_snippets/snippets_normalizeSparqlWherePatterns.d.ts +2 -0
  421. package/dist/generators/ts/_snippets/snippets_normalizeSparqlWherePatterns.js +97 -0
  422. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.d.ts +2 -0
  423. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +71 -0
  424. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.d.ts +2 -0
  425. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +10 -0
  426. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.d.ts +2 -0
  427. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +22 -0
  428. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.d.ts +2 -0
  429. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +14 -0
  430. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.d.ts +2 -0
  431. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +94 -0
  432. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.d.ts +2 -0
  433. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +92 -0
  434. package/dist/generators/ts/_snippets/snippets_sortSparqlPatterns.d.ts +2 -0
  435. package/dist/generators/ts/_snippets/snippets_sortSparqlPatterns.js +26 -0
  436. package/dist/generators/ts/_snippets/snippets_sparqlInstancesOfPattern.d.ts +2 -0
  437. package/dist/generators/ts/_snippets/snippets_sparqlInstancesOfPattern.js +32 -0
  438. package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.d.ts +2 -0
  439. package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +61 -0
  440. package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.d.ts +2 -0
  441. package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.js +27 -0
  442. package/dist/generators/ts/_snippets/snippets_strictEquals.d.ts +2 -0
  443. package/dist/generators/ts/_snippets/snippets_strictEquals.js +14 -0
  444. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.d.ts +2 -0
  445. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +47 -0
  446. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.d.ts +2 -0
  447. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +98 -0
  448. package/dist/generators/ts/_snippets/snippets_termSchemaSparqlPatterns.d.ts +2 -0
  449. package/dist/generators/ts/_snippets/snippets_termSchemaSparqlPatterns.js +29 -0
  450. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.d.ts +2 -0
  451. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +11 -0
  452. package/dist/generators/ts/codeEquals.d.ts +3 -0
  453. package/dist/generators/ts/codeEquals.js +7 -0
  454. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -2
  455. package/dist/generators/ts/graphqlSchemaVariableStatement.js +56 -60
  456. package/dist/generators/ts/imports.d.ts +40 -0
  457. package/dist/generators/ts/imports.js +41 -0
  458. package/dist/generators/ts/objectSetDeclarations.d.ts +2 -2
  459. package/dist/generators/ts/objectSetDeclarations.js +5 -7
  460. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +2 -2
  461. package/dist/generators/ts/objectSetInterfaceDeclaration.js +19 -41
  462. package/dist/generators/ts/objectSetMethodSignatures.d.ts +9 -3
  463. package/dist/generators/ts/objectSetMethodSignatures.js +14 -34
  464. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +2 -2
  465. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +279 -359
  466. package/dist/generators/ts/rdfjsTermExpression.d.ts +2 -1
  467. package/dist/generators/ts/rdfjsTermExpression.js +28 -10
  468. package/dist/generators/ts/removeUndefined.d.ts +2 -0
  469. package/dist/generators/ts/removeUndefined.js +17 -0
  470. package/dist/generators/ts/snippets.d.ts +104 -0
  471. package/dist/generators/ts/snippets.js +205 -0
  472. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +2 -2
  473. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +209 -388
  474. package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +9 -0
  475. package/dist/generators/ts/synthesizeUberObjectUnionType.js +59 -0
  476. package/dist/generators/ts/ts-poet-wrapper.d.ts +5 -0
  477. package/dist/generators/ts/ts-poet-wrapper.js +13 -0
  478. package/dist/generators/ts/tsName.d.ts +11 -2
  479. package/dist/generators/ts/tsName.js +25 -28
  480. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +4 -3
  481. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +18 -15
  482. package/dist/index.d.ts +6 -1
  483. package/dist/index.js +5 -1
  484. package/dist/input/NodeShape.d.ts +14 -11
  485. package/dist/input/NodeShape.js +87 -80
  486. package/dist/input/Ontology.d.ts +1 -1
  487. package/dist/input/Ontology.js +13 -0
  488. package/dist/input/PropertyShape.d.ts +8 -5
  489. package/dist/input/PropertyShape.js +46 -9
  490. package/dist/input/ShapesGraph.d.ts +23 -6
  491. package/dist/input/ShapesGraph.js +58 -39
  492. package/dist/input/ancestorClassIris.js +4 -1
  493. package/dist/input/descendantClassIris.js +8 -2
  494. package/dist/input/generated.d.ts +3032 -1044
  495. package/dist/input/generated.js +3595 -2734
  496. package/dist/input/index.d.ts +1 -1
  497. package/dist/input/index.js +1 -1
  498. package/dist/input/tsFeatures.d.ts +1 -1
  499. package/package.json +39 -45
  500. package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +0 -2
  501. package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +0 -2
  502. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +0 -13
  503. package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +0 -51
  504. package/dist/_ShapesGraphToAstTransformer/pickLiteral.d.ts +0 -4
  505. package/dist/_ShapesGraphToAstTransformer/pickLiteral.js +0 -18
  506. package/dist/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.d.ts +0 -4
  507. package/dist/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.js +0 -26
  508. package/dist/_ShapesGraphToAstTransformer/shapeAstName.d.ts +0 -5
  509. package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +0 -69
  510. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +0 -10
  511. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +0 -185
  512. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +0 -10
  513. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +0 -32
  514. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +0 -10
  515. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +0 -46
  516. package/dist/ast/CompositeType.d.ts +0 -13
  517. package/dist/ast/CompositeType.js +0 -2
  518. package/dist/ast/Name.d.ts +0 -49
  519. package/dist/ast/Name.js +0 -2
  520. package/dist/ast/ObjectCompositeType.d.ts +0 -33
  521. package/dist/ast/ObjectCompositeType.js +0 -2
  522. package/dist/generators/ts/DeclaredType.d.ts +0 -17
  523. package/dist/generators/ts/DeclaredType.js +0 -13
  524. package/dist/generators/ts/Import.d.ts +0 -20
  525. package/dist/generators/ts/Import.js +0 -65
  526. package/dist/generators/ts/NumberType.d.ts +0 -13
  527. package/dist/generators/ts/NumberType.js +0 -71
  528. package/dist/generators/ts/PrimitiveType.d.ts +0 -21
  529. package/dist/generators/ts/PrimitiveType.js +0 -57
  530. package/dist/generators/ts/SnippetDeclarations.d.ts +0 -17
  531. package/dist/generators/ts/SnippetDeclarations.js +0 -367
  532. package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +0 -12
  533. package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +0 -31
  534. package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +0 -100
  535. package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +0 -315
  536. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +0 -51
  537. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +0 -138
  538. package/dist/generators/ts/_ObjectType/classDeclaration.d.ts +0 -5
  539. package/dist/generators/ts/_ObjectType/classDeclaration.js +0 -122
  540. package/dist/generators/ts/_ObjectType/createFunctionDeclaration.d.ts +0 -5
  541. package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +0 -73
  542. package/dist/generators/ts/_ObjectType/equalsFunctionDeclaration.d.ts +0 -5
  543. package/dist/generators/ts/_ObjectType/equalsFunctionDeclaration.js +0 -19
  544. package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.d.ts +0 -11
  545. package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +0 -73
  546. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +0 -5
  547. package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +0 -28
  548. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +0 -5
  549. package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +0 -49
  550. package/dist/generators/ts/_ObjectType/hashFunctionDeclarations.d.ts +0 -4
  551. package/dist/generators/ts/_ObjectType/hashFunctionDeclarations.js +0 -18
  552. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.d.ts +0 -13
  553. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +0 -96
  554. package/dist/generators/ts/_ObjectType/index.d.ts +0 -22
  555. package/dist/generators/ts/_ObjectType/index.js +0 -22
  556. package/dist/generators/ts/_ObjectType/interfaceDeclaration.d.ts +0 -5
  557. package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +0 -21
  558. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +0 -4
  559. package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +0 -189
  560. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +0 -5
  561. package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +0 -28
  562. package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +0 -9
  563. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +0 -5
  564. package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +0 -37
  565. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +0 -4
  566. package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +0 -169
  567. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +0 -5
  568. package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +0 -22
  569. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +0 -5
  570. package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +0 -21
  571. package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.d.ts +0 -4
  572. package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +0 -166
  573. package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.d.ts +0 -10
  574. package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.d.ts +0 -10
  575. package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +0 -76
  576. package/dist/generators/ts/forwardingObjectSetClassDeclaration.d.ts +0 -8
  577. package/dist/generators/ts/forwardingObjectSetClassDeclaration.js +0 -29
  578. package/dist/generators/ts/objectInitializer.d.ts +0 -2
  579. package/dist/generators/ts/objectInitializer.js +0 -14
  580. package/dist/input/PropertyPath.d.ts +0 -41
  581. package/dist/input/PropertyPath.js +0 -95
@@ -1,139 +1,203 @@
1
+ import dataFactory from "@rdfjs/data-model";
1
2
  import { rdf } from "@tpluscode/rdf-ns-builders";
2
3
  import { Either, Left, Maybe } from "purify-ts";
3
4
  import { invariant } from "ts-invariant";
4
- import * as input from "../input/index.js";
5
+ import * as ast from "../ast/index.js";
6
+ import { Eithers } from "../Eithers.js";
5
7
  import { tsFeaturesDefault } from "../input/tsFeatures.js";
6
- import { logger } from "../logger.js";
7
- import { flattenAstObjectCompositeTypeMemberTypes } from "./flattenAstObjectCompositeTypeMemberTypes.js";
8
- import { pickLiteral } from "./pickLiteral.js";
8
+ import { nodeShapeIdentifierMintingStrategy } from "./nodeShapeIdentifierMintingStrategy.js";
9
+ import { nodeShapeTsFeatures } from "./nodeShapeTsFeatures.js";
10
+ import { shapeNodeKinds } from "./shapeNodeKinds.js";
11
+ const defaultNodeShapeNodeKinds = new Set([
12
+ "BlankNode",
13
+ "IRI",
14
+ ]);
15
+ function isObjectTypePropertyRequired(property) {
16
+ switch (property.type.kind) {
17
+ case "DefaultValueType":
18
+ return false;
19
+ case "LazyObjectOptionType":
20
+ return false;
21
+ case "LazyObjectSetType":
22
+ return property.type.partialType.minCount > 0;
23
+ case "OptionType":
24
+ return false;
25
+ case "SetType":
26
+ return property.type.minCount > 0;
27
+ case "UnionType":
28
+ return property.type.memberTypes.every((memberType) => isObjectTypePropertyRequired({ type: memberType }));
29
+ case "BlankNodeType":
30
+ case "IdentifierType":
31
+ case "IriType":
32
+ case "LazyObjectType":
33
+ case "ListType":
34
+ case "LiteralType":
35
+ case "ObjectType":
36
+ case "ObjectUnionType":
37
+ case "PlaceholderType":
38
+ case "TermType":
39
+ return true;
40
+ case "IntersectionType":
41
+ case "ObjectIntersectionType":
42
+ throw new Error("unsupported");
43
+ default:
44
+ property.type;
45
+ throw new Error("should never reach this point");
46
+ }
47
+ }
48
+ const listPropertiesObjectType = new ast.ObjectType({
49
+ abstract: false,
50
+ export_: false,
51
+ extern: false,
52
+ comment: Maybe.empty(),
53
+ label: Maybe.empty(),
54
+ identifierMintingStrategy: Maybe.empty(),
55
+ identifierType: new ast.IdentifierType({
56
+ comment: Maybe.empty(),
57
+ label: Maybe.empty(),
58
+ }),
59
+ fromRdfType: Maybe.empty(),
60
+ name: Maybe.empty(),
61
+ toRdfTypes: [],
62
+ tsFeatures: new Set([]),
63
+ tsObjectDeclarationType: "class",
64
+ shapeIdentifier: dataFactory.blankNode(),
65
+ synthetic: true,
66
+ tsImports: [],
67
+ });
9
68
  /**
10
69
  * Is an ast.ObjectType actually the shape of an RDF list?
11
70
  * If so, return the type of its rdf:first.
12
71
  */
13
72
  function transformNodeShapeToAstListType(nodeShape) {
14
73
  invariant(nodeShape.isList);
15
- // Put a placeholder in the cache to deal with cyclic references
16
- const listType = {
17
- comment: pickLiteral(nodeShape.comments).map((literal) => literal.value),
18
- identifierNodeKind: nodeShape.nodeKinds.has("BlankNode")
19
- ? "BlankNode"
20
- : "NamedNode",
21
- itemType: {
22
- kind: "PlaceholderType",
23
- },
24
- kind: "ListType",
25
- label: pickLiteral(nodeShape.labels).map((literal) => literal.value),
26
- mutable: nodeShape.mutable,
27
- name: this.shapeAstName(nodeShape),
28
- identifierMintingStrategy: nodeShape.identifierMintingStrategy,
29
- toRdfTypes: nodeShape.toRdfTypes,
30
- };
31
- this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, listType);
32
- const properties = [];
33
- for (const propertyShape of nodeShape.constraints.properties) {
34
- const propertyEither = this.transformPropertyShapeToAstObjectTypeProperty(propertyShape);
35
- if (propertyEither.isLeft()) {
36
- logger.warn("error transforming %s %s: %s", nodeShape, propertyShape, propertyEither.extract().message);
37
- continue;
38
- // return property;
39
- }
40
- properties.push(propertyEither.unsafeCoerce());
41
- }
42
- if (properties.length !== 2) {
43
- return Left(new Error(`${nodeShape} does not have exactly two properties`));
44
- }
45
- // rdf:first can have any type
46
- // The type of the rdf:first property is the list item type.
47
- const firstProperty = properties.find((property) => property.path.iri.equals(rdf.first));
48
- if (!firstProperty) {
49
- return Left(new Error(`${nodeShape} does not have an rdf:first property`));
50
- }
51
- const restProperty = properties.find((property) => property.path.iri.equals(rdf.rest));
52
- if (!restProperty) {
53
- return Left(new Error(`${nodeShape} does not have an rdf:rest property`));
54
- }
55
- if (restProperty.type.kind !== "UnionType") {
56
- return Left(new Error(`${nodeShape} rdf:rest property is not sh:xone`));
57
- }
58
- if (restProperty.type.memberTypes.length !== 2) {
59
- return Left(new Error(`${nodeShape} rdf:rest property sh:xone does not have exactly two member types`));
60
- }
61
- // rdf:rest should be sh:xone ( [ sh:class nodeShape ] [ sh:hasValue rdf:nil ] )
62
- if (!restProperty.type.memberTypes.find((type) => type.kind === "ListType" &&
63
- type.name.identifier.equals(nodeShape.identifier))) {
64
- return Left(new Error(`${nodeShape} rdf:rest property sh:xone is not recursive into the node shape`));
65
- }
66
- if (!restProperty.type.memberTypes.find((type) => type.kind === "IdentifierType")) {
67
- return Left(new Error(`${nodeShape} rdf:rest property sh:xone does not include sh:hasValue rdf:nil`));
68
- }
69
- listType.itemType = firstProperty.type;
70
- return Either.of(listType);
74
+ return Eithers.chain3(nodeShapeIdentifierMintingStrategy(nodeShape), shapeNodeKinds(nodeShape, { defaultNodeShapeNodeKinds }), nodeShape.constraints.xone).chain(([identifierMintingStrategy, nodeKinds, xone]) => {
75
+ // Put a placeholder in the cache to deal with cyclic references
76
+ // Remove the placeholder if the transformation fails.
77
+ const listType = new ast.ListType({
78
+ comment: nodeShape.comment,
79
+ identifierNodeKind: nodeKinds.has("BlankNode") ? "BlankNode" : "IRI",
80
+ itemType: ast.PlaceholderType.instance,
81
+ label: nodeShape.label,
82
+ mutable: nodeShape.mutable.orDefault(false),
83
+ identifierMintingStrategy,
84
+ shapeIdentifier: this.shapeIdentifier(nodeShape),
85
+ toRdfTypes: nodeShape.toRdfTypes,
86
+ });
87
+ this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, listType);
88
+ return (() => {
89
+ let emptyListShape;
90
+ let nonEmptyListShape;
91
+ for (const shape of xone) {
92
+ if (shape.constraints.hasValues.length === 1 &&
93
+ shape.constraints.hasValues[0].equals(rdf.nil)) {
94
+ emptyListShape = shape;
95
+ }
96
+ else if (shape.kind === "NodeShape" &&
97
+ shape.constraints.properties.orDefault([]).length >= 2) {
98
+ nonEmptyListShape = shape;
99
+ }
100
+ }
101
+ if (!emptyListShape || !nonEmptyListShape) {
102
+ return Left(new Error(`${nodeShape} does not have an sh:xone with exactly two shapes, one for the empty list and one for the non-empty list`));
103
+ }
104
+ return nonEmptyListShape.constraints.properties.chain((nonEmptyListShapeProperties) => {
105
+ let firstPropertyShape;
106
+ let restPropertyShape;
107
+ for (const propertyShape of nonEmptyListShapeProperties) {
108
+ if (propertyShape.path.termType !== "NamedNode") {
109
+ continue;
110
+ }
111
+ if (propertyShape.path.equals(rdf.first)) {
112
+ firstPropertyShape = propertyShape;
113
+ }
114
+ else if (propertyShape.path.equals(rdf.rest)) {
115
+ restPropertyShape = propertyShape;
116
+ }
117
+ }
118
+ if (!firstPropertyShape) {
119
+ return Left(new Error(`${nodeShape} has a non-empty list shape without an sh:property shape whose sh:path is rdf:first`));
120
+ }
121
+ if (firstPropertyShape.constraints.maxCount.extract() !== 1 ||
122
+ firstPropertyShape.constraints.minCount.extract() !== 1) {
123
+ return Left(new Error(`${nodeShape} non-empty list shape rdf:first property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
124
+ }
125
+ if (!restPropertyShape) {
126
+ return Left(new Error(`${nodeShape} has a non-empty list shape without an sh:property shape whose sh:path is rdf:rest`));
127
+ }
128
+ if (restPropertyShape.constraints.maxCount.extract() !== 1 ||
129
+ restPropertyShape.constraints.minCount.extract() !== 1) {
130
+ return Left(new Error(`${nodeShape} non-empty list shape rdf:rest property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
131
+ }
132
+ return this.transformPropertyShapeToAstObjectTypeProperty({
133
+ // Just need a dummy ast.ObjectType here to get the properties transformed.
134
+ objectType: listPropertiesObjectType,
135
+ propertyShape: firstPropertyShape,
136
+ }).chain((firstProperty) => {
137
+ if (!ast.ListType.isItemType(firstProperty.type)) {
138
+ return Left(new Error(`${nodeShape}: ${firstProperty.type.kind} is not a valid list item type`));
139
+ }
140
+ listType.itemType = firstProperty.type;
141
+ return this.transformPropertyShapeToAstObjectTypeProperty({
142
+ // Just need a dummy ast.ObjectType here to get the properties transformed.
143
+ objectType: listPropertiesObjectType,
144
+ propertyShape: restPropertyShape,
145
+ }).chain((restProperty) => {
146
+ if (restProperty.type.kind !== "ListType" ||
147
+ !restProperty.type.shapeIdentifier.equals(nodeShape.identifier)) {
148
+ return Left(new Error(`${nodeShape} rdf:rest property is not recursive into the node shape`));
149
+ }
150
+ return Either.of(listType);
151
+ });
152
+ });
153
+ });
154
+ })().ifLeft(() => {
155
+ this.nodeShapeAstTypesByIdentifier.delete(nodeShape.identifier);
156
+ });
157
+ });
71
158
  }
72
- export function transformNodeShapeToAstObjectCompositeType({ export_, nodeShape, }) {
73
- let compositeTypeShapes;
74
- let compositeTypeKind;
75
- if (nodeShape.constraints.and.length > 0) {
76
- compositeTypeShapes = nodeShape.constraints.and;
77
- compositeTypeKind = "ObjectIntersectionType";
78
- }
79
- else if (nodeShape.constraints.xone.length > 0) {
80
- compositeTypeShapes = nodeShape.constraints.xone;
81
- compositeTypeKind = "ObjectUnionType";
82
- }
83
- else {
84
- throw new Error("should never be reached");
85
- }
86
- const compositeTypeNodeShapes = [];
87
- for (const compositeTypeShape of compositeTypeShapes) {
88
- if (!(compositeTypeShape instanceof input.NodeShape)) {
89
- return Left(new Error(`${nodeShape} has non-NodeShape in its logical constraint`));
159
+ export function transformNodeShapeToAstObjectCompoundType({ export_, nodeShape, }) {
160
+ return Eithers.chain3(nodeShape.constraints.and, nodeShapeTsFeatures(nodeShape), nodeShape.constraints.xone).chain(([andShapes, tsFeatures, xoneShapes]) => {
161
+ let compoundTypeShapes;
162
+ let compoundTypeKind;
163
+ if (andShapes.length > 0) {
164
+ compoundTypeShapes = andShapes;
165
+ compoundTypeKind = "ObjectIntersectionType";
90
166
  }
91
- compositeTypeNodeShapes.push(compositeTypeShape);
92
- }
93
- if (compositeTypeNodeShapes.length === 0) {
94
- return Left(new Error(`${nodeShape} has no NodeShapes in its logical constraint`));
95
- }
96
- // Put a placeholder in the cache to deal with cyclic references
97
- const compositeType = {
98
- comment: pickLiteral(nodeShape.comments).map((literal) => literal.value),
99
- export: export_,
100
- kind: compositeTypeKind,
101
- label: pickLiteral(nodeShape.labels).map((literal) => literal.value),
102
- memberTypes: [],
103
- name: this.shapeAstName(nodeShape),
104
- tsFeatures: new Set(),
105
- };
106
- this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, compositeType);
107
- const memberTypes = [];
108
- for (const memberNodeShape of compositeTypeNodeShapes) {
109
- const memberTypeEither = this.transformNodeShapeToAstType(memberNodeShape);
110
- if (memberTypeEither.isLeft()) {
111
- return memberTypeEither;
167
+ else if (xoneShapes.length > 0) {
168
+ compoundTypeShapes = xoneShapes;
169
+ compoundTypeKind = "ObjectUnionType";
112
170
  }
113
- const memberType = memberTypeEither.unsafeCoerce();
114
- switch (memberType.kind) {
115
- case "ObjectType":
116
- case "ObjectIntersectionType":
117
- case "ObjectUnionType":
118
- memberTypes.push(memberType);
119
- break;
120
- default:
121
- return Left(new Error(`${nodeShape} has one or more non-ObjectType node shapes in its logical constraint`));
171
+ else {
172
+ throw new Error("should never be reached");
122
173
  }
123
- }
124
- return flattenAstObjectCompositeTypeMemberTypes({
125
- objectCompositeTypeKind: compositeTypeKind,
126
- memberTypes,
127
- shape: nodeShape,
128
- }).map(({ memberTypes, tsFeatures }) => {
129
- // Add to the placeholder composite type and return it.
130
- for (const memberType of memberTypes) {
131
- compositeType.memberTypes.push(memberType);
174
+ const compoundTypeNodeShapes = [];
175
+ for (const compoundTypeShape of compoundTypeShapes) {
176
+ if (compoundTypeShape.kind !== "NodeShape") {
177
+ return Left(new Error(`${nodeShape} has non-NodeShape in its logical constraint`));
178
+ }
179
+ compoundTypeNodeShapes.push(compoundTypeShape);
132
180
  }
133
- for (const tsFeature of tsFeatures) {
134
- compositeType.tsFeatures.add(tsFeature);
181
+ if (compoundTypeNodeShapes.length === 0) {
182
+ return Left(new Error(`${nodeShape} has no NodeShapes in its logical constraint`));
135
183
  }
136
- return compositeType;
184
+ // Put a placeholder in the cache to deal with cyclic references
185
+ const compoundType = new (compoundTypeKind === "ObjectIntersectionType"
186
+ ? ast.ObjectIntersectionType
187
+ : ast.ObjectUnionType)({
188
+ comment: nodeShape.comment,
189
+ export_,
190
+ label: nodeShape.label,
191
+ name: nodeShape.shaclmateName,
192
+ shapeIdentifier: this.shapeIdentifier(nodeShape),
193
+ tsFeatures,
194
+ });
195
+ this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, compoundType);
196
+ return Either.sequence(compoundTypeNodeShapes.map((memberNodeShape) => this.transformNodeShapeToAstType(memberNodeShape).chain((memberType) => compoundType.addMemberType(memberType))))
197
+ .map(() => compoundType)
198
+ .ifLeft(() => {
199
+ this.nodeShapeAstTypesByIdentifier.delete(nodeShape.identifier);
200
+ });
137
201
  });
138
202
  }
139
203
  export function transformNodeShapeToAstType(nodeShape) {
@@ -146,123 +210,130 @@ export function transformNodeShapeToAstType(nodeShape) {
146
210
  if (nodeShape.isList) {
147
211
  return transformNodeShapeToAstListType.bind(this)(nodeShape);
148
212
  }
149
- const export_ = nodeShape.export.orDefault(true);
150
- if (nodeShape.constraints.and.length > 0 ||
151
- nodeShape.constraints.xone.length > 0) {
152
- return transformNodeShapeToAstObjectCompositeType.bind(this)({
153
- export_,
154
- nodeShape,
155
- });
156
- }
157
- const fromRdfType = nodeShape.fromRdfType.alt(nodeShape.rdfType);
158
- const toRdfTypes = nodeShape.toRdfTypes.concat();
159
- if (toRdfTypes.length === 0) {
160
- toRdfTypes.push(...nodeShape.rdfType.toList());
161
- }
162
- // Ensure toRdfTypes has fromRdfType
163
- fromRdfType.ifJust((fromRdfType) => {
164
- if (!toRdfTypes.some((toRdfType) => toRdfType.equals(fromRdfType))) {
165
- toRdfTypes.push(fromRdfType);
213
+ return Eithers.chain11(nodeShape.ancestorNodeShapes, nodeShape.childNodeShapes, nodeShape.descendantNodeShapes, nodeShape.parentNodeShapes, nodeShape.constraints.and, nodeShapeIdentifierMintingStrategy(nodeShape), shapeNodeKinds(nodeShape, { defaultNodeShapeNodeKinds }), nodeShape.constraints.properties, nodeShapeTsFeatures(nodeShape), nodeShape.tsObjectDeclarationType.isJust()
214
+ ? Either.of(nodeShape.tsObjectDeclarationType)
215
+ : nodeShape.isDefinedBy.map((ontology) => ontology.chain((ontology) => ontology.tsObjectDeclarationType)), nodeShape.constraints.xone).chain(([ancestorNodeShapes, childNodeShapes, descendantNodeShapes, parentNodeShapes, andShapes, identifierMintingStrategy, nodeKinds, propertyShapes, tsFeatures, tsObjectDeclarationType, xoneShapes,]) => {
216
+ const abstract = nodeShape.abstract.orDefault(false);
217
+ const export_ = nodeShape.export.orDefault(true);
218
+ if (andShapes.length > 0 || xoneShapes.length > 0) {
219
+ return transformNodeShapeToAstObjectCompoundType.bind(this)({
220
+ export_,
221
+ nodeShape,
222
+ });
166
223
  }
167
- });
168
- const identifierIn = nodeShape.constraints.in_.filter((term) => term.termType === "NamedNode");
169
- // Put a placeholder in the cache to deal with cyclic references
170
- // If this node shape's properties (directly or indirectly) refer to the node shape itself,
171
- // we'll return this placeholder.
172
- const objectType = {
173
- abstract: nodeShape.abstract.orDefault(false),
174
- ancestorObjectTypes: [],
175
- childObjectTypes: [],
176
- comment: pickLiteral(nodeShape.comments).map((literal) => literal.value),
177
- descendantObjectTypes: [],
178
- export: export_,
179
- extern: nodeShape.extern.orDefault(false),
180
- fromRdfType,
181
- label: pickLiteral(nodeShape.labels).map((literal) => literal.value),
182
- kind: "ObjectType",
183
- identifierIn,
184
- identifierMintingStrategy: identifierIn.length === 0
185
- ? nodeShape.identifierMintingStrategy
186
- : Maybe.empty(),
187
- identifierNodeKinds: identifierIn.length === 0 ? nodeShape.nodeKinds : new Set(["NamedNode"]),
188
- name: this.shapeAstName(nodeShape),
189
- properties: [], // This is mutable, we'll populate it below.
190
- parentObjectTypes: [], // This is mutable, we'll populate it below
191
- synthetic: false,
192
- toRdfTypes,
193
- tsFeatures: nodeShape.tsFeatures.orDefault(new Set(tsFeaturesDefault)),
194
- tsImports: nodeShape.tsImports,
195
- tsObjectDeclarationType: nodeShape.tsObjectDeclarationType.orDefault("class"),
196
- };
197
- this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, objectType);
198
- // Populate ancestor and descendant object types
199
- const relatedObjectTypes = (relatedNodeShapes) => {
200
- return relatedNodeShapes.flatMap((relatedNodeShape) => this.transformNodeShapeToAstType(relatedNodeShape)
201
- .toMaybe()
202
- .filter((astType) => astType.kind === "ObjectType")
203
- .toList());
204
- };
205
- objectType.ancestorObjectTypes.push(...relatedObjectTypes(nodeShape.ancestorNodeShapes));
206
- objectType.childObjectTypes.push(...relatedObjectTypes(nodeShape.childNodeShapes));
207
- objectType.descendantObjectTypes.push(...relatedObjectTypes(nodeShape.descendantNodeShapes));
208
- objectType.parentObjectTypes.push(...relatedObjectTypes(nodeShape.parentNodeShapes));
209
- // Populate properties
210
- // Check whether a type refers to this ObjectType
211
- const isPropertyRecursive = (astType) => {
212
- switch (astType.kind) {
213
- case "IdentifierType":
214
- case "LiteralType":
215
- case "PlaceholderType":
216
- case "TermType":
217
- return false;
218
- case "ObjectType":
219
- if (astType.name === objectType.name) {
220
- return true;
221
- }
222
- for (const property of astType.properties) {
223
- if (isPropertyRecursive(property.type)) {
224
- return true;
225
- }
226
- }
227
- return false;
228
- case "IntersectionType":
229
- case "ObjectIntersectionType":
230
- case "ObjectUnionType":
231
- case "UnionType":
232
- for (const memberType of astType.memberTypes) {
233
- if (isPropertyRecursive(memberType)) {
234
- return true;
235
- }
224
+ let fromRdfType;
225
+ let toRdfTypes;
226
+ if (!abstract) {
227
+ fromRdfType = nodeShape.fromRdfType.alt(nodeShape.rdfType);
228
+ if (nodeShape.isClass &&
229
+ nodeShape.identifier.termType === "NamedNode") {
230
+ fromRdfType = fromRdfType.alt(Maybe.of(nodeShape.identifier));
231
+ }
232
+ toRdfTypes = nodeShape.toRdfTypes.concat();
233
+ if (toRdfTypes.length === 0) {
234
+ toRdfTypes.push(...nodeShape.rdfType.toList());
235
+ }
236
+ // Ensure toRdfTypes has fromRdfType
237
+ fromRdfType.ifJust((fromRdfType) => {
238
+ if (!toRdfTypes.some((toRdfType) => toRdfType.equals(fromRdfType))) {
239
+ toRdfTypes.push(fromRdfType);
236
240
  }
237
- return false;
238
- case "ListType":
239
- case "OptionType":
240
- case "SetType":
241
- return isPropertyRecursive(astType.itemType);
241
+ });
242
242
  }
243
- };
244
- for (const propertyShape of nodeShape.constraints.properties) {
245
- const propertyEither = this.transformPropertyShapeToAstObjectTypeProperty(propertyShape);
246
- if (propertyEither.isLeft()) {
247
- logger.warn("error transforming %s %s: %s", nodeShape, propertyShape, propertyEither.extract().message);
248
- continue;
249
- // return property;
243
+ else {
244
+ fromRdfType = Maybe.empty();
245
+ toRdfTypes = [];
250
246
  }
251
- const property = propertyEither.unsafeCoerce();
252
- objectType.properties.push({
253
- ...property,
254
- recursive: isPropertyRecursive(property.type),
255
- });
256
- }
257
- objectType.properties.sort((left, right) => {
258
- if (left.order < right.order) {
259
- return -1;
247
+ if (nodeKinds.has("Literal")) {
248
+ return Left(new Error(`${nodeShape} should not have a nodeKind "Literal"`));
249
+ }
250
+ let identifierType;
251
+ if (nodeKinds.size === 2) {
252
+ invariant(nodeShape.identifierIn.length === 0);
253
+ identifierType = new ast.IdentifierType({
254
+ comment: Maybe.empty(),
255
+ label: Maybe.empty(),
256
+ });
260
257
  }
261
- if (left.order > right.order) {
262
- return 1;
258
+ else {
259
+ switch ([...nodeKinds][0]) {
260
+ case "BlankNode":
261
+ invariant(nodeShape.identifierIn.length === 0);
262
+ identifierType = new ast.BlankNodeType({
263
+ comment: Maybe.empty(),
264
+ label: Maybe.empty(),
265
+ });
266
+ break;
267
+ case "IRI":
268
+ identifierType = new ast.IriType({
269
+ comment: Maybe.empty(),
270
+ hasValues: [],
271
+ in_: nodeShape.identifierIn,
272
+ label: Maybe.empty(),
273
+ });
274
+ break;
275
+ case "Literal":
276
+ throw new Error("should never happen");
277
+ }
263
278
  }
264
- return 0;
279
+ // Put a placeholder in the cache to deal with cyclic references
280
+ // Remove the placeholder if the transformation fails.
281
+ // If this node shape's properties (directly or indirectly) refer to the node shape itself,
282
+ // we'll return this placeholder.
283
+ const objectType = new ast.ObjectType({
284
+ abstract,
285
+ comment: nodeShape.comment,
286
+ export_: export_,
287
+ extern: nodeShape.extern.orDefault(false),
288
+ fromRdfType,
289
+ label: nodeShape.label,
290
+ identifierType,
291
+ identifierMintingStrategy,
292
+ name: nodeShape.shaclmateName,
293
+ shapeIdentifier: this.shapeIdentifier(nodeShape),
294
+ synthetic: false,
295
+ toRdfTypes,
296
+ tsFeatures: tsFeatures.orDefault(new Set(tsFeaturesDefault)),
297
+ tsImports: nodeShape.tsImports,
298
+ tsObjectDeclarationType: tsObjectDeclarationType.orDefault("class"),
299
+ });
300
+ this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, objectType);
301
+ return (() => {
302
+ // Populate ancestor and descendant object types
303
+ const relatedObjectTypes = (relatedNodeShapes) => {
304
+ return relatedNodeShapes.flatMap((relatedNodeShape) => this.transformNodeShapeToAstType(relatedNodeShape)
305
+ .toMaybe()
306
+ .filter((astType) => astType.kind === "ObjectType")
307
+ .toList());
308
+ };
309
+ objectType.addAncestorObjectTypes(...relatedObjectTypes(ancestorNodeShapes));
310
+ objectType.addChildObjectTypes(...relatedObjectTypes(childNodeShapes));
311
+ objectType.addDescendantObjectTypes(...relatedObjectTypes(descendantNodeShapes));
312
+ objectType.addParentObjectTypes(...relatedObjectTypes(parentNodeShapes));
313
+ // Populate properties
314
+ for (const propertyShape of propertyShapes) {
315
+ const propertyEither = this.transformPropertyShapeToAstObjectTypeProperty({
316
+ objectType,
317
+ propertyShape,
318
+ });
319
+ if (propertyEither.isLeft()) {
320
+ return propertyEither;
321
+ }
322
+ propertyEither.ifRight((property) => {
323
+ objectType.addProperties(property);
324
+ });
325
+ }
326
+ if (!objectType.abstract &&
327
+ !objectType.extern &&
328
+ objectType.fromRdfType.isNothing() &&
329
+ !objectType.properties.some(isObjectTypePropertyRequired)) {
330
+ return Left(new Error(`${nodeShape} has no required properties and no implicitly required rdf:type`));
331
+ }
332
+ objectType.sortProperties();
333
+ return Either.of(objectType);
334
+ })().ifLeft(() => {
335
+ this.nodeShapeAstTypesByIdentifier.delete(nodeShape.identifier);
336
+ });
265
337
  });
266
- return Either.of(objectType);
267
338
  }
268
339
  //# sourceMappingURL=transformNodeShapeToAstType.js.map
@@ -1,6 +1,9 @@
1
1
  import { Either } from "purify-ts";
2
- import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
3
- import type * as ast from "../ast/index.js";
2
+ import * as ast from "../ast/index.js";
4
3
  import type * as input from "../input/index.js";
5
- export declare function transformPropertyShapeToAstObjectTypeProperty(this: ShapesGraphToAstTransformer, propertyShape: input.PropertyShape): Either<Error, ast.ObjectType.Property>;
4
+ import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
5
+ export declare function transformPropertyShapeToAstObjectTypeProperty(this: ShapesGraphToAstTransformer, { objectType, propertyShape, }: {
6
+ objectType: ast.ObjectType;
7
+ propertyShape: input.PropertyShape;
8
+ }): Either<Error, ast.ObjectType.Property>;
6
9
  //# sourceMappingURL=transformPropertyShapeToAstObjectTypeProperty.d.ts.map