@contember/binding 1.1.0-alpha.1 → 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 (390) 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/accessorTreeStateReducer.js +11 -2
  15. package/dist/development/accessorTree/accessorTreeStateReducer.js.map +1 -1
  16. package/dist/development/accessorTree/useAccessorTreeState.js +12 -0
  17. package/dist/development/accessorTree/useAccessorTreeState.js.map +1 -0
  18. package/dist/development/accessorTree/useDataBinding.js +41 -51
  19. package/dist/development/accessorTree/useDataBinding.js.map +1 -1
  20. package/dist/development/core/AccessorErrorManager.js +2 -2
  21. package/dist/development/core/AccessorErrorManager.js.map +1 -1
  22. package/dist/development/core/Config.js +1 -2
  23. package/dist/development/core/Config.js.map +1 -1
  24. package/dist/development/core/DataBinding.js +18 -35
  25. package/dist/development/core/DataBinding.js.map +1 -1
  26. package/dist/development/core/DirtinessTracker.js +4 -13
  27. package/dist/development/core/DirtinessTracker.js.map +1 -1
  28. package/dist/development/core/ErrorsPreprocessor.js +9 -13
  29. package/dist/development/core/ErrorsPreprocessor.js.map +1 -1
  30. package/dist/development/core/EventManager.js +12 -7
  31. package/dist/development/core/EventManager.js.map +1 -1
  32. package/dist/development/core/IncrementalMarkerBuilder.js +1 -1
  33. package/dist/development/core/MarkerMerger.js +2 -2
  34. package/dist/development/core/MutationGenerator.js +175 -136
  35. package/dist/development/core/MutationGenerator.js.map +1 -1
  36. package/dist/development/core/RequestResponseNormalizer.js +93 -130
  37. package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
  38. package/dist/development/core/StateInitializer.js +22 -30
  39. package/dist/development/core/StateInitializer.js.map +1 -1
  40. package/dist/development/core/TreeAugmenter.js +4 -4
  41. package/dist/development/core/TreeAugmenter.js.map +1 -1
  42. package/dist/development/core/TreeStore.js +9 -20
  43. package/dist/development/core/TreeStore.js.map +1 -1
  44. package/dist/development/core/VariableInputTransformer.js.map +1 -1
  45. package/dist/development/core/operations/EntityOperations.js +10 -9
  46. package/dist/development/core/operations/EntityOperations.js.map +1 -1
  47. package/dist/development/core/operations/ListOperations.js +1 -1
  48. package/dist/development/core/operations/ListOperations.js.map +1 -1
  49. package/dist/development/core/requestAliases/MutationAlias.js +2 -40
  50. package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
  51. package/dist/development/core/schema/Schema.js +27 -3
  52. package/dist/development/core/schema/Schema.js.map +1 -1
  53. package/dist/development/core/schema/SchemaLoader.js +12 -12
  54. package/dist/development/core/schema/SchemaLoader.js.map +1 -1
  55. package/dist/development/core/schema/SchemaPreprocessor.js +1 -1
  56. package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
  57. package/dist/development/coreComponents/Component.js +5 -2
  58. package/dist/development/coreComponents/Component.js.map +1 -1
  59. package/dist/development/coreComponents/DataBindingProvider.js +0 -1
  60. package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
  61. package/dist/development/coreComponents/HasOne.js +1 -1
  62. package/dist/development/dao/Environment.js +34 -2
  63. package/dist/development/dao/Environment.js.map +1 -1
  64. package/dist/development/dao/TreeNodeEnvironmentFactory.js +4 -10
  65. package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -1
  66. package/dist/development/helperComponents/DeferredSubTrees.js +16 -8
  67. package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
  68. package/dist/development/helperComponents/If.js +39 -0
  69. package/dist/development/helperComponents/If.js.map +1 -0
  70. package/dist/development/helperComponents/SugaredField.js +1 -1
  71. package/dist/development/helperComponents/helpers/FilterEvaluator.js +35 -0
  72. package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  73. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js +38 -0
  74. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  75. package/dist/development/helperComponents/helpers/evaluateCondition.js +46 -0
  76. package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -0
  77. package/dist/development/index.js +6 -1
  78. package/dist/development/index.js.map +1 -1
  79. package/dist/development/markers/EntityListSubTreeMarker.js +1 -1
  80. package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
  81. package/dist/development/markers/EntitySubTreeMarker.js +1 -1
  82. package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
  83. package/dist/development/markers/PlaceholderGenerator.js +4 -4
  84. package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
  85. package/dist/development/queryLanguage/MarkerFactory.js +2 -2
  86. package/dist/development/queryLanguage/QueryLanguage.js +1 -1
  87. package/dist/development/utils/Hashing.js +21 -6
  88. package/dist/development/utils/Hashing.js.map +1 -1
  89. package/dist/production/accessorPropagation/EnvironmentContext.js +28 -2
  90. package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
  91. package/dist/production/accessorPropagation/useEntityListSubTree.js +4 -2
  92. package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
  93. package/dist/production/accessorPropagation/useEntitySubTree.js +4 -2
  94. package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
  95. package/dist/production/accessorPropagation/useExtendTree.js +27 -0
  96. package/dist/production/accessorPropagation/useExtendTree.js.map +1 -0
  97. package/dist/production/accessorTree/AccessorTree.js +16 -14
  98. package/dist/production/accessorTree/AccessorTree.js.map +1 -1
  99. package/dist/production/accessorTree/AccessorTreeStateContext.js +4 -0
  100. package/dist/production/accessorTree/AccessorTreeStateContext.js.map +1 -0
  101. package/dist/production/accessorTree/NormalizedPersistedData.js.map +1 -1
  102. package/dist/production/accessorTree/accessorTreeStateReducer.js +11 -2
  103. package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
  104. package/dist/production/accessorTree/useAccessorTreeState.js +12 -0
  105. package/dist/production/accessorTree/useAccessorTreeState.js.map +1 -0
  106. package/dist/production/accessorTree/useDataBinding.js +41 -51
  107. package/dist/production/accessorTree/useDataBinding.js.map +1 -1
  108. package/dist/production/core/AccessorErrorManager.js +2 -2
  109. package/dist/production/core/AccessorErrorManager.js.map +1 -1
  110. package/dist/production/core/Config.js +1 -2
  111. package/dist/production/core/Config.js.map +1 -1
  112. package/dist/production/core/DataBinding.js +18 -35
  113. package/dist/production/core/DataBinding.js.map +1 -1
  114. package/dist/production/core/DirtinessTracker.js +4 -13
  115. package/dist/production/core/DirtinessTracker.js.map +1 -1
  116. package/dist/production/core/ErrorsPreprocessor.js +9 -13
  117. package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
  118. package/dist/production/core/EventManager.js +11 -6
  119. package/dist/production/core/EventManager.js.map +1 -1
  120. package/dist/production/core/IncrementalMarkerBuilder.js +1 -1
  121. package/dist/production/core/MarkerMerger.js +2 -2
  122. package/dist/production/core/MutationGenerator.js +175 -136
  123. package/dist/production/core/MutationGenerator.js.map +1 -1
  124. package/dist/production/core/RequestResponseNormalizer.js +93 -130
  125. package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
  126. package/dist/production/core/StateInitializer.js +22 -30
  127. package/dist/production/core/StateInitializer.js.map +1 -1
  128. package/dist/production/core/TreeAugmenter.js +4 -4
  129. package/dist/production/core/TreeAugmenter.js.map +1 -1
  130. package/dist/production/core/TreeStore.js +9 -20
  131. package/dist/production/core/TreeStore.js.map +1 -1
  132. package/dist/production/core/VariableInputTransformer.js.map +1 -1
  133. package/dist/production/core/operations/EntityOperations.js +10 -9
  134. package/dist/production/core/operations/EntityOperations.js.map +1 -1
  135. package/dist/production/core/operations/ListOperations.js +1 -1
  136. package/dist/production/core/operations/ListOperations.js.map +1 -1
  137. package/dist/production/core/requestAliases/MutationAlias.js +2 -33
  138. package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
  139. package/dist/production/core/schema/Schema.js +27 -3
  140. package/dist/production/core/schema/Schema.js.map +1 -1
  141. package/dist/production/core/schema/SchemaLoader.js +12 -12
  142. package/dist/production/core/schema/SchemaLoader.js.map +1 -1
  143. package/dist/production/core/schema/SchemaPreprocessor.js +1 -1
  144. package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
  145. package/dist/production/coreComponents/Component.js +5 -2
  146. package/dist/production/coreComponents/Component.js.map +1 -1
  147. package/dist/production/coreComponents/DataBindingProvider.js +0 -1
  148. package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
  149. package/dist/production/coreComponents/HasOne.js +1 -1
  150. package/dist/production/dao/Environment.js +34 -2
  151. package/dist/production/dao/Environment.js.map +1 -1
  152. package/dist/production/dao/TreeNodeEnvironmentFactory.js +4 -10
  153. package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -1
  154. package/dist/production/helperComponents/DeferredSubTrees.js +16 -8
  155. package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
  156. package/dist/production/helperComponents/If.js +39 -0
  157. package/dist/production/helperComponents/If.js.map +1 -0
  158. package/dist/production/helperComponents/SugaredField.js +1 -1
  159. package/dist/production/helperComponents/helpers/FilterEvaluator.js +35 -0
  160. package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  161. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js +38 -0
  162. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  163. package/dist/production/helperComponents/helpers/evaluateCondition.js +46 -0
  164. package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -0
  165. package/dist/production/index.js +6 -1
  166. package/dist/production/index.js.map +1 -1
  167. package/dist/production/markers/EntityListSubTreeMarker.js +1 -1
  168. package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
  169. package/dist/production/markers/EntitySubTreeMarker.js +1 -1
  170. package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
  171. package/dist/production/markers/PlaceholderGenerator.js +4 -4
  172. package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
  173. package/dist/production/queryLanguage/MarkerFactory.js +2 -2
  174. package/dist/production/queryLanguage/QueryLanguage.js +1 -1
  175. package/dist/production/utils/Hashing.js +21 -6
  176. package/dist/production/utils/Hashing.js.map +1 -1
  177. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
  178. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
  179. package/dist/types/accessorPropagation/EntityKeyContext.d.ts +1 -1
  180. package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
  181. package/dist/types/accessorPropagation/EnvironmentContext.d.ts +13 -2
  182. package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
  183. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
  184. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
  185. package/dist/types/accessorPropagation/index.d.ts +1 -0
  186. package/dist/types/accessorPropagation/index.d.ts.map +1 -1
  187. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts +2 -1
  188. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -1
  189. package/dist/types/accessorPropagation/useEntitySubTree.d.ts +2 -1
  190. package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
  191. package/dist/types/accessorPropagation/useExtendTree.d.ts +5 -0
  192. package/dist/types/accessorPropagation/useExtendTree.d.ts.map +1 -0
  193. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
  194. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
  195. package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
  196. package/dist/types/accessorTree/AccessorTreeState.d.ts +8 -0
  197. package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
  198. package/dist/types/accessorTree/AccessorTreeStateAction.d.ts +6 -0
  199. package/dist/types/accessorTree/AccessorTreeStateAction.d.ts.map +1 -1
  200. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +4 -0
  201. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -0
  202. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -1
  203. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
  204. package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
  205. package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
  206. package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
  207. package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
  208. package/dist/types/accessorTree/NormalizedPersistedData.d.ts +2 -2
  209. package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
  210. package/dist/types/accessorTree/QueryRequestResponse.d.ts +2 -2
  211. package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
  212. package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +1 -1
  213. package/dist/types/accessorTree/index.d.ts +1 -0
  214. package/dist/types/accessorTree/index.d.ts.map +1 -1
  215. package/dist/types/accessorTree/useAccessorTreeState.d.ts +2 -0
  216. package/dist/types/accessorTree/useAccessorTreeState.d.ts.map +1 -0
  217. package/dist/types/accessorTree/useDataBinding.d.ts +1 -1
  218. package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
  219. package/dist/types/accessors/BindingConfig.d.ts +0 -1
  220. package/dist/types/accessors/BindingConfig.d.ts.map +1 -1
  221. package/dist/types/core/AccessorErrorManager.d.ts +2 -1
  222. package/dist/types/core/AccessorErrorManager.d.ts.map +1 -1
  223. package/dist/types/core/Config.d.ts.map +1 -1
  224. package/dist/types/core/DataBinding.d.ts +3 -4
  225. package/dist/types/core/DataBinding.d.ts.map +1 -1
  226. package/dist/types/core/DirtinessTracker.d.ts +2 -5
  227. package/dist/types/core/DirtinessTracker.d.ts.map +1 -1
  228. package/dist/types/core/ErrorsPreprocessor.d.ts +3 -1
  229. package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
  230. package/dist/types/core/EventManager.d.ts +1 -1
  231. package/dist/types/core/EventManager.d.ts.map +1 -1
  232. package/dist/types/core/MutationGenerator.d.ts +25 -1
  233. package/dist/types/core/MutationGenerator.d.ts.map +1 -1
  234. package/dist/types/core/RequestResponseNormalizer.d.ts +6 -7
  235. package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
  236. package/dist/types/core/StateInitializer.d.ts +1 -5
  237. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  238. package/dist/types/core/TreeAugmenter.d.ts +3 -2
  239. package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
  240. package/dist/types/core/TreeStore.d.ts +5 -5
  241. package/dist/types/core/TreeStore.d.ts.map +1 -1
  242. package/dist/types/core/VariableInputTransformer.d.ts +2 -2
  243. package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
  244. package/dist/types/core/index.d.ts +1 -0
  245. package/dist/types/core/index.d.ts.map +1 -1
  246. package/dist/types/core/operations/EntityOperations.d.ts.map +1 -1
  247. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  248. package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -3
  249. package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -1
  250. package/dist/types/core/requestAliases/index.d.ts +0 -3
  251. package/dist/types/core/requestAliases/index.d.ts.map +1 -1
  252. package/dist/types/core/schema/RawSchemaEntity.d.ts +3 -2
  253. package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -1
  254. package/dist/types/core/schema/Schema.d.ts +13 -3
  255. package/dist/types/core/schema/Schema.d.ts.map +1 -1
  256. package/dist/types/core/schema/SchemaColumn.d.ts +1 -1
  257. package/dist/types/core/schema/SchemaColumn.d.ts.map +1 -1
  258. package/dist/types/core/schema/SchemaEntity.d.ts +1 -1
  259. package/dist/types/core/schema/SchemaEntity.d.ts.map +1 -1
  260. package/dist/types/core/schema/SchemaLoader.d.ts +2 -1
  261. package/dist/types/core/schema/SchemaLoader.d.ts.map +1 -1
  262. package/dist/types/core/schema/SchemaRelation.d.ts +1 -1
  263. package/dist/types/core/schema/SchemaRelation.d.ts.map +1 -1
  264. package/dist/types/core/state/FieldState.d.ts +2 -2
  265. package/dist/types/core/state/FieldState.d.ts.map +1 -1
  266. package/dist/types/coreComponents/Component.d.ts +9 -4
  267. package/dist/types/coreComponents/Component.d.ts.map +1 -1
  268. package/dist/types/coreComponents/DataBindingProvider.d.ts +0 -1
  269. package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
  270. package/dist/types/coreComponents/Entity.d.ts +1 -1
  271. package/dist/types/coreComponents/Entity.d.ts.map +1 -1
  272. package/dist/types/coreComponents/Field.d.ts +1 -1
  273. package/dist/types/coreComponents/Field.d.ts.map +1 -1
  274. package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
  275. package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
  276. package/dist/types/dao/Environment.d.ts +9 -0
  277. package/dist/types/dao/Environment.d.ts.map +1 -1
  278. package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -1
  279. package/dist/types/entityEvents/useDerivedField.d.ts +2 -2
  280. package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
  281. package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
  282. package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
  283. package/dist/types/helperComponents/FieldView.d.ts +7 -7
  284. package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
  285. package/dist/types/helperComponents/If.d.ts +14 -0
  286. package/dist/types/helperComponents/If.d.ts.map +1 -0
  287. package/dist/types/helperComponents/StaticRender.d.ts +1 -1
  288. package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
  289. package/dist/types/helperComponents/SugaredField.d.ts +1 -1
  290. package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
  291. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts +9 -0
  292. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts.map +1 -0
  293. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts +10 -0
  294. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts.map +1 -0
  295. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +4 -0
  296. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -0
  297. package/dist/types/helperComponents/index.d.ts +1 -0
  298. package/dist/types/helperComponents/index.d.ts.map +1 -1
  299. package/dist/types/markers/FieldMarker.d.ts +3 -3
  300. package/dist/types/markers/FieldMarker.d.ts.map +1 -1
  301. package/dist/types/markers/PlaceholderGenerator.d.ts +3 -2
  302. package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -1
  303. package/dist/types/treeParameters/primitives/FieldValue.d.ts +2 -2
  304. package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -1
  305. package/dist/types/treeParameters/primitives/Json.d.ts +7 -0
  306. package/dist/types/treeParameters/primitives/Json.d.ts.map +1 -0
  307. package/dist/types/treeParameters/primitives/index.d.ts +1 -0
  308. package/dist/types/treeParameters/primitives/index.d.ts.map +1 -1
  309. package/dist/types/tsconfig.tsbuildinfo +1 -1
  310. package/dist/types/utils/Hashing.d.ts +3 -2
  311. package/dist/types/utils/Hashing.d.ts.map +1 -1
  312. package/package.json +7 -5
  313. package/src/accessorPropagation/EnvironmentContext.tsx +44 -0
  314. package/src/accessorPropagation/index.ts +1 -0
  315. package/src/accessorPropagation/useEntityListSubTree.ts +8 -1
  316. package/src/accessorPropagation/useEntitySubTree.ts +8 -1
  317. package/src/accessorPropagation/useExtendTree.ts +30 -0
  318. package/src/accessorTree/AccessorTree.tsx +18 -18
  319. package/src/accessorTree/AccessorTreeState.ts +12 -1
  320. package/src/accessorTree/AccessorTreeStateAction.ts +7 -1
  321. package/src/accessorTree/AccessorTreeStateContext.ts +4 -0
  322. package/src/accessorTree/AccessorTreeStateOptions.ts +0 -1
  323. package/src/accessorTree/NormalizedPersistedData.ts +2 -2
  324. package/src/accessorTree/QueryRequestResponse.ts +2 -2
  325. package/src/accessorTree/accessorTreeStateReducer.ts +10 -1
  326. package/src/accessorTree/index.ts +1 -0
  327. package/src/accessorTree/useAccessorTreeState.ts +11 -0
  328. package/src/accessorTree/useDataBinding.ts +41 -59
  329. package/src/accessors/BindingConfig.ts +0 -1
  330. package/src/core/AccessorErrorManager.ts +3 -2
  331. package/src/core/Config.ts +0 -1
  332. package/src/core/DataBinding.ts +19 -38
  333. package/src/core/DirtinessTracker.ts +4 -16
  334. package/src/core/ErrorsPreprocessor.ts +14 -16
  335. package/src/core/EventManager.ts +14 -8
  336. package/src/core/MutationGenerator.ts +244 -183
  337. package/src/core/RequestResponseNormalizer.ts +110 -161
  338. package/src/core/StateInitializer.ts +35 -47
  339. package/src/core/TreeAugmenter.ts +5 -4
  340. package/src/core/TreeStore.ts +11 -21
  341. package/src/core/VariableInputTransformer.ts +2 -2
  342. package/src/core/index.ts +1 -0
  343. package/src/core/operations/EntityOperations.ts +9 -10
  344. package/src/core/operations/ListOperations.ts +2 -1
  345. package/src/core/requestAliases/MutationAlias.ts +2 -57
  346. package/src/core/requestAliases/index.ts +0 -3
  347. package/src/core/schema/RawSchemaEntity.ts +1 -2
  348. package/src/core/schema/Schema.ts +38 -4
  349. package/src/core/schema/SchemaColumn.ts +1 -1
  350. package/src/core/schema/SchemaEntity.ts +1 -1
  351. package/src/core/schema/SchemaLoader.ts +13 -11
  352. package/src/core/schema/SchemaPreprocessor.ts +1 -1
  353. package/src/core/schema/SchemaRelation.ts +1 -1
  354. package/src/core/state/FieldState.ts +2 -2
  355. package/src/coreComponents/Component.tsx +20 -7
  356. package/src/coreComponents/DataBindingProvider.tsx +0 -2
  357. package/src/dao/Environment.ts +42 -1
  358. package/src/dao/TreeNodeEnvironmentFactory.ts +6 -10
  359. package/src/helperComponents/DeferredSubTrees.tsx +20 -13
  360. package/src/helperComponents/If.tsx +71 -0
  361. package/src/helperComponents/helpers/FilterEvaluator.ts +46 -0
  362. package/src/helperComponents/helpers/FilterFieldsCollector.ts +46 -0
  363. package/src/helperComponents/helpers/evaluateCondition.ts +52 -0
  364. package/src/helperComponents/index.ts +1 -0
  365. package/src/markers/EntityListSubTreeMarker.ts +1 -1
  366. package/src/markers/EntitySubTreeMarker.ts +1 -1
  367. package/src/markers/PlaceholderGenerator.ts +5 -2
  368. package/src/treeParameters/primitives/FieldValue.ts +2 -2
  369. package/src/treeParameters/primitives/Json.ts +7 -0
  370. package/src/treeParameters/primitives/index.ts +1 -0
  371. package/src/typings/react-fix.d.ts +12 -0
  372. package/src/utils/Hashing.ts +23 -8
  373. package/dist/development/core/requestAliases/mutationOperationSubTreeType.js +0 -6
  374. package/dist/development/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
  375. package/dist/development/core/requestAliases/mutationOperationType.js +0 -7
  376. package/dist/development/core/requestAliases/mutationOperationType.js.map +0 -1
  377. package/dist/production/core/requestAliases/mutationOperationSubTreeType.js +0 -6
  378. package/dist/production/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
  379. package/dist/production/core/requestAliases/mutationOperationType.js +0 -7
  380. package/dist/production/core/requestAliases/mutationOperationType.js.map +0 -1
  381. package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts +0 -11
  382. package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts.map +0 -1
  383. package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts +0 -5
  384. package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts.map +0 -1
  385. package/dist/types/core/requestAliases/mutationOperationType.d.ts +0 -6
  386. package/dist/types/core/requestAliases/mutationOperationType.d.ts.map +0 -1
  387. package/src/accessorPropagation/EnvironmentContext.ts +0 -5
  388. package/src/core/requestAliases/TopLevelMutationOperation.ts +0 -11
  389. package/src/core/requestAliases/mutationOperationSubTreeType.ts +0 -4
  390. package/src/core/requestAliases/mutationOperationType.ts +0 -5
