@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
@@ -16,28 +16,28 @@ import { UnionType } from "./UnionType.js";
16
16
  export class ObjectUnionType extends UnionType {
17
17
  kind = "ObjectUnion";
18
18
  get identifierTypeAlias() {
19
- return this.alias.map((alias) => code `${alias}.Identifier`).unsafeCoerce();
19
+ return this.name.map((name) => code `${name}.Identifier`).unsafeCoerce();
20
20
  }
21
21
  get objectSetMethodNames() {
22
- return this.alias
23
- .map((alias) => ObjectType_objectSetMethodNames.call({
24
- alias,
22
+ return this.name
23
+ .map((name) => ObjectType_objectSetMethodNames.call({
24
+ name,
25
25
  configuration: this.configuration,
26
26
  }))
27
27
  .unsafeCoerce();
28
28
  }
29
29
  get schema() {
30
- return this.alias
31
- .map((alias) => code `${alias}.schema`)
30
+ return this.name
31
+ .map((name) => code `${name}.schema`)
32
32
  .orDefault(super.schema);
33
33
  }
34
34
  get schemaType() {
35
- return this.alias
35
+ return this.name
36
36
  .map(() => code `typeof ${this.schema}`)
37
37
  .orDefault(super.schemaType);
38
38
  }
39
39
  get staticModuleDeclarations() {
40
- const alias = this.alias.unsafeCoerce();
40
+ const name = this.name.unsafeCoerce();
41
41
  return {
42
42
  ...super.staticModuleDeclarations,
43
43
  ...this.identifierTypeDeclarations,
@@ -47,22 +47,22 @@ export class ObjectUnionType extends UnionType {
47
47
  ...this.graphqlTypeVariableStatement,
48
48
  ...this.isTypeFunctionDeclaration,
49
49
  ...this.schemaVariableStatement,
50
- ...ObjectType_sparqlConstructQueryFunctionDeclaration.call({
51
- alias,
52
- configuration: this.configuration,
53
- filterType: this.filterType,
54
- reusables: this.reusables,
55
- })
56
- .map((code_) => singleEntryRecord(`sparqlConstructQuery`, code_))
57
- .orDefault({}),
58
- ...ObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
59
- alias,
60
- configuration: this.configuration,
61
- filterType: this.filterType,
62
- reusables: this.reusables,
63
- })
64
- .map((code_) => singleEntryRecord(`sparqlConstructQueryString`, code_))
65
- .orDefault({}),
50
+ ...(this.configuration.features.has("Object.SPARQL")
51
+ ? {
52
+ ...singleEntryRecord("sparqlConstructQuery", ObjectType_sparqlConstructQueryFunctionDeclaration.call({
53
+ name,
54
+ configuration: this.configuration,
55
+ filterType: this.filterType,
56
+ reusables: this.reusables,
57
+ })),
58
+ ...singleEntryRecord("sparqlConstructQueryString", ObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
59
+ name,
60
+ configuration: this.configuration,
61
+ filterType: this.filterType,
62
+ reusables: this.reusables,
63
+ })),
64
+ }
65
+ : {}),
66
66
  ...this.toRdfResourceFunctionDeclaration,
67
67
  };
68
68
  }
@@ -72,7 +72,7 @@ export class ObjectUnionType extends UnionType {
72
72
  }
73
73
  return singleEntryRecord(`focusSparqlConstructTriples`, code `\
74
74
  export function focusSparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${this.reusables.imports.NamedNode} | ${this.reusables.imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${this.reusables.imports.sparqljs}.Triple[] {
75
- return [${joinCode(this.members.map((member) => code `...${member.type.alias.unsafeCoerce()}.focusSparqlConstructTriples({ filter: filter?.on?.${member.type.alias.unsafeCoerce()}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.alias.unsafeCoerce())}\` }).concat()`), { on: ", " })}];
75
+ return [${joinCode(this.members.map((member) => code `...${member.type.name.unsafeCoerce()}.focusSparqlConstructTriples({ filter: filter?.on?.${member.type.name.unsafeCoerce()}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name.unsafeCoerce())}\` }).concat()`), { on: ", " })}];
76
76
  }`);
77
77
  }
78
78
  get focusSparqlWherePatternsFunctionDeclaration() {
@@ -96,7 +96,7 @@ if (focusIdentifier.termType === "Variable") {
96
96
  }));
97
97
  }`,
