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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/dist/development/index.cjs +8 -8
  2. package/dist/development/index.js +4 -4
  3. package/dist/development/src/accessorTree/NormalizedPersistedData.cjs.map +1 -1
  4. package/dist/development/src/accessorTree/NormalizedPersistedData.js.map +1 -1
  5. package/dist/development/src/accessors/EntityAccessorImpl.cjs.map +1 -1
  6. package/dist/development/src/accessors/EntityAccessorImpl.js.map +1 -1
  7. package/dist/development/src/accessors/EntityListAccessorImpl.cjs +1 -1
  8. package/dist/development/src/accessors/EntityListAccessorImpl.cjs.map +1 -1
  9. package/dist/development/src/accessors/EntityListAccessorImpl.js +1 -1
  10. package/dist/development/src/accessors/EntityListAccessorImpl.js.map +1 -1
  11. package/dist/development/src/accessors/FieldAccessorImpl.cjs.map +1 -1
  12. package/dist/development/src/accessors/FieldAccessorImpl.js.map +1 -1
  13. package/dist/development/src/core/AccessorErrorManager.cjs.map +1 -1
  14. package/dist/development/src/core/AccessorErrorManager.js.map +1 -1
  15. package/dist/development/src/core/Config.cjs.map +1 -1
  16. package/dist/development/src/core/Config.js.map +1 -1
  17. package/dist/development/src/core/DataBinding.cjs +10 -7
  18. package/dist/development/src/core/DataBinding.cjs.map +1 -1
  19. package/dist/development/src/core/DataBinding.js +10 -7
  20. package/dist/development/src/core/DataBinding.js.map +1 -1
  21. package/dist/development/src/core/DirtinessTracker.cjs.map +1 -1
  22. package/dist/development/src/core/DirtinessTracker.js.map +1 -1
  23. package/dist/development/src/core/ErrorsPreprocessor.cjs.map +1 -1
  24. package/dist/development/src/core/ErrorsPreprocessor.js.map +1 -1
  25. package/dist/development/src/core/EventManager.cjs.map +1 -1
  26. package/dist/development/src/core/EventManager.js.map +1 -1
  27. package/dist/development/src/core/MutationGenerator.cjs.map +1 -1
  28. package/dist/development/src/core/MutationGenerator.js.map +1 -1
  29. package/dist/development/src/core/QueryGenerator.cjs.map +1 -1
  30. package/dist/development/src/core/QueryGenerator.js.map +1 -1
  31. package/dist/development/src/core/RealmKeyGenerator.cjs.map +1 -1
  32. package/dist/development/src/core/RealmKeyGenerator.js.map +1 -1
  33. package/dist/development/src/core/RequestResponseNormalizer.cjs.map +1 -1
  34. package/dist/development/src/core/RequestResponseNormalizer.js.map +1 -1
  35. package/dist/development/src/core/StateInitializer.cjs +1 -1
  36. package/dist/development/src/core/StateInitializer.cjs.map +1 -1
  37. package/dist/development/src/core/StateInitializer.js +2 -2
  38. package/dist/development/src/core/StateInitializer.js.map +1 -1
  39. package/dist/development/src/core/TreeAugmenter.cjs +2 -5
  40. package/dist/development/src/core/TreeAugmenter.cjs.map +1 -1
  41. package/dist/development/src/core/TreeAugmenter.js +2 -5
  42. package/dist/development/src/core/TreeAugmenter.js.map +1 -1
  43. package/dist/development/src/core/TreeStore.cjs.map +1 -1
  44. package/dist/development/src/core/TreeStore.js.map +1 -1
  45. package/dist/development/src/core/exceptions/ErrorLocator.cjs.map +1 -1
  46. package/dist/development/src/core/exceptions/ErrorLocator.js.map +1 -1
  47. package/dist/development/src/core/exceptions/MarkerSugarer.cjs.map +1 -1
  48. package/dist/development/src/core/exceptions/MarkerSugarer.js.map +1 -1
  49. package/dist/development/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -1
  50. package/dist/development/src/core/exceptions/TreeParameterSugarer.js.map +1 -1
  51. package/dist/development/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
  52. package/dist/development/src/core/factories/createBatchUpdatesOptions.js.map +1 -1
  53. package/dist/development/src/core/operations/EntityOperations.cjs +1 -3
  54. package/dist/development/src/core/operations/EntityOperations.cjs.map +1 -1
  55. package/dist/development/src/core/operations/EntityOperations.js +1 -3
  56. package/dist/development/src/core/operations/EntityOperations.js.map +1 -1
  57. package/dist/development/src/core/operations/FieldOperations.cjs.map +1 -1
  58. package/dist/development/src/core/operations/FieldOperations.js.map +1 -1
  59. package/dist/development/src/core/operations/ListOperations.cjs.map +1 -1
  60. package/dist/development/src/core/operations/ListOperations.js.map +1 -1
  61. package/dist/development/src/core/operations/OperationsHelpers.cjs.map +1 -1
  62. package/dist/development/src/core/operations/OperationsHelpers.js.map +1 -1
  63. package/dist/development/src/core/requestAliases/MutationAlias.cjs.map +1 -1
  64. package/dist/development/src/core/requestAliases/MutationAlias.js.map +1 -1
  65. package/dist/development/src/core/state/StateIterator.cjs.map +1 -1
  66. package/dist/development/src/core/state/StateIterator.js.map +1 -1
  67. package/dist/development/src/core/utils/getCombinedSignal.cjs.map +1 -1
  68. package/dist/development/src/core/utils/getCombinedSignal.js.map +1 -1
  69. package/dist/development/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -1
  70. package/dist/development/src/fieldHelpers/helpers/FieldHelper.js.map +1 -1
  71. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +3 -3
  72. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -1
  73. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js +3 -3
  74. package/dist/development/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
  75. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -1
  76. package/dist/development/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
  77. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -1
  78. package/dist/development/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -1
  79. package/dist/development/src/utils/isEmptyObject.cjs.map +1 -1
  80. package/dist/development/src/utils/isEmptyObject.js.map +1 -1
  81. package/dist/production/index.cjs +8 -8
  82. package/dist/production/index.js +4 -4
  83. package/dist/production/src/accessorTree/NormalizedPersistedData.cjs.map +1 -1
  84. package/dist/production/src/accessorTree/NormalizedPersistedData.js.map +1 -1
  85. package/dist/production/src/accessors/EntityAccessorImpl.cjs.map +1 -1
  86. package/dist/production/src/accessors/EntityAccessorImpl.js.map +1 -1
  87. package/dist/production/src/accessors/EntityListAccessorImpl.cjs +1 -1
  88. package/dist/production/src/accessors/EntityListAccessorImpl.cjs.map +1 -1
  89. package/dist/production/src/accessors/EntityListAccessorImpl.js +1 -1
  90. package/dist/production/src/accessors/EntityListAccessorImpl.js.map +1 -1
  91. package/dist/production/src/accessors/FieldAccessorImpl.cjs.map +1 -1
  92. package/dist/production/src/accessors/FieldAccessorImpl.js.map +1 -1
  93. package/dist/production/src/core/AccessorErrorManager.cjs.map +1 -1
  94. package/dist/production/src/core/AccessorErrorManager.js.map +1 -1
  95. package/dist/production/src/core/Config.cjs.map +1 -1
  96. package/dist/production/src/core/Config.js.map +1 -1
  97. package/dist/production/src/core/DataBinding.cjs +10 -7
  98. package/dist/production/src/core/DataBinding.cjs.map +1 -1
  99. package/dist/production/src/core/DataBinding.js +10 -7
  100. package/dist/production/src/core/DataBinding.js.map +1 -1
  101. package/dist/production/src/core/DirtinessTracker.cjs.map +1 -1
  102. package/dist/production/src/core/DirtinessTracker.js.map +1 -1
  103. package/dist/production/src/core/ErrorsPreprocessor.cjs.map +1 -1
  104. package/dist/production/src/core/ErrorsPreprocessor.js.map +1 -1
  105. package/dist/production/src/core/EventManager.cjs.map +1 -1
  106. package/dist/production/src/core/EventManager.js.map +1 -1
  107. package/dist/production/src/core/MutationGenerator.cjs.map +1 -1
  108. package/dist/production/src/core/MutationGenerator.js.map +1 -1
  109. package/dist/production/src/core/QueryGenerator.cjs.map +1 -1
  110. package/dist/production/src/core/QueryGenerator.js.map +1 -1
  111. package/dist/production/src/core/RealmKeyGenerator.cjs.map +1 -1
  112. package/dist/production/src/core/RealmKeyGenerator.js.map +1 -1
  113. package/dist/production/src/core/RequestResponseNormalizer.cjs.map +1 -1
  114. package/dist/production/src/core/RequestResponseNormalizer.js.map +1 -1
  115. package/dist/production/src/core/StateInitializer.cjs +1 -1
  116. package/dist/production/src/core/StateInitializer.cjs.map +1 -1
  117. package/dist/production/src/core/StateInitializer.js +2 -2
  118. package/dist/production/src/core/StateInitializer.js.map +1 -1
  119. package/dist/production/src/core/TreeAugmenter.cjs +2 -5
  120. package/dist/production/src/core/TreeAugmenter.cjs.map +1 -1
  121. package/dist/production/src/core/TreeAugmenter.js +2 -5
  122. package/dist/production/src/core/TreeAugmenter.js.map +1 -1
  123. package/dist/production/src/core/TreeStore.cjs.map +1 -1
  124. package/dist/production/src/core/TreeStore.js.map +1 -1
  125. package/dist/production/src/core/exceptions/ErrorLocator.cjs.map +1 -1
  126. package/dist/production/src/core/exceptions/ErrorLocator.js.map +1 -1
  127. package/dist/production/src/core/exceptions/MarkerSugarer.cjs.map +1 -1
  128. package/dist/production/src/core/exceptions/MarkerSugarer.js.map +1 -1
  129. package/dist/production/src/core/exceptions/TreeParameterSugarer.cjs.map +1 -1
  130. package/dist/production/src/core/exceptions/TreeParameterSugarer.js.map +1 -1
  131. package/dist/production/src/core/factories/createBatchUpdatesOptions.cjs.map +1 -1
  132. package/dist/production/src/core/factories/createBatchUpdatesOptions.js.map +1 -1
  133. package/dist/production/src/core/operations/EntityOperations.cjs +1 -3
  134. package/dist/production/src/core/operations/EntityOperations.cjs.map +1 -1
  135. package/dist/production/src/core/operations/EntityOperations.js +1 -3
  136. package/dist/production/src/core/operations/EntityOperations.js.map +1 -1
  137. package/dist/production/src/core/operations/FieldOperations.cjs.map +1 -1
  138. package/dist/production/src/core/operations/FieldOperations.js.map +1 -1
  139. package/dist/production/src/core/operations/ListOperations.cjs.map +1 -1
  140. package/dist/production/src/core/operations/ListOperations.js.map +1 -1
  141. package/dist/production/src/core/operations/OperationsHelpers.cjs.map +1 -1
  142. package/dist/production/src/core/operations/OperationsHelpers.js.map +1 -1
  143. package/dist/production/src/core/requestAliases/MutationAlias.cjs.map +1 -1
  144. package/dist/production/src/core/requestAliases/MutationAlias.js.map +1 -1
  145. package/dist/production/src/core/state/StateIterator.cjs.map +1 -1
  146. package/dist/production/src/core/state/StateIterator.js.map +1 -1
  147. package/dist/production/src/core/utils/getCombinedSignal.cjs.map +1 -1
  148. package/dist/production/src/core/utils/getCombinedSignal.js.map +1 -1
  149. package/dist/production/src/fieldHelpers/helpers/FieldHelper.cjs.map +1 -1
  150. package/dist/production/src/fieldHelpers/helpers/FieldHelper.js.map +1 -1
  151. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs +3 -3
  152. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.cjs.map +1 -1
  153. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js +3 -3
  154. package/dist/production/src/fieldHelpers/helpers/TemporalFieldHelper.js.map +1 -1
  155. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.cjs.map +1 -1
  156. package/dist/production/src/fieldHelpers/helpers/UuidFieldHelper.js.map +1 -1
  157. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.cjs.map +1 -1
  158. package/dist/production/src/utils/generateEnumerabilityPreventingEntropy.js.map +1 -1
  159. package/dist/production/src/utils/isEmptyObject.cjs.map +1 -1
  160. package/dist/production/src/utils/isEmptyObject.js.map +1 -1
  161. package/dist/types/accessors/EntityAccessorImpl.d.ts.map +1 -1
  162. package/dist/types/accessors/EntityListAccessorImpl.d.ts.map +1 -1
  163. package/dist/types/core/DataBinding.d.ts.map +1 -1
  164. package/dist/types/core/ErrorsPreprocessor.d.ts.map +1 -1
  165. package/dist/types/core/EventManager.d.ts.map +1 -1
  166. package/dist/types/core/MutationGenerator.d.ts.map +1 -1
  167. package/dist/types/core/QueryGenerator.d.ts.map +1 -1
  168. package/dist/types/core/RealmKeyGenerator.d.ts.map +1 -1
  169. package/dist/types/core/RequestResponseNormalizer.d.ts.map +1 -1
  170. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  171. package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
  172. package/dist/types/core/TreeStore.d.ts.map +1 -1
  173. package/dist/types/core/operations/FieldOperations.d.ts.map +1 -1
  174. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  175. package/dist/types/core/state/EntityListState.d.ts.map +1 -1
  176. package/dist/types/tsconfig.tsbuildinfo +1 -1
  177. package/package.json +10 -5
  178. package/src/accessorTree/NormalizedPersistedData.ts +1 -1
  179. package/src/accessors/EntityAccessorImpl.ts +13 -11
  180. package/src/accessors/EntityListAccessorImpl.ts +16 -7
  181. package/src/core/AccessorErrorManager.ts +2 -2
  182. package/src/core/DataBinding.ts +24 -15
  183. package/src/core/ErrorsPreprocessor.ts +4 -5
  184. package/src/core/EventManager.ts +34 -46
  185. package/src/core/MutationGenerator.ts +23 -27
  186. package/src/core/QueryGenerator.ts +4 -5
  187. package/src/core/RealmKeyGenerator.ts +5 -3
  188. package/src/core/RequestResponseNormalizer.ts +3 -8
  189. package/src/core/StateInitializer.ts +10 -18
  190. package/src/core/TreeAugmenter.ts +8 -15
  191. package/src/core/TreeStore.ts +5 -4
  192. package/src/core/operations/EntityOperations.ts +25 -25
  193. package/src/core/operations/FieldOperations.ts +15 -17
  194. package/src/core/operations/ListOperations.ts +15 -15
  195. package/src/core/operations/OperationsHelpers.ts +2 -2
  196. package/src/core/state/EntityListState.ts +3 -9
  197. package/src/fieldHelpers/helpers/TemporalFieldHelper.ts +3 -3
  198. package/src/utils/assertNever.ts +4 -4
  199. package/tests/example.test.ts +2 -2
