@dudousxd/nestjs-durable-core 0.85.9 → 0.85.10
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.cjs +42 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +39 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
NestedWorkflowCallError: () => NestedWorkflowCallError,
|
|
57
57
|
NonDeterminismError: () => NonDeterminismError,
|
|
58
58
|
QueueController: () => QueueController,
|
|
59
|
+
REMOTE_EVENT: () => REMOTE_EVENT,
|
|
59
60
|
RUN_HISTORY_FIXTURE_VERSION: () => RUN_HISTORY_FIXTURE_VERSION,
|
|
60
61
|
RUN_VALUE_FACET_LIMIT: () => RUN_VALUE_FACET_LIMIT,
|
|
61
62
|
RUN_VALUE_FACET_SCAN: () => RUN_VALUE_FACET_SCAN,
|
|
@@ -146,11 +147,13 @@ __export(index_exports, {
|
|
|
146
147
|
isFailedMember: () => isFailedMember,
|
|
147
148
|
isLegacyDescriptor: () => isLegacyDescriptor,
|
|
148
149
|
isNonEmptyRunScope: () => isNonEmptyRunScope,
|
|
150
|
+
isRemoteEvent: () => isRemoteEvent,
|
|
149
151
|
isWorkflowControlFlowSignal: () => isWorkflowControlFlowSignal,
|
|
150
152
|
legacySingletonHolders: () => legacySingletonHolders,
|
|
151
153
|
listSignalWaitersOfRuns: () => listSignalWaitersOfRuns,
|
|
152
154
|
liveHandoff: () => liveHandoff,
|
|
153
155
|
log: () => log,
|
|
156
|
+
markRemoteEvent: () => markRemoteEvent,
|
|
154
157
|
matchesAttributes: () => matchesAttributes,
|
|
155
158
|
mergeRunFacetRows: () => mergeRunFacetRows,
|
|
156
159
|
mergeRunValueFacetRows: () => mergeRunValueFacetRows,
|
|
@@ -2775,6 +2778,20 @@ function codeAndDetails(err) {
|
|
|
2775
2778
|
}
|
|
2776
2779
|
__name(codeAndDetails, "codeAndDetails");
|
|
2777
2780
|
|
|
2781
|
+
// src/remote-event.ts
|
|
2782
|
+
var REMOTE_EVENT = Symbol.for("@dudousxd/nestjs-durable:remote-event");
|
|
2783
|
+
function markRemoteEvent(event) {
|
|
2784
|
+
Object.defineProperty(event, REMOTE_EVENT, {
|
|
2785
|
+
value: true
|
|
2786
|
+
});
|
|
2787
|
+
return event;
|
|
2788
|
+
}
|
|
2789
|
+
__name(markRemoteEvent, "markRemoteEvent");
|
|
2790
|
+
function isRemoteEvent(event) {
|
|
2791
|
+
return event[REMOTE_EVENT] === true;
|
|
2792
|
+
}
|
|
2793
|
+
__name(isRemoteEvent, "isRemoteEvent");
|
|
2794
|
+
|
|
2778
2795
|
// src/tenant-group.ts
|
|
2779
2796
|
function tenantGroup(baseGroup, tenant) {
|
|
2780
2797
|
return tenant !== void 0 && tenant !== "" && tenant !== "default" ? `${baseGroup}@${tenant}` : baseGroup;
|
|
@@ -5479,10 +5496,10 @@ var WorkflowEngine = class {
|
|
|
5479
5496
|
this.controlPlane?.onControl((msg) => {
|
|
5480
5497
|
if (msg.from === this.instanceId) return;
|
|
5481
5498
|
if (msg.kind === "event") {
|
|
5482
|
-
this.deliver({
|
|
5499
|
+
this.deliver(markRemoteEvent({
|
|
5483
5500
|
...msg.event,
|
|
5484
5501
|
at: new Date(msg.event.at)
|
|
5485
|
-
});
|
|
5502
|
+
}));
|
|
5486
5503
|
} else if (msg.kind === "cancel") {
|
|
5487
5504
|
this.notifyCancelled(msg.runId);
|
|
5488
5505
|
} else if (msg.kind === "enqueued") {
|
|
@@ -7487,7 +7504,7 @@ var WorkflowEngine = class {
|
|
|
7487
7504
|
async redriveSettledStepFans(runId, fans) {
|
|
7488
7505
|
for (const fan of fans) {
|
|
7489
7506
|
if (this.stepFansFiredHere.has(`${runId}:${fan.from}`)) continue;
|
|
7490
|
-
if (await this.
|
|
7507
|
+
if (await this.stepFanHasPending(runId, fan.from, fan.to)) continue;
|
|
7491
7508
|
const nowMs = this.clock();
|
|
7492
7509
|
if (!await this.store.tryLockRun(runId, this.instanceId, nowMs + this.leaseMs, nowMs)) {
|
|
7493
7510
|
return;
|
|
@@ -10835,21 +10852,26 @@ ${run.workflowVersion}`;
|
|
|
10835
10852
|
let closed = barriers.get(fan.firstSeq);
|
|
10836
10853
|
if (!closed) {
|
|
10837
10854
|
const lastSeq = fan.firstSeq + fan.size - 1;
|
|
10838
|
-
closed = queuedIn(fan.firstSeq, lastSeq) ? Promise.resolve(true) : this.
|
|
10855
|
+
closed = queuedIn(fan.firstSeq, lastSeq) ? Promise.resolve(true) : this.stepFanHasPending(result.runId, fan.firstSeq, lastSeq).catch(() => false);
|
|
10839
10856
|
barriers.set(fan.firstSeq, closed);
|
|
10840
10857
|
}
|
|
10841
10858
|
if (await closed) return true;
|
|
10842
10859
|
this.noteRecent(this.stepFansFiredHere, `${result.runId}:${fan.firstSeq}`);
|
|
10843
10860
|
return false;
|
|
10844
10861
|
}
|
|
10845
|
-
/**
|
|
10846
|
-
async
|
|
10847
|
-
if (this.store.
|
|
10848
|
-
return this.store.
|
|
10862
|
+
/** Whether any step of a step fan's seq range is still `pending`. */
|
|
10863
|
+
async stepFanHasPending(runId, from, to) {
|
|
10864
|
+
if (this.store.hasCheckpoints) {
|
|
10865
|
+
return this.store.hasCheckpoints(runId, from, to, [
|
|
10849
10866
|
"pending"
|
|
10850
10867
|
]);
|
|
10851
10868
|
}
|
|
10852
|
-
|
|
10869
|
+
if (this.store.countCheckpoints) {
|
|
10870
|
+
return await this.store.countCheckpoints(runId, from, to, [
|
|
10871
|
+
"pending"
|
|
10872
|
+
]) > 0;
|
|
10873
|
+
}
|
|
10874
|
+
return (await this.store.listCheckpoints(runId)).some((c) => c.seq >= from && c.seq <= to && c.status === "pending");
|
|
10853
10875
|
}
|
|
10854
10876
|
/**
|
|
10855
10877
|
* Apply a remote workflow-turn {@link WorkflowDecision} durably — runs on WHATEVER instance receives
|
|
@@ -11681,6 +11703,8 @@ var CodecStateStore = class {
|
|
|
11681
11703
|
getCheckpointsForSettle;
|
|
11682
11704
|
/** Decodes each checkpoint read. Bound only when the inner store has it. */
|
|
11683
11705
|
getCheckpoints;
|
|
11706
|
+
/** Forwarded verbatim — reads no payload. Bound only when the inner store has it. */
|
|
11707
|
+
hasCheckpoints;
|
|
11684
11708
|
/** Forwarded verbatim — a count reads no payload. Bound only when the inner store has it. */
|
|
11685
11709
|
countCheckpoints;
|
|
11686
11710
|
/** Forwarded verbatim — retention selects by status/updatedAt/scope, never by payload. Bound only
|
|
@@ -11741,6 +11765,8 @@ var CodecStateStore = class {
|
|
|
11741
11765
|
if (getForSettle) this.getCheckpointsForSettle = async (runId, seqs) => (await getForSettle.call(inner, runId, seqs)).map((cp) => this.decCp(cp));
|
|
11742
11766
|
const getMany = inner.getCheckpoints;
|
|
11743
11767
|
if (getMany) this.getCheckpoints = async (runId, seqs) => (await getMany.call(inner, runId, seqs)).map((cp) => this.decCp(cp));
|
|
11768
|
+
const hasCps = inner.hasCheckpoints;
|
|
11769
|
+
if (hasCps) this.hasCheckpoints = (runId, from, to, statuses) => hasCps.call(inner, runId, from, to, statuses);
|
|
11744
11770
|
const countCps = inner.countCheckpoints;
|
|
11745
11771
|
if (countCps) this.countCheckpoints = (runId, from, to, statuses) => countCps.call(inner, runId, from, to, statuses);
|
|
11746
11772
|
const stats = inner.checkpointStats;
|
|
@@ -12034,6 +12060,7 @@ function collectMetrics(engine) {
|
|
|
12034
12060
|
return entry;
|
|
12035
12061
|
}, "wf");
|
|
12036
12062
|
const stop = engine.subscribe((e) => {
|
|
12063
|
+
if (isRemoteEvent(e)) return;
|
|
12037
12064
|
switch (e.type) {
|
|
12038
12065
|
case "run.started":
|
|
12039
12066
|
m.runs.started += 1;
|
|
@@ -12808,6 +12835,9 @@ var InMemoryStateStore = class {
|
|
|
12808
12835
|
...latest
|
|
12809
12836
|
} : void 0;
|
|
12810
12837
|
}
|
|
12838
|
+
async hasCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
12839
|
+
return await this.countCheckpoints(runId, fromSeq, toSeq, statuses) > 0;
|
|
12840
|
+
}
|
|
12811
12841
|
async countCheckpoints(runId, fromSeq, toSeq, statuses) {
|
|
12812
12842
|
let n = 0;
|
|
12813
12843
|
for (const cp of this.checkpoints.values()) {
|
|
@@ -13001,6 +13031,7 @@ var InMemoryRunQueue = class {
|
|
|
13001
13031
|
NestedWorkflowCallError,
|
|
13002
13032
|
NonDeterminismError,
|
|
13003
13033
|
QueueController,
|
|
13034
|
+
REMOTE_EVENT,
|
|
13004
13035
|
RUN_HISTORY_FIXTURE_VERSION,
|
|
13005
13036
|
RUN_VALUE_FACET_LIMIT,
|
|
13006
13037
|
RUN_VALUE_FACET_SCAN,
|
|
@@ -13091,11 +13122,13 @@ var InMemoryRunQueue = class {
|
|
|
13091
13122
|
isFailedMember,
|
|
13092
13123
|
isLegacyDescriptor,
|
|
13093
13124
|
isNonEmptyRunScope,
|
|
13125
|
+
isRemoteEvent,
|
|
13094
13126
|
isWorkflowControlFlowSignal,
|
|
13095
13127
|
legacySingletonHolders,
|
|
13096
13128
|
listSignalWaitersOfRuns,
|
|
13097
13129
|
liveHandoff,
|
|
13098
13130
|
log,
|
|
13131
|
+
markRemoteEvent,
|
|
13099
13132
|
matchesAttributes,
|
|
13100
13133
|
mergeRunFacetRows,
|
|
13101
13134
|
mergeRunValueFacetRows,
|