@etohq/workflow-engine-redis 1.0.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.
Files changed (63) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +10 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/loaders/index.d.ts +3 -0
  7. package/dist/loaders/index.d.ts.map +1 -0
  8. package/dist/loaders/index.js +11 -0
  9. package/dist/loaders/index.js.map +1 -0
  10. package/dist/loaders/redis.d.ts +4 -0
  11. package/dist/loaders/redis.d.ts.map +1 -0
  12. package/dist/loaders/redis.js +64 -0
  13. package/dist/loaders/redis.js.map +1 -0
  14. package/dist/loaders/utils.d.ts +6 -0
  15. package/dist/loaders/utils.d.ts.map +1 -0
  16. package/dist/loaders/utils.js +11 -0
  17. package/dist/loaders/utils.js.map +1 -0
  18. package/dist/migrations/Migration20231228143900.d.ts +6 -0
  19. package/dist/migrations/Migration20231228143900.d.ts.map +1 -0
  20. package/dist/migrations/Migration20231228143900.js +40 -0
  21. package/dist/migrations/Migration20231228143900.js.map +1 -0
  22. package/dist/migrations/Migration20241206123341.d.ts +5 -0
  23. package/dist/migrations/Migration20241206123341.d.ts.map +1 -0
  24. package/dist/migrations/Migration20241206123341.js +19 -0
  25. package/dist/migrations/Migration20241206123341.js.map +1 -0
  26. package/dist/models/index.d.ts +2 -0
  27. package/dist/models/index.d.ts.map +1 -0
  28. package/dist/models/index.js +6 -0
  29. package/dist/models/index.js.map +1 -0
  30. package/dist/models/workflow-execution.d.ts +10 -0
  31. package/dist/models/workflow-execution.d.ts.map +1 -0
  32. package/dist/models/workflow-execution.js +33 -0
  33. package/dist/models/workflow-execution.js.map +1 -0
  34. package/dist/schema/index.d.ts +3 -0
  35. package/dist/schema/index.d.ts.map +1 -0
  36. package/dist/schema/index.js +26 -0
  37. package/dist/schema/index.js.map +1 -0
  38. package/dist/services/index.d.ts +3 -0
  39. package/dist/services/index.d.ts.map +1 -0
  40. package/dist/services/index.js +19 -0
  41. package/dist/services/index.js.map +1 -0
  42. package/dist/services/workflow-orchestrator.d.ts +83 -0
  43. package/dist/services/workflow-orchestrator.d.ts.map +1 -0
  44. package/dist/services/workflow-orchestrator.js +514 -0
  45. package/dist/services/workflow-orchestrator.js.map +1 -0
  46. package/dist/services/workflows-module.d.ts +54 -0
  47. package/dist/services/workflows-module.d.ts.map +1 -0
  48. package/dist/services/workflows-module.js +113 -0
  49. package/dist/services/workflows-module.js.map +1 -0
  50. package/dist/tsconfig.tsbuildinfo +1 -0
  51. package/dist/types/index.d.ts +30 -0
  52. package/dist/types/index.d.ts.map +1 -0
  53. package/dist/types/index.js +3 -0
  54. package/dist/types/index.js.map +1 -0
  55. package/dist/utils/index.d.ts +2 -0
  56. package/dist/utils/index.d.ts.map +1 -0
  57. package/dist/utils/index.js +18 -0
  58. package/dist/utils/index.js.map +1 -0
  59. package/dist/utils/workflow-orchestrator-storage.d.ts +46 -0
  60. package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -0
  61. package/dist/utils/workflow-orchestrator-storage.js +262 -0
  62. package/dist/utils/workflow-orchestrator-storage.js.map +1 -0
  63. package/package.json +65 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Workflow Orchestrator
