@contember/binding 1.0.3 → 1.1.0-alpha.10

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 (493) hide show
  1. package/dist/development/accessorPropagation/EnvironmentContext.js +28 -2
  2. package/dist/development/accessorPropagation/EnvironmentContext.js.map +1 -1
  3. package/dist/development/accessorPropagation/useEntityListSubTree.js +4 -2
  4. package/dist/development/accessorPropagation/useEntityListSubTree.js.map +1 -1
  5. package/dist/development/accessorPropagation/useEntitySubTree.js +4 -2
  6. package/dist/development/accessorPropagation/useEntitySubTree.js.map +1 -1
  7. package/dist/development/accessorPropagation/useExtendTree.js +27 -0
  8. package/dist/development/accessorPropagation/useExtendTree.js.map +1 -0
  9. package/dist/development/accessorTree/AccessorTree.js +16 -14
  10. package/dist/development/accessorTree/AccessorTree.js.map +1 -1
  11. package/dist/development/accessorTree/AccessorTreeStateContext.js +4 -0
  12. package/dist/development/accessorTree/AccessorTreeStateContext.js.map +1 -0
  13. package/dist/development/accessorTree/NormalizedPersistedData.js.map +1 -1
  14. package/dist/development/accessorTree/RuntimeId.js +17 -4
  15. package/dist/development/accessorTree/RuntimeId.js.map +1 -1
  16. package/dist/development/accessorTree/accessorTreeStateReducer.js +11 -2
  17. package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
  18. package/dist/development/accessorTree/useAccessorTreeState.js +12 -0
  19. package/dist/development/accessorTree/useAccessorTreeState.js.map +1 -0
  20. package/dist/development/accessorTree/useDataBinding.js +41 -51
  21. package/dist/development/accessorTree/useDataBinding.js.map +1 -1
  22. package/dist/development/accessors/EntityAccessor.js +0 -32
  23. package/dist/development/accessors/EntityAccessor.js.map +1 -1
  24. package/dist/development/accessors/EntityListAccessor.js +1 -1
  25. package/dist/development/accessors/EntityListAccessor.js.map +1 -1
  26. package/dist/development/core/AccessorErrorManager.js +5 -2
  27. package/dist/development/core/AccessorErrorManager.js.map +1 -1
  28. package/dist/development/core/Config.js +1 -2
  29. package/dist/development/core/Config.js.map +1 -1
  30. package/dist/development/core/DataBinding.js +24 -53
  31. package/dist/development/core/DataBinding.js.map +1 -1
  32. package/dist/development/core/DirtinessTracker.js +4 -13
  33. package/dist/development/core/DirtinessTracker.js.map +1 -1
  34. package/dist/development/core/ErrorsPreprocessor.js +9 -13
  35. package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
  36. package/dist/development/core/EventManager.js +12 -7
  37. package/dist/development/core/EventManager.js.map +1 -1
  38. package/dist/development/core/IncrementalMarkerBuilder.js +1 -1
  39. package/dist/development/core/MarkerComparator.js +1 -1
  40. package/dist/development/core/MarkerMerger.js +3 -6
  41. package/dist/development/core/MarkerMerger.js.map +1 -1
  42. package/dist/development/core/MutationGenerator.js +180 -141
  43. package/dist/development/core/MutationGenerator.js.map +1 -1
  44. package/dist/development/core/RequestResponseNormalizer.js +93 -134
  45. package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
  46. package/dist/development/core/StateInitializer.js +30 -38
  47. package/dist/development/core/StateInitializer.js.map +1 -1
  48. package/dist/development/core/TreeAugmenter.js +14 -14
  49. package/dist/development/core/TreeAugmenter.js.map +1 -1
  50. package/dist/development/core/TreeFilterGenerator.js +2 -2
  51. package/dist/development/core/TreeFilterGenerator.js.map +1 -1
  52. package/dist/development/core/TreeStore.js +12 -23
  53. package/dist/development/core/TreeStore.js.map +1 -1
  54. package/dist/development/core/VariableInputTransformer.js +4 -1
  55. package/dist/development/core/VariableInputTransformer.js.map +1 -1
  56. package/dist/development/core/operations/EntityOperations.js +14 -13
  57. package/dist/development/core/operations/EntityOperations.js.map +1 -1
  58. package/dist/development/core/operations/FieldOperations.js +2 -2
  59. package/dist/development/core/operations/FieldOperations.js.map +1 -1
  60. package/dist/development/core/operations/ListOperations.js +3 -3
  61. package/dist/development/core/operations/ListOperations.js.map +1 -1
  62. package/dist/development/core/operations/OperationsHelpers.js +2 -2
  63. package/dist/development/core/operations/OperationsHelpers.js.map +1 -1
  64. package/dist/development/core/requestAliases/MutationAlias.js +4 -40
  65. package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
  66. package/dist/development/core/schema/Schema.js +29 -2
  67. package/dist/development/core/schema/Schema.js.map +1 -1
  68. package/dist/development/core/schema/SchemaLoader.js +12 -12
  69. package/dist/development/core/schema/SchemaLoader.js.map +1 -1
  70. package/dist/development/core/schema/SchemaPreprocessor.js +1 -1
  71. package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
  72. package/dist/development/coreComponents/Component.js +5 -2
  73. package/dist/development/coreComponents/Component.js.map +1 -1
  74. package/dist/development/coreComponents/DataBindingProvider.js +0 -1
  75. package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
  76. package/dist/development/coreComponents/EntityListSubTree.js +4 -12
  77. package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
  78. package/dist/development/coreComponents/EntitySubTree.js +4 -22
  79. package/dist/development/coreComponents/EntitySubTree.js.map +1 -1
  80. package/dist/development/coreComponents/Field.js +5 -1
  81. package/dist/development/coreComponents/Field.js.map +1 -1
  82. package/dist/development/coreComponents/HasMany.js +3 -5
  83. package/dist/development/coreComponents/HasMany.js.map +1 -1
  84. package/dist/development/coreComponents/HasOne.js +4 -6
  85. package/dist/development/coreComponents/HasOne.js.map +1 -1
  86. package/dist/development/dao/Environment.js +175 -90
  87. package/dist/development/dao/Environment.js.map +1 -1
  88. package/dist/development/dao/TreeNodeEnvironmentFactory.js +153 -0
  89. package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -0
  90. package/dist/development/helperComponents/DeferredSubTrees.js +16 -8
  91. package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
  92. package/dist/development/helperComponents/If.js +39 -0
  93. package/dist/development/helperComponents/If.js.map +1 -0
  94. package/dist/development/helperComponents/SugaredField.js +1 -1
  95. package/dist/development/helperComponents/helpers/FilterEvaluator.js +35 -0
  96. package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  97. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js +38 -0
  98. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  99. package/dist/development/helperComponents/helpers/evaluateCondition.js +46 -0
  100. package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -0
  101. package/dist/development/index.js +7 -2
  102. package/dist/development/index.js.map +1 -1
  103. package/dist/development/markers/EntityListSubTreeMarker.js +1 -1
  104. package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
  105. package/dist/development/markers/EntitySubTreeMarker.js +1 -1
  106. package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
  107. package/dist/development/markers/PlaceholderGenerator.js +4 -4
  108. package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
  109. package/dist/development/queryLanguage/MarkerFactory.js +6 -5
  110. package/dist/development/queryLanguage/MarkerFactory.js.map +1 -1
  111. package/dist/development/queryLanguage/Parser.js +18 -6
  112. package/dist/development/queryLanguage/Parser.js.map +1 -1
  113. package/dist/development/queryLanguage/QueryLanguage.js +1 -1
  114. package/dist/development/utils/Hashing.js +21 -6
  115. package/dist/development/utils/Hashing.js.map +1 -1
  116. package/dist/production/accessorPropagation/EnvironmentContext.js +28 -2
  117. package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
  118. package/dist/production/accessorPropagation/useEntityListSubTree.js +4 -2
  119. package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
  120. package/dist/production/accessorPropagation/useEntitySubTree.js +4 -2
  121. package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
  122. package/dist/production/accessorPropagation/useExtendTree.js +27 -0
  123. package/dist/production/accessorPropagation/useExtendTree.js.map +1 -0
  124. package/dist/production/accessorTree/AccessorTree.js +16 -14
  125. package/dist/production/accessorTree/AccessorTree.js.map +1 -1
  126. package/dist/production/accessorTree/AccessorTreeStateContext.js +4 -0
  127. package/dist/production/accessorTree/AccessorTreeStateContext.js.map +1 -0
  128. package/dist/production/accessorTree/NormalizedPersistedData.js.map +1 -1
  129. package/dist/production/accessorTree/RuntimeId.js +17 -4
  130. package/dist/production/accessorTree/RuntimeId.js.map +1 -1
  131. package/dist/production/accessorTree/accessorTreeStateReducer.js +11 -2
  132. package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
  133. package/dist/production/accessorTree/useAccessorTreeState.js +12 -0
  134. package/dist/production/accessorTree/useAccessorTreeState.js.map +1 -0
  135. package/dist/production/accessorTree/useDataBinding.js +41 -51
  136. package/dist/production/accessorTree/useDataBinding.js.map +1 -1
  137. package/dist/production/accessors/EntityAccessor.js +0 -32
  138. package/dist/production/accessors/EntityAccessor.js.map +1 -1
  139. package/dist/production/accessors/EntityListAccessor.js +1 -1
  140. package/dist/production/accessors/EntityListAccessor.js.map +1 -1
  141. package/dist/production/core/AccessorErrorManager.js +5 -2
  142. package/dist/production/core/AccessorErrorManager.js.map +1 -1
  143. package/dist/production/core/Config.js +1 -2
  144. package/dist/production/core/Config.js.map +1 -1
  145. package/dist/production/core/DataBinding.js +24 -44
  146. package/dist/production/core/DataBinding.js.map +1 -1
  147. package/dist/production/core/DirtinessTracker.js +4 -13
  148. package/dist/production/core/DirtinessTracker.js.map +1 -1
  149. package/dist/production/core/ErrorsPreprocessor.js +9 -13
  150. package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
  151. package/dist/production/core/EventManager.js +11 -6
  152. package/dist/production/core/EventManager.js.map +1 -1
  153. package/dist/production/core/IncrementalMarkerBuilder.js +1 -1
  154. package/dist/production/core/MarkerComparator.js +1 -1
  155. package/dist/production/core/MarkerMerger.js +3 -6
  156. package/dist/production/core/MarkerMerger.js.map +1 -1
  157. package/dist/production/core/MutationGenerator.js +180 -141
  158. package/dist/production/core/MutationGenerator.js.map +1 -1
  159. package/dist/production/core/RequestResponseNormalizer.js +93 -134
  160. package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
  161. package/dist/production/core/StateInitializer.js +30 -38
  162. package/dist/production/core/StateInitializer.js.map +1 -1
  163. package/dist/production/core/TreeAugmenter.js +14 -14
  164. package/dist/production/core/TreeAugmenter.js.map +1 -1
  165. package/dist/production/core/TreeFilterGenerator.js +2 -2
  166. package/dist/production/core/TreeFilterGenerator.js.map +1 -1
  167. package/dist/production/core/TreeStore.js +12 -23
  168. package/dist/production/core/TreeStore.js.map +1 -1
  169. package/dist/production/core/VariableInputTransformer.js +4 -1
  170. package/dist/production/core/VariableInputTransformer.js.map +1 -1
  171. package/dist/production/core/operations/EntityOperations.js +14 -13
  172. package/dist/production/core/operations/EntityOperations.js.map +1 -1
  173. package/dist/production/core/operations/FieldOperations.js.map +1 -1
  174. package/dist/production/core/operations/ListOperations.js +3 -3
  175. package/dist/production/core/operations/ListOperations.js.map +1 -1
  176. package/dist/production/core/operations/OperationsHelpers.js +2 -2
  177. package/dist/production/core/operations/OperationsHelpers.js.map +1 -1
  178. package/dist/production/core/requestAliases/MutationAlias.js +4 -33
  179. package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
  180. package/dist/production/core/schema/Schema.js +29 -2
  181. package/dist/production/core/schema/Schema.js.map +1 -1
  182. package/dist/production/core/schema/SchemaLoader.js +12 -12
  183. package/dist/production/core/schema/SchemaLoader.js.map +1 -1
  184. package/dist/production/core/schema/SchemaPreprocessor.js +1 -1
  185. package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
  186. package/dist/production/coreComponents/Component.js +5 -2
  187. package/dist/production/coreComponents/Component.js.map +1 -1
  188. package/dist/production/coreComponents/DataBindingProvider.js +0 -1
  189. package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
  190. package/dist/production/coreComponents/EntityListSubTree.js +4 -12
  191. package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
  192. package/dist/production/coreComponents/EntitySubTree.js +4 -22
  193. package/dist/production/coreComponents/EntitySubTree.js.map +1 -1
  194. package/dist/production/coreComponents/Field.js +5 -1
  195. package/dist/production/coreComponents/Field.js.map +1 -1
  196. package/dist/production/coreComponents/HasMany.js +3 -5
  197. package/dist/production/coreComponents/HasMany.js.map +1 -1
  198. package/dist/production/coreComponents/HasOne.js +4 -6
  199. package/dist/production/coreComponents/HasOne.js.map +1 -1
  200. package/dist/production/dao/Environment.js +175 -90
  201. package/dist/production/dao/Environment.js.map +1 -1
  202. package/dist/production/dao/TreeNodeEnvironmentFactory.js +153 -0
  203. package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -0
  204. package/dist/production/helperComponents/DeferredSubTrees.js +16 -8
  205. package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
  206. package/dist/production/helperComponents/If.js +39 -0
  207. package/dist/production/helperComponents/If.js.map +1 -0
  208. package/dist/production/helperComponents/SugaredField.js +1 -1
  209. package/dist/production/helperComponents/helpers/FilterEvaluator.js +35 -0
  210. package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  211. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js +38 -0
  212. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  213. package/dist/production/helperComponents/helpers/evaluateCondition.js +46 -0
  214. package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -0
  215. package/dist/production/index.js +7 -2
  216. package/dist/production/index.js.map +1 -1
  217. package/dist/production/markers/EntityListSubTreeMarker.js +1 -1
  218. package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
  219. package/dist/production/markers/EntitySubTreeMarker.js +1 -1
  220. package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
  221. package/dist/production/markers/PlaceholderGenerator.js +4 -4
  222. package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
  223. package/dist/production/queryLanguage/MarkerFactory.js +6 -5
  224. package/dist/production/queryLanguage/MarkerFactory.js.map +1 -1
  225. package/dist/production/queryLanguage/Parser.js +15 -6
  226. package/dist/production/queryLanguage/Parser.js.map +1 -1
  227. package/dist/production/queryLanguage/QueryLanguage.js +1 -1
  228. package/dist/production/utils/Hashing.js +21 -6
  229. package/dist/production/utils/Hashing.js.map +1 -1
  230. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
  231. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
  232. package/dist/types/accessorPropagation/EntityKeyContext.d.ts +1 -1
  233. package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
  234. package/dist/types/accessorPropagation/EnvironmentContext.d.ts +13 -2
  235. package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
  236. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
  237. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
  238. package/dist/types/accessorPropagation/index.d.ts +1 -0
  239. package/dist/types/accessorPropagation/index.d.ts.map +1 -1
  240. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts +2 -1
  241. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -1
  242. package/dist/types/accessorPropagation/useEntitySubTree.d.ts +2 -1
  243. package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
  244. package/dist/types/accessorPropagation/useExtendTree.d.ts +5 -0
  245. package/dist/types/accessorPropagation/useExtendTree.d.ts.map +1 -0
  246. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
  247. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
  248. package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
  249. package/dist/types/accessorTree/AccessorTreeState.d.ts +8 -0
  250. package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
  251. package/dist/types/accessorTree/AccessorTreeStateAction.d.ts +6 -0
  252. package/dist/types/accessorTree/AccessorTreeStateAction.d.ts.map +1 -1
  253. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +4 -0
  254. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -0
  255. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -1
  256. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
  257. package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
  258. package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
  259. package/dist/types/accessorTree/MutationRequestResponse.d.ts +5 -1
  260. package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -1
  261. package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
  262. package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
  263. package/dist/types/accessorTree/NormalizedPersistedData.d.ts +5 -5
  264. package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
  265. package/dist/types/accessorTree/PersistResult.d.ts +2 -1
  266. package/dist/types/accessorTree/PersistResult.d.ts.map +1 -1
  267. package/dist/types/accessorTree/QueryRequestResponse.d.ts +11 -10
  268. package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
  269. package/dist/types/accessorTree/RuntimeId.d.ts +16 -6
  270. package/dist/types/accessorTree/RuntimeId.d.ts.map +1 -1
  271. package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +1 -1
  272. package/dist/types/accessorTree/index.d.ts +1 -0
  273. package/dist/types/accessorTree/index.d.ts.map +1 -1
  274. package/dist/types/accessorTree/useAccessorTreeState.d.ts +2 -0
  275. package/dist/types/accessorTree/useAccessorTreeState.d.ts.map +1 -0
  276. package/dist/types/accessorTree/useDataBinding.d.ts +1 -1
  277. package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
  278. package/dist/types/accessors/BindingConfig.d.ts +0 -1
  279. package/dist/types/accessors/BindingConfig.d.ts.map +1 -1
  280. package/dist/types/accessors/EntityAccessor.d.ts +1 -3
  281. package/dist/types/accessors/EntityAccessor.d.ts.map +1 -1
  282. package/dist/types/accessors/EntityListAccessor.d.ts +2 -2
  283. package/dist/types/accessors/EntityListAccessor.d.ts.map +1 -1
  284. package/dist/types/core/AccessorErrorManager.d.ts +2 -1
  285. package/dist/types/core/AccessorErrorManager.d.ts.map +1 -1
  286. package/dist/types/core/Config.d.ts.map +1 -1
  287. package/dist/types/core/DataBinding.d.ts +3 -4
  288. package/dist/types/core/DataBinding.d.ts.map +1 -1
  289. package/dist/types/core/DirtinessTracker.d.ts +2 -5
  290. package/dist/types/core/DirtinessTracker.d.ts.map +1 -1
  291. package/dist/types/core/ErrorsPreprocessor.d.ts +5 -3
  292. package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
  293. package/dist/types/core/EventManager.d.ts +1 -1
  294. package/dist/types/core/EventManager.d.ts.map +1 -1
  295. package/dist/types/core/MarkerMerger.d.ts.map +1 -1
  296. package/dist/types/core/MutationGenerator.d.ts +25 -1
  297. package/dist/types/core/MutationGenerator.d.ts.map +1 -1
  298. package/dist/types/core/RequestResponseNormalizer.d.ts +6 -7
  299. package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
  300. package/dist/types/core/StateInitializer.d.ts +1 -5
  301. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  302. package/dist/types/core/TreeAugmenter.d.ts +3 -2
  303. package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
  304. package/dist/types/core/TreeStore.d.ts +8 -8
  305. package/dist/types/core/TreeStore.d.ts.map +1 -1
  306. package/dist/types/core/VariableInputTransformer.d.ts +2 -2
  307. package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
  308. package/dist/types/core/index.d.ts +1 -0
  309. package/dist/types/core/index.d.ts.map +1 -1
  310. package/dist/types/core/operations/EntityOperations.d.ts.map +1 -1
  311. package/dist/types/core/operations/ListOperations.d.ts +2 -1
  312. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  313. package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -3
  314. package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -1
  315. package/dist/types/core/requestAliases/index.d.ts +0 -3
  316. package/dist/types/core/requestAliases/index.d.ts.map +1 -1
  317. package/dist/types/core/schema/RawSchemaEntity.d.ts +3 -2
  318. package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -1
  319. package/dist/types/core/schema/Schema.d.ts +14 -2
  320. package/dist/types/core/schema/Schema.d.ts.map +1 -1
  321. package/dist/types/core/schema/SchemaColumn.d.ts +1 -1
  322. package/dist/types/core/schema/SchemaColumn.d.ts.map +1 -1
  323. package/dist/types/core/schema/SchemaEntity.d.ts +1 -1
  324. package/dist/types/core/schema/SchemaEntity.d.ts.map +1 -1
  325. package/dist/types/core/schema/SchemaLoader.d.ts +2 -1
  326. package/dist/types/core/schema/SchemaLoader.d.ts.map +1 -1
  327. package/dist/types/core/schema/SchemaRelation.d.ts +1 -1
  328. package/dist/types/core/schema/SchemaRelation.d.ts.map +1 -1
  329. package/dist/types/core/schema/index.d.ts +0 -1
  330. package/dist/types/core/schema/index.d.ts.map +1 -1
  331. package/dist/types/core/state/FieldState.d.ts +2 -2
  332. package/dist/types/core/state/FieldState.d.ts.map +1 -1
  333. package/dist/types/coreComponents/Component.d.ts +9 -4
  334. package/dist/types/coreComponents/Component.d.ts.map +1 -1
  335. package/dist/types/coreComponents/DataBindingProvider.d.ts +0 -1
  336. package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
  337. package/dist/types/coreComponents/Entity.d.ts +1 -1
  338. package/dist/types/coreComponents/Entity.d.ts.map +1 -1
  339. package/dist/types/coreComponents/EntityListSubTree.d.ts +1 -1
  340. package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
  341. package/dist/types/coreComponents/EntitySubTree.d.ts +1 -1
  342. package/dist/types/coreComponents/EntitySubTree.d.ts.map +1 -1
  343. package/dist/types/coreComponents/Field.d.ts +1 -1
  344. package/dist/types/coreComponents/Field.d.ts.map +1 -1
  345. package/dist/types/coreComponents/HasMany.d.ts +1 -1
  346. package/dist/types/coreComponents/HasMany.d.ts.map +1 -1
  347. package/dist/types/coreComponents/HasOne.d.ts +1 -1
  348. package/dist/types/coreComponents/HasOne.d.ts.map +1 -1
  349. package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
  350. package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
  351. package/dist/types/dao/Environment.d.ts +89 -41
  352. package/dist/types/dao/Environment.d.ts.map +1 -1
  353. package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts +19 -0
  354. package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -0
  355. package/dist/types/entityEvents/useDerivedField.d.ts +2 -2
  356. package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
  357. package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
  358. package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
  359. package/dist/types/helperComponents/FieldView.d.ts +7 -7
  360. package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
  361. package/dist/types/helperComponents/If.d.ts +14 -0
  362. package/dist/types/helperComponents/If.d.ts.map +1 -0
  363. package/dist/types/helperComponents/StaticRender.d.ts +1 -1
  364. package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
  365. package/dist/types/helperComponents/SugaredField.d.ts +1 -1
  366. package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
  367. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts +9 -0
  368. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts.map +1 -0
  369. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts +10 -0
  370. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts.map +1 -0
  371. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +4 -0
  372. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -0
  373. package/dist/types/helperComponents/index.d.ts +1 -0
  374. package/dist/types/helperComponents/index.d.ts.map +1 -1
  375. package/dist/types/markers/FieldMarker.d.ts +3 -3
  376. package/dist/types/markers/FieldMarker.d.ts.map +1 -1
  377. package/dist/types/markers/PlaceholderGenerator.d.ts +3 -2
  378. package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -1
  379. package/dist/types/queryLanguage/MarkerFactory.d.ts.map +1 -1
  380. package/dist/types/queryLanguage/Parser.d.ts.map +1 -1
  381. package/dist/types/treeParameters/primitives/EntityId.d.ts +1 -1
  382. package/dist/types/treeParameters/primitives/EntityId.d.ts.map +1 -1
  383. package/dist/types/treeParameters/primitives/FieldValue.d.ts +2 -2
  384. package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -1
  385. package/dist/types/treeParameters/primitives/Json.d.ts +7 -0
  386. package/dist/types/treeParameters/primitives/Json.d.ts.map +1 -0
  387. package/dist/types/treeParameters/primitives/index.d.ts +1 -0
  388. package/dist/types/treeParameters/primitives/index.d.ts.map +1 -1
  389. package/dist/types/tsconfig.tsbuildinfo +1 -1
  390. package/dist/types/utils/Hashing.d.ts +3 -2
  391. package/dist/types/utils/Hashing.d.ts.map +1 -1
  392. package/package.json +11 -6
  393. package/src/accessorPropagation/EnvironmentContext.tsx +44 -0
  394. package/src/accessorPropagation/index.ts +1 -0
  395. package/src/accessorPropagation/useEntityListSubTree.ts +8 -1
  396. package/src/accessorPropagation/useEntitySubTree.ts +8 -1
  397. package/src/accessorPropagation/useExtendTree.ts +30 -0
  398. package/src/accessorTree/AccessorTree.tsx +18 -18
  399. package/src/accessorTree/AccessorTreeState.ts +12 -1
  400. package/src/accessorTree/AccessorTreeStateAction.ts +7 -1
  401. package/src/accessorTree/AccessorTreeStateContext.ts +4 -0
  402. package/src/accessorTree/AccessorTreeStateOptions.ts +0 -1
  403. package/src/accessorTree/MutationRequestResponse.ts +3 -1
  404. package/src/accessorTree/NormalizedPersistedData.ts +5 -5
  405. package/src/accessorTree/PersistResult.ts +2 -1
  406. package/src/accessorTree/QueryRequestResponse.ts +17 -14
  407. package/src/accessorTree/RuntimeId.ts +27 -6
  408. package/src/accessorTree/accessorTreeStateReducer.ts +10 -1
  409. package/src/accessorTree/index.ts +1 -0
  410. package/src/accessorTree/useAccessorTreeState.ts +11 -0
  411. package/src/accessorTree/useDataBinding.ts +41 -59
  412. package/src/accessors/BindingConfig.ts +0 -1
  413. package/src/accessors/EntityAccessor.ts +2 -51
  414. package/src/accessors/EntityListAccessor.ts +3 -3
  415. package/src/core/AccessorErrorManager.ts +6 -2
  416. package/src/core/Config.ts +0 -1
  417. package/src/core/DataBinding.ts +25 -65
  418. package/src/core/DirtinessTracker.ts +4 -16
  419. package/src/core/ErrorsPreprocessor.ts +16 -18
  420. package/src/core/EventManager.ts +14 -8
  421. package/src/core/MarkerMerger.ts +1 -4
  422. package/src/core/MutationGenerator.ts +249 -188
  423. package/src/core/RequestResponseNormalizer.ts +111 -163
  424. package/src/core/StateInitializer.ts +46 -58
  425. package/src/core/TreeAugmenter.ts +16 -15
  426. package/src/core/TreeFilterGenerator.ts +5 -5
  427. package/src/core/TreeStore.ts +23 -27
  428. package/src/core/VariableInputTransformer.ts +9 -6
  429. package/src/core/index.ts +1 -0
  430. package/src/core/operations/EntityOperations.ts +13 -14
  431. package/src/core/operations/FieldOperations.ts +2 -2
  432. package/src/core/operations/ListOperations.ts +6 -5
  433. package/src/core/operations/OperationsHelpers.ts +2 -2
  434. package/src/core/requestAliases/MutationAlias.ts +4 -57
  435. package/src/core/requestAliases/index.ts +0 -3
  436. package/src/core/schema/RawSchemaEntity.ts +1 -2
  437. package/src/core/schema/Schema.ts +42 -3
  438. package/src/core/schema/SchemaColumn.ts +1 -1
  439. package/src/core/schema/SchemaEntity.ts +1 -1
  440. package/src/core/schema/SchemaLoader.ts +13 -11
  441. package/src/core/schema/SchemaPreprocessor.ts +1 -1
  442. package/src/core/schema/SchemaRelation.ts +1 -1
  443. package/src/core/schema/index.ts +0 -1
  444. package/src/core/state/FieldState.ts +2 -2
  445. package/src/coreComponents/Component.tsx +20 -7
  446. package/src/coreComponents/DataBindingProvider.tsx +0 -2
  447. package/src/coreComponents/EntityListSubTree.tsx +5 -16
  448. package/src/coreComponents/EntitySubTree.tsx +17 -32
  449. package/src/coreComponents/Field.tsx +4 -0
  450. package/src/coreComponents/HasMany.tsx +4 -6
  451. package/src/coreComponents/HasOne.tsx +6 -7
  452. package/src/dao/Environment.ts +260 -124
  453. package/src/dao/TreeNodeEnvironmentFactory.ts +224 -0
  454. package/src/helperComponents/DeferredSubTrees.tsx +20 -13
  455. package/src/helperComponents/If.tsx +71 -0
  456. package/src/helperComponents/helpers/FilterEvaluator.ts +46 -0
  457. package/src/helperComponents/helpers/FilterFieldsCollector.ts +46 -0
  458. package/src/helperComponents/helpers/evaluateCondition.ts +52 -0
  459. package/src/helperComponents/index.ts +1 -0
  460. package/src/markers/EntityListSubTreeMarker.ts +1 -1
  461. package/src/markers/EntitySubTreeMarker.ts +1 -1
  462. package/src/markers/PlaceholderGenerator.ts +5 -2
  463. package/src/queryLanguage/MarkerFactory.ts +5 -3
  464. package/src/queryLanguage/Parser.ts +24 -11
  465. package/src/treeParameters/primitives/EntityId.ts +1 -1
  466. package/src/treeParameters/primitives/FieldValue.ts +2 -2
  467. package/src/treeParameters/primitives/Json.ts +7 -0
  468. package/src/treeParameters/primitives/index.ts +1 -0
  469. package/src/typings/react-fix.d.ts +12 -0
  470. package/src/utils/Hashing.ts +23 -8
  471. package/dist/development/core/requestAliases/mutationOperationSubTreeType.js +0 -6
  472. package/dist/development/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
  473. package/dist/development/core/requestAliases/mutationOperationType.js +0 -7
  474. package/dist/development/core/requestAliases/mutationOperationType.js.map +0 -1
  475. package/dist/development/core/schema/SchemaValidator.js +0 -116
  476. package/dist/development/core/schema/SchemaValidator.js.map +0 -1
  477. package/dist/production/core/requestAliases/mutationOperationSubTreeType.js +0 -6
  478. package/dist/production/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
  479. package/dist/production/core/requestAliases/mutationOperationType.js +0 -7
  480. package/dist/production/core/requestAliases/mutationOperationType.js.map +0 -1
  481. package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts +0 -11
  482. package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts.map +0 -1
  483. package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts +0 -5
  484. package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts.map +0 -1
  485. package/dist/types/core/requestAliases/mutationOperationType.d.ts +0 -6
  486. package/dist/types/core/requestAliases/mutationOperationType.d.ts.map +0 -1
  487. package/dist/types/core/schema/SchemaValidator.d.ts +0 -14
  488. package/dist/types/core/schema/SchemaValidator.d.ts.map +0 -1
  489. package/src/accessorPropagation/EnvironmentContext.ts +0 -5
  490. package/src/core/requestAliases/TopLevelMutationOperation.ts +0 -11
  491. package/src/core/requestAliases/mutationOperationSubTreeType.ts +0 -4
  492. package/src/core/requestAliases/mutationOperationType.ts +0 -5
  493. package/src/core/schema/SchemaValidator.ts +0 -238
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListSubTree.js","sources":["../../../src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { whereToFilter } from '@contember/client'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.DeltaFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n\t(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst newEnvironment =\n\t\t\t\tprops.variables === undefined\n\t\t\t\t\t? oldEnvironment\n\t\t\t\t\t: oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\n\t\t\tif (newEnvironment.hasName('rootWhere') || newEnvironment.hasName('rootWhereAsFilter')) {\n\t\t\t\treturn newEnvironment\n\t\t\t}\n\n\t\t\tconst rootWhere = { id: NIL_UUID } as const\n\t\t\treturn newEnvironment.putDelta({\n\t\t\t\trootWhere,\n\t\t\t\trootWhereAsFilter: whereToFilter(rootWhere),\n\t\t\t})\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;AAiCa,MAAA,oBAAoB,UAChC,CAAyB,UAA0D;AACxD,4BAAA,MAAM,YAAY,6CAA6C;AAEzF,QAAM,aAAa;AACb,QAAA,aAAa,+BAA+B,KAAK;AACvD,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,MAAM,UAAU,GAC7C,CAAC,YAAY,YAAY,MAAM,UAAU,CAC1C;AACM,QAAA,WAAW,8BAA8B,WAAW;AAQ1D,SAAQA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO;AAAA,EAAA,CAAoB;AACnD,GACA;AAAA,EACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,QAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,aAAO,cAAc,2CAA2C,OAAO,QAAQ,WAAW;AAAA,IAC3F;AACA,WAAO,cAAc,8BAA8B,OAAO,QAAQ,WAAW;AAAA,EAC9E;AAAA,EACA,cAAc,WACZA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO,UAAU;AAAA,EAAA,GAC/BA,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,EAAA,CAAkB,GAC/B,MAAM,QACR;AAAA,EAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,UAAM,iBACL,MAAM,cAAc,SACjB,iBACA,eAAe,SAAS,YAAY,cAAc,gBAAgB,MAAM,SAAS,CAAC;AAEtF,QAAI,eAAe,QAAQ,WAAW,KAAK,eAAe,QAAQ,mBAAmB,GAAG;AAChF,aAAA;AAAA,IACR;AAEM,UAAA,YAAY,EAAE,IAAI;AACxB,WAAO,eAAe,SAAS;AAAA,MAC9B;AAAA,MACA,mBAAmB,cAAc,SAAS;AAAA,IAAA,CAC1C;AAAA,EACF;AACD,GACA,mBACD;;"}
1
+ {"version":3,"file":"EntityListSubTree.js","sources":["../../../src/coreComponents/EntityListSubTree.tsx"],"sourcesContent":["import { whereToFilter } from '@contember/client'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { ComponentType, ReactElement, ReactNode, useCallback } from 'react'\nimport {\n\tuseAccessorUpdateSubscription,\n\tuseEntityListSubTreeParameters,\n\tuseGetEntityListSubTree,\n} from '../accessorPropagation'\nimport { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory, QueryLanguage } from '../queryLanguage'\nimport type { SugaredQualifiedEntityList, SugaredUnconstrainedQualifiedEntityList, TreeRootId } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntityListSubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntityListSubTreeProps<ListProps, EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntityListSubTreeAdditionalProps &\n\t(SugaredQualifiedEntityList | SugaredUnconstrainedQualifiedEntityList) &\n\t(\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const EntityListSubTree = Component(\n\t<ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntityListSubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntityListSubTree()\n\t\tconst parameters = useEntityListSubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ?\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne\n\t\t// ) :\n\t\t// \tprops.children\n\t\t// )\n\t\treturn <EntityList {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntityListSubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntityListSubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={0 as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityListSubtree(environment, props)\n\t\t},\n\t},\n\t'EntityListSubTree',\n) as <ListProps, EntityProps>(props: EntityListSubTreeProps<ListProps, EntityProps>) => ReactElement\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;AAkCa,MAAA,oBAAoB,UAChC,CAAyB,UAA0D;AACxD,4BAAA,MAAM,YAAY,6CAA6C;AAEzF,QAAM,aAAa;AACb,QAAA,aAAa,+BAA+B,KAAK;AACvD,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,MAAM,UAAU,GAC7C,CAAC,YAAY,YAAY,MAAM,UAAU,CAC1C;AACM,QAAA,WAAW,8BAA8B,WAAW;AAQ1D,SAAQA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO;AAAA,EAAA,CAAoB;AACnD,GACA;AAAA,EACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,QAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,aAAO,cAAc,2CAA2C,OAAO,QAAQ,WAAW;AAAA,IAC3F;AACA,WAAO,cAAc,8BAA8B,OAAO,QAAQ,WAAW;AAAA,EAC9E;AAAA,EACA,cAAc,WACZA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO,UAAU;AAAA,EAAA,GAC/BA,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,EAAA,CAAkB,GAC/B,MAAM,QACR;AAAA,EAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,UAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,WAAA,2BAA2B,sCAAsC,aAAa,KAAK;AAAA,EAC3F;AACD,GACA,mBACD;;"}
@@ -1,16 +1,14 @@
1
1
  import { createElement, Fragment, useCallback } from "react";
2
- import { whereToFilter } from "@contember/client";
3
2
  import { useConstantValueInvariant } from "@contember/react-utils";
4
- import { PRIMARY_KEY_NAME, NIL_UUID } from "../bindingTypes.js";
3
+ import { PRIMARY_KEY_NAME } from "../bindingTypes.js";
5
4
  import { Component } from "./Component.js";
6
5
  import { Entity } from "./Entity.js";
7
6
  import { Field } from "./Field.js";
7
+ import { TreeNodeEnvironmentFactory } from "../dao/TreeNodeEnvironmentFactory.js";
8
8
  import { SetOrderFieldOnCreate } from "../accessorSorting/SetOrderFieldOnCreate.js";
9
9
  import { useGetEntitySubTree } from "../accessorPropagation/useGetEntitySubTree.js";
10
10
  import { useEntitySubTreeParameters } from "../accessorPropagation/useEntitySubTreeParameters.js";
11
11
  import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
12
- import { Environment } from "../dao/Environment.js";
13
- import { QueryLanguage } from "../queryLanguage/QueryLanguage.js";
14
12
  import { useAccessorUpdateSubscription } from "../accessorPropagation/useAccessorUpdateSubscription.js";
15
13
  const EntitySubTree = Component((props) => {
16
14
  useConstantValueInvariant(props.isCreating, "EntitySubTree: cannot update isCreating");
@@ -40,24 +38,8 @@ const EntitySubTree = Component((props) => {
40
38
  entity: props.entity
41
39
  })),
42
40
  generateEnvironment: (props, oldEnvironment) => {
43
- const newEnvironment = props.variables === void 0 ? oldEnvironment : oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables));
44
- if (newEnvironment.hasName("rootWhere") || newEnvironment.hasName("rootWhereAsFilter")) {
45
- return newEnvironment;
46
- }
47
- if (props.isCreating) {
48
- const rootWhere = { id: NIL_UUID };
49
- return newEnvironment.putDelta({
50
- rootWhere,
51
- rootWhereAsFilter: whereToFilter(rootWhere),
52
- rootShouldExists: "no"
53
- });
54
- }
55
- const qualifiedSingleEntity = QueryLanguage.desugarQualifiedSingleEntity(props, newEnvironment, { missingSetOnCreate: "fill" });
56
- return newEnvironment.putDelta({
57
- rootWhere: qualifiedSingleEntity.where,
58
- rootWhereAsFilter: whereToFilter(qualifiedSingleEntity.where),
59
- rootShouldExists: qualifiedSingleEntity.setOnCreate ? "maybe" : "yes"
60
- });
41
+ const environment = oldEnvironment.withVariables(props.variables);
42
+ return TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props);
61
43
  }
