@budibase/worker 2.2.26 → 2.2.27
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/Dockerfile +1 -1
- package/coverage/clover.xml +1393 -1364
- package/coverage/coverage-final.json +83 -77
- package/coverage/lcov-report/index.html +133 -133
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +52 -52
- package/coverage/lcov-report/src/api/controllers/global/configs.ts.html +161 -218
- package/coverage/lcov-report/src/api/controllers/global/email.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/global/events.ts.html +136 -0
- package/coverage/lcov-report/src/api/controllers/global/index.html +85 -70
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +16 -16
- package/coverage/lcov-report/src/api/controllers/global/roles.ts.html +77 -77
- package/coverage/lcov-report/src/api/controllers/global/self.ts.html +20 -20
- package/coverage/lcov-report/src/api/controllers/global/templates.ts.html +54 -54
- package/coverage/lcov-report/src/api/controllers/global/users.ts.html +82 -43
- package/coverage/lcov-report/src/api/controllers/global/workspaces.ts.html +9 -9
- package/coverage/lcov-report/src/api/controllers/system/accounts.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/system/environment.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/system/index.html +11 -11
- package/coverage/lcov-report/src/api/controllers/system/migrations.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/system/restore.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/system/status.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/system/tenants.ts.html +7 -7
- package/coverage/lcov-report/src/api/index.html +1 -1
- package/coverage/lcov-report/src/api/index.ts.html +37 -25
- package/coverage/lcov-report/src/api/routes/global/auth.ts.html +14 -14
- package/coverage/lcov-report/src/api/routes/global/configs.ts.html +25 -25
- package/coverage/lcov-report/src/api/routes/global/email.ts.html +13 -13
- package/coverage/lcov-report/src/api/routes/global/events.ts.html +109 -0
- package/coverage/lcov-report/src/api/routes/global/index.html +37 -22
- package/coverage/lcov-report/src/api/routes/global/license.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/global/roles.ts.html +10 -10
- package/coverage/lcov-report/src/api/routes/global/self.ts.html +11 -11
- package/coverage/lcov-report/src/api/routes/global/templates.ts.html +14 -14
- package/coverage/lcov-report/src/api/routes/global/users.ts.html +62 -20
- package/coverage/lcov-report/src/api/routes/global/workspaces.ts.html +12 -12
- package/coverage/lcov-report/src/api/routes/index.html +7 -7
- package/coverage/lcov-report/src/api/routes/index.ts.html +29 -23
- package/coverage/lcov-report/src/api/routes/system/accounts.ts.html +10 -10
- package/coverage/lcov-report/src/api/routes/system/environment.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/system/index.html +15 -15
- package/coverage/lcov-report/src/api/routes/system/migrations.ts.html +10 -10
- package/coverage/lcov-report/src/api/routes/system/restore.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/system/status.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/system/tenants.ts.html +10 -10
- package/coverage/lcov-report/src/api/routes/validation/index.html +3 -3
- package/coverage/lcov-report/src/api/routes/validation/index.ts.html +2 -2
- package/coverage/lcov-report/src/api/routes/validation/users.ts.html +14 -14
- package/coverage/lcov-report/src/constants/index.html +17 -17
- package/coverage/lcov-report/src/constants/index.ts.html +77 -53
- package/coverage/lcov-report/src/constants/templates/index.html +19 -19
- package/coverage/lcov-report/src/constants/templates/index.ts.html +42 -42
- package/coverage/lcov-report/src/db/index.html +3 -3
- package/coverage/lcov-report/src/db/index.ts.html +10 -10
- package/coverage/lcov-report/src/environment.ts.html +44 -29
- package/coverage/lcov-report/src/index.html +27 -27
- package/coverage/lcov-report/src/index.ts.html +55 -55
- package/coverage/lcov-report/src/middleware/cloudRestricted.ts.html +5 -5
- package/coverage/lcov-report/src/middleware/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/globalInfoSyncUsers.ts.html +9 -9
- package/coverage/lcov-report/src/migrations/functions/index.html +11 -11
- package/coverage/lcov-report/src/migrations/index.html +15 -15
- package/coverage/lcov-report/src/migrations/index.ts.html +27 -27
- package/coverage/lcov-report/src/sdk/accounts/accounts.ts.html +13 -13
- package/coverage/lcov-report/src/sdk/accounts/index.html +13 -13
- package/coverage/lcov-report/src/sdk/accounts/index.ts.html +2 -2
- package/coverage/lcov-report/src/sdk/index.html +5 -5
- package/coverage/lcov-report/src/sdk/index.ts.html +6 -6
- package/coverage/lcov-report/src/sdk/users/events.ts.html +82 -58
- package/coverage/lcov-report/src/sdk/users/index.html +29 -29
- package/coverage/lcov-report/src/sdk/users/index.ts.html +2 -2
- package/coverage/lcov-report/src/sdk/users/users.ts.html +176 -119
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +119 -95
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +7 -7
- package/coverage/lcov-report/src/tests/api/auth.ts.html +8 -8
- package/coverage/lcov-report/src/tests/api/base.ts.html +5 -5
- package/coverage/lcov-report/src/tests/api/configs.ts.html +9 -9
- package/coverage/lcov-report/src/tests/api/email.ts.html +6 -6
- package/coverage/lcov-report/src/tests/api/environment.ts.html +6 -6
- package/coverage/lcov-report/src/tests/api/groups.ts.html +163 -0
- package/coverage/lcov-report/src/tests/api/index.html +91 -31
- package/coverage/lcov-report/src/tests/api/index.ts.html +62 -29
- package/coverage/lcov-report/src/tests/api/license.ts.html +136 -0
- package/coverage/lcov-report/src/tests/api/migrations.ts.html +8 -8
- package/coverage/lcov-report/src/tests/api/restore.ts.html +7 -7
- package/coverage/lcov-report/src/tests/api/roles.ts.html +181 -0
- package/coverage/lcov-report/src/tests/api/self.ts.html +7 -7
- package/coverage/lcov-report/src/tests/api/status.ts.html +6 -6
- package/coverage/lcov-report/src/tests/api/templates.ts.html +175 -0
- package/coverage/lcov-report/src/tests/api/tenants.ts.html +10 -10
- package/coverage/lcov-report/src/tests/api/users.ts.html +28 -25
- package/coverage/lcov-report/src/tests/controllers.ts.html +14 -14
- package/coverage/lcov-report/src/tests/index.html +34 -34
- package/coverage/lcov-report/src/tests/index.ts.html +19 -55
- package/coverage/lcov-report/src/tests/mocks/{email.js.html → email.ts.html} +5 -5
- package/coverage/lcov-report/src/tests/mocks/index.html +6 -6
- package/coverage/lcov-report/src/tests/mocks/index.ts.html +10 -10
- package/coverage/lcov-report/src/tests/structures/configs.ts.html +11 -11
- package/coverage/lcov-report/src/tests/structures/groups.ts.html +15 -15
- package/coverage/lcov-report/src/tests/structures/index.html +25 -25
- package/coverage/lcov-report/src/tests/structures/index.ts.html +17 -17
- package/coverage/lcov-report/src/tests/structures/users.ts.html +16 -16
- package/coverage/lcov-report/src/utilities/appService.ts.html +45 -18
- package/coverage/lcov-report/src/utilities/email.ts.html +28 -28
- package/coverage/lcov-report/src/utilities/fileSystem.ts.html +4 -4
- package/coverage/lcov-report/src/utilities/index.html +27 -27
- package/coverage/lcov-report/src/utilities/index.ts.html +2 -2
- package/coverage/lcov-report/src/utilities/redis.ts.html +20 -20
- package/coverage/lcov-report/src/utilities/templates.ts.html +6 -6
- package/coverage/lcov-report/src/utilities/users.ts.html +3 -3
- package/coverage/lcov.info +2777 -2582
- package/jest.config.ts +7 -2
- package/package.json +10 -7
- package/scripts/dev/manage.js +2 -2
- package/src/api/controllers/global/auth.ts +1 -1
- package/src/api/controllers/global/configs.ts +112 -131
- package/src/api/controllers/global/events.ts +17 -0
- package/src/api/controllers/global/users.ts +14 -1
- package/src/api/index.ts +4 -0
- package/src/api/routes/global/auth.ts +1 -1
- package/src/api/routes/global/configs.ts +7 -7
- package/src/api/routes/global/email.ts +1 -1
- package/src/api/routes/global/events.ts +8 -0
- package/src/api/routes/global/license.ts +1 -1
- package/src/api/routes/global/roles.ts +1 -1
- package/src/api/routes/global/self.ts +1 -1
- package/src/api/routes/global/templates.ts +1 -1
- package/src/api/routes/global/tests/groups.spec.ts +58 -0
- package/src/api/routes/global/tests/license.spec.ts +0 -2
- package/src/api/routes/global/tests/roles.spec.ts +66 -5
- package/src/api/routes/global/tests/templates.spec.ts +81 -9
- package/src/api/routes/global/tests/users.spec.ts +2 -2
- package/src/api/routes/global/users.ts +15 -1
- package/src/api/routes/global/workspaces.ts +1 -1
- package/src/api/routes/index.ts +2 -0
- package/src/api/routes/system/accounts.ts +1 -1
- package/src/api/routes/system/environment.ts +1 -1
- package/src/api/routes/system/migrations.ts +1 -1
- package/src/api/routes/system/restore.ts +1 -1
- package/src/api/routes/system/status.ts +1 -1
- package/src/api/routes/system/tenants.ts +1 -1
- package/src/api/routes/system/tests/environment.spec.ts +1 -1
- package/src/constants/index.ts +13 -5
- package/src/db/index.ts +1 -1
- package/src/environment.ts +6 -1
- package/src/index.ts +5 -5
- package/src/middleware/cloudRestricted.ts +1 -1
- package/src/sdk/users/events.ts +8 -0
- package/src/sdk/users/users.ts +23 -4
- package/src/tests/TestConfiguration.ts +11 -3
- package/src/tests/api/groups.ts +26 -0
- package/src/tests/api/index.ts +12 -1
- package/src/tests/api/license.ts +17 -0
- package/src/tests/api/roles.ts +32 -0
- package/src/tests/api/templates.ts +30 -0
- package/src/tests/api/users.ts +2 -1
- package/src/tests/index.ts +6 -18
- package/src/tests/jestEnv.ts +11 -0
- package/src/tests/jestSetup.ts +3 -15
- package/src/tests/mocks/{email.js → email.ts} +1 -1
- package/src/tests/mocks/index.ts +4 -4
- package/src/tests/structures/configs.ts +2 -2
- package/src/tests/structures/groups.ts +1 -1
- package/src/tests/structures/index.ts +4 -4
- package/src/tests/structures/users.ts +1 -1
- package/src/utilities/appService.ts +12 -3
- package/tsconfig.json +2 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI, TestAPIOpts } from "./base"
|
|
3
|
+
|
|
4
|
+
export class RolesAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
get = (opts?: TestAPIOpts) => {
|
|
10
|
+
return this.request
|
|
11
|
+
.get(`/api/global/roles`)
|
|
12
|
+
.set(this.config.defaultHeaders())
|
|
13
|
+
.expect("Content-Type", /json/)
|
|
14
|
+
.expect(opts?.status ? opts.status : 200)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
find = (appId: string, opts?: TestAPIOpts) => {
|
|
18
|
+
return this.request
|
|
19
|
+
.get(`/api/global/roles/${appId}`)
|
|
20
|
+
.set(this.config.defaultHeaders())
|
|
21
|
+
.expect("Content-Type", /json/)
|
|
22
|
+
.expect(opts?.status ? opts.status : 200)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
remove = (appId: string, opts?: TestAPIOpts) => {
|
|
26
|
+
return this.request
|
|
27
|
+
.delete(`/api/global/roles/${appId}`)
|
|
28
|
+
.set(this.config.defaultHeaders())
|
|
29
|
+
.expect("Content-Type", /json/)
|
|
30
|
+
.expect(opts?.status ? opts.status : 200)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI, TestAPIOpts } from "./base"
|
|
3
|
+
|
|
4
|
+
export class TemplatesAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
definitions = (opts?: TestAPIOpts) => {
|
|
10
|
+
return this.request
|
|
11
|
+
.get(`/api/global/template/definitions`)
|
|
12
|
+
.set(opts?.headers ? opts.headers : this.config.defaultHeaders())
|
|
13
|
+
.expect(opts?.status ? opts.status : 200)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getTemplate = (opts?: TestAPIOpts) => {
|
|
17
|
+
return this.request
|
|
18
|
+
.get(`/api/global/template`)
|
|
19
|
+
.set(opts?.headers ? opts.headers : this.config.defaultHeaders())
|
|
20
|
+
.expect(opts?.status ? opts.status : 200)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
saveTemplate = (data: any, opts?: TestAPIOpts) => {
|
|
24
|
+
return this.request
|
|
25
|
+
.post(`/api/global/template`)
|
|
26
|
+
.send(data)
|
|
27
|
+
.set(opts?.headers ? opts.headers : this.config.defaultHeaders())
|
|
28
|
+
.expect(opts?.status ? opts.status : 200)
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/tests/api/users.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
User,
|
|
6
6
|
CreateAdminUserRequest,
|
|
7
7
|
} from "@budibase/types"
|
|
8
|
-
import
|
|
8
|
+
import structures from "../structures"
|
|
9
9
|
import { generator } from "@budibase/backend-core/tests"
|
|
10
10
|
import TestConfiguration from "../TestConfiguration"
|
|
11
11
|
import { TestAPI, TestAPIOpts } from "./base"
|
|
@@ -48,6 +48,7 @@ export class UserAPI extends TestAPI {
|
|
|
48
48
|
.send({
|
|
49
49
|
password: "newpassword",
|
|
50
50
|
inviteCode: code,
|
|
51
|
+
firstName: "Ted",
|
|
51
52
|
})
|
|
52
53
|
.expect("Content-Type", /json/)
|
|
53
54
|
.expect(200)
|
package/src/tests/index.ts
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const pkg = {
|
|
9
|
-
structures,
|
|
10
|
-
generator,
|
|
11
|
-
uuid,
|
|
12
|
-
TENANT_1: structures.TENANT_1,
|
|
13
|
-
mocks,
|
|
14
|
-
TestConfiguration,
|
|
15
|
-
API,
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export = pkg
|
|
1
|
+
export { default as mocks } from "./mocks"
|
|
2
|
+
export { generator } from "@budibase/backend-core/tests"
|
|
3
|
+
export { default as TestConfiguration } from "./TestConfiguration"
|
|
4
|
+
export { default as structures } from "./structures"
|
|
5
|
+
export { default as API } from "./api"
|
|
6
|
+
export { v4 as uuid } from "uuid"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
process.env.SELF_HOSTED = "0"
|
|
2
|
+
process.env.NODE_ENV = "jest"
|
|
3
|
+
process.env.JWT_SECRET = "test-jwtsecret"
|
|
4
|
+
process.env.LOG_LEVEL = "silent"
|
|
5
|
+
process.env.MULTI_TENANCY = "1"
|
|
6
|
+
process.env.MINIO_URL = "http://localhost"
|
|
7
|
+
process.env.MINIO_ACCESS_KEY = "test"
|
|
8
|
+
process.env.MINIO_SECRET_KEY = "test"
|
|
9
|
+
process.env.PLATFORM_URL = "http://localhost:10000"
|
|
10
|
+
process.env.INTERNAL_API_KEY = "tet"
|
|
11
|
+
process.env.DISABLE_ACCOUNT_PORTAL = "0"
|
package/src/tests/jestSetup.ts
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
import env from "../environment"
|
|
2
|
-
|
|
3
|
-
env._set("SELF_HOSTED", "0")
|
|
4
|
-
env._set("NODE_ENV", "jest")
|
|
5
|
-
env._set("JWT_SECRET", "test-jwtsecret")
|
|
6
|
-
env._set("LOG_LEVEL", "silent")
|
|
7
|
-
env._set("MULTI_TENANCY", true)
|
|
8
|
-
env._set("MINIO_URL", "http://localhost")
|
|
9
|
-
env._set("MINIO_ACCESS_KEY", "test")
|
|
10
|
-
env._set("MINIO_SECRET_KEY", "test")
|
|
11
|
-
env._set("PLATFORM_URL", "http://localhost:10000")
|
|
12
|
-
env._set("INTERNAL_API_KEY", "test")
|
|
13
|
-
env._set("DISABLE_ACCOUNT_PORTAL", false)
|
|
14
|
-
|
|
15
1
|
import { mocks } from "@budibase/backend-core/tests"
|
|
16
2
|
|
|
17
3
|
// must explicitly enable fetch mock
|
|
@@ -22,7 +8,9 @@ mocks.fetch.enable()
|
|
|
22
8
|
const tk = require("timekeeper")
|
|
23
9
|
tk.freeze(mocks.date.MOCK_DATE)
|
|
24
10
|
|
|
25
|
-
|
|
11
|
+
if (!process.env.DEBUG) {
|
|
12
|
+
global.console.log = jest.fn() // console.log are ignored in tests
|
|
13
|
+
}
|
|
26
14
|
|
|
27
15
|
if (!process.env.CI) {
|
|
28
16
|
// set a longer timeout in dev for debugging
|
package/src/tests/mocks/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { mocks
|
|
1
|
+
import * as email from "./email"
|
|
2
|
+
import { mocks } from "@budibase/backend-core/tests"
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export default {
|
|
5
5
|
email,
|
|
6
|
-
...
|
|
6
|
+
...mocks,
|
|
7
7
|
}
|
|
@@ -4,9 +4,9 @@ import * as users from "./users"
|
|
|
4
4
|
import * as groups from "./groups"
|
|
5
5
|
import { v4 as uuid } from "uuid"
|
|
6
6
|
|
|
7
|
-
const TENANT_ID = "default"
|
|
8
|
-
const TENANT_1 = "tenant1"
|
|
9
|
-
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306"
|
|
7
|
+
export const TENANT_ID = "default"
|
|
8
|
+
export const TENANT_1 = "tenant1"
|
|
9
|
+
export const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306"
|
|
10
10
|
|
|
11
11
|
const pkg = {
|
|
12
12
|
...structures,
|
|
@@ -19,4 +19,4 @@ const pkg = {
|
|
|
19
19
|
groups,
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export
|
|
22
|
+
export default pkg
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fetch from "node-fetch"
|
|
2
|
-
import { constants, tenancy } from "@budibase/backend-core"
|
|
2
|
+
import { constants, tenancy, logging } from "@budibase/backend-core"
|
|
3
3
|
import { checkSlashesInUrl } from "../utilities"
|
|
4
4
|
import env from "../environment"
|
|
5
|
+
import { SyncUserRequest, User } from "@budibase/types"
|
|
5
6
|
|
|
6
7
|
async function makeAppRequest(url: string, method: string, body: any) {
|
|
7
8
|
if (env.isTest()) {
|
|
@@ -17,14 +18,22 @@ async function makeAppRequest(url: string, method: string, body: any) {
|
|
|
17
18
|
request.body = JSON.stringify(body)
|
|
18
19
|
}
|
|
19
20
|
request.method = method
|
|
21
|
+
|
|
22
|
+
// add x-budibase-correlation-id header
|
|
23
|
+
logging.correlation.setHeader(request.headers)
|
|
24
|
+
|
|
20
25
|
return fetch(checkSlashesInUrl(env.APPS_URL + url), request)
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
export async function syncUserInApps(userId: string) {
|
|
28
|
+
export async function syncUserInApps(userId: string, previousUser?: User) {
|
|
29
|
+
const body: SyncUserRequest = {
|
|
30
|
+
previousUser,
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
const response = await makeAppRequest(
|
|
25
34
|
`/api/users/metadata/sync/${userId}`,
|
|
26
35
|
"POST",
|
|
27
|
-
|
|
36
|
+
body
|
|
28
37
|
)
|
|
29
38
|
if (response && response.status !== 200) {
|
|
30
39
|
throw "Unable to sync user."
|
package/tsconfig.json
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"ts-node": {
|
|
16
|
-
"require": ["tsconfig-paths/register"]
|
|
16
|
+
"require": ["tsconfig-paths/register"],
|
|
17
|
+
"swc": true
|
|
17
18
|
},
|
|
18
19
|
"references": [
|
|
19
20
|
{ "path": "../types" },
|
|
@@ -25,7 +26,6 @@
|
|
|
25
26
|
"package.json"
|
|
26
27
|
],
|
|
27
28
|
"exclude": [
|
|
28
|
-
"node_modules",
|
|
29
29
|
"dist"
|
|
30
30
|
]
|
|
31
31
|
}
|