@hops-ops/distributed 4.4.0 → 4.4.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.
|
@@ -13,7 +13,7 @@ function assertActualProjectionCapabilities(contract, delta) {
|
|
|
13
13
|
for (const reference of item.projection_refs)
|
|
14
14
|
references.add(reference);
|
|
15
15
|
}
|
|
16
|
-
let
|
|
16
|
+
let selectedEvents;
|
|
17
17
|
for (const reference of references) {
|
|
18
18
|
const operations = delta.operations.filter((item) => item.occurrence_ordinal === ordinal &&
|
|
19
19
|
item.projection_refs.includes(reference));
|
|
@@ -22,20 +22,27 @@ function assertActualProjectionCapabilities(contract, delta) {
|
|
|
22
22
|
const candidates = contract.capabilities.arms.filter((arm) => arm.projection_ref === reference &&
|
|
23
23
|
operations.every(({ mutation }) => capabilityAllowsMutation(arm, mutation)) &&
|
|
24
24
|
recoveries.every(({ target }) => capabilityAllowsRecovery(arm, target)));
|
|
25
|
-
if (candidates.length
|
|
26
|
-
throw new Error('actual projection delta
|
|
25
|
+
if (candidates.length === 0) {
|
|
26
|
+
throw new Error('actual projection delta is outside every generated event arm');
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const candidateEvents = new Map(candidates.map(({ event }) => [eventIdentity(event), event]));
|
|
29
|
+
if (selectedEvents === undefined) {
|
|
30
|
+
selectedEvents = candidateEvents;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
for (const identity of selectedEvents.keys()) {
|
|
34
|
+
if (!candidateEvents.has(identity))
|
|
35
|
+
selectedEvents.delete(identity);
|
|
36
|
+
}
|
|
37
|
+
if (selectedEvents.size === 0) {
|
|
33
38
|
throw new Error('actual projection refs disagree on their generated event arm');
|
|
34
39
|
}
|
|
35
|
-
selectedEvent = event;
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
}
|
|
43
|
+
function eventIdentity(event) {
|
|
44
|
+
return JSON.stringify([event.id, event.name, event.version]);
|
|
45
|
+
}
|
|
39
46
|
function capabilityAllowsMutation(arm, mutation) {
|
|
40
47
|
switch (mutation.op) {
|
|
41
48
|
case 'upsert': {
|
package/package.json
CHANGED