@budibase/worker 1.0.185-alpha.7 → 1.0.185

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/docker_run.sh CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
1
3
  if [[ -z $CLUSTER_MODE ]]; then
2
4
  yarn run:docker
3
5
  else
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.185-alpha.7",
4
+ "version": "1.0.185",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -32,9 +32,9 @@
32
32
  "author": "Budibase",
33
33
  "license": "GPL-3.0",
34
34
  "dependencies": {
35
- "@budibase/backend-core": "^1.0.185-alpha.7",
36
- "@budibase/pro": "1.0.185-alpha.6",
37
- "@budibase/string-templates": "^1.0.185-alpha.7",
35
+ "@budibase/backend-core": "^1.0.185",
36
+ "@budibase/pro": "1.0.184",
37
+ "@budibase/string-templates": "^1.0.185",
38
38
  "@koa/router": "^8.0.0",
39
39
  "@sentry/node": "6.17.7",
40
40
  "@techpass/passport-openidconnect": "^0.3.0",
@@ -90,5 +90,5 @@
90
90
  "./scripts/jestSetup.js"
91
91
  ]
92
92
  },
93
- "gitHead": "5d1fd1e48955e7ef59a0fa2622dfd2d786a763e1"
93
+ "gitHead": "9bdb67f67219b1227e4878c4a8751f0548f3ec7d"
94
94
  }
@@ -25,5 +25,6 @@ export const getInfo = async (ctx: any) => {
25
25
  }
26
26
 
27
27
  export const getQuotaUsage = async (ctx: any) => {
28
- ctx.body = await quotas.getQuotaUsage()
28
+ const usage = await quotas.getQuotaUsage()
29
+ ctx.body = usage
29
30
  }
