@dudousxd/nestjs-durable 0.62.0 → 0.64.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 +197 -88
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +48 -6
- package/dist/index.d.ts +48 -6
- package/dist/index.js +149 -42
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -732,6 +732,19 @@ var DurableStartClient = class {
|
|
|
732
732
|
...opts?.searchAttributes !== void 0 ? {
|
|
733
733
|
searchAttributes: opts.searchAttributes
|
|
734
734
|
} : {},
|
|
735
|
+
// The start options the control plane applies (version pin, priority, delayed start, quota).
|
|
736
|
+
...opts?.version !== void 0 ? {
|
|
737
|
+
version: opts.version
|
|
738
|
+
} : {},
|
|
739
|
+
...opts?.priority !== void 0 ? {
|
|
740
|
+
priority: opts.priority
|
|
741
|
+
} : {},
|
|
742
|
+
...opts?.startAt !== void 0 ? {
|
|
743
|
+
startAt: opts.startAt
|
|
744
|
+
} : {},
|
|
745
|
+
...opts?.concurrency !== void 0 ? {
|
|
746
|
+
concurrency: opts.concurrency
|
|
747
|
+
} : {},
|
|
735
748
|
...tenant ? {
|
|
736
749
|
tenantId: tenant.id,
|
|
737
750
|
...tenant.kind !== void 0 ? {
|
|
@@ -742,9 +755,10 @@ var DurableStartClient = class {
|
|
|
742
755
|
deps: this.deps
|
|
743
756
|
} : {}
|
|
744
757
|
});
|
|
758
|
+
const startAtMs = opts?.startAt instanceof Date ? opts.startAt.getTime() : opts?.startAt;
|
|
745
759
|
return {
|
|
746
760
|
runId,
|
|
747
|
-
status: "pending"
|
|
761
|
+
status: startAtMs !== void 0 && Number.isFinite(startAtMs) && startAtMs > Date.now() ? "suspended" : "pending"
|
|
748
762
|
};
|
|
749
763
|
}
|
|
750
764
|
cancel(_runId) {
|
|
@@ -790,7 +804,7 @@ function tenantUnsupported(method) {
|
|
|
790
804
|
__name(tenantUnsupported, "tenantUnsupported");
|
|
791
805
|
|
|
792
806
|
// src/durable-worker.module.ts
|
|
793
|
-
import { DURABLE_OPTIONS_CANONICAL } from "@dudousxd/nestjs-durable-core";
|
|
807
|
+
import { DURABLE_OPTIONS_CANONICAL, WorkflowEngine, bindWorkflowClass, resolveTenantToken as resolveTenantToken2, workflowName as workflowName3 } from "@dudousxd/nestjs-durable-core";
|
|
794
808
|
import { Inject, Injectable as Injectable2 } from "@nestjs/common";
|
|
795
809
|
import { DiscoveryService, MetadataScanner } from "@nestjs/core";
|
|
796
810
|
|
|
@@ -987,6 +1001,12 @@ function registerOnRuntime(runtime, scanner, meta, instance, origin) {
|
|
|
987
1001
|
}
|
|
988
1002
|
__name(registerOnRuntime, "registerOnRuntime");
|
|
989
1003
|
|
|
1004
|
+
// src/tokens.ts
|
|
1005
|
+
import { RunGateway } from "@dudousxd/nestjs-durable-core";
|
|
1006
|
+
var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
1007
|
+
var TENANT_AUTH = Symbol("nestjs-durable:tenant-auth");
|
|
1008
|
+
var RUN_GATEWAY = RunGateway;
|
|
1009
|
+
|
|
990
1010
|
// src/durable-worker.module.ts
|
|
991
1011
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
992
1012
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1029,28 +1049,38 @@ var ThinWorkflowRegistrar = class {
|
|
|
1029
1049
|
metadataScanner;
|
|
1030
1050
|
runtime;
|
|
1031
1051
|
options;
|
|
1032
|
-
|
|
1052
|
+
starter;
|
|
1053
|
+
constructor(discovery, metadataScanner, runtime, options, starter) {
|
|
1033
1054
|
this.discovery = discovery;
|
|
1034
1055
|
this.metadataScanner = metadataScanner;
|
|
1035
1056
|
this.runtime = runtime;
|
|
1036
1057
|
this.options = options;
|
|
1058
|
+
this.starter = starter;
|
|
1037
1059
|
}
|
|
1038
1060
|
onModuleInit() {
|
|
1039
1061
|
const runtime = this.runtime;
|
|
1040
1062
|
if (runtime === null || !isPureThinWorker(this.options)) return;
|
|
1041
|
-
|
|
1063
|
+
const starter = this.starter;
|
|
1064
|
+
scanWorkflows(this.discovery, (meta, instance, origin) => {
|
|
1065
|
+
registerOnRuntime(runtime, this.metadataScanner, meta, instance, origin);
|
|
1066
|
+
bindWorkflowClass(instance.constructor, {
|
|
1067
|
+
start: /* @__PURE__ */ __name((name, input, runId, opts) => starter.start(name, input, runId, opts), "start")
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1042
1070
|
}
|
|
1043
1071
|
};
|
|
1044
1072
|
ThinWorkflowRegistrar = _ts_decorate2([
|
|
1045
1073
|
Injectable2(),
|
|
1046
1074
|
_ts_param(2, Inject(DURABLE_WORKER_RUNTIME)),
|
|
1047
1075
|
_ts_param(3, Inject(DURABLE_OPTIONS_CANONICAL)),
|
|
1076
|
+
_ts_param(4, Inject(WorkflowEngine)),
|
|
1048
1077
|
_ts_metadata2("design:type", Function),
|
|
1049
1078
|
_ts_metadata2("design:paramtypes", [
|
|
1050
1079
|
typeof DiscoveryService === "undefined" ? Object : DiscoveryService,
|
|
1051
1080
|
typeof MetadataScanner === "undefined" ? Object : MetadataScanner,
|
|
1052
1081
|
Object,
|
|
1053
|
-
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
1082
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
1083
|
+
typeof WorkflowStartClient === "undefined" ? Object : WorkflowStartClient
|
|
1054
1084
|
])
|
|
1055
1085
|
], ThinWorkflowRegistrar);
|
|
1056
1086
|
var ThinStepRegistrar = class {
|
|
@@ -1093,18 +1123,25 @@ var ThinWorkerBootstrap = class {
|
|
|
1093
1123
|
options;
|
|
1094
1124
|
runRedisWorker;
|
|
1095
1125
|
runnersSink;
|
|
1126
|
+
auth;
|
|
1096
1127
|
runners = [];
|
|
1097
|
-
constructor(runtime, options, runRedisWorker2, runnersSink) {
|
|
1128
|
+
constructor(runtime, options, runRedisWorker2, runnersSink, auth) {
|
|
1098
1129
|
this.runtime = runtime;
|
|
1099
1130
|
this.options = options;
|
|
1100
1131
|
this.runRedisWorker = runRedisWorker2;
|
|
1101
1132
|
this.runnersSink = runnersSink;
|
|
1133
|
+
this.auth = auth;
|
|
1102
1134
|
}
|
|
1103
1135
|
async onApplicationBootstrap() {
|
|
1104
1136
|
const options = this.options;
|
|
1105
1137
|
const runtime = this.runtime;
|
|
1106
1138
|
if (runtime === null || !isPureThinWorker(options) || options.connection === void 0) return;
|
|
1107
|
-
if (options.consumers === false)
|
|
1139
|
+
if (options.consumers === false) {
|
|
1140
|
+
if ((options.schedules?.length ?? 0) > 0) {
|
|
1141
|
+
console.warn("[nestjs-durable] `schedules` on a tenant with `consumers: false` are not announced: a tenant announces its schedules on its worker descriptor, so declare them on the processes that run its workers.");
|
|
1142
|
+
}
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1108
1145
|
const handle = await this.runRedisWorker({
|
|
1109
1146
|
runtime,
|
|
1110
1147
|
connection: options.connection,
|
|
@@ -1119,7 +1156,10 @@ var ThinWorkerBootstrap = class {
|
|
|
1119
1156
|
} : {},
|
|
1120
1157
|
...options.concurrency !== void 0 ? {
|
|
1121
1158
|
concurrency: options.concurrency
|
|
1122
|
-
} : {}
|
|
1159
|
+
} : {},
|
|
1160
|
+
// Announce the app's schedules (an empty list too) so the control plane adopts, updates and
|
|
1161
|
+
// withdraws them: a tenant has no store to fire them from.
|
|
1162
|
+
...await tenantScheduleAnnouncement(options, this.auth.tenantToken)
|
|
1123
1163
|
});
|
|
1124
1164
|
this.runners.push(handle);
|
|
1125
1165
|
this.runnersSink.push(handle);
|
|
@@ -1134,14 +1174,47 @@ ThinWorkerBootstrap = _ts_decorate2([
|
|
|
1134
1174
|
_ts_param(1, Inject(DURABLE_OPTIONS_CANONICAL)),
|
|
1135
1175
|
_ts_param(2, Inject(RUN_REDIS_WORKER)),
|
|
1136
1176
|
_ts_param(3, Inject(DURABLE_WORKER_RUNNERS)),
|
|
1177
|
+
_ts_param(4, Inject(TENANT_AUTH)),
|
|
1137
1178
|
_ts_metadata2("design:type", Function),
|
|
1138
1179
|
_ts_metadata2("design:paramtypes", [
|
|
1139
1180
|
Object,
|
|
1140
1181
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
1141
1182
|
typeof RunRedisWorkerFn === "undefined" ? Object : RunRedisWorkerFn,
|
|
1142
|
-
Array
|
|
1183
|
+
Array,
|
|
1184
|
+
typeof ResolvedTenantAuth === "undefined" ? Object : ResolvedTenantAuth
|
|
1143
1185
|
])
|
|
1144
1186
|
], ThinWorkerBootstrap);
|
|
1187
|
+
async function tenantScheduleAnnouncement(options, tenantToken) {
|
|
1188
|
+
let tenant;
|
|
1189
|
+
try {
|
|
1190
|
+
tenant = tenantToken !== void 0 ? await resolveTenantToken2(tenantToken) : options.partition ?? "default";
|
|
1191
|
+
} catch (error) {
|
|
1192
|
+
console.warn(`[nestjs-durable] this worker announces no schedules: its tenantToken failed (${error instanceof Error ? error.message : String(error)})`);
|
|
1193
|
+
return {};
|
|
1194
|
+
}
|
|
1195
|
+
return {
|
|
1196
|
+
schedules: {
|
|
1197
|
+
tenant,
|
|
1198
|
+
items: (options.schedules ?? []).map(announcedSchedule)
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
}
|
|
1202
|
+
__name(tenantScheduleAnnouncement, "tenantScheduleAnnouncement");
|
|
1203
|
+
function announcedSchedule(s) {
|
|
1204
|
+
const item = {
|
|
1205
|
+
key: s.key,
|
|
1206
|
+
workflow: workflowName3(s.workflow)
|
|
1207
|
+
};
|
|
1208
|
+
if (s.input !== void 0) item.input = s.input;
|
|
1209
|
+
if (s.everyMs !== void 0) item.everyMs = s.everyMs;
|
|
1210
|
+
if (s.cron !== void 0) item.cron = s.cron;
|
|
1211
|
+
if (s.timezone !== void 0) item.timezone = s.timezone;
|
|
1212
|
+
if (s.paused === true) item.paused = true;
|
|
1213
|
+
if (s.overlap !== void 0) item.overlap = s.overlap;
|
|
1214
|
+
if (s.jitter !== void 0 && s.jitter > 0) item.jitterMs = s.jitter;
|
|
1215
|
+
return item;
|
|
1216
|
+
}
|
|
1217
|
+
__name(announcedSchedule, "announcedSchedule");
|
|
1145
1218
|
function thinWorkerProviders() {
|
|
1146
1219
|
return [
|
|
1147
1220
|
{
|
|
@@ -1231,7 +1304,7 @@ function unavailableRunGateway() {
|
|
|
1231
1304
|
__name(unavailableRunGateway, "unavailableRunGateway");
|
|
1232
1305
|
|
|
1233
1306
|
// src/durable.module.ts
|
|
1234
|
-
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
|
|
1307
|
+
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 WorkflowEngine7, sealDurableCopies, useDurableExecution } from "@dudousxd/nestjs-durable-core";
|
|
1235
1308
|
import { Inject as Inject9, Injectable as Injectable13, Module } from "@nestjs/common";
|
|
1236
1309
|
import { DiscoveryModule, ModuleRef as ModuleRef2 } from "@nestjs/core";
|
|
1237
1310
|
|
|
@@ -1316,7 +1389,7 @@ DurableStepRegistrar = _ts_decorate3([
|
|
|
1316
1389
|
], DurableStepRegistrar);
|
|
1317
1390
|
|
|
1318
1391
|
// src/entity.ts
|
|
1319
|
-
import { WorkflowEngine } from "@dudousxd/nestjs-durable-core";
|
|
1392
|
+
import { WorkflowEngine as WorkflowEngine2 } from "@dudousxd/nestjs-durable-core";
|
|
1320
1393
|
import { Injectable as Injectable4 } from "@nestjs/common";
|
|
1321
1394
|
import "reflect-metadata";
|
|
1322
1395
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
@@ -1399,7 +1472,7 @@ EntityService = _ts_decorate4([
|
|
|
1399
1472
|
Injectable4(),
|
|
1400
1473
|
_ts_metadata4("design:type", Function),
|
|
1401
1474
|
_ts_metadata4("design:paramtypes", [
|
|
1402
|
-
typeof
|
|
1475
|
+
typeof WorkflowEngine2 === "undefined" ? Object : WorkflowEngine2
|
|
1403
1476
|
])
|
|
1404
1477
|
], EntityService);
|
|
1405
1478
|
|
|
@@ -1567,7 +1640,7 @@ function inAppWorkerProviders() {
|
|
|
1567
1640
|
__name(inAppWorkerProviders, "inAppWorkerProviders");
|
|
1568
1641
|
|
|
1569
1642
|
// src/proxy-run-gateway.ts
|
|
1570
|
-
import { SUMMARY_CHILD_LIMIT, childIdsOf, pageFan, resolveTenantToken as
|
|
1643
|
+
import { SUMMARY_CHILD_LIMIT, childIdsOf, pageFan, resolveTenantToken as resolveTenantToken3, scopeTenantQuery, summarizeTimeline, tenantVisible } from "@dudousxd/nestjs-durable-core";
|
|
1571
1644
|
import { Injectable as Injectable6 } from "@nestjs/common";
|
|
1572
1645
|
|
|
1573
1646
|
// src/run-request-responder.ts
|
|
@@ -2180,7 +2253,7 @@ var ProxyRunGateway = class {
|
|
|
2180
2253
|
request(body) {
|
|
2181
2254
|
const source = this.tenantToken;
|
|
2182
2255
|
if (typeof source !== "function") return this.send(source ?? this.tenant, body);
|
|
2183
|
-
return
|
|
2256
|
+
return resolveTenantToken3(source).then((tenant) => this.send(tenant, body));
|
|
2184
2257
|
}
|
|
2185
2258
|
send(tenant, body) {
|
|
2186
2259
|
return new Promise((resolve, reject) => {
|
|
@@ -2734,7 +2807,7 @@ RetentionPoller = _ts_decorate8([
|
|
|
2734
2807
|
], RetentionPoller);
|
|
2735
2808
|
|
|
2736
2809
|
// src/store-run-gateway.ts
|
|
2737
|
-
import { LIFECYCLE_REGISTRY_WORKFLOW, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL2, SUMMARY_CHILD_LIMIT as SUMMARY_CHILD_LIMIT2, WorkflowEngine as
|
|
2810
|
+
import { LIFECYCLE_REGISTRY_WORKFLOW, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL2, SUMMARY_CHILD_LIMIT as SUMMARY_CHILD_LIMIT2, WorkflowEngine as WorkflowEngine3, 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";
|
|
2738
2811
|
import { Inject as Inject6, Injectable as Injectable9 } from "@nestjs/common";
|
|
2739
2812
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
2740
2813
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3147,7 +3220,7 @@ StoreRunGateway = _ts_decorate9([
|
|
|
3147
3220
|
_ts_metadata9("design:type", Function),
|
|
3148
3221
|
_ts_metadata9("design:paramtypes", [
|
|
3149
3222
|
typeof StateStore === "undefined" ? Object : StateStore,
|
|
3150
|
-
typeof
|
|
3223
|
+
typeof WorkflowEngine3 === "undefined" ? Object : WorkflowEngine3
|
|
3151
3224
|
])
|
|
3152
3225
|
], StoreRunGateway);
|
|
3153
3226
|
|
|
@@ -3194,7 +3267,7 @@ var TenantEventRepublisher = class {
|
|
|
3194
3267
|
|
|
3195
3268
|
// src/timer-poller.ts
|
|
3196
3269
|
import * as durableCore from "@dudousxd/nestjs-durable-core";
|
|
3197
|
-
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL6, WorkflowEngine as
|
|
3270
|
+
import { ANNOUNCED_SCHEDULE_TAG, DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL6, WorkflowEngine as WorkflowEngine4, runSchedules, workflowName as workflowName4 } from "@dudousxd/nestjs-durable-core";
|
|
3198
3271
|
import { Inject as Inject7, Injectable as Injectable10, Optional as Optional3 } from "@nestjs/common";
|
|
3199
3272
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
3200
3273
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3245,13 +3318,15 @@ var TimerPoller = class {
|
|
|
3245
3318
|
endWait;
|
|
3246
3319
|
/** When the owed-lifecycle listing last succeeded (see {@link owedSweepDue}). */
|
|
3247
3320
|
owedSweptAt;
|
|
3321
|
+
/** When the tenant schedule announcements were last reconciled (see {@link announcedSchedules}). */
|
|
3322
|
+
announcedSyncedAt;
|
|
3248
3323
|
constructor(engine, options, leases = new SweepLeases()) {
|
|
3249
3324
|
this.engine = engine;
|
|
3250
3325
|
this.options = options;
|
|
3251
3326
|
this.leases = leases;
|
|
3252
3327
|
}
|
|
3253
3328
|
async onApplicationBootstrap() {
|
|
3254
|
-
for (const s of this.options.schedules ?? [])
|
|
3329
|
+
for (const s of this.options.schedules ?? []) workflowName4(s.workflow);
|
|
3255
3330
|
if (!isDrivingOperator(this.options)) return;
|
|
3256
3331
|
this.engine.consumeRuns?.();
|
|
3257
3332
|
this.unsubscribeEnqueued = this.engine.onEnqueued((runId) => {
|
|
@@ -3334,7 +3409,8 @@ var TimerPoller = class {
|
|
|
3334
3409
|
try {
|
|
3335
3410
|
const now = Date.now();
|
|
3336
3411
|
const stored = await this.engine.nextDueAt(now + wait, {
|
|
3337
|
-
persistedSchedules: this.options.persistedSchedules === true
|
|
3412
|
+
persistedSchedules: this.options.persistedSchedules === true,
|
|
3413
|
+
announcedSchedules: this.announcedSchedules() !== void 0
|
|
3338
3414
|
});
|
|
3339
3415
|
const schedules = this.options.schedules;
|
|
3340
3416
|
const scheduled = schedules && schedules.length > 0 && nextScheduleFireAt2 ? nextScheduleFireAt2(this.engine, schedules, now) : void 0;
|
|
@@ -3351,6 +3427,22 @@ var TimerPoller = class {
|
|
|
3351
3427
|
}
|
|
3352
3428
|
}
|
|
3353
3429
|
/**
|
|
3430
|
+
* The tenant schedule adoption settings when it is on (see
|
|
3431
|
+
* {@link DurableModuleOptions.announcedSchedules}), else undefined: off by option, on a core
|
|
3432
|
+
* without it, or on a store that does not persist schedules.
|
|
3433
|
+
*/
|
|
3434
|
+
announcedSchedules() {
|
|
3435
|
+
const option = this.options.announcedSchedules;
|
|
3436
|
+
if (option === false) return void 0;
|
|
3437
|
+
if (typeof this.engine.syncAnnouncedSchedules !== "function") return void 0;
|
|
3438
|
+
if (this.engine.schedules?.supported !== true) return void 0;
|
|
3439
|
+
const settings = typeof option === "object" ? option : {};
|
|
3440
|
+
return {
|
|
3441
|
+
syncMs: settings.syncMs ?? 15e3,
|
|
3442
|
+
graceMs: settings.graceMs
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
/**
|
|
3354
3446
|
* Whether this poll lists the owed lifecycle runs: until a sweep that listed them succeeded, then
|
|
3355
3447
|
* once per `owedLifecycleSweepMs` (a clock that went back lists them again).
|
|
3356
3448
|
*/
|
|
@@ -3433,8 +3525,27 @@ var TimerPoller = class {
|
|
|
3433
3525
|
if (schedules && schedules.length > 0) {
|
|
3434
3526
|
note(await this.sweep("schedules", () => runSchedules(this.engine, schedules, Date.now())));
|
|
3435
3527
|
}
|
|
3528
|
+
const announced = this.announcedSchedules();
|
|
3529
|
+
if (announced) {
|
|
3530
|
+
const at = Date.now();
|
|
3531
|
+
const last = this.announcedSyncedAt;
|
|
3532
|
+
if (last === void 0 || at < last || at - last >= announced.syncMs) {
|
|
3533
|
+
await this.sweep("announcedSchedules", () => this.leases.run("announced-schedules", async () => {
|
|
3534
|
+
await this.engine.syncAnnouncedSchedules({
|
|
3535
|
+
...announced.graceMs !== void 0 ? {
|
|
3536
|
+
graceMs: announced.graceMs
|
|
3537
|
+
} : {}
|
|
3538
|
+
});
|
|
3539
|
+
this.announcedSyncedAt = at;
|
|
3540
|
+
}));
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3436
3543
|
if (this.options.persistedSchedules) {
|
|
3437
3544
|
note(await this.sweep("persistedSchedules", () => this.engine.schedules.tick()));
|
|
3545
|
+
} else if (announced) {
|
|
3546
|
+
note(await this.sweep("announcedScheduleFires", () => this.engine.schedules.tick(Date.now(), {
|
|
3547
|
+
tag: ANNOUNCED_SCHEDULE_TAG
|
|
3548
|
+
})));
|
|
3438
3549
|
}
|
|
3439
3550
|
return worked;
|
|
3440
3551
|
}
|
|
@@ -3454,19 +3565,14 @@ TimerPoller = _ts_decorate10([
|
|
|
3454
3565
|
_ts_param7(2, Optional3()),
|
|
3455
3566
|
_ts_metadata10("design:type", Function),
|
|
3456
3567
|
_ts_metadata10("design:paramtypes", [
|
|
3457
|
-
typeof
|
|
3568
|
+
typeof WorkflowEngine4 === "undefined" ? Object : WorkflowEngine4,
|
|
3458
3569
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
3459
3570
|
typeof SweepLeases === "undefined" ? Object : SweepLeases
|
|
3460
3571
|
])
|
|
3461
3572
|
], TimerPoller);
|
|
3462
3573
|
|
|
3463
|
-
// src/tokens.ts
|
|
3464
|
-
import { RunGateway } from "@dudousxd/nestjs-durable-core";
|
|
3465
|
-
var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
3466
|
-
var RUN_GATEWAY = RunGateway;
|
|
3467
|
-
|
|
3468
3574
|
// src/workflow.registrar.ts
|
|
3469
|
-
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL7, RemoteWorkflowExecutor, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL3, WorkflowEngine as
|
|
3575
|
+
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL7, RemoteWorkflowExecutor, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL3, WorkflowEngine as WorkflowEngine5, bindWorkflowClass as bindWorkflowClass2, sanitizeQueueToken, tenantGroup, workflowName as workflowName5 } from "@dudousxd/nestjs-durable-core";
|
|
3470
3576
|
import { Inject as Inject8, Injectable as Injectable11 } from "@nestjs/common";
|
|
3471
3577
|
import { DiscoveryService as DiscoveryService4, MetadataScanner as MetadataScanner4 } from "@nestjs/core";
|
|
3472
3578
|
|
|
@@ -3611,7 +3717,7 @@ var WorkflowRegistrar = class {
|
|
|
3611
3717
|
executor: new RemoteWorkflowExecutor(this.inAppWorker.transport, meta.name, this.inAppWorker.partition)
|
|
3612
3718
|
} : {}
|
|
3613
3719
|
});
|
|
3614
|
-
|
|
3720
|
+
bindWorkflowClass2(workflowCtor, {
|
|
3615
3721
|
start: /* @__PURE__ */ __name((name, input, runId, opts) => this.engine.start(name, input, runId, opts), "start"),
|
|
3616
3722
|
waitForRun: /* @__PURE__ */ __name((runId, opts) => this.engine.waitForRun(runId, opts), "waitForRun")
|
|
3617
3723
|
});
|
|
@@ -3626,7 +3732,7 @@ var WorkflowRegistrar = class {
|
|
|
3626
3732
|
});
|
|
3627
3733
|
deadLetterByWorkflow.set(meta.name, dlqName);
|
|
3628
3734
|
} else if (meta.deadLetterWorkflow) {
|
|
3629
|
-
deadLetterByWorkflow.set(meta.name,
|
|
3735
|
+
deadLetterByWorkflow.set(meta.name, workflowName5(meta.deadLetterWorkflow));
|
|
3630
3736
|
}
|
|
3631
3737
|
});
|
|
3632
3738
|
this.reportUnattributed(unattributed);
|
|
@@ -3674,7 +3780,7 @@ var WorkflowRegistrar = class {
|
|
|
3674
3780
|
* a `dlq:<runId>` id, so re-recovery never double-dispatches.
|
|
3675
3781
|
*/
|
|
3676
3782
|
installDeadLetterRouting(byWorkflow) {
|
|
3677
|
-
const fallback = this.options.deadLetterWorkflow ?
|
|
3783
|
+
const fallback = this.options.deadLetterWorkflow ? workflowName5(this.options.deadLetterWorkflow) : void 0;
|
|
3678
3784
|
if (byWorkflow.size === 0 && !fallback) return;
|
|
3679
3785
|
this.engine.onDead((run) => {
|
|
3680
3786
|
const target = byWorkflow.get(run.workflow) ?? fallback;
|
|
@@ -3706,7 +3812,7 @@ WorkflowRegistrar = _ts_decorate11([
|
|
|
3706
3812
|
_ts_metadata11("design:paramtypes", [
|
|
3707
3813
|
typeof DiscoveryService4 === "undefined" ? Object : DiscoveryService4,
|
|
3708
3814
|
typeof MetadataScanner4 === "undefined" ? Object : MetadataScanner4,
|
|
3709
|
-
typeof
|
|
3815
|
+
typeof WorkflowEngine5 === "undefined" ? Object : WorkflowEngine5,
|
|
3710
3816
|
Object,
|
|
3711
3817
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
3712
3818
|
Object
|
|
@@ -3715,7 +3821,7 @@ WorkflowRegistrar = _ts_decorate11([
|
|
|
3715
3821
|
|
|
3716
3822
|
// src/workflow.service.ts
|
|
3717
3823
|
import { randomUUID } from "node:crypto";
|
|
3718
|
-
import { WorkflowEngine as
|
|
3824
|
+
import { WorkflowEngine as WorkflowEngine6 } from "@dudousxd/nestjs-durable-core";
|
|
3719
3825
|
import { Injectable as Injectable12 } from "@nestjs/common";
|
|
3720
3826
|
function _ts_decorate12(decorators, target, key, desc) {
|
|
3721
3827
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -3806,7 +3912,7 @@ WorkflowService = _ts_decorate12([
|
|
|
3806
3912
|
Injectable12(),
|
|
3807
3913
|
_ts_metadata12("design:type", Function),
|
|
3808
3914
|
_ts_metadata12("design:paramtypes", [
|
|
3809
|
-
typeof
|
|
3915
|
+
typeof WorkflowEngine6 === "undefined" ? Object : WorkflowEngine6
|
|
3810
3916
|
])
|
|
3811
3917
|
], WorkflowService);
|
|
3812
3918
|
|
|
@@ -3983,7 +4089,6 @@ function resolveTopologyPreset(options) {
|
|
|
3983
4089
|
};
|
|
3984
4090
|
}
|
|
3985
4091
|
__name(resolveTopologyPreset, "resolveTopologyPreset");
|
|
3986
|
-
var TENANT_AUTH = Symbol("nestjs-durable:tenant-auth");
|
|
3987
4092
|
var RunGatewayBootstrap = class RunGatewayBootstrap2 {
|
|
3988
4093
|
static {
|
|
3989
4094
|
__name(this, "RunGatewayBootstrap");
|
|
@@ -4042,7 +4147,7 @@ RunGatewayBootstrap = _ts_decorate13([
|
|
|
4042
4147
|
_ts_param9(5, Inject9(TENANT_AUTH)),
|
|
4043
4148
|
_ts_metadata13("design:type", Function),
|
|
4044
4149
|
_ts_metadata13("design:paramtypes", [
|
|
4045
|
-
typeof
|
|
4150
|
+
typeof WorkflowEngine7 === "undefined" ? Object : WorkflowEngine7,
|
|
4046
4151
|
Object,
|
|
4047
4152
|
typeof RunGateway2 === "undefined" ? Object : RunGateway2,
|
|
4048
4153
|
Object,
|
|
@@ -4165,7 +4270,7 @@ var DurableModule = class _DurableModule {
|
|
|
4165
4270
|
// Shared token, bound EXACTLY once: a real engine for the operator role, or a store-less
|
|
4166
4271
|
// `DurableStartClient` facade for a thin worker (no `store`) — either way, `WorkflowService`
|
|
4167
4272
|
// and app code call `engine.start(...)` unchanged.
|
|
4168
|
-
provide:
|
|
4273
|
+
provide: WorkflowEngine7,
|
|
4169
4274
|
useFactory: /* @__PURE__ */ __name(async (options, store, transport, moduleRef, auth) => {
|
|
4170
4275
|
if (options.store === void 0) {
|
|
4171
4276
|
return new DurableStartClient({
|
|
@@ -4192,7 +4297,7 @@ var DurableModule = class _DurableModule {
|
|
|
4192
4297
|
if (t) deferTransportConsumers(t);
|
|
4193
4298
|
}
|
|
4194
4299
|
}
|
|
4195
|
-
const engine = new
|
|
4300
|
+
const engine = new WorkflowEngine7({
|
|
4196
4301
|
store,
|
|
4197
4302
|
transport: transport ?? void 0,
|
|
4198
4303
|
transports: options.transports,
|
|
@@ -4272,7 +4377,7 @@ var DurableModule = class _DurableModule {
|
|
|
4272
4377
|
inject: [
|
|
4273
4378
|
DURABLE_OPTIONS_CANONICAL8,
|
|
4274
4379
|
STATE_STORE_CANONICAL4,
|
|
4275
|
-
|
|
4380
|
+
WorkflowEngine7,
|
|
4276
4381
|
TENANT_AUTH,
|
|
4277
4382
|
ModuleRef2
|
|
4278
4383
|
]
|
|
@@ -4289,7 +4394,7 @@ var DurableModule = class _DurableModule {
|
|
|
4289
4394
|
exports: [
|
|
4290
4395
|
WorkflowService,
|
|
4291
4396
|
EntityService,
|
|
4292
|
-
|
|
4397
|
+
WorkflowEngine7,
|
|
4293
4398
|
STATE_STORE,
|
|
4294
4399
|
STATE_STORE_CANONICAL4,
|
|
4295
4400
|
TRANSPORT,
|
|
@@ -4305,7 +4410,7 @@ DurableModule = _ts_decorate13([
|
|
|
4305
4410
|
], DurableModule);
|
|
4306
4411
|
|
|
4307
4412
|
// src/federated-app-gateway.ts
|
|
4308
|
-
import { WorkflowEngine as
|
|
4413
|
+
import { WorkflowEngine as WorkflowEngine8 } from "@dudousxd/nestjs-durable-core";
|
|
4309
4414
|
var FederatedAppGateway = class {
|
|
4310
4415
|
static {
|
|
4311
4416
|
__name(this, "FederatedAppGateway");
|
|
@@ -4320,7 +4425,7 @@ var FederatedAppGateway = class {
|
|
|
4320
4425
|
tailing = false;
|
|
4321
4426
|
constructor(options) {
|
|
4322
4427
|
this.options = options;
|
|
4323
|
-
this.reads = new StoreRunGateway(options.store, new
|
|
4428
|
+
this.reads = new StoreRunGateway(options.store, new WorkflowEngine8({
|
|
4324
4429
|
store: options.store
|
|
4325
4430
|
}));
|
|
4326
4431
|
this.timeoutMs = options.timeoutMs ?? 1e4;
|
|
@@ -4565,7 +4670,7 @@ function federatedAppGateway(options) {
|
|
|
4565
4670
|
__name(federatedAppGateway, "federatedAppGateway");
|
|
4566
4671
|
|
|
4567
4672
|
// src/index.ts
|
|
4568
|
-
import { DuplicateDurableCopyError, hmacTenantVerifier, LIFECYCLE_PENDING_TAG, lifecycleRunId, lifecycleSourceOf as lifecycleSourceOf2, prevCronFireMs, readSearchAttributes as readSearchAttributes2, RunGateway as RunGateway3, runCompletedEvent as runCompletedEvent2, runFailedEvent as runFailedEvent2, runSchedules as runSchedules2, scheduledRunId, scheduleRunIdAt, signTenantToken, triggeredRunsOf, WorkflowEngine as
|
|
4673
|
+
import { DuplicateDurableCopyError, hmacTenantVerifier, LIFECYCLE_PENDING_TAG, lifecycleRunId, lifecycleSourceOf as lifecycleSourceOf2, prevCronFireMs, readSearchAttributes as readSearchAttributes2, RunGateway as RunGateway3, runCompletedEvent as runCompletedEvent2, runFailedEvent as runFailedEvent2, runSchedules as runSchedules2, scheduledRunId, scheduleRunIdAt, signTenantToken, triggeredRunsOf, WorkflowEngine as WorkflowEngine9 } from "@dudousxd/nestjs-durable-core";
|
|
4569
4674
|
export {
|
|
4570
4675
|
BAD_RUN_REQUEST,
|
|
4571
4676
|
CONTEXT_ACCESSOR,
|
|
@@ -4606,6 +4711,7 @@ export {
|
|
|
4606
4711
|
Step,
|
|
4607
4712
|
StepInterceptor,
|
|
4608
4713
|
StoreRunGateway,
|
|
4714
|
+
TENANT_AUTH,
|
|
4609
4715
|
TENANT_REPUBLISH_MAX_LIMIT,
|
|
4610
4716
|
TenantEventRepublisher,
|
|
4611
4717
|
ThinStepRegistrar,
|
|
@@ -4614,7 +4720,7 @@ export {
|
|
|
4614
4720
|
UNSUPPORTED_RUN_REQUEST,
|
|
4615
4721
|
WORKFLOW_METADATA,
|
|
4616
4722
|
Workflow,
|
|
4617
|
-
|
|
4723
|
+
WorkflowEngine9 as WorkflowEngine,
|
|
4618
4724
|
WorkflowService,
|
|
4619
4725
|
attributesOf,
|
|
4620
4726
|
entityConfigFor,
|
|
@@ -4641,6 +4747,7 @@ export {
|
|
|
4641
4747
|
scheduleRunIdAt,
|
|
4642
4748
|
scheduledRunId,
|
|
4643
4749
|
signTenantToken,
|
|
4750
|
+
tenantScheduleAnnouncement,
|
|
4644
4751
|
thinWorkerProviders,
|
|
4645
4752
|
triggeredRunsOf,
|
|
4646
4753
|
unavailableRunGateway
|