@dudousxd/nestjs-durable 0.31.0 → 0.33.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 +13 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -3
- package/dist/index.d.ts +12 -3
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
|
|
2
|
-
export { AttributeFilter, EngineEvent, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, StepCheckpoint, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowRun } from '@dudousxd/nestjs-durable-core';
|
|
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';
|
|
@@ -527,10 +527,18 @@ interface DurableModuleOptions {
|
|
|
527
527
|
* dispatch routes a run's `namespace` to. `{ role: 'tenant' }` sets this FOR you from `tenant` —
|
|
528
528
|
* you never set `partition` directly under `topology`.
|
|
529
529
|
*
|
|
530
|
+
* **One `tenant` word, two axes — the preset maps it to the right one per role:** on a
|
|
531
|
+
* `control-plane` an optional `tenant` scopes the OPERATOR to its own runs (maps to `namespace` —
|
|
532
|
+
* a self-contained local stack sharing a broker with a deployed cluster names itself so neither
|
|
533
|
+
* drives the other's runs; leave it unset on a deployed operator to drive every tenant). On a
|
|
534
|
+
* `tenant` role it is required and maps to `partition` (the worker's queue suffix).
|
|
535
|
+
*
|
|
530
536
|
* ```ts
|
|
531
|
-
* // Control plane: owns the store, dispatches over the transport, prunes old runs.
|
|
537
|
+
* // Control plane: owns the store, dispatches over the transport, prunes old runs. The optional
|
|
538
|
+
* // `tenant` (e.g. from an env var) scopes this operator to its own runs — undefined on a
|
|
539
|
+
* // deployed operator (drives everything), set on a local stack sharing the broker.
|
|
532
540
|
* DurableModule.forRoot({
|
|
533
|
-
* topology: { role: 'control-plane' },
|
|
541
|
+
* topology: { role: 'control-plane', tenant: process.env.DURABLE_TENANT },
|
|
534
542
|
* store,
|
|
535
543
|
* transport,
|
|
536
544
|
* retention: { policies: [{ statuses: ['completed', 'cancelled'], maxAge: '14d' }] },
|
|
@@ -548,6 +556,7 @@ interface DurableModuleOptions {
|
|
|
548
556
|
*/
|
|
549
557
|
topology?: {
|
|
550
558
|
role: 'control-plane';
|
|
559
|
+
tenant?: string;
|
|
551
560
|
} | {
|
|
552
561
|
role: 'tenant';
|
|
553
562
|
tenant: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StepError, WorkflowRef, SingletonConfig, SearchAttributesSchema, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, RunWaiting, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
|
|
2
|
-
export { AttributeFilter, EngineEvent, RunDetail, RunGateway, RunListItem, RunQuery, RunStatus, RunWaiting, SearchAttributes, StepCheckpoint, StepLogger, WorkflowCtx, WorkflowEngine, WorkflowRun } from '@dudousxd/nestjs-durable-core';
|
|
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';
|
|
@@ -527,10 +527,18 @@ interface DurableModuleOptions {
|
|
|
527
527
|
* dispatch routes a run's `namespace` to. `{ role: 'tenant' }` sets this FOR you from `tenant` —
|
|
528
528
|
* you never set `partition` directly under `topology`.
|
|
529
529
|
*
|
|
530
|
+
* **One `tenant` word, two axes — the preset maps it to the right one per role:** on a
|
|
531
|
+
* `control-plane` an optional `tenant` scopes the OPERATOR to its own runs (maps to `namespace` —
|
|
532
|
+
* a self-contained local stack sharing a broker with a deployed cluster names itself so neither
|
|
533
|
+
* drives the other's runs; leave it unset on a deployed operator to drive every tenant). On a
|
|
534
|
+
* `tenant` role it is required and maps to `partition` (the worker's queue suffix).
|
|
535
|
+
*
|
|
530
536
|
* ```ts
|
|
531
|
-
* // Control plane: owns the store, dispatches over the transport, prunes old runs.
|
|
537
|
+
* // Control plane: owns the store, dispatches over the transport, prunes old runs. The optional
|
|
538
|
+
* // `tenant` (e.g. from an env var) scopes this operator to its own runs — undefined on a
|
|
539
|
+
* // deployed operator (drives everything), set on a local stack sharing the broker.
|
|
532
540
|
* DurableModule.forRoot({
|
|
533
|
-
* topology: { role: 'control-plane' },
|
|
541
|
+
* topology: { role: 'control-plane', tenant: process.env.DURABLE_TENANT },
|
|
534
542
|
* store,
|
|
535
543
|
* transport,
|
|
536
544
|
* retention: { policies: [{ statuses: ['completed', 'cancelled'], maxAge: '14d' }] },
|
|
@@ -548,6 +556,7 @@ interface DurableModuleOptions {
|
|
|
548
556
|
*/
|
|
549
557
|
topology?: {
|
|
550
558
|
role: 'control-plane';
|
|
559
|
+
tenant?: string;
|
|
551
560
|
} | {
|
|
552
561
|
role: 'tenant';
|
|
553
562
|
tenant: string;
|
package/dist/index.js
CHANGED
|
@@ -1781,8 +1781,9 @@ function assertValidTopology(options) {
|
|
|
1781
1781
|
if (options.partition !== void 0) {
|
|
1782
1782
|
throw new Error("topology: { role: 'control-plane' } forbids `partition`.\npartition is the WORKER queue-routing suffix \u2014 on a control-plane node, runs are dispatched to tenant partitions via each run's namespace, not via this option. Set `partition` (or `topology: { role: 'tenant', tenant }`) on the WORKER node instead.");
|
|
1783
1783
|
}
|
|
1784
|
-
if (
|
|
1785
|
-
throw new Error(
|
|
1784
|
+
if (topology.tenant !== void 0 && options.namespace !== void 0 && options.namespace !== topology.tenant) {
|
|
1785
|
+
throw new Error(`topology: { role: 'control-plane', tenant: '${topology.tenant}' } conflicts with \`namespace: '${options.namespace}'\`.
|
|
1786
|
+
tenant maps 1:1 onto namespace (the operator's poll-scoping axis) \u2014 set only \`tenant\`, or set \`namespace\` to the same value.`);
|
|
1786
1787
|
}
|
|
1787
1788
|
return;
|
|
1788
1789
|
}
|
|
@@ -1804,7 +1805,14 @@ tenant maps 1:1 onto partition (the worker queue-routing suffix) \u2014 set only
|
|
|
1804
1805
|
__name(assertValidTopology, "assertValidTopology");
|
|
1805
1806
|
function resolveTopology(options) {
|
|
1806
1807
|
const topology = options.topology;
|
|
1807
|
-
if (topology === void 0
|
|
1808
|
+
if (topology === void 0) return options;
|
|
1809
|
+
if (topology.role === "control-plane") {
|
|
1810
|
+
if (topology.tenant === void 0 || options.namespace !== void 0) return options;
|
|
1811
|
+
return {
|
|
1812
|
+
...options,
|
|
1813
|
+
namespace: topology.tenant
|
|
1814
|
+
};
|
|
1815
|
+
}
|
|
1808
1816
|
if (options.partition !== void 0) return options;
|
|
1809
1817
|
return {
|
|
1810
1818
|
...options,
|
|
@@ -2046,7 +2054,7 @@ DurableModule = _ts_decorate12([
|
|
|
2046
2054
|
], DurableModule);
|
|
2047
2055
|
|
|
2048
2056
|
// src/index.ts
|
|
2049
|
-
import { WorkflowEngine as WorkflowEngine7 } from "@dudousxd/nestjs-durable-core";
|
|
2057
|
+
import { readSearchAttributes, WorkflowEngine as WorkflowEngine7 } from "@dudousxd/nestjs-durable-core";
|
|
2050
2058
|
export {
|
|
2051
2059
|
CONTEXT_ACCESSOR,
|
|
2052
2060
|
DEAD_LETTER_METADATA,
|
|
@@ -2095,6 +2103,7 @@ export {
|
|
|
2095
2103
|
isDrivingOperator,
|
|
2096
2104
|
isOperatorRole,
|
|
2097
2105
|
isStepInterceptor,
|
|
2106
|
+
readSearchAttributes,
|
|
2098
2107
|
thinWorkerProviders,
|
|
2099
2108
|
unavailableRunGateway
|
|
2100
2109
|
};
|