@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
@@ -55,7 +55,7 @@ export class UnionType extends AbstractType {
55
55
  switch (member.type.kind) {
56
56
  case "Object":
57
57
  case "ObjectUnion":
58
- return code `${member.type.alias.unsafeCoerce()}.is${member.type.alias.unsafeCoerce()}(${instance})`;
58
+ return code `${member.type.name.unsafeCoerce()}.is${member.type.name.unsafeCoerce()}(${instance})`;
59
59
  }
60
60
  }
61
61
  const discriminantName = json
@@ -131,18 +131,18 @@ export class UnionType extends AbstractType {
131
131
  });
132
132
  }
133
133
  get declaration() {
134
- const alias = this.alias.extract();
135
- if (!alias) {
134
+ const name = this.name.extract();
135
+ if (!name) {
136
136
  return Maybe.empty();
137
137
  }
138
138
  const declarations = [];
139
139
  if (this.configuration.features.has("Object.type")) {
140
- declarations.push(code `export type ${def(alias)} = ${this.inlineExpression};`);
140
+ declarations.push(code `export type ${def(name)} = ${this.inlineExpression};`);
141
141
  }
142
142
  const staticModuleDeclarations = Object.entries(this.staticModuleDeclarations);
143
143
  if (staticModuleDeclarations.length > 0) {
144
144
  declarations.push(code `\
145
- export namespace ${def(alias)} {
145
+ export namespace ${def(name)} {
146
146
  ${joinCode(staticModuleDeclarations
147
147
  .sort((left, right) => left[0].localeCompare(right[0]))
148
148
  .map((_) => _[1]), { on: "\n\n" })}
@@ -154,7 +154,6 @@ ${joinCode(staticModuleDeclarations
154
154
  switch (this.discriminant.kind) {
155
155
  case "Extrinsic":
156
156
  return Maybe.of({
157
- descendantValues: [],
158
157
  jsonName: this.discriminant.jsonName,
159
158
  name: this.discriminant.name,
160
159
  values: this.discriminant.memberValues,
@@ -178,32 +177,53 @@ ${joinCode(staticModuleDeclarations
178
177
  }
179
178
  }
180
179
  get equalsFunction() {
181
- return this.alias
182
- .map((alias) => code `${alias}.equals`)
183
- .orDefault(this.inlineEqualsFunction);
180
+ return this.name
181
+ .map((name) => code `${name}.equals`)
182
+ .orDefault(this.equalsFunctionExpression);
183
+ }
184
+ get expression() {
185
+ return this.name
186
+ .map((name) => code `${name}`)
187
+ .orDefault(this.inlineExpression);
184
188
  }
185
189
  get filterFunction() {
186
- return this.alias
187
- .map((alias) => code `${alias}.filter`)
188
- .orDefault(this.inlineFilterFunction);
190
+ return this.name
191
+ .map((name) => code `${name}.filter`)
192
+ .orDefault(this.filterFunctionExpression);
189
193
  }
190
194
  get filterType() {
191
- return this.alias
192
- .map((alias) => code `${alias}.Filter`)
193
- .orDefault(this.inlineFilterType);
195
+ return this.name
196
+ .map((name) => code `${name}.Filter`)
197
+ .orDefault(this.filterTypeLiteral);
198
+ }
199
+ get fromRdfResourceValuesFunction() {
200
+ return this.name
201
+ .map((name) => code `${name}.fromRdfResourceValues`)
202
+ .orDefault(this.fromRdfResourceValuesFunctionExpression);
194
203
  }
195
204
  get graphqlType() {
196
- const alias = this.alias.extract();
197
- if (!alias ||
205
+ const name = this.name.extract();
206
+ if (!name ||
198
207
  !this.members.every((member) => member.type.kind === "Object")) {
199
208
  throw new Error("not implemented");
200
209
  }
201
- return new AbstractType.GraphqlType(code `${alias}.GraphQL`, this.reusables);
210
+ return new AbstractType.GraphqlType(code `${name}.GraphQL`, this.reusables);
202
211
  }
203
212
  get hashFunction() {
204
- return this.alias
205
- .map((alias) => code `${alias}.hash`)
206
- .orDefault(this.inlineHashFunction);
213
+ return this.name
214
+ .map((name) => code `${name}.hash`)
215
+ .orDefault(this.hashFunctionExpression);
216
+ }
217
+ get jsTypes() {
218
+ const jsTypes = [];
219
+ for (const member of this.members) {
220
+ for (const memberJsType of member.type.jsTypes) {
221
+ if (!jsTypes.some((jsType) => AbstractType.JsType.equals(jsType, memberJsType))) {
222
+ jsTypes.push(memberJsType);
223
+ }
224
+ }
225
+ }
226
+ return jsTypes;
207
227
  }
208
228
  get jsonSchemaFunctionDeclaration() {
209
229
  const meta = {
@@ -215,10 +235,10 @@ ${joinCode(staticModuleDeclarations
215
235
  this.label.ifJust((label) => {
216
236
  meta["title"] = label;
217
237
  });
218
- return code `export const schema = () => ${this.inlineJsonSchema}.meta(${meta});`;
238
+ return code `export const schema = () => ${this.jsonSchemaExpression}.meta(${meta});`;
219
239
  }
220
240
  get jsonTypeAliasDeclaration() {
221
- return code `export type Json = ${this.inlineJsonType.expression}`;
241
+ return code `export type Json = ${this.jsonTypeLiteral.expression}`;
222
242
  }
223
243
  get members() {
224
244
  return this.lazyMembers();
@@ -226,22 +246,19 @@ ${joinCode(staticModuleDeclarations
226
246
  get mutable() {
227
247
  return this.members.some((member) => member.type.mutable);
228
248
  }
229
- get expression() {
230
- return this.alias
231
- .map((alias) => code `${alias}`)
232
- .orDefault(this.inlineExpression);
249
+ get referencesNamedType() {
250
+ return (this.name.isJust() ||
251
+ this.members.some((member) => member.type.referencesNamedType));
233
252
  }
234
- get referencesObjectType() {
235
- return this.members.some((member) => member.type.referencesObjectType);
253
+ get schema() {
254
+ return this.name
255
+ .map((name) => code `${name}.schema`)
256
+ .orDefault(this.schemaExpression);
236
257
  }
237
258
  get schemaType() {
238
- return code `${{
239
- kind: this.kind,
240
- members: code `{ ${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}: ${{
241
- discriminantValues: code `readonly (number | string)[]`,
242
- type: type.schemaType,
243
- }}`), { on: ";" })} }`,
244
- }}`;
259
+ return this.name
260
+ .map(() => code `typeof ${this.schema}`)
261
+ .orDefault(this.schemaTypeExpression);
245
262
  }
246
263
  get toRdfResourceValueTypes() {
247
264
  const set = new Set();
@@ -252,28 +269,98 @@ ${joinCode(staticModuleDeclarations
252
269
  }
253
270
  return set;
254
271
  }
255
- get jsTypes() {
256
- const jsTypes = [];
257
- for (const member of this.members) {
258
- for (const memberJsType of member.type.jsTypes) {
259
- if (!jsTypes.some((jsType) => AbstractType.JsType.equals(jsType, memberJsType))) {
260
- jsTypes.push(memberJsType);
261
- }
262
- }
263
- }
264
- return jsTypes;
265
- }
266
272
  get valueSparqlConstructTriplesFunction() {
267
- return this.alias
268
- .map((alias) => code `${alias}.valueSparqlConstructTriples`)
269
- .orDefault(this.inlineValueSparqlConstructTriplesFunction);
273
+ return this.name
274
+ .map((name) => code `${name}.valueSparqlConstructTriples`)
275
+ .orDefault(this.valueSparqlConstructTriplesFunctionExpression);
270
276
  }
271
277
  get valueSparqlWherePatternsFunction() {
272
- return this.alias
273
- .map((alias) => code `${alias}.valueSparqlWherePatterns`)
274
- .orDefault(this.inlineValueSparqlWherePatternsFunction);
278
+ return this.name
279
+ .map((name) => code `${name}.valueSparqlWherePatterns`)
280
+ .orDefault(this.valueSparqlWherePatternsFunctionExpression);
281
+ }
282
+ get schemaInitializers() {
283
+ return super.schemaInitializers.concat(code `members: { ${joinCode(this.members.map(({ discriminantValues, type, primaryDiscriminantValue }) => code `${literalOf(primaryDiscriminantValue)}: ${{
284
+ discriminantValues: discriminantValues,
285
+ type: type.schema,
286
+ }}`), { on: "," })} }`);
287
+ }
288
+ get schemaTypeExpression() {
289
+ return code `${{
290
+ kind: this.kind,
291
+ members: code `{ ${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}: ${{
292
+ discriminantValues: code `readonly (number | string)[]`,
293
+ type: type.schemaType,
294
+ }}`), { on: ";" })} }`,
295
+ }}`;
296
+ }
297
+ get staticModuleDeclarations() {
298
+ const name = this.name.unsafeCoerce();
299
+ const staticModuleDeclarations = {};
300
+ if (this.configuration.features.has("Object.equals")) {
301
+ staticModuleDeclarations[`equals`] =
302
+ code `export const equals = ${this.equalsFunctionExpression};`;
303
+ }
304
+ if (this.configuration.features.has("Object.filter")) {
305
+ staticModuleDeclarations[`Filter`] =
306
+ code `export type Filter = ${this.filterTypeLiteral};`;
307
+ staticModuleDeclarations[`filter`] =
308
+ code `export const filter = ${this.filterFunctionExpression};`;
309
+ }
310
+ if (this.configuration.features.has("Object.hash")) {
311
+ staticModuleDeclarations[`hash`] =
312
+ code `export const hash = ${this.hashFunctionExpression};`;
313
+ }
314
+ if (this.configuration.features.has("Object.JSON.type")) {
315
+ staticModuleDeclarations[`Json.type`] =
316
+ code `${this.jsonTypeAliasDeclaration}`;
317
+ }
318
+ if (this.configuration.features.has("Object.JSON.schema")) {
319
+ staticModuleDeclarations[`Json.namespace`] = code `\
320
+ export namespace Json {
321
+ ${this.jsonSchemaFunctionDeclaration}
322
+
323
+ export function parse(json: unknown): ${this.reusables.imports.Either}<Error, Json> {
324
+ const jsonSafeParseResult = schema().safeParse(json);
325
+ if (!jsonSafeParseResult.success) { return ${this.reusables.imports.Left}(jsonSafeParseResult.error); }
326
+ return ${this.reusables.imports.Right}(jsonSafeParseResult.data);
327
+ }
328
+ }`;
329
+ }
330
+ if (this.configuration.features.has("Object.fromJson")) {
331
+ staticModuleDeclarations[`fromJson`] =
332
+ code `export const fromJson = ${this.fromJsonFunctionExpression};`;
333
+ }
334
+ if (this.configuration.features.has("Object.fromRdf")) {
335
+ staticModuleDeclarations[`fromRdfResourceValues`] =
336
+ code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${name}, ${this.schemaType}> = ${this.fromRdfResourceValuesFunctionExpression};`;
337
+ }
338
+ if (this.configuration.features.has("Object.schema")) {
339
+ staticModuleDeclarations["schema"] =
340
+ code `export const schema = ${this.schemaExpression}`;
341
+ }
342
+ if (this.configuration.features.has("Object.toJson")) {
343
+ staticModuleDeclarations[`toJson`] =
344
+ code `export const toJson = ${this.toJsonFunctionExpression};`;
345
+ }
346
+ if (this.configuration.features.has("Object.toRdf")) {
347
+ staticModuleDeclarations[`toRdfResourceValues`] =
348
+ code `export const toRdfResourceValues = ${this.toRdfResourceValuesFunctionExpression};`;
349
+ }
350
+ if (this.configuration.features.has("Object.SPARQL")) {
351
+ staticModuleDeclarations[`valueSparqlConstructTriples`] =
352
+ code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.valueSparqlConstructTriplesFunctionExpression};`;
353
+ staticModuleDeclarations[`valueSparqlWherePatterns`] =
354
+ code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.valueSparqlWherePatternsFunctionExpression};`;
355
+ }
356
+ if (this.configuration.features.has("Object.toString")) {
357
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
358
+ staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
359
+ code `export const ${syntheticNamePrefix}toString = ${this.toStringFunctionExpression};`;
360
+ }
361
+ return staticModuleDeclarations;
275
362
  }
