@budibase/worker 2.13.14 → 2.13.16

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/Dockerfile CHANGED
@@ -5,22 +5,38 @@ LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="scripts/watchtower-ho
5
5
  LABEL com.centurylinklabs.watchtower.lifecycle.post-update="scripts/watchtower-hooks/post-update.sh"
6
6
  LABEL com.centurylinklabs.watchtower.lifecycle.post-check="scripts/watchtower-hooks/post-check.sh"
7
7
 
8
- WORKDIR /app
9
8
 
10
9
  # handle node-gyp
11
- RUN apk add --no-cache --virtual .gyp python3 make g++
10
+ RUN apk add --no-cache --virtual .gyp python3 make g++ jq
12
11
  RUN yarn global add pm2
13
12
 
13
+ WORKDIR /
14
+
15
+ COPY scripts/removeWorkspaceDependencies.sh scripts/removeWorkspaceDependencies.sh
16
+ RUN chmod +x ./scripts/removeWorkspaceDependencies.sh
17
+
18
+
19
+ WORKDIR /string-templates
20
+ COPY packages/string-templates/package.json package.json
21
+ RUN ../scripts/removeWorkspaceDependencies.sh package.json
22
+ RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --production=true --network-timeout 1000000
23
+ COPY packages/string-templates .
24
+
14
25
 
15
- COPY package.json .
16
- COPY dist/yarn.lock .
17
- RUN yarn install --production=true --network-timeout 1000000
26
+ WORKDIR /app
27
+ COPY packages/worker/package.json .
28
+ COPY packages/worker/dist/yarn.lock .
29
+ RUN cd ../string-templates && yarn link && cd - && yarn link @budibase/string-templates
30
+
31
+ RUN ../scripts/removeWorkspaceDependencies.sh package.json
32
+
33
+ RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --production=true --network-timeout 1000000
18
34
  # Remove unneeded data from file system to reduce image size
19
35
  RUN apk del .gyp \
20
36
  && yarn cache clean
21
37
 
22
- COPY dist/ dist/
23
- COPY docker_run.sh .
38
+ COPY packages/worker/dist/ dist/
39
+ COPY packages/worker/docker_run.sh .
24
40
 
25
41
  EXPOSE 4001
26
42
 
@@ -34,4 +50,9 @@ ENV POSTHOG_TOKEN=phc_bIjZL7oh2GEUd2vqvTBH8WvrX0fWTFQMs6H5KQxiUxU
34
50
  ENV TENANT_FEATURE_FLAGS=*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR
35
51
  ENV ACCOUNT_PORTAL_URL=https://account.budibase.app
36
52
 
53
+ ARG BUDIBASE_VERSION
54
+ # Ensuring the version argument is sent
55
+ RUN test -n "$BUDIBASE_VERSION"
56
+ ENV BUDIBASE_VERSION=$BUDIBASE_VERSION
57
+
37
58
  CMD ["./docker_run.sh"]
@@ -1,4 +1,5 @@
1
1
  import fs from "fs"
2
+
2
3
  module FetchMock {
3
4
  const fetch = jest.requireActual("node-fetch")
4
5
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.13.14",
4
+ "version": "2.13.16",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -37,10 +37,10 @@
37
37
  "author": "Budibase",
38
38
  "license": "GPL-3.0",
39
39
  "dependencies": {
40
- "@budibase/backend-core": "2.13.14",
41
- "@budibase/pro": "2.13.14",
42
- "@budibase/string-templates": "2.13.14",
43
- "@budibase/types": "2.13.14",
40
+ "@budibase/backend-core": "2.13.16",
41
+ "@budibase/pro": "2.13.16",
42
+ "@budibase/string-templates": "2.13.16",
43
+ "@budibase/types": "2.13.16",
44
44
  "@koa/router": "8.0.8",
45
45
  "@techpass/passport-openidconnect": "0.3.2",
46
46
  "@types/global-agent": "2.1.1",
@@ -107,5 +107,5 @@
107
107
  }
108
108
  }
109
109
  },
110
- "gitHead": "d7323933c747ed34405f6c7b12558fbd84f8f361"
110
+ "gitHead": "ea1029726d55fb3604a8b1463e9ea159cdbd2aae"
111
111
  }
