@shaclmate/compiler 4.0.41 → 4.0.42

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 (320) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +1 -0
  2. package/dist/ShapesGraphToAstTransformer.js +10 -45
  3. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.d.ts +17 -0
  4. package/dist/_ShapesGraphToAstTransformer/{transformPropertyShapeToAstObjectTypeProperty.js → transformPropertyShapeToAstStructTypeField.js} +71 -48
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +1 -1
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +29 -20
  7. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.d.ts → transformShapeToAstStructType.d.ts} +2 -2
  8. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.js → transformShapeToAstStructType.js} +35 -29
  9. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +2 -1
  10. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +1 -1
  11. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
  12. package/dist/ast/AbstractCompoundType.d.ts +2 -2
  13. package/dist/ast/AbstractCompoundType.js +4 -4
  14. package/dist/ast/AbstractContainerType.d.ts +2 -2
  15. package/dist/ast/AbstractContainerType.js +4 -4
  16. package/dist/ast/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +10 -10
  17. package/dist/ast/{AbstractLazyObjectType.js → AbstractLazyType.js} +3 -3
  18. package/dist/ast/AbstractType.d.ts +1 -1
  19. package/dist/ast/AbstractType.js +3 -0
  20. package/dist/ast/Ast.d.ts +2 -4
  21. package/dist/ast/DefaultValueType.js +2 -1
  22. package/dist/ast/IntersectionType.d.ts +2 -2
  23. package/dist/ast/IntersectionType.js +3 -3
  24. package/dist/ast/LazyOptionType.d.ts +6 -0
  25. package/dist/ast/LazyOptionType.js +5 -0
  26. package/dist/ast/LazySetType.d.ts +6 -0
  27. package/dist/ast/LazySetType.js +5 -0
  28. package/dist/ast/LazyType.d.ts +5 -0
  29. package/dist/ast/LazyType.js +5 -0
  30. package/dist/ast/ListType.d.ts +2 -2
  31. package/dist/ast/ListType.js +4 -4
  32. package/dist/ast/OptionType.js +2 -1
  33. package/dist/ast/SetType.js +2 -1
  34. package/dist/ast/StructCompoundType.d.ts +12 -0
  35. package/dist/ast/{ObjectCompoundType.js → StructCompoundType.js} +18 -18
  36. package/dist/ast/StructIntersectionType.d.ts +4 -0
  37. package/dist/ast/StructIntersectionType.js +2 -0
  38. package/dist/ast/{ObjectType.d.ts → StructType.d.ts} +28 -27
  39. package/dist/ast/{ObjectType.js → StructType.js} +81 -78
  40. package/dist/ast/StructUnionType.d.ts +4 -0
  41. package/dist/ast/StructUnionType.js +2 -0
  42. package/dist/ast/Type.d.ts +5 -5
  43. package/dist/ast/Type.js +4 -4
  44. package/dist/ast/UnionType.d.ts +2 -2
  45. package/dist/ast/UnionType.js +3 -3
  46. package/dist/ast/index.d.ts +7 -7
  47. package/dist/ast/index.js +7 -7
  48. package/dist/generators/AstJsonGenerator.js +2 -2
  49. package/dist/generators/transformAstToLabeledPropertyGraph.js +8 -8
  50. package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
  51. package/dist/generators/ts/AbstractContainerType.js +6 -6
  52. package/dist/generators/ts/AbstractDateType.d.ts +1 -7
  53. package/dist/generators/ts/AbstractDateType.js +1 -11
  54. package/dist/generators/ts/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +7 -7
  55. package/dist/generators/ts/{AbstractLazyObjectType.js → AbstractLazyType.js} +19 -17
  56. package/dist/generators/ts/AbstractLiteralType.d.ts +2 -5
  57. package/dist/generators/ts/AbstractLiteralType.js +0 -21
  58. package/dist/generators/ts/AbstractNumericType.d.ts +1 -7
  59. package/dist/generators/ts/AbstractNumericType.js +15 -25
  60. package/dist/generators/ts/AbstractObjectSetType.d.ts +1 -1
  61. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  62. package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -1
  63. package/dist/generators/ts/AbstractPrimitiveType.js +1 -1
  64. package/dist/generators/ts/AbstractTermType.d.ts +6 -21
  65. package/dist/generators/ts/AbstractTermType.js +26 -55
  66. package/dist/generators/ts/AbstractType.d.ts +40 -47
  67. package/dist/generators/ts/AbstractType.js +17 -6
  68. package/dist/generators/ts/BigDecimalType.d.ts +3 -3
  69. package/dist/generators/ts/BigDecimalType.js +3 -8
  70. package/dist/generators/ts/BigIntType.d.ts +2 -2
  71. package/dist/generators/ts/BigIntType.js +7 -4
  72. package/dist/generators/ts/BlankNodeType.d.ts +2 -7
  73. package/dist/generators/ts/BlankNodeType.js +2 -7
  74. package/dist/generators/ts/BooleanType.d.ts +3 -3
  75. package/dist/generators/ts/BooleanType.js +12 -14
  76. package/dist/generators/ts/DateTimeType.d.ts +2 -2
  77. package/dist/generators/ts/DateTimeType.js +14 -4
  78. package/dist/generators/ts/DateType.d.ts +2 -2
  79. package/dist/generators/ts/DateType.js +14 -4
  80. package/dist/generators/ts/DefaultValueType.d.ts +8 -8
  81. package/dist/generators/ts/DefaultValueType.js +10 -12
  82. package/dist/generators/ts/FloatType.d.ts +2 -2
  83. package/dist/generators/ts/FloatType.js +7 -4
  84. package/dist/generators/ts/IdentifierType.d.ts +2 -2
  85. package/dist/generators/ts/IdentifierType.js +2 -7
  86. package/dist/generators/ts/IntType.d.ts +2 -2
  87. package/dist/generators/ts/IntType.js +7 -4
  88. package/dist/generators/ts/IriType.d.ts +2 -2
  89. package/dist/generators/ts/IriType.js +12 -14
  90. package/dist/generators/ts/{LazyObjectOptionType.d.ts → LazyOptionType.d.ts} +12 -11
  91. package/dist/generators/ts/{LazyObjectOptionType.js → LazyOptionType.js} +23 -14
  92. package/dist/generators/ts/LazySetType.d.ts +20 -0
  93. package/dist/generators/ts/{LazyObjectSetType.js → LazySetType.js} +22 -13
  94. package/dist/generators/ts/LazyType.d.ts +19 -0
  95. package/dist/generators/ts/{LazyObjectType.js → LazyType.js} +22 -13
  96. package/dist/generators/ts/ListType.d.ts +1 -1
  97. package/dist/generators/ts/ListType.js +9 -19
  98. package/dist/generators/ts/LiteralType.d.ts +3 -2
  99. package/dist/generators/ts/LiteralType.js +6 -2
  100. package/dist/generators/ts/ObjectType.d.ts +16 -3
  101. package/dist/generators/ts/ObjectType.js +301 -91
  102. package/dist/generators/ts/ObjectUnionType.js +40 -40
  103. package/dist/generators/ts/OptionType.d.ts +2 -2
  104. package/dist/generators/ts/OptionType.js +7 -5
  105. package/dist/generators/ts/SetType.d.ts +3 -3
  106. package/dist/generators/ts/SetType.js +8 -10
  107. package/dist/generators/ts/Snippets.d.ts +26 -8
  108. package/dist/generators/ts/Snippets.js +161 -35
  109. package/dist/generators/ts/StringType.d.ts +4 -3
  110. package/dist/generators/ts/StringType.js +18 -11
  111. package/dist/generators/ts/TermType.d.ts +7 -5
  112. package/dist/generators/ts/TermType.js +28 -9
  113. package/dist/generators/ts/TsGenerator.js +11 -6
  114. package/dist/generators/ts/Type.d.ts +4 -4
  115. package/dist/generators/ts/TypeFactory.d.ts +5 -5
  116. package/dist/generators/ts/TypeFactory.js +79 -58
  117. package/dist/generators/ts/UnionType.d.ts +23 -18
  118. package/dist/generators/ts/UnionType.js +227 -221
  119. package/dist/generators/ts/ZodGenerator.js +15 -7
  120. package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +24 -15
  121. package/dist/generators/ts/_ObjectType/AbstractProperty.js +1 -24
  122. package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +8 -6
  123. package/dist/generators/ts/_ObjectType/DiscriminantProperty.js +11 -24
  124. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +8 -2
  125. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +44 -16
  126. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.d.ts +4 -0
  127. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.js +28 -0
  128. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.d.ts +4 -0
  129. package/dist/generators/ts/_ObjectType/{ObjectType_equalsFunctionDeclaration.js → ObjectType_equalsFunctionExpression.js} +6 -10
  130. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.d.ts +4 -0
  131. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +12 -0
  132. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeExpression.d.ts +4 -0
  133. package/dist/generators/ts/_ObjectType/{ObjectType_filterTypeDeclaration.js → ObjectType_filterTypeExpression.js} +6 -8
  134. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_focusSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  135. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionExpression.js} +5 -9
  136. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_focusSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  137. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → ObjectType_focusSparqlWherePatternsFunctionExpression.js} +5 -9
  138. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.d.ts +4 -0
  139. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.js +12 -0
  140. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.d.ts +4 -0
  141. package/dist/generators/ts/_ObjectType/{ObjectType_fromRdfResourceFunctionDeclaration.js → ObjectType_fromRdfResourceFunctionExpression.js} +8 -16
  142. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeExpression.d.ts +4 -0
  143. package/dist/generators/ts/_ObjectType/{ObjectType_graphqlTypeVariableStatement.js → ObjectType_graphqlTypeExpression.js} +6 -13
  144. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.d.ts +4 -0
  145. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +30 -0
  146. package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +4 -0
  147. package/dist/generators/ts/_ObjectType/{identifierTypeDeclarations.js → ObjectType_identifierTypeDeclarations.js} +2 -5
  148. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +3 -3
  149. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +1 -2
  150. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.js +2 -6
  151. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.d.ts +4 -0
  152. package/dist/generators/ts/_ObjectType/{ObjectType_jsonSchemaFunctionDeclaration.js → ObjectType_jsonSchemaExpression.js} +3 -10
  153. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.d.ts +4 -0
  154. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.js +5 -0
  155. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.d.ts +4 -0
  156. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js +17 -0
  157. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +1 -1
  158. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.js +2 -2
  159. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +4 -0
  160. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +18 -0
  161. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +4 -0
  162. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +18 -0
  163. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -3
  164. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +5 -9
  165. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -3
  166. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +4 -8
  167. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.d.ts +4 -0
  168. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +14 -0
  169. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.d.ts +4 -0
  170. package/dist/generators/ts/_ObjectType/{ObjectType_toRdfResourceFunctionDeclaration.js → ObjectType_toRdfResourceFunctionExpression.js} +6 -12
  171. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.d.ts +4 -0
  172. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.js +7 -0
  173. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.d.ts +4 -0
  174. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.js +5 -0
  175. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_valueSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  176. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionExpression.js +8 -0
  177. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_valueSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  178. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionExpression.js +10 -0
  179. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +9 -2
  180. package/dist/generators/ts/_ObjectType/ShaclProperty.js +65 -33
  181. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +4 -3
  182. package/dist/generators/ts/_snippets/snippets_DateSchema.js +4 -3
  183. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
  184. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +6 -5
  185. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +2 -1
  186. package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -0
  187. package/dist/generators/ts/_snippets/snippets_Lazy.d.ts +3 -0
  188. package/dist/generators/ts/_snippets/snippets_Lazy.js +22 -0
  189. package/dist/generators/ts/_snippets/snippets_LazyOption.d.ts +3 -0
  190. package/dist/generators/ts/_snippets/snippets_LazyOption.js +25 -0
  191. package/dist/generators/ts/_snippets/snippets_LazySet.d.ts +3 -0
  192. package/dist/generators/ts/_snippets/snippets_LazySet.js +40 -0
  193. package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +1 -3
  194. package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -0
  195. package/dist/generators/ts/_snippets/snippets_NumericSchema.js +2 -1
  196. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +6 -8
  197. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +32 -32
  198. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
  199. package/dist/generators/ts/_snippets/snippets_StringSchema.js +5 -3
  200. package/dist/generators/ts/_snippets/snippets_TermFilter.js +3 -3
  201. package/dist/generators/ts/_snippets/snippets_TermSchema.js +4 -2
  202. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.d.ts +3 -0
  203. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +6 -0
  204. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.d.ts +3 -0
  205. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.js +6 -0
  206. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.d.ts +3 -0
  207. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.js +6 -0
  208. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.d.ts +3 -0
  209. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.js +6 -0
  210. package/dist/generators/ts/_snippets/snippets_convertToLazy.d.ts +3 -0
  211. package/dist/generators/ts/_snippets/snippets_convertToLazy.js +15 -0
  212. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.d.ts +3 -0
  213. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.js +33 -0
  214. package/dist/generators/ts/_snippets/snippets_convertToLazySet.d.ts +3 -0
  215. package/dist/generators/ts/_snippets/snippets_convertToLazySet.js +27 -0
  216. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.d.ts +3 -0
  217. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.js +6 -0
  218. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.d.ts +3 -0
  219. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.js +6 -0
  220. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.d.ts +3 -0
  221. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.js +10 -0
  222. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  223. package/dist/generators/ts/_snippets/snippets_filterNumeric.js +1 -1
  224. package/dist/generators/ts/_snippets/snippets_filterTerm.js +1 -2
  225. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.d.ts +3 -0
  226. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.js +6 -0
  227. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.d.ts +3 -0
  228. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.js +6 -0
  229. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.d.ts +3 -0
  230. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.js +6 -0
  231. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.d.ts +3 -0
  232. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.js +6 -0
  233. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.d.ts +3 -0
  234. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.js +15 -0
  235. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.d.ts +3 -0
  236. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +6 -0
  237. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.d.ts +3 -0
  238. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.js +11 -0
  239. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.d.ts +3 -0
  240. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.js +8 -0
  241. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.d.ts +3 -0
  242. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.js +8 -0
  243. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +1 -1
  244. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.d.ts +3 -0
  245. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.js +9 -0
  246. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +13 -7
  247. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.d.ts +3 -0
  248. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.js +6 -0
  249. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +1 -1
  250. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.d.ts +3 -0
  251. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +17 -0
  252. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.d.ts +3 -0
  253. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +60 -0
  254. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
  255. package/dist/input/generated.d.ts +464 -389
  256. package/dist/input/generated.js +1748 -2294
  257. package/package.json +2 -2
  258. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +0 -9
  259. package/dist/ast/LazyObjectOptionType.d.ts +0 -6
  260. package/dist/ast/LazyObjectOptionType.js +0 -5
  261. package/dist/ast/LazyObjectSetType.d.ts +0 -6
  262. package/dist/ast/LazyObjectSetType.js +0 -5
  263. package/dist/ast/LazyObjectType.d.ts +0 -5
  264. package/dist/ast/LazyObjectType.js +0 -5
  265. package/dist/ast/ObjectCompoundType.d.ts +0 -12
  266. package/dist/ast/ObjectIntersectionType.d.ts +0 -4
  267. package/dist/ast/ObjectIntersectionType.js +0 -2
  268. package/dist/ast/ObjectUnionType.d.ts +0 -4
  269. package/dist/ast/ObjectUnionType.js +0 -2
  270. package/dist/generators/ts/LazyObjectSetType.d.ts +0 -20
  271. package/dist/generators/ts/LazyObjectType.d.ts +0 -19
  272. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
  273. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +0 -44
  274. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +0 -5
  275. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -5
  276. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +0 -21
  277. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -5
  278. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  279. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +0 -18
  280. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  281. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  282. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  283. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  284. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.js +0 -10
  285. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  286. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +0 -4
  287. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +0 -41
  288. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
  289. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +0 -12
  290. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  291. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  292. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +0 -9
  293. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  294. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +0 -15
  295. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -5
  296. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +0 -12
  297. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  298. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +0 -20
  299. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  300. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +0 -4
  301. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.js +0 -29
  302. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +0 -11
  303. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +0 -13
  304. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
  305. package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +0 -3
  306. package/dist/generators/ts/_snippets/snippets_LazyObject.js +0 -22
  307. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +0 -3
  308. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +0 -25
  309. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +0 -3
  310. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +0 -40
  311. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +0 -3
  312. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +0 -15
  313. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +0 -3
  314. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +0 -31
  315. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +0 -3
  316. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +0 -25
  317. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +0 -3
  318. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +0 -15
  319. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +0 -3
  320. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +0 -23
