@budibase/server 1.0.80 → 1.0.81-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/__mocks__/node-fetch.ts +1 -0
- package/builder/assets/{index.c8d1e8f0.css → index.8b1dc06c.css} +2 -2
- package/builder/assets/index.e4d4c510.js +1291 -0
- package/builder/assets/{vendor.20f80cec.js → vendor.a7c6ad0a.js} +190 -216
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2531 -2440
- package/coverage/coverage-final.json +138 -137
- 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 +152 -149
- 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 +86 -23
- package/coverage/lcov-report/api/controllers/row/index.html +46 -46
- package/coverage/lcov-report/api/controllers/row/index.js.html +76 -49
- package/coverage/lcov-report/api/controllers/row/internal.js.html +144 -84
- 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 +62 -20
- package/coverage/lcov-report/api/controllers/table/index.html +20 -20
- package/coverage/lcov-report/api/controllers/table/index.js.html +47 -44
- 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 +18 -27
- package/coverage/lcov-report/api/index.html +10 -10
- package/coverage/lcov-report/api/index.js.html +37 -28
- 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 +19 -109
- 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 +18 -156
- 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 +38 -32
- 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 +16 -58
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +15 -78
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/row.js.html +80 -14
- package/coverage/lcov-report/api/routes/screen.js.html +14 -95
- 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 +17 -62
- 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 +111 -0
- package/coverage/lcov-report/api/routes/utils/validators.js.html +737 -0
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +14 -62
- 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 +12 -9
- 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 +40 -28
- 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 +123 -87
- 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 +91 -76
- 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 +123 -39
- 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 +200 -53
- package/coverage/lcov.info +3555 -3411
- package/dist/api/controllers/application.js +1 -0
- package/dist/api/controllers/public/applications.js +94 -0
- package/dist/api/controllers/public/mapping/applications.js +29 -0
- package/dist/api/controllers/public/mapping/index.js +11 -0
- package/dist/api/controllers/public/mapping/queries.js +36 -0
- package/dist/api/controllers/public/mapping/rows.js +24 -0
- package/dist/api/controllers/public/mapping/tables.js +23 -0
- package/dist/api/controllers/public/mapping/types.js +2 -0
- package/dist/api/controllers/public/mapping/users.js +29 -0
- package/dist/api/controllers/public/queries.js +38 -0
- package/dist/api/controllers/public/rows.js +97 -0
- package/dist/api/controllers/public/tables.js +75 -0
- package/dist/api/controllers/public/users.js +95 -0
- package/dist/api/controllers/public/utils.js +49 -0
- package/dist/api/controllers/row/external.js +18 -0
- package/dist/api/controllers/row/index.js +11 -0
- package/dist/api/controllers/row/internal.js +15 -1
- package/dist/api/controllers/table/external.js +8 -2
- package/dist/api/controllers/table/index.js +2 -1
- package/dist/api/controllers/webhook.js +3 -5
- package/dist/api/index.js +3 -1
- package/dist/api/routes/automation.js +3 -31
- package/dist/api/routes/datasource.js +3 -50
- package/dist/api/routes/index.js +2 -0
- package/dist/api/routes/permission.js +4 -14
- package/dist/api/routes/public/applications.js +141 -0
- package/dist/api/routes/public/index.js +101 -0
- package/dist/api/routes/public/middleware/mapper.js +94 -0
- package/dist/api/routes/public/queries.js +77 -0
- package/dist/api/routes/public/rows.js +229 -0
- package/dist/api/routes/public/tables.js +154 -0
- package/dist/api/routes/public/users.js +137 -0
- package/dist/api/routes/public/utils/Endpoint.js +36 -0
- package/dist/api/routes/role.js +3 -19
- package/dist/api/routes/row.js +18 -5
- package/dist/api/routes/screen.js +2 -23
- package/dist/api/routes/table.js +3 -17
- package/dist/api/routes/tests/utilities/index.js +23 -0
- package/dist/api/routes/utils/validators.js +200 -0
- package/dist/api/routes/webhook.js +2 -17
- 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 +3 -0
- package/dist/db/utils.js +11 -0
- package/dist/definitions/openapi.js +6 -0
- package/dist/environment.js +1 -0
- package/dist/integrations/base/sql.js +16 -1
- package/dist/integrations/base/sqlTable.js +21 -9
- package/dist/integrations/googlesheets.js +3 -0
- package/dist/integrations/microsoftSqlServer.js +60 -43
- package/dist/integrations/mysql.js +3 -0
- package/dist/integrations/oracle.js +14 -19
- package/dist/integrations/postgres.js +34 -28
- package/dist/integrations/utils.js +32 -15
- package/dist/package.json +11 -7
- package/dist/tests/utilities/TestConfiguration.js +25 -8
- package/dist/threads/query.js +33 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +50 -15
- package/package.json +12 -8
- package/scripts/integrations/mssql/data/setup.sql +18 -1
- package/scripts/integrations/oracle/oracle.md +2 -2
- package/scripts/integrations/postgres/init.sql +11 -3
- package/scripts/likeCypress.ts +9 -6
- package/specs/generate.js +94 -0
- package/specs/openapi.json +2232 -0
- package/specs/openapi.yaml +1538 -0
- package/specs/parameters.js +59 -0
- package/specs/resources/application.js +101 -0
- package/specs/resources/index.js +24 -0
- package/specs/resources/misc.js +12 -0
- package/specs/resources/query.js +189 -0
- package/specs/resources/row.js +125 -0
- package/specs/resources/table.js +191 -0
- package/specs/resources/user.js +126 -0
- package/specs/resources/utils/Resource.js +26 -0
- package/specs/resources/utils/index.js +11 -0
- package/specs/security.js +7 -0
- package/src/api/controllers/application.js +1 -0
- package/src/api/controllers/public/applications.ts +74 -0
- package/src/api/controllers/public/mapping/applications.ts +32 -0
- package/src/api/controllers/public/mapping/index.ts +13 -0
- package/src/api/controllers/public/mapping/queries.ts +39 -0
- package/src/api/controllers/public/mapping/rows.ts +31 -0
- package/src/api/controllers/public/mapping/tables.ts +26 -0
- package/src/api/controllers/public/mapping/types.ts +13 -0
- package/src/api/controllers/public/mapping/users.ts +32 -0
- package/src/api/controllers/public/queries.ts +20 -0
- package/src/api/controllers/public/rows.ts +77 -0
- package/src/api/controllers/public/tables.ts +56 -0
- package/src/api/controllers/public/users.ts +82 -0
- package/src/api/controllers/public/utils.ts +38 -0
- package/src/api/controllers/row/ExternalRequest.ts +1 -1
- package/src/api/controllers/row/external.js +21 -0
- package/src/api/controllers/row/index.js +9 -0
- package/src/api/controllers/row/internal.js +20 -0
- package/src/api/controllers/table/external.js +16 -2
- package/src/api/controllers/table/index.js +2 -1
- package/src/api/controllers/webhook.js +3 -6
- package/src/api/index.js +4 -1
- package/src/api/routes/automation.js +3 -33
- package/src/api/routes/datasource.js +6 -52
- package/src/api/routes/index.js +2 -0
- package/src/api/routes/permission.js +4 -18
- package/src/api/routes/public/applications.ts +156 -0
- package/src/api/routes/public/index.ts +118 -0
- package/src/api/routes/public/middleware/mapper.ts +81 -0
- package/src/api/routes/public/queries.ts +81 -0
- package/src/api/routes/public/rows.ts +242 -0
- package/src/api/routes/public/tables.ts +169 -0
- package/src/api/routes/public/tests/compare.spec.js +184 -0
- package/src/api/routes/public/users.ts +144 -0
- package/src/api/routes/public/utils/Endpoint.ts +51 -0
- package/src/api/routes/role.js +3 -24
- package/src/api/routes/row.js +24 -2
- package/src/api/routes/screen.js +2 -29
- package/src/api/routes/table.js +4 -19
- package/src/api/routes/tests/utilities/index.js +24 -0
- package/src/api/routes/utils/validators.js +219 -0
- package/src/api/routes/webhook.js +2 -18
- package/src/automations/steps/filter.js +3 -2
- package/src/automations/steps/queryRows.js +1 -1
- package/src/automations/utils.js +2 -2
- package/src/constants/index.js +4 -0
- package/src/db/utils.js +12 -0
- package/src/definitions/common.ts +4 -0
- package/src/definitions/datasource.ts +7 -0
- package/src/definitions/openapi.ts +943 -0
- package/src/environment.js +1 -0
- package/src/integrations/base/datasourcePlus.ts +3 -0
- package/src/integrations/base/sql.ts +16 -1
- package/src/integrations/base/sqlTable.ts +35 -13
- package/src/integrations/googlesheets.ts +5 -2
- package/src/integrations/microsoftSqlServer.ts +86 -61
- package/src/integrations/mysql.ts +4 -0
- package/src/integrations/oracle.ts +27 -35
- package/src/integrations/postgres.ts +33 -26
- package/src/integrations/utils.ts +43 -15
- package/src/tests/utilities/TestConfiguration.js +23 -2
- package/src/threads/query.js +37 -9
- package/src/utilities/workerRequests.js +65 -16
- package/builder/assets/index.22a39cc9.js +0 -1352
- package/scripts/proxy/generateProxyConfig.js +0 -70
|
@@ -36,10 +36,31 @@ function request(ctx, request) {
|
|
|
36
36
|
delete request.body;
|
|
37
37
|
}
|
|
38
38
|
if (ctx && ctx.headers) {
|
|
39
|
-
request.headers
|
|
39
|
+
request.headers = ctx.headers;
|
|
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
|
+
}
|
|
43
64
|
exports.request = request;
|
|
44
65
|
// have to pass in the tenant ID as this could be coming from an automation
|
|
45
66
|
exports.sendSmtpEmail = (to, from, subject, contents, automation) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -55,21 +76,14 @@ exports.sendSmtpEmail = (to, from, subject, contents, automation) => __awaiter(v
|
|
|
55
76
|
automation,
|
|
56
77
|
},
|
|
57
78
|
}));
|
|
58
|
-
|
|
59
|
-
const error = yield response.text();
|
|
60
|
-
throw `Unable to send email - ${error}`;
|
|
61
|
-
}
|
|
62
|
-
return response.json();
|
|
79
|
+
return checkResponse(response, "send email");
|
|
63
80
|
});
|
|
64
81
|
exports.getGlobalSelf = (ctx, appId = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
-
const endpoint = `/api/global/
|
|
82
|
+
const endpoint = `/api/global/self`;
|
|
66
83
|
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + endpoint),
|
|
67
84
|
// we don't want to use API key when getting self
|
|
68
85
|
request(ctx, { method: "GET" }));
|
|
69
|
-
|
|
70
|
-
ctx.throw(400, "Unable to get self globally.");
|
|
71
|
-
}
|
|
72
|
-
let json = yield response.json();
|
|
86
|
+
let json = yield checkResponse(response, "get self globally", { ctx });
|
|
73
87
|
if (appId) {
|
|
74
88
|
json = updateAppRole(json);
|
|
75
89
|
}
|
|
@@ -80,8 +94,29 @@ exports.removeAppFromUserRoles = (ctx, appId) => __awaiter(void 0, void 0, void
|
|
|
80
94
|
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + `/api/global/roles/${prodAppId}`), request(ctx, {
|
|
81
95
|
method: "DELETE",
|
|
82
96
|
}));
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
return checkResponse(response, "remove app role");
|
|
98
|
+
});
|
|
99
|
+
exports.allGlobalUsers = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
const response = yield fetch(checkSlashesInUrl(env.WORKER_URL + "/api/global/users"),
|
|
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 });
|
|
87
122
|
});
|
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.
|
|
4
|
+
"version": "1.0.81-alpha.2",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -21,10 +21,8 @@
|
|
|
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",
|
|
27
24
|
"format": "prettier --config ../../.prettierrc.json 'src/**/*.ts' --write",
|
|
25
|
+
"specs": "node specs/generate.js && openapi-typescript specs/openapi.yaml --output src/definitions/openapi.ts",
|
|
28
26
|
"lint": "eslint --fix src/",
|
|
29
27
|
"lint:fix": "yarn run format && yarn run lint",
|
|
30
28
|
"initialise": "node scripts/initialise.js",
|
|
@@ -73,9 +71,9 @@
|
|
|
73
71
|
"license": "GPL-3.0",
|
|
74
72
|
"dependencies": {
|
|
75
73
|
"@apidevtools/swagger-parser": "^10.0.3",
|
|
76
|
-
"@budibase/backend-core": "^1.0.
|
|
77
|
-
"@budibase/client": "^1.0.
|
|
78
|
-
"@budibase/string-templates": "^1.0.
|
|
74
|
+
"@budibase/backend-core": "^1.0.81-alpha.2",
|
|
75
|
+
"@budibase/client": "^1.0.81-alpha.2",
|
|
76
|
+
"@budibase/string-templates": "^1.0.81-alpha.2",
|
|
79
77
|
"@bull-board/api": "^3.7.0",
|
|
80
78
|
"@bull-board/koa": "^3.7.0",
|
|
81
79
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -110,6 +108,7 @@
|
|
|
110
108
|
"koa-send": "5.0.0",
|
|
111
109
|
"koa-session": "5.12.0",
|
|
112
110
|
"koa-static": "5.0.0",
|
|
111
|
+
"koa2-ratelimit": "^1.1.0",
|
|
113
112
|
"lodash": "4.17.21",
|
|
114
113
|
"memorystream": "^0.3.1",
|
|
115
114
|
"mongodb": "3.6.3",
|
|
@@ -125,6 +124,7 @@
|
|
|
125
124
|
"pouchdb-all-dbs": "1.0.2",
|
|
126
125
|
"pouchdb-find": "^7.2.2",
|
|
127
126
|
"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,6 +150,7 @@
|
|
|
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",
|
|
153
154
|
"@typescript-eslint/parser": "4.28.0",
|
|
154
155
|
"apidoc": "^0.50.2",
|
|
155
156
|
"babel-jest": "^27.0.2",
|
|
@@ -157,12 +158,15 @@
|
|
|
157
158
|
"docker-compose": "^0.23.6",
|
|
158
159
|
"eslint": "^6.8.0",
|
|
159
160
|
"jest": "^27.0.5",
|
|
161
|
+
"jest-openapi": "^0.14.2",
|
|
160
162
|
"nodemon": "^2.0.4",
|
|
161
163
|
"openapi-types": "^9.3.1",
|
|
164
|
+
"openapi-typescript": "^5.2.0",
|
|
162
165
|
"path-to-regexp": "^6.2.0",
|
|
163
166
|
"prettier": "^2.3.1",
|
|
164
167
|
"rimraf": "^3.0.2",
|
|
165
168
|
"supertest": "^4.0.2",
|
|
169
|
+
"swagger-jsdoc": "^6.1.0",
|
|
166
170
|
"ts-jest": "^27.0.3",
|
|
167
171
|
"ts-node": "^10.0.0",
|
|
168
172
|
"typescript": "^4.3.5",
|
|
@@ -171,5 +175,5 @@
|
|
|
171
175
|
"optionalDependencies": {
|
|
172
176
|
"oracledb": "^5.3.0"
|
|
173
177
|
},
|
|
174
|
-
"gitHead": "
|
|
178
|
+
"gitHead": "31614e942ba70ccb4576e2d487e75c646d53cb84"
|
|
175
179
|
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
USE master;
|
|
2
|
-
|
|
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
|
+
|
|
3
8
|
IF OBJECT_ID ('dbo.products', 'U') IS NOT NULL
|
|
4
9
|
DROP TABLE products;
|
|
5
10
|
GO
|
|
@@ -61,3 +66,15 @@ VALUES ('Bob', '30'),
|
|
|
61
66
|
('Bobert', '99'),
|
|
62
67
|
('Jan', '22'),
|
|
63
68
|
('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 `xepdb1`
|
|
12
12
|
- The default password is configured in the compose file as `oracle`
|
|
13
|
-
- The `system
|
|
13
|
+
- The `system` and `pdbadmin` users share this password
|
|
14
14
|
|
|
15
15
|
## Instant Client
|
|
16
16
|
|
|
@@ -1,11 +1,14 @@
|
|
|
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');
|
|
3
5
|
CREATE TABLE Persons (
|
|
4
6
|
PersonID SERIAL PRIMARY KEY,
|
|
5
7
|
LastName varchar(255),
|
|
6
8
|
FirstName varchar(255),
|
|
7
9
|
Address varchar(255),
|
|
8
|
-
City varchar(255) DEFAULT 'Belfast'
|
|
10
|
+
City varchar(255) DEFAULT 'Belfast',
|
|
11
|
+
Type person_job
|
|
9
12
|
);
|
|
10
13
|
CREATE TABLE Tasks (
|
|
11
14
|
TaskID SERIAL PRIMARY KEY,
|
|
@@ -35,8 +38,12 @@ CREATE TABLE Products_Tasks (
|
|
|
35
38
|
REFERENCES Tasks(TaskID),
|
|
36
39
|
PRIMARY KEY (ProductID, TaskID)
|
|
37
40
|
);
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
CREATE TABLE test.table1 (
|
|
42
|
+
id SERIAL PRIMARY KEY,
|
|
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');
|
|
40
47
|
INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (1, 2, 'assembling', TRUE);
|
|
41
48
|
INSERT INTO Tasks (ExecutorID, QaID, TaskName, Completed) VALUES (2, 1, 'processing', FALSE);
|
|
42
49
|
INSERT INTO Products (ProductName) VALUES ('Computers');
|
|
@@ -46,3 +53,4 @@ INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (1, 1);
|
|
|
46
53
|
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (2, 1);
|
|
47
54
|
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (3, 1);
|
|
48
55
|
INSERT INTO Products_Tasks (ProductID, TaskID) VALUES (1, 2);
|
|
56
|
+
INSERT INTO test.table1 (Name) VALUES ('Test');
|
package/scripts/likeCypress.ts
CHANGED
|
@@ -2,14 +2,13 @@
|
|
|
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
|
+
import path from "path"
|
|
6
6
|
const tmpdir = path.join(require("os").tmpdir(), ".budibase")
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
const WORKER_PORT = "
|
|
8
|
+
const SERVER_PORT = "4100"
|
|
9
|
+
const WORKER_PORT = "4200"
|
|
10
10
|
|
|
11
11
|
// @ts-ignore
|
|
12
|
-
process.env.PORT = MAIN_PORT
|
|
13
12
|
process.env.BUDIBASE_API_KEY = "6BE826CB-6B30-4AEC-8777-2E90464633DE"
|
|
14
13
|
process.env.NODE_ENV = "cypress"
|
|
15
14
|
process.env.ENABLE_ANALYTICS = "false"
|
|
@@ -27,7 +26,11 @@ process.env.ALLOW_DEV_AUTOMATIONS = "1"
|
|
|
27
26
|
|
|
28
27
|
// don't make this a variable or top level require
|
|
29
28
|
// it will cause environment module to be loaded prematurely
|
|
30
|
-
|
|
29
|
+
|
|
30
|
+
// override the port with the worker port temporarily
|
|
31
31
|
process.env.PORT = WORKER_PORT
|
|
32
32
|
const worker = require("../../worker/src/index")
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
// override the port with the server port
|
|
35
|
+
process.env.PORT = SERVER_PORT
|
|
36
|
+
const server = require("../src/app")
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const swaggerJsdoc = require("swagger-jsdoc")
|
|
2
|
+
const { join } = require("path")
|
|
3
|
+
const { writeFileSync } = require("fs")
|
|
4
|
+
const { examples, schemas } = require("./resources")
|
|
5
|
+
const parameters = require("./parameters")
|
|
6
|
+
const security = require("./security")
|
|
7
|
+
|
|
8
|
+
const VARIABLES = {}
|
|
9
|
+
|
|
10
|
+
const options = {
|
|
11
|
+
definition: {
|
|
12
|
+
openapi: "3.0.0",
|
|
13
|
+
info: {
|
|
14
|
+
title: "Budibase API",
|
|
15
|
+
description: "The public API for Budibase apps and its services.",
|
|
16
|
+
version: "1.0.0",
|
|
17
|
+
},
|
|
18
|
+
servers: [
|
|
19
|
+
{
|
|
20
|
+
url: "https://budibase.app/api/public/v1",
|
|
21
|
+
description: "Budibase Cloud API",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
url: "{protocol}://{hostname}/api/public/v1",
|
|
25
|
+
description: "Budibase self hosted API",
|
|
26
|
+
variables: {
|
|
27
|
+
protocol: {
|
|
28
|
+
default: "http",
|
|
29
|
+
description:
|
|
30
|
+
"Whether HTTP or HTTPS should be used to communicate with your Budibase instance.",
|
|
31
|
+
},
|
|
32
|
+
hostname: {
|
|
33
|
+
default: "localhost:10000",
|
|
34
|
+
description: "The URL of your Budibase instance.",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
components: {
|
|
40
|
+
parameters: {
|
|
41
|
+
...parameters,
|
|
42
|
+
},
|
|
43
|
+
examples: {
|
|
44
|
+
...examples,
|
|
45
|
+
},
|
|
46
|
+
securitySchemes: {
|
|
47
|
+
...security,
|
|
48
|
+
},
|
|
49
|
+
schemas: {
|
|
50
|
+
...schemas,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
security: [
|
|
54
|
+
{
|
|
55
|
+
ApiKeyAuth: [],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
format: ".json",
|
|
60
|
+
apis: [join(__dirname, "..", "src", "api", "routes", "public", "*.ts")],
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function writeFile(output, filename) {
|
|
64
|
+
try {
|
|
65
|
+
const path = join(__dirname, filename)
|
|
66
|
+
let spec = output
|
|
67
|
+
if (filename.endsWith("json")) {
|
|
68
|
+
spec = JSON.stringify(output, null, 2)
|
|
69
|
+
}
|
|
70
|
+
// input the static variables
|
|
71
|
+
for (let [key, replacement] of Object.entries(VARIABLES)) {
|
|
72
|
+
spec = spec.replace(new RegExp(`{${key}}`, "g"), replacement)
|
|
73
|
+
}
|
|
74
|
+
writeFileSync(path, spec)
|
|
75
|
+
console.log(`Wrote spec to ${path}`)
|
|
76
|
+
return path
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error(err)
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function run() {
|
|
83
|
+
const outputJSON = swaggerJsdoc(options)
|
|
84
|
+
options.format = ".yaml"
|
|
85
|
+
const outputYAML = swaggerJsdoc(options)
|
|
86
|
+
writeFile(outputJSON, "openapi.json")
|
|
87
|
+
return writeFile(outputYAML, "openapi.yaml")
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (require.main === module) {
|
|
91
|
+
run()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
module.exports = run
|