@budibase/server 1.0.123 → 1.0.125
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.3d890df7.js +1299 -0
- package/builder/assets/index.89795487.css +6 -0
- package/builder/assets/{vendor.8e34a169.js → vendor.5240f480.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +695 -1678
- package/coverage/coverage-final.json +28 -43
- package/coverage/lcov-report/api/controllers/analytics.js.html +8 -3
- package/coverage/lcov-report/api/controllers/apikeys.js.html +9 -4
- package/coverage/lcov-report/api/controllers/auth.js.html +8 -3
- package/coverage/lcov-report/api/controllers/automation.js.html +8 -3
- package/coverage/lcov-report/api/controllers/backup.js.html +8 -3
- package/coverage/lcov-report/api/controllers/cloud.js.html +8 -3
- package/coverage/lcov-report/api/controllers/component.js.html +8 -3
- package/coverage/lcov-report/api/controllers/datasource.js.html +11 -6
- package/coverage/lcov-report/api/controllers/dev.js.html +8 -3
- package/coverage/lcov-report/api/controllers/index.html +16 -26
- package/coverage/lcov-report/api/controllers/integration.js.html +8 -3
- package/coverage/lcov-report/api/controllers/layout.js.html +8 -3
- package/coverage/lcov-report/api/controllers/metadata.js.html +8 -3
- package/coverage/lcov-report/api/controllers/migrations.js.html +8 -3
- package/coverage/lcov-report/api/controllers/permission.js.html +8 -3
- package/coverage/lcov-report/api/controllers/query/index.html +16 -26
- package/coverage/lcov-report/api/controllers/query/validation.js.html +8 -3
- package/coverage/lcov-report/api/controllers/role.js.html +10 -5
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -4
- package/coverage/lcov-report/api/controllers/row/external.js.html +8 -3
- package/coverage/lcov-report/api/controllers/row/index.html +25 -35
- package/coverage/lcov-report/api/controllers/row/internal.js.html +32 -24
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +21 -16
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -19
- package/coverage/lcov-report/api/controllers/row/utils.js.html +33 -19
- package/coverage/lcov-report/api/controllers/screen.js.html +9 -4
- package/coverage/lcov-report/api/controllers/script.js.html +8 -3
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +55 -50
- package/coverage/lcov-report/api/controllers/table/external.js.html +8 -3
- package/coverage/lcov-report/api/controllers/table/index.html +19 -44
- package/coverage/lcov-report/api/controllers/table/index.js.html +20 -15
- package/coverage/lcov-report/api/controllers/templates.js.html +8 -3
- package/coverage/lcov-report/api/controllers/user.js.html +8 -3
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +8 -3
- package/coverage/lcov-report/api/controllers/view/index.html +8 -3
- package/coverage/lcov-report/api/controllers/view/index.js.html +10 -5
- package/coverage/lcov-report/api/controllers/view/utils.js.html +8 -3
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +8 -3
- package/coverage/lcov-report/api/controllers/webhook.js.html +10 -5
- package/coverage/lcov-report/api/index.html +18 -13
- package/coverage/lcov-report/api/index.js.html +28 -8
- package/coverage/lcov-report/api/routes/analytics.js.html +8 -3
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -3
- package/coverage/lcov-report/api/routes/auth.js.html +8 -3
- package/coverage/lcov-report/api/routes/automation.js.html +8 -3
- package/coverage/lcov-report/api/routes/backup.js.html +8 -3
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -3
- package/coverage/lcov-report/api/routes/component.js.html +8 -3
- package/coverage/lcov-report/api/routes/datasource.js.html +8 -3
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -3
- package/coverage/lcov-report/api/routes/dev.js.html +9 -4
- package/coverage/lcov-report/api/routes/index.html +13 -68
- package/coverage/lcov-report/api/routes/integration.js.html +8 -3
- package/coverage/lcov-report/api/routes/layout.js.html +8 -3
- package/coverage/lcov-report/api/routes/metadata.js.html +8 -3
- package/coverage/lcov-report/api/routes/migrations.js.html +8 -3
- package/coverage/lcov-report/api/routes/permission.js.html +8 -3
- package/coverage/lcov-report/api/routes/query.js.html +8 -3
- package/coverage/lcov-report/api/routes/role.js.html +8 -3
- package/coverage/lcov-report/api/routes/routing.js.html +8 -3
- package/coverage/lcov-report/api/routes/screen.js.html +8 -3
- package/coverage/lcov-report/api/routes/script.js.html +8 -3
- package/coverage/lcov-report/api/routes/table.js.html +8 -3
- package/coverage/lcov-report/api/routes/templates.js.html +8 -3
- package/coverage/lcov-report/api/routes/user.js.html +8 -3
- package/coverage/lcov-report/api/routes/utils/index.html +8 -3
- package/coverage/lcov-report/api/routes/utils/validators.js.html +8 -3
- package/coverage/lcov-report/api/routes/view.js.html +8 -3
- package/coverage/lcov-report/api/routes/webhook.js.html +8 -3
- package/coverage/lcov-report/automations/actions.js.html +21 -7
- package/coverage/lcov-report/automations/automationUtils.js.html +64 -23
- package/coverage/lcov-report/automations/bullboard.js.html +8 -3
- package/coverage/lcov-report/automations/index.html +27 -37
- package/coverage/lcov-report/automations/index.js.html +8 -3
- package/coverage/lcov-report/automations/steps/bash.js.html +8 -3
- package/coverage/lcov-report/automations/steps/delay.js.html +8 -3
- package/coverage/lcov-report/automations/steps/discord.js.html +8 -3
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +8 -3
- package/coverage/lcov-report/automations/steps/executeScript.js.html +8 -3
- package/coverage/lcov-report/automations/steps/filter.js.html +8 -3
- package/coverage/lcov-report/automations/steps/index.html +31 -41
- package/coverage/lcov-report/automations/steps/integromat.js.html +8 -3
- package/coverage/lcov-report/{api/routes/static.js.html → automations/steps/loop.js.html} +70 -80
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +9 -4
- package/coverage/lcov-report/automations/steps/queryRows.js.html +9 -4
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +8 -3
- package/coverage/lcov-report/automations/steps/serverLog.js.html +8 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +8 -3
- package/coverage/lcov-report/automations/steps/updateRow.js.html +8 -3
- package/coverage/lcov-report/automations/steps/utils.js.html +14 -9
- package/coverage/lcov-report/automations/steps/zapier.js.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/index.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +8 -3
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +8 -3
- package/coverage/lcov-report/automations/triggers.js.html +16 -11
- package/coverage/lcov-report/block-navigation.js +8 -0
- package/coverage/lcov-report/constants/index.html +12 -7
- package/coverage/lcov-report/constants/index.js.html +55 -32
- package/coverage/lcov-report/constants/layouts.js.html +8 -3
- package/coverage/lcov-report/constants/screens.js.html +8 -3
- package/coverage/lcov-report/db/inMemoryView.js.html +8 -3
- package/coverage/lcov-report/db/index.html +8 -3
- package/coverage/lcov-report/db/index.js.html +9 -4
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +20 -15
- package/coverage/lcov-report/db/linkedRows/index.html +8 -3
- package/coverage/lcov-report/db/linkedRows/index.js.html +22 -17
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +12 -7
- package/coverage/lcov-report/db/newid.js.html +11 -6
- package/coverage/lcov-report/db/utils.js.html +84 -79
- package/coverage/lcov-report/events/AutomationEmitter.js.html +14 -9
- package/coverage/lcov-report/events/index.html +8 -3
- package/coverage/lcov-report/events/index.js.html +9 -4
- package/coverage/lcov-report/events/utils.js.html +18 -13
- package/coverage/lcov-report/index.html +125 -120
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +8 -3
- package/coverage/lcov-report/integrations/tests/index.html +8 -3
- package/coverage/lcov-report/middleware/appInfo.js.html +8 -3
- package/coverage/lcov-report/middleware/builder.js.html +8 -3
- package/coverage/lcov-report/middleware/currentapp.js.html +65 -15
- package/coverage/lcov-report/middleware/index.html +25 -50
- package/coverage/lcov-report/middleware/joi-validator.js.html +9 -4
- package/coverage/lcov-report/middleware/publicApi.js.html +8 -3
- package/coverage/lcov-report/middleware/resourceId.js.html +8 -3
- package/coverage/lcov-report/middleware/selfhost.js.html +9 -4
- package/coverage/lcov-report/middleware/utils.js.html +8 -3
- package/coverage/lcov-report/sorter.js +26 -0
- package/coverage/lcov-report/threads/automation.js.html +581 -90
- package/coverage/lcov-report/threads/index.html +30 -40
- package/coverage/lcov-report/threads/query.js.html +9 -4
- package/coverage/lcov-report/threads/utils.js.html +17 -9
- package/coverage/lcov-report/utilities/bcrypt.js.html +8 -3
- package/coverage/lcov-report/utilities/budibaseDir.js.html +8 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +8 -3
- package/coverage/lcov-report/utilities/csvParser.js.html +10 -5
- package/coverage/lcov-report/utilities/global.js.html +9 -4
- package/coverage/lcov-report/utilities/index.html +8 -3
- package/coverage/lcov-report/utilities/index.js.html +11 -6
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +32 -9
- package/coverage/lcov-report/utilities/queue/index.html +12 -7
- package/coverage/lcov-report/utilities/routing/index.html +8 -3
- package/coverage/lcov-report/utilities/routing/index.js.html +8 -3
- package/coverage/lcov-report/utilities/rowProcessor/index.html +8 -3
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +48 -43
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +18 -13
- package/coverage/lcov-report/utilities/scriptRunner.js.html +8 -3
- package/coverage/lcov-report/utilities/security.js.html +9 -4
- package/coverage/lcov-report/utilities/statusCodes.js.html +8 -3
- package/coverage/lcov-report/utilities/usageQuota/index.html +24 -34
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +44 -39
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +8 -3
- package/coverage/lcov-report/utilities/users.js.html +8 -3
- package/coverage/lcov-report/utilities/workerRequests.js.html +9 -4
- package/coverage/lcov.info +1144 -2875
- package/dist/api/controllers/application.js +145 -73
- package/dist/api/controllers/deploy/index.js +68 -36
- package/dist/api/controllers/public/applications.js +29 -9
- package/dist/api/controllers/public/queries.js +27 -7
- package/dist/api/controllers/public/rows.js +32 -12
- package/dist/api/controllers/public/tables.js +2 -2
- package/dist/api/controllers/public/users.js +8 -8
- package/dist/api/controllers/public/utils.js +1 -1
- package/dist/api/controllers/query/import/index.js +3 -3
- package/dist/api/controllers/query/index.js +57 -44
- package/dist/api/controllers/row/ExternalRequest.js +27 -27
- package/dist/api/controllers/row/index.js +83 -60
- package/dist/api/controllers/row/internal.js +2 -1
- package/dist/api/controllers/row/utils.js +2 -1
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +3 -0
- package/dist/api/controllers/table/bulkFormula.js +2 -1
- package/dist/api/controllers/table/internal.js +41 -35
- package/dist/api/controllers/table/utils.js +271 -229
- package/dist/api/index.js +5 -0
- package/dist/api/routes/application.js +39 -13
- package/dist/api/routes/index.js +61 -56
- package/dist/api/routes/public/index.js +6 -9
- package/dist/api/routes/public/queries.js +1 -1
- package/dist/api/routes/public/rows.js +1 -1
- package/dist/api/routes/public/tables.js +3 -3
- package/dist/api/routes/public/users.js +1 -1
- package/dist/api/routes/row.js +43 -17
- package/dist/api/routes/static.js +40 -13
- package/dist/api/routes/tests/utilities/TestFunctions.js +75 -33
- package/dist/app.js +8 -4
- package/dist/automations/actions.js +3 -0
- package/dist/automations/automationUtils.js +10 -0
- package/dist/automations/steps/createRow.js +12 -12
- package/dist/automations/steps/deleteRow.js +13 -16
- package/dist/automations/steps/loop.js +51 -0
- package/dist/automations/tests/utilities/index.js +13 -11
- package/dist/automations/utils.js +187 -133
- package/dist/constants/index.js +5 -0
- package/dist/definitions/datasource.js +1 -0
- package/dist/environment.js +2 -3
- package/dist/index.js +4 -0
- package/dist/integrations/base/sql.js +2 -2
- package/dist/integrations/base/sqlTable.js +2 -2
- package/dist/integrations/googlesheets.js +1 -1
- package/dist/integrations/index.js +4 -0
- package/dist/integrations/microsoftSqlServer.js +8 -8
- package/dist/integrations/mysql.js +9 -9
- package/dist/integrations/oracle.js +7 -7
- package/dist/integrations/postgres.js +7 -7
- package/dist/integrations/queries/sql.js +2 -2
- package/dist/integrations/redis.js +158 -0
- package/dist/integrations/rest.js +1 -1
- package/dist/middleware/authorized.js +51 -51
- package/dist/middleware/currentapp.js +15 -1
- package/dist/migrations/functions/appUrls.js +1 -1
- package/dist/migrations/functions/developerQuota.js +49 -0
- package/dist/migrations/functions/publishedAppsQuota.js +47 -0
- package/dist/migrations/functions/quotas1.js +6 -2
- package/dist/migrations/functions/usageQuotas/index.js +0 -4
- package/dist/migrations/functions/usageQuotas/syncApps.js +4 -7
- package/dist/migrations/functions/usageQuotas/syncDevelopers.js +24 -0
- package/dist/migrations/functions/usageQuotas/syncPublishedApps.js +26 -0
- package/dist/migrations/functions/usageQuotas/syncRows.js +5 -8
- package/dist/migrations/index.js +17 -1
- package/dist/package.json +14 -8
- package/dist/threads/automation.js +149 -27
- package/dist/threads/index.js +36 -10
- package/dist/threads/utils.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utilities/queue/inMemoryQueue.js +6 -1
- package/nodemon.json +1 -1
- package/package.json +15 -9
- package/scripts/dev/manage.js +2 -0
- package/src/api/controllers/{application.js → application.ts} +118 -51
- package/src/api/controllers/deploy/{index.js → index.ts} +53 -29
- package/src/api/controllers/public/applications.ts +2 -2
- package/src/api/controllers/public/queries.ts +1 -1
- package/src/api/controllers/public/rows.ts +1 -1
- package/src/api/controllers/query/{index.js → index.ts} +51 -48
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/{index.js → index.ts} +24 -17
- package/src/api/controllers/row/internal.js +2 -1
- package/src/api/controllers/row/utils.js +4 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +3 -0
- package/src/api/controllers/table/bulkFormula.js +1 -1
- package/src/api/controllers/table/{internal.js → internal.ts} +30 -26
- package/src/api/controllers/table/{utils.js → utils.ts} +86 -69
- package/src/api/index.js +5 -0
- package/src/api/routes/{application.js → application.ts} +8 -14
- package/src/api/routes/index.ts +60 -0
- package/src/api/routes/public/index.ts +1 -4
- package/src/api/routes/{row.js → row.ts} +7 -15
- package/src/api/routes/{static.js → static.ts} +11 -11
- package/src/api/routes/tests/misc.spec.js +39 -37
- package/src/api/routes/tests/utilities/{TestFunctions.js → TestFunctions.ts} +57 -33
- package/src/app.ts +1 -2
- package/src/automations/actions.js +3 -0
- package/src/automations/automationUtils.js +12 -0
- package/src/automations/steps/{createRow.js → createRow.ts} +9 -15
- package/src/automations/steps/{deleteRow.js → deleteRow.ts} +10 -16
- package/src/automations/steps/loop.js +50 -0
- package/src/automations/tests/automation.spec.js +0 -1
- package/src/automations/tests/{createRow.spec.js → createRow.spec.ts} +4 -15
- package/src/automations/tests/{deleteRow.spec.js → deleteRow.spec.ts} +3 -5
- package/src/automations/tests/utilities/index.js +12 -10
- package/src/automations/{utils.js → utils.ts} +39 -28
- package/src/constants/index.js +6 -0
- package/src/definitions/common.ts +1 -0
- package/src/definitions/datasource.ts +1 -0
- package/src/environment.js +2 -3
- package/src/index.ts +3 -0
- package/src/integrations/index.ts +4 -0
- package/src/integrations/redis.ts +152 -0
- package/src/integrations/tests/redis.spec.js +60 -0
- package/src/middleware/{authorized.js → authorized.ts} +20 -14
- package/src/middleware/currentapp.js +16 -1
- package/src/middleware/tests/currentapp.spec.js +8 -4
- package/src/migrations/functions/developerQuota.ts +15 -0
- package/src/migrations/functions/publishedAppsQuota.ts +13 -0
- package/src/migrations/functions/tests/quotas1.spec.js +0 -2
- package/src/migrations/functions/usageQuotas/index.ts +0 -5
- package/src/migrations/functions/usageQuotas/syncApps.ts +3 -6
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +19 -0
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +21 -0
- package/src/migrations/functions/usageQuotas/syncRows.ts +3 -6
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.ts +34 -0
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +40 -0
- package/src/migrations/index.ts +13 -1
- package/src/threads/automation.js +196 -34
- package/src/threads/{index.js → index.ts} +18 -14
- package/src/threads/utils.js +1 -0
- package/src/utilities/queue/inMemoryQueue.js +7 -1
- package/tsconfig.build.json +10 -0
- package/tsconfig.json +2 -2
- package/builder/assets/index.68a7f4e3.css +0 -6
- package/builder/assets/index.8d4a5b33.js +0 -1291
- package/coverage/lcov-report/api/controllers/application.js.html +0 -1436
- package/coverage/lcov-report/api/controllers/query/index.js.html +0 -713
- package/coverage/lcov-report/api/controllers/row/index.js.html +0 -524
- package/coverage/lcov-report/api/controllers/table/internal.js.html +0 -620
- package/coverage/lcov-report/api/controllers/table/utils.js.html +0 -1331
- package/coverage/lcov-report/api/routes/application.js.html +0 -179
- package/coverage/lcov-report/api/routes/index.js.html +0 -266
- package/coverage/lcov-report/api/routes/row.js.html +0 -908
- package/coverage/lcov-report/automations/steps/createRow.js.html +0 -380
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +0 -347
- package/coverage/lcov-report/automations/utils.js.html +0 -665
- package/coverage/lcov-report/middleware/authorized.js.html +0 -458
- package/coverage/lcov-report/middleware/usageQuota.js.html +0 -572
- package/coverage/lcov-report/threads/index.js.html +0 -296
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -359
- package/dist/middleware/usageQuota.js +0 -154
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/utilities/usageQuota/index.js +0 -86
- package/src/api/routes/index.js +0 -62
- package/src/middleware/tests/usageQuota.spec.js +0 -120
- package/src/middleware/usageQuota.js +0 -164
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +0 -41
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +0 -45
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
- package/src/utilities/usageQuota/index.js +0 -93
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { transform } from "../../../utilities/csvParser"
|
|
2
|
+
import {
|
|
3
3
|
getRowParams,
|
|
4
4
|
generateRowID,
|
|
5
5
|
InternalTables,
|
|
6
6
|
getTableParams,
|
|
7
7
|
BudibaseInternalDB,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
} from "../../../db/utils"
|
|
9
|
+
import { isEqual } from "lodash"
|
|
10
|
+
import { AutoFieldSubTypes, FieldTypes } from "../../../constants"
|
|
11
|
+
import {
|
|
12
12
|
inputProcessing,
|
|
13
13
|
cleanupAttachments,
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
} from "../../../utilities/rowProcessor"
|
|
15
|
+
import {
|
|
16
16
|
USERS_TABLE_SCHEMA,
|
|
17
17
|
SwitchableTypes,
|
|
18
18
|
CanSwitchTypes,
|
|
19
|
-
}
|
|
20
|
-
|
|
19
|
+
} from "../../../constants"
|
|
20
|
+
import {
|
|
21
21
|
isExternalTable,
|
|
22
22
|
breakExternalTableId,
|
|
23
23
|
isSQL,
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const usageQuota = require("../../../utilities/usageQuota")
|
|
24
|
+
} from "../../../integrations/utils"
|
|
25
|
+
import { getViews, saveView } from "../view/utils"
|
|
26
|
+
import viewTemplate from "../view/viewBuilder"
|
|
28
27
|
const { getAppDB } = require("@budibase/backend-core/context")
|
|
29
|
-
|
|
28
|
+
import { cloneDeep } from "lodash/fp"
|
|
29
|
+
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
export async function clearColumns(table: any, columnNames: any) {
|
|
32
32
|
const db = getAppDB()
|
|
33
33
|
const rows = await db.allDocs(
|
|
34
34
|
getRowParams(table._id, null, {
|
|
@@ -36,18 +36,18 @@ exports.clearColumns = async (table, columnNames) => {
|
|
|
36
36
|
})
|
|
37
37
|
)
|
|
38
38
|
return db.bulkDocs(
|
|
39
|
-
rows.rows.map(({ doc }) => {
|
|
40
|
-
columnNames.forEach(colName => delete doc[colName])
|
|
39
|
+
rows.rows.map(({ doc }: any) => {
|
|
40
|
+
columnNames.forEach((colName: any) => delete doc[colName])
|
|
41
41
|
return doc
|
|
42
42
|
})
|
|
43
43
|
)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
export async function checkForColumnUpdates(oldTable: any, updatedTable: any) {
|
|
47
47
|
const db = getAppDB()
|
|
48
48
|
let updatedRows = []
|
|
49
49
|
const rename = updatedTable._rename
|
|
50
|
-
let deletedColumns = []
|
|
50
|
+
let deletedColumns: any = []
|
|
51
51
|
if (oldTable && oldTable.schema && updatedTable.schema) {
|
|
52
52
|
deletedColumns = Object.keys(oldTable.schema).filter(
|
|
53
53
|
colName => updatedTable.schema[colName] == null
|
|
@@ -61,14 +61,14 @@ exports.checkForColumnUpdates = async (oldTable, updatedTable) => {
|
|
|
61
61
|
include_docs: true,
|
|
62
62
|
})
|
|
63
63
|
)
|
|
64
|
-
const rawRows = rows.rows.map(({ doc }) => doc)
|
|
65
|
-
updatedRows = rawRows.map(row => {
|
|
64
|
+
const rawRows = rows.rows.map(({ doc }: any) => doc)
|
|
65
|
+
updatedRows = rawRows.map((row: any) => {
|
|
66
66
|
row = cloneDeep(row)
|
|
67
67
|
if (rename) {
|
|
68
68
|
row[rename.updated] = row[rename.old]
|
|
69
69
|
delete row[rename.old]
|
|
70
70
|
} else if (deletedColumns.length !== 0) {
|
|
71
|
-
deletedColumns.forEach(colName => delete row[colName])
|
|
71
|
+
deletedColumns.forEach((colName: any) => delete row[colName])
|
|
72
72
|
}
|
|
73
73
|
return row
|
|
74
74
|
})
|
|
@@ -76,14 +76,14 @@ exports.checkForColumnUpdates = async (oldTable, updatedTable) => {
|
|
|
76
76
|
// cleanup any attachments from object storage for deleted attachment columns
|
|
77
77
|
await cleanupAttachments(updatedTable, { oldTable, rows: rawRows })
|
|
78
78
|
// Update views
|
|
79
|
-
await
|
|
79
|
+
await checkForViewUpdates(updatedTable, rename, deletedColumns)
|
|
80
80
|
delete updatedTable._rename
|
|
81
81
|
}
|
|
82
82
|
return { rows: updatedRows, table: updatedTable }
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// makes sure the passed in table isn't going to reset the auto ID
|
|
86
|
-
|
|
86
|
+
export function makeSureTableUpToDate(table: any, tableToSave: any) {
|
|
87
87
|
if (!table) {
|
|
88
88
|
return tableToSave
|
|
89
89
|
}
|
|
@@ -91,7 +91,9 @@ exports.makeSureTableUpToDate = (table, tableToSave) => {
|
|
|
91
91
|
tableToSave._rev = table._rev
|
|
92
92
|
// make sure auto IDs are always updated - these are internal
|
|
93
93
|
// so the client may not know they have changed
|
|
94
|
-
|
|
94
|
+
let field: any
|
|
95
|
+
let column: any
|
|
96
|
+
for ([field, column] of Object.entries(table.schema)) {
|
|
95
97
|
if (
|
|
96
98
|
column.autocolumn &&
|
|
97
99
|
column.subtype === AutoFieldSubTypes.AUTO_ID &&
|
|
@@ -103,30 +105,32 @@ exports.makeSureTableUpToDate = (table, tableToSave) => {
|
|
|
103
105
|
return tableToSave
|
|
104
106
|
}
|
|
105
107
|
|
|
106
|
-
|
|
108
|
+
export async function handleDataImport(user: any, table: any, dataImport: any) {
|
|
107
109
|
if (!dataImport || !dataImport.csvString) {
|
|
108
110
|
return table
|
|
109
111
|
}
|
|
110
112
|
|
|
111
113
|
const db = getAppDB()
|
|
112
114
|
// Populate the table with rows imported from CSV in a bulk update
|
|
113
|
-
const data = await
|
|
115
|
+
const data = await transform({
|
|
114
116
|
...dataImport,
|
|
115
117
|
existingTable: table,
|
|
116
118
|
})
|
|
117
119
|
|
|
118
|
-
let finalData = []
|
|
120
|
+
let finalData: any = []
|
|
119
121
|
for (let i = 0; i < data.length; i++) {
|
|
120
122
|
let row = data[i]
|
|
121
123
|
row._id = generateRowID(table._id)
|
|
122
124
|
row.tableId = table._id
|
|
123
|
-
const processed = inputProcessing(user, table, row, {
|
|
125
|
+
const processed: any = inputProcessing(user, table, row, {
|
|
124
126
|
noAutoRelationships: true,
|
|
125
127
|
})
|
|
126
128
|
table = processed.table
|
|
127
129
|
row = processed.row
|
|
128
130
|
|
|
129
|
-
|
|
131
|
+
let fieldName: any
|
|
132
|
+
let schema: any
|
|
133
|
+
for ([fieldName, schema] of Object.entries(table.schema)) {
|
|
130
134
|
// check whether the options need to be updated for inclusion as part of the data import
|
|
131
135
|
if (
|
|
132
136
|
schema.type === FieldTypes.OPTIONS &&
|
|
@@ -143,17 +147,13 @@ exports.handleDataImport = async (user, table, dataImport) => {
|
|
|
143
147
|
finalData.push(row)
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
await
|
|
147
|
-
dryRun: true,
|
|
148
|
-
})
|
|
149
|
-
await db.bulkDocs(finalData)
|
|
150
|
-
await usageQuota.update(usageQuota.Properties.ROW, finalData.length)
|
|
150
|
+
await quotas.addRows(finalData.length, () => db.bulkDocs(finalData))
|
|
151
151
|
let response = await db.put(table)
|
|
152
152
|
table._rev = response._rev
|
|
153
153
|
return table
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
export async function handleSearchIndexes(table: any) {
|
|
157
157
|
const db = getAppDB()
|
|
158
158
|
// create relevant search indexes
|
|
159
159
|
if (table.indexes && table.indexes.length > 0) {
|
|
@@ -161,12 +161,12 @@ exports.handleSearchIndexes = async table => {
|
|
|
161
161
|
const indexName = `search:${table._id}`
|
|
162
162
|
|
|
163
163
|
const existingIndex = currentIndexes.indexes.find(
|
|
164
|
-
existing => existing.name === indexName
|
|
164
|
+
(existing: any) => existing.name === indexName
|
|
165
165
|
)
|
|
166
166
|
|
|
167
167
|
if (existingIndex) {
|
|
168
168
|
const currentFields = existingIndex.def.fields.map(
|
|
169
|
-
field => Object.keys(field)[0]
|
|
169
|
+
(field: any) => Object.keys(field)[0]
|
|
170
170
|
)
|
|
171
171
|
|
|
172
172
|
// if index fields have changed, delete the original index
|
|
@@ -197,7 +197,7 @@ exports.handleSearchIndexes = async table => {
|
|
|
197
197
|
return table
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
export function checkStaticTables(table: any) {
|
|
201
201
|
// check user schema has all required elements
|
|
202
202
|
if (table._id === InternalTables.USER_METADATA) {
|
|
203
203
|
for (let [key, schema] of Object.entries(USERS_TABLE_SCHEMA.schema)) {
|
|
@@ -211,7 +211,13 @@ exports.checkStaticTables = table => {
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
class TableSaveFunctions {
|
|
214
|
-
|
|
214
|
+
db: any
|
|
215
|
+
user: any
|
|
216
|
+
oldTable: any
|
|
217
|
+
dataImport: any
|
|
218
|
+
rows: any
|
|
219
|
+
|
|
220
|
+
constructor({ user, oldTable, dataImport }: any) {
|
|
215
221
|
this.db = getAppDB()
|
|
216
222
|
this.user = user
|
|
217
223
|
this.oldTable = oldTable
|
|
@@ -221,25 +227,25 @@ class TableSaveFunctions {
|
|
|
221
227
|
}
|
|
222
228
|
|
|
223
229
|
// before anything is done
|
|
224
|
-
async before(table) {
|
|
230
|
+
async before(table: any) {
|
|
225
231
|
if (this.oldTable) {
|
|
226
|
-
table =
|
|
232
|
+
table = makeSureTableUpToDate(this.oldTable, table)
|
|
227
233
|
}
|
|
228
|
-
table =
|
|
234
|
+
table = checkStaticTables(table)
|
|
229
235
|
return table
|
|
230
236
|
}
|
|
231
237
|
|
|
232
238
|
// when confirmed valid
|
|
233
|
-
async mid(table) {
|
|
234
|
-
let response = await
|
|
239
|
+
async mid(table: any) {
|
|
240
|
+
let response = await checkForColumnUpdates(this.oldTable, table)
|
|
235
241
|
this.rows = this.rows.concat(response.rows)
|
|
236
242
|
return table
|
|
237
243
|
}
|
|
238
244
|
|
|
239
245
|
// after saving
|
|
240
|
-
async after(table) {
|
|
241
|
-
table = await
|
|
242
|
-
table = await
|
|
246
|
+
async after(table: any) {
|
|
247
|
+
table = await handleSearchIndexes(table)
|
|
248
|
+
table = await handleDataImport(this.user, table, this.dataImport)
|
|
243
249
|
return table
|
|
244
250
|
}
|
|
245
251
|
|
|
@@ -248,21 +254,21 @@ class TableSaveFunctions {
|
|
|
248
254
|
}
|
|
249
255
|
}
|
|
250
256
|
|
|
251
|
-
|
|
257
|
+
export async function getAllInternalTables() {
|
|
252
258
|
const db = getAppDB()
|
|
253
259
|
const internalTables = await db.allDocs(
|
|
254
260
|
getTableParams(null, {
|
|
255
261
|
include_docs: true,
|
|
256
262
|
})
|
|
257
263
|
)
|
|
258
|
-
return internalTables.rows.map(tableDoc => ({
|
|
264
|
+
return internalTables.rows.map((tableDoc: any) => ({
|
|
259
265
|
...tableDoc.doc,
|
|
260
266
|
type: "internal",
|
|
261
267
|
sourceId: BudibaseInternalDB._id,
|
|
262
268
|
}))
|
|
263
269
|
}
|
|
264
270
|
|
|
265
|
-
|
|
271
|
+
export async function getAllExternalTables(datasourceId: any) {
|
|
266
272
|
const db = getAppDB()
|
|
267
273
|
const datasource = await db.get(datasourceId)
|
|
268
274
|
if (!datasource || !datasource.entities) {
|
|
@@ -271,24 +277,28 @@ exports.getAllExternalTables = async datasourceId => {
|
|
|
271
277
|
return datasource.entities
|
|
272
278
|
}
|
|
273
279
|
|
|
274
|
-
|
|
275
|
-
const entities = await
|
|
280
|
+
export async function getExternalTable(datasourceId: any, tableName: any) {
|
|
281
|
+
const entities = await getAllExternalTables(datasourceId)
|
|
276
282
|
return entities[tableName]
|
|
277
283
|
}
|
|
278
284
|
|
|
279
|
-
|
|
285
|
+
export async function getTable(tableId: any) {
|
|
280
286
|
const db = getAppDB()
|
|
281
287
|
if (isExternalTable(tableId)) {
|
|
282
288
|
let { datasourceId, tableName } = breakExternalTableId(tableId)
|
|
283
289
|
const datasource = await db.get(datasourceId)
|
|
284
|
-
const table = await
|
|
290
|
+
const table = await getExternalTable(datasourceId, tableName)
|
|
285
291
|
return { ...table, sql: isSQL(datasource) }
|
|
286
292
|
} else {
|
|
287
293
|
return db.get(tableId)
|
|
288
294
|
}
|
|
289
295
|
}
|
|
290
296
|
|
|
291
|
-
|
|
297
|
+
export async function checkForViewUpdates(
|
|
298
|
+
table: any,
|
|
299
|
+
rename: any,
|
|
300
|
+
deletedColumns: any
|
|
301
|
+
) {
|
|
292
302
|
const views = await getViews()
|
|
293
303
|
const tableViews = views.filter(view => view.meta.tableId === table._id)
|
|
294
304
|
|
|
@@ -312,7 +322,7 @@ exports.checkForViewUpdates = async (table, rename, deletedColumns) => {
|
|
|
312
322
|
|
|
313
323
|
// Update filters if required
|
|
314
324
|
if (view.meta.filters) {
|
|
315
|
-
view.meta.filters.forEach(filter => {
|
|
325
|
+
view.meta.filters.forEach((filter: any) => {
|
|
316
326
|
if (filter.key === rename.old) {
|
|
317
327
|
filter.key = rename.updated
|
|
318
328
|
needsUpdated = true
|
|
@@ -320,7 +330,7 @@ exports.checkForViewUpdates = async (table, rename, deletedColumns) => {
|
|
|
320
330
|
})
|
|
321
331
|
}
|
|
322
332
|
} else if (deletedColumns) {
|
|
323
|
-
deletedColumns.forEach(column => {
|
|
333
|
+
deletedColumns.forEach((column: any) => {
|
|
324
334
|
// Remove calculation statement if required
|
|
325
335
|
if (view.meta.field === column) {
|
|
326
336
|
delete view.meta.field
|
|
@@ -338,7 +348,7 @@ exports.checkForViewUpdates = async (table, rename, deletedColumns) => {
|
|
|
338
348
|
// Remove filters referencing deleted field if required
|
|
339
349
|
if (view.meta.filters && view.meta.filters.length) {
|
|
340
350
|
const initialLength = view.meta.filters.length
|
|
341
|
-
view.meta.filters = view.meta.filters.filter(filter => {
|
|
351
|
+
view.meta.filters = view.meta.filters.filter((filter: any) => {
|
|
342
352
|
return filter.key !== column
|
|
343
353
|
})
|
|
344
354
|
if (initialLength !== view.meta.filters.length) {
|
|
@@ -360,16 +370,20 @@ exports.checkForViewUpdates = async (table, rename, deletedColumns) => {
|
|
|
360
370
|
}
|
|
361
371
|
}
|
|
362
372
|
|
|
363
|
-
|
|
373
|
+
export function generateForeignKey(column: any, relatedTable: any) {
|
|
364
374
|
return `fk_${relatedTable.name}_${column.fieldName}`
|
|
365
375
|
}
|
|
366
376
|
|
|
367
|
-
|
|
377
|
+
export function generateJunctionTableName(
|
|
378
|
+
column: any,
|
|
379
|
+
table: any,
|
|
380
|
+
relatedTable: any
|
|
381
|
+
) {
|
|
368
382
|
return `jt_${table.name}_${relatedTable.name}_${column.name}_${column.fieldName}`
|
|
369
383
|
}
|
|
370
384
|
|
|
371
|
-
|
|
372
|
-
const structure = {
|
|
385
|
+
export function foreignKeyStructure(keyName: any, meta = null) {
|
|
386
|
+
const structure: any = {
|
|
373
387
|
type: FieldTypes.NUMBER,
|
|
374
388
|
constraints: {},
|
|
375
389
|
name: keyName,
|
|
@@ -380,7 +394,7 @@ exports.foreignKeyStructure = (keyName, meta = null) => {
|
|
|
380
394
|
return structure
|
|
381
395
|
}
|
|
382
396
|
|
|
383
|
-
|
|
397
|
+
export function areSwitchableTypes(type1: any, type2: any) {
|
|
384
398
|
if (
|
|
385
399
|
SwitchableTypes.indexOf(type1) === -1 &&
|
|
386
400
|
SwitchableTypes.indexOf(type2) === -1
|
|
@@ -397,21 +411,24 @@ exports.areSwitchableTypes = (type1, type2) => {
|
|
|
397
411
|
return false
|
|
398
412
|
}
|
|
399
413
|
|
|
400
|
-
|
|
414
|
+
export function hasTypeChanged(table: any, oldTable: any) {
|
|
401
415
|
if (!oldTable) {
|
|
402
416
|
return false
|
|
403
417
|
}
|
|
404
|
-
|
|
418
|
+
let key: any
|
|
419
|
+
let field: any
|
|
420
|
+
for ([key, field] of Object.entries(oldTable.schema)) {
|
|
405
421
|
const oldType = field.type
|
|
406
422
|
if (!table.schema[key]) {
|
|
407
423
|
continue
|
|
408
424
|
}
|
|
409
425
|
const newType = table.schema[key].type
|
|
410
|
-
if (oldType !== newType && !
|
|
426
|
+
if (oldType !== newType && !areSwitchableTypes(oldType, newType)) {
|
|
411
427
|
return true
|
|
412
428
|
}
|
|
413
429
|
}
|
|
414
430
|
return false
|
|
415
431
|
}
|
|
416
432
|
|
|
417
|
-
|
|
433
|
+
const _TableSaveFunctions = TableSaveFunctions
|
|
434
|
+
export { _TableSaveFunctions as TableSaveFunctions }
|
package/src/api/index.js
CHANGED
|
@@ -4,12 +4,14 @@ const {
|
|
|
4
4
|
auditLog,
|
|
5
5
|
buildTenancyMiddleware,
|
|
6
6
|
} = require("@budibase/backend-core/auth")
|
|
7
|
+
const { errors } = require("@budibase/backend-core")
|
|
7
8
|
const currentApp = require("../middleware/currentapp")
|
|
8
9
|
const compress = require("koa-compress")
|
|
9
10
|
const zlib = require("zlib")
|
|
10
11
|
const { mainRoutes, staticRoutes, publicRoutes } = require("./routes")
|
|
11
12
|
const pkg = require("../../package.json")
|
|
12
13
|
const env = require("../environment")
|
|
14
|
+
const { middleware: pro } = require("@budibase/pro")
|
|
13
15
|
|
|
14
16
|
const router = new Router()
|
|
15
17
|
|
|
@@ -52,6 +54,7 @@ router
|
|
|
52
54
|
})
|
|
53
55
|
)
|
|
54
56
|
.use(currentApp)
|
|
57
|
+
.use(pro.licensing())
|
|
55
58
|
.use(auditLog)
|
|
56
59
|
|
|
57
60
|
// error handling middleware
|
|
@@ -60,10 +63,12 @@ router.use(async (ctx, next) => {
|
|
|
60
63
|
await next()
|
|
61
64
|
} catch (err) {
|
|
62
65
|
ctx.status = err.status || err.statusCode || 500
|
|
66
|
+
const error = errors.getPublicError(err)
|
|
63
67
|
ctx.body = {
|
|
64
68
|
message: err.message,
|
|
65
69
|
status: ctx.status,
|
|
66
70
|
validationErrors: err.validation,
|
|
71
|
+
error,
|
|
67
72
|
}
|
|
68
73
|
if (env.NODE_ENV !== "jest") {
|
|
69
74
|
ctx.log.error(err)
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const usage = require("../../middleware/usageQuota")
|
|
1
|
+
import Router from "@koa/router"
|
|
2
|
+
import * as controller from "../controllers/application"
|
|
3
|
+
import authorized from "../../middleware/authorized"
|
|
4
|
+
import { BUILDER } from "@budibase/backend-core/permissions"
|
|
6
5
|
|
|
7
|
-
const router = Router()
|
|
6
|
+
const router = new Router()
|
|
8
7
|
|
|
9
8
|
router
|
|
10
9
|
.post("/api/applications/:appId/sync", authorized(BUILDER), controller.sync)
|
|
11
|
-
.post("/api/applications", authorized(BUILDER),
|
|
10
|
+
.post("/api/applications", authorized(BUILDER), controller.create)
|
|
12
11
|
.get("/api/applications/:appId/definition", controller.fetchAppDefinition)
|
|
13
12
|
.get("/api/applications", controller.fetch)
|
|
14
13
|
.get("/api/applications/:appId/appPackage", controller.fetchAppPackage)
|
|
@@ -23,11 +22,6 @@ router
|
|
|
23
22
|
authorized(BUILDER),
|
|
24
23
|
controller.revertClient
|
|
25
24
|
)
|
|
26
|
-
.delete(
|
|
27
|
-
"/api/applications/:appId",
|
|
28
|
-
authorized(BUILDER),
|
|
29
|
-
usage,
|
|
30
|
-
controller.delete
|
|
31
|
-
)
|
|
25
|
+
.delete("/api/applications/:appId", authorized(BUILDER), controller.destroy)
|
|
32
26
|
|
|
33
|
-
|
|
27
|
+
export default router
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import authRoutes from "./auth"
|
|
2
|
+
import layoutRoutes from "./layout"
|
|
3
|
+
import screenRoutes from "./screen"
|
|
4
|
+
import userRoutes from "./user"
|
|
5
|
+
import applicationRoutes from "./application"
|
|
6
|
+
import tableRoutes from "./table"
|
|
7
|
+
import rowRoutes from "./row"
|
|
8
|
+
import viewRoutes from "./view"
|
|
9
|
+
import componentRoutes from "./component"
|
|
10
|
+
import automationRoutes from "./automation"
|
|
11
|
+
import webhookRoutes from "./webhook"
|
|
12
|
+
import roleRoutes from "./role"
|
|
13
|
+
import deployRoutes from "./deploy"
|
|
14
|
+
import apiKeysRoutes from "./apikeys"
|
|
15
|
+
import templatesRoutes from "./templates"
|
|
16
|
+
import analyticsRoutes from "./analytics"
|
|
17
|
+
import routingRoutes from "./routing"
|
|
18
|
+
import integrationRoutes from "./integration"
|
|
19
|
+
import permissionRoutes from "./permission"
|
|
20
|
+
import datasourceRoutes from "./datasource"
|
|
21
|
+
import queryRoutes from "./query"
|
|
22
|
+
import backupRoutes from "./backup"
|
|
23
|
+
import metadataRoutes from "./metadata"
|
|
24
|
+
import devRoutes from "./dev"
|
|
25
|
+
import cloudRoutes from "./cloud"
|
|
26
|
+
import migrationRoutes from "./migrations"
|
|
27
|
+
|
|
28
|
+
export { default as staticRoutes } from "./static"
|
|
29
|
+
export { default as publicRoutes } from "./public"
|
|
30
|
+
|
|
31
|
+
export const mainRoutes = [
|
|
32
|
+
authRoutes,
|
|
33
|
+
deployRoutes,
|
|
34
|
+
layoutRoutes,
|
|
35
|
+
screenRoutes,
|
|
36
|
+
userRoutes,
|
|
37
|
+
applicationRoutes,
|
|
38
|
+
automationRoutes,
|
|
39
|
+
viewRoutes,
|
|
40
|
+
componentRoutes,
|
|
41
|
+
roleRoutes,
|
|
42
|
+
apiKeysRoutes,
|
|
43
|
+
templatesRoutes,
|
|
44
|
+
analyticsRoutes,
|
|
45
|
+
webhookRoutes,
|
|
46
|
+
routingRoutes,
|
|
47
|
+
integrationRoutes,
|
|
48
|
+
permissionRoutes,
|
|
49
|
+
datasourceRoutes,
|
|
50
|
+
queryRoutes,
|
|
51
|
+
backupRoutes,
|
|
52
|
+
metadataRoutes,
|
|
53
|
+
devRoutes,
|
|
54
|
+
cloudRoutes,
|
|
55
|
+
// these need to be handled last as they still use /api/:tableId
|
|
56
|
+
// this could be breaking as koa may recognise other routes as this
|
|
57
|
+
tableRoutes,
|
|
58
|
+
rowRoutes,
|
|
59
|
+
migrationRoutes,
|
|
60
|
+
]
|
|
@@ -3,7 +3,6 @@ import queryEndpoints from "./queries"
|
|
|
3
3
|
import tableEndpoints from "./tables"
|
|
4
4
|
import rowEndpoints from "./rows"
|
|
5
5
|
import userEndpoints from "./users"
|
|
6
|
-
import usage from "../../../middleware/usageQuota"
|
|
7
6
|
import authorized from "../../../middleware/authorized"
|
|
8
7
|
import publicApi from "../../../middleware/publicApi"
|
|
9
8
|
import { paramResource, paramSubResource } from "../../../middleware/resourceId"
|
|
@@ -114,8 +113,6 @@ function applyRoutes(
|
|
|
114
113
|
// add the authorization middleware, using the correct perm type
|
|
115
114
|
addMiddleware(endpoints.read, authorized(permType, PermissionLevels.READ))
|
|
116
115
|
addMiddleware(endpoints.write, authorized(permType, PermissionLevels.WRITE))
|
|
117
|
-
// add the usage quota middleware
|
|
118
|
-
addMiddleware(endpoints.write, usage)
|
|
119
116
|
// add the output mapper middleware
|
|
120
117
|
addMiddleware(endpoints.read, mapperMiddleware, { output: true })
|
|
121
118
|
addMiddleware(endpoints.write, mapperMiddleware, { output: true })
|
|
@@ -130,4 +127,4 @@ applyRoutes(queryEndpoints, PermissionTypes.QUERY, "queryId")
|
|
|
130
127
|
// needs to be applied last for routing purposes, don't override other endpoints
|
|
131
128
|
applyRoutes(rowEndpoints, PermissionTypes.TABLE, "tableId", "rowId")
|
|
132
129
|
|
|
133
|
-
|
|
130
|
+
export default publicRouter
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
paramResource,
|
|
7
|
-
paramSubResource,
|
|
8
|
-
} = require("../../middleware/resourceId")
|
|
1
|
+
import Router from "@koa/router"
|
|
2
|
+
import * as rowController from "../controllers/row"
|
|
3
|
+
import authorized from "../../middleware/authorized"
|
|
4
|
+
import { paramResource, paramSubResource } from "../../middleware/resourceId"
|
|
9
5
|
const {
|
|
10
6
|
PermissionLevels,
|
|
11
7
|
PermissionTypes,
|
|
12
8
|
} = require("@budibase/backend-core/permissions")
|
|
13
9
|
const { internalSearchValidator } = require("./utils/validators")
|
|
14
10
|
|
|
15
|
-
const router = Router()
|
|
11
|
+
const router = new Router()
|
|
16
12
|
|
|
17
13
|
router
|
|
18
14
|
/**
|
|
@@ -180,7 +176,6 @@ router
|
|
|
180
176
|
"/api/:tableId/rows",
|
|
181
177
|
paramResource("tableId"),
|
|
182
178
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
|
183
|
-
usage,
|
|
184
179
|
rowController.save
|
|
185
180
|
)
|
|
186
181
|
/**
|
|
@@ -195,7 +190,6 @@ router
|
|
|
195
190
|
"/api/:tableId/rows",
|
|
196
191
|
paramResource("tableId"),
|
|
197
192
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
|
198
|
-
usage,
|
|
199
193
|
rowController.patch
|
|
200
194
|
)
|
|
201
195
|
/**
|
|
@@ -248,7 +242,6 @@ router
|
|
|
248
242
|
"/api/:tableId/rows",
|
|
249
243
|
paramResource("tableId"),
|
|
250
244
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
|
251
|
-
usage,
|
|
252
245
|
rowController.destroy
|
|
253
246
|
)
|
|
254
247
|
|
|
@@ -269,8 +262,7 @@ router
|
|
|
269
262
|
"/api/:tableId/rows/exportRows",
|
|
270
263
|
paramResource("tableId"),
|
|
271
264
|
authorized(PermissionTypes.TABLE, PermissionLevels.WRITE),
|
|
272
|
-
|
|
273
|
-
rowController.export
|
|
265
|
+
rowController.exportRows
|
|
274
266
|
)
|
|
275
267
|
|
|
276
|
-
|
|
268
|
+
export default router
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import Router from "@koa/router"
|
|
2
|
+
import * as controller from "../controllers/static"
|
|
3
|
+
import { budibaseTempDir } from "../../utilities/budibaseDir"
|
|
4
|
+
import authorized from "../../middleware/authorized"
|
|
5
|
+
import {
|
|
6
6
|
BUILDER,
|
|
7
7
|
PermissionTypes,
|
|
8
8
|
PermissionLevels,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
} from "@budibase/backend-core/permissions"
|
|
10
|
+
import * as env from "../../environment"
|
|
11
|
+
import { paramResource } from "../../middleware/resourceId"
|
|
12
12
|
|
|
13
|
-
const router = Router()
|
|
13
|
+
const router = new Router()
|
|
14
14
|
|
|
15
15
|
/* istanbul ignore next */
|
|
16
|
-
router.param("file", async (file, ctx, next) => {
|
|
16
|
+
router.param("file", async (file: any, ctx: any, next: any) => {
|
|
17
17
|
ctx.file = file && file.includes(".") ? file : "index.html"
|
|
18
18
|
if (!ctx.file.startsWith("budibase-client")) {
|
|
19
19
|
return next()
|
|
@@ -52,4 +52,4 @@ router
|
|
|
52
52
|
controller.getSignedUploadURL
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
export default router
|