@contember/binding-legacy 2.1.0-alpha.9 → 2.1.0-beta.1

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 (199) hide show
  1. package/dist/development/index.cjs +8 -8
  2. package/dist/development/index.js +4 -4
  3. package/dist/development/src/accessorTree/NormalizedPersistedData.cjs.map +1 -1
  4. package/dist/development/src/accessorTree/NormalizedPersistedData.js.map +1 -1
  5. package/dist/development/src/accessors/EntityAccessorImpl.cjs.map +1 -1
  6. package/dist/development/src/accessors/EntityAccessorImpl.js.map +1 -1
  7. package/dist/development/src/accessors/EntityListAccessorImpl.cjs +1 -1
  8. package/dist/development/src/accessors/EntityListAccessorImpl.cjs.map +1 -1
  9. package/dist/development/src/accessors/EntityListAccessorImpl.js +1 -1
  10. package/dist/development/src/accessors/EntityListAccessorImpl.js.map +1 -1
  11. package/dist/development/src/accessors/FieldAccessorImpl.cjs.map +1 -1
  12. package/dist/development/src/accessors/FieldAccessorImpl.js.map +1 -1
  13. package/dist/development/src/core/AccessorErrorManager.cjs.map +1 -1
  14. package/dist/development/src/core/AccessorErrorManager.js.map +1 -1
  15. package/dist/development/src/core/Config.cjs.map +1 -1
  16. package/dist/development/src/core/Config.js.map +1 -1
  17. package/dist/development/src/core/DataBinding.cjs +10 -7
  18. package/dist/development/src/core/DataBinding.cjs.map +1 -1
  19. package/dist/development/src/core/DataBinding.js +10 -7
  20. package/dist/development/src/core/DataBinding.js.map +1 -1
  21. package/dist/development/src/core/DirtinessTracker.cjs.map +1 -1
  22. package/dist/development/src/core/DirtinessTracker.js.map +1 -1
  23. package/dist/development/src/core/ErrorsPreprocessor.cjs.map +1 -1
  24. package/dist/development/src/core/ErrorsPreprocessor.js.map +1 -1
  25. package/dist/development/src/core/EventManager.cjs.map +1 -1
  26. package/dist/development/src/core/EventManager.js.map +1 -1
  27. package/dist/development/src/core/MutationGenerator.cjs.map +1 -1
  28. package/dist/development/src/core/MutationGenerator.js.map +1 -1
  29. package/dist/development/src/core/QueryGenerator.cjs.map +1 -1
  30. package/dist/development/src/core/QueryGenerator.js.map +1 -1
  31. package/dist/development/src/core/RealmKeyGenerator.cjs.map +1 -1
  32. package/dist/development/src/core/RealmKeyGenerator.js.map +1 -1
  33. package/dist/development/src/core/RequestResponseNormalizer.cjs.map +1 -1
  34. package/dist/development/src/core/RequestResponseNormalizer.js.map +1 -1
  35. package/dist/development/src/core/StateInitializer.cjs +1 -1
  36. package/dist/development/src/core/StateInitializer.cjs.map +1 -1
  37. package/dist/development/src/core/StateInitializer.js +2 -2
  38. package/dist/development/src/core/StateInitializer.js.map +1 -1
  39. package/dist/development/src/core/TreeAugmenter.cjs +2 -5
  40. package/dist/development/src/core/TreeAugmenter.cjs.map +1 -1
  41. package/dist/development/src/core/TreeAugmenter.js +2 -5
  42. package/dist/development/src/core/TreeAugmenter.js.map +1 -1
  43. package/dist/development/src/core/TreeStore.cjs.map +1 -1
  44. package/dist/development/src/core/TreeStore.js.map +1 -1
  45. package/dist/development/src/core/exceptions/ErrorLocator.cjs.map +1 -1
  46. package/dist/development/src/core/exceptions/ErrorLocator.js.map +1 -1
  47. package/dist/development/src/core/exceptions/MarkerSugarer.cjs.map +1 -1
  48. package/dist/development/src/core/exceptions/MarkerSugarer.js.map +1 -1
  49. package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -1
  50. package/dist/development/src/core/exceptions/TreeParameterSugarer.js.map +1 -1
  51. package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
  52. package/dist/development/src/core/factories/createBatchUpdatesOptions.js.map +1 -1
  53. package/dist/development/src/core/operations/EntityOperations.cjs +1 -3
  54. package/dist/development/src/core/operations/EntityOperations.cjs.map +1 -1
  55. package/dist/development/src/core/operations/EntityOperations.js +1 -3
  56. package/dist/development/src/core/operations/EntityOperations.js.map +1 -1
  57. package/dist/development/src/core/operations/FieldOperations.cjs.map +1 -1
  58. package/dist/development/src/core/operations/FieldOperations.js.map +1 -1
  59. package/dist/development/src/core/operations/ListOperations.cjs.map +1 -1
  60. package/dist/development/src/core/operations/ListOperations.js.map +1 -1
  61. package/dist/development/src/core/operations/OperationsHelpers.cjs.map +1 -1
  62. package/dist/development/src/core/operations/OperationsHelpers.js.map +1 -1
  63. package/dist/development/src/core/requestAliases/MutationAlias.cjs.map +1 -1
  64. package/dist/development/src/core/requestAliases/MutationAlias.js.map +1 -1
  65. package/dist/development/src/core/state/StateIterator.cjs.map +1 -1
  66. package/dist/development/src/core/state/StateIterator.js.map +1 -1
  67. package/dist/development/src/core/utils/getCombinedSignal.cjs.map +1 -1
  68. package/dist/development/src/core/utils/getCombinedSignal.js.map +1 -1
  69. package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -1
  70. package/dist/development/src/fieldHelpers/helpers/FieldHelper.js.map +1 -1
  71. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +3 -3
  72. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -1
  73. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js +3 -3
  74. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
  75. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -1
  76. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
  77. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -1
  78. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -1
  79. package/dist/development/src/utils/isEmptyObject.cjs.map +1 -1
  80. package/dist/development/src/utils/isEmptyObject.js.map +1 -1
  81. package/dist/production/index.cjs +8 -8
  82. package/dist/production/index.js +4 -4
  83. package/dist/production/src/accessorTree/NormalizedPersistedData.cjs.map +1 -1
  84. package/dist/production/src/accessorTree/NormalizedPersistedData.js.map +1 -1
  85. package/dist/production/src/accessors/EntityAccessorImpl.cjs.map +1 -1
  86. package/dist/production/src/accessors/EntityAccessorImpl.js.map +1 -1
  87. package/dist/production/src/accessors/EntityListAccessorImpl.cjs +1 -1
  88. package/dist/production/src/accessors/EntityListAccessorImpl.cjs.map +1 -1
  89. package/dist/production/src/accessors/EntityListAccessorImpl.js +1 -1
  90. package/dist/production/src/accessors/EntityListAccessorImpl.js.map +1 -1
  91. package/dist/production/src/accessors/FieldAccessorImpl.cjs.map +1 -1
  92. package/dist/production/src/accessors/FieldAccessorImpl.js.map +1 -1
  93. package/dist/production/src/core/AccessorErrorManager.cjs.map +1 -1
  94. package/dist/production/src/core/AccessorErrorManager.js.map +1 -1
  95. package/dist/production/src/core/Config.cjs.map +1 -1
  96. package/dist/production/src/core/Config.js.map +1 -1
  97. package/dist/production/src/core/DataBinding.cjs +10 -7
  98. package/dist/production/src/core/DataBinding.cjs.map +1 -1
  99. package/dist/production/src/core/DataBinding.js +10 -7
  100. package/dist/production/src/core/DataBinding.js.map +1 -1
  101. package/dist/production/src/core/DirtinessTracker.cjs.map +1 -1
  102. package/dist/production/src/core/DirtinessTracker.js.map +1 -1
  103. package/dist/production/src/core/ErrorsPreprocessor.cjs.map +1 -1
  104. package/dist/production/src/core/ErrorsPreprocessor.js.map +1 -1
  105. package/dist/production/src/core/EventManager.cjs.map +1 -1
  106. package/dist/production/src/core/EventManager.js.map +1 -1
  107. package/dist/production/src/core/MutationGenerator.cjs.map +1 -1
  108. package/dist/production/src/core/MutationGenerator.js.map +1 -1
  109. package/dist/production/src/core/QueryGenerator.cjs.map +1 -1
  110. package/dist/production/src/core/QueryGenerator.js.map +1 -1
  111. package/dist/production/src/core/RealmKeyGenerator.cjs.map +1 -1
  112. package/dist/production/src/core/RealmKeyGenerator.js.map +1 -1
  113. package/dist/production/src/core/RequestResponseNormalizer.cjs.map +1 -1
  114. package/dist/production/src/core/RequestResponseNormalizer.js.map +1 -1
  115. package/dist/production/src/core/StateInitializer.cjs +1 -1
  116. package/dist/production/src/core/StateInitializer.cjs.map +1 -1
  117. package/dist/production/src/core/StateInitializer.js +2 -2
  118. package/dist/production/src/core/StateInitializer.js.map +1 -1
  119. package/dist/production/src/core/TreeAugmenter.cjs +2 -5
  120. package/dist/production/src/core/TreeAugmenter.cjs.map +1 -1
  121. package/dist/production/src/core/TreeAugmenter.js +2 -5
  122. package/dist/production/src/core/TreeAugmenter.js.map +1 -1
  123. package/dist/production/src/core/TreeStore.cjs.map +1 -1
  124. package/dist/production/src/core/TreeStore.js.map +1 -1
  125. package/dist/production/src/core/exceptions/ErrorLocator.cjs.map +1 -1
  126. package/dist/production/src/core/exceptions/ErrorLocator.js.map +1 -1
  127. package/dist/production/src/core/exceptions/MarkerSugarer.cjs.map +1 -1
  128. package/dist/production/src/core/exceptions/MarkerSugarer.js.map +1 -1
  129. package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -1
  130. package/dist/production/src/core/exceptions/TreeParameterSugarer.js.map +1 -1
  131. package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
  132. package/dist/production/src/core/factories/createBatchUpdatesOptions.js.map +1 -1
  133. package/dist/production/src/core/operations/EntityOperations.cjs +1 -3
  134. package/dist/production/src/core/operations/EntityOperations.cjs.map +1 -1
  135. package/dist/production/src/core/operations/EntityOperations.js +1 -3
  136. package/dist/production/src/core/operations/EntityOperations.js.map +1 -1
  137. package/dist/production/src/core/operations/FieldOperations.cjs.map +1 -1
  138. package/dist/production/src/core/operations/FieldOperations.js.map +1 -1
  139. package/dist/production/src/core/operations/ListOperations.cjs.map +1 -1
  140. package/dist/production/src/core/operations/ListOperations.js.map +1 -1
  141. package/dist/production/src/core/operations/OperationsHelpers.cjs.map +1 -1
  142. package/dist/production/src/core/operations/OperationsHelpers.js.map +1 -1
  143. package/dist/production/src/core/requestAliases/MutationAlias.cjs.map +1 -1
  144. package/dist/production/src/core/requestAliases/MutationAlias.js.map +1 -1
  145. package/dist/production/src/core/state/StateIterator.cjs.map +1 -1
  146. package/dist/production/src/core/state/StateIterator.js.map +1 -1
  147. package/dist/production/src/core/utils/getCombinedSignal.cjs.map +1 -1
  148. package/dist/production/src/core/utils/getCombinedSignal.js.map +1 -1
  149. package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -1
  150. package/dist/production/src/fieldHelpers/helpers/FieldHelper.js.map +1 -1
  151. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +3 -3
  152. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -1
  153. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js +3 -3
  154. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
  155. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -1
  156. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
  157. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -1
  158. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -1
  159. package/dist/production/src/utils/isEmptyObject.cjs.map +1 -1
  160. package/dist/production/src/utils/isEmptyObject.js.map +1 -1
  161. package/dist/types/accessors/EntityAccessorImpl.d.ts.map +1 -1
  162. package/dist/types/accessors/EntityListAccessorImpl.d.ts.map +1 -1
  163. package/dist/types/core/DataBinding.d.ts.map +1 -1
  164. package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
  165. package/dist/types/core/EventManager.d.ts.map +1 -1
  166. package/dist/types/core/MutationGenerator.d.ts.map +1 -1
  167. package/dist/types/core/QueryGenerator.d.ts.map +1 -1
  168. package/dist/types/core/RealmKeyGenerator.d.ts.map +1 -1
  169. package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
  170. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  171. package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
  172. package/dist/types/core/TreeStore.d.ts.map +1 -1
  173. package/dist/types/core/operations/FieldOperations.d.ts.map +1 -1
  174. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  175. package/dist/types/core/state/EntityListState.d.ts.map +1 -1
  176. package/dist/types/tsconfig.tsbuildinfo +1 -1
  177. package/package.json +10 -5
  178. package/src/accessorTree/NormalizedPersistedData.ts +1 -1
  179. package/src/accessors/EntityAccessorImpl.ts +13 -11
  180. package/src/accessors/EntityListAccessorImpl.ts +16 -7
  181. package/src/core/AccessorErrorManager.ts +2 -2
  182. package/src/core/DataBinding.ts +24 -15
  183. package/src/core/ErrorsPreprocessor.ts +4 -5
  184. package/src/core/EventManager.ts +34 -46
  185. package/src/core/MutationGenerator.ts +23 -27
  186. package/src/core/QueryGenerator.ts +4 -5
  187. package/src/core/RealmKeyGenerator.ts +5 -3
  188. package/src/core/RequestResponseNormalizer.ts +3 -8
  189. package/src/core/StateInitializer.ts +10 -18
  190. package/src/core/TreeAugmenter.ts +8 -15
  191. package/src/core/TreeStore.ts +5 -4
  192. package/src/core/operations/EntityOperations.ts +25 -25
  193. package/src/core/operations/FieldOperations.ts +15 -17
  194. package/src/core/operations/ListOperations.ts +15 -15
  195. package/src/core/operations/OperationsHelpers.ts +2 -2
  196. package/src/core/state/EntityListState.ts +3 -9
  197. package/src/fieldHelpers/helpers/TemporalFieldHelper.ts +3 -3
  198. package/src/utils/assertNever.ts +4 -4
  199. package/tests/example.test.ts +2 -2
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const bindingCommon = require("@contember/binding-common");
4
- const EntityAccessorImpl = require("./src/accessors/EntityAccessorImpl.cjs");
5
- const EntityListAccessorImpl = require("./src/accessors/EntityListAccessorImpl.cjs");
6
- const FieldAccessorImpl = require("./src/accessors/FieldAccessorImpl.cjs");
7
- const NormalizedPersistedData = require("./src/accessorTree/NormalizedPersistedData.cjs");
8
4
  const Config = require("./src/core/Config.cjs");
