@dudousxd/nestjs-durable 0.33.0 → 0.34.1
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 +104 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -2
- package/dist/index.d.ts +74 -2
- package/dist/index.js +23 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,76 @@
|
|
|
1
|
-
import { StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend,
|
|
1
|
+
import { WorkflowCtx, SearchAttributes, WorkflowClass, StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
export { AttributeFilter, EngineEvent, InferSearchAttributes, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowRun, readSearchAttributes } from '@dudousxd/nestjs-durable-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
5
5
|
import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
|
|
6
6
|
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The search-attributes shape a `@Workflow` class declares — extracted from its `run` method's
|
|
10
|
+
* `ctx: WorkflowCtx<A>` annotation, mirroring the `WorkflowInputOf`/`WorkflowOutputOf` structural-
|
|
11
|
+
* typing idiom in core's `workflow-ref.ts` (which extract `run`'s `input`/return type the same way).
|
|
12
|
+
* A class whose `run` leaves `ctx` untyped (or types it as the bare `WorkflowCtx`) resolves to the
|
|
13
|
+
* untyped `SearchAttributes` default — matching `WorkflowCtx` itself.
|
|
14
|
+
*/
|
|
15
|
+
type WorkflowAttributesOf<C> = C extends abstract new (...args: never[]) => {
|
|
16
|
+
run(ctx: WorkflowCtx<infer A>, input: never): unknown;
|
|
17
|
+
} ? A : SearchAttributes;
|
|
18
|
+
/**
|
|
19
|
+
* Read a run's search attributes **by workflow class**, with the schema resolved from that class's
|
|
20
|
+
* `@Workflow({ searchAttributes })` decorator metadata — the same single-source-of-truth idiom as
|
|
21
|
+
* triggering a workflow by class (`ctx.child(ShippingWorkflow, input)`, `engine.start(CheckoutWorkflow,
|
|
22
|
+
* input)`): the decorator is the one place the schema lives, and every reader references the
|
|
23
|
+
* WORKFLOW, never re-imports or re-declares the schema itself. The return type is inferred
|
|
24
|
+
* structurally from the class's `run(ctx: WorkflowCtx<A>, …)` annotation (see
|
|
25
|
+
* {@link WorkflowAttributesOf}), so a valid read is typed to `A` with no explicit type argument.
|
|
26
|
+
*
|
|
27
|
+
* Delegates to core's `readSearchAttributes(schema, run)` for the actual read, so the same lenient
|
|
28
|
+
* safe-parse semantics apply: a run whose stored `searchAttributes` predate the schema, or fail it,
|
|
29
|
+
* reads back as `{}` rather than throwing (see `readSearchAttributes`'s doc comment).
|
|
30
|
+
*
|
|
31
|
+
* @throws if `workflow` isn't a `@Workflow`-decorated class (no metadata at all — nothing to resolve
|
|
32
|
+
* the schema from).
|
|
33
|
+
* @throws if `workflow` is a `@Workflow` class that never declared a `searchAttributes` schema —
|
|
34
|
+
* reading attributes by class needs one to resolve against.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { z } from 'zod';
|
|
39
|
+
* import { Injectable } from '@nestjs/common';
|
|
40
|
+
* import {
|
|
41
|
+
* attributesOf,
|
|
42
|
+
* InferSearchAttributes,
|
|
43
|
+
* Workflow,
|
|
44
|
+
* WorkflowCtx,
|
|
45
|
+
* WorkflowHandler,
|
|
46
|
+
* } from '@dudousxd/nestjs-durable';
|
|
47
|
+
*
|
|
48
|
+
* const orderAttrs = z.object({ tier: z.enum(['free', 'pro']), amount: z.number() });
|
|
49
|
+
* type OrderAttrs = InferSearchAttributes<typeof orderAttrs>;
|
|
50
|
+
*
|
|
51
|
+
* @Workflow({ name: 'checkout', searchAttributes: orderAttrs })
|
|
52
|
+
* class CheckoutWorkflow implements WorkflowHandler<{ orderId: string }, void, OrderAttrs> {
|
|
53
|
+
* async run(ctx: WorkflowCtx<OrderAttrs>, input: { orderId: string }): Promise<void> {
|
|
54
|
+
* await ctx.upsertSearchAttributes({ tier: 'pro', amount: 100 });
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* @Injectable()
|
|
59
|
+
* class CheckoutDashboardService {
|
|
60
|
+
* constructor(private readonly store: StateStore) {}
|
|
61
|
+
*
|
|
62
|
+
* async tierOf(runId: string) {
|
|
63
|
+
* const run = await this.store.getRun(runId);
|
|
64
|
+
* const attrs = attributesOf(CheckoutWorkflow, run ?? {}); // OrderAttrs
|
|
65
|
+
* return attrs.tier;
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function attributesOf<C extends WorkflowClass>(workflow: C, run: {
|
|
71
|
+
searchAttributes?: SearchAttributes | null | undefined;
|
|
72
|
+
}): WorkflowAttributesOf<C>;
|
|
73
|
+
|
|
8
74
|
/**
|
|
9
75
|
* Local, structural mirror of `@dudousxd/nestjs-context`'s public accessor
|
|
10
76
|
* (`packages/core/src/accessor.ts`).
|
|
@@ -612,6 +678,7 @@ declare class DurableStartClient {
|
|
|
612
678
|
}, _opts?: StartOptions): Promise<void>;
|
|
613
679
|
publishEvent(_name: string, _payload: unknown, _opts?: {
|
|
614
680
|
id?: string;
|
|
681
|
+
buffer?: boolean;
|
|
615
682
|
}): Promise<void>;
|
|
616
683
|
}
|
|
617
684
|
|
|
@@ -1029,10 +1096,15 @@ declare class WorkflowService {
|
|
|
1029
1096
|
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
|
|
1030
1097
|
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
1031
1098
|
* touched (resumed + started).
|
|
1099
|
+
*
|
|
1100
|
+
* Reliable by default: a publish that touches NOBODY (no live waiter, no subscriber) buffers ONE
|
|
1101
|
+
* copy so a LATER `waitForEvent(name, { match })` still consumes it instead of it being dropped —
|
|
1102
|
+
* see {@link WorkflowEngine.publishEvent}'s full semantics doc. Pass `opts.buffer: false` to opt out.
|
|
1032
1103
|
*/
|
|
1033
1104
|
publishEvent(name: string, payload: unknown, opts?: {
|
|
1034
1105
|
id?: string;
|
|
1106
|
+
buffer?: boolean;
|
|
1035
1107
|
}): Promise<number>;
|
|
1036
1108
|
}
|
|
1037
1109
|
|
|
1038
|
-
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 };
|
|
1110
|
+
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 WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,76 @@
|
|
|
1
|
-
import { StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend,
|
|
1
|
+
import { WorkflowCtx, SearchAttributes, WorkflowClass, StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
export { AttributeFilter, EngineEvent, InferSearchAttributes, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, SearchAttributesSchema, StepCheckpoint, StepEvent, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowHandler, WorkflowRun, readSearchAttributes } from '@dudousxd/nestjs-durable-core';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
5
5
|
import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
|
|
6
6
|
import { DiscoveryService, MetadataScanner } from '@nestjs/core';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* The search-attributes shape a `@Workflow` class declares — extracted from its `run` method's
|
|
10
|
+
* `ctx: WorkflowCtx<A>` annotation, mirroring the `WorkflowInputOf`/`WorkflowOutputOf` structural-
|
|
11
|
+
* typing idiom in core's `workflow-ref.ts` (which extract `run`'s `input`/return type the same way).
|
|
12
|
+
* A class whose `run` leaves `ctx` untyped (or types it as the bare `WorkflowCtx`) resolves to the
|
|
13
|
+
* untyped `SearchAttributes` default — matching `WorkflowCtx` itself.
|
|
14
|
+
*/
|
|
15
|
+
type WorkflowAttributesOf<C> = C extends abstract new (...args: never[]) => {
|
|
16
|
+
run(ctx: WorkflowCtx<infer A>, input: never): unknown;
|
|
17
|
+
} ? A : SearchAttributes;
|
|
18
|
+
/**
|
|
19
|
+
* Read a run's search attributes **by workflow class**, with the schema resolved from that class's
|
|
20
|
+
* `@Workflow({ searchAttributes })` decorator metadata — the same single-source-of-truth idiom as
|
|
21
|
+
* triggering a workflow by class (`ctx.child(ShippingWorkflow, input)`, `engine.start(CheckoutWorkflow,
|
|
22
|
+
* input)`): the decorator is the one place the schema lives, and every reader references the
|
|
23
|
+
* WORKFLOW, never re-imports or re-declares the schema itself. The return type is inferred
|
|
24
|
+
* structurally from the class's `run(ctx: WorkflowCtx<A>, …)` annotation (see
|
|
25
|
+
* {@link WorkflowAttributesOf}), so a valid read is typed to `A` with no explicit type argument.
|
|
26
|
+
*
|
|
27
|
+
* Delegates to core's `readSearchAttributes(schema, run)` for the actual read, so the same lenient
|
|
28
|
+
* safe-parse semantics apply: a run whose stored `searchAttributes` predate the schema, or fail it,
|
|
29
|
+
* reads back as `{}` rather than throwing (see `readSearchAttributes`'s doc comment).
|
|
30
|
+
*
|
|
31
|
+
* @throws if `workflow` isn't a `@Workflow`-decorated class (no metadata at all — nothing to resolve
|
|
32
|
+
* the schema from).
|
|
33
|
+
* @throws if `workflow` is a `@Workflow` class that never declared a `searchAttributes` schema —
|
|
34
|
+
* reading attributes by class needs one to resolve against.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { z } from 'zod';
|
|
39
|
+
* import { Injectable } from '@nestjs/common';
|
|
40
|
+
* import {
|
|
41
|
+
* attributesOf,
|
|
42
|
+
* InferSearchAttributes,
|
|
43
|
+
* Workflow,
|
|
44
|
+
* WorkflowCtx,
|
|
45
|
+
* WorkflowHandler,
|
|
46
|
+
* } from '@dudousxd/nestjs-durable';
|
|
47
|
+
*
|
|
48
|
+
* const orderAttrs = z.object({ tier: z.enum(['free', 'pro']), amount: z.number() });
|
|
49
|
+
* type OrderAttrs = InferSearchAttributes<typeof orderAttrs>;
|
|
50
|
+
*
|
|
51
|
+
* @Workflow({ name: 'checkout', searchAttributes: orderAttrs })
|
|
52
|
+
* class CheckoutWorkflow implements WorkflowHandler<{ orderId: string }, void, OrderAttrs> {
|
|
53
|
+
* async run(ctx: WorkflowCtx<OrderAttrs>, input: { orderId: string }): Promise<void> {
|
|
54
|
+
* await ctx.upsertSearchAttributes({ tier: 'pro', amount: 100 });
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* @Injectable()
|
|
59
|
+
* class CheckoutDashboardService {
|
|
60
|
+
* constructor(private readonly store: StateStore) {}
|
|
61
|
+
*
|
|
62
|
+
* async tierOf(runId: string) {
|
|
63
|
+
* const run = await this.store.getRun(runId);
|
|
64
|
+
* const attrs = attributesOf(CheckoutWorkflow, run ?? {}); // OrderAttrs
|
|
65
|
+
* return attrs.tier;
|
|
66
|
+
* }
|
|
67
|
+
* }
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
declare function attributesOf<C extends WorkflowClass>(workflow: C, run: {
|
|
71
|
+
searchAttributes?: SearchAttributes | null | undefined;
|
|
72
|
+
}): WorkflowAttributesOf<C>;
|
|
73
|
+
|
|
8
74
|
/**
|
|
9
75
|
* Local, structural mirror of `@dudousxd/nestjs-context`'s public accessor
|
|
10
76
|
* (`packages/core/src/accessor.ts`).
|
|
@@ -612,6 +678,7 @@ declare class DurableStartClient {
|
|
|
612
678
|
}, _opts?: StartOptions): Promise<void>;
|
|
613
679
|
publishEvent(_name: string, _payload: unknown, _opts?: {
|
|
614
680
|
id?: string;
|
|
681
|
+
buffer?: boolean;
|
|
615
682
|
}): Promise<void>;
|
|
616
683
|
}
|
|
617
684
|
|
|
@@ -1029,10 +1096,15 @@ declare class WorkflowService {
|
|
|
1029
1096
|
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
|
|
1030
1097
|
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
1031
1098
|
* touched (resumed + started).
|
|
1099
|
+
*
|
|
1100
|
+
* Reliable by default: a publish that touches NOBODY (no live waiter, no subscriber) buffers ONE
|
|
1101
|
+
* copy so a LATER `waitForEvent(name, { match })` still consumes it instead of it being dropped —
|
|
1102
|
+
* see {@link WorkflowEngine.publishEvent}'s full semantics doc. Pass `opts.buffer: false` to opt out.
|
|
1032
1103
|
*/
|
|
1033
1104
|
publishEvent(name: string, payload: unknown, opts?: {
|
|
1034
1105
|
id?: string;
|
|
1106
|
+
buffer?: boolean;
|
|
1035
1107
|
}): Promise<number>;
|
|
1036
1108
|
}
|
|
1037
1109
|
|
|
1038
|
-
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 };
|
|
1110
|
+
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 WorkflowAttributesOf, type WorkflowMeta, type WorkflowOptions, WorkflowService, attributesOf, entityConfigFor, getDurableStepMeta, getEntityMeta, getOnEvents, getWorkflowMeta, inAppWorkerProviders, isDeadLetterHandler, isDrivingOperator, isOperatorRole, isStepInterceptor, thinWorkerProviders, unavailableRunGateway };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
7
7
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
// src/attributes-of.ts
|
|
11
|
+
import { readSearchAttributes } from "@dudousxd/nestjs-durable-core";
|
|
12
|
+
|
|
10
13
|
// src/decorators.ts
|
|
11
14
|
import { DURABLE_STEP_CONFIG, DURABLE_STEP_NAME, WORKFLOW_NAME_KEY } from "@dudousxd/nestjs-durable-core";
|
|
12
15
|
import "reflect-metadata";
|
|
@@ -114,6 +117,19 @@ function getOnEvents(meta, target) {
|
|
|
114
117
|
}
|
|
115
118
|
__name(getOnEvents, "getOnEvents");
|
|
116
119
|
|
|
120
|
+
// src/attributes-of.ts
|
|
121
|
+
function attributesOf(workflow, run) {
|
|
122
|
+
const meta = getWorkflowMeta(workflow);
|
|
123
|
+
if (!meta) {
|
|
124
|
+
throw new Error(`attributesOf: ${workflow.name} is not a @Workflow class \u2014 is it decorated with @Workflow({ name, searchAttributes })?`);
|
|
125
|
+
}
|
|
126
|
+
if (!meta.searchAttributes) {
|
|
127
|
+
throw new Error(`attributesOf: workflow '${meta.name}' declares no searchAttributes schema \u2014 reading attributes by class requires the workflow to declare its schema: @Workflow({ name: '${meta.name}', searchAttributes: mySchema }).`);
|
|
128
|
+
}
|
|
129
|
+
return readSearchAttributes(meta.searchAttributes, run);
|
|
130
|
+
}
|
|
131
|
+
__name(attributesOf, "attributesOf");
|
|
132
|
+
|
|
117
133
|
// src/durable-start-client.ts
|
|
118
134
|
import { startRun } from "@dudousxd/durable-worker";
|
|
119
135
|
import { workflowName } from "@dudousxd/nestjs-durable-core";
|
|
@@ -1678,6 +1694,10 @@ var WorkflowService = class {
|
|
|
1678
1694
|
* starts a fresh run of every workflow subscribed via `@Workflow({ onEvent })` / `@OnDurableEvent` (the
|
|
1679
1695
|
* payload becomes its input). Pass `opts.id` to dedupe redeliveries. Returns how many runs it
|
|
1680
1696
|
* touched (resumed + started).
|
|
1697
|
+
*
|
|
1698
|
+
* Reliable by default: a publish that touches NOBODY (no live waiter, no subscriber) buffers ONE
|
|
1699
|
+
* copy so a LATER `waitForEvent(name, { match })` still consumes it instead of it being dropped —
|
|
1700
|
+
* see {@link WorkflowEngine.publishEvent}'s full semantics doc. Pass `opts.buffer: false` to opt out.
|
|
1681
1701
|
*/
|
|
1682
1702
|
publishEvent(name, payload, opts) {
|
|
1683
1703
|
return this.engine.publishEvent(name, payload, opts);
|
|
@@ -2054,7 +2074,7 @@ DurableModule = _ts_decorate12([
|
|
|
2054
2074
|
], DurableModule);
|
|
2055
2075
|
|
|
2056
2076
|
// src/index.ts
|
|
2057
|
-
import { readSearchAttributes, WorkflowEngine as WorkflowEngine7 } from "@dudousxd/nestjs-durable-core";
|
|
2077
|
+
import { readSearchAttributes as readSearchAttributes2, WorkflowEngine as WorkflowEngine7 } from "@dudousxd/nestjs-durable-core";
|
|
2058
2078
|
export {
|
|
2059
2079
|
CONTEXT_ACCESSOR,
|
|
2060
2080
|
DEAD_LETTER_METADATA,
|
|
@@ -2093,6 +2113,7 @@ export {
|
|
|
2093
2113
|
Workflow,
|
|
2094
2114
|
WorkflowEngine7 as WorkflowEngine,
|
|
2095
2115
|
WorkflowService,
|
|
2116
|
+
attributesOf,
|
|
2096
2117
|
entityConfigFor,
|
|
2097
2118
|
getDurableStepMeta,
|
|
2098
2119
|
getEntityMeta,
|
|
@@ -2103,7 +2124,7 @@ export {
|
|
|
2103
2124
|
isDrivingOperator,
|
|
2104
2125
|
isOperatorRole,
|
|
2105
2126
|
isStepInterceptor,
|
|
2106
|
-
readSearchAttributes,
|
|
2127
|
+
readSearchAttributes2 as readSearchAttributes,
|
|
2107
2128
|
thinWorkerProviders,
|
|
2108
2129
|
unavailableRunGateway
|
|
2109
2130
|
};
|