98
98
  code `patterns.push({ patterns: [${joinCode(this.members.map((member) => code `${{
99
- patterns: code `${member.type.alias.unsafeCoerce()}.focusSparqlWherePatterns({ filter: filter?.on?.${member.type.alias.unsafeCoerce()}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.alias.unsafeCoerce())}\` }).concat()`,
99
+ patterns: code `${member.type.name.unsafeCoerce()}.focusSparqlWherePatterns({ filter: filter?.on?.${member.type.name.unsafeCoerce()}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name.unsafeCoerce())}\` }).concat()`,
100
100
  type: literalOf("group"),
101
101
  }}`), { on: ", " })}], type: "union" });`,
102
102
  code `return patterns;`,
@@ -107,11 +107,11 @@ if (focusIdentifier.termType === "Variable") {
107
107
  if (!this.configuration.features.has("Object.fromRdf")) {
108
108
  return {};
109
109
  }
110
- const alias = this.alias.unsafeCoerce();
110
+ const name = this.name.unsafeCoerce();
111
111
  return singleEntryRecord(`fromRdfResource`, code `\
112
- export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<${alias}> = (resource, options) =>
112
+ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<${name}> = (resource, options) =>
113
113
  ${this.members.reduce((expression, member) => {
114
- const memberTypeExpression = code `(${member.type.alias.unsafeCoerce()}.fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${this.reusables.imports.Either}<Error, ${alias}>)`;
114
+ const memberTypeExpression = code `(${member.type.name.unsafeCoerce()}.fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${this.reusables.imports.Either}<Error, ${name}>)`;
115
115
  return expression !== null
116
116
  ? code `${expression}.altLazy(() => ${memberTypeExpression})`
117
117
  : memberTypeExpression;
@@ -124,13 +124,13 @@ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}
124
124
  if (this.synthetic) {
125
125
  return {};
126
126
  }
127
- const alias = this.alias.unsafeCoerce();
127
+ const name = this.name.unsafeCoerce();
128
128
  return singleEntryRecord(`GraphQL`, code `\
129
129
  export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
130
130
  description: this.comment.map(JSON.stringify).extract(),
131
- name: alias,
132
- resolveType: code `(value: ${alias}) => value.${this.configuration.syntheticNamePrefix}type`,
133
- types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
131
+ name: name,
132
+ resolveType: code `(value: ${name}) => value.${this.configuration.syntheticNamePrefix}type`,
133
+ types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableExpression), { on: ", " })}]`,
134
134
  }});`);
135
135
  }
