@7365admin1/core 3.99.1-staging.375 → 3.99.1-staging.376

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ `GET /api/organizations?search=` now matches part of a client's name or e-mail, case-insensitively (escaped, so regex characters are literal). It was a whole-word `$text` search, so typing part of a name found nothing and a full name returned unrelated clients - the Super Admin Client details picker looked broken. The non-staff scope is still ANDed in.
package/dist/index.js CHANGED
@@ -6582,6 +6582,17 @@ function MOrg(value) {
6582
6582
 
6583
6583
  // src/repositories/organization.repo.ts
6584
6584
  var import_mongodb20 = require("mongodb");
6585
+
6586
+ // src/utils/org-search.util.ts
6587
+ function orgSearchMatch(search) {
6588
+ const term = typeof search === "string" ? search.trim() : "";
6589
+ if (!term)
6590
+ return null;
6591
+ const pattern = { $regex: term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $options: "i" };
6592
+ return { $or: [{ name: pattern }, { email: pattern }] };
6593
+ }
6594
+
6595
+ // src/repositories/organization.repo.ts
6585
6596
  var DUPLICATE_FIELD_LABEL = {
6586
6597
  name: "name",
6587
6598
  email: "email address"
@@ -6743,9 +6754,10 @@ function useOrgRepo() {
6743
6754
  query2.$or = reach;
6744
6755
  cacheOptions.scope = `${ids2.join(",")}|${email.toLowerCase()}`;
6745
6756
  }
6746
- if (search) {
6747
- query2.$text = { $search: search };
6748
- cacheOptions.search = search;
6757
+ const searchMatch2 = orgSearchMatch(search);
6758
+ if (searchMatch2) {
6759
+ query2.$and = [searchMatch2];
6760
+ cacheOptions.substring = search.trim().toLowerCase();
6749
6761
  }
6750
6762
  if (nature) {
6751
6763
  query2.nature = nature;
@@ -7007,22 +7019,9 @@ function useOrgRepo() {
7007
7019
  const query2 = {
7008
7020
  status
7009
7021
  };
7010
- if (search) {
7011
- query2.$or = [
7012
- {
7013
- name: {
7014
- $regex: search,
7015
- $options: "i"
7016
- }
7017
- },
7018
- {
7019
- email: {
7020
- $regex: search,
7021
- $options: "i"
7022
- }
7023
- }
7024
- ];
7025
- }
7022
+ const searchMatch2 = orgSearchMatch(search);
7023
+ if (searchMatch2)
7024
+ query2.$or = searchMatch2.$or;
7026
7025
  const subscriptionMatch = {};
7027
7026
  if (type) {
7028
7027
  subscriptionMatch["subscription.type"] = type;