@dudousxd/nestjs-durable-core 0.50.0 → 0.51.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
@@ -3308,7 +3308,7 @@ declare function attributeOperand(filter: AttributeFilter): string | number;
3308
3308
  * ```
3309
3309
  */
3310
3310
  declare function readSearchAttributes<S extends SearchAttributesSchema>(schema: S, run: {
3311
- searchAttributes?: SearchAttributes | undefined;
3311
+ searchAttributes?: SearchAttributes | null | undefined;
3312
3312
  }): InferSearchAttributes<S>;
3313
3313
 
3314
3314
  /**
@@ -3369,6 +3369,60 @@ declare const STATE_STORE_CANONICAL: unique symbol;
3369
3369
  declare const TRANSPORT_CANONICAL: unique symbol;
3370
3370
  declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
3371
3371
 
3372
+ /**
3373
+ * The OPT-IN declaration-site contract for a `@Workflow` class: `implements WorkflowHandler<TInput,
3374
+ * TOutput, A>` pins the class's `run(ctx, input)` signature against `TInput`/`TOutput`/`A` so a wrong
3375
+ * signature — a renamed method, swapped/missing param, wrong return type — is a compile error AT THE
3376
+ * CLASS instead of surfacing later as a runtime discovery failure (the `@Workflow` decorator finds no
3377
+ * `run` it recognizes) or a silently-wrong type flowing out of `ctx.child(ThisWorkflow, …)` /
3378
+ * `engine.start(ThisWorkflow, …)`. `A` also declares the run's {@link SearchAttributes} shape, so
3379
+ * `ctx.upsertSearchAttributes` is narrowed to it inside the workflow body — see
3380
+ * {@link SearchAttributesSchema} / {@link InferSearchAttributes} for pairing it with a `@Workflow({
3381
+ * searchAttributes })` schema.
3382
+ *
3383
+ * This is a TYPES-ONLY contract: nothing reads `implements WorkflowHandler` at runtime, registration
3384
+ * still goes through the `@Workflow` decorator + reflected metadata exactly as before, and a class
3385
+ * that doesn't implement it works exactly as it always has.
3386
+ *
3387
+ * IMPORTANT caveat: TypeScript does **not** contextually infer a method's parameter types from an
3388
+ * `implements` clause the way it does for e.g. an object literal assigned to a typed variable. The
3389
+ * class still has to annotate `ctx`/`input` itself — `implements` only CHECKS that what you wrote is
3390
+ * assignable to the interface; it doesn't write the annotations for you. Leaving `run`'s params
3391
+ * unannotated still leaves them `any`/inferred-from-usage, `implements` or not.
3392
+ *
3393
+ * @example
3394
+ * ```ts
3395
+ * import { z } from 'zod';
3396
+ * import { Workflow } from '@dudousxd/nestjs-durable';
3397
+ * import type { InferSearchAttributes, WorkflowCtx, WorkflowHandler } from '@dudousxd/nestjs-durable';
3398
+ *
3399
+ * const orderAttrs = z.object({
3400
+ * tier: z.enum(['free', 'pro']),
3401
+ * amount: z.number(),
3402
+ * });
3403
+ * type OrderAttrs = InferSearchAttributes<typeof orderAttrs>;
3404
+ *
3405
+ * interface CheckoutInput {
3406
+ * orderId: string;
3407
+ * }
3408
+ * interface CheckoutOutput {
3409
+ * receiptId: string;
3410
+ * }
3411
+ *
3412
+ * @Workflow({ name: 'checkout', searchAttributes: orderAttrs })
3413
+ * class CheckoutWorkflow implements WorkflowHandler<CheckoutInput, CheckoutOutput, OrderAttrs> {
3414
+ * async run(ctx: WorkflowCtx<OrderAttrs>, input: CheckoutInput): Promise<CheckoutOutput> {
3415
+ * await ctx.upsertSearchAttributes({ tier: 'pro', amount: 100 });
3416
+ * const receiptId = await ctx.step('charge-card', { orderId: input.orderId });
3417
+ * return { receiptId };
3418
+ * }
3419
+ * }
3420
+ * ```
3421
+ */
3422
+ interface WorkflowHandler<TInput = unknown, TOutput = unknown, A extends SearchAttributes = SearchAttributes> {
3423
+ run(ctx: WorkflowCtx<A>, input: TInput): Promise<TOutput> | TOutput;
3424
+ }
3425
+
3372
3426
  /**
3373
3427
  * A non-durable, in-process `StateStore` for tests and local development.
3374
3428
  * The shipped `@dudousxd/nestjs-durable-store` package re-exports an equivalent.
@@ -3458,4 +3512,4 @@ declare class InMemoryTransport implements Transport, ControlPlane {
3458
3512
  onControl(handler: (msg: ControlMessage) => void): void;
3459
3513
  }
3460
3514
 
3461
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableTopology, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, type RunWaiting, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, classifyWaiterToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, indexWaitersByRun, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, readSearchAttributes, resolveRunWaiting, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };
3515
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableTopology, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, type RunWaiting, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, classifyWaiterToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, indexWaitersByRun, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, readSearchAttributes, resolveRunWaiting, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };
package/dist/index.d.ts CHANGED
@@ -3308,7 +3308,7 @@ declare function attributeOperand(filter: AttributeFilter): string | number;
3308
3308
  * ```
