@dudousxd/nestjs-durable 0.36.0 → 0.38.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.d.cts CHANGED
@@ -129,6 +129,9 @@ interface WorkflowMeta {
129
129
  maxSize: number;
130
130
  within: string | number;
131
131
  } | undefined;
132
+ /** Capabilities a live worker must advertise to run this workflow's turns (handshake §7.5). See
133
+ * `WorkflowOptions`. */
134
+ requires?: string[] | undefined;
132
135
  }
133
136
  interface WorkflowOptions {
134
137
  name: string;
@@ -159,6 +162,14 @@ interface WorkflowOptions {
159
162
  * runs that get stuck or loop forever. Omit for no limit.
160
163
  */
161
164
  executionTimeout?: string | number;
165
+ /**
166
+ * Capabilities a live worker MUST advertise to run this workflow's turns (handshake design §7.5).
167
+ * Only meaningful for a group-served / remote workflow (an in-app worker or a cross-runtime body):
168
+ * the control-plane dispatches a turn only to a capability-capable + protocol-compatible worker, and
169
+ * if descriptors are published on its group but none qualifies the run parks `blocked` until the
170
+ * recovery poll finds one. Absent/empty = "runs anywhere" (a legacy fleet skips the guard, §7.7).
171
+ */
172
+ requires?: string[];
162
173
  /**
163
174
  * Validate the workflow input at `start` against a **class-validator DTO** (the same
164
175
  * `plainToInstance` + `validate` NestJS runs in controllers) — invalid input is rejected before any
@@ -266,6 +277,15 @@ interface StepOptions {
266
277
  * `retries`). Omit to wait indefinitely.
267
278
  */
268
279
  timeoutMs?: number;
280
+ /**
281
+ * Capabilities a live worker MUST advertise to run this step (handshake design §7.5). The
282
+ * control-plane routes the step only to workers whose descriptor advertises every name here; if
283
+ * descriptors are published on the step's group but none is capability-capable + protocol-compatible,
284
+ * the run parks `blocked` (never a silent hang) until the recovery poll finds one. Absent/empty =
285
+ * "runs anywhere" (the default — a legacy fleet publishing no descriptors skips the guard, §7.7). A
286
+ * per-call `ctx.step(ref, input, { requires })` overrides this.
287
+ */
288
+ requires?: string[];
269
289
  }
270
290
  /**
271
291
  * Marks a provider method as a durable step handler. An in-process transport (e.g. the
@@ -1040,13 +1060,16 @@ declare class TenantEventRepublisher {
1040
1060
  */
1041
1061
  declare const CONTEXT_ACCESSOR: unique symbol;
1042
1062
  /**
1043
- * Injection token for the bound `RunGateway` — the read/control surface a consumer (a controller,
1044
- * or the `RunRequestResponder`) uses instead of reaching for `WorkflowEngine`/`StateStore`
1045
- * directly. `DurableModule` binds it to `StoreRunGateway` on worker/drive (operator) instances.
1046
- * `Symbol.for` so re-resolving this module (e.g. across a dynamic-module boundary) still hits the
1047
- * same registration.
1063
+ * @deprecated Inject the `RunGateway` abstract class directly (it is its own DI token now):
1064
+ * `constructor(private readonly gateway: RunGateway)`, provider `{ provide: RunGateway, useClass }`.
1065
+ * This symbol is kept as a back-compat alias — it points at the `RunGateway` class, so existing
1066
+ * `@Inject(RUN_GATEWAY)` sites resolve the very same token — and will be removed in a future major.
1067
+ *
1068
+ * `RunGateway` is owned by `@dudousxd/nestjs-durable-core` (a required peer dep of both this package
1069
+ * and the dashboard), so the abstract class is a single shared token across packages without the
1070
+ * previous `Symbol.for` value-sharing hack.
1048
1071
  */
1049
- declare const RUN_GATEWAY: unique symbol;
1072
+ declare const RUN_GATEWAY: typeof RunGateway;
1050
1073
 
1051
1074
  /** Public entry point for starting and resuming workflow runs. */
1052
1075
  declare class WorkflowService {
package/dist/index.d.ts CHANGED
@@ -129,6 +129,9 @@ interface WorkflowMeta {
129
129
  maxSize: number;
130
130
  within: string | number;
131
131
  } | undefined;
132
+ /** Capabilities a live worker must advertise to run this workflow's turns (handshake §7.5). See
133
+ * `WorkflowOptions`. */
134
+ requires?: string[] | undefined;
132
135
  }
133
136
  interface WorkflowOptions {
134
137
  name: string;
@@ -159,6 +162,14 @@ interface WorkflowOptions {
159
162
  * runs that get stuck or loop forever. Omit for no limit.
160
163
  */
161
164
  executionTimeout?: string | number;
165
+ /**
166
+ * Capabilities a live worker MUST advertise to run this workflow's turns (handshake design §7.5).
167
+ * Only meaningful for a group-served / remote workflow (an in-app worker or a cross-runtime body):
168
+ * the control-plane dispatches a turn only to a capability-capable + protocol-compatible worker, and
169
+ * if descriptors are published on its group but none qualifies the run parks `blocked` until the
170
+ * recovery poll finds one. Absent/empty = "runs anywhere" (a legacy fleet skips the guard, §7.7).
171
+ */
172
+ requires?: string[];
162
173
  /**
163
174
  * Validate the workflow input at `start` against a **class-validator DTO** (the same
164
175
  * `plainToInstance` + `validate` NestJS runs in controllers) — invalid input is rejected before any
@@ -266,6 +277,15 @@ interface StepOptions {
266
277
  * `retries`). Omit to wait indefinitely.
267
278
  */
268
279
  timeoutMs?: number;
280
+ /**
281
+ * Capabilities a live worker MUST advertise to run this step (handshake design §7.5). The
282
+ * control-plane routes the step only to workers whose descriptor advertises every name here; if
283
+ * descriptors are published on the step's group but none is capability-capable + protocol-compatible,
284
+ * the run parks `blocked` (never a silent hang) until the recovery poll finds one. Absent/empty =
285
+ * "runs anywhere" (the default — a legacy fleet publishing no descriptors skips the guard, §7.7). A
286
+ * per-call `ctx.step(ref, input, { requires })` overrides this.
287
+ */
288
+ requires?: string[];
269
289
  }
270
290
  /**
271
291
  * Marks a provider method as a durable step handler. An in-process transport (e.g. the
@@ -1040,13 +1060,16 @@ declare class TenantEventRepublisher {
1040
1060
  */
1041
1061
  declare const CONTEXT_ACCESSOR: unique symbol;
1042
1062
  /**
1043
- * Injection token for the bound `RunGateway` — the read/control surface a consumer (a controller,
1044
- * or the `RunRequestResponder`) uses instead of reaching for `WorkflowEngine`/`StateStore`
1045
- * directly. `DurableModule` binds it to `StoreRunGateway` on worker/drive (operator) instances.
1046
- * `Symbol.for` so re-resolving this module (e.g. across a dynamic-module boundary) still hits the
1047
- * same registration.
1063
+ * @deprecated Inject the `RunGateway` abstract class directly (it is its own DI token now):
1064
+ * `constructor(private readonly gateway: RunGateway)`, provider `{ provide: RunGateway, useClass }`.
1065
+ * This symbol is kept as a back-compat alias — it points at the `RunGateway` class, so existing
1066
+ * `@Inject(RUN_GATEWAY)` sites resolve the very same token — and will be removed in a future major.
1067
+ *
1068
+ * `RunGateway` is owned by `@dudousxd/nestjs-durable-core` (a required peer dep of both this package
1069
+ * and the dashboard), so the abstract class is a single shared token across packages without the
1070
+ * previous `Symbol.for` value-sharing hack.
1048
1071
  */
1049
- declare const RUN_GATEWAY: unique symbol;
1072
+ declare const RUN_GATEWAY: typeof RunGateway;
1050
1073
 
1051
1074
  /** Public entry point for starting and resuming workflow runs. */
1052
1075
  declare class WorkflowService {
package/dist/index.js CHANGED
@@ -28,7 +28,8 @@ function Workflow(options) {
28
28
  searchAttributes: options.searchAttributes,
29
29
  onEvent: options.onEvent,
30
30
  debounce: options.debounce,
31
- batch: options.batch
31
+ batch: options.batch,
32
+ requires: options.requires
32
33
  };
33
34
  Reflect.defineMetadata(WORKFLOW_METADATA, meta, target);
34
35
  Object.defineProperty(target, WORKFLOW_NAME_KEY, {
@@ -50,7 +51,8 @@ function stepConfigFrom(options) {
50
51
  backoffMs: options.backoffMs,
51
52
  backoffMaxMs: options.backoffMaxMs,
52
53
  jitter: options.jitter,
53
- timeoutMs: options.timeoutMs
54
+ timeoutMs: options.timeoutMs,
55
+ requires: options.requires
54
56
  };
55
57
  const hasAnyField = Object.values(config).some((value) => value !== void 0);
56
58
  return hasAnyField ? config : void 0;
@@ -482,7 +484,7 @@ function unavailableRunGateway() {
482
484
  __name(unavailableRunGateway, "unavailableRunGateway");
483
485
 
484
486
  // src/durable.module.ts
485
- import { DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL7, STATE_STORE, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL4, TRANSPORT, TRANSPORT_CANONICAL as TRANSPORT_CANONICAL3, WorkflowEngine as WorkflowEngine6 } from "@dudousxd/nestjs-durable-core";
487
+ import { DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL as DURABLE_OPTIONS_CANONICAL7, RunGateway as RunGateway2, STATE_STORE, STATE_STORE_CANONICAL as STATE_STORE_CANONICAL4, TRANSPORT, TRANSPORT_CANONICAL as TRANSPORT_CANONICAL3, WorkflowEngine as WorkflowEngine6 } from "@dudousxd/nestjs-durable-core";
486
488
  import { Inject as Inject8, Injectable as Injectable12, Module } from "@nestjs/common";
487
489
  import { DiscoveryModule, ModuleRef } from "@nestjs/core";
488
490
 
@@ -1416,8 +1418,9 @@ TimerPoller = _ts_decorate9([
1416
1418
  ], TimerPoller);
1417
1419
 
1418
1420
  // src/tokens.ts
1421
+ import { RunGateway } from "@dudousxd/nestjs-durable-core";
1419
1422
  var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
1420
- var RUN_GATEWAY = Symbol.for("nestjs-durable:run-gateway");
1423
+ var RUN_GATEWAY = RunGateway;
1421
1424
 
1422
1425
  // src/workflow.registrar.ts
1423
1426
  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";
@@ -1553,6 +1556,7 @@ var WorkflowRegistrar = class {
1553
1556
  tags: meta.tags,
1554
1557
  singleton: meta.singleton,
1555
1558
  executionTimeout: meta.executionTimeout,
1559
+ requires: meta.requires,
1556
1560
  validateInput,
1557
1561
  searchAttributesSchema: meta.searchAttributes,
1558
1562
  onEvent: getOnEvents(meta, workflowCtor),
@@ -1883,14 +1887,13 @@ var RunGatewayBootstrap = class RunGatewayBootstrap2 {
1883
1887
  RunGatewayBootstrap = _ts_decorate12([
1884
1888
  Injectable12(),
1885
1889
  _ts_param8(1, Inject8(TRANSPORT_CANONICAL3)),
1886
- _ts_param8(2, Inject8(RUN_GATEWAY)),
1887
1890
  _ts_param8(3, Inject8(STATE_STORE_CANONICAL4)),
1888
1891
  _ts_param8(4, Inject8(DURABLE_OPTIONS_CANONICAL7)),
1889
1892
  _ts_metadata12("design:type", Function),
1890
1893
  _ts_metadata12("design:paramtypes", [
1891
1894
  typeof WorkflowEngine6 === "undefined" ? Object : WorkflowEngine6,
1892
1895
  Object,
1893
- typeof RunGateway === "undefined" ? Object : RunGateway,
1896
+ typeof RunGateway2 === "undefined" ? Object : RunGateway2,
1894
1897
  Object,
1895
1898
  typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
1896
1899
  ])
@@ -2035,7 +2038,7 @@ var DurableModule = class _DurableModule {
2035
2038
  // or (for a thin worker, no `store`) a `ProxyRunGateway` over `transport` when given, else a
2036
2039
  // gateway whose every method rejects with a clear tenant error.
2037
2040
  {
2038
- provide: RUN_GATEWAY,
2041
+ provide: RunGateway2,
2039
2042
  useFactory: /* @__PURE__ */ __name((options, store, engine) => {
2040
2043
  if (options.store !== void 0) {
2041
2044
  if (!store) {
@@ -2068,7 +2071,7 @@ var DurableModule = class _DurableModule {
2068
2071
  TRANSPORT,
2069
2072
  TRANSPORT_CANONICAL3,
2070
2073
  DURABLE_OPTIONS_CANONICAL7,
2071
- RUN_GATEWAY
2074
+ RunGateway2
2072
2075
  ]
2073
2076
  };
2074
2077
  }