9
5
  const DataBinding = require("./src/core/DataBinding.cjs");
10
6
  const DirtinessTracker = require("./src/core/DirtinessTracker.cjs");
7
+ const EntityAccessorImpl = require("./src/accessors/EntityAccessorImpl.cjs");
8
+ const EntityListAccessorImpl = require("./src/accessors/EntityListAccessorImpl.cjs");
11
9
  const EventManager = require("./src/core/EventManager.cjs");
10
+ const FieldAccessorImpl = require("./src/accessors/FieldAccessorImpl.cjs");
11
+ const NormalizedPersistedData = require("./src/accessorTree/NormalizedPersistedData.cjs");
12
12
  const QueryGenerator = require("./src/core/QueryGenerator.cjs");
13
13
  const StateInitializer = require("./src/core/StateInitializer.cjs");
14
14
  const TreeAugmenter = require("./src/core/TreeAugmenter.cjs");
15
15
  const TreeStore = require("./src/core/TreeStore.cjs");
16
- exports.EntityAccessorImpl = EntityAccessorImpl.EntityAccessorImpl;
17
- exports.EntityListAccessorImpl = EntityListAccessorImpl.EntityListAccessorImpl;
18
- exports.FieldAccessorImpl = FieldAccessorImpl.FieldAccessorImpl;
19
- exports.NormalizedPersistedData = NormalizedPersistedData.NormalizedPersistedData;
20
16
  exports.Config = Config.Config;
21
17
  exports.DataBinding = DataBinding.DataBinding;
22
18
  exports.DirtinessTracker = DirtinessTracker.DirtinessTracker;
19
+ exports.EntityAccessorImpl = EntityAccessorImpl.EntityAccessorImpl;
20
+ exports.EntityListAccessorImpl = EntityListAccessorImpl.EntityListAccessorImpl;
23
21
  exports.EventManager = EventManager.EventManager;
22
+ exports.FieldAccessorImpl = FieldAccessorImpl.FieldAccessorImpl;
23
+ exports.NormalizedPersistedData = NormalizedPersistedData.NormalizedPersistedData;
24
24
  exports.QueryGenerator = QueryGenerator.QueryGenerator;
25
25
  exports.StateInitializer = StateInitializer.StateInitializer;
26
26
  exports.TreeAugmenter = TreeAugmenter.TreeAugmenter;
@@ -1,12 +1,12 @@
1
1
  export * from "@contember/binding-common";
2
- import { EntityAccessorImpl } from "./src/accessors/EntityAccessorImpl.js";
3
- import { EntityListAccessorImpl } from "./src/accessors/EntityListAccessorImpl.js";
4
- import { FieldAccessorImpl } from "./src/accessors/FieldAccessorImpl.js";
5
- import { NormalizedPersistedData } from "./src/accessorTree/NormalizedPersistedData.js";
6
2
  import { Config } from "./src/core/Config.js";
7
3
  import { DataBinding } from "./src/core/DataBinding.js";
8
4
  import { DirtinessTracker } from "./src/core/DirtinessTracker.js";
5
+ import { EntityAccessorImpl } from "./src/accessors/EntityAccessorImpl.js";
6
+ import { EntityListAccessorImpl } from "./src/accessors/EntityListAccessorImpl.js";
9
7
  import { EventManager } from "./src/core/EventManager.js";
8
+ import { FieldAccessorImpl } from "./src/accessors/FieldAccessorImpl.js";
9
+ import { NormalizedPersistedData } from "./src/accessorTree/NormalizedPersistedData.js";
10
10
  import { QueryGenerator } from "./src/core/QueryGenerator.js";
11
11
  import { StateInitializer } from "./src/core/StateInitializer.js";
