@7365admin1/core 3.99.1-staging.374 → 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
+ Dashboard: a deleted work order (`status: "deleted"` in `work-orders2`) no longer counts as open on the Open Work Order tile, its trend, the activity chart, or as pending in the Work Order Status bar. The filters listed only "Deleted"; both spellings are now excluded.
@@ -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;
@@ -86281,6 +86280,8 @@ var Period = /* @__PURE__ */ ((Period2) => {
86281
86280
  Period2["THIS_MONTH"] = "thisMonth";
86282
86281
  return Period2;
86283
86282
  })(Period || {});
86283
+ var WORK_ORDER_DELETED = ["Deleted", "deleted"];
86284
+ var WORK_ORDER_NOT_OPEN = ["Completed", ...WORK_ORDER_DELETED];
86284
86285
  function useNewDashboardRepo() {
86285
86286
  const db2 = import_node_server_utils252.useAtlas.getDb();
86286
86287
  if (!db2) {
@@ -86382,7 +86383,7 @@ function useNewDashboardRepo() {
86382
86383
  $match: {
86383
86384
  site: { $in: [siteIdObj, siteId] },
86384
86385
  service: "Security",
86385
- status: { $nin: ["Completed", "Deleted"] }
86386
+ status: { $nin: WORK_ORDER_NOT_OPEN }
86386
86387
  }
86387
86388
  },
86388
86389
  {
@@ -86414,7 +86415,7 @@ function useNewDashboardRepo() {
86414
86415
  site: { $in: [siteIdObj, siteId] },
86415
86416
  service: "Security",
86416
86417
  createdAt: priorPeriodRange,
86417
- status: { $nin: ["Completed", "Deleted"] }
86418
+ status: { $nin: WORK_ORDER_NOT_OPEN }
86418
86419
  }
86419
86420
  },
86420
86421
  { $count: "count" }
@@ -86425,7 +86426,7 @@ function useNewDashboardRepo() {
86425
86426
  site: { $in: [siteIdObj, siteId] },
86426
86427
  service: "Security",
86427
86428
  createdAt: periodRange,
86428
- status: { $nin: ["Completed", "Deleted"] }
86429
+ status: { $nin: WORK_ORDER_NOT_OPEN }
86429
86430
  }
86430
86431
  },
86431
86432
  { $count: "count" }
@@ -86785,7 +86786,7 @@ function useNewDashboardRepo() {
86785
86786
  {
86786
86787
  $match: {
86787
86788
  site: { $in: [siteIdObj, siteId] },
86788
- status: { $nin: ["Completed", "Deleted"] }
86789
+ status: { $nin: WORK_ORDER_NOT_OPEN }
86789
86790
  }
86790
86791
  },
86791
86792
  {
@@ -86816,7 +86817,7 @@ function useNewDashboardRepo() {
86816
86817
  $match: {
86817
86818
  site: { $in: [siteIdObj, siteId] },
86818
86819
  createdAt: priorPeriodRange,
86819
- status: { $nin: ["Completed", "Deleted"] }
86820
+ status: { $nin: WORK_ORDER_NOT_OPEN }
86820
86821
  }
86821
86822
  },
86822
86823
  { $count: "count" }
@@ -86826,7 +86827,7 @@ function useNewDashboardRepo() {
86826
86827
  $match: {
86827
86828
  site: { $in: [siteIdObj, siteId] },
86828
86829
  createdAt: periodRange,
86829
- status: { $nin: ["Completed", "Deleted"] }
86830
+ status: { $nin: WORK_ORDER_NOT_OPEN }
86830
86831
  }
86831
86832
  },
86832
86833
  { $count: "count" }
@@ -87010,7 +87011,8 @@ function useNewDashboardRepo() {
87010
87011
  {
87011
87012
  $match: {
87012
87013
  site: { $in: [siteIdObj, siteId] },
87013
- createdAt: periodRange
87014
+ createdAt: periodRange,
87015
+ status: { $nin: WORK_ORDER_DELETED }
87014
87016
  }
87015
87017
  },
87016
87018
  {
@@ -87172,7 +87174,7 @@ function useNewDashboardRepo() {
87172
87174
  const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
87173
87175
  const workOrderMatchQuery = {
87174
87176
  site,
87175
- status: { $nin: ["Completed", "Deleted"] }
87177
+ status: { $nin: WORK_ORDER_NOT_OPEN }
87176
87178
  };
87177
87179
  if (serviceType !== "property_management_agency") {
87178
87180
  workOrderMatchQuery.service = workOrderService;
@@ -87348,7 +87350,7 @@ function useNewDashboardRepo() {
87348
87350
  try {
87349
87351
  const workOrderQuery = {
87350
87352
  site,
87351
- status: { $nin: ["Deleted"] },
87353
+ status: { $nin: WORK_ORDER_DELETED },
87352
87354
  $or: [
87353
87355
  { createdAt: { $gte: rangeStart, $lte: rangeEnd } },
87354
87356
  {