@budibase/worker 2.11.32 → 2.11.34

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/worker",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.11.32",
4
+ "version": "2.11.34",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -38,10 +38,10 @@
38
38
  "author": "Budibase",
39
39
  "license": "GPL-3.0",
40
40
  "dependencies": {
41
- "@budibase/backend-core": "2.11.32",
42
- "@budibase/pro": "2.11.32",
43
- "@budibase/string-templates": "2.11.32",
44
- "@budibase/types": "2.11.32",
41
+ "@budibase/backend-core": "2.11.34",
42
+ "@budibase/pro": "2.11.34",
43
+ "@budibase/string-templates": "2.11.34",
44
+ "@budibase/types": "2.11.34",
45
45
  "@koa/router": "8.0.8",
46
46
  "@sentry/node": "6.17.7",
47
47
  "@techpass/passport-openidconnect": "0.3.2",
@@ -110,5 +110,5 @@
110
110
  }
111
111
  }
112
112
  },
113
- "gitHead": "c78678f641ef364c15f56af29b9f1f77733e8e79"
113
+ "gitHead": "8f27e106f79c936f0f40de5b1f2dbf59c6d3b367"
114
114
  }
@@ -197,7 +197,12 @@ export const getAppUsers = async (ctx: Ctx<SearchUsersRequest>) => {
197
197
  export const search = async (ctx: Ctx<SearchUsersRequest>) => {
198
198
  const body = ctx.request.body
199
199
 
200
- if (body.paginated === false) {
200
+ // TODO: for now only one supported search key, string.email
201
+ if (body?.query && !userSdk.core.isSupportedUserSearch(body.query)) {
202
+ ctx.throw(501, "Can only search by string.email or equal._id")
203
+ }
204
+
205
+ if (body.paginate === false) {
201
206
  await getAppUsers(ctx)
202
207
  } else {
203
208
  const paginated = await userSdk.core.paginatedUsers(body)
@@ -544,6 +544,36 @@ describe("/api/global/users", () => {
544
544
  })
545
545
  })
546
546
 
547
+ describe("POST /api/global/users/search", () => {
548
+ it("should be able to search by email", async () => {
549
+ const user = await config.createUser()
550
+ const response = await config.api.users.searchUsers({
551
+ query: { string: { email: user.email } },
552
+ })
553
+ expect(response.body.data.length).toBe(1)
554
+ expect(response.body.data[0].email).toBe(user.email)
555
+ })
556
+
557
+ it("should be able to search by _id", async () => {
558
+ const user = await config.createUser()
559
+ const response = await config.api.users.searchUsers({
560
+ query: { equal: { _id: user._id } },
561
+ })
562
+ expect(response.body.data.length).toBe(1)
563
+ expect(response.body.data[0]._id).toBe(user._id)
564
+ })
565
+
566
+ it("should throw an error when unimplemented options used", async () => {
567
+ const user = await config.createUser()
568
+ await config.api.users.searchUsers(
569
+ {
570
+ query: { equal: { firstName: user.firstName } },
571
+ },
572
+ 501
573
+ )
574
+ })
575
+ })
576
+
547
577
  describe("DELETE /api/global/users/:userId", () => {
548
578
  it("should be able to destroy a basic user", async () => {
549
579
  const user = await config.createUser()
@@ -4,6 +4,7 @@ import {
4
4
  InviteUsersRequest,
5
5
  User,
6
6
  CreateAdminUserRequest,
7
+ SearchQuery,
7
8
  } from "@budibase/types"
8
9
  import structures from "../structures"
9
10
  import { generator } from "@budibase/backend-core/tests"
@@ -133,6 +134,15 @@ export class UserAPI extends TestAPI {
133
134
  .expect(status ? status : 200)
134
135
  }
135
136
 
137
+ searchUsers = ({ query }: { query?: SearchQuery }, status = 200) => {
138
+ return this.request
139
+ .post("/api/global/users/search")
140
+ .set(this.config.defaultHeaders())
141
+ .send({ query })
142
+ .expect("Content-Type", /json/)
143
+ .expect(status ? status : 200)
144
+ }
145
+
136
146
  getUser = (userId: string, opts?: TestAPIOpts) => {
137
147
  return this.request
138
148
  .get(`/api/global/users/${userId}`)