@shaclmate/compiler 4.0.38 → 4.0.40

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 (256) hide show
  1. package/dist/ShapesGraphToAstTransformer.js +12 -12
  2. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +24 -24
  3. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -4
  4. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +16 -16
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
  7. package/dist/ast/AbstractCollectionType.d.ts +1 -1
  8. package/dist/ast/AbstractCompoundType.d.ts +1 -1
  9. package/dist/ast/AbstractCompoundType.js +15 -15
  10. package/dist/ast/AbstractContainerType.d.ts +1 -1
  11. package/dist/ast/AbstractContainerType.js +15 -15
  12. package/dist/ast/AbstractLazyObjectType.d.ts +1 -1
  13. package/dist/ast/AbstractTermType.d.ts +1 -1
  14. package/dist/ast/BlankNodeType.d.ts +1 -1
  15. package/dist/ast/BlankNodeType.js +1 -1
  16. package/dist/ast/DefaultValueType.d.ts +1 -1
  17. package/dist/ast/DefaultValueType.js +2 -2
  18. package/dist/ast/IdentifierType.d.ts +1 -1
  19. package/dist/ast/IdentifierType.js +1 -1
  20. package/dist/ast/IntersectionType.d.ts +1 -1
  21. package/dist/ast/IntersectionType.js +3 -3
  22. package/dist/ast/IriType.d.ts +1 -1
  23. package/dist/ast/IriType.js +1 -1
  24. package/dist/ast/LazyObjectOptionType.d.ts +1 -1
  25. package/dist/ast/LazyObjectOptionType.js +1 -1
  26. package/dist/ast/LazyObjectSetType.d.ts +1 -1
  27. package/dist/ast/LazyObjectSetType.js +1 -1
  28. package/dist/ast/LazyObjectType.d.ts +1 -1
  29. package/dist/ast/LazyObjectType.js +1 -1
  30. package/dist/ast/ListType.d.ts +1 -1
  31. package/dist/ast/ListType.js +16 -16
  32. package/dist/ast/LiteralType.d.ts +1 -1
  33. package/dist/ast/LiteralType.js +1 -1
  34. package/dist/ast/ObjectCompoundType.js +3 -3
  35. package/dist/ast/ObjectType.d.ts +1 -1
  36. package/dist/ast/ObjectType.js +16 -16
  37. package/dist/ast/OptionType.d.ts +1 -1
  38. package/dist/ast/OptionType.js +1 -1
  39. package/dist/ast/SetType.d.ts +1 -1
  40. package/dist/ast/SetType.js +1 -1
  41. package/dist/ast/TermType.d.ts +1 -1
  42. package/dist/ast/TermType.js +1 -1
  43. package/dist/ast/Type.js +15 -15
  44. package/dist/ast/UnionType.d.ts +1 -1
  45. package/dist/ast/UnionType.js +3 -3
  46. package/dist/generators/transformAstToLabeledPropertyGraph.js +10 -10
  47. package/dist/generators/ts/AbstractCollectionType.d.ts +2 -6
  48. package/dist/generators/ts/AbstractCollectionType.js +16 -15
  49. package/dist/generators/ts/AbstractContainerType.d.ts +7 -11
  50. package/dist/generators/ts/AbstractContainerType.js +35 -36
  51. package/dist/generators/ts/AbstractDateType.d.ts +4 -4
  52. package/dist/generators/ts/AbstractDateType.js +2 -2
  53. package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
  54. package/dist/generators/ts/AbstractLazyObjectType.d.ts +14 -17
  55. package/dist/generators/ts/AbstractLazyObjectType.js +26 -38
  56. package/dist/generators/ts/AbstractLiteralType.d.ts +1 -5
  57. package/dist/generators/ts/AbstractLiteralType.js +7 -6
  58. package/dist/generators/ts/AbstractNumericType.d.ts +2 -2
  59. package/dist/generators/ts/AbstractNumericType.js +3 -3
  60. package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
  61. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  62. package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -6
  63. package/dist/generators/ts/AbstractPrimitiveType.js +9 -10
  64. package/dist/generators/ts/AbstractTermType.d.ts +1 -5
  65. package/dist/generators/ts/AbstractTermType.js +3 -17
  66. package/dist/generators/ts/AbstractType.d.ts +22 -15
  67. package/dist/generators/ts/AbstractType.js +18 -8
  68. package/dist/generators/ts/BigDecimalType.d.ts +2 -2
  69. package/dist/generators/ts/BigDecimalType.js +3 -3
  70. package/dist/generators/ts/BigIntType.d.ts +1 -1
  71. package/dist/generators/ts/BigIntType.js +3 -3
  72. package/dist/generators/ts/BlankNodeType.d.ts +4 -4
  73. package/dist/generators/ts/BlankNodeType.js +12 -12
  74. package/dist/generators/ts/BooleanType.d.ts +3 -3
  75. package/dist/generators/ts/BooleanType.js +11 -6
  76. package/dist/generators/ts/DateTimeType.d.ts +1 -1
  77. package/dist/generators/ts/DateTimeType.js +1 -1
  78. package/dist/generators/ts/DateType.d.ts +1 -1
  79. package/dist/generators/ts/DateType.js +1 -1
  80. package/dist/generators/ts/DefaultValueType.d.ts +3 -7
  81. package/dist/generators/ts/DefaultValueType.js +17 -21
  82. package/dist/generators/ts/FloatType.d.ts +1 -1
  83. package/dist/generators/ts/FloatType.js +1 -1
  84. package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
  85. package/dist/generators/ts/GraphqlSchema.js +4 -4
  86. package/dist/generators/ts/IdentifierType.d.ts +4 -4
  87. package/dist/generators/ts/IdentifierType.js +14 -14
  88. package/dist/generators/ts/IntType.d.ts +1 -1
  89. package/dist/generators/ts/IntType.js +1 -1
  90. package/dist/generators/ts/IriType.d.ts +4 -2
  91. package/dist/generators/ts/IriType.js +27 -22
  92. package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
  93. package/dist/generators/ts/LazyObjectOptionType.js +7 -7
  94. package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
  95. package/dist/generators/ts/LazyObjectSetType.js +6 -6
  96. package/dist/generators/ts/LazyObjectType.d.ts +1 -1
  97. package/dist/generators/ts/LazyObjectType.js +5 -5
  98. package/dist/generators/ts/ListType.d.ts +5 -6
  99. package/dist/generators/ts/ListType.js +24 -25
  100. package/dist/generators/ts/LiteralType.d.ts +3 -2
  101. package/dist/generators/ts/LiteralType.js +14 -7
  102. package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +24 -24
  103. package/dist/generators/ts/ObjectType.js +350 -0
  104. package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
  105. package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +54 -64
  106. package/dist/generators/ts/OptionType.d.ts +2 -6
  107. package/dist/generators/ts/OptionType.js +12 -18
  108. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -8
  109. package/dist/generators/ts/SetType.d.ts +1 -1
  110. package/dist/generators/ts/SetType.js +1 -1
  111. package/dist/generators/ts/Snippets.d.ts +1 -0
  112. package/dist/generators/ts/Snippets.js +7 -0
  113. package/dist/generators/ts/SparqlObjectSetType.js +2 -2
  114. package/dist/generators/ts/StringType.d.ts +3 -3
  115. package/dist/generators/ts/StringType.js +11 -6
  116. package/dist/generators/ts/TermType.d.ts +3 -3
  117. package/dist/generators/ts/TermType.js +13 -13
  118. package/dist/generators/ts/TsGenerator.js +12 -9
  119. package/dist/generators/ts/Type.d.ts +4 -5
  120. package/dist/generators/ts/TypeFactory.d.ts +7 -8
  121. package/dist/generators/ts/TypeFactory.js +79 -80
  122. package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +40 -15
  123. package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +328 -135
  124. package/dist/generators/ts/ZodGenerator.js +7 -9
  125. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +13 -13
  126. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +11 -14
  127. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +3 -2
  128. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +24 -15
  129. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +3 -6
  130. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +20 -12
  131. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
  132. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_createFunctionDeclaration.js → _ObjectType/ObjectType_createFunctionDeclaration.js} +6 -6
  133. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
  134. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +5 -5
  135. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
  136. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -3
  137. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
  138. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +3 -3
  139. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  140. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  141. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  142. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +3 -3
  143. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
  144. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js → _ObjectType/ObjectType_fromJsonFunctionDeclaration.js} +4 -4
  145. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
  146. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js} +7 -31
  147. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
  148. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
  149. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
  150. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
  151. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
  152. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
  153. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
  154. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js → _ObjectType/ObjectType_hashFunctionDeclarations.js} +8 -8
  155. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
  156. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_interfaceDeclaration.js → _ObjectType/ObjectType_interfaceDeclaration.js} +5 -5
  157. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
  158. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js → _ObjectType/ObjectType_isTypeFunctionDeclaration.js} +3 -3
  159. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
  160. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
  161. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
  162. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +2 -2
  163. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
  164. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js → _ObjectType/ObjectType_jsonTypeAliasDeclaration.js} +2 -2
  165. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
  166. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
  167. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
  168. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
  169. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
  170. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +14 -0
  171. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
  172. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
  173. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
  174. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
  175. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  176. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js → _ObjectType/ObjectType_toJsonFunctionDeclaration.js} +4 -4
  177. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  178. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
  179. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
  180. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +6 -6
  181. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
  182. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
  183. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
  184. package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
  185. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +2 -6
  186. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +24 -28
  187. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
  188. package/dist/generators/ts/{_NamedObjectType → _ObjectType}/identifierTypeDeclarations.js +4 -2
  189. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +2 -2
  190. package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +1 -1
  191. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +1 -1
  192. package/dist/generators/ts/_snippets/snippets_IriSchema.js +2 -2
  193. package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +2 -2
  194. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
  195. package/dist/generators/ts/_snippets/snippets_StringSchema.js +2 -2
  196. package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +1 -1
  197. package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
  198. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  199. package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.d.ts +3 -0
  200. package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.js +16 -0
  201. package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +1 -1
  202. package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
  203. package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
  204. package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +1 -1
  205. package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +3 -3
  206. package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +1 -1
  207. package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +1 -1
  208. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +1 -1
  209. package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +1 -1
  210. package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +1 -1
  211. package/dist/generators/ts/_snippets/snippets_validateArray.js +1 -1
  212. package/dist/generators/ts/_snippets/snippets_validateMaybe.js +1 -1
  213. package/dist/generators/ts/tsComment.js +1 -1
  214. package/dist/input/generated.d.ts +1399 -1468
  215. package/dist/input/generated.js +518 -655
  216. package/package.json +4 -4
  217. package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
  218. package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
  219. package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
  220. package/dist/generators/ts/AnonymousUnionType.js +0 -59
  221. package/dist/generators/ts/NamedObjectType.js +0 -341
  222. package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
  223. package/dist/generators/ts/NamedUnionType.d.ts +0 -11
  224. package/dist/generators/ts/NamedUnionType.js +0 -13
  225. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
  226. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
  227. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
  228. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
  229. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  230. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  231. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  232. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  233. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  234. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  235. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  236. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  237. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
  238. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
  239. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
  240. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
  241. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  242. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  243. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  244. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
  245. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
  246. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
  247. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  248. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  249. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
  250. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
  251. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
  252. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
  253. package/dist/generators/ts/removeUndefined.d.ts +0 -2
  254. package/dist/generators/ts/removeUndefined.js +0 -17
  255. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
  256. /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
