@etohq/workflow-engine-inmemory 1.5.1-alpha.4 → 1.5.1-alpha.8
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/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/Migration20241206101446.d.ts +1 -1
- package/dist/migrations/Migration20241206101446.d.ts.map +1 -1
- package/dist/migrations/Migration20241206101446.js +1 -1
- package/dist/migrations/Migration20241206101446.js.map +1 -1
- package/dist/migrations/Migration20250128174331.d.ts +1 -1
- package/dist/migrations/Migration20250128174331.d.ts.map +1 -1
- package/dist/migrations/Migration20250128174331.js +1 -1
- package/dist/migrations/Migration20250128174331.js.map +1 -1
- package/dist/migrations/Migration20250505092459.d.ts +1 -1
- package/dist/migrations/Migration20250505092459.d.ts.map +1 -1
- package/dist/migrations/Migration20250505092459.js +1 -1
- package/dist/migrations/Migration20250505092459.js.map +1 -1
- package/dist/migrations/Migration20250819104213.d.ts +6 -0
- package/dist/migrations/Migration20250819104213.d.ts.map +1 -0
- package/dist/migrations/Migration20250819104213.js +14 -0
- package/dist/migrations/Migration20250819104213.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/Migration20250908080305.d.ts +6 -0
- package/dist/migrations/Migration20250908080305.d.ts.map +1 -0
- package/dist/migrations/Migration20250908080305.js +20 -0
- package/dist/migrations/Migration20250908080305.js.map +1 -0
- package/dist/models/workflow-execution.d.ts.map +1 -1
- package/dist/models/workflow-execution.js +20 -0
- package/dist/models/workflow-execution.js.map +1 -1
- package/dist/services/workflow-orchestrator.d.ts +12 -3
- package/dist/services/workflow-orchestrator.d.ts.map +1 -1
- package/dist/services/workflow-orchestrator.js +113 -32
- package/dist/services/workflow-orchestrator.js.map +1 -1
- package/dist/services/workflows-module.d.ts +12 -6
- package/dist/services/workflows-module.d.ts.map +1 -1
- package/dist/services/workflows-module.js +17 -21
- package/dist/services/workflows-module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/workflow-orchestrator-storage.d.ts +4 -1
- package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -1
- package/dist/utils/workflow-orchestrator-storage.js +234 -138
- package/dist/utils/workflow-orchestrator-storage.js.map +1 -1
- package/package.json +4 -4
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("@etohq/framework/awilix");
|
|
4
4
|
const utils_1 = require("../utils");
|
|
5
5
|
exports.default = async ({ container }) => {
|
|
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,oDAAiD;AACjD,oCAAgE;AAEhE,kBAAe,KAAK,EAAE,EAAE,SAAS,EAAE,EAAiB,EAAE;IACpD,SAAS,CAAC,QAAQ,CAAC;QACjB,qCAAqC,EAAE,IAAA,gBAAO,EAC5C,6CAAqC,CACtC,CAAC,SAAS,EAAE;KACd,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,uCAAuC,CAAA;AAEjE,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("@etohq/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,sEAAiE;AAEjE,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":"Migration20241206101446.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241206101446.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20241206101446.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241206101446.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAEjE,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.Migration20241206101446 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@etohq/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20241206101446 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":"Migration20241206101446.js","sourceRoot":"","sources":["../../src/migrations/Migration20241206101446.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20241206101446.js","sourceRoot":"","sources":["../../src/migrations/Migration20241206101446.ts"],"names":[],"mappings":";;;AAAA,sEAAiE;AAEjE,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":"Migration20250128174331.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250128174331.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20250128174331.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250128174331.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAEjE,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.Migration20250128174331 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@etohq/framework/mikro-orm/migrations");
|
|
5
5
|
class Migration20250128174331 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":"Migration20250128174331.js","sourceRoot":"","sources":["../../src/migrations/Migration20250128174331.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20250128174331.js","sourceRoot":"","sources":["../../src/migrations/Migration20250128174331.ts"],"names":[],"mappings":";;;AAAA,sEAAiE;AAEjE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20250505092459.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250505092459.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Migration20250505092459.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250505092459.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAGjE,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBrC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Migration20250505092459 = void 0;
|
|
4
|
-
const migrations_1 = require("@mikro-orm/migrations");
|
|
4
|
+
const migrations_1 = require("@etohq/framework/mikro-orm/migrations");
|
|
5
5
|
const ulid_1 = require("ulid");
|
|
6
6
|
class Migration20250505092459 extends migrations_1.Migration {
|
|
7
7
|
async up() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Migration20250505092459.js","sourceRoot":"","sources":["../../src/migrations/Migration20250505092459.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Migration20250505092459.js","sourceRoot":"","sources":["../../src/migrations/Migration20250505092459.ts"],"names":[],"mappings":";;;AAAA,sEAAiE;AACjE,+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":"Migration20250819104213.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250819104213.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAEjE,qBAAa,uBAAwB,SAAQ,SAAS;IACrC,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAGrC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Migration20250819104213 = void 0;
|
|
4
|
+
const migrations_1 = require("@etohq/framework/mikro-orm/migrations");
|
|
5
|
+
class Migration20250819104213 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.Migration20250819104213 = Migration20250819104213;
|
|
14
|
+
//# sourceMappingURL=Migration20250819104213.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250819104213.js","sourceRoot":"","sources":["../../src/migrations/Migration20250819104213.ts"],"names":[],"mappings":";;;AAAA,sEAAiE;AAEjE,MAAa,uBAAwB,SAAQ,sBAAS;IAC3C,KAAK,CAAC,EAAE;QACf,IAAI,CAAC,MAAM,CACT,uHAAuH,CACxH,CAAA;IACH,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,IAAI,CAAC,MAAM,CAAC,uDAAuD,CAAC,CAAA;IACtE,CAAC;CACF;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,uCAAuC,CAAA;AAEjE,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("@etohq/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,sEAAiE;AAEjE,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":"Migration20250908080305.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20250908080305.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAEjE,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.Migration20250908080305 = void 0;
|
|
4
|
+
const migrations_1 = require("@etohq/framework/mikro-orm/migrations");
|
|
5
|
+
class Migration20250908080305 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.Migration20250908080305 = Migration20250908080305;
|
|
20
|
+
//# sourceMappingURL=Migration20250908080305.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Migration20250908080305.js","sourceRoot":"","sources":["../../src/migrations/Migration20250908080305.ts"],"names":[],"mappings":";;;AAAA,sEAAiE;AAEjE,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"}
|
|
@@ -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;;;;;;;;;yBAsD1B,CAAA"}
|
|
@@ -36,5 +36,25 @@ exports.WorkflowExecution = utils_1.model
|
|
|
36
36
|
on: ["state"],
|
|
37
37
|
where: "deleted_at IS NULL",
|
|
38
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
|
+
},
|
|
39
59
|
]);
|
|
40
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,kEAAiE;AACjE,kDAA8C;AAEjC,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,MAAM,EAAE,aAAK,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE;IACjC,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,EAAE,QAAQ,CAAC;QAC/C,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE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AAQ,CAAC;QACd,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC;QACrC,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,OAAO,EAAE,YAAY,CAAC;QAC3B,KAAK,EAAE,oBAAoB;KAC5B;IACD;QACE,EAAE,EAAE,CAAC,gBAAgB,EAAE,YAAY,EAAE,OAAO,CAAC;QAC7C,KAAK,EAAE,mDAAmD;KAC3D;IACD;QACE,EAAE,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC;QACpC,KAAK,EACH,+FAA+F;KAClG;CACF,CAAC,CAAA"}
|
|
@@ -10,6 +10,10 @@ export type WorkflowOrchestratorRunOptions<T> = Omit<FlowRunOptions<T>, "contain
|
|
|
10
10
|
container?: ContainerLike;
|
|
11
11
|
};
|
|
12
12
|
type RegisterStepSuccessOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input">;
|
|
13
|
+
type RegisterStepFailureOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input"> & {
|
|
14
|
+
forcePermanentFailure?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type RetryStepOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input" | "resultFrom">;
|
|
13
17
|
type IdempotencyKeyParts = {
|
|
14
18
|
workflowId: string;
|
|
15
19
|
transactionId: string;
|
|
@@ -43,12 +47,12 @@ type UnsubscribeOptions = {
|
|
|
43
47
|
subscriberOrId: string | SubscriberHandler;
|
|
44
48
|
};
|
|
45
49
|
export declare class WorkflowOrchestratorService {
|
|
46
|
-
private
|
|
50
|
+
#private;
|
|
51
|
+
private static subscribers;
|
|
47
52
|
private container_;
|
|
48
53
|
private inMemoryDistributedTransactionStorage_;
|
|
49
54
|
constructor({ inMemoryDistributedTransactionStorage, sharedContainer, }: {
|
|
50
55
|
inMemoryDistributedTransactionStorage: InMemoryDistributedTransactionStorage;
|
|
51
|
-
workflowOrchestratorService: WorkflowOrchestratorService;
|
|
52
56
|
sharedContainer: EtoContainer;
|
|
53
57
|
});
|
|
54
58
|
onApplicationStart(): Promise<void>;
|
|
@@ -57,6 +61,10 @@ export declare class WorkflowOrchestratorService {
|
|
|
57
61
|
run<T = unknown>(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorRunOptions<T>): Promise<any>;
|
|
58
62
|
cancel(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorCancelOptions): Promise<any>;
|
|
59
63
|
getRunningTransaction(workflowId: string, transactionId: string, context?: Context): Promise<DistributedTransactionType>;
|
|
64
|
+
retryStep<T = unknown>({ idempotencyKey, options, }: {
|
|
65
|
+
idempotencyKey: string | IdempotencyKeyParts;
|
|
66
|
+
options?: RetryStepOptions<T>;
|
|
67
|
+
}): Promise<any>;
|
|
60
68
|
setStepSuccess<T = unknown>({ idempotencyKey, stepResponse, options, }: {
|
|
61
69
|
idempotencyKey: string | IdempotencyKeyParts;
|
|
62
70
|
stepResponse: unknown;
|
|
@@ -65,11 +73,12 @@ export declare class WorkflowOrchestratorService {
|
|
|
65
73
|
setStepFailure<T = unknown>({ idempotencyKey, stepResponse, options, }: {
|
|
66
74
|
idempotencyKey: string | IdempotencyKeyParts;
|
|
67
75
|
stepResponse: unknown;
|
|
68
|
-
options?:
|
|
76
|
+
options?: RegisterStepFailureOptions<T>;
|
|
69
77
|
}): Promise<any>;
|
|
70
78
|
subscribe({ workflowId, transactionId, subscriber, subscriberId, }: SubscribeOptions): void;
|
|
71
79
|
unsubscribe({ workflowId, transactionId, subscriberOrId, }: UnsubscribeOptions): void;
|
|
72
80
|
private notify;
|
|
81
|
+
private processSubscriberNotifications;
|
|
73
82
|
private buildWorkflowEvents;
|
|
74
83
|
private buildIdempotencyKeyAndParts;
|
|
75
84
|
}
|
|
@@ -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,
|
|
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,EAIL,gBAAgB,EACjB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,KAAK,cAAc,EAGnB,cAAc,EACf,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,iCAAiC,EAAE,MAAM,QAAQ,CAAA;AAE1D,OAAO,EAAE,qCAAqC,EAAE,MAAM,UAAU,CAAA;AAEhE,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,KAAK,0BAA0B,CAAC,CAAC,IAAI,IAAI,CACvC,8BAA8B,CAAC,CAAC,CAAC,EACjC,eAAe,GAAG,OAAO,CAC1B,CAAA;AAED,KAAK,0BAA0B,CAAC,CAAC,IAAI,IAAI,CACvC,8BAA8B,CAAC,CAAC,CAAC,EACjC,eAAe,GAAG,OAAO,CAC1B,GAAG;IACF,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AAED,KAAK,gBAAgB,CAAC,CAAC,IAAI,IAAI,CAC7B,8BAA8B,CAAC,CAAC,CAAC,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EACV,UAAU,EACV,aAAa,EACb,cAAc,GACf,EAAE,kBAAkB;IAoCrB,OAAO,CAAC,MAAM;YAKA,8BAA8B;IAyC5C,OAAO,CAAC,mBAAmB;IA6G3B,OAAO,CAAC,2BAA2B;CA+BpC"}
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _WorkflowOrchestratorService_logger;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.WorkflowOrchestratorService = void 0;
|
|
4
16
|
const orchestration_1 = require("@etohq/framework/orchestration");
|
|
@@ -8,10 +20,11 @@ const ulid_1 = require("ulid");
|
|
|
8
20
|
const AnySubscriber = "any";
|
|
9
21
|
class WorkflowOrchestratorService {
|
|
10
22
|
constructor({ inMemoryDistributedTransactionStorage, sharedContainer, }) {
|
|
11
|
-
this
|
|
23
|
+
_WorkflowOrchestratorService_logger.set(this, void 0);
|
|
12
24
|
this.container_ = sharedContainer;
|
|
13
25
|
this.inMemoryDistributedTransactionStorage_ =
|
|
14
26
|
inMemoryDistributedTransactionStorage;
|
|
27
|
+
__classPrivateFieldSet(this, _WorkflowOrchestratorService_logger, this.container_.resolve("logger", { allowUnregistered: true }) ?? console, "f");
|
|
15
28
|
inMemoryDistributedTransactionStorage.setWorkflowOrchestratorService(this);
|
|
16
29
|
orchestration_1.DistributedTransaction.setStorage(inMemoryDistributedTransactionStorage);
|
|
17
30
|
orchestration_1.WorkflowScheduler.setStorage(inMemoryDistributedTransactionStorage);
|
|
@@ -22,9 +35,16 @@ class WorkflowOrchestratorService {
|
|
|
22
35
|
async onApplicationShutdown() {
|
|
23
36
|
await this.inMemoryDistributedTransactionStorage_.onApplicationShutdown();
|
|
24
37
|
}
|
|
25
|
-
async triggerParentStep(transaction, result) {
|
|
38
|
+
async triggerParentStep(transaction, result, errors) {
|
|
26
39
|
const metadata = transaction.flow.metadata;
|
|
27
|
-
const { parentStepIdempotencyKey } = metadata ?? {};
|
|
40
|
+
const { parentStepIdempotencyKey, cancelingFromParentStep } = metadata ?? {};
|
|
41
|
+
if (cancelingFromParentStep) {
|
|
42
|
+
/**
|
|
43
|
+
* If the sub workflow is cancelling from a parent step, we don't want to trigger the parent
|
|
44
|
+
* step.
|
|
45
|
+
*/
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
28
48
|
if (parentStepIdempotencyKey) {
|
|
29
49
|
const hasFailed = [
|
|
30
50
|
utils_1.TransactionState.REVERTED,
|
|
@@ -33,13 +53,19 @@ class WorkflowOrchestratorService {
|
|
|
33
53
|
if (hasFailed) {
|
|
34
54
|
await this.setStepFailure({
|
|
35
55
|
idempotencyKey: parentStepIdempotencyKey,
|
|
36
|
-
stepResponse:
|
|
56
|
+
stepResponse: errors,
|
|
57
|
+
options: {
|
|
58
|
+
logOnError: true,
|
|
59
|
+
},
|
|
37
60
|
});
|
|
38
61
|
}
|
|
39
62
|
else {
|
|
40
63
|
await this.setStepSuccess({
|
|
41
64
|
idempotencyKey: parentStepIdempotencyKey,
|
|
42
65
|
stepResponse: result,
|
|
66
|
+
options: {
|
|
67
|
+
logOnError: true,
|
|
68
|
+
},
|
|
43
69
|
});
|
|
44
70
|
}
|
|
45
71
|
}
|
|
@@ -98,7 +124,7 @@ class WorkflowOrchestratorService {
|
|
|
98
124
|
result,
|
|
99
125
|
errors,
|
|
100
126
|
});
|
|
101
|
-
await this.triggerParentStep(ret.transaction, result);
|
|
127
|
+
await this.triggerParentStep(ret.transaction, result, errors);
|
|
102
128
|
}
|
|
103
129
|
if (throwOnError && (ret.thrownError || ret.errors?.length)) {
|
|
104
130
|
if (ret.thrownError) {
|
|
@@ -178,7 +204,7 @@ class WorkflowOrchestratorService {
|
|
|
178
204
|
result,
|
|
179
205
|
errors,
|
|
180
206
|
});
|
|
181
|
-
await this.triggerParentStep(ret.transaction, result);
|
|
207
|
+
await this.triggerParentStep(ret.transaction, result, errors);
|
|
182
208
|
}
|
|
183
209
|
if (throwOnError && (ret.thrownError || ret.errors?.length)) {
|
|
184
210
|
if (ret.thrownError) {
|
|
@@ -205,6 +231,48 @@ class WorkflowOrchestratorService {
|
|
|
205
231
|
const transaction = await flow.getRunningTransaction(transactionId, context);
|
|
206
232
|
return transaction;
|
|
207
233
|
}
|
|
234
|
+
async retryStep({ idempotencyKey, options, }) {
|
|
235
|
+
const { context, logOnError, container, events: eventHandlers, } = options ?? {};
|
|
236
|
+
let { throwOnError } = options ?? {};
|
|
237
|
+
throwOnError ??= true;
|
|
238
|
+
const [idempotencyKey_, { workflowId, transactionId }] = this.buildIdempotencyKeyAndParts(idempotencyKey);
|
|
239
|
+
const exportedWorkflow = workflows_sdk_1.EtoWorkflow.getWorkflow(workflowId);
|
|
240
|
+
if (!exportedWorkflow) {
|
|
241
|
+
throw new Error(`Workflow with id "${workflowId}" not found.`);
|
|
242
|
+
}
|
|
243
|
+
const events = this.buildWorkflowEvents({
|
|
244
|
+
customEventHandlers: eventHandlers,
|
|
245
|
+
transactionId,
|
|
246
|
+
workflowId,
|
|
247
|
+
});
|
|
248
|
+
const ret = await exportedWorkflow.retryStep({
|
|
249
|
+
idempotencyKey: idempotencyKey_,
|
|
250
|
+
context,
|
|
251
|
+
throwOnError: false,
|
|
252
|
+
logOnError,
|
|
253
|
+
events,
|
|
254
|
+
container: container ?? this.container_,
|
|
255
|
+
});
|
|
256
|
+
if (ret.transaction.hasFinished()) {
|
|
257
|
+
const { result, errors } = ret;
|
|
258
|
+
this.notify({
|
|
259
|
+
eventType: "onFinish",
|
|
260
|
+
workflowId,
|
|
261
|
+
transactionId,
|
|
262
|
+
state: ret.transaction.getFlow().state,
|
|
263
|
+
result,
|
|
264
|
+
errors,
|
|
265
|
+
});
|
|
266
|
+
await this.triggerParentStep(ret.transaction, result, errors);
|
|
267
|
+
}
|
|
268
|
+
if (throwOnError && (ret.thrownError || ret.errors?.length)) {
|
|
269
|
+
if (ret.thrownError) {
|
|
270
|
+
throw ret.thrownError;
|
|
271
|
+
}
|
|
272
|
+
throw ret.errors[0].error;
|
|
273
|
+
}
|
|
274
|
+
return ret;
|
|
275
|
+
}
|
|
208
276
|
async setStepSuccess({ idempotencyKey, stepResponse, options, }) {
|
|
209
277
|
const { context, logOnError, resultFrom, container, events: eventHandlers, } = options ?? {};
|
|
210
278
|
let { throwOnError } = options ?? {};
|
|
@@ -239,7 +307,7 @@ class WorkflowOrchestratorService {
|
|
|
239
307
|
result,
|
|
240
308
|
errors,
|
|
241
309
|
});
|
|
242
|
-
await this.triggerParentStep(ret.transaction, result);
|
|
310
|
+
await this.triggerParentStep(ret.transaction, result, errors);
|
|
243
311
|
}
|
|
244
312
|
if (throwOnError && (ret.thrownError || ret.errors?.length)) {
|
|
245
313
|
if (ret.thrownError) {
|
|
@@ -250,7 +318,7 @@ class WorkflowOrchestratorService {
|
|
|
250
318
|
return ret;
|
|
251
319
|
}
|
|
252
320
|
async setStepFailure({ idempotencyKey, stepResponse, options, }) {
|
|
253
|
-
const { context, logOnError, resultFrom, container, events: eventHandlers, } = options ?? {};
|
|
321
|
+
const { context, logOnError, resultFrom, container, events: eventHandlers, forcePermanentFailure = false, } = options ?? {};
|
|
254
322
|
let { throwOnError } = options ?? {};
|
|
255
323
|
throwOnError ??= true;
|
|
256
324
|
const [idempotencyKey_, { workflowId, transactionId }] = this.buildIdempotencyKeyAndParts(idempotencyKey);
|
|
@@ -270,6 +338,7 @@ class WorkflowOrchestratorService {
|
|
|
270
338
|
throwOnError: false,
|
|
271
339
|
logOnError,
|
|
272
340
|
events,
|
|
341
|
+
forcePermanentFailure,
|
|
273
342
|
response: stepResponse,
|
|
274
343
|
container: container ?? this.container_,
|
|
275
344
|
});
|
|
@@ -283,7 +352,7 @@ class WorkflowOrchestratorService {
|
|
|
283
352
|
result,
|
|
284
353
|
errors,
|
|
285
354
|
});
|
|
286
|
-
await this.triggerParentStep(ret.transaction, result);
|
|
355
|
+
await this.triggerParentStep(ret.transaction, result, errors);
|
|
287
356
|
}
|
|
288
357
|
if (throwOnError && (ret.thrownError || ret.errors?.length)) {
|
|
289
358
|
if (ret.thrownError) {
|
|
@@ -295,7 +364,7 @@ class WorkflowOrchestratorService {
|
|
|
295
364
|
}
|
|
296
365
|
subscribe({ workflowId, transactionId, subscriber, subscriberId, }) {
|
|
297
366
|
subscriber._id = subscriberId;
|
|
298
|
-
const subscribers =
|
|
367
|
+
const subscribers = WorkflowOrchestratorService.subscribers.get(workflowId) ?? new Map();
|
|
299
368
|
const handlerIndex = (handlers) => {
|
|
300
369
|
return handlers.findIndex((s) => s === subscriber || s._id === subscriberId);
|
|
301
370
|
};
|
|
@@ -307,7 +376,7 @@ class WorkflowOrchestratorService {
|
|
|
307
376
|
}
|
|
308
377
|
transactionSubscribers.push(subscriber);
|
|
309
378
|
subscribers.set(transactionId, transactionSubscribers);
|
|
310
|
-
|
|
379
|
+
WorkflowOrchestratorService.subscribers.set(workflowId, subscribers);
|
|
311
380
|
return;
|
|
312
381
|
}
|
|
313
382
|
const workflowSubscribers = subscribers.get(AnySubscriber) ?? [];
|
|
@@ -317,10 +386,10 @@ class WorkflowOrchestratorService {
|
|
|
317
386
|
}
|
|
318
387
|
workflowSubscribers.push(subscriber);
|
|
319
388
|
subscribers.set(AnySubscriber, workflowSubscribers);
|
|
320
|
-
|
|
389
|
+
WorkflowOrchestratorService.subscribers.set(workflowId, subscribers);
|
|
321
390
|
}
|
|
322
391
|
unsubscribe({ workflowId, transactionId, subscriberOrId, }) {
|
|
323
|
-
const subscribers =
|
|
392
|
+
const subscribers = WorkflowOrchestratorService.subscribers.get(workflowId) ?? new Map();
|
|
324
393
|
const filterSubscribers = (handlers) => {
|
|
325
394
|
return handlers.filter((handler) => {
|
|
326
395
|
return handler._id
|
|
@@ -337,7 +406,7 @@ class WorkflowOrchestratorService {
|
|
|
337
406
|
else {
|
|
338
407
|
subscribers.delete(transactionId);
|
|
339
408
|
}
|
|
340
|
-
|
|
409
|
+
WorkflowOrchestratorService.subscribers.set(workflowId, subscribers);
|
|
341
410
|
return;
|
|
342
411
|
}
|
|
343
412
|
const workflowSubscribers = subscribers.get(AnySubscriber) ?? [];
|
|
@@ -348,34 +417,44 @@ class WorkflowOrchestratorService {
|
|
|
348
417
|
else {
|
|
349
418
|
subscribers.delete(AnySubscriber);
|
|
350
419
|
}
|
|
351
|
-
|
|
420
|
+
WorkflowOrchestratorService.subscribers.set(workflowId, subscribers);
|
|
352
421
|
}
|
|
353
422
|
notify(options) {
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
result
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
423
|
+
// Process subscribers asynchronously to avoid blocking workflow execution
|
|
424
|
+
setImmediate(() => this.processSubscriberNotifications(options));
|
|
425
|
+
}
|
|
426
|
+
async processSubscriberNotifications(options) {
|
|
427
|
+
const { workflowId, transactionId, eventType } = options;
|
|
428
|
+
const subscribers = WorkflowOrchestratorService.subscribers.get(workflowId) ?? new Map();
|
|
429
|
+
const notifySubscribersAsync = async (handlers) => {
|
|
430
|
+
const promises = handlers.map(async (handler) => {
|
|
431
|
+
try {
|
|
432
|
+
const result = handler(options);
|
|
433
|
+
if (result && typeof result === "object" && "then" in result) {
|
|
434
|
+
await result;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
catch (error) {
|
|
438
|
+
__classPrivateFieldGet(this, _WorkflowOrchestratorService_logger, "f").error(`Subscriber error: ${error}`);
|
|
439
|
+
}
|
|
368
440
|
});
|
|
441
|
+
await (0, utils_1.promiseAll)(promises);
|
|
369
442
|
};
|
|
443
|
+
const tasks = [];
|
|
370
444
|
if (transactionId) {
|
|
371
445
|
const transactionSubscribers = subscribers.get(transactionId) ?? [];
|
|
372
|
-
|
|
373
|
-
|
|
446
|
+
if (transactionSubscribers.length > 0) {
|
|
447
|
+
tasks.push(notifySubscribersAsync(transactionSubscribers));
|
|
448
|
+
}
|
|
449
|
+
if (eventType === "onFinish") {
|
|
374
450
|
subscribers.delete(transactionId);
|
|
375
451
|
}
|
|
376
452
|
}
|
|
377
453
|
const workflowSubscribers = subscribers.get(AnySubscriber) ?? [];
|
|
378
|
-
|
|
454
|
+
if (workflowSubscribers.length > 0) {
|
|
455
|
+
tasks.push(notifySubscribersAsync(workflowSubscribers));
|
|
456
|
+
}
|
|
457
|
+
await (0, utils_1.promiseAll)(tasks);
|
|
379
458
|
}
|
|
380
459
|
buildWorkflowEvents({ customEventHandlers, workflowId, transactionId, }) {
|
|
381
460
|
const notify = ({ eventType, step, result, response, errors, state, }) => {
|
|
@@ -479,4 +558,6 @@ class WorkflowOrchestratorService {
|
|
|
479
558
|
}
|
|
480
559
|
}
|
|
481
560
|
exports.WorkflowOrchestratorService = WorkflowOrchestratorService;
|
|
561
|
+
_WorkflowOrchestratorService_logger = new WeakMap();
|
|
562
|
+
WorkflowOrchestratorService.subscribers = new Map();
|
|
482
563
|
//# sourceMappingURL=workflow-orchestrator.js.map
|