@medusajs/workflow-engine-redis 0.0.2 → 0.0.3-next-20240221072935

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.
@@ -1,6 +1,6 @@
1
1
  import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
2
2
  import { ModulesSdkTypes } from "@medusajs/types";
3
- import { WorkflowOrchestratorTypes } from "@medusajs/workflows-sdk";
3
+ import { IWorkflowEngineService } from "@medusajs/workflows-sdk";
4
4
  import { InitializeModuleInjectableDependencies } from "../types";
5
- export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<WorkflowOrchestratorTypes.IWorkflowsModuleService>;
5
+ export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<IWorkflowEngineService>;
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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;AAE9B,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"}
@@ -1,34 +1,7 @@
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
- };
1
+ import { DALUtils } from "@medusajs/utils";
2
+ declare const WorkflowExecutionRepository_base: new ({ manager }: {
3
+ manager: any;
4
+ }) => DALUtils.MikroOrmBaseRepository<object>;
32
5
  export declare class WorkflowExecutionRepository extends WorkflowExecutionRepository_base {
33
6
  }
34
7
  export {};
@@ -1 +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"}
1
+ {"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../src/repositories/workflow-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;;;;AAI1C,qBAAa,2BAA4B,SAAQ,gCAEhD;CAAG"}
@@ -1,4 +1,3 @@
1
- export * from "./workflow-execution";
2
1
  export * from "./workflow-orchestrator";
3
2
  export * from "./workflows-module";
4
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA;AACvC,cAAc,oBAAoB,CAAA"}
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./workflow-execution"), exports);
18
17
  __exportStar(require("./workflow-orchestrator"), exports);
19
18
  __exportStar(require("./workflows-module"), exports);
@@ -1,18 +1,22 @@
1
- import { Context, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig } from "@medusajs/types";
2
- import type { ReturnWorkflow, UnwrapWorkflowInputDataType, WorkflowOrchestratorTypes } from "@medusajs/workflows-sdk";
3
- import { WorkflowExecutionService, WorkflowOrchestratorService } from ".";
1
+ import { Context, DAL, FindConfig, InternalModuleDeclaration, ModuleJoinerConfig, ModulesSdkTypes } from "@medusajs/types";
2
+ import type { IWorkflowEngineService, ReturnWorkflow, UnwrapWorkflowInputDataType, WorkflowOrchestratorTypes } from "@medusajs/workflows-sdk";
3
+ import { WorkflowOrchestratorService } from ".";
4
4
  type InjectedDependencies = {
5
5
  baseRepository: DAL.RepositoryService;
6
- workflowExecutionService: WorkflowExecutionService;
6
+ workflowExecutionService: ModulesSdkTypes.InternalModuleService<any>;
7
7
  workflowOrchestratorService: WorkflowOrchestratorService;
8
8
  };
9
- export declare class WorkflowsModuleService implements WorkflowOrchestratorTypes.IWorkflowsModuleService {
9
+ export declare class WorkflowsModuleService implements IWorkflowEngineService {
10
10
  protected readonly moduleDeclaration: InternalModuleDeclaration;
11
11
  protected baseRepository_: DAL.RepositoryService;
12
- protected workflowExecutionService_: WorkflowExecutionService;
12
+ protected workflowExecutionService_: ModulesSdkTypes.InternalModuleService<any>;
13
13
  protected workflowOrchestratorService_: WorkflowOrchestratorService;
14
14
  constructor({ baseRepository, workflowExecutionService, workflowOrchestratorService, }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
15
15
  __joinerConfig(): ModuleJoinerConfig;
16
+ retrieveWorkflowExecution(idOrObject: string | {
17
+ workflow_id: string;
18
+ transaction_id: string;
19
+ }, config?: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO>, sharedContext?: Context): Promise<WorkflowOrchestratorTypes.WorkflowExecutionDTO>;
16
20
  listWorkflowExecution(filters?: WorkflowOrchestratorTypes.FilterableWorkflowExecutionProps, config?: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO>, sharedContext?: Context): Promise<WorkflowOrchestratorTypes.WorkflowExecutionDTO[]>;
17
21
  listAndCountWorkflowExecution(filters?: WorkflowOrchestratorTypes.FilterableWorkflowExecutionProps, config?: FindConfig<WorkflowOrchestratorTypes.WorkflowExecutionDTO>, sharedContext?: Context): Promise<[WorkflowOrchestratorTypes.WorkflowExecutionDTO[], number]>;
18
22
  run<TWorkflow extends string | ReturnWorkflow<any, any, any>>(workflowIdOrWorkflow: TWorkflow, options?: WorkflowOrchestratorTypes.WorkflowOrchestratorRunDTO<TWorkflow extends ReturnWorkflow<any, any, any> ? UnwrapWorkflowInputDataType<TWorkflow> : unknown>, context?: Context): Promise<any>;
@@ -1 +1 @@
1
- {"version":3,"file":"workflows-module.d.ts","sourceRoot":"","sources":["../../src/services/workflows-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,UAAU,EACV,yBAAyB,EACzB,kBAAkB,EACnB,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AAS,EAC/B,OAAO,GAAE,yBAAyB,CAAC,0BAA0B,CAC3D,SAAS,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAC3C,2BAA2B,CAAC,SAAS,CAAC,GACtC,OAAO,CACP,EACW,OAAO,GAAE,OAAY;IAYlC,qBAAqB,CACzB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACJ,OAAO,GAAE,OAAY;IAUlC,cAAc,CAClB,EACE,cAAc,EACd,YAAY,EACZ,OAAO,GACR,EAAE;QACD,cAAc,EAAE,MAAM,GAAG,MAAM,CAAA;QAC/B,YAAY,EAAE,OAAO,CAAA;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAC9B,EACgB,OAAO,GAAE,OAAY;IAalC,cAAc,CAClB,EACE,cAAc,EACd,YAAY,EACZ,OAAO,GACR,EAAE;QACD,cAAc,EAAE,MAAM,GAAG,MAAM,CAAA;QAC/B,YAAY,EAAE,OAAO,CAAA;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAC9B,EACgB,OAAO,GAAE,OAAY;IAalC,SAAS,CACb,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAA;QAClB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,UAAU,EAAE,QAAQ,CAAA;QACpB,YAAY,CAAC,EAAE,MAAM,CAAA;KACtB,EACgB,OAAO,GAAE,OAAY;IAMlC,WAAW,CACf,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAA;QAClB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,cAAc,EAAE,MAAM,GAAG,QAAQ,CAAA;KAClC,EACgB,OAAO,GAAE,OAAY;CAIzC"}
1
+ {"version":3,"file":"workflows-module.d.ts","sourceRoot":"","sources":["../../src/services/workflows-module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,GAAG,EACH,UA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AAM,CAAA;KACtB,EACgB,OAAO,GAAE,OAAY;IAMlC,WAAW,CACf,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAA;QAClB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,cAAc,EAAE,MAAM,GAAG,QAAQ,CAAA;KAClC,EACgB,OAAO,GAAE,OAAY;CAIzC"}
@@ -26,13 +26,57 @@ class WorkflowsModuleService {
26
26
  __joinerConfig() {
27
27
  return joiner_config_1.joinerConfig;
28
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
+ }
29
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
+ }
30
60
  const wfExecutions = await this.workflowExecutionService_.list(filters, config, sharedContext);
31
- return this.baseRepository_.serialize(wfExecutions, {
61
+ return await this.baseRepository_.serialize(wfExecutions, {
32
62
  populate: true,
33
63
  });
34
64
  }
35
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
+ }
36
80
  const [wfExecutions, count] = await this.workflowExecutionService_.listAndCount(filters, config, sharedContext);
37
81
  return [
38
82
  await this.baseRepository_.serialize(wfExecutions, {
@@ -70,6 +114,13 @@ class WorkflowsModuleService {
70
114
  }
71
115
  }
72
116
  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);
73
124
  __decorate([
74
125
  (0, utils_1.InjectManager)("baseRepository_"),
75
126
  __param(2, (0, utils_1.MedusaContext)()),
@@ -1,5 +1,5 @@
1
1
  import { DistributedTransaction, DistributedTransactionStorage, TransactionCheckpoint, TransactionStep } from "@medusajs/orchestration";
2
- import { WorkflowExecutionService } from "../services";
2
+ import { ModulesSdkTypes } from "@medusajs/types";
3
3
  import Redis from "ioredis";
4
4
  export declare class RedisDistributedTransactionStorage extends DistributedTransactionStorage {
5
5
  private static TTL_AFTER_COMPLETED;
@@ -9,7 +9,7 @@ export declare class RedisDistributedTransactionStorage extends DistributedTrans
9
9
  private queue;
10
10
  private worker;
11
11
  constructor({ workflowExecutionService, redisConnection, redisWorkerConnection, redisQueueName, }: {
12
- workflowExecutionService: WorkflowExecutionService;
12
+ workflowExecutionService: ModulesSdkTypes.InternalModuleService<any>;
13
13
  redisConnection: Redis;
14
14
  redisWorkerConnection: Redis;
15
15
  redisQueueName: string;
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-orchestrator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V,UAAU,CACd,WAAW,EAAE,sBAAsB,EACnC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC;IAIV,0BAA0B,CAC9B,WAAW,EAAE,sBAAsB,EACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAeV,uBAAuB,CAC3B,WAAW,EAAE,sBAAsB,GAClC,OAAO,CAAC,IAAI,CAAC;IAIV,mBAAmB,CACvB,WAAW,EAAE,sBAAsB,EACnC,IAAI,EAAE,eAAe,EACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAgBV,gBAAgB,CACpB,WAAW,EAAE,sBAAsB,EACnC,IAAI,EAAE,eAAe,GACpB,OAAO,CAAC,IAAI,CAAC;IAIhB,OAAO,CAAC,QAAQ;YAcF,SAAS;CAYxB"}
1
+ {"version":3,"file":"workflow-orchestrator-storage.d.ts","sourceRoot":"","sources":["../../src/utils/workflow-orchestrator-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,qBAAqB,EACrB,eAAe,EAChB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAIjD,OAAO,KAAK,MAAM,SAAS,CAAA;AAS3B,qBAAa,kCAAmC,SAAQ,6BAA6B;IACnF,OAAO,CAAC,MAAM,CAAC,mBAAmB,CAAU;IAC5C,OAAO,CAAC,yBAAyB,CAA4C;IAC7E,OAAO,CAAC,4BAA4B,CAA6B;IAEjE,OAAO,CAAC,WAAW,CAAO;IAC1B,OAAO,CAAC,KAAK,CAAO;IACpB,OAAO,CAAC,MAAM,CAAQ;gBAEV,EACV,wBAAwB,EACxB,eAAe,EACf,qBAAqB,EACrB,cAAc,GACf,EAAE;QACD,wBAAwB,EAAE,eAAe,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAA;QACpE,e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ends orchestration_1.DistributedTran
103
103
  retention_time: retentionTime,
104
104
  });
105
105
  }
106
+ const stringifiedData = JSON.stringify(data, this.stringifyWithSymbol);
107
+ const parsedData = JSON.parse(stringifiedData);
106
108
  if (!hasFinished) {
107
109
  if (ttl) {
108
- await this.redisClient.set(key, JSON.stringify(data, this.stringifyWithSymbol), "EX", ttl);
110
+ await this.redisClient.set(key, stringifiedData, "EX", ttl);
109
111
  }
110
112
  else {
111
- await this.redisClient.set(key, JSON.stringify(data, this.stringifyWithSymbol));
113
+ await this.redisClient.set(key, stringifiedData);
112
114
  }
113
115
  }
114
116
  if (hasFinished && !retentionTime) {
115
- await this.deleteFromDb(data);
117
+ await this.deleteFromDb(parsedData);
116
118
  }
117
119
  else {
118
- await this.saveToDb(data);
120
+ await this.saveToDb(parsedData);
119
121
  }
120
122
  if (hasFinished) {
121
123
  // await this.redisClient.del(key)
122
- await this.redisClient.set(key, JSON.stringify(data, this.stringifyWithSymbol), "EX", RedisDistributedTransactionStorage.TTL_AFTER_COMPLETED);
124
+ await this.redisClient.set(key, stringifiedData, "EX", RedisDistributedTransactionStorage.TTL_AFTER_COMPLETED);
123
125
  }
124
126
  }
125
127
  async scheduleRetry(transaction, step, timestamp, interval) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/workflow-engine-redis",
3
- "version": "0.0.2",
3
+ "version": "0.0.3-next-20240221072935",
4
4
  "description": "Medusa Workflow Orchestrator module using Redis to track workflows executions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "@mikro-orm/cli": "5.9.7",
38
38
  "cross-env": "^5.2.1",
39
39
  "jest": "^29.6.3",
40
- "medusa-test-utils": "^1.1.40",
40
+ "medusa-test-utils": "1.1.42-next-20240221072935",
41
41
  "rimraf": "^3.0.2",
42
42
  "ts-jest": "^29.1.1",
43
43
  "ts-node": "^10.9.1",
@@ -45,10 +45,10 @@
45
45
  "typescript": "^5.1.6"
46
46
  },
47
47
  "dependencies": {
48
- "@medusajs/modules-sdk": "^1.12.7",
49
- "@medusajs/types": "^1.11.11",
50
- "@medusajs/utils": "^1.11.4",
51
- "@medusajs/workflows-sdk": "^0.1.2",
48
+ "@medusajs/modules-sdk": "1.12.9-next-20240221072935",
49
+ "@medusajs/types": "1.11.14-next-20240221072935",
50
+ "@medusajs/utils": "1.11.7-next-20240221072935",
51
+ "@medusajs/workflows-sdk": "0.1.4-next-20240221072935",
52
52
  "@mikro-orm/core": "5.9.7",
53
53
  "@mikro-orm/migrations": "5.9.7",
54
54
  "@mikro-orm/postgresql": "5.9.7",
@@ -1,16 +0,0 @@
1
- import { DAL } from "@medusajs/types";
2
- import { ModulesSdkUtils } from "@medusajs/utils";
3
- import { WorkflowExecution } from "../models";
4
- type InjectedDependencies = {
5
- workflowExecutionRepository: DAL.RepositoryService;
6
- };
7
- declare const WorkflowExecutionService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => ModulesSdkUtils.AbstractService<TEntity_1, InjectedDependencies, {}, {
8
- list?: any;
9
- listAndCount?: any;
10
- }>;
11
- export declare class WorkflowExecutionService<TEntity extends WorkflowExecution = WorkflowExecution> extends WorkflowExecutionService_base<TEntity> {
12
- protected workflowExecutionRepository_: DAL.RepositoryService<TEntity>;
13
- constructor({ workflowExecutionRepository }: InjectedDependencies);
14
- }
15
- export {};
16
- //# sourceMappingURL=workflow-execution.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workflow-execution.d.ts","sourceRoot":"","sources":["../../src/services/workflow-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3C,KAAK,oBAAoB,GAAG;IAC1B,2BAA2B,EAAE,GAAG,CAAC,iBAAiB,CAAA;CACnD,CAAA;;;;;AAED,qBAAa,wBAAwB,CACnC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,CACrD,SAAQ,8BAER,OAAO,CAAC;IACR,SAAS,CAAC,4BAA4B,EAAE,GAAG,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAA;gBAE1D,EAAE,2BAA2B,EAAE,EAAE,oBAAoB;CAKlE"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WorkflowExecutionService = void 0;
4
- const utils_1 = require("@medusajs/utils");
5
- const _models_1 = require("../models");
6
- class WorkflowExecutionService extends utils_1.ModulesSdkUtils.abstractServiceFactory(_models_1.WorkflowExecution) {
7
- constructor({ workflowExecutionRepository }) {
8
- // @ts-ignore
9
- super(...arguments);
10
- this.workflowExecutionRepository_ = workflowExecutionRepository;
11
- }
12
- }
13
- exports.WorkflowExecutionService = WorkflowExecutionService;