62
44
  }, "EntitySubTree");
63
45
  export { EntitySubTree };
@@ -1 +1 @@
1
- {"version":3,"file":"EntitySubTree.js","sources":["../../../src/coreComponents/EntitySubTree.tsx"],"sourcesContent":["import { whereToFilter } from '@contember/client'\nimport { useConstantValueInvariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\nimport { NIL_UUID, PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory, QueryLanguage } from '../queryLanguage'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.DeltaFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> = {\n\ttreeRootId?: TreeRootId\n\tchildren?: ReactNode\n} & EntitySubTreeAdditionalProps &\n\t(SugaredQualifiedSingleEntity | (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps))\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst newEnvironment =\n\t\t\t\tprops.variables === undefined\n\t\t\t\t\t? oldEnvironment\n\t\t\t\t\t: oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\n\t\t\tif (newEnvironment.hasName('rootWhere') || newEnvironment.hasName('rootWhereAsFilter')) {\n\t\t\t\treturn newEnvironment\n\t\t\t}\n\n\t\t\tif (props.isCreating) {\n\t\t\t\tconst rootWhere = { id: NIL_UUID } as const\n\t\t\t\treturn newEnvironment.putDelta({\n\t\t\t\t\trootWhere,\n\t\t\t\t\trootWhereAsFilter: whereToFilter(rootWhere),\n\t\t\t\t\trootShouldExists: 'no',\n\t\t\t\t})\n\t\t\t}\n\t\t\tconst qualifiedSingleEntity = QueryLanguage.desugarQualifiedSingleEntity(props, newEnvironment, { missingSetOnCreate: 'fill' })\n\t\t\treturn newEnvironment.putDelta({\n\t\t\t\trootWhere: qualifiedSingleEntity.where,\n\t\t\t\trootWhereAsFilter: whereToFilter(qualifiedSingleEntity.where),\n\t\t\t\trootShouldExists: qualifiedSingleEntity.setOnCreate ? 'maybe' : 'yes',\n\t\t\t})\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["_jsx","_jsxFragment"],"mappings":";;;;;;;;;;;;;;AA4Ba,MAAA,gBAAgB,UAC5B,CAAyB,UAA2C;AACzC,4BAAA,MAAM,YAAY,yCAAyC;AAErF,QAAM,aAAa;AACb,QAAA,aAAa,2BAA2B,KAAK;AACnD,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,MAAM,UAAU,GAC7C,CAAC,YAAY,YAAY,MAAM,UAAU,CAC1C;AACM,QAAA,WAAW,8BAA8B,WAAW;AAQ1D,SAAQA,8BAAA,QAAA;AAAA,OAAW;AAAA,IAAO;AAAA,EAAA,CAAoB;AAC/C,GACA;AAAA,EACC,sBAAsB,CAAC,OA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Invariant } from '@contember/react-utils'\nimport { ReactElement, ReactNode, useCallback } from 'react'\nimport { useAccessorUpdateSubscription, useEntitySubTreeParameters, useGetEntitySubTree } from '../accessorPropagation'\nimport { SetOrderFieldOnCreate, SetOrderFieldOnCreateOwnProps } from '../accessorSorting'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type {\n\tSugaredQualifiedSingleEntity,\n\tSugaredUnconstrainedQualifiedSingleEntity,\n\tTreeRootId,\n} from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface EntitySubTreeAdditionalProps {\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport type EntitySubTreeAdditionalCreationProps = {} | SetOrderFieldOnCreateOwnProps\n\nexport type EntitySubTreeProps<EntityProps> =\n\t& {\n\t\ttreeRootId?: TreeRootId\n\t\tchildren?: ReactNode\n\t}\n\t& EntitySubTreeAdditionalProps\n\t& (\n\t\t| SugaredQualifiedSingleEntity\n\t\t| (SugaredUnconstrainedQualifiedSingleEntity & EntitySubTreeAdditionalCreationProps)\n\t)\n\nexport const EntitySubTree = Component(\n\t<EntityProps extends {}>(props: EntitySubTreeProps<EntityProps>) => {\n\t\tuseConstantValueInvariant(props.isCreating, 'EntitySubTree: cannot update isCreating')\n\n\t\tconst getSubTree = useGetEntitySubTree()\n\t\tconst parameters = useEntitySubTreeParameters(props)\n\t\tconst getAccessor = useCallback(\n\t\t\t() => getSubTree(parameters, props.treeRootId),\n\t\t\t[getSubTree, parameters, props.treeRootId],\n\t\t)\n\t\tconst accessor = useAccessorUpdateSubscription(getAccessor)\n\n\t\t// TODO revive top-level hasOneRelationPath\n\t\t// {parameters.value.hasOneRelationPath.length ? (\n\t\t// \t<HasOne field={parameters.value.hasOneRelationPath}>{props.children}</HasOne>\n\t\t// ) : (\n\t\t// \tprops.children\n\t\t// )}\n\t\treturn <Entity {...props} accessor={accessor} />\n\t},\n\t{\n\t\tgenerateBranchMarker: (props, fields, environment) => {\n\t\t\tif ('isCreating' in props && props.isCreating) {\n\t\t\t\treturn MarkerFactory.createUnconstrainedEntitySubTreeMarker(props, fields, environment)\n\t\t\t}\n\t\t\treturn MarkerFactory.createEntitySubTreeMarker(props, fields, environment)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<>\n\t\t\t\t<Entity {...props} accessor={0 as any}>\n\t\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t\t{props.children}\n\t\t\t\t</Entity>\n\t\t\t\t{props.isCreating && 'orderField' in props && (\n\t\t\t\t\t<SetOrderFieldOnCreate\n\t\t\t\t\t\torderField={props.orderField}\n\t\t\t\t\t\tnewOrderFieldValue={props.newOrderFieldValue}\n\t\t\t\t\t\tentity={props.entity}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</>\n\t\t),\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntitySubtree(environment, props)\n\t\t},\n\t},\n\t'EntitySubTree',\n) as <EntityProps>(pros: EntitySubTreeProps<EntityProps>) => ReactElement\n"],"names":["_jsx","_jsxFragment"],"mappings":";;;;;;;;;;;;AAkCa,MAAA,gBAAgB,UAC5B,CAAyB,UAA2C;AACzC,4BAAA,MAAM,YAAY,yCAAyC;AAErF,QAAM,aAAa;AACb,QAAA,aAAa,2BAA2B,KAAK;AACnD,QAAM,cAAc,YACnB,MAAM,WAAW,YAAY,MAAM,UAAU,GAC7C,CAAC,YAAY,YAAY,MAAM,UAAU,CAC1C;AACM,QAAA,WAAW,8BAA8B,WAAW;AAQ1D,SAAQA,8BAAA,QAAA;AAAA,OAAW;AAAA,IAAO;AAAA,EAAA,CAAoB;AAC/C,GACA;AAAA,EACC,sBAAsB,CAAC,OAAO,QAAQ,gBAAgB;AACjD,QAAA,gBAAgB,SAAS,MAAM,YAAY;AAC9C,aAAO,cAAc,uCAAuC,OAAO,QAAQ,WAAW;AAAA,IACvF;AACA,WAAO,cAAc,0BAA0B,OAAO,QAAQ,WAAW;AAAA,EAC1E;AAAA,EACA,cAAc,CACb,UAAAA,8BAAAC,UAAA,MACED,8BAAA,QAAA;AAAA,OAAW;AAAA,IAAO,UAAU;AAAA,EAAA,GAC3BA,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,EAAA,CAAkB,GAC/B,MAAM,QACR,GACC,MAAM,cAAc,gBAAgB,SACnCA,8BAAA,uBAAA;AAAA,IACA,YAAY,MAAM;AAAA,IAClB,oBAAoB,MAAM;AAAA,IAC1B,QAAQ,MAAM;AAAA,EAAA,CACf,CAEF;AAAA,EAED,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,UAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,WAAA,2BAA2B,kCAAkC,aAAa,KAAK;AAAA,EACvF;AACD,GACA,eACD;;"}
@@ -1,6 +1,7 @@
1
1
  import { createElement, Fragment } from "react";
2
2
  import { GraphQlBuilder } from "@contember/client";
3
3
  import { Component } from "./Component.js";
4
+ import { TreeNodeEnvironmentFactory } from "../dao/TreeNodeEnvironmentFactory.js";
4
5
  import { useField } from "../accessorPropagation/useField.js";
5
6
  import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
6
7
  const Field = Component((props) => {
@@ -13,7 +14,10 @@ const Field = Component((props) => {
13
14
  }
14
15
  return /* @__PURE__ */ createElement(Fragment, null, field.value);
15
16
  }, {
16
- generateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment)
17
+ generateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),
18
+ generateEnvironment: (props, environment) => {
19
+ return TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props);
20
+ }
17
21
  }, "Field");
18
22
  export { Field };
19
23
  //# sourceMappingURL=Field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sources":["../../../src/coreComponents/Field.tsx"],"sourcesContent":["import { GraphQlBuilder } from '@contember/client'\nimport type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { FieldValue, SugaredRelativeSingleField } from '../treeParameters'\nimport { Component } from './Component'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\t\tFieldRuntimeProps<Persisted> {}\n\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value instanceof GraphQlBuilder.GraphQlLiteral ||\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":["_jsx","_jsxFragment"],"mappings":";;;;;AAiBa,MAAA,QAAQ,UACpB,CAA4C,UAAiC;AACtE,QAAA,QAAQ,SAAoB,KAAK;AAEnC,MAAA,MAAM,WAAW,QAAW;AAC/B,WAAUA,8BAAAC,UAAA,MAAA,MAAM,OAAO,MAAM,KAAK,CAAE;AAAA,EACrC;AAGC,MAAA,MAAM,iBAAiB,eAAe,kBACtC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,WAAA;AAAA,EACR;AACO,SAAAD,8BAAAC,UAAA,MAAG,MAAM,KAAM;AACvB,GACA;AAAA,EACC,oBAAoB,CAAC,OAAO,gBAAgB,cAAc,kBAAkB,OAAO,WAAW;AAC/F,GACA,OACD;;"}
1
+ {"version":3,"file":"Field.js","sources":["../../../src/coreComponents/Field.tsx"],"sourcesContent":["import { GraphQlBuilder } from '@contember/client'\nimport type { ReactElement, ReactNode } from 'react'\nimport { useField } from '../accessorPropagation'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { FieldValue, SugaredRelativeSingleField } from '../treeParameters'\nimport { Component } from './Component'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport interface FieldBasicProps extends SugaredRelativeSingleField {}\n\nexport interface FieldRuntimeProps<Persisted extends FieldValue = FieldValue> {\n\tformat?: (value: Persisted | null) => ReactNode\n}\n\nexport interface FieldProps<Persisted extends FieldValue = FieldValue>\n\textends FieldBasicProps,\n\t\tFieldRuntimeProps<Persisted> {}\n\nexport const Field = Component(\n\t<Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => {\n\t\tconst field = useField<Persisted>(props)\n\n\t\tif (props.format !== undefined) {\n\t\t\treturn <>{props.format(field.value)}</>\n\t\t}\n\n\t\tif (\n\t\t\tfield.value instanceof GraphQlBuilder.GraphQlLiteral ||\n\t\t\tfield.value === null ||\n\t\t\ttypeof field.value === 'boolean'\n\t\t) {\n\t\t\treturn null\n\t\t}\n\t\treturn <>{field.value}</>\n\t},\n\t{\n\t\tgenerateLeafMarker: (props, environment) => MarkerFactory.createFieldMarker(props, environment),\n\t\tgenerateEnvironment: (props, environment) => {\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForField(environment, props)\n\t\t},\n\t},\n\t'Field',\n) as <Persisted extends FieldValue = FieldValue>(props: FieldProps<Persisted>) => ReactElement\n"],"names":["_jsx","_jsxFragment"],"mappings":";;;;;;AAkBa,MAAA,QAAQ,UACpB,CAA4C,UAAiC;AACtE,QAAA,QAAQ,SAAoB,KAAK;AAEnC,MAAA,MAAM,WAAW,QAAW;AAC/B,WAAUA,8BAAAC,UAAA,MAAA,MAAM,OAAO,MAAM,KAAK,CAAE;AAAA,EACrC;AAGC,MAAA,MAAM,iBAAiB,eAAe,kBACtC,MAAM,UAAU,QAChB,OAAO,MAAM,UAAU,WACtB;AACM,WAAA;AAAA,EACR;AACO,SAAAD,8BAAAC,UAAA,MAAG,MAAM,KAAM;AACvB,GACA;AAAA,EACC,oBAAoB,CAAC,OAAO,gBAAgB,cAAc,kBAAkB,OAAO,WAAW;AAAA,EAC9F,qBAAqB,CAAC,OAAO,gBAAgB;AACrC,WAAA,2BAA2B,0BAA0B,aAAa,KAAK;AAAA,EAC/E;AACD,GACA,OACD;;"}
@@ -3,8 +3,8 @@ import { PRIMARY_KEY_NAME } from "../bindingTypes.js";
3
3
  import { Component } from "./Component.js";
4
4
  import { EntityList } from "./EntityList.js";
5
5
  import { Field } from "./Field.js";
6
+ import { TreeNodeEnvironmentFactory } from "../dao/TreeNodeEnvironmentFactory.js";
6
7
  import { useEntityList } from "../accessorPropagation/useEntityList.js";
7
- import { Environment } from "../dao/Environment.js";
8
8
  import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
9
9
  const HasMany = Component((props) => {
10
10
  const entityList = useEntityList(props);
@@ -14,10 +14,8 @@ const HasMany = Component((props) => {
14
14
  });
15
15
  }, {
16
16
  generateEnvironment: (props, oldEnvironment) => {
17
- if (props.variables === void 0) {
18
- return oldEnvironment;
19
- }
20
- return oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables));
17
+ const environment = oldEnvironment.withVariables(props.variables);
18
+ return TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props);
21
19
  },
22
20
  staticRender: (props) => /* @__PURE__ */ createElement(EntityList, {
23
21
  ...props,
@@ -1 +1 @@
1
- {"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport type { EntityBaseProps } from './Entity'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.DeltaFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tif (props.variables === undefined) {\n\t\t\t\treturn oldEnvironment\n\t\t\t}\n\t\t\treturn oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":["_jsx"],"mappings":";;;;;;;;AAsBa,MAAA,UAAU,UACtB,CAAyB,UAAgD;AAClE,QAAA,aAAa,cAAc,KAAK;AAEtC,SAAQA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO,UAAU;AAAA,EAAA,CAAY;AACrD,GACA;AAAA,EACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC3C,QAAA,MAAM,cAAc,QAAW;AAC3B,aAAA;AAAA,IACR;AACA,WAAO,eAAe,SAAS,YAAY,cAAc,gBAAgB,MAAM,SAAS,CAAC;AAAA,EAC1F;AAAA,EACA,cAAc,WACZA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO,UAAU;AAAA,EAAA,GAC/BA,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,EAAA,CAAkB,GAC/B,MAAM,QACR;AAAA,EAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,+BAA+B,OAAO,aAAa,MAAM;AACzE,GACA,SACD;;"}
1
+ {"version":3,"file":"HasMany.js","sources":["../../../src/coreComponents/HasMany.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntityList } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeEntityList } from '../treeParameters'\nimport { Component } from './Component'\nimport { EntityList, EntityListBaseProps } from './EntityList'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasManyProps<ListProps = never, EntityProps = never> = SugaredRelativeEntityList & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n} & (\n\t\t| {}\n\t\t| {\n\t\t\t\tlistComponent: ComponentType<ListProps & EntityListBaseProps>\n\t\t\t\tlistProps?: ListProps\n\t\t }\n\t)\n\nexport const HasMany = Component(\n\t<ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => {\n\t\tconst entityList = useEntityList(props)\n\n\t\treturn <EntityList {...props} accessor={entityList} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntityList(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<EntityList {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</EntityList>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeEntityListFields(props, environment, fields),\n\t},\n\t'HasMany',\n) as <ListProps, EntityProps>(props: HasManyProps<ListProps, EntityProps>) => ReactElement\n"],"names":["_jsx"],"mappings":";;;;;;;;AAsBa,MAAA,UAAU,UACtB,CAAyB,UAAgD;AAClE,QAAA,aAAa,cAAc,KAAK;AAEtC,SAAQA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO,UAAU;AAAA,EAAA,CAAY;AACrD,GACA;AAAA,EACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,UAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,WAAA,2BAA2B,+BAA+B,aAAa,KAAK;AAAA,EACpF;AAAA,EACA,cAAc,WACZA,8BAAA,YAAA;AAAA,OAAe;AAAA,IAAO,UAAU;AAAA,EAAA,GAC/BA,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,EAAA,CAAkB,GAC/B,MAAM,QACR;AAAA,EAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,+BAA+B,OAAO,aAAa,MAAM;AACzE,GACA,SACD;;"}
@@ -3,9 +3,9 @@ import { PRIMARY_KEY_NAME } from "../bindingTypes.js";
3
3
  import { Component } from "./Component.js";
4
4
  import { Entity } from "./Entity.js";
5
5
  import { Field } from "./Field.js";
6
- import { useEntity } from "../accessorPropagation/useEntity.js";
7
- import { Environment } from "../dao/Environment.js";
6
+ import { TreeNodeEnvironmentFactory } from "../dao/TreeNodeEnvironmentFactory.js";
8
7
  import { MarkerFactory } from "../queryLanguage/MarkerFactory.js";
8
+ import { useEntity } from "../accessorPropagation/useEntity.js";
9
9
  const HasOne = Component((props) => {
10
10
  const entity = useEntity(props);
11
11
  return /* @__PURE__ */ createElement(Entity, {
@@ -14,10 +14,8 @@ const HasOne = Component((props) => {
14
14
  });
15
15
  }, {
16
16
  generateEnvironment: (props, oldEnvironment) => {
17
- if (props.variables === void 0) {
18
- return oldEnvironment;
19
- }
20
- return oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables));
17
+ const environment = oldEnvironment.withVariables(props.variables);
18
+ return TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props);
21
19
  },
22
20
  staticRender: (props) => /* @__PURE__ */ createElement(Entity, {
23
21
  ...props,
@@ -1 +1 @@
1
- {"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ComponentType, ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity, EntityBaseProps } from './Entity'\nimport { Field } from './Field'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.DeltaFactory\n}\n\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tif (props.variables === undefined) {\n\t\t\t\treturn oldEnvironment\n\t\t\t}\n\t\t\treturn oldEnvironment.putDelta(Environment.generateDelta(oldEnvironment, props.variables))\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":["_jsx"],"mappings":";;;;;;;;AAea,MAAA,SAAS,UACrB,CAAyB,UAAoC;AACtD,QAAA,SAAS,UAAU,KAAK;AAE9B,SAAQA,8BAAA,QAAA;AAAA,OAAW;AAAA,IAAO,UAAU;AAAA,EAAA,CAAQ;AAC7C,GACA;AAAA,EACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC3C,QAAA,MAAM,cAAc,QAAW;AAC3B,aAAA;AAAA,IACR;AACA,WAAO,eAAe,SAAS,YAAY,cAAc,gBAAgB,MAAM,SAAS,CAAC;AAAA,EAC1F;AAAA,EACA,cAAc,WACZA,8BAAA,QAAA;AAAA,OAAW;AAAA,IAAO,UAAU;AAAA,EAAA,GAC3BA,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,EAAA,CAAkB,GAC/B,MAAM,QACR;AAAA,EAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,iCAAiC,OAAO,aAAa,MAAM;AAC3E,GACA,QACD;;"}
1
+ {"version":3,"file":"HasOne.js","sources":["../../../src/coreComponents/HasOne.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from 'react'\nimport { useEntity } from '../accessorPropagation'\nimport { PRIMARY_KEY_NAME } from '../bindingTypes'\nimport { Environment } from '../dao'\nimport { MarkerFactory } from '../queryLanguage'\nimport type { SugaredRelativeSingleEntity } from '../treeParameters'\nimport { Component } from './Component'\nimport { Entity } from './Entity'\nimport { Field } from './Field'\nimport { TreeNodeEnvironmentFactory } from '../dao/TreeNodeEnvironmentFactory'\n\nexport type HasOneProps<EntityProps = never> = SugaredRelativeSingleEntity & {\n\tchildren?: ReactNode\n\tvariables?: Environment.ValuesMapWithFactory\n}\n\nexport const HasOne = Component(\n\t<EntityProps extends {}>(props: HasOneProps<EntityProps>) => {\n\t\tconst entity = useEntity(props)\n\n\t\treturn <Entity {...props} accessor={entity} />\n\t},\n\t{\n\t\tgenerateEnvironment: (props, oldEnvironment) => {\n\t\t\tconst environment = oldEnvironment.withVariables(props.variables)\n\t\t\treturn TreeNodeEnvironmentFactory.createEnvironmentForEntity(environment, props)\n\t\t},\n\t\tstaticRender: props => (\n\t\t\t<Entity {...props} accessor={undefined as any}>\n\t\t\t\t<Field field={PRIMARY_KEY_NAME} />\n\t\t\t\t{props.children}\n\t\t\t</Entity>\n\t\t),\n\t\tgenerateBranchMarker: (props, fields, environment) =>\n\t\t\tMarkerFactory.createRelativeSingleEntityFields(props, environment, fields),\n\t},\n\t'HasOne',\n) as <EntityProps extends {}>(props: HasOneProps<EntityProps>) => ReactElement\n"],"names":["_jsx"],"mappings":";;;;;;;;AAgBa,MAAA,SAAS,UACrB,CAAyB,UAAoC;AACtD,QAAA,SAAS,UAAU,KAAK;AAE9B,SAAQA,8BAAA,QAAA;AAAA,OAAW;AAAA,IAAO,UAAU;AAAA,EAAA,CAAQ;AAC7C,GACA;AAAA,EACC,qBAAqB,CAAC,OAAO,mBAAmB;AAC/C,UAAM,cAAc,eAAe,cAAc,MAAM,SAAS;AACzD,WAAA,2BAA2B,2BAA2B,aAAa,KAAK;AAAA,EAChF;AAAA,EACA,cAAc,WACZA,8BAAA,QAAA;AAAA,OAAW;AAAA,IAAO,UAAU;AAAA,EAAA,GAC3BA,8BAAA,OAAA;AAAA,IAAM,OAAO;AAAA,EAAA,CAAkB,GAC/B,MAAM,QACR;AAAA,EAED,sBAAsB,CAAC,OAAO,QAAQ,gBACrC,cAAc,iCAAiC,OAAO,aAAa,MAAM;AAC3E,GACA,QACD;;"}
@@ -1,122 +1,207 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
1
+ import { BindingError } from "../BindingError.js";
2
+ import equal from "fast-deep-equal/es6";
7
3
  class Environment {
8
- constructor(names = Environment.defaultNameStore) {
9
- __publicField(this, "names");
10
- this.names = {
11
- ...Environment.defaultNameStore,
12
- ...names
13
- };
4
+ constructor(options) {
5
+ this.options = options;
14
6
  }
15
- static create(delta = {}) {
7
+ static create() {
16
8
  return new Environment({
17
- ...Environment.defaultSystemVariables,
18
- dimensions: {}
19
- }).putDelta(delta);
20
- }
21
- hasName(name) {
22
- return name in this.names;
9
+ dimensions: {},
10
+ variables: {},
11
+ parameters: {},
12
+ extensions: /* @__PURE__ */ new Map()
13
+ });
23
14
  }
24
- hasDimension(dimensionName) {
25
- return dimensionName in this.names.dimensions;
15
+ getSubTree() {
16
+ for (let env = this; env.options.node; env = env.getParent()) {
17
+ const node = env.options.node;
18
+ if (node.type === "subtree-entity" || node.type === "subtree-entity-list") {
19
+ return node;
20
+ }
21
+ }
22
+ throw new BindingError("Not in a SubTree");
26
23
  }
27
- getValueOrElse(name, fallback) {
28
- if (!this.hasName(name)) {
29
- return fallback;
24
+ getSubTreeNode() {
25
+ if (!this.options.node) {
26
+ throw new BindingError();
30
27
  }
31
- return this.names[name];
28
+ return this.options.node;
32
29
  }
33
- getDimensionOrElse(dimensionName, fallback) {
34
- if (!this.hasDimension(dimensionName)) {
35
- return fallback;
30
+ withSubTree(SubTree) {
31
+ const { parent, ...options } = this.options;
32
+ return new Environment({
33
+ ...options,
34
+ node: SubTree
35
+ });
36
+ }
37
+ withSubTreeChild(node) {
38
+ if (!this.options.node) {
39
+ throw new BindingError(`Cannot call withSubTreeChild without previous call of withSubTree`);
36
40
  }
37
- return this.names.dimensions[dimensionName];
41
+ if (this.options.node.entity.fields.get(node.field.name) !== node.field) {
42
+ throw new BindingError();
43
+ }
44
+ return new Environment({
45
+ ...this.options,
46
+ node,
47
+ parent: this
48
+ });
38
49
  }
39
- getValue(name) {
40
- return this.names[name];
50
+ hasVariable(key) {
51
+ return key in this.options.variables;
41
52
  }
42
- getDimension(dimensionName) {
43
- return this.names.dimensions[dimensionName];
53
+ getVariable(key) {
54
+ if (!(key in this.options.variables)) {
55
+ throw new BindingError(`Variable ${key} not found`);
56
+ }
57
+ return this.options.variables[key];
44
58
  }
45
- getAllNames() {
46
- return { ...this.names };
59
+ getVariableOrElse(key, fallback) {
60
+ return this.options.variables[key] ?? fallback;
47
61
  }
48
- getAllDimensions() {
49
- return { ...this.names.dimensions };
62
+ getValue(key) {
63
+ console.warn("Environment.getValue() is deprecated, use Environment.getVariable() or Environment.getParameter() instead.");
64
+ return this.getVariableOrElse(key, void 0) ?? this.getParameterOrElse(key, void 0);
65
+ }
66
+ getValueOrElse(key, fallback) {
67
+ console.warn("Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.");
68
+ return this.getVariableOrElse(key, void 0) ?? this.getParameterOrElse(key, fallback);
50
69
  }
51
- getSystemVariable(name) {
52
- return this.names[name];
70
+ hasName(key) {
71
+ console.warn("Environment.hasName() is deprecated, use Environment.hasVariable() or Environment.hasParameter() instead.");
72
+ return key in this.options.variables || key in this.options.parameters;
53
73
  }
54
- putName(name, value) {
74
+ withVariables(variables) {
75
+ if (variables === void 0) {
76
+ return this;
77
+ }
78
+ const newVariables = { ...this.options.variables };
79
+ for (const [newName, newValue] of Object.entries(variables)) {
80
+ if (newName === "labelMiddleware") {
81
+ throw new BindingError("You cannot pass labelMiddleware to withVariables method. Use withLabelMiddleware instead.");
82
+ }
83
+ const resolvedValue = typeof newValue === "function" ? newValue(this) : newValue;
84
+ if (resolvedValue === void 0) {
85
+ delete newVariables[newName];
86
+ } else {
87
+ newVariables[newName] = resolvedValue;
88
+ }
89
+ }
55
90
  return new Environment({
56
- ...this.names,
57
- dimensions: { ...this.names.dimensions },
58
- [name]: value
91
+ ...this.options,
92
+ variables: newVariables,
93
+ parent: this
59
94
  });
60
95
  }
61
- putSystemVariable(name, value) {
62
- return this.putName(name, value);
96
+ getAllVariables() {
97
+ return this.options.variables;
63
98
  }
64
- putDelta(delta) {
65
- const currentNames = this.getAllNames();
66
- for (const newName in delta) {
67
- const deltaValue = delta[newName];
68
- if (deltaValue === void 0) {
69
- delete currentNames[newName];
70
- } else {
71
- currentNames[newName] = deltaValue;
72
- }
99
+ hasParameter(key) {
100
+ return key in this.options.parameters;
101
+ }
102
+ getParameter(key) {
103
+ if (!(key in this.options.parameters)) {
104
+ throw new BindingError(`Parameter ${key} not found`);
73
105
  }
74
- return new Environment(currentNames);
106
+ return this.options.parameters[key];
107
+ }
108
+ getParameterOrElse(key, fallback) {
109
+ return this.options.parameters[key] ?? fallback;
75
110
  }
76
- updateDimensionsIfNecessary(dimensions, defaultDimensions) {
77
- const normalizedDimensions = {
78
- ...defaultDimensions,
111
+ getAllParameters() {
112
+ return this.options.parameters;
113
+ }
114
+ withParameters(parameters) {
115
+ return new Environment({ ...this.options, parameters });
116
+ }
117
+ hasDimension(dimensionName) {
118
+ return dimensionName in this.options.dimensions;
119
+ }
120
+ getDimension(dimensionName) {
121
+ if (!(dimensionName in this.options.dimensions)) {
122
+ throw new BindingError(`Dimension ${dimensionName} does not exist.`);
123
+ }
124
+ return this.options.dimensions[dimensionName];
125
+ }
126
+ getDimensionOrElse(dimensionName, fallback) {
127
+ return this.options.dimensions[dimensionName] ?? fallback;
128
+ }
129
+ getAllDimensions() {
130
+ return this.options.dimensions;
131
+ }
132
+ withDimensions(dimensions) {
133
+ const newDimensions = {
134
+ ...this.options.dimensions,
79
135
  ...dimensions
80
136
  };
81
- const dimensionsEqual = JSON.stringify(this.names.dimensions) === JSON.stringify(normalizedDimensions);
82
- return dimensionsEqual ? this : new Environment({
83
- ...this.names,
84
- dimensions: { ...normalizedDimensions }
85
- });
137
+ if (equal(newDimensions, this.options.dimensions)) {
138
+ return this;
139
+ }
140
+ return new Environment({ ...this.options, dimensions: newDimensions });
86
141
  }
87
- static generateDelta(currentEnvironment, delta) {
88
- const newDelta = {};
89
- for (const name in delta) {
90
- const value = delta[name];
91
- newDelta[name] = value && value instanceof Function && !Environment.systemVariableNames.has(name) ? value(currentEnvironment) : delta[name];
142
+ getSchema() {
143
+ if (!this.options.schema) {
144
+ throw new BindingError("Schema is not set");
92
145
  }
93
- return newDelta;
146
+ return this.options.schema;
147
+ }
148
+ withSchema(schema) {
149
+ return new Environment({ ...this.options, schema });
150
+ }
151
+ getParent() {
152
+ if (!this.options.parent) {
153
+ throw new BindingError("There is no parent environment");
154
+ }
155
+ return this.options.parent;
156
+ }
157
+ withExtension(extension, state) {
158
+ return new Environment({
159
+ ...this.options,
160
+ extensions: new Map([...this.options.extensions, [extension, state]])
161
+ });
94
162
  }
95
- applySystemMiddleware(name, ...args) {
96
- const middleware = this.names[name];
97
- if (typeof middleware === "function") {
98
- return middleware(...args);
163
+ getExtension(extension) {
164
+ const state = this.options.extensions.get(extension);
165
+ return extension.create(state, this);
166
+ }
167
+ merge(other) {
168
+ if (other === this) {
169
+ return this;
170
+ }
171
+ if (!equal(this.options.node, other.options.node)) {
172
+ throw new BindingError(`Cannot merge two environments with different tree position.`);
173
+ }
174
+ if (this.options.parameters !== other.options.parameters) {
175
+ throw new BindingError(`Cannot merge two environments with different parameters.`);
176
+ }
177
+ if (this.options.dimensions !== other.options.dimensions) {
178
+ throw new BindingError(`Cannot merge two environments with different dimensions.`);
179
+ }
180
+ if (this.options.extensions !== other.options.extensions) {
181
+ throw new BindingError(`Cannot merge two environments with different extensions.`);
99
182
  }
100
- return args;
183
+ if (equal(this.options.variables, other.options.variables) && this.options.parent === other.options.parent) {
184
+ return this;
185
+ }
186
+ for (const key in other.options.variables) {
187
+ if (key in this.options.variables && !equal(this.options.variables[key], other.options.variables[key])) {
188
+ throw new BindingError(`Cannot merge two environments with different value of variable ${key}:
189
+ ` + JSON.stringify(this.options.variables[key]) + "\n" + JSON.stringify(other.options.variables[key]));
190
+ }
191
+ }
192
+ return new Environment({
193
+ ...this.options,
194
+ parent: this.options.parent && other.options.parent ? this.options.parent.merge(other.options.parent) : void 0,
195
+ variables: { ...this.options.variables, ...other.options.variables }
196
+ });
101
197
  }
102
198
  }
103
199
  ((Environment2) => {
104
- Environment2.systemVariableNames = /* @__PURE__ */ new Set([
105
- "labelMiddleware",
106
- "rootWhere",
107
- "rootWhereAsFilter",
108
- "rootShouldExists"
109
- ]);
110
- Environment2.reservedVariableNames = /* @__PURE__ */ new Set([
111
- ...Environment2.systemVariableNames,
112
- "dimensions"
113
- ]);
114
- Environment2.defaultSystemVariables = {
115
- labelMiddleware: (label) => label
116
- };
117
- Environment2.defaultNameStore = {
118
- ...Environment2.defaultSystemVariables,
119
- dimensions: {}
200
+ Environment2.createExtension = (create, otherMethods) => {
201
+ return {
202
+ create,
203
+ ...otherMethods
204
+ };
120
205
  };
121
206
  })(Environment || (Environment = {}));
122
207
  export { Environment };
@@ -1 +1 @@
1
- {"version":3,"file":"Environment.js","sources":["../../../src/dao/Environment.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport type { Filter, UniqueWhere } from '../treeParameters'\n\nclass Environment {\n\tprivate readonly names: Environment.NameStore\n\n\tpublic constructor(names: Environment.NameStore = Environment.defaultNameStore) {\n\t\tthis.names = {\n\t\t\t...Environment.defaultNameStore,\n\t\t\t...names,\n\t\t}\n\t}\n\n\tpublic static create(delta: Partial<Environment.NameStore> = {}) {\n\t\treturn new Environment({\n\t\t\t...Environment.defaultSystemVariables,\n\t\t\tdimensions: {},\n\t\t}).putDelta(delta)\n\t}\n\n\tpublic hasName(name: keyof Environment.NameStore): boolean {\n\t\treturn name in this.names\n\t}\n\n\tpublic hasDimension(dimensionName: keyof Environment.SelectedDimensions): boolean {\n\t\treturn dimensionName in this.names.dimensions\n\t}\n\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(\n\t\tname: keyof Environment.NameStore,\n\t\tfallback: F,\n\t): V | F {\n\t\tif (!this.hasName(name)) {\n\t\t\treturn fallback\n\t\t}\n\t\treturn this.names[name] as V\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: keyof Environment.SelectedDimensions, fallback: F): string[] | F {\n\t\tif (!this.hasDimension(dimensionName)) {\n\t\t\treturn fallback\n\t\t}\n\t\treturn this.names.dimensions[dimensionName]\n\t}\n\n\tpublic getValue<V extends Environment.Value = Environment.Value>(name: keyof Environment.NameStore): V {\n\t\treturn this.names[name] as V\n\t}\n\n\tpublic getDimension(dimensionName: keyof Environment.SelectedDimensions): string[] {\n\t\treturn this.names.dimensions[dimensionName]\n\t}\n\n\tpublic getAllNames(): Environment.NameStore {\n\t\treturn { ...this.names }\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn { ...this.names.dimensions }\n\t}\n\n\tpublic getSystemVariable<N extends Environment.SystemVariableName>(name: N): Environment.SystemVariables[N] {\n\t\treturn this.names[name]\n\t}\n\n\tpublic putName(name: Environment.Name, value: Environment.Value): Environment {\n\t\treturn new Environment({\n\t\t\t...this.names,\n\t\t\tdimensions: { ...this.names.dimensions },\n\t\t\t[name]: value,\n\t\t})\n\t}\n\n\tpublic putSystemVariable<N extends Environment.SystemVariableName>(\n\t\tname: N,\n\t\tvalue: Environment.SystemVariables[N],\n\t): Environment {\n\t\treturn this.putName(name, value)\n\t}\n\n\tpublic putDelta(delta: Partial<Environment.NameStore>): Environment {\n\t\tconst currentNames = this.getAllNames()\n\n\t\tfor (const newName in delta) {\n\t\t\tconst deltaValue = delta[newName]\n\t\t\tif (deltaValue === undefined) {\n\t\t\t\tdelete currentNames[newName]\n\t\t\t} else {\n\t\t\t\tcurrentNames[newName] = deltaValue\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment(currentNames)\n\t}\n\n\tpublic updateDimensionsIfNecessary(\n\t\tdimensions: Environment.NameStore['dimensions'],\n\t\tdefaultDimensions: Environment.NameStore['dimensions'],\n\t): Environment {\n\t\tconst normalizedDimensions: Environment.NameStore['dimensions'] = {\n\t\t\t...defaultDimensions,\n\t\t\t...dimensions,\n\t\t}\n\n\t\tconst dimensionsEqual = JSON.stringify(this.names.dimensions) === JSON.stringify(normalizedDimensions)\n\t\treturn dimensionsEqual\n\t\t\t? this\n\t\t\t: new Environment({\n\t\t\t\t\t...this.names,\n\t\t\t\t\tdimensions: { ...normalizedDimensions },\n\t\t\t })\n\t}\n\n\tpublic static generateDelta(\n\t\tcurrentEnvironment: Environment,\n\t\tdelta: Environment.DeltaFactory,\n\t): Partial<Environment.NameStore> {\n\t\tconst newDelta: Partial<Environment.NameStore> = {}\n\n\t\tfor (const name in delta) {\n\t\t\tconst value = delta[name]\n\n\t\t\tnewDelta[name] =\n\t\t\t\tvalue &&\n\t\t\t\tvalue instanceof Function &&\n\t\t\t\t!Environment.systemVariableNames.has(name as Environment.SystemVariableName)\n\t\t\t\t\t? value(currentEnvironment)\n\t\t\t\t\t: delta[name]\n\t\t}\n\n\t\treturn newDelta\n\t}\n\n\tpublic applySystemMiddleware<\n\t\tN extends Environment.SystemMiddlewareName,\n\t\tA extends Parameters<Exclude<Environment.SystemMiddleware[N], undefined>>,\n\t>(name: N, ...args: A): ReturnType<Exclude<Environment.SystemMiddleware[N], undefined>> | A {\n\t\tconst middleware: Environment.SystemMiddleware[N] = this.names[name]\n\t\tif (typeof middleware === 'function') {\n\t\t\treturn (middleware as (...args: A) => any)(...args)\n\t\t}\n\t\treturn args\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string | number\n\n\texport type Value = ReactNode\n\n\texport interface SystemVariables {\n\t\tlabelMiddleware?: (label: ReactNode) => ReactNode\n\t\trootWhere?: UniqueWhere\n\t\trootWhereAsFilter?: Filter\n\t\trootShouldExists?: 'no' | 'maybe' | 'yes'\n\t}\n\n\texport const systemVariableNames: Set<SystemVariableName> = new Set([\n\t\t'labelMiddleware',\n\t\t'rootWhere',\n\t\t'rootWhereAsFilter',\n\t\t'rootShouldExists',\n\t])\n\n\texport const reservedVariableNames: Set<string> = new Set([\n\t\t...systemVariableNames,\n\t\t'dimensions',\n\t])\n\n\texport type SystemVariableName = keyof SystemVariables\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport interface NameStore extends SystemVariables {\n\t\tdimensions: SelectedDimensions\n\n\t\t[name: string]: Value\n\t}\n\n\texport type DeltaFactory = { [N in string]: ((environment: Environment) => Environment.Value) | Environment.Value } &\n\t\t{ [N in keyof SystemVariables]?: SystemVariables[N] }\n\n\texport type SystemMiddleware = {\n\t\t[N in SystemMiddlewareName]: SystemVariables[N]\n\t}\n\n\texport type SystemMiddlewareName = 'labelMiddleware'\n\n\texport const defaultSystemVariables: SystemVariables = {\n\t\tlabelMiddleware: label => label,\n\t}\n\n\texport const defaultNameStore: NameStore = {\n\t\t...defaultSystemVariables,\n\t\tdimensions: {},\n\t}\n}\n\nexport { Environment }\n"],"names":[],"mappings":";;;;;;AAGA,MAAM,YAAY;AAAA,EAGV,YAAY,QAA+B,YAAY,kBAAkB;AAF/D;AAGhB,SAAK,QAAQ;AAAA,SACT,YAAY;AAAA,SACZ;AAAA,IAAA;AAAA,EAEL;AAAA,SAEc,OAAO,QAAwC,IAAI;AAChE,WAAO,IAAI,YAAY;AAAA,SACnB,YAAY;AAAA,MACf,YAAY,CAAC;AAAA,IAAA,CACb,EAAE,SAAS,KAAK;AAAA,EAClB;AAAA,EAEO,QAAQ,MAA4C;AAC1D,WAAO,QAAQ,KAAK;AAAA,EACrB;AAAA,EAEO,aAAa,eAA8D;AAC1E,WAAA,iBAAiB,KAAK,MAAM;AAAA,EACpC;AAAA,EAEO,eACN,MACA,UACQ;AACR,QAAI,CAAC,KAAK,QAAQ,IAAI,GAAG;AACjB,aAAA;AAAA,IACR;AACA,WAAO,KAAK,MAAM;AAAA,EACnB;AAAA,EAEO,mBAAsB,eAAqD,UAA2B;AAC5G,QAAI,CAAC,KAAK,aAAa,aAAa,GAAG;AAC/B,aAAA;AAAA,IACR;AACO,WAAA,KAAK,MAAM,WAAW;AAAA,EAC9B;AAAA,EAEO,SAA0D,MAAsC;AACtG,WAAO,KAAK,MAAM;AAAA,EACnB;AAAA,EAEO,aAAa,eAA+D;AAC3E,WAAA,KAAK,MAAM,WAAW;AA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F,UAAA,aAA8C,KAAK,MAAM;AAC3D,QAAA,OAAO,eAAe,YAAY;AAC7B,aAAA,WAAmC,GAAG,IAAI;AAAA,IACnD;AACO,WAAA;AAAA,EACR;AACD;AAEA,AAAA,EAAU,iBAAV;AAYc,eAAA,0CAAmD,IAAI;AAAA,IACnE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AAEY,eAAA,4CAAyC,IAAI;AAAA,IACzD,GAAG,aAAA;AAAA,IACH;AAAA,EAAA,CACA;AAuBY,eAA0C,yBAAA;AAAA,IACtD,iBAAiB,CAAS,UAAA;AAAA,EAAA;AAGd,eAA8B,mBAAA;AAAA,OACvC,aAAA;AAAA,IACH,YAAY,CAAC;AAAA,EAAA;AACd,GApDS,eAAA,eAAA,CAAA,EAAA;;"}
1
+ {"version":3,"file":"Environment.js","sources":["../../../src/dao/Environment.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingError } from '../BindingError'\nimport type { Filter } from '../treeParameters'\nimport equal from 'fast-deep-equal/es6'\nimport { Schema, SchemaColumn, SchemaEntity, SchemaRelation } from '../core/schema'\n\nclass Environment {\n\tprivate constructor(\n\t\tprivate readonly options: Environment.Options,\n\t) {\n\t}\n\n\tpublic static create() {\n\t\treturn new Environment({\n\t\t\tdimensions: {},\n\t\t\tvariables: {},\n\t\t\tparameters: {},\n\t\t\textensions: new Map(),\n\t\t})\n\t}\n\n\tpublic getSubTree(): Environment.SubTreeNode {\n\t\tfor (let env: Environment = this; env.options.node; env = env.getParent()) {\n\t\t\tconst node = env.options.node\n\t\t\tif (node.type === 'subtree-entity' || node.type === 'subtree-entity-list') {\n\t\t\t\treturn node\n\t\t\t}\n\t\t}\n\t\tthrow new BindingError('Not in a SubTree')\n\t}\n\n\tpublic getSubTreeNode(): Environment.AnyNode {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn this.options.node\n\t}\n\n\tpublic withSubTree(SubTree: Environment.SubTreeNode) {\n\t\tconst { parent, ...options } = this.options\n\t\treturn new Environment({\n\t\t\t...options,\n\t\t\tnode: SubTree,\n\t\t})\n\t}\n\n\tpublic withSubTreeChild(node: Environment.InnerNode) {\n\t\tif (!this.options.node) {\n\t\t\tthrow new BindingError(`Cannot call withSubTreeChild without previous call of withSubTree`)\n\t\t}\n\t\tif (this.options.node.entity.fields.get(node.field.name) !== node.field) {\n\t\t\tthrow new BindingError()\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tnode,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\n\tpublic hasVariable(key: string): boolean {\n\t\treturn key in this.options.variables\n\t}\n\n\tpublic getVariable<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tif (!(key in this.options.variables)) {\n\t\t\tthrow new BindingError(`Variable ${key} not found`)\n\t\t}\n\t\treturn this.options.variables[key] as V\n\t}\n\n\tpublic getVariableOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\treturn (this.options.variables[key] as V) ?? fallback\n\t}\n\n\t/** @deprecated use getVariable or getParameter */\n\tpublic getValue<V extends Environment.Value = Environment.Value>(key: string): V {\n\t\tconsole.warn('Environment.getValue() is deprecated, use Environment.getVariable() or Environment.getParameter() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, undefined) as V\n\t}\n\n\t/** @deprecated use getVariableOrElse or getParameterOrElse */\n\tpublic getValueOrElse<F, V extends Environment.Value = Environment.Value>(key: string, fallback: F): V | F {\n\t\tconsole.warn('Environment.getValueOrElse() is deprecated, use Environment.getVariableOrElse() or Environment.getParameterOrElse() instead.')\n\t\treturn this.getVariableOrElse(key, undefined) ?? this.getParameterOrElse(key, fallback) as V | F\n\t}\n\n\t/** @deprecated */\n\tpublic hasName(key: string): boolean {\n\t\tconsole.warn('Environment.hasName() is deprecated, use Environment.hasVariable() or Environment.hasParameter() instead.')\n\t\treturn key in this.options.variables || key in this.options.parameters\n\t}\n\n\tpublic withVariables(variables: Environment.ValuesMapWithFactory | undefined): Environment {\n\t\tif (variables === undefined) {\n\t\t\treturn this\n\t\t}\n\t\tconst newVariables = { ...this.options.variables }\n\t\tfor (const [newName, newValue] of Object.entries(variables)) {\n\t\t\tif (newName === 'labelMiddleware') {\n\t\t\t\tthrow new BindingError('You cannot pass labelMiddleware to withVariables method. Use withLabelMiddleware instead.')\n\t\t\t}\n\t\t\tconst resolvedValue = typeof newValue === 'function' ? newValue(this) : newValue\n\t\t\tif (resolvedValue === undefined) {\n\t\t\t\tdelete newVariables[newName]\n\t\t\t} else {\n\t\t\t\tnewVariables[newName] = resolvedValue\n\t\t\t}\n\t\t}\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tvariables: newVariables,\n\t\t\tparent: this,\n\t\t})\n\t}\n\n\tpublic getAllVariables() {\n\t\treturn this.options.variables\n\t}\n\n\tpublic hasParameter(key: string): boolean {\n\t\treturn key in this.options.parameters\n\t}\n\n\tpublic getParameter<F>(key: string): string | number {\n\t\tif (!(key in this.options.parameters)) {\n\t\t\tthrow new BindingError(`Parameter ${key} not found`)\n\t\t}\n\t\treturn this.options.parameters[key] as string | number\n\t}\n\n\tpublic getParameterOrElse<F>(key: string, fallback: F): string | number | F {\n\t\treturn this.options.parameters[key] ?? fallback\n\t}\n\n\tpublic getAllParameters() {\n\t\treturn this.options.parameters\n\t}\n\n\tpublic withParameters(parameters: Environment.Parameters): Environment {\n\t\treturn new Environment({ ...this.options, parameters })\n\t}\n\n\tpublic hasDimension(dimensionName: string): boolean {\n\t\treturn dimensionName in this.options.dimensions\n\t}\n\n\tpublic getDimension<F>(dimensionName: string): string[] {\n\t\tif (!(dimensionName in this.options.dimensions)) {\n\t\t\tthrow new BindingError(`Dimension ${dimensionName} does not exist.`)\n\t\t}\n\t\treturn this.options.dimensions[dimensionName]\n\t}\n\n\tpublic getDimensionOrElse<F>(dimensionName: string, fallback: F): string[] | F {\n\t\treturn this.options.dimensions[dimensionName] ?? fallback\n\t}\n\n\tpublic getAllDimensions(): Environment.SelectedDimensions {\n\t\treturn this.options.dimensions\n\t}\n\n\tpublic withDimensions(dimensions: Environment.SelectedDimensions): Environment {\n\t\tconst newDimensions = {\n\t\t\t...this.options.dimensions,\n\t\t\t...dimensions,\n\t\t}\n\t\tif (equal(newDimensions, this.options.dimensions)) {\n\t\t\treturn this\n\t\t}\n\t\treturn new Environment({ ...this.options, dimensions: newDimensions })\n\t}\n\n\tpublic getSchema(): Schema {\n\t\tif (!this.options.schema) {\n\t\t\tthrow new BindingError('Schema is not set')\n\t\t}\n\t\treturn this.options.schema\n\t}\n\n\tpublic withSchema(schema: Schema): Environment {\n\t\treturn new Environment({ ...this.options, schema })\n\t}\n\n\tpublic getParent(): Environment {\n\t\tif (!this.options.parent) {\n\t\t\tthrow new BindingError('There is no parent environment')\n\t\t}\n\t\treturn this.options.parent\n\t}\n\n\tpublic withExtension<S, R>(extension: Environment.Extension<S, R>, state: S): Environment {\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\textensions: new Map([...this.options.extensions, [extension, state] as [Environment.Extension<unknown, unknown>, unknown]]),\n\t\t})\n\t}\n\n\tpublic getExtension<S, R>(extension: Environment.Extension<S, R>): R {\n\t\tconst state = this.options.extensions.get(extension as Environment.Extension<unknown, unknown>)\n\t\treturn extension.create(state as S, this)\n\t}\n\n\tpublic merge(other: Environment): Environment {\n\t\tif (other === this) {\n\t\t\treturn this\n\t\t}\n\t\tif (!equal(this.options.node, other.options.node)) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different tree position.`)\n\t\t}\n\t\tif (this.options.parameters !== other.options.parameters) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different parameters.`)\n\t\t}\n\t\tif (this.options.dimensions !== other.options.dimensions) {\n\t\t\tthrow new BindingError(`Cannot merge two environments with different dimensions.`)\n\t\t}\n\t\tif (this.options.extensions !== other.options.extensions) {\n\t\t\t// todo: deep compare?\n\t\t\tthrow new BindingError(`Cannot merge two environments with different extensions.`)\n\t\t}\n\n\t\tif (equal(this.options.variables, other.options.variables) && this.options.parent === other.options.parent) {\n\t\t\treturn this\n\t\t}\n\t\tfor (const key in other.options.variables) {\n\t\t\tif (key in this.options.variables && !equal(this.options.variables[key], other.options.variables[key])) {\n\t\t\t\tthrow new BindingError(`Cannot merge two environments with different value of variable ${key}:\\n`\n\t\t\t\t\t+ JSON.stringify(this.options.variables[key]) + '\\n'\n\t\t\t\t\t+ JSON.stringify(other.options.variables[key]))\n\t\t\t}\n\t\t}\n\n\t\treturn new Environment({\n\t\t\t...this.options,\n\t\t\tparent: this.options.parent && other.options.parent ? this.options.parent.merge(other.options.parent) : undefined,\n\t\t\tvariables: { ...this.options.variables, ...other.options.variables },\n\t\t})\n\t}\n}\n\nnamespace Environment {\n\texport type Name = string\n\n\texport type Value = ReactNode\n\n\texport type ResolvedValue = Value | Filter\n\n\texport interface Options {\n\t\tnode?: AnyNode\n\t\tschema?: Schema\n\t\tdimensions: SelectedDimensions\n\t\tparameters: Parameters\n\t\tvariables: CustomVariables\n\t\tparent?: Environment\n\t\textensions: Map<Extension<unknown, unknown>, unknown>\n\t}\n\n\texport type SubTreeNode =\n\t\t| SubTreeEntityNode\n\t\t| SubTreeEntityListNode\n\n\texport type InnerNode =\n\t\t| EntityNode\n\t\t| EntityListNode\n\t\t| ColumnNode\n\n\texport type AnyNode =\n\t\t| SubTreeNode\n\t\t| InnerNode\n\n\texport interface SubTreeEntityNode {\n\t\ttype: 'subtree-entity'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero' | 'one' | 'zero-or-one'\n\t\tfilter: Filter\n\t}\n\n\texport interface SubTreeEntityListNode {\n\t\ttype: 'subtree-entity-list'\n\t\tentity: SchemaEntity\n\t\texpectedCardinality: 'zero-to-many' | 'zero'\n\t\tfilter: Filter\n\t}\n\n\texport interface EntityNode {\n\t\ttype: 'entity'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface EntityListNode {\n\t\ttype: 'entity-list'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaRelation\n\t}\n\n\texport interface ColumnNode {\n\t\ttype: 'column'\n\t\tentity: SchemaEntity\n\t\tfield: SchemaColumn\n\t}\n\n\texport interface SelectedDimensions {\n\t\t[key: string]: string[]\n\t}\n\n\texport type Parameters = {\n\t\t[K in string]?: string | number\n\t}\n\n\texport interface CustomVariables {\n\t\t[key: string]: Value\n\t}\n\n\texport interface ValuesMapWithFactory {\n\t\t[key: string]:\n\t\t\t| ((environment: Environment) => Value)\n\t\t\t| Value\n\t}\n\n\texport type Extension<State, Result> = {\n\t\tcreate: (state: State | undefined, environment: Environment) => Result\n\t}\n\n\texport const createExtension = <S, R>(create: Extension<S, R>['create'], otherMethods?: Omit<Extension<S, R>, 'create'>): Extension<S, R> => {\n\t\treturn {\n\t\t\tcreate,\n\t\t\t...otherMethods,\n\t\t}\n\t}\n\n\t/** @deprecated */\n\texport type DeltaFactory = ValuesMapWithFactory\n}\n\nexport { Environment }\n"],"names":[],"mappings":";;AAMA,MAAM,YAAY;AAAA,EACT,YACU,SAChB;AADgB,SAAA,UAAA;AAAA,EAElB;AAAA,SAEc,SAAS;AACtB,WAAO,IAAI,YAAY;AAAA,MACtB,YAAY,CAAC;AAAA,MACb,WAAW,CAAC;AAAA,MACZ,YAAY,CAAC;AAAA,MACb,gCAAgB,IAAI;AAAA,IAAA,CACpB;AAAA,EACF;AAAA,EAEO,aAAsC;AACnC,aAAA,MAAmB,MAAM,IAAI,QAAQ,MAAM,MAAM,IAAI,aAAa;AACpE,YAAA,OAAO,IAAI,QAAQ;AACzB,UAAI,KAAK,SAAS,oBAAoB,KAAK,SAAS,uBAAuB;AACnE,eAAA;AAAA,MACR;AAAA,IACD;AACM,UAAA,IAAI,aAAa,kBAAkB;AAAA,EAC1C;AAAA,EAEO,iBAAsC;AACxC,QAAA,CAAC,KAAK,QAAQ,MAAM;AACvB,YAAM,IAAI,aAAa;AAAA,IACxB;AACA,WAAO,KAAK,QAA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