@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.cjs +57 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -6
- package/dist/index.d.ts +29 -6
- package/dist/index.js +11 -8
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -56,7 +56,7 @@ __export(index_exports, {
|
|
|
56
56
|
ThinWorkflowRegistrar: () => ThinWorkflowRegistrar,
|
|
57
57
|
WORKFLOW_METADATA: () => WORKFLOW_METADATA,
|
|
58
58
|
Workflow: () => Workflow,
|
|
59
|
-
WorkflowEngine: () =>
|
|
59
|
+
WorkflowEngine: () => import_nestjs_durable_core15.WorkflowEngine,
|
|
60
60
|
WorkflowService: () => WorkflowService,
|
|
61
61
|
attributesOf: () => attributesOf,
|
|
62
62
|
entityConfigFor: () => entityConfigFor,
|
|
@@ -69,7 +69,7 @@ __export(index_exports, {
|
|
|
69
69
|
isDrivingOperator: () => isDrivingOperator,
|
|
70
70
|
isOperatorRole: () => isOperatorRole,
|
|
71
71
|
isStepInterceptor: () => isStepInterceptor,
|
|
72
|
-
readSearchAttributes: () =>
|
|
72
|
+
readSearchAttributes: () => import_nestjs_durable_core15.readSearchAttributes,
|
|
73
73
|
thinWorkerProviders: () => thinWorkerProviders,
|
|
74
74
|
unavailableRunGateway: () => unavailableRunGateway
|
|
75
75
|
});
|
|
@@ -96,7 +96,8 @@ function Workflow(options) {
|
|
|
96
96
|
searchAttributes: options.searchAttributes,
|
|
97
97
|
onEvent: options.onEvent,
|
|
98
98
|
debounce: options.debounce,
|
|
99
|
-
batch: options.batch
|
|
99
|
+
batch: options.batch,
|
|
100
|
+
requires: options.requires
|
|
100
101
|
};
|
|
101
102
|
Reflect.defineMetadata(WORKFLOW_METADATA, meta, target);
|
|
102
103
|
Object.defineProperty(target, import_nestjs_durable_core.WORKFLOW_NAME_KEY, {
|
|
@@ -118,7 +119,8 @@ function stepConfigFrom(options) {
|
|
|
118
119
|
backoffMs: options.backoffMs,
|
|
119
120
|
backoffMaxMs: options.backoffMaxMs,
|
|
120
121
|
jitter: options.jitter,
|
|
121
|
-
timeoutMs: options.timeoutMs
|
|
122
|
+
timeoutMs: options.timeoutMs,
|
|
123
|
+
requires: options.requires
|
|
122
124
|
};
|
|
123
125
|
const hasAnyField = Object.values(config).some((value) => value !== void 0);
|
|
124
126
|
return hasAnyField ? config : void 0;
|
|
@@ -550,7 +552,7 @@ function unavailableRunGateway() {
|
|
|
550
552
|
__name(unavailableRunGateway, "unavailableRunGateway");
|
|
551
553
|
|
|
552
554
|
// src/durable.module.ts
|
|
553
|
-
var
|
|
555
|
+
var import_nestjs_durable_core14 = require("@dudousxd/nestjs-durable-core");
|
|
554
556
|
var import_common12 = require("@nestjs/common");
|
|
555
557
|
var import_core5 = require("@nestjs/core");
|
|
556
558
|
|
|
@@ -1484,11 +1486,12 @@ TimerPoller = _ts_decorate9([
|
|
|
1484
1486
|
], TimerPoller);
|
|
1485
1487
|
|
|
1486
1488
|
// src/tokens.ts
|
|
1489
|
+
var import_nestjs_durable_core11 = require("@dudousxd/nestjs-durable-core");
|
|
1487
1490
|
var CONTEXT_ACCESSOR = Symbol.for("@dudousxd/nestjs-context:accessor");
|
|
1488
|
-
var RUN_GATEWAY =
|
|
1491
|
+
var RUN_GATEWAY = import_nestjs_durable_core11.RunGateway;
|
|
1489
1492
|
|
|
1490
1493
|
// src/workflow.registrar.ts
|
|
1491
|
-
var
|
|
1494
|
+
var import_nestjs_durable_core12 = require("@dudousxd/nestjs-durable-core");
|
|
1492
1495
|
var import_common10 = require("@nestjs/common");
|
|
1493
1496
|
var import_core4 = require("@nestjs/core");
|
|
1494
1497
|
|
|
@@ -1610,17 +1613,18 @@ var WorkflowRegistrar = class {
|
|
|
1610
1613
|
const validateInput = meta.validateInput ?? (meta.inputSchema ? classValidatorInput(meta.inputSchema) : void 0);
|
|
1611
1614
|
const eventBatch = meta.debounce ? {
|
|
1612
1615
|
mode: "debounce",
|
|
1613
|
-
windowMs: (0,
|
|
1616
|
+
windowMs: (0, import_nestjs_durable_core12.parseDuration)(meta.debounce)
|
|
1614
1617
|
} : meta.batch ? {
|
|
1615
1618
|
mode: "batch",
|
|
1616
1619
|
maxSize: meta.batch.maxSize,
|
|
1617
|
-
windowMs: (0,
|
|
1620
|
+
windowMs: (0, import_nestjs_durable_core12.parseDuration)(meta.batch.within)
|
|
1618
1621
|
} : void 0;
|
|
1619
1622
|
const workflowCtor = workflow.constructor;
|
|
1620
1623
|
this.engine.register(meta.name, meta.version, (ctx, input) => workflow.run(ctx, input), {
|
|
1621
1624
|
tags: meta.tags,
|
|
1622
1625
|
singleton: meta.singleton,
|
|
1623
1626
|
executionTimeout: meta.executionTimeout,
|
|
1627
|
+
requires: meta.requires,
|
|
1624
1628
|
validateInput,
|
|
1625
1629
|
searchAttributesSchema: meta.searchAttributes,
|
|
1626
1630
|
onEvent: getOnEvents(meta, workflowCtor),
|
|
@@ -1635,11 +1639,11 @@ var WorkflowRegistrar = class {
|
|
|
1635
1639
|
// so a turn dispatched under the wrong token would never be consumed. Absent → the inline fast
|
|
1636
1640
|
// path (unchanged).
|
|
1637
1641
|
...this.inAppWorker ? {
|
|
1638
|
-
group: (0,
|
|
1639
|
-
executor: new
|
|
1642
|
+
group: (0, import_nestjs_durable_core12.tenantGroup)((0, import_nestjs_durable_core12.sanitizeQueueToken)(meta.name), this.inAppWorker.partition),
|
|
1643
|
+
executor: new import_nestjs_durable_core12.RemoteWorkflowExecutor(this.inAppWorker.transport, meta.name, this.inAppWorker.partition)
|
|
1640
1644
|
} : {}
|
|
1641
1645
|
});
|
|
1642
|
-
(0,
|
|
1646
|
+
(0, import_nestjs_durable_core12.bindWorkflowClass)(workflowCtor, {
|
|
1643
1647
|
start: /* @__PURE__ */ __name((name, input, runId, opts) => this.engine.start(name, input, runId, opts), "start"),
|
|
1644
1648
|
waitForRun: /* @__PURE__ */ __name((runId, opts) => this.engine.waitForRun(runId, opts), "waitForRun")
|
|
1645
1649
|
});
|
|
@@ -1652,7 +1656,7 @@ var WorkflowRegistrar = class {
|
|
|
1652
1656
|
this.engine.register(dlqName, meta.version, inline);
|
|
1653
1657
|
deadLetterByWorkflow.set(meta.name, dlqName);
|
|
1654
1658
|
} else if (meta.deadLetterWorkflow) {
|
|
1655
|
-
deadLetterByWorkflow.set(meta.name, (0,
|
|
1659
|
+
deadLetterByWorkflow.set(meta.name, (0, import_nestjs_durable_core12.workflowName)(meta.deadLetterWorkflow));
|
|
1656
1660
|
}
|
|
1657
1661
|
});
|
|
1658
1662
|
this.installDeadLetterRouting(deadLetterByWorkflow);
|
|
@@ -1674,7 +1678,7 @@ var WorkflowRegistrar = class {
|
|
|
1674
1678
|
* a `dlq:<runId>` id, so re-recovery never double-dispatches.
|
|
1675
1679
|
*/
|
|
1676
1680
|
installDeadLetterRouting(byWorkflow) {
|
|
1677
|
-
const fallback = this.options.deadLetterWorkflow ? (0,
|
|
1681
|
+
const fallback = this.options.deadLetterWorkflow ? (0, import_nestjs_durable_core12.workflowName)(this.options.deadLetterWorkflow) : void 0;
|
|
1678
1682
|
if (byWorkflow.size === 0 && !fallback) return;
|
|
1679
1683
|
this.engine.onDead((run) => {
|
|
1680
1684
|
const target = byWorkflow.get(run.workflow) ?? fallback;
|
|
@@ -1699,14 +1703,14 @@ var WorkflowRegistrar = class {
|
|
|
1699
1703
|
};
|
|
1700
1704
|
WorkflowRegistrar = _ts_decorate10([
|
|
1701
1705
|
(0, import_common10.Injectable)(),
|
|
1702
|
-
_ts_param7(3, (0, import_common10.Inject)(
|
|
1703
|
-
_ts_param7(4, (0, import_common10.Inject)(
|
|
1706
|
+
_ts_param7(3, (0, import_common10.Inject)(import_nestjs_durable_core12.STATE_STORE_CANONICAL)),
|
|
1707
|
+
_ts_param7(4, (0, import_common10.Inject)(import_nestjs_durable_core12.DURABLE_OPTIONS_CANONICAL)),
|
|
1704
1708
|
_ts_param7(5, (0, import_common10.Inject)(IN_APP_WORKER_BINDING)),
|
|
1705
1709
|
_ts_metadata10("design:type", Function),
|
|
1706
1710
|
_ts_metadata10("design:paramtypes", [
|
|
1707
1711
|
typeof import_core4.DiscoveryService === "undefined" ? Object : import_core4.DiscoveryService,
|
|
1708
1712
|
typeof import_core4.MetadataScanner === "undefined" ? Object : import_core4.MetadataScanner,
|
|
1709
|
-
typeof
|
|
1713
|
+
typeof import_nestjs_durable_core12.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core12.WorkflowEngine,
|
|
1710
1714
|
Object,
|
|
1711
1715
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions,
|
|
1712
1716
|
Object
|
|
@@ -1715,7 +1719,7 @@ WorkflowRegistrar = _ts_decorate10([
|
|
|
1715
1719
|
|
|
1716
1720
|
// src/workflow.service.ts
|
|
1717
1721
|
var import_node_crypto = require("crypto");
|
|
1718
|
-
var
|
|
1722
|
+
var import_nestjs_durable_core13 = require("@dudousxd/nestjs-durable-core");
|
|
1719
1723
|
var import_common11 = require("@nestjs/common");
|
|
1720
1724
|
function _ts_decorate11(decorators, target, key, desc) {
|
|
1721
1725
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1775,7 +1779,7 @@ WorkflowService = _ts_decorate11([
|
|
|
1775
1779
|
(0, import_common11.Injectable)(),
|
|
1776
1780
|
_ts_metadata11("design:type", Function),
|
|
1777
1781
|
_ts_metadata11("design:paramtypes", [
|
|
1778
|
-
typeof
|
|
1782
|
+
typeof import_nestjs_durable_core13.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core13.WorkflowEngine
|
|
1779
1783
|
])
|
|
1780
1784
|
], WorkflowService);
|
|
1781
1785
|
|
|
@@ -1950,15 +1954,14 @@ var RunGatewayBootstrap = class RunGatewayBootstrap2 {
|
|
|
1950
1954
|
};
|
|
1951
1955
|
RunGatewayBootstrap = _ts_decorate12([
|
|
1952
1956
|
(0, import_common12.Injectable)(),
|
|
1953
|
-
_ts_param8(1, (0, import_common12.Inject)(
|
|
1954
|
-
_ts_param8(
|
|
1955
|
-
_ts_param8(
|
|
1956
|
-
_ts_param8(4, (0, import_common12.Inject)(import_nestjs_durable_core13.DURABLE_OPTIONS_CANONICAL)),
|
|
1957
|
+
_ts_param8(1, (0, import_common12.Inject)(import_nestjs_durable_core14.TRANSPORT_CANONICAL)),
|
|
1958
|
+
_ts_param8(3, (0, import_common12.Inject)(import_nestjs_durable_core14.STATE_STORE_CANONICAL)),
|
|
1959
|
+
_ts_param8(4, (0, import_common12.Inject)(import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL)),
|
|
1957
1960
|
_ts_metadata12("design:type", Function),
|
|
1958
1961
|
_ts_metadata12("design:paramtypes", [
|
|
1959
|
-
typeof
|
|
1962
|
+
typeof import_nestjs_durable_core14.WorkflowEngine === "undefined" ? Object : import_nestjs_durable_core14.WorkflowEngine,
|
|
1960
1963
|
Object,
|
|
1961
|
-
typeof RunGateway === "undefined" ? Object : RunGateway,
|
|
1964
|
+
typeof import_nestjs_durable_core14.RunGateway === "undefined" ? Object : import_nestjs_durable_core14.RunGateway,
|
|
1962
1965
|
Object,
|
|
1963
1966
|
typeof DurableModuleOptions === "undefined" ? Object : DurableModuleOptions
|
|
1964
1967
|
])
|
|
@@ -1970,13 +1973,13 @@ var DurableModule = class _DurableModule {
|
|
|
1970
1973
|
static forRoot(options) {
|
|
1971
1974
|
_DurableModule.assertValid(options);
|
|
1972
1975
|
return _DurableModule.build({
|
|
1973
|
-
provide:
|
|
1976
|
+
provide: import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL,
|
|
1974
1977
|
useValue: resolveTopology(options)
|
|
1975
1978
|
});
|
|
1976
1979
|
}
|
|
1977
1980
|
static forRootAsync(options) {
|
|
1978
1981
|
return _DurableModule.build({
|
|
1979
|
-
provide:
|
|
1982
|
+
provide: import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL,
|
|
1980
1983
|
useFactory: /* @__PURE__ */ __name(async (...args) => {
|
|
1981
1984
|
const resolved = await options.useFactory(...args);
|
|
1982
1985
|
_DurableModule.assertValid(resolved);
|
|
@@ -2009,41 +2012,41 @@ var DurableModule = class _DurableModule {
|
|
|
2009
2012
|
providers: [
|
|
2010
2013
|
optionsProvider,
|
|
2011
2014
|
{
|
|
2012
|
-
provide:
|
|
2015
|
+
provide: import_nestjs_durable_core14.STATE_STORE_CANONICAL,
|
|
2013
2016
|
useFactory: /* @__PURE__ */ __name((options) => options.store !== void 0 ? scopedStore(options.store, options) : null, "useFactory"),
|
|
2014
2017
|
inject: [
|
|
2015
|
-
|
|
2018
|
+
import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL
|
|
2016
2019
|
]
|
|
2017
2020
|
},
|
|
2018
2021
|
{
|
|
2019
|
-
provide:
|
|
2022
|
+
provide: import_nestjs_durable_core14.TRANSPORT_CANONICAL,
|
|
2020
2023
|
// With a POOL (`transports`) and no singular `transport`, the canonical transport is the
|
|
2021
2024
|
// pool's PRIMARY — the same one the engine dispatches on first. Leaving it null starved
|
|
2022
2025
|
// the step registrar / in-app worker of a transport, so a pool-configured operator
|
|
2023
2026
|
// registered NO step handlers and its own steps parked in `wait` with no consumer.
|
|
2024
2027
|
useFactory: /* @__PURE__ */ __name((options) => options.transport ?? options.transports?.[0]?.transport ?? null, "useFactory"),
|
|
2025
2028
|
inject: [
|
|
2026
|
-
|
|
2029
|
+
import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL
|
|
2027
2030
|
]
|
|
2028
2031
|
},
|
|
2029
2032
|
// Legacy back-compat aliases (deprecated tokens still resolve to the same instances):
|
|
2030
2033
|
{
|
|
2031
|
-
provide:
|
|
2032
|
-
useExisting:
|
|
2034
|
+
provide: import_nestjs_durable_core14.STATE_STORE,
|
|
2035
|
+
useExisting: import_nestjs_durable_core14.STATE_STORE_CANONICAL
|
|
2033
2036
|
},
|
|
2034
2037
|
{
|
|
2035
|
-
provide:
|
|
2036
|
-
useExisting:
|
|
2038
|
+
provide: import_nestjs_durable_core14.TRANSPORT,
|
|
2039
|
+
useExisting: import_nestjs_durable_core14.TRANSPORT_CANONICAL
|
|
2037
2040
|
},
|
|
2038
2041
|
{
|
|
2039
|
-
provide:
|
|
2040
|
-
useExisting:
|
|
2042
|
+
provide: import_nestjs_durable_core14.DURABLE_OPTIONS,
|
|
2043
|
+
useExisting: import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL
|
|
2041
2044
|
},
|
|
2042
2045
|
{
|
|
2043
2046
|
// Shared token, bound EXACTLY once: a real engine for the operator role, or a store-less
|
|
2044
2047
|
// `DurableStartClient` facade for a thin worker (no `store`) — either way, `WorkflowService`
|
|
2045
2048
|
// and app code call `engine.start(...)` unchanged.
|
|
2046
|
-
provide:
|
|
2049
|
+
provide: import_nestjs_durable_core14.WorkflowEngine,
|
|
2047
2050
|
useFactory: /* @__PURE__ */ __name(async (options, store, transport, moduleRef) => {
|
|
2048
2051
|
if (options.store === void 0) {
|
|
2049
2052
|
return new DurableStartClient(options);
|
|
@@ -2056,7 +2059,7 @@ var DurableModule = class _DurableModule {
|
|
|
2056
2059
|
const context = options.context ?? (accessor ? () => carrierFromAccessor(accessor) : void 0);
|
|
2057
2060
|
const runtime = accessor ? await resolveContextRuntime() : void 0;
|
|
2058
2061
|
const rehydrate = runtime && ((carrier, fn) => carrier && Object.keys(carrier).length > 0 ? runtime.deserialize(carrier, fn) : fn());
|
|
2059
|
-
const engine = new
|
|
2062
|
+
const engine = new import_nestjs_durable_core14.WorkflowEngine({
|
|
2060
2063
|
store,
|
|
2061
2064
|
transport: transport ?? void 0,
|
|
2062
2065
|
transports: options.transports,
|
|
@@ -2087,9 +2090,9 @@ var DurableModule = class _DurableModule {
|
|
|
2087
2090
|
return engine;
|
|
2088
2091
|
}, "useFactory"),
|
|
2089
2092
|
inject: [
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
+
import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL,
|
|
2094
|
+
import_nestjs_durable_core14.STATE_STORE_CANONICAL,
|
|
2095
|
+
import_nestjs_durable_core14.TRANSPORT_CANONICAL,
|
|
2093
2096
|
import_core5.ModuleRef
|
|
2094
2097
|
]
|
|
2095
2098
|
},
|
|
@@ -2103,7 +2106,7 @@ var DurableModule = class _DurableModule {
|
|
|
2103
2106
|
// or (for a thin worker, no `store`) a `ProxyRunGateway` over `transport` when given, else a
|
|
2104
2107
|
// gateway whose every method rejects with a clear tenant error.
|
|
2105
2108
|
{
|
|
2106
|
-
provide:
|
|
2109
|
+
provide: import_nestjs_durable_core14.RunGateway,
|
|
2107
2110
|
useFactory: /* @__PURE__ */ __name((options, store, engine) => {
|
|
2108
2111
|
if (options.store !== void 0) {
|
|
2109
2112
|
if (!store) {
|
|
@@ -2114,9 +2117,9 @@ var DurableModule = class _DurableModule {
|
|
|
2114
2117
|
return options.transport ? new ProxyRunGateway(options.transport, options.partition ?? "default", options.runGatewayTimeoutMs) : unavailableRunGateway();
|
|
2115
2118
|
}, "useFactory"),
|
|
2116
2119
|
inject: [
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
+
import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL,
|
|
2121
|
+
import_nestjs_durable_core14.STATE_STORE_CANONICAL,
|
|
2122
|
+
import_nestjs_durable_core14.WorkflowEngine
|
|
2120
2123
|
]
|
|
2121
2124
|
},
|
|
2122
2125
|
RunGatewayBootstrap,
|
|
@@ -2130,13 +2133,13 @@ var DurableModule = class _DurableModule {
|
|
|
2130
2133
|
exports: [
|
|
2131
2134
|
WorkflowService,
|
|
2132
2135
|
EntityService,
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2136
|
+
import_nestjs_durable_core14.WorkflowEngine,
|
|
2137
|
+
import_nestjs_durable_core14.STATE_STORE,
|
|
2138
|
+
import_nestjs_durable_core14.STATE_STORE_CANONICAL,
|
|
2139
|
+
import_nestjs_durable_core14.TRANSPORT,
|
|
2140
|
+
import_nestjs_durable_core14.TRANSPORT_CANONICAL,
|
|
2141
|
+
import_nestjs_durable_core14.DURABLE_OPTIONS_CANONICAL,
|
|
2142
|
+
import_nestjs_durable_core14.RunGateway
|
|
2140
2143
|
]
|
|
2141
2144
|
};
|
|
2142
2145
|
}
|
|
@@ -2146,7 +2149,7 @@ DurableModule = _ts_decorate12([
|
|
|
2146
2149
|
], DurableModule);
|
|
2147
2150
|
|
|
2148
2151
|
// src/index.ts
|
|
2149
|
-
var
|
|
2152
|
+
var import_nestjs_durable_core15 = require("@dudousxd/nestjs-durable-core");
|
|
2150
2153
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2151
2154
|
0 && (module.exports = {
|
|
2152
2155
|
CONTEXT_ACCESSOR,
|