@budibase/worker 2.7.35 → 2.7.36-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/jest.config.ts +3 -5
- package/nodemon.json +1 -1
- package/package.json +8 -6
- package/src/api/controllers/global/auth.ts +0 -1
- package/src/api/controllers/global/email.ts +2 -0
- package/src/api/controllers/global/users.ts +1 -1
- package/src/api/controllers/system/environment.ts +3 -2
- package/src/api/routes/global/tests/roles.spec.ts +3 -2
- package/src/api/routes/system/tests/environment.spec.ts +1 -0
- package/src/environment.ts +1 -0
- package/src/utilities/email.ts +22 -19
- package/tsconfig.build.json +1 -1
package/jest.config.ts
CHANGED
|
@@ -21,11 +21,9 @@ const config: Config.InitialOptions = {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// add pro sources if they exist
|
|
24
|
-
if (fs.existsSync("../pro/
|
|
25
|
-
config.moduleNameMapper!["@budibase/pro/(.*)"] =
|
|
26
|
-
|
|
27
|
-
config.moduleNameMapper!["@budibase/pro"] =
|
|
28
|
-
"<rootDir>/../pro/packages/pro/src"
|
|
24
|
+
if (fs.existsSync("../pro/src")) {
|
|
25
|
+
config.moduleNameMapper!["@budibase/pro/(.*)"] = "<rootDir>/../pro/$1"
|
|
26
|
+
config.moduleNameMapper!["@budibase/pro"] = "<rootDir>/../pro/src"
|
|
29
27
|
}
|
|
30
28
|
|
|
31
29
|
export default config
|
package/nodemon.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.7.
|
|
4
|
+
"version": "2.7.36-alpha.1",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -38,21 +38,23 @@
|
|
|
38
38
|
"author": "Budibase",
|
|
39
39
|
"license": "GPL-3.0",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@budibase/backend-core": "2.7.
|
|
42
|
-
"@budibase/pro": "2.7.
|
|
43
|
-
"@budibase/string-templates": "2.7.
|
|
44
|
-
"@budibase/types": "2.7.
|
|
41
|
+
"@budibase/backend-core": "2.7.36-alpha.1",
|
|
42
|
+
"@budibase/pro": "2.7.36-alpha.1",
|
|
43
|
+
"@budibase/string-templates": "2.7.36-alpha.1",
|
|
44
|
+
"@budibase/types": "2.7.36-alpha.1",
|
|
45
45
|
"@koa/router": "8.0.8",
|
|
46
46
|
"@sentry/node": "6.17.7",
|
|
47
47
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
48
48
|
"@types/global-agent": "2.1.1",
|
|
49
49
|
"aws-sdk": "2.1030.0",
|
|
50
|
+
"bcrypt": "5.1.0",
|
|
50
51
|
"bcryptjs": "2.4.3",
|
|
51
52
|
"dd-trace": "3.13.2",
|
|
52
53
|
"dotenv": "8.6.0",
|
|
53
54
|
"elastic-apm-node": "3.38.0",
|
|
54
55
|
"global-agent": "3.0.0",
|
|
55
56
|
"got": "11.8.3",
|
|
57
|
+
"ical-generator": "4.1.0",
|
|
56
58
|
"joi": "17.6.0",
|
|
57
59
|
"koa": "2.13.4",
|
|
58
60
|
"koa-body": "4.2.0",
|
|
@@ -103,5 +105,5 @@
|
|
|
103
105
|
"typescript": "4.7.3",
|
|
104
106
|
"update-dotenv": "1.1.1"
|
|
105
107
|
},
|
|
106
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "8d3bbb718b4e3dea5e1da2dfa30fac231ef4fe22"
|
|
107
109
|
}
|
|
@@ -14,6 +14,7 @@ export async function sendEmail(ctx: BBContext) {
|
|
|
14
14
|
cc,
|
|
15
15
|
bcc,
|
|
16
16
|
automation,
|
|
17
|
+
invite,
|
|
17
18
|
} = ctx.request.body
|
|
18
19
|
let user
|
|
19
20
|
if (userId) {
|
|
@@ -29,6 +30,7 @@ export async function sendEmail(ctx: BBContext) {
|
|
|
29
30
|
cc,
|
|
30
31
|
bcc,
|
|
31
32
|
automation,
|
|
33
|
+
invite,
|
|
32
34
|
})
|
|
33
35
|
ctx.body = {
|
|
34
36
|
...response,
|
|
@@ -38,7 +38,7 @@ const MAX_USERS_UPLOAD_LIMIT = 1000
|
|
|
38
38
|
|
|
39
39
|
export const save = async (ctx: UserCtx<User, SaveUserResponse>) => {
|
|
40
40
|
try {
|
|
41
|
-
const currentUserId = ctx.user
|
|
41
|
+
const currentUserId = ctx.user?._id
|
|
42
42
|
const requestUser = ctx.request.body
|
|
43
43
|
|
|
44
44
|
const user = await userSdk.save(requestUser, { currentUserId })
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ctx } from "@budibase/types"
|
|
2
2
|
import env from "../../../environment"
|
|
3
3
|
|
|
4
|
-
export const fetch = async (ctx:
|
|
4
|
+
export const fetch = async (ctx: Ctx) => {
|
|
5
5
|
ctx.body = {
|
|
6
6
|
multiTenancy: !!env.MULTI_TENANCY,
|
|
7
|
+
offlineMode: !!env.OFFLINE_MODE,
|
|
7
8
|
cloud: !env.SELF_HOSTED,
|
|
8
9
|
accountPortalUrl: env.ACCOUNT_PORTAL_URL,
|
|
9
10
|
disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
|
|
@@ -19,6 +19,7 @@ jest.mock("@budibase/backend-core", () => {
|
|
|
19
19
|
|
|
20
20
|
let appId: string
|
|
21
21
|
let appDb: Database
|
|
22
|
+
const ROLE_NAME = "newRole"
|
|
22
23
|
|
|
23
24
|
async function addAppMetadata() {
|
|
24
25
|
await appDb.put({
|
|
@@ -34,7 +35,7 @@ describe("/api/global/roles", () => {
|
|
|
34
35
|
const config = new TestConfiguration()
|
|
35
36
|
|
|
36
37
|
const role = new roles.Role(
|
|
37
|
-
db.generateRoleID(
|
|
38
|
+
db.generateRoleID(ROLE_NAME),
|
|
38
39
|
roles.BUILTIN_ROLE_IDS.BASIC,
|
|
39
40
|
permissions.BuiltinPermissionID.READ_ONLY
|
|
40
41
|
)
|
|
@@ -66,7 +67,7 @@ describe("/api/global/roles", () => {
|
|
|
66
67
|
const res = await config.api.roles.get()
|
|
67
68
|
expect(res.body).toBeDefined()
|
|
68
69
|
expect(res.body[appId].roles.length).toEqual(5)
|
|
69
|
-
expect(res.body[appId].roles.map((r: any) => r._id)).toContain(
|
|
70
|
+
expect(res.body[appId].roles.map((r: any) => r._id)).toContain(ROLE_NAME)
|
|
70
71
|
})
|
|
71
72
|
})
|
|
72
73
|
|
package/src/environment.ts
CHANGED
|
@@ -61,6 +61,7 @@ const environment = {
|
|
|
61
61
|
CHECKLIST_CACHE_TTL: parseIntSafe(process.env.CHECKLIST_CACHE_TTL) || 3600,
|
|
62
62
|
SESSION_UPDATE_PERIOD: process.env.SESSION_UPDATE_PERIOD,
|
|
63
63
|
ENCRYPTED_TEST_PUBLIC_API_KEY: process.env.ENCRYPTED_TEST_PUBLIC_API_KEY,
|
|
64
|
+
OFFLINE_MODE: process.env.OFFLINE_MODE,
|
|
64
65
|
/**
|
|
65
66
|
* Mock the email service in use - links to ethereal hosted emails are logged instead.
|
|
66
67
|
*/
|
package/src/utilities/email.ts
CHANGED
|
@@ -4,28 +4,11 @@ import { getTemplateByPurpose, EmailTemplates } from "../constants/templates"
|
|
|
4
4
|
import { getSettingsTemplateContext } from "./templates"
|
|
5
5
|
import { processString } from "@budibase/string-templates"
|
|
6
6
|
import { getResetPasswordCode, getInviteCode } from "./redis"
|
|
7
|
-
import { User, SMTPInnerConfig } from "@budibase/types"
|
|
7
|
+
import { User, SendEmailOpts, SMTPInnerConfig } from "@budibase/types"
|
|
8
8
|
import { configs } from "@budibase/backend-core"
|
|
9
|
+
import ical from "ical-generator"
|
|
9
10
|
const nodemailer = require("nodemailer")
|
|
10
11
|
|
|
11
|
-
type SendEmailOpts = {
|
|
12
|
-
// workspaceId If finer grain controls being used then this will lookup config for workspace.
|
|
13
|
-
workspaceId?: string
|
|
14
|
-
// user If sending to an existing user the object can be provided, this is used in the context.
|
|
15
|
-
user: User
|
|
16
|
-
// from If sending from an address that is not what is configured in the SMTP config.
|
|
17
|
-
from?: string
|
|
18
|
-
// contents If sending a custom email then can supply contents which will be added to it.
|
|
19
|
-
contents?: string
|
|
20
|
-
// subject A custom subject can be specified if the config one is not desired.
|
|
21
|
-
subject?: string
|
|
22
|
-
// info Pass in a structure of information to be stored alongside the invitation.
|
|
23
|
-
info?: any
|
|
24
|
-
cc?: boolean
|
|
25
|
-
bcc?: boolean
|
|
26
|
-
automation?: boolean
|
|
27
|
-
}
|
|
28
|
-
|
|
29
12
|
const TEST_MODE = env.ENABLE_EMAIL_TEST_MODE && env.isDev()
|
|
30
13
|
const TYPE = TemplateType.EMAIL
|
|
31
14
|
|
|
@@ -200,6 +183,26 @@ export async function sendEmail(
|
|
|
200
183
|
context
|
|
201
184
|
)
|
|
202
185
|
}
|
|
186
|
+
if (opts?.invite) {
|
|
187
|
+
const calendar = ical({
|
|
188
|
+
name: "Invite",
|
|
189
|
+
})
|
|
190
|
+
calendar.createEvent({
|
|
191
|
+
start: opts.invite.startTime,
|
|
192
|
+
end: opts.invite.endTime,
|
|
193
|
+
summary: opts.invite.summary,
|
|
194
|
+
location: opts.invite.location,
|
|
195
|
+
url: opts.invite.url,
|
|
196
|
+
})
|
|
197
|
+
message = {
|
|
198
|
+
...message,
|
|
199
|
+
icalEvent: {
|
|
200
|
+
method: "request",
|
|
201
|
+
content: calendar.toString(),
|
|
202
|
+
},
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
203
206
|
const response = await transport.sendMail(message)
|
|
204
207
|
if (TEST_MODE) {
|
|
205
208
|
console.log("Test email URL: " + nodemailer.getTestMessageUrl(response))
|
package/tsconfig.build.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@budibase/backend-core": ["../backend-core/src"],
|
|
17
17
|
"@budibase/backend-core/*": ["../backend-core/*"],
|
|
18
18
|
"@budibase/shared-core": ["../shared-core/src"],
|
|
19
|
-
"@budibase/pro": ["../pro/
|
|
19
|
+
"@budibase/pro": ["../pro/src"]
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"include": ["src/**/*"],
|