@contember/binding-legacy 2.1.0-alpha.3 → 2.1.0-alpha.35

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 (412) hide show
  1. package/package.json +10 -5
  2. package/src/accessorTree/NormalizedPersistedData.ts +1 -1
  3. package/src/accessors/EntityAccessorImpl.ts +13 -11
  4. package/src/accessors/EntityListAccessorImpl.ts +16 -7
  5. package/src/core/AccessorErrorManager.ts +2 -2
  6. package/src/core/DataBinding.ts +24 -15
  7. package/src/core/ErrorsPreprocessor.ts +4 -5
  8. package/src/core/EventManager.ts +34 -46
  9. package/src/core/MutationGenerator.ts +85 -87
  10. package/src/core/QueryGenerator.ts +4 -5
  11. package/src/core/RealmKeyGenerator.ts +5 -3
  12. package/src/core/RequestResponseNormalizer.ts +3 -8
  13. package/src/core/StateInitializer.ts +10 -18
  14. package/src/core/TreeAugmenter.ts +9 -16
  15. package/src/core/TreeStore.ts +5 -4
  16. package/src/core/operations/EntityOperations.ts +25 -25
  17. package/src/core/operations/FieldOperations.ts +15 -17
  18. package/src/core/operations/ListOperations.ts +15 -15
  19. package/src/core/operations/OperationsHelpers.ts +2 -2
  20. package/src/core/state/EntityListState.ts +3 -9
  21. package/src/fieldHelpers/helpers/TemporalFieldHelper.ts +3 -3
  22. package/src/utils/assertNever.ts +4 -4
  23. package/tests/example.test.ts +2 -2
  24. package/dist/development/index.cjs +0 -34
  25. package/dist/development/index.cjs.map +0 -1
  26. package/dist/development/index.js +0 -28
  27. package/dist/development/index.js.map +0 -1
  28. package/dist/development/src/accessorTree/NormalizedPersistedData.cjs +0 -10
  29. package/dist/development/src/accessorTree/NormalizedPersistedData.cjs.map +0 -1
  30. package/dist/development/src/accessorTree/NormalizedPersistedData.js +0 -10
  31. package/dist/development/src/accessorTree/NormalizedPersistedData.js.map +0 -1
  32. package/dist/development/src/accessors/EntityAccessorImpl.cjs +0 -179
  33. package/dist/development/src/accessors/EntityAccessorImpl.cjs.map +0 -1
  34. package/dist/development/src/accessors/EntityAccessorImpl.js +0 -179
  35. package/dist/development/src/accessors/EntityAccessorImpl.js.map +0 -1
  36. package/dist/development/src/accessors/EntityListAccessorImpl.cjs +0 -112
  37. package/dist/development/src/accessors/EntityListAccessorImpl.cjs.map +0 -1
  38. package/dist/development/src/accessors/EntityListAccessorImpl.js +0 -112
  39. package/dist/development/src/accessors/EntityListAccessorImpl.js.map +0 -1
  40. package/dist/development/src/accessors/FieldAccessorImpl.cjs +0 -54
  41. package/dist/development/src/accessors/FieldAccessorImpl.cjs.map +0 -1
  42. package/dist/development/src/accessors/FieldAccessorImpl.js +0 -54
  43. package/dist/development/src/accessors/FieldAccessorImpl.js.map +0 -1
  44. package/dist/development/src/core/AccessorErrorManager.cjs +0 -200
  45. package/dist/development/src/core/AccessorErrorManager.cjs.map +0 -1
  46. package/dist/development/src/core/AccessorErrorManager.js +0 -200
  47. package/dist/development/src/core/AccessorErrorManager.js.map +0 -1
  48. package/dist/development/src/core/Config.cjs +0 -29
  49. package/dist/development/src/core/Config.cjs.map +0 -1
  50. package/dist/development/src/core/Config.js +0 -29
  51. package/dist/development/src/core/Config.js.map +0 -1
  52. package/dist/development/src/core/DataBinding.cjs +0 -354
  53. package/dist/development/src/core/DataBinding.cjs.map +0 -1
  54. package/dist/development/src/core/DataBinding.js +0 -354
  55. package/dist/development/src/core/DataBinding.js.map +0 -1
  56. package/dist/development/src/core/DirtinessTracker.cjs +0 -26
  57. package/dist/development/src/core/DirtinessTracker.cjs.map +0 -1
  58. package/dist/development/src/core/DirtinessTracker.js +0 -26
  59. package/dist/development/src/core/DirtinessTracker.js.map +0 -1
  60. package/dist/development/src/core/ErrorsPreprocessor.cjs +0 -180
  61. package/dist/development/src/core/ErrorsPreprocessor.cjs.map +0 -1
  62. package/dist/development/src/core/ErrorsPreprocessor.js +0 -180
  63. package/dist/development/src/core/ErrorsPreprocessor.js.map +0 -1
  64. package/dist/development/src/core/EventManager.cjs +0 -439
  65. package/dist/development/src/core/EventManager.cjs.map +0 -1
  66. package/dist/development/src/core/EventManager.js +0 -439
  67. package/dist/development/src/core/EventManager.js.map +0 -1
  68. package/dist/development/src/core/MutationGenerator.cjs +0 -668
  69. package/dist/development/src/core/MutationGenerator.cjs.map +0 -1
  70. package/dist/development/src/core/MutationGenerator.js +0 -668
  71. package/dist/development/src/core/MutationGenerator.js.map +0 -1
  72. package/dist/development/src/core/QueryGenerator.cjs +0 -110
  73. package/dist/development/src/core/QueryGenerator.cjs.map +0 -1
  74. package/dist/development/src/core/QueryGenerator.js +0 -110
  75. package/dist/development/src/core/QueryGenerator.js.map +0 -1
  76. package/dist/development/src/core/RealmKeyGenerator.cjs +0 -42
  77. package/dist/development/src/core/RealmKeyGenerator.cjs.map +0 -1
  78. package/dist/development/src/core/RealmKeyGenerator.js +0 -42
  79. package/dist/development/src/core/RealmKeyGenerator.js.map +0 -1
  80. package/dist/development/src/core/RequestResponseNormalizer.cjs +0 -136
  81. package/dist/development/src/core/RequestResponseNormalizer.cjs.map +0 -1
  82. package/dist/development/src/core/RequestResponseNormalizer.js +0 -136
  83. package/dist/development/src/core/RequestResponseNormalizer.js.map +0 -1
  84. package/dist/development/src/core/StateInitializer.cjs +0 -379
  85. package/dist/development/src/core/StateInitializer.cjs.map +0 -1
  86. package/dist/development/src/core/StateInitializer.js +0 -379
  87. package/dist/development/src/core/StateInitializer.js.map +0 -1
  88. package/dist/development/src/core/TreeAugmenter.cjs +0 -354
  89. package/dist/development/src/core/TreeAugmenter.cjs.map +0 -1
  90. package/dist/development/src/core/TreeAugmenter.js +0 -354
  91. package/dist/development/src/core/TreeAugmenter.js.map +0 -1
  92. package/dist/development/src/core/TreeStore.cjs +0 -172
  93. package/dist/development/src/core/TreeStore.cjs.map +0 -1
  94. package/dist/development/src/core/TreeStore.js +0 -172
  95. package/dist/development/src/core/TreeStore.js.map +0 -1
  96. package/dist/development/src/core/exceptions/ErrorLocator.cjs +0 -59
  97. package/dist/development/src/core/exceptions/ErrorLocator.cjs.map +0 -1
  98. package/dist/development/src/core/exceptions/ErrorLocator.js +0 -59
  99. package/dist/development/src/core/exceptions/ErrorLocator.js.map +0 -1
  100. package/dist/development/src/core/exceptions/MarkerSugarer.cjs +0 -51
  101. package/dist/development/src/core/exceptions/MarkerSugarer.cjs.map +0 -1
  102. package/dist/development/src/core/exceptions/MarkerSugarer.js +0 -51
  103. package/dist/development/src/core/exceptions/MarkerSugarer.js.map +0 -1
  104. package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs +0 -33
  105. package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs.map +0 -1
  106. package/dist/development/src/core/exceptions/TreeParameterSugarer.js +0 -33
  107. package/dist/development/src/core/exceptions/TreeParameterSugarer.js.map +0 -1
  108. package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs +0 -23
  109. package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs.map +0 -1
  110. package/dist/development/src/core/factories/createBatchUpdatesOptions.js +0 -23
  111. package/dist/development/src/core/factories/createBatchUpdatesOptions.js.map +0 -1
  112. package/dist/development/src/core/operations/EntityOperations.cjs +0 -226
  113. package/dist/development/src/core/operations/EntityOperations.cjs.map +0 -1
  114. package/dist/development/src/core/operations/EntityOperations.js +0 -226
  115. package/dist/development/src/core/operations/EntityOperations.js.map +0 -1
  116. package/dist/development/src/core/operations/FieldOperations.cjs +0 -92
  117. package/dist/development/src/core/operations/FieldOperations.cjs.map +0 -1
  118. package/dist/development/src/core/operations/FieldOperations.js +0 -92
  119. package/dist/development/src/core/operations/FieldOperations.js.map +0 -1
  120. package/dist/development/src/core/operations/ListOperations.cjs +0 -158
  121. package/dist/development/src/core/operations/ListOperations.cjs.map +0 -1
  122. package/dist/development/src/core/operations/ListOperations.js +0 -158
  123. package/dist/development/src/core/operations/ListOperations.js.map +0 -1
  124. package/dist/development/src/core/operations/OperationsHelpers.cjs +0 -87
  125. package/dist/development/src/core/operations/OperationsHelpers.cjs.map +0 -1
  126. package/dist/development/src/core/operations/OperationsHelpers.js +0 -87
  127. package/dist/development/src/core/operations/OperationsHelpers.js.map +0 -1
  128. package/dist/development/src/core/requestAliases/MutationAlias.cjs +0 -14
  129. package/dist/development/src/core/requestAliases/MutationAlias.cjs.map +0 -1
  130. package/dist/development/src/core/requestAliases/MutationAlias.js +0 -14
  131. package/dist/development/src/core/requestAliases/MutationAlias.js.map +0 -1
  132. package/dist/development/src/core/state/StateIterator.cjs +0 -100
  133. package/dist/development/src/core/state/StateIterator.cjs.map +0 -1
  134. package/dist/development/src/core/state/StateIterator.js +0 -100
  135. package/dist/development/src/core/state/StateIterator.js.map +0 -1
  136. package/dist/development/src/core/state/getEntityMarker.cjs +0 -5
  137. package/dist/development/src/core/state/getEntityMarker.cjs.map +0 -1
  138. package/dist/development/src/core/state/getEntityMarker.js +0 -5
  139. package/dist/development/src/core/state/getEntityMarker.js.map +0 -1
  140. package/dist/development/src/core/utils/getCombinedSignal.cjs +0 -33
  141. package/dist/development/src/core/utils/getCombinedSignal.cjs.map +0 -1
  142. package/dist/development/src/core/utils/getCombinedSignal.js +0 -33
  143. package/dist/development/src/core/utils/getCombinedSignal.js.map +0 -1
  144. package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs +0 -13
  145. package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs.map +0 -1
  146. package/dist/development/src/fieldHelpers/helpers/FieldHelper.js +0 -13
  147. package/dist/development/src/fieldHelpers/helpers/FieldHelper.js.map +0 -1
  148. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +0 -18
  149. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +0 -1
  150. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js +0 -18
  151. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +0 -1
  152. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs +0 -16
  153. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +0 -1
  154. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js +0 -16
  155. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js.map +0 -1
  156. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs +0 -7
  157. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +0 -1
  158. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js +0 -7
  159. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js.map +0 -1
  160. package/dist/development/src/utils/isEmptyObject.cjs +0 -12
  161. package/dist/development/src/utils/isEmptyObject.cjs.map +0 -1
  162. package/dist/development/src/utils/isEmptyObject.js +0 -12
  163. package/dist/development/src/utils/isEmptyObject.js.map +0 -1
  164. package/dist/production/index.cjs +0 -34
  165. package/dist/production/index.cjs.map +0 -1
  166. package/dist/production/index.js +0 -28
  167. package/dist/production/index.js.map +0 -1
  168. package/dist/production/src/accessorTree/NormalizedPersistedData.cjs +0 -10
  169. package/dist/production/src/accessorTree/NormalizedPersistedData.cjs.map +0 -1
  170. package/dist/production/src/accessorTree/NormalizedPersistedData.js +0 -10
  171. package/dist/production/src/accessorTree/NormalizedPersistedData.js.map +0 -1
  172. package/dist/production/src/accessors/EntityAccessorImpl.cjs +0 -179
  173. package/dist/production/src/accessors/EntityAccessorImpl.cjs.map +0 -1
  174. package/dist/production/src/accessors/EntityAccessorImpl.js +0 -179
  175. package/dist/production/src/accessors/EntityAccessorImpl.js.map +0 -1
  176. package/dist/production/src/accessors/EntityListAccessorImpl.cjs +0 -112
  177. package/dist/production/src/accessors/EntityListAccessorImpl.cjs.map +0 -1
  178. package/dist/production/src/accessors/EntityListAccessorImpl.js +0 -112
  179. package/dist/production/src/accessors/EntityListAccessorImpl.js.map +0 -1
  180. package/dist/production/src/accessors/FieldAccessorImpl.cjs +0 -54
  181. package/dist/production/src/accessors/FieldAccessorImpl.cjs.map +0 -1
  182. package/dist/production/src/accessors/FieldAccessorImpl.js +0 -54
  183. package/dist/production/src/accessors/FieldAccessorImpl.js.map +0 -1
  184. package/dist/production/src/core/AccessorErrorManager.cjs +0 -200
  185. package/dist/production/src/core/AccessorErrorManager.cjs.map +0 -1
  186. package/dist/production/src/core/AccessorErrorManager.js +0 -200
  187. package/dist/production/src/core/AccessorErrorManager.js.map +0 -1
  188. package/dist/production/src/core/Config.cjs +0 -29
  189. package/dist/production/src/core/Config.cjs.map +0 -1
  190. package/dist/production/src/core/Config.js +0 -29
  191. package/dist/production/src/core/Config.js.map +0 -1
  192. package/dist/production/src/core/DataBinding.cjs +0 -354
  193. package/dist/production/src/core/DataBinding.cjs.map +0 -1
  194. package/dist/production/src/core/DataBinding.js +0 -354
  195. package/dist/production/src/core/DataBinding.js.map +0 -1
  196. package/dist/production/src/core/DirtinessTracker.cjs +0 -26
  197. package/dist/production/src/core/DirtinessTracker.cjs.map +0 -1
  198. package/dist/production/src/core/DirtinessTracker.js +0 -26
  199. package/dist/production/src/core/DirtinessTracker.js.map +0 -1
  200. package/dist/production/src/core/ErrorsPreprocessor.cjs +0 -180
  201. package/dist/production/src/core/ErrorsPreprocessor.cjs.map +0 -1
  202. package/dist/production/src/core/ErrorsPreprocessor.js +0 -180
  203. package/dist/production/src/core/ErrorsPreprocessor.js.map +0 -1
  204. package/dist/production/src/core/EventManager.cjs +0 -413
  205. package/dist/production/src/core/EventManager.cjs.map +0 -1
  206. package/dist/production/src/core/EventManager.js +0 -413
  207. package/dist/production/src/core/EventManager.js.map +0 -1
  208. package/dist/production/src/core/MutationGenerator.cjs +0 -668
  209. package/dist/production/src/core/MutationGenerator.cjs.map +0 -1
  210. package/dist/production/src/core/MutationGenerator.js +0 -668
  211. package/dist/production/src/core/MutationGenerator.js.map +0 -1
  212. package/dist/production/src/core/QueryGenerator.cjs +0 -110
  213. package/dist/production/src/core/QueryGenerator.cjs.map +0 -1
  214. package/dist/production/src/core/QueryGenerator.js +0 -110
  215. package/dist/production/src/core/QueryGenerator.js.map +0 -1
  216. package/dist/production/src/core/RealmKeyGenerator.cjs +0 -42
  217. package/dist/production/src/core/RealmKeyGenerator.cjs.map +0 -1
  218. package/dist/production/src/core/RealmKeyGenerator.js +0 -42
  219. package/dist/production/src/core/RealmKeyGenerator.js.map +0 -1
  220. package/dist/production/src/core/RequestResponseNormalizer.cjs +0 -136
  221. package/dist/production/src/core/RequestResponseNormalizer.cjs.map +0 -1
  222. package/dist/production/src/core/RequestResponseNormalizer.js +0 -136
  223. package/dist/production/src/core/RequestResponseNormalizer.js.map +0 -1
  224. package/dist/production/src/core/StateInitializer.cjs +0 -379
  225. package/dist/production/src/core/StateInitializer.cjs.map +0 -1
  226. package/dist/production/src/core/StateInitializer.js +0 -379
  227. package/dist/production/src/core/StateInitializer.js.map +0 -1
  228. package/dist/production/src/core/TreeAugmenter.cjs +0 -354
  229. package/dist/production/src/core/TreeAugmenter.cjs.map +0 -1
  230. package/dist/production/src/core/TreeAugmenter.js +0 -354
  231. package/dist/production/src/core/TreeAugmenter.js.map +0 -1
  232. package/dist/production/src/core/TreeStore.cjs +0 -172
  233. package/dist/production/src/core/TreeStore.cjs.map +0 -1
  234. package/dist/production/src/core/TreeStore.js +0 -172
  235. package/dist/production/src/core/TreeStore.js.map +0 -1
  236. package/dist/production/src/core/exceptions/ErrorLocator.cjs +0 -59
  237. package/dist/production/src/core/exceptions/ErrorLocator.cjs.map +0 -1
  238. package/dist/production/src/core/exceptions/ErrorLocator.js +0 -59
  239. package/dist/production/src/core/exceptions/ErrorLocator.js.map +0 -1
  240. package/dist/production/src/core/exceptions/MarkerSugarer.cjs +0 -51
  241. package/dist/production/src/core/exceptions/MarkerSugarer.cjs.map +0 -1
  242. package/dist/production/src/core/exceptions/MarkerSugarer.js +0 -51
  243. package/dist/production/src/core/exceptions/MarkerSugarer.js.map +0 -1
  244. package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs +0 -33
  245. package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs.map +0 -1
  246. package/dist/production/src/core/exceptions/TreeParameterSugarer.js +0 -33
  247. package/dist/production/src/core/exceptions/TreeParameterSugarer.js.map +0 -1
  248. package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs +0 -23
  249. package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs.map +0 -1
  250. package/dist/production/src/core/factories/createBatchUpdatesOptions.js +0 -23
  251. package/dist/production/src/core/factories/createBatchUpdatesOptions.js.map +0 -1
  252. package/dist/production/src/core/operations/EntityOperations.cjs +0 -226
  253. package/dist/production/src/core/operations/EntityOperations.cjs.map +0 -1
  254. package/dist/production/src/core/operations/EntityOperations.js +0 -226
  255. package/dist/production/src/core/operations/EntityOperations.js.map +0 -1
  256. package/dist/production/src/core/operations/FieldOperations.cjs +0 -73
  257. package/dist/production/src/core/operations/FieldOperations.cjs.map +0 -1
  258. package/dist/production/src/core/operations/FieldOperations.js +0 -73
  259. package/dist/production/src/core/operations/FieldOperations.js.map +0 -1
  260. package/dist/production/src/core/operations/ListOperations.cjs +0 -158
  261. package/dist/production/src/core/operations/ListOperations.cjs.map +0 -1
  262. package/dist/production/src/core/operations/ListOperations.js +0 -158
  263. package/dist/production/src/core/operations/ListOperations.js.map +0 -1
  264. package/dist/production/src/core/operations/OperationsHelpers.cjs +0 -87
  265. package/dist/production/src/core/operations/OperationsHelpers.cjs.map +0 -1
  266. package/dist/production/src/core/operations/OperationsHelpers.js +0 -87
  267. package/dist/production/src/core/operations/OperationsHelpers.js.map +0 -1
  268. package/dist/production/src/core/requestAliases/MutationAlias.cjs +0 -14
  269. package/dist/production/src/core/requestAliases/MutationAlias.cjs.map +0 -1
  270. package/dist/production/src/core/requestAliases/MutationAlias.js +0 -14
  271. package/dist/production/src/core/requestAliases/MutationAlias.js.map +0 -1
  272. package/dist/production/src/core/state/StateIterator.cjs +0 -100
  273. package/dist/production/src/core/state/StateIterator.cjs.map +0 -1
  274. package/dist/production/src/core/state/StateIterator.js +0 -100
  275. package/dist/production/src/core/state/StateIterator.js.map +0 -1
  276. package/dist/production/src/core/state/getEntityMarker.cjs +0 -5
  277. package/dist/production/src/core/state/getEntityMarker.cjs.map +0 -1
  278. package/dist/production/src/core/state/getEntityMarker.js +0 -5
  279. package/dist/production/src/core/state/getEntityMarker.js.map +0 -1
  280. package/dist/production/src/core/utils/getCombinedSignal.cjs +0 -33
  281. package/dist/production/src/core/utils/getCombinedSignal.cjs.map +0 -1
  282. package/dist/production/src/core/utils/getCombinedSignal.js +0 -33
  283. package/dist/production/src/core/utils/getCombinedSignal.js.map +0 -1
  284. package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs +0 -13
  285. package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs.map +0 -1
  286. package/dist/production/src/fieldHelpers/helpers/FieldHelper.js +0 -13
  287. package/dist/production/src/fieldHelpers/helpers/FieldHelper.js.map +0 -1
  288. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +0 -18
  289. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +0 -1
  290. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js +0 -18
  291. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +0 -1
  292. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs +0 -16
  293. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +0 -1
  294. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js +0 -16
  295. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js.map +0 -1
  296. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs +0 -7
  297. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +0 -1
  298. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js +0 -7
  299. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js.map +0 -1
  300. package/dist/production/src/utils/isEmptyObject.cjs +0 -12
  301. package/dist/production/src/utils/isEmptyObject.cjs.map +0 -1
  302. package/dist/production/src/utils/isEmptyObject.js +0 -12
  303. package/dist/production/src/utils/isEmptyObject.js.map +0 -1
  304. package/dist/types/accessorTree/NormalizedPersistedData.d.ts +0 -18
  305. package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +0 -1
  306. package/dist/types/accessorTree/index.d.ts +0 -2
  307. package/dist/types/accessorTree/index.d.ts.map +0 -1
  308. package/dist/types/accessors/BindingConfig.d.ts +0 -6
  309. package/dist/types/accessors/BindingConfig.d.ts.map +0 -1
  310. package/dist/types/accessors/EntityAccessorImpl.d.ts +0 -56
  311. package/dist/types/accessors/EntityAccessorImpl.d.ts.map +0 -1
  312. package/dist/types/accessors/EntityListAccessorImpl.d.ts +0 -57
  313. package/dist/types/accessors/EntityListAccessorImpl.d.ts.map +0 -1
  314. package/dist/types/accessors/FieldAccessorImpl.d.ts +0 -32
  315. package/dist/types/accessors/FieldAccessorImpl.d.ts.map +0 -1
  316. package/dist/types/accessors/index.d.ts +0 -5
  317. package/dist/types/accessors/index.d.ts.map +0 -1
  318. package/dist/types/core/AccessorErrorManager.d.ts +0 -25
  319. package/dist/types/core/AccessorErrorManager.d.ts.map +0 -1
  320. package/dist/types/core/Config.d.ts +0 -9
  321. package/dist/types/core/Config.d.ts.map +0 -1
  322. package/dist/types/core/DataBinding.d.ts +0 -54
  323. package/dist/types/core/DataBinding.d.ts.map +0 -1
  324. package/dist/types/core/DirtinessTracker.d.ts +0 -9
  325. package/dist/types/core/DirtinessTracker.d.ts.map +0 -1
  326. package/dist/types/core/ErrorsPreprocessor.d.ts +0 -34
  327. package/dist/types/core/ErrorsPreprocessor.d.ts.map +0 -1
  328. package/dist/types/core/EventManager.d.ts +0 -57
  329. package/dist/types/core/EventManager.d.ts.map +0 -1
  330. package/dist/types/core/MutationGenerator.d.ts +0 -49
  331. package/dist/types/core/MutationGenerator.d.ts.map +0 -1
  332. package/dist/types/core/QueryGenerator.d.ts +0 -13
  333. package/dist/types/core/QueryGenerator.d.ts.map +0 -1
  334. package/dist/types/core/RealmKeyGenerator.d.ts +0 -10
  335. package/dist/types/core/RealmKeyGenerator.d.ts.map +0 -1
  336. package/dist/types/core/RequestResponseNormalizer.d.ts +0 -11
  337. package/dist/types/core/RequestResponseNormalizer.d.ts.map +0 -1
  338. package/dist/types/core/StateInitializer.d.ts +0 -34
  339. package/dist/types/core/StateInitializer.d.ts.map +0 -1
  340. package/dist/types/core/TreeAugmenter.d.ts +0 -25
  341. package/dist/types/core/TreeAugmenter.d.ts.map +0 -1
  342. package/dist/types/core/TreeStore.d.ts +0 -30
  343. package/dist/types/core/TreeStore.d.ts.map +0 -1
  344. package/dist/types/core/UpdateMetadata.d.ts +0 -4
  345. package/dist/types/core/UpdateMetadata.d.ts.map +0 -1
  346. package/dist/types/core/exceptions/ErrorLocator.d.ts +0 -8
  347. package/dist/types/core/exceptions/ErrorLocator.d.ts.map +0 -1
  348. package/dist/types/core/exceptions/MarkerSugarer.d.ts +0 -10
  349. package/dist/types/core/exceptions/MarkerSugarer.d.ts.map +0 -1
  350. package/dist/types/core/exceptions/TreeParameterSugarer.d.ts +0 -11
  351. package/dist/types/core/exceptions/TreeParameterSugarer.d.ts.map +0 -1
  352. package/dist/types/core/factories/createBatchUpdatesOptions.d.ts +0 -5
  353. package/dist/types/core/factories/createBatchUpdatesOptions.d.ts.map +0 -1
  354. package/dist/types/core/factories/index.d.ts +0 -2
  355. package/dist/types/core/factories/index.d.ts.map +0 -1
  356. package/dist/types/core/index.d.ts +0 -9
  357. package/dist/types/core/index.d.ts.map +0 -1
  358. package/dist/types/core/operations/EntityOperations.d.ts +0 -26
  359. package/dist/types/core/operations/EntityOperations.d.ts.map +0 -1
  360. package/dist/types/core/operations/FieldOperations.d.ts +0 -22
  361. package/dist/types/core/operations/FieldOperations.d.ts.map +0 -1
  362. package/dist/types/core/operations/ListOperations.d.ts +0 -32
  363. package/dist/types/core/operations/ListOperations.d.ts.map +0 -1
  364. package/dist/types/core/operations/OperationsHelpers.d.ts +0 -14
  365. package/dist/types/core/operations/OperationsHelpers.d.ts.map +0 -1
  366. package/dist/types/core/operations/index.d.ts +0 -4
  367. package/dist/types/core/operations/index.d.ts.map +0 -1
  368. package/dist/types/core/requestAliases/MutationAlias.d.ts +0 -6
  369. package/dist/types/core/requestAliases/MutationAlias.d.ts.map +0 -1
  370. package/dist/types/core/requestAliases/index.d.ts +0 -2
  371. package/dist/types/core/requestAliases/index.d.ts.map +0 -1
  372. package/dist/types/core/state/EntityListState.d.ts +0 -29
  373. package/dist/types/core/state/EntityListState.d.ts.map +0 -1
  374. package/dist/types/core/state/EntityRealmState.d.ts +0 -44
  375. package/dist/types/core/state/EntityRealmState.d.ts.map +0 -1
  376. package/dist/types/core/state/EntityState.d.ts +0 -11
  377. package/dist/types/core/state/EntityState.d.ts.map +0 -1
  378. package/dist/types/core/state/FieldState.d.ts +0 -19
  379. package/dist/types/core/state/FieldState.d.ts.map +0 -1
  380. package/dist/types/core/state/StateIterator.d.ts +0 -14
  381. package/dist/types/core/state/StateIterator.d.ts.map +0 -1
  382. package/dist/types/core/state/StateNode.d.ts +0 -8
  383. package/dist/types/core/state/StateNode.d.ts.map +0 -1
  384. package/dist/types/core/state/getEntityMarker.d.ts +0 -3
  385. package/dist/types/core/state/getEntityMarker.d.ts.map +0 -1
  386. package/dist/types/core/state/index.d.ts +0 -8
  387. package/dist/types/core/state/index.d.ts.map +0 -1
  388. package/dist/types/core/utils/getCombinedSignal.d.ts +0 -2
  389. package/dist/types/core/utils/getCombinedSignal.d.ts.map +0 -1
  390. package/dist/types/core/utils/index.d.ts +0 -2
  391. package/dist/types/core/utils/index.d.ts.map +0 -1
  392. package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts +0 -7
  393. package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts.map +0 -1
  394. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts +0 -10
  395. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +0 -1
  396. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +0 -10
  397. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts.map +0 -1
  398. package/dist/types/fieldHelpers/helpers/index.d.ts +0 -3
  399. package/dist/types/fieldHelpers/helpers/index.d.ts.map +0 -1
  400. package/dist/types/fieldHelpers/index.d.ts +0 -2
  401. package/dist/types/fieldHelpers/index.d.ts.map +0 -1
  402. package/dist/types/index.d.ts +0 -5
  403. package/dist/types/index.d.ts.map +0 -1
  404. package/dist/types/tsconfig.tsbuildinfo +0 -1
  405. package/dist/types/utils/assertNever.d.ts +0 -2
  406. package/dist/types/utils/assertNever.d.ts.map +0 -1
  407. package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts +0 -2
  408. package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts.map +0 -1
  409. package/dist/types/utils/index.d.ts +0 -4
  410. package/dist/types/utils/index.d.ts.map +0 -1
  411. package/dist/types/utils/isEmptyObject.d.ts +0 -2
  412. package/dist/types/utils/isEmptyObject.d.ts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorsPreprocessor.cjs","sources":["../../../../../packages/binding-legacy/src/core/ErrorsPreprocessor.ts"],"sourcesContent":["import type { EntityId, ErrorAccessor, FieldName, PlaceholderName } from '@contember/binding-common'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport { MutationAlias } from './requestAliases'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { MutationError, MutationResult, ValidationError } from '@contember/client'\n\nclass ErrorsPreprocessor {\n\tpublic constructor(\n\t\tprivate readonly requestResponse: DataBindingTransactionResult,\n\t\tprivate readonly operations: SubMutationOperation[],\n\t) {}\n\n\tpublic preprocess(): ErrorsPreprocessor.ErrorTreeRoot {\n\t\tconst treeRoot: ErrorsPreprocessor.ErrorTreeRoot = new Map()\n\n\t\tif (this.requestResponse === undefined) {\n\t\t\treturn treeRoot\n\t\t}\n\n\t\tfor (const operation of this.operations) {\n\t\t\tconst mutationResponse = this.requestResponse.data[operation.alias]\n\t\t\tconst processedResponse = this.processMutationResponse(mutationResponse)\n\n\t\t\tif (processedResponse === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst { subTreeType, subTreePlaceholder, id } = operation\n\n\t\t\tif (subTreeType === 'single') {\n\t\t\t\tif (treeRoot.has(subTreePlaceholder)) {\n\t\t\t\t\treturn this.rejectCorruptData()\n\t\t\t\t}\n\t\t\t\ttreeRoot.set(subTreePlaceholder, processedResponse)\n\t\t\t} else if (subTreeType === 'list') {\n\t\t\t\tconst child = treeRoot.get(subTreePlaceholder)\n\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\ttreeRoot.set(subTreePlaceholder, {\n\t\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\t\tchildren: new Map([[id, processedResponse]]),\n\t\t\t\t\t\tvalidation: [],\n\t\t\t\t\t\texecution: [],\n\t\t\t\t\t})\n\t\t\t\t} else if (child.nodeType === 'iNode') {\n\t\t\t\t\tchild.children.set(id, processedResponse)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn assertNever(subTreeType)\n\t\t\t}\n\n\t\t}\n\t\treturn treeRoot\n\t}\n\n\tprivate processMutationResponse(mutationResponse: MutationResult): ErrorsPreprocessor.ErrorNode | undefined {\n\t\tif (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (mutationResponse.validation?.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.validation?.errors)\n\t\t}\n\t\tif (mutationResponse.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.errors)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate getErrorNode(errors: ValidationError[] | MutationError[]): ErrorsPreprocessor.ErrorNode {\n\t\tconst [head, ...tail] = errors\n\n\t\tlet rootNode = this.getRootNode(head)\n\n\t\terrorLoop: for (const error of tail) {\n\t\t\tlet currentNode = rootNode\n\n\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\n\t\t\tfor (let i = 0, pathLength = path.length; i < pathLength; i++) {\n\t\t\t\tconst pathNode = path[i]\n\n\t\t\t\tif (currentNode.nodeType === 'leaf') {\n\t\t\t\t\t(currentNode as any as ErrorsPreprocessor.ErrorINode).nodeType = 'iNode'\n\t\t\t\t\t;(currentNode as any as ErrorsPreprocessor.ErrorINode).children = new Map()\n\t\t\t\t}\n\n\t\t\t\tif ('field' in pathNode) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tlet alias = pathNode.field\n\t\t\t\t\t\tlet nextIndex = i + 1\n\t\t\t\t\t\tif (nextIndex in path) {\n\t\t\t\t\t\t\tconst nextPathNode = path[nextIndex]\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t'index' in nextPathNode &&\n\t\t\t\t\t\t\t\ttypeof nextPathNode.alias === 'string' &&\n\t\t\t\t\t\t\t\tnextPathNode.alias.startsWith(pathNode.field)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// We're dealing with a reduced hasMany relation.\n\t\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\t\tnextIndex++\n\t\t\t\t\t\t\t\talias = nextPathNode.alias\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!currentNode.children.has(alias)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(alias, this.getRootNode(error, nextIndex))\n\t\t\t\t\t\t\tif (nextIndex <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(alias)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else if ('index' in path) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\t\t\tif (alias === null) {\n\t\t\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst entityId = MutationAlias.decodeEntityId(alias)\n\n\t\t\t\t\t\tif (!currentNode.children.has(entityId)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(entityId, this.getRootNode(error, i + 1))\n\t\t\t\t\t\t\tif (i + 1 <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(entityId)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isExecutionError(error)) {\n\t\t\t\tcurrentNode.execution.push({ type: 'execution', code: error.type, developerMessage: error.message })\n\t\t\t} else {\n\t\t\t\tcurrentNode.validation.push(this.createValidationError(error.message.text))\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate getRootNode(error: ValidationError | MutationError, startIndex: number = 0): ErrorsPreprocessor.ErrorNode {\n\t\tlet rootNode: ErrorsPreprocessor.ErrorNode = {\n\t\t\tvalidation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],\n\t\t\texecution: this.isExecutionError(error) ? [{ type: 'execution', code: error.type, developerMessage: error.message }] : [],\n\t\t\tnodeType: 'leaf',\n\t\t}\n\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\tfor (let i = path.length - 1; i >= startIndex; i--) {\n\t\t\tconst pathNode = path[i]\n\t\t\tif ('field' in pathNode) {\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[pathNode.field, rootNode]]),\n\t\t\t\t}\n\t\t\t} else if ('index' in pathNode) {\n\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\tif (alias === null) {\n\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[MutationAlias.decodeEntityId(alias), rootNode]]),\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(pathNode)\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate createValidationError(message: string): ErrorAccessor.ValidationError {\n\t\tif (message === 'Field is required') {\n\t\t\t// TODO this is just awful. Validation errors currently don't have error codes which makes it more difficult\n\t\t\t// \tto translate the error messages. This is the most common such error, and so we just make up a code\n\t\t\t// \tin order to facilitate error handling further downstream.\n\t\t\treturn {\n\t\t\t\ttype: 'validation',\n\t\t\t\tcode: 'fieldRequired',\n\t\t\t\tmessage,\n\t\t\t}\n\t\t}\n\t\treturn { type: 'validation', message, code: undefined }\n\t}\n\n\tprivate isExecutionError(error: ValidationError | MutationError): error is MutationError {\n\t\treturn 'type' in error\n\t}\n\n\tprivate rejectCorruptData(): never {\n\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t'Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed.',\n\t\t)\n\t}\n}\n\nnamespace ErrorsPreprocessor {\n\texport interface BaseErrorNode {\n\t\tvalidation: ErrorAccessor.ValidationError[]\n\t\texecution: ErrorAccessor.ExecutionError[]\n\t}\n\n\texport interface LeafErrorNode extends BaseErrorNode {\n\t\tnodeType: 'leaf'\n\t}\n\n\texport interface ErrorINode extends BaseErrorNode {\n\t\tnodeType: 'iNode'\n\t\tchildren: Map<FieldName | EntityId, ErrorNode>\n\t}\n\n\texport type ErrorNode = ErrorINode | LeafErrorNode\n\n\texport type ErrorTreeRoot = Map<PlaceholderName, ErrorNode>\n\n\texport class ErrorsPreprocessorError extends Error {}\n}\n\nexport { ErrorsPreprocessor }\n"],"names":["assertNever","MutationAlias","ErrorsPreprocessor"],"mappings":";;;;AAOA,MAAM,mBAAmB;AAAA,EACjB,YACW,iBACA,YAChB;AAFgB,SAAA,kBAAA;AACA,SAAA,aAAA;AAAA,EAAA;AAAA,EAGX,aAA+C;AAC/C,UAAA,+BAAiD,IAAI;AAEvD,QAAA,KAAK,oBAAoB,QAAW;AAChC,aAAA;AAAA,IAAA;AAGG,eAAA,aAAa,KAAK,YAAY;AACxC,YAAM,mBAAmB,KAAK,gBAAgB,KAAK,UAAU,KAAK;AAC5D,YAAA,oBAAoB,KAAK,wBAAwB,gBAAgB;AAEvE,UAAI,sBAAsB,QAAW;AACpC;AAAA,MAAA;AAED,YAAM,EAAE,aAAa,oBAAoB,GAAO,IAAA;AAEhD,UAAI,gBAAgB,UAAU;AACzB,YAAA,SAAS,IAAI,kBAAkB,GAAG;AACrC,iBAAO,KAAK,kBAAkB;AAAA,QAAA;AAEtB,iBAAA,IAAI,oBAAoB,iBAAiB;AAAA,MAAA,WACxC,gBAAgB,QAAQ;AAC5B,cAAA,QAAQ,SAAS,IAAI,kBAAkB;AAE7C,YAAI,UAAU,QAAW;AACxB,mBAAS,IAAI,oBAAoB;AAAA,YAChC,UAAU;AAAA,YACV,8BAAc,IAAI,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC;AAAA,YAC3C,YAAY,CAAC;AAAA,YACb,WAAW,CAAA;AAAA,UAAC,CACZ;AAAA,QAAA,WACS,MAAM,aAAa,SAAS;AAChC,gBAAA,SAAS,IAAI,IAAI,iBAAiB;AAAA,QAAA;AAAA,MACzC,OACM;AACN,eAAOA,cAAAA,YAAY,WAAW;AAAA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A,sBAAM,0BAAA;AAAA,GAnBJ,uBAAA,qBAAA,CAAA,EAAA;;"}
@@ -1,180 +0,0 @@
1
- import { assertNever } from "@contember/binding-common";
2
- import { MutationAlias } from "./requestAliases/MutationAlias.js";
3
- class ErrorsPreprocessor {
4
- constructor(requestResponse, operations) {
5
- this.requestResponse = requestResponse;
6
- this.operations = operations;
7
- }
8
- preprocess() {
9
- const treeRoot = /* @__PURE__ */ new Map();
10
- if (this.requestResponse === void 0) {
11
- return treeRoot;
12
- }
13
- for (const operation of this.operations) {
14
- const mutationResponse = this.requestResponse.data[operation.alias];
15
- const processedResponse = this.processMutationResponse(mutationResponse);
16
- if (processedResponse === void 0) {
17
- continue;
18
- }
19
- const { subTreeType, subTreePlaceholder, id } = operation;
20
- if (subTreeType === "single") {
21
- if (treeRoot.has(subTreePlaceholder)) {
22
- return this.rejectCorruptData();
23
- }
24
- treeRoot.set(subTreePlaceholder, processedResponse);
25
- } else if (subTreeType === "list") {
26
- const child = treeRoot.get(subTreePlaceholder);
27
- if (child === void 0) {
28
- treeRoot.set(subTreePlaceholder, {
29
- nodeType: "iNode",
30
- children: /* @__PURE__ */ new Map([[id, processedResponse]]),
31
- validation: [],
32
- execution: []
33
- });
34
- } else if (child.nodeType === "iNode") {
35
- child.children.set(id, processedResponse);
36
- }
37
- } else {
38
- return assertNever(subTreeType);
39
- }
40
- }
41
- return treeRoot;
42
- }
43
- processMutationResponse(mutationResponse) {
44
- if (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {
45
- return void 0;
46
- }
47
- if (mutationResponse.validation?.errors.length) {
48
- return this.getErrorNode(mutationResponse.validation?.errors);
49
- }
50
- if (mutationResponse.errors.length) {
51
- return this.getErrorNode(mutationResponse.errors);
52
- }
53
- return void 0;
54
- }
55
- getErrorNode(errors) {
56
- const [head, ...tail] = errors;
57
- let rootNode = this.getRootNode(head);
58
- errorLoop: for (const error of tail) {
59
- let currentNode = rootNode;
60
- const path = "paths" in error ? error.paths[0] ?? [] : error.path;
61
- for (let i = 0, pathLength = path.length; i < pathLength; i++) {
62
- const pathNode = path[i];
63
- if (currentNode.nodeType === "leaf") {
64
- currentNode.nodeType = "iNode";
65
- currentNode.children = /* @__PURE__ */ new Map();
66
- }
67
- if ("field" in pathNode) {
68
- if (currentNode.nodeType === "iNode") {
69
- let alias = pathNode.field;
70
- let nextIndex = i + 1;
71
- if (nextIndex in path) {
72
- const nextPathNode = path[nextIndex];
73
- if ("index" in nextPathNode && typeof nextPathNode.alias === "string" && nextPathNode.alias.startsWith(pathNode.field)) {
74
- i++;
75
- nextIndex++;
76
- alias = nextPathNode.alias;
77
- }
78
- }
79
- if (!currentNode.children.has(alias)) {
80
- currentNode.children.set(alias, this.getRootNode(error, nextIndex));
81
- if (nextIndex <= path.length) {
82
- continue errorLoop;
83
- }
84
- }
85
- currentNode = currentNode.children.get(alias);
86
- } else {
87
- this.rejectCorruptData();
88
- }
89
- } else if ("index" in path) {
90
- if (currentNode.nodeType === "iNode") {
91
- const alias = pathNode.alias;
92
- if (alias === null) {
93
- throw new ErrorsPreprocessor.ErrorsPreprocessorError(
94
- `Corrupt data: undefined alias for node with index ${pathNode.index}.`
95
- );
96
- }
97
- const entityId = MutationAlias.decodeEntityId(alias);
98
- if (!currentNode.children.has(entityId)) {
99
- currentNode.children.set(entityId, this.getRootNode(error, i + 1));
100
- if (i + 1 <= path.length) {
101
- continue errorLoop;
102
- }
103
- }
104
- currentNode = currentNode.children.get(entityId);
105
- } else {
106
- this.rejectCorruptData();
107
- }
108
- }
109
- }
110
- if (this.isExecutionError(error)) {
111
- currentNode.execution.push({ type: "execution", code: error.type, developerMessage: error.message });
112
- } else {
113
- currentNode.validation.push(this.createValidationError(error.message.text));
114
- }
115
- }
116
- return rootNode;
117
- }
118
- getRootNode(error, startIndex = 0) {
119
- let rootNode = {
120
- validation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],
121
- execution: this.isExecutionError(error) ? [{ type: "execution", code: error.type, developerMessage: error.message }] : [],
122
- nodeType: "leaf"
123
- };
124
- const path = "paths" in error ? error.paths[0] ?? [] : error.path;
125
- for (let i = path.length - 1; i >= startIndex; i--) {
126
- const pathNode = path[i];
127
- if ("field" in pathNode) {
128
- rootNode = {
129
- validation: [],
130
- execution: [],
131
- nodeType: "iNode",
132
- children: /* @__PURE__ */ new Map([[pathNode.field, rootNode]])
133
- };
134
- } else if ("index" in pathNode) {
135
- const alias = pathNode.alias;
136
- if (alias === null) {
137
- throw new ErrorsPreprocessor.ErrorsPreprocessorError(
138
- `Corrupt data: undefined alias for node with index ${pathNode.index}.`
139
- );
140
- }
141
- rootNode = {
142
- validation: [],
143
- execution: [],
144
- nodeType: "iNode",
145
- children: /* @__PURE__ */ new Map([[MutationAlias.decodeEntityId(alias), rootNode]])
146
- };
147
- } else {
148
- assertNever(pathNode);
149
- }
150
- }
151
- return rootNode;
152
- }
153
- createValidationError(message) {
154
- if (message === "Field is required") {
155
- return {
156
- type: "validation",
157
- code: "fieldRequired",
158
- message
159
- };
160
- }
161
- return { type: "validation", message, code: void 0 };
162
- }
163
- isExecutionError(error) {
164
- return "type" in error;
165
- }
166
- rejectCorruptData() {
167
- throw new ErrorsPreprocessor.ErrorsPreprocessorError(
168
- "Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed."
169
- );
170
- }
171
- }
172
- ((ErrorsPreprocessor2) => {
173
- class ErrorsPreprocessorError extends Error {
174
- }
175
- ErrorsPreprocessor2.ErrorsPreprocessorError = ErrorsPreprocessorError;
176
- })(ErrorsPreprocessor || (ErrorsPreprocessor = {}));
177
- export {
178
- ErrorsPreprocessor
179
- };
180
- //# sourceMappingURL=ErrorsPreprocessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ErrorsPreprocessor.js","sources":["../../../../../packages/binding-legacy/src/core/ErrorsPreprocessor.ts"],"sourcesContent":["import type { EntityId, ErrorAccessor, FieldName, PlaceholderName } from '@contember/binding-common'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport { MutationAlias } from './requestAliases'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { MutationError, MutationResult, ValidationError } from '@contember/client'\n\nclass ErrorsPreprocessor {\n\tpublic constructor(\n\t\tprivate readonly requestResponse: DataBindingTransactionResult,\n\t\tprivate readonly operations: SubMutationOperation[],\n\t) {}\n\n\tpublic preprocess(): ErrorsPreprocessor.ErrorTreeRoot {\n\t\tconst treeRoot: ErrorsPreprocessor.ErrorTreeRoot = new Map()\n\n\t\tif (this.requestResponse === undefined) {\n\t\t\treturn treeRoot\n\t\t}\n\n\t\tfor (const operation of this.operations) {\n\t\t\tconst mutationResponse = this.requestResponse.data[operation.alias]\n\t\t\tconst processedResponse = this.processMutationResponse(mutationResponse)\n\n\t\t\tif (processedResponse === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst { subTreeType, subTreePlaceholder, id } = operation\n\n\t\t\tif (subTreeType === 'single') {\n\t\t\t\tif (treeRoot.has(subTreePlaceholder)) {\n\t\t\t\t\treturn this.rejectCorruptData()\n\t\t\t\t}\n\t\t\t\ttreeRoot.set(subTreePlaceholder, processedResponse)\n\t\t\t} else if (subTreeType === 'list') {\n\t\t\t\tconst child = treeRoot.get(subTreePlaceholder)\n\n\t\t\t\tif (child === undefined) {\n\t\t\t\t\ttreeRoot.set(subTreePlaceholder, {\n\t\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\t\tchildren: new Map([[id, processedResponse]]),\n\t\t\t\t\t\tvalidation: [],\n\t\t\t\t\t\texecution: [],\n\t\t\t\t\t})\n\t\t\t\t} else if (child.nodeType === 'iNode') {\n\t\t\t\t\tchild.children.set(id, processedResponse)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn assertNever(subTreeType)\n\t\t\t}\n\n\t\t}\n\t\treturn treeRoot\n\t}\n\n\tprivate processMutationResponse(mutationResponse: MutationResult): ErrorsPreprocessor.ErrorNode | undefined {\n\t\tif (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {\n\t\t\treturn undefined\n\t\t}\n\t\tif (mutationResponse.validation?.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.validation?.errors)\n\t\t}\n\t\tif (mutationResponse.errors.length) {\n\t\t\treturn this.getErrorNode(mutationResponse.errors)\n\t\t}\n\t\treturn undefined\n\t}\n\n\tprivate getErrorNode(errors: ValidationError[] | MutationError[]): ErrorsPreprocessor.ErrorNode {\n\t\tconst [head, ...tail] = errors\n\n\t\tlet rootNode = this.getRootNode(head)\n\n\t\terrorLoop: for (const error of tail) {\n\t\t\tlet currentNode = rootNode\n\n\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\n\t\t\tfor (let i = 0, pathLength = path.length; i < pathLength; i++) {\n\t\t\t\tconst pathNode = path[i]\n\n\t\t\t\tif (currentNode.nodeType === 'leaf') {\n\t\t\t\t\t(currentNode as any as ErrorsPreprocessor.ErrorINode).nodeType = 'iNode'\n\t\t\t\t\t;(currentNode as any as ErrorsPreprocessor.ErrorINode).children = new Map()\n\t\t\t\t}\n\n\t\t\t\tif ('field' in pathNode) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tlet alias = pathNode.field\n\t\t\t\t\t\tlet nextIndex = i + 1\n\t\t\t\t\t\tif (nextIndex in path) {\n\t\t\t\t\t\t\tconst nextPathNode = path[nextIndex]\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\t'index' in nextPathNode &&\n\t\t\t\t\t\t\t\ttypeof nextPathNode.alias === 'string' &&\n\t\t\t\t\t\t\t\tnextPathNode.alias.startsWith(pathNode.field)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\t// We're dealing with a reduced hasMany relation.\n\t\t\t\t\t\t\t\ti++\n\t\t\t\t\t\t\t\tnextIndex++\n\t\t\t\t\t\t\t\talias = nextPathNode.alias\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (!currentNode.children.has(alias)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(alias, this.getRootNode(error, nextIndex))\n\t\t\t\t\t\t\tif (nextIndex <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(alias)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t} else if ('index' in path) {\n\t\t\t\t\tif (currentNode.nodeType === 'iNode') {\n\t\t\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\t\t\tif (alias === null) {\n\t\t\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst entityId = MutationAlias.decodeEntityId(alias)\n\n\t\t\t\t\t\tif (!currentNode.children.has(entityId)) {\n\t\t\t\t\t\t\tcurrentNode.children.set(entityId, this.getRootNode(error, i + 1))\n\t\t\t\t\t\t\tif (i + 1 <= path.length) {\n\t\t\t\t\t\t\t\t// This path has been handled by getRootNode\n\t\t\t\t\t\t\t\tcontinue errorLoop\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcurrentNode = currentNode.children.get(entityId)!\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.rejectCorruptData()\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (this.isExecutionError(error)) {\n\t\t\t\tcurrentNode.execution.push({ type: 'execution', code: error.type, developerMessage: error.message })\n\t\t\t} else {\n\t\t\t\tcurrentNode.validation.push(this.createValidationError(error.message.text))\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate getRootNode(error: ValidationError | MutationError, startIndex: number = 0): ErrorsPreprocessor.ErrorNode {\n\t\tlet rootNode: ErrorsPreprocessor.ErrorNode = {\n\t\t\tvalidation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],\n\t\t\texecution: this.isExecutionError(error) ? [{ type: 'execution', code: error.type, developerMessage: error.message }] : [],\n\t\t\tnodeType: 'leaf',\n\t\t}\n\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\tfor (let i = path.length - 1; i >= startIndex; i--) {\n\t\t\tconst pathNode = path[i]\n\t\t\tif ('field' in pathNode) {\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[pathNode.field, rootNode]]),\n\t\t\t\t}\n\t\t\t} else if ('index' in pathNode) {\n\t\t\t\tconst alias = pathNode.alias\n\n\t\t\t\tif (alias === null) {\n\t\t\t\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t\t\t\t`Corrupt data: undefined alias for node with index ${pathNode.index}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\trootNode = {\n\t\t\t\t\tvalidation: [],\n\t\t\t\t\texecution: [],\n\t\t\t\t\tnodeType: 'iNode',\n\t\t\t\t\tchildren: new Map([[MutationAlias.decodeEntityId(alias), rootNode]]),\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tassertNever(pathNode)\n\t\t\t}\n\t\t}\n\n\t\treturn rootNode\n\t}\n\n\tprivate createValidationError(message: string): ErrorAccessor.ValidationError {\n\t\tif (message === 'Field is required') {\n\t\t\t// TODO this is just awful. Validation errors currently don't have error codes which makes it more difficult\n\t\t\t// \tto translate the error messages. This is the most common such error, and so we just make up a code\n\t\t\t// \tin order to facilitate error handling further downstream.\n\t\t\treturn {\n\t\t\t\ttype: 'validation',\n\t\t\t\tcode: 'fieldRequired',\n\t\t\t\tmessage,\n\t\t\t}\n\t\t}\n\t\treturn { type: 'validation', message, code: undefined }\n\t}\n\n\tprivate isExecutionError(error: ValidationError | MutationError): error is MutationError {\n\t\treturn 'type' in error\n\t}\n\n\tprivate rejectCorruptData(): never {\n\t\tthrow new ErrorsPreprocessor.ErrorsPreprocessorError(\n\t\t\t'Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed.',\n\t\t)\n\t}\n}\n\nnamespace ErrorsPreprocessor {\n\texport interface BaseErrorNode {\n\t\tvalidation: ErrorAccessor.ValidationError[]\n\t\texecution: ErrorAccessor.ExecutionError[]\n\t}\n\n\texport interface LeafErrorNode extends BaseErrorNode {\n\t\tnodeType: 'leaf'\n\t}\n\n\texport interface ErrorINode extends BaseErrorNode {\n\t\tnodeType: 'iNode'\n\t\tchildren: Map<FieldName | EntityId, ErrorNode>\n\t}\n\n\texport type ErrorNode = ErrorINode | LeafErrorNode\n\n\texport type ErrorTreeRoot = Map<PlaceholderName, ErrorNode>\n\n\texport class ErrorsPreprocessorError extends Error {}\n}\n\nexport { ErrorsPreprocessor }\n"],"names":["ErrorsPreprocessor"],"mappings":";;AAOA,MAAM,mBAAmB;AAAA,EACjB,YACW,iBACA,YAChB;AAFgB,SAAA,kBAAA;AACA,SAAA,aAAA;AAAA,EAAA;AAAA,EAGX,aAA+C;AAC/C,UAAA,+BAAiD,IAAI;AAEvD,QAAA,KAAK,oBAAoB,QAAW;AAChC,aAAA;AAAA,IAAA;AAGG,eAAA,aAAa,KAAK,YAAY;AACxC,YAAM,mBAAmB,KAAK,gBAAgB,KAAK,UAAU,KAAK;AAC5D,YAAA,oBAAoB,KAAK,wBAAwB,gBAAgB;AAEvE,UAAI,sBAAsB,QAAW;AACpC;AAAA,MAAA;AAED,YAAM,EAAE,aAAa,oBAAoB,GAAO,IAAA;AAEhD,UAAI,gBAAgB,UAAU;AACzB,YAAA,SAAS,IAAI,kBAAkB,GAAG;AACrC,iBAAO,KAAK,kBAAkB;AAAA,QAAA;AAEtB,iBAAA,IAAI,oB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D;AAC7E,QAAI,YAAY,qBAAqB;AAI7B,aAAA;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,MACD;AAAA,IAAA;AAED,WAAO,EAAE,MAAM,cAAc,SAAS,MAAM,OAAU;AAAA,EAAA;AAAA,EAG/C,iBAAiB,OAAgE;AACxF,WAAO,UAAU;AAAA,EAAA;AAAA,EAGV,oBAA2B;AAClC,UAAM,IAAI,mBAAmB;AAAA,MAC5B;AAAA,IACD;AAAA,EAAA;AAEF;AAAA,CAEA,CAAUA,wBAAV;AAAA,EAmBQ,MAAM,gCAAgC,MAAM;AAAA,EAAA;AAA5CA,sBAAM,0BAAA;AAAA,GAnBJ,uBAAA,qBAAA,CAAA,EAAA;"}
@@ -1,439 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const bindingCommon = require("@contember/binding-common");
4
- const StateIterator = require("./state/StateIterator.cjs");
5
- const getEntityMarker = require("./state/getEntityMarker.cjs");
6
- var __defProp = Object.defineProperty;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
- class EventManager {
10
- constructor(asyncBatchUpdatesOptions, batchUpdatesOptions, config, dirtinessTracker, onUpdate, treeStore, batchedUpdates) {
11
- this.asyncBatchUpdatesOptions = asyncBatchUpdatesOptions;
12
- this.batchUpdatesOptions = batchUpdatesOptions;
13
- this.config = config;
14
- this.dirtinessTracker = dirtinessTracker;
15
- this.onUpdate = onUpdate;
16
- this.treeStore = treeStore;
17
- this.batchedUpdates = batchedUpdates;
18
- __publicField(this, "transactionDepth", 0);
19
- __publicField(this, "isFrozenWhileUpdating", false);
20
- __publicField(this, "isMutating", false);
21
- __publicField(this, "ongoingPersistOperation");
22
- __publicField(this, "previousMetadata");
23
- __publicField(this, "newlyInitializedWithListeners", /* @__PURE__ */ new Set());
24
- __publicField(this, "pendingWithBeforeUpdate", /* @__PURE__ */ new Set());
25
- __publicField(this, "rootsWithPendingUpdates", /* @__PURE__ */ new Set());
26
- }
27
- async persistOperation(operation) {
28
- if (this.ongoingPersistOperation !== void 0) {
29
- if (this.isMutating) {
30
- throw new bindingCommon.BindingError(`Cannot trigger a persist whilst another one is ongoing!`);
31
- }
32
- return await this.ongoingPersistOperation;
33
- }
34
- if (this.transactionDepth > 0) {
35
- throw new bindingCommon.BindingError(`Cannot trigger a persist whilst batching updates!`);
36
- }
37
- return await (this.ongoingPersistOperation = new Promise(async (resolve, reject) => {
38
- await Promise.resolve();
39
- this.isMutating = true;
40
- this.flushUpdates();
41
- try {
42
- resolve(await this.asyncOperation(operation));
43
- } catch (e) {
44
- if (!(typeof e === "object" && e !== null && "type" in e && e.type === "invalidInput")) {
45
- console.error("PersistError", e);
46
- }
47
- reject(e);
48
- } finally {
49
- this.ongoingPersistOperation = void 0;
50
- this.isMutating = false;
51
- this.flushUpdates();
52
- }
53
- }));
54
- }
55
- syncTransaction(transaction) {
56
- try {
57
- this.transactionDepth++;
58
- return transaction();
59
- } finally {
60
- this.transactionDepth--;
61
- }
62
- }
63
- syncOperation(operation) {
64
- const result = this.syncTransaction(operation);
65
- this.flushUpdates();
66
- return result;
67
- }
68
- async asyncTransaction(transaction) {
69
- try {
70
- this.transactionDepth++;
71
- return await transaction();
72
- } finally {
73
- this.transactionDepth--;
74
- }
75
- }
76
- async asyncOperation(operation) {
77
- const result = await this.asyncTransaction(operation);
78
- this.flushUpdates();
79
- return result;
80
- }
81
- flushUpdates() {
82
- if (this.transactionDepth > 0) {
83
- return;
84
- }
85
- if (this.isFrozenWhileUpdating) {
86
- throw new bindingCommon.BindingError(
87
- `Trying to perform an update while the whole accessor tree is already updating. This is most likely caused by updating the accessor tree while rendering or from within the 'update' event handler, which is a no-op. If you wish to mutate the tree in reaction to other changes, use the 'beforeUpdate' event.`
88
- );
89
- }
90
- const newMetadata = this.getNewUpdateMetadata();
91
- if (!this.shouldFlushUpdates(newMetadata)) {
92
- return;
93
- }
94
- this.batchedUpdates(() => {
95
- this.isFrozenWhileUpdating = true;
96
- this.triggerBeforeFlushEvents();
97
- this.onUpdate(newMetadata);
98
- const rootStates = Array.from(this.rootsWithPendingUpdates);
99
- this.flushPendingAccessorUpdates(rootStates);
100
- this.rootsWithPendingUpdates.clear();
101
- this.isFrozenWhileUpdating = false;
102
- this.previousMetadata = newMetadata;
103
- });
104
- }
105
- getNewUpdateMetadata() {
106
- return {
107
- isMutating: this.isMutating
108
- };
109
- }
110
- shouldFlushUpdates(newMetadata) {
111
- if (this.transactionDepth > 0) {
112
- return false;
113
- }
114
- if (this.previousMetadata === void 0) {
115
- return true;
116
- }
117
- if (this.rootsWithPendingUpdates.size) {
118
- return true;
119
- }
120
- for (const key in newMetadata) {
121
- const fromPrevious = this.previousMetadata[key];
122
- const fromNew = newMetadata[key];
123
- if (!Object.is(fromPrevious, fromNew)) {
124
- return true;
125
- }
126
- }
127
- return false;
128
- }
129
- registerNewlyInitialized(newlyInitialized) {
130
- const initializeListeners = this.getEventListeners(newlyInitialized, { type: "initialize" });
131
- if (initializeListeners === void 0) {
132
- return;
133
- }
134
- this.newlyInitializedWithListeners.add(newlyInitialized);
135
- if (this.transactionDepth === 0) {
136
- this.triggerOnInitialize();
137
- }
138
- }
139
- registerUpdatedConnection(parentState, placeholderName) {
140
- if (parentState.fieldsWithPendingConnectionUpdates === void 0) {
141
- parentState.fieldsWithPendingConnectionUpdates = /* @__PURE__ */ new Set();
142
- }
143
- const marker = getEntityMarker.getEntityMarker(parentState);
144
- placeholders: for (const [fieldName, placeholdersByField] of marker.fields.placeholders) {
145
- if (typeof placeholdersByField === "string") {
146
- if (placeholdersByField === placeholderName) {
147
- parentState.fieldsWithPendingConnectionUpdates.add(fieldName);
148
- }
149
- } else {
150
- for (const placeholderByFieldName of placeholdersByField) {
151
- if (placeholderByFieldName === placeholderName) {
152
- parentState.fieldsWithPendingConnectionUpdates.add(fieldName);
153
- continue placeholders;
154
- }
155
- }
156
- }
157
- }
158
- }
159
- registerJustUpdated(justUpdated, changesDelta) {
160
- const beforeUpdateListeners = this.getEventListeners(justUpdated, { type: "beforeUpdate" });
161
- if (beforeUpdateListeners !== void 0) {
162
- this.pendingWithBeforeUpdate.add(justUpdated);
163
- }
164
- justUpdated.accessor = void 0;
165
- switch (justUpdated.type) {
166
- case "entityRealm":
167
- case "entityList": {
168
- justUpdated.unpersistedChangesCount += changesDelta;
169
- {
170
- if (justUpdated.unpersistedChangesCount < 0) {
171
- console.error(
172
- `We have *JUST* reached a completely invalid state. From now on, anything can (and likely will) go wrong. This is definitely a bug. Please try to report whatever led to this situation.`
173
- );
174
- }
175
- }
176
- const parent = justUpdated.blueprint.parent;
177
- if (parent === void 0) {
178
- this.rootsWithPendingUpdates.add(justUpdated);
179
- if (!(justUpdated.blueprint.type === "subTree" && justUpdated.blueprint.marker.parameters.isCreating && justUpdated.blueprint.marker.parameters.isUnpersisted)) {
180
- this.dirtinessTracker.increaseBy(changesDelta);
181
- }
182
- } else {
183
- if (!parent.childrenWithPendingUpdates) {
184
- parent.childrenWithPendingUpdates = /* @__PURE__ */ new Set();
185
- }
186
- parent.childrenWithPendingUpdates.add(justUpdated);
187
- this.registerJustUpdated(parent, changesDelta);
188
- }
189
- break;
190
- }
191
- case "field": {
192
- const parent = justUpdated.parent;
193
- if (!parent.childrenWithPendingUpdates) {
194
- parent.childrenWithPendingUpdates = /* @__PURE__ */ new Set();
195
- }
196
- parent.childrenWithPendingUpdates.add(justUpdated);
197
- this.registerJustUpdated(justUpdated.parent, changesDelta);
198
- break;
199
- }
200
- }
201
- }
202
- flushPendingAccessorUpdates(rootStates) {
203
- const agenda = rootStates;
204
- for (const state of agenda) {
205
- const updateListeners = state.type === "field" ? this.getEventDispatchers(state, { type: "update" }, [state.getAccessor()]) : state.type === "entityRealm" ? this.getEventDispatchers(state, { type: "update" }, [state.getAccessor()]) : this.getEventDispatchers(state, { type: "update" }, [state.getAccessor()]);
206
- if (updateListeners !== void 0) {
207
- for (const handler of updateListeners) {
208
- handler();
209
- }
210
- }
211
- if (state.type === "entityRealm" && state.fieldsWithPendingConnectionUpdates) {
212
- for (const updatedField of state.fieldsWithPendingConnectionUpdates) {
213
- const listeners = this.getEventListeners(state, { type: "connectionUpdate", key: updatedField });
214
- if (!listeners) {
215
- continue;
216
- }
217
- for (const listener of listeners) {
218
- listener(state.getAccessor());
219
- }
220
- }
221
- }
222
- switch (state.type) {
223
- case "entityRealm":
224
- case "entityList": {
225
- if (state.childrenWithPendingUpdates !== void 0) {
226
- for (const childState of state.childrenWithPendingUpdates) {
227
- agenda.push(childState);
228
- }
229
- state.childrenWithPendingUpdates.clear();
230
- }
231
- break;
232
- }
233
- case "field":
234
- break;
235
- default:
236
- bindingCommon.assertNever(state);
237
- }
238
- }
239
- }
240
- async triggerAsyncMutatingEvent(eventType, options) {
241
- await this.asyncTransaction(async () => {
242
- const callbackQueue = [];
243
- for (const [, subTreeState] of StateIterator.StateIterator.eachRootState(this.treeStore)) {
244
- for (const iNode of StateIterator.StateIterator.depthFirstINodes(subTreeState)) {
245
- const listeners = this.getEventListeners(iNode, { type: eventType }) ?? [];
246
- for (const listener of listeners) {
247
- callbackQueue.push([iNode, listener]);
248
- }
249
- }
250
- }
251
- for (let waterfallDepth = 0; waterfallDepth < this.config.getValue(`${eventType}SettleLimit`); waterfallDepth++) {
252
- const promiseReturns = [];
253
- const correspondingStates = [];
254
- if (callbackQueue.length === 0) {
255
- break;
256
- }
257
- for (const [state, callback] of callbackQueue) {
258
- correspondingStates.push(state);
259
- const changesCountBefore2 = this.dirtinessTracker.getTotalTouchCount();
260
- let validateChanges = false;
261
- try {
262
- const result = callback(state.getAccessor, options);
263
- if (result instanceof Promise) {
264
- validateChanges = true;
265
- promiseReturns.push(result);
266
- } else {
267
- promiseReturns.push(Promise.resolve(result));
268
- }
269
- } catch (e) {
270
- promiseReturns.push(Promise.reject(e));
271
- }
272
- if (validateChanges) {
273
- this.validateWithoutChanges(changesCountBefore2, eventType);
274
- }
275
- }
276
- const changesCountBefore = this.dirtinessTracker.getTotalTouchCount();
277
- const newCallbacks = await Promise.allSettled(promiseReturns);
278
- this.validateWithoutChanges(changesCountBefore, eventType);
279
- callbackQueue.length = 0;
280
- for (const newlyInitialized of this.newlyInitializedWithListeners) {
281
- if (newlyInitialized.type === "field") {
282
- continue;
283
- }
284
- const beforePersistHandlers = this.getEventListeners(newlyInitialized, { type: eventType });
285
- if (beforePersistHandlers) {
286
- for (const listener of beforePersistHandlers) {
287
- callbackQueue.push([newlyInitialized, listener]);
288
- }
289
- }
290
- }
291
- this.triggerBeforeFlushEvents();
292
- this.handleRejections(eventType, newCallbacks);
293
- for (let i = 0; i < newCallbacks.length; i++) {
294
- const result = newCallbacks[i];
295
- const correspondingState = correspondingStates[i];
296
- if (result.status === "fulfilled") {
297
- if (typeof result.value === "function") {
298
- callbackQueue.push([correspondingState, result.value]);
299
- }
300
- }
301
- }
302
- }
303
- {
304
- if (callbackQueue.length) {
305
- throw new bindingCommon.BindingError(
306
- `Exceeded the ${eventType} settle limit. Your code likely contains a deadlock. If that's not the case, raise the settle limit from DataBindingProvider.`
307
- );
308
- }
309
- }
310
- });
311
- }
312
- triggerBeforeFlushEvents() {
313
- this.syncTransaction(() => {
314
- const settleLimit = this.config.getValue("beforeUpdateSettleLimit");
315
- for (let attemptNumber = 0; attemptNumber < settleLimit; attemptNumber++) {
316
- if (!this.pendingWithBeforeUpdate.size) {
317
- this.triggerOnInitialize();
318
- return;
319
- }
320
- const withBeforeUpdate = this.pendingWithBeforeUpdate;
321
- this.pendingWithBeforeUpdate = /* @__PURE__ */ new Set();
322
- for (const state of withBeforeUpdate) {
323
- const listeners = this.getEventListeners(state, { type: "beforeUpdate" });
324
- if (listeners === void 0) {
325
- continue;
326
- }
327
- switch (state.type) {
328
- case "field":
329
- for (const listener of listeners) {
330
- listener(state.getAccessor());
331
- }
332
- break;
333
- case "entityRealm":
334
- case "entityList":
335
- for (const listener of listeners) {
336
- state.getAccessor().batchUpdates(listener);
337
- }
338
- break;
339
- default:
340
- return bindingCommon.assertNever(state);
341
- }
342
- }
343
- this.triggerOnInitialize();
344
- }
345
- throw new bindingCommon.BindingError(
346
- `Maximum stabilization limit of updates caused by 'beforeUpdate' exceeded. This likely means there is an infinite feedback loop in your code.`
347
- );
348
- });
349
- }
350
- triggerOnInitialize() {
351
- this.syncTransaction(() => {
352
- for (const state of this.newlyInitializedWithListeners) {
353
- const listeners = state.type === "field" ? this.getEventDispatchers(state, { type: "initialize" }, [state.getAccessor, this.batchUpdatesOptions]) : state.type === "entityRealm" ? this.getEventDispatchers(state, { type: "initialize" }, [state.getAccessor, this.batchUpdatesOptions]) : this.getEventDispatchers(state, { type: "initialize" }, [state.getAccessor, this.batchUpdatesOptions]);
354
- if (listeners) {
355
- for (const listener of listeners) {
356
- listener();
357
- }
358
- }
359
- if (state.type === "entityRealm") {
360
- state.entity.hasIdSetInStone = true;
361
- }
362
- }
363
- this.newlyInitializedWithListeners.clear();
364
- });
365
- }
366
- async triggerOnPersistError(options) {
367
- await this.asyncTransaction(async () => {
368
- const handlerPromises = [];
369
- for (const [, subTreeState] of StateIterator.StateIterator.eachRootState(this.treeStore)) {
370
- for (const iNode of StateIterator.StateIterator.depthFirstINodes(subTreeState)) {
371
- const dispatchers = iNode.type === "entityRealm" ? this.getEventDispatchers(iNode, { type: "persistError" }, [iNode.getAccessor, options]) : this.getEventDispatchers(iNode, { type: "persistError" }, [iNode.getAccessor, options]);
372
- if (dispatchers === void 0) {
373
- continue;
374
- }
375
- for (const listener of dispatchers ?? []) {
376
- try {
377
- const result = listener();
378
- if (result instanceof Promise) {
379
- handlerPromises.push(result);
380
- } else {
381
- handlerPromises.push(Promise.resolve(result));
382
- }
383
- } catch (e) {
384
- handlerPromises.push(Promise.reject(e));
385
- }
386
- }
387
- }
388
- }
389
- const handlerResults = await Promise.allSettled(handlerPromises);
390
- this.handleRejections("persistError", handlerResults);
391
- });
392
- }
393
- async triggerOnBeforePersist() {
394
- return this.triggerAsyncMutatingEvent("beforePersist", this.asyncBatchUpdatesOptions);
395
- }
396
- async triggerOnPersistSuccess(options) {
397
- return this.triggerAsyncMutatingEvent("persistSuccess", options);
398
- }
399
- getEventListeners(state, event) {
400
- if (!state.eventListeners) {
401
- return void 0;
402
- }
403
- return state.eventListeners.get(event);
404
- }
405
- getEventDispatchers(state, event, listenerArgs) {
406
- const eventListeners = this.getEventListeners(state, event);
407
- if (eventListeners === void 0) {
408
- return void 0;
409
- }
410
- return Array.from(eventListeners.values(), (listener) => {
411
- return () => listener(...listenerArgs);
412
- });
413
- }
414
- handleRejections(handler, promises) {
415
- const rejections = promises.filter((it) => it.status === "rejected");
416
- if (rejections.length === 0) {
417
- return;
418
- }
419
- rejections.forEach((it) => console.error(it.reason));
420
- {
421
- throw new bindingCommon.BindingError(
422
- `A ${handler} handler returned a promise that rejected. This is a no-op that will fail silently in production.`
423
- );
424
- }
425
- }
426
- validateWithoutChanges(initialCount, eventType) {
427
- const changesCountAfter = this.dirtinessTracker.getTotalTouchCount();
428
- {
429
- if (initialCount !== changesCountAfter) {
430
- throw new bindingCommon.BindingError(
431
- `A ${eventType} event handler cannot be asynchronous and alter the accessor tree at the same time. To achieve this, prepare your data asynchronously but only touch the tree from a returned callback.`
432
- );
433
- }
434
- }
435
- }
436
- }
437
- __publicField(EventManager, "NO_CHANGES_DIFFERENCE", 0);
438
- exports.EventManager = EventManager;
439
- //# sourceMappingURL=EventManager.cjs.map