@budibase/server 1.0.200-alpha.5 → 1.0.200
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/Dockerfile +0 -2
- package/builder/assets/index.f83b3433.js +1315 -0
- package/builder/index.html +1 -1
- package/coverage/clover.xml +2004 -2094
- package/coverage/coverage-final.json +122 -121
- package/coverage/lcov-report/api/controllers/analytics.js.html +202 -0
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +72 -174
- package/coverage/lcov-report/api/controllers/backup.js.html +6 -30
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +41 -53
- package/coverage/lcov-report/api/controllers/dev.js.html +70 -94
- package/coverage/lcov-report/api/controllers/index.html +72 -57
- package/coverage/lcov-report/api/controllers/integration.js.html +8 -8
- package/coverage/lcov-report/api/controllers/layout.js.html +19 -28
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +48 -78
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +19 -19
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +54 -54
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +24 -24
- package/coverage/lcov-report/api/controllers/screen.js.html +20 -56
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +17 -23
- package/coverage/lcov-report/api/controllers/table/index.html +26 -26
- package/coverage/lcov-report/api/controllers/table/index.js.html +49 -85
- package/coverage/lcov-report/api/controllers/templates.js.html +6 -6
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/index.html +21 -21
- package/coverage/lcov-report/api/controllers/view/index.js.html +65 -275
- package/coverage/lcov-report/api/controllers/view/utils.js.html +23 -23
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +40 -40
- package/coverage/lcov-report/api/controllers/webhook.js.html +17 -17
- package/coverage/lcov-report/api/index.html +15 -15
- package/coverage/lcov-report/api/index.js.html +45 -39
- package/coverage/lcov-report/api/routes/analytics.js.html +13 -7
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +11 -11
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +9 -9
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +9 -9
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +9 -9
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/screen.js.html +9 -9
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +10 -10
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +36 -36
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +9 -9
- package/coverage/lcov-report/automations/actions.js.html +25 -25
- package/coverage/lcov-report/automations/automationUtils.js.html +8 -8
- package/coverage/lcov-report/automations/bullboard.js.html +35 -35
- package/coverage/lcov-report/automations/index.html +29 -29
- package/coverage/lcov-report/automations/index.js.html +17 -29
- package/coverage/lcov-report/automations/steps/bash.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/loop.js.html +2 -2
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +30 -30
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/inMemoryView.js.html +5 -5
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +9 -9
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +17 -17
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +19 -19
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +81 -81
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +7 -7
- package/coverage/lcov-report/events/utils.js.html +10 -10
- package/coverage/lcov-report/index.html +79 -79
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
- package/coverage/lcov-report/middleware/builder.js.html +20 -20
- package/coverage/lcov-report/middleware/currentapp.js.html +49 -49
- package/coverage/lcov-report/middleware/index.html +11 -11
- package/coverage/lcov-report/middleware/joi-validator.js.html +20 -44
- package/coverage/lcov-report/middleware/publicApi.js.html +5 -5
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +14 -14
- package/coverage/lcov-report/utilities/csvParser.js.html +34 -34
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +25 -25
- package/coverage/lcov-report/utilities/index.js.html +41 -41
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
- package/coverage/lcov-report/utilities/queue/index.html +15 -15
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +59 -59
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +15 -15
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +30 -30
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +7 -7
- package/coverage/lcov-report/utilities/workerRequests.js.html +29 -29
- package/coverage/lcov.info +2771 -2914
- package/dist/api/controllers/analytics.js +30 -7
- package/dist/api/controllers/application.js +16 -56
- package/dist/api/controllers/automation.js +2 -31
- package/dist/api/controllers/backup.js +0 -7
- package/dist/api/controllers/datasource.js +2 -8
- package/dist/api/controllers/deploy/index.js +2 -6
- package/dist/api/controllers/dev.js +2 -9
- package/dist/api/controllers/layout.js +0 -3
- package/dist/api/controllers/query/import/index.js +2 -12
- package/dist/api/controllers/query/import/sources/curl.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi2.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi3.js +0 -3
- package/dist/api/controllers/query/index.js +2 -16
- package/dist/api/controllers/role.js +0 -11
- package/dist/api/controllers/screen.js +1 -10
- package/dist/api/controllers/static/index.js +15 -29
- package/dist/api/controllers/table/external.js +0 -2
- package/dist/api/controllers/table/index.js +0 -12
- package/dist/api/controllers/table/utils.js +3 -3
- package/dist/api/controllers/view/index.js +6 -62
- package/dist/api/index.js +4 -2
- package/dist/api/routes/analytics.js +3 -1
- package/dist/app.js +8 -16
- package/dist/automations/index.js +0 -4
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/environment.js +2 -4
- package/dist/integrations/firebase.js +0 -1
- package/dist/middleware/joi-validator.js +0 -5
- package/dist/migrations/index.js +31 -95
- package/dist/package.json +69 -79
- package/dist/tests/utilities/TestConfiguration.js +93 -121
- package/dist/tests/utilities/structures.js +0 -45
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +70 -80
- package/scripts/dev/manage.js +0 -2
- package/scripts/jestSetup.js +0 -7
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/analytics.js +39 -0
- package/src/api/controllers/application.ts +18 -60
- package/src/api/controllers/automation.js +2 -36
- package/src/api/controllers/backup.js +0 -8
- package/src/api/controllers/datasource.js +4 -8
- package/src/api/controllers/deploy/index.ts +2 -6
- package/src/api/controllers/dev.js +2 -10
- package/src/api/controllers/layout.js +0 -3
- package/src/api/controllers/query/import/index.ts +3 -16
- package/src/api/controllers/query/import/sources/base/index.ts +1 -2
- package/src/api/controllers/query/import/sources/curl.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi2.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi3.ts +0 -4
- package/src/api/controllers/query/import/tests/index.spec.js +7 -20
- package/src/api/controllers/query/index.ts +3 -16
- package/src/api/controllers/role.js +0 -10
- package/src/api/controllers/screen.js +1 -13
- package/src/api/controllers/static/index.js +15 -28
- package/src/api/controllers/table/external.js +0 -2
- package/src/api/controllers/table/index.js +0 -12
- package/src/api/controllers/table/utils.ts +4 -4
- package/src/api/controllers/view/index.js +6 -76
- package/src/api/index.js +4 -2
- package/src/api/routes/analytics.js +3 -1
- package/src/api/routes/public/utils/Endpoint.ts +1 -1
- package/src/api/routes/tests/__snapshots__/datasource.spec.js.snap +1 -5
- package/src/api/routes/tests/application.spec.js +4 -64
- package/src/api/routes/tests/automation.spec.js +60 -168
- package/src/api/routes/tests/backup.spec.js +0 -2
- package/src/api/routes/tests/datasource.spec.js +0 -5
- package/src/api/routes/tests/layout.spec.js +0 -4
- package/src/api/routes/tests/query.spec.js +13 -56
- package/src/api/routes/tests/role.spec.js +7 -40
- package/src/api/routes/tests/row.spec.js +3 -2
- package/src/api/routes/tests/screen.spec.js +4 -30
- package/src/api/routes/tests/static.spec.js +54 -120
- package/src/api/routes/tests/table.spec.js +38 -102
- package/src/api/routes/tests/view.spec.js +43 -222
- package/src/app.ts +9 -18
- package/src/automations/index.js +0 -4
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/automations/tests/delay.spec.js +0 -4
- package/src/environment.js +2 -5
- package/src/integrations/firebase.ts +0 -1
- package/src/middleware/joi-validator.js +0 -8
- package/src/migrations/index.ts +51 -120
- package/src/module.d.ts +1 -0
- package/src/tests/utilities/TestConfiguration.js +90 -138
- package/src/tests/utilities/structures.js +0 -71
- package/tsconfig.build.json +5 -20
- package/tsconfig.json +17 -22
- package/builder/assets/index.cb381b7a.js +0 -1315
- package/dist/migrations/functions/backfill/app/automations.js +0 -31
- package/dist/migrations/functions/backfill/app/datasources.js +0 -28
- package/dist/migrations/functions/backfill/app/layouts.js +0 -33
- package/dist/migrations/functions/backfill/app/queries.js +0 -32
- package/dist/migrations/functions/backfill/app/roles.js +0 -28
- package/dist/migrations/functions/backfill/app/screens.js +0 -28
- package/dist/migrations/functions/backfill/app/tables.js +0 -40
- package/dist/migrations/functions/backfill/app.js +0 -175
- package/dist/migrations/functions/backfill/global/configs.js +0 -61
- package/dist/migrations/functions/backfill/global/quotas.js +0 -60
- package/dist/migrations/functions/backfill/global/users.js +0 -50
- package/dist/migrations/functions/backfill/global.js +0 -189
- package/dist/migrations/functions/backfill/index.js +0 -32
- package/dist/migrations/functions/backfill/installation.js +0 -80
- package/dist/migrations/tests/helpers.js +0 -72
- package/dist/migrations/tests/structures.js +0 -37
- package/src/api/controllers/analytics.ts +0 -8
- package/src/api/routes/tests/data/export.txt +0 -1
- package/src/api/routes/tests/deployment.spec.js +0 -25
- package/src/api/routes/tests/dev.spec.js +0 -40
- package/src/migrations/functions/backfill/app/automations.ts +0 -26
- package/src/migrations/functions/backfill/app/datasources.ts +0 -22
- package/src/migrations/functions/backfill/app/layouts.ts +0 -29
- package/src/migrations/functions/backfill/app/queries.ts +0 -33
- package/src/migrations/functions/backfill/app/roles.ts +0 -22
- package/src/migrations/functions/backfill/app/screens.ts +0 -22
- package/src/migrations/functions/backfill/app/tables.ts +0 -36
- package/src/migrations/functions/backfill/app.ts +0 -148
- package/src/migrations/functions/backfill/global/configs.ts +0 -66
- package/src/migrations/functions/backfill/global/quotas.ts +0 -60
- package/src/migrations/functions/backfill/global/users.ts +0 -49
- package/src/migrations/functions/backfill/global.ts +0 -194
- package/src/migrations/functions/backfill/index.ts +0 -7
- package/src/migrations/functions/backfill/installation.ts +0 -50
- package/src/migrations/tests/helpers.ts +0 -40
- package/src/migrations/tests/index.spec.ts +0 -132
- package/src/migrations/tests/structures.ts +0 -66
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.199",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -9,9 +9,7 @@
|
|
|
9
9
|
"url": "https://github.com/Budibase/budibase.git"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"
|
|
13
|
-
"build": "tsc -p tsconfig.build.json && mv dist/src/* dist/ && rimraf dist/src/",
|
|
14
|
-
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
|
|
12
|
+
"build": "rimraf dist/ && tsc -p tsconfig.build.json && mv dist/src/* dist/ && rimraf dist/src/ && yarn postbuild",
|
|
15
13
|
"debug": "yarn build && node --expose-gc --inspect=9222 dist/index.js",
|
|
16
14
|
"postbuild": "copyfiles -u 1 src/**/*.svelte dist/ && copyfiles -u 1 src/**/*.hbs dist/ && copyfiles -u 1 src/**/*.json dist/",
|
|
17
15
|
"test": "jest --coverage --maxWorkers=2",
|
|
@@ -39,11 +37,6 @@
|
|
|
39
37
|
"jest": {
|
|
40
38
|
"preset": "ts-jest",
|
|
41
39
|
"testEnvironment": "node",
|
|
42
|
-
"moduleNameMapper": {
|
|
43
|
-
"@budibase/backend-core/(.*)": "<rootDir>/../backend-core/$1",
|
|
44
|
-
"@budibase/backend-core": "<rootDir>/../backend-core/src",
|
|
45
|
-
"@budibase/types": "<rootDir>/../types/src"
|
|
46
|
-
},
|
|
47
40
|
"setupFiles": [
|
|
48
41
|
"./scripts/jestSetup.js"
|
|
49
42
|
],
|
|
@@ -76,123 +69,120 @@
|
|
|
76
69
|
"author": "Budibase",
|
|
77
70
|
"license": "GPL-3.0",
|
|
78
71
|
"dependencies": {
|
|
79
|
-
"@apidevtools/swagger-parser": "10.0.3",
|
|
80
|
-
"@budibase/backend-core": "^1.0.
|
|
81
|
-
"@budibase/client": "^1.0.
|
|
82
|
-
"@budibase/pro": "1.0.
|
|
83
|
-
"@budibase/string-templates": "^1.0.
|
|
84
|
-
"@bull-board/api": "3.7.0",
|
|
85
|
-
"@bull-board/koa": "3.
|
|
72
|
+
"@apidevtools/swagger-parser": "^10.0.3",
|
|
73
|
+
"@budibase/backend-core": "^1.0.199",
|
|
74
|
+
"@budibase/client": "^1.0.199",
|
|
75
|
+
"@budibase/pro": "1.0.199",
|
|
76
|
+
"@budibase/string-templates": "^1.0.199",
|
|
77
|
+
"@bull-board/api": "^3.7.0",
|
|
78
|
+
"@bull-board/koa": "^3.7.0",
|
|
86
79
|
"@elastic/elasticsearch": "7.10.0",
|
|
87
|
-
"@google-cloud/firestore": "5.0.2",
|
|
80
|
+
"@google-cloud/firestore": "^5.0.2",
|
|
88
81
|
"@koa/router": "8.0.0",
|
|
89
82
|
"@sendgrid/mail": "7.1.1",
|
|
90
83
|
"@sentry/node": "6.17.7",
|
|
84
|
+
"@types/global-agent": "^2.1.1",
|
|
85
|
+
"@types/koa__router": "^8.0.11",
|
|
91
86
|
"airtable": "0.10.1",
|
|
92
87
|
"arangojs": "7.2.0",
|
|
93
|
-
"aws-sdk": "2.
|
|
88
|
+
"aws-sdk": "^2.767.0",
|
|
94
89
|
"bcryptjs": "2.4.3",
|
|
95
|
-
"bull": "3.
|
|
90
|
+
"bull": "^3.22.4",
|
|
96
91
|
"chmodr": "1.2.0",
|
|
97
92
|
"csvtojson": "2.0.10",
|
|
98
|
-
"curlconverter": "3.21.0",
|
|
93
|
+
"curlconverter": "^3.21.0",
|
|
99
94
|
"dotenv": "8.2.0",
|
|
100
95
|
"download": "8.0.0",
|
|
101
96
|
"fix-path": "3.0.0",
|
|
102
|
-
"form-data": "4.0.0",
|
|
97
|
+
"form-data": "^4.0.0",
|
|
103
98
|
"fs-extra": "8.1.0",
|
|
104
|
-
"global-agent": "3.0.0",
|
|
105
|
-
"google-auth-library": "7.
|
|
106
|
-
"google-spreadsheet": "3.2.0",
|
|
99
|
+
"global-agent": "^3.0.0",
|
|
100
|
+
"google-auth-library": "^7.11.0",
|
|
101
|
+
"google-spreadsheet": "^3.2.0",
|
|
107
102
|
"jimp": "0.16.1",
|
|
108
103
|
"joi": "17.2.1",
|
|
109
|
-
"js-yaml": "4.1.0",
|
|
104
|
+
"js-yaml": "^4.1.0",
|
|
110
105
|
"jsonschema": "1.4.0",
|
|
111
|
-
"knex": "0.95.
|
|
106
|
+
"knex": "^0.95.6",
|
|
112
107
|
"koa": "2.7.0",
|
|
113
108
|
"koa-body": "4.2.0",
|
|
114
109
|
"koa-compress": "4.0.1",
|
|
115
|
-
"koa-connect": "2.1.0",
|
|
110
|
+
"koa-connect": "^2.1.0",
|
|
116
111
|
"koa-pino-logger": "3.0.0",
|
|
117
112
|
"koa-send": "5.0.0",
|
|
118
113
|
"koa-session": "5.12.0",
|
|
119
114
|
"koa-static": "5.0.0",
|
|
120
|
-
"koa2-ratelimit": "1.1.0",
|
|
115
|
+
"koa2-ratelimit": "^1.1.0",
|
|
121
116
|
"lodash": "4.17.21",
|
|
122
|
-
"memorystream": "0.3.1",
|
|
117
|
+
"memorystream": "^0.3.1",
|
|
123
118
|
"mongodb": "3.6.3",
|
|
124
119
|
"mssql": "6.2.3",
|
|
125
|
-
"mysql2": "2.3.
|
|
120
|
+
"mysql2": "^2.3.1",
|
|
126
121
|
"node-fetch": "2.6.7",
|
|
127
|
-
"open": "8.4.0",
|
|
122
|
+
"open": "^8.4.0",
|
|
128
123
|
"pg": "8.5.1",
|
|
129
124
|
"pino-pretty": "4.0.0",
|
|
130
|
-
"posthog-node": "1.
|
|
125
|
+
"posthog-node": "^1.1.4",
|
|
131
126
|
"pouchdb": "7.3.0",
|
|
132
|
-
"pouchdb-adapter-memory": "7.2.
|
|
127
|
+
"pouchdb-adapter-memory": "^7.2.1",
|
|
133
128
|
"pouchdb-all-dbs": "1.0.2",
|
|
134
|
-
"pouchdb-find": "7.2.2",
|
|
129
|
+
"pouchdb-find": "^7.2.2",
|
|
135
130
|
"pouchdb-replication-stream": "1.2.9",
|
|
136
131
|
"redis": "4",
|
|
137
132
|
"server-destroy": "1.0.1",
|
|
138
|
-
"svelte": "3.
|
|
139
|
-
"swagger-parser": "10.0.3",
|
|
133
|
+
"svelte": "^3.38.2",
|
|
134
|
+
"swagger-parser": "^10.0.3",
|
|
140
135
|
"to-json-schema": "0.2.5",
|
|
141
136
|
"uuid": "3.3.2",
|
|
142
137
|
"validate.js": "0.13.1",
|
|
143
|
-
"vm2": "3.9.
|
|
144
|
-
"worker-farm": "1.7.0",
|
|
145
|
-
"xml2js": "0.4.23",
|
|
138
|
+
"vm2": "^3.9.3",
|
|
139
|
+
"worker-farm": "^1.7.0",
|
|
140
|
+
"xml2js": "^0.4.23",
|
|
146
141
|
"yargs": "13.2.4",
|
|
147
142
|
"zlib": "1.0.5"
|
|
148
143
|
},
|
|
149
144
|
"devDependencies": {
|
|
150
|
-
"@babel/core": "7.
|
|
151
|
-
"@babel/preset-env": "7.
|
|
145
|
+
"@babel/core": "^7.14.3",
|
|
146
|
+
"@babel/preset-env": "^7.14.4",
|
|
152
147
|
"@budibase/standard-components": "^0.9.139",
|
|
153
|
-
"@
|
|
154
|
-
"@
|
|
155
|
-
"@types/
|
|
156
|
-
"@types/
|
|
157
|
-
"@types/
|
|
158
|
-
"@types/
|
|
159
|
-
"@types/
|
|
160
|
-
"@types/
|
|
161
|
-
"@types/koa": "2.13.4",
|
|
162
|
-
"@types/koa__router": "8.0.0",
|
|
148
|
+
"@jest/test-sequencer": "^24.8.0",
|
|
149
|
+
"@types/apidoc": "^0.50.0",
|
|
150
|
+
"@types/bson": "^4.2.0",
|
|
151
|
+
"@types/bull": "^3.15.1",
|
|
152
|
+
"@types/google-spreadsheet": "^3.1.5",
|
|
153
|
+
"@types/jest": "^27.4.1",
|
|
154
|
+
"@types/koa": "^2.13.3",
|
|
155
|
+
"@types/koa-router": "^7.4.2",
|
|
163
156
|
"@types/lodash": "4.14.180",
|
|
164
157
|
"@types/mongodb": "3.6.3",
|
|
165
|
-
"@types/node": "
|
|
166
|
-
"@types/
|
|
167
|
-
"@types/
|
|
168
|
-
"@types/redis": "4.0.11",
|
|
158
|
+
"@types/node": "^15.12.4",
|
|
159
|
+
"@types/oracledb": "^5.2.1",
|
|
160
|
+
"@types/redis": "^4.0.11",
|
|
169
161
|
"@typescript-eslint/parser": "5.12.0",
|
|
170
|
-
"apidoc": "0.50.
|
|
171
|
-
"babel-jest": "27.
|
|
172
|
-
"copyfiles": "2.4.1",
|
|
173
|
-
"docker-compose": "0.23.
|
|
174
|
-
"eslint": "6.8.0",
|
|
175
|
-
"ioredis-mock": "7.2.0",
|
|
176
|
-
"is-wsl": "2.2.0",
|
|
177
|
-
"jest": "27.5
|
|
178
|
-
"jest-openapi": "0.14.2",
|
|
179
|
-
"nodemon": "2.0.
|
|
180
|
-
"openapi-types": "9.3.1",
|
|
181
|
-
"openapi-typescript": "5.2.0",
|
|
182
|
-
"path-to-regexp": "6.2.0",
|
|
183
|
-
"prettier": "2.
|
|
184
|
-
"rimraf": "3.0.2",
|
|
185
|
-
"supertest": "4.0.2",
|
|
186
|
-
"swagger-jsdoc": "6.1.0",
|
|
187
|
-
"
|
|
188
|
-
"ts-
|
|
189
|
-
"
|
|
190
|
-
"
|
|
191
|
-
"typescript": "4.6.2",
|
|
192
|
-
"update-dotenv": "1.1.1"
|
|
162
|
+
"apidoc": "^0.50.2",
|
|
163
|
+
"babel-jest": "^27.0.2",
|
|
164
|
+
"copyfiles": "^2.4.1",
|
|
165
|
+
"docker-compose": "^0.23.6",
|
|
166
|
+
"eslint": "^6.8.0",
|
|
167
|
+
"ioredis-mock": "^7.2.0",
|
|
168
|
+
"is-wsl": "^2.2.0",
|
|
169
|
+
"jest": "^27.0.5",
|
|
170
|
+
"jest-openapi": "^0.14.2",
|
|
171
|
+
"nodemon": "^2.0.4",
|
|
172
|
+
"openapi-types": "^9.3.1",
|
|
173
|
+
"openapi-typescript": "^5.2.0",
|
|
174
|
+
"path-to-regexp": "^6.2.0",
|
|
175
|
+
"prettier": "^2.3.1",
|
|
176
|
+
"rimraf": "^3.0.2",
|
|
177
|
+
"supertest": "^4.0.2",
|
|
178
|
+
"swagger-jsdoc": "^6.1.0",
|
|
179
|
+
"ts-jest": "^27.0.3",
|
|
180
|
+
"ts-node": "^10.0.0",
|
|
181
|
+
"typescript": "^4.5.5",
|
|
182
|
+
"update-dotenv": "^1.1.1"
|
|
193
183
|
},
|
|
194
184
|
"optionalDependencies": {
|
|
195
|
-
"oracledb": "5.3.0"
|
|
185
|
+
"oracledb": "^5.3.0"
|
|
196
186
|
},
|
|
197
187
|
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
|
|
198
188
|
}
|
|
@@ -48,9 +48,6 @@ class TestConfiguration {
|
|
|
48
48
|
getAppId() {
|
|
49
49
|
return this.appId;
|
|
50
50
|
}
|
|
51
|
-
getProdAppId() {
|
|
52
|
-
return this.prodAppId;
|
|
53
|
-
}
|
|
54
51
|
doInContext(appId, task) {
|
|
55
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
53
|
if (!appId) {
|
|
@@ -69,24 +66,6 @@ class TestConfiguration {
|
|
|
69
66
|
});
|
|
70
67
|
});
|
|
71
68
|
}
|
|
72
|
-
// SETUP / TEARDOWN
|
|
73
|
-
// use a new id as the name to avoid name collisions
|
|
74
|
-
init(appName = newid()) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
yield this.globalUser();
|
|
77
|
-
return this.createApp(appName);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
end() {
|
|
81
|
-
if (!this) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
if (this.server) {
|
|
85
|
-
this.server.close();
|
|
86
|
-
}
|
|
87
|
-
cleanup(this.allApps.map(app => app.appId));
|
|
88
|
-
}
|
|
89
|
-
// UTILS
|
|
90
69
|
_req(config, params, controlFunc) {
|
|
91
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
71
|
const request = {};
|
|
@@ -108,8 +87,24 @@ class TestConfiguration {
|
|
|
108
87
|
}));
|
|
109
88
|
});
|
|
110
89
|
}
|
|
111
|
-
|
|
112
|
-
|
|
90
|
+
generateApiKey(userId = GLOBAL_USER_ID) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
return doWithGlobalDB(TENANT_ID, (db) => __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
const id = generateDevInfoID(userId);
|
|
94
|
+
let devInfo;
|
|
95
|
+
try {
|
|
96
|
+
devInfo = yield db.get(id);
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
devInfo = { _id: id, userId };
|
|
100
|
+
}
|
|
101
|
+
devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`);
|
|
102
|
+
yield db.put(devInfo);
|
|
103
|
+
return devInfo.apiKey;
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
globalUser({ id = GLOBAL_USER_ID, builder = true, email = EMAIL, roles, } = {}) {
|
|
113
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
114
109
|
return doWithGlobalDB(TENANT_ID, (db) => __awaiter(this, void 0, void 0, function* () {
|
|
115
110
|
let existing;
|
|
@@ -131,75 +126,26 @@ class TestConfiguration {
|
|
|
131
126
|
else {
|
|
132
127
|
user.builder = { global: false };
|
|
133
128
|
}
|
|
134
|
-
if (admin) {
|
|
135
|
-
user.admin = { global: true };
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
user.admin = { global: false };
|
|
139
|
-
}
|
|
140
129
|
const resp = yield db.put(user);
|
|
141
130
|
return Object.assign({ _rev: resp._rev }, user);
|
|
142
131
|
}));
|
|
143
132
|
});
|
|
144
133
|
}
|
|
145
|
-
|
|
134
|
+
// use a new id as the name to avoid name collisions
|
|
135
|
+
init(appName = newid()) {
|
|
146
136
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
id: globalId,
|
|
150
|
-
email,
|
|
151
|
-
builder,
|
|
152
|
-
admin,
|
|
153
|
-
roles,
|
|
154
|
-
});
|
|
155
|
-
yield userCache.invalidateUser(globalId);
|
|
156
|
-
return Object.assign(Object.assign({}, resp), { globalId });
|
|
137
|
+
yield this.globalUser();
|
|
138
|
+
return this.createApp(appName);
|
|
157
139
|
});
|
|
158
140
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
// make sure the user exists in the global DB
|
|
168
|
-
if (roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
|
|
169
|
-
yield this.globalUser({
|
|
170
|
-
id: userId,
|
|
171
|
-
builder,
|
|
172
|
-
roles: { [this.prodAppId]: roleId },
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
yield createASession(userId, {
|
|
176
|
-
sessionId: "sessionid",
|
|
177
|
-
tenantId: TENANT_ID,
|
|
178
|
-
});
|
|
179
|
-
// have to fake this
|
|
180
|
-
const auth = {
|
|
181
|
-
userId,
|
|
182
|
-
sessionId: "sessionid",
|
|
183
|
-
tenantId: TENANT_ID,
|
|
184
|
-
};
|
|
185
|
-
const app = {
|
|
186
|
-
roleId: roleId,
|
|
187
|
-
appId,
|
|
188
|
-
};
|
|
189
|
-
const authToken = jwt.sign(auth, env.JWT_SECRET);
|
|
190
|
-
const appToken = jwt.sign(app, env.JWT_SECRET);
|
|
191
|
-
// returning necessary request headers
|
|
192
|
-
yield userCache.invalidateUser(userId);
|
|
193
|
-
return {
|
|
194
|
-
Accept: "application/json",
|
|
195
|
-
Cookie: [
|
|
196
|
-
`${Cookies.Auth}=${authToken}`,
|
|
197
|
-
`${Cookies.CurrentApp}=${appToken}`,
|
|
198
|
-
],
|
|
199
|
-
[Headers.APP_ID]: appId,
|
|
200
|
-
};
|
|
201
|
-
}));
|
|
202
|
-
});
|
|
141
|
+
end() {
|
|
142
|
+
if (!this) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (this.server) {
|
|
146
|
+
this.server.close();
|
|
147
|
+
}
|
|
148
|
+
cleanup(this.allApps.map(app => app.appId));
|
|
203
149
|
}
|
|
204
150
|
defaultHeaders(extras = {}) {
|
|
205
151
|
const auth = {
|
|
@@ -237,25 +183,6 @@ class TestConfiguration {
|
|
|
237
183
|
return this.login({ email, roleId, builder, prodApp });
|
|
238
184
|
});
|
|
239
185
|
}
|
|
240
|
-
// API
|
|
241
|
-
generateApiKey(userId = GLOBAL_USER_ID) {
|
|
242
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
-
return doWithGlobalDB(TENANT_ID, (db) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
const id = generateDevInfoID(userId);
|
|
245
|
-
let devInfo;
|
|
246
|
-
try {
|
|
247
|
-
devInfo = yield db.get(id);
|
|
248
|
-
}
|
|
249
|
-
catch (err) {
|
|
250
|
-
devInfo = { _id: id, userId };
|
|
251
|
-
}
|
|
252
|
-
devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`);
|
|
253
|
-
yield db.put(devInfo);
|
|
254
|
-
return devInfo.apiKey;
|
|
255
|
-
}));
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
// APP
|
|
259
186
|
createApp(appName) {
|
|
260
187
|
return __awaiter(this, void 0, void 0, function* () {
|
|
261
188
|
// create dev app
|
|
@@ -283,7 +210,6 @@ class TestConfiguration {
|
|
|
283
210
|
}));
|
|
284
211
|
});
|
|
285
212
|
}
|
|
286
|
-
// TABLE
|
|
287
213
|
updateTable(config = null) {
|
|
288
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
289
215
|
config = config || basicTable();
|
|
@@ -337,7 +263,6 @@ class TestConfiguration {
|
|
|
337
263
|
return this.createTable(table);
|
|
338
264
|
});
|
|
339
265
|
}
|
|
340
|
-
// ROW
|
|
341
266
|
createRow(config = null) {
|
|
342
267
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
268
|
if (!this.table) {
|
|
@@ -361,7 +286,6 @@ class TestConfiguration {
|
|
|
361
286
|
return this._req(null, { tableId }, controllers.row.fetch);
|
|
362
287
|
});
|
|
363
288
|
}
|
|
364
|
-
// ROLE
|
|
365
289
|
createRole(config = null) {
|
|
366
290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
367
291
|
config = config || basicRole();
|
|
@@ -377,20 +301,19 @@ class TestConfiguration {
|
|
|
377
301
|
}, controllers.perms.addPermission);
|
|
378
302
|
});
|
|
379
303
|
}
|
|
380
|
-
// VIEW
|
|
381
304
|
createView(config) {
|
|
382
305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
383
306
|
if (!this.table) {
|
|
384
307
|
throw "Test requires table to be configured.";
|
|
385
308
|
}
|
|
386
309
|
const view = config || {
|
|
310
|
+
map: "function(doc) { emit(doc[doc.key], doc._id); } ",
|
|
387
311
|
tableId: this.table._id,
|
|
388
312
|
name: "ViewTest",
|
|
389
313
|
};
|
|
390
314
|
return this._req(view, null, controllers.view.save);
|
|
391
315
|
});
|
|
392
316
|
}
|
|
393
|
-
// AUTOMATION
|
|
394
317
|
createAutomation(config) {
|
|
395
318
|
return __awaiter(this, void 0, void 0, function* () {
|
|
396
319
|
config = config || basicAutomation();
|
|
@@ -415,16 +338,6 @@ class TestConfiguration {
|
|
|
415
338
|
return this._req(null, { id: automation._id, rev: automation._rev }, controllers.automation.destroy);
|
|
416
339
|
});
|
|
417
340
|
}
|
|
418
|
-
createWebhook(config = null) {
|
|
419
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
420
|
-
if (!this.automation) {
|
|
421
|
-
throw "Must create an automation before creating webhook.";
|
|
422
|
-
}
|
|
423
|
-
config = config || basicWebhook(this.automation._id);
|
|
424
|
-
return (yield this._req(config, null, controllers.webhook.save)).webhook;
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
// DATASOURCE
|
|
428
341
|
createDatasource(config = null) {
|
|
429
342
|
return __awaiter(this, void 0, void 0, function* () {
|
|
430
343
|
config = config || basicDatasource();
|
|
@@ -465,7 +378,6 @@ class TestConfiguration {
|
|
|
465
378
|
return { datasource, query: basedOnQuery };
|
|
466
379
|
});
|
|
467
380
|
}
|
|
468
|
-
// QUERY
|
|
469
381
|
previewQuery(request, config, datasource, fields) {
|
|
470
382
|
return __awaiter(this, void 0, void 0, function* () {
|
|
471
383
|
return request
|
|
@@ -491,19 +403,79 @@ class TestConfiguration {
|
|
|
491
403
|
return this._req(config, null, controllers.query.save);
|
|
492
404
|
});
|
|
493
405
|
}
|
|
494
|
-
// SCREEN
|
|
495
406
|
createScreen(config = null) {
|
|
496
407
|
return __awaiter(this, void 0, void 0, function* () {
|
|
497
408
|
config = config || basicScreen();
|
|
498
409
|
return this._req(config, null, controllers.screen.save);
|
|
499
410
|
});
|
|
500
411
|
}
|
|
501
|
-
|
|
412
|
+
createWebhook(config = null) {
|
|
413
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
414
|
+
if (!this.automation) {
|
|
415
|
+
throw "Must create an automation before creating webhook.";
|
|
416
|
+
}
|
|
417
|
+
config = config || basicWebhook(this.automation._id);
|
|
418
|
+
return (yield this._req(config, null, controllers.webhook.save)).webhook;
|
|
419
|
+
});
|
|
420
|
+
}
|
|
502
421
|
createLayout(config = null) {
|
|
503
422
|
return __awaiter(this, void 0, void 0, function* () {
|
|
504
423
|
config = config || basicLayout();
|
|
505
424
|
return yield this._req(config, null, controllers.layout.save);
|
|
506
425
|
});
|
|
507
426
|
}
|
|
427
|
+
createUser(id = null, email = EMAIL) {
|
|
428
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
429
|
+
const globalId = !id ? `us_${Math.random()}` : `us_${id}`;
|
|
430
|
+
const resp = yield this.globalUser({ id: globalId, email });
|
|
431
|
+
yield userCache.invalidateUser(globalId);
|
|
432
|
+
return Object.assign(Object.assign({}, resp), { globalId });
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
login({ roleId, userId, builder, prodApp = false } = {}) {
|
|
436
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
437
|
+
const appId = prodApp ? this.prodAppId : this.appId;
|
|
438
|
+
return context.doInAppContext(appId, () => __awaiter(this, void 0, void 0, function* () {
|
|
439
|
+
userId = !userId ? `us_uuid1` : userId;
|
|
440
|
+
if (!this.request) {
|
|
441
|
+
throw "Server has not been opened, cannot login.";
|
|
442
|
+
}
|
|
443
|
+
// make sure the user exists in the global DB
|
|
444
|
+
if (roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
|
|
445
|
+
yield this.globalUser({
|
|
446
|
+
id: userId,
|
|
447
|
+
builder,
|
|
448
|
+
roles: { [this.prodAppId]: roleId },
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
yield createASession(userId, {
|
|
452
|
+
sessionId: "sessionid",
|
|
453
|
+
tenantId: TENANT_ID,
|
|
454
|
+
});
|
|
455
|
+
// have to fake this
|
|
456
|
+
const auth = {
|
|
457
|
+
userId,
|
|
458
|
+
sessionId: "sessionid",
|
|
459
|
+
tenantId: TENANT_ID,
|
|
460
|
+
};
|
|
461
|
+
const app = {
|
|
462
|
+
roleId: roleId,
|
|
463
|
+
appId,
|
|
464
|
+
};
|
|
465
|
+
const authToken = jwt.sign(auth, env.JWT_SECRET);
|
|
466
|
+
const appToken = jwt.sign(app, env.JWT_SECRET);
|
|
467
|
+
// returning necessary request headers
|
|
468
|
+
yield userCache.invalidateUser(userId);
|
|
469
|
+
return {
|
|
470
|
+
Accept: "application/json",
|
|
471
|
+
Cookie: [
|
|
472
|
+
`${Cookies.Auth}=${authToken}`,
|
|
473
|
+
`${Cookies.CurrentApp}=${appToken}`,
|
|
474
|
+
],
|
|
475
|
+
[Headers.APP_ID]: appId,
|
|
476
|
+
};
|
|
477
|
+
}));
|
|
478
|
+
});
|
|
479
|
+
}
|
|
508
480
|
}
|
|
509
481
|
module.exports = TestConfiguration;
|
|
@@ -4,8 +4,6 @@ const { BUILTIN_PERMISSION_IDS } = require("@budibase/backend-core/permissions")
|
|
|
4
4
|
const { createHomeScreen } = require("../../constants/screens");
|
|
5
5
|
const { EMPTY_LAYOUT } = require("../../constants/layouts");
|
|
6
6
|
const { cloneDeep } = require("lodash/fp");
|
|
7
|
-
const { v4: uuidv4 } = require("uuid");
|
|
8
|
-
const { TRIGGER_DEFINITIONS, ACTION_DEFINITIONS } = require("../../automations");
|
|
9
7
|
exports.TENANT_ID = "default";
|
|
10
8
|
exports.basicTable = () => {
|
|
11
9
|
return {
|
|
@@ -28,49 +26,6 @@ exports.basicTable = () => {
|
|
|
28
26
|
},
|
|
29
27
|
};
|
|
30
28
|
};
|
|
31
|
-
exports.basicView = tableId => {
|
|
32
|
-
return {
|
|
33
|
-
tableId,
|
|
34
|
-
name: "ViewTest",
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
exports.filterView = tableId => {
|
|
38
|
-
return Object.assign(Object.assign({}, this.basicView(tableId)), { filters: [
|
|
39
|
-
{
|
|
40
|
-
value: 0,
|
|
41
|
-
condition: "MT",
|
|
42
|
-
key: "count",
|
|
43
|
-
},
|
|
44
|
-
] });
|
|
45
|
-
};
|
|
46
|
-
exports.calculationView = tableId => {
|
|
47
|
-
return Object.assign(Object.assign({}, this.basicView(tableId)), { field: "count", calculation: "sum" });
|
|
48
|
-
};
|
|
49
|
-
exports.view = tableId => {
|
|
50
|
-
return Object.assign(Object.assign({}, this.filterView(tableId)), this.calculationView(tableId));
|
|
51
|
-
};
|
|
52
|
-
exports.automationStep = (actionDefinition = ACTION_DEFINITIONS.CREATE_ROW) => {
|
|
53
|
-
return Object.assign({ id: uuidv4() }, actionDefinition);
|
|
54
|
-
};
|
|
55
|
-
exports.automationTrigger = (triggerDefinition = TRIGGER_DEFINITIONS.ROW_SAVED) => {
|
|
56
|
-
return Object.assign({ id: uuidv4() }, triggerDefinition);
|
|
57
|
-
};
|
|
58
|
-
exports.newAutomation = ({ steps, trigger } = {}) => {
|
|
59
|
-
const automation = exports.basicAutomation();
|
|
60
|
-
if (trigger) {
|
|
61
|
-
automation.definition.trigger = trigger;
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
automation.definition.trigger = exports.automationTrigger();
|
|
65
|
-
}
|
|
66
|
-
if (steps) {
|
|
67
|
-
automation.definition.steps = steps;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
automation.definition.steps = [exports.automationStep()];
|
|
71
|
-
}
|
|
72
|
-
return automation;
|
|
73
|
-
};
|
|
74
29
|
exports.basicAutomation = () => {
|
|
75
30
|
return {
|
|
76
31
|
name: "My Automation",
|