@budibase/worker 3.2.25 → 3.2.27
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/package.json +9 -10
- package/src/api/controllers/global/auth.ts +26 -12
- package/src/api/controllers/global/configs.ts +14 -6
- package/src/api/controllers/global/email.ts +9 -2
- package/src/api/controllers/global/license.ts +6 -3
- package/src/api/controllers/global/roles.ts +10 -4
- package/src/api/controllers/global/self.ts +15 -8
- package/src/api/controllers/global/templates.ts +35 -17
- package/src/api/controllers/global/users.ts +41 -14
- package/src/api/controllers/system/accounts.ts +11 -3
- package/src/api/controllers/system/environment.ts +3 -3
- package/src/api/controllers/system/logs.ts +2 -2
- package/src/api/controllers/system/migrations.ts +12 -2
- package/src/api/controllers/system/restore.ts +4 -2
- package/src/api/controllers/system/tenants.ts +3 -3
- package/src/api/routes/global/email.ts +1 -1
- package/src/api/routes/global/tests/auth.spec.ts +2 -2
- package/src/api/routes/global/tests/email.spec.ts +1 -1
- package/src/api/routes/global/tests/realEmail.spec.ts +1 -2
- package/src/api/routes/global/tests/templates.spec.ts +2 -5
- package/src/api/routes/global/tests/users.spec.ts +1 -1
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/system/tests/environment.spec.ts +2 -2
- package/src/constants/index.ts +1 -9
- package/src/constants/templates/index.ts +17 -15
- package/src/middleware/cloudRestricted.ts +2 -2
- package/src/middleware/handleScimBody.ts +1 -1
- package/src/sdk/accounts/metadata.ts +1 -4
- package/src/sdk/auth/auth.ts +1 -2
- package/src/sdk/users/users.ts +1 -1
- package/src/tests/api/accounts.ts +0 -5
- package/src/tests/api/auditLogs.ts +0 -5
- package/src/tests/api/auth.ts +0 -5
- package/src/tests/api/base.ts +1 -1
- package/src/tests/api/configs.ts +0 -5
- package/src/tests/api/email.ts +1 -6
- package/src/tests/api/environment.ts +0 -5
- package/src/tests/api/groups.ts +0 -5
- package/src/tests/api/license.ts +0 -5
- package/src/tests/api/migrations.ts +0 -5
- package/src/tests/api/restore.ts +0 -5
- package/src/tests/api/roles.ts +0 -5
- package/src/tests/api/scim/groups.ts +0 -5
- package/src/tests/api/scim/shared.ts +0 -5
- package/src/tests/api/scim/users.ts +0 -5
- package/src/tests/api/self.ts +0 -5
- package/src/tests/api/status.ts +0 -5
- package/src/tests/api/templates.ts +0 -5
- package/src/tests/api/users.ts +1 -10
- package/src/tests/controllers.ts +0 -1
- package/src/utilities/email.ts +7 -2
- package/src/utilities/templates.ts +2 -5
- package/tsconfig.build.json +2 -19
- package/tsconfig.json +0 -4
- package/src/api/controllers/global/workspaces.ts +0 -53
- package/src/api/routes/global/workspaces.ts +0 -37
package/src/tests/api/users.ts
CHANGED
|
@@ -9,14 +9,9 @@ import {
|
|
|
9
9
|
} from "@budibase/types"
|
|
10
10
|
import structures from "../structures"
|
|
11
11
|
import { generator } from "@budibase/backend-core/tests"
|
|
12
|
-
import TestConfiguration from "../TestConfiguration"
|
|
13
12
|
import { TestAPI, TestAPIOpts } from "./base"
|
|
14
13
|
|
|
15
14
|
export class UserAPI extends TestAPI {
|
|
16
|
-
constructor(config: TestConfiguration) {
|
|
17
|
-
super(config)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
15
|
// INVITE
|
|
21
16
|
|
|
22
17
|
sendUserInvite = async (sendMailMock: any, email: string, status = 200) => {
|
|
@@ -178,11 +173,7 @@ export class UserAPI extends TestAPI {
|
|
|
178
173
|
.expect(opts?.status ? opts.status : 200)
|
|
179
174
|
}
|
|
180
175
|
|
|
181
|
-
grantBuilderToApp = (
|
|
182
|
-
userId: string,
|
|
183
|
-
appId: string,
|
|
184
|
-
statusCode: number = 200
|
|
185
|
-
) => {
|
|
176
|
+
grantBuilderToApp = (userId: string, appId: string, statusCode = 200) => {
|
|
186
177
|
return this.request
|
|
187
178
|
.post(`/api/global/users/${userId}/app/${appId}/builder`)
|
|
188
179
|
.set(this.config.defaultHeaders())
|
package/src/tests/controllers.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * as email from "../api/controllers/global/email"
|
|
2
|
-
export * as workspaces from "../api/controllers/global/workspaces"
|
|
3
2
|
export * as config from "../api/controllers/global/configs"
|
|
4
3
|
export * as templates from "../api/controllers/global/templates"
|
|
5
4
|
export * as users from "../api/controllers/global/users"
|
package/src/utilities/email.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import env from "../environment"
|
|
2
|
-
import {
|
|
2
|
+
import { TemplateType } from "../constants"
|
|
3
3
|
import { getTemplateByPurpose, EmailTemplates } from "../constants/templates"
|
|
4
4
|
import { getSettingsTemplateContext } from "./templates"
|
|
5
5
|
import { processString } from "@budibase/string-templates"
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
User,
|
|
8
|
+
SendEmailOpts,
|
|
9
|
+
SMTPInnerConfig,
|
|
10
|
+
EmailTemplatePurpose,
|
|
11
|
+
} from "@budibase/types"
|
|
7
12
|
import { configs, cache, objectStore } from "@budibase/backend-core"
|
|
8
13
|
import ical from "ical-generator"
|
|
9
14
|
import _ from "lodash"
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { tenancy, configs } from "@budibase/backend-core"
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
LOGO_URL,
|
|
5
|
-
EmailTemplatePurpose,
|
|
6
|
-
} from "../constants"
|
|
2
|
+
import { EmailTemplatePurpose } from "@budibase/types"
|
|
3
|
+
import { InternalTemplateBinding, LOGO_URL } from "../constants"
|
|
7
4
|
import { checkSlashesInUrl } from "./index"
|
|
8
5
|
|
|
9
6
|
const BASE_COMPANY = "Budibase"
|
package/tsconfig.build.json
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../tsconfig.build.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["es2020"],
|
|
6
|
-
"strict": true,
|
|
7
|
-
"noImplicitAny": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"incremental": true,
|
|
11
|
-
"types": ["node", "jest"],
|
|
12
|
-
"outDir": "dist",
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"paths": {
|
|
15
|
-
"@budibase/types": ["../types/src"],
|
|
16
|
-
"@budibase/backend-core": ["../backend-core/src"],
|
|
17
|
-
"@budibase/backend-core/*": ["../backend-core/*"],
|
|
18
|
-
"@budibase/shared-core": ["../shared-core/src"],
|
|
19
|
-
"@budibase/pro": ["../pro/src"],
|
|
20
|
-
"@budibase/string-templates": ["../string-templates/src"]
|
|
21
|
-
}
|
|
4
|
+
"target": "es2020"
|
|
22
5
|
},
|
|
23
6
|
"include": ["src/**/*"],
|
|
24
7
|
"exclude": [
|
package/tsconfig.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { tenancy, db as dbCore } from "@budibase/backend-core"
|
|
2
|
-
import { BBContext } from "@budibase/types"
|
|
3
|
-
|
|
4
|
-
export async function save(ctx: BBContext) {
|
|
5
|
-
const db = tenancy.getGlobalDB()
|
|
6
|
-
const workspaceDoc = ctx.request.body
|
|
7
|
-
|
|
8
|
-
// workspace does not exist yet
|
|
9
|
-
if (!workspaceDoc._id) {
|
|
10
|
-
workspaceDoc._id = dbCore.generateWorkspaceID()
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
const response = await db.put(workspaceDoc)
|
|
15
|
-
ctx.body = {
|
|
16
|
-
_id: response.id,
|
|
17
|
-
_rev: response.rev,
|
|
18
|
-
}
|
|
19
|
-
} catch (err: any) {
|
|
20
|
-
ctx.throw(err.status, err)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function fetch(ctx: BBContext) {
|
|
25
|
-
const db = tenancy.getGlobalDB()
|
|
26
|
-
const response = await db.allDocs(
|
|
27
|
-
dbCore.getWorkspaceParams(undefined, {
|
|
28
|
-
include_docs: true,
|
|
29
|
-
})
|
|
30
|
-
)
|
|
31
|
-
ctx.body = response.rows.map(row => row.doc)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export async function find(ctx: BBContext) {
|
|
35
|
-
const db = tenancy.getGlobalDB()
|
|
36
|
-
try {
|
|
37
|
-
ctx.body = await db.get(ctx.params.id)
|
|
38
|
-
} catch (err: any) {
|
|
39
|
-
ctx.throw(err.status, err)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export async function destroy(ctx: BBContext) {
|
|
44
|
-
const db = tenancy.getGlobalDB()
|
|
45
|
-
const { id, rev } = ctx.params
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
await db.remove(id, rev)
|
|
49
|
-
ctx.body = { message: "Workspace deleted successfully" }
|
|
50
|
-
} catch (err: any) {
|
|
51
|
-
ctx.throw(err.status, err)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import Router from "@koa/router"
|
|
2
|
-
import * as controller from "../../controllers/global/workspaces"
|
|
3
|
-
import { auth } from "@budibase/backend-core"
|
|
4
|
-
import Joi from "joi"
|
|
5
|
-
|
|
6
|
-
const router: Router = new Router()
|
|
7
|
-
|
|
8
|
-
function buildWorkspaceSaveValidation() {
|
|
9
|
-
// prettier-ignore
|
|
10
|
-
return auth.joiValidator.body(Joi.object({
|
|
11
|
-
_id: Joi.string().optional(),
|
|
12
|
-
_rev: Joi.string().optional(),
|
|
13
|
-
name: Joi.string().required(),
|
|
14
|
-
users: Joi.array().required(),
|
|
15
|
-
managers: Joi.array().required(),
|
|
16
|
-
roles: Joi.object({
|
|
17
|
-
default: Joi.string().optional(),
|
|
18
|
-
app: Joi.object()
|
|
19
|
-
.pattern(/.*/, Joi.string())
|
|
20
|
-
.required()
|
|
21
|
-
.unknown(true),
|
|
22
|
-
}).unknown(true).optional(),
|
|
23
|
-
}).required().unknown(true))
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
router
|
|
27
|
-
.post(
|
|
28
|
-
"/api/global/workspaces",
|
|
29
|
-
auth.adminOnly,
|
|
30
|
-
buildWorkspaceSaveValidation(),
|
|
31
|
-
controller.save
|
|
32
|
-
)
|
|
33
|
-
.delete("/api/global/workspaces/:id", auth.adminOnly, controller.destroy)
|
|
34
|
-
.get("/api/global/workspaces", controller.fetch)
|
|
35
|
-
.get("/api/global/workspaces/:id", controller.find)
|
|
36
|
-
|
|
37
|
-
export default router
|