@budibase/server 2.2.12-alpha.5 → 2.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/aws-sdk.ts +0 -19
- package/__mocks__/node-fetch.ts +0 -78
- package/builder/assets/{index.fa480d5b.css → index.9cb087df.css} +2 -2
- package/builder/assets/{index.d930bfc5.js → index.ef02c146.js} +369 -372
- package/builder/index.html +2 -2
- package/coverage/clover.xml +5094 -5122
- package/coverage/coverage-final.json +265 -268
- package/coverage/lcov-report/index.html +215 -215
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/apikeys.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/application.ts.html +183 -258
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +11 -11
- package/coverage/lcov-report/src/api/controllers/automation.ts.html +51 -51
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +6 -6
- package/coverage/lcov-report/src/api/controllers/cloud.ts.html +79 -91
- package/coverage/lcov-report/src/api/controllers/component.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/datasource.ts.html +30 -30
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.ts.html +14 -17
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +19 -19
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +195 -141
- package/coverage/lcov-report/src/api/controllers/dev.ts.html +18 -18
- package/coverage/lcov-report/src/api/controllers/index.html +51 -51
- package/coverage/lcov-report/src/api/controllers/integration.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/layout.ts.html +6 -6
- package/coverage/lcov-report/src/api/controllers/metadata.ts.html +9 -9
- package/coverage/lcov-report/src/api/controllers/migrations.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/permission.ts.html +13 -13
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +19 -19
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +63 -63
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +72 -72
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +135 -150
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +55 -55
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +11 -11
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +18 -18
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +20 -20
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +16 -67
- package/coverage/lcov-report/src/api/controllers/public/index.html +15 -15
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +6 -6
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +10 -10
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +9 -9
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +11 -11
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +6 -6
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/openapi.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/query/import/sources/curl.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +10 -10
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +14 -14
- package/coverage/lcov-report/src/api/controllers/query/index.html +19 -19
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +60 -60
- package/coverage/lcov-report/src/api/controllers/query/validation.ts.html +9 -9
- package/coverage/lcov-report/src/api/controllers/role.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/routing.ts.html +6 -6
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +15 -12
- package/coverage/lcov-report/src/api/controllers/row/external.ts.html +20 -20
- package/coverage/lcov-report/src/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +14 -14
- package/coverage/lcov-report/src/api/controllers/row/internal.ts.html +52 -55
- package/coverage/lcov-report/src/api/controllers/row/internalSearch.ts.html +9 -9
- package/coverage/lcov-report/src/api/controllers/row/staticFormula.ts.html +12 -21
- package/coverage/lcov-report/src/api/controllers/row/utils.ts.html +14 -17
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +26 -26
- package/coverage/lcov-report/src/api/controllers/script.ts.html +18 -18
- package/coverage/lcov-report/src/api/controllers/static/index.html +11 -11
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +44 -32
- package/coverage/lcov-report/src/api/controllers/table/bulkFormula.ts.html +10 -10
- package/coverage/lcov-report/src/api/controllers/table/external.ts.html +14 -14
- package/coverage/lcov-report/src/api/controllers/table/index.html +19 -19
- package/coverage/lcov-report/src/api/controllers/table/index.ts.html +14 -14
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +17 -17
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +70 -52
- package/coverage/lcov-report/src/api/controllers/templates.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/user.ts.html +119 -119
- package/coverage/lcov-report/src/api/controllers/view/exporters.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/view/index.html +24 -24
- package/coverage/lcov-report/src/api/controllers/view/index.ts.html +77 -59
- package/coverage/lcov-report/src/api/controllers/view/utils.ts.html +22 -22
- package/coverage/lcov-report/src/api/controllers/view/viewBuilder.ts.html +69 -51
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +14 -14
- package/coverage/lcov-report/src/api/index.html +1 -1
- package/coverage/lcov-report/src/api/index.ts.html +33 -33
- package/coverage/lcov-report/src/api/routes/analytics.ts.html +7 -7
- package/coverage/lcov-report/src/api/routes/apikeys.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/application.ts.html +11 -44
- package/coverage/lcov-report/src/api/routes/auth.ts.html +6 -6
- package/coverage/lcov-report/src/api/routes/automation.ts.html +11 -11
- package/coverage/lcov-report/src/api/routes/backup.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/cloud.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/component.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/datasource.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/deploy.ts.html +11 -8
- package/coverage/lcov-report/src/api/routes/dev.ts.html +13 -13
- package/coverage/lcov-report/src/api/routes/index.html +7 -7
- package/coverage/lcov-report/src/api/routes/index.ts.html +37 -40
- package/coverage/lcov-report/src/api/routes/integration.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/layout.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/metadata.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/migrations.ts.html +7 -7
- package/coverage/lcov-report/src/api/routes/permission.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +14 -146
- package/coverage/lcov-report/src/api/routes/public/index.html +7 -7
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +52 -52
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +15 -15
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +16 -28
- package/coverage/lcov-report/src/api/routes/public/queries.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +12 -12
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +12 -12
- package/coverage/lcov-report/src/api/routes/public/tests/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/tests/utils.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +12 -12
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +19 -19
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/query.ts.html +11 -11
- package/coverage/lcov-report/src/api/routes/role.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/routing.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/row.ts.html +11 -11
- package/coverage/lcov-report/src/api/routes/screen.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/script.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/static.ts.html +14 -14
- package/coverage/lcov-report/src/api/routes/table.ts.html +11 -11
- package/coverage/lcov-report/src/api/routes/templates.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +15 -15
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.ts.html +24 -24
- package/coverage/lcov-report/src/api/routes/user.ts.html +9 -9
- package/coverage/lcov-report/src/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/utils/validators.ts.html +42 -42
- package/coverage/lcov-report/src/api/routes/view.ts.html +10 -10
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +10 -10
- package/coverage/lcov-report/src/app.ts.html +32 -32
- package/coverage/lcov-report/src/automations/actions.ts.html +25 -25
- package/coverage/lcov-report/src/automations/automationUtils.ts.html +19 -91
- package/coverage/lcov-report/src/automations/bullboard.ts.html +11 -11
- package/coverage/lcov-report/src/automations/index.html +19 -19
- package/coverage/lcov-report/src/automations/index.ts.html +13 -13
- package/coverage/lcov-report/src/automations/logging/index.html +1 -1
- package/coverage/lcov-report/src/automations/logging/index.ts.html +11 -11
- package/coverage/lcov-report/src/automations/steps/bash.ts.html +34 -34
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +7 -7
- package/coverage/lcov-report/src/automations/steps/delay.ts.html +5 -5
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +7 -7
- package/coverage/lcov-report/src/automations/steps/discord.ts.html +33 -33
- package/coverage/lcov-report/src/automations/steps/executeQuery.ts.html +35 -35
- package/coverage/lcov-report/src/automations/steps/executeScript.ts.html +31 -31
- package/coverage/lcov-report/src/automations/steps/filter.ts.html +6 -6
- package/coverage/lcov-report/src/automations/steps/index.html +83 -83
- package/coverage/lcov-report/src/automations/steps/integromat.ts.html +6 -6
- package/coverage/lcov-report/src/automations/steps/loop.ts.html +3 -3
- package/coverage/lcov-report/src/automations/steps/outgoingWebhook.ts.html +14 -14
- package/coverage/lcov-report/src/automations/steps/queryRows.ts.html +17 -17
- package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.ts.html +28 -28
- package/coverage/lcov-report/src/automations/steps/serverLog.ts.html +18 -18
- package/coverage/lcov-report/src/automations/steps/slack.ts.html +6 -6
- package/coverage/lcov-report/src/automations/steps/updateRow.ts.html +7 -7
- package/coverage/lcov-report/src/automations/steps/utils.ts.html +16 -16
- package/coverage/lcov-report/src/automations/steps/zapier.ts.html +22 -22
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +5 -5
- package/coverage/lcov-report/src/automations/tests/utilities/index.ts.html +26 -26
- package/coverage/lcov-report/src/automations/triggerInfo/app.ts.html +3 -3
- package/coverage/lcov-report/src/automations/triggerInfo/cron.ts.html +3 -3
- package/coverage/lcov-report/src/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/src/automations/triggerInfo/index.ts.html +8 -8
- package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.ts.html +3 -3
- package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.ts.html +3 -3
- package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.ts.html +3 -3
- package/coverage/lcov-report/src/automations/triggerInfo/webhook.ts.html +3 -3
- package/coverage/lcov-report/src/automations/triggers.ts.html +21 -21
- package/coverage/lcov-report/src/automations/utils.ts.html +56 -56
- package/coverage/lcov-report/src/constants/index.html +1 -1
- package/coverage/lcov-report/src/constants/index.ts.html +92 -92
- package/coverage/lcov-report/src/constants/layouts.ts.html +4 -4
- package/coverage/lcov-report/src/constants/screens.ts.html +5 -5
- package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.ts.html +23 -23
- package/coverage/lcov-report/src/db/defaultData/employeeImport.ts.html +2 -2
- package/coverage/lcov-report/src/db/defaultData/expensesImport.ts.html +2 -2
- package/coverage/lcov-report/src/db/defaultData/index.html +1 -1
- package/coverage/lcov-report/src/db/defaultData/inventoryImport.ts.html +2 -2
- package/coverage/lcov-report/src/db/defaultData/jobsImport.ts.html +2 -2
- package/coverage/lcov-report/src/db/dynamoClient.ts.html +16 -16
- package/coverage/lcov-report/src/db/inMemoryView.ts.html +5 -5
- package/coverage/lcov-report/src/db/index.html +19 -19
- package/coverage/lcov-report/src/db/index.ts.html +9 -9
- package/coverage/lcov-report/src/db/linkedRows/LinkController.ts.html +8 -8
- package/coverage/lcov-report/src/db/linkedRows/LinkDocument.ts.html +4 -4
- package/coverage/lcov-report/src/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/src/db/linkedRows/index.ts.html +15 -15
- package/coverage/lcov-report/src/db/linkedRows/linkUtils.ts.html +12 -12
- package/coverage/lcov-report/src/db/newid.ts.html +4 -4
- package/coverage/lcov-report/src/db/utils.ts.html +80 -80
- package/coverage/lcov-report/src/definitions/automations.ts.html +4 -4
- package/coverage/lcov-report/src/definitions/datasource.ts.html +4 -4
- package/coverage/lcov-report/src/definitions/index.html +1 -1
- package/coverage/lcov-report/src/environment.ts.html +28 -40
- package/coverage/lcov-report/src/events/AutomationEmitter.ts.html +6 -6
- package/coverage/lcov-report/src/events/BudibaseEmitter.ts.html +5 -5
- package/coverage/lcov-report/src/events/index.html +1 -1
- package/coverage/lcov-report/src/events/index.ts.html +4 -4
- package/coverage/lcov-report/src/events/utils.ts.html +3 -3
- package/coverage/lcov-report/src/index.html +25 -25
- package/coverage/lcov-report/src/index.ts.html +1 -1
- package/coverage/lcov-report/src/integrations/airtable.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/base/index.html +1 -1
- package/coverage/lcov-report/src/integrations/base/query.ts.html +3 -3
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +14 -14
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +8 -8
- package/coverage/lcov-report/src/integrations/base/utils.ts.html +3 -3
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/dynamodb.ts.html +6 -6
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/firebase.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +12 -12
- package/coverage/lcov-report/src/integrations/index.html +5 -5
- package/coverage/lcov-report/src/integrations/index.ts.html +47 -35
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +8 -8
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/mysql.ts.html +10 -10
- package/coverage/lcov-report/src/integrations/oracle.ts.html +13 -13
- package/coverage/lcov-report/src/integrations/postgres.ts.html +42 -42
- package/coverage/lcov-report/src/integrations/queries/index.html +1 -1
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +13 -13
- package/coverage/lcov-report/src/integrations/redis.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/rest.ts.html +16 -16
- package/coverage/lcov-report/src/integrations/s3.ts.html +6 -6
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/src/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/src/integrations/utils.ts.html +36 -36
- package/coverage/lcov-report/src/middleware/appInfo.ts.html +7 -7
- package/coverage/lcov-report/src/middleware/authorized.ts.html +28 -28
- package/coverage/lcov-report/src/middleware/builder.ts.html +17 -17
- package/coverage/lcov-report/src/middleware/currentapp.ts.html +39 -39
- package/coverage/lcov-report/src/middleware/index.html +1 -1
- package/coverage/lcov-report/src/middleware/joi-validator.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/publicApi.ts.html +4 -4
- package/coverage/lcov-report/src/middleware/resourceId.ts.html +22 -22
- package/coverage/lcov-report/src/middleware/selfhost.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/utils.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/backfill/app/queries.ts.html +7 -7
- package/coverage/lcov-report/src/migrations/functions/backfill/app/roles.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +19 -19
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +10 -13
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +7 -7
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +6 -6
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +15 -15
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +8 -8
- package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +6 -6
- package/coverage/lcov-report/src/migrations/functions/tableSettings.ts.html +6 -6
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +2 -2
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +6 -6
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.ts.html +32 -32
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/index.html +1 -1
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/applications/index.html +15 -15
- package/coverage/lcov-report/src/sdk/app/applications/index.ts.html +4 -4
- package/coverage/lcov-report/src/sdk/app/applications/sync.ts.html +34 -34
- package/coverage/lcov-report/src/sdk/app/applications/utils.ts.html +9 -9
- package/coverage/lcov-report/src/sdk/app/automations/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/automations/index.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/automations/webhook.ts.html +6 -6
- package/coverage/lcov-report/src/sdk/app/backups/constants.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/backups/exports.ts.html +17 -17
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +53 -41
- package/coverage/lcov-report/src/sdk/app/backups/index.html +28 -28
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +5 -5
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +73 -73
- package/coverage/lcov-report/src/sdk/app/rows/attachments.ts.html +6 -6
- package/coverage/lcov-report/src/sdk/app/rows/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/rows/index.ts.html +4 -4
- package/coverage/lcov-report/src/sdk/app/rows/rows.ts.html +4 -4
- package/coverage/lcov-report/src/sdk/app/tables/index.html +1 -1
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +5 -5
- package/coverage/lcov-report/src/sdk/index.html +1 -1
- package/coverage/lcov-report/src/sdk/index.ts.html +9 -9
- package/coverage/lcov-report/src/sdk/users/index.html +5 -5
- package/coverage/lcov-report/src/sdk/users/index.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/users/utils.ts.html +34 -34
- package/coverage/lcov-report/src/startup.ts.html +42 -42
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.ts.html +125 -182
- package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +15 -15
- package/coverage/lcov-report/src/tests/utilities/index.html +15 -15
- package/coverage/lcov-report/src/tests/utilities/index.ts.html +1 -1
- package/coverage/lcov-report/src/tests/utilities/structures.ts.html +30 -30
- package/coverage/lcov-report/src/threads/automation.ts.html +103 -34
- package/coverage/lcov-report/src/threads/index.html +19 -19
- package/coverage/lcov-report/src/threads/index.ts.html +25 -25
- package/coverage/lcov-report/src/threads/query.ts.html +71 -71
- package/coverage/lcov-report/src/threads/utils.ts.html +18 -18
- package/coverage/lcov-report/src/utilities/budibaseDir.ts.html +3 -3
- package/coverage/lcov-report/src/utilities/centralPath.ts.html +4 -4
- package/coverage/lcov-report/src/utilities/csvParser.ts.html +8 -8
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +12 -12
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +19 -79
- package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +1049 -20
- package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/global.ts.html +43 -43
- package/coverage/lcov-report/src/utilities/index.html +63 -48
- package/coverage/lcov-report/src/utilities/index.ts.html +168 -36
- package/coverage/lcov-report/src/utilities/plugins.ts.html +151 -0
- package/coverage/lcov-report/src/utilities/redis.ts.html +32 -32
- package/coverage/lcov-report/src/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.ts.html +5 -5
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +28 -28
- package/coverage/lcov-report/src/utilities/rowProcessor/index.ts.html +33 -60
- package/coverage/lcov-report/src/utilities/rowProcessor/map.ts.html +3 -3
- package/coverage/lcov-report/src/utilities/rowProcessor/utils.ts.html +38 -38
- package/coverage/lcov-report/src/utilities/scriptRunner.ts.html +32 -32
- package/coverage/lcov-report/src/utilities/security.ts.html +6 -6
- package/coverage/lcov-report/src/utilities/statusCodes.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/src/utilities/usageQuota/rows.ts.html +35 -35
- package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/users.ts.html +6 -6
- package/coverage/lcov-report/src/utilities/workerRequests.ts.html +56 -56
- package/coverage/lcov-report/src/watch.ts.html +9 -9
- package/coverage/lcov-report/src/websocket.ts.html +15 -15
- package/coverage/lcov.info +7320 -7367
- package/dist/api/controllers/application.js +35 -47
- package/dist/api/controllers/cloud.js +2 -6
- package/dist/api/controllers/deploy/index.js +60 -43
- package/dist/api/controllers/plugin/index.js +6 -6
- package/dist/api/controllers/public/applications.js +1 -22
- package/dist/api/controllers/row/ExternalRequest.js +1 -0
- package/dist/api/controllers/row/internal.js +12 -12
- package/dist/api/controllers/row/staticFormula.js +1 -1
- package/dist/api/controllers/static/index.js +11 -8
- package/dist/api/controllers/table/utils.js +2 -1
- package/dist/api/controllers/view/index.js +6 -5
- package/dist/api/controllers/view/viewBuilder.js +8 -2
- package/dist/api/routes/application.js +0 -3
- package/dist/api/routes/deploy.js +2 -1
- package/dist/api/routes/public/applications.js +0 -37
- package/dist/api/routes/public/middleware/mapper.js +0 -3
- package/dist/api/routes/tests/utilities/TestFunctions.js +167 -0
- package/dist/api/routes/tests/utilities/index.js +131 -0
- package/dist/automations/automationUtils.js +1 -26
- package/dist/automations/tests/utilities/index.js +81 -0
- package/dist/environment.js +1 -5
- package/dist/integrations/googlesheets.js +1 -1
- package/dist/integrations/index.js +2 -1
- package/dist/migrations/functions/backfill/global/configs.js +4 -4
- package/dist/package.json +7 -9
- package/dist/sdk/app/backups/imports.js +6 -2
- package/dist/tests/utilities/TestConfiguration.js +562 -0
- package/dist/tests/utilities/controllers.js +40 -0
- package/dist/tests/utilities/structures.js +168 -0
- package/dist/threads/automation.js +28 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/clientLibrary.js +3 -3
- package/dist/utilities/fileSystem/index.js +342 -18
- package/dist/utilities/index.js +44 -1
- package/dist/utilities/plugins.js +26 -0
- package/dist/utilities/rowProcessor/index.js +4 -12
- package/package.json +8 -10
- package/scripts/dev/manage.js +16 -0
- package/specs/openapi.json +0 -84
- package/specs/openapi.yaml +0 -53
- package/specs/resources/application.js +0 -19
- package/src/api/controllers/application.ts +36 -61
- package/src/api/controllers/auth.ts +2 -2
- package/src/api/controllers/cloud.ts +6 -10
- package/src/api/controllers/deploy/Deployment.ts +0 -1
- package/src/api/controllers/deploy/index.ts +58 -40
- package/src/api/controllers/plugin/index.ts +9 -14
- package/src/api/controllers/public/applications.ts +0 -17
- package/src/api/controllers/row/ExternalRequest.ts +1 -0
- package/src/api/controllers/row/internal.ts +23 -24
- package/src/api/controllers/row/staticFormula.ts +2 -5
- package/src/api/controllers/row/utils.ts +1 -2
- package/src/api/controllers/static/index.ts +10 -6
- package/src/api/controllers/table/utils.ts +7 -1
- package/src/api/controllers/view/index.ts +11 -5
- package/src/api/controllers/view/viewBuilder.ts +14 -8
- package/src/api/routes/application.ts +0 -11
- package/src/api/routes/deploy.ts +1 -0
- package/src/api/routes/index.ts +3 -4
- package/src/api/routes/public/applications.ts +0 -44
- package/src/api/routes/public/middleware/mapper.ts +0 -4
- package/src/api/routes/tests/__snapshots__/{datasource.spec.ts.snap → datasource.spec.js.snap} +0 -0
- package/src/api/routes/tests/{application.spec.ts → application.spec.js} +18 -94
- package/src/api/routes/tests/{backup.spec.ts → backup.spec.js} +6 -17
- package/src/api/routes/tests/{datasource.spec.ts → datasource.spec.js} +15 -23
- package/src/api/routes/tests/deployment.spec.ts +25 -0
- package/src/api/routes/tests/permissions.spec.js +1 -1
- package/src/api/routes/tests/routing.spec.js +2 -1
- package/src/api/routes/tests/row.spec.js +2 -4
- package/src/api/routes/tests/static.spec.js +17 -2
- package/src/api/routes/tests/table.spec.js +2 -8
- package/src/api/routes/tests/user.spec.js +0 -86
- package/src/api/routes/tests/utilities/index.ts +2 -2
- package/src/api/routes/tests/webhook.spec.js +1 -1
- package/src/automations/automationUtils.ts +0 -24
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/unitTests/automationUtils.spec.js +17 -0
- package/src/definitions/openapi.ts +0 -10
- package/src/environment.ts +1 -5
- package/src/integrations/googlesheets.ts +1 -1
- package/src/integrations/index.ts +5 -1
- package/src/migrations/functions/backfill/global/configs.ts +4 -5
- package/src/sdk/app/backups/imports.ts +6 -2
- package/src/sdk/tests/attachments.spec.ts +4 -1
- package/src/tests/jestSetup.ts +1 -4
- package/src/tests/utilities/TestConfiguration.ts +4 -23
- package/src/threads/automation.ts +27 -4
- package/src/utilities/fileSystem/clientLibrary.ts +1 -1
- package/src/utilities/fileSystem/index.ts +348 -5
- package/src/utilities/index.ts +45 -1
- package/src/utilities/plugins.ts +22 -0
- package/src/utilities/rowProcessor/index.ts +8 -17
- package/tsconfig.build.json +0 -2
- package/coverage/lcov-report/src/utilities/fileSystem/app.ts.html +0 -343
- package/coverage/lcov-report/src/utilities/fileSystem/filesystem.ts.html +0 -595
- package/coverage/lcov-report/src/utilities/fileSystem/plugin.ts.html +0 -280
- package/coverage/lcov-report/src/utilities/fileSystem/template.ts.html +0 -193
- package/dist/utilities/fileSystem/app.js +0 -97
- package/dist/utilities/fileSystem/filesystem.js +0 -182
- package/dist/utilities/fileSystem/plugin.js +0 -63
- package/dist/utilities/fileSystem/template.js +0 -44
- package/src/api/routes/tests/cloud.spec.ts +0 -65
- package/src/api/routes/tests/data/budibase-component-1.0.1.tgz +0 -0
- package/src/api/routes/tests/data/comment-box-1.0.2.tar.gz +0 -0
- package/src/api/routes/tests/data/export-test.tar.gz +0 -0
- package/src/api/routes/tests/plugin.spec.ts +0 -179
- package/src/automations/tests/bash.spec.js +0 -34
- package/src/automations/tests/discord.spec.js +0 -27
- package/src/automations/tests/executeQuery.spec.js +0 -49
- package/src/automations/tests/executeScript.spec.js +0 -48
- package/src/automations/tests/sendSmtpEmail.spec.js +0 -71
- package/src/automations/tests/serverLog.spec.js +0 -22
- package/src/automations/tests/zapier.spec.js +0 -27
- package/src/automations/unitTests/automationUtils.spec.ts +0 -65
- package/src/utilities/fileSystem/app.ts +0 -86
- package/src/utilities/fileSystem/filesystem.ts +0 -170
- package/src/utilities/fileSystem/plugin.ts +0 -65
- package/src/utilities/fileSystem/template.ts +0 -36
- package/src/utilities/rowProcessor/tests/utils.spec.ts +0 -57
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import { mocks } from "@budibase/backend-core/tests"
|
|
2
|
-
|
|
3
|
-
// init the licensing mock
|
|
4
|
-
import * as pro from "@budibase/pro"
|
|
5
|
-
mocks.licenses.init(pro)
|
|
6
|
-
|
|
7
|
-
// use unlimited license by default
|
|
8
|
-
mocks.licenses.useUnlimited()
|
|
9
|
-
|
|
10
1
|
import { init as dbInit } from "../../db"
|
|
11
2
|
dbInit()
|
|
12
3
|
import env from "../../environment"
|
|
@@ -360,6 +351,7 @@ class TestConfiguration {
|
|
|
360
351
|
}
|
|
361
352
|
|
|
362
353
|
// APP
|
|
354
|
+
|
|
363
355
|
async createApp(appName: string) {
|
|
364
356
|
// create dev app
|
|
365
357
|
// clear any old app
|
|
@@ -372,7 +364,7 @@ class TestConfiguration {
|
|
|
372
364
|
await context.updateAppId(this.appId)
|
|
373
365
|
|
|
374
366
|
// create production app
|
|
375
|
-
this.prodApp = await this.
|
|
367
|
+
this.prodApp = await this.deploy()
|
|
376
368
|
|
|
377
369
|
this.allApps.push(this.prodApp)
|
|
378
370
|
this.allApps.push(this.app)
|
|
@@ -380,8 +372,8 @@ class TestConfiguration {
|
|
|
380
372
|
return this.app
|
|
381
373
|
}
|
|
382
374
|
|
|
383
|
-
async
|
|
384
|
-
await this._req(null, null, controllers.deploy.
|
|
375
|
+
async deploy() {
|
|
376
|
+
await this._req(null, null, controllers.deploy.deployApp)
|
|
385
377
|
// @ts-ignore
|
|
386
378
|
const prodAppId = this.getAppId().replace("_dev", "")
|
|
387
379
|
this.prodAppId = prodAppId
|
|
@@ -392,17 +384,6 @@ class TestConfiguration {
|
|
|
392
384
|
})
|
|
393
385
|
}
|
|
394
386
|
|
|
395
|
-
async unpublish() {
|
|
396
|
-
const response = await this._req(
|
|
397
|
-
null,
|
|
398
|
-
{ appId: this.appId },
|
|
399
|
-
controllers.app.unpublish
|
|
400
|
-
)
|
|
401
|
-
this.prodAppId = null
|
|
402
|
-
this.prodApp = null
|
|
403
|
-
return response
|
|
404
|
-
}
|
|
405
|
-
|
|
406
387
|
// TABLE
|
|
407
388
|
|
|
408
389
|
async updateTable(config?: any) {
|
|
@@ -32,8 +32,31 @@ const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId
|
|
|
32
32
|
const CRON_STEP_ID = triggerDefs.CRON.stepId
|
|
33
33
|
const STOPPED_STATUS = { success: true, status: AutomationStatus.STOPPED }
|
|
34
34
|
|
|
35
|
+
function typecastForLooping(loopStep: LoopStep, input: LoopInput) {
|
|
36
|
+
if (!input || !input.binding) {
|
|
37
|
+
return null
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
switch (loopStep.inputs.option) {
|
|
41
|
+
case LoopStepType.ARRAY:
|
|
42
|
+
if (typeof input.binding === "string") {
|
|
43
|
+
return JSON.parse(input.binding)
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case LoopStepType.STRING:
|
|
47
|
+
if (Array.isArray(input.binding)) {
|
|
48
|
+
return input.binding.join(",")
|
|
49
|
+
}
|
|
50
|
+
break
|
|
51
|
+
}
|
|
52
|
+
} catch (err) {
|
|
53
|
+
throw new Error("Unable to cast to correct type")
|
|
54
|
+
}
|
|
55
|
+
return input.binding
|
|
56
|
+
}
|
|
57
|
+
|
|
35
58
|
function getLoopIterations(loopStep: LoopStep, input: LoopInput) {
|
|
36
|
-
const binding =
|
|
59
|
+
const binding = typecastForLooping(loopStep, input)
|
|
37
60
|
if (!loopStep || !binding) {
|
|
38
61
|
return 1
|
|
39
62
|
}
|
|
@@ -266,7 +289,7 @@ class Orchestrator {
|
|
|
266
289
|
|
|
267
290
|
let tempOutput = { items: loopSteps, iterations: iterationCount }
|
|
268
291
|
try {
|
|
269
|
-
newInput.binding =
|
|
292
|
+
newInput.binding = typecastForLooping(
|
|
270
293
|
loopStep as LoopStep,
|
|
271
294
|
newInput
|
|
272
295
|
)
|
|
@@ -419,7 +442,7 @@ class Orchestrator {
|
|
|
419
442
|
|
|
420
443
|
// Delete the step after the loop step as it's irrelevant, since information is included
|
|
421
444
|
// in the loop step
|
|
422
|
-
if (wasLoopStep
|
|
445
|
+
if (wasLoopStep) {
|
|
423
446
|
this._context.steps.splice(loopStepNumber + 1, 1)
|
|
424
447
|
wasLoopStep = false
|
|
425
448
|
}
|
|
@@ -438,8 +461,8 @@ class Orchestrator {
|
|
|
438
461
|
})
|
|
439
462
|
this._context.steps[loopStepNumber] = tempOutput
|
|
440
463
|
|
|
464
|
+
loopSteps = undefined
|
|
441
465
|
wasLoopStep = true
|
|
442
|
-
loopSteps = []
|
|
443
466
|
}
|
|
444
467
|
}
|
|
445
468
|
|
|
@@ -4,7 +4,7 @@ import fs from "fs"
|
|
|
4
4
|
import { objectStore } from "@budibase/backend-core"
|
|
5
5
|
import { resolve } from "../centralPath"
|
|
6
6
|
import env from "../../environment"
|
|
7
|
-
|
|
7
|
+
const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..")
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Client library paths in the object store:
|
|
@@ -1,5 +1,348 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { budibaseTempDir } from "../budibaseDir"
|
|
2
|
+
import fs from "fs"
|
|
3
|
+
import { join } from "path"
|
|
4
|
+
import { context, objectStore } from "@budibase/backend-core"
|
|
5
|
+
import { ObjectStoreBuckets } from "../../constants"
|
|
6
|
+
import { updateClientLibrary } from "./clientLibrary"
|
|
7
|
+
import { checkSlashesInUrl } from "../"
|
|
8
|
+
import env from "../../environment"
|
|
9
|
+
import fetch from "node-fetch"
|
|
10
|
+
const uuid = require("uuid/v4")
|
|
11
|
+
const tar = require("tar")
|
|
12
|
+
|
|
13
|
+
export const TOP_LEVEL_PATH = join(__dirname, "..", "..", "..")
|
|
14
|
+
export const NODE_MODULES_PATH = join(TOP_LEVEL_PATH, "node_modules")
|
|
15
|
+
const DATASOURCE_PATH = join(budibaseTempDir(), "datasource")
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The single stack system (Cloud and Builder) should not make use of the file system where possible,
|
|
19
|
+
* this file handles all of the file access for the system with the intention of limiting it all to one
|
|
20
|
+
* place. Keeping all of this logic in one place means that when we need to do file system access (like
|
|
21
|
+
* downloading a package or opening a temporary file) in can be done in way that we can confirm it shouldn't
|
|
22
|
+
* be done through an object store instead.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Upon first startup of instance there may not be everything we need in tmp directory, set it up.
|
|
27
|
+
*/
|
|
28
|
+
export function init() {
|
|
29
|
+
const tempDir = budibaseTempDir()
|
|
30
|
+
if (!fs.existsSync(tempDir)) {
|
|
31
|
+
// some test cases fire this quickly enough that
|
|
32
|
+
// synchronous cases can end up here at the same time
|
|
33
|
+
try {
|
|
34
|
+
fs.mkdirSync(tempDir)
|
|
35
|
+
} catch (err: any) {
|
|
36
|
+
if (!err || err.code !== "EEXIST") {
|
|
37
|
+
throw err
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const clientLibPath = join(budibaseTempDir(), "budibase-client.js")
|
|
42
|
+
if (env.isTest() && !fs.existsSync(clientLibPath)) {
|
|
43
|
+
fs.copyFileSync(require.resolve("@budibase/client"), clientLibPath)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the system is currently in development mode and if it is makes sure
|
|
49
|
+
* everything required to function is ready.
|
|
50
|
+
*/
|
|
51
|
+
exports.checkDevelopmentEnvironment = () => {
|
|
52
|
+
if (!env.isDev() || env.isTest()) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
if (!fs.existsSync(budibaseTempDir())) {
|
|
56
|
+
fs.mkdirSync(budibaseTempDir())
|
|
57
|
+
}
|
|
58
|
+
let error
|
|
59
|
+
if (!fs.existsSync(join(process.cwd(), ".env"))) {
|
|
60
|
+
error = "Must run via yarn once to generate environment."
|
|
61
|
+
}
|
|
62
|
+
if (error) {
|
|
63
|
+
console.error(error)
|
|
64
|
+
process.exit(-1)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Used to retrieve a handlebars file from the system which will be used as a template.
|
|
70
|
+
* This is allowable as the template handlebars files should be static and identical across
|
|
71
|
+
* the cluster.
|
|
72
|
+
* @param {string} path The path to the handlebars file which is to be loaded.
|
|
73
|
+
* @returns {string} The loaded handlebars file as a string - loaded as utf8.
|
|
74
|
+
*/
|
|
75
|
+
export function loadHandlebarsFile(path: string) {
|
|
76
|
+
return fs.readFileSync(path, "utf8")
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* When return a file from the API need to write the file to the system temporarily so we
|
|
81
|
+
* can create a read stream to send.
|
|
82
|
+
* @param {string} contents the contents of the file which is to be returned from the API.
|
|
83
|
+
* @param {string} encoding the encoding of the file to return (utf8 default)
|
|
84
|
+
* @return {Object} the read stream which can be put into the koa context body.
|
|
85
|
+
*/
|
|
86
|
+
export function apiFileReturn(
|
|
87
|
+
contents: string,
|
|
88
|
+
encoding: BufferEncoding = "utf8"
|
|
89
|
+
) {
|
|
90
|
+
const path = join(budibaseTempDir(), uuid())
|
|
91
|
+
fs.writeFileSync(path, contents, { encoding })
|
|
92
|
+
return fs.createReadStream(path, { encoding })
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function streamFile(path: string) {
|
|
96
|
+
return fs.createReadStream(path)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Writes the provided contents to a temporary file, which can be used briefly.
|
|
101
|
+
* @param {string} fileContents contents which will be written to a temp file.
|
|
102
|
+
* @return {string} the path to the temp file.
|
|
103
|
+
*/
|
|
104
|
+
export function storeTempFile(fileContents: string) {
|
|
105
|
+
const path = join(budibaseTempDir(), uuid())
|
|
106
|
+
fs.writeFileSync(path, fileContents)
|
|
107
|
+
return path
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Utility function for getting a file read stream - a simple in memory buffered read
|
|
112
|
+
* stream doesn't work for pouchdb.
|
|
113
|
+
*/
|
|
114
|
+
export function stringToFileStream(contents: string) {
|
|
115
|
+
const path = exports.storeTempFile(contents)
|
|
116
|
+
return fs.createReadStream(path)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Creates a temp file and returns it from the API.
|
|
121
|
+
* @param {string} fileContents the contents to be returned in file.
|
|
122
|
+
*/
|
|
123
|
+
export function sendTempFile(fileContents: string) {
|
|
124
|
+
const path = exports.storeTempFile(fileContents)
|
|
125
|
+
return fs.createReadStream(path)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Uploads the latest client library to the object store.
|
|
130
|
+
* @param {string} appId The ID of the app which is being created.
|
|
131
|
+
* @return {Promise<void>} once promise completes app resources should be ready in object store.
|
|
132
|
+
*/
|
|
133
|
+
export async function createApp(appId: string) {
|
|
134
|
+
await updateClientLibrary(appId)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Removes all of the assets created for an app in the object store.
|
|
139
|
+
* @param {string} appId The ID of the app which is being deleted.
|
|
140
|
+
* @return {Promise<void>} once promise completes the app resources will be removed from object store.
|
|
141
|
+
*/
|
|
142
|
+
export async function deleteApp(appId: string) {
|
|
143
|
+
await objectStore.deleteFolder(ObjectStoreBuckets.APPS, `${appId}/`)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves a template and pipes it to minio as well as making it available temporarily.
|
|
148
|
+
* @param {string} type The type of template which is to be retrieved.
|
|
149
|
+
* @param name
|
|
150
|
+
* @return {Promise<*>}
|
|
151
|
+
*/
|
|
152
|
+
export async function downloadTemplate(type: string, name: string) {
|
|
153
|
+
const DEFAULT_TEMPLATES_BUCKET =
|
|
154
|
+
"prod-budi-templates.s3-eu-west-1.amazonaws.com"
|
|
155
|
+
const templateUrl = `https://${DEFAULT_TEMPLATES_BUCKET}/templates/${type}/${name}.tar.gz`
|
|
156
|
+
return objectStore.downloadTarball(
|
|
157
|
+
templateUrl,
|
|
158
|
+
ObjectStoreBuckets.TEMPLATES,
|
|
159
|
+
type
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Retrieves component libraries from object store (or tmp symlink if in local)
|
|
165
|
+
*/
|
|
166
|
+
export async function getComponentLibraryManifest(library: string) {
|
|
167
|
+
const appId = context.getAppId()
|
|
168
|
+
const filename = "manifest.json"
|
|
169
|
+
/* istanbul ignore next */
|
|
170
|
+
// when testing in cypress and so on we need to get the package
|
|
171
|
+
// as the environment may not be fully fleshed out for dev or prod
|
|
172
|
+
if (env.isTest()) {
|
|
173
|
+
library = library.replace("standard-components", "client")
|
|
174
|
+
const lib = library.split("/")[1]
|
|
175
|
+
const path = require.resolve(library).split(lib)[0]
|
|
176
|
+
return require(join(path, lib, filename))
|
|
177
|
+
} else if (env.isDev()) {
|
|
178
|
+
const path = join(NODE_MODULES_PATH, "@budibase", "client", filename)
|
|
179
|
+
// always load from new so that updates are refreshed
|
|
180
|
+
delete require.cache[require.resolve(path)]
|
|
181
|
+
return require(path)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!appId) {
|
|
185
|
+
throw new Error("No app ID found - cannot get component libraries")
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
let resp
|
|
189
|
+
let path
|
|
190
|
+
try {
|
|
191
|
+
// Try to load the manifest from the new file location
|
|
192
|
+
path = join(appId, filename)
|
|
193
|
+
resp = await objectStore.retrieve(ObjectStoreBuckets.APPS, path)
|
|
194
|
+
} catch (error) {
|
|
195
|
+
console.error(
|
|
196
|
+
`component-manifest-objectstore=failed appId=${appId} path=${path}`,
|
|
197
|
+
error
|
|
198
|
+
)
|
|
199
|
+
// Fallback to loading it from the old location for old apps
|
|
200
|
+
path = join(appId, "node_modules", library, "package", filename)
|
|
201
|
+
resp = await objectStore.retrieve(ObjectStoreBuckets.APPS, path)
|
|
202
|
+
}
|
|
203
|
+
if (typeof resp !== "string") {
|
|
204
|
+
resp = resp.toString("utf8")
|
|
205
|
+
}
|
|
206
|
+
return JSON.parse(resp)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* All file reads come through here just to make sure all of them make sense
|
|
211
|
+
* allows a centralised location to check logic is all good.
|
|
212
|
+
*/
|
|
213
|
+
export function readFileSync(
|
|
214
|
+
filepath: string,
|
|
215
|
+
options: BufferEncoding = "utf8"
|
|
216
|
+
) {
|
|
217
|
+
return fs.readFileSync(filepath, { encoding: options })
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Given a set of app IDs makes sure file system is cleared of any of their temp info.
|
|
222
|
+
*/
|
|
223
|
+
export function cleanup(appIds: string[]) {
|
|
224
|
+
for (let appId of appIds) {
|
|
225
|
+
const path = join(budibaseTempDir(), appId)
|
|
226
|
+
if (fs.existsSync(path)) {
|
|
227
|
+
fs.rmdirSync(path, { recursive: true })
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function createTempFolder(item: string) {
|
|
233
|
+
const path = join(budibaseTempDir(), item)
|
|
234
|
+
try {
|
|
235
|
+
// remove old tmp directories automatically - don't combine
|
|
236
|
+
if (fs.existsSync(path)) {
|
|
237
|
+
fs.rmSync(path, { recursive: true, force: true })
|
|
238
|
+
}
|
|
239
|
+
fs.mkdirSync(path)
|
|
240
|
+
} catch (err: any) {
|
|
241
|
+
throw new Error(`Path cannot be created: ${err.message}`)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return path
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export async function extractTarball(fromFilePath: string, toPath: string) {
|
|
248
|
+
await tar.extract({
|
|
249
|
+
file: fromFilePath,
|
|
250
|
+
C: toPath,
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export async function getPluginMetadata(path: string) {
|
|
255
|
+
let metadata: { schema?: any; package?: any } = {}
|
|
256
|
+
try {
|
|
257
|
+
const pkg = fs.readFileSync(join(path, "package.json"), "utf8")
|
|
258
|
+
const schema = fs.readFileSync(join(path, "schema.json"), "utf8")
|
|
259
|
+
|
|
260
|
+
metadata.schema = JSON.parse(schema)
|
|
261
|
+
metadata.package = JSON.parse(pkg)
|
|
262
|
+
|
|
263
|
+
if (
|
|
264
|
+
!metadata.package.name ||
|
|
265
|
+
!metadata.package.version ||
|
|
266
|
+
!metadata.package.description
|
|
267
|
+
) {
|
|
268
|
+
throw new Error(
|
|
269
|
+
"package.json is missing one of 'name', 'version' or 'description'."
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
} catch (err: any) {
|
|
273
|
+
throw new Error(
|
|
274
|
+
`Unable to process schema.json/package.json in plugin. ${err.message}`
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return { metadata, directory: path }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
export async function getDatasourcePlugin(
|
|
282
|
+
name: string,
|
|
283
|
+
url: string,
|
|
284
|
+
hash: string
|
|
285
|
+
) {
|
|
286
|
+
if (!fs.existsSync(DATASOURCE_PATH)) {
|
|
287
|
+
fs.mkdirSync(DATASOURCE_PATH)
|
|
288
|
+
}
|
|
289
|
+
const filename = join(DATASOURCE_PATH, name)
|
|
290
|
+
const metadataName = `${filename}.bbmetadata`
|
|
291
|
+
if (fs.existsSync(filename)) {
|
|
292
|
+
const currentHash = fs.readFileSync(metadataName, "utf8")
|
|
293
|
+
// if hash is the same return the file, otherwise remove it and re-download
|
|
294
|
+
if (currentHash === hash) {
|
|
295
|
+
return require(filename)
|
|
296
|
+
} else {
|
|
297
|
+
console.log(`Updating plugin: ${name}`)
|
|
298
|
+
delete require.cache[require.resolve(filename)]
|
|
299
|
+
fs.unlinkSync(filename)
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const fullUrl = checkSlashesInUrl(
|
|
303
|
+
`${env.MINIO_URL}/${ObjectStoreBuckets.PLUGINS}/${url}`
|
|
304
|
+
)
|
|
305
|
+
const response = await fetch(fullUrl)
|
|
306
|
+
if (response.status === 200) {
|
|
307
|
+
const content = await response.text()
|
|
308
|
+
fs.writeFileSync(filename, content)
|
|
309
|
+
fs.writeFileSync(metadataName, hash)
|
|
310
|
+
return require(filename)
|
|
311
|
+
} else {
|
|
312
|
+
throw new Error(
|
|
313
|
+
`Unable to retrieve plugin - reason: ${await response.text()}`
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Find for a file recursively from start path applying filter, return first match
|
|
320
|
+
*/
|
|
321
|
+
export function findFileRec(startPath: string, filter: any) {
|
|
322
|
+
if (!fs.existsSync(startPath)) {
|
|
323
|
+
return
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
const files = fs.readdirSync(startPath)
|
|
327
|
+
for (let i = 0, len = files.length; i < len; i++) {
|
|
328
|
+
const filename = join(startPath, files[i])
|
|
329
|
+
const stat = fs.lstatSync(filename)
|
|
330
|
+
|
|
331
|
+
if (stat.isDirectory()) {
|
|
332
|
+
return exports.findFileRec(filename, filter)
|
|
333
|
+
} else if (filename.endsWith(filter)) {
|
|
334
|
+
return filename
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Remove a folder which is not empty from the file system
|
|
341
|
+
*/
|
|
342
|
+
export function deleteFolderFileSystem(path: string) {
|
|
343
|
+
if (!fs.existsSync(path)) {
|
|
344
|
+
return
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
fs.rmSync(path, { recursive: true, force: true })
|
|
348
|
+
}
|
package/src/utilities/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import env from "../environment"
|
|
2
|
-
import {
|
|
2
|
+
import { OBJ_STORE_DIRECTORY } from "../constants"
|
|
3
|
+
import { objectStore, context } from "@budibase/backend-core"
|
|
3
4
|
import { generateMetadataID } from "../db/utils"
|
|
4
5
|
import { Document } from "@budibase/types"
|
|
5
6
|
import stream from "stream"
|
|
@@ -31,6 +32,49 @@ export function checkSlashesInUrl(url: string) {
|
|
|
31
32
|
return url.replace(/(https?:\/\/)|(\/)+/g, "$1$2")
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Gets the address of the object store, depending on whether self hosted or in cloud.
|
|
37
|
+
* @return {string} The base URL of the object store (MinIO or S3).
|
|
38
|
+
*/
|
|
39
|
+
export function objectStoreUrl() {
|
|
40
|
+
if (env.SELF_HOSTED || env.MINIO_URL) {
|
|
41
|
+
// can use a relative url for this as all goes through the proxy (this is hosted in minio)
|
|
42
|
+
return OBJ_STORE_DIRECTORY
|
|
43
|
+
} else {
|
|
44
|
+
return env.CDN_URL
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* In production the client library is stored in the object store, however in development
|
|
50
|
+
* we use the symlinked version produced by lerna, located in node modules. We link to this
|
|
51
|
+
* via a specific endpoint (under /api/assets/client).
|
|
52
|
+
* @param {string} appId In production we need the appId to look up the correct bucket, as the
|
|
53
|
+
* version of the client lib may differ between apps.
|
|
54
|
+
* @param {string} version The version to retrieve.
|
|
55
|
+
* @return {string} The URL to be inserted into appPackage response or server rendered
|
|
56
|
+
* app index file.
|
|
57
|
+
*/
|
|
58
|
+
export function clientLibraryPath(appId: string, version: string) {
|
|
59
|
+
if (env.isProd()) {
|
|
60
|
+
let url = `${objectStoreUrl()}/${objectStore.sanitizeKey(
|
|
61
|
+
appId
|
|
62
|
+
)}/budibase-client.js`
|
|
63
|
+
|
|
64
|
+
// append app version to bust the cache
|
|
65
|
+
if (version) {
|
|
66
|
+
url += `?v=${version}`
|
|
67
|
+
}
|
|
68
|
+
return url
|
|
69
|
+
} else {
|
|
70
|
+
return `/api/assets/client`
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function attachmentsRelativeURL(attachmentKey: string) {
|
|
75
|
+
return checkSlashesInUrl(`${objectStoreUrl()}/${attachmentKey}`)
|
|
76
|
+
}
|
|
77
|
+
|
|
34
78
|
export async function updateEntityMetadata(
|
|
35
79
|
type: string,
|
|
36
80
|
entityId: string,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import env from "../environment"
|
|
2
|
+
import { plugins as ProPlugins } from "@budibase/pro"
|
|
3
|
+
import { objectStore } from "@budibase/backend-core"
|
|
4
|
+
import { Plugin } from "@budibase/types"
|
|
5
|
+
|
|
6
|
+
export function enrichPluginURLs(plugins: Plugin[]) {
|
|
7
|
+
if (!plugins || !plugins.length) {
|
|
8
|
+
return []
|
|
9
|
+
}
|
|
10
|
+
return plugins.map(plugin => {
|
|
11
|
+
const cloud = !env.SELF_HOSTED
|
|
12
|
+
const bucket = objectStore.ObjectStoreBuckets.PLUGINS
|
|
13
|
+
const jsFileName = "plugin.min.js"
|
|
14
|
+
|
|
15
|
+
// In self host we need to prefix the path, as the bucket name is not part
|
|
16
|
+
// of the bucket path. In cloud, it's already part of the bucket path.
|
|
17
|
+
let jsUrl = cloud ? `${env.CDN_URL}/` : `/${bucket}/`
|
|
18
|
+
jsUrl += ProPlugins.getBucketPath(plugin.name)
|
|
19
|
+
jsUrl += jsFileName
|
|
20
|
+
return { ...plugin, jsUrl }
|
|
21
|
+
})
|
|
22
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as linkRows from "../../db/linkedRows"
|
|
2
2
|
import { FieldTypes, AutoFieldSubTypes } from "../../constants"
|
|
3
|
+
import { attachmentsRelativeURL } from "../index"
|
|
3
4
|
import { processFormulas, fixAutoColumnSubType } from "./utils"
|
|
4
5
|
import { ObjectStoreBuckets } from "../../constants"
|
|
5
6
|
import { context, db as dbCore, objectStore } from "@budibase/backend-core"
|
|
6
7
|
import { InternalTables } from "../../db/utils"
|
|
7
8
|
import { TYPE_TRANSFORM_MAP } from "./map"
|
|
8
|
-
import { Row,
|
|
9
|
+
import { Row, Table, ContextUser } from "@budibase/types"
|
|
9
10
|
const { cloneDeep } = require("lodash/fp")
|
|
10
11
|
export * from "./utils"
|
|
11
12
|
|
|
@@ -34,7 +35,7 @@ function getRemovedAttachmentKeys(
|
|
|
34
35
|
return oldKeys
|
|
35
36
|
}
|
|
36
37
|
const newKeys = row[attachmentKey].map((attachment: any) => attachment.key)
|
|
37
|
-
return oldKeys.filter((key:
|
|
38
|
+
return oldKeys.filter((key: any) => newKeys.indexOf(key) === -1)
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
/**
|
|
@@ -104,7 +105,7 @@ export function processAutoColumn(
|
|
|
104
105
|
* @param {object} type The type fo coerce to
|
|
105
106
|
* @returns {object} The coerced value
|
|
106
107
|
*/
|
|
107
|
-
export function coerce(row: any, type:
|
|
108
|
+
export function coerce(row: any, type: any) {
|
|
108
109
|
// no coercion specified for type, skip it
|
|
109
110
|
if (!TYPE_TRANSFORM_MAP[type]) {
|
|
110
111
|
return row
|
|
@@ -157,16 +158,6 @@ export function inputProcessing(
|
|
|
157
158
|
else {
|
|
158
159
|
clonedRow[key] = coerce(value, field.type)
|
|
159
160
|
}
|
|
160
|
-
|
|
161
|
-
// remove any attachment urls, they are generated on read
|
|
162
|
-
if (field.type === FieldTypes.ATTACHMENT) {
|
|
163
|
-
const attachments = clonedRow[key]
|
|
164
|
-
if (attachments?.length) {
|
|
165
|
-
attachments.forEach((attachment: RowAttachment) => {
|
|
166
|
-
delete attachment.url
|
|
167
|
-
})
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
161
|
}
|
|
171
162
|
|
|
172
163
|
if (!clonedRow._id || !clonedRow._rev) {
|
|
@@ -203,15 +194,15 @@ export async function outputProcessing(
|
|
|
203
194
|
// process formulas
|
|
204
195
|
enriched = processFormulas(table, enriched, { dynamic: true }) as Row[]
|
|
205
196
|
|
|
206
|
-
//
|
|
197
|
+
// update the attachments URL depending on hosting
|
|
207
198
|
for (let [property, column] of Object.entries(table.schema)) {
|
|
208
199
|
if (column.type === FieldTypes.ATTACHMENT) {
|
|
209
200
|
for (let row of enriched) {
|
|
210
201
|
if (row[property] == null || !Array.isArray(row[property])) {
|
|
211
202
|
continue
|
|
212
203
|
}
|
|
213
|
-
row[property].forEach((attachment:
|
|
214
|
-
attachment.url =
|
|
204
|
+
row[property].forEach((attachment: any) => {
|
|
205
|
+
attachment.url = attachmentsRelativeURL(attachment.key)
|
|
215
206
|
})
|
|
216
207
|
}
|
|
217
208
|
}
|
|
@@ -274,6 +265,6 @@ export async function cleanupAttachments(
|
|
|
274
265
|
}
|
|
275
266
|
}
|
|
276
267
|
if (files.length > 0) {
|
|
277
|
-
|
|
268
|
+
return objectStore.deleteFiles(ObjectStoreBuckets.APPS, files)
|
|
278
269
|
}
|
|
279
270
|
}
|