@budibase/worker 2.1.40-alpha.5 → 2.1.41
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 +24 -14
- package/{src/tests/jestSetup.ts → scripts/jestSetup.js} +3 -12
- package/scripts/localdomain.js +7 -33
- package/src/api/controllers/global/auth.ts +43 -51
- package/src/api/controllers/global/{configs.ts → configs.js} +114 -119
- package/src/api/controllers/global/{email.ts → email.js} +5 -6
- package/src/api/controllers/global/roles.js +68 -0
- package/src/api/controllers/global/self.ts +2 -2
- package/src/api/controllers/global/users.ts +2 -4
- package/src/api/controllers/global/{workspaces.ts → workspaces.js} +18 -15
- package/src/api/controllers/system/{environment.ts → environment.js} +2 -3
- package/src/api/controllers/system/restore.ts +1 -1
- package/src/api/controllers/system/{status.ts → status.js} +3 -4
- package/src/api/controllers/system/tenants.ts +51 -8
- package/src/api/index.ts +8 -31
- package/src/api/routes/global/{auth.ts → auth.js} +48 -31
- package/src/api/routes/global/{configs.ts → configs.js} +23 -22
- package/src/api/routes/global/{email.ts → email.js} +10 -9
- package/src/api/routes/global/license.ts +1 -1
- package/src/api/routes/global/roles.js +12 -0
- package/src/api/routes/global/self.ts +2 -2
- package/src/api/routes/global/templates.ts +4 -4
- package/src/api/routes/global/tests/auth.spec.ts +64 -134
- package/src/api/routes/global/tests/configs.spec.ts +35 -34
- package/src/api/routes/global/tests/email.spec.ts +3 -4
- package/src/api/routes/global/tests/realEmail.spec.ts +3 -2
- package/src/api/routes/global/tests/self.spec.ts +4 -3
- package/src/api/routes/global/tests/users.spec.ts +59 -51
- package/src/api/routes/global/{users.ts → users.js} +32 -26
- package/src/api/routes/global/{workspaces.ts → workspaces.js} +10 -9
- package/src/api/routes/index.ts +1 -2
- package/src/api/routes/system/accounts.ts +1 -1
- package/src/api/routes/system/environment.js +8 -0
- package/src/api/routes/system/migrations.ts +1 -1
- package/src/api/routes/system/restore.ts +1 -1
- package/src/api/routes/system/status.js +8 -0
- package/src/api/routes/system/tenants.js +12 -0
- package/src/api/routes/system/tests/accounts.spec.ts +6 -5
- package/src/api/routes/validation/users.ts +3 -3
- package/src/constants/{index.ts → index.js} +64 -57
- package/src/constants/templates/{index.ts → index.js} +19 -23
- package/src/db/index.js +11 -0
- package/src/environment.ts +7 -9
- package/src/index.ts +16 -15
- package/src/middleware/{cloudRestricted.ts → cloudRestricted.js} +4 -5
- package/src/tests/TestConfiguration.ts +50 -99
- package/src/tests/api/accounts.ts +8 -5
- package/src/tests/api/auth.ts +6 -3
- package/src/tests/api/configs.ts +8 -15
- package/src/tests/api/email.ts +6 -3
- package/src/tests/api/index.ts +0 -15
- package/src/tests/api/self.ts +6 -11
- package/src/tests/api/users.ts +8 -40
- package/src/tests/controllers.js +7 -0
- package/src/tests/index.ts +1 -5
- package/src/tests/structures/accounts.ts +24 -0
- package/src/tests/structures/{configs.ts → configs.js} +11 -11
- package/src/tests/structures/index.ts +3 -5
- package/src/tests/structures/users.ts +0 -1
- package/src/utilities/appService.js +33 -0
- package/src/utilities/{email.ts → email.js} +45 -78
- package/src/utilities/fileSystem.js +5 -0
- package/src/utilities/{index.ts → index.js} +1 -1
- package/src/utilities/{redis.ts → redis.js} +24 -29
- package/src/utilities/templates.js +49 -0
- package/src/utilities/users.js +17 -0
- package/tsconfig.build.json +3 -2
- package/tsconfig.json +1 -3
- package/__mocks__/aws-sdk.ts +0 -15
- package/__mocks__/oauth.ts +0 -57
- package/coverage/clover.xml +0 -2153
- package/coverage/coverage-final.json +0 -78
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -431
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +0 -925
- package/coverage/lcov-report/src/api/controllers/global/configs.ts.html +0 -1405
- package/coverage/lcov-report/src/api/controllers/global/email.ts.html +0 -196
- package/coverage/lcov-report/src/api/controllers/global/index.html +0 -236
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +0 -187
- package/coverage/lcov-report/src/api/controllers/global/roles.ts.html +0 -283
- package/coverage/lcov-report/src/api/controllers/global/self.ts.html +0 -577
- package/coverage/lcov-report/src/api/controllers/global/templates.ts.html +0 -316
- package/coverage/lcov-report/src/api/controllers/global/users.ts.html +0 -796
- package/coverage/lcov-report/src/api/controllers/global/workspaces.ts.html +0 -244
- package/coverage/lcov-report/src/api/controllers/system/accounts.ts.html +0 -148
- package/coverage/lcov-report/src/api/controllers/system/environment.ts.html +0 -124
- package/coverage/lcov-report/src/api/controllers/system/index.html +0 -191
- package/coverage/lcov-report/src/api/controllers/system/migrations.ts.html +0 -124
- package/coverage/lcov-report/src/api/controllers/system/restore.ts.html +0 -124
- package/coverage/lcov-report/src/api/controllers/system/status.ts.html +0 -133
- package/coverage/lcov-report/src/api/controllers/system/tenants.ts.html +0 -154
- package/coverage/lcov-report/src/api/index.html +0 -116
- package/coverage/lcov-report/src/api/index.ts.html +0 -583
- package/coverage/lcov-report/src/api/routes/global/auth.ts.html +0 -349
- package/coverage/lcov-report/src/api/routes/global/configs.ts.html +0 -457
- package/coverage/lcov-report/src/api/routes/global/email.ts.html +0 -193
- package/coverage/lcov-report/src/api/routes/global/index.html +0 -236
- package/coverage/lcov-report/src/api/routes/global/license.ts.html +0 -124
- package/coverage/lcov-report/src/api/routes/global/roles.ts.html +0 -133
- package/coverage/lcov-report/src/api/routes/global/self.ts.html +0 -139
- package/coverage/lcov-report/src/api/routes/global/templates.ts.html +0 -196
- package/coverage/lcov-report/src/api/routes/global/users.ts.html +0 -409
- package/coverage/lcov-report/src/api/routes/global/workspaces.ts.html +0 -196
- package/coverage/lcov-report/src/api/routes/index.html +0 -116
- package/coverage/lcov-report/src/api/routes/index.ts.html +0 -196
- package/coverage/lcov-report/src/api/routes/system/accounts.ts.html +0 -142
- package/coverage/lcov-report/src/api/routes/system/environment.ts.html +0 -109
- package/coverage/lcov-report/src/api/routes/system/index.html +0 -191
- package/coverage/lcov-report/src/api/routes/system/migrations.ts.html +0 -142
- package/coverage/lcov-report/src/api/routes/system/restore.ts.html +0 -109
- package/coverage/lcov-report/src/api/routes/system/status.ts.html +0 -109
- package/coverage/lcov-report/src/api/routes/system/tenants.ts.html +0 -124
- package/coverage/lcov-report/src/api/routes/validation/index.html +0 -131
- package/coverage/lcov-report/src/api/routes/validation/index.ts.html +0 -88
- package/coverage/lcov-report/src/api/routes/validation/users.ts.html +0 -235
- package/coverage/lcov-report/src/constants/index.html +0 -116
- package/coverage/lcov-report/src/constants/index.ts.html +0 -613
- package/coverage/lcov-report/src/constants/templates/index.html +0 -116
- package/coverage/lcov-report/src/constants/templates/index.ts.html +0 -316
- package/coverage/lcov-report/src/db/index.html +0 -116
- package/coverage/lcov-report/src/db/index.ts.html +0 -115
- package/coverage/lcov-report/src/environment.ts.html +0 -373
- package/coverage/lcov-report/src/index.html +0 -131
- package/coverage/lcov-report/src/index.ts.html +0 -394
- package/coverage/lcov-report/src/middleware/cloudRestricted.ts.html +0 -139
- package/coverage/lcov-report/src/middleware/index.html +0 -116
- package/coverage/lcov-report/src/migrations/functions/globalInfoSyncUsers.ts.html +0 -145
- package/coverage/lcov-report/src/migrations/functions/index.html +0 -116
- package/coverage/lcov-report/src/migrations/index.html +0 -116
- package/coverage/lcov-report/src/migrations/index.ts.html +0 -271
- package/coverage/lcov-report/src/sdk/accounts/accounts.ts.html +0 -262
- package/coverage/lcov-report/src/sdk/accounts/index.html +0 -131
- package/coverage/lcov-report/src/sdk/accounts/index.ts.html +0 -88
- package/coverage/lcov-report/src/sdk/index.html +0 -116
- package/coverage/lcov-report/src/sdk/index.ts.html +0 -106
- package/coverage/lcov-report/src/sdk/users/events.ts.html +0 -577
- package/coverage/lcov-report/src/sdk/users/index.html +0 -146
- package/coverage/lcov-report/src/sdk/users/index.ts.html +0 -88
- package/coverage/lcov-report/src/sdk/users/users.ts.html +0 -1903
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +0 -1051
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +0 -160
- package/coverage/lcov-report/src/tests/api/auth.ts.html +0 -220
- package/coverage/lcov-report/src/tests/api/base.ts.html +0 -133
- package/coverage/lcov-report/src/tests/api/configs.ts.html +0 -226
- package/coverage/lcov-report/src/tests/api/email.ts.html +0 -148
- package/coverage/lcov-report/src/tests/api/environment.ts.html +0 -130
- package/coverage/lcov-report/src/tests/api/index.html +0 -296
- package/coverage/lcov-report/src/tests/api/index.ts.html +0 -205
- package/coverage/lcov-report/src/tests/api/migrations.ts.html +0 -151
- package/coverage/lcov-report/src/tests/api/restore.ts.html +0 -127
- package/coverage/lcov-report/src/tests/api/self.ts.html +0 -163
- package/coverage/lcov-report/src/tests/api/status.ts.html +0 -121
- package/coverage/lcov-report/src/tests/api/tenants.ts.html +0 -130
- package/coverage/lcov-report/src/tests/api/users.ts.html +0 -511
- package/coverage/lcov-report/src/tests/controllers.ts.html +0 -100
- package/coverage/lcov-report/src/tests/index.html +0 -146
- package/coverage/lcov-report/src/tests/index.ts.html +0 -139
- package/coverage/lcov-report/src/tests/mocks/email.js.html +0 -115
- package/coverage/lcov-report/src/tests/mocks/index.html +0 -131
- package/coverage/lcov-report/src/tests/mocks/index.ts.html +0 -106
- package/coverage/lcov-report/src/tests/structures/configs.ts.html +0 -313
- package/coverage/lcov-report/src/tests/structures/groups.ts.html +0 -118
- package/coverage/lcov-report/src/tests/structures/index.html +0 -161
- package/coverage/lcov-report/src/tests/structures/index.ts.html +0 -151
- package/coverage/lcov-report/src/tests/structures/users.ts.html +0 -196
- package/coverage/lcov-report/src/utilities/appService.ts.html +0 -181
- package/coverage/lcov-report/src/utilities/email.ts.html +0 -850
- package/coverage/lcov-report/src/utilities/fileSystem.ts.html +0 -100
- package/coverage/lcov-report/src/utilities/index.html +0 -206
- package/coverage/lcov-report/src/utilities/index.ts.html +0 -112
- package/coverage/lcov-report/src/utilities/redis.ts.html +0 -424
- package/coverage/lcov-report/src/utilities/templates.ts.html +0 -232
- package/coverage/lcov-report/src/utilities/users.ts.html +0 -133
- package/coverage/lcov.info +0 -3958
- package/jest.config.ts +0 -29
- package/src/api/controllers/global/roles.ts +0 -66
- package/src/api/routes/global/roles.ts +0 -16
- package/src/api/routes/global/tests/license.spec.ts +0 -31
- package/src/api/routes/global/tests/roles.spec.ts +0 -27
- package/src/api/routes/global/tests/templates.spec.ts +0 -35
- package/src/api/routes/global/tests/workspaces.spec.ts +0 -29
- package/src/api/routes/system/environment.ts +0 -8
- package/src/api/routes/system/status.ts +0 -8
- package/src/api/routes/system/tenants.ts +0 -13
- package/src/api/routes/system/tests/environment.spec.ts +0 -29
- package/src/api/routes/system/tests/migrations.spec.ts +0 -63
- package/src/api/routes/system/tests/restore.spec.ts +0 -36
- package/src/api/routes/system/tests/status.spec.ts +0 -48
- package/src/api/routes/system/tests/tenants.spec.ts +0 -61
- package/src/db/index.ts +0 -10
- package/src/middleware/tests/tenancy.spec.ts +0 -73
- package/src/tests/api/base.ts +0 -16
- package/src/tests/api/environment.ts +0 -15
- package/src/tests/api/migrations.ts +0 -22
- package/src/tests/api/restore.ts +0 -14
- package/src/tests/api/status.ts +0 -12
- package/src/tests/api/tenants.ts +0 -15
- package/src/tests/controllers.ts +0 -5
- package/src/utilities/appService.ts +0 -32
- package/src/utilities/fileSystem.ts +0 -5
- package/src/utilities/templates.ts +0 -49
- package/src/utilities/users.ts +0 -16
package/src/tests/api/tenants.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import TestConfiguration from "../TestConfiguration"
|
|
2
|
-
import { TestAPI, TestAPIOpts } from "./base"
|
|
3
|
-
|
|
4
|
-
export class TenantAPI extends TestAPI {
|
|
5
|
-
constructor(config: TestConfiguration) {
|
|
6
|
-
super(config)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
delete = (tenantId: string, opts?: TestAPIOpts) => {
|
|
10
|
-
return this.request
|
|
11
|
-
.delete(`/api/system/tenants/${tenantId}`)
|
|
12
|
-
.set(opts?.headers)
|
|
13
|
-
.expect(opts?.status ? opts.status : 204)
|
|
14
|
-
}
|
|
15
|
-
}
|
package/src/tests/controllers.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export * as email from "../api/controllers/global/email"
|
|
2
|
-
export * as workspaces from "../api/controllers/global/workspaces"
|
|
3
|
-
export * as config from "../api/controllers/global/configs"
|
|
4
|
-
export * as templates from "../api/controllers/global/templates"
|
|
5
|
-
export * as users from "../api/controllers/global/users"
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch"
|
|
2
|
-
import { constants, tenancy } from "@budibase/backend-core"
|
|
3
|
-
import { checkSlashesInUrl } from "../utilities"
|
|
4
|
-
import env from "../environment"
|
|
5
|
-
|
|
6
|
-
async function makeAppRequest(url: string, method: string, body: any) {
|
|
7
|
-
if (env.isTest()) {
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
const request: any = { headers: {} }
|
|
11
|
-
request.headers[constants.Header.API_KEY] = env.INTERNAL_API_KEY
|
|
12
|
-
if (tenancy.isTenantIdSet()) {
|
|
13
|
-
request.headers[constants.Header.TENANT_ID] = tenancy.getTenantId()
|
|
14
|
-
}
|
|
15
|
-
if (body) {
|
|
16
|
-
request.headers["Content-Type"] = "application/json"
|
|
17
|
-
request.body = JSON.stringify(body)
|
|
18
|
-
}
|
|
19
|
-
request.method = method
|
|
20
|
-
return fetch(checkSlashesInUrl(env.APPS_URL + url), request)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function syncUserInApps(userId: string) {
|
|
24
|
-
const response = await makeAppRequest(
|
|
25
|
-
`/api/users/metadata/sync/${userId}`,
|
|
26
|
-
"POST",
|
|
27
|
-
{}
|
|
28
|
-
)
|
|
29
|
-
if (response && response.status !== 200) {
|
|
30
|
-
throw "Unable to sync user."
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { db as dbCore, tenancy } from "@budibase/backend-core"
|
|
2
|
-
import {
|
|
3
|
-
Config,
|
|
4
|
-
InternalTemplateBinding,
|
|
5
|
-
LOGO_URL,
|
|
6
|
-
EmailTemplatePurpose,
|
|
7
|
-
} from "../constants"
|
|
8
|
-
import { checkSlashesInUrl } from "./index"
|
|
9
|
-
const BASE_COMPANY = "Budibase"
|
|
10
|
-
|
|
11
|
-
export async function getSettingsTemplateContext(
|
|
12
|
-
purpose: EmailTemplatePurpose,
|
|
13
|
-
code?: string
|
|
14
|
-
) {
|
|
15
|
-
const db = tenancy.getGlobalDB()
|
|
16
|
-
// TODO: use more granular settings in the future if required
|
|
17
|
-
let settings =
|
|
18
|
-
(await dbCore.getScopedConfig(db, { type: Config.SETTINGS })) || {}
|
|
19
|
-
const URL = settings.platformUrl
|
|
20
|
-
const context: any = {
|
|
21
|
-
[InternalTemplateBinding.LOGO_URL]:
|
|
22
|
-
checkSlashesInUrl(`${URL}/${settings.logoUrl}`) || LOGO_URL,
|
|
23
|
-
[InternalTemplateBinding.PLATFORM_URL]: URL,
|
|
24
|
-
[InternalTemplateBinding.COMPANY]: settings.company || BASE_COMPANY,
|
|
25
|
-
[InternalTemplateBinding.DOCS_URL]:
|
|
26
|
-
settings.docsUrl || "https://docs.budibase.com/",
|
|
27
|
-
[InternalTemplateBinding.LOGIN_URL]: checkSlashesInUrl(
|
|
28
|
-
tenancy.addTenantToUrl(`${URL}/login`)
|
|
29
|
-
),
|
|
30
|
-
[InternalTemplateBinding.CURRENT_DATE]: new Date().toISOString(),
|
|
31
|
-
[InternalTemplateBinding.CURRENT_YEAR]: new Date().getFullYear(),
|
|
32
|
-
}
|
|
33
|
-
// attach purpose specific context
|
|
34
|
-
switch (purpose) {
|
|
35
|
-
case EmailTemplatePurpose.PASSWORD_RECOVERY:
|
|
36
|
-
context[InternalTemplateBinding.RESET_CODE] = code
|
|
37
|
-
context[InternalTemplateBinding.RESET_URL] = checkSlashesInUrl(
|
|
38
|
-
tenancy.addTenantToUrl(`${URL}/builder/auth/reset?code=${code}`)
|
|
39
|
-
)
|
|
40
|
-
break
|
|
41
|
-
case EmailTemplatePurpose.INVITATION:
|
|
42
|
-
context[InternalTemplateBinding.INVITE_CODE] = code
|
|
43
|
-
context[InternalTemplateBinding.INVITE_URL] = checkSlashesInUrl(
|
|
44
|
-
tenancy.addTenantToUrl(`${URL}/builder/invite?code=${code}`)
|
|
45
|
-
)
|
|
46
|
-
break
|
|
47
|
-
}
|
|
48
|
-
return context
|
|
49
|
-
}
|
package/src/utilities/users.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { tenancy, db as dbCore } from "@budibase/backend-core"
|
|
2
|
-
|
|
3
|
-
export async function checkAnyUserExists() {
|
|
4
|
-
try {
|
|
5
|
-
const db = tenancy.getGlobalDB()
|
|
6
|
-
const users = await db.allDocs(
|
|
7
|
-
dbCore.getGlobalUserParams(null, {
|
|
8
|
-
include_docs: true,
|
|
9
|
-
limit: 1,
|
|
10
|
-
})
|
|
11
|
-
)
|
|
12
|
-
return users && users.rows.length >= 1
|
|
13
|
-
} catch (err) {
|
|
14
|
-
throw new Error("Unable to retrieve user list")
|
|
15
|
-
}
|
|
16
|
-
}
|