@budibase/worker 2.4.42-alpha.4 → 2.4.42

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.4.42-alpha.4",
4
+ "version": "2.4.42",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -36,10 +36,10 @@
36
36
  "author": "Budibase",
37
37
  "license": "GPL-3.0",
38
38
  "dependencies": {
39
- "@budibase/backend-core": "2.4.42-alpha.4",
40
- "@budibase/pro": "2.4.42-alpha.2",
41
- "@budibase/string-templates": "2.4.42-alpha.4",
42
- "@budibase/types": "2.4.42-alpha.4",
39
+ "@budibase/backend-core": "^2.4.42",
40
+ "@budibase/pro": "2.4.41",
41
+ "@budibase/string-templates": "^2.4.42",
42
+ "@budibase/types": "^2.4.42",
43
43
  "@koa/router": "8.0.8",
44
44
  "@sentry/node": "6.17.7",
45
45
  "@techpass/passport-openidconnect": "0.3.2",
@@ -101,5 +101,5 @@
101
101
  "typescript": "4.7.3",
102
102
  "update-dotenv": "1.1.1"
103
103
  },
104
- "gitHead": "08cf82288300f22ebb730b1f1c68bc9a67691efc"
104
+ "gitHead": "6cff785e5ac488eafb8b9a4c3ccd7558f2f332cf"
105
105
  }
package/scripts/test.sh CHANGED
@@ -3,10 +3,10 @@
3
3
  if [[ -n $CI ]]
4
4
  then
5
5
  # --runInBand performs better in ci where resources are limited
6
- echo "jest --coverage --runInBand --forceExit"
7
- jest --coverage --runInBand --forceExit
6
+ echo "jest --coverage --runInBand"
7
+ jest --coverage --runInBand
8
8
  else
9
9
  # --maxWorkers performs better in development
10
10
  echo "jest --coverage --maxWorkers=2"
11
11
  jest --coverage --maxWorkers=2
12
- fi
12
+ fi
@@ -11,7 +11,6 @@ import {
11
11
  tenancy,
12
12
  } from "@budibase/backend-core"
13
13
  import { checkAnyUserExists } from "../../../utilities/users"
