@contember/binding-legacy 2.1.0-alpha.36 → 2.1.0-alpha.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/dist/development/index.cjs +34 -0
  2. package/dist/development/index.cjs.map +1 -0
  3. package/dist/development/index.js +28 -0
  4. package/dist/development/index.js.map +1 -0
  5. package/dist/development/src/accessorTree/NormalizedPersistedData.cjs +10 -0
  6. package/dist/development/src/accessorTree/NormalizedPersistedData.cjs.map +1 -0
  7. package/dist/development/src/accessorTree/NormalizedPersistedData.js +10 -0
  8. package/dist/development/src/accessorTree/NormalizedPersistedData.js.map +1 -0
  9. package/dist/development/src/accessors/EntityAccessorImpl.cjs +179 -0
  10. package/dist/development/src/accessors/EntityAccessorImpl.cjs.map +1 -0
  11. package/dist/development/src/accessors/EntityAccessorImpl.js +179 -0
  12. package/dist/development/src/accessors/EntityAccessorImpl.js.map +1 -0
  13. package/dist/development/src/accessors/EntityListAccessorImpl.cjs +112 -0
  14. package/dist/development/src/accessors/EntityListAccessorImpl.cjs.map +1 -0
  15. package/dist/development/src/accessors/EntityListAccessorImpl.js +112 -0
  16. package/dist/development/src/accessors/EntityListAccessorImpl.js.map +1 -0
  17. package/dist/development/src/accessors/FieldAccessorImpl.cjs +54 -0
  18. package/dist/development/src/accessors/FieldAccessorImpl.cjs.map +1 -0
  19. package/dist/development/src/accessors/FieldAccessorImpl.js +54 -0
  20. package/dist/development/src/accessors/FieldAccessorImpl.js.map +1 -0
  21. package/dist/development/src/core/AccessorErrorManager.cjs +200 -0
  22. package/dist/development/src/core/AccessorErrorManager.cjs.map +1 -0
  23. package/dist/development/src/core/AccessorErrorManager.js +200 -0
  24. package/dist/development/src/core/AccessorErrorManager.js.map +1 -0
  25. package/dist/development/src/core/Config.cjs +29 -0
  26. package/dist/development/src/core/Config.cjs.map +1 -0
  27. package/dist/development/src/core/Config.js +29 -0
  28. package/dist/development/src/core/Config.js.map +1 -0
  29. package/dist/development/src/core/DataBinding.cjs +357 -0
  30. package/dist/development/src/core/DataBinding.cjs.map +1 -0
  31. package/dist/development/src/core/DataBinding.js +357 -0
  32. package/dist/development/src/core/DataBinding.js.map +1 -0
  33. package/dist/development/src/core/DirtinessTracker.cjs +26 -0
  34. package/dist/development/src/core/DirtinessTracker.cjs.map +1 -0
  35. package/dist/development/src/core/DirtinessTracker.js +26 -0
  36. package/dist/development/src/core/DirtinessTracker.js.map +1 -0
  37. package/dist/development/src/core/ErrorsPreprocessor.cjs +180 -0
  38. package/dist/development/src/core/ErrorsPreprocessor.cjs.map +1 -0
  39. package/dist/development/src/core/ErrorsPreprocessor.js +180 -0
  40. package/dist/development/src/core/ErrorsPreprocessor.js.map +1 -0
  41. package/dist/development/src/core/EventManager.cjs +439 -0
  42. package/dist/development/src/core/EventManager.cjs.map +1 -0
  43. package/dist/development/src/core/EventManager.js +439 -0
  44. package/dist/development/src/core/EventManager.js.map +1 -0
  45. package/dist/development/src/core/MutationGenerator.cjs +670 -0
  46. package/dist/development/src/core/MutationGenerator.cjs.map +1 -0
  47. package/dist/development/src/core/MutationGenerator.js +670 -0
  48. package/dist/development/src/core/MutationGenerator.js.map +1 -0
  49. package/dist/development/src/core/QueryGenerator.cjs +110 -0
  50. package/dist/development/src/core/QueryGenerator.cjs.map +1 -0
  51. package/dist/development/src/core/QueryGenerator.js +110 -0
  52. package/dist/development/src/core/QueryGenerator.js.map +1 -0
  53. package/dist/development/src/core/RealmKeyGenerator.cjs +42 -0
  54. package/dist/development/src/core/RealmKeyGenerator.cjs.map +1 -0
  55. package/dist/development/src/core/RealmKeyGenerator.js +42 -0
  56. package/dist/development/src/core/RealmKeyGenerator.js.map +1 -0
  57. package/dist/development/src/core/RequestResponseNormalizer.cjs +136 -0
  58. package/dist/development/src/core/RequestResponseNormalizer.cjs.map +1 -0
  59. package/dist/development/src/core/RequestResponseNormalizer.js +136 -0
  60. package/dist/development/src/core/RequestResponseNormalizer.js.map +1 -0
  61. package/dist/development/src/core/StateInitializer.cjs +379 -0
  62. package/dist/development/src/core/StateInitializer.cjs.map +1 -0
  63. package/dist/development/src/core/StateInitializer.js +379 -0
  64. package/dist/development/src/core/StateInitializer.js.map +1 -0
  65. package/dist/development/src/core/TreeAugmenter.cjs +351 -0
  66. package/dist/development/src/core/TreeAugmenter.cjs.map +1 -0
  67. package/dist/development/src/core/TreeAugmenter.js +351 -0
  68. package/dist/development/src/core/TreeAugmenter.js.map +1 -0
  69. package/dist/development/src/core/TreeStore.cjs +172 -0
  70. package/dist/development/src/core/TreeStore.cjs.map +1 -0
  71. package/dist/development/src/core/TreeStore.js +172 -0
  72. package/dist/development/src/core/TreeStore.js.map +1 -0
  73. package/dist/development/src/core/exceptions/ErrorLocator.cjs +59 -0
  74. package/dist/development/src/core/exceptions/ErrorLocator.cjs.map +1 -0
  75. package/dist/development/src/core/exceptions/ErrorLocator.js +59 -0
  76. package/dist/development/src/core/exceptions/ErrorLocator.js.map +1 -0
  77. package/dist/development/src/core/exceptions/MarkerSugarer.cjs +51 -0
  78. package/dist/development/src/core/exceptions/MarkerSugarer.cjs.map +1 -0
  79. package/dist/development/src/core/exceptions/MarkerSugarer.js +51 -0
  80. package/dist/development/src/core/exceptions/MarkerSugarer.js.map +1 -0
  81. package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs +33 -0
  82. package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -0
  83. package/dist/development/src/core/exceptions/TreeParameterSugarer.js +33 -0
  84. package/dist/development/src/core/exceptions/TreeParameterSugarer.js.map +1 -0
  85. package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs +23 -0
  86. package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -0
  87. package/dist/development/src/core/factories/createBatchUpdatesOptions.js +23 -0
  88. package/dist/development/src/core/factories/createBatchUpdatesOptions.js.map +1 -0
  89. package/dist/development/src/core/operations/EntityOperations.cjs +224 -0
  90. package/dist/development/src/core/operations/EntityOperations.cjs.map +1 -0
  91. package/dist/development/src/core/operations/EntityOperations.js +224 -0
  92. package/dist/development/src/core/operations/EntityOperations.js.map +1 -0
  93. package/dist/development/src/core/operations/FieldOperations.cjs +92 -0
  94. package/dist/development/src/core/operations/FieldOperations.cjs.map +1 -0
  95. package/dist/development/src/core/operations/FieldOperations.js +92 -0
  96. package/dist/development/src/core/operations/FieldOperations.js.map +1 -0
  97. package/dist/development/src/core/operations/ListOperations.cjs +158 -0
  98. package/dist/development/src/core/operations/ListOperations.cjs.map +1 -0
  99. package/dist/development/src/core/operations/ListOperations.js +158 -0
  100. package/dist/development/src/core/operations/ListOperations.js.map +1 -0
  101. package/dist/development/src/core/operations/OperationsHelpers.cjs +87 -0
  102. package/dist/development/src/core/operations/OperationsHelpers.cjs.map +1 -0
  103. package/dist/development/src/core/operations/OperationsHelpers.js +87 -0
  104. package/dist/development/src/core/operations/OperationsHelpers.js.map +1 -0
  105. package/dist/development/src/core/requestAliases/MutationAlias.cjs +14 -0
  106. package/dist/development/src/core/requestAliases/MutationAlias.cjs.map +1 -0
  107. package/dist/development/src/core/requestAliases/MutationAlias.js +14 -0
  108. package/dist/development/src/core/requestAliases/MutationAlias.js.map +1 -0
  109. package/dist/development/src/core/state/StateIterator.cjs +100 -0
  110. package/dist/development/src/core/state/StateIterator.cjs.map +1 -0
  111. package/dist/development/src/core/state/StateIterator.js +100 -0
  112. package/dist/development/src/core/state/StateIterator.js.map +1 -0
  113. package/dist/development/src/core/state/getEntityMarker.cjs +5 -0
  114. package/dist/development/src/core/state/getEntityMarker.cjs.map +1 -0
  115. package/dist/development/src/core/state/getEntityMarker.js +5 -0
  116. package/dist/development/src/core/state/getEntityMarker.js.map +1 -0
  117. package/dist/development/src/core/utils/getCombinedSignal.cjs +33 -0
  118. package/dist/development/src/core/utils/getCombinedSignal.cjs.map +1 -0
  119. package/dist/development/src/core/utils/getCombinedSignal.js +33 -0
  120. package/dist/development/src/core/utils/getCombinedSignal.js.map +1 -0
  121. package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs +13 -0
  122. package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -0
  123. package/dist/development/src/fieldHelpers/helpers/FieldHelper.js +13 -0
  124. package/dist/development/src/fieldHelpers/helpers/FieldHelper.js.map +1 -0
  125. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +18 -0
  126. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -0
  127. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js +18 -0
  128. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -0
  129. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs +16 -0
  130. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -0
  131. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js +16 -0
  132. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -0
  133. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs +7 -0
  134. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -0
  135. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js +7 -0
  136. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -0
  137. package/dist/development/src/utils/isEmptyObject.cjs +12 -0
  138. package/dist/development/src/utils/isEmptyObject.cjs.map +1 -0
  139. package/dist/development/src/utils/isEmptyObject.js +12 -0
  140. package/dist/development/src/utils/isEmptyObject.js.map +1 -0
  141. package/dist/production/index.cjs +34 -0
  142. package/dist/production/index.cjs.map +1 -0
  143. package/dist/production/index.js +28 -0
  144. package/dist/production/index.js.map +1 -0
  145. package/dist/production/src/accessorTree/NormalizedPersistedData.cjs +10 -0
  146. package/dist/production/src/accessorTree/NormalizedPersistedData.cjs.map +1 -0
  147. package/dist/production/src/accessorTree/NormalizedPersistedData.js +10 -0
  148. package/dist/production/src/accessorTree/NormalizedPersistedData.js.map +1 -0
  149. package/dist/production/src/accessors/EntityAccessorImpl.cjs +179 -0
  150. package/dist/production/src/accessors/EntityAccessorImpl.cjs.map +1 -0
  151. package/dist/production/src/accessors/EntityAccessorImpl.js +179 -0
  152. package/dist/production/src/accessors/EntityAccessorImpl.js.map +1 -0
  153. package/dist/production/src/accessors/EntityListAccessorImpl.cjs +112 -0
  154. package/dist/production/src/accessors/EntityListAccessorImpl.cjs.map +1 -0
  155. package/dist/production/src/accessors/EntityListAccessorImpl.js +112 -0
  156. package/dist/production/src/accessors/EntityListAccessorImpl.js.map +1 -0
  157. package/dist/production/src/accessors/FieldAccessorImpl.cjs +54 -0
  158. package/dist/production/src/accessors/FieldAccessorImpl.cjs.map +1 -0
  159. package/dist/production/src/accessors/FieldAccessorImpl.js +54 -0
  160. package/dist/production/src/accessors/FieldAccessorImpl.js.map +1 -0
  161. package/dist/production/src/core/AccessorErrorManager.cjs +200 -0
  162. package/dist/production/src/core/AccessorErrorManager.cjs.map +1 -0
  163. package/dist/production/src/core/AccessorErrorManager.js +200 -0
  164. package/dist/production/src/core/AccessorErrorManager.js.map +1 -0
  165. package/dist/production/src/core/Config.cjs +29 -0
  166. package/dist/production/src/core/Config.cjs.map +1 -0
  167. package/dist/production/src/core/Config.js +29 -0
  168. package/dist/production/src/core/Config.js.map +1 -0
  169. package/dist/production/src/core/DataBinding.cjs +357 -0
  170. package/dist/production/src/core/DataBinding.cjs.map +1 -0
  171. package/dist/production/src/core/DataBinding.js +357 -0
  172. package/dist/production/src/core/DataBinding.js.map +1 -0
  173. package/dist/production/src/core/DirtinessTracker.cjs +26 -0
  174. package/dist/production/src/core/DirtinessTracker.cjs.map +1 -0
  175. package/dist/production/src/core/DirtinessTracker.js +26 -0
  176. package/dist/production/src/core/DirtinessTracker.js.map +1 -0
  177. package/dist/production/src/core/ErrorsPreprocessor.cjs +180 -0
  178. package/dist/production/src/core/ErrorsPreprocessor.cjs.map +1 -0
  179. package/dist/production/src/core/ErrorsPreprocessor.js +180 -0
  180. package/dist/production/src/core/ErrorsPreprocessor.js.map +1 -0
  181. package/dist/production/src/core/EventManager.cjs +413 -0
  182. package/dist/production/src/core/EventManager.cjs.map +1 -0
  183. package/dist/production/src/core/EventManager.js +413 -0
  184. package/dist/production/src/core/EventManager.js.map +1 -0
  185. package/dist/production/src/core/MutationGenerator.cjs +670 -0
  186. package/dist/production/src/core/MutationGenerator.cjs.map +1 -0
  187. package/dist/production/src/core/MutationGenerator.js +670 -0
  188. package/dist/production/src/core/MutationGenerator.js.map +1 -0
  189. package/dist/production/src/core/QueryGenerator.cjs +110 -0
  190. package/dist/production/src/core/QueryGenerator.cjs.map +1 -0
  191. package/dist/production/src/core/QueryGenerator.js +110 -0
  192. package/dist/production/src/core/QueryGenerator.js.map +1 -0
  193. package/dist/production/src/core/RealmKeyGenerator.cjs +42 -0
  194. package/dist/production/src/core/RealmKeyGenerator.cjs.map +1 -0
  195. package/dist/production/src/core/RealmKeyGenerator.js +42 -0
  196. package/dist/production/src/core/RealmKeyGenerator.js.map +1 -0
  197. package/dist/production/src/core/RequestResponseNormalizer.cjs +136 -0
  198. package/dist/production/src/core/RequestResponseNormalizer.cjs.map +1 -0
  199. package/dist/production/src/core/RequestResponseNormalizer.js +136 -0
  200. package/dist/production/src/core/RequestResponseNormalizer.js.map +1 -0
  201. package/dist/production/src/core/StateInitializer.cjs +379 -0
  202. package/dist/production/src/core/StateInitializer.cjs.map +1 -0
  203. package/dist/production/src/core/StateInitializer.js +379 -0
  204. package/dist/production/src/core/StateInitializer.js.map +1 -0
  205. package/dist/production/src/core/TreeAugmenter.cjs +351 -0
  206. package/dist/production/src/core/TreeAugmenter.cjs.map +1 -0
  207. package/dist/production/src/core/TreeAugmenter.js +351 -0
  208. package/dist/production/src/core/TreeAugmenter.js.map +1 -0
  209. package/dist/production/src/core/TreeStore.cjs +172 -0
  210. package/dist/production/src/core/TreeStore.cjs.map +1 -0
  211. package/dist/production/src/core/TreeStore.js +172 -0
  212. package/dist/production/src/core/TreeStore.js.map +1 -0
  213. package/dist/production/src/core/exceptions/ErrorLocator.cjs +59 -0
  214. package/dist/production/src/core/exceptions/ErrorLocator.cjs.map +1 -0
  215. package/dist/production/src/core/exceptions/ErrorLocator.js +59 -0
  216. package/dist/production/src/core/exceptions/ErrorLocator.js.map +1 -0
  217. package/dist/production/src/core/exceptions/MarkerSugarer.cjs +51 -0
  218. package/dist/production/src/core/exceptions/MarkerSugarer.cjs.map +1 -0
  219. package/dist/production/src/core/exceptions/MarkerSugarer.js +51 -0
  220. package/dist/production/src/core/exceptions/MarkerSugarer.js.map +1 -0
  221. package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs +33 -0
  222. package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -0
  223. package/dist/production/src/core/exceptions/TreeParameterSugarer.js +33 -0
  224. package/dist/production/src/core/exceptions/TreeParameterSugarer.js.map +1 -0
  225. package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs +23 -0
  226. package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -0
  227. package/dist/production/src/core/factories/createBatchUpdatesOptions.js +23 -0
  228. package/dist/production/src/core/factories/createBatchUpdatesOptions.js.map +1 -0
  229. package/dist/production/src/core/operations/EntityOperations.cjs +224 -0
  230. package/dist/production/src/core/operations/EntityOperations.cjs.map +1 -0
  231. package/dist/production/src/core/operations/EntityOperations.js +224 -0
  232. package/dist/production/src/core/operations/EntityOperations.js.map +1 -0
  233. package/dist/production/src/core/operations/FieldOperations.cjs +73 -0
  234. package/dist/production/src/core/operations/FieldOperations.cjs.map +1 -0
  235. package/dist/production/src/core/operations/FieldOperations.js +73 -0
  236. package/dist/production/src/core/operations/FieldOperations.js.map +1 -0
  237. package/dist/production/src/core/operations/ListOperations.cjs +158 -0
  238. package/dist/production/src/core/operations/ListOperations.cjs.map +1 -0
  239. package/dist/production/src/core/operations/ListOperations.js +158 -0
  240. package/dist/production/src/core/operations/ListOperations.js.map +1 -0
  241. package/dist/production/src/core/operations/OperationsHelpers.cjs +87 -0
  242. package/dist/production/src/core/operations/OperationsHelpers.cjs.map +1 -0
  243. package/dist/production/src/core/operations/OperationsHelpers.js +87 -0
  244. package/dist/production/src/core/operations/OperationsHelpers.js.map +1 -0
  245. package/dist/production/src/core/requestAliases/MutationAlias.cjs +14 -0
  246. package/dist/production/src/core/requestAliases/MutationAlias.cjs.map +1 -0
  247. package/dist/production/src/core/requestAliases/MutationAlias.js +14 -0
  248. package/dist/production/src/core/requestAliases/MutationAlias.js.map +1 -0
  249. package/dist/production/src/core/state/StateIterator.cjs +100 -0
  250. package/dist/production/src/core/state/StateIterator.cjs.map +1 -0
  251. package/dist/production/src/core/state/StateIterator.js +100 -0
  252. package/dist/production/src/core/state/StateIterator.js.map +1 -0
  253. package/dist/production/src/core/state/getEntityMarker.cjs +5 -0
  254. package/dist/production/src/core/state/getEntityMarker.cjs.map +1 -0
  255. package/dist/production/src/core/state/getEntityMarker.js +5 -0
  256. package/dist/production/src/core/state/getEntityMarker.js.map +1 -0
  257. package/dist/production/src/core/utils/getCombinedSignal.cjs +33 -0
  258. package/dist/production/src/core/utils/getCombinedSignal.cjs.map +1 -0
  259. package/dist/production/src/core/utils/getCombinedSignal.js +33 -0
  260. package/dist/production/src/core/utils/getCombinedSignal.js.map +1 -0
  261. package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs +13 -0
  262. package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -0
  263. package/dist/production/src/fieldHelpers/helpers/FieldHelper.js +13 -0
  264. package/dist/production/src/fieldHelpers/helpers/FieldHelper.js.map +1 -0
  265. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +18 -0
  266. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -0
  267. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js +18 -0
  268. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -0
  269. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs +16 -0
  270. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -0
  271. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js +16 -0
  272. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -0
  273. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs +7 -0
  274. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -0
  275. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js +7 -0
  276. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -0
  277. package/dist/production/src/utils/isEmptyObject.cjs +12 -0
  278. package/dist/production/src/utils/isEmptyObject.cjs.map +1 -0
  279. package/dist/production/src/utils/isEmptyObject.js +12 -0
  280. package/dist/production/src/utils/isEmptyObject.js.map +1 -0
  281. package/dist/types/accessorTree/NormalizedPersistedData.d.ts +18 -0
  282. package/dist/types/accessorTree/NormalizedPersistedData.d.ts.map +1 -0
  283. package/dist/types/accessorTree/index.d.ts +2 -0
  284. package/dist/types/accessorTree/index.d.ts.map +1 -0
  285. package/dist/types/accessors/BindingConfig.d.ts +6 -0
  286. package/dist/types/accessors/BindingConfig.d.ts.map +1 -0
  287. package/dist/types/accessors/EntityAccessorImpl.d.ts +56 -0
  288. package/dist/types/accessors/EntityAccessorImpl.d.ts.map +1 -0
  289. package/dist/types/accessors/EntityListAccessorImpl.d.ts +57 -0
  290. package/dist/types/accessors/EntityListAccessorImpl.d.ts.map +1 -0
  291. package/dist/types/accessors/FieldAccessorImpl.d.ts +32 -0
  292. package/dist/types/accessors/FieldAccessorImpl.d.ts.map +1 -0
  293. package/dist/types/accessors/index.d.ts +5 -0
  294. package/dist/types/accessors/index.d.ts.map +1 -0
  295. package/dist/types/core/AccessorErrorManager.d.ts +25 -0
  296. package/dist/types/core/AccessorErrorManager.d.ts.map +1 -0
  297. package/dist/types/core/Config.d.ts +9 -0
  298. package/dist/types/core/Config.d.ts.map +1 -0
  299. package/dist/types/core/DataBinding.d.ts +54 -0
  300. package/dist/types/core/DataBinding.d.ts.map +1 -0
  301. package/dist/types/core/DirtinessTracker.d.ts +9 -0
  302. package/dist/types/core/DirtinessTracker.d.ts.map +1 -0
  303. package/dist/types/core/ErrorsPreprocessor.d.ts +34 -0
  304. package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -0
  305. package/dist/types/core/EventManager.d.ts +57 -0
  306. package/dist/types/core/EventManager.d.ts.map +1 -0
  307. package/dist/types/core/MutationGenerator.d.ts +49 -0
  308. package/dist/types/core/MutationGenerator.d.ts.map +1 -0
  309. package/dist/types/core/QueryGenerator.d.ts +13 -0
  310. package/dist/types/core/QueryGenerator.d.ts.map +1 -0
  311. package/dist/types/core/RealmKeyGenerator.d.ts +10 -0
  312. package/dist/types/core/RealmKeyGenerator.d.ts.map +1 -0
  313. package/dist/types/core/RequestResponseNormalizer.d.ts +11 -0
  314. package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -0
  315. package/dist/types/core/StateInitializer.d.ts +34 -0
  316. package/dist/types/core/StateInitializer.d.ts.map +1 -0
  317. package/dist/types/core/TreeAugmenter.d.ts +25 -0
  318. package/dist/types/core/TreeAugmenter.d.ts.map +1 -0
  319. package/dist/types/core/TreeStore.d.ts +30 -0
  320. package/dist/types/core/TreeStore.d.ts.map +1 -0
  321. package/dist/types/core/UpdateMetadata.d.ts +4 -0
  322. package/dist/types/core/UpdateMetadata.d.ts.map +1 -0
  323. package/dist/types/core/exceptions/ErrorLocator.d.ts +8 -0
  324. package/dist/types/core/exceptions/ErrorLocator.d.ts.map +1 -0
  325. package/dist/types/core/exceptions/MarkerSugarer.d.ts +10 -0
  326. package/dist/types/core/exceptions/MarkerSugarer.d.ts.map +1 -0
  327. package/dist/types/core/exceptions/TreeParameterSugarer.d.ts +11 -0
  328. package/dist/types/core/exceptions/TreeParameterSugarer.d.ts.map +1 -0
  329. package/dist/types/core/factories/createBatchUpdatesOptions.d.ts +5 -0
  330. package/dist/types/core/factories/createBatchUpdatesOptions.d.ts.map +1 -0
  331. package/dist/types/core/factories/index.d.ts +2 -0
  332. package/dist/types/core/factories/index.d.ts.map +1 -0
  333. package/dist/types/core/index.d.ts +9 -0
  334. package/dist/types/core/index.d.ts.map +1 -0
  335. package/dist/types/core/operations/EntityOperations.d.ts +26 -0
  336. package/dist/types/core/operations/EntityOperations.d.ts.map +1 -0
  337. package/dist/types/core/operations/FieldOperations.d.ts +22 -0
  338. package/dist/types/core/operations/FieldOperations.d.ts.map +1 -0
  339. package/dist/types/core/operations/ListOperations.d.ts +32 -0
  340. package/dist/types/core/operations/ListOperations.d.ts.map +1 -0
  341. package/dist/types/core/operations/OperationsHelpers.d.ts +14 -0
  342. package/dist/types/core/operations/OperationsHelpers.d.ts.map +1 -0
  343. package/dist/types/core/operations/index.d.ts +4 -0
  344. package/dist/types/core/operations/index.d.ts.map +1 -0
  345. package/dist/types/core/requestAliases/MutationAlias.d.ts +6 -0
  346. package/dist/types/core/requestAliases/MutationAlias.d.ts.map +1 -0
  347. package/dist/types/core/requestAliases/index.d.ts +2 -0
  348. package/dist/types/core/requestAliases/index.d.ts.map +1 -0
  349. package/dist/types/core/state/EntityListState.d.ts +29 -0
  350. package/dist/types/core/state/EntityListState.d.ts.map +1 -0
  351. package/dist/types/core/state/EntityRealmState.d.ts +44 -0
  352. package/dist/types/core/state/EntityRealmState.d.ts.map +1 -0
  353. package/dist/types/core/state/EntityState.d.ts +11 -0
  354. package/dist/types/core/state/EntityState.d.ts.map +1 -0
  355. package/dist/types/core/state/FieldState.d.ts +19 -0
  356. package/dist/types/core/state/FieldState.d.ts.map +1 -0
  357. package/dist/types/core/state/StateIterator.d.ts +14 -0
  358. package/dist/types/core/state/StateIterator.d.ts.map +1 -0
  359. package/dist/types/core/state/StateNode.d.ts +8 -0
  360. package/dist/types/core/state/StateNode.d.ts.map +1 -0
  361. package/dist/types/core/state/getEntityMarker.d.ts +3 -0
  362. package/dist/types/core/state/getEntityMarker.d.ts.map +1 -0
  363. package/dist/types/core/state/index.d.ts +8 -0
  364. package/dist/types/core/state/index.d.ts.map +1 -0
  365. package/dist/types/core/utils/getCombinedSignal.d.ts +2 -0
  366. package/dist/types/core/utils/getCombinedSignal.d.ts.map +1 -0
  367. package/dist/types/core/utils/index.d.ts +2 -0
  368. package/dist/types/core/utils/index.d.ts.map +1 -0
  369. package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts +7 -0
  370. package/dist/types/fieldHelpers/helpers/FieldHelper.d.ts.map +1 -0
  371. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts +10 -0
  372. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +1 -0
  373. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +10 -0
  374. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts.map +1 -0
  375. package/dist/types/fieldHelpers/helpers/index.d.ts +3 -0
  376. package/dist/types/fieldHelpers/helpers/index.d.ts.map +1 -0
  377. package/dist/types/fieldHelpers/index.d.ts +2 -0
  378. package/dist/types/fieldHelpers/index.d.ts.map +1 -0
  379. package/dist/types/index.d.ts +5 -0
  380. package/dist/types/index.d.ts.map +1 -0
  381. package/dist/types/tsconfig.tsbuildinfo +1 -0
  382. package/dist/types/utils/assertNever.d.ts +2 -0
  383. package/dist/types/utils/assertNever.d.ts.map +1 -0
  384. package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts +2 -0
  385. package/dist/types/utils/generateEnumerabilityPreventingEntropy.d.ts.map +1 -0
  386. package/dist/types/utils/index.d.ts +4 -0
  387. package/dist/types/utils/index.d.ts.map +1 -0
  388. package/dist/types/utils/isEmptyObject.d.ts +2 -0
  389. package/dist/types/utils/isEmptyObject.d.ts.map +1 -0
  390. package/package.json +5 -5
