@budibase/server 1.0.79-alpha.7 → 1.0.79
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__/mysql2/promise.ts +17 -0
- package/__mocks__/node-fetch.ts +0 -1
- package/builder/assets/{index.c57242d4.css → index.c8d1e8f0.css} +2 -2
- package/builder/assets/index.f28c5d54.js +1352 -0
- package/builder/assets/{vendor.6b00a24f.js → vendor.20f80cec.js} +216 -190
- package/builder/index.html +3 -3
- package/coverage/clover.xml +2229 -2277
- package/coverage/coverage-final.json +136 -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 +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 +64 -79
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
- package/coverage/lcov-report/middleware/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 +1 -1
- package/coverage/lcov-report/threads/index.js.html +10 -10
- package/coverage/lcov-report/threads/query.js.html +1 -1
- 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 +3039 -3115
- 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/integrations/mysql.js +81 -65
- package/dist/integrations/utils.js +1 -1
- package/dist/package.json +4 -8
- package/dist/tests/utilities/TestConfiguration.js +8 -25
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/workerRequests.js +15 -50
- package/package.json +5 -9
- package/scripts/integrations/postgres/init.sql +3 -5
- package/scripts/likeCypress.ts +6 -9
- package/src/api/controllers/application.js +0 -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/integrations/mysql.ts +92 -85
- package/src/integrations/tests/mysql.spec.js +4 -4
- package/src/integrations/utils.ts +1 -1
- package/src/tests/utilities/TestConfiguration.js +2 -23
- package/src/utilities/workerRequests.js +16 -65
- package/builder/assets/index.ef62c13b.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 -68
- 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 -83
- package/specs/openapi.json +0 -2222
- package/specs/openapi.yaml +0 -1530
- 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 -82
- 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
package/src/api/routes/table.js
CHANGED
|
@@ -7,10 +7,25 @@ const {
|
|
|
7
7
|
PermissionLevels,
|
|
8
8
|
PermissionTypes,
|
|
9
9
|
} = require("@budibase/backend-core/permissions")
|
|
10
|
-
const
|
|
10
|
+
const joiValidator = require("../../middleware/joi-validator")
|
|
11
|
+
const Joi = require("joi")
|
|
11
12
|
|
|
12
13
|
const router = Router()
|
|
13
14
|
|
|
15
|
+
function generateSaveValidator() {
|
|
16
|
+
// prettier-ignore
|
|
17
|
+
return joiValidator.body(Joi.object({
|
|
18
|
+
_id: Joi.string(),
|
|
19
|
+
_rev: Joi.string(),
|
|
20
|
+
type: Joi.string().valid("table", "internal", "external"),
|
|
21
|
+
primaryDisplay: Joi.string(),
|
|
22
|
+
schema: Joi.object().required(),
|
|
23
|
+
name: Joi.string().required(),
|
|
24
|
+
views: Joi.object(),
|
|
25
|
+
dataImport: Joi.object(),
|
|
26
|
+
}).unknown(true))
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
router
|
|
15
30
|
/**
|
|
16
31
|
* @api {get} /api/tables Fetch all tables
|
|
@@ -38,8 +53,8 @@ router
|
|
|
38
53
|
* @apiSuccess {object[]} body The response body will be the table that was found.
|
|
39
54
|
*/
|
|
40
55
|
.get(
|
|
41
|
-
"/api/tables/:
|
|
42
|
-
paramResource("
|
|
56
|
+
"/api/tables/:id",
|
|
57
|
+
paramResource("id"),
|
|
43
58
|
authorized(PermissionTypes.TABLE, PermissionLevels.READ),
|
|
44
59
|
tableController.find
|
|
45
60
|
)
|
|
@@ -121,7 +136,7 @@ router
|
|
|
121
136
|
// allows control over updating a table
|
|
122
137
|
bodyResource("_id"),
|
|
123
138
|
authorized(BUILDER),
|
|
124
|
-
|
|
139
|
+
generateSaveValidator(),
|
|
125
140
|
tableController.save
|
|
126
141
|
)
|
|
127
142
|
/**
|
|
@@ -2,18 +2,6 @@ const TestConfig = require("../../../../tests/utilities/TestConfiguration")
|
|
|
2
2
|
const structures = require("../../../../tests/utilities/structures")
|
|
3
3
|
const env = require("../../../../environment")
|
|
4
4
|
|
|
5
|
-
function user() {
|
|
6
|
-
return {
|
|
7
|
-
_id: "user",
|
|
8
|
-
_rev: "rev",
|
|
9
|
-
createdAt: Date.now(),
|
|
10
|
-
email: "test@test.com",
|
|
11
|
-
roles: {},
|
|
12
|
-
tenantId: "default",
|
|
13
|
-
status: "active",
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
5
|
jest.mock("../../../../utilities/workerRequests", () => ({
|
|
18
6
|
getGlobalUsers: jest.fn(() => {
|
|
19
7
|
return {
|
|
@@ -25,18 +13,6 @@ jest.mock("../../../../utilities/workerRequests", () => ({
|
|
|
25
13
|
_id: "us_uuid1",
|
|
26
14
|
}
|
|
27
15
|
}),
|
|
28
|
-
allGlobalUsers: jest.fn(() => {
|
|
29
|
-
return [user()]
|
|
30
|
-
}),
|
|
31
|
-
readGlobalUser: jest.fn(() => {
|
|
32
|
-
return user()
|
|
33
|
-
}),
|
|
34
|
-
saveGlobalUser: jest.fn(() => {
|
|
35
|
-
return { _id: "user", _rev: "rev" }
|
|
36
|
-
}),
|
|
37
|
-
deleteGlobalUser: jest.fn(() => {
|
|
38
|
-
return { message: "deleted user" }
|
|
39
|
-
}),
|
|
40
16
|
removeAppFromUserRoles: jest.fn(),
|
|
41
17
|
}))
|
|
42
18
|
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
const Router = require("@koa/router")
|
|
2
2
|
const controller = require("../controllers/webhook")
|
|
3
3
|
const authorized = require("../../middleware/authorized")
|
|
4
|
+
const joiValidator = require("../../middleware/joi-validator")
|
|
4
5
|
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
5
|
-
const
|
|
6
|
+
const Joi = require("joi")
|
|
6
7
|
|
|
7
8
|
const router = Router()
|
|
8
9
|
|
|
10
|
+
function generateSaveValidator() {
|
|
11
|
+
// prettier-ignore
|
|
12
|
+
return joiValidator.body(Joi.object({
|
|
13
|
+
live: Joi.bool(),
|
|
14
|
+
_id: Joi.string().optional(),
|
|
15
|
+
_rev: Joi.string().optional(),
|
|
16
|
+
name: Joi.string().required(),
|
|
17
|
+
bodySchema: Joi.object().optional(),
|
|
18
|
+
action: Joi.object({
|
|
19
|
+
type: Joi.string().required().valid(controller.WebhookType.AUTOMATION),
|
|
20
|
+
target: Joi.string().required(),
|
|
21
|
+
}).required(),
|
|
22
|
+
}).unknown(true))
|
|
23
|
+
}
|
|
24
|
+
|
|
9
25
|
router
|
|
10
26
|
.get("/api/webhooks", authorized(BUILDER), controller.fetch)
|
|
11
27
|
.put(
|
|
12
28
|
"/api/webhooks",
|
|
13
29
|
authorized(BUILDER),
|
|
14
|
-
|
|
30
|
+
generateSaveValidator(),
|
|
15
31
|
controller.save
|
|
16
32
|
)
|
|
17
33
|
.delete("/api/webhooks/:id/:rev", authorized(BUILDER), controller.destroy)
|
|
@@ -16,11 +16,10 @@ exports.FilterConditions = FilterConditions
|
|
|
16
16
|
exports.PrettyFilterConditions = PrettyFilterConditions
|
|
17
17
|
|
|
18
18
|
exports.definition = {
|
|
19
|
-
name: "
|
|
19
|
+
name: "Filter",
|
|
20
20
|
tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
|
|
21
21
|
icon: "Branch2",
|
|
22
|
-
description:
|
|
23
|
-
"Conditionally halt automations which do not meet certain conditions",
|
|
22
|
+
description: "Filter any automations which do not meet certain conditions",
|
|
24
23
|
type: "LOGIC",
|
|
25
24
|
internal: true,
|
|
26
25
|
stepId: "FILTER",
|
package/src/automations/utils.js
CHANGED
|
@@ -5,7 +5,7 @@ const CouchDB = require("../db")
|
|
|
5
5
|
const { queue } = require("./bullboard")
|
|
6
6
|
const newid = require("../db/newid")
|
|
7
7
|
const { updateEntityMetadata } = require("../utilities")
|
|
8
|
-
const { MetadataTypes
|
|
8
|
+
const { MetadataTypes } = require("../constants")
|
|
9
9
|
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
10
10
|
const { cloneDeep } = require("lodash/fp")
|
|
11
11
|
const { getAppDB, getAppId } = require("@budibase/backend-core/context")
|
|
@@ -159,7 +159,7 @@ exports.checkForWebhooks = async ({ oldAuto, newAuto }) => {
|
|
|
159
159
|
request: {
|
|
160
160
|
body: new webhooks.Webhook(
|
|
161
161
|
"Automation webhook",
|
|
162
|
-
WebhookType.AUTOMATION,
|
|
162
|
+
webhooks.WebhookType.AUTOMATION,
|
|
163
163
|
newAuto._id
|
|
164
164
|
),
|
|
165
165
|
},
|
package/src/constants/index.js
CHANGED
package/src/db/utils.js
CHANGED
|
@@ -146,18 +146,6 @@ exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
|
|
|
146
146
|
return getDocParams(DocumentTypes.ROW, endOfKey, otherProps)
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
/**
|
|
150
|
-
* Given a row ID this will find the table ID within it (only works for internal tables).
|
|
151
|
-
* @param {string} rowId The ID of the row.
|
|
152
|
-
* @returns {string} The table ID.
|
|
153
|
-
*/
|
|
154
|
-
exports.getTableIDFromRowID = rowId => {
|
|
155
|
-
const components = rowId
|
|
156
|
-
.split(DocumentTypes.TABLE + SEPARATOR)[1]
|
|
157
|
-
.split(SEPARATOR)
|
|
158
|
-
return `${DocumentTypes.TABLE}${SEPARATOR}${components[0]}`
|
|
159
|
-
}
|
|
160
|
-
|
|
161
149
|
/**
|
|
162
150
|
* Gets a new row ID for the specified table.
|
|
163
151
|
* @param {string} tableId The table which the row is being created for.
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
import { DatasourcePlus } from "./base/datasourcePlus"
|
|
17
17
|
|
|
18
18
|
module MySQLModule {
|
|
19
|
-
const mysql = require("mysql2")
|
|
19
|
+
const mysql = require("mysql2/promise")
|
|
20
20
|
const Sql = require("./base/sql")
|
|
21
21
|
|
|
22
22
|
interface MySQLConfig {
|
|
@@ -29,7 +29,7 @@ module MySQLModule {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const SCHEMA: Integration = {
|
|
32
|
-
docs: "https://github.com/
|
|
32
|
+
docs: "https://github.com/sidorares/node-mysql2",
|
|
33
33
|
plus: true,
|
|
34
34
|
friendlyName: "MySQL",
|
|
35
35
|
description:
|
|
@@ -80,36 +80,9 @@ module MySQLModule {
|
|
|
80
80
|
},
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
function internalQuery(
|
|
84
|
-
client: any,
|
|
85
|
-
query: SqlQuery,
|
|
86
|
-
connect: boolean = true
|
|
87
|
-
): Promise<any[] | any> {
|
|
88
|
-
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
89
|
-
return new Promise((resolve, reject) => {
|
|
90
|
-
if (connect) {
|
|
91
|
-
client.connect()
|
|
92
|
-
}
|
|
93
|
-
return client.query(
|
|
94
|
-
query.sql,
|
|
95
|
-
query.bindings || {},
|
|
96
|
-
(error: any, results: object[]) => {
|
|
97
|
-
if (error) {
|
|
98
|
-
reject(error)
|
|
99
|
-
} else {
|
|
100
|
-
resolve(results)
|
|
101
|
-
}
|
|
102
|
-
if (connect) {
|
|
103
|
-
client.end()
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
)
|
|
107
|
-
})
|
|
108
|
-
}
|
|
109
|
-
|
|
110
83
|
class MySQLIntegration extends Sql implements DatasourcePlus {
|
|
111
84
|
private config: MySQLConfig
|
|
112
|
-
private
|
|
85
|
+
private client: any
|
|
113
86
|
public tables: Record<string, Table> = {}
|
|
114
87
|
public schemaErrors: Record<string, string> = {}
|
|
115
88
|
|
|
@@ -119,93 +92,127 @@ module MySQLModule {
|
|
|
119
92
|
if (config.ssl && Object.keys(config.ssl).length === 0) {
|
|
120
93
|
delete config.ssl
|
|
121
94
|
}
|
|
122
|
-
this.
|
|
95
|
+
this.config = config
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async connect() {
|
|
99
|
+
this.client = await mysql.createConnection(this.config)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async disconnect() {
|
|
103
|
+
await this.client.end()
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async internalQuery(
|
|
107
|
+
query: SqlQuery,
|
|
108
|
+
connect: boolean = true
|
|
109
|
+
): Promise<any[] | any> {
|
|
110
|
+
try {
|
|
111
|
+
if (connect) {
|
|
112
|
+
await this.connect()
|
|
113
|
+
}
|
|
114
|
+
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
115
|
+
const response = await this.client.query(
|
|
116
|
+
query.sql,
|
|
117
|
+
query.bindings || []
|
|
118
|
+
)
|
|
119
|
+
return response[0]
|
|
120
|
+
} finally {
|
|
121
|
+
if (connect) {
|
|
122
|
+
await this.disconnect()
|
|
123
|
+
}
|
|
124
|
+
}
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
async buildSchema(datasourceId: string, entities: Record<string, Table>) {
|
|
126
128
|
const tables: { [key: string]: Table } = {}
|
|
127
129
|
const database = this.config.database
|
|
128
|
-
this.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.
|
|
133
|
-
|
|
134
|
-
false
|
|
135
|
-
)
|
|
136
|
-
const tableNames = tablesResp.map(
|
|
137
|
-
(obj: any) =>
|
|
138
|
-
obj[`Tables_in_${database}`] ||
|
|
139
|
-
obj[`Tables_in_${database.toLowerCase()}`]
|
|
140
|
-
)
|
|
141
|
-
for (let tableName of tableNames) {
|
|
142
|
-
const primaryKeys = []
|
|
143
|
-
const schema: TableSchema = {}
|
|
144
|
-
const descResp = await internalQuery(
|
|
145
|
-
this.client,
|
|
146
|
-
{ sql: `DESCRIBE \`${tableName}\`;` },
|
|
130
|
+
await this.connect()
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
// get the tables first
|
|
134
|
+
const tablesResp = await this.internalQuery(
|
|
135
|
+
{ sql: "SHOW TABLES;" },
|
|
147
136
|
false
|
|
148
137
|
)
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
138
|
+
const tableNames = tablesResp.map(
|
|
139
|
+
(obj: any) =>
|
|
140
|
+
obj[`Tables_in_${database}`] ||
|
|
141
|
+
obj[`Tables_in_${database.toLowerCase()}`]
|
|
142
|
+
)
|
|
143
|
+
for (let tableName of tableNames) {
|
|
144
|
+
const primaryKeys = []
|
|
145
|
+
const schema: TableSchema = {}
|
|
146
|
+
const descResp = await this.internalQuery(
|
|
147
|
+
{ sql: `DESCRIBE \`${tableName}\`;` },
|
|
148
|
+
false
|
|
149
|
+
)
|
|
150
|
+
for (let column of descResp) {
|
|
151
|
+
const columnName = column.Field
|
|
152
|
+
if (
|
|
153
|
+
column.Key === "PRI" &&
|
|
154
|
+
primaryKeys.indexOf(column.Key) === -1
|
|
155
|
+
) {
|
|
156
|
+
primaryKeys.push(columnName)
|
|
157
|
+
}
|
|
158
|
+
const constraints = {
|
|
159
|
+
presence: column.Null !== "YES",
|
|
160
|
+
}
|
|
161
|
+
const isAuto: boolean =
|
|
162
|
+
typeof column.Extra === "string" &&
|
|
163
|
+
(column.Extra === "auto_increment" ||
|
|
164
|
+
column.Extra.toLowerCase().includes("generated"))
|
|
165
|
+
schema[columnName] = {
|
|
166
|
+
name: columnName,
|
|
167
|
+
autocolumn: isAuto,
|
|
168
|
+
type: convertSqlType(column.Type),
|
|
169
|
+
constraints,
|
|
170
|
+
}
|
|
166
171
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
if (!tables[tableName]) {
|
|
173
|
+
tables[tableName] = {
|
|
174
|
+
_id: buildExternalTableId(datasourceId, tableName),
|
|
175
|
+
primary: primaryKeys,
|
|
176
|
+
name: tableName,
|
|
177
|
+
schema,
|
|
178
|
+
}
|
|
174
179
|
}
|
|
175
180
|
}
|
|
181
|
+
} finally {
|
|
182
|
+
await this.disconnect()
|
|
176
183
|
}
|
|
177
|
-
|
|
178
|
-
this.client.end()
|
|
179
184
|
const final = finaliseExternalTables(tables, entities)
|
|
180
185
|
this.tables = final.tables
|
|
181
186
|
this.schemaErrors = final.errors
|
|
182
187
|
}
|
|
183
188
|
|
|
184
189
|
async create(query: SqlQuery | string) {
|
|
185
|
-
const results = await internalQuery(
|
|
190
|
+
const results = await this.internalQuery(getSqlQuery(query))
|
|
186
191
|
return results.length ? results : [{ created: true }]
|
|
187
192
|
}
|
|
188
193
|
|
|
189
194
|
async read(query: SqlQuery | string) {
|
|
190
|
-
return internalQuery(
|
|
195
|
+
return this.internalQuery(getSqlQuery(query))
|
|
191
196
|
}
|
|
192
197
|
|
|
193
198
|
async update(query: SqlQuery | string) {
|
|
194
|
-
const results = await internalQuery(
|
|
199
|
+
const results = await this.internalQuery(getSqlQuery(query))
|
|
195
200
|
return results.length ? results : [{ updated: true }]
|
|
196
201
|
}
|
|
197
202
|
|
|
198
203
|
async delete(query: SqlQuery | string) {
|
|
199
|
-
const results = await internalQuery(
|
|
204
|
+
const results = await this.internalQuery(getSqlQuery(query))
|
|
200
205
|
return results.length ? results : [{ deleted: true }]
|
|
201
206
|
}
|
|
202
207
|
|
|
203
208
|
async query(json: QueryJson) {
|
|
204
|
-
this.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
await this.connect()
|
|
210
|
+
try {
|
|
211
|
+
const queryFn = (query: any) => this.internalQuery(query, false)
|
|
212
|
+
return await this.queryWithReturning(json, queryFn)
|
|
213
|
+
} finally {
|
|
214
|
+
await this.disconnect()
|
|
215
|
+
}
|
|
209
216
|
}
|
|
210
217
|
}
|
|
211
218
|
|
|
@@ -19,7 +19,7 @@ describe("MySQL Integration", () => {
|
|
|
19
19
|
await config.integration.create({
|
|
20
20
|
sql
|
|
21
21
|
})
|
|
22
|
-
expect(config.integration.client.query).toHaveBeenCalledWith(sql,
|
|
22
|
+
expect(config.integration.client.query).toHaveBeenCalledWith(sql, [])
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
it("calls the read method with the correct params", async () => {
|
|
@@ -27,7 +27,7 @@ describe("MySQL Integration", () => {
|
|
|
27
27
|
await config.integration.read({
|
|
28
28
|
sql
|
|
29
29
|
})
|
|
30
|
-
expect(config.integration.client.query).toHaveBeenCalledWith(sql,
|
|
30
|
+
expect(config.integration.client.query).toHaveBeenCalledWith(sql, [])
|
|
31
31
|
})
|
|
32
32
|
|
|
33
33
|
it("calls the update method with the correct params", async () => {
|
|
@@ -35,7 +35,7 @@ describe("MySQL Integration", () => {
|
|
|
35
35
|
await config.integration.update({
|
|
36
36
|
sql
|
|
37
37
|
})
|
|
38
|
-
expect(config.integration.client.query).toHaveBeenCalledWith(sql,
|
|
38
|
+
expect(config.integration.client.query).toHaveBeenCalledWith(sql, [])
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
it("calls the delete method with the correct params", async () => {
|
|
@@ -43,7 +43,7 @@ describe("MySQL Integration", () => {
|
|
|
43
43
|
await config.integration.delete({
|
|
44
44
|
sql
|
|
45
45
|
})
|
|
46
|
-
expect(config.integration.client.query).toHaveBeenCalledWith(sql,
|
|
46
|
+
expect(config.integration.client.query).toHaveBeenCalledWith(sql, [])
|
|
47
47
|
})
|
|
48
48
|
|
|
49
49
|
describe("no rows returned", () => {
|
|
@@ -25,8 +25,6 @@ const { createASession } = require("@budibase/backend-core/sessions")
|
|
|
25
25
|
const { user: userCache } = require("@budibase/backend-core/cache")
|
|
26
26
|
const newid = require("../../db/newid")
|
|
27
27
|
const context = require("@budibase/backend-core/context")
|
|
28
|
-
const { generateDevInfoID, SEPARATOR } = require("@budibase/backend-core/db")
|
|
29
|
-
const { encrypt } = require("@budibase/backend-core/encryption")
|
|
30
28
|
|
|
31
29
|
const GLOBAL_USER_ID = "us_uuid1"
|
|
32
30
|
const EMAIL = "babs@babs.com"
|
|
@@ -49,10 +47,6 @@ class TestConfiguration {
|
|
|
49
47
|
return this.request
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
getApp() {
|
|
53
|
-
return this.app
|
|
54
|
-
}
|
|
55
|
-
|
|
56
50
|
getAppId() {
|
|
57
51
|
return this.appId
|
|
58
52
|
}
|
|
@@ -89,20 +83,6 @@ class TestConfiguration {
|
|
|
89
83
|
}
|
|
90
84
|
}
|
|
91
85
|
|
|
92
|
-
async generateApiKey(userId = GLOBAL_USER_ID) {
|
|
93
|
-
const db = getGlobalDB(TENANT_ID)
|
|
94
|
-
const id = generateDevInfoID(userId)
|
|
95
|
-
let devInfo
|
|
96
|
-
try {
|
|
97
|
-
devInfo = await db.get(id)
|
|
98
|
-
} catch (err) {
|
|
99
|
-
devInfo = { _id: id, userId }
|
|
100
|
-
}
|
|
101
|
-
devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`)
|
|
102
|
-
await db.put(devInfo)
|
|
103
|
-
return devInfo.apiKey
|
|
104
|
-
}
|
|
105
|
-
|
|
106
86
|
async globalUser({
|
|
107
87
|
id = GLOBAL_USER_ID,
|
|
108
88
|
builder = true,
|
|
@@ -155,7 +135,7 @@ class TestConfiguration {
|
|
|
155
135
|
cleanup(this.allApps.map(app => app.appId))
|
|
156
136
|
}
|
|
157
137
|
|
|
158
|
-
defaultHeaders(
|
|
138
|
+
defaultHeaders() {
|
|
159
139
|
const auth = {
|
|
160
140
|
userId: GLOBAL_USER_ID,
|
|
161
141
|
sessionId: "sessionid",
|
|
@@ -174,7 +154,6 @@ class TestConfiguration {
|
|
|
174
154
|
`${Cookies.CurrentApp}=${appToken}`,
|
|
175
155
|
],
|
|
176
156
|
[Headers.CSRF_TOKEN]: CSRF_TOKEN,
|
|
177
|
-
...extras,
|
|
178
157
|
}
|
|
179
158
|
if (this.appId) {
|
|
180
159
|
headers[Headers.APP_ID] = this.appId
|
|
@@ -247,7 +226,7 @@ class TestConfiguration {
|
|
|
247
226
|
|
|
248
227
|
async getTable(tableId = null) {
|
|
249
228
|
tableId = tableId || this.table._id
|
|
250
|
-
return this._req(null, { tableId }, controllers.table.find)
|
|
229
|
+
return this._req(null, { id: tableId }, controllers.table.find)
|
|
251
230
|
}
|
|
252
231
|
|
|
253
232
|
async createLinkedTable(relationshipType = null, links = ["link"]) {
|
|
@@ -26,31 +26,11 @@ function request(ctx, request) {
|
|
|
26
26
|
delete request.body
|
|
27
27
|
}
|
|
28
28
|
if (ctx && ctx.headers) {
|
|
29
|
-
request.headers = ctx.headers
|
|
29
|
+
request.headers.cookie = ctx.headers.cookie
|
|
30
30
|
}
|
|
31
31
|
return request
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
async function checkResponse(response, errorMsg, { ctx } = {}) {
|
|
35
|
-
if (response.status !== 200) {
|
|
36
|
-
let error
|
|
37
|
-
try {
|
|
38
|
-
error = await response.json()
|
|
39
|
-
} catch (err) {
|
|
40
|
-
error = await response.text()
|
|
41
|
-
}
|
|
42
|
-
const msg = `Unable to ${errorMsg} - ${
|
|
43
|
-
error.message ? error.message : error
|
|
44
|
-
}`
|
|
45
|
-
if (ctx) {
|
|
46
|
-
ctx.throw(400, msg)
|
|
47
|
-
} else {
|
|
48
|
-
throw msg
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return response.json()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
34
|
exports.request = request
|
|
55
35
|
|
|
56
36
|
// have to pass in the tenant ID as this could be coming from an automation
|
|
@@ -70,17 +50,25 @@ exports.sendSmtpEmail = async (to, from, subject, contents, automation) => {
|
|
|
70
50
|
},
|
|
71
51
|
})
|
|
72
52
|
)
|
|
73
|
-
|
|
53
|
+
|
|
54
|
+
if (response.status !== 200) {
|
|
55
|
+
const error = await response.text()
|
|
56
|
+
throw `Unable to send email - ${error}`
|
|
57
|
+
}
|
|
58
|
+
return response.json()
|
|
74
59
|
}
|
|
75
60
|
|
|
76
61
|
exports.getGlobalSelf = async (ctx, appId = null) => {
|
|
77
|
-
const endpoint = `/api/global/self`
|
|
62
|
+
const endpoint = `/api/global/users/self`
|
|
78
63
|
const response = await fetch(
|
|
79
64
|
checkSlashesInUrl(env.WORKER_URL + endpoint),
|
|
80
65
|
// we don't want to use API key when getting self
|
|
81
66
|
request(ctx, { method: "GET" })
|
|
82
67
|
)
|
|
83
|
-
|
|
68
|
+
if (response.status !== 200) {
|
|
69
|
+
ctx.throw(400, "Unable to get self globally.")
|
|
70
|
+
}
|
|
71
|
+
let json = await response.json()
|
|
84
72
|
if (appId) {
|
|
85
73
|
json = updateAppRole(json)
|
|
86
74
|
}
|
|
@@ -95,45 +83,8 @@ exports.removeAppFromUserRoles = async (ctx, appId) => {
|
|
|
95
83
|
method: "DELETE",
|
|
96
84
|
})
|
|
97
85
|
)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const response = await fetch(
|
|
103
|
-
checkSlashesInUrl(env.WORKER_URL + "/api/global/users"),
|
|
104
|
-
// we don't want to use API key when getting self
|
|
105
|
-
request(ctx, { method: "GET" })
|
|
106
|
-
)
|
|
107
|
-
return checkResponse(response, "get users", { ctx })
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
exports.saveGlobalUser = async ctx => {
|
|
111
|
-
const response = await fetch(
|
|
112
|
-
checkSlashesInUrl(env.WORKER_URL + "/api/global/users"),
|
|
113
|
-
// we don't want to use API key when getting self
|
|
114
|
-
request(ctx, { method: "POST", body: ctx.request.body })
|
|
115
|
-
)
|
|
116
|
-
return checkResponse(response, "save user", { ctx })
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
exports.deleteGlobalUser = async ctx => {
|
|
120
|
-
const response = await fetch(
|
|
121
|
-
checkSlashesInUrl(
|
|
122
|
-
env.WORKER_URL + `/api/global/users/${ctx.params.userId}`
|
|
123
|
-
),
|
|
124
|
-
// we don't want to use API key when getting self
|
|
125
|
-
request(ctx, { method: "DELETE" })
|
|
126
|
-
)
|
|
127
|
-
return checkResponse(response, "delete user", { ctx, body: ctx.request.body })
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
exports.readGlobalUser = async ctx => {
|
|
131
|
-
const response = await fetch(
|
|
132
|
-
checkSlashesInUrl(
|
|
133
|
-
env.WORKER_URL + `/api/global/users/${ctx.params.userId}`
|
|
134
|
-
),
|
|
135
|
-
// we don't want to use API key when getting self
|
|
136
|
-
request(ctx, { method: "GET" })
|
|
137
|
-
)
|
|
138
|
-
return checkResponse(response, "get user", { ctx })
|
|
86
|
+
if (response.status !== 200) {
|
|
87
|
+
throw "Unable to remove app role"
|
|
88
|
+
}
|
|
89
|
+
return response.json()
|
|
139
90
|
}
|