@dudousxd/nestjs-durable 0.54.0 → 0.55.0
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.cjs
CHANGED
|
@@ -29,8 +29,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
30
|
|
|
31
31
|
// src/index.ts
|
|
32
|
-
var
|
|
33
|
-
__export(
|
|
32
|
+
var src_exports = {};
|
|
33
|
+
__export(src_exports, {
|
|
34
34
|
BAD_RUN_REQUEST: () => BAD_RUN_REQUEST,
|
|
35
35
|
CONTEXT_ACCESSOR: () => CONTEXT_ACCESSOR,
|
|
36
36
|
DEAD_LETTER_METADATA: () => DEAD_LETTER_METADATA,
|
|
@@ -50,7 +50,7 @@ __export(index_exports, {
|
|
|
50
50
|
IN_APP_WORKER_RUNNERS: () => IN_APP_WORKER_RUNNERS,
|
|
51
51
|
IN_APP_WORKER_RUNTIME: () => IN_APP_WORKER_RUNTIME,
|
|
52
52
|
InAppWorkerBootstrap: () => InAppWorkerBootstrap,
|
|
53
|
-
LIFECYCLE_PENDING_TAG: () =>
|
|
53
|
+
LIFECYCLE_PENDING_TAG: () => import_nestjs_durable_core20.LIFECYCLE_PENDING_TAG,
|
|
54
54
|
ON_ERROR_METADATA: () => ON_ERROR_METADATA,
|
|
55
55
|
ON_EVENT_BATCH_METADATA: () => ON_EVENT_BATCH_METADATA,
|
|
56
56
|
ON_EVENT_METADATA: () => ON_EVENT_METADATA,
|
|
@@ -63,7 +63,7 @@ __export(index_exports, {
|
|
|
63
63
|
ProxyRunGateway: () => ProxyRunGateway,
|
|
64
64
|
RUN_GATEWAY: () => RUN_GATEWAY,
|
|
65
65
|
RUN_REDIS_WORKER: () => RUN_REDIS_WORKER,
|
|
66
|
-
RunGateway: () =>
|
|
66
|
+
RunGateway: () => import_nestjs_durable_core20.RunGateway,
|
|
67
67
|
RunGatewayError: () => RunGatewayError,
|
|
68
68
|
RunRequestResponder: () => RunRequestResponder,
|
|
69
69
|
STEP_INTERCEPTOR_METADATA: () => STEP_INTERCEPTOR_METADATA,
|
|
@@ -78,7 +78,7 @@ __export(index_exports, {
|
|
|
78
78
|
UNSUPPORTED_RUN_REQUEST: () => UNSUPPORTED_RUN_REQUEST,
|
|
79
79
|
WORKFLOW_METADATA: () => WORKFLOW_METADATA,
|
|
80
80
|
Workflow: () => Workflow,
|
|
81
|
-
WorkflowEngine: () =>
|
|
81
|
+
WorkflowEngine: () => import_nestjs_durable_core20.WorkflowEngine,
|
|
82
82
|
WorkflowService: () => WorkflowService,
|
|
83
83
|
attributesOf: () => attributesOf,
|
|
84
84
|
entityConfigFor: () => entityConfigFor,
|
|
@@ -87,28 +87,28 @@ __export(index_exports, {
|
|
|
87
87
|
getEntityMeta: () => getEntityMeta,
|
|
88
88
|
getOnEvents: () => getOnEvents,
|
|
89
89
|
getWorkflowMeta: () => getWorkflowMeta,
|
|
90
|
-
hmacTenantVerifier: () =>
|
|
90
|
+
hmacTenantVerifier: () => import_nestjs_durable_core20.hmacTenantVerifier,
|
|
91
91
|
inAppWorkerProviders: () => inAppWorkerProviders,
|
|
92
92
|
isDeadLetterHandler: () => isDeadLetterHandler,
|
|
93
93
|
isDrivingOperator: () => isDrivingOperator,
|
|
94
94
|
isOperatorRole: () => isOperatorRole,
|
|
95
95
|
isStepInterceptor: () => isStepInterceptor,
|
|
96
|
-
lifecycleRunId: () =>
|
|
97
|
-
lifecycleSourceOf: () =>
|
|
96
|
+
lifecycleRunId: () => import_nestjs_durable_core20.lifecycleRunId,
|
|
97
|
+
lifecycleSourceOf: () => import_nestjs_durable_core20.lifecycleSourceOf,
|
|
98
98
|
onErrorCodesOf: () => onErrorCodesOf,
|
|
99
|
-
prevCronFireMs: () =>
|
|
100
|
-
readSearchAttributes: () =>
|
|
101
|
-
runCompletedEvent: () =>
|
|
102
|
-
runFailedEvent: () =>
|
|
103
|
-
runSchedules: () =>
|
|
104
|
-
scheduleRunIdAt: () =>
|
|
105
|
-
scheduledRunId: () =>
|
|
106
|
-
signTenantToken: () =>
|
|
99
|
+
prevCronFireMs: () => import_nestjs_durable_core20.prevCronFireMs,
|
|
100
|
+
readSearchAttributes: () => import_nestjs_durable_core20.readSearchAttributes,
|
|
101
|
+
runCompletedEvent: () => import_nestjs_durable_core20.runCompletedEvent,
|
|
102
|
+
runFailedEvent: () => import_nestjs_durable_core20.runFailedEvent,
|
|
103
|
+
runSchedules: () => import_nestjs_durable_core20.runSchedules,
|
|
104
|
+
scheduleRunIdAt: () => import_nestjs_durable_core20.scheduleRunIdAt,
|
|
105
|
+
scheduledRunId: () => import_nestjs_durable_core20.scheduledRunId,
|
|
106
|
+
signTenantToken: () => import_nestjs_durable_core20.signTenantToken,
|
|
107
107
|
thinWorkerProviders: () => thinWorkerProviders,
|
|
108
|
-
triggeredRunsOf: () =>
|
|
108
|
+
triggeredRunsOf: () => import_nestjs_durable_core20.triggeredRunsOf,
|
|
109
109
|
unavailableRunGateway: () => unavailableRunGateway
|
|
110
110
|
});
|
|
111
|
-
module.exports = __toCommonJS(
|
|
111
|
+
module.exports = __toCommonJS(src_exports);
|
|
112
112
|
|
|
113
113
|
// src/attributes-of.ts
|
|
114
114
|
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
@@ -1024,9 +1024,9 @@ function unavailableRunGateway() {
|
|
|
1024
1024
|
__name(unavailableRunGateway, "unavailableRunGateway");
|
|
1025
1025
|
|
|
1026
1026
|
// src/durable.module.ts
|
|
1027
|
-
var
|
|
1028
|
-
var
|
|
1029
|
-
var
|
|
1027
|
+
var import_nestjs_durable_core19 = require("@dudousxd/nestjs-durable-core");
|
|
1028
|
+
var import_common13 = require("@nestjs/common");
|
|
1029
|
+
var import_core6 = require("@nestjs/core");
|
|
1030
1030
|
|
|
1031
1031
|
// src/durable-step.registrar.ts
|
|
1032
1032
|
var import_nestjs_durable_core7 = require("@dudousxd/nestjs-durable-core");
|
|
@@ -2106,8 +2106,8 @@ ProxyRunGateway = _ts_decorate6([
|
|
|
2106
2106
|
], ProxyRunGateway);
|
|
2107
2107
|
|
|
2108
2108
|
// src/retention-poller.ts
|
|
2109
|
-
var
|
|
2110
|
-
var
|
|
2109
|
+
var import_nestjs_durable_core13 = require("@dudousxd/nestjs-durable-core");
|
|
2110
|
+
var import_common8 = require("@nestjs/common");
|
|
2111
2111
|
|
|
2112
2112
|
// src/settle-within.ts
|
|
2113
2113
|
async function settleWithin(p, timeoutMs) {
|
|
@@ -2132,7 +2132,10 @@ async function settleWithin(p, timeoutMs) {
|
|
|
2132
2132
|
}
|
|
2133
2133
|
__name(settleWithin, "settleWithin");
|
|
2134
2134
|
|
|
2135
|
-
// src/
|
|
2135
|
+
// src/sweep-leases.ts
|
|
2136
|
+
var import_nestjs_durable_core12 = require("@dudousxd/nestjs-durable-core");
|
|
2137
|
+
var import_common7 = require("@nestjs/common");
|
|
2138
|
+
var import_core4 = require("@nestjs/core");
|
|
2136
2139
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
2137
2140
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2138
2141
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
@@ -2159,6 +2162,110 @@ function _ts_param4(paramIndex, decorator) {
|
|
|
2159
2162
|
};
|
|
2160
2163
|
}
|
|
2161
2164
|
__name(_ts_param4, "_ts_param");
|
|
2165
|
+
var SweepLeases = class {
|
|
2166
|
+
static {
|
|
2167
|
+
__name(this, "SweepLeases");
|
|
2168
|
+
}
|
|
2169
|
+
moduleRef;
|
|
2170
|
+
options;
|
|
2171
|
+
logger = new import_common7.Logger("nestjs-durable");
|
|
2172
|
+
/** Set by {@link onModuleInit} (before any poller's bootstrap). `null`: no `@nestjs/locks`. */
|
|
2173
|
+
locks = null;
|
|
2174
|
+
leases = /* @__PURE__ */ new Map();
|
|
2175
|
+
constructor(moduleRef, options) {
|
|
2176
|
+
this.moduleRef = moduleRef;
|
|
2177
|
+
this.options = options;
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Run `fn` if this pod holds (or now takes) the lease of `sweep`; otherwise skip it and resolve
|
|
2181
|
+
* `undefined`. Without `@nestjs/locks` it always runs `fn`.
|
|
2182
|
+
*/
|
|
2183
|
+
async run(sweep, fn) {
|
|
2184
|
+
const locks = this.locks;
|
|
2185
|
+
if (!locks) return fn();
|
|
2186
|
+
if (!await this.holds(locks, sweep)) return void 0;
|
|
2187
|
+
return fn();
|
|
2188
|
+
}
|
|
2189
|
+
async holds(locks, sweep) {
|
|
2190
|
+
if (this.leases.get(sweep)?.held) return true;
|
|
2191
|
+
this.leases.delete(sweep);
|
|
2192
|
+
let lock;
|
|
2193
|
+
try {
|
|
2194
|
+
lock = await locks.acquire(this.key(sweep));
|
|
2195
|
+
} catch (error) {
|
|
2196
|
+
this.logger.warn(`could not take the ${sweep} sweep lease; skipping this tick: ${String(error)}`);
|
|
2197
|
+
return false;
|
|
2198
|
+
}
|
|
2199
|
+
if (!lock) return false;
|
|
2200
|
+
this.leases.set(sweep, lock);
|
|
2201
|
+
return true;
|
|
2202
|
+
}
|
|
2203
|
+
key(sweep) {
|
|
2204
|
+
const ns = this.options?.namespace;
|
|
2205
|
+
return ns ? `durable:${sweep}:${ns}` : `durable:${sweep}`;
|
|
2206
|
+
}
|
|
2207
|
+
/** Detects `Locks` once, and logs which mode is active. Nest awaits it before any bootstrap hook. */
|
|
2208
|
+
async onModuleInit() {
|
|
2209
|
+
this.locks = await this.detect();
|
|
2210
|
+
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)");
|
|
2211
|
+
}
|
|
2212
|
+
async detect() {
|
|
2213
|
+
let locks = null;
|
|
2214
|
+
if (this.moduleRef) {
|
|
2215
|
+
try {
|
|
2216
|
+
const specifier = "@nestjs/locks";
|
|
2217
|
+
const mod = await import(specifier);
|
|
2218
|
+
if (mod.Locks) {
|
|
2219
|
+
locks = this.moduleRef.get(mod.Locks, {
|
|
2220
|
+
strict: false
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2223
|
+
} catch {
|
|
2224
|
+
locks = null;
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
return locks;
|
|
2228
|
+
}
|
|
2229
|
+
};
|
|
2230
|
+
SweepLeases = _ts_decorate7([
|
|
2231
|
+
(0, import_common7.Injectable)(),
|
|
2232
|
+
_ts_param4(0, (0, import_common7.Optional)()),
|
|
2233
|
+
_ts_param4(1, (0, import_common7.Optional)()),
|
|
2234
|
+
_ts_param4(1, (0, import_common7.Inject)(import_nestjs_durable_core12.DURABLE_OPTIONS_CANONICAL)),
|
|
2235
|
+
_ts_metadata7("design:type", Function),
|
|
2236
|
+
_ts_metadata7("design:paramtypes", [
|
|
2237
|
+
typeof import_core4.ModuleRef === "undefined" ? Object : import_core4.ModuleRef,
|
|
2238
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
2239
|
+
])
|
|
2240
|
+
], SweepLeases);
|
|
2241
|
+
|
|
2242
|
+
// src/retention-poller.ts
|
|
2243
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
2244
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2245
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2246
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2247
|
+
} else {
|
|
2248
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2249
|
+
if (d = decorators[i]) {
|
|
2250
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2255
|
+
}
|
|
2256
|
+
__name(_ts_decorate8, "_ts_decorate");
|
|
2257
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
2258
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2259
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
__name(_ts_metadata8, "_ts_metadata");
|
|
2263
|
+
function _ts_param5(paramIndex, decorator) {
|
|
2264
|
+
return function(target, key) {
|
|
2265
|
+
decorator(target, key, paramIndex);
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
__name(_ts_param5, "_ts_param");
|
|
2162
2269
|
var DEFAULT_SWEEP_INTERVAL_MS = 6e4;
|
|
2163
2270
|
var DEFAULT_BATCH_SIZE = 1e3;
|
|
2164
2271
|
var MAX_BATCHES_PER_POLICY = 100;
|
|
@@ -2172,10 +2279,10 @@ function validateRetention(retention) {
|
|
|
2172
2279
|
if (policy.maxAge == null && policy.maxCount == null) {
|
|
2173
2280
|
throw new Error("durable retention: each policy must set maxAge and/or maxCount");
|
|
2174
2281
|
}
|
|
2175
|
-
if (policy.maxAge != null) (0,
|
|
2282
|
+
if (policy.maxAge != null) (0, import_nestjs_durable_core13.parseDuration)(policy.maxAge);
|
|
2176
2283
|
for (const status of policy.statuses) {
|
|
2177
|
-
if (!
|
|
2178
|
-
throw new Error(`durable retention: status "${status}" is not terminal; only ${
|
|
2284
|
+
if (!import_nestjs_durable_core13.TERMINAL_RUN_STATUSES.includes(status)) {
|
|
2285
|
+
throw new Error(`durable retention: status "${status}" is not terminal; only ${import_nestjs_durable_core13.TERMINAL_RUN_STATUSES.join(", ")} can be pruned`);
|
|
2179
2286
|
}
|
|
2180
2287
|
const key = `${scopeKey}|${status}`;
|
|
2181
2288
|
if (seen.has(key)) {
|
|
@@ -2201,14 +2308,16 @@ var RetentionPoller = class {
|
|
|
2201
2308
|
}
|
|
2202
2309
|
store;
|
|
2203
2310
|
options;
|
|
2311
|
+
leases;
|
|
2204
2312
|
timer;
|
|
2205
2313
|
sweeping = false;
|
|
2206
2314
|
stopping = false;
|
|
2207
2315
|
/** The sweep in flight, so shutdown can wait for it before the store closes. */
|
|
2208
2316
|
current;
|
|
2209
|
-
constructor(store, options) {
|
|
2317
|
+
constructor(store, options, leases = new SweepLeases()) {
|
|
2210
2318
|
this.store = store;
|
|
2211
2319
|
this.options = options;
|
|
2320
|
+
this.leases = leases;
|
|
2212
2321
|
}
|
|
2213
2322
|
/** Non-null once past the `isDrivingOperator` guard (which requires `options.store` to be set). */
|
|
2214
2323
|
requireStore() {
|
|
@@ -2227,7 +2336,7 @@ var RetentionPoller = class {
|
|
|
2227
2336
|
return;
|
|
2228
2337
|
}
|
|
2229
2338
|
void this.sweep();
|
|
2230
|
-
const intervalMs = retention.sweepInterval != null ? (0,
|
|
2339
|
+
const intervalMs = retention.sweepInterval != null ? (0, import_nestjs_durable_core13.parseDuration)(retention.sweepInterval) : DEFAULT_SWEEP_INTERVAL_MS;
|
|
2231
2340
|
if (intervalMs > 0) {
|
|
2232
2341
|
this.timer = setInterval(() => void this.sweep(), intervalMs);
|
|
2233
2342
|
this.timer.unref?.();
|
|
@@ -2270,37 +2379,42 @@ var RetentionPoller = class {
|
|
|
2270
2379
|
if (!retention || typeof prune !== "function") return;
|
|
2271
2380
|
this.sweeping = true;
|
|
2272
2381
|
try {
|
|
2273
|
-
|
|
2274
|
-
const now = Date.now();
|
|
2275
|
-
for (const policy of retention.policies) {
|
|
2276
|
-
for (let batch = 0; batch < MAX_BATCHES_PER_POLICY; batch++) {
|
|
2277
|
-
if (this.stopping) return;
|
|
2278
|
-
const deleted = await prune.call(store, policy, now, batchSize);
|
|
2279
|
-
if (deleted < batchSize) break;
|
|
2280
|
-
}
|
|
2281
|
-
}
|
|
2382
|
+
await this.leases.run("retention", () => this.prune(retention, store, prune));
|
|
2282
2383
|
} catch (error) {
|
|
2283
2384
|
console.error("[nestjs-durable] retention sweep failed; retrying next interval:", error);
|
|
2284
2385
|
} finally {
|
|
2285
2386
|
this.sweeping = false;
|
|
2286
2387
|
}
|
|
2287
2388
|
}
|
|
2389
|
+
async prune(retention, store, prune) {
|
|
2390
|
+
const batchSize = retention.batchSize ?? DEFAULT_BATCH_SIZE;
|
|
2391
|
+
const now = Date.now();
|
|
2392
|
+
for (const policy of retention.policies) {
|
|
2393
|
+
for (let batch = 0; batch < MAX_BATCHES_PER_POLICY; batch++) {
|
|
2394
|
+
if (this.stopping) return;
|
|
2395
|
+
const deleted = await prune.call(store, policy, now, batchSize);
|
|
2396
|
+
if (deleted < batchSize) break;
|
|
2397
|
+
}
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2288
2400
|
};
|
|
2289
|
-
RetentionPoller =
|
|
2290
|
-
(0,
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2401
|
+
RetentionPoller = _ts_decorate8([
|
|
2402
|
+
(0, import_common8.Injectable)(),
|
|
2403
|
+
_ts_param5(0, (0, import_common8.Inject)(import_nestjs_durable_core13.STATE_STORE_CANONICAL)),
|
|
2404
|
+
_ts_param5(1, (0, import_common8.Inject)(import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL)),
|
|
2405
|
+
_ts_param5(2, (0, import_common8.Optional)()),
|
|
2406
|
+
_ts_metadata8("design:type", Function),
|
|
2407
|
+
_ts_metadata8("design:paramtypes", [
|
|
2295
2408
|
Object,
|
|
2296
|
-
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
2409
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
2410
|
+
typeof SweepLeases === "undefined" ? Object : SweepLeases
|
|
2297
2411
|
])
|
|
2298
2412
|
], RetentionPoller);
|
|
2299
2413
|
|
|
2300
2414
|
// src/store-run-gateway.ts
|
|
2301
|
-
var
|
|
2302
|
-
var
|
|
2303
|
-
function
|
|
2415
|
+
var import_nestjs_durable_core14 = require("@dudousxd/nestjs-durable-core");
|
|
2416
|
+
var import_common9 = require("@nestjs/common");
|
|
2417
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2304
2418
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2305
2419
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2306
2420
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2313,19 +2427,19 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2313
2427
|
}
|
|
2314
2428
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2315
2429
|
}
|
|
2316
|
-
__name(
|
|
2317
|
-
function
|
|
2430
|
+
__name(_ts_decorate9, "_ts_decorate");
|
|
2431
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
2318
2432
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2319
2433
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2320
2434
|
}
|
|
2321
2435
|
}
|
|
2322
|
-
__name(
|
|
2323
|
-
function
|
|
2436
|
+
__name(_ts_metadata9, "_ts_metadata");
|
|
2437
|
+
function _ts_param6(paramIndex, decorator) {
|
|
2324
2438
|
return function(target, key) {
|
|
2325
2439
|
decorator(target, key, paramIndex);
|
|
2326
2440
|
};
|
|
2327
2441
|
}
|
|
2328
|
-
__name(
|
|
2442
|
+
__name(_ts_param6, "_ts_param");
|
|
2329
2443
|
function detailExtras(links) {
|
|
2330
2444
|
const { lifecycleSubscribers, lifecycleDeliveries, waitsFor, awaitedBy, triggeredBy } = links;
|
|
2331
2445
|
if (!lifecycleSubscribers && !lifecycleDeliveries && !waitsFor && !awaitedBy && !triggeredBy) {
|
|
@@ -2341,14 +2455,14 @@ function detailExtras(links) {
|
|
|
2341
2455
|
}
|
|
2342
2456
|
__name(detailExtras, "detailExtras");
|
|
2343
2457
|
function withoutRegistry(query) {
|
|
2344
|
-
if (query.workflow ===
|
|
2458
|
+
if (query.workflow === import_nestjs_durable_core14.LIFECYCLE_REGISTRY_WORKFLOW || query.workflows?.includes(import_nestjs_durable_core14.LIFECYCLE_REGISTRY_WORKFLOW)) {
|
|
2345
2459
|
return query;
|
|
2346
2460
|
}
|
|
2347
2461
|
return {
|
|
2348
2462
|
...query,
|
|
2349
2463
|
excludeWorkflows: [
|
|
2350
2464
|
...query.excludeWorkflows ?? [],
|
|
2351
|
-
|
|
2465
|
+
import_nestjs_durable_core14.LIFECYCLE_REGISTRY_WORKFLOW
|
|
2352
2466
|
]
|
|
2353
2467
|
};
|
|
2354
2468
|
}
|
|
@@ -2385,10 +2499,10 @@ var StoreRunGateway = class {
|
|
|
2385
2499
|
...links
|
|
2386
2500
|
};
|
|
2387
2501
|
}
|
|
2388
|
-
if ((0,
|
|
2502
|
+
if ((0, import_nestjs_durable_core14.aggregatesCheckpoints)(this.store)) {
|
|
2389
2503
|
const stats = await this.store.checkpointStats(runId);
|
|
2390
|
-
const etag = (0,
|
|
2391
|
-
if ((0,
|
|
2504
|
+
const etag = (0, import_nestjs_durable_core14.extendEtag)((0, import_nestjs_durable_core14.runDetailEtag)(run, stats, over), detailExtras(links));
|
|
2505
|
+
if ((0, import_nestjs_durable_core14.etagMatches)(options?.ifNoneMatch, etag)) {
|
|
2392
2506
|
return {
|
|
2393
2507
|
run,
|
|
2394
2508
|
timeline: [],
|
|
@@ -2399,18 +2513,18 @@ var StoreRunGateway = class {
|
|
|
2399
2513
|
}
|
|
2400
2514
|
return {
|
|
2401
2515
|
run,
|
|
2402
|
-
...await (0,
|
|
2516
|
+
...await (0, import_nestjs_durable_core14.summarizeRunFromStore)(this.store, runId, over, stats),
|
|
2403
2517
|
etag,
|
|
2404
2518
|
...links
|
|
2405
2519
|
};
|
|
2406
2520
|
}
|
|
2407
2521
|
const full = await this.store.listCheckpoints(runId);
|
|
2408
|
-
const { timeline, fans } = (0,
|
|
2409
|
-
const ids = (0,
|
|
2522
|
+
const { timeline, fans } = (0, import_nestjs_durable_core14.summarizeTimeline)(full, over);
|
|
2523
|
+
const ids = (0, import_nestjs_durable_core14.childIdsOf)(full);
|
|
2410
2524
|
return {
|
|
2411
2525
|
run,
|
|
2412
2526
|
timeline,
|
|
2413
|
-
children: ids.slice(0,
|
|
2527
|
+
children: ids.slice(0, import_nestjs_durable_core14.SUMMARY_CHILD_LIMIT),
|
|
2414
2528
|
fans,
|
|
2415
2529
|
childCount: ids.length,
|
|
2416
2530
|
...links
|
|
@@ -2425,24 +2539,24 @@ var StoreRunGateway = class {
|
|
|
2425
2539
|
*/
|
|
2426
2540
|
async lifecycleLinks(run) {
|
|
2427
2541
|
const triggered = await this.engine.triggeredRuns(run);
|
|
2428
|
-
const source = (0,
|
|
2429
|
-
const kind = (0,
|
|
2542
|
+
const source = (0, import_nestjs_durable_core14.lifecycleSourceOf)(run);
|
|
2543
|
+
const kind = (0, import_nestjs_durable_core14.lifecycleKindOf)(run.status);
|
|
2430
2544
|
const subscribers = kind ? await this.engine.lifecycleSubscribers(run.workflow, kind, run.namespace || "default") : [];
|
|
2431
2545
|
const workflowLifecycle = await this.engine.workflowLifecycle(run.workflow);
|
|
2432
2546
|
const linked = workflowLifecycle.startsOnSettle.length > 0 || workflowLifecycle.startedBy.length > 0;
|
|
2433
|
-
const deliveries = kind ? (0,
|
|
2547
|
+
const deliveries = kind ? (0, import_nestjs_durable_core14.lifecycleDeliveriesOf)(run, {
|
|
2434
2548
|
subscribers,
|
|
2435
2549
|
live: new Set(subscribers),
|
|
2436
2550
|
coalesced: this.engine.coalescedSubscribers(run)
|
|
2437
2551
|
}) : [];
|
|
2438
2552
|
const [own, onIt] = await Promise.all([
|
|
2439
|
-
run.status === "suspended" ? (0,
|
|
2553
|
+
run.status === "suspended" ? (0, import_nestjs_durable_core14.listSignalWaitersOfRuns)(this.store, [
|
|
2440
2554
|
run.id
|
|
2441
2555
|
]) : [],
|
|
2442
|
-
run.workflow.startsWith("__") ? [] : this.store.listSignalWaiters((0,
|
|
2556
|
+
run.workflow.startsWith("__") ? [] : this.store.listSignalWaiters((0, import_nestjs_durable_core14.runWaitPrefix)(run.id))
|
|
2443
2557
|
]);
|
|
2444
2558
|
const waitsFor = own.flatMap((w) => {
|
|
2445
|
-
const target = (0,
|
|
2559
|
+
const target = (0, import_nestjs_durable_core14.runWaitTargetOf)(w);
|
|
2446
2560
|
return target !== void 0 ? [
|
|
2447
2561
|
{
|
|
2448
2562
|
runId: target,
|
|
@@ -2450,14 +2564,14 @@ var StoreRunGateway = class {
|
|
|
2450
2564
|
}
|
|
2451
2565
|
] : [];
|
|
2452
2566
|
});
|
|
2453
|
-
const awaitedBy = onIt.filter((w) => (0,
|
|
2567
|
+
const awaitedBy = onIt.filter((w) => (0, import_nestjs_durable_core14.runWaitTargetOf)(w) === run.id).map((w) => ({
|
|
2454
2568
|
runId: w.runId,
|
|
2455
2569
|
seq: w.seq
|
|
2456
2570
|
}));
|
|
2457
2571
|
const started = deliveries.flatMap((d) => d.state === "started" && d.runId !== void 0 ? [
|
|
2458
2572
|
d.runId
|
|
2459
2573
|
] : []);
|
|
2460
|
-
const { runs } = await (0,
|
|
2574
|
+
const { runs } = await (0, import_nestjs_durable_core14.readRunsByIds)(this.store, [
|
|
2461
2575
|
...source ? [
|
|
2462
2576
|
source.runId
|
|
2463
2577
|
] : [],
|
|
@@ -2474,7 +2588,7 @@ var StoreRunGateway = class {
|
|
|
2474
2588
|
} : link;
|
|
2475
2589
|
}, "withRun");
|
|
2476
2590
|
const sourceRun = source ? runs.get(source.runId) : void 0;
|
|
2477
|
-
const traceId = (0,
|
|
2591
|
+
const traceId = (0, import_nestjs_durable_core14.traceIdOfTraceparent)((0, import_nestjs_durable_core14.lifecycleTraceparentOf)(sourceRun?.tags));
|
|
2478
2592
|
return {
|
|
2479
2593
|
...triggered.length > 0 ? {
|
|
2480
2594
|
triggered
|
|
@@ -2519,12 +2633,12 @@ var StoreRunGateway = class {
|
|
|
2519
2633
|
}
|
|
2520
2634
|
async getFanMembers(runId, group, query) {
|
|
2521
2635
|
if (!await this.store.getRun(runId)) return null;
|
|
2522
|
-
if ((0,
|
|
2636
|
+
if ((0, import_nestjs_durable_core14.aggregatesCheckpoints)(this.store)) {
|
|
2523
2637
|
const stats = await this.store.checkpointStats(runId, {
|
|
2524
2638
|
group
|
|
2525
2639
|
});
|
|
2526
|
-
const etag = (0,
|
|
2527
|
-
if ((0,
|
|
2640
|
+
const etag = (0, import_nestjs_durable_core14.fanPageEtag)(group, stats, query);
|
|
2641
|
+
if ((0, import_nestjs_durable_core14.etagMatches)(query.ifNoneMatch, etag)) {
|
|
2528
2642
|
return {
|
|
2529
2643
|
items: [],
|
|
2530
2644
|
total: 0,
|
|
@@ -2533,17 +2647,17 @@ var StoreRunGateway = class {
|
|
|
2533
2647
|
};
|
|
2534
2648
|
}
|
|
2535
2649
|
return {
|
|
2536
|
-
...await (0,
|
|
2650
|
+
...await (0, import_nestjs_durable_core14.pageFanFromStore)(this.store, runId, group, query, stats),
|
|
2537
2651
|
etag
|
|
2538
2652
|
};
|
|
2539
2653
|
}
|
|
2540
|
-
return (0,
|
|
2654
|
+
return (0, import_nestjs_durable_core14.pageFan)(await this.store.listCheckpoints(runId), group, query);
|
|
2541
2655
|
}
|
|
2542
2656
|
async listRuns(query) {
|
|
2543
2657
|
const runs = await this.store.listRuns(withoutRegistry(query));
|
|
2544
|
-
const waiterByRun = (0,
|
|
2658
|
+
const waiterByRun = (0, import_nestjs_durable_core14.indexWaitersByRun)(await (0, import_nestjs_durable_core14.listSignalWaitersOfRuns)(this.store, runs.filter((run) => run.status === "suspended").map((run) => run.id)));
|
|
2545
2659
|
return runs.map((run) => {
|
|
2546
|
-
const waiting = (0,
|
|
2660
|
+
const waiting = (0, import_nestjs_durable_core14.resolveRunWaiting)(run, waiterByRun);
|
|
2547
2661
|
return waiting ? {
|
|
2548
2662
|
...run,
|
|
2549
2663
|
waiting
|
|
@@ -2560,7 +2674,7 @@ var StoreRunGateway = class {
|
|
|
2560
2674
|
const scoped = withoutRegistry(query);
|
|
2561
2675
|
if (this.store.runFacets) return this.store.runFacets(scoped);
|
|
2562
2676
|
const runs = await this.store.listRuns(scoped);
|
|
2563
|
-
return (0,
|
|
2677
|
+
return (0, import_nestjs_durable_core14.mergeRunFacetRows)(runs.map((r) => ({
|
|
2564
2678
|
status: r.status,
|
|
2565
2679
|
origin: r.origin,
|
|
2566
2680
|
count: 1
|
|
@@ -2595,13 +2709,13 @@ var StoreRunGateway = class {
|
|
|
2595
2709
|
"suspended"
|
|
2596
2710
|
]
|
|
2597
2711
|
}),
|
|
2598
|
-
(0,
|
|
2712
|
+
(0, import_nestjs_durable_core14.listSignalWaitersOfRuns)(this.store, runIds)
|
|
2599
2713
|
]);
|
|
2600
|
-
const waiterByRun = (0,
|
|
2714
|
+
const waiterByRun = (0, import_nestjs_durable_core14.indexWaitersByRun)(waiters);
|
|
2601
2715
|
const result = {};
|
|
2602
2716
|
for (const run of suspended) {
|
|
2603
2717
|
if (!idSet.has(run.id)) continue;
|
|
2604
|
-
const waiting = (0,
|
|
2718
|
+
const waiting = (0, import_nestjs_durable_core14.resolveRunWaiting)(run, waiterByRun);
|
|
2605
2719
|
if (waiting) result[run.id] = waiting;
|
|
2606
2720
|
}
|
|
2607
2721
|
return result;
|
|
@@ -2636,13 +2750,13 @@ var StoreRunGateway = class {
|
|
|
2636
2750
|
});
|
|
2637
2751
|
}
|
|
2638
2752
|
};
|
|
2639
|
-
StoreRunGateway =
|
|
2640
|
-
(0,
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2753
|
+
StoreRunGateway = _ts_decorate9([
|
|
2754
|
+
(0, import_common9.Injectable)(),
|
|
2755
|
+
_ts_param6(0, (0, import_common9.Inject)(import_nestjs_durable_core14.STATE_STORE_CANONICAL)),
|
|
2756
|
+
_ts_metadata9("design:type", Function),
|
|
2757
|
+
_ts_metadata9("design:paramtypes", [
|
|
2644
2758
|
typeof StateStore === "undefined" ? Object : StateStore,
|
|
2645
|
-
typeof
|
|
2759
|
+
typeof import_nestjs_durable_core14.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core14.WorkflowEngine
|
|
2646
2760
|
])
|
|
2647
2761
|
], StoreRunGateway);
|
|
2648
2762
|
|
|
@@ -2688,9 +2802,9 @@ var TenantEventRepublisher = class {
|
|
|
2688
2802
|
};
|
|
2689
2803
|
|
|
2690
2804
|
// src/timer-poller.ts
|
|
2691
|
-
var
|
|
2692
|
-
var
|
|
2693
|
-
function
|
|
2805
|
+
var import_nestjs_durable_core15 = require("@dudousxd/nestjs-durable-core");
|
|
2806
|
+
var import_common10 = require("@nestjs/common");
|
|
2807
|
+
function _ts_decorate10(decorators, target, key, desc) {
|
|
2694
2808
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2695
2809
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2696
2810
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2703,36 +2817,38 @@ function _ts_decorate9(decorators, target, key, desc) {
|
|
|
2703
2817
|
}
|
|
2704
2818
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2705
2819
|
}
|
|
2706
|
-
__name(
|
|
2707
|
-
function
|
|
2820
|
+
__name(_ts_decorate10, "_ts_decorate");
|
|
2821
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
2708
2822
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2709
2823
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2710
2824
|
}
|
|
2711
2825
|
}
|
|
2712
|
-
__name(
|
|
2713
|
-
function
|
|
2826
|
+
__name(_ts_metadata10, "_ts_metadata");
|
|
2827
|
+
function _ts_param7(paramIndex, decorator) {
|
|
2714
2828
|
return function(target, key) {
|
|
2715
2829
|
decorator(target, key, paramIndex);
|
|
2716
2830
|
};
|
|
2717
2831
|
}
|
|
2718
|
-
__name(
|
|
2832
|
+
__name(_ts_param7, "_ts_param");
|
|
2719
2833
|
var TimerPoller = class {
|
|
2720
2834
|
static {
|
|
2721
2835
|
__name(this, "TimerPoller");
|
|
2722
2836
|
}
|
|
2723
2837
|
engine;
|
|
2724
2838
|
options;
|
|
2839
|
+
leases;
|
|
2725
2840
|
timer;
|
|
2726
2841
|
polling = false;
|
|
2727
2842
|
/** The sweep in flight, so shutdown can wait for it instead of racing the store's close. */
|
|
2728
2843
|
current;
|
|
2729
2844
|
unsubscribeEnqueued;
|
|
2730
|
-
constructor(engine, options) {
|
|
2845
|
+
constructor(engine, options, leases = new SweepLeases()) {
|
|
2731
2846
|
this.engine = engine;
|
|
2732
2847
|
this.options = options;
|
|
2848
|
+
this.leases = leases;
|
|
2733
2849
|
}
|
|
2734
2850
|
async onApplicationBootstrap() {
|
|
2735
|
-
for (const s of this.options.schedules ?? []) (0,
|
|
2851
|
+
for (const s of this.options.schedules ?? []) (0, import_nestjs_durable_core15.workflowName)(s.workflow);
|
|
2736
2852
|
if (!isDrivingOperator(this.options)) return;
|
|
2737
2853
|
this.engine.consumeRuns?.();
|
|
2738
2854
|
this.unsubscribeEnqueued = this.engine.onEnqueued((runId) => {
|
|
@@ -2802,12 +2918,13 @@ var TimerPoller = class {
|
|
|
2802
2918
|
await this.sweep("recoverIncomplete", () => this.engine.recoverIncomplete());
|
|
2803
2919
|
await this.sweep("resumeDueTimers", () => this.engine.resumeDueTimers());
|
|
2804
2920
|
await this.sweep("sweepTimeouts", () => this.engine.sweepTimeouts());
|
|
2805
|
-
await this.sweep("sweepStalled", async () => this.engine.sweepStalled?.());
|
|
2806
|
-
await this.sweep("sweepBufferedSignals", async () => this.engine.sweepBufferedSignals?.());
|
|
2921
|
+
await this.sweep("sweepStalled", () => this.leases.run("stalled-pager", async () => this.engine.sweepStalled?.()));
|
|
2922
|
+
await this.sweep("sweepBufferedSignals", () => this.leases.run("buffered-signals", async () => this.engine.sweepBufferedSignals?.()));
|
|
2923
|
+
await this.sweep("sweepExpiredSignalIds", () => this.leases.run("signal-ids", async () => this.engine.sweepExpiredSignalIds?.()));
|
|
2807
2924
|
await this.sweep("sweepLifecycleEvents", async () => this.engine.sweepLifecycleEvents?.());
|
|
2808
2925
|
const schedules = this.options.schedules;
|
|
2809
2926
|
if (schedules && schedules.length > 0) {
|
|
2810
|
-
await this.sweep("schedules", () => (0,
|
|
2927
|
+
await this.sweep("schedules", () => (0, import_nestjs_durable_core15.runSchedules)(this.engine, schedules, Date.now()));
|
|
2811
2928
|
}
|
|
2812
2929
|
if (this.options.persistedSchedules) {
|
|
2813
2930
|
await this.sweep("persistedSchedules", () => this.engine.schedules.tick());
|
|
@@ -2823,25 +2940,27 @@ var TimerPoller = class {
|
|
|
2823
2940
|
}
|
|
2824
2941
|
}
|
|
2825
2942
|
};
|
|
2826
|
-
TimerPoller =
|
|
2827
|
-
(0,
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
typeof
|
|
2943
|
+
TimerPoller = _ts_decorate10([
|
|
2944
|
+
(0, import_common10.Injectable)(),
|
|
2945
|
+
_ts_param7(1, (0, import_common10.Inject)(import_nestjs_durable_core15.DURABLE_OPTIONS_CANONICAL)),
|
|
2946
|
+
_ts_param7(2, (0, import_common10.Optional)()),
|
|
2947
|
+
_ts_metadata10("design:type", Function),
|
|
2948
|
+
_ts_metadata10("design:paramtypes", [
|
|
2949
|
+
typeof import_nestjs_durable_core15.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core15.WorkflowEngine,
|
|
2950
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
2951
|
+
typeof SweepLeases === "undefined" ? Object : SweepLeases
|
|
2833
2952
|
])
|
|
2834
2953
|
], TimerPoller);
|
|
2835
2954
|
|
|
2836
2955
|
// src/tokens.ts
|
|
2837
|
-
var
|
|
2956
|
+
var import_nestjs_durable_core16 = require("@dudousxd/nestjs-durable-core");
|
|
2838
2957
|
var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
2839
|
-
var RUN_GATEWAY =
|
|
2958
|
+
var RUN_GATEWAY = import_nestjs_durable_core16.RunGateway;
|
|
2840
2959
|
|
|
2841
2960
|
// src/workflow.registrar.ts
|
|
2842
|
-
var
|
|
2843
|
-
var
|
|
2844
|
-
var
|
|
2961
|
+
var import_nestjs_durable_core17 = require("@dudousxd/nestjs-durable-core");
|
|
2962
|
+
var import_common11 = require("@nestjs/common");
|
|
2963
|
+
var import_core5 = require("@nestjs/core");
|
|
2845
2964
|
|
|
2846
2965
|
// src/step-interceptor.ts
|
|
2847
2966
|
var import_reflect_metadata3 = require("reflect-metadata");
|
|
@@ -2858,7 +2977,7 @@ function isStepInterceptor(target) {
|
|
|
2858
2977
|
__name(isStepInterceptor, "isStepInterceptor");
|
|
2859
2978
|
|
|
2860
2979
|
// src/workflow.registrar.ts
|
|
2861
|
-
function
|
|
2980
|
+
function _ts_decorate11(decorators, target, key, desc) {
|
|
2862
2981
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2863
2982
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2864
2983
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2871,19 +2990,19 @@ function _ts_decorate10(decorators, target, key, desc) {
|
|
|
2871
2990
|
}
|
|
2872
2991
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2873
2992
|
}
|
|
2874
|
-
__name(
|
|
2875
|
-
function
|
|
2993
|
+
__name(_ts_decorate11, "_ts_decorate");
|
|
2994
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
2876
2995
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2877
2996
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
2878
2997
|
}
|
|
2879
2998
|
}
|
|
2880
|
-
__name(
|
|
2881
|
-
function
|
|
2999
|
+
__name(_ts_metadata11, "_ts_metadata");
|
|
3000
|
+
function _ts_param8(paramIndex, decorator) {
|
|
2882
3001
|
return function(target, key) {
|
|
2883
3002
|
decorator(target, key, paramIndex);
|
|
2884
3003
|
};
|
|
2885
3004
|
}
|
|
2886
|
-
__name(
|
|
3005
|
+
__name(_ts_param8, "_ts_param");
|
|
2887
3006
|
var UNSERVED_ROUTES_RECHECK_MS = 3e4;
|
|
2888
3007
|
var WorkflowRegistrar = class {
|
|
2889
3008
|
static {
|
|
@@ -2980,11 +3099,11 @@ var WorkflowRegistrar = class {
|
|
|
2980
3099
|
// so a turn dispatched under the wrong token would never be consumed. Absent → the inline fast
|
|
2981
3100
|
// path (unchanged).
|
|
2982
3101
|
...this.inAppWorker ? {
|
|
2983
|
-
group: (0,
|
|
2984
|
-
executor: new
|
|
3102
|
+
group: (0, import_nestjs_durable_core17.tenantGroup)((0, import_nestjs_durable_core17.sanitizeQueueToken)(meta.name), this.inAppWorker.partition),
|
|
3103
|
+
executor: new import_nestjs_durable_core17.RemoteWorkflowExecutor(this.inAppWorker.transport, meta.name, this.inAppWorker.partition)
|
|
2985
3104
|
} : {}
|
|
2986
3105
|
});
|
|
2987
|
-
(0,
|
|
3106
|
+
(0, import_nestjs_durable_core17.bindWorkflowClass)(workflowCtor, {
|
|
2988
3107
|
start: /* @__PURE__ */ __name((name, input, runId, opts) => this.engine.start(name, input, runId, opts), "start"),
|
|
2989
3108
|
waitForRun: /* @__PURE__ */ __name((runId, opts) => this.engine.waitForRun(runId, opts), "waitForRun")
|
|
2990
3109
|
});
|
|
@@ -2999,7 +3118,7 @@ var WorkflowRegistrar = class {
|
|
|
2999
3118
|
});
|
|
3000
3119
|
deadLetterByWorkflow.set(meta.name, dlqName);
|
|
3001
3120
|
} else if (meta.deadLetterWorkflow) {
|
|
3002
|
-
deadLetterByWorkflow.set(meta.name, (0,
|
|
3121
|
+
deadLetterByWorkflow.set(meta.name, (0, import_nestjs_durable_core17.workflowName)(meta.deadLetterWorkflow));
|
|
3003
3122
|
}
|
|
3004
3123
|
});
|
|
3005
3124
|
this.reportUnattributed(unattributed);
|
|
@@ -3047,7 +3166,7 @@ var WorkflowRegistrar = class {
|
|
|
3047
3166
|
* a `dlq:<runId>` id, so re-recovery never double-dispatches.
|
|
3048
3167
|
*/
|
|
3049
3168
|
installDeadLetterRouting(byWorkflow) {
|
|
3050
|
-
const fallback = this.options.deadLetterWorkflow ? (0,
|
|
3169
|
+
const fallback = this.options.deadLetterWorkflow ? (0, import_nestjs_durable_core17.workflowName)(this.options.deadLetterWorkflow) : void 0;
|
|
3051
3170
|
if (byWorkflow.size === 0 && !fallback) return;
|
|
3052
3171
|
this.engine.onDead((run) => {
|
|
3053
3172
|
const target = byWorkflow.get(run.workflow) ?? fallback;
|
|
@@ -3070,16 +3189,16 @@ var WorkflowRegistrar = class {
|
|
|
3070
3189
|
});
|
|
3071
3190
|
}
|
|
3072
3191
|
};
|
|
3073
|
-
WorkflowRegistrar =
|
|
3074
|
-
(0,
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
typeof
|
|
3081
|
-
typeof
|
|
3082
|
-
typeof
|
|
3192
|
+
WorkflowRegistrar = _ts_decorate11([
|
|
3193
|
+
(0, import_common11.Injectable)(),
|
|
3194
|
+
_ts_param8(3, (0, import_common11.Inject)(import_nestjs_durable_core17.STATE_STORE_CANONICAL)),
|
|
3195
|
+
_ts_param8(4, (0, import_common11.Inject)(import_nestjs_durable_core17.DURABLE_OPTIONS_CANONICAL)),
|
|
3196
|
+
_ts_param8(5, (0, import_common11.Inject)(IN_APP_WORKER_BINDING)),
|
|
3197
|
+
_ts_metadata11("design:type", Function),
|
|
3198
|
+
_ts_metadata11("design:paramtypes", [
|
|
3199
|
+
typeof import_core5.DiscoveryService === "undefined" ? Object : import_core5.DiscoveryService,
|
|
3200
|
+
typeof import_core5.MetadataScanner === "undefined" ? Object : import_core5.MetadataScanner,
|
|
3201
|
+
typeof import_nestjs_durable_core17.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core17.WorkflowEngine,
|
|
3083
3202
|
Object,
|
|
3084
3203
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
3085
3204
|
Object
|
|
@@ -3088,9 +3207,9 @@ WorkflowRegistrar = _ts_decorate10([
|
|
|
3088
3207
|
|
|
3089
3208
|
// src/workflow.service.ts
|
|
3090
3209
|
var import_node_crypto = require("crypto");
|
|
3091
|
-
var
|
|
3092
|
-
var
|
|
3093
|
-
function
|
|
3210
|
+
var import_nestjs_durable_core18 = require("@dudousxd/nestjs-durable-core");
|
|
3211
|
+
var import_common12 = require("@nestjs/common");
|
|
3212
|
+
function _ts_decorate12(decorators, target, key, desc) {
|
|
3094
3213
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3095
3214
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3096
3215
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3103,13 +3222,13 @@ function _ts_decorate11(decorators, target, key, desc) {
|
|
|
3103
3222
|
}
|
|
3104
3223
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3105
3224
|
}
|
|
3106
|
-
__name(
|
|
3107
|
-
function
|
|
3225
|
+
__name(_ts_decorate12, "_ts_decorate");
|
|
3226
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
3108
3227
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3109
3228
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3110
3229
|
}
|
|
3111
3230
|
}
|
|
3112
|
-
__name(
|
|
3231
|
+
__name(_ts_metadata12, "_ts_metadata");
|
|
3113
3232
|
var WorkflowService = class {
|
|
3114
3233
|
static {
|
|
3115
3234
|
__name(this, "WorkflowService");
|
|
@@ -3134,9 +3253,13 @@ var WorkflowService = class {
|
|
|
3134
3253
|
waitForRun(runId, opts) {
|
|
3135
3254
|
return this.engine.waitForRun(runId, opts);
|
|
3136
3255
|
}
|
|
3137
|
-
/**
|
|
3138
|
-
signal(
|
|
3139
|
-
|
|
3256
|
+
/**
|
|
3257
|
+
* Deliver an external signal (e.g. from a webhook) to the run waiting on `token`, or buffer it for
|
|
3258
|
+
* the next wait on it. With `{ id }`, a re-send with the same token and id is dropped (resolves
|
|
3259
|
+
* `null`): see {@link SignalOptions}.
|
|
3260
|
+
*/
|
|
3261
|
+
signal(token, payload, opts) {
|
|
3262
|
+
return this.engine.signal(token, payload, opts);
|
|
3140
3263
|
}
|
|
3141
3264
|
signalWithStart(workflow, input, runId, signal, opts) {
|
|
3142
3265
|
return this.engine.signalWithStart(workflow, input, runId, signal, opts);
|
|
@@ -3171,16 +3294,16 @@ var WorkflowService = class {
|
|
|
3171
3294
|
return this.engine.republishLifecycle(target);
|
|
3172
3295
|
}
|
|
3173
3296
|
};
|
|
3174
|
-
WorkflowService =
|
|
3175
|
-
(0,
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
typeof
|
|
3297
|
+
WorkflowService = _ts_decorate12([
|
|
3298
|
+
(0, import_common12.Injectable)(),
|
|
3299
|
+
_ts_metadata12("design:type", Function),
|
|
3300
|
+
_ts_metadata12("design:paramtypes", [
|
|
3301
|
+
typeof import_nestjs_durable_core18.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core18.WorkflowEngine
|
|
3179
3302
|
])
|
|
3180
3303
|
], WorkflowService);
|
|
3181
3304
|
|
|
3182
3305
|
// src/durable.module.ts
|
|
3183
|
-
function
|
|
3306
|
+
function _ts_decorate13(decorators, target, key, desc) {
|
|
3184
3307
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3185
3308
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
3186
3309
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -3193,19 +3316,19 @@ function _ts_decorate12(decorators, target, key, desc) {
|
|
|
3193
3316
|
}
|
|
3194
3317
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3195
3318
|
}
|
|
3196
|
-
__name(
|
|
3197
|
-
function
|
|
3319
|
+
__name(_ts_decorate13, "_ts_decorate");
|
|
3320
|
+
function _ts_metadata13(metadataKey, metadataValue) {
|
|
3198
3321
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
3199
3322
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
3200
3323
|
}
|
|
3201
3324
|
}
|
|
3202
|
-
__name(
|
|
3203
|
-
function
|
|
3325
|
+
__name(_ts_metadata13, "_ts_metadata");
|
|
3326
|
+
function _ts_param9(paramIndex, decorator) {
|
|
3204
3327
|
return function(target, key) {
|
|
3205
3328
|
decorator(target, key, paramIndex);
|
|
3206
3329
|
};
|
|
3207
3330
|
}
|
|
3208
|
-
__name(
|
|
3331
|
+
__name(_ts_param9, "_ts_param");
|
|
3209
3332
|
function resolveAccessor(moduleRef) {
|
|
3210
3333
|
try {
|
|
3211
3334
|
return moduleRef.get(CONTEXT_ACCESSOR, {
|
|
@@ -3393,16 +3516,16 @@ var RunGatewayBootstrap = class RunGatewayBootstrap2 {
|
|
|
3393
3516
|
this.unsubscribe?.();
|
|
3394
3517
|
}
|
|
3395
3518
|
};
|
|
3396
|
-
RunGatewayBootstrap =
|
|
3397
|
-
(0,
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
typeof
|
|
3519
|
+
RunGatewayBootstrap = _ts_decorate13([
|
|
3520
|
+
(0, import_common13.Injectable)(),
|
|
3521
|
+
_ts_param9(1, (0, import_common13.Inject)(import_nestjs_durable_core19.TRANSPORT_CANONICAL)),
|
|
3522
|
+
_ts_param9(3, (0, import_common13.Inject)(import_nestjs_durable_core19.STATE_STORE_CANONICAL)),
|
|
3523
|
+
_ts_param9(4, (0, import_common13.Inject)(import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL)),
|
|
3524
|
+
_ts_metadata13("design:type", Function),
|
|
3525
|
+
_ts_metadata13("design:paramtypes", [
|
|
3526
|
+
typeof import_nestjs_durable_core19.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core19.WorkflowEngine,
|
|
3404
3527
|
Object,
|
|
3405
|
-
typeof
|
|
3528
|
+
typeof import_nestjs_durable_core19.RunGateway === "undefined" ? Object : import_nestjs_durable_core19.RunGateway,
|
|
3406
3529
|
Object,
|
|
3407
3530
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
3408
3531
|
])
|
|
@@ -3414,13 +3537,13 @@ var DurableModule = class _DurableModule {
|
|
|
3414
3537
|
static forRoot(options) {
|
|
3415
3538
|
_DurableModule.assertValid(options);
|
|
3416
3539
|
return _DurableModule.build({
|
|
3417
|
-
provide:
|
|
3540
|
+
provide: import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL,
|
|
3418
3541
|
useValue: resolveTopology(options)
|
|
3419
3542
|
});
|
|
3420
3543
|
}
|
|
3421
3544
|
static forRootAsync(options) {
|
|
3422
3545
|
return _DurableModule.build({
|
|
3423
|
-
provide:
|
|
3546
|
+
provide: import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL,
|
|
3424
3547
|
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
3425
3548
|
const resolved = await options.useFactory(...args);
|
|
3426
3549
|
_DurableModule.assertValid(resolved);
|
|
@@ -3448,46 +3571,46 @@ var DurableModule = class _DurableModule {
|
|
|
3448
3571
|
module: _DurableModule,
|
|
3449
3572
|
global: true,
|
|
3450
3573
|
imports: [
|
|
3451
|
-
|
|
3574
|
+
import_core6.DiscoveryModule
|
|
3452
3575
|
],
|
|
3453
3576
|
providers: [
|
|
3454
3577
|
optionsProvider,
|
|
3455
3578
|
{
|
|
3456
|
-
provide:
|
|
3579
|
+
provide: import_nestjs_durable_core19.STATE_STORE_CANONICAL,
|
|
3457
3580
|
useFactory: /* @__PURE__ */ __name((options) => options.store !== void 0 ? scopedStore(options.store, options) : null, "useFactory"),
|
|
3458
3581
|
inject: [
|
|
3459
|
-
|
|
3582
|
+
import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL
|
|
3460
3583
|
]
|
|
3461
3584
|
},
|
|
3462
3585
|
{
|
|
3463
|
-
provide:
|
|
3586
|
+
provide: import_nestjs_durable_core19.TRANSPORT_CANONICAL,
|
|
3464
3587
|
// With a POOL (`transports`) and no singular `transport`, the canonical transport is the
|
|
3465
3588
|
// pool's PRIMARY — the same one the engine dispatches on first. Leaving it null starved
|
|
3466
3589
|
// the step registrar / in-app worker of a transport, so a pool-configured operator
|
|
3467
3590
|
// registered NO step handlers and its own steps parked in `wait` with no consumer.
|
|
3468
3591
|
useFactory: /* @__PURE__ */ __name((options) => options.transport ?? options.transports?.[0]?.transport ?? null, "useFactory"),
|
|
3469
3592
|
inject: [
|
|
3470
|
-
|
|
3593
|
+
import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL
|
|
3471
3594
|
]
|
|
3472
3595
|
},
|
|
3473
3596
|
// Legacy back-compat aliases (deprecated tokens still resolve to the same instances):
|
|
3474
3597
|
{
|
|
3475
|
-
provide:
|
|
3476
|
-
useExisting:
|
|
3598
|
+
provide: import_nestjs_durable_core19.STATE_STORE,
|
|
3599
|
+
useExisting: import_nestjs_durable_core19.STATE_STORE_CANONICAL
|
|
3477
3600
|
},
|
|
3478
3601
|
{
|
|
3479
|
-
provide:
|
|
3480
|
-
useExisting:
|
|
3602
|
+
provide: import_nestjs_durable_core19.TRANSPORT,
|
|
3603
|
+
useExisting: import_nestjs_durable_core19.TRANSPORT_CANONICAL
|
|
3481
3604
|
},
|
|
3482
3605
|
{
|
|
3483
|
-
provide:
|
|
3484
|
-
useExisting:
|
|
3606
|
+
provide: import_nestjs_durable_core19.DURABLE_OPTIONS,
|
|
3607
|
+
useExisting: import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL
|
|
3485
3608
|
},
|
|
3486
3609
|
{
|
|
3487
3610
|
// Shared token, bound EXACTLY once: a real engine for the operator role, or a store-less
|
|
3488
3611
|
// `DurableStartClient` facade for a thin worker (no `store`) — either way, `WorkflowService`
|
|
3489
3612
|
// and app code call `engine.start(...)` unchanged.
|
|
3490
|
-
provide:
|
|
3613
|
+
provide: import_nestjs_durable_core19.WorkflowEngine,
|
|
3491
3614
|
useFactory: /* @__PURE__ */ __name(async (options, store, transport, moduleRef) => {
|
|
3492
3615
|
if (options.store === void 0) {
|
|
3493
3616
|
return new DurableStartClient(options);
|
|
@@ -3508,7 +3631,7 @@ var DurableModule = class _DurableModule {
|
|
|
3508
3631
|
if (t) deferTransportConsumers(t);
|
|
3509
3632
|
}
|
|
3510
3633
|
}
|
|
3511
|
-
const engine = new
|
|
3634
|
+
const engine = new import_nestjs_durable_core19.WorkflowEngine({
|
|
3512
3635
|
store,
|
|
3513
3636
|
transport: transport ?? void 0,
|
|
3514
3637
|
transports: options.transports,
|
|
@@ -3524,8 +3647,12 @@ var DurableModule = class _DurableModule {
|
|
|
3524
3647
|
stalledAfterMs: options.stalledAfterMs,
|
|
3525
3648
|
timerBatchSize: options.timerBatchSize,
|
|
3526
3649
|
eventBufferTtlMs: options.eventBufferTtlMs,
|
|
3650
|
+
signalIdTtl: options.signalIdTtl,
|
|
3527
3651
|
blockedPollMs: options.blockedPollMs,
|
|
3528
3652
|
trackStepStart: options.trackStepStart,
|
|
3653
|
+
stickyRuns: options.stickyRuns,
|
|
3654
|
+
stickyIdleMs: options.stickyIdleMs,
|
|
3655
|
+
routeReplies: options.routeReplies,
|
|
3529
3656
|
instanceId: options.instanceId,
|
|
3530
3657
|
namespace: options.namespace,
|
|
3531
3658
|
webhookUrl: options.webhookUrl,
|
|
@@ -3550,23 +3677,24 @@ var DurableModule = class _DurableModule {
|
|
|
3550
3677
|
return engine;
|
|
3551
3678
|
}, "useFactory"),
|
|
3552
3679
|
inject: [
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3680
|
+
import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL,
|
|
3681
|
+
import_nestjs_durable_core19.STATE_STORE_CANONICAL,
|
|
3682
|
+
import_nestjs_durable_core19.TRANSPORT_CANONICAL,
|
|
3683
|
+
import_core6.ModuleRef
|
|
3557
3684
|
]
|
|
3558
3685
|
},
|
|
3559
3686
|
WorkflowService,
|
|
3560
3687
|
EntityService,
|
|
3561
3688
|
WorkflowRegistrar,
|
|
3562
3689
|
DurableStepRegistrar,
|
|
3690
|
+
SweepLeases,
|
|
3563
3691
|
TimerPoller,
|
|
3564
3692
|
RetentionPoller,
|
|
3565
3693
|
// Tenant run gateway: bound EXACTLY once — the store-backed `StoreRunGateway` for an operator,
|
|
3566
3694
|
// or (for a thin worker, no `store`) a `ProxyRunGateway` over `transport` when given, else a
|
|
3567
3695
|
// gateway whose every method rejects with a clear tenant error.
|
|
3568
3696
|
{
|
|
3569
|
-
provide:
|
|
3697
|
+
provide: import_nestjs_durable_core19.RunGateway,
|
|
3570
3698
|
useFactory: /* @__PURE__ */ __name((options, store, engine) => {
|
|
3571
3699
|
if (options.store !== void 0) {
|
|
3572
3700
|
if (!store) {
|
|
@@ -3577,9 +3705,9 @@ var DurableModule = class _DurableModule {
|
|
|
3577
3705
|
return options.transport ? new ProxyRunGateway(options.transport, options.partition ?? "default", options.runGatewayTimeoutMs, void 0, options.tenantToken) : unavailableRunGateway();
|
|
3578
3706
|
}, "useFactory"),
|
|
3579
3707
|
inject: [
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3708
|
+
import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL,
|
|
3709
|
+
import_nestjs_durable_core19.STATE_STORE_CANONICAL,
|
|
3710
|
+
import_nestjs_durable_core19.WorkflowEngine
|
|
3583
3711
|
]
|
|
3584
3712
|
},
|
|
3585
3713
|
RunGatewayBootstrap,
|
|
@@ -3593,23 +3721,23 @@ var DurableModule = class _DurableModule {
|
|
|
3593
3721
|
exports: [
|
|
3594
3722
|
WorkflowService,
|
|
3595
3723
|
EntityService,
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3724
|
+
import_nestjs_durable_core19.WorkflowEngine,
|
|
3725
|
+
import_nestjs_durable_core19.STATE_STORE,
|
|
3726
|
+
import_nestjs_durable_core19.STATE_STORE_CANONICAL,
|
|
3727
|
+
import_nestjs_durable_core19.TRANSPORT,
|
|
3728
|
+
import_nestjs_durable_core19.TRANSPORT_CANONICAL,
|
|
3729
|
+
import_nestjs_durable_core19.DURABLE_OPTIONS_CANONICAL,
|
|
3730
|
+
import_nestjs_durable_core19.RunGateway
|
|
3603
3731
|
]
|
|
3604
3732
|
};
|
|
3605
3733
|
}
|
|
3606
3734
|
};
|
|
3607
|
-
DurableModule =
|
|
3608
|
-
(0,
|
|
3735
|
+
DurableModule = _ts_decorate13([
|
|
3736
|
+
(0, import_common13.Module)({})
|
|
3609
3737
|
], DurableModule);
|
|
3610
3738
|
|
|
3611
3739
|
// src/index.ts
|
|
3612
|
-
var
|
|
3740
|
+
var import_nestjs_durable_core20 = require("@dudousxd/nestjs-durable-core");
|
|
3613
3741
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3614
3742
|
0 && (module.exports = {
|
|
3615
3743
|
BAD_RUN_REQUEST,
|