@budibase/worker 2.7.34-alpha.8 → 2.7.35

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,9 +21,11 @@ const config: Config.InitialOptions = {
21
21
  }
22
22
 
23
23
  // add pro sources if they exist
24
- if (fs.existsSync("../pro/src")) {
25
- config.moduleNameMapper!["@budibase/pro/(.*)"] = "<rootDir>/../pro/$1"
26
- config.moduleNameMapper!["@budibase/pro"] = "<rootDir>/../pro/src"
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"
27
29
  }
28
30
 
29
31
  export default config
package/nodemon.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "watch": ["src", "../backend-core", "../pro"],
2
+ "watch": ["src", "../backend-core", "../pro/packages/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.34-alpha.8",
4
+ "version": "2.7.35",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -38,23 +38,21 @@
38
38
  "author": "Budibase",
39
39
  "license": "GPL-3.0",
40
40
  "dependencies": {
41
- "@budibase/backend-core": "2.7.34-alpha.8",
42
- "@budibase/pro": "2.7.34-alpha.8",
43
- "@budibase/string-templates": "2.7.34-alpha.8",
44
- "@budibase/types": "2.7.34-alpha.8",
41
+ "@budibase/backend-core": "2.7.35",
42
+ "@budibase/pro": "2.7.35",
43
+ "@budibase/string-templates": "2.7.35",
44
+ "@budibase/types": "2.7.35",
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",
51
50
  "bcryptjs": "2.4.3",
52
51
  "dd-trace": "3.13.2",
53
52
  "dotenv": "8.6.0",
54
53
  "elastic-apm-node": "3.38.0",
55
54
  "global-agent": "3.0.0",
56
55
  "got": "11.8.3",
57
- "ical-generator": "4.1.0",
58
56
  "joi": "17.6.0",
59
57
  "koa": "2.13.4",
60
58
  "koa-body": "4.2.0",
@@ -105,5 +103,5 @@
105
103
  "typescript": "4.7.3",
106
104
  "update-dotenv": "1.1.1"
107
105
  },
108
- "gitHead": "a27cb4357beaeed017086a1c2b1617d0a0f87f57"
106
+ "gitHead": "6db1d089ee2d2df8caf513cf2cb4b22f167b91f1"
109
107
  }
@@ -140,6 +140,7 @@ export const datasourcePreAuth = async (ctx: any, next: any) => {
140
140
  {
141
141
  provider,
142
142
  appId: ctx.query.appId,
143
+ datasourceId: ctx.query.datasourceId,
143
144
  },
144
145
  Cookie.DatasourceAuth
145
146
  )
@@ -28,6 +28,7 @@ import {
28
28
  SSOConfig,
29
29
  SSOConfigType,
30
30
  UserCtx,
31
+ OIDCLogosConfig,
31
32
  } from "@budibase/types"
32
33
  import * as pro from "@budibase/pro"
33
34
 
@@ -280,13 +281,39 @@ export async function save(ctx: UserCtx<Config>) {
280
281
  }
281
282
  }
282
283
 