136
136
  get identifierTypeDeclarations() {
@@ -148,13 +148,13 @@ export namespace Identifier {
148
148
  if (!this.configuration.features.has("Object.type")) {
149
149
  return {};
150
150
  }
151
- const alias = this.alias.unsafeCoerce();
152
- if (alias === `${this.configuration.syntheticNamePrefix}Object`) {
151
+ const name = this.name.unsafeCoerce();
152
+ if (name === `${this.configuration.syntheticNamePrefix}Object`) {
153
153
  return {};
154
154
  }
155
- return singleEntryRecord(`is${alias}`, code `\
156
- export function is${alias}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${alias} {
157
- return ${joinCode(this.members.map((member) => code `${member.type.alias.unsafeCoerce()}.is${member.type.alias.unsafeCoerce()}(object)`), { on: " || " })};
155
+ return singleEntryRecord(`is${name}`, code `\
156
+ export function is${name}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${name} {
157
+ return ${joinCode(this.members.map((member) => code `${member.type.name.unsafeCoerce()}.is${member.type.name.unsafeCoerce()}(object)`), { on: " || " })};
158
158
  }`);
159
159
  }
160
160
  get schemaVariableStatement() {
@@ -163,7 +163,7 @@ export namespace Identifier {
163
163
  }
164
164
  const commonPropertiesByName = {};
165
165
  this.members.forEach((member, memberI) => {
166
- for (const memberTypeProperty of member.type.properties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.properties))) {
166
+ for (const memberTypeProperty of member.type.properties) {
167
167
  if (memberTypeProperty.kind !== "Shacl") {
168
168
  continue;
169
169
  }
@@ -199,11 +199,11 @@ export const schema = { ${joinCode(super.schemaInitializers.concat(code `propert
199
199
  if (!this.configuration.features.has("Object.toRdf")) {
200
200
  return {};
201
201
  }
202
- const alias = this.alias.unsafeCoerce();
202
+ const name = this.name.unsafeCoerce();
203
203
  return singleEntryRecord(`toRdfResource`, code `\
204
- export const toRdfResource: ${this.reusables.snippets.ToRdfResourceFunction}<${alias}> = (object, options) => {
204
+ export const toRdfResource: ${this.reusables.snippets.ToRdfResourceFunction}<${name}> = (object, options) => {
205
205
  ${joinCode(this.members
206
- .map((member) => code `if (${member.type.alias.unsafeCoerce()}.is${member.type.alias.unsafeCoerce()}(object)) { return ${member.type.alias.unsafeCoerce()}.toRdfResource(object, options); }`)
206
+ .map((member) => code `if (${member.type.name.unsafeCoerce()}.is${member.type.name.unsafeCoerce()}(object)) { return ${member.type.name.unsafeCoerce()}.toRdfResource(object, options); }`)
207
207
  .concat(code `throw new Error("unrecognized type");`))}
208
208
  };`);
209
209
  }
@@ -4,22 +4,26 @@ import { type Code } from "./ts-poet-wrapper.js";
4
4
  export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends AbstractContainerType<ItemTypeT> {
5
5
  readonly discriminantProperty: Maybe<AbstractContainerType.DiscriminantProperty>;
6
6
  readonly graphqlArgs: AbstractContainerType<ItemTypeT>["graphqlArgs"];
7
+ readonly jsTypes: readonly [{
8
+ readonly instanceof: "Maybe";
9
+ readonly typeof: "object";
10
+ }];
7
11
  readonly kind = "Option";
8
- readonly typeofs: "object"[];
9
12
  get conversionFunction(): Maybe<AbstractContainerType.ConversionFunction>;
10
13
  get equalsFunction(): Code;
11
14
  get expression(): Code;
12
15
  get filterFunction(): Code;
13
16
  get filterType(): Code;
17
+ get fromRdfResourceValuesFunction(): Code;
14
18
  get graphqlType(): AbstractContainerType.GraphqlType;
15
19
  get hashFunction(): Code;
16
20
  get mutable(): boolean;
17
21
  get schemaType(): Code;
22
+ get toRdfResourceValueTypes(): AbstractContainerType<ItemTypeT>["toRdfResourceValueTypes"];
18
23
  get validationFunction(): Maybe<Code>;
19
24
  get valueSparqlConstructTriplesFunction(): Code;
20
25
  get valueSparqlWherePatternsFunction(): Code;
21
26
  fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
22
- fromRdfResourceValuesExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
23
27
  graphqlResolveExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;
24
28
  jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
25
29
  jsonType(parameters?: Parameters<AbstractContainerType<ItemTypeT>["jsonType"]>[0]): AbstractContainerType.JsonType;
@@ -13,18 +13,20 @@ import { code } from "./ts-poet-wrapper.js";
13
13
  export class OptionType extends AbstractContainerType {
14
14
  discriminantProperty = Maybe.empty();
15
15
  graphqlArgs = Maybe.empty();
16
+ jsTypes = [
17
+ { instanceof: "Maybe", typeof: "object" },
18
+ ];
16
19
  kind = "Option";
17
- typeofs = ["object"];
18
20
  get conversionFunction() {
19
21
  const itemConversionFunction = this.itemType.conversionFunction.orDefault(this.itemConversionFunctionDefault);
20
22
  return Maybe.of({
21
23
  code: code `${this.reusables.snippets.convertToMaybe}(${itemConversionFunction.code})`,
22
24
  sourceTypes: itemConversionFunction.sourceTypes.concat({
23
25
  expression: this.expression,
24
- typeof: "object",
26
+ jsType: { instanceof: "Maybe", typeof: "object" },
25
27
  }, {
26
28
  expression: code `undefined`,
27
- typeof: "undefined",
29
+ jsType: { typeof: "undefined" },
28
30
  }),
29
31
  });
30
32
  }
@@ -40,9 +42,12 @@ export class OptionType extends AbstractContainerType {
40
42
  get filterType() {
41
43
  return code `${this.reusables.snippets.MaybeFilter}<${this.itemType.filterType}>`;
42
44
  }
45
+ get fromRdfResourceValuesFunction() {
46
+ return code `${this.reusables.snippets.maybeFromRdfResourceValues}<${this.itemType.expression}, ${this.itemType.schemaType}>(${this.itemType.fromRdfResourceValuesFunction})`;
47
+ }
43
48
  get graphqlType() {
44
49
  invariant(!this.itemType.graphqlType.nullable);
45
- return new AbstractContainerType.GraphqlType(this.itemType.graphqlType.name, this.reusables, {
50
+ return new AbstractContainerType.GraphqlType(this.itemType.graphqlType.expression, this.reusables, {
46
51
  nullable: true,
47
52
  });
48
53
  }
@@ -55,6 +60,9 @@ export class OptionType extends AbstractContainerType {
55
60
  get schemaType() {
56
61
  return code `${this.reusables.snippets.MaybeSchema}<${this.itemType.schemaType}>`;
57
62
  }
63
+ get toRdfResourceValueTypes() {
64
+ return this.itemType.toRdfResourceValueTypes;
65
+ }
58
66
  get validationFunction() {
59
67
  return Maybe.of(code `${this.reusables.snippets.validateMaybe}(${this.itemType.validationFunction.orDefault(this.itemValidationFunctionDefault)})`);
60
68
  }
@@ -71,10 +79,6 @@ export class OptionType extends AbstractContainerType {
71
79
  });
72
80
  return code `${expression}.map(item => (${itemFromJsonExpression}).map(${this.reusables.imports.Maybe}.of)).orDefault(${this.reusables.imports.Either}.of(${this.reusables.imports.Maybe}.empty()))`;
73
81
  }
74
- fromRdfResourceValuesExpression(parameters) {
75
- const { variables } = parameters;
76
- return code `${this.itemType.fromRdfResourceValuesExpression(parameters)}.map(values => values.length > 0 ? values.map(value => ${this.reusables.imports.Maybe}.of(value)) : ${this.reusables.imports.Resource}.Values.fromValue<${this.reusables.imports.Maybe}<${this.itemType.expression}>>({ focusResource: ${variables.resource}, propertyPath: ${variables.propertyPath}, value: ${this.reusables.imports.Maybe}.empty() }))`;
77
- }
78
82
  graphqlResolveExpression(parameters) {
79
83
  return code `${this.itemType.graphqlResolveExpression(parameters)}.extractNullable()`;
80
84
  }
@@ -84,7 +88,7 @@ export class OptionType extends AbstractContainerType {
84
88
  jsonType(parameters) {
85
89
  const itemTypeJsonType = this.itemType.jsonType(parameters);
86
90
  invariant(!itemTypeJsonType.optional);
87
- return new AbstractContainerType.JsonType(itemTypeJsonType.name, {
91
+ return new AbstractContainerType.JsonType(itemTypeJsonType.expression, {
88
92
  optional: true,
89
93
  });
90
94
  }
@@ -123,6 +127,9 @@ __decorate([
123
127
  __decorate([
124
128
  Memoize()
125
129
  ], OptionType.prototype, "filterType", null);
130
+ __decorate([
131
+ Memoize()
132
+ ], OptionType.prototype, "fromRdfResourceValuesFunction", null);
126
133
  __decorate([
127
134
  Memoize()
128
135
  ], OptionType.prototype, "graphqlType", null);
@@ -87,10 +87,7 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
87
87
  // objectsSync has per-object type logic, not just forwarding
88
88
  ];
89
89
  const runtimeObjectType = (filterFunction, namedObjectType) => {
90
- const fromRdfTypes = namedObjectType.fromRdfTypeVariable
91
- .toList()
92
- .concat(namedObjectType.descendantFromRdfTypeVariables);
93
- return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.expression}.fromRdfResource, fromRdfTypes: ${fromRdfTypes.length > 0 ? code `[${joinCode(fromRdfTypes, { on: ", " })}]` : "[]"} }`;
90
+ return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.expression}.fromRdfResource, fromRdfTypes: ${namedObjectType.fromRdfTypeVariable.map((fromRdfTypeVariable) => code `[${fromRdfTypeVariable}]`).orDefault(code `[]`)} }`;
94
91
  };
95
92
  switch (namedObjectType.kind) {
96
93
  case "Object": {
@@ -1,17 +1,32 @@
1
+ import { Maybe } from "purify-ts";
1
2
  import { AbstractCollectionType } from "./AbstractCollectionType.js";
3
+ import type { AbstractContainerType } from "./AbstractContainerType.js";
2
4
  import { type Code } from "./ts-poet-wrapper.js";
3
5
  export declare class SetType<ItemTypeT extends SetType.ItemType> extends AbstractCollectionType<ItemTypeT> {
4
6
  readonly graphqlArgs: AbstractCollectionType<ItemTypeT>["graphqlArgs"];
7
+ readonly jsTypes: readonly [{
8
+ readonly instanceof: "Array";
9
+ readonly typeof: "object";
10
+ }];
5
11
  readonly kind = "Set";
12
+ readonly minCount: bigint;
13
+ constructor({ minCount, ...superParameters }: {
14
+ minCount: bigint;
15
+ } & ConstructorParameters<typeof AbstractCollectionType<ItemTypeT>>[0]);
16
+ get conversionFunction(): Maybe<AbstractCollectionType.ConversionFunction>;
17
+ get fromRdfResourceValuesFunction(): Code;
18
+ get toRdfResourceValueTypes(): AbstractCollectionType<ItemTypeT>["toRdfResourceValueTypes"];
6
19
  get valueSparqlConstructTriplesFunction(): Code;
7
20
  get valueSparqlWherePatternsFunction(): Code;
8
- fromRdfResourceValuesExpression(parameters: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
21
+ protected get schemaInitializers(): readonly Code[];
22
+ fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
23
+ jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
9
24
  jsonType(): AbstractCollectionType.JsonType;
10
25
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toRdfResourceValuesExpression"]>[0]): Code;
11
26
  toStringExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toStringExpression"]>[0]): Code;
12
27
  }
13
28
  export declare namespace SetType {
14
29
  type ItemType = AbstractCollectionType.ItemType;
15
- const isItemType: typeof import("./AbstractContainerType.js").AbstractContainerType.isItemType;
30
+ const isItemType: typeof AbstractContainerType.isItemType;
16
31
  }
17
32
  //# sourceMappingURL=SetType.d.ts.map
@@ -5,28 +5,98 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { Maybe } from "purify-ts";
8
+ import { invariant } from "ts-invariant";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractCollectionType } from "./AbstractCollectionType.js";
10
- import { code, joinCode } from "./ts-poet-wrapper.js";
11
+ import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
11
12
  export class SetType extends AbstractCollectionType {
12
13
  graphqlArgs = Maybe.empty();
14
+ jsTypes = [
15
+ { instanceof: "Array", typeof: "object" },
16
+ ];
13
17
  kind = "Set";
18
+ minCount;
19
+ constructor({ minCount, ...superParameters }) {
20
+ super(superParameters);
21
+ this.minCount = minCount;
22
+ invariant(this.minCount >= 0n);
23
+ if (this._mutable) {
24
+ invariant(this.minCount === 0n);
25
+ }
26
+ }
27
+ get conversionFunction() {
28
+ const itemConversionFunction = this.itemType.conversionFunction.orDefault(this.itemConversionFunctionDefault);
29
+ let conversionFunction;
30
+ const sourceTypes = [];
31
+ if (itemConversionFunction.sourceTypes.some((sourceType) => sourceType.jsType.typeof === "object" &&
32
+ sourceType.jsType.instanceof === "Array")) {
33
+ conversionFunction = this.reusables.snippets.convertToArraySet;
34
+ }
35
+ else {
36
+ conversionFunction = this.reusables.snippets.convertToScalarSet;
37
+ // Convert from a single item
38
+ sourceTypes.push(...itemConversionFunction.sourceTypes);
39
+ }
40
+ // Convert from an array of items
41
+ sourceTypes.push({
42
+ expression: code `readonly (${joinCode(itemConversionFunction.sourceTypes.map((itemSourceType) => code `${itemSourceType.expression}`), { on: " | " })})[]`,
43
+ jsType: { instanceof: "Array", typeof: "object" },
44
+ });
45
+ // Convert from undefined to an empty array
46
+ if (this.minCount === 0n) {
47
+ sourceTypes.push({
48
+ expression: code `undefined`,
49
+ jsType: { typeof: "undefined" },
50
+ });
51
+ }
52
+ return Maybe.of({
53
+ code: code `${conversionFunction}(${itemConversionFunction.code}, ${literalOf(!this._mutable)})`,
54
+ sourceTypes,
55
+ });
56
+ }
57
+ get fromRdfResourceValuesFunction() {
58
+ return code `${this._mutable ? this.reusables.snippets.mutableSetFromRdfResourceValues : this.reusables.snippets.setFromRdfResourceValues}<${this.itemType.expression}, ${this.itemType.schemaType}>(${this.itemType.fromRdfResourceValuesFunction})`;
59
+ }
60
+ get toRdfResourceValueTypes() {
61
+ return this.itemType.toRdfResourceValueTypes;
62
+ }
14
63
  get valueSparqlConstructTriplesFunction() {
15
64
  return code `${this.reusables.snippets.setSparqlConstructTriples}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlConstructTriplesFunction})`;
16
65
  }
17
66
  get valueSparqlWherePatternsFunction() {
18
67
  return code `${this.reusables.snippets.setSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
19
68
  }
20
- fromRdfResourceValuesExpression(parameters) {
21
- const { variables } = parameters;
22
- return joinCode([
23
- this.itemType.fromRdfResourceValuesExpression(parameters),
24
- code `map(values => values.toArray()${this._mutable ? ".concat()" : ""})`,
25
- code `map(valuesArray => ${this.reusables.imports.Resource}.Values.fromValue({ focusResource: ${variables.resource}, propertyPath: ${variables.propertyPath}, value: valuesArray }))`,
26
- ], { on: "." });
69
+ get schemaInitializers() {
70
+ let schemaInitializers = super.schemaInitializers;
71
+ if (this.minCount > 0n) {
72
+ schemaInitializers = schemaInitializers.concat(code `minCount: ${Number(this.minCount)}`);
73
+ }
74
+ return schemaInitializers;
75
+ }
76
+ fromJsonExpression({ variables, }) {
77
+ let expression = variables.value;
78
+ if (this.minCount === 0n) {
79
+ expression = code `(${expression} ?? [])`;
80
+ }
81
+ return code `${this.reusables.imports.Either}.sequence<Error, ${this.itemType.expression}>(${expression}.map(item => (${this.itemType.fromJsonExpression({
82
+ variables: { value: code `item` },
83
+ })})))`;
84
+ }
85
+ jsonSchema(parameters) {
86
+ let schema = code `${this.itemType.jsonSchema(parameters)}.array()`;
87
+ if (this.minCount > 0n) {
88
+ schema = code `${schema}.nonempty().min(${this.minCount})`;
89
+ }
90
+ else {
91
+ schema = code `${schema}.optional()`;
92
+ }
93
+ if (!this._mutable) {
94
+ schema = code `${schema}.readonly()`;
95
+ }
96
+ return schema;
27
97
  }
28
98
  jsonType() {
29
- const name = code `${!this.mutable ? "readonly " : ""}(${this.itemType.jsonType().name})[]`;
99
+ const name = code `${!this.mutable ? "readonly " : ""}(${this.itemType.jsonType().expression})[]`;
30
100
  if (this.minCount === 0n) {
31
101
  return new AbstractCollectionType.JsonType(name, { optional: true });
32
102
  }
@@ -41,6 +111,12 @@ export class SetType extends AbstractCollectionType {
41
111
  return code `(${variables.value}.length > 0 ? \`[\${${variables.value}.map(item => (${this.itemType.toStringExpression({ variables: { value: code `item` } })}))}]\` : undefined)`;
42
112
  }
43
113
  }
114
+ __decorate([
115
+ Memoize()
116
+ ], SetType.prototype, "conversionFunction", null);
117
+ __decorate([
118
+ Memoize()
119
+ ], SetType.prototype, "fromRdfResourceValuesFunction", null);
44
120
  __decorate([
45
121
  Memoize()
46
122
  ], SetType.prototype, "valueSparqlConstructTriplesFunction", null);
@@ -34,9 +34,9 @@ export declare class Snippets {
34
34
  get IdentifierSet(): Snippet;
35
35
  get IriFilter(): Snippet;
36
36
  get IriSchema(): Snippet;
37
- get LazyObject(): Snippet;
38
- get LazyObjectOption(): Snippet;
39
- get LazyObjectSet(): Snippet;
37
+ get Lazy(): Snippet;
38
+ get LazyOption(): Snippet;
39
+ get LazySet(): Snippet;
40
40
  get LiteralFilter(): Snippet;
41
41
  get LiteralSchema(): Snippet;
42
42
  get MaybeFilter(): Snippet;
@@ -63,29 +63,38 @@ export declare class Snippets {
63
63
  get _ToRdfResourceFunction(): Snippet;
64
64
  get arrayEquals(): Snippet;
65
65
  get arrayIntersection(): Snippet;
66
+ get bigDecimalFromRdfResourceValues(): Snippet;
66
67
  get bigDecimalLiteral(): Snippet;
67
68
  get bigDecimalSparqlWherePatterns(): Snippet;
69
+ get bigIntFromRdfResourceValues(): Snippet;
70
+ get blankNodeFromRdfResourceValues(): Snippet;
68
71
  get blankNodeSparqlWherePatterns(): Snippet;
69
72
  get booleanEquals(): Snippet;
73
+ get booleanFromRdfResourceValues(): Snippet;
70
74
  get booleanSparqlWherePatterns(): Snippet;
71
75
  get compactRecord(): Snippet;
72
- get convertToArray(): Snippet;
76
+ get convertToArraySet(): Snippet;
73
77
  get convertToBlankNode(): Snippet;
74
78
  get convertToBlankNodeIdentifierProperty(): Snippet;
75
79
  get convertToIdentifier(): Snippet;
76
80
  get convertToIdentifierProperty(): Snippet;
77
81
  get convertToIri(): Snippet;
78
82
  get convertToIriIdentifierProperty(): Snippet;
79
- get convertToLazyObject(): Snippet;
80
- get convertToLazyObjectOption(): Snippet;
81
- get convertToLazyObjectSet(): Snippet;
83
+ get convertToLazy(): Snippet;
84
+ get convertToLazyOption(): Snippet;
85
+ get convertToLazySet(): Snippet;
86
+ get convertToList(): Snippet;
82
87
  get convertToLiteral(): Snippet;
83
88
  get convertToMaybe(): Snippet;
89
+ get convertToScalarSet(): Snippet;
84
90
  get convertWithDefaultValue(): Snippet;
85
91
  get dateEquals(): Snippet;
92
+ get dateFromRdfResourceValues(): Snippet;
86
93
  get dateSparqlWherePatterns(): Snippet;
94
+ get dateTimeFromRdfResourceValues(): Snippet;
87
95
  get decodeBigDecimalLiteral(): Snippet;
88
96
  get deduplicateSparqlPatterns(): Snippet;
97
+ get defaultValueFromRdfResourceValues(): Snippet;
89
98
  get defaultValueSparqlWherePatterns(): Snippet;
90
99
  get ensureRdfResourceType(): Snippet;
91
100
  get filterArray(): Snippet;
@@ -100,8 +109,7 @@ export declare class Snippets {
100
109
  get filterNumeric(): Snippet;
101
110
  get filterString(): Snippet;
102
111
  get filterTerm(): Snippet;
103
- get fromRdfLanguageIn(): Snippet;
104
- get fromRdfPreferredLanguages(): Snippet;
112
+ get floatFromRdfResourceValues(): Snippet;
105
113
  get hashArray(): Snippet;
106
114
  get hashBigDecimal(): Snippet;
107
115
  get hashBoolean(): Snippet;
@@ -111,27 +119,36 @@ export declare class Snippets {
111
119
  get hashNumeric(): Snippet;
112
120
  get hashString(): Snippet;
113
121
  get hashTerm(): Snippet;
122
+ get identifierFromRdfResourceValues(): Snippet;
114
123
  get identifierSparqlWherePatterns(): Snippet;
115
124
  get identityConversionFunction(): Snippet;
116
125
  get identityValidationFunction(): Snippet;
117
126
  get ifUsed(): Code[];
127
+ get intFromRdfResourceValues(): Snippet;
128
+ get iriFromRdfResourceValues(): Snippet;
118
129
  get iriSparqlWherePatterns(): Snippet;
119
130
  get liftSparqlPatterns(): Snippet;
131
+ get listFromRdfResourceValues(): Snippet;
120
132
  get listSparqlConstructTriples(): Snippet;
121
133
  get listSparqlWherePatterns(): Snippet;
122
134
  get literalFactory(): Snippet;
135
+ get literalFromRdfResourceValues(): Snippet;
123
136
  get literalSchemaSparqlPatterns(): Snippet;
124
137
  get literalSparqlWherePatterns(): Snippet;
125
138
  get maybeEquals(): Snippet;
139
+ get maybeFromRdfResourceValues(): Snippet;
126
140
  get maybeSparqlConstructTriples(): Snippet;
127
141
  get maybeSparqlWherePatterns(): Snippet;
128
142
  get monkeyPatchObject(): Snippet;
143
+ get mutableListFromRdfResourceValues(): Snippet;
144
+ get mutableSetFromRdfResourceValues(): Snippet;
129
145
  get normalizeSparqlWherePatterns(): Snippet;
130
146
  get numericSparqlWherePatterns(): Snippet;
131
147
  get parseBlankNode(): Snippet;
132
148
  get parseIdentifier(): Snippet;
133
149
  get parseIri(): Snippet;
134
150
  get sequenceRecord(): Snippet;
151
+ get setFromRdfResourceValues(): Snippet;
135
152
  get setSparqlConstructTriples(): Snippet;
136
153
  get setSparqlWherePatterns(): Snippet;
137
154
  get shaclPropertyFromRdf(): Snippet;
@@ -142,8 +159,11 @@ export declare class Snippets {
142
159
  get sparqlPropertyPath(): Snippet;
143
160
  get sparqlValueInPattern(): Snippet;
144
161
  get strictEquals(): Snippet;
162
+ get stringFromRdfResourceValues(): Snippet;
145
163
  get stringSparqlWherePatterns(): Snippet;
146
164
  get termFilterSparqlPatterns(): Snippet;
165
+ get termFromRdfResourceValues(): Snippet;
166
+ get termLikeFromRdfResourceValues(): Snippet;
147
167
  get termSchemaSparqlPatterns(): Snippet;
148
168
  get termSparqlWherePatterns(): Snippet;
149
169
  get toIsoDateString(): Snippet;