@@ -1,24 +1,26 @@
1
1
  import { createElement } from "react";
2
+ import { AccessorTreeStateContext } from "./AccessorTreeStateContext.js";
2
3
  import { DirtinessContext } from "./DirtinessContext.js";
3
4
  import { MutationStateContext } from "./MutationStateContext.js";
5
+ import { EnvironmentContext } from "../accessorPropagation/EnvironmentContext.js";
4
6
  import { BindingOperationsProvider } from "../accessorPropagation/BindingOperationsProvider.js";
5
7
  function AccessorTree({ state, children }) {
6
- if (state.name === "initialized") {
7
- return /* @__PURE__ */ createElement(DirtinessContext.Provider, {
8
- value: state.data.hasUnpersistedChanges
9
- }, /* @__PURE__ */ createElement(MutationStateContext.Provider, {
10
- value: state.data.isMutating
11
- }, /* @__PURE__ */ createElement(BindingOperationsProvider, {
12
- bindingOperations: state.data.bindingOperations
13
- }, children)));
14
- }
15
- return /* @__PURE__ */ createElement(DirtinessContext.Provider, {
16
- value: false
8
+ const stateData = state.name === "initialized" ? state.data : {
9
+ hasUnpersistedChanges: false,
10
+ isMutating: false,
11
+ bindingOperations: void 0
12
+ };
13
+ return /* @__PURE__ */ createElement(EnvironmentContext.Provider, {
14
+ value: state.environment
15
+ }, /* @__PURE__ */ createElement(AccessorTreeStateContext.Provider, {
16
+ value: state
17
+ }, /* @__PURE__ */ createElement(DirtinessContext.Provider, {
18
+ value: stateData.hasUnpersistedChanges
17
19
  }, /* @__PURE__ */ createElement(MutationStateContext.Provider, {
18
- value: false
20
+ value: stateData.isMutating
19
21
  }, /* @__PURE__ */ createElement(BindingOperationsProvider, {
20
- bindingOperations: void 0
21
- }, children)));
22
+ bindingOperations: stateData.bindingOperations
23
+ }, children)))));
22
24
  }
