@budibase/server 1.0.48 → 1.0.49-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.e083dcaf.js → index.8184eed9.js} +224 -222
- package/builder/assets/{index.39e01193.css → index.dd9e386f.css} +1 -1
- package/builder/assets/{vendor.f9faf6ab.js → vendor.3bd2f661.js} +12 -12
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1860 -1683
- package/coverage/coverage-final.json +99 -95
- 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/application.js.html +210 -126
- package/coverage/lcov-report/api/controllers/auth.js.html +18 -6
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- 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 +4 -4
- package/coverage/lcov-report/api/controllers/datasource.js.html +72 -36
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +38 -53
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- 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 +6 -6
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +15 -15
- package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/row/internal.js.html +44 -44
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -8
- package/coverage/lcov-report/api/controllers/row/utils.js.html +39 -57
- 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 +23 -23
- package/coverage/lcov-report/api/controllers/table/index.js.html +57 -39
- package/coverage/lcov-report/api/controllers/table/internal.js.html +40 -34
- package/coverage/lcov-report/api/controllers/table/utils.js.html +87 -63
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +30 -24
- 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 +10 -10
- 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/application.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 +7 -22
- package/coverage/lcov-report/api/routes/index.js.html +4 -10
- 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/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/row.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/static.js.html +17 -2
- 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/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +13 -19
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +11 -20
- 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 +13 -13
- 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 +5 -5
- package/coverage/lcov-report/constants/index.js.html +38 -26
- 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 +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +18 -18
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +31 -31
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +15 -15
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +85 -85
- 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 +5 -5
- package/coverage/lcov-report/events/utils.js.html +3 -3
- package/coverage/lcov-report/index.html +107 -77
- 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/authorized.js.html +166 -64
- package/coverage/lcov-report/middleware/builder.js.html +8 -8
- package/coverage/lcov-report/middleware/currentapp.js.html +29 -29
- package/coverage/lcov-report/middleware/index.html +30 -30
- package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
- 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/usageQuota.js.html +275 -41
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/migrations/usageQuotas/index.html +141 -0
- package/coverage/lcov-report/migrations/usageQuotas/index.js.html +152 -0
- package/coverage/lcov-report/{api/routes/hosting.js.html → migrations/usageQuotas/syncApps.js.html} +42 -27
- package/coverage/lcov-report/{api/controllers/hosting.js.html → migrations/usageQuotas/syncRows.js.html} +41 -44
- 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 +8 -8
- 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 +53 -53
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
- 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 +141 -0
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +356 -0
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +302 -0
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +134 -0
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +39 -108
- package/coverage/lcov.info +2730 -2419
- package/dist/api/controllers/application.js +49 -20
- package/dist/api/controllers/auth.js +4 -0
- package/dist/api/controllers/datasource.js +11 -0
- package/dist/api/controllers/row/utils.js +6 -8
- package/dist/api/controllers/static/index.js +59 -10
- package/dist/api/controllers/table/index.js +10 -4
- package/dist/api/controllers/table/internal.js +2 -0
- package/dist/api/controllers/table/utils.js +9 -2
- package/dist/api/controllers/user.js +2 -0
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/static.js +2 -1
- package/dist/automations/steps/createRow.js +2 -4
- package/dist/automations/steps/deleteRow.js +1 -4
- package/dist/constants/index.js +3 -0
- package/dist/definitions/datasource.js +1 -0
- package/dist/environment.js +1 -0
- package/dist/integrations/base/sql.js +13 -6
- package/dist/integrations/googlesheets.js +340 -0
- package/dist/integrations/index.js +3 -0
- package/dist/integrations/utils.js +57 -9
- package/dist/middleware/authorized.js +55 -30
- package/dist/middleware/usageQuota.js +82 -13
- package/dist/migrations/usageQuotas/index.js +24 -0
- package/dist/migrations/usageQuotas/syncApps.js +26 -0
- package/dist/migrations/usageQuotas/syncRows.js +29 -0
- package/dist/package.json +8 -5
- package/dist/tests/utilities/TestConfiguration.js +10 -6
- package/dist/threads/query.js +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/{usageQuota.js → usageQuota/index.js} +44 -31
- package/dist/utilities/usageQuota/rows.js +77 -0
- package/dist/utilities/usageQuota/usageQuoteReset.js +16 -0
- package/dist/utilities/workerRequests.js +0 -20
- package/nodemon.json +1 -1
- package/package.json +9 -6
- package/src/api/controllers/application.js +52 -24
- package/src/api/controllers/auth.js +4 -0
- package/src/api/controllers/datasource.js +12 -0
- package/src/api/controllers/row/utils.js +6 -12
- package/src/api/controllers/static/index.js +63 -10
- package/src/api/controllers/table/index.js +15 -9
- package/src/api/controllers/table/internal.js +2 -0
- package/src/api/controllers/table/utils.js +9 -1
- package/src/api/controllers/user.js +2 -0
- package/src/api/routes/index.js +0 -2
- package/src/api/routes/static.js +5 -0
- package/src/api/routes/tests/application.spec.js +2 -2
- package/src/api/routes/tests/auth.spec.js +1 -2
- package/src/api/routes/tests/static.spec.js +98 -0
- package/src/automations/steps/createRow.js +2 -4
- package/src/automations/steps/deleteRow.js +1 -4
- package/src/constants/index.js +4 -0
- package/src/definitions/datasource.ts +3 -0
- package/src/environment.js +1 -0
- package/src/integrations/base/sql.ts +14 -7
- package/src/integrations/googlesheets.ts +353 -0
- package/src/integrations/index.ts +3 -0
- package/src/integrations/tests/sql.spec.js +16 -0
- package/src/integrations/utils.ts +71 -11
- package/src/middleware/authorized.js +64 -30
- package/src/middleware/tests/authorized.spec.js +6 -4
- package/src/middleware/tests/usageQuota.spec.js +18 -24
- package/src/middleware/usageQuota.js +93 -15
- package/src/migrations/tests/usageQuotas/index.spec.js +27 -0
- package/src/migrations/tests/usageQuotas/syncApps.spec.js +37 -0
- package/src/migrations/tests/usageQuotas/syncRows.spec.js +43 -0
- package/src/migrations/usageQuotas/index.js +24 -0
- package/src/migrations/usageQuotas/syncApps.js +18 -0
- package/src/migrations/usageQuotas/syncRows.js +21 -0
- package/src/tests/utilities/TestConfiguration.js +10 -6
- package/src/threads/query.js +5 -0
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +72 -0
- package/src/utilities/usageQuota/index.js +92 -0
- package/src/utilities/usageQuota/rows.js +74 -0
- package/src/utilities/usageQuota/usageQuoteReset.js +18 -0
- package/src/utilities/workerRequests.js +0 -23
- 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
- package/src/utilities/usageQuota.js +0 -73
|
@@ -8,6 +8,7 @@ const {
|
|
|
8
8
|
getTable,
|
|
9
9
|
handleDataImport,
|
|
10
10
|
} = require("./utils")
|
|
11
|
+
const usageQuota = require("../../../utilities/usageQuota")
|
|
11
12
|
|
|
12
13
|
exports.save = async function (ctx) {
|
|
13
14
|
const appId = ctx.appId
|
|
@@ -119,6 +120,7 @@ exports.destroy = async function (ctx) {
|
|
|
119
120
|
})
|
|
120
121
|
)
|
|
121
122
|
await db.bulkDocs(rows.rows.map(row => ({ ...row.doc, _deleted: true })))
|
|
123
|
+
await usageQuota.update(usageQuota.Properties.ROW, -rows.rows.length)
|
|
122
124
|
|
|
123
125
|
// update linked rows
|
|
124
126
|
await linkRows.updateLinks({
|
|
@@ -16,9 +16,11 @@ const {
|
|
|
16
16
|
const {
|
|
17
17
|
isExternalTable,
|
|
18
18
|
breakExternalTableId,
|
|
19
|
+
isSQL,
|
|
19
20
|
} = require("../../../integrations/utils")
|
|
20
21
|
const { getViews, saveView } = require("../view/utils")
|
|
21
22
|
const viewTemplate = require("../view/viewBuilder")
|
|
23
|
+
const usageQuota = require("../../../utilities/usageQuota")
|
|
22
24
|
|
|
23
25
|
exports.checkForColumnUpdates = async (db, oldTable, updatedTable) => {
|
|
24
26
|
let updatedRows = []
|
|
@@ -115,7 +117,11 @@ exports.handleDataImport = async (appId, user, table, dataImport) => {
|
|
|
115
117
|
finalData.push(row)
|
|
116
118
|
}
|
|
117
119
|
|
|
120
|
+
await usageQuota.update(usageQuota.Properties.ROW, finalData.length, {
|
|
121
|
+
dryRun: true,
|
|
122
|
+
})
|
|
118
123
|
await db.bulkDocs(finalData)
|
|
124
|
+
await usageQuota.update(usageQuota.Properties.ROW, finalData.length)
|
|
119
125
|
let response = await db.put(table)
|
|
120
126
|
table._rev = response._rev
|
|
121
127
|
return table
|
|
@@ -246,7 +252,9 @@ exports.getTable = async (appId, tableId) => {
|
|
|
246
252
|
const db = new CouchDB(appId)
|
|
247
253
|
if (isExternalTable(tableId)) {
|
|
248
254
|
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
249
|
-
|
|
255
|
+
const datasource = await db.get(datasourceId)
|
|
256
|
+
const table = await exports.getExternalTable(appId, datasourceId, tableName)
|
|
257
|
+
return { ...table, sql: isSQL(datasource) }
|
|
250
258
|
} else {
|
|
251
259
|
return db.get(tableId)
|
|
252
260
|
}
|
|
@@ -167,6 +167,8 @@ exports.updateSelfMetadata = async function (ctx) {
|
|
|
167
167
|
ctx.request.body._id = ctx.user._id
|
|
168
168
|
// make sure no stale rev
|
|
169
169
|
delete ctx.request.body._rev
|
|
170
|
+
// make sure no csrf token
|
|
171
|
+
delete ctx.request.body.csrfToken
|
|
170
172
|
await exports.updateMetadata(ctx)
|
|
171
173
|
}
|
|
172
174
|
|
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,
|
package/src/api/routes/static.js
CHANGED
|
@@ -46,5 +46,10 @@ router
|
|
|
46
46
|
)
|
|
47
47
|
// TODO: this likely needs to be secured in some way
|
|
48
48
|
.get("/:appId/:path*", controller.serveApp)
|
|
49
|
+
.post(
|
|
50
|
+
"/api/attachments/:datasourceId/url",
|
|
51
|
+
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
|
52
|
+
controller.getSignedUploadURL
|
|
53
|
+
)
|
|
49
54
|
|
|
50
55
|
module.exports = router
|
|
@@ -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}`)
|
|
@@ -13,10 +13,9 @@ describe("/authenticate", () => {
|
|
|
13
13
|
|
|
14
14
|
describe("fetch self", () => {
|
|
15
15
|
it("should be able to fetch self", async () => {
|
|
16
|
-
const headers = await config.login()
|
|
17
16
|
const res = await request
|
|
18
17
|
.get(`/api/self`)
|
|
19
|
-
.set(
|
|
18
|
+
.set(config.defaultHeaders())
|
|
20
19
|
.expect("Content-Type", /json/)
|
|
21
20
|
.expect(200)
|
|
22
21
|
expect(res.body._id).toEqual(generateUserMetadataID("us_uuid1"))
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
jest.mock("node-fetch")
|
|
2
|
+
jest.mock("aws-sdk", () => ({
|
|
3
|
+
config: {
|
|
4
|
+
update: jest.fn(),
|
|
5
|
+
},
|
|
6
|
+
DynamoDB: {
|
|
7
|
+
DocumentClient: jest.fn(),
|
|
8
|
+
},
|
|
9
|
+
S3: jest.fn(() => ({
|
|
10
|
+
getSignedUrl: jest.fn(() => {
|
|
11
|
+
return "my-url"
|
|
12
|
+
}),
|
|
13
|
+
})),
|
|
14
|
+
}))
|
|
15
|
+
|
|
16
|
+
const setup = require("./utilities")
|
|
17
|
+
|
|
18
|
+
describe("/attachments", () => {
|
|
19
|
+
let request = setup.getRequest()
|
|
20
|
+
let config = setup.getConfig()
|
|
21
|
+
let app
|
|
22
|
+
|
|
23
|
+
afterAll(setup.afterAll)
|
|
24
|
+
|
|
25
|
+
beforeEach(async () => {
|
|
26
|
+
app = await config.init()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe("generateSignedUrls", () => {
|
|
30
|
+
let datasource
|
|
31
|
+
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
datasource = await config.createDatasource({
|
|
34
|
+
datasource: {
|
|
35
|
+
type: "datasource",
|
|
36
|
+
name: "Test",
|
|
37
|
+
source: "S3",
|
|
38
|
+
config: {},
|
|
39
|
+
},
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it("should be able to generate a signed upload URL", async () => {
|
|
44
|
+
const bucket = "foo"
|
|
45
|
+
const key = "bar"
|
|
46
|
+
const res = await request
|
|
47
|
+
.post(`/api/attachments/${datasource._id}/url`)
|
|
48
|
+
.send({ bucket, key })
|
|
49
|
+
.set(config.defaultHeaders())
|
|
50
|
+
.expect("Content-Type", /json/)
|
|
51
|
+
.expect(200)
|
|
52
|
+
expect(res.body.signedUrl).toEqual("my-url")
|
|
53
|
+
expect(res.body.publicUrl).toEqual(
|
|
54
|
+
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
|
|
55
|
+
)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it("should handle an invalid datasource ID", async () => {
|
|
59
|
+
const res = await request
|
|
60
|
+
.post(`/api/attachments/foo/url`)
|
|
61
|
+
.send({
|
|
62
|
+
bucket: "foo",
|
|
63
|
+
key: "bar",
|
|
64
|
+
})
|
|
65
|
+
.set(config.defaultHeaders())
|
|
66
|
+
.expect("Content-Type", /json/)
|
|
67
|
+
.expect(400)
|
|
68
|
+
expect(res.body.message).toEqual(
|
|
69
|
+
"The specified datasource could not be found"
|
|
70
|
+
)
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it("should require a bucket parameter", async () => {
|
|
74
|
+
const res = await request
|
|
75
|
+
.post(`/api/attachments/${datasource._id}/url`)
|
|
76
|
+
.send({
|
|
77
|
+
bucket: undefined,
|
|
78
|
+
key: "bar",
|
|
79
|
+
})
|
|
80
|
+
.set(config.defaultHeaders())
|
|
81
|
+
.expect("Content-Type", /json/)
|
|
82
|
+
.expect(400)
|
|
83
|
+
expect(res.body.message).toEqual("bucket and key values are required")
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it("should require a key parameter", async () => {
|
|
87
|
+
const res = await request
|
|
88
|
+
.post(`/api/attachments/${datasource._id}/url`)
|
|
89
|
+
.send({
|
|
90
|
+
bucket: "foo",
|
|
91
|
+
})
|
|
92
|
+
.set(config.defaultHeaders())
|
|
93
|
+
.expect("Content-Type", /json/)
|
|
94
|
+
.expect(400)
|
|
95
|
+
expect(res.body.message).toEqual("bucket and key values are required")
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
})
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const rowController = require("../../api/controllers/row")
|
|
2
2
|
const automationUtils = require("../automationUtils")
|
|
3
|
-
const env = require("../../environment")
|
|
4
3
|
const usage = require("../../utilities/usageQuota")
|
|
5
4
|
const { buildCtx } = require("./utils")
|
|
6
5
|
|
|
@@ -83,10 +82,9 @@ exports.run = async function ({ inputs, appId, emitter }) {
|
|
|
83
82
|
inputs.row.tableId,
|
|
84
83
|
inputs.row
|
|
85
84
|
)
|
|
86
|
-
|
|
87
|
-
await usage.update(usage.Properties.ROW, 1)
|
|
88
|
-
}
|
|
85
|
+
await usage.update(usage.Properties.ROW, 1, { dryRun: true })
|
|
89
86
|
await rowController.save(ctx)
|
|
87
|
+
await usage.update(usage.Properties.ROW, 1)
|
|
90
88
|
return {
|
|
91
89
|
row: inputs.row,
|
|
92
90
|
response: ctx.body,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const rowController = require("../../api/controllers/row")
|
|
2
|
-
const env = require("../../environment")
|
|
3
2
|
const usage = require("../../utilities/usageQuota")
|
|
4
3
|
const { buildCtx } = require("./utils")
|
|
5
4
|
const automationUtils = require("../automationUtils")
|
|
@@ -74,9 +73,7 @@ exports.run = async function ({ inputs, appId, emitter }) {
|
|
|
74
73
|
})
|
|
75
74
|
|
|
76
75
|
try {
|
|
77
|
-
|
|
78
|
-
await usage.update(usage.Properties.ROW, -1)
|
|
79
|
-
}
|
|
76
|
+
await usage.update(usage.Properties.ROW, -1)
|
|
80
77
|
await rowController.destroy(ctx)
|
|
81
78
|
return {
|
|
82
79
|
response: ctx.body,
|
package/src/constants/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export enum SourceNames {
|
|
|
47
47
|
ARANGODB = "ARANGODB",
|
|
48
48
|
REST = "REST",
|
|
49
49
|
ORACLE = "ORACLE",
|
|
50
|
+
GOOGLE_SHEETS = "GOOGLE_SHEETS",
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
export enum IncludeRelationships {
|
|
@@ -86,6 +87,8 @@ export interface ExtraQueryConfig {
|
|
|
86
87
|
export interface Integration {
|
|
87
88
|
docs: string
|
|
88
89
|
plus?: boolean
|
|
90
|
+
auth?: { type: string }
|
|
91
|
+
relationships?: boolean
|
|
89
92
|
description: string
|
|
90
93
|
friendlyName: string
|
|
91
94
|
datasource: {}
|
package/src/environment.js
CHANGED
|
@@ -38,6 +38,7 @@ module.exports = {
|
|
|
38
38
|
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
39
39
|
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
|
40
40
|
USE_QUOTAS: process.env.USE_QUOTAS,
|
|
41
|
+
EXCLUDE_QUOTAS_TENANTS: process.env.EXCLUDE_QUOTAS_TENANTS,
|
|
41
42
|
REDIS_URL: process.env.REDIS_URL,
|
|
42
43
|
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
|
43
44
|
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
|
@@ -72,16 +72,22 @@ class InternalBuilder {
|
|
|
72
72
|
|
|
73
73
|
// right now we only do filters on the specific table being queried
|
|
74
74
|
addFilters(
|
|
75
|
-
tableName: string,
|
|
76
75
|
query: KnexQuery,
|
|
77
|
-
filters: SearchFilters | undefined
|
|
76
|
+
filters: SearchFilters | undefined,
|
|
77
|
+
opts: { relationship?: boolean; tableName?: string }
|
|
78
78
|
): KnexQuery {
|
|
79
79
|
function iterate(
|
|
80
80
|
structure: { [key: string]: any },
|
|
81
81
|
fn: (key: string, value: any) => void
|
|
82
82
|
) {
|
|
83
83
|
for (let [key, value] of Object.entries(structure)) {
|
|
84
|
-
|
|
84
|
+
const isRelationshipField = key.includes(".")
|
|
85
|
+
if (!opts.relationship && !isRelationshipField) {
|
|
86
|
+
fn(`${opts.tableName}.${key}`, value)
|
|
87
|
+
}
|
|
88
|
+
if (opts.relationship && isRelationshipField) {
|
|
89
|
+
fn(key, value)
|
|
90
|
+
}
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
if (!filters) {
|
|
@@ -272,7 +278,7 @@ class InternalBuilder {
|
|
|
272
278
|
if (foundOffset) {
|
|
273
279
|
query = query.offset(foundOffset)
|
|
274
280
|
}
|
|
275
|
-
query = this.addFilters(
|
|
281
|
+
query = this.addFilters(query, filters, { tableName })
|
|
276
282
|
// add sorting to pre-query
|
|
277
283
|
query = this.addSorting(query, json)
|
|
278
284
|
// @ts-ignore
|
|
@@ -285,20 +291,21 @@ class InternalBuilder {
|
|
|
285
291
|
preQuery = this.addSorting(preQuery, json)
|
|
286
292
|
}
|
|
287
293
|
// handle joins
|
|
288
|
-
|
|
294
|
+
query = this.addRelationships(
|
|
289
295
|
knex,
|
|
290
296
|
preQuery,
|
|
291
297
|
selectStatement,
|
|
292
298
|
tableName,
|
|
293
299
|
relationships
|
|
294
300
|
)
|
|
301
|
+
return this.addFilters(query, filters, { relationship: true })
|
|
295
302
|
}
|
|
296
303
|
|
|
297
304
|
update(knex: Knex, json: QueryJson, opts: QueryOptions): KnexQuery {
|
|
298
305
|
const { endpoint, body, filters } = json
|
|
299
306
|
let query: KnexQuery = knex(endpoint.entityId)
|
|
300
307
|
const parsedBody = parseBody(body)
|
|
301
|
-
query = this.addFilters(endpoint.entityId
|
|
308
|
+
query = this.addFilters(query, filters, { tableName: endpoint.entityId })
|
|
302
309
|
// mysql can't use returning
|
|
303
310
|
if (opts.disableReturning) {
|
|
304
311
|
return query.update(parsedBody)
|
|
@@ -310,7 +317,7 @@ class InternalBuilder {
|
|
|
310
317
|
delete(knex: Knex, json: QueryJson, opts: QueryOptions): KnexQuery {
|
|
311
318
|
const { endpoint, filters } = json
|
|
312
319
|
let query: KnexQuery = knex(endpoint.entityId)
|
|
313
|
-
query = this.addFilters(endpoint.entityId
|
|
320
|
+
query = this.addFilters(query, filters, { tableName: endpoint.entityId })
|
|
314
321
|
// mysql can't use returning
|
|
315
322
|
if (opts.disableReturning) {
|
|
316
323
|
return query.delete()
|