@budibase/server 1.0.190 → 1.0.192-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.
- package/builder/assets/{index.bb5e3dfd.css → index.8a6f249b.css} +2 -2
- package/builder/assets/index.e9d6bfd0.js +1315 -0
- package/builder/assets/{vendor.5240f480.js → vendor.9bf2fcb4.js} +53 -53
- package/builder/index.html +3 -3
- package/coverage/clover.xml +96 -83
- package/coverage/coverage-final.json +11 -11
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +15 -15
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +12 -9
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +3 -3
- package/coverage/lcov-report/api/controllers/view/index.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +13 -7
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +33 -9
- package/coverage/lcov-report/automations/index.html +26 -26
- package/coverage/lcov-report/automations/index.js.html +24 -9
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +14 -14
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +5 -2
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +10 -7
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +1 -1
- package/coverage/lcov-report/db/utils.js.html +4 -4
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +65 -65
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +43 -10
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +14 -14
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +11 -32
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +19 -19
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +29 -8
- package/coverage/lcov-report/utilities/queue/index.html +15 -15
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +168 -142
- package/dist/api/controllers/templates.js +2 -1
- package/dist/api/controllers/view/exporters.js +1 -1
- package/dist/api/index.js +3 -1
- package/dist/api/routes/public/index.js +11 -1
- package/dist/app.js +24 -4
- package/dist/automations/bullboard.js +7 -0
- package/dist/automations/index.js +4 -1
- package/dist/automations/steps/queryRows.js +1 -0
- package/dist/automations/steps/sendSmtpEmail.js +1 -0
- package/dist/environment.js +9 -13
- package/dist/middleware/builder.js +9 -2
- package/dist/package.json +5 -5
- package/dist/threads/index.js +20 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/budibaseDir.js +0 -6
- package/dist/utilities/queue/inMemoryQueue.js +8 -0
- package/dist/utilities/redis.js +1 -1
- package/package.json +6 -6
- package/scripts/likeCypress.ts +0 -1
- package/src/api/controllers/templates.js +2 -1
- package/src/api/controllers/view/exporters.js +1 -1
- package/src/api/index.js +3 -1
- package/src/api/routes/public/index.ts +10 -1
- package/src/app.ts +25 -4
- package/src/automations/bullboard.js +8 -0
- package/src/automations/index.js +6 -1
- package/src/automations/steps/queryRows.js +1 -0
- package/src/automations/steps/sendSmtpEmail.js +1 -0
- package/src/environment.js +9 -13
- package/src/middleware/builder.js +13 -2
- package/src/threads/index.ts +22 -0
- package/src/utilities/budibaseDir.js +0 -7
- package/src/utilities/queue/inMemoryQueue.js +7 -0
- package/src/utilities/redis.js +2 -0
- package/builder/assets/index.478109df.js +0 -1299
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const { join } = require("./centralPath");
|
|
3
|
-
const { homedir } = require("os");
|
|
4
|
-
const env = require("../environment");
|
|
5
2
|
const { budibaseTempDir } = require("@budibase/backend-core/objectStore");
|
|
6
|
-
module.exports.budibaseAppsDir = function () {
|
|
7
|
-
return env.BUDIBASE_DIR || join(homedir(), ".budibase");
|
|
8
|
-
};
|
|
9
3
|
module.exports.budibaseTempDir = budibaseTempDir;
|
|
@@ -80,6 +80,14 @@ class InMemoryQueue {
|
|
|
80
80
|
this._messages.push(newJob(this._name, msg));
|
|
81
81
|
this._emitter.emit("message");
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* replicating the close function from bull, which waits for jobs to finish.
|
|
85
|
+
*/
|
|
86
|
+
close() {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
return [];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
83
91
|
/**
|
|
84
92
|
* This removes a cron which has been implemented, this is part of Bull API.
|
|
85
93
|
* @param {string} cronJobId The cron which is to be removed.
|
package/dist/utilities/redis.js
CHANGED
|
@@ -51,7 +51,7 @@ exports.getAllLocks = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
51
51
|
exports.updateLock = (devAppId, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
52
|
// make sure always global user ID
|
|
53
53
|
const globalId = getGlobalIDFromUserMetadataID(user._id);
|
|
54
|
-
const inputUser = Object.assign(Object.assign({}, user), { userId: globalId, _id: globalId });
|
|
54
|
+
const inputUser = Object.assign(Object.assign({}, user), { userId: globalId, _id: globalId, lockedAt: new Date().getTime() });
|
|
55
55
|
yield devAppClient.store(devAppId, inputUser, APP_DEV_LOCK_SECONDS);
|
|
56
56
|
});
|
|
57
57
|
exports.clearLock = (devAppId, user) => __awaiter(void 0, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.192-alpha.0",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,10 +70,10 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/backend-core": "^1.0.
|
|
74
|
-
"@budibase/client": "^1.0.
|
|
75
|
-
"@budibase/pro": "1.0.
|
|
76
|
-
"@budibase/string-templates": "^1.0.
|
|
73
|
+
"@budibase/backend-core": "^1.0.192-alpha.0",
|
|
74
|
+
"@budibase/client": "^1.0.192-alpha.0",
|
|
75
|
+
"@budibase/pro": "1.0.191",
|
|
76
|
+
"@budibase/string-templates": "^1.0.192-alpha.0",
|
|
77
77
|
"@bull-board/api": "^3.7.0",
|
|
78
78
|
"@bull-board/koa": "^3.7.0",
|
|
79
79
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -184,5 +184,5 @@
|
|
|
184
184
|
"optionalDependencies": {
|
|
185
185
|
"oracledb": "^5.3.0"
|
|
186
186
|
},
|
|
187
|
-
"gitHead": "
|
|
187
|
+
"gitHead": "c4a7598c9a81e36f24c557e89d310c8145ac3a22"
|
|
188
188
|
}
|
package/scripts/likeCypress.ts
CHANGED
|
@@ -9,7 +9,6 @@ const SERVER_PORT = "4100"
|
|
|
9
9
|
const WORKER_PORT = "4200"
|
|
10
10
|
|
|
11
11
|
// @ts-ignore
|
|
12
|
-
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
|
|
13
12
|
process.env.NODE_ENV = "cypress"
|
|
14
13
|
process.env.ENABLE_ANALYTICS = "false"
|
|
15
14
|
process.env.JWT_SECRET = "budibase"
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const fetch = require("node-fetch")
|
|
2
2
|
const { downloadTemplate } = require("../../utilities/fileSystem")
|
|
3
|
+
const env = require("../../environment")
|
|
3
4
|
|
|
4
5
|
// development flag, can be used to test against templates exported locally
|
|
5
6
|
const DEFAULT_TEMPLATES_BUCKET =
|
|
6
7
|
"prod-budi-templates.s3-eu-west-1.amazonaws.com"
|
|
7
8
|
|
|
8
9
|
exports.fetch = async function (ctx) {
|
|
9
|
-
|
|
10
|
+
let type = env.TEMPLATE_REPOSITORY
|
|
10
11
|
let response,
|
|
11
12
|
error = false
|
|
12
13
|
try {
|
package/src/api/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const { mainRoutes, staticRoutes, publicRoutes } = require("./routes")
|
|
|
12
12
|
const pkg = require("../../package.json")
|
|
13
13
|
const env = require("../environment")
|
|
14
14
|
const { middleware: pro } = require("@budibase/pro")
|
|
15
|
+
const { shutdown } = require("./routes/public")
|
|
15
16
|
|
|
16
17
|
const router = new Router()
|
|
17
18
|
|
|
@@ -90,4 +91,5 @@ router.use(publicRoutes.allowedMethods())
|
|
|
90
91
|
router.use(staticRoutes.routes())
|
|
91
92
|
router.use(staticRoutes.allowedMethods())
|
|
92
93
|
|
|
93
|
-
module.exports = router
|
|
94
|
+
module.exports.router = router
|
|
95
|
+
module.exports.shutdown = shutdown
|
|
@@ -29,6 +29,7 @@ function getApiLimitPerSecond(): number {
|
|
|
29
29
|
return parseInt(env.API_REQ_LIMIT_PER_SEC)
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
let rateLimitStore: any = null
|
|
32
33
|
if (!env.isTest()) {
|
|
33
34
|
const REDIS_OPTS = getRedisOptions()
|
|
34
35
|
let options
|
|
@@ -47,8 +48,9 @@ if (!env.isTest()) {
|
|
|
47
48
|
database: 1,
|
|
48
49
|
}
|
|
49
50
|
}
|
|
51
|
+
rateLimitStore = new Stores.Redis(options)
|
|
50
52
|
RateLimit.defaultOptions({
|
|
51
|
-
store:
|
|
53
|
+
store: rateLimitStore,
|
|
52
54
|
})
|
|
53
55
|
}
|
|
54
56
|
// rate limiting, allows for 2 requests per second
|
|
@@ -128,3 +130,10 @@ applyRoutes(queryEndpoints, PermissionTypes.QUERY, "queryId")
|
|
|
128
130
|
applyRoutes(rowEndpoints, PermissionTypes.TABLE, "tableId", "rowId")
|
|
129
131
|
|
|
130
132
|
export default publicRouter
|
|
133
|
+
|
|
134
|
+
export const shutdown = () => {
|
|
135
|
+
if (rateLimitStore) {
|
|
136
|
+
rateLimitStore.client.disconnect()
|
|
137
|
+
rateLimitStore = null
|
|
138
|
+
}
|
|
139
|
+
}
|
package/src/app.ts
CHANGED
|
@@ -14,6 +14,8 @@ const automations = require("./automations/index")
|
|
|
14
14
|
const Sentry = require("@sentry/node")
|
|
15
15
|
const fileSystem = require("./utilities/fileSystem")
|
|
16
16
|
const bullboard = require("./automations/bullboard")
|
|
17
|
+
const { logAlert } = require("@budibase/backend-core/logging")
|
|
18
|
+
const { Thread } = require("./threads")
|
|
17
19
|
import redis from "./utilities/redis"
|
|
18
20
|
import * as migrations from "./migrations"
|
|
19
21
|
|
|
@@ -49,7 +51,7 @@ app.context.eventEmitter = eventEmitter
|
|
|
49
51
|
app.context.auth = {}
|
|
50
52
|
|
|
51
53
|
// api routes
|
|
52
|
-
app.use(api.routes())
|
|
54
|
+
app.use(api.router.routes())
|
|
53
55
|
|
|
54
56
|
if (env.isProd()) {
|
|
55
57
|
env._set("NODE_ENV", "production")
|
|
@@ -68,11 +70,24 @@ if (env.isProd()) {
|
|
|
68
70
|
const server = http.createServer(app.callback())
|
|
69
71
|
destroyable(server)
|
|
70
72
|
|
|
73
|
+
let shuttingDown = false,
|
|
74
|
+
errCode = 0
|
|
71
75
|
server.on("close", async () => {
|
|
72
|
-
|
|
76
|
+
// already in process
|
|
77
|
+
if (shuttingDown) {
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
shuttingDown = true
|
|
81
|
+
if (!env.isTest()) {
|
|
73
82
|
console.log("Server Closed")
|
|
74
83
|
}
|
|
84
|
+
await automations.shutdown()
|
|
75
85
|
await redis.shutdown()
|
|
86
|
+
await Thread.shutdown()
|
|
87
|
+
api.shutdown()
|
|
88
|
+
if (!env.isTest()) {
|
|
89
|
+
process.exit(errCode)
|
|
90
|
+
}
|
|
76
91
|
})
|
|
77
92
|
|
|
78
93
|
module.exports = server.listen(env.PORT || 0, async () => {
|
|
@@ -90,7 +105,13 @@ const shutdown = () => {
|
|
|
90
105
|
}
|
|
91
106
|
|
|
92
107
|
process.on("uncaughtException", err => {
|
|
93
|
-
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
// don't worry about this error, comes from zlib isn't important
|
|
110
|
+
if (err && err["code"] === "ERR_INVALID_CHAR") {
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
errCode = -1
|
|
114
|
+
logAlert("Uncaught exception.", err)
|
|
94
115
|
shutdown()
|
|
95
116
|
})
|
|
96
117
|
|
|
@@ -102,7 +123,7 @@ process.on("SIGTERM", () => {
|
|
|
102
123
|
// not recommended in a clustered environment
|
|
103
124
|
if (!env.HTTP_MIGRATIONS) {
|
|
104
125
|
migrations.migrate().catch(err => {
|
|
105
|
-
|
|
126
|
+
logAlert("Error performing migrations. Exiting.", err)
|
|
106
127
|
shutdown()
|
|
107
128
|
})
|
|
108
129
|
}
|
|
@@ -45,4 +45,12 @@ exports.init = () => {
|
|
|
45
45
|
return serverAdapter.registerPlugin()
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
exports.shutdown = async () => {
|
|
49
|
+
if (automationQueue) {
|
|
50
|
+
clearInterval(cleanupInternal)
|
|
51
|
+
await automationQueue.close()
|
|
52
|
+
automationQueue = null
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
exports.queue = automationQueue
|
package/src/automations/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { processEvent } = require("./utils")
|
|
2
|
-
const { queue } = require("./bullboard")
|
|
2
|
+
const { queue, shutdown } = require("./bullboard")
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* This module is built purely to kick off the worker farm and manage the inputs/outputs
|
|
@@ -14,4 +14,9 @@ exports.init = function () {
|
|
|
14
14
|
exports.getQueues = () => {
|
|
15
15
|
return [queue]
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
exports.shutdown = () => {
|
|
19
|
+
return shutdown()
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
exports.queue = queue
|
package/src/environment.js
CHANGED
|
@@ -43,15 +43,12 @@ module.exports = {
|
|
|
43
43
|
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
|
44
44
|
MINIO_URL: process.env.MINIO_URL,
|
|
45
45
|
WORKER_URL: process.env.WORKER_URL,
|
|
46
|
-
SELF_HOSTED: process.env.SELF_HOSTED,
|
|
47
46
|
AWS_REGION: process.env.AWS_REGION,
|
|
48
|
-
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
|
49
47
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
50
48
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
|
51
49
|
REDIS_URL: process.env.REDIS_URL,
|
|
52
50
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
|
53
51
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
|
54
|
-
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
|
55
52
|
HTTP_MIGRATIONS: process.env.HTTP_MIGRATIONS,
|
|
56
53
|
API_REQ_LIMIT_PER_SEC: process.env.API_REQ_LIMIT_PER_SEC,
|
|
57
54
|
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
|
|
@@ -61,28 +58,27 @@ module.exports = {
|
|
|
61
58
|
JEST_WORKER_ID: process.env.JEST_WORKER_ID,
|
|
62
59
|
BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
|
|
63
60
|
DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
|
|
61
|
+
TEMPLATE_REPOSITORY: process.env.TEMPLATE_REPOSITORY || "app",
|
|
64
62
|
DISABLE_AUTO_PROD_APP_SYNC: process.env.DISABLE_AUTO_PROD_APP_SYNC,
|
|
65
63
|
// minor
|
|
66
64
|
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
|
67
65
|
LOGGER: process.env.LOGGER,
|
|
68
66
|
LOG_LEVEL: process.env.LOG_LEVEL,
|
|
69
|
-
AUTOMATION_DIRECTORY: process.env.AUTOMATION_DIRECTORY,
|
|
70
|
-
AUTOMATION_BUCKET: process.env.AUTOMATION_BUCKET,
|
|
71
67
|
AUTOMATION_MAX_ITERATIONS: process.env.AUTOMATION_MAX_ITERATIONS,
|
|
72
68
|
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
|
|
73
69
|
DYNAMO_ENDPOINT: process.env.DYNAMO_ENDPOINT,
|
|
74
70
|
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
|
|
75
71
|
QUERY_THREAD_TIMEOUT: parseIntSafe(process.env.QUERY_THREAD_TIMEOUT),
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
BUDIBASE_DIR: process.env.BUDIBASE_DIR,
|
|
79
|
-
DEPLOYMENT_DB_URL: process.env.DEPLOYMENT_DB_URL,
|
|
80
|
-
BUDIBASE_API_KEY: process.env.BUDIBASE_API_KEY,
|
|
81
|
-
USERID_API_KEY: process.env.USERID_API_KEY,
|
|
82
|
-
DEPLOYMENT_CREDENTIALS_URL: process.env.DEPLOYMENT_CREDENTIALS_URL,
|
|
72
|
+
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
|
73
|
+
// flags
|
|
83
74
|
ALLOW_DEV_AUTOMATIONS: process.env.ALLOW_DEV_AUTOMATIONS,
|
|
84
75
|
DISABLE_THREADING: process.env.DISABLE_THREADING,
|
|
85
|
-
|
|
76
|
+
DISABLE_DEVELOPER_LICENSE: process.env.DISABLE_DEVELOPER_LICENSE,
|
|
77
|
+
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
|
78
|
+
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
|
79
|
+
SELF_HOSTED: process.env.SELF_HOSTED,
|
|
80
|
+
// old
|
|
81
|
+
CLIENT_ID: process.env.CLIENT_ID,
|
|
86
82
|
_set(key, value) {
|
|
87
83
|
process.env[key] = value
|
|
88
84
|
module.exports[key] = value
|
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
setDebounce,
|
|
7
7
|
} = require("../utilities/redis")
|
|
8
8
|
const { doWithDB } = require("@budibase/backend-core/db")
|
|
9
|
-
const { DocumentTypes } = require("../db/utils")
|
|
9
|
+
const { DocumentTypes, getGlobalIDFromUserMetadataID } = require("../db/utils")
|
|
10
10
|
const { PermissionTypes } = require("@budibase/backend-core/permissions")
|
|
11
11
|
const { app: appCache } = require("@budibase/backend-core/cache")
|
|
12
12
|
|
|
@@ -51,6 +51,9 @@ async function updateAppUpdatedAt(ctx) {
|
|
|
51
51
|
await doWithDB(appId, async db => {
|
|
52
52
|
const metadata = await db.get(DocumentTypes.APP_METADATA)
|
|
53
53
|
metadata.updatedAt = new Date().toISOString()
|
|
54
|
+
|
|
55
|
+
metadata.updatedBy = getGlobalIDFromUserMetadataID(ctx.user.userId)
|
|
56
|
+
|
|
54
57
|
const response = await db.put(metadata)
|
|
55
58
|
metadata._rev = response.rev
|
|
56
59
|
await appCache.invalidateAppMetadata(appId, metadata)
|
|
@@ -67,7 +70,15 @@ module.exports = async (ctx, permType) => {
|
|
|
67
70
|
}
|
|
68
71
|
const isBuilderApi = permType === PermissionTypes.BUILDER
|
|
69
72
|
const referer = ctx.headers["referer"]
|
|
70
|
-
|
|
73
|
+
|
|
74
|
+
const overviewPath = "/builder/portal/overview/"
|
|
75
|
+
const overviewContext = !referer ? false : referer.includes(overviewPath)
|
|
76
|
+
if (overviewContext) {
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const hasAppId = !referer ? false : referer.includes(appId)
|
|
81
|
+
const editingApp = referer ? hasAppId : false
|
|
71
82
|
// check this is a builder call and editing
|
|
72
83
|
if (!isBuilderApi || !editingApp) {
|
|
73
84
|
return
|
package/src/threads/index.ts
CHANGED
|
@@ -28,6 +28,8 @@ export class Thread {
|
|
|
28
28
|
workers: any
|
|
29
29
|
timeoutMs: any
|
|
30
30
|
|
|
31
|
+
static workerRefs: any[] = []
|
|
32
|
+
|
|
31
33
|
constructor(type: any, opts: any = { timeoutMs: null, count: 1 }) {
|
|
32
34
|
this.type = type
|
|
33
35
|
this.count = opts.count ? opts.count : 1
|
|
@@ -46,6 +48,7 @@ export class Thread {
|
|
|
46
48
|
workerOpts.maxCallTime = opts.timeoutMs
|
|
47
49
|
}
|
|
48
50
|
this.workers = workerFarm(workerOpts, typeToFile(type))
|
|
51
|
+
Thread.workerRefs.push(this.workers)
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -73,4 +76,23 @@ export class Thread {
|
|
|
73
76
|
})
|
|
74
77
|
})
|
|
75
78
|
}
|
|
79
|
+
|
|
80
|
+
static shutdown() {
|
|
81
|
+
return new Promise<void>(resolve => {
|
|
82
|
+
if (Thread.workerRefs.length === 0) {
|
|
83
|
+
resolve()
|
|
84
|
+
}
|
|
85
|
+
let count = 0
|
|
86
|
+
function complete() {
|
|
87
|
+
count++
|
|
88
|
+
if (count >= Thread.workerRefs.length) {
|
|
89
|
+
resolve()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
for (let worker of Thread.workerRefs) {
|
|
93
|
+
workerFarm.end(worker, complete)
|
|
94
|
+
}
|
|
95
|
+
Thread.workerRefs = []
|
|
96
|
+
})
|
|
97
|
+
}
|
|
76
98
|
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
const { join } = require("./centralPath")
|
|
2
|
-
const { homedir } = require("os")
|
|
3
|
-
const env = require("../environment")
|
|
4
1
|
const { budibaseTempDir } = require("@budibase/backend-core/objectStore")
|
|
5
2
|
|
|
6
|
-
module.exports.budibaseAppsDir = function () {
|
|
7
|
-
return env.BUDIBASE_DIR || join(homedir(), ".budibase")
|
|
8
|
-
}
|
|
9
|
-
|
|
10
3
|
module.exports.budibaseTempDir = budibaseTempDir
|
|
@@ -75,6 +75,13 @@ class InMemoryQueue {
|
|
|
75
75
|
this._emitter.emit("message")
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* replicating the close function from bull, which waits for jobs to finish.
|
|
80
|
+
*/
|
|
81
|
+
async close() {
|
|
82
|
+
return []
|
|
83
|
+
}
|
|
84
|
+
|
|
78
85
|
/**
|
|
79
86
|
* This removes a cron which has been implemented, this is part of Bull API.
|
|
80
87
|
* @param {string} cronJobId The cron which is to be removed.
|
package/src/utilities/redis.js
CHANGED