@shaclmate/compiler 4.0.40 → 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 (344) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +1 -8
  2. package/dist/ShapesGraphToAstTransformer.js +11 -126
  3. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
  4. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.d.ts +17 -0
  5. package/dist/_ShapesGraphToAstTransformer/{transformPropertyShapeToAstObjectTypeProperty.js → transformPropertyShapeToAstStructTypeField.js} +71 -48
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +1 -1
  7. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +29 -20
  8. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.d.ts → transformShapeToAstStructType.d.ts} +3 -3
  9. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.js → transformShapeToAstStructType.js} +35 -45
  10. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +2 -1
  11. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +1 -1
  12. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
  13. package/dist/ast/AbstractCompoundType.d.ts +3 -2
  14. package/dist/ast/AbstractCompoundType.js +5 -5
  15. package/dist/ast/AbstractContainerType.d.ts +2 -2
  16. package/dist/ast/AbstractContainerType.js +4 -4
  17. package/dist/ast/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +10 -12
  18. package/dist/ast/{AbstractLazyObjectType.js → AbstractLazyType.js} +3 -3
  19. package/dist/ast/AbstractType.d.ts +1 -1
  20. package/dist/ast/AbstractType.js +3 -0
  21. package/dist/ast/Ast.d.ts +2 -6
  22. package/dist/ast/DefaultValueType.js +2 -1
  23. package/dist/ast/IntersectionType.d.ts +2 -2
  24. package/dist/ast/IntersectionType.js +3 -3
  25. package/dist/ast/LazyOptionType.d.ts +6 -0
  26. package/dist/ast/LazyOptionType.js +5 -0
  27. package/dist/ast/LazySetType.d.ts +6 -0
  28. package/dist/ast/LazySetType.js +5 -0
  29. package/dist/ast/LazyType.d.ts +5 -0
  30. package/dist/ast/LazyType.js +5 -0
  31. package/dist/ast/ListType.d.ts +2 -2
  32. package/dist/ast/ListType.js +5 -5
  33. package/dist/ast/OptionType.js +2 -1
  34. package/dist/ast/SetType.js +2 -1
  35. package/dist/ast/StructCompoundType.d.ts +12 -0
  36. package/dist/ast/{ObjectCompoundType.js → StructCompoundType.js} +18 -18
  37. package/dist/ast/StructIntersectionType.d.ts +4 -0
  38. package/dist/ast/StructIntersectionType.js +2 -0
  39. package/dist/ast/{ObjectType.d.ts → StructType.d.ts} +28 -39
  40. package/dist/ast/{ObjectType.js → StructType.js} +81 -156
  41. package/dist/ast/StructUnionType.d.ts +4 -0
  42. package/dist/ast/StructUnionType.js +2 -0
  43. package/dist/ast/Type.d.ts +5 -5
  44. package/dist/ast/Type.js +4 -4
  45. package/dist/ast/UnionType.d.ts +2 -2
  46. package/dist/ast/UnionType.js +3 -3
  47. package/dist/ast/index.d.ts +7 -7
  48. package/dist/ast/index.js +7 -7
  49. package/dist/generators/AstJsonGenerator.js +7 -3
  50. package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
  51. package/dist/generators/ts/AbstractCollectionType.d.ts +4 -11
  52. package/dist/generators/ts/AbstractCollectionType.js +3 -62
  53. package/dist/generators/ts/AbstractContainerType.d.ts +1 -2
  54. package/dist/generators/ts/AbstractContainerType.js +7 -10
  55. package/dist/generators/ts/AbstractDateType.d.ts +5 -8
  56. package/dist/generators/ts/AbstractDateType.js +7 -12
  57. package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
  58. package/dist/generators/ts/AbstractIdentifierType.js +3 -0
  59. package/dist/generators/ts/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +8 -8
  60. package/dist/generators/ts/{AbstractLazyObjectType.js → AbstractLazyType.js} +30 -17
  61. package/dist/generators/ts/AbstractLiteralType.d.ts +3 -5
  62. package/dist/generators/ts/AbstractLiteralType.js +0 -21
  63. package/dist/generators/ts/AbstractNumericType.d.ts +1 -7
  64. package/dist/generators/ts/AbstractNumericType.js +17 -27
  65. package/dist/generators/ts/AbstractObjectSetType.d.ts +1 -1
  66. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  67. package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -1
  68. package/dist/generators/ts/AbstractPrimitiveType.js +1 -1
  69. package/dist/generators/ts/AbstractTermType.d.ts +7 -23
  70. package/dist/generators/ts/AbstractTermType.js +27 -58
  71. package/dist/generators/ts/AbstractType.d.ts +86 -63
  72. package/dist/generators/ts/AbstractType.js +48 -22
  73. package/dist/generators/ts/BigDecimalType.d.ts +7 -3
  74. package/dist/generators/ts/BigDecimalType.js +7 -9
  75. package/dist/generators/ts/BigIntType.d.ts +5 -3
  76. package/dist/generators/ts/BigIntType.js +8 -5
  77. package/dist/generators/ts/BlankNodeType.d.ts +2 -7
  78. package/dist/generators/ts/BlankNodeType.js +4 -9
  79. package/dist/generators/ts/BooleanType.d.ts +6 -4
  80. package/dist/generators/ts/BooleanType.js +13 -15
  81. package/dist/generators/ts/DateTimeType.d.ts +2 -2
  82. package/dist/generators/ts/DateTimeType.js +14 -4
  83. package/dist/generators/ts/DateType.d.ts +2 -2
  84. package/dist/generators/ts/DateType.js +14 -4
  85. package/dist/generators/ts/DefaultValueType.d.ts +40 -2
  86. package/dist/generators/ts/DefaultValueType.js +15 -14
  87. package/dist/generators/ts/FloatType.d.ts +5 -3
  88. package/dist/generators/ts/FloatType.js +8 -5
  89. package/dist/generators/ts/GraphqlSchema.js +2 -2
  90. package/dist/generators/ts/IdentifierType.d.ts +2 -2
  91. package/dist/generators/ts/IdentifierType.js +8 -11
  92. package/dist/generators/ts/IntType.d.ts +5 -3
  93. package/dist/generators/ts/IntType.js +8 -5
  94. package/dist/generators/ts/IriType.d.ts +2 -2
  95. package/dist/generators/ts/IriType.js +16 -16
  96. package/dist/generators/ts/{LazyObjectOptionType.d.ts → LazyOptionType.d.ts} +13 -11
  97. package/dist/generators/ts/LazyOptionType.js +75 -0
  98. package/dist/generators/ts/LazySetType.d.ts +20 -0
  99. package/dist/generators/ts/LazySetType.js +76 -0
  100. package/dist/generators/ts/LazyType.d.ts +19 -0
  101. package/dist/generators/ts/LazyType.js +65 -0
  102. package/dist/generators/ts/ListType.d.ts +11 -2
  103. package/dist/generators/ts/ListType.js +53 -26
  104. package/dist/generators/ts/LiteralType.d.ts +7 -2
  105. package/dist/generators/ts/LiteralType.js +12 -5
  106. package/dist/generators/ts/ObjectType.d.ts +24 -25
  107. package/dist/generators/ts/ObjectType.js +303 -161
  108. package/dist/generators/ts/ObjectUnionType.js +42 -42
  109. package/dist/generators/ts/OptionType.d.ts +6 -2
  110. package/dist/generators/ts/OptionType.js +16 -9
  111. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -4
  112. package/dist/generators/ts/SetType.d.ts +17 -2
  113. package/dist/generators/ts/SetType.js +85 -9
  114. package/dist/generators/ts/Snippets.d.ts +29 -9
  115. package/dist/generators/ts/Snippets.js +179 -39
  116. package/dist/generators/ts/StringType.d.ts +7 -4
  117. package/dist/generators/ts/StringType.js +23 -12
  118. package/dist/generators/ts/TermType.d.ts +9 -3
  119. package/dist/generators/ts/TermType.js +29 -7
  120. package/dist/generators/ts/TsGenerator.d.ts +1 -1
  121. package/dist/generators/ts/TsGenerator.js +62 -32
  122. package/dist/generators/ts/Type.d.ts +4 -4
  123. package/dist/generators/ts/TypeFactory.d.ts +5 -5
  124. package/dist/generators/ts/TypeFactory.js +90 -82
  125. package/dist/generators/ts/UnionType.d.ts +25 -23
  126. package/dist/generators/ts/UnionType.js +254 -261
  127. package/dist/generators/ts/ZodGenerator.d.ts +1 -1
  128. package/dist/generators/ts/ZodGenerator.js +29 -14
  129. package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +28 -16
  130. package/dist/generators/ts/_ObjectType/AbstractProperty.js +1 -24
  131. package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +15 -17
  132. package/dist/generators/ts/_ObjectType/DiscriminantProperty.js +24 -54
  133. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +8 -2
  134. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +48 -20
  135. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.d.ts +4 -0
  136. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.js +28 -0
  137. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.d.ts +4 -0
  138. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.js +15 -0
  139. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.d.ts +4 -0
  140. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +12 -0
  141. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeExpression.d.ts +4 -0
  142. package/dist/generators/ts/_ObjectType/{ObjectType_filterTypeDeclaration.js → ObjectType_filterTypeExpression.js} +5 -10
  143. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_focusSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  144. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionExpression.js} +5 -13
  145. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_focusSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  146. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → ObjectType_focusSparqlWherePatternsFunctionExpression.js} +8 -31
  147. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.d.ts +4 -0
  148. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.js +12 -0
  149. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.d.ts +4 -0
  150. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.js +43 -0
  151. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeExpression.d.ts +4 -0
  152. package/dist/generators/ts/_ObjectType/{ObjectType_graphqlTypeVariableStatement.js → ObjectType_graphqlTypeExpression.js} +6 -13
  153. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.d.ts +4 -0
  154. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +30 -0
  155. package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +4 -0
  156. package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.js +13 -0
  157. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +11 -8
  158. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +1 -2
  159. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.js +2 -6
  160. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.d.ts +4 -0
  161. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.js +18 -0
  162. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.d.ts +4 -0
  163. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.js +5 -0
  164. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.d.ts +4 -0
  165. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js +17 -0
  166. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +1 -1
  167. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.js +2 -2
  168. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +4 -0
  169. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +18 -0
  170. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +4 -0
  171. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +18 -0
  172. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -3
  173. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +5 -9
  174. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -3
  175. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +4 -8
  176. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.d.ts +4 -0
  177. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +14 -0
  178. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.d.ts +4 -0
  179. package/dist/generators/ts/_ObjectType/{ObjectType_toRdfResourceFunctionDeclaration.js → ObjectType_toRdfResourceFunctionExpression.js} +7 -13
  180. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.d.ts +4 -0
  181. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.js +7 -0
  182. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.d.ts +4 -0
  183. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.js +5 -0
  184. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_valueSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  185. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionExpression.js +8 -0
  186. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_valueSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  187. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionExpression.js +10 -0
  188. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +9 -2
  189. package/dist/generators/ts/_ObjectType/ShaclProperty.js +70 -38
  190. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +4 -3
  191. package/dist/generators/ts/_snippets/snippets_DateSchema.js +4 -3
  192. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
  193. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +6 -5
  194. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +2 -1
  195. package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -0
  196. package/dist/generators/ts/_snippets/snippets_Lazy.d.ts +3 -0
  197. package/dist/generators/ts/_snippets/snippets_Lazy.js +22 -0
  198. package/dist/generators/ts/_snippets/snippets_LazyOption.d.ts +3 -0
  199. package/dist/generators/ts/_snippets/snippets_LazyOption.js +25 -0
  200. package/dist/generators/ts/_snippets/snippets_LazySet.d.ts +3 -0
  201. package/dist/generators/ts/_snippets/snippets_LazySet.js +40 -0
  202. package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +1 -3
  203. package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -0
  204. package/dist/generators/ts/_snippets/snippets_NumericSchema.js +2 -1
  205. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +6 -8
  206. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +32 -32
  207. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
  208. package/dist/generators/ts/_snippets/snippets_StringSchema.js +5 -3
  209. package/dist/generators/ts/_snippets/snippets_TermFilter.js +3 -3
  210. package/dist/generators/ts/_snippets/snippets_TermSchema.js +4 -2
  211. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.d.ts +3 -0
  212. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +6 -0
  213. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.d.ts +3 -0
  214. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.js +6 -0
  215. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.d.ts +3 -0
  216. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.js +6 -0
  217. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.d.ts +3 -0
  218. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.js +6 -0
  219. package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
  220. package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
  221. package/dist/generators/ts/_snippets/snippets_convertToLazy.d.ts +3 -0
  222. package/dist/generators/ts/_snippets/snippets_convertToLazy.js +15 -0
  223. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.d.ts +3 -0
  224. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.js +33 -0
  225. package/dist/generators/ts/_snippets/snippets_convertToLazySet.d.ts +3 -0
  226. package/dist/generators/ts/_snippets/snippets_convertToLazySet.js +27 -0
  227. package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
  228. package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
  229. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
  230. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
  231. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.d.ts +3 -0
  232. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.js +6 -0
  233. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.d.ts +3 -0
  234. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.js +6 -0
  235. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.d.ts +3 -0
  236. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.js +10 -0
  237. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  238. package/dist/generators/ts/_snippets/snippets_filterNumeric.js +1 -1
  239. package/dist/generators/ts/_snippets/snippets_filterTerm.js +1 -2
  240. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.d.ts +3 -0
  241. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.js +6 -0
  242. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.d.ts +3 -0
  243. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.js +6 -0
  244. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.d.ts +3 -0
  245. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.js +6 -0
  246. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.d.ts +3 -0
  247. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.js +6 -0
  248. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.d.ts +3 -0
  249. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.js +15 -0
  250. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.d.ts +3 -0
  251. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +6 -0
  252. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.d.ts +3 -0
  253. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.js +11 -0
  254. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.d.ts +3 -0
  255. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.js +8 -0
  256. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.d.ts +3 -0
  257. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.js +8 -0
  258. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +1 -1
  259. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.d.ts +3 -0
  260. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.js +9 -0
  261. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +13 -7
  262. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.d.ts +3 -0
  263. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.js +6 -0
  264. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +1 -1
  265. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.d.ts +3 -0
  266. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +17 -0
  267. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.d.ts +3 -0
  268. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +60 -0
  269. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
  270. package/dist/input/generated.d.ts +1116 -400
  271. package/dist/input/generated.js +1879 -1917
  272. package/package.json +2 -4
  273. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +0 -9
  274. package/dist/ast/LazyObjectOptionType.d.ts +0 -6
  275. package/dist/ast/LazyObjectOptionType.js +0 -5
  276. package/dist/ast/LazyObjectSetType.d.ts +0 -6
  277. package/dist/ast/LazyObjectSetType.js +0 -5
  278. package/dist/ast/LazyObjectType.d.ts +0 -5
  279. package/dist/ast/LazyObjectType.js +0 -5
  280. package/dist/ast/ObjectCompoundType.d.ts +0 -12
  281. package/dist/ast/ObjectIntersectionType.d.ts +0 -4
  282. package/dist/ast/ObjectIntersectionType.js +0 -2
  283. package/dist/ast/ObjectUnionType.d.ts +0 -4
  284. package/dist/ast/ObjectUnionType.js +0 -2
  285. package/dist/generators/ts/LazyObjectOptionType.js +0 -62
  286. package/dist/generators/ts/LazyObjectSetType.d.ts +0 -20
  287. package/dist/generators/ts/LazyObjectSetType.js +0 -61
  288. package/dist/generators/ts/LazyObjectType.d.ts +0 -19
  289. package/dist/generators/ts/LazyObjectType.js +0 -53
  290. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
  291. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +0 -65
  292. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +0 -5
  293. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.js +0 -23
  294. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -5
  295. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +0 -24
  296. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -5
  297. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  298. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +0 -43
  299. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  300. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
  301. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  302. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  303. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  304. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.js +0 -10
  305. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  306. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +0 -4
  307. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +0 -45
  308. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
  309. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +0 -16
  310. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  311. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -31
  312. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  313. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +0 -16
  314. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  315. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +0 -17
  316. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -5
  317. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +0 -14
  318. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  319. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +0 -41
  320. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  321. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +0 -4
  322. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.js +0 -36
  323. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +0 -11
  324. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +0 -13
  325. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
  326. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +0 -27
  327. package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +0 -3
  328. package/dist/generators/ts/_snippets/snippets_LazyObject.js +0 -22
  329. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +0 -3
  330. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +0 -25
  331. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +0 -3
  332. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +0 -40
  333. package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
  334. package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
  335. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +0 -3
  336. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +0 -15
  337. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +0 -3
  338. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +0 -31
  339. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +0 -3
  340. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +0 -25
  341. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +0 -3
  342. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +0 -15
  343. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +0 -3
  344. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +0 -23