276
- get inlineEqualsFunction() {
363
+ get equalsFunctionExpression() {
277
364
  return code `\
278
365
  ((left: ${this.expression}, right: ${this.expression}) => {
279
366
  ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `left`)} && ${typeCheck(code `right`)}) {
@@ -283,7 +370,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
283
370
  return ${this.reusables.imports.Left}({ left, right, propertyName: "type", propertyValuesUnequal: { left: typeof left, right: typeof right, type: "boolean" as const }, type: "property" as const });
284
371
  })`;
285
372
  }
286
- get inlineFilterFunction() {
373
+ get filterFunctionExpression() {
287
374
  const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
288
375
  return code `\
289
376
  ((filter: ${this.filterType}, value: ${this.expression}) => {
@@ -305,7 +392,7 @@ if (filter.on?.[${literalOf(primaryDiscriminantValue)}] !== undefined && ${typeC
305
392
  return true;
306
393
  })`;
307
394
  }
308
- get inlineFilterType() {
395
+ get filterTypeLiteral() {
309
396
  const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
310
397
  return code `\
311
398
  {
@@ -313,7 +400,7 @@ if (filter.on?.[${literalOf(primaryDiscriminantValue)}] !== undefined && ${typeC
313
400
  readonly on?: { ${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}?: ${type.filterType}`), { on: ";" })} }
