@etohq/workflow-engine-redis 1.4.0 → 1.5.1-alpha.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/loaders/redis.d.ts +2 -2
- package/dist/loaders/redis.d.ts.map +1 -1
- package/dist/loaders/redis.js +4 -1
- package/dist/loaders/redis.js.map +1 -1
- package/dist/migrations/Migration20250120111059.d.ts +6 -0
- package/dist/migrations/Migration20250120111059.d.ts.map +1 -0
- package/dist/migrations/Migration20250120111059.js +14 -0
- package/dist/migrations/Migration20250120111059.js.map +1 -0
- package/dist/migrations/Migration20250128174354.d.ts +6 -0
- package/dist/migrations/Migration20250128174354.d.ts.map +1 -0
- package/dist/migrations/Migration20250128174354.js +24 -0
- package/dist/migrations/Migration20250128174354.js.map +1 -0
- package/dist/migrations/Migration20250505101505.d.ts +6 -0
- package/dist/migrations/Migration20250505101505.d.ts.map +1 -0
- package/dist/migrations/Migration20250505101505.js +40 -0
- package/dist/migrations/Migration20250505101505.js.map +1 -0
- package/dist/models/workflow-execution.d.ts +2 -0
- package/dist/models/workflow-execution.d.ts.map +1 -1
- package/dist/models/workflow-execution.js +7 -0
- package/dist/models/workflow-execution.js.map +1 -1
- package/dist/services/workflow-orchestrator.d.ts +16 -7
- package/dist/services/workflow-orchestrator.d.ts.map +1 -1
- package/dist/services/workflow-orchestrator.js +148 -97
- package/dist/services/workflow-orchestrator.js.map +1 -1
- package/dist/services/workflows-module.d.ts +110 -5
- package/dist/services/workflows-module.d.ts.map +1 -1
- package/dist/services/workflows-module.js +117 -13
- package/dist/services/workflows-module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/workflow-orchestrator-storage.d.ts +15 -4
- package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -1
- package/dist/utils/workflow-orchestrator-storage.js +302 -56
- package/dist/utils/workflow-orchestrator-storage.js.map +1 -1
- package/package.json +11 -11
package/dist/loaders/redis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LoaderOptions } from "@etohq/framework/types";
|
|
2
|
-
declare const _default: ({ container, logger, options, dataLoaderOnly
|
|
1
|
+
import { InternalModuleDeclaration, LoaderOptions } from "@etohq/framework/types";
|
|
2
|
+
declare const _default: ({ container, logger, options, dataLoaderOnly }: LoaderOptions, moduleDeclaration: InternalModuleDeclaration) => Promise<void>;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=redis.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,wBAAwB,CAAA;yBAM7B,gDAAgD,aAAa,EAC7D,mBAAmB,yBAAyB,KAC3C,OAAO,CAAC,IAAI,CAAC;AAHhB,wBAsEC"}
|
package/dist/loaders/redis.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const awilix_1 = require("awilix");
|
|
7
7
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
|
-
exports.default = async ({ container, logger, options, dataLoaderOnly,
|
|
8
|
+
exports.default = async ({ container, logger, options, dataLoaderOnly }, moduleDeclaration) => {
|
|
9
9
|
const { url, options: redisOptions, pubsub, } = options?.redis;
|
|
10
10
|
// TODO: get default from ENV VAR
|
|
11
11
|
if (!url) {
|
|
@@ -13,6 +13,7 @@ exports.default = async ({ container, logger, options, dataLoaderOnly, }) => {
|
|
|
13
13
|
}
|
|
14
14
|
const cnnPubSub = pubsub ?? { url, options: redisOptions };
|
|
15
15
|
const queueName = options?.queueName ?? "eto-workflows";
|
|
16
|
+
const jobQueueName = options?.jobQueueName ?? "eto-workflows-jobs";
|
|
16
17
|
let connection;
|
|
17
18
|
let redisPublisher;
|
|
18
19
|
let redisSubscriber;
|
|
@@ -37,12 +38,14 @@ exports.default = async ({ container, logger, options, dataLoaderOnly, }) => {
|
|
|
37
38
|
logger?.error(`An error occurred while connecting to Redis PubSub in module 'workflow-engine-redis': ${err}`);
|
|
38
39
|
}
|
|
39
40
|
container.register({
|
|
41
|
+
isWorkerMode: (0, awilix_1.asValue)(moduleDeclaration.worker_mode !== "server"),
|
|
40
42
|
partialLoading: (0, awilix_1.asValue)(true),
|
|
41
43
|
redisConnection: (0, awilix_1.asValue)(connection),
|
|
42
44
|
redisWorkerConnection: (0, awilix_1.asValue)(workerConnection),
|
|
43
45
|
redisPublisher: (0, awilix_1.asValue)(redisPublisher),
|
|
44
46
|
redisSubscriber: (0, awilix_1.asValue)(redisSubscriber),
|
|
45
47
|
redisQueueName: (0, awilix_1.asValue)(queueName),
|
|
48
|
+
redisJobQueueName: (0, awilix_1.asValue)(jobQueueName),
|
|
46
49
|
redisDisconnectHandler: (0, awilix_1.asValue)(async () => {
|
|
47
50
|
connection.disconnect();
|
|
48
51
|
workerConnection.disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":";;;;;AAIA,mCAAgC;AAChC,sDAA2B;AAG3B,kBAAe,KAAK,EAClB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAiB,EAC7D,iBAA4C,EAC7B,EAAE;IACjB,MAAM,EACJ,GAAG,EACH,OAAO,EAAE,YAAY,EACrB,MAAM,GACP,GAAG,OAAO,EAAE,KAA8B,CAAA;IAE3C,iCAAiC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I,CAAC;IAInB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20250120111059 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20250120111059 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id_transaction_id_unique" ON "workflow_execution" (workflow_id, transaction_id) WHERE deleted_at IS NULL;');
|
|
8
|
+
}
|
|
9
|
+
async down() {
|
|
10
|
+
this.addSql('drop index if exists "IDX_workflow_execution_workflow_id_transaction_id_unique";');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Migration20250120111059 = Migration20250120111059;
|
|
14
|
+
//# sourceMappingURL=Migration20250120111059.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250120111059.js","sourceRoot":"","sources":["../../src/migrations/Migration20250120111059.ts"],"names":[],"mappings":";;;AAAA,sDAAkD;AAElD,MAAa,uBAAwB,SAAQ,sBAAS;IAEpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CAAC,8KAA8K,CAAC,CAAC;IAC9L,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CAAC,kFAAkF,CAAC,CAAC;IAClG,CAAC;CAEF;AAVD,0DAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250128174354.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250128174354.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAKrC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20250128174354 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
class Migration20250128174354 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`alter table if exists "workflow_execution" add column if not exists "retention_time" integer null;`);
|
|
8
|
+
this.addSql(`
|
|
9
|
+
UPDATE workflow_execution
|
|
10
|
+
SET retention_time = (
|
|
11
|
+
SELECT COALESCE(
|
|
12
|
+
(execution->'options'->>'retentionTime')::integer,
|
|
13
|
+
0
|
|
14
|
+
)
|
|
15
|
+
)
|
|
16
|
+
WHERE execution->'options' ? 'retentionTime';
|
|
17
|
+
`);
|
|
18
|
+
}
|
|
19
|
+
async down() {
|
|
20
|
+
this.addSql(`alter table if exists "workflow_execution" drop column if exists "retention_time";`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.Migration20250128174354 = Migration20250128174354;
|
|
24
|
+
//# sourceMappingURL=Migration20250128174354.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250128174354.js","sourceRoot":"","sources":["../../src/migrations/Migration20250128174354.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,MAAa,uBAAwB,SAAQ,sBAAS;IAC3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CACT,oGAAoG,CACrG,CAAA;QACD,IAAI,CAAC,MAAM,CAAC;;;;;;;;;KASX,CAAC,CAAA;IACJ,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CACT,oFAAoF,CACrF,CAAA;IACH,CAAC;CACF;AAtBD,0DAsBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250505101505.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250505101505.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAGjD,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBrC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20250505101505 = void 0;
|
|
4
|
+
const migrations_1 = require("@mikro-orm/migrations");
|
|
5
|
+
const ulid_1 = require("ulid");
|
|
6
|
+
class Migration20250505101505 extends migrations_1.Migration {
|
|
7
|
+
async up() {
|
|
8
|
+
this.addSql(`alter table if exists "workflow_execution" drop constraint if exists "workflow_execution_workflow_id_transaction_id_run_id_unique";`);
|
|
9
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_workflow_id_transaction_id_unique";`);
|
|
10
|
+
this.addSql(`alter table if exists "workflow_execution" drop constraint if exists "PK_workflow_execution_workflow_id_transaction_id";`);
|
|
11
|
+
this.addSql(`alter table if exists "workflow_execution" add column if not exists "run_id" text not null default '${(0, ulid_1.ulid)()}';`);
|
|
12
|
+
this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id_transaction_id_run_id_unique" ON "workflow_execution" (workflow_id, transaction_id, run_id) WHERE deleted_at IS NULL;`);
|
|
13
|
+
/*
|
|
14
|
+
* We mistakenly named this migration differently in the workflow engines; this has caused issues with the migrations. Switching between engines will fail because the primary key is attempted to be set twice.
|
|
15
|
+
* The issue happens in the following scenario:
|
|
16
|
+
* 1. In memory engine is used
|
|
17
|
+
* 2. Migration is run
|
|
18
|
+
* 3. Primary is key added
|
|
19
|
+
* 3. Redis engine is used
|
|
20
|
+
* 4. Migration is run
|
|
21
|
+
* 5. Same primary key is attempted to be set again
|
|
22
|
+
* 6. Migration fails
|
|
23
|
+
*
|
|
24
|
+
* The same scenario can happen if you go from Redis to In memory.
|
|
25
|
+
*
|
|
26
|
+
* With this fix, we ensure the primary key is only ever set once.
|
|
27
|
+
*/
|
|
28
|
+
this.addSql(`alter table if exists "workflow_execution" drop constraint if exists "workflow_execution_pkey";`);
|
|
29
|
+
this.addSql(`alter table if exists "workflow_execution" add constraint "workflow_execution_pkey" primary key ("workflow_id", "transaction_id", "run_id");`);
|
|
30
|
+
}
|
|
31
|
+
async down() {
|
|
32
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_workflow_id_transaction_id_run_id_unique";`);
|
|
33
|
+
this.addSql(`alter table if exists "workflow_execution" drop constraint if exists "workflow_execution_pkey";`);
|
|
34
|
+
this.addSql(`alter table if exists "workflow_execution" drop column if exists "run_id";`);
|
|
35
|
+
this.addSql(`CREATE UNIQUE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id_transaction_id_unique" ON "workflow_execution" (workflow_id, transaction_id) WHERE deleted_at IS NULL;`);
|
|
36
|
+
this.addSql(`alter table if exists "workflow_execution" add constraint "workflow_execution_pkey" primary key ("workflow_id", "transaction_id");`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.Migration20250505101505 = Migration20250505101505;
|
|
40
|
+
//# sourceMappingURL=Migration20250505101505.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250505101505.js","sourceRoot":"","sources":["../../src/migrations/Migration20250505101505.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AACjD,+BAA2B;AAE3B,MAAa,uBAAwB,SAAQ,sBAAS;IAC3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CACT,qIAAqI,CACtI,CAAA;QACD,IAAI,CAAC,MAAM,CACT,kFAAkF,CACnF,CAAA;QACD,IAAI,CAAC,MAAM,CACT,0HAA0H,CAC3H,CAAA;QAED,IAAI,CAAC,MAAM,CACT,uGAAuG,IAAA,WAAI,GAAE,IAAI,CAClH,CAAA;QACD,IAAI,CAAC,MAAM,CACT,6LAA6L,CAC9L,CAAA;QACD;;;;;;;;;;;;;;WAcG;QACH,IAAI,CAAC,MAAM,CACT,iGAAiG,CAClG,CAAA;QACD,IAAI,CAAC,MAAM,CACT,8IAA8I,CAC/I,CAAA;IACH,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CACT,yFAAyF,CAC1F,CAAA;QACD,IAAI,CAAC,MAAM,CACT,iGAAiG,CAClG,CAAA;QACD,IAAI,CAAC,MAAM,CACT,4EAA4E,CAC7E,CAAA;QAED,IAAI,CAAC,MAAM,CACT,8KAA8K,CAC/K,CAAA;QACD,IAAI,CAAC,MAAM,CACT,oIAAoI,CACrI,CAAA;IACH,CAAC;CACF;AA3DD,0DA2DC"}
|
|
@@ -3,8 +3,10 @@ export declare const WorkflowExecution: import("@etohq/framework/utils").DmlEnti
|
|
|
3
3
|
id: import("@etohq/framework/utils").IdProperty;
|
|
4
4
|
workflow_id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
5
5
|
transaction_id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
6
|
+
run_id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").TextProperty>;
|
|
6
7
|
execution: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
7
8
|
context: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
|
|
8
9
|
state: import("@etohq/framework/utils").EnumProperty<typeof TransactionState>;
|
|
10
|
+
retention_time: import("@etohq/framework/utils").NullableModifier<number, import("@etohq/framework/utils").NumberProperty>;
|
|
9
11
|
}>, "workflow_execution">;
|
|
10
12
|
//# sourceMappingURL=workflow-execution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../src/models/workflow-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAGjE,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../src/models/workflow-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAGjE,eAAO,MAAM,iBAAiB;;;;;;;;;yBAiC1B,CAAA"}
|
|
@@ -8,9 +8,11 @@ exports.WorkflowExecution = utils_1.model
|
|
|
8
8
|
id: utils_1.model.id({ prefix: "wf_exec" }),
|
|
9
9
|
workflow_id: utils_1.model.text().primaryKey(),
|
|
10
10
|
transaction_id: utils_1.model.text().primaryKey(),
|
|
11
|
+
run_id: utils_1.model.text().primaryKey(),
|
|
11
12
|
execution: utils_1.model.json().nullable(),
|
|
12
13
|
context: utils_1.model.json().nullable(),
|
|
13
14
|
state: utils_1.model.enum(orchestration_1.TransactionState),
|
|
15
|
+
retention_time: utils_1.model.number().nullable(),
|
|
14
16
|
})
|
|
15
17
|
.indexes([
|
|
16
18
|
{
|
|
@@ -25,6 +27,11 @@ exports.WorkflowExecution = utils_1.model
|
|
|
25
27
|
on: ["transaction_id"],
|
|
26
28
|
where: "deleted_at IS NULL",
|
|
27
29
|
},
|
|
30
|
+
{
|
|
31
|
+
on: ["workflow_id", "transaction_id", "run_id"],
|
|
32
|
+
unique: true,
|
|
33
|
+
where: "deleted_at IS NULL",
|
|
34
|
+
},
|
|
28
35
|
{
|
|
29
36
|
on: ["state"],
|
|
30
37
|
where: "deleted_at IS NULL",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-execution.js","sourceRoot":"","sources":["../../src/models/workflow-execution.ts"],"names":[],"mappings":";;;AAAA,kEAAiE;AACjE,kDAA8C;AAEjC,QAAA,iBAAiB,GAAG,aAAK;KACnC,MAAM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KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,gBAAgB,CAAC;QACtB,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,aAAa,EAAE,gBAAgB,EAAE,QAAQ,CAAC;QAC/C,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,OAAO,CAAC;QACb,KAAK,EAAE,oBAAoB;KAC5B;CACF,CAAC,CAAA"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { DistributedTransactionEvents, DistributedTransactionType, TransactionStep } from "@etohq/framework/orchestration";
|
|
2
2
|
import { ContainerLike, Context, EtoContainer } from "@etohq/framework/types";
|
|
3
|
-
import {
|
|
3
|
+
import { TransactionState } from "@etohq/framework/utils";
|
|
4
|
+
import { FlowCancelOptions, FlowRunOptions, ReturnWorkflow } from "@etohq/framework/workflows-sdk";
|
|
4
5
|
import Redis from "ioredis";
|
|
5
6
|
import type { RedisDistributedTransactionStorage } from "../utils";
|
|
6
7
|
export type WorkflowOrchestratorRunOptions<T> = Omit<FlowRunOptions<T>, "container"> & {
|
|
7
8
|
transactionId?: string;
|
|
9
|
+
runId?: string;
|
|
10
|
+
container?: ContainerLike;
|
|
11
|
+
};
|
|
12
|
+
export type WorkflowOrchestratorCancelOptions = Omit<FlowCancelOptions, "transaction" | "transactionId" | "container"> & {
|
|
13
|
+
transactionId: string;
|
|
14
|
+
runId?: string;
|
|
8
15
|
container?: ContainerLike;
|
|
9
16
|
};
|
|
10
17
|
type RegisterStepSuccessOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input">;
|
|
@@ -22,6 +29,7 @@ type NotifyOptions = {
|
|
|
22
29
|
response?: unknown;
|
|
23
30
|
result?: unknown;
|
|
24
31
|
errors?: unknown[];
|
|
32
|
+
state?: TransactionState;
|
|
25
33
|
};
|
|
26
34
|
type SubscriberHandler = {
|
|
27
35
|
(input: NotifyOptions): void;
|
|
@@ -60,20 +68,21 @@ export declare class WorkflowOrchestratorService {
|
|
|
60
68
|
onApplicationPrepareShutdown(): Promise<void>;
|
|
61
69
|
onApplicationStart(): Promise<void>;
|
|
62
70
|
private triggerParentStep;
|
|
63
|
-
run<T = unknown>(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorRunOptions<T
|
|
64
|
-
|
|
71
|
+
run<T = unknown>(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorRunOptions<T>): Promise<any>;
|
|
72
|
+
cancel(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorCancelOptions): Promise<any>;
|
|
73
|
+
getRunningTransaction(workflowId: string, transactionId: string, context?: Context): Promise<DistributedTransactionType>;
|
|
65
74
|
setStepSuccess<T = unknown>({ idempotencyKey, stepResponse, options, }: {
|
|
66
75
|
idempotencyKey: string | IdempotencyKeyParts;
|
|
67
76
|
stepResponse: unknown;
|
|
68
77
|
options?: RegisterStepSuccessOptions<T>;
|
|
69
|
-
}
|
|
78
|
+
}): Promise<any>;
|
|
70
79
|
setStepFailure<T = unknown>({ idempotencyKey, stepResponse, options, }: {
|
|
71
80
|
idempotencyKey: string | IdempotencyKeyParts;
|
|
72
81
|
stepResponse: unknown;
|
|
73
82
|
options?: RegisterStepSuccessOptions<T>;
|
|
74
|
-
}
|
|
75
|
-
subscribe({ workflowId, transactionId, subscriber, subscriberId }: SubscribeOptions
|
|
76
|
-
unsubscribe({ workflowId, transactionId, subscriberOrId }: UnsubscribeOptions
|
|
83
|
+
}): Promise<any>;
|
|
84
|
+
subscribe({ workflowId, transactionId, subscriber, subscriberId, }: SubscribeOptions): void;
|
|
85
|
+
unsubscribe({ workflowId, transactionId, subscriberOrId, }: UnsubscribeOptions): void;
|
|
77
86
|
private notify;
|
|
78
87
|
private getChannelName;
|
|
79
88
|
private buildWorkflowEvents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-orchestrator.d.ts","sourceRoot":"","sources":["../../src/services/workflow-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,4BAA4B,EAC5B,0BAA0B,EAE1B,eAAe,EAEhB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,aAAa,EACb,OAAO,EAEP,YAAY,EACb,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"workflow-orchestrator.d.ts","sourceRoot":"","sources":["../../src/services/workflow-orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,4BAA4B,EAC5B,0BAA0B,EAE1B,eAAe,EAEhB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EACL,aAAa,EACb,OAAO,EAEP,YAAY,EACb,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAY,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,EACL,iBAAiB,EACjB,cAAc,EAGd,cAAc,EACf,MAAM,gCAAgC,CAAA;AACvC,OAAO,KAAK,MAAM,SAAS,CAAA;AAG3B,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,UAAU,CAAA;AAElE,MAAM,MAAM,8BAA8B,CAAC,CAAC,IAAI,IAAI,CAClD,cAAc,CAAC,CAAC,CAAC,EACjB,WAAW,CACZ,GAAG;IACF,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,iCAAiC,GAAG,IAAI,CAClD,iBAAiB,EACjB,aAAa,GAAG,eAAe,GAAG,WAAW,CAC9C,GAAG;IACF,aAAa,EAAE,MAAM,CAAA;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,aAAa,CAAA;CAC1B,CAAA;AAED,KAAK,0BAA0B,CAAC,CAAC,IAAI,IAAI,CACvC,8BAA8B,CAAC,CAAC,C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