@budibase/server 2.2.12-alpha.3 → 2.2.12-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builder/assets/{bb-emblem.4e4717da.svg → bb-emblem.05f7ae7a.svg} +1 -1
- package/builder/assets/index.2203da4c.css +6 -0
- package/builder/assets/{index.8a1f534a.js → index.4dc7e0fd.js} +389 -401
- package/builder/index.html +2 -2
- package/coverage/clover.xml +1959 -2080
- package/coverage/coverage-final.json +278 -279
- package/coverage/lcov-report/index.html +391 -391
- package/coverage/lcov-report/src/api/controllers/analytics.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/apikeys.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/application.ts.html +82 -82
- package/coverage/lcov-report/src/api/controllers/auth.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/automation.ts.html +17 -17
- package/coverage/lcov-report/src/api/controllers/backup.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/cloud.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/component.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/datasource.ts.html +23 -23
- package/coverage/lcov-report/src/api/controllers/deploy/Deployment.ts.html +16 -16
- package/coverage/lcov-report/src/api/controllers/deploy/index.html +7 -7
- package/coverage/lcov-report/src/api/controllers/deploy/index.ts.html +73 -73
- package/coverage/lcov-report/src/api/controllers/dev.ts.html +15 -15
- package/coverage/lcov-report/src/api/controllers/index.html +98 -98
- package/coverage/lcov-report/src/api/controllers/integration.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/layout.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/metadata.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/migrations.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/permission.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/plugin/file.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/plugin/github.ts.html +17 -17
- package/coverage/lcov-report/src/api/controllers/plugin/index.html +31 -31
- package/coverage/lcov-report/src/api/controllers/plugin/index.ts.html +21 -21
- package/coverage/lcov-report/src/api/controllers/plugin/npm.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/plugin/uploaders.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/plugin/url.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/plugin/utils.ts.html +2 -2
- package/coverage/lcov-report/src/api/controllers/public/applications.ts.html +27 -27
- package/coverage/lcov-report/src/api/controllers/public/index.html +58 -58
- package/coverage/lcov-report/src/api/controllers/public/mapping/applications.ts.html +6 -6
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.html +25 -25
- package/coverage/lcov-report/src/api/controllers/public/mapping/index.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/public/mapping/queries.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/public/mapping/rows.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/public/mapping/tables.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/public/mapping/users.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/public/queries.ts.html +13 -13
- package/coverage/lcov-report/src/api/controllers/public/rows.ts.html +18 -18
- package/coverage/lcov-report/src/api/controllers/public/tables.ts.html +19 -19
- package/coverage/lcov-report/src/api/controllers/public/users.ts.html +24 -24
- package/coverage/lcov-report/src/api/controllers/public/utils.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/query/import/index.html +8 -8
- package/coverage/lcov-report/src/api/controllers/query/import/index.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.html +14 -14
- package/coverage/lcov-report/src/api/controllers/query/import/sources/base/index.ts.html +13 -13
- 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 +6 -6
- package/coverage/lcov-report/src/api/controllers/query/import/sources/index.html +23 -23
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi2.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/query/import/sources/openapi3.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/query/index.html +15 -15
- package/coverage/lcov-report/src/api/controllers/query/index.ts.html +20 -20
- package/coverage/lcov-report/src/api/controllers/query/validation.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/role.ts.html +4 -4
- package/coverage/lcov-report/src/api/controllers/routing.ts.html +5 -5
- package/coverage/lcov-report/src/api/controllers/row/ExternalRequest.ts.html +48 -30
- package/coverage/lcov-report/src/api/controllers/row/external.ts.html +38 -38
- package/coverage/lcov-report/src/api/controllers/row/index.html +58 -58
- package/coverage/lcov-report/src/api/controllers/row/index.ts.html +12 -12
- package/coverage/lcov-report/src/api/controllers/row/internal.ts.html +39 -36
- package/coverage/lcov-report/src/api/controllers/row/internalSearch.ts.html +28 -28
- package/coverage/lcov-report/src/api/controllers/row/staticFormula.ts.html +14 -14
- package/coverage/lcov-report/src/api/controllers/row/utils.ts.html +7 -7
- package/coverage/lcov-report/src/api/controllers/screen.ts.html +8 -8
- package/coverage/lcov-report/src/api/controllers/script.ts.html +10 -10
- package/coverage/lcov-report/src/api/controllers/static/index.html +15 -15
- package/coverage/lcov-report/src/api/controllers/static/index.ts.html +17 -17
- package/coverage/lcov-report/src/api/controllers/table/bulkFormula.ts.html +10 -10
- package/coverage/lcov-report/src/api/controllers/table/external.ts.html +33 -33
- package/coverage/lcov-report/src/api/controllers/table/index.html +48 -48
- package/coverage/lcov-report/src/api/controllers/table/index.ts.html +128 -41
- package/coverage/lcov-report/src/api/controllers/table/internal.ts.html +19 -22
- package/coverage/lcov-report/src/api/controllers/table/utils.ts.html +52 -55
- package/coverage/lcov-report/src/api/controllers/templates.ts.html +15 -15
- package/coverage/lcov-report/src/api/controllers/user.ts.html +101 -77
- package/coverage/lcov-report/src/api/controllers/view/exporters.ts.html +63 -18
- package/coverage/lcov-report/src/api/controllers/view/index.html +38 -38
- package/coverage/lcov-report/src/api/controllers/view/index.ts.html +62 -35
- package/coverage/lcov-report/src/api/controllers/view/utils.ts.html +19 -19
- package/coverage/lcov-report/src/api/controllers/view/viewBuilder.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/webhook.ts.html +4 -4
- package/coverage/lcov-report/src/api/index.html +15 -15
- package/coverage/lcov-report/src/api/index.ts.html +10 -10
- package/coverage/lcov-report/src/api/routes/analytics.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/apikeys.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/application.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/auth.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/automation.ts.html +5 -5
- package/coverage/lcov-report/src/api/routes/backup.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/cloud.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/component.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/datasource.ts.html +5 -5
- package/coverage/lcov-report/src/api/routes/deploy.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/dev.ts.html +5 -5
- package/coverage/lcov-report/src/api/routes/index.html +66 -66
- package/coverage/lcov-report/src/api/routes/index.ts.html +5 -5
- package/coverage/lcov-report/src/api/routes/integration.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/layout.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/metadata.ts.html +5 -5
- package/coverage/lcov-report/src/api/routes/migrations.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/permission.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/plugin.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/public/applications.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/public/index.html +24 -24
- package/coverage/lcov-report/src/api/routes/public/index.ts.html +10 -10
- package/coverage/lcov-report/src/api/routes/public/middleware/index.html +5 -5
- 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 +3 -3
- package/coverage/lcov-report/src/api/routes/public/rows.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/public/tables.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/public/tests/index.html +7 -7
- package/coverage/lcov-report/src/api/routes/public/tests/utils.ts.html +5 -5
- package/coverage/lcov-report/src/api/routes/public/users.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/public/utils/Endpoint.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/public/utils/index.html +5 -5
- package/coverage/lcov-report/src/api/routes/query.ts.html +5 -5
- package/coverage/lcov-report/src/api/routes/role.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/routing.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/row.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/screen.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/script.ts.html +13 -13
- package/coverage/lcov-report/src/api/routes/static.ts.html +6 -6
- package/coverage/lcov-report/src/api/routes/table.ts.html +20 -89
- package/coverage/lcov-report/src/api/routes/templates.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/tests/utilities/TestFunctions.ts.html +13 -13
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.html +23 -23
- package/coverage/lcov-report/src/api/routes/tests/utilities/index.ts.html +14 -14
- package/coverage/lcov-report/src/api/routes/user.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/utils/index.html +3 -3
- package/coverage/lcov-report/src/api/routes/utils/validators.ts.html +8 -8
- package/coverage/lcov-report/src/api/routes/view.ts.html +4 -4
- package/coverage/lcov-report/src/api/routes/webhook.ts.html +4 -4
- package/coverage/lcov-report/src/app.ts.html +22 -16
- package/coverage/lcov-report/src/automations/actions.ts.html +9 -9
- package/coverage/lcov-report/src/automations/automationUtils.ts.html +15 -15
- package/coverage/lcov-report/src/automations/bullboard.ts.html +12 -12
- package/coverage/lcov-report/src/automations/index.html +52 -52
- package/coverage/lcov-report/src/automations/index.ts.html +16 -16
- package/coverage/lcov-report/src/automations/logging/index.html +3 -3
- package/coverage/lcov-report/src/automations/logging/index.ts.html +5 -5
- package/coverage/lcov-report/src/automations/steps/bash.ts.html +5 -5
- package/coverage/lcov-report/src/automations/steps/createRow.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/delay.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/deleteRow.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/discord.ts.html +5 -5
- package/coverage/lcov-report/src/automations/steps/executeQuery.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/executeScript.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/filter.ts.html +8 -8
- package/coverage/lcov-report/src/automations/steps/index.html +71 -71
- 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 +12 -12
- package/coverage/lcov-report/src/automations/steps/queryRows.ts.html +12 -12
- package/coverage/lcov-report/src/automations/steps/sendSmtpEmail.ts.html +5 -5
- package/coverage/lcov-report/src/automations/steps/serverLog.ts.html +5 -5
- package/coverage/lcov-report/src/automations/steps/slack.ts.html +6 -6
- package/coverage/lcov-report/src/automations/steps/updateRow.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/utils.ts.html +4 -4
- package/coverage/lcov-report/src/automations/steps/zapier.ts.html +4 -4
- package/coverage/lcov-report/src/automations/tests/utilities/index.html +15 -15
- package/coverage/lcov-report/src/automations/tests/utilities/index.ts.html +14 -14
- package/coverage/lcov-report/src/automations/triggerInfo/app.ts.html +5 -5
- package/coverage/lcov-report/src/automations/triggerInfo/cron.ts.html +5 -5
- package/coverage/lcov-report/src/automations/triggerInfo/index.html +17 -17
- package/coverage/lcov-report/src/automations/triggerInfo/index.ts.html +4 -4
- package/coverage/lcov-report/src/automations/triggerInfo/rowDeleted.ts.html +5 -5
- package/coverage/lcov-report/src/automations/triggerInfo/rowSaved.ts.html +5 -5
- package/coverage/lcov-report/src/automations/triggerInfo/rowUpdated.ts.html +5 -5
- package/coverage/lcov-report/src/automations/triggerInfo/webhook.ts.html +5 -5
- package/coverage/lcov-report/src/automations/triggers.ts.html +11 -11
- package/coverage/lcov-report/src/automations/utils.ts.html +37 -37
- package/coverage/lcov-report/src/constants/index.html +19 -19
- package/coverage/lcov-report/src/constants/index.ts.html +103 -103
- package/coverage/lcov-report/src/constants/layouts.ts.html +6 -6
- package/coverage/lcov-report/src/constants/screens.ts.html +2 -2
- package/coverage/lcov-report/src/db/defaultData/datasource_bb_default.ts.html +25 -25
- package/coverage/lcov-report/src/db/defaultData/employeeImport.ts.html +7 -7
- package/coverage/lcov-report/src/db/defaultData/expensesImport.ts.html +7 -7
- package/coverage/lcov-report/src/db/defaultData/index.html +43 -43
- package/coverage/lcov-report/src/db/defaultData/inventoryImport.ts.html +7 -7
- package/coverage/lcov-report/src/db/defaultData/jobsImport.ts.html +7 -7
- package/coverage/lcov-report/src/db/dynamoClient.ts.html +12 -12
- package/coverage/lcov-report/src/db/inMemoryView.ts.html +10 -10
- package/coverage/lcov-report/src/db/index.html +32 -32
- package/coverage/lcov-report/src/db/index.ts.html +3 -3
- package/coverage/lcov-report/src/db/linkedRows/LinkController.ts.html +22 -22
- package/coverage/lcov-report/src/db/linkedRows/LinkDocument.ts.html +4 -4
- package/coverage/lcov-report/src/db/linkedRows/index.html +37 -37
- package/coverage/lcov-report/src/db/linkedRows/index.ts.html +18 -18
- package/coverage/lcov-report/src/db/linkedRows/linkUtils.ts.html +15 -15
- package/coverage/lcov-report/src/db/newid.ts.html +4 -4
- package/coverage/lcov-report/src/db/utils.ts.html +59 -59
- 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 +4 -4
- package/coverage/lcov-report/src/environment.ts.html +25 -25
- package/coverage/lcov-report/src/events/AutomationEmitter.ts.html +7 -7
- package/coverage/lcov-report/src/events/BudibaseEmitter.ts.html +4 -4
- package/coverage/lcov-report/src/events/index.html +20 -20
- package/coverage/lcov-report/src/events/index.ts.html +5 -5
- package/coverage/lcov-report/src/events/utils.ts.html +11 -11
- package/coverage/lcov-report/src/index.html +36 -36
- package/coverage/lcov-report/src/index.ts.html +6 -6
- package/coverage/lcov-report/src/integrations/airtable.ts.html +8 -8
- package/coverage/lcov-report/src/integrations/arangodb.ts.html +7 -7
- package/coverage/lcov-report/src/integrations/base/index.html +20 -20
- package/coverage/lcov-report/src/integrations/base/query.ts.html +2 -2
- package/coverage/lcov-report/src/integrations/base/sql.ts.html +28 -28
- package/coverage/lcov-report/src/integrations/base/sqlTable.ts.html +15 -15
- package/coverage/lcov-report/src/integrations/base/utils.ts.html +2 -2
- package/coverage/lcov-report/src/integrations/couchdb.ts.html +8 -8
- package/coverage/lcov-report/src/integrations/dynamodb.ts.html +12 -12
- package/coverage/lcov-report/src/integrations/elasticsearch.ts.html +7 -7
- package/coverage/lcov-report/src/integrations/firebase.ts.html +10 -10
- package/coverage/lcov-report/src/integrations/googlesheets.ts.html +33 -33
- package/coverage/lcov-report/src/integrations/index.html +123 -123
- package/coverage/lcov-report/src/integrations/index.ts.html +13 -13
- package/coverage/lcov-report/src/integrations/microsoftSqlServer.ts.html +26 -26
- package/coverage/lcov-report/src/integrations/mongodb.ts.html +15 -15
- package/coverage/lcov-report/src/integrations/mysql.ts.html +20 -20
- package/coverage/lcov-report/src/integrations/oracle.ts.html +21 -21
- package/coverage/lcov-report/src/integrations/postgres.ts.html +15 -15
- package/coverage/lcov-report/src/integrations/queries/index.html +5 -5
- package/coverage/lcov-report/src/integrations/queries/sql.ts.html +6 -6
- package/coverage/lcov-report/src/integrations/redis.ts.html +5 -5
- package/coverage/lcov-report/src/integrations/rest.ts.html +15 -15
- package/coverage/lcov-report/src/integrations/s3.ts.html +14 -14
- package/coverage/lcov-report/src/integrations/snowflake.ts.html +12 -12
- 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 +34 -34
- package/coverage/lcov-report/src/middleware/appInfo.ts.html +8 -8
- package/coverage/lcov-report/src/middleware/authorized.ts.html +26 -14
- package/coverage/lcov-report/src/middleware/builder.ts.html +12 -12
- package/coverage/lcov-report/src/middleware/currentapp.ts.html +14 -11
- package/coverage/lcov-report/src/middleware/index.html +40 -40
- package/coverage/lcov-report/src/middleware/joi-validator.ts.html +10 -10
- package/coverage/lcov-report/src/middleware/publicApi.ts.html +7 -7
- package/coverage/lcov-report/src/middleware/resourceId.ts.html +6 -6
- package/coverage/lcov-report/src/middleware/selfhost.ts.html +2 -2
- package/coverage/lcov-report/src/middleware/utils.ts.html +2 -2
- package/coverage/lcov-report/src/migrations/functions/appUrls.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/functions/backfill/app/automations.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/app/datasources.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/app/index.html +31 -31
- package/coverage/lcov-report/src/migrations/functions/backfill/app/layouts.ts.html +4 -4
- 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 +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/app/screens.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/app/tables.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/backfill/app.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/global/configs.ts.html +6 -6
- package/coverage/lcov-report/src/migrations/functions/backfill/global/index.html +19 -19
- package/coverage/lcov-report/src/migrations/functions/backfill/global/quotas.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/global/users.ts.html +8 -8
- package/coverage/lcov-report/src/migrations/functions/backfill/global.ts.html +11 -11
- package/coverage/lcov-report/src/migrations/functions/backfill/index.html +26 -26
- package/coverage/lcov-report/src/migrations/functions/backfill/index.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/functions/backfill/installation.ts.html +7 -7
- package/coverage/lcov-report/src/migrations/functions/index.html +18 -18
- package/coverage/lcov-report/src/migrations/functions/syncQuotas.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/functions/tableSettings.ts.html +7 -7
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.html +11 -11
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/index.ts.html +2 -2
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncApps.ts.html +2 -2
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncPlugins.ts.html +5 -5
- package/coverage/lcov-report/src/migrations/functions/usageQuotas/syncRows.ts.html +2 -2
- package/coverage/lcov-report/src/migrations/functions/userEmailViewCasing.ts.html +3 -3
- package/coverage/lcov-report/src/migrations/index.html +15 -15
- package/coverage/lcov-report/src/migrations/index.ts.html +13 -13
- package/coverage/lcov-report/src/migrations/tests/helpers.ts.html +4 -4
- package/coverage/lcov-report/src/migrations/tests/index.html +6 -6
- package/coverage/lcov-report/src/migrations/tests/structures.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/applications/index.html +11 -11
- package/coverage/lcov-report/src/sdk/app/applications/index.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/applications/sync.ts.html +20 -20
- package/coverage/lcov-report/src/sdk/app/applications/utils.ts.html +13 -13
- package/coverage/lcov-report/src/sdk/app/automations/index.html +7 -7
- 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 +15 -15
- package/coverage/lcov-report/src/sdk/app/backups/imports.ts.html +8 -8
- package/coverage/lcov-report/src/sdk/app/backups/index.html +27 -27
- package/coverage/lcov-report/src/sdk/app/backups/index.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/backups/statistics.ts.html +7 -7
- package/coverage/lcov-report/src/sdk/app/rows/attachments.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/rows/index.html +8 -8
- package/coverage/lcov-report/src/sdk/app/rows/index.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/app/rows/rows.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/app/tables/index.html +11 -11
- package/coverage/lcov-report/src/sdk/app/tables/index.ts.html +7 -7
- package/coverage/lcov-report/src/sdk/index.html +5 -5
- package/coverage/lcov-report/src/sdk/index.ts.html +4 -4
- package/coverage/lcov-report/src/sdk/users/index.html +6 -6
- package/coverage/lcov-report/src/sdk/users/index.ts.html +3 -3
- package/coverage/lcov-report/src/sdk/users/utils.ts.html +23 -23
- package/coverage/lcov-report/src/startup.ts.html +10 -25
- package/coverage/lcov-report/src/tests/utilities/TestConfiguration.ts.html +61 -61
- package/coverage/lcov-report/src/tests/utilities/controllers.ts.html +11 -11
- package/coverage/lcov-report/src/tests/utilities/index.html +26 -26
- package/coverage/lcov-report/src/tests/utilities/index.ts.html +2 -2
- package/coverage/lcov-report/src/tests/utilities/structures.ts.html +30 -30
- package/coverage/lcov-report/src/threads/automation.ts.html +20 -20
- package/coverage/lcov-report/src/threads/index.html +39 -39
- package/coverage/lcov-report/src/threads/index.ts.html +17 -17
- package/coverage/lcov-report/src/threads/query.ts.html +12 -12
- package/coverage/lcov-report/src/threads/utils.ts.html +19 -19
- package/coverage/lcov-report/src/utilities/budibaseDir.ts.html +5 -5
- package/coverage/lcov-report/src/utilities/centralPath.ts.html +6 -6
- package/coverage/lcov-report/src/utilities/fileSystem/app.ts.html +22 -22
- package/coverage/lcov-report/src/utilities/fileSystem/clientLibrary.ts.html +19 -19
- package/coverage/lcov-report/src/utilities/fileSystem/filesystem.ts.html +35 -35
- package/coverage/lcov-report/src/utilities/fileSystem/index.html +42 -42
- package/coverage/lcov-report/src/utilities/fileSystem/index.ts.html +6 -6
- package/coverage/lcov-report/src/utilities/fileSystem/plugin.ts.html +13 -13
- package/coverage/lcov-report/src/utilities/fileSystem/processor.ts.html +9 -9
- package/coverage/lcov-report/src/utilities/fileSystem/template.ts.html +11 -11
- package/coverage/lcov-report/src/utilities/global.ts.html +51 -51
- package/coverage/lcov-report/src/utilities/index.html +74 -89
- package/coverage/lcov-report/src/utilities/index.ts.html +25 -25
- package/coverage/lcov-report/src/utilities/redis.ts.html +25 -25
- package/coverage/lcov-report/src/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/src/utilities/routing/index.ts.html +2 -2
- package/coverage/lcov-report/src/utilities/rowProcessor/index.html +32 -32
- package/coverage/lcov-report/src/utilities/rowProcessor/index.ts.html +20 -20
- package/coverage/lcov-report/src/utilities/rowProcessor/map.ts.html +8 -8
- package/coverage/lcov-report/src/utilities/rowProcessor/utils.ts.html +15 -15
- package/coverage/lcov-report/src/utilities/{csvParser.ts.html → schema.ts.html} +174 -234
- package/coverage/lcov-report/src/utilities/scriptRunner.ts.html +4 -4
- package/coverage/lcov-report/src/utilities/security.ts.html +10 -10
- package/coverage/lcov-report/src/utilities/usageQuota/index.html +9 -9
- package/coverage/lcov-report/src/utilities/usageQuota/rows.ts.html +5 -5
- package/coverage/lcov-report/src/utilities/usageQuota/usageQuoteReset.ts.html +3 -3
- package/coverage/lcov-report/src/utilities/users.ts.html +4 -4
- package/coverage/lcov-report/src/utilities/workerRequests.ts.html +57 -30
- package/coverage/lcov-report/src/watch.ts.html +13 -13
- package/coverage/lcov-report/src/websocket.ts.html +3 -3
- package/coverage/lcov.info +7522 -7169
- package/dist/api/controllers/query/index.js +5 -2
- package/dist/api/controllers/row/ExternalRequest.js +7 -0
- package/dist/api/controllers/row/internal.js +12 -8
- package/dist/api/controllers/static/index.js +7 -4
- package/dist/api/controllers/static/templates/BudibaseApp.svelte +0 -1
- package/dist/api/controllers/table/external.js +8 -30
- package/dist/api/controllers/table/index.js +44 -15
- package/dist/api/controllers/table/internal.js +6 -7
- package/dist/api/controllers/table/utils.js +9 -9
- package/dist/api/controllers/user.js +14 -6
- package/dist/api/controllers/view/exporters.js +22 -6
- package/dist/api/controllers/view/index.js +19 -34
- package/dist/api/controllers/view/viewBuilder.js +15 -2
- package/dist/api/routes/analytics.js +2 -1
- package/dist/api/routes/apikeys.js +2 -1
- package/dist/api/routes/application.js +2 -1
- package/dist/api/routes/auth.js +2 -1
- package/dist/api/routes/automation.js +2 -1
- package/dist/api/routes/backup.js +2 -1
- package/dist/api/routes/cloud.js +2 -1
- package/dist/api/routes/component.js +2 -1
- package/dist/api/routes/datasource.js +2 -1
- package/dist/api/routes/deploy.js +2 -1
- package/dist/api/routes/dev.js +2 -1
- package/dist/api/routes/integration.js +2 -1
- package/dist/api/routes/layout.js +2 -1
- package/dist/api/routes/metadata.js +2 -1
- package/dist/api/routes/migrations.js +2 -1
- package/dist/api/routes/permission.js +2 -1
- package/dist/api/routes/query.js +2 -1
- package/dist/api/routes/role.js +2 -1
- package/dist/api/routes/routing.js +2 -1
- package/dist/api/routes/screen.js +2 -1
- package/dist/api/routes/script.js +2 -1
- package/dist/api/routes/static.js +6 -5
- package/dist/api/routes/table.js +8 -38
- package/dist/api/routes/templates.js +2 -1
- package/dist/api/routes/user.js +2 -1
- package/dist/api/routes/utils/validators.js +1 -1
- package/dist/api/routes/view.js +2 -1
- package/dist/api/routes/webhook.js +2 -1
- package/dist/app.js +9 -7
- package/dist/automations/logging/index.js +5 -25
- package/dist/db/index.js +5 -2
- package/dist/db/linkedRows/LinkController.js +2 -1
- package/dist/db/linkedRows/LinkDocument.js +2 -1
- package/dist/db/newid.js +4 -2
- package/dist/environment.js +2 -1
- package/dist/events/AutomationEmitter.js +2 -1
- package/dist/events/BudibaseEmitter.js +2 -1
- package/dist/events/index.js +2 -1
- package/dist/integrations/index.js +5 -5
- package/dist/middleware/authorized.js +2 -1
- package/dist/middleware/builder.js +4 -2
- package/dist/middleware/currentapp.js +6 -3
- package/dist/middleware/publicApi.js +4 -2
- package/dist/middleware/selfhost.js +4 -1
- package/dist/package.json +9 -7
- package/dist/startup.js +17 -17
- package/dist/threads/index.js +4 -4
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/filesystem.js +3 -3
- package/dist/utilities/schema.js +108 -0
- package/dist/utilities/scriptRunner.js +2 -1
- package/dist/utilities/statusCodes.js +2 -1
- package/dist/utilities/workerRequests.js +2 -0
- package/dist/watch.js +2 -25
- package/jest.config.ts +5 -2
- package/package.json +10 -8
- package/src/api/controllers/query/index.ts +2 -2
- package/src/api/controllers/row/ExternalRequest.ts +6 -0
- package/src/api/controllers/row/internal.ts +10 -9
- package/src/api/controllers/static/index.ts +1 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +0 -1
- package/src/api/controllers/table/external.ts +10 -10
- package/src/api/controllers/table/index.ts +46 -17
- package/src/api/controllers/table/internal.ts +6 -7
- package/src/api/controllers/table/utils.ts +12 -13
- package/src/api/controllers/user.ts +21 -13
- package/src/api/controllers/view/exporters.ts +20 -5
- package/src/api/controllers/view/index.ts +21 -12
- package/src/api/controllers/view/tests/viewBuilder.spec.js +1 -1
- package/src/api/controllers/view/viewBuilder.ts +1 -1
- package/src/api/routes/analytics.ts +1 -1
- package/src/api/routes/apikeys.ts +1 -1
- package/src/api/routes/application.ts +1 -1
- package/src/api/routes/auth.ts +1 -1
- package/src/api/routes/automation.ts +1 -1
- package/src/api/routes/backup.ts +1 -1
- package/src/api/routes/cloud.ts +1 -1
- package/src/api/routes/component.ts +1 -1
- package/src/api/routes/datasource.ts +1 -1
- package/src/api/routes/deploy.ts +1 -1
- package/src/api/routes/dev.ts +1 -1
- package/src/api/routes/integration.ts +1 -1
- package/src/api/routes/layout.ts +1 -1
- package/src/api/routes/metadata.ts +1 -1
- package/src/api/routes/migrations.ts +1 -1
- package/src/api/routes/permission.ts +1 -1
- package/src/api/routes/query.ts +1 -1
- package/src/api/routes/role.ts +1 -1
- package/src/api/routes/routing.ts +1 -1
- package/src/api/routes/screen.ts +1 -1
- package/src/api/routes/script.ts +1 -1
- package/src/api/routes/static.ts +2 -2
- package/src/api/routes/table.ts +16 -39
- package/src/api/routes/templates.ts +1 -1
- package/src/api/routes/tests/misc.spec.js +4 -10
- package/src/api/routes/tests/plugin.spec.ts +10 -10
- package/src/api/routes/tests/table.spec.js +8 -30
- package/src/api/routes/tests/user.spec.js +20 -1
- package/src/api/routes/tests/utilities/TestFunctions.ts +1 -1
- package/src/api/routes/user.ts +1 -1
- package/src/api/routes/utils/validators.ts +1 -1
- package/src/api/routes/view.ts +1 -1
- package/src/api/routes/webhook.ts +1 -1
- package/src/app.ts +5 -3
- package/src/automations/logging/index.ts +1 -1
- package/src/db/index.ts +1 -1
- package/src/db/linkedRows/LinkController.ts +1 -1
- package/src/db/linkedRows/LinkDocument.ts +1 -1
- package/src/db/newid.ts +1 -1
- package/src/db/tests/linkController.spec.js +1 -1
- package/src/environment.ts +1 -1
- package/src/events/AutomationEmitter.ts +1 -1
- package/src/events/BudibaseEmitter.ts +1 -1
- package/src/events/index.ts +1 -1
- package/src/integrations/index.ts +4 -4
- package/src/integrations/tests/rest.spec.ts +15 -13
- package/src/middleware/authorized.ts +5 -1
- package/src/middleware/builder.ts +1 -1
- package/src/middleware/currentapp.ts +4 -3
- package/src/middleware/publicApi.ts +1 -1
- package/src/middleware/selfhost.ts +1 -1
- package/src/middleware/tests/authorized.spec.js +1 -1
- package/src/middleware/tests/currentapp.spec.js +1 -1
- package/src/middleware/tests/selfhost.spec.js +1 -1
- package/src/startup.ts +3 -8
- package/src/tests/jestEnv.ts +13 -0
- package/src/tests/jestSetup.ts +0 -14
- package/src/tests/utilities/TestConfiguration.ts +1 -1
- package/src/threads/index.ts +1 -1
- package/src/utilities/fileSystem/filesystem.ts +1 -1
- package/src/utilities/schema.ts +141 -0
- package/src/utilities/scriptRunner.ts +1 -1
- package/src/utilities/statusCodes.ts +1 -1
- package/src/utilities/workerRequests.ts +10 -1
- package/src/watch.ts +1 -1
- package/builder/assets/index.fa480d5b.css +0 -6
- package/coverage/lcov-report/src/utilities/statusCodes.ts.html +0 -106
- package/dist/utilities/csvParser.js +0 -152
- package/src/utilities/csvParser.ts +0 -161
- package/src/utilities/tests/__snapshots__/csvParser.spec.js.snap +0 -15
- package/src/utilities/tests/csvParser.spec.js +0 -112
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for src/utilities/statusCodes.ts</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/utilities</a> statusCodes.ts</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">0% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>0/1</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">100% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>0/0</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>0/0</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">0% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>0/1</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input oninput="onInput()" type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line low'></div>
|
|
65
|
-
<pre><table class="coverage">
|
|
66
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
-
<a name='L8'></a><a href='#L8'>8</a></td><td class="line-coverage quiet"><span class="cline-any cline-no"> </span>
|
|
74
|
-
<span class="cline-any cline-neutral"> </span>
|
|
75
|
-
<span class="cline-any cline-neutral"> </span>
|
|
76
|
-
<span class="cline-any cline-neutral"> </span>
|
|
77
|
-
<span class="cline-any cline-neutral"> </span>
|
|
78
|
-
<span class="cline-any cline-neutral"> </span>
|
|
79
|
-
<span class="cline-any cline-neutral"> </span>
|
|
80
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js"><span class="cstat-no" title="statement not covered" >export = {</span>
|
|
81
|
-
OK: 200,
|
|
82
|
-
UNAUTHORIZED: 401,
|
|
83
|
-
FORBIDDEN: 403,
|
|
84
|
-
NOT_FOUND: 404,
|
|
85
|
-
INTERAL_ERROR: 500,
|
|
86
|
-
}
|
|
87
|
-
</pre></td></tr></table></pre>
|
|
88
|
-
|
|
89
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
90
|
-
</div><!-- /wrapper -->
|
|
91
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
92
|
-
Code coverage generated by
|
|
93
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
94
|
-
at Tue Jan 10 2023 11:12:48 GMT+0000 (Coordinated Universal Time)
|
|
95
|
-
</div>
|
|
96
|
-
<script src="../../prettify.js"></script>
|
|
97
|
-
<script>
|
|
98
|
-
window.onload = function () {
|
|
99
|
-
prettyPrint();
|
|
100
|
-
};
|
|
101
|
-
</script>
|
|
102
|
-
<script src="../../sorter.js"></script>
|
|
103
|
-
<script src="../../block-navigation.js"></script>
|
|
104
|
-
</body>
|
|
105
|
-
</html>
|
|
106
|
-
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.transform = exports.updateSchema = exports.parse = void 0;
|
|
16
|
-
const csvtojson_1 = __importDefault(require("csvtojson"));
|
|
17
|
-
const constants_1 = require("../constants");
|
|
18
|
-
const VALIDATORS = {
|
|
19
|
-
[constants_1.FieldTypes.STRING]: () => true,
|
|
20
|
-
[constants_1.FieldTypes.OPTIONS]: () => true,
|
|
21
|
-
[constants_1.FieldTypes.BARCODEQR]: () => true,
|
|
22
|
-
[constants_1.FieldTypes.NUMBER]: (attribute) => {
|
|
23
|
-
// allow not to be present
|
|
24
|
-
if (!attribute) {
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
return !isNaN(Number(attribute));
|
|
28
|
-
},
|
|
29
|
-
[constants_1.FieldTypes.DATETIME]: (attribute) => {
|
|
30
|
-
// allow not to be present
|
|
31
|
-
if (!attribute) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
return !isNaN(new Date(attribute).getTime());
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
const PARSERS = {
|
|
38
|
-
[constants_1.FieldTypes.NUMBER]: (attribute) => {
|
|
39
|
-
if (!attribute) {
|
|
40
|
-
return attribute;
|
|
41
|
-
}
|
|
42
|
-
return Number(attribute);
|
|
43
|
-
},
|
|
44
|
-
[constants_1.FieldTypes.DATETIME]: (attribute) => {
|
|
45
|
-
if (!attribute) {
|
|
46
|
-
return attribute;
|
|
47
|
-
}
|
|
48
|
-
return new Date(attribute).toISOString();
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
function parse(csvString, parsers) {
|
|
52
|
-
const result = (0, csvtojson_1.default)().fromString(csvString);
|
|
53
|
-
const schema = {};
|
|
54
|
-
return new Promise((resolve, reject) => {
|
|
55
|
-
result.on("header", headers => {
|
|
56
|
-
for (let header of headers) {
|
|
57
|
-
schema[header] = {
|
|
58
|
-
type: parsers[header] ? parsers[header].type : "string",
|
|
59
|
-
success: true,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
result.subscribe(row => {
|
|
64
|
-
// For each CSV row parse all the columns that need parsed
|
|
65
|
-
for (let key of Object.keys(parsers)) {
|
|
66
|
-
if (!schema[key] || schema[key].success) {
|
|
67
|
-
// get the validator for the column type
|
|
68
|
-
const validator = VALIDATORS[parsers[key].type];
|
|
69
|
-
try {
|
|
70
|
-
// allow null/undefined values
|
|
71
|
-
schema[key].success = !row[key] || validator(row[key]);
|
|
72
|
-
}
|
|
73
|
-
catch (err) {
|
|
74
|
-
schema[key].success = false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
result.on("done", error => {
|
|
80
|
-
if (error) {
|
|
81
|
-
console.error(error);
|
|
82
|
-
reject(error);
|
|
83
|
-
}
|
|
84
|
-
resolve(schema);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
exports.parse = parse;
|
|
89
|
-
function updateSchema({ schema, existingTable, }) {
|
|
90
|
-
if (!schema) {
|
|
91
|
-
return schema;
|
|
92
|
-
}
|
|
93
|
-
const finalSchema = {};
|
|
94
|
-
const schemaKeyMap = {};
|
|
95
|
-
Object.keys(schema).forEach(key => (schemaKeyMap[key.toLowerCase()] = key));
|
|
96
|
-
for (let [key, field] of Object.entries((existingTable === null || existingTable === void 0 ? void 0 : existingTable.schema) || {})) {
|
|
97
|
-
const lcKey = key.toLowerCase();
|
|
98
|
-
const foundKey = schemaKeyMap[lcKey];
|
|
99
|
-
if (foundKey) {
|
|
100
|
-
finalSchema[key] = schema[foundKey];
|
|
101
|
-
finalSchema[key].type = field.type;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return finalSchema;
|
|
105
|
-
}
|
|
106
|
-
exports.updateSchema = updateSchema;
|
|
107
|
-
function transform({ schema, csvString, existingTable, }) {
|
|
108
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
if (!schema || !csvString) {
|
|
110
|
-
throw new Error("Unable to transform CSV without schema");
|
|
111
|
-
}
|
|
112
|
-
const colParser = {};
|
|
113
|
-
// make sure the table has all the columns required for import
|
|
114
|
-
if (existingTable) {
|
|
115
|
-
schema = updateSchema({ schema, existingTable });
|
|
116
|
-
}
|
|
117
|
-
for (let [key, field] of Object.entries(schema || {})) {
|
|
118
|
-
// don't import data to auto columns
|
|
119
|
-
if (!field.autocolumn) {
|
|
120
|
-
colParser[key] = PARSERS[field.type] || field.type;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
try {
|
|
124
|
-
const data = yield (0, csvtojson_1.default)({ colParser }).fromString(csvString);
|
|
125
|
-
const schemaKeyMap = {};
|
|
126
|
-
Object.keys(schema || {}).forEach(key => (schemaKeyMap[key.toLowerCase()] = key));
|
|
127
|
-
for (let element of data) {
|
|
128
|
-
if (!data) {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
for (let key of Object.keys(element)) {
|
|
132
|
-
const mappedKey = schemaKeyMap[key.toLowerCase()];
|
|
133
|
-
// isn't a column in the table, remove it
|
|
134
|
-
if (mappedKey == null) {
|
|
135
|
-
delete element[key];
|
|
136
|
-
}
|
|
137
|
-
// casing is different, fix it in row
|
|
138
|
-
else if (key !== mappedKey) {
|
|
139
|
-
element[mappedKey] = element[key];
|
|
140
|
-
delete element[key];
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return data;
|
|
145
|
-
}
|
|
146
|
-
catch (err) {
|
|
147
|
-
console.error(`Error transforming CSV to JSON for data import`, err);
|
|
148
|
-
throw err;
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
exports.transform = transform;
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { FieldSchema, Table } from "@budibase/types"
|
|
2
|
-
import csv from "csvtojson"
|
|
3
|
-
import { FieldTypes } from "../constants"
|
|
4
|
-
|
|
5
|
-
type CsvParseOpts = {
|
|
6
|
-
schema?: { [key: string]: any }
|
|
7
|
-
existingTable: Table
|
|
8
|
-
csvString?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const VALIDATORS: any = {
|
|
12
|
-
[FieldTypes.STRING]: () => true,
|
|
13
|
-
[FieldTypes.OPTIONS]: () => true,
|
|
14
|
-
[FieldTypes.BARCODEQR]: () => true,
|
|
15
|
-
[FieldTypes.NUMBER]: (attribute?: string) => {
|
|
16
|
-
// allow not to be present
|
|
17
|
-
if (!attribute) {
|
|
18
|
-
return true
|
|
19
|
-
}
|
|
20
|
-
return !isNaN(Number(attribute))
|
|
21
|
-
},
|
|
22
|
-
[FieldTypes.DATETIME]: (attribute?: string) => {
|
|
23
|
-
// allow not to be present
|
|
24
|
-
if (!attribute) {
|
|
25
|
-
return true
|
|
26
|
-
}
|
|
27
|
-
return !isNaN(new Date(attribute).getTime())
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const PARSERS: any = {
|
|
32
|
-
[FieldTypes.NUMBER]: (attribute?: string) => {
|
|
33
|
-
if (!attribute) {
|
|
34
|
-
return attribute
|
|
35
|
-
}
|
|
36
|
-
return Number(attribute)
|
|
37
|
-
},
|
|
38
|
-
[FieldTypes.DATETIME]: (attribute?: string) => {
|
|
39
|
-
if (!attribute) {
|
|
40
|
-
return attribute
|
|
41
|
-
}
|
|
42
|
-
return new Date(attribute).toISOString()
|
|
43
|
-
},
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function parse(csvString: string, parsers: any): Record<string, any> {
|
|
47
|
-
const result = csv().fromString(csvString)
|
|
48
|
-
|
|
49
|
-
const schema: Record<string, any> = {}
|
|
50
|
-
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
result.on("header", headers => {
|
|
53
|
-
for (let header of headers) {
|
|
54
|
-
schema[header] = {
|
|
55
|
-
type: parsers[header] ? parsers[header].type : "string",
|
|
56
|
-
success: true,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
})
|
|
60
|
-
result.subscribe(row => {
|
|
61
|
-
// For each CSV row parse all the columns that need parsed
|
|
62
|
-
for (let key of Object.keys(parsers)) {
|
|
63
|
-
if (!schema[key] || schema[key].success) {
|
|
64
|
-
// get the validator for the column type
|
|
65
|
-
const validator = VALIDATORS[parsers[key].type]
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
// allow null/undefined values
|
|
69
|
-
schema[key].success = !row[key] || validator(row[key])
|
|
70
|
-
} catch (err) {
|
|
71
|
-
schema[key].success = false
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
result.on("done", error => {
|
|
77
|
-
if (error) {
|
|
78
|
-
console.error(error)
|
|
79
|
-
reject(error)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
resolve(schema)
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function updateSchema({
|
|
88
|
-
schema,
|
|
89
|
-
existingTable,
|
|
90
|
-
}: {
|
|
91
|
-
schema?: Record<string, any>
|
|
92
|
-
existingTable?: Table
|
|
93
|
-
}) {
|
|
94
|
-
if (!schema) {
|
|
95
|
-
return schema
|
|
96
|
-
}
|
|
97
|
-
const finalSchema: Record<string, FieldSchema> = {}
|
|
98
|
-
const schemaKeyMap: Record<string, any> = {}
|
|
99
|
-
Object.keys(schema).forEach(key => (schemaKeyMap[key.toLowerCase()] = key))
|
|
100
|
-
for (let [key, field] of Object.entries(existingTable?.schema || {})) {
|
|
101
|
-
const lcKey = key.toLowerCase()
|
|
102
|
-
const foundKey: string = schemaKeyMap[lcKey]
|
|
103
|
-
if (foundKey) {
|
|
104
|
-
finalSchema[key] = schema[foundKey]
|
|
105
|
-
finalSchema[key].type = field.type
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return finalSchema
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export async function transform({
|
|
112
|
-
schema,
|
|
113
|
-
csvString,
|
|
114
|
-
existingTable,
|
|
115
|
-
}: CsvParseOpts) {
|
|
116
|
-
if (!schema || !csvString) {
|
|
117
|
-
throw new Error("Unable to transform CSV without schema")
|
|
118
|
-
}
|
|
119
|
-
const colParser: any = {}
|
|
120
|
-
|
|
121
|
-
// make sure the table has all the columns required for import
|
|
122
|
-
if (existingTable) {
|
|
123
|
-
schema = updateSchema({ schema, existingTable })
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
for (let [key, field] of Object.entries(schema || {})) {
|
|
127
|
-
// don't import data to auto columns
|
|
128
|
-
if (!field.autocolumn) {
|
|
129
|
-
colParser[key] = PARSERS[field.type] || field.type
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
try {
|
|
134
|
-
const data = await csv({ colParser }).fromString(csvString)
|
|
135
|
-
const schemaKeyMap: any = {}
|
|
136
|
-
Object.keys(schema || {}).forEach(
|
|
137
|
-
key => (schemaKeyMap[key.toLowerCase()] = key)
|
|
138
|
-
)
|
|
139
|
-
for (let element of data) {
|
|
140
|
-
if (!data) {
|
|
141
|
-
continue
|
|
142
|
-
}
|
|
143
|
-
for (let key of Object.keys(element)) {
|
|
144
|
-
const mappedKey = schemaKeyMap[key.toLowerCase()]
|
|
145
|
-
// isn't a column in the table, remove it
|
|
146
|
-
if (mappedKey == null) {
|
|
147
|
-
delete element[key]
|
|
148
|
-
}
|
|
149
|
-
// casing is different, fix it in row
|
|
150
|
-
else if (key !== mappedKey) {
|
|
151
|
-
element[mappedKey] = element[key]
|
|
152
|
-
delete element[key]
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
return data
|
|
157
|
-
} catch (err) {
|
|
158
|
-
console.error(`Error transforming CSV to JSON for data import`, err)
|
|
159
|
-
throw err
|
|
160
|
-
}
|
|
161
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
const { readFileSync } = require("../fileSystem")
|
|
2
|
-
const csvParser = require("../csvParser")
|
|
3
|
-
|
|
4
|
-
const CSV_PATH = __dirname + "/test.csv"
|
|
5
|
-
|
|
6
|
-
const SCHEMAS = {
|
|
7
|
-
VALID: {
|
|
8
|
-
Age: {
|
|
9
|
-
type: "number",
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
INVALID: {
|
|
13
|
-
Address: {
|
|
14
|
-
type: "number",
|
|
15
|
-
},
|
|
16
|
-
Age: {
|
|
17
|
-
type: "number",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
IGNORE: {
|
|
21
|
-
Address: {
|
|
22
|
-
type: "omit",
|
|
23
|
-
},
|
|
24
|
-
Age: {
|
|
25
|
-
type: "omit",
|
|
26
|
-
},
|
|
27
|
-
Name: {
|
|
28
|
-
type: "string",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
BROKEN: {
|
|
32
|
-
Address: {
|
|
33
|
-
type: "datetime",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
describe("CSV Parser", () => {
|
|
39
|
-
const csvString = readFileSync(CSV_PATH, "utf8")
|
|
40
|
-
|
|
41
|
-
describe("parsing", () => {
|
|
42
|
-
it("returns status and types for a valid CSV transformation", async () => {
|
|
43
|
-
expect(await csvParser.parse(csvString, SCHEMAS.VALID)).toEqual({
|
|
44
|
-
Address: {
|
|
45
|
-
success: true,
|
|
46
|
-
type: "string",
|
|
47
|
-
},
|
|
48
|
-
Age: {
|
|
49
|
-
success: true,
|
|
50
|
-
type: "number",
|
|
51
|
-
},
|
|
52
|
-
Name: {
|
|
53
|
-
success: true,
|
|
54
|
-
type: "string",
|
|
55
|
-
},
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
it("returns status and types for an invalid CSV transformation", async () => {
|
|
60
|
-
expect(await csvParser.parse(csvString, SCHEMAS.INVALID)).toEqual({
|
|
61
|
-
Address: {
|
|
62
|
-
success: false,
|
|
63
|
-
type: "number",
|
|
64
|
-
},
|
|
65
|
-
Age: {
|
|
66
|
-
success: true,
|
|
67
|
-
type: "number",
|
|
68
|
-
},
|
|
69
|
-
Name: {
|
|
70
|
-
success: true,
|
|
71
|
-
type: "string",
|
|
72
|
-
},
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
describe("transformation", () => {
|
|
78
|
-
it("transforms a CSV file into JSON", async () => {
|
|
79
|
-
expect(
|
|
80
|
-
await csvParser.transform({
|
|
81
|
-
schema: SCHEMAS.VALID,
|
|
82
|
-
csvString,
|
|
83
|
-
})
|
|
84
|
-
).toMatchSnapshot()
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
it("transforms a CSV file into JSON ignoring certain fields", async () => {
|
|
88
|
-
expect(
|
|
89
|
-
await csvParser.transform({
|
|
90
|
-
schema: SCHEMAS.IGNORE,
|
|
91
|
-
csvString,
|
|
92
|
-
})
|
|
93
|
-
).toEqual([
|
|
94
|
-
{
|
|
95
|
-
Name: "Bertå",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
Name: "Ernie",
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
Name: "Big Bird",
|
|
102
|
-
},
|
|
103
|
-
])
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
it("throws an error on invalid schema", async () => {
|
|
107
|
-
await expect(
|
|
108
|
-
csvParser.transform({ schema: SCHEMAS.BROKEN, csvString })
|
|
109
|
-
).rejects.toThrow()
|
|
110
|
-
})
|
|
111
|
-
})
|
|
112
|
-
})
|