@dudousxd/nestjs-durable-core 0.90.1 → 0.91.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
@@ -1244,7 +1244,7 @@ declare namespace StandardSchemaV1 {
1244
1244
  * (pnpm peer-dependency multiplexing, or a dual ESM/CJS load) still reads the SAME key. A plain
1245
1245
  * `Symbol()` would mint a distinct token per copy, so a decorator running against one core instance
1246
1246
  * could stamp a name core's `ctx.step` (a different instance) can never read back. Mirrors the
1247
- * `STATE_STORE` token fix in `./tokens.ts`.
1247
+ * DI token fix in `./tokens.ts`.
1248
1248
  */
1249
1249
  declare const DURABLE_STEP_NAME: unique symbol;
1250
1250
  /**
@@ -4137,13 +4137,6 @@ declare function countRuns(store: StateStore, query: Omit<RunQuery, 'limit' | 'o
4137
4137
  */
4138
4138
  declare function assertConcurrency(store: StateStore, workflow: string, quota: ConcurrencyQuota): Promise<void>;
4139
4139
 
4140
- /**
4141
- * Back-compat alias of {@link WorkflowCtx}. `localStep` — the checkpointed in-process step primitive
4142
- * used for saga compensation — is now part of the public {@link WorkflowCtx}, so this type adds
4143
- * nothing; it is kept only so internal consumers (the durable-entity runner) keep compiling.
4144
- */
4145
- type InternalWorkflowCtx = WorkflowCtx;
4146
-
4147
4140
  /** One operation on a durable entity: mutate `state` in place and/or return a result. */
4148
4141
  type EntityHandler<S = unknown> = (state: S, arg: unknown) => unknown | Promise<unknown>;
4149
4142
  /** A durable keyed entity (a virtual object): per-key serialized handlers over durable state. */
@@ -4155,7 +4148,7 @@ interface EntityConfig<S = unknown> {
4155
4148
  }
4156
4149
  /** The slice of the engine the entity subsystem needs (so it stays a standalone module). */
4157
4150
  interface EntityHost {
4158
- register(name: string, version: string, fn: (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4151
+ register(name: string, version: string, fn: (ctx: WorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4159
4152
  origin?: string | undefined;
4160
4153
  }): void;
4161
4154
  signalWithStart(workflow: string, input: unknown, runId: string, signal: {
@@ -5283,7 +5276,7 @@ declare function resolveWireTenant(wireTenant: string, verifyTenant: TenantVerif
5283
5276
  /** Resolve a {@link TenantTokenSource} to the token string to put on the wire. */
5284
5277
  declare function resolveTenantToken(source: TenantTokenSource): Promise<string>;
5285
5278
 
5286
- type WorkflowFn = (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>;
5279
+ type WorkflowFn = (ctx: WorkflowCtx, input: unknown) => Promise<unknown>;
5287
5280
  /**
5288
5281
  * Options for {@link WorkflowEngine.start}.
5289
5282
  *
@@ -5583,7 +5576,7 @@ interface WorkflowEngineDeps {
5583
5576
  */
5584
5577
  context?: (() => Record<string, unknown> | undefined) | undefined;
5585
5578
  /**
5586
- * Re-hydrate the originating context around a LOCAL step body, so a `@DurableStep` reader sees the
5579
+ * Re-hydrate the originating context around a LOCAL step body, so a `@Step` reader sees the
5587
5580
  * tenant / user / correlation ids that were live when the run was started — even on a path the
5588
5581
  * engine drives outside the originating request scope (a resume after crash/scale-down, a timer).
5589
5582
  * Given the carrier produced by {@link context} (may be empty/undefined) and the step body `fn`, it
@@ -7306,7 +7299,7 @@ declare class WorkflowEngine {
7306
7299
  /** {@link getRunChildren} without the tenancy check (the engine's own subtree walks). */
7307
7300
  private runChildrenUnchecked;
7308
7301
  /** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
7309
- * `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
7302
+ * `extra` the caller declares. Local-step groups (a group consumed by in-process `@Step`
7310
7303
  * workers, e.g. `pipeline`) aren't derivable from registrations — pass them via `extra` so a group
7311
7304
  * with backlog and ZERO workers is still reported (the alert case has no heartbeat to discover). */
7312
7305
  knownGroups(extra?: string[]): string[];
@@ -8999,11 +8992,6 @@ interface ScheduledWorkflow<W extends WorkflowRef = WorkflowRef> {
8999
8992
  * `Math.random`; overridden in tests so jitter is deterministic. */
9000
8993
  interface RunSchedulesOptions {
9001
8994
  random?: () => number;
9002
- /**
9003
- * @deprecated No longer called: jitter defers a window to a later tick instead of sleeping inside
9004
- * this one. Kept so existing callers still type-check.
9005
- */
9006
- sleep?: (ms: number) => Promise<void>;
9007
8995
  }
9008
8996
  /** Deterministic run id for a fixed-interval schedule's current time window. */
9009
8997
  declare function scheduledRunId(key: string, everyMs: number, nowMs: number): string;
@@ -9175,35 +9163,33 @@ declare function sanitizeQueueToken(name: string): string;
9175
9163
  * `import` (`index.js`) and once as `require` (`index.cjs`). A plain `Symbol()` would mint a
9176
9164
  * DISTINCT token per copy, so `DurableModule` (provider) and `DashboardService` / a store adapter
9177
9165
  * (injector) could resolve different symbols → Nest can't satisfy the dependency
9178
- * (`STATE_STORE is not available in the DurableApiModule context`). A registered symbol collapses
9166
+ * (`<token> is not available in the DurableApiModule context`). A registered symbol collapses
9179
9167
  * them to one. Mirrors the `CONTEXT_ACCESSOR` token in `@dudousxd/nestjs-durable`'s `tokens.ts`.
9180
9168
  */
9181
9169
  /**
9182
- * @deprecated Use {@link STATE_STORE_CANONICAL} (`@dudousxd/nestjs-durable:state-store`). The legacy
9183
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9170
+ * The durable DI tokens, following the ecosystem capability naming `@dudousxd/nestjs-durable:<name>`
9171
+ * (identical to `capability('durable', <name>)`), so an external library can resolve durable's
9172
+ * store/transport/options by name without importing durable internals. Bare `Symbol.for` keeps
9173
+ * `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9174
+ */
9175
+ declare const STATE_STORE_CANONICAL: unique symbol;
9176
+ declare const TRANSPORT_CANONICAL: unique symbol;
9177
+ declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9178
+ /**
9179
+ * @deprecated Use {@link STATE_STORE_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9180
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9184
9181
  */
9185
9182
  declare const STATE_STORE: unique symbol;
9186
9183
  /**
9187
- * @deprecated Use {@link TRANSPORT_CANONICAL} (`@dudousxd/nestjs-durable:transport`). The legacy
9188
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9184
+ * @deprecated Use {@link TRANSPORT_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9185
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9189
9186
  */
9190
9187
  declare const TRANSPORT: unique symbol;
9191
9188
  /**
9192
- * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL} (`@dudousxd/nestjs-durable:options`). The legacy
9193
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9189
+ * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9190
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9194
9191
  */
9195
9192
  declare const DURABLE_OPTIONS: unique symbol;
9196
- /**
9197
- * Canonical, cross-lib-discoverable aliases of the durable DI tokens, following the ecosystem
9198
- * capability naming `@dudousxd/nestjs-durable:<name>` (identical to `capability('durable', <name>)`).
9199
- * `DurableModule` binds these alongside the legacy tokens (dual-bind), so an external library can
9200
- * resolve durable's store/transport/options by the canonical name without importing durable
9201
- * internals. Bare `Symbol.for` (same cross-copy-stability rationale as the legacy tokens above)
9202
- * keeps `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9203
- */
9204
- declare const STATE_STORE_CANONICAL: unique symbol;
9205
- declare const TRANSPORT_CANONICAL: unique symbol;
9206
- declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9207
9193
 
9208
9194
  /**
9209
9195
  * The OPT-IN declaration-site contract for a `@Workflow` class: `implements WorkflowHandler<TInput,
package/dist/index.d.ts CHANGED
@@ -1244,7 +1244,7 @@ declare namespace StandardSchemaV1 {
1244
1244
  * (pnpm peer-dependency multiplexing, or a dual ESM/CJS load) still reads the SAME key. A plain
1245
1245
  * `Symbol()` would mint a distinct token per copy, so a decorator running against one core instance
1246
1246
  * could stamp a name core's `ctx.step` (a different instance) can never read back. Mirrors the
1247
- * `STATE_STORE` token fix in `./tokens.ts`.
1247
+ * DI token fix in `./tokens.ts`.
1248
1248
  */
1249
1249
  declare const DURABLE_STEP_NAME: unique symbol;
1250
1250
  /**
@@ -4137,13 +4137,6 @@ declare function countRuns(store: StateStore, query: Omit<RunQuery, 'limit' | 'o
4137
4137
  */
4138
4138
  declare function assertConcurrency(store: StateStore, workflow: string, quota: ConcurrencyQuota): Promise<void>;
4139
4139
 
4140
- /**
4141
- * Back-compat alias of {@link WorkflowCtx}. `localStep` — the checkpointed in-process step primitive
4142
- * used for saga compensation — is now part of the public {@link WorkflowCtx}, so this type adds
4143
- * nothing; it is kept only so internal consumers (the durable-entity runner) keep compiling.
4144
- */
4145
- type InternalWorkflowCtx = WorkflowCtx;
4146
-
4147
4140
  /** One operation on a durable entity: mutate `state` in place and/or return a result. */
4148
4141
  type EntityHandler<S = unknown> = (state: S, arg: unknown) => unknown | Promise<unknown>;
4149
4142
  /** A durable keyed entity (a virtual object): per-key serialized handlers over durable state. */
@@ -4155,7 +4148,7 @@ interface EntityConfig<S = unknown> {
4155
4148
  }
4156
4149
  /** The slice of the engine the entity subsystem needs (so it stays a standalone module). */
4157
4150
  interface EntityHost {
4158
- register(name: string, version: string, fn: (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4151
+ register(name: string, version: string, fn: (ctx: WorkflowCtx, input: unknown) => Promise<unknown>, opts?: {
4159
4152
  origin?: string | undefined;
4160
4153
  }): void;
4161
4154
  signalWithStart(workflow: string, input: unknown, runId: string, signal: {
@@ -5283,7 +5276,7 @@ declare function resolveWireTenant(wireTenant: string, verifyTenant: TenantVerif
5283
5276
  /** Resolve a {@link TenantTokenSource} to the token string to put on the wire. */
5284
5277
  declare function resolveTenantToken(source: TenantTokenSource): Promise<string>;
5285
5278
 
5286
- type WorkflowFn = (ctx: InternalWorkflowCtx, input: unknown) => Promise<unknown>;
5279
+ type WorkflowFn = (ctx: WorkflowCtx, input: unknown) => Promise<unknown>;
5287
5280
  /**
5288
5281
  * Options for {@link WorkflowEngine.start}.
5289
5282
  *
@@ -5583,7 +5576,7 @@ interface WorkflowEngineDeps {
5583
5576
  */
5584
5577
  context?: (() => Record<string, unknown> | undefined) | undefined;
5585
5578
  /**
5586
- * Re-hydrate the originating context around a LOCAL step body, so a `@DurableStep` reader sees the
5579
+ * Re-hydrate the originating context around a LOCAL step body, so a `@Step` reader sees the
5587
5580
  * tenant / user / correlation ids that were live when the run was started — even on a path the
5588
5581
  * engine drives outside the originating request scope (a resume after crash/scale-down, a timer).
5589
5582
  * Given the carrier produced by {@link context} (may be empty/undefined) and the step body `fn`, it
@@ -7306,7 +7299,7 @@ declare class WorkflowEngine {
7306
7299
  /** {@link getRunChildren} without the tenancy check (the engine's own subtree walks). */
7307
7300
  private runChildrenUnchecked;
7308
7301
  /** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
7309
- * `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
7302
+ * `extra` the caller declares. Local-step groups (a group consumed by in-process `@Step`
7310
7303
  * workers, e.g. `pipeline`) aren't derivable from registrations — pass them via `extra` so a group
7311
7304
  * with backlog and ZERO workers is still reported (the alert case has no heartbeat to discover). */
7312
7305
  knownGroups(extra?: string[]): string[];
@@ -8999,11 +8992,6 @@ interface ScheduledWorkflow<W extends WorkflowRef = WorkflowRef> {
8999
8992
  * `Math.random`; overridden in tests so jitter is deterministic. */
9000
8993
  interface RunSchedulesOptions {
9001
8994
  random?: () => number;
9002
- /**
9003
- * @deprecated No longer called: jitter defers a window to a later tick instead of sleeping inside
9004
- * this one. Kept so existing callers still type-check.
9005
- */
9006
- sleep?: (ms: number) => Promise<void>;
9007
8995
  }
9008
8996
  /** Deterministic run id for a fixed-interval schedule's current time window. */
9009
8997
  declare function scheduledRunId(key: string, everyMs: number, nowMs: number): string;
@@ -9175,35 +9163,33 @@ declare function sanitizeQueueToken(name: string): string;
9175
9163
  * `import` (`index.js`) and once as `require` (`index.cjs`). A plain `Symbol()` would mint a
9176
9164
  * DISTINCT token per copy, so `DurableModule` (provider) and `DashboardService` / a store adapter
9177
9165
  * (injector) could resolve different symbols → Nest can't satisfy the dependency
9178
- * (`STATE_STORE is not available in the DurableApiModule context`). A registered symbol collapses
9166
+ * (`<token> is not available in the DurableApiModule context`). A registered symbol collapses
9179
9167
  * them to one. Mirrors the `CONTEXT_ACCESSOR` token in `@dudousxd/nestjs-durable`'s `tokens.ts`.
9180
9168
  */
9181
9169
  /**
9182
- * @deprecated Use {@link STATE_STORE_CANONICAL} (`@dudousxd/nestjs-durable:state-store`). The legacy
9183
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9170
+ * The durable DI tokens, following the ecosystem capability naming `@dudousxd/nestjs-durable:<name>`
9171
+ * (identical to `capability('durable', <name>)`), so an external library can resolve durable's
9172
+ * store/transport/options by name without importing durable internals. Bare `Symbol.for` keeps
9173
+ * `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9174
+ */
9175
+ declare const STATE_STORE_CANONICAL: unique symbol;
9176
+ declare const TRANSPORT_CANONICAL: unique symbol;
9177
+ declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9178
+ /**
9179
+ * @deprecated Use {@link STATE_STORE_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9180
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9184
9181
  */
9185
9182
  declare const STATE_STORE: unique symbol;
9186
9183
  /**
9187
- * @deprecated Use {@link TRANSPORT_CANONICAL} (`@dudousxd/nestjs-durable:transport`). The legacy
9188
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9184
+ * @deprecated Use {@link TRANSPORT_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9185
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9189
9186
  */
9190
9187
  declare const TRANSPORT: unique symbol;
9191
9188
  /**
9192
- * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL} (`@dudousxd/nestjs-durable:options`). The legacy
9193
- * token stays bound as a back-compat alias and still resolves; it will be removed in a future major.
9189
+ * @deprecated Use {@link DURABLE_OPTIONS_CANONICAL}. Kept because published `@dudousxd/nestjs-durable`
9190
+ * releases import it from core; `DurableModule` binds it to the same instance as the canonical token.
9194
9191
  */
9195
9192
  declare const DURABLE_OPTIONS: unique symbol;
9196
- /**
9197
- * Canonical, cross-lib-discoverable aliases of the durable DI tokens, following the ecosystem
9198
- * capability naming `@dudousxd/nestjs-durable:<name>` (identical to `capability('durable', <name>)`).
9199
- * `DurableModule` binds these alongside the legacy tokens (dual-bind), so an external library can
9200
- * resolve durable's store/transport/options by the canonical name without importing durable
9201
- * internals. Bare `Symbol.for` (same cross-copy-stability rationale as the legacy tokens above)
9202
- * keeps `core` free of any `@dudousxd/nestjs-diagnostics` runtime dependency.
9203
- */
9204
- declare const STATE_STORE_CANONICAL: unique symbol;
9205
- declare const TRANSPORT_CANONICAL: unique symbol;
9206
- declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
9207
9193
 
9208
9194
  /**
9209
9195
  * The OPT-IN declaration-site contract for a `@Workflow` class: `implements WorkflowHandler<TInput,
package/dist/index.js CHANGED
@@ -11256,7 +11256,7 @@ var WorkflowEngine = class _WorkflowEngine {
11256
11256
  ];
11257
11257
  }
11258
11258
  /** The worker groups this engine dispatches to: every registered remote workflow's group, plus any
11259
- * `extra` the caller declares. Local-step groups (a group consumed by in-process `@DurableStep`
11259
+ * `extra` the caller declares. Local-step groups (a group consumed by in-process `@Step`
11260
11260
  * workers, e.g. `pipeline`) aren't derivable from registrations — pass them via `extra` so a group
11261
11261
  * with backlog and ZERO workers is still reported (the alert case has no heartbeat to discover). */
11262
11262
  knownGroups(extra = []) {
@@ -16026,12 +16026,12 @@ function readSearchAttributes(schema, run) {
16026
16026
  __name(readSearchAttributes, "readSearchAttributes");
16027
16027
 
16028
16028
  // src/tokens.ts
16029
- var STATE_STORE = Symbol.for("nestjs-durable:STATE_STORE");
16030
- var TRANSPORT = Symbol.for("nestjs-durable:TRANSPORT");
16031
- var DURABLE_OPTIONS = Symbol.for("nestjs-durable:DURABLE_OPTIONS");
16032
16029
  var STATE_STORE_CANONICAL = Symbol.for("@dudousxd/nestjs-durable:state-store");
16033
16030
  var TRANSPORT_CANONICAL = Symbol.for("@dudousxd/nestjs-durable:transport");
16034
16031
  var DURABLE_OPTIONS_CANONICAL = Symbol.for("@dudousxd/nestjs-durable:options");
16032
+ var STATE_STORE = Symbol.for("nestjs-durable:STATE_STORE");
16033
+ var TRANSPORT = Symbol.for("nestjs-durable:TRANSPORT");
16034
+ var DURABLE_OPTIONS = Symbol.for("nestjs-durable:DURABLE_OPTIONS");
16035
16035
 
16036
16036
  // src/testing/in-memory-state-store.ts
16037
16037
  var RETENTION_EXCLUDED = [