@contember/binding-legacy 2.1.0-beta.1 → 2.2.0-alpha.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 (230) hide show
  1. package/dist/development/src/accessors/EntityAccessorImpl.cjs.map +1 -1
  2. package/dist/development/src/accessors/EntityAccessorImpl.js.map +1 -1
  3. package/dist/development/src/accessors/EntityListAccessorImpl.cjs.map +1 -1
  4. package/dist/development/src/accessors/EntityListAccessorImpl.js.map +1 -1
  5. package/dist/development/src/accessors/FieldAccessorImpl.cjs.map +1 -1
  6. package/dist/development/src/accessors/FieldAccessorImpl.js.map +1 -1
  7. package/dist/development/src/core/AccessorErrorManager.cjs.map +1 -1
  8. package/dist/development/src/core/AccessorErrorManager.js.map +1 -1
  9. package/dist/development/src/core/Config.cjs.map +1 -1
  10. package/dist/development/src/core/Config.js.map +1 -1
  11. package/dist/development/src/core/DataBinding.cjs.map +1 -1
  12. package/dist/development/src/core/DataBinding.js.map +1 -1
  13. package/dist/development/src/core/ErrorsPreprocessor.cjs.map +1 -1
  14. package/dist/development/src/core/ErrorsPreprocessor.js.map +1 -1
  15. package/dist/development/src/core/EventManager.cjs.map +1 -1
  16. package/dist/development/src/core/EventManager.js.map +1 -1
  17. package/dist/development/src/core/MutationGenerator.cjs.map +1 -1
  18. package/dist/development/src/core/MutationGenerator.js.map +1 -1
  19. package/dist/development/src/core/RealmKeyGenerator.cjs.map +1 -1
  20. package/dist/development/src/core/RealmKeyGenerator.js.map +1 -1
  21. package/dist/development/src/core/RequestResponseNormalizer.cjs.map +1 -1
  22. package/dist/development/src/core/RequestResponseNormalizer.js.map +1 -1
  23. package/dist/development/src/core/StateInitializer.cjs +23 -1
  24. package/dist/development/src/core/StateInitializer.cjs.map +1 -1
  25. package/dist/development/src/core/StateInitializer.js +23 -1
  26. package/dist/development/src/core/StateInitializer.js.map +1 -1
  27. package/dist/development/src/core/TreeAugmenter.cjs.map +1 -1
  28. package/dist/development/src/core/TreeAugmenter.js.map +1 -1
  29. package/dist/development/src/core/TreeStore.cjs.map +1 -1
  30. package/dist/development/src/core/TreeStore.js.map +1 -1
  31. package/dist/development/src/core/exceptions/ErrorLocator.cjs.map +1 -1
  32. package/dist/development/src/core/exceptions/ErrorLocator.js.map +1 -1
  33. package/dist/development/src/core/exceptions/MarkerSugarer.cjs.map +1 -1
  34. package/dist/development/src/core/exceptions/MarkerSugarer.js.map +1 -1
  35. package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
  36. package/dist/development/src/core/factories/createBatchUpdatesOptions.js.map +1 -1
  37. package/dist/development/src/core/operations/EntityOperations.cjs.map +1 -1
  38. package/dist/development/src/core/operations/EntityOperations.js.map +1 -1
  39. package/dist/development/src/core/operations/FieldOperations.cjs.map +1 -1
  40. package/dist/development/src/core/operations/FieldOperations.js.map +1 -1
  41. package/dist/development/src/core/operations/ListOperations.cjs.map +1 -1
  42. package/dist/development/src/core/operations/ListOperations.js.map +1 -1
  43. package/dist/development/src/core/operations/OperationsHelpers.cjs.map +1 -1
  44. package/dist/development/src/core/operations/OperationsHelpers.js.map +1 -1
  45. package/dist/development/src/core/state/StateIterator.cjs.map +1 -1
  46. package/dist/development/src/core/state/StateIterator.js.map +1 -1
  47. package/dist/development/src/core/state/getEntityMarker.cjs.map +1 -1
  48. package/dist/development/src/core/state/getEntityMarker.js.map +1 -1
  49. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -1
  50. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
  51. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -1
  52. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
  53. package/dist/production/src/accessors/EntityAccessorImpl.cjs.map +1 -1
  54. package/dist/production/src/accessors/EntityAccessorImpl.js.map +1 -1
  55. package/dist/production/src/accessors/EntityListAccessorImpl.cjs.map +1 -1
  56. package/dist/production/src/accessors/EntityListAccessorImpl.js.map +1 -1
  57. package/dist/production/src/accessors/FieldAccessorImpl.cjs.map +1 -1
  58. package/dist/production/src/accessors/FieldAccessorImpl.js.map +1 -1
  59. package/dist/production/src/core/AccessorErrorManager.cjs.map +1 -1
  60. package/dist/production/src/core/AccessorErrorManager.js.map +1 -1
  61. package/dist/production/src/core/Config.cjs.map +1 -1
  62. package/dist/production/src/core/Config.js.map +1 -1
  63. package/dist/production/src/core/DataBinding.cjs.map +1 -1
  64. package/dist/production/src/core/DataBinding.js.map +1 -1
  65. package/dist/production/src/core/ErrorsPreprocessor.cjs.map +1 -1
  66. package/dist/production/src/core/ErrorsPreprocessor.js.map +1 -1
  67. package/dist/production/src/core/EventManager.cjs.map +1 -1
  68. package/dist/production/src/core/EventManager.js.map +1 -1
  69. package/dist/production/src/core/MutationGenerator.cjs.map +1 -1
  70. package/dist/production/src/core/MutationGenerator.js.map +1 -1
  71. package/dist/production/src/core/RealmKeyGenerator.cjs.map +1 -1
  72. package/dist/production/src/core/RealmKeyGenerator.js.map +1 -1
  73. package/dist/production/src/core/RequestResponseNormalizer.cjs.map +1 -1
  74. package/dist/production/src/core/RequestResponseNormalizer.js.map +1 -1
  75. package/dist/production/src/core/StateInitializer.cjs +23 -1
  76. package/dist/production/src/core/StateInitializer.cjs.map +1 -1
  77. package/dist/production/src/core/StateInitializer.js +23 -1
  78. package/dist/production/src/core/StateInitializer.js.map +1 -1
  79. package/dist/production/src/core/TreeAugmenter.cjs.map +1 -1
  80. package/dist/production/src/core/TreeAugmenter.js.map +1 -1
  81. package/dist/production/src/core/TreeStore.cjs.map +1 -1
  82. package/dist/production/src/core/TreeStore.js.map +1 -1
  83. package/dist/production/src/core/exceptions/ErrorLocator.cjs.map +1 -1
  84. package/dist/production/src/core/exceptions/ErrorLocator.js.map +1 -1
  85. package/dist/production/src/core/exceptions/MarkerSugarer.cjs.map +1 -1
  86. package/dist/production/src/core/exceptions/MarkerSugarer.js.map +1 -1
  87. package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
  88. package/dist/production/src/core/factories/createBatchUpdatesOptions.js.map +1 -1
  89. package/dist/production/src/core/operations/EntityOperations.cjs.map +1 -1
  90. package/dist/production/src/core/operations/EntityOperations.js.map +1 -1
  91. package/dist/production/src/core/operations/FieldOperations.cjs.map +1 -1
  92. package/dist/production/src/core/operations/FieldOperations.js.map +1 -1
  93. package/dist/production/src/core/operations/ListOperations.cjs.map +1 -1
  94. package/dist/production/src/core/operations/ListOperations.js.map +1 -1
  95. package/dist/production/src/core/operations/OperationsHelpers.cjs.map +1 -1
  96. package/dist/production/src/core/operations/OperationsHelpers.js.map +1 -1
  97. package/dist/production/src/core/state/StateIterator.cjs.map +1 -1
  98. package/dist/production/src/core/state/StateIterator.js.map +1 -1
  99. package/dist/production/src/core/state/getEntityMarker.cjs.map +1 -1
  100. package/dist/production/src/core/state/getEntityMarker.js.map +1 -1
  101. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -1
  102. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
  103. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -1
  104. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
  105. package/dist/types/accessorTree/index.d.ts +1 -1
  106. package/dist/types/accessorTree/index.d.ts.map +1 -1
  107. package/dist/types/accessors/EntityAccessorImpl.d.ts +3 -3
  108. package/dist/types/accessors/EntityAccessorImpl.d.ts.map +1 -1
  109. package/dist/types/accessors/EntityListAccessorImpl.d.ts +2 -2
  110. package/dist/types/accessors/EntityListAccessorImpl.d.ts.map +1 -1
  111. package/dist/types/accessors/FieldAccessorImpl.d.ts +3 -3
  112. package/dist/types/accessors/FieldAccessorImpl.d.ts.map +1 -1
  113. package/dist/types/accessors/index.d.ts +4 -4
  114. package/dist/types/accessors/index.d.ts.map +1 -1
  115. package/dist/types/core/AccessorErrorManager.d.ts +4 -4
  116. package/dist/types/core/AccessorErrorManager.d.ts.map +1 -1
  117. package/dist/types/core/Config.d.ts +1 -1
  118. package/dist/types/core/Config.d.ts.map +1 -1
  119. package/dist/types/core/DataBinding.d.ts +1 -1
  120. package/dist/types/core/DataBinding.d.ts.map +1 -1
  121. package/dist/types/core/ErrorsPreprocessor.d.ts +1 -1
  122. package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
  123. package/dist/types/core/EventManager.d.ts +5 -5
  124. package/dist/types/core/EventManager.d.ts.map +1 -1
  125. package/dist/types/core/MutationGenerator.d.ts +1 -1
  126. package/dist/types/core/MutationGenerator.d.ts.map +1 -1
  127. package/dist/types/core/RealmKeyGenerator.d.ts +1 -1
  128. package/dist/types/core/RealmKeyGenerator.d.ts.map +1 -1
  129. package/dist/types/core/RequestResponseNormalizer.d.ts +2 -2
  130. package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
  131. package/dist/types/core/StateInitializer.d.ts +5 -4
  132. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  133. package/dist/types/core/TreeAugmenter.d.ts +4 -4
  134. package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
  135. package/dist/types/core/TreeStore.d.ts +3 -3
  136. package/dist/types/core/TreeStore.d.ts.map +1 -1
  137. package/dist/types/core/exceptions/ErrorLocator.d.ts +1 -1
  138. package/dist/types/core/exceptions/ErrorLocator.d.ts.map +1 -1
  139. package/dist/types/core/factories/createBatchUpdatesOptions.d.ts +1 -1
  140. package/dist/types/core/factories/createBatchUpdatesOptions.d.ts.map +1 -1
  141. package/dist/types/core/factories/index.d.ts +1 -1
  142. package/dist/types/core/factories/index.d.ts.map +1 -1
  143. package/dist/types/core/index.d.ts +8 -8
  144. package/dist/types/core/index.d.ts.map +1 -1
  145. package/dist/types/core/operations/EntityOperations.d.ts +5 -5
  146. package/dist/types/core/operations/EntityOperations.d.ts.map +1 -1
  147. package/dist/types/core/operations/FieldOperations.d.ts +5 -5
  148. package/dist/types/core/operations/FieldOperations.d.ts.map +1 -1
  149. package/dist/types/core/operations/ListOperations.d.ts +5 -5
  150. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  151. package/dist/types/core/operations/OperationsHelpers.d.ts +4 -4
  152. package/dist/types/core/operations/OperationsHelpers.d.ts.map +1 -1
  153. package/dist/types/core/operations/index.d.ts +3 -3
  154. package/dist/types/core/operations/index.d.ts.map +1 -1
  155. package/dist/types/core/requestAliases/index.d.ts +1 -1
  156. package/dist/types/core/requestAliases/index.d.ts.map +1 -1
  157. package/dist/types/core/state/EntityListState.d.ts +1 -1
  158. package/dist/types/core/state/EntityListState.d.ts.map +1 -1
  159. package/dist/types/core/state/EntityRealmState.d.ts +3 -3
  160. package/dist/types/core/state/EntityRealmState.d.ts.map +1 -1
  161. package/dist/types/core/state/EntityState.d.ts +1 -1
  162. package/dist/types/core/state/EntityState.d.ts.map +1 -1
  163. package/dist/types/core/state/FieldState.d.ts +1 -1
  164. package/dist/types/core/state/FieldState.d.ts.map +1 -1
  165. package/dist/types/core/state/StateIterator.d.ts +5 -5
  166. package/dist/types/core/state/StateIterator.d.ts.map +1 -1
  167. package/dist/types/core/state/StateNode.d.ts +3 -3
  168. package/dist/types/core/state/StateNode.d.ts.map +1 -1
  169. package/dist/types/core/state/getEntityMarker.d.ts +1 -1
  170. package/dist/types/core/state/getEntityMarker.d.ts.map +1 -1
  171. package/dist/types/core/state/index.d.ts +7 -7
  172. package/dist/types/core/state/index.d.ts.map +1 -1
  173. package/dist/types/core/utils/index.d.ts +1 -1
  174. package/dist/types/core/utils/index.d.ts.map +1 -1
  175. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts +1 -1
  176. package/dist/types/fieldHelpers/helpers/TemporalFieldHelper.d.ts.map +1 -1
  177. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts +1 -1
  178. package/dist/types/fieldHelpers/helpers/UuidFieldHelper.d.ts.map +1 -1
  179. package/dist/types/fieldHelpers/helpers/index.d.ts +2 -2
  180. package/dist/types/fieldHelpers/helpers/index.d.ts.map +1 -1
  181. package/dist/types/fieldHelpers/index.d.ts +1 -1
  182. package/dist/types/fieldHelpers/index.d.ts.map +1 -1
  183. package/dist/types/index.d.ts +3 -3
  184. package/dist/types/index.d.ts.map +1 -1
  185. package/dist/types/tsconfig.tsbuildinfo +1 -1
  186. package/dist/types/utils/index.d.ts +3 -3
  187. package/dist/types/utils/index.d.ts.map +1 -1
  188. package/package.json +4 -4
  189. package/src/accessorTree/index.ts +1 -1
  190. package/src/accessors/EntityAccessorImpl.ts +3 -3
  191. package/src/accessors/EntityListAccessorImpl.ts +2 -2
  192. package/src/accessors/FieldAccessorImpl.ts +3 -3
  193. package/src/accessors/index.ts +4 -4
  194. package/src/core/AccessorErrorManager.ts +5 -5
  195. package/src/core/Config.ts +1 -1
  196. package/src/core/DataBinding.ts +14 -14
  197. package/src/core/ErrorsPreprocessor.ts +2 -2
  198. package/src/core/EventManager.ts +5 -5
  199. package/src/core/MutationGenerator.ts +6 -6
  200. package/src/core/RealmKeyGenerator.ts +1 -1
  201. package/src/core/RequestResponseNormalizer.ts +2 -2
  202. package/src/core/StateInitializer.ts +32 -9
  203. package/src/core/TreeAugmenter.ts +7 -7
  204. package/src/core/TreeStore.ts +4 -4
  205. package/src/core/exceptions/ErrorLocator.ts +3 -3
  206. package/src/core/exceptions/MarkerSugarer.ts +1 -1
  207. package/src/core/factories/createBatchUpdatesOptions.ts +1 -1
  208. package/src/core/factories/index.ts +1 -1
  209. package/src/core/index.ts +8 -8
  210. package/src/core/operations/EntityOperations.ts +7 -7
  211. package/src/core/operations/FieldOperations.ts +6 -6
  212. package/src/core/operations/ListOperations.ts +8 -8
  213. package/src/core/operations/OperationsHelpers.ts +5 -5
  214. package/src/core/operations/index.ts +3 -3
  215. package/src/core/requestAliases/index.ts +1 -1
  216. package/src/core/state/EntityListState.ts +1 -1
  217. package/src/core/state/EntityRealmState.ts +3 -3
  218. package/src/core/state/EntityState.ts +1 -1
  219. package/src/core/state/FieldState.ts +1 -1
  220. package/src/core/state/StateIterator.ts +6 -6
  221. package/src/core/state/StateNode.ts +3 -3
  222. package/src/core/state/getEntityMarker.ts +1 -1
  223. package/src/core/state/index.ts +7 -7
  224. package/src/core/utils/index.ts +1 -1
  225. package/src/fieldHelpers/helpers/TemporalFieldHelper.ts +1 -1
  226. package/src/fieldHelpers/helpers/UuidFieldHelper.ts +1 -1
  227. package/src/fieldHelpers/helpers/index.ts +2 -2
  228. package/src/fieldHelpers/index.ts +1 -1
  229. package/src/index.ts +3 -3
  230. package/src/utils/index.ts +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"ListOperations.js","sources":["../../../../../../packages/binding-legacy/src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityId,\n\tEventListenersStore,\n\tLocalizedBindingError,\n\tMarkerComparator,\n\tRuntimeId,\n\tUnpersistedEntityDummyId,\n} from '@contember/binding-common'\nimport type { AccessorErrorManager } from '../AccessorErrorManager'\nimport { EventManager } from '../EventManager'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\nimport { OperationsHelpers } from './OperationsHelpers'\nimport { ErrorLocator } from '../exceptions/ErrorLocator'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type `\n\t\t\t\t\t\t\t+ `'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n`\n\t\t\t\t\t\t\t+ `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are `\n\t\t\t\t\t\t\t\t+ `incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n`\n\t\t\t\t\t\t\t\t+ `${error.message}\\n\\n`\n\t\t\t\t\t\t\t\t+ (error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '')\n\t\t\t\t\t\t\t\t+ `Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else if (idToConnect.existsOnServer) {\n\t\t\t\t\t// ignoring unpersisted entities\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: { noPersist?: boolean }) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\n\t\t\tif (!listState.children.has(childEntity.id)) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Entity list doesn't include an entity with id '${childEntity.id}' and so it cannot remove it.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tstate.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: EntityId) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = typeof id === 'number' || uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = typeof id === 'string' && (this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id))\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.`\n\t\t\t\t\t+ (looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids `\n\t\t\t\t\t\t\t+ `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and `\n\t\t\t\t\t\t\t+ `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["uuidValidate"],"mappings":";;;;;;;;AAoBO,MAAM,eAAe;AAAA,EACpB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;AALgB,SAAA,uBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,YAAA;AAAA,EACf;AAAA,EAEI,SAAS,WAA4B,OAAwC;AACnF,WAAO,KAAK,qBAAqB,SAAS,WAAW,KAAK;AAAA,EAC3D;AAAA,EAEO,iBACN,OACA,OACA,UACC;AACD,QAAI,MAAM,mBAAmB,QAAW;AACvC,YAAM,iBAAiB,IAAI,oBAAA;AAAA,IAC5B;AACA,WAAO,MAAM,eAAe,IAAI,OAAO,QAAQ;AAAA,EAChD;AAAA,EAEO,sBACN,OACA,OACA,UACC;AACD,QAAI,MAAM,wBAAwB,QAAW;AAC5C,YAAM,sBAAsB,IAAI,oBAAA;AAAA,IACjC;AACA,WAAO,MAAM,oBAAoB,IAAI,OAAO,QAAQ;AAAA,EACrD;AAAA,EAEO,aAAa,OAAwB,gBAAwD;AACnG,SAAK,aAAa,cAAc,MAAM;AACrC,qBAAe,MAAM,aAAa,KAAK,mBAAmB;AAAA,IAC3D,CAAC;AAAA,EACF;AAAA,EAEO,cAAc,YAA6B,iBAAiC;AAClF,SAAK,aAAa,cAAc,MAAM;AACrC,YAAM,qBAAqB,KAAK,UAAU,0BAA0B,UAAU;AAC9E,YAAM,iBAAiB,kBAAkB,iCAAiC,KAAK,WAAW,eAAe;AACzG,YAAM,cAAc,eAAe,OAAO;AAG1C,iBAAW,SAAS,cAAc,sBAAsB,KAAK,WAAW,UAAU,GAAG;AACpF,YAAI,MAAM,eAAe,eAAe,OAAO,YAAY;AAC1D,gBAAM,IAAI;AAAA,YACT,iFACO,eAAe,OAAO,UAAU,UAAU,MAAM,UAAU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AE,KAAK,yBAAyB,eAAe,EAAE;AAC5G,UAAI,aAAa;AAChB,cAAM,IAAI,aAAa,kDAAkD,EAAE,6BAA6B;AAAA,MACzG;AACA,YAAM,eAAe,OAAO,OAAO,aAAa,KAAK,UAAU,iBAAiB,IAAI,EAAE,KAAK,kBAAkB,uBAAuB,EAAE;AACtI,YAAM,IAAI;AAAA,QACT,kDAAkD,EAAE,oCAChD,eACA;AAAA,oQAGA;AAAA,MAAA;AAAA,IAEN;AACA,WAAO,MAAM,YAAA;AAAA,EACd;AACD;"}
1
+ {"version":3,"file":"ListOperations.js","sources":["../../../../../../packages/binding-legacy/src/core/operations/ListOperations.ts"],"sourcesContent":["import { validate as uuidValidate } from 'uuid'\nimport type { BatchUpdatesOptions, EntityAccessor, EntityListAccessor, ErrorAccessor } from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityId,\n\tEventListenersStore,\n\tLocalizedBindingError,\n\tMarkerComparator,\n\tRuntimeId,\n\tUnpersistedEntityDummyId,\n} from '@contember/binding-common'\nimport type { AccessorErrorManager } from '../AccessorErrorManager.js'\nimport { EventManager } from '../EventManager.js'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator.js'\nimport { EntityListState, getEntityMarker, StateIterator } from '../state/index.js'\nimport type { StateInitializer } from '../StateInitializer.js'\nimport type { TreeStore } from '../TreeStore.js'\nimport { OperationsHelpers } from './OperationsHelpers.js'\nimport { ErrorLocator } from '../exceptions/ErrorLocator.js'\n\nexport class ListOperations {\n\tpublic constructor(\n\t\tprivate readonly accessorErrorManager: AccessorErrorManager,\n\t\tprivate readonly batchUpdatesOptions: BatchUpdatesOptions,\n\t\tprivate readonly eventManager: EventManager,\n\t\tprivate readonly stateInitializer: StateInitializer,\n\t\tprivate readonly treeStore: TreeStore,\n\t) {}\n\n\tpublic addError(listState: EntityListState, error: ErrorAccessor.Error): () => void {\n\t\treturn this.accessorErrorManager.addError(listState, error)\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\tif (state.eventListeners === undefined) {\n\t\t\tstate.eventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.eventListeners.add(event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tstate: EntityListState,\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\tif (state.childEventListeners === undefined) {\n\t\t\tstate.childEventListeners = new EventListenersStore()\n\t\t}\n\t\treturn state.childEventListeners.add(event, listener)\n\t}\n\n\tpublic batchUpdates(state: EntityListState, performUpdates: EntityListAccessor.BatchUpdatesHandler) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tperformUpdates(state.getAccessor, this.batchUpdatesOptions)\n\t\t})\n\t}\n\n\tpublic connectEntity(outerState: EntityListState, entityToConnect: EntityAccessor) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(outerState)\n\t\t\tconst stateToConnect = OperationsHelpers.resolveAndPrepareEntityToConnect(this.treeStore, entityToConnect)\n\t\t\tconst idToConnect = stateToConnect.entity.id\n\n\t\t\t// TODO disable this at the top-level.\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tif (state.entityName !== stateToConnect.entity.entityName) {\n\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t`EntityListAccessor.connectEntity: Attempting to connect at an entity of type `\n\t\t\t\t\t\t\t+ `'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\\n\\n`\n\t\t\t\t\t\t\t+ `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tMarkerComparator.assertEntityMarkersSubsetOf(\n\t\t\t\t\t\tstate.blueprint.marker.fields,\n\t\t\t\t\t\tgetEntityMarker(stateToConnect).fields,\n\t\t\t\t\t)\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof LocalizedBindingError) {\n\t\t\t\t\t\tthrow new BindingError(\n\t\t\t\t\t\t\t`Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are `\n\t\t\t\t\t\t\t\t+ `incompatible with entities found on this list. Make sure both trees are equivalent.\\n\\n`\n\t\t\t\t\t\t\t\t+ `${error.message}\\n\\n`\n\t\t\t\t\t\t\t\t+ (error.markerPath.length > 1\n\t\t\t\t\t\t\t\t\t? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\\n\\n`\n\t\t\t\t\t\t\t\t\t: '')\n\t\t\t\t\t\t\t\t+ `Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t\tthrow error\n\t\t\t\t}\n\n\t\t\t\tif (state.children.has(idToConnect.value)) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.stateInitializer.initializeEntityRealm(idToConnect, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t}, stateToConnect)\n\n\t\t\t\tstate.plannedRemovals?.delete(idToConnect.value)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(idToConnect.value)) {\n\t\t\t\t\t// It was removed from the list but now we're adding it back.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t} else if (idToConnect.existsOnServer) {\n\t\t\t\t\t// ignoring unpersisted entities\n\t\t\t\t\tchangesDelta++\n\t\t\t\t}\n\t\t\t\tif (stateToConnect.type === 'entityRealm') {\n\t\t\t\t\tchangesDelta += stateToConnect.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: { noPersist?: boolean }) {\n\t\tthis.eventManager.syncOperation(() => {\n\t\t\t// TODO disable this at the top-level.\n\t\t\tconst persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)\n\n\t\t\tif (!listState.children.has(childEntity.id)) {\n\t\t\t\tthrow new BindingError(\n\t\t\t\t\t`Entity list doesn't include an entity with id '${childEntity.id}' and so it cannot remove it.`,\n\t\t\t\t)\n\t\t\t}\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, listState)) {\n\t\t\t\tconst disconnectedChildIdValue = childEntity.id\n\t\t\t\tconst disconnectedChildRealm = state.children.get(disconnectedChildIdValue)\n\n\t\t\t\tif (disconnectedChildRealm === undefined) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tthis.treeStore.disposeOfRealm(disconnectedChildRealm)\n\t\t\t\tstate.children.delete(disconnectedChildIdValue)\n\n\t\t\t\tlet changesDelta = 0\n\n\t\t\t\tif (persistedEntityIds.has(disconnectedChildIdValue)) {\n\t\t\t\t\tchangesDelta++\n\n\t\t\t\t\tif (state.plannedRemovals === undefined) {\n\t\t\t\t\t\tstate.plannedRemovals = new Map()\n\t\t\t\t\t}\n\t\t\t\t\tif (!options.noPersist) {\n\t\t\t\t\t\tstate.plannedRemovals.set(disconnectedChildIdValue, 'disconnect')\n\t\t\t\t\t}\n\t\t\t\t} else if (disconnectedChildRealm.entity.id.existsOnServer) {\n\t\t\t\t\t// Disconnecting unpersisted entities doesn't constitute a change.\n\n\t\t\t\t\t// It wasn't on the list, then it was, and now we're removing it again.\n\t\t\t\t\tchangesDelta--\n\t\t\t\t}\n\n\t\t\t\tif (disconnectedChildRealm.type === 'entityRealm') {\n\t\t\t\t\t// Undoing whatever changes this child had caused.\n\t\t\t\t\tchangesDelta -= disconnectedChildRealm.unpersistedChangesCount\n\t\t\t\t}\n\n\t\t\t\tthis.eventManager.registerJustUpdated(state, changesDelta)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic createNewEntity(outerState: EntityListState, initialize: EntityAccessor.BatchUpdatesHandler | undefined): RuntimeId {\n\t\treturn this.eventManager.syncOperation((): RuntimeId => {\n\t\t\t// All siblings need to have the same id.\n\t\t\tconst id = new UnpersistedEntityDummyId()\n\n\t\t\tfor (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {\n\t\t\t\tconst newEntity = this.stateInitializer.initializeEntityRealm(id, state.entityName, {\n\t\t\t\t\ttype: 'listEntity',\n\t\t\t\t\tparent: state,\n\t\t\t\t})\n\n\t\t\t\tthis.stateInitializer.runImmediateUserInitialization(newEntity, initialize)\n\n\t\t\t\t// The act of creating the entity doesn't constitute a change unless there's something inside to persist.\n\t\t\t\t// TODO forceCreate\n\t\t\t\t// TODO defaultValue\n\t\t\t\tthis.eventManager.registerJustUpdated(state, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\t\t\treturn id\n\t\t})\n\t}\n\n\tpublic getChildEntityById(state: EntityListState, id: EntityId) {\n\t\tconst realm = state.children.get(id)\n\t\tif (realm === undefined) {\n\t\t\tconst isRuntimeId = typeof id === 'number' || uuidValidate(id) || UnpersistedEntityDummyId.matchesDummyId(id)\n\t\t\tif (isRuntimeId) {\n\t\t\t\tthrow new BindingError(`EntityList: cannot retrieve an entity with id '${id}' as it is not on the list.`)\n\t\t\t}\n\t\t\tconst looksLikeKey = typeof id === 'string' && (this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id))\n\t\t\tthrow new BindingError(\n\t\t\t\t`EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.`\n\t\t\t\t\t+ (looksLikeKey\n\t\t\t\t\t\t? `\\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids `\n\t\t\t\t\t\t\t+ `and you can use \\`EntityAccessor.id\\` to obtain one. Keys, on the other hand, are globally unique and `\n\t\t\t\t\t\t\t+ `you can use \\`getEntityByKey\\` to get its EntityAccessor.`\n\t\t\t\t\t\t: ''),\n\t\t\t)\n\t\t}\n\t\treturn realm.getAccessor()\n\t}\n}\n"],"names":["uuidValidate"],"mappings":";;;;;;;;AAoBO,MAAM,eAAe;AAAA,EACpB,YACW,sBACA,qBACA,cACA,kBACA,WAChB;AALgB,SAAA,uBAAA;AACA,SAAA,sBAAA;AACA,SAAA,eAAA;AACA,SAAA,mBAAA;AACA,SAAA,YAAA;AAAA,EACf;AAAA,EAEI,SAAS,WAA4B,OAAwC;AACnF,WAAO,KAAK,qBAAqB,SAAS,WAAW,KAAK;AAAA,EAC3D;AAAA,EAEO,iBACN,OACA,OACA,UACC;AACD,QAAI,MAAM,mBAAmB,QAAW;AACvC,YAAM,iBAAiB,IAAI,oBAAA;AAAA,IAC5B;AACA,WAAO,MAAM,eAAe,IAAI,OAAO,QAAQ;AAAA,EAChD;AAAA,EAEO,sBACN,OACA,OACA,UACC;AACD,QAAI,MAAM,wBAAwB,QAAW;AAC5C,YAAM,sBAAsB,IAAI,oBAAA;AAAA,IACjC;AACA,WAAO,MAAM,oBAAoB,IAAI,OAAO,QAAQ;AAAA,EACrD;AAAA,EAEO,aAAa,OAAwB,gBAAwD;AACnG,SAAK,aAAa,cAAc,MAAM;AACrC,qBAAe,MAAM,aAAa,KAAK,mBAAmB;AAAA,IAC3D,CAAC;AAAA,EACF;AAAA,EAEO,cAAc,YAA6B,iBAAiC;AAClF,SAAK,aAAa,cAAc,MAAM;AACrC,YAAM,qBAAqB,KAAK,UAAU,0BAA0B,UAAU;AAC9E,YAAM,iBAAiB,kBAAkB,iCAAiC,KAAK,WAAW,eAAe;AACzG,YAAM,cAAc,eAAe,OAAO;AAG1C,iBAAW,SAAS,cAAc,sBAAsB,KAAK,WAAW,UAAU,GAAG;AACpF,YAAI,MAAM,eAAe,eAAe,OAAO,YAAY;AAC1D,gBAAM,IAAI;AAAA,YACT,iFACO,eAAe,OAAO,UAAU,UAAU,MAAM,UA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EAAE,KAAK,yBAAyB,eAAe,EAAE;AAC5G,UAAI,aAAa;AAChB,cAAM,IAAI,aAAa,kDAAkD,EAAE,6BAA6B;AAAA,MACzG;AACA,YAAM,eAAe,OAAO,OAAO,aAAa,KAAK,UAAU,iBAAiB,IAAI,EAAE,KAAK,kBAAkB,uBAAuB,EAAE;AACtI,YAAM,IAAI;AAAA,QACT,kDAAkD,EAAE,oCAChD,eACA;AAAA,oQAGA;AAAA,MAAA;AAAA,IAEN;AACA,WAAO,MAAM,YAAA;AAAA,EACd;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"OperationsHelpers.cjs","sources":["../../../../../../packages/binding-legacy/src/core/operations/OperationsHelpers.ts"],"sourcesContent":["import type { EntityAccessor } from '@contember/binding-common'\nimport type { RuntimeId } from '@contember/binding-common'\nimport { BindingError } from '@contember/binding-common'\nimport { PRIMARY_KEY_NAME } from '@contember/binding-common'\nimport { EventManager } from '../EventManager'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport type { EntityRealmState, EntityRealmStateStub, EntityState } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\n\nexport class OperationsHelpers {\n\tpublic static rejectInvalidAccessorTree(): never {\n\t\tthrow new BindingError(\n\t\t\t`The accessor tree does not correspond to the MarkerTree. This should absolutely never happen.`,\n\t\t)\n\t}\n\n\tpublic static resolveAndPrepareEntityToConnect(\n\t\ttreeStore: TreeStore,\n\t\tentityToConnect: EntityAccessor,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\tconst entityToConnectKey = entityToConnect.key\n\t\tif (!entityToConnectKey) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity without a key.`)\n\t\t}\n\t\tconst stateToConnect = treeStore.entityRealmStore.get(entityToConnectKey)\n\n\t\tif (stateToConnect === undefined) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity with key '${entityToConnectKey}' but it doesn't exist.`)\n\t\t}\n\t\t// TODO This is commented out for now in order to at least somewhat mitigate the limitations of dealing with\n\t\t// \t\tinverse relations. However, once that has been addressed systemically, this code needs to be re-enabled.\n\t\t// if (!stateToConnect.entity.id.existsOnServer) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Attempting to connect an entity with key '${stateToConnect.realmKey}' that ` +\n\t\t// \t\t\t`doesn't exist on server. That is currently impossible.`, // At least for now.\n\t\t// \t)\n\t\t// }\n\n\t\t// TODO\n\t\t// if (stateToConnect.entity.isScheduledForDeletion) {\n\t\t// \t// As far as the other realms are concerned, this entity is deleted. We don't want to just make it re-appear\n\t\t// \t// for them just because some other random relation decided to connect it.\n\t\t// \tstateToConnect.entity.realms.clear()\n\t\t// \tstateToConnect.entity.isScheduledForDeletion = false\n\t\t// }\n\n\t\treturn stateToConnect\n\t}\n\n\tpublic static changeEntityId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\tentity: EntityState,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst previousId = entity.id\n\n\t\ttreeStore.entityStore.delete(previousId.uniqueValue)\n\t\ttreeStore.entityStore.set(newId.uniqueValue, entity)\n\n\t\tlet counter = 0\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.changeRealmId(treeStore, eventManager, stateInitializer, realm, newId)\n\n\t\t\tif (++counter === entity.realms.size) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tentity.hasIdSetInStone = true\n\t\tentity.id = newId\n\t}\n\n\tpublic static changeRealmId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst oldEntity = realm.entity\n\t\tconst oldRealmKey = realm.realmKey\n\t\tconst oldId = oldEntity.id\n\n\t\tconst realmBlueprint = realm.blueprint\n\n\t\tconst newEntity = stateInitializer.initializeEntityState(newId, oldEntity.entityName)\n\t\tconst newRealmKey = RealmKeyGenerator.getRealmKey(newId, realmBlueprint)\n\n\t\trealm.realmKey = newRealmKey\n\t\trealm.entity = newEntity\n\n\t\t// This may still actually be necessary if we're going from a client to server generated uuid.\n\t\t// They both may have the same value but still be different.\n\t\tnewEntity.id = newId\n\t\toldEntity.realms.delete(oldRealmKey)\n\t\tnewEntity.realms.set(newRealmKey, realm)\n\n\t\tif (realm.type === 'entityRealm') {\n\t\t\tconst childIdState = realm.children.get(PRIMARY_KEY_NAME)\n\t\t\tif (childIdState?.type === 'field') {\n\t\t\t\tchildIdState.value = newId.value\n\t\t\t\teventManager.registerJustUpdated(childIdState, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\n\t\t\tthis.purgeStaleListenersAfterIdChange(realm)\n\t\t}\n\n\t\tif (oldEntity.realms.size === 0) {\n\t\t\ttreeStore.disposeOfEntity(oldEntity)\n\t\t}\n\n\t\ttreeStore.entityRealmStore.delete(oldRealmKey)\n\t\ttreeStore.entityRealmStore.set(newRealmKey, realm)\n\n\t\tif (realmBlueprint.type === 'listEntity') {\n\t\t\tconst list = realmBlueprint.parent\n\t\t\tlist.children.changeKey(oldId.value, newId.value) // 😎\n\t\t} else if (realmBlueprint.type === 'hasOne') {\n\t\t\teventManager.registerUpdatedConnection(realmBlueprint.parent, realmBlueprint.marker.placeholderName)\n\t\t}\n\t\tconst parent = realmBlueprint.parent\n\t\tif (parent) {\n\t\t\teventManager.registerJustUpdated(parent, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t\tif (realm.type === 'entityRealm') {\n\t\t\teventManager.registerJustUpdated(realm, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t}\n\n\tpublic static purgeStaleListenersAfterIdChange(realm: EntityRealmState) {\n\t\t// Version 1.\n\t\t// The listeners subscribed to a particular entity key so we no longer want to call these.\n\t\t// The only positionally associated listeners are in the blueprint so we re-initialize those.\n\t\t// realm.eventListeners = stateInitializer.initializeEntityEventListenerStore(realmBlueprint)\n\n\t\t// Version 2.\n\t\t// This is version two of this terrible hack. We want to preserve e.g. persistSuccess handlers.\n\n\t\t// Version 3.\n\t\t// The saga continues. We add a condition to exempt top-level realms. That way they can start\n\t\t// propagating changes from the top.\n\t\tconst listeners = realm.eventListeners\n\t\tif (listeners) {\n\t\t\tif (realm.blueprint.parent) {\n\t\t\t\tlisteners.delete({ type: 'update' })\n\t\t\t}\n\t\t\tlisteners.deleteByType('connectionUpdate')\n\t\t}\n\t}\n}\n"],"names":["BindingError","RealmKeyGenerator","PRIMARY_KEY_NAME","EventManager"],"mappings":";;;;;AAUO,MAAM,kBAAkB;AAAA,EAC9B,OAAc,4BAAmC;AAChD,UAAM,IAAIA,cAAAA;AAAAA,MACT;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,OAAc,iCACb,WACA,iBAC0C;AAC1C,UAAM,qBAAqB,gBAAgB;AAC3C,QAAI,CAAC,oBAAoB;AACxB,YAAM,IAAIA,cAAAA,aAAa,gDAAgD;AAAA,IACxE;AACA,UAAM,iBAAiB,UAAU,iBAAiB,IAAI,kBAAkB;AAExE,QAAI,mBAAmB,QAAW;AACjC,YAAM,IAAIA,cAAAA,aAAa,6CAA6C,kBAAkB,yBAAyB;AAAA,IAChH;AAkBA,WAAO;AAAA,EACR;AAAA,EAEA,OAAc,eACb,WACA,cACA,kBACA,QACA,OACC;AACD,UAAM,aAAa,OAAO;AAE1B,cAAU,YAAY,OAAO,WAAW,WAAW;AACnD,cAAU,YAAY,IAAI,MAAM,aAAa,MAAM;AAEnD,QAAI,UAAU;AACd,eAAW,SAAS,OAAO,OAAO,OAAA,GAAU;AAC3C,WAAK,cAAc,WAAW,cAAc,kBAAkB,OAAO,KAAK;AAE1E,UAAI,EAAE,YAAY,OAAO,OAAO,MAAM;AACrC;AAAA,MACD;AAAA,IACD;AAEA,WAAO,kBAAkB;AACzB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,OAAc,cACb,WACA,cACA,kBACA,OACA,OACC;AACD,UAAM,YA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AC3B,kBAAU,OAAO,EAAE,MAAM,SAAA,CAAU;AAAA,MACpC;AACA,gBAAU,aAAa,kBAAkB;AAAA,IAC1C;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"OperationsHelpers.cjs","sources":["../../../../../../packages/binding-legacy/src/core/operations/OperationsHelpers.ts"],"sourcesContent":["import type { EntityAccessor } from '@contember/binding-common'\nimport type { RuntimeId } from '@contember/binding-common'\nimport { BindingError } from '@contember/binding-common'\nimport { PRIMARY_KEY_NAME } from '@contember/binding-common'\nimport { EventManager } from '../EventManager.js'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator.js'\nimport type { EntityRealmState, EntityRealmStateStub, EntityState } from '../state/index.js'\nimport type { StateInitializer } from '../StateInitializer.js'\nimport type { TreeStore } from '../TreeStore.js'\n\nexport class OperationsHelpers {\n\tpublic static rejectInvalidAccessorTree(): never {\n\t\tthrow new BindingError(\n\t\t\t`The accessor tree does not correspond to the MarkerTree. This should absolutely never happen.`,\n\t\t)\n\t}\n\n\tpublic static resolveAndPrepareEntityToConnect(\n\t\ttreeStore: TreeStore,\n\t\tentityToConnect: EntityAccessor,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\tconst entityToConnectKey = entityToConnect.key\n\t\tif (!entityToConnectKey) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity without a key.`)\n\t\t}\n\t\tconst stateToConnect = treeStore.entityRealmStore.get(entityToConnectKey)\n\n\t\tif (stateToConnect === undefined) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity with key '${entityToConnectKey}' but it doesn't exist.`)\n\t\t}\n\t\t// TODO This is commented out for now in order to at least somewhat mitigate the limitations of dealing with\n\t\t// \t\tinverse relations. However, once that has been addressed systemically, this code needs to be re-enabled.\n\t\t// if (!stateToConnect.entity.id.existsOnServer) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Attempting to connect an entity with key '${stateToConnect.realmKey}' that ` +\n\t\t// \t\t\t`doesn't exist on server. That is currently impossible.`, // At least for now.\n\t\t// \t)\n\t\t// }\n\n\t\t// TODO\n\t\t// if (stateToConnect.entity.isScheduledForDeletion) {\n\t\t// \t// As far as the other realms are concerned, this entity is deleted. We don't want to just make it re-appear\n\t\t// \t// for them just because some other random relation decided to connect it.\n\t\t// \tstateToConnect.entity.realms.clear()\n\t\t// \tstateToConnect.entity.isScheduledForDeletion = false\n\t\t// }\n\n\t\treturn stateToConnect\n\t}\n\n\tpublic static changeEntityId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\tentity: EntityState,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst previousId = entity.id\n\n\t\ttreeStore.entityStore.delete(previousId.uniqueValue)\n\t\ttreeStore.entityStore.set(newId.uniqueValue, entity)\n\n\t\tlet counter = 0\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.changeRealmId(treeStore, eventManager, stateInitializer, realm, newId)\n\n\t\t\tif (++counter === entity.realms.size) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tentity.hasIdSetInStone = true\n\t\tentity.id = newId\n\t}\n\n\tpublic static changeRealmId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst oldEntity = realm.entity\n\t\tconst oldRealmKey = realm.realmKey\n\t\tconst oldId = oldEntity.id\n\n\t\tconst realmBlueprint = realm.blueprint\n\n\t\tconst newEntity = stateInitializer.initializeEntityState(newId, oldEntity.entityName)\n\t\tconst newRealmKey = RealmKeyGenerator.getRealmKey(newId, realmBlueprint)\n\n\t\trealm.realmKey = newRealmKey\n\t\trealm.entity = newEntity\n\n\t\t// This may still actually be necessary if we're going from a client to server generated uuid.\n\t\t// They both may have the same value but still be different.\n\t\tnewEntity.id = newId\n\t\toldEntity.realms.delete(oldRealmKey)\n\t\tnewEntity.realms.set(newRealmKey, realm)\n\n\t\tif (realm.type === 'entityRealm') {\n\t\t\tconst childIdState = realm.children.get(PRIMARY_KEY_NAME)\n\t\t\tif (childIdState?.type === 'field') {\n\t\t\t\tchildIdState.value = newId.value\n\t\t\t\teventManager.registerJustUpdated(childIdState, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\n\t\t\tthis.purgeStaleListenersAfterIdChange(realm)\n\t\t}\n\n\t\tif (oldEntity.realms.size === 0) {\n\t\t\ttreeStore.disposeOfEntity(oldEntity)\n\t\t}\n\n\t\ttreeStore.entityRealmStore.delete(oldRealmKey)\n\t\ttreeStore.entityRealmStore.set(newRealmKey, realm)\n\n\t\tif (realmBlueprint.type === 'listEntity') {\n\t\t\tconst list = realmBlueprint.parent\n\t\t\tlist.children.changeKey(oldId.value, newId.value) // 😎\n\t\t} else if (realmBlueprint.type === 'hasOne') {\n\t\t\teventManager.registerUpdatedConnection(realmBlueprint.parent, realmBlueprint.marker.placeholderName)\n\t\t}\n\t\tconst parent = realmBlueprint.parent\n\t\tif (parent) {\n\t\t\teventManager.registerJustUpdated(parent, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t\tif (realm.type === 'entityRealm') {\n\t\t\teventManager.registerJustUpdated(realm, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t}\n\n\tpublic static purgeStaleListenersAfterIdChange(realm: EntityRealmState) {\n\t\t// Version 1.\n\t\t// The listeners subscribed to a particular entity key so we no longer want to call these.\n\t\t// The only positionally associated listeners are in the blueprint so we re-initialize those.\n\t\t// realm.eventListeners = stateInitializer.initializeEntityEventListenerStore(realmBlueprint)\n\n\t\t// Version 2.\n\t\t// This is version two of this terrible hack. We want to preserve e.g. persistSuccess handlers.\n\n\t\t// Version 3.\n\t\t// The saga continues. We add a condition to exempt top-level realms. That way they can start\n\t\t// propagating changes from the top.\n\t\tconst listeners = realm.eventListeners\n\t\tif (listeners) {\n\t\t\tif (realm.blueprint.parent) {\n\t\t\t\tlisteners.delete({ type: 'update' })\n\t\t\t}\n\t\t\tlisteners.deleteByType('connectionUpdate')\n\t\t}\n\t}\n}\n"],"names":["BindingError","RealmKeyGenerator","PRIMARY_KEY_NAME","EventManager"],"mappings":";;;;;AAUO,MAAM,kBAAkB;AAAA,EAC9B,OAAc,4BAAmC;AAChD,UAAM,IAAIA,cAAAA;AAAAA,MACT;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,OAAc,iCACb,WACA,iBAC0C;AAC1C,UAAM,qBAAqB,gBAAgB;AAC3C,QAAI,CAAC,oBAAoB;AACxB,YAAM,IAAIA,cAAAA,aAAa,gDAAgD;AAAA,IACxE;AACA,UAAM,iBAAiB,UAAU,iBAAiB,IAAI,kBAAkB;AAExE,QAAI,mBAAmB,QAAW;AACjC,YAAM,IAAIA,cAAAA,aAAa,6CAA6C,kBAAkB,yBAAyB;AAAA,IAChH;AAkBA,WAAO;AAAA,EACR;AAAA,EAEA,OAAc,eACb,WACA,cACA,kBACA,QACA,OACC;AACD,UAAM,aAAa,OAAO;AAE1B,cAAU,YAAY,OAAO,WAAW,WAAW;AACnD,cAAU,YAAY,IAAI,MAAM,aAAa,MAAM;AAEnD,QAAI,UAAU;AACd,eAAW,SAAS,OAAO,OAAO,OAAA,GAAU;AAC3C,WAAK,cAAc,WAAW,cAAc,kBAAkB,OAAO,KAAK;AAE1E,UAAI,EAAE,YAAY,OAAO,OAAO,MAAM;AACrC;AAAA,MACD;AAAA,IACD;AAEA,WAAO,kBAAkB;AACzB,WAAO,KAAK;AAAA,EACb;AAAA,EAEA,OAAc,cACb,WACA,cACA,kBACA,OACA,OACC;AACD,UAAM,YAAY,MAAM;AACxB,UAAM,cAAc,MAAM;AAC1B,UAAM,QAAQ,UAAU;AAExB,UAAM,iBAAiB,MAAM;AAE7B,UAAM,YAAY,iBAAiB,sBAAsB,OAAO,UAAU,UAAU;AACpF,UAAM,cAAcC,kBAAAA,kBAAkB,YAAY,OAAO,cAAc;AAEvE,UAAM,WAAW;AACjB,UAAM,SAAS;AAIf,cAAU,KAAK;AACf,cAAU,OAAO,OAAO,WAAW;AACnC,cAAU,OAAO,IAAI,aAAa,KAAK;AAEvC,QAAI,MAAM,SAAS,eAAe;AACjC,YAAM,eAAe,MAAM,SAAS,IAAIC,cAAAA,gBAAgB;AACxD,UAAI,cAAc,SAAS,SAAS;AACnC,qBAAa,QAAQ,MAAM;AAC3B,qBAAa,oBAAoB,cAAcC,aAAAA,aAAa,qBAAqB;AAAA,MAClF;AAEA,WAAK,iCAAiC,KAAK;AAAA,IAC5C;AAEA,QAAI,UAAU,OAAO,SAAS,GAAG;AAChC,gBAAU,gBAAgB,SAAS;AAAA,IACpC;AAEA,cAAU,iBAAiB,OAAO,WAAW;AAC7C,cAAU,iBAAiB,IAAI,aAAa,KAAK;AAEjD,QAAI,eAAe,SAAS,cAAc;AACzC,YAAM,OAAO,eAAe;AAC5B,WAAK,SAAS,UAAU,MAAM,OAAO,MAAM,KAAK;AAAA,IACjD,WAAW,eAAe,SAAS,UAAU;AAC5C,mBAAa,0BAA0B,eAAe,QAAQ,eAAe,OAAO,eAAe;AAAA,IACpG;AACA,UAAM,SAAS,eAAe;AAC9B,QAAI,QAAQ;AACX,mBAAa,oBAAoB,QAAQA,aAAAA,aAAa,qBAAqB;AAAA,IAC5E;AACA,QAAI,MAAM,SAAS,eAAe;AACjC,mBAAa,oBAAoB,OAAOA,aAAAA,aAAa,qBAAqB;AAAA,IAC3E;AAAA,EACD;AAAA,EAEA,OAAc,iCAAiC,OAAyB;AAYvE,UAAM,YAAY,MAAM;AACxB,QAAI,WAAW;AACd,UAAI,MAAM,UAAU,QAAQ;AAC3B,kBAAU,OAAO,EAAE,MAAM,SAAA,CAAU;AAAA,MACpC;AACA,gBAAU,aAAa,kBAAkB;AAAA,IAC1C;AAAA,EACD;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"OperationsHelpers.js","sources":["../../../../../../packages/binding-legacy/src/core/operations/OperationsHelpers.ts"],"sourcesContent":["import type { EntityAccessor } from '@contember/binding-common'\nimport type { RuntimeId } from '@contember/binding-common'\nimport { BindingError } from '@contember/binding-common'\nimport { PRIMARY_KEY_NAME } from '@contember/binding-common'\nimport { EventManager } from '../EventManager'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator'\nimport type { EntityRealmState, EntityRealmStateStub, EntityState } from '../state'\nimport type { StateInitializer } from '../StateInitializer'\nimport type { TreeStore } from '../TreeStore'\n\nexport class OperationsHelpers {\n\tpublic static rejectInvalidAccessorTree(): never {\n\t\tthrow new BindingError(\n\t\t\t`The accessor tree does not correspond to the MarkerTree. This should absolutely never happen.`,\n\t\t)\n\t}\n\n\tpublic static resolveAndPrepareEntityToConnect(\n\t\ttreeStore: TreeStore,\n\t\tentityToConnect: EntityAccessor,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\tconst entityToConnectKey = entityToConnect.key\n\t\tif (!entityToConnectKey) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity without a key.`)\n\t\t}\n\t\tconst stateToConnect = treeStore.entityRealmStore.get(entityToConnectKey)\n\n\t\tif (stateToConnect === undefined) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity with key '${entityToConnectKey}' but it doesn't exist.`)\n\t\t}\n\t\t// TODO This is commented out for now in order to at least somewhat mitigate the limitations of dealing with\n\t\t// \t\tinverse relations. However, once that has been addressed systemically, this code needs to be re-enabled.\n\t\t// if (!stateToConnect.entity.id.existsOnServer) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Attempting to connect an entity with key '${stateToConnect.realmKey}' that ` +\n\t\t// \t\t\t`doesn't exist on server. That is currently impossible.`, // At least for now.\n\t\t// \t)\n\t\t// }\n\n\t\t// TODO\n\t\t// if (stateToConnect.entity.isScheduledForDeletion) {\n\t\t// \t// As far as the other realms are concerned, this entity is deleted. We don't want to just make it re-appear\n\t\t// \t// for them just because some other random relation decided to connect it.\n\t\t// \tstateToConnect.entity.realms.clear()\n\t\t// \tstateToConnect.entity.isScheduledForDeletion = false\n\t\t// }\n\n\t\treturn stateToConnect\n\t}\n\n\tpublic static changeEntityId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\tentity: EntityState,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst previousId = entity.id\n\n\t\ttreeStore.entityStore.delete(previousId.uniqueValue)\n\t\ttreeStore.entityStore.set(newId.uniqueValue, entity)\n\n\t\tlet counter = 0\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.changeRealmId(treeStore, eventManager, stateInitializer, realm, newId)\n\n\t\t\tif (++counter === entity.realms.size) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tentity.hasIdSetInStone = true\n\t\tentity.id = newId\n\t}\n\n\tpublic static changeRealmId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst oldEntity = realm.entity\n\t\tconst oldRealmKey = realm.realmKey\n\t\tconst oldId = oldEntity.id\n\n\t\tconst realmBlueprint = realm.blueprint\n\n\t\tconst newEntity = stateInitializer.initializeEntityState(newId, oldEntity.entityName)\n\t\tconst newRealmKey = RealmKeyGenerator.getRealmKey(newId, realmBlueprint)\n\n\t\trealm.realmKey = newRealmKey\n\t\trealm.entity = newEntity\n\n\t\t// This may still actually be necessary if we're going from a client to server generated uuid.\n\t\t// They both may have the same value but still be different.\n\t\tnewEntity.id = newId\n\t\toldEntity.realms.delete(oldRealmKey)\n\t\tnewEntity.realms.set(newRealmKey, realm)\n\n\t\tif (realm.type === 'entityRealm') {\n\t\t\tconst childIdState = realm.children.get(PRIMARY_KEY_NAME)\n\t\t\tif (childIdState?.type === 'field') {\n\t\t\t\tchildIdState.value = newId.value\n\t\t\t\teventManager.registerJustUpdated(childIdState, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\n\t\t\tthis.purgeStaleListenersAfterIdChange(realm)\n\t\t}\n\n\t\tif (oldEntity.realms.size === 0) {\n\t\t\ttreeStore.disposeOfEntity(oldEntity)\n\t\t}\n\n\t\ttreeStore.entityRealmStore.delete(oldRealmKey)\n\t\ttreeStore.entityRealmStore.set(newRealmKey, realm)\n\n\t\tif (realmBlueprint.type === 'listEntity') {\n\t\t\tconst list = realmBlueprint.parent\n\t\t\tlist.children.changeKey(oldId.value, newId.value) // 😎\n\t\t} else if (realmBlueprint.type === 'hasOne') {\n\t\t\teventManager.registerUpdatedConnection(realmBlueprint.parent, realmBlueprint.marker.placeholderName)\n\t\t}\n\t\tconst parent = realmBlueprint.parent\n\t\tif (parent) {\n\t\t\teventManager.registerJustUpdated(parent, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t\tif (realm.type === 'entityRealm') {\n\t\t\teventManager.registerJustUpdated(realm, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t}\n\n\tpublic static purgeStaleListenersAfterIdChange(realm: EntityRealmState) {\n\t\t// Version 1.\n\t\t// The listeners subscribed to a particular entity key so we no longer want to call these.\n\t\t// The only positionally associated listeners are in the blueprint so we re-initialize those.\n\t\t// realm.eventListeners = stateInitializer.initializeEntityEventListenerStore(realmBlueprint)\n\n\t\t// Version 2.\n\t\t// This is version two of this terrible hack. We want to preserve e.g. persistSuccess handlers.\n\n\t\t// Version 3.\n\t\t// The saga continues. We add a condition to exempt top-level realms. That way they can start\n\t\t// propagating changes from the top.\n\t\tconst listeners = realm.eventListeners\n\t\tif (listeners) {\n\t\t\tif (realm.blueprint.parent) {\n\t\t\t\tlisteners.delete({ type: 'update' })\n\t\t\t}\n\t\t\tlisteners.deleteByType('connectionUpdate')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAUO,MAAM,kBAAkB;AAAA,EAC9B,OAAc,4BAAmC;AAChD,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,OAAc,iCACb,WACA,iBAC0C;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IAC5C;AAEA,QAAI,UAAU,OAAO,SAAS,GAAG;AAChC,gBAAU,gBAAgB,SAAS;AAAA,IACpC;AAEA,cAAU,iBAAiB,OAAO,WAAW;AAC7C,cAAU,iBAAiB,IAAI,aAAa,KAAK;AAEjD,QAAI,eAAe,SAAS,cAAc;AACzC,YAAM,OAAO,eAAe;AAC5B,WAAK,SAAS,UAAU,MAAM,OAAO,MAAM,KAAK;AAAA,IACjD,WAAW,eAAe,SAAS,UAAU;AAC5C,mBAAa,0BAA0B,eAAe,QAAQ,eAAe,OAAO,eAAe;AAAA,IACpG;AACA,UAAM,SAAS,eAAe;AAC9B,QAAI,QAAQ;AACX,mBAAa,oBAAoB,QAAQ,aAAa,qBAAqB;AAAA,IAC5E;AACA,QAAI,MAAM,SAAS,eAAe;AACjC,mBAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,IAC3E;AAAA,EACD;AAAA,EAEA,OAAc,iCAAiC,OAAyB;AAYvE,UAAM,YAAY,MAAM;AACxB,QAAI,WAAW;AACd,UAAI,MAAM,UAAU,QAAQ;AAC3B,kBAAU,OAAO,EAAE,MAAM,SAAA,CAAU;AAAA,MACpC;AACA,gBAAU,aAAa,kBAAkB;AAAA,IAC1C;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"OperationsHelpers.js","sources":["../../../../../../packages/binding-legacy/src/core/operations/OperationsHelpers.ts"],"sourcesContent":["import type { EntityAccessor } from '@contember/binding-common'\nimport type { RuntimeId } from '@contember/binding-common'\nimport { BindingError } from '@contember/binding-common'\nimport { PRIMARY_KEY_NAME } from '@contember/binding-common'\nimport { EventManager } from '../EventManager.js'\nimport { RealmKeyGenerator } from '../RealmKeyGenerator.js'\nimport type { EntityRealmState, EntityRealmStateStub, EntityState } from '../state/index.js'\nimport type { StateInitializer } from '../StateInitializer.js'\nimport type { TreeStore } from '../TreeStore.js'\n\nexport class OperationsHelpers {\n\tpublic static rejectInvalidAccessorTree(): never {\n\t\tthrow new BindingError(\n\t\t\t`The accessor tree does not correspond to the MarkerTree. This should absolutely never happen.`,\n\t\t)\n\t}\n\n\tpublic static resolveAndPrepareEntityToConnect(\n\t\ttreeStore: TreeStore,\n\t\tentityToConnect: EntityAccessor,\n\t): EntityRealmState | EntityRealmStateStub {\n\t\tconst entityToConnectKey = entityToConnect.key\n\t\tif (!entityToConnectKey) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity without a key.`)\n\t\t}\n\t\tconst stateToConnect = treeStore.entityRealmStore.get(entityToConnectKey)\n\n\t\tif (stateToConnect === undefined) {\n\t\t\tthrow new BindingError(`Attempting to connect an entity with key '${entityToConnectKey}' but it doesn't exist.`)\n\t\t}\n\t\t// TODO This is commented out for now in order to at least somewhat mitigate the limitations of dealing with\n\t\t// \t\tinverse relations. However, once that has been addressed systemically, this code needs to be re-enabled.\n\t\t// if (!stateToConnect.entity.id.existsOnServer) {\n\t\t// \tthrow new BindingError(\n\t\t// \t\t`Attempting to connect an entity with key '${stateToConnect.realmKey}' that ` +\n\t\t// \t\t\t`doesn't exist on server. That is currently impossible.`, // At least for now.\n\t\t// \t)\n\t\t// }\n\n\t\t// TODO\n\t\t// if (stateToConnect.entity.isScheduledForDeletion) {\n\t\t// \t// As far as the other realms are concerned, this entity is deleted. We don't want to just make it re-appear\n\t\t// \t// for them just because some other random relation decided to connect it.\n\t\t// \tstateToConnect.entity.realms.clear()\n\t\t// \tstateToConnect.entity.isScheduledForDeletion = false\n\t\t// }\n\n\t\treturn stateToConnect\n\t}\n\n\tpublic static changeEntityId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\tentity: EntityState,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst previousId = entity.id\n\n\t\ttreeStore.entityStore.delete(previousId.uniqueValue)\n\t\ttreeStore.entityStore.set(newId.uniqueValue, entity)\n\n\t\tlet counter = 0\n\t\tfor (const realm of entity.realms.values()) {\n\t\t\tthis.changeRealmId(treeStore, eventManager, stateInitializer, realm, newId)\n\n\t\t\tif (++counter === entity.realms.size) {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tentity.hasIdSetInStone = true\n\t\tentity.id = newId\n\t}\n\n\tpublic static changeRealmId(\n\t\ttreeStore: TreeStore,\n\t\teventManager: EventManager,\n\t\tstateInitializer: StateInitializer,\n\t\trealm: EntityRealmState | EntityRealmStateStub,\n\t\tnewId: RuntimeId,\n\t) {\n\t\tconst oldEntity = realm.entity\n\t\tconst oldRealmKey = realm.realmKey\n\t\tconst oldId = oldEntity.id\n\n\t\tconst realmBlueprint = realm.blueprint\n\n\t\tconst newEntity = stateInitializer.initializeEntityState(newId, oldEntity.entityName)\n\t\tconst newRealmKey = RealmKeyGenerator.getRealmKey(newId, realmBlueprint)\n\n\t\trealm.realmKey = newRealmKey\n\t\trealm.entity = newEntity\n\n\t\t// This may still actually be necessary if we're going from a client to server generated uuid.\n\t\t// They both may have the same value but still be different.\n\t\tnewEntity.id = newId\n\t\toldEntity.realms.delete(oldRealmKey)\n\t\tnewEntity.realms.set(newRealmKey, realm)\n\n\t\tif (realm.type === 'entityRealm') {\n\t\t\tconst childIdState = realm.children.get(PRIMARY_KEY_NAME)\n\t\t\tif (childIdState?.type === 'field') {\n\t\t\t\tchildIdState.value = newId.value\n\t\t\t\teventManager.registerJustUpdated(childIdState, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t\t}\n\n\t\t\tthis.purgeStaleListenersAfterIdChange(realm)\n\t\t}\n\n\t\tif (oldEntity.realms.size === 0) {\n\t\t\ttreeStore.disposeOfEntity(oldEntity)\n\t\t}\n\n\t\ttreeStore.entityRealmStore.delete(oldRealmKey)\n\t\ttreeStore.entityRealmStore.set(newRealmKey, realm)\n\n\t\tif (realmBlueprint.type === 'listEntity') {\n\t\t\tconst list = realmBlueprint.parent\n\t\t\tlist.children.changeKey(oldId.value, newId.value) // 😎\n\t\t} else if (realmBlueprint.type === 'hasOne') {\n\t\t\teventManager.registerUpdatedConnection(realmBlueprint.parent, realmBlueprint.marker.placeholderName)\n\t\t}\n\t\tconst parent = realmBlueprint.parent\n\t\tif (parent) {\n\t\t\teventManager.registerJustUpdated(parent, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t\tif (realm.type === 'entityRealm') {\n\t\t\teventManager.registerJustUpdated(realm, EventManager.NO_CHANGES_DIFFERENCE)\n\t\t}\n\t}\n\n\tpublic static purgeStaleListenersAfterIdChange(realm: EntityRealmState) {\n\t\t// Version 1.\n\t\t// The listeners subscribed to a particular entity key so we no longer want to call these.\n\t\t// The only positionally associated listeners are in the blueprint so we re-initialize those.\n\t\t// realm.eventListeners = stateInitializer.initializeEntityEventListenerStore(realmBlueprint)\n\n\t\t// Version 2.\n\t\t// This is version two of this terrible hack. We want to preserve e.g. persistSuccess handlers.\n\n\t\t// Version 3.\n\t\t// The saga continues. We add a condition to exempt top-level realms. That way they can start\n\t\t// propagating changes from the top.\n\t\tconst listeners = realm.eventListeners\n\t\tif (listeners) {\n\t\t\tif (realm.blueprint.parent) {\n\t\t\t\tlisteners.delete({ type: 'update' })\n\t\t\t}\n\t\t\tlisteners.deleteByType('connectionUpdate')\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;AAUO,MAAM,kBAAkB;AAAA,EAC9B,OAAc,4BAAmC;AAChD,UAAM,IAAI;AAAA,MACT;AAAA,IAAA;AAAA,EAEF;AAAA,EAEA,OAAc,iCACb,WACA,iBAC0C;AAC1C,UAAM,qBAAqB,gBAAgB;AAC3C,QAAI,CAAC,oBAAoB;AACxB,YAAM,IAAI,aAAa,gDAAgD;AAAA,IACxE;AACA,UAAM,iBAAiB,UAAU,iBAAiB,IAAI,kBAAkB;AAExE,QAAI,mBAAmB,QAAW;AACjC,YAAM,IAAI,aAAa,6CAA6C,kBAAkB,yBAAyB;AAAA,IAChH;AAkBA,WAAO;AAAA,EACR;AAAA,EAEA,OAAc,eACb,WACA,cACA,kBACA,QACA,OACC;AACD,UAAM,aAAa,OAAO;AAE1B,cA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,eAAe;AAAA,IACpG;AACA,UAAM,SAAS,eAAe;AAC9B,QAAI,QAAQ;AACX,mBAAa,oBAAoB,QAAQ,aAAa,qBAAqB;AAAA,IAC5E;AACA,QAAI,MAAM,SAAS,eAAe;AACjC,mBAAa,oBAAoB,OAAO,aAAa,qBAAqB;AAAA,IAC3E;AAAA,EACD;AAAA,EAEA,OAAc,iCAAiC,OAAyB;AAYvE,UAAM,YAAY,MAAM;AACxB,QAAI,WAAW;AACd,UAAI,MAAM,UAAU,QAAQ;AAC3B,kBAAU,OAAO,EAAE,MAAM,SAAA,CAAU;AAAA,MACpC;AACA,gBAAU,aAAa,kBAAkB;AAAA,IAC1C;AAAA,EACD;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"StateIterator.cjs","sources":["../../../../../../packages/binding-legacy/src/core/state/StateIterator.ts"],"sourcesContent":["import type { FieldValue, PlaceholderName } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport type { TreeStore } from '../TreeStore'\nimport type { EntityListState } from './EntityListState'\nimport type { EntityRealmState } from './EntityRealmState'\nimport type { FieldState } from './FieldState'\nimport { getEntityMarker } from './getEntityMarker'\nimport type { RootStateNode, StateINode, StateNode } from './StateNode'\n\nexport class StateIterator {\n\tpublic static *eachSiblingRealm(\n\t\tstate: EntityRealmState,\n\t\trelevantPlaceholder?: PlaceholderName,\n\t): IterableIterator<EntityRealmState> {\n\t\tfor (let [realmKey, realm] of state.entity.realms) {\n\t\t\tif (realm.type === 'entityRealmStub') {\n\t\t\t\tif (relevantPlaceholder === undefined || getEntityMarker(realm).fields.placeholders.has(relevantPlaceholder)) {\n\t\t\t\t\trealm.getAccessor()\n\t\t\t\t\trealm = state.entity.realms.get(realmKey) as EntityRealmState\n\t\t\t\t} else {\n\t\t\t\t\t// This realm is irrelevant. No need to force-initialize it.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield realm\n\t\t}\n\t}\n\n\t// Note that this only yields siblings with the same placeholderName!\n\tpublic static *eachSiblingRealmChild<Value extends FieldValue, S extends EntityListState | FieldState<Value>>(\n\t\ttreeStore: TreeStore,\n\t\tstate: S & StateNode<Value>,\n\t): IterableIterator<S> {\n\t\tif (state.type === 'entityList' && state.blueprint.parent === undefined) {\n\t\t\t// Top-level entity list\n\t\t\tfor (const [, rootStates] of treeStore.subTreeStatesByRoot) {\n\t\t\t\tconst rootList = rootStates.get(state.blueprint.marker.placeholderName)\n\t\t\t\tif (rootList?.type === 'entityList') {\n\t\t\t\t\tyield rootList as S\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet closestEntityRealm: EntityRealmState\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (state.type === 'field') {\n\t\t\tclosestEntityRealm = state.parent\n\t\t\tplaceholderName = state.placeholderName\n\t\t} else if (state.type === 'entityList') {\n\t\t\tclosestEntityRealm = state.blueprint.parent! // The parent-less case is handled above. Hence the assertion.\n\t\t\tplaceholderName = state.blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(state)\n\t\t}\n\n\t\tfor (const realm of this.eachSiblingRealm(closestEntityRealm, placeholderName)) {\n\t\t\tconst child = realm.children.get(placeholderName)\n\t\t\tif (child === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.type === state.type) {\n\t\t\t\tyield child as S\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static *depthFirstAllNodes(root: StateNode): IterableIterator<StateNode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tswitch (childState.type) {\n\t\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tyield* this.depthFirstAllNodes(childState)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn assertNever(childState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'field':\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tyield root\n\t}\n\n\tpublic static *depthFirstINodes(\n\t\troot: StateINode,\n\t\tmatch?: (iNode: StateINode) => boolean,\n\t): IterableIterator<StateINode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tif (childState.type === 'entityRealm' || childState.type === 'entityList') {\n\t\t\t\t\t\tyield* this.depthFirstINodes(childState, match)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tif (match === undefined || match(root)) {\n\t\t\tyield root\n\t\t}\n\t}\n\n\tpublic static *eachRootState(treeStore: TreeStore): IterableIterator<[PlaceholderName, RootStateNode]> {\n\t\tfor (const rootStates of treeStore.subTreeStatesByRoot.values()) {\n\t\t\tyield* rootStates.entries()\n\t\t}\n\t}\n}\n"],"names":["getEntityMarker","assertNever"],"mappings":";;;;AASO,MAAM,cAAc;AAAA,EAC1B,QAAe,iBACd,OACA,qBACqC;AACrC,aAAS,CAAC,UAAU,KAAK,KAAK,MAAM,OAAO,QAAQ;AAClD,UAAI,MAAM,SAAS,mBAAmB;AACrC,YAAI,wBAAwB,UAAaA,gBAAAA,gBAAgB,KAAK,EAAE,OAAO,aAAa,IAAI,mBAAmB,GAAG;AAC7G,gBAAM,YAAA;AACN,kBAAQ,MAAM,OAAO,OAAO,IAAI,QAAQ;AAAA,QACzC,OAAO;AAEN;AAAA,QACD;AAAA,MACD;AACA,YAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA,EAGA,QAAe,sBACd,WACA,OACsB;AACtB,QAAI,MAAM,SAAS,gBA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MACL,KAAK;AACJ,mBAAW,cAAc,KAAK,SAAS,OAAA,GAAU;AAChD,cAAI,WAAW,SAAS,iBAAiB,WAAW,SAAS,cAAc;AAC1E,mBAAO,KAAK,iBAAiB,YAAY,KAAK;AAAA,UAC/C;AAAA,QACD;AACA;AAAA,MACD;AACC,eAAOA,cAAAA,YAAY,IAAI;AAAA,IAAA;AAEzB,QAAI,UAAU,UAAa,MAAM,IAAI,GAAG;AACvC,YAAM;AAAA,IACP;AAAA,EACD;AAAA,EAEA,QAAe,cAAc,WAA0E;AACtG,eAAW,cAAc,UAAU,oBAAoB,OAAA,GAAU;AAChE,aAAO,WAAW,QAAA;AAAA,IACnB;AAAA,EACD;AACD;;"}
1
+ {"version":3,"file":"StateIterator.cjs","sources":["../../../../../../packages/binding-legacy/src/core/state/StateIterator.ts"],"sourcesContent":["import type { FieldValue, PlaceholderName } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport type { TreeStore } from '../TreeStore.js'\nimport type { EntityListState } from './EntityListState.js'\nimport type { EntityRealmState } from './EntityRealmState.js'\nimport type { FieldState } from './FieldState.js'\nimport { getEntityMarker } from './getEntityMarker.js'\nimport type { RootStateNode, StateINode, StateNode } from './StateNode.js'\n\nexport class StateIterator {\n\tpublic static *eachSiblingRealm(\n\t\tstate: EntityRealmState,\n\t\trelevantPlaceholder?: PlaceholderName,\n\t): IterableIterator<EntityRealmState> {\n\t\tfor (let [realmKey, realm] of state.entity.realms) {\n\t\t\tif (realm.type === 'entityRealmStub') {\n\t\t\t\tif (relevantPlaceholder === undefined || getEntityMarker(realm).fields.placeholders.has(relevantPlaceholder)) {\n\t\t\t\t\trealm.getAccessor()\n\t\t\t\t\trealm = state.entity.realms.get(realmKey) as EntityRealmState\n\t\t\t\t} else {\n\t\t\t\t\t// This realm is irrelevant. No need to force-initialize it.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield realm\n\t\t}\n\t}\n\n\t// Note that this only yields siblings with the same placeholderName!\n\tpublic static *eachSiblingRealmChild<Value extends FieldValue, S extends EntityListState | FieldState<Value>>(\n\t\ttreeStore: TreeStore,\n\t\tstate: S & StateNode<Value>,\n\t): IterableIterator<S> {\n\t\tif (state.type === 'entityList' && state.blueprint.parent === undefined) {\n\t\t\t// Top-level entity list\n\t\t\tfor (const [, rootStates] of treeStore.subTreeStatesByRoot) {\n\t\t\t\tconst rootList = rootStates.get(state.blueprint.marker.placeholderName)\n\t\t\t\tif (rootList?.type === 'entityList') {\n\t\t\t\t\tyield rootList as S\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet closestEntityRealm: EntityRealmState\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (state.type === 'field') {\n\t\t\tclosestEntityRealm = state.parent\n\t\t\tplaceholderName = state.placeholderName\n\t\t} else if (state.type === 'entityList') {\n\t\t\tclosestEntityRealm = state.blueprint.parent! // The parent-less case is handled above. Hence the assertion.\n\t\t\tplaceholderName = state.blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(state)\n\t\t}\n\n\t\tfor (const realm of this.eachSiblingRealm(closestEntityRealm, placeholderName)) {\n\t\t\tconst child = realm.children.get(placeholderName)\n\t\t\tif (child === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.type === state.type) {\n\t\t\t\tyield child as S\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static *depthFirstAllNodes(root: StateNode): IterableIterator<StateNode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tswitch (childState.type) {\n\t\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tyield* this.depthFirstAllNodes(childState)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn assertNever(childState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'field':\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tyield root\n\t}\n\n\tpublic static *depthFirstINodes(\n\t\troot: StateINode,\n\t\tmatch?: (iNode: StateINode) => boolean,\n\t): IterableIterator<StateINode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tif (childState.type === 'entityRealm' || childState.type === 'entityList') {\n\t\t\t\t\t\tyield* this.depthFirstINodes(childState, match)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tif (match === undefined || match(root)) {\n\t\t\tyield root\n\t\t}\n\t}\n\n\tpublic static *eachRootState(treeStore: TreeStore): IterableIterator<[PlaceholderName, RootStateNode]> {\n\t\tfor (const rootStates of treeStore.subTreeStatesByRoot.values()) {\n\t\t\tyield* rootStates.entries()\n\t\t}\n\t}\n}\n"],"names":["getEntityMarker","assertNever"],"mappings":";;;;AASO,MAAM,cAAc;AAAA,EAC1B,QAAe,iBACd,OACA,qBACqC;AACrC,aAAS,CAAC,UAAU,KAAK,KAAK,MAAM,OAAO,QAAQ;AAClD,UAAI,MAAM,SAAS,mBAAmB;AACrC,YAAI,wBAAwB,UAAaA,gBAAAA,gBAAgB,KAAK,EAAE,OAAO,aAAa,IAAI,mBAAmB,GAAG;AAC7G,gBAAM,YAAA;AACN,kBAAQ,MAAM,OAAO,OAAO,IAAI,QAAQ;AAAA,QACzC,OAAO;AAEN;AAAA,QACD;AAAA,MACD;AACA,YAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA,EAGA,QAAe,sBACd,WACA,OACsB;AACtB,QAAI,MAAM,SAAS,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AA,MACL,KAAK;AACJ,mBAAW,cAAc,KAAK,SAAS,OAAA,GAAU;AAChD,cAAI,WAAW,SAAS,iBAAiB,WAAW,SAAS,cAAc;AAC1E,mBAAO,KAAK,iBAAiB,YAAY,KAAK;AAAA,UAC/C;AAAA,QACD;AACA;AAAA,MACD;AACC,eAAOA,cAAAA,YAAY,IAAI;AAAA,IAAA;AAEzB,QAAI,UAAU,UAAa,MAAM,IAAI,GAAG;AACvC,YAAM;AAAA,IACP;AAAA,EACD;AAAA,EAEA,QAAe,cAAc,WAA0E;AACtG,eAAW,cAAc,UAAU,oBAAoB,OAAA,GAAU;AAChE,aAAO,WAAW,QAAA;AAAA,IACnB;AAAA,EACD;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"StateIterator.js","sources":["../../../../../../packages/binding-legacy/src/core/state/StateIterator.ts"],"sourcesContent":["import type { FieldValue, PlaceholderName } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport type { TreeStore } from '../TreeStore'\nimport type { EntityListState } from './EntityListState'\nimport type { EntityRealmState } from './EntityRealmState'\nimport type { FieldState } from './FieldState'\nimport { getEntityMarker } from './getEntityMarker'\nimport type { RootStateNode, StateINode, StateNode } from './StateNode'\n\nexport class StateIterator {\n\tpublic static *eachSiblingRealm(\n\t\tstate: EntityRealmState,\n\t\trelevantPlaceholder?: PlaceholderName,\n\t): IterableIterator<EntityRealmState> {\n\t\tfor (let [realmKey, realm] of state.entity.realms) {\n\t\t\tif (realm.type === 'entityRealmStub') {\n\t\t\t\tif (relevantPlaceholder === undefined || getEntityMarker(realm).fields.placeholders.has(relevantPlaceholder)) {\n\t\t\t\t\trealm.getAccessor()\n\t\t\t\t\trealm = state.entity.realms.get(realmKey) as EntityRealmState\n\t\t\t\t} else {\n\t\t\t\t\t// This realm is irrelevant. No need to force-initialize it.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield realm\n\t\t}\n\t}\n\n\t// Note that this only yields siblings with the same placeholderName!\n\tpublic static *eachSiblingRealmChild<Value extends FieldValue, S extends EntityListState | FieldState<Value>>(\n\t\ttreeStore: TreeStore,\n\t\tstate: S & StateNode<Value>,\n\t): IterableIterator<S> {\n\t\tif (state.type === 'entityList' && state.blueprint.parent === undefined) {\n\t\t\t// Top-level entity list\n\t\t\tfor (const [, rootStates] of treeStore.subTreeStatesByRoot) {\n\t\t\t\tconst rootList = rootStates.get(state.blueprint.marker.placeholderName)\n\t\t\t\tif (rootList?.type === 'entityList') {\n\t\t\t\t\tyield rootList as S\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet closestEntityRealm: EntityRealmState\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (state.type === 'field') {\n\t\t\tclosestEntityRealm = state.parent\n\t\t\tplaceholderName = state.placeholderName\n\t\t} else if (state.type === 'entityList') {\n\t\t\tclosestEntityRealm = state.blueprint.parent! // The parent-less case is handled above. Hence the assertion.\n\t\t\tplaceholderName = state.blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(state)\n\t\t}\n\n\t\tfor (const realm of this.eachSiblingRealm(closestEntityRealm, placeholderName)) {\n\t\t\tconst child = realm.children.get(placeholderName)\n\t\t\tif (child === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.type === state.type) {\n\t\t\t\tyield child as S\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static *depthFirstAllNodes(root: StateNode): IterableIterator<StateNode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tswitch (childState.type) {\n\t\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tyield* this.depthFirstAllNodes(childState)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn assertNever(childState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'field':\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tyield root\n\t}\n\n\tpublic static *depthFirstINodes(\n\t\troot: StateINode,\n\t\tmatch?: (iNode: StateINode) => boolean,\n\t): IterableIterator<StateINode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tif (childState.type === 'entityRealm' || childState.type === 'entityList') {\n\t\t\t\t\t\tyield* this.depthFirstINodes(childState, match)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tif (match === undefined || match(root)) {\n\t\t\tyield root\n\t\t}\n\t}\n\n\tpublic static *eachRootState(treeStore: TreeStore): IterableIterator<[PlaceholderName, RootStateNode]> {\n\t\tfor (const rootStates of treeStore.subTreeStatesByRoot.values()) {\n\t\t\tyield* rootStates.entries()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AASO,MAAM,cAAc;AAAA,EAC1B,QAAe,iBACd,OACA,qBACqC;AACrC,aAAS,CAAC,UAAU,KAAK,KAAK,MAAM,OAAO,QAAQ;AAClD,UAAI,MAAM,SAAS,mBAAmB;AACrC,YAAI,wBAAwB,UAAa,gBAAgB,KAAK,EAAE,OAAO,aAAa,IAAI,mBAAmB,GAAG;AAC7G,gBAAM,YAAA;AACN,kBAAQ,MAAM,OAAO,OAAO,IAAI,QAAQ;AAAA,QACzC,OAAO;AAEN;AAAA,QACD;AAAA,MACD;AACA,YAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA,EAGA,QAAe,sBACd,WACA,OACsB;AACtB,QAAI,MAAM,SAAS,gBAAgB,MAAM,UAAU,WAAW,Q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AAU;AAChD,cAAI,WAAW,SAAS,iBAAiB,WAAW,SAAS,cAAc;AAC1E,mBAAO,KAAK,iBAAiB,YAAY,KAAK;AAAA,UAC/C;AAAA,QACD;AACA;AAAA,MACD;AACC,eAAO,YAAY,IAAI;AAAA,IAAA;AAEzB,QAAI,UAAU,UAAa,MAAM,IAAI,GAAG;AACvC,YAAM;AAAA,IACP;AAAA,EACD;AAAA,EAEA,QAAe,cAAc,WAA0E;AACtG,eAAW,cAAc,UAAU,oBAAoB,OAAA,GAAU;AAChE,aAAO,WAAW,QAAA;AAAA,IACnB;AAAA,EACD;AACD;"}
1
+ {"version":3,"file":"StateIterator.js","sources":["../../../../../../packages/binding-legacy/src/core/state/StateIterator.ts"],"sourcesContent":["import type { FieldValue, PlaceholderName } from '@contember/binding-common'\nimport { assertNever } from '@contember/binding-common'\nimport type { TreeStore } from '../TreeStore.js'\nimport type { EntityListState } from './EntityListState.js'\nimport type { EntityRealmState } from './EntityRealmState.js'\nimport type { FieldState } from './FieldState.js'\nimport { getEntityMarker } from './getEntityMarker.js'\nimport type { RootStateNode, StateINode, StateNode } from './StateNode.js'\n\nexport class StateIterator {\n\tpublic static *eachSiblingRealm(\n\t\tstate: EntityRealmState,\n\t\trelevantPlaceholder?: PlaceholderName,\n\t): IterableIterator<EntityRealmState> {\n\t\tfor (let [realmKey, realm] of state.entity.realms) {\n\t\t\tif (realm.type === 'entityRealmStub') {\n\t\t\t\tif (relevantPlaceholder === undefined || getEntityMarker(realm).fields.placeholders.has(relevantPlaceholder)) {\n\t\t\t\t\trealm.getAccessor()\n\t\t\t\t\trealm = state.entity.realms.get(realmKey) as EntityRealmState\n\t\t\t\t} else {\n\t\t\t\t\t// This realm is irrelevant. No need to force-initialize it.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t}\n\t\t\tyield realm\n\t\t}\n\t}\n\n\t// Note that this only yields siblings with the same placeholderName!\n\tpublic static *eachSiblingRealmChild<Value extends FieldValue, S extends EntityListState | FieldState<Value>>(\n\t\ttreeStore: TreeStore,\n\t\tstate: S & StateNode<Value>,\n\t): IterableIterator<S> {\n\t\tif (state.type === 'entityList' && state.blueprint.parent === undefined) {\n\t\t\t// Top-level entity list\n\t\t\tfor (const [, rootStates] of treeStore.subTreeStatesByRoot) {\n\t\t\t\tconst rootList = rootStates.get(state.blueprint.marker.placeholderName)\n\t\t\t\tif (rootList?.type === 'entityList') {\n\t\t\t\t\tyield rootList as S\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn\n\t\t}\n\n\t\tlet closestEntityRealm: EntityRealmState\n\t\tlet placeholderName: PlaceholderName\n\n\t\tif (state.type === 'field') {\n\t\t\tclosestEntityRealm = state.parent\n\t\t\tplaceholderName = state.placeholderName\n\t\t} else if (state.type === 'entityList') {\n\t\t\tclosestEntityRealm = state.blueprint.parent! // The parent-less case is handled above. Hence the assertion.\n\t\t\tplaceholderName = state.blueprint.marker.placeholderName\n\t\t} else {\n\t\t\treturn assertNever(state)\n\t\t}\n\n\t\tfor (const realm of this.eachSiblingRealm(closestEntityRealm, placeholderName)) {\n\t\t\tconst child = realm.children.get(placeholderName)\n\t\t\tif (child === undefined) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (child.type === state.type) {\n\t\t\t\tyield child as S\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static *depthFirstAllNodes(root: StateNode): IterableIterator<StateNode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tswitch (childState.type) {\n\t\t\t\t\t\tcase 'field':\n\t\t\t\t\t\tcase 'entityRealm':\n\t\t\t\t\t\tcase 'entityList':\n\t\t\t\t\t\t\tyield* this.depthFirstAllNodes(childState)\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tcase 'entityRealmStub':\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\treturn assertNever(childState)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tcase 'field':\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tyield root\n\t}\n\n\tpublic static *depthFirstINodes(\n\t\troot: StateINode,\n\t\tmatch?: (iNode: StateINode) => boolean,\n\t): IterableIterator<StateINode> {\n\t\tswitch (root.type) {\n\t\t\tcase 'entityRealm':\n\t\t\tcase 'entityList':\n\t\t\t\tfor (const childState of root.children.values()) {\n\t\t\t\t\tif (childState.type === 'entityRealm' || childState.type === 'entityList') {\n\t\t\t\t\t\tyield* this.depthFirstINodes(childState, match)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\tdefault:\n\t\t\t\treturn assertNever(root)\n\t\t}\n\t\tif (match === undefined || match(root)) {\n\t\t\tyield root\n\t\t}\n\t}\n\n\tpublic static *eachRootState(treeStore: TreeStore): IterableIterator<[PlaceholderName, RootStateNode]> {\n\t\tfor (const rootStates of treeStore.subTreeStatesByRoot.values()) {\n\t\t\tyield* rootStates.entries()\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;AASO,MAAM,cAAc;AAAA,EAC1B,QAAe,iBACd,OACA,qBACqC;AACrC,aAAS,CAAC,UAAU,KAAK,KAAK,MAAM,OAAO,QAAQ;AAClD,UAAI,MAAM,SAAS,mBAAmB;AACrC,YAAI,wBAAwB,UAAa,gBAAgB,KAAK,EAAE,OAAO,aAAa,IAAI,mBAAmB,GAAG;AAC7G,gBAAM,YAAA;AACN,kBAAQ,MAAM,OAAO,OAAO,IAAI,QAAQ;AAAA,QACzC,OAAO;AAEN;AAAA,QACD;AAAA,MACD;AACA,YAAM;AAAA,IACP;AAAA,EACD;AAAA;AAAA,EAGA,QAAe,sBACd,WACA,OACsB;AACtB,QAAI,MAAM,SAAS,gBAAgB,MAAM,UAAU,WAAW,QAAW;AAExE,iBAAW,CAAA,EAAG,UAAU,KAAK,UAAU,qBAAqB;AAC3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,mBAAO,KAAK,iBAAiB,YAAY,KAAK;AAAA,UAC/C;AAAA,QACD;AACA;AAAA,MACD;AACC,eAAO,YAAY,IAAI;AAAA,IAAA;AAEzB,QAAI,UAAU,UAAa,MAAM,IAAI,GAAG;AACvC,YAAM;AAAA,IACP;AAAA,EACD;AAAA,EAEA,QAAe,cAAc,WAA0E;AACtG,eAAW,cAAc,UAAU,oBAAoB,OAAA,GAAU;AAChE,aAAO,WAAW,QAAA;AAAA,IACnB;AAAA,EACD;AACD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getEntityMarker.cjs","sources":["../../../../../../packages/binding-legacy/src/core/state/getEntityMarker.ts"],"sourcesContent":["import type { EntityRealmState, EntityRealmStateStub } from './EntityRealmState'\n\nexport const getEntityMarker = (realm: EntityRealmState | EntityRealmStateStub) =>\n\trealm.blueprint.type === 'listEntity' ? realm.blueprint.parent.blueprint.marker : realm.blueprint.marker\n"],"names":[],"mappings":";;AAEO,MAAM,kBAAkB,CAAC,UAC/B,MAAM,UAAU,SAAS,eAAe,MAAM,UAAU,OAAO,UAAU,SAAS,MAAM,UAAU;;"}
1
+ {"version":3,"file":"getEntityMarker.cjs","sources":["../../../../../../packages/binding-legacy/src/core/state/getEntityMarker.ts"],"sourcesContent":["import type { EntityRealmState, EntityRealmStateStub } from './EntityRealmState.js'\n\nexport const getEntityMarker = (realm: EntityRealmState | EntityRealmStateStub) =>\n\trealm.blueprint.type === 'listEntity' ? realm.blueprint.parent.blueprint.marker : realm.blueprint.marker\n"],"names":[],"mappings":";;AAEO,MAAM,kBAAkB,CAAC,UAC/B,MAAM,UAAU,SAAS,eAAe,MAAM,UAAU,OAAO,UAAU,SAAS,MAAM,UAAU;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getEntityMarker.js","sources":["../../../../../../packages/binding-legacy/src/core/state/getEntityMarker.ts"],"sourcesContent":["import type { EntityRealmState, EntityRealmStateStub } from './EntityRealmState'\n\nexport const getEntityMarker = (realm: EntityRealmState | EntityRealmStateStub) =>\n\trealm.blueprint.type === 'listEntity' ? realm.blueprint.parent.blueprint.marker : realm.blueprint.marker\n"],"names":[],"mappings":"AAEO,MAAM,kBAAkB,CAAC,UAC/B,MAAM,UAAU,SAAS,eAAe,MAAM,UAAU,OAAO,UAAU,SAAS,MAAM,UAAU;"}
1
+ {"version":3,"file":"getEntityMarker.js","sources":["../../../../../../packages/binding-legacy/src/core/state/getEntityMarker.ts"],"sourcesContent":["import type { EntityRealmState, EntityRealmStateStub } from './EntityRealmState.js'\n\nexport const getEntityMarker = (realm: EntityRealmState | EntityRealmStateStub) =>\n\trealm.blueprint.type === 'listEntity' ? realm.blueprint.parent.blueprint.marker : realm.blueprint.marker\n"],"names":[],"mappings":"AAEO,MAAM,kBAAkB,CAAC,UAC/B,MAAM,UAAU,SAAS,eAAe,MAAM,UAAU,OAAO,UAAU,SAAS,MAAM,UAAU;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TemporalFieldHelper.cjs","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t// public setToDate() TODO\n\t// public setToTime() TODO\n\t// public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":["FieldHelper","TemporalFieldHelper"],"mappings":";;;AAGA,MAAM,4BAA4BA,YAAAA,YAAoB;AAAA,EAC9C,SAAS,SAAuC;AACtD,SAAK,YAAA,EAAc,aAAY,oBAAI,QAAO,YAAA,GAAe,OAAO;AAAA,EACjE;AAAA;AAAA;AAAA;AAKD;AAAA,CACA,CAAUC,yBAAV;AACcA,uBAAA,WAAW,CACvB,OACA,YACI;AACJ,QAAIA,qBAAoB,KAAK,EAAE,SAAS,OAAO;AAAA,EAChD;AAAA,GANS,wBAAA,sBAAA,CAAA,EAAA;;"}
1
+ {"version":3,"file":"TemporalFieldHelper.cjs","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper.js'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t// public setToDate() TODO\n\t// public setToTime() TODO\n\t// public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":["FieldHelper","TemporalFieldHelper"],"mappings":";;;AAGA,MAAM,4BAA4BA,YAAAA,YAAoB;AAAA,EAC9C,SAAS,SAAuC;AACtD,SAAK,YAAA,EAAc,aAAY,oBAAI,QAAO,YAAA,GAAe,OAAO;AAAA,EACjE;AAAA;AAAA;AAAA;AAKD;AAAA,CACA,CAAUC,yBAAV;AACcA,uBAAA,WAAW,CACvB,OACA,YACI;AACJ,QAAIA,qBAAoB,KAAK,EAAE,SAAS,OAAO;AAAA,EAChD;AAAA,GANS,wBAAA,sBAAA,CAAA,EAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"TemporalFieldHelper.js","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t// public setToDate() TODO\n\t// public setToTime() TODO\n\t// public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":["TemporalFieldHelper"],"mappings":";AAGA,MAAM,4BAA4B,YAAoB;AAAA,EAC9C,SAAS,SAAuC;AACtD,SAAK,YAAA,EAAc,aAAY,oBAAI,QAAO,YAAA,GAAe,OAAO;AAAA,EACjE;AAAA;AAAA;AAAA;AAKD;AAAA,CACA,CAAUA,yBAAV;AACcA,uBAAA,WAAW,CACvB,OACA,YACI;AACJ,QAAIA,qBAAoB,KAAK,EAAE,SAAS,OAAO;AAAA,EAChD;AAAA,GANS,wBAAA,sBAAA,CAAA,EAAA;"}
1
+ {"version":3,"file":"TemporalFieldHelper.js","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/TemporalFieldHelper.ts"],"sourcesContent":["import type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper.js'\n\nclass TemporalFieldHelper extends FieldHelper<string> {\n\tpublic setToNow(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(new Date().toISOString(), options)\n\t}\n\n\t// public setToDate() TODO\n\t// public setToTime() TODO\n\t// public setToDateTime() TODO\n}\nnamespace TemporalFieldHelper {\n\texport const setToNow = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew TemporalFieldHelper(field).setToNow(options)\n\t}\n}\nexport { TemporalFieldHelper }\n"],"names":["TemporalFieldHelper"],"mappings":";AAGA,MAAM,4BAA4B,YAAoB;AAAA,EAC9C,SAAS,SAAuC;AACtD,SAAK,YAAA,EAAc,aAAY,oBAAI,QAAO,YAAA,GAAe,OAAO;AAAA,EACjE;AAAA;AAAA;AAAA;AAKD;AAAA,CACA,CAAUA,yBAAV;AACcA,uBAAA,WAAW,CACvB,OACA,YACI;AACJ,QAAIA,qBAAoB,KAAK,EAAE,SAAS,OAAO;AAAA,EAChD;AAAA,GANS,wBAAA,sBAAA,CAAA,EAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"UuidFieldHelper.cjs","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/UuidFieldHelper.ts"],"sourcesContent":["import { v4 as uuidV4 } from 'uuid'\nimport type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper'\n\nclass UuidFieldHelper extends FieldHelper<string> {\n\tpublic setToUuid(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(uuidV4(), options)\n\t}\n}\nnamespace UuidFieldHelper {\n\texport const setToUuid = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew UuidFieldHelper(field).setToUuid(options)\n\t}\n}\nexport { UuidFieldHelper }\n"],"names":["FieldHelper","uuidV4","UuidFieldHelper"],"mappings":";;;;AAIA,MAAM,wBAAwBA,YAAAA,YAAoB;AAAA,EAC1C,UAAU,SAAuC;AACvD,SAAK,YAAA,EAAc,YAAYC,KAAAA,GAAA,GAAU,OAAO;AAAA,EACjD;AACD;AAAA,CACA,CAAUC,qBAAV;AACcA,mBAAA,YAAY,CACxB,OACA,YACI;AACJ,QAAIA,iBAAgB,KAAK,EAAE,UAAU,OAAO;AAAA,EAC7C;AAAA,GANS,oBAAA,kBAAA,CAAA,EAAA;;"}
1
+ {"version":3,"file":"UuidFieldHelper.cjs","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/UuidFieldHelper.ts"],"sourcesContent":["import { v4 as uuidV4 } from 'uuid'\nimport type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper.js'\n\nclass UuidFieldHelper extends FieldHelper<string> {\n\tpublic setToUuid(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(uuidV4(), options)\n\t}\n}\nnamespace UuidFieldHelper {\n\texport const setToUuid = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew UuidFieldHelper(field).setToUuid(options)\n\t}\n}\nexport { UuidFieldHelper }\n"],"names":["FieldHelper","uuidV4","UuidFieldHelper"],"mappings":";;;;AAIA,MAAM,wBAAwBA,YAAAA,YAAoB;AAAA,EAC1C,UAAU,SAAuC;AACvD,SAAK,YAAA,EAAc,YAAYC,KAAAA,GAAA,GAAU,OAAO;AAAA,EACjD;AACD;AAAA,CACA,CAAUC,qBAAV;AACcA,mBAAA,YAAY,CACxB,OACA,YACI;AACJ,QAAIA,iBAAgB,KAAK,EAAE,UAAU,OAAO;AAAA,EAC7C;AAAA,GANS,oBAAA,kBAAA,CAAA,EAAA;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"UuidFieldHelper.js","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/UuidFieldHelper.ts"],"sourcesContent":["import { v4 as uuidV4 } from 'uuid'\nimport type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper'\n\nclass UuidFieldHelper extends FieldHelper<string> {\n\tpublic setToUuid(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(uuidV4(), options)\n\t}\n}\nnamespace UuidFieldHelper {\n\texport const setToUuid = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew UuidFieldHelper(field).setToUuid(options)\n\t}\n}\nexport { UuidFieldHelper }\n"],"names":["uuidV4","UuidFieldHelper"],"mappings":";;AAIA,MAAM,wBAAwB,YAAoB;AAAA,EAC1C,UAAU,SAAuC;AACvD,SAAK,YAAA,EAAc,YAAYA,GAAA,GAAU,OAAO;AAAA,EACjD;AACD;AAAA,CACA,CAAUC,qBAAV;AACcA,mBAAA,YAAY,CACxB,OACA,YACI;AACJ,QAAIA,iBAAgB,KAAK,EAAE,UAAU,OAAO;AAAA,EAC7C;AAAA,GANS,oBAAA,kBAAA,CAAA,EAAA;"}
1
+ {"version":3,"file":"UuidFieldHelper.js","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/UuidFieldHelper.ts"],"sourcesContent":["import { v4 as uuidV4 } from 'uuid'\nimport type { FieldAccessor } from '@contember/binding-common'\nimport { FieldHelper } from './FieldHelper.js'\n\nclass UuidFieldHelper extends FieldHelper<string> {\n\tpublic setToUuid(options?: FieldAccessor.UpdateOptions) {\n\t\tthis.getAccessor().updateValue(uuidV4(), options)\n\t}\n}\nnamespace UuidFieldHelper {\n\texport const setToUuid = (\n\t\tfield: FieldAccessor<string> | FieldAccessor.GetFieldAccessor<string>,\n\t\toptions?: FieldAccessor.UpdateOptions,\n\t) => {\n\t\tnew UuidFieldHelper(field).setToUuid(options)\n\t}\n}\nexport { UuidFieldHelper }\n"],"names":["uuidV4","UuidFieldHelper"],"mappings":";;AAIA,MAAM,wBAAwB,YAAoB;AAAA,EAC1C,UAAU,SAAuC;AACvD,SAAK,YAAA,EAAc,YAAYA,GAAA,GAAU,OAAO;AAAA,EACjD;AACD;AAAA,CACA,CAAUC,qBAAV;AACcA,mBAAA,YAAY,CACxB,OACA,YACI;AACJ,QAAIA,iBAAgB,KAAK,EAAE,UAAU,OAAO;AAAA,EAC7C;AAAA,GANS,oBAAA,kBAAA,CAAA,EAAA;"}
@@ -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''\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,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;AAC7B,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA;AAAA,EAIA,SAAS,OAAiD;AACzD,WAAO,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAAA,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEA,iBACC,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEA,aAAa,gBAA0D;AACtE,SAAK,WAAW,aAAa,KAAK,OAAO,cAAc;AAAA,EACxD;AAAA,EAEA,qBAAqB,OAA6C,iBAAuC;AACxG,UAAM,YAAYC,cAAAA,cAAc,4BAA4B,OAAO,KAAK,WAAW;AACnF,UAAM,aAAa,KAAK,UAAU;AAAA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A,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,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
+ {"version":3,"file":"EntityAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state/index.js'\nimport type { EntityOperations } from '../core/operations/index.js'\nimport { SingleEntityPersistedData } from '../accessorTree/index.js'\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,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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AAgB,YAAY;AAAA,EACzG;AAAA,EAEQ,4BAA4B,OAAe,aAA0B,gBAAqB,oBAAkC;AACnI,UAAM,OAAO,KAAK,kBAAkB,kBAAkB;AACtD,UAAM,IAAIF,cAAAA;AAAAA,MACT,2CAEO,KAAK,QAAQD,cAAAA,cAAc,iBAAiB,WAAW,CAAC;AAAA;AAAA;AAAA;AAAA,IAG5D,KAAK,UAAU,cAAc,IAC7B;AAAA,IAAA;AAAA,EAEL;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,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''\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: field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AEA,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
+ {"version":3,"file":"EntityAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state/index.js'\nimport type { EntityOperations } from '../core/operations/index.js'\nimport { SingleEntityPersistedData } from '../accessorTree/index.js'\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;AAC7B,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA;AAAA,EAIA,SAAS,OAAiD;AACzD,WAAO,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEA,iBACC,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEA,aAAa,gBAA0D;AACtE,SAAK,WAAW,aAAa,KAAK,OAAO,cAAc;AAAA,EACxD;AAAA,EAEA,qBAAqB,OAA6C,iBAAuC;AACxG,UAAM,YAA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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;"}
@@ -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 {\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,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OAAiD;AAChE,WAAO,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAAA,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEO,iBACN,OACA,UACC;AACD,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEO,sBACN,OACA,UACC;AACD,WAAO,KAAK,WAAW,sBAAsB,KAAK,OAAO,OAAO,QAAQ;AAAA,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;;"}
1
+ {"version":3,"file":"EntityListAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state/index.js'\nimport type { ListOperations } from '../core/operations/index.js'\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,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;AAAA,EAEO,UAAmB;AACzB,WAAO,KAAK,WAAW;AAAA,EACxB;AAAA,EAEA,IAAW,SAAiB;AAC3B,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,EAEO,kBAAkB,eAAmD;AAC3E,QAAI,OAAO,kBAAkB,YAAY,OAAO,kBAAkB,UAAU;AAC3E,aAAO,KAAK,qBAAqB,IAAI,aAAa;AAAA,IACnD;AACA,UAAM,aAAa,c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QAAQ,YAAA;AAAA,EACrC;AAAA,EAEO,YAA6D;AACnE,WAAO,KAAK,MAAM,UAAU;AAAA,EAC7B;AACD;;"}
@@ -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 {\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;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,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;"}
1
+ {"version":3,"file":"EntityListAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state/index.js'\nimport type { ListOperations } from '../core/operations/index.js'\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,SAA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AiB,MAAM;AAAA,MAC7B;AAAA,IACD,CAAC;AAAA,EACF;AAAA,EAEO,SAAS,OAAiD;AAChE,WAAO,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEO,iBACN,OACA,UACC;AACD,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEO,sBACN,OACA,UACC;AACD,WAAO,KAAK,WAAW,sBAAsB,KAAK,OAAO,OAAO,QAAQ;AAAA,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;"}
@@ -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,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
+ {"version":3,"file":"FieldAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state/index.js'\nimport type { FieldOperations } from '../core/operations/index.js'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers/index.js'\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,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
+ {"version":3,"file":"FieldAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state/index.js'\nimport type { FieldOperations } from '../core/operations/index.js'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers/index.js'\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;"}