@shaclmate/compiler 4.0.41 → 4.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +1 -0
  2. package/dist/ShapesGraphToAstTransformer.js +11 -43
  3. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.d.ts +17 -0
  4. package/dist/_ShapesGraphToAstTransformer/{transformPropertyShapeToAstObjectTypeProperty.js → transformPropertyShapeToAstStructTypeField.js} +71 -48
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +1 -1
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +29 -20
  7. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.d.ts → transformShapeToAstStructType.d.ts} +2 -2
  8. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.js → transformShapeToAstStructType.js} +35 -29
  9. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +2 -1
  10. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +1 -1
  11. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +9 -4
  12. package/dist/ast/AbstractCompoundType.d.ts +2 -2
  13. package/dist/ast/AbstractCompoundType.js +4 -4
  14. package/dist/ast/AbstractContainerType.d.ts +2 -2
  15. package/dist/ast/AbstractContainerType.js +4 -4
  16. package/dist/ast/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +10 -10
  17. package/dist/ast/{AbstractLazyObjectType.js → AbstractLazyType.js} +3 -3
  18. package/dist/ast/AbstractType.d.ts +1 -1
  19. package/dist/ast/AbstractType.js +3 -0
  20. package/dist/ast/Ast.d.ts +2 -4
  21. package/dist/ast/DefaultValueType.js +2 -1
  22. package/dist/ast/IntersectionType.d.ts +2 -2
  23. package/dist/ast/IntersectionType.js +3 -3
  24. package/dist/ast/LazyOptionType.d.ts +6 -0
  25. package/dist/ast/LazyOptionType.js +5 -0
  26. package/dist/ast/LazySetType.d.ts +6 -0
  27. package/dist/ast/LazySetType.js +5 -0
  28. package/dist/ast/LazyType.d.ts +5 -0
  29. package/dist/ast/LazyType.js +5 -0
  30. package/dist/ast/ListType.d.ts +2 -2
  31. package/dist/ast/ListType.js +4 -4
  32. package/dist/ast/OptionType.js +2 -1
  33. package/dist/ast/SetType.js +2 -1
  34. package/dist/ast/StructCompoundType.d.ts +12 -0
  35. package/dist/ast/{ObjectCompoundType.js → StructCompoundType.js} +18 -18
  36. package/dist/ast/StructIntersectionType.d.ts +4 -0
  37. package/dist/ast/StructIntersectionType.js +2 -0
  38. package/dist/ast/{ObjectType.d.ts → StructType.d.ts} +28 -27
  39. package/dist/ast/{ObjectType.js → StructType.js} +81 -78
  40. package/dist/ast/StructUnionType.d.ts +4 -0
  41. package/dist/ast/StructUnionType.js +2 -0
  42. package/dist/ast/Type.d.ts +5 -5
  43. package/dist/ast/Type.js +4 -4
  44. package/dist/ast/UnionType.d.ts +2 -2
  45. package/dist/ast/UnionType.js +3 -3
  46. package/dist/ast/index.d.ts +7 -7
  47. package/dist/ast/index.js +7 -7
  48. package/dist/generators/AstJsonGenerator.js +2 -2
  49. package/dist/generators/transformAstToLabeledPropertyGraph.js +8 -8
  50. package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
  51. package/dist/generators/ts/AbstractContainerType.js +6 -6
  52. package/dist/generators/ts/AbstractDateType.d.ts +1 -7
  53. package/dist/generators/ts/AbstractDateType.js +1 -11
  54. package/dist/generators/ts/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +7 -7
  55. package/dist/generators/ts/{AbstractLazyObjectType.js → AbstractLazyType.js} +19 -17
  56. package/dist/generators/ts/AbstractLiteralType.d.ts +2 -5
  57. package/dist/generators/ts/AbstractLiteralType.js +0 -21
  58. package/dist/generators/ts/AbstractNumericType.d.ts +1 -7
  59. package/dist/generators/ts/AbstractNumericType.js +15 -25
  60. package/dist/generators/ts/AbstractObjectSetType.d.ts +1 -1
  61. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  62. package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -1
  63. package/dist/generators/ts/AbstractPrimitiveType.js +1 -1
  64. package/dist/generators/ts/AbstractTermType.d.ts +6 -21
  65. package/dist/generators/ts/AbstractTermType.js +26 -55
  66. package/dist/generators/ts/AbstractType.d.ts +40 -47
  67. package/dist/generators/ts/AbstractType.js +17 -6
  68. package/dist/generators/ts/BigDecimalType.d.ts +3 -3
  69. package/dist/generators/ts/BigDecimalType.js +3 -8
  70. package/dist/generators/ts/BigIntType.d.ts +2 -2
  71. package/dist/generators/ts/BigIntType.js +7 -4
  72. package/dist/generators/ts/BlankNodeType.d.ts +2 -7
  73. package/dist/generators/ts/BlankNodeType.js +2 -7
  74. package/dist/generators/ts/BooleanType.d.ts +3 -3
  75. package/dist/generators/ts/BooleanType.js +12 -14
  76. package/dist/generators/ts/DateTimeType.d.ts +2 -2
  77. package/dist/generators/ts/DateTimeType.js +14 -4
  78. package/dist/generators/ts/DateType.d.ts +2 -2
  79. package/dist/generators/ts/DateType.js +14 -4
  80. package/dist/generators/ts/DefaultValueType.d.ts +8 -8
  81. package/dist/generators/ts/DefaultValueType.js +10 -12
  82. package/dist/generators/ts/FloatType.d.ts +2 -2
  83. package/dist/generators/ts/FloatType.js +7 -4
  84. package/dist/generators/ts/IdentifierType.d.ts +2 -2
  85. package/dist/generators/ts/IdentifierType.js +2 -7
  86. package/dist/generators/ts/IntType.d.ts +2 -2
  87. package/dist/generators/ts/IntType.js +7 -4
  88. package/dist/generators/ts/IriType.d.ts +2 -2
  89. package/dist/generators/ts/IriType.js +12 -14
  90. package/dist/generators/ts/{LazyObjectOptionType.d.ts → LazyOptionType.d.ts} +12 -11
  91. package/dist/generators/ts/{LazyObjectOptionType.js → LazyOptionType.js} +23 -14
  92. package/dist/generators/ts/LazySetType.d.ts +20 -0
  93. package/dist/generators/ts/{LazyObjectSetType.js → LazySetType.js} +22 -13
  94. package/dist/generators/ts/LazyType.d.ts +19 -0
  95. package/dist/generators/ts/{LazyObjectType.js → LazyType.js} +22 -13
  96. package/dist/generators/ts/ListType.d.ts +1 -1
  97. package/dist/generators/ts/ListType.js +9 -19
  98. package/dist/generators/ts/LiteralType.d.ts +3 -2
  99. package/dist/generators/ts/LiteralType.js +6 -2
  100. package/dist/generators/ts/ObjectType.d.ts +16 -3
  101. package/dist/generators/ts/ObjectType.js +301 -91
  102. package/dist/generators/ts/ObjectUnionType.js +40 -40
  103. package/dist/generators/ts/OptionType.d.ts +2 -2
  104. package/dist/generators/ts/OptionType.js +7 -5
  105. package/dist/generators/ts/SetType.d.ts +3 -3
  106. package/dist/generators/ts/SetType.js +8 -10
  107. package/dist/generators/ts/Snippets.d.ts +26 -8
  108. package/dist/generators/ts/Snippets.js +161 -35
  109. package/dist/generators/ts/StringType.d.ts +4 -3
  110. package/dist/generators/ts/StringType.js +18 -11
  111. package/dist/generators/ts/TermType.d.ts +7 -5
  112. package/dist/generators/ts/TermType.js +28 -9
  113. package/dist/generators/ts/TsGenerator.js +11 -6
  114. package/dist/generators/ts/Type.d.ts +4 -4
  115. package/dist/generators/ts/TypeFactory.d.ts +5 -5
  116. package/dist/generators/ts/TypeFactory.js +79 -58
  117. package/dist/generators/ts/UnionType.d.ts +23 -18
  118. package/dist/generators/ts/UnionType.js +227 -221
  119. package/dist/generators/ts/ZodGenerator.js +15 -7
  120. package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +24 -15
  121. package/dist/generators/ts/_ObjectType/AbstractProperty.js +1 -24
  122. package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +8 -6
  123. package/dist/generators/ts/_ObjectType/DiscriminantProperty.js +11 -24
  124. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +8 -2
  125. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +44 -16
  126. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.d.ts +4 -0
  127. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.js +28 -0
  128. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.d.ts +4 -0
  129. package/dist/generators/ts/_ObjectType/{ObjectType_equalsFunctionDeclaration.js → ObjectType_equalsFunctionExpression.js} +6 -10
  130. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.d.ts +4 -0
  131. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +12 -0
  132. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeExpression.d.ts +4 -0
  133. package/dist/generators/ts/_ObjectType/{ObjectType_filterTypeDeclaration.js → ObjectType_filterTypeExpression.js} +6 -8
  134. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_focusSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  135. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionExpression.js} +5 -9
  136. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_focusSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  137. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → ObjectType_focusSparqlWherePatternsFunctionExpression.js} +5 -9
  138. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.d.ts +4 -0
  139. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.js +12 -0
  140. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.d.ts +4 -0
  141. package/dist/generators/ts/_ObjectType/{ObjectType_fromRdfResourceFunctionDeclaration.js → ObjectType_fromRdfResourceFunctionExpression.js} +8 -16
  142. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeExpression.d.ts +4 -0
  143. package/dist/generators/ts/_ObjectType/{ObjectType_graphqlTypeVariableStatement.js → ObjectType_graphqlTypeExpression.js} +6 -13
  144. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.d.ts +4 -0
  145. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +30 -0
  146. package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +4 -0
  147. package/dist/generators/ts/_ObjectType/{identifierTypeDeclarations.js → ObjectType_identifierTypeDeclarations.js} +2 -5
  148. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +3 -3
  149. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +1 -2
  150. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.js +2 -6
  151. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.d.ts +4 -0
  152. package/dist/generators/ts/_ObjectType/{ObjectType_jsonSchemaFunctionDeclaration.js → ObjectType_jsonSchemaExpression.js} +3 -10
  153. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.d.ts +4 -0
  154. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.js +5 -0
  155. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.d.ts +4 -0
  156. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js +17 -0
  157. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +1 -1
  158. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.js +2 -2
  159. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +4 -0
  160. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +18 -0
  161. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +4 -0
  162. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +18 -0
  163. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -3
  164. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +5 -9
  165. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -3
  166. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +4 -8
  167. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.d.ts +4 -0
  168. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +14 -0
  169. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.d.ts +4 -0
  170. package/dist/generators/ts/_ObjectType/{ObjectType_toRdfResourceFunctionDeclaration.js → ObjectType_toRdfResourceFunctionExpression.js} +6 -12
  171. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.d.ts +4 -0
  172. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.js +7 -0
  173. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.d.ts +4 -0
  174. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.js +5 -0
  175. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_valueSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  176. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionExpression.js +8 -0
  177. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_valueSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  178. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionExpression.js +10 -0
  179. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +9 -2
  180. package/dist/generators/ts/_ObjectType/ShaclProperty.js +65 -33
  181. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +4 -3
  182. package/dist/generators/ts/_snippets/snippets_DateSchema.js +4 -3
  183. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
  184. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +6 -5
  185. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +2 -1
  186. package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -0
  187. package/dist/generators/ts/_snippets/snippets_Lazy.d.ts +3 -0
  188. package/dist/generators/ts/_snippets/snippets_Lazy.js +22 -0
  189. package/dist/generators/ts/_snippets/snippets_LazyOption.d.ts +3 -0
  190. package/dist/generators/ts/_snippets/snippets_LazyOption.js +25 -0
  191. package/dist/generators/ts/_snippets/snippets_LazySet.d.ts +3 -0
  192. package/dist/generators/ts/_snippets/snippets_LazySet.js +40 -0
  193. package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +1 -3
  194. package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -0
  195. package/dist/generators/ts/_snippets/snippets_NumericSchema.js +2 -1
  196. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +6 -8
  197. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +32 -32
  198. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
  199. package/dist/generators/ts/_snippets/snippets_StringSchema.js +5 -3
  200. package/dist/generators/ts/_snippets/snippets_TermFilter.js +3 -3
  201. package/dist/generators/ts/_snippets/snippets_TermSchema.js +4 -2
  202. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.d.ts +3 -0
  203. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +6 -0
  204. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.d.ts +3 -0
  205. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.js +6 -0
  206. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.d.ts +3 -0
  207. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.js +6 -0
  208. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.d.ts +3 -0
  209. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.js +6 -0
  210. package/dist/generators/ts/_snippets/snippets_convertToLazy.d.ts +3 -0
  211. package/dist/generators/ts/_snippets/snippets_convertToLazy.js +15 -0
  212. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.d.ts +3 -0
  213. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.js +33 -0
  214. package/dist/generators/ts/_snippets/snippets_convertToLazySet.d.ts +3 -0
  215. package/dist/generators/ts/_snippets/snippets_convertToLazySet.js +27 -0
  216. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.d.ts +3 -0
  217. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.js +6 -0
  218. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.d.ts +3 -0
  219. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.js +6 -0
  220. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.d.ts +3 -0
  221. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.js +10 -0
  222. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  223. package/dist/generators/ts/_snippets/snippets_filterNumeric.js +1 -1
  224. package/dist/generators/ts/_snippets/snippets_filterTerm.js +1 -2
  225. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.d.ts +3 -0
  226. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.js +6 -0
  227. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.d.ts +3 -0
  228. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.js +6 -0
  229. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.d.ts +3 -0
  230. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.js +6 -0
  231. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.d.ts +3 -0
  232. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.js +6 -0
  233. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.d.ts +3 -0
  234. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.js +15 -0
  235. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.d.ts +3 -0
  236. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +6 -0
  237. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.d.ts +3 -0
  238. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.js +11 -0
  239. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.d.ts +3 -0
  240. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.js +8 -0
  241. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.d.ts +3 -0
  242. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.js +8 -0
  243. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +1 -1
  244. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.d.ts +3 -0
  245. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.js +9 -0
  246. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +13 -7
  247. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.d.ts +3 -0
  248. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.js +6 -0
  249. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +1 -1
  250. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.d.ts +3 -0
  251. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +17 -0
  252. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.d.ts +3 -0
  253. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +60 -0
  254. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
  255. package/dist/input/generated.d.ts +511 -386
  256. package/dist/input/generated.js +1780 -2293
  257. package/package.json +2 -2
  258. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +0 -9
  259. package/dist/ast/LazyObjectOptionType.d.ts +0 -6
  260. package/dist/ast/LazyObjectOptionType.js +0 -5
  261. package/dist/ast/LazyObjectSetType.d.ts +0 -6
  262. package/dist/ast/LazyObjectSetType.js +0 -5
  263. package/dist/ast/LazyObjectType.d.ts +0 -5
  264. package/dist/ast/LazyObjectType.js +0 -5
  265. package/dist/ast/ObjectCompoundType.d.ts +0 -12
  266. package/dist/ast/ObjectIntersectionType.d.ts +0 -4
  267. package/dist/ast/ObjectIntersectionType.js +0 -2
  268. package/dist/ast/ObjectUnionType.d.ts +0 -4
  269. package/dist/ast/ObjectUnionType.js +0 -2
  270. package/dist/generators/ts/LazyObjectSetType.d.ts +0 -20
  271. package/dist/generators/ts/LazyObjectType.d.ts +0 -19
  272. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
  273. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +0 -44
  274. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +0 -5
  275. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -5
  276. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +0 -21
  277. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -5
  278. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  279. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +0 -18
  280. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  281. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  282. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  283. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  284. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.js +0 -10
  285. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  286. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +0 -4
  287. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +0 -41
  288. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
  289. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +0 -12
  290. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  291. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  292. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +0 -9
  293. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  294. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +0 -15
  295. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -5
  296. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +0 -12
  297. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  298. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +0 -20
  299. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  300. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +0 -4
  301. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.js +0 -29
  302. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +0 -11
  303. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +0 -13
  304. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
  305. package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +0 -3
  306. package/dist/generators/ts/_snippets/snippets_LazyObject.js +0 -22
  307. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +0 -3
  308. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +0 -25
  309. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +0 -3
  310. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +0 -40
  311. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +0 -3
  312. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +0 -15
  313. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +0 -3
  314. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +0 -31
  315. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +0 -3
  316. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +0 -25
  317. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +0 -3
  318. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +0 -15
  319. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +0 -3
  320. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +0 -23
