@budibase/server 1.0.123-alpha.0 → 1.0.123
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.68a7f4e3.css +6 -0
- package/builder/assets/index.8d4a5b33.js +1291 -0
- package/builder/assets/{vendor.5240f480.js → vendor.8e34a169.js} +1 -1
- package/builder/index.html +3 -3
- package/coverage/clover.xml +1763 -758
- package/coverage/coverage-final.json +43 -28
- package/coverage/lcov-report/api/controllers/analytics.js.html +3 -8
- package/coverage/lcov-report/api/controllers/apikeys.js.html +4 -9
- package/coverage/lcov-report/api/controllers/application.js.html +1436 -0
- package/coverage/lcov-report/api/controllers/auth.js.html +3 -8
- package/coverage/lcov-report/api/controllers/automation.js.html +3 -8
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -8
- package/coverage/lcov-report/api/controllers/cloud.js.html +3 -8
- package/coverage/lcov-report/api/controllers/component.js.html +3 -8
- package/coverage/lcov-report/api/controllers/datasource.js.html +6 -11
- package/coverage/lcov-report/api/controllers/dev.js.html +3 -8
- package/coverage/lcov-report/api/controllers/index.html +26 -16
- package/coverage/lcov-report/api/controllers/integration.js.html +3 -8
- package/coverage/lcov-report/api/controllers/layout.js.html +3 -8
- package/coverage/lcov-report/api/controllers/metadata.js.html +3 -8
- package/coverage/lcov-report/api/controllers/migrations.js.html +3 -8
- package/coverage/lcov-report/api/controllers/permission.js.html +3 -8
- package/coverage/lcov-report/api/controllers/query/index.html +26 -16
- package/coverage/lcov-report/api/controllers/query/index.js.html +713 -0
- package/coverage/lcov-report/api/controllers/query/validation.js.html +3 -8
- package/coverage/lcov-report/api/controllers/role.js.html +5 -10
- package/coverage/lcov-report/api/controllers/routing.js.html +4 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +3 -8
- package/coverage/lcov-report/api/controllers/row/index.html +35 -25
- package/coverage/lcov-report/api/controllers/row/index.js.html +524 -0
- package/coverage/lcov-report/api/controllers/row/internal.js.html +24 -32
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +16 -21
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +19 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +19 -33
- package/coverage/lcov-report/api/controllers/screen.js.html +4 -9
- package/coverage/lcov-report/api/controllers/script.js.html +3 -8
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +50 -55
- package/coverage/lcov-report/api/controllers/table/external.js.html +3 -8
- package/coverage/lcov-report/api/controllers/table/index.html +44 -19
- package/coverage/lcov-report/api/controllers/table/index.js.html +15 -20
- package/coverage/lcov-report/api/controllers/table/internal.js.html +620 -0
- package/coverage/lcov-report/api/controllers/table/utils.js.html +1331 -0
- package/coverage/lcov-report/api/controllers/templates.js.html +3 -8
- package/coverage/lcov-report/api/controllers/user.js.html +3 -8
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +3 -8
- package/coverage/lcov-report/api/controllers/view/index.html +3 -8
- package/coverage/lcov-report/api/controllers/view/index.js.html +5 -10
- package/coverage/lcov-report/api/controllers/view/utils.js.html +3 -8
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +3 -8
- package/coverage/lcov-report/api/controllers/webhook.js.html +5 -10
- package/coverage/lcov-report/api/index.html +13 -18
- package/coverage/lcov-report/api/index.js.html +8 -28
- package/coverage/lcov-report/api/routes/analytics.js.html +3 -8
- package/coverage/lcov-report/api/routes/apikeys.js.html +3 -8
- package/coverage/lcov-report/api/routes/application.js.html +179 -0
- package/coverage/lcov-report/api/routes/auth.js.html +3 -8
- package/coverage/lcov-report/api/routes/automation.js.html +3 -8
- package/coverage/lcov-report/api/routes/backup.js.html +3 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +3 -8
- package/coverage/lcov-report/api/routes/component.js.html +3 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +3 -8
- package/coverage/lcov-report/api/routes/deploy.js.html +3 -8
- package/coverage/lcov-report/api/routes/dev.js.html +4 -9
- package/coverage/lcov-report/api/routes/index.html +68 -13
- package/coverage/lcov-report/api/routes/index.js.html +266 -0
- package/coverage/lcov-report/api/routes/integration.js.html +3 -8
- package/coverage/lcov-report/api/routes/layout.js.html +3 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +3 -8
- package/coverage/lcov-report/api/routes/migrations.js.html +3 -8
- package/coverage/lcov-report/api/routes/permission.js.html +3 -8
- package/coverage/lcov-report/api/routes/query.js.html +3 -8
- package/coverage/lcov-report/api/routes/role.js.html +3 -8
- package/coverage/lcov-report/api/routes/routing.js.html +3 -8
- package/coverage/lcov-report/api/routes/row.js.html +908 -0
- package/coverage/lcov-report/api/routes/screen.js.html +3 -8
- package/coverage/lcov-report/api/routes/script.js.html +3 -8
- package/coverage/lcov-report/{automations/steps/loop.js.html → api/routes/static.js.html} +80 -70
- package/coverage/lcov-report/api/routes/table.js.html +3 -8
- package/coverage/lcov-report/api/routes/templates.js.html +3 -8
- package/coverage/lcov-report/api/routes/user.js.html +3 -8
- package/coverage/lcov-report/api/routes/utils/index.html +3 -8
- package/coverage/lcov-report/api/routes/utils/validators.js.html +3 -8
- package/coverage/lcov-report/api/routes/view.js.html +3 -8
- package/coverage/lcov-report/api/routes/webhook.js.html +3 -8
- package/coverage/lcov-report/automations/actions.js.html +7 -21
- package/coverage/lcov-report/automations/automationUtils.js.html +23 -64
- package/coverage/lcov-report/automations/bullboard.js.html +3 -8
- package/coverage/lcov-report/automations/index.html +37 -27
- package/coverage/lcov-report/automations/index.js.html +3 -8
- package/coverage/lcov-report/automations/steps/bash.js.html +3 -8
- package/coverage/lcov-report/automations/steps/createRow.js.html +380 -0
- package/coverage/lcov-report/automations/steps/delay.js.html +3 -8
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +347 -0
- package/coverage/lcov-report/automations/steps/discord.js.html +3 -8
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +3 -8
- package/coverage/lcov-report/automations/steps/executeScript.js.html +3 -8
- package/coverage/lcov-report/automations/steps/filter.js.html +3 -8
- package/coverage/lcov-report/automations/steps/index.html +41 -31
- package/coverage/lcov-report/automations/steps/integromat.js.html +3 -8
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +4 -9
- package/coverage/lcov-report/automations/steps/queryRows.js.html +4 -9
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +3 -8
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -8
- package/coverage/lcov-report/automations/steps/slack.js.html +3 -8
- package/coverage/lcov-report/automations/steps/updateRow.js.html +3 -8
- package/coverage/lcov-report/automations/steps/utils.js.html +9 -14
- package/coverage/lcov-report/automations/steps/zapier.js.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/index.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +3 -8
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +3 -8
- package/coverage/lcov-report/automations/triggers.js.html +11 -16
- package/coverage/lcov-report/automations/utils.js.html +665 -0
- package/coverage/lcov-report/block-navigation.js +0 -8
- package/coverage/lcov-report/constants/index.html +3 -8
- package/coverage/lcov-report/constants/index.js.html +42 -41
- package/coverage/lcov-report/constants/layouts.js.html +3 -8
- package/coverage/lcov-report/constants/screens.js.html +3 -8
- package/coverage/lcov-report/db/inMemoryView.js.html +3 -8
- package/coverage/lcov-report/db/index.html +3 -8
- package/coverage/lcov-report/db/index.js.html +4 -9
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +23 -25
- package/coverage/lcov-report/db/linkedRows/index.html +12 -17
- package/coverage/lcov-report/db/linkedRows/index.js.html +17 -22
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +7 -12
- package/coverage/lcov-report/db/newid.js.html +6 -11
- package/coverage/lcov-report/db/utils.js.html +79 -84
- package/coverage/lcov-report/events/AutomationEmitter.js.html +9 -14
- package/coverage/lcov-report/events/index.html +3 -8
- package/coverage/lcov-report/events/index.js.html +4 -9
- package/coverage/lcov-report/events/utils.js.html +13 -18
- package/coverage/lcov-report/index.html +132 -137
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +3 -8
- package/coverage/lcov-report/integrations/tests/index.html +3 -8
- package/coverage/lcov-report/middleware/appInfo.js.html +3 -8
- package/coverage/lcov-report/middleware/authorized.js.html +458 -0
- package/coverage/lcov-report/middleware/builder.js.html +3 -8
- package/coverage/lcov-report/middleware/currentapp.js.html +15 -65
- package/coverage/lcov-report/middleware/index.html +50 -25
- package/coverage/lcov-report/middleware/joi-validator.js.html +4 -9
- package/coverage/lcov-report/middleware/publicApi.js.html +3 -8
- package/coverage/lcov-report/middleware/resourceId.js.html +3 -8
- package/coverage/lcov-report/middleware/selfhost.js.html +4 -9
- package/coverage/lcov-report/middleware/usageQuota.js.html +572 -0
- package/coverage/lcov-report/middleware/utils.js.html +3 -8
- package/coverage/lcov-report/sorter.js +0 -26
- package/coverage/lcov-report/threads/automation.js.html +90 -581
- package/coverage/lcov-report/threads/index.html +40 -30
- package/coverage/lcov-report/threads/index.js.html +296 -0
- package/coverage/lcov-report/threads/query.js.html +4 -9
- package/coverage/lcov-report/threads/utils.js.html +9 -17
- package/coverage/lcov-report/utilities/bcrypt.js.html +3 -8
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -8
- package/coverage/lcov-report/utilities/centralPath.js.html +3 -8
- package/coverage/lcov-report/utilities/csvParser.js.html +5 -10
- package/coverage/lcov-report/utilities/global.js.html +4 -9
- package/coverage/lcov-report/utilities/index.html +3 -8
- package/coverage/lcov-report/utilities/index.js.html +6 -11
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -32
- package/coverage/lcov-report/utilities/queue/index.html +7 -12
- package/coverage/lcov-report/utilities/routing/index.html +3 -8
- package/coverage/lcov-report/utilities/routing/index.js.html +3 -8
- package/coverage/lcov-report/utilities/rowProcessor/index.html +27 -32
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +71 -67
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +106 -27
- package/coverage/lcov-report/utilities/scriptRunner.js.html +3 -8
- package/coverage/lcov-report/utilities/security.js.html +4 -9
- package/coverage/lcov-report/utilities/statusCodes.js.html +3 -8
- package/coverage/lcov-report/utilities/usageQuota/index.html +34 -24
- package/coverage/lcov-report/utilities/usageQuota/index.js.html +359 -0
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +39 -44
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +3 -8
- package/coverage/lcov-report/utilities/users.js.html +3 -8
- package/coverage/lcov-report/utilities/workerRequests.js.html +4 -9
- package/coverage/lcov.info +3061 -1290
- package/dist/api/controllers/application.js +73 -145
- package/dist/api/controllers/deploy/index.js +36 -68
- package/dist/api/controllers/public/applications.js +9 -29
- package/dist/api/controllers/public/queries.js +7 -27
- package/dist/api/controllers/public/rows.js +12 -32
- 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 +44 -57
- package/dist/api/controllers/row/ExternalRequest.js +27 -27
- package/dist/api/controllers/row/index.js +60 -83
- package/dist/api/controllers/row/internal.js +1 -2
- package/dist/api/controllers/row/utils.js +1 -2
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -3
- package/dist/api/controllers/table/bulkFormula.js +1 -2
- package/dist/api/controllers/table/internal.js +55 -40
- package/dist/api/controllers/table/utils.js +229 -271
- package/dist/api/index.js +0 -5
- package/dist/api/routes/application.js +13 -39
- package/dist/api/routes/index.js +56 -61
- package/dist/api/routes/public/index.js +9 -6
- 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 +17 -43
- package/dist/api/routes/static.js +13 -40
- package/dist/api/routes/tests/utilities/TestFunctions.js +33 -75
- package/dist/app.js +4 -8
- package/dist/automations/actions.js +0 -3
- package/dist/automations/automationUtils.js +0 -10
- package/dist/automations/steps/createRow.js +12 -12
- package/dist/automations/steps/deleteRow.js +16 -13
- package/dist/automations/tests/utilities/index.js +11 -13
- package/dist/automations/utils.js +133 -187
- package/dist/constants/index.js +7 -5
- package/dist/db/linkedRows/LinkController.js +1 -0
- package/dist/definitions/datasource.js +0 -1
- package/dist/environment.js +3 -2
- package/dist/index.js +0 -4
- 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 +0 -4
- 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/rest.js +1 -1
- package/dist/middleware/authorized.js +51 -51
- package/dist/middleware/currentapp.js +1 -15
- package/dist/middleware/usageQuota.js +154 -0
- package/dist/migrations/functions/appUrls.js +1 -1
- package/dist/migrations/functions/quotas1.js +2 -6
- package/dist/migrations/functions/usageQuotas/index.js +4 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +7 -4
- package/dist/migrations/functions/usageQuotas/syncRows.js +8 -5
- package/dist/migrations/index.js +1 -17
- package/dist/package.json +4 -10
- package/dist/threads/automation.js +27 -149
- package/dist/threads/index.js +10 -36
- package/dist/threads/utils.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utilities/queue/inMemoryQueue.js +1 -6
- package/dist/utilities/rowProcessor/index.js +11 -6
- package/dist/utilities/rowProcessor/utils.js +27 -1
- package/dist/utilities/usageQuota/index.js +86 -0
- package/nodemon.json +1 -1
- package/package.json +9 -15
- package/scripts/dev/manage.js +0 -2
- package/src/api/controllers/{application.ts → application.js} +51 -118
- package/src/api/controllers/deploy/{index.ts → index.js} +29 -53
- 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.ts → index.js} +48 -51
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/{index.ts → index.js} +17 -24
- package/src/api/controllers/row/internal.js +1 -2
- package/src/api/controllers/row/utils.js +1 -4
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -3
- package/src/api/controllers/table/bulkFormula.js +1 -1
- package/src/api/controllers/table/{internal.ts → internal.js} +48 -27
- package/src/api/controllers/table/{utils.ts → utils.js} +69 -86
- package/src/api/index.js +0 -5
- package/src/api/routes/{application.ts → application.js} +14 -8
- package/src/api/routes/index.js +62 -0
- package/src/api/routes/public/index.ts +4 -1
- package/src/api/routes/{row.ts → row.js} +15 -7
- package/src/api/routes/{static.ts → static.js} +11 -11
- package/src/api/routes/tests/misc.spec.js +37 -39
- package/src/api/routes/tests/routing.spec.js +0 -1
- package/src/api/routes/tests/utilities/{TestFunctions.ts → TestFunctions.js} +33 -57
- package/src/app.ts +2 -1
- package/src/automations/actions.js +0 -3
- package/src/automations/automationUtils.js +0 -12
- package/src/automations/steps/{createRow.ts → createRow.js} +15 -9
- package/src/automations/steps/{deleteRow.ts → deleteRow.js} +16 -10
- package/src/automations/tests/automation.spec.js +1 -0
- package/src/automations/tests/{createRow.spec.ts → createRow.spec.js} +15 -4
- package/src/automations/tests/{deleteRow.spec.ts → deleteRow.spec.js} +5 -3
- package/src/automations/tests/utilities/index.js +10 -12
- package/src/automations/{utils.ts → utils.js} +28 -39
- package/src/constants/index.js +8 -6
- package/src/db/linkedRows/LinkController.js +1 -0
- package/src/definitions/datasource.ts +0 -1
- package/src/environment.js +3 -2
- package/src/index.ts +0 -3
- package/src/integrations/index.ts +0 -4
- package/src/middleware/{authorized.ts → authorized.js} +14 -20
- package/src/middleware/currentapp.js +1 -16
- package/src/middleware/tests/usageQuota.spec.js +120 -0
- package/src/middleware/usageQuota.js +164 -0
- package/src/migrations/functions/tests/quotas1.spec.js +2 -0
- package/src/migrations/functions/usageQuotas/index.ts +5 -0
- package/src/migrations/functions/usageQuotas/syncApps.ts +6 -3
- package/src/migrations/functions/usageQuotas/syncRows.ts +6 -3
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.js +41 -0
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.js +45 -0
- package/src/migrations/index.ts +1 -13
- package/src/threads/automation.js +34 -196
- package/src/threads/{index.ts → index.js} +14 -18
- package/src/threads/utils.js +0 -1
- package/src/utilities/queue/inMemoryQueue.js +1 -7
- package/src/utilities/rowProcessor/index.js +12 -9
- package/src/utilities/rowProcessor/utils.js +29 -1
- package/src/utilities/tests/usageQuota/usageQuota.spec.js +72 -0
- package/src/utilities/usageQuota/index.js +93 -0
- package/tsconfig.json +2 -2
- package/builder/assets/index.89795487.css +0 -6
- package/builder/assets/index.be9a1b80.js +0 -1299
- package/dist/automations/steps/loop.js +0 -51
- package/dist/integrations/redis.js +0 -158
- package/dist/migrations/functions/developerQuota.js +0 -49
- package/dist/migrations/functions/publishedAppsQuota.js +0 -47
- package/dist/migrations/functions/usageQuotas/syncDevelopers.js +0 -24
- package/dist/migrations/functions/usageQuotas/syncPublishedApps.js +0 -26
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/src/api/routes/index.ts +0 -60
- package/src/automations/steps/loop.js +0 -50
- package/src/integrations/redis.ts +0 -152
- package/src/integrations/tests/redis.spec.js +0 -60
- package/src/migrations/functions/developerQuota.ts +0 -15
- package/src/migrations/functions/publishedAppsQuota.ts +0 -13
- package/src/migrations/functions/usageQuotas/syncDevelopers.ts +0 -19
- package/src/migrations/functions/usageQuotas/syncPublishedApps.ts +0 -21
- package/src/migrations/functions/usageQuotas/tests/syncApps.spec.ts +0 -34
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +0 -40
- package/tsconfig.build.json +0 -10
|
@@ -8,75 +8,64 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const constants_2 = require("../../../constants");
|
|
22
|
-
const utils_2 = require("../../../integrations/utils");
|
|
23
|
-
const utils_3 = require("../view/utils");
|
|
24
|
-
const viewBuilder_1 = __importDefault(require("../view/viewBuilder"));
|
|
11
|
+
const csvParser = require("../../../utilities/csvParser");
|
|
12
|
+
const { getRowParams, generateRowID, InternalTables, getTableParams, BudibaseInternalDB, } = require("../../../db/utils");
|
|
13
|
+
const { isEqual } = require("lodash");
|
|
14
|
+
const { AutoFieldSubTypes, FieldTypes } = require("../../../constants");
|
|
15
|
+
const { inputProcessing, cleanupAttachments, } = require("../../../utilities/rowProcessor");
|
|
16
|
+
const { USERS_TABLE_SCHEMA, SwitchableTypes, CanSwitchTypes, } = require("../../../constants");
|
|
17
|
+
const { isExternalTable, breakExternalTableId, isSQL, } = require("../../../integrations/utils");
|
|
18
|
+
const { getViews, saveView } = require("../view/utils");
|
|
19
|
+
const viewTemplate = require("../view/viewBuilder");
|
|
20
|
+
const usageQuota = require("../../../utilities/usageQuota");
|
|
25
21
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
const { cloneDeep } = require("lodash/fp");
|
|
23
|
+
exports.clearColumns = (table, columnNames) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const db = getAppDB();
|
|
25
|
+
const rows = yield db.allDocs(getRowParams(table._id, null, {
|
|
26
|
+
include_docs: true,
|
|
27
|
+
}));
|
|
28
|
+
return db.bulkDocs(rows.rows.map(({ doc }) => {
|
|
29
|
+
columnNames.forEach(colName => delete doc[colName]);
|
|
30
|
+
return doc;
|
|
31
|
+
}));
|
|
32
|
+
});
|
|
33
|
+
exports.checkForColumnUpdates = (oldTable, updatedTable) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const db = getAppDB();
|
|
35
|
+
let updatedRows = [];
|
|
36
|
+
const rename = updatedTable._rename;
|
|
37
|
+
let deletedColumns = [];
|
|
38
|
+
if (oldTable && oldTable.schema && updatedTable.schema) {
|
|
39
|
+
deletedColumns = Object.keys(oldTable.schema).filter(colName => updatedTable.schema[colName] == null);
|
|
40
|
+
}
|
|
41
|
+
// check for renaming of columns or deleted columns
|
|
42
|
+
if (rename || deletedColumns.length !== 0) {
|
|
43
|
+
// Update all rows
|
|
44
|
+
const rows = yield db.allDocs(getRowParams(updatedTable._id, null, {
|
|
32
45
|
include_docs: true,
|
|
33
46
|
}));
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
include_docs: true,
|
|
55
|
-
}));
|
|
56
|
-
const rawRows = rows.rows.map(({ doc }) => doc);
|
|
57
|
-
updatedRows = rawRows.map((row) => {
|
|
58
|
-
row = (0, fp_1.cloneDeep)(row);
|
|
59
|
-
if (rename) {
|
|
60
|
-
row[rename.updated] = row[rename.old];
|
|
61
|
-
delete row[rename.old];
|
|
62
|
-
}
|
|
63
|
-
else if (deletedColumns.length !== 0) {
|
|
64
|
-
deletedColumns.forEach((colName) => delete row[colName]);
|
|
65
|
-
}
|
|
66
|
-
return row;
|
|
67
|
-
});
|
|
68
|
-
// cleanup any attachments from object storage for deleted attachment columns
|
|
69
|
-
yield (0, rowProcessor_1.cleanupAttachments)(updatedTable, { oldTable, rows: rawRows });
|
|
70
|
-
// Update views
|
|
71
|
-
yield checkForViewUpdates(updatedTable, rename, deletedColumns);
|
|
72
|
-
delete updatedTable._rename;
|
|
73
|
-
}
|
|
74
|
-
return { rows: updatedRows, table: updatedTable };
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
exports.checkForColumnUpdates = checkForColumnUpdates;
|
|
47
|
+
const rawRows = rows.rows.map(({ doc }) => doc);
|
|
48
|
+
updatedRows = rawRows.map(row => {
|
|
49
|
+
row = cloneDeep(row);
|
|
50
|
+
if (rename) {
|
|
51
|
+
row[rename.updated] = row[rename.old];
|
|
52
|
+
delete row[rename.old];
|
|
53
|
+
}
|
|
54
|
+
else if (deletedColumns.length !== 0) {
|
|
55
|
+
deletedColumns.forEach(colName => delete row[colName]);
|
|
56
|
+
}
|
|
57
|
+
return row;
|
|
58
|
+
});
|
|
59
|
+
// cleanup any attachments from object storage for deleted attachment columns
|
|
60
|
+
yield cleanupAttachments(updatedTable, { oldTable, rows: rawRows });
|
|
61
|
+
// Update views
|
|
62
|
+
yield exports.checkForViewUpdates(updatedTable, rename, deletedColumns);
|
|
63
|
+
delete updatedTable._rename;
|
|
64
|
+
}
|
|
65
|
+
return { rows: updatedRows, table: updatedTable };
|
|
66
|
+
});
|
|
78
67
|
// makes sure the passed in table isn't going to reset the auto ID
|
|
79
|
-
|
|
68
|
+
exports.makeSureTableUpToDate = (table, tableToSave) => {
|
|
80
69
|
if (!table) {
|
|
81
70
|
return tableToSave;
|
|
82
71
|
}
|
|
@@ -84,83 +73,66 @@ function makeSureTableUpToDate(table, tableToSave) {
|
|
|
84
73
|
tableToSave._rev = table._rev;
|
|
85
74
|
// make sure auto IDs are always updated - these are internal
|
|
86
75
|
// so the client may not know they have changed
|
|
87
|
-
let field
|
|
88
|
-
let column;
|
|
89
|
-
for ([field, column] of Object.entries(table.schema)) {
|
|
76
|
+
for (let [field, column] of Object.entries(table.schema)) {
|
|
90
77
|
if (column.autocolumn &&
|
|
91
|
-
column.subtype ===
|
|
78
|
+
column.subtype === AutoFieldSubTypes.AUTO_ID &&
|
|
92
79
|
tableToSave.schema[field]) {
|
|
93
80
|
tableToSave.schema[field].lastID = column.lastID;
|
|
94
81
|
}
|
|
95
82
|
}
|
|
96
83
|
return tableToSave;
|
|
97
|
-
}
|
|
98
|
-
exports.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
let
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
schema.constraints.inclusion = [
|
|
125
|
-
...schema.constraints.inclusion,
|
|
126
|
-
row[fieldName],
|
|
127
|
-
];
|
|
128
|
-
}
|
|
84
|
+
};
|
|
85
|
+
exports.handleDataImport = (user, table, dataImport) => __awaiter(void 0, void 0, void 0, function* () {
|
|
86
|
+
if (!dataImport || !dataImport.csvString) {
|
|
87
|
+
return table;
|
|
88
|
+
}
|
|
89
|
+
const db = getAppDB();
|
|
90
|
+
// Populate the table with rows imported from CSV in a bulk update
|
|
91
|
+
const data = yield csvParser.transform(Object.assign(Object.assign({}, dataImport), { existingTable: table }));
|
|
92
|
+
let finalData = [];
|
|
93
|
+
for (let i = 0; i < data.length; i++) {
|
|
94
|
+
let row = data[i];
|
|
95
|
+
row._id = generateRowID(table._id);
|
|
96
|
+
row.tableId = table._id;
|
|
97
|
+
const processed = inputProcessing(user, table, row, {
|
|
98
|
+
noAutoRelationships: true,
|
|
99
|
+
});
|
|
100
|
+
table = processed.table;
|
|
101
|
+
row = processed.row;
|
|
102
|
+
for (let [fieldName, schema] of Object.entries(table.schema)) {
|
|
103
|
+
// check whether the options need to be updated for inclusion as part of the data import
|
|
104
|
+
if (schema.type === FieldTypes.OPTIONS &&
|
|
105
|
+
(!schema.constraints.inclusion ||
|
|
106
|
+
schema.constraints.inclusion.indexOf(row[fieldName]) === -1)) {
|
|
107
|
+
schema.constraints.inclusion = [
|
|
108
|
+
...schema.constraints.inclusion,
|
|
109
|
+
row[fieldName],
|
|
110
|
+
];
|
|
129
111
|
}
|
|
130
|
-
finalData.push(row);
|
|
131
112
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
113
|
+
finalData.push(row);
|
|
114
|
+
}
|
|
115
|
+
yield usageQuota.update(usageQuota.Properties.ROW, finalData.length, {
|
|
116
|
+
dryRun: true,
|
|
136
117
|
});
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
fields: table.indexes,
|
|
156
|
-
name: indexName,
|
|
157
|
-
ddoc: "search_ddoc",
|
|
158
|
-
type: "json",
|
|
159
|
-
},
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
118
|
+
yield db.bulkDocs(finalData);
|
|
119
|
+
yield usageQuota.update(usageQuota.Properties.ROW, finalData.length);
|
|
120
|
+
let response = yield db.put(table);
|
|
121
|
+
table._rev = response._rev;
|
|
122
|
+
return table;
|
|
123
|
+
});
|
|
124
|
+
exports.handleSearchIndexes = (table) => __awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
+
const db = getAppDB();
|
|
126
|
+
// create relevant search indexes
|
|
127
|
+
if (table.indexes && table.indexes.length > 0) {
|
|
128
|
+
const currentIndexes = yield db.getIndexes();
|
|
129
|
+
const indexName = `search:${table._id}`;
|
|
130
|
+
const existingIndex = currentIndexes.indexes.find(existing => existing.name === indexName);
|
|
131
|
+
if (existingIndex) {
|
|
132
|
+
const currentFields = existingIndex.def.fields.map(field => Object.keys(field)[0]);
|
|
133
|
+
// if index fields have changed, delete the original index
|
|
134
|
+
if (!isEqual(currentFields, table.indexes)) {
|
|
135
|
+
yield db.deleteIndex(existingIndex);
|
|
164
136
|
// create/recreate the index with fields
|
|
165
137
|
yield db.createIndex({
|
|
166
138
|
index: {
|
|
@@ -172,14 +144,24 @@ function handleSearchIndexes(table) {
|
|
|
172
144
|
});
|
|
173
145
|
}
|
|
174
146
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
147
|
+
else {
|
|
148
|
+
// create/recreate the index with fields
|
|
149
|
+
yield db.createIndex({
|
|
150
|
+
index: {
|
|
151
|
+
fields: table.indexes,
|
|
152
|
+
name: indexName,
|
|
153
|
+
ddoc: "search_ddoc",
|
|
154
|
+
type: "json",
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return table;
|
|
160
|
+
});
|
|
161
|
+
exports.checkStaticTables = table => {
|
|
180
162
|
// check user schema has all required elements
|
|
181
|
-
if (table._id ===
|
|
182
|
-
for (let [key, schema] of Object.entries(
|
|
163
|
+
if (table._id === InternalTables.USER_METADATA) {
|
|
164
|
+
for (let [key, schema] of Object.entries(USERS_TABLE_SCHEMA.schema)) {
|
|
183
165
|
// check if the schema exists on the table to be created/updated
|
|
184
166
|
if (table.schema[key] == null) {
|
|
185
167
|
table.schema[key] = schema;
|
|
@@ -187,8 +169,7 @@ function checkStaticTables(table) {
|
|
|
187
169
|
}
|
|
188
170
|
}
|
|
189
171
|
return table;
|
|
190
|
-
}
|
|
191
|
-
exports.checkStaticTables = checkStaticTables;
|
|
172
|
+
};
|
|
192
173
|
class TableSaveFunctions {
|
|
193
174
|
constructor({ user, oldTable, dataImport }) {
|
|
194
175
|
this.db = getAppDB();
|
|
@@ -202,16 +183,16 @@ class TableSaveFunctions {
|
|
|
202
183
|
before(table) {
|
|
203
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
204
185
|
if (this.oldTable) {
|
|
205
|
-
table = makeSureTableUpToDate(this.oldTable, table);
|
|
186
|
+
table = exports.makeSureTableUpToDate(this.oldTable, table);
|
|
206
187
|
}
|
|
207
|
-
table = checkStaticTables(table);
|
|
188
|
+
table = exports.checkStaticTables(table);
|
|
208
189
|
return table;
|
|
209
190
|
});
|
|
210
191
|
}
|
|
211
192
|
// when confirmed valid
|
|
212
193
|
mid(table) {
|
|
213
194
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
-
let response = yield checkForColumnUpdates(this.oldTable, table);
|
|
195
|
+
let response = yield exports.checkForColumnUpdates(this.oldTable, table);
|
|
215
196
|
this.rows = this.rows.concat(response.rows);
|
|
216
197
|
return table;
|
|
217
198
|
});
|
|
@@ -219,8 +200,8 @@ class TableSaveFunctions {
|
|
|
219
200
|
// after saving
|
|
220
201
|
after(table) {
|
|
221
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
-
table = yield handleSearchIndexes(table);
|
|
223
|
-
table = yield handleDataImport(this.user, table, this.dataImport);
|
|
203
|
+
table = yield exports.handleSearchIndexes(table);
|
|
204
|
+
table = yield exports.handleDataImport(this.user, table, this.dataImport);
|
|
224
205
|
return table;
|
|
225
206
|
});
|
|
226
207
|
}
|
|
@@ -228,128 +209,111 @@ class TableSaveFunctions {
|
|
|
228
209
|
return this.rows;
|
|
229
210
|
}
|
|
230
211
|
}
|
|
231
|
-
function
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
212
|
+
exports.getAllInternalTables = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
213
|
+
const db = getAppDB();
|
|
214
|
+
const internalTables = yield db.allDocs(getTableParams(null, {
|
|
215
|
+
include_docs: true,
|
|
216
|
+
}));
|
|
217
|
+
return internalTables.rows.map(tableDoc => (Object.assign(Object.assign({}, tableDoc.doc), { type: "internal", sourceId: BudibaseInternalDB._id })));
|
|
218
|
+
});
|
|
219
|
+
exports.getAllExternalTables = (datasourceId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
220
|
+
const db = getAppDB();
|
|
221
|
+
const datasource = yield db.get(datasourceId);
|
|
222
|
+
if (!datasource || !datasource.entities) {
|
|
223
|
+
throw "Datasource is not configured fully.";
|
|
224
|
+
}
|
|
225
|
+
return datasource.entities;
|
|
226
|
+
});
|
|
227
|
+
exports.getExternalTable = (datasourceId, tableName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
228
|
+
const entities = yield exports.getAllExternalTables(datasourceId);
|
|
229
|
+
return entities[tableName];
|
|
230
|
+
});
|
|
231
|
+
exports.getTable = (tableId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
232
|
+
const db = getAppDB();
|
|
233
|
+
if (isExternalTable(tableId)) {
|
|
234
|
+
let { datasourceId, tableName } = breakExternalTableId(tableId);
|
|
244
235
|
const datasource = yield db.get(datasourceId);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
236
|
+
const table = yield exports.getExternalTable(datasourceId, tableName);
|
|
237
|
+
return Object.assign(Object.assign({}, table), { sql: isSQL(datasource) });
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return db.get(tableId);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
exports.checkForViewUpdates = (table, rename, deletedColumns) => __awaiter(void 0, void 0, void 0, function* () {
|
|
244
|
+
const views = yield getViews();
|
|
245
|
+
const tableViews = views.filter(view => view.meta.tableId === table._id);
|
|
246
|
+
// Check each table view to see if impacted by this table action
|
|
247
|
+
for (let view of tableViews) {
|
|
248
|
+
let needsUpdated = false;
|
|
249
|
+
// First check for renames, otherwise check for deletions
|
|
250
|
+
if (rename) {
|
|
251
|
+
// Update calculation field if required
|
|
252
|
+
if (view.meta.field === rename.old) {
|
|
253
|
+
view.meta.field = rename.updated;
|
|
254
|
+
needsUpdated = true;
|
|
255
|
+
}
|
|
256
|
+
// Update group by field if required
|
|
257
|
+
if (view.meta.groupBy === rename.old) {
|
|
258
|
+
view.meta.groupBy = rename.updated;
|
|
259
|
+
needsUpdated = true;
|
|
260
|
+
}
|
|
261
|
+
// Update filters if required
|
|
262
|
+
if (view.meta.filters) {
|
|
263
|
+
view.meta.filters.forEach(filter => {
|
|
264
|
+
if (filter.key === rename.old) {
|
|
265
|
+
filter.key = rename.updated;
|
|
266
|
+
needsUpdated = true;
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
270
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// Check each table view to see if impacted by this table action
|
|
279
|
-
for (let view of tableViews) {
|
|
280
|
-
let needsUpdated = false;
|
|
281
|
-
// First check for renames, otherwise check for deletions
|
|
282
|
-
if (rename) {
|
|
283
|
-
// Update calculation field if required
|
|
284
|
-
if (view.meta.field === rename.old) {
|
|
285
|
-
view.meta.field = rename.updated;
|
|
271
|
+
else if (deletedColumns) {
|
|
272
|
+
deletedColumns.forEach(column => {
|
|
273
|
+
// Remove calculation statement if required
|
|
274
|
+
if (view.meta.field === column) {
|
|
275
|
+
delete view.meta.field;
|
|
276
|
+
delete view.meta.calculation;
|
|
277
|
+
delete view.meta.groupBy;
|
|
286
278
|
needsUpdated = true;
|
|
287
279
|
}
|
|
288
|
-
//
|
|
289
|
-
if (view.meta.groupBy ===
|
|
290
|
-
view.meta.groupBy
|
|
280
|
+
// Remove group by field if required
|
|
281
|
+
if (view.meta.groupBy === column) {
|
|
282
|
+
delete view.meta.groupBy;
|
|
291
283
|
needsUpdated = true;
|
|
292
284
|
}
|
|
293
|
-
//
|
|
294
|
-
if (view.meta.filters) {
|
|
295
|
-
view.meta.filters.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
needsUpdated = true;
|
|
299
|
-
}
|
|
285
|
+
// Remove filters referencing deleted field if required
|
|
286
|
+
if (view.meta.filters && view.meta.filters.length) {
|
|
287
|
+
const initialLength = view.meta.filters.length;
|
|
288
|
+
view.meta.filters = view.meta.filters.filter(filter => {
|
|
289
|
+
return filter.key !== column;
|
|
300
290
|
});
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
else if (deletedColumns) {
|
|
304
|
-
deletedColumns.forEach((column) => {
|
|
305
|
-
// Remove calculation statement if required
|
|
306
|
-
if (view.meta.field === column) {
|
|
307
|
-
delete view.meta.field;
|
|
308
|
-
delete view.meta.calculation;
|
|
309
|
-
delete view.meta.groupBy;
|
|
310
|
-
needsUpdated = true;
|
|
311
|
-
}
|
|
312
|
-
// Remove group by field if required
|
|
313
|
-
if (view.meta.groupBy === column) {
|
|
314
|
-
delete view.meta.groupBy;
|
|
291
|
+
if (initialLength !== view.meta.filters.length) {
|
|
315
292
|
needsUpdated = true;
|
|
316
293
|
}
|
|
317
|
-
// Remove filters referencing deleted field if required
|
|
318
|
-
if (view.meta.filters && view.meta.filters.length) {
|
|
319
|
-
const initialLength = view.meta.filters.length;
|
|
320
|
-
view.meta.filters = view.meta.filters.filter((filter) => {
|
|
321
|
-
return filter.key !== column;
|
|
322
|
-
});
|
|
323
|
-
if (initialLength !== view.meta.filters.length) {
|
|
324
|
-
needsUpdated = true;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
// Update view if required
|
|
330
|
-
if (needsUpdated) {
|
|
331
|
-
const newViewTemplate = (0, viewBuilder_1.default)(view.meta);
|
|
332
|
-
yield (0, utils_3.saveView)(null, view.name, newViewTemplate);
|
|
333
|
-
if (!newViewTemplate.meta.schema) {
|
|
334
|
-
newViewTemplate.meta.schema = table.schema;
|
|
335
294
|
}
|
|
336
|
-
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
// Update view if required
|
|
298
|
+
if (needsUpdated) {
|
|
299
|
+
const newViewTemplate = viewTemplate(view.meta);
|
|
300
|
+
yield saveView(null, view.name, newViewTemplate);
|
|
301
|
+
if (!newViewTemplate.meta.schema) {
|
|
302
|
+
newViewTemplate.meta.schema = table.schema;
|
|
337
303
|
}
|
|
304
|
+
table.views[view.name] = newViewTemplate.meta;
|
|
338
305
|
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
exports.
|
|
342
|
-
function generateForeignKey(column, relatedTable) {
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
exports.generateForeignKey = (column, relatedTable) => {
|
|
343
309
|
return `fk_${relatedTable.name}_${column.fieldName}`;
|
|
344
|
-
}
|
|
345
|
-
exports.
|
|
346
|
-
function generateJunctionTableName(column, table, relatedTable) {
|
|
310
|
+
};
|
|
311
|
+
exports.generateJunctionTableName = (column, table, relatedTable) => {
|
|
347
312
|
return `jt_${table.name}_${relatedTable.name}_${column.name}_${column.fieldName}`;
|
|
348
|
-
}
|
|
349
|
-
exports.
|
|
350
|
-
function foreignKeyStructure(keyName, meta = null) {
|
|
313
|
+
};
|
|
314
|
+
exports.foreignKeyStructure = (keyName, meta = null) => {
|
|
351
315
|
const structure = {
|
|
352
|
-
type:
|
|
316
|
+
type: FieldTypes.NUMBER,
|
|
353
317
|
constraints: {},
|
|
354
318
|
name: keyName,
|
|
355
319
|
};
|
|
@@ -357,40 +321,34 @@ function foreignKeyStructure(keyName, meta = null) {
|
|
|
357
321
|
structure.meta = meta;
|
|
358
322
|
}
|
|
359
323
|
return structure;
|
|
360
|
-
}
|
|
361
|
-
exports.
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
constants_2.SwitchableTypes.indexOf(type2) === -1) {
|
|
324
|
+
};
|
|
325
|
+
exports.areSwitchableTypes = (type1, type2) => {
|
|
326
|
+
if (SwitchableTypes.indexOf(type1) === -1 &&
|
|
327
|
+
SwitchableTypes.indexOf(type2) === -1) {
|
|
365
328
|
return false;
|
|
366
329
|
}
|
|
367
|
-
for (let option of
|
|
330
|
+
for (let option of CanSwitchTypes) {
|
|
368
331
|
const index1 = option.indexOf(type1), index2 = option.indexOf(type2);
|
|
369
332
|
if (index1 !== -1 && index2 !== -1 && index1 !== index2) {
|
|
370
333
|
return true;
|
|
371
334
|
}
|
|
372
335
|
}
|
|
373
336
|
return false;
|
|
374
|
-
}
|
|
375
|
-
exports.
|
|
376
|
-
function hasTypeChanged(table, oldTable) {
|
|
337
|
+
};
|
|
338
|
+
exports.hasTypeChanged = (table, oldTable) => {
|
|
377
339
|
if (!oldTable) {
|
|
378
340
|
return false;
|
|
379
341
|
}
|
|
380
|
-
let key
|
|
381
|
-
let field;
|
|
382
|
-
for ([key, field] of Object.entries(oldTable.schema)) {
|
|
342
|
+
for (let [key, field] of Object.entries(oldTable.schema)) {
|
|
383
343
|
const oldType = field.type;
|
|
384
344
|
if (!table.schema[key]) {
|
|
385
345
|
continue;
|
|
386
346
|
}
|
|
387
347
|
const newType = table.schema[key].type;
|
|
388
|
-
if (oldType !== newType && !areSwitchableTypes(oldType, newType)) {
|
|
348
|
+
if (oldType !== newType && !exports.areSwitchableTypes(oldType, newType)) {
|
|
389
349
|
return true;
|
|
390
350
|
}
|
|
391
351
|
}
|
|
392
352
|
return false;
|
|
393
|
-
}
|
|
394
|
-
exports.
|
|
395
|
-
const _TableSaveFunctions = TableSaveFunctions;
|
|
396
|
-
exports.TableSaveFunctions = _TableSaveFunctions;
|
|
353
|
+
};
|
|
354
|
+
exports.TableSaveFunctions = TableSaveFunctions;
|
package/dist/api/index.js
CHANGED
|
@@ -10,14 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
const Router = require("@koa/router");
|
|
12
12
|
const { buildAuthMiddleware, auditLog, buildTenancyMiddleware, } = require("@budibase/backend-core/auth");
|
|
13
|
-
const { errors } = require("@budibase/backend-core");
|
|
14
13
|
const currentApp = require("../middleware/currentapp");
|
|
15
14
|
const compress = require("koa-compress");
|
|
16
15
|
const zlib = require("zlib");
|
|
17
16
|
const { mainRoutes, staticRoutes, publicRoutes } = require("./routes");
|
|
18
17
|
const pkg = require("../../package.json");
|
|
19
18
|
const env = require("../environment");
|
|
20
|
-
const { middleware: pro } = require("@budibase/pro");
|
|
21
19
|
const router = new Router();
|
|
22
20
|
router.get("/health", ctx => (ctx.status = 200));
|
|
23
21
|
router.get("/version", ctx => (ctx.body = pkg.version));
|
|
@@ -51,7 +49,6 @@ router
|
|
|
51
49
|
noTenancyRequired: true,
|
|
52
50
|
}))
|
|
53
51
|
.use(currentApp)
|
|
54
|
-
.use(pro.licensing())
|
|
55
52
|
.use(auditLog);
|
|
56
53
|
// error handling middleware
|
|
57
54
|
router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -60,12 +57,10 @@ router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
60
57
|
}
|
|
61
58
|
catch (err) {
|
|
62
59
|
ctx.status = err.status || err.statusCode || 500;
|
|
63
|
-
const error = errors.getPublicError(err);
|
|
64
60
|
ctx.body = {
|
|
65
61
|
message: err.message,
|
|
66
62
|
status: ctx.status,
|
|
67
63
|
validationErrors: err.validation,
|
|
68
|
-
error,
|
|
69
64
|
};
|
|
70
65
|
if (env.NODE_ENV !== "jest") {
|
|
71
66
|
ctx.log.error(err);
|