@budibase/server 1.0.46-alpha.4 → 1.0.46-alpha.5
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.c21ee1fb.js → index.298ba3d3.js} +183 -183
- package/builder/assets/{vendor.10e2ad1b.js → vendor.3bd2f661.js} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +1590 -1615
- package/coverage/coverage-final.json +136 -138
- package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +190 -127
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +12 -12
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
- package/coverage/lcov-report/api/controllers/index.html +19 -34
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.js.html +19 -19
- package/coverage/lcov-report/api/controllers/query/validation.js.html +9 -9
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.html +13 -13
- package/coverage/lcov-report/api/controllers/row/internal.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -8
- package/coverage/lcov-report/api/controllers/row/utils.js.html +13 -13
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/table/internal.js.html +10 -10
- package/coverage/lcov-report/api/controllers/table/utils.js.html +26 -26
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +20 -20
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +15 -15
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +26 -26
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +9 -9
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +14 -14
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +13 -13
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +7 -22
- package/coverage/lcov-report/api/routes/index.js.html +31 -37
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/permission.js.html +12 -12
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +12 -12
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +10 -10
- package/coverage/lcov-report/api/routes/screen.js.html +11 -11
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +12 -12
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +11 -11
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +7 -7
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/automations/utils.js.html +32 -32
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +22 -22
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +7 -7
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +18 -18
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +13 -13
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +73 -73
- 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 +6 -6
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +45 -45
- 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 +5 -5
- package/coverage/lcov-report/middleware/authorized.js.html +17 -17
- package/coverage/lcov-report/middleware/builder.js.html +16 -16
- package/coverage/lcov-report/middleware/currentapp.js.html +46 -73
- package/coverage/lcov-report/middleware/index.html +10 -10
- package/coverage/lcov-report/middleware/joi-validator.js.html +6 -6
- package/coverage/lcov-report/middleware/resourceId.js.html +22 -22
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +17 -17
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/migrations/usageQuotas/index.html +1 -1
- package/coverage/lcov-report/migrations/usageQuotas/index.js.html +6 -6
- package/coverage/lcov-report/migrations/usageQuotas/syncApps.js.html +6 -6
- package/coverage/lcov-report/migrations/usageQuotas/syncRows.js.html +7 -7
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +15 -15
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +23 -8
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +26 -26
- package/coverage/lcov-report/utilities/index.html +19 -19
- package/coverage/lcov-report/utilities/index.js.html +25 -25
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +17 -17
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +4 -4
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- 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/index.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +39 -108
- package/coverage/lcov.info +1937 -1974
- package/dist/api/controllers/application.js +45 -24
- package/dist/api/controllers/static/index.js +9 -10
- package/dist/api/routes/index.js +0 -2
- package/dist/integrations/rest.js +5 -5
- package/dist/integrations/s3.js +1 -1
- package/dist/integrations/utils.js +6 -3
- package/dist/middleware/currentapp.js +0 -9
- package/dist/package.json +5 -5
- package/dist/tests/utilities/TestConfiguration.js +3 -1
- package/dist/threads/query.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +0 -20
- package/nodemon.json +1 -1
- package/package.json +6 -6
- package/src/api/controllers/application.js +48 -27
- package/src/api/controllers/static/index.js +13 -10
- package/src/api/routes/index.js +0 -2
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/integrations/rest.ts +9 -28
- package/src/integrations/s3.ts +1 -1
- package/src/integrations/utils.ts +18 -5
- package/src/middleware/currentapp.js +0 -9
- package/src/migrations/tests/usageQuotas/syncRows.spec.js +1 -1
- package/src/tests/utilities/TestConfiguration.js +3 -1
- package/src/threads/query.js +5 -0
- package/src/utilities/workerRequests.js +0 -23
- package/coverage/lcov-report/api/controllers/hosting.js.html +0 -146
- package/coverage/lcov-report/api/routes/hosting.js.html +0 -119
- package/dist/api/controllers/hosting.js +0 -30
- package/dist/api/routes/hosting.js +0 -11
- package/src/api/controllers/hosting.js +0 -22
- package/src/api/routes/hosting.js +0 -13
- package/src/api/routes/tests/hosting.spec.js +0 -36
|
@@ -61,26 +61,6 @@ exports.sendSmtpEmail = (to, from, subject, contents, automation) => __awaiter(v
|
|
|
61
61
|
}
|
|
62
62
|
return response.json();
|
|
63
63
|
});
|
|
64
|
-
exports.getDeployedApps = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
try {
|
|
66
|
-
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/apps`), request(null, {
|
|
67
|
-
method: "GET",
|
|
68
|
-
}));
|
|
69
|
-
const json = yield response.json();
|
|
70
|
-
const apps = {};
|
|
71
|
-
for (let [key, value] of Object.entries(json)) {
|
|
72
|
-
if (value.url) {
|
|
73
|
-
value.url = value.url.toLowerCase();
|
|
74
|
-
apps[key.toLowerCase()] = value;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return apps;
|
|
78
|
-
}
|
|
79
|
-
catch (err) {
|
|
80
|
-
// error, cannot determine deployed apps, don't stop app creation - sort this later
|
|
81
|
-
return {};
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
64
|
exports.getGlobalSelf = (ctx, appId = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
65
|
const endpoint = `/api/global/users/self`;
|
|
86
66
|
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + endpoint),
|
package/nodemon.json
CHANGED
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.46-alpha.
|
|
4
|
+
"version": "1.0.46-alpha.5",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"license": "GPL-3.0",
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
-
"@budibase/backend-core": "^1.0.46-alpha.
|
|
74
|
-
"@budibase/client": "^1.0.46-alpha.
|
|
75
|
-
"@budibase/string-templates": "^1.0.46-alpha.
|
|
73
|
+
"@budibase/backend-core": "^1.0.46-alpha.5",
|
|
74
|
+
"@budibase/client": "^1.0.46-alpha.5",
|
|
75
|
+
"@budibase/string-templates": "^1.0.46-alpha.5",
|
|
76
76
|
"@bull-board/api": "^3.7.0",
|
|
77
77
|
"@bull-board/koa": "^3.7.0",
|
|
78
78
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"mongodb": "3.6.3",
|
|
111
111
|
"mssql": "6.2.3",
|
|
112
112
|
"mysql2": "^2.3.1",
|
|
113
|
-
"node-fetch": "2.6.
|
|
113
|
+
"node-fetch": "2.6.7",
|
|
114
114
|
"open": "^8.4.0",
|
|
115
115
|
"pg": "8.5.1",
|
|
116
116
|
"pino-pretty": "4.0.0",
|
|
@@ -165,5 +165,5 @@
|
|
|
165
165
|
"optionalDependencies": {
|
|
166
166
|
"oracledb": "^5.3.0"
|
|
167
167
|
},
|
|
168
|
-
"gitHead": "
|
|
168
|
+
"gitHead": "cbfb0f8a13790f223580d3fee84e334eeda5b56e"
|
|
169
169
|
}
|
|
@@ -33,10 +33,7 @@ const {
|
|
|
33
33
|
Replication,
|
|
34
34
|
} = require("@budibase/backend-core/db")
|
|
35
35
|
const { USERS_TABLE_SCHEMA } = require("../../constants")
|
|
36
|
-
const {
|
|
37
|
-
getDeployedApps,
|
|
38
|
-
removeAppFromUserRoles,
|
|
39
|
-
} = require("../../utilities/workerRequests")
|
|
36
|
+
const { removeAppFromUserRoles } = require("../../utilities/workerRequests")
|
|
40
37
|
const { clientLibraryPath, stringToReadStream } = require("../../utilities")
|
|
41
38
|
const { getAllLocks } = require("../../utilities/redis")
|
|
42
39
|
const {
|
|
@@ -78,29 +75,41 @@ function getUserRoleId(ctx) {
|
|
|
78
75
|
: ctx.user.role._id
|
|
79
76
|
}
|
|
80
77
|
|
|
81
|
-
async function
|
|
78
|
+
async function getAppUrl(ctx) {
|
|
79
|
+
// construct the url
|
|
82
80
|
let url
|
|
83
81
|
if (ctx.request.body.url) {
|
|
82
|
+
// if the url is provided, use that
|
|
84
83
|
url = encodeURI(ctx.request.body.url)
|
|
85
|
-
} else
|
|
84
|
+
} else {
|
|
85
|
+
// otherwise use the name
|
|
86
86
|
url = encodeURI(`${ctx.request.body.name}`)
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
url = `/${url.replace(URL_REGEX_SLASH, "")}`.toLowerCase()
|
|
89
|
+
|
|
90
|
+
return url
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const checkAppUrl = (ctx, apps, url, currentAppId) => {
|
|
94
|
+
if (currentAppId) {
|
|
95
|
+
apps = apps.filter(app => app.appId !== currentAppId)
|
|
96
|
+
}
|
|
97
|
+
if (apps.some(app => app.url === url)) {
|
|
98
|
+
ctx.throw(400, "App URL is already in use.")
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const checkAppName = (ctx, apps, name, currentAppId) => {
|
|
103
|
+
// TODO: Replace with Joi
|
|
104
|
+
if (!name) {
|
|
105
|
+
ctx.throw(400, "Name is required")
|
|
90
106
|
}
|
|
91
|
-
if (
|
|
92
|
-
|
|
107
|
+
if (currentAppId) {
|
|
108
|
+
apps = apps.filter(app => app.appId !== currentAppId)
|
|
93
109
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
url &&
|
|
97
|
-
deployedApps[url] != null &&
|
|
98
|
-
ctx.params != null &&
|
|
99
|
-
deployedApps[url].appId !== ctx.params.appId
|
|
100
|
-
) {
|
|
101
|
-
ctx.throw(400, "App name/URL is already in use.")
|
|
110
|
+
if (apps.some(app => app.name === name)) {
|
|
111
|
+
ctx.throw(400, "App name is already in use.")
|
|
102
112
|
}
|
|
103
|
-
return url
|
|
104
113
|
}
|
|
105
114
|
|
|
106
115
|
async function createInstance(template) {
|
|
@@ -206,6 +215,12 @@ exports.fetchAppPackage = async ctx => {
|
|
|
206
215
|
}
|
|
207
216
|
|
|
208
217
|
exports.create = async ctx => {
|
|
218
|
+
const apps = await getAllApps(CouchDB, { dev: true })
|
|
219
|
+
const name = ctx.request.body.name
|
|
220
|
+
checkAppName(ctx, apps, name)
|
|
221
|
+
const url = await getAppUrl(ctx)
|
|
222
|
+
checkAppUrl(ctx, apps, url)
|
|
223
|
+
|
|
209
224
|
const { useTemplate, templateKey, templateString } = ctx.request.body
|
|
210
225
|
const instanceConfig = {
|
|
211
226
|
useTemplate,
|
|
@@ -218,7 +233,6 @@ exports.create = async ctx => {
|
|
|
218
233
|
const instance = await createInstance(instanceConfig)
|
|
219
234
|
const appId = instance._id
|
|
220
235
|
|
|
221
|
-
const url = await getAppUrlIfNotInUse(ctx)
|
|
222
236
|
const db = new CouchDB(appId)
|
|
223
237
|
let _rev
|
|
224
238
|
try {
|
|
@@ -235,7 +249,7 @@ exports.create = async ctx => {
|
|
|
235
249
|
type: "app",
|
|
236
250
|
version: packageJson.version,
|
|
237
251
|
componentLibraries: ["@budibase/standard-components"],
|
|
238
|
-
name:
|
|
252
|
+
name: name,
|
|
239
253
|
url: url,
|
|
240
254
|
template: ctx.request.body.template,
|
|
241
255
|
instance: instance,
|
|
@@ -263,7 +277,15 @@ exports.create = async ctx => {
|
|
|
263
277
|
}
|
|
264
278
|
|
|
265
279
|
exports.update = async ctx => {
|
|
266
|
-
const
|
|
280
|
+
const apps = await getAllApps(CouchDB, { dev: true })
|
|
281
|
+
// validation
|
|
282
|
+
const name = ctx.request.body.name
|
|
283
|
+
checkAppName(ctx, apps, name, ctx.params.appId)
|
|
284
|
+
const url = await getAppUrl(ctx)
|
|
285
|
+
checkAppUrl(ctx, apps, url, ctx.params.appId)
|
|
286
|
+
|
|
287
|
+
const appPackageUpdates = { name, url }
|
|
288
|
+
const data = await updateAppPackage(appPackageUpdates, ctx.params.appId)
|
|
267
289
|
ctx.status = 200
|
|
268
290
|
ctx.body = data
|
|
269
291
|
}
|
|
@@ -285,7 +307,7 @@ exports.updateClient = async ctx => {
|
|
|
285
307
|
version: packageJson.version,
|
|
286
308
|
revertableVersion: currentVersion,
|
|
287
309
|
}
|
|
288
|
-
const data = await updateAppPackage(
|
|
310
|
+
const data = await updateAppPackage(appPackageUpdates, ctx.params.appId)
|
|
289
311
|
ctx.status = 200
|
|
290
312
|
ctx.body = data
|
|
291
313
|
}
|
|
@@ -308,7 +330,7 @@ exports.revertClient = async ctx => {
|
|
|
308
330
|
version: application.revertableVersion,
|
|
309
331
|
revertableVersion: null,
|
|
310
332
|
}
|
|
311
|
-
const data = await updateAppPackage(
|
|
333
|
+
const data = await updateAppPackage(appPackageUpdates, ctx.params.appId)
|
|
312
334
|
ctx.status = 200
|
|
313
335
|
ctx.body = data
|
|
314
336
|
}
|
|
@@ -381,12 +403,11 @@ exports.sync = async (ctx, next) => {
|
|
|
381
403
|
}
|
|
382
404
|
}
|
|
383
405
|
|
|
384
|
-
const updateAppPackage = async (
|
|
385
|
-
const url = await getAppUrlIfNotInUse(ctx)
|
|
406
|
+
const updateAppPackage = async (appPackage, appId) => {
|
|
386
407
|
const db = new CouchDB(appId)
|
|
387
408
|
const application = await db.get(DocumentTypes.APP_METADATA)
|
|
388
409
|
|
|
389
|
-
const newAppPackage = { ...application, ...appPackage
|
|
410
|
+
const newAppPackage = { ...application, ...appPackage }
|
|
390
411
|
if (appPackage._rev !== application._rev) {
|
|
391
412
|
newAppPackage._rev = application._rev
|
|
392
413
|
}
|
|
@@ -5,7 +5,7 @@ const { resolve, join } = require("../../../utilities/centralPath")
|
|
|
5
5
|
const uuid = require("uuid")
|
|
6
6
|
const { ObjectStoreBuckets } = require("../../../constants")
|
|
7
7
|
const { processString } = require("@budibase/string-templates")
|
|
8
|
-
const {
|
|
8
|
+
const { getAllApps } = require("@budibase/backend-core/db")
|
|
9
9
|
const CouchDB = require("../../../db")
|
|
10
10
|
const {
|
|
11
11
|
loadHandlebarsFile,
|
|
@@ -39,12 +39,18 @@ async function prepareUpload({ s3Key, bucket, metadata, file }) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
async function
|
|
43
|
-
// the "appId" component of the URL
|
|
42
|
+
async function getAppIdFromUrl(ctx) {
|
|
43
|
+
// the "appId" component of the URL can be the id or the custom url
|
|
44
44
|
let possibleAppUrl = `/${encodeURI(ctx.params.appId).toLowerCase()}`
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
// search prod apps for a url that matches, exclude dev where id is always used
|
|
47
|
+
const apps = await getAllApps(CouchDB, { dev: false })
|
|
48
|
+
const app = apps.filter(
|
|
49
|
+
a => a.url && a.url.toLowerCase() === possibleAppUrl
|
|
50
|
+
)[0]
|
|
51
|
+
|
|
52
|
+
if (app && app.appId) {
|
|
53
|
+
return app.appId
|
|
48
54
|
} else {
|
|
49
55
|
return ctx.params.appId
|
|
50
56
|
}
|
|
@@ -77,10 +83,7 @@ exports.uploadFile = async function (ctx) {
|
|
|
77
83
|
}
|
|
78
84
|
|
|
79
85
|
exports.serveApp = async function (ctx) {
|
|
80
|
-
let appId = ctx
|
|
81
|
-
if (env.SELF_HOSTED) {
|
|
82
|
-
appId = await checkForSelfHostedURL(ctx)
|
|
83
|
-
}
|
|
86
|
+
let appId = await getAppIdFromUrl(ctx)
|
|
84
87
|
const App = require("./templates/BudibaseApp.svelte").default
|
|
85
88
|
const db = new CouchDB(appId, { skip_setup: true })
|
|
86
89
|
const appInfo = await db.get(DocumentTypes.APP_METADATA)
|
package/src/api/routes/index.js
CHANGED
|
@@ -20,7 +20,6 @@ const integrationRoutes = require("./integration")
|
|
|
20
20
|
const permissionRoutes = require("./permission")
|
|
21
21
|
const datasourceRoutes = require("./datasource")
|
|
22
22
|
const queryRoutes = require("./query")
|
|
23
|
-
const hostingRoutes = require("./hosting")
|
|
24
23
|
const backupRoutes = require("./backup")
|
|
25
24
|
const metadataRoutes = require("./metadata")
|
|
26
25
|
const devRoutes = require("./dev")
|
|
@@ -46,7 +45,6 @@ exports.mainRoutes = [
|
|
|
46
45
|
permissionRoutes,
|
|
47
46
|
datasourceRoutes,
|
|
48
47
|
queryRoutes,
|
|
49
|
-
hostingRoutes,
|
|
50
48
|
backupRoutes,
|
|
51
49
|
metadataRoutes,
|
|
52
50
|
devRoutes,
|
|
@@ -53,8 +53,8 @@ describe("/applications", () => {
|
|
|
53
53
|
|
|
54
54
|
describe("fetch", () => {
|
|
55
55
|
it("lists all applications", async () => {
|
|
56
|
-
await config.createApp(
|
|
57
|
-
await config.createApp(
|
|
56
|
+
await config.createApp("app1")
|
|
57
|
+
await config.createApp("app2")
|
|
58
58
|
|
|
59
59
|
const res = await request
|
|
60
60
|
.get(`/api/applications?status=${AppStatus.DEV}`)
|
package/src/integrations/rest.ts
CHANGED
|
@@ -43,8 +43,8 @@ const coreFields = {
|
|
|
43
43
|
enum: Object.values(BodyTypes),
|
|
44
44
|
},
|
|
45
45
|
pagination: {
|
|
46
|
-
type: DatasourceFieldTypes.OBJECT
|
|
47
|
-
}
|
|
46
|
+
type: DatasourceFieldTypes.OBJECT
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
module RestModule {
|
|
@@ -178,17 +178,12 @@ module RestModule {
|
|
|
178
178
|
headers,
|
|
179
179
|
},
|
|
180
180
|
pagination: {
|
|
181
|
-
cursor: nextCursor
|
|
182
|
-
}
|
|
181
|
+
cursor: nextCursor
|
|
182
|
+
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
getUrl(
|
|
187
|
-
path: string,
|
|
188
|
-
queryString: string,
|
|
189
|
-
pagination: PaginationConfig | null,
|
|
190
|
-
paginationValues: PaginationValues | null
|
|
191
|
-
): string {
|
|
186
|
+
getUrl(path: string, queryString: string, pagination: PaginationConfig | null, paginationValues: PaginationValues | null): string {
|
|
192
187
|
// Add pagination params to query string if required
|
|
193
188
|
if (pagination?.location === "query" && paginationValues) {
|
|
194
189
|
const { pageParam, sizeParam } = pagination
|
|
@@ -222,22 +217,14 @@ module RestModule {
|
|
|
222
217
|
return complete
|
|
223
218
|
}
|
|
224
219
|
|
|
225
|
-
addBody(
|
|
226
|
-
bodyType: string,
|
|
227
|
-
body: string | any,
|
|
228
|
-
input: any,
|
|
229
|
-
pagination: PaginationConfig | null,
|
|
230
|
-
paginationValues: PaginationValues | null
|
|
231
|
-
) {
|
|
220
|
+
addBody(bodyType: string, body: string | any, input: any, pagination: PaginationConfig | null, paginationValues: PaginationValues | null) {
|
|
232
221
|
if (!input.headers) {
|
|
233
222
|
input.headers = {}
|
|
234
223
|
}
|
|
235
224
|
if (bodyType === BodyTypes.NONE) {
|
|
236
225
|
return input
|
|
237
226
|
}
|
|
238
|
-
let error,
|
|
239
|
-
object: any = {},
|
|
240
|
-
string = ""
|
|
227
|
+
let error, object: any = {}, string = ""
|
|
241
228
|
try {
|
|
242
229
|
if (body) {
|
|
243
230
|
string = typeof body !== "string" ? JSON.stringify(body) : body
|
|
@@ -346,7 +333,7 @@ module RestModule {
|
|
|
346
333
|
requestBody,
|
|
347
334
|
authConfigId,
|
|
348
335
|
pagination,
|
|
349
|
-
paginationValues
|
|
336
|
+
paginationValues
|
|
350
337
|
} = query
|
|
351
338
|
const authHeaders = this.getAuthHeaders(authConfigId)
|
|
352
339
|
|
|
@@ -365,13 +352,7 @@ module RestModule {
|
|
|
365
352
|
}
|
|
366
353
|
|
|
367
354
|
let input: any = { method, headers: this.headers }
|
|
368
|
-
input = this.addBody(
|
|
369
|
-
bodyType,
|
|
370
|
-
requestBody,
|
|
371
|
-
input,
|
|
372
|
-
pagination,
|
|
373
|
-
paginationValues
|
|
374
|
-
)
|
|
355
|
+
input = this.addBody(bodyType, requestBody, input, pagination, paginationValues)
|
|
375
356
|
|
|
376
357
|
this.startTimeMs = performance.now()
|
|
377
358
|
const url = this.getUrl(path, queryString, pagination, paginationValues)
|
package/src/integrations/s3.ts
CHANGED
|
@@ -153,8 +153,15 @@ export function isIsoDateString(str: string) {
|
|
|
153
153
|
* @param column The column to check, to see if it is a valid relationship.
|
|
154
154
|
* @param tableIds The IDs of the tables which currently exist.
|
|
155
155
|
*/
|
|
156
|
-
function shouldCopyRelationship(
|
|
157
|
-
|
|
156
|
+
function shouldCopyRelationship(
|
|
157
|
+
column: { type: string; tableId?: string },
|
|
158
|
+
tableIds: [string]
|
|
159
|
+
) {
|
|
160
|
+
return (
|
|
161
|
+
column.type === FieldTypes.LINK &&
|
|
162
|
+
column.tableId &&
|
|
163
|
+
tableIds.includes(column.tableId)
|
|
164
|
+
)
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
/**
|
|
@@ -165,9 +172,15 @@ function shouldCopyRelationship(column: { type: string, tableId?: string }, tabl
|
|
|
165
172
|
* @param column The column to check for options or boolean type.
|
|
166
173
|
* @param fetchedColumn The fetched column to check for the type in the external database.
|
|
167
174
|
*/
|
|
168
|
-
function shouldCopySpecialColumn(
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
function shouldCopySpecialColumn(
|
|
176
|
+
column: { type: string },
|
|
177
|
+
fetchedColumn: { type: string } | undefined
|
|
178
|
+
) {
|
|
179
|
+
return (
|
|
180
|
+
column.type === FieldTypes.OPTIONS ||
|
|
181
|
+
((!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER) &&
|
|
182
|
+
column.type === FieldTypes.BOOLEAN)
|
|
183
|
+
)
|
|
171
184
|
}
|
|
172
185
|
|
|
173
186
|
/**
|
|
@@ -47,15 +47,6 @@ module.exports = async (ctx, next) => {
|
|
|
47
47
|
(!ctx.user || !ctx.user.builder || !ctx.user.builder.global)
|
|
48
48
|
) {
|
|
49
49
|
clearCookie(ctx, Cookies.CurrentApp)
|
|
50
|
-
// have to set the return url on the server side as client side is not available
|
|
51
|
-
setCookie(ctx, ctx.url, Cookies.RETURN_URL, {
|
|
52
|
-
// don't sign so the browser can easily read
|
|
53
|
-
sign: false,
|
|
54
|
-
// use the request domain to match how ui handles the return url cookie.
|
|
55
|
-
// it's important we don't use the shared domain here as the builder
|
|
56
|
-
// can't delete from it without awareness of the domain.
|
|
57
|
-
requestDomain: true,
|
|
58
|
-
})
|
|
59
50
|
return ctx.redirect("/")
|
|
60
51
|
}
|
|
61
52
|
|
|
@@ -22,6 +22,7 @@ const { getGlobalDB } = require("@budibase/backend-core/tenancy")
|
|
|
22
22
|
const { createASession } = require("@budibase/backend-core/sessions")
|
|
23
23
|
const { user: userCache } = require("@budibase/backend-core/cache")
|
|
24
24
|
const CouchDB = require("../../db")
|
|
25
|
+
const newid = require("../../db/newid")
|
|
25
26
|
core.init(CouchDB)
|
|
26
27
|
|
|
27
28
|
const GLOBAL_USER_ID = "us_uuid1"
|
|
@@ -98,7 +99,8 @@ class TestConfiguration {
|
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
|
|
102
|
+
// use a new id as the name to avoid name collisions
|
|
103
|
+
async init(appName = newid()) {
|
|
102
104
|
await this.globalUser()
|
|
103
105
|
return this.createApp(appName)
|
|
104
106
|
}
|
package/src/threads/query.js
CHANGED
|
@@ -58,29 +58,6 @@ exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
|
|
|
58
58
|
return response.json()
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
exports.getDeployedApps = async () => {
|
|
62
|
-
try {
|
|
63
|
-
const response = await fetch(
|
|
64
|
-
checkSlashesInUrl(env.WORKER_URL + `/api/apps`),
|
|
65
|
-
request(null, {
|
|
66
|
-
method: "GET",
|
|
67
|
-
})
|
|
68
|
-
)
|
|
69
|
-
const json = await response.json()
|
|
70
|
-
const apps = {}
|
|
71
|
-
for (let [key, value] of Object.entries(json)) {
|
|
72
|
-
if (value.url) {
|
|
73
|
-
value.url = value.url.toLowerCase()
|
|
74
|
-
apps[key.toLowerCase()] = value
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return apps
|
|
78
|
-
} catch (err) {
|
|
79
|
-
// error, cannot determine deployed apps, don't stop app creation - sort this later
|
|
80
|
-
return {}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
61
|
exports.getGlobalSelf = async (ctx, appId = null) => {
|
|
85
62
|
const endpoint = `/api/global/users/self`
|
|
86
63
|
const response = await fetch(
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for api/controllers/hosting.js</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">api/controllers</a> hosting.js</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">93.33% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>14/15</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">75% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>3/4</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">50% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>1/2</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">93.33% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>14/15</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
</div>
|
|
58
|
-
<div class='status-line high'></div>
|
|
59
|
-
<pre><table class="coverage">
|
|
60
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
61
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
62
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
63
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
64
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
65
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
66
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
67
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
68
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
69
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
70
|
-
<a name='L11'></a><a href='#L11'>11</a>
|
|
71
|
-
<a name='L12'></a><a href='#L12'>12</a>
|
|
72
|
-
<a name='L13'></a><a href='#L13'>13</a>
|
|
73
|
-
<a name='L14'></a><a href='#L14'>14</a>
|
|
74
|
-
<a name='L15'></a><a href='#L15'>15</a>
|
|
75
|
-
<a name='L16'></a><a href='#L16'>16</a>
|
|
76
|
-
<a name='L17'></a><a href='#L17'>17</a>
|
|
77
|
-
<a name='L18'></a><a href='#L18'>18</a>
|
|
78
|
-
<a name='L19'></a><a href='#L19'>19</a>
|
|
79
|
-
<a name='L20'></a><a href='#L20'>20</a>
|
|
80
|
-
<a name='L21'></a><a href='#L21'>21</a>
|
|
81
|
-
<a name='L22'></a><a href='#L22'>22</a>
|
|
82
|
-
<a name='L23'></a><a href='#L23'>23</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">24x</span>
|
|
83
|
-
<span class="cline-any cline-yes">24x</span>
|
|
84
|
-
<span class="cline-any cline-yes">24x</span>
|
|
85
|
-
<span class="cline-any cline-yes">24x</span>
|
|
86
|
-
<span class="cline-any cline-yes">24x</span>
|
|
87
|
-
<span class="cline-any cline-neutral"> </span>
|
|
88
|
-
<span class="cline-any cline-yes">24x</span>
|
|
89
|
-
<span class="cline-any cline-yes">1x</span>
|
|
90
|
-
<span class="cline-any cline-yes">1x</span>
|
|
91
|
-
<span class="cline-any cline-yes">1x</span>
|
|
92
|
-
<span class="cline-any cline-yes">1x</span>
|
|
93
|
-
<span class="cline-any cline-yes">1x</span>
|
|
94
|
-
<span class="cline-any cline-yes">1x</span>
|
|
95
|
-
<span class="cline-any cline-neutral"> </span>
|
|
96
|
-
<span class="cline-any cline-yes">1x</span>
|
|
97
|
-
<span class="cline-any cline-neutral"> </span>
|
|
98
|
-
<span class="cline-any cline-neutral"> </span>
|
|
99
|
-
<span class="cline-any cline-neutral"> </span>
|
|
100
|
-
<span class="cline-any cline-neutral"> </span>
|
|
101
|
-
<span class="cline-any cline-yes">24x</span>
|
|
102
|
-
<span class="cline-any cline-no"> </span>
|
|
103
|
-
<span class="cline-any cline-neutral"> </span>
|
|
104
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">const CouchDB = require("../../db")
|
|
105
|
-
const { getDeployedApps } = require("../../utilities/workerRequests")
|
|
106
|
-
const { getScopedConfig } = require("@budibase/backend-core/db")
|
|
107
|
-
const { Configs } = require("@budibase/backend-core/constants")
|
|
108
|
-
const { checkSlashesInUrl } = require("../../utilities")
|
|
109
|
-
|
|
110
|
-
exports.fetchUrls = async ctx => {
|
|
111
|
-
const appId = ctx.appId
|
|
112
|
-
const db = new CouchDB(appId)
|
|
113
|
-
const settings = await getScopedConfig(db, { type: Configs.SETTINGS })
|
|
114
|
-
let appUrl = "http://localhost:10000/app"
|
|
115
|
-
if (settings && settings["platformUrl"]) {
|
|
116
|
-
appUrl = checkSlashesInUrl(`${settings["platformUrl"]}/app`)
|
|
117
|
-
}
|
|
118
|
-
ctx.body = {
|
|
119
|
-
app: appUrl,
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
exports.getDeployedApps = <span class="fstat-no" title="function not covered" >as</span>ync ctx => {
|
|
124
|
-
<span class="cstat-no" title="statement not covered" > ctx.body = await getDeployedApps()</span>
|
|
125
|
-
}
|
|
126
|
-
</pre></td></tr></table></pre>
|
|
127
|
-
|
|
128
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
129
|
-
</div><!-- /wrapper -->
|
|
130
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
131
|
-
Code coverage generated by
|
|
132
|
-
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
133
|
-
at Mon Jan 24 2022 15:47:33 GMT+0000 (Coordinated Universal Time)
|
|
134
|
-
</div>
|
|
135
|
-
</div>
|
|
136
|
-
<script src="../../prettify.js"></script>
|
|
137
|
-
<script>
|
|
138
|
-
window.onload = function () {
|
|
139
|
-
prettyPrint();
|
|
140
|
-
};
|
|
141
|
-
</script>
|
|
142
|
-
<script src="../../sorter.js"></script>
|
|
143
|
-
<script src="../../block-navigation.js"></script>
|
|
144
|
-
</body>
|
|
145
|
-
</html>
|
|
146
|
-
|