@budibase/worker 2.8.22 → 2.8.23-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.
@@ -1,6 +1,10 @@
1
1
  const actual = jest.requireActual("@budibase/pro")
2
2
  const pro = {
3
3
  ...actual,
4
+ features: {
5
+ ...actual.features,
6
+ isSSOEnforced: jest.fn(),
7
+ },
4
8
  licensing: {
5
9
  keys: {
6
10
  activateLicenseKey: jest.fn(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.8.22",
4
+ "version": "2.8.23-alpha.0",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -38,10 +38,10 @@
38
38
  "author": "Budibase",
39
39
  "license": "GPL-3.0",
40
40
  "dependencies": {
41
- "@budibase/backend-core": "2.8.22",
42
- "@budibase/pro": "2.8.22",
43
- "@budibase/string-templates": "2.8.22",
44
- "@budibase/types": "2.8.22",
41
+ "@budibase/backend-core": "2.8.23-alpha.0",
42
+ "@budibase/pro": "2.8.23-alpha.0",
43
+ "@budibase/string-templates": "2.8.23-alpha.0",
44
+ "@budibase/types": "2.8.23-alpha.0",
45
45
  "@koa/router": "8.0.8",
46
46
  "@sentry/node": "6.17.7",
47
47
  "@techpass/passport-openidconnect": "0.3.2",
@@ -104,5 +104,5 @@
104
104
  "typescript": "4.7.3",
105
105
  "update-dotenv": "1.1.1"
106
106
  },
107
- "gitHead": "b0975991ddc123785883f3f871c527290a3ca538"
107
+ "gitHead": "1b460cd886d859d2bd8446291ea1d3bda2864396"
108
108
  }
@@ -507,17 +507,17 @@ export async function configChecklist(ctx: Ctx) {
507
507
  smtp: {
508
508
  checked: !!smtpConfig,
509
509
  label: "Set up email",
510
- link: "/builder/portal/manage/email",
510
+ link: "/builder/portal/settings/email",
511
511
  },
512
512
  adminUser: {
513
513
  checked: userExists,
514
514
  label: "Create your first user",
515
- link: "/builder/portal/manage/users",
515
+ link: "/builder/portal/users/users",
516
516
  },
517
517
  sso: {
518
518
  checked: !!googleConfig || !!oidcConfig,
519
519
  label: "Set up single sign-on",
520
- link: "/builder/portal/manage/auth",
520
+ link: "/builder/portal/settings/auth",
521
521
  },
522
522
  }
523
523
  }
@@ -1,6 +1,6 @@
1
1
  import { sendEmail as sendEmailFn } from "../../../utilities/email"
2
2
  import { tenancy } from "@budibase/backend-core"
3
- import { BBContext } from "@budibase/types"
3
+ import { BBContext, User } from "@budibase/types"
4
4
 
5
5
  export async function sendEmail(ctx: BBContext) {
6
6
  let {
@@ -16,10 +16,10 @@ export async function sendEmail(ctx: BBContext) {
16
16
  automation,
17
17
  invite,
18
18
  } = ctx.request.body
19
- let user
19
+ let user: any
20
20
  if (userId) {
21
21
  const db = tenancy.getGlobalDB()
22
- user = await db.get(userId)
22
+ user = await db.get<User>(userId)
23
23
  }
24
24
  const response = await sendEmailFn(email, purpose, {
25
25
  workspaceId,
@@ -35,7 +35,7 @@ export async function find(ctx: BBContext) {
35
35
  const appId = ctx.params.appId
36
36
  await context.doInAppContext(dbCore.getDevAppID(appId), async () => {
37
37
  const db = context.getAppDB()
38
- const app = await db.get(dbCore.DocumentType.APP_METADATA)
38
+ const app = await db.get<App>(dbCore.DocumentType.APP_METADATA)
39
39
  ctx.body = {
40
40
  roles: await roles.getAllRoles(),
41
41
  name: app.name,
@@ -44,7 +44,7 @@ export async function generateAPIKey(ctx: any) {
44
44
  const id = dbCore.generateDevInfoID(userId)
45
45
  let devInfo
46
46
  try {
47
- devInfo = await db.get(id)
47
+ devInfo = await db.get<any>(id)
48
48
  } catch (err) {
49
49
  devInfo = { _id: id, userId }
50
50
  }
@@ -412,7 +412,7 @@ export const inviteAccept = async (
412
412
 
413
413
  const saved = await userSdk.save(request)
414
414
  const db = tenancy.getGlobalDB()
415
- const user = await db.get(saved._id)
415
+ const user = await db.get<User>(saved._id)
416
416
  await events.user.inviteAccepted(user)
417
417
  return saved
418
418
  })
@@ -0,0 +1,13 @@
1
+ import { UserCtx } from "@budibase/types"
2
+ import { installation, logging } from "@budibase/backend-core"
3
+
4
+ export async function getLogs(ctx: UserCtx) {
5
+ const logReadStream = logging.system.getLogReadStream()
6
+
7
+ const { installId } = await installation.getInstall()
8
+
9
+ const fileName = `${installId}-${Date.now()}.log`
10
+
11
+ ctx.set("content-disposition", `attachment; filename=${fileName}`)
12
+ ctx.body = logReadStream
13
+ }
@@ -277,6 +277,7 @@ describe("configs", () => {
277
277
  describe("GET /api/global/configs/public", () => {
278
278
  it("should return the expected public settings", async () => {
279
279
  await saveSettingsConfig()
280
+ mocks.pro.features.isSSOEnforced.mockResolvedValue(false)
280
281
 
281
282
  const res = await config.api.configs.getPublicSettings()
282
283
  const body = res.body as GetPublicSettingsResponse
@@ -16,6 +16,9 @@ import licenseRoutes from "./global/license"
16
16
  import migrationRoutes from "./system/migrations"
17
17
  import accountRoutes from "./system/accounts"
18
18
  import restoreRoutes from "./system/restore"
19
+ import systemLogRoutes from "./system/logs"
20
+
21
+ import env from "../../environment"
19
22
 
20
23
  export const routes: Router[] = [
21
24
  configRoutes,
@@ -38,3 +41,7 @@ export const routes: Router[] = [
38
41
  eventRoutes,
39
42
  pro.scim,
40
43
  ]
44
+
45
+ if (env.SELF_HOSTED) {
46
+ routes.push(systemLogRoutes)
47
+ }
@@ -0,0 +1,9 @@
1
+ import Router from "@koa/router"
2
+ import { middleware } from "@budibase/backend-core"
3
+ import * as controller from "../../controllers/system/logs"
4
+
5
+ const router: Router = new Router()
6
+
7
+ router.get("/api/system/logs", middleware.adminOnly, controller.getLogs)
8
+
9
+ export default router
@@ -1,14 +1,9 @@
1
- import { structures } from "../../../tests"
2
- import { mocks } from "@budibase/backend-core/tests"
1
+ import { structures, mocks } from "../../../tests"
3
2
  import { env, context } from "@budibase/backend-core"
4
3
  import * as users from "../users"
5
4
  import { CloudAccount } from "@budibase/types"
6
5
  import { isPreventPasswordActions } from "../users"
7
6
 
8
- jest.mock("@budibase/pro")
9
- import * as _pro from "@budibase/pro"
10
- const pro = jest.mocked(_pro, true)
11
-
12
7
  describe("users", () => {
13
8
  beforeEach(() => {
14
9
  jest.clearAllMocks()
@@ -56,7 +51,7 @@ describe("users", () => {
56
51
  it("returns true for all users when sso is enforced", async () => {
57
52
  await context.doInTenant(structures.tenant.id(), async () => {
58
53
  const user = structures.users.user()
59
- pro.features.isSSOEnforced.mockResolvedValueOnce(true)
54
+ mocks.pro.features.isSSOEnforced.mockResolvedValueOnce(true)
60
55
  const result = await users.isPreventPasswordActions(user)
61
56
  expect(result).toBe(true)
62
57
  })