@budibase/server 1.2.58-alpha.6 → 1.2.58
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/__mocks__/mongodb.ts +0 -4
- package/__mocks__/node-fetch.ts +1 -8
- package/builder/assets/index.08dd0c5e.css +6 -0
- package/builder/assets/index.5cf58e77.js +975 -0
- package/builder/assets/{vendor.67dbd8fa.js → vendor.6bcafa60.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +524 -549
- package/coverage/coverage-final.json +20 -20
- 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 +1 -1
- 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 +25 -25
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +191 -317
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +18 -27
- 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 +2 -2
- 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 +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/api/index.js.html +5 -5
- 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 +6 -9
- package/coverage/lcov-report/automations/index.html +11 -11
- package/coverage/lcov-report/automations/index.js.html +1 -1
- 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 +1 -1
- 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 +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- 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 +30 -30
- 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 +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 +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +33 -33
- 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 +12 -12
- package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
- package/coverage/lcov-report/middleware/index.html +10 -10
- package/coverage/lcov-report/middleware/joi-validator.js.html +9 -18
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +12 -12
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- 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 +31 -31
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- 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 +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 +2 -2
- 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 +20 -20
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +7 -7
- package/coverage/lcov-report/utilities/workerRequests.js.html +13 -13
- package/coverage/lcov.info +844 -888
- package/dist/api/controllers/application.js +14 -80
- package/dist/api/controllers/row/internalSearch.js +4 -39
- package/dist/api/controllers/row/utils.js +1 -3
- package/dist/api/controllers/static/index.js +2 -26
- package/dist/api/controllers/table/external.js +1 -1
- package/dist/api/routes/static.js +0 -3
- package/dist/app.js +3 -4
- package/dist/automations/bullboard.js +0 -1
- package/dist/automations/logging/index.js +0 -3
- package/dist/integrations/base/sql.js +30 -62
- package/dist/integrations/base/utils.js +27 -13
- package/dist/integrations/microsoftSqlServer.js +2 -5
- package/dist/integrations/mongodb.js +8 -35
- package/dist/integrations/mysql.js +2 -2
- package/dist/integrations/postgres.js +2 -5
- package/dist/middleware/joi-validator.js +4 -7
- package/dist/package.json +7 -7
- package/dist/threads/index.js +0 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +1 -2
- package/dist/utilities/redis.js +0 -1
- package/package.json +8 -8
- package/src/api/controllers/application.ts +15 -96
- package/src/api/controllers/row/internalSearch.js +3 -45
- package/src/api/controllers/row/utils.js +1 -4
- package/src/api/controllers/static/index.ts +1 -21
- package/src/api/controllers/table/external.js +1 -1
- package/src/api/routes/static.ts +0 -12
- package/src/api/routes/tests/application.spec.js +0 -26
- package/src/api/routes/tests/static.spec.js +7 -19
- package/src/app.ts +3 -5
- package/src/automations/bullboard.js +0 -1
- package/src/automations/logging/index.ts +0 -3
- package/src/integrations/base/sql.ts +30 -67
- package/src/integrations/base/utils.ts +18 -9
- package/src/integrations/microsoftSqlServer.ts +2 -3
- package/src/integrations/mongodb.ts +8 -35
- package/src/integrations/mysql.ts +1 -1
- package/src/integrations/postgres.ts +1 -2
- package/src/integrations/tests/mongo.spec.js +0 -218
- package/src/integrations/tests/sql.spec.js +11 -101
- package/src/middleware/joi-validator.js +4 -7
- package/src/threads/index.ts +0 -1
- package/src/utilities/fileSystem/index.js +0 -2
- package/src/utilities/redis.js +0 -1
- package/builder/assets/index.7ba6d256.js +0 -875
- package/builder/assets/index.fdb1647e.css +0 -6
- package/dist/api/controllers/static/templates/preview.hbs +0 -103
- package/dist/integrations/base/query.js +0 -27
- package/src/api/controllers/static/templates/preview.hbs +0 -103
- package/src/api/routes/tests/data/old-app.txt +0 -3
- package/src/api/routes/tests/internalSearch.spec.js +0 -176
- package/src/integrations/base/query.ts +0 -16
|
@@ -14,7 +14,7 @@ const { join } = require("path");
|
|
|
14
14
|
const uuid = require("uuid/v4");
|
|
15
15
|
const { doWithDB, dangerousGetDB, closeDB, } = require("@budibase/backend-core/db");
|
|
16
16
|
const { ObjectStoreBuckets } = require("../../constants");
|
|
17
|
-
const { upload, retrieve, retrieveToTmp, streamUpload, deleteFolder, downloadTarball,
|
|
17
|
+
const { upload, retrieve, retrieveToTmp, streamUpload, deleteFolder, downloadTarball, } = require("./utilities");
|
|
18
18
|
const { updateClientLibrary } = require("./clientLibrary");
|
|
19
19
|
const env = require("../../environment");
|
|
20
20
|
const { USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX, TABLE_ROW_PREFIX, } = require("../../db/utils");
|
|
@@ -291,6 +291,5 @@ exports.cleanup = appIds => {
|
|
|
291
291
|
exports.upload = upload;
|
|
292
292
|
exports.retrieve = retrieve;
|
|
293
293
|
exports.retrieveToTmp = retrieveToTmp;
|
|
294
|
-
exports.deleteFiles = deleteFiles;
|
|
295
294
|
exports.TOP_LEVEL_PATH = TOP_LEVEL_PATH;
|
|
296
295
|
exports.NODE_MODULES_PATH = NODE_MODULES_PATH;
|
package/dist/utilities/redis.js
CHANGED
|
@@ -30,7 +30,6 @@ exports.shutdown = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
30
30
|
yield debounceClient.finish();
|
|
31
31
|
if (flagClient)
|
|
32
32
|
yield flagClient.finish();
|
|
33
|
-
console.log("Redis shutdown");
|
|
34
33
|
});
|
|
35
34
|
exports.doesUserHaveLock = (devAppId, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
35
|
const value = yield devAppClient.get(devAppId);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.2.58
|
|
4
|
+
"version": "1.2.58",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
"license": "GPL-3.0",
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "1.2.58
|
|
81
|
-
"@budibase/client": "1.2.58
|
|
82
|
-
"@budibase/pro": "1.2.
|
|
83
|
-
"@budibase/string-templates": "1.2.58
|
|
84
|
-
"@budibase/types": "1.2.58
|
|
80
|
+
"@budibase/backend-core": "^1.2.58",
|
|
81
|
+
"@budibase/client": "^1.2.58",
|
|
82
|
+
"@budibase/pro": "1.2.57",
|
|
83
|
+
"@budibase/string-templates": "^1.2.58",
|
|
84
|
+
"@budibase/types": "^1.2.58",
|
|
85
85
|
"@bull-board/api": "3.7.0",
|
|
86
86
|
"@bull-board/koa": "3.9.4",
|
|
87
87
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
"google-auth-library": "7.12.0",
|
|
108
108
|
"google-spreadsheet": "3.2.0",
|
|
109
109
|
"jimp": "0.16.1",
|
|
110
|
-
"joi": "17.
|
|
110
|
+
"joi": "17.2.1",
|
|
111
111
|
"js-yaml": "4.1.0",
|
|
112
112
|
"jsonschema": "1.4.0",
|
|
113
113
|
"knex": "0.95.15",
|
|
@@ -196,5 +196,5 @@
|
|
|
196
196
|
"optionalDependencies": {
|
|
197
197
|
"oracledb": "5.3.0"
|
|
198
198
|
},
|
|
199
|
-
"gitHead": "
|
|
199
|
+
"gitHead": "2922b47620173f41097d36b9dc5b1c0f8f7b063a"
|
|
200
200
|
}
|
|
@@ -47,14 +47,7 @@ import { checkAppMetadata } from "../../automations/logging"
|
|
|
47
47
|
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
|
48
48
|
import { quotas } from "@budibase/pro"
|
|
49
49
|
import { errors, events, migrations } from "@budibase/backend-core"
|
|
50
|
-
import {
|
|
51
|
-
App,
|
|
52
|
-
Layout,
|
|
53
|
-
Screen,
|
|
54
|
-
MigrationType,
|
|
55
|
-
AppNavigation,
|
|
56
|
-
} from "@budibase/types"
|
|
57
|
-
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
|
50
|
+
import { App, MigrationType } from "@budibase/types"
|
|
58
51
|
|
|
59
52
|
const URL_REGEX_SLASH = /\/|\\/g
|
|
60
53
|
|
|
@@ -250,19 +243,27 @@ const performAppCreate = async (ctx: any) => {
|
|
|
250
243
|
}
|
|
251
244
|
const instance = await createInstance(instanceConfig)
|
|
252
245
|
const appId = instance._id
|
|
253
|
-
const db = context.getAppDB()
|
|
254
246
|
|
|
255
|
-
|
|
247
|
+
const db = context.getAppDB()
|
|
248
|
+
let _rev
|
|
249
|
+
try {
|
|
250
|
+
// if template there will be an existing doc
|
|
251
|
+
const existing = await db.get(DocumentType.APP_METADATA)
|
|
252
|
+
_rev = existing._rev
|
|
253
|
+
} catch (err) {
|
|
254
|
+
// nothing to do
|
|
255
|
+
}
|
|
256
|
+
const newApplication: App = {
|
|
256
257
|
_id: DocumentType.APP_METADATA,
|
|
257
|
-
_rev
|
|
258
|
-
appId,
|
|
258
|
+
_rev,
|
|
259
|
+
appId: instance._id,
|
|
259
260
|
type: "app",
|
|
260
261
|
version: packageJson.version,
|
|
261
262
|
componentLibraries: ["@budibase/standard-components"],
|
|
262
263
|
name: name,
|
|
263
264
|
url: url,
|
|
264
|
-
template:
|
|
265
|
-
instance,
|
|
265
|
+
template: ctx.request.body.template,
|
|
266
|
+
instance: instance,
|
|
266
267
|
tenantId: getTenantId(),
|
|
267
268
|
updatedAt: new Date().toISOString(),
|
|
268
269
|
createdAt: new Date().toISOString(),
|
|
@@ -284,36 +285,6 @@ const performAppCreate = async (ctx: any) => {
|
|
|
284
285
|
buttonBorderRadius: "16px",
|
|
285
286
|
},
|
|
286
287
|
}
|
|
287
|
-
|
|
288
|
-
// If we used a template or imported an app there will be an existing doc.
|
|
289
|
-
// Fetch and migrate some metadata from the existing app.
|
|
290
|
-
try {
|
|
291
|
-
const existing: App = await db.get(DocumentType.APP_METADATA)
|
|
292
|
-
const keys: (keyof App)[] = [
|
|
293
|
-
"_rev",
|
|
294
|
-
"navigation",
|
|
295
|
-
"theme",
|
|
296
|
-
"customTheme",
|
|
297
|
-
"icon",
|
|
298
|
-
]
|
|
299
|
-
keys.forEach(key => {
|
|
300
|
-
if (existing[key]) {
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
newApplication[key] = existing[key]
|
|
303
|
-
}
|
|
304
|
-
})
|
|
305
|
-
|
|
306
|
-
// Migrate navigation settings and screens if required
|
|
307
|
-
if (existing && !existing.navigation) {
|
|
308
|
-
const navigation = await migrateAppNavigation()
|
|
309
|
-
if (navigation) {
|
|
310
|
-
newApplication.navigation = navigation
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
} catch (err) {
|
|
314
|
-
// Nothing to do
|
|
315
|
-
}
|
|
316
|
-
|
|
317
288
|
const response = await db.put(newApplication, { force: true })
|
|
318
289
|
newApplication._rev = response.rev
|
|
319
290
|
|
|
@@ -596,55 +567,3 @@ const updateAppPackage = async (appPackage: any, appId: any) => {
|
|
|
596
567
|
return newAppPackage
|
|
597
568
|
})
|
|
598
569
|
}
|
|
599
|
-
|
|
600
|
-
const migrateAppNavigation = async () => {
|
|
601
|
-
const db = context.getAppDB()
|
|
602
|
-
const existing: App = await db.get(DocumentType.APP_METADATA)
|
|
603
|
-
const layouts: Layout[] = await getLayouts()
|
|
604
|
-
const screens: Screen[] = await getScreens()
|
|
605
|
-
|
|
606
|
-
// Migrate all screens, removing custom layouts
|
|
607
|
-
for (let screen of screens) {
|
|
608
|
-
if (!screen.layoutId) {
|
|
609
|
-
return
|
|
610
|
-
}
|
|
611
|
-
const layout = layouts.find(layout => layout._id === screen.layoutId)
|
|
612
|
-
screen.layoutId = undefined
|
|
613
|
-
screen.showNavigation = layout?.props.navigation !== "None"
|
|
614
|
-
screen.width = layout?.props.width || "Large"
|
|
615
|
-
await db.put(screen)
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// Migrate layout navigation settings
|
|
619
|
-
const { name, customTheme } = existing
|
|
620
|
-
const layout = layouts?.find(
|
|
621
|
-
(layout: Layout) => layout._id === BASE_LAYOUT_PROP_IDS.PRIVATE
|
|
622
|
-
)
|
|
623
|
-
if (layout) {
|
|
624
|
-
let navigationSettings: any = {
|
|
625
|
-
navigation: "Top",
|
|
626
|
-
title: name,
|
|
627
|
-
navWidth: "Large",
|
|
628
|
-
navBackground:
|
|
629
|
-
customTheme?.navBackground || "var(--spectrum-global-color-gray-50)",
|
|
630
|
-
navTextColor:
|
|
631
|
-
customTheme?.navTextColor || "var(--spectrum-global-color-gray-800)",
|
|
632
|
-
}
|
|
633
|
-
if (layout) {
|
|
634
|
-
navigationSettings.hideLogo = layout.props.hideLogo
|
|
635
|
-
navigationSettings.hideTitle = layout.props.hideTitle
|
|
636
|
-
navigationSettings.title = layout.props.title || name
|
|
637
|
-
navigationSettings.logoUrl = layout.props.logoUrl
|
|
638
|
-
navigationSettings.links = layout.props.links
|
|
639
|
-
navigationSettings.navigation = layout.props.navigation || "Top"
|
|
640
|
-
navigationSettings.sticky = layout.props.sticky
|
|
641
|
-
navigationSettings.navWidth = layout.props.width || "Large"
|
|
642
|
-
if (navigationSettings.navigation === "None") {
|
|
643
|
-
navigationSettings.navigation = "Top"
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
return navigationSettings
|
|
647
|
-
} else {
|
|
648
|
-
return null
|
|
649
|
-
}
|
|
650
|
-
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { SearchIndexes } = require("../../../db/utils")
|
|
2
|
-
const { removeKeyNumbering } = require("./utils")
|
|
3
2
|
const fetch = require("node-fetch")
|
|
4
3
|
const { getCouchInfo } = require("@budibase/backend-core/db")
|
|
5
4
|
const { getAppId } = require("@budibase/backend-core/context")
|
|
@@ -21,8 +20,6 @@ class QueryBuilder {
|
|
|
21
20
|
notEmpty: {},
|
|
22
21
|
oneOf: {},
|
|
23
22
|
contains: {},
|
|
24
|
-
notContains: {},
|
|
25
|
-
containsAny: {},
|
|
26
23
|
...base,
|
|
27
24
|
}
|
|
28
25
|
this.limit = 50
|
|
@@ -128,16 +125,6 @@ class QueryBuilder {
|
|
|
128
125
|
return this
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
addNotContains(key, value) {
|
|
132
|
-
this.query.notContains[key] = value
|
|
133
|
-
return this
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
addContainsAny(key, value) {
|
|
137
|
-
this.query.containsAny[key] = value
|
|
138
|
-
return this
|
|
139
|
-
}
|
|
140
|
-
|
|
141
128
|
/**
|
|
142
129
|
* Preprocesses a value before going into a lucene search.
|
|
143
130
|
* Transforms strings to lowercase and wraps strings and bools in quotes.
|
|
@@ -183,29 +170,11 @@ class QueryBuilder {
|
|
|
183
170
|
return `${key}:${builder.preprocess(value, allPreProcessingOpts)}`
|
|
184
171
|
}
|
|
185
172
|
|
|
186
|
-
const contains = (key, value
|
|
187
|
-
if (
|
|
173
|
+
const contains = (key, value) => {
|
|
174
|
+
if (!value && value !== 0) {
|
|
188
175
|
return null
|
|
189
176
|
}
|
|
190
|
-
|
|
191
|
-
return `${key}:${value}`
|
|
192
|
-
}
|
|
193
|
-
let statement = `${builder.preprocess(value[0], { escape: true })}`
|
|
194
|
-
for (let i = 1; i < value.length; i++) {
|
|
195
|
-
statement += ` ${mode} ${builder.preprocess(value[i], {
|
|
196
|
-
escape: true,
|
|
197
|
-
})}`
|
|
198
|
-
}
|
|
199
|
-
return `${key}:(${statement})`
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const notContains = (key, value) => {
|
|
203
|
-
const allPrefix = allOr === "" ? "*:* AND" : ""
|
|
204
|
-
return allPrefix + "NOT " + contains(key, value)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const containsAny = (key, value) => {
|
|
208
|
-
return contains(key, value, "OR")
|
|
177
|
+
return `${key}:${builder.preprocess(value, { escape: true })}`
|
|
209
178
|
}
|
|
210
179
|
|
|
211
180
|
const oneOf = (key, value) => {
|
|
@@ -228,8 +197,6 @@ class QueryBuilder {
|
|
|
228
197
|
|
|
229
198
|
function build(structure, queryFn) {
|
|
230
199
|
for (let [key, value] of Object.entries(structure)) {
|
|
231
|
-
// check for new format - remove numbering if needed
|
|
232
|
-
key = removeKeyNumbering(key)
|
|
233
200
|
key = builder.preprocess(key.replace(/ /g, "_"), {
|
|
234
201
|
escape: true,
|
|
235
202
|
})
|
|
@@ -308,12 +275,6 @@ class QueryBuilder {
|
|
|
308
275
|
if (this.query.contains) {
|
|
309
276
|
build(this.query.contains, contains)
|
|
310
277
|
}
|
|
311
|
-
if (this.query.notContains) {
|
|
312
|
-
build(this.query.notContains, notContains)
|
|
313
|
-
}
|
|
314
|
-
if (this.query.containsAny) {
|
|
315
|
-
build(this.query.containsAny, containsAny)
|
|
316
|
-
}
|
|
317
278
|
// make sure table ID is always added as an AND
|
|
318
279
|
if (tableId) {
|
|
319
280
|
query = `(${query})`
|
|
@@ -349,9 +310,6 @@ class QueryBuilder {
|
|
|
349
310
|
}
|
|
350
311
|
}
|
|
351
312
|
|
|
352
|
-
// exported for unit testing
|
|
353
|
-
exports.QueryBuilder = QueryBuilder
|
|
354
|
-
|
|
355
313
|
/**
|
|
356
314
|
* Executes a lucene search query.
|
|
357
315
|
* @param url The query URL
|
|
@@ -3,9 +3,8 @@ const { cloneDeep } = require("lodash/fp")
|
|
|
3
3
|
const { InternalTables } = require("../../../db/utils")
|
|
4
4
|
const userController = require("../user")
|
|
5
5
|
const { FieldTypes } = require("../../../constants")
|
|
6
|
+
const { makeExternalQuery } = require("../../../integrations/base/utils")
|
|
6
7
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
7
|
-
const { makeExternalQuery } = require("../../../integrations/base/query")
|
|
8
|
-
const { removeKeyNumbering } = require("../../../integrations/base/utils")
|
|
9
8
|
|
|
10
9
|
validateJs.extend(validateJs.validators.datetime, {
|
|
11
10
|
parse: function (value) {
|
|
@@ -17,8 +16,6 @@ validateJs.extend(validateJs.validators.datetime, {
|
|
|
17
16
|
},
|
|
18
17
|
})
|
|
19
18
|
|
|
20
|
-
exports.removeKeyNumbering = removeKeyNumbering
|
|
21
|
-
|
|
22
19
|
exports.getDatasourceAndQuery = async json => {
|
|
23
20
|
const datasourceId = json.endpoint.datasourceId
|
|
24
21
|
const db = getAppDB()
|
|
@@ -12,7 +12,7 @@ const {
|
|
|
12
12
|
} = require("../../../utilities/fileSystem")
|
|
13
13
|
const env = require("../../../environment")
|
|
14
14
|
const { clientLibraryPath } = require("../../../utilities")
|
|
15
|
-
const { upload
|
|
15
|
+
const { upload } = require("../../../utilities/fileSystem")
|
|
16
16
|
const { attachmentsRelativeURL } = require("../../../utilities")
|
|
17
17
|
const { DocumentType } = require("../../../db/utils")
|
|
18
18
|
const { getAppDB, getAppId } = require("@budibase/backend-core/context")
|
|
@@ -97,10 +97,6 @@ export const uploadFile = async function (ctx: any) {
|
|
|
97
97
|
ctx.body = await Promise.all(uploads)
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
export const deleteObjects = async function (ctx: any) {
|
|
101
|
-
ctx.body = await deleteFiles(ObjectStoreBuckets.APPS, ctx.request.body.keys)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
100
|
export const serveApp = async function (ctx: any) {
|
|
105
101
|
const db = getAppDB({ skip_setup: true })
|
|
106
102
|
const appInfo = await db.get(DocumentType.APP_METADATA)
|
|
@@ -128,22 +124,6 @@ export const serveApp = async function (ctx: any) {
|
|
|
128
124
|
}
|
|
129
125
|
}
|
|
130
126
|
|
|
131
|
-
export const serveBuilderPreview = async function (ctx: any) {
|
|
132
|
-
const db = getAppDB({ skip_setup: true })
|
|
133
|
-
const appInfo = await db.get(DocumentType.APP_METADATA)
|
|
134
|
-
|
|
135
|
-
if (!env.isJest()) {
|
|
136
|
-
let appId = getAppId()
|
|
137
|
-
const previewHbs = loadHandlebarsFile(`${__dirname}/templates/preview.hbs`)
|
|
138
|
-
ctx.body = await processString(previewHbs, {
|
|
139
|
-
clientLibPath: clientLibraryPath(appId, appInfo.version, ctx),
|
|
140
|
-
})
|
|
141
|
-
} else {
|
|
142
|
-
// just return the app info for jest to assert on
|
|
143
|
-
ctx.body = { ...appInfo, builderPreview: true }
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
127
|
export const serveClientLibrary = async function (ctx: any) {
|
|
148
128
|
return send(ctx, "budibase-client.js", {
|
|
149
129
|
root: join(NODE_MODULES_PATH, "@budibase", "client", "dist"),
|
|
@@ -14,7 +14,7 @@ const {
|
|
|
14
14
|
FieldTypes,
|
|
15
15
|
RelationshipTypes,
|
|
16
16
|
} = require("../../../constants")
|
|
17
|
-
const { makeExternalQuery } = require("../../../integrations/base/
|
|
17
|
+
const { makeExternalQuery } = require("../../../integrations/base/utils")
|
|
18
18
|
const { cloneDeep } = require("lodash/fp")
|
|
19
19
|
const csvParser = require("../../../utilities/csvParser")
|
|
20
20
|
const { handleRequest } = require("../row/external")
|
package/src/api/routes/static.ts
CHANGED
|
@@ -38,11 +38,6 @@ router
|
|
|
38
38
|
// TODO: for now this builder endpoint is not authorized/secured, will need to be
|
|
39
39
|
.get("/builder/:file*", controller.serveBuilder)
|
|
40
40
|
.post("/api/attachments/process", authorized(BUILDER), controller.uploadFile)
|
|
41
|
-
.post(
|
|
42
|
-
"/api/attachments/delete",
|
|
43
|
-
authorized(BUILDER),
|
|
44
|
-
controller.deleteObjects
|
|
45
|
-
)
|
|
46
41
|
.post("/api/beta/:feature", controller.toggleBetaUiFeature)
|
|
47
42
|
.post(
|
|
48
43
|
"/api/attachments/:tableId/upload",
|
|
@@ -50,13 +45,6 @@ router
|
|
|
50
45
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
|
51
46
|
controller.uploadFile
|
|
52
47
|
)
|
|
53
|
-
.post(
|
|
54
|
-
"/api/attachments/:tableId/delete",
|
|
55
|
-
paramResource("tableId"),
|
|
56
|
-
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
|
57
|
-
controller.deleteObjects
|
|
58
|
-
)
|
|
59
|
-
.get("/preview", authorized(BUILDER), controller.serveBuilderPreview)
|
|
60
48
|
.get("/:appId/:path*", controller.serveApp)
|
|
61
49
|
.get("/app/:appUrl/:path*", controller.serveApp)
|
|
62
50
|
.post(
|
|
@@ -17,7 +17,6 @@ const {
|
|
|
17
17
|
checkBuilderEndpoint,
|
|
18
18
|
} = require("./utilities/TestFunctions")
|
|
19
19
|
const setup = require("./utilities")
|
|
20
|
-
const { basicScreen, basicLayout } = setup.structures
|
|
21
20
|
const { AppStatus } = require("../../../db/utils")
|
|
22
21
|
const { events } = require("@budibase/backend-core")
|
|
23
22
|
|
|
@@ -82,31 +81,6 @@ describe("/applications", () => {
|
|
|
82
81
|
body: { name: "My App" },
|
|
83
82
|
})
|
|
84
83
|
})
|
|
85
|
-
|
|
86
|
-
it("migrates navigation settings from old apps", async () => {
|
|
87
|
-
const res = await request
|
|
88
|
-
.post("/api/applications")
|
|
89
|
-
.field("name", "Old App")
|
|
90
|
-
.field("useTemplate", "true")
|
|
91
|
-
.set(config.defaultHeaders())
|
|
92
|
-
.attach("templateFile", "src/api/routes/tests/data/old-app.txt")
|
|
93
|
-
.expect("Content-Type", /json/)
|
|
94
|
-
.expect(200)
|
|
95
|
-
expect(res.body._id).toBeDefined()
|
|
96
|
-
expect(res.body.navigation).toBeDefined()
|
|
97
|
-
expect(res.body.navigation.hideLogo).toBe(true)
|
|
98
|
-
expect(res.body.navigation.title).toBe("Custom Title")
|
|
99
|
-
expect(res.body.navigation.hideLogo).toBe(true)
|
|
100
|
-
expect(res.body.navigation.navigation).toBe("Left")
|
|
101
|
-
expect(res.body.navigation.navBackground).toBe(
|
|
102
|
-
"var(--spectrum-global-color-blue-600)"
|
|
103
|
-
)
|
|
104
|
-
expect(res.body.navigation.navTextColor).toBe(
|
|
105
|
-
"var(--spectrum-global-color-gray-50)"
|
|
106
|
-
)
|
|
107
|
-
expect(events.app.created).toBeCalledTimes(1)
|
|
108
|
-
expect(events.app.fileImported).toBeCalledTimes(1)
|
|
109
|
-
})
|
|
110
84
|
})
|
|
111
85
|
|
|
112
86
|
describe("fetch", () => {
|
|
@@ -40,6 +40,7 @@ describe("/static", () => {
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
describe("/app", () => {
|
|
43
|
+
|
|
43
44
|
beforeEach(() => {
|
|
44
45
|
jest.clearAllMocks()
|
|
45
46
|
})
|
|
@@ -59,7 +60,7 @@ describe("/static", () => {
|
|
|
59
60
|
it("should serve the app by url", async () => {
|
|
60
61
|
const headers = config.defaultHeaders()
|
|
61
62
|
delete headers[constants.Headers.APP_ID]
|
|
62
|
-
|
|
63
|
+
|
|
63
64
|
const res = await request
|
|
64
65
|
.get(`/app${config.prodApp.url}`)
|
|
65
66
|
.set(headers)
|
|
@@ -81,7 +82,7 @@ describe("/static", () => {
|
|
|
81
82
|
describe("/attachments", () => {
|
|
82
83
|
describe("generateSignedUrls", () => {
|
|
83
84
|
let datasource
|
|
84
|
-
|
|
85
|
+
|
|
85
86
|
beforeEach(async () => {
|
|
86
87
|
datasource = await config.createDatasource({
|
|
87
88
|
datasource: {
|
|
@@ -92,7 +93,7 @@ describe("/static", () => {
|
|
|
92
93
|
},
|
|
93
94
|
})
|
|
94
95
|
})
|
|
95
|
-
|
|
96
|
+
|
|
96
97
|
it("should be able to generate a signed upload URL", async () => {
|
|
97
98
|
const bucket = "foo"
|
|
98
99
|
const key = "bar"
|
|
@@ -107,7 +108,7 @@ describe("/static", () => {
|
|
|
107
108
|
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
|
|
108
109
|
)
|
|
109
110
|
})
|
|
110
|
-
|
|
111
|
+
|
|
111
112
|
it("should handle an invalid datasource ID", async () => {
|
|
112
113
|
const res = await request
|
|
113
114
|
.post(`/api/attachments/foo/url`)
|
|
@@ -122,7 +123,7 @@ describe("/static", () => {
|
|
|
122
123
|
"The specified datasource could not be found"
|
|
123
124
|
)
|
|
124
125
|
})
|
|
125
|
-
|
|
126
|
+
|
|
126
127
|
it("should require a bucket parameter", async () => {
|
|
127
128
|
const res = await request
|
|
128
129
|
.post(`/api/attachments/${datasource._id}/url`)
|
|
@@ -135,7 +136,7 @@ describe("/static", () => {
|
|
|
135
136
|
.expect(400)
|
|
136
137
|
expect(res.body.message).toEqual("bucket and key values are required")
|
|
137
138
|
})
|
|
138
|
-
|
|
139
|
+
|
|
139
140
|
it("should require a key parameter", async () => {
|
|
140
141
|
const res = await request
|
|
141
142
|
.post(`/api/attachments/${datasource._id}/url`)
|
|
@@ -150,17 +151,4 @@ describe("/static", () => {
|
|
|
150
151
|
})
|
|
151
152
|
})
|
|
152
153
|
|
|
153
|
-
describe("/preview", () => {
|
|
154
|
-
beforeEach(() => {
|
|
155
|
-
jest.clearAllMocks()
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
it("should serve the builder preview", async () => {
|
|
159
|
-
const headers = config.defaultHeaders()
|
|
160
|
-
const res = await request.get(`/preview`).set(headers).expect(200)
|
|
161
|
-
|
|
162
|
-
expect(res.body.appId).toBe(config.appId)
|
|
163
|
-
expect(res.body.builderPreview).toBe(true)
|
|
164
|
-
})
|
|
165
|
-
})
|
|
166
154
|
})
|
package/src/app.ts
CHANGED
|
@@ -83,7 +83,9 @@ server.on("close", async () => {
|
|
|
83
83
|
return
|
|
84
84
|
}
|
|
85
85
|
shuttingDown = true
|
|
86
|
-
|
|
86
|
+
if (!env.isTest()) {
|
|
87
|
+
console.log("Server Closed")
|
|
88
|
+
}
|
|
87
89
|
await automations.shutdown()
|
|
88
90
|
await redis.shutdown()
|
|
89
91
|
await events.shutdown()
|
|
@@ -165,7 +167,3 @@ process.on("uncaughtException", err => {
|
|
|
165
167
|
process.on("SIGTERM", () => {
|
|
166
168
|
shutdown()
|
|
167
169
|
})
|
|
168
|
-
|
|
169
|
-
process.on("SIGINT", () => {
|
|
170
|
-
shutdown()
|
|
171
|
-
})
|
|
@@ -23,9 +23,6 @@ export async function checkAppMetadata(apps: App[]) {
|
|
|
23
23
|
for (let [key, errors] of Object.entries(metadata.automationErrors)) {
|
|
24
24
|
const updated = []
|
|
25
25
|
for (let error of errors) {
|
|
26
|
-
if (!error) {
|
|
27
|
-
continue
|
|
28
|
-
}
|
|
29
26
|
const startDate = error.split(dbUtils.SEPARATOR)[2]
|
|
30
27
|
if (startDate > maxStartDate) {
|
|
31
28
|
updated.push(error)
|