@contember/binding 1.1.0-alpha.1 → 1.1.0-alpha.12

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 (431) 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/accessors/EntityAccessor.js +19 -8
  21. package/dist/development/accessors/EntityAccessor.js.map +1 -1
  22. package/dist/development/accessors/EntityListAccessor.js +10 -10
  23. package/dist/development/accessors/EntityListAccessor.js.map +1 -1
  24. package/dist/development/accessors/FieldAccessor.js +6 -6
  25. package/dist/development/accessors/FieldAccessor.js.map +1 -1
  26. package/dist/development/core/AccessorErrorManager.js +2 -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 +23 -37
  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 +13 -8
  37. package/dist/development/core/EventManager.js.map +1 -1
  38. package/dist/development/core/IncrementalMarkerBuilder.js +1 -1
  39. package/dist/development/core/MarkerMerger.js +2 -2
  40. package/dist/development/core/MutationGenerator.js +175 -136
  41. package/dist/development/core/MutationGenerator.js.map +1 -1
  42. package/dist/development/core/RequestResponseNormalizer.js +93 -130
  43. package/dist/development/core/RequestResponseNormalizer.js.map +1 -1
  44. package/dist/development/core/StateInitializer.js +22 -30
  45. package/dist/development/core/StateInitializer.js.map +1 -1
  46. package/dist/development/core/TreeAugmenter.js +4 -4
  47. package/dist/development/core/TreeAugmenter.js.map +1 -1
  48. package/dist/development/core/TreeStore.js +9 -20
  49. package/dist/development/core/TreeStore.js.map +1 -1
  50. package/dist/development/core/VariableInputTransformer.js.map +1 -1
  51. package/dist/development/core/factories/createBatchUpdatesOptions.js.map +1 -1
  52. package/dist/development/core/operations/EntityOperations.js +10 -9
  53. package/dist/development/core/operations/EntityOperations.js.map +1 -1
  54. package/dist/development/core/operations/ListOperations.js +1 -1
  55. package/dist/development/core/operations/ListOperations.js.map +1 -1
  56. package/dist/development/core/requestAliases/MutationAlias.js +2 -40
  57. package/dist/development/core/requestAliases/MutationAlias.js.map +1 -1
  58. package/dist/development/core/schema/Schema.js +27 -3
  59. package/dist/development/core/schema/Schema.js.map +1 -1
  60. package/dist/development/core/schema/SchemaLoader.js +12 -12
  61. package/dist/development/core/schema/SchemaLoader.js.map +1 -1
  62. package/dist/development/core/schema/SchemaPreprocessor.js +1 -1
  63. package/dist/development/core/schema/SchemaPreprocessor.js.map +1 -1
  64. package/dist/development/coreComponents/Component.js +5 -2
  65. package/dist/development/coreComponents/Component.js.map +1 -1
  66. package/dist/development/coreComponents/DataBindingProvider.js +0 -1
  67. package/dist/development/coreComponents/DataBindingProvider.js.map +1 -1
  68. package/dist/development/coreComponents/EntityListSubTree.js.map +1 -1
  69. package/dist/development/coreComponents/HasOne.js +1 -1
  70. package/dist/development/dao/Environment.js +34 -2
  71. package/dist/development/dao/Environment.js.map +1 -1
  72. package/dist/development/dao/TreeNodeEnvironmentFactory.js +6 -13
  73. package/dist/development/dao/TreeNodeEnvironmentFactory.js.map +1 -1
  74. package/dist/development/helperComponents/DeferredSubTrees.js +16 -8
  75. package/dist/development/helperComponents/DeferredSubTrees.js.map +1 -1
  76. package/dist/development/helperComponents/If.js +39 -0
  77. package/dist/development/helperComponents/If.js.map +1 -0
  78. package/dist/development/helperComponents/SugaredField.js +1 -1
  79. package/dist/development/helperComponents/helpers/FilterEvaluator.js +35 -0
  80. package/dist/development/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  81. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js +38 -0
  82. package/dist/development/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  83. package/dist/development/helperComponents/helpers/evaluateCondition.js +46 -0
  84. package/dist/development/helperComponents/helpers/evaluateCondition.js.map +1 -0
  85. package/dist/development/index.js +6 -1
  86. package/dist/development/index.js.map +1 -1
  87. package/dist/development/markers/EntityListSubTreeMarker.js +1 -1
  88. package/dist/development/markers/EntityListSubTreeMarker.js.map +1 -1
  89. package/dist/development/markers/EntitySubTreeMarker.js +1 -1
  90. package/dist/development/markers/EntitySubTreeMarker.js.map +1 -1
  91. package/dist/development/markers/PlaceholderGenerator.js +4 -4
  92. package/dist/development/markers/PlaceholderGenerator.js.map +1 -1
  93. package/dist/development/queryLanguage/MarkerFactory.js +2 -2
  94. package/dist/development/queryLanguage/QueryLanguage.js +1 -1
  95. package/dist/development/utils/Hashing.js +21 -6
  96. package/dist/development/utils/Hashing.js.map +1 -1
  97. package/dist/production/accessorPropagation/EnvironmentContext.js +28 -2
  98. package/dist/production/accessorPropagation/EnvironmentContext.js.map +1 -1
  99. package/dist/production/accessorPropagation/useEntityListSubTree.js +4 -2
  100. package/dist/production/accessorPropagation/useEntityListSubTree.js.map +1 -1
  101. package/dist/production/accessorPropagation/useEntitySubTree.js +4 -2
  102. package/dist/production/accessorPropagation/useEntitySubTree.js.map +1 -1
  103. package/dist/production/accessorPropagation/useExtendTree.js +27 -0
  104. package/dist/production/accessorPropagation/useExtendTree.js.map +1 -0
  105. package/dist/production/accessorTree/AccessorTree.js +16 -14
  106. package/dist/production/accessorTree/AccessorTree.js.map +1 -1
  107. package/dist/production/accessorTree/AccessorTreeStateContext.js +4 -0
  108. package/dist/production/accessorTree/AccessorTreeStateContext.js.map +1 -0
  109. package/dist/production/accessorTree/NormalizedPersistedData.js.map +1 -1
  110. package/dist/production/accessorTree/accessorTreeStateReducer.js +11 -2
  111. package/dist/production/accessorTree/accessorTreeStateReducer.js.map +1 -1
  112. package/dist/production/accessorTree/useAccessorTreeState.js +12 -0
  113. package/dist/production/accessorTree/useAccessorTreeState.js.map +1 -0
  114. package/dist/production/accessorTree/useDataBinding.js +41 -51
  115. package/dist/production/accessorTree/useDataBinding.js.map +1 -1
  116. package/dist/production/accessors/EntityAccessor.js +19 -8
  117. package/dist/production/accessors/EntityAccessor.js.map +1 -1
  118. package/dist/production/accessors/EntityListAccessor.js +10 -10
  119. package/dist/production/accessors/EntityListAccessor.js.map +1 -1
  120. package/dist/production/accessors/FieldAccessor.js +6 -6
  121. package/dist/production/accessors/FieldAccessor.js.map +1 -1
  122. package/dist/production/core/AccessorErrorManager.js +2 -2
  123. package/dist/production/core/AccessorErrorManager.js.map +1 -1
  124. package/dist/production/core/Config.js +1 -2
  125. package/dist/production/core/Config.js.map +1 -1
  126. package/dist/production/core/DataBinding.js +23 -37
  127. package/dist/production/core/DataBinding.js.map +1 -1
  128. package/dist/production/core/DirtinessTracker.js +4 -13
  129. package/dist/production/core/DirtinessTracker.js.map +1 -1
  130. package/dist/production/core/ErrorsPreprocessor.js +9 -13
  131. package/dist/production/core/ErrorsPreprocessor.js.map +1 -1
  132. package/dist/production/core/EventManager.js +12 -7
  133. package/dist/production/core/EventManager.js.map +1 -1
  134. package/dist/production/core/IncrementalMarkerBuilder.js +1 -1
  135. package/dist/production/core/MarkerMerger.js +2 -2
  136. package/dist/production/core/MutationGenerator.js +175 -136
  137. package/dist/production/core/MutationGenerator.js.map +1 -1
  138. package/dist/production/core/RequestResponseNormalizer.js +93 -130
  139. package/dist/production/core/RequestResponseNormalizer.js.map +1 -1
  140. package/dist/production/core/StateInitializer.js +22 -30
  141. package/dist/production/core/StateInitializer.js.map +1 -1
  142. package/dist/production/core/TreeAugmenter.js +4 -4
  143. package/dist/production/core/TreeAugmenter.js.map +1 -1
  144. package/dist/production/core/TreeStore.js +9 -20
  145. package/dist/production/core/TreeStore.js.map +1 -1
  146. package/dist/production/core/VariableInputTransformer.js.map +1 -1
  147. package/dist/production/core/factories/createBatchUpdatesOptions.js.map +1 -1
  148. package/dist/production/core/operations/EntityOperations.js +10 -9
  149. package/dist/production/core/operations/EntityOperations.js.map +1 -1
  150. package/dist/production/core/operations/ListOperations.js +1 -1
  151. package/dist/production/core/operations/ListOperations.js.map +1 -1
  152. package/dist/production/core/requestAliases/MutationAlias.js +2 -33
  153. package/dist/production/core/requestAliases/MutationAlias.js.map +1 -1
  154. package/dist/production/core/schema/Schema.js +27 -3
  155. package/dist/production/core/schema/Schema.js.map +1 -1
  156. package/dist/production/core/schema/SchemaLoader.js +12 -12
  157. package/dist/production/core/schema/SchemaLoader.js.map +1 -1
  158. package/dist/production/core/schema/SchemaPreprocessor.js +1 -1
  159. package/dist/production/core/schema/SchemaPreprocessor.js.map +1 -1
  160. package/dist/production/coreComponents/Component.js +5 -2
  161. package/dist/production/coreComponents/Component.js.map +1 -1
  162. package/dist/production/coreComponents/DataBindingProvider.js +0 -1
  163. package/dist/production/coreComponents/DataBindingProvider.js.map +1 -1
  164. package/dist/production/coreComponents/EntityListSubTree.js.map +1 -1
  165. package/dist/production/coreComponents/HasOne.js +1 -1
  166. package/dist/production/dao/Environment.js +34 -2
  167. package/dist/production/dao/Environment.js.map +1 -1
  168. package/dist/production/dao/TreeNodeEnvironmentFactory.js +6 -13
  169. package/dist/production/dao/TreeNodeEnvironmentFactory.js.map +1 -1
  170. package/dist/production/helperComponents/DeferredSubTrees.js +16 -8
  171. package/dist/production/helperComponents/DeferredSubTrees.js.map +1 -1
  172. package/dist/production/helperComponents/If.js +39 -0
  173. package/dist/production/helperComponents/If.js.map +1 -0
  174. package/dist/production/helperComponents/SugaredField.js +1 -1
  175. package/dist/production/helperComponents/helpers/FilterEvaluator.js +35 -0
  176. package/dist/production/helperComponents/helpers/FilterEvaluator.js.map +1 -0
  177. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js +38 -0
  178. package/dist/production/helperComponents/helpers/FilterFieldsCollector.js.map +1 -0
  179. package/dist/production/helperComponents/helpers/evaluateCondition.js +46 -0
  180. package/dist/production/helperComponents/helpers/evaluateCondition.js.map +1 -0
  181. package/dist/production/index.js +6 -1
  182. package/dist/production/index.js.map +1 -1
  183. package/dist/production/markers/EntityListSubTreeMarker.js +1 -1
  184. package/dist/production/markers/EntityListSubTreeMarker.js.map +1 -1
  185. package/dist/production/markers/EntitySubTreeMarker.js +1 -1
  186. package/dist/production/markers/EntitySubTreeMarker.js.map +1 -1
  187. package/dist/production/markers/PlaceholderGenerator.js +4 -4
  188. package/dist/production/markers/PlaceholderGenerator.js.map +1 -1
  189. package/dist/production/queryLanguage/MarkerFactory.js +2 -2
  190. package/dist/production/queryLanguage/QueryLanguage.js +1 -1
  191. package/dist/production/utils/Hashing.js +21 -6
  192. package/dist/production/utils/Hashing.js.map +1 -1
  193. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts +1 -1
  194. package/dist/types/accessorPropagation/BindingOperationsContext.d.ts.map +1 -1
  195. package/dist/types/accessorPropagation/EntityKeyContext.d.ts +1 -1
  196. package/dist/types/accessorPropagation/EntityKeyContext.d.ts.map +1 -1
  197. package/dist/types/accessorPropagation/EnvironmentContext.d.ts +13 -2
  198. package/dist/types/accessorPropagation/EnvironmentContext.d.ts.map +1 -1
  199. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts +1 -1
  200. package/dist/types/accessorPropagation/TreeRootIdContext.d.ts.map +1 -1
  201. package/dist/types/accessorPropagation/index.d.ts +1 -0
  202. package/dist/types/accessorPropagation/index.d.ts.map +1 -1
  203. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts +3 -1
  204. package/dist/types/accessorPropagation/useEntityListSubTree.d.ts.map +1 -1
  205. package/dist/types/accessorPropagation/useEntitySubTree.d.ts +3 -1
  206. package/dist/types/accessorPropagation/useEntitySubTree.d.ts.map +1 -1
  207. package/dist/types/accessorPropagation/useExtendTree.d.ts +5 -0
  208. package/dist/types/accessorPropagation/useExtendTree.d.ts.map +1 -0
  209. package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts +2 -1
  210. package/dist/types/accessorPropagation/useGetEntityListSubTree.d.ts.map +1 -1
  211. package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts +2 -1
  212. package/dist/types/accessorPropagation/useGetEntitySubTree.d.ts.map +1 -1
  213. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts +1 -1
  214. package/dist/types/accessorSorting/SetOrderFieldOnCreate.d.ts.map +1 -1
  215. package/dist/types/accessorSorting/addEntityAtIndex.d.ts +1 -1
  216. package/dist/types/accessorSorting/addEntityAtIndex.d.ts.map +1 -1
  217. package/dist/types/accessorTree/AccessorTree.d.ts.map +1 -1
  218. package/dist/types/accessorTree/AccessorTreeState.d.ts +8 -0
  219. package/dist/types/accessorTree/AccessorTreeState.d.ts.map +1 -1
  220. package/dist/types/accessorTree/AccessorTreeStateAction.d.ts +6 -0
  221. package/dist/types/accessorTree/AccessorTreeStateAction.d.ts.map +1 -1
  222. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts +4 -0
  223. package/dist/types/accessorTree/AccessorTreeStateContext.d.ts.map +1 -0
  224. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts +0 -1
  225. package/dist/types/accessorTree/AccessorTreeStateOptions.d.ts.map +1 -1
  226. package/dist/types/accessorTree/DirtinessContext.d.ts +1 -1
  227. package/dist/types/accessorTree/DirtinessContext.d.ts.map +1 -1
  228. package/dist/types/accessorTree/MutationRequestResponse.d.ts +5 -5
  229. package/dist/types/accessorTree/MutationRequestResponse.d.ts.map +1 -1
  230. package/dist/types/accessorTree/MutationStateContext.d.ts +1 -1
  231. package/dist/types/accessorTree/MutationStateContext.d.ts.map +1 -1
  232. package/dist/types/accessorTree/NormalizedPersistedData.d.ts +2 -2
  233. package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -1
  234. package/dist/types/accessorTree/QueryRequestResponse.d.ts +2 -2
  235. package/dist/types/accessorTree/QueryRequestResponse.d.ts.map +1 -1
  236. package/dist/types/accessorTree/accessorTreeStateReducer.d.ts.map +1 -1
  237. package/dist/types/accessorTree/index.d.ts +1 -0
  238. package/dist/types/accessorTree/index.d.ts.map +1 -1
  239. package/dist/types/accessorTree/useAccessorTreeState.d.ts +2 -0
  240. package/dist/types/accessorTree/useAccessorTreeState.d.ts.map +1 -0
  241. package/dist/types/accessorTree/useDataBinding.d.ts +1 -1
  242. package/dist/types/accessorTree/useDataBinding.d.ts.map +1 -1
  243. package/dist/types/accessors/BindingConfig.d.ts +0 -1
  244. package/dist/types/accessors/BindingConfig.d.ts.map +1 -1
  245. package/dist/types/accessors/EntityAccessor.d.ts +4 -2
  246. package/dist/types/accessors/EntityAccessor.d.ts.map +1 -1
  247. package/dist/types/accessors/EntityListAccessor.d.ts +2 -2
  248. package/dist/types/accessors/EntityListAccessor.d.ts.map +1 -1
  249. package/dist/types/accessors/FieldAccessor.d.ts +2 -2
  250. package/dist/types/accessors/FieldAccessor.d.ts.map +1 -1
  251. package/dist/types/core/AccessorErrorManager.d.ts +2 -1
  252. package/dist/types/core/AccessorErrorManager.d.ts.map +1 -1
  253. package/dist/types/core/Config.d.ts.map +1 -1
  254. package/dist/types/core/DataBinding.d.ts +3 -4
  255. package/dist/types/core/DataBinding.d.ts.map +1 -1
  256. package/dist/types/core/DirtinessTracker.d.ts +2 -5
  257. package/dist/types/core/DirtinessTracker.d.ts.map +1 -1
  258. package/dist/types/core/ErrorsPreprocessor.d.ts +3 -1
  259. package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
  260. package/dist/types/core/EventManager.d.ts +1 -1
  261. package/dist/types/core/EventManager.d.ts.map +1 -1
  262. package/dist/types/core/MutationGenerator.d.ts +25 -1
  263. package/dist/types/core/MutationGenerator.d.ts.map +1 -1
  264. package/dist/types/core/RequestResponseNormalizer.d.ts +6 -7
  265. package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
  266. package/dist/types/core/StateInitializer.d.ts +1 -5
  267. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  268. package/dist/types/core/TreeAugmenter.d.ts +3 -2
  269. package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
  270. package/dist/types/core/TreeStore.d.ts +5 -5
  271. package/dist/types/core/TreeStore.d.ts.map +1 -1
  272. package/dist/types/core/VariableInputTransformer.d.ts +2 -2
  273. package/dist/types/core/VariableInputTransformer.d.ts.map +1 -1
  274. package/dist/types/core/index.d.ts +1 -0
  275. package/dist/types/core/index.d.ts.map +1 -1
  276. package/dist/types/core/operations/EntityOperations.d.ts.map +1 -1
  277. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  278. package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -3
  279. package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -1
  280. package/dist/types/core/requestAliases/index.d.ts +0 -3
  281. package/dist/types/core/requestAliases/index.d.ts.map +1 -1
  282. package/dist/types/core/schema/RawSchemaEntity.d.ts +3 -2
  283. package/dist/types/core/schema/RawSchemaEntity.d.ts.map +1 -1
  284. package/dist/types/core/schema/Schema.d.ts +13 -3
  285. package/dist/types/core/schema/Schema.d.ts.map +1 -1
  286. package/dist/types/core/schema/SchemaColumn.d.ts +1 -1
  287. package/dist/types/core/schema/SchemaColumn.d.ts.map +1 -1
  288. package/dist/types/core/schema/SchemaEntity.d.ts +1 -1
  289. package/dist/types/core/schema/SchemaEntity.d.ts.map +1 -1
  290. package/dist/types/core/schema/SchemaLoader.d.ts +2 -1
  291. package/dist/types/core/schema/SchemaLoader.d.ts.map +1 -1
  292. package/dist/types/core/schema/SchemaRelation.d.ts +1 -1
  293. package/dist/types/core/schema/SchemaRelation.d.ts.map +1 -1
  294. package/dist/types/core/state/FieldState.d.ts +2 -2
  295. package/dist/types/core/state/FieldState.d.ts.map +1 -1
  296. package/dist/types/coreComponents/Component.d.ts +9 -4
  297. package/dist/types/coreComponents/Component.d.ts.map +1 -1
  298. package/dist/types/coreComponents/DataBindingProvider.d.ts +0 -1
  299. package/dist/types/coreComponents/DataBindingProvider.d.ts.map +1 -1
  300. package/dist/types/coreComponents/Entity.d.ts +1 -1
  301. package/dist/types/coreComponents/Entity.d.ts.map +1 -1
  302. package/dist/types/coreComponents/EntityListSubTree.d.ts.map +1 -1
  303. package/dist/types/coreComponents/Field.d.ts +1 -1
  304. package/dist/types/coreComponents/Field.d.ts.map +1 -1
  305. package/dist/types/coreComponents/ParentEntity.d.ts +1 -1
  306. package/dist/types/coreComponents/ParentEntity.d.ts.map +1 -1
  307. package/dist/types/dao/Environment.d.ts +9 -0
  308. package/dist/types/dao/Environment.d.ts.map +1 -1
  309. package/dist/types/dao/TreeNodeEnvironmentFactory.d.ts.map +1 -1
  310. package/dist/types/entityEvents/useDerivedField.d.ts +2 -2
  311. package/dist/types/entityEvents/useDerivedField.d.ts.map +1 -1
  312. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts +1 -1
  313. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +1 -1
  314. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +1 -1
  315. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts.map +1 -1
  316. package/dist/types/helperComponents/DeferredSubTrees.d.ts +1 -1
  317. package/dist/types/helperComponents/DeferredSubTrees.d.ts.map +1 -1
  318. package/dist/types/helperComponents/FieldView.d.ts +7 -7
  319. package/dist/types/helperComponents/FieldView.d.ts.map +1 -1
  320. package/dist/types/helperComponents/If.d.ts +14 -0
  321. package/dist/types/helperComponents/If.d.ts.map +1 -0
  322. package/dist/types/helperComponents/StaticRender.d.ts +1 -1
  323. package/dist/types/helperComponents/StaticRender.d.ts.map +1 -1
  324. package/dist/types/helperComponents/SugaredField.d.ts +1 -1
  325. package/dist/types/helperComponents/SugaredField.d.ts.map +1 -1
  326. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts +9 -0
  327. package/dist/types/helperComponents/helpers/FilterEvaluator.d.ts.map +1 -0
  328. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts +10 -0
  329. package/dist/types/helperComponents/helpers/FilterFieldsCollector.d.ts.map +1 -0
  330. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts +4 -0
  331. package/dist/types/helperComponents/helpers/evaluateCondition.d.ts.map +1 -0
  332. package/dist/types/helperComponents/index.d.ts +1 -0
  333. package/dist/types/helperComponents/index.d.ts.map +1 -1
  334. package/dist/types/markers/FieldMarker.d.ts +3 -3
  335. package/dist/types/markers/FieldMarker.d.ts.map +1 -1
  336. package/dist/types/markers/PlaceholderGenerator.d.ts +3 -2
  337. package/dist/types/markers/PlaceholderGenerator.d.ts.map +1 -1
  338. package/dist/types/treeParameters/primitives/FieldValue.d.ts +2 -2
  339. package/dist/types/treeParameters/primitives/FieldValue.d.ts.map +1 -1
  340. package/dist/types/treeParameters/primitives/Json.d.ts +7 -0
  341. package/dist/types/treeParameters/primitives/Json.d.ts.map +1 -0
  342. package/dist/types/treeParameters/primitives/index.d.ts +1 -0
  343. package/dist/types/treeParameters/primitives/index.d.ts.map +1 -1
  344. package/dist/types/tsconfig.tsbuildinfo +1 -1
  345. package/dist/types/utils/Hashing.d.ts +3 -2
  346. package/dist/types/utils/Hashing.d.ts.map +1 -1
  347. package/package.json +7 -5
  348. package/src/accessorPropagation/EnvironmentContext.tsx +44 -0
  349. package/src/accessorPropagation/index.ts +1 -0
  350. package/src/accessorPropagation/useEntityListSubTree.ts +8 -1
  351. package/src/accessorPropagation/useEntitySubTree.ts +8 -1
  352. package/src/accessorPropagation/useExtendTree.ts +30 -0
  353. package/src/accessorTree/AccessorTree.tsx +18 -18
  354. package/src/accessorTree/AccessorTreeState.ts +12 -1
  355. package/src/accessorTree/AccessorTreeStateAction.ts +7 -1
  356. package/src/accessorTree/AccessorTreeStateContext.ts +4 -0
  357. package/src/accessorTree/AccessorTreeStateOptions.ts +0 -1
  358. package/src/accessorTree/MutationRequestResponse.ts +9 -3
  359. package/src/accessorTree/NormalizedPersistedData.ts +2 -2
  360. package/src/accessorTree/QueryRequestResponse.ts +2 -2
  361. package/src/accessorTree/accessorTreeStateReducer.ts +10 -1
  362. package/src/accessorTree/index.ts +1 -0
  363. package/src/accessorTree/useAccessorTreeState.ts +11 -0
  364. package/src/accessorTree/useDataBinding.ts +41 -59
  365. package/src/accessors/BindingConfig.ts +0 -1
  366. package/src/accessors/EntityAccessor.ts +20 -7
  367. package/src/accessors/EntityListAccessor.ts +9 -9
  368. package/src/accessors/FieldAccessor.ts +5 -5
  369. package/src/core/AccessorErrorManager.ts +3 -2
  370. package/src/core/Config.ts +0 -1
  371. package/src/core/DataBinding.ts +24 -40
  372. package/src/core/DirtinessTracker.ts +4 -16
  373. package/src/core/ErrorsPreprocessor.ts +14 -16
  374. package/src/core/EventManager.ts +14 -8
  375. package/src/core/MutationGenerator.ts +244 -183
  376. package/src/core/RequestResponseNormalizer.ts +110 -161
  377. package/src/core/StateInitializer.ts +35 -47
  378. package/src/core/TreeAugmenter.ts +5 -4
  379. package/src/core/TreeStore.ts +11 -21
  380. package/src/core/VariableInputTransformer.ts +2 -2
  381. package/src/core/factories/createBatchUpdatesOptions.ts +1 -1
  382. package/src/core/index.ts +1 -0
  383. package/src/core/operations/EntityOperations.ts +9 -10
  384. package/src/core/operations/ListOperations.ts +2 -1
  385. package/src/core/requestAliases/MutationAlias.ts +2 -57
  386. package/src/core/requestAliases/index.ts +0 -3
  387. package/src/core/schema/RawSchemaEntity.ts +1 -2
  388. package/src/core/schema/Schema.ts +38 -4
  389. package/src/core/schema/SchemaColumn.ts +1 -1
  390. package/src/core/schema/SchemaEntity.ts +1 -1
  391. package/src/core/schema/SchemaLoader.ts +13 -11
  392. package/src/core/schema/SchemaPreprocessor.ts +1 -1
  393. package/src/core/schema/SchemaRelation.ts +1 -1
  394. package/src/core/state/FieldState.ts +2 -2
  395. package/src/coreComponents/Component.tsx +20 -7
  396. package/src/coreComponents/DataBindingProvider.tsx +0 -2
  397. package/src/coreComponents/EntityListSubTree.tsx +2 -3
  398. package/src/dao/Environment.ts +42 -1
  399. package/src/dao/TreeNodeEnvironmentFactory.ts +8 -13
  400. package/src/helperComponents/DeferredSubTrees.tsx +20 -13
  401. package/src/helperComponents/If.tsx +71 -0
  402. package/src/helperComponents/helpers/FilterEvaluator.ts +46 -0
  403. package/src/helperComponents/helpers/FilterFieldsCollector.ts +46 -0
  404. package/src/helperComponents/helpers/evaluateCondition.ts +52 -0
  405. package/src/helperComponents/index.ts +1 -0
  406. package/src/markers/EntityListSubTreeMarker.ts +1 -1
  407. package/src/markers/EntitySubTreeMarker.ts +1 -1
  408. package/src/markers/PlaceholderGenerator.ts +5 -2
  409. package/src/treeParameters/primitives/FieldValue.ts +2 -2
  410. package/src/treeParameters/primitives/Json.ts +7 -0
  411. package/src/treeParameters/primitives/index.ts +1 -0
  412. package/src/typings/react-fix.d.ts +12 -0
  413. package/src/utils/Hashing.ts +23 -8
  414. package/dist/development/core/requestAliases/mutationOperationSubTreeType.js +0 -6
  415. package/dist/development/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
  416. package/dist/development/core/requestAliases/mutationOperationType.js +0 -7
  417. package/dist/development/core/requestAliases/mutationOperationType.js.map +0 -1
  418. package/dist/production/core/requestAliases/mutationOperationSubTreeType.js +0 -6
  419. package/dist/production/core/requestAliases/mutationOperationSubTreeType.js.map +0 -1
  420. package/dist/production/core/requestAliases/mutationOperationType.js +0 -7
  421. package/dist/production/core/requestAliases/mutationOperationType.js.map +0 -1
  422. package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts +0 -11
  423. package/dist/types/core/requestAliases/TopLevelMutationOperation.d.ts.map +0 -1
  424. package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts +0 -5
  425. package/dist/types/core/requestAliases/mutationOperationSubTreeType.d.ts.map +0 -1
  426. package/dist/types/core/requestAliases/mutationOperationType.d.ts +0 -6
  427. package/dist/types/core/requestAliases/mutationOperationType.d.ts.map +0 -1
  428. package/src/accessorPropagation/EnvironmentContext.ts +0 -5
  429. package/src/core/requestAliases/TopLevelMutationOperation.ts +0 -11
  430. package/src/core/requestAliases/mutationOperationSubTreeType.ts +0 -4
  431. package/src/core/requestAliases/mutationOperationType.ts +0 -5
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListAccessor.js","sources":["../../../src/accessors/EntityListAccessor.ts"],"sourcesContent":["import type { ListOperations } from '../core/operations'\nimport type { Environment } from '../dao'\nimport type { EntityId, EntityRealmKey } from '../treeParameters'\nimport type { AsyncBatchUpdatesOptions } from './AsyncBatchUpdatesOptions'\nimport type { BatchUpdatesOptions } from './BatchUpdatesOptions'\nimport type { EntityAccessor } from './EntityAccessor'\nimport type { Errorable } from './Errorable'\nimport { ErrorAccessor } from './ErrorAccessor'\nimport type { PersistErrorOptions } from './PersistErrorOptions'\nimport type { PersistSuccessOptions } from './PersistSuccessOptions'\nimport type { EntityListState } from '../core/state'\nimport { RuntimeId } from '../accessorTree'\n\nclass EntityListAccessor implements Errorable {\n\tpublic constructor(\n\t\tprivate readonly stateKey: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic *keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key\n\t\t}\n\t}\n\n\tpublic *ids(): IterableIterator<EntityId> {\n\t\treturn this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.stateKey, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.RuntimeEntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.stateKey, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.stateKey, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.stateKey, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.stateKey, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.stateKey, initialize)\n\t}\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.stateKey, childEntity, options)\n\t}\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.stateKey, id)\n\t}\n}\n\nnamespace EntityListAccessor {\n\texport type GetEntityListAccessor = () => EntityListAccessor\n\texport type BatchUpdatesHandler = (getAccessor: GetEntityListAccessor, options: BatchUpdatesOptions) => void\n\n\texport type UpdateListener = (accessor: EntityListAccessor) => void\n\n\texport type BeforePersistHandler = (\n\t\tgetAccessor: GetEntityListAccessor,\n\t\toptions: AsyncBatchUpdatesOptions,\n\t) => void | Promise<void | BeforePersistHandler>\n\n\texport type PersistErrorHandler = (\n\t\tgetAccessor: GetEntityListAccessor,\n\t\toptions: PersistErrorOptions,\n\t) => void | Promise<void>\n\n\texport type PersistSuccessHandler = (\n\t\tgetAccessor: GetEntityListAccessor,\n\t\toptions: PersistSuccessOptions,\n\t) => void | Promise<void | PersistSuccessHandler>\n\n\texport type ChildEventListenerMap = {\n\t\t[EventType in keyof Pick<EntityAccessor.EntityEventListenerMap, 'beforeUpdate' | 'initialize' | 'update'> &\n\t\t\tstring as `child${Capitalize<EventType>}`]: EntityAccessor.EntityEventListenerMap[EventType]\n\t}\n\n\texport interface RuntimeEntityListEventListenerMap {\n\t\tbeforePersist: BeforePersistHandler\n\t\tbeforeUpdate: BatchUpdatesHandler\n\t\tpersistError: PersistErrorHandler\n\t\tpersistSuccess: PersistSuccessHandler\n\t\tupdate: UpdateListener\n\t}\n\texport interface EntityListEventListenerMap extends RuntimeEntityListEventListenerMap {\n\t\tinitialize: BatchUpdatesHandler\n\t}\n\texport type EntityListEventType = keyof EntityListEventListenerMap\n}\n\nexport { EntityListAccessor }\n"],"names":[],"mappings":";AAaA,MAAM,mBAAwC;AAAA,EACtC,YACW,UACA,YACA,WACA,uBACD,uBACA,QACA,aACA,aACf;AARgB,SAAA,WAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAAA,EACd;AAAA,GAOK,OAAyC;AAChD,eAAW,YAAY,MAAM;AAC5B,YAAM,SAAS;AAAA,IAChB;AAAA,EACD;AAAA,GAEQ,MAAkC;AAClC,WAAA,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AO,QAAQ;AAAA,EAC5E;AAAA,EAEO,aAAa,gBAA8D;AACjF,SAAK,WAAW,aAAa,KAAK,UAAU,cAAc;AAAA,EAC3D;AAAA,EAEO,cAAc,iBAAuC;AAC3D,SAAK,WAAW,cAAc,KAAK,UAAU,eAAe;AAAA,EAC7D;AAAA,EAEO,gBAAgB,YAA4D;AAClF,WAAO,KAAK,WAAW,gBAAgB,KAAK,UAAU,UAAU;AAAA,EACjE;AAAA,EACO,iBAAiB,aAA6B,UAAmC,IAAU;AACjG,SAAK,WAAW,iBAAiB,KAAK,UAAU,aAAa,OAAO;AAAA,EACrE;AAAA,EACO,mBAAmB,IAA8B;AACvD,WAAO,KAAK,WAAW,mBAAmB,KAAK,UAAU,EAAE;AAAA,EAC5D;AACD;;"}
1
+ {"version":3,"file":"EntityListAccessor.js","sources":["../../../src/accessors/EntityListAccessor.ts"],"sourcesContent":["import type { ListOperations } from '../core/operations'\nimport type { Environment } from '../dao'\nimport type { EntityId, EntityRealmKey } from '../treeParameters'\nimport type { AsyncBatchUpdatesOptions } from './AsyncBatchUpdatesOptions'\nimport type { BatchUpdatesOptions } from './BatchUpdatesOptions'\nimport type { EntityAccessor } from './EntityAccessor'\nimport type { Errorable } from './Errorable'\nimport { ErrorAccessor } from './ErrorAccessor'\nimport type { PersistErrorOptions } from './PersistErrorOptions'\nimport type { PersistSuccessOptions } from './PersistSuccessOptions'\nimport type { EntityListState } from '../core/state'\nimport { RuntimeId } from '../accessorTree'\n\nclass EntityListAccessor implements Errorable {\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic *keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key\n\t\t}\n\t}\n\n\tpublic *ids(): IterableIterator<EntityId> {\n\t\treturn this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.RuntimeEntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n}\n\nnamespace EntityListAccessor {\n\texport type GetEntityListAccessor = () => EntityListAccessor\n\texport type BatchUpdatesHandler = (getAccessor: GetEntityListAccessor, options: BatchUpdatesOptions) => void\n\n\texport type UpdateListener = (accessor: EntityListAccessor) => void\n\n\texport type BeforePersistHandler = (\n\t\tgetAccessor: GetEntityListAccessor,\n\t\toptions: AsyncBatchUpdatesOptions,\n\t) => void | Promise<void | BeforePersistHandler>\n\n\texport type PersistErrorHandler = (\n\t\tgetAccessor: GetEntityListAccessor,\n\t\toptions: PersistErrorOptions,\n\t) => void | Promise<void>\n\n\texport type PersistSuccessHandler = (\n\t\tgetAccessor: GetEntityListAccessor,\n\t\toptions: PersistSuccessOptions,\n\t) => void | Promise<void | PersistSuccessHandler>\n\n\texport type ChildEventListenerMap = {\n\t\t[EventType in keyof Pick<EntityAccessor.EntityEventListenerMap, 'beforeUpdate' | 'initialize' | 'update'> &\n\t\t\tstring as `child${Capitalize<EventType>}`]: EntityAccessor.EntityEventListenerMap[EventType]\n\t}\n\n\texport interface RuntimeEntityListEventListenerMap {\n\t\tbeforePersist: BeforePersistHandler\n\t\tbeforeUpdate: BatchUpdatesHandler\n\t\tpersistError: PersistErrorHandler\n\t\tpersistSuccess: PersistSuccessHandler\n\t\tupdate: UpdateListener\n\t}\n\texport interface EntityListEventListenerMap extends RuntimeEntityListEventListenerMap {\n\t\tinitialize: BatchUpdatesHandler\n\t}\n\texport type EntityListEventType = keyof EntityListEventListenerMap\n}\n\nexport { EntityListAccessor }\n"],"names":[],"mappings":";AAaA,MAAM,mBAAwC;AAAA,EACtC,YACW,OACA,YACA,WACA,uBACD,uBACA,QACA,aACA,aACf;AARgB,SAAA,QAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAAA,EACd;AAAA,GAOK,OAAyC;AAChD,eAAW,YAAY,MAAM;AAC5B,YAAM,SAAS;AAAA,IAChB;AAAA,EACD;AAAA,GAEQ,MAAkC;AAClC,WAAA,KAAK,UAAU;EACvB;AAAA,MAMW,uBAAsC;AACzC,WAAA,IAAI,IAAI,KAAK,qBAAqB;AAAA,EAC1C;AAAA,IAES,OAAO,YAA8C;AAC7D,eAAW,EAAE,iBAAiB,KAAK,UAAU,UAAU;AACtD,YAAM,YAAY;AAAA,IACnB;AAAA,EACD;AAAA,EAEO,YAAY,IAAuB;AAClC,WAAA,KAAK,UAAU,IAAI,EAAE;AAAA,EAC7B;AAAA,EAEO,UAAmB;AACz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AA6B,UAAmC,IAAU;AACjG,SAAK,WAAW,iBAAiB,KAAK,OAAO,aAAa,OAAO;AAAA,EAClE;AAAA,EACO,mBAAmB,IAA8B;AACvD,WAAO,KAAK,WAAW,mBAAmB,KAAK,OAAO,EAAE;AAAA,EACzD;AACD;;"}
@@ -2,8 +2,8 @@ import { ErrorAccessor } from "./ErrorAccessor.js";
2
2
  import { TemporalFieldHelper } from "../fieldHelpers/helpers/TemporalFieldHelper.js";