@@ -0,0 +1,379 @@
1
+ import { EntityListSubTreeMarker, UnpersistedEntityDummyId, ServerId, FieldMarker, BindingError, HasManyRelationMarker, HasOneRelationMarker, assertNever, EventListenersStore } from "@contember/binding-common";
2
+ import { BijectiveIndexedMap } from "@contember/utilities";
3
+ import { RealmKeyGenerator } from "./RealmKeyGenerator.js";
4
+ import { FieldOperations } from "./operations/FieldOperations.js";
5
+ import { EntityOperations } from "./operations/EntityOperations.js";
6
+ import { ListOperations } from "./operations/ListOperations.js";
7
+ import { EntityAccessorImpl } from "../accessors/EntityAccessorImpl.js";
8
+ import { EntityListAccessorImpl } from "../accessors/EntityListAccessorImpl.js";
9
+ import { FieldAccessorImpl } from "../accessors/FieldAccessorImpl.js";
10
+ import { getEntityMarker } from "./state/getEntityMarker.js";
11
+ var __defProp = Object.defineProperty;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
14
+ class StateInitializer {
15
+ constructor(accessorErrorManager, batchUpdatesOptions, eventManager, treeStore) {
16
+ this.eventManager = eventManager;
17
+ this.treeStore = treeStore;
18
+ __publicField(this, "fieldOperations");
19
+ __publicField(this, "entityOperations");
20
+ __publicField(this, "listOperations");
21
+ this.fieldOperations = new FieldOperations(accessorErrorManager, this.eventManager, this, this.treeStore);
22
+ this.entityOperations = new EntityOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore);
23
+ this.listOperations = new ListOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore);
24
+ }
25
+ initializeSubTree(tree) {
26
+ let subTreeState;
27
+ const persistedRootData = this.treeStore.subTreePersistedData.get(tree.placeholderName);
28
+ if (tree instanceof EntityListSubTreeMarker) {
29
+ const persistedEntityIds = persistedRootData instanceof Set ? persistedRootData : /* @__PURE__ */ new Set();
30
+ subTreeState = this.initializeEntityListState(
31
+ { type: "subTree", marker: tree, parent: void 0 },
32
+ tree.entityName,
33
+ persistedEntityIds
34
+ );
35
+ } else {
36
+ subTreeState = this.materializeEntityRealm(
37
+ this.initializeEntityRealm(
38
+ persistedRootData instanceof ServerId ? persistedRootData : new UnpersistedEntityDummyId(),
39
+ tree.entityName,
40
+ {
41
+ type: "subTree",
42
+ marker: tree,
43
+ parent: void 0
44
+ }
45
+ )
46
+ );
47
+ }
48
+ return subTreeState;
49
+ }
50
+ initializeEntityRealm(id, entityName, blueprint, copyFrom) {
51
+ const entity = this.initializeEntityState(id, entityName);
52
+ const realmKey = RealmKeyGenerator.getRealmKey(id, blueprint);
53
+ const existing = this.treeStore.entityRealmStore.get(realmKey);
54
+ if (existing !== void 0) {
55
+ return existing;
56
+ }
57
+ if (!copyFrom || copyFrom.type !== "entityRealm") {
58
+ const stub = {
59
+ type: "entityRealmStub",
60
+ blueprint,
61
+ entity,
62
+ realmKey,
63
+ getAccessor: () => this.materializeEntityRealm(stub).getAccessor()
64
+ };
65
+ this.registerEntityRealm(stub);
66
+ return stub;
67
+ }
68
+ const realm = this.createEntityRealm(blueprint, realmKey, entity, copyFrom);
69
+ this.registerEntityRealm(realm);
70
+ const marker = getEntityMarker(realm);
71
+ const pathBack = this.treeStore.getPathBackToParent(realm);
72
+ for (const [placeholderName, field] of marker.fields.markers) {
73
+ if (field instanceof FieldMarker) {
74
+ const value = copyFrom.children.get(placeholderName);
75
+ if (!value || value.type !== "field") {
76
+ throw new BindingError();
77
+ }
78
+ this.initializeFromFieldMarker(realm, field, void 0, value);
79
+ } else if (field instanceof HasManyRelationMarker) {
80
+ const value = copyFrom.children.get(placeholderName);
81
+ if (!value || value.type !== "entityList") {
82
+ throw new BindingError();
83
+ }
84
+ this.initializeFromHasManyRelationMarker(realm, field, new Set(value.children.keys()));
85
+ } else if (field instanceof HasOneRelationMarker) {
86
+ let runtimeId;
87
+ let subCopyFrom;
88
+ if (pathBack?.fieldBackToParent === field.parameters.field && !field.parameters.reducedBy) {
89
+ runtimeId = pathBack.parent.entity.id;
90
+ } else {
91
+ const value = copyFrom.children.get(placeholderName);
92
+ if (!value || value.type !== "entityRealm" && value.type !== "entityRealmStub") {
93
+ throw new BindingError();
94
+ }
95
+ runtimeId = !(value.entity.id instanceof UnpersistedEntityDummyId) ? value.entity.id : new UnpersistedEntityDummyId();
96
+ if (value.type === "entityRealm") {
97
+ subCopyFrom = value;
98
+ }
99
+ }
100
+ this.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom);
101
+ } else {
102
+ assertNever(field);
103
+ }
104
+ }
105
+ this.eventManager.registerNewlyInitialized(realm);
106
+ return realm;
107
+ }
108
+ createEntityRealm(blueprint, realmKey, entity, copyFrom) {
109
+ const entityRealm = {
110
+ type: "entityRealm",
111
+ blueprint,
112
+ realmKey,
113
+ entity,
114
+ accessor: void 0,
115
+ children: /* @__PURE__ */ new Map(),
116
+ childrenWithPendingUpdates: void 0,
117
+ errors: void 0,
118
+ eventListeners: this.initializeEntityEventListenerStore(blueprint),
119
+ fieldsWithPendingConnectionUpdates: void 0,
120
+ plannedHasOneDeletions: void 0,
121
+ unpersistedChangesCount: copyFrom?.unpersistedChangesCount ?? 0,
122
+ getAccessor: () => {
123
+ if (entityRealm.accessor === void 0) {
124
+ const entity2 = entityRealm.entity;
125
+ entityRealm.accessor = new EntityAccessorImpl(
126
+ entityRealm,
127
+ this.entityOperations,
128
+ entity2.id,
129
+ entityRealm.realmKey,
130
+ entity2.entityName,
131
+ // We're technically exposing more info in runtime than we'd like but that way we don't have to allocate and
132
+ // keep in sync two copies of the same data. TS hides the extra info anyway.
133
+ entityRealm.children,
134
+ this.treeStore.persistedEntityData.get(entity2.id.uniqueValue),
135
+ entityRealm.unpersistedChangesCount !== 0,
136
+ entityRealm.errors,
137
+ getEntityMarker(entityRealm).environment,
138
+ entityRealm.getAccessor
139
+ );
140
+ }
141
+ return entityRealm.accessor;
142
+ }
143
+ };
144
+ return entityRealm;
145
+ }
146
+ materializeEntityRealm(state) {
147
+ if (state.type === "entityRealm") {
148
+ return state;
149
+ }
150
+ const { realmKey, entity, blueprint } = state;
151
+ const existing = this.treeStore.entityRealmStore.get(realmKey);
152
+ if (existing !== void 0 && existing.type === "entityRealm") {
153
+ return existing;
154
+ }
155
+ const entityRealm = this.createEntityRealm(blueprint, realmKey, entity);
156
+ this.registerEntityRealm(entityRealm);
157
+ const persistedData = this.treeStore.persistedEntityData.get(entity.id.uniqueValue);
158
+ const marker = getEntityMarker(state);
159
+ const pathBack = this.treeStore.getPathBackToParent(entityRealm);
160
+ for (const [placeholderName, field] of marker.fields.markers) {
161
+ const fieldDatum = persistedData?.get(placeholderName)?.value;
162
+ if (field instanceof FieldMarker) {
163
+ this.initializeFromFieldMarker(entityRealm, field, fieldDatum);
164
+ } else if (field instanceof HasManyRelationMarker) {
165
+ this.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : /* @__PURE__ */ new Set());
166
+ } else if (field instanceof HasOneRelationMarker) {
167
+ let runtimeId;
168
+ if (pathBack?.fieldBackToParent === field.parameters.field && !field.parameters.reducedBy) {
169
+ runtimeId = pathBack.parent.entity.id;
170
+ } else {
171
+ runtimeId = fieldDatum instanceof ServerId ? fieldDatum : new UnpersistedEntityDummyId();
172
+ }
173
+ this.initializeFromHasOneRelationMarker(entityRealm, field, runtimeId);
174
+ } else {
175
+ assertNever(field);
176
+ }
177
+ }
178
+ this.eventManager.registerNewlyInitialized(entityRealm);
179
+ return entityRealm;
180
+ }
181
+ registerEntityRealm(entityRealm) {
182
+ const { realmKey, blueprint, entity } = entityRealm;
183
+ this.treeStore.entityRealmStore.set(entityRealm.realmKey, entityRealm);
184
+ if (blueprint.type === "listEntity") {
185
+ blueprint.parent.children.set(entity.id.value, entityRealm);
186
+ } else if (blueprint.type === "hasOne") {
187
+ blueprint.parent.children.set(blueprint.marker.placeholderName, entityRealm);
188
+ }
189
+ entity.realms.set(realmKey, entityRealm);
190
+ }
191
+ initializeEntityState(id, entityName) {
192
+ const entityId = id.uniqueValue;
193
+ const existing = this.treeStore.entityStore.get(entityId);
194
+ if (existing !== void 0) {
195
+ return existing;
196
+ }
197
+ const entityState = {
198
+ entityName,
199
+ hasIdSetInStone: id instanceof ServerId,
200
+ id,
201
+ isScheduledForDeletion: false,
202
+ maidenId: id instanceof UnpersistedEntityDummyId ? id : void 0,
203
+ realms: /* @__PURE__ */ new Map()
204
+ };
205
+ this.treeStore.entityStore.set(entityId, entityState);
206
+ return entityState;
207
+ }
208
+ initializeEntityListState(blueprint, entityName, initialEntityIds) {
209
+ const entityListState = {
210
+ type: "entityList",
211
+ accessor: void 0,
212
+ blueprint,
213
+ children: new BijectiveIndexedMap((realm) => realm.entity.id.value),
214
+ childrenWithPendingUpdates: void 0,
215
+ entityName,
216
+ eventListeners: this.initializeEntityListEventListenerStore(blueprint),
217
+ childEventListeners: this.initializeEntityListChildEventListenerStore(blueprint),
218
+ errors: void 0,
219
+ plannedRemovals: void 0,
220
+ unpersistedChangesCount: 0,
221
+ // TODO force creation?
222
+ getAccessor: () => {
223
+ if (entityListState.accessor === void 0) {
224
+ const persistedEntityIds = this.treeStore.getEntityListPersistedIds(entityListState);
225
+ entityListState.accessor = new EntityListAccessorImpl(
226
+ entityListState,
227
+ this.listOperations,
228
+ entityListState.entityName,
229
+ entityListState.children,
230
+ persistedEntityIds,
231
+ entityListState.unpersistedChangesCount !== 0,
232
+ entityListState.errors,
233
+ entityListState.blueprint.marker.environment,
234
+ entityListState.getAccessor
235
+ );
236
+ }
237
+ return entityListState.accessor;
238
+ }
239
+ };
240
+ const initialData = initialEntityIds.size === 0 ? Array.from({ length: blueprint.marker.parameters.initialEntityCount }) : initialEntityIds;
241
+ for (const entityId of initialData) {
242
+ this.initializeEntityRealm(
243
+ entityId ? new ServerId(entityId, entityName) : new UnpersistedEntityDummyId(),
244
+ entityListState.entityName,
245
+ {
246
+ type: "listEntity",
247
+ parent: entityListState
248
+ }
249
+ );
250
+ }
251
+ this.eventManager.registerNewlyInitialized(entityListState);
252
+ return entityListState;
253
+ }
254
+ initializeFieldState(parent, placeholderName, fieldMarker, persistedValue, copyFromState) {
255
+ const resolvedFieldValue = copyFromState ? copyFromState.value : persistedValue ?? fieldMarker.defaultValue ?? null;
256
+ const fieldState = {
257
+ type: "field",
258
+ accessor: void 0,
259
+ fieldMarker,
260
+ placeholderName,
261
+ persistedValue,
262
+ parent,
263
+ value: resolvedFieldValue,
264
+ eventListeners: this.initializeFieldEventListenerStore(fieldMarker),
265
+ errors: void 0,
266
+ touchLog: void 0,
267
+ hasUnpersistedChanges: copyFromState?.hasUnpersistedChanges ?? false,
268
+ getAccessor: () => {
269
+ if (fieldState.accessor === void 0) {
270
+ const fieldSchema = this.treeStore.schema.getEntityColumn(parent.entity.entityName, fieldMarker.fieldName);
271
+ fieldState.accessor = new FieldAccessorImpl(
272
+ fieldState,
273
+ this.fieldOperations,
274
+ fieldState.placeholderName,
275
+ fieldState.value,
276
+ fieldState.persistedValue === void 0 ? null : fieldState.persistedValue,
277
+ fieldState.fieldMarker.defaultValue,
278
+ fieldState.errors,
279
+ fieldState.hasUnpersistedChanges,
280
+ fieldState.touchLog,
281
+ fieldState.getAccessor,
282
+ fieldSchema
283
+ );
284
+ }
285
+ return fieldState.accessor;
286
+ }
287
+ };
288
+ this.eventManager.registerNewlyInitialized(fieldState);
289
+ return fieldState;
290
+ }
291
+ initializeFromFieldMarker(parent, field, persistedValue, copyFromState) {
292
+ if (persistedValue instanceof Set) {
293
+ throw new BindingError(
294
+ `Received a collection of referenced entities where a single '${field.fieldName}' field was expected. Perhaps you wanted to use a <Repeater />?`
295
+ );
296
+ }
297
+ if (persistedValue instanceof ServerId) {
298
+ throw new BindingError(
299
+ `Received a referenced entity where a single '${field.fieldName}' field was expected. Perhaps you wanted to use <HasOne />?`
300
+ );
301
+ }
302
+ parent.children.set(
303
+ field.placeholderName,
304
+ this.initializeFieldState(parent, field.placeholderName, field, persistedValue, copyFromState)
305
+ );
306
+ }
307
+ initializeFromHasOneRelationMarker(parent, field, entityId, copyFrom) {
308
+ parent.children.set(
309
+ field.placeholderName,
310
+ this.initializeEntityRealm(entityId, this.getRelationTargetEntityName(parent, field), {
311
+ type: "hasOne",
312
+ parent,
313
+ marker: field
314
+ }, copyFrom)
315
+ );
316
+ }
317
+ initializeFromHasManyRelationMarker(parent, field, persistedEntityIds) {
318
+ parent.children.set(
319
+ field.placeholderName,
320
+ this.initializeEntityListState(
321
+ { type: "hasMany", marker: field, parent },
322
+ this.getRelationTargetEntityName(parent, field),
323
+ persistedEntityIds
324
+ )
325
+ );
326
+ }
327
+ getRelationTargetEntityName(entityRealm, field) {
328
+ const targetField = this.treeStore.schema.getEntityRelation(entityRealm.entity.entityName, field.parameters.field);
329
+ return targetField.targetEntity;
330
+ }
331
+ runImmediateUserInitialization(realm, initialize) {
332
+ if (initialize === void 0) {
333
+ return;
334
+ }
335
+ const entityRealm = this.materializeEntityRealm(realm);
336
+ realm.getAccessor().batchUpdates(initialize);
337
+ const initializeListeners = this.eventManager.getEventListeners(entityRealm, { type: "initialize" });
338
+ if (initializeListeners === void 0 || initializeListeners.size === 0) {
339
+ realm.entity.hasIdSetInStone = true;
340
+ }
341
+ }
342
+ initializeEntityEventListenerStore(blueprint) {
343
+ if (blueprint.type === "listEntity") {
344
+ const blueprintListeners2 = blueprint.parent.blueprint.marker.parameters.childEventListeners;
345
+ const childInitialize = blueprintListeners2?.get({ type: "initialize" });
346
+ const store = new EventListenersStore(() => blueprint.parent.childEventListeners);
347
+ if (childInitialize !== void 0) {
348
+ store.set({ type: "initialize" }, childInitialize);
349
+ }
350
+ return store;
351
+ }
352
+ const blueprintListeners = blueprint.marker.parameters.eventListeners;
353
+ if (blueprintListeners === void 0) {
354
+ return void 0;
355
+ }
356
+ return blueprintListeners.clone();
357
+ }
358
+ initializeEntityListEventListenerStore(blueprint) {
359
+ const blueprintListeners = blueprint.marker.parameters.eventListeners;
360
+ if (blueprintListeners === void 0) {
361
+ return void 0;
362
+ }
363
+ return blueprintListeners.clone();
364
+ }
365
+ initializeEntityListChildEventListenerStore(blueprint) {
366
+ const blueprintListeners = blueprint.marker.parameters.childEventListeners;
367
+ if (blueprintListeners === void 0) {
368
+ return void 0;
369
+ }
370
+ return blueprintListeners.clone();
371
+ }
372
+ initializeFieldEventListenerStore(marker) {
373
+ return marker.parameters.eventListeners?.clone();
374
+ }
375
+ }
376
+ export {
377
+ StateInitializer
378
+ };
379
+ //# sourceMappingURL=StateInitializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StateInitializer.js","sources":["../../../../../packages/binding-legacy/src/core/StateInitializer.ts"],"sourcesContent":["import { BatchUpdatesOptions, EntityAccessor, FieldAccessor } from '@contember/binding-common'\nimport { RuntimeId, ServerId, UnpersistedEntityDummyId } from '@contember/binding-common'\nimport { BindingError } from '@contember/binding-common'\nimport { EntityListSubTreeMarker, EntitySubTreeMarker, FieldMarker, HasManyRelationMarker, HasOneRelationMarker } from '@contember/binding-common'\nimport { BijectiveIndexedMap } from '@contember/utilities'\nimport type {\n\tEntityEventListenerStore,\n\tEntityId,\n\tEntityListEventListenerStore,\n\tEntityName,\n\tFieldEventListenerStore,\n\tFieldName,\n\tFieldValue,\n} from '@contember/binding-common'\nimport { EventListenersStore } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport type { AccessorErrorManager } from './AccessorErrorManager'\nimport type { EventManager } from './EventManager'\nimport { EntityOperations, FieldOperations, ListOperations } from './operations'\nimport { RealmKeyGenerator } from './RealmKeyGenerator'\nimport {\n\tEntityListBlueprint,\n\tEntityListState,\n\tEntityRealmBlueprint,\n\tEntityRealmState,\n\tEntityRealmStateStub,\n\tEntityState,\n\tFieldState,\n\tgetEntityMarker,\n\tRootStateNode,\n} from './state'\nimport { TreeParameterMerger } from '@contember/binding-common'\nimport type { TreeStore } from './TreeStore'\nimport { EntityAccessorImpl, EntityListAccessorImpl, FieldAccessorImpl } from '../accessors'\nimport { EntityFieldPersistedData, EntityFieldPersistedValue } from '../accessorTree'\n\nexport class StateInitializer {\n\tprivate readonly fieldOperations: FieldOperations\n\tprivate readonly entityOperations: EntityOperations\n\tprivate readonly listOperations: ListOperations\n\n\tpublic constructor(\n\t\taccessorErrorManager: AccessorErrorManager,\n\t\tbatchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {\n\t\tthis.fieldOperations = new FieldOperations(accessorErrorManager, this.eventManager, this, this.treeStore)\n\t\tthis.entityOperations = new EntityOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore)\n\t\tthis.listOperations = new ListOperations(accessorErrorManager, batchUpdatesOptions, this.eventManager, this, this.treeStore)\n\t}\n\n\tpublic initializeSubTree(tree: EntitySubTreeMarker | EntityListSubTreeMarker): RootStateNode {\n\t\tlet subTreeState: RootStateNode\n\t\tconst persistedRootData = this.treeStore.subTreePersistedData.get(tree.placeholderName)\n\n\t\tif (tree instanceof EntityListSubTreeMarker) {\n\t\t\tconst persistedEntityIds: Set<EntityId> = persistedRootData instanceof Set ? persistedRootData : new Set()\n\t\t\tsubTreeState = this.initializeEntityListState(\n\t\t\t\t{ type: 'subTree', marker: tree, parent: undefined },\n\t\t\t\ttree.entityName,\n\t\t\t\tpersistedEntityIds,\n\t\t\t)\n\t\t} else {\n\t\t\tsubTreeState = this.materializeEntityRealm(\n\t\t\t\tthis.initializeEntityRealm(\n\t\t\t\t\tpersistedRootData instanceof ServerId ? persistedRootData : new UnpersistedEntityDummyId(),\n\t\t\t\t\ttree.entityName,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'subTree',\n\t\t\t\t\t\tmarker: tree,\n\t\t\t\t\t\tparent: undefined,\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t)\n\t\t}\n\n\t\treturn subTreeState\n\t}\n\n\tpublic initializeEntityRealm(\n\t\tid: RuntimeId,\n\t\tentityName: EntityName,\n\t\tblueprint: EntityRealmBlueprint,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\t// This is counter-intuitive a bit. The method can also return an EntityRealmState, not just a stub.\n\t\t// The reason is so that each call-site can just default to trying to initialize a stub without having to keep\n\t\t// in mind that the realm might have already been initialized.\n\n\t\tconst entity = this.initializeEntityState(id, entityName)\n\t\tconst realmKey = RealmKeyGenerator.getRealmKey(id, blueprint)\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tif (!copyFrom || copyFrom.type !== 'entityRealm') {\n\t\t\tconst stub: EntityRealmStateStub = {\n\t\t\t\ttype: 'entityRealmStub',\n\n\t\t\t\tblueprint,\n\t\t\t\tentity,\n\t\t\t\trealmKey,\n\t\t\t\tgetAccessor: () => this.materializeEntityRealm(stub).getAccessor(),\n\t\t\t}\n\t\t\tthis.registerEntityRealm(stub)\n\n\t\t\treturn stub\n\t\t}\n\t\tconst realm = this.createEntityRealm(blueprint, realmKey, entity, copyFrom)\n\n\t\tthis.registerEntityRealm(realm)\n\n\t\tconst marker = getEntityMarker(realm)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(realm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'field') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromFieldMarker(realm, field, undefined, value)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\tif (!value || value.type !== 'entityList') {\n\t\t\t\t\tthrow new BindingError()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasManyRelationMarker(realm, field, new Set(value.children.keys()))\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tlet subCopyFrom: EntityRealmState | undefined\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field && !field.parameters.reducedBy) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\tconst value = copyFrom.children.get(placeholderName)\n\t\t\t\t\tif (!value || (value.type !== 'entityRealm' && value.type !== 'entityRealmStub')) {\n\t\t\t\t\t\tthrow new BindingError()\n\t\t\t\t\t}\n\t\t\t\t\truntimeId = !(value.entity.id instanceof UnpersistedEntityDummyId) ? value.entity.id : new UnpersistedEntityDummyId()\n\t\t\t\t\tif (value.type === 'entityRealm') {\n\t\t\t\t\t\tsubCopyFrom = value\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(realm, field, runtimeId, subCopyFrom)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(realm)\n\t\treturn realm\n\t}\n\n\tprivate createEntityRealm(\n\t\tblueprint: EntityRealmBlueprint,\n\t\trealmKey: string,\n\t\tentity: EntityState,\n\t\tcopyFrom?: EntityRealmState,\n\t): EntityRealmState {\n\t\tconst entityRealm: EntityRealmState = {\n\t\t\ttype: 'entityRealm',\n\n\t\t\tblueprint,\n\t\t\trealmKey,\n\t\t\tentity,\n\n\t\t\taccessor: undefined,\n\t\t\tchildren: new Map(),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\terrors: undefined,\n\t\t\teventListeners: this.initializeEntityEventListenerStore(blueprint),\n\t\t\tfieldsWithPendingConnectionUpdates: undefined,\n\t\t\tplannedHasOneDeletions: undefined,\n\t\t\tunpersistedChangesCount: copyFrom?.unpersistedChangesCount ?? 0,\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityRealm.accessor === undefined) {\n\t\t\t\t\tconst entity = entityRealm.entity\n\t\t\t\t\tentityRealm.accessor = new EntityAccessorImpl(\n\t\t\t\t\t\tentityRealm,\n\t\t\t\t\t\tthis.entityOperations,\n\t\t\t\t\t\tentity.id,\n\t\t\t\t\t\tentityRealm.realmKey,\n\t\t\t\t\t\tentity.entityName,\n\t\t\t\t\t\t// We're technically exposing more info in runtime than we'd like but that way we don't have to allocate and\n\t\t\t\t\t\t// keep in sync two copies of the same data. TS hides the extra info anyway.\n\t\t\t\t\t\tentityRealm.children,\n\t\t\t\t\t\tthis.treeStore.persistedEntityData.get(entity.id.uniqueValue),\n\t\t\t\t\t\tentityRealm.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityRealm.errors,\n\t\t\t\t\t\tgetEntityMarker(entityRealm).environment,\n\t\t\t\t\t\tentityRealm.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityRealm.accessor\n\t\t\t},\n\t\t}\n\t\treturn entityRealm\n\t}\n\n\tprivate materializeEntityRealm(state: EntityRealmState | EntityRealmStateStub): EntityRealmState {\n\t\tif (state.type === 'entityRealm') {\n\t\t\treturn state\n\t\t}\n\t\tconst { realmKey, entity, blueprint } = state\n\n\t\tconst existing = this.treeStore.entityRealmStore.get(realmKey)\n\t\tif (existing !== undefined && existing.type === 'entityRealm') {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityRealm = this.createEntityRealm(blueprint, realmKey, entity)\n\n\t\tthis.registerEntityRealm(entityRealm)\n\n\t\t// if (blueprint.creationParameters.forceCreation && !entity.id.existsOnServer) {\n\t\t// \tentityRealm.unpersistedChangesCount += 1\n\t\t// }\n\n\t\tconst persistedData = this.treeStore.persistedEntityData.get(entity.id.uniqueValue)\n\n\t\tconst marker = getEntityMarker(state)\n\t\tconst pathBack = this.treeStore.getPathBackToParent(entityRealm)\n\n\t\tfor (const [placeholderName, field] of marker.fields.markers) {\n\t\t\tconst fieldDatum = persistedData?.get(placeholderName)?.value\n\n\t\t\tif (field instanceof FieldMarker) {\n\t\t\t\tthis.initializeFromFieldMarker(entityRealm, field, fieldDatum)\n\t\t\t} else if (field instanceof HasManyRelationMarker) {\n\t\t\t\t// if (pathBack?.fieldBackToParent === field.parameters.field) {\n\t\t\t\t// \t// TODO this is probably wrong?\n\t\t\t\t// \tconst ids = pathBack.parent.children.get(field.placeholderName)\n\t\t\t\t// \tconst newData = this.treeStore.persistedEntityData.get(pathBack.parent.entity.id.value)\n\t\t\t\t// \tconsole.log('many?', pathBack, field, entityRealm, fieldDatum, ids)\n\t\t\t\t// }\n\t\t\t\tthis.initializeFromHasManyRelationMarker(entityRealm, field, fieldDatum instanceof Set ? fieldDatum : new Set())\n\t\t\t} else if (field instanceof HasOneRelationMarker) {\n\t\t\t\tlet runtimeId: RuntimeId\n\t\t\t\tif (pathBack?.fieldBackToParent === field.parameters.field && !field.parameters.reducedBy) {\n\t\t\t\t\truntimeId = pathBack.parent.entity.id\n\t\t\t\t} else {\n\t\t\t\t\truntimeId = fieldDatum instanceof ServerId ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t\t\t}\n\t\t\t\tthis.initializeFromHasOneRelationMarker(entityRealm, field, runtimeId)\n\t\t\t} else {\n\t\t\t\tassertNever(field)\n\t\t\t}\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityRealm)\n\n\t\treturn entityRealm\n\t}\n\n\tprivate registerEntityRealm(entityRealm: EntityRealmState | EntityRealmStateStub) {\n\t\tconst { realmKey, blueprint, entity } = entityRealm\n\n\t\tthis.treeStore.entityRealmStore.set(entityRealm.realmKey, entityRealm)\n\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tblueprint.parent.children.set(entity.id.value, entityRealm)\n\t\t} else if (blueprint.type === 'hasOne') {\n\t\t\tblueprint.parent.children.set(blueprint.marker.placeholderName, entityRealm)\n\t\t}\n\t\tentity.realms.set(realmKey, entityRealm)\n\t}\n\n\tpublic initializeEntityState(id: RuntimeId, entityName: EntityName): EntityState {\n\t\tconst entityId = id.uniqueValue\n\n\t\tconst existing = this.treeStore.entityStore.get(entityId)\n\t\tif (existing !== undefined) {\n\t\t\treturn existing\n\t\t}\n\n\t\tconst entityState: EntityState = {\n\t\t\tentityName,\n\t\t\thasIdSetInStone: id instanceof ServerId,\n\t\t\tid,\n\t\t\tisScheduledForDeletion: false,\n\t\t\tmaidenId: id instanceof UnpersistedEntityDummyId ? id : undefined,\n\t\t\trealms: new Map(),\n\t\t}\n\t\tthis.treeStore.entityStore.set(entityId, entityState)\n\n\t\treturn entityState\n\t}\n\n\tprivate initializeEntityListState(\n\t\tblueprint: EntityListBlueprint,\n\t\tentityName: EntityName,\n\t\tinitialEntityIds: Set<EntityId>,\n\t): EntityListState {\n\t\tconst entityListState: EntityListState = {\n\t\t\ttype: 'entityList',\n\t\t\taccessor: undefined,\n\t\t\tblueprint,\n\t\t\tchildren: new BijectiveIndexedMap(realm => realm.entity.id.value),\n\t\t\tchildrenWithPendingUpdates: undefined,\n\t\t\tentityName,\n\t\t\teventListeners: this.initializeEntityListEventListenerStore(blueprint),\n\t\t\tchildEventListeners: this.initializeEntityListChildEventListenerStore(blueprint),\n\t\t\terrors: undefined,\n\t\t\tplannedRemovals: undefined,\n\t\t\tunpersistedChangesCount: 0, // TODO force creation?\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (entityListState.accessor === undefined) {\n\t\t\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(entityListState)\n\t\t\t\t\tentityListState.accessor = new EntityListAccessorImpl(\n\t\t\t\t\t\tentityListState,\n\t\t\t\t\t\tthis.listOperations,\n\t\t\t\t\t\tentityListState.entityName,\n\t\t\t\t\t\tentityListState.children,\n\t\t\t\t\t\tpersistedEntityIds,\n\t\t\t\t\t\tentityListState.unpersistedChangesCount !== 0,\n\t\t\t\t\t\tentityListState.errors,\n\t\t\t\t\t\tentityListState.blueprint.marker.environment,\n\t\t\t\t\t\tentityListState.getAccessor,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn entityListState.accessor\n\t\t\t},\n\t\t}\n\n\t\tconst initialData: Iterable<EntityId | undefined> = initialEntityIds.size === 0\n\t\t\t? Array.from({ length: blueprint.marker.parameters.initialEntityCount })\n\t\t\t: initialEntityIds\n\t\tfor (const entityId of initialData) {\n\t\t\tthis.initializeEntityRealm(\n\t\t\t\tentityId ? new ServerId(entityId, entityName) : new UnpersistedEntityDummyId(),\n\t\t\t\tentityListState.entityName,\n\t\t\t\t{\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: entityListState,\n\t\t\t\t},\n\t\t\t)\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(entityListState)\n\n\t\treturn entityListState\n\t}\n\n\tprivate initializeFieldState(\n\t\tparent: EntityRealmState,\n\t\tplaceholderName: FieldName,\n\t\tfieldMarker: FieldMarker,\n\t\tpersistedValue: FieldValue | undefined,\n\t\tcopyFromState: FieldState | undefined,\n\t): FieldState {\n\t\tconst resolvedFieldValue = copyFromState ? copyFromState.value : (persistedValue ?? fieldMarker.defaultValue ?? null)\n\n\t\tconst fieldState: FieldState = {\n\t\t\ttype: 'field',\n\t\t\taccessor: undefined,\n\t\t\tfieldMarker,\n\t\t\tplaceholderName,\n\t\t\tpersistedValue,\n\t\t\tparent,\n\t\t\tvalue: resolvedFieldValue,\n\t\t\teventListeners: this.initializeFieldEventListenerStore(fieldMarker),\n\t\t\terrors: undefined,\n\t\t\ttouchLog: undefined,\n\t\t\thasUnpersistedChanges: copyFromState?.hasUnpersistedChanges ?? false,\n\n\t\t\tgetAccessor: () => {\n\t\t\t\tif (fieldState.accessor === undefined) {\n\t\t\t\t\tconst fieldSchema = this.treeStore.schema.getEntityColumn(parent.entity.entityName, fieldMarker.fieldName)\n\n\t\t\t\t\tfieldState.accessor = new FieldAccessorImpl(\n\t\t\t\t\t\tfieldState,\n\t\t\t\t\t\tthis.fieldOperations,\n\t\t\t\t\t\tfieldState.placeholderName,\n\t\t\t\t\t\tfieldState.value,\n\t\t\t\t\t\tfieldState.persistedValue === undefined ? null : fieldState.persistedValue,\n\t\t\t\t\t\tfieldState.fieldMarker.defaultValue,\n\t\t\t\t\t\tfieldState.errors,\n\t\t\t\t\t\tfieldState.hasUnpersistedChanges,\n\t\t\t\t\t\tfieldState.touchLog,\n\t\t\t\t\t\tfieldState.getAccessor,\n\t\t\t\t\t\tfieldSchema,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn fieldState.accessor\n\t\t\t},\n\t\t}\n\n\t\tthis.eventManager.registerNewlyInitialized(fieldState)\n\t\treturn fieldState\n\t}\n\n\tprivate initializeFromFieldMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: FieldMarker,\n\t\tpersistedValue: EntityFieldPersistedValue | undefined,\n\t\tcopyFromState?: FieldState,\n\t) {\n\t\tif (persistedValue instanceof Set) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a collection of referenced entities where a single '${field.fieldName}' field was expected. `\n\t\t\t\t\t+ `Perhaps you wanted to use a <Repeater />?`,\n\t\t\t)\n\t\t}\n\t\tif (persistedValue instanceof ServerId) {\n\t\t\tthrow new BindingError(\n\t\t\t\t`Received a referenced entity where a single '${field.fieldName}' field was expected. `\n\t\t\t\t\t+ `Perhaps you wanted to use <HasOne />?`,\n\t\t\t)\n\t\t}\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeFieldState(parent, field.placeholderName, field, persistedValue, copyFromState),\n\t\t)\n\t}\n\n\tprivate initializeFromHasOneRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasOneRelationMarker,\n\t\tentityId: RuntimeId,\n\t\tcopyFrom?: EntityRealmState | EntityRealmStateStub,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityRealm(entityId, this.getRelationTargetEntityName(parent, field), {\n\t\t\t\ttype: 'hasOne',\n\t\t\t\tparent,\n\t\t\t\tmarker: field,\n\t\t\t}, copyFrom),\n\t\t)\n\t\t// if (fieldDatum instanceof ServerGeneratedUuid || fieldDatum === null || fieldDatum === undefined) {\n\t\t// \tconst entityId = fieldDatum instanceof ServerGeneratedUuid ? fieldDatum : new UnpersistedEntityDummyId()\n\t\t//\n\t\t//\n\t\t// } else if (fieldDatum instanceof Set) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a collection of entities for field '${relation.field}' where a single entity was expected. ` +\n\t\t// \t\t\t`Perhaps you wanted to use a <Repeater />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a single entity was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate initializeFromHasManyRelationMarker(\n\t\tparent: EntityRealmState,\n\t\tfield: HasManyRelationMarker,\n\t\tpersistedEntityIds: Set<EntityId>,\n\t) {\n\t\tparent.children.set(\n\t\t\tfield.placeholderName,\n\t\t\tthis.initializeEntityListState(\n\t\t\t\t{ type: 'hasMany', marker: field, parent },\n\t\t\t\tthis.getRelationTargetEntityName(parent, field),\n\t\t\t\tpersistedEntityIds,\n\t\t\t),\n\t\t)\n\t\t// const relation = field.parameters\n\t\t//\n\t\t// if (fieldDatum === undefined || fieldDatum instanceof Set) {\n\t\t//\n\t\t// } else if (typeof fieldDatum === 'object') {\n\t\t// \t// Intentionally allowing `fieldDatum === null` here as well since this should only happen when a *hasOne\n\t\t// \t// relation is unlinked, e.g. a Person does not have a linked Nationality.\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a referenced entity for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you wanted to use a <HasOne />?`,\n\t\t// \t)\n\t\t// } else {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Received a scalar value for field '${relation.field}' where a collection of entities was expected.` +\n\t\t// \t\t\t`Perhaps you meant to use a variant of <Field />?`,\n\t\t// \t)\n\t\t// }\n\t}\n\n\tprivate getRelationTargetEntityName(\n\t\tentityRealm: EntityRealmState,\n\t\tfield: HasOneRelationMarker | HasManyRelationMarker,\n\t): EntityName {\n\t\tconst targetField = this.treeStore.schema.getEntityRelation(entityRealm.entity.entityName, field.parameters.field)\n\t\treturn targetField.targetEntity\n\t}\n\n\tpublic runImmediateUserInitialization(\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tinitialize: EntityAccessor.BatchUpdatesHandler | undefined,\n\t) {\n\t\tif (initialize === undefined) {\n\t\t\treturn\n\t\t}\n\t\tconst entityRealm = this.materializeEntityRealm(realm)\n\n\t\trealm.getAccessor().batchUpdates(initialize)\n\n\t\tconst initializeListeners = this.eventManager.getEventListeners(entityRealm, { type: 'initialize' })\n\t\tif (initializeListeners === undefined || initializeListeners.size === 0) {\n\t\t\trealm.entity.hasIdSetInStone = true\n\t\t}\n\t}\n\n\tpublic initializeEntityEventListenerStore(blueprint: EntityRealmBlueprint): EntityEventListenerStore | undefined {\n\t\tif (blueprint.type === 'listEntity') {\n\t\t\tconst blueprintListeners = blueprint.parent.blueprint.marker.parameters.childEventListeners\n\t\t\tconst childInitialize = blueprintListeners?.get({ type: 'initialize' })\n\t\t\tconst store: EntityEventListenerStore = new EventListenersStore(() => blueprint.parent.childEventListeners)\n\n\t\t\tif (childInitialize !== undefined) {\n\t\t\t\tstore.set({ type: 'initialize' }, childInitialize)\n\t\t\t}\n\t\t\treturn store\n\t\t}\n\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprintListeners.clone()\n\t}\n\n\tprivate initializeEntityListEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityListEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.eventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprintListeners.clone()\n\t}\n\n\tprivate initializeEntityListChildEventListenerStore(\n\t\tblueprint: EntityListBlueprint,\n\t): EntityEventListenerStore | undefined {\n\t\tconst blueprintListeners = blueprint.marker.parameters.childEventListeners\n\n\t\tif (blueprintListeners === undefined) {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprintListeners.clone()\n\t}\n\n\tprivate initializeFieldEventListenerStore(marker: FieldMarker): FieldEventListenerStore | undefined {\n\t\treturn marker.parameters.eventListeners?.clone()\n\t}\n}\n"],"names":["entity","blueprintListeners"],"mappings":";;;;;;;;;;;;;AAoCO,MAAM,iBAAiB;AAAA,EAKtB,YACN,sBACA,qBACiB,cACA,WAChB;AAFgB,SAAA,eAAA;AACA,SAAA,YAAA;AARlB,kBAAA,MAAiB,iBAAA;AACjB,kBAAA,MAAiB,kBAAA;AACjB,kBAAA,MAAiB,gBAAA;AAQhB,SAAK,kBAAkB,IAAI,gBAAgB,sBAAsB,KAAK,cAAc,MAAM,KAAK,SAAS;AACxG,SAAK,mBAAmB,IAAI,iBAAiB,sBAAsB,qBAAqB,KAAK,cAAc,MAAM,KAAK,SAAS;AAC/H,SAAK,iBAAiB,IAAI,eAAe,sBAAsB,qBAAqB,KAAK,cAAc,MAAM,KAAK,SAAS;AAAA,EAC5H;AAAA,EAEO,kBAAkB,MAAoE;AAC5F,QAAI;AACJ,UAAM,oBAAoB,KAAK,UAAU,qBAAqB,IAAI,KAAK,eAAe;AAEtF,QAAI,gBAAgB,yBAAyB;AAC5C,YAAM,qBAAoC,6BAA6B,MAAM,wCAAwB,IAAA;AACrG,qBAAe,KAAK;AAAA,QACnB,EAAE,MAAM,WAAW,QAAQ,MAAM,QAAQ,OAAA;AAAA,QACzC,KAAK;AAAA,QACL;AAAA,MAAA;AAAA,IAEF,OAAO;AACN,qBAAe,KAAK;AAAA,QACnB,KAAK;AAAA,UACJ,6BAA6B,WAAW,oBAAoB,IAAI,yBAAA;AAAA,UAChE,KAAK;AAAA,UACL;AAAA,YACC,MAAM;AAAA,YACN,QAAQ;AAAA,YACR,QAAQ;AAAA,UAAA;AAAA,QACT;AAAA,MACD;AAAA,IAEF;AAEA,WAAO;AAAA,EACR;AAAA,EAEO,sBACN,IACA,YACA,WACA,UAC0C;AAK1C,UAAM,SAAS,KAAK,sBAAsB,IAAI,UAAU;AACxD,UAAM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