medusa-test-utils 1.1.45-snapshot-20240717160031 → 1.1.45-snapshot-20240718083016

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. package/dist/database.d.ts +0 -1
  2. package/dist/database.js +142 -56
  3. package/dist/database.js.map +1 -1
  4. package/dist/id-map.d.ts +2 -3
  5. package/dist/id-map.js +13 -8
  6. package/dist/id-map.js.map +1 -1
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +6 -3
  9. package/dist/index.js.map +1 -1
  10. package/dist/init-modules.d.ts +0 -1
  11. package/dist/init-modules.js +95 -38
  12. package/dist/init-modules.js.map +1 -1
  13. package/dist/jest.d.ts +0 -1
  14. package/dist/jest.js +62 -14
  15. package/dist/jest.js.map +1 -1
  16. package/dist/medusa-test-runner-utils/bootstrap-app.d.ts +5 -10
  17. package/dist/medusa-test-runner-utils/bootstrap-app.js +146 -54
  18. package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
  19. package/dist/medusa-test-runner-utils/use-db.d.ts +12 -5
  20. package/dist/medusa-test-runner-utils/use-db.js +143 -29
  21. package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
  22. package/dist/medusa-test-runner.d.ts +3 -9
  23. package/dist/medusa-test-runner.js +332 -144
  24. package/dist/medusa-test-runner.js.map +1 -1
  25. package/dist/mock-event-bus-service.d.ts +4 -5
  26. package/dist/mock-event-bus-service.js +51 -13
  27. package/dist/mock-event-bus-service.js.map +1 -1
  28. package/dist/mock-manager.d.ts +9 -0
  29. package/dist/mock-manager.js +30 -0
  30. package/dist/mock-manager.js.map +1 -0
  31. package/dist/mock-repository.d.ts +51 -0
  32. package/dist/mock-repository.js +193 -0
  33. package/dist/mock-repository.js.map +1 -0
  34. package/dist/module-test-runner.d.ts +2 -3
  35. package/dist/module-test-runner.js +129 -60
  36. package/dist/module-test-runner.js.map +1 -1
  37. package/package.json +12 -7
  38. package/dist/database.d.ts.map +0 -1
  39. package/dist/events.d.ts +0 -3
  40. package/dist/events.d.ts.map +0 -1
  41. package/dist/events.js +0 -24
  42. package/dist/events.js.map +0 -1
  43. package/dist/id-map.d.ts.map +0 -1
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/init-modules.d.ts.map +0 -1
  46. package/dist/jest.d.ts.map +0 -1
  47. package/dist/medusa-test-runner-utils/bootstrap-app.d.ts.map +0 -1
  48. package/dist/medusa-test-runner-utils/use-db.d.ts.map +0 -1
  49. package/dist/medusa-test-runner.d.ts.map +0 -1
  50. package/dist/mock-event-bus-service.d.ts.map +0 -1
  51. package/dist/module-test-runner.d.ts.map +0 -1
@@ -25,4 +25,3 @@ export declare function getMikroOrmWrapper({ mikroOrmEntities, pathToMigrations,
25
25
  clientUrl?: string;
26
26
  schema?: string;
27
27
  }): TestDatabase;
28
- //# sourceMappingURL=database.d.ts.map
package/dist/database.js CHANGED
@@ -1,22 +1,60 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.getMikroOrmWrapper = exports.getMikroOrmConfig = exports.getDatabaseURL = void 0;
4
- const postgresql_1 = require("@mikro-orm/postgresql");
40
+ var postgresql_1 = require("@mikro-orm/postgresql");
5
41
  function getDatabaseURL(dbName) {
6
- const DB_HOST = process.env.DB_HOST ?? "localhost";
7
- const DB_USERNAME = process.env.DB_USERNAME ?? "";
8
- const DB_PASSWORD = process.env.DB_PASSWORD;
9
- const DB_NAME = dbName ?? process.env.DB_TEMP_NAME;
10
- return `postgres://${DB_USERNAME}${DB_PASSWORD ? `:${DB_PASSWORD}` : ""}@${DB_HOST}/${DB_NAME}`;
42
+ var _a, _b;
43
+ var DB_HOST = (_a = process.env.DB_HOST) !== null && _a !== void 0 ? _a : "localhost";
44
+ var DB_USERNAME = (_b = process.env.DB_USERNAME) !== null && _b !== void 0 ? _b : "";
45
+ var DB_PASSWORD = process.env.DB_PASSWORD;
46
+ var DB_NAME = dbName !== null && dbName !== void 0 ? dbName : process.env.DB_TEMP_NAME;
47
+ return "postgres://".concat(DB_USERNAME).concat(DB_PASSWORD ? ":".concat(DB_PASSWORD) : "", "@").concat(DB_HOST, "/").concat(DB_NAME);
11
48
  }
12
49
  exports.getDatabaseURL = getDatabaseURL;
13
- function getMikroOrmConfig({ mikroOrmEntities, pathToMigrations, clientUrl, schema, }) {
14
- const DB_URL = clientUrl ?? getDatabaseURL();
50
+ function getMikroOrmConfig(_a) {
51
+ var mikroOrmEntities = _a.mikroOrmEntities, pathToMigrations = _a.pathToMigrations, clientUrl = _a.clientUrl, schema = _a.schema;
52
+ var DB_URL = clientUrl !== null && clientUrl !== void 0 ? clientUrl : getDatabaseURL();
15
53
  return {
16
54
  type: "postgresql",
17
55
  clientUrl: DB_URL,
18
56
  entities: Object.values(mikroOrmEntities),
19
- schema: schema ?? process.env.MEDUSA_DB_SCHEMA,
57
+ schema: schema !== null && schema !== void 0 ? schema : process.env.MEDUSA_DB_SCHEMA,
20
58
  debug: false,
21
59
  migrations: {
22
60
  pathTs: pathToMigrations,
@@ -25,73 +63,121 @@ function getMikroOrmConfig({ mikroOrmEntities, pathToMigrations, clientUrl, sche
25
63
  };
26
64
  }
27
65
  exports.getMikroOrmConfig = getMikroOrmConfig;
28
- function getMikroOrmWrapper({ mikroOrmEntities, pathToMigrations, clientUrl, schema, }) {
66
+ function getMikroOrmWrapper(_a) {
67
+ var mikroOrmEntities = _a.mikroOrmEntities, pathToMigrations = _a.pathToMigrations, clientUrl = _a.clientUrl, schema = _a.schema;
29
68
  return {
30
- mikroOrmEntities,
31
- pathToMigrations,
32
- clientUrl: clientUrl ?? getDatabaseURL(),
33
- schema: schema ?? process.env.MEDUSA_DB_SCHEMA,
69
+ mikroOrmEntities: mikroOrmEntities,
70
+ pathToMigrations: pathToMigrations,
71
+ clientUrl: clientUrl !== null && clientUrl !== void 0 ? clientUrl : getDatabaseURL(),
72
+ schema: schema !== null && schema !== void 0 ? schema : process.env.MEDUSA_DB_SCHEMA,
34
73
  orm: null,
35
74
  manager: null,
36
- getManager() {
75
+ getManager: function () {
37
76
  if (this.manager === null) {
38
77
  throw new Error("manager entity not available");
39
78
  }
40
79
  return this.manager;
41
80
  },
42
- forkManager() {
81
+ forkManager: function () {
43
82
  if (this.manager === null) {
44
83
  throw new Error("manager entity not available");
45
84
  }
46
85
  return this.manager.fork();
47
86
  },
48
- getOrm() {
87
+ getOrm: function () {
49
88
  if (this.orm === null) {
50
89
  throw new Error("orm entity not available");
51
90
  }
52
91
  return this.orm;
53
92
  },
54
- async setupDatabase() {
55
- const OrmConfig = getMikroOrmConfig({
56
- mikroOrmEntities: this.mikroOrmEntities,
57
- pathToMigrations: this.pathToMigrations,
58
- clientUrl: this.clientUrl,
59
- schema: this.schema,
93
+ setupDatabase: function () {
94
+ var _a, _b;
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var OrmConfig, _c, err_1, pendingMigrations;
97
+ return __generator(this, function (_d) {
98
+ switch (_d.label) {
99
+ case 0:
100
+ OrmConfig = getMikroOrmConfig({
101
+ mikroOrmEntities: this.mikroOrmEntities,
102
+ pathToMigrations: this.pathToMigrations,
103
+ clientUrl: this.clientUrl,
104
+ schema: this.schema,
105
+ });
106
+ // Initializing the ORM
107
+ _c = this;
108
+ return [4 /*yield*/, postgresql_1.MikroORM.init(OrmConfig)];
109
+ case 1:
110
+ // Initializing the ORM
111
+ _c.orm = _d.sent();
112
+ this.manager = this.orm.em;
113
+ _d.label = 2;
114
+ case 2:
115
+ _d.trys.push([2, 4, , 5]);
116
+ return [4 /*yield*/, this.orm.getSchemaGenerator().ensureDatabase()];
117
+ case 3:
118
+ _d.sent();
119
+ return [3 /*break*/, 5];
120
+ case 4:
121
+ err_1 = _d.sent();
122
+ console.log(err_1);
123
+ return [3 /*break*/, 5];
124
+ case 5: return [4 /*yield*/, ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.execute("CREATE SCHEMA IF NOT EXISTS \"".concat((_b = this.schema) !== null && _b !== void 0 ? _b : "public", "\";")))];
125
+ case 6:
126
+ _d.sent();
127
+ return [4 /*yield*/, this.orm
128
+ .getMigrator()
129
+ .getPendingMigrations()];
130
+ case 7:
131
+ pendingMigrations = _d.sent();
132
+ if (!(pendingMigrations && pendingMigrations.length > 0)) return [3 /*break*/, 9];
133
+ return [4 /*yield*/, this.orm
134
+ .getMigrator()
135
+ .up({ migrations: pendingMigrations.map(function (m) { return m.name; }) })];
136
+ case 8:
137
+ _d.sent();
138
+ return [3 /*break*/, 11];
139
+ case 9: return [4 /*yield*/, this.orm.schema.refreshDatabase()]; // ensure db exists and is fresh
140
+ case 10:
141
+ _d.sent(); // ensure db exists and is fresh
142
+ _d.label = 11;
143
+ case 11: return [2 /*return*/];
144
+ }
145
+ });
60
146
  });
61
- // Initializing the ORM
62
- this.orm = await postgresql_1.MikroORM.init(OrmConfig);
63
- this.manager = this.orm.em;
64
- try {
65
- await this.orm.getSchemaGenerator().ensureDatabase();
66
- }
67
- catch (err) {
68
- console.log(err);
69
- }
70
- await this.manager?.execute(`CREATE SCHEMA IF NOT EXISTS "${this.schema ?? "public"}";`);
71
- const pendingMigrations = await this.orm
72
- .getMigrator()
73
- .getPendingMigrations();
74
- if (pendingMigrations && pendingMigrations.length > 0) {
75
- await this.orm
76
- .getMigrator()
77
- .up({ migrations: pendingMigrations.map((m) => m.name) });
78
- }
79
- else {
80
- await this.orm.schema.refreshDatabase(); // ensure db exists and is fresh
81
- }
82
147
  },
83
- async clearDatabase() {
84
- if (this.orm === null) {
85
- throw new Error("ORM not configured");
86
- }
87
- await this.manager?.execute(`DROP SCHEMA IF EXISTS "${this.schema ?? "public"}" CASCADE;`);
88
- await this.manager?.execute(`CREATE SCHEMA IF NOT EXISTS "${this.schema ?? "public"}";`);
89
- try {
90
- await this.orm.close();
91
- }
92
- catch { }
93
- this.orm = null;
94
- this.manager = null;
148
+ clearDatabase: function () {
149
+ var _a, _b, _c, _d;
150
+ return __awaiter(this, void 0, void 0, function () {
151
+ var _e;
152
+ return __generator(this, function (_f) {
153
+ switch (_f.label) {
154
+ case 0:
155
+ if (this.orm === null) {
156
+ throw new Error("ORM not configured");
157
+ }
158
+ return [4 /*yield*/, ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.execute("DROP SCHEMA IF EXISTS \"".concat((_b = this.schema) !== null && _b !== void 0 ? _b : "public", "\" CASCADE;")))];
159
+ case 1:
160
+ _f.sent();
161
+ return [4 /*yield*/, ((_c = this.manager) === null || _c === void 0 ? void 0 : _c.execute("CREATE SCHEMA IF NOT EXISTS \"".concat((_d = this.schema) !== null && _d !== void 0 ? _d : "public", "\";")))];
162
+ case 2:
163
+ _f.sent();
164
+ _f.label = 3;
165
+ case 3:
166
+ _f.trys.push([3, 5, , 6]);
167
+ return [4 /*yield*/, this.orm.close()];
168
+ case 4:
169
+ _f.sent();
170
+ return [3 /*break*/, 6];
171
+ case 5:
172
+ _e = _f.sent();
173
+ return [3 /*break*/, 6];
174
+ case 6:
175
+ this.orm = null;
176
+ this.manager = null;
177
+ return [2 /*return*/];
178
+ }
179
+ });
180
+ });
95
181
  },
96
182
  };
97
183
  }
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":";;;AAAA,sDAA2E;AAE3E,SAAgB,cAAc,CAAC,MAAe;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,WAAW,CAAA;IAClD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAA;IACjD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAA;IAC3C,MAAM,OAAO,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAA;IAElD,OAAO,cAAc,WAAW,GAC9B,WAAW,CAAC,C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jD,wBAAiD;4BACnD,qBAAM,IAAI,CAAC,GAAG;qCACX,WAAW,EAAE;qCACb,EAAE,CAAC,EAAE,UAAU,EAAE,iBAAiB,CAAC,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAK,EAAP,CAAO,CAAC,EAAE,CAAC,EAAA;;4BAF5D,SAE4D,CAAA;;gCAE5D,qBAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,eAAe,EAAE,EAAA,CAAC,gCAAgC;;4BAAxE,SAAuC,CAAA,CAAC,gCAAgC;;;;;;SAE3E;QAEK,aAAa;;;;;;;4BACjB,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE;gCACrB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;6BACtC;4BAED,qBAAM,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CACzB,kCAA0B,MAAA,IAAI,CAAC,MAAM,mCAAI,QAAQ,gBAAY,CAC9D,CAAA,EAAA;;4BAFD,SAEC,CAAA;4BAED,qBAAM,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CACzB,wCAAgC,MAAA,IAAI,CAAC,MAAM,mCAAI,QAAQ,QAAI,CAC5D,CAAA,EAAA;;4BAFD,SAEC,CAAA;;;;4BAGC,qBAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAA;;4BAAtB,SAAsB,CAAA;;;;;;4BAGxB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAA;4BACf,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;;;;;SACpB;KACF,CAAA;AACH,CAAC;AArGD,gDAqGC"}
package/dist/id-map.d.ts CHANGED
@@ -1,7 +1,6 @@
1
+ export default instance;
2
+ declare const instance: IdMap;
1
3
  declare class IdMap {
2
4
  ids: {};
3
5
  getId(key: any, prefix?: string, length?: number): any;
4
6
  }
5
- declare const instance: IdMap;
6
- export default instance;
7
- //# sourceMappingURL=id-map.d.ts.map
package/dist/id-map.js CHANGED
@@ -3,18 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const randomatic_1 = __importDefault(require("randomatic"));
7
- class IdMap {
8
- ids = {};
9
- getId(key, prefix = "", length = 10) {
6
+ var randomatic_1 = __importDefault(require("randomatic"));
7
+ var IdMap = /** @class */ (function () {
8
+ function IdMap() {
9
+ this.ids = {};
10
+ }
11
+ IdMap.prototype.getId = function (key, prefix, length) {
12
+ if (prefix === void 0) { prefix = ""; }
13
+ if (length === void 0) { length = 10; }
10
14
  if (this.ids[key]) {
11
15
  return this.ids[key];
12
16
  }
13
- const id = `${prefix && prefix + "_"}${(0, randomatic_1.default)("Aa0", length)}`;
17
+ var id = "".concat(prefix && prefix + "_").concat((0, randomatic_1.default)("Aa0", length));
14
18
  this.ids[key] = id;
15
19
  return id;
16
- }
17
- }
18
- const instance = new IdMap();
20
+ };
21
+ return IdMap;
22
+ }());
23
+ var instance = new IdMap();
19
24
  exports.default = instance;
20
25
  //# sourceMappingURL=id-map.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"id-map.js","sourceRoot":"","sources":["../src/id-map.ts"],"names":[],"mappings":";;;;;AAAA,4DAAkC;AAElC,MAAM,KAAK;IACT,GAAG,GAAG,EAAE,CAAA;IAER,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE;QACjC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC;QAED,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,MAAM,GAAG,GAAG,GAAG,IAAA,oBAAS,EAAC,KAAK,EAAE,MAAM,CAAC,EAAE,CAAA;QACjE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QAElB,OAAO,EAAE,CAAA;IACX,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,IAAI,KAAK,EAAE,CAAA;AAC5B,kBAAe,QAAQ,CAAA"}
1
+ {"version":3,"file":"id-map.js","sourceRoot":"","sources":["../src/id-map.js"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAElC;IAAA;QACE,QAAG,GAAG,EAAE,CAAA;IAYV,CAAC;IAVC,qBAAK,GAAL,UAAM,GAAG,EAAE,MAAW,EAAE,MAAW;QAAxB,uBAAA,EAAA,WAAW;QAAE,uBAAA,EAAA,WAAW;QACjC,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACjB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;SACrB;QAED,IAAM,EAAE,GAAG,UAAG,MAAM,IAAI,MAAM,GAAG,GAAG,SAAG,IAAA,oBAAS,EAAC,KAAK,EAAE,MAAM,CAAC,CAAE,CAAA;QACjE,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;QAElB,OAAO,EAAE,CAAA;IACX,CAAC;IACH,YAAC;AAAD,CAAC,AAbD,IAaC;AAED,IAAM,QAAQ,GAAG,IAAI,KAAK,EAAE,CAAA;AAC5B,kBAAe,QAAQ,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export * as TestDatabaseUtils from "./database";
2
- export * as TestEventUtils from "./events";
3
- export * as JestUtils from "./jest";
4
2
  export { default as IdMap } from "./id-map";
3
+ export * as JestUtils from "./jest";
4
+ export { default as MockManager } from "./mock-manager";
5
+ export { default as MockRepository } from "./mock-repository";
5
6
  export * from "./init-modules";
6
7
  export { default as MockEventBusService } from "./mock-event-bus-service";
7
8
  export * from "./module-test-runner";
8
9
  export * from "./medusa-test-runner";
9
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -29,12 +29,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  return (mod && mod.__esModule) ? mod : { "default": mod };
30
30
  };
31
31
  Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.MockEventBusService = exports.IdMap = exports.JestUtils = exports.TestEventUtils = exports.TestDatabaseUtils = void 0;
32
+ exports.MockEventBusService = exports.MockRepository = exports.MockManager = exports.JestUtils = exports.IdMap = exports.TestDatabaseUtils = void 0;
33
33
  exports.TestDatabaseUtils = __importStar(require("./database"));
34
- exports.TestEventUtils = __importStar(require("./events"));
35
- exports.JestUtils = __importStar(require("./jest"));
36
34
  var id_map_1 = require("./id-map");
37
35
  Object.defineProperty(exports, "IdMap", { enumerable: true, get: function () { return __importDefault(id_map_1).default; } });
36
+ exports.JestUtils = __importStar(require("./jest"));
37
+ var mock_manager_1 = require("./mock-manager");
38
+ Object.defineProperty(exports, "MockManager", { enumerable: true, get: function () { return __importDefault(mock_manager_1).default; } });
39
+ var mock_repository_1 = require("./mock-repository");
40
+ Object.defineProperty(exports, "MockRepository", { enumerable: true, get: function () { return __importDefault(mock_repository_1).default; } });
38
41
  __exportStar(require("./init-modules"), exports);
39
42
  var mock_event_bus_service_1 = require("./mock-event-bus-service");
40
43
  Object.defineProperty(exports, "MockEventBusService", { enumerable: true, get: function () { return __importDefault(mock_event_bus_service_1).default; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAA+C;AAC/C,2DAA0C;AAC1C,oDAAmC;AACnC,mCAA2C;AAAlC,gHAAA,OAAO,OAAS;AACzB,iDAA8B;AAC9B,mEAAyE;AAAhE,8IAAA,OAAO,OAAuB;AACvC,uDAAoC;AACpC,uDAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAA+C;AAC/C,mCAA2C;AAAlC,gHAAA,OAAO,OAAS;AACzB,oDAAmC;AACnC,+CAAuD;AAA9C,4HAAA,OAAO,OAAe;AAC/B,qDAA6D;AAApD,kIAAA,OAAO,OAAkB;AAClC,iDAA8B;AAC9B,mEAAyE;AAAhE,8IAAA,OAAO,OAAuB;AACvC,uDAAoC;AACpC,uDAAoC"}
@@ -15,4 +15,3 @@ export declare function initModules({ injectedDependencies, databaseConfig, modu
15
15
  medusaApp: any;
16
16
  shutdown: () => Promise<void>;
17
17
  }>;
18
- //# sourceMappingURL=init-modules.d.ts.map
@@ -1,46 +1,103 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.initModules = void 0;
4
- const utils_1 = require("@medusajs/utils");
5
- async function initModules({ injectedDependencies, databaseConfig, modulesConfig, joinerConfig, preventConnectionDestroyWarning = false, }) {
6
- const moduleSdkImports = require("@medusajs/modules-sdk");
7
- injectedDependencies ??= {};
8
- let sharedPgConnection = injectedDependencies?.[utils_1.ContainerRegistrationKeys.PG_CONNECTION];
9
- let shouldDestroyConnectionAutomatically = !sharedPgConnection;
10
- if (!sharedPgConnection) {
11
- sharedPgConnection = (0, utils_1.createPgConnection)({
12
- clientUrl: databaseConfig.clientUrl,
13
- schema: databaseConfig.schema,
14
- });
15
- injectedDependencies[utils_1.ContainerRegistrationKeys.PG_CONNECTION] =
16
- sharedPgConnection;
17
- }
18
- const medusaApp = await moduleSdkImports.MedusaApp({
19
- modulesConfig,
20
- servicesConfig: joinerConfig,
21
- injectedDependencies,
22
- });
23
- await medusaApp.onApplicationStart();
24
- async function shutdown() {
25
- if (shouldDestroyConnectionAutomatically) {
26
- await medusaApp.onApplicationPrepareShutdown();
27
- await (0, utils_1.promiseAll)([
28
- sharedPgConnection.context?.destroy(),
29
- sharedPgConnection.destroy(),
30
- medusaApp.onApplicationShutdown(),
31
- ]);
40
+ var utils_1 = require("@medusajs/utils");
41
+ function initModules(_a) {
42
+ var injectedDependencies = _a.injectedDependencies, databaseConfig = _a.databaseConfig, modulesConfig = _a.modulesConfig, joinerConfig = _a.joinerConfig, _b = _a.preventConnectionDestroyWarning, preventConnectionDestroyWarning = _b === void 0 ? false : _b;
43
+ return __awaiter(this, void 0, void 0, function () {
44
+ function shutdown() {
45
+ var _a;
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ return __generator(this, function (_b) {
48
+ switch (_b.label) {
49
+ case 0:
50
+ if (!shouldDestroyConnectionAutomatically) return [3 /*break*/, 2];
51
+ return [4 /*yield*/, (0, utils_1.promiseAll)([
52
+ (_a = sharedPgConnection.context) === null || _a === void 0 ? void 0 : _a.destroy(),
53
+ sharedPgConnection.destroy(),
54
+ medusaApp.onApplicationShutdown(),
55
+ ])];
56
+ case 1:
57
+ _b.sent();
58
+ return [3 /*break*/, 3];
59
+ case 2:
60
+ if (!preventConnectionDestroyWarning) {
61
+ console.info("You are using a custom shared connection. The connection won't be destroyed automatically.");
62
+ }
63
+ _b.label = 3;
64
+ case 3:
65
+ moduleSdkImports.MedusaModule.clearInstances();
66
+ return [2 /*return*/];
67
+ }
68
+ });
69
+ });
32
70
  }
33
- else {
34
- if (!preventConnectionDestroyWarning) {
35
- console.info(`You are using a custom shared connection. The connection won't be destroyed automatically.`);
71
+ var moduleSdkImports, sharedPgConnection, shouldDestroyConnectionAutomatically, medusaApp;
72
+ return __generator(this, function (_c) {
73
+ switch (_c.label) {
74
+ case 0:
75
+ moduleSdkImports = require("@medusajs/modules-sdk");
76
+ injectedDependencies !== null && injectedDependencies !== void 0 ? injectedDependencies : (injectedDependencies = {});
77
+ sharedPgConnection = injectedDependencies === null || injectedDependencies === void 0 ? void 0 : injectedDependencies[utils_1.ContainerRegistrationKeys.PG_CONNECTION];
78
+ shouldDestroyConnectionAutomatically = !sharedPgConnection;
79
+ if (!sharedPgConnection) {
80
+ sharedPgConnection = utils_1.ModulesSdkUtils.createPgConnection({
81
+ clientUrl: databaseConfig.clientUrl,
82
+ schema: databaseConfig.schema,
83
+ });
84
+ injectedDependencies[utils_1.ContainerRegistrationKeys.PG_CONNECTION] =
85
+ sharedPgConnection;
86
+ }
87
+ return [4 /*yield*/, moduleSdkImports.MedusaApp({
88
+ modulesConfig: modulesConfig,
89
+ servicesConfig: joinerConfig,
90
+ injectedDependencies: injectedDependencies,
91
+ })];
92
+ case 1:
93
+ medusaApp = _c.sent();
94
+ return [2 /*return*/, {
95
+ medusaApp: medusaApp,
96
+ shutdown: shutdown,
97
+ }];
36
98
  }
37
- }
38
- moduleSdkImports.MedusaModule.clearInstances();
39
- }
40
- return {
41
- medusaApp,
42
- shutdown,
43
- };
99
+ });
100
+ });
44
101
  }
45
102
  exports.initModules = initModules;
46
103
  //# sourceMappingURL=init-modules.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-modules.js","sourceRoot":"","sources":["../src/init-modules.ts"],"names":[],"mappings":";;;AAKA,2CAIwB;AAkBjB,KAAK,UAAU,WAAW,CAAC,EAChC,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,+BAA+B,GAAG,KAAK,GACpB;IACnB,MAAM,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAEzD,oBAAoB,KAAK,EAAE,CAAA;IAE3B,IAAI,kBAAkB,GACpB,oBAAoB,EAAE,CAAC,iCAAyB,CAAC,aAAa,CAAC,CAAA;IAEjE,IAAI,oCAAoC,GAAG,CAAC,kBAAkB,CAAA;IAC9D,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,kBAAkB,GAAG,IAAA,0BAAkB,EAAC;YACtC,SAAS,EAAE,cAAc,CAAC,SAAS;YACnC,MAAM,EAAE,cAAc,CAAC,MAAM;SAC9B,CAAC,CAAA;QAEF,oBAAoB,CAAC,iCAAyB,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SAAS,CAAC,qBAAqB,EAAE;iCAClC,CAAC,EAAA;;4BAJF,SAIE,CAAA;;;4BAEF,IAAI,CAAC,+BAA+B,EAAE;gCACpC,OAAO,CAAC,IAAI,CACV,4FAA4F,CAC7F,CAAA;6BACF;;;4BAEH,gBAAgB,CAAC,YAAY,CAAC,cAAc,EAAE,CAAA;;;;;SAC/C;;;;;oBAvCK,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;oBAEzD,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,IAApB,oBAAoB,GAAK,EAAE,EAAA;oBAEvB,kBAAkB,GACpB,oBAAoB,aAApB,oBAAoB,uBAApB,oBAAoB,CAAG,iCAAyB,CAAC,aAAa,CAAC,CAAA;oBAE7D,oCAAoC,GAAG,CAAC,kBAAkB,CAAA;oBAC9D,IAAI,CAAC,kBAAkB,EAAE;wBACvB,kBAAkB,GAAG,uBAAe,CAAC,kBAAkB,CAAC;4BACtD,SAAS,EAAE,cAAc,CAAC,SAAS;4BACnC,MAAM,EAAE,cAAc,CAAC,MAAM;yBAC9B,CAAC,CAAA;wBAEF,oBAAoB,CAAC,iCAAyB,CAAC,aAAa,CAAC;4BAC3D,kBAAkB,CAAA;qBACrB;oBAEiB,qBAAM,gBAAgB,CAAC,SAAS,CAAC;4BACjD,aAAa,eAAA;4BACb,cAAc,EAAE,YAAY;4BAC5B,oBAAoB,sBAAA;yBACrB,CAAC,EAAA;;oBAJI,SAAS,GAAG,SAIhB;oBAmBF,sBAAO;4BACL,SAAS,WAAA;4BACT,QAAQ,UAAA;yBACT,EAAA;;;;CACF;AApDD,kCAoDC"}
package/dist/jest.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  export declare function afterAllHookDropDatabase(): void;
2
- //# sourceMappingURL=jest.d.ts.map
package/dist/jest.js CHANGED
@@ -1,25 +1,73 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.afterAllHookDropDatabase = void 0;
4
- const pg_god_1 = require("pg-god");
40
+ var pg_god_1 = require("pg-god");
5
41
  function afterAllHookDropDatabase() {
6
- const DB_HOST = process.env.DB_HOST ?? "localhost";
7
- const DB_USERNAME = process.env.DB_USERNAME ?? "postgres";
8
- const DB_PASSWORD = process.env.DB_PASSWORD ?? "";
9
- const DB_NAME = process.env.DB_TEMP_NAME || "";
10
- const pgGodCredentials = {
42
+ var _this = this;
43
+ var _a, _b, _c;
44
+ var DB_HOST = (_a = process.env.DB_HOST) !== null && _a !== void 0 ? _a : "localhost";
45
+ var DB_USERNAME = (_b = process.env.DB_USERNAME) !== null && _b !== void 0 ? _b : "postgres";
46
+ var DB_PASSWORD = (_c = process.env.DB_PASSWORD) !== null && _c !== void 0 ? _c : "";
47
+ var DB_NAME = process.env.DB_TEMP_NAME || "";
48
+ var pgGodCredentials = {
11
49
  user: DB_USERNAME,
12
50
  password: DB_PASSWORD,
13
51
  host: DB_HOST,
14
52
  };
15
- afterAll(async () => {
16
- try {
17
- await (0, pg_god_1.dropDatabase)({ databaseName: DB_NAME }, pgGodCredentials);
18
- }
19
- catch (e) {
20
- console.error(`This might fail if it is run during the unit tests since there is no database to drop. Otherwise, please check what is the issue. ${e.message}`);
21
- }
22
- });
53
+ afterAll(function () { return __awaiter(_this, void 0, void 0, function () {
54
+ var e_1;
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0:
58
+ _a.trys.push([0, 2, , 3]);
59
+ return [4 /*yield*/, (0, pg_god_1.dropDatabase)({ databaseName: DB_NAME }, pgGodCredentials)];
60
+ case 1:
61
+ _a.sent();
62
+ return [3 /*break*/, 3];
63
+ case 2:
64
+ e_1 = _a.sent();
65
+ console.error("This might fail if it is run during the unit tests since there is no database to drop. Otherwise, please check what is the issue. ".concat(e_1.message));
66
+ return [3 /*break*/, 3];
67
+ case 3: return [2 /*return*/];
68
+ }
69
+ });
70
+ }); });
23
71
  }
24
72
  exports.afterAllHookDropDatabase = afterAllHookDropDatabase;
25
73
  //# sourceMappingURL=jest.js.map
package/dist/jest.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jest.js","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AAErC,SAAgB,wBAAwB;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,WAAW,CAAA;IAClD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,UAAU,CAAA;IACzD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAA;IACjD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAA;IAE9C,MAAM,gBAAgB,GAAG;QACvB,IAAI,EAAE,WAAW;QACjB,QAAQ,EAAE,WAAW;QACrB,IAAI,EAAE,OAAO;KACd,CAAA;IAED,QAAQ,CAAC,KAAK,IAAI,EAAE;QAClB,IAAI,CAAC;YACH,MAAM,IAAA,qBAAY,EAAC,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,gBAAgB,CAAC,CAAA;QACjE,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CACX,qIAAqI,CAAC,CAAC,OAAO,EAAE,CACjJ,CAAA;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AArBD,4DAqBC"}
1
+ {"version":3,"file":"jest.js","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAqC;AAErC,SAAgB,wBAAwB;IAAxC,iBAqBC;;IApBC,IAAM,OAAO,GAAG,MAAA,OAAO,C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