3309
3309
  */
3310
3310
  declare function readSearchAttributes<S extends SearchAttributesSchema>(schema: S, run: {
3311
- searchAttributes?: SearchAttributes | undefined;
3311
+ searchAttributes?: SearchAttributes | null | undefined;
3312
3312
  }): InferSearchAttributes<S>;
3313
3313
 
3314
3314
  /**
@@ -3369,6 +3369,60 @@ declare const STATE_STORE_CANONICAL: unique symbol;
3369
3369
  declare const TRANSPORT_CANONICAL: unique symbol;
3370
3370
  declare const DURABLE_OPTIONS_CANONICAL: unique symbol;
3371
3371
 
3372
+ /**
3373
+ * The OPT-IN declaration-site contract for a `@Workflow` class: `implements WorkflowHandler<TInput,
3374
+ * TOutput, A>` pins the class's `run(ctx, input)` signature against `TInput`/`TOutput`/`A` so a wrong
3375
+ * signature — a renamed method, swapped/missing param, wrong return type — is a compile error AT THE
3376
+ * CLASS instead of surfacing later as a runtime discovery failure (the `@Workflow` decorator finds no
3377
+ * `run` it recognizes) or a silently-wrong type flowing out of `ctx.child(ThisWorkflow, …)` /
3378
+ * `engine.start(ThisWorkflow, …)`. `A` also declares the run's {@link SearchAttributes} shape, so
3379
+ * `ctx.upsertSearchAttributes` is narrowed to it inside the workflow body — see
3380
+ * {@link SearchAttributesSchema} / {@link InferSearchAttributes} for pairing it with a `@Workflow({
3381
+ * searchAttributes })` schema.
3382
+ *
3383
+ * This is a TYPES-ONLY contract: nothing reads `implements WorkflowHandler` at runtime, registration
3384
+ * still goes through the `@Workflow` decorator + reflected metadata exactly as before, and a class
3385
+ * that doesn't implement it works exactly as it always has.
3386
+ *
3387
+ * IMPORTANT caveat: TypeScript does **not** contextually infer a method's parameter types from an
3388
+ * `implements` clause the way it does for e.g. an object literal assigned to a typed variable. The
3389
+ * class still has to annotate `ctx`/`input` itself — `implements` only CHECKS that what you wrote is
3390
+ * assignable to the interface; it doesn't write the annotations for you. Leaving `run`'s params
3391
+ * unannotated still leaves them `any`/inferred-from-usage, `implements` or not.
3392
+ *
3393
+ * @example
3394
+ * ```ts
3395
+ * import { z } from 'zod';
3396
+ * import { Workflow } from '@dudousxd/nestjs-durable';
3397
+ * import type { InferSearchAttributes, WorkflowCtx, WorkflowHandler } from '@dudousxd/nestjs-durable';
3398
+ *
3399
+ * const orderAttrs = z.object({
3400
+ * tier: z.enum(['free', 'pro']),
3401
+ * amount: z.number(),
3402
+ * });
3403
+ * type OrderAttrs = InferSearchAttributes<typeof orderAttrs>;
3404
+ *
3405
+ * interface CheckoutInput {
3406
+ * orderId: string;
3407
+ * }
3408
+ * interface CheckoutOutput {
3409
+ * receiptId: string;
3410
+ * }
3411
+ *
3412
+ * @Workflow({ name: 'checkout', searchAttributes: orderAttrs })
3413
+ * class CheckoutWorkflow implements WorkflowHandler<CheckoutInput, CheckoutOutput, OrderAttrs> {
3414
+ * async run(ctx: WorkflowCtx<OrderAttrs>, input: CheckoutInput): Promise<CheckoutOutput> {
3415
+ * await ctx.upsertSearchAttributes({ tier: 'pro', amount: 100 });
3416
+ * const receiptId = await ctx.step('charge-card', { orderId: input.orderId });
3417
+ * return { receiptId };
3418
+ * }
3419
+ * }
3420
+ * ```
3421
+ */
3422
+ interface WorkflowHandler<TInput = unknown, TOutput = unknown, A extends SearchAttributes = SearchAttributes> {
3423
+ run(ctx: WorkflowCtx<A>, input: TInput): Promise<TOutput> | TOutput;
3424
+ }
3425
+
3372
3426
  /**
3373
3427
  * A non-durable, in-process `StateStore` for tests and local development.
3374
3428
  * The shipped `@dudousxd/nestjs-durable-store` package re-exports an equivalent.
@@ -3458,4 +3512,4 @@ declare class InMemoryTransport implements Transport, ControlPlane {
3458
3512
  onControl(handler: (msg: ControlMessage) => void): void;
3459
3513
  }
3460
3514
 
3461
- export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableTopology, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, type RunWaiting, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, classifyWaiterToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, indexWaitersByRun, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, readSearchAttributes, resolveRunWaiting, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };
3515
+ export { type AccumulatorHost, type Admission, type AdmissionBackend, type AdmissionItem, type AttributeFilter, type AttributeOp, type BackoffStrategy, type ChildCallOptions, CodecStateStore, ContinueAsNew, type ControlMessage, type ControlPlane, DURABLE_OPTIONS, DURABLE_OPTIONS_CANONICAL, DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, type DurableTopology, type DurableWebhook, DurableWorkflow, type EngineEvent, type EngineEventType, type EngineListener, Entities, type EntityConfig, type EntityHandler, type EntityHost, EventAccumulators, type EventBatchConfig, FatalError, GatherError, type GroupHealth, type Heartbeat, type HistoryEvent, InMemoryAdmissionBackend, InMemoryStateStore, InMemoryTransport, type InferSearchAttributes, type MetricsCollector, type MetricsSnapshot, type NamedTransport, NonDeterminismError, type PayloadCodec, type QueueConfig, QueueController, RemoteStepError, RemoteStepTimeout, type RemoteTask, RemoteWorkflowExecutor, RemoteWorkflowTimeout, type RetentionPolicy, type RunAttributeRow, type RunDetail, type RunDispatcher, type RunGateway, type RunListItem, type RunQuery, type RunReply, type RunReplyResult, type RunRequest, type RunRequestKind, type RunResult, type RunSchedulesOptions, type RunStatus, type RunWaiting, STATE_STORE, STATE_STORE_CANONICAL, type ScheduledWorkflow, type SearchAttributes, type SearchAttributesSchema, SignalTimeoutError, type SignalWaiter, type SingletonConfig, SingletonQueueFullError, StandardSchemaV1, type StartOptions, type StartRunMessage, type StateStore, type StepCheckpoint, type StepConfig, type StepDef, type StepDispatchOpts, type StepError, type StepEvent, type StepHandler, type StepInterceptor, type StepInvocation, type StepKind, type StepLogger, type StepOptions, type StepRef, type StepResult, type StepUndo, type StoreTransaction, type SubProcessHandle, TERMINAL_RUN_STATUSES, TRANSPORT, TRANSPORT_CANONICAL, type TenantEvent, type Transport, type UndoOf, type UpdateResult, type UpdateValidator, WORKFLOW_NAME_KEY, type WireDates, type WorkerAdjust, type WorkerConcurrencyStatus, type WorkerHeartbeat, type WorkerStatus, type WorkflowClass, type WorkflowCommand, type WorkflowCtx, type WorkflowDecision, WorkflowEngine, type WorkflowEngineDeps, type WorkflowExecutor, type WorkflowHandler, type WorkflowInputOf, type WorkflowOutputOf, type WorkflowRef, type WorkflowRun, type WorkflowStartClient, type WorkflowStepEvent, WorkflowSuspended, type WorkflowTask, applyAttributeQuery, attributeColumnFor, attributeOperand, bindWorkflowClass, breakpointToken, classifyWaiterToken, collectMetrics, createStepLogger, currentWorkflowCtx, eventMatchOf, eventMatches, eventNameOf, eventPrefix, eventToken, indexWaitersByRun, matchesAttributes, normalizeAttributeRows, parseDuration, prevCronFireMs, readSearchAttributes, resolveRunWaiting, runInWorkflowCtx, runSchedules, runStepHandler, sanitizeQueueToken, scheduledRunId, sqlComparator, stepConfigOf, stepId, stepNameOf, tenantGroup, workflowName };