@etohq/workflow-engine-inmemory 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 (59) 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 +2 -0
  7. package/dist/loaders/index.d.ts.map +1 -0
  8. package/dist/loaders/index.js +9 -0
  9. package/dist/loaders/index.js.map +1 -0
  10. package/dist/loaders/utils.d.ts +5 -0
  11. package/dist/loaders/utils.d.ts.map +1 -0
  12. package/dist/loaders/utils.js +10 -0
  13. package/dist/loaders/utils.js.map +1 -0
  14. package/dist/migrations/Migration20231228143900.d.ts +6 -0
  15. package/dist/migrations/Migration20231228143900.d.ts.map +1 -0
  16. package/dist/migrations/Migration20231228143900.js +40 -0
  17. package/dist/migrations/Migration20231228143900.js.map +1 -0
  18. package/dist/migrations/Migration20241206101446.d.ts +5 -0
  19. package/dist/migrations/Migration20241206101446.d.ts.map +1 -0
  20. package/dist/migrations/Migration20241206101446.js +19 -0
  21. package/dist/migrations/Migration20241206101446.js.map +1 -0
  22. package/dist/models/index.d.ts +2 -0
  23. package/dist/models/index.d.ts.map +1 -0
  24. package/dist/models/index.js +6 -0
  25. package/dist/models/index.js.map +1 -0
  26. package/dist/models/workflow-execution.d.ts +10 -0
  27. package/dist/models/workflow-execution.d.ts.map +1 -0
  28. package/dist/models/workflow-execution.js +33 -0
  29. package/dist/models/workflow-execution.js.map +1 -0
  30. package/dist/schema/index.d.ts +3 -0
  31. package/dist/schema/index.d.ts.map +1 -0
  32. package/dist/schema/index.js +26 -0
  33. package/dist/schema/index.js.map +1 -0
  34. package/dist/services/index.d.ts +3 -0
  35. package/dist/services/index.d.ts.map +1 -0
  36. package/dist/services/index.js +19 -0
  37. package/dist/services/index.js.map +1 -0
  38. package/dist/services/workflow-orchestrator.d.ts +69 -0
  39. package/dist/services/workflow-orchestrator.d.ts.map +1 -0
  40. package/dist/services/workflow-orchestrator.js +423 -0
  41. package/dist/services/workflow-orchestrator.js.map +1 -0
  42. package/dist/services/workflows-module.d.ts +48 -0
  43. package/dist/services/workflows-module.d.ts.map +1 -0
  44. package/dist/services/workflows-module.js +100 -0
  45. package/dist/services/workflows-module.js.map +1 -0
  46. package/dist/tsconfig.tsbuildinfo +1 -0
  47. package/dist/types/index.d.ts +5 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/index.js +3 -0
  50. package/dist/types/index.js.map +1 -0
  51. package/dist/utils/index.d.ts +2 -0
  52. package/dist/utils/index.d.ts.map +1 -0
  53. package/dist/utils/index.js +18 -0
  54. package/dist/utils/index.js.map +1 -0
  55. package/dist/utils/workflow-orchestrator-storage.d.ts +34 -0
  56. package/dist/utils/workflow-orchestrator-storage.d.ts.map +1 -0
  57. package/dist/utils/workflow-orchestrator-storage.js +227 -0
  58. package/dist/utils/workflow-orchestrator-storage.js.map +1 -0
  59. package/package.json +64 -0
@@ -0,0 +1,18 @@
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-storage"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kEAA+C"}
@@ -0,0 +1,34 @@
1
+ import { DistributedTransactionType, IDistributedSchedulerStorage, IDistributedTransactionStorage, SchedulerOptions, TransactionCheckpoint, TransactionOptions, TransactionStep } from "@etohq/framework/orchestration";
2
+ import { Logger, ModulesSdkTypes } from "@etohq/framework/types";
3
+ export declare class InMemoryDistributedTransactionStorage implements IDistributedTransactionStorage, IDistributedSchedulerStorage {
4
+ private workflowExecutionService_;
5
+ private logger_;
6
+ private workflowOrchestratorService_;
7
+ private storage;
8
+ private scheduled;
9
+ private retries;
10
+ private timeouts;
11
+ constructor({ workflowExecutionService, logger, }: {
12
+ workflowExecutionService: ModulesSdkTypes.IEtoInternalService<any>;
13
+ logger: Logger;
14
+ });
15
+ setWorkflowOrchestratorService(workflowOrchestratorService: any): void;
16
+ private saveToDb;
17
+ private deleteFromDb;
18
+ get(key: string, options?: TransactionOptions): Promise<TransactionCheckpoint | undefined>;
19
+ list(): Promise<TransactionCheckpoint[]>;
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>;
33
+ }
34
+ //# sourceMappingURL=workflow-orchestrator-storage.d.ts.map
@@ -0,0 +1 @@
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,eAAe,EAChB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKhE,qBAAa,qCACX,YAAW,8BAA8B,EAAE,4BAA4B;IAEvE,OAAO,CAAC,yBAAyB,CAA0C;IAC3E,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,4BAA4B,CAA6B;IAEjE,OAAO,CAAC,OAAO,CAAgD;IAC/D,OAAO,CAAC,SAAS,CAQJ;IACb,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,QAAQ,CAAkC;gBAEtC,EACV,wBAAwB,EACxB,MAAM,GACP,EAAE;QACD,wBAAwB,EAAE,eAAe,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;QAClE,MAAM,EAAE,MAAM,CAAA;KACf;IAKD,8BAA8B,CAAC,2BAA2B,KAAA;YAI5C,QAAQ;YAeR,YAAY;IASpB,GAAG,CACP,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAoCvC,IAAI,IAAI,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAIxC,IAAI,CACR,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,qBAAqB,EAC3B,GAAG,CAAC,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,IAAI,CAAC;IAgCV,aAAa,CACjB,WAAW,EAAE,0BAA0B,EACvC,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAeV,UAAU,CACd,WAAW,EAAE,0BAA0B,EACvC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC;IAWV,0BAA0B,CAC9B,WAAW,EAAE,0BAA0B,EACvC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,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"}
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InMemoryDistributedTransactionStorage = void 0;
4
+ const utils_1 = require("@etohq/framework/utils");
5
+ const cron_parser_1 = require("cron-parser");
6
+ class InMemoryDistributedTransactionStorage {
7
+ constructor({ workflowExecutionService, logger, }) {
8
+ this.storage = new Map();
9
+ this.scheduled = new Map();
10
+ this.retries = new Map();
11
+ this.timeouts = new Map();
12
+ this.workflowExecutionService_ = workflowExecutionService;
13
+ this.logger_ = logger;
14
+ }
15
+ setWorkflowOrchestratorService(workflowOrchestratorService) {
16
+ this.workflowOrchestratorService_ = workflowOrchestratorService;
17
+ }
18
+ async saveToDb(data) {
19
+ await this.workflowExecutionService_.upsert([
20
+ {
21
+ workflow_id: data.flow.modelId,
22
+ transaction_id: data.flow.transactionId,
23
+ execution: data.flow,
24
+ context: {
25
+ data: data.context,
26
+ errors: data.errors,
27
+ },
28
+ state: data.flow.state,
29
+ },
30
+ ]);
31
+ }
32
+ async deleteFromDb(data) {
33
+ await this.workflowExecutionService_.delete([
34
+ {
35
+ workflow_id: data.flow.modelId,
36
+ transaction_id: data.flow.transactionId,
37
+ },
38
+ ]);
39
+ }
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;
66
+ }
67
+ async list() {
68
+ return Array.from(this.storage.values());
69
+ }
70
+ async save(key, data, ttl, options) {
71
+ this.storage.set(key, data);
72
+ /**
73
+ * Store the retention time only if the transaction is done, failed or reverted.
74
+ * From that moment, this tuple can be later on archived or deleted after the retention time.
75
+ */
76
+ const hasFinished = [
77
+ utils_1.TransactionState.DONE,
78
+ utils_1.TransactionState.FAILED,
79
+ utils_1.TransactionState.REVERTED,
80
+ ].includes(data.flow.state);
81
+ const { retentionTime, idempotent } = options ?? {};
82
+ if (hasFinished) {
83
+ Object.assign(data, {
84
+ retention_time: retentionTime,
85
+ });
86
+ }
87
+ if (hasFinished && !retentionTime && !idempotent) {
88
+ await this.deleteFromDb(data);
89
+ }
90
+ else {
91
+ await this.saveToDb(data);
92
+ }
93
+ if (hasFinished) {
94
+ this.storage.delete(key);
95
+ }
96
+ }
97
+ async scheduleRetry(transaction, step, timestamp, interval) {
98
+ const { modelId: workflowId, transactionId } = transaction;
99
+ const inter = setTimeout(async () => {
100
+ await this.workflowOrchestratorService_.run(workflowId, {
101
+ transactionId,
102
+ logOnError: true,
103
+ throwOnError: false,
104
+ });
105
+ }, interval * 1e3);
106
+ const key = `${workflowId}:${transactionId}:${step.id}`;
107
+ this.retries.set(key, inter);
108
+ }
109
+ async clearRetry(transaction, step) {
110
+ const { modelId: workflowId, transactionId } = transaction;
111
+ const key = `${workflowId}:${transactionId}:${step.id}`;
112
+ const inter = this.retries.get(key);
113
+ if (inter) {
114
+ clearTimeout(inter);
115
+ this.retries.delete(key);
116
+ }
117
+ }
118
+ async scheduleTransactionTimeout(transaction, timestamp, interval) {
119
+ const { modelId: workflowId, transactionId } = transaction;
120
+ const inter = setTimeout(async () => {
121
+ await this.workflowOrchestratorService_.run(workflowId, {
122
+ transactionId,
123
+ throwOnError: false,
124
+ });
125
+ }, interval * 1e3);
126
+ const key = `${workflowId}:${transactionId}`;
127
+ this.timeouts.set(key, inter);
128
+ }
129
+ async clearTransactionTimeout(transaction) {
130
+ const { modelId: workflowId, transactionId } = transaction;
131
+ const key = `${workflowId}:${transactionId}`;
132
+ const inter = this.timeouts.get(key);
133
+ if (inter) {
134
+ clearTimeout(inter);
135
+ this.timeouts.delete(key);
136
+ }
137
+ }
138
+ async scheduleStepTimeout(transaction, step, timestamp, interval) {
139
+ const { modelId: workflowId, transactionId } = transaction;
140
+ const inter = setTimeout(async () => {
141
+ await this.workflowOrchestratorService_.run(workflowId, {
142
+ transactionId,
143
+ throwOnError: false,
144
+ });
145
+ }, interval * 1e3);
146
+ const key = `${workflowId}:${transactionId}:${step.id}`;
147
+ this.timeouts.set(key, inter);
148
+ }
149
+ async clearStepTimeout(transaction, step) {
150
+ const { modelId: workflowId, transactionId } = transaction;
151
+ const key = `${workflowId}:${transactionId}:${step.id}`;
152
+ const inter = this.timeouts.get(key);
153
+ if (inter) {
154
+ clearTimeout(inter);
155
+ this.timeouts.delete(key);
156
+ }
157
+ }
158
+ /* Scheduler storage methods */
159
+ async schedule(jobDefinition, schedulerOptions) {
160
+ const jobId = typeof jobDefinition === "string" ? jobDefinition : jobDefinition.jobId;
161
+ // In order to ensure that the schedule configuration is always up to date, we first cancel an existing job, if there was one
162
+ // any only then we add the new one.
163
+ await this.remove(jobId);
164
+ const expression = (0, cron_parser_1.parseExpression)(schedulerOptions.cron);
165
+ const nextExecution = expression.next().getTime() - Date.now();
166
+ const timer = setTimeout(async () => {
167
+ this.jobHandler(jobId);
168
+ }, nextExecution);
169
+ this.scheduled.set(jobId, {
170
+ timer,
171
+ expression,
172
+ numberOfExecutions: 0,
173
+ config: schedulerOptions,
174
+ });
175
+ }
176
+ async remove(jobId) {
177
+ const job = this.scheduled.get(jobId);
178
+ if (!job) {
179
+ return;
180
+ }
181
+ clearTimeout(job.timer);
182
+ this.scheduled.delete(jobId);
183
+ }
184
+ async removeAll() {
185
+ for (const [key] of this.scheduled) {
186
+ await this.remove(key);
187
+ }
188
+ }
189
+ async jobHandler(jobId) {
190
+ const job = this.scheduled.get(jobId);
191
+ if (!job) {
192
+ return;
193
+ }
194
+ if (job.config?.numberOfExecutions !== undefined &&
195
+ job.config.numberOfExecutions <= job.numberOfExecutions) {
196
+ this.scheduled.delete(jobId);
197
+ return;
198
+ }
199
+ const nextExecution = job.expression.next().getTime() - Date.now();
200
+ const timer = setTimeout(async () => {
201
+ this.jobHandler(jobId);
202
+ }, nextExecution);
203
+ this.scheduled.set(jobId, {
204
+ timer,
205
+ expression: job.expression,
206
+ numberOfExecutions: (job.numberOfExecutions ?? 0) + 1,
207
+ config: job.config,
208
+ });
209
+ try {
210
+ // With running the job after setting a new timer we basically allow for concurrent runs, unless we add idempotency keys once they are supported.
211
+ await this.workflowOrchestratorService_.run(jobId, {
212
+ logOnError: true,
213
+ throwOnError: false,
214
+ });
215
+ }
216
+ catch (e) {
217
+ if (e instanceof utils_1.EtoError && e.type === utils_1.EtoError.Types.NOT_FOUND) {
218
+ this.logger_?.warn(`Tried to execute a scheduled workflow with ID ${jobId} that does not exist, removing it from the scheduler.`);
219
+ await this.remove(jobId);
220
+ return;
221
+ }
222
+ throw e;
223
+ }
224
+ }
225
+ }
226
+ exports.InMemoryDistributedTransactionStorage = InMemoryDistributedTransactionStorage;
227
+ //# sourceMappingURL=workflow-orchestrator-storage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-orchestrator-storage.js","sourceRoot":"","sources":["../../src/utils/workflow-orchestrator-storage.ts"],"names":[],"mappings":";;;AAUA,kDAAmE;AAEnE,6CAA6D;AAE7D,MAAa,qCAAqC;IAoBhD,YAAY,EACV,wBAAwB,EACxB,MAAM,GAIP;QAnBO,YAAO,GAAuC,IAAI,GAAG,EAAE,CAAA;QACvD,cAAS,GAQb,IAAI,GAAG,EAAE,CAAA;QACL,YAAO,GAAyB,IAAI,GAAG,EAAE,CAAA;QACzC,aAAQ,GAAyB,IAAI,GAAG,EAAE,CAAA;QAShD,IAAI,CAAC,yBAAyB,GAAG,wBAAwB,CAAA;QACzD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;IACvB,CAAC;IAED,8BAA8B,CAAC,2BAA2B;QACxD,IAAI,CAAC,4BAA4B,GAAG,2BAA2B,CAAA;IACjE,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,IAA2B;QAChD,MAAM,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC;YAC1C;gBACE,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO;gBAC9B,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,aAAa;gBACvC,SAAS,EAAE,IAAI,CAAC,IAAI;gBACpB,OAAO,EAAE;oBACP,IAAI,EAAE,IAAI,CAAC,OAAO;oBAClB,MAAM,EAAE,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C,YAAY,gBAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,gBAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;gBACjE,IAAI,CAAC,OAAO,EAAE,IAAI,CAChB,iDAAiD,KAAK,uDAAuD,CAC9G,CAAA;gBAED,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gBACxB,OAAM;YACR,CAAC;YAED,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;CACF;AApUD,sFAoUC"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@etohq/workflow-engine-inmemory",
3
+ "version": "1.0.0",
4
+ "description": "Eto Workflow Orchestrator module",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "!dist/**/__tests__",
10
+ "!dist/**/__mocks__",
11
+ "!dist/**/__fixtures__"
12
+ ],
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/etohq/eto",
19
+ "directory": "packages/workflow-engine-inmemory"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "author": "Eto",
25
+ "license": "MIT",
26
+ "scripts": {
27
+ "watch": "tsc --build --watch",
28
+ "watch:test": "tsc --build tsconfig.spec.json --watch",
29
+ "resolve:aliases": "tsc --showConfig -p tsconfig.json > tsconfig.resolved.json && tsc-alias -p tsconfig.resolved.json && rimraf tsconfig.resolved.json", "build": "rimraf dist && tsc --build && npm run resolve:aliases",
30
+ "test": "jest --passWithNoTests --runInBand --bail --forceExit -- src",
31
+ "test:integration": "jest --silent --forceExit -- integration-tests/**/__tests__/**/*.ts",
32
+ "migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create --initial",
33
+ "migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:create",
34
+ "migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm migration:up",
35
+ "orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts eto-mikro-orm cache:clear"
36
+ },
37
+ "devDependencies": {
38
+ "@etohq/framework": "^1.0.0",
39
+ "@etohq/test-utils": "^1.0.0",
40
+ "@mikro-orm/cli": "5.9.7",
41
+ "@mikro-orm/core": "5.9.7",
42
+ "@mikro-orm/migrations": "5.9.7",
43
+ "@mikro-orm/postgresql": "5.9.7",
44
+ "@swc/core": "^1.7.28",
45
+ "@swc/jest": "^0.2.36",
46
+ "@types/jest": "^29.5.14",
47
+ "awilix": "^8.0.1",
48
+ "jest": "^29.7.0",
49
+ "rimraf": "^5.0.2",
50
+ "tsc-alias": "^1.8.6",
51
+ "typescript": "^5.6.2"
52
+ },
53
+ "dependencies": {
54
+ "cron-parser": "^4.9.0",
55
+ "ulid": "^2.3.0"
56
+ },
57
+ "peerDependencies": {
58
+ "@etohq/framework": "^1.0.0",
59
+ "@mikro-orm/core": "5.9.7",
60
+ "@mikro-orm/migrations": "5.9.7",
61
+ "@mikro-orm/postgresql": "5.9.7",
62
+ "awilix": "^8.0.1"
63
+ }
64
+ }