@@ -1,5 +1,5 @@
1
- import { ObjectType_jsonSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js";
2
- import { ObjectType_jsonTypeAliasDeclaration } from "./_ObjectType/ObjectType_jsonTypeAliasDeclaration.js";
1
+ import { ObjectType_jsonSchemaExpression } from "./_ObjectType/ObjectType_jsonSchemaExpression.js";
2
+ import { ObjectType_jsonTypeExpression } from "./_ObjectType/ObjectType_jsonTypeExpression.js";
3
3
  import { Reusables } from "./Reusables.js";
4
4
  import { TsGenerator } from "./TsGenerator.js";
5
5
  import { TypeFactory } from "./TypeFactory.js";
@@ -20,14 +20,16 @@ export class ZodGenerator {
20
20
  const declarations = [];
21
21
  for (const astNamedType of ast_.namedTypes) {
22
22
  switch (astNamedType.kind) {
23
- case "Object": {
23
+ case "Struct": {
24
24
  const tsNamedObjectType = typeFactory.createObjectType(astNamedType);
25
25
  declarations.push(code `\
26
- export namespace ${tsNamedObjectType.alias.unsafeCoerce()} {
27
- ${joinCode(ObjectType_jsonTypeAliasDeclaration.call(tsNamedObjectType).toList())}
26
+ export namespace ${tsNamedObjectType.name.unsafeCoerce()} {
27
+ export type Json = ${ObjectType_jsonTypeExpression.call(tsNamedObjectType)};
28
28
 
29
29
  export namespace Json {
30
- ${joinCode(ObjectType_jsonSchemaFunctionDeclaration.call(tsNamedObjectType).toList())}
30
+ export function schema() {
31
+ return ${ObjectType_jsonSchemaExpression.call(tsNamedObjectType)};
32
+ }
31
33
  }
32
34
  }`);
33
35
  break;
@@ -35,7 +37,7 @@ export namespace ${tsNamedObjectType.alias.unsafeCoerce()} {
35
37
  case "Union": {
36
38
  const tsNamedUnionType = typeFactory.createUnionType(astNamedType);
37
39
  declarations.push(code `\
38
- export namespace ${tsNamedUnionType.alias.unsafeCoerce()} {
40
+ export namespace ${tsNamedUnionType.name.unsafeCoerce()} {
39
41
  ${tsNamedUnionType.jsonTypeAliasDeclaration}
40
42
  export namespace Json {
41
43
  ${tsNamedUnionType.jsonSchemaFunctionDeclaration}
@@ -43,6 +45,12 @@ export namespace ${tsNamedUnionType.alias.unsafeCoerce()} {
43
45
  }`);
44
46
  break;
45
47
  }
48
+ default: {
49
+ const type = typeFactory.createType(astNamedType);
50
+ type.declaration.ifJust((declaration) => {
51
+ declarations.push(declaration);
52
+ });
53
+ }
46
54
  }
47
55
  }
48
56
  declarations.splice(0, 0, joinCode(reusables.snippets.ifUsed, { on: "\n\n" }));
@@ -1,4 +1,4 @@
1
- import { Maybe } from "purify-ts";
1
+ import type { Maybe } from "purify-ts";
2
2
  import type { Logger } from "ts-log";
3
3
  import type { Reusables } from "../Reusables.js";
4
4
  import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
@@ -9,19 +9,22 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "express
9
9
  protected readonly configuration: TsGenerator.Configuration;
10
10
  protected readonly logger: Logger;
11
11
  protected readonly objectType: {
12
- readonly alias: Maybe<string>;
12
+ readonly name: Maybe<string>;
13
13
  };
14
14
  protected readonly reusables: Reusables;
15
15
  /**
16
16
  * Optional parameter to include in the parameters object of constructor function.
17
17
  */
18
- abstract readonly constructorParameter: Maybe<Code>;
18
+ abstract readonly constructorParameter: Maybe<{
19
+ readonly hasQuestionToken: boolean;
20
+ readonly signature: Code;
21
+ }>;
19
22
  /**
20
- * Property declaration to include in a class or interface declaration of the object type.
23
+ * Property declaration to include in the type declaration of the ObjectType.
21
24
  */
22
25
  abstract readonly declaration: Code;
23
26
  /**
24
- * Optional property in the object type's filter.
27
+ * Optional property in the ObjectType's filter.
25
28
  */
26
29
  abstract readonly filterProperty: Maybe<{
27
30
  readonly name: string;
@@ -39,6 +42,12 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "express
39
42
  resolve: Code;
40
43
  type: Code;
41
44
  }>;
45
+ /**
46
+ * Parameter to include in the expression of the ObjectType passed to its hash function.
47
+ *
48
+ * Only specified if different from declaration.
49
+ */
50
+ abstract readonly hashFunctionParameter: Code;
42
51
  /**
43
52
  * zod object key: schema.
44
53
  */
@@ -66,6 +75,14 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "express
66
75
  * Is the property's type the ObjectType or does its type indirectly reference the ObjectType?
67
76
  */
68
77
  abstract readonly recursive: boolean;
78
+ /**
79
+ * TypeScript object describing this type, for runtime use.
80
+ */
81
+ abstract readonly schema: Maybe<Code>;
82
+ /**
83
+ * TypeScript type describing .schema.
84
+ */
85
+ abstract readonly schemaType: Maybe<Code>;
69
86
  /**
70
87
  * Property type
71
88
  . */
@@ -75,19 +92,11 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "express
75
92
  logger: Logger;
76
93
  name: string;
77
94
  objectType: {
78
- readonly alias: Maybe<string>;
95
+ readonly name: Maybe<string>;
79
96
  };
80
97
  reusables: Reusables;
81
98
  type: TypeT;
82
99
  });
83
- /**
84
- * TypeScript object describing this type, for runtime use.
85
- */
86
- get schema(): Maybe<Code>;
87
- /**
88
- * Helper to compose the result of schema along the type hierarchy.
89
- */
90
- protected get schemaInitializers(): readonly Code[];
91
100
  /**
92
101
  * Expression to access the value of this property on an object instance. May evaluate a thunk.
93
102
  */
@@ -118,10 +127,10 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "express
118
127
  abstract fromRdfResourceValuesInitializer(parameters: {
119
128
  variables: {
120
129
  context: Code;
130
+ focusResource: Code;
121
131
  graph: Code;
122
132
  objectSet: Code;
123
133
  preferredLanguages: Code;
124
- resource: Code;
125
134
  };
126
135
  }): Maybe<Code>;
127
136
  /**
@@ -1,13 +1,5 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { Maybe } from "purify-ts";
8
- import { Memoize } from "typescript-memoize";
9
1
  import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
10
- import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
2
+ import { code } from "../ts-poet-wrapper.js";
11
3
  export class AbstractProperty {
12
4
  configuration;
13
5
  logger;
@@ -34,18 +26,6 @@ export class AbstractProperty {
34
26
  snippets: this.reusables.snippets,
35
27
  });
36
28
  }
37
- /**
38
- * TypeScript object describing this type, for runtime use.
39
- */
40
- get schema() {
41
- return Maybe.of(code `{ ${joinCode(this.schemaInitializers.concat(), { on: ", " })} }`);
42
- }
43
- /**
44
- * Helper to compose the result of schema along the type hierarchy.
45
- */
46
- get schemaInitializers() {
47
- return [code `kind: ${literalOf(this.kind)}`];
48
- }
49
29
  /**
50
30
  * Expression to access the value of this property on an object instance. May evaluate a thunk.
51
31
  */
@@ -54,7 +34,4 @@ export class AbstractProperty {
54
34
  }
55
35
  rdfjsTermExpression;
56
36
  }
57
- __decorate([
58
- Memoize()
59
- ], AbstractProperty.prototype, "schema", null);
60
37
  //# sourceMappingURL=AbstractProperty.js.map
@@ -2,21 +2,24 @@ import { Maybe } from "purify-ts";
2
2
  import { type Code } from "../ts-poet-wrapper.js";
3
3
  import { AbstractProperty } from "./AbstractProperty.js";
4
4
  export declare class DiscriminantProperty extends AbstractProperty<DiscriminantProperty.Type> {
5
- readonly constructorParameter: Maybe<Code>;
5
+ readonly constructorParameter: AbstractProperty<DiscriminantProperty.Type>["constructorParameter"];
6
+ readonly declaration: Code;
6
7
  readonly filterProperty: AbstractProperty<DiscriminantProperty.Type>["filterProperty"];
7
8
  readonly graphqlField: AbstractProperty<DiscriminantProperty.Type>["graphqlField"];
9
+ readonly hashFunctionParameter: Code;
10
+ readonly jsonName = "@type";
11
+ readonly jsonSignature: Maybe<Code>;
8
12
  readonly kind = "Discriminant";
9
13
  readonly mutable = false;
10
14
  readonly recursive = false;
15
+ readonly schema: Maybe<Code>;
16
+ readonly schemaType: Maybe<Code>;
11
17
  readonly value: string;
12
18
  constructor({ value, ...superParameters }: {
13
19
  value: string;
14
20
  } & Omit<ConstructorParameters<typeof AbstractProperty>[0], "type">);
15
- get declaration(): Code;
16
- get jsonName(): string;
17
21
  get jsonSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonSchema"];
18
- get jsonSignature(): Maybe<Code>;
19
- get schema(): Maybe<Code>;
22
+ get values(): readonly string[];
20
23
  private get constValue();
21
24
  constructorInitializer(): Maybe<Code>;
22
25
  fromJsonInitializer(): Maybe<Code>;
@@ -28,7 +31,6 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
28
31
  toJsonInitializer({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["toJsonInitializer"]>[0]): Maybe<Code>;
29
32
  toRdfRdfResourceValuesStatements(): readonly Code[];
30
33
  toStringInitializer(): Maybe<Code>;
31
- get values(): readonly string[];
32
34
  }
33
35
  export declare namespace DiscriminantProperty {
34
36
  class Type {
@@ -10,37 +10,31 @@ import { code, literalOf } from "../ts-poet-wrapper.js";
10
10
  import { AbstractProperty } from "./AbstractProperty.js";
11
11
  export class DiscriminantProperty extends AbstractProperty {
12
12
  constructorParameter = Maybe.empty();
13
+ declaration = code `readonly ${this.name}: ${this.type.expression};`;
13
14
  filterProperty = Maybe.empty();
14
15
  graphqlField = Maybe.empty();
16
+ hashFunctionParameter = code `readonly ${this.name}?: ${this.type.expression};`;
17
+ jsonName = "@type";
18
+ jsonSignature = Maybe.of(code `readonly "${this.jsonName}": ${this.type.expression}`);
15
19
  kind = "Discriminant";
16
20
  mutable = false;
17
21
  recursive = false;
22
+ schema = Maybe.empty();
23
+ schemaType = Maybe.empty();
18
24
  value;
19
25
  constructor({ value, ...superParameters }) {
20
26
  super({ ...superParameters, type: new DiscriminantProperty.Type(value) });
21
27
  this.value = value;
22
28
  }
23
- get declaration() {
24
- return code `readonly ${this.name}: ${this.type.expression};`;
25
- }
26
- get jsonName() {
27
- return "@type";
28
- }
29
29
  get jsonSchema() {
30
30
  return Maybe.of({
31
31
  key: this.jsonName,
32
32
  schema: code `${this.reusables.imports.z}.literal(${literalOf(this.value)})`,
33
33
  });
34
34
  }
35
- get jsonSignature() {
36
- return Maybe.of(code `readonly "${this.jsonName}": ${this.type.expression}`);
37
- }
38
- get schema() {
39
- return Maybe.empty();
35
+ get values() {
36
+ return [this.value];
40
37
  }
41
- // protected override get schemaInitializers(): readonly Code[] {
42
- // return super.schemaInitializers.concat(code`type: ${this.type.schema}`);
43
- // }
44
38
  get constValue() {
45
39
  return code `${literalOf(this.value)} as const`;
46
40
  }
@@ -54,7 +48,9 @@ export class DiscriminantProperty extends AbstractProperty {
54
48
  return Maybe.empty();
55
49
  }
56
50
  hashStatements({ variables, }) {
57
- return [code `${variables.hasher}.update(${variables.value});`];
51
+ return [
52
+ code `if (${variables.value}) { ${variables.hasher}.update(${variables.value}); }`,
53
+ ];
58
54
  }
59
55
  jsonUiSchemaElement({ variables, }) {
60
56
  const scope = code `\`\${${variables.scopePrefix}}/properties/${this.jsonName}\``;
@@ -75,19 +71,10 @@ export class DiscriminantProperty extends AbstractProperty {
75
71
  toStringInitializer() {
76
72
  return Maybe.empty();
77
73
  }
78
- get values() {
79
- return [this.value];
80
- }
81
74
  }
82
- __decorate([
83
- Memoize()
84
- ], DiscriminantProperty.prototype, "jsonName", null);
85
75
  __decorate([
86
76
  Memoize()
87
77
  ], DiscriminantProperty.prototype, "jsonSchema", null);
88
- __decorate([
89
- Memoize()
90
- ], DiscriminantProperty.prototype, "jsonSignature", null);
91
78
  __decorate([
92
79
  Memoize()
93
80
  ], DiscriminantProperty.prototype, "values", null);
@@ -8,17 +8,23 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
8
8
  readonly kind = "Identifier";
9
9
  readonly mutable = false;
10
10
  readonly recursive = false;
11
- get constructorParameter(): Maybe<Code>;
11
+ get constructorParameter(): Maybe<{
12
+ hasQuestionToken: boolean;
13
+ signature: Code;
14
+ }>;
12
15
  get declaration(): Code;
13
16
  get filterProperty(): Maybe<{
14
17
  name: string;
15
18
  type: Code;
16
19
  }>;
17
20
  get graphqlField(): AbstractProperty<IdentifierType>["graphqlField"];
21
+ get hashFunctionParameter(): Code;
18
22
  get jsonSchema(): AbstractProperty<IdentifierType>["jsonSchema"];
19
23
  get jsonSignature(): Maybe<Code>;
20
- protected get schemaInitializers(): readonly Code[];
24
+ get schema(): Maybe<Code>;
25
+ get schemaType(): Maybe<Code>;
21
26
  private get typeExpression();
27
+ private get typeSchemaVariable();
22
28
  accessExpression({ variables, }: Parameters<AbstractProperty<BlankNodeType | IdentifierType | IriType>["accessExpression"]>[0]): Code;
23
29
  constructorInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorInitializer"]>[0]): Maybe<Code>;
24
30
  fromJsonInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonInitializer"]>[0]): Maybe<Code>;
@@ -27,7 +27,10 @@ export class IdentifierProperty extends AbstractProperty {
27
27
  typeExpressions.push(code `${type.expression}`);
28
28
  }
29
29
  }
30
- return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeExpressions, { on: "|" })};`);
30
+ return Maybe.of({
31
+ hasQuestionToken,
32
+ signature: code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeExpressions, { on: "|" })};`,
33
+ });
31
34
  }
32
35
  get declaration() {
33
36
  return code `readonly ${this.name}: () => ${this.typeExpression};`;
@@ -45,10 +48,13 @@ export class IdentifierProperty extends AbstractProperty {
45
48
  args: Maybe.empty(),
46
49
  description: Maybe.empty(),
47
50
  name: `_${this.name.substring(syntheticNamePrefix.length)}`,
48
- resolve: code `(source) => ${this.typeExpression}.stringify(${this.accessExpression({ variables: { object: code `source` } })})`,
51
+ resolve: code `(source) => ${this.type.stringifyFunction}(${this.accessExpression({ variables: { object: code `source` } })})`,
49
52
  type: this.type.graphqlType.expression,
50
53
  });
51
54
  }
55
+ get hashFunctionParameter() {
56
+ return code `readonly ${this.name}?: () => ${this.typeExpression};`;
57
+ }
52
58
  get jsonSchema() {
53
59
  let schema;
54
60
  if (this.type.in_.length > 0 && this.type.kind === "Iri") {
@@ -70,14 +76,25 @@ export class IdentifierProperty extends AbstractProperty {
70
76
  }
71
77
  return Maybe.of(code `readonly "@id": string`);
72
78
  }
73
- get schemaInitializers() {
74
- return super.schemaInitializers.concat(code `type: ${this.type.schema}`);
79
+ get schema() {
80
+ return Maybe.of(code `{ ${joinCode([code `kind: ${literalOf(this.kind)}`, code `type: ${this.type.schema}`], { on: ", " })} }`);
81
+ }
82
+ get schemaType() {
83
+ return Maybe.of(code `{ ${joinCode([
84
+ code `readonly kind: ${literalOf(this.kind)}`,
85
+ code `readonly type: ${this.type.schemaType}`,
86
+ ], { on: ", " })} }`);
75
87
  }
76
88
  get typeExpression() {
77
- return this.objectType.alias
89
+ return this.objectType.name
78
90
  .map((objectTypeAlias) => code `${objectTypeAlias}.Identifier`)
79
91
  .orDefault(this.type.expression);
80
92
  }
93
+ get typeSchemaVariable() {
94
+ return this.objectType.name
95
+ .map((name) => code `${name}.schema.properties.${this.name}.type`)
96
+ .orDefaultLazy(() => this.type.schema);
97
+ }
81
98
  accessExpression({ variables, }) {
82
99
  return code `${variables.object}.${this.name}()`;
83
100
  }
@@ -106,16 +123,26 @@ export class IdentifierProperty extends AbstractProperty {
106
123
  })}`);
107
124
  }
108
125
  fromRdfResourceValuesInitializer({ variables, }) {
109
- return Maybe.of(code `${this.name}: ${this.type.fromRdfResourceValuesExpression({
110
- variables: {
111
- ...variables,
112
- propertyPath: this.rdfjsTermExpression(rdf.subject),
113
- resourceValues: code `${this.reusables.imports.Right}(new ${this.reusables.imports.Resource}.Value(${{ dataFactory: this.reusables.imports.dataFactory, focusResource: variables.resource, propertyPath: this.rdfjsTermExpression(rdf.subject), term: code `${variables.resource}.identifier` }}).toValues())`,
114
- },
115
- })}.chain(values => values.head())`);
126
+ const options = {
127
+ context: variables.context,
128
+ graph: variables.graph,
129
+ focusResource: variables.focusResource,
130
+ preferredLanguages: variables.preferredLanguages,
131
+ propertyPath: this.rdfjsTermExpression(rdf.subject),
132
+ schema: this.typeSchemaVariable,
133
+ };
134
+ if (this.configuration.features.has("ObjectSet")) {
135
+ options["objectSet"] = variables.objectSet;
136
+ }
137
+ return Maybe.of(code `${this.name}: ${this.type.fromRdfResourceValuesFunction}(
138
+ new ${this.reusables.imports.Resource}.Value(${{ dataFactory: this.reusables.imports.dataFactory, focusResource: variables.focusResource, propertyPath: this.rdfjsTermExpression(rdf.subject), term: code `${variables.focusResource}.identifier` }}).toValues(),
139
+ ${options}
140
+ ).chain(values => values.head())`);
116
141
  }
117
142
  hashStatements({ variables, }) {
118
- return [code `${variables.hasher}.update(${variables.value}.value);`];
143
+ return [
144
+ code `if (${variables.value}) { ${variables.hasher}.update(${variables.value}().value); }`,
145
+ ];
119
146
  }
120
147
  jsonUiSchemaElement({ variables, }) {
121
148
  return Maybe.of(code `{ label: "Identifier", scope: \`\${${variables.scopePrefix}}/properties/@id\`, type: "Control" }`);
@@ -131,9 +158,7 @@ export class IdentifierProperty extends AbstractProperty {
131
158
  ignoreRdfType: true, // Unused
132
159
  preferredLanguages: variables.preferredLanguages,
133
160
  propertyPatterns: code `[]`,
134
- schema: this.objectType.alias
135
- .map((objectTypeAlias) => code `${objectTypeAlias}.schema.properties.${this.name}.type`)
136
- .orDefault(this.type.schema),
161
+ schema: this.typeSchemaVariable,
137
162
  valueVariable: variables.focusIdentifier,
138
163
  variablePrefix: variables.variablePrefix, // Unused
139
164
  }})`,
@@ -176,6 +201,9 @@ __decorate([
176
201
  __decorate([
177
202
  Memoize()
178
203
  ], IdentifierProperty.prototype, "graphqlField", null);
204
+ __decorate([
205
+ Memoize()
206
+ ], IdentifierProperty.prototype, "hashFunctionParameter", null);
179
207
  __decorate([
180
208
  Memoize()
181
209
  ], IdentifierProperty.prototype, "jsonSchema", null);
@@ -0,0 +1,4 @@
1
+ import type { ObjectType } from "../ObjectType.js";
2
+ import { type Code } from "../ts-poet-wrapper.js";
3
+ export declare function ObjectType_createFunctionExpression(this: ObjectType): Code;
4
+ //# sourceMappingURL=ObjectType_createFunctionExpression.d.ts.map
@@ -0,0 +1,28 @@
1
+ import { invariant } from "ts-invariant";
2
+ import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
3
+ export function ObjectType_createFunctionExpression() {
4
+ const parametersVariable = code `parameters${this.constructorParameters.hasQuestionToken ? "?" : ""}`;
5
+ const propertyInitializers = this.properties.flatMap((property) => property
6
+ .constructorInitializer({
7
+ variables: { parameters: parametersVariable },
8
+ })
9
+ .toList());
10
+ invariant(propertyInitializers.length > 0);
11
+ let returnExpression = code `${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyInitializers, { on: "," })} })`;
12
+ this.discriminantProperty.ifJust((discriminantProperty) => {
13
+ returnExpression = code `${returnExpression}.map(properties => ({ ...properties, ${discriminantProperty.name}: ${literalOf(discriminantProperty.value)} as const }))`;
14
+ });
15
+ const monkeyPatchMethods = {};
16
+ if (this.configuration.features.has("Object.toJson")) {
17
+ monkeyPatchMethods["toJson"] = this.toJsonFunction;
18
+ }
19
+ if (this.configuration.features.has("Object.toString")) {
20
+ monkeyPatchMethods[`${this.configuration.syntheticNamePrefix}toString`] =
21
+ this.toStringFunction;
22
+ }
23
+ if (Object.keys(monkeyPatchMethods).length > 0) {
24
+ returnExpression = code `${returnExpression}.map(object => ${this.reusables.snippets.monkeyPatchObject}(object, ${monkeyPatchMethods}))`;
25
+ }
26
+ return code `((parameters${this.name.map(() => code ``).orDefaultLazy(() => code `: ${this.constructorParameters.type.expression}`)}) => ${returnExpression})`;
27
+ }
28
+ //# sourceMappingURL=ObjectType_createFunctionExpression.js.map
@@ -0,0 +1,4 @@
1
+ import type { ObjectType } from "../ObjectType.js";
2
+ import { type Code } from "../ts-poet-wrapper.js";
3
+ export declare function ObjectType_equalsFunctionExpression(this: ObjectType): Code;
4
+ //# sourceMappingURL=ObjectType_equalsFunctionExpression.d.ts.map
@@ -1,9 +1,5 @@
1
- import { Maybe } from "purify-ts";
2
1
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
- export function ObjectType_equalsFunctionDeclaration() {
4
- if (!this.configuration.features.has("Object.equals")) {
5
- return Maybe.empty();
6
- }
2
+ export function ObjectType_equalsFunctionExpression() {
7
3
  const chain = [];
8
4
  for (const property of this.properties) {
9
5
  if (property.kind === "Discriminant") {
@@ -11,9 +7,9 @@ export function ObjectType_equalsFunctionDeclaration() {
11
7
  }
12
8
  chain.push(code `(${property.type.equalsFunction})(${property.accessExpression({ variables: { object: code `left` } })}, ${property.accessExpression({ variables: { object: code `right` } })}).mapLeft(propertyValuesUnequal => ({ left, right, propertyName: "${property.name}", propertyValuesUnequal, type: "property" as const }))`);
13
9
  }
14
- return Maybe.of(code `\
15
- export function equals(left: ${this.expression}, right: ${this.expression}): ${this.reusables.snippets.EqualsResult} {
16
- return ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
17
- }`);
10
+ return code `\
11
+ ((left, right) =>
12
+ ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
13
+ )`;
18
14
  }
19
- //# sourceMappingURL=ObjectType_equalsFunctionDeclaration.js.map
15
+ //# sourceMappingURL=ObjectType_equalsFunctionExpression.js.map
@@ -0,0 +1,4 @@
1
+ import type { ObjectType } from "../ObjectType.js";
2
+ import { type Code } from "../ts-poet-wrapper.js";
3
+ export declare function ObjectType_filterFunctionExpression(this: ObjectType): Code;
4
+ //# sourceMappingURL=ObjectType_filterFunctionExpression.d.ts.map
@@ -0,0 +1,12 @@
1
+ import { code, joinCode } from "../ts-poet-wrapper.js";
2
+ export function ObjectType_filterFunctionExpression() {
3
+ const statements = [];
4
+ for (const property of this.properties) {
5
+ property.filterProperty.ifJust(({ name }) => {
6
+ statements.push(code `if (filter.${name} !== undefined && !${property.type.filterFunction}(filter.${name}, ${property.accessExpression({ variables: { object: code `value` } })})) { return false; }`);
7
+ });
8
+ }
9
+ statements.push(code `return true;`);
10
+ return code `((filter, value) => { ${joinCode(statements)} })`;
11
+ }
12
+ //# sourceMappingURL=ObjectType_filterFunctionExpression.js.map
@@ -0,0 +1,4 @@
1
+ import type { ObjectType } from "../ObjectType.js";
2
+ import { type Code } from "../ts-poet-wrapper.js";
3
+ export declare function ObjectType_filterTypeExpression(this: ObjectType): Code;
4
+ //# sourceMappingURL=ObjectType_filterTypeExpression.d.ts.map
@@ -1,9 +1,5 @@
1
- import { Maybe } from "purify-ts";
2
1
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
- export function ObjectType_filterTypeDeclaration() {
4
- if (!this.configuration.features.has("Object.filter")) {
5
- return Maybe.empty();
6
- }
2
+ export function ObjectType_filterTypeExpression() {
7
3
  const members = [];
8
4
  if (this.properties.length > 0) {
9
5
  const filterProperties = {};
@@ -16,7 +12,9 @@ export function ObjectType_filterTypeDeclaration() {
16
12
  members.push(code `{ ${joinCode(Object.entries(filterProperties).map(([name, type]) => code `readonly ${name}?: ${type}`), { on: ";" })} }`);
17
13
  }
18
14
  }
19
- return Maybe.of(code `\
20
- export type Filter = ${members.length > 0 ? joinCode(members, { on: " & " }) : "object"};`);
15
+ if (members.length > 0) {
16
+ return joinCode(members, { on: " & " });
17
+ }
18
+ return code `object`;
21
19
  }
22
- //# sourceMappingURL=ObjectType_filterTypeDeclaration.js.map
20
+ //# sourceMappingURL=ObjectType_filterTypeExpression.js.map
@@ -1,5 +1,4 @@
1
- import { Maybe } from "purify-ts";
2
1
  import type { ObjectType } from "../ObjectType.js";
3
2
  import { type Code } from "../ts-poet-wrapper.js";
4
- export declare function ObjectType_focusSparqlConstructTriplesFunctionDeclaration(this: ObjectType): Maybe<Code>;
5
- //# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts.map
3
+ export declare function ObjectType_focusSparqlConstructTriplesFunctionExpression(this: ObjectType): Code;
4
+ //# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionExpression.d.ts.map
@@ -1,15 +1,11 @@
1
1
  import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
2
- import { Maybe } from "purify-ts";
3
2
  import { code, joinCode } from "../ts-poet-wrapper.js";
4
3
  const variables = {
5
4
  filter: code `parameters.filter`,
6
5
  focusIdentifier: code `parameters.focusIdentifier`,
7
6
  variablePrefix: code `parameters.variablePrefix`,
8
7
  };
9
- export function ObjectType_focusSparqlConstructTriplesFunctionDeclaration() {
10
- if (!this.configuration.features.has("Object.SPARQL")) {
11
- return Maybe.empty();
12
- }
8
+ export function ObjectType_focusSparqlConstructTriplesFunctionExpression() {
13
9
  const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
14
10
  const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
15
11
  let triplesVariableDeclarationKeyword = "const";
@@ -36,8 +32,8 @@ if (!parameters?.ignoreRdfType) {
36
32
  triplesVariableDeclarationKeyword = "let";
37
33
  });
38
34
  }
39
- return Maybe.of(code `\
40
- export const focusSparqlConstructTriples: ${this.reusables.snippets.FocusSparqlConstructTriplesFunction}<${this.filterType}> = (${statements.length === 0 ? "_" : ""}parameters) => {
35
+ return code `\
36
+ ((${statements.length === 0 ? "_" : ""}parameters) => {
41
37
  ${statements.length > 0
42
38
  ? joinCode([
43
39
  code `${triplesVariableDeclarationKeyword} triples: ${this.reusables.imports.sparqljs}.Triple[] = [];`,
@@ -45,6 +41,6 @@ ${statements.length > 0
45
41
  code `return triples;`,
46
42
  ])
47
43
  : "return [];"}
48
- };`);
44
+ })`;
49
45
  }
50
- //# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js.map
46
+ //# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionExpression.js.map
@@ -1,5 +1,4 @@
1
- import { Maybe } from "purify-ts";
2
1
  import type { ObjectType } from "../ObjectType.js";
3
2
  import { type Code } from "../ts-poet-wrapper.js";
4
- export declare function ObjectType_focusSparqlWherePatternsFunctionDeclaration(this: ObjectType): Maybe<Code>;
5
- //# sourceMappingURL=ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts.map
3
+ export declare function ObjectType_focusSparqlWherePatternsFunctionExpression(this: ObjectType): Code;
4
+ //# sourceMappingURL=ObjectType_focusSparqlWherePatternsFunctionExpression.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
2
- import { Maybe } from "purify-ts";
3
2
  import { code, joinCode } from "../ts-poet-wrapper.js";
4
3
  const variables = {
5
4
  filter: code `parameters.filter`,
@@ -7,10 +6,7 @@ const variables = {
7
6
  focusIdentifier: code `parameters.focusIdentifier`,
8
7
  variablePrefix: code `parameters.variablePrefix`,
9
8
  };
10
- export function ObjectType_focusSparqlWherePatternsFunctionDeclaration() {
11
- if (!this.configuration.features.has("Object.SPARQL")) {
12
- return Maybe.empty();
13
- }
9
+ export function ObjectType_focusSparqlWherePatternsFunctionExpression() {
14
10
  const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
15
11
  const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
16
12
  let patternsVariableDeclarationKeyword = "const";
@@ -69,8 +65,8 @@ if (!parameters?.ignoreRdfType) {
69
65
  patternsVariableDeclarationKeyword = "let";
70
66
  });
71
67
  }
72
- return Maybe.of(code `\
73
- export const focusSparqlWherePatterns: ${this.reusables.snippets.FocusSparqlWherePatternsFunction}<${this.filterType}> = (${statements.length === 0 ? "_" : ""}parameters) => {
68
+ return code `\
69
+ ((${statements.length === 0 ? "_" : ""}parameters) => {
74
70
  ${statements.length > 0
75
71
  ? joinCode([
76
72
  code `${patternsVariableDeclarationKeyword} patterns: ${this.reusables.snippets.SparqlPattern}[] = [];`,
@@ -78,6 +74,6 @@ ${statements.length > 0
78
74
  code `return patterns;`,
79
75
  ])
80
76
  : "return [];"}
81
- };`);
77
+ })`;
82
78
  }
83
- //# sourceMappingURL=ObjectType_focusSparqlWherePatternsFunctionDeclaration.js.map
79
+ //# sourceMappingURL=ObjectType_focusSparqlWherePatternsFunctionExpression.js.map