@dudousxd/nestjs-durable 0.33.0 → 0.34.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 +104 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -2
- package/dist/index.d.ts +74 -2
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -56,8 +56,9 @@ __export(index_exports, {
|
|
|
56
56
|
ThinWorkflowRegistrar: () => ThinWorkflowRegistrar,
|
|
57
57
|
WORKFLOW_METADATA: () => WORKFLOW_METADATA,
|
|
58
58
|
Workflow: () => Workflow,
|
|
59
|
-
WorkflowEngine: () =>
|
|
59
|
+
WorkflowEngine: () => import_nestjs_durable_core14.WorkflowEngine,
|
|
60
60
|
WorkflowService: () => WorkflowService,
|
|
61
|
+
attributesOf: () => attributesOf,
|
|
61
62
|
entityConfigFor: () => entityConfigFor,
|
|
62
63
|
getDurableStepMeta: () => getDurableStepMeta,
|
|
63
64
|
getEntityMeta: () => getEntityMeta,
|
|
@@ -68,12 +69,15 @@ __export(index_exports, {
|
|
|
68
69
|
isDrivingOperator: () => isDrivingOperator,
|
|
69
70
|
isOperatorRole: () => isOperatorRole,
|
|
70
71
|
isStepInterceptor: () => isStepInterceptor,
|
|
71
|
-
readSearchAttributes: () =>
|
|
72
|
+
readSearchAttributes: () => import_nestjs_durable_core14.readSearchAttributes,
|
|
72
73
|
thinWorkerProviders: () => thinWorkerProviders,
|
|
73
74
|
unavailableRunGateway: () => unavailableRunGateway
|
|
74
75
|
});
|
|
75
76
|
module.exports = __toCommonJS(index_exports);
|
|
76
77
|
|
|
78
|
+
// src/attributes-of.ts
|
|
79
|
+
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
80
|
+
|
|
77
81
|
// src/decorators.ts
|
|
78
82
|
var import_nestjs_durable_core = require("@dudousxd/nestjs-durable-core");
|
|
79
83
|
var import_reflect_metadata = require("reflect-metadata");
|
|
@@ -181,9 +185,22 @@ function getOnEvents(meta, target) {
|
|
|
181
185
|
}
|
|
182
186
|
__name(getOnEvents, "getOnEvents");
|
|
183
187
|
|
|
188
|
+
// src/attributes-of.ts
|
|
189
|
+
function attributesOf(workflow, run) {
|
|
190
|
+
const meta = getWorkflowMeta(workflow);
|
|
191
|
+
if (!meta) {
|
|
192
|
+
throw new Error(`attributesOf: ${workflow.name} is not a @Workflow class \u2014 is it decorated with @Workflow({ name, searchAttributes })?`);
|
|
193
|
+
}
|
|
194
|
+
if (!meta.searchAttributes) {
|
|
195
|
+
throw new Error(`attributesOf: workflow '${meta.name}' declares no searchAttributes schema \u2014 reading attributes by class requires the workflow to declare its schema: @Workflow({ name: '${meta.name}', searchAttributes: mySchema }).`);
|
|
196
|
+
}
|
|
197
|
+
return (0, import_nestjs_durable_core2.readSearchAttributes)(meta.searchAttributes, run);
|
|
198
|
+
}
|
|
199
|
+
__name(attributesOf, "attributesOf");
|
|
200
|
+
|
|
184
201
|
// src/durable-start-client.ts
|
|
185
202
|
var import_durable_worker = require("@dudousxd/durable-worker");
|
|
186
|
-
var
|
|
203
|
+
var import_nestjs_durable_core3 = require("@dudousxd/nestjs-durable-core");
|
|
187
204
|
var import_common = require("@nestjs/common");
|
|
188
205
|
function _ts_decorate(decorators, target, key, desc) {
|
|
189
206
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -209,7 +226,7 @@ var DurableStartClient = class {
|
|
|
209
226
|
this.tenant = options.partition ?? "default";
|
|
210
227
|
}
|
|
211
228
|
async start(workflow, input, runId = globalThis.crypto.randomUUID(), opts) {
|
|
212
|
-
const name = (0,
|
|
229
|
+
const name = (0, import_nestjs_durable_core3.workflowName)(workflow);
|
|
213
230
|
await (0, import_durable_worker.startRun)(this.options.connection, {
|
|
214
231
|
tenant: this.tenant,
|
|
215
232
|
workflow: name,
|
|
@@ -278,7 +295,7 @@ __name(tenantUnsupported, "tenantUnsupported");
|
|
|
278
295
|
|
|
279
296
|
// src/durable-worker.module.ts
|
|
280
297
|
var import_durable_worker2 = require("@dudousxd/durable-worker");
|
|
281
|
-
var
|
|
298
|
+
var import_nestjs_durable_core4 = require("@dudousxd/nestjs-durable-core");
|
|
282
299
|
var import_common2 = require("@nestjs/common");
|
|
283
300
|
var import_core = require("@nestjs/core");
|
|
284
301
|
|
|
@@ -362,7 +379,7 @@ var ThinWorkflowRegistrar = class {
|
|
|
362
379
|
};
|
|
363
380
|
ThinWorkflowRegistrar = _ts_decorate2([
|
|
364
381
|
(0, import_common2.Injectable)(),
|
|
365
|
-
_ts_param(2, (0, import_common2.Inject)(
|
|
382
|
+
_ts_param(2, (0, import_common2.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL)),
|
|
366
383
|
_ts_metadata2("design:type", Function),
|
|
367
384
|
_ts_metadata2("design:paramtypes", [
|
|
368
385
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
@@ -391,7 +408,7 @@ var ThinStepRegistrar = class {
|
|
|
391
408
|
};
|
|
392
409
|
ThinStepRegistrar = _ts_decorate2([
|
|
393
410
|
(0, import_common2.Injectable)(),
|
|
394
|
-
_ts_param(3, (0, import_common2.Inject)(
|
|
411
|
+
_ts_param(3, (0, import_common2.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL)),
|
|
395
412
|
_ts_metadata2("design:type", Function),
|
|
396
413
|
_ts_metadata2("design:paramtypes", [
|
|
397
414
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
@@ -443,7 +460,7 @@ var ThinWorkerBootstrap = class {
|
|
|
443
460
|
};
|
|
444
461
|
ThinWorkerBootstrap = _ts_decorate2([
|
|
445
462
|
(0, import_common2.Injectable)(),
|
|
446
|
-
_ts_param(1, (0, import_common2.Inject)(
|
|
463
|
+
_ts_param(1, (0, import_common2.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL)),
|
|
447
464
|
_ts_param(2, (0, import_common2.Inject)(RUN_REDIS_WORKER)),
|
|
448
465
|
_ts_param(3, (0, import_common2.Inject)(DURABLE_WORKER_RUNNERS)),
|
|
449
466
|
_ts_metadata2("design:type", Function),
|
|
@@ -469,7 +486,7 @@ function thinWorkerProviders() {
|
|
|
469
486
|
workflowGroup: options.partition ?? ""
|
|
470
487
|
}), "useFactory"),
|
|
471
488
|
inject: [
|
|
472
|
-
|
|
489
|
+
import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL
|
|
473
490
|
]
|
|
474
491
|
},
|
|
475
492
|
{
|
|
@@ -533,12 +550,12 @@ function unavailableRunGateway() {
|
|
|
533
550
|
__name(unavailableRunGateway, "unavailableRunGateway");
|
|
534
551
|
|
|
535
552
|
// src/durable.module.ts
|
|
536
|
-
var
|
|
553
|
+
var import_nestjs_durable_core13 = require("@dudousxd/nestjs-durable-core");
|
|
537
554
|
var import_common12 = require("@nestjs/common");
|
|
538
555
|
var import_core5 = require("@nestjs/core");
|
|
539
556
|
|
|
540
557
|
// src/durable-step.registrar.ts
|
|
541
|
-
var
|
|
558
|
+
var import_nestjs_durable_core5 = require("@dudousxd/nestjs-durable-core");
|
|
542
559
|
var import_common3 = require("@nestjs/common");
|
|
543
560
|
var import_core2 = require("@nestjs/core");
|
|
544
561
|
|
|
@@ -597,8 +614,8 @@ var DurableStepRegistrar = class {
|
|
|
597
614
|
};
|
|
598
615
|
DurableStepRegistrar = _ts_decorate3([
|
|
599
616
|
(0, import_common3.Injectable)(),
|
|
600
|
-
_ts_param2(2, (0, import_common3.Inject)(
|
|
601
|
-
_ts_param2(3, (0, import_common3.Inject)(
|
|
617
|
+
_ts_param2(2, (0, import_common3.Inject)(import_nestjs_durable_core5.TRANSPORT_CANONICAL)),
|
|
618
|
+
_ts_param2(3, (0, import_common3.Inject)(import_nestjs_durable_core5.DURABLE_OPTIONS_CANONICAL)),
|
|
602
619
|
_ts_metadata3("design:type", Function),
|
|
603
620
|
_ts_metadata3("design:paramtypes", [
|
|
604
621
|
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
@@ -609,7 +626,7 @@ DurableStepRegistrar = _ts_decorate3([
|
|
|
609
626
|
], DurableStepRegistrar);
|
|
610
627
|
|
|
611
628
|
// src/entity.ts
|
|
612
|
-
var
|
|
629
|
+
var import_nestjs_durable_core6 = require("@dudousxd/nestjs-durable-core");
|
|
613
630
|
var import_common4 = require("@nestjs/common");
|
|
614
631
|
var import_reflect_metadata2 = require("reflect-metadata");
|
|
615
632
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
@@ -683,13 +700,13 @@ EntityService = _ts_decorate4([
|
|
|
683
700
|
(0, import_common4.Injectable)(),
|
|
684
701
|
_ts_metadata4("design:type", Function),
|
|
685
702
|
_ts_metadata4("design:paramtypes", [
|
|
686
|
-
typeof
|
|
703
|
+
typeof import_nestjs_durable_core6.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core6.WorkflowEngine
|
|
687
704
|
])
|
|
688
705
|
], EntityService);
|
|
689
706
|
|
|
690
707
|
// src/in-app-worker.ts
|
|
691
708
|
var import_durable_worker3 = require("@dudousxd/durable-worker");
|
|
692
|
-
var
|
|
709
|
+
var import_nestjs_durable_core7 = require("@dudousxd/nestjs-durable-core");
|
|
693
710
|
var import_common5 = require("@nestjs/common");
|
|
694
711
|
var import_core3 = require("@nestjs/core");
|
|
695
712
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
@@ -782,7 +799,7 @@ var InAppWorkerBootstrap = class {
|
|
|
782
799
|
};
|
|
783
800
|
InAppWorkerBootstrap = _ts_decorate5([
|
|
784
801
|
(0, import_common5.Injectable)(),
|
|
785
|
-
_ts_param3(2, (0, import_common5.Inject)(
|
|
802
|
+
_ts_param3(2, (0, import_common5.Inject)(import_nestjs_durable_core7.DURABLE_OPTIONS_CANONICAL)),
|
|
786
803
|
_ts_param3(3, (0, import_common5.Inject)(IN_APP_WORKER_RUNTIME)),
|
|
787
804
|
_ts_param3(4, (0, import_common5.Inject)(IN_APP_RUN_REDIS_WORKER)),
|
|
788
805
|
_ts_param3(5, (0, import_common5.Inject)(IN_APP_WORKER_RUNNERS)),
|
|
@@ -802,8 +819,8 @@ function inAppWorkerProviders() {
|
|
|
802
819
|
provide: IN_APP_WORKER_BINDING,
|
|
803
820
|
useFactory: /* @__PURE__ */ __name((transport, options) => inAppWorkerBinding(transport, options), "useFactory"),
|
|
804
821
|
inject: [
|
|
805
|
-
|
|
806
|
-
|
|
822
|
+
import_nestjs_durable_core7.TRANSPORT_CANONICAL,
|
|
823
|
+
import_nestjs_durable_core7.DURABLE_OPTIONS_CANONICAL
|
|
807
824
|
]
|
|
808
825
|
},
|
|
809
826
|
{
|
|
@@ -819,7 +836,7 @@ function inAppWorkerProviders() {
|
|
|
819
836
|
workflowGroup: options.partition ?? ""
|
|
820
837
|
}), "useFactory"),
|
|
821
838
|
inject: [
|
|
822
|
-
|
|
839
|
+
import_nestjs_durable_core7.DURABLE_OPTIONS_CANONICAL
|
|
823
840
|
]
|
|
824
841
|
},
|
|
825
842
|
{
|
|
@@ -986,7 +1003,7 @@ ProxyRunGateway = _ts_decorate6([
|
|
|
986
1003
|
], ProxyRunGateway);
|
|
987
1004
|
|
|
988
1005
|
// src/retention-poller.ts
|
|
989
|
-
var
|
|
1006
|
+
var import_nestjs_durable_core8 = require("@dudousxd/nestjs-durable-core");
|
|
990
1007
|
var import_common7 = require("@nestjs/common");
|
|
991
1008
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
992
1009
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1017,10 +1034,10 @@ function validateRetention(retention) {
|
|
|
1017
1034
|
if (policy.maxAge == null && policy.maxCount == null) {
|
|
1018
1035
|
throw new Error("durable retention: each policy must set maxAge and/or maxCount");
|
|
1019
1036
|
}
|
|
1020
|
-
if (policy.maxAge != null) (0,
|
|
1037
|
+
if (policy.maxAge != null) (0, import_nestjs_durable_core8.parseDuration)(policy.maxAge);
|
|
1021
1038
|
for (const status of policy.statuses) {
|
|
1022
|
-
if (!
|
|
1023
|
-
throw new Error(`durable retention: status "${status}" is not terminal; only ${
|
|
1039
|
+
if (!import_nestjs_durable_core8.TERMINAL_RUN_STATUSES.includes(status)) {
|
|
1040
|
+
throw new Error(`durable retention: status "${status}" is not terminal; only ${import_nestjs_durable_core8.TERMINAL_RUN_STATUSES.join(", ")} can be pruned`);
|
|
1024
1041
|
}
|
|
1025
1042
|
if (seen.has(status)) {
|
|
1026
1043
|
throw new Error(`durable retention: status "${status}" appears in more than one policy; status sets must be disjoint`);
|
|
@@ -1059,7 +1076,7 @@ var RetentionPoller = class {
|
|
|
1059
1076
|
return;
|
|
1060
1077
|
}
|
|
1061
1078
|
await this.sweep();
|
|
1062
|
-
const intervalMs = retention.sweepInterval != null ? (0,
|
|
1079
|
+
const intervalMs = retention.sweepInterval != null ? (0, import_nestjs_durable_core8.parseDuration)(retention.sweepInterval) : DEFAULT_SWEEP_INTERVAL_MS;
|
|
1063
1080
|
if (intervalMs > 0) {
|
|
1064
1081
|
this.timer = setInterval(() => void this.sweep(), intervalMs);
|
|
1065
1082
|
this.timer.unref?.();
|
|
@@ -1091,8 +1108,8 @@ var RetentionPoller = class {
|
|
|
1091
1108
|
};
|
|
1092
1109
|
RetentionPoller = _ts_decorate7([
|
|
1093
1110
|
(0, import_common7.Injectable)(),
|
|
1094
|
-
_ts_param4(0, (0, import_common7.Inject)(
|
|
1095
|
-
_ts_param4(1, (0, import_common7.Inject)(
|
|
1111
|
+
_ts_param4(0, (0, import_common7.Inject)(import_nestjs_durable_core8.STATE_STORE_CANONICAL)),
|
|
1112
|
+
_ts_param4(1, (0, import_common7.Inject)(import_nestjs_durable_core8.DURABLE_OPTIONS_CANONICAL)),
|
|
1096
1113
|
_ts_metadata7("design:type", Function),
|
|
1097
1114
|
_ts_metadata7("design:paramtypes", [
|
|
1098
1115
|
Object,
|
|
@@ -1226,7 +1243,7 @@ var RunRequestResponder = class {
|
|
|
1226
1243
|
};
|
|
1227
1244
|
|
|
1228
1245
|
// src/store-run-gateway.ts
|
|
1229
|
-
var
|
|
1246
|
+
var import_nestjs_durable_core9 = require("@dudousxd/nestjs-durable-core");
|
|
1230
1247
|
var import_common8 = require("@nestjs/common");
|
|
1231
1248
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
1232
1249
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1275,9 +1292,9 @@ var StoreRunGateway = class {
|
|
|
1275
1292
|
}
|
|
1276
1293
|
async listRuns(query) {
|
|
1277
1294
|
const runs = await this.store.listRuns(query);
|
|
1278
|
-
const waiterByRun = (0,
|
|
1295
|
+
const waiterByRun = (0, import_nestjs_durable_core9.indexWaitersByRun)(await this.store.listSignalWaiters(""));
|
|
1279
1296
|
return runs.map((run) => {
|
|
1280
|
-
const waiting = (0,
|
|
1297
|
+
const waiting = (0, import_nestjs_durable_core9.resolveRunWaiting)(run, waiterByRun);
|
|
1281
1298
|
return waiting ? {
|
|
1282
1299
|
...run,
|
|
1283
1300
|
waiting
|
|
@@ -1305,11 +1322,11 @@ var StoreRunGateway = class {
|
|
|
1305
1322
|
}),
|
|
1306
1323
|
this.store.listSignalWaiters("")
|
|
1307
1324
|
]);
|
|
1308
|
-
const waiterByRun = (0,
|
|
1325
|
+
const waiterByRun = (0, import_nestjs_durable_core9.indexWaitersByRun)(waiters);
|
|
1309
1326
|
const result = {};
|
|
1310
1327
|
for (const run of suspended) {
|
|
1311
1328
|
if (!idSet.has(run.id)) continue;
|
|
1312
|
-
const waiting = (0,
|
|
1329
|
+
const waiting = (0, import_nestjs_durable_core9.resolveRunWaiting)(run, waiterByRun);
|
|
1313
1330
|
if (waiting) result[run.id] = waiting;
|
|
1314
1331
|
}
|
|
1315
1332
|
return result;
|
|
@@ -1343,11 +1360,11 @@ var StoreRunGateway = class {
|
|
|
1343
1360
|
};
|
|
1344
1361
|
StoreRunGateway = _ts_decorate8([
|
|
1345
1362
|
(0, import_common8.Injectable)(),
|
|
1346
|
-
_ts_param5(0, (0, import_common8.Inject)(
|
|
1363
|
+
_ts_param5(0, (0, import_common8.Inject)(import_nestjs_durable_core9.STATE_STORE_CANONICAL)),
|
|
1347
1364
|
_ts_metadata8("design:type", Function),
|
|
1348
1365
|
_ts_metadata8("design:paramtypes", [
|
|
1349
1366
|
typeof StateStore === "undefined" ? Object : StateStore,
|
|
1350
|
-
typeof
|
|
1367
|
+
typeof import_nestjs_durable_core9.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core9.WorkflowEngine
|
|
1351
1368
|
])
|
|
1352
1369
|
], StoreRunGateway);
|
|
1353
1370
|
|
|
@@ -1393,7 +1410,7 @@ var TenantEventRepublisher = class {
|
|
|
1393
1410
|
};
|
|
1394
1411
|
|
|
1395
1412
|
// src/timer-poller.ts
|
|
1396
|
-
var
|
|
1413
|
+
var import_nestjs_durable_core10 = require("@dudousxd/nestjs-durable-core");
|
|
1397
1414
|
var import_common9 = require("@nestjs/common");
|
|
1398
1415
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
1399
1416
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1449,7 +1466,7 @@ var TimerPoller = class {
|
|
|
1449
1466
|
await this.engine.sweepTimeouts();
|
|
1450
1467
|
const schedules = this.options.schedules;
|
|
1451
1468
|
if (schedules && schedules.length > 0) {
|
|
1452
|
-
await (0,
|
|
1469
|
+
await (0, import_nestjs_durable_core10.runSchedules)(this.engine, schedules, Date.now());
|
|
1453
1470
|
}
|
|
1454
1471
|
} finally {
|
|
1455
1472
|
this.polling = false;
|
|
@@ -1458,10 +1475,10 @@ var TimerPoller = class {
|
|
|
1458
1475
|
};
|
|
1459
1476
|
TimerPoller = _ts_decorate9([
|
|
1460
1477
|
(0, import_common9.Injectable)(),
|
|
1461
|
-
_ts_param6(1, (0, import_common9.Inject)(
|
|
1478
|
+
_ts_param6(1, (0, import_common9.Inject)(import_nestjs_durable_core10.DURABLE_OPTIONS_CANONICAL)),
|
|
1462
1479
|
_ts_metadata9("design:type", Function),
|
|
1463
1480
|
_ts_metadata9("design:paramtypes", [
|
|
1464
|
-
typeof
|
|
1481
|
+
typeof import_nestjs_durable_core10.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core10.WorkflowEngine,
|
|
1465
1482
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
1466
1483
|
])
|
|
1467
1484
|
], TimerPoller);
|
|
@@ -1471,7 +1488,7 @@ var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
|
1471
1488
|
var RUN_GATEWAY = Symbol.for("nestjs-durable:run-gateway");
|
|
1472
1489
|
|
|
1473
1490
|
// src/workflow.registrar.ts
|
|
1474
|
-
var
|
|
1491
|
+
var import_nestjs_durable_core11 = require("@dudousxd/nestjs-durable-core");
|
|
1475
1492
|
var import_common10 = require("@nestjs/common");
|
|
1476
1493
|
var import_core4 = require("@nestjs/core");
|
|
1477
1494
|
|
|
@@ -1593,11 +1610,11 @@ var WorkflowRegistrar = class {
|
|
|
1593
1610
|
const validateInput = meta.validateInput ?? (meta.inputSchema ? classValidatorInput(meta.inputSchema) : void 0);
|
|
1594
1611
|
const eventBatch = meta.debounce ? {
|
|
1595
1612
|
mode: "debounce",
|
|
1596
|
-
windowMs: (0,
|
|
1613
|
+
windowMs: (0, import_nestjs_durable_core11.parseDuration)(meta.debounce)
|
|
1597
1614
|
} : meta.batch ? {
|
|
1598
1615
|
mode: "batch",
|
|
1599
1616
|
maxSize: meta.batch.maxSize,
|
|
1600
|
-
windowMs: (0,
|
|
1617
|
+
windowMs: (0, import_nestjs_durable_core11.parseDuration)(meta.batch.within)
|
|
1601
1618
|
} : void 0;
|
|
1602
1619
|
const workflowCtor = workflow.constructor;
|
|
1603
1620
|
this.engine.register(meta.name, meta.version, (ctx, input) => workflow.run(ctx, input), {
|
|
@@ -1618,11 +1635,11 @@ var WorkflowRegistrar = class {
|
|
|
1618
1635
|
// so a turn dispatched under the wrong token would never be consumed. Absent → the inline fast
|
|
1619
1636
|
// path (unchanged).
|
|
1620
1637
|
...this.inAppWorker ? {
|
|
1621
|
-
group: (0,
|
|
1622
|
-
executor: new
|
|
1638
|
+
group: (0, import_nestjs_durable_core11.tenantGroup)((0, import_nestjs_durable_core11.sanitizeQueueToken)(meta.name), this.inAppWorker.partition),
|
|
1639
|
+
executor: new import_nestjs_durable_core11.RemoteWorkflowExecutor(this.inAppWorker.transport, meta.name, this.inAppWorker.partition)
|
|
1623
1640
|
} : {}
|
|
1624
1641
|
});
|
|
1625
|
-
(0,
|
|
1642
|
+
(0, import_nestjs_durable_core11.bindWorkflowClass)(workflowCtor, {
|
|
1626
1643
|
start: /* @__PURE__ */ __name((name, input, runId, opts) => this.engine.start(name, input, runId, opts), "start"),
|
|
1627
1644
|
waitForRun: /* @__PURE__ */ __name((runId, opts) => this.engine.waitForRun(runId, opts), "waitForRun")
|
|
1628
1645
|
});
|
|
@@ -1635,7 +1652,7 @@ var WorkflowRegistrar = class {
|
|
|
1635
1652
|
this.engine.register(dlqName, meta.version, inline);
|
|
1636
1653
|
deadLetterByWorkflow.set(meta.name, dlqName);
|
|
1637
1654
|
} else if (meta.deadLetterWorkflow) {
|
|
1638
|
-
deadLetterByWorkflow.set(meta.name, (0,
|
|
1655
|
+
deadLetterByWorkflow.set(meta.name, (0, import_nestjs_durable_core11.workflowName)(meta.deadLetterWorkflow));
|
|
1639
1656
|
}
|
|
1640
1657
|
});
|
|
1641
1658
|
this.installDeadLetterRouting(deadLetterByWorkflow);
|
|
@@ -1657,7 +1674,7 @@ var WorkflowRegistrar = class {
|
|
|
1657
1674
|
* a `dlq:<runId>` id, so re-recovery never double-dispatches.
|
|
1658
1675
|
*/
|
|
1659
1676
|
installDeadLetterRouting(byWorkflow) {
|
|
1660
|
-
const fallback = this.options.deadLetterWorkflow ? (0,
|
|
1677
|
+
const fallback = this.options.deadLetterWorkflow ? (0, import_nestjs_durable_core11.workflowName)(this.options.deadLetterWorkflow) : void 0;
|
|
1661
1678
|
if (byWorkflow.size === 0 && !fallback) return;
|
|
1662
1679
|
this.engine.onDead((run) => {
|
|
1663
1680
|
const target = byWorkflow.get(run.workflow) ?? fallback;
|
|
@@ -1682,14 +1699,14 @@ var WorkflowRegistrar = class {
|
|
|
1682
1699
|
};
|
|
1683
1700
|
WorkflowRegistrar = _ts_decorate10([
|
|
1684
1701
|
(0, import_common10.Injectable)(),
|
|
1685
|
-
_ts_param7(3, (0, import_common10.Inject)(
|
|
1686
|
-
_ts_param7(4, (0, import_common10.Inject)(
|
|
1702
|
+
_ts_param7(3, (0, import_common10.Inject)(import_nestjs_durable_core11.STATE_STORE_CANONICAL)),
|
|
1703
|
+
_ts_param7(4, (0, import_common10.Inject)(import_nestjs_durable_core11.DURABLE_OPTIONS_CANONICAL)),
|
|
1687
1704
|
_ts_param7(5, (0, import_common10.Inject)(IN_APP_WORKER_BINDING)),
|
|
1688
1705
|
_ts_metadata10("design:type", Function),
|
|
1689
1706
|
_ts_metadata10("design:paramtypes", [
|
|
1690
1707
|
typeof import_core4.DiscoveryService === "undefined" ? Object : import_core4.DiscoveryService,
|
|
1691
1708
|
typeof import_core4.MetadataScanner === "undefined" ? Object : import_core4.MetadataScanner,
|
|
1692
|
-
typeof
|
|
1709
|
+
typeof import_nestjs_durable_core11.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core11.WorkflowEngine,
|
|
1693
1710
|
Object,
|
|
1694
1711
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
1695
1712
|
Object
|
|
@@ -1698,7 +1715,7 @@ WorkflowRegistrar = _ts_decorate10([
|
|
|
1698
1715
|
|
|
1699
1716
|
// src/workflow.service.ts
|
|
1700
1717
|
var import_node_crypto = require("crypto");
|
|
1701
|
-
var
|
|
1718
|
+
var import_nestjs_durable_core12 = require("@dudousxd/nestjs-durable-core");
|
|
1702
1719
|
var import_common11 = require("@nestjs/common");
|
|
1703
1720
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
1704
1721
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1745,6 +1762,10 @@ var WorkflowService = class {
|
|
|
1745
1762
|
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
|
|
1746
1763
|
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
1747
1764
|
* touched (resumed + started).
|
|
1765
|
+
*
|
|
1766
|
+
* Reliable by default: a publish that touches NOBODY (no live waiter, no subscriber) buffers ONE
|
|
1767
|
+
* copy so a LATER `waitForEvent(name, { match })` still consumes it instead of it being dropped —
|
|
1768
|
+
* see {@link WorkflowEngine.publishEvent}'s full semantics doc. Pass `opts.buffer: false` to opt out.
|
|
1748
1769
|
*/
|
|
1749
1770
|
publishEvent(name, payload, opts) {
|
|
1750
1771
|
return this.engine.publishEvent(name, payload, opts);
|
|
@@ -1754,7 +1775,7 @@ WorkflowService = _ts_decorate11([
|
|
|
1754
1775
|
(0, import_common11.Injectable)(),
|
|
1755
1776
|
_ts_metadata11("design:type", Function),
|
|
1756
1777
|
_ts_metadata11("design:paramtypes", [
|
|
1757
|
-
typeof
|
|
1778
|
+
typeof import_nestjs_durable_core12.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core12.WorkflowEngine
|
|
1758
1779
|
])
|
|
1759
1780
|
], WorkflowService);
|
|
1760
1781
|
|
|
@@ -1929,13 +1950,13 @@ var RunGatewayBootstrap = class RunGatewayBootstrap2 {
|
|
|
1929
1950
|
};
|
|
1930
1951
|
RunGatewayBootstrap = _ts_decorate12([
|
|
1931
1952
|
(0, import_common12.Injectable)(),
|
|
1932
|
-
_ts_param8(1, (0, import_common12.Inject)(
|
|
1953
|
+
_ts_param8(1, (0, import_common12.Inject)(import_nestjs_durable_core13.TRANSPORT_CANONICAL)),
|
|
1933
1954
|
_ts_param8(2, (0, import_common12.Inject)(RUN_GATEWAY)),
|
|
1934
|
-
_ts_param8(3, (0, import_common12.Inject)(
|
|
1935
|
-
_ts_param8(4, (0, import_common12.Inject)(
|
|
1955
|
+
_ts_param8(3, (0, import_common12.Inject)(import_nestjs_durable_core13.STATE_STORE_CANONICAL)),
|
|
1956
|
+
_ts_param8(4, (0, import_common12.Inject)(import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL)),
|
|
1936
1957
|
_ts_metadata12("design:type", Function),
|
|
1937
1958
|
_ts_metadata12("design:paramtypes", [
|
|
1938
|
-
typeof
|
|
1959
|
+
typeof import_nestjs_durable_core13.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core13.WorkflowEngine,
|
|
1939
1960
|
Object,
|
|
1940
1961
|
typeof RunGateway === "undefined" ? Object : RunGateway,
|
|
1941
1962
|
Object,
|
|
@@ -1949,13 +1970,13 @@ var DurableModule = class _DurableModule {
|
|
|
1949
1970
|
static forRoot(options) {
|
|
1950
1971
|
_DurableModule.assertValid(options);
|
|
1951
1972
|
return _DurableModule.build({
|
|
1952
|
-
provide:
|
|
1973
|
+
provide: import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL,
|
|
1953
1974
|
useValue: resolveTopology(options)
|
|
1954
1975
|
});
|
|
1955
1976
|
}
|
|
1956
1977
|
static forRootAsync(options) {
|
|
1957
1978
|
return _DurableModule.build({
|
|
1958
|
-
provide:
|
|
1979
|
+
provide: import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL,
|
|
1959
1980
|
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
1960
1981
|
const resolved = await options.useFactory(...args);
|
|
1961
1982
|
_DurableModule.assertValid(resolved);
|
|
@@ -1988,37 +2009,37 @@ var DurableModule = class _DurableModule {
|
|
|
1988
2009
|
providers: [
|
|
1989
2010
|
optionsProvider,
|
|
1990
2011
|
{
|
|
1991
|
-
provide:
|
|
2012
|
+
provide: import_nestjs_durable_core13.STATE_STORE_CANONICAL,
|
|
1992
2013
|
useFactory: /* @__PURE__ */ __name((options) => options.store !== void 0 ? scopedStore(options.store, options) : null, "useFactory"),
|
|
1993
2014
|
inject: [
|
|
1994
|
-
|
|
2015
|
+
import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL
|
|
1995
2016
|
]
|
|
1996
2017
|
},
|
|
1997
2018
|
{
|
|
1998
|
-
provide:
|
|
2019
|
+
provide: import_nestjs_durable_core13.TRANSPORT_CANONICAL,
|
|
1999
2020
|
useFactory: /* @__PURE__ */ __name((options) => options.transport ?? null, "useFactory"),
|
|
2000
2021
|
inject: [
|
|
2001
|
-
|
|
2022
|
+
import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL
|
|
2002
2023
|
]
|
|
2003
2024
|
},
|
|
2004
2025
|
// Legacy back-compat aliases (deprecated tokens still resolve to the same instances):
|
|
2005
2026
|
{
|
|
2006
|
-
provide:
|
|
2007
|
-
useExisting:
|
|
2027
|
+
provide: import_nestjs_durable_core13.STATE_STORE,
|
|
2028
|
+
useExisting: import_nestjs_durable_core13.STATE_STORE_CANONICAL
|
|
2008
2029
|
},
|
|
2009
2030
|
{
|
|
2010
|
-
provide:
|
|
2011
|
-
useExisting:
|
|
2031
|
+
provide: import_nestjs_durable_core13.TRANSPORT,
|
|
2032
|
+
useExisting: import_nestjs_durable_core13.TRANSPORT_CANONICAL
|
|
2012
2033
|
},
|
|
2013
2034
|
{
|
|
2014
|
-
provide:
|
|
2015
|
-
useExisting:
|
|
2035
|
+
provide: import_nestjs_durable_core13.DURABLE_OPTIONS,
|
|
2036
|
+
useExisting: import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL
|
|
2016
2037
|
},
|
|
2017
2038
|
{
|
|
2018
2039
|
// Shared token, bound EXACTLY once: a real engine for the operator role, or a store-less
|
|
2019
2040
|
// `DurableStartClient` facade for a thin worker (no `store`) — either way, `WorkflowService`
|
|
2020
2041
|
// and app code call `engine.start(...)` unchanged.
|
|
2021
|
-
provide:
|
|
2042
|
+
provide: import_nestjs_durable_core13.WorkflowEngine,
|
|
2022
2043
|
useFactory: /* @__PURE__ */ __name(async (options, store, transport, moduleRef) => {
|
|
2023
2044
|
if (options.store === void 0) {
|
|
2024
2045
|
return new DurableStartClient(options);
|
|
@@ -2031,7 +2052,7 @@ var DurableModule = class _DurableModule {
|
|
|
2031
2052
|
const context = options.context ?? (accessor ? () => carrierFromAccessor(accessor) : void 0);
|
|
2032
2053
|
const runtime = accessor ? await resolveContextRuntime() : void 0;
|
|
2033
2054
|
const rehydrate = runtime && ((carrier, fn) => carrier && Object.keys(carrier).length > 0 ? runtime.deserialize(carrier, fn) : fn());
|
|
2034
|
-
const engine = new
|
|
2055
|
+
const engine = new import_nestjs_durable_core13.WorkflowEngine({
|
|
2035
2056
|
store,
|
|
2036
2057
|
transport: transport ?? void 0,
|
|
2037
2058
|
transports: options.transports,
|
|
@@ -2062,9 +2083,9 @@ var DurableModule = class _DurableModule {
|
|
|
2062
2083
|
return engine;
|
|
2063
2084
|
}, "useFactory"),
|
|
2064
2085
|
inject: [
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2086
|
+
import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL,
|
|
2087
|
+
import_nestjs_durable_core13.STATE_STORE_CANONICAL,
|
|
2088
|
+
import_nestjs_durable_core13.TRANSPORT_CANONICAL,
|
|
2068
2089
|
import_core5.ModuleRef
|
|
2069
2090
|
]
|
|
2070
2091
|
},
|
|
@@ -2089,9 +2110,9 @@ var DurableModule = class _DurableModule {
|
|
|
2089
2110
|
return options.transport ? new ProxyRunGateway(options.transport, options.partition ?? "default", options.runGatewayTimeoutMs) : unavailableRunGateway();
|
|
2090
2111
|
}, "useFactory"),
|
|
2091
2112
|
inject: [
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2113
|
+
import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL,
|
|
2114
|
+
import_nestjs_durable_core13.STATE_STORE_CANONICAL,
|
|
2115
|
+
import_nestjs_durable_core13.WorkflowEngine
|
|
2095
2116
|
]
|
|
2096
2117
|
},
|
|
2097
2118
|
RunGatewayBootstrap,
|
|
@@ -2105,12 +2126,12 @@ var DurableModule = class _DurableModule {
|
|
|
2105
2126
|
exports: [
|
|
2106
2127
|
WorkflowService,
|
|
2107
2128
|
EntityService,
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2129
|
+
import_nestjs_durable_core13.WorkflowEngine,
|
|
2130
|
+
import_nestjs_durable_core13.STATE_STORE,
|
|
2131
|
+
import_nestjs_durable_core13.STATE_STORE_CANONICAL,
|
|
2132
|
+
import_nestjs_durable_core13.TRANSPORT,
|
|
2133
|
+
import_nestjs_durable_core13.TRANSPORT_CANONICAL,
|
|
2134
|
+
import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL,
|
|
2114
2135
|
RUN_GATEWAY
|
|
2115
2136
|
]
|
|
2116
2137
|
};
|
|
@@ -2121,7 +2142,7 @@ DurableModule = _ts_decorate12([
|
|
|
2121
2142
|
], DurableModule);
|
|
2122
2143
|
|
|
2123
2144
|
// src/index.ts
|
|
2124
|
-
var
|
|
2145
|
+
var import_nestjs_durable_core14 = require("@dudousxd/nestjs-durable-core");
|
|
2125
2146
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2126
2147
|
0 && (module.exports = {
|
|
2127
2148
|
CONTEXT_ACCESSOR,
|
|
@@ -2161,6 +2182,7 @@ var import_nestjs_durable_core13 = require("@dudousxd/nestjs-durable-core");
|
|
|
2161
2182
|
Workflow,
|
|
2162
2183
|
WorkflowEngine,
|
|
2163
2184
|
WorkflowService,
|
|
2185
|
+
attributesOf,
|
|
2164
2186
|
entityConfigFor,
|
|
2165
2187
|
getDurableStepMeta,
|
|
2166
2188
|
getEntityMeta,
|