@@ -8,17 +8,11 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
8
8
  abstract readonly kind: "BigInt" | "Float" | "Int";
9
9
  get filterFunction(): Code;
10
10
  get filterType(): Code;
11
- get expression(): Code;
12
11
  get schemaType(): Code;
13
12
  get valueSparqlWherePatternsFunction(): Code;
13
+ protected get inlineExpression(): Code;
14
14
  jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
15
15
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
16
- protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<ValueT>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<ValueT>["fromRdfResourceValuesExpressionChain"]>;
17
- protected abstract fromRdfResourceValueExpression(variables: {
18
- variables: {
19
- value: Code;
20
- };
21
- }): Code;
22
16
  }
23
17
  export declare namespace AbstractNumericType {
24
18
  const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
@@ -13,45 +13,35 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
13
13
  export class AbstractNumericType extends AbstractPrimitiveType {
14
14
  hashFunction = code `${this.reusables.snippets.hashNumeric}`;
15
15
  get filterFunction() {
16
- return code `${this.reusables.snippets.filterNumeric}<${this.typeofs[0]}>`;
16
+ return code `${this.reusables.snippets.filterNumeric}<${this.expression}>`;
17
17
  }
18
18
  get filterType() {
19
- return code `${this.reusables.snippets.NumericFilter}<${this.typeofs[0]}>`;
20
- }
21
- get expression() {
22
- if (this.primitiveIn.length > 0) {
23
- return code `${joinCode(this.primitiveIn.map((value) => this.literalExpression(value)), { on: " | " })}`;
24
- }
25
- return code `${this.typeofs[0]}`;
19
+ return code `${this.reusables.snippets.NumericFilter}<${this.expression}>`;
26
20
  }
27
21
  get schemaType() {
28
- return code `${this.reusables.snippets.NumericSchema}<${this.typeofs[0]}>`;
22
+ return code `${this.reusables.snippets.NumericSchema}<${this.expression}>`;
29
23
  }
30
24
  get valueSparqlWherePatternsFunction() {
31
- return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.typeofs[0]}>`;
25
+ return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.expression}>`;
26
+ }
27
+ get inlineExpression() {
28
+ if (this.primitiveIn.length > 0) {
29
+ return code `${joinCode(this.primitiveIn.map((value) => this.literalValueExpression(value)), { on: " | " })}`;
30
+ }
31
+ return code `${this.jsTypes[0].typeof}`;
32
32
  }
33
33
  jsonSchema(_parameters) {
34
34
  switch (this.primitiveIn.length) {
35
35
  case 0:
36
- return code `${this.reusables.imports.z}.${this.typeofs[0]}()`;
36
+ return code `${this.reusables.imports.z}.${this.jsTypes[0].typeof}()`;
37
37
  case 1:
38
- return code `${this.reusables.imports.z}.literal(${this.literalExpression(this.primitiveIn[0])})`;
38
+ return code `${this.reusables.imports.z}.literal(${this.literalValueExpression(this.primitiveIn[0])})`;
39
39
  default:
40
- return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalExpression(value)})`), { on: "," })}])`;
40
+ return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalValueExpression(value)})`), { on: "," })}])`;
41
41
  }
