@dudousxd/nestjs-durable 0.54.0 → 0.55.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.
- package/dist/index.cjs +324 -196
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -3
- package/dist/index.d.ts +28 -3
- package/dist/index.js +230 -102
- package/dist/index.js.map +1 -1
- package/dist/migrate-from-nestjs-workflows.cjs +766 -0
- package/dist/migrate-from-nestjs-workflows.cjs.map +1 -0
- package/dist/migrate-from-nestjs-workflows.d.cts +125 -0
- package/dist/migrate-from-nestjs-workflows.d.ts +125 -0
- package/dist/migrate-from-nestjs-workflows.js +741 -0
- package/dist/migrate-from-nestjs-workflows.js.map +1 -0
- package/dist/outbox.cjs +243 -0
- package/dist/outbox.cjs.map +1 -0
- package/dist/outbox.d.cts +117 -0
- package/dist/outbox.d.ts +117 -0
- package/dist/outbox.js +213 -0
- package/dist/outbox.js.map +1 -0
- package/package.json +53 -11
- package/skills/durable-workflows/SKILL.md +8 -2
package/dist/index.js
CHANGED
|
@@ -915,9 +915,9 @@ function unavailableRunGateway() {
|
|
|
915
915
|
__name(unavailableRunGateway, "unavailableRunGateway");
|
|
916
916
|
|
|
917
917
|
// src/durable.module.ts
|
|
918
|
-
import { DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL as
|
|
919
|
-
import { Inject as
|
|
920
|
-
import { DiscoveryModule, ModuleRef } from "@nestjs/core";
|
|
918
|
+
import { DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL8, RunGateway as RunGateway2, STATE_STORE, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL4, TRANSPORT, TRANSPORT_CANONICAL as TRANSPORT_CANONICAL3, WorkflowEngine as WorkflowEngine6 } from "@dudousxd/nestjs-durable-core";
|
|
919
|
+
import { Inject as Inject9, Injectable as Injectable13, Module } from "@nestjs/common";
|
|
920
|
+
import { DiscoveryModule, ModuleRef as ModuleRef2 } from "@nestjs/core";
|
|
921
921
|
|
|
922
922
|
// src/durable-step.registrar.ts
|
|
923
923
|
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL2, TRANSPORT_CANONICAL } from "@dudousxd/nestjs-durable-core";
|
|
@@ -1997,8 +1997,8 @@ ProxyRunGateway = _ts_decorate6([
|
|
|
1997
1997
|
], ProxyRunGateway);
|
|
1998
1998
|
|
|
1999
1999
|
// src/retention-poller.ts
|
|
2000
|
-
import { DURABLE_OPTIONS_CANONICAL as
|
|
2001
|
-
import { Inject as
|
|
2000
|
+
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL5, STATE_STORE_CANONICAL, TERMINAL_RUN_STATUSES, parseDuration as parseDuration2 } from "@dudousxd/nestjs-durable-core";
|
|
2001
|
+
import { Inject as Inject5, Injectable as Injectable8, Optional as Optional2 } from "@nestjs/common";
|
|
2002
2002
|
|
|
2003
2003
|
// src/settle-within.ts
|
|
2004
2004
|
async function settleWithin(p, timeoutMs) {
|
|
@@ -2023,7 +2023,10 @@ async function settleWithin(p, timeoutMs) {
|
|
|
2023
2023
|
}
|
|
2024
2024
|
__name(settleWithin, "settleWithin");
|
|
2025
2025
|
|
|
2026
|
-
// src/
|
|
2026
|
+
// src/sweep-leases.ts
|
|
2027
|
+
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL4 } from "@dudousxd/nestjs-durable-core";
|
|
2028
|
+
import { Inject as Inject4, Injectable as Injectable7, Logger, Optional } from "@nestjs/common";
|
|
2029
|
+
import { ModuleRef } from "@nestjs/core";
|
|
2027
2030
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
2028
2031
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2029
2032
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2050,6 +2053,110 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
2050
2053
|
};
|
|
2051
2054
|
}
|
|
2052
2055
|
__name(_ts_param4, "_ts_param");
|
|
2056
|
+
var SweepLeases = class {
|
|
2057
|
+
static {
|
|
2058
|
+
__name(this, "SweepLeases");
|
|
2059
|
+
}
|
|
2060
|
+
moduleRef;
|
|
2061
|
+
options;
|
|
2062
|
+
logger = new Logger("nestjs-durable");
|
|
2063
|
+
/** Set by {@link onModuleInit} (before any poller's bootstrap). `null`: no `@nestjs/locks`. */
|
|
2064
|
+
locks = null;
|
|
2065
|
+
leases = /* @__PURE__ */ new Map();
|
|
2066
|
+
constructor(moduleRef, options) {
|
|
2067
|
+
this.moduleRef = moduleRef;
|
|
2068
|
+
this.options = options;
|
|
2069
|
+
}
|
|
2070
|
+
/**
|
|
2071
|
+
* Run `fn` if this pod holds (or now takes) the lease of `sweep`; otherwise skip it and resolve
|
|
2072
|
+
* `undefined`. Without `@nestjs/locks` it always runs `fn`.
|
|
2073
|
+
*/
|
|
2074
|
+
async run(sweep, fn) {
|
|
2075
|
+
const locks = this.locks;
|
|
2076
|
+
if (!locks) return fn();
|
|
2077
|
+
if (!await this.holds(locks, sweep)) return void 0;
|
|
2078
|
+
return fn();
|
|
2079
|
+
}
|
|
2080
|
+
async holds(locks, sweep) {
|
|
2081
|
+
if (this.leases.get(sweep)?.held) return true;
|
|
2082
|
+
this.leases.delete(sweep);
|
|
2083
|
+
let lock;
|
|
2084
|
+
try {
|
|
2085
|
+
lock = await locks.acquire(this.key(sweep));
|
|
2086
|
+
} catch (error) {
|
|
2087
|
+
this.logger.warn(`could not take the ${sweep} sweep lease; skipping this tick: ${String(error)}`);
|
|
2088
|
+
return false;
|
|
2089
|
+
}
|
|
2090
|
+
if (!lock) return false;
|
|
2091
|
+
this.leases.set(sweep, lock);
|
|
2092
|
+
return true;
|
|
2093
|
+
}
|
|
2094
|
+
key(sweep) {
|
|
2095
|
+
const ns = this.options?.namespace;
|
|
2096
|
+
return ns ? `durable:${sweep}:${ns}` : `durable:${sweep}`;
|
|
2097
|
+
}
|
|
2098
|
+
/** Detects `Locks` once, and logs which mode is active. Nest awaits it before any bootstrap hook. */
|
|
2099
|
+
async onModuleInit() {
|
|
2100
|
+
this.locks = await this.detect();
|
|
2101
|
+
this.logger.log(this.locks ? "fleet-wide sweeps (retention, stalled-run pager, buffered-signal cleanup, expired signal-id cleanup) run on one pod at a time, through @nestjs/locks" : "fleet-wide sweeps run on every driving pod (import LocksModule from @nestjs/locks to run them on one)");
|
|
2102
|
+
}
|
|
2103
|
+
async detect() {
|
|
2104
|
+
let locks = null;
|
|
2105
|
+
if (this.moduleRef) {
|
|
2106
|
+
try {
|
|
2107
|
+
const specifier = "@nestjs/locks";
|
|
2108
|
+
const mod = await import(specifier);
|
|
2109
|
+
if (mod.Locks) {
|
|
2110
|
+
locks = this.moduleRef.get(mod.Locks, {
|
|
2111
|
+
strict: false
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
} catch {
|
|
2115
|
+
locks = null;
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
return locks;
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
SweepLeases = _ts_decorate7([
|
|
2122
|
+
Injectable7(),
|
|
2123
|
+
_ts_param4(0, Optional()),
|
|
2124
|
+
_ts_param4(1, Optional()),
|
|
2125
|
+
_ts_param4(1, Inject4(DURABLE_OPTIONS_CANONICAL4)),
|
|
2126
|
+
_ts_metadata7("design:type", Function),
|
|
2127
|
+
_ts_metadata7("design:paramtypes", [
|
|
2128
|
+
typeof ModuleRef === "undefined" ? Object : ModuleRef,
|
|
2129
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
2130
|
+
])
|
|
2131
|
+
], SweepLeases);
|
|
2132
|
+
|
|
2133
|
+
// src/retention-poller.ts
|
|
2134
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2135
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2136
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2137
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2138
|
+
} else {
|
|
2139
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2140
|
+
if (d = decorators[i]) {
|
|
2141
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2142
|
+
}
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2146
|
+
}
|
|
2147
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2148
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
2149
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2150
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2151
|
+
}
|
|
2152
|
+
}
|
|
2153
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2154
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2155
|
+
return function(target, key) {
|
|
2156
|
+
decorator(target, key, paramIndex);
|
|
2157
|
+
};
|
|
2158
|
+
}
|
|
2159
|
+
__name(_ts_param5, "_ts_param");
|
|
2053
2160
|
var DEFAULT_SWEEP_INTERVAL_MS = 6e4;
|
|
2054
2161
|
var DEFAULT_BATCH_SIZE = 1e3;
|
|
2055
2162
|
var MAX_BATCHES_PER_POLICY = 100;
|
|
@@ -2092,14 +2199,16 @@ var RetentionPoller = class {
|
|
|
2092
2199
|
}
|
|
2093
2200
|
store;
|
|
2094
2201
|
options;
|
|
2202
|
+
leases;
|
|
2095
2203
|
timer;
|
|
2096
2204
|
sweeping = false;
|
|
2097
2205
|
stopping = false;
|
|
2098
2206
|
/** The sweep in flight, so shutdown can wait for it before the store closes. */
|
|
2099
2207
|
current;
|
|
2100
|
-
constructor(store, options) {
|
|
2208
|
+
constructor(store, options, leases = new SweepLeases()) {
|
|
2101
2209
|
this.store = store;
|
|
2102
2210
|
this.options = options;
|
|
2211
|
+
this.leases = leases;
|
|
2103
2212
|
}
|
|
2104
2213
|
/** Non-null once past the `isDrivingOperator` guard (which requires `options.store` to be set). */
|
|
2105
2214
|
requireStore() {
|
|
@@ -2161,37 +2270,42 @@ var RetentionPoller = class {
|
|
|
2161
2270
|
if (!retention || typeof prune !== "function") return;
|
|
2162
2271
|
this.sweeping = true;
|
|
2163
2272
|
try {
|
|
2164
|
-
|
|
2165
|
-
const now = Date.now();
|
|
2166
|
-
for (const policy of retention.policies) {
|
|
2167
|
-
for (let batch = 0; batch < MAX_BATCHES_PER_POLICY; batch++) {
|
|
2168
|
-
if (this.stopping) return;
|
|
2169
|
-
const deleted = await prune.call(store, policy, now, batchSize);
|
|
2170
|
-
if (deleted < batchSize) break;
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2273
|
+
await this.leases.run("retention", () => this.prune(retention, store, prune));
|
|
2173
2274
|
} catch (error) {
|
|
2174
2275
|
console.error("[nestjs-durable] retention sweep failed; retrying next interval:", error);
|
|
2175
2276
|
} finally {
|
|
2176
2277
|
this.sweeping = false;
|
|
2177
2278
|
}
|
|
2178
2279
|
}
|
|
2280
|
+
async prune(retention, store, prune) {
|
|
2281
|
+
const batchSize = retention.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
2282
|
+
const now = Date.now();
|
|
2283
|
+
for (const policy of retention.policies) {
|
|
2284
|
+
for (let batch = 0; batch < MAX_BATCHES_PER_POLICY; batch++) {
|
|
2285
|
+
if (this.stopping) return;
|
|
2286
|
+
const deleted = await prune.call(store, policy, now, batchSize);
|
|
2287
|
+
if (deleted < batchSize) break;
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2179
2291
|
};
|
|
2180
|
-
RetentionPoller =
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2292
|
+
RetentionPoller = _ts_decorate8([
|
|
2293
|
+
Injectable8(),
|
|
2294
|
+
_ts_param5(0, Inject5(STATE_STORE_CANONICAL)),
|
|
2295
|
+
_ts_param5(1, Inject5(DURABLE_OPTIONS_CANONICAL5)),
|
|
2296
|
+
_ts_param5(2, Optional2()),
|
|
2297
|
+
_ts_metadata8("design:type", Function),
|
|
2298
|
+
_ts_metadata8("design:paramtypes", [
|
|
2186
2299
|
Object,
|
|
2187
|
-
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
2300
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
2301
|
+
typeof SweepLeases === "undefined" ? Object : SweepLeases
|
|
2188
2302
|
])
|
|
2189
2303
|
], RetentionPoller);
|
|
2190
2304
|
|
|
2191
2305
|
// src/store-run-gateway.ts
|
|
2192
2306
|
import { LIFECYCLE_REGISTRY_WORKFLOW, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL2, SUMMARY_CHILD_LIMIT as SUMMARY_CHILD_LIMIT2, WorkflowEngine as WorkflowEngine2, aggregatesCheckpoints, childIdsOf as childIdsOf2, etagMatches, extendEtag, fanPageEtag, indexWaitersByRun, lifecycleDeliveriesOf, lifecycleKindOf as lifecycleKindOf2, lifecycleSourceOf, lifecycleTraceparentOf, listSignalWaitersOfRuns, mergeRunFacetRows, pageFan as pageFan2, pageFanFromStore, readRunsByIds, resolveRunWaiting, runDetailEtag, runWaitPrefix, runWaitTargetOf, summarizeRunFromStore, summarizeTimeline as summarizeTimeline2, traceIdOfTraceparent } from "@dudousxd/nestjs-durable-core";
|
|
2193
|
-
import { Inject as
|
|
2194
|
-
function
|
|
2307
|
+
import { Inject as Inject6, Injectable as Injectable9 } from "@nestjs/common";
|
|
2308
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2195
2309
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2196
2310
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2197
2311
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2204,19 +2318,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2204
2318
|
}
|
|
2205
2319
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2206
2320
|
}
|
|
2207
|
-
__name(
|
|
2208
|
-
function
|
|
2321
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2322
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
2209
2323
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2210
2324
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2211
2325
|
}
|
|
2212
2326
|
}
|
|
2213
|
-
__name(
|
|
2214
|
-
function
|
|
2327
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2328
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2215
2329
|
return function(target, key) {
|
|
2216
2330
|
decorator(target, key, paramIndex);
|
|
2217
2331
|
};
|
|
2218
2332
|
}
|
|
2219
|
-
__name(
|
|
2333
|
+
__name(_ts_param6, "_ts_param");
|
|
2220
2334
|
function detailExtras(links) {
|
|
2221
2335
|
const { lifecycleSubscribers, lifecycleDeliveries, waitsFor, awaitedBy, triggeredBy } = links;
|
|
2222
2336
|
if (!lifecycleSubscribers && !lifecycleDeliveries && !waitsFor && !awaitedBy && !triggeredBy) {
|
|
@@ -2527,11 +2641,11 @@ var StoreRunGateway = class {
|
|
|
2527
2641
|
});
|
|
2528
2642
|
}
|
|
2529
2643
|
};
|
|
2530
|
-
StoreRunGateway =
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2644
|
+
StoreRunGateway = _ts_decorate9([
|
|
2645
|
+
Injectable9(),
|
|
2646
|
+
_ts_param6(0, Inject6(STATE_STORE_CANONICAL2)),
|
|
2647
|
+
_ts_metadata9("design:type", Function),
|
|
2648
|
+
_ts_metadata9("design:paramtypes", [
|
|
2535
2649
|
typeof StateStore === "undefined" ? Object : StateStore,
|
|
2536
2650
|
typeof WorkflowEngine2 === "undefined" ? Object : WorkflowEngine2
|
|
2537
2651
|
])
|
|
@@ -2579,9 +2693,9 @@ var TenantEventRepublisher = class {
|
|
|
2579
2693
|
};
|
|
2580
2694
|
|
|
2581
2695
|
// src/timer-poller.ts
|
|
2582
|
-
import { DURABLE_OPTIONS_CANONICAL as
|
|
2583
|
-
import { Inject as
|
|
2584
|
-
function
|
|
2696
|
+
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL6, WorkflowEngine as WorkflowEngine3, runSchedules, workflowName as workflowName3 } from "@dudousxd/nestjs-durable-core";
|
|
2697
|
+
import { Inject as Inject7, Injectable as Injectable10, Optional as Optional3 } from "@nestjs/common";
|
|
2698
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
2585
2699
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2586
2700
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2587
2701
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2594,33 +2708,35 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
2594
2708
|
}
|
|
2595
2709
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2596
2710
|
}
|
|
2597
|
-
__name(
|
|
2598
|
-
function
|
|
2711
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
2712
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
2599
2713
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2600
2714
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2601
2715
|
}
|
|
2602
2716
|
}
|
|
2603
|
-
__name(
|
|
2604
|
-
function
|
|
2717
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2718
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2605
2719
|
return function(target, key) {
|
|
2606
2720
|
decorator(target, key, paramIndex);
|
|
2607
2721
|
};
|
|
2608
2722
|
}
|
|
2609
|
-
__name(
|
|
2723
|
+
__name(_ts_param7, "_ts_param");
|
|
2610
2724
|
var TimerPoller = class {
|
|
2611
2725
|
static {
|
|
2612
2726
|
__name(this, "TimerPoller");
|
|
2613
2727
|
}
|
|
2614
2728
|
engine;
|
|
2615
2729
|
options;
|
|
2730
|
+
leases;
|
|
2616
2731
|
timer;
|
|
2617
2732
|
polling = false;
|
|
2618
2733
|
/** The sweep in flight, so shutdown can wait for it instead of racing the store's close. */
|
|
2619
2734
|
current;
|
|
2620
2735
|
unsubscribeEnqueued;
|
|
2621
|
-
constructor(engine, options) {
|
|
2736
|
+
constructor(engine, options, leases = new SweepLeases()) {
|
|
2622
2737
|
this.engine = engine;
|
|
2623
2738
|
this.options = options;
|
|
2739
|
+
this.leases = leases;
|
|
2624
2740
|
}
|
|
2625
2741
|
async onApplicationBootstrap() {
|
|
2626
2742
|
for (const s of this.options.schedules ?? []) workflowName3(s.workflow);
|
|
@@ -2693,8 +2809,9 @@ var TimerPoller = class {
|
|
|
2693
2809
|
await this.sweep("recoverIncomplete", () => this.engine.recoverIncomplete());
|
|
2694
2810
|
await this.sweep("resumeDueTimers", () => this.engine.resumeDueTimers());
|
|
2695
2811
|
await this.sweep("sweepTimeouts", () => this.engine.sweepTimeouts());
|
|
2696
|
-
await this.sweep("sweepStalled", async () => this.engine.sweepStalled?.());
|
|
2697
|
-
await this.sweep("sweepBufferedSignals", async () => this.engine.sweepBufferedSignals?.());
|
|
2812
|
+
await this.sweep("sweepStalled", () => this.leases.run("stalled-pager", async () => this.engine.sweepStalled?.()));
|
|
2813
|
+
await this.sweep("sweepBufferedSignals", () => this.leases.run("buffered-signals", async () => this.engine.sweepBufferedSignals?.()));
|
|
2814
|
+
await this.sweep("sweepExpiredSignalIds", () => this.leases.run("signal-ids", async () => this.engine.sweepExpiredSignalIds?.()));
|
|
2698
2815
|
await this.sweep("sweepLifecycleEvents", async () => this.engine.sweepLifecycleEvents?.());
|
|
2699
2816
|
const schedules = this.options.schedules;
|
|
2700
2817
|
if (schedules && schedules.length > 0) {
|
|
@@ -2714,13 +2831,15 @@ var TimerPoller = class {
|
|
|
2714
2831
|
}
|
|
2715
2832
|
}
|
|
2716
2833
|
};
|
|
2717
|
-
TimerPoller =
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2834
|
+
TimerPoller = _ts_decorate10([
|
|
2835
|
+
Injectable10(),
|
|
2836
|
+
_ts_param7(1, Inject7(DURABLE_OPTIONS_CANONICAL6)),
|
|
2837
|
+
_ts_param7(2, Optional3()),
|
|
2838
|
+
_ts_metadata10("design:type", Function),
|
|
2839
|
+
_ts_metadata10("design:paramtypes", [
|
|
2722
2840
|
typeof WorkflowEngine3 === "undefined" ? Object : WorkflowEngine3,
|
|
2723
|
-
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
2841
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
2842
|
+
typeof SweepLeases === "undefined" ? Object : SweepLeases
|
|
2724
2843
|
])
|
|
2725
2844
|
], TimerPoller);
|
|
2726
2845
|
|
|
@@ -2730,8 +2849,8 @@ var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
|
2730
2849
|
var RUN_GATEWAY = RunGateway;
|
|
2731
2850
|
|
|
2732
2851
|
// src/workflow.registrar.ts
|
|
2733
|
-
import { DURABLE_OPTIONS_CANONICAL as
|
|
2734
|
-
import { Inject as
|
|
2852
|
+
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL7, RemoteWorkflowExecutor, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL3, WorkflowEngine as WorkflowEngine4, bindWorkflowClass, sanitizeQueueToken, tenantGroup, workflowName as workflowName4 } from "@dudousxd/nestjs-durable-core";
|
|
2853
|
+
import { Inject as Inject8, Injectable as Injectable11 } from "@nestjs/common";
|
|
2735
2854
|
import { DiscoveryService as DiscoveryService4, MetadataScanner as MetadataScanner4 } from "@nestjs/core";
|
|
2736
2855
|
|
|
2737
2856
|
// src/step-interceptor.ts
|
|
@@ -2749,7 +2868,7 @@ function isStepInterceptor(target) {
|
|
|
2749
2868
|
__name(isStepInterceptor, "isStepInterceptor");
|
|
2750
2869
|
|
|
2751
2870
|
// src/workflow.registrar.ts
|
|
2752
|
-
function
|
|
2871
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
2753
2872
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2754
2873
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2755
2874
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2762,19 +2881,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
2762
2881
|
}
|
|
2763
2882
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2764
2883
|
}
|
|
2765
|
-
__name(
|
|
2766
|
-
function
|
|
2884
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2885
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
2767
2886
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2768
2887
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2769
2888
|
}
|
|
2770
2889
|
}
|
|
2771
|
-
__name(
|
|
2772
|
-
function
|
|
2890
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
2891
|
+
function _ts_param8(paramIndex, decorator) {
|
|
2773
2892
|
return function(target, key) {
|
|
2774
2893
|
decorator(target, key, paramIndex);
|
|
2775
2894
|
};
|
|
2776
2895
|
}
|
|
2777
|
-
__name(
|
|
2896
|
+
__name(_ts_param8, "_ts_param");
|
|
2778
2897
|
var UNSERVED_ROUTES_RECHECK_MS = 3e4;
|
|
2779
2898
|
var WorkflowRegistrar = class {
|
|
2780
2899
|
static {
|
|
@@ -2961,13 +3080,13 @@ var WorkflowRegistrar = class {
|
|
|
2961
3080
|
});
|
|
2962
3081
|
}
|
|
2963
3082
|
};
|
|
2964
|
-
WorkflowRegistrar =
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
3083
|
+
WorkflowRegistrar = _ts_decorate11([
|
|
3084
|
+
Injectable11(),
|
|
3085
|
+
_ts_param8(3, Inject8(STATE_STORE_CANONICAL3)),
|
|
3086
|
+
_ts_param8(4, Inject8(DURABLE_OPTIONS_CANONICAL7)),
|
|
3087
|
+
_ts_param8(5, Inject8(IN_APP_WORKER_BINDING)),
|
|
3088
|
+
_ts_metadata11("design:type", Function),
|
|
3089
|
+
_ts_metadata11("design:paramtypes", [
|
|
2971
3090
|
typeof DiscoveryService4 === "undefined" ? Object : DiscoveryService4,
|
|
2972
3091
|
typeof MetadataScanner4 === "undefined" ? Object : MetadataScanner4,
|
|
2973
3092
|
typeof WorkflowEngine4 === "undefined" ? Object : WorkflowEngine4,
|
|
@@ -2980,8 +3099,8 @@ WorkflowRegistrar = _ts_decorate10([
|
|
|
2980
3099
|
// src/workflow.service.ts
|
|
2981
3100
|
import { randomUUID } from "node:crypto";
|
|
2982
3101
|
import { WorkflowEngine as WorkflowEngine5 } from "@dudousxd/nestjs-durable-core";
|
|
2983
|
-
import { Injectable as
|
|
2984
|
-
function
|
|
3102
|
+
import { Injectable as Injectable12 } from "@nestjs/common";
|
|
3103
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
2985
3104
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2986
3105
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2987
3106
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2994,13 +3113,13 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
2994
3113
|
}
|
|
2995
3114
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2996
3115
|
}
|
|
2997
|
-
__name(
|
|
2998
|
-
function
|
|
3116
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
3117
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
2999
3118
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3000
3119
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3001
3120
|
}
|
|
3002
3121
|
}
|
|
3003
|
-
__name(
|
|
3122
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3004
3123
|
var WorkflowService = class {
|
|
3005
3124
|
static {
|
|
3006
3125
|
__name(this, "WorkflowService");
|
|
@@ -3025,9 +3144,13 @@ var WorkflowService = class {
|
|
|
3025
3144
|
waitForRun(runId, opts) {
|
|
3026
3145
|
return this.engine.waitForRun(runId, opts);
|
|
3027
3146
|
}
|
|
3028
|
-
/**
|
|
3029
|
-
signal(
|
|
3030
|
-
|
|
3147
|
+
/**
|
|
3148
|
+
* Deliver an external signal (e.g. from a webhook) to the run waiting on `token`, or buffer it for
|
|
3149
|
+
* the next wait on it. With `{ id }`, a re-send with the same token and id is dropped (resolves
|
|
3150
|
+
* `null`): see {@link SignalOptions}.
|
|
3151
|
+
*/
|
|
3152
|
+
signal(token, payload, opts) {
|
|
3153
|
+
return this.engine.signal(token, payload, opts);
|
|
3031
3154
|
}
|
|
3032
3155
|
signalWithStart(workflow, input, runId, signal, opts) {
|
|
3033
3156
|
return this.engine.signalWithStart(workflow, input, runId, signal, opts);
|
|
@@ -3062,16 +3185,16 @@ var WorkflowService = class {
|
|
|
3062
3185
|
return this.engine.republishLifecycle(target);
|
|
3063
3186
|
}
|
|
3064
3187
|
};
|
|
3065
|
-
WorkflowService =
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3188
|
+
WorkflowService = _ts_decorate12([
|
|
3189
|
+
Injectable12(),
|
|
3190
|
+
_ts_metadata12("design:type", Function),
|
|
3191
|
+
_ts_metadata12("design:paramtypes", [
|
|
3069
3192
|
typeof WorkflowEngine5 === "undefined" ? Object : WorkflowEngine5
|
|
3070
3193
|
])
|
|
3071
3194
|
], WorkflowService);
|
|
3072
3195
|
|
|
3073
3196
|
// src/durable.module.ts
|
|
3074
|
-
function
|
|
3197
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
3075
3198
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3076
3199
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3077
3200
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3084,19 +3207,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
3084
3207
|
}
|
|
3085
3208
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3086
3209
|
}
|
|
3087
|
-
__name(
|
|
3088
|
-
function
|
|
3210
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
3211
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
3089
3212
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3090
3213
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3091
3214
|
}
|
|
3092
3215
|
}
|
|
3093
|
-
__name(
|
|
3094
|
-
function
|
|
3216
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3217
|
+
function _ts_param9(paramIndex, decorator) {
|
|
3095
3218
|
return function(target, key) {
|
|
3096
3219
|
decorator(target, key, paramIndex);
|
|
3097
3220
|
};
|
|
3098
3221
|
}
|
|
3099
|
-
__name(
|
|
3222
|
+
__name(_ts_param9, "_ts_param");
|
|
3100
3223
|
function resolveAccessor(moduleRef) {
|
|
3101
3224
|
try {
|
|
3102
3225
|
return moduleRef.get(CONTEXT_ACCESSOR, {
|
|
@@ -3284,13 +3407,13 @@ var RunGatewayBootstrap = class RunGatewayBootstrap2 {
|
|
|
3284
3407
|
this.unsubscribe?.();
|
|
3285
3408
|
}
|
|
3286
3409
|
};
|
|
3287
|
-
RunGatewayBootstrap =
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3410
|
+
RunGatewayBootstrap = _ts_decorate13([
|
|
3411
|
+
Injectable13(),
|
|
3412
|
+
_ts_param9(1, Inject9(TRANSPORT_CANONICAL3)),
|
|
3413
|
+
_ts_param9(3, Inject9(STATE_STORE_CANONICAL4)),
|
|
3414
|
+
_ts_param9(4, Inject9(DURABLE_OPTIONS_CANONICAL8)),
|
|
3415
|
+
_ts_metadata13("design:type", Function),
|
|
3416
|
+
_ts_metadata13("design:paramtypes", [
|
|
3294
3417
|
typeof WorkflowEngine6 === "undefined" ? Object : WorkflowEngine6,
|
|
3295
3418
|
Object,
|
|
3296
3419
|
typeof RunGateway2 === "undefined" ? Object : RunGateway2,
|
|
@@ -3305,13 +3428,13 @@ var DurableModule = class _DurableModule {
|
|
|
3305
3428
|
static forRoot(options) {
|
|
3306
3429
|
_DurableModule.assertValid(options);
|
|
3307
3430
|
return _DurableModule.build({
|
|
3308
|
-
provide:
|
|
3431
|
+
provide: DURABLE_OPTIONS_CANONICAL8,
|
|
3309
3432
|
useValue: resolveTopology(options)
|
|
3310
3433
|
});
|
|
3311
3434
|
}
|
|
3312
3435
|
static forRootAsync(options) {
|
|
3313
3436
|
return _DurableModule.build({
|
|
3314
|
-
provide:
|
|
3437
|
+
provide: DURABLE_OPTIONS_CANONICAL8,
|
|
3315
3438
|
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
3316
3439
|
const resolved = await options.useFactory(...args);
|
|
3317
3440
|
_DurableModule.assertValid(resolved);
|
|
@@ -3347,7 +3470,7 @@ var DurableModule = class _DurableModule {
|
|
|
3347
3470
|
provide: STATE_STORE_CANONICAL4,
|
|
3348
3471
|
useFactory: /* @__PURE__ */ __name((options) => options.store !== void 0 ? scopedStore(options.store, options) : null, "useFactory"),
|
|
3349
3472
|
inject: [
|
|
3350
|
-
|
|
3473
|
+
DURABLE_OPTIONS_CANONICAL8
|
|
3351
3474
|
]
|
|
3352
3475
|
},
|
|
3353
3476
|
{
|
|
@@ -3358,7 +3481,7 @@ var DurableModule = class _DurableModule {
|
|
|
3358
3481
|
// registered NO step handlers and its own steps parked in `wait` with no consumer.
|
|
3359
3482
|
useFactory: /* @__PURE__ */ __name((options) => options.transport ?? options.transports?.[0]?.transport ?? null, "useFactory"),
|
|
3360
3483
|
inject: [
|
|
3361
|
-
|
|
3484
|
+
DURABLE_OPTIONS_CANONICAL8
|
|
3362
3485
|
]
|
|
3363
3486
|
},
|
|
3364
3487
|
// Legacy back-compat aliases (deprecated tokens still resolve to the same instances):
|
|
@@ -3372,7 +3495,7 @@ var DurableModule = class _DurableModule {
|
|
|
3372
3495
|
},
|
|
3373
3496
|
{
|
|
3374
3497
|
provide: DURABLE_OPTIONS,
|
|
3375
|
-
useExisting:
|
|
3498
|
+
useExisting: DURABLE_OPTIONS_CANONICAL8
|
|
3376
3499
|
},
|
|
3377
3500
|
{
|
|
3378
3501
|
// Shared token, bound EXACTLY once: a real engine for the operator role, or a store-less
|
|
@@ -3415,8 +3538,12 @@ var DurableModule = class _DurableModule {
|
|
|
3415
3538
|
stalledAfterMs: options.stalledAfterMs,
|
|
3416
3539
|
timerBatchSize: options.timerBatchSize,
|
|
3417
3540
|
eventBufferTtlMs: options.eventBufferTtlMs,
|
|
3541
|
+
signalIdTtl: options.signalIdTtl,
|
|
3418
3542
|
blockedPollMs: options.blockedPollMs,
|
|
3419
3543
|
trackStepStart: options.trackStepStart,
|
|
3544
|
+
stickyRuns: options.stickyRuns,
|
|
3545
|
+
stickyIdleMs: options.stickyIdleMs,
|
|
3546
|
+
routeReplies: options.routeReplies,
|
|
3420
3547
|
instanceId: options.instanceId,
|
|
3421
3548
|
namespace: options.namespace,
|
|
3422
3549
|
webhookUrl: options.webhookUrl,
|
|
@@ -3441,16 +3568,17 @@ var DurableModule = class _DurableModule {
|
|
|
3441
3568
|
return engine;
|
|
3442
3569
|
}, "useFactory"),
|
|
3443
3570
|
inject: [
|
|
3444
|
-
|
|
3571
|
+
DURABLE_OPTIONS_CANONICAL8,
|
|
3445
3572
|
STATE_STORE_CANONICAL4,
|
|
3446
3573
|
TRANSPORT_CANONICAL3,
|
|
3447
|
-
|
|
3574
|
+
ModuleRef2
|
|
3448
3575
|
]
|
|
3449
3576
|
},
|
|
3450
3577
|
WorkflowService,
|
|
3451
3578
|
EntityService,
|
|
3452
3579
|
WorkflowRegistrar,
|
|
3453
3580
|
DurableStepRegistrar,
|
|
3581
|
+
SweepLeases,
|
|
3454
3582
|
TimerPoller,
|
|
3455
3583
|
RetentionPoller,
|
|
3456
3584
|
// Tenant run gateway: bound EXACTLY once — the store-backed `StoreRunGateway` for an operator,
|
|
@@ -3468,7 +3596,7 @@ var DurableModule = class _DurableModule {
|
|
|
3468
3596
|
return options.transport ? new ProxyRunGateway(options.transport, options.partition ?? "default", options.runGatewayTimeoutMs, void 0, options.tenantToken) : unavailableRunGateway();
|
|
3469
3597
|
}, "useFactory"),
|
|
3470
3598
|
inject: [
|
|
3471
|
-
|
|
3599
|
+
DURABLE_OPTIONS_CANONICAL8,
|
|
3472
3600
|
STATE_STORE_CANONICAL4,
|
|
3473
3601
|
WorkflowEngine6
|
|
3474
3602
|
]
|
|
@@ -3489,13 +3617,13 @@ var DurableModule = class _DurableModule {
|
|
|
3489
3617
|
STATE_STORE_CANONICAL4,
|
|
3490
3618
|
TRANSPORT,
|
|
3491
3619
|
TRANSPORT_CANONICAL3,
|
|
3492
|
-
|
|
3620
|
+
DURABLE_OPTIONS_CANONICAL8,
|
|
3493
3621
|
RunGateway2
|
|
3494
3622
|
]
|
|
3495
3623
|
};
|
|
3496
3624
|
}
|
|
3497
3625
|
};
|
|
3498
|
-
DurableModule =
|
|
3626
|
+
DurableModule = _ts_decorate13([
|
|
3499
3627
|
Module({})
|
|
3500
3628
|
], DurableModule);
|
|
3501
3629
|
|