@budibase/backend-core 2.22.14 → 2.22.16
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/index.js +6 -1
- package/dist/index.js.map +2 -2
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/src/users/users.d.ts +1 -1
- package/dist/src/users/users.js +8 -2
- package/dist/src/users/users.js.map +1 -1
- package/dist/tests/core/utilities/testContainerUtils.d.ts +25 -0
- package/dist/tests/core/utilities/testContainerUtils.js +35 -13
- package/dist/tests/core/utilities/testContainerUtils.js.map +1 -1
- package/package.json +4 -4
- package/src/users/users.ts +9 -4
- package/tests/core/utilities/testContainerUtils.ts +38 -14
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.16",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@budibase/nano": "10.1.5",
|
|
25
25
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
26
|
-
"@budibase/shared-core": "2.22.
|
|
27
|
-
"@budibase/types": "2.22.
|
|
26
|
+
"@budibase/shared-core": "2.22.16",
|
|
27
|
+
"@budibase/types": "2.22.16",
|
|
28
28
|
"@govtechsg/passport-openidconnect": "^1.0.2",
|
|
29
29
|
"aws-cloudfront-sign": "3.0.2",
|
|
30
30
|
"aws-sdk": "2.1030.0",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "4a14e2ae9fdbc95da043dae51af41e53a7cd8bb8"
|
|
100
100
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BulkDocsResponse,
|
|
1
|
+
import { BulkDocsResponse, ContextUser, DatabaseQueryOpts, SearchQuery, SearchUsersRequest, User } from "@budibase/types";
|
|
2
2
|
type GetOpts = {
|
|
3
3
|
cleanup?: boolean;
|
|
4
4
|
};
|
package/dist/src/users/users.js
CHANGED
|
@@ -35,8 +35,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
35
35
|
exports.removeAppBuilder = exports.addAppBuilder = exports.cleanseUserObject = exports.removePortalUserPermissions = exports.getCreatorCount = exports.getUserCount = exports.paginatedUsers = exports.searchGlobalUsersByEmail = exports.getGlobalUserByAppPage = exports.searchGlobalUsersByAppAccess = exports.searchGlobalUsersByApp = exports.doesUserExist = exports.getGlobalUserByEmail = exports.getById = exports.bulkUpdateGlobalUsers = exports.getAllUserIds = exports.bulkGetGlobalUsersById = exports.isSupportedUserSearch = void 0;
|
|
36
36
|
const db_1 = require("../db");
|
|
37
37
|
const types_1 = require("@budibase/types");
|
|
38
|
-
const context_1 = require("../context");
|
|
39
38
|
const context = __importStar(require("../context"));
|
|
39
|
+
const context_1 = require("../context");
|
|
40
40
|
const utils_1 = require("./utils");
|
|
41
41
|
const db_2 = require("./db");
|
|
42
42
|
function removeUserPassword(users) {
|
|
@@ -58,6 +58,7 @@ function isSupportedUserSearch(query) {
|
|
|
58
58
|
const allowed = [
|
|
59
59
|
{ op: types_1.SearchQueryOperators.STRING, key: "email" },
|
|
60
60
|
{ op: types_1.SearchQueryOperators.EQUAL, key: "_id" },
|
|
61
|
+
{ op: types_1.SearchQueryOperators.ONE_OF, key: "_id" },
|
|
61
62
|
];
|
|
62
63
|
for (let [key, operation] of Object.entries(query)) {
|
|
63
64
|
if (typeof operation !== "object") {
|
|
@@ -250,7 +251,7 @@ function searchGlobalUsersByEmail(email, opts, getOpts) {
|
|
|
250
251
|
exports.searchGlobalUsersByEmail = searchGlobalUsersByEmail;
|
|
251
252
|
const PAGE_LIMIT = 8;
|
|
252
253
|
function paginatedUsers({ bookmark, query, appId, limit, } = {}) {
|
|
253
|
-
var _a, _b, _c;
|
|
254
|
+
var _a, _b, _c, _d, _e;
|
|
254
255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
255
256
|
const db = (0, context_1.getGlobalDB)();
|
|
256
257
|
const pageSize = limit !== null && limit !== void 0 ? limit : PAGE_LIMIT;
|
|
@@ -277,6 +278,11 @@ function paginatedUsers({ bookmark, query, appId, limit, } = {}) {
|
|
|
277
278
|
userList = yield searchGlobalUsersByEmail((_c = query === null || query === void 0 ? void 0 : query.string) === null || _c === void 0 ? void 0 : _c.email, opts);
|
|
278
279
|
property = "email";
|
|
279
280
|
}
|
|
281
|
+
else if ((_d = query === null || query === void 0 ? void 0 : query.oneOf) === null || _d === void 0 ? void 0 : _d._id) {
|
|
282
|
+
userList = yield bulkGetGlobalUsersById((_e = query === null || query === void 0 ? void 0 : query.oneOf) === null || _e === void 0 ? void 0 : _e._id, {
|
|
283
|
+
cleanup: true,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
280
286
|
else {
|
|
281
287
|
// no search, query allDocs
|
|
282
288
|
const response = yield db.allDocs((0, db_1.getGlobalUserParams)(null, opts));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../../src/users/users.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAac;AACd,2CASwB;AACxB,wCAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"users.js","sourceRoot":"","sources":["../../../src/users/users.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAac;AACd,2CASwB;AACxB,oDAAqC;AACrC,wCAAwC;AACxC,mCAAmC;AACnC,6BAA6B;AAI7B,SAAS,kBAAkB,CAAC,KAAoB;IAC9C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC,G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,IAAI,uCAAJ,IAAI,GAAK,EAAE,EAAA;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACjC,MAAM,WAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAA;;CACjD;AAPD,sCAOC;AAED,SAAsB,gBAAgB,CAAC,IAAU,EAAE,KAAa;;;QAC9D,MAAM,SAAS,GAAG,IAAA,iBAAY,EAAC,KAAK,CAAC,CAAA;QACrC,IAAI,IAAI,CAAC,OAAO,KAAI,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,0CAAE,QAAQ,CAAC,SAAS,CAAC,CAAA,EAAE;YAC1D,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAA;SACrE;QACD,MAAM,WAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAA;;CACjD;AAND,4CAMC"}
|
|
@@ -1 +1,26 @@
|
|
|
1
|
+
interface ContainerInfo {
|
|
2
|
+
Command: string;
|
|
3
|
+
CreatedAt: string;
|
|
4
|
+
ID: string;
|
|
5
|
+
Image: string;
|
|
6
|
+
Labels: string;
|
|
7
|
+
LocalVolumes: string;
|
|
8
|
+
Mounts: string;
|
|
9
|
+
Names: string;
|
|
10
|
+
Networks: string;
|
|
11
|
+
Ports: string;
|
|
12
|
+
RunningFor: string;
|
|
13
|
+
Size: string;
|
|
14
|
+
State: string;
|
|
15
|
+
Status: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function getContainerByImage(image: string): ContainerInfo;
|
|
18
|
+
export declare function getContainerById(id: string): ContainerInfo | undefined;
|
|
19
|
+
export interface Port {
|
|
20
|
+
host: number;
|
|
21
|
+
container: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function getExposedV4Ports(container: ContainerInfo): Port[];
|
|
24
|
+
export declare function getExposedV4Port(container: ContainerInfo, port: number): number | undefined;
|
|
1
25
|
export declare function setupEnv(...envs: any[]): void;
|
|
26
|
+
export {};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setupEnv = void 0;
|
|
4
|
-
const db_1 = require("../../../src/db");
|
|
3
|
+
exports.setupEnv = exports.getExposedV4Port = exports.getExposedV4Ports = exports.getContainerById = exports.getContainerByImage = void 0;
|
|
5
4
|
const child_process_1 = require("child_process");
|
|
5
|
+
const IPV4_PORT_REGEX = new RegExp(`0\\.0\\.0\\.0:(\\d+)->(\\d+)/tcp`, "g");
|
|
6
6
|
function getTestcontainers() {
|
|
7
|
-
|
|
7
|
+
// We use --format json to make sure the output is nice and machine-readable,
|
|
8
|
+
// and we use --no-trunc so that the command returns full container IDs so we
|
|
9
|
+
// can filter on them correctly.
|
|
10
|
+
return (0, child_process_1.execSync)("docker ps --format json --no-trunc")
|
|
8
11
|
.toString()
|
|
9
12
|
.split("\n")
|
|
10
13
|
.filter(x => x.length > 0)
|
|
@@ -12,35 +15,54 @@ function getTestcontainers() {
|
|
|
12
15
|
.filter(x => x.Labels.includes("org.testcontainers=true"));
|
|
13
16
|
}
|
|
14
17
|
function getContainerByImage(image) {
|
|
15
|
-
|
|
18
|
+
const containers = getTestcontainers().filter(x => x.Image.startsWith(image));
|
|
19
|
+
if (containers.length > 1) {
|
|
20
|
+
let errorMessage = `Multiple containers found starting with image: "${image}"\n\n`;
|
|
21
|
+
for (const container of containers) {
|
|
22
|
+
errorMessage += JSON.stringify(container, null, 2);
|
|
23
|
+
}
|
|
24
|
+
throw new Error(errorMessage);
|
|
25
|
+
}
|
|
26
|
+
return containers[0];
|
|
16
27
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
28
|
+
exports.getContainerByImage = getContainerByImage;
|
|
29
|
+
function getContainerById(id) {
|
|
30
|
+
return getTestcontainers().find(x => x.ID === id);
|
|
31
|
+
}
|
|
32
|
+
exports.getContainerById = getContainerById;
|
|
33
|
+
function getExposedV4Ports(container) {
|
|
34
|
+
let ports = [];
|
|
35
|
+
for (const match of container.Ports.matchAll(IPV4_PORT_REGEX)) {
|
|
36
|
+
ports.push({ host: parseInt(match[1]), container: parseInt(match[2]) });
|
|
21
37
|
}
|
|
22
|
-
return
|
|
38
|
+
return ports;
|
|
39
|
+
}
|
|
40
|
+
exports.getExposedV4Ports = getExposedV4Ports;
|
|
41
|
+
function getExposedV4Port(container, port) {
|
|
42
|
+
var _a;
|
|
43
|
+
return (_a = getExposedV4Ports(container).find(x => x.container === port)) === null || _a === void 0 ? void 0 : _a.host;
|
|
23
44
|
}
|
|
45
|
+
exports.getExposedV4Port = getExposedV4Port;
|
|
24
46
|
function setupEnv(...envs) {
|
|
47
|
+
// We start couchdb in globalSetup.ts, in the root of the monorepo, so it
|
|
48
|
+
// should be relatively safe to look for it by its image name.
|
|
25
49
|
const couch = getContainerByImage("budibase/couchdb");
|
|
26
50
|
if (!couch) {
|
|
27
51
|
throw new Error("CouchDB container not found");
|
|
28
52
|
}
|
|
29
|
-
const couchPort =
|
|
53
|
+
const couchPort = getExposedV4Port(couch, 5984);
|
|
30
54
|
if (!couchPort) {
|
|
31
55
|
throw new Error("CouchDB port not found");
|
|
32
56
|
}
|
|
33
57
|
const configs = [
|
|
34
58
|
{ key: "COUCH_DB_PORT", value: `${couchPort}` },
|
|
35
|
-
{ key: "COUCH_DB_URL", value: `http://
|
|
59
|
+
{ key: "COUCH_DB_URL", value: `http://127.0.0.1:${couchPort}` },
|
|
36
60
|
];
|
|
37
61
|
for (const config of configs.filter(x => !!x.value)) {
|
|
38
62
|
for (const env of envs) {
|
|
39
63
|
env._set(config.key, config.value);
|
|
40
64
|
}
|
|
41
65
|
}
|
|
42
|
-
// @ts-expect-error
|
|
43
|
-
db_1.DatabaseImpl.nano = undefined;
|
|
44
66
|
}
|
|
45
67
|
exports.setupEnv = setupEnv;
|
|
46
68
|
//# sourceMappingURL=testContainerUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testContainerUtils.js","sourceRoot":"","sources":["../../../../tests/core/utilities/testContainerUtils.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"testContainerUtils.js","sourceRoot":"","sources":["../../../../tests/core/utilities/testContainerUtils.ts"],"names":[],"mappings":";;;AAAA,iDAAwC;AAExC,MAAM,eAAe,GAAG,IAAI,MAAM,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;AAmB3E,SAAS,iBAAiB;IACxB,6EAA6E;IAC7E,6EAA6E;IAC7E,gCAAgC;IAChC,OAAO,IAAA,wBAAQ,EAAC,oCAAoC,CAAC;SAClD,QAAQ,EAAE;SACV,KAAK,CAAC,IAAI,CAAC;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SACzB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAkB,CAAC;SACxC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,CAAA;AAC9D,CAAC;AAED,SAAgB,mBAAmB,CAAC,KAAa;IAC/C,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7E,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;QACzB,IAAI,YAAY,GAAG,mDAAmD,KAAK,OAAO,CAAA;QAClF,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YAClC,YAAY,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,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EAAE;QACd,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;KAC1C;IAED,MAAM,OAAO,GAAG;QACd,EAAE,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,EAAE;QAC/C,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,oBAAoB,SAAS,EAAE,EAAE;KAChE,CAAA;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE;QACnD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAA;SACnC;KACF;AACH,CAAC;AAvBD,4BAuBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.16",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@budibase/nano": "10.1.5",
|
|
25
25
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
26
|
-
"@budibase/shared-core": "2.22.
|
|
27
|
-
"@budibase/types": "2.22.
|
|
26
|
+
"@budibase/shared-core": "2.22.16",
|
|
27
|
+
"@budibase/types": "2.22.16",
|
|
28
28
|
"@govtechsg/passport-openidconnect": "^1.0.2",
|
|
29
29
|
"aws-cloudfront-sign": "3.0.2",
|
|
30
30
|
"aws-sdk": "2.1030.0",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "4a14e2ae9fdbc95da043dae51af41e53a7cd8bb8"
|
|
100
100
|
}
|
package/src/users/users.ts
CHANGED
|
@@ -14,16 +14,16 @@ import {
|
|
|
14
14
|
} from "../db"
|
|
15
15
|
import {
|
|
16
16
|
BulkDocsResponse,
|
|
17
|
+
ContextUser,
|
|
18
|
+
CouchFindOptions,
|
|
19
|
+
DatabaseQueryOpts,
|
|
17
20
|
SearchQuery,
|
|
18
21
|
SearchQueryOperators,
|
|
19
22
|
SearchUsersRequest,
|
|
20
23
|
User,
|
|
21
|
-
ContextUser,
|
|
22
|
-
DatabaseQueryOpts,
|
|
23
|
-
CouchFindOptions,
|
|
24
24
|
} from "@budibase/types"
|
|
25
|
-
import { getGlobalDB } from "../context"
|
|
26
25
|
import * as context from "../context"
|
|
26
|
+
import { getGlobalDB } from "../context"
|
|
27
27
|
import { isCreator } from "./utils"
|
|
28
28
|
import { UserDB } from "./db"
|
|
29
29
|
|
|
@@ -48,6 +48,7 @@ export function isSupportedUserSearch(query: SearchQuery) {
|
|
|
48
48
|
const allowed = [
|
|
49
49
|
{ op: SearchQueryOperators.STRING, key: "email" },
|
|
50
50
|
{ op: SearchQueryOperators.EQUAL, key: "_id" },
|
|
51
|
+
{ op: SearchQueryOperators.ONE_OF, key: "_id" },
|
|
51
52
|
]
|
|
52
53
|
for (let [key, operation] of Object.entries(query)) {
|
|
53
54
|
if (typeof operation !== "object") {
|
|
@@ -285,6 +286,10 @@ export async function paginatedUsers({
|
|
|
285
286
|
} else if (query?.string?.email) {
|
|
286
287
|
userList = await searchGlobalUsersByEmail(query?.string?.email, opts)
|
|
287
288
|
property = "email"
|
|
289
|
+
} else if (query?.oneOf?._id) {
|
|
290
|
+
userList = await bulkGetGlobalUsersById(query?.oneOf?._id, {
|
|
291
|
+
cleanup: true,
|
|
292
|
+
})
|
|
288
293
|
} else {
|
|
289
294
|
// no search, query allDocs
|
|
290
295
|
const response = await db.allDocs(getGlobalUserParams(null, opts))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { DatabaseImpl } from "../../../src/db"
|
|
2
1
|
import { execSync } from "child_process"
|
|
3
2
|
|
|
3
|
+
const IPV4_PORT_REGEX = new RegExp(`0\\.0\\.0\\.0:(\\d+)->(\\d+)/tcp`, "g")
|
|
4
|
+
|
|
4
5
|
interface ContainerInfo {
|
|
5
6
|
Command: string
|
|
6
7
|
CreatedAt: string
|
|
@@ -19,7 +20,10 @@ interface ContainerInfo {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
function getTestcontainers(): ContainerInfo[] {
|
|
22
|
-
|
|
23
|
+
// We use --format json to make sure the output is nice and machine-readable,
|
|
24
|
+
// and we use --no-trunc so that the command returns full container IDs so we
|
|
25
|
+
// can filter on them correctly.
|
|
26
|
+
return execSync("docker ps --format json --no-trunc")
|
|
23
27
|
.toString()
|
|
24
28
|
.split("\n")
|
|
25
29
|
.filter(x => x.length > 0)
|
|
@@ -27,32 +31,55 @@ function getTestcontainers(): ContainerInfo[] {
|
|
|
27
31
|
.filter(x => x.Labels.includes("org.testcontainers=true"))
|
|
28
32
|
}
|
|
29
33
|
|
|
30
|
-
function getContainerByImage(image: string) {
|
|
31
|
-
|
|
34
|
+
export function getContainerByImage(image: string) {
|
|
35
|
+
const containers = getTestcontainers().filter(x => x.Image.startsWith(image))
|
|
36
|
+
if (containers.length > 1) {
|
|
37
|
+
let errorMessage = `Multiple containers found starting with image: "${image}"\n\n`
|
|
38
|
+
for (const container of containers) {
|
|
39
|
+
errorMessage += JSON.stringify(container, null, 2)
|
|
40
|
+
}
|
|
41
|
+
throw new Error(errorMessage)
|
|
42
|
+
}
|
|
43
|
+
return containers[0]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function getContainerById(id: string) {
|
|
47
|
+
return getTestcontainers().find(x => x.ID === id)
|
|
32
48
|
}
|
|
33
49
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
export interface Port {
|
|
51
|
+
host: number
|
|
52
|
+
container: number
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getExposedV4Ports(container: ContainerInfo): Port[] {
|
|
56
|
+
let ports: Port[] = []
|
|
57
|
+
for (const match of container.Ports.matchAll(IPV4_PORT_REGEX)) {
|
|
58
|
+
ports.push({ host: parseInt(match[1]), container: parseInt(match[2]) })
|
|
38
59
|
}
|
|
39
|
-
return
|
|
60
|
+
return ports
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getExposedV4Port(container: ContainerInfo, port: number) {
|
|
64
|
+
return getExposedV4Ports(container).find(x => x.container === port)?.host
|
|
40
65
|
}
|
|
41
66
|
|
|
42
67
|
export function setupEnv(...envs: any[]) {
|
|
68
|
+
// We start couchdb in globalSetup.ts, in the root of the monorepo, so it
|
|
69
|
+
// should be relatively safe to look for it by its image name.
|
|
43
70
|
const couch = getContainerByImage("budibase/couchdb")
|
|
44
71
|
if (!couch) {
|
|
45
72
|
throw new Error("CouchDB container not found")
|
|
46
73
|
}
|
|
47
74
|
|
|
48
|
-
const couchPort =
|
|
75
|
+
const couchPort = getExposedV4Port(couch, 5984)
|
|
49
76
|
if (!couchPort) {
|
|
50
77
|
throw new Error("CouchDB port not found")
|
|
51
78
|
}
|
|
52
79
|
|
|
53
80
|
const configs = [
|
|
54
81
|
{ key: "COUCH_DB_PORT", value: `${couchPort}` },
|
|
55
|
-
{ key: "COUCH_DB_URL", value: `http://
|
|
82
|
+
{ key: "COUCH_DB_URL", value: `http://127.0.0.1:${couchPort}` },
|
|
56
83
|
]
|
|
57
84
|
|
|
58
85
|
for (const config of configs.filter(x => !!x.value)) {
|
|
@@ -60,7 +87,4 @@ export function setupEnv(...envs: any[]) {
|
|
|
60
87
|
env._set(config.key, config.value)
|
|
61
88
|
}
|
|
62
89
|
}
|
|
63
|
-
|
|
64
|
-
// @ts-expect-error
|
|
65
|
-
DatabaseImpl.nano = undefined
|
|
66
90
|
}
|