42
42
  }
43
43
  toRdfResourceValuesExpression({ variables, }) {
44
- return code `[${this.reusables.snippets.literalFactory}.${this.typeofs[0]}(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
45
- }
46
- fromRdfResourceValuesExpressionChain({ variables, }) {
47
- return {
48
- ...super.fromRdfResourceValuesExpressionChain({ variables }),
49
- languageIn: undefined,
50
- preferredLanguages: undefined,
51
- valueTo: code `chain(values => values.chainMap(value => ${this.fromRdfResourceValueExpression({
52
- variables: { value: code `value` },
53
- })}))`,
54
- };
44
+ return code `[${this.reusables.snippets.literalFactory}.${this.jsTypes[0].typeof}(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
55
45
  }
56
46
  }
57
47
  __decorate([
@@ -60,15 +50,15 @@ __decorate([
60
50
  __decorate([
61
51
  Memoize()
62
52
  ], AbstractNumericType.prototype, "filterType", null);
63
- __decorate([
64
- Memoize()
65
- ], AbstractNumericType.prototype, "expression", null);
66
53
  __decorate([
67
54
  Memoize()
68
55
  ], AbstractNumericType.prototype, "schemaType", null);
69
56
  __decorate([
70
57
  Memoize()
71
58
  ], AbstractNumericType.prototype, "valueSparqlWherePatternsFunction", null);
59
+ __decorate([
60
+ Memoize()
61
+ ], AbstractNumericType.prototype, "inlineExpression", null);
72
62
  (function (AbstractNumericType) {
73
63
  AbstractNumericType.JsonType = AbstractPrimitiveType.JsonType;
74
64
  })(AbstractNumericType || (AbstractNumericType = {}));
@@ -20,9 +20,9 @@ export declare abstract class AbstractObjectSetType {
20
20
  });
21
21
  abstract readonly declaration: Code;
22
22
  protected methodSignatures(namedObjectType: {
23
- readonly alias: Maybe<string>;
24
23
  readonly filterType: Code;
25
24
  readonly identifierTypeAlias: Code;
25
+ readonly name: Maybe<string>;
26
26
  readonly objectSetMethodNames: ObjectType.ObjectSetMethodNames;
27
27
  }, options?: {
28
28
  parameterNamePrefix?: string;
@@ -21,7 +21,7 @@ export class AbstractObjectSetType {
21
21
  object: {
22
22
  name: methodNames.object,
23
23
  parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
24
- returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.alias.unsafeCoerce()}>>`,
24
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.name.unsafeCoerce()}>>`,
25
25
  },
26
26
  objectCount: {
27
27
  name: methodNames.objectCount,
@@ -36,7 +36,7 @@ export class AbstractObjectSetType {
36
36
  objects: {
37
37
  name: methodNames.objects,
38
38
  parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
39
- returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.alias.unsafeCoerce()}[]>>`,
39
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name.unsafeCoerce()}[]>>`,
40
40
  },
41
41
  };
42
42
  }
@@ -17,12 +17,13 @@ export declare abstract class AbstractPrimitiveType<ValueT extends bigint | bool
17
17
  fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
18
18
  graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
19
19
  jsonType(): AbstractLiteralType.JsonType;
20
- abstract literalExpression(literal: Literal | ValueT): Code;
20
+ abstract literalValueExpression(literal: Literal | ValueT): Code;
21
21
  toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
22
22
  }
23
23
  export declare namespace AbstractPrimitiveType {
24
24
  type ConversionFunction = AbstractLiteralType.ConversionFunction;
25
25
  type DiscriminantProperty = AbstractLiteralType.DiscriminantProperty;
26
+ type JsType = AbstractLiteralType.JsType;
26
27
  const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
27
28
  type GraphqlType = AbstractLiteralType.GraphqlType;
28
29
  const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
@@ -24,7 +24,7 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
24
24
  get schemaInitializers() {
25
25
  let initializers = super.schemaInitializers;
26
26
  if (this.primitiveIn.length > 0) {
27
- initializers = initializers.concat(code `in: ${arrayOf(...this.primitiveIn.map((in_) => this.literalExpression(in_)))}`);
27
+ initializers = initializers.concat(code `in: ${arrayOf(...this.primitiveIn.map((in_) => this.literalValueExpression(in_)))} as const`);
28
28
  }
29
29
  return initializers;
30
30
  }
@@ -2,11 +2,9 @@ import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
2
2
  import { NodeKind } from "@shaclmate/shacl-ast";
3
3
  import { Maybe } from "purify-ts";
4
4
  import { AbstractType } from "./AbstractType.js";
5
- import type { Type } from "./Type.js";
6
- import type { Typeof } from "./Typeof.js";
7
5
  import { type Code } from "./ts-poet-wrapper.js";
8
6
  /**
9
- * Abstract base class for IdentifierType and LiteralType.
7
+ * Abstract base class for all types that are terms in RDF (i.e., identifiers, literals).
10
8
  *
11
9
  * ConstantTermT is the type of sh:hasValue and sh:in.
12
10
  * RuntimeTermT is the type of values at runtime.
@@ -14,7 +12,7 @@ import { type Code } from "./ts-poet-wrapper.js";
14
12
  * The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
15
13
  */
16
14
  export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends AbstractType {
17
- readonly declaration: Maybe<Code>;
15
+ protected abstract readonly inlineExpression: Code;
18
16
  readonly equalsFunction: Code;
19
17
  readonly graphqlArgs: AbstractType["graphqlArgs"];
20
18
  readonly hasValues: readonly ConstantTermT[];
@@ -23,43 +21,29 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
23
21
  readonly mutable: boolean;
24
22
  abstract readonly nodeKinds: ReadonlySet<NodeKind>;
25
23
  readonly recursive = false;
26
- readonly referencesObjectType = false;
27
- readonly typeofs: readonly Typeof[];
28
24
  readonly validationFunction: Maybe<Code>;
29
25
  constructor({ hasValues, in_, ...superParameters }: {
30
26
  hasValues: readonly ConstantTermT[];
31
27
  in_: readonly ConstantTermT[];
32
28
  } & ConstructorParameters<typeof AbstractType>[0]);
33
- get constrained(): boolean;
29
+ get declaration(): Maybe<Code>;
34
30
  get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
31
+ get expression(): Code;
32
+ get referencesNamedType(): boolean;
35
33
  get termTypes(): ReadonlySet<"BlankNode" | "Literal" | "NamedNode">;
36
34
  get toRdfResourceValueTypes(): Set<"BlankNode" | "Literal" | "NamedNode">;
37
35
  get valueSparqlConstructTriplesFunction(): Code;
38
- fromRdfResourceValuesExpression(parameters: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
36
+ protected get schemaInitializers(): readonly Code[];
39
37
  jsonUiSchemaElement(): Maybe<Code>;
40
38
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
41
39
  toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
42
- /**
43
- * The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
44
- *
45
- * hasValues: test whether the values sequence has sh:hasValue values
46
- * languageIn: filter the values sequence to literals with the right sh:languageIn (or runtime languageIn)
47
- * valueTo: convert values in the values sequence to the appropriate term type/sub-type (literal, string, etc.)
48
- *
49
- * Considering the sub-expressions as a record instead of an array allows them to be selectively overridden by subclasses.
50
- */
51
- protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<Type["fromRdfResourceValuesExpression"]>[0]): {
52
- hasValues?: Code;
53
- languageIn?: Code;
54
- preferredLanguages?: Code;
55
- valueTo: Code;
56
- };
57
40
  }
58
41
  export declare namespace AbstractTermType {
59
42
  type ConversionFunction = AbstractType.ConversionFunction;
60
43
  type DiscriminantProperty = AbstractType.DiscriminantProperty;
61
44
  const GraphqlType: typeof AbstractType.GraphqlType;
62
45
  type GraphqlType = AbstractType.GraphqlType;
46
+ type JsType = AbstractType.JsType;
63
47
  const JsonType: typeof AbstractType.JsonType;
64
48
  type JsonType = AbstractType.JsonType;
65
49
  }
@@ -8,9 +8,9 @@ import { NodeKind } from "@shaclmate/shacl-ast";
8
8
  import { Maybe } from "purify-ts";
9
9
  import { Memoize } from "typescript-memoize";
10
10
  import { AbstractType } from "./AbstractType.js";
11
- import { code, joinCode } from "./ts-poet-wrapper.js";
11
+ import { arrayOf, code } from "./ts-poet-wrapper.js";
12
12
  /**
13
- * Abstract base class for IdentifierType and LiteralType.
13
+ * Abstract base class for all types that are terms in RDF (i.e., identifiers, literals).
14
14
  *
15
15
  * ConstantTermT is the type of sh:hasValue and sh:in.
16
16
  * RuntimeTermT is the type of values at runtime.
@@ -18,7 +18,6 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
18
18
  * The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
19
19
  */
20
20
  export class AbstractTermType extends AbstractType {
21
- declaration = Maybe.empty();
22
21
  equalsFunction = code `${this.reusables.snippets.booleanEquals}`;
23
22
  graphqlArgs = Maybe.empty();
24
23
  hasValues;
@@ -26,26 +25,32 @@ export class AbstractTermType extends AbstractType {
26
25
  in_;
27
26
  mutable = false;
28
27
  recursive = false;
29
- referencesObjectType = false;
30
- typeofs = ["object"];
31
28
  validationFunction = Maybe.empty();
32
29
  constructor({ hasValues, in_, ...superParameters }) {
33
30
  super(superParameters);
34
31
  this.hasValues = hasValues;
35
32
  this.in_ = in_;
36
33
  }
37
- get constrained() {
38
- return this.hasValues.length > 0 || this.in_.length > 0;
34
+ get declaration() {
35
+ return this.name.map((name) => code `export type ${name} = ${this.inlineExpression};`);
39
36
  }
40
37
  get discriminantProperty() {
41
38
  return Maybe.of({
42
- descendantValues: [],
43
39
  jsonName: "termType",
44
40
  name: "termType",
45
- ownValues: [...this.nodeKinds].map(NodeKind.toTermType),
46
- type: "string",
41
+ values: [...this.nodeKinds].map(NodeKind.toTermType),
47
42
  });
48
43
  }
44
+ get expression() {
45
+ const name = this.name.extract();
46
+ if (name) {
47
+ return code `${name}`;
48
+ }
49
+ return this.inlineExpression;
50
+ }
51
+ get referencesNamedType() {
52
+ return this.name.isJust();
53
+ }
49
54
  get termTypes() {
50
55
  return new Set([...this.nodeKinds].map(NodeKind.toTermType));
51
56
  }
@@ -55,21 +60,12 @@ export class AbstractTermType extends AbstractType {
55
60
  get valueSparqlConstructTriplesFunction() {
56
61
  return code `((_: object) => [])`;
57
62
  }
58
- fromRdfResourceValuesExpression(parameters) {
59
- // invariant(
60
- // this.nodeKinds.has("Literal") &&
61
- // (this.nodeKinds.has("BlankNode") || this.nodeKinds.has("NamedNode")),
62
- // "IdentifierType and LiteralType should override",
63
- // );
64
- const chain = this.fromRdfResourceValuesExpressionChain(parameters);
65
- const { variables } = parameters;
66
- return joinCode([
67
- variables.resourceValues,
68
- chain.hasValues,
69
- chain.languageIn,
70
- chain.preferredLanguages,
71
- chain.valueTo,
72
- ].filter((_) => _ !== undefined), { on: "." });
63
+ get schemaInitializers() {
64
+ let initializers = super.schemaInitializers;
65
+ if (this.hasValues.length > 0) {
66
+ initializers = initializers.concat(code `hasValues: ${arrayOf(...this.hasValues.map((hasValue) => this.rdfjsTermExpression(hasValue)))}`);
67
+ }
68
+ return initializers;
73
69
  }
74
70
  jsonUiSchemaElement() {
75
71
  return Maybe.empty();
@@ -80,43 +76,16 @@ export class AbstractTermType extends AbstractType {
80
76
  toStringExpression({ variables, }) {
81
77
  return code `${variables.value}.toString()`;
82
78
  }
83
- /**
84
- * The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
85
- *
86
- * hasValues: test whether the values sequence has sh:hasValue values
87
- * languageIn: filter the values sequence to literals with the right sh:languageIn (or runtime languageIn)
88
- * valueTo: convert values in the values sequence to the appropriate term type/sub-type (literal, string, etc.)
89
- *
90
- * Considering the sub-expressions as a record instead of an array allows them to be selectively overridden by subclasses.
91
- */
92
- fromRdfResourceValuesExpressionChain({ variables, }) {
93
- let valueToExpression;
94
- if (this.in_.length > 0) {
95
- valueToExpression = code `value.toTerm([${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}])`;
96
- }
97
- else if (this.nodeKinds.size < 3) {
98
- const eitherTypeParameters = code `<Error, ${this.expression}>`;
99
- valueToExpression = code `value.toTerm().chain(term => {
100
- switch (term.termType) {
101
- ${[...this.nodeKinds].map((nodeKind) => `case "${NodeKind.toTermType(nodeKind)}":`).join("\n")} return ${this.reusables.imports.Either}.of${eitherTypeParameters}(term);
102
- default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.expression}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
103
- }})`;
104
- }
105
- else {
106
- valueToExpression = code `value.toTerm()`;
107
- }
108
- return {
109
- hasValues: this.hasValues.length > 0
110
- ? code `\
111
- chain(values => ${this.reusables.imports.Either}.sequence([${joinCode(this.hasValues.map((hasValue) => this.rdfjsTermExpression(hasValue)), { on: ", " })}].map(hasValue => values.find(value => value.term.equals(hasValue)))).map(() => values))`
112
- : undefined,
113
- valueTo: code `chain(values => values.chainMap(value => ${valueToExpression}))`,
114
- };
115
- }
116
79
  }
80
+ __decorate([
81
+ Memoize()
82
+ ], AbstractTermType.prototype, "declaration", null);
117
83
  __decorate([
118
84
  Memoize()
119
85
  ], AbstractTermType.prototype, "discriminantProperty", null);
86
+ __decorate([
87
+ Memoize()
88
+ ], AbstractTermType.prototype, "expression", null);
120
89
  __decorate([
121
90
  Memoize()
122
91
  ], AbstractTermType.prototype, "termTypes", null);
@@ -1,9 +1,9 @@
1
+ import type { BlankNode, NamedNode } from "@rdfjs/types";
1
2
  import type { Maybe } from "purify-ts";
2
3
  import type { Logger } from "ts-log";
3
4
  import type { Reusables } from "./Reusables.js";
4
5
  import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
5
6
  import type { TsGenerator } from "./TsGenerator.js";
6
- import type { Typeof } from "./Typeof.js";
7
7
  import { type Code } from "./ts-poet-wrapper.js";
8
8
  /**
9
9
  * Abstract base class all types.
@@ -12,10 +12,6 @@ export declare abstract class AbstractType {
12
12
  protected readonly configuration: TsGenerator.Configuration;
13
13
  protected readonly logger: Logger;
14
14
  protected readonly reusables: Reusables;
15
- /**
16
- * Alias for this type.
17
- */
18
- readonly alias: Maybe<string>;
19
15
  /**
20
16
  * Comment from rdfs:comment.
21
17
  */
@@ -39,7 +35,7 @@ export declare abstract class AbstractType {
39
35
  */
40
36
  abstract readonly discriminantProperty: Maybe<AbstractType.DiscriminantProperty>;
41
37
  /**
42
- * A function (reference or declaration) that compares two property values of this type, returning a
38
+ * A function (reference or literal) that compares two property values of this type, returning a
43
39
  * $EqualsResult.
44
40
  */
45
41
  abstract readonly equalsFunction: Code;
@@ -48,7 +44,7 @@ export declare abstract class AbstractType {
48
44
  */
49
45
  abstract readonly expression: Code;
50
46
  /**
51
- * A function (reference or declaration) that takes a filter of filterType (below) and a value of this type
47
+ * A function (reference or literal) that takes a filter of filterType (below) and a value of this type
52
48
  * and returns true if the value passes the filter.
53
49
  */
54
50
  abstract readonly filterFunction: Code;
@@ -56,6 +52,27 @@ export declare abstract class AbstractType {
56
52
  * Composite type for filtering instances of this type e.g., SomeObject.Filter with filters for each property.
57
53
  */
58
54
  abstract readonly filterType: Code;
55
+ /**
56
+ * A FromRdfResourceValuesFunction (reference or literal) that converts a Either<Error, rdfjsResource.Resource.Values> to a
57
+ * Either<Error, rdfjsResource.Resource.Values<this type>>.
58
+ *
59
+ * These functions are used to deserialize property values in an ObjectType, either directly (a property with this type) or indirectly (a property with a type like OptionType
60
+ * that has a type parameter of this type).
61
+ *
62
+ * Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
63
+ * to be considered valid. Similarly, values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
64
+ * (if it exists) is always of the first preferred language.
65
+ *
66
+ * The function takes two parameters, a rdfjsResource.Resource.Values and a parameters object with the following parameters:
67
+ * context: unanticipated properties (...) passed to Object.fromRdf
68
+ * focusResource: the Resource passed to Object.fromRdf
69
+ * graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
70
+ * ignoreRdfType: whether the RDF type of objects/object unions should be ignored
71
+ * objectSet: the ObjectSet passed to Object.fromRdf
72
+ * preferredLanguages: the preferred languages array (e.g., ["en"]) passed to Object.fromRdf
73
+ * propertyPath: the PropertyPath of the object's property
74
+ */
75
+ abstract readonly fromRdfResourceValuesFunction: Code;
59
76
  /**
60
77
  * Declarations for GraphQL arguments to pass to this the graphqlResolveExpression.
61
78
  */
@@ -67,9 +84,13 @@ export declare abstract class AbstractType {
67
84
  */
68
85
  abstract readonly graphqlType: AbstractType.GraphqlType;
69
86
  /**
70
- * A function (reference or declaration) that takes a Hasher and a value of this type, calls hasher.update on the value, and returns the Hasher.
87
+ * A function (reference or literal) that takes a Hasher and a value of this type, calls hasher.update on the value, and returns the Hasher.
71
88
  */
72
89
  abstract readonly hashFunction: Code;
90
+ /**
91
+ * JavaScript type(s) the type.
92
+ */
93
+ abstract readonly jsTypes: readonly AbstractType.JsType[];
73
94
  /**
74
95
  * Type discriminant.
75
96
  */
@@ -82,6 +103,10 @@ export declare abstract class AbstractType {
82
103
  * Is a value of this type mutable?
83
104
  */
84
105
  abstract readonly mutable: boolean;
106
+ /**
107
+ * Name for this type.
108
+ */
109
+ readonly name: Maybe<string>;
85
110
  /**
86
111
  * Does this type directly or indirectly reference itself?
87
112
  */
@@ -89,19 +114,19 @@ export declare abstract class AbstractType {
89
114
  /**
90
115
  * Is this type an ObjectType or does it reference an object type?
91
116
  */
92
- abstract readonly referencesObjectType: boolean;
117
+ abstract readonly referencesNamedType: boolean;
93
118
  /**
94
119
  * TypeScript type describing .schema.
95
120
  */
96
121
  abstract readonly schemaType: Code;
97
122
  /**
98
- * The type(s) of the array elements produced by the toRdfResourceValuesExpression.
123
+ * Identifier of the shape this type was derived from.
99
124
  */
100
- abstract readonly toRdfResourceValueTypes: ReadonlySet<"BlankNode" | "NamedNode" | "Literal">;
125
+ readonly shapeIdentifier: BlankNode | NamedNode;
101
126
  /**
102
- * JavaScript typeof(s) the type.
127
+ * The type(s) of the array elements produced by the toRdfResourceValuesExpression.
103
128
  */
104
- abstract readonly typeofs: readonly Typeof[];
129
+ abstract readonly toRdfResourceValueTypes: ReadonlySet<"BlankNode" | "NamedNode" | "Literal">;
105
130
  /**
106
131
  * Function that takes
107
132
  * - a schema of this.schemaType
@@ -115,7 +140,7 @@ export declare abstract class AbstractType {
115
140
  */
116
141
  abstract readonly validationFunction: Maybe<Code>;
117
142
  /**
118
- * A ValueSparqlConstructTriplesFunction (reference or declaration) that returns an array of sparqljs.Triple's for a property value of this type.
143
+ * A ValueSparqlConstructTriplesFunction (reference or literal) that returns an array of sparqljs.Triple's for a property value of this type.
119
144
  *
120
145
  * The function takes a parameters object with the following parameters:
121
146
  * - filter: an instance of filterType | undefined
@@ -126,7 +151,7 @@ export declare abstract class AbstractType {
126
151
  */
127
152
  abstract readonly valueSparqlConstructTriplesFunction: Code;
128
153
  /**
129
- * A ValueSparqlWherePatternsFunction (reference or declaration) that returns an array of SparqlPattern's for a property value of this type.
154
+ * A ValueSparqlWherePatternsFunction (reference or literal) that returns an array of SparqlPattern's for a property value of this type.
130
155
  *
131
156
  * The function takes a parameters object with the following parameters:
132
157
  * - filter: an instance of filterType | undefined
@@ -137,18 +162,20 @@ export declare abstract class AbstractType {
137
162
  * - variablePrefix: string prefix to use for new variables
138
163
  */
139
164
  abstract readonly valueSparqlWherePatternsFunction: Code;
140
- constructor({ alias, comment, configuration, label, logger, reusables, }: {
141
- alias: Maybe<string>;
165
+ constructor({ comment, configuration, label, logger, name, reusables, shapeIdentifier, }: {
166
+ name: Maybe<string>;
142
167
  comment: Maybe<string>;
143
168
  configuration: TsGenerator.Configuration;
144
169
  label: Maybe<string>;
145
170
  logger: Logger;
146
171
  reusables: Reusables;
172
+ shapeIdentifier: BlankNode | NamedNode;
147
173
  });
148
174
  /**
149
175
  * TypeScript object describing this type, for runtime use.
150
176
  */
151
177
  get schema(): Code;
178
+ protected get schemaExpression(): Code;
152
179
  /**
153
180
  * Helper to compose the result of schema along the type hierarchy.
154
181
  */
@@ -161,41 +188,6 @@ export declare abstract class AbstractType {
161
188
  value: Code;
162
189
  };
163
190
  }): Code;
164
- /**
165
- * An expression that converts a Either<Error, rdfjsResource.Resource.Values> to a
166
- * Either<Error, rdfjsResource.Resource.Values<this type>>.
167
- *
168
- * These expressions are used to deserialize property values in an ObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
169
- * that has a type parameter of this Type).
170
- *
171
- * Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
172
- * to be considered valid. Similar
173
- *
174
- * Values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
175
- * (if it exists) is always of the first preferred language.
176
- *
177
- * variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
178
- * context: unanticipated properties (...) passed to Object.fromRdf
179
- * graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
180
- * ignoreRdfType: whether the RDF type of objects/object unions should be ignored
181
- * objectSet: the ObjectSet passed to Object.fromRdf
182
- * preferredLanguages: the preferred languages array (e.g., ["en"]) passed to Object.fromRdf
183
- * propertyPath: the PropertyPath of the object's property
184
- * resource: the Resource passed to Object.fromRdf
185
- * resourceValues: the Either<Error, rdfjsResource.Resource.Values> to be converted to values of this type
186
- */
187
- abstract fromRdfResourceValuesExpression(parameters: {
188
- variables: {
189
- context: Code;
190
- graph: Code;
191
- ignoreRdfType?: boolean;
192
- objectSet: Code;
193
- preferredLanguages: Code;
194
- propertyPath: Code;
195
- resource: Code;
196
- resourceValues: Code;
197
- };
198
- }): Code;
199
191
  /**
200
192
  * An expression that resolves a value of this type in the GraphQL server.
201
193
  */
@@ -277,14 +269,13 @@ export declare namespace AbstractType {
277
269
  readonly code: Code;
278
270
  readonly sourceTypes: {
279
271
  readonly expression: Code;
280
- readonly typeof: Typeof;
272
+ readonly jsType: JsType;
281
273
  }[];
282
274
  }
283
275
  interface DiscriminantProperty {
284
- readonly descendantValues: readonly DiscriminantProperty.Value[];
285
276
  readonly jsonName: string;
286
277
  readonly name: string;
287
- readonly ownValues: readonly DiscriminantProperty.Value[];
278
+ readonly values: readonly DiscriminantProperty.Value[];
288
279
  }
289
280
  namespace DiscriminantProperty {
290
281
  type Value = number | string;
@@ -295,14 +286,46 @@ export declare namespace AbstractType {
295
286
  */
296
287
  readonly nullable: boolean;
297
288
  /**
298
- * The name of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
289
+ * The expression of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
299
290
  */
300
- readonly nullableName: Code;
291
+ readonly nullableExpression: Code;
301
292
  private readonly reusables;
302
- constructor(nullableName: Code, reusables: Reusables, options?: {
293
+ constructor(nullableExpression: Code, reusables: Reusables, options?: {
303
294
  nullable: boolean;
304
295
  });
305
- get name(): Code;
296
+ get expression(): Code;
297
+ }
298
+ type JsType = {
299
+ typeof: "bigint";
300
+ } | {
301
+ typeof: "boolean";
302
+ } | {
303
+ typeof: "function";
304
+ } | {
305
+ typeof: "number";
306
+ } | {
307
+ instanceof: "Array";
308
+ typeof: "object";
309
+ } | {
310
+ className: Code;
311
+ instanceof: "class";
312
+ typeof: "object";
313
+ } | {
314
+ instanceof: "Date";
315
+ typeof: "object";
316
+ } | {
317
+ instanceof: "Maybe";
318
+ typeof: "object";
319
+ } | {
320
+ instanceof: "Object";
321
+ typeof: "object";
322
+ } | {
323
+ typeof: "string";
324
+ } | {
325
+ typeof: "undefined";
326
+ };
327
+ namespace JsType {
328
+ function equals(left: JsType, right: JsType): boolean;
306
329
  }
307
330
  class JsonType {
308
331
  /**
@@ -310,13 +333,13 @@ export declare namespace AbstractType {
310
333
  */
311
334
  readonly optional: boolean;
312
335
  /**
313
- * The name of the type when it's required i.e. -- so it should never include "| undefined".
336
+ * The expression of the type when it's required i.e. -- so it should never include "| undefined".
314
337
  */
315
- readonly requiredName: Code | string;
316
- constructor(requiredName: Code | string, parameters?: {
338
+ readonly requiredExpression: Code;
339
+ constructor(requiredExpression: Code, parameters?: {
317
340
  optional: boolean;
318
341
  });
319
- get name(): Code | string;
342
+ get expression(): Code;
320
343
  }
321
344
  }
322
345
  //# sourceMappingURL=AbstractType.d.ts.map