@budibase/server 1.0.80 → 1.0.81-alpha.0
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.57958259.js +1290 -0
- package/builder/assets/{index.c8d1e8f0.css → index.dd19c61c.css} +2 -2
- 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
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const { object } = require("./utils")
|
|
2
|
+
const Resource = require("./utils/Resource")
|
|
3
|
+
|
|
4
|
+
const user = {
|
|
5
|
+
_id: "us_693a73206518477283a8d5ae31103252",
|
|
6
|
+
email: "test@test.com",
|
|
7
|
+
roles: {
|
|
8
|
+
app_957b12f943d348faa61db7e18e088d0f: "BASIC",
|
|
9
|
+
},
|
|
10
|
+
builder: {
|
|
11
|
+
global: false,
|
|
12
|
+
},
|
|
13
|
+
admin: {
|
|
14
|
+
global: true,
|
|
15
|
+
},
|
|
16
|
+
tenantId: "default",
|
|
17
|
+
status: "active",
|
|
18
|
+
budibaseAccess: true,
|
|
19
|
+
csrfToken: "9c70291d-7137-48f9-9166-99ab5473a3d4",
|
|
20
|
+
userId: "us_693a73206518477283a8d5ae31103252",
|
|
21
|
+
roleId: "ADMIN",
|
|
22
|
+
role: {
|
|
23
|
+
_id: "ADMIN",
|
|
24
|
+
name: "Admin",
|
|
25
|
+
permissionId: "admin",
|
|
26
|
+
inherits: "POWER",
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const userSchema = object(
|
|
31
|
+
{
|
|
32
|
+
email: {
|
|
33
|
+
description: "The email address of the user, this must be unique.",
|
|
34
|
+
type: "string",
|
|
35
|
+
},
|
|
36
|
+
password: {
|
|
37
|
+
description:
|
|
38
|
+
"The password of the user if using password based login - this will never be returned. This can be" +
|
|
39
|
+
" left out of subsequent requests (updates) and will be enriched back into the user structure.",
|
|
40
|
+
type: "string",
|
|
41
|
+
},
|
|
42
|
+
status: {
|
|
43
|
+
description: "The status of the user, if they are active.",
|
|
44
|
+
type: "string",
|
|
45
|
+
enum: ["active"],
|
|
46
|
+
},
|
|
47
|
+
firstName: {
|
|
48
|
+
description: "The first name of the user",
|
|
49
|
+
type: "string",
|
|
50
|
+
},
|
|
51
|
+
lastName: {
|
|
52
|
+
description: "The last name of the user",
|
|
53
|
+
type: "string",
|
|
54
|
+
},
|
|
55
|
+
forceResetPassword: {
|
|
56
|
+
description:
|
|
57
|
+
"If set to true forces the user to reset their password on first login.",
|
|
58
|
+
type: "boolean",
|
|
59
|
+
},
|
|
60
|
+
builder: {
|
|
61
|
+
description: "Describes if the user is a builder user or not.",
|
|
62
|
+
type: "object",
|
|
63
|
+
properties: {
|
|
64
|
+
global: {
|
|
65
|
+
description:
|
|
66
|
+
"If set to true the user will be able to build any app in the system.",
|
|
67
|
+
type: "boolean",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
admin: {
|
|
72
|
+
description: "Describes if the user is an admin user or not.",
|
|
73
|
+
type: "object",
|
|
74
|
+
properties: {
|
|
75
|
+
global: {
|
|
76
|
+
description:
|
|
77
|
+
"If set to true the user will be able to administrate the system.",
|
|
78
|
+
type: "boolean",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
roles: {
|
|
83
|
+
description:
|
|
84
|
+
"Contains the roles of the user per app (assuming they are not a builder user).",
|
|
85
|
+
type: "object",
|
|
86
|
+
additionalProperties: {
|
|
87
|
+
type: "string",
|
|
88
|
+
description:
|
|
89
|
+
"A map of app ID (production app ID, minus the _dev component) to a role ID, e.g. ADMIN.",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{ required: ["email", "roles"] }
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
const userOutputSchema = {
|
|
97
|
+
...userSchema,
|
|
98
|
+
properties: {
|
|
99
|
+
...userSchema.properties,
|
|
100
|
+
_id: {
|
|
101
|
+
description: "The ID of the user.",
|
|
102
|
+
type: "string",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
required: [...userSchema.required, "_id"],
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
module.exports = new Resource()
|
|
109
|
+
.setExamples({
|
|
110
|
+
user: {
|
|
111
|
+
value: {
|
|
112
|
+
data: user,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
users: {
|
|
116
|
+
value: {
|
|
117
|
+
data: [user],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
})
|
|
121
|
+
.setSchemas({
|
|
122
|
+
user: userSchema,
|
|
123
|
+
userOutput: object({
|
|
124
|
+
data: userOutputSchema,
|
|
125
|
+
}),
|
|
126
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class Resource {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.examples = {}
|
|
4
|
+
this.schemas = {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
setExamples(examples) {
|
|
8
|
+
this.examples = examples
|
|
9
|
+
return this
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
setSchemas(schemas) {
|
|
13
|
+
this.schemas = schemas
|
|
14
|
+
return this
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getExamples() {
|
|
18
|
+
return this.examples
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getSchemas() {
|
|
22
|
+
return this.schemas
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = Resource
|
|
@@ -263,6 +263,7 @@ exports.create = async ctx => {
|
|
|
263
263
|
tenantId: getTenantId(),
|
|
264
264
|
updatedAt: new Date().toISOString(),
|
|
265
265
|
createdAt: new Date().toISOString(),
|
|
266
|
+
status: AppStatus.DEV,
|
|
266
267
|
}
|
|
267
268
|
const response = await db.put(newApplication, { force: true })
|
|
268
269
|
newApplication._rev = response.rev
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const { getAllApps } = require("@budibase/backend-core/db")
|
|
2
|
+
const { updateAppId } = require("@budibase/backend-core/context")
|
|
3
|
+
import { search as stringSearch } from "./utils"
|
|
4
|
+
import { default as controller } from "../application"
|
|
5
|
+
import { Application } from "../../../definitions/common"
|
|
6
|
+
|
|
7
|
+
function fixAppID(app: Application, params: any) {
|
|
8
|
+
if (!params) {
|
|
9
|
+
return app
|
|
10
|
+
}
|
|
11
|
+
if (!app._id && params.appId) {
|
|
12
|
+
app._id = params.appId
|
|
13
|
+
}
|
|
14
|
+
return app
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function setResponseApp(ctx: any) {
|
|
18
|
+
if (ctx.body && ctx.body.appId && (!ctx.params || !ctx.params.appId)) {
|
|
19
|
+
ctx.params = { appId: ctx.body.appId }
|
|
20
|
+
}
|
|
21
|
+
await controller.fetchAppPackage(ctx)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function search(ctx: any, next: any) {
|
|
25
|
+
const { name } = ctx.request.body
|
|
26
|
+
const apps = await getAllApps({ all: true })
|
|
27
|
+
ctx.body = stringSearch(apps, name)
|
|
28
|
+
await next()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function create(ctx: any, next: any) {
|
|
32
|
+
if (!ctx.request.body || !ctx.request.body.useTemplate) {
|
|
33
|
+
ctx.request.body = {
|
|
34
|
+
useTemplate: false,
|
|
35
|
+
...ctx.request.body,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
await controller.create(ctx)
|
|
39
|
+
await setResponseApp(ctx)
|
|
40
|
+
await next()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function read(ctx: any, next: any) {
|
|
44
|
+
updateAppId(ctx.params.appId)
|
|
45
|
+
await setResponseApp(ctx)
|
|
46
|
+
await next()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function update(ctx: any, next: any) {
|
|
50
|
+
ctx.request.body = fixAppID(ctx.request.body, ctx.params)
|
|
51
|
+
updateAppId(ctx.params.appId)
|
|
52
|
+
await controller.update(ctx)
|
|
53
|
+
await setResponseApp(ctx)
|
|
54
|
+
await next()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function destroy(ctx: any, next: any) {
|
|
58
|
+
updateAppId(ctx.params.appId)
|
|
59
|
+
// get the app before deleting it
|
|
60
|
+
await setResponseApp(ctx)
|
|
61
|
+
const body = ctx.body
|
|
62
|
+
await controller.delete(ctx)
|
|
63
|
+
// overwrite the body again
|
|
64
|
+
ctx.body = body
|
|
65
|
+
await next()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default {
|
|
69
|
+
create,
|
|
70
|
+
update,
|
|
71
|
+
read,
|
|
72
|
+
destroy,
|
|
73
|
+
search,
|
|
74
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Application } from "./types"
|
|
2
|
+
|
|
3
|
+
function application(body: any): Application {
|
|
4
|
+
let app = body?.application ? body.application : body
|
|
5
|
+
return {
|
|
6
|
+
_id: app.appId,
|
|
7
|
+
name: app.name,
|
|
8
|
+
url: app.url,
|
|
9
|
+
status: app.status,
|
|
10
|
+
createdAt: app.createdAt,
|
|
11
|
+
updatedAt: app.updatedAt,
|
|
12
|
+
version: app.version,
|
|
13
|
+
tenantId: app.tenantId,
|
|
14
|
+
lockedBy: app.lockedBy,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function mapApplication(ctx: any): { data: Application } {
|
|
19
|
+
return {
|
|
20
|
+
data: application(ctx.body),
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function mapApplications(ctx: any): { data: Application[] } {
|
|
25
|
+
const apps = ctx.body.map((body: any) => application(body))
|
|
26
|
+
return { data: apps }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
mapApplication,
|
|
31
|
+
mapApplications,
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import tables from "./tables"
|
|
2
|
+
import applications from "./applications"
|
|
3
|
+
import users from "./users"
|
|
4
|
+
import rows from "./rows"
|
|
5
|
+
import queries from "./queries"
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
...tables,
|
|
9
|
+
...applications,
|
|
10
|
+
...users,
|
|
11
|
+
...rows,
|
|
12
|
+
...queries,
|
|
13
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Query, ExecuteQuery } from "./types"
|
|
2
|
+
|
|
3
|
+
function query(body: any): Query {
|
|
4
|
+
return {
|
|
5
|
+
_id: body._id,
|
|
6
|
+
datasourceId: body.datasourceId,
|
|
7
|
+
parameters: body.parameters,
|
|
8
|
+
fields: body.fields,
|
|
9
|
+
queryVerb: body.queryVerb,
|
|
10
|
+
name: body.name,
|
|
11
|
+
schema: body.schema,
|
|
12
|
+
transformer: body.transformer,
|
|
13
|
+
readable: body.readable,
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function mapQueries(ctx: any): { data: Query[] } {
|
|
18
|
+
const queries = ctx.body.map((body: any) => query(body))
|
|
19
|
+
return {
|
|
20
|
+
data: queries,
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function mapQueryExecution(ctx: any): ExecuteQuery {
|
|
25
|
+
// very little we can map here, structure mostly unknown
|
|
26
|
+
return {
|
|
27
|
+
data: ctx.body.data,
|
|
28
|
+
pagination: ctx.body.pagination,
|
|
29
|
+
extra: {
|
|
30
|
+
raw: ctx.body.raw,
|
|
31
|
+
headers: ctx.body.headers,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default {
|
|
37
|
+
mapQueries,
|
|
38
|
+
mapQueryExecution,
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Row, RowSearch } from "./types"
|
|
2
|
+
|
|
3
|
+
function row(body: any): Row {
|
|
4
|
+
delete body._rev
|
|
5
|
+
// have to input everything, since structure unknown
|
|
6
|
+
return {
|
|
7
|
+
...body,
|
|
8
|
+
_id: body._id,
|
|
9
|
+
tableId: body.tableId,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function mapRowSearch(ctx: any): RowSearch {
|
|
14
|
+
const rows = ctx.body.rows.map((body: any) => row(body))
|
|
15
|
+
return {
|
|
16
|
+
data: rows,
|
|
17
|
+
hasNextPage: ctx.body.hasNextPage,
|
|
18
|
+
bookmark: ctx.body.bookmark,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function mapRow(ctx: any): { data: Row } {
|
|
23
|
+
return {
|
|
24
|
+
data: row(ctx.body),
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default {
|
|
29
|
+
mapRowSearch,
|
|
30
|
+
mapRow,
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Table } from "./types"
|
|
2
|
+
|
|
3
|
+
function table(body: any): Table {
|
|
4
|
+
return {
|
|
5
|
+
_id: body._id,
|
|
6
|
+
name: body.name,
|
|
7
|
+
schema: body.schema,
|
|
8
|
+
primaryDisplay: body.primaryDisplay,
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function mapTable(ctx: any): { data: Table } {
|
|
13
|
+
return {
|
|
14
|
+
data: table(ctx.body),
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function mapTables(ctx: any): { data: Table[] } {
|
|
19
|
+
const tables = ctx.body.map((body: any) => table(body))
|
|
20
|
+
return { data: tables }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
mapTable,
|
|
25
|
+
mapTables,
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { components } from "../../../../definitions/openapi"
|
|
2
|
+
|
|
3
|
+
export type Query = components["schemas"]["query"]
|
|
4
|
+
export type ExecuteQuery = components["schemas"]["executeQueryOutput"]
|
|
5
|
+
|
|
6
|
+
export type Application = components["schemas"]["applicationOutput"]["data"]
|
|
7
|
+
|
|
8
|
+
export type Table = components["schemas"]["tableOutput"]["data"]
|
|
9
|
+
|
|
10
|
+
export type Row = components["schemas"]["rowOutput"]["data"]
|
|
11
|
+
export type RowSearch = components["schemas"]["searchOutput"]
|
|
12
|
+
|
|
13
|
+
export type User = components["schemas"]["userOutput"]["data"]
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { User } from "./types"
|
|
2
|
+
|
|
3
|
+
function user(body: any): User {
|
|
4
|
+
return {
|
|
5
|
+
_id: body._id,
|
|
6
|
+
email: body.email,
|
|
7
|
+
password: body.password,
|
|
8
|
+
status: body.status,
|
|
9
|
+
firstName: body.firstName,
|
|
10
|
+
lastName: body.lastName,
|
|
11
|
+
forceResetPassword: body.forceResetPassword,
|
|
12
|
+
builder: body.builder,
|
|
13
|
+
admin: body.admin,
|
|
14
|
+
roles: body.roles,
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function mapUser(ctx: any): { data: User } {
|
|
19
|
+
return {
|
|
20
|
+
data: user(ctx.body),
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function mapUsers(ctx: any): { data: User[] } {
|
|
25
|
+
const users = ctx.body.map((body: any) => user(body))
|
|
26
|
+
return { data: users }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
mapUser,
|
|
31
|
+
mapUsers,
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { search as stringSearch } from "./utils"
|
|
2
|
+
import { default as queryController } from "../query"
|
|
3
|
+
|
|
4
|
+
export async function search(ctx: any, next: any) {
|
|
5
|
+
await queryController.fetch(ctx)
|
|
6
|
+
const { name } = ctx.request.body
|
|
7
|
+
ctx.body = stringSearch(ctx.body, name)
|
|
8
|
+
await next()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function execute(ctx: any, next: any) {
|
|
12
|
+
// don't wrap this, already returns "data"
|
|
13
|
+
await queryController.executeV2(ctx)
|
|
14
|
+
await next()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default {
|
|
18
|
+
search,
|
|
19
|
+
execute,
|
|
20
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { default as rowController } from "../row"
|
|
2
|
+
import { addRev } from "./utils"
|
|
3
|
+
import { Row } from "../../../definitions/common"
|
|
4
|
+
|
|
5
|
+
// makes sure that the user doesn't need to pass in the type, tableId or _id params for
|
|
6
|
+
// the call to be correct
|
|
7
|
+
function fixRow(row: Row, params: any) {
|
|
8
|
+
if (!params || !row) {
|
|
9
|
+
return row
|
|
10
|
+
}
|
|
11
|
+
if (params.rowId) {
|
|
12
|
+
row._id = params.rowId
|
|
13
|
+
}
|
|
14
|
+
if (params.tableId) {
|
|
15
|
+
row.tableId = params.tableId
|
|
16
|
+
}
|
|
17
|
+
if (!row.type) {
|
|
18
|
+
row.type = "row"
|
|
19
|
+
}
|
|
20
|
+
return row
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function search(ctx: any, next: any) {
|
|
24
|
+
let { sort, paginate, bookmark, limit, query } = ctx.request.body
|
|
25
|
+
// update the body to the correct format of the internal search
|
|
26
|
+
if (!sort) {
|
|
27
|
+
sort = {}
|
|
28
|
+
}
|
|
29
|
+
ctx.request.body = {
|
|
30
|
+
sort: sort.column,
|
|
31
|
+
sortType: sort.type,
|
|
32
|
+
sortOrder: sort.order,
|
|
33
|
+
bookmark,
|
|
34
|
+
paginate,
|
|
35
|
+
limit,
|
|
36
|
+
query,
|
|
37
|
+
}
|
|
38
|
+
await rowController.search(ctx)
|
|
39
|
+
await next()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function create(ctx: any, next: any) {
|
|
43
|
+
ctx.request.body = fixRow(ctx.request.body, ctx.params)
|
|
44
|
+
await rowController.save(ctx)
|
|
45
|
+
await next()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function read(ctx: any, next: any) {
|
|
49
|
+
await rowController.fetchEnrichedRow(ctx)
|
|
50
|
+
await next()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function update(ctx: any, next: any) {
|
|
54
|
+
ctx.request.body = await addRev(fixRow(ctx.request.body, ctx.params.tableId))
|
|
55
|
+
await rowController.save(ctx)
|
|
56
|
+
await next()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export async function destroy(ctx: any, next: any) {
|
|
60
|
+
// set the body as expected, with the _id and _rev fields
|
|
61
|
+
ctx.request.body = await addRev(
|
|
62
|
+
fixRow({ _id: ctx.params.rowId }, ctx.params.tableId)
|
|
63
|
+
)
|
|
64
|
+
await rowController.destroy(ctx)
|
|
65
|
+
// destroy controller doesn't currently return the row as the body, need to adjust this
|
|
66
|
+
// in the public API to be correct
|
|
67
|
+
ctx.body = ctx.row
|
|
68
|
+
await next()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default {
|
|
72
|
+
create,
|
|
73
|
+
read,
|
|
74
|
+
update,
|
|
75
|
+
destroy,
|
|
76
|
+
search,
|
|
77
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { search as stringSearch, addRev } from "./utils"
|
|
2
|
+
import { default as controller } from "../table"
|
|
3
|
+
import { Table } from "../../../definitions/common"
|
|
4
|
+
|
|
5
|
+
function fixTable(table: Table, params: any) {
|
|
6
|
+
if (!params || !table) {
|
|
7
|
+
return table
|
|
8
|
+
}
|
|
9
|
+
if (params.tableId) {
|
|
10
|
+
table._id = params.tableId
|
|
11
|
+
}
|
|
12
|
+
if (!table.type) {
|
|
13
|
+
table.type = "table"
|
|
14
|
+
}
|
|
15
|
+
return table
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function search(ctx: any, next: any) {
|
|
19
|
+
const { name } = ctx.request.body
|
|
20
|
+
await controller.fetch(ctx)
|
|
21
|
+
ctx.body = stringSearch(ctx.body, name)
|
|
22
|
+
await next()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function create(ctx: any, next: any) {
|
|
26
|
+
await controller.save(ctx)
|
|
27
|
+
await next()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function read(ctx: any, next: any) {
|
|
31
|
+
await controller.find(ctx)
|
|
32
|
+
await next()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function update(ctx: any, next: any) {
|
|
36
|
+
ctx.request.body = await addRev(
|
|
37
|
+
fixTable(ctx.request.body, ctx.params),
|
|
38
|
+
ctx.params.tableId
|
|
39
|
+
)
|
|
40
|
+
await controller.save(ctx)
|
|
41
|
+
await next()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function destroy(ctx: any, next: any) {
|
|
45
|
+
await controller.destroy(ctx)
|
|
46
|
+
ctx.body = ctx.table
|
|
47
|
+
await next()
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
create,
|
|
52
|
+
read,
|
|
53
|
+
update,
|
|
54
|
+
destroy,
|
|
55
|
+
search,
|
|
56
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
allGlobalUsers,
|
|
3
|
+
deleteGlobalUser,
|
|
4
|
+
readGlobalUser,
|
|
5
|
+
saveGlobalUser,
|
|
6
|
+
} from "../../../utilities/workerRequests"
|
|
7
|
+
import { search as stringSearch } from "./utils"
|
|
8
|
+
|
|
9
|
+
const { getProdAppID } = require("@budibase/backend-core/db")
|
|
10
|
+
|
|
11
|
+
function fixUser(ctx: any) {
|
|
12
|
+
if (!ctx.request.body) {
|
|
13
|
+
return ctx
|
|
14
|
+
}
|
|
15
|
+
if (!ctx.request.body._id && ctx.params.userId) {
|
|
16
|
+
ctx.request.body._id = ctx.params.userId
|
|
17
|
+
}
|
|
18
|
+
if (!ctx.request.body.roles) {
|
|
19
|
+
ctx.request.body.roles = {}
|
|
20
|
+
} else {
|
|
21
|
+
const newRoles: { [key: string]: string } = {}
|
|
22
|
+
for (let [appId, role] of Object.entries(ctx.request.body.roles)) {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
newRoles[getProdAppID(appId)] = role
|
|
25
|
+
}
|
|
26
|
+
ctx.request.body.roles = newRoles
|
|
27
|
+
}
|
|
28
|
+
return ctx
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getUser(ctx: any, userId?: string) {
|
|
32
|
+
if (userId) {
|
|
33
|
+
ctx.params = { userId }
|
|
34
|
+
} else if (!ctx.params?.userId) {
|
|
35
|
+
throw "No user ID provided for getting"
|
|
36
|
+
}
|
|
37
|
+
return readGlobalUser(ctx)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function search(ctx: any, next: any) {
|
|
41
|
+
const { name } = ctx.request.body
|
|
42
|
+
const users = await allGlobalUsers(ctx)
|
|
43
|
+
ctx.body = stringSearch(users, name, "email")
|
|
44
|
+
await next()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function create(ctx: any, next: any) {
|
|
48
|
+
const response = await saveGlobalUser(fixUser(ctx))
|
|
49
|
+
ctx.body = await getUser(ctx, response._id)
|
|
50
|
+
await next()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function read(ctx: any, next: any) {
|
|
54
|
+
ctx.body = await readGlobalUser(ctx)
|
|
55
|
+
await next()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function update(ctx: any, next: any) {
|
|
59
|
+
const user = await readGlobalUser(ctx)
|
|
60
|
+
ctx.request.body = {
|
|
61
|
+
...ctx.request.body,
|
|
62
|
+
_rev: user._rev,
|
|
63
|
+
}
|
|
64
|
+
const response = await saveGlobalUser(fixUser(ctx))
|
|
65
|
+
ctx.body = await getUser(ctx, response._id)
|
|
66
|
+
await next()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function destroy(ctx: any, next: any) {
|
|
70
|
+
const user = await getUser(ctx)
|
|
71
|
+
await deleteGlobalUser(ctx)
|
|
72
|
+
ctx.body = user
|
|
73
|
+
await next()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default {
|
|
77
|
+
create,
|
|
78
|
+
read,
|
|
79
|
+
update,
|
|
80
|
+
destroy,
|
|
81
|
+
search,
|
|
82
|
+
}
|