@rotorsoft/act 1.31.19 → 1.31.21
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.
package/dist/index.js
CHANGED
|
@@ -4870,6 +4870,25 @@ function register_new_state(state2, states, actions, events) {
|
|
|
4870
4870
|
events[name] = { schema: state2.events[name], reactions: /* @__PURE__ */ new Map() };
|
|
4871
4871
|
}
|
|
4872
4872
|
}
|
|
4873
|
+
function pick_declared(existing, incoming, what, state_name) {
|
|
4874
|
+
if (existing && incoming && existing !== incoming)
|
|
4875
|
+
throw new Error(`Duplicate ${what} for state "${state_name}"`);
|
|
4876
|
+
return incoming ?? existing;
|
|
4877
|
+
}
|
|
4878
|
+
function autoclose_of(existing, state2) {
|
|
4879
|
+
pick_declared(
|
|
4880
|
+
existing.autoclose,
|
|
4881
|
+
state2.autoclose,
|
|
4882
|
+
"autoclose policy",
|
|
4883
|
+
state2.name
|
|
4884
|
+
);
|
|
4885
|
+
const owner = state2.autoclose ? state2 : existing;
|
|
4886
|
+
return {
|
|
4887
|
+
autoclose: owner.autoclose,
|
|
4888
|
+
autoclose_after_days: owner.autoclose_after_days,
|
|
4889
|
+
autoclose_keep_days: owner.autoclose_keep_days
|
|
4890
|
+
};
|
|
4891
|
+
}
|
|
4873
4892
|
function merge_into_existing(state2, existing, states, actions, events) {
|
|
4874
4893
|
for (const name of Object.keys(state2.actions)) {
|
|
4875
4894
|
if (existing.actions[name] === state2.actions[name]) continue;
|
|
@@ -4894,11 +4913,26 @@ function merge_into_existing(state2, existing, states, actions, events) {
|
|
|
4894
4913
|
patch: merged_patch,
|
|
4895
4914
|
on: { ...existing.on, ...state2.on },
|
|
4896
4915
|
given: { ...existing.given, ...state2.given },
|
|
4897
|
-
snap:
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4916
|
+
snap: pick_declared(existing.snap, state2.snap, "snap strategy", state2.name),
|
|
4917
|
+
// Per-action retry policy is keyed by action name, so the two partials'
|
|
4918
|
+
// maps combine. Left `undefined` when neither declared one, so the
|
|
4919
|
+
// orchestrator's `me.options?.[action]` lookup is unchanged.
|
|
4920
|
+
options: existing.options || state2.options ? { ...existing.options, ...state2.options } : void 0,
|
|
4921
|
+
disclose: pick_declared(
|
|
4922
|
+
existing.disclose,
|
|
4923
|
+
state2.disclose,
|
|
4924
|
+
"disclosure predicate",
|
|
4925
|
+
state2.name
|
|
4926
|
+
),
|
|
4927
|
+
archive: pick_declared(
|
|
4928
|
+
existing.archive,
|
|
4929
|
+
state2.archive,
|
|
4930
|
+
"archiver",
|
|
4931
|
+
state2.name
|
|
4932
|
+
),
|
|
4933
|
+
// `.autocloses(...)` sets its two day fields alongside the predicate, so
|
|
4934
|
+
// the whole triple travels together from whichever partial declared it.
|
|
4935
|
+
...autoclose_of(existing, state2)
|
|
4902
4936
|
};
|
|
4903
4937
|
states.set(state2.name, merged);
|
|
4904
4938
|
for (const name of Object.keys(merged.actions)) {
|