3
3
  import { UuidFieldHelper } from "../fieldHelpers/helpers/UuidFieldHelper.js";
4
4
  class FieldAccessor {
5
- constructor(stateKey, operations, fieldName, value, valueOnServer, defaultValue, errors, hasUnpersistedChanges, touchLog, getAccessor, schema) {
6
- this.stateKey = stateKey;
5
+ constructor(state, operations, fieldName, value, valueOnServer, defaultValue, errors, hasUnpersistedChanges, touchLog, getAccessor, schema) {
6
+ this.state = state;
7
7
  this.operations = operations;
8
8
  this.fieldName = fieldName;
9
9
  this.value = value;
@@ -16,16 +16,16 @@ class FieldAccessor {
16
16
  this.schema = schema;
17
17
  }
18
18
  addError(error) {
19
- return this.operations.addError(this.stateKey, ErrorAccessor.normalizeError(error));
19
+ return this.operations.addError(this.state, ErrorAccessor.normalizeError(error));
20
20
  }
21
21
  clearErrors() {
22
- this.operations.clearErrors(this.stateKey);
22
+ this.operations.clearErrors(this.state);
23
23
  }
24
24
  addEventListener(event, listener) {
25
- return this.operations.addEventListener(this.stateKey, event, listener);
25
+ return this.operations.addEventListener(this.state, event, listener);
26
26
  }
27
27
  updateValue(newValue, options) {
28
- this.operations.updateValue(this.stateKey, newValue, options);
28
+ this.operations.updateValue(this.state, newValue, options);
29
29
  }
30
30
  hasValue(candidate) {
31
31
  return this.value === candidate;
@@ -1 +1 @@
1
- {"version":3,"file":"FieldAccessor.js","sources":["../../../src/accessors/FieldAccessor.ts"],"sourcesContent":["import type { FieldOperations } from '../core/operations'\nimport type { FieldState } from '../core/state'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport type { FieldName, FieldValue } from '../treeParameters'\nimport type { BatchUpdatesOptions } from './BatchUpdatesOptions'\nimport type { Errorable } from './Errorable'\nimport { ErrorAccessor } from './ErrorAccessor'\nimport type { SchemaColumn } from '../core/schema/SchemaColumn'\n\nclass FieldAccessor<Value extends FieldValue = FieldValue> implements Errorable {\n\tconstructor(\n\t\tprivate readonly stateKey: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.stateKey, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.stateKey)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.stateKey, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.stateKey, newValue, options)\n\t}\n\n\tpublic hasValue(candidate: this['value']): boolean {\n\t\treturn this.value === candidate\n\t}\n\n\tpublic isTouchedBy(agent: string) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy(FieldAccessor.userAgent)\n\t}\n\n\tpublic get resolvedValue() {\n\t\tif (this.defaultValue === undefined) {\n\t\t\treturn this.value\n\t\t}\n\t\treturn this.value === null ? this.defaultValue : this.value\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n}\nnamespace FieldAccessor {\n\texport const userAgent = 'user'\n\n\texport interface UpdateOptions {\n\t\tagent?: string\n\t}\n\n\texport type GetFieldAccessor<Value extends FieldValue = FieldValue> = () => FieldAccessor<Value>\n\n\texport type BeforeUpdateListener<Value extends FieldValue = FieldValue> = (\n\t\tupdatedAccessor: FieldAccessor<Value>,\n\t) => void\n\texport type InitializeListener<Value extends FieldValue = FieldValue> = (\n\t\tgetAccessor: GetFieldAccessor<Value>,\n\t\toptions: BatchUpdatesOptions,\n\t) => void\n\texport type UpdateListener<Value extends FieldValue = FieldValue> = (accessor: FieldAccessor<Value>) => void\n\n\texport interface RuntimeFieldEventListenerMap<Value extends FieldValue = FieldValue> {\n\t\tbeforeUpdate: BeforeUpdateListener<Value>\n\t\tupdate: UpdateListener<Value>\n\t}\n\texport interface FieldEventListenerMap<Value extends FieldValue = FieldValue>\n\t\textends RuntimeFieldEventListenerMap<Value> {\n\t\tinitialize: InitializeListener<Value>\n\t}\n\texport type FieldEventType = keyof FieldEventListenerMap\n}\n\nexport { FieldAccessor }\n"],"names":[],"mappings":";;;AASA,MAAM,cAA0E;AAAA,EAC/E,YACkB,UACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,WAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAAA,EACd;AAAA,EAEI,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,UAAU,cAAc,eAAe,KAAK,CAAC;AAAA,EACnF;AAAA,EAEO,cAAoB;AACrB,SAAA,WAAW,YAAY,KAAK,QAAQ;AAAA,EAC1C;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,UAAU,OAAO,QAAQ;AAAA,EACvE;AAAA,EAEO,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,UAAU,UAAU,OAAO;AAAA,EAC7D;AAAA,EAEO,SAAS,WAAmC;AAClD,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,EAEO,YAAY,OAAe;AACjC,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EACrC;AAAA,MAEW,YAAY;AACf,WAAA,KAAK,YAAY,cAAc,SAAS;AAAA,EAChD;AAAA,MAEW,gBAAgB;AACtB,QAAA,KAAK,iBAAiB,QAAW;AACpC,aAAO,KAAK;AAAA,IACb;AACA,WAAO,KAAK,UAAU,OAAO,KAAK,eAAe,KAAK;AAAA,EACvD;AAAA,MAIW,aAAkC;AACrC,WAAA,IAAI,oBAAoB,KAAK,WAAkD;AAAA,EACvF;AAAA,MAEW,SAA0B;AAC7B,WAAA,IAAI,gBAAgB,KAAK,WAAkD;AAAA,EACnF;AACD;AACA,AAAA,EAAU,mBAAV;AACc,iBAAY,YAAA;AAAA,GADhB,iBAAA,iBAAA,CAAA,EAAA;;"}
1
+ {"version":3,"file":"FieldAccessor.js","sources":["../../../src/accessors/FieldAccessor.ts"],"sourcesContent":["import type { FieldOperations } from '../core/operations'\nimport type { FieldState } from '../core/state'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport type { FieldName, FieldValue } from '../treeParameters'\nimport type { BatchUpdatesOptions } from './BatchUpdatesOptions'\nimport type { Errorable } from './Errorable'\nimport { ErrorAccessor } from './ErrorAccessor'\nimport type { SchemaColumn } from '../core/schema/SchemaColumn'\n\nclass FieldAccessor<Value extends FieldValue = FieldValue> implements Errorable {\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic hasValue(candidate: this['value']): boolean {\n\t\treturn this.value === candidate\n\t}\n\n\tpublic isTouchedBy(agent: string) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy(FieldAccessor.userAgent)\n\t}\n\n\tpublic get resolvedValue() {\n\t\tif (this.defaultValue === undefined) {\n\t\t\treturn this.value\n\t\t}\n\t\treturn this.value === null ? this.defaultValue : this.value\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n}\nnamespace FieldAccessor {\n\texport const userAgent = 'user'\n\n\texport interface UpdateOptions {\n\t\tagent?: string\n\t}\n\n\texport type GetFieldAccessor<Value extends FieldValue = FieldValue> = () => FieldAccessor<Value>\n\n\texport type BeforeUpdateListener<Value extends FieldValue = FieldValue> = (\n\t\tupdatedAccessor: FieldAccessor<Value>,\n\t) => void\n\texport type InitializeListener<Value extends FieldValue = FieldValue> = (\n\t\tgetAccessor: GetFieldAccessor<Value>,\n\t\toptions: BatchUpdatesOptions,\n\t) => void\n\texport type UpdateListener<Value extends FieldValue = FieldValue> = (accessor: FieldAccessor<Value>) => void\n\n\texport interface RuntimeFieldEventListenerMap<Value extends FieldValue = FieldValue> {\n\t\tbeforeUpdate: BeforeUpdateListener<Value>\n\t\tupdate: UpdateListener<Value>\n\t}\n\texport interface FieldEventListenerMap<Value extends FieldValue = FieldValue>\n\t\textends RuntimeFieldEventListenerMap<Value> {\n\t\tinitialize: InitializeListener<Value>\n\t}\n\texport type FieldEventType = keyof FieldEventListenerMap\n}\n\nexport { FieldAccessor }\n"],"names":[],"mappings":";;;AASA,MAAM,cAA0E;AAAA,EAC/E,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAAA,EACd;AAAA,EAEI,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEO,cAAoB;AACrB,SAAA,WAAW,YAAY,KAAK,KAAK;AAAA,EACvC;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEO,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAC1D;AAAA,EAEO,SAAS,WAAmC;AAClD,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,EAEO,YAAY,OAAe;AACjC,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EACrC;AAAA,MAEW,YAAY;AACf,WAAA,KAAK,YAAY,cAAc,SAAS;AAAA,EAChD;AAAA,MAEW,gBAAgB;AACtB,QAAA,KAAK,iBAAiB,QAAW;AACpC,aAAO,KAAK;AAAA,IACb;AACA,WAAO,KAAK,UAAU,OAAO,KAAK,eAAe,KAAK;AAAA,EACvD;AAAA,MAIW,aAAkC;AACrC,WAAA,IAAI,oBAAoB,KAAK,WAAkD;AAAA,EACvF;AAAA,MAEW,SAA0B;AAC7B,WAAA,IAAI,gBAAgB,KAAK,WAAkD;AAAA,EACnF;AACD;AACA,AAAA,EAAU,mBAAV;AACc,iBAAY,YAAA;AAAA,GADhB,iBAAA,iBAAA,CAAA,EAAA;;"}
@@ -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,UAAU;AAEd,aAAO,MAAM;AAAA,IAAA;AAGsB,SAAA,eAAA;AAA6C,SAAA,YAAA;AAAA,EAAuB;AAAA,EAEjG,YAAY;AACX,WAAA,CAAC,CAAC,KAAK,cAAc;AAAA,EAC7B;AAAA,EAEO,YAAmC;AACzC,WAAO,MAAM,KAAK,KAAK,cAAc,OAAU,GAAA,CAAA,OAAM,MAAM,KAAK,GAAG,OAAQ,CAAA,CAAC,EAAE,KAAK;AAAA,EACpF;AAAA,EAEO,cAAc;AACf,SAAA,aAAa,cAAc,MAAM;AAC1B,iBAAA,CAAC,cAAc,KAAK,eAAe;AAC7C,kBAAU,SAAS;AACnB,aAAK,aAAa,oBAAoB,WAAW,aAAa,qBAAqB;AAAA,MACpF;AACA,WAAK,cAAc;IAAM,CACzB;AAAA,EACF;AAAA,EAEO,mBAAmB,OAAwB;AAC1C,WAAA,KAAK,aAAa,cAAc,MAAM;AAC5C,UAAI,CAAC,KAAK,cAAc,IAAI,KAAK,GAAG;AACnC;AAAA,MACD;AACK,WAAA,cAAc,OAAO,KAAK;AAC/B,YAAM,SAAS;AACf,WAAK,aAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,IAAA,CAC/E;AAAA,EACF;AAAA,EAEO,cAAc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AAA,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\t\t\t}\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;;;;;;AAQO,MAAM,qBAAqB;AAAA,EAS1B,YAA6B,cAA6C,WAAsB;AAR/F,6DAA8D;AAE9D,yCAAuB,OAAA;AAC9B,UAAI,UAAU;AAEd,aAAO,MAAM;AAAA,IAAA;AAGsB,SAAA,eAAA;AAA6C,SAAA,YAAA;AAAA,EAAuB;AAAA,EAEjG,YAAY;AACX,WAAA,CAAC,CAAC,KAAK,cAAc;AAAA,EAC7B;AAAA,EAEO,YAAmC;AACzC,WAAO,MAAM,KAAK,KAAK,cAAc,OAAU,GAAA,CAAA,OAAM,MAAM,KAAK,GAAG,OAAQ,CAAA,CAAC,EAAE,KAAK;AAAA,EACpF;AAAA,EAEO,cAAc;AACf,SAAA,aAAa,cAAc,MAAM;AAC1B,iBAAA,CAAC,cAAc,KAAK,eAAe;AAC7C,kBAAU,SAAS;AACnB,aAAK,aAAa,oBAAoB,WAAW,aAAa,qBAAqB;AAAA,MACpF;AACA,WAAK,cAAc;IAAM,CACzB;AAAA,EACF;AAAA,EAEO,mBAAmB,OAAwB;AAC1C,WAAA,KAAK,aAAa,cAAc,MAAM;AAC5C,UAAI,CAAC,KAAK,cAAc,IAAI,KAAK,G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AC7E,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 {
@@ -130,7 +128,7 @@ const _DataBinding = class {
130
128
  type: "invalidResponse"
131
129
  };
132
130
  }
133
- const { __typename, ...mutationData } = mutationResponse.data.transaction;
131
+ const { __typename, ok, errorMessage, ...mutationData } = mutationResponse.data.transaction;
134
132
  const aliases = Object.keys(mutationData);
135
133
  if (aliases.every((item) => mutationData[item].ok)) {
136
134
  const persistedEntityIds = aliases.map((alias) => mutationData[alias].node?.id).filter((id) => id !== void 0);
@@ -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,16 @@ 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
+ if (errorMessage) {
167
+ console.error(errorMessage);
168
+ }
169
+ this.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData, operations));
169
170
  await this.eventManager.triggerOnPersistError(persistErrorOptions);
170
171
  await onPersistError?.(persistErrorOptions);
171
172
  if (shouldTryAgain) {
@@ -191,9 +192,7 @@ const _DataBinding = class {
191
192
  if (options.signal?.aborted) {
192
193
  return Promise.reject(DataBindingExtendAborted);
193
194
  }
194
- const schema = await this.getOrLoadSchema();
195
- this.treeStore.setSchema(schema);
196
- const markerTreeRoot = new MarkerTreeGenerator(newFragment, (options.environment ?? this.environment).withSchema(schema)).generate();
195
+ const markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate();
197
196
  if (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {
198
197
  return this.eventManager.syncOperation(() => {
199
198
  const newTreeRootId = this.getNewTreeRootId();
@@ -243,7 +242,7 @@ const _DataBinding = class {
243
242
  return;
244
243
  }
245
244
  this.eventManager.syncOperation(() => {
246
- this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {});
245
+ this.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {}, aggregateMarkerTreeRoot);
247
246
  for (const extension of pendingExtensions) {
248
247
  this.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot);
249
248
  extension.resolve(extension.newTreeRootId);
@@ -259,17 +258,17 @@ const _DataBinding = class {
259
258
  signal
260
259
  });
261
260
  } catch (metadata) {
262
- if (metadata.name === "AbortError") {
261
+ if (typeof metadata === "object" && metadata !== null && metadata.name === "AbortError") {
263
262
  return;
264
263
  }
265
- this.onError(metadataToRequestError(metadata));
264
+ this.onError(metadataToRequestError(metadata), this);
266
265
  }
267
266
  if (queryResponse && queryResponse.errors !== void 0 && queryResponse.errors.length > 0) {
268
267
  this.onError({
269
268
  type: "gqlError",
270
269
  query: query ?? "unknown query",
271
270
  errors: queryResponse.errors
272
- });
271
+ }, this);
273
272
  }
274
273
  return queryResponse;
275
274
  }
@@ -310,24 +309,11 @@ const _DataBinding = class {
310
309
  }
311
310
  });
312
311
  }
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
312
  getNewTreeRootId() {
326
313
  return this.treeStore.markerTrees.size === 0 ? void 0 : `${generateEnumerabilityPreventingEntropy()}-${_DataBinding.getNextTreeRootIdSeed()}`;
327
314
  }
328
315
  };
