@7365admin1/core 3.102.1 → 3.102.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/core
2
2
 
3
+ ## 3.102.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 4666dc3: `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.
8
+
3
9
  ## 3.102.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -6531,6 +6531,17 @@ function MOrg(value) {
6531
6531
 
6532
6532
  // src/repositories/organization.repo.ts
6533
6533
  var import_mongodb20 = require("mongodb");
6534
+
6535
+ // src/utils/org-search.util.ts
6536
+ function orgSearchMatch(search) {
6537
+ const term = typeof search === "string" ? search.trim() : "";
6538
+ if (!term)
6539
+ return null;
6540
+ const pattern = { $regex: term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $options: "i" };
6541
+ return { $or: [{ name: pattern }, { email: pattern }] };
6542
+ }
6543
+
6544
+ // src/repositories/organization.repo.ts
6534
6545
  var DUPLICATE_FIELD_LABEL = {
6535
6546
  name: "name",
6536
6547
  email: "email address"
@@ -6692,9 +6703,10 @@ function useOrgRepo() {
6692
6703
  query2.$or = reach;
6693
6704
  cacheOptions.scope = `${ids2.join(",")}|${email.toLowerCase()}`;
6694
6705
  }
6695
- if (search) {
6696
- query2.$text = { $search: search };
6697
- cacheOptions.search = search;
6706
+ const searchMatch2 = orgSearchMatch(search);
6707
+ if (searchMatch2) {
6708
+ query2.$and = [searchMatch2];
6709
+ cacheOptions.substring = search.trim().toLowerCase();
6698
6710
  }
6699
6711
  if (nature) {
6700
6712
  query2.nature = nature;
@@ -6956,22 +6968,9 @@ function useOrgRepo() {
6956
6968
  const query2 = {
6957
6969
  status
6958
6970
  };
6959
- if (search) {
6960
- query2.$or = [
6961
- {
6962
- name: {
6963
- $regex: search,
6964
- $options: "i"
6965
- }
6966
- },
6967
- {
6968
- email: {
6969
- $regex: search,
6970
- $options: "i"
6971
- }
6972
- }
6973
- ];
6974
- }
6971
+ const searchMatch2 = orgSearchMatch(search);
6972
+ if (searchMatch2)
6973
+ query2.$or = searchMatch2.$or;
6975
6974
  const subscriptionMatch = {};
6976
6975
  if (type) {
6977
6976
  subscriptionMatch["subscription.type"] = type;