@dudousxd/nestjs-durable 0.27.0 → 0.28.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 +10 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -7
- package/dist/index.d.ts +12 -7
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -106,7 +106,7 @@ interface WorkflowOptions {
|
|
|
106
106
|
* Start a fresh run of this workflow whenever any of these events is published via
|
|
107
107
|
* `publishEvent(name, payload)` — the payload becomes the run's input. e.g.
|
|
108
108
|
* `onEvent: ['user.registered', 'user.invited']`. The same subscription can also be declared with
|
|
109
|
-
* the `@
|
|
109
|
+
* the `@OnDurableEvent(...)` class decorator; the two are merged.
|
|
110
110
|
*/
|
|
111
111
|
onEvent?: string[];
|
|
112
112
|
/**
|
|
@@ -234,11 +234,16 @@ declare const ON_EVENT_METADATA: unique symbol;
|
|
|
234
234
|
/**
|
|
235
235
|
* Subscribe a `@Workflow` class to one or more events: when any of them is published via
|
|
236
236
|
* `publishEvent(name, payload)`, a fresh run of the workflow starts with the payload as input.
|
|
237
|
-
* Equivalent to `@Workflow({ onEvent })` — use whichever reads better; multiple
|
|
238
|
-
* decorators and the option are all merged.
|
|
237
|
+
* Equivalent to `@Workflow({ onEvent })` — use whichever reads better; multiple
|
|
238
|
+
* `@OnDurableEvent(...)` decorators and the option are all merged.
|
|
239
|
+
*
|
|
240
|
+
* Named "durable" on purpose: `@nestjs/event-emitter` exports an `@OnEvent` decorator, and in an
|
|
241
|
+
* app using both libs an auto-import picking the wrong one fails silently in either direction.
|
|
239
242
|
*/
|
|
240
|
-
declare function
|
|
241
|
-
/**
|
|
243
|
+
declare function OnDurableEvent(...events: string[]): ClassDecorator;
|
|
244
|
+
/** @deprecated Renamed to `OnDurableEvent` — this alias clashes with `@nestjs/event-emitter`'s `@OnEvent` and will be removed in the next minor. */
|
|
245
|
+
declare const OnEvent: typeof OnDurableEvent;
|
|
246
|
+
/** All events a workflow class subscribes to — the union of `@Workflow({ onEvent })` and `@OnDurableEvent`. */
|
|
242
247
|
declare function getOnEvents(meta: WorkflowMeta, target: object): string[];
|
|
243
248
|
|
|
244
249
|
/**
|
|
@@ -901,7 +906,7 @@ declare class WorkflowService {
|
|
|
901
906
|
}>;
|
|
902
907
|
/**
|
|
903
908
|
* Publish a named event. Resumes runs waiting on it via `ctx.waitForEvent(name, { match })` and
|
|
904
|
-
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@
|
|
909
|
+
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
|
|
905
910
|
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
906
911
|
* touched (resumed + started).
|
|
907
912
|
*/
|
|
@@ -910,4 +915,4 @@ declare class WorkflowService {
|
|
|
910
915
|
}): Promise<number>;
|
|
911
916
|
}
|
|
912
917
|
|
|
913
|
-
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
|
|
918
|
+
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnDurableEvent, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
|
package/dist/index.d.ts
CHANGED
|
@@ -106,7 +106,7 @@ interface WorkflowOptions {
|
|
|
106
106
|
* Start a fresh run of this workflow whenever any of these events is published via
|
|
107
107
|
* `publishEvent(name, payload)` — the payload becomes the run's input. e.g.
|
|
108
108
|
* `onEvent: ['user.registered', 'user.invited']`. The same subscription can also be declared with
|
|
109
|
-
* the `@
|
|
109
|
+
* the `@OnDurableEvent(...)` class decorator; the two are merged.
|
|
110
110
|
*/
|
|
111
111
|
onEvent?: string[];
|
|
112
112
|
/**
|
|
@@ -234,11 +234,16 @@ declare const ON_EVENT_METADATA: unique symbol;
|
|
|
234
234
|
/**
|
|
235
235
|
* Subscribe a `@Workflow` class to one or more events: when any of them is published via
|
|
236
236
|
* `publishEvent(name, payload)`, a fresh run of the workflow starts with the payload as input.
|
|
237
|
-
* Equivalent to `@Workflow({ onEvent })` — use whichever reads better; multiple
|
|
238
|
-
* decorators and the option are all merged.
|
|
237
|
+
* Equivalent to `@Workflow({ onEvent })` — use whichever reads better; multiple
|
|
238
|
+
* `@OnDurableEvent(...)` decorators and the option are all merged.
|
|
239
|
+
*
|
|
240
|
+
* Named "durable" on purpose: `@nestjs/event-emitter` exports an `@OnEvent` decorator, and in an
|
|
241
|
+
* app using both libs an auto-import picking the wrong one fails silently in either direction.
|
|
239
242
|
*/
|
|
240
|
-
declare function
|
|
241
|
-
/**
|
|
243
|
+
declare function OnDurableEvent(...events: string[]): ClassDecorator;
|
|
244
|
+
/** @deprecated Renamed to `OnDurableEvent` — this alias clashes with `@nestjs/event-emitter`'s `@OnEvent` and will be removed in the next minor. */
|
|
245
|
+
declare const OnEvent: typeof OnDurableEvent;
|
|
246
|
+
/** All events a workflow class subscribes to — the union of `@Workflow({ onEvent })` and `@OnDurableEvent`. */
|
|
242
247
|
declare function getOnEvents(meta: WorkflowMeta, target: object): string[];
|
|
243
248
|
|
|
244
249
|
/**
|
|
@@ -901,7 +906,7 @@ declare class WorkflowService {
|
|
|
901
906
|
}>;
|
|
902
907
|
/**
|
|
903
908
|
* Publish a named event. Resumes runs waiting on it via `ctx.waitForEvent(name, { match })` and
|
|
904
|
-
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@
|
|
909
|
+
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
|
|
905
910
|
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
906
911
|
* touched (resumed + started).
|
|
907
912
|
*/
|
|
@@ -910,4 +915,4 @@ declare class WorkflowService {
|
|
|
910
915
|
}): Promise<number>;
|
|
911
916
|
}
|
|
912
917
|
|
|
913
|
-
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
|
|
918
|
+
export { CONTEXT_ACCESSOR, type ContextAccessor, type ContextStore, DEAD_LETTER_METADATA, DURABLE_STEP_METADATA, DURABLE_WORKER_RUNNERS, DeadLetter, DurableModule, type DurableModuleAsyncOptions, type DurableModuleOptions, type DurableRetentionOptions, DurableStartClient, DurableStep, type DurableStepInterceptor, type DurableStepMeta, ENTITY_METADATA, ENTITY_ON_METADATA, Entity, EntityService, IN_APP_RUN_REDIS_WORKER, IN_APP_WORKER_BINDING, IN_APP_WORKER_RUNNERS, IN_APP_WORKER_RUNTIME, type InAppWorkerBinding, InAppWorkerBootstrap, ON_EVENT_METADATA, On, OnDurableEvent, OnEvent, ProxyRunGateway, RUN_GATEWAY, RUN_REDIS_WORKER, type RunLookupStore, type RunRedisWorkerFn, RunRequestResponder, type RunRequestTransport, STEP_INTERCEPTOR_METADATA, Step, StepInterceptor, type StepOptions, StoreRunGateway, TenantEventRepublisher, ThinStepRegistrar, ThinWorkerBootstrap, ThinWorkflowRegistrar, type UserRef, WORKFLOW_METADATA, Workflow, type WorkflowMeta, type WorkflowOptions, WorkflowService, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
|
package/dist/index.js
CHANGED
|
@@ -91,7 +91,7 @@ function isDeadLetterHandler(method) {
|
|
|
91
91
|
}
|
|
92
92
|
__name(isDeadLetterHandler, "isDeadLetterHandler");
|
|
93
93
|
var ON_EVENT_METADATA = Symbol("nestjs-durable:on-event");
|
|
94
|
-
function
|
|
94
|
+
function OnDurableEvent(...events) {
|
|
95
95
|
return (target) => {
|
|
96
96
|
const existing = Reflect.getMetadata(ON_EVENT_METADATA, target) ?? [];
|
|
97
97
|
Reflect.defineMetadata(ON_EVENT_METADATA, [
|
|
@@ -100,7 +100,8 @@ function OnEvent(...events) {
|
|
|
100
100
|
], target);
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
__name(
|
|
103
|
+
__name(OnDurableEvent, "OnDurableEvent");
|
|
104
|
+
var OnEvent = OnDurableEvent;
|
|
104
105
|
function getOnEvents(meta, target) {
|
|
105
106
|
const fromDecorator = Reflect.getMetadata(ON_EVENT_METADATA, target) ?? [];
|
|
106
107
|
return [
|
|
@@ -1274,7 +1275,7 @@ var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
|
1274
1275
|
var RUN_GATEWAY = Symbol.for("nestjs-durable:run-gateway");
|
|
1275
1276
|
|
|
1276
1277
|
// src/workflow.registrar.ts
|
|
1277
|
-
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL6, RemoteWorkflowExecutor, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL3, WorkflowEngine as WorkflowEngine4, parseDuration as parseDuration2, sanitizeQueueToken, tenantGroup, workflowName as workflowName2 } from "@dudousxd/nestjs-durable-core";
|
|
1278
|
+
import { DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL6, RemoteWorkflowExecutor, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL3, WorkflowEngine as WorkflowEngine4, bindWorkflowClass, parseDuration as parseDuration2, sanitizeQueueToken, tenantGroup, workflowName as workflowName2 } from "@dudousxd/nestjs-durable-core";
|
|
1278
1279
|
import { Inject as Inject7, Injectable as Injectable10 } from "@nestjs/common";
|
|
1279
1280
|
import { DiscoveryService as DiscoveryService4, MetadataScanner as MetadataScanner4 } from "@nestjs/core";
|
|
1280
1281
|
|
|
@@ -1424,6 +1425,10 @@ var WorkflowRegistrar = class {
|
|
|
1424
1425
|
executor: new RemoteWorkflowExecutor(this.inAppWorker.transport, meta.name, this.inAppWorker.partition)
|
|
1425
1426
|
} : {}
|
|
1426
1427
|
});
|
|
1428
|
+
bindWorkflowClass(workflowCtor, {
|
|
1429
|
+
start: /* @__PURE__ */ __name((name, input, runId, opts) => this.engine.start(name, input, runId, opts), "start"),
|
|
1430
|
+
waitForRun: /* @__PURE__ */ __name((runId, opts) => this.engine.waitForRun(runId, opts), "waitForRun")
|
|
1431
|
+
});
|
|
1427
1432
|
const inline = this.findDeadLetterHandler(workflow);
|
|
1428
1433
|
if (inline && meta.deadLetterWorkflow) {
|
|
1429
1434
|
throw new Error(`@Workflow ${meta.name} declares both an inline @DeadLetter() method and a deadLetterWorkflow option. Use one: the inline handler, or the reference.`);
|
|
@@ -1540,7 +1545,7 @@ var WorkflowService = class {
|
|
|
1540
1545
|
}
|
|
1541
1546
|
/**
|
|
1542
1547
|
* Publish a named event. Resumes runs waiting on it via `ctx.waitForEvent(name, { match })` and
|
|
1543
|
-
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@
|
|
1548
|
+
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
|
|
1544
1549
|
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
1545
1550
|
* touched (resumed + started).
|
|
1546
1551
|
*/
|
|
@@ -1874,6 +1879,7 @@ export {
|
|
|
1874
1879
|
InAppWorkerBootstrap,
|
|
1875
1880
|
ON_EVENT_METADATA,
|
|
1876
1881
|
On,
|
|
1882
|
+
OnDurableEvent,
|
|
1877
1883
|
OnEvent,
|
|
1878
1884
|
ProxyRunGateway,
|
|
1879
1885
|
RUN_GATEWAY,
|