@budibase/worker 3.2.27 → 3.2.29
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/package.json +2 -2
- package/src/api/controllers/global/auth.ts +16 -4
- package/src/api/controllers/global/events.ts +5 -2
- package/src/api/controllers/global/license.ts +20 -10
- package/src/api/controllers/global/users.ts +5 -2
- package/src/api/controllers/system/accounts.ts +0 -1
- package/src/api/controllers/system/migrations.ts +3 -3
- package/src/api/routes/system/tests/migrations.spec.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.29",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "047c20252062a6f96aa2028bc4f9c5c882cd6860"
|
|
118
118
|
}
|
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
GetInitInfoResponse,
|
|
23
23
|
PasswordResetResponse,
|
|
24
24
|
PasswordResetUpdateResponse,
|
|
25
|
+
SetInitInfoResponse,
|
|
26
|
+
LoginResponse,
|
|
25
27
|
} from "@budibase/types"
|
|
26
28
|
import env from "../../../environment"
|
|
27
29
|
import { Next } from "koa"
|
|
@@ -59,7 +61,10 @@ async function passportCallback(
|
|
|
59
61
|
ctx.set(Header.TOKEN, token)
|
|
60
62
|
}
|
|
61
63
|
|
|
62
|
-
export const login = async (
|
|
64
|
+
export const login = async (
|
|
65
|
+
ctx: Ctx<LoginRequest, LoginResponse>,
|
|
66
|
+
next: Next
|
|
67
|
+
) => {
|
|
63
68
|
const email = ctx.request.body.username
|
|
64
69
|
|
|
65
70
|
const user = await userSdk.db.getUserByEmail(email)
|
|
@@ -74,7 +79,10 @@ export const login = async (ctx: Ctx<LoginRequest, void>, next: Next) => {
|
|
|
74
79
|
await context.identity.doInUserContext(user, ctx, async () => {
|
|
75
80
|
await events.auth.login("local", user.email)
|
|
76
81
|
})
|
|
77
|
-
ctx.
|
|
82
|
+
ctx.body = {
|
|
83
|
+
message: "Login successful",
|
|
84
|
+
userId: user.userId,
|
|
85
|
+
}
|
|
78
86
|
}
|
|
79
87
|
)(ctx, next)
|
|
80
88
|
}
|
|
@@ -88,10 +96,14 @@ export const logout = async (ctx: UserCtx<void, LogoutResponse>) => {
|
|
|
88
96
|
|
|
89
97
|
// INIT
|
|
90
98
|
|
|
91
|
-
export const setInitInfo = (
|
|
99
|
+
export const setInitInfo = (
|
|
100
|
+
ctx: UserCtx<SetInitInfoRequest, SetInitInfoResponse>
|
|
101
|
+
) => {
|
|
92
102
|
const initInfo = ctx.request.body
|
|
93
103
|
setCookie(ctx, initInfo, Cookie.Init)
|
|
94
|
-
ctx.
|
|
104
|
+
ctx.body = {
|
|
105
|
+
message: "Init info updated.",
|
|
106
|
+
}
|
|
95
107
|
}
|
|
96
108
|
|
|
97
109
|
export const getInitInfo = (ctx: UserCtx<void, GetInitInfoResponse>) => {
|
|
@@ -2,10 +2,13 @@ import {
|
|
|
2
2
|
UserCtx,
|
|
3
3
|
PostEventPublishRequest,
|
|
4
4
|
EventPublishType,
|
|
5
|
+
PostEventPublishResponse,
|
|
5
6
|
} from "@budibase/types"
|
|
6
7
|
import { events } from "@budibase/backend-core"
|
|
7
8
|
|
|
8
|
-
export async function publish(
|
|
9
|
+
export async function publish(
|
|
10
|
+
ctx: UserCtx<PostEventPublishRequest, PostEventPublishResponse>
|
|
11
|
+
) {
|
|
9
12
|
switch (ctx.request.body.type) {
|
|
10
13
|
case EventPublishType.ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED:
|
|
11
14
|
await events.environmentVariable.upgradePanelOpened(ctx.user._id!)
|
|
@@ -13,5 +16,5 @@ export async function publish(ctx: UserCtx<PostEventPublishRequest, void>) {
|
|
|
13
16
|
default:
|
|
14
17
|
ctx.throw(400, "Invalid publish event type.")
|
|
15
18
|
}
|
|
16
|
-
ctx.
|
|
19
|
+
ctx.body = { message: "Event published." }
|
|
17
20
|
}
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { licensing, quotas } from "@budibase/pro"
|
|
2
2
|
import {
|
|
3
3
|
ActivateLicenseKeyRequest,
|
|
4
|
+
ActivateLicenseKeyResponse,
|
|
4
5
|
ActivateOfflineLicenseTokenRequest,
|
|
6
|
+
ActivateOfflineLicenseTokenResponse,
|
|
5
7
|
GetLicenseKeyResponse,
|
|
6
8
|
GetOfflineIdentifierResponse,
|
|
7
9
|
GetOfflineLicenseTokenResponse,
|
|
8
10
|
GetQuotaUsageResponse,
|
|
11
|
+
RefreshOfflineLicenseResponse,
|
|
9
12
|
UserCtx,
|
|
10
13
|
} from "@budibase/types"
|
|
11
14
|
|
|
12
15
|
// LICENSE KEY
|
|
13
16
|
|
|
14
17
|
export async function activateLicenseKey(
|
|
15
|
-
ctx: UserCtx<ActivateLicenseKeyRequest>
|
|
18
|
+
ctx: UserCtx<ActivateLicenseKeyRequest, ActivateLicenseKeyResponse>
|
|
16
19
|
) {
|
|
17
20
|
const { licenseKey } = ctx.request.body
|
|
18
21
|
await licensing.keys.activateLicenseKey(licenseKey)
|
|
19
|
-
ctx.
|
|
22
|
+
ctx.body = {
|
|
23
|
+
message: "License activated.",
|
|
24
|
+
}
|
|
20
25
|
}
|
|
21
26
|
|
|
22
27
|
export async function getLicenseKey(ctx: UserCtx<void, GetLicenseKeyResponse>) {
|
|
23
28
|
const licenseKey = await licensing.keys.getLicenseKey()
|
|
24
29
|
if (licenseKey) {
|
|
25
30
|
ctx.body = { licenseKey: "*" }
|
|
26
|
-
ctx.status = 200
|
|
27
31
|
} else {
|
|
28
32
|
ctx.status = 404
|
|
29
33
|
}
|
|
@@ -37,11 +41,16 @@ export async function deleteLicenseKey(ctx: UserCtx<void, void>) {
|
|
|
37
41
|
// OFFLINE LICENSE
|
|
38
42
|
|
|
39
43
|
export async function activateOfflineLicenseToken(
|
|
40
|
-
ctx: UserCtx<
|
|
44
|
+
ctx: UserCtx<
|
|
45
|
+
ActivateOfflineLicenseTokenRequest,
|
|
46
|
+
ActivateOfflineLicenseTokenResponse
|
|
47
|
+
>
|
|
41
48
|
) {
|
|
42
49
|
const { offlineLicenseToken } = ctx.request.body
|
|
43
50
|
await licensing.offline.activateOfflineLicenseToken(offlineLicenseToken)
|
|
44
|
-
ctx.
|
|
51
|
+
ctx.body = {
|
|
52
|
+
message: "License token activated.",
|
|
53
|
+
}
|
|
45
54
|
}
|
|
46
55
|
|
|
47
56
|
export async function getOfflineLicenseToken(
|
|
@@ -50,7 +59,6 @@ export async function getOfflineLicenseToken(
|
|
|
50
59
|
const offlineLicenseToken = await licensing.offline.getOfflineLicenseToken()
|
|
51
60
|
if (offlineLicenseToken) {
|
|
52
61
|
ctx.body = { offlineLicenseToken: "*" }
|
|
53
|
-
ctx.status = 200
|
|
54
62
|
} else {
|
|
55
63
|
ctx.status = 404
|
|
56
64
|
}
|
|
@@ -66,14 +74,17 @@ export async function getOfflineLicenseIdentifier(
|
|
|
66
74
|
) {
|
|
67
75
|
const identifierBase64 = await licensing.offline.getIdentifierBase64()
|
|
68
76
|
ctx.body = { identifierBase64 }
|
|
69
|
-
ctx.status = 200
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
// LICENSES
|
|
73
80
|
|
|
74
|
-
export const refresh = async (
|
|
81
|
+
export const refresh = async (
|
|
82
|
+
ctx: UserCtx<void, RefreshOfflineLicenseResponse>
|
|
83
|
+
) => {
|
|
75
84
|
await licensing.cache.refresh()
|
|
76
|
-
ctx.
|
|
85
|
+
ctx.body = {
|
|
86
|
+
message: "License refreshed.",
|
|
87
|
+
}
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
// USAGE
|
|
@@ -82,5 +93,4 @@ export const getQuotaUsage = async (
|
|
|
82
93
|
ctx: UserCtx<void, GetQuotaUsageResponse>
|
|
83
94
|
) => {
|
|
84
95
|
ctx.body = await quotas.getQuotaUsage()
|
|
85
|
-
ctx.status = 200
|
|
86
96
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
AcceptUserInviteRequest,
|
|
5
5
|
AcceptUserInviteResponse,
|
|
6
6
|
AddSSoUserRequest,
|
|
7
|
+
AddSSoUserResponse,
|
|
7
8
|
BulkUserRequest,
|
|
8
9
|
BulkUserResponse,
|
|
9
10
|
CheckInviteResponse,
|
|
@@ -93,7 +94,9 @@ export const save = async (ctx: UserCtx<User, SaveUserResponse>) => {
|
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
96
|
|
|
96
|
-
export const addSsoSupport = async (
|
|
97
|
+
export const addSsoSupport = async (
|
|
98
|
+
ctx: Ctx<AddSSoUserRequest, AddSSoUserResponse>
|
|
99
|
+
) => {
|
|
97
100
|
const { email, ssoId } = ctx.request.body
|
|
98
101
|
try {
|
|
99
102
|
// Status is changed to 404 from getUserDoc if user is not found
|
|
@@ -113,7 +116,7 @@ export const addSsoSupport = async (ctx: Ctx<AddSSoUserRequest, void>) => {
|
|
|
113
116
|
email,
|
|
114
117
|
ssoId,
|
|
115
118
|
})
|
|
116
|
-
ctx.
|
|
119
|
+
ctx.body = { message: "SSO support added." }
|
|
117
120
|
} catch (err: any) {
|
|
118
121
|
ctx.throw(err.status || 400, err)
|
|
119
122
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FetchMigrationDefinitionsResponse,
|
|
3
3
|
RunGlobalMigrationRequest,
|
|
4
|
+
RunGlobalMigrationResponse,
|
|
4
5
|
UserCtx,
|
|
5
6
|
} from "@budibase/types"
|
|
6
7
|
|
|
7
8
|
const { migrate, MIGRATIONS } = require("../../../migrations")
|
|
8
9
|
|
|
9
10
|
export const runMigrations = async (
|
|
10
|
-
ctx: UserCtx<RunGlobalMigrationRequest,
|
|
11
|
+
ctx: UserCtx<RunGlobalMigrationRequest, RunGlobalMigrationResponse>
|
|
11
12
|
) => {
|
|
12
13
|
const options = ctx.request.body
|
|
13
14
|
// don't await as can take a while, just return
|
|
14
15
|
migrate(options)
|
|
15
|
-
ctx.
|
|
16
|
+
ctx.body = { message: "Migration started." }
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export const fetchDefinitions = async (
|
|
19
20
|
ctx: UserCtx<void, FetchMigrationDefinitionsResponse>
|
|
20
21
|
) => {
|
|
21
22
|
ctx.body = MIGRATIONS
|
|
22
|
-
ctx.status = 200
|
|
23
23
|
}
|
|
@@ -36,7 +36,7 @@ describe("/api/system/migrations", () => {
|
|
|
36
36
|
|
|
37
37
|
it("runs migrations", async () => {
|
|
38
38
|
const res = await config.api.migrations.runMigrations()
|
|
39
|
-
expect(res.
|
|
39
|
+
expect(res.body.message).toBeDefined()
|
|
40
40
|
expect(migrateFn).toHaveBeenCalledTimes(1)
|
|
41
41
|
})
|
|
42
42
|
})
|