@contember/binding-legacy 2.1.0-alpha.30 → 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 +23 -27
  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 +8 -15
  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 -670
  69. package/dist/development/src/core/MutationGenerator.cjs.map +0 -1
  70. package/dist/development/src/core/MutationGenerator.js +0 -670
  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 -670
  209. package/dist/production/src/core/MutationGenerator.cjs.map +0 -1
  210. package/dist/production/src/core/MutationGenerator.js +0 -670
  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,180 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const bindingCommon = require("@contember/binding-common");
4
- const MutationAlias = require("./requestAliases/MutationAlias.cjs");
5
- class ErrorsPreprocessor {
6
- constructor(requestResponse, operations) {
7
- this.requestResponse = requestResponse;
8
- this.operations = operations;
9
- }
10
- preprocess() {
11
- const treeRoot = /* @__PURE__ */ new Map();
12
- if (this.requestResponse === void 0) {
13
- return treeRoot;
14
- }
15
- for (const operation of this.operations) {
16
- const mutationResponse = this.requestResponse.data[operation.alias];
17
- const processedResponse = this.processMutationResponse(mutationResponse);
18
- if (processedResponse === void 0) {
19
- continue;
20
- }
21
- const { subTreeType, subTreePlaceholder, id } = operation;
22
- if (subTreeType === "single") {
23
- if (treeRoot.has(subTreePlaceholder)) {
24
- return this.rejectCorruptData();
25
- }
26
- treeRoot.set(subTreePlaceholder, processedResponse);
27
- } else if (subTreeType === "list") {
28
- const child = treeRoot.get(subTreePlaceholder);
29
- if (child === void 0) {
30
- treeRoot.set(subTreePlaceholder, {
31
- nodeType: "iNode",
32
- children: /* @__PURE__ */ new Map([[id, processedResponse]]),
33
- validation: [],
34
- execution: []
35
- });
36
- } else if (child.nodeType === "iNode") {
37
- child.children.set(id, processedResponse);
38
- }
39
- } else {
40
- return bindingCommon.assertNever(subTreeType);
41
- }
42
- }
43
- return treeRoot;
44
- }
45
- processMutationResponse(mutationResponse) {
46
- if (mutationResponse.ok && mutationResponse.validation?.valid && mutationResponse.errors.length === 0) {
47
- return void 0;
48
- }
49
- if (mutationResponse.validation?.errors.length) {
50
- return this.getErrorNode(mutationResponse.validation?.errors);
51
- }
52
- if (mutationResponse.errors.length) {
53
- return this.getErrorNode(mutationResponse.errors);
54
- }
55
- return void 0;
56
- }
57
- getErrorNode(errors) {
58
- const [head, ...tail] = errors;
59
- let rootNode = this.getRootNode(head);
60
- errorLoop: for (const error of tail) {
61
- let currentNode = rootNode;
62
- const path = "paths" in error ? error.paths[0] ?? [] : error.path;
63
- for (let i = 0, pathLength = path.length; i < pathLength; i++) {
64
- const pathNode = path[i];
65
- if (currentNode.nodeType === "leaf") {
66
- currentNode.nodeType = "iNode";
67
- currentNode.children = /* @__PURE__ */ new Map();
68
- }
69
- if ("field" in pathNode) {
70
- if (currentNode.nodeType === "iNode") {
71
- let alias = pathNode.field;
72
- let nextIndex = i + 1;
73
- if (nextIndex in path) {
74
- const nextPathNode = path[nextIndex];
75
- if ("index" in nextPathNode && typeof nextPathNode.alias === "string" && nextPathNode.alias.startsWith(pathNode.field)) {
76
- i++;
77
- nextIndex++;
78
- alias = nextPathNode.alias;
79
- }
80
- }
81
- if (!currentNode.children.has(alias)) {
82
- currentNode.children.set(alias, this.getRootNode(error, nextIndex));
83
- if (nextIndex <= path.length) {
84
- continue errorLoop;
85
- }
86
- }
87
- currentNode = currentNode.children.get(alias);
88
- } else {
89
- this.rejectCorruptData();
90
- }
91
- } else if ("index" in path) {
92
- if (currentNode.nodeType === "iNode") {
93
- const alias = pathNode.alias;
94
- if (alias === null) {
95
- throw new ErrorsPreprocessor.ErrorsPreprocessorError(
96
- `Corrupt data: undefined alias for node with index ${pathNode.index}.`
97
- );
98
- }
99
- const entityId = MutationAlias.MutationAlias.decodeEntityId(alias);
100
- if (!currentNode.children.has(entityId)) {
101
- currentNode.children.set(entityId, this.getRootNode(error, i + 1));
102
- if (i + 1 <= path.length) {
103
- continue errorLoop;
104
- }
105
- }
106
- currentNode = currentNode.children.get(entityId);
107
- } else {
108
- this.rejectCorruptData();
109
- }
110
- }
111
- }
112
- if (this.isExecutionError(error)) {
113
- currentNode.execution.push({ type: "execution", code: error.type, developerMessage: error.message });
114
- } else {
115
- currentNode.validation.push(this.createValidationError(error.message.text));
116
- }
117
- }
118
- return rootNode;
119
- }
120
- getRootNode(error, startIndex = 0) {
121
- let rootNode = {
122
- validation: this.isExecutionError(error) ? [] : [this.createValidationError(error.message.text)],
123
- execution: this.isExecutionError(error) ? [{ type: "execution", code: error.type, developerMessage: error.message }] : [],
124
- nodeType: "leaf"
125
- };
126
- const path = "paths" in error ? error.paths[0] ?? [] : error.path;
127
- for (let i = path.length - 1; i >= startIndex; i--) {
128
- const pathNode = path[i];
129
- if ("field" in pathNode) {
130
- rootNode = {
131
- validation: [],
132
- execution: [],
133
- nodeType: "iNode",
134
- children: /* @__PURE__ */ new Map([[pathNode.field, rootNode]])
135
- };
136
- } else if ("index" in pathNode) {
137
- const alias = pathNode.alias;
138
- if (alias === null) {
139
- throw new ErrorsPreprocessor.ErrorsPreprocessorError(
140
- `Corrupt data: undefined alias for node with index ${pathNode.index}.`
141
- );
142
- }
143
- rootNode = {
144
- validation: [],
145
- execution: [],
146
- nodeType: "iNode",
147
- children: /* @__PURE__ */ new Map([[MutationAlias.MutationAlias.decodeEntityId(alias), rootNode]])
148
- };
149
- } else {
150
- bindingCommon.assertNever(pathNode);
151
- }
152
- }
153
- return rootNode;
154
- }
155
- createValidationError(message) {
156
- if (message === "Field is required") {
157
- return {
158
- type: "validation",
159
- code: "fieldRequired",
160
- message
161
- };
162
- }
163
- return { type: "validation", message, code: void 0 };
164
- }
165
- isExecutionError(error) {
166
- return "type" in error;
167
- }
168
- rejectCorruptData() {
169
- throw new ErrorsPreprocessor.ErrorsPreprocessorError(
170
- "Received corrupted data: a node cannot be simultaneously field-indexed and path-indexed."
171
- );
172
- }
173
- }
174
- ((ErrorsPreprocessor2) => {
175
- class ErrorsPreprocessorError extends Error {
176
- }
177
- ErrorsPreprocessor2.ErrorsPreprocessorError = ErrorsPreprocessorError;
178
- })(ErrorsPreprocessor || (ErrorsPreprocessor = {}));
179
- exports.ErrorsPreprocessor = ErrorsPreprocessor;
180
- //# sourceMappingURL=ErrorsPreprocessor.cjs.map
@@ -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,MAAA;AAAA,IAC/B;AAGM,WAAA;AAAA,EAAA;AAAA,EAGA,wBAAwB,kBAA4E;AACvG,QAAA,iBAAiB,MAAM,iBAAiB,YAAY,SAAS,iBAAiB,OAAO,WAAW,GAAG;AAC/F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KAAK;AAC7C,YAAA,WAAW,KAAK,CAAC;AACvB,UAAI,WAAW,UAAU;AACb,mBAAA;AAAA,UACV,YAAY,CAAC;AAAA,UACb,WAAW,CAAC;AAAA,UACZ,UAAU;AAAA,UACV,8BAAc,IAAI,CAAC,CAAC,SAAS,OAAO,QAAQ,CAAC,CAAC;AAAA,QAC/C;AAAA,MAAA,WACU,WAAW,UAAU;AAC/B,cAAM,QAAQ,SAAS;AAEvB,YAAI,UAAU,MAAM;AACnB,gBAAM,IAAI,mBAAmB;AAAA,YAC5B,qDAAqD,SAAS,KAAK;AAAA,UACpE;AAAA,QAAA;AAGU,mBAAA;AAAA,UACV,YAAY,CAAC;AAAA,UACb,WAAW,CAAC;AAAA,UACZ,UAAU;AAAA,UACV,UAAc,oBAAA,IAAI,CAAC,CAACA,cAAAA,cAAc,eAAe,KAAK,GAAG,QAAQ,CAAC,CAAC;AAAA,QACpE;AAAA,MAAA,OACM;AACND,sBAAAA,YAAY,QAAQ;AAAA,MAAA;AAAA,IACrB;AAGM,WAAA;AAAA,EAAA;AAAA,EAGA,sBAAsB,SAAgD;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,CAAUE,wBAAV;AAAA,EAmBQ,MAAM,gCAAgC,MAAM;AAAA,EAAA;AAA5CA,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,oBAAoB,iBAAiB;AAAA,MAAA,WACxC,gBAAgB,QAAQ;AAC5B,cAAA,QAAQ,SAAS,IAAI,kBAAkB;AAE7C,YAAI,UAAU,QAAW;AACxB,mBAAS,IAAI,oBAAoB;AAAA,YAChC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