@medusajs/workflow-engine-redis 3.0.0-snapshot-20250410105645 → 3.0.0-snapshot-20251104004624
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.map +1 -1
- package/dist/loaders/redis.js +10 -10
- package/dist/loaders/redis.js.map +1 -1
- package/dist/loaders/utils.d.ts.map +1 -1
- package/dist/loaders/utils.js +1 -1
- package/dist/loaders/utils.js.map +1 -1
- package/dist/migrations/Migration20231228143900.d.ts +1 -1
- package/dist/migrations/Migration20231228143900.d.ts.map +1 -1
- package/dist/migrations/Migration20231228143900.js +1 -1
- package/dist/migrations/Migration20231228143900.js.map +1 -1
- package/dist/migrations/Migration20241206123341.d.ts +1 -1
- package/dist/migrations/Migration20241206123341.d.ts.map +1 -1
- package/dist/migrations/Migration20241206123341.js +1 -1
- package/dist/migrations/Migration20241206123341.js.map +1 -1
- package/dist/migrations/Migration20250120111059.d.ts +1 -1
- package/dist/migrations/Migration20250120111059.d.ts.map +1 -1
- package/dist/migrations/Migration20250120111059.js +1 -1
- package/dist/migrations/Migration20250120111059.js.map +1 -1
- package/dist/migrations/Migration20250128174354.d.ts +1 -1
- package/dist/migrations/Migration20250128174354.d.ts.map +1 -1
- package/dist/migrations/Migration20250128174354.js +1 -1
- package/dist/migrations/Migration20250128174354.js.map +1 -1
- 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/migrations/Migration20250819110923.d.ts +6 -0
- package/dist/migrations/Migration20250819110923.d.ts.map +1 -0
- package/dist/migrations/Migration20250819110923.js +14 -0
- package/dist/migrations/Migration20250819110923.js.map +1 -0
- package/dist/migrations/Migration20250819110924.d.ts +6 -0
- package/dist/migrations/Migration20250819110924.d.ts.map +1 -0
- package/dist/migrations/Migration20250819110924.js +16 -0
- package/dist/migrations/Migration20250819110924.js.map +1 -0
- package/dist/migrations/Migration20250908080326.d.ts +6 -0
- package/dist/migrations/Migration20250908080326.d.ts.map +1 -0
- package/dist/migrations/Migration20250908080326.js +20 -0
- package/dist/migrations/Migration20250908080326.js.map +1 -0
- package/dist/models/workflow-execution.d.ts +1 -0
- package/dist/models/workflow-execution.d.ts.map +1 -1
- package/dist/models/workflow-execution.js +22 -1
- package/dist/models/workflow-execution.js.map +1 -1
- package/dist/services/workflow-orchestrator.d.ts +16 -3
- package/dist/services/workflow-orchestrator.d.ts.map +1 -1
- package/dist/services/workflow-orchestrator.js +247 -118
- package/dist/services/workflow-orchestrator.js.map +1 -1
- package/dist/services/workflows-module.d.ts +114 -9
- package/dist/services/workflows-module.d.ts.map +1 -1
- package/dist/services/workflows-module.js +115 -52
- package/dist/services/workflows-module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/workflow-orchestrator-storage.d.ts +10 -3
- package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -1
- package/dist/utils/workflow-orchestrator-storage.js +334 -134
- package/dist/utils/workflow-orchestrator-storage.js.map +1 -1
- package/package.json +14 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EACd,MAAM,2BAA2B,CAAA;yBAMhC,gDAAgD,aAAa,EAC7D,mBAAmB,yBAAyB,KAC3C,OAAO,CAAC,IAAI,CAAC;AAHhB,wBAwEC"}
|
package/dist/loaders/redis.js
CHANGED
|
@@ -3,17 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const awilix_1 = require("awilix");
|
|
6
|
+
const awilix_1 = require("@medusajs/framework/awilix");
|
|
7
7
|
const ioredis_1 = __importDefault(require("ioredis"));
|
|
8
8
|
exports.default = async ({ container, logger, options, dataLoaderOnly }, moduleDeclaration) => {
|
|
9
|
-
const { url, options: redisOptions, pubsub, } = options?.redis;
|
|
9
|
+
const { url, options: redisOptions, jobQueueName, queueName, pubsub, } = options?.redis;
|
|
10
10
|
// TODO: get default from ENV VAR
|
|
11
11
|
if (!url) {
|
|
12
12
|
throw Error("No `redis.url` provided in `workflowOrchestrator` module options. It is required for the Workflow Orchestrator Redis.");
|
|
13
13
|
}
|
|
14
14
|
const cnnPubSub = pubsub ?? { url, options: redisOptions };
|
|
15
|
-
const
|
|
16
|
-
const
|
|
15
|
+
const queueName_ = queueName ?? "medusa-workflows";
|
|
16
|
+
const jobQueueName_ = jobQueueName ?? "medusa-workflows-jobs";
|
|
17
17
|
let connection;
|
|
18
18
|
let redisPublisher;
|
|
19
19
|
let redisSubscriber;
|
|
@@ -24,18 +24,18 @@ exports.default = async ({ container, logger, options, dataLoaderOnly }, moduleD
|
|
|
24
24
|
...(redisOptions ?? {}),
|
|
25
25
|
maxRetriesPerRequest: null,
|
|
26
26
|
});
|
|
27
|
-
logger?.info(`Connection to Redis in module 'workflow-engine-redis' established`);
|
|
27
|
+
logger?.info(`[Workflow-engine-redis] Connection to Redis in module 'workflow-engine-redis' established`);
|
|
28
28
|
}
|
|
29
29
|
catch (err) {
|
|
30
|
-
logger?.error(`An error occurred while connecting to Redis in module 'workflow-engine-redis': ${err}`);
|
|
30
|
+
logger?.error(`[Workflow-engine-redis] An error occurred while connecting to Redis in module 'workflow-engine-redis': ${err}`);
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
redisPublisher = await getConnection(cnnPubSub.url, cnnPubSub.options);
|
|
34
34
|
redisSubscriber = await getConnection(cnnPubSub.url, cnnPubSub.options);
|
|
35
|
-
logger?.info(`Connection to Redis PubSub in module 'workflow-engine-redis' established`);
|
|
35
|
+
logger?.info(`[Workflow-engine-redis] Connection to Redis PubSub in module 'workflow-engine-redis' established`);
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
|
38
|
-
logger?.error(`An error occurred while connecting to Redis PubSub in module 'workflow-engine-redis': ${err}`);
|
|
38
|
+
logger?.error(`[Workflow-engine-redis] An error occurred while connecting to Redis PubSub in module 'workflow-engine-redis': ${err}`);
|
|
39
39
|
}
|
|
40
40
|
container.register({
|
|
41
41
|
isWorkerMode: (0, awilix_1.asValue)(moduleDeclaration.worker_mode !== "server"),
|
|
@@ -44,8 +44,8 @@ exports.default = async ({ container, logger, options, dataLoaderOnly }, moduleD
|
|
|
44
44
|
redisWorkerConnection: (0, awilix_1.asValue)(workerConnection),
|
|
45
45
|
redisPublisher: (0, awilix_1.asValue)(redisPublisher),
|
|
46
46
|
redisSubscriber: (0, awilix_1.asValue)(redisSubscriber),
|
|
47
|
-
redisQueueName: (0, awilix_1.asValue)(
|
|
48
|
-
redisJobQueueName: (0, awilix_1.asValue)(
|
|
47
|
+
redisQueueName: (0, awilix_1.asValue)(queueName_),
|
|
48
|
+
redisJobQueueName: (0, awilix_1.asValue)(jobQueueName_),
|
|
49
49
|
redisDisconnectHandler: (0, awilix_1.asValue)(async () => {
|
|
50
50
|
connection.disconnect();
|
|
51
51
|
workerConnection.disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":";;;;;AAIA,
|
|
1
|
+
{"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":";;;;;AAIA,uDAAoD;AACpD,sDAA2B;AAG3B,kBAAe,KAAK,EAClB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,cA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"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":"yBAGsB;;;CAA6B,KAAG,OAAO,CAAC,IAAI,CAAC;AAAnE,wBAOC"}
|
package/dist/loaders/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const awilix_1 = require("awilix");
|
|
3
|
+
const awilix_1 = require("@medusajs/framework/awilix");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
exports.default = async ({ container, dataLoaderOnly }) => {
|
|
6
6
|
container.register({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":";;AAAA,uDAA6D;AAC7D,oCAA6D;AAE7D,kBAAe,KAAK,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,EAAiB,EAAE;IACpE,SAAS,CAAC,QAAQ,CAAC;QACjB,kCAAkC,EAAE,IAAA,gBAAO,EACzC,0CAAkC,CACnC,CAAC,SAAS,EAAE;QACb,cAAc,EAAE,IAAA,gBAAO,EAAC,CAAC,CAAC,cAAc,CAAC;KAC1C,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20231228143900.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20231228143900.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20231228143900.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20231228143900.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAY5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20231221104256 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20231221104256 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
7
|
this.addSql(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20231228143900.js","sourceRoot":"","sources":["../../src/migrations/Migration20231228143900.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20231228143900.js","sourceRoot":"","sources":["../../src/migrations/Migration20231228143900.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AAEpE,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT;;;;;;;;;;;;;;;;;;;OAmBC,CACF,CAAA;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,MAAM,CACT;;;;;;;OAOC,CACF,CAAA;IACH,CAAC;CACF;AAtCD,0DAsCC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20241206123341.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241206123341.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20241206123341.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241206123341.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB1B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20241206123341 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20241206123341 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
7
|
this.addSql(`DROP INDEX IF EXISTS "IDX_workflow_execution_id";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20241206123341.js","sourceRoot":"","sources":["../../src/migrations/Migration20241206123341.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20241206123341.js","sourceRoot":"","sources":["../../src/migrations/Migration20241206123341.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AAEpE,MAAa,uBAAwB,SAAQ,sBAAS;IACpD,KAAK,CAAC,EAAE;QACN,IAAI,CAAC,MAAM,CACT;;;2DAGqD,CACtD,CAAA;QACD,IAAI,CAAC,MAAM,CACT,+HAA+H,CAChI,CAAA;QACD,IAAI,CAAC,MAAM,CACT,+GAA+G,CAChH,CAAA;QACD,IAAI,CAAC,MAAM,CACT,iIAAiI,CAClI,CAAA;QACD,IAAI,CAAC,MAAM,CACT,uIAAuI,CACxI,CAAA;QACD,IAAI,CAAC,MAAM,CACT,qHAAqH,CACtH,CAAA;IACH,CAAC;CACF;AAxBD,0DAwBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20250120111059.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250120111059.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20250120111059.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250120111059.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,qBAAa,uBAAwB,SAAQ,SAAS;IAE9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAInB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20250120111059 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20250120111059 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
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;');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20250120111059.js","sourceRoot":"","sources":["../../src/migrations/Migration20250120111059.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20250120111059.js","sourceRoot":"","sources":["../../src/migrations/Migration20250120111059.ts"],"names":[],"mappings":";;;AAAA,yEAAqE;AAErE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20250128174354.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250128174354.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20250128174354.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250128174354.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAgBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAKrC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20250128174354 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20250128174354 extends migrations_1.Migration {
|
|
6
6
|
async up() {
|
|
7
7
|
this.addSql(`alter table if exists "workflow_execution" add column if not exists "retention_time" integer null;`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20250128174354.js","sourceRoot":"","sources":["../../src/migrations/Migration20250128174354.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20250128174354.js","sourceRoot":"","sources":["../../src/migrations/Migration20250128174354.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AAEpE,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,0CAA0C,CAAA;AAGpE,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("@medusajs/framework/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,yEAAoE;AACpE,+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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250819110923.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250819110923.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAC;AAErE,qBAAa,uBAAwB,SAAQ,SAAS;IAErC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAInB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAIrC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20250819110923 = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
|
+
class Migration20250819110923 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_run_id" ON "workflow_execution" (run_id) WHERE deleted_at IS NULL;`);
|
|
8
|
+
}
|
|
9
|
+
async down() {
|
|
10
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_run_id";`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.Migration20250819110923 = Migration20250819110923;
|
|
14
|
+
//# sourceMappingURL=Migration20250819110923.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250819110923.js","sourceRoot":"","sources":["../../src/migrations/Migration20250819110923.ts"],"names":[],"mappings":";;;AAAA,yEAAqE;AAErE,MAAa,uBAAwB,SAAQ,sBAAS;IAE3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CAAC,uHAAuH,CAAC,CAAC;IACvI,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,uDAAuD,CAAC,CAAC;IACvE,CAAC;CAEF;AAVD,0DAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250819110924.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250819110924.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAUnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAOrC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20250819110924 = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/framework/mikro-orm/migrations");
|
|
5
|
+
class Migration20250819110924 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id_transaction_id" ON "workflow_execution" (workflow_id, transaction_id) WHERE deleted_at IS NULL;`);
|
|
8
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_run_id" ON "workflow_execution" (run_id) WHERE deleted_at IS NULL;`);
|
|
9
|
+
}
|
|
10
|
+
async down() {
|
|
11
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_workflow_id_transaction_id";`);
|
|
12
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_run_id";`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Migration20250819110924 = Migration20250819110924;
|
|
16
|
+
//# sourceMappingURL=Migration20250819110924.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250819110924.js","sourceRoot":"","sources":["../../src/migrations/Migration20250819110924.ts"],"names":[],"mappings":";;;AAAA,yEAAoE;AAEpE,MAAa,uBAAwB,SAAQ,sBAAS;IAC3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CACT,gKAAgK,CACjK,CAAA;QAED,IAAI,CAAC,MAAM,CACT,uHAAuH,CACxH,CAAA;IACH,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CACT,2EAA2E,CAC5E,CAAA;QAED,IAAI,CAAC,MAAM,CAAC,uDAAuD,CAAC,CAAA;IACtE,CAAC;CACF;AAlBD,0DAkBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250908080326.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250908080326.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AAE/D,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAenB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAcrC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20250908080326 = void 0;
|
|
4
|
+
const migrations_1 = require("@medusajs/deps/mikro-orm/migrations");
|
|
5
|
+
class Migration20250908080326 extends migrations_1.Migration {
|
|
6
|
+
async up() {
|
|
7
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id_transaction_id" ON "workflow_execution" (workflow_id, transaction_id) WHERE deleted_at IS NULL;`);
|
|
8
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_state_updated_at" ON "workflow_execution" (state, updated_at) WHERE deleted_at IS NULL;`);
|
|
9
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_retention_time_updated_at_state" ON "workflow_execution" (retention_time, updated_at, state) WHERE deleted_at IS NULL AND retention_time IS NOT NULL;`);
|
|
10
|
+
this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_updated_at_retention_time" ON "workflow_execution" (updated_at, retention_time) WHERE deleted_at IS NULL AND retention_time IS NOT NULL AND state IN ('done', 'failed', 'reverted');`);
|
|
11
|
+
}
|
|
12
|
+
async down() {
|
|
13
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_workflow_id_transaction_id";`);
|
|
14
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_state_updated_at";`);
|
|
15
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_retention_time_updated_at_state";`);
|
|
16
|
+
this.addSql(`drop index if exists "IDX_workflow_execution_updated_at_retention_time";`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.Migration20250908080326 = Migration20250908080326;
|
|
20
|
+
//# sourceMappingURL=Migration20250908080326.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250908080326.js","sourceRoot":"","sources":["../../src/migrations/Migration20250908080326.ts"],"names":[],"mappings":";;;AAAA,oEAA+D;AAE/D,MAAa,uBAAwB,SAAQ,sBAAS;IAC3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CACT,gKAAgK,CACjK,CAAA;QACD,IAAI,CAAC,MAAM,CACT,4IAA4I,CAC7I,CAAA;QACD,IAAI,CAAC,MAAM,CACT,0MAA0M,CAC3M,CAAA;QACD,IAAI,CAAC,MAAM,CACT,yOAAyO,CAC1O,CAAA;IACH,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CACT,2EAA2E,CAC5E,CAAA;QACD,IAAI,CAAC,MAAM,CACT,iEAAiE,CAClE,CAAA;QACD,IAAI,CAAC,MAAM,CACT,gFAAgF,CACjF,CAAA;QACD,IAAI,CAAC,MAAM,CACT,0EAA0E,CAC3E,CAAA;IACH,CAAC;CACF;AA9BD,0DA8BC"}
|
|
@@ -3,6 +3,7 @@ export declare const WorkflowExecution: import("@medusajs/framework/utils").DmlE
|
|
|
3
3
|
id: import("@medusajs/framework/utils").IdProperty;
|
|
4
4
|
workflow_id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
5
5
|
transaction_id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
6
|
+
run_id: import("@medusajs/framework/utils").PrimaryKeyModifier<string, import("@medusajs/framework/utils").TextProperty>;
|
|
6
7
|
execution: import("@medusajs/framework/utils").NullableModifier<Record<string, unknown>, import("@medusajs/framework/utils").JSONProperty>;
|
|
7
8
|
context: import("@medusajs/framework/utils").NullableModifier<Record<string, unknown>, import("@medusajs/framework/utils").JSONProperty>;
|
|
8
9
|
state: import("@medusajs/framework/utils").EnumProperty<typeof TransactionState>;
|
|
@@ -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,mCAAmC,CAAA;AAGpE,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,mCAAmC,CAAA;AAGpE,eAAO,MAAM,iBAAiB;;;;;;;;;yBAsD1B,CAAA"}
|
|
@@ -8,6 +8,7 @@ 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),
|
|
@@ -27,7 +28,7 @@ exports.WorkflowExecution = utils_1.model
|
|
|
27
28
|
where: "deleted_at IS NULL",
|
|
28
29
|
},
|
|
29
30
|
{
|
|
30
|
-
on: ["workflow_id", "transaction_id"],
|
|
31
|
+
on: ["workflow_id", "transaction_id", "run_id"],
|
|
31
32
|
unique: true,
|
|
32
33
|
where: "deleted_at IS NULL",
|
|
33
34
|
},
|
|
@@ -35,5 +36,25 @@ exports.WorkflowExecution = utils_1.model
|
|
|
35
36
|
on: ["state"],
|
|
36
37
|
where: "deleted_at IS NULL",
|
|
37
38
|
},
|
|
39
|
+
{
|
|
40
|
+
on: ["run_id"],
|
|
41
|
+
where: "deleted_at IS NULL",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
on: ["workflow_id", "transaction_id"],
|
|
45
|
+
where: "deleted_at IS NULL",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
on: ["state", "updated_at"],
|
|
49
|
+
where: "deleted_at IS NULL",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
on: ["retention_time", "updated_at", "state"],
|
|
53
|
+
where: "deleted_at IS NULL AND retention_time IS NOT NULL",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
on: ["updated_at", "retention_time"],
|
|
57
|
+
where: "deleted_at IS NULL AND retention_time IS NOT NULL AND state IN ('done', 'failed', 'reverted')",
|
|
58
|
+
},
|
|
38
59
|
]);
|
|
39
60
|
//# sourceMappingURL=workflow-execution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-execution.js","sourceRoot":"","sources":["../../src/models/workflow-execution.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AACpE,qDAAiD;AAEpC,QAAA,iBAAiB,GAAG,aAAK;KACnC,MAAM,CAAC,oBAAoB,EAAE;IAC5B,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACnC,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACtC,cAAc,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACzC,SAAS,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAClC,OAAO,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAChC,KAAK,EAAE,aAAK,CAAC,IAAI,CAAC,gCAAgB,CAAC;IACnC,cAAc,EAAE,aAAK,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC1C,CAAC;KACD,OAAO,CAAC;IACP;QACE,EAAE,EAAE,CAAC,IAAI,CAAC;QACV,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,aAAa,CAAC;QACnB,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,gBAAgB,CAAC;QACtB,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"workflow-execution.js","sourceRoot":"","sources":["../../src/models/workflow-execution.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AACpE,qDAAiD;AAEpC,QAAA,iBAAiB,GAAG,aAAK;KACnC,MAAM,CAAC,oBAAoB,EAAE;IAC5B,EAAE,EAAE,aAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACnC,WAAW,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACtC,cAA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ClG;CACF,CAAC,CAAA"}
|
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { DistributedTransactionEvents, DistributedTransactionType, TransactionStep } from "@medusajs/framework/orchestration";
|
|
2
2
|
import { ContainerLike, Context, MedusaContainer } from "@medusajs/framework/types";
|
|
3
|
+
import { TransactionState } from "@medusajs/framework/utils";
|
|
3
4
|
import { FlowCancelOptions, FlowRunOptions, ReturnWorkflow } from "@medusajs/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;
|
|
8
10
|
container?: ContainerLike;
|
|
9
11
|
};
|
|
10
12
|
export type WorkflowOrchestratorCancelOptions = Omit<FlowCancelOptions, "transaction" | "transactionId" | "container"> & {
|
|
11
13
|
transactionId: string;
|
|
14
|
+
runId?: string;
|
|
12
15
|
container?: ContainerLike;
|
|
13
16
|
};
|
|
14
17
|
type RegisterStepSuccessOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input">;
|
|
18
|
+
type RegisterStepFailureOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input"> & {
|
|
19
|
+
forcePermanentFailure?: boolean;
|
|
20
|
+
};
|
|
21
|
+
type RetryStepOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input" | "resultFrom">;
|
|
15
22
|
type IdempotencyKeyParts = {
|
|
16
23
|
workflowId: string;
|
|
17
24
|
transactionId: string;
|
|
@@ -20,12 +27,14 @@ type IdempotencyKeyParts = {
|
|
|
20
27
|
};
|
|
21
28
|
type NotifyOptions = {
|
|
22
29
|
eventType: keyof DistributedTransactionEvents;
|
|
30
|
+
isFlowAsync: boolean;
|
|
23
31
|
workflowId: string;
|
|
24
32
|
transactionId?: string;
|
|
25
33
|
step?: TransactionStep;
|
|
26
34
|
response?: unknown;
|
|
27
35
|
result?: unknown;
|
|
28
36
|
errors?: unknown[];
|
|
37
|
+
state?: TransactionState;
|
|
29
38
|
};
|
|
30
39
|
type SubscriberHandler = {
|
|
31
40
|
(input: NotifyOptions): void;
|
|
@@ -49,8 +58,7 @@ export declare class WorkflowOrchestratorService {
|
|
|
49
58
|
protected redisPublisher: Redis;
|
|
50
59
|
protected redisSubscriber: Redis;
|
|
51
60
|
protected container_: MedusaContainer;
|
|
52
|
-
private subscribers;
|
|
53
|
-
private activeStepsCount;
|
|
61
|
+
private static subscribers;
|
|
54
62
|
protected redisDistributedTransactionStorage_: RedisDistributedTransactionStorage;
|
|
55
63
|
constructor({ dataLoaderOnly, redisDistributedTransactionStorage, redisPublisher, redisSubscriber, sharedContainer, }: {
|
|
56
64
|
dataLoaderOnly: boolean;
|
|
@@ -67,6 +75,10 @@ export declare class WorkflowOrchestratorService {
|
|
|
67
75
|
run<T = unknown>(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorRunOptions<T>): Promise<any>;
|
|
68
76
|
cancel(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorCancelOptions): Promise<any>;
|
|
69
77
|
getRunningTransaction(workflowId: string, transactionId: string, context?: Context): Promise<DistributedTransactionType>;
|
|
78
|
+
retryStep<T = unknown>({ idempotencyKey, options, }: {
|
|
79
|
+
idempotencyKey: string | IdempotencyKeyParts;
|
|
80
|
+
options?: RetryStepOptions<T>;
|
|
81
|
+
}): Promise<any>;
|
|
70
82
|
setStepSuccess<T = unknown>({ idempotencyKey, stepResponse, options, }: {
|
|
71
83
|
idempotencyKey: string | IdempotencyKeyParts;
|
|
72
84
|
stepResponse: unknown;
|
|
@@ -75,11 +87,12 @@ export declare class WorkflowOrchestratorService {
|
|
|
75
87
|
setStepFailure<T = unknown>({ idempotencyKey, stepResponse, options, }: {
|
|
76
88
|
idempotencyKey: string | IdempotencyKeyParts;
|
|
77
89
|
stepResponse: unknown;
|
|
78
|
-
options?:
|
|
90
|
+
options?: RegisterStepFailureOptions<T>;
|
|
79
91
|
}): Promise<any>;
|
|
80
92
|
subscribe({ workflowId, transactionId, subscriber, subscriberId, }: SubscribeOptions): void;
|
|
81
93
|
unsubscribe({ workflowId, transactionId, subscriberOrId, }: UnsubscribeOptions): void;
|
|
82
94
|
private notify;
|
|
95
|
+
private processSubscriberNotifications;
|
|
83
96
|
private getChannelName;
|
|
84
97
|
private buildWorkflowEvents;
|
|
85
98
|
private buildIdempotencyKeyAndParts;
|
|
@@ -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,mCAAmC,CAAA;AAC1C,OAAO,EACL,aAAa,EACb,OAAO,EAEP,eAAe,EAChB,MAAM,2BAA2B,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,mCAAmC,CAAA;AAC1C,OAAO,EACL,aAAa,EACb,OAAO,EAEP,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAIL,gBAAgB,EACjB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EACL,iBAAiB,EACjB,cAAc,EAGd,cAAc,EACf,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,MAAM,SAAS,CAAA;AAE3B,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,MA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