@budibase/worker 2.5.6-alpha.1 → 2.5.6-alpha.3
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 +6 -6
- package/src/sdk/users/users.ts +0 -10
- package/src/utilities/appService.ts +0 -46
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.5.6-alpha.
|
|
4
|
+
"version": "2.5.6-alpha.3",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"author": "Budibase",
|
|
38
38
|
"license": "GPL-3.0",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@budibase/backend-core": "2.5.6-alpha.
|
|
41
|
-
"@budibase/pro": "2.5.
|
|
42
|
-
"@budibase/string-templates": "2.5.6-alpha.
|
|
43
|
-
"@budibase/types": "2.5.6-alpha.
|
|
40
|
+
"@budibase/backend-core": "2.5.6-alpha.3",
|
|
41
|
+
"@budibase/pro": "2.5.6-alpha.2",
|
|
42
|
+
"@budibase/string-templates": "2.5.6-alpha.3",
|
|
43
|
+
"@budibase/types": "2.5.6-alpha.3",
|
|
44
44
|
"@koa/router": "8.0.8",
|
|
45
45
|
"@sentry/node": "6.17.7",
|
|
46
46
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"typescript": "4.7.3",
|
|
103
103
|
"update-dotenv": "1.1.1"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "38b2a2407eeb58c3f143c1d91d517e38b27cdd89"
|
|
106
106
|
}
|
package/src/sdk/users/users.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import env from "../../environment"
|
|
2
|
-
import * as apps from "../../utilities/appService"
|
|
3
2
|
import * as eventHelpers from "./events"
|
|
4
3
|
import {
|
|
5
4
|
accounts,
|
|
@@ -30,7 +29,6 @@ import {
|
|
|
30
29
|
PlatformUser,
|
|
31
30
|
PlatformUserByEmail,
|
|
32
31
|
RowResponse,
|
|
33
|
-
SearchUsersRequest,
|
|
34
32
|
User,
|
|
35
33
|
SaveUserOpts,
|
|
36
34
|
Account,
|
|
@@ -280,9 +278,6 @@ export const save = async (
|
|
|
280
278
|
await platform.users.addUser(tenantId, builtUser._id!, builtUser.email)
|
|
281
279
|
await cache.user.invalidateUser(response.id)
|
|
282
280
|
|
|
283
|
-
// let server know to sync user
|
|
284
|
-
await apps.syncUserInApps(_id, dbUser)
|
|
285
|
-
|
|
286
281
|
await Promise.all(groupPromises)
|
|
287
282
|
|
|
288
283
|
// finally returned the saved user from the db
|
|
@@ -432,7 +427,6 @@ export const bulkCreate = async (
|
|
|
432
427
|
// instead of relying on looping tenant creation
|
|
433
428
|
await platform.users.addUser(tenantId, user._id, user.email)
|
|
434
429
|
await eventHelpers.handleSaveEvents(user, undefined)
|
|
435
|
-
await apps.syncUserInApps(user._id)
|
|
436
430
|
}
|
|
437
431
|
|
|
438
432
|
const saved = usersToBulkSave.map(user => {
|
|
@@ -571,8 +565,6 @@ export const destroy = async (id: string) => {
|
|
|
571
565
|
await eventHelpers.handleDeleteEvents(dbUser)
|
|
572
566
|
await cache.user.invalidateUser(userId)
|
|
573
567
|
await sessions.invalidateSessions(userId, { reason: "deletion" })
|
|
574
|
-
// let server know to sync user
|
|
575
|
-
await apps.syncUserInApps(userId, dbUser)
|
|
576
568
|
}
|
|
577
569
|
|
|
578
570
|
const bulkDeleteProcessing = async (dbUser: User) => {
|
|
@@ -581,8 +573,6 @@ const bulkDeleteProcessing = async (dbUser: User) => {
|
|
|
581
573
|
await eventHelpers.handleDeleteEvents(dbUser)
|
|
582
574
|
await cache.user.invalidateUser(userId)
|
|
583
575
|
await sessions.invalidateSessions(userId, { reason: "bulk-deletion" })
|
|
584
|
-
// let server know to sync user
|
|
585
|
-
await apps.syncUserInApps(userId, dbUser)
|
|
586
576
|
}
|
|
587
577
|
|
|
588
578
|
export const invite = async (
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch"
|
|
2
|
-
import {
|
|
3
|
-
constants,
|
|
4
|
-
tenancy,
|
|
5
|
-
logging,
|
|
6
|
-
env as coreEnv,
|
|
7
|
-
} from "@budibase/backend-core"
|
|
8
|
-
import { checkSlashesInUrl } from "../utilities"
|
|
9
|
-
import env from "../environment"
|
|
10
|
-
import { SyncUserRequest, User } from "@budibase/types"
|
|
11
|
-
|
|
12
|
-
async function makeAppRequest(url: string, method: string, body: any) {
|
|
13
|
-
if (env.isTest()) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
const request: any = { headers: {} }
|
|
17
|
-
request.headers[constants.Header.API_KEY] = coreEnv.INTERNAL_API_KEY
|
|
18
|
-
if (tenancy.isTenantIdSet()) {
|
|
19
|
-
request.headers[constants.Header.TENANT_ID] = tenancy.getTenantId()
|
|
20
|
-
}
|
|
21
|
-
if (body) {
|
|
22
|
-
request.headers["Content-Type"] = "application/json"
|
|
23
|
-
request.body = JSON.stringify(body)
|
|
24
|
-
}
|
|
25
|
-
request.method = method
|
|
26
|
-
|
|
27
|
-
// add x-budibase-correlation-id header
|
|
28
|
-
logging.correlation.setHeader(request.headers)
|
|
29
|
-
|
|
30
|
-
return fetch(checkSlashesInUrl(env.APPS_URL + url), request)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export async function syncUserInApps(userId: string, previousUser?: User) {
|
|
34
|
-
const body: SyncUserRequest = {
|
|
35
|
-
previousUser,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const response = await makeAppRequest(
|
|
39
|
-
`/api/users/metadata/sync/${userId}`,
|
|
40
|
-
"POST",
|
|
41
|
-
body
|
|
42
|
-
)
|
|
43
|
-
if (response && response.status !== 200) {
|
|
44
|
-
throw "Unable to sync user."
|
|
45
|
-
}
|
|
46
|
-
}
|