314
401
  }`;
315
402
  }
316
- get inlineFromJsonFunction() {
403
+ get fromJsonFunctionExpression() {
317
404
  return code `\
318
405
  ((value: ${this.jsonType().expression}): ${this.reusables.imports.Either}<Error, ${this.expression}> => {
319
406
  ${joinCode(this.members.map(({ jsonType, jsonTypeCheck, type, unwrap, wrap }) => code `if (${jsonTypeCheck(code `value`)}) { return ${type.fromJsonExpression({
@@ -325,33 +412,13 @@ ${joinCode(this.members.map(({ jsonType, jsonTypeCheck, type, unwrap, wrap }) =>
325
412
  throw new Error("unable to deserialize JSON");
326
413
  })`;
327
414
  }
328
- get inlineFromRdfResourceValuesFunction() {
329
- const variables = {
330
- context: code `_options.context`,
331
- graph: code `_options.graph`,
332
- ignoreRdfType: false,
333
- objectSet: code `_options.objectSet`,
334
- preferredLanguages: code `_options.preferredLanguages`,
335
- propertyPath: code `_options.propertyPath`,
336
- resource: code `_options.resource`,
337
- };
415
+ get fromRdfResourceValuesFunctionExpression() {
338
416
  return code `\
339
- (((values, _options) =>
340
- values.chain(values => values.chainMap(value => {
341
- const valueAsValues = ${this.reusables.imports.Right}(value.toValues());
342
- return ${this.members.reduce((expression, { type, primaryDiscriminantValue }, memberI) => {
343
- let typeExpression = type.fromRdfResourceValuesExpression({
344
- variables: {
345
- context: variables.context,
346
- graph: variables.graph,
347
- ignoreRdfType: false,
348
- objectSet: variables.objectSet,
349
- preferredLanguages: variables.preferredLanguages,
350
- propertyPath: variables.propertyPath,
351
- resource: variables.resource,
352
- resourceValues: code `valueAsValues`,
353
- },
354
- });
417
+ (((values, options) =>
418
+ values.chainMap(value => {
419
+ const valueAsValues = value.toValues();
420
+ return ${this.members.reduce((expression, { type, primaryDiscriminantValue }, memberI) => {
421
+ let typeExpression = code `${type.fromRdfResourceValuesFunction}(valueAsValues, { ...options, schema: options.schema.members[${literalOf(primaryDiscriminantValue)}].type })`;
355
422
  if (this.discriminant.kind === "Extrinsic" ||
356
423
  (this.discriminant.kind === "Hybrid" &&
357
424
  this.discriminant.memberValues[memberI].kind === "Extrinsic")) {
@@ -362,17 +429,49 @@ ${joinCode(this.members.map(({ jsonType, jsonTypeCheck, type, unwrap, wrap }) =>
362
429
  ? code `${expression}.altLazy(() => ${typeExpression})`
363
430
  : typeExpression;
364
431
  }, null)}.chain(values => values.head());
365
- }))
366
- ) satisfies ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}>)`;
432
+ })
433
+ ) satisfies ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.schemaType}>)`;
367
434
  }
368
- get inlineHashFunction() {
435
+ get hashFunctionExpression() {
369
436
  return code `\
370
437
  (<HasherT extends ${this.reusables.snippets.Hasher}>(hasher: HasherT, value: ${this.expression}): HasherT => {
371
438
  ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `value`)}) { return ${type.hashFunction}(hasher, ${unwrap(code `value`)}); }`))}
372
439
  return hasher;
373
440
  })`;