12
12
  import { TreeAugmenter } from "./src/core/TreeAugmenter.js";
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizedPersistedData.cjs","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n//\t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":";;AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EAAA;AAElB;;"}
1
+ {"version":3,"file":"NormalizedPersistedData.cjs","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n// \t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":";;AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizedPersistedData.js","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n//\t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":"AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EAAA;AAElB;"}
1
+ {"version":3,"file":"NormalizedPersistedData.js","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n// \t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":"AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(''\n\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(''\n\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t+ 'Provided parameters:\\n'\n\t\t\t+ JSON.stringify(relationParams)\n\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":["ErrorAccessor","QueryLanguage","PlaceholderGenerator","TreeNodeUtils","BindingError","HasOneRelationMarker","PlaceholderParametersGenerator","HasManyRelationMarker","getEntityMarker"],"mappings":";;;;;;;AAkCO,MAAM,mBAA6C;AAAA,EAGlD,YACW,OACA,YACA,WACR,KACA,MACQ,WACA,gBACR,uBACA,QACA,aACA,aACR;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACR,SAAA,MAAA;AACA,SAAA,OAAA;AACQ,SAAA,YAAA;AACA,SAAA,iBAAA;AACR,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAbV,kBAAA,MAAgB,UAAS,gBAAA;AAAA,EAAA;AAAA,EAiBzB,IAAI,aAAmC;AACtC,WAAO,KAAK,UAAU,iBAAiB,KAAK,UAAU,QAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAM/D,IAAI,KAAe;AAClB,WAAO,KAAK,UAAU;AAAA,EAAA;AAAA,EAGvB,IAAI,iBAA0B;AAC7B,WAAO,KAAK,UAAU;AAAA,EAAA;AAAA;AAAA,EAKvB,SA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,KAAK,QAAQD,cAAAA,cAAc,iBAAiB,WAAW,CAAC;AAAA;AAAA;AAAA;AAAA,IAG5D,KAAK,UAAU,cAAc,IAC7B;AAAA,IACH;AAAA,EAAA;AAAA,EAGO,kBAAkB,QAAuB;AAC5C,QAAA,OAAO,WAAW,GAAG;AACjB,aAAA;AAAA,IAAA;AAGF,UAAA,mBAAmB,OAAO,IAAI,CAAM,OAAA,KAAK,UAAU,EAAE,CAAC,EAAE,KAAK,IAAI;AACvE,UAAM,UAAU,OAAO,WAAW,IAC/B,4FACA;AAEI,WAAA;AAAA;AAAA,EAAO,OAAO;AAAA,EAAK,gBAAgB;AAAA,EAAA;AAAA,EAGnC,iBACP,SACA,mBACA,WACoB;AACpB,WAAO,MAAM,KAAK,QAAQ,OAAA,CAAQ,EAChC,OAAO,CAAC,OAA+B,cAAc,qBAAsB,GAAG,WAAW,UAAU,SAAS;AAAA,EAAA;AAAA,EAG/G,YAA6D;AACtD,UAAA,YAAY,KAAK,MAAM;AACzB,QAAA,UAAU,SAAS,WAAW;AAC1B,aAAA;AAAA,IAAA;AAED,WAAA,UAAU,OAAO,YAAY;AAAA,EAAA;AAAA,EAGrC,YAAY;AACJ,WAAAK,gBAAA,gBAAgB,KAAK,KAAK;AAAA,EAAA;AAAA,EAGlC,aAAa,OAAe;AAC3B,UAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK;AACzC,WAAA;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IACvB;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"EntityAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t\t+ 'Provided parameters:\\n'\n\t\t\t\t+ JSON.stringify(relationParams)\n\t\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":["ErrorAccessor","QueryLanguage","PlaceholderGenerator","TreeNodeUtils","BindingError","HasOneRelationMarker","PlaceholderParametersGenerator","HasManyRelationMarker","getEntityMarker"],"mappings":";;;;;;;AAkCO,MAAM,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ACR;AACA,WAAO,UAAU,OAAO,YAAA;AAAA,EACzB;AAAA,EAEA,YAAY;AACX,WAAOK,gBAAAA,gBAAgB,KAAK,KAAK;AAAA,EAClC;AAAA,EAEA,aAAa,OAAe;AAC3B,UAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK;AAChD,WAAO;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IAAA;AAAA,EAExB;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(''\n\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(''\n\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t+ 'Provided parameters:\\n'\n\t\t\t+ JSON.stringify(relationParams)\n\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAkCO,MAAM,mBAA6C;AAAA,EAGlD,YACW,OACA,YACA,WACR,KACA,MACQ,WACA,gBACR,uBACA,QACA,aACA,aACR;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACR,SAAA,MAAA;AACA,SAAA,OAAA;AACQ,SAAA,YAAA;AACA,SAAA,iBAAA;AACR,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAbV,kBAAA,MAAgB,UAAS,gBAAA;AAAA,EAAA;AAAA,EAiBzB,IAAI,aAAmC;AACtC,WAAO,KAAK,UAAU,iBAAiB,KAAK,UAAU,QAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAM/D,IAAI,KAAe;AAClB,WAAO,KAAK,UAAU;AAAA,EAAA;AAAA,EAGvB,IAAI,iBAA0B;AAC7B,WAAO,KAAK,UAAU;AAAA,EAAA;AAAA;AAAA,EAKvB,SAAS,OAAiD;AAClD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAAA;AAAA,EAGhF,iBACC,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAGpE,aAAa,gBAA0D;AACtE,SAAK,WAAW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B;AAAA,EAAA;AAAA,EAGnC,iBACP,SACA,mBACA,WACoB;AACpB,WAAO,MAAM,KAAK,QAAQ,OAAA,CAAQ,EAChC,OAAO,CAAC,OAA+B,cAAc,qBAAsB,GAAG,WAAW,UAAU,SAAS;AAAA,EAAA;AAAA,EAG/G,YAA6D;AACtD,UAAA,YAAY,KAAK,MAAM;AACzB,QAAA,UAAU,SAAS,WAAW;AAC1B,aAAA;AAAA,IAAA;AAED,WAAA,UAAU,OAAO,YAAY;AAAA,EAAA;AAAA,EAGrC,YAAY;AACJ,WAAA,gBAAgB,KAAK,KAAK;AAAA,EAAA;AAAA,EAGlC,aAAa,OAAe;AAC3B,UAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK;AACzC,WAAA;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IACvB;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"EntityAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t\t+ 'Provided parameters:\\n'\n\t\t\t\t+ JSON.stringify(relationParams)\n\t\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAkCO,MAAM,mBAA6C;AAAA,EAGlD,YACW,OACA,YACA,WACR,KACA,MACQ,WACA,gBACR,uBACA,QACA,aACA,aACR;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACR,SAAA,MAAA;AACA,SAAA,OAAA;AACQ,SAAA,YAAA;AACA,SAAA,iBAAA;AACR,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAbV,kBAAA,MAAgB,UAAS,gBAAA;AAAA,EAezB;AAAA,EAEA,IAAI,aAAmC;AACtC,WAAO,KAAK,UAAU,iBAAiB,KAAK,UAAU,QAAQ;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,KAAe;AAClB,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,EAEA,IAAI,iBAA0B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L;AAAA,EAEQ,kBAAkB,QAAuB;AAChD,QAAI,OAAO,WAAW,GAAG;AACxB,aAAO;AAAA,IACR;AAEA,UAAM,mBAAmB,OAAO,IAAI,CAAA,OAAM,KAAK,UAAU,EAAE,CAAC,EAAE,KAAK,IAAI;AACvE,UAAM,UAAU,OAAO,WAAW,IAC/B,4FACA;AAEH,WAAO;AAAA;AAAA,EAAO,OAAO;AAAA,EAAK,gBAAgB;AAAA,EAC3C;AAAA,EAEQ,iBACP,SACA,mBACA,WACoB;AACpB,WAAO,MAAM,KAAK,QAAQ,OAAA,CAAQ,EAChC,OAAO,CAAC,OAA+B,cAAc,qBAAsB,GAAG,WAAW,UAAU,SAAS;AAAA,EAC/G;AAAA,EAEA,YAA6D;AAC5D,UAAM,YAAY,KAAK,MAAM;AAC7B,QAAI,UAAU,SAAS,WAAW;AACjC,aAAO;AAAA,IACR;AACA,WAAO,UAAU,OAAO,YAAA;AAAA,EACzB;AAAA,EAEA,YAAY;AACX,WAAO,gBAAgB,KAAK,KAAK;AAAA,EAClC;AAAA,EAEA,aAAa,OAAe;AAC3B,UAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK;AAChD,WAAO;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IAAA;AAAA,EAExB;AACD;"}
@@ -28,7 +28,7 @@ class EntityListAccessorImpl {
28
28
  }
29
29
  }
30
30
  *ids() {
31
- return this._children.keys();
31
+ yield* this._children.keys();
32
32
  }
33
33
  /**
34
34
  * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state'\nimport type { ListOperations } from '../core/operations'\nimport { EntityAccessor, EntityId, EntityListSubTreeMarker, EntityName, EntityRealmKey, Environment, ErrorAccessor,\n\tHasManyRelationMarker, RuntimeId } from '@contember/binding-common'\nimport { EntityListAccessor } from '@contember/binding-common'\n\nexport class EntityListAccessorImpl implements EntityListAccessor {\n\tpublic readonly __type = 'EntityListAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {\n\t}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic* keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key!\n\t\t}\n\t}\n\n\tpublic* ids(): IterableIterator<EntityId> {\n\t\treturn this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic* [Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n\n\tpublic getParent(): EntityAccessor | undefined {\n\t\treturn this.state.blueprint.parent?.getAccessor()\n\t}\n\n\tpublic getMarker(): EntityListSubTreeMarker | HasManyRelationMarker {\n\t\treturn this.state.blueprint.marker\n\t}\n}\n"],"names":["ErrorAccessor"],"mappings":";;;;;;AAMO,MAAM,uBAAqD;AAAA,EAG1D,YACW,OACA,YACD,MACC,WACA,uBACD,uBACA,QACA,aACA,aACf;AATgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAXjB,kBAAA,MAAiB,UAAS,oBAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB1B,CAAQ,OAAyC;AAChD,eAAW,YAAY,MAAM;AAC5B,YAAM,SAAS;AAAA,IAAA;AAAA,EAChB;AAAA,EAGD,CAAQ,MAAkC;AAClC,WAAA,KAAK,UAAU,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO5B,IAAW,uBAAsC;AACzC,WAAA,IAAI,IAAI,KAAK,qBAAqB;AAAA,EAAA;AAAA,EAG1C,EAAS,OAAO,QAAQ,IAAsC;AAC7D,eAAW,EAAE,YAAY,KAAK,KAAK,UAAU,UAAU;AACtD,YAAM,YAAY;AAAA,IAAA;AAAA,EACnB;AAAA,EAGM,YAAY,IAAuB;AAClC,WAAA,KAAK,UAAU,IAAI,EAAE;AAAA,EAAA;AAAA,EAGtB,UAAmB;AACzB,WAAO,KAAK,WAAW;AAAA,EAAA;AAAA,EAGxB,IAAW,SAAiB;AAC3B,WAAO,KAAK,UAAU;AAAA,EAAA;AAAA,EAGhB,kBAAkB,eAAmD;AAC3E,QAAI,OAAO,kBAAkB,YAAY,OAAO,kBAAkB,UAAU;AACpE,aAAA,KAA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AAE;AAAA,EAAA;AAAA,EAGlD,YAAwC;AAC9C,WAAO,KAAK,MAAM,UAAU,QAAQ,YAAY;AAAA,EAAA;AAAA,EAG1C,YAA6D;AAC5D,WAAA,KAAK,MAAM,UAAU;AAAA,EAAA;AAE9B;;"}
1
+ {"version":3,"file":"EntityListAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state'\nimport type { ListOperations } from '../core/operations'\nimport {\n\tEntityAccessor,\n\tEntityId,\n\tEntityListSubTreeMarker,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasManyRelationMarker,\n\tRuntimeId,\n} from '@contember/binding-common'\nimport { EntityListAccessor } from '@contember/binding-common'\n\nexport class EntityListAccessorImpl implements EntityListAccessor {\n\tpublic readonly __type = 'EntityListAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {\n\t}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic *keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key!\n\t\t}\n\t}\n\n\tpublic *ids(): IterableIterator<EntityId> {\n\t\tyield* this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n\n\tpublic getParent(): EntityAccessor | undefined {\n\t\treturn this.state.blueprint.parent?.getAccessor()\n\t}\n\n\tpublic getMarker(): EntityListSubTreeMarker | HasManyRelationMarker {\n\t\treturn this.state.blueprint.marker\n\t}\n}\n"],"names":["ErrorAccessor"],"mappings":";;;;;;AAeO,MAAM,uBAAqD;AAAA,EAG1D,YACW,OACA,YACD,MACC,WACA,uBACD,uBACA,QACA,aACA,aACf;AATgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAXjB,kBAAA,MAAgB,UAAS,oBAAA;AAAA,EAazB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,CAAQ,OAAyC;AAChD,eAAW,YAAY,MAAM;AAC5B,YAAM,SAAS;AAAA,IAChB;AAAA,EACD;AAAA,EAEA,CAAQ,MAAkC;AACzC,WAAO,KAAK,UAAU,KAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,uBAAsC;AAChD,WAAO,IAA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AA,EACzE;AAAA,EAEO,aAAa,gBAA8D;AACjF,SAAK,WAAW,aAAa,KAAK,OAAO,cAAc;AAAA,EACxD;AAAA,EAEO,cAAc,iBAAuC;AAC3D,SAAK,WAAW,cAAc,KAAK,OAAO,eAAe;AAAA,EAC1D;AAAA,EAEO,gBAAgB,YAA4D;AAClF,WAAO,KAAK,WAAW,gBAAgB,KAAK,OAAO,UAAU;AAAA,EAC9D;AAAA,EAEO,iBAAiB,aAA6B,UAAmC,IAAU;AACjG,SAAK,WAAW,iBAAiB,KAAK,OAAO,aAAa,OAAO;AAAA,EAClE;AAAA,EAEO,mBAAmB,IAA8B;AACvD,WAAO,KAAK,WAAW,mBAAmB,KAAK,OAAO,EAAE;AAAA,EACzD;AAAA,EAEO,YAAwC;AAC9C,WAAO,KAAK,MAAM,UAAU,QAAQ,YAAA;AAAA,EACrC;AAAA,EAEO,YAA6D;AACnE,WAAO,KAAK,MAAM,UAAU;AAAA,EAC7B;AACD;;"}
@@ -26,7 +26,7 @@ class EntityListAccessorImpl {
26
26
  }
27
27
  }
28
28
  *ids() {
29
- return this._children.keys();
29
+ yield* this._children.keys();
30
30
  }
31
31
  /**
32
32
  * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state'\nimport type { ListOperations } from '../core/operations'\nimport { EntityAccessor, EntityId, EntityListSubTreeMarker, EntityName, EntityRealmKey, Environment, ErrorAccessor,\n\tHasManyRelationMarker, RuntimeId } from '@contember/binding-common'\nimport { EntityListAccessor } from '@contember/binding-common'\n\nexport class EntityListAccessorImpl implements EntityListAccessor {\n\tpublic readonly __type = 'EntityListAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {\n\t}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic* keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key!\n\t\t}\n\t}\n\n\tpublic* ids(): IterableIterator<EntityId> {\n\t\treturn this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic* [Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n\n\tpublic getParent(): EntityAccessor | undefined {\n\t\treturn this.state.blueprint.parent?.getAccessor()\n\t}\n\n\tpublic getMarker(): EntityListSubTreeMarker | HasManyRelationMarker {\n\t\treturn this.state.blueprint.marker\n\t}\n}\n"],"names":[],"mappings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/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state'\nimport type { ListOperations } from '../core/operations'\nimport {\n\tEntityAccessor,\n\tEntityId,\n\tEntityListSubTreeMarker,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasManyRelationMarker,\n\tRuntimeId,\n} from '@contember/binding-common'\nimport { EntityListAccessor } from '@contember/binding-common'\n\nexport class EntityListAccessorImpl implements EntityListAccessor {\n\tpublic readonly __type = 'EntityListAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {\n\t}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic *keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key!\n\t\t}\n\t}\n\n\tpublic *ids(): IterableIterator<EntityId> {\n\t\tyield* this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n\n\tpublic getParent(): EntityAccessor | undefined {\n\t\treturn this.state.blueprint.parent?.getAccessor()\n\t}\n\n\tpublic getMarker(): EntityListSubTreeMarker | HasManyRelationMarker {\n\t\treturn this.state.blueprint.marker\n\t}\n}\n"],"names":[],"mappings":";;;;AAeO,MAAM,uBAAqD;AAAA,EAG1D,YACW,OACA,YACD,MACC,WACA,uBACD,uBACA,QACA,aACA,aACf;AATgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAXjB,kBAAA,MAAgB,UAAS,oBAAA;AAAA,EAazB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,CAAQ,OAAyC;AAChD,eAAW,YAAY,MAAM;AAC5B,YAAM,SAAS;AAAA,IAChB;AAAA,EACD;AAAA,EAEA,CAAQ,MAAkC;AACzC,WAAO,KAAK,UAAU,KAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,uBAAsC;AAChD,WAAO,IAAI,IAAI,KAAK,qBAAqB;AAAA,EAC1C;AAAA,EAEA,EAAS,OAAO,QAAQ,IAAsC;AAC7D,eAAW,EAAE,YAAA,KAAiB,KAAK,UAAU,UAAU;AACtD,YAAM,YAAA;AAAA,IACP;AAAA,EACD;AAAA,EAEO,YAAY,IAAuB;AACzC,WAAO,KAAK,UAAU,IAAI,EAAE;AAAA,EAC7B;AAA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AAAA,EAC9D;AAAA,EAEO,iBAAiB,aAA6B,UAAmC,IAAU;AACjG,SAAK,WAAW,iBAAiB,KAAK,OAAO,aAAa,OAAO;AAAA,EAClE;AAAA,EAEO,mBAAmB,IAA8B;AACvD,WAAO,KAAK,WAAW,mBAAmB,KAAK,OAAO,EAAE;AAAA,EACzD;AAAA,EAEO,YAAwC;AAC9C,WAAO,KAAK,MAAM,UAAU,QAAQ,YAAA;AAAA,EACrC;AAAA,EAEO,YAA6D;AACnE,WAAO,KAAK,MAAM,UAAU;AAAA,EAC7B;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":["ErrorAccessor","TemporalFieldHelper","UuidFieldHelper"],"mappings":";;;;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAAA;AAAA,EAiBlB,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAc,cAAA,eAAe,KAAK,CAAC;AAAA,EAAA;AAAA,EAGzE,cAAoB;AACrB,SAAA,WAAW,YAAY,KAAK,KAAK;AAAA,EAAA;AAAA,EAGhC,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAG7D,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAAA;AAAA,EAGnD,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EAAA;AAAA,EAGrC,IAAW,YAAY;AACf,WAAA,KAAK,YAAY,MAAM;AAAA,EAAA;AAAA;AAAA,EAK/B,IAAW,aAAkC;AACrC,WAAA,IAAIC,oBAAAA,oBAAoB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAGvF,IAAW,SAA0B;AAC7B,WAAA,IAAIC,gBAAAA,gBAAgB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAG5E,YAA4B;AAC3B,WAAA,KAAK,MAAM,OAAO,YAAY;AAAA,EAAA;AAEvC;;"}
1
+ {"version":3,"file":"FieldAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":["ErrorAccessor","TemporalFieldHelper","UuidFieldHelper"],"mappings":";;;;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAezB;AAAA,EAEO,SAAS,OAAiD;AAChE,WAAO,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAAA,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEO,cAAoB;AAC1B,SAAK,WAAW,YAAY,KAAK,KAAK;AAAA,EACvC;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEO,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAC1D;AAAA,EAEO,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EACrC;AAAA,EAEA,IAAW,YAAY;AACtB,WAAO,KAAK,YAAY,MAAM;AAAA,EAC/B;AAAA;AAAA,EAIA,IAAW,aAAkC;AAC5C,WAAO,IAAIC,oBAAAA,oBAAoB,KAAK,WAAkD;AAAA,EACvF;AAAA,EAEA,IAAW,SAA0B;AACpC,WAAO,IAAIC,gBAAAA,gBAAgB,KAAK,WAAkD;AAAA,EACnF;AAAA,EAEO,YAA4B;AAClC,WAAO,KAAK,MAAM,OAAO,YAAA;AAAA,EAC1B;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAAA;AAAA,EAiBlB,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAAA;AAAA,EAGzE,cAAoB;AACrB,SAAA,WAAW,YAAY,KAAK,KAAK;AAAA,EAAA;AAAA,EAGhC,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAG7D,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAAA;AAAA,EAGnD,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EAAA;AAAA,EAGrC,IAAW,YAAY;AACf,WAAA,KAAK,YAAY,MAAM;AAAA,EAAA;AAAA;AAAA,EAK/B,IAAW,aAAkC;AACrC,WAAA,IAAI,oBAAoB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAGvF,IAAW,SAA0B;AAC7B,WAAA,IAAI,gBAAgB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAG5E,YAA4B;AAC3B,WAAA,KAAK,MAAM,OAAO,YAAY;AAAA,EAAA;AAEvC;"}
1
+ {"version":3,"file":"FieldAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAezB;AAAA,EAEO,SAAS,OAAiD;AAChE,WAAO,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEO,cAAoB;AAC1B,SAAK,WAAW,YAAY,KAAK,KAAK;AAAA,EACvC;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEO,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAC1D;AAAA,EAEO,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EACrC;AAAA,EAEA,IAAW,YAAY;AACtB,WAAO,KAAK,YAAY,MAAM;AAAA,EAC/B;AAAA;AAAA,EAIA,IAAW,aAAkC;AAC5C,WAAO,IAAI,oBAAoB,KAAK,WAAkD;AAAA,EACvF;AAAA,EAEA,IAAW,SAA0B;AACpC,WAAO,IAAI,gBAAgB,KAAK,WAAkD;AAAA,EACnF;AAAA,EAEO,YAA4B;AAClC,WAAO,KAAK,MAAM,OAAO,YAAA;AAAA,EAC1B;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AccessorErrorManager.cjs","sources":["../../../../../packages/binding-legacy/src/core/AccessorErrorManager.ts"],"sourcesContent":["import { ErrorAccessor } from '@contember/binding-common'\nimport { ErrorsPreprocessor } from './ErrorsPreprocessor'\nimport { EventManager } from './EventManager'\nimport { EntityListState, EntityRealmState, getEntityMarker, StateNode } from './state'\nimport type { TreeStore } from './TreeStore'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { MutationError, ValidationError } from '@contember/client'\n\nexport class AccessorErrorManager {\n\tprivate errorsByState: Map<StateNode, ErrorAccessor.ErrorsById> = new Map()\n\n\tprivate getNewErrorId = (() => {\n\t\tlet errorId = 1\n\n\t\treturn () => errorId++\n\t})()\n\n\tpublic constructor(private readonly eventManager: EventManager, private readonly treeStore: TreeStore) {}\n\n\tpublic hasErrors() {\n\t\treturn !!this.errorsByState.size\n\t}\n\n\tpublic getErrors(): ErrorAccessor.Error[] {\n\t\treturn Array.from(this.errorsByState.values(), it => Array.from(it.values())).flat()\n\t}\n\n\tpublic clearErrors() {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tfor (const [stateNode] of this.errorsByState) {\n\t\t\t\tstateNode.errors = undefined\n\t\t\t\tthis.eventManager.registerJustUpdated(stateNode, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\tthis.errorsByState.clear()\n\t\t})\n\t}\n\n\tpublic clearErrorsByState(state: StateNode): void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tif (!this.errorsByState.has(state)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errorsByState.delete(state)\n\t\t\tstate.errors = undefined\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t})\n\t}\n\n\tpublic replaceErrors(data: DataBindingTransactionResult, operations: SubMutationOperation[]) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.clearErrors()\n\n\t\t\tconst preprocessor = new ErrorsPreprocessor(data, operations)\n\t\t\tconst errorTreeRoot = preprocessor.preprocess()\n\n\t\t\tthis.setRootStateErrors(errorTreeRoot)\n\n\t\t\tthis.dumpErrorData(data)\n\t\t})\n\t}\n\n\tpublic addError(state: StateNode, error: ErrorAccessor.Error): () => void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tconst errorId = this.getNewErrorId()\n\n\t\t\tlet errorsById: ErrorAccessor.ErrorsById | undefined = this.errorsByState.get(state)\n\t\t\tif (errorsById === undefined) {\n\t\t\t\tthis.errorsByState.set(state, (errorsById = new Map()))\n\t\t\t}\n\t\t\terrorsById.set(errorId, error)\n\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\n\t\t\treturn () =>\n\t\t\t\tthis.eventManager.syncOperation(() => {\n\t\t\t\t\tconst errorsById = this.errorsByState.get(state)\n\t\t\t\t\tif (errorsById === undefined) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terrorsById.delete(errorId)\n\t\t\t\t\tif (errorsById.size) {\n\t\t\t\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.errors = undefined\n\t\t\t\t\t\tthis.errorsByState.delete(state)\n\t\t\t\t\t}\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t})\n\t\t})\n\t}\n\n\tprivate addSeveralErrors(state: StateNode, errors: ErrorsPreprocessor.BaseErrorNode) {\n\t\tif (errors.validation) {\n\t\t\tfor (const error of errors.validation) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t\tif (errors.execution) {\n\t\t\tfor (const error of errors.execution) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setRootStateErrors(errorTreeRoot: ErrorsPreprocessor.ErrorTreeRoot) {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [subTreePlaceholder, rootError] of errorTreeRoot) {\n\t\t\t\tconst rootState = rootStates.get(subTreePlaceholder)\n\n\t\t\t\tif (!rootState) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (rootState.type) {\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tthis.setEntityStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tthis.setEntityListStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityStateErrors(\n\t\tstate: EntityRealmState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, child] of errors.children) {\n\t\t\tif (typeof childKey !== 'string') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.nodeType === 'leaf') {\n\t\t\t\tconst fieldState = state.children.get(childKey)\n\n\t\t\t\tif (fieldState?.type === 'field') {\n\t\t\t\t\tthis.addSeveralErrors(fieldState, child)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Deliberately letting flow get here as well. Leaf errors *CAN* refer to relations as well.\n\n\t\t\tconst fields = getEntityMarker(state).fields\n\t\t\tconst placeholders = fields.placeholders.get(childKey)\n\t\t\tif (placeholders === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst normalizedPlaceholders = typeof placeholders === 'string' ? new Set([placeholders]) : placeholders\n\n\t\t\tfor (const normalizedPlaceholder of normalizedPlaceholders) {\n\t\t\t\tconst fieldState = state.children.get(normalizedPlaceholder)\n\t\t\t\tif (fieldState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\t// unwrap for reduced has many\n\t\t\t\t\t\tif (child.nodeType === 'iNode' && child.children.has(fieldState.entity.id.value)) {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child.children.get(fieldState.entity.id.value)!)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\tthis.setEntityListStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityListStateErrors(\n\t\tstate: EntityListState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, childError] of errors.children) {\n\t\t\tlet childState = state.children.get(childKey)\n\n\t\t\tif (childState === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\tchildState.getAccessor() // Force init\n\t\t\t\tchildState = state.children.get(childKey)!\n\t\t\t}\n\n\t\t\tif (childError.nodeType === 'iNode') {\n\t\t\t\tthis.setEntityStateErrors(childState as EntityRealmState, childError)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dumpErrorData(data: DataBindingTransactionResult) {\n\t\t// TODO this is just temporary\n\t\tfor (const subTreePlaceholder in data.data) {\n\t\t\tconst treeDatum = data.data[subTreePlaceholder]\n\t\t\tconst executionErrors: Array<MutationError | ValidationError> = treeDatum.errors\n\t\t\tconst allErrors = treeDatum?.validation?.errors\n\t\t\t\t? executionErrors.concat(treeDatum.validation.errors)\n\t\t\t\t: executionErrors\n\t\t\tconst normalizedErrors = allErrors.map((error: MutationError | ValidationError) => {\n\t\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\t\t\treturn {\n\t\t\t\t\tpath: path\n\t\t\t\t\t\t.map(pathPart => {\n\t\t\t\t\t\t\tif ('field' in pathPart) {\n\t\t\t\t\t\t\t\treturn pathPart.field\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (pathPart.alias) {\n\t\t\t\t\t\t\t\treturn `#${pathPart.index}(${pathPart.alias})`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn pathPart.index\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('.'),\n\t\t\t\t\ttype: 'type' in error ? error.type : undefined,\n\t\t\t\t\tmessage: typeof error.message === 'string' ? error.message : error.message?.text,\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (Object.keys(normalizedErrors).length) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.table(normalizedErrors)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["EventManager","ErrorsPreprocessor","errorsById","getEntityMarker"],"mappings":";;;;;;;;AASO,MAAM,qBAAqB;AAAA,EAS1B,YAA6B,cAA6C,WAAsB;AAAnE,SAAA,eAAA;AAA6C,SAAA,YAAA;AARzE,kBAAA,MAAA,qCAA8D,IAAI,CAAA;AAE1E,kBAAA,MAAQ,iBAAuB,uBAAA;AAC9B,UAAI,UAAU;AAEd,aAAO,MAAM;AAAA,IAAA,IACX;AAAA,EAAA;AAAA,EAII,YAAY;AACX,WAAA,CAAC,CAAC,KAAK,cAAc;AAAA,EAAA;AAAA,EAGtB,YAAmC;AACzC,WAAO,MAAM,KAAK,KAAK,cAAc,UAAU,CAAA,OAAM,MAAM,KAAK,GAAG,OAAA,CAAQ,CAAC,EAAE,KAAK;AAAA,EAAA;AAAA,EAG7E,cAAc;AACf,SAAA,aAAa,cAAc,MAAM;AACrC,iBAAW,CAAC,SAAS,KAAK,KAAK,eAAe;AAC7C,kBAAU,SAAS;AACnB,aAAK,aAAa,oBAAoB,WAAWA,aAAAA,aAAa,qBAA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kBAAkB;AAC9C,YAAM,kBAA0D,UAAU;AACpE,YAAA,YAAY,WAAW,YAAY,SACtC,gBAAgB,OAAO,UAAU,WAAW,MAAM,IAClD;AACH,YAAM,mBAAmB,UAAU,IAAI,CAAC,UAA2C;AAC5E,cAAA,OAAO,WAAW,QAAS,MAAM,MAAM,CAAC,KAAK,KAAM,MAAM;AACxD,eAAA;AAAA,UACN,MAAM,KACJ,IAAI,CAAY,aAAA;AAChB,gBAAI,WAAW,UAAU;AACxB,qBAAO,SAAS;AAAA,YAAA;AAEjB,gBAAI,SAAS,OAAO;AACnB,qBAAO,IAAI,SAAS,KAAK,IAAI,SAAS,KAAK;AAAA,YAAA;AAE5C,mBAAO,SAAS;AAAA,UAAA,CAChB,EACA,KAAK,GAAG;AAAA,UACV,MAAM,UAAU,QAAQ,MAAM,OAAO;AAAA,UACrC,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,UAAU,MAAM,SAAS;AAAA,QAC7E;AAAA,MAAA,CACA;AACD,UAAI,OAAO,KAAK,gBAAgB,EAAE,QAAQ;AAEzC,gBAAQ,MAAM,gBAAgB;AAAA,MAAA;AAAA,IAC/B;AAAA,EACD;AAEF;;"}
1
+ {"version":3,"file":"AccessorErrorManager.cjs","sources":["../../../../../packages/binding-legacy/src/core/AccessorErrorManager.ts"],"sourcesContent":["import { ErrorAccessor } from '@contember/binding-common'\nimport { ErrorsPreprocessor } from './ErrorsPreprocessor'\nimport { EventManager } from './EventManager'\nimport { EntityListState, EntityRealmState, getEntityMarker, StateNode } from './state'\nimport type { TreeStore } from './TreeStore'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { MutationError, ValidationError } from '@contember/client'\n\nexport class AccessorErrorManager {\n\tprivate errorsByState: Map<StateNode, ErrorAccessor.ErrorsById> = new Map()\n\n\tprivate getNewErrorId = (() => {\n\t\tlet errorId = 1\n\n\t\treturn () => errorId++\n\t})()\n\n\tpublic constructor(private readonly eventManager: EventManager, private readonly treeStore: TreeStore) {}\n\n\tpublic hasErrors() {\n\t\treturn !!this.errorsByState.size\n\t}\n\n\tpublic getErrors(): ErrorAccessor.Error[] {\n\t\treturn Array.from(this.errorsByState.values(), it => Array.from(it.values())).flat()\n\t}\n\n\tpublic clearErrors() {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tfor (const [stateNode] of this.errorsByState) {\n\t\t\t\tstateNode.errors = undefined\n\t\t\t\tthis.eventManager.registerJustUpdated(stateNode, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\tthis.errorsByState.clear()\n\t\t})\n\t}\n\n\tpublic clearErrorsByState(state: StateNode): void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tif (!this.errorsByState.has(state)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errorsByState.delete(state)\n\t\t\tstate.errors = undefined\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t})\n\t}\n\n\tpublic replaceErrors(data: DataBindingTransactionResult, operations: SubMutationOperation[]) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.clearErrors()\n\n\t\t\tconst preprocessor = new ErrorsPreprocessor(data, operations)\n\t\t\tconst errorTreeRoot = preprocessor.preprocess()\n\n\t\t\tthis.setRootStateErrors(errorTreeRoot)\n\n\t\t\tthis.dumpErrorData(data)\n\t\t})\n\t}\n\n\tpublic addError(state: StateNode, error: ErrorAccessor.Error): () => void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tconst errorId = this.getNewErrorId()\n\n\t\t\tlet errorsById: ErrorAccessor.ErrorsById | undefined = this.errorsByState.get(state)\n\t\t\tif (errorsById === undefined) {\n\t\t\t\tthis.errorsByState.set(state, errorsById = new Map())\n\t\t\t}\n\t\t\terrorsById.set(errorId, error)\n\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\n\t\t\treturn () =>\n\t\t\t\tthis.eventManager.syncOperation(() => {\n\t\t\t\t\tconst errorsById = this.errorsByState.get(state)\n\t\t\t\t\tif (errorsById === undefined) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terrorsById.delete(errorId)\n\t\t\t\t\tif (errorsById.size) {\n\t\t\t\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.errors = undefined\n\t\t\t\t\t\tthis.errorsByState.delete(state)\n\t\t\t\t\t}\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t})\n\t\t})\n\t}\n\n\tprivate addSeveralErrors(state: StateNode, errors: ErrorsPreprocessor.BaseErrorNode) {\n\t\tif (errors.validation) {\n\t\t\tfor (const error of errors.validation) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t\tif (errors.execution) {\n\t\t\tfor (const error of errors.execution) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setRootStateErrors(errorTreeRoot: ErrorsPreprocessor.ErrorTreeRoot) {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [subTreePlaceholder, rootError] of errorTreeRoot) {\n\t\t\t\tconst rootState = rootStates.get(subTreePlaceholder)\n\n\t\t\t\tif (!rootState) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (rootState.type) {\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tthis.setEntityStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tthis.setEntityListStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityStateErrors(\n\t\tstate: EntityRealmState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, child] of errors.children) {\n\t\t\tif (typeof childKey !== 'string') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.nodeType === 'leaf') {\n\t\t\t\tconst fieldState = state.children.get(childKey)\n\n\t\t\t\tif (fieldState?.type === 'field') {\n\t\t\t\t\tthis.addSeveralErrors(fieldState, child)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Deliberately letting flow get here as well. Leaf errors *CAN* refer to relations as well.\n\n\t\t\tconst fields = getEntityMarker(state).fields\n\t\t\tconst placeholders = fields.placeholders.get(childKey)\n\t\t\tif (placeholders === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst normalizedPlaceholders = typeof placeholders === 'string' ? new Set([placeholders]) : placeholders\n\n\t\t\tfor (const normalizedPlaceholder of normalizedPlaceholders) {\n\t\t\t\tconst fieldState = state.children.get(normalizedPlaceholder)\n\t\t\t\tif (fieldState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\t// unwrap for reduced has many\n\t\t\t\t\t\tif (child.nodeType === 'iNode' && child.children.has(fieldState.entity.id.value)) {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child.children.get(fieldState.entity.id.value)!)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\tthis.setEntityListStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityListStateErrors(\n\t\tstate: EntityListState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, childError] of errors.children) {\n\t\t\tlet childState = state.children.get(childKey)\n\n\t\t\tif (childState === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\tchildState.getAccessor() // Force init\n\t\t\t\tchildState = state.children.get(childKey)!\n\t\t\t}\n\n\t\t\tif (childError.nodeType === 'iNode') {\n\t\t\t\tthis.setEntityStateErrors(childState as EntityRealmState, childError)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dumpErrorData(data: DataBindingTransactionResult) {\n\t\t// TODO this is just temporary\n\t\tfor (const subTreePlaceholder in data.data) {\n\t\t\tconst treeDatum = data.data[subTreePlaceholder]\n\t\t\tconst executionErrors: Array<MutationError | ValidationError> = treeDatum.errors\n\t\t\tconst allErrors = treeDatum?.validation?.errors\n\t\t\t\t? executionErrors.concat(treeDatum.validation.errors)\n\t\t\t\t: executionErrors\n\t\t\tconst normalizedErrors = allErrors.map((error: MutationError | ValidationError) => {\n\t\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\t\t\treturn {\n\t\t\t\t\tpath: path\n\t\t\t\t\t\t.map(pathPart => {\n\t\t\t\t\t\t\tif ('field' in pathPart) {\n\t\t\t\t\t\t\t\treturn pathPart.field\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (pathPart.alias) {\n\t\t\t\t\t\t\t\treturn `#${pathPart.index}(${pathPart.alias})`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn pathPart.index\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('.'),\n\t\t\t\t\ttype: 'type' in error ? error.type : undefined,\n\t\t\t\t\tmessage: typeof error.message === 'string' ? error.message : error.message?.text,\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (Object.keys(normalizedErrors).length) {\n\t\t\t\t// biome-ignore lint/suspicious/noConsole: debug output\n\t\t\t\tconsole.table(normalizedErrors)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["EventManager","ErrorsPreprocessor","errorsById","getEntityMarker"],"mappings":";;;;;;;;AASO,MAAM,qBAAqB;AAAA,EAS1B,YAA6B,cAA6C,WAAsB;AAAnE,SAAA,eAAA;AAA6C,SAAA,YAAA;AARjF,kBAAA,MAAQ,qCAA8D,IAAA,CAAI;AAE1E,kBAAA,MAAQ,iBAAiB,uBAAM;AAC9B,UAAI,UAAU;AAEd,aAAO,MAAM;AAAA,IACd,IAAG;AAAA,EAEqG;AAAA,EAEjG,YAAY;AAClB,WAAO,CAAC,CAAC,KAAK,cAAc;AAAA,EAC7B;AAAA,EAEO,YAAmC;AACzC,WAAO,MAAM,KAAK,KAAK,cAAc,UAAU,CAAA,OAAM,MAAM,KAAK,GAAG,OAAA,CAAQ,CAAC,EAAE,KAAA;AAAA,EAC/E;AAAA,EAEO,cAAc;AACpB,SAAK,aAAa,cAAc,MAAM;AACrC,iBAAW,CAAC,SAAS,KAAK,KAAK,eAAe;AAC7C,kBAAU,SAAS;AACnB,aAAK,aAAa,oBAAoB,WAAWA,aAAAA,aAAa,qBAAqB;AAAA,MACpF;AACA,WAAK,cAAc,MAAA;AAAA,IACpB,CAAC;AAAA,EACF;AAAA,EAEO,mBAAmB,OAAwB;AACjD,WAAO,KAAK,aAAa,cAAc,MAAM;AAC5C,UAAI,CAAC,KAAK,cAAc,IAAI,KAAK,GAAG;AACnC;AAAA,MACD;AACA,WAAK,cAAc,OAAO,KAAK;AAC/B,YAAM,SAAS;AACf,WAAK,aAAa,oBAAoB,OAAOA,aAAAA,aAAa,qBAAqB;AAAA,IAChF,CAAC;AAAA,EACF;AAAA,EAEO,cAAc,MAAoC,YAAoC;AA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AAI,SAAS,KAAK;AAAA,YAC5C;AACA,mBAAO,SAAS;AAAA,UACjB,CAAC,EACA,KAAK,GAAG;AAAA,UACV,MAAM,UAAU,QAAQ,MAAM,OAAO;AAAA,UACrC,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,UAAU,MAAM,SAAS;AAAA,QAAA;AAAA,MAE9E,CAAC;AACD,UAAI,OAAO,KAAK,gBAAgB,EAAE,QAAQ;AAEzC,gBAAQ,MAAM,gBAAgB;AAAA,MAC/B;AAAA,IACD;AAAA,EACD;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AccessorErrorManager.js","sources":["../../../../../packages/binding-legacy/src/core/AccessorErrorManager.ts"],"sourcesContent":["import { ErrorAccessor } from '@contember/binding-common'\nimport { ErrorsPreprocessor } from './ErrorsPreprocessor'\nimport { EventManager } from './EventManager'\nimport { EntityListState, EntityRealmState, getEntityMarker, StateNode } from './state'\nimport type { TreeStore } from './TreeStore'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { MutationError, ValidationError } from '@contember/client'\n\nexport class AccessorErrorManager {\n\tprivate errorsByState: Map<StateNode, ErrorAccessor.ErrorsById> = new Map()\n\n\tprivate getNewErrorId = (() => {\n\t\tlet errorId = 1\n\n\t\treturn () => errorId++\n\t})()\n\n\tpublic constructor(private readonly eventManager: EventManager, private readonly treeStore: TreeStore) {}\n\n\tpublic hasErrors() {\n\t\treturn !!this.errorsByState.size\n\t}\n\n\tpublic getErrors(): ErrorAccessor.Error[] {\n\t\treturn Array.from(this.errorsByState.values(), it => Array.from(it.values())).flat()\n\t}\n\n\tpublic clearErrors() {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tfor (const [stateNode] of this.errorsByState) {\n\t\t\t\tstateNode.errors = undefined\n\t\t\t\tthis.eventManager.registerJustUpdated(stateNode, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\tthis.errorsByState.clear()\n\t\t})\n\t}\n\n\tpublic clearErrorsByState(state: StateNode): void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tif (!this.errorsByState.has(state)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errorsByState.delete(state)\n\t\t\tstate.errors = undefined\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t})\n\t}\n\n\tpublic replaceErrors(data: DataBindingTransactionResult, operations: SubMutationOperation[]) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.clearErrors()\n\n\t\t\tconst preprocessor = new ErrorsPreprocessor(data, operations)\n\t\t\tconst errorTreeRoot = preprocessor.preprocess()\n\n\t\t\tthis.setRootStateErrors(errorTreeRoot)\n\n\t\t\tthis.dumpErrorData(data)\n\t\t})\n\t}\n\n\tpublic addError(state: StateNode, error: ErrorAccessor.Error): () => void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tconst errorId = this.getNewErrorId()\n\n\t\t\tlet errorsById: ErrorAccessor.ErrorsById | undefined = this.errorsByState.get(state)\n\t\t\tif (errorsById === undefined) {\n\t\t\t\tthis.errorsByState.set(state, (errorsById = new Map()))\n\t\t\t}\n\t\t\terrorsById.set(errorId, error)\n\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\n\t\t\treturn () =>\n\t\t\t\tthis.eventManager.syncOperation(() => {\n\t\t\t\t\tconst errorsById = this.errorsByState.get(state)\n\t\t\t\t\tif (errorsById === undefined) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terrorsById.delete(errorId)\n\t\t\t\t\tif (errorsById.size) {\n\t\t\t\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.errors = undefined\n\t\t\t\t\t\tthis.errorsByState.delete(state)\n\t\t\t\t\t}\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t})\n\t\t})\n\t}\n\n\tprivate addSeveralErrors(state: StateNode, errors: ErrorsPreprocessor.BaseErrorNode) {\n\t\tif (errors.validation) {\n\t\t\tfor (const error of errors.validation) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t\tif (errors.execution) {\n\t\t\tfor (const error of errors.execution) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setRootStateErrors(errorTreeRoot: ErrorsPreprocessor.ErrorTreeRoot) {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [subTreePlaceholder, rootError] of errorTreeRoot) {\n\t\t\t\tconst rootState = rootStates.get(subTreePlaceholder)\n\n\t\t\t\tif (!rootState) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (rootState.type) {\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tthis.setEntityStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tthis.setEntityListStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityStateErrors(\n\t\tstate: EntityRealmState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, child] of errors.children) {\n\t\t\tif (typeof childKey !== 'string') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.nodeType === 'leaf') {\n\t\t\t\tconst fieldState = state.children.get(childKey)\n\n\t\t\t\tif (fieldState?.type === 'field') {\n\t\t\t\t\tthis.addSeveralErrors(fieldState, child)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Deliberately letting flow get here as well. Leaf errors *CAN* refer to relations as well.\n\n\t\t\tconst fields = getEntityMarker(state).fields\n\t\t\tconst placeholders = fields.placeholders.get(childKey)\n\t\t\tif (placeholders === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst normalizedPlaceholders = typeof placeholders === 'string' ? new Set([placeholders]) : placeholders\n\n\t\t\tfor (const normalizedPlaceholder of normalizedPlaceholders) {\n\t\t\t\tconst fieldState = state.children.get(normalizedPlaceholder)\n\t\t\t\tif (fieldState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\t// unwrap for reduced has many\n\t\t\t\t\t\tif (child.nodeType === 'iNode' && child.children.has(fieldState.entity.id.value)) {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child.children.get(fieldState.entity.id.value)!)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\tthis.setEntityListStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityListStateErrors(\n\t\tstate: EntityListState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, childError] of errors.children) {\n\t\t\tlet childState = state.children.get(childKey)\n\n\t\t\tif (childState === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\tchildState.getAccessor() // Force init\n\t\t\t\tchildState = state.children.get(childKey)!\n\t\t\t}\n\n\t\t\tif (childError.nodeType === 'iNode') {\n\t\t\t\tthis.setEntityStateErrors(childState as EntityRealmState, childError)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dumpErrorData(data: DataBindingTransactionResult) {\n\t\t// TODO this is just temporary\n\t\tfor (const subTreePlaceholder in data.data) {\n\t\t\tconst treeDatum = data.data[subTreePlaceholder]\n\t\t\tconst executionErrors: Array<MutationError | ValidationError> = treeDatum.errors\n\t\t\tconst allErrors = treeDatum?.validation?.errors\n\t\t\t\t? executionErrors.concat(treeDatum.validation.errors)\n\t\t\t\t: executionErrors\n\t\t\tconst normalizedErrors = allErrors.map((error: MutationError | ValidationError) => {\n\t\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\t\t\treturn {\n\t\t\t\t\tpath: path\n\t\t\t\t\t\t.map(pathPart => {\n\t\t\t\t\t\t\tif ('field' in pathPart) {\n\t\t\t\t\t\t\t\treturn pathPart.field\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (pathPart.alias) {\n\t\t\t\t\t\t\t\treturn `#${pathPart.index}(${pathPart.alias})`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn pathPart.index\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('.'),\n\t\t\t\t\ttype: 'type' in error ? error.type : undefined,\n\t\t\t\t\tmessage: typeof error.message === 'string' ? error.message : error.message?.text,\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (Object.keys(normalizedErrors).length) {\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.table(normalizedErrors)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["errorsById"],"mappings":";;;;;;AASO,MAAM,qBAAqB;AAAA,EAS1B,YAA6B,cAA6C,WAAsB;AAAnE,SAAA,eAAA;AAA6C,SAAA,YAAA;AARzE,kBAAA,MAAA,qCAA8D,IAAI,CAAA;AAE1E,kBAAA,MAAQ,iBAAuB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AK,OAAO,UAAU;AACrD,UAAI,aAAa,MAAM,SAAS,IAAI,QAAQ;AAE5C,UAAI,eAAe,QAAW;AAC7B;AAAA,MAAA;AAEG,UAAA,WAAW,SAAS,mBAAmB;AAC1C,mBAAW,YAAY;AACV,qBAAA,MAAM,SAAS,IAAI,QAAQ;AAAA,MAAA;AAGrC,UAAA,WAAW,aAAa,SAAS;AAC/B,aAAA,qBAAqB,YAAgC,UAAU;AAAA,MAAA;AAAA,IACrE;AAAA,EACD;AAAA,EAGO,cAAc,MAAoC;AAE9C,eAAA,sBAAsB,KAAK,MAAM;AACrC,YAAA,YAAY,KAAK,KAAK,kBAAkB;AAC9C,YAAM,kBAA0D,UAAU;AACpE,YAAA,YAAY,WAAW,YAAY,SACtC,gBAAgB,OAAO,UAAU,WAAW,MAAM,IAClD;AACH,YAAM,mBAAmB,UAAU,IAAI,CAAC,UAA2C;AAC5E,cAAA,OAAO,WAAW,QAAS,MAAM,MAAM,CAAC,KAAK,KAAM,MAAM;AACxD,eAAA;AAAA,UACN,MAAM,KACJ,IAAI,CAAY,aAAA;AAChB,gBAAI,WAAW,UAAU;AACxB,qBAAO,SAAS;AAAA,YAAA;AAEjB,gBAAI,SAAS,OAAO;AACnB,qBAAO,IAAI,SAAS,KAAK,IAAI,SAAS,KAAK;AAAA,YAAA;AAE5C,mBAAO,SAAS;AAAA,UAAA,CAChB,EACA,KAAK,GAAG;AAAA,UACV,MAAM,UAAU,QAAQ,MAAM,OAAO;AAAA,UACrC,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,UAAU,MAAM,SAAS;AAAA,QAC7E;AAAA,MAAA,CACA;AACD,UAAI,OAAO,KAAK,gBAAgB,EAAE,QAAQ;AAEzC,gBAAQ,MAAM,gBAAgB;AAAA,MAAA;AAAA,IAC/B;AAAA,EACD;AAEF;"}
1
+ {"version":3,"file":"AccessorErrorManager.js","sources":["../../../../../packages/binding-legacy/src/core/AccessorErrorManager.ts"],"sourcesContent":["import { ErrorAccessor } from '@contember/binding-common'\nimport { ErrorsPreprocessor } from './ErrorsPreprocessor'\nimport { EventManager } from './EventManager'\nimport { EntityListState, EntityRealmState, getEntityMarker, StateNode } from './state'\nimport type { TreeStore } from './TreeStore'\nimport { SubMutationOperation } from './MutationGenerator'\nimport { DataBindingTransactionResult } from '@contember/binding-common'\nimport { MutationError, ValidationError } from '@contember/client'\n\nexport class AccessorErrorManager {\n\tprivate errorsByState: Map<StateNode, ErrorAccessor.ErrorsById> = new Map()\n\n\tprivate getNewErrorId = (() => {\n\t\tlet errorId = 1\n\n\t\treturn () => errorId++\n\t})()\n\n\tpublic constructor(private readonly eventManager: EventManager, private readonly treeStore: TreeStore) {}\n\n\tpublic hasErrors() {\n\t\treturn !!this.errorsByState.size\n\t}\n\n\tpublic getErrors(): ErrorAccessor.Error[] {\n\t\treturn Array.from(this.errorsByState.values(), it => Array.from(it.values())).flat()\n\t}\n\n\tpublic clearErrors() {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tfor (const [stateNode] of this.errorsByState) {\n\t\t\t\tstateNode.errors = undefined\n\t\t\t\tthis.eventManager.registerJustUpdated(stateNode, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\tthis.errorsByState.clear()\n\t\t})\n\t}\n\n\tpublic clearErrorsByState(state: StateNode): void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tif (!this.errorsByState.has(state)) {\n\t\t\t\treturn\n\t\t\t}\n\t\t\tthis.errorsByState.delete(state)\n\t\t\tstate.errors = undefined\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t})\n\t}\n\n\tpublic replaceErrors(data: DataBindingTransactionResult, operations: SubMutationOperation[]) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tthis.clearErrors()\n\n\t\t\tconst preprocessor = new ErrorsPreprocessor(data, operations)\n\t\t\tconst errorTreeRoot = preprocessor.preprocess()\n\n\t\t\tthis.setRootStateErrors(errorTreeRoot)\n\n\t\t\tthis.dumpErrorData(data)\n\t\t})\n\t}\n\n\tpublic addError(state: StateNode, error: ErrorAccessor.Error): () => void {\n\t\treturn this.eventManager.syncOperation(() => {\n\t\t\tconst errorId = this.getNewErrorId()\n\n\t\t\tlet errorsById: ErrorAccessor.ErrorsById | undefined = this.errorsByState.get(state)\n\t\t\tif (errorsById === undefined) {\n\t\t\t\tthis.errorsByState.set(state, errorsById = new Map())\n\t\t\t}\n\t\t\terrorsById.set(errorId, error)\n\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\n\t\t\treturn () =>\n\t\t\t\tthis.eventManager.syncOperation(() => {\n\t\t\t\t\tconst errorsById = this.errorsByState.get(state)\n\t\t\t\t\tif (errorsById === undefined) {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terrorsById.delete(errorId)\n\t\t\t\t\tif (errorsById.size) {\n\t\t\t\t\t\tstate.errors = { errors: Array.from(errorsById.values()) }\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate.errors = undefined\n\t\t\t\t\t\tthis.errorsByState.delete(state)\n\t\t\t\t\t}\n\t\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t\t})\n\t\t})\n\t}\n\n\tprivate addSeveralErrors(state: StateNode, errors: ErrorsPreprocessor.BaseErrorNode) {\n\t\tif (errors.validation) {\n\t\t\tfor (const error of errors.validation) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t\tif (errors.execution) {\n\t\t\tfor (const error of errors.execution) {\n\t\t\t\tthis.addError(state, error)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setRootStateErrors(errorTreeRoot: ErrorsPreprocessor.ErrorTreeRoot) {\n\t\tfor (const rootStates of this.treeStore.subTreeStatesByRoot.values()) {\n\t\t\tfor (const [subTreePlaceholder, rootError] of errorTreeRoot) {\n\t\t\t\tconst rootState = rootStates.get(subTreePlaceholder)\n\n\t\t\t\tif (!rootState) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (rootState.type) {\n\t\t\t\t\tcase 'entityRealm': {\n\t\t\t\t\t\tthis.setEntityStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tcase 'entityList': {\n\t\t\t\t\t\tthis.setEntityListStateErrors(rootState, rootError)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityStateErrors(\n\t\tstate: EntityRealmState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, child] of errors.children) {\n\t\t\tif (typeof childKey !== 'string') {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.nodeType === 'leaf') {\n\t\t\t\tconst fieldState = state.children.get(childKey)\n\n\t\t\t\tif (fieldState?.type === 'field') {\n\t\t\t\t\tthis.addSeveralErrors(fieldState, child)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Deliberately letting flow get here as well. Leaf errors *CAN* refer to relations as well.\n\n\t\t\tconst fields = getEntityMarker(state).fields\n\t\t\tconst placeholders = fields.placeholders.get(childKey)\n\t\t\tif (placeholders === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst normalizedPlaceholders = typeof placeholders === 'string' ? new Set([placeholders]) : placeholders\n\n\t\t\tfor (const normalizedPlaceholder of normalizedPlaceholders) {\n\t\t\t\tconst fieldState = state.children.get(normalizedPlaceholder)\n\t\t\t\tif (fieldState === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tswitch (fieldState.type) {\n\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\t// unwrap for reduced has many\n\t\t\t\t\t\tif (child.nodeType === 'iNode' && child.children.has(fieldState.entity.id.value)) {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child.children.get(fieldState.entity.id.value)!)\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tthis.setEntityStateErrors(fieldState, child)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbreak\n\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\tthis.setEntityListStateErrors(fieldState, child)\n\t\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate setEntityListStateErrors(\n\t\tstate: EntityListState,\n\t\terrors: ErrorsPreprocessor.ErrorINode | ErrorsPreprocessor.LeafErrorNode,\n\t) {\n\t\tthis.addSeveralErrors(state, errors)\n\n\t\tif (errors.nodeType !== 'iNode') {\n\t\t\treturn\n\t\t}\n\n\t\tfor (const [childKey, childError] of errors.children) {\n\t\t\tlet childState = state.children.get(childKey)\n\n\t\t\tif (childState === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (childState.type === 'entityRealmStub') {\n\t\t\t\tchildState.getAccessor() // Force init\n\t\t\t\tchildState = state.children.get(childKey)!\n\t\t\t}\n\n\t\t\tif (childError.nodeType === 'iNode') {\n\t\t\t\tthis.setEntityStateErrors(childState as EntityRealmState, childError)\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dumpErrorData(data: DataBindingTransactionResult) {\n\t\t// TODO this is just temporary\n\t\tfor (const subTreePlaceholder in data.data) {\n\t\t\tconst treeDatum = data.data[subTreePlaceholder]\n\t\t\tconst executionErrors: Array<MutationError | ValidationError> = treeDatum.errors\n\t\t\tconst allErrors = treeDatum?.validation?.errors\n\t\t\t\t? executionErrors.concat(treeDatum.validation.errors)\n\t\t\t\t: executionErrors\n\t\t\tconst normalizedErrors = allErrors.map((error: MutationError | ValidationError) => {\n\t\t\t\tconst path = 'paths' in error ? (error.paths[0] ?? []) : error.path\n\t\t\t\treturn {\n\t\t\t\t\tpath: path\n\t\t\t\t\t\t.map(pathPart => {\n\t\t\t\t\t\t\tif ('field' in pathPart) {\n\t\t\t\t\t\t\t\treturn pathPart.field\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif (pathPart.alias) {\n\t\t\t\t\t\t\t\treturn `#${pathPart.index}(${pathPart.alias})`\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn pathPart.index\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.join('.'),\n\t\t\t\t\ttype: 'type' in error ? error.type : undefined,\n\t\t\t\t\tmessage: typeof error.message === 'string' ? error.message : error.message?.text,\n\t\t\t\t}\n\t\t\t})\n\t\t\tif (Object.keys(normalizedErrors).length) {\n\t\t\t\t// biome-ignore lint/suspicious/noConsole: debug output\n\t\t\t\tconsole.table(normalizedErrors)\n\t\t\t}\n\t\t}\n\t}\n}\n"],"names":["errorsById"],"mappings":";;;;;;AASO,MAAM,qBAAqB;AAAA,EAS1B,YAA6B,cAA6C,WAAsB;AAAnE,SAAA,eAAA;AAA6C,SAAA,YAAA;AARjF,kBAAA,MAAQ,qCAA8D,IAAA,CAAI;AAE1E,kBAAA,MAAQ,iBAAiB,uBAAM;AAC9B,UAAI,UAAU;AAEd,aAAO,MAAM;AAAA,IACd,IAAG;AAAA,EAEqG;AAAA,EAEjG,YAAY;AAClB,WAAO,CAAC,CAAC,KAAK,cAAc;AAAA,EAC7B;AAAA,EAEO,YAAmC;AACzC,WAAO,MAAM,KAAK,KAAK,cAAc,UAAU,CAAA,OAAM,MAAM,KAAK,GAAG,OAAA,CAAQ,CAAC,EAAE,KAAA;AAAA,EAC/E;AAAA,EAEO,cAAc;AACpB,SAAK,aAAa,cAAc,MAAM;AACrC,iBAAW,CAAC,SAAS,KAAK,KAAK,eAAe;AAC7C,kBAAU,SAAS;AACnB,aAAK,aAAa,oBAAoB,WAAW,aAAa,qBAAqB;AAAA,MAC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,gBAAgB,OAAO,UAAU,WAAW,MAAM,IAClD;AACH,YAAM,mBAAmB,UAAU,IAAI,CAAC,UAA2C;AAClF,cAAM,OAAO,WAAW,QAAS,MAAM,MAAM,CAAC,KAAK,KAAM,MAAM;AAC/D,eAAO;AAAA,UACN,MAAM,KACJ,IAAI,CAAA,aAAY;AAChB,gBAAI,WAAW,UAAU;AACxB,qBAAO,SAAS;AAAA,YACjB;AACA,gBAAI,SAAS,OAAO;AACnB,qBAAO,IAAI,SAAS,KAAK,IAAI,SAAS,KAAK;AAAA,YAC5C;AACA,mBAAO,SAAS;AAAA,UACjB,CAAC,EACA,KAAK,GAAG;AAAA,UACV,MAAM,UAAU,QAAQ,MAAM,OAAO;AAAA,UACrC,SAAS,OAAO,MAAM,YAAY,WAAW,MAAM,UAAU,MAAM,SAAS;AAAA,QAAA;AAAA,MAE9E,CAAC;AACD,UAAI,OAAO,KAAK,gBAAgB,EAAE,QAAQ;AAEzC,gBAAQ,MAAM,gBAAgB;AAAA,MAC/B;AAAA,IACD;AAAA,EACD;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Config.cjs","sources":["../../../../../packages/binding-legacy/src/core/Config.ts"],"sourcesContent":["import type { BindingConfig } from '../accessors'\n\nexport class Config {\n\tprivate static defaultConfig: BindingConfig = {\n\t\tbeforePersistSettleLimit: 20,\n\t\tbeforeUpdateSettleLimit: 20,\n\t\tpersistSuccessSettleLimit: 20,\n\t}\n\n\tprivate readonly config: BindingConfig\n\n\tpublic constructor(config: Partial<BindingConfig> = {}) {\n\t\tthis.config = {\n\t\t\t...Config.defaultConfig,\n\t\t\t...config,\n\t\t}\n\t}\n\n\tpublic getValue<Name extends keyof BindingConfig>(name: Name): BindingConfig[Name] {\n\t\treturn this.config[name]\n\t}\n\n\tpublic setValue<Name extends keyof BindingConfig>(name: Name, value: BindingConfig[Name]): this {\n\t\tthis.config[name] = value\n\t\treturn this\n\t}\n}\n"],"names":["_Config"],"mappings":";;;;;AAEO,MAAM,UAAN,MAAMA,SAAO;AAAA,EASZ,YAAY,SAAiC,IAAI;AAFvC,kBAAA,MAAA,QAAA;AAGhB,SAAK,SAAS;AAAA,MACb,GAAGA,SAAO;AAAA,MACV,GAAG;AAAA,IACJ;AAAA,EAAA;AAAA,EAGM,SAA2C,MAAiC;AAC3E,WAAA,KAAK,OAAO,IAAI;AAAA,EAAA;AAAA,EAGjB,SAA2C,MAAY,OAAkC;AAC1F,SAAA,OAAO,IAAI,IAAI;AACb,WAAA;AAAA,EAAA;AAET;AAvBC,cADY,SACG,iBAA+B;AAAA,EAC7C,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,2BAA2B;AAC5B,CAAA;AALM,IAAM,SAAN;;"}
1
+ {"version":3,"file":"Config.cjs","sources":["../../../../../packages/binding-legacy/src/core/Config.ts"],"sourcesContent":["import type { BindingConfig } from '../accessors'\n\nexport class Config {\n\tprivate static defaultConfig: BindingConfig = {\n\t\tbeforePersistSettleLimit: 20,\n\t\tbeforeUpdateSettleLimit: 20,\n\t\tpersistSuccessSettleLimit: 20,\n\t}\n\n\tprivate readonly config: BindingConfig\n\n\tpublic constructor(config: Partial<BindingConfig> = {}) {\n\t\tthis.config = {\n\t\t\t...Config.defaultConfig,\n\t\t\t...config,\n\t\t}\n\t}\n\n\tpublic getValue<Name extends keyof BindingConfig>(name: Name): BindingConfig[Name] {\n\t\treturn this.config[name]\n\t}\n\n\tpublic setValue<Name extends keyof BindingConfig>(name: Name, value: BindingConfig[Name]): this {\n\t\tthis.config[name] = value\n\t\treturn this\n\t}\n}\n"],"names":["_Config"],"mappings":";;;;;AAEO,MAAM,UAAN,MAAMA,SAAO;AAAA,EASZ,YAAY,SAAiC,IAAI;AAFxD,kBAAA,MAAiB,QAAA;AAGhB,SAAK,SAAS;AAAA,MACb,GAAGA,SAAO;AAAA,MACV,GAAG;AAAA,IAAA;AAAA,EAEL;AAAA,EAEO,SAA2C,MAAiC;AAClF,WAAO,KAAK,OAAO,IAAI;AAAA,EACxB;AAAA,EAEO,SAA2C,MAAY,OAAkC;AAC/F,SAAK,OAAO,IAAI,IAAI;AACpB,WAAO;AAAA,EACR;AACD;AAvBC,cADY,SACG,iBAA+B;AAAA,EAC7C,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,2BAA2B;AAC5B,CAAA;AALM,IAAM,SAAN;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Config.js","sources":["../../../../../packages/binding-legacy/src/core/Config.ts"],"sourcesContent":["import type { BindingConfig } from '../accessors'\n\nexport class Config {\n\tprivate static defaultConfig: BindingConfig = {\n\t\tbeforePersistSettleLimit: 20,\n\t\tbeforeUpdateSettleLimit: 20,\n\t\tpersistSuccessSettleLimit: 20,\n\t}\n\n\tprivate readonly config: BindingConfig\n\n\tpublic constructor(config: Partial<BindingConfig> = {}) {\n\t\tthis.config = {\n\t\t\t...Config.defaultConfig,\n\t\t\t...config,\n\t\t}\n\t}\n\n\tpublic getValue<Name extends keyof BindingConfig>(name: Name): BindingConfig[Name] {\n\t\treturn this.config[name]\n\t}\n\n\tpublic setValue<Name extends keyof BindingConfig>(name: Name, value: BindingConfig[Name]): this {\n\t\tthis.config[name] = value\n\t\treturn this\n\t}\n}\n"],"names":["_Config"],"mappings":";;;AAEO,MAAM,UAAN,MAAMA,SAAO;AAAA,EASZ,YAAY,SAAiC,IAAI;AAFvC,kBAAA,MAAA,QAAA;AAGhB,SAAK,SAAS;AAAA,MACb,GAAGA,SAAO;AAAA,MACV,GAAG;AAAA,IACJ;AAAA,EAAA;AAAA,EAGM,SAA2C,MAAiC;AAC3E,WAAA,KAAK,OAAO,IAAI;AAAA,EAAA;AAAA,EAGjB,SAA2C,MAAY,OAAkC;AAC1F,SAAA,OAAO,IAAI,IAAI;AACb,WAAA;AAAA,EAAA;AAET;AAvBC,cADY,SACG,iBAA+B;AAAA,EAC7C,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,2BAA2B;AAC5B,CAAA;AALM,IAAM,SAAN;"}
1
+ {"version":3,"file":"Config.js","sources":["../../../../../packages/binding-legacy/src/core/Config.ts"],"sourcesContent":["import type { BindingConfig } from '../accessors'\n\nexport class Config {\n\tprivate static defaultConfig: BindingConfig = {\n\t\tbeforePersistSettleLimit: 20,\n\t\tbeforeUpdateSettleLimit: 20,\n\t\tpersistSuccessSettleLimit: 20,\n\t}\n\n\tprivate readonly config: BindingConfig\n\n\tpublic constructor(config: Partial<BindingConfig> = {}) {\n\t\tthis.config = {\n\t\t\t...Config.defaultConfig,\n\t\t\t...config,\n\t\t}\n\t}\n\n\tpublic getValue<Name extends keyof BindingConfig>(name: Name): BindingConfig[Name] {\n\t\treturn this.config[name]\n\t}\n\n\tpublic setValue<Name extends keyof BindingConfig>(name: Name, value: BindingConfig[Name]): this {\n\t\tthis.config[name] = value\n\t\treturn this\n\t}\n}\n"],"names":["_Config"],"mappings":";;;AAEO,MAAM,UAAN,MAAMA,SAAO;AAAA,EASZ,YAAY,SAAiC,IAAI;AAFxD,kBAAA,MAAiB,QAAA;AAGhB,SAAK,SAAS;AAAA,MACb,GAAGA,SAAO;AAAA,MACV,GAAG;AAAA,IAAA;AAAA,EAEL;AAAA,EAEO,SAA2C,MAAiC;AAClF,WAAO,KAAK,OAAO,IAAI;AAAA,EACxB;AAAA,EAEO,SAA2C,MAAY,OAAkC;AAC/F,SAAK,OAAO,IAAI,IAAI;AACpB,WAAO;AAAA,EACR;AACD;AAvBC,cADY,SACG,iBAA+B;AAAA,EAC7C,0BAA0B;AAAA,EAC1B,yBAAyB;AAAA,EACzB,2BAA2B;AAC5B,CAAA;AALM,IAAM,SAAN;"}
@@ -105,14 +105,17 @@ const _DataBinding = class _DataBinding2 {
105
105
  const { mutations, operations } = mutationResult;
106
106
  let response;
107
107
  try {
108
- response = await this.contentClient.mutate(this.queryBuilder.transaction(mutations, {
109
- deferForeignKeyConstraints: true
110
- }), {
111
- signal,
112
- onBeforeRequest: ({ query, variables }) => {
113
- console.debug(query, variables);
108
+ response = await this.contentClient.mutate(
109
+ this.queryBuilder.transaction(mutations, {
110
+ deferForeignKeyConstraints: true
111
+ }),
112
+ {
113
+ signal,
114
+ onBeforeRequest: ({ query, variables }) => {
115
+ console.debug(query, variables);
116
+ }
114
117
  }
115
- });
118
+ );
116
119
  } catch (e) {
117
120
  if (e instanceof client.GraphQlClientError) {
118
121
  this.onError(e, this);