@@ -51,10 +51,22 @@ export async function removeAppRole(ctx: Ctx) {
51
51
  const users = await sdk.users.db.allUsers()
52
52
  const bulk = []
53
53
  const cacheInvalidations = []
54
+ const prodAppId = dbCore.getProdAppID(appId)
54
55
  for (let user of users) {
55
- if (user.roles[appId]) {
56
- cacheInvalidations.push(cache.user.invalidateUser(user._id))
57
- delete user.roles[appId]
56
+ let updated = false
57
+ if (user.roles[prodAppId]) {
58
+ cacheInvalidations.push(cache.user.invalidateUser(user._id!))
59
+ delete user.roles[prodAppId]
60
+ updated = true
61
+ }
62
+ if (user.builder && Array.isArray(user.builder?.apps)) {
63
+ const idx = user.builder.apps.indexOf(prodAppId)
64
+ if (idx !== -1) {
65
+ user.builder.apps.splice(idx, 1)
66
+ updated = true
67
+ }
68
+ }
69
+ if (updated) {
58
70
  bulk.push(user)
59
71
  }
60
72
  }
@@ -10,6 +10,7 @@ import {
10
10
  import env from "../../../environment"
11
11
  import { groups } from "@budibase/pro"
12
12
  import { UpdateSelfRequest, UpdateSelfResponse, UserCtx } from "@budibase/types"
13
+
13
14
  const { newid } = utils
14
15
 
15
16
  function newTestApiKey() {
@@ -120,28 +120,17 @@ export const adminUser = async (
120
120
  )
121
121
  }
122
122
 
123
- const user: User = {
124
- email: email,
125
- password: password,
126
- createdAt: Date.now(),
127
- roles: {},
128
- builder: {
129
- global: true,
130
- },
131
- admin: {
132
- global: true,
133
- },
134
- tenantId,
135
- ssoId,
136
- }
137
123
  try {
138
- // always bust checklist beforehand, if an error occurs but can proceed, don't get
139
- // stuck in a cycle
140
- await cache.bustCache(cache.CacheKey.CHECKLIST)
141
- const finalUser = await userSdk.db.save(user, {
142
- hashPassword,
143
- requirePassword,
144
- })
124
+ const finalUser = await userSdk.db.createAdminUser(
125
+ email,
126
+ password,
127
+ tenantId,
128
+ {
129
+ ssoId,
130
+ hashPassword,
131
+ requirePassword,
132
+ }
133
+ )
145
134
 
146
135
  // events
147
136
  let account: CloudAccount | undefined
package/src/api/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import Router from "@koa/router"
2
+
2
3
  const compress = require("koa-compress")
4
+
3
5
  import zlib from "zlib"
4
6
  import { routes } from "./routes"
5
7
  import { middleware as pro } from "@budibase/pro"
@@ -3,6 +3,7 @@ import * as controller from "../../controllers/global/templates"
3
3
  import { TemplatePurpose, TemplateType } from "../../../constants"
4
4
  import { auth as authCore } from "@budibase/backend-core"
5
5
  import Joi from "joi"
6
+
6
7
  const { adminOnly, joiValidator } = authCore
7
8
 
8
9
  const router: Router = new Router()
@@ -7,6 +7,7 @@ import {
7
7
  structures,
8
8
  generator,
9
9
  } from "../../../../tests"
10
+
10
11
  const sendMailMock = mocks.email.mock()
11
12
  import { events, constants } from "@budibase/backend-core"
12
13
  import { Response } from "superagent"
@@ -1,6 +1,7 @@
1
1
  // mock the email system
2
2
  jest.mock("nodemailer")
3
3
  import { TestConfiguration, structures, mocks } from "../../../../tests"
4
+
4
5
  mocks.email.mock()
5
6
  import { events } from "@budibase/backend-core"
6
7
  import { GetPublicSettingsResponse, Config, ConfigType } from "@budibase/types"
@@ -1,5 +1,6 @@
1
1
  jest.mock("nodemailer")
2
2
  import { TestConfiguration, mocks } from "../../../../tests"
3
+
3
4
  const sendMailMock = mocks.email.mock()
4
5
  import { EmailTemplatePurpose } from "../../../../constants"
5
6
 
@@ -1,4 +1,5 @@
1
1
  import { TestConfiguration, mocks, structures } from "../../../../tests"
2
+
2
3
  const licensing = mocks.pro.licensing
3
4
  const quotas = mocks.pro.quotas
4
5
 
@@ -1,6 +1,7 @@
1
1
  jest.unmock("node-fetch")
2
2
  import { TestConfiguration } from "../../../../tests"
3
3
  import { EmailTemplatePurpose } from "../../../../constants"
4
+
4
5
  const nodemailer = require("nodemailer")
5
6
  const fetch = require("node-fetch")
6
7
 
@@ -1,6 +1,7 @@
1
1
  import { HealthStatusResponse } from "@budibase/types"
2
2
  import { TestConfiguration } from "../../../../tests"
3
3
  import { accounts as _accounts } from "@budibase/backend-core"
4
+
4
5
  const accounts = jest.mocked(_accounts)
5
6
 
6
7
  describe("/api/system/status", () => {
package/src/index.ts CHANGED
@@ -18,13 +18,14 @@ import {
18
18
  timers,
19
19
  redis,
20
20
  } from "@budibase/backend-core"
21
+
21
22
  db.init()
22
- import Koa from "koa"
23
23
  import koaBody from "koa-body"
24
24
  import http from "http"
25
25
  import api from "./api"
26
26
 
27
27
  const koaSession = require("koa-session")
28
+
28
29
  import { userAgent } from "koa-useragent"
29
30
 
30
31
  import destroyable from "server-destroy"
@@ -40,7 +41,7 @@ if (coreEnv.ENABLE_SSO_MAINTENANCE_MODE) {
40
41
  // this will setup http and https proxies form env variables
41
42
  bootstrap()
42
43
 
43
- const app: Application = new Koa()
44
+ const app: Application = new Application()
44
45
 
45
46
  app.keys = ["secret", "key"]
46
47
 
@@ -7,10 +7,13 @@ mocks.licenses.init(mocks.pro)
7
7
  mocks.licenses.useUnlimited()
8
8
 
9
9
  import * as dbConfig from "../db"
10
+
10
11
  dbConfig.init()
11
12
  import env from "../environment"
12
13
  import * as controllers from "./controllers"
14
+
13
15
  const supertest = require("supertest")
16
+
14
17
  import { Config } from "../constants"
15
18
  import {
16
19
  users,
@@ -8,6 +8,7 @@ mocks.fetch.enable()
8
8
  // mock all dates to 2020-01-01T00:00:00.000Z
9
9
  // use tk.reset() to use real dates in individual tests
10
10
  const tk = require("timekeeper")
11
+
11
12
  tk.freeze(mocks.date.MOCK_DATE)
12
13
 
13
14
  if (!process.env.CI) {
@@ -2,6 +2,7 @@ import * as email from "./email"
2
2
  import { mocks } from "@budibase/backend-core/tests"
3
3
 
4
4
  import * as _pro from "@budibase/pro"
5
+
5
6
  const pro = jest.mocked(_pro, { shallow: false })
6
7
 
7
8
  export default {
@@ -6,6 +6,7 @@ import { processString } from "@budibase/string-templates"
6
6
  import { User, SendEmailOpts, SMTPInnerConfig } from "@budibase/types"
7
7
  import { configs, cache } from "@budibase/backend-core"
8
8
  import ical from "ical-generator"
9
+
9
10
  const nodemailer = require("nodemailer")
10
11
 
11
12
  const TEST_MODE = env.ENABLE_EMAIL_TEST_MODE && env.isDev()
package/Dockerfile.v2 DELETED
@@ -1,58 +0,0 @@
1
- FROM node:18-alpine
2
-
3
- LABEL com.centurylinklabs.watchtower.lifecycle.pre-check="scripts/watchtower-hooks/pre-check.sh"
4
- LABEL com.centurylinklabs.watchtower.lifecycle.pre-update="scripts/watchtower-hooks/pre-update.sh"
5
- LABEL com.centurylinklabs.watchtower.lifecycle.post-update="scripts/watchtower-hooks/post-update.sh"
6
- LABEL com.centurylinklabs.watchtower.lifecycle.post-check="scripts/watchtower-hooks/post-check.sh"
7
-
8
-
9
- # handle node-gyp
10
- RUN apk add --no-cache --virtual .gyp python3 make g++ jq
11
- RUN yarn global add pm2
12
-
13
- WORKDIR /
14
-
15
- COPY scripts/removeWorkspaceDependencies.sh scripts/removeWorkspaceDependencies.sh
16
- RUN chmod +x ./scripts/removeWorkspaceDependencies.sh
17
-
18
-
19
- WORKDIR /string-templates
20
- COPY packages/string-templates/package.json package.json
21
- RUN ../scripts/removeWorkspaceDependencies.sh package.json
22
- RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --production=true --network-timeout 1000000
23
- COPY packages/string-templates .
24
-
25
-
26
- WORKDIR /app
27
- COPY packages/worker/package.json .
28
- COPY packages/worker/dist/yarn.lock .
29
- RUN cd ../string-templates && yarn link && cd - && yarn link @budibase/string-templates
30
-
31
- RUN ../scripts/removeWorkspaceDependencies.sh package.json
32
-
33
- RUN --mount=type=cache,target=/root/.yarn YARN_CACHE_FOLDER=/root/.yarn yarn install --production=true --network-timeout 1000000
34
- # Remove unneeded data from file system to reduce image size
35
- RUN apk del .gyp \
36
- && yarn cache clean
37
-
38
- COPY packages/worker/dist/ dist/
39
- COPY packages/worker/docker_run.sh .
40
-
41
- EXPOSE 4001
42
-
43
- # have to add node environment production after install
44
- # due to this causing yarn to stop installing dev dependencies
45
- # which are actually needed to get this environment up and running
46
- ENV NODE_ENV=production
47
- ENV CLUSTER_MODE=${CLUSTER_MODE}
48
- ENV SERVICE=worker-service
49
- ENV POSTHOG_TOKEN=phc_bIjZL7oh2GEUd2vqvTBH8WvrX0fWTFQMs6H5KQxiUxU
50
- ENV TENANT_FEATURE_FLAGS=*:LICENSING,*:USER_GROUPS,*:ONBOARDING_TOUR
51
- ENV ACCOUNT_PORTAL_URL=https://account.budibase.app
52
-
53
- ARG BUDIBASE_VERSION
54
- # Ensuring the version argument is sent
55
- RUN test -n "$BUDIBASE_VERSION"
56
- ENV BUDIBASE_VERSION=$BUDIBASE_VERSION
57
-
58
- CMD ["./docker_run.sh"]