@shaclmate/compiler 4.0.40 → 4.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/dist/ShapesGraphToAstTransformer.d.ts +1 -8
  2. package/dist/ShapesGraphToAstTransformer.js +11 -126
  3. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
  4. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.d.ts +17 -0
  5. package/dist/_ShapesGraphToAstTransformer/{transformPropertyShapeToAstObjectTypeProperty.js → transformPropertyShapeToAstStructTypeField.js} +71 -48
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +1 -1
  7. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +29 -20
  8. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.d.ts → transformShapeToAstStructType.d.ts} +3 -3
  9. package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.js → transformShapeToAstStructType.js} +35 -45
  10. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +2 -1
  11. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +1 -1
  12. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
  13. package/dist/ast/AbstractCompoundType.d.ts +3 -2
  14. package/dist/ast/AbstractCompoundType.js +5 -5
  15. package/dist/ast/AbstractContainerType.d.ts +2 -2
  16. package/dist/ast/AbstractContainerType.js +4 -4
  17. package/dist/ast/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +10 -12
  18. package/dist/ast/{AbstractLazyObjectType.js → AbstractLazyType.js} +3 -3
  19. package/dist/ast/AbstractType.d.ts +1 -1
  20. package/dist/ast/AbstractType.js +3 -0
  21. package/dist/ast/Ast.d.ts +2 -6
  22. package/dist/ast/DefaultValueType.js +2 -1
  23. package/dist/ast/IntersectionType.d.ts +2 -2
  24. package/dist/ast/IntersectionType.js +3 -3
  25. package/dist/ast/LazyOptionType.d.ts +6 -0
  26. package/dist/ast/LazyOptionType.js +5 -0
  27. package/dist/ast/LazySetType.d.ts +6 -0
  28. package/dist/ast/LazySetType.js +5 -0
  29. package/dist/ast/LazyType.d.ts +5 -0
  30. package/dist/ast/LazyType.js +5 -0
  31. package/dist/ast/ListType.d.ts +2 -2
  32. package/dist/ast/ListType.js +5 -5
  33. package/dist/ast/OptionType.js +2 -1
  34. package/dist/ast/SetType.js +2 -1
  35. package/dist/ast/StructCompoundType.d.ts +12 -0
  36. package/dist/ast/{ObjectCompoundType.js → StructCompoundType.js} +18 -18
  37. package/dist/ast/StructIntersectionType.d.ts +4 -0
  38. package/dist/ast/StructIntersectionType.js +2 -0
  39. package/dist/ast/{ObjectType.d.ts → StructType.d.ts} +28 -39
  40. package/dist/ast/{ObjectType.js → StructType.js} +81 -156
  41. package/dist/ast/StructUnionType.d.ts +4 -0
  42. package/dist/ast/StructUnionType.js +2 -0
  43. package/dist/ast/Type.d.ts +5 -5
  44. package/dist/ast/Type.js +4 -4
  45. package/dist/ast/UnionType.d.ts +2 -2
  46. package/dist/ast/UnionType.js +3 -3
  47. package/dist/ast/index.d.ts +7 -7
  48. package/dist/ast/index.js +7 -7
  49. package/dist/generators/AstJsonGenerator.js +7 -3
  50. package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
  51. package/dist/generators/ts/AbstractCollectionType.d.ts +4 -11
  52. package/dist/generators/ts/AbstractCollectionType.js +3 -62
  53. package/dist/generators/ts/AbstractContainerType.d.ts +1 -2
  54. package/dist/generators/ts/AbstractContainerType.js +7 -10
  55. package/dist/generators/ts/AbstractDateType.d.ts +5 -8
  56. package/dist/generators/ts/AbstractDateType.js +7 -12
  57. package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
  58. package/dist/generators/ts/AbstractIdentifierType.js +3 -0
  59. package/dist/generators/ts/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +8 -8
  60. package/dist/generators/ts/{AbstractLazyObjectType.js → AbstractLazyType.js} +30 -17
  61. package/dist/generators/ts/AbstractLiteralType.d.ts +3 -5
  62. package/dist/generators/ts/AbstractLiteralType.js +0 -21
  63. package/dist/generators/ts/AbstractNumericType.d.ts +1 -7
  64. package/dist/generators/ts/AbstractNumericType.js +17 -27
  65. package/dist/generators/ts/AbstractObjectSetType.d.ts +1 -1
  66. package/dist/generators/ts/AbstractObjectSetType.js +2 -2
  67. package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -1
  68. package/dist/generators/ts/AbstractPrimitiveType.js +1 -1
  69. package/dist/generators/ts/AbstractTermType.d.ts +7 -23
  70. package/dist/generators/ts/AbstractTermType.js +27 -58
  71. package/dist/generators/ts/AbstractType.d.ts +86 -63
  72. package/dist/generators/ts/AbstractType.js +48 -22
  73. package/dist/generators/ts/BigDecimalType.d.ts +7 -3
  74. package/dist/generators/ts/BigDecimalType.js +7 -9
  75. package/dist/generators/ts/BigIntType.d.ts +5 -3
  76. package/dist/generators/ts/BigIntType.js +8 -5
  77. package/dist/generators/ts/BlankNodeType.d.ts +2 -7
  78. package/dist/generators/ts/BlankNodeType.js +4 -9
  79. package/dist/generators/ts/BooleanType.d.ts +6 -4
  80. package/dist/generators/ts/BooleanType.js +13 -15
  81. package/dist/generators/ts/DateTimeType.d.ts +2 -2
  82. package/dist/generators/ts/DateTimeType.js +14 -4
  83. package/dist/generators/ts/DateType.d.ts +2 -2
  84. package/dist/generators/ts/DateType.js +14 -4
  85. package/dist/generators/ts/DefaultValueType.d.ts +40 -2
  86. package/dist/generators/ts/DefaultValueType.js +15 -14
  87. package/dist/generators/ts/FloatType.d.ts +5 -3
  88. package/dist/generators/ts/FloatType.js +8 -5
  89. package/dist/generators/ts/GraphqlSchema.js +2 -2
  90. package/dist/generators/ts/IdentifierType.d.ts +2 -2
  91. package/dist/generators/ts/IdentifierType.js +8 -11
  92. package/dist/generators/ts/IntType.d.ts +5 -3
  93. package/dist/generators/ts/IntType.js +8 -5
  94. package/dist/generators/ts/IriType.d.ts +2 -2
  95. package/dist/generators/ts/IriType.js +16 -16
  96. package/dist/generators/ts/{LazyObjectOptionType.d.ts → LazyOptionType.d.ts} +13 -11
  97. package/dist/generators/ts/LazyOptionType.js +75 -0
  98. package/dist/generators/ts/LazySetType.d.ts +20 -0
  99. package/dist/generators/ts/LazySetType.js +76 -0
  100. package/dist/generators/ts/LazyType.d.ts +19 -0
  101. package/dist/generators/ts/LazyType.js +65 -0
  102. package/dist/generators/ts/ListType.d.ts +11 -2
  103. package/dist/generators/ts/ListType.js +53 -26
  104. package/dist/generators/ts/LiteralType.d.ts +7 -2
  105. package/dist/generators/ts/LiteralType.js +12 -5
  106. package/dist/generators/ts/ObjectType.d.ts +24 -25
  107. package/dist/generators/ts/ObjectType.js +303 -161
  108. package/dist/generators/ts/ObjectUnionType.js +42 -42
  109. package/dist/generators/ts/OptionType.d.ts +6 -2
  110. package/dist/generators/ts/OptionType.js +16 -9
  111. package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -4
  112. package/dist/generators/ts/SetType.d.ts +17 -2
  113. package/dist/generators/ts/SetType.js +85 -9
  114. package/dist/generators/ts/Snippets.d.ts +29 -9
  115. package/dist/generators/ts/Snippets.js +179 -39
  116. package/dist/generators/ts/StringType.d.ts +7 -4
  117. package/dist/generators/ts/StringType.js +23 -12
  118. package/dist/generators/ts/TermType.d.ts +9 -3
  119. package/dist/generators/ts/TermType.js +29 -7
  120. package/dist/generators/ts/TsGenerator.d.ts +1 -1
  121. package/dist/generators/ts/TsGenerator.js +62 -32
  122. package/dist/generators/ts/Type.d.ts +4 -4
  123. package/dist/generators/ts/TypeFactory.d.ts +5 -5
  124. package/dist/generators/ts/TypeFactory.js +90 -82
  125. package/dist/generators/ts/UnionType.d.ts +25 -23
  126. package/dist/generators/ts/UnionType.js +254 -261
  127. package/dist/generators/ts/ZodGenerator.d.ts +1 -1
  128. package/dist/generators/ts/ZodGenerator.js +29 -14
  129. package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +28 -16
  130. package/dist/generators/ts/_ObjectType/AbstractProperty.js +1 -24
  131. package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +15 -17
  132. package/dist/generators/ts/_ObjectType/DiscriminantProperty.js +24 -54
  133. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +8 -2
  134. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +48 -20
  135. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.d.ts +4 -0
  136. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.js +28 -0
  137. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.d.ts +4 -0
  138. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.js +15 -0
  139. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.d.ts +4 -0
  140. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +12 -0
  141. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeExpression.d.ts +4 -0
  142. package/dist/generators/ts/_ObjectType/{ObjectType_filterTypeDeclaration.js → ObjectType_filterTypeExpression.js} +5 -10
  143. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_focusSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  144. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionExpression.js} +5 -13
  145. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_focusSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  146. package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → ObjectType_focusSparqlWherePatternsFunctionExpression.js} +8 -31
  147. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.d.ts +4 -0
  148. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.js +12 -0
  149. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.d.ts +4 -0
  150. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.js +43 -0
  151. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeExpression.d.ts +4 -0
  152. package/dist/generators/ts/_ObjectType/{ObjectType_graphqlTypeVariableStatement.js → ObjectType_graphqlTypeExpression.js} +6 -13
  153. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.d.ts +4 -0
  154. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +30 -0
  155. package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +4 -0
  156. package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.js +13 -0
  157. package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +11 -8
  158. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +1 -2
  159. package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.js +2 -6
  160. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.d.ts +4 -0
  161. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.js +18 -0
  162. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.d.ts +4 -0
  163. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.js +5 -0
  164. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.d.ts +4 -0
  165. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js +17 -0
  166. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +1 -1
  167. package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.js +2 -2
  168. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +4 -0
  169. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +18 -0
  170. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +4 -0
  171. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +18 -0
  172. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -3
  173. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +5 -9
  174. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -3
  175. package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +4 -8
  176. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.d.ts +4 -0
  177. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +14 -0
  178. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.d.ts +4 -0
  179. package/dist/generators/ts/_ObjectType/{ObjectType_toRdfResourceFunctionDeclaration.js → ObjectType_toRdfResourceFunctionExpression.js} +7 -13
  180. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.d.ts +4 -0
  181. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.js +7 -0
  182. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.d.ts +4 -0
  183. package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.js +5 -0
  184. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_valueSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
  185. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionExpression.js +8 -0
  186. package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_valueSparqlWherePatternsFunctionExpression.d.ts} +2 -3
  187. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionExpression.js +10 -0
  188. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +9 -2
  189. package/dist/generators/ts/_ObjectType/ShaclProperty.js +70 -38
  190. package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +4 -3
  191. package/dist/generators/ts/_snippets/snippets_DateSchema.js +4 -3
  192. package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
  193. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +6 -5
  194. package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +2 -1
  195. package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -0
  196. package/dist/generators/ts/_snippets/snippets_Lazy.d.ts +3 -0
  197. package/dist/generators/ts/_snippets/snippets_Lazy.js +22 -0
  198. package/dist/generators/ts/_snippets/snippets_LazyOption.d.ts +3 -0
  199. package/dist/generators/ts/_snippets/snippets_LazyOption.js +25 -0
  200. package/dist/generators/ts/_snippets/snippets_LazySet.d.ts +3 -0
  201. package/dist/generators/ts/_snippets/snippets_LazySet.js +40 -0
  202. package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +1 -3
  203. package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -0
  204. package/dist/generators/ts/_snippets/snippets_NumericSchema.js +2 -1
  205. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +6 -8
  206. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +32 -32
  207. package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
  208. package/dist/generators/ts/_snippets/snippets_StringSchema.js +5 -3
  209. package/dist/generators/ts/_snippets/snippets_TermFilter.js +3 -3
  210. package/dist/generators/ts/_snippets/snippets_TermSchema.js +4 -2
  211. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.d.ts +3 -0
  212. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +6 -0
  213. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.d.ts +3 -0
  214. package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.js +6 -0
  215. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.d.ts +3 -0
  216. package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.js +6 -0
  217. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.d.ts +3 -0
  218. package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.js +6 -0
  219. package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
  220. package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
  221. package/dist/generators/ts/_snippets/snippets_convertToLazy.d.ts +3 -0
  222. package/dist/generators/ts/_snippets/snippets_convertToLazy.js +15 -0
  223. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.d.ts +3 -0
  224. package/dist/generators/ts/_snippets/snippets_convertToLazyOption.js +33 -0
  225. package/dist/generators/ts/_snippets/snippets_convertToLazySet.d.ts +3 -0
  226. package/dist/generators/ts/_snippets/snippets_convertToLazySet.js +27 -0
  227. package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
  228. package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
  229. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
  230. package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
  231. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.d.ts +3 -0
  232. package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.js +6 -0
  233. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.d.ts +3 -0
  234. package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.js +6 -0
  235. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.d.ts +3 -0
  236. package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.js +10 -0
  237. package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
  238. package/dist/generators/ts/_snippets/snippets_filterNumeric.js +1 -1
  239. package/dist/generators/ts/_snippets/snippets_filterTerm.js +1 -2
  240. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.d.ts +3 -0
  241. package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.js +6 -0
  242. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.d.ts +3 -0
  243. package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.js +6 -0
  244. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.d.ts +3 -0
  245. package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.js +6 -0
  246. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.d.ts +3 -0
  247. package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.js +6 -0
  248. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.d.ts +3 -0
  249. package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.js +15 -0
  250. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.d.ts +3 -0
  251. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +6 -0
  252. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.d.ts +3 -0
  253. package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.js +11 -0
  254. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.d.ts +3 -0
  255. package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.js +8 -0
  256. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.d.ts +3 -0
  257. package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.js +8 -0
  258. package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +1 -1
  259. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.d.ts +3 -0
  260. package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.js +9 -0
  261. package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +13 -7
  262. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.d.ts +3 -0
  263. package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.js +6 -0
  264. package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +1 -1
  265. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.d.ts +3 -0
  266. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +17 -0
  267. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.d.ts +3 -0
  268. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +60 -0
  269. package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
  270. package/dist/input/generated.d.ts +1116 -400
  271. package/dist/input/generated.js +1879 -1917
  272. package/package.json +2 -4
  273. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +0 -9
  274. package/dist/ast/LazyObjectOptionType.d.ts +0 -6
  275. package/dist/ast/LazyObjectOptionType.js +0 -5
  276. package/dist/ast/LazyObjectSetType.d.ts +0 -6
  277. package/dist/ast/LazyObjectSetType.js +0 -5
  278. package/dist/ast/LazyObjectType.d.ts +0 -5
  279. package/dist/ast/LazyObjectType.js +0 -5
  280. package/dist/ast/ObjectCompoundType.d.ts +0 -12
  281. package/dist/ast/ObjectIntersectionType.d.ts +0 -4
  282. package/dist/ast/ObjectIntersectionType.js +0 -2
  283. package/dist/ast/ObjectUnionType.d.ts +0 -4
  284. package/dist/ast/ObjectUnionType.js +0 -2
  285. package/dist/generators/ts/LazyObjectOptionType.js +0 -62
  286. package/dist/generators/ts/LazyObjectSetType.d.ts +0 -20
  287. package/dist/generators/ts/LazyObjectSetType.js +0 -61
  288. package/dist/generators/ts/LazyObjectType.d.ts +0 -19
  289. package/dist/generators/ts/LazyObjectType.js +0 -53
  290. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
  291. package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +0 -65
  292. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +0 -5
  293. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.js +0 -23
  294. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -5
  295. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +0 -24
  296. package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -5
  297. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
  298. package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +0 -43
  299. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
  300. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
  301. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
  302. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
  303. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
  304. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.js +0 -10
  305. package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
  306. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +0 -4
  307. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +0 -45
  308. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
  309. package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +0 -16
  310. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
  311. package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -31
  312. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
  313. package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +0 -16
  314. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
  315. package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +0 -17
  316. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -5
  317. package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +0 -14
  318. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +0 -5
  319. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +0 -41
  320. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
  321. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +0 -4
  322. package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.js +0 -36
  323. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +0 -11
  324. package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +0 -13
  325. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
  326. package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +0 -27
  327. package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +0 -3
  328. package/dist/generators/ts/_snippets/snippets_LazyObject.js +0 -22
  329. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +0 -3
  330. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +0 -25
  331. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +0 -3
  332. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +0 -40
  333. package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
  334. package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
  335. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +0 -3
  336. package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +0 -15
  337. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +0 -3
  338. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +0 -31
  339. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +0 -3
  340. package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +0 -25
  341. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +0 -3
  342. package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +0 -15
  343. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +0 -3
  344. package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +0 -23
@@ -32,32 +32,11 @@ export class UnionType extends AbstractType {
32
32
  discriminantValues = [this.discriminant.memberValues[memberI]];
33
33
  break;
34
34
  case "Hybrid":
35
- discriminantValues =
36
- this.discriminant.memberValues[memberI].ownValues;
35
+ discriminantValues = this.discriminant.memberValues[memberI].values;
37
36
  break;
38
37
  case "Intrinsic": {
39
- // A member type's combined discriminant property values are its "own" values plus any descendant values that are
40
- // not the "own" values of some other member type.
41
- // So if you have type A, type B, and B inherits A, then
42
- // A has
43
- // own discriminant property values: ["A"]
44
- // descendant discriminant property values: ["B"]
45
- // and B has
46
- // own discriminant property values: ["B"]
47
- // descendant discriminant property values ["B"]
48
- // In this case A shouldn't have "B" as a combined discriminant property value since it's "claimed" by B.
49
- const memberOwnDiscriminantPropertyValues = new Set();
50
- for (const member of members) {
51
- for (const ownDiscriminantPropertyValue of member.type.discriminantProperty.unsafeCoerce()
52
- .ownValues) {
53
- memberOwnDiscriminantPropertyValues.add(ownDiscriminantPropertyValue);
54
- }
55
- }
56
- discriminantValues = member.type.discriminantProperty
57
- .unsafeCoerce()
58
- .ownValues.concat(member.type.discriminantProperty
59
- .unsafeCoerce()
60
- .descendantValues.filter((value) => !memberOwnDiscriminantPropertyValues.has(value)));
38
+ discriminantValues =
39
+ member.type.discriminantProperty.unsafeCoerce().values;
61
40
  break;
62
41
  }
63
42
  case "Typeof":
@@ -76,7 +55,7 @@ export class UnionType extends AbstractType {
76
55
  switch (member.type.kind) {
77
56
  case "Object":
78
57
  case "ObjectUnion":
79
- 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})`;
80
59
  }
81
60
  }
82
61
  const discriminantName = json
@@ -90,7 +69,7 @@ export class UnionType extends AbstractType {
90
69
  includeDiscriminantProperty: this.discriminant.kind === "Intrinsic" ||
91
70
  (this.discriminant.kind === "Hybrid" &&
92
71
  this.discriminant.memberValues[memberI].kind === "Intrinsic"),
93
- }).name,
72
+ }).expression,
94
73
  jsonTypeCheck: typeCheck(true),
95
74
  primaryDiscriminantValue: discriminantValues[0],
96
75
  type: member.type,
@@ -136,31 +115,34 @@ export class UnionType extends AbstractType {
136
115
  return Maybe.of({
137
116
  code: code `${this.reusables.snippets.identityConversionFunction}`,
138
117
  sourceTypes: this.discriminant.kind === "Typeof"
139
- ? this.members.map(({ primaryDiscriminantValue, type }) => ({
118
+ ? this.members.flatMap(({ type }) => type.jsTypes.map((jsType) => ({
140
119
  expression: type.expression,
141
- typeof: primaryDiscriminantValue,
142
- }))
120
+ jsType,
121
+ })))
143
122
  : [
144
123
  {
145
124
  expression: this.expression,
146
- typeof: "object",
125
+ jsType: {
126
+ instanceof: "Object",
127
+ typeof: "object",
128
+ },
147
129
  },
148
130
  ],
149
131
  });
150
132
  }
151
133
  get declaration() {
152
- const alias = this.alias.extract();
153
- if (!alias) {
134
+ const name = this.name.extract();
135
+ if (!name) {
154
136
  return Maybe.empty();
155
137
  }
156
138
  const declarations = [];
157
139
  if (this.configuration.features.has("Object.type")) {
158
- declarations.push(code `export type ${def(alias)} = ${this.inlineExpression};`);
140
+ declarations.push(code `export type ${def(name)} = ${this.inlineExpression};`);
159
141
  }
160
142
  const staticModuleDeclarations = Object.entries(this.staticModuleDeclarations);
161
143
  if (staticModuleDeclarations.length > 0) {
162
144
  declarations.push(code `\
163
- export namespace ${def(alias)} {
145
+ export namespace ${def(name)} {
164
146
  ${joinCode(staticModuleDeclarations
165
147
  .sort((left, right) => left[0].localeCompare(right[0]))
166
148
  .map((_) => _[1]), { on: "\n\n" })}
@@ -172,24 +154,21 @@ ${joinCode(staticModuleDeclarations
172
154
  switch (this.discriminant.kind) {
173
155
  case "Extrinsic":
174
156
  return Maybe.of({
175
- descendantValues: [],
176
157
  jsonName: this.discriminant.jsonName,
177
- ownValues: this.discriminant.memberValues,
178
158
  name: this.discriminant.name,
159
+ values: this.discriminant.memberValues,
179
160
  });
180
161
  case "Hybrid":
181
162
  return Maybe.of({
182
- descendantValues: [],
183
163
  jsonName: this.discriminant.jsonName,
184
- ownValues: this.discriminant.memberValues.flatMap((_) => _.ownValues),
185
164
  name: "termType",
165
+ values: this.discriminant.memberValues.flatMap((_) => _.values),
186
166
  });
187
167
  case "Intrinsic":
188
168
  return Maybe.of({
189
- descendantValues: this.discriminant.memberValues.flatMap((_) => _.descendantValues),
190
169
  jsonName: this.discriminant.jsonName,
191
170
  name: this.discriminant.name,
192
- ownValues: this.discriminant.memberValues.flatMap((_) => _.ownValues),
171
+ values: this.discriminant.memberValues,
193
172
  });
194
173
  case "Typeof":
195
174
  return Maybe.empty();
@@ -198,32 +177,53 @@ ${joinCode(staticModuleDeclarations
198
177
  }
199
178
  }
200
179
  get equalsFunction() {
201
- return this.alias
202
- .map((alias) => code `${alias}.equals`)
203
- .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);
204
188
  }
205
189
  get filterFunction() {
206
- return this.alias
207
- .map((alias) => code `${alias}.filter`)
208
- .orDefault(this.inlineFilterFunction);
190
+ return this.name
191
+ .map((name) => code `${name}.filter`)
192
+ .orDefault(this.filterFunctionExpression);
209
193
  }
210
194
  get filterType() {
211
- return this.alias
212
- .map((alias) => code `${alias}.Filter`)
213
- .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);
214
203
  }
215
204
  get graphqlType() {
216
- const alias = this.alias.extract();
217
- if (!alias ||
205
+ const name = this.name.extract();
206
+ if (!name ||
218
207
  !this.members.every((member) => member.type.kind === "Object")) {
219
208
  throw new Error("not implemented");
220
209
  }
221
- return new AbstractType.GraphqlType(code `${alias}.GraphQL`, this.reusables);
210
+ return new AbstractType.GraphqlType(code `${name}.GraphQL`, this.reusables);
222
211
  }
223
212
  get hashFunction() {
224
- return this.alias
225
- .map((alias) => code `${alias}.hash`)
226
- .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;
227
227
  }
228
228
  get jsonSchemaFunctionDeclaration() {
229
229
  const meta = {
@@ -235,10 +235,10 @@ ${joinCode(staticModuleDeclarations
235
235
  this.label.ifJust((label) => {
236
236
  meta["title"] = label;
237
237
  });
238
- return code `export const schema = () => ${this.inlineJsonSchema}.meta(${meta});`;
238
+ return code `export const schema = () => ${this.jsonSchemaExpression}.meta(${meta});`;
239
239
  }
240
240
  get jsonTypeAliasDeclaration() {
241
- return code `export type Json = ${this.inlineJsonType.name}`;
241
+ return code `export type Json = ${this.jsonTypeLiteral.expression}`;
242
242
  }
243
243
  get members() {
244
244
  return this.lazyMembers();
@@ -246,22 +246,19 @@ ${joinCode(staticModuleDeclarations
246
246
  get mutable() {
247
247
  return this.members.some((member) => member.type.mutable);
248
248
  }
249
- get expression() {
250
- return this.alias
251
- .map((alias) => code `${alias}`)
252
- .orDefault(this.inlineExpression);
249
+ get referencesNamedType() {
250
+ return (this.name.isJust() ||
251
+ this.members.some((member) => member.type.referencesNamedType));
253
252
  }
254
- get referencesObjectType() {
255
- 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);
256
257
  }
257
258
  get schemaType() {
258
- return code `${{
259
- kind: this.kind,
260
- members: code `{ ${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}: ${{
261
- discriminantValues: code `readonly (number | string)[]`,
262
- type: type.schemaType,
263
- }}`), { on: ";" })} }`,
264
- }}`;
259
+ return this.name
260
+ .map(() => code `typeof ${this.schema}`)
261
+ .orDefault(this.schemaTypeExpression);
265
262
  }
266
263
  get toRdfResourceValueTypes() {
267
264
  const set = new Set();
@@ -272,20 +269,98 @@ ${joinCode(staticModuleDeclarations
272
269
  }
273
270
  return set;
274
271
  }
275
- get typeofs() {
276
- return [...new Set(this.members.flatMap((member) => member.type.typeofs))];
277
- }
278
272
  get valueSparqlConstructTriplesFunction() {
279
- return this.alias
280
- .map((alias) => code `${alias}.valueSparqlConstructTriples`)
281
- .orDefault(this.inlineValueSparqlConstructTriplesFunction);
273
+ return this.name
274
+ .map((name) => code `${name}.valueSparqlConstructTriples`)
275
+ .orDefault(this.valueSparqlConstructTriplesFunctionExpression);
282
276
  }
283
277
  get valueSparqlWherePatternsFunction() {
284
- return this.alias
285
- .map((alias) => code `${alias}.valueSparqlWherePatterns`)
286
- .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
287
  }
288
- get inlineEqualsFunction() {
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;
362
+ }
363
+ get equalsFunctionExpression() {
289
364
  return code `\
290
365
  ((left: ${this.expression}, right: ${this.expression}) => {
291
366
  ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `left`)} && ${typeCheck(code `right`)}) {
@@ -295,7 +370,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
295
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 });
296
371
  })`;
297
372
  }
298
- get inlineFilterFunction() {
373
+ get filterFunctionExpression() {
299
374
  const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
300
375
  return code `\
301
376
  ((filter: ${this.filterType}, value: ${this.expression}) => {
@@ -317,7 +392,7 @@ if (filter.on?.[${literalOf(primaryDiscriminantValue)}] !== undefined && ${typeC
317
392
  return true;
318
393
  })`;
319
394
  }
320
- get inlineFilterType() {
395
+ get filterTypeLiteral() {
321
396
  const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
322
397
  return code `\
323
398
  {
@@ -325,9 +400,9 @@ if (filter.on?.[${literalOf(primaryDiscriminantValue)}] !== undefined && ${typeC
325
400
  readonly on?: { ${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}?: ${type.filterType}`), { on: ";" })} }
326
401
  }`;
327
402
  }
328
- get inlineFromJsonFunction() {
403
+ get fromJsonFunctionExpression() {
329
404
  return code `\
330
- ((value: ${this.jsonType().name}): ${this.reusables.imports.Either}<Error, ${this.expression}> => {
405
+ ((value: ${this.jsonType().expression}): ${this.reusables.imports.Either}<Error, ${this.expression}> => {
331
406
  ${joinCode(this.members.map(({ jsonType, jsonTypeCheck, type, unwrap, wrap }) => code `if (${jsonTypeCheck(code `value`)}) { return ${type.fromJsonExpression({
332
407
  variables: {
333
408
  value: code `(${unwrap(code `value`)} as ${jsonType})`,
@@ -337,33 +412,13 @@ ${joinCode(this.members.map(({ jsonType, jsonTypeCheck, type, unwrap, wrap }) =>
337
412
  throw new Error("unable to deserialize JSON");
338
413
  })`;
339
414
  }
340
- get inlineFromRdfResourceValuesFunction() {
341
- const variables = {
342
- context: code `_options.context`,
343
- graph: code `_options.graph`,
344
- ignoreRdfType: false,
345
- objectSet: code `_options.objectSet`,
346
- preferredLanguages: code `_options.preferredLanguages`,
347
- propertyPath: code `_options.propertyPath`,
348
- resource: code `_options.resource`,
349
- };
415
+ get fromRdfResourceValuesFunctionExpression() {
350
416
  return code `\
351
- (((values, _options) =>
352
- values.chain(values => values.chainMap(value => {
353
- const valueAsValues = ${this.reusables.imports.Right}(value.toValues());
354
- return ${this.members.reduce((expression, { type, primaryDiscriminantValue }, memberI) => {
355
- let typeExpression = type.fromRdfResourceValuesExpression({
356
- variables: {
357
- context: variables.context,
358
- graph: variables.graph,
359
- ignoreRdfType: false,
360
- objectSet: variables.objectSet,
361
- preferredLanguages: variables.preferredLanguages,
362
- propertyPath: variables.propertyPath,
363
- resource: variables.resource,
364
- resourceValues: code `valueAsValues`,
365
- },
366
- });
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 })`;
367
422
  if (this.discriminant.kind === "Extrinsic" ||
368
423
  (this.discriminant.kind === "Hybrid" &&
369
424
  this.discriminant.memberValues[memberI].kind === "Extrinsic")) {
@@ -374,17 +429,49 @@ ${joinCode(this.members.map(({ jsonType, jsonTypeCheck, type, unwrap, wrap }) =>
374
429
  ? code `${expression}.altLazy(() => ${typeExpression})`
375
430
  : typeExpression;
376
431
  }, null)}.chain(values => values.head());
377
- }))
378
- ) satisfies ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}>)`;
432
+ })
433
+ ) satisfies ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.expression}, ${this.schemaType}>)`;
379
434
  }
380
- get inlineHashFunction() {
435
+ get hashFunctionExpression() {
381
436
  return code `\
382
437
  (<HasherT extends ${this.reusables.snippets.Hasher}>(hasher: HasherT, value: ${this.expression}): HasherT => {
383
438
  ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `value`)}) { return ${type.hashFunction}(hasher, ${unwrap(code `value`)}); }`))}
384
439
  return hasher;
385
440
  })`;
386
441
  }
387
- 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() {
388
475
  const discriminant = this.discriminant; // To get type narrowing to work
389
476
  switch (discriminant.kind) {
390
477
  case "Extrinsic":
@@ -414,7 +501,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
414
501
  throw discriminant;
415
502
  }
416
503
  }
417
- get inlineJsonType() {
504
+ get jsonTypeLiteral() {
418
505
  const discriminant = this.discriminant; // To get type narrowing to work
419
506
  switch (discriminant.kind) {
420
507
  case "Extrinsic":
@@ -437,44 +524,15 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
437
524
  throw discriminant;
438
525
  }
439
526
  }
440
- get inlineExpression() {
441
- const discriminant = this.discriminant; // To get type narrowing to work
442
- switch (discriminant.kind) {
443
- case "Extrinsic":
444
- return code `(${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `{ ${discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.expression} }`), { on: "|" })})`;
445
- case "Hybrid":
446
- return code `(${joinCode(this.members.map(({ primaryDiscriminantValue, type }, memberI) => {
447
- switch (discriminant.memberValues[memberI].kind) {
448
- case "Extrinsic":
449
- return code `{ ${discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.expression} }`;
450
- case "Intrinsic":
451
- return code `${type.expression}`;
452
- default:
453
- throw new Error();
454
- }
455
- }), { on: "|" })})`;
456
- case "Intrinsic":
457
- // If every type shares a discriminant (e.g., RDF/JS "termType" or generated ObjectType "type"),
458
- // just join their names with "|"
459
- return code `(${joinCode(this.members.map(({ type }) => code `${type.expression}`), { on: "|" })})`;
460
- case "Typeof":
461
- // The type.name may include literal values, but they should still be unambiguous with other member types since the typeofs
462
- // of the different member types are known to be different.
463
- return code `(${joinCode(this.members.map(({ type }) => code `${type.expression}`), { on: "|" })})`;
464
- default:
465
- discriminant;
466
- throw new Error("should never reach this point");
467
- }
468
- }
469
- get inlineToJsonFunction() {
527
+ get toJsonFunctionExpression() {
470
528
  return code `\
471
- ((value: ${this.expression}): ${this.jsonType().name} => {
529
+ ((value: ${this.expression}): ${this.jsonType().expression} => {
472
530
  ${joinCode(this.members.map(({ typeCheck, typeToJsonExpression, unwrap, wrap }) => code `if (${typeCheck(code `value`)}) { return ${wrap(typeToJsonExpression(unwrap(code `value`)))}; }`))}
473
531
 
474
532
  throw new Error("unable to serialize to JSON");
475
533
  })`;
476
534
  }
477
- get inlineToRdfResourceValuesFunction() {
535
+ get toRdfResourceValuesFunctionExpression() {
478
536
  return code `\
479
537
  (((value, _options): (${joinCode([...this.toRdfResourceValueTypes].map((toRdfResourceValueType) => {
480
538
  switch (toRdfResourceValueType) {
@@ -502,7 +560,7 @@ ${joinCode(this.members.map(({ type, unwrap, typeCheck }) => code `if (${typeChe
502
560
  throw new Error("unable to serialize to RDF");
503
561
  }) satisfies ${this.reusables.snippets.ToRdfResourceValuesFunction}<${this.expression}>)`;
504
562
  }
505
- get inlineToStringFunction() {
563
+ get toStringFunctionExpression() {
506
564
  return code `\
507
565
  ((value: ${this.expression}): string => {
508
566
  ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `value`)}) { return ${type.toStringExpression({
@@ -512,7 +570,7 @@ ${joinCode(this.members.map(({ type, typeCheck, unwrap }) => code `if (${typeChe
512
570
  throw new Error("unable to serialize to string");
513
571
  })`;
514
572
  }
515
- get inlineValueSparqlConstructTriplesFunction() {
573
+ get valueSparqlConstructTriplesFunctionExpression() {
516
574
  return code `\
517
575
  ((({ ignoreRdfType, filter, schema, ...otherParameters }) => {
518
576
  let triples: ${this.reusables.imports.sparqljs}.Triple[] = [];
@@ -523,7 +581,7 @@ triples = triples.concat(${type.valueSparqlConstructTriplesFunction}({ ...otherP
523
581
  return triples;
524
582
  }) satisfies ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}>)`;
525
583
  }
526
- get inlineValueSparqlWherePatternsFunction() {
584
+ get valueSparqlWherePatternsFunctionExpression() {
527
585
  return code `\
528
586
  ((({ filter, schema, ...otherParameters }) => {
529
587
  const unionPatterns: ${this.reusables.imports.sparqljs}.GroupPattern[] = [];
@@ -534,114 +592,38 @@ unionPatterns.push({ patterns: ${type.valueSparqlWherePatternsFunction}({ ...oth
534
592
  return [{ patterns: unionPatterns, type: "union" }];
535
593
  }) satisfies ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}>)`;
536
594
  }
537
- get schemaInitializers() {
538
- return super.schemaInitializers.concat(code `members: { ${joinCode(this.members.map(({ discriminantValues, type, primaryDiscriminantValue }) => code `${literalOf(primaryDiscriminantValue)}: ${{
539
- discriminantValues: discriminantValues,
540
- type: type.schema,
541
- }}`), { on: "," })} }`);
542
- }
543
- get staticModuleDeclarations() {
544
- const alias = this.alias.unsafeCoerce();
545
- const staticModuleDeclarations = {};
546
- if (this.configuration.features.has("Object.equals")) {
547
- staticModuleDeclarations[`equals`] =
548
- code `export const equals = ${this.inlineEqualsFunction};`;
549
- }
550
- if (this.configuration.features.has("Object.filter")) {
551
- staticModuleDeclarations[`Filter`] =
552
- code `export type Filter = ${this.inlineFilterType};`;
553
- staticModuleDeclarations[`filter`] =
554
- code `export const filter = ${this.inlineFilterFunction};`;
555
- }
556
- if (this.configuration.features.has("Object.hash")) {
557
- staticModuleDeclarations[`hash`] =
558
- code `export const hash = ${this.inlineHashFunction};`;
559
- }
560
- if (this.configuration.features.has("Object.JSON.type")) {
561
- staticModuleDeclarations[`Json.type`] =
562
- code `${this.jsonTypeAliasDeclaration}`;
563
- }
564
- if (this.configuration.features.has("Object.JSON.schema")) {
565
- staticModuleDeclarations[`Json.namespace`] = code `\
566
- export namespace Json {
567
- ${this.jsonSchemaFunctionDeclaration}
568
-
569
- export function parse(json: unknown): ${this.reusables.imports.Either}<Error, Json> {
570
- const jsonSafeParseResult = schema().safeParse(json);
571
- if (!jsonSafeParseResult.success) { return ${this.reusables.imports.Left}(jsonSafeParseResult.error); }
572
- return ${this.reusables.imports.Right}(jsonSafeParseResult.data);
573
- }
574
- }`;
575
- }
576
- if (this.configuration.features.has("Object.fromJson")) {
577
- staticModuleDeclarations[`fromJson`] =
578
- code `export const fromJson = ${this.inlineFromJsonFunction};`;
579
- }
580
- if (this.configuration.features.has("Object.fromRdf")) {
581
- staticModuleDeclarations[`fromRdfResourceValues`] =
582
- code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${alias}> = ${this.inlineFromRdfResourceValuesFunction};`;
583
- }
584
- if (this.configuration.features.has("Object.toJson")) {
585
- staticModuleDeclarations[`toJson`] =
586
- code `export const toJson = ${this.inlineToJsonFunction};`;
587
- }
588
- if (this.configuration.features.has("Object.toRdf")) {
589
- staticModuleDeclarations[`toRdfResourceValues`] =
590
- code `export const toRdfResourceValues = ${this.inlineToRdfResourceValuesFunction};`;
591
- }
592
- if (this.configuration.features.has("Object.SPARQL")) {
593
- staticModuleDeclarations[`valueSparqlConstructTriples`] =
594
- code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
595
- staticModuleDeclarations[`valueSparqlWherePatterns`] =
596
- code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
597
- }
598
- if (this.configuration.features.has("Object.toString")) {
599
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
600
- staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
601
- code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
602
- }
603
- return staticModuleDeclarations;
604
- }
605
595
  fromJsonExpression({ variables, }) {
606
- return code `${this.alias.map((alias) => code `${alias}.fromJson`).orDefault(this.inlineFromJsonFunction)}(${variables.value})`;
607
- }
608
- fromRdfResourceValuesExpression({ variables, }) {
609
- const { resourceValues: resourceValuesVariable, ...fromRdfResourceValuesOptionsTemp } = variables;
610
- const fromRdfResourceValuesOptions = fromRdfResourceValuesOptionsTemp;
611
- if (!this.configuration.features.has("ObjectSet")) {
612
- delete fromRdfResourceValuesOptions["objectSet"];
613
- }
614
- 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})`;
615
597
  }
616
598
  graphqlResolveExpression({ variables, }) {
617
599
  return variables.value;
618
600
  }
619
601
  jsonSchema({ context, }) {
620
- const expression = this.alias
621
- .map((alias) => code `${alias}.Json.schema()`)
622
- .orDefault(this.inlineJsonSchema);
602
+ const expression = this.name
603
+ .map((name) => code `${name}.Json.schema()`)
604
+ .orDefault(this.jsonSchemaExpression);
623
605
  if (context === "property" && this.recursive) {
624
- return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.jsonType().name}> => ${expression})`;
606
+ return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.jsonType().expression}> => ${expression})`;
625
607
  }
626
608
  return expression;
627
609
  }
628
610
  jsonType() {
629
- return this.alias
630
- .map((alias) => new AbstractType.JsonType(`${alias}.Json`))
631
- .orDefault(this.inlineJsonType);
611
+ return this.name
612
+ .map((name) => new AbstractType.JsonType(code `${name}.Json`))
613
+ .orDefault(this.jsonTypeLiteral);
632
614
  }
633
615
  jsonUiSchemaElement() {
634
616
  return Maybe.empty();
635
617
  }
636
618
  toJsonExpression({ variables, }) {
637
- 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})`;
638
620
  }
639
621
  toRdfResourceValuesExpression({ variables, }) {
640
622
  const { value: valueVariable, ...otherVariables } = variables;
641
- 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})`;
642
624
  }
643
625
  toStringExpression({ variables, }) {
644
- 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})`;
645
627
  }
646
628
  lazyMembers;
647
629
  }
@@ -657,18 +639,27 @@ __decorate([
657
639
  __decorate([
658
640
  Memoize()
659
641
  ], UnionType.prototype, "equalsFunction", null);
642
+ __decorate([
643
+ Memoize()
644
+ ], UnionType.prototype, "expression", null);
660
645
  __decorate([
661
646
  Memoize()
662
647
  ], UnionType.prototype, "filterFunction", null);
663
648
  __decorate([
664
649
  Memoize()
665
650
  ], UnionType.prototype, "filterType", null);
651
+ __decorate([
652
+ Memoize()
653
+ ], UnionType.prototype, "fromRdfResourceValuesFunction", null);
666
654
  __decorate([
667
655
  Memoize()
668
656
  ], UnionType.prototype, "graphqlType", null);
669
657
  __decorate([
670
658
  Memoize()
671
659
  ], UnionType.prototype, "hashFunction", null);
660
+ __decorate([
661
+ Memoize()
662
+ ], UnionType.prototype, "jsTypes", null);
672
663
  __decorate([
673
664
  Memoize()
674
665
  ], UnionType.prototype, "members", null);
@@ -677,13 +668,13 @@ __decorate([
677
668
  ], UnionType.prototype, "mutable", null);
678
669
  __decorate([
679
670
  Memoize()
680
- ], UnionType.prototype, "expression", null);
671
+ ], UnionType.prototype, "schema", null);
681
672
  __decorate([
682
673
  Memoize()
683
- ], UnionType.prototype, "toRdfResourceValueTypes", null);
674
+ ], UnionType.prototype, "schemaType", null);
684
675
  __decorate([
685
676
  Memoize()
686
- ], UnionType.prototype, "typeofs", null);
677
+ ], UnionType.prototype, "toRdfResourceValueTypes", null);
687
678
  __decorate([
688
679
  Memoize()
689
680
  ], UnionType.prototype, "valueSparqlConstructTriplesFunction", null);
@@ -692,25 +683,28 @@ __decorate([
692
683
  ], UnionType.prototype, "valueSparqlWherePatternsFunction", null);
693
684
  __decorate([
694
685
  Memoize()
695
- ], UnionType.prototype, "inlineEqualsFunction", null);
686
+ ], UnionType.prototype, "schemaTypeExpression", null);
696
687
  __decorate([
697
688
  Memoize()
698
- ], UnionType.prototype, "inlineFilterFunction", null);
689
+ ], UnionType.prototype, "equalsFunctionExpression", null);
699
690
  __decorate([
700
691
  Memoize()
701
- ], UnionType.prototype, "inlineFilterType", null);
692
+ ], UnionType.prototype, "filterFunctionExpression", null);
702
693
  __decorate([
703
694
  Memoize()
704
- ], UnionType.prototype, "inlineJsonType", null);
695
+ ], UnionType.prototype, "filterTypeLiteral", null);
705
696
  __decorate([
706
697
  Memoize()
707
698
  ], UnionType.prototype, "inlineExpression", null);
708
699
  __decorate([
709
700
  Memoize()
710
- ], UnionType.prototype, "inlineValueSparqlConstructTriplesFunction", null);
701
+ ], UnionType.prototype, "jsonTypeLiteral", null);
711
702
  __decorate([
712
703
  Memoize()
713
- ], UnionType.prototype, "inlineValueSparqlWherePatternsFunction", null);
704
+ ], UnionType.prototype, "valueSparqlConstructTriplesFunctionExpression", null);
705
+ __decorate([
706
+ Memoize()
707
+ ], UnionType.prototype, "valueSparqlWherePatternsFunctionExpression", null);
714
708
  __decorate([
715
709
  Memoize()
716
710
  ], UnionType.prototype, "jsonType", null);
@@ -743,7 +737,7 @@ export var Discriminant;
743
737
  // intrinsic
744
738
  {
745
739
  let inlineDiscriminantProperty;
746
- const memberValues = [];
740
+ let memberValues = [];
747
741
  for (const memberType of memberTypes) {
748
742
  const memberTypeDiscriminantProperty = memberType.discriminantProperty.extract();
749
743
  if (!memberTypeDiscriminantProperty) {
@@ -758,10 +752,7 @@ export var Discriminant;
758
752
  inlineDiscriminantProperty = undefined;
759
753
  break;
760
754
  }
761
- memberValues.push({
762
- descendantValues: memberTypeDiscriminantProperty.descendantValues,
763
- ownValues: memberTypeDiscriminantProperty.ownValues,
764
- });
755
+ memberValues = memberValues.concat(memberTypeDiscriminantProperty.values);
765
756
  }
766
757
  if (inlineDiscriminantProperty) {
767
758
  return {
@@ -774,15 +765,17 @@ export var Discriminant;
774
765
  }
775
766
  // typeof
776
767
  {
768
+ const memberTypeofs = [];
777
769
  const memberTypeofsSet = new Set();
778
770
  for (const memberType of memberTypes) {
779
- for (const memberTypeof of memberType.typeofs) {
780
- memberTypeofsSet.add(memberTypeof);
771
+ for (const memberJsType of memberType.jsTypes) {
772
+ memberTypeofs.push(memberJsType.typeof);
773
+ memberTypeofsSet.add(memberJsType.typeof);
781
774
  }
782
775
  }
783
776
  if (memberTypeofsSet.size === memberTypes.length) {
784
777
  return {
785
- memberValues: memberTypes.flatMap((memberType) => memberType.typeofs),
778
+ memberValues: memberTypeofs,
786
779
  kind: "Typeof",
787
780
  };
788
781
  }
@@ -790,15 +783,15 @@ export var Discriminant;
790
783
  // hybrid
791
784
  // If some member type is an RDF/JS term then reuse "termType" as the discriminant.
792
785
  if (memberTypes.some((memberType) => termTypes(memberType).size > 0)) {
793
- const extrinsicMemberTypeNamesSet = new Set();
786
+ const extrinsicMemberTypeAliasesSet = new Set();
794
787
  let extrinsicMemberTypeCount = 0;
795
788
  for (const memberType of memberTypes) {
796
789
  if (termTypes(memberType).size > 0) {
797
790
  continue;
798
791
  }
799
792
  extrinsicMemberTypeCount++;
800
- if (memberType.alias.isJust()) {
801
- extrinsicMemberTypeNamesSet.add(memberType.alias.extract());
793
+ if (memberType.name.isJust()) {
794
+ extrinsicMemberTypeAliasesSet.add(memberType.name.extract());
802
795
  }
803
796
  else {
804
797
  break;
@@ -812,13 +805,13 @@ export var Discriminant;
812
805
  if (memberTermTypes.size > 0) {
813
806
  return {
814
807
  kind: "Intrinsic",
815
- ownValues: [...memberTermTypes],
808
+ values: [...memberTermTypes],
816
809
  };
817
810
  }
818
811
  return {
819
812
  kind: "Extrinsic",
820
- ownValues: extrinsicMemberTypeNamesSet.size === extrinsicMemberTypeCount
821
- ? [memberType.alias.unsafeCoerce()]
813
+ values: extrinsicMemberTypeAliasesSet.size === extrinsicMemberTypeCount
814
+ ? [memberType.name.unsafeCoerce()]
822
815
  : [memberTypeI.toString()],
823
816
  };
824
817
  }),
@@ -829,7 +822,7 @@ export var Discriminant;
829
822
  {
830
823
  let memberValues;
831
824
  {
832
- const memberTypeNames = memberTypes.map((memberType) => memberType.alias.orDefault(memberType.typeofs[0]));
825
+ const memberTypeNames = memberTypes.map((memberType) => memberType.name.orDefault(memberType.jsTypes[0].typeof));
833
826
  const memberTypeNamesSet = new Set(memberTypeNames);
834
827
  if (memberTypeNamesSet.size === memberTypeNames.length) {
835
828
  memberValues = memberTypeNames;