@@ -75,8 +75,8 @@ const checkCurrentApp = ctx => {
75
75
  const addSessionAttributesToUser = ctx => {
76
76
  ctx.body.account = ctx.user.account
77
77
  ctx.body.license = ctx.user.license
78
- ctx.body.budibaseAccess = !!ctx.user.budibaseAccess
79
- ctx.body.accountPortalAccess = !!ctx.user.accountPortalAccess
78
+ ctx.body.budibaseAccess = ctx.user.budibaseAccess
79
+ ctx.body.accountPortalAccess = ctx.user.accountPortalAccess
80
80
  ctx.body.csrfToken = ctx.user.csrfToken
81
81
  }
82
82
 
@@ -12,7 +12,6 @@ const {
12
12
  getTenantId,
13
13
  getTenantUser,
14
14
  doesTenantExist,
15
- doInTenant,
16
15
  } = require("@budibase/backend-core/tenancy")
17
16
  const { removeUserFromInfoDB } = require("@budibase/backend-core/deprovision")
18
17
  const { errors } = require("@budibase/backend-core")
@@ -42,73 +41,70 @@ const parseBooleanParam = (param: any) => {
42
41
 
43
42
  export const adminUser = async (ctx: any) => {
44
43
  const { email, password, tenantId } = ctx.request.body
45
- await doInTenant(tenantId, async () => {
46
- // account portal sends a pre-hashed password - honour param to prevent double hashing
47
- const hashPassword = parseBooleanParam(ctx.request.query.hashPassword)
48
- // account portal sends no password for SSO users
49
- const requirePassword = parseBooleanParam(ctx.request.query.requirePassword)
50
-
51
- if (await doesTenantExist(tenantId)) {
52
- ctx.throw(403, "Organisation already exists.")
53
- }
54
44
 
55
- const response = await doWithGlobalDB(tenantId, async (db: any) => {
56
- const response = await db.allDocs(
57
- getGlobalUserParams(null, {
58
- include_docs: true,
59
- })
60
- )
61
- // write usage quotas for cloud
62
- if (!env.SELF_HOSTED) {
63
- // could be a scenario where it exists, make sure its clean
64
- try {
65
- const usageQuota = await db.get(
66
- StaticDatabases.GLOBAL.docs.usageQuota
67
- )
68
- if (usageQuota) {
69
- await db.remove(usageQuota._id, usageQuota._rev)
70
- }
71
- } catch (err) {
72
- // don't worry about errors
45
+ // account portal sends a pre-hashed password - honour param to prevent double hashing
46
+ const hashPassword = parseBooleanParam(ctx.request.query.hashPassword)
47
+ // account portal sends no password for SSO users
48
+ const requirePassword = parseBooleanParam(ctx.request.query.requirePassword)
49
+
50
+ if (await doesTenantExist(tenantId)) {
51
+ ctx.throw(403, "Organisation already exists.")
52
+ }
53
+
54
+ const response = await doWithGlobalDB(tenantId, async (db: any) => {
55
+ const response = await db.allDocs(
56
+ getGlobalUserParams(null, {
57
+ include_docs: true,
58
+ })
59
+ )
60
+ // write usage quotas for cloud
61
+ if (!env.SELF_HOSTED) {
62
+ // could be a scenario where it exists, make sure its clean
63
+ try {
64
+ const usageQuota = await db.get(StaticDatabases.GLOBAL.docs.usageQuota)
65
+ if (usageQuota) {
66
+ await db.remove(usageQuota._id, usageQuota._rev)
73
67
  }
74
- await db.put(quotas.generateNewQuotaUsage())
68
+ } catch (err) {
69
+ // don't worry about errors
75
70
  }
76
- return response
77
- })
78
-
79
- if (response.rows.some((row: any) => row.doc.admin)) {
80
- ctx.throw(
81
- 403,
82
- "You cannot initialise once an global user has been created."
83
- )
71
+ await db.put(quotas.generateNewQuotaUsage())
84
72
  }
73
+ return response
74
+ })
85
75
 
86
- const user = {
87
- email: email,
88
- password: password,
89
- createdAt: Date.now(),
90
- roles: {},
91
- builder: {
92
- global: true,
93
- },
94
- admin: {
95
- global: true,
96
- },
76
+ if (response.rows.some((row: any) => row.doc.admin)) {
77
+ ctx.throw(
78
+ 403,
79
+ "You cannot initialise once an global user has been created."
80
+ )
81
+ }
82
+
83
+ const user = {
84
+ email: email,
85
+ password: password,
86
+ createdAt: Date.now(),
87
+ roles: {},
88
+ builder: {
89
+ global: true,
90
+ },
91
+ admin: {
92
+ global: true,
93
+ },
94
+ tenantId,
95
+ }
96
+ try {
97
+ const finalUser = await users.save(
98
+ user,
97
99
  tenantId,
98
- }
99
- try {
100
- const finalUser = await users.save(
101
- user,
102
- tenantId,
103
- hashPassword,
104
- requirePassword
105
- )
106
- await bustCache(CacheKeys.CHECKLIST)
107
- ctx.body = finalUser
108
- } catch (err: any) {
109
- ctx.throw(err.status || 400, err)
110
- }
111
- })
100
+ hashPassword,
101
+ requirePassword
102
+ )
103
+ await bustCache(CacheKeys.CHECKLIST)
104
+ ctx.body = finalUser
105
+ } catch (err: any) {
106
+ ctx.throw(err.status || 400, err)
107
+ }
112
108
  }
113
109
 
114
110
  export const destroy = async (ctx: any) => {
@@ -27,40 +27,33 @@ function parseIntSafe(number) {
27
27
  }
28
28
 
29
29
  module.exports = {
30
- // auth
30
+ NODE_ENV: process.env.NODE_ENV,
31
+ SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
32
+ PORT: process.env.PORT || process.env.WORKER_PORT,
33
+ CLUSTER_PORT: process.env.CLUSTER_PORT,
31
34
  MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
32
35
  MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
36
+ MINIO_URL: process.env.MINIO_URL,
37
+ COUCH_DB_URL: process.env.COUCH_DB_URL,
38
+ LOG_LEVEL: process.env.LOG_LEVEL,
33
39
  JWT_SECRET: process.env.JWT_SECRET,
34
40
  SALT_ROUNDS: process.env.SALT_ROUNDS,
41
+ REDIS_URL: process.env.REDIS_URL,
35
42
  REDIS_PASSWORD: process.env.REDIS_PASSWORD,
36
43
  INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
37
- COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
38
- // urls
39
- MINIO_URL: process.env.MINIO_URL,
40
- COUCH_DB_URL: process.env.COUCH_DB_URL,
41
- REDIS_URL: process.env.REDIS_URL,
42
- ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
43
- PLATFORM_URL: process.env.PLATFORM_URL,
44
- APPS_URL: process.env.APPS_URL,
45
- // ports
46
- PORT: process.env.PORT || process.env.WORKER_PORT,
47
- CLUSTER_PORT: process.env.CLUSTER_PORT,
48
- // flags
49
- NODE_ENV: process.env.NODE_ENV,
50
- SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
51
- LOG_LEVEL: process.env.LOG_LEVEL,
52
44
  MULTI_TENANCY: process.env.MULTI_TENANCY,
53
45
  DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
46
+ ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
54
47
  SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED,
55
- DISABLE_DEVELOPER_LICENSE: process.env.DISABLE_DEVELOPER_LICENSE,
56
- // smtp
57
48
  SMTP_USER: process.env.SMTP_USER,
58
49
  SMTP_PASSWORD: process.env.SMTP_PASSWORD,
59
50
  SMTP_HOST: process.env.SMTP_HOST,
60
51
  SMTP_PORT: process.env.SMTP_PORT,
61
52
  SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
62
- // other
53
+ PLATFORM_URL: process.env.PLATFORM_URL,
54
+ COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
63
55
  CHECKLIST_CACHE_TTL: parseIntSafe(process.env.CHECKLIST_CACHE_TTL) || 3600,
56
+ APPS_URL: process.env.APPS_URL,
64
57
  _set(key, value) {
65
58
  process.env[key] = value
66
59
  module.exports[key] = value