329
316
  let DataBinding = _DataBinding;
330
- __publicField(DataBinding, "schemaLoadCache", /* @__PURE__ */ new Map());
331
317
  __publicField(DataBinding, "getNextTreeRootIdSeed", (() => {
332
318
  let seed = 1;
333
319
  return () => seed++;
@@ -1 +1 @@
1
- {"version":3,"file":"DataBinding.js","sources":["../../../src/core/DataBinding.ts"],"sourcesContent":["import type { GraphQlClient, GraphQlClientFailedRequestMetadata, TreeFilter } from '@contember/client'\nimport type { ReactNode } from 'react'\nimport {\n\tAsyncBatchUpdatesOptions,\n\tBatchUpdatesOptions,\n\tBindingOperations,\n\tExtendTreeOptions,\n\tPersistErrorOptions,\n\tPersistSuccessOptions,\n\tTreeRootAccessor,\n} from '../accessors'\nimport {\n\tmetadataToRequestError,\n\tMutationRequestResponse,\n\tQueryRequestResponse,\n\tRequestError,\n\tSuccessfulPersistResult,\n} from '../accessorTree'\nimport type { Environment } from '../dao'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { TreeRootId } from '../treeParameters'\nimport { assertNever, generateEnumerabilityPreventingEntropy } from '../utils'\nimport { AccessorErrorManager } from './AccessorErrorManager'\nimport { Config } from './Config'\nimport { DirtinessTracker } from './DirtinessTracker'\nimport { EventManager } from './EventManager'\nimport { createBatchUpdatesOptions } from './factories'\nimport { MarkerMerger } from './MarkerMerger'\nimport { MarkerTreeGenerator } from './MarkerTreeGenerator'\nimport { MutationGenerator } from './MutationGenerator'\nimport { QueryGenerator } from './QueryGenerator'\nimport { Schema, SchemaLoader } from './schema'\nimport { StateIterator } from './state'\nimport { StateInitializer } from './StateInitializer'\nimport { TreeAugmenter } from './TreeAugmenter'\nimport { TreeFilterGenerator } from './TreeFilterGenerator'\nimport { TreeStore } from './TreeStore'\nimport type { UpdateMetadata } from './UpdateMetadata'\nimport { getCombinedSignal } from './utils'\n\nexport class DataBinding {\n\tprivate static readonly schemaLoadCache: Map<string, Schema | Promise<Schema>> = new Map()\n\n\tprivate readonly accessorErrorManager: AccessorErrorManager\n\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions\n\tprivate readonly asyncBatchUpdatesOptions: AsyncBatchUpdatesOptions\n\tprivate readonly bindingOperations: BindingOperations\n\tprivate readonly config: Config\n\tprivate readonly dirtinessTracker: DirtinessTracker\n\tprivate readonly eventManager: EventManager\n\tprivate readonly stateInitializer: StateInitializer\n\tprivate readonly treeAugmenter: TreeAugmenter\n\tprivate readonly treeStore: TreeStore\n\n\t// private treeRootListeners: {\n\t// \teventListeners: {}\n\t// } = {\n\t// \teventListeners: {},\n\t// }\n\n\tpublic constructor(\n\t\tprivate readonly contentApiClient: GraphQlClient,\n\t\tprivate readonly systemApiClient: GraphQlClient,\n\t\tprivate readonly tenantApiClient: GraphQlClient,\n\t\tprivate readonly environment: Environment,\n\t\tprivate readonly onUpdate: (newData: TreeRootAccessor) => void,\n\t\tprivate readonly onError: (error: RequestError) => void,\n\t\tprivate readonly onPersistSuccess: (result: SuccessfulPersistResult) => void,\n\t) {\n\t\tthis.config = new Config()\n\t\tthis.treeStore = new TreeStore()\n\t\tthis.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore)\n\t\tthis.asyncBatchUpdatesOptions = {\n\t\t\t...this.batchUpdatesOptions,\n\t\t\tcontentClient: contentApiClient,\n\t\t\tsystemClient: systemApiClient,\n\t\t\ttenantClient: tenantApiClient,\n\t\t}\n\t\tthis.dirtinessTracker = new DirtinessTracker()\n\t\tthis.eventManager = new EventManager(\n\t\t\tthis.asyncBatchUpdatesOptions,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.dirtinessTracker,\n\t\t\tthis.resolvedOnUpdate,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.accessorErrorManager = new AccessorErrorManager(this.eventManager, this.treeStore)\n\t\tthis.stateInitializer = new StateInitializer(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.eventManager,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.treeAugmenter = new TreeAugmenter(this.eventManager, this.stateInitializer, this.treeStore)\n\n\t\t// TODO move this elsewhere\n\t\tthis.bindingOperations = Object.freeze<BindingOperations>({\n\t\t\t...this.asyncBatchUpdatesOptions,\n\t\t\tgetTreeFilters: (): TreeFilter[] => {\n\t\t\t\tconst generator = new TreeFilterGenerator(this.treeStore)\n\t\t\t\treturn generator.generateTreeFilter()\n\t\t\t},\n\t\t\tbatchDeferredUpdates: performUpdates => {\n\t\t\t\tthis.eventManager.syncTransaction(() => performUpdates(this.bindingOperations))\n\t\t\t},\n\t\t\textendTree: async (...args) => await this.extendTree(...args),\n\t\t\tpersist: async ({ signal, onPersistSuccess, onPersistError } = {}) =>\n\t\t\t\tawait this.eventManager.persistOperation(async () => {\n\t\t\t\t\tfor (let attemptNumber = 1; attemptNumber <= this.config.getValue('maxPersistAttempts'); attemptNumber++) {\n\t\t\t\t\t\t// TODO if the tree is in an inconsistent state, wait for lock releases\n\n\t\t\t\t\t\tthis.eventManager.syncTransaction(() => {\n\t\t\t\t\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait this.eventManager.triggerOnBeforePersist()\n\n\t\t\t\t\t\tlet shouldTryAgain = false\n\t\t\t\t\t\tconst proposedBackOffs: number[] = []\n\t\t\t\t\t\tconst persistErrorOptions: PersistErrorOptions = {\n\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\ttryAgain: options => {\n\t\t\t\t\t\t\t\tshouldTryAgain = true\n\t\t\t\t\t\t\t\tif (options?.proposedBackoff !== undefined && options.proposedBackoff > 0) {\n\t\t\t\t\t\t\t\t\tproposedBackOffs.push(options.proposedBackoff)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattemptNumber,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.accessorErrorManager.hasErrors()) {\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tcontinue // Trying again immediately\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst generator = new MutationGenerator(this.treeStore)\n\t\t\t\t\t\tconst mutation = generator.getPersistMutation()\n\n\t\t\t\t\t\tif (mutation === undefined) {\n\t\t\t\t\t\t\tthis.dirtinessTracker.reset() // TODO This ideally shouldn't be necessary but given the current limitations, this makes for better UX.\n\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\tsuccessType: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(mutation, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tif (mutationResponse.errors !== undefined && mutationResponse.errors.length > 0) {\n\t\t\t\t\t\t\tthis.onError({\n\t\t\t\t\t\t\t\ttype: 'gqlError',\n\t\t\t\t\t\t\t\tquery: mutation,\n\t\t\t\t\t\t\t\terrors: mutationResponse.errors,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!mutationResponse.data?.transaction) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: [],\n\t\t\t\t\t\t\t\ttype: 'invalidResponse',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { __typename, ...mutationData } = mutationResponse.data.transaction\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (aliases.every(item => mutationData[item].ok)) {\n\t\t\t\t\t\t\tconst persistedEntityIds = aliases.map(alias => mutationData[alias].node?.id).filter(id => id !== undefined)\n\t\t\t\t\t\t\tconst result: SuccessfulPersistResult = {\n\t\t\t\t\t\t\t\ttype: 'justSuccess',\n\t\t\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait this.eventManager.asyncTransaction(async () => {\n\t\t\t\t\t\t\t\t\tthis.resetTreeAfterSuccessfulPersist()\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.updatePersistedData(\n\t\t\t\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\t\t\t\tObject.entries(mutationData).map(([placeholderName, subTreeResponse]) => [\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\t\t\t\t\tsubTreeResponse.node,\n\t\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\t\t\tsuccessType: result.type,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.resetCreatingSubTrees()\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.error(e)\n\t\t\t\t\t\t\t\tconst resultWithError = {\n\t\t\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t\t\tafterPersistError: e,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.onPersistSuccess(resultWithError)\n\t\t\t\t\t\t\t\treturn resultWithError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.onPersistSuccess(result)\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData))\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tif (proposedBackOffs.length) {\n\t\t\t\t\t\t\t\t\tconst geometricMean = Math.round(\n\t\t\t\t\t\t\t\t\t\tMath.pow(\n\t\t\t\t\t\t\t\t\t\t\tproposedBackOffs.reduce((a, b) => a * b, 1),\n\t\t\t\t\t\t\t\t\t\t\t1 / proposedBackOffs.length,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, geometricMean))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Max attempts exceeded\n\t\t\t\t\t// TODO fire persist error\n\t\t\t\t\tthrow {\n\t\t\t\t\t\ttype: 'givenUp',\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t})\n\t}\n\n\tprivate resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {\n\t\tthis.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations))\n\t}\n\n\t// This is currently useless but potentially future-compatible\n\t// private readonly addTreeRootEventListener: TreeRootAccessor.AddTreeRootEventListener = this.getAddEventListener(\n\t// \tthis.treeRootListeners,\n\t// )\n\n\tprivate pendingExtensions: Set<{\n\t\tmarkerTreeRoot: MarkerTreeRoot\n\t\tnewFragment: ReactNode\n\t\tnewTreeRootId: TreeRootId | undefined\n\t\toptions: ExtendTreeOptions\n\t\treject: () => void\n\t\tresolve: (newRootId: TreeRootId | undefined) => void\n\t}> = new Set()\n\n\tpublic async extendTree(newFragment: ReactNode, options: ExtendTreeOptions = {}): Promise<TreeRootId | undefined> {\n\t\tif (options.signal?.aborted) {\n\t\t\treturn Promise.reject(DataBindingExtendAborted)\n\t\t}\n\t\tconst schema = await this.getOrLoadSchema()\n\t\tthis.treeStore.setSchema(schema)\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, (options.environment ?? this.environment).withSchema(schema)).generate()\n\n\t\tif (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {\n\t\t\t// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this\n\t\t\t// could still be false.\n\n\t\t\treturn this.eventManager.syncOperation(() => {\n\t\t\t\tconst newTreeRootId = this.getNewTreeRootId()\n\t\t\t\tthis.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)\n\t\t\t\treturn newTreeRootId\n\t\t\t})\n\t\t}\n\n\t\treturn await new Promise((resolve, reject) => {\n\t\t\tthis.pendingExtensions.add({\n\t\t\t\tmarkerTreeRoot,\n\t\t\t\tnewFragment,\n\t\t\t\tnewTreeRootId: this.getNewTreeRootId(),\n\t\t\t\toptions,\n\t\t\t\treject: () => reject(DataBindingExtendAborted),\n\t\t\t\tresolve,\n\t\t\t})\n\t\t\tconst pendingExtensionsCount = this.pendingExtensions.size\n\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (pendingExtensionsCount < this.pendingExtensions.size) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.flushBatchedTreeExtensions()\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async flushBatchedTreeExtensions() {\n\t\t// This is an async operation so we just take whatever pendingExtensions there are now and let any new ones\n\t\t// accumulate in an empty set.\n\t\tconst pendingExtensions = Array.from(this.pendingExtensions).filter(extension => {\n\t\t\tif (extension.options.signal?.aborted) {\n\t\t\t\textension.reject()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\tthis.pendingExtensions.clear()\n\n\t\tconst aggregateMarkerTreeRoot = pendingExtensions.reduce<MarkerTreeRoot | undefined>(\n\t\t\t(previousValue, currentValue) => {\n\t\t\t\tif (previousValue === undefined) {\n\t\t\t\t\treturn currentValue.markerTreeRoot\n\t\t\t\t}\n\t\t\t\treturn MarkerMerger.mergeMarkerTreeRoots(previousValue, currentValue.markerTreeRoot)\n\t\t\t},\n\t\t\tundefined,\n\t\t)\n\n\t\tif (aggregateMarkerTreeRoot === undefined) {\n\t\t\treturn\n\t\t}\n\n\t\tconst aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))\n\n\t\tconst aggregatePersistedData = await this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal)\n\n\t\tif (aggregateSignal?.aborted) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {})\n\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tthis.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)\n\t\t\t\textension.resolve(extension.newTreeRootId)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate async fetchPersistedData(\n\t\ttree: MarkerTreeRoot,\n\t\tsignal?: AbortSignal,\n\t): Promise<QueryRequestResponse | undefined> {\n\t\tconst queryGenerator = new QueryGenerator(tree)\n\t\tconst query = queryGenerator.getReadQuery()\n\n\t\tlet queryResponse: QueryRequestResponse | undefined = undefined\n\n\t\ttry {\n\t\t\tqueryResponse =\n\t\t\t\tquery === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t })\n\t\t} catch (metadata) {\n\t\t\tif (metadata.name === 'AbortError') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata))\n\t\t}\n\n\t\tif (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {\n\t\t\tthis.onError({\n\t\t\t\ttype: 'gqlError',\n\t\t\t\tquery: query ?? 'unknown query',\n\t\t\t\terrors: queryResponse.errors,\n\t\t\t})\n\t\t}\n\n\t\treturn queryResponse\n\t}\n\n\tprivate resetTreeAfterSuccessfulPersist() {\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\tthis.dirtinessTracker.reset()\n\n\t\t\tfor (const [, rootState] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\t\tfor (const state of StateIterator.depthFirstAllNodes(rootState)) {\n\t\t\t\t\tswitch (state.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tif (state.hasUnpersistedChanges || state.touchLog?.size) {\n\t\t\t\t\t\t\t\tstate.touchLog?.clear()\n\t\t\t\t\t\t\t\tstate.hasUnpersistedChanges = false\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedRemovals?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedRemovals?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedHasOneDeletions?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedHasOneDeletions?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(state)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate getOrLoadSchema(): Schema | Promise<Schema> {\n\t\tconst existing = DataBinding.schemaLoadCache.get(this.contentApiClient.apiUrl)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst schemaPromise = SchemaLoader.loadSchema(this.contentApiClient, this.config.getValue('maxSchemaLoadAttempts'))\n\t\tschemaPromise.then(schema => {\n\t\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schema)\n\t\t})\n\t\tDataBinding.schemaLoadCache.set(this.contentApiClient.apiUrl, schemaPromise)\n\t\treturn schemaPromise\n\t}\n\n\tprivate static getNextTreeRootIdSeed = (() => {\n\t\tlet seed = 1\n\t\treturn () => seed++\n\t})()\n\n\tprivate getNewTreeRootId() {\n\t\t// TODO this is an awful, awful hack.\n\t\t// TODO the particular shape of the alias is relied on in MutationAlias. If you change this, change it there too.\n\t\treturn this.treeStore.markerTrees.size === 0\n\t\t\t? undefined\n\t\t\t: `${generateEnumerabilityPreventingEntropy()}-${DataBinding.getNextTreeRootIdSeed()}`\n\t}\n}\n\nexport const DataBindingExtendAborted = Symbol('aborted')\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAwCO,2BAAkB;AAAA,EAoBjB,YACW,kBACA,iBACA,iBACA,aACA,UACA,SACA,kBAChB;AAzBe;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAsMT,4CAAmB,CAAC,EAAE,iBAAiC;AACzD,WAAA,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,cAAc,YAAY,KAAK,iBAAiB,CAAC;AAAA,IAAA;AAQnG,iEAOC;AA7MS,SAAA,mBAAA;AACA,SAAA,kBAAA;AACA,SAAA,kBAAA;AACA,SAAA,cAAA;AACA,SAAA,WAAA;AACA,SAAA,UAAA;AACA,SAAA,mBAAA;AAEZ,SAAA,SAAS,IAAI;AACb,SAAA,YAAY,IAAI;AACrB,SAAK,sBAAsB,0BAA0B,aAAa,KAAK,SAAS;AAChF,SAAK,2BAA2B;AAAA,SAC5B,KAAK;AAAA,MACR,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA,IAAA;AAEV,SAAA,mBAAmB,IAAI;AAC5B,SAAK,eAAe,IAAI,aACvB,KAAK,0BACL,KAAK,qBACL,KAAK,QACL,KAAK,kBACL,KAAK,kBACL,KAAK,SACN;AACA,SAAK,uBAAuB,IAAI,qBAAqB,KAAK,cAAc,KAAK,SAAS;AACtF,SAAK,mBAAmB,IAAI,iBAC3B,KAAK,sBACL,KAAK,qBACL,KAAK,QACL,KAAK,cACL,KAAK,SACN;AACK,SAAA,gBAAgB,IAAI,cAAc,KAAK,cAAc,KAAK,kBAAkB,KAAK,SAAS;AAG1F,SAAA,oBAAoB,OAAO,OAA0B;AAAA,SACtD,KAAK;AAAA,MACR,gBAAgB,MAAoB;AACnC,cAAM,YAAY,IAAI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AwB;AAC9B,qBAAK,aAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,cAChF;AACA;AAAA,YACD;AAAA;AAEC,0BAAiB;AAAA;AAAA,QAEpB;AAAA,MACD;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAEQ,kBAA4C;AACnD,UAAM,WAAW,aAAY,gBAAgB,IAAI,KAAK,iBAAiB,MAAM;AAC7E,QAAI,aAAa,QAAW;AACpB,aAAA;AAAA,IACR;AAEM,UAAA,gBAAgB,aAAa,WAAW,KAAK,kBAAkB,KAAK,OAAO,SAAS,uBAAuB,CAAC;AAClH,kBAAc,KAAK,CAAU,WAAA;AAC5B,mBAAY,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ,MAAM;AAAA,IAAA,CACpE;AACD,iBAAY,gBAAgB,IAAI,KAAK,iBAAiB,QAAQ,aAAa;AACpE,WAAA;AAAA,EACR;AAAA,EAOQ,mBAAmB;AAGnB,WAAA,KAAK,UAAU,YAAY,SAAS,IACxC,SACA,GAAG,uCAA4C,KAAA,aAAY,sBAAsB;AAAA,EACrF;AACD;AA1ZO;AACkB,cADlB,aACkB,uCAA6D;AA6YtE,cA9YT,aA8YS,yBAA+B,OAAA;AAC7C,MAAI,OAAO;AACX,SAAO,MAAM;AAAA;AAYF,MAAA,2BAA2B,OAAO,SAAS;;"}
1
+ {"version":3,"file":"DataBinding.js","sources":["../../../src/core/DataBinding.ts"],"sourcesContent":["import type { GraphQlClient, GraphQlClientFailedRequestMetadata, TreeFilter } from '@contember/client'\nimport type { ReactNode } from 'react'\nimport {\n\tAsyncBatchUpdatesOptions,\n\tBatchUpdatesOptions,\n\tBindingOperations,\n\tExtendTreeOptions,\n\tPersistErrorOptions,\n\tPersistSuccessOptions,\n\tTreeRootAccessor,\n} from '../accessors'\nimport {\n\tmetadataToRequestError,\n\tMutationRequestResponse,\n\tQueryRequestResponse,\n\tRequestError,\n\tSuccessfulPersistResult,\n} from '../accessorTree'\nimport type { Environment } from '../dao'\nimport type { MarkerTreeRoot } from '../markers'\nimport type { TreeRootId } from '../treeParameters'\nimport { assertNever, generateEnumerabilityPreventingEntropy } from '../utils'\nimport { AccessorErrorManager } from './AccessorErrorManager'\nimport { Config } from './Config'\nimport { DirtinessTracker } from './DirtinessTracker'\nimport { EventManager } from './EventManager'\nimport { createBatchUpdatesOptions } from './factories'\nimport { MarkerMerger } from './MarkerMerger'\nimport { MarkerTreeGenerator } from './MarkerTreeGenerator'\nimport { MutationGenerator } from './MutationGenerator'\nimport { QueryGenerator } from './QueryGenerator'\nimport { StateIterator } from './state'\nimport { StateInitializer } from './StateInitializer'\nimport { TreeAugmenter } from './TreeAugmenter'\nimport { TreeFilterGenerator } from './TreeFilterGenerator'\nimport { TreeStore } from './TreeStore'\nimport type { UpdateMetadata } from './UpdateMetadata'\nimport { getCombinedSignal } from './utils'\n\nexport class DataBinding {\n\tprivate readonly accessorErrorManager: AccessorErrorManager\n\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions\n\tprivate readonly asyncBatchUpdatesOptions: AsyncBatchUpdatesOptions\n\tprivate readonly bindingOperations: BindingOperations\n\tprivate readonly config: Config\n\tprivate readonly dirtinessTracker: DirtinessTracker\n\tprivate readonly eventManager: EventManager\n\tprivate readonly stateInitializer: StateInitializer\n\tprivate readonly treeAugmenter: TreeAugmenter\n\n\t// private treeRootListeners: {\n\t// \teventListeners: {}\n\t// } = {\n\t// \teventListeners: {},\n\t// }\n\n\tpublic constructor(\n\t\tprivate readonly contentApiClient: GraphQlClient,\n\t\tprivate readonly systemApiClient: GraphQlClient,\n\t\tprivate readonly tenantApiClient: GraphQlClient,\n\t\tprivate readonly treeStore: TreeStore,\n\t\tprivate readonly environment: Environment,\n\t\tprivate readonly onUpdate: (newData: TreeRootAccessor, binding: DataBinding) => void,\n\t\tprivate readonly onError: (error: RequestError, binding: DataBinding) => void,\n\t\tprivate readonly onPersistSuccess: (result: SuccessfulPersistResult, binding: DataBinding) => void,\n\t) {\n\t\tthis.config = new Config()\n\t\tthis.batchUpdatesOptions = createBatchUpdatesOptions(environment, this.treeStore)\n\t\tthis.asyncBatchUpdatesOptions = {\n\t\t\t...this.batchUpdatesOptions,\n\t\t\tcontentClient: contentApiClient,\n\t\t\tsystemClient: systemApiClient,\n\t\t\ttenantClient: tenantApiClient,\n\t\t}\n\t\tthis.dirtinessTracker = new DirtinessTracker()\n\t\tthis.eventManager = new EventManager(\n\t\t\tthis.asyncBatchUpdatesOptions,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.config,\n\t\t\tthis.dirtinessTracker,\n\t\t\tthis.resolvedOnUpdate,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.accessorErrorManager = new AccessorErrorManager(this.eventManager, this.treeStore)\n\t\tthis.stateInitializer = new StateInitializer(\n\t\t\tthis.accessorErrorManager,\n\t\t\tthis.batchUpdatesOptions,\n\t\t\tthis.eventManager,\n\t\t\tthis.treeStore,\n\t\t)\n\t\tthis.treeAugmenter = new TreeAugmenter(this.eventManager, this.stateInitializer, this.treeStore)\n\n\t\t// TODO move this elsewhere\n\t\tthis.bindingOperations = Object.freeze<BindingOperations>({\n\t\t\t...this.asyncBatchUpdatesOptions,\n\t\t\tgetTreeFilters: (): TreeFilter[] => {\n\t\t\t\tconst generator = new TreeFilterGenerator(this.treeStore)\n\t\t\t\treturn generator.generateTreeFilter()\n\t\t\t},\n\t\t\tbatchDeferredUpdates: performUpdates => {\n\t\t\t\tthis.eventManager.syncTransaction(() => performUpdates(this.bindingOperations))\n\t\t\t},\n\t\t\textendTree: async (...args) => await this.extendTree(...args),\n\t\t\tpersist: async ({ signal, onPersistSuccess, onPersistError } = {}) =>\n\t\t\t\tawait this.eventManager.persistOperation(async () => {\n\t\t\t\t\tfor (let attemptNumber = 1; attemptNumber <= this.config.getValue('maxPersistAttempts'); attemptNumber++) {\n\t\t\t\t\t\t// TODO if the tree is in an inconsistent state, wait for lock releases\n\n\t\t\t\t\t\tthis.eventManager.syncTransaction(() => {\n\t\t\t\t\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\t\t\t\t})\n\t\t\t\t\t\tawait this.eventManager.triggerOnBeforePersist()\n\n\t\t\t\t\t\tlet shouldTryAgain = false\n\t\t\t\t\t\tconst proposedBackOffs: number[] = []\n\t\t\t\t\t\tconst persistErrorOptions: PersistErrorOptions = {\n\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\ttryAgain: options => {\n\t\t\t\t\t\t\t\tshouldTryAgain = true\n\t\t\t\t\t\t\t\tif (options?.proposedBackoff !== undefined && options.proposedBackoff > 0) {\n\t\t\t\t\t\t\t\t\tproposedBackOffs.push(options.proposedBackoff)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tattemptNumber,\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (this.accessorErrorManager.hasErrors()) {\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tcontinue // Trying again immediately\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst generator = new MutationGenerator(this.treeStore)\n\t\t\t\t\t\tconst mutationResult = generator.getPersistMutation()\n\n\t\t\t\t\t\tif (mutationResult === undefined) {\n\t\t\t\t\t\t\tthis.dirtinessTracker.reset() // TODO This ideally shouldn't be necessary but given the current limitations, this makes for better UX.\n\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\tsuccessType: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: 'nothingToPersist',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { query, operations } = mutationResult\n\n\t\t\t\t\t\tconst mutationResponse: MutationRequestResponse = await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t})\n\n\t\t\t\t\t\tif (mutationResponse.errors !== undefined && mutationResponse.errors.length > 0) {\n\t\t\t\t\t\t\tthis.onError({\n\t\t\t\t\t\t\t\ttype: 'gqlError',\n\t\t\t\t\t\t\t\tquery,\n\t\t\t\t\t\t\t\terrors: mutationResponse.errors,\n\t\t\t\t\t\t\t}, this)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (!mutationResponse.data?.transaction) {\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: [],\n\t\t\t\t\t\t\t\ttype: 'invalidResponse',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst { __typename, ok, errorMessage, ...mutationData } = mutationResponse.data.transaction\n\t\t\t\t\t\tconst aliases = Object.keys(mutationData)\n\t\t\t\t\t\tif (aliases.every(item => mutationData[item].ok)) {\n\t\t\t\t\t\t\tconst persistedEntityIds = aliases.map(alias => mutationData[alias].node?.id).filter(id => id !== undefined)\n\t\t\t\t\t\t\tconst result: SuccessfulPersistResult = {\n\t\t\t\t\t\t\t\ttype: 'justSuccess',\n\t\t\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tawait this.eventManager.asyncTransaction(async () => {\n\t\t\t\t\t\t\t\t\tthis.resetTreeAfterSuccessfulPersist()\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.updatePersistedData(\n\t\t\t\t\t\t\t\t\t\tObject.fromEntries(\n\t\t\t\t\t\t\t\t\t\t\tObject.entries(mutationData).map(([placeholderName, subTreeResponse]) => [\n\t\t\t\t\t\t\t\t\t\t\t\tplaceholderName,\n\t\t\t\t\t\t\t\t\t\t\t\tsubTreeResponse.node,\n\t\t\t\t\t\t\t\t\t\t\t]),\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\toperations,\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tconst persistSuccessOptions: PersistSuccessOptions = {\n\t\t\t\t\t\t\t\t\t\t...this.bindingOperations,\n\t\t\t\t\t\t\t\t\t\tsuccessType: result.type,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistSuccess(persistSuccessOptions)\n\t\t\t\t\t\t\t\t\tawait onPersistSuccess?.(persistSuccessOptions)\n\n\t\t\t\t\t\t\t\t\tthis.treeAugmenter.resetCreatingSubTrees()\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t\tconsole.error(e)\n\t\t\t\t\t\t\t\tconst resultWithError = {\n\t\t\t\t\t\t\t\t\t...result,\n\t\t\t\t\t\t\t\t\tafterPersistError: e,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tthis.onPersistSuccess(resultWithError, this)\n\t\t\t\t\t\t\t\treturn resultWithError\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.onPersistSuccess(result, this)\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (errorMessage) {\n\t\t\t\t\t\t\t\tconsole.error(errorMessage)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.eventManager.syncTransaction(() => this.accessorErrorManager.replaceErrors(mutationData, operations))\n\t\t\t\t\t\t\tawait this.eventManager.triggerOnPersistError(persistErrorOptions)\n\t\t\t\t\t\t\tawait onPersistError?.(persistErrorOptions)\n\t\t\t\t\t\t\tif (shouldTryAgain) {\n\t\t\t\t\t\t\t\tif (proposedBackOffs.length) {\n\t\t\t\t\t\t\t\t\tconst geometricMean = Math.round(\n\t\t\t\t\t\t\t\t\t\tMath.pow(\n\t\t\t\t\t\t\t\t\t\t\tproposedBackOffs.reduce((a, b) => a * b, 1),\n\t\t\t\t\t\t\t\t\t\t\t1 / proposedBackOffs.length,\n\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\tawait new Promise(resolve => setTimeout(resolve, geometricMean))\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tcontinue\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthrow {\n\t\t\t\t\t\t\t\terrors: this.accessorErrorManager.getErrors(),\n\t\t\t\t\t\t\t\ttype: 'invalidInput',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t// Max attempts exceeded\n\t\t\t\t\t// TODO fire persist error\n\t\t\t\t\tthrow {\n\t\t\t\t\t\ttype: 'givenUp',\n\t\t\t\t\t}\n\t\t\t\t}),\n\t\t})\n\t}\n\n\tprivate resolvedOnUpdate = ({ isMutating }: UpdateMetadata) => {\n\t\tthis.onUpdate(new TreeRootAccessor(this.dirtinessTracker.hasChanges(), isMutating, this.bindingOperations), this)\n\t}\n\n\t// This is currently useless but potentially future-compatible\n\t// private readonly addTreeRootEventListener: TreeRootAccessor.AddTreeRootEventListener = this.getAddEventListener(\n\t// \tthis.treeRootListeners,\n\t// )\n\n\tprivate pendingExtensions: Set<{\n\t\tmarkerTreeRoot: MarkerTreeRoot\n\t\tnewFragment: ReactNode\n\t\tnewTreeRootId: TreeRootId | undefined\n\t\toptions: ExtendTreeOptions\n\t\treject: () => void\n\t\tresolve: (newRootId: TreeRootId | undefined) => void\n\t}> = new Set()\n\n\tpublic async extendTree(newFragment: ReactNode, options: ExtendTreeOptions = {}): Promise<TreeRootId | undefined> {\n\t\tif (options.signal?.aborted) {\n\t\t\treturn Promise.reject(DataBindingExtendAborted)\n\t\t}\n\t\tconst markerTreeRoot = new MarkerTreeGenerator(newFragment, options.environment ?? this.environment).generate()\n\n\t\tif (this.treeStore.effectivelyHasTreeRoot(markerTreeRoot)) {\n\t\t\t// This isn't perfectly accurate as theoretically, we could already have all the data necessary but this\n\t\t\t// could still be false.\n\n\t\t\treturn this.eventManager.syncOperation(() => {\n\t\t\t\tconst newTreeRootId = this.getNewTreeRootId()\n\t\t\t\tthis.treeAugmenter.extendTreeStates(newTreeRootId, markerTreeRoot)\n\t\t\t\treturn newTreeRootId\n\t\t\t})\n\t\t}\n\n\t\treturn await new Promise((resolve, reject) => {\n\t\t\tthis.pendingExtensions.add({\n\t\t\t\tmarkerTreeRoot,\n\t\t\t\tnewFragment,\n\t\t\t\tnewTreeRootId: this.getNewTreeRootId(),\n\t\t\t\toptions,\n\t\t\t\treject: () => reject(DataBindingExtendAborted),\n\t\t\t\tresolve,\n\t\t\t})\n\t\t\tconst pendingExtensionsCount = this.pendingExtensions.size\n\n\t\t\tPromise.resolve().then(() => {\n\t\t\t\tif (pendingExtensionsCount < this.pendingExtensions.size) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tthis.flushBatchedTreeExtensions()\n\t\t\t})\n\t\t})\n\t}\n\n\tprivate async flushBatchedTreeExtensions() {\n\t\t// This is an async operation so we just take whatever pendingExtensions there are now and let any new ones\n\t\t// accumulate in an empty set.\n\t\tconst pendingExtensions = Array.from(this.pendingExtensions).filter(extension => {\n\t\t\tif (extension.options.signal?.aborted) {\n\t\t\t\textension.reject()\n\t\t\t\treturn false\n\t\t\t}\n\t\t\treturn true\n\t\t})\n\t\tthis.pendingExtensions.clear()\n\n\t\tconst aggregateMarkerTreeRoot = pendingExtensions.reduce<MarkerTreeRoot | undefined>(\n\t\t\t(previousValue, currentValue) => {\n\t\t\t\tif (previousValue === undefined) {\n\t\t\t\t\treturn currentValue.markerTreeRoot\n\t\t\t\t}\n\t\t\t\treturn MarkerMerger.mergeMarkerTreeRoots(previousValue, currentValue.markerTreeRoot)\n\t\t\t},\n\t\t\tundefined,\n\t\t)\n\n\t\tif (aggregateMarkerTreeRoot === undefined) {\n\t\t\treturn\n\t\t}\n\n\t\tconst aggregateSignal = getCombinedSignal(pendingExtensions.map(extension => extension.options.signal))\n\n\t\tconst aggregatePersistedData = await this.fetchPersistedData(aggregateMarkerTreeRoot, aggregateSignal)\n\n\t\tif (aggregateSignal?.aborted) {\n\t\t\treturn\n\t\t}\n\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.treeAugmenter.extendPersistedData(aggregatePersistedData?.data ?? {}, aggregateMarkerTreeRoot)\n\n\t\t\tfor (const extension of pendingExtensions) {\n\t\t\t\tthis.treeAugmenter.extendTreeStates(extension.newTreeRootId, extension.markerTreeRoot)\n\t\t\t\textension.resolve(extension.newTreeRootId)\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate async fetchPersistedData(\n\t\ttree: MarkerTreeRoot,\n\t\tsignal?: AbortSignal,\n\t): Promise<QueryRequestResponse | undefined> {\n\t\tconst queryGenerator = new QueryGenerator(tree)\n\t\tconst query = queryGenerator.getReadQuery()\n\n\t\tlet queryResponse: QueryRequestResponse | undefined = undefined\n\n\t\ttry {\n\t\t\tqueryResponse =\n\t\t\t\tquery === undefined\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.contentApiClient.sendRequest(query, {\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t })\n\t\t} catch (metadata) {\n\t\t\tif (typeof metadata === 'object' && metadata !== null && (metadata as { name?: unknown }).name === 'AbortError') {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.onError(metadataToRequestError(metadata as GraphQlClientFailedRequestMetadata), this)\n\t\t}\n\n\t\tif (queryResponse && queryResponse.errors !== undefined && queryResponse.errors.length > 0) {\n\t\t\tthis.onError({\n\t\t\t\ttype: 'gqlError',\n\t\t\t\tquery: query ?? 'unknown query',\n\t\t\t\terrors: queryResponse.errors,\n\t\t\t}, this)\n\t\t}\n\n\t\treturn queryResponse\n\t}\n\n\tprivate resetTreeAfterSuccessfulPersist() {\n\t\tthis.eventManager.syncTransaction(() => {\n\t\t\tthis.accessorErrorManager.clearErrors()\n\t\t\tthis.dirtinessTracker.reset()\n\n\t\t\tfor (const [, rootState] of StateIterator.eachRootState(this.treeStore)) {\n\t\t\t\tfor (const state of StateIterator.depthFirstAllNodes(rootState)) {\n\t\t\t\t\tswitch (state.type) {\n\t\t\t\t\t\tcase 'field': {\n\t\t\t\t\t\t\tif (state.hasUnpersistedChanges || state.touchLog?.size) {\n\t\t\t\t\t\t\t\tstate.touchLog?.clear()\n\t\t\t\t\t\t\t\tstate.hasUnpersistedChanges = false\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedRemovals?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedRemovals?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\t\tif (state.unpersistedChangesCount > 0 || state.plannedHasOneDeletions?.size) {\n\t\t\t\t\t\t\t\tstate.unpersistedChangesCount = 0\n\t\t\t\t\t\t\t\tstate.plannedHasOneDeletions?.clear()\n\t\t\t\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tassertNever(state)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})\n\t}\n\n\tprivate static getNextTreeRootIdSeed = (() => {\n\t\tlet seed = 1\n\t\treturn () => seed++\n\t})()\n\n\tprivate getNewTreeRootId() {\n\t\t// TODO this is an awful, awful hack.\n\t\t// TODO the particular shape of the alias is relied on in MutationAlias. If you change this, change it there too.\n\t\treturn this.treeStore.markerTrees.size === 0\n\t\t\t? undefined\n\t\t\t: `${generateEnumerabilityPreventingEntropy()}-${DataBinding.getNextTreeRootIdSeed()}`\n\t}\n}\n\nexport const DataBindingExtendAborted = Symbol('aborted')\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuCO,2BAAkB;AAAA,EAiBjB,YACW,kBACA,iBACA,iBACA,WACA,aACA,UACA,SACA,kBAChB;AAzBe;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AA0MT,4CAAmB,CAAC,EAAE,iBAAiC;AACzD,WAAA,SAAS,IAAI,iBAAiB,KAAK,iBAAiB,WAAW,GAAG,YAAY,KAAK,iBAAiB,GAAG,IAAI;AAAA,IAAA;AAQzG,iEAOC;AAjNS,SAAA,mBAAA;AACA,SAAA,kBAAA;AACA,SAAA,kBAAA;AACA,SAAA,YAAA;AACA,SAAA,cAAA;AACA,SAAA,WAAA;AACA,SAAA,UAAA;AACA,SAAA,mBAAA;AAEZ,SAAA,SAAS,IAAI;AAClB,SAAK,sBAAsB,0BAA0B,aAAa,KAAK,SAAS;AAChF,SAAK,2BAA2B;AAAA,SAC5B,KAAK;AAAA,MACR,eAAe;AAAA,MACf,cAAc;AAAA,MACd,cAAc;AAAA,IAAA;AAEV,SAAA,mBAAmB,IAAI;AAC5B,SAAK,eAAe,IAAI,aACvB,KAAK,0BACL,KAAK,qBACL,KAAK,QACL,KAAK,kBACL,KAAK,kBACL,KAAK,SACN;AACA,SAAK,uBAAuB,IAAI,qBAAqB,KAAK,cA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AAK,aAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,cAChF;AACA;AAAA,YACD;AAAA,iBACK;AACJ,kBAAI,MAAM,0BAA0B,KAAK,MAAM,iBAAiB,MAAM;AACrE,sBAAM,0BAA0B;AAChC,sBAAM,iBAAiB;AACvB,qBAAK,aAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,cAChF;AACA;AAAA,iBACI,eAAe;AACnB,kBAAI,MAAM,0BAA0B,KAAK,MAAM,wBAAwB,MAAM;AAC5E,sBAAM,0BAA0B;AAChC,sBAAM,wBAAwB;AAC9B,qBAAK,aAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,cAChF;AACA;AAAA,YACD;AAAA;AAEC,0BAAiB;AAAA;AAAA,QAEpB;AAAA,MACD;AAAA,IAAA,CACA;AAAA,EACF;AAAA,EAOQ,mBAAmB;AAGnB,WAAA,KAAK,UAAU,YAAY,SAAS,IACxC,SACA,GAAG,uCAA4C,KAAA,aAAY,sBAAsB;AAAA,EACrF;AACD;AA3YO;AA+XS,cA/XT,aA+XS,yBAA+B,OAAA;AAC7C,MAAI,OAAO;AACX,SAAO,MAAM;AAAA;AAYF,MAAA,2BAA2B,OAAO,SAAS;;"}
@@ -7,13 +7,10 @@ var __publicField = (obj, key, value) => {
7
7
  class DirtinessTracker {
8
8
  constructor() {
9
9
  __publicField(this, "changesCount", 0);
10
- __publicField(this, "totalChangesCount", 0);
10
+ __publicField(this, "touchedCount", 0);
11
11
  }
12
- getChangesCount() {
13
- return this.changesCount;
14
- }
15
- getTotalChangesCount() {
16
- return this.totalChangesCount;
12
+ getTotalTouchCount() {
13
+ return this.touchedCount;
17
14
  }
18
15
  hasChanges() {
19
16
  return this.changesCount > 0;
@@ -21,15 +18,9 @@ class DirtinessTracker {
21
18
  reset() {
22
19
  this.changesCount = 0;
23
20
  }
24
- increment() {
25
- this.totalChangesCount++;
26
- this.changesCount++;
27
- }
28
- decrement() {
29
- this.changesCount--;
30
- }
31
21
  increaseBy(delta) {
32
22
  this.changesCount += delta;
23
+ this.touchedCount++;
33
24
  }
34
25
  }
35
26
  export { DirtinessTracker };
@@ -1 +1 @@
1
- {"version":3,"file":"DirtinessTracker.js","sources":["../../../src/core/DirtinessTracker.ts"],"sourcesContent":["export class DirtinessTracker {\n\tprivate changesCount = 0\n\tprivate totalChangesCount = 0\n\n\tpublic getChangesCount() {\n\t\treturn this.changesCount\n\t}\n\n\tpublic getTotalChangesCount() {\n\t\treturn this.totalChangesCount\n\t}\n\n\tpublic hasChanges() {\n\t\treturn this.changesCount > 0\n\t}\n\n\tpublic reset() {\n\t\tthis.changesCount = 0\n\t}\n\n\tpublic increment() {\n\t\tthis.totalChangesCount++\n\t\tthis.changesCount++\n\t}\n\n\tpublic decrement() {\n\t\tthis.changesCount--\n\t}\n\n\tpublic increaseBy(delta: number) {\n\t\tthis.changesCount += delta\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAAO,MAAM,iBAAiB;AAAA,EAAvB;AACE,wCAAe;AACf,6CAAoB;AAAA;AAAA,EAErB,kBAAkB;AACxB,WAAO,KAAK;AAAA,EACb;AAAA,EAEO,uBAAuB;AAC7B,WAAO,KAAK;AAAA,EACb;AAAA,EAEO,aAAa;AACnB,WAAO,KAAK,eAAe;AAAA,EAC5B;AAAA,EAEO,QAAQ;AACd,SAAK,eAAe;AAAA,EACrB;AAAA,EAEO,YAAY;AACb,SAAA;AACA,SAAA;AAAA,EACN;AAAA,EAEO,YAAY;AACb,SAAA;AAAA,EACN;AAAA,EAEO,WAAW,OAAe;AAChC,SAAK,gBAAgB;AAAA,EACtB;AACD;;"}
1
+ {"version":3,"file":"DirtinessTracker.js","sources":["../../../src/core/DirtinessTracker.ts"],"sourcesContent":["export class DirtinessTracker {\n\tprivate changesCount = 0\n\tprivate touchedCount = 0\n\n\tpublic getTotalTouchCount() {\n\t\treturn this.touchedCount\n\t}\n\n\tpublic hasChanges() {\n\t\treturn this.changesCount > 0\n\t}\n\n\tpublic reset() {\n\t\tthis.changesCount = 0\n\t}\n\n\tpublic increaseBy(delta: number) {\n\t\tthis.changesCount += delta\n\t\tthis.touchedCount++\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAAO,MAAM,iBAAiB;AAAA,EAAvB;AACE,wCAAe;AACf,wCAAe;AAAA;AAAA,EAEhB,qBAAqB;AAC3B,WAAO,KAAK;AAAA,EACb;AAAA,EAEO,aAAa;AACnB,WAAO,KAAK,eAAe;AAAA,EAC5B;AAAA,EAEO,QAAQ;AACd,SAAK,eAAe;AAAA,EACrB;AAAA,EAEO,WAAW,OAAe;AAChC,SAAK,gBAAgB;AAChB,SAAA;AAAA,EACN;AACD;;"}
@@ -1,42 +1,38 @@
1
1
  import { MutationAlias } from "./requestAliases/MutationAlias.js";
2
- import { mutationOperationSubTreeType } from "./requestAliases/mutationOperationSubTreeType.js";
3
2
  import { assertNever } from "../utils/assertNever.js";
4
3
  class ErrorsPreprocessor {
5
- constructor(requestResponse) {
4
+ constructor(requestResponse, operations) {
6
5
  this.requestResponse = requestResponse;
6
+ this.operations = operations;
7
7
  }
8
8
  preprocess() {
9
9
  const treeRoot = /* @__PURE__ */ new Map();
10
10
  if (this.requestResponse === void 0) {
11
11
  return treeRoot;
12
12
  }
13
- for (const mutationAlias in this.requestResponse) {
14
- const mutationResponse = this.requestResponse[mutationAlias];
13
+ for (const operation of this.operations) {
14
+ const mutationResponse = this.requestResponse[operation.alias];
15
15
  const processedResponse = this.processMutationResponse(mutationResponse);
16
16
  if (processedResponse === void 0) {
17
17
  continue;
18
18
  }
19
- const operation = MutationAlias.decodeTopLevel(mutationAlias);
20
- if (operation === void 0) {
21
- continue;
22
- }
23
- const { subTreeType, subTreePlaceholder, entityId } = operation;
24
- if (subTreeType === mutationOperationSubTreeType.singleEntity) {
19
+ const { subTreeType, subTreePlaceholder, id } = operation;
20
+ if (subTreeType === "single") {
25
21
  if (treeRoot.has(subTreePlaceholder)) {
26
22
  return this.rejectCorruptData();
27
23
  }
28
24
  treeRoot.set(subTreePlaceholder, processedResponse);
29
- } else if (subTreeType === mutationOperationSubTreeType.entityList) {
25
+ } else if (subTreeType === "list") {
30
26
  const child = treeRoot.get(subTreePlaceholder);
31
27
  if (child === void 0) {
32
28
  treeRoot.set(subTreePlaceholder, {
33
29
  nodeType: "iNode",
34
- children: /* @__PURE__ */ new Map([[entityId, processedResponse]]),
30
+ children: /* @__PURE__ */ new Map([[id, processedResponse]]),
35
31
  validation: [],
36
32
  execution: []
37
33
  });
38
34
  } else if (child.nodeType === "iNode") {
39
- child.children.set(entityId, processedResponse);
35
+ child.children.set(id, processedResponse);
40
36
  }
41
37
  } else {
42
38
  return assertNever();