@dudousxd/nestjs-durable 0.18.1 → 0.20.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 +294 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -2
- package/dist/index.d.ts +102 -2
- package/dist/index.js +287 -89
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
package/dist/index.cjs
CHANGED
|
@@ -24,9 +24,12 @@ __export(index_exports, {
|
|
|
24
24
|
CONTEXT_ACCESSOR: () => CONTEXT_ACCESSOR,
|
|
25
25
|
DEAD_LETTER_METADATA: () => DEAD_LETTER_METADATA,
|
|
26
26
|
DURABLE_STEP_METADATA: () => DURABLE_STEP_METADATA,
|
|
27
|
+
DURABLE_WORKER_OPTIONS: () => DURABLE_WORKER_OPTIONS,
|
|
28
|
+
DURABLE_WORKER_RUNNERS: () => DURABLE_WORKER_RUNNERS,
|
|
27
29
|
DeadLetter: () => DeadLetter,
|
|
28
30
|
DurableModule: () => DurableModule,
|
|
29
31
|
DurableStep: () => DurableStep,
|
|
32
|
+
DurableWorkerModule: () => DurableWorkerModule,
|
|
30
33
|
ENTITY_METADATA: () => ENTITY_METADATA,
|
|
31
34
|
ENTITY_ON_METADATA: () => ENTITY_ON_METADATA,
|
|
32
35
|
Entity: () => Entity,
|
|
@@ -34,8 +37,12 @@ __export(index_exports, {
|
|
|
34
37
|
ON_EVENT_METADATA: () => ON_EVENT_METADATA,
|
|
35
38
|
On: () => On,
|
|
36
39
|
OnEvent: () => OnEvent,
|
|
40
|
+
RUN_REDIS_WORKER: () => RUN_REDIS_WORKER,
|
|
37
41
|
STEP_INTERCEPTOR_METADATA: () => STEP_INTERCEPTOR_METADATA,
|
|
38
42
|
StepInterceptor: () => StepInterceptor,
|
|
43
|
+
ThinStepRegistrar: () => ThinStepRegistrar,
|
|
44
|
+
ThinWorkerBootstrap: () => ThinWorkerBootstrap,
|
|
45
|
+
ThinWorkflowRegistrar: () => ThinWorkflowRegistrar,
|
|
39
46
|
WORKFLOW_METADATA: () => WORKFLOW_METADATA,
|
|
40
47
|
Workflow: () => Workflow,
|
|
41
48
|
WorkflowService: () => WorkflowService,
|
|
@@ -129,15 +136,44 @@ function getOnEvents(meta, target) {
|
|
|
129
136
|
}
|
|
130
137
|
__name(getOnEvents, "getOnEvents");
|
|
131
138
|
|
|
132
|
-
// src/durable.module.ts
|
|
133
|
-
var
|
|
134
|
-
var import_common6 = require("@nestjs/common");
|
|
135
|
-
var import_core3 = require("@nestjs/core");
|
|
136
|
-
|
|
137
|
-
// src/durable-step.registrar.ts
|
|
138
|
-
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
139
|
+
// src/durable-worker.module.ts
|
|
140
|
+
var import_durable_worker = require("@dudousxd/durable-worker");
|
|
139
141
|
var import_common = require("@nestjs/common");
|
|
140
142
|
var import_core = require("@nestjs/core");
|
|
143
|
+
|
|
144
|
+
// src/discovery-helpers.ts
|
|
145
|
+
function scanWorkflows(discovery, register) {
|
|
146
|
+
for (const wrapper of discovery.getProviders()) {
|
|
147
|
+
const { instance } = wrapper;
|
|
148
|
+
if (!instance || typeof instance !== "object") continue;
|
|
149
|
+
const meta = getWorkflowMeta(instance.constructor);
|
|
150
|
+
if (!meta) continue;
|
|
151
|
+
const workflow = instance;
|
|
152
|
+
if (typeof workflow.run !== "function") {
|
|
153
|
+
throw new Error(`@Workflow ${meta.name} must define a run(ctx, input) method`);
|
|
154
|
+
}
|
|
155
|
+
register(meta, workflow);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
__name(scanWorkflows, "scanWorkflows");
|
|
159
|
+
function scanSteps(discovery, scanner, register) {
|
|
160
|
+
for (const wrapper of discovery.getProviders()) {
|
|
161
|
+
const { instance } = wrapper;
|
|
162
|
+
if (!instance || typeof instance !== "object") continue;
|
|
163
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
164
|
+
for (const methodName of scanner.getAllMethodNames(prototype)) {
|
|
165
|
+
const method = instance[methodName];
|
|
166
|
+
if (typeof method !== "function") continue;
|
|
167
|
+
const meta = getDurableStepMeta(method);
|
|
168
|
+
if (!meta) continue;
|
|
169
|
+
const handler = /* @__PURE__ */ __name((input, log) => method.call(instance, input, log), "handler");
|
|
170
|
+
register(meta, handler);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
__name(scanSteps, "scanSteps");
|
|
175
|
+
|
|
176
|
+
// src/durable-worker.module.ts
|
|
141
177
|
function _ts_decorate(decorators, target, key, desc) {
|
|
142
178
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
143
179
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -155,6 +191,182 @@ function _ts_param(paramIndex, decorator) {
|
|
|
155
191
|
};
|
|
156
192
|
}
|
|
157
193
|
__name(_ts_param, "_ts_param");
|
|
194
|
+
var DURABLE_WORKER_OPTIONS = Symbol("nestjs-durable:worker-options");
|
|
195
|
+
var RUN_REDIS_WORKER = Symbol("nestjs-durable:run-redis-worker");
|
|
196
|
+
var DURABLE_WORKER_RUNNERS = Symbol("nestjs-durable:worker-runners");
|
|
197
|
+
var ThinWorkflowRegistrar = class {
|
|
198
|
+
static {
|
|
199
|
+
__name(this, "ThinWorkflowRegistrar");
|
|
200
|
+
}
|
|
201
|
+
discovery;
|
|
202
|
+
runtime;
|
|
203
|
+
constructor(discovery, runtime) {
|
|
204
|
+
this.discovery = discovery;
|
|
205
|
+
this.runtime = runtime;
|
|
206
|
+
}
|
|
207
|
+
onModuleInit() {
|
|
208
|
+
scanWorkflows(this.discovery, (meta, instance) => this.runtime.registerWorkflow(meta.name, (ctx, input) => instance.run(ctx, input)));
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
ThinWorkflowRegistrar = _ts_decorate([
|
|
212
|
+
(0, import_common.Injectable)(),
|
|
213
|
+
_ts_metadata("design:type", Function),
|
|
214
|
+
_ts_metadata("design:paramtypes", [
|
|
215
|
+
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
216
|
+
typeof import_durable_worker.DurableWorkerRuntime === "undefined" ? Object : import_durable_worker.DurableWorkerRuntime
|
|
217
|
+
])
|
|
218
|
+
], ThinWorkflowRegistrar);
|
|
219
|
+
var ThinStepRegistrar = class {
|
|
220
|
+
static {
|
|
221
|
+
__name(this, "ThinStepRegistrar");
|
|
222
|
+
}
|
|
223
|
+
discovery;
|
|
224
|
+
metadataScanner;
|
|
225
|
+
runtime;
|
|
226
|
+
constructor(discovery, metadataScanner, runtime) {
|
|
227
|
+
this.discovery = discovery;
|
|
228
|
+
this.metadataScanner = metadataScanner;
|
|
229
|
+
this.runtime = runtime;
|
|
230
|
+
}
|
|
231
|
+
onModuleInit() {
|
|
232
|
+
scanSteps(this.discovery, this.metadataScanner, (meta, handler) => this.runtime.registerStep(meta.name, handler));
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
ThinStepRegistrar = _ts_decorate([
|
|
236
|
+
(0, import_common.Injectable)(),
|
|
237
|
+
_ts_metadata("design:type", Function),
|
|
238
|
+
_ts_metadata("design:paramtypes", [
|
|
239
|
+
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
240
|
+
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
241
|
+
typeof import_durable_worker.DurableWorkerRuntime === "undefined" ? Object : import_durable_worker.DurableWorkerRuntime
|
|
242
|
+
])
|
|
243
|
+
], ThinStepRegistrar);
|
|
244
|
+
var ThinWorkerBootstrap = class {
|
|
245
|
+
static {
|
|
246
|
+
__name(this, "ThinWorkerBootstrap");
|
|
247
|
+
}
|
|
248
|
+
runtime;
|
|
249
|
+
options;
|
|
250
|
+
runRedisWorker;
|
|
251
|
+
runnersSink;
|
|
252
|
+
runners = [];
|
|
253
|
+
constructor(runtime, options, runRedisWorker, runnersSink) {
|
|
254
|
+
this.runtime = runtime;
|
|
255
|
+
this.options = options;
|
|
256
|
+
this.runRedisWorker = runRedisWorker;
|
|
257
|
+
this.runnersSink = runnersSink;
|
|
258
|
+
}
|
|
259
|
+
async onApplicationBootstrap() {
|
|
260
|
+
for (const group of this.options.groups) {
|
|
261
|
+
const handle = await this.runRedisWorker({
|
|
262
|
+
runtime: this.runtime,
|
|
263
|
+
group,
|
|
264
|
+
connection: this.options.connection,
|
|
265
|
+
...this.options.prefix !== void 0 ? {
|
|
266
|
+
prefix: this.options.prefix
|
|
267
|
+
} : {},
|
|
268
|
+
...this.options.instanceId !== void 0 ? {
|
|
269
|
+
instanceId: this.options.instanceId
|
|
270
|
+
} : {}
|
|
271
|
+
});
|
|
272
|
+
this.runners.push(handle);
|
|
273
|
+
this.runnersSink.push(handle);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
async onApplicationShutdown() {
|
|
277
|
+
await Promise.allSettled(this.runners.map((h) => h.close()));
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
ThinWorkerBootstrap = _ts_decorate([
|
|
281
|
+
(0, import_common.Injectable)(),
|
|
282
|
+
_ts_param(1, (0, import_common.Inject)(DURABLE_WORKER_OPTIONS)),
|
|
283
|
+
_ts_param(2, (0, import_common.Inject)(RUN_REDIS_WORKER)),
|
|
284
|
+
_ts_param(3, (0, import_common.Inject)(DURABLE_WORKER_RUNNERS)),
|
|
285
|
+
_ts_metadata("design:type", Function),
|
|
286
|
+
_ts_metadata("design:paramtypes", [
|
|
287
|
+
typeof import_durable_worker.DurableWorkerRuntime === "undefined" ? Object : import_durable_worker.DurableWorkerRuntime,
|
|
288
|
+
typeof DurableWorkerModuleOptions === "undefined" ? Object : DurableWorkerModuleOptions,
|
|
289
|
+
typeof RunRedisWorkerFn === "undefined" ? Object : RunRedisWorkerFn,
|
|
290
|
+
Array
|
|
291
|
+
])
|
|
292
|
+
], ThinWorkerBootstrap);
|
|
293
|
+
var DurableWorkerModule = class _DurableWorkerModule {
|
|
294
|
+
static {
|
|
295
|
+
__name(this, "DurableWorkerModule");
|
|
296
|
+
}
|
|
297
|
+
static forRoot(options) {
|
|
298
|
+
return _DurableWorkerModule.build({
|
|
299
|
+
provide: DURABLE_WORKER_OPTIONS,
|
|
300
|
+
useValue: options
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
static forRootAsync(options) {
|
|
304
|
+
return _DurableWorkerModule.build({
|
|
305
|
+
provide: DURABLE_WORKER_OPTIONS,
|
|
306
|
+
useFactory: options.useFactory,
|
|
307
|
+
inject: options.inject ?? []
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
static build(optionsProvider) {
|
|
311
|
+
return {
|
|
312
|
+
module: _DurableWorkerModule,
|
|
313
|
+
imports: [
|
|
314
|
+
import_core.DiscoveryModule
|
|
315
|
+
],
|
|
316
|
+
providers: [
|
|
317
|
+
optionsProvider,
|
|
318
|
+
{
|
|
319
|
+
provide: import_durable_worker.DurableWorkerRuntime,
|
|
320
|
+
useFactory: /* @__PURE__ */ __name(() => new import_durable_worker.DurableWorkerRuntime(), "useFactory")
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
provide: RUN_REDIS_WORKER,
|
|
324
|
+
useValue: import_durable_worker.runRedisWorker
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
provide: DURABLE_WORKER_RUNNERS,
|
|
328
|
+
useValue: []
|
|
329
|
+
},
|
|
330
|
+
ThinWorkflowRegistrar,
|
|
331
|
+
ThinStepRegistrar,
|
|
332
|
+
ThinWorkerBootstrap
|
|
333
|
+
],
|
|
334
|
+
exports: [
|
|
335
|
+
import_durable_worker.DurableWorkerRuntime
|
|
336
|
+
]
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
DurableWorkerModule = _ts_decorate([
|
|
341
|
+
(0, import_common.Module)({})
|
|
342
|
+
], DurableWorkerModule);
|
|
343
|
+
|
|
344
|
+
// src/durable.module.ts
|
|
345
|
+
var import_nestjs_durable_core7 = require("@dudousxd/nestjs-durable-core");
|
|
346
|
+
var import_common7 = require("@nestjs/common");
|
|
347
|
+
var import_core4 = require("@nestjs/core");
|
|
348
|
+
|
|
349
|
+
// src/durable-step.registrar.ts
|
|
350
|
+
var import_nestjs_durable_core2 = require("@dudousxd/nestjs-durable-core");
|
|
351
|
+
var import_common2 = require("@nestjs/common");
|
|
352
|
+
var import_core2 = require("@nestjs/core");
|
|
353
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
354
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
355
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
356
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
357
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
358
|
+
}
|
|
359
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
360
|
+
function _ts_metadata2(k, v) {
|
|
361
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
362
|
+
}
|
|
363
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
364
|
+
function _ts_param2(paramIndex, decorator) {
|
|
365
|
+
return function(target, key) {
|
|
366
|
+
decorator(target, key, paramIndex);
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
__name(_ts_param2, "_ts_param");
|
|
158
370
|
function supportsHandle(transport) {
|
|
159
371
|
return typeof transport?.handle === "function";
|
|
160
372
|
}
|
|
@@ -177,28 +389,17 @@ var DurableStepRegistrar = class {
|
|
|
177
389
|
if (this.options.worker === false) return;
|
|
178
390
|
if (!supportsHandle(this.transport)) return;
|
|
179
391
|
const transport = this.transport;
|
|
180
|
-
|
|
181
|
-
const { instance } = wrapper;
|
|
182
|
-
if (!instance || typeof instance !== "object") continue;
|
|
183
|
-
const prototype = Object.getPrototypeOf(instance);
|
|
184
|
-
for (const methodName of this.metadataScanner.getAllMethodNames(prototype)) {
|
|
185
|
-
const method = instance[methodName];
|
|
186
|
-
if (typeof method !== "function") continue;
|
|
187
|
-
const meta = getDurableStepMeta(method);
|
|
188
|
-
if (!meta) continue;
|
|
189
|
-
transport.handle(meta.name, (input, log) => instance[methodName](input, log));
|
|
190
|
-
}
|
|
191
|
-
}
|
|
392
|
+
scanSteps(this.discovery, this.metadataScanner, (meta, handler) => transport.handle(meta.name, handler));
|
|
192
393
|
}
|
|
193
394
|
};
|
|
194
|
-
DurableStepRegistrar =
|
|
195
|
-
(0,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
typeof
|
|
201
|
-
typeof
|
|
395
|
+
DurableStepRegistrar = _ts_decorate2([
|
|
396
|
+
(0, import_common2.Injectable)(),
|
|
397
|
+
_ts_param2(2, (0, import_common2.Inject)(import_nestjs_durable_core2.TRANSPORT_CANONICAL)),
|
|
398
|
+
_ts_param2(3, (0, import_common2.Inject)(import_nestjs_durable_core2.DURABLE_OPTIONS_CANONICAL)),
|
|
399
|
+
_ts_metadata2("design:type", Function),
|
|
400
|
+
_ts_metadata2("design:paramtypes", [
|
|
401
|
+
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
402
|
+
typeof import_core2.MetadataScanner === "undefined" ? Object : import_core2.MetadataScanner,
|
|
202
403
|
Object,
|
|
203
404
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
204
405
|
])
|
|
@@ -206,19 +407,19 @@ DurableStepRegistrar = _ts_decorate([
|
|
|
206
407
|
|
|
207
408
|
// src/entity.ts
|
|
208
409
|
var import_nestjs_durable_core3 = require("@dudousxd/nestjs-durable-core");
|
|
209
|
-
var
|
|
410
|
+
var import_common3 = require("@nestjs/common");
|
|
210
411
|
var import_reflect_metadata2 = require("reflect-metadata");
|
|
211
|
-
function
|
|
412
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
212
413
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
213
414
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
214
415
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
215
416
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
216
417
|
}
|
|
217
|
-
__name(
|
|
218
|
-
function
|
|
418
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
419
|
+
function _ts_metadata3(k, v) {
|
|
219
420
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
220
421
|
}
|
|
221
|
-
__name(
|
|
422
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
222
423
|
var ENTITY_METADATA = Symbol("nestjs-durable:entity");
|
|
223
424
|
var ENTITY_ON_METADATA = Symbol("nestjs-durable:entity-on");
|
|
224
425
|
function Entity(options) {
|
|
@@ -275,34 +476,34 @@ var EntityService = class {
|
|
|
275
476
|
return this.engine.getEntityState(name, key);
|
|
276
477
|
}
|
|
277
478
|
};
|
|
278
|
-
EntityService =
|
|
279
|
-
(0,
|
|
280
|
-
|
|
281
|
-
|
|
479
|
+
EntityService = _ts_decorate3([
|
|
480
|
+
(0, import_common3.Injectable)(),
|
|
481
|
+
_ts_metadata3("design:type", Function),
|
|
482
|
+
_ts_metadata3("design:paramtypes", [
|
|
282
483
|
typeof import_nestjs_durable_core3.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core3.WorkflowEngine
|
|
283
484
|
])
|
|
284
485
|
], EntityService);
|
|
285
486
|
|
|
286
487
|
// src/timer-poller.ts
|
|
287
488
|
var import_nestjs_durable_core4 = require("@dudousxd/nestjs-durable-core");
|
|
288
|
-
var
|
|
289
|
-
function
|
|
489
|
+
var import_common4 = require("@nestjs/common");
|
|
490
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
290
491
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
291
492
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
292
493
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
293
494
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
294
495
|
}
|
|
295
|
-
__name(
|
|
296
|
-
function
|
|
496
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
497
|
+
function _ts_metadata4(k, v) {
|
|
297
498
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
298
499
|
}
|
|
299
|
-
__name(
|
|
300
|
-
function
|
|
500
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
501
|
+
function _ts_param3(paramIndex, decorator) {
|
|
301
502
|
return function(target, key) {
|
|
302
503
|
decorator(target, key, paramIndex);
|
|
303
504
|
};
|
|
304
505
|
}
|
|
305
|
-
__name(
|
|
506
|
+
__name(_ts_param3, "_ts_param");
|
|
306
507
|
var TimerPoller = class {
|
|
307
508
|
static {
|
|
308
509
|
__name(this, "TimerPoller");
|
|
@@ -347,11 +548,11 @@ var TimerPoller = class {
|
|
|
347
548
|
}
|
|
348
549
|
}
|
|
349
550
|
};
|
|
350
|
-
TimerPoller =
|
|
351
|
-
(0,
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
551
|
+
TimerPoller = _ts_decorate4([
|
|
552
|
+
(0, import_common4.Injectable)(),
|
|
553
|
+
_ts_param3(1, (0, import_common4.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS_CANONICAL)),
|
|
554
|
+
_ts_metadata4("design:type", Function),
|
|
555
|
+
_ts_metadata4("design:paramtypes", [
|
|
355
556
|
typeof import_nestjs_durable_core4.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core4.WorkflowEngine,
|
|
356
557
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
357
558
|
])
|
|
@@ -362,8 +563,8 @@ var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
|
362
563
|
|
|
363
564
|
// src/workflow.registrar.ts
|
|
364
565
|
var import_nestjs_durable_core5 = require("@dudousxd/nestjs-durable-core");
|
|
365
|
-
var
|
|
366
|
-
var
|
|
566
|
+
var import_common5 = require("@nestjs/common");
|
|
567
|
+
var import_core3 = require("@nestjs/core");
|
|
367
568
|
|
|
368
569
|
// src/input-validation.ts
|
|
369
570
|
function classValidatorInput(cls) {
|
|
@@ -405,23 +606,23 @@ function isStepInterceptor(target) {
|
|
|
405
606
|
__name(isStepInterceptor, "isStepInterceptor");
|
|
406
607
|
|
|
407
608
|
// src/workflow.registrar.ts
|
|
408
|
-
function
|
|
609
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
409
610
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
410
611
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
411
612
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
412
613
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
413
614
|
}
|
|
414
|
-
__name(
|
|
415
|
-
function
|
|
615
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
616
|
+
function _ts_metadata5(k, v) {
|
|
416
617
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
417
618
|
}
|
|
418
|
-
__name(
|
|
419
|
-
function
|
|
619
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
620
|
+
function _ts_param4(paramIndex, decorator) {
|
|
420
621
|
return function(target, key) {
|
|
421
622
|
decorator(target, key, paramIndex);
|
|
422
623
|
};
|
|
423
624
|
}
|
|
424
|
-
__name(
|
|
625
|
+
__name(_ts_param4, "_ts_param");
|
|
425
626
|
var WorkflowRegistrar = class {
|
|
426
627
|
static {
|
|
427
628
|
__name(this, "WorkflowRegistrar");
|
|
@@ -468,14 +669,9 @@ var WorkflowRegistrar = class {
|
|
|
468
669
|
const entityMeta = getEntityMeta(instance.constructor);
|
|
469
670
|
if (entityMeta) {
|
|
470
671
|
this.engine.registerEntity(entityMeta.name, entityConfigFor(instance.constructor));
|
|
471
|
-
continue;
|
|
472
|
-
}
|
|
473
|
-
const meta = getWorkflowMeta(instance.constructor);
|
|
474
|
-
if (!meta) continue;
|
|
475
|
-
const workflow = instance;
|
|
476
|
-
if (typeof workflow.run !== "function") {
|
|
477
|
-
throw new Error(`@Workflow ${meta.name} must define a run(ctx, input) method`);
|
|
478
672
|
}
|
|
673
|
+
}
|
|
674
|
+
scanWorkflows(this.discovery, (meta, workflow) => {
|
|
479
675
|
const validateInput = meta.validateInput ?? (meta.inputSchema ? classValidatorInput(meta.inputSchema) : void 0);
|
|
480
676
|
const eventBatch = meta.debounce ? {
|
|
481
677
|
mode: "debounce",
|
|
@@ -485,15 +681,16 @@ var WorkflowRegistrar = class {
|
|
|
485
681
|
maxSize: meta.batch.maxSize,
|
|
486
682
|
windowMs: (0, import_nestjs_durable_core5.parseDuration)(meta.batch.within)
|
|
487
683
|
} : void 0;
|
|
684
|
+
const workflowCtor = workflow.constructor;
|
|
488
685
|
this.engine.register(meta.name, meta.version, (ctx, input) => workflow.run(ctx, input), {
|
|
489
686
|
tags: meta.tags,
|
|
490
687
|
singleton: meta.singleton,
|
|
491
688
|
executionTimeout: meta.executionTimeout,
|
|
492
689
|
validateInput,
|
|
493
|
-
onEvent: getOnEvents(meta,
|
|
690
|
+
onEvent: getOnEvents(meta, workflowCtor),
|
|
494
691
|
eventBatch
|
|
495
692
|
});
|
|
496
|
-
const inline = this.findDeadLetterHandler(
|
|
693
|
+
const inline = this.findDeadLetterHandler(workflow);
|
|
497
694
|
if (inline && meta.deadLetterWorkflow) {
|
|
498
695
|
throw new Error(`@Workflow ${meta.name} declares both an inline @DeadLetter() method and a deadLetterWorkflow option. Use one: the inline handler, or the reference.`);
|
|
499
696
|
}
|
|
@@ -504,7 +701,7 @@ var WorkflowRegistrar = class {
|
|
|
504
701
|
} else if (meta.deadLetterWorkflow) {
|
|
505
702
|
deadLetterByWorkflow.set(meta.name, (0, import_nestjs_durable_core5.workflowName)(meta.deadLetterWorkflow));
|
|
506
703
|
}
|
|
507
|
-
}
|
|
704
|
+
});
|
|
508
705
|
this.installDeadLetterRouting(deadLetterByWorkflow);
|
|
509
706
|
}
|
|
510
707
|
/** Returns the instance's `@DeadLetter()` method bound to the instance, or undefined if none. */
|
|
@@ -538,14 +735,14 @@ var WorkflowRegistrar = class {
|
|
|
538
735
|
});
|
|
539
736
|
}
|
|
540
737
|
};
|
|
541
|
-
WorkflowRegistrar =
|
|
542
|
-
(0,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
typeof
|
|
548
|
-
typeof
|
|
738
|
+
WorkflowRegistrar = _ts_decorate5([
|
|
739
|
+
(0, import_common5.Injectable)(),
|
|
740
|
+
_ts_param4(3, (0, import_common5.Inject)(import_nestjs_durable_core5.STATE_STORE_CANONICAL)),
|
|
741
|
+
_ts_param4(4, (0, import_common5.Inject)(import_nestjs_durable_core5.DURABLE_OPTIONS_CANONICAL)),
|
|
742
|
+
_ts_metadata5("design:type", Function),
|
|
743
|
+
_ts_metadata5("design:paramtypes", [
|
|
744
|
+
typeof import_core3.DiscoveryService === "undefined" ? Object : import_core3.DiscoveryService,
|
|
745
|
+
typeof import_core3.MetadataScanner === "undefined" ? Object : import_core3.MetadataScanner,
|
|
549
746
|
typeof import_nestjs_durable_core5.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core5.WorkflowEngine,
|
|
550
747
|
typeof StateStore === "undefined" ? Object : StateStore,
|
|
551
748
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
@@ -555,18 +752,18 @@ WorkflowRegistrar = _ts_decorate4([
|
|
|
555
752
|
// src/workflow.service.ts
|
|
556
753
|
var import_node_crypto = require("crypto");
|
|
557
754
|
var import_nestjs_durable_core6 = require("@dudousxd/nestjs-durable-core");
|
|
558
|
-
var
|
|
559
|
-
function
|
|
755
|
+
var import_common6 = require("@nestjs/common");
|
|
756
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
560
757
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
561
758
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
562
759
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
563
760
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
564
761
|
}
|
|
565
|
-
__name(
|
|
566
|
-
function
|
|
762
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
763
|
+
function _ts_metadata6(k, v) {
|
|
567
764
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
568
765
|
}
|
|
569
|
-
__name(
|
|
766
|
+
__name(_ts_metadata6, "_ts_metadata");
|
|
570
767
|
var WorkflowService = class {
|
|
571
768
|
static {
|
|
572
769
|
__name(this, "WorkflowService");
|
|
@@ -606,22 +803,22 @@ var WorkflowService = class {
|
|
|
606
803
|
return this.engine.publishEvent(name, payload, opts);
|
|
607
804
|
}
|
|
608
805
|
};
|
|
609
|
-
WorkflowService =
|
|
610
|
-
(0,
|
|
611
|
-
|
|
612
|
-
|
|
806
|
+
WorkflowService = _ts_decorate6([
|
|
807
|
+
(0, import_common6.Injectable)(),
|
|
808
|
+
_ts_metadata6("design:type", Function),
|
|
809
|
+
_ts_metadata6("design:paramtypes", [
|
|
613
810
|
typeof import_nestjs_durable_core6.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core6.WorkflowEngine
|
|
614
811
|
])
|
|
615
812
|
], WorkflowService);
|
|
616
813
|
|
|
617
814
|
// src/durable.module.ts
|
|
618
|
-
function
|
|
815
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
619
816
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
620
817
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
621
818
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
622
819
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
623
820
|
}
|
|
624
|
-
__name(
|
|
821
|
+
__name(_ts_decorate7, "_ts_decorate");
|
|
625
822
|
function resolveAccessor(moduleRef) {
|
|
626
823
|
try {
|
|
627
824
|
return moduleRef.get(CONTEXT_ACCESSOR, {
|
|
@@ -683,7 +880,7 @@ var DurableModule = class _DurableModule {
|
|
|
683
880
|
module: _DurableModule,
|
|
684
881
|
global: true,
|
|
685
882
|
imports: [
|
|
686
|
-
|
|
883
|
+
import_core4.DiscoveryModule
|
|
687
884
|
],
|
|
688
885
|
providers: [
|
|
689
886
|
optionsProvider,
|
|
@@ -730,6 +927,7 @@ var DurableModule = class _DurableModule {
|
|
|
730
927
|
leaseMs: opts.leaseMs,
|
|
731
928
|
admission: opts.admission,
|
|
732
929
|
maxRecoveryAttempts: opts.maxRecoveryAttempts,
|
|
930
|
+
remoteAdvanceSilenceMs: opts.remoteAdvanceSilenceMs,
|
|
733
931
|
instanceId: opts.instanceId,
|
|
734
932
|
webhookUrl: opts.webhookUrl,
|
|
735
933
|
traceparent: opts.traceparent,
|
|
@@ -751,7 +949,7 @@ var DurableModule = class _DurableModule {
|
|
|
751
949
|
import_nestjs_durable_core7.STATE_STORE_CANONICAL,
|
|
752
950
|
import_nestjs_durable_core7.TRANSPORT_CANONICAL,
|
|
753
951
|
import_nestjs_durable_core7.DURABLE_OPTIONS_CANONICAL,
|
|
754
|
-
|
|
952
|
+
import_core4.ModuleRef
|
|
755
953
|
]
|
|
756
954
|
},
|
|
757
955
|
WorkflowService,
|
|
@@ -773,17 +971,20 @@ var DurableModule = class _DurableModule {
|
|
|
773
971
|
};
|
|
774
972
|
}
|
|
775
973
|
};
|
|
776
|
-
DurableModule =
|
|
777
|
-
(0,
|
|
974
|
+
DurableModule = _ts_decorate7([
|
|
975
|
+
(0, import_common7.Module)({})
|
|
778
976
|
], DurableModule);
|
|
779
977
|
// Annotate the CommonJS export names for ESM import in node:
|
|
780
978
|
0 && (module.exports = {
|
|
781
979
|
CONTEXT_ACCESSOR,
|
|
782
980
|
DEAD_LETTER_METADATA,
|
|
783
981
|
DURABLE_STEP_METADATA,
|
|
982
|
+
DURABLE_WORKER_OPTIONS,
|
|
983
|
+
DURABLE_WORKER_RUNNERS,
|
|
784
984
|
DeadLetter,
|
|
785
985
|
DurableModule,
|
|
786
986
|
DurableStep,
|
|
987
|
+
DurableWorkerModule,
|
|
787
988
|
ENTITY_METADATA,
|
|
788
989
|
ENTITY_ON_METADATA,
|
|
789
990
|
Entity,
|
|
@@ -791,8 +992,12 @@ DurableModule = _ts_decorate6([
|
|
|
791
992
|
ON_EVENT_METADATA,
|
|
792
993
|
On,
|
|
793
994
|
OnEvent,
|
|
995
|
+
RUN_REDIS_WORKER,
|
|
794
996
|
STEP_INTERCEPTOR_METADATA,
|
|
795
997
|
StepInterceptor,
|
|
998
|
+
ThinStepRegistrar,
|
|
999
|
+
ThinWorkerBootstrap,
|
|
1000
|
+
ThinWorkflowRegistrar,
|
|
796
1001
|
WORKFLOW_METADATA,
|
|
797
1002
|
Workflow,
|
|
798
1003
|
WorkflowService,
|