@budibase/server 0.9.188 → 0.9.190-alpha.2
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 +7 -1
- package/__mocks__/mssql.ts +1 -1
- package/__mocks__/oracledb.ts +31 -0
- package/__mocks__/pg.ts +3 -0
- package/builder/assets/bb-space-man.5be51a45.svg +290 -0
- package/builder/assets/index.7d405e74.css +1 -0
- package/builder/assets/index.edea4fa5.js +1316 -0
- package/builder/assets/oracle.66592424.png +0 -0
- package/builder/assets/vendor.470042a4.js +152 -0
- package/builder/assets/vendor.5e1fe644.css +1 -0
- package/builder/index.html +4 -4
- package/coverage/clover.xml +1507 -1081
- package/coverage/coverage-final.json +93 -89
- package/coverage/lcov-report/api/controllers/analytics.js.html +2 -2
- package/coverage/lcov-report/api/controllers/apikeys.js.html +2 -2
- package/coverage/lcov-report/api/controllers/application.js.html +64 -13
- package/coverage/lcov-report/api/controllers/auth.js.html +19 -10
- package/coverage/lcov-report/api/controllers/automation.js.html +3 -3
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +4 -4
- package/coverage/lcov-report/api/controllers/datasource.js.html +232 -28
- package/coverage/lcov-report/api/controllers/dev.js.html +16 -7
- package/coverage/lcov-report/api/controllers/hosting.js.html +10 -10
- package/coverage/lcov-report/api/controllers/index.html +91 -91
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +3 -3
- package/coverage/lcov-report/api/controllers/metadata.js.html +3 -3
- package/coverage/lcov-report/api/controllers/permission.js.html +3 -3
- package/coverage/lcov-report/api/controllers/query.js.html +53 -209
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +3 -3
- package/coverage/lcov-report/api/controllers/row/external.js.html +17 -8
- package/coverage/lcov-report/api/controllers/row/index.html +26 -26
- package/coverage/lcov-report/api/controllers/row/index.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/internal.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +2 -2
- package/coverage/lcov-report/api/controllers/row/utils.js.html +21 -30
- package/coverage/lcov-report/api/controllers/screen.js.html +2 -2
- package/coverage/lcov-report/api/controllers/script.js.html +3 -3
- package/coverage/lcov-report/api/controllers/table/external.js.html +1001 -0
- package/coverage/lcov-report/api/controllers/table/index.html +56 -26
- package/coverage/lcov-report/api/controllers/table/index.js.html +80 -350
- package/coverage/lcov-report/api/controllers/table/internal.js.html +545 -0
- package/coverage/lcov-report/api/controllers/table/utils.js.html +175 -52
- package/coverage/lcov-report/api/controllers/templates.js.html +4 -4
- package/coverage/lcov-report/api/controllers/user.js.html +390 -33
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +19 -4
- package/coverage/lcov-report/api/controllers/view/index.html +22 -22
- package/coverage/lcov-report/api/controllers/view/index.js.html +52 -13
- package/coverage/lcov-report/api/controllers/view/utils.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +3 -3
- package/coverage/lcov-report/api/controllers/webhook.js.html +4 -4
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +2 -2
- package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +4 -4
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +5 -2
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +2 -2
- package/coverage/lcov-report/api/routes/table.js.html +35 -2
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +17 -2
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +2 -2
- package/coverage/lcov-report/automations/automationUtils.js.html +4 -4
- package/coverage/lcov-report/automations/bullboard.js.html +71 -20
- package/coverage/lcov-report/automations/index.html +35 -50
- package/coverage/lcov-report/automations/index.js.html +2 -2
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +3 -3
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +3 -3
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +14 -14
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +3 -3
- package/coverage/lcov-report/automations/steps/queryRows.js.html +3 -3
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +7 -7
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- 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 +22 -10
- package/coverage/lcov-report/automations/utils.js.html +42 -12
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +87 -21
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/client.js.html +2 -2
- package/coverage/lcov-report/db/inMemoryView.js.html +2 -2
- package/coverage/lcov-report/db/index.html +2 -2
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +6 -6
- package/coverage/lcov-report/db/linkedRows/index.html +10 -10
- package/coverage/lcov-report/db/linkedRows/index.js.html +5 -5
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +6 -6
- package/coverage/lcov-report/db/newid.js.html +3 -3
- package/coverage/lcov-report/db/utils.js.html +57 -57
- package/coverage/lcov-report/events/AutomationEmitter.js.html +6 -6
- package/coverage/lcov-report/events/index.html +6 -6
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +5 -5
- package/coverage/lcov-report/index.html +106 -91
- 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 +2 -2
- package/coverage/lcov-report/middleware/authorized.js.html +11 -8
- package/coverage/lcov-report/middleware/builder.js.html +16 -7
- package/coverage/lcov-report/middleware/currentapp.js.html +6 -6
- package/coverage/lcov-report/middleware/index.html +23 -23
- package/coverage/lcov-report/middleware/joi-validator.js.html +2 -2
- package/coverage/lcov-report/middleware/resourceId.js.html +18 -18
- package/coverage/lcov-report/middleware/selfhost.js.html +2 -2
- package/coverage/lcov-report/middleware/usageQuota.js.html +4 -4
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/{automations/thread.js.html → threads/automation.js.html} +90 -33
- package/coverage/lcov-report/threads/index.html +141 -0
- package/coverage/lcov-report/threads/index.js.html +278 -0
- package/coverage/lcov-report/threads/query.js.html +278 -0
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +144 -15
- package/coverage/lcov-report/utilities/global.js.html +26 -11
- package/coverage/lcov-report/utilities/index.html +48 -48
- package/coverage/lcov-report/utilities/index.js.html +47 -14
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +30 -9
- package/coverage/lcov-report/utilities/queue/index.html +14 -14
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +4 -4
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +2 -2
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +3 -3
- package/coverage/lcov-report/utilities/scriptRunner.js.html +16 -7
- package/coverage/lcov-report/utilities/security.js.html +3 -3
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +5 -5
- package/coverage/lcov.info +2495 -1737
- package/dist/api/controllers/application.js +15 -1
- package/dist/api/controllers/auth.js +3 -3
- package/dist/api/controllers/datasource.js +67 -16
- package/dist/api/controllers/deploy/index.js +2 -0
- package/dist/api/controllers/dev.js +4 -1
- package/dist/api/controllers/query.js +30 -58
- package/dist/api/controllers/row/ExternalRequest.js +78 -34
- package/dist/api/controllers/row/external.js +3 -1
- package/dist/api/controllers/row/utils.js +6 -12
- package/dist/api/controllers/table/external.js +249 -0
- package/dist/api/controllers/table/index.js +49 -123
- package/dist/api/controllers/table/internal.js +150 -0
- package/dist/api/controllers/table/utils.js +62 -28
- package/dist/api/controllers/user.js +123 -11
- package/dist/api/controllers/view/exporters.js +4 -0
- package/dist/api/controllers/view/index.js +14 -2
- package/dist/api/routes/query.js +1 -1
- package/dist/api/routes/table.js +7 -1
- package/dist/api/routes/user.js +2 -1
- package/dist/app.js +2 -11
- package/dist/automations/bullboard.js +37 -10
- package/dist/automations/triggers.js +7 -3
- package/dist/automations/utils.js +11 -2
- package/dist/constants/index.js +19 -0
- package/dist/definitions/datasource.js +5 -0
- package/dist/environment.js +13 -0
- package/dist/integrations/base/IntegrationBase.js +2 -0
- package/dist/integrations/base/datasourcePlus.js +2 -0
- package/dist/integrations/base/sql.js +353 -177
- package/dist/integrations/base/sqlTable.js +143 -0
- package/dist/integrations/base/utils.js +30 -0
- package/dist/integrations/index.js +6 -0
- package/dist/integrations/microsoftSqlServer.js +117 -9
- package/dist/integrations/mysql.js +16 -85
- package/dist/integrations/oracle.js +347 -0
- package/dist/integrations/postgres.js +35 -28
- package/dist/integrations/utils.js +71 -9
- package/dist/middleware/authorized.js +2 -1
- package/dist/middleware/builder.js +4 -1
- package/dist/package.json +12 -7
- package/dist/tests/utilities/TestConfiguration.js +2 -1
- package/dist/{automations/thread.js → threads/automation.js} +26 -8
- package/dist/threads/index.js +64 -0
- package/dist/threads/query.js +64 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/csvParser.js +46 -5
- package/dist/utilities/global.js +6 -2
- package/dist/utilities/index.js +11 -0
- package/dist/utilities/queue/inMemoryQueue.js +8 -0
- package/dist/utilities/scriptRunner.js +4 -1
- package/package.json +13 -8
- package/scripts/dev/manage.js +1 -0
- package/scripts/integrations/mssql/data/Dockerfile +9 -0
- package/scripts/integrations/mssql/data/entrypoint.sh +24 -0
- package/scripts/integrations/mssql/data/setup.sql +54 -0
- package/scripts/integrations/mssql/docker-compose.yaml +12 -0
- package/scripts/integrations/mssql/reset.sh +3 -0
- package/scripts/integrations/oracle/docker-compose.yml +19 -0
- package/scripts/integrations/oracle/instantclient/linux/x86-64/basiclite-21.4.zip +0 -0
- package/scripts/integrations/oracle/instantclient/linux/x86-64/install.sh +23 -0
- package/scripts/integrations/oracle/oracle.md +90 -0
- package/scripts/integrations/postgres/docker-compose.yml +3 -3
- package/scripts/likeCypress.ts +33 -0
- package/src/api/controllers/application.js +18 -1
- package/src/api/controllers/auth.js +3 -0
- package/src/api/controllers/datasource.js +84 -16
- package/src/api/controllers/deploy/index.js +2 -0
- package/src/api/controllers/dev.js +4 -1
- package/src/api/controllers/query.js +29 -81
- package/src/api/controllers/row/ExternalRequest.ts +91 -36
- package/src/api/controllers/row/external.js +4 -1
- package/src/api/controllers/row/utils.js +8 -11
- package/src/api/controllers/table/external.js +307 -0
- package/src/api/controllers/table/index.js +47 -137
- package/src/api/controllers/table/internal.js +155 -0
- package/src/api/controllers/table/utils.js +74 -33
- package/src/api/controllers/user.js +132 -13
- package/src/api/controllers/view/exporters.js +5 -0
- package/src/api/controllers/view/index.js +15 -2
- package/src/api/routes/query.js +1 -0
- package/src/api/routes/table.js +11 -0
- package/src/api/routes/tests/datasource.spec.js +2 -2
- package/src/api/routes/tests/misc.spec.js +5 -1
- package/src/api/routes/tests/query.spec.js +0 -1
- package/src/api/routes/user.js +5 -0
- package/src/app.ts +2 -10
- package/src/automations/bullboard.js +28 -11
- package/src/automations/tests/automation.spec.js +3 -4
- package/src/automations/triggers.js +7 -3
- package/src/automations/utils.js +12 -2
- package/src/constants/index.js +22 -0
- package/src/definitions/common.ts +7 -1
- package/src/definitions/datasource.ts +10 -3
- package/src/environment.js +15 -0
- package/src/integrations/airtable.ts +2 -1
- package/src/integrations/arangodb.ts +2 -1
- package/src/integrations/base/IntegrationBase.ts +6 -0
- package/src/integrations/base/datasourcePlus.ts +9 -0
- package/src/integrations/base/sql.ts +377 -218
- package/src/integrations/base/sqlTable.ts +180 -0
- package/src/integrations/base/utils.ts +22 -0
- package/src/integrations/couchdb.ts +2 -1
- package/src/integrations/dynamodb.ts +2 -1
- package/src/integrations/elasticsearch.ts +2 -1
- package/src/integrations/index.ts +7 -0
- package/src/integrations/microsoftSqlServer.ts +145 -13
- package/src/integrations/mongodb.ts +2 -1
- package/src/integrations/mysql.ts +23 -95
- package/src/integrations/oracle.ts +458 -0
- package/src/integrations/postgres.ts +45 -35
- package/src/integrations/rest.ts +2 -1
- package/src/integrations/s3.ts +2 -1
- package/src/integrations/tests/microsoftSqlServer.spec.js +22 -15
- package/src/integrations/tests/oracle.spec.js +94 -0
- package/src/integrations/tests/postgres.spec.js +4 -0
- package/src/integrations/utils.ts +78 -8
- package/src/middleware/authorized.js +2 -1
- package/src/middleware/builder.js +4 -1
- package/src/tests/utilities/TestConfiguration.js +2 -1
- package/src/{automations/thread.js → threads/automation.js} +27 -8
- package/src/threads/index.js +66 -0
- package/src/threads/query.js +66 -0
- package/src/utilities/csvParser.js +48 -5
- package/src/utilities/global.js +7 -2
- package/src/utilities/index.js +11 -0
- package/src/utilities/queue/inMemoryQueue.js +7 -0
- package/src/utilities/scriptRunner.js +4 -1
- package/src/utilities/tests/__snapshots__/csvParser.spec.js.snap +0 -6
- package/src/utilities/tests/csvParser.spec.js +3 -0
- package/tsconfig.json +1 -1
- package/builder/assets/index.550fdba7.js +0 -201
- package/builder/assets/index.7469e1e4.css +0 -29
- package/builder/assets/vendor.278a305c.js +0 -9
- package/builder/assets/vendor.d75d5eb7.css +0 -1
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.190-alpha.1",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"test": "jest --coverage --maxWorkers=2",
|
|
15
15
|
"test:watch": "jest --watch",
|
|
16
16
|
"predocker": "copyfiles -f ../client/dist/budibase-client.js ../client/manifest.json client",
|
|
17
|
-
"build:docker": "yarn run predocker && docker build . -t app-service",
|
|
17
|
+
"build:docker": "yarn run predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
|
|
18
18
|
"run:docker": "node dist/index.js",
|
|
19
19
|
"dev:stack:up": "node scripts/dev/manage.js up",
|
|
20
20
|
"dev:stack:down": "node scripts/dev/manage.js down",
|
|
@@ -68,9 +68,11 @@
|
|
|
68
68
|
"author": "Budibase",
|
|
69
69
|
"license": "GPL-3.0",
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@budibase/auth": "^0.9.
|
|
72
|
-
"@budibase/client": "^0.9.
|
|
73
|
-
"@budibase/string-templates": "^0.9.
|
|
71
|
+
"@budibase/auth": "^0.9.190-alpha.1",
|
|
72
|
+
"@budibase/client": "^0.9.190-alpha.1",
|
|
73
|
+
"@budibase/string-templates": "^0.9.190-alpha.1",
|
|
74
|
+
"@bull-board/api": "^3.7.0",
|
|
75
|
+
"@bull-board/koa": "^3.7.0",
|
|
74
76
|
"@elastic/elasticsearch": "7.10.0",
|
|
75
77
|
"@koa/router": "8.0.0",
|
|
76
78
|
"@sendgrid/mail": "7.1.1",
|
|
@@ -80,7 +82,6 @@
|
|
|
80
82
|
"aws-sdk": "^2.767.0",
|
|
81
83
|
"bcryptjs": "2.4.3",
|
|
82
84
|
"bull": "^3.22.4",
|
|
83
|
-
"bull-board": "^2.0.1",
|
|
84
85
|
"chmodr": "1.2.0",
|
|
85
86
|
"csvtojson": "2.0.10",
|
|
86
87
|
"dotenv": "8.2.0",
|
|
@@ -120,6 +121,7 @@
|
|
|
120
121
|
"uuid": "3.3.2",
|
|
121
122
|
"validate.js": "0.13.1",
|
|
122
123
|
"vm2": "^3.9.3",
|
|
124
|
+
"worker-farm": "^1.7.0",
|
|
123
125
|
"yargs": "13.2.4",
|
|
124
126
|
"zlib": "1.0.5"
|
|
125
127
|
},
|
|
@@ -133,12 +135,12 @@
|
|
|
133
135
|
"@types/koa": "^2.13.3",
|
|
134
136
|
"@types/koa-router": "^7.4.2",
|
|
135
137
|
"@types/node": "^15.12.4",
|
|
138
|
+
"@types/oracledb": "^5.2.1",
|
|
136
139
|
"@typescript-eslint/parser": "4.28.0",
|
|
137
140
|
"babel-jest": "^27.0.2",
|
|
138
141
|
"copyfiles": "^2.4.1",
|
|
139
142
|
"docker-compose": "^0.23.6",
|
|
140
143
|
"eslint": "^6.8.0",
|
|
141
|
-
"express": "^4.17.1",
|
|
142
144
|
"jest": "^27.0.5",
|
|
143
145
|
"nodemon": "^2.0.4",
|
|
144
146
|
"prettier": "^2.3.1",
|
|
@@ -149,5 +151,8 @@
|
|
|
149
151
|
"typescript": "^4.3.5",
|
|
150
152
|
"update-dotenv": "^1.1.1"
|
|
151
153
|
},
|
|
154
|
+
"optionalDependencies": {
|
|
155
|
+
"oracledb": "^5.3.0"
|
|
156
|
+
},
|
|
152
157
|
"gitHead": "d1836a898cab3f8ab80ee6d8f42be1a9eed7dcdc"
|
|
153
158
|
}
|
|
@@ -289,7 +289,8 @@ class TestConfiguration {
|
|
|
289
289
|
createDatasource(config = null) {
|
|
290
290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
291
291
|
config = config || basicDatasource();
|
|
292
|
-
|
|
292
|
+
const response = yield this._req(config, null, controllers.datasource.save);
|
|
293
|
+
this.datasource = response.datasource;
|
|
293
294
|
return this.datasource;
|
|
294
295
|
});
|
|
295
296
|
}
|
|
@@ -8,17 +8,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
const
|
|
11
|
+
// when thread starts, make sure it is recorded
|
|
12
|
+
const env = require("../environment");
|
|
13
|
+
env.setInThread();
|
|
14
|
+
const actions = require("../automations/actions");
|
|
15
|
+
const automationUtils = require("../automations/automationUtils");
|
|
13
16
|
const AutomationEmitter = require("../events/AutomationEmitter");
|
|
14
17
|
const { processObject } = require("@budibase/string-templates");
|
|
15
18
|
const { DEFAULT_TENANT_ID } = require("@budibase/auth").constants;
|
|
16
19
|
const CouchDB = require("../db");
|
|
17
20
|
const { DocumentTypes, isDevAppID } = require("../db/utils");
|
|
18
21
|
const { doInTenant } = require("@budibase/auth/tenancy");
|
|
19
|
-
const env = require("../environment");
|
|
20
22
|
const usage = require("../utilities/usageQuota");
|
|
23
|
+
const { definitions: triggerDefs } = require("../automations/triggerInfo");
|
|
21
24
|
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId;
|
|
25
|
+
const CRON_STEP_ID = triggerDefs.CRON.stepId;
|
|
22
26
|
const STOPPED_STATUS = { success: false, status: "STOPPED" };
|
|
23
27
|
/**
|
|
24
28
|
* The automation orchestrator is a class responsible for executing automations.
|
|
@@ -31,6 +35,8 @@ class Orchestrator {
|
|
|
31
35
|
this._chainCount = this._metadata ? this._metadata.automationChainCount : 0;
|
|
32
36
|
this._appId = triggerOutput.appId;
|
|
33
37
|
this._app = null;
|
|
38
|
+
const triggerStepId = automation.definition.trigger.stepId;
|
|
39
|
+
triggerOutput = this.cleanupTriggerOutputs(triggerStepId, triggerOutput);
|
|
34
40
|
// remove from context
|
|
35
41
|
delete triggerOutput.appId;
|
|
36
42
|
delete triggerOutput.metadata;
|
|
@@ -42,10 +48,15 @@ class Orchestrator {
|
|
|
42
48
|
this._emitter = new AutomationEmitter(this._chainCount + 1);
|
|
43
49
|
this.executionOutput = { trigger: {}, steps: [] };
|
|
44
50
|
// setup the execution output
|
|
45
|
-
const triggerStepId = automation.definition.trigger.stepId;
|
|
46
51
|
const triggerId = automation.definition.trigger.id;
|
|
47
52
|
this.updateExecutionOutput(triggerId, triggerStepId, null, triggerOutput);
|
|
48
53
|
}
|
|
54
|
+
cleanupTriggerOutputs(stepId, triggerOutput) {
|
|
55
|
+
if (stepId === CRON_STEP_ID) {
|
|
56
|
+
triggerOutput.timestamp = Date.now();
|
|
57
|
+
}
|
|
58
|
+
return triggerOutput;
|
|
59
|
+
}
|
|
49
60
|
getStepFunctionality(stepId) {
|
|
50
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
62
|
let step = yield actions.getAction(stepId);
|
|
@@ -122,7 +133,14 @@ class Orchestrator {
|
|
|
122
133
|
});
|
|
123
134
|
}
|
|
124
135
|
}
|
|
125
|
-
module.exports = (
|
|
126
|
-
const automationOrchestrator = new Orchestrator(
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
module.exports = (input, callback) => {
|
|
137
|
+
const automationOrchestrator = new Orchestrator(input.data.automation, input.data.event);
|
|
138
|
+
automationOrchestrator
|
|
139
|
+
.execute()
|
|
140
|
+
.then(response => {
|
|
141
|
+
callback(null, response);
|
|
142
|
+
})
|
|
143
|
+
.catch(err => {
|
|
144
|
+
callback(err);
|
|
145
|
+
});
|
|
146
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const workerFarm = require("worker-farm");
|
|
3
|
+
const env = require("../environment");
|
|
4
|
+
const ThreadType = {
|
|
5
|
+
QUERY: "query",
|
|
6
|
+
AUTOMATION: "automation",
|
|
7
|
+
};
|
|
8
|
+
function typeToFile(type) {
|
|
9
|
+
let filename = null;
|
|
10
|
+
switch (type) {
|
|
11
|
+
case ThreadType.QUERY:
|
|
12
|
+
filename = "./query";
|
|
13
|
+
break;
|
|
14
|
+
case ThreadType.AUTOMATION:
|
|
15
|
+
filename = "./automation";
|
|
16
|
+
break;
|
|
17
|
+
default:
|
|
18
|
+
throw "Unknown thread type";
|
|
19
|
+
}
|
|
20
|
+
return require.resolve(filename);
|
|
21
|
+
}
|
|
22
|
+
class Thread {
|
|
23
|
+
constructor(type, opts = { timeoutMs: null, count: 1 }) {
|
|
24
|
+
this.type = type;
|
|
25
|
+
this.count = opts.count ? opts.count : 1;
|
|
26
|
+
this.disableThreading =
|
|
27
|
+
env.isTest() ||
|
|
28
|
+
env.DISABLE_THREADING ||
|
|
29
|
+
this.count === 0 ||
|
|
30
|
+
env.isInThread();
|
|
31
|
+
if (!this.disableThreading) {
|
|
32
|
+
const workerOpts = {
|
|
33
|
+
autoStart: true,
|
|
34
|
+
maxConcurrentWorkers: this.count,
|
|
35
|
+
};
|
|
36
|
+
if (opts.timeoutMs) {
|
|
37
|
+
workerOpts.maxCallTime = opts.timeoutMs;
|
|
38
|
+
}
|
|
39
|
+
this.workers = workerFarm(workerOpts, typeToFile(type));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
run(data) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
let fncToCall;
|
|
45
|
+
// if in test then don't use threading
|
|
46
|
+
if (this.disableThreading) {
|
|
47
|
+
fncToCall = require(typeToFile(this.type));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
fncToCall = this.workers;
|
|
51
|
+
}
|
|
52
|
+
fncToCall(data, (err, response) => {
|
|
53
|
+
if (err) {
|
|
54
|
+
reject(err);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
resolve(response);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
module.exports.Thread = Thread;
|
|
64
|
+
module.exports.ThreadType = ThreadType;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
// when thread starts, make sure it is recorded
|
|
12
|
+
const env = require("../environment");
|
|
13
|
+
env.setInThread();
|
|
14
|
+
const ScriptRunner = require("../utilities/scriptRunner");
|
|
15
|
+
const { integrations } = require("../integrations");
|
|
16
|
+
function formatResponse(resp) {
|
|
17
|
+
if (typeof resp === "string") {
|
|
18
|
+
try {
|
|
19
|
+
resp = JSON.parse(resp);
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
resp = { response: resp };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return resp;
|
|
26
|
+
}
|
|
27
|
+
function runAndTransform(datasource, queryVerb, query, transformer) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const Integration = integrations[datasource.source];
|
|
30
|
+
if (!Integration) {
|
|
31
|
+
throw "Integration type does not exist.";
|
|
32
|
+
}
|
|
33
|
+
const integration = new Integration(datasource.config);
|
|
34
|
+
let rows = formatResponse(yield integration[queryVerb](query));
|
|
35
|
+
// transform as required
|
|
36
|
+
if (transformer) {
|
|
37
|
+
const runner = new ScriptRunner(transformer, { data: rows });
|
|
38
|
+
rows = runner.execute();
|
|
39
|
+
}
|
|
40
|
+
// needs to an array for next step
|
|
41
|
+
if (!Array.isArray(rows)) {
|
|
42
|
+
rows = [rows];
|
|
43
|
+
}
|
|
44
|
+
// map into JSON if just raw primitive here
|
|
45
|
+
if (rows.find(row => typeof row !== "object")) {
|
|
46
|
+
rows = rows.map(value => ({ value }));
|
|
47
|
+
}
|
|
48
|
+
// get all the potential fields in the schema
|
|
49
|
+
let keys = rows.flatMap(Object.keys);
|
|
50
|
+
if (integration.end) {
|
|
51
|
+
integration.end();
|
|
52
|
+
}
|
|
53
|
+
return { rows, keys };
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
module.exports = (input, callback) => {
|
|
57
|
+
runAndTransform(input.datasource, input.queryVerb, input.query, input.transformer)
|
|
58
|
+
.then(response => {
|
|
59
|
+
callback(null, response);
|
|
60
|
+
})
|
|
61
|
+
.catch(err => {
|
|
62
|
+
callback(err);
|
|
63
|
+
});
|
|
64
|
+
};
|