@budibase/worker 2.7.33 → 2.7.34-alpha.0

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 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/packages")) {
25
- config.moduleNameMapper!["@budibase/pro/(.*)"] =
26
- "<rootDir>/../pro/packages/pro/$1"
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
@@ -1,5 +1,5 @@
1
1
  {
2
- "watch": ["src", "../backend-core", "../pro/packages/pro"],
2
+ "watch": ["src", "../backend-core", "../pro"],
3
3
  "ext": "js,ts,json",
4
4
  "ignore": [
5
5
  "src/**/*.spec.ts",
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.33",
4
+ "version": "2.7.34-alpha.0",
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.33",
42
- "@budibase/pro": "2.7.33",
43
- "@budibase/string-templates": "2.7.33",
44
- "@budibase/types": "2.7.33",
41
+ "@budibase/backend-core": "2.7.34-alpha.0",
42
+ "@budibase/pro": "2.7.34-alpha.0",
43
+ "@budibase/string-templates": "2.7.34-alpha.0",
44
+ "@budibase/types": "2.7.34-alpha.0",
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": "36a5d6ebbe381fd2dc578abade0c4a06dd620740"
108
+ "gitHead": "cccf8af5f375f074bef7420b148dda909e97ce28"
107
109
  }
@@ -140,7 +140,6 @@ export const datasourcePreAuth = async (ctx: any, next: any) => {
140
140
  {
141
141
  provider,
142
142
  appId: ctx.query.appId,
143
- datasourceId: ctx.query.datasourceId,
144
143
  },
145
144
  Cookie.DatasourceAuth
146
145
  )
@@ -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._id
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 { BBContext } from "@budibase/types"
1
+ import { Ctx } from "@budibase/types"
2
2
  import env from "../../../environment"
3
3
 
4
- export const fetch = async (ctx: BBContext) => {
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,
@@ -24,6 +24,7 @@ describe("/api/system/environment", () => {
24
24
  isDev: false,
25
25
  multiTenancy: true,
26
26
  baseUrl: "http://localhost:10000",
27
+ offlineMode: false,
27
28
  })
28
29
  })
29
30
  })
@@ -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
  */
@@ -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))
@@ -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/packages/pro/src"]
19
+ "@budibase/pro": ["../pro/src"]
20
20
  }
21
21
  },
22
22
  "include": ["src/**/*"],