374
441
  }
375
- get inlineJsonSchema() {
442
+ /**
443
+ * An inline expression of this type rather than a type reference/name.
444
+ */
445
+ get inlineExpression() {
446
+ const discriminant = this.discriminant; // To get type narrowing to work
447
+ switch (discriminant.kind) {
448
+ case "Extrinsic":
449
+ return code `(${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `{ ${discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.expression} }`), { on: "|" })})`;
450
+ case "Hybrid":
451
+ return code `(${joinCode(this.members.map(({ primaryDiscriminantValue, type }, memberI) => {
452
+ switch (discriminant.memberValues[memberI].kind) {
453
+ case "Extrinsic":
454
+ return code `{ ${discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.expression} }`;
455
+ case "Intrinsic":
456
+ return code `${type.expression}`;
457
+ default:
458
+ throw new Error();
459
+ }
460
+ }), { on: "|" })})`;
461
+ case "Intrinsic":
462
+ // If every type shares a discriminant (e.g., RDF/JS "termType" or generated ObjectType "type"),
463
+ // just join their names with "|"
464
+ return code `(${joinCode(this.members.map(({ type }) => code `${type.expression}`), { on: "|" })})`;
465
+ case "Typeof":
466
+ // The type.name may include literal values, but they should still be unambiguous with other member types since the typeofs
467
+ // of the different member types are known to be different.
468
+ return code `(${joinCode(this.members.map(({ type }) => code `${type.expression}`), { on: "|" })})`;
469
+ default:
470
+ discriminant;
471
+ throw new Error("should never reach this point");
472
+ }
473
+ }
474
+ get jsonSchemaExpression() {
376
475
  const discriminant = this.discriminant; // To get type narrowing to work
377
476
  switch (discriminant.kind) {
378
477
  case "Extrinsic":
@@ -402,7 +501,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
402
501
  throw discriminant;
403
502
  }
404
503
  }
405
- get inlineJsonType() {
504
+ get jsonTypeLiteral() {
406
505
  const discriminant = this.discriminant; // To get type narrowing to work
407
506
  switch (discriminant.kind) {
408
507
  case "Extrinsic":
@@ -425,36 +524,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
425
524
  throw discriminant;
426
525
  }
427
526
  }
428
- get inlineExpression() {
429
- const discriminant = this.discriminant; // To get type narrowing to work
430
- switch (discriminant.kind) {
431
- case "Extrinsic":
432
- return code `(${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `{ ${discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.expression} }`), { on: "|" })})`;
433
- case "Hybrid":
434
- return code `(${joinCode(this.members.map(({ primaryDiscriminantValue, type }, memberI) => {
435
- switch (discriminant.memberValues[memberI].kind) {
436
- case "Extrinsic":
437
- return code `{ ${discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.expression} }`;
438
- case "Intrinsic":
439
- return code `${type.expression}`;
440
- default:
441
- throw new Error();
442
- }
443
- }), { on: "|" })})`;
444
- case "Intrinsic":
445
- // If every type shares a discriminant (e.g., RDF/JS "termType" or generated ObjectType "type"),
446
- // just join their names with "|"
447
- return code `(${joinCode(this.members.map(({ type }) => code `${type.expression}`), { on: "|" })})`;
448
- case "Typeof":
449
- // The type.name may include literal values, but they should still be unambiguous with other member types since the typeofs
450
- // of the different member types are known to be different.
451
- return code `(${joinCode(this.members.map(({ type }) => code `${type.expression}`), { on: "|" })})`;
452
- default:
453
- discriminant;
454
- throw new Error("should never reach this point");
455
- }
456
- }
457
- get inlineToJsonFunction() {
527
+ get toJsonFunctionExpression() {
458
528
  return code `\
459
529
  ((value: ${this.expression}): ${this.jsonType().expression} => {
460
530
  ${joinCode(this.members.map(({ typeCheck, typeToJsonExpression, unwrap, wrap }) => code `if (${typeCheck(code `value`)}) { return ${wrap(typeToJsonExpression(unwrap(code `value`)))}; }`))}
@@ -462,7 +532,7 @@ ${joinCode(this.members.map(({ typeCheck, typeToJsonExpression, unwrap, wrap })
462
532
  throw new Error("unable to serialize to JSON");
463
533
  })`;
464
534
  }
465
- get inlineToRdfResourceValuesFunction() {
535
+ get toRdfResourceValuesFunctionExpression() {
466
536
  return code `\
467
537
  (((value, _options): (${joinCode([...this.toRdfResourceValueTypes].map((toRdfResourceValueType) => {
468
538
  switch (toRdfResourceValueType) {
@@ -490,7 +560,7 @@ ${joinCode(this.members.map(({ type, unwrap, typeCheck }) => code `if (${typeChe
490
560
  throw new Error("unable to serialize to RDF");
491
561
  }) satisfies ${this.reusables.snippets.ToRdfResourceValuesFunction}<${this.expression}>)`;
492
562
  }
493
- get inlineToStringFunction() {
563
+ get toStringFunctionExpression() {
494
564
  return code `\
495
565
  ((value: ${this.expression}): string => {
496
566
  ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `value`)}) { return ${type.toStringExpression({
@@ -500,7 +570,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
500
570
  throw new Error("unable to serialize to string");
501
571
  })`;
502
572
  }
503
- get inlineValueSparqlConstructTriplesFunction() {
573
+ get valueSparqlConstructTriplesFunctionExpression() {
504
574
  return code `\
505
575
  ((({ ignoreRdfType, filter, schema, ...otherParameters }) => {
506
576
  let triples: ${this.reusables.imports.sparqljs}.Triple[] = [];
@@ -511,7 +581,7 @@ triples = triples.concat(${type.valueSparqlConstructTriplesFunction}({ ...otherP
511
581
  return triples;
512
582
  }) satisfies ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}>)`;
513
583
  }
514
- get inlineValueSparqlWherePatternsFunction() {
584
+ get valueSparqlWherePatternsFunctionExpression() {
515
585
  return code `\
516
586
  ((({ filter, schema, ...otherParameters }) => {
517
587
  const unionPatterns: ${this.reusables.imports.sparqljs}.GroupPattern[] = [];
@@ -522,114 +592,38 @@ unionPatterns.push({ patterns: ${type.valueSparqlWherePatternsFunction}({ ...oth
522
592
  return [{ patterns: unionPatterns, type: "union" }];
523
593
  }) satisfies ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}>)`;
524
594
  }
525
- get schemaInitializers() {
526
- return super.schemaInitializers.concat(code `members: { ${joinCode(this.members.map(({ discriminantValues, type, primaryDiscriminantValue }) => code `${literalOf(primaryDiscriminantValue)}: ${{
527
- discriminantValues: discriminantValues,
528
- type: type.schema,
529
- }}`), { on: "," })} }`);
530
- }
531
- get staticModuleDeclarations() {
532
- const alias = this.alias.unsafeCoerce();
533
- const staticModuleDeclarations = {};
534
- if (this.configuration.features.has("Object.equals")) {
535
- staticModuleDeclarations[`equals`] =
536
- code `export const equals = ${this.inlineEqualsFunction};`;
537
- }
538
- if (this.configuration.features.has("Object.filter")) {
539
- staticModuleDeclarations[`Filter`] =
540
- code `export type Filter = ${this.inlineFilterType};`;
541
- staticModuleDeclarations[`filter`] =
542
- code `export const filter = ${this.inlineFilterFunction};`;
543
- }
544
- if (this.configuration.features.has("Object.hash")) {
545
- staticModuleDeclarations[`hash`] =
546
- code `export const hash = ${this.inlineHashFunction};`;
547
- }
548
- if (this.configuration.features.has("Object.JSON.type")) {
549
- staticModuleDeclarations[`Json.type`] =
550
- code `${this.jsonTypeAliasDeclaration}`;
551
- }
552
- if (this.configuration.features.has("Object.JSON.schema")) {
553
- staticModuleDeclarations[`Json.namespace`] = code `\
554
- export namespace Json {
555
- ${this.jsonSchemaFunctionDeclaration}
556
-
557
- export function parse(json: unknown): ${this.reusables.imports.Either}<Error, Json> {
558
- const jsonSafeParseResult = schema().safeParse(json);
559
- if (!jsonSafeParseResult.success) { return ${this.reusables.imports.Left}(jsonSafeParseResult.error); }
560
- return ${this.reusables.imports.Right}(jsonSafeParseResult.data);
561
- }
562
- }`;
563
- }
564
- if (this.configuration.features.has("Object.fromJson")) {
565
- staticModuleDeclarations[`fromJson`] =
566
- code `export const fromJson = ${this.inlineFromJsonFunction};`;
567
- }
568
- if (this.configuration.features.has("Object.fromRdf")) {
569
- staticModuleDeclarations[`fromRdfResourceValues`] =
570
- code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${alias}> = ${this.inlineFromRdfResourceValuesFunction};`;
571
- }
572
- if (this.configuration.features.has("Object.toJson")) {
573
- staticModuleDeclarations[`toJson`] =
574
- code `export const toJson = ${this.inlineToJsonFunction};`;
575
- }
576
- if (this.configuration.features.has("Object.toRdf")) {
577
- staticModuleDeclarations[`toRdfResourceValues`] =
578
- code `export const toRdfResourceValues = ${this.inlineToRdfResourceValuesFunction};`;
579
- }
580
- if (this.configuration.features.has("Object.SPARQL")) {
581
- staticModuleDeclarations[`valueSparqlConstructTriples`] =
582
- code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
583
- staticModuleDeclarations[`valueSparqlWherePatterns`] =
584
- code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
585
- }
586
- if (this.configuration.features.has("Object.toString")) {
587
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
588
- staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
589
- code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
590
- }
591
- return staticModuleDeclarations;
592
- }
593
595
  fromJsonExpression({ variables, }) {
594
- return code `${this.alias.map((alias) => code `${alias}.fromJson`).orDefault(this.inlineFromJsonFunction)}(${variables.value})`;
595
- }
596
- fromRdfResourceValuesExpression({ variables, }) {
597
- const { resourceValues: resourceValuesVariable, ...fromRdfResourceValuesOptionsTemp } = variables;
598
- const fromRdfResourceValuesOptions = fromRdfResourceValuesOptionsTemp;
599
- if (!this.configuration.features.has("ObjectSet")) {
600
- delete fromRdfResourceValuesOptions["objectSet"];
601
- }
602
- return code `${this.alias.map((alias) => code `${alias}.fromRdfResourceValues`).orDefault(this.inlineFromRdfResourceValuesFunction)}(${resourceValuesVariable}, ${fromRdfResourceValuesOptions})`;
596
+ return code `${this.name.map((name) => code `${name}.fromJson`).orDefault(this.fromJsonFunctionExpression)}(${variables.value})`;
603
597
  }
604
598
  graphqlResolveExpression({ variables, }) {
605
599
  return variables.value;
606
600
  }
607
601
  jsonSchema({ context, }) {
608
- const expression = this.alias
609
- .map((alias) => code `${alias}.Json.schema()`)
610
- .orDefault(this.inlineJsonSchema);
602
+ const expression = this.name
603
+ .map((name) => code `${name}.Json.schema()`)
604
+ .orDefault(this.jsonSchemaExpression);
611
605
  if (context === "property" && this.recursive) {
612
606
  return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.jsonType().expression}> => ${expression})`;
613
607
  }
614
608
  return expression;
615
609
  }
616
610
  jsonType() {
617
- return this.alias
618
- .map((alias) => new AbstractType.JsonType(code `${alias}.Json`))
619
- .orDefault(this.inlineJsonType);
611
+ return this.name
612
+ .map((name) => new AbstractType.JsonType(code `${name}.Json`))
613
+ .orDefault(this.jsonTypeLiteral);
620
614
  }
621
615
  jsonUiSchemaElement() {
622
616
  return Maybe.empty();
623
617
  }
624
618
  toJsonExpression({ variables, }) {
625
- return code `${this.alias.map((alias) => code `${alias}.toJson`).orDefault(this.inlineToJsonFunction)}(${variables.value})`;
619
+ return code `${this.name.map((name) => code `${name}.toJson`).orDefault(this.toJsonFunctionExpression)}(${variables.value})`;
626
620
  }
627
621
  toRdfResourceValuesExpression({ variables, }) {
628
622
  const { value: valueVariable, ...otherVariables } = variables;
629
- return code `${this.alias.map((alias) => code `${alias}.toRdfResourceValues`).orDefault(this.inlineToRdfResourceValuesFunction)}(${valueVariable}, ${otherVariables})`;
623
+ return code `${this.name.map((name) => code `${name}.toRdfResourceValues`).orDefault(this.toRdfResourceValuesFunctionExpression)}(${valueVariable}, ${otherVariables})`;
630
624
  }
631
625
  toStringExpression({ variables, }) {
632
- return code `${this.alias.map((alias) => code `${alias}.${this.configuration.syntheticNamePrefix}toString`).orDefault(this.inlineToStringFunction)}(${variables.value})`;
626
+ return code `${this.name.map((name) => code `${name}.${this.configuration.syntheticNamePrefix}toString`).orDefault(this.toStringFunctionExpression)}(${variables.value})`;
633
627
  }
634
628
  lazyMembers;
635
629
  }
@@ -645,18 +639,27 @@ __decorate([
645
639
  __decorate([
646
640
  Memoize()
647
641
  ], UnionType.prototype, "equalsFunction", null);
642
+ __decorate([
643
+ Memoize()
644
+ ], UnionType.prototype, "expression", null);
648
645
  __decorate([
649
646
  Memoize()
650
647
  ], UnionType.prototype, "filterFunction", null);
651
648
  __decorate([
652
649
  Memoize()
653
650
  ], UnionType.prototype, "filterType", null);
651
+ __decorate([
652
+ Memoize()
653
+ ], UnionType.prototype, "fromRdfResourceValuesFunction", null);
654
654
  __decorate([
655
655
  Memoize()
656
656
  ], UnionType.prototype, "graphqlType", null);
657
657
  __decorate([
658
658
  Memoize()
659
659
  ], UnionType.prototype, "hashFunction", null);
660
+ __decorate([
661
+ Memoize()
662
+ ], UnionType.prototype, "jsTypes", null);
660
663
  __decorate([
661
664
  Memoize()
662
665
  ], UnionType.prototype, "members", null);
@@ -665,13 +668,13 @@ __decorate([
665
668
  ], UnionType.prototype, "mutable", null);
666
669
  __decorate([
667
670
  Memoize()
668
- ], UnionType.prototype, "expression", null);
671
+ ], UnionType.prototype, "schema", null);
669
672
  __decorate([
670
673
  Memoize()
671
- ], UnionType.prototype, "toRdfResourceValueTypes", null);
674
+ ], UnionType.prototype, "schemaType", null);
672
675
  __decorate([
673
676
  Memoize()
674
- ], UnionType.prototype, "jsTypes", null);
677
+ ], UnionType.prototype, "toRdfResourceValueTypes", null);
675
678
  __decorate([
676
679
  Memoize()
677
680
  ], UnionType.prototype, "valueSparqlConstructTriplesFunction", null);
@@ -680,25 +683,28 @@ __decorate([
680
683
  ], UnionType.prototype, "valueSparqlWherePatternsFunction", null);
681
684
  __decorate([
682
685
  Memoize()
683
- ], UnionType.prototype, "inlineEqualsFunction", null);
686
+ ], UnionType.prototype, "schemaTypeExpression", null);
684
687
  __decorate([
685
688
  Memoize()
686
- ], UnionType.prototype, "inlineFilterFunction", null);
689
+ ], UnionType.prototype, "equalsFunctionExpression", null);
687
690
  __decorate([
688
691
  Memoize()
689
- ], UnionType.prototype, "inlineFilterType", null);
692
+ ], UnionType.prototype, "filterFunctionExpression", null);
690
693
  __decorate([
691
694
  Memoize()
692
- ], UnionType.prototype, "inlineJsonType", null);
695
+ ], UnionType.prototype, "filterTypeLiteral", null);
693
696
  __decorate([
694
697
  Memoize()
695
698
  ], UnionType.prototype, "inlineExpression", null);
696
699
  __decorate([
697
700
  Memoize()
698
- ], UnionType.prototype, "inlineValueSparqlConstructTriplesFunction", null);
701
+ ], UnionType.prototype, "jsonTypeLiteral", null);
702
+ __decorate([
703
+ Memoize()
704
+ ], UnionType.prototype, "valueSparqlConstructTriplesFunctionExpression", null);
699
705
  __decorate([
700
706
  Memoize()
701
- ], UnionType.prototype, "inlineValueSparqlWherePatternsFunction", null);
707
+ ], UnionType.prototype, "valueSparqlWherePatternsFunctionExpression", null);
702
708
  __decorate([
703
709
  Memoize()
704
710
  ], UnionType.prototype, "jsonType", null);
@@ -784,8 +790,8 @@ export var Discriminant;
784
790
  continue;
785
791
  }
786
792
  extrinsicMemberTypeCount++;
787
- if (memberType.alias.isJust()) {
788
- extrinsicMemberTypeAliasesSet.add(memberType.alias.extract());
793
+ if (memberType.name.isJust()) {
794
+ extrinsicMemberTypeAliasesSet.add(memberType.name.extract());
789
795
  }
790
796
  else {
791
797
  break;
@@ -805,7 +811,7 @@ export var Discriminant;
805
811
  return {
806
812
  kind: "Extrinsic",
807
813
  values: extrinsicMemberTypeAliasesSet.size === extrinsicMemberTypeCount
808
- ? [memberType.alias.unsafeCoerce()]
814
+ ? [memberType.name.unsafeCoerce()]
809
815
  : [memberTypeI.toString()],
810
816
  };
811
817
  }),
@@ -816,7 +822,7 @@ export var Discriminant;
816
822
  {
817
823
  let memberValues;
818
824
  {
819
- const memberTypeNames = memberTypes.map((memberType) => memberType.alias.orDefault(memberType.jsTypes[0].typeof));
825
+ const memberTypeNames = memberTypes.map((memberType) => memberType.name.orDefault(memberType.jsTypes[0].typeof));
820
826
  const memberTypeNamesSet = new Set(memberTypeNames);
821
827
  if (memberTypeNamesSet.size === memberTypeNames.length) {
822
828
  memberValues = memberTypeNames;