@budibase/server 1.0.80-alpha.3 → 1.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/node-fetch.ts +0 -1
- package/builder/assets/index.22a39cc9.js +1352 -0
- package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
- package/builder/assets/{vendor.a7c6ad0a.js → vendor.20f80cec.js} +216 -190
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2327 -2390
- package/coverage/coverage-final.json +137 -138
- package/coverage/lcov-report/api/controllers/analytics.js.html +6 -6
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/application.js.html +149 -152
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
- package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
- 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 +16 -16
- package/coverage/lcov-report/api/controllers/dev.js.html +19 -19
- package/coverage/lcov-report/api/controllers/index.html +16 -16
- package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
- package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
- 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/index.js.html +26 -26
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +9 -9
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
- package/coverage/lcov-report/api/controllers/row/index.html +27 -27
- package/coverage/lcov-report/api/controllers/row/index.js.html +46 -46
- package/coverage/lcov-report/api/controllers/row/internal.js.html +82 -94
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +204 -204
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +29 -29
- package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
- 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 +12 -12
- package/coverage/lcov-report/api/controllers/table/index.html +11 -11
- package/coverage/lcov-report/api/controllers/table/index.js.html +44 -47
- package/coverage/lcov-report/api/controllers/table/internal.js.html +50 -50
- package/coverage/lcov-report/api/controllers/table/utils.js.html +80 -80
- package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
- package/coverage/lcov-report/api/controllers/view/utils.js.html +12 -12
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
- package/coverage/lcov-report/api/controllers/webhook.js.html +27 -18
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +28 -37
- package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/application.js.html +9 -9
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +109 -19
- 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 +156 -18
- 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 +35 -35
- package/coverage/lcov-report/api/routes/index.js.html +32 -38
- 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 +58 -16
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +78 -15
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +14 -17
- package/coverage/lcov-report/api/routes/screen.js.html +95 -14
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +13 -13
- package/coverage/lcov-report/api/routes/table.js.html +62 -17
- 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/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +62 -14
- package/coverage/lcov-report/automations/actions.js.html +24 -24
- package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
- package/coverage/lcov-report/automations/bullboard.js.html +16 -16
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +7 -7
- package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
- package/coverage/lcov-report/automations/steps/createRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +7 -7
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +9 -12
- 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/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +11 -11
- 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 +26 -26
- package/coverage/lcov-report/automations/utils.js.html +35 -35
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +28 -40
- 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/client.js.html +18 -18
- package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
- package/coverage/lcov-report/db/index.html +15 -15
- package/coverage/lcov-report/db/index.js.html +3 -3
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +21 -21
- 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 +30 -30
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +87 -123
- 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 +8 -8
- package/coverage/lcov-report/events/utils.js.html +18 -18
- package/coverage/lcov-report/index.html +74 -89
- 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/authorized.js.html +29 -29
- package/coverage/lcov-report/middleware/builder.js.html +16 -16
- package/coverage/lcov-report/middleware/currentapp.js.html +44 -44
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- 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/usageQuota.js.html +17 -17
- 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 +19 -19
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +39 -123
- package/coverage/lcov-report/threads/utils.js.html +14 -14
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
- package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
- package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +18 -18
- package/coverage/lcov-report/utilities/index.js.html +24 -24
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +9 -9
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- 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 +60 -60
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +13 -13
- 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/index.js.html +12 -12
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +8 -8
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +5 -5
- package/coverage/lcov-report/utilities/workerRequests.js.html +53 -200
- package/coverage/lcov.info +3233 -3332
- package/dist/api/controllers/application.js +0 -1
- package/dist/api/controllers/row/internal.js +1 -4
- package/dist/api/controllers/table/index.js +1 -2
- package/dist/api/controllers/webhook.js +5 -3
- package/dist/api/index.js +1 -3
- package/dist/api/routes/automation.js +31 -3
- package/dist/api/routes/datasource.js +50 -3
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/permission.js +14 -4
- package/dist/api/routes/role.js +19 -3
- package/dist/api/routes/row.js +4 -3
- package/dist/api/routes/screen.js +23 -2
- package/dist/api/routes/table.js +17 -3
- package/dist/api/routes/tests/utilities/index.js +0 -23
- package/dist/api/routes/webhook.js +17 -2
- package/dist/automations/steps/filter.js +2 -2
- package/dist/automations/steps/queryRows.js +1 -1
- package/dist/automations/utils.js +2 -2
- package/dist/constants/index.js +0 -3
- package/dist/db/utils.js +0 -11
- package/dist/environment.js +0 -1
- package/dist/integrations/base/sql.js +1 -16
- package/dist/integrations/base/sqlTable.js +4 -8
- package/dist/integrations/googlesheets.js +0 -3
- package/dist/integrations/microsoftSqlServer.js +43 -60
- package/dist/integrations/mysql.js +0 -3
- package/dist/integrations/oracle.js +19 -14
- package/dist/integrations/postgres.js +28 -34
- package/dist/integrations/utils.js +15 -32
- package/dist/package.json +7 -11
- package/dist/tests/utilities/TestConfiguration.js +8 -25
- package/dist/threads/query.js +8 -33
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +15 -50
- package/package.json +8 -12
- package/scripts/integrations/mssql/data/setup.sql +1 -18
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +3 -11
- package/scripts/likeCypress.ts +6 -9
- package/scripts/proxy/generateProxyConfig.js +70 -0
- package/src/api/controllers/application.js +0 -1
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/internal.js +0 -4
- package/src/api/controllers/table/index.js +1 -2
- package/src/api/controllers/webhook.js +6 -3
- package/src/api/index.js +1 -4
- package/src/api/routes/automation.js +33 -3
- package/src/api/routes/datasource.js +52 -6
- package/src/api/routes/index.js +0 -2
- package/src/api/routes/permission.js +18 -4
- package/src/api/routes/role.js +24 -3
- package/src/api/routes/row.js +2 -3
- package/src/api/routes/screen.js +29 -2
- package/src/api/routes/table.js +19 -4
- package/src/api/routes/tests/utilities/index.js +0 -24
- package/src/api/routes/webhook.js +18 -2
- package/src/automations/steps/filter.js +2 -3
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +0 -4
- package/src/db/utils.js +0 -12
- package/src/definitions/common.ts +0 -4
- package/src/definitions/datasource.ts +0 -1
- package/src/environment.js +0 -1
- package/src/integrations/base/datasourcePlus.ts +0 -3
- package/src/integrations/base/sql.ts +1 -16
- package/src/integrations/base/sqlTable.ts +7 -11
- package/src/integrations/googlesheets.ts +2 -5
- package/src/integrations/microsoftSqlServer.ts +61 -86
- package/src/integrations/mysql.ts +0 -4
- package/src/integrations/oracle.ts +35 -27
- package/src/integrations/postgres.ts +26 -33
- package/src/integrations/utils.ts +15 -43
- package/src/tests/utilities/TestConfiguration.js +2 -23
- package/src/threads/query.js +9 -37
- package/src/utilities/workerRequests.js +16 -65
- package/builder/assets/index.f8c92447.js +0 -1288
- package/coverage/lcov-report/api/routes/utils/index.html +0 -111
- package/coverage/lcov-report/api/routes/utils/validators.js.html +0 -737
- package/dist/api/controllers/public/applications.js +0 -94
- package/dist/api/controllers/public/mapping/applications.js +0 -29
- package/dist/api/controllers/public/mapping/index.js +0 -11
- package/dist/api/controllers/public/mapping/queries.js +0 -36
- package/dist/api/controllers/public/mapping/rows.js +0 -24
- package/dist/api/controllers/public/mapping/tables.js +0 -23
- package/dist/api/controllers/public/mapping/types.js +0 -2
- package/dist/api/controllers/public/mapping/users.js +0 -29
- package/dist/api/controllers/public/queries.js +0 -38
- package/dist/api/controllers/public/rows.js +0 -97
- package/dist/api/controllers/public/tables.js +0 -75
- package/dist/api/controllers/public/users.js +0 -95
- package/dist/api/controllers/public/utils.js +0 -49
- package/dist/api/routes/public/applications.js +0 -141
- package/dist/api/routes/public/index.js +0 -101
- package/dist/api/routes/public/middleware/mapper.js +0 -94
- package/dist/api/routes/public/queries.js +0 -77
- package/dist/api/routes/public/rows.js +0 -229
- package/dist/api/routes/public/tables.js +0 -154
- package/dist/api/routes/public/users.js +0 -137
- package/dist/api/routes/public/utils/Endpoint.js +0 -36
- package/dist/api/routes/utils/validators.js +0 -200
- package/dist/definitions/openapi.js +0 -6
- package/specs/generate.js +0 -94
- package/specs/openapi.json +0 -2232
- package/specs/openapi.yaml +0 -1538
- package/specs/parameters.js +0 -59
- package/specs/resources/application.js +0 -101
- package/specs/resources/index.js +0 -24
- package/specs/resources/misc.js +0 -12
- package/specs/resources/query.js +0 -189
- package/specs/resources/row.js +0 -125
- package/specs/resources/table.js +0 -191
- package/specs/resources/user.js +0 -126
- package/specs/resources/utils/Resource.js +0 -26
- package/specs/resources/utils/index.js +0 -11
- package/specs/security.js +0 -7
- package/src/api/controllers/public/applications.ts +0 -74
- package/src/api/controllers/public/mapping/applications.ts +0 -32
- package/src/api/controllers/public/mapping/index.ts +0 -13
- package/src/api/controllers/public/mapping/queries.ts +0 -39
- package/src/api/controllers/public/mapping/rows.ts +0 -31
- package/src/api/controllers/public/mapping/tables.ts +0 -26
- package/src/api/controllers/public/mapping/types.ts +0 -13
- package/src/api/controllers/public/mapping/users.ts +0 -32
- package/src/api/controllers/public/queries.ts +0 -20
- package/src/api/controllers/public/rows.ts +0 -77
- package/src/api/controllers/public/tables.ts +0 -56
- package/src/api/controllers/public/users.ts +0 -82
- package/src/api/controllers/public/utils.ts +0 -38
- package/src/api/routes/public/applications.ts +0 -156
- package/src/api/routes/public/index.ts +0 -118
- package/src/api/routes/public/middleware/mapper.ts +0 -81
- package/src/api/routes/public/queries.ts +0 -81
- package/src/api/routes/public/rows.ts +0 -242
- package/src/api/routes/public/tables.ts +0 -169
- package/src/api/routes/public/tests/compare.spec.js +0 -184
- package/src/api/routes/public/users.ts +0 -144
- package/src/api/routes/public/utils/Endpoint.ts +0 -51
- package/src/api/routes/utils/validators.js +0 -219
- package/src/definitions/openapi.ts +0 -943
|
@@ -36,31 +36,10 @@ function request(ctx, request) {
|
|
|
36
36
|
delete request.body;
|
|
37
37
|
}
|
|
38
38
|
if (ctx && ctx.headers) {
|
|
39
|
-
request.headers = ctx.headers;
|
|
39
|
+
request.headers.cookie = ctx.headers.cookie;
|
|
40
40
|
}
|
|
41
41
|
return request;
|
|
42
42
|
}
|
|
43
|
-
function checkResponse(response, errorMsg, { ctx } = {}) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
if (response.status !== 200) {
|
|
46
|
-
let error;
|
|
47
|
-
try {
|
|
48
|
-
error = yield response.json();
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
error = yield response.text();
|
|
52
|
-
}
|
|
53
|
-
const msg = `Unable to ${errorMsg} - ${error.message ? error.message : error}`;
|
|
54
|
-
if (ctx) {
|
|
55
|
-
ctx.throw(400, msg);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
throw msg;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return response.json();
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
43
|
exports.request = request;
|
|
65
44
|
// have to pass in the tenant ID as this could be coming from an automation
|
|
66
45
|
exports.sendSmtpEmail = (to, from, subject, contents, automation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -76,14 +55,21 @@ exports.sendSmtpEmail = (to, from, subject, contents, automation) => __awaiter(v
|
|
|
76
55
|
automation,
|
|
77
56
|
},
|
|
78
57
|
}));
|
|
79
|
-
|
|
58
|
+
if (response.status !== 200) {
|
|
59
|
+
const error = yield response.text();
|
|
60
|
+
throw `Unable to send email - ${error}`;
|
|
61
|
+
}
|
|
62
|
+
return response.json();
|
|
80
63
|
});
|
|
81
64
|
exports.getGlobalSelf = (ctx, appId = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
-
const endpoint = `/api/global/self`;
|
|
65
|
+
const endpoint = `/api/global/users/self`;
|
|
83
66
|
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + endpoint),
|
|
84
67
|
// we don't want to use API key when getting self
|
|
85
68
|
request(ctx, { method: "GET" }));
|
|
86
|
-
|
|
69
|
+
if (response.status !== 200) {
|
|
70
|
+
ctx.throw(400, "Unable to get self globally.");
|
|
71
|
+
}
|
|
72
|
+
let json = yield response.json();
|
|
87
73
|
if (appId) {
|
|
88
74
|
json = updateAppRole(json);
|
|
89
75
|
}
|
|
@@ -94,29 +80,8 @@ exports.removeAppFromUserRoles = (ctx, appId) => __awaiter(void 0, void 0, void
|
|
|
94
80
|
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${prodAppId}`), request(ctx, {
|
|
95
81
|
method: "DELETE",
|
|
96
82
|
}));
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// we don't want to use API key when getting self
|
|
102
|
-
request(ctx, { method: "GET" }));
|
|
103
|
-
return checkResponse(response, "get users", { ctx });
|
|
104
|
-
});
|
|
105
|
-
exports.saveGlobalUser = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
106
|
-
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/users"),
|
|
107
|
-
// we don't want to use API key when getting self
|
|
108
|
-
request(ctx, { method: "POST", body: ctx.request.body }));
|
|
109
|
-
return checkResponse(response, "save user", { ctx });
|
|
110
|
-
});
|
|
111
|
-
exports.deleteGlobalUser = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
-
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/users/${ctx.params.userId}`),
|
|
113
|
-
// we don't want to use API key when getting self
|
|
114
|
-
request(ctx, { method: "DELETE" }));
|
|
115
|
-
return checkResponse(response, "delete user", { ctx, body: ctx.request.body });
|
|
116
|
-
});
|
|
117
|
-
exports.readGlobalUser = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
-
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/users/${ctx.params.userId}`),
|
|
119
|
-
// we don't want to use API key when getting self
|
|
120
|
-
request(ctx, { method: "GET" }));
|
|
121
|
-
return checkResponse(response, "get user", { ctx });
|
|
83
|
+
if (response.status !== 200) {
|
|
84
|
+
throw "Unable to remove app role";
|
|
85
|
+
}
|
|
86
|
+
return response.json();
|
|
122
87
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "1.0.80
|
|
4
|
+
"version": "1.0.80",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
"dev:stack:down": "node scripts/dev/manage.js down",
|
|
22
22
|
"dev:stack:nuke": "node scripts/dev/manage.js nuke",
|
|
23
23
|
"dev:builder": "yarn run dev:stack:up && nodemon",
|
|
24
|
+
"generate:proxy:compose": "node scripts/proxy/generateProxyConfig compose",
|
|
25
|
+
"generate:proxy:preprod": "node scripts/proxy/generateProxyConfig preprod",
|
|
26
|
+
"generate:proxy:prod": "node scripts/proxy/generateProxyConfig prod",
|
|
24
27
|
"format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write",
|
|
25
|
-
"specs": "node specs/generate.js && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
|
|
26
28
|
"lint": "eslint --fix src/",
|
|
27
29
|
"lint:fix": "yarn run format && yarn run lint",
|
|
28
30
|
"initialise": "node scripts/initialise.js",
|
|
@@ -71,9 +73,9 @@
|
|
|
71
73
|
"license": "GPL-3.0",
|
|
72
74
|
"dependencies": {
|
|
73
75
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
74
|
-
"@budibase/backend-core": "^1.0.80
|
|
75
|
-
"@budibase/client": "^1.0.80
|
|
76
|
-
"@budibase/string-templates": "^1.0.80
|
|
76
|
+
"@budibase/backend-core": "^1.0.80",
|
|
77
|
+
"@budibase/client": "^1.0.80",
|
|
78
|
+
"@budibase/string-templates": "^1.0.80",
|
|
77
79
|
"@bull-board/api": "^3.7.0",
|
|
78
80
|
"@bull-board/koa": "^3.7.0",
|
|
79
81
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -108,7 +110,6 @@
|
|
|
108
110
|
"koa-send": "5.0.0",
|
|
109
111
|
"koa-session": "5.12.0",
|
|
110
112
|
"koa-static": "5.0.0",
|
|
111
|
-
"koa2-ratelimit": "^1.1.0",
|
|
112
113
|
"lodash": "4.17.21",
|
|
113
114
|
"memorystream": "^0.3.1",
|
|
114
115
|
"mongodb": "3.6.3",
|
|
@@ -124,7 +125,6 @@
|
|
|
124
125
|
"pouchdb-all-dbs": "1.0.2",
|
|
125
126
|
"pouchdb-find": "^7.2.2",
|
|
126
127
|
"pouchdb-replication-stream": "1.2.9",
|
|
127
|
-
"redis": "4",
|
|
128
128
|
"server-destroy": "1.0.1",
|
|
129
129
|
"svelte": "^3.38.2",
|
|
130
130
|
"swagger-parser": "^10.0.3",
|
|
@@ -150,7 +150,6 @@
|
|
|
150
150
|
"@types/koa-router": "^7.4.2",
|
|
151
151
|
"@types/node": "^15.12.4",
|
|
152
152
|
"@types/oracledb": "^5.2.1",
|
|
153
|
-
"@types/redis": "^4.0.11",
|
|
154
153
|
"@typescript-eslint/parser": "4.28.0",
|
|
155
154
|
"apidoc": "^0.50.2",
|
|
156
155
|
"babel-jest": "^27.0.2",
|
|
@@ -158,15 +157,12 @@
|
|
|
158
157
|
"docker-compose": "^0.23.6",
|
|
159
158
|
"eslint": "^6.8.0",
|
|
160
159
|
"jest": "^27.0.5",
|
|
161
|
-
"jest-openapi": "^0.14.2",
|
|
162
160
|
"nodemon": "^2.0.4",
|
|
163
161
|
"openapi-types": "^9.3.1",
|
|
164
|
-
"openapi-typescript": "^5.2.0",
|
|
165
162
|
"path-to-regexp": "^6.2.0",
|
|
166
163
|
"prettier": "^2.3.1",
|
|
167
164
|
"rimraf": "^3.0.2",
|
|
168
165
|
"supertest": "^4.0.2",
|
|
169
|
-
"swagger-jsdoc": "^6.1.0",
|
|
170
166
|
"ts-jest": "^27.0.3",
|
|
171
167
|
"ts-node": "^10.0.0",
|
|
172
168
|
"typescript": "^4.3.5",
|
|
@@ -175,5 +171,5 @@
|
|
|
175
171
|
"optionalDependencies": {
|
|
176
172
|
"oracledb": "^5.3.0"
|
|
177
173
|
},
|
|
178
|
-
"gitHead": "
|
|
174
|
+
"gitHead": "0295a18622fdb95e1d279a0d54962d9e2762bc75"
|
|
179
175
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
USE master;
|
|
2
|
-
|
|
3
|
-
IF NOT EXISTS(SELECT 1 FROM sys.schemas WHERE name = 'Chains')
|
|
4
|
-
BEGIN
|
|
5
|
-
EXEC sys.sp_executesql N'CREATE SCHEMA Chains;'
|
|
6
|
-
END
|
|
7
|
-
|
|
2
|
+
|
|
8
3
|
IF OBJECT_ID ('dbo.products', 'U') IS NOT NULL
|
|
9
4
|
DROP TABLE products;
|
|
10
5
|
GO
|
|
@@ -66,15 +61,3 @@ VALUES ('Bob', '30'),
|
|
|
66
61
|
('Bobert', '99'),
|
|
67
62
|
('Jan', '22'),
|
|
68
63
|
('Megan', '11');
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
IF OBJECT_ID ('Chains.sizes', 'U') IS NOT NULL
|
|
72
|
-
DROP TABLE Chains.sizes;
|
|
73
|
-
GO
|
|
74
|
-
CREATE TABLE Chains.sizes
|
|
75
|
-
(
|
|
76
|
-
sizeid int IDENTITY(1, 1),
|
|
77
|
-
name varchar(30),
|
|
78
|
-
CONSTRAINT pk_size PRIMARY KEY NONCLUSTERED (sizeid)
|
|
79
|
-
);
|
|
80
|
-
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
To install oracle express edition simply run `docker-compose up`
|
|
10
10
|
|
|
11
|
-
- A single instance pluggable database (PDB) will be created named `
|
|
11
|
+
- A single instance pluggable database (PDB) will be created named `xepdb`
|
|
12
12
|
- The default password is configured in the compose file as `oracle`
|
|
13
|
-
- The `system` and `pdbadmin` users share this password
|
|
13
|
+
- The `system`, `sys` and `pdbadmin` users all share this password
|
|
14
14
|
|
|
15
15
|
## Instant Client
|
|
16
16
|
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
SELECT 'CREATE DATABASE main'
|
|
2
2
|
WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'main')\gexec
|
|
3
|
-
CREATE SCHEMA test;
|
|
4
|
-
CREATE TYPE person_job AS ENUM ('qa', 'programmer', 'designer');
|
|
5
3
|
CREATE TABLE Persons (
|
|
6
4
|
PersonID SERIAL PRIMARY KEY,
|
|
7
5
|
LastName varchar(255),
|
|
8
6
|
FirstName varchar(255),
|
|
9
7
|
Address varchar(255),
|
|
10
|
-
City varchar(255) DEFAULT 'Belfast'
|
|
11
|
-
Type person_job
|
|
8
|
+
City varchar(255) DEFAULT 'Belfast'
|
|
12
9
|
);
|
|
13
10
|
CREATE TABLE Tasks (
|
|
14
11
|
TaskID SERIAL PRIMARY KEY,
|
|
@@ -38,12 +35,8 @@ CREATE TABLE Products_Tasks (
|
|
|
38
35
|
REFERENCES Tasks(TaskID),
|
|
39
36
|
PRIMARY KEY (ProductID, TaskID)
|
|
40
37
|
);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Name varchar(255)
|
|
44
|
-
);
|
|
45
|
-
INSERT INTO Persons (FirstName, LastName, Address, City, Type) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast', 'qa');
|
|
46
|
-
INSERT INTO Persons (FirstName, LastName, Address, City, Type) VALUES ('John', 'Smith', '64 Updown Road', 'Dublin', 'programmer');
|
|
38
|
+
INSERT INTO Persons (FirstName, LastName, Address, City) VALUES ('Mike', 'Hughes', '123 Fake Street', 'Belfast');
|
|
39
|
+
INSERT INTO Persons (FirstName, LastName, Address, City) Values ('John', 'Smith', '64 Updown Road', 'Dublin');
|
|
47
40
|
INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (1, 2, 'assembling', TRUE);
|
|
48
41
|
INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (2, 1, 'processing', FALSE);
|
|
49
42
|
INSERT INTO Products (ProductName) VALUES ('Computers');
|
|
@@ -53,4 +46,3 @@ INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (1, 1);
|
|
|
53
46
|
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (2, 1);
|
|
54
47
|
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (3, 1);
|
|
55
48
|
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (1, 2);
|
|
56
|
-
INSERT INTO test.table1 (Name) VALUES ('Test');
|
package/scripts/likeCypress.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
* This script just makes it easy to re-create *
|
|
3
3
|
* a cypress like environment for testing the backend *
|
|
4
4
|
******************************************************/
|
|
5
|
-
|
|
5
|
+
const path = require("path")
|
|
6
6
|
const tmpdir = path.join(require("os").tmpdir(), ".budibase")
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const WORKER_PORT = "
|
|
8
|
+
const MAIN_PORT = "10001"
|
|
9
|
+
const WORKER_PORT = "10002"
|
|
10
10
|
|
|
11
11
|
// @ts-ignore
|
|
12
|
+
process.env.PORT = MAIN_PORT
|
|
12
13
|
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
|
|
13
14
|
process.env.NODE_ENV = "cypress"
|
|
14
15
|
process.env.ENABLE_ANALYTICS = "false"
|
|
@@ -26,11 +27,7 @@ process.env.ALLOW_DEV_AUTOMATIONS = "1"
|
|
|
26
27
|
|
|
27
28
|
// don't make this a variable or top level require
|
|
28
29
|
// it will cause environment module to be loaded prematurely
|
|
29
|
-
|
|
30
|
-
// override the port with the worker port temporarily
|
|
30
|
+
const server = require("../src/app")
|
|
31
31
|
process.env.PORT = WORKER_PORT
|
|
32
32
|
const worker = require("../../worker/src/index")
|
|
33
|
-
|
|
34
|
-
// override the port with the server port
|
|
35
|
-
process.env.PORT = SERVER_PORT
|
|
36
|
-
const server = require("../src/app")
|
|
33
|
+
process.env.PORT = MAIN_PORT
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const path = require("path")
|
|
3
|
+
const fs = require("fs")
|
|
4
|
+
const { processStringSync } = require("@budibase/string-templates")
|
|
5
|
+
|
|
6
|
+
const Configs = {
|
|
7
|
+
prod: {
|
|
8
|
+
k8s: true,
|
|
9
|
+
apps: "app-service.budibase.svc.cluster.local",
|
|
10
|
+
worker: "worker-service.budibase.svc.cluster.local",
|
|
11
|
+
minio: "minio-service.budibase.svc.cluster.local",
|
|
12
|
+
couchdb: "budibase-prod-svc-couchdb",
|
|
13
|
+
},
|
|
14
|
+
preprod: {
|
|
15
|
+
k8s: true,
|
|
16
|
+
apps: "app-service.budibase.svc.cluster.local",
|
|
17
|
+
worker: "worker-service.budibase.svc.cluster.local",
|
|
18
|
+
minio: "minio-service.budibase.svc.cluster.local",
|
|
19
|
+
couchdb: "budibase-preprod-svc-couchdb",
|
|
20
|
+
},
|
|
21
|
+
compose: {
|
|
22
|
+
compose: true,
|
|
23
|
+
apps: "app-service",
|
|
24
|
+
worker: "worker-service",
|
|
25
|
+
minio: "minio-service",
|
|
26
|
+
couchdb: "couchdb-service",
|
|
27
|
+
watchtower: "watchtower-service",
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const Commands = {
|
|
32
|
+
Prod: "prod",
|
|
33
|
+
Preprod: "preprod",
|
|
34
|
+
Compose: "compose",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function init(managementCommand) {
|
|
38
|
+
const config = Configs[managementCommand]
|
|
39
|
+
const hostingPath = path.join(process.cwd(), "..", "..", "hosting")
|
|
40
|
+
const nginxHbsPath = path.join(hostingPath, "nginx.prod.conf.hbs")
|
|
41
|
+
const nginxOutputPath = path.join(
|
|
42
|
+
hostingPath,
|
|
43
|
+
"proxy",
|
|
44
|
+
".generated-nginx.prod.conf"
|
|
45
|
+
)
|
|
46
|
+
const contents = fs.readFileSync(nginxHbsPath, "utf8")
|
|
47
|
+
fs.writeFileSync(nginxOutputPath, processStringSync(contents, config))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const managementCommand = process.argv.slice(2)[0]
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
!managementCommand ||
|
|
54
|
+
!Object.values(Commands).some(command => managementCommand === command)
|
|
55
|
+
) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"You must supply either a 'compose', 'preprod' or 'prod' commmand to generate an NGINX config."
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
init(managementCommand)
|
|
62
|
+
.then(() => {
|
|
63
|
+
console.log("Done! 🎉")
|
|
64
|
+
})
|
|
65
|
+
.catch(err => {
|
|
66
|
+
console.error(
|
|
67
|
+
"Something went wrong while creating the nginx configuration",
|
|
68
|
+
err.message
|
|
69
|
+
)
|
|
70
|
+
})
|
|
@@ -263,7 +263,6 @@ exports.create = async ctx => {
|
|
|
263
263
|
tenantId: getTenantId(),
|
|
264
264
|
updatedAt: new Date().toISOString(),
|
|
265
265
|
createdAt: new Date().toISOString(),
|
|
266
|
-
status: AppStatus.DEV,
|
|
267
266
|
}
|
|
268
267
|
const response = await db.put(newApplication, { force: true })
|
|
269
268
|
newApplication._rev = response.rev
|
|
@@ -58,7 +58,7 @@ module External {
|
|
|
58
58
|
) {
|
|
59
59
|
const primary = table.primary
|
|
60
60
|
// if passed in array need to copy for shifting etc
|
|
61
|
-
let idCopy
|
|
61
|
+
let idCopy = cloneDeep(id)
|
|
62
62
|
if (filters) {
|
|
63
63
|
// need to map over the filters and make sure the _id field isn't present
|
|
64
64
|
for (let filter of Object.values(filters)) {
|
|
@@ -2,7 +2,6 @@ const linkRows = require("../../../db/linkedRows")
|
|
|
2
2
|
const {
|
|
3
3
|
generateRowID,
|
|
4
4
|
getRowParams,
|
|
5
|
-
getTableIDFromRowID,
|
|
6
5
|
DocumentTypes,
|
|
7
6
|
InternalTables,
|
|
8
7
|
} = require("../../../db/utils")
|
|
@@ -387,9 +386,6 @@ exports.fetchEnrichedRow = async ctx => {
|
|
|
387
386
|
let groups = {},
|
|
388
387
|
tables = {}
|
|
389
388
|
for (let row of response) {
|
|
390
|
-
if (!row.tableId) {
|
|
391
|
-
row.tableId = getTableIDFromRowID(row._id)
|
|
392
|
-
}
|
|
393
389
|
const linkedTableId = row.tableId
|
|
394
390
|
if (groups[linkedTableId] == null) {
|
|
395
391
|
groups[linkedTableId] = [row]
|
|
@@ -48,7 +48,7 @@ exports.fetch = async function (ctx) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
exports.find = async function (ctx) {
|
|
51
|
-
const tableId = ctx.params.
|
|
51
|
+
const tableId = ctx.params.id
|
|
52
52
|
ctx.body = await getTable(tableId)
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -70,7 +70,6 @@ exports.destroy = async function (ctx) {
|
|
|
70
70
|
ctx.eventEmitter &&
|
|
71
71
|
ctx.eventEmitter.emitTable(`table:delete`, appId, deletedTable)
|
|
72
72
|
ctx.status = 200
|
|
73
|
-
ctx.table = deletedTable
|
|
74
73
|
ctx.body = { message: `Table ${tableId} deleted.` }
|
|
75
74
|
}
|
|
76
75
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const { generateWebhookID, getWebhookParams } = require("../../db/utils")
|
|
2
2
|
const toJsonSchema = require("to-json-schema")
|
|
3
3
|
const validate = require("jsonschema").validate
|
|
4
|
-
const { WebhookType } = require("../../constants")
|
|
5
4
|
const triggers = require("../../automations/triggers")
|
|
6
5
|
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
7
6
|
const { getAppDB, updateAppId } = require("@budibase/backend-core/context")
|
|
@@ -19,6 +18,10 @@ function Webhook(name, type, target) {
|
|
|
19
18
|
|
|
20
19
|
exports.Webhook = Webhook
|
|
21
20
|
|
|
21
|
+
exports.WebhookType = {
|
|
22
|
+
AUTOMATION: "automation",
|
|
23
|
+
}
|
|
24
|
+
|
|
22
25
|
exports.fetch = async ctx => {
|
|
23
26
|
const db = getAppDB()
|
|
24
27
|
const response = await db.allDocs(
|
|
@@ -59,7 +62,7 @@ exports.buildSchema = async ctx => {
|
|
|
59
62
|
const webhook = await db.get(ctx.params.id)
|
|
60
63
|
webhook.bodySchema = toJsonSchema(ctx.request.body)
|
|
61
64
|
// update the automation outputs
|
|
62
|
-
if (webhook.action.type === WebhookType.AUTOMATION) {
|
|
65
|
+
if (webhook.action.type === exports.WebhookType.AUTOMATION) {
|
|
63
66
|
let automation = await db.get(webhook.action.target)
|
|
64
67
|
const autoOutputs = automation.definition.trigger.schema.outputs
|
|
65
68
|
let properties = webhook.bodySchema.properties
|
|
@@ -89,7 +92,7 @@ exports.trigger = async ctx => {
|
|
|
89
92
|
validate(ctx.request.body, webhook.bodySchema)
|
|
90
93
|
}
|
|
91
94
|
const target = await db.get(webhook.action.target)
|
|
92
|
-
if (webhook.action.type === WebhookType.AUTOMATION) {
|
|
95
|
+
if (webhook.action.type === exports.WebhookType.AUTOMATION) {
|
|
93
96
|
// trigger with both the pure request and then expand it
|
|
94
97
|
// incase the user has produced a schema to bind to
|
|
95
98
|
await triggers.externalTrigger(target, {
|
package/src/api/index.js
CHANGED
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
const currentApp = require("../middleware/currentapp")
|
|
9
9
|
const compress = require("koa-compress")
|
|
10
10
|
const zlib = require("zlib")
|
|
11
|
-
const { mainRoutes, staticRoutes
|
|
11
|
+
const { mainRoutes, staticRoutes } = require("./routes")
|
|
12
12
|
const pkg = require("../../package.json")
|
|
13
13
|
const env = require("../environment")
|
|
14
14
|
|
|
@@ -82,9 +82,6 @@ for (let route of mainRoutes) {
|
|
|
82
82
|
router.use(route.allowedMethods())
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
router.use(publicRoutes.routes())
|
|
86
|
-
router.use(publicRoutes.allowedMethods())
|
|
87
|
-
|
|
88
85
|
// WARNING - static routes will catch everything else after them this must be last
|
|
89
86
|
router.use(staticRoutes.routes())
|
|
90
87
|
router.use(staticRoutes.allowedMethods())
|
|
@@ -1,20 +1,50 @@
|
|
|
1
1
|
const Router = require("@koa/router")
|
|
2
2
|
const controller = require("../controllers/automation")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
|
+
const joiValidator = require("../../middleware/joi-validator")
|
|
4
5
|
const {
|
|
5
6
|
BUILDER,
|
|
6
7
|
PermissionLevels,
|
|
7
8
|
PermissionTypes,
|
|
8
9
|
} = require("@budibase/backend-core/permissions")
|
|
10
|
+
const Joi = require("joi")
|
|
9
11
|
const { bodyResource, paramResource } = require("../../middleware/resourceId")
|
|
10
12
|
const {
|
|
11
13
|
middleware: appInfoMiddleware,
|
|
12
14
|
AppType,
|
|
13
15
|
} = require("../../middleware/appInfo")
|
|
14
|
-
const { automationValidator } = require("./utils/validators")
|
|
15
16
|
|
|
16
17
|
const router = Router()
|
|
17
18
|
|
|
19
|
+
// prettier-ignore
|
|
20
|
+
function generateStepSchema(allowStepTypes) {
|
|
21
|
+
return Joi.object({
|
|
22
|
+
stepId: Joi.string().required(),
|
|
23
|
+
id: Joi.string().required(),
|
|
24
|
+
description: Joi.string().required(),
|
|
25
|
+
name: Joi.string().required(),
|
|
26
|
+
tagline: Joi.string().required(),
|
|
27
|
+
icon: Joi.string().required(),
|
|
28
|
+
params: Joi.object(),
|
|
29
|
+
args: Joi.object(),
|
|
30
|
+
type: Joi.string().required().valid(...allowStepTypes),
|
|
31
|
+
}).unknown(true)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function generateValidator(existing = false) {
|
|
35
|
+
// prettier-ignore
|
|
36
|
+
return joiValidator.body(Joi.object({
|
|
37
|
+
_id: existing ? Joi.string().required() : Joi.string(),
|
|
38
|
+
_rev: existing ? Joi.string().required() : Joi.string(),
|
|
39
|
+
name: Joi.string().required(),
|
|
40
|
+
type: Joi.string().valid("automation").required(),
|
|
41
|
+
definition: Joi.object({
|
|
42
|
+
steps: Joi.array().required().items(generateStepSchema(["ACTION", "LOGIC"])),
|
|
43
|
+
trigger: generateStepSchema(["TRIGGER"]).allow(null),
|
|
44
|
+
}).required().unknown(true),
|
|
45
|
+
}).unknown(true))
|
|
46
|
+
}
|
|
47
|
+
|
|
18
48
|
router
|
|
19
49
|
.get(
|
|
20
50
|
"/api/automations/trigger/list",
|
|
@@ -42,13 +72,13 @@ router
|
|
|
42
72
|
"/api/automations",
|
|
43
73
|
bodyResource("_id"),
|
|
44
74
|
authorized(BUILDER),
|
|
45
|
-
|
|
75
|
+
generateValidator(true),
|
|
46
76
|
controller.update
|
|
47
77
|
)
|
|
48
78
|
.post(
|
|
49
79
|
"/api/automations",
|
|
50
80
|
authorized(BUILDER),
|
|
51
|
-
|
|
81
|
+
generateValidator(false),
|
|
52
82
|
controller.create
|
|
53
83
|
)
|
|
54
84
|
.delete(
|
|
@@ -1,18 +1,64 @@
|
|
|
1
1
|
const Router = require("@koa/router")
|
|
2
2
|
const datasourceController = require("../controllers/datasource")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
|
+
const joiValidator = require("../../middleware/joi-validator")
|
|
4
5
|
const {
|
|
5
6
|
BUILDER,
|
|
6
7
|
PermissionLevels,
|
|
7
8
|
PermissionTypes,
|
|
8
9
|
} = require("@budibase/backend-core/permissions")
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
datasourceQueryValidator,
|
|
12
|
-
} = require("./utils/validators")
|
|
10
|
+
const Joi = require("joi")
|
|
11
|
+
const { DataSourceOperation } = require("../../constants")
|
|
13
12
|
|
|
14
13
|
const router = Router()
|
|
15
14
|
|
|
15
|
+
function generateDatasourceSchema() {
|
|
16
|
+
// prettier-ignore
|
|
17
|
+
return joiValidator.body(Joi.object({
|
|
18
|
+
_id: Joi.string(),
|
|
19
|
+
_rev: Joi.string(),
|
|
20
|
+
// source: Joi.string().valid("POSTGRES_PLUS"),
|
|
21
|
+
type: Joi.string().allow("datasource_plus"),
|
|
22
|
+
relationships: Joi.array().items(Joi.object({
|
|
23
|
+
from: Joi.string().required(),
|
|
24
|
+
to: Joi.string().required(),
|
|
25
|
+
cardinality: Joi.valid("1:N", "1:1", "N:N").required()
|
|
26
|
+
})),
|
|
27
|
+
// entities: Joi.array().items(Joi.object({
|
|
28
|
+
// type: Joi.string().valid(...Object.values(FieldTypes)).required(),
|
|
29
|
+
// name: Joi.string().required(),
|
|
30
|
+
// })),
|
|
31
|
+
}).unknown(true))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function generateQueryDatasourceSchema() {
|
|
35
|
+
// prettier-ignore
|
|
36
|
+
return joiValidator.body(Joi.object({
|
|
37
|
+
endpoint: Joi.object({
|
|
38
|
+
datasourceId: Joi.string().required(),
|
|
39
|
+
operation: Joi.string().required().valid(...Object.values(DataSourceOperation)),
|
|
40
|
+
entityId: Joi.string().required(),
|
|
41
|
+
}).required(),
|
|
42
|
+
resource: Joi.object({
|
|
43
|
+
fields: Joi.array().items(Joi.string()).optional(),
|
|
44
|
+
}).optional(),
|
|
45
|
+
body: Joi.object().optional(),
|
|
46
|
+
sort: Joi.object().optional(),
|
|
47
|
+
filters: Joi.object({
|
|
48
|
+
string: Joi.object().optional(),
|
|
49
|
+
range: Joi.object().optional(),
|
|
50
|
+
equal: Joi.object().optional(),
|
|
51
|
+
notEqual: Joi.object().optional(),
|
|
52
|
+
empty: Joi.object().optional(),
|
|
53
|
+
notEmpty: Joi.object().optional(),
|
|
54
|
+
}).optional(),
|
|
55
|
+
paginate: Joi.object({
|
|
56
|
+
page: Joi.string().alphanum().optional(),
|
|
57
|
+
limit: Joi.number().optional(),
|
|
58
|
+
}).optional(),
|
|
59
|
+
}))
|
|
60
|
+
}
|
|
61
|
+
|
|
16
62
|
router
|
|
17
63
|
.get("/api/datasources", authorized(BUILDER), datasourceController.fetch)
|
|
18
64
|
.get(
|
|
@@ -28,7 +74,7 @@ router
|
|
|
28
74
|
.post(
|
|
29
75
|
"/api/datasources/query",
|
|
30
76
|
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
|
31
|
-
|
|
77
|
+
generateQueryDatasourceSchema(),
|
|
32
78
|
datasourceController.query
|
|
33
79
|
)
|
|
34
80
|
.post(
|
|
@@ -39,7 +85,7 @@ router
|
|
|
39
85
|
.post(
|
|
40
86
|
"/api/datasources",
|
|
41
87
|
authorized(BUILDER),
|
|
42
|
-
|
|
88
|
+
generateDatasourceSchema(),
|
|
43
89
|
datasourceController.save
|
|
44
90
|
)
|
|
45
91
|
.delete(
|
package/src/api/routes/index.js
CHANGED
|
@@ -25,7 +25,6 @@ const metadataRoutes = require("./metadata")
|
|
|
25
25
|
const devRoutes = require("./dev")
|
|
26
26
|
const cloudRoutes = require("./cloud")
|
|
27
27
|
const migrationRoutes = require("./migrations")
|
|
28
|
-
const publicRoutes = require("./public")
|
|
29
28
|
|
|
30
29
|
exports.mainRoutes = [
|
|
31
30
|
authRoutes,
|
|
@@ -58,5 +57,4 @@ exports.mainRoutes = [
|
|
|
58
57
|
migrationRoutes,
|
|
59
58
|
]
|
|
60
59
|
|
|
61
|
-
exports.publicRoutes = publicRoutes
|
|
62
60
|
exports.staticRoutes = staticRoutes
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
const Router = require("@koa/router")
|
|
2
2
|
const controller = require("../controllers/permission")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
|
-
const {
|
|
5
|
-
|
|
4
|
+
const {
|
|
5
|
+
BUILDER,
|
|
6
|
+
PermissionLevels,
|
|
7
|
+
} = require("@budibase/backend-core/permissions")
|
|
8
|
+
const Joi = require("joi")
|
|
9
|
+
const joiValidator = require("../../middleware/joi-validator")
|
|
6
10
|
|
|
7
11
|
const router = Router()
|
|
8
12
|
|
|
13
|
+
function generateValidator() {
|
|
14
|
+
const permLevelArray = Object.values(PermissionLevels)
|
|
15
|
+
// prettier-ignore
|
|
16
|
+
return joiValidator.params(Joi.object({
|
|
17
|
+
level: Joi.string().valid(...permLevelArray).required(),
|
|
18
|
+
resourceId: Joi.string(),
|
|
19
|
+
roleId: Joi.string(),
|
|
20
|
+
}).unknown(true))
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
router
|
|
10
24
|
.get("/api/permission/builtin", authorized(BUILDER), controller.fetchBuiltin)
|
|
11
25
|
.get("/api/permission/levels", authorized(BUILDER), controller.fetchLevels)
|
|
@@ -19,14 +33,14 @@ router
|
|
|
19
33
|
.post(
|
|
20
34
|
"/api/permission/:roleId/:resourceId/:level",
|
|
21
35
|
authorized(BUILDER),
|
|
22
|
-
|
|
36
|
+
generateValidator(),
|
|
23
37
|
controller.addPermission
|
|
24
38
|
)
|
|
25
39
|
// deleting the level defaults it back the underlying access control for the resource
|
|
26
40
|
.delete(
|
|
27
41
|
"/api/permission/:roleId/:resourceId/:level",
|
|
28
42
|
authorized(BUILDER),
|
|
29
|
-
|
|
43
|
+
generateValidator(),
|
|
30
44
|
controller.removePermission
|
|
31
45
|
)
|
|
32
46
|
|