@tsed/testcontainers-mongo 8.0.0-alpha.5 → 8.0.0-alpha.7
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/lib/esm/services/ContainerUtils.js +0 -3
- package/lib/esm/services/ContainerUtils.js.map +1 -1
- package/lib/esm/services/TestContainersMongo.js.map +1 -1
- package/lib/types/services/ContainerUtils.d.ts +26 -2
- package/package.json +15 -16
- package/lib/cjs/index.js +0 -5
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/services/ContainerUtils.js +0 -63
- package/lib/cjs/services/ContainerUtils.js.map +0 -1
- package/lib/cjs/services/TestContainersMongo.js +0 -50
- package/lib/cjs/services/TestContainersMongo.js.map +0 -1
- package/lib/cjs/setup/vi.setup.js +0 -13
- package/lib/cjs/setup/vi.setup.js.map +0 -1
- package/lib/esm/package.json +0 -3
- package/lib/types-esm/index.d.ts +0 -1
- package/lib/types-esm/services/ContainerUtils.d.ts +0 -27
- package/lib/types-esm/services/TestContainersMongo.d.ts +0 -41
- package/lib/types-esm/setup/vi.setup.d.ts +0 -2
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { MongoDBContainer } from "@testcontainers/mongodb";
|
|
2
2
|
const KEY = "TEST_CONTAINER_MONGO";
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
4
3
|
// @ts-ignore
|
|
5
4
|
global[KEY] = null;
|
|
6
5
|
function getEnvironment(key) {
|
|
7
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
8
6
|
// @ts-ignore
|
|
9
7
|
return global[key];
|
|
10
8
|
}
|
|
11
9
|
function setEnvironment(key, environment) {
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
13
10
|
// @ts-ignore
|
|
14
11
|
global[key] = environment;
|
|
15
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerUtils.js","sourceRoot":"","sources":["../../../src/services/ContainerUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContainerUtils.js","sourceRoot":"","sources":["../../../src/services/ContainerUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,gBAAgB,EAA0B,MAAM,yBAAyB,CAAC;AAWlF,MAAM,GAAG,GAAG,sBAAsB,CAAC;AAEnC,aAAa;AACb,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAEnB,SAAS,cAAc,CAAI,GAAW;IACpC,aAAa;IACb,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,cAAc,CAAC,GAAW,EAAE,WAAoB;IACvD,aAAa;IACb,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;AAC5B,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAK,GAAG,aAAa;IACjD,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;AAC7C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAc;IACnD,yBAAyB;IACzB,MAAM,SAAS,GAAG,cAAc,CAA0B,GAAG,CAAC,IAAI,CAAC,MAAM,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;IAEtG,cAAc,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAE/B,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,mBAAmB,EAAE,CAAC;IAExD,OAAO;QACL,SAAS;QACT,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS;KAC3B,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,SAAS,GAAG,cAAc,CAA0B,GAAG,CAAC,CAAC;IAE/D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAChD,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,OAAO,CAAC,GAAG,CAAC,SAAmB,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,EAAU,EACV,OAAuB,EAAE;IAMzB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;IAC/C,MAAM,EAAC,MAAM,GAAG,SAAS,EAAE,GAAG,SAAS,EAAC,GAAG,IAAI,CAAC;IAChD,MAAM,GAAG,GAAG,GAAG,WAAW,EAAE,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;IAEjD,OAAO;QACL,EAAE;QACF,GAAG;QACH,iBAAiB,EAAE;YACjB,gBAAgB,EAAE,IAAI;YACtB,GAAG,SAAS;SACY;KAC3B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,OAA0B,EAAE;IACrE,OAAO,CAAC,yBAAyB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TestContainersMongo.js","sourceRoot":"","sources":["../../../src/services/TestContainersMongo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"TestContainersMongo.js","sourceRoot":"","sources":["../../../src/services/TestContainersMongo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEpC,OAAO,EAAC,yBAAyB,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAE7H,MAAM,OAAO,mBAAmB;aACvB,qBAAgB,G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CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACnD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,OAAO,CAAC,KAAK,CAAC,cAAc,cAAc,eAAe,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC"}
|
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="mongoose/types/aggregate.js" />
|
|
3
|
+
/// <reference types="mongoose/types/callback.js" />
|
|
4
|
+
/// <reference types="mongoose/types/collection.js" />
|
|
5
|
+
/// <reference types="mongoose/types/connection.js" />
|
|
6
|
+
/// <reference types="mongoose/types/cursor.js" />
|
|
7
|
+
/// <reference types="mongoose/types/document.js" />
|
|
8
|
+
/// <reference types="mongoose/types/error.js" />
|
|
9
|
+
/// <reference types="mongoose/types/expressions.js" />
|
|
10
|
+
/// <reference types="mongoose/types/helpers.js" />
|
|
11
|
+
/// <reference types="mongoose/types/middlewares.js" />
|
|
12
|
+
/// <reference types="mongoose/types/indexes.js" />
|
|
13
|
+
/// <reference types="mongoose/types/models.js" />
|
|
14
|
+
/// <reference types="mongoose/types/mongooseoptions.js" />
|
|
15
|
+
/// <reference types="mongoose/types/pipelinestage.js" />
|
|
16
|
+
/// <reference types="mongoose/types/populate.js" />
|
|
17
|
+
/// <reference types="mongoose/types/query.js" />
|
|
18
|
+
/// <reference types="mongoose/types/schemaoptions.js" />
|
|
19
|
+
/// <reference types="mongoose/types/schematypes.js" />
|
|
20
|
+
/// <reference types="mongoose/types/session.js" />
|
|
21
|
+
/// <reference types="mongoose/types/types.js" />
|
|
22
|
+
/// <reference types="mongoose/types/utility.js" />
|
|
23
|
+
/// <reference types="mongoose/types/validation.js" />
|
|
24
|
+
/// <reference types="mongoose/types/virtuals.js" />
|
|
25
|
+
/// <reference types="mongoose/types/inferschematype.js" />
|
|
26
|
+
import type { ConnectionOptions } from "node:tls";
|
|
2
27
|
import { StartedMongoDBContainer } from "@testcontainers/mongodb";
|
|
3
28
|
import type { ConnectOptions } from "mongoose";
|
|
4
|
-
import type { ConnectionOptions } from "node:tls";
|
|
5
29
|
declare global {
|
|
6
30
|
namespace NodeJS {
|
|
7
31
|
interface Global {
|
package/package.json
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/testcontainers-mongo",
|
|
3
3
|
"description": "A module to test Ts.ED code that use MongoDB as database using Test Containers",
|
|
4
|
-
"type": "
|
|
5
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "8.0.0-alpha.7",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
|
-
"main": "./lib/
|
|
7
|
+
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
9
9
|
"typings": "./lib/types/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./lib/types/index.d.ts",
|
|
13
13
|
"import": "./lib/esm/index.js",
|
|
14
|
-
"require": "./lib/cjs/index.js",
|
|
15
14
|
"default": "./lib/cjs/index.js"
|
|
16
15
|
},
|
|
17
16
|
"./vitest/setup": {
|
|
18
17
|
"types": "./lib/types/setup/vi.setup.d.ts",
|
|
19
18
|
"import": "./lib/esm/setup/vi.setup.js",
|
|
20
|
-
"default": "./lib/
|
|
19
|
+
"default": "./lib/esm/setup/vi.setup.js"
|
|
21
20
|
}
|
|
22
21
|
},
|
|
23
22
|
"scripts": {
|
|
@@ -26,25 +25,25 @@
|
|
|
26
25
|
},
|
|
27
26
|
"dependencies": {
|
|
28
27
|
"semver": "^7.6.0",
|
|
29
|
-
"tslib": "2.
|
|
28
|
+
"tslib": "2.7.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@testcontainers/mongodb": ">=10.11.0",
|
|
33
|
-
"@tsed/barrels": "8.0.0-alpha.
|
|
34
|
-
"@tsed/common": "8.0.0-alpha.
|
|
35
|
-
"@tsed/core": "8.0.0-alpha.
|
|
36
|
-
"@tsed/di": "8.0.0-alpha.
|
|
37
|
-
"@tsed/typescript": "8.0.0-alpha.
|
|
38
|
-
"eslint": "
|
|
32
|
+
"@tsed/barrels": "8.0.0-alpha.7",
|
|
33
|
+
"@tsed/common": "8.0.0-alpha.7",
|
|
34
|
+
"@tsed/core": "8.0.0-alpha.7",
|
|
35
|
+
"@tsed/di": "8.0.0-alpha.7",
|
|
36
|
+
"@tsed/typescript": "8.0.0-alpha.7",
|
|
37
|
+
"eslint": "9.11.1",
|
|
39
38
|
"mongodb": "6.8.0",
|
|
40
39
|
"testcontainers": ">=10.11.0",
|
|
41
|
-
"typescript": "4.
|
|
40
|
+
"typescript": "5.4.5"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
44
43
|
"@testcontainers/mongodb": ">=10.11.0",
|
|
45
|
-
"@tsed/common": "8.0.0-alpha.
|
|
46
|
-
"@tsed/core": "8.0.0-alpha.
|
|
47
|
-
"@tsed/di": "8.0.0-alpha.
|
|
44
|
+
"@tsed/common": "8.0.0-alpha.7",
|
|
45
|
+
"@tsed/core": "8.0.0-alpha.7",
|
|
46
|
+
"@tsed/di": "8.0.0-alpha.7",
|
|
48
47
|
"mongodb": ">=6",
|
|
49
48
|
"testcontainers": ">=10.11.0"
|
|
50
49
|
},
|
package/lib/cjs/index.js
DELETED
package/lib/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,4EAAkD"}
|
package/lib/cjs/package.json
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMongoConnectionsOptions = exports.getMongoConnectionOptions = exports.getMongoUrl = exports.stopMongoServer = exports.startMongoServer = void 0;
|
|
4
|
-
const mongodb_1 = require("@testcontainers/mongodb");
|
|
5
|
-
const KEY = "TEST_CONTAINER_MONGO";
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
global[KEY] = null;
|
|
9
|
-
function getEnvironment(key) {
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
return global[key];
|
|
13
|
-
}
|
|
14
|
-
function setEnvironment(key, environment) {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
global[key] = environment;
|
|
18
|
-
}
|
|
19
|
-
function createMongoContainer(image = "mongo:6.0.1") {
|
|
20
|
-
return new mongodb_1.MongoDBContainer(image).start();
|
|
21
|
-
}
|
|
22
|
-
async function startMongoServer(image) {
|
|
23
|
-
// await stopMockServer()
|
|
24
|
-
const container = getEnvironment(KEY) || (await createMongoContainer(image));
|
|
25
|
-
setEnvironment(KEY, container);
|
|
26
|
-
process.env.MONGO_URL = container.getConnectionString();
|
|
27
|
-
return {
|
|
28
|
-
container,
|
|
29
|
-
url: process.env.MONGO_URL
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
exports.startMongoServer = startMongoServer;
|
|
33
|
-
async function stopMongoServer() {
|
|
34
|
-
const container = getEnvironment(KEY);
|
|
35
|
-
process.stdout.write("Stopping mongo server\n");
|
|
36
|
-
if (container) {
|
|
37
|
-
await container.stop();
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.stopMongoServer = stopMongoServer;
|
|
41
|
-
function getMongoUrl() {
|
|
42
|
-
return process.env.MONGO_URL;
|
|
43
|
-
}
|
|
44
|
-
exports.getMongoUrl = getMongoUrl;
|
|
45
|
-
function getMongoConnectionOptions(id, opts = {}) {
|
|
46
|
-
const seed = Math.floor(Math.random() * 10000);
|
|
47
|
-
const { dbName = "db-test", ...otherOpts } = opts;
|
|
48
|
-
const url = `${getMongoUrl()}/${dbName}-${seed}`;
|
|
49
|
-
return {
|
|
50
|
-
id,
|
|
51
|
-
url,
|
|
52
|
-
connectionOptions: {
|
|
53
|
-
directConnection: true,
|
|
54
|
-
...otherOpts
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
exports.getMongoConnectionOptions = getMongoConnectionOptions;
|
|
59
|
-
function getMongoConnectionsOptions(opts = {}) {
|
|
60
|
-
return [getMongoConnectionOptions("default", opts)];
|
|
61
|
-
}
|
|
62
|
-
exports.getMongoConnectionsOptions = getMongoConnectionsOptions;
|
|
63
|
-
//# sourceMappingURL=ContainerUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContainerUtils.js","sourceRoot":"","sources":["../../../src/services/ContainerUtils.ts"],"names":[],"mappings":";;;AAAA,qDAAkF;AAalF,MAAM,GAAG,GAAG,sBAAsB,CAAC;AAEnC,6DAA6D;AAC7D,aAAa;AACb,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;AAEnB,SAAS,cAAc,CAAI,GAAW;IACpC,6DAA6D;IAC7D,aAAa;IACb,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,cAAc,CAAC,GAAW,EAAE,WAAoB;IACvD,6DAA6D;IAC7D,aAAa;IACb,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC;AAC5B,CAAC;AAED,SAAS,oBAAoB,CAAC,KAAK,GAAG,aAAa;IACjD,OAAO,IAAI,0BAAgB,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;AAC7C,CAAC;AAEM,KAAK,UAAU,gBAAgB,CAAC,KAAc;IACnD,yBAAyB;IACzB,MAAM,SAAS,GAAG,cAAc,CAA0B,GAAG,CAAC,IAAI,CAAC,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"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TestContainersMongo = void 0;
|
|
4
|
-
const common_1 = require("@tsed/common");
|
|
5
|
-
const mongodb_1 = require("mongodb");
|
|
6
|
-
const ContainerUtils_js_1 = require("./ContainerUtils.js");
|
|
7
|
-
class TestContainersMongo {
|
|
8
|
-
static { this.startMongoServer = ContainerUtils_js_1.startMongoServer; }
|
|
9
|
-
static { this.stopMongoServer = ContainerUtils_js_1.stopMongoServer; }
|
|
10
|
-
static { this.getMongoConnectionsOptions = ContainerUtils_js_1.getMongoConnectionsOptions; }
|
|
11
|
-
static { this.getMongoConnectionOptions = ContainerUtils_js_1.getMongoConnectionOptions; }
|
|
12
|
-
static create(options = {}) {
|
|
13
|
-
TestContainersMongo.configuration = (0, ContainerUtils_js_1.getMongoConnectionsOptions)();
|
|
14
|
-
return common_1.PlatformTest.create({
|
|
15
|
-
...options,
|
|
16
|
-
mongoose: TestContainersMongo.configuration
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
static bootstrap(mod, opts = {}) {
|
|
20
|
-
return () => {
|
|
21
|
-
TestContainersMongo.configuration = (0, ContainerUtils_js_1.getMongoConnectionsOptions)();
|
|
22
|
-
return common_1.PlatformTest.bootstrap(mod, {
|
|
23
|
-
mongoose: TestContainersMongo.configuration,
|
|
24
|
-
...opts
|
|
25
|
-
})();
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
static async reset(collectionName) {
|
|
29
|
-
if (typeof collectionName === "string") {
|
|
30
|
-
await TestContainersMongo.cleanCollection(collectionName);
|
|
31
|
-
}
|
|
32
|
-
return common_1.PlatformTest.reset();
|
|
33
|
-
}
|
|
34
|
-
static async cleanCollection(collectionName, mongoSettings = TestContainersMongo.configuration) {
|
|
35
|
-
try {
|
|
36
|
-
const client = new mongodb_1.MongoClient(mongoSettings[0].url, {
|
|
37
|
-
directConnection: true
|
|
38
|
-
});
|
|
39
|
-
await client.connect();
|
|
40
|
-
const db = client.db();
|
|
41
|
-
await db.collection(collectionName).deleteMany({});
|
|
42
|
-
await client.close();
|
|
43
|
-
}
|
|
44
|
-
catch (er) {
|
|
45
|
-
console.error(`Collection ${collectionName} not found. ${er.message} ${er.stack}`);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.TestContainersMongo = TestContainersMongo;
|
|
50
|
-
//# sourceMappingURL=TestContainersMongo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TestContainersMongo.js","sourceRoot":"","sources":["../../../src/services/TestContainersMongo.ts"],"names":[],"mappings":";;;AAAA,yCAA0C;AAC1C,qCAAoC;AACpC,2DAA6H;AAE7H,MAAa,mBAAmB;aACvB,qBAAgB,GAAG,oCAAgB,CAAC;aACpC,oBAAe,GAAG,mCAAe,CAAC;aAClC,+BAA0B,GAAG,8CAA0B,CAAC;aACxD,8BAAyB,GAAG,6CAAyB,CAAC;IAI7D,MAAM,CAAC,MAAM,CAAC,UAAuC,EAAE;QACrD,mBAAmB,CAAC,aAAa,GAAG,IAAA,8CAA0B,GAAE,CAAC;QAEjE,OAAO,qBAAY,CAAC,MAAM,CAAC;YACzB,GAAG,OAAO;YACV,QAAQ,EAAE,mBAAmB,CAAC,aAAa;SAC5C,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,GAAY,EAAE,OAAoC,EAAE;QACnE,OAAO,GAAG,EAAE;YACV,mBAAmB,CAAC,aAAa,GAAG,IAAA,8CAA0B,GAAE,CAAC;YACjE,OAAO,qBAAY,CAAC,SAAS,CAAC,GAAG,EAAE;gBACjC,QAAQ,EAAE,mBAAmB,CAAC,aAAa;gBAC3C,GAAG,IAAI;aACR,CAAC,EAAE,CAAC;QACP,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,cAAuB;QACxC,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;YACtC,MAAM,mBAAmB,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;SAC3D;QAED,OAAO,qBAAY,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,cAAsB,EAAE,aAAa,GAAG,mBAAmB,CAAC,aAAa;QACpG,IAAI;YACF,MAAM,MAAM,GAAG,IAAI,qBAAW,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE;gBACnD,gBAAgB,EAAE,IAAI;aACvB,CAAC,CAAC;YAEH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;YACvB,MAAM,EAAE,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;YACvB,MAAM,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;YACnD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;SACtB;QAAC,OAAO,EAAE,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,cAAc,cAAc,eAAe,EAAE,CAAC,OAAO,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;SACpF;IACH,CAAC;;AAhDH,kDAiDC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.teardown = exports.setup = void 0;
|
|
4
|
-
const ContainerUtils_js_1 = require("../services/ContainerUtils.js");
|
|
5
|
-
async function setup() {
|
|
6
|
-
await (0, ContainerUtils_js_1.startMongoServer)();
|
|
7
|
-
}
|
|
8
|
-
exports.setup = setup;
|
|
9
|
-
async function teardown() {
|
|
10
|
-
await (0, ContainerUtils_js_1.stopMongoServer)();
|
|
11
|
-
}
|
|
12
|
-
exports.teardown = teardown;
|
|
13
|
-
//# sourceMappingURL=vi.setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vi.setup.js","sourceRoot":"","sources":["../../../src/setup/vi.setup.ts"],"names":[],"mappings":";;;AAAA,qEAAgF;AAEzE,KAAK,UAAU,KAAK;IACzB,MAAM,IAAA,oCAAgB,GAAE,CAAC;AAC3B,CAAC;AAFD,sBAEC;AAEM,KAAK,UAAU,QAAQ;IAC5B,MAAM,IAAA,mCAAe,GAAE,CAAC;AAC1B,CAAC;AAFD,4BAEC"}
|
package/lib/esm/package.json
DELETED
package/lib/types-esm/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./services/TestContainersMongo.js";
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { StartedMongoDBContainer } from "@testcontainers/mongodb";
|
|
3
|
-
import type { ConnectOptions } from "mongoose";
|
|
4
|
-
import type { ConnectionOptions } from "node:tls";
|
|
5
|
-
declare global {
|
|
6
|
-
namespace NodeJS {
|
|
7
|
-
interface Global {
|
|
8
|
-
TEST_CONTAINER_MONGO: StartedMongoDBContainer | null;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare function startMongoServer(image?: string): Promise<{
|
|
13
|
-
container: StartedMongoDBContainer;
|
|
14
|
-
url: string;
|
|
15
|
-
}>;
|
|
16
|
-
export declare function stopMongoServer(): Promise<void>;
|
|
17
|
-
export declare function getMongoUrl(): string;
|
|
18
|
-
export declare function getMongoConnectionOptions(id: string, opts?: ConnectOptions): {
|
|
19
|
-
id: string;
|
|
20
|
-
url: string;
|
|
21
|
-
connectionOptions: ConnectOptions;
|
|
22
|
-
};
|
|
23
|
-
export declare function getMongoConnectionsOptions(opts?: ConnectionOptions): {
|
|
24
|
-
id: string;
|
|
25
|
-
url: string;
|
|
26
|
-
connectionOptions: ConnectOptions;
|
|
27
|
-
}[];
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/// <reference types="mongoose/types/aggregate.js" />
|
|
2
|
-
/// <reference types="mongoose/types/callback.js" />
|
|
3
|
-
/// <reference types="mongoose/types/collection.js" />
|
|
4
|
-
/// <reference types="mongoose/types/connection.js" />
|
|
5
|
-
/// <reference types="mongoose/types/cursor.js" />
|
|
6
|
-
/// <reference types="mongoose/types/document.js" />
|
|
7
|
-
/// <reference types="mongoose/types/error.js" />
|
|
8
|
-
/// <reference types="mongoose/types/expressions.js" />
|
|
9
|
-
/// <reference types="mongoose/types/helpers.js" />
|
|
10
|
-
/// <reference types="mongoose/types/middlewares.js" />
|
|
11
|
-
/// <reference types="mongoose/types/indexes.js" />
|
|
12
|
-
/// <reference types="mongoose/types/models.js" />
|
|
13
|
-
/// <reference types="mongoose/types/mongooseoptions.js" />
|
|
14
|
-
/// <reference types="mongoose/types/pipelinestage.js" />
|
|
15
|
-
/// <reference types="mongoose/types/populate.js" />
|
|
16
|
-
/// <reference types="mongoose/types/query.js" />
|
|
17
|
-
/// <reference types="mongoose/types/schemaoptions.js" />
|
|
18
|
-
/// <reference types="mongoose/types/schematypes.js" />
|
|
19
|
-
/// <reference types="mongoose/types/session.js" />
|
|
20
|
-
/// <reference types="mongoose/types/types.js" />
|
|
21
|
-
/// <reference types="mongoose/types/utility.js" />
|
|
22
|
-
/// <reference types="mongoose/types/validation.js" />
|
|
23
|
-
/// <reference types="mongoose/types/virtuals.js" />
|
|
24
|
-
/// <reference types="mongoose" />
|
|
25
|
-
/// <reference types="mongoose/types/inferschematype.js" />
|
|
26
|
-
import { getMongoConnectionOptions, getMongoConnectionsOptions, startMongoServer, stopMongoServer } from "./ContainerUtils.js";
|
|
27
|
-
export declare class TestContainersMongo {
|
|
28
|
-
static startMongoServer: typeof startMongoServer;
|
|
29
|
-
static stopMongoServer: typeof stopMongoServer;
|
|
30
|
-
static getMongoConnectionsOptions: typeof getMongoConnectionsOptions;
|
|
31
|
-
static getMongoConnectionOptions: typeof getMongoConnectionOptions;
|
|
32
|
-
private static configuration;
|
|
33
|
-
static create(options?: Partial<TsED.Configuration>): Promise<void>;
|
|
34
|
-
static bootstrap(mod: unknown, opts?: Partial<TsED.Configuration>): () => Promise<void>;
|
|
35
|
-
static reset(collectionName?: string): Promise<void>;
|
|
36
|
-
static cleanCollection(collectionName: string, mongoSettings?: {
|
|
37
|
-
id: string;
|
|
38
|
-
url: string;
|
|
39
|
-
connectionOptions: import("mongoose").ConnectOptions;
|
|
40
|
-
}[]): Promise<void>;
|
|
41
|
-
}
|