@budibase/worker 2.2.26 → 2.2.27-alpha.1
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/__mocks__/node-fetch.ts +23 -0
- package/coverage/clover.xml +1423 -1379
- package/coverage/coverage-final.json +83 -77
- package/coverage/lcov-report/index.html +140 -140
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +52 -52
- package/coverage/lcov-report/src/api/controllers/global/configs.ts.html +167 -224
- 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 +83 -68
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +16 -16
- package/coverage/lcov-report/src/api/controllers/global/roles.ts.html +69 -69
- 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 +83 -44
- 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 +42 -30
- 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 +18 -18
- package/coverage/lcov-report/src/constants/templates/index.ts.html +42 -42
- package/coverage/lcov-report/src/db/index.html +17 -17
- package/coverage/lcov-report/src/db/index.ts.html +18 -18
- package/coverage/lcov-report/src/environment.ts.html +45 -30
- 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 +28 -28
- package/coverage/lcov-report/src/sdk/users/index.ts.html +2 -2
- package/coverage/lcov-report/src/sdk/users/users.ts.html +174 -120
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +221 -107
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +7 -7
- package/coverage/lcov-report/src/tests/api/auth.ts.html +25 -13
- package/coverage/lcov-report/src/tests/api/base.ts.html +5 -5
- package/coverage/lcov-report/src/tests/api/configs.ts.html +11 -11
- 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 +30 -27
- 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 +26 -26
- package/coverage/lcov-report/src/tests/structures/index.ts.html +16 -22
- 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 +7 -7
- package/coverage/lcov.info +2826 -2609
- package/jest-testcontainers-config.js +8 -0
- package/jest.config.ts +10 -4
- package/package.json +11 -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/auth.spec.ts +30 -22
- package/src/api/routes/global/tests/configs.spec.ts +114 -94
- 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 +71 -5
- package/src/api/routes/global/tests/templates.spec.ts +81 -9
- package/src/api/routes/global/tests/users.spec.ts +35 -36
- 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 -5
- package/src/tests/TestConfiguration.ts +52 -14
- package/src/tests/api/auth.ts +7 -3
- package/src/tests/api/configs.ts +2 -2
- 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 +4 -3
- package/src/tests/index.ts +6 -18
- package/src/tests/jestEnv.ts +11 -0
- package/src/tests/jestSetup.ts +8 -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 +3 -5
- package/src/tests/structures/users.ts +1 -1
- package/src/utilities/appService.ts +12 -3
- package/tsconfig.json +2 -2
package/src/tests/api/index.ts
CHANGED
|
@@ -10,7 +10,10 @@ import { MigrationAPI } from "./migrations"
|
|
|
10
10
|
import { StatusAPI } from "./status"
|
|
11
11
|
import { RestoreAPI } from "./restore"
|
|
12
12
|
import { TenantAPI } from "./tenants"
|
|
13
|
-
|
|
13
|
+
import { GroupsAPI } from "./groups"
|
|
14
|
+
import { RolesAPI } from "./roles"
|
|
15
|
+
import { TemplatesAPI } from "./templates"
|
|
16
|
+
import { LicenseAPI } from "./license"
|
|
14
17
|
export default class API {
|
|
15
18
|
accounts: AccountAPI
|
|
16
19
|
auth: AuthAPI
|
|
@@ -23,6 +26,10 @@ export default class API {
|
|
|
23
26
|
status: StatusAPI
|
|
24
27
|
restore: RestoreAPI
|
|
25
28
|
tenants: TenantAPI
|
|
29
|
+
groups: GroupsAPI
|
|
30
|
+
roles: RolesAPI
|
|
31
|
+
templates: TemplatesAPI
|
|
32
|
+
license: LicenseAPI
|
|
26
33
|
|
|
27
34
|
constructor(config: TestConfiguration) {
|
|
28
35
|
this.accounts = new AccountAPI(config)
|
|
@@ -36,5 +43,9 @@ export default class API {
|
|
|
36
43
|
this.status = new StatusAPI(config)
|
|
37
44
|
this.restore = new RestoreAPI(config)
|
|
38
45
|
this.tenants = new TenantAPI(config)
|
|
46
|
+
this.groups = new GroupsAPI(config)
|
|
47
|
+
this.roles = new RolesAPI(config)
|
|
48
|
+
this.templates = new TemplatesAPI(config)
|
|
49
|
+
this.license = new LicenseAPI(config)
|
|
39
50
|
}
|
|
40
51
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import TestConfiguration from "../TestConfiguration"
|
|
2
|
+
import { TestAPI } from "./base"
|
|
3
|
+
|
|
4
|
+
export class LicenseAPI extends TestAPI {
|
|
5
|
+
constructor(config: TestConfiguration) {
|
|
6
|
+
super(config)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
activate = async (licenseKey: string) => {
|
|
10
|
+
return this.request
|
|
11
|
+
.post("/api/global/license/activate")
|
|
12
|
+
.send({ licenseKey: licenseKey })
|
|
13
|
+
.set(this.config.defaultHeaders())
|
|
14
|
+
.expect("Content-Type", /json/)
|
|
15
|
+
.expect(200)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -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"
|
|
@@ -26,8 +26,8 @@ export class UserAPI extends TestAPI {
|
|
|
26
26
|
email,
|
|
27
27
|
})
|
|
28
28
|
.set(this.config.defaultHeaders())
|
|
29
|
-
.expect("Content-Type", /json/)
|
|
30
29
|
.expect(status)
|
|
30
|
+
.expect("Content-Type", /json/)
|
|
31
31
|
|
|
32
32
|
if (status !== 200) {
|
|
33
33
|
return { code: undefined, res }
|
|
@@ -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)
|
|
@@ -99,7 +100,7 @@ export class UserAPI extends TestAPI {
|
|
|
99
100
|
request = {
|
|
100
101
|
email: structures.email(),
|
|
101
102
|
password: generator.string(),
|
|
102
|
-
tenantId: structures.
|
|
103
|
+
tenantId: structures.tenant.id(),
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
const res = await this.request
|
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,18 +1,7 @@
|
|
|
1
|
-
import
|
|
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)
|
|
1
|
+
import { mocks, testContainerUtils } from "@budibase/backend-core/tests"
|
|
14
2
|
|
|
15
|
-
import
|
|
3
|
+
import env from "../environment"
|
|
4
|
+
import { env as coreEnv } from "@budibase/backend-core"
|
|
16
5
|
|
|
17
6
|
// must explicitly enable fetch mock
|
|
18
7
|
mocks.fetch.enable()
|
|
@@ -22,10 +11,14 @@ mocks.fetch.enable()
|
|
|
22
11
|
const tk = require("timekeeper")
|
|
23
12
|
tk.freeze(mocks.date.MOCK_DATE)
|
|
24
13
|
|
|
25
|
-
|
|
14
|
+
if (!process.env.DEBUG) {
|
|
15
|
+
global.console.log = jest.fn() // console.log are ignored in tests
|
|
16
|
+
}
|
|
26
17
|
|
|
27
18
|
if (!process.env.CI) {
|
|
28
19
|
// set a longer timeout in dev for debugging
|
|
29
20
|
// 100 seconds
|
|
30
21
|
jest.setTimeout(100000)
|
|
31
22
|
}
|
|
23
|
+
|
|
24
|
+
testContainerUtils.setupEnv(env, coreEnv)
|
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,8 @@ 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
|
|
9
|
-
const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306"
|
|
7
|
+
export const TENANT_ID = "default"
|
|
8
|
+
export const CSRF_TOKEN = "e3727778-7af0-4226-b5eb-f43cbe60a306"
|
|
10
9
|
|
|
11
10
|
const pkg = {
|
|
12
11
|
...structures,
|
|
@@ -14,9 +13,8 @@ const pkg = {
|
|
|
14
13
|
configs,
|
|
15
14
|
users,
|
|
16
15
|
TENANT_ID,
|
|
17
|
-
TENANT_1,
|
|
18
16
|
CSRF_TOKEN,
|
|
19
17
|
groups,
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
export
|
|
20
|
+
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
|
}
|