@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
|
@@ -8,64 +8,75 @@ 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
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.TableSaveFunctions = exports.hasTypeChanged = exports.areSwitchableTypes = exports.foreignKeyStructure = exports.generateJunctionTableName = exports.generateForeignKey = exports.checkForViewUpdates = exports.getTable = exports.getExternalTable = exports.getAllExternalTables = exports.getAllInternalTables = exports.checkStaticTables = exports.handleSearchIndexes = exports.handleDataImport = exports.makeSureTableUpToDate = exports.checkForColumnUpdates = exports.clearColumns = void 0;
|
|
16
|
+
const csvParser_1 = require("../../../utilities/csvParser");
|
|
17
|
+
const utils_1 = require("../../../db/utils");
|
|
18
|
+
const lodash_1 = require("lodash");
|
|
19
|
+
const constants_1 = require("../../../constants");
|
|
20
|
+
const rowProcessor_1 = require("../../../utilities/rowProcessor");
|
|
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"));
|
|
21
25
|
const { getAppDB } = require("@budibase/backend-core/context");
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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, {
|
|
26
|
+
const fp_1 = require("lodash/fp");
|
|
27
|
+
const pro_1 = require("@budibase/pro");
|
|
28
|
+
function clearColumns(table, columnNames) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const db = getAppDB();
|
|
31
|
+
const rows = yield db.allDocs((0, utils_1.getRowParams)(table._id, null, {
|
|
45
32
|
include_docs: true,
|
|
46
33
|
}));
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
34
|
+
return db.bulkDocs(rows.rows.map(({ doc }) => {
|
|
35
|
+
columnNames.forEach((colName) => delete doc[colName]);
|
|
36
|
+
return doc;
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.clearColumns = clearColumns;
|
|
41
|
+
function checkForColumnUpdates(oldTable, updatedTable) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const db = getAppDB();
|
|
44
|
+
let updatedRows = [];
|
|
45
|
+
const rename = updatedTable._rename;
|
|
46
|
+
let deletedColumns = [];
|
|
47
|
+
if (oldTable && oldTable.schema && updatedTable.schema) {
|
|
48
|
+
deletedColumns = Object.keys(oldTable.schema).filter(colName => updatedTable.schema[colName] == null);
|
|
49
|
+
}
|
|
50
|
+
// check for renaming of columns or deleted columns
|
|
51
|
+
if (rename || deletedColumns.length !== 0) {
|
|
52
|
+
// Update all rows
|
|
53
|
+
const rows = yield db.allDocs((0, utils_1.getRowParams)(updatedTable._id, null, {
|
|
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;
|
|
67
78
|
// makes sure the passed in table isn't going to reset the auto ID
|
|
68
|
-
|
|
79
|
+
function makeSureTableUpToDate(table, tableToSave) {
|
|
69
80
|
if (!table) {
|
|
70
81
|
return tableToSave;
|
|
71
82
|
}
|
|
@@ -73,66 +84,83 @@ exports.makeSureTableUpToDate = (table, tableToSave) => {
|
|
|
73
84
|
tableToSave._rev = table._rev;
|
|
74
85
|
// make sure auto IDs are always updated - these are internal
|
|
75
86
|
// so the client may not know they have changed
|
|
76
|
-
|
|
87
|
+
let field;
|
|
88
|
+
let column;
|
|
89
|
+
for ([field, column] of Object.entries(table.schema)) {
|
|
77
90
|
if (column.autocolumn &&
|
|
78
|
-
column.subtype === AutoFieldSubTypes.AUTO_ID &&
|
|
91
|
+
column.subtype === constants_1.AutoFieldSubTypes.AUTO_ID &&
|
|
79
92
|
tableToSave.schema[field]) {
|
|
80
93
|
tableToSave.schema[field].lastID = column.lastID;
|
|
81
94
|
}
|
|
82
95
|
}
|
|
83
96
|
return tableToSave;
|
|
84
|
-
}
|
|
85
|
-
exports.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
97
|
+
}
|
|
98
|
+
exports.makeSureTableUpToDate = makeSureTableUpToDate;
|
|
99
|
+
function handleDataImport(user, table, dataImport) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
if (!dataImport || !dataImport.csvString) {
|
|
102
|
+
return table;
|
|
103
|
+
}
|
|
104
|
+
const db = getAppDB();
|
|
105
|
+
// Populate the table with rows imported from CSV in a bulk update
|
|
106
|
+
const data = yield (0, csvParser_1.transform)(Object.assign(Object.assign({}, dataImport), { existingTable: table }));
|
|
107
|
+
let finalData = [];
|
|
108
|
+
for (let i = 0; i < data.length; i++) {
|
|
109
|
+
let row = data[i];
|
|
110
|
+
row._id = (0, utils_1.generateRowID)(table._id);
|
|
111
|
+
row.tableId = table._id;
|
|
112
|
+
const processed = (0, rowProcessor_1.inputProcessing)(user, table, row, {
|
|
113
|
+
noAutoRelationships: true,
|
|
114
|
+
});
|
|
115
|
+
table = processed.table;
|
|
116
|
+
row = processed.row;
|
|
117
|
+
let fieldName;
|
|
118
|
+
let schema;
|
|
119
|
+
for ([fieldName, schema] of Object.entries(table.schema)) {
|
|
120
|
+
// check whether the options need to be updated for inclusion as part of the data import
|
|
121
|
+
if (schema.type === constants_1.FieldTypes.OPTIONS &&
|
|
122
|
+
(!schema.constraints.inclusion ||
|
|
123
|
+
schema.constraints.inclusion.indexOf(row[fieldName]) === -1)) {
|
|
124
|
+
schema.constraints.inclusion = [
|
|
125
|
+
...schema.constraints.inclusion,
|
|
126
|
+
row[fieldName],
|
|
127
|
+
];
|
|
128
|
+
}
|
|
111
129
|
}
|
|
130
|
+
finalData.push(row);
|
|
112
131
|
}
|
|
113
|
-
finalData.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
132
|
+
yield pro_1.quotas.addRows(finalData.length, () => db.bulkDocs(finalData));
|
|
133
|
+
let response = yield db.put(table);
|
|
134
|
+
table._rev = response._rev;
|
|
135
|
+
return table;
|
|
117
136
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
137
|
+
}
|
|
138
|
+
exports.handleDataImport = handleDataImport;
|
|
139
|
+
function handleSearchIndexes(table) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
const db = getAppDB();
|
|
142
|
+
// create relevant search indexes
|
|
143
|
+
if (table.indexes && table.indexes.length > 0) {
|
|
144
|
+
const currentIndexes = yield db.getIndexes();
|
|
145
|
+
const indexName = `search:${table._id}`;
|
|
146
|
+
const existingIndex = currentIndexes.indexes.find((existing) => existing.name === indexName);
|
|
147
|
+
if (existingIndex) {
|
|
148
|
+
const currentFields = existingIndex.def.fields.map((field) => Object.keys(field)[0]);
|
|
149
|
+
// if index fields have changed, delete the original index
|
|
150
|
+
if (!(0, lodash_1.isEqual)(currentFields, table.indexes)) {
|
|
151
|
+
yield db.deleteIndex(existingIndex);
|
|
152
|
+
// create/recreate the index with fields
|
|
153
|
+
yield db.createIndex({
|
|
154
|
+
index: {
|
|
155
|
+
fields: table.indexes,
|
|
156
|
+
name: indexName,
|
|
157
|
+
ddoc: "search_ddoc",
|
|
158
|
+
type: "json",
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
136
164
|
// create/recreate the index with fields
|
|
137
165
|
yield db.createIndex({
|
|
138
166
|
index: {
|
|
@@ -144,24 +172,14 @@ exports.handleSearchIndexes = (table) => __awaiter(void 0, void 0, void 0, funct
|
|
|
144
172
|
});
|
|
145
173
|
}
|
|
146
174
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
name: indexName,
|
|
153
|
-
ddoc: "search_ddoc",
|
|
154
|
-
type: "json",
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
return table;
|
|
160
|
-
});
|
|
161
|
-
exports.checkStaticTables = table => {
|
|
175
|
+
return table;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
exports.handleSearchIndexes = handleSearchIndexes;
|
|
179
|
+
function checkStaticTables(table) {
|
|
162
180
|
// check user schema has all required elements
|
|
163
|
-
if (table._id === InternalTables.USER_METADATA) {
|
|
164
|
-
for (let [key, schema] of Object.entries(USERS_TABLE_SCHEMA.schema)) {
|
|
181
|
+
if (table._id === utils_1.InternalTables.USER_METADATA) {
|
|
182
|
+
for (let [key, schema] of Object.entries(constants_2.USERS_TABLE_SCHEMA.schema)) {
|
|
165
183
|
// check if the schema exists on the table to be created/updated
|
|
166
184
|
if (table.schema[key] == null) {
|
|
167
185
|
table.schema[key] = schema;
|
|
@@ -169,7 +187,8 @@ exports.checkStaticTables = table => {
|
|
|
169
187
|
}
|
|
170
188
|
}
|
|
171
189
|
return table;
|
|
172
|
-
}
|
|
190
|
+
}
|
|
191
|
+
exports.checkStaticTables = checkStaticTables;
|
|
173
192
|
class TableSaveFunctions {
|
|
174
193
|
constructor({ user, oldTable, dataImport }) {
|
|
175
194
|
this.db = getAppDB();
|
|
@@ -183,16 +202,16 @@ class TableSaveFunctions {
|
|
|
183
202
|
before(table) {
|
|
184
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
185
204
|
if (this.oldTable) {
|
|
186
|
-
table =
|
|
205
|
+
table = makeSureTableUpToDate(this.oldTable, table);
|
|
187
206
|
}
|
|
188
|
-
table =
|
|
207
|
+
table = checkStaticTables(table);
|
|
189
208
|
return table;
|
|
190
209
|
});
|
|
191
210
|
}
|
|
192
211
|
// when confirmed valid
|
|
193
212
|
mid(table) {
|
|
194
213
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
let response = yield
|
|
214
|
+
let response = yield checkForColumnUpdates(this.oldTable, table);
|
|
196
215
|
this.rows = this.rows.concat(response.rows);
|
|
197
216
|
return table;
|
|
198
217
|
});
|
|
@@ -200,8 +219,8 @@ class TableSaveFunctions {
|
|
|
200
219
|
// after saving
|
|
201
220
|
after(table) {
|
|
202
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
table = yield
|
|
204
|
-
table = yield
|
|
222
|
+
table = yield handleSearchIndexes(table);
|
|
223
|
+
table = yield handleDataImport(this.user, table, this.dataImport);
|
|
205
224
|
return table;
|
|
206
225
|
});
|
|
207
226
|
}
|
|
@@ -209,111 +228,128 @@ class TableSaveFunctions {
|
|
|
209
228
|
return this.rows;
|
|
210
229
|
}
|
|
211
230
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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);
|
|
231
|
+
function getAllInternalTables() {
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
const db = getAppDB();
|
|
234
|
+
const internalTables = yield db.allDocs((0, utils_1.getTableParams)(null, {
|
|
235
|
+
include_docs: true,
|
|
236
|
+
}));
|
|
237
|
+
return internalTables.rows.map((tableDoc) => (Object.assign(Object.assign({}, tableDoc.doc), { type: "internal", sourceId: utils_1.BudibaseInternalDB._id })));
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
exports.getAllInternalTables = getAllInternalTables;
|
|
241
|
+
function getAllExternalTables(datasourceId) {
|
|
242
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
+
const db = getAppDB();
|
|
235
244
|
const datasource = yield db.get(datasourceId);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
}
|
|
245
|
+
if (!datasource || !datasource.entities) {
|
|
246
|
+
throw "Datasource is not configured fully.";
|
|
247
|
+
}
|
|
248
|
+
return datasource.entities;
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
exports.getAllExternalTables = getAllExternalTables;
|
|
252
|
+
function getExternalTable(datasourceId, tableName) {
|
|
253
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
+
const entities = yield getAllExternalTables(datasourceId);
|
|
255
|
+
return entities[tableName];
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
exports.getExternalTable = getExternalTable;
|
|
259
|
+
function getTable(tableId) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
const db = getAppDB();
|
|
262
|
+
if ((0, utils_2.isExternalTable)(tableId)) {
|
|
263
|
+
let { datasourceId, tableName } = (0, utils_2.breakExternalTableId)(tableId);
|
|
264
|
+
const datasource = yield db.get(datasourceId);
|
|
265
|
+
const table = yield getExternalTable(datasourceId, tableName);
|
|
266
|
+
return Object.assign(Object.assign({}, table), { sql: (0, utils_2.isSQL)(datasource) });
|
|
270
267
|
}
|
|
271
|
-
else
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
268
|
+
else {
|
|
269
|
+
return db.get(tableId);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
exports.getTable = getTable;
|
|
274
|
+
function checkForViewUpdates(table, rename, deletedColumns) {
|
|
275
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
const views = yield (0, utils_3.getViews)();
|
|
277
|
+
const tableViews = views.filter(view => view.meta.tableId === table._id);
|
|
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;
|
|
278
286
|
needsUpdated = true;
|
|
279
287
|
}
|
|
280
|
-
//
|
|
281
|
-
if (view.meta.groupBy ===
|
|
282
|
-
|
|
288
|
+
// Update group by field if required
|
|
289
|
+
if (view.meta.groupBy === rename.old) {
|
|
290
|
+
view.meta.groupBy = rename.updated;
|
|
283
291
|
needsUpdated = true;
|
|
284
292
|
}
|
|
285
|
-
//
|
|
286
|
-
if (view.meta.filters
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
293
|
+
// Update filters if required
|
|
294
|
+
if (view.meta.filters) {
|
|
295
|
+
view.meta.filters.forEach((filter) => {
|
|
296
|
+
if (filter.key === rename.old) {
|
|
297
|
+
filter.key = rename.updated;
|
|
298
|
+
needsUpdated = true;
|
|
299
|
+
}
|
|
290
300
|
});
|
|
291
|
-
|
|
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;
|
|
292
315
|
needsUpdated = true;
|
|
293
316
|
}
|
|
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;
|
|
294
335
|
}
|
|
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;
|
|
336
|
+
table.views[view.name] = newViewTemplate.meta;
|
|
303
337
|
}
|
|
304
|
-
table.views[view.name] = newViewTemplate.meta;
|
|
305
338
|
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
exports.
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
exports.checkForViewUpdates = checkForViewUpdates;
|
|
342
|
+
function generateForeignKey(column, relatedTable) {
|
|
309
343
|
return `fk_${relatedTable.name}_${column.fieldName}`;
|
|
310
|
-
}
|
|
311
|
-
exports.
|
|
344
|
+
}
|
|
345
|
+
exports.generateForeignKey = generateForeignKey;
|
|
346
|
+
function generateJunctionTableName(column, table, relatedTable) {
|
|
312
347
|
return `jt_${table.name}_${relatedTable.name}_${column.name}_${column.fieldName}`;
|
|
313
|
-
}
|
|
314
|
-
exports.
|
|
348
|
+
}
|
|
349
|
+
exports.generateJunctionTableName = generateJunctionTableName;
|
|
350
|
+
function foreignKeyStructure(keyName, meta = null) {
|
|
315
351
|
const structure = {
|
|
316
|
-
type: FieldTypes.NUMBER,
|
|
352
|
+
type: constants_1.FieldTypes.NUMBER,
|
|
317
353
|
constraints: {},
|
|
318
354
|
name: keyName,
|
|
319
355
|
};
|
|
@@ -321,34 +357,40 @@ exports.foreignKeyStructure = (keyName, meta = null) => {
|
|
|
321
357
|
structure.meta = meta;
|
|
322
358
|
}
|
|
323
359
|
return structure;
|
|
324
|
-
}
|
|
325
|
-
exports.
|
|
326
|
-
|
|
327
|
-
|
|
360
|
+
}
|
|
361
|
+
exports.foreignKeyStructure = foreignKeyStructure;
|
|
362
|
+
function areSwitchableTypes(type1, type2) {
|
|
363
|
+
if (constants_2.SwitchableTypes.indexOf(type1) === -1 &&
|
|
364
|
+
constants_2.SwitchableTypes.indexOf(type2) === -1) {
|
|
328
365
|
return false;
|
|
329
366
|
}
|
|
330
|
-
for (let option of CanSwitchTypes) {
|
|
367
|
+
for (let option of constants_2.CanSwitchTypes) {
|
|
331
368
|
const index1 = option.indexOf(type1), index2 = option.indexOf(type2);
|
|
332
369
|
if (index1 !== -1 && index2 !== -1 && index1 !== index2) {
|
|
333
370
|
return true;
|
|
334
371
|
}
|
|
335
372
|
}
|
|
336
373
|
return false;
|
|
337
|
-
}
|
|
338
|
-
exports.
|
|
374
|
+
}
|
|
375
|
+
exports.areSwitchableTypes = areSwitchableTypes;
|
|
376
|
+
function hasTypeChanged(table, oldTable) {
|
|
339
377
|
if (!oldTable) {
|
|
340
378
|
return false;
|
|
341
379
|
}
|
|
342
|
-
|
|
380
|
+
let key;
|
|
381
|
+
let field;
|
|
382
|
+
for ([key, field] of Object.entries(oldTable.schema)) {
|
|
343
383
|
const oldType = field.type;
|
|
344
384
|
if (!table.schema[key]) {
|
|
345
385
|
continue;
|
|
346
386
|
}
|
|
347
387
|
const newType = table.schema[key].type;
|
|
348
|
-
if (oldType !== newType && !
|
|
388
|
+
if (oldType !== newType && !areSwitchableTypes(oldType, newType)) {
|
|
349
389
|
return true;
|
|
350
390
|
}
|
|
351
391
|
}
|
|
352
392
|
return false;
|
|
353
|
-
}
|
|
354
|
-
exports.
|
|
393
|
+
}
|
|
394
|
+
exports.hasTypeChanged = hasTypeChanged;
|
|
395
|
+
const _TableSaveFunctions = TableSaveFunctions;
|
|
396
|
+
exports.TableSaveFunctions = _TableSaveFunctions;
|
package/dist/api/index.js
CHANGED
|
@@ -10,12 +10,14 @@ 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");
|
|
13
14
|
const currentApp = require("../middleware/currentapp");
|
|
14
15
|
const compress = require("koa-compress");
|
|
15
16
|
const zlib = require("zlib");
|
|
16
17
|
const { mainRoutes, staticRoutes, publicRoutes } = require("./routes");
|
|
17
18
|
const pkg = require("../../package.json");
|
|
18
19
|
const env = require("../environment");
|
|
20
|
+
const { middleware: pro } = require("@budibase/pro");
|
|
19
21
|
const router = new Router();
|
|
20
22
|
router.get("/health", ctx => (ctx.status = 200));
|
|
21
23
|
router.get("/version", ctx => (ctx.body = pkg.version));
|
|
@@ -49,6 +51,7 @@ router
|
|
|
49
51
|
noTenancyRequired: true,
|
|
50
52
|
}))
|
|
51
53
|
.use(currentApp)
|
|
54
|
+
.use(pro.licensing())
|
|
52
55
|
.use(auditLog);
|
|
53
56
|
// error handling middleware
|
|
54
57
|
router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -57,10 +60,12 @@ router.use((ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
57
60
|
}
|
|
58
61
|
catch (err) {
|
|
59
62
|
ctx.status = err.status || err.statusCode || 500;
|
|
63
|
+
const error = errors.getPublicError(err);
|
|
60
64
|
ctx.body = {
|
|
61
65
|
message: err.message,
|
|
62
66
|
status: ctx.status,
|
|
63
67
|
validationErrors: err.validation,
|
|
68
|
+
error,
|
|
64
69
|
};
|
|
65
70
|
if (env.NODE_ENV !== "jest") {
|
|
66
71
|
ctx.log.error(err);
|