@medusajs/workflow-engine-inmemory 0.0.2-next-20240124093206

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 (65) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +43 -0
  5. package/dist/initialize/index.d.ts +6 -0
  6. package/dist/initialize/index.d.ts.map +1 -0
  7. package/dist/initialize/index.js +18 -0
  8. package/dist/joiner-config.d.ts +8 -0
  9. package/dist/joiner-config.d.ts.map +1 -0
  10. package/dist/joiner-config.js +34 -0
  11. package/dist/loaders/connection.d.ts +5 -0
  12. package/dist/loaders/connection.d.ts.map +1 -0
  13. package/dist/loaders/connection.js +41 -0
  14. package/dist/loaders/container.d.ts +3 -0
  15. package/dist/loaders/container.d.ts.map +1 -0
  16. package/dist/loaders/container.js +33 -0
  17. package/dist/loaders/index.d.ts +4 -0
  18. package/dist/loaders/index.d.ts.map +1 -0
  19. package/dist/loaders/index.js +19 -0
  20. package/dist/loaders/utils.d.ts +5 -0
  21. package/dist/loaders/utils.d.ts.map +1 -0
  22. package/dist/loaders/utils.js +9 -0
  23. package/dist/migrations/Migration20231228143900.d.ts +6 -0
  24. package/dist/migrations/Migration20231228143900.d.ts.map +1 -0
  25. package/dist/migrations/Migration20231228143900.js +39 -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 +8 -0
  29. package/dist/models/workflow-execution.d.ts +19 -0
  30. package/dist/models/workflow-execution.d.ts.map +1 -0
  31. package/dist/models/workflow-execution.js +97 -0
  32. package/dist/module-definition.d.ts +3 -0
  33. package/dist/module-definition.d.ts.map +1 -0
  34. package/dist/module-definition.js +16 -0
  35. package/dist/repositories/index.d.ts +3 -0
  36. package/dist/repositories/index.d.ts.map +1 -0
  37. package/dist/repositories/index.js +7 -0
  38. package/dist/repositories/workflow-execution.d.ts +35 -0
  39. package/dist/repositories/workflow-execution.d.ts.map +1 -0
  40. package/dist/repositories/workflow-execution.js +9 -0
  41. package/dist/schema/index.d.ts +3 -0
  42. package/dist/schema/index.d.ts.map +1 -0
  43. package/dist/schema/index.js +28 -0
  44. package/dist/services/index.d.ts +4 -0
  45. package/dist/services/index.d.ts.map +1 -0
  46. package/dist/services/index.js +19 -0
  47. package/dist/services/workflow-execution.d.ts +16 -0
  48. package/dist/services/workflow-execution.d.ts.map +1 -0
  49. package/dist/services/workflow-execution.js +13 -0
  50. package/dist/services/workflow-orchestrator.d.ts +66 -0
  51. package/dist/services/workflow-orchestrator.d.ts.map +1 -0
  52. package/dist/services/workflow-orchestrator.js +352 -0
  53. package/dist/services/workflows-module.d.ts +43 -0
  54. package/dist/services/workflows-module.d.ts.map +1 -0
  55. package/dist/services/workflows-module.js +128 -0
  56. package/dist/types/index.d.ts +5 -0
  57. package/dist/types/index.d.ts.map +1 -0
  58. package/dist/types/index.js +2 -0
  59. package/dist/utils/index.d.ts +2 -0
  60. package/dist/utils/index.d.ts.map +1 -0
  61. package/dist/utils/index.js +17 -0
  62. package/dist/utils/workflow-orchestrator-storage.d.ts +25 -0
  63. package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -0
  64. package/dist/utils/workflow-orchestrator-storage.js +135 -0
  65. package/package.json +59 -0
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # Workflow Orchestrator
@@ -0,0 +1,7 @@
1
+ import { moduleDefinition } from "./module-definition";
2
+ export default moduleDefinition;
3
+ export declare const runMigrations: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
4
+ export declare const revertMigration: ({ options, logger, }?: Pick<import("@medusajs/modules-sdk").LoaderOptions<import("@medusajs/modules-sdk").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
5
+ export * from "./initialize";
6
+ export * from "./loaders";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,eAAe,gBAAgB,CAAA;AAQ/B,eAAO,MAAM,aAAa,iMAEzB,CAAA;AACD,eAAO,MAAM,eAAe,iMAE3B,CAAA;AAED,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.revertMigration = exports.runMigrations = void 0;
30
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
31
+ const utils_1 = require("@medusajs/utils");
32
+ const models = __importStar(require("./models"));
33
+ const module_definition_1 = require("./module-definition");
34
+ exports.default = module_definition_1.moduleDefinition;
35
+ const migrationScriptOptions = {
36
+ moduleName: modules_sdk_1.Modules.WORKFLOW_ENGINE,
37
+ models: models,
38
+ pathToMigrations: __dirname + "/migrations",
39
+ };
40
+ exports.runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
41
+ exports.revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
42
+ __exportStar(require("./initialize"), exports);
43
+ __exportStar(require("./loaders"), exports);
@@ -0,0 +1,6 @@
1
+ import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
2
+ import { ModulesSdkTypes } from "@medusajs/types";
3
+ import { WorkflowOrchestratorTypes } from "@medusajs/workflows-sdk";
4
+ import { InitializeModuleInjectableDependencies } from "../types";
5
+ export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<WorkflowOrchestratorTypes.IWorkflowsModuleService>;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/initialize/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EAI1B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,EAAE,sCAAsC,EAAE,MAAM,UAAU,CAAA;AAEjE,eAAO,MAAM,UAAU,aAEjB,gBAAgB,8BAA8B,GAC9C,gBAAgB,6CAA6C,GAC7D,yBAAyB,GACzB,yBAAyB,yBACN,sCAAsC,KAC5D,QAAQ,0BAA0B,uBAAuB,CAgB3D,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initialize = void 0;
4
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
5
+ const module_definition_1 = require("../module-definition");
6
+ const initialize = async (options, injectedDependencies) => {
7
+ const loaded =
8
+ // eslint-disable-next-line max-len
9
+ await modules_sdk_1.MedusaModule.bootstrap({
10
+ moduleKey: modules_sdk_1.Modules.WORKFLOW_ENGINE,
11
+ defaultPath: modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.WORKFLOW_ENGINE],
12
+ declaration: options,
13
+ injectedDependencies,
14
+ moduleExports: module_definition_1.moduleDefinition,
15
+ });
16
+ return loaded[modules_sdk_1.Modules.WORKFLOW_ENGINE];
17
+ };
18
+ exports.initialize = initialize;
@@ -0,0 +1,8 @@
1
+ import { ModuleJoinerConfig } from "@medusajs/types";
2
+ import { MapToConfig } from "@medusajs/utils";
3
+ export declare const LinkableKeys: {
4
+ workflow_execution_id: string;
5
+ };
6
+ export declare const entityNameToLinkableKeysMap: MapToConfig;
7
+ export declare const joinerConfig: ModuleJoinerConfig;
8
+ //# sourceMappingURL=joiner-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joiner-config.d.ts","sourceRoot":"","sources":["../src/joiner-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAI7C,eAAO,MAAM,YAAY;;CAExB,CAAA;AAWD,eAAO,MAAM,2BAA2B,EAAE,WAAmC,CAAA;AAE7E,eAAO,MAAM,YAAY,EAAE,kBAY1B,CAAA"}
@@ -0,0 +1,34 @@
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.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
7
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
8
+ const _models_1 = require("./models");
9
+ const schema_1 = __importDefault(require("./schema"));
10
+ exports.LinkableKeys = {
11
+ workflow_execution_id: _models_1.WorkflowExecution.name,
12
+ };
13
+ const entityLinkableKeysMap = {};
14
+ Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
15
+ entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
16
+ entityLinkableKeysMap[value].push({
17
+ mapTo: key,
18
+ valueFrom: key.split("_").pop(),
19
+ });
20
+ });
21
+ exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
22
+ exports.joinerConfig = {
23
+ serviceName: modules_sdk_1.Modules.WORKFLOW_ENGINE,
24
+ primaryKeys: ["id"],
25
+ schema: schema_1.default,
26
+ linkableKeys: exports.LinkableKeys,
27
+ alias: {
28
+ name: ["workflow_execution", "workflow_executions"],
29
+ args: {
30
+ entity: _models_1.WorkflowExecution.name,
31
+ methodSuffix: "WorkflowExecution",
32
+ },
33
+ },
34
+ };
@@ -0,0 +1,5 @@
1
+ import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk";
2
+ import { ModulesSdkTypes } from "@medusajs/types";
3
+ declare const _default: ({ options, container, logger, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
4
+ export default _default;
5
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/loaders/connection.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,aAAa,EAEd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;0DAU5C,cACC,gBAAgB,8BAA8B,GAC9C,gBAAgB,6CAA6C,CAChE,sBACmB,yBAAyB,KAC5C,QAAQ,IAAI,CAAC;AAVhB,wBAyBC"}
@@ -0,0 +1,41 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
27
+ const utils_1 = require("@medusajs/utils");
28
+ const WorkflowOrchestratorModels = __importStar(require("../models"));
29
+ exports.default = async ({ options, container, logger, }, moduleDeclaration) => {
30
+ const entities = Object.values(WorkflowOrchestratorModels);
31
+ const pathToMigrations = __dirname + "/../migrations";
32
+ await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
33
+ moduleName: modules_sdk_1.Modules.WORKFLOW_ENGINE,
34
+ entities,
35
+ container,
36
+ options,
37
+ moduleDeclaration,
38
+ logger,
39
+ pathToMigrations,
40
+ });
41
+ };
@@ -0,0 +1,3 @@
1
+ declare const _default: ({ container, options }: import("@medusajs/types").LoaderOptions) => Promise<void>;
2
+ export default _default;
3
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/loaders/container.ts"],"names":[],"mappings":";AAIA,wBAIE"}
@@ -0,0 +1,33 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const utils_1 = require("@medusajs/utils");
27
+ const ModuleModels = __importStar(require("../models"));
28
+ const ModuleServices = __importStar(require("../services"));
29
+ exports.default = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
30
+ moduleModels: ModuleModels,
31
+ moduleServices: ModuleServices,
32
+ moduleRepositories: { BaseRepository: utils_1.MikroOrmBaseRepository },
33
+ });
@@ -0,0 +1,4 @@
1
+ export * from "./connection";
2
+ export * from "./container";
3
+ export * from "./utils";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/loaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,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("./connection"), exports);
18
+ __exportStar(require("./container"), exports);
19
+ __exportStar(require("./utils"), exports);
@@ -0,0 +1,5 @@
1
+ declare const _default: ({ container }: {
2
+ container: any;
3
+ }) => Promise<void>;
4
+ export default _default;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/loaders/utils.ts"],"names":[],"mappings":";;MAGsC,QAAQ,IAAI,CAAC;AAAnD,wBAMC"}
@@ -0,0 +1,9 @@
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 }) => {
6
+ container.register({
7
+ inMemoryDistributedTransactionStorage: (0, awilix_1.asClass)(utils_1.InMemoryDistributedTransactionStorage).singleton(),
8
+ });
9
+ };
@@ -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,39 @@
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;
@@ -0,0 +1,2 @@
1
+ export { default as 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,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,8 @@
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.WorkflowExecution = void 0;
7
+ var workflow_execution_1 = require("./workflow-execution");
8
+ Object.defineProperty(exports, "WorkflowExecution", { enumerable: true, get: function () { return __importDefault(workflow_execution_1).default; } });
@@ -0,0 +1,19 @@
1
+ import { TransactionState } from "@medusajs/orchestration";
2
+ import { OptionalProps } from "@mikro-orm/core";
3
+ type OptionalFields = "deleted_at";
4
+ export default class WorkflowExecution {
5
+ [OptionalProps]?: OptionalFields;
6
+ id: string;
7
+ workflow_id: string;
8
+ transaction_id: string;
9
+ execution: Record<string, unknown> | null;
10
+ context: Record<string, unknown> | null;
11
+ state: TransactionState;
12
+ created_at: Date;
13
+ updated_at: Date;
14
+ deleted_at: Date | null;
15
+ onCreate(): void;
16
+ onInit(): void;
17
+ }
18
+ export {};
19
+ //# 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,yBAAyB,CAAA;AAE1D,OAAO,EAOL,aAAa,EAId,MAAM,iBAAiB,CAAA;AAExB,KAAK,cAAc,GAAG,YAAY,CAAA;AAQlC,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,CAAC,aAAa,CAAC,CAAC,EAAE,cAAc,CAAA;IAIhC,EAAE,EAAG,MAAM,CAAA;IAIX,WAAW,EAAE,MAAM,CAAA;IAInB,cAAc,EAAE,MAAM,CAAA;IAGtB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAO;IAGhD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAO;IAI9C,KAAK,EAAE,gBAAgB,CAAA;IAOvB,UAAU,EAAE,IAAI,CAAA;IAQhB,UAAU,EAAE,IAAI,CAAA;IAGhB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAO;IAG9B,QAAQ;IAKR,MAAM;CAGP"}
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const orchestration_1 = require("@medusajs/orchestration");
13
+ const utils_1 = require("@medusajs/utils");
14
+ const core_1 = require("@mikro-orm/core");
15
+ let WorkflowExecution = class WorkflowExecution {
16
+ constructor() {
17
+ this.execution = null;
18
+ this.context = null;
19
+ this.deleted_at = null;
20
+ }
21
+ onCreate() {
22
+ this.id = (0, utils_1.generateEntityId)(this.id, "wf_exec");
23
+ }
24
+ onInit() {
25
+ this.id = (0, utils_1.generateEntityId)(this.id, "wf_exec");
26
+ }
27
+ };
28
+ __decorate([
29
+ (0, core_1.Property)({ columnType: "text", nullable: false }),
30
+ (0, core_1.Index)({ name: "IDX_workflow_execution_id" }),
31
+ __metadata("design:type", String)
32
+ ], WorkflowExecution.prototype, "id", void 0);
33
+ __decorate([
34
+ (0, core_1.Index)({ name: "IDX_workflow_execution_workflow_id" }),
35
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
36
+ __metadata("design:type", String)
37
+ ], WorkflowExecution.prototype, "workflow_id", void 0);
38
+ __decorate([
39
+ (0, core_1.Index)({ name: "IDX_workflow_execution_transaction_id" }),
40
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
41
+ __metadata("design:type", String)
42
+ ], WorkflowExecution.prototype, "transaction_id", void 0);
43
+ __decorate([
44
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
45
+ __metadata("design:type", Object)
46
+ ], WorkflowExecution.prototype, "execution", void 0);
47
+ __decorate([
48
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
49
+ __metadata("design:type", Object)
50
+ ], WorkflowExecution.prototype, "context", void 0);
51
+ __decorate([
52
+ (0, core_1.Index)({ name: "IDX_workflow_execution_state" }),
53
+ (0, core_1.Enum)(() => orchestration_1.TransactionState),
54
+ __metadata("design:type", String)
55
+ ], WorkflowExecution.prototype, "state", void 0);
56
+ __decorate([
57
+ (0, core_1.Property)({
58
+ onCreate: () => new Date(),
59
+ columnType: "timestamptz",
60
+ defaultRaw: "now()",
61
+ }),
62
+ __metadata("design:type", Date)
63
+ ], WorkflowExecution.prototype, "created_at", void 0);
64
+ __decorate([
65
+ (0, core_1.Property)({
66
+ onCreate: () => new Date(),
67
+ onUpdate: () => new Date(),
68
+ columnType: "timestamptz",
69
+ defaultRaw: "now()",
70
+ }),
71
+ __metadata("design:type", Date)
72
+ ], WorkflowExecution.prototype, "updated_at", void 0);
73
+ __decorate([
74
+ (0, core_1.Property)({ columnType: "timestamptz", nullable: true }),
75
+ __metadata("design:type", Object)
76
+ ], WorkflowExecution.prototype, "deleted_at", void 0);
77
+ __decorate([
78
+ (0, core_1.BeforeCreate)(),
79
+ __metadata("design:type", Function),
80
+ __metadata("design:paramtypes", []),
81
+ __metadata("design:returntype", void 0)
82
+ ], WorkflowExecution.prototype, "onCreate", null);
83
+ __decorate([
84
+ (0, core_1.OnInit)(),
85
+ __metadata("design:type", Function),
86
+ __metadata("design:paramtypes", []),
87
+ __metadata("design:returntype", void 0)
88
+ ], WorkflowExecution.prototype, "onInit", null);
89
+ WorkflowExecution = __decorate([
90
+ (0, core_1.Entity)(),
91
+ (0, core_1.Unique)({
92
+ name: "IDX_workflow_execution_workflow_id_transaction_id_unique",
93
+ properties: ["workflow_id", "transaction_id"],
94
+ }),
95
+ (0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
96
+ ], WorkflowExecution);
97
+ exports.default = WorkflowExecution;
@@ -0,0 +1,3 @@
1
+ import { ModuleExports } from "@medusajs/types";
2
+ export declare const moduleDefinition: ModuleExports;
3
+ //# sourceMappingURL=module-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-definition.d.ts","sourceRoot":"","sources":["../src/module-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAS/C,eAAO,MAAM,gBAAgB,EAAE,aAG9B,CAAA"}
@@ -0,0 +1,16 @@
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.moduleDefinition = void 0;
7
+ const _services_1 = require("./services");
8
+ const connection_1 = __importDefault(require("./loaders/connection"));
9
+ const container_1 = __importDefault(require("./loaders/container"));
10
+ const utils_1 = __importDefault(require("./loaders/utils"));
11
+ const service = _services_1.WorkflowsModuleService;
12
+ const loaders = [container_1.default, connection_1.default, utils_1.default];
13
+ exports.moduleDefinition = {
14
+ service,
15
+ loaders,
16
+ };
@@ -0,0 +1,3 @@
1
+ export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
2
+ export { WorkflowExecutionRepository } from "./workflow-execution";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/repositories/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowExecutionRepository = exports.BaseRepository = void 0;
4
+ var utils_1 = require("@medusajs/utils");
5
+ Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
6
+ var workflow_execution_1 = require("./workflow-execution");
7
+ Object.defineProperty(exports, "WorkflowExecutionRepository", { enumerable: true, get: function () { return workflow_execution_1.WorkflowExecutionRepository; } });
@@ -0,0 +1,35 @@
1
+ import { WorkflowExecution } from "../models";
2
+ declare const WorkflowExecutionRepository_base: {
3
+ new (...args: any[]): {
4
+ create(data: any[], context?: import("@medusajs/types").Context | undefined): Promise<WorkflowExecution[]>;
5
+ update(data: any[], context?: import("@medusajs/types").Context | undefined): Promise<WorkflowExecution[]>;
6
+ delete(primaryKeyValues: string[] | object[], context?: import("@medusajs/types").Context | undefined): Promise<void>;
7
+ find(options?: import("@medusajs/types").FindOptions<WorkflowExecution> | undefined, context?: import("@medusajs/types").Context | undefined): Promise<WorkflowExecution[]>;
8
+ findAndCount(findOptions?: import("@medusajs/types").FindOptions<WorkflowExecution> | undefined, context?: import("@medusajs/types").Context | undefined): Promise<[WorkflowExecution[], number]>;
9
+ upsert(data: any[], context?: import("@medusajs/types").Context | undefined): Promise<WorkflowExecution[]>;
10
+ softDelete(idsOrFilter: string[] | {
11
+ [x: string]: any;
12
+ }, { transactionManager: manager }?: import("@medusajs/types").Context | undefined): Promise<[WorkflowExecution[], Record<string, unknown[]>]>;
13
+ restore(idsOrFilter: string[] | {
14
+ [x: string]: any;
15
+ }, { transactionManager: manager }?: import("@medusajs/types").Context | undefined): Promise<[WorkflowExecution[], Record<string, unknown[]>]>;
16
+ applyFreeTextSearchFilters<T>(findOptions: import("@medusajs/types").FindOptions<T & {
17
+ q?: string | undefined;
18
+ }>, retrieveConstraintsToApply: (q: string) => any[]): void;
19
+ readonly manager_: any;
20
+ getFreshManager<TManager = unknown>(): TManager;
21
+ getActiveManager<TManager_1 = unknown>({ transactionManager, manager }?: import("@medusajs/types").Context | undefined): TManager_1;
22
+ transaction<TManager_2 = unknown>(task: (transactionManager: TManager_2) => Promise<any>, options?: {
23
+ isolationLevel?: string | undefined;
24
+ enableNestedTransactions?: boolean | undefined;
25
+ transaction?: TManager_2 | undefined;
26
+ } | undefined): Promise<any>;
27
+ serialize<TOutput extends object | object[]>(data: any, options?: any): Promise<TOutput>;
28
+ };
29
+ buildUniqueCompositeKeyValue(keys: string[], data: object): string;
30
+ retrievePrimaryKeys(entity: import("@mikro-orm/core").EntityClass<WorkflowExecution> | import("@mikro-orm/core").EntitySchema<WorkflowExecution, never>): ("workflow_id" | "transaction_id" | "deleted_at" | "id" | "execution" | "context" | "state" | "created_at" | "updated_at" | "onCreate" | "onInit")[];
31
+ };
32
+ export declare class WorkflowExecutionRepository extends WorkflowExecutionRepository_base {
33
+ }
34
+ export {};
35
+ //# sourceMappingURL=workflow-execution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../src/repositories/workflow-execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAG3C,qBAAa,2BAA4B,SAAQ,gCAEhD;CAAG"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WorkflowExecutionRepository = void 0;
4
+ const utils_1 = require("@medusajs/utils");
5
+ const _models_1 = require("../models");
6
+ // eslint-disable-next-line max-len
7
+ class WorkflowExecutionRepository extends utils_1.DALUtils.mikroOrmBaseRepositoryFactory(_models_1.WorkflowExecution) {
8
+ }
9
+ exports.WorkflowExecutionRepository = WorkflowExecutionRepository;
@@ -0,0 +1,3 @@
1
+ declare const _default: "\nscalar DateTime\nscalar JSON\n\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,wBAyBC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = `
4
+ scalar DateTime
5
+ scalar JSON
6
+
7
+ enum TransactionState {
8
+ NOT_STARTED
9
+ INVOKING
10
+ WAITING_TO_COMPENSATE
11
+ COMPENSATING
12
+ DONE
13
+ REVERTED
14
+ FAILED
15
+ }
16
+
17
+ type WorkflowExecution {
18
+ id: ID!
19
+ created_at: DateTime!
20
+ updated_at: DateTime!
21
+ deleted_at: DateTime
22
+ workflow_id: string
23
+ transaction_id: string
24
+ execution: JSON
25
+ context: JSON
26
+ state: TransactionState
27
+ }
28
+ `;
@@ -0,0 +1,4 @@
1
+ export * from "./workflow-execution";
2
+ export * from "./workflow-orchestrator";
3
+ export * from "./workflows-module";
4
+ //# 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,sBAAsB,CAAA;AACpC,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA"}