@dudousxd/nestjs-durable 0.30.0 → 0.30.2
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 +26 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.ts +11 -3
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery,
|
|
1
|
+
import { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
4
4
|
import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
|
|
@@ -717,7 +717,9 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
717
717
|
private request;
|
|
718
718
|
topology(): DurableTopology;
|
|
719
719
|
getRunDetail(runId: string): Promise<RunDetail | null>;
|
|
720
|
-
|
|
720
|
+
/** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
|
|
721
|
+
* it through as plain JSON, so a tenant's list rows name the wait too. */
|
|
722
|
+
listRuns(query: RunQuery): Promise<RunListItem[]>;
|
|
721
723
|
/** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
|
|
722
724
|
workerHealth(): Promise<GroupHealth[]>;
|
|
723
725
|
cancel(runId: string, opts?: {
|
|
@@ -728,6 +730,9 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
728
730
|
retryWithInput(runId: string, input: unknown): Promise<{
|
|
729
731
|
runId: string;
|
|
730
732
|
} | null>;
|
|
733
|
+
redispatchPending(runId: string): Promise<(RunResult & {
|
|
734
|
+
redispatched: number;
|
|
735
|
+
}) | null>;
|
|
731
736
|
subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
|
|
732
737
|
}
|
|
733
738
|
|
|
@@ -804,7 +809,7 @@ declare class StoreRunGateway implements RunGateway {
|
|
|
804
809
|
constructor(store: StateStore, engine: WorkflowEngine);
|
|
805
810
|
topology(): DurableTopology;
|
|
806
811
|
getRunDetail(runId: string): Promise<RunDetail | null>;
|
|
807
|
-
listRuns(query: RunQuery): Promise<
|
|
812
|
+
listRuns(query: RunQuery): Promise<RunListItem[]>;
|
|
808
813
|
/** Every group the engine knows about — unscoped. A tenant proxy's request is scoped by the
|
|
809
814
|
* `RunRequestResponder` (to the requester's `@<tenant>` groups); the operator's own UI sees all. */
|
|
810
815
|
workerHealth(): Promise<GroupHealth[]>;
|
|
@@ -817,6 +822,9 @@ declare class StoreRunGateway implements RunGateway {
|
|
|
817
822
|
retryWithInput(runId: string, input: unknown): Promise<{
|
|
818
823
|
runId: string;
|
|
819
824
|
} | null>;
|
|
825
|
+
redispatchPending(runId: string): Promise<(RunResult & {
|
|
826
|
+
redispatched: number;
|
|
827
|
+
}) | null>;
|
|
820
828
|
subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
|
|
821
829
|
}
|
|
822
830
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery,
|
|
1
|
+
import { StepError, WorkflowRef, SingletonConfig, StateStore, Transport, NamedTransport, ControlPlane, ScheduledWorkflow, RetentionPolicy, QueueConfig, AdmissionBackend, WorkflowClass, WorkflowInputOf, StartOptions, RunResult, RunGateway, WorkflowEngine, EntityHandler, DurableTopology, RunDetail, RunQuery, RunListItem, GroupHealth, EngineEvent, RunRequest, RunReply, StepInvocation, TenantEvent } from '@dudousxd/nestjs-durable-core';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { ConcurrencyOption, StartRunDeps, RunRedisWorkerOptions, RunningWorker, DurableWorkerRuntime } from '@dudousxd/durable-worker';
|
|
4
4
|
import { DynamicModule, InjectionToken, OnModuleInit, OnApplicationBootstrap, OnApplicationShutdown, Provider } from '@nestjs/common';
|
|
@@ -717,7 +717,9 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
717
717
|
private request;
|
|
718
718
|
topology(): DurableTopology;
|
|
719
719
|
getRunDetail(runId: string): Promise<RunDetail | null>;
|
|
720
|
-
|
|
720
|
+
/** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
|
|
721
|
+
* it through as plain JSON, so a tenant's list rows name the wait too. */
|
|
722
|
+
listRuns(query: RunQuery): Promise<RunListItem[]>;
|
|
721
723
|
/** Round-trips to the operator, which scopes the result to this tenant's own `@<tenant>` groups. */
|
|
722
724
|
workerHealth(): Promise<GroupHealth[]>;
|
|
723
725
|
cancel(runId: string, opts?: {
|
|
@@ -728,6 +730,9 @@ declare class ProxyRunGateway implements RunGateway {
|
|
|
728
730
|
retryWithInput(runId: string, input: unknown): Promise<{
|
|
729
731
|
runId: string;
|
|
730
732
|
} | null>;
|
|
733
|
+
redispatchPending(runId: string): Promise<(RunResult & {
|
|
734
|
+
redispatched: number;
|
|
735
|
+
}) | null>;
|
|
731
736
|
subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
|
|
732
737
|
}
|
|
733
738
|
|
|
@@ -804,7 +809,7 @@ declare class StoreRunGateway implements RunGateway {
|
|
|
804
809
|
constructor(store: StateStore, engine: WorkflowEngine);
|
|
805
810
|
topology(): DurableTopology;
|
|
806
811
|
getRunDetail(runId: string): Promise<RunDetail | null>;
|
|
807
|
-
listRuns(query: RunQuery): Promise<
|
|
812
|
+
listRuns(query: RunQuery): Promise<RunListItem[]>;
|
|
808
813
|
/** Every group the engine knows about — unscoped. A tenant proxy's request is scoped by the
|
|
809
814
|
* `RunRequestResponder` (to the requester's `@<tenant>` groups); the operator's own UI sees all. */
|
|
810
815
|
workerHealth(): Promise<GroupHealth[]>;
|
|
@@ -817,6 +822,9 @@ declare class StoreRunGateway implements RunGateway {
|
|
|
817
822
|
retryWithInput(runId: string, input: unknown): Promise<{
|
|
818
823
|
runId: string;
|
|
819
824
|
} | null>;
|
|
825
|
+
redispatchPending(runId: string): Promise<(RunResult & {
|
|
826
|
+
redispatched: number;
|
|
827
|
+
}) | null>;
|
|
820
828
|
subscribe(runId: string, onEvent: (event: EngineEvent) => void): () => void;
|
|
821
829
|
}
|
|
822
830
|
|
package/dist/index.js
CHANGED
|
@@ -451,6 +451,9 @@ function unavailableRunGateway() {
|
|
|
451
451
|
retryWithInput(_runId, _input) {
|
|
452
452
|
return tenantGatewayUnavailable("retryWithInput");
|
|
453
453
|
},
|
|
454
|
+
redispatchPending(_runId) {
|
|
455
|
+
return tenantGatewayUnavailable("redispatchPending");
|
|
456
|
+
},
|
|
454
457
|
subscribe(_runId, _onEvent) {
|
|
455
458
|
throw new Error("RunGateway.subscribe() is not available \u2014 pass `transport` to use RunGateway.");
|
|
456
459
|
}
|
|
@@ -836,6 +839,8 @@ var ProxyRunGateway = class {
|
|
|
836
839
|
runId
|
|
837
840
|
});
|
|
838
841
|
}
|
|
842
|
+
/** The control plane's `StoreRunGateway` resolves each run's `waiting` descriptor; the reply carries
|
|
843
|
+
* it through as plain JSON, so a tenant's list rows name the wait too. */
|
|
839
844
|
listRuns(query) {
|
|
840
845
|
return this.request({
|
|
841
846
|
kind: "listRuns",
|
|
@@ -877,6 +882,12 @@ var ProxyRunGateway = class {
|
|
|
877
882
|
input
|
|
878
883
|
});
|
|
879
884
|
}
|
|
885
|
+
redispatchPending(runId) {
|
|
886
|
+
return this.request({
|
|
887
|
+
kind: "redispatch",
|
|
888
|
+
runId
|
|
889
|
+
});
|
|
890
|
+
}
|
|
880
891
|
subscribe(runId, onEvent) {
|
|
881
892
|
const unsubscribe = this.transport.onTenantEvent?.(this.tenant, (evt) => {
|
|
882
893
|
if (evt.event.runId === runId) onEvent(evt.event);
|
|
@@ -1108,12 +1119,14 @@ var RunRequestResponder = class {
|
|
|
1108
1119
|
return this.gateway.continue(body.runId);
|
|
1109
1120
|
case "retryWithInput":
|
|
1110
1121
|
return this.gateway.retryWithInput(body.runId, body.input);
|
|
1122
|
+
case "redispatch":
|
|
1123
|
+
return this.gateway.redispatchPending(body.runId);
|
|
1111
1124
|
}
|
|
1112
1125
|
}
|
|
1113
1126
|
};
|
|
1114
1127
|
|
|
1115
1128
|
// src/store-run-gateway.ts
|
|
1116
|
-
import { STATE_STORE_CANONICAL as STATE_STORE_CANONICAL2, WorkflowEngine as WorkflowEngine2 } from "@dudousxd/nestjs-durable-core";
|
|
1129
|
+
import { STATE_STORE_CANONICAL as STATE_STORE_CANONICAL2, WorkflowEngine as WorkflowEngine2, indexWaitersByRun, resolveRunWaiting } from "@dudousxd/nestjs-durable-core";
|
|
1117
1130
|
import { Inject as Inject5, Injectable as Injectable8 } from "@nestjs/common";
|
|
1118
1131
|
function _ts_decorate8(decorators, target, key, desc) {
|
|
1119
1132
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1160,8 +1173,16 @@ var StoreRunGateway = class {
|
|
|
1160
1173
|
children
|
|
1161
1174
|
};
|
|
1162
1175
|
}
|
|
1163
|
-
listRuns(query) {
|
|
1164
|
-
|
|
1176
|
+
async listRuns(query) {
|
|
1177
|
+
const runs = await this.store.listRuns(query);
|
|
1178
|
+
const waiterByRun = indexWaitersByRun(await this.store.listSignalWaiters(""));
|
|
1179
|
+
return runs.map((run) => {
|
|
1180
|
+
const waiting = resolveRunWaiting(run, waiterByRun);
|
|
1181
|
+
return waiting ? {
|
|
1182
|
+
...run,
|
|
1183
|
+
waiting
|
|
1184
|
+
} : run;
|
|
1185
|
+
});
|
|
1165
1186
|
}
|
|
1166
1187
|
/** Every group the engine knows about — unscoped. A tenant proxy's request is scoped by the
|
|
1167
1188
|
* `RunRequestResponder` (to the requester's `@<tenant>` groups); the operator's own UI sees all. */
|
|
@@ -1181,6 +1202,9 @@ var StoreRunGateway = class {
|
|
|
1181
1202
|
retryWithInput(runId, input) {
|
|
1182
1203
|
return this.engine.retryWithInput(runId, input);
|
|
1183
1204
|
}
|
|
1205
|
+
redispatchPending(runId) {
|
|
1206
|
+
return this.engine.redispatchPending(runId);
|
|
1207
|
+
}
|
|
1184
1208
|
subscribe(runId, onEvent) {
|
|
1185
1209
|
return this.engine.subscribe((event) => {
|
|
1186
1210
|
if (event.runId === runId) onEvent(event);
|