@medusajs/workflow-engine-inmemory 0.0.5 → 1.0.0-rc-20241001083650
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -41
- package/dist/index.js.map +1 -0
- package/dist/loaders/index.d.ts +1 -3
- package/dist/loaders/index.d.ts.map +1 -1
- package/dist/loaders/index.js +6 -16
- package/dist/loaders/index.js.map +1 -0
- package/dist/loaders/utils.d.ts.map +1 -1
- package/dist/loaders/utils.js +1 -0
- package/dist/loaders/utils.js.map +1 -0
- package/dist/migrations/Migration20231228143900.js +1 -0
- package/dist/migrations/Migration20231228143900.js.map +1 -0
- package/dist/models/index.js +1 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/workflow-execution.d.ts +1 -1
- package/dist/models/workflow-execution.d.ts.map +1 -1
- package/dist/models/workflow-execution.js +3 -2
- package/dist/models/workflow-execution.js.map +1 -0
- package/dist/schema/index.d.ts +1 -1
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -3
- package/dist/schema/index.js.map +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/workflow-orchestrator.d.ts +9 -6
- package/dist/services/workflow-orchestrator.d.ts.map +1 -1
- package/dist/services/workflow-orchestrator.js +61 -21
- package/dist/services/workflow-orchestrator.js.map +1 -0
- package/dist/services/workflows-module.d.ts +15 -14
- package/dist/services/workflows-module.d.ts.map +1 -1
- package/dist/services/workflows-module.js +10 -89
- package/dist/services/workflows-module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/workflow-orchestrator-storage.d.ts +22 -13
- package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -1
- package/dist/utils/workflow-orchestrator-storage.js +104 -27
- package/dist/utils/workflow-orchestrator-storage.js.map +1 -0
- package/package.json +24 -19
- package/dist/initialize/index.d.ts +0 -6
- package/dist/initialize/index.d.ts.map +0 -1
- package/dist/initialize/index.js +0 -18
- package/dist/joiner-config.d.ts +0 -8
- package/dist/joiner-config.d.ts.map +0 -1
- package/dist/joiner-config.js +0 -34
- package/dist/loaders/connection.d.ts +0 -5
- package/dist/loaders/connection.d.ts.map +0 -1
- package/dist/loaders/connection.js +0 -41
- package/dist/loaders/container.d.ts +0 -3
- package/dist/loaders/container.d.ts.map +0 -1
- package/dist/loaders/container.js +0 -33
- package/dist/module-definition.d.ts +0 -3
- package/dist/module-definition.d.ts.map +0 -1
- package/dist/module-definition.js +0 -16
- package/dist/repositories/index.d.ts +0 -3
- package/dist/repositories/index.d.ts.map +0 -1
- package/dist/repositories/index.js +0 -7
- package/dist/repositories/workflow-execution.d.ts +0 -8
- package/dist/repositories/workflow-execution.d.ts.map +0 -1
- package/dist/repositories/workflow-execution.js +0 -9
@@ -14,93 +14,34 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
14
14
|
var _a;
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
16
16
|
exports.WorkflowsModuleService = void 0;
|
17
|
-
const
|
18
|
-
const
|
19
|
-
|
17
|
+
const types_1 = require("@medusajs/framework/types");
|
18
|
+
const utils_1 = require("@medusajs/framework/utils");
|
19
|
+
const _models_1 = require("../models");
|
20
|
+
class WorkflowsModuleService extends utils_1.ModulesSdkUtils.MedusaService({ WorkflowExecution: _models_1.WorkflowExecution }) {
|
20
21
|
constructor({ baseRepository, workflowExecutionService, workflowOrchestratorService, }, moduleDeclaration) {
|
22
|
+
// @ts-ignore
|
23
|
+
super(...arguments);
|
21
24
|
this.moduleDeclaration = moduleDeclaration;
|
22
25
|
this.baseRepository_ = baseRepository;
|
23
26
|
this.workflowExecutionService_ = workflowExecutionService;
|
24
27
|
this.workflowOrchestratorService_ = workflowOrchestratorService;
|
25
28
|
}
|
26
|
-
__joinerConfig() {
|
27
|
-
return joiner_config_1.joinerConfig;
|
28
|
-
}
|
29
|
-
async retrieveWorkflowExecution(idOrObject, config = {}, sharedContext = {}) {
|
30
|
-
const objValue = (0, utils_1.isString)(idOrObject)
|
31
|
-
? { id: idOrObject }
|
32
|
-
: {
|
33
|
-
workflow_id: idOrObject.workflow_id,
|
34
|
-
transaction_id: idOrObject.transaction_id,
|
35
|
-
};
|
36
|
-
const wfExecution = await this.workflowExecutionService_.list(objValue, config, sharedContext);
|
37
|
-
if (wfExecution.length === 0) {
|
38
|
-
throw new utils_1.MedusaError(utils_1.MedusaError.Types.NOT_FOUND, `WorkflowExecution with ${Object.keys(objValue).join(", ")}: ${Object.values(objValue).join(", ")} was not found`);
|
39
|
-
}
|
40
|
-
// eslint-disable-next-line max-len
|
41
|
-
return await this.baseRepository_.serialize(wfExecution[0], {
|
42
|
-
populate: true,
|
43
|
-
});
|
44
|
-
}
|
45
|
-
async listWorkflowExecution(filters = {}, config = {}, sharedContext = {}) {
|
46
|
-
if (filters.transaction_id) {
|
47
|
-
if (Array.isArray(filters.transaction_id)) {
|
48
|
-
filters.transaction_id = {
|
49
|
-
$in: filters.transaction_id,
|
50
|
-
};
|
51
|
-
}
|
52
|
-
}
|
53
|
-
if (filters.workflow_id) {
|
54
|
-
if (Array.isArray(filters.workflow_id)) {
|
55
|
-
filters.workflow_id = {
|
56
|
-
$in: filters.workflow_id,
|
57
|
-
};
|
58
|
-
}
|
59
|
-
}
|
60
|
-
const wfExecutions = await this.workflowExecutionService_.list(filters, config, sharedContext);
|
61
|
-
return await this.baseRepository_.serialize(wfExecutions, {
|
62
|
-
populate: true,
|
63
|
-
});
|
64
|
-
}
|
65
|
-
async listAndCountWorkflowExecution(filters = {}, config = {}, sharedContext = {}) {
|
66
|
-
if (filters.transaction_id) {
|
67
|
-
if (Array.isArray(filters.transaction_id)) {
|
68
|
-
filters.transaction_id = {
|
69
|
-
$in: filters.transaction_id,
|
70
|
-
};
|
71
|
-
}
|
72
|
-
}
|
73
|
-
if (filters.workflow_id) {
|
74
|
-
if (Array.isArray(filters.workflow_id)) {
|
75
|
-
filters.workflow_id = {
|
76
|
-
$in: filters.workflow_id,
|
77
|
-
};
|
78
|
-
}
|
79
|
-
}
|
80
|
-
const [wfExecutions, count] = await this.workflowExecutionService_.listAndCount(filters, config, sharedContext);
|
81
|
-
return [
|
82
|
-
await this.baseRepository_.serialize(wfExecutions, {
|
83
|
-
populate: true,
|
84
|
-
}),
|
85
|
-
count,
|
86
|
-
];
|
87
|
-
}
|
88
29
|
async run(workflowIdOrWorkflow, options = {}, context = {}) {
|
89
30
|
const ret = await this.workflowOrchestratorService_.run(workflowIdOrWorkflow, options, context);
|
90
31
|
return ret;
|
91
32
|
}
|
92
33
|
async getRunningTransaction(workflowId, transactionId, context = {}) {
|
93
|
-
return this.workflowOrchestratorService_.getRunningTransaction(workflowId, transactionId, context);
|
34
|
+
return await this.workflowOrchestratorService_.getRunningTransaction(workflowId, transactionId, context);
|
94
35
|
}
|
95
36
|
async setStepSuccess({ idempotencyKey, stepResponse, options, }, context = {}) {
|
96
|
-
return this.workflowOrchestratorService_.setStepSuccess({
|
37
|
+
return await this.workflowOrchestratorService_.setStepSuccess({
|
97
38
|
idempotencyKey,
|
98
39
|
stepResponse,
|
99
40
|
options,
|
100
41
|
}, context);
|
101
42
|
}
|
102
43
|
async setStepFailure({ idempotencyKey, stepResponse, options, }, context = {}) {
|
103
|
-
return this.workflowOrchestratorService_.setStepFailure({
|
44
|
+
return await this.workflowOrchestratorService_.setStepFailure({
|
104
45
|
idempotencyKey,
|
105
46
|
stepResponse,
|
106
47
|
options,
|
@@ -114,27 +55,6 @@ class WorkflowsModuleService {
|
|
114
55
|
}
|
115
56
|
}
|
116
57
|
exports.WorkflowsModuleService = WorkflowsModuleService;
|
117
|
-
__decorate([
|
118
|
-
(0, utils_1.InjectManager)("baseRepository_"),
|
119
|
-
__param(2, (0, utils_1.MedusaContext)()),
|
120
|
-
__metadata("design:type", Function),
|
121
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
122
|
-
__metadata("design:returntype", Promise)
|
123
|
-
], WorkflowsModuleService.prototype, "retrieveWorkflowExecution", null);
|
124
|
-
__decorate([
|
125
|
-
(0, utils_1.InjectManager)("baseRepository_"),
|
126
|
-
__param(2, (0, utils_1.MedusaContext)()),
|
127
|
-
__metadata("design:type", Function),
|
128
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
129
|
-
__metadata("design:returntype", Promise)
|
130
|
-
], WorkflowsModuleService.prototype, "listWorkflowExecution", null);
|
131
|
-
__decorate([
|
132
|
-
(0, utils_1.InjectManager)("baseRepository_"),
|
133
|
-
__param(2, (0, utils_1.MedusaContext)()),
|
134
|
-
__metadata("design:type", Function),
|
135
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
136
|
-
__metadata("design:returntype", Promise)
|
137
|
-
], WorkflowsModuleService.prototype, "listAndCountWorkflowExecution", null);
|
138
58
|
__decorate([
|
139
59
|
(0, utils_1.InjectSharedContext)(),
|
140
60
|
__param(2, (0, utils_1.MedusaContext)()),
|
@@ -177,3 +97,4 @@ __decorate([
|
|
177
97
|
__metadata("design:paramtypes", [Object, Object]),
|
178
98
|
__metadata("design:returntype", Promise)
|
179
99
|
], WorkflowsModuleService.prototype, "unsubscribe", null);
|
100
|
+
//# sourceMappingURL=workflows-module.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workflows-module.js","sourceRoot":"","sources":["../../src/services/workflows-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAOkC;AAClC,qDAIkC;AAKlC,qCAA2C;AAS3C,MAAa,sBAEX,SAAQ,uBAAe,CAAC,aAAa,CAEpC,EAAE,iBAAiB,EAAjB,2BAAiB,EAAE,CAAC;IAMvB,YACE,EACE,cAAc,EACd,wBAAwB,EACxB,2BAA2B,GACN,EACJ,iBAA4C;QAE/D,aAAa;QACb,KAAK,CAAC,G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C;IAGK,AAAN,KAAK,CAAC,WAAW,CACf,IAIC,EACgB,UAAmB,EAAE;QAEtC,OAAO,IAAI,CAAC,4BAA4B,CAAC,WAAW,CAAC,IAAW,EAAE,OAAO,CAAC,CAAA;IAC5E,CAAC;CACF;AAhID,wDAgIC;AArGO;IADL,IAAA,2BAAmB,GAAE;IAQnB,WAAA,IAAA,qBAAa,GAAE,CAAA;;yDANM,SAAS,oBAAT,SAAS;;iDAehC;AAGK;IADL,IAAA,2BAAmB,GAAE;IAInB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;mEAOjB;AAGK;IADL,IAAA,2BAAmB,GAAE;IAWnB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;4DAUjB;AAGK;IADL,IAAA,2BAAmB,GAAE;IAWnB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;4DAUjB;AAGK;IADL,IAAA,2BAAmB,GAAE;IAQnB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;uDAGjB;AAGK;IADL,IAAA,2BAAmB,GAAE;IAOnB,WAAA,IAAA,qBAAa,GAAE,CAAA;;;;yDAGjB"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"root":["../src/index.ts","../src/loaders/index.ts","../src/loaders/utils.ts","../src/migrations/migration20231228143900.ts","../src/models/index.ts","../src/models/workflow-execution.ts","../src/schema/index.ts","../src/services/index.ts","../src/services/workflow-orchestrator.ts","../src/services/workflows-module.ts","../src/types/index.ts","../src/utils/index.ts","../src/utils/workflow-orchestrator-storage.ts"],"version":"5.6.2"}
|
package/dist/types/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAElD,MAAM,MAAM,sCAAsC,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA"}
|
package/dist/types/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
package/dist/utils/index.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAA+C"}
|
@@ -1,25 +1,34 @@
|
|
1
|
-
import {
|
2
|
-
import { ModulesSdkTypes } from "@medusajs/types";
|
3
|
-
export declare class InMemoryDistributedTransactionStorage
|
1
|
+
import { DistributedTransactionType, IDistributedSchedulerStorage, IDistributedTransactionStorage, SchedulerOptions, TransactionCheckpoint, TransactionOptions, TransactionStep } from "@medusajs/framework/orchestration";
|
2
|
+
import { Logger, ModulesSdkTypes } from "@medusajs/framework/types";
|
3
|
+
export declare class InMemoryDistributedTransactionStorage implements IDistributedTransactionStorage, IDistributedSchedulerStorage {
|
4
4
|
private workflowExecutionService_;
|
5
|
+
private logger_;
|
5
6
|
private workflowOrchestratorService_;
|
6
7
|
private storage;
|
8
|
+
private scheduled;
|
7
9
|
private retries;
|
8
10
|
private timeouts;
|
9
|
-
constructor({ workflowExecutionService, }: {
|
10
|
-
workflowExecutionService: ModulesSdkTypes.
|
11
|
+
constructor({ workflowExecutionService, logger, }: {
|
12
|
+
workflowExecutionService: ModulesSdkTypes.IMedusaInternalService<any>;
|
13
|
+
logger: Logger;
|
11
14
|
});
|
12
15
|
setWorkflowOrchestratorService(workflowOrchestratorService: any): void;
|
13
16
|
private saveToDb;
|
14
17
|
private deleteFromDb;
|
15
|
-
get(key: string): Promise<TransactionCheckpoint | undefined>;
|
18
|
+
get(key: string, options?: TransactionOptions): Promise<TransactionCheckpoint | undefined>;
|
16
19
|
list(): Promise<TransactionCheckpoint[]>;
|
17
|
-
save(key: string, data: TransactionCheckpoint, ttl?: number): Promise<void>;
|
18
|
-
scheduleRetry(transaction:
|
19
|
-
clearRetry(transaction:
|
20
|
-
scheduleTransactionTimeout(transaction:
|
21
|
-
clearTransactionTimeout(transaction:
|
22
|
-
scheduleStepTimeout(transaction:
|
23
|
-
clearStepTimeout(transaction:
|
20
|
+
save(key: string, data: TransactionCheckpoint, ttl?: number, options?: TransactionOptions): Promise<void>;
|
21
|
+
scheduleRetry(transaction: DistributedTransactionType, step: TransactionStep, timestamp: number, interval: number): Promise<void>;
|
22
|
+
clearRetry(transaction: DistributedTransactionType, step: TransactionStep): Promise<void>;
|
23
|
+
scheduleTransactionTimeout(transaction: DistributedTransactionType, timestamp: number, interval: number): Promise<void>;
|
24
|
+
clearTransactionTimeout(transaction: DistributedTransactionType): Promise<void>;
|
25
|
+
scheduleStepTimeout(transaction: DistributedTransactionType, step: TransactionStep, timestamp: number, interval: number): Promise<void>;
|
26
|
+
clearStepTimeout(transaction: DistributedTransactionType, step: TransactionStep): Promise<void>;
|
27
|
+
schedule(jobDefinition: string | {
|
28
|
+
jobId: string;
|
29
|
+
}, schedulerOptions: SchedulerOptions): Promise<void>;
|
30
|
+
remove(jobId: string): Promise<void>;
|
31
|
+
removeAll(): Promise<void>;
|
32
|
+
jobHandler(jobId: string): Promise<void>;
|
24
33
|
}
|
25
34
|
//# sourceMappingURL=workflow-orchestrator-storage.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workflow-orchestrator-storage.d.ts","sourceRoot":"","sources":["../../src/utils/workflow-orchestrator-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
1
|
+
{"version":3,"file":"workflow-orchestrator-storage.d.ts","sourceRoot":"","sources":["../../src/utils/workflow-orchestrator-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,8BAA8B,EAC9B,gBAAgB,EAChB,qBAAqB,EACrB,kBAAkB,EAClB,e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O,CAAC,IAAI,CAAC;IAcV,uBAAuB,CAC3B,WAAW,EAAE,0BAA0B,GACtC,OAAO,CAAC,IAAI,CAAC;IAWV,mBAAmB,CACvB,WAAW,EAAE,0BAA0B,EACvC,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAcV,gBAAgB,CACpB,WAAW,EAAE,0BAA0B,EACvC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC;IAYV,QAAQ,CACZ,aAAa,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,EACzC,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,IAAI,CAAC;IAsBV,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUpC,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1B,UAAU,CAAC,KAAK,EAAE,MAAM;CA6C/B"}
|
@@ -1,16 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.InMemoryDistributedTransactionStorage = void 0;
|
4
|
-
const
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
constructor({ workflowExecutionService, }) {
|
9
|
-
super();
|
4
|
+
const utils_1 = require("@medusajs/framework/utils");
|
5
|
+
const cron_parser_1 = require("cron-parser");
|
6
|
+
class InMemoryDistributedTransactionStorage {
|
7
|
+
constructor({ workflowExecutionService, logger, }) {
|
10
8
|
this.storage = new Map();
|
9
|
+
this.scheduled = new Map();
|
11
10
|
this.retries = new Map();
|
12
11
|
this.timeouts = new Map();
|
13
12
|
this.workflowExecutionService_ = workflowExecutionService;
|
13
|
+
this.logger_ = logger;
|
14
14
|
}
|
15
15
|
setWorkflowOrchestratorService(workflowOrchestratorService) {
|
16
16
|
this.workflowOrchestratorService_ = workflowOrchestratorService;
|
@@ -37,30 +37,38 @@ class InMemoryDistributedTransactionStorage extends orchestration_1.DistributedT
|
|
37
37
|
},
|
38
38
|
]);
|
39
39
|
}
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
40
|
+
async get(key, options) {
|
41
|
+
const data = this.storage.get(key);
|
42
|
+
if (data) {
|
43
|
+
return data;
|
44
|
+
}
|
45
|
+
const { idempotent } = options ?? {};
|
46
|
+
if (!idempotent) {
|
47
|
+
return;
|
48
|
+
}
|
49
|
+
const [_, workflowId, transactionId] = key.split(":");
|
50
|
+
const trx = await this.workflowExecutionService_
|
51
|
+
.retrieve({
|
52
|
+
workflow_id: workflowId,
|
53
|
+
transaction_id: transactionId,
|
54
|
+
}, {
|
55
|
+
select: ["execution", "context"],
|
56
|
+
})
|
57
|
+
.catch(() => undefined);
|
58
|
+
if (trx) {
|
59
|
+
return {
|
60
|
+
flow: trx.execution,
|
61
|
+
context: trx.context.data,
|
62
|
+
errors: trx.context.errors,
|
63
|
+
};
|
64
|
+
}
|
65
|
+
return;
|
57
66
|
}
|
58
67
|
async list() {
|
59
68
|
return Array.from(this.storage.values());
|
60
69
|
}
|
61
|
-
async save(key, data, ttl) {
|
70
|
+
async save(key, data, ttl, options) {
|
62
71
|
this.storage.set(key, data);
|
63
|
-
let retentionTime;
|
64
72
|
/**
|
65
73
|
* Store the retention time only if the transaction is done, failed or reverted.
|
66
74
|
* From that moment, this tuple can be later on archived or deleted after the retention time.
|
@@ -70,15 +78,15 @@ class InMemoryDistributedTransactionStorage extends orchestration_1.DistributedT
|
|
70
78
|
utils_1.TransactionState.FAILED,
|
71
79
|
utils_1.TransactionState.REVERTED,
|
72
80
|
].includes(data.flow.state);
|
81
|
+
const { retentionTime, idempotent } = options ?? {};
|
73
82
|
if (hasFinished) {
|
74
|
-
retentionTime = data.flow.options?.retentionTime;
|
75
83
|
Object.assign(data, {
|
76
84
|
retention_time: retentionTime,
|
77
85
|
});
|
78
86
|
}
|
79
87
|
const stringifiedData = JSON.stringify(data);
|
80
88
|
const parsedData = JSON.parse(stringifiedData);
|
81
|
-
if (hasFinished && !retentionTime) {
|
89
|
+
if (hasFinished && !retentionTime && !idempotent) {
|
82
90
|
await this.deleteFromDb(parsedData);
|
83
91
|
}
|
84
92
|
else {
|
@@ -93,6 +101,7 @@ class InMemoryDistributedTransactionStorage extends orchestration_1.DistributedT
|
|
93
101
|
const inter = setTimeout(async () => {
|
94
102
|
await this.workflowOrchestratorService_.run(workflowId, {
|
95
103
|
transactionId,
|
104
|
+
logOnError: true,
|
96
105
|
throwOnError: false,
|
97
106
|
});
|
98
107
|
}, interval * 1e3);
|
@@ -148,5 +157,73 @@ class InMemoryDistributedTransactionStorage extends orchestration_1.DistributedT
|
|
148
157
|
this.timeouts.delete(key);
|
149
158
|
}
|
150
159
|
}
|
160
|
+
/* Scheduler storage methods */
|
161
|
+
async schedule(jobDefinition, schedulerOptions) {
|
162
|
+
const jobId = typeof jobDefinition === "string" ? jobDefinition : jobDefinition.jobId;
|
163
|
+
// In order to ensure that the schedule configuration is always up to date, we first cancel an existing job, if there was one
|
164
|
+
// any only then we add the new one.
|
165
|
+
await this.remove(jobId);
|
166
|
+
const expression = (0, cron_parser_1.parseExpression)(schedulerOptions.cron);
|
167
|
+
const nextExecution = expression.next().getTime() - Date.now();
|
168
|
+
const timer = setTimeout(async () => {
|
169
|
+
this.jobHandler(jobId);
|
170
|
+
}, nextExecution);
|
171
|
+
this.scheduled.set(jobId, {
|
172
|
+
timer,
|
173
|
+
expression,
|
174
|
+
numberOfExecutions: 0,
|
175
|
+
config: schedulerOptions,
|
176
|
+
});
|
177
|
+
}
|
178
|
+
async remove(jobId) {
|
179
|
+
const job = this.scheduled.get(jobId);
|
180
|
+
if (!job) {
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
clearTimeout(job.timer);
|
184
|
+
this.scheduled.delete(jobId);
|
185
|
+
}
|
186
|
+
async removeAll() {
|
187
|
+
for (const [key] of this.scheduled) {
|
188
|
+
await this.remove(key);
|
189
|
+
}
|
190
|
+
}
|
191
|
+
async jobHandler(jobId) {
|
192
|
+
const job = this.scheduled.get(jobId);
|
193
|
+
if (!job) {
|
194
|
+
return;
|
195
|
+
}
|
196
|
+
if (job.config?.numberOfExecutions !== undefined &&
|
197
|
+
job.config.numberOfExecutions <= job.numberOfExecutions) {
|
198
|
+
this.scheduled.delete(jobId);
|
199
|
+
return;
|
200
|
+
}
|
201
|
+
const nextExecution = job.expression.next().getTime() - Date.now();
|
202
|
+
const timer = setTimeout(async () => {
|
203
|
+
this.jobHandler(jobId);
|
204
|
+
}, nextExecution);
|
205
|
+
this.scheduled.set(jobId, {
|
206
|
+
timer,
|
207
|
+
expression: job.expression,
|
208
|
+
numberOfExecutions: (job.numberOfExecutions ?? 0) + 1,
|
209
|
+
config: job.config,
|
210
|
+
});
|
211
|
+
try {
|
212
|
+
// With running the job after setting a new timer we basically allow for concurrent runs, unless we add idempotency keys once they are supported.
|
213
|
+
await this.workflowOrchestratorService_.run(jobId, {
|
214
|
+
logOnError: true,
|
215
|
+
throwOnError: false,
|
216
|
+
});
|
217
|
+
}
|
218
|
+
catch (e) {
|
219
|
+
if (e instanceof utils_1.MedusaError && e.type === utils_1.MedusaError.Types.NOT_FOUND) {
|
220
|
+
this.logger_?.warn(`Tried to execute a scheduled workflow with ID ${jobId} that does not exist, removing it from the scheduler.`);
|
221
|
+
await this.remove(jobId);
|
222
|
+
return;
|
223
|
+
}
|
224
|
+
throw e;
|
225
|
+
}
|
226
|
+
}
|
151
227
|
}
|
152
228
|
exports.InMemoryDistributedTransactionStorage = InMemoryDistributedTransactionStorage;
|
229
|
+
//# sourceMappingURL=workflow-orchestrator-storage.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"workflow-orchestrator-storage.js","sourceRoot":"","sources":["../../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ACF;AAvUD,sFAuUC"}
|
package/package.json
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/workflow-engine-inmemory",
|
3
|
-
"version": "0.0
|
3
|
+
"version": "1.0.0-rc-20241001083650",
|
4
4
|
"description": "Medusa Workflow Orchestrator module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
7
7
|
"files": [
|
8
|
-
"dist"
|
8
|
+
"dist",
|
9
|
+
"!dist/**/__tests__",
|
10
|
+
"!dist/**/__mocks__",
|
11
|
+
"!dist/**/__fixtures__"
|
9
12
|
],
|
10
13
|
"engines": {
|
11
|
-
"node": ">=
|
14
|
+
"node": ">=20"
|
12
15
|
},
|
13
16
|
"repository": {
|
14
17
|
"type": "git",
|
@@ -23,10 +26,10 @@
|
|
23
26
|
"scripts": {
|
24
27
|
"watch": "tsc --build --watch",
|
25
28
|
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
26
|
-
"
|
27
|
-
"build": "rimraf dist && tsc --build &&
|
29
|
+
"resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json",
|
30
|
+
"build": "rimraf dist && tsc --build && npm run resolve:aliases",
|
28
31
|
"test": "jest --passWithNoTests --runInBand --bail --forceExit -- src",
|
29
|
-
"test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
32
|
+
"test:integration": "jest --silent --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
30
33
|
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
31
34
|
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
|
32
35
|
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
|
@@ -34,26 +37,28 @@
|
|
34
37
|
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
35
38
|
},
|
36
39
|
"devDependencies": {
|
40
|
+
"@medusajs/framework": "1.0.0-rc-20241001083650",
|
37
41
|
"@mikro-orm/cli": "5.9.7",
|
38
|
-
"
|
39
|
-
"
|
40
|
-
"
|
42
|
+
"@mikro-orm/core": "5.9.7",
|
43
|
+
"@mikro-orm/migrations": "5.9.7",
|
44
|
+
"@mikro-orm/postgresql": "5.9.7",
|
45
|
+
"@swc/core": "^1.7.28",
|
46
|
+
"@swc/jest": "^0.2.36",
|
47
|
+
"jest": "^29.7.0",
|
48
|
+
"medusa-test-utils": "2.0.0-rc-20241001083650",
|
41
49
|
"rimraf": "^3.0.2",
|
42
|
-
"ts-jest": "^29.1.1",
|
43
|
-
"ts-node": "^10.9.1",
|
44
50
|
"tsc-alias": "^1.8.6",
|
45
|
-
"typescript": "^5.
|
51
|
+
"typescript": "^5.6.2"
|
46
52
|
},
|
47
53
|
"dependencies": {
|
48
|
-
"
|
49
|
-
"
|
50
|
-
|
51
|
-
|
54
|
+
"cron-parser": "^4.9.0",
|
55
|
+
"ulid": "^2.3.0"
|
56
|
+
},
|
57
|
+
"peerDependencies": {
|
58
|
+
"@medusajs/framework": "1.0.0-rc-20241001083650",
|
52
59
|
"@mikro-orm/core": "5.9.7",
|
53
60
|
"@mikro-orm/migrations": "5.9.7",
|
54
61
|
"@mikro-orm/postgresql": "5.9.7",
|
55
|
-
"awilix": "^8.0.
|
56
|
-
"dotenv": "^16.4.5",
|
57
|
-
"knex": "2.4.2"
|
62
|
+
"awilix": "^8.0.1"
|
58
63
|
}
|
59
64
|
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
|
2
|
-
import { ModulesSdkTypes } from "@medusajs/types";
|
3
|
-
import { IWorkflowEngineService } from "@medusajs/workflows-sdk";
|
4
|
-
import { InitializeModuleInjectableDependencies } from "../types";
|
5
|
-
export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<IWorkflowEngineService>;
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +0,0 @@
|
|
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,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,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,sBAAsB,CAchC,CAAA"}
|
package/dist/initialize/index.js
DELETED
@@ -1,18 +0,0 @@
|
|
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;
|
package/dist/joiner-config.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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"}
|
package/dist/joiner-config.js
DELETED
@@ -1,34 +0,0 @@
|
|
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
|
-
};
|
@@ -1,5 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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"}
|