@@ -1 +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,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YACL,KAAK;AACG,qBAAA,KAAK,mBAAmB,UAAU;AACzC;AAAA,YACD,KAAK;AACJ;AAAA,YACD;AACC,qBAAO,YAAY,UAAU;AAAA,UAAA;AAAA,QAC/B;AAED;AAAA,MACD,KAAK;AACJ;AAAA,MACD;AACC,eAAO,YAAY,IAAI;AAAA,IAAA;AAEnB,UAAA;AAAA,EAAA;AAAA,EAGP,QAAe,iBACd,MACA,OAC+B;AAC/B,YAAQ,KAAK,MAAM;AAAA,MAClB,KAAK;AAAA,MACL,KAAK;AACJ,mBAAW,cAAc,KAAK,SAAS,OAAA,GAAU;AAChD,cAAI,WAAW,SAAS,iBAAiB,WAAW,SAAS,cAAc;AACnE,mBAAA,KAAK,iBAAiB,YAAY,KAAK;AAAA,UAAA;AAAA,QAC/C;AAED;AAAA,MACD;AACC,eAAO,YAAY,IAAI;AAAA,IAAA;AAEzB,QAAI,UAAU,UAAa,MAAM,IAAI,GAAG;AACjC,YAAA;AAAA,IAAA;AAAA,EACP;AAAA,EAGD,QAAe,cAAc,WAA0E;AACtG,eAAW,cAAc,UAAU,oBAAoB,OAAA,GAAU;AAChE,aAAO,WAAW,QAAQ;AAAA,IAAA;AAAA,EAC3B;AAEF;"}
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,wBAAw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J;AAAA,YACD;AACC,qBAAO,YAAY,UAAU;AAAA,UAAA;AAAA,QAEhC;AACA;AAAA,MACD,KAAK;AACJ;AAAA,MACD;AACC,eAAO,YAAY,IAAI;AAAA,IAAA;AAEzB,UAAM;AAAA,EACP;AAAA,EAEA,QAAe,iBACd,MACA,OAC+B;AAC/B,YAAQ,KAAK,MAAA;AAAA,MACZ,KAAK;AAAA,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,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":"getCombinedSignal.cjs","sources":["../../../../../../packages/binding-legacy/src/core/utils/getCombinedSignal.ts"],"sourcesContent":["// Returns a signal that aborts when all present signals are aborted.\nexport const getCombinedSignal = (components: Iterable<AbortSignal | undefined>): AbortSignal => {\n\tlet abortedCount = 0\n\tlet signalCount = 0\n\n\tconst controller = new AbortController()\n\tconst refresh = () => {\n\t\tif (signalCount === 0) {\n\t\t\treturn\n\t\t}\n\t\tif (abortedCount >= signalCount) {\n\t\t\tcontroller.abort()\n\t\t}\n\t}\n\n\tfor (const component of components) {\n\t\tif (!component) {\n\t\t\tcontinue\n\t\t}\n\n\t\tsignalCount++\n\n\t\tif (component.aborted) {\n\t\t\tabortedCount++\n\t\t} else {\n\t\t\tcomponent.addEventListener('abort', () => {\n\t\t\t\tabortedCount++\n\t\t\t\trefresh()\n\t\t\t})\n\t\t}\n\t}\n\n\trefresh()\n\n\treturn controller.signal\n}\n"],"names":[],"mappings":";;AACa,MAAA,oBAAoB,CAAC,eAA+D;AAChG,MAAI,eAAe;AACnB,MAAI,cAAc;AAEZ,QAAA,aAAa,IAAI,gBAAgB;AACvC,QAAM,UAAU,MAAM;AACrB,QAAI,gBAAgB,GAAG;AACtB;AAAA,IAAA;AAED,QAAI,gBAAgB,aAAa;AAChC,iBAAW,MAAM;AAAA,IAAA;AAAA,EAEnB;AAEA,aAAW,aAAa,YAAY;AACnC,QAAI,CAAC,WAAW;AACf;AAAA,IAAA;AAGD;AAEA,QAAI,UAAU,SAAS;AACtB;AAAA,IAAA,OACM;AACI,gBAAA,iBAAiB,SAAS,MAAM;AACzC;AACQ,gBAAA;AAAA,MAAA,CACR;AAAA,IAAA;AAAA,EACF;AAGO,UAAA;AAER,SAAO,WAAW;AACnB;;"}
1
+ {"version":3,"file":"getCombinedSignal.cjs","sources":["../../../../../../packages/binding-legacy/src/core/utils/getCombinedSignal.ts"],"sourcesContent":["// Returns a signal that aborts when all present signals are aborted.\nexport const getCombinedSignal = (components: Iterable<AbortSignal | undefined>): AbortSignal => {\n\tlet abortedCount = 0\n\tlet signalCount = 0\n\n\tconst controller = new AbortController()\n\tconst refresh = () => {\n\t\tif (signalCount === 0) {\n\t\t\treturn\n\t\t}\n\t\tif (abortedCount >= signalCount) {\n\t\t\tcontroller.abort()\n\t\t}\n\t}\n\n\tfor (const component of components) {\n\t\tif (!component) {\n\t\t\tcontinue\n\t\t}\n\n\t\tsignalCount++\n\n\t\tif (component.aborted) {\n\t\t\tabortedCount++\n\t\t} else {\n\t\t\tcomponent.addEventListener('abort', () => {\n\t\t\t\tabortedCount++\n\t\t\t\trefresh()\n\t\t\t})\n\t\t}\n\t}\n\n\trefresh()\n\n\treturn controller.signal\n}\n"],"names":[],"mappings":";;AACO,MAAM,oBAAoB,CAAC,eAA+D;AAChG,MAAI,eAAe;AACnB,MAAI,cAAc;AAElB,QAAM,aAAa,IAAI,gBAAA;AACvB,QAAM,UAAU,MAAM;AACrB,QAAI,gBAAgB,GAAG;AACtB;AAAA,IACD;AACA,QAAI,gBAAgB,aAAa;AAChC,iBAAW,MAAA;AAAA,IACZ;AAAA,EACD;AAEA,aAAW,aAAa,YAAY;AACnC,QAAI,CAAC,WAAW;AACf;AAAA,IACD;AAEA;AAEA,QAAI,UAAU,SAAS;AACtB;AAAA,IACD,OAAO;AACN,gBAAU,iBAAiB,SAAS,MAAM;AACzC;AACA,gBAAA;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AAEA,UAAA;AAEA,SAAO,WAAW;AACnB;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"getCombinedSignal.js","sources":["../../../../../../packages/binding-legacy/src/core/utils/getCombinedSignal.ts"],"sourcesContent":["// Returns a signal that aborts when all present signals are aborted.\nexport const getCombinedSignal = (components: Iterable<AbortSignal | undefined>): AbortSignal => {\n\tlet abortedCount = 0\n\tlet signalCount = 0\n\n\tconst controller = new AbortController()\n\tconst refresh = () => {\n\t\tif (signalCount === 0) {\n\t\t\treturn\n\t\t}\n\t\tif (abortedCount >= signalCount) {\n\t\t\tcontroller.abort()\n\t\t}\n\t}\n\n\tfor (const component of components) {\n\t\tif (!component) {\n\t\t\tcontinue\n\t\t}\n\n\t\tsignalCount++\n\n\t\tif (component.aborted) {\n\t\t\tabortedCount++\n\t\t} else {\n\t\t\tcomponent.addEventListener('abort', () => {\n\t\t\t\tabortedCount++\n\t\t\t\trefresh()\n\t\t\t})\n\t\t}\n\t}\n\n\trefresh()\n\n\treturn controller.signal\n}\n"],"names":[],"mappings":"AACa,MAAA,oBAAoB,CAAC,eAA+D;AAChG,MAAI,eAAe;AACnB,MAAI,cAAc;AAEZ,QAAA,aAAa,IAAI,gBAAgB;AACvC,QAAM,UAAU,MAAM;AACrB,QAAI,gBAAgB,GAAG;AACtB;AAAA,IAAA;AAED,QAAI,gBAAgB,aAAa;AAChC,iBAAW,MAAM;AAAA,IAAA;AAAA,EAEnB;AAEA,aAAW,aAAa,YAAY;AACnC,QAAI,CAAC,WAAW;AACf;AAAA,IAAA;AAGD;AAEA,QAAI,UAAU,SAAS;AACtB;AAAA,IAAA,OACM;AACI,gBAAA,iBAAiB,SAAS,MAAM;AACzC;AACQ,gBAAA;AAAA,MAAA,CACR;AAAA,IAAA;AAAA,EACF;AAGO,UAAA;AAER,SAAO,WAAW;AACnB;"}
1
+ {"version":3,"file":"getCombinedSignal.js","sources":["../../../../../../packages/binding-legacy/src/core/utils/getCombinedSignal.ts"],"sourcesContent":["// Returns a signal that aborts when all present signals are aborted.\nexport const getCombinedSignal = (components: Iterable<AbortSignal | undefined>): AbortSignal => {\n\tlet abortedCount = 0\n\tlet signalCount = 0\n\n\tconst controller = new AbortController()\n\tconst refresh = () => {\n\t\tif (signalCount === 0) {\n\t\t\treturn\n\t\t}\n\t\tif (abortedCount >= signalCount) {\n\t\t\tcontroller.abort()\n\t\t}\n\t}\n\n\tfor (const component of components) {\n\t\tif (!component) {\n\t\t\tcontinue\n\t\t}\n\n\t\tsignalCount++\n\n\t\tif (component.aborted) {\n\t\t\tabortedCount++\n\t\t} else {\n\t\t\tcomponent.addEventListener('abort', () => {\n\t\t\t\tabortedCount++\n\t\t\t\trefresh()\n\t\t\t})\n\t\t}\n\t}\n\n\trefresh()\n\n\treturn controller.signal\n}\n"],"names":[],"mappings":"AACO,MAAM,oBAAoB,CAAC,eAA+D;AAChG,MAAI,eAAe;AACnB,MAAI,cAAc;AAElB,QAAM,aAAa,IAAI,gBAAA;AACvB,QAAM,UAAU,MAAM;AACrB,QAAI,gBAAgB,GAAG;AACtB;AAAA,IACD;AACA,QAAI,gBAAgB,aAAa;AAChC,iBAAW,MAAA;AAAA,IACZ;AAAA,EACD;AAEA,aAAW,aAAa,YAAY;AACnC,QAAI,CAAC,WAAW;AACf;AAAA,IACD;AAEA;AAEA,QAAI,UAAU,SAAS;AACtB;AAAA,IACD,OAAO;AACN,gBAAU,iBAAiB,SAAS,MAAM;AACzC;AACA,gBAAA;AAAA,MACD,CAAC;AAAA,IACF;AAAA,EACD;AAEA,UAAA;AAEA,SAAO,WAAW;AACnB;"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldHelper.cjs","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import type { FieldValue } from '@contember/binding-common'\nimport { FieldAccessor } from '@contember/binding-common'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = typeof field === 'function' ? field : field.getAccessor\n\t}\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFrE,kBAAA,MAAA,aAAA;AAGlB,SAAK,cAAc,OAAO,UAAU,aAAa,QAAQ,MAAM;AAAA,EAAA;AAEjE;;"}
1
+ {"version":3,"file":"FieldHelper.cjs","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import type { FieldValue } from '@contember/binding-common'\nimport { FieldAccessor } from '@contember/binding-common'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = typeof field === 'function' ? field : field.getAccessor\n\t}\n}\n"],"names":[],"mappings":";;;;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFxF,kBAAA,MAAmB,aAAA;AAGlB,SAAK,cAAc,OAAO,UAAU,aAAa,QAAQ,MAAM;AAAA,EAChE;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldHelper.js","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import type { FieldValue } from '@contember/binding-common'\nimport { FieldAccessor } from '@contember/binding-common'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = typeof field === 'function' ? field : field.getAccessor\n\t}\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFrE,kBAAA,MAAA,aAAA;AAGlB,SAAK,cAAc,OAAO,UAAU,aAAa,QAAQ,MAAM;AAAA,EAAA;AAEjE;"}
1
+ {"version":3,"file":"FieldHelper.js","sources":["../../../../../../packages/binding-legacy/src/fieldHelpers/helpers/FieldHelper.ts"],"sourcesContent":["import type { FieldValue } from '@contember/binding-common'\nimport { FieldAccessor } from '@contember/binding-common'\n\nexport class FieldHelper<Value extends FieldValue = FieldValue> {\n\tprotected readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>\n\n\tpublic constructor(field: FieldAccessor<Value> | FieldAccessor.GetFieldAccessor<Value>) {\n\t\tthis.getAccessor = typeof field === 'function' ? field : field.getAccessor\n\t}\n}\n"],"names":[],"mappings":";;;AAGO,MAAM,YAAmD;AAAA,EAGxD,YAAY,OAAqE;AAFxF,kBAAA,MAAmB,aAAA;AAGlB,SAAK,cAAc,OAAO,UAAU,aAAa,QAAQ,MAAM;AAAA,EAChE;AACD;"}
@@ -5,9 +5,9 @@ class TemporalFieldHelper extends FieldHelper.FieldHelper {
5
5
  setToNow(options) {
6
6
  this.getAccessor().updateValue((/* @__PURE__ */ new Date()).toISOString(), options);
7
7
  }
8
- //public setToDate() TODO
9
- //public setToTime() TODO
10
- //public setToDateTime() TODO
8
+ // public setToDate() TODO
9
+ // public setToTime() TODO
10
+ // public setToDateTime() TODO
11
11
  }
12
12
  ((TemporalFieldHelper2) => {
13
13
  TemporalFieldHelper2.setToNow = (field, options) => {
@@ -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;AACjD,SAAA,cAAc,aAAY,oBAAI,QAAO,eAAe,OAAO;AAAA,EAAA;AAAA;AAAA;AAAA;AAMlE;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'\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;;"}
@@ -3,9 +3,9 @@ class TemporalFieldHelper extends FieldHelper {
3
3
  setToNow(options) {
4
4
  this.getAccessor().updateValue((/* @__PURE__ */ new Date()).toISOString(), options);
5
5
  }
6
- //public setToDate() TODO
7
- //public setToTime() TODO
8
- //public setToDateTime() TODO
6
+ // public setToDate() TODO
7
+ // public setToTime() TODO
8
+ // public setToDateTime() TODO
9
9
  }
10
10
  ((TemporalFieldHelper2) => {
11
11
  TemporalFieldHelper2.setToNow = (field, options) => {
@@ -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;AACjD,SAAA,cAAc,aAAY,oBAAI,QAAO,eAAe,OAAO;AAAA,EAAA;AAAA;AAAA;AAAA;AAMlE;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'\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,YAAY,EAAE,YAAYC,KAAA,GAAA,GAAU,OAAO;AAAA,EAAA;AAElD;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'\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,YAAY,EAAE,YAAYA,GAAA,GAAU,OAAO;AAAA,EAAA;AAElD;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'\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":"generateEnumerabilityPreventingEntropy.cjs","sources":["../../../../../packages/binding-legacy/src/utils/generateEnumerabilityPreventingEntropy.ts"],"sourcesContent":["export const generateEnumerabilityPreventingEntropy = (length: number = 5): string => {\n\treturn (Math.random() * Math.pow(10, length)).toFixed(0).padStart(length, '0')\n}\n"],"names":[],"mappings":";;AAAa,MAAA,yCAAyC,CAAC,SAAiB,MAAc;AACrF,UAAQ,KAAK,OAAW,IAAA,KAAK,IAAI,IAAI,MAAM,GAAG,QAAQ,CAAC,EAAE,SAAS,QAAQ,GAAG;AAC9E;;"}
1
+ {"version":3,"file":"generateEnumerabilityPreventingEntropy.cjs","sources":["../../../../../packages/binding-legacy/src/utils/generateEnumerabilityPreventingEntropy.ts"],"sourcesContent":["export const generateEnumerabilityPreventingEntropy = (length: number = 5): string => {\n\treturn (Math.random() * Math.pow(10, length)).toFixed(0).padStart(length, '0')\n}\n"],"names":[],"mappings":";;AAAO,MAAM,yCAAyC,CAAC,SAAiB,MAAc;AACrF,UAAQ,KAAK,OAAA,IAAW,KAAK,IAAI,IAAI,MAAM,GAAG,QAAQ,CAAC,EAAE,SAAS,QAAQ,GAAG;AAC9E;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateEnumerabilityPreventingEntropy.js","sources":["../../../../../packages/binding-legacy/src/utils/generateEnumerabilityPreventingEntropy.ts"],"sourcesContent":["export const generateEnumerabilityPreventingEntropy = (length: number = 5): string => {\n\treturn (Math.random() * Math.pow(10, length)).toFixed(0).padStart(length, '0')\n}\n"],"names":[],"mappings":"AAAa,MAAA,yCAAyC,CAAC,SAAiB,MAAc;AACrF,UAAQ,KAAK,OAAW,IAAA,KAAK,IAAI,IAAI,MAAM,GAAG,QAAQ,CAAC,EAAE,SAAS,QAAQ,GAAG;AAC9E;"}
1
+ {"version":3,"file":"generateEnumerabilityPreventingEntropy.js","sources":["../../../../../packages/binding-legacy/src/utils/generateEnumerabilityPreventingEntropy.ts"],"sourcesContent":["export const generateEnumerabilityPreventingEntropy = (length: number = 5): string => {\n\treturn (Math.random() * Math.pow(10, length)).toFixed(0).padStart(length, '0')\n}\n"],"names":[],"mappings":"AAAO,MAAM,yCAAyC,CAAC,SAAiB,MAAc;AACrF,UAAQ,KAAK,OAAA,IAAW,KAAK,IAAI,IAAI,MAAM,GAAG,QAAQ,CAAC,EAAE,SAAS,QAAQ,GAAG;AAC9E;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isEmptyObject.cjs","sources":["../../../../../packages/binding-legacy/src/utils/isEmptyObject.ts"],"sourcesContent":["export const isEmptyObject = (arg: object): boolean => {\n\t// This is faster than Object.keys(arg).length === 0 && arg.constructor === Object\n\tfor (const key in arg) {\n\t\tif (arg.hasOwnProperty(key)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"],"names":[],"mappings":";;AAAa,MAAA,gBAAgB,CAAC,QAAyB;AAEtD,aAAW,OAAO,KAAK;AAClB,QAAA,IAAI,eAAe,GAAG,GAAG;AACrB,aAAA;AAAA,IAAA;AAAA,EACR;AAEM,SAAA;AACR;;"}
1
+ {"version":3,"file":"isEmptyObject.cjs","sources":["../../../../../packages/binding-legacy/src/utils/isEmptyObject.ts"],"sourcesContent":["export const isEmptyObject = (arg: object): boolean => {\n\t// This is faster than Object.keys(arg).length === 0 && arg.constructor === Object\n\tfor (const key in arg) {\n\t\tif (arg.hasOwnProperty(key)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"],"names":[],"mappings":";;AAAO,MAAM,gBAAgB,CAAC,QAAyB;AAEtD,aAAW,OAAO,KAAK;AACtB,QAAI,IAAI,eAAe,GAAG,GAAG;AAC5B,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"isEmptyObject.js","sources":["../../../../../packages/binding-legacy/src/utils/isEmptyObject.ts"],"sourcesContent":["export const isEmptyObject = (arg: object): boolean => {\n\t// This is faster than Object.keys(arg).length === 0 && arg.constructor === Object\n\tfor (const key in arg) {\n\t\tif (arg.hasOwnProperty(key)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"],"names":[],"mappings":"AAAa,MAAA,gBAAgB,CAAC,QAAyB;AAEtD,aAAW,OAAO,KAAK;AAClB,QAAA,IAAI,eAAe,GAAG,GAAG;AACrB,aAAA;AAAA,IAAA;AAAA,EACR;AAEM,SAAA;AACR;"}
1
+ {"version":3,"file":"isEmptyObject.js","sources":["../../../../../packages/binding-legacy/src/utils/isEmptyObject.ts"],"sourcesContent":["export const isEmptyObject = (arg: object): boolean => {\n\t// This is faster than Object.keys(arg).length === 0 && arg.constructor === Object\n\tfor (const key in arg) {\n\t\tif (arg.hasOwnProperty(key)) {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}\n"],"names":[],"mappings":"AAAO,MAAM,gBAAgB,CAAC,QAAyB;AAEtD,aAAW,OAAO,KAAK;AACtB,QAAI,IAAI,eAAe,GAAG,GAAG;AAC5B,aAAO;AAAA,IACR;AAAA,EACD;AACA,SAAO;AACR;"}
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const bindingCommon = require("@contember/binding-common");
4
- const EntityAccessorImpl = require("./src/accessors/EntityAccessorImpl.cjs");
5
- const EntityListAccessorImpl = require("./src/accessors/EntityListAccessorImpl.cjs");
6
- const FieldAccessorImpl = require("./src/accessors/FieldAccessorImpl.cjs");
7
- const NormalizedPersistedData = require("./src/accessorTree/NormalizedPersistedData.cjs");
8
4
  const Config = require("./src/core/Config.cjs");
9
5
  const DataBinding = require("./src/core/DataBinding.cjs");
10
6
  const DirtinessTracker = require("./src/core/DirtinessTracker.cjs");
7
+ const EntityAccessorImpl = require("./src/accessors/EntityAccessorImpl.cjs");
8
+ const EntityListAccessorImpl = require("./src/accessors/EntityListAccessorImpl.cjs");
11
9
  const EventManager = require("./src/core/EventManager.cjs");
10
+ const FieldAccessorImpl = require("./src/accessors/FieldAccessorImpl.cjs");
11
+ const NormalizedPersistedData = require("./src/accessorTree/NormalizedPersistedData.cjs");
12
12
  const QueryGenerator = require("./src/core/QueryGenerator.cjs");
13
13
  const StateInitializer = require("./src/core/StateInitializer.cjs");
14
14
  const TreeAugmenter = require("./src/core/TreeAugmenter.cjs");
15
15
  const TreeStore = require("./src/core/TreeStore.cjs");
16
- exports.EntityAccessorImpl = EntityAccessorImpl.EntityAccessorImpl;
17
- exports.EntityListAccessorImpl = EntityListAccessorImpl.EntityListAccessorImpl;
18
- exports.FieldAccessorImpl = FieldAccessorImpl.FieldAccessorImpl;
19
- exports.NormalizedPersistedData = NormalizedPersistedData.NormalizedPersistedData;
20
16
  exports.Config = Config.Config;
21
17
  exports.DataBinding = DataBinding.DataBinding;
22
18
  exports.DirtinessTracker = DirtinessTracker.DirtinessTracker;
19
+ exports.EntityAccessorImpl = EntityAccessorImpl.EntityAccessorImpl;
20
+ exports.EntityListAccessorImpl = EntityListAccessorImpl.EntityListAccessorImpl;
23
21
  exports.EventManager = EventManager.EventManager;
22
+ exports.FieldAccessorImpl = FieldAccessorImpl.FieldAccessorImpl;
23
+ exports.NormalizedPersistedData = NormalizedPersistedData.NormalizedPersistedData;
24
24
  exports.QueryGenerator = QueryGenerator.QueryGenerator;
25
25
  exports.StateInitializer = StateInitializer.StateInitializer;
26
26
  exports.TreeAugmenter = TreeAugmenter.TreeAugmenter;
@@ -1,12 +1,12 @@
1
1
  export * from "@contember/binding-common";
2
- import { EntityAccessorImpl } from "./src/accessors/EntityAccessorImpl.js";
3
- import { EntityListAccessorImpl } from "./src/accessors/EntityListAccessorImpl.js";
4
- import { FieldAccessorImpl } from "./src/accessors/FieldAccessorImpl.js";
5
- import { NormalizedPersistedData } from "./src/accessorTree/NormalizedPersistedData.js";
6
2
  import { Config } from "./src/core/Config.js";
7
3
  import { DataBinding } from "./src/core/DataBinding.js";
8
4
  import { DirtinessTracker } from "./src/core/DirtinessTracker.js";
5
+ import { EntityAccessorImpl } from "./src/accessors/EntityAccessorImpl.js";
6
+ import { EntityListAccessorImpl } from "./src/accessors/EntityListAccessorImpl.js";
9
7
  import { EventManager } from "./src/core/EventManager.js";
8
+ import { FieldAccessorImpl } from "./src/accessors/FieldAccessorImpl.js";
9
+ import { NormalizedPersistedData } from "./src/accessorTree/NormalizedPersistedData.js";
10
10
  import { QueryGenerator } from "./src/core/QueryGenerator.js";
11
11
  import { StateInitializer } from "./src/core/StateInitializer.js";
12
12
  import { TreeAugmenter } from "./src/core/TreeAugmenter.js";
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizedPersistedData.cjs","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n//\t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":";;AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EAAA;AAElB;;"}
1
+ {"version":3,"file":"NormalizedPersistedData.cjs","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n// \t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":";;AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"NormalizedPersistedData.js","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n//\t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":"AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EAAA;AAElB;"}
1
+ {"version":3,"file":"NormalizedPersistedData.js","sources":["../../../../../packages/binding-legacy/src/accessorTree/NormalizedPersistedData.ts"],"sourcesContent":["import type { EntityId, FieldValue, PlaceholderName } from '@contember/binding-common'\nimport type { ServerId, UniqueEntityId } from '@contember/binding-common'\n\n// HasMany relations are encoded as sets of entity ids.\n// HasOne relations are encoded as BoxedSingleEntityId just to make them different from actual strings.\n// \t\tNot sure whether that is a reasonable precaution or just pure overhead.\nexport type EntityFieldPersistedValue = FieldValue | ServerId | EntityListPersistedData\n\nexport type EntityFieldPersistedData<Value extends EntityFieldPersistedValue = EntityFieldPersistedValue> = {\n\treadable: boolean | undefined\n\tupdatable: boolean | undefined\n\tvalue: Value\n}\n\nexport type SingleEntityPersistedData = Map<PlaceholderName, EntityFieldPersistedData>\n\nexport type EntityListPersistedData = Set<EntityId>\n\nexport type PersistedEntityDataStore = Map<UniqueEntityId, SingleEntityPersistedData>\n\n// The key is the subTree placeholder name\nexport type SubTreeDataStore = Map<PlaceholderName, ServerId | EntityListPersistedData>\n\nexport class NormalizedPersistedData {\n\tpublic constructor(\n\t\tpublic readonly subTreeDataStore: SubTreeDataStore,\n\t\tpublic readonly persistedEntityDataStore: PersistedEntityDataStore,\n\t) {}\n}\n"],"names":[],"mappings":"AAuBO,MAAM,wBAAwB;AAAA,EAC7B,YACU,kBACA,0BACf;AAFe,SAAA,mBAAA;AACA,SAAA,2BAAA;AAAA,EACd;AACJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"EntityAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(''\n\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(''\n\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t+ 'Provided parameters:\\n'\n\t\t\t+ JSON.stringify(relationParams)\n\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":["ErrorAccessor","QueryLanguage","PlaceholderGenerator","TreeNodeUtils","BindingError","HasOneRelationMarker","PlaceholderParametersGenerator","HasManyRelationMarker","getEntityMarker"],"mappings":";;;;;;;AAkCO,MAAM,mBAA6C;AAAA,EAGlD,YACW,OACA,YACA,WACR,KACA,MACQ,WACA,gBACR,uBACA,QACA,aACA,aACR;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACR,SAAA,MAAA;AACA,SAAA,OAAA;AACQ,SAAA,YAAA;AACA,SAAA,iBAAA;AACR,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAbV,kBAAA,MAAgB,UAAS,gBAAA;AAAA,EAAA;AAAA,EAiBzB,IAAI,aAAmC;AACtC,WAAO,KAAK,UAAU,iBAAiB,KAAK,UAAU,QAAQ;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA,EAM/D,IAAI,KAAe;AAClB,WAAO,KAAK,UAAU;AAAA,EAAA;AAAA,EAGvB,IAAI,iBAA0B;AAC7B,WAAO,KAAK,UAAU;AAAA,EAAA;AAAA;AAAA,EAKvB,SAAS,OAAiD;AAClD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAc,cAAA,eAAe,KAAK,CAAC;AAAA,EAAA;AAAA,EAGhF,iBACC,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAGpE,aAAa,gBAA0D;AACtE,SAAK,WAAW,aAAa,KAAK,OAAO,cAAc;AAAA,EAAA;AAAA,EAGxD,qBAAqB,OAA6C,iBAAuC;AACxG,UAAM,YAAYC,cAAAA,cAAc,4BAA4B,OAAO,KAAK,WAAW;AAC7E,UAAA,aAAa,KAAK,UAAU;AAAA,MACjC,oBAAoB,UAAU,mBAAmB,MAAM,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;AACpB,WAAO,MAAM,KAAK,QAAQ,OAAA,CAAQ,EAChC,OAAO,CAAC,OAA+B,cAAc,qBAAsB,GAAG,WAAW,UAAU,SAAS;AAAA,EAAA;AAAA,EAG/G,YAA6D;AACtD,UAAA,YAAY,KAAK,MAAM;AACzB,QAAA,UAAU,SAAS,WAAW;AAC1B,aAAA;AAAA,IAAA;AAED,WAAA,UAAU,OAAO,YAAY;AAAA,EAAA;AAAA,EAGrC,YAAY;AACJ,WAAAK,gBAAA,gBAAgB,KAAK,KAAK;AAAA,EAAA;AAAA,EAGlC,aAAa,OAAe;AAC3B,UAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK;AACzC,WAAA;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IACvB;AAAA,EAAA;AAEF;;"}
1
+ {"version":3,"file":"EntityAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t\t+ 'Provided parameters:\\n'\n\t\t\t\t+ JSON.stringify(relationParams)\n\t\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":["ErrorAccessor","QueryLanguage","PlaceholderGenerator","TreeNodeUtils","BindingError","HasOneRelationMarker","PlaceholderParametersGenerator","HasManyRelationMarker","getEntityMarker"],"mappings":";;;;;;;AAkCO,MAAM,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,IAA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4B,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+ 'EntityAccessor: cannot access field '\n\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(''\n\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t+ 'Provided parameters:\\n'\n\t\t\t+ JSON.stringify(relationParams)\n\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAkCO,MAAM,mBAA6C;AAAA,EAGlD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I,KAAK;AACzC,WAAA;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IACvB;AAAA,EAAA;AAEF;"}
1
+ {"version":3,"file":"EntityAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityAccessorImpl.ts"],"sourcesContent":["import { EntityRealmState, getEntityMarker } from '../core/state'\nimport type { EntityOperations } from '../core/operations'\nimport { SingleEntityPersistedData } from '../accessorTree'\nimport {\n\tEntityFieldMarkers,\n\tEntityListAccessor,\n\tFieldAccessor,\n\tFieldValue,\n\tHasManyRelation,\n\tHasManyRelationMarker,\n\tHasOneRelation,\n\tRelativeEntityList,\n\tRelativeSingleEntity,\n\tRelativeSingleField,\n\tSugaredRelativeEntityList,\n\tSugaredRelativeSingleField,\n} from '@contember/binding-common'\nimport {\n\tBindingError,\n\tEntityAccessor,\n\tEntityId,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasOneRelationMarker,\n\tPlaceholderGenerator,\n\tPlaceholderParametersGenerator,\n\tQueryLanguage,\n\tRuntimeId,\n\tSugaredRelativeSingleEntity,\n\tTreeNodeUtils,\n} from '@contember/binding-common'\n\nexport class EntityAccessorImpl implements EntityAccessor {\n\tpublic readonly __type = 'EntityAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityRealmState,\n\t\tprivate readonly operations: EntityOperations,\n\t\tprivate readonly runtimeId: RuntimeId,\n\t\treadonly key: EntityRealmKey, // ⚠️ This is *NOT* the id! ⚠️\n\t\treadonly name: EntityName,\n\t\tprivate readonly fieldData: EntityAccessor.FieldData,\n\t\tprivate readonly dataFromServer: SingleEntityPersistedData | undefined,\n\t\treadonly hasUnpersistedChanges: boolean,\n\t\treadonly errors: ErrorAccessor | undefined,\n\t\treadonly environment: Environment,\n\t\treadonly getAccessor: EntityAccessor.GetEntityAccessor,\n\t) {\n\t}\n\n\tget idOnServer(): EntityId | undefined {\n\t\treturn this.runtimeId.existsOnServer ? this.runtimeId.value : undefined\n\t}\n\n\t/**\n\t * Note that for entities that don't yet exist on server this will return a dummy id.\n\t */\n\tget id(): EntityId {\n\t\treturn this.runtimeId.value\n\t}\n\n\tget existsOnServer(): boolean {\n\t\treturn this.runtimeId.existsOnServer\n\t}\n\n\t//\n\n\taddError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\taddEventListener<Type extends keyof EntityAccessor.RuntimeEntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tbatchUpdates(performUpdates: EntityAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tconnectEntityAtField(field: SugaredRelativeSingleEntity | string, entityToConnect: EntityAccessor): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.connectEntityAtField(relativeTo.state, fieldName, entityToConnect)\n\t}\n\n\tdisconnectEntityAtField(field: SugaredRelativeSingleEntity | string, initializeReplacement?: EntityAccessor.BatchUpdatesHandler): void {\n\t\tconst desugared = QueryLanguage.desugarRelativeSingleEntity(field, this.environment)\n\t\tconst relativeTo = this.getEntity({\n\t\t\thasOneRelationPath: desugared.hasOneRelationPath.slice(0, -1),\n\t\t})\n\t\tconst fieldName = desugared.hasOneRelationPath[desugared.hasOneRelationPath.length - 1].field\n\t\tthis.operations.disconnectEntityAtField(relativeTo.state, fieldName, initializeReplacement)\n\t}\n\n\tdeleteEntity(): void {\n\t\tthis.operations.deleteEntity(this.state)\n\t}\n\n\t//\n\n\tupdateValues(fieldValuePairs: EntityAccessor.FieldValuePairs): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst entries = Array.isArray(fieldValuePairs) ? fieldValuePairs : Object.entries(fieldValuePairs)\n\n\t\t\tfor (const [field, value] of entries) {\n\t\t\t\tgetAccessor().getField(field).updateValue(value)\n\t\t\t}\n\t\t})\n\t}\n\n\t/**\n\t * Please keep in mind that this method signature is literally impossible to implement safely. The generic parameter\n\t * is really just a way to succinctly write a type cast. Nothing more, really.\n\t */\n\tgetField<Value extends FieldValue = FieldValue>(field: SugaredRelativeSingleField | string | RelativeSingleField): FieldAccessor<Value> {\n\t\tif (typeof field === 'string' || !('hasOneRelationPath' in field)) {\n\t\t\treturn this.getField<Value>(QueryLanguage.desugarRelativeSingleField(field, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(field)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getFieldPlaceholder(field.field)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (accessor) {\n\t\t\treturn accessor.getAccessor() as FieldAccessor<Value>\n\t\t}\n\n\t\tTreeNodeUtils.resolveColumn(entity.environment, field.field)\n\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ 'EntityAccessor: cannot access field '\n\t\t\t\t+ `'${field.field}' on ${TreeNodeUtils.describeLocation(entity.environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.',\n\t\t)\n\t}\n\n\tgetEntity(entity: SugaredRelativeSingleEntity | string | RelativeSingleEntity): EntityAccessorImpl {\n\t\tif (typeof entity === 'string' || !('hasOneRelationPath' in entity)) {\n\t\t\treturn this.getEntity(QueryLanguage.desugarRelativeSingleEntity(entity, this.environment))\n\t\t}\n\n\t\tlet relativeTo: EntityAccessorImpl = this\n\n\t\tfor (const hasOneRelation of entity.hasOneRelationPath) {\n\t\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasOneRelationPlaceholder(hasOneRelation)\n\t\t\tconst accessor = relativeTo.fieldData.get(fieldPlaceholder)\n\t\t\tif (!accessor) {\n\t\t\t\treturn this.raiseInvalidHasOneRelationError(relativeTo, hasOneRelation)\n\t\t\t}\n\n\t\t\trelativeTo = accessor.getAccessor() as EntityAccessorImpl\n\t\t}\n\t\treturn relativeTo\n\t}\n\n\tgetEntityList(entityList: SugaredRelativeEntityList | string | RelativeEntityList): EntityListAccessor {\n\t\tif (typeof entityList === 'string' || !('hasOneRelationPath' in entityList)) {\n\t\t\treturn this.getEntityList(QueryLanguage.desugarRelativeEntityList(entityList, this.environment))\n\t\t}\n\n\t\tconst entity = this.getEntity(entityList)\n\t\tconst fieldPlaceholder = PlaceholderGenerator.getHasManyRelationPlaceholder(entityList.hasManyRelation)\n\t\tconst accessor = entity.fieldData.get(fieldPlaceholder)\n\t\tif (!accessor) {\n\t\t\treturn this.raiseInvalidHasManyRelationError(entity, entityList.hasManyRelation)\n\t\t}\n\n\t\treturn accessor.getAccessor() as EntityListAccessor\n\t}\n\n\tprivate raiseInvalidHasOneRelationError(relativeTo: EntityAccessor, hasOneRelation: HasOneRelation): never {\n\t\tTreeNodeUtils.resolveHasOneRelation(relativeTo.environment, hasOneRelation.field, !!hasOneRelation.reducedBy)\n\n\t\tconst entityMarker = relativeTo.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasOneRelationMarker, hasOneRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasOneRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasOneRelationParameters(hasOneRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasOneRelation.field, relativeTo.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseInvalidHasManyRelationError(entity: EntityAccessor, hasManyRelation: HasManyRelation): never {\n\t\tTreeNodeUtils.resolveHasManyRelation(entity.environment, hasManyRelation.field)\n\n\t\tconst entityMarker = entity.getMarker()\n\t\tconst possibleMarkers = this.getMarkersOfType(entityMarker.fields.markers, HasManyRelationMarker, hasManyRelation.field)\n\t\tconst markerParams = possibleMarkers.map(it => PlaceholderParametersGenerator.createHasManyRelationParameters(it.parameters))\n\n\t\tconst relationParams = PlaceholderParametersGenerator.createHasManyRelationParameters(hasManyRelation)\n\n\t\tthis.raiseUndefinedRelationError(hasManyRelation.field, entity.environment, relationParams, markerParams)\n\t}\n\n\tprivate raiseUndefinedRelationError(field: string, environment: Environment, relationParams: any, otherMarkersParams: any[]): never {\n\t\tconst hint = this.createHintMessage(otherMarkersParams)\n\t\tthrow new BindingError(\n\t\t\t''\n\t\t\t\t+ `EntityAccessor: cannot access relation `\n\t\t\t\t+ `'${field}' on ${TreeNodeUtils.describeLocation(environment)}.\\n`\n\t\t\t\t+ 'The cause of the error is that this relation has not been registered during the static rendering process. As a result, it lacks a required marker and accessor.\\n\\n'\n\t\t\t\t+ 'Provided parameters:\\n'\n\t\t\t\t+ JSON.stringify(relationParams)\n\t\t\t\t+ hint,\n\t\t)\n\t}\n\n\tprivate createHintMessage(params: any[]): string {\n\t\tif (params.length === 0) {\n\t\t\treturn ''\n\t\t}\n\n\t\tconst serializedParams = params.map(it => JSON.stringify(it)).join('\\n')\n\t\tconst message = params.length === 1\n\t\t\t? 'However, there is existing marker for the same field, but it have different parameters:'\n\t\t\t: 'However, there are existing markers for the same field, but they have different parameters:'\n\n\t\treturn `\\n\\n${message}\\n${serializedParams}`\n\t}\n\n\tprivate getMarkersOfType<T extends { new(...args: any[]): HasManyRelationMarker | HasOneRelationMarker }>(\n\t\tmarkers: EntityFieldMarkers,\n\t\tmarkerConstructor: T,\n\t\tfieldName: string,\n\t): InstanceType<T>[] {\n\t\treturn Array.from(markers.values())\n\t\t\t.filter((it): it is InstanceType<T> => (it instanceof markerConstructor) && it.parameters.field === fieldName)\n\t}\n\n\tgetParent(): EntityAccessor | EntityListAccessor | undefined {\n\t\tconst blueprint = this.state.blueprint\n\t\tif (blueprint.type === 'subTree') {\n\t\t\treturn undefined\n\t\t}\n\t\treturn blueprint.parent.getAccessor()\n\t}\n\n\tgetMarker() {\n\t\treturn getEntityMarker(this.state)\n\t}\n\n\tgetFieldMeta(field: string) {\n\t\tconst fieldData = this.dataFromServer?.get(field)\n\t\treturn {\n\t\t\treadable: fieldData?.readable,\n\t\t\tupdatable: fieldData?.updatable,\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;;AAkCO,MAAM,mBAA6C;AAAA,EAGlD,YACW,OACA,YACA,WACR,KACA,MACQ,WACA,gBACR,uBACA,QACA,aACA,aACR;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACA,SAAA,YAAA;AACR,SAAA,MAAA;AACA,SAAA,OAAA;AACQ,SAAA,YAAA;AACA,SAAA,iBAAA;AACR,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAbV,kBAAA,MAAgB,UAAS,gBAAA;AAAA,EAezB;AAAA,EAEA,IAAI,aAAmC;AACtC,WAAO,KAAK,UAAU,iBAAiB,KAAK,UAAU,QAAQ;AAAA,EAC/D;AAAA;AAAA;AAAA;AAAA,EAKA,IAAI,KAAe;AAClB,WAAO,KAAK,UAAU;AAAA,EACvB;AAAA,EAEA,IAAI,iBAA0B;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,YAAY,cAAc,4BAA4B,OAAO,KAAK,WAAW;AACnF,UAAM,aAAa,KAAK,UAAU;AA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AA,EAEA,YAA6D;AAC5D,UAAM,YAAY,KAAK,MAAM;AAC7B,QAAI,UAAU,SAAS,WAAW;AACjC,aAAO;AAAA,IACR;AACA,WAAO,UAAU,OAAO,YAAA;AAAA,EACzB;AAAA,EAEA,YAAY;AACX,WAAO,gBAAgB,KAAK,KAAK;AAAA,EAClC;AAAA,EAEA,aAAa,OAAe;AAC3B,UAAM,YAAY,KAAK,gBAAgB,IAAI,KAAK;AAChD,WAAO;AAAA,MACN,UAAU,WAAW;AAAA,MACrB,WAAW,WAAW;AAAA,IAAA;AAAA,EAExB;AACD;"}
@@ -28,7 +28,7 @@ class EntityListAccessorImpl {
28
28
  }
29
29
  }
30
30
  *ids() {
31
- return this._children.keys();
31
+ yield* this._children.keys();
32
32
  }
33
33
  /**
34
34
  * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state'\nimport type { ListOperations } from '../core/operations'\nimport { EntityAccessor, EntityId, EntityListSubTreeMarker, EntityName, EntityRealmKey, Environment, ErrorAccessor,\n\tHasManyRelationMarker, RuntimeId } from '@contember/binding-common'\nimport { EntityListAccessor } from '@contember/binding-common'\n\nexport class EntityListAccessorImpl implements EntityListAccessor {\n\tpublic readonly __type = 'EntityListAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {\n\t}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic* keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key!\n\t\t}\n\t}\n\n\tpublic* ids(): IterableIterator<EntityId> {\n\t\treturn this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic* [Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n\n\tpublic getParent(): EntityAccessor | undefined {\n\t\treturn this.state.blueprint.parent?.getAccessor()\n\t}\n\n\tpublic getMarker(): EntityListSubTreeMarker | HasManyRelationMarker {\n\t\treturn this.state.blueprint.marker\n\t}\n}\n"],"names":["ErrorAccessor"],"mappings":";;;;;;AAMO,MAAM,uBAAqD;AAAA,EAG1D,YACW,OACA,YACD,MACC,WACA,uBACD,uBACA,QACA,aACA,aACf;AATgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cA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AAM;AAAA,MAAA;AAAA,IAC7B,CACA;AAAA,EAAA;AAAA,EAGK,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAc,cAAA,eAAe,KAAK,CAAC;AAAA,EAAA;AAAA,EAGzE,iBACN,OACA,UACC;AACD,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAG7D,sBACN,OACA,UACC;AACD,WAAO,KAAK,WAAW,sBAAsB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAGlE,aAAa,gBAA8D;AACjF,SAAK,WAAW,aAAa,KAAK,OAAO,cAAc;AAAA,EAAA;AAAA,EAGjD,cAAc,iBAAuC;AAC3D,SAAK,WAAW,cAAc,KAAK,OAAO,eAAe;AAAA,EAAA;AAAA,EAGnD,gBAAgB,YAA4D;AAClF,WAAO,KAAK,WAAW,gBAAgB,KAAK,OAAO,UAAU;AAAA,EAAA;AAAA,EAGvD,iBAAiB,aAA6B,UAAmC,IAAU;AACjG,SAAK,WAAW,iBAAiB,KAAK,OAAO,aAAa,OAAO;AAAA,EAAA;AAAA,EAG3D,mBAAmB,IAA8B;AACvD,WAAO,KAAK,WAAW,mBAAmB,KAAK,OAAO,EAAE;AAAA,EAAA;AAAA,EAGlD,YAAwC;AAC9C,WAAO,KAAK,MAAM,UAAU,QAAQ,YAAY;AAAA,EAAA;AAAA,EAG1C,YAA6D;AAC5D,WAAA,KAAK,MAAM,UAAU;AAAA,EAAA;AAE9B;;"}
1
+ {"version":3,"file":"EntityListAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state'\nimport type { ListOperations } from '../core/operations'\nimport {\n\tEntityAccessor,\n\tEntityId,\n\tEntityListSubTreeMarker,\n\tEntityName,\n\tEntityRealmKey,\n\tEnvironment,\n\tErrorAccessor,\n\tHasManyRelationMarker,\n\tRuntimeId,\n} from '@contember/binding-common'\nimport { EntityListAccessor } from '@contember/binding-common'\n\nexport class EntityListAccessorImpl implements EntityListAccessor {\n\tpublic readonly __type = 'EntityListAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {\n\t}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic *keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key!\n\t\t}\n\t}\n\n\tpublic *ids(): IterableIterator<EntityId> {\n\t\tyield* this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic *[Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n\n\tpublic getParent(): EntityAccessor | undefined {\n\t\treturn this.state.blueprint.parent?.getAccessor()\n\t}\n\n\tpublic getMarker(): EntityListSubTreeMarker | HasManyRelationMarker {\n\t\treturn this.state.blueprint.marker\n\t}\n}\n"],"names":["ErrorAccessor"],"mappings":";;;;;;AAeO,MAAM,uBAAqD;AAAA,EAG1D,YACW,OACA,YACD,MACC,WACA,uBACD,uBACA,QACA,aACA,aACf;AATgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAXjB,kBAAA,MAAgB,UAAS,oBAAA;AAAA,EAazB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,CAAQ,OAAyC;AAChD,eAAW,YAAY,MAAM;AAC5B,YAAM,SAAS;AAAA,IAChB;AAAA,EACD;AAAA,EAEA,CAAQ,MAAkC;AACzC,WAAO,KAAK,UAAU,KAAA;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,IAAW,uBAAsC;AAChD,WAAO,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;AAC3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E;AAAA,EACzD;AAAA,EAEO,YAAwC;AAC9C,WAAO,KAAK,MAAM,UAAU,QAAQ,YAAA;AAAA,EACrC;AAAA,EAEO,YAA6D;AACnE,WAAO,KAAK,MAAM,UAAU;AAAA,EAC7B;AACD;;"}
@@ -26,7 +26,7 @@ class EntityListAccessorImpl {
26
26
  }
27
27
  }
28
28
  *ids() {
29
- return this._children.keys();
29
+ yield* this._children.keys();
30
30
  }
31
31
  /**
32
32
  * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on
@@ -1 +1 @@
1
- {"version":3,"file":"EntityListAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/EntityListAccessorImpl.ts"],"sourcesContent":["import type { EntityListState } from '../core/state'\nimport type { ListOperations } from '../core/operations'\nimport { EntityAccessor, EntityId, EntityListSubTreeMarker, EntityName, EntityRealmKey, Environment, ErrorAccessor,\n\tHasManyRelationMarker, RuntimeId } from '@contember/binding-common'\nimport { EntityListAccessor } from '@contember/binding-common'\n\nexport class EntityListAccessorImpl implements EntityListAccessor {\n\tpublic readonly __type = 'EntityListAccessor' as const\n\n\tpublic constructor(\n\t\tprivate readonly state: EntityListState,\n\t\tprivate readonly operations: ListOperations,\n\t\tpublic readonly name: EntityName,\n\t\tprivate readonly _children: ReadonlyMap<EntityId, { getAccessor: EntityAccessor.GetEntityAccessor }>,\n\t\tprivate readonly _idsPersistedOnServer: ReadonlySet<EntityId>,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly environment: Environment,\n\t\tpublic readonly getAccessor: EntityListAccessor.GetEntityListAccessor,\n\t) {\n\t}\n\n\t/**\n\t * Returns all entity keys that are on the list.\n\t * **KEYS ARE NOT IDS!**\n\t * @see EntityAccessor.key\n\t */\n\tpublic* keys(): IterableIterator<EntityRealmKey> {\n\t\tfor (const accessor of this) {\n\t\t\tyield accessor.key!\n\t\t}\n\t}\n\n\tpublic* ids(): IterableIterator<EntityId> {\n\t\treturn this._children.keys()\n\t}\n\n\t/**\n\t * This will only contain the ids that the server knows about. Not necessarily the ids that have been added on\n\t * the list since the last server query.\n\t */\n\tpublic get idsPersistedOnServer(): Set<EntityId> {\n\t\treturn new Set(this._idsPersistedOnServer)\n\t}\n\n\tpublic* [Symbol.iterator](): IterableIterator<EntityAccessor> {\n\t\tfor (const { getAccessor } of this._children.values()) {\n\t\t\tyield getAccessor()\n\t\t}\n\t}\n\n\tpublic hasEntityId(id: EntityId): boolean {\n\t\treturn this._children.has(id)\n\t}\n\n\tpublic isEmpty(): boolean {\n\t\treturn this.length === 0\n\t}\n\n\tpublic get length(): number {\n\t\treturn this._children.size\n\t}\n\n\tpublic hasEntityOnServer(entityOrItsId: EntityAccessor | EntityId): boolean {\n\t\tif (typeof entityOrItsId === 'string' || typeof entityOrItsId === 'number') {\n\t\t\treturn this.idsPersistedOnServer.has(entityOrItsId)\n\t\t}\n\t\tconst idOnServer = entityOrItsId.idOnServer\n\t\tif (idOnServer === undefined) {\n\t\t\treturn false\n\t\t}\n\t\treturn this.idsPersistedOnServer.has(idOnServer)\n\t}\n\n\tpublic deleteAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tentity.deleteEntity()\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic disconnectAll(): void {\n\t\tthis.batchUpdates(getAccessor => {\n\t\t\tconst list = getAccessor()\n\t\t\tfor (const entity of list) {\n\t\t\t\tlist.disconnectEntity(entity)\n\t\t\t}\n\t\t})\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic addEventListener<Type extends keyof EntityListAccessor.RuntimeEntityListEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityListAccessor.EntityListEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic addChildEventListener<Type extends keyof EntityAccessor.EntityEventListenerMap>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: EntityAccessor.EntityEventListenerMap[Type],\n\t) {\n\t\treturn this.operations.addChildEventListener(this.state, event, listener)\n\t}\n\n\tpublic batchUpdates(performUpdates: EntityListAccessor.BatchUpdatesHandler): void {\n\t\tthis.operations.batchUpdates(this.state, performUpdates)\n\t}\n\n\tpublic connectEntity(entityToConnect: EntityAccessor): void {\n\t\tthis.operations.connectEntity(this.state, entityToConnect)\n\t}\n\n\tpublic createNewEntity(initialize?: EntityAccessor.BatchUpdatesHandler): RuntimeId {\n\t\treturn this.operations.createNewEntity(this.state, initialize)\n\t}\n\n\tpublic disconnectEntity(childEntity: EntityAccessor, options: { noPersist?: boolean } = {}): void {\n\t\tthis.operations.disconnectEntity(this.state, childEntity, options)\n\t}\n\n\tpublic getChildEntityById(id: EntityId): EntityAccessor {\n\t\treturn this.operations.getChildEntityById(this.state, id)\n\t}\n\n\tpublic getParent(): EntityAccessor | undefined {\n\t\treturn this.state.blueprint.parent?.getAccessor()\n\t}\n\n\tpublic getMarker(): EntityListSubTreeMarker | HasManyRelationMarker {\n\t\treturn this.state.blueprint.marker\n\t}\n}\n"],"names":[],"mappings":";;;;AAMO,MAAM,uBAAqD;AAAA,EAG1D,YACW,OACA,YACD,MACC,WACA,uBACD,uBACA,QACA,aACA,aACf;AATgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,OAAA;AACC,SAAA,YAAA;AACA,SAAA,wBAAA;AACD,SAAA,wBAAA;AACA,SAAA,SAAA;AACA,SAAA,cAAA;AACA,SAAA,cAAA;AAXjB,kBAAA,MAAiB,UAAS,oBAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAoB1B,CAAQ,OAAyC;AAChD,eAAW,YAAY,MAAM;AAC5B,YAAM,SAAS;AAAA,IAAA;AAAA,EAChB;AAAA,EAGD,CAAQ,MAAkC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AO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAG7D,sBACN,OACA,UACC;AACD,WAAO,KAAK,WAAW,sBAAsB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAGlE,aAAa,gBAA8D;AACjF,SAAK,WAAW,aAAa,KAAK,OAAO,cAAc;AAAA,EAAA;AAAA,EAGjD,cAAc,iBAAuC;AAC3D,SAAK,WAAW,cAAc,KAAK,OAAO,eAAe;AAAA,EAAA;AAAA,EAGnD,gBAAgB,YAA4D;AAClF,WAAO,KAAK,WAAW,gBAAgB,KAAK,OAAO,UAAU;AAAA,EAAA;AAAA,EAGvD,iBAAiB,aAA6B,UAAmC,IAAU;AACjG,SAAK,WAAW,iBAAiB,KAAK,OAAO,aAAa,OAAO;AAAA,EAAA;AAAA,EAG3D,mBAAmB,IAA8B;AACvD,WAAO,KAAK,WAAW,mBAAmB,KAAK,OAAO,EAAE;AAAA,EAAA;AAAA,EAGlD,YAAwC;AAC9C,WAAO,KAAK,MAAM,UAAU,QAAQ,YAAY;AAAA,EAAA;AAAA,EAG1C,YAA6D;AAC5D,WAAA,KAAK,MAAM,UAAU;AAAA,EAAA;AAE9B;"}
1
+ {"version":3,"file":"EntityListAccessorImpl.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":";;;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.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":["ErrorAccessor","TemporalFieldHelper","UuidFieldHelper"],"mappings":";;;;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAAA;AAAA,EAiBlB,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAc,cAAA,eAAe,KAAK,CAAC;AAAA,EAAA;AAAA,EAGzE,cAAoB;AACrB,SAAA,WAAW,YAAY,KAAK,KAAK;AAAA,EAAA;AAAA,EAGhC,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAG7D,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAAA;AAAA,EAGnD,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EAAA;AAAA,EAGrC,IAAW,YAAY;AACf,WAAA,KAAK,YAAY,MAAM;AAAA,EAAA;AAAA;AAAA,EAK/B,IAAW,aAAkC;AACrC,WAAA,IAAIC,oBAAAA,oBAAoB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAGvF,IAAW,SAA0B;AAC7B,WAAA,IAAIC,gBAAAA,gBAAgB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAG5E,YAA4B;AAC3B,WAAA,KAAK,MAAM,OAAO,YAAY;AAAA,EAAA;AAEvC;;"}
1
+ {"version":3,"file":"FieldAccessorImpl.cjs","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":["ErrorAccessor","TemporalFieldHelper","UuidFieldHelper"],"mappings":";;;;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAezB;AAAA,EAEO,SAAS,OAAiD;AAChE,WAAO,KAAK,WAAW,SAAS,KAAK,OAAOA,cAAAA,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEO,cAAoB;AAC1B,SAAK,WAAW,YAAY,KAAK,KAAK;AAAA,EACvC;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEO,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAC1D;AAAA,EAEO,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EACrC;AAAA,EAEA,IAAW,YAAY;AACtB,WAAO,KAAK,YAAY,MAAM;AAAA,EAC/B;AAAA;AAAA,EAIA,IAAW,aAAkC;AAC5C,WAAO,IAAIC,oBAAAA,oBAAoB,KAAK,WAAkD;AAAA,EACvF;AAAA,EAEA,IAAW,SAA0B;AACpC,WAAO,IAAIC,gBAAAA,gBAAgB,KAAK,WAAkD;AAAA,EACnF;AAAA,EAEO,YAA4B;AAClC,WAAO,KAAK,MAAM,OAAO,YAAA;AAAA,EAC1B;AACD;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"FieldAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAAA;AAAA,EAiBlB,SAAS,OAAiD;AACzD,WAAA,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAAA;AAAA,EAGzE,cAAoB;AACrB,SAAA,WAAW,YAAY,KAAK,KAAK;AAAA,EAAA;AAAA,EAGhC,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EAAA;AAAA,EAG7D,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAAA;AAAA,EAGnD,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EAAA;AAAA,EAGrC,IAAW,YAAY;AACf,WAAA,KAAK,YAAY,MAAM;AAAA,EAAA;AAAA;AAAA,EAK/B,IAAW,aAAkC;AACrC,WAAA,IAAI,oBAAoB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAGvF,IAAW,SAA0B;AAC7B,WAAA,IAAI,gBAAgB,KAAK,WAAkD;AAAA,EAAA;AAAA,EAG5E,YAA4B;AAC3B,WAAA,KAAK,MAAM,OAAO,YAAY;AAAA,EAAA;AAEvC;"}
1
+ {"version":3,"file":"FieldAccessorImpl.js","sources":["../../../../../packages/binding-legacy/src/accessors/FieldAccessorImpl.ts"],"sourcesContent":["import type { FieldState } from '../core/state'\nimport type { FieldOperations } from '../core/operations'\nimport { TemporalFieldHelper, UuidFieldHelper } from '../fieldHelpers'\nimport { EntityAccessor, ErrorAccessor, FieldAccessor, FieldName, FieldValue, SchemaColumn } from '@contember/binding-common'\n\nexport class FieldAccessorImpl<Value extends FieldValue = FieldValue> implements FieldAccessor {\n\tpublic readonly __type = 'FieldAccessor' as const\n\n\tconstructor(\n\t\tprivate readonly state: FieldState<Value>,\n\t\tprivate readonly operations: FieldOperations,\n\t\tpublic readonly fieldName: FieldName,\n\t\tpublic readonly value: Value | null,\n\t\tpublic readonly valueOnServer: Value | null,\n\t\tpublic readonly defaultValue: Value | undefined,\n\t\tpublic readonly errors: ErrorAccessor | undefined,\n\t\tpublic readonly hasUnpersistedChanges: boolean,\n\t\tprivate readonly touchLog: ReadonlySet<string> | undefined,\n\t\tpublic readonly getAccessor: FieldAccessor.GetFieldAccessor<Value>,\n\t\tpublic readonly schema: SchemaColumn,\n\t) {\n\t}\n\n\tpublic addError(error: ErrorAccessor.Error | string): () => void {\n\t\treturn this.operations.addError(this.state, ErrorAccessor.normalizeError(error))\n\t}\n\n\tpublic clearErrors(): void {\n\t\tthis.operations.clearErrors(this.state)\n\t}\n\n\tpublic addEventListener<Type extends keyof FieldAccessor.FieldEventListenerMap<Value>>(\n\t\tevent: { type: Type; key?: string },\n\t\tlistener: FieldAccessor.FieldEventListenerMap<Value>[Type],\n\t): () => void {\n\t\treturn this.operations.addEventListener(this.state, event, listener)\n\t}\n\n\tpublic updateValue(newValue: Value | null, options?: FieldAccessor.UpdateOptions): void {\n\t\tthis.operations.updateValue(this.state, newValue, options)\n\t}\n\n\tpublic isTouchedBy(agent: 'user' | (string & {})) {\n\t\treturn this.touchLog?.has(agent) ?? false\n\t}\n\n\tpublic get isTouched() {\n\t\treturn this.isTouchedBy('user')\n\t}\n\n\t// helpers\n\n\tpublic get asTemporal(): TemporalFieldHelper {\n\t\treturn new TemporalFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic get asUuid(): UuidFieldHelper {\n\t\treturn new UuidFieldHelper(this.getAccessor as FieldAccessor.GetFieldAccessor<any>)\n\t}\n\n\tpublic getParent(): EntityAccessor {\n\t\treturn this.state.parent.getAccessor()\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,kBAAkF;AAAA,EAG9F,YACkB,OACA,YACD,WACA,OACA,eACA,cACA,QACA,uBACC,UACD,aACA,QACf;AAXgB,SAAA,QAAA;AACA,SAAA,aAAA;AACD,SAAA,YAAA;AACA,SAAA,QAAA;AACA,SAAA,gBAAA;AACA,SAAA,eAAA;AACA,SAAA,SAAA;AACA,SAAA,wBAAA;AACC,SAAA,WAAA;AACD,SAAA,cAAA;AACA,SAAA,SAAA;AAbjB,kBAAA,MAAgB,UAAS,eAAA;AAAA,EAezB;AAAA,EAEO,SAAS,OAAiD;AAChE,WAAO,KAAK,WAAW,SAAS,KAAK,OAAO,cAAc,eAAe,KAAK,CAAC;AAAA,EAChF;AAAA,EAEO,cAAoB;AAC1B,SAAK,WAAW,YAAY,KAAK,KAAK;AAAA,EACvC;AAAA,EAEO,iBACN,OACA,UACa;AACb,WAAO,KAAK,WAAW,iBAAiB,KAAK,OAAO,OAAO,QAAQ;AAAA,EACpE;AAAA,EAEO,YAAY,UAAwB,SAA6C;AACvF,SAAK,WAAW,YAAY,KAAK,OAAO,UAAU,OAAO;AAAA,EAC1D;AAAA,EAEO,YAAY,OAA+B;AACjD,WAAO,KAAK,UAAU,IAAI,KAAK,KAAK;AAAA,EACrC;AAAA,EAEA,IAAW,YAAY;AACtB,WAAO,KAAK,YAAY,MAAM;AAAA,EAC/B;AAAA;AAAA,EAIA,IAAW,aAAkC;AAC5C,WAAO,IAAI,oBAAoB,KAAK,WAAkD;AAAA,EACvF;AAAA,EAEA,IAAW,SAA0B;AACpC,WAAO,IAAI,gBAAgB,KAAK,WAAkD;AAAA,EACnF;AAAA,EAEO,YAA4B;AAClC,WAAO,KAAK,MAAM,OAAO,YAAA;AAAA,EAC1B;AACD;"}