@dudousxd/nestjs-durable 0.43.1 → 0.44.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 +243 -86
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -5
- package/dist/index.d.ts +31 -5
- package/dist/index.js +231 -91
- package/dist/index.js.map +1 -1
- package/package.json +14 -10
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
9
|
var __export = (target, all) => {
|
|
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
|
|
21
31
|
// src/index.ts
|
|
@@ -25,6 +35,7 @@ __export(index_exports, {
|
|
|
25
35
|
DEAD_LETTER_METADATA: () => DEAD_LETTER_METADATA,
|
|
26
36
|
DURABLE_STEP_METADATA: () => DURABLE_STEP_METADATA,
|
|
27
37
|
DURABLE_WORKER_RUNNERS: () => DURABLE_WORKER_RUNNERS,
|
|
38
|
+
DURABLE_WORKER_RUNTIME: () => DURABLE_WORKER_RUNTIME,
|
|
28
39
|
DeadLetter: () => DeadLetter,
|
|
29
40
|
DurableModule: () => DurableModule,
|
|
30
41
|
DurableStartClient: () => DurableStartClient,
|
|
@@ -313,18 +324,47 @@ function attributesOf(workflow, run) {
|
|
|
313
324
|
__name(attributesOf, "attributesOf");
|
|
314
325
|
|
|
315
326
|
// src/durable-start-client.ts
|
|
316
|
-
var import_durable_worker = require("@dudousxd/durable-worker");
|
|
317
327
|
var import_nestjs_durable_core3 = require("@dudousxd/nestjs-durable-core");
|
|
318
328
|
var import_common = require("@nestjs/common");
|
|
329
|
+
|
|
330
|
+
// src/worker-sdk.ts
|
|
331
|
+
async function workerSdk() {
|
|
332
|
+
try {
|
|
333
|
+
return await import("@dudousxd/durable-worker");
|
|
334
|
+
} catch (cause) {
|
|
335
|
+
throw new Error("@dudousxd/durable-worker is not installed. It is an optional peer needed only by the roles that run workflow bodies (`connection` set on DurableModule.forRoot) \u2014 install it, or drop `connection`.", {
|
|
336
|
+
cause
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
__name(workerSdk, "workerSdk");
|
|
341
|
+
var startRun = /* @__PURE__ */ __name(async (connection, options) => (await workerSdk()).startRun(connection, options), "startRun");
|
|
342
|
+
var runRedisWorker = /* @__PURE__ */ __name(async (options) => (await workerSdk()).runRedisWorker(options), "runRedisWorker");
|
|
343
|
+
async function createWorkerRuntime(options) {
|
|
344
|
+
const { DurableWorkerRuntime: Runtime } = await workerSdk();
|
|
345
|
+
return new Runtime(options);
|
|
346
|
+
}
|
|
347
|
+
__name(createWorkerRuntime, "createWorkerRuntime");
|
|
348
|
+
|
|
349
|
+
// src/durable-start-client.ts
|
|
319
350
|
function _ts_decorate(decorators, target, key, desc) {
|
|
320
351
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
321
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
322
|
-
|
|
352
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
353
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
354
|
+
} else {
|
|
355
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
356
|
+
if (d = decorators[i]) {
|
|
357
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
323
361
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
324
362
|
}
|
|
325
363
|
__name(_ts_decorate, "_ts_decorate");
|
|
326
|
-
function _ts_metadata(
|
|
327
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
364
|
+
function _ts_metadata(metadataKey, metadataValue) {
|
|
365
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
366
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
367
|
+
}
|
|
328
368
|
}
|
|
329
369
|
__name(_ts_metadata, "_ts_metadata");
|
|
330
370
|
var DurableStartClient = class {
|
|
@@ -341,7 +381,7 @@ var DurableStartClient = class {
|
|
|
341
381
|
}
|
|
342
382
|
async start(workflow, input, runId = globalThis.crypto.randomUUID(), opts) {
|
|
343
383
|
const name = (0, import_nestjs_durable_core3.workflowName)(workflow);
|
|
344
|
-
await
|
|
384
|
+
await startRun(this.options.connection, {
|
|
345
385
|
tenant: this.tenant,
|
|
346
386
|
workflow: name,
|
|
347
387
|
input,
|
|
@@ -408,7 +448,6 @@ function tenantUnsupported(method) {
|
|
|
408
448
|
__name(tenantUnsupported, "tenantUnsupported");
|
|
409
449
|
|
|
410
450
|
// src/durable-worker.module.ts
|
|
411
|
-
var import_durable_worker2 = require("@dudousxd/durable-worker");
|
|
412
451
|
var import_nestjs_durable_core4 = require("@dudousxd/nestjs-durable-core");
|
|
413
452
|
var import_common2 = require("@nestjs/common");
|
|
414
453
|
var import_core = require("@nestjs/core");
|
|
@@ -453,13 +492,22 @@ __name(scanSteps, "scanSteps");
|
|
|
453
492
|
// src/durable-worker.module.ts
|
|
454
493
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
455
494
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
456
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
457
|
-
|
|
495
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
496
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
497
|
+
} else {
|
|
498
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
499
|
+
if (d = decorators[i]) {
|
|
500
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
458
504
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
459
505
|
}
|
|
460
506
|
__name(_ts_decorate2, "_ts_decorate");
|
|
461
|
-
function _ts_metadata2(
|
|
462
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
507
|
+
function _ts_metadata2(metadataKey, metadataValue) {
|
|
508
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
509
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
510
|
+
}
|
|
463
511
|
}
|
|
464
512
|
__name(_ts_metadata2, "_ts_metadata");
|
|
465
513
|
function _ts_param(paramIndex, decorator) {
|
|
@@ -469,6 +517,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
469
517
|
}
|
|
470
518
|
__name(_ts_param, "_ts_param");
|
|
471
519
|
var RUN_REDIS_WORKER = Symbol("nestjs-durable:run-redis-worker");
|
|
520
|
+
var DURABLE_WORKER_RUNTIME = Symbol("nestjs-durable:worker-runtime");
|
|
472
521
|
var DURABLE_WORKER_RUNNERS = Symbol("nestjs-durable:worker-runners");
|
|
473
522
|
function isPureThinWorker(options) {
|
|
474
523
|
return options.store === void 0 && options.connection !== void 0;
|
|
@@ -487,8 +536,9 @@ var ThinWorkflowRegistrar = class {
|
|
|
487
536
|
this.options = options;
|
|
488
537
|
}
|
|
489
538
|
onModuleInit() {
|
|
490
|
-
|
|
491
|
-
|
|
539
|
+
const runtime = this.runtime;
|
|
540
|
+
if (runtime === null || !isPureThinWorker(this.options)) return;
|
|
541
|
+
scanWorkflows(this.discovery, (meta, instance, origin) => runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input), {
|
|
492
542
|
version: meta.version,
|
|
493
543
|
...meta.requires !== void 0 ? {
|
|
494
544
|
requires: meta.requires
|
|
@@ -501,11 +551,12 @@ var ThinWorkflowRegistrar = class {
|
|
|
501
551
|
};
|
|
502
552
|
ThinWorkflowRegistrar = _ts_decorate2([
|
|
503
553
|
(0, import_common2.Injectable)(),
|
|
554
|
+
_ts_param(1, (0, import_common2.Inject)(DURABLE_WORKER_RUNTIME)),
|
|
504
555
|
_ts_param(2, (0, import_common2.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL)),
|
|
505
556
|
_ts_metadata2("design:type", Function),
|
|
506
557
|
_ts_metadata2("design:paramtypes", [
|
|
507
558
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
508
|
-
|
|
559
|
+
Object,
|
|
509
560
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
510
561
|
])
|
|
511
562
|
], ThinWorkflowRegistrar);
|
|
@@ -524,18 +575,20 @@ var ThinStepRegistrar = class {
|
|
|
524
575
|
this.options = options;
|
|
525
576
|
}
|
|
526
577
|
onModuleInit() {
|
|
527
|
-
|
|
528
|
-
|
|
578
|
+
const runtime = this.runtime;
|
|
579
|
+
if (runtime === null || !isPureThinWorker(this.options)) return;
|
|
580
|
+
scanSteps(this.discovery, this.metadataScanner, (meta, handler) => runtime.registerStep(meta.name, handler));
|
|
529
581
|
}
|
|
530
582
|
};
|
|
531
583
|
ThinStepRegistrar = _ts_decorate2([
|
|
532
584
|
(0, import_common2.Injectable)(),
|
|
585
|
+
_ts_param(2, (0, import_common2.Inject)(DURABLE_WORKER_RUNTIME)),
|
|
533
586
|
_ts_param(3, (0, import_common2.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL)),
|
|
534
587
|
_ts_metadata2("design:type", Function),
|
|
535
588
|
_ts_metadata2("design:paramtypes", [
|
|
536
589
|
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
537
590
|
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
538
|
-
|
|
591
|
+
Object,
|
|
539
592
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
540
593
|
])
|
|
541
594
|
], ThinStepRegistrar);
|
|
@@ -548,17 +601,18 @@ var ThinWorkerBootstrap = class {
|
|
|
548
601
|
runRedisWorker;
|
|
549
602
|
runnersSink;
|
|
550
603
|
runners = [];
|
|
551
|
-
constructor(runtime, options,
|
|
604
|
+
constructor(runtime, options, runRedisWorker2, runnersSink) {
|
|
552
605
|
this.runtime = runtime;
|
|
553
606
|
this.options = options;
|
|
554
|
-
this.runRedisWorker =
|
|
607
|
+
this.runRedisWorker = runRedisWorker2;
|
|
555
608
|
this.runnersSink = runnersSink;
|
|
556
609
|
}
|
|
557
610
|
async onApplicationBootstrap() {
|
|
558
611
|
const options = this.options;
|
|
559
|
-
|
|
612
|
+
const runtime = this.runtime;
|
|
613
|
+
if (runtime === null || !isPureThinWorker(options) || options.connection === void 0) return;
|
|
560
614
|
const handle = await this.runRedisWorker({
|
|
561
|
-
runtime
|
|
615
|
+
runtime,
|
|
562
616
|
connection: options.connection,
|
|
563
617
|
...options.partition !== void 0 ? {
|
|
564
618
|
partition: options.partition
|
|
@@ -582,12 +636,13 @@ var ThinWorkerBootstrap = class {
|
|
|
582
636
|
};
|
|
583
637
|
ThinWorkerBootstrap = _ts_decorate2([
|
|
584
638
|
(0, import_common2.Injectable)(),
|
|
639
|
+
_ts_param(0, (0, import_common2.Inject)(DURABLE_WORKER_RUNTIME)),
|
|
585
640
|
_ts_param(1, (0, import_common2.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL)),
|
|
586
641
|
_ts_param(2, (0, import_common2.Inject)(RUN_REDIS_WORKER)),
|
|
587
642
|
_ts_param(3, (0, import_common2.Inject)(DURABLE_WORKER_RUNNERS)),
|
|
588
643
|
_ts_metadata2("design:type", Function),
|
|
589
644
|
_ts_metadata2("design:paramtypes", [
|
|
590
|
-
|
|
645
|
+
Object,
|
|
591
646
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
592
647
|
typeof RunRedisWorkerFn === "undefined" ? Object : RunRedisWorkerFn,
|
|
593
648
|
Array
|
|
@@ -596,7 +651,7 @@ ThinWorkerBootstrap = _ts_decorate2([
|
|
|
596
651
|
function thinWorkerProviders() {
|
|
597
652
|
return [
|
|
598
653
|
{
|
|
599
|
-
provide:
|
|
654
|
+
provide: DURABLE_WORKER_RUNTIME,
|
|
600
655
|
// The runtime's `WorkflowWorker` falls back to its own `group` ctor param as the WORKFLOW's
|
|
601
656
|
// `workflowPartition` for any `ctx.step` call (see `workflow-context.ts`'s `resolveCallGroup`)
|
|
602
657
|
// — that fallback MUST equal this module's own `partition`, or a dispatched step's decision
|
|
@@ -604,16 +659,20 @@ function thinWorkerProviders() {
|
|
|
604
659
|
// to. Explicit `''` (never
|
|
605
660
|
// `undefined`) so it does NOT fall through to `WorkflowWorker`'s unrelated `'workflows'`
|
|
606
661
|
// default parameter.
|
|
607
|
-
|
|
662
|
+
//
|
|
663
|
+
// The role gate lives HERE, not just in the consumers: constructing the runtime resolves the
|
|
664
|
+
// optional `@dudousxd/durable-worker` peer, so an operator that never runs a worker must not
|
|
665
|
+
// reach this branch at all.
|
|
666
|
+
useFactory: /* @__PURE__ */ __name((options) => isPureThinWorker(options) ? createWorkerRuntime({
|
|
608
667
|
workflowGroup: options.partition ?? ""
|
|
609
|
-
}), "useFactory"),
|
|
668
|
+
}) : null, "useFactory"),
|
|
610
669
|
inject: [
|
|
611
670
|
import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL
|
|
612
671
|
]
|
|
613
672
|
},
|
|
614
673
|
{
|
|
615
674
|
provide: RUN_REDIS_WORKER,
|
|
616
|
-
useValue:
|
|
675
|
+
useValue: runRedisWorker
|
|
617
676
|
},
|
|
618
677
|
{
|
|
619
678
|
provide: DURABLE_WORKER_RUNNERS,
|
|
@@ -700,13 +759,22 @@ __name(isDrivingOperator, "isDrivingOperator");
|
|
|
700
759
|
// src/durable-step.registrar.ts
|
|
701
760
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
702
761
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
703
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
704
|
-
|
|
762
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
763
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
764
|
+
} else {
|
|
765
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
766
|
+
if (d = decorators[i]) {
|
|
767
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
705
771
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
706
772
|
}
|
|
707
773
|
__name(_ts_decorate3, "_ts_decorate");
|
|
708
|
-
function _ts_metadata3(
|
|
709
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
774
|
+
function _ts_metadata3(metadataKey, metadataValue) {
|
|
775
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
776
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
777
|
+
}
|
|
710
778
|
}
|
|
711
779
|
__name(_ts_metadata3, "_ts_metadata");
|
|
712
780
|
function _ts_param2(paramIndex, decorator) {
|
|
@@ -759,13 +827,22 @@ var import_common4 = require("@nestjs/common");
|
|
|
759
827
|
var import_reflect_metadata2 = require("reflect-metadata");
|
|
760
828
|
function _ts_decorate4(decorators, target, key, desc) {
|
|
761
829
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
762
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
763
|
-
|
|
830
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
831
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
832
|
+
} else {
|
|
833
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
834
|
+
if (d = decorators[i]) {
|
|
835
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
764
839
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
765
840
|
}
|
|
766
841
|
__name(_ts_decorate4, "_ts_decorate");
|
|
767
|
-
function _ts_metadata4(
|
|
768
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
842
|
+
function _ts_metadata4(metadataKey, metadataValue) {
|
|
843
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
844
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
845
|
+
}
|
|
769
846
|
}
|
|
770
847
|
__name(_ts_metadata4, "_ts_metadata");
|
|
771
848
|
var ENTITY_METADATA = Symbol("nestjs-durable:entity");
|
|
@@ -833,19 +910,27 @@ EntityService = _ts_decorate4([
|
|
|
833
910
|
], EntityService);
|
|
834
911
|
|
|
835
912
|
// src/in-app-worker.ts
|
|
836
|
-
var import_durable_worker3 = require("@dudousxd/durable-worker");
|
|
837
913
|
var import_nestjs_durable_core7 = require("@dudousxd/nestjs-durable-core");
|
|
838
914
|
var import_common5 = require("@nestjs/common");
|
|
839
915
|
var import_core3 = require("@nestjs/core");
|
|
840
916
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
841
917
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
842
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
843
|
-
|
|
918
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
919
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
920
|
+
} else {
|
|
921
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
922
|
+
if (d = decorators[i]) {
|
|
923
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
}
|
|
844
927
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
845
928
|
}
|
|
846
929
|
__name(_ts_decorate5, "_ts_decorate");
|
|
847
|
-
function _ts_metadata5(
|
|
848
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
930
|
+
function _ts_metadata5(metadataKey, metadataValue) {
|
|
931
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
932
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
933
|
+
}
|
|
849
934
|
}
|
|
850
935
|
__name(_ts_metadata5, "_ts_metadata");
|
|
851
936
|
function _ts_param3(paramIndex, decorator) {
|
|
@@ -886,17 +971,18 @@ var InAppWorkerBootstrap = class {
|
|
|
886
971
|
runRedisWorker;
|
|
887
972
|
runnersSink;
|
|
888
973
|
runners = [];
|
|
889
|
-
constructor(discovery, metadataScanner, options, runtime,
|
|
974
|
+
constructor(discovery, metadataScanner, options, runtime, runRedisWorker2, runnersSink) {
|
|
890
975
|
this.discovery = discovery;
|
|
891
976
|
this.metadataScanner = metadataScanner;
|
|
892
977
|
this.options = options;
|
|
893
978
|
this.runtime = runtime;
|
|
894
|
-
this.runRedisWorker =
|
|
979
|
+
this.runRedisWorker = runRedisWorker2;
|
|
895
980
|
this.runnersSink = runnersSink;
|
|
896
981
|
}
|
|
897
982
|
onModuleInit() {
|
|
898
|
-
|
|
899
|
-
|
|
983
|
+
const runtime = this.runtime;
|
|
984
|
+
if (runtime === null || !isCoLocatedWorker(this.options)) return;
|
|
985
|
+
scanWorkflows(this.discovery, (meta, instance, origin) => runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input), {
|
|
900
986
|
version: meta.version,
|
|
901
987
|
...meta.requires !== void 0 ? {
|
|
902
988
|
requires: meta.requires
|
|
@@ -905,13 +991,14 @@ var InAppWorkerBootstrap = class {
|
|
|
905
991
|
origin
|
|
906
992
|
} : {}
|
|
907
993
|
}));
|
|
908
|
-
scanSteps(this.discovery, this.metadataScanner, (meta, handler) =>
|
|
994
|
+
scanSteps(this.discovery, this.metadataScanner, (meta, handler) => runtime.registerStep(meta.name, handler));
|
|
909
995
|
}
|
|
910
996
|
async onApplicationBootstrap() {
|
|
911
997
|
const options = this.options;
|
|
912
|
-
|
|
998
|
+
const runtime = this.runtime;
|
|
999
|
+
if (runtime === null || !isCoLocatedWorker(options) || options.connection === void 0) return;
|
|
913
1000
|
const handle = await this.runRedisWorker({
|
|
914
|
-
runtime
|
|
1001
|
+
runtime,
|
|
915
1002
|
connection: options.connection,
|
|
916
1003
|
...options.partition !== void 0 ? {
|
|
917
1004
|
partition: options.partition
|
|
@@ -944,7 +1031,7 @@ InAppWorkerBootstrap = _ts_decorate5([
|
|
|
944
1031
|
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
945
1032
|
typeof import_core3.MetadataScanner === "undefined" ? Object : import_core3.MetadataScanner,
|
|
946
1033
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
947
|
-
|
|
1034
|
+
Object,
|
|
948
1035
|
typeof RunRedisWorkerFn === "undefined" ? Object : RunRedisWorkerFn,
|
|
949
1036
|
Array
|
|
950
1037
|
])
|
|
@@ -968,16 +1055,20 @@ function inAppWorkerProviders() {
|
|
|
968
1055
|
// to. Explicit `''` (never
|
|
969
1056
|
// `undefined`) so it does NOT fall through to `WorkflowWorker`'s unrelated `'workflows'`
|
|
970
1057
|
// default parameter.
|
|
971
|
-
|
|
1058
|
+
//
|
|
1059
|
+
// The role gate lives HERE, not just in the consumer: constructing the runtime resolves the
|
|
1060
|
+
// optional `@dudousxd/durable-worker` peer, so an operator that never runs a worker must not
|
|
1061
|
+
// reach this branch at all.
|
|
1062
|
+
useFactory: /* @__PURE__ */ __name((options) => isCoLocatedWorker(options) ? createWorkerRuntime({
|
|
972
1063
|
workflowGroup: options.partition ?? ""
|
|
973
|
-
}), "useFactory"),
|
|
1064
|
+
}) : null, "useFactory"),
|
|
974
1065
|
inject: [
|
|
975
1066
|
import_nestjs_durable_core7.DURABLE_OPTIONS_CANONICAL
|
|
976
1067
|
]
|
|
977
1068
|
},
|
|
978
1069
|
{
|
|
979
1070
|
provide: IN_APP_RUN_REDIS_WORKER,
|
|
980
|
-
useValue:
|
|
1071
|
+
useValue: runRedisWorker
|
|
981
1072
|
},
|
|
982
1073
|
{
|
|
983
1074
|
provide: IN_APP_WORKER_RUNNERS,
|
|
@@ -992,13 +1083,22 @@ __name(inAppWorkerProviders, "inAppWorkerProviders");
|
|
|
992
1083
|
var import_common6 = require("@nestjs/common");
|
|
993
1084
|
function _ts_decorate6(decorators, target, key, desc) {
|
|
994
1085
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
995
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
996
|
-
|
|
1086
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1087
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1088
|
+
} else {
|
|
1089
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1090
|
+
if (d = decorators[i]) {
|
|
1091
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
997
1095
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
998
1096
|
}
|
|
999
1097
|
__name(_ts_decorate6, "_ts_decorate");
|
|
1000
|
-
function _ts_metadata6(
|
|
1001
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1098
|
+
function _ts_metadata6(metadataKey, metadataValue) {
|
|
1099
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1100
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1101
|
+
}
|
|
1002
1102
|
}
|
|
1003
1103
|
__name(_ts_metadata6, "_ts_metadata");
|
|
1004
1104
|
var ProxyRunGateway = class {
|
|
@@ -1160,13 +1260,22 @@ var import_nestjs_durable_core8 = require("@dudousxd/nestjs-durable-core");
|
|
|
1160
1260
|
var import_common7 = require("@nestjs/common");
|
|
1161
1261
|
function _ts_decorate7(decorators, target, key, desc) {
|
|
1162
1262
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1163
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1164
|
-
|
|
1263
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1264
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1265
|
+
} else {
|
|
1266
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1267
|
+
if (d = decorators[i]) {
|
|
1268
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1165
1272
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1166
1273
|
}
|
|
1167
1274
|
__name(_ts_decorate7, "_ts_decorate");
|
|
1168
|
-
function _ts_metadata7(
|
|
1169
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1275
|
+
function _ts_metadata7(metadataKey, metadataValue) {
|
|
1276
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1277
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1278
|
+
}
|
|
1170
1279
|
}
|
|
1171
1280
|
__name(_ts_metadata7, "_ts_metadata");
|
|
1172
1281
|
function _ts_param4(paramIndex, decorator) {
|
|
@@ -1437,13 +1546,22 @@ var import_nestjs_durable_core9 = require("@dudousxd/nestjs-durable-core");
|
|
|
1437
1546
|
var import_common8 = require("@nestjs/common");
|
|
1438
1547
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
1439
1548
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1440
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1441
|
-
|
|
1549
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1550
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1551
|
+
} else {
|
|
1552
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1553
|
+
if (d = decorators[i]) {
|
|
1554
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1442
1558
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1443
1559
|
}
|
|
1444
1560
|
__name(_ts_decorate8, "_ts_decorate");
|
|
1445
|
-
function _ts_metadata8(
|
|
1446
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1561
|
+
function _ts_metadata8(metadataKey, metadataValue) {
|
|
1562
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1563
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1564
|
+
}
|
|
1447
1565
|
}
|
|
1448
1566
|
__name(_ts_metadata8, "_ts_metadata");
|
|
1449
1567
|
function _ts_param5(paramIndex, decorator) {
|
|
@@ -1629,13 +1747,22 @@ var import_nestjs_durable_core10 = require("@dudousxd/nestjs-durable-core");
|
|
|
1629
1747
|
var import_common9 = require("@nestjs/common");
|
|
1630
1748
|
function _ts_decorate9(decorators, target, key, desc) {
|
|
1631
1749
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1632
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1633
|
-
|
|
1750
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1751
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1752
|
+
} else {
|
|
1753
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1754
|
+
if (d = decorators[i]) {
|
|
1755
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1634
1759
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1635
1760
|
}
|
|
1636
1761
|
__name(_ts_decorate9, "_ts_decorate");
|
|
1637
|
-
function _ts_metadata9(
|
|
1638
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1762
|
+
function _ts_metadata9(metadataKey, metadataValue) {
|
|
1763
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1764
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1765
|
+
}
|
|
1639
1766
|
}
|
|
1640
1767
|
__name(_ts_metadata9, "_ts_metadata");
|
|
1641
1768
|
function _ts_param6(paramIndex, decorator) {
|
|
@@ -1737,15 +1864,15 @@ var import_core4 = require("@nestjs/core");
|
|
|
1737
1864
|
|
|
1738
1865
|
// src/input-validation.ts
|
|
1739
1866
|
function classValidatorInput(cls) {
|
|
1740
|
-
let cv;
|
|
1741
|
-
let ct;
|
|
1742
|
-
try {
|
|
1743
|
-
cv = require("class-validator");
|
|
1744
|
-
ct = require("class-transformer");
|
|
1745
|
-
} catch {
|
|
1746
|
-
throw new Error('@Workflow({ inputSchema }) needs the optional peers "class-validator" and "class-transformer" \u2014 install them, or pass a `validateInput` function instead.');
|
|
1747
|
-
}
|
|
1748
1867
|
return async (input) => {
|
|
1868
|
+
let cv;
|
|
1869
|
+
let ct;
|
|
1870
|
+
try {
|
|
1871
|
+
cv = await import("class-validator");
|
|
1872
|
+
ct = await import("class-transformer");
|
|
1873
|
+
} catch {
|
|
1874
|
+
throw new Error('@Workflow({ inputSchema }) needs the optional peers "class-validator" and "class-transformer" \u2014 install them, or pass a `validateInput` function instead.');
|
|
1875
|
+
}
|
|
1749
1876
|
const instance = ct.plainToInstance(cls, input);
|
|
1750
1877
|
const errors = await cv.validate(instance, {
|
|
1751
1878
|
whitelist: true
|
|
@@ -1777,13 +1904,22 @@ __name(isStepInterceptor, "isStepInterceptor");
|
|
|
1777
1904
|
// src/workflow.registrar.ts
|
|
1778
1905
|
function _ts_decorate10(decorators, target, key, desc) {
|
|
1779
1906
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1780
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1781
|
-
|
|
1907
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
1908
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1909
|
+
} else {
|
|
1910
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
1911
|
+
if (d = decorators[i]) {
|
|
1912
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
}
|
|
1782
1916
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1783
1917
|
}
|
|
1784
1918
|
__name(_ts_decorate10, "_ts_decorate");
|
|
1785
|
-
function _ts_metadata10(
|
|
1786
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
1919
|
+
function _ts_metadata10(metadataKey, metadataValue) {
|
|
1920
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
1921
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
1922
|
+
}
|
|
1787
1923
|
}
|
|
1788
1924
|
__name(_ts_metadata10, "_ts_metadata");
|
|
1789
1925
|
function _ts_param7(paramIndex, decorator) {
|
|
@@ -1982,13 +2118,22 @@ var import_nestjs_durable_core13 = require("@dudousxd/nestjs-durable-core");
|
|
|
1982
2118
|
var import_common11 = require("@nestjs/common");
|
|
1983
2119
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
1984
2120
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1985
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1986
|
-
|
|
2121
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2122
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2123
|
+
} else {
|
|
2124
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2125
|
+
if (d = decorators[i]) {
|
|
2126
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
}
|
|
1987
2130
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1988
2131
|
}
|
|
1989
2132
|
__name(_ts_decorate11, "_ts_decorate");
|
|
1990
|
-
function _ts_metadata11(
|
|
1991
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2133
|
+
function _ts_metadata11(metadataKey, metadataValue) {
|
|
2134
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2135
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2136
|
+
}
|
|
1992
2137
|
}
|
|
1993
2138
|
__name(_ts_metadata11, "_ts_metadata");
|
|
1994
2139
|
var WorkflowService = class {
|
|
@@ -2045,13 +2190,22 @@ WorkflowService = _ts_decorate11([
|
|
|
2045
2190
|
// src/durable.module.ts
|
|
2046
2191
|
function _ts_decorate12(decorators, target, key, desc) {
|
|
2047
2192
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2048
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2049
|
-
|
|
2193
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
|
|
2194
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
2195
|
+
} else {
|
|
2196
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
2197
|
+
if (d = decorators[i]) {
|
|
2198
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2050
2202
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2051
2203
|
}
|
|
2052
2204
|
__name(_ts_decorate12, "_ts_decorate");
|
|
2053
|
-
function _ts_metadata12(
|
|
2054
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
2205
|
+
function _ts_metadata12(metadataKey, metadataValue) {
|
|
2206
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
|
|
2207
|
+
return Reflect.metadata(metadataKey, metadataValue);
|
|
2208
|
+
}
|
|
2055
2209
|
}
|
|
2056
2210
|
__name(_ts_metadata12, "_ts_metadata");
|
|
2057
2211
|
function _ts_param8(paramIndex, decorator) {
|
|
@@ -2346,6 +2500,8 @@ var DurableModule = class _DurableModule {
|
|
|
2346
2500
|
admission: options.admission,
|
|
2347
2501
|
maxRecoveryAttempts: options.maxRecoveryAttempts,
|
|
2348
2502
|
remoteAdvanceSilenceMs: options.remoteAdvanceSilenceMs,
|
|
2503
|
+
remoteRedispatchMs: options.remoteRedispatchMs,
|
|
2504
|
+
remoteRedispatchMax: options.remoteRedispatchMax,
|
|
2349
2505
|
instanceId: options.instanceId,
|
|
2350
2506
|
namespace: options.namespace,
|
|
2351
2507
|
webhookUrl: options.webhookUrl,
|
|
@@ -2434,6 +2590,7 @@ var import_nestjs_durable_core15 = require("@dudousxd/nestjs-durable-core");
|
|
|
2434
2590
|
DEAD_LETTER_METADATA,
|
|
2435
2591
|
DURABLE_STEP_METADATA,
|
|
2436
2592
|
DURABLE_WORKER_RUNNERS,
|
|
2593
|
+
DURABLE_WORKER_RUNTIME,
|
|
2437
2594
|
DeadLetter,
|
|
2438
2595
|
DurableModule,
|
|
2439
2596
|
DurableStartClient,
|