@@ -6,6 +6,7 @@ import type * as ast from "./ast/index.js";
6
6
  import type * as input from "./input/index.js";
7
7
  export declare class ShapesGraphToAstTransformer {
8
8
  protected readonly cachedAstTypesByShapeIdentifier: TermMap<BlankNode | NamedNode, ast.Type>;
9
+ protected readonly syntheticAstStructTypesByName: Map<string, ast.StructType>;
9
10
  protected readonly logger: Logger;
10
11
  protected readonly shapesGraph: input.ShapesGraph;
11
12
  constructor({ logger, shapesGraph, }: {
@@ -1,12 +1,11 @@
1
1
  import TermMap from "@rdfjs/term-map";
2
- import { dash } from "@tpluscode/rdf-ns-builders";
3
2
  import { Either } from "purify-ts";
4
- import { invariant } from "ts-invariant";
5
3
  import { ShapeStack } from "./_ShapesGraphToAstTransformer/ShapeStack.js";
6
4
  import { transformShapeToAstType } from "./_ShapesGraphToAstTransformer/transformShapeToAstType.js";
7
5
  export class ShapesGraphToAstTransformer {
8
6
  // Members are protected so they're accessible to functions in other files
9
7
  cachedAstTypesByShapeIdentifier = new TermMap();
8
+ syntheticAstStructTypesByName = new Map();
10
9
  logger;
11
10
  shapesGraph;
12
11
  constructor({ logger, shapesGraph, }) {
@@ -15,67 +14,33 @@ export class ShapesGraphToAstTransformer {
15
14
  }
16
15
  transform() {
17
16
  const astNamedTypes = [];
18
- const syntheticAstObjectTypesByName = {};
19
17
  for (const nodeShape of this.shapesGraph.nodeShapes) {
20
18
  if (nodeShape.$identifier().termType !== "NamedNode") {
21
19
  continue;
22
20
  }
23
- if (nodeShape.$identifier().value.startsWith(dash[""].value)) {
24
- continue;
25
- }
26
21
  const nodeShapeAstTypeEither = transformShapeToAstType.call(this, nodeShape, new ShapeStack());
27
22
  if (nodeShapeAstTypeEither.isLeft()) {
28
23
  return nodeShapeAstTypeEither;
29
24
  }
30
25
  const nodeShapeAstType = nodeShapeAstTypeEither.unsafeCoerce();
31
- switch (nodeShapeAstType.kind) {
32
- case "Intersection":
33
- case "Union":
34
- if (nodeShapeAstType.name.isJust()) {
35
- astNamedTypes.push(nodeShapeAstType);
36
- }
37
- break;
38
- case "Object": {
39
- invariant(nodeShapeAstType.name.isJust(), `node shape missing name: ${nodeShapeAstType.shapeIdentifier}`);
40
- astNamedTypes.push(nodeShapeAstType);
41
- for (const property of nodeShapeAstType.properties) {
42
- switch (property.type.kind) {
43
- case "LazyObjectOption":
44
- case "LazyObjectSet":
45
- case "LazyObject": {
46
- const partialItemType = property.type.partialType.kind === "Object" ||
47
- property.type.partialType.kind === "Union"
48
- ? property.type.partialType
49
- : property.type.partialType.itemType;
50
- if (partialItemType.kind === "Object" &&
51
- partialItemType.synthetic) {
52
- const partialItemTypeName = partialItemType.name.unsafeCoerce();
53
- if (!syntheticAstObjectTypesByName[partialItemTypeName]) {
54
- syntheticAstObjectTypesByName[partialItemTypeName] =
55
- partialItemType;
56
- }
57
- }
58
- }
59
- }
60
- }
61
- break;
62
- }
63
- default:
64
- break;
65
- }
26
+ nodeShapeAstType.name.ifJust(() => {
27
+ astNamedTypes.push(nodeShapeAstType);
28
+ });
66
29
  }
67
30
  return Either.of({
68
31
  lazyTypesCount: [...this.cachedAstTypesByShapeIdentifier.values()].reduce((acc, astType) => {
69
32
  switch (astType.kind) {
70
- case "LazyObject":
71
- case "LazyObjectOption":
72
- case "LazyObjectSet":
33
+ case "Lazy":
34
+ case "LazyOption":
35
+ case "LazySet":
73
36
  return acc + 1;
74
37
  default:
75
38
  return acc;
76
39
  }
77
40
  }, 0),
78
- namedTypes: astNamedTypes.concat(Object.values(syntheticAstObjectTypesByName)),
41
+ namedTypes: astNamedTypes.concat([
42
+ ...this.syntheticAstStructTypesByName.values(),
43
+ ]),
79
44
  });
80
45
  }
81
46
  }
@@ -0,0 +1,17 @@
1
+ import { Either, Maybe } from "purify-ts";
2
+ import * as ast from "../ast/index.js";
3
+ import type * as input from "../input/index.js";
4
+ import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
5
+ /**
6
+ * Try to transform a property shape to an ast.StructType.Field.
7
+ *
8
+ * Returns:
9
+ * - Right<Just<ast.StructType.Field>> if the transformation succeeds
10
+ * - Right<Nothing> if the property shape should be ignored
11
+ * - Left<Error> if the transformation fails
12
+ */
13
+ export declare function transformPropertyShapeToAstStructTypeField(this: ShapesGraphToAstTransformer, { propertyShape, structType, }: {
14
+ propertyShape: input.PropertyShape;
15
+ structType: ast.StructType;
16
+ }): Either<Error, Maybe<ast.StructType.Field>>;
17
+ //# sourceMappingURL=transformPropertyShapeToAstStructTypeField.d.ts.map
@@ -1,37 +1,13 @@
1
1
  import dataFactory from "@rdfx/data-factory";
2
2
  import { Curie } from "@shaclmate/shacl-ast";
3
+ import { sh } from "@tpluscode/rdf-ns-builders";
3
4
  import { Either, Left, Maybe } from "purify-ts";
4
5
  import { invariant } from "ts-invariant";
5
6
  import * as ast from "../ast/index.js";
6
7
  import { Eithers } from "../Eithers.js";
7
8
  import { ShapeStack } from "./ShapeStack.js";
8
9
  import { transformShapeToAstType } from "./transformShapeToAstType.js";
9
- function synthesizePartialAstObjectType({ identifierType, }) {
10
- let syntheticName;
11
- switch (identifierType.kind) {
12
- case "BlankNode":
13
- throw new Error("should never happen");
14
- case "Identifier":
15
- syntheticName = "DefaultPartial";
16
- break;
17
- case "Iri":
18
- syntheticName = "NamedDefaultPartial";
19
- break;
20
- }
21
- return new ast.ObjectType({
22
- comment: Maybe.empty(),
23
- extern: false,
24
- fromRdfType: Maybe.empty(),
25
- identifierType,
26
- label: Maybe.empty(),
27
- name: Maybe.of(syntheticName),
28
- shapeIdentifier: dataFactory.namedNode(`urn:shaclmate:synthetic:${syntheticName}`),
29
- synthetic: true,
30
- toRdfTypes: [],
31
- tsImports: [],
32
- });
33
- }
34
- function propertyName(objectType, propertyShape) {
10
+ function fieldName(propertyShape, structType) {
35
11
  // Explicit shaclmate:name or sh:name
36
12
  const name = propertyShape.shaclmateName.alt(propertyShape.name).extract();
37
13
  if (name) {
@@ -46,8 +22,8 @@ function propertyName(objectType, propertyShape) {
46
22
  // like ex:NodeShape-property
47
23
  const propertyShapeIdentifier = propertyShape.$identifier();
48
24
  if (propertyShapeIdentifier.termType === "NamedNode" &&
49
- objectType.shapeIdentifier.termType === "NamedNode") {
50
- const propertyShapeIdentifierPrefix = `${objectType.shapeIdentifier.value}-`;
25
+ structType.shapeIdentifier.termType === "NamedNode") {
26
+ const propertyShapeIdentifierPrefix = `${structType.shapeIdentifier.value}-`;
51
27
  if (propertyShapeIdentifier.value.startsWith(propertyShapeIdentifierPrefix) &&
52
28
  propertyShapeIdentifier.value.length >
53
29
  propertyShapeIdentifierPrefix.length) {
@@ -72,6 +48,37 @@ function propertyName(objectType, propertyShape) {
72
48
  }
73
49
  throw new Error(`${propertyShape}: unable to infer name`);
74
50
  }
51
+ function synthesizePartialAstStructType({ identifierType, }) {
52
+ let syntheticName;
53
+ switch (identifierType.kind) {
54
+ case "BlankNode":
55
+ throw new Error("should never happen");
56
+ case "Identifier":
57
+ syntheticName = "DefaultPartial";
58
+ break;
59
+ case "Iri":
60
+ syntheticName = "NamedDefaultPartial";
61
+ break;
62
+ }
63
+ let partialAstStructType = this.syntheticAstStructTypesByName.get(syntheticName);
64
+ if (partialAstStructType) {
65
+ return partialAstStructType;
66
+ }
67
+ partialAstStructType = new ast.StructType({
68
+ comment: Maybe.empty(),
69
+ extern: false,
70
+ fromRdfType: Maybe.empty(),
71
+ identifierType,
72
+ label: Maybe.empty(),
73
+ name: Maybe.of(syntheticName),
74
+ shapeIdentifier: dataFactory.namedNode(`urn:shaclmate:synthetic:${syntheticName}`),
75
+ synthetic: true,
76
+ toRdfTypes: [],
77
+ tsImports: [],
78
+ });
79
+ this.syntheticAstStructTypesByName.set(syntheticName, partialAstStructType);
80
+ return partialAstStructType;
81
+ }
75
82
  function transformPropertyShapeToAstType(propertyShape, shapeStack) {
76
83
  // if (
77
84
  // propertyShape.path.kind === "PredicatePath" &&
@@ -122,7 +129,23 @@ function transformPropertyShapeToAstType(propertyShape, shapeStack) {
122
129
  }));
123
130
  });
124
131
  }
125
- export function transformPropertyShapeToAstObjectTypeProperty({ objectType, propertyShape, }) {
132
+ /**
133
+ * Try to transform a property shape to an ast.StructType.Field.
134
+ *
135
+ * Returns:
136
+ * - Right<Just<ast.StructType.Field>> if the transformation succeeds
137
+ * - Right<Nothing> if the property shape should be ignored
138
+ * - Left<Error> if the transformation fails
139
+ */
140
+ export function transformPropertyShapeToAstStructTypeField({ propertyShape, structType, }) {
141
+ if (propertyShape.ignore) {
142
+ return Either.of(Maybe.empty());
143
+ }
144
+ switch (propertyShape.severity.orDefault(sh.Violation).value) {
145
+ case "http://www.w3.org/ns/shacl#Info":
146
+ case "http://www.w3.org/ns/shacl#Warning":
147
+ return Either.of(Maybe.empty());
148
+ }
126
149
  const shapeStack = new ShapeStack(); // Start a new ShapeStack per property shape
127
150
  return Eithers.chain2(propertyShape.resolve.isJust()
128
151
  ? this.shapesGraph
@@ -135,14 +158,14 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
135
158
  .call(this, propertyShapeResolve.unsafeCoerce(), shapeStack)
136
159
  .chain((astResolveType) => {
137
160
  switch (astResolveType.kind) {
138
- case "Object":
161
+ case "Struct":
139
162
  return Either.of(astResolveType);
140
163
  case "Union":
141
164
  if (
142
165
  // This check relies on .members being populated, which may not happen in cycles
143
166
  astResolveType.members.length > 0 &&
144
- !astResolveType.isObjectUnionType()) {
145
- return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind} with non-ObjectType members`));
167
+ !astResolveType.isStructUnionType()) {
168
+ return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind} with non-StructType members`));
146
169
  }
147
170
  return Either.of(astResolveType);
148
171
  default:
@@ -162,10 +185,10 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
162
185
  case "Set":
163
186
  astItemType = astType.itemType;
164
187
  break;
165
- case "LazyObjectOption":
166
- case "LazyObjectSet":
188
+ case "LazyOption":
189
+ case "LazySet":
167
190
  // biome-ignore lint/suspicious/noFallthroughSwitchClause: break is unreachable
168
- case "LazyObject":
191
+ case "Lazy":
169
192
  invariant(false, `lazy types should not appear here: ${astType.kind}`);
170
193
  default:
171
194
  astItemType = astType;
@@ -176,16 +199,16 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
176
199
  case "BlankNode":
177
200
  case "Identifier":
178
201
  case "Iri":
179
- astPartialItemType = synthesizePartialAstObjectType({
202
+ astPartialItemType = synthesizePartialAstStructType.call(this, {
180
203
  identifierType: astItemType,
181
204
  });
182
205
  break;
183
- case "Object":
206
+ case "Struct":
184
207
  astPartialItemType = astItemType;
185
208
  break;
186
209
  case "Union":
187
- if (!astItemType.isObjectUnionType()) {
188
- return Left(new Error(`${propertyShape} partial type cannot be a ${astItemType.kind} with non-ObjectType members`));
210
+ if (!astItemType.isStructUnionType()) {
211
+ return Left(new Error(`${propertyShape} partial type cannot be a ${astItemType.kind} with non-StructType members`));
189
212
  }
190
213
  astPartialItemType = astItemType;
191
214
  break;
@@ -202,16 +225,16 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
202
225
  case "BlankNode":
203
226
  case "Identifier":
204
227
  case "Iri":
205
- case "Object":
228
+ case "Struct":
206
229
  case "Union":
207
- astType = new ast.LazyObjectType({
230
+ astType = new ast.LazyType({
208
231
  ...astAbstractTypeProperties,
209
232
  partialType: astPartialItemType,
210
233
  resolveType: astResolveItemType,
211
234
  });
212
235
  break;
213
236
  case "Option":
214
- astType = new ast.LazyObjectOptionType({
237
+ astType = new ast.LazyOptionType({
215
238
  ...astAbstractTypeProperties,
216
239
  partialType: new ast.OptionType({
217
240
  itemType: astPartialItemType,
@@ -222,7 +245,7 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
222
245
  });
223
246
  break;
224
247
  case "Set":
225
- astType = new ast.LazyObjectSetType({
248
+ astType = new ast.LazySetType({
226
249
  ...astAbstractTypeProperties,
227
250
  partialType: new ast.SetType({
228
251
  itemType: astPartialItemType,
@@ -244,19 +267,19 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
244
267
  astType.nodeKinds.has("Literal")) {
245
268
  return Left(new Error(`${propertyShape}: property shapes with inverse paths can only have blank node or IRI node kinds`));
246
269
  }
247
- return Either.of(new ast.ObjectType.Property({
270
+ return Either.of(Maybe.of(new ast.StructType.Field({
248
271
  comment: propertyShape.comment,
249
272
  description: propertyShape.description,
250
273
  display: propertyShape.display,
251
274
  label: propertyShape.label,
252
275
  mutable: propertyShape.mutable.orDefault(false),
253
- name: propertyName.call(this, objectType, propertyShape),
254
- objectType,
276
+ name: fieldName.call(this, propertyShape, structType),
255
277
  order: propertyShape.order.orDefault(0),
256
278
  path: propertyShape.path,
257
279
  shapeIdentifier: propertyShape.$identifier(),
280
+ structType,
258
281
  type: astType,
259
- }));
282
+ })));
260
283
  });
261
284
  }
262
- //# sourceMappingURL=transformPropertyShapeToAstObjectTypeProperty.js.map
285
+ //# sourceMappingURL=transformPropertyShapeToAstStructTypeField.js.map
@@ -4,7 +4,7 @@ import type * as input from "../input/index.js";
4
4
  import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
5
5
  import type { ShapeStack } from "./ShapeStack.js";
6
6
  /**
7
- * Is an ast.ObjectType actually the shape of an RDF list?
7
+ * Is an ast.StructType actually the shape of an RDF list?
8
8
  * If so, return the type of its rdf:first.
9
9
  */
10
10
  export declare function transformShapeToAstListType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.ListType>>;
@@ -4,10 +4,9 @@ import { Either, Left, Maybe } from "purify-ts";
4
4
  import * as ast from "../ast/index.js";
5
5
  import { Eithers } from "../Eithers.js";
6
6
  import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
7
- import { shapeAstTypeName } from "./shapeAstTypeName.js";
8
7
  import { shapeNodeKinds } from "./shapeNodeKinds.js";
9
- import { transformPropertyShapeToAstObjectTypeProperty } from "./transformPropertyShapeToAstObjectTypeProperty.js";
10
- const listPropertiesObjectType = new ast.ObjectType({
8
+ import { transformPropertyShapeToAstStructTypeField } from "./transformPropertyShapeToAstStructTypeField.js";
9
+ const listPropertiesStructType = new ast.StructType({
11
10
  extern: false,
12
11
  comment: Maybe.empty(),
13
12
  label: Maybe.empty(),
@@ -32,7 +31,7 @@ const astListTypePlaceholderItemType = new ast.BlankNodeType({
32
31
  });
33
32
  const empty = Either.of(Maybe.empty());
34
33
  /**
35
- * Is an ast.ObjectType actually the shape of an RDF list?
34
+ * Is an ast.StructType actually the shape of an RDF list?
36
35
  * If so, return the type of its rdf:first.
37
36
  */
38
37
  export function transformShapeToAstListType(shape, shapeStack) {
@@ -53,7 +52,9 @@ export function transformShapeToAstListType(shape, shapeStack) {
53
52
  itemType: astListTypePlaceholderItemType,
54
53
  label: nodeShape.label,
55
54
  mutable: nodeShape.mutable.orDefault(false),
56
- name: shapeAstTypeName(nodeShape),
55
+ // name: shapeAstTypeName(nodeShape),
56
+ // List types don't need names currently
57
+ name: Maybe.empty(),
57
58
  shapeIdentifier: nodeShape.$identifier(),
58
59
  toRdfTypes: nodeShape.toRdfTypes,
59
60
  });
@@ -74,10 +75,10 @@ export function transformShapeToAstListType(shape, shapeStack) {
74
75
  if (!emptyListShape || !nonEmptyListShape) {
75
76
  return empty;
76
77
  }
77
- return Either.sequence(nonEmptyListShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier))).chain((nonEmptyListShapeProperties) => {
78
+ return Either.sequence(nonEmptyListShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier))).chain((nonEmptyListShapePropertyShapes) => {
78
79
  let firstPropertyShape;
79
80
  let restPropertyShape;
80
- for (const propertyShape of nonEmptyListShapeProperties) {
81
+ for (const propertyShape of nonEmptyListShapePropertyShapes) {
81
82
  if (propertyShape.path.termType !== "NamedNode") {
82
83
  continue;
83
84
  }
@@ -102,26 +103,34 @@ export function transformShapeToAstListType(shape, shapeStack) {
102
103
  restPropertyShape.minCount.extract() !== 1n) {
103
104
  return Left(new Error(`${nodeShape} non-empty list shape rdf:rest property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
104
105
  }
105
- return transformPropertyShapeToAstObjectTypeProperty
106
+ return transformPropertyShapeToAstStructTypeField
106
107
  .call(this, {
107
- // Just need a dummy ast.ObjectType here to get the properties transformed.
108
- objectType: listPropertiesObjectType,
108
+ // Just need a dummy ast.StructType here to get the properties transformed.
109
109
  propertyShape: firstPropertyShape,
110
+ structType: listPropertiesStructType,
110
111
  })
111
- .chain((firstProperty) => {
112
- if (!ast.ListType.isItemType(firstProperty.type)) {
113
- return Left(new Error(`${nodeShape}: ${firstProperty.type.kind} is not a valid list item type`));
112
+ .chain((firstFieldMaybe) => {
113
+ const firstField = firstFieldMaybe.extract();
114
+ if (!firstField) {
115
+ return Left(new Error(`${nodeShape}: rdf:first field is ignored`));
114
116
  }
115
- listType.itemType = firstProperty.type;
116
- return transformPropertyShapeToAstObjectTypeProperty
117
+ if (!ast.ListType.isItemType(firstField.type)) {
118
+ return Left(new Error(`${nodeShape}: ${firstField.type.kind} is not a valid list item type`));
119
+ }
120
+ listType.itemType = firstField.type;
121
+ return transformPropertyShapeToAstStructTypeField
117
122
  .call(this, {
118
- // Just need a dummy ast.ObjectType here to get the properties transformed.
119
- objectType: listPropertiesObjectType,
123
+ // Just need a dummy ast.StructType here to get the properties transformed.
120
124
  propertyShape: restPropertyShape,
125
+ structType: listPropertiesStructType,
121
126
  })
122
- .chain((restProperty) => {
123
- if (restProperty.type.kind !== "List" ||
124
- !restProperty.type.shapeIdentifier.equals(nodeShape.$identifier())) {
127
+ .chain((restFieldMaybe) => {
128
+ const restField = restFieldMaybe.extract();
129
+ if (!restField) {
130
+ return Left(new Error(`${nodeShape}: rdf:rest field is ignored`));
131
+ }
132
+ if (restField.type.kind !== "List" ||
133
+ !restField.type.shapeIdentifier.equals(nodeShape.$identifier())) {
125
134
  return Left(new Error(`${nodeShape} rdf:rest property is not recursive into the node shape`));
126
135
  }
127
136
  return Either.of(Maybe.of(listType));
@@ -3,5 +3,5 @@ import * as ast from "../ast/index.js";
3
3
  import type * as input from "../input/index.js";
4
4
  import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
5
5
  import type { ShapeStack } from "./ShapeStack.js";
6
- export declare function transformShapeToAstObjectType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.Type>>;
7
- //# sourceMappingURL=transformShapeToAstObjectType.d.ts.map
6
+ export declare function transformShapeToAstStructType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.Type>>;
7
+ //# sourceMappingURL=transformShapeToAstStructType.d.ts.map
@@ -6,41 +6,42 @@ import { Eithers } from "../Eithers.js";
6
6
  import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
7
7
  import { shapeAstTypeName } from "./shapeAstTypeName.js";
8
8
  import { shapeNodeKinds } from "./shapeNodeKinds.js";
9
- import { transformPropertyShapeToAstObjectTypeProperty } from "./transformPropertyShapeToAstObjectTypeProperty.js";
9
+ import { transformPropertyShapeToAstStructTypeField } from "./transformPropertyShapeToAstStructTypeField.js";
10
10
  import { transformShapeToAstType } from "./transformShapeToAstType.js";
11
- function isObjectTypePropertyRequired(property) {
12
- switch (property.type.kind) {
11
+ function isStructTypeFieldRequired(field) {
12
+ switch (field.type.kind) {
13
13
  case "DefaultValue":
14
14
  return false;
15
- case "LazyObjectOption":
15
+ case "LazyOption":
16
16
  return false;
17
- case "LazyObjectSet":
18
- return property.type.partialType.minCount > 0n;
17
+ case "LazySet":
18
+ return field.type.partialType.minCount > 0n;
19
19
  case "Option":
20
20
  return false;
21
21
  case "Set":
22
- return property.type.minCount > 0;
22
+ return field.type.minCount > 0;
23
23
  case "Union":
24
- return property.type.members.every((member) => isObjectTypePropertyRequired({ type: member.type }));
24
+ return field.type.members.every((member) => isStructTypeFieldRequired({ type: member.type }));
25
25
  case "BlankNode":
26
26
  case "Identifier":
27
27
  case "Iri":
28
- case "LazyObject":
28
+ case "Lazy":
29
29
  case "List":
30
30
  case "Literal":
31
- case "Object":
31
+ case "Struct":
32
32
  case "Term":
33
33
  return true;
34
34
  case "Intersection":
35
35
  throw new Error("unsupported");
36
36
  default:
37
- property.type;
37
+ field.type;
38
38
  throw new Error("should never reach this point");
39
39
  }
40
40
  }
41
- export function transformShapeToAstObjectType(shape, shapeStack) {
41
+ export function transformShapeToAstStructType(shape, shapeStack) {
42
42
  shapeStack.push(shape);
43
43
  try {
44
+ // If the shape has an sh:node itself then transform that instead
44
45
  if (shape.node.isJust()) {
45
46
  return this.shapesGraph
46
47
  .nodeShape(shape.node.unsafeCoerce())
@@ -55,9 +56,12 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
55
56
  nodeShape.xone.orDefault([]).length > 0) {
56
57
  return Either.of(Maybe.empty());
57
58
  }
58
- if (nodeShape.$identifier().termType !== "NamedNode") {
59
- return Either.of(Maybe.empty());
60
- }
59
+ if (!nodeShape.extern.orDefault(false)) {
60
+ if (nodeShape.properties.length === 0) {
61
+ // A node shape must have sh:property to be considered a StructType
62
+ return Either.of(Maybe.empty());
63
+ }
64
+ } // else assume all extern node shapes are structs
61
65
  return Eithers.chain2(shapeNodeKinds.call(this, nodeShape, { defaultNodeShapeNodeKinds }), Either.sequence(nodeShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier)))).chain(([nodeKinds, propertyShapes]) => {
62
66
  const nodeShapeIdentifier = nodeShape.$identifier();
63
67
  const isClass = nodeShape.subClassOf.length > 0 ||
@@ -114,7 +118,7 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
114
118
  // Remove the placeholder if the transformation fails.
115
119
  // If this node shape's properties (directly or indirectly) refer to the node shape itself,
116
120
  // we'll return this placeholder.
117
- const objectType = new ast.ObjectType({
121
+ const structType = new ast.StructType({
118
122
  comment: nodeShape.comment,
119
123
  extern: nodeShape.extern.orDefault(false),
120
124
  fromRdfType,
@@ -126,28 +130,30 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
126
130
  toRdfTypes,
127
131
  tsImports: nodeShape.tsImports,
128
132
  });
129
- this.cachedAstTypesByShapeIdentifier.set(nodeShape.$identifier(), objectType);
133
+ this.cachedAstTypesByShapeIdentifier.set(nodeShape.$identifier(), structType);
130
134
  return (() => {
131
135
  // Populate properties
132
136
  for (const propertyShape of propertyShapes) {
133
- const propertyEither = transformPropertyShapeToAstObjectTypeProperty.call(this, {
134
- objectType,
137
+ const fieldEither = transformPropertyShapeToAstStructTypeField.call(this, {
135
138
  propertyShape,
139
+ structType,
136
140
  });
137
- if (propertyEither.isLeft()) {
138
- return propertyEither;
141
+ if (fieldEither.isLeft()) {
142
+ return fieldEither;
139
143
  }
140
- propertyEither.ifRight((property) => {
141
- objectType.addProperties(property);
144
+ fieldEither.ifRight((property) => {
145
+ property.ifJust((property) => {
146
+ structType.addFields(property);
147
+ });
142
148
  });
143
149
  }
144
- if (!objectType.extern &&
145
- objectType.fromRdfType.isNothing() &&
146
- !objectType.properties.some(isObjectTypePropertyRequired)) {
150
+ if (!structType.extern &&
151
+ structType.fromRdfType.isNothing() &&
152
+ !structType.fields.some(isStructTypeFieldRequired)) {
147
153
  return Left(new Error(`${nodeShape} has no required properties and no implicitly required rdf:type`));
148
154
  }
149
- objectType.sortProperties();
150
- return Either.of(Maybe.of(objectType));
155
+ structType.sortFields();
156
+ return Either.of(Maybe.of(structType));
151
157
  })().ifLeft(() => {
152
158
  this.cachedAstTypesByShapeIdentifier.delete(nodeShape.$identifier());
153
159
  });
@@ -157,4 +163,4 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
157
163
  shapeStack.pop(shape);
158
164
  }
159
165
  }
160
- //# sourceMappingURL=transformShapeToAstObjectType.js.map
166
+ //# sourceMappingURL=transformShapeToAstStructType.js.map
@@ -1,6 +1,7 @@
1
1
  import { Either, Left, Maybe } from "purify-ts";
2
2
  import { invariant } from "ts-invariant";
3
3
  import * as ast from "../ast/index.js";
4
+ import { shapeAstTypeName } from "./shapeAstTypeName.js";
4
5
  import { shapeNodeKinds } from "./shapeNodeKinds.js";
5
6
  /**
6
7
  * Try to convert a shape to an AST TermType using some heuristics.
@@ -13,7 +14,7 @@ export function transformShapeToAstTermType(shape, shapeStack) {
13
14
  const in_ = shapeStack.constraints.in_;
14
15
  const astAbstractTypeProperties = {
15
16
  comment: Maybe.empty(),
16
- name: Maybe.empty(),
17
+ name: shapeAstTypeName(shape),
17
18
  label: Maybe.empty(),
18
19
  shapeIdentifier: shape.$identifier(),
19
20
  };
@@ -4,7 +4,7 @@ import type * as input from "../input/index.js";
4
4
  import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
5
5
  import type { ShapeStack } from "./ShapeStack.js";
6
6
  /**
7
- * Try to convert a shape to a type using some heuristics. All shape -> AST type transformation calls should go through this function,
7
+ * Try to transform a shape to an AST type using some heuristics. All shape -> AST type transformation calls should go through this function,
8
8
  * not the other transformShapeToAst*Type functions directly.
9
9
  */
10
10
  export declare function transformShapeToAstType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, ast.Type>;
@@ -1,15 +1,15 @@
1
1
  import { Either } from "purify-ts";
2
2
  import { transformShapeToAstCompoundType } from "./transformShapeToAstCompoundType.js";
3
3
  import { transformShapeToAstListType } from "./transformShapeToAstListType.js";
4
- import { transformShapeToAstObjectType } from "./transformShapeToAstObjectType.js";
4
+ import { transformShapeToAstStructType } from "./transformShapeToAstStructType.js";
5
5
  import { transformShapeToAstTermType } from "./transformShapeToAstTermType.js";
6
6
  const tryTransformShapeToAstTypeMethods = [
7
7
  transformShapeToAstListType, // List type must be before compound type since a list shape uses sh:xone
8
8
  transformShapeToAstCompoundType,
9
- transformShapeToAstObjectType,
9
+ transformShapeToAstStructType,
10
10
  ];
11
11
  /**
12
- * Try to convert a shape to a type using some heuristics. All shape -> AST type transformation calls should go through this function,
12
+ * Try to transform a shape to an AST type using some heuristics. All shape -> AST type transformation calls should go through this function,
13
13
  * not the other transformShapeToAst*Type functions directly.
14
14
  */
15
15
  export function transformShapeToAstType(shape, shapeStack) {
@@ -6,7 +6,7 @@ import type { IntersectionType } from "./IntersectionType.js";
6
6
  import type { IriType } from "./IriType.js";
7
7
  import type { ListType } from "./ListType.js";
8
8
  import type { LiteralType } from "./LiteralType.js";
9
- import type { ObjectType } from "./ObjectType.js";
9
+ import type { StructType } from "./StructType.js";
10
10
  import type { TermType } from "./TermType.js";
11
11
  import type { Type } from "./Type.js";
12
12
  import type { UnionType } from "./UnionType.js";
@@ -39,7 +39,7 @@ export declare namespace AbstractCompoundType {
39
39
  interface Member<TypeT extends MemberType> {
40
40
  readonly type: TypeT;
41
41
  }
42
- type MemberType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | ObjectType | TermType | UnionType;
42
+ type MemberType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType | UnionType;
43
43
  function isMemberType(type: Type): type is MemberType;
44
44
  }
45
45
  //# sourceMappingURL=AbstractCompoundType.d.ts.map