14
- import { getLicensedConfig } from "../../../utilities/configs"
15
14
  import {
16
15
  Config,
17
16
  ConfigType,
@@ -212,38 +211,6 @@ export async function save(ctx: UserCtx<Config>) {
212
211
  ctx.throw(400, err)
213
212
  }
214
213
 
215
- // Ignore branding changes if the license does not permit it
216
- // Favicon and Logo Url are excluded.
217
- try {
218
- const brandingEnabled = await pro.features.isBrandingEnabled()
219
- if (existingConfig?.config && !brandingEnabled) {
220
- const {
221
- emailBrandingEnabled,
222
- testimonialsEnabled,
223
- platformTitle,
224
- metaDescription,
225
- loginHeading,
226
- loginButton,
227
- metaImageUrl,
228
- metaTitle,
229
- } = existingConfig.config
230
-
231
- body.config = {
232
- ...body.config,
233
- emailBrandingEnabled,
234
- testimonialsEnabled,
235
- platformTitle,
236
- metaDescription,
237
- loginHeading,
238
- loginButton,
239
- metaImageUrl,
240
- metaTitle,
241
- }
242
- }
243
- } catch (e) {
244
- console.error("There was an issue retrieving the license", e)
245
- }
246
-
247
214
  try {
248
215
  body._id = configs.generateConfigID(type)
249
216
  const response = await configs.save(body)
@@ -309,9 +276,6 @@ export async function publicSettings(
309
276
  // settings
310
277
  const configDoc = await configs.getSettingsConfigDoc()
311
278
  const config = configDoc.config
312
-
313
- const branding = await pro.branding.getBrandingConfig(config)
314
-
315
279
  // enrich the logo url - empty url means deleted
316
280
  if (config.logoUrl && config.logoUrl !== "") {
317
281
  config.logoUrl = objectStore.getGlobalFileUrl(
@@ -321,19 +285,8 @@ export async function publicSettings(
321
285
  )
322
286
  }
323
287
 
324
- if (branding.faviconUrl && branding.faviconUrl !== "") {
325
- // @ts-ignore
326
- config.faviconUrl = objectStore.getGlobalFileUrl(
327
- "settings",
328
- "faviconUrl",
329
- branding.faviconUrl
330
- )
331
- }
332
-
333
288
  // google
334
289
  const googleConfig = await configs.getGoogleConfig()
335
- const googleDatasourceConfigured =
336
- !!(await configs.getGoogleDatasourceConfig())
337
290
  const preActivated = googleConfig && googleConfig.activated == null
338
291
  const google = preActivated || !!googleConfig?.activated
339
292
  const _googleCallbackUrl = await googleCallbackUrl(googleConfig)
@@ -352,9 +305,7 @@ export async function publicSettings(
352
305
  _rev: configDoc._rev,
353
306
  config: {
354
307
  ...config,
355
- ...branding,
356
308
  google,
357
- googleDatasourceConfigured,
358
309
  oidc,
359
310
  isSSOEnforced,
360
311
  oidcCallbackUrl: _oidcCallbackUrl,
@@ -3,6 +3,7 @@ import {
3
3
  getInviteCodes,
4
4
  updateInviteCode,
5
5
  } from "../../../utilities/redis"
6
+ // import sdk from "../../../sdk"
6
7
  import * as userSdk from "../../../sdk/users"
7
8
  import env from "../../../environment"
8
9
  import {
@@ -25,11 +26,11 @@ import {
25
26
  import {
26
27
  accounts,
27
28
  cache,
29
+ errors,
28
30
  events,
29
31
  migrations,
30
32
  tenancy,
31
33
  platform,
32
- ErrorCode,
33
34
  } from "@budibase/backend-core"
34
35
  import { checkAnyUserExists } from "../../../utilities/users"
35
36
  import { isEmailConfigured } from "../../../utilities/email"
@@ -420,7 +421,7 @@ export const inviteAccept = async (
420
421
  email: user.email,
421
422
  }
422
423
  } catch (err: any) {
423
- if (err.code === ErrorCode.USAGE_LIMIT_EXCEEDED) {
424
+ if (err.code === errors.codes.USAGE_LIMIT_EXCEEDED) {
424
425
  // explicitly re-throw limit exceeded errors
425
426
  ctx.throw(400, err)
426
427
  }
@@ -7,7 +7,6 @@ export const fetch = async (ctx: BBContext) => {
7
7
  cloud: !env.SELF_HOSTED,
8
8
  accountPortalUrl: env.ACCOUNT_PORTAL_URL,
9
9
  disableAccountPortal: env.DISABLE_ACCOUNT_PORTAL,
10
- baseUrl: env.PLATFORM_URL,
11
10
  // in test need to pretend its in production for the UI (Cypress)
12
11
  isDev: env.isDev() && !env.isTest(),
13
12
  }
@@ -17,7 +17,3 @@ export async function destroy(ctx: UserCtx) {
17
17
  throw err
18
18
  }
19
19
  }
20
-
21
- export async function info(ctx: UserCtx) {
22
- ctx.body = await tenantSdk.tenantInfo(ctx.params.tenantId)
23
- }
@@ -286,17 +286,14 @@ describe("configs", () => {
286
286
  type: "settings",
287
287
  config: {
288
288
  company: "Budibase",
289
- emailBrandingEnabled: true,
290
289
  logoUrl: "",
291
290
  analyticsEnabled: false,
292
291
  google: false,
293
- googleDatasourceConfigured: false,
294
292
  googleCallbackUrl: `http://localhost:10000/api/global/auth/${config.tenantId}/google/callback`,
295
293
  isSSOEnforced: false,
296
294
  oidc: false,
297
295
  oidcCallbackUrl: `http://localhost:10000/api/global/auth/${config.tenantId}/oidc/callback`,
298
296
  platformUrl: "http://localhost:10000",
299
- testimonialsEnabled: true,
300
297
  },
301
298
  }
302
299
  delete body._rev
@@ -23,7 +23,6 @@ describe("/api/system/environment", () => {
23
23
  disableAccountPortal: 0,
24
24
  isDev: false,
25
25
  multiTenancy: true,
26
- baseUrl: "http://localhost:10000",
27
26
  })
28
27
  })
29
28
  })
@@ -20,7 +20,6 @@ export enum TemplateType {
20
20
  }
21
21
 
22
22
  export enum EmailTemplatePurpose {
23
- CORE = "core",
24
23
  BASE = "base",
25
24
  PASSWORD_RECOVERY = "password_recovery",
26
25
  INVITATION = "invitation",
@@ -21,7 +21,6 @@ export const EmailTemplates = {
21
21
  join(__dirname, "welcome.hbs")
22
22
  ),
23
23
  [EmailTemplatePurpose.CUSTOM]: readStaticFile(join(__dirname, "custom.hbs")),
24
- [EmailTemplatePurpose.CORE]: readStaticFile(join(__dirname, "core.hbs")),
25
24
  }
26
25
 
27
26
  export function addBaseTemplates(templates: Template[], type?: string) {
package/src/index.ts CHANGED
@@ -21,7 +21,6 @@ import {
21
21
  middleware,
22
22
  queue,
23
23
  env as coreEnv,
24
- timers,
25
24
  } from "@budibase/backend-core"
26
25
  db.init()
27
26
  import Koa from "koa"
@@ -92,7 +91,6 @@ server.on("close", async () => {
92
91
  }
93
92
  shuttingDown = true
94
93
  console.log("Server Closed")
95
- timers.cleanup()
96
94
  await redis.shutdown()
97
95
  await events.shutdown()
98
96
  await queue.shutdown()
@@ -74,10 +74,3 @@ async function removeTenantUsers(tenantId: string) {
74
74
  throw err
75
75
  }
76
76
  }
77
-
78
- export async function tenantInfo(tenantId: string) {
79
- const globalDbName = tenancy.getGlobalDBName(tenantId)
80
- return {
81
- exists: await dbCore.dbExists(globalDbName),
82
- }
83
- }
@@ -106,8 +106,6 @@ class TestConfiguration {
106
106
  async afterAll() {
107
107
  if (this.server) {
108
108
  await this.server.close()
109
- } else {
110
- await require("../index").default.close()
111
109
  }
112
110
  }
113
111
 
@@ -2,10 +2,8 @@ import TestConfiguration from "../TestConfiguration"
2
2
  import { TestAPI, TestAPIOpts } from "./base"
3
3
 
4
4
  export class TenantAPI extends TestAPI {
5
- config: TestConfiguration
6
5
  constructor(config: TestConfiguration) {
7
6
  super(config)
8
- this.config = config
9
7
  }
10
8
 
11
9
  delete = (tenantId: string, opts?: TestAPIOpts) => {
@@ -10,4 +10,3 @@ process.env.MINIO_SECRET_KEY = "test"
10
10
  process.env.PLATFORM_URL = "http://localhost:10000"
11
11
  process.env.INTERNAL_API_KEY = "tet"
12
12
  process.env.DISABLE_ACCOUNT_PORTAL = "0"
13
- process.env.REDIS_PASSWORD = "budibase"
@@ -2,7 +2,7 @@ import "./logging"
2
2
 
3
3
  import { mocks, testContainerUtils } from "@budibase/backend-core/tests"
4
4
  import env from "../environment"
5
- import { env as coreEnv, timers } from "@budibase/backend-core"
5
+ import { env as coreEnv } from "@budibase/backend-core"
6
6
 
7
7
  // must explicitly enable fetch mock
8
8
  mocks.fetch.enable()
@@ -21,7 +21,3 @@ if (!process.env.CI) {
21
21
  }
22
22
 
23
23
  testContainerUtils.setupEnv(env, coreEnv)
24
-
25
- afterAll(() => {
26
- timers.cleanup()
27
- })
@@ -1,6 +1,6 @@
1
1
  import env from "../environment"
2
2
  import { EmailTemplatePurpose, TemplateType } from "../constants"
3
- import { getTemplateByPurpose, EmailTemplates } from "../constants/templates"
3
+ import { getTemplateByPurpose } from "../constants/templates"
4
4
  import { getSettingsTemplateContext } from "./templates"
5
5
  import { processString } from "@budibase/string-templates"
6
6
  import { getResetPasswordCode, getInviteCode } from "./redis"
@@ -109,16 +109,11 @@ async function buildEmail(
109
109
  getTemplateByPurpose(TYPE, EmailTemplatePurpose.BASE),
110
110
  getTemplateByPurpose(TYPE, purpose),
111
111
  ])
112
-
113
- // Change from branding to core
114
- let core = EmailTemplates[EmailTemplatePurpose.CORE]
115
-
116
- if (!base || !body || !core) {
112
+ if (!base || !body) {
117
113
  throw "Unable to build email, missing base components"
118
114
  }
119
115
  base = base.contents
120
116
  body = body.contents
121
-
122
117
  let name = user ? user.name : undefined
123
118
  if (user && !name && user.firstName) {
124
119
  name = user.lastName ? `${user.firstName} ${user.lastName}` : user.firstName
@@ -131,12 +126,8 @@ async function buildEmail(
131
126
  user: user || {},
132
127
  }
133
128
 
134
- // Prepend the core template
135
- const fullBody = core + body
136
-
137
- body = await processString(fullBody, context)
138
-
139
- // this should now be the core email HTML
129
+ body = await processString(body, context)
130
+ // this should now be the complete email HTML
140
131
  return processString(base, {
141
132
  ...context,
142
133
  body,
@@ -1,22 +1,17 @@
1
1
  import { tenancy, configs } from "@budibase/backend-core"
2
- import { SettingsInnerConfig } from "@budibase/types"
3
2
  import {
4
3
  InternalTemplateBinding,
5
4
  LOGO_URL,
6
5
  EmailTemplatePurpose,
7
6
  } from "../constants"
8
7
  import { checkSlashesInUrl } from "./index"
9
- import { getLicensedConfig } from "./configs"
10
-
11
8
  const BASE_COMPANY = "Budibase"
12
- import * as pro from "@budibase/pro"
13
9
 
14
10
  export async function getSettingsTemplateContext(
15
11
  purpose: EmailTemplatePurpose,
16
12
  code?: string | null
17
13
  ) {
18
- const settings = await configs.getSettingsConfig()
19
- const branding = await pro.branding.getBrandingConfig(settings)
14
+ let settings = await configs.getSettingsConfig()
20
15
  const URL = settings.platformUrl
21
16
  const context: any = {
22
17
  [InternalTemplateBinding.LOGO_URL]:
@@ -30,9 +25,6 @@ export async function getSettingsTemplateContext(
30
25
  [InternalTemplateBinding.CURRENT_DATE]: new Date().toISOString(),
31
26
  [InternalTemplateBinding.CURRENT_YEAR]: new Date().getFullYear(),
32
27
  }
33
-
34
- context["enableEmailBranding"] = branding.emailBrandingEnabled === true
35
-
36
28
  // attach purpose specific context
37
29
  switch (purpose) {
38
30
  case EmailTemplatePurpose.PASSWORD_RECOVERY:
@@ -1,33 +0,0 @@
1
- {{#if enableEmailBranding}}
2
- <tr>
3
- <td cellpadding="0" cellspacing="0">
4
- <table
5
- align="center"
6
- width="570"
7
- cellpadding="0"
8
- cellspacing="0"
9
- role="presentation"
10
- >
11
- <tbody>
12
- <tr>
13
- <td
14
- style="padding:0 35px; padding-top: 15px;"
15
- cellpadding="0"
16
- cellspacing="0"
17
- >
18
- <img
19
- width="32px"
20
- style="margin-right:16px; vertical-align: middle;"
21
- alt="Budibase Logo"
22
- src="https://i.imgur.com/Xhdt1YP.png"
23
- />
24
- <strong style="vertical-align: middle; font-size: 1.1em">
25
- Budibase
26
- </strong>
27
- </td>
28
- </tr>
29
- </tbody>
30
- </table>
31
- </td>
32
- </tr>
33
- {{/if}}
@@ -1,27 +0,0 @@
1
- import * as pro from "@budibase/pro"
2
-
3
- export async function getLicensedConfig() {
4
- let licensedConfig: object = {}
5
- const defaults = {
6
- emailBrandingEnabled: true,
7
- testimonialsEnabled: true,
8
- platformTitle: undefined,
9
- metaDescription: undefined,
10
- loginHeading: undefined,
11
- loginButton: undefined,
12
- metaImageUrl: undefined,
13
- metaTitle: undefined,
14
- }
15
-
16
- try {
17
- // License/Feature Checks
18
- const enabled = await pro.features.isBrandingEnabled()
19
- if (!enabled) {
20
- licensedConfig = { ...defaults }
21
- }
22
- } catch (e) {
23
- licensedConfig = { ...defaults }
24
- console.info("Could not retrieve license", e)
25
- }
26
- return licensedConfig
27
- }