23
25
  AccessorTree.displayName = "AccessorTree";
24
26
  export { AccessorTree };
@@ -1 +1 @@
1
- {"version":3,"file":"AccessorTree.js","sources":["../../../src/accessorTree/AccessorTree.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingOperationsProvider } from '../accessorPropagation'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport { DirtinessContext } from './DirtinessContext'\nimport { MutationStateContext } from './MutationStateContext'\n\nexport interface AccessorTreeProps {\n\tstate: AccessorTreeState\n\tchildren: ReactNode\n}\n\nexport function AccessorTree({ state, children }: AccessorTreeProps) {\n\t// It is *CRUCIAL* that both branches differ only in props, not structurally. Otherwise there would be far too many\n\t// remounts.\n\tif (state.name === 'initialized') {\n\t\treturn (\n\t\t\t<DirtinessContext.Provider value={state.data.hasUnpersistedChanges}>\n\t\t\t\t<MutationStateContext.Provider value={state.data.isMutating}>\n\t\t\t\t\t<BindingOperationsProvider bindingOperations={state.data.bindingOperations}>\n\t\t\t\t\t\t{children}\n\t\t\t\t\t</BindingOperationsProvider>\n\t\t\t\t</MutationStateContext.Provider>\n\t\t\t</DirtinessContext.Provider>\n\t\t)\n\t}\n\treturn (\n\t\t<DirtinessContext.Provider value={false}>\n\t\t\t<MutationStateContext.Provider value={false}>\n\t\t\t\t<BindingOperationsProvider bindingOperations={undefined}>{children}</BindingOperationsProvider>\n\t\t\t</MutationStateContext.Provider>\n\t\t</DirtinessContext.Provider>\n\t)\n}\nAccessorTree.displayName = 'AccessorTree'\n"],"names":["_jsx"],"mappings":";;;;AAW6B,sBAAA,EAAE,OAAO,YAA+B;AAGhE,MAAA,MAAM,SAAS,eAAe;AAEhC,WAAAA,8BAAC,iBAAiB,UAAjB;AAAA,MAA0B,OAAO,MAAM,KAAK;AAAA,IAAA,GAC5CA,8BAAC,qBAAqB,UAArB;AAAA,MAA8B,OAAO,MAAM,KAAK;AAAA,IAAA,GAC/CA,8BAAA,2BAAA;AAAA,MAA0B,mBAAmB,MAAM,KAAK;AAAA,IAAA,GACvD,QACF,CACD,CACD;AAAA,EAEF;AAEC,SAAAA,8BAAC,iBAAiB,UAAjB;AAAA,IAA0B,OAAO;AAAA,EAAA,GACjCA,8BAAC,qBAAqB,UAArB;AAAA,IAA8B,OAAO;AAAA,EAAA,GACpCA,8BAAA,2BAAA;AAAA,IAA0B,mBAAmB;AAAA,EAAA,GAAY,QAAS,CACpE,CACD;AAEF;AACA,aAAa,cAAc;;"}
1
+ {"version":3,"file":"AccessorTree.js","sources":["../../../src/accessorTree/AccessorTree.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { BindingOperationsProvider, EnvironmentContext } from '../accessorPropagation'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport { AccessorTreeStateContext } from './AccessorTreeStateContext'\nimport { DirtinessContext } from './DirtinessContext'\nimport { MutationStateContext } from './MutationStateContext'\n\nexport interface AccessorTreeProps {\n\tstate: AccessorTreeState\n\tchildren: ReactNode\n}\n\nexport function AccessorTree({ state, children }: AccessorTreeProps) {\n\tconst stateData = state.name === 'initialized' ? state.data : {\n\t\thasUnpersistedChanges: false,\n\t\tisMutating: false,\n\t\tbindingOperations: undefined,\n\t}\n\treturn (\n\t\t<EnvironmentContext.Provider value={state.environment}>\n\t\t\t<AccessorTreeStateContext.Provider value={state}>\n\t\t\t\t<DirtinessContext.Provider value={stateData.hasUnpersistedChanges}>\n\t\t\t\t\t<MutationStateContext.Provider value={stateData.isMutating}>\n\t\t\t\t\t\t<BindingOperationsProvider bindingOperations={stateData.bindingOperations}>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</BindingOperationsProvider>\n\t\t\t\t\t</MutationStateContext.Provider>\n\t\t\t\t</DirtinessContext.Provider>\n\t\t\t</AccessorTreeStateContext.Provider>\n\t\t</EnvironmentContext.Provider>\n\t)\n}\n\nAccessorTree.displayName = 'AccessorTree'\n"],"names":["_jsx"],"mappings":";;;;;;AAY6B,sBAAA,EAAE,OAAO,YAA+B;AACpE,QAAM,YAAY,MAAM,SAAS,gBAAgB,MAAM,OAAO;AAAA,IAC7D,uBAAuB;AAAA,IACvB,YAAY;AAAA,IACZ,mBAAmB;AAAA,EAAA;AAGnB,SAAAA,8BAAC,mBAAmB,UAAnB;AAAA,IAA4B,OAAO,MAAM;AAAA,EAAA,GACzCA,8BAAC,yBAAyB,UAAzB;AAAA,IAAkC,OAAO;AAAA,EAAA,GACzCA,8BAAC,iBAAiB,UAAjB;AAAA,IAA0B,OAAO,UAAU;AAAA,EAAA,GAC3CA,8BAAC,qBAAqB,UAArB;AAAA,IAA8B,OAAO,UAAU;AAAA,EAAA,GAC9CA,8BAAA,2BAAA;AAAA,IAA0B,mBAAmB,UAAU;AAAA,EAAA,GACtD,QACF,CACD,CACD,CACD,CACD;AAEF;AAEA,aAAa,cAAc;;"}
@@ -0,0 +1,4 @@
1
+ import { createContext } from "react";
2
+ const AccessorTreeStateContext = createContext(void 0);
3
+ export { AccessorTreeStateContext };
4
+ //# sourceMappingURL=AccessorTreeStateContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccessorTreeStateContext.js","sources":["../../../src/accessorTree/AccessorTreeStateContext.ts"],"sourcesContent":["import { createContext } from 'react'\nimport { AccessorTreeState } from './AccessorTreeState'\n\nexport const AccessorTreeStateContext = createContext<AccessorTreeState | undefined>(undefined)\n"],"names":[],"mappings":";AAGa,MAAA,2BAA2B,cAA6C,MAAS;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizedPersistedData.js","sources":["../../../src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, PlaceholderName, Scalar } from '../treeParameters'\nimport type { ServerId, UniqueEntityId } from './RuntimeId'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n//\t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedData = Scalar | ServerId | EntityListPersistedData\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":"AAiBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;;"}
1
+ {"version":3,"file":"NormalizedPersistedData.js","sources":["../../../src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '../treeParameters'\nimport type { ServerId, UniqueEntityId } from './RuntimeId'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n//\t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedData = FieldValue | ServerId | EntityListPersistedData\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":"AAiBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;;"}
@@ -1,21 +1,30 @@
1
1
  const accessorTreeStateReducer = (previousState, action) => {
2
2
  switch (action.type) {
3
3
  case "setData":
4
- if (previousState.name === "error") {
4
+ if (previousState.name === "error" || previousState.binding !== action.binding) {
5
5
  return previousState;
6
6
  }
7
7
  return {
8
8
  name: "initialized",
9
+ environment: previousState.environment,
10
+ binding: previousState.binding,
9
11
  data: action.data
10
12
  };
11
13
  case "failWithError":
14
+ if (previousState.binding !== action.binding) {
15
+ return previousState;
16
+ }
12
17
  return {
13
18
  name: "error",
19
+ environment: previousState.environment,
20
+ binding: previousState.binding,
14
21
  error: action.error
15
22
  };
16
23
  case "reset":
17
24
  return {
18
- name: "initializing"
25
+ name: "initializing",
26
+ environment: action.environment,
27
+ binding: action.binding
19
28
  };
20
29
  }
21
30
  };
@@ -1 +1 @@
1
- {"version":3,"file":"accessorTreeStateReducer.js","sources":["../../../src/accessorTree/accessorTreeStateReducer.ts"],"sourcesContent":["import type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateAction } from './AccessorTreeStateAction'\n\nexport const accessorTreeStateReducer = (\n\tpreviousState: AccessorTreeState,\n\taction: AccessorTreeStateAction,\n): AccessorTreeState => {\n\tswitch (action.type) {\n\t\tcase 'setData':\n\t\t\tif (previousState.name === 'error') {\n\t\t\t\treturn previousState\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: 'initialized',\n\t\t\t\tdata: action.data,\n\t\t\t}\n\t\tcase 'failWithError':\n\t\t\treturn {\n\t\t\t\tname: 'error',\n\t\t\t\terror: action.error,\n\t\t\t}\n\t\tcase 'reset':\n\t\t\treturn {\n\t\t\t\tname: 'initializing',\n\t\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAGa,MAAA,2BAA2B,CACvC,eACA,WACuB;AACvB,UAAQ,OAAO;AAAA,SACT;AACA,UAAA,cAAc,SAAS,SAAS;AAC5B,eAAA;AAAA,MACR;AACO,aAAA;AAAA,QACN,MAAM;AAAA,QACN,MAAM,OAAO;AAAA,MAAA;AAAA,SAEV;AACG,aAAA;AAAA,QACN,MAAM;AAAA,QACN,OAAO,OAAO;AAAA,MAAA;AAAA,SAEX;AACG,aAAA;AAAA,QACN,MAAM;AAAA,MAAA;AAAA;AAGV;;"}
1
+ {"version":3,"file":"accessorTreeStateReducer.js","sources":["../../../src/accessorTree/accessorTreeStateReducer.ts"],"sourcesContent":["import type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateAction } from './AccessorTreeStateAction'\n\nexport const accessorTreeStateReducer = (\n\tpreviousState: AccessorTreeState,\n\taction: AccessorTreeStateAction,\n): AccessorTreeState => {\n\tswitch (action.type) {\n\t\tcase 'setData':\n\t\t\tif (previousState.name === 'error' || previousState.binding !== action.binding) {\n\t\t\t\treturn previousState\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: 'initialized',\n\t\t\t\tenvironment: previousState.environment,\n\t\t\t\tbinding: previousState.binding,\n\t\t\t\tdata: action.data,\n\t\t\t}\n\t\tcase 'failWithError':\n\t\t\tif (previousState.binding !== action.binding) {\n\t\t\t\treturn previousState\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tname: 'error',\n\t\t\t\tenvironment: previousState.environment,\n\t\t\t\tbinding: previousState.binding,\n\t\t\t\terror: action.error,\n\t\t\t}\n\t\tcase 'reset':\n\t\t\treturn {\n\t\t\t\tname: 'initializing',\n\t\t\t\tenvironment: action.environment,\n\t\t\t\tbinding: action.binding,\n\t\t\t}\n\t}\n}\n"],"names":[],"mappings":"AAGa,MAAA,2BAA2B,CACvC,eACA,WACuB;AACvB,UAAQ,OAAO;AAAA,SACT;AACJ,UAAI,cAAc,SAAS,WAAW,cAAc,YAAY,OAAO,SAAS;AACxE,eAAA;AAAA,MACR;AACO,aAAA;AAAA,QACN,MAAM;AAAA,QACN,aAAa,cAAc;AAAA,QAC3B,SAAS,cAAc;AAAA,QACvB,MAAM,OAAO;AAAA,MAAA;AAAA,SAEV;AACA,UAAA,cAAc,YAAY,OAAO,SAAS;AACtC,eAAA;AAAA,MACR;AACO,aAAA;AAAA,QACN,MAAM;AAAA,QACN,aAAa,cAAc;AAAA,QAC3B,SAAS,cAAc;AAAA,QACvB,OAAO,OAAO;AAAA,MAAA;AAAA,SAEX;AACG,aAAA;AAAA,QACN,MAAM;AAAA,QACN,aAAa,OAAO;AAAA,QACpB,SAAS,OAAO;AAAA,MAAA;AAAA;AAGpB;;"}
@@ -0,0 +1,12 @@
1
+ import { useContext } from "react";
2
+ import { AccessorTreeStateContext } from "./AccessorTreeStateContext.js";
3
+ import { BindingError } from "../BindingError.js";
4
+ const useAccessorTreeState = () => {
5
+ const state = useContext(AccessorTreeStateContext);
6
+ if (!state) {
7
+ throw new BindingError();
8
+ }
9
+ return state;
10
+ };
11
+ export { useAccessorTreeState };
12
+ //# sourceMappingURL=useAccessorTreeState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAccessorTreeState.js","sources":["../../../src/accessorTree/useAccessorTreeState.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { AccessorTreeStateContext } from './AccessorTreeStateContext'\nimport { BindingError } from '../BindingError'\n\nexport const useAccessorTreeState = () => {\n\tconst state = useContext(AccessorTreeStateContext)\n\tif (!state) {\n\t\tthrow new BindingError()\n\t}\n\treturn state\n}\n"],"names":[],"mappings":";;;AAIO,MAAM,uBAAuB,MAAM;AACnC,QAAA,QAAQ,WAAW,wBAAwB;AACjD,MAAI,CAAC,OAAO;AACX,UAAM,IAAI,aAAa;AAAA,EACxB;AACO,SAAA;AACR;;"}
@@ -1,71 +1,61 @@
1
1
  import { useCurrentContentGraphQlClient, useCurrentSystemGraphQlClient, useTenantGraphQlClient } from "@contember/react-client";
2
- import { useReducer, useRef, useCallback, useState, useEffect } from "react";
2
+ import { useRef, useState, useCallback, useReducer, useEffect } from "react";
3
3
  import { accessorTreeStateReducer } from "./accessorTreeStateReducer.js";
4
+ import { TreeStore } from "../core/TreeStore.js";
5
+ import { useIsMounted } from "@contember/react-utils";
4
6
  import { useEnvironment } from "../accessorPropagation/useEnvironment.js";
5
7
  import { DataBinding } from "../core/DataBinding.js";
6
- const initialState = {
7
- name: "initializing"
8
- };
8
+ import { SchemaLoader } from "../core/schema/SchemaLoader.js";
9
9
  const useDataBinding = ({
10
10
  nodeTree,
11
- refreshOnEnvironmentChange = true,
12
11
  refreshOnPersist = false
13
12
  }) => {
14
13
  const contentClient = useCurrentContentGraphQlClient();
15
14
  const systemClient = useCurrentSystemGraphQlClient();
16
15
  const tenantClient = useTenantGraphQlClient();
17
16
  const environment = useEnvironment();
18
- const [state, dispatch] = useReducer(accessorTreeStateReducer, initialState);
19
- const isFirstRenderRef = useRef(true);
20
- const isMountedRef = useRef(true);
21
- const onUpdate = useCallback((accessor) => {
22
- if (!isMountedRef.current) {
23
- return;
24
- }
25
- dispatch({
26
- type: "setData",
27
- data: accessor
28
- });
29
- }, []);
30
- const onError = useCallback((error) => {
31
- if (!isMountedRef.current) {
32
- return;
33
- }
34
- dispatch({
35
- type: "failWithError",
36
- error
37
- });
38
- }, []);
39
- const createDataBinding = useCallback(() => {
40
- const create = () => new DataBinding(contentClient, systemClient, tenantClient, environment, onUpdate, onError, () => {
41
- if (!isMountedRef.current || !refreshOnPersist) {
42
- return;
17
+ const currentTreeStore = useRef();
18
+ const isMountedRef = useIsMounted();
19
+ const [schema, setSchema] = useState();
20
+ const resetDataBinding = useCallback((environment2, newStore) => {
21
+ const onUpdate = (data, binding2) => {
22
+ if (isMountedRef.current) {
23
+ dispatch({ type: "setData", data, binding: binding2 });
43
24
  }
44
- dispatch({ type: "reset" });
45
- setDataBinding(create());
46
- });
47
- return create();
48
- }, [contentClient, systemClient, tenantClient, environment, onUpdate, onError, refreshOnPersist]);
49
- const [dataBinding, setDataBinding] = useState(() => createDataBinding());
50
- useEffect(() => {
51
- if (state.name !== "initializing") {
52
- return;
25
+ };
26
+ const onError = (error, binding2) => {
27
+ if (isMountedRef.current) {
28
+ dispatch({ type: "failWithError", error, binding: binding2 });
29
+ }
30
+ };
31
+ const onPersistSuccess = () => {
32
+ if (isMountedRef.current && refreshOnPersist) {
33
+ resetDataBinding(environment2, true);
34
+ }
35
+ };
36
+ if (currentTreeStore.current === void 0 || newStore) {
37
+ currentTreeStore.current = new TreeStore(environment2.getSchema());
53
38
  }
54
- dataBinding.extendTree(nodeTree);
55
- }, [nodeTree, dataBinding, state.name]);
39
+ const binding = new DataBinding(contentClient, systemClient, tenantClient, currentTreeStore.current, environment2, onUpdate, onError, onPersistSuccess);
40
+ dispatch({ type: "reset", binding, environment: environment2 });
41
+ }, [contentClient, systemClient, tenantClient, isMountedRef, refreshOnPersist]);
42
+ const [state, dispatch] = useReducer(accessorTreeStateReducer, {
43
+ name: "initializing",
44
+ environment
45
+ });
56
46
  useEffect(() => {
57
- if (isFirstRenderRef.current || !refreshOnEnvironmentChange) {
58
- return;
47
+ (async () => {
48
+ setSchema(await SchemaLoader.loadSchema(contentClient));
49
+ })();
50
+ }, [contentClient]);
51
+ useEffect(() => {
52
+ if (schema) {
53
+ resetDataBinding(environment.withSchema(schema), false);
59
54
  }
60
- dispatch({ type: "reset" });
61
- setDataBinding(createDataBinding());
62
- }, [createDataBinding, refreshOnEnvironmentChange]);
55
+ }, [resetDataBinding, schema, environment]);
63
56
  useEffect(() => {
64
- isFirstRenderRef.current = false;
65
- return () => {
66
- isMountedRef.current = false;
67
- };
68
- }, []);
57
+ state.binding?.extendTree(nodeTree);
58
+ }, [nodeTree, state.binding]);
69
59
  return state;
70
60
  };
71
61
  export { useDataBinding };
@@ -1 +1 @@
1
- {"version":3,"file":"useDataBinding.js","sources":["../../../src/accessorTree/useDataBinding.ts"],"sourcesContent":["import {\n\tuseCurrentContentGraphQlClient,\n\tuseCurrentSystemGraphQlClient,\n\tuseTenantGraphQlClient,\n} from '@contember/react-client'\nimport { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { TreeRootAccessor } from '../accessors'\nimport { DataBinding } from '../core'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateOptions } from './AccessorTreeStateOptions'\nimport { accessorTreeStateReducer } from './accessorTreeStateReducer'\nimport type { RequestError } from './RequestError'\n\nconst initialState: AccessorTreeState = {\n\tname: 'initializing',\n}\n\nexport const useDataBinding = ({\n\tnodeTree,\n\trefreshOnEnvironmentChange = true,\n\trefreshOnPersist = false,\n}: AccessorTreeStateOptions): AccessorTreeState => {\n\tconst contentClient = useCurrentContentGraphQlClient()\n\tconst systemClient = useCurrentSystemGraphQlClient()\n\tconst tenantClient = useTenantGraphQlClient()\n\tconst environment = useEnvironment()\n\n\tconst [state, dispatch] = useReducer(accessorTreeStateReducer, initialState)\n\n\tconst isFirstRenderRef = useRef(true)\n\tconst isMountedRef = useRef(true)\n\n\tconst onUpdate = useCallback((accessor: TreeRootAccessor) => {\n\t\tif (!isMountedRef.current) {\n\t\t\treturn\n\t\t}\n\t\tdispatch({\n\t\t\ttype: 'setData',\n\t\t\tdata: accessor,\n\t\t})\n\t}, [])\n\tconst onError = useCallback((error: RequestError) => {\n\t\tif (!isMountedRef.current) {\n\t\t\treturn\n\t\t}\n\t\tdispatch({\n\t\t\ttype: 'failWithError',\n\t\t\terror,\n\t\t})\n\t}, [])\n\n\tconst createDataBinding = useCallback(\n\t\t() => {\n\t\t\tconst create = (): DataBinding => new DataBinding(contentClient, systemClient, tenantClient, environment, onUpdate, onError, () => {\n\t\t\t\tif (!isMountedRef.current || !refreshOnPersist) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tdispatch({ type: 'reset' })\n\t\t\t\tsetDataBinding(create())\n\t\t\t})\n\t\t\treturn create()\n\t\t},\n\t\t[contentClient, systemClient, tenantClient, environment, onUpdate, onError, refreshOnPersist],\n\t)\n\n\tconst [dataBinding, setDataBinding] = useState(() => createDataBinding())\n\n\tuseEffect(() => {\n\t\tif (state.name !== 'initializing') {\n\t\t\t// Ideally, this condition shouldn't be necessary. However, people are nowhere near careful and diligent\n\t\t\t// enough to maintain the contract that a change in referential identity of the children passed to\n\t\t\t// DataBindingProvider will result in a new DataBinding instance (which typically involves a new query).\n\t\t\t// To make their lives a bit easier, we do this.\n\t\t\treturn\n\t\t}\n\t\tdataBinding.extendTree(nodeTree)\n\t}, [nodeTree, dataBinding, state.name])\n\n\tuseEffect(() => {\n\t\tif (isFirstRenderRef.current || !refreshOnEnvironmentChange) {\n\t\t\treturn\n\t\t}\n\t\tdispatch({ type: 'reset' })\n\t\t// This essentially just reacts to new environments.\n\t\tsetDataBinding(createDataBinding())\n\t}, [createDataBinding, refreshOnEnvironmentChange])\n\n\tuseEffect(() => {\n\t\tisFirstRenderRef.current = false\n\n\t\treturn () => {\n\t\t\tisMountedRef.current = false\n\t\t}\n\t}, [])\n\n\treturn state\n}\n"],"names":[],"mappings":";;;;;AAcA,MAAM,eAAkC;AAAA,EACvC,MAAM;AACP;AAEO,MAAM,iBAAiB,CAAC;AAAA,EAC9B;AAAA,EACA,6BAA6B;AAAA,EAC7B,mBAAmB;AAAA,MAC+B;AAClD,QAAM,gBAAgB;AACtB,QAAM,eAAe;AACrB,QAAM,eAAe;AACrB,QAAM,cAAc;AAEpB,QAAM,CAAC,OAAO,YAAY,WAAW,0BAA0B,YAAY;AAErE,QAAA,mBAAmB,OAAO,IAAI;AAC9B,QAAA,eAAe,OAAO,IAAI;AAE1B,QAAA,WAAW,YAAY,CAAC,aAA+B;AACxD,QAAA,CAAC,aAAa,SAAS;AAC1B;AAAA,IACD;AACS,aAAA;AAAA,MACR,MAAM;AAAA,MACN,MAAM;AAAA,IAAA,CACN;AAAA,EACF,GAAG,CAAE,CAAA;AACC,QAAA,UAAU,YAAY,CAAC,UAAwB;AAChD,QAAA,CAAC,aAAa,SAAS;AAC1B;AAAA,IACD;AACS,aAAA;AAAA,MACR,MAAM;AAAA,MACN;AAAA,IAAA,CACA;AAAA,EACF,GAAG,CAAE,CAAA;AAEC,QAAA,oBAAoB,YACzB,MAAM;AACC,UAAA,SAAS,MAAmB,IAAI,YAAY,eAAe,cAAc,cAAc,aAAa,UAAU,SAAS,MAAM;AAClI,UAAI,CAAC,aAAa,WAAW,CAAC,kBAAkB;AAC/C;AAAA,MACD;AACS,eAAA,EAAE,MAAM,QAAA,CAAS;AAC1B,qBAAe,QAAQ;AAAA,IAAA,CACvB;AACD,WAAO,OAAO;AAAA,EAAA,GAEf,CAAC,eAAe,cAAc,cAAc,aAAa,UAAU,SAAS,gBAAgB,CAC7F;AAEA,QAAM,CAAC,aAAa,kBAAkB,SAAS,MAAM,mBAAmB;AAExE,YAAU,MAAM;AACX,QAAA,MAAM,SAAS,gBAAgB;AAKlC;AAAA,IACD;AACA,gBAAY,WAAW,QAAQ;AAAA,KAC7B,CAAC,UAAU,aAAa,MAAM,IAAI,CAAC;AAEtC,YAAU,MAAM;AACX,QAAA,iBAAiB,WAAW,CAAC,4BAA4B;AAC5D;AAAA,IACD;AACS,aAAA,EAAE,MAAM,QAAA,CAAS;AAE1B,mBAAe,mBAAmB;AAAA,EAAA,GAChC,CAAC,mBAAmB,0BAA0B,CAAC;AAElD,YAAU,MAAM;AACf,qBAAiB,UAAU;AAE3B,WAAO,MAAM;AACZ,mBAAa,UAAU;AAAA,IAAA;AAAA,EAEzB,GAAG,CAAE,CAAA;AAEE,SAAA;AACR;;"}
1
+ {"version":3,"file":"useDataBinding.js","sources":["../../../src/accessorTree/useDataBinding.ts"],"sourcesContent":["import {\n\tuseCurrentContentGraphQlClient,\n\tuseCurrentSystemGraphQlClient,\n\tuseTenantGraphQlClient,\n} from '@contember/react-client'\nimport { useCallback, useEffect, useReducer, useRef, useState } from 'react'\nimport { useEnvironment } from '../accessorPropagation'\nimport type { TreeRootAccessor } from '../accessors'\nimport { DataBinding } from '../core'\nimport type { AccessorTreeState } from './AccessorTreeState'\nimport type { AccessorTreeStateOptions } from './AccessorTreeStateOptions'\nimport { accessorTreeStateReducer } from './accessorTreeStateReducer'\nimport type { RequestError } from './RequestError'\nimport { Environment } from '../dao'\nimport { Schema, SchemaLoader } from '../core/schema'\nimport { TreeStore } from '../core/TreeStore'\nimport { useIsMounted } from '@contember/react-utils'\n\nexport const useDataBinding = ({\n\tnodeTree,\n\trefreshOnPersist = false,\n}: AccessorTreeStateOptions): AccessorTreeState => {\n\tconst contentClient = useCurrentContentGraphQlClient()\n\tconst systemClient = useCurrentSystemGraphQlClient()\n\tconst tenantClient = useTenantGraphQlClient()\n\tconst environment = useEnvironment()\n\tconst currentTreeStore = useRef<TreeStore>()\n\tconst isMountedRef = useIsMounted()\n\tconst [schema, setSchema] = useState<Schema>()\n\n\tconst resetDataBinding = useCallback((environment: Environment, newStore: boolean) => {\n\t\tconst onUpdate = (data: TreeRootAccessor, binding: DataBinding) => {\n\t\t\tif (isMountedRef.current) {\n\t\t\t\tdispatch({ type: 'setData', data, binding })\n\t\t\t}\n\t\t}\n\n\t\tconst onError = (error: RequestError, binding: DataBinding) => {\n\t\t\tif (isMountedRef.current) {\n\t\t\t\tdispatch({ type: 'failWithError', error, binding })\n\t\t\t}\n\t\t}\n\n\t\tconst onPersistSuccess = () => {\n\t\t\tif (isMountedRef.current && refreshOnPersist) {\n\t\t\t\tresetDataBinding(environment, true)\n\t\t\t}\n\t\t}\n\n\t\tif (currentTreeStore.current === undefined || newStore) {\n\t\t\tcurrentTreeStore.current = new TreeStore(environment.getSchema())\n\t\t}\n\n\t\tconst binding = new DataBinding(contentClient, systemClient, tenantClient, currentTreeStore.current, environment, onUpdate, onError, onPersistSuccess)\n\t\tdispatch({ type: 'reset', binding, environment })\n\t}, [contentClient, systemClient, tenantClient, isMountedRef, refreshOnPersist])\n\n\tconst [state, dispatch] = useReducer(accessorTreeStateReducer, {\n\t\tname: 'initializing',\n\t\tenvironment,\n\t})\n\n\tuseEffect(() => {\n\t\t(async () => {\n\t\t\tsetSchema(await SchemaLoader.loadSchema(contentClient))\n\t\t})()\n\t}, [contentClient])\n\n\tuseEffect(() => {\n\t\tif (schema) {\n\t\t\tresetDataBinding(environment.withSchema(schema), false)\n\t\t}\n\t}, [resetDataBinding, schema, environment])\n\n\tuseEffect(() => {\n\t\tstate.binding?.extendTree(nodeTree)\n\t}, [nodeTree, state.binding])\n\n\treturn state\n}\n"],"names":[],"mappings":";;;;;;;;AAkBO,MAAM,iBAAiB,CAAC;AAAA,EAC9B;AAAA,EACA,mBAAmB;AAAA,MAC+B;AAClD,QAAM,gBAAgB;AACtB,QAAM,eAAe;AACrB,QAAM,eAAe;AACrB,QAAM,cAAc;AACpB,QAAM,mBAAmB;AACzB,QAAM,eAAe;AACf,QAAA,CAAC,QAAQ,aAAa,SAAiB;AAE7C,QAAM,mBAAmB,YAAY,CAAC,cAA0B,aAAsB;AAC/E,UAAA,WAAW,CAAC,MAAwB,aAAyB;AAClE,UAAI,aAAa,SAAS;AACzB,iBAAS,EAAE,MAAM,WAAW,MAAM,mBAAS;AAAA,MAC5C;AAAA,IAAA;AAGK,UAAA,UAAU,CAAC,OAAqB,aAAyB;AAC9D,UAAI,aAAa,SAAS;AACzB,iBAAS,EAAE,MAAM,iBAAiB,OAAO,mBAAS;AAAA,MACnD;AAAA,IAAA;AAGD,UAAM,mBAAmB,MAAM;AAC1B,UAAA,aAAa,WAAW,kBAAkB;AAC7C,yBAAiB,cAAa,IAAI;AAAA,MACnC;AAAA,IAAA;AAGG,QAAA,iBAAiB,YAAY,UAAa,UAAU;AACvD,uBAAiB,UAAU,IAAI,UAAU,aAAY,UAAW,CAAA;AAAA,IACjE;AAEM,UAAA,UAAU,IAAI,YAAY,eAAe,cAAc,cAAc,iBAAiB,SAAS,cAAa,UAAU,SAAS,gBAAgB;AACrJ,aAAS,EAAE,MAAM,SAAS,SAAS,2BAAa;AAAA,EAAA,GAC9C,CAAC,eAAe,cAAc,cAAc,cAAc,gBAAgB,CAAC;AAE9E,QAAM,CAAC,OAAO,YAAY,WAAW,0BAA0B;AAAA,IAC9D,MAAM;AAAA,IACN;AAAA,EAAA,CACA;AAED,YAAU,MAAM;AACd,IAAY,aAAA;AACZ,gBAAU,MAAM,aAAa,WAAW,aAAa,CAAC;AAAA,IAAA;EACpD,GACD,CAAC,aAAa,CAAC;AAElB,YAAU,MAAM;AACf,QAAI,QAAQ;AACX,uBAAiB,YAAY,WAAW,MAAM,GAAG,KAAK;AAAA,IACvD;AAAA,EACE,GAAA,CAAC,kBAAkB,QAAQ,WAAW,CAAC;AAE1C,YAAU,MAAM;AACT,UAAA,SAAS,WAAW,QAAQ;AAAA,EAChC,GAAA,CAAC,UAAU,MAAM,OAAO,CAAC;AAErB,SAAA;AACR;;"}
@@ -43,10 +43,10 @@ class AccessorErrorManager {
43
43
  this.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE);
44
44
  });
