@7365admin1/core 3.102.0 → 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/dist/index.mjs CHANGED
@@ -5593,6 +5593,17 @@ function MOrg(value) {
5593
5593
 
5594
5594
  // src/repositories/organization.repo.ts
5595
5595
  import { ObjectId as ObjectId20 } from "mongodb";
5596
+
5597
+ // src/utils/org-search.util.ts
5598
+ function orgSearchMatch(search) {
5599
+ const term = typeof search === "string" ? search.trim() : "";
5600
+ if (!term)
5601
+ return null;
5602
+ const pattern = { $regex: term.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), $options: "i" };
5603
+ return { $or: [{ name: pattern }, { email: pattern }] };
5604
+ }
5605
+
5606
+ // src/repositories/organization.repo.ts
5596
5607
  var DUPLICATE_FIELD_LABEL = {
5597
5608
  name: "name",
5598
5609
  email: "email address"
@@ -5754,9 +5765,10 @@ function useOrgRepo() {
5754
5765
  query2.$or = reach;
5755
5766
  cacheOptions.scope = `${ids2.join(",")}|${email.toLowerCase()}`;
5756
5767
  }
5757
- if (search) {
5758
- query2.$text = { $search: search };
5759
- cacheOptions.search = search;
5768
+ const searchMatch2 = orgSearchMatch(search);
5769
+ if (searchMatch2) {
5770
+ query2.$and = [searchMatch2];
5771
+ cacheOptions.substring = search.trim().toLowerCase();
5760
5772
  }
5761
5773
  if (nature) {
5762
5774
  query2.nature = nature;
@@ -6018,22 +6030,9 @@ function useOrgRepo() {
6018
6030
  const query2 = {
6019
6031
  status
6020
6032
  };
6021
- if (search) {
6022
- query2.$or = [
6023
- {
6024
- name: {
6025
- $regex: search,
6026
- $options: "i"
6027
- }
6028
- },
6029
- {
6030
- email: {
6031
- $regex: search,
6032
- $options: "i"
6033
- }
6034
- }
6035
- ];
6036
- }
6033
+ const searchMatch2 = orgSearchMatch(search);
6034
+ if (searchMatch2)
6035
+ query2.$or = searchMatch2.$or;
6037
6036
  const subscriptionMatch = {};
6038
6037
  if (type) {
6039
6038
  subscriptionMatch["subscription.type"] = type;
@@ -84108,6 +84107,8 @@ var Period = /* @__PURE__ */ ((Period2) => {
84108
84107
  Period2["THIS_MONTH"] = "thisMonth";
84109
84108
  return Period2;
84110
84109
  })(Period || {});
84110
+ var WORK_ORDER_DELETED = ["Deleted", "deleted"];
84111
+ var WORK_ORDER_NOT_OPEN = ["Completed", ...WORK_ORDER_DELETED];
84111
84112
  function useNewDashboardRepo() {
84112
84113
  const db2 = useAtlas124.getDb();
84113
84114
  if (!db2) {
@@ -84209,7 +84210,7 @@ function useNewDashboardRepo() {
84209
84210
  $match: {
84210
84211
  site: { $in: [siteIdObj, siteId] },
84211
84212
  service: "Security",
84212
- status: { $nin: ["Completed", "Deleted"] }
84213
+ status: { $nin: WORK_ORDER_NOT_OPEN }
84213
84214
  }
84214
84215
  },
84215
84216
  {
@@ -84241,7 +84242,7 @@ function useNewDashboardRepo() {
84241
84242
  site: { $in: [siteIdObj, siteId] },
84242
84243
  service: "Security",
84243
84244
  createdAt: priorPeriodRange,
84244
- status: { $nin: ["Completed", "Deleted"] }
84245
+ status: { $nin: WORK_ORDER_NOT_OPEN }
84245
84246
  }
84246
84247
  },
84247
84248
  { $count: "count" }
@@ -84252,7 +84253,7 @@ function useNewDashboardRepo() {
84252
84253
  site: { $in: [siteIdObj, siteId] },
84253
84254
  service: "Security",
84254
84255
  createdAt: periodRange,
84255
- status: { $nin: ["Completed", "Deleted"] }
84256
+ status: { $nin: WORK_ORDER_NOT_OPEN }
84256
84257
  }
84257
84258
  },
84258
84259
  { $count: "count" }
@@ -84612,7 +84613,7 @@ function useNewDashboardRepo() {
84612
84613
  {
84613
84614
  $match: {
84614
84615
  site: { $in: [siteIdObj, siteId] },
84615
- status: { $nin: ["Completed", "Deleted"] }
84616
+ status: { $nin: WORK_ORDER_NOT_OPEN }
84616
84617
  }
84617
84618
  },
84618
84619
  {
@@ -84643,7 +84644,7 @@ function useNewDashboardRepo() {
84643
84644
  $match: {
84644
84645
  site: { $in: [siteIdObj, siteId] },
84645
84646
  createdAt: priorPeriodRange,
84646
- status: { $nin: ["Completed", "Deleted"] }
84647
+ status: { $nin: WORK_ORDER_NOT_OPEN }
84647
84648
  }
84648
84649
  },
84649
84650
  { $count: "count" }
@@ -84653,7 +84654,7 @@ function useNewDashboardRepo() {
84653
84654
  $match: {
84654
84655
  site: { $in: [siteIdObj, siteId] },
84655
84656
  createdAt: periodRange,
84656
- status: { $nin: ["Completed", "Deleted"] }
84657
+ status: { $nin: WORK_ORDER_NOT_OPEN }
84657
84658
  }
84658
84659
  },
84659
84660
  { $count: "count" }
@@ -84837,7 +84838,8 @@ function useNewDashboardRepo() {
84837
84838
  {
84838
84839
  $match: {
84839
84840
  site: { $in: [siteIdObj, siteId] },
84840
- createdAt: periodRange
84841
+ createdAt: periodRange,
84842
+ status: { $nin: WORK_ORDER_DELETED }
84841
84843
  }
84842
84844
  },
84843
84845
  {
@@ -84999,7 +85001,7 @@ function useNewDashboardRepo() {
84999
85001
  const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
85000
85002
  const workOrderMatchQuery = {
85001
85003
  site,
85002
- status: { $nin: ["Completed", "Deleted"] }
85004
+ status: { $nin: WORK_ORDER_NOT_OPEN }
85003
85005
  };
85004
85006
  if (serviceType !== "property_management_agency") {
85005
85007
  workOrderMatchQuery.service = workOrderService;
@@ -85175,7 +85177,7 @@ function useNewDashboardRepo() {
85175
85177
  try {
85176
85178
  const workOrderQuery = {
85177
85179
  site,
85178
- status: { $nin: ["Deleted"] },
85180
+ status: { $nin: WORK_ORDER_DELETED },
85179
85181
  $or: [
85180
85182
  { createdAt: { $gte: rangeStart, $lte: rangeEnd } },
85181
85183
  {