@@ -0,0 +1,350 @@
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 { NodeKind } from "@shaclmate/shacl-ast";
8
+ import { camelCase } from "change-case";
9
+ import { Maybe } from "purify-ts";
10
+ import { Memoize } from "typescript-memoize";
11
+ import { DiscriminantProperty as _DiscriminantProperty } from "./_ObjectType/DiscriminantProperty.js";
12
+ import { IdentifierProperty as _IdentifierProperty } from "./_ObjectType/IdentifierProperty.js";
13
+ import { identifierTypeDeclarations } from "./_ObjectType/identifierTypeDeclarations.js";
14
+ import { ObjectType_createFunctionDeclaration } from "./_ObjectType/ObjectType_createFunctionDeclaration.js";
15
+ import { ObjectType_equalsFunctionDeclaration } from "./_ObjectType/ObjectType_equalsFunctionDeclaration.js";
16
+ import { ObjectType_filterFunctionDeclaration } from "./_ObjectType/ObjectType_filterFunctionDeclaration.js";
17
+ import { ObjectType_filterTypeDeclaration } from "./_ObjectType/ObjectType_filterTypeDeclaration.js";
18
+ import { ObjectType_focusSparqlConstructTriplesFunctionDeclaration } from "./_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js";
19
+ import { ObjectType_focusSparqlWherePatternsFunctionDeclaration } from "./_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js";
20
+ import { ObjectType_fromJsonFunctionDeclaration } from "./_ObjectType/ObjectType_fromJsonFunctionDeclaration.js";
21
+ import { ObjectType_fromRdfResourceFunctionDeclaration } from "./_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js";
22
+ import { ObjectType_fromRdfResourceValuesFunctionDeclaration } from "./_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js";
23
+ import { ObjectType_fromRdfTypeVariableStatement } from "./_ObjectType/ObjectType_fromRdfTypeVariableStatement.js";
24
+ import { ObjectType_graphqlTypeVariableStatement } from "./_ObjectType/ObjectType_graphqlTypeVariableStatement.js";
25
+ import { ObjectType_hashFunctionDeclarations } from "./_ObjectType/ObjectType_hashFunctionDeclarations.js";
26
+ import { ObjectType_interfaceDeclaration } from "./_ObjectType/ObjectType_interfaceDeclaration.js";
27
+ import { ObjectType_isTypeFunctionDeclaration } from "./_ObjectType/ObjectType_isTypeFunctionDeclaration.js";
28
+ import { ObjectType_jsonParseFunctionDeclaration } from "./_ObjectType/ObjectType_jsonParseFunctionDeclaration.js";
29
+ import { ObjectType_jsonSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js";
30
+ import { ObjectType_jsonTypeAliasDeclaration } from "./_ObjectType/ObjectType_jsonTypeAliasDeclaration.js";
31
+ import { ObjectType_jsonUiSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js";
32
+ import { ObjectType_objectSetMethodNames } from "./_ObjectType/ObjectType_objectSetMethodNames.js";
33
+ import { ObjectType_schemaVariableStatement } from "./_ObjectType/ObjectType_schemaVariableStatement.js";
34
+ import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js";
35
+ import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
36
+ import { ObjectType_toJsonFunctionDeclaration } from "./_ObjectType/ObjectType_toJsonFunctionDeclaration.js";
37
+ import { ObjectType_toRdfResourceFunctionDeclaration } from "./_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js";
38
+ import { ObjectType_toStringFunctionDeclarations } from "./_ObjectType/ObjectType_toStringFunctionDeclarations.js";
39
+ import { ObjectType_valueSparqlConstructTriplesFunctionDeclaration } from "./_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js";
40
+ import { ObjectType_valueSparqlWherePatternsFunctionDeclaration } from "./_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js";
41
+ import { ShaclProperty as _ShaclProperty } from "./_ObjectType/ShaclProperty.js";
42
+ import { AbstractType } from "./AbstractType.js";
43
+ import { code, def, joinCode } from "./ts-poet-wrapper.js";
44
+ export class ObjectType extends AbstractType {
45
+ toRdfTypes;
46
+ conversionFunction = Maybe.empty();
47
+ extern;
48
+ fromRdfType;
49
+ graphqlArgs = Maybe.empty();
50
+ identifierType;
51
+ kind = "Object";
52
+ recursive;
53
+ referencesObjectType = true;
54
+ synthetic;
55
+ typeofs = ["object"];
56
+ validationFunction = Maybe.empty();
57
+ constructor({ extern, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }) {
58
+ super(superParameters);
59
+ this.extern = extern;
60
+ this.fromRdfType = fromRdfType;
61
+ this.identifierType = identifierType;
62
+ // Lazily initialize some members in getters to avoid recursive construction
63
+ this.lazyAncestorObjectTypes = lazyAncestorObjectTypes;
64
+ this.lazyChildObjectTypes = lazyChildObjectTypes;
65
+ this.lazyDescendantObjectTypes = lazyDescendantObjectTypes;
66
+ this.lazyDiscriminantProperty = lazyDiscriminantProperty;
67
+ this.lazyParentObjectTypes = lazyParentObjectTypes;
68
+ this.lazyProperties = lazyProperties;
69
+ this.recursive = recursive;
70
+ this.synthetic = synthetic;
71
+ this.toRdfTypes = toRdfTypes;
72
+ }
73
+ get _discriminantProperty() {
74
+ return this.lazyDiscriminantProperty(this);
75
+ }
76
+ get ancestorObjectTypes() {
77
+ return this.lazyAncestorObjectTypes();
78
+ }
79
+ get childObjectTypes() {
80
+ return this.lazyChildObjectTypes();
81
+ }
82
+ get declaration() {
83
+ const alias = this.alias.extract();
84
+ if (!alias) {
85
+ return Maybe.empty();
86
+ }
87
+ const declarations = [];
88
+ if (!this.extern) {
89
+ const staticModuleDeclarations = [];
90
+ if (this.configuration.features.has("Object.type")) {
91
+ declarations.push(ObjectType_interfaceDeclaration.call(this));
92
+ }
93
+ staticModuleDeclarations.push(...ObjectType_createFunctionDeclaration.call(this).toList(), ...ObjectType_equalsFunctionDeclaration.call(this).toList(), ...ObjectType_hashFunctionDeclarations.call(this));
94
+ const jsonModuleDeclarations = [
95
+ ...ObjectType_jsonParseFunctionDeclaration.call(this).toList(),
96
+ ...ObjectType_jsonSchemaFunctionDeclaration.call(this).toList(),
97
+ ...ObjectType_jsonUiSchemaFunctionDeclaration.call(this).toList(),
98
+ ];
99
+ staticModuleDeclarations.push(...ObjectType_graphqlTypeVariableStatement.call(this).toList(), ...identifierTypeDeclarations.call(this), ...ObjectType_jsonTypeAliasDeclaration.call(this).toList(), ...(jsonModuleDeclarations.length > 0
100
+ ? [
101
+ code `export namespace Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`,
102
+ ]
103
+ : []), ...ObjectType_filterFunctionDeclaration.call(this).toList(), ...ObjectType_filterTypeDeclaration.call(this).toList(), ...ObjectType_focusSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...ObjectType_focusSparqlWherePatternsFunctionDeclaration.call(this).toList(), ...ObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...ObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...ObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...ObjectType_fromRdfTypeVariableStatement.call(this).toList(), ...ObjectType_isTypeFunctionDeclaration.call(this).toList(), ...ObjectType_schemaVariableStatement.call(this).toList(), ...ObjectType_sparqlConstructQueryFunctionDeclaration.call({
104
+ alias,
105
+ configuration: this.configuration,
106
+ filterType: this.filterType,
107
+ reusables: this.reusables,
108
+ }).toList(), ...ObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
109
+ alias,
110
+ configuration: this.configuration,
111
+ filterType: this.filterType,
112
+ reusables: this.reusables,
113
+ }).toList(), ...ObjectType_toJsonFunctionDeclaration.call(this).toList(), ...ObjectType_toRdfResourceFunctionDeclaration.call(this).toList(), ...ObjectType_toStringFunctionDeclarations.call(this), ...ObjectType_valueSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...ObjectType_valueSparqlWherePatternsFunctionDeclaration.call(this).toList());
114
+ if (staticModuleDeclarations.length > 0) {
115
+ declarations.push(code `\
116
+ export namespace ${def(alias)} {
117
+ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
118
+ }`);
119
+ }
120
+ }
121
+ if (declarations.length === 0) {
122
+ return Maybe.empty();
123
+ }
124
+ return Maybe.of(joinCode(declarations, { on: "\n\n" }));
125
+ }
126
+ get descendantFromRdfTypeVariables() {
127
+ return this.descendantObjectTypes.flatMap((descendantObjectType) => descendantObjectType.fromRdfTypeVariable.toList());
128
+ }
129
+ get descendantFromRdfTypes() {
130
+ return this.descendantObjectTypes.flatMap((descendantObjectType) => descendantObjectType.fromRdfType.toList());
131
+ }
132
+ get descendantObjectTypes() {
133
+ return this.lazyDescendantObjectTypes();
134
+ }
135
+ get discriminantProperty() {
136
+ return Maybe.of({
137
+ jsonName: this._discriminantProperty.jsonName,
138
+ name: this._discriminantProperty.name,
139
+ ownValues: this._discriminantProperty.type.ownValues,
140
+ descendantValues: this._discriminantProperty.type.descendantValues,
141
+ });
142
+ }
143
+ get discriminantValue() {
144
+ return this.alias.unsafeCoerce();
145
+ }
146
+ get equalsFunction() {
147
+ return code `${this.alias.unsafeCoerce()}.equals`;
148
+ }
149
+ get expression() {
150
+ return code `${this.alias.unsafeCoerce()}`;
151
+ }
152
+ get filterFunction() {
153
+ return code `${this.alias.unsafeCoerce()}.filter`;
154
+ }
155
+ get filterType() {
156
+ return code `${this.alias.unsafeCoerce()}.Filter`;
157
+ }
158
+ get fromRdfTypeVariable() {
159
+ return this.fromRdfType.map(() => code `${this.alias.unsafeCoerce()}.fromRdfType`);
160
+ }
161
+ get graphqlType() {
162
+ return new AbstractType.GraphqlType(code `${this.alias.unsafeCoerce()}.GraphQL`, this.reusables);
163
+ }
164
+ get hashFunction() {
165
+ return code `${this.alias.unsafeCoerce()}.hash`;
166
+ }
167
+ get identifierTypeAlias() {
168
+ return code `${this.alias.unsafeCoerce()}.Identifier`;
169
+ }
170
+ get mutable() {
171
+ return this.properties.some((property) => property.mutable);
172
+ }
173
+ get objectSetMethodNames() {
174
+ return ObjectType_objectSetMethodNames.call({
175
+ alias: this.alias.unsafeCoerce(),
176
+ configuration: this.configuration,
177
+ });
178
+ }
179
+ get parentObjectTypes() {
180
+ return this.lazyParentObjectTypes();
181
+ }
182
+ get properties() {
183
+ const properties = this.lazyProperties(this);
184
+ const propertyNames = new Set();
185
+ for (const property of properties) {
186
+ if (propertyNames.has(property.name)) {
187
+ throw new Error(`duplicate property '${property.name}'`);
188
+ }
189
+ }
190
+ return properties;
191
+ }
192
+ get schema() {
193
+ return code `${this.alias.unsafeCoerce()}.schema`;
194
+ }
195
+ get schemaType() {
196
+ return code `typeof ${this.schema}`;
197
+ }
198
+ get toRdfResourceValueTypes() {
199
+ return new Set([...this.identifierType.nodeKinds].map(NodeKind.toTermType));
200
+ }
201
+ get toRdfjsResourceType() {
202
+ if (this.parentObjectTypes.length > 0) {
203
+ return this.parentObjectTypes[0].toRdfjsResourceType;
204
+ }
205
+ return code `${this.reusables.imports.Resource}${this.identifierType.kind === "Iri" ? code `<${this.reusables.imports.NamedNode}>` : ""}`;
206
+ }
207
+ get valueSparqlConstructTriplesFunction() {
208
+ return code `${this.alias.unsafeCoerce()}.valueSparqlConstructTriples`;
209
+ }
210
+ get valueSparqlWherePatternsFunction() {
211
+ return code `${this.alias.unsafeCoerce()}.valueSparqlWherePatterns`;
212
+ }
213
+ get thisVariable() {
214
+ return code `_${camelCase(this.alias.unsafeCoerce())}`;
215
+ }
216
+ fromJsonExpression({ variables, }) {
217
+ // Assumes the JSON object has been recursively validated already.
218
+ return code `${this.alias.unsafeCoerce()}.fromJson(${variables.value})`;
219
+ }
220
+ fromRdfResourceValuesExpression({ variables, }) {
221
+ const { resourceValues: resourceValuesVariable, ...fromRdfResourceValuesOptionsTemp } = variables;
222
+ const fromRdfResourceValuesOptions = fromRdfResourceValuesOptionsTemp;
223
+ if (!this.configuration.features.has("ObjectSet")) {
224
+ delete fromRdfResourceValuesOptions["objectSet"];
225
+ }
226
+ return code `${this.alias.unsafeCoerce()}.fromRdfResourceValues(${resourceValuesVariable}, ${fromRdfResourceValuesOptions})`;
227
+ }
228
+ graphqlResolveExpression({ variables, }) {
229
+ return variables.value;
230
+ }
231
+ jsonSchema({ context, }) {
232
+ let expression = code `${this.alias.unsafeCoerce()}.Json.schema()`;
233
+ if (context === "property" &&
234
+ this.properties.some((property) => property.recursive)) {
235
+ expression = code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.alias.unsafeCoerce()}.Json> => ${expression})`;
236
+ }
237
+ return expression;
238
+ }
239
+ jsonType() {
240
+ return new AbstractType.JsonType(code `${this.alias.unsafeCoerce()}.Json`);
241
+ }
242
+ jsonUiSchemaElement({ variables, }) {
243
+ return Maybe.of(code `${this.alias.unsafeCoerce()}.Json.uiSchema({ scopePrefix: ${variables.scopePrefix} })`);
244
+ }
245
+ toJsonExpression({ variables, }) {
246
+ return code `${this.alias.unsafeCoerce()}.toJson(${variables.value})`;
247
+ }
248
+ toRdfResourceValuesExpression({ variables, }) {
249
+ return code `[${this.alias.unsafeCoerce()}.toRdfResource(${variables.value}, { graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
250
+ }
251
+ toStringExpression({ variables, }) {
252
+ return code `${this.alias.unsafeCoerce()}.${this.configuration.syntheticNamePrefix}toString(${variables.value})`;
253
+ }
254
+ lazyAncestorObjectTypes;
255
+ lazyChildObjectTypes;
256
+ lazyDescendantObjectTypes;
257
+ lazyDiscriminantProperty;
258
+ lazyParentObjectTypes;
259
+ lazyProperties;
260
+ }
261
+ __decorate([
262
+ Memoize()
263
+ ], ObjectType.prototype, "_discriminantProperty", null);
264
+ __decorate([
265
+ Memoize()
266
+ ], ObjectType.prototype, "ancestorObjectTypes", null);
267
+ __decorate([
268
+ Memoize()
269
+ ], ObjectType.prototype, "childObjectTypes", null);
270
+ __decorate([
271
+ Memoize()
272
+ ], ObjectType.prototype, "descendantFromRdfTypeVariables", null);
273
+ __decorate([
274
+ Memoize()
275
+ ], ObjectType.prototype, "descendantFromRdfTypes", null);
276
+ __decorate([
277
+ Memoize()
278
+ ], ObjectType.prototype, "descendantObjectTypes", null);
279
+ __decorate([
280
+ Memoize()
281
+ ], ObjectType.prototype, "discriminantProperty", null);
282
+ __decorate([
283
+ Memoize()
284
+ ], ObjectType.prototype, "discriminantValue", null);
285
+ __decorate([
286
+ Memoize()
287
+ ], ObjectType.prototype, "equalsFunction", null);
288
+ __decorate([
289
+ Memoize()
290
+ ], ObjectType.prototype, "expression", null);
291
+ __decorate([
292
+ Memoize()
293
+ ], ObjectType.prototype, "filterFunction", null);
294
+ __decorate([
295
+ Memoize()
296
+ ], ObjectType.prototype, "filterType", null);
297
+ __decorate([
298
+ Memoize()
299
+ ], ObjectType.prototype, "fromRdfTypeVariable", null);
300
+ __decorate([
301
+ Memoize()
302
+ ], ObjectType.prototype, "graphqlType", null);
303
+ __decorate([
304
+ Memoize()
305
+ ], ObjectType.prototype, "hashFunction", null);
306
+ __decorate([
307
+ Memoize()
308
+ ], ObjectType.prototype, "identifierTypeAlias", null);
309
+ __decorate([
310
+ Memoize()
311
+ ], ObjectType.prototype, "mutable", null);
312
+ __decorate([
313
+ Memoize()
314
+ ], ObjectType.prototype, "objectSetMethodNames", null);
315
+ __decorate([
316
+ Memoize()
317
+ ], ObjectType.prototype, "parentObjectTypes", null);
318
+ __decorate([
319
+ Memoize()
320
+ ], ObjectType.prototype, "properties", null);
321
+ __decorate([
322
+ Memoize()
323
+ ], ObjectType.prototype, "schema", null);
324
+ __decorate([
325
+ Memoize()
326
+ ], ObjectType.prototype, "schemaType", null);
327
+ __decorate([
328
+ Memoize()
329
+ ], ObjectType.prototype, "toRdfResourceValueTypes", null);
330
+ __decorate([
331
+ Memoize()
332
+ ], ObjectType.prototype, "toRdfjsResourceType", null);
333
+ __decorate([
334
+ Memoize()
335
+ ], ObjectType.prototype, "valueSparqlConstructTriplesFunction", null);
336
+ __decorate([
337
+ Memoize()
338
+ ], ObjectType.prototype, "valueSparqlWherePatternsFunction", null);
339
+ __decorate([
340
+ Memoize()
341
+ ], ObjectType.prototype, "thisVariable", null);
342
+ __decorate([
343
+ Memoize()
344
+ ], ObjectType.prototype, "jsonType", null);
345
+ (function (ObjectType) {
346
+ ObjectType.IdentifierProperty = _IdentifierProperty;
347
+ ObjectType.ShaclProperty = _ShaclProperty;
348
+ ObjectType.DiscriminantProperty = _DiscriminantProperty;
349
+ })(ObjectType || (ObjectType = {}));
350
+ //# sourceMappingURL=ObjectType.js.map
@@ -0,0 +1,20 @@
1
+ import type { ObjectType } from "./ObjectType.js";
2
+ import { type Code } from "./ts-poet-wrapper.js";
3
+ import { UnionType } from "./UnionType.js";
4
+ export declare class ObjectUnionType extends UnionType<ObjectType> {
5
+ readonly kind = "ObjectUnion";
6
+ get identifierTypeAlias(): Code;
7
+ get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
8
+ get schema(): Code;
9
+ get schemaType(): Code;
10
+ protected get staticModuleDeclarations(): Record<string, Code>;
11
+ private get focusSparqlConstructTriplesFunctionDeclaration();
12
+ private get focusSparqlWherePatternsFunctionDeclaration();
13
+ private get fromRdfResourceFunctionDeclaration();
14
+ private get graphqlTypeVariableStatement();
15
+ private get identifierTypeDeclarations();
16
+ private get isTypeFunctionDeclaration();
17
+ private get schemaVariableStatement();
18
+ private get toRdfResourceFunctionDeclaration();
19
+ }
20
+ //# sourceMappingURL=ObjectUnionType.d.ts.map
@@ -6,44 +6,38 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { PropertyPath } from "@rdfx/resource";
8
8
  import { pascalCase } from "change-case";
9
- import { Maybe } from "purify-ts";
10
9
  import { Memoize } from "typescript-memoize";
11
- import { NamedObjectType_objectSetMethodNames } from "./_NamedObjectType/NamedObjectType_objectSetMethodNames.js";
12
- import { NamedObjectType_sparqlConstructQueryFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js";
13
- import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
14
- import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
15
- import { AbstractType } from "./AbstractType.js";
10
+ import { ObjectType_objectSetMethodNames } from "./_ObjectType/ObjectType_objectSetMethodNames.js";
11
+ import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js";
12
+ import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
16
13
  import { singleEntryRecord } from "./singleEntryRecord.js";
17
14
  import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
18
- export class NamedObjectUnionType extends AbstractNamedUnionType {
19
- #identifierType;
20
- graphqlArgs = Maybe.empty();
21
- kind = "NamedObjectUnionType";
22
- synthetic;
23
- constructor({ identifierType, synthetic, ...superParameters }) {
24
- super({ ...superParameters, identifierType: Maybe.of(identifierType) });
25
- this.#identifierType = identifierType;
26
- this.synthetic = synthetic;
27
- }
28
- get graphqlType() {
29
- return new AbstractType.GraphqlType(code `${this._name}.GraphQL`, this.reusables);
30
- }
15
+ import { UnionType } from "./UnionType.js";
16
+ export class ObjectUnionType extends UnionType {
17
+ kind = "ObjectUnion";
31
18
  get identifierTypeAlias() {
32
- return code `${this.name}.Identifier`;
19
+ return this.alias.map((alias) => code `${alias}.Identifier`).unsafeCoerce();
33
20
  }
34
21
  get objectSetMethodNames() {
35
- return NamedObjectType_objectSetMethodNames.call({
22
+ return this.alias
23
+ .map((alias) => ObjectType_objectSetMethodNames.call({
24
+ alias,
36
25
  configuration: this.configuration,
37
- name: this.name,
38
- });
26
+ }))
27
+ .unsafeCoerce();
39
28
  }
40
29
  get schema() {
41
- return code `${this.name}.schema`;
30
+ return this.alias
31
+ .map((alias) => code `${alias}.schema`)
32
+ .orDefault(super.schema);
42
33
  }
43
34
  get schemaType() {
44
- return code `typeof ${this.schema}`;
35
+ return this.alias
36
+ .map(() => code `typeof ${this.schema}`)
37
+ .orDefault(super.schemaType);
45
38
  }
46
39
  get staticModuleDeclarations() {
40
+ const alias = this.alias.unsafeCoerce();
47
41
  return {
48
42
  ...super.staticModuleDeclarations,
49
43
  ...this.identifierTypeDeclarations,
@@ -53,18 +47,18 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
53
47
  ...this.graphqlTypeVariableStatement,
54
48
  ...this.isTypeFunctionDeclaration,
55
49
  ...this.schemaVariableStatement,
56
- ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
50
+ ...ObjectType_sparqlConstructQueryFunctionDeclaration.call({
51
+ alias,
57
52
  configuration: this.configuration,
58
53
  filterType: this.filterType,
59
- name: this.name,
60
54
  reusables: this.reusables,
61
55
  })
62
56
  .map((code_) => singleEntryRecord(`sparqlConstructQuery`, code_))
63
57
  .orDefault({}),
64
- ...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
58
+ ...ObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
59
+ alias,
65
60
  configuration: this.configuration,
66
61
  filterType: this.filterType,
67
- name: this.name,
68
62
  reusables: this.reusables,
69
63
  })
70
64
  .map((code_) => singleEntryRecord(`sparqlConstructQueryString`, code_))
@@ -78,7 +72,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
78
72
  }
79
73
  return singleEntryRecord(`focusSparqlConstructTriples`, code `\
80
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[] {
81
- return [${joinCode(this.members.map((member) => code `...${member.type.name}.focusSparqlConstructTriples({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`), { on: ", " })}];
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: ", " })}];
82
76
  }`);
83
77
  }
84
78
  get focusSparqlWherePatternsFunctionDeclaration() {
@@ -91,18 +85,18 @@ ${joinCode([
91
85
  code `let patterns: ${this.reusables.snippets.SparqlPattern}[] = [];`,
92
86
  code `\
93
87
  if (focusIdentifier.termType === "Variable") {
94
- patterns = patterns.concat(${this.#identifierType.valueSparqlWherePatternsFunction}({
88
+ patterns = patterns.concat(${this.identifierType.unsafeCoerce().valueSparqlWherePatternsFunction}({
95
89
  filter: filter?.${this.configuration.syntheticNamePrefix}identifier,
96
90
  ignoreRdfType: false,
97
91
  preferredLanguages,
98
92
  propertyPatterns: [],
99
- schema: ${this.#identifierType.schema},
93
+ schema: ${this.identifierType.unsafeCoerce().schema},
100
94
  valueVariable: focusIdentifier,
101
95
  variablePrefix,
102
96
  }));
103
97
  }`,
104
98
  code `patterns.push({ patterns: [${joinCode(this.members.map((member) => code `${{
105
- patterns: code `${member.type.name}.focusSparqlWherePatterns({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`,
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()`,
106
100
  type: literalOf("group"),
107
101
  }}`), { on: ", " })}], type: "union" });`,
108
102
  code `return patterns;`,
@@ -113,10 +107,11 @@ if (focusIdentifier.termType === "Variable") {
113
107
  if (!this.configuration.features.has("Object.fromRdf")) {
114
108
  return {};
115
109
  }
110
+ const alias = this.alias.unsafeCoerce();
116
111
  return singleEntryRecord(`fromRdfResource`, code `\
117
- export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<${this.name}> = (resource, options) =>
112
+ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<${alias}> = (resource, options) =>
118
113
  ${this.members.reduce((expression, member) => {
119
- const memberTypeExpression = code `(${member.type.name}.fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${this.reusables.imports.Either}<Error, ${this.name}>)`;
114
+ const memberTypeExpression = code `(${member.type.alias.unsafeCoerce()}.fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${this.reusables.imports.Either}<Error, ${alias}>)`;
120
115
  return expression !== null
121
116
  ? code `${expression}.altLazy(() => ${memberTypeExpression})`
122
117
  : memberTypeExpression;
@@ -129,11 +124,12 @@ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}
129
124
  if (this.synthetic) {
130
125
  return {};
131
126
  }
127
+ const alias = this.alias.unsafeCoerce();
132
128
  return singleEntryRecord(`GraphQL`, code `\
133
129
  export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
134
130
  description: this.comment.map(JSON.stringify).extract(),
135
- name: this.name,
136
- resolveType: code `(value: ${this.name}) => value.${this.configuration.syntheticNamePrefix}type`,
131
+ name: alias,
132
+ resolveType: code `(value: ${alias}) => value.${this.configuration.syntheticNamePrefix}type`,
137
133
  types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
138
134
  }});`);
139
135
  }
@@ -142,22 +138,23 @@ export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
142
138
  return {};
143
139
  }
144
140
  return singleEntryRecord(`Identifier`, code `\
145
- export type Identifier = ${this.#identifierType.name};
141
+ export type Identifier = ${this.identifierType.unsafeCoerce().expression};
146
142
  export namespace Identifier {
147
- export const parse = ${this.#identifierType.parseFunction};
148
- export const stringify = ${this.#identifierType.stringifyFunction};
143
+ export const parse = ${this.identifierType.unsafeCoerce().parseFunction};
144
+ export const stringify = ${this.identifierType.unsafeCoerce().stringifyFunction};
149
145
  }`);
150
146
  }
151
147
  get isTypeFunctionDeclaration() {
152
148
  if (!this.configuration.features.has("Object.type")) {
153
149
  return {};
154
150
  }
155
- if (this._name === `${this.configuration.syntheticNamePrefix}Object`) {
151
+ const alias = this.alias.unsafeCoerce();
152
+ if (alias === `${this.configuration.syntheticNamePrefix}Object`) {
156
153
  return {};
157
154
  }
158
- return singleEntryRecord(`is${this._name}`, code `\
159
- export function is${this._name}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${this.name} {
160
- return ${joinCode(this.members.map((member) => code `${member.type.name}.is${member.type.name}(object)`), { on: " || " })};
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: " || " })};
161
158
  }`);
162
159
  }
163
160
  get schemaVariableStatement() {
@@ -167,7 +164,7 @@ export namespace Identifier {
167
164
  const commonPropertiesByName = {};
168
165
  this.members.forEach((member, memberI) => {
169
166
  for (const memberTypeProperty of member.type.properties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.properties))) {
170
- if (memberTypeProperty.kind !== "ShaclProperty") {
167
+ if (memberTypeProperty.kind !== "Shacl") {
171
168
  continue;
172
169
  }
173
170
  let commonProperty = commonPropertiesByName[memberTypeProperty.name];
@@ -191,43 +188,36 @@ export namespace Identifier {
191
188
  if (!memberTypesWithProperty.every((value) => value)) {
192
189
  continue;
193
190
  }
194
- propertiesObject.push(code `${property.name}: ${property.schema}`);
191
+ property.schema.ifJust((propertySchema) => {
192
+ propertiesObject.push(code `${property.name}: ${propertySchema}`);
193
+ });
195
194
  }
196
195
  return singleEntryRecord(`schema`, code `\
197
- export const schema =
198
- ${{
199
- ...super.schemaObject,
200
- properties: code `{ ${joinCode(propertiesObject, { on: ", " })} }`,
201
- }} as const;`);
196
+ export const schema = { ${joinCode(super.schemaInitializers.concat(code `properties: { ${joinCode(propertiesObject, { on: ", " })} }`), { on: ", " })} } as const;`);
202
197
  }
203
198
  get toRdfResourceFunctionDeclaration() {
204
199
  if (!this.configuration.features.has("Object.toRdf")) {
205
200
  return {};
206
201
  }
202
+ const alias = this.alias.unsafeCoerce();
207
203
  return singleEntryRecord(`toRdfResource`, code `\
208
- export const toRdfResource: ${this.reusables.snippets.ToRdfResourceFunction}<${this.name}> = (object, options) => {
204
+ export const toRdfResource: ${this.reusables.snippets.ToRdfResourceFunction}<${alias}> = (object, options) => {
209
205
  ${joinCode(this.members
210
- .map((member) => code `if (${member.type.name}.is${member.type.name}(object)) { return ${member.type.name}.toRdfResource(object, options); }`)
206
+ .map((member) => code `if (${member.type.alias.unsafeCoerce()}.is${member.type.alias.unsafeCoerce()}(object)) { return ${member.type.alias.unsafeCoerce()}.toRdfResource(object, options); }`)
211
207
  .concat(code `throw new Error("unrecognized type");`))}
212
208
  };`);
213
209
  }
214
- graphqlResolveExpression({ variables, }) {
215
- return variables.value;
216
- }
217
210
  }
218
211
  __decorate([
219
212
  Memoize()
220
- ], NamedObjectUnionType.prototype, "graphqlType", null);
221
- __decorate([
222
- Memoize()
223
- ], NamedObjectUnionType.prototype, "identifierTypeAlias", null);
213
+ ], ObjectUnionType.prototype, "identifierTypeAlias", null);
224
214
  __decorate([
225
215
  Memoize()
226
- ], NamedObjectUnionType.prototype, "objectSetMethodNames", null);
216
+ ], ObjectUnionType.prototype, "objectSetMethodNames", null);
227
217
  __decorate([
228
218
  Memoize()
229
- ], NamedObjectUnionType.prototype, "schema", null);
219
+ ], ObjectUnionType.prototype, "schema", null);
230
220
  __decorate([
231
221
  Memoize()
232
- ], NamedObjectUnionType.prototype, "schemaType", null);
233
- //# sourceMappingURL=NamedObjectUnionType.js.map
222
+ ], ObjectUnionType.prototype, "schemaType", null);
223
+ //# sourceMappingURL=ObjectUnionType.js.map
@@ -4,24 +4,20 @@ 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 kind = "OptionType";
7
+ readonly kind = "Option";
8
8
  readonly typeofs: "object"[];
9
9
  get conversionFunction(): Maybe<AbstractContainerType.ConversionFunction>;
10
10
  get equalsFunction(): Code;
11
+ get expression(): Code;
11
12
  get filterFunction(): Code;
12
13
  get filterType(): Code;
13
14
  get graphqlType(): AbstractContainerType.GraphqlType;
14
15
  get hashFunction(): Code;
15
16
  get mutable(): boolean;
16
- get name(): Code;
17
17
  get schemaType(): Code;
18
18
  get validationFunction(): Maybe<Code>;
19
19
  get valueSparqlConstructTriplesFunction(): Code;
20
20
  get valueSparqlWherePatternsFunction(): Code;
21
- protected get schemaObject(): {
22
- kind: Code;
23
- item: Code;
24
- };
25
21
  fromJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
26
22
  fromRdfResourceValuesExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
27
23
  graphqlResolveExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;