284
+ function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) {
285
+ if (!oidcLogos) {
286
+ return
287
+ }
288
+ oidcLogos.config = Object.keys(oidcLogos.config || {}).reduce(
289
+ (acc: any, key: string) => {
290
+ if (!key.endsWith("Etag")) {
291
+ const etag = oidcLogos.config[`${key}Etag`]
292
+ const objectStoreUrl = objectStore.getGlobalFileUrl(
293
+ oidcLogos.type,
294
+ key,
295
+ etag
296
+ )
297
+ acc[key] = objectStoreUrl
298
+ } else {
299
+ acc[key] = oidcLogos.config[key]
300
+ }
301
+ return acc
302
+ },
303
+ {}
304
+ )
305
+ }
306
+
283
307
  export async function find(ctx: UserCtx) {
284
308
  try {
285
309
  // Find the config with the most granular scope based on context
286
310
  const type = ctx.params.type
287
- const scopedConfig = await configs.getConfig(type)
311
+ let scopedConfig = await configs.getConfig(type)
288
312
 
289
313
  if (scopedConfig) {
314
+ if (type === ConfigType.OIDC_LOGOS) {
315
+ enrichOIDCLogos(scopedConfig)
316
+ }
290
317
  ctx.body = scopedConfig
291
318
  } else {
292
319
  // don't throw an error, there simply is nothing to return
@@ -300,16 +327,21 @@ export async function find(ctx: UserCtx) {
300
327
  export async function publicOidc(ctx: Ctx<void, GetPublicOIDCConfigResponse>) {
301
328
  try {
302
329
  // Find the config with the most granular scope based on context
303
- const config = await configs.getOIDCConfig()
330
+ const oidcConfig = await configs.getOIDCConfig()
331
+ const oidcCustomLogos = await configs.getOIDCLogosDoc()
332
+
333
+ if (oidcCustomLogos) {
334
+ enrichOIDCLogos(oidcCustomLogos)
335
+ }
304
336
 
305
- if (!config) {
337
+ if (!oidcConfig) {
306
338
  ctx.body = []
307
339
  } else {
308
340
  ctx.body = [
309
341
  {
310
- logo: config.logo,
311
- name: config.name,
312
- uuid: config.uuid,
342
+ logo: oidcCustomLogos?.config[oidcConfig.logo] ?? oidcConfig.logo,
343
+ name: oidcConfig.name,
344
+ uuid: oidcConfig.uuid,
313
345
  },
314
346
  ]
315
347
  }
@@ -14,7 +14,6 @@ export async function sendEmail(ctx: BBContext) {
14
14
  cc,
15
15
  bcc,
16
16
  automation,
17
- invite,
18
17
  } = ctx.request.body
19
18
  let user
20
19
  if (userId) {
@@ -30,7 +29,6 @@ export async function sendEmail(ctx: BBContext) {
30
29
  cc,
31
30
  bcc,
32
31
  automation,
33
- invite,
34
32
  })
35
33
  ctx.body = {
36
34
  ...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,10 +1,9 @@
1
- import { Ctx } from "@budibase/types"
1
+ import { BBContext } from "@budibase/types"
2
2
  import env from "../../../environment"
3
3
 
4
- export const fetch = async (ctx: Ctx) => {
4
+ export const fetch = async (ctx: BBContext) => {
5
5
  ctx.body = {
6
6
  multiTenancy: !!env.MULTI_TENANCY,
7
- offlineMode: !!env.OFFLINE_MODE,
8
7
  cloud: !env.SELF_HOSTED,
9
8
  accountPortalUrl: env.ACCOUNT_PORTAL_URL,
10
9
  disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
@@ -24,7 +24,6 @@ describe("/api/system/environment", () => {
24
24
  isDev: false,
25
25
  multiTenancy: true,
26
26
  baseUrl: "http://localhost:10000",
27
- offlineMode: false,
28
27
  })
29
28
  })
30
29
  })
@@ -61,7 +61,6 @@ 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,
65
64
  /**
66
65
  * Mock the email service in use - links to ethereal hosted emails are logged instead.
67
66
  */
@@ -4,11 +4,28 @@ 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, SendEmailOpts, SMTPInnerConfig } from "@budibase/types"
7
+ import { User, SMTPInnerConfig } from "@budibase/types"
8
8
  import { configs } from "@budibase/backend-core"
9
- import ical from "ical-generator"
10
9
  const nodemailer = require("nodemailer")
11
10
 
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
+
12
29
  const TEST_MODE = env.ENABLE_EMAIL_TEST_MODE && env.isDev()
13
30
  const TYPE = TemplateType.EMAIL
14
31
 
@@ -183,26 +200,6 @@ export async function sendEmail(
183
200
  context
184
201
  )
185
202
  }
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
-
206
203
  const response = await transport.sendMail(message)
207
204
  if (TEST_MODE) {
208
205
  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/src"]
19
+ "@budibase/pro": ["../pro/packages/pro/src"]
20
20
  }
21
21
  },
22
22
  "include": ["src/**/*"],