@budibase/server 2.2.3 → 2.2.4-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/aws-sdk.ts +19 -0
- package/__mocks__/node-fetch.ts +78 -0
- package/builder/assets/{index.c7a7a2d0.js → index.4aa8e747.js} +194 -194
- package/builder/index.html +1 -1
- package/coverage/clover.xml +4914 -4899
- package/coverage/coverage-final.json +265 -262
- package/coverage/lcov-report/index.html +176 -176
- 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 +171 -159
- 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 +91 -79
- 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 -14
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +83 -83
- 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 +150 -135
- 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 +10 -10
- package/coverage/lcov-report/src/api/controllers/public/index.html +1 -1
- 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 +10 -10
- 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 +43 -25
- package/coverage/lcov-report/src/api/controllers/row/external.ts.html +20 -20
- package/coverage/lcov-report/src/api/controllers/row/index.html +13 -13
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +14 -14
- package/coverage/lcov-report/src/api/controllers/row/internal.ts.html +54 -51
- package/coverage/lcov-report/src/api/controllers/row/internalSearch.ts.html +9 -9
- package/coverage/lcov-report/src/api/controllers/row/staticFormula.ts.html +21 -12
- package/coverage/lcov-report/src/api/controllers/row/utils.ts.html +17 -14
- 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 +32 -44
- 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 +51 -51
- 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 +1 -1
- package/coverage/lcov-report/src/api/controllers/view/index.ts.html +47 -47
- package/coverage/lcov-report/src/api/controllers/view/utils.ts.html +22 -22
- package/coverage/lcov-report/src/api/controllers/view/viewBuilder.ts.html +33 -33
- 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 +9 -9
- 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 +8 -8
- package/coverage/lcov-report/src/api/routes/dev.ts.html +13 -13
- package/coverage/lcov-report/src/api/routes/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.ts.html +40 -37
- 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 +12 -12
- package/coverage/lcov-report/src/api/routes/public/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +52 -52
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/public/middleware/mapper.ts.html +10 -10
- 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 +16 -16
- 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 +22 -22
- 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 +91 -19
- 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 +43 -31
- 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 +26 -26
- 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 +11 -11
- package/coverage/lcov-report/src/integrations/index.html +5 -5
- package/coverage/lcov-report/src/integrations/index.ts.html +35 -47
- 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 +13 -10
- 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 +42 -54
- package/coverage/lcov-report/src/sdk/app/backups/index.html +30 -30
- 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/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 +8 -8
- 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 +146 -119
- package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +15 -15
- package/coverage/lcov-report/src/tests/utilities/index.html +10 -10
- 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 +32 -101
- 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/app.ts.html +343 -0
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +12 -12
- package/coverage/lcov-report/src/utilities/fileSystem/filesystem.ts.html +595 -0
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +79 -19
- package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +20 -1049
- package/coverage/lcov-report/src/utilities/fileSystem/plugin.ts.html +280 -0
- package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/fileSystem/template.ts.html +193 -0
- package/coverage/lcov-report/src/utilities/global.ts.html +42 -42
- package/coverage/lcov-report/src/utilities/index.html +48 -63
- package/coverage/lcov-report/src/utilities/index.ts.html +36 -168
- 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 +60 -33
- 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 +6978 -6941
- package/dist/api/controllers/application.js +9 -10
- package/dist/api/controllers/cloud.js +6 -2
- package/dist/api/controllers/plugin/index.js +6 -6
- package/dist/api/controllers/row/ExternalRequest.js +14 -8
- package/dist/api/controllers/row/internal.js +11 -11
- package/dist/api/controllers/row/staticFormula.js +1 -1
- package/dist/api/controllers/static/index.js +8 -11
- package/dist/automations/automationUtils.js +26 -1
- package/dist/environment.js +6 -2
- package/dist/integrations/index.js +1 -2
- package/dist/migrations/functions/backfill/global/configs.js +4 -4
- package/dist/package.json +9 -7
- package/dist/sdk/app/backups/imports.js +3 -7
- package/dist/threads/automation.js +2 -26
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/app.js +97 -0
- package/dist/utilities/fileSystem/clientLibrary.js +3 -3
- package/dist/utilities/fileSystem/filesystem.js +182 -0
- package/dist/utilities/fileSystem/index.js +18 -342
- package/dist/utilities/fileSystem/plugin.js +63 -0
- package/dist/utilities/fileSystem/template.js +44 -0
- package/dist/utilities/index.js +1 -44
- package/dist/utilities/rowProcessor/index.js +12 -4
- package/package.json +10 -8
- package/src/api/controllers/application.ts +16 -12
- package/src/api/controllers/auth.ts +2 -2
- package/src/api/controllers/cloud.ts +10 -6
- package/src/api/controllers/plugin/index.ts +14 -9
- package/src/api/controllers/row/ExternalRequest.ts +14 -8
- package/src/api/controllers/row/internal.ts +23 -22
- package/src/api/controllers/row/staticFormula.ts +5 -2
- package/src/api/controllers/row/utils.ts +2 -1
- package/src/api/controllers/static/index.ts +6 -10
- package/src/api/routes/index.ts +4 -3
- package/src/api/routes/tests/__snapshots__/{datasource.spec.js.snap → datasource.spec.ts.snap} +0 -0
- package/src/api/routes/tests/{application.spec.js → application.spec.ts} +40 -7
- package/src/api/routes/tests/{backup.spec.js → backup.spec.ts} +17 -6
- package/src/api/routes/tests/cloud.spec.ts +66 -0
- 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/{datasource.spec.js → datasource.spec.ts} +23 -15
- package/src/api/routes/tests/plugin.spec.ts +179 -0
- package/src/api/routes/tests/routing.spec.js +0 -1
- package/src/api/routes/tests/row.spec.js +4 -2
- package/src/api/routes/tests/static.spec.js +2 -17
- package/src/api/routes/tests/table.spec.js +8 -2
- package/src/api/routes/tests/user.spec.js +86 -0
- package/src/api/routes/tests/utilities/index.ts +2 -2
- package/src/automations/automationUtils.ts +24 -0
- package/src/automations/tests/bash.spec.js +34 -0
- package/src/automations/tests/discord.spec.js +27 -0
- package/src/automations/tests/executeQuery.spec.js +49 -0
- package/src/automations/tests/executeScript.spec.js +48 -0
- package/src/automations/tests/sendSmtpEmail.spec.js +71 -0
- package/src/automations/tests/serverLog.spec.js +22 -0
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/tests/zapier.spec.js +27 -0
- package/src/automations/unitTests/automationUtils.spec.ts +65 -0
- package/src/environment.ts +6 -2
- package/src/integrations/index.ts +1 -5
- package/src/migrations/functions/backfill/global/configs.ts +5 -4
- package/src/sdk/app/backups/imports.ts +3 -7
- package/src/tests/jestSetup.ts +4 -1
- package/src/tests/utilities/TestConfiguration.ts +9 -0
- package/src/threads/automation.ts +2 -25
- package/src/utilities/fileSystem/app.ts +86 -0
- package/src/utilities/fileSystem/clientLibrary.ts +1 -1
- package/src/utilities/fileSystem/filesystem.ts +170 -0
- package/src/utilities/fileSystem/index.ts +5 -348
- package/src/utilities/fileSystem/plugin.ts +65 -0
- package/src/utilities/fileSystem/template.ts +36 -0
- package/src/utilities/index.ts +1 -45
- package/src/utilities/rowProcessor/index.ts +17 -8
- package/src/utilities/rowProcessor/tests/utils.spec.ts +57 -0
- package/tsconfig.build.json +2 -0
- package/coverage/lcov-report/src/utilities/plugins.ts.html +0 -151
- package/dist/api/routes/tests/utilities/TestFunctions.js +0 -167
- package/dist/api/routes/tests/utilities/index.js +0 -131
- package/dist/automations/tests/utilities/index.js +0 -81
- package/dist/tests/utilities/TestConfiguration.js +0 -562
- package/dist/tests/utilities/controllers.js +0 -40
- package/dist/tests/utilities/structures.js +0 -168
- package/dist/utilities/plugins.js +0 -26
- package/src/automations/unitTests/automationUtils.spec.js +0 -17
- package/src/utilities/plugins.ts +0 -22
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
let mockObjectStore = jest.fn().mockImplementation(() => {
|
|
2
|
+
return [{ name: "test.js" }]
|
|
3
|
+
})
|
|
4
|
+
|
|
5
|
+
let deleteFolder = jest.fn().mockImplementation()
|
|
6
|
+
jest.mock("@budibase/backend-core", () => {
|
|
7
|
+
const core = jest.requireActual("@budibase/backend-core")
|
|
8
|
+
return {
|
|
9
|
+
...core,
|
|
10
|
+
objectStore: {
|
|
11
|
+
...core.objectStore,
|
|
12
|
+
upload: jest.fn(),
|
|
13
|
+
uploadDirectory: mockObjectStore,
|
|
14
|
+
deleteFolder: deleteFolder,
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
import { events } from "@budibase/backend-core"
|
|
20
|
+
import * as setup from "./utilities"
|
|
21
|
+
|
|
22
|
+
describe("/plugins", () => {
|
|
23
|
+
let request = setup.getRequest()
|
|
24
|
+
let config = setup.getConfig()
|
|
25
|
+
|
|
26
|
+
afterAll(setup.afterAll)
|
|
27
|
+
|
|
28
|
+
beforeEach(async () => {
|
|
29
|
+
await config.init()
|
|
30
|
+
jest.clearAllMocks()
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const createPlugin = async (status?: number) => {
|
|
34
|
+
return request
|
|
35
|
+
.post(`/api/plugin/upload`)
|
|
36
|
+
.attach("file", "src/api/routes/tests/data/comment-box-1.0.2.tar.gz")
|
|
37
|
+
.set(config.defaultHeaders())
|
|
38
|
+
.expect("Content-Type", /json/)
|
|
39
|
+
.expect(status ? status : 200)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const getPlugins = async (status?: number) => {
|
|
43
|
+
return request
|
|
44
|
+
.get(`/api/plugin`)
|
|
45
|
+
.set(config.defaultHeaders())
|
|
46
|
+
.expect("Content-Type", /json/)
|
|
47
|
+
.expect(status ? status : 200)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe("upload", () => {
|
|
51
|
+
it("should be able to upload a plugin", async () => {
|
|
52
|
+
let res = await createPlugin()
|
|
53
|
+
expect(res.body).toBeDefined()
|
|
54
|
+
expect(res.body.plugins).toBeDefined()
|
|
55
|
+
expect(res.body.plugins[0]._id).toEqual("plg_comment-box")
|
|
56
|
+
expect(events.plugin.imported).toHaveBeenCalledTimes(1)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
it("should not be able to create a plugin if there is an error", async () => {
|
|
60
|
+
mockObjectStore.mockImplementationOnce(() => {
|
|
61
|
+
throw new Error()
|
|
62
|
+
})
|
|
63
|
+
let res = await createPlugin(400)
|
|
64
|
+
expect(res.body.message).toEqual("Failed to import plugin: Error")
|
|
65
|
+
expect(events.plugin.imported).toHaveBeenCalledTimes(0)
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
describe("fetch", () => {
|
|
70
|
+
it("should be able to fetch plugins", async () => {
|
|
71
|
+
await createPlugin()
|
|
72
|
+
const res = await getPlugins()
|
|
73
|
+
expect(res.body).toBeDefined()
|
|
74
|
+
expect(res.body[0]._id).toEqual("plg_comment-box")
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
describe("destroy", () => {
|
|
79
|
+
it("should be able to delete a plugin", async () => {
|
|
80
|
+
await createPlugin()
|
|
81
|
+
const res = await request
|
|
82
|
+
.delete(`/api/plugin/plg_comment-box`)
|
|
83
|
+
.set(config.defaultHeaders())
|
|
84
|
+
.expect("Content-Type", /json/)
|
|
85
|
+
.expect(200)
|
|
86
|
+
expect(res.body).toBeDefined()
|
|
87
|
+
expect(res.body.message).toEqual("Plugin plg_comment-box deleted.")
|
|
88
|
+
|
|
89
|
+
const plugins = await getPlugins()
|
|
90
|
+
expect(plugins.body).toBeDefined()
|
|
91
|
+
expect(plugins.body.length).toEqual(0)
|
|
92
|
+
expect(events.plugin.deleted).toHaveBeenCalledTimes(1)
|
|
93
|
+
})
|
|
94
|
+
it("should handle an error deleting a plugin", async () => {
|
|
95
|
+
deleteFolder.mockImplementationOnce(() => {
|
|
96
|
+
throw new Error()
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
await createPlugin()
|
|
100
|
+
const res = await request
|
|
101
|
+
.delete(`/api/plugin/plg_comment-box`)
|
|
102
|
+
.set(config.defaultHeaders())
|
|
103
|
+
.expect("Content-Type", /json/)
|
|
104
|
+
.expect(400)
|
|
105
|
+
|
|
106
|
+
expect(res.body.message).toEqual("Failed to delete plugin: Error")
|
|
107
|
+
expect(events.plugin.deleted).toHaveBeenCalledTimes(0)
|
|
108
|
+
const plugins = await getPlugins()
|
|
109
|
+
expect(plugins.body).toBeDefined()
|
|
110
|
+
expect(plugins.body.length).toEqual(1)
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
describe("github", () => {
|
|
115
|
+
const createGithubPlugin = async (status?: number, url?: string) => {
|
|
116
|
+
return await request
|
|
117
|
+
.post(`/api/plugin`)
|
|
118
|
+
.send({
|
|
119
|
+
source: "Github",
|
|
120
|
+
url,
|
|
121
|
+
githubToken: "token",
|
|
122
|
+
})
|
|
123
|
+
.set(config.defaultHeaders())
|
|
124
|
+
.expect("Content-Type", /json/)
|
|
125
|
+
.expect(status ? status : 200)
|
|
126
|
+
}
|
|
127
|
+
it("should be able to create a plugin from github", async () => {
|
|
128
|
+
const res = await createGithubPlugin(
|
|
129
|
+
200,
|
|
130
|
+
"https://github.com/my-repo/budibase-comment-box.git"
|
|
131
|
+
)
|
|
132
|
+
expect(res.body).toBeDefined()
|
|
133
|
+
expect(res.body.plugin).toBeDefined()
|
|
134
|
+
expect(res.body.plugin._id).toEqual("plg_comment-box")
|
|
135
|
+
})
|
|
136
|
+
it("should fail if the url is not from github", async () => {
|
|
137
|
+
const res = await createGithubPlugin(
|
|
138
|
+
400,
|
|
139
|
+
"https://notgithub.com/my-repo/budibase-comment-box"
|
|
140
|
+
)
|
|
141
|
+
expect(res.body.message).toEqual(
|
|
142
|
+
"Failed to import plugin: The plugin origin must be from Github"
|
|
143
|
+
)
|
|
144
|
+
})
|
|
145
|
+
})
|
|
146
|
+
describe("npm", () => {
|
|
147
|
+
it("should be able to create a plugin from npm", async () => {
|
|
148
|
+
const res = await request
|
|
149
|
+
.post(`/api/plugin`)
|
|
150
|
+
.send({
|
|
151
|
+
source: "NPM",
|
|
152
|
+
url: "https://www.npmjs.com/package/budibase-component",
|
|
153
|
+
})
|
|
154
|
+
.set(config.defaultHeaders())
|
|
155
|
+
.expect("Content-Type", /json/)
|
|
156
|
+
.expect(200)
|
|
157
|
+
expect(res.body).toBeDefined()
|
|
158
|
+
expect(res.body.plugin._id).toEqual("plg_budibase-component")
|
|
159
|
+
expect(events.plugin.imported).toHaveBeenCalled()
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
describe("url", () => {
|
|
164
|
+
it("should be able to create a plugin from a URL", async () => {
|
|
165
|
+
const res = await request
|
|
166
|
+
.post(`/api/plugin`)
|
|
167
|
+
.send({
|
|
168
|
+
source: "URL",
|
|
169
|
+
url: "https://www.someurl.com/comment-box/comment-box-1.0.2.tar.gz",
|
|
170
|
+
})
|
|
171
|
+
.set(config.defaultHeaders())
|
|
172
|
+
.expect("Content-Type", /json/)
|
|
173
|
+
.expect(200)
|
|
174
|
+
expect(res.body).toBeDefined()
|
|
175
|
+
expect(res.body.plugin._id).toEqual("plg_comment-box")
|
|
176
|
+
expect(events.plugin.imported).toHaveBeenCalledTimes(1)
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
})
|
|
@@ -10,6 +10,7 @@ const {
|
|
|
10
10
|
StaticQuotaName,
|
|
11
11
|
MonthlyQuotaName,
|
|
12
12
|
} = require("@budibase/types")
|
|
13
|
+
const { structures } = require("@budibase/backend-core/tests");
|
|
13
14
|
|
|
14
15
|
describe("/rows", () => {
|
|
15
16
|
let request = setup.getRequest()
|
|
@@ -494,12 +495,13 @@ describe("/rows", () => {
|
|
|
494
495
|
describe("attachments", () => {
|
|
495
496
|
it("should allow enriching attachment rows", async () => {
|
|
496
497
|
const table = await config.createAttachmentTable()
|
|
498
|
+
const attachmentId = `${structures.uuid()}.csv`
|
|
497
499
|
const row = await config.createRow({
|
|
498
500
|
name: "test",
|
|
499
501
|
description: "test",
|
|
500
502
|
attachment: [
|
|
501
503
|
{
|
|
502
|
-
key: `${config.getAppId()}/attachments
|
|
504
|
+
key: `${config.getAppId()}/attachments/${attachmentId}`,
|
|
503
505
|
},
|
|
504
506
|
],
|
|
505
507
|
tableId: table._id,
|
|
@@ -509,7 +511,7 @@ describe("/rows", () => {
|
|
|
509
511
|
context.doInAppContext(config.getAppId(), async () => {
|
|
510
512
|
const enriched = await outputProcessing(table, [row])
|
|
511
513
|
expect(enriched[0].attachment[0].url).toBe(
|
|
512
|
-
`/prod-budi-app-assets/${config.
|
|
514
|
+
`/files/signed/prod-budi-app-assets/${config.getProdAppId()}/attachments/${attachmentId}`
|
|
513
515
|
)
|
|
514
516
|
})
|
|
515
517
|
})
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
jest.mock("node-fetch")
|
|
2
|
-
jest.mock("aws-sdk", () => ({
|
|
3
|
-
config: {
|
|
4
|
-
update: jest.fn(),
|
|
5
|
-
},
|
|
6
|
-
DynamoDB: {
|
|
7
|
-
DocumentClient: jest.fn(),
|
|
8
|
-
},
|
|
9
|
-
S3: jest.fn(() => ({
|
|
10
|
-
getSignedUrl: jest.fn(() => {
|
|
11
|
-
return "my-url"
|
|
12
|
-
}),
|
|
13
|
-
})),
|
|
14
|
-
}))
|
|
15
|
-
|
|
16
1
|
const setup = require("./utilities")
|
|
17
|
-
const {
|
|
2
|
+
const { constants } = require("@budibase/backend-core")
|
|
18
3
|
|
|
19
4
|
describe("/static", () => {
|
|
20
5
|
let request = setup.getRequest()
|
|
@@ -102,7 +87,7 @@ describe("/static", () => {
|
|
|
102
87
|
.set(config.defaultHeaders())
|
|
103
88
|
.expect("Content-Type", /json/)
|
|
104
89
|
.expect(200)
|
|
105
|
-
expect(res.body.signedUrl).toEqual("
|
|
90
|
+
expect(res.body.signedUrl).toEqual("http://test.com/foo/bar")
|
|
106
91
|
expect(res.body.publicUrl).toEqual(
|
|
107
92
|
`https://${bucket}.s3.eu-west-1.amazonaws.com/${key}`
|
|
108
93
|
)
|
|
@@ -51,7 +51,7 @@ describe("/tables", () => {
|
|
|
51
51
|
table.dataImport.schema = table.schema
|
|
52
52
|
|
|
53
53
|
const res = await createTable(table)
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
expect(events.table.created).toBeCalledTimes(1)
|
|
56
56
|
expect(events.table.created).toBeCalledWith(res.body)
|
|
57
57
|
expect(events.table.imported).toBeCalledTimes(1)
|
|
@@ -87,6 +87,12 @@ describe("/tables", () => {
|
|
|
87
87
|
|
|
88
88
|
it("updates all the row fields for a table when a schema key is renamed", async () => {
|
|
89
89
|
const testTable = await config.createTable()
|
|
90
|
+
await config.createView({
|
|
91
|
+
name: "TestView",
|
|
92
|
+
field: "Price",
|
|
93
|
+
calculation: "stats",
|
|
94
|
+
tableId: testTable._id,
|
|
95
|
+
})
|
|
90
96
|
|
|
91
97
|
const testRow = await request
|
|
92
98
|
.post(`/api/${testTable._id}/rows`)
|
|
@@ -109,7 +115,7 @@ describe("/tables", () => {
|
|
|
109
115
|
updated: "updatedName"
|
|
110
116
|
},
|
|
111
117
|
schema: {
|
|
112
|
-
updatedName: {type: "string"}
|
|
118
|
+
updatedName: { type: "string" }
|
|
113
119
|
}
|
|
114
120
|
})
|
|
115
121
|
.set(config.defaultHeaders())
|
|
@@ -90,4 +90,90 @@ describe("/users", () => {
|
|
|
90
90
|
expect(res.body.tableId).toBeDefined()
|
|
91
91
|
})
|
|
92
92
|
})
|
|
93
|
+
describe("setFlag", () => {
|
|
94
|
+
it("should throw an error if a flag is not provided", async () => {
|
|
95
|
+
await config.createUser()
|
|
96
|
+
const res = await request
|
|
97
|
+
.post(`/api/users/flags`)
|
|
98
|
+
.set(config.defaultHeaders())
|
|
99
|
+
.send({ value: "test" })
|
|
100
|
+
.expect(400)
|
|
101
|
+
.expect("Content-Type", /json/)
|
|
102
|
+
expect(res.body.message).toEqual("Must supply a 'flag' field in request body.")
|
|
103
|
+
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
it("should be able to set a flag on the user", async () => {
|
|
107
|
+
await config.createUser()
|
|
108
|
+
const res = await request
|
|
109
|
+
.post(`/api/users/flags`)
|
|
110
|
+
.set(config.defaultHeaders())
|
|
111
|
+
.send({ value: "test", flag: "test" })
|
|
112
|
+
.expect(200)
|
|
113
|
+
.expect("Content-Type", /json/)
|
|
114
|
+
expect(res.body.message).toEqual("Flag set successfully")
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
|
|
118
|
+
describe("getFlags", () => {
|
|
119
|
+
it("should get flags for a specific user", async () => {
|
|
120
|
+
let flagData = { value: "test", flag: "test" }
|
|
121
|
+
await config.createUser()
|
|
122
|
+
await request
|
|
123
|
+
.post(`/api/users/flags`)
|
|
124
|
+
.set(config.defaultHeaders())
|
|
125
|
+
.send(flagData)
|
|
126
|
+
.expect(200)
|
|
127
|
+
.expect("Content-Type", /json/)
|
|
128
|
+
|
|
129
|
+
const res = await request
|
|
130
|
+
.get(`/api/users/flags`)
|
|
131
|
+
.set(config.defaultHeaders())
|
|
132
|
+
.expect(200)
|
|
133
|
+
.expect("Content-Type", /json/)
|
|
134
|
+
expect(res.body[flagData.value]).toEqual(flagData.flag)
|
|
135
|
+
})
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
describe("setFlag", () => {
|
|
139
|
+
it("should throw an error if a flag is not provided", async () => {
|
|
140
|
+
await config.createUser()
|
|
141
|
+
const res = await request
|
|
142
|
+
.post(`/api/users/flags`)
|
|
143
|
+
.set(config.defaultHeaders())
|
|
144
|
+
.send({ value: "test" })
|
|
145
|
+
.expect(400)
|
|
146
|
+
.expect("Content-Type", /json/)
|
|
147
|
+
expect(res.body.message).toEqual("Must supply a 'flag' field in request body.")
|
|
148
|
+
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
it("should be able to set a flag on the user", async () => {
|
|
152
|
+
await config.createUser()
|
|
153
|
+
const res = await request
|
|
154
|
+
.post(`/api/users/flags`)
|
|
155
|
+
.set(config.defaultHeaders())
|
|
156
|
+
.send({ value: "test", flag: "test" })
|
|
157
|
+
.expect(200)
|
|
158
|
+
.expect("Content-Type", /json/)
|
|
159
|
+
expect(res.body.message).toEqual("Flag set successfully")
|
|
160
|
+
})
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
describe("syncUser", () => {
|
|
164
|
+
it("should sync the user", async () => {
|
|
165
|
+
let user = await config.createUser()
|
|
166
|
+
await config.createApp('New App')
|
|
167
|
+
let res = await request
|
|
168
|
+
.post(`/api/users/metadata/sync/${user._id}`)
|
|
169
|
+
.set(config.defaultHeaders())
|
|
170
|
+
.expect(200)
|
|
171
|
+
.expect("Content-Type", /json/)
|
|
172
|
+
expect(res.body.message).toEqual('User synced.')
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
93
179
|
})
|
|
@@ -63,14 +63,14 @@ export function afterAll() {
|
|
|
63
63
|
|
|
64
64
|
export function getRequest() {
|
|
65
65
|
if (!request) {
|
|
66
|
-
|
|
66
|
+
beforeAll()
|
|
67
67
|
}
|
|
68
68
|
return request
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function getConfig() {
|
|
72
72
|
if (!config) {
|
|
73
|
-
|
|
73
|
+
beforeAll()
|
|
74
74
|
}
|
|
75
75
|
return config
|
|
76
76
|
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
} from "@budibase/string-templates"
|
|
6
6
|
import sdk from "../sdk"
|
|
7
7
|
import { Row } from "@budibase/types"
|
|
8
|
+
import { LoopStep, LoopStepType, LoopInput } from "../definitions/automations"
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* When values are input to the system generally they will be of type string as this is required for template strings.
|
|
@@ -123,3 +124,26 @@ export function stringSplit(value: string | string[]) {
|
|
|
123
124
|
}
|
|
124
125
|
return value
|
|
125
126
|
}
|
|
127
|
+
|
|
128
|
+
export function typecastForLooping(loopStep: LoopStep, input: LoopInput) {
|
|
129
|
+
if (!input || !input.binding) {
|
|
130
|
+
return null
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
switch (loopStep.inputs.option) {
|
|
134
|
+
case LoopStepType.ARRAY:
|
|
135
|
+
if (typeof input.binding === "string") {
|
|
136
|
+
return JSON.parse(input.binding)
|
|
137
|
+
}
|
|
138
|
+
break
|
|
139
|
+
case LoopStepType.STRING:
|
|
140
|
+
if (Array.isArray(input.binding)) {
|
|
141
|
+
return input.binding.join(",")
|
|
142
|
+
}
|
|
143
|
+
break
|
|
144
|
+
}
|
|
145
|
+
} catch (err) {
|
|
146
|
+
throw new Error("Unable to cast to correct type")
|
|
147
|
+
}
|
|
148
|
+
return input.binding
|
|
149
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const setup = require("./utilities")
|
|
2
|
+
|
|
3
|
+
describe("test the bash action", () => {
|
|
4
|
+
let config = setup.getConfig()
|
|
5
|
+
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await config.init()
|
|
8
|
+
})
|
|
9
|
+
afterAll(setup.afterAll)
|
|
10
|
+
|
|
11
|
+
it("should be able to execute a script", async () => {
|
|
12
|
+
|
|
13
|
+
let res = await setup.runStep("EXECUTE_BASH",
|
|
14
|
+
inputs = {
|
|
15
|
+
code: "echo 'test'"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
)
|
|
19
|
+
expect(res.stdout).toEqual("test\n")
|
|
20
|
+
expect(res.success).toEqual(true)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it("should handle a null value", async () => {
|
|
24
|
+
|
|
25
|
+
let res = await setup.runStep("EXECUTE_BASH",
|
|
26
|
+
inputs = {
|
|
27
|
+
code: null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
)
|
|
32
|
+
expect(res.stdout).toEqual("Budibase bash automation failed: Invalid inputs")
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const setup = require("./utilities")
|
|
2
|
+
const fetch = require("node-fetch")
|
|
3
|
+
|
|
4
|
+
jest.mock("node-fetch")
|
|
5
|
+
|
|
6
|
+
describe("test the outgoing webhook action", () => {
|
|
7
|
+
let inputs
|
|
8
|
+
let config = setup.getConfig()
|
|
9
|
+
|
|
10
|
+
beforeEach(async () => {
|
|
11
|
+
await config.init()
|
|
12
|
+
inputs = {
|
|
13
|
+
username: "joe_bloggs",
|
|
14
|
+
url: "http://www.test.com",
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
afterAll(setup.afterAll)
|
|
19
|
+
|
|
20
|
+
it("should be able to run the action", async () => {
|
|
21
|
+
const res = await setup.runStep(setup.actions.discord.stepId, inputs)
|
|
22
|
+
expect(res.response.url).toEqual("http://www.test.com")
|
|
23
|
+
expect(res.response.method).toEqual("post")
|
|
24
|
+
expect(res.success).toEqual(true)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const setup = require("./utilities")
|
|
2
|
+
|
|
3
|
+
describe("test the execute query action", () => {
|
|
4
|
+
let datasource
|
|
5
|
+
let config = setup.getConfig()
|
|
6
|
+
|
|
7
|
+
beforeEach(async () => {
|
|
8
|
+
await config.init()
|
|
9
|
+
|
|
10
|
+
await config.createDatasource()
|
|
11
|
+
query = await config.createQuery()
|
|
12
|
+
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
afterAll(setup.afterAll)
|
|
16
|
+
|
|
17
|
+
it("should be able to execute a query", async () => {
|
|
18
|
+
let res = await setup.runStep(setup.actions.EXECUTE_QUERY.stepId,
|
|
19
|
+
inputs = {
|
|
20
|
+
query: { queryId: query._id }
|
|
21
|
+
}
|
|
22
|
+
)
|
|
23
|
+
expect(res.response).toEqual([{ a: 'string', b: 1 }])
|
|
24
|
+
expect(res.success).toEqual(true)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it("should handle a null query value", async () => {
|
|
28
|
+
let res = await setup.runStep(setup.actions.EXECUTE_QUERY.stepId,
|
|
29
|
+
inputs = {
|
|
30
|
+
query: null
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
expect(res.response.message).toEqual("Invalid inputs")
|
|
34
|
+
expect(res.success).toEqual(false)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
it("should handle an error executing a query", async () => {
|
|
39
|
+
let res = await setup.runStep(setup.actions.EXECUTE_QUERY.stepId,
|
|
40
|
+
inputs = {
|
|
41
|
+
query: { queryId: "wrong_id" }
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
expect(res.response).toEqual('{"status":404,"name":"not_found","message":"missing","reason":"missing"}')
|
|
45
|
+
expect(res.success).toEqual(false)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const setup = require("./utilities")
|
|
2
|
+
|
|
3
|
+
describe("test the execute script action", () => {
|
|
4
|
+
let config = setup.getConfig()
|
|
5
|
+
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await config.init()
|
|
8
|
+
})
|
|
9
|
+
afterAll(setup.afterAll)
|
|
10
|
+
|
|
11
|
+
it("should be able to execute a script", async () => {
|
|
12
|
+
|
|
13
|
+
let res = await setup.runStep(setup.actions.EXECUTE_SCRIPT.stepId,
|
|
14
|
+
inputs = {
|
|
15
|
+
code: "return 1 + 1"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
)
|
|
19
|
+
expect(res.value).toEqual(2)
|
|
20
|
+
expect(res.success).toEqual(true)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it("should handle a null value", async () => {
|
|
24
|
+
|
|
25
|
+
let res = await setup.runStep(setup.actions.EXECUTE_SCRIPT.stepId,
|
|
26
|
+
inputs = {
|
|
27
|
+
code: null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
)
|
|
32
|
+
expect(res.response.message).toEqual("Invalid inputs")
|
|
33
|
+
expect(res.success).toEqual(false)
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it("should be able to handle an error gracefully", async () => {
|
|
37
|
+
|
|
38
|
+
let res = await setup.runStep(setup.actions.EXECUTE_SCRIPT.stepId,
|
|
39
|
+
inputs = {
|
|
40
|
+
code: "return something.map(x => x.name)"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
)
|
|
44
|
+
expect(res.response).toEqual("ReferenceError: something is not defined")
|
|
45
|
+
expect(res.success).toEqual(false)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
})
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
function generateResponse(to, from) {
|
|
3
|
+
return {
|
|
4
|
+
"success": true,
|
|
5
|
+
"response": {
|
|
6
|
+
"accepted": [
|
|
7
|
+
to
|
|
8
|
+
],
|
|
9
|
+
"envelope": {
|
|
10
|
+
"from": from,
|
|
11
|
+
"to": [
|
|
12
|
+
to
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"message": `Email sent to ${to}.`
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const mockFetch = jest.fn(() => ({
|
|
22
|
+
headers: {
|
|
23
|
+
raw: () => {
|
|
24
|
+
return { "content-type": ["application/json"] }
|
|
25
|
+
},
|
|
26
|
+
get: () => ["application/json"],
|
|
27
|
+
},
|
|
28
|
+
json: jest.fn(() => response),
|
|
29
|
+
status: 200,
|
|
30
|
+
text: jest.fn(),
|
|
31
|
+
}))
|
|
32
|
+
jest.mock("node-fetch", () => mockFetch)
|
|
33
|
+
const setup = require("./utilities")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
describe("test the outgoing webhook action", () => {
|
|
37
|
+
let inputs
|
|
38
|
+
let config = setup.getConfig()
|
|
39
|
+
beforeEach(async () => {
|
|
40
|
+
await config.init()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
afterAll(setup.afterAll)
|
|
44
|
+
|
|
45
|
+
it("should be able to run the action", async () => {
|
|
46
|
+
inputs = {
|
|
47
|
+
to: "user1@test.com",
|
|
48
|
+
from: "admin@test.com",
|
|
49
|
+
subject: "hello",
|
|
50
|
+
contents: "testing",
|
|
51
|
+
}
|
|
52
|
+
let resp = generateResponse(inputs.to, inputs.from)
|
|
53
|
+
mockFetch.mockImplementationOnce(() => ({
|
|
54
|
+
headers: {
|
|
55
|
+
raw: () => {
|
|
56
|
+
return { "content-type": ["application/json"] }
|
|
57
|
+
},
|
|
58
|
+
get: () => ["application/json"],
|
|
59
|
+
},
|
|
60
|
+
json: jest.fn(() => resp),
|
|
61
|
+
status: 200,
|
|
62
|
+
text: jest.fn(),
|
|
63
|
+
}))
|
|
64
|
+
const res = await setup.runStep(setup.actions.SEND_EMAIL_SMTP.stepId, inputs)
|
|
65
|
+
expect(res.response).toEqual(resp)
|
|
66
|
+
expect(res.success).toEqual(true)
|
|
67
|
+
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const setup = require("./utilities")
|
|
2
|
+
|
|
3
|
+
describe("test the server log action", () => {
|
|
4
|
+
let config = setup.getConfig()
|
|
5
|
+
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await config.init()
|
|
8
|
+
inputs = {
|
|
9
|
+
text: "log message",
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
afterAll(setup.afterAll)
|
|
13
|
+
|
|
14
|
+
it("should be able to log the text", async () => {
|
|
15
|
+
|
|
16
|
+
let res = await setup.runStep(setup.actions.SERVER_LOG.stepId,
|
|
17
|
+
inputs
|
|
18
|
+
)
|
|
19
|
+
expect(res.message).toEqual(`App ${config.getAppId()} - ${inputs.text}`)
|
|
20
|
+
expect(res.success).toEqual(true)
|
|
21
|
+
})
|
|
22
|
+
})
|