@budibase/backend-core 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/dist/index.js CHANGED
@@ -6262,6 +6262,7 @@ __export(users_exports3, {
6262
6262
  isAdminOrBuilder: () => isAdminOrBuilder2,
6263
6263
  isBuilder: () => isBuilder2,
6264
6264
  isGlobalBuilder: () => isGlobalBuilder2,
6265
+ isSupportedUserSearch: () => isSupportedUserSearch,
6265
6266
  paginatedUsers: () => paginatedUsers,
6266
6267
  removePortalUserPermissions: () => removePortalUserPermissions,
6267
6268
  searchExistingEmails: () => searchExistingEmails,
@@ -6273,6 +6274,7 @@ __export(users_exports3, {
6273
6274
 
6274
6275
  // src/users/users.ts
6275
6276
  init_db4();
6277
+ init_src();
6276
6278
  init_context2();
6277
6279
  init_context2();
6278
6280
  function removeUserPassword(users) {
@@ -6289,6 +6291,28 @@ function removeUserPassword(users) {
6289
6291
  }
6290
6292
  return users;
6291
6293
  }
6294
+ var isSupportedUserSearch = (query) => {
6295
+ const allowed = [
6296
+ { op: "string" /* STRING */, key: "email" },
6297
+ { op: "equal" /* EQUAL */, key: "_id" }
6298
+ ];
6299
+ for (let [key, operation] of Object.entries(query)) {
6300
+ if (typeof operation !== "object") {
6301
+ return false;
6302
+ }
6303
+ const fields = Object.keys(operation || {});
6304
+ if (fields.length === 0) {
6305
+ continue;
6306
+ }
6307
+ const allowedOperation = allowed.find(
6308
+ (allow) => allow.op === key && fields.length === 1 && fields[0] === allow.key
6309
+ );
6310
+ if (!allowedOperation) {
6311
+ return false;
6312
+ }
6313
+ }
6314
+ return true;
6315
+ };
6292
6316
  var bulkGetGlobalUsersById = async (userIds, opts) => {
6293
6317
  const db = getGlobalDB();
6294
6318
  let users = (await db.allDocs({
@@ -6414,8 +6438,8 @@ var searchGlobalUsersByEmail = async (email, opts, getOpts) => {
6414
6438
  };
6415
6439
  var PAGE_LIMIT = 8;
6416
6440
  var paginatedUsers = async ({
6417
- page,
6418
- email,
6441
+ bookmark,
6442
+ query,
6419
6443
  appId
6420
6444
  } = {}) => {
6421
6445
  const db = getGlobalDB();
@@ -6423,15 +6447,17 @@ var paginatedUsers = async ({
6423
6447
  include_docs: true,
6424
6448
  limit: PAGE_LIMIT + 1
6425
6449
  };
6426
- if (page) {
6427
- opts.startkey = page;
6450
+ if (bookmark) {
6451
+ opts.startkey = bookmark;
6428
6452
  }
6429
6453
  let userList, property = "_id", getKey;
6430
- if (appId) {
6454
+ if (query?.equal?._id) {
6455
+ userList = [await getById(query.equal._id)];
6456
+ } else if (appId) {
6431
6457
  userList = await searchGlobalUsersByApp(appId, opts);
6432
6458
  getKey = (doc) => getGlobalUserByAppPage(appId, doc);
6433
- } else if (email) {
6434
- userList = await searchGlobalUsersByEmail(email, opts);
6459
+ } else if (query?.string?.email) {
6460
+ userList = await searchGlobalUsersByEmail(query?.string?.email, opts);
6435
6461
  property = "email";
6436
6462
  } else {
6437
6463
  const response = await db.allDocs(getGlobalUserParams(null, opts));