@@ -0,0 +1,6 @@
1
+ import { WorkflowsModuleService } from "./services";
2
+ declare const _default: import("@etohq/types").ModuleExports<typeof WorkflowsModuleService> & {
3
+ linkable: Record<string, any>;
4
+ };
5
+ export default _default;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAA;;;;AAGlD,wBAGE"}
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@etohq/framework/utils");
4
+ const _services_1 = require("./services");
5
+ const loaders_1 = require("./loaders");
6
+ exports.default = (0, utils_1.Module)(utils_1.Modules.WORKFLOW_ENGINE, {
7
+ service: _services_1.WorkflowsModuleService,
8
+ loaders: [loaders_1.loadUtils, loaders_1.redisConnection],
9
+ });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,kDAAwD;AACxD,yCAAkD;AAClD,uCAAsD;AAEtD,kBAAe,IAAA,cAAM,EAAC,eAAO,CAAC,eAAe,EAAE;IAC7C,OAAO,EAAE,kCAAsB;IAC/B,OAAO,EAAE,CAAC,mBAAS,EAAE,yBAAe,CAAU;CAC/C,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { default as redisConnection } from "./redis";
2
+ export { default as loadUtils } from "./utils";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,SAAS,CAAA"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.loadUtils = exports.redisConnection = void 0;
7
+ var redis_1 = require("./redis");
8
+ Object.defineProperty(exports, "redisConnection", { enumerable: true, get: function () { return __importDefault(redis_1).default; } });
9
+ var utils_1 = require("./utils");
10
+ Object.defineProperty(exports, "loadUtils", { enumerable: true, get: function () { return __importDefault(utils_1).default; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAoD;AAA3C,yHAAA,OAAO,OAAmB;AACnC,iCAA8C;AAArC,mHAAA,OAAO,OAAa"}
@@ -0,0 +1,4 @@
1
+ import { LoaderOptions } from "@etohq/framework/types";
2
+ declare const _default: ({ container, logger, options, dataLoaderOnly, }: LoaderOptions) => Promise<void>;
3
+ export default _default;
4
+ //# sourceMappingURL=redis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;0EAUnD,aAAa,KAAG,OAAO,CAAC,IAAI,CAAC;AALhC,wBAqEC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const awilix_1 = require("awilix");
7
+ const ioredis_1 = __importDefault(require("ioredis"));
8
+ exports.default = async ({ container, logger, options, dataLoaderOnly, }) => {
9
+ const { url, options: redisOptions, pubsub, } = options?.redis;
10
+ // TODO: get default from ENV VAR
11
+ if (!url) {
12
+ throw Error("No `redis.url` provided in `workflowOrchestrator` module options. It is required for the Workflow Orchestrator Redis.");
13
+ }
14
+ const cnnPubSub = pubsub ?? { url, options: redisOptions };
15
+ const queueName = options?.queueName ?? "eto-workflows";
16
+ let connection;
17
+ let redisPublisher;
18
+ let redisSubscriber;
19
+ let workerConnection;
20
+ try {
21
+ connection = await getConnection(url, redisOptions);
22
+ workerConnection = await getConnection(url, {
23
+ ...(redisOptions ?? {}),
24
+ maxRetriesPerRequest: null,
25
+ });
26
+ logger?.info(`Connection to Redis in module 'workflow-engine-redis' established`);
27
+ }
28
+ catch (err) {
29
+ logger?.error(`An error occurred while connecting to Redis in module 'workflow-engine-redis': ${err}`);
30
+ }
31
+ try {
32
+ redisPublisher = await getConnection(cnnPubSub.url, cnnPubSub.options);
33
+ redisSubscriber = await getConnection(cnnPubSub.url, cnnPubSub.options);
34
+ logger?.info(`Connection to Redis PubSub in module 'workflow-engine-redis' established`);
35
+ }
36
+ catch (err) {
37
+ logger?.error(`An error occurred while connecting to Redis PubSub in module 'workflow-engine-redis': ${err}`);
38
+ }
39
+ container.register({
40
+ partialLoading: (0, awilix_1.asValue)(true),
41
+ redisConnection: (0, awilix_1.asValue)(connection),
42
+ redisWorkerConnection: (0, awilix_1.asValue)(workerConnection),
43
+ redisPublisher: (0, awilix_1.asValue)(redisPublisher),
44
+ redisSubscriber: (0, awilix_1.asValue)(redisSubscriber),
45
+ redisQueueName: (0, awilix_1.asValue)(queueName),
46
+ redisDisconnectHandler: (0, awilix_1.asValue)(async () => {
47
+ connection.disconnect();
48
+ workerConnection.disconnect();
49
+ redisPublisher.disconnect();
50
+ redisSubscriber.disconnect();
51
+ }),
52
+ });
53
+ };
54
+ async function getConnection(url, redisOptions) {
55
+ const connection = new ioredis_1.default(url, {
56
+ lazyConnect: true,
57
+ ...(redisOptions ?? {}),
58
+ });
59
+ await new Promise(async (resolve) => {
60
+ await connection.connect(resolve);
61
+ });
62
+ return connection;
63
+ }
64
+ //# sourceMappingURL=redis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redis.js","sourceRoot":"","sources":["../../src/loaders/redis.ts"],"names":[],"mappings":";;;;;AACA,mCAAgC;AAChC,sDAA2B;AAG3B,kBAAe,KAAK,EAAE,EACpB,SAAS,EACT,MAAM,EACN,OAAO,EACP,cAAc,GACA,EAAiB,EAAE;IACjC,MAAM,EACJ,GAAG,EACH,OAAO,EAAE,YAAY,EACrB,MAAM,GACP,GAAG,OAAO,EAAE,KAA8B,CAAA;IAE3C,iCAAiC;IACjC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,KAAK,CACT,uHAAuH,CACxH,CAAA;IACH,CAAC;IAED,MAAM,SAAS,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O,EAAC,eAAe,CAAC;QACzC,cAAc,EAAE,IAAA,gBAAO,EAAC,SAAS,CAAC;QAClC,sBAAsB,EAAE,IAAA,gBAAO,EAAC,KAAK,IAAI,EAAE;YACzC,UAAU,CAAC,UAAU,EAAE,CAAA;YACvB,gBAAgB,CAAC,UAAU,EAAE,CAAA;YAC7B,cAAc,CAAC,UAAU,EAAE,CAAA;YAC3B,eAAe,CAAC,UAAU,EAAE,CAAA;QAC9B,CAAC,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,KAAK,UAAU,aAAa,CAAC,GAAG,EAAE,YAAY;IAC5C,MAAM,UAAU,GAAG,IAAI,iBAAK,CAAC,GAAG,EAAE;QAChC,WAAW,EAAE,IAAI;QACjB,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;KACxB,CAAC,CAAA;IAEF,MAAM,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAClC,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -0,0 +1,6 @@
1
+ declare const _default: ({ container, dataLoaderOnly }: {
2
+ container: any;
3
+ dataLoaderOnly: any;
4
+ }) => Promise<void>;
5
+ export default _default;
6
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":";;;MAGsD,OAAO,CAAC,IAAI,CAAC;AAAnE,wBAOC"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const awilix_1 = require("awilix");
4
+ const utils_1 = require("../utils");
5
+ exports.default = async ({ container, dataLoaderOnly }) => {
6
+ container.register({
7
+ redisDistributedTransactionStorage: (0, awilix_1.asClass)(utils_1.RedisDistributedTransactionStorage).singleton(),
8
+ dataLoaderOnly: (0, awilix_1.asValue)(!!dataLoaderOnly),
9
+ });
10
+ };
11
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":";;AAAA,mCAAyC;AACzC,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"}
@@ -0,0 +1,6 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20231221104256 extends Migration {
3
+ up(): Promise<void>;
4
+ down(): Promise<void>;
5
+ }
6
+ //# sourceMappingURL=Migration20231228143900.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20231228143900.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20231228143900.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAY5B"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20231221104256 = void 0;
4
+ const migrations_1 = require("@mikro-orm/migrations");
5
+ class Migration20231221104256 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql(`
8
+ CREATE TABLE IF NOT EXISTS workflow_execution
9
+ (
10
+ id character varying NOT NULL,
11
+ workflow_id character varying NOT NULL,
12
+ transaction_id character varying NOT NULL,
13
+ execution jsonb NULL,
14
+ context jsonb NULL,
15
+ state character varying NOT NULL,
16
+ created_at timestamp WITHOUT time zone NOT NULL DEFAULT Now(),
17
+ updated_at timestamp WITHOUT time zone NOT NULL DEFAULT Now(),
18
+ deleted_at timestamp WITHOUT time zone NULL,
19
+ CONSTRAINT "PK_workflow_execution_workflow_id_transaction_id" PRIMARY KEY ("workflow_id", "transaction_id")
20
+ );
21
+
22
+ CREATE UNIQUE INDEX IF NOT EXISTS "IDX_workflow_execution_id" ON "workflow_execution" ("id");
23
+ CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id" ON "workflow_execution" ("workflow_id") WHERE deleted_at IS NULL;
24
+ CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_transaction_id" ON "workflow_execution" ("transaction_id") WHERE deleted_at IS NULL;
25
+ CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_state" ON "workflow_execution" ("state") WHERE deleted_at IS NULL;
26
+ `);
27
+ }
28
+ async down() {
29
+ this.addSql(`
30
+ DROP INDEX "IDX_workflow_execution_id";
31
+ DROP INDEX "IDX_workflow_execution_workflow_id";
32
+ DROP INDEX "IDX_workflow_execution_transaction_id";
33
+ DROP INDEX "IDX_workflow_execution_state";
34
+
35
+ DROP TABLE IF EXISTS workflow_execution;
36
+ `);
37
+ }
38
+ }
39
+ exports.Migration20231221104256 = Migration20231221104256;
40
+ //# sourceMappingURL=Migration20231228143900.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20231228143900.js","sourceRoot":"","sources":["../../src/migrations/Migration20231228143900.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,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"}
@@ -0,0 +1,5 @@
1
+ import { Migration } from "@mikro-orm/migrations";
2
+ export declare class Migration20241206123341 extends Migration {
3
+ up(): Promise<void>;
4
+ }
5
+ //# sourceMappingURL=Migration20241206123341.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20241206123341.d.ts","sourceRoot":"","sources":["../../src/migrations/Migration20241206123341.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAEjD,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;CAuB1B"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Migration20241206123341 = void 0;
4
+ const migrations_1 = require("@mikro-orm/migrations");
5
+ class Migration20241206123341 extends migrations_1.Migration {
6
+ async up() {
7
+ this.addSql(`DROP INDEX IF EXISTS "IDX_workflow_execution_id";
8
+ DROP INDEX IF EXISTS "IDX_workflow_execution_workflow_id";
9
+ DROP INDEX IF EXISTS "IDX_workflow_execution_transaction_id";
10
+ DROP INDEX IF EXISTS "IDX_workflow_execution_state";`);
11
+ this.addSql('CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_deleted_at" ON "workflow_execution" (deleted_at) WHERE deleted_at IS NULL;');
12
+ this.addSql('CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_id" ON "workflow_execution" (id) WHERE deleted_at IS NULL;');
13
+ this.addSql('CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id" ON "workflow_execution" (workflow_id) WHERE deleted_at IS NULL;');
14
+ this.addSql('CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_transaction_id" ON "workflow_execution" (transaction_id) WHERE deleted_at IS NULL;');
15
+ this.addSql('CREATE INDEX IF NOT EXISTS "IDX_workflow_execution_state" ON "workflow_execution" (state) WHERE deleted_at IS NULL;');
16
+ }
17
+ }
18
+ exports.Migration20241206123341 = Migration20241206123341;
19
+ //# sourceMappingURL=Migration20241206123341.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Migration20241206123341.js","sourceRoot":"","sources":["../../src/migrations/Migration20241206123341.ts"],"names":[],"mappings":";;;AAAA,sDAAiD;AAEjD,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"}
@@ -0,0 +1,2 @@
1
+ export { WorkflowExecution } from "./workflow-execution";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowExecution = void 0;
4
+ var workflow_execution_1 = require("./workflow-execution");
5
+ Object.defineProperty(exports, "WorkflowExecution", { enumerable: true, get: function () { return workflow_execution_1.WorkflowExecution; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,2DAAwD;AAA/C,uHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,10 @@
1
+ import { TransactionState } from "@etohq/framework/orchestration";
2
+ export declare const WorkflowExecution: import("@etohq/framework/utils").DmlEntity<import("@etohq/framework/utils").DMLEntitySchemaBuilder<{
3
+ id: import("@etohq/framework/utils").IdProperty;
4
+ workflow_id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").TextProperty>;
5
+ transaction_id: import("@etohq/framework/utils").PrimaryKeyModifier<string, import("@etohq/framework/utils").TextProperty>;
6
+ execution: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
7
+ context: import("@etohq/framework/utils").NullableModifier<Record<string, unknown>, import("@etohq/framework/utils").JSONProperty>;
8
+ state: import("@etohq/framework/utils").EnumProperty<typeof TransactionState>;
9
+ }>, "workflow_execution">;
10
+ //# sourceMappingURL=workflow-execution.d.ts.map
@@ -0,0 +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;;;;;;;yBA0B1B,CAAA"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowExecution = void 0;
4
+ const orchestration_1 = require("@etohq/framework/orchestration");
5
+ const utils_1 = require("@etohq/framework/utils");
6
+ exports.WorkflowExecution = utils_1.model
7
+ .define("workflow_execution", {
8
+ id: utils_1.model.id({ prefix: "wf_exec" }),
9
+ workflow_id: utils_1.model.text().primaryKey(),
10
+ transaction_id: utils_1.model.text().primaryKey(),
11
+ execution: utils_1.model.json().nullable(),
12
+ context: utils_1.model.json().nullable(),
13
+ state: utils_1.model.enum(orchestration_1.TransactionState),
14
+ })
15
+ .indexes([
16
+ {
17
+ on: ["id"],
18
+ where: "deleted_at IS NULL",
19
+ },
20
+ {
21
+ on: ["workflow_id"],
22
+ where: "deleted_at IS NULL",
23
+ },
24
+ {
25
+ on: ["transaction_id"],
26
+ where: "deleted_at IS NULL",
27
+ },
28
+ {
29
+ on: ["state"],
30
+ where: "deleted_at IS NULL",
31
+ },
32
+ ]);
33
+ //# sourceMappingURL=workflow-execution.js.map
@@ -0,0 +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,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;CACpC,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,OAAO,CAAC;QACb,KAAK,EAAE,oBAAoB;KAC5B;CACF,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ declare const _default: "\nenum TransactionState {\n NOT_STARTED\n INVOKING\n WAITING_TO_COMPENSATE\n COMPENSATING\n DONE\n REVERTED\n FAILED\n}\n\ntype WorkflowExecution {\n id: ID!\n created_at: DateTime!\n updated_at: DateTime!\n deleted_at: DateTime\n workflow_id: string\n transaction_id: string\n execution: JSON\n context: JSON\n state: TransactionState\n}\n";
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":";AAAA,wBAsBC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = `
4
+ enum TransactionState {
5
+ NOT_STARTED
6
+ INVOKING
7
+ WAITING_TO_COMPENSATE
8
+ COMPENSATING
9
+ DONE
10
+ REVERTED
11
+ FAILED
12
+ }
13
+
14
+ type WorkflowExecution {
15
+ id: ID!
16
+ created_at: DateTime!
17
+ updated_at: DateTime!
18
+ deleted_at: DateTime
19
+ workflow_id: string
20
+ transaction_id: string
21
+ execution: JSON
22
+ context: JSON
23
+ state: TransactionState
24
+ }
25
+ `;
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":";;AAAA,kBAAe;;;;;;;;;;;;;;;;;;;;;;CAsBd,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from "./workflow-orchestrator";
2
+ export * from "./workflows-module";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./workflow-orchestrator"), exports);
18
+ __exportStar(require("./workflows-module"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC;AACvC,qDAAkC"}
@@ -0,0 +1,83 @@
1
+ import { DistributedTransactionEvents, DistributedTransactionType, TransactionStep } from "@etohq/framework/orchestration";
2
+ import { ContainerLike, Context, EtoContainer } from "@etohq/framework/types";
3
+ import { FlowRunOptions, ReturnWorkflow } from "@etohq/framework/workflows-sdk";
4
+ import Redis from "ioredis";
5
+ import type { RedisDistributedTransactionStorage } from "../utils";
6
+ export type WorkflowOrchestratorRunOptions<T> = Omit<FlowRunOptions<T>, "container"> & {
7
+ transactionId?: string;
8
+ container?: ContainerLike;
9
+ };
10
+ type RegisterStepSuccessOptions<T> = Omit<WorkflowOrchestratorRunOptions<T>, "transactionId" | "input">;
11
+ type IdempotencyKeyParts = {
12
+ workflowId: string;
13
+ transactionId: string;
14
+ stepId: string;
15
+ action: "invoke" | "compensate";
16
+ };
17
+ type NotifyOptions = {
18
+ eventType: keyof DistributedTransactionEvents;
19
+ workflowId: string;
20
+ transactionId?: string;
21
+ step?: TransactionStep;
22
+ response?: unknown;
23
+ result?: unknown;
24
+ errors?: unknown[];
25
+ };
26
+ type SubscriberHandler = {
27
+ (input: NotifyOptions): void;
28
+ } & {
29
+ _id?: string;
30
+ };
31
+ type SubscribeOptions = {
32
+ workflowId: string;
33
+ transactionId?: string;
34
+ subscriber: SubscriberHandler;
35
+ subscriberId?: string;
36
+ };
37
+ type UnsubscribeOptions = {
38
+ workflowId: string;
39
+ transactionId?: string;
40
+ subscriberOrId: string | SubscriberHandler;
41
+ };
42
+ export declare class WorkflowOrchestratorService {
43
+ #private;
44
+ private instanceId;
45
+ protected redisPublisher: Redis;
46
+ protected redisSubscriber: Redis;
47
+ protected container_: EtoContainer;
48
+ private subscribers;
49
+ private activeStepsCount;
50
+ protected redisDistributedTransactionStorage_: RedisDistributedTransactionStorage;
51
+ constructor({ dataLoaderOnly, redisDistributedTransactionStorage, redisPublisher, redisSubscriber, sharedContainer, }: {
52
+ dataLoaderOnly: boolean;
53
+ redisDistributedTransactionStorage: RedisDistributedTransactionStorage;
54
+ workflowOrchestratorService: WorkflowOrchestratorService;
55
+ redisPublisher: Redis;
56
+ redisSubscriber: Redis;
57
+ sharedContainer: EtoContainer;
58
+ });
59
+ onApplicationShutdown(): Promise<void>;
60
+ onApplicationPrepareShutdown(): Promise<void>;
61
+ onApplicationStart(): Promise<void>;
62
+ private triggerParentStep;
63
+ run<T = unknown>(workflowIdOrWorkflow: string | ReturnWorkflow<any, any, any>, options?: WorkflowOrchestratorRunOptions<T>, sharedContext?: Context): Promise<any>;
64
+ getRunningTransaction(workflowId: string, transactionId: string, options?: WorkflowOrchestratorRunOptions<undefined>, sharedContext?: Context): Promise<DistributedTransactionType>;
65
+ setStepSuccess<T = unknown>({ idempotencyKey, stepResponse, options, }: {
66
+ idempotencyKey: string | IdempotencyKeyParts;
67
+ stepResponse: unknown;
68
+ options?: RegisterStepSuccessOptions<T>;
69
+ }, sharedContext?: Context): Promise<any>;
70
+ setStepFailure<T = unknown>({ idempotencyKey, stepResponse, options, }: {
71
+ idempotencyKey: string | IdempotencyKeyParts;
72
+ stepResponse: unknown;
73
+ options?: RegisterStepSuccessOptions<T>;
74
+ }, sharedContext?: Context): Promise<any>;
75
+ subscribe({ workflowId, transactionId, subscriber, subscriberId }: SubscribeOptions, sharedContext?: Context): void;
76
+ unsubscribe({ workflowId, transactionId, subscriberOrId }: UnsubscribeOptions, sharedContext?: Context): void;
77
+ private notify;
78
+ private getChannelName;
79
+ private buildWorkflowEvents;
80
+ private buildIdempotencyKeyAndParts;
81
+ }
82
+ export {};
83
+ //# sourceMappingURL=workflow-orchestrator.d.ts.map
@@ -0,0 +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;AAO/B,OAAO,EACL,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,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,mBAAmB,GAAG;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,QAAQ,GAAG,YAAY,CAAA;CAChC,CAAA;AAED,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,4BAA4B,CAAA;IAC7C,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,IAAI,CAAC,EAAE,eAAe,CAAA;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IACh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