45
45
  }
46
- replaceErrors(data) {
46
+ replaceErrors(data, operations) {
47
47
  this.eventManager.syncOperation(() => {
48
48
  this.clearErrors();
49
- const preprocessor = new ErrorsPreprocessor(data);
49
+ const preprocessor = new ErrorsPreprocessor(data, operations);
50
50
  const errorTreeRoot = preprocessor.preprocess();
51
51
  this.setRootStateErrors(errorTreeRoot);
52
52
  this.dumpErrorData(data);
@@ -1 +1 @@
1
- {"version":3,"file":"AccessorErrorManager.js","sources":["../../../src/core/AccessorErrorManager.ts"],"sourcesContent":["import { ErrorAccessor } from '../accessors'\nimport type { ExecutionError, MutationDataResponse, ValidationError } from '../accessorTree'\nimport { ErrorsPreprocessor } from './ErrorsPreprocessor'\nimport { EventManager } from './EventManager'\nimport { EntityListState, EntityRealmState, getEntityMarker, StateNode } from './state'\nimport type { TreeStore } from './TreeStore'\n\nexport class AccessorErrorManager {\n\tprivate errorsByState: Map<StateNode, ErrorAccessor.ErrorsById> = new Map()\n\n\tprivate getNewErrorId = (() => {\n\t\tlet errorId = 1\n\n\t\treturn () => errorId++\n\t})()\n\n\tpublic constructor(private readonly eventManager: EventManager, private readonly treeStore: TreeStore) {}\n\n\tpublic hasErrors() {\n\t\treturn !!this.errorsByState.size\n\t}\n\n\tpublic getErrors(): ErrorAccessor.Error[] {\n\t\treturn Array.from(this.errorsByState.values(), it => Array.from(it.values())).flat()\n\t}\n\n\tpublic clearErrors() {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tfor (const [stateNode] of this.errorsByState) {\n\t\t\t\tstateNode.errors = undefined\n\t\t\t\tthis.eventManager.registerJustUpdated(stateNode, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\tthis.errorsByState.clear()\n\t\t})\n\t}\n\n\tpublic clearErrorsByState(state: StateNode): void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tif (!this.errorsByState.has(state)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errorsByState.delete(state)\n\t\t\tstate.errors = undefined\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t})\n\t}\n\n\tpublic replaceErrors(data: MutationDataResponse) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.clearErrors()\n\n\t\t\tconst preprocessor = new ErrorsPreprocessor(data)\n\t\t\tconst errorTreeRoot = preprocessor.preprocess()\n\n\t\t\tthis.setRootStateErrors(errorTreeRoot)\n\n\t\t\tthis.dumpErrorData(data)\n\t\t})\n\t}\n\n\tpublic addError(state: StateNode, error: ErrorAccessor.Error): () => void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tconst errorId = this.getNewErrorId()\n\n\t\t\tlet errorsById: ErrorAccessor.ErrorsById | undefined = this.errorsByState.get(state)\n\t\t\tif (errorsById === undefined) {\n\t\t\t\tthis.errorsByState.set(state, (errorsById = new Map()))\n\t\t\t}\n\t\t\terrorsById.set(errorId, error)\n\t\t\tstate.errors = new ErrorAccessor(Array.from(errorsById.values()))\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\n\t\t\treturn () =>\n\t\t\t\tthis.eventManager.syncOperation(() => {\n\t\t\t\t\tconst errorsById = this.errorsByState.get(state)\n\t\t\t\t\tif (errorsById === undefined) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terrorsById.delete(errorId)\n\t\t\t\t\tif (errorsById.size) {\n\t\t\t\t\t\tstate.errors = new ErrorAccessor(Array.from(errorsById.values()))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.errors = undefined\n\t\t\t\t\t\tthis.errorsByState.delete(state)\n\t\t\t\t\t}\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t})\n\t\t})\n\t}\n\n\tprivate addSeveralErrors(state: StateNode, errors: ErrorsPreprocessor.BaseErrorNode) {\n\t\tif (errors.validation) {\n\t\t\tfor (const error of errors.validation) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t\tif (errors.execution) {\n\t\t\tfor (const error of errors.execution) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setRootStateErrors(errorTreeRoot: ErrorsPreprocessor.ErrorTreeRoot) {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [subTreePlaceholder, rootError] of errorTreeRoot) {\n\t\t\t\tconst rootState = rootStates.get(subTreePlaceholder)\n\n\t\t\t\tif (!rootState) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (rootState.type) {\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tthis.setEntityStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tthis.setEntityListStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityStateErrors(\n\t\tstate: EntityRealmState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, child] of errors.children) {\n\t\t\tif (typeof childKey !== 'string') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.nodeType === 'leaf') {\n\t\t\t\tconst fieldState = state.children.get(childKey)\n\n\t\t\t\tif (fieldState?.type === 'field') {\n\t\t\t\t\tthis.addSeveralErrors(fieldState, child)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Deliberately letting flow get here as well. Leaf errors *CAN* refer to relations as well.\n\n\t\t\tconst fields = getEntityMarker(state).fields\n\t\t\tconst placeholders = fields.placeholders.get(childKey)\n\t\t\tif (placeholders === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst normalizedPlaceholders = typeof placeholders === 'string' ? new Set([placeholders]) : placeholders\n\n\t\t\tfor (const normalizedPlaceholder of normalizedPlaceholders) {\n\t\t\t\tconst fieldState = state.children.get(normalizedPlaceholder)\n\t\t\t\tif (fieldState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\tthis.setEntityListStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityListStateErrors(\n\t\tstate: EntityListState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, childError] of errors.children) {\n\t\t\tlet childState = state.children.get(childKey)\n\n\t\t\tif (childState === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\tchildState.getAccessor() // Force init\n\t\t\t\tchildState = state.children.get(childKey)!\n\t\t\t}\n\n\t\t\tif (childError.nodeType === 'iNode') {\n\t\t\t\tthis.setEntityStateErrors(childState as EntityRealmState, childError)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dumpErrorData(data: MutationDataResponse) {\n\t\t// TODO this is just temporary\n\t\tfor (const subTreePlaceholder in data) {\n\t\t\tconst treeDatum = data[subTreePlaceholder]\n\t\t\tconst executionErrors: Array<ExecutionError | ValidationError> = treeDatum.errors\n\t\t\tconst allErrors = treeDatum?.validation?.errors\n\t\t\t\t? executionErrors.concat(treeDatum.validation.errors)\n\t\t\t\t: executionErrors\n\t\t\tconst normalizedErrors = allErrors.map((error: ExecutionError | ValidationError) => {\n\t\t\t\treturn {\n\t\t\t\t\tpath: error.path\n\t\t\t\t\t\t.map(pathPart => {\n\t\t\t\t\t\t\tif (pathPart.__typename === '_FieldPathFragment') {\n\t\t\t\t\t\t\t\treturn pathPart.field\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (pathPart.alias) {\n\t\t\t\t\t\t\t\treturn `#${pathPart.index}(${pathPart.alias})`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn pathPart.index\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('.'),\n\t\t\t\t\ttype: 'type' in error ? error.type : undefined,\n\t\t\t\t\tmessage: typeof error.message === 'string' ? error.message : error.message?.text,\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (Object.keys(normalizedErrors).length) {\n\t\t\t\tconsole.table(normalizedErrors)\n\t\t\t}\n\t\t\tif (treeDatum.errorMessage) {\n\t\t\t\tconsole.error(treeDatum.errorMessage)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;AAOO,MAAM,qBAAqB;AAAA,EAS1B,YAA6B,cAA6C,WAAsB;AAR/F,6DAA8D;AAE9D,yCAAuB,OAAA;AAC9B,UAAI,UA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AEQ,cAAc,MAA4B;AAEjD,eAAW,sBAAsB,MAAM;AACtC,YAAM,YAAY,KAAK;AACvB,YAAM,kBAA2D,UAAU;AACrE,YAAA,YAAY,WAAW,YAAY,SACtC,gBAAgB,OAAO,UAAU,WAAW,MAAM,IAClD;AACH,YAAM,mBAAmB,UAAU,IAAI,CAAC,UAA4C;AAC5E,eAAA;AAAA,UACN,MAAM,MAAM,KACV,IAAI,CAAY,aAAA;AACZ,gBAAA,SAAS,eAAe,sBAAsB;AACjD,qBAAO,SAAS;AAAA,YACjB;AACA,gBAAI,SAAS,OAAO;AACZ,qBAAA,IAAI,SAAS,SAAS,SAAS;AAAA,YACvC;AACA,mBAAO,SAAS;AAAA,UAAA,CAChB,EACA,KAAK,GAAG;AAAA,UACV,MAAM,UAAU,QAAQ,MAAM,OAAO;AAAA,UACrC,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,UAAU,MAAM,SAAS;AAAA,QAAA;AAAA,MAC7E,CACA;AACD,UAAI,OAAO,KAAK,gBAAgB,EAAE,QAAQ;AACzC,gBAAQ,MAAM,gBAAgB;AAAA,MAC/B;AACA,UAAI,UAAU,cAAc;AACnB,gBAAA,MAAM,UAAU,YAAY;AAAA,MACrC;AAAA,IACD;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"AccessorErrorManager.js","sources":["../../../src/core/AccessorErrorManager.ts"],"sourcesContent":["import { ErrorAccessor } from '../accessors'\nimport type { ExecutionError, MutationDataResponse, ValidationError } from '../accessorTree'\nimport { ErrorsPreprocessor } from './ErrorsPreprocessor'\nimport { EventManager } from './EventManager'\nimport { EntityListState, EntityRealmState, getEntityMarker, StateNode } from './state'\nimport type { TreeStore } from './TreeStore'\nimport { SubMutationOperation } from './MutationGenerator'\n\nexport class AccessorErrorManager {\n\tprivate errorsByState: Map<StateNode, ErrorAccessor.ErrorsById> = new Map()\n\n\tprivate getNewErrorId = (() => {\n\t\tlet errorId = 1\n\n\t\treturn () => errorId++\n\t})()\n\n\tpublic constructor(private readonly eventManager: EventManager, private readonly treeStore: TreeStore) {}\n\n\tpublic hasErrors() {\n\t\treturn !!this.errorsByState.size\n\t}\n\n\tpublic getErrors(): ErrorAccessor.Error[] {\n\t\treturn Array.from(this.errorsByState.values(), it => Array.from(it.values())).flat()\n\t}\n\n\tpublic clearErrors() {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tfor (const [stateNode] of this.errorsByState) {\n\t\t\t\tstateNode.errors = undefined\n\t\t\t\tthis.eventManager.registerJustUpdated(stateNode, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\tthis.errorsByState.clear()\n\t\t})\n\t}\n\n\tpublic clearErrorsByState(state: StateNode): void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tif (!this.errorsByState.has(state)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errorsByState.delete(state)\n\t\t\tstate.errors = undefined\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t})\n\t}\n\n\tpublic replaceErrors(data: MutationDataResponse, operations: SubMutationOperation[]) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.clearErrors()\n\n\t\t\tconst preprocessor = new ErrorsPreprocessor(data, operations)\n\t\t\tconst errorTreeRoot = preprocessor.preprocess()\n\n\t\t\tthis.setRootStateErrors(errorTreeRoot)\n\n\t\t\tthis.dumpErrorData(data)\n\t\t})\n\t}\n\n\tpublic addError(state: StateNode, error: ErrorAccessor.Error): () => void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tconst errorId = this.getNewErrorId()\n\n\t\t\tlet errorsById: ErrorAccessor.ErrorsById | undefined = this.errorsByState.get(state)\n\t\t\tif (errorsById === undefined) {\n\t\t\t\tthis.errorsByState.set(state, (errorsById = new Map()))\n\t\t\t}\n\t\t\terrorsById.set(errorId, error)\n\t\t\tstate.errors = new ErrorAccessor(Array.from(errorsById.values()))\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\n\t\t\treturn () =>\n\t\t\t\tthis.eventManager.syncOperation(() => {\n\t\t\t\t\tconst errorsById = this.errorsByState.get(state)\n\t\t\t\t\tif (errorsById === undefined) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terrorsById.delete(errorId)\n\t\t\t\t\tif (errorsById.size) {\n\t\t\t\t\t\tstate.errors = new ErrorAccessor(Array.from(errorsById.values()))\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.errors = undefined\n\t\t\t\t\t\tthis.errorsByState.delete(state)\n\t\t\t\t\t}\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t})\n\t\t})\n\t}\n\n\tprivate addSeveralErrors(state: StateNode, errors: ErrorsPreprocessor.BaseErrorNode) {\n\t\tif (errors.validation) {\n\t\t\tfor (const error of errors.validation) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t\tif (errors.execution) {\n\t\t\tfor (const error of errors.execution) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setRootStateErrors(errorTreeRoot: ErrorsPreprocessor.ErrorTreeRoot) {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [subTreePlaceholder, rootError] of errorTreeRoot) {\n\t\t\t\tconst rootState = rootStates.get(subTreePlaceholder)\n\n\t\t\t\tif (!rootState) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (rootState.type) {\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tthis.setEntityStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tthis.setEntityListStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityStateErrors(\n\t\tstate: EntityRealmState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, child] of errors.children) {\n\t\t\tif (typeof childKey !== 'string') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.nodeType === 'leaf') {\n\t\t\t\tconst fieldState = state.children.get(childKey)\n\n\t\t\t\tif (fieldState?.type === 'field') {\n\t\t\t\t\tthis.addSeveralErrors(fieldState, child)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Deliberately letting flow get here as well. Leaf errors *CAN* refer to relations as well.\n\n\t\t\tconst fields = getEntityMarker(state).fields\n\t\t\tconst placeholders = fields.placeholders.get(childKey)\n\t\t\tif (placeholders === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst normalizedPlaceholders = typeof placeholders === 'string' ? new Set([placeholders]) : placeholders\n\n\t\t\tfor (const normalizedPlaceholder of normalizedPlaceholders) {\n\t\t\t\tconst fieldState = state.children.get(normalizedPlaceholder)\n\t\t\t\tif (fieldState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\tthis.setEntityListStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityListStateErrors(\n\t\tstate: EntityListState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, childError] of errors.children) {\n\t\t\tlet childState = state.children.get(childKey)\n\n\t\t\tif (childState === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\tchildState.getAccessor() // Force init\n\t\t\t\tchildState = state.children.get(childKey)!\n\t\t\t}\n\n\t\t\tif (childError.nodeType === 'iNode') {\n\t\t\t\tthis.setEntityStateErrors(childState as EntityRealmState, childError)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dumpErrorData(data: MutationDataResponse) {\n\t\t// TODO this is just temporary\n\t\tfor (const subTreePlaceholder in data) {\n\t\t\tconst treeDatum = data[subTreePlaceholder]\n\t\t\tconst executionErrors: Array<ExecutionError | ValidationError> = treeDatum.errors\n\t\t\tconst allErrors = treeDatum?.validation?.errors\n\t\t\t\t? executionErrors.concat(treeDatum.validation.errors)\n\t\t\t\t: executionErrors\n\t\t\tconst normalizedErrors = allErrors.map((error: ExecutionError | ValidationError) => {\n\t\t\t\treturn {\n\t\t\t\t\tpath: error.path\n\t\t\t\t\t\t.map(pathPart => {\n\t\t\t\t\t\t\tif (pathPart.__typename === '_FieldPathFragment') {\n\t\t\t\t\t\t\t\treturn pathPart.field\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (pathPart.alias) {\n\t\t\t\t\t\t\t\treturn `#${pathPart.index}(${pathPart.alias})`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn pathPart.index\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('.'),\n\t\t\t\t\ttype: 'type' in error ? error.type : undefined,\n\t\t\t\t\tmessage: typeof error.message === 'string' ? error.message : error.message?.text,\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (Object.keys(normalizedErrors).length) {\n\t\t\t\tconsole.table(normalizedErrors)\n\t\t\t}\n\t\t\tif (treeDatum.errorMessage) {\n\t\t\t\tconsole.error(treeDatum.errorMessage)\n\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AAC1C,mBAAW,YAAY;AACV,qBAAA,MAAM,SAAS,IAAI,QAAQ;AAAA,MACzC;AAEI,UAAA,WAAW,aAAa,SAAS;AAC/B,aAAA,qBAAqB,YAAgC,UAAU;AAAA,MACrE;AAAA,IACD;AAAA,EACD;AAAA,EAEQ,cAAc,MAA4B;AAEjD,eAAW,sBAAsB,MAAM;AACtC,YAAM,YAAY,KAAK;AACvB,YAAM,kBAA2D,UAAU;AACrE,YAAA,YAAY,WAAW,YAAY,SACtC,gBAAgB,OAAO,UAAU,WAAW,MAAM,IAClD;AACH,YAAM,mBAAmB,UAAU,IAAI,CAAC,UAA4C;AAC5E,eAAA;AAAA,UACN,MAAM,MAAM,KACV,IAAI,CAAY,aAAA;AACZ,gBAAA,SAAS,eAAe,sBAAsB;AACjD,qBAAO,SAAS;AAAA,YACjB;AACA,gBAAI,SAAS,OAAO;AACZ,qBAAA,IAAI,SAAS,SAAS,SAAS;AAAA,YACvC;AACA,mBAAO,SAAS;AAAA,UAAA,CAChB,EACA,KAAK,GAAG;AAAA,UACV,MAAM,UAAU,QAAQ,MAAM,OAAO;AAAA,UACrC,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,UAAU,MAAM,SAAS;AAAA,QAAA;AAAA,MAC7E,CACA;AACD,UAAI,OAAO,KAAK,gBAAgB,EAAE,QAAQ;AACzC,gBAAQ,MAAM,gBAAgB;AAAA,MAC/B;AACA,UAAI,UAAU,cAAc;AACnB,gBAAA,MAAM,UAAU,YAAY;AAAA,MACrC;AAAA,IACD;AAAA,EACD;AACD;;"}
@@ -25,8 +25,7 @@ __publicField(Config, "defaultConfig", {
25
25
  beforePersistSettleLimit: 20,
26
26
  beforeUpdateSettleLimit: 20,
27
27
  persistSuccessSettleLimit: 20,
28
- maxPersistAttempts: 5,
29
- maxSchemaLoadAttempts: 3
28
+ maxPersistAttempts: 5
30
29
  });
31
30
  export { Config };
32
31
  //# sourceMappingURL=Config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Config.js","sources":["../../../src/core/Config.ts"],"sourcesContent":["import type { BindingConfig } from '../accessors'\n\nexport class Config {\n\tprivate static defaultConfig: BindingConfig = {\n\t\tbeforePersistSettleLimit: 20,\n\t\tbeforeUpdateSettleLimit: 20,\n\t\tpersistSuccessSettleLimit: 20,\n\t\tmaxPersistAttempts: 5,\n\t\tmaxSchemaLoadAttempts: 3,\n\t}\n\n\tprivate readonly config: BindingConfig\n\n\tpublic constructor(config: Partial<BindingConfig> = {}) {\n\t\tthis.config = {\n\t\t\t...Config.defaultConfig,\n\t\t\t...config,\n\t\t}\n\t}\n\n\tpublic getValue<Name extends keyof BindingConfig>(name: Name): BindingConfig[Name] {\n\t\treturn this.config[name]\n\t}\n\n\tpublic setValue<Name extends keyof BindingConfig>(name: Name, value: BindingConfig[Name]): this {\n\t\tthis.config[name] = value\n\t\treturn this\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAEO,sBAAa;AAAA,EAWZ,YAAY,SAAiC,IAAI;AAFvC;AAGhB,SAAK,SAAS;AAAA,SACV,QAAO;AAAA,SACP;AAAA,IAAA;AAAA,EAEL;AAAA,EAEO,SAA2C,MAAiC;AAClF,WAAO,KAAK,OAAO;AAAA,EACpB;AAAA,EAEO,SAA2C,MAAY,OAAkC;AAC/F,SAAK,OAAO,QAAQ;AACb,WAAA;AAAA,EACR;AACD;AA1BO;AACS,cADT,QACS,iBAA+B;AAAA,EAC7C,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA;;"}
1
+ {"version":3,"file":"Config.js","sources":["../../../src/core/Config.ts"],"sourcesContent":["import type { BindingConfig } from '../accessors'\n\nexport class Config {\n\tprivate static defaultConfig: BindingConfig = {\n\t\tbeforePersistSettleLimit: 20,\n\t\tbeforeUpdateSettleLimit: 20,\n\t\tpersistSuccessSettleLimit: 20,\n\t\tmaxPersistAttempts: 5,\n\t}\n\n\tprivate readonly config: BindingConfig\n\n\tpublic constructor(config: Partial<BindingConfig> = {}) {\n\t\tthis.config = {\n\t\t\t...Config.defaultConfig,\n\t\t\t...config,\n\t\t}\n\t}\n\n\tpublic getValue<Name extends keyof BindingConfig>(name: Name): BindingConfig[Name] {\n\t\treturn this.config[name]\n\t}\n\n\tpublic setValue<Name extends keyof BindingConfig>(name: Name, value: BindingConfig[Name]): this {\n\t\tthis.config[name] = value\n\t\treturn this\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAEO,sBAAa;AAAA,EAUZ,YAAY,SAAiC,IAAI;AAFvC;AAGhB,SAAK,SAAS;AAAA,SACV,QAAO;AAAA,SACP;AAAA,IAAA;AAAA,EAEL;AAAA,EAEO,SAA2C,MAAiC;AAClF,WAAO,KAAK,OAAO;AAAA,EACpB;AAAA,EAEO,SAA2C,MAAY,OAAkC;AAC/F,SAAK,OAAO,QAAQ;AACb,WAAA;AAAA,EACR;AACD;AAzBO;AACS,cADT,QACS,iBAA+B;AAAA,EAC7C,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA;;"}
@@ -15,17 +15,15 @@ import { QueryGenerator } from "./QueryGenerator.js";
15
15
  import { StateInitializer } from "./StateInitializer.js";
16
16
  import { TreeAugmenter } from "./TreeAugmenter.js";
17
17
  import { TreeFilterGenerator } from "./TreeFilterGenerator.js";
18
- import { TreeStore } from "./TreeStore.js";
19
18
  import { createBatchUpdatesOptions } from "./factories/createBatchUpdatesOptions.js";
20
19
  import { TreeRootAccessor } from "../accessors/TreeRootAccessor.js";
21
20
  import { getCombinedSignal } from "./utils/getCombinedSignal.js";
22
21
  import { metadataToRequestError } from "../accessorTree/metadataToRequestError.js";
23
- import { SchemaLoader } from "./schema/SchemaLoader.js";
24
22
  import { StateIterator } from "./state/StateIterator.js";
25
23
  import { assertNever } from "../utils/assertNever.js";
26
24
  import { generateEnumerabilityPreventingEntropy } from "../utils/generateEnumerabilityPreventingEntropy.js";
27
25
  const _DataBinding = class {
28
- constructor(contentApiClient, systemApiClient, tenantApiClient, environment, onUpdate, onError, onPersistSuccess) {
26
+ constructor(contentApiClient, systemApiClient, tenantApiClient, treeStore, environment, onUpdate, onError, onPersistSuccess) {
29
27
  __publicField(this, "accessorErrorManager");
30
28
  __publicField(this, "batchUpdatesOptions");
31
29
  __publicField(this, "asyncBatchUpdatesOptions");
@@ -35,20 +33,19 @@ const _DataBinding = class {
35
33
  __publicField(this, "eventManager");
36
34
  __publicField(this, "stateInitializer");
37
35
  __publicField(this, "treeAugmenter");
38
- __publicField(this, "treeStore");
39
36
  __publicField(this, "resolvedOnUpdate", ({ isMutating }) => {
40
- this.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations));
37
+ this.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations), this);
41
38
  });
42
39
  __publicField(this, "pendingExtensions", /* @__PURE__ */ new Set());
43
40
  this.contentApiClient = contentApiClient;
44
41
  this.systemApiClient = systemApiClient;
45
42
  this.tenantApiClient = tenantApiClient;
43
+ this.treeStore = treeStore;
46
44
  this.environment = environment;
47
45
  this.onUpdate = onUpdate;
48
46
  this.onError = onError;
49
47
  this.onPersistSuccess = onPersistSuccess;
50
48
  this.config = new Config();
51
- this.treeStore = new TreeStore();
52
49
  this.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore);
53
50
  this.asyncBatchUpdatesOptions = {
54
51
  ...this.batchUpdatesOptions,
@@ -59,7 +56,7 @@ const _DataBinding = class {
59
56
  this.dirtinessTracker = new DirtinessTracker();
60
57
  this.eventManager = new EventManager(this.asyncBatchUpdatesOptions, this.batchUpdatesOptions, this.config, this.dirtinessTracker, this.resolvedOnUpdate, this.treeStore);
61
58
  this.accessorErrorManager = new AccessorErrorManager(this.eventManager, this.treeStore);
62
- this.stateInitializer = new StateInitializer(this.accessorErrorManager, this.batchUpdatesOptions, this.config, this.eventManager, this.treeStore);
59
+ this.stateInitializer = new StateInitializer(this.accessorErrorManager, this.batchUpdatesOptions, this.eventManager, this.treeStore);
63
60
  this.treeAugmenter = new TreeAugmenter(this.eventManager, this.stateInitializer, this.treeStore);
64
61
  this.bindingOperations = Object.freeze({
65
62
  ...this.asyncBatchUpdatesOptions,
@@ -101,8 +98,8 @@ const _DataBinding = class {
101
98
  };
102
99
  }
103
100
  const generator = new MutationGenerator(this.treeStore);
104
- const mutation = generator.getPersistMutation();
105
- if (mutation === void 0) {
101
+ const mutationResult = generator.getPersistMutation();
102
+ if (mutationResult === void 0) {
106
103
  this.dirtinessTracker.reset();
107
104
  const persistSuccessOptions = {
108
105
  ...this.bindingOperations,
@@ -114,15 +111,16 @@ const _DataBinding = class {
114
111
  type: "nothingToPersist"
115
112
  };
116
113
  }
117
- const mutationResponse = await this.contentApiClient.sendRequest(mutation, {
114
+ const { query, operations } = mutationResult;
115
+ const mutationResponse = await this.contentApiClient.sendRequest(query, {
118
116
  signal
119
117
  });
120
118
  if (mutationResponse.errors !== void 0 && mutationResponse.errors.length > 0) {
121
119
  this.onError({
122
120
  type: "gqlError",
123
- query: mutation,
121
+ query,
124
122
  errors: mutationResponse.errors
125
- });
123
+ }, this);
126
124
  }
127
125
  if (!mutationResponse.data?.transaction) {
128
126
  throw {
@@ -144,7 +142,7 @@ const _DataBinding = class {
144
142
  this.treeAugmenter.updatePersistedData(Object.fromEntries(Object.entries(mutationData).map(([placeholderName, subTreeResponse]) => [
145
143
  placeholderName,
146
144
  subTreeResponse.node
147
- ])));
145
+ ])), operations);
148
146
  const persistSuccessOptions = {
149
147
  ...this.bindingOperations,
150
148
  successType: result.type
@@ -159,13 +157,13 @@ const _DataBinding = class {
159
157
  ...result,
160
158
  afterPersistError: e
161
159
  };
162
- this.onPersistSuccess(resultWithError);
160
+ this.onPersistSuccess(resultWithError, this);
163
161
  return resultWithError;
164
162
  }
165
- this.onPersistSuccess(result);
163
+ this.onPersistSuccess(result, this);
166
164
  return result;
167
165
  } else {
168
- this.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData));
166
+ this.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData, operations));
169
167
  await this.eventManager.triggerOnPersistError(persistErrorOptions);
170
168
  await onPersistError?.(persistErrorOptions);
171
169
  if (shouldTryAgain) {
@@ -191,9 +189,7 @@ const _DataBinding = class {
191
189
  if (options.signal?.aborted) {
192
190
  return Promise.reject(DataBindingExtendAborted);
193
191
  }
194
- const schema = await this.getOrLoadSchema();
195
- this.treeStore.setSchema(schema);
196
- const markerTreeRoot = new MarkerTreeGenerator(newFragment, (options.environment ?? this.environment).withSchema(schema)).generate();
192
+ const markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate();
197
193
  if (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {
198
194
  return this.eventManager.syncOperation(() => {
199
195
  const newTreeRootId = this.getNewTreeRootId();
@@ -243,7 +239,7 @@ const _DataBinding = class {
243
239
  return;
244
240
  }
245
241
  this.eventManager.syncOperation(() => {
246
- this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {});
242
+ this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {}, aggregateMarkerTreeRoot);
247
243
  for (const extension of pendingExtensions) {
248
244
  this.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot);
249
245
  extension.resolve(extension.newTreeRootId);
@@ -262,14 +258,14 @@ const _DataBinding = class {
262
258
  if (metadata.name === "AbortError") {
263
259
  return;
264
260
  }
265
- this.onError(metadataToRequestError(metadata));
261
+ this.onError(metadataToRequestError(metadata), this);
266
262
  }
267
263
  if (queryResponse && queryResponse.errors !== void 0 && queryResponse.errors.length > 0) {
268
264
  this.onError({
269
265
  type: "gqlError",
270
266
  query: query ?? "unknown query",
271
267
  errors: queryResponse.errors
272
- });
268
+ }, this);
273
269
  }
274
270
  return queryResponse;
275
271
  }
@@ -310,24 +306,11 @@ const _DataBinding = class {
310
306
  }
311
307
  });
312
308
  }
313
- getOrLoadSchema() {
314
- const existing = _DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl);
315
- if (existing !== void 0) {
316
- return existing;
317
- }
318
- const schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue("maxSchemaLoadAttempts"));
319
- schemaPromise.then((schema) => {
320
- _DataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema);
321
- });
322
- _DataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise);
323
- return schemaPromise;
324
- }
325
309
  getNewTreeRootId() {
326
310
  return this.treeStore.markerTrees.size === 0 ? void 0 : `${generateEnumerabilityPreventingEntropy()}-${_DataBinding.getNextTreeRootIdSeed()}`;
327
311
  }
328
312
  };
329
313
  let DataBinding = _DataBinding;
330
- __publicField(DataBinding, "schemaLoadCache", /* @__PURE__ */ new Map());
331
314
  __publicField(DataBinding, "getNextTreeRootIdSeed", (() => {
332
315
  let seed = 1;
333
316
  return () => seed++;