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

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 (200) 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 +24 -2
  36. package/dist/development/src/core/StateInitializer.cjs.map +1 -1
  37. package/dist/development/src/core/StateInitializer.js +25 -3
  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 +24 -2
  116. package/dist/production/src/core/StateInitializer.cjs.map +1 -1
  117. package/dist/production/src/core/StateInitializer.js +25 -3
  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 +1 -0
  171. package/dist/types/core/StateInitializer.d.ts.map +1 -1
  172. package/dist/types/core/TreeAugmenter.d.ts.map +1 -1
  173. package/dist/types/core/TreeStore.d.ts.map +1 -1
  174. package/dist/types/core/operations/FieldOperations.d.ts.map +1 -1
  175. package/dist/types/core/operations/ListOperations.d.ts.map +1 -1
  176. package/dist/types/core/state/EntityListState.d.ts.map +1 -1
  177. package/dist/types/tsconfig.tsbuildinfo +1 -1
  178. package/package.json +10 -5
  179. package/src/accessorTree/NormalizedPersistedData.ts +1 -1
  180. package/src/accessors/EntityAccessorImpl.ts +13 -11
  181. package/src/accessors/EntityListAccessorImpl.ts +16 -7
  182. package/src/core/AccessorErrorManager.ts +2 -2
  183. package/src/core/DataBinding.ts +24 -15
  184. package/src/core/ErrorsPreprocessor.ts +4 -5
  185. package/src/core/EventManager.ts +34 -46
  186. package/src/core/MutationGenerator.ts +23 -27
  187. package/src/core/QueryGenerator.ts +4 -5
  188. package/src/core/RealmKeyGenerator.ts +5 -3
  189. package/src/core/RequestResponseNormalizer.ts +3 -8
  190. package/src/core/StateInitializer.ts +34 -19
  191. package/src/core/TreeAugmenter.ts +8 -15
  192. package/src/core/TreeStore.ts +5 -4
  193. package/src/core/operations/EntityOperations.ts +25 -25
  194. package/src/core/operations/FieldOperations.ts +15 -17
  195. package/src/core/operations/ListOperations.ts +15 -15
  196. package/src/core/operations/OperationsHelpers.ts +2 -2
  197. package/src/core/state/EntityListState.ts +3 -9
  198. package/src/fieldHelpers/helpers/TemporalFieldHelper.ts +3 -3
  199. package/src/utils/assertNever.ts +4 -4
  200. package/tests/example.test.ts +2 -2
@@ -56,14 +56,14 @@ export class EntityOperations {
56
56
 
57
57
  if (fieldSchema === undefined) {
58
58
  throw new BindingError(
59
- `EntityAccessor.connectEntityAtField: Unknown field ${entityName}.${fieldName}.\n\n` +
60
- `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
59
+ `EntityAccessor.connectEntityAtField: Unknown field ${entityName}.${fieldName}.\n\n`
60
+ + `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
61
61
  )
62
62
  } else if (fieldSchema.__typename === '_Column') {
63
63
  throw new BindingError(
64
- `EntityAccessor.connectEntityAtField: Cannot connect at field ${entityName}.${fieldName} because ` +
65
- `it's not a has-one relation.\n\n` +
66
- `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
64
+ `EntityAccessor.connectEntityAtField: Cannot connect at field ${entityName}.${fieldName} because `
65
+ + `it's not a has-one relation.\n\n`
66
+ + `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
67
67
  )
68
68
  }
69
69
 
@@ -73,19 +73,19 @@ export class EntityOperations {
73
73
  const previouslyConnectedState = state.children.get(targetHasOneMarker.placeholderName)
74
74
 
75
75
  if (
76
- previouslyConnectedState === undefined ||
77
- previouslyConnectedState.type === 'field' ||
78
- previouslyConnectedState.type === 'entityList'
76
+ previouslyConnectedState === undefined
77
+ || previouslyConnectedState.type === 'field'
78
+ || previouslyConnectedState.type === 'entityList'
79
79
  ) {
80
80
  OperationsHelpers.rejectInvalidAccessorTree()
81
81
  }
82
82
 
83
83
  if (previouslyConnectedState.entity.entityName !== stateToConnect.entity.entityName) {
84
84
  throw new BindingError(
85
- `EntityAccessor.connectEntityAtField: Attempting to connect at field ${entityName}.${fieldName} ` +
86
- `an entity of type '${stateToConnect.entity.entityName}' but ` +
87
- `'${previouslyConnectedState.entity.entityName}' is expected.\n\n` +
88
- `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
85
+ `EntityAccessor.connectEntityAtField: Attempting to connect at field ${entityName}.${fieldName} `
86
+ + `an entity of type '${stateToConnect.entity.entityName}' but `
87
+ + `'${previouslyConnectedState.entity.entityName}' is expected.\n\n`
88
+ + `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
89
89
  )
90
90
  }
91
91
 
@@ -94,21 +94,21 @@ export class EntityOperations {
94
94
  } catch (error) {
95
95
  if (error instanceof LocalizedBindingError) {
96
96
  throw new BindingError(
97
- `EntityAccessor: cannot connect entity with key '${entityToConnect.key}' because its fields are` +
98
- `incompatible with entities found at field '${fieldName}'. Make sure both trees are equivalent.\n\n` +
99
- `${error.message}\n\n` +
100
- (error.markerPath.length > 1
97
+ `EntityAccessor: cannot connect entity with key '${entityToConnect.key}' because its fields are`
98
+ + `incompatible with entities found at field '${fieldName}'. Make sure both trees are equivalent.\n\n`
99
+ + `${error.message}\n\n`
100
+ + (error.markerPath.length > 1
101
101
  ? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\n\n`
102
- : '') +
103
- `Entity located at: ${ErrorLocator.locateInternalState(state)}.`,
102
+ : '')
103
+ + `Entity located at: ${ErrorLocator.locateInternalState(state)}.`,
104
104
  )
105
105
  }
106
106
  throw error
107
107
  }
108
108
 
109
109
  if (
110
- previouslyConnectedState === stateToConnect ||
111
- previouslyConnectedState.entity.id.value === stateToConnect.entity.id.value
110
+ previouslyConnectedState === stateToConnect
111
+ || previouslyConnectedState.entity.id.value === stateToConnect.entity.id.value
112
112
  ) {
113
113
  continue // Do nothing.
114
114
  }
@@ -130,9 +130,9 @@ export class EntityOperations {
130
130
  changesDelta++ // We're changing it from the persisted id.
131
131
  } else if (!previouslyConnectedState.entity.id.existsOnServer) {
132
132
  if (
133
- persistedId === null || // We're updating.
134
- (persistedId === undefined && // We're creating.
135
- (!fieldsToConnect.hasAtLeastOneBearingField || !targetHasOneMarker.parameters.isNonbearing))
133
+ persistedId === null // We're updating.
134
+ || (persistedId === undefined // We're creating.
135
+ && (!fieldsToConnect.hasAtLeastOneBearingField || !targetHasOneMarker.parameters.isNonbearing))
136
136
  ) {
137
137
  changesDelta++
138
138
  }
@@ -171,8 +171,8 @@ export class EntityOperations {
171
171
  const stateToDisconnect = state.children.get(targetHasOneMarker.placeholderName)
172
172
 
173
173
  if (
174
- stateToDisconnect === undefined ||
175
- (stateToDisconnect.type !== 'entityRealm' && stateToDisconnect.type !== 'entityRealmStub')
174
+ stateToDisconnect === undefined
175
+ || (stateToDisconnect.type !== 'entityRealm' && stateToDisconnect.type !== 'entityRealmStub')
176
176
  ) {
177
177
  OperationsHelpers.rejectInvalidAccessorTree()
178
178
  }
@@ -59,21 +59,21 @@ export class FieldOperations {
59
59
  if (import.meta.env.DEV) {
60
60
  if (newValue !== fieldState.value && (fieldState.touchLog !== undefined || entity.hasIdSetInStone)) {
61
61
  throw new BindingError(
62
- `Trying to set the '${PRIMARY_KEY_NAME}' field for the second time. This is prohibited.\n` +
63
- `Once set, it is immutable.`,
62
+ `Trying to set the '${PRIMARY_KEY_NAME}' field for the second time. This is prohibited.\n`
63
+ + `Once set, it is immutable.`,
64
64
  )
65
65
  }
66
66
  if (typeof newValue !== 'string' || !uuidValidate(newValue)) {
67
67
  throw new BindingError(
68
- `Invalid value supplied for the '${PRIMARY_KEY_NAME}' field. ` +
69
- `Expecting a valid uuid but '${newValue}' was given.\n` +
70
- `Hint: you may use 'FieldAccessor.asUuid.setToUuid()'.`,
68
+ `Invalid value supplied for the '${PRIMARY_KEY_NAME}' field. `
69
+ + `Expecting a valid uuid but '${newValue}' was given.\n`
70
+ + `Hint: you may use 'FieldAccessor.asUuid.setToUuid()'.`,
71
71
  )
72
72
  }
73
73
  if (this.treeStore.entityStore.has(ServerId.formatUniqueValue(newValue, entity.entityName))) {
74
74
  throw new BindingError(
75
- `Trying to set the '${PRIMARY_KEY_NAME}' field to '${newValue}' which is a valid uuid but is not unique. ` +
76
- `It is already in use by an existing entity.`,
75
+ `Trying to set the '${PRIMARY_KEY_NAME}' field to '${newValue}' which is a valid uuid but is not unique. `
76
+ + `It is already in use by an existing entity.`,
77
77
  )
78
78
  }
79
79
  }
@@ -98,21 +98,19 @@ export class FieldOperations {
98
98
  field.touchLog.add(agent)
99
99
  field.value = newValue
100
100
 
101
- const resolvedValue =
102
- field.fieldMarker.defaultValue === undefined
103
- ? newValue
104
- : newValue === null
105
- ? field.fieldMarker.defaultValue
106
- : newValue
101
+ const resolvedValue = field.fieldMarker.defaultValue === undefined
102
+ ? newValue
103
+ : newValue === null
104
+ ? field.fieldMarker.defaultValue
105
+ : newValue
107
106
  const normalizedPersistedValue = field.persistedValue === undefined ? null : field.persistedValue
108
107
  const hadUnpersistedChangesBefore = field.hasUnpersistedChanges
109
108
  const hasUnpersistedChangesNow = resolvedValue !== normalizedPersistedValue
110
109
  field.hasUnpersistedChanges = hasUnpersistedChangesNow
111
110
 
112
- const shouldInfluenceUpdateCount =
113
- !getEntityMarker(parent).fields.hasAtLeastOneBearingField ||
114
- !field.fieldMarker.isNonbearing ||
115
- field.persistedValue !== undefined
111
+ const shouldInfluenceUpdateCount = !getEntityMarker(parent).fields.hasAtLeastOneBearingField
112
+ || !field.fieldMarker.isNonbearing
113
+ || field.persistedValue !== undefined
116
114
 
117
115
  let changesDelta = EventManager.NO_CHANGES_DIFFERENCE
118
116
 
@@ -69,9 +69,9 @@ export class ListOperations {
69
69
  for (const state of StateIterator.eachSiblingRealmChild(this.treeStore, outerState)) {
70
70
  if (state.entityName !== stateToConnect.entity.entityName) {
71
71
  throw new BindingError(
72
- `EntityListAccessor.connectEntity: Attempting to connect at an entity of type ` +
73
- `'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\n\n` +
74
- `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
72
+ `EntityListAccessor.connectEntity: Attempting to connect at an entity of type `
73
+ + `'${stateToConnect.entity.entityName}' but '${state.entityName}' is expected.\n\n`
74
+ + `Entity located at: ${ErrorLocator.locateInternalState(outerState)}.`,
75
75
  )
76
76
  }
77
77
 
@@ -83,13 +83,13 @@ export class ListOperations {
83
83
  } catch (error) {
84
84
  if (error instanceof LocalizedBindingError) {
85
85
  throw new BindingError(
86
- `Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are ` +
87
- `incompatible with entities found on this list. Make sure both trees are equivalent.\n\n` +
88
- `${error.message}\n\n` +
89
- (error.markerPath.length > 1
86
+ `Entity list: cannot connect entity with key '${entityToConnect.key}' because its fields are `
87
+ + `incompatible with entities found on this list. Make sure both trees are equivalent.\n\n`
88
+ + `${error.message}\n\n`
89
+ + (error.markerPath.length > 1
90
90
  ? `Incompatibility found at: ${ErrorLocator.locateMarkerPath(error.markerPath)}.\n\n`
91
- : '') +
92
- `Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,
91
+ : '')
92
+ + `Entity list located at: ${ErrorLocator.locateInternalState(state)}.`,
93
93
  )
94
94
  }
95
95
  throw error
@@ -124,7 +124,7 @@ export class ListOperations {
124
124
  })
125
125
  }
126
126
 
127
- public disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: {noPersist?: boolean}) {
127
+ public disconnectEntity(listState: EntityListState, childEntity: EntityAccessor, options: { noPersist?: boolean }) {
128
128
  this.eventManager.syncOperation(() => {
129
129
  // TODO disable this at the top-level.
130
130
  const persistedEntityIds = this.treeStore.getEntityListPersistedIds(listState)
@@ -205,11 +205,11 @@ export class ListOperations {
205
205
  }
206
206
  const looksLikeKey = typeof id === 'string' && (this.treeStore.entityRealmStore.has(id) || RealmKeyGenerator.vaguelyAppearsToBeAKey(id))
207
207
  throw new BindingError(
208
- `EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.` +
209
- (looksLikeKey
210
- ? `\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids ` +
211
- `and you can use \`EntityAccessor.id\` to obtain one. Keys, on the other hand, are globally unique and ` +
212
- `you can use \`getEntityByKey\` to get its EntityAccessor.`
208
+ `EntityList: cannot retrieve an entity with id '${id}' because it's not a valid id.`
209
+ + (looksLikeKey
210
+ ? `\nThe supplied value appears to be an entity *key*, not an *id*. List accessors are indexed by ids `
211
+ + `and you can use \`EntityAccessor.id\` to obtain one. Keys, on the other hand, are globally unique and `
212
+ + `you can use \`getEntityByKey\` to get its EntityAccessor.`
213
213
  : ''),
214
214
  )
215
215
  }
@@ -29,7 +29,7 @@ export class OperationsHelpers {
29
29
  throw new BindingError(`Attempting to connect an entity with key '${entityToConnectKey}' but it doesn't exist.`)
30
30
  }
31
31
  // TODO This is commented out for now in order to at least somewhat mitigate the limitations of dealing with
32
- // inverse relations. However, once that has been addressed systemically, this code needs to be re-enabled.
32
+ // inverse relations. However, once that has been addressed systemically, this code needs to be re-enabled.
33
33
  // if (!stateToConnect.entity.id.existsOnServer) {
34
34
  // throw new BindingError(
35
35
  // `Attempting to connect an entity with key '${stateToConnect.realmKey}' that ` +
@@ -134,7 +134,7 @@ export class OperationsHelpers {
134
134
  // Version 1.
135
135
  // The listeners subscribed to a particular entity key so we no longer want to call these.
136
136
  // The only positionally associated listeners are in the blueprint so we re-initialize those.
137
- //realm.eventListeners = stateInitializer.initializeEntityEventListenerStore(realmBlueprint)
137
+ // realm.eventListeners = stateInitializer.initializeEntityEventListenerStore(realmBlueprint)
138
138
 
139
139
  // Version 2.
140
140
  // This is version two of this terrible hack. We want to preserve e.g. persistSuccess handlers.
@@ -1,12 +1,6 @@
1
1
  import type { EntityListAccessor, ErrorAccessor } from '@contember/binding-common'
2
2
  import type { EntityListSubTreeMarker, HasManyRelationMarker } from '@contember/binding-common'
3
- import type {
4
- EntityEventListenerStore,
5
- EntityId,
6
- EntityListEventListenerStore,
7
- EntityName,
8
- RemovalType,
9
- } from '@contember/binding-common'
3
+ import type { EntityEventListenerStore, EntityId, EntityListEventListenerStore, EntityName, RemovalType } from '@contember/binding-common'
10
4
  import type { BijectiveIndexedMap } from '@contember/utilities'
11
5
  import type { EntityRealmState, EntityRealmStateStub } from './EntityRealmState'
12
6
 
@@ -15,12 +9,12 @@ export type EntityListBlueprint =
15
9
  readonly type: 'hasMany'
16
10
  readonly marker: HasManyRelationMarker
17
11
  readonly parent: EntityRealmState
18
- }
12
+ }
19
13
  | {
20
14
  readonly type: 'subTree'
21
15
  readonly marker: EntityListSubTreeMarker
22
16
  readonly parent: undefined
23
- }
17
+ }
24
18
 
25
19
  export interface EntityListState {
26
20
  type: 'entityList'
@@ -6,9 +6,9 @@ class TemporalFieldHelper extends FieldHelper<string> {
6
6
  this.getAccessor().updateValue(new Date().toISOString(), options)
7
7
  }
8
8
 
9
- //public setToDate() TODO
10
- //public setToTime() TODO
11
- //public setToDateTime() TODO
9
+ // public setToDate() TODO
10
+ // public setToTime() TODO
11
+ // public setToDateTime() TODO
12
12
  }
13
13
  namespace TemporalFieldHelper {
14
14
  export const setToNow = (
@@ -2,9 +2,9 @@ import { BindingError } from '@contember/binding-common'
2
2
 
3
3
  export function assertNever(_: never): never {
4
4
  throw new BindingError(
5
- `FATAL ERROR. This should absolutely never have happened. Yet, despite all efforts, here we are. ` +
6
- `Please find solace in having a good laugh about the whole situation. ` +
7
- `You have just witnessed true harshness of software development. ` +
8
- `Please report this bug.`,
5
+ `FATAL ERROR. This should absolutely never have happened. Yet, despite all efforts, here we are. `
6
+ + `Please find solace in having a good laugh about the whole situation. `
7
+ + `You have just witnessed true harshness of software development. `
8
+ + `Please report this bug.`,
9
9
  )
10
10
  }
@@ -1,5 +1,5 @@
1
1
  import { describe, test } from 'bun:test'
2
2
 
3
- describe('@contember/binding-legacy', function () {
4
- test('@contember/binding-legacy', function () { })
3
+ describe('@contember/binding-legacy', function() {
4
+ test('@contember/binding-legacy', function() {})
5
5
  })