@dudousxd/nestjs-durable 0.15.0 → 0.17.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/LICENSE +21 -0
- package/dist/index.cjs +791 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +417 -0
- package/dist/index.d.ts +417 -8
- package/dist/index.js +745 -21
- package/dist/index.js.map +1 -1
- package/package.json +21 -7
- package/dist/context-accessor.d.ts +0 -31
- package/dist/context-accessor.d.ts.map +0 -1
- package/dist/context-accessor.js +0 -3
- package/dist/context-accessor.js.map +0 -1
- package/dist/decorators.d.ts +0 -146
- package/dist/decorators.d.ts.map +0 -1
- package/dist/decorators.js +0 -103
- package/dist/decorators.js.map +0 -1
- package/dist/durable-step.registrar.d.ts +0 -30
- package/dist/durable-step.registrar.d.ts.map +0 -1
- package/dist/durable-step.registrar.js +0 -85
- package/dist/durable-step.registrar.js.map +0 -1
- package/dist/durable.module.d.ts +0 -108
- package/dist/durable.module.d.ts.map +0 -1
- package/dist/durable.module.js +0 -207
- package/dist/durable.module.js.map +0 -1
- package/dist/entity.d.ts +0 -43
- package/dist/entity.d.ts.map +0 -1
- package/dist/entity.js +0 -94
- package/dist/entity.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/input-validation.d.ts +0 -9
- package/dist/input-validation.d.ts.map +0 -1
- package/dist/input-validation.js +0 -30
- package/dist/input-validation.js.map +0 -1
- package/dist/step-interceptor.d.ts +0 -20
- package/dist/step-interceptor.d.ts.map +0 -1
- package/dist/step-interceptor.js +0 -22
- package/dist/step-interceptor.js.map +0 -1
- package/dist/timer-poller.d.ts +0 -20
- package/dist/timer-poller.d.ts.map +0 -1
- package/dist/timer-poller.js +0 -81
- package/dist/timer-poller.js.map +0 -1
- package/dist/tokens.d.ts +0 -13
- package/dist/tokens.d.ts.map +0 -1
- package/dist/tokens.js +0 -16
- package/dist/tokens.js.map +0 -1
- package/dist/workflow.registrar.d.ts +0 -33
- package/dist/workflow.registrar.d.ts.map +0 -1
- package/dist/workflow.registrar.js +0 -169
- package/dist/workflow.registrar.js.map +0 -1
- package/dist/workflow.service.d.ts +0 -55
- package/dist/workflow.service.d.ts.map +0 -1
- package/dist/workflow.service.js +0 -58
- package/dist/workflow.service.js.map +0 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,791 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
CONTEXT_ACCESSOR: () => CONTEXT_ACCESSOR,
|
|
25
|
+
DEAD_LETTER_METADATA: () => DEAD_LETTER_METADATA,
|
|
26
|
+
DURABLE_STEP_METADATA: () => DURABLE_STEP_METADATA,
|
|
27
|
+
DeadLetter: () => DeadLetter,
|
|
28
|
+
DurableModule: () => DurableModule,
|
|
29
|
+
DurableStep: () => DurableStep,
|
|
30
|
+
ENTITY_METADATA: () => ENTITY_METADATA,
|
|
31
|
+
ENTITY_ON_METADATA: () => ENTITY_ON_METADATA,
|
|
32
|
+
Entity: () => Entity,
|
|
33
|
+
EntityService: () => EntityService,
|
|
34
|
+
ON_EVENT_METADATA: () => ON_EVENT_METADATA,
|
|
35
|
+
On: () => On,
|
|
36
|
+
OnEvent: () => OnEvent,
|
|
37
|
+
STEP_INTERCEPTOR_METADATA: () => STEP_INTERCEPTOR_METADATA,
|
|
38
|
+
StepInterceptor: () => StepInterceptor,
|
|
39
|
+
WORKFLOW_METADATA: () => WORKFLOW_METADATA,
|
|
40
|
+
Workflow: () => Workflow,
|
|
41
|
+
WorkflowService: () => WorkflowService,
|
|
42
|
+
entityConfigFor: () => entityConfigFor,
|
|
43
|
+
getDurableStepMeta: () => getDurableStepMeta,
|
|
44
|
+
getEntityMeta: () => getEntityMeta,
|
|
45
|
+
getOnEvents: () => getOnEvents,
|
|
46
|
+
getWorkflowMeta: () => getWorkflowMeta,
|
|
47
|
+
isDeadLetterHandler: () => isDeadLetterHandler,
|
|
48
|
+
isStepInterceptor: () => isStepInterceptor
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(index_exports);
|
|
51
|
+
|
|
52
|
+
// src/decorators.ts
|
|
53
|
+
var import_nestjs_durable_core = require("@dudousxd/nestjs-durable-core");
|
|
54
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
55
|
+
var WORKFLOW_METADATA = Symbol("nestjs-durable:workflow");
|
|
56
|
+
function Workflow(options) {
|
|
57
|
+
return (target) => {
|
|
58
|
+
const meta = {
|
|
59
|
+
name: options.name,
|
|
60
|
+
version: options.version ?? "1",
|
|
61
|
+
deadLetterWorkflow: options.deadLetterWorkflow,
|
|
62
|
+
tags: options.tags,
|
|
63
|
+
singleton: options.singleton,
|
|
64
|
+
executionTimeout: options.executionTimeout,
|
|
65
|
+
inputSchema: options.inputSchema,
|
|
66
|
+
validateInput: options.validateInput,
|
|
67
|
+
onEvent: options.onEvent,
|
|
68
|
+
debounce: options.debounce,
|
|
69
|
+
batch: options.batch
|
|
70
|
+
};
|
|
71
|
+
Reflect.defineMetadata(WORKFLOW_METADATA, meta, target);
|
|
72
|
+
Object.defineProperty(target, import_nestjs_durable_core.WORKFLOW_NAME_KEY, {
|
|
73
|
+
value: options.name,
|
|
74
|
+
configurable: true
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
__name(Workflow, "Workflow");
|
|
79
|
+
function getWorkflowMeta(target) {
|
|
80
|
+
return Reflect.getMetadata(WORKFLOW_METADATA, target);
|
|
81
|
+
}
|
|
82
|
+
__name(getWorkflowMeta, "getWorkflowMeta");
|
|
83
|
+
var DURABLE_STEP_METADATA = Symbol("nestjs-durable:step-handler");
|
|
84
|
+
function DurableStep(name) {
|
|
85
|
+
return (_target, _propertyKey, descriptor) => {
|
|
86
|
+
const meta = {
|
|
87
|
+
name
|
|
88
|
+
};
|
|
89
|
+
Reflect.defineMetadata(DURABLE_STEP_METADATA, meta, descriptor.value);
|
|
90
|
+
return descriptor;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
__name(DurableStep, "DurableStep");
|
|
94
|
+
function getDurableStepMeta(method) {
|
|
95
|
+
return Reflect.getMetadata(DURABLE_STEP_METADATA, method);
|
|
96
|
+
}
|
|
97
|
+
__name(getDurableStepMeta, "getDurableStepMeta");
|
|
98
|
+
var DEAD_LETTER_METADATA = Symbol("nestjs-durable:dead-letter");
|
|
99
|
+
function DeadLetter() {
|
|
100
|
+
return (_target, _propertyKey, descriptor) => {
|
|
101
|
+
Reflect.defineMetadata(DEAD_LETTER_METADATA, true, descriptor.value);
|
|
102
|
+
return descriptor;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
__name(DeadLetter, "DeadLetter");
|
|
106
|
+
function isDeadLetterHandler(method) {
|
|
107
|
+
return Reflect.getMetadata(DEAD_LETTER_METADATA, method) === true;
|
|
108
|
+
}
|
|
109
|
+
__name(isDeadLetterHandler, "isDeadLetterHandler");
|
|
110
|
+
var ON_EVENT_METADATA = Symbol("nestjs-durable:on-event");
|
|
111
|
+
function OnEvent(...events) {
|
|
112
|
+
return (target) => {
|
|
113
|
+
const existing = Reflect.getMetadata(ON_EVENT_METADATA, target) ?? [];
|
|
114
|
+
Reflect.defineMetadata(ON_EVENT_METADATA, [
|
|
115
|
+
...existing,
|
|
116
|
+
...events
|
|
117
|
+
], target);
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
__name(OnEvent, "OnEvent");
|
|
121
|
+
function getOnEvents(meta, target) {
|
|
122
|
+
const fromDecorator = Reflect.getMetadata(ON_EVENT_METADATA, target) ?? [];
|
|
123
|
+
return [
|
|
124
|
+
.../* @__PURE__ */ new Set([
|
|
125
|
+
...meta.onEvent ?? [],
|
|
126
|
+
...fromDecorator
|
|
127
|
+
])
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
__name(getOnEvents, "getOnEvents");
|
|
131
|
+
|
|
132
|
+
// src/durable.module.ts
|
|
133
|
+
var import_nestjs_durable_core7 = require("@dudousxd/nestjs-durable-core");
|
|
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
|
+
var import_common = require("@nestjs/common");
|
|
140
|
+
var import_core = require("@nestjs/core");
|
|
141
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
142
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
143
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
144
|
+
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;
|
|
145
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
146
|
+
}
|
|
147
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
148
|
+
function _ts_metadata(k, v) {
|
|
149
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
150
|
+
}
|
|
151
|
+
__name(_ts_metadata, "_ts_metadata");
|
|
152
|
+
function _ts_param(paramIndex, decorator) {
|
|
153
|
+
return function(target, key) {
|
|
154
|
+
decorator(target, key, paramIndex);
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
__name(_ts_param, "_ts_param");
|
|
158
|
+
function supportsHandle(transport) {
|
|
159
|
+
return typeof transport?.handle === "function";
|
|
160
|
+
}
|
|
161
|
+
__name(supportsHandle, "supportsHandle");
|
|
162
|
+
var DurableStepRegistrar = class {
|
|
163
|
+
static {
|
|
164
|
+
__name(this, "DurableStepRegistrar");
|
|
165
|
+
}
|
|
166
|
+
discovery;
|
|
167
|
+
metadataScanner;
|
|
168
|
+
transport;
|
|
169
|
+
options;
|
|
170
|
+
constructor(discovery, metadataScanner, transport, options) {
|
|
171
|
+
this.discovery = discovery;
|
|
172
|
+
this.metadataScanner = metadataScanner;
|
|
173
|
+
this.transport = transport;
|
|
174
|
+
this.options = options;
|
|
175
|
+
}
|
|
176
|
+
onModuleInit() {
|
|
177
|
+
if (this.options.worker === false) return;
|
|
178
|
+
if (!supportsHandle(this.transport)) return;
|
|
179
|
+
const transport = this.transport;
|
|
180
|
+
for (const wrapper of this.discovery.getProviders()) {
|
|
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
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
DurableStepRegistrar = _ts_decorate([
|
|
195
|
+
(0, import_common.Injectable)(),
|
|
196
|
+
_ts_param(2, (0, import_common.Inject)(import_nestjs_durable_core2.TRANSPORT)),
|
|
197
|
+
_ts_param(3, (0, import_common.Inject)(import_nestjs_durable_core2.DURABLE_OPTIONS)),
|
|
198
|
+
_ts_metadata("design:type", Function),
|
|
199
|
+
_ts_metadata("design:paramtypes", [
|
|
200
|
+
typeof import_core.DiscoveryService === "undefined" ? Object : import_core.DiscoveryService,
|
|
201
|
+
typeof import_core.MetadataScanner === "undefined" ? Object : import_core.MetadataScanner,
|
|
202
|
+
Object,
|
|
203
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
204
|
+
])
|
|
205
|
+
], DurableStepRegistrar);
|
|
206
|
+
|
|
207
|
+
// src/entity.ts
|
|
208
|
+
var import_nestjs_durable_core3 = require("@dudousxd/nestjs-durable-core");
|
|
209
|
+
var import_common2 = require("@nestjs/common");
|
|
210
|
+
var import_reflect_metadata2 = require("reflect-metadata");
|
|
211
|
+
function _ts_decorate2(decorators, target, key, desc) {
|
|
212
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
213
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
214
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
216
|
+
}
|
|
217
|
+
__name(_ts_decorate2, "_ts_decorate");
|
|
218
|
+
function _ts_metadata2(k, v) {
|
|
219
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
220
|
+
}
|
|
221
|
+
__name(_ts_metadata2, "_ts_metadata");
|
|
222
|
+
var ENTITY_METADATA = Symbol("nestjs-durable:entity");
|
|
223
|
+
var ENTITY_ON_METADATA = Symbol("nestjs-durable:entity-on");
|
|
224
|
+
function Entity(options) {
|
|
225
|
+
return (target) => {
|
|
226
|
+
Reflect.defineMetadata(ENTITY_METADATA, options, target);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
__name(Entity, "Entity");
|
|
230
|
+
function On(op) {
|
|
231
|
+
return (target, propertyKey) => {
|
|
232
|
+
const ctor = target.constructor;
|
|
233
|
+
const ops = Reflect.getMetadata(ENTITY_ON_METADATA, ctor) ?? /* @__PURE__ */ new Map();
|
|
234
|
+
ops.set(op, propertyKey);
|
|
235
|
+
Reflect.defineMetadata(ENTITY_ON_METADATA, ops, ctor);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
__name(On, "On");
|
|
239
|
+
function getEntityMeta(target) {
|
|
240
|
+
return Reflect.getMetadata(ENTITY_METADATA, target);
|
|
241
|
+
}
|
|
242
|
+
__name(getEntityMeta, "getEntityMeta");
|
|
243
|
+
function entityConfigFor(ctor) {
|
|
244
|
+
const ops = Reflect.getMetadata(ENTITY_ON_METADATA, ctor) ?? /* @__PURE__ */ new Map();
|
|
245
|
+
const Cls = ctor;
|
|
246
|
+
const handlers = {};
|
|
247
|
+
for (const [op, method] of ops) {
|
|
248
|
+
handlers[op] = (state, arg) => {
|
|
249
|
+
Object.setPrototypeOf(state, Cls.prototype);
|
|
250
|
+
const fn = state[method];
|
|
251
|
+
if (typeof fn !== "function") throw new Error(`entity handler "${method}" is not a method`);
|
|
252
|
+
return fn.call(state, arg);
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
initialState: /* @__PURE__ */ __name(() => new Cls(), "initialState"),
|
|
257
|
+
handlers
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
__name(entityConfigFor, "entityConfigFor");
|
|
261
|
+
var EntityService = class {
|
|
262
|
+
static {
|
|
263
|
+
__name(this, "EntityService");
|
|
264
|
+
}
|
|
265
|
+
engine;
|
|
266
|
+
constructor(engine) {
|
|
267
|
+
this.engine = engine;
|
|
268
|
+
}
|
|
269
|
+
/** Send an operation to an entity (fire-and-forget; ordered + exactly-once per key). */
|
|
270
|
+
signal(name, key, op, arg) {
|
|
271
|
+
return this.engine.signalEntity(name, key, op, arg);
|
|
272
|
+
}
|
|
273
|
+
/** Read an entity's current durable state (or undefined if it has none yet). */
|
|
274
|
+
getState(name, key) {
|
|
275
|
+
return this.engine.getEntityState(name, key);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
EntityService = _ts_decorate2([
|
|
279
|
+
(0, import_common2.Injectable)(),
|
|
280
|
+
_ts_metadata2("design:type", Function),
|
|
281
|
+
_ts_metadata2("design:paramtypes", [
|
|
282
|
+
typeof import_nestjs_durable_core3.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core3.WorkflowEngine
|
|
283
|
+
])
|
|
284
|
+
], EntityService);
|
|
285
|
+
|
|
286
|
+
// src/timer-poller.ts
|
|
287
|
+
var import_nestjs_durable_core4 = require("@dudousxd/nestjs-durable-core");
|
|
288
|
+
var import_common3 = require("@nestjs/common");
|
|
289
|
+
function _ts_decorate3(decorators, target, key, desc) {
|
|
290
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
291
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
292
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
294
|
+
}
|
|
295
|
+
__name(_ts_decorate3, "_ts_decorate");
|
|
296
|
+
function _ts_metadata3(k, v) {
|
|
297
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
298
|
+
}
|
|
299
|
+
__name(_ts_metadata3, "_ts_metadata");
|
|
300
|
+
function _ts_param2(paramIndex, decorator) {
|
|
301
|
+
return function(target, key) {
|
|
302
|
+
decorator(target, key, paramIndex);
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
__name(_ts_param2, "_ts_param");
|
|
306
|
+
var TimerPoller = class {
|
|
307
|
+
static {
|
|
308
|
+
__name(this, "TimerPoller");
|
|
309
|
+
}
|
|
310
|
+
engine;
|
|
311
|
+
options;
|
|
312
|
+
timer;
|
|
313
|
+
polling = false;
|
|
314
|
+
unsubscribeEnqueued;
|
|
315
|
+
constructor(engine, options) {
|
|
316
|
+
this.engine = engine;
|
|
317
|
+
this.options = options;
|
|
318
|
+
}
|
|
319
|
+
async onApplicationBootstrap() {
|
|
320
|
+
if (this.options.worker === false) return;
|
|
321
|
+
this.unsubscribeEnqueued = this.engine.onEnqueued((runId) => void this.engine.runOne(runId));
|
|
322
|
+
await this.poll();
|
|
323
|
+
const intervalMs = this.options.timerPollMs ?? 1e3;
|
|
324
|
+
if (intervalMs > 0) {
|
|
325
|
+
this.timer = setInterval(() => void this.poll(), intervalMs);
|
|
326
|
+
this.timer.unref?.();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
onModuleDestroy() {
|
|
330
|
+
if (this.timer) clearInterval(this.timer);
|
|
331
|
+
this.unsubscribeEnqueued?.();
|
|
332
|
+
}
|
|
333
|
+
async poll() {
|
|
334
|
+
if (this.polling) return;
|
|
335
|
+
this.polling = true;
|
|
336
|
+
try {
|
|
337
|
+
await this.engine.runPending();
|
|
338
|
+
await this.engine.recoverIncomplete();
|
|
339
|
+
await this.engine.resumeDueTimers();
|
|
340
|
+
await this.engine.sweepTimeouts();
|
|
341
|
+
const schedules = this.options.schedules;
|
|
342
|
+
if (schedules && schedules.length > 0) {
|
|
343
|
+
await (0, import_nestjs_durable_core4.runSchedules)(this.engine, schedules, Date.now());
|
|
344
|
+
}
|
|
345
|
+
} finally {
|
|
346
|
+
this.polling = false;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
TimerPoller = _ts_decorate3([
|
|
351
|
+
(0, import_common3.Injectable)(),
|
|
352
|
+
_ts_param2(1, (0, import_common3.Inject)(import_nestjs_durable_core4.DURABLE_OPTIONS)),
|
|
353
|
+
_ts_metadata3("design:type", Function),
|
|
354
|
+
_ts_metadata3("design:paramtypes", [
|
|
355
|
+
typeof import_nestjs_durable_core4.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core4.WorkflowEngine,
|
|
356
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
357
|
+
])
|
|
358
|
+
], TimerPoller);
|
|
359
|
+
|
|
360
|
+
// src/tokens.ts
|
|
361
|
+
var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
362
|
+
|
|
363
|
+
// src/workflow.registrar.ts
|
|
364
|
+
var import_nestjs_durable_core5 = require("@dudousxd/nestjs-durable-core");
|
|
365
|
+
var import_common4 = require("@nestjs/common");
|
|
366
|
+
var import_core2 = require("@nestjs/core");
|
|
367
|
+
|
|
368
|
+
// src/input-validation.ts
|
|
369
|
+
function classValidatorInput(cls) {
|
|
370
|
+
let cv;
|
|
371
|
+
let ct;
|
|
372
|
+
try {
|
|
373
|
+
cv = require("class-validator");
|
|
374
|
+
ct = require("class-transformer");
|
|
375
|
+
} catch {
|
|
376
|
+
throw new Error('@Workflow({ inputSchema }) needs the optional peers "class-validator" and "class-transformer" \u2014 install them, or pass a `validateInput` function instead.');
|
|
377
|
+
}
|
|
378
|
+
return async (input) => {
|
|
379
|
+
const instance = ct.plainToInstance(cls, input);
|
|
380
|
+
const errors = await cv.validate(instance, {
|
|
381
|
+
whitelist: true
|
|
382
|
+
});
|
|
383
|
+
if (errors.length > 0) {
|
|
384
|
+
const message = errors.map((e) => Object.values(e.constraints ?? {
|
|
385
|
+
_: e.property
|
|
386
|
+
}).join(", ")).join("; ");
|
|
387
|
+
throw new Error(`invalid input for workflow: ${message}`);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
__name(classValidatorInput, "classValidatorInput");
|
|
392
|
+
|
|
393
|
+
// src/step-interceptor.ts
|
|
394
|
+
var import_reflect_metadata3 = require("reflect-metadata");
|
|
395
|
+
var STEP_INTERCEPTOR_METADATA = Symbol("nestjs-durable:step-interceptor");
|
|
396
|
+
function StepInterceptor() {
|
|
397
|
+
return (target) => {
|
|
398
|
+
Reflect.defineMetadata(STEP_INTERCEPTOR_METADATA, true, target);
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
__name(StepInterceptor, "StepInterceptor");
|
|
402
|
+
function isStepInterceptor(target) {
|
|
403
|
+
return Reflect.getMetadata(STEP_INTERCEPTOR_METADATA, target) === true;
|
|
404
|
+
}
|
|
405
|
+
__name(isStepInterceptor, "isStepInterceptor");
|
|
406
|
+
|
|
407
|
+
// src/workflow.registrar.ts
|
|
408
|
+
function _ts_decorate4(decorators, target, key, desc) {
|
|
409
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
410
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
411
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
413
|
+
}
|
|
414
|
+
__name(_ts_decorate4, "_ts_decorate");
|
|
415
|
+
function _ts_metadata4(k, v) {
|
|
416
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
417
|
+
}
|
|
418
|
+
__name(_ts_metadata4, "_ts_metadata");
|
|
419
|
+
function _ts_param3(paramIndex, decorator) {
|
|
420
|
+
return function(target, key) {
|
|
421
|
+
decorator(target, key, paramIndex);
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
__name(_ts_param3, "_ts_param");
|
|
425
|
+
var WorkflowRegistrar = class {
|
|
426
|
+
static {
|
|
427
|
+
__name(this, "WorkflowRegistrar");
|
|
428
|
+
}
|
|
429
|
+
discovery;
|
|
430
|
+
metadataScanner;
|
|
431
|
+
engine;
|
|
432
|
+
store;
|
|
433
|
+
options;
|
|
434
|
+
constructor(discovery, metadataScanner, engine, store, options) {
|
|
435
|
+
this.discovery = discovery;
|
|
436
|
+
this.metadataScanner = metadataScanner;
|
|
437
|
+
this.engine = engine;
|
|
438
|
+
this.store = store;
|
|
439
|
+
this.options = options;
|
|
440
|
+
}
|
|
441
|
+
async onApplicationBootstrap() {
|
|
442
|
+
if (this.options.worker === false) return;
|
|
443
|
+
await this.engine.recoverIncomplete();
|
|
444
|
+
}
|
|
445
|
+
/** On deploy/shutdown: stop picking up new runs and wait for in-flight ones to settle, then close
|
|
446
|
+
* the transport(s) so the broker workers stop consuming and connections are released. Closing
|
|
447
|
+
* AFTER the drain keeps the transport alive while in-flight runs dispatch/await their remote steps. */
|
|
448
|
+
async onApplicationShutdown() {
|
|
449
|
+
await this.engine.drain(this.options.shutdownTimeoutMs);
|
|
450
|
+
const transports = [
|
|
451
|
+
this.options.transport,
|
|
452
|
+
...(this.options.transports ?? []).map((t) => t.transport)
|
|
453
|
+
];
|
|
454
|
+
await Promise.allSettled(transports.map((t) => t?.close?.()));
|
|
455
|
+
}
|
|
456
|
+
async onModuleInit() {
|
|
457
|
+
if (this.options.autoSchema !== false) {
|
|
458
|
+
await this.store.ensureSchema?.();
|
|
459
|
+
}
|
|
460
|
+
const deadLetterByWorkflow = /* @__PURE__ */ new Map();
|
|
461
|
+
for (const wrapper of this.discovery.getProviders()) {
|
|
462
|
+
const { instance } = wrapper;
|
|
463
|
+
if (!instance || typeof instance !== "object") continue;
|
|
464
|
+
if (isStepInterceptor(instance.constructor)) {
|
|
465
|
+
const interceptor = instance;
|
|
466
|
+
this.engine.use((invocation, next) => interceptor.intercept(invocation, next));
|
|
467
|
+
}
|
|
468
|
+
const entityMeta = getEntityMeta(instance.constructor);
|
|
469
|
+
if (entityMeta) {
|
|
470
|
+
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
|
+
}
|
|
479
|
+
const validateInput = meta.validateInput ?? (meta.inputSchema ? classValidatorInput(meta.inputSchema) : void 0);
|
|
480
|
+
const eventBatch = meta.debounce ? {
|
|
481
|
+
mode: "debounce",
|
|
482
|
+
windowMs: (0, import_nestjs_durable_core5.parseDuration)(meta.debounce)
|
|
483
|
+
} : meta.batch ? {
|
|
484
|
+
mode: "batch",
|
|
485
|
+
maxSize: meta.batch.maxSize,
|
|
486
|
+
windowMs: (0, import_nestjs_durable_core5.parseDuration)(meta.batch.within)
|
|
487
|
+
} : void 0;
|
|
488
|
+
this.engine.register(meta.name, meta.version, (ctx, input) => workflow.run(ctx, input), {
|
|
489
|
+
tags: meta.tags,
|
|
490
|
+
singleton: meta.singleton,
|
|
491
|
+
executionTimeout: meta.executionTimeout,
|
|
492
|
+
validateInput,
|
|
493
|
+
onEvent: getOnEvents(meta, instance.constructor),
|
|
494
|
+
eventBatch
|
|
495
|
+
});
|
|
496
|
+
const inline = this.findDeadLetterHandler(instance);
|
|
497
|
+
if (inline && meta.deadLetterWorkflow) {
|
|
498
|
+
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
|
+
}
|
|
500
|
+
if (inline) {
|
|
501
|
+
const dlqName = `${meta.name}.dlq`;
|
|
502
|
+
this.engine.register(dlqName, meta.version, inline);
|
|
503
|
+
deadLetterByWorkflow.set(meta.name, dlqName);
|
|
504
|
+
} else if (meta.deadLetterWorkflow) {
|
|
505
|
+
deadLetterByWorkflow.set(meta.name, (0, import_nestjs_durable_core5.workflowName)(meta.deadLetterWorkflow));
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
this.installDeadLetterRouting(deadLetterByWorkflow);
|
|
509
|
+
}
|
|
510
|
+
/** Returns the instance's `@DeadLetter()` method bound to the instance, or undefined if none. */
|
|
511
|
+
findDeadLetterHandler(instance) {
|
|
512
|
+
const prototype = Object.getPrototypeOf(instance);
|
|
513
|
+
for (const methodName of this.metadataScanner.getAllMethodNames(prototype)) {
|
|
514
|
+
const method = instance[methodName];
|
|
515
|
+
if (typeof method === "function" && isDeadLetterHandler(method)) {
|
|
516
|
+
return (ctx, input) => method.call(instance, ctx, input);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
return void 0;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* Installs a single onDead listener that routes a dead run to its workflow's handler (from the
|
|
523
|
+
* map) or the module-level `deadLetterWorkflow` default. The handler is started idempotently with
|
|
524
|
+
* a `dlq:<runId>` id, so re-recovery never double-dispatches.
|
|
525
|
+
*/
|
|
526
|
+
installDeadLetterRouting(byWorkflow) {
|
|
527
|
+
const fallback = this.options.deadLetterWorkflow ? (0, import_nestjs_durable_core5.workflowName)(this.options.deadLetterWorkflow) : void 0;
|
|
528
|
+
if (byWorkflow.size === 0 && !fallback) return;
|
|
529
|
+
this.engine.onDead((run) => {
|
|
530
|
+
const target = byWorkflow.get(run.workflow) ?? fallback;
|
|
531
|
+
if (!target) return;
|
|
532
|
+
void this.engine.start(target, {
|
|
533
|
+
deadRunId: run.id,
|
|
534
|
+
workflow: run.workflow,
|
|
535
|
+
input: run.input,
|
|
536
|
+
error: run.error
|
|
537
|
+
}, `dlq:${run.id}`).catch(() => void 0);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
WorkflowRegistrar = _ts_decorate4([
|
|
542
|
+
(0, import_common4.Injectable)(),
|
|
543
|
+
_ts_param3(3, (0, import_common4.Inject)(import_nestjs_durable_core5.STATE_STORE)),
|
|
544
|
+
_ts_param3(4, (0, import_common4.Inject)(import_nestjs_durable_core5.DURABLE_OPTIONS)),
|
|
545
|
+
_ts_metadata4("design:type", Function),
|
|
546
|
+
_ts_metadata4("design:paramtypes", [
|
|
547
|
+
typeof import_core2.DiscoveryService === "undefined" ? Object : import_core2.DiscoveryService,
|
|
548
|
+
typeof import_core2.MetadataScanner === "undefined" ? Object : import_core2.MetadataScanner,
|
|
549
|
+
typeof import_nestjs_durable_core5.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core5.WorkflowEngine,
|
|
550
|
+
typeof StateStore === "undefined" ? Object : StateStore,
|
|
551
|
+
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
552
|
+
])
|
|
553
|
+
], WorkflowRegistrar);
|
|
554
|
+
|
|
555
|
+
// src/workflow.service.ts
|
|
556
|
+
var import_node_crypto = require("crypto");
|
|
557
|
+
var import_nestjs_durable_core6 = require("@dudousxd/nestjs-durable-core");
|
|
558
|
+
var import_common5 = require("@nestjs/common");
|
|
559
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
560
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
561
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
562
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
564
|
+
}
|
|
565
|
+
__name(_ts_decorate5, "_ts_decorate");
|
|
566
|
+
function _ts_metadata5(k, v) {
|
|
567
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
568
|
+
}
|
|
569
|
+
__name(_ts_metadata5, "_ts_metadata");
|
|
570
|
+
var WorkflowService = class {
|
|
571
|
+
static {
|
|
572
|
+
__name(this, "WorkflowService");
|
|
573
|
+
}
|
|
574
|
+
engine;
|
|
575
|
+
constructor(engine) {
|
|
576
|
+
this.engine = engine;
|
|
577
|
+
}
|
|
578
|
+
start(workflow, input, runId = (0, import_node_crypto.randomUUID)(), opts) {
|
|
579
|
+
return this.engine.start(workflow, input, runId, opts);
|
|
580
|
+
}
|
|
581
|
+
resume(runId) {
|
|
582
|
+
return this.engine.resume(runId);
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Resolve once a run settles — terminal (completed/failed/cancelled/dead) or suspended. `start`
|
|
586
|
+
* only enqueues (a worker runs the body), so pair them when a request needs the outcome:
|
|
587
|
+
* `const { runId } = await svc.start(...); const result = await svc.waitForRun(runId)`.
|
|
588
|
+
*/
|
|
589
|
+
waitForRun(runId, opts) {
|
|
590
|
+
return this.engine.waitForRun(runId, opts);
|
|
591
|
+
}
|
|
592
|
+
/** Deliver an external signal (e.g. from a webhook) to the run waiting on `token`. */
|
|
593
|
+
signal(token, payload) {
|
|
594
|
+
return this.engine.signal(token, payload);
|
|
595
|
+
}
|
|
596
|
+
signalWithStart(workflow, input, runId, signal, opts) {
|
|
597
|
+
return this.engine.signalWithStart(workflow, input, runId, signal, opts);
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Publish a named event. Resumes runs waiting on it via `ctx.waitForEvent(name, { match })` and
|
|
601
|
+
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnEvent` (the
|
|
602
|
+
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
603
|
+
* touched (resumed + started).
|
|
604
|
+
*/
|
|
605
|
+
publishEvent(name, payload, opts) {
|
|
606
|
+
return this.engine.publishEvent(name, payload, opts);
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
WorkflowService = _ts_decorate5([
|
|
610
|
+
(0, import_common5.Injectable)(),
|
|
611
|
+
_ts_metadata5("design:type", Function),
|
|
612
|
+
_ts_metadata5("design:paramtypes", [
|
|
613
|
+
typeof import_nestjs_durable_core6.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core6.WorkflowEngine
|
|
614
|
+
])
|
|
615
|
+
], WorkflowService);
|
|
616
|
+
|
|
617
|
+
// src/durable.module.ts
|
|
618
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
619
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
620
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
621
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
623
|
+
}
|
|
624
|
+
__name(_ts_decorate6, "_ts_decorate");
|
|
625
|
+
function resolveAccessor(moduleRef) {
|
|
626
|
+
try {
|
|
627
|
+
return moduleRef.get(CONTEXT_ACCESSOR, {
|
|
628
|
+
strict: false
|
|
629
|
+
});
|
|
630
|
+
} catch {
|
|
631
|
+
return void 0;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
__name(resolveAccessor, "resolveAccessor");
|
|
635
|
+
function carrierFromAccessor(accessor) {
|
|
636
|
+
const carrier = {};
|
|
637
|
+
const traceId = accessor.traceId();
|
|
638
|
+
if (traceId !== void 0) carrier.traceId = traceId;
|
|
639
|
+
const tenantId = accessor.tenantId();
|
|
640
|
+
if (tenantId !== void 0) carrier.tenantId = tenantId;
|
|
641
|
+
const userRef = accessor.userRef();
|
|
642
|
+
if (userRef !== void 0) carrier.userRef = userRef;
|
|
643
|
+
return carrier;
|
|
644
|
+
}
|
|
645
|
+
__name(carrierFromAccessor, "carrierFromAccessor");
|
|
646
|
+
function isContextRuntime(x) {
|
|
647
|
+
return !!x && typeof x.deserialize === "function";
|
|
648
|
+
}
|
|
649
|
+
__name(isContextRuntime, "isContextRuntime");
|
|
650
|
+
async function resolveContextRuntime() {
|
|
651
|
+
try {
|
|
652
|
+
const specifier = "@dudousxd/nestjs-context";
|
|
653
|
+
const mod = await import(specifier);
|
|
654
|
+
return isContextRuntime(mod.Context) ? mod.Context : void 0;
|
|
655
|
+
} catch {
|
|
656
|
+
return void 0;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
__name(resolveContextRuntime, "resolveContextRuntime");
|
|
660
|
+
function isControlPlane(x) {
|
|
661
|
+
return !!x && typeof x.publishControl === "function" && typeof x.onControl === "function";
|
|
662
|
+
}
|
|
663
|
+
__name(isControlPlane, "isControlPlane");
|
|
664
|
+
var DurableModule = class _DurableModule {
|
|
665
|
+
static {
|
|
666
|
+
__name(this, "DurableModule");
|
|
667
|
+
}
|
|
668
|
+
static forRoot(options) {
|
|
669
|
+
return _DurableModule.build({
|
|
670
|
+
provide: import_nestjs_durable_core7.DURABLE_OPTIONS,
|
|
671
|
+
useValue: options
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
static forRootAsync(options) {
|
|
675
|
+
return _DurableModule.build({
|
|
676
|
+
provide: import_nestjs_durable_core7.DURABLE_OPTIONS,
|
|
677
|
+
useFactory: options.useFactory,
|
|
678
|
+
inject: options.inject ?? []
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
static build(optionsProvider) {
|
|
682
|
+
return {
|
|
683
|
+
module: _DurableModule,
|
|
684
|
+
global: true,
|
|
685
|
+
imports: [
|
|
686
|
+
import_core3.DiscoveryModule
|
|
687
|
+
],
|
|
688
|
+
providers: [
|
|
689
|
+
optionsProvider,
|
|
690
|
+
{
|
|
691
|
+
provide: import_nestjs_durable_core7.STATE_STORE,
|
|
692
|
+
useFactory: /* @__PURE__ */ __name((options) => options.store, "useFactory"),
|
|
693
|
+
inject: [
|
|
694
|
+
import_nestjs_durable_core7.DURABLE_OPTIONS
|
|
695
|
+
]
|
|
696
|
+
},
|
|
697
|
+
{
|
|
698
|
+
provide: import_nestjs_durable_core7.TRANSPORT,
|
|
699
|
+
useFactory: /* @__PURE__ */ __name((options) => options.transport ?? null, "useFactory"),
|
|
700
|
+
inject: [
|
|
701
|
+
import_nestjs_durable_core7.DURABLE_OPTIONS
|
|
702
|
+
]
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
provide: import_nestjs_durable_core7.WorkflowEngine,
|
|
706
|
+
useFactory: /* @__PURE__ */ __name(async (store, transport, opts, moduleRef) => {
|
|
707
|
+
const primary = transport ?? opts.transports?.[0]?.transport;
|
|
708
|
+
const accessor = resolveAccessor(moduleRef);
|
|
709
|
+
const context = opts.context ?? (accessor ? () => carrierFromAccessor(accessor) : void 0);
|
|
710
|
+
const runtime = accessor ? await resolveContextRuntime() : void 0;
|
|
711
|
+
const rehydrate = runtime && ((carrier, fn) => carrier && Object.keys(carrier).length > 0 ? runtime.deserialize(carrier, fn) : fn());
|
|
712
|
+
const engine = new import_nestjs_durable_core7.WorkflowEngine({
|
|
713
|
+
store,
|
|
714
|
+
transport: transport ?? void 0,
|
|
715
|
+
transports: opts.transports,
|
|
716
|
+
controlPlane: opts.controlPlane ?? (isControlPlane(primary) ? primary : void 0),
|
|
717
|
+
leaseMs: opts.leaseMs,
|
|
718
|
+
admission: opts.admission,
|
|
719
|
+
maxRecoveryAttempts: opts.maxRecoveryAttempts,
|
|
720
|
+
instanceId: opts.instanceId,
|
|
721
|
+
webhookUrl: opts.webhookUrl,
|
|
722
|
+
traceparent: opts.traceparent,
|
|
723
|
+
context,
|
|
724
|
+
rehydrate: rehydrate || void 0,
|
|
725
|
+
compensationRetries: opts.compensationRetries,
|
|
726
|
+
// A non-worker (API/dashboard) instance must not run workflows: enqueue-only, leaving
|
|
727
|
+
// each `pending` run in the store for a worker's `runPending` poll. Workers use the
|
|
728
|
+
// default in-process dispatcher (execute locally).
|
|
729
|
+
runDispatcher: opts.worker === false ? {
|
|
730
|
+
dispatch: /* @__PURE__ */ __name(() => {
|
|
731
|
+
}, "dispatch")
|
|
732
|
+
} : void 0
|
|
733
|
+
});
|
|
734
|
+
for (const queue of opts.queues ?? []) engine.registerQueue(queue);
|
|
735
|
+
return engine;
|
|
736
|
+
}, "useFactory"),
|
|
737
|
+
inject: [
|
|
738
|
+
import_nestjs_durable_core7.STATE_STORE,
|
|
739
|
+
import_nestjs_durable_core7.TRANSPORT,
|
|
740
|
+
import_nestjs_durable_core7.DURABLE_OPTIONS,
|
|
741
|
+
import_core3.ModuleRef
|
|
742
|
+
]
|
|
743
|
+
},
|
|
744
|
+
WorkflowService,
|
|
745
|
+
EntityService,
|
|
746
|
+
WorkflowRegistrar,
|
|
747
|
+
DurableStepRegistrar,
|
|
748
|
+
TimerPoller
|
|
749
|
+
],
|
|
750
|
+
exports: [
|
|
751
|
+
WorkflowService,
|
|
752
|
+
EntityService,
|
|
753
|
+
import_nestjs_durable_core7.WorkflowEngine,
|
|
754
|
+
import_nestjs_durable_core7.STATE_STORE,
|
|
755
|
+
import_nestjs_durable_core7.TRANSPORT
|
|
756
|
+
]
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
};
|
|
760
|
+
DurableModule = _ts_decorate6([
|
|
761
|
+
(0, import_common6.Module)({})
|
|
762
|
+
], DurableModule);
|
|
763
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
764
|
+
0 && (module.exports = {
|
|
765
|
+
CONTEXT_ACCESSOR,
|
|
766
|
+
DEAD_LETTER_METADATA,
|
|
767
|
+
DURABLE_STEP_METADATA,
|
|
768
|
+
DeadLetter,
|
|
769
|
+
DurableModule,
|
|
770
|
+
DurableStep,
|
|
771
|
+
ENTITY_METADATA,
|
|
772
|
+
ENTITY_ON_METADATA,
|
|
773
|
+
Entity,
|
|
774
|
+
EntityService,
|
|
775
|
+
ON_EVENT_METADATA,
|
|
776
|
+
On,
|
|
777
|
+
OnEvent,
|
|
778
|
+
STEP_INTERCEPTOR_METADATA,
|
|
779
|
+
StepInterceptor,
|
|
780
|
+
WORKFLOW_METADATA,
|
|
781
|
+
Workflow,
|
|
782
|
+
WorkflowService,
|
|
783
|
+
entityConfigFor,
|
|
784
|
+
getDurableStepMeta,
|
|
785
|
+
getEntityMeta,
|
|
786
|
+
getOnEvents,
|
|
787
|
+
getWorkflowMeta,
|
|
788
|
+
isDeadLetterHandler,
|
|
789
|
+
isStepInterceptor
|
|
790
|
+
});
|
|
791
|
+
//# sourceMappingURL=index.cjs.map
|