@shaclmate/compiler 4.0.39 → 4.0.41

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