medusa-test-utils 1.1.45 → 2.0.0-rc-20241003153304
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.
- package/dist/database.d.ts +2 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +100 -146
- package/dist/database.js.map +1 -1
- package/dist/events.d.ts +3 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +41 -0
- package/dist/events.js.map +1 -0
- package/dist/id-map.d.ts +3 -2
- package/dist/id-map.d.ts.map +1 -0
- package/dist/id-map.js +8 -11
- package/dist/id-map.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/init-modules.d.ts +2 -1
- package/dist/init-modules.d.ts.map +1 -0
- package/dist/init-modules.js +39 -97
- package/dist/init-modules.js.map +1 -1
- package/dist/jest.d.ts +1 -0
- package/dist/jest.d.ts.map +1 -0
- package/dist/jest.js +15 -64
- package/dist/jest.js.map +1 -1
- package/dist/medusa-test-runner-utils/bootstrap-app.d.ts +10 -5
- package/dist/medusa-test-runner-utils/bootstrap-app.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/bootstrap-app.js +53 -147
- package/dist/medusa-test-runner-utils/bootstrap-app.js.map +1 -1
- package/dist/medusa-test-runner-utils/clear-instances.d.ts +8 -0
- package/dist/medusa-test-runner-utils/clear-instances.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/clear-instances.js +14 -0
- package/dist/medusa-test-runner-utils/clear-instances.js.map +1 -0
- package/dist/medusa-test-runner-utils/config.d.ts +5 -0
- package/dist/medusa-test-runner-utils/config.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/config.js +28 -0
- package/dist/medusa-test-runner-utils/config.js.map +1 -0
- package/dist/medusa-test-runner-utils/index.d.ts +6 -0
- package/dist/medusa-test-runner-utils/index.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/index.js +22 -0
- package/dist/medusa-test-runner-utils/index.js.map +1 -0
- package/dist/medusa-test-runner-utils/use-db.d.ts +15 -12
- package/dist/medusa-test-runner-utils/use-db.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/use-db.js +51 -143
- package/dist/medusa-test-runner-utils/use-db.js.map +1 -1
- package/dist/medusa-test-runner-utils/utils.d.ts +2 -0
- package/dist/medusa-test-runner-utils/utils.d.ts.map +1 -0
- package/dist/medusa-test-runner-utils/utils.js +10 -0
- package/dist/medusa-test-runner-utils/utils.js.map +1 -0
- package/dist/medusa-test-runner.d.ts +16 -6
- package/dist/medusa-test-runner.d.ts.map +1 -0
- package/dist/medusa-test-runner.js +123 -343
- package/dist/medusa-test-runner.js.map +1 -1
- package/dist/mock-event-bus-service.d.ts +5 -4
- package/dist/mock-event-bus-service.d.ts.map +1 -0
- package/dist/mock-event-bus-service.js +13 -51
- package/dist/mock-event-bus-service.js.map +1 -1
- package/dist/module-test-runner.d.ts +4 -2
- package/dist/module-test-runner.d.ts.map +1 -0
- package/dist/module-test-runner.js +117 -132
- package/dist/module-test-runner.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +28 -39
- package/dist/mock-manager.d.ts +0 -9
- package/dist/mock-manager.js +0 -30
- package/dist/mock-manager.js.map +0 -1
- package/dist/mock-repository.d.ts +0 -51
- package/dist/mock-repository.js +0 -193
- package/dist/mock-repository.js.map +0 -1
package/dist/init-modules.js
CHANGED
@@ -1,103 +1,45 @@
|
|
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
|
-
};
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
exports.initModules =
|
40
|
-
|
41
|
-
function initModules(
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
-
});
|
70
|
-
}
|
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
|
-
}];
|
98
|
-
}
|
3
|
+
exports.initModules = initModules;
|
4
|
+
const utils_1 = require("@medusajs/framework/utils");
|
5
|
+
async function initModules({ injectedDependencies, databaseConfig, modulesConfig, joinerConfig, preventConnectionDestroyWarning = false, }) {
|
6
|
+
const moduleSdkImports = require("@medusajs/framework/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,
|
99
14
|
});
|
15
|
+
injectedDependencies[utils_1.ContainerRegistrationKeys.PG_CONNECTION] =
|
16
|
+
sharedPgConnection;
|
17
|
+
}
|
18
|
+
const medusaApp = await moduleSdkImports.MedusaApp({
|
19
|
+
modulesConfig,
|
20
|
+
servicesConfig: joinerConfig,
|
21
|
+
injectedDependencies,
|
100
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
|
+
]);
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
if (!preventConnectionDestroyWarning) {
|
35
|
+
console.info(`You are using a custom shared connection. The connection won't be destroyed automatically.`);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
moduleSdkImports.MedusaModule.clearInstances();
|
39
|
+
}
|
40
|
+
return {
|
41
|
+
medusaApp,
|
42
|
+
shutdown,
|
43
|
+
};
|
101
44
|
}
|
102
|
-
exports.initModules = initModules;
|
103
45
|
//# sourceMappingURL=init-modules.js.map
|
package/dist/init-modules.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"init-modules.js","sourceRoot":"","sources":["../src/init-modules.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"init-modules.js","sourceRoot":"","sources":["../src/init-modules.ts"],"names":[],"mappings":";;AA2BA,kCAwDC;AA9ED,qDAIkC;AAkB3B,KAAK,UAAU,WAAW,CAAC,EAChC,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,YAAY,EACZ,+BAA+B,GAAG,KAAK,GACpB;IACnB,MAAM,gBAAgB,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAA;IAEnE,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,CAAC,aAAa,CAAC;YAC3D,kBAAkB,CAAA;IACtB,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,gBAAgB,CAAC,SAAS,CAAC;QACjD,aAAa;QACb,cAAc,EAAE,YAAY;QAC5B,oBAAoB;KACrB,CAAC,CAAA;IAEF,MAAM,SAAS,CAAC,kBAAkB,EAAE,CAAA;IAEpC,KAAK,UAAU,QAAQ;QACrB,IAAI,oCAAoC,EAAE,CAAC;YACzC,MAAM,SAAS,CAAC,4BAA4B,EAAE,CAAA;YAE9C,MAAM,IAAA,kBAAU,EAAC;gBACd,kBAA0B,CAAC,OAAO,EAAE,OAAO,EAAE;gBAC7C,kBAA0B,CAAC,OAAO,EAAE;gBACrC,SAAS,CAAC,qBAAqB,EAAE;aAClC,CAAC,CAAA;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,+BAA+B,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CACV,4FAA4F,CAC7F,CAAA;YACH,CAAC;QACH,CAAC;QACD,gBAAgB,CAAC,YAAY,CAAC,cAAc,EAAE,CAAA;IAChD,CAAC;IAED,OAAO;QACL,SAAS;QACT,QAAQ;KACT,CAAA;AACH,CAAC"}
|
package/dist/jest.d.ts
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jest.d.ts","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":"AAEA,wBAAgB,wBAAwB,SAqBvC"}
|
package/dist/jest.js
CHANGED
@@ -1,73 +1,24 @@
|
|
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
|
-
};
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
39
|
-
exports.afterAllHookDropDatabase =
|
40
|
-
|
3
|
+
exports.afterAllHookDropDatabase = afterAllHookDropDatabase;
|
4
|
+
const pg_god_1 = require("pg-god");
|
41
5
|
function afterAllHookDropDatabase() {
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
var DB_NAME = process.env.DB_TEMP_NAME || "";
|
48
|
-
var pgGodCredentials = {
|
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 = {
|
49
11
|
user: DB_USERNAME,
|
50
12
|
password: DB_PASSWORD,
|
51
13
|
host: DB_HOST,
|
52
14
|
};
|
53
|
-
afterAll(
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
}); });
|
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
|
+
});
|
71
23
|
}
|
72
|
-
exports.afterAllHookDropDatabase = afterAllHookDropDatabase;
|
73
24
|
//# 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":"
|
1
|
+
{"version":3,"file":"jest.js","sourceRoot":"","sources":["../src/jest.ts"],"names":[],"mappings":";;AAEA,4DAqBC;AAvBD,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"}
|
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}): Promise<
|
1
|
+
import { MedusaContainer } from "@medusajs/framework/types";
|
2
|
+
export declare function startApp({ cwd, env, }?: {
|
3
|
+
cwd?: string;
|
4
|
+
env?: Record<any, any>;
|
5
|
+
}): Promise<{
|
6
|
+
shutdown: () => Promise<void>;
|
7
|
+
container: MedusaContainer;
|
8
|
+
port: number;
|
9
|
+
}>;
|
10
|
+
//# sourceMappingURL=bootstrap-app.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bootstrap-app.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/bootstrap-app.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AA4B3D,wBAAsB,QAAQ,CAAC,EAC7B,GAAG,EACH,GAAQ,GACT,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;CAAO,GAAG,OAAO,CAAC;IACzD,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,SAAS,EAAE,eAAe,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAC,CAyCD"}
|
@@ -1,153 +1,59 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
return
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
14
|
-
function step(op) {
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
17
|
-
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;
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
19
|
-
switch (op[0]) {
|
20
|
-
case 0: case 1: t = op; break;
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
24
|
-
default:
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
29
|
-
if (t[2]) _.ops.pop();
|
30
|
-
_.trys.pop(); continue;
|
31
|
-
}
|
32
|
-
op = body.call(thisArg, _);
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
35
|
-
}
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
36
4
|
};
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
return ar;
|
52
|
-
};
|
53
|
-
var _this = this;
|
54
|
-
var path = require("path");
|
55
|
-
var express = require("express");
|
56
|
-
var getPort = require("get-port");
|
57
|
-
var _a = require("@medusajs/utils"), isObject = _a.isObject, promiseAll = _a.promiseAll;
|
58
|
-
var GracefulShutdownServer = require("medusa-core-utils").GracefulShutdownServer;
|
59
|
-
function bootstrapApp(_a) {
|
60
|
-
var _b = _a === void 0 ? {} : _a, cwd = _b.cwd, _c = _b.env, env = _c === void 0 ? {} : _c;
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
62
|
-
var app, loaders, _d, container, shutdown, PORT;
|
63
|
-
return __generator(this, function (_e) {
|
64
|
-
switch (_e.label) {
|
65
|
-
case 0:
|
66
|
-
app = express();
|
67
|
-
if (isObject(env)) {
|
68
|
-
Object.entries(env).forEach(function (_a) {
|
69
|
-
var _b = __read(_a, 2), k = _b[0], v = _b[1];
|
70
|
-
return (process.env[k] = v);
|
71
|
-
});
|
72
|
-
}
|
73
|
-
loaders = require("@medusajs/medusa/dist/loaders").default;
|
74
|
-
return [4 /*yield*/, loaders({
|
75
|
-
directory: path.resolve(cwd || process.cwd()),
|
76
|
-
expressApp: app,
|
77
|
-
isTest: false,
|
78
|
-
})];
|
79
|
-
case 1:
|
80
|
-
_d = _e.sent(), container = _d.container, shutdown = _d.shutdown;
|
81
|
-
return [4 /*yield*/, getPort()];
|
82
|
-
case 2:
|
83
|
-
PORT = _e.sent();
|
84
|
-
return [2 /*return*/, {
|
85
|
-
shutdown: shutdown,
|
86
|
-
container: container,
|
87
|
-
app: app,
|
88
|
-
port: PORT,
|
89
|
-
}];
|
90
|
-
}
|
91
|
-
});
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.startApp = startApp;
|
7
|
+
const express_1 = __importDefault(require("express"));
|
8
|
+
const get_port_1 = __importDefault(require("get-port"));
|
9
|
+
const path_1 = require("path");
|
10
|
+
const utils_1 = require("./utils");
|
11
|
+
const utils_2 = require("@medusajs/framework/utils");
|
12
|
+
async function bootstrapApp({ cwd, env = {}, } = {}) {
|
13
|
+
const app = (0, express_1.default)();
|
14
|
+
(0, utils_1.applyEnvVarsToProcess)(env);
|
15
|
+
const loaders = require("@medusajs/medusa/loaders/index").default;
|
16
|
+
const { container, shutdown } = await loaders({
|
17
|
+
directory: (0, path_1.resolve)(cwd || process.cwd()),
|
18
|
+
expressApp: app,
|
92
19
|
});
|
20
|
+
const PORT = process.env.PORT ? parseInt(process.env.PORT) : await (0, get_port_1.default)();
|
21
|
+
return {
|
22
|
+
shutdown,
|
23
|
+
container,
|
24
|
+
app,
|
25
|
+
port: PORT,
|
26
|
+
};
|
93
27
|
}
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
}
|
120
|
-
return [2 /*return*/];
|
121
|
-
}
|
122
|
-
});
|
123
|
-
}); };
|
124
|
-
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
125
|
-
var server = app.listen(port, function (err) { return __awaiter(_this, void 0, void 0, function () {
|
126
|
-
return __generator(this, function (_a) {
|
127
|
-
switch (_a.label) {
|
128
|
-
case 0:
|
129
|
-
if (!err) return [3 /*break*/, 2];
|
130
|
-
return [4 /*yield*/, shutdown()];
|
131
|
-
case 1:
|
132
|
-
_a.sent();
|
133
|
-
return [2 /*return*/, reject(err)];
|
134
|
-
case 2:
|
135
|
-
process.send(port);
|
136
|
-
resolve({
|
137
|
-
shutdown: shutdown,
|
138
|
-
container: container,
|
139
|
-
port: port,
|
140
|
-
});
|
141
|
-
return [2 /*return*/];
|
142
|
-
}
|
143
|
-
});
|
144
|
-
}); });
|
145
|
-
expressServer = GracefulShutdownServer.create(server);
|
146
|
-
})];
|
147
|
-
case 2: return [2 /*return*/, _f.sent()];
|
148
|
-
}
|
28
|
+
async function startApp({ cwd, env = {}, } = {}) {
|
29
|
+
const { app, port, container, shutdown: medusaShutdown, } = await bootstrapApp({
|
30
|
+
cwd,
|
31
|
+
env,
|
32
|
+
});
|
33
|
+
let expressServer;
|
34
|
+
const shutdown = async () => {
|
35
|
+
await (0, utils_2.promiseAll)([expressServer?.shutdown(), medusaShutdown()]);
|
36
|
+
if (typeof global !== "undefined" && global?.gc) {
|
37
|
+
global.gc();
|
38
|
+
}
|
39
|
+
};
|
40
|
+
return await new Promise((resolve, reject) => {
|
41
|
+
const server = app
|
42
|
+
.listen(port)
|
43
|
+
.on("error", async (err) => {
|
44
|
+
await shutdown();
|
45
|
+
return reject(err);
|
46
|
+
})
|
47
|
+
.on("listening", () => {
|
48
|
+
process.send?.(port);
|
49
|
+
resolve({
|
50
|
+
shutdown,
|
51
|
+
container,
|
52
|
+
port,
|
149
53
|
});
|
150
54
|
});
|
151
|
-
|
152
|
-
|
55
|
+
// TODO: fix that once we find the appropriate place to put this util
|
56
|
+
expressServer = utils_2.GracefulShutdownServer.create(server);
|
57
|
+
});
|
58
|
+
}
|
153
59
|
//# sourceMappingURL=bootstrap-app.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bootstrap-app.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/bootstrap-app.
|
1
|
+
{"version":3,"file":"bootstrap-app.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/bootstrap-app.ts"],"names":[],"mappings":";;;;;AA+BA,4BAgDC;AA/ED,sDAA6B;AAC7B,wDAA8B;AAC9B,+BAA8B;AAE9B,mCAA+C;AAC/C,qDAA8E;AAE9E,KAAK,UAAU,YAAY,CAAC,EAC1B,GAAG,EACH,GAAG,GAAG,EAAE,MACoC,EAAE;IAC9C,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAA;IACrB,IAAA,6BAAqB,EAAC,GAAG,CAAC,CAAA;IAE1B,MAAM,OAAO,GAAG,OAAO,CAAC,gCAAgC,CAAC,CAAC,OAAO,CAAA;IAEjE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,OAAO,CAAC;QAC5C,SAAS,EAAE,IAAA,cAAO,EAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACxC,UAAU,EAAE,GAAG;KAChB,CAAC,CAAA;IAEF,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,kBAAO,GAAE,CAAA;IAE5E,OAAO;QACL,QAAQ;QACR,SAAS;QACT,GAAG;QACH,IAAI,EAAE,IAAI;KACX,CAAA;AACH,CAAC;AAEM,KAAK,UAAU,QAAQ,CAAC,EAC7B,GAAG,EACH,GAAG,GAAG,EAAE,MACoC,EAAE;IAK9C,MAAM,EACJ,GAAG,EACH,IAAI,EACJ,SAAS,EACT,QAAQ,EAAE,cAAc,GACzB,GAAG,MAAM,YAAY,CAAC;QACrB,GAAG;QACH,GAAG;KACJ,CAAC,CAAA;IAEF,IAAI,aAAa,CAAA;IAEjB,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;QAC1B,MAAM,IAAA,kBAAU,EAAC,CAAC,aAAa,EAAE,QAAQ,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC,CAAA;QAE/D,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,EAAE,EAAE,EAAE,CAAC;YAChD,MAAM,CAAC,EAAE,EAAE,CAAA;QACb,CAAC;IACH,CAAC,CAAA;IAED,OAAO,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,MAAM,GAAG,GAAG;aACf,MAAM,CAAC,IAAI,CAAC;aACZ,EAAE,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YACzB,MAAM,QAAQ,EAAE,CAAA;YAChB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;QACpB,CAAC,CAAC;aACD,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE;YACpB,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAA;YAEpB,OAAO,CAAC;gBACN,QAAQ;gBACR,SAAS;gBACT,IAAI;aACL,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QAEJ,qEAAqE;QACrE,aAAa,GAAG,8BAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* cleanup temporary created resources for the migrations
|
3
|
+
* @internal I didnt find a god place to put that, should we eventually add a close function
|
4
|
+
* to the planner to handle that part? so that you would do planner.close() and it will handle the cleanup
|
5
|
+
* automatically just like we usually do for the classic migrations actions
|
6
|
+
*/
|
7
|
+
export declare function clearInstances(): Promise<void>;
|
8
|
+
//# sourceMappingURL=clear-instances.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"clear-instances.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/clear-instances.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAsB,cAAc,kBAGnC"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.clearInstances = clearInstances;
|
4
|
+
/**
|
5
|
+
* cleanup temporary created resources for the migrations
|
6
|
+
* @internal I didnt find a god place to put that, should we eventually add a close function
|
7
|
+
* to the planner to handle that part? so that you would do planner.close() and it will handle the cleanup
|
8
|
+
* automatically just like we usually do for the classic migrations actions
|
9
|
+
*/
|
10
|
+
async function clearInstances() {
|
11
|
+
const { MedusaModule } = require("@medusajs/framework/modules-sdk");
|
12
|
+
MedusaModule.clearInstances();
|
13
|
+
}
|
14
|
+
//# sourceMappingURL=clear-instances.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"clear-instances.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/clear-instances.ts"],"names":[],"mappings":";;AAMA,wCAGC;AATD;;;;;GAKG;AACI,KAAK,UAAU,cAAc;IAClC,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,iCAAiC,CAAC,CAAA;IACnE,YAAY,CAAC,cAAc,EAAE,CAAA;AAC/B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/config.ts"],"names":[],"mappings":"AAEA,wBAAsB,oBAAoB,CACxC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,iBA4BjD"}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.configLoaderOverride = configLoaderOverride;
|
4
|
+
const utils_1 = require("@medusajs/framework/utils");
|
5
|
+
async function configLoaderOverride(entryDirectory, override) {
|
6
|
+
const { configManager } = await import("@medusajs/framework/config");
|
7
|
+
const { configModule, error } = (0, utils_1.getConfigFile)(entryDirectory, "medusa-config.js");
|
8
|
+
if (error) {
|
9
|
+
throw new Error(error.message || "Error during config loading");
|
10
|
+
}
|
11
|
+
configModule.projectConfig.databaseDriverOptions;
|
12
|
+
configModule.projectConfig.databaseUrl = override.clientUrl;
|
13
|
+
configModule.projectConfig.databaseLogging = !!override.debug;
|
14
|
+
configModule.projectConfig.databaseDriverOptions =
|
15
|
+
override.clientUrl.includes("localhost")
|
16
|
+
? {}
|
17
|
+
: {
|
18
|
+
connection: {
|
19
|
+
ssl: { rejectUnauthorized: false },
|
20
|
+
},
|
21
|
+
idle_in_transaction_session_timeout: 20000,
|
22
|
+
};
|
23
|
+
configManager.loadConfig({
|
24
|
+
projectConfig: configModule,
|
25
|
+
baseDir: entryDirectory,
|
26
|
+
});
|
27
|
+
}
|
28
|
+
//# sourceMappingURL=config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/config.ts"],"names":[],"mappings":";;AAEA,oDA8BC;AAhCD,qDAAyD;AAElD,KAAK,UAAU,oBAAoB,CACxC,cAAsB,EACtB,QAAgD;IAEhD,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAA;IACpE,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,IAAA,qBAAa,EAE3C,cAAc,EAAE,kBAAkB,CAAC,CAAA;IAErC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,6BAA6B,CAAC,CAAA;IACjE,CAAC;IAED,YAAY,CAAC,aAAa,CAAC,qBAAqB,CAAA;IAChD,YAAY,CAAC,aAAa,CAAC,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAA;IAC3D,YAAY,CAAC,aAAa,CAAC,eAAe,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAA;IAC7D,YAAY,CAAC,aAAa,CAAC,qBAAqB;QAC9C,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC;YACtC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,UAAU,EAAE;oBACV,GAAG,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE;iBACnC;gBACD,mCAAmC,EAAE,KAAK;aAC3C,CAAA;IAEP,aAAa,CAAC,UAAU,CAAC;QACvB,aAAa,EAAE,YAAY;QAC3B,OAAO,EAAE,cAAc;KACxB,CAAC,CAAA;AACJ,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/medusa-test-runner-utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
@@ -0,0 +1,22 @@
|
|
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("./bootstrap-app"), exports);
|
18
|
+
__exportStar(require("./clear-instances"), exports);
|
19
|
+
__exportStar(require("./config"), exports);
|
20
|
+
__exportStar(require("./use-db"), exports);
|
21
|
+
__exportStar(require("./utils"), exports);
|
22
|
+
//# sourceMappingURL=index.js.map
|