@7365admin1/core 3.136.2 → 3.138.0

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
@@ -8723,6 +8723,9 @@ function serviceProviderNatureFor(app) {
8723
8723
  const nature = PROVIDER_NATURE_ALIASES[key] ?? key;
8724
8724
  return nature !== "property_management_agency" && SERVICE_TYPE_LABELS[nature] ? nature : "";
8725
8725
  }
8726
+ function sanitizeCompanyName(value) {
8727
+ return String(value ?? "").replace(/[\u0000-\u001f\u007f<>]/g, " ").replace(/\s+/g, " ").trim().slice(0, 120).trim();
8728
+ }
8726
8729
 
8727
8730
  // src/utils/invite-actor.util.ts
8728
8731
  import { useAtlas as useAtlas17 } from "@7365admin1/node-server-utils";
@@ -9065,7 +9068,8 @@ import {
9065
9068
  getDirectory,
9066
9069
  logger as logger36,
9067
9070
  useMailer as useMailer2,
9068
- useAtlas as useAtlas38
9071
+ useAtlas as useAtlas38,
9072
+ useCache as useCache21
9069
9073
  } from "@7365admin1/node-server-utils";
9070
9074
  import { ObjectId as ObjectId56 } from "mongodb";
9071
9075
 
@@ -10276,7 +10280,7 @@ function robotFaultText(robotName, fault) {
10276
10280
  }
10277
10281
  return {
10278
10282
  title: "Robot fault",
10279
- body: `${robotName || "A robot"} reports a fault: ${fault.message || fault.code}.`
10283
+ body: `${robotName || "A robot"} reports a fault: ${String(fault.message || fault.code).replace(/\.\s*$/, "")}.`
10280
10284
  };
10281
10285
  }
10282
10286
  function robotConnectionText(robotName, online, minutes) {
@@ -24562,10 +24566,36 @@ function useServiceProviderInviteService() {
24562
24566
  );
24563
24567
  }
24564
24568
  const user = await getUserById(actor.id).catch(() => null);
24565
- const name = String(companyName ?? "").trim() || String(invite.metadata?.name ?? "").trim() || String(user?.name ?? "").trim();
24569
+ const { orgId } = await createProviderCompany({
24570
+ invite,
24571
+ nature,
24572
+ user,
24573
+ companyName,
24574
+ country
24575
+ });
24576
+ const result = await accept({ id, userId: actor.id, org: orgId });
24577
+ return {
24578
+ ...result,
24579
+ orgId,
24580
+ nature,
24581
+ companyName: (await getOrgById(orgId).catch(() => null))?.name ?? "",
24582
+ siteId: invite.metadata?.siteId?.toString?.() ?? "",
24583
+ siteName: String(invite.metadata?.siteName ?? "")
24584
+ };
24585
+ }
24586
+ async function createProviderCompany({
24587
+ invite,
24588
+ nature,
24589
+ user,
24590
+ companyName,
24591
+ country
24592
+ }) {
24593
+ const inviteeId = String(user?._id ?? "");
24594
+ const name = sanitizeCompanyName(companyName) || sanitizeCompanyName(invite.metadata?.name) || sanitizeCompanyName(user?.name);
24566
24595
  if (!name)
24567
24596
  throw new BadRequestError47("Enter your company's name.");
24568
24597
  const email = String(invite.email ?? "").trim().toLowerCase();
24598
+ const actor = { id: inviteeId };
24569
24599
  const orgId = String(
24570
24600
  await addOrg({
24571
24601
  name,
@@ -24607,15 +24637,9 @@ function useServiceProviderInviteService() {
24607
24637
  await useUserRepo().updateUserFieldById({ _id: actor.id, field: "defaultOrg", value: orgId }).catch(() => void 0);
24608
24638
  logger36.log({
24609
24639
  level: "info",
24610
- message: `[sp-invite] invite=${id} new company org=${orgId} nature=${nature}`
24640
+ message: `[sp-invite] invite=${String(invite._id)} new company org=${orgId} nature=${nature}`
24611
24641
  });
24612
- const result = await accept({ id, userId: actor.id, org: orgId });
24613
- return {
24614
- ...result,
24615
- orgId,
24616
- nature,
24617
- siteId: invite.metadata?.siteId?.toString?.() ?? ""
24618
- };
24642
+ return { orgId, name };
24619
24643
  }
24620
24644
  async function wrongJoinContext(id, userId) {
24621
24645
  const actor = await actorFor(userId);
@@ -24684,7 +24708,8 @@ function useServiceProviderInviteService() {
24684
24708
  async function repairWrongJoin({ id, userId }) {
24685
24709
  const { actor, invite, senderOrg, user } = await wrongJoinContext(id, userId);
24686
24710
  const rows = await wrongJoinRows(invite, senderOrg, user);
24687
- if (!rows.length) {
24711
+ const defaultOrgIsSender = !!user?._id && String(user?.defaultOrg ?? "") === senderOrg;
24712
+ if (!rows.length && !defaultOrgIsSender) {
24688
24713
  return {
24689
24714
  message: "Nothing to repair: this account is not in the sender's organisation.",
24690
24715
  changed: 0
@@ -24693,12 +24718,15 @@ function useServiceProviderInviteService() {
24693
24718
  const { updateMemberStatus } = useMemberRepo();
24694
24719
  for (const row of rows)
24695
24720
  await updateMemberStatus(row._id, { status: "inactive" });
24721
+ if (defaultOrgIsSender)
24722
+ await setDefaultOrg(String(user._id), "");
24696
24723
  await _transition({
24697
24724
  id,
24698
24725
  from: [],
24699
24726
  event: {
24700
24727
  ...event("wrong-join-repaired", actor),
24701
- memberIds: rows.map((row) => row._id)
24728
+ memberIds: rows.map((row) => row._id),
24729
+ ...defaultOrgIsSender ? { defaultOrgWas: senderOrg } : {}
24702
24730
  }
24703
24731
  });
24704
24732
  logger36.log({
@@ -24719,12 +24747,170 @@ function useServiceProviderInviteService() {
24719
24747
  const ids2 = (repaired.memberIds ?? []).filter((m) => ObjectId56.isValid(m));
24720
24748
  for (const m of ids2)
24721
24749
  await updateMemberStatus(m, { status: "active" }).catch(() => 0);
24750
+ const { user } = await wrongJoinContext(id, userId);
24751
+ if (repaired.defaultOrgWas && user?._id && !String(user.defaultOrg ?? "")) {
24752
+ await setDefaultOrg(String(user._id), String(repaired.defaultOrgWas));
24753
+ }
24722
24754
  await _transition({ id, from: [], event: event("wrong-join-undone", actor) });
24723
24755
  return {
24724
24756
  message: `Undone: ${ids2.length} membership${ids2.length === 1 ? "" : "s"} active again.`,
24725
24757
  changed: ids2.length
24726
24758
  };
24727
24759
  }
24760
+ async function setDefaultOrg(userId, orgId) {
24761
+ if (!orgId) {
24762
+ await useAtlas38.getDb()?.collection("users").updateOne(
24763
+ { _id: new ObjectId56(userId) },
24764
+ { $unset: { defaultOrg: "" }, $set: { updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
24765
+ );
24766
+ await useCache21("users").delNamespace().catch(() => void 0);
24767
+ return;
24768
+ }
24769
+ await useUserRepo().updateUserFieldById({ _id: userId, field: "defaultOrg", value: orgId }).catch(() => void 0);
24770
+ }
24771
+ async function finishSetupContext(id, userId) {
24772
+ const ctx = await wrongJoinContext(id, userId);
24773
+ const { invite, user, senderOrg } = ctx;
24774
+ const nature = serviceProviderNatureFor(invite.metadata?.app);
24775
+ const existing = user?._id && nature ? await getByCreatorAndNature(String(user._id), nature).catch(() => null) : null;
24776
+ const stillInSender = await wrongJoinRows(invite, senderOrg, user);
24777
+ let blocked = "";
24778
+ if (!user?._id) {
24779
+ blocked = "This email has no account yet. The invitee signs up from the invitation email.";
24780
+ } else if (!nature) {
24781
+ blocked = "This invitation does not say which service the company provides.";
24782
+ } else if (invite.deletedAt) {
24783
+ blocked = "This invitation was deleted by the sender.";
24784
+ } else if (invite.status === "awaiting-approval" /* AWAITING_APPROVAL */) {
24785
+ blocked = "Approve the invitation first.";
24786
+ } else if (invite.status !== "pending" /* PENDING */) {
24787
+ blocked = `This invitation is ${serviceProviderInviteLabel(invite.status)}, not waiting for an answer.`;
24788
+ } else if (isServiceProviderInviteExpired(invite)) {
24789
+ blocked = "This invitation has expired. Press Resend email first.";
24790
+ } else if (stillInSender.length) {
24791
+ blocked = "The account is still inside the sender's organisation. Press Check account, then Repair, first.";
24792
+ }
24793
+ return { ...ctx, nature, existing, blocked };
24794
+ }
24795
+ function lastFinishSetup(invite) {
24796
+ const history = invite.history ?? [];
24797
+ const last = [...history].reverse().find((e) => ["finish-setup-applied", "finish-setup-undone"].includes(e?.action));
24798
+ return last?.action === "finish-setup-applied" ? last : null;
24799
+ }
24800
+ async function finishSetupPreview({
24801
+ id,
24802
+ userId,
24803
+ companyName
24804
+ }) {
24805
+ const { invite, user, senderOrg, nature, existing, blocked } = await finishSetupContext(id, userId);
24806
+ const [sender, currentDefault] = await Promise.all([
24807
+ getOrgById(senderOrg).catch(() => null),
24808
+ user?.defaultOrg ? getOrgById(String(user.defaultOrg)).catch(() => null) : null
24809
+ ]);
24810
+ const applied = lastFinishSetup(invite);
24811
+ return {
24812
+ invitationId: id,
24813
+ email: String(invite.email ?? ""),
24814
+ account: user?._id ? String(user.name || user.email || "") : "",
24815
+ service: nature,
24816
+ serviceLabel: nature ? serviceTypeLabel(nature) : "",
24817
+ senderOrgName: String(sender?.name ?? ""),
24818
+ siteName: String(invite.metadata?.siteName ?? ""),
24819
+ companyName: existing ? String(existing.name ?? "") : sanitizeCompanyName(companyName) || sanitizeCompanyName(invite.metadata?.name) || sanitizeCompanyName(user?.name),
24820
+ usesExistingCompany: !!existing,
24821
+ currentDefaultOrgName: String(currentDefault?.name ?? ""),
24822
+ status: String(invite.status ?? ""),
24823
+ canApply: !blocked,
24824
+ blocked,
24825
+ applied: applied ? { at: applied.at, by: applied.byName, orgId: applied.orgId, companyName: applied.companyName } : null
24826
+ };
24827
+ }
24828
+ async function finishSetupApply({
24829
+ id,
24830
+ userId,
24831
+ companyName,
24832
+ country
24833
+ }) {
24834
+ const { actor, invite, user, nature, existing, blocked } = await finishSetupContext(id, userId);
24835
+ if (blocked)
24836
+ throw new BadRequestError47(blocked);
24837
+ const defaultOrgWas = String(user.defaultOrg ?? "");
24838
+ let orgId = existing ? String(existing._id) : "";
24839
+ let name = existing ? String(existing.name ?? "") : "";
24840
+ if (!orgId) {
24841
+ ({ orgId, name } = await createProviderCompany({ invite, nature, user, companyName, country }));
24842
+ } else {
24843
+ await setDefaultOrg(String(user._id), orgId);
24844
+ }
24845
+ const result = await useCustomerSiteService().addViaInvite(
24846
+ id,
24847
+ { id: actor.id, name: actor.name },
24848
+ orgId
24849
+ );
24850
+ await _transition({
24851
+ id,
24852
+ from: [],
24853
+ event: {
24854
+ ...event("finish-setup-applied", actor),
24855
+ orgId,
24856
+ companyName: name,
24857
+ created: !existing,
24858
+ defaultOrgWas
24859
+ }
24860
+ });
24861
+ if (result.accepted)
24862
+ await notifyInviter(invite, true, name);
24863
+ const siteName = String(invite.metadata?.siteName ?? "");
24864
+ logger36.log({
24865
+ level: "info",
24866
+ message: `[sp-invite] finish-setup invite=${id} org=${orgId} created=${!existing} by=${actor.id}`
24867
+ });
24868
+ return {
24869
+ message: `${name} is set up and linked to ${siteName || "the site"}.`,
24870
+ orgId,
24871
+ companyName: name,
24872
+ nature,
24873
+ created: !existing
24874
+ };
24875
+ }
24876
+ async function finishSetupUndo({ id, userId }) {
24877
+ const { actor, invite, user } = await wrongJoinContext(id, userId);
24878
+ const applied = lastFinishSetup(invite);
24879
+ if (!applied)
24880
+ throw new BadRequestError47("There is no Finish setup to undo on this invitation.");
24881
+ const orgId = String(applied.orgId ?? "");
24882
+ const siteId = invite.metadata?.siteId?.toString?.() ?? "";
24883
+ const db2 = useAtlas38.getDb();
24884
+ if (!db2 || !ObjectId56.isValid(orgId))
24885
+ throw new BadRequestError47("Nothing to undo.");
24886
+ if (ObjectId56.isValid(siteId)) {
24887
+ await db2.collection("customer.sites").updateMany(
24888
+ { org: new ObjectId56(orgId), site: new ObjectId56(siteId), status: "active" },
24889
+ { $set: { status: "inactive", updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
24890
+ );
24891
+ await useCache21("customer.sites").delNamespace().catch(() => void 0);
24892
+ }
24893
+ if (applied.created) {
24894
+ const { updateMemberStatus } = useMemberRepo();
24895
+ const members = await db2.collection("members").find({ org: { $in: [new ObjectId56(orgId), orgId] }, status: "active" }).toArray();
24896
+ for (const m of members) {
24897
+ await updateMemberStatus(m._id.toString(), { status: "inactive" });
24898
+ }
24899
+ await useOrgRepo().updateStatusById(orgId, "deleted").catch(() => void 0);
24900
+ }
24901
+ if (user?._id && String(user.defaultOrg ?? "") === orgId) {
24902
+ await setDefaultOrg(String(user._id), String(applied.defaultOrgWas ?? ""));
24903
+ }
24904
+ await _transition({
24905
+ id,
24906
+ from: ["complete" /* COMPLETE */],
24907
+ to: "pending" /* PENDING */,
24908
+ event: event("finish-setup-undone", actor)
24909
+ });
24910
+ return {
24911
+ message: "Undone: the site is off the company's list and the invitation is open again."
24912
+ };
24913
+ }
24728
24914
  async function notifyInviter(invite, accepted, providerName) {
24729
24915
  try {
24730
24916
  const to = invite.metadata?.invitedBy?.toString?.() ?? "";
@@ -24938,6 +25124,9 @@ function useServiceProviderInviteService() {
24938
25124
  wrongJoinPreview,
24939
25125
  repairWrongJoin,
24940
25126
  undoWrongJoin,
25127
+ finishSetupPreview,
25128
+ finishSetupApply,
25129
+ finishSetupUndo,
24941
25130
  linkSite,
24942
25131
  listReceived,
24943
25132
  getForProvider,
@@ -26024,7 +26213,7 @@ import {
26024
26213
  makeCacheKey as makeCacheKey17,
26025
26214
  paginate as paginate19,
26026
26215
  useAtlas as useAtlas41,
26027
- useCache as useCache21,
26216
+ useCache as useCache22,
26028
26217
  AppError as AppError12,
26029
26218
  toObjectId as toObjectId9
26030
26219
  } from "@7365admin1/node-server-utils";
@@ -26047,7 +26236,7 @@ function usePersonRepo() {
26047
26236
  }
26048
26237
  const collection = db2.collection(site_people_namespace_collection);
26049
26238
  const vehiclesCollection = db2.collection("vehicles");
26050
- const { delNamespace, getCache, setCache } = useCache21(
26239
+ const { delNamespace, getCache, setCache } = useCache22(
26051
26240
  site_people_namespace_collection
26052
26241
  );
26053
26242
  async function withoutDeletedPlates(people) {
@@ -29941,7 +30130,7 @@ import {
29941
30130
  makeCacheKey as makeCacheKey18,
29942
30131
  paginate as paginate20,
29943
30132
  useAtlas as useAtlas47,
29944
- useCache as useCache22
30133
+ useCache as useCache23
29945
30134
  } from "@7365admin1/node-server-utils";
29946
30135
 
29947
30136
  // src/models/subscription.model.ts
@@ -30103,7 +30292,7 @@ function useSubscriptionRepo() {
30103
30292
  );
30104
30293
  }
30105
30294
  }
30106
- const { delNamespace, setCache, getCache, delCache } = useCache22(namespace_collection3);
30295
+ const { delNamespace, setCache, getCache, delCache } = useCache23(namespace_collection3);
30107
30296
  async function add(value, session) {
30108
30297
  try {
30109
30298
  value = MSubscription(value);
@@ -31758,7 +31947,7 @@ import {
31758
31947
  logger as logger49,
31759
31948
  makeCacheKey as makeCacheKey19,
31760
31949
  useAtlas as useAtlas49,
31761
- useCache as useCache23
31950
+ useCache as useCache24
31762
31951
  } from "@7365admin1/node-server-utils";
31763
31952
 
31764
31953
  // src/models/address.model.ts
@@ -31809,7 +31998,7 @@ function useAddressRepo() {
31809
31998
  throw new InternalServerError28("Failed to create index on address.");
31810
31999
  }
31811
32000
  }
31812
- const { delNamespace, getCache, setCache } = useCache23(namespace_collection3);
32001
+ const { delNamespace, getCache, setCache } = useCache24(namespace_collection3);
31813
32002
  async function add(value, session) {
31814
32003
  try {
31815
32004
  value = MAddress(value);
@@ -31867,7 +32056,7 @@ import {
31867
32056
  NotFoundError as NotFoundError21,
31868
32057
  paginate as paginate21,
31869
32058
  useAtlas as useAtlas50,
31870
- useCache as useCache24
32059
+ useCache as useCache25
31871
32060
  } from "@7365admin1/node-server-utils";
31872
32061
 
31873
32062
  // src/models/promo-code.model.ts
@@ -32040,7 +32229,7 @@ function usePromoCodeRepo() {
32040
32229
  );
32041
32230
  }
32042
32231
  }
32043
- const { delNamespace, setCache, getCache, delCache } = useCache24(namespace_collection3);
32232
+ const { delNamespace, setCache, getCache, delCache } = useCache25(namespace_collection3);
32044
32233
  async function invalidate(context) {
32045
32234
  try {
32046
32235
  await delNamespace();
@@ -32303,7 +32492,7 @@ import {
32303
32492
  makeCacheKey as makeCacheKey21,
32304
32493
  paginate as paginate22,
32305
32494
  useAtlas as useAtlas51,
32306
- useCache as useCache25
32495
+ useCache as useCache26
32307
32496
  } from "@7365admin1/node-server-utils";
32308
32497
 
32309
32498
  // src/models/invoice.model.ts
@@ -32416,7 +32605,7 @@ function useInvoiceRepo() {
32416
32605
  }
32417
32606
  const namespace_collection3 = "invoices";
32418
32607
  const { collection, createInvoice } = useInvoiceModel(db2);
32419
- const { delNamespace, getCache, setCache } = useCache25(namespace_collection3);
32608
+ const { delNamespace, getCache, setCache } = useCache26(namespace_collection3);
32420
32609
  async function createIndex() {
32421
32610
  try {
32422
32611
  await collection.createIndexes([
@@ -32602,7 +32791,7 @@ import {
32602
32791
  logger as logger52,
32603
32792
  makeCacheKey as makeCacheKey22,
32604
32793
  useAtlas as useAtlas52,
32605
- useCache as useCache26
32794
+ useCache as useCache27
32606
32795
  } from "@7365admin1/node-server-utils";
32607
32796
 
32608
32797
  // src/models/counter.model.ts
@@ -32647,7 +32836,7 @@ function useCounterRepo() {
32647
32836
  }
32648
32837
  const namespace_collection3 = "counters";
32649
32838
  const { collection, createCounter } = useCounterModel(db2);
32650
- const { delNamespace, getCache, setCache } = useCache26(namespace_collection3);
32839
+ const { delNamespace, getCache, setCache } = useCache27(namespace_collection3);
32651
32840
  async function createIndex() {
32652
32841
  try {
32653
32842
  await collection.createIndexes([{ key: { type: 1 } }]);
@@ -32764,7 +32953,7 @@ import {
32764
32953
  makeCacheKey as makeCacheKey23,
32765
32954
  paginate as paginate23,
32766
32955
  useAtlas as useAtlas53,
32767
- useCache as useCache27
32956
+ useCache as useCache28
32768
32957
  } from "@7365admin1/node-server-utils";
32769
32958
 
32770
32959
  // src/models/payment.model.ts
@@ -32897,7 +33086,7 @@ function usePaymentRepo() {
32897
33086
  }
32898
33087
  const namespace_collection3 = "payments";
32899
33088
  const { collection, createPayment } = usePaymentModel(db2);
32900
- const { delNamespace, getCache, setCache } = useCache27(namespace_collection3);
33089
+ const { delNamespace, getCache, setCache } = useCache28(namespace_collection3);
32901
33090
  async function createIndex() {
32902
33091
  try {
32903
33092
  await collection.createIndexes([
@@ -33044,7 +33233,7 @@ import {
33044
33233
  makeCacheKey as makeCacheKey24,
33045
33234
  NotFoundError as NotFoundError22,
33046
33235
  useAtlas as useAtlas54,
33047
- useCache as useCache28
33236
+ useCache as useCache29
33048
33237
  } from "@7365admin1/node-server-utils";
33049
33238
 
33050
33239
  // src/models/price.model.ts
@@ -33120,7 +33309,7 @@ function usePriceRepo() {
33120
33309
  throw new InternalServerError33("Failed to create price unique index.");
33121
33310
  }
33122
33311
  }
33123
- const { delNamespace, setCache, getCache, delCache } = useCache28(namespace_collection3);
33312
+ const { delNamespace, setCache, getCache, delCache } = useCache29(namespace_collection3);
33124
33313
  async function add(value) {
33125
33314
  try {
33126
33315
  value = createPrice(value);
@@ -33928,7 +34117,7 @@ import {
33928
34117
  NotFoundError as NotFoundError23,
33929
34118
  paginate as paginate24,
33930
34119
  useAtlas as useAtlas56,
33931
- useCache as useCache29
34120
+ useCache as useCache30
33932
34121
  } from "@7365admin1/node-server-utils";
33933
34122
 
33934
34123
  // src/models/subscription-plan.model.ts
@@ -33992,7 +34181,7 @@ function useSubscriptionPlanRepo() {
33992
34181
  }
33993
34182
  const namespace_collection3 = "subscription-plans";
33994
34183
  const collection = db2.collection(namespace_collection3);
33995
- const { delNamespace, getCache, setCache } = useCache29(namespace_collection3);
34184
+ const { delNamespace, getCache, setCache } = useCache30(namespace_collection3);
33996
34185
  async function createIndex() {
33997
34186
  try {
33998
34187
  await collection.createIndex([
@@ -36457,7 +36646,7 @@ import {
36457
36646
  BadRequestError as BadRequestError91,
36458
36647
  paginate as paginate26,
36459
36648
  NotFoundError as NotFoundError25,
36460
- useCache as useCache30,
36649
+ useCache as useCache31,
36461
36650
  logger as logger66,
36462
36651
  makeCacheKey as makeCacheKey26
36463
36652
  } from "@7365admin1/node-server-utils";
@@ -36469,7 +36658,7 @@ function useCustomerRepo() {
36469
36658
  }
36470
36659
  const namespace_collection3 = "customers";
36471
36660
  const collection = db2.collection(namespace_collection3);
36472
- const { delNamespace, getCache, setCache } = useCache30(namespace_collection3);
36661
+ const { delNamespace, getCache, setCache } = useCache31(namespace_collection3);
36473
36662
  async function createIndex() {
36474
36663
  try {
36475
36664
  await collection.createIndexes([
@@ -36929,7 +37118,7 @@ import {
36929
37118
  paginate as paginate27,
36930
37119
  toObjectId as toObjectId12,
36931
37120
  useAtlas as useAtlas61,
36932
- useCache as useCache31
37121
+ useCache as useCache32
36933
37122
  } from "@7365admin1/node-server-utils";
36934
37123
 
36935
37124
  // src/models/building.model.ts
@@ -37145,7 +37334,7 @@ function useBuildingUnitRepo() {
37145
37334
  const buildingUnitCollection = db2.collection(
37146
37335
  site_people_namespace_collection
37147
37336
  );
37148
- const { getCache, setCache, delNamespace, delCache } = useCache31(
37337
+ const { getCache, setCache, delNamespace, delCache } = useCache32(
37149
37338
  building_units_namespace_collection
37150
37339
  );
37151
37340
  async function createIndexes() {
@@ -40895,7 +41084,7 @@ function MChat(value) {
40895
41084
  import {
40896
41085
  useAtlas as useAtlas66,
40897
41086
  InternalServerError as InternalServerError37,
40898
- useCache as useCache32,
41087
+ useCache as useCache33,
40899
41088
  logger as logger74
40900
41089
  } from "@7365admin1/node-server-utils";
40901
41090
  function useChatRepo() {
@@ -40905,7 +41094,7 @@ function useChatRepo() {
40905
41094
  }
40906
41095
  const namespace_collection3 = "chats";
40907
41096
  const collection = db2.collection(namespace_collection3);
40908
- const { delNamespace } = useCache32(namespace_collection3);
41097
+ const { delNamespace } = useCache33(namespace_collection3);
40909
41098
  async function createChat(value, session) {
40910
41099
  try {
40911
41100
  value = MChat(value);
@@ -40970,7 +41159,7 @@ import {
40970
41159
  makeCacheKey as makeCacheKey28,
40971
41160
  paginate as paginate28,
40972
41161
  useAtlas as useAtlas67,
40973
- useCache as useCache33
41162
+ useCache as useCache34
40974
41163
  } from "@7365admin1/node-server-utils";
40975
41164
  import { ObjectId as ObjectId86 } from "mongodb";
40976
41165
  var buildings_namespace_collection = "buildings";
@@ -40983,7 +41172,7 @@ function useBuildingRepo() {
40983
41172
  const buildingUnitCollection = db2.collection(
40984
41173
  building_units_namespace_collection
40985
41174
  );
40986
- const { getCache, setCache, delNamespace } = useCache33(
41175
+ const { getCache, setCache, delNamespace } = useCache34(
40987
41176
  buildings_namespace_collection
40988
41177
  );
40989
41178
  async function createIndexes() {
@@ -41716,7 +41905,7 @@ import {
41716
41905
  paginate as paginate29,
41717
41906
  toObjectId as toObjectId14,
41718
41907
  useAtlas as useAtlas68,
41719
- useCache as useCache34
41908
+ useCache as useCache35
41720
41909
  } from "@7365admin1/node-server-utils";
41721
41910
  import { ObjectId as ObjectId88 } from "mongodb";
41722
41911
 
@@ -41798,13 +41987,13 @@ function useBuildingLevelRepo() {
41798
41987
  const buildingUnitCollection = db2.collection(
41799
41988
  building_units_namespace_collection
41800
41989
  );
41801
- const { getCache, setCache, delNamespace, delCache } = useCache34(
41990
+ const { getCache, setCache, delNamespace, delCache } = useCache35(
41802
41991
  building_level_namespace_collection
41803
41992
  );
41804
- const { delNamespace: delBuildingNamespace } = useCache34(
41993
+ const { delNamespace: delBuildingNamespace } = useCache35(
41805
41994
  buildings_namespace_collection
41806
41995
  );
41807
- const { delNamespace: delUnitNamespace } = useCache34(
41996
+ const { delNamespace: delUnitNamespace } = useCache35(
41808
41997
  building_units_namespace_collection
41809
41998
  );
41810
41999
  async function createIndexes() {
@@ -46115,7 +46304,7 @@ import {
46115
46304
  useAtlas as useAtlas72,
46116
46305
  InternalServerError as InternalServerError40,
46117
46306
  BadRequestError as BadRequestError114,
46118
- useCache as useCache35,
46307
+ useCache as useCache36,
46119
46308
  logger as logger87,
46120
46309
  makeCacheKey as makeCacheKey30,
46121
46310
  NotFoundError as NotFoundError33
@@ -46127,7 +46316,7 @@ function useAttendanceSettingsRepository() {
46127
46316
  }
46128
46317
  const namespace_collection3 = "site.attendance-settings";
46129
46318
  const collection = db2.collection(namespace_collection3);
46130
- const { delNamespace, setCache, getCache } = useCache35(namespace_collection3);
46319
+ const { delNamespace, setCache, getCache } = useCache36(namespace_collection3);
46131
46320
  async function createIndex() {
46132
46321
  try {
46133
46322
  await collection.createIndexes([
@@ -46402,7 +46591,7 @@ import {
46402
46591
  InternalServerError as InternalServerError41,
46403
46592
  paginate as paginate30,
46404
46593
  BadRequestError as BadRequestError117,
46405
- useCache as useCache36,
46594
+ useCache as useCache37,
46406
46595
  logger as logger91,
46407
46596
  makeCacheKey as makeCacheKey31,
46408
46597
  NotFoundError as NotFoundError34
@@ -46414,7 +46603,7 @@ function useAttendanceRepository() {
46414
46603
  }
46415
46604
  const namespace_collection3 = "site.attendances";
46416
46605
  const collection = db2.collection(namespace_collection3);
46417
- const { delNamespace, setCache, getCache, delCache } = useCache36(namespace_collection3);
46606
+ const { delNamespace, setCache, getCache, delCache } = useCache37(namespace_collection3);
46418
46607
  async function createIndex() {
46419
46608
  try {
46420
46609
  await collection.createIndexes([
@@ -60171,7 +60360,7 @@ function UseAccessManagementRepo() {
60171
60360
 
60172
60361
  // src/services/access-management.service.ts
60173
60362
  import { parseStringPromise as parseStringPromise3 } from "xml2js";
60174
- import { logger as logger100, makeCacheKey as makeCacheKey33, useCache as useCache38 } from "@7365admin1/node-server-utils";
60363
+ import { logger as logger100, makeCacheKey as makeCacheKey33, useCache as useCache39 } from "@7365admin1/node-server-utils";
60175
60364
  import { Readable } from "stream";
60176
60365
  import * as xlsx from "xlsx";
60177
60366
  var namespace = "cache:acm";
@@ -60245,7 +60434,7 @@ function useAccessManagementSvc() {
60245
60434
  return result ? JSON.parse(result) : null;
60246
60435
  };
60247
60436
  const doorAccessLevelsSvc = async (params) => {
60248
- const { getCache: getCache2, setCache: setCache2 } = useCache38(namespace);
60437
+ const { getCache: getCache2, setCache: setCache2 } = useCache39(namespace);
60249
60438
  const cacheKey = makeCacheKey33(namespace, {
60250
60439
  user: params.user,
60251
60440
  resource: "door-levels"
@@ -60271,7 +60460,7 @@ function useAccessManagementSvc() {
60271
60460
  }
60272
60461
  };
60273
60462
  const liftAccessLevelsSvc = async (params) => {
60274
- const { getCache: getCache2, setCache: setCache2 } = useCache38(namespace);
60463
+ const { getCache: getCache2, setCache: setCache2 } = useCache39(namespace);
60275
60464
  const cacheKey = makeCacheKey33(namespace, {
60276
60465
  user: params.user,
60277
60466
  resource: "lift-levels"
@@ -60297,7 +60486,7 @@ function useAccessManagementSvc() {
60297
60486
  }
60298
60487
  };
60299
60488
  const accessGroupsSvc = async (params) => {
60300
- const { getCache: getCache2, setCache: setCache2 } = useCache38(namespace);
60489
+ const { getCache: getCache2, setCache: setCache2 } = useCache39(namespace);
60301
60490
  const cacheKey = makeCacheKey33(namespace, {
60302
60491
  user: params.user,
60303
60492
  resource: "access-groups"
@@ -61657,7 +61846,7 @@ import {
61657
61846
  makeCacheKey as makeCacheKey34,
61658
61847
  paginate as paginate33,
61659
61848
  useAtlas as useAtlas81,
61660
- useCache as useCache39
61849
+ useCache as useCache40
61661
61850
  } from "@7365admin1/node-server-utils";
61662
61851
  import { ObjectId as ObjectId107 } from "mongodb";
61663
61852
  var guests_namespace_collection = "visitor.guests";
@@ -61667,7 +61856,7 @@ function useGuestManagementRepo() {
61667
61856
  throw new InternalServerError48("Unable to connect to server.");
61668
61857
  }
61669
61858
  const collection = db2.collection(guests_namespace_collection);
61670
- const { delNamespace, getCache, setCache } = useCache39(
61859
+ const { delNamespace, getCache, setCache } = useCache40(
61671
61860
  guests_namespace_collection
61672
61861
  );
61673
61862
  async function createTextIndex() {
@@ -62718,7 +62907,7 @@ import {
62718
62907
  paginate as paginate34,
62719
62908
  BadRequestError as BadRequestError134,
62720
62909
  NotFoundError as NotFoundError42,
62721
- useCache as useCache40,
62910
+ useCache as useCache41,
62722
62911
  makeCacheKey as makeCacheKey35,
62723
62912
  logger as logger106
62724
62913
  } from "@7365admin1/node-server-utils";
@@ -63132,7 +63321,7 @@ function useRobotRepo() {
63132
63321
  }
63133
63322
  const namespace_collection3 = "robots";
63134
63323
  const collection = db2.collection(namespace_collection3);
63135
- const { delNamespace, getCache, setCache } = useCache40(namespace_collection3);
63324
+ const { delNamespace, getCache, setCache } = useCache41(namespace_collection3);
63136
63325
  async function createIndex() {
63137
63326
  try {
63138
63327
  await collection.createIndexes([
@@ -63819,7 +64008,7 @@ function robotManifest(brand, reportedModel) {
63819
64008
  const b = robotBrandFor(brand);
63820
64009
  const reported = typeof reportedModel === "string" ? reportedModel.trim().slice(0, 60) : "";
63821
64010
  if (!b)
63822
- return { capabilities: {}, profile: { model: reported, modelKnown: false, alarms: [], makerApp: "", makerAppOnly: [] } };
64011
+ return { capabilities: {}, profile: { model: reported, modelKnown: false, alarms: [], makerApp: "", makerAppOnly: [], clearFault: [] } };
63823
64012
  const prefix = modelKey(b.brand);
63824
64013
  let key = modelKey(reported);
63825
64014
  if (prefix && key.startsWith(prefix) && key !== prefix)
@@ -63832,7 +64021,8 @@ function robotManifest(brand, reportedModel) {
63832
64021
  modelKnown: Boolean(m),
63833
64022
  alarms: [...m?.alarms ?? b.info?.alarms ?? []],
63834
64023
  makerApp: m?.makerApp ?? b.info?.makerApp ?? "",
63835
- makerAppOnly: [...m?.makerAppOnly ?? b.info?.makerAppOnly ?? []]
64024
+ makerAppOnly: [...m?.makerAppOnly ?? b.info?.makerAppOnly ?? []],
64025
+ clearFault: [...m?.clearFault ?? b.info?.clearFault ?? []]
63836
64026
  }
63837
64027
  };
63838
64028
  }
@@ -64665,6 +64855,246 @@ function useRobotCloudService(credentials, options = {}) {
64665
64855
  // src/services/ounitech.adapter.ts
64666
64856
  import axios4 from "axios";
64667
64857
  import { BadRequestError as BadRequestError137 } from "@7365admin1/node-server-utils";
64858
+
64859
+ // src/utils/ounitech-codes.util.ts
64860
+ var CLEAR = "Clear the fault (press and release the emergency stop)";
64861
+ var SUPPORT = "If it keeps happening, call Ounitech support";
64862
+ var DOCK = "Push it onto its charging dock so it can find its position again";
64863
+ var WAIT = "Wait until it is ready, then try again";
64864
+ var WHEEL = "Clear anything caught in the wheel and check the floor for holes";
64865
+ var NONE = "Normal when the emergency stop is pressed or released - no action needed";
64866
+ var T = {
64867
+ "100": ["Charging dock is over-heating", "Unplug the dock and let it cool down"],
64868
+ "101": ["Charging dock's clean-water tank is empty", "Fill the dock's clean-water tank"],
64869
+ "102": ["Charging dock's waste-water tank is full", "Drain the dock (unlock the dock, long-press Drain)"],
64870
+ "103": ["Charging dock valve or pump fault", `Check the pump connections. ${SUPPORT}`],
64871
+ "104": ["Charging dock valve or pump fault", `Check the pump connections. ${SUPPORT}`],
64872
+ "105": ["Charging dock valve or pump fault", `Check the pump connections. ${SUPPORT}`],
64873
+ "106": ["Charging dock valve or pump fault", `Check the pump connections. ${SUPPORT}`],
64874
+ "107": ["Charging dock valve or pump fault", `Check the pump connections. ${SUPPORT}`],
64875
+ "200": ["Battery not responding (flat for a long time)", "Charge it on the dock, or take the battery out and put it back"],
64876
+ "204": ["Wheel driver board offline", `Check the wheel wiring. ${SUPPORT}`],
64877
+ "205": ["Side-brush driver offline (side brush won't turn)", "Check the side-brush motor wire"],
64878
+ "206": ["Button panel offline (handle lights off)", `Check the handle's cable contact. ${SUPPORT}`],
64879
+ "207": ["Vacuum fan stalled", "Clean the vacuum pipe, HEPA filter, dust bag and tray"],
64880
+ "209": ["Vacuum fan fault", `${CLEAR}. ${SUPPORT}`],
64881
+ "210": ["Roller mop motor fault", "Take out the roller and clear anything tangled in it"],
64882
+ "211": ["Roller brush motor fault", "Take out the roller and clear anything tangled in it"],
64883
+ "212": ["Left side-brush motor fault", "Clear anything tangled in the side brush"],
64884
+ "213": ["Right side-brush motor fault", "Clear anything tangled in the side brush"],
64885
+ "214": ["Clean-water pump fault", `Re-plug the pump board. ${SUPPORT}`],
64886
+ "218": ["Waste-water pump fault", `Re-plug the pump board. ${SUPPORT}`],
64887
+ "219": ["Mop lift motor fault", `Restart the robot (power switch at the back). ${SUPPORT}`],
64888
+ "220": ["Brush lift motor fault", `Restart the robot (power switch at the back). ${SUPPORT}`],
64889
+ "221": ["Wheel fault", WHEEL],
64890
+ "222": ["Wheel fault", WHEEL],
64891
+ "223": ["Wheel stalled", WHEEL],
64892
+ "224": ["Wheel stalled", WHEEL],
64893
+ "228": ["Cooling fan fault", "Call Ounitech support"],
64894
+ "233": ["Battery short circuit", "Stop using the robot and call Ounitech support to replace the battery"],
64895
+ "234": ["Battery over-charged", "Take it off charge and call Ounitech support"],
64896
+ "245": ["Water-suction fan stalled", "Unclog the suction pipe and replace the filter"],
64897
+ "248": ["Squeegee motor fault", `Check the squeegee cable and motor. ${SUPPORT}`],
64898
+ "250": ["Battery full"],
64899
+ "251": ["Battery low"],
64900
+ "252": ["Battery too low to charge", "Call Ounitech support"],
64901
+ "255": ["Battery charging current high"],
64902
+ "256": ["Battery over-charged", "Take it off charge and call Ounitech support"],
64903
+ "257": ["Battery over 70 \xB0C", "Stop charging and let it cool down"],
64904
+ "302": ["Robot can't load its map", "Call Ounitech support"],
64905
+ "303": ["The map's area layout is damaged", "Re-edit the areas in the Ounitech app and save"],
64906
+ "304": ["The area layout doesn't match the map", "In the Ounitech app, switch to another floor map and back"],
64907
+ "305": ["Lost contact with its motion controller", "Restart the robot (power switch at the back)"],
64908
+ "306": ["Robot couldn't receive the chosen area", `${CLEAR}, then send the task again`],
64909
+ "307": ["Robot is finding its position again", "If the site has changed, push it onto its charging dock"],
64910
+ "308": ["Robot couldn't find its position", DOCK],
64911
+ "310": ["No signal from the charging dock", `Check the dock is powered. ${SUPPORT}`],
64912
+ "312": ["Couldn't dock", "Check the dock hasn't been moved"],
64913
+ "314": ["Couldn't dock - trying again", "Check the dock hasn't been moved"],
64914
+ "315": ["Couldn't dock - trying again", "Check the dock hasn't been moved"],
64915
+ "316": ["Lost the wireless link to its charging dock", "Check the dock is powered"],
64916
+ "319": ["Robot was moved while charging", "Press the emergency stop and push it back onto the dock"],
64917
+ "401": ["Battery below 10% - going to charge"],
64918
+ "403": ["Robot has left its charging dock"],
64919
+ "404": ["Charging dock reports a fault", "See the dock's other alerts"],
64920
+ "405": ["Couldn't call the lift"],
64921
+ "407": ["Lift is full"],
64922
+ "409": ["Couldn't switch map", "Call Ounitech support"],
64923
+ "410": ["Internal communication problem", SUPPORT],
64924
+ "415": ["Gyro data fault", `Check the cables. ${SUPPORT}`],
64925
+ "416": ["Wheel odometer data fault", `Check the cables. ${SUPPORT}`],
64926
+ "417": ["Laser scanner data fault", `Check the cables. ${SUPPORT}`],
64927
+ "418": ["Couldn't dock - trying again", "Check the dock hasn't been moved"],
64928
+ "419": ["Couldn't dock - trying again", "Check the dock hasn't been moved"],
64929
+ "420": ["Docking failed several times", "Check the dock's position and the robot's position"],
64930
+ "423": ["Dust box blocked", "Empty the dust box and clear the pipe"],
64931
+ "431": ["Robot's waste-water tank is high - returning to empty"],
64932
+ "432": ["Robot's clean water is low - returning to refill"],
64933
+ "433": ["Robot over-heating while charging", "Let it cool down"],
64934
+ "443": ["No charging current", "Seat the battery and clean the charging contacts"],
64935
+ "445": ["Area laser fault", "Call Ounitech support"],
64936
+ "446": ["Area laser board offline", "Call Ounitech support"],
64937
+ "448": ["Wheel drawing too much current", WHEEL],
64938
+ "449": ["Wheel over-current fault", `${WHEEL}, then clear the fault (press and release the emergency stop)`],
64939
+ "450": ["Wheels slipping", "Check the wheels"],
64940
+ "453": ["Robot tried to leave a no-go area", DOCK],
64941
+ "454": ["Robot hasn't moved for a long time", "Clear its path and wipe its sensors"],
64942
+ "457": ["Left bumper hit something", "Tap the bumper if it stays stuck"],
64943
+ "458": ["Right bumper hit something", "Tap the bumper if it stays stuck"],
64944
+ "459": ["Water suction blocked", "Clean the suction pipe and filters"],
64945
+ "460": ["Front camera fault", `Check the camera cable. ${SUPPORT}`],
64946
+ "462": ["Left camera fault", `Check the camera cable. ${SUPPORT}`],
64947
+ "464": ["Right camera fault", `Check the camera cable. ${SUPPORT}`],
64948
+ "469": ["The map's floor doesn't match the floor it senses", "Check it is on the right floor; the air-pressure sensor may need recalibrating"],
64949
+ "470": ["Gyro offline", "Call Ounitech support"],
64950
+ "471": ["Roller motor needs servicing", "Book a service"],
64951
+ "472": ["Fan needs servicing", "Book a service"],
64952
+ "500": ["Scheduled job skipped: floor can't be reached", "Cross-floor jobs need lift control"],
64953
+ "501": ["Scheduled job skipped: robot not ready to clean", "Check battery, water, tanks and dust box"],
64954
+ "502": ["Waited over 20 minutes for the lift - going to charge"],
64955
+ "503": ["Scheduled job done - going to charge"],
64956
+ "504": ["Job done - going to charge"],
64957
+ "505": ["Job cancelled - going to charge"],
64958
+ "506": ["Couldn't leave the charging dock", "Check the wheels"],
64959
+ "507": ["Clean water low - returning to refill, then continuing"],
64960
+ "508": ["Waste water high - returning to empty, then continuing"],
64961
+ "509": ["Dust box missing", "Fit the dust box"],
64962
+ "510": ["Clean-water tank missing", "Fit the clean-water tank"],
64963
+ "511": ["Waste-water tank missing", "Fit the waste-water tank"],
64964
+ "512": ["Tank cover missing", "Fit the tank cover"],
64965
+ "513": ["Top cover open", "Close the top cover"],
64966
+ "514": ["Handle is up (manual mode) - the app can't start a job", "Lower the handle"],
64967
+ "515": ["Battery below 10% - can't clean", "Let it charge"],
64968
+ "517": ["Robot is starting up - not ready yet", WAIT],
64969
+ "518": ["Robot is shutting down"],
64970
+ "519": ["Robot is resuming - not ready yet", WAIT],
64971
+ "520": ["Robot is finding its position - not ready yet", WAIT],
64972
+ "521": ["Robot is downloading its map - not ready yet", WAIT],
64973
+ "522": ["Couldn't resume: clean water below half", "Wait for it to refill"],
64974
+ "523": ["Couldn't resume: waste water too high", "Wait for it to empty"],
64975
+ "524": ["Charging dock doesn't match this robot", "Re-scan the dock's QR code in the Ounitech app"],
64976
+ "525": ["Scheduled time ended before the job finished", "Give the schedule a longer time window"],
64977
+ "527": ["Software updating", "Don't use the robot until it finishes"],
64978
+ "528": ["Software updating", "Don't use the robot until it finishes"],
64979
+ "529": ["Software updating", "Don't use the robot until it finishes"],
64980
+ "530": ["Software updating", "Don't use the robot until it finishes"],
64981
+ "531": ["Manual mode - the app's command was refused", "Lower the handle"],
64982
+ "532": ["Finding its starting position"],
64983
+ "534": ["Finding its starting position after a map switch"],
64984
+ "535": ["Areas updated"],
64985
+ "536": ["Virtual walls updated"],
64986
+ "537": ["Safe zones updated"],
64987
+ "538": ["Map saved"],
64988
+ "539": ["Couldn't save the map", "Save it again"],
64989
+ "540": ["Cliff sensor switched on"],
64990
+ "541": ["Cliff sensor switched off"],
64991
+ "542": ["Stopped at a drop (cliff sensor)", `Pull it back by the handle, ${CLEAR.charAt(0).toLowerCase()}${CLEAR.slice(1)}, and add a virtual wall there`],
64992
+ "543": ["Slowing down near a drop (cliff sensor)", "Add a virtual wall there if it keeps happening"],
64993
+ "544": ["Scheduled shutdown soon - returning to the dock"],
64994
+ "545": ["Edge cleaning started"],
64995
+ "546": ["Edge cleaning finished"],
64996
+ "549": ["Asking to switch map"],
64997
+ "552": ["No floor switch needed"],
64998
+ "553": ["Area can't be reached - job ended", "In the Ounitech app, switch map and back, or re-save an area"],
64999
+ "554": ["Sensor calibration"],
65000
+ "555": ["Sensor calibration - clear obstacles around the robot"],
65001
+ "556": ["Sensor calibration - clear obstacles around the robot"],
65002
+ "557": ["Slow zones updated"],
65003
+ "560": ["Fan stalled - returning to the dock", "Press and release the emergency stop, then check the fan"],
65004
+ "561": ["Couldn't reconnect to the charging dock", "Check the dock"],
65005
+ "562": ["Scheduled shutdown soon - no new jobs"],
65006
+ "563": ["Robot is in a fault state", "Find the cause, clear it (press and release the emergency stop), and check the robot"],
65007
+ "564": ["Fault cleared - robot on standby"],
65008
+ "565": ["Handling waste water"],
65009
+ "566": ["Waste water handled"],
65010
+ "567": ["Fan stalled", "Clear the fan, then resume"],
65011
+ "568": ["No charging dock on this floor", "Set the dock's floor in the Ounitech app"],
65012
+ "570": ["Finding its starting position - can't start yet", WAIT],
65013
+ "571": ["Stopped too long - side brush switched off", "Pause, then resume"],
65014
+ "572": ["Lift ride took too long - job cancelled", "Push it back onto its charging dock"],
65015
+ "573": ["Camera saw a drop", "Add a virtual wall 1 m from the drop"],
65016
+ "574": ["Map updating", WAIT],
65017
+ "575": ["Air-pressure sensor reading invalid", "Recalibrate the air-pressure sensor"],
65018
+ "576": ["Air-pressure sensor calibration"],
65019
+ "577": ["Air-pressure sensor calibration"],
65020
+ "578": ["Air-pressure sensor calibration"],
65021
+ "581": ["Taught route started"],
65022
+ "582": ["Taught route ended"],
65023
+ "583": ["Taught route cleared"],
65024
+ "585": ["An area's positioning mode changed"],
65025
+ "587": ["Battery discharging while on charge", "Seat the battery and clean the charging contacts"],
65026
+ "588": ["Switched off with the power button"],
65027
+ "589": ["Switched off by the timed power schedule"],
65028
+ "590": ["Switched on"],
65029
+ "591": ["Switched on with the power button"],
65030
+ "592": ["Switched on by the timed power schedule"],
65031
+ "593": ["Still finding its position - can't take commands yet", WAIT],
65032
+ "600": ["Left wheel driver offline", NONE],
65033
+ "601": ["Left wheel driver reset", NONE],
65034
+ "603": ["Left wheel drawing too much current", WHEEL],
65035
+ "604": ["Left wheel drawing too much current", WHEEL],
65036
+ "605": ["Left wheel stalled", WHEEL],
65037
+ "620": ["Right wheel driver offline", NONE],
65038
+ "621": ["Right wheel driver reset", NONE],
65039
+ "622": ["Right wheel driver error", "Call Ounitech support"],
65040
+ "623": ["Right wheel drawing too much current", WHEEL],
65041
+ "624": ["Right wheel drawing too much current", WHEEL],
65042
+ "625": ["Right wheel stalled", WHEEL],
65043
+ "640": ["A part is overdue for replacement - won't clean", "Replace the part"],
65044
+ "641": ["A running job is blocking the schedule", "Cancel the job or wait"],
65045
+ "642": ["Can't find its position while charging", "Put it on standby first"],
65046
+ "643": ["Can't reset the dock while charging", "Put it on standby first"],
65047
+ "644": ["Can't set its starting position while charging", "Put it on standby first"],
65048
+ "700": ["Vacuum button pressed"],
65049
+ "701": ["Standard button pressed"],
65050
+ "702": ["Dust-mop button pressed"],
65051
+ "703": ["Cancel button pressed"],
65052
+ "704": ["Strong button pressed"],
65053
+ "705": ["Mop button pressed"],
65054
+ "706": ["Pause button pressed"],
65055
+ "707": ["Recall button pressed"],
65056
+ "708": ["Pause button held"],
65057
+ "709": ["Pause button held"],
65058
+ "710": ["Wheel drawing too much current", WHEEL],
65059
+ "711": ["Wheel over-heating", "Let it cool and check the wheel"],
65060
+ "712": ["Wheel kept drawing too much current", `${WHEEL}, then clear the fault (press and release the emergency stop)`],
65061
+ "713": ["Switching lift - timed power paused"],
65062
+ "731": ["Robot locked by the dealer", "Ask the dealer"],
65063
+ "732": ["Voice file updated"],
65064
+ "733": ["Switched off from the app"],
65065
+ "737": ["Laser scanner motion-sensor fault", "Call Ounitech support"],
65066
+ "738": ["Can't start: clean water low", "Fill the clean-water tank"],
65067
+ "739": ["Can't start: waste water high", "Empty the waste-water tank"],
65068
+ "760": ["Map file missing", "Call Ounitech support"],
65069
+ "761": ["Map file damaged", "Call Ounitech support"],
65070
+ "762": ["Started from the wrong place (it was pushed)", "Push it back onto its charging dock"],
65071
+ "775": ["Moved by a person during a lift ride", "Cancel the job and push it back onto its charging dock"],
65072
+ "776": ["Boxed in", `Clear its path, wipe its sensors. ${DOCK}`],
65073
+ "777": ["Can't reach its target", `Clear its path, wipe its sensors. ${DOCK}`],
65074
+ "778": ["Couldn't dock - recovering by itself", "Check the dock's sensor and that the dock hasn't moved"],
65075
+ "779": ["Robot settings changed"],
65076
+ "780": ["Top cover open", "Close the top cover"],
65077
+ "781": ["Dust box not fitted", "Fit the dust box"],
65078
+ "782": ["Waste-water tank not fitted", "Fit the waste-water tank"],
65079
+ "785": ["Position ready"]
65080
+ };
65081
+ var _a;
65082
+ for (const c of [...range(740, 759), 763, 764, 783, 784])
65083
+ T[_a = String(c)] ?? (T[_a] = ["Sensor or camera calibration", "Recalibrate if it failed"]);
65084
+ var _a2;
65085
+ for (const c of range(765, 773))
65086
+ T[_a2 = String(c)] ?? (T[_a2] = ["QR code return-point / position scan", "Rescan if it failed"]);
65087
+ T["774"] ?? (T["774"] = ["Taught route saved"]);
65088
+ function range(a, b) {
65089
+ return Array.from({ length: b - a + 1 }, (_, i) => a + i);
65090
+ }
65091
+ var OUNITECH_CODES = T;
65092
+ function ounitechCodeWords(code) {
65093
+ const c = OUNITECH_CODES[code];
65094
+ return c ? c[1] ? `${c[0]}. ${c[1]}.` : c[0] : null;
65095
+ }
65096
+
65097
+ // src/services/ounitech.adapter.ts
64668
65098
  var OUNITECH_BRAND = "ounitech";
64669
65099
  var OUNITECH_CAPABILITIES = {
64670
65100
  // Pose in the chapter-6 robot list (metres) and the tracking stream.
@@ -64693,8 +65123,9 @@ var OUNITECH_CAPABILITIES = {
64693
65123
  // taskState carries the job and its %, shown in the status words; there is
64694
65124
  // no command id to follow a job WE started, so completion is not claimed.
64695
65125
  processCompletion: false,
65126
+ // The manual: "Combined cleaning" across floors exists in the Ounitech app and needs its
65127
+ // lift-control module (code 500 = floor unreachable); no API call starts one.
64696
65128
  multiFloor: false,
64697
- // plans can name floors; no API starts a cross-floor job
64698
65129
  // `start-spot-cleaning` takes a PIXEL polygon while poses are metres, and
64699
65130
  // whether y is flipped between the two is not documented. Hidden until one
64700
65131
  // real robot confirms the frame.
@@ -64850,9 +65281,9 @@ function ounitechFault(list) {
64850
65281
  }
64851
65282
  function faultWords(a) {
64852
65283
  if (!a.code)
64853
- return { code: "error", message: a.message.slice(0, 200) };
64854
- const words = a.message.startsWith(`Robot alert ${a.code}:`) ? a.message : `${a.message} (fault ${a.code})`;
64855
- return { code: a.code.slice(0, 60), message: words.slice(0, 200) };
65284
+ return { code: "error", message: a.message.slice(0, 300) };
65285
+ const words = alertWords(a.code) ?? a.vendorText ?? a.message;
65286
+ return { code: a.code.slice(0, 60), message: `${a.code} \xB7 ${words}`.slice(0, 300) };
64856
65287
  }
64857
65288
  function ounitechMapShare(map, x, y, clamp4 = false) {
64858
65289
  const w = map?.width, h = map?.height, r = map?.resolution;
@@ -65000,22 +65431,8 @@ function ounitechTaskRecord(t, maps = [], tz = 480) {
65000
65431
  floorNo: Number.isInteger(t.floorNo) ? t.floorNo : map?.floorNo ?? null
65001
65432
  };
65002
65433
  }
65003
- var ALERT_WORDS = {
65004
- "205": "Side brush driver offline",
65005
- "206": "Button panel offline",
65006
- // 306 "接收定点指定区域故障": seen live 30 Sep right after start-area-cleaning on an area with no centre point.
65007
- "306": "Robot couldn't receive the chosen cleaning area",
65008
- "540": "Floor check: cliff sensor switched on",
65009
- "563": "Robot is in a fault state",
65010
- "588": "Switched off with the power button",
65011
- "589": "Switched off by the timed power schedule",
65012
- "593": "Still finding its position - try again shortly",
65013
- "601": "Left wheel driver reset",
65014
- "620": "Right wheel driver offline",
65015
- "621": "Right wheel driver reset",
65016
- "734": "IMU zero offset too large",
65017
- "785": "Localisation ready"
65018
- };
65434
+ var VENDOR_TEXT_EN = { "734": "IMU zero offset too large" };
65435
+ var alertWords = (code) => code ? ounitechCodeWords(code) ?? VENDOR_TEXT_EN[code] ?? null : null;
65019
65436
  var ALERT_LEVEL_WORDS = { \u63D0\u793A: "Notice", \u8B66\u544A: "Warning", \u6545\u969C: "Fault", \u9519\u8BEF: "Error", \u4E25\u91CD: "Critical" };
65020
65437
  function ounitechAlertRecord(a, tz = 480) {
65021
65438
  const raw = String(a.errMsg ?? a.errCode ?? "").trim();
@@ -65031,7 +65448,7 @@ function ounitechAlertRecord(a, tz = 480) {
65031
65448
  code,
65032
65449
  level: lv ? ALERT_LEVEL_WORDS[lv[1].trim()] ?? lv[1].trim() : null,
65033
65450
  // An untranslated Chinese text keeps its code up front, so the row is never only Chinese.
65034
- message: ALERT_WORDS[code] ?? (/[㐀-鿿]/.test(rest || raw) && code ? `Robot alert ${code}: ${rest || raw}` : rest || raw),
65451
+ message: alertWords(code) ?? (/[㐀-鿿]/.test(rest || raw) && code ? `Robot alert ${code}: ${rest || raw}` : rest || raw),
65035
65452
  vendorText: rest || raw,
65036
65453
  resolved,
65037
65454
  at: ounitechTime(a.createTime, tz)
@@ -65409,7 +65826,7 @@ function createOunitechAdapter(credentials, options) {
65409
65826
  const blind = command.areas.filter((n) => centre.has(n) && !centre.get(n));
65410
65827
  if (blind.length) {
65411
65828
  throw new BadRequestError137(
65412
- `${blind.map((n) => `"${n}"`).join(", ")} has no centre point on the robot's map, so the robot can't be sent there (it stops with fault 306). Use Clean all, or redraw the area in the Ounitech app.`
65829
+ `${blind.map((n) => `"${n}"`).join(", ")} has no centre point on the robot's map, so the robot can't be sent there (it stops with fault 306). ` + (blind.includes("default") ? `"default" is the whole map before it is divided into areas. Use Clean all, or divide the map in the Ounitech app (Control -> Divide areas).` : "Use Clean all, or redraw the area in the Ounitech app.")
65413
65830
  );
65414
65831
  }
65415
65832
  await cloud.startAreaCleaning(robotSn, command.areas, options2);
@@ -65672,7 +66089,17 @@ var OUNITECH_BRAND_DEFINITION = {
65672
66089
  { name: "Q3-G", codes: ["Q3G", "Q3-G"] },
65673
66090
  { name: "Q3-W", codes: ["Q3W", "Q3-W"] }
65674
66091
  ],
65675
- info: { makerApp: "the Ounitech app", makerAppOnly: ["pausing or stopping a job", "cleaning across floors", "changing maps, areas and schedules"] },
66092
+ info: {
66093
+ makerApp: "the Ounitech app",
66094
+ makerAppOnly: ["pausing or stopping a job", "cleaning across floors", "changing maps, areas and schedules"],
66095
+ // Q3-G User Manual / Troubleshooting Checklist (2026-09-30). The API has no documented way to clear an Error.
66096
+ clearFault: [
66097
+ 'Press the red emergency stop on top of the robot, then turn it clockwise to release it. It says "emergency stop button bounced" and the fault clears.',
66098
+ "If it has lost its position: lift the handle, push it onto its charging dock until the metal contacts touch, then press and release the emergency stop. It relocates by itself.",
66099
+ "Still stuck: restart it with the power switch at the back. It is ready when only the child-lock light stays on.",
66100
+ "Handle buttons not responding: press Child lock 3 times to unlock them."
66101
+ ]
66102
+ },
65676
66103
  create: (credentials) => createOunitechAdapter(credentials)
65677
66104
  };
65678
66105
  function registerOunitechBrand() {
@@ -70964,7 +71391,7 @@ function toBuildingYaml(name, rmf) {
70964
71391
  }
70965
71392
  const lifts = {};
70966
71393
  for (const l of rmf.lifts) {
70967
- const range = liftFloorRange(l, rmf.levels);
71394
+ const range2 = liftFloorRange(l, rmf.levels);
70968
71395
  lifts[l.name] = {
70969
71396
  x: l.x,
70970
71397
  y: l.y,
@@ -70972,9 +71399,9 @@ function toBuildingYaml(name, rmf) {
70972
71399
  width: l.widthM,
70973
71400
  depth: l.depthM,
70974
71401
  reference_floor_name: l.referenceFloor,
70975
- initial_floor_name: range.initial,
70976
- lowest_floor: range.lowest,
70977
- highest_floor: range.highest,
71402
+ initial_floor_name: range2.initial,
71403
+ lowest_floor: range2.lowest,
71404
+ highest_floor: range2.highest,
70978
71405
  doors: Object.fromEntries(
70979
71406
  l.doors.map((d) => [d.name, { door_type: LIFT_DOOR_TYPE_INT[d.type] ?? 2, x: d.x, y: d.y, width: d.widthM, motion_axis_orientation: d.axisYawRad }])
70980
71407
  ),
@@ -71024,13 +71451,13 @@ function toNavGraphs(name, rmf) {
71024
71451
  const out = {};
71025
71452
  const elevation = new Map(rmf.levels.map((l) => [l.name, l.elevationM]));
71026
71453
  const shafts = rmf.lifts.map((l) => {
71027
- const range = liftFloorRange(l, rmf.levels);
71454
+ const range2 = liftFloorRange(l, rmf.levels);
71028
71455
  return {
71029
71456
  lift: l,
71030
71457
  verts: liftShaft(l),
71031
71458
  // lift.py: no lowest / highest floor = no bound; a lift with no level_doors marks nothing.
71032
- lo: elevation.get(range.lowest) ?? -Infinity,
71033
- hi: elevation.get(range.highest) ?? Infinity,
71459
+ lo: elevation.get(range2.lowest) ?? -Infinity,
71460
+ hi: elevation.get(range2.highest) ?? Infinity,
71034
71461
  hasDoors: l.levelDoors.length > 0
71035
71462
  };
71036
71463
  });
@@ -73706,7 +74133,7 @@ import {
73706
74133
  makeCacheKey as makeCacheKey36,
73707
74134
  paginate as paginate36,
73708
74135
  useAtlas as useAtlas86,
73709
- useCache as useCache41
74136
+ useCache as useCache42
73710
74137
  } from "@7365admin1/node-server-utils";
73711
74138
  import { ObjectId as ObjectId115 } from "mongodb";
73712
74139
  function usePatrolQuestionRepo() {
@@ -73716,7 +74143,7 @@ function usePatrolQuestionRepo() {
73716
74143
  }
73717
74144
  const namespace_collection3 = "patrol.questions";
73718
74145
  const collection = db2.collection(namespace_collection3);
73719
- const { delNamespace, getCache, setCache } = useCache41(namespace_collection3);
74146
+ const { delNamespace, getCache, setCache } = useCache42(namespace_collection3);
73720
74147
  async function createIndexes() {
73721
74148
  try {
73722
74149
  await collection.createIndexes([{ key: { site: 1, status: 1 } }]);
@@ -74171,7 +74598,7 @@ import {
74171
74598
  makeCacheKey as makeCacheKey37,
74172
74599
  paginate as paginate37,
74173
74600
  useAtlas as useAtlas87,
74174
- useCache as useCache42
74601
+ useCache as useCache43
74175
74602
  } from "@7365admin1/node-server-utils";
74176
74603
  import { ObjectId as ObjectId117 } from "mongodb";
74177
74604
 
@@ -74192,7 +74619,7 @@ function usePatrolRouteRepo() {
74192
74619
  }
74193
74620
  const namespace_collection3 = "patrol.route";
74194
74621
  const collection = db2.collection(namespace_collection3);
74195
- const { delNamespace, getCache, setCache } = useCache42(namespace_collection3);
74622
+ const { delNamespace, getCache, setCache } = useCache43(namespace_collection3);
74196
74623
  async function createIndexes() {
74197
74624
  try {
74198
74625
  await collection.createIndexes([
@@ -74951,7 +75378,7 @@ import {
74951
75378
  makeCacheKey as makeCacheKey38,
74952
75379
  paginate as paginate38,
74953
75380
  useAtlas as useAtlas88,
74954
- useCache as useCache43
75381
+ useCache as useCache44
74955
75382
  } from "@7365admin1/node-server-utils";
74956
75383
  import { ObjectId as ObjectId119 } from "mongodb";
74957
75384
  function usePatrolLogRepo() {
@@ -74961,7 +75388,7 @@ function usePatrolLogRepo() {
74961
75388
  }
74962
75389
  const namespace_collection3 = "patrol.logs";
74963
75390
  const collection = db2.collection(namespace_collection3);
74964
- const { delNamespace, getCache, setCache } = useCache43(namespace_collection3);
75391
+ const { delNamespace, getCache, setCache } = useCache44(namespace_collection3);
74965
75392
  async function createIndexes() {
74966
75393
  try {
74967
75394
  await collection.createIndexes([
@@ -76847,7 +77274,7 @@ import {
76847
77274
  NotFoundError as NotFoundError51,
76848
77275
  paginate as paginate40,
76849
77276
  useAtlas as useAtlas91,
76850
- useCache as useCache44
77277
+ useCache as useCache45
76851
77278
  } from "@7365admin1/node-server-utils";
76852
77279
  import { ObjectId as ObjectId123 } from "mongodb";
76853
77280
  function useSiteFacilityRepo() {
@@ -76857,7 +77284,7 @@ function useSiteFacilityRepo() {
76857
77284
  }
76858
77285
  const namespace_collection3 = "site.facilities";
76859
77286
  const collection = db2.collection(namespace_collection3);
76860
- const { delNamespace, getCache, setCache } = useCache44(namespace_collection3);
77287
+ const { delNamespace, getCache, setCache } = useCache45(namespace_collection3);
76861
77288
  async function createTextIndex() {
76862
77289
  try {
76863
77290
  await collection.createIndex({
@@ -77529,7 +77956,7 @@ import {
77529
77956
  NotFoundError as NotFoundError53,
77530
77957
  paginate as paginate41,
77531
77958
  useAtlas as useAtlas93,
77532
- useCache as useCache45
77959
+ useCache as useCache46
77533
77960
  } from "@7365admin1/node-server-utils";
77534
77961
  import { ObjectId as ObjectId125 } from "mongodb";
77535
77962
  function useServiceProviderBillingRepo() {
@@ -77539,7 +77966,7 @@ function useServiceProviderBillingRepo() {
77539
77966
  }
77540
77967
  const namespace_collection3 = "site.service-provider.billing";
77541
77968
  const collection = db2.collection(namespace_collection3);
77542
- const { delNamespace, getCache, setCache } = useCache45(namespace_collection3);
77969
+ const { delNamespace, getCache, setCache } = useCache46(namespace_collection3);
77543
77970
  async function createIndexes() {
77544
77971
  try {
77545
77972
  await collection.createIndexes([{ key: { orgId: 1, status: 1 } }]);
@@ -78200,7 +78627,7 @@ import {
78200
78627
  paginate as paginate42,
78201
78628
  toObjectId as toObjectId18,
78202
78629
  useAtlas as useAtlas95,
78203
- useCache as useCache46
78630
+ useCache as useCache47
78204
78631
  } from "@7365admin1/node-server-utils";
78205
78632
  import { ObjectId as ObjectId127 } from "mongodb";
78206
78633
  var facility_bookings_namespace_collection = "site.facilty-booking";
@@ -78210,7 +78637,7 @@ function useSiteFacilityBookingRepo() {
78210
78637
  throw new InternalServerError58("Unable to connect to server.");
78211
78638
  }
78212
78639
  const collection = db2.collection(facility_bookings_namespace_collection);
78213
- const { delNamespace, getCache, setCache } = useCache46(
78640
+ const { delNamespace, getCache, setCache } = useCache47(
78214
78641
  facility_bookings_namespace_collection
78215
78642
  );
78216
78643
  async function createIndexes() {
@@ -78768,7 +79195,7 @@ import {
78768
79195
  NotFoundError as NotFoundError56,
78769
79196
  paginate as paginate43,
78770
79197
  useAtlas as useAtlas97,
78771
- useCache as useCache47
79198
+ useCache as useCache48
78772
79199
  } from "@7365admin1/node-server-utils";
78773
79200
  import { ObjectId as ObjectId129 } from "mongodb";
78774
79201
  function useDocumentManagementRepo() {
@@ -78778,7 +79205,7 @@ function useDocumentManagementRepo() {
78778
79205
  }
78779
79206
  const namespace_collection3 = "documents";
78780
79207
  const collection = db2.collection(namespace_collection3);
78781
- const { delNamespace, getCache, setCache } = useCache47(namespace_collection3);
79208
+ const { delNamespace, getCache, setCache } = useCache48(namespace_collection3);
78782
79209
  async function createIndex() {
78783
79210
  try {
78784
79211
  await collection.createIndexes([
@@ -79868,7 +80295,7 @@ import {
79868
80295
  NotFoundError as NotFoundError58,
79869
80296
  paginate as paginate44,
79870
80297
  useAtlas as useAtlas99,
79871
- useCache as useCache48
80298
+ useCache as useCache49
79872
80299
  } from "@7365admin1/node-server-utils";
79873
80300
  import { ObjectId as ObjectId132 } from "mongodb";
79874
80301
  var bulletin_boards_namespace_collection = "bulletin-boards";
@@ -79878,7 +80305,7 @@ function useBulletinBoardRepo() {
79878
80305
  throw new InternalServerError60("Unable to connect to server.");
79879
80306
  }
79880
80307
  const collection = db2.collection(bulletin_boards_namespace_collection);
79881
- const { delNamespace, getCache, setCache } = useCache48(
80308
+ const { delNamespace, getCache, setCache } = useCache49(
79882
80309
  bulletin_boards_namespace_collection
79883
80310
  );
79884
80311
  async function createIndexes() {
@@ -80707,7 +81134,7 @@ import {
80707
81134
  InternalServerError as InternalServerError61,
80708
81135
  logger as logger142,
80709
81136
  useAtlas as useAtlas101,
80710
- useCache as useCache49,
81137
+ useCache as useCache50,
80711
81138
  paginate as paginate45,
80712
81139
  makeCacheKey as makeCacheKey44
80713
81140
  } from "@7365admin1/node-server-utils";
@@ -80719,7 +81146,7 @@ function useSiteBillingItemRepo() {
80719
81146
  }
80720
81147
  const namespace_collection3 = "site.billing.items";
80721
81148
  const collection = db2.collection(namespace_collection3);
80722
- const { delNamespace, setCache, getCache } = useCache49(namespace_collection3);
81149
+ const { delNamespace, setCache, getCache } = useCache50(namespace_collection3);
80723
81150
  async function createIndexes() {
80724
81151
  try {
80725
81152
  await collection.createIndexes([
@@ -80968,7 +81395,7 @@ import {
80968
81395
  InternalServerError as InternalServerError62,
80969
81396
  logger as logger144,
80970
81397
  useAtlas as useAtlas102,
80971
- useCache as useCache50,
81398
+ useCache as useCache51,
80972
81399
  paginate as paginate46,
80973
81400
  makeCacheKey as makeCacheKey45
80974
81401
  } from "@7365admin1/node-server-utils";
@@ -81100,7 +81527,7 @@ function useSiteBillingConfigurationRepo() {
81100
81527
  }
81101
81528
  const namespace_collection3 = "site.billing.configuration";
81102
81529
  const collection = db2.collection(namespace_collection3);
81103
- const { delNamespace, setCache, getCache } = useCache50(namespace_collection3);
81530
+ const { delNamespace, setCache, getCache } = useCache51(namespace_collection3);
81104
81531
  async function createIndexes() {
81105
81532
  try {
81106
81533
  await collection.createIndexes([{ key: { site: 1, status: 1 } }]);
@@ -81963,7 +82390,7 @@ import {
81963
82390
  NotFoundError as NotFoundError63,
81964
82391
  paginate as paginate47,
81965
82392
  useAtlas as useAtlas105,
81966
- useCache as useCache51
82393
+ useCache as useCache52
81967
82394
  } from "@7365admin1/node-server-utils";
81968
82395
  import { ObjectId as ObjectId139 } from "mongodb";
81969
82396
  var events_namespace_collection = "event-management";
@@ -81973,7 +82400,7 @@ function useEventManagementRepo() {
81973
82400
  throw new InternalServerError63("Unable to connect to server.");
81974
82401
  }
81975
82402
  const collection = db2.collection(events_namespace_collection);
81976
- const { delNamespace, getCache, setCache } = useCache51(
82403
+ const { delNamespace, getCache, setCache } = useCache52(
81977
82404
  events_namespace_collection
81978
82405
  );
81979
82406
  async function createIndexes() {
@@ -82684,7 +83111,7 @@ import {
82684
83111
  InternalServerError as InternalServerError64,
82685
83112
  logger as logger152,
82686
83113
  useAtlas as useAtlas107,
82687
- useCache as useCache52,
83114
+ useCache as useCache53,
82688
83115
  paginate as paginate48,
82689
83116
  makeCacheKey as makeCacheKey47
82690
83117
  } from "@7365admin1/node-server-utils";
@@ -82696,7 +83123,7 @@ function useSiteUnitBillingRepo() {
82696
83123
  }
82697
83124
  const namespace_collection3 = "site.unit.billing";
82698
83125
  const collection = db2.collection(namespace_collection3);
82699
- const { delNamespace, setCache, getCache } = useCache52(namespace_collection3);
83126
+ const { delNamespace, setCache, getCache } = useCache53(namespace_collection3);
82700
83127
  async function createIndexes() {
82701
83128
  try {
82702
83129
  await collection.createIndexes([
@@ -85282,7 +85709,7 @@ import {
85282
85709
  NotFoundError as NotFoundError66,
85283
85710
  paginate as paginate49,
85284
85711
  useAtlas as useAtlas110,
85285
- useCache as useCache53
85712
+ useCache as useCache54
85286
85713
  } from "@7365admin1/node-server-utils";
85287
85714
  import { ObjectId as ObjectId145 } from "mongodb";
85288
85715
  function useNfcPatrolTagRepo() {
@@ -85293,8 +85720,8 @@ function useNfcPatrolTagRepo() {
85293
85720
  const namespace_collection3 = "nfc-patrol-tags";
85294
85721
  const namespace_collection_nfc_patrol_routes = "nfc-patrol-routes";
85295
85722
  const collection = db2.collection(namespace_collection3);
85296
- const { delNamespace, getCache, setCache } = useCache53(namespace_collection3);
85297
- const { delNamespace: delNamespaceNfcPatrolRoutes } = useCache53(
85723
+ const { delNamespace, getCache, setCache } = useCache54(namespace_collection3);
85724
+ const { delNamespace: delNamespaceNfcPatrolRoutes } = useCache54(
85298
85725
  namespace_collection_nfc_patrol_routes
85299
85726
  );
85300
85727
  async function createIndexes() {
@@ -85518,7 +85945,7 @@ import {
85518
85945
  makeCacheKey as makeCacheKey49,
85519
85946
  paginate as paginate50,
85520
85947
  useAtlas as useAtlas111,
85521
- useCache as useCache54
85948
+ useCache as useCache55
85522
85949
  } from "@7365admin1/node-server-utils";
85523
85950
  import { ObjectId as ObjectId147 } from "mongodb";
85524
85951
 
@@ -85597,7 +86024,7 @@ function useNfcPatrolRouteRepo() {
85597
86024
  }
85598
86025
  const namespace_collection3 = "nfc-patrol-routes";
85599
86026
  const collection = db2.collection(namespace_collection3);
85600
- const { delNamespace, getCache, setCache } = useCache54(namespace_collection3);
86027
+ const { delNamespace, getCache, setCache } = useCache55(namespace_collection3);
85601
86028
  async function createIndexes() {
85602
86029
  try {
85603
86030
  await collection.createIndexes([
@@ -86435,7 +86862,7 @@ import {
86435
86862
  NotFoundError as NotFoundError68,
86436
86863
  paginate as paginate51,
86437
86864
  useAtlas as useAtlas113,
86438
- useCache as useCache55
86865
+ useCache as useCache56
86439
86866
  } from "@7365admin1/node-server-utils";
86440
86867
  import { ObjectId as ObjectId149 } from "mongodb";
86441
86868
  function useBulletinVideoRepo() {
@@ -86454,7 +86881,7 @@ function useBulletinVideoRepo() {
86454
86881
  }
86455
86882
  const namespace_collection3 = "bulletin-videos";
86456
86883
  const collection = db2.collection(namespace_collection3);
86457
- const { delNamespace, getCache, setCache } = useCache55(namespace_collection3);
86884
+ const { delNamespace, getCache, setCache } = useCache56(namespace_collection3);
86458
86885
  async function add(value, session) {
86459
86886
  try {
86460
86887
  value = MBulletinVideo(value);
@@ -87037,7 +87464,7 @@ import {
87037
87464
  InternalServerError as InternalServerError68,
87038
87465
  logger as logger163,
87039
87466
  useAtlas as useAtlas115,
87040
- useCache as useCache56,
87467
+ useCache as useCache57,
87041
87468
  paginate as paginate52,
87042
87469
  makeCacheKey as makeCacheKey51
87043
87470
  } from "@7365admin1/node-server-utils";
@@ -87049,7 +87476,7 @@ function useStatementOfAccountRepo() {
87049
87476
  }
87050
87477
  const namespace_collection3 = "site.statement-of-accounts";
87051
87478
  const collection = db2.collection(namespace_collection3);
87052
- const { delNamespace, getCache, setCache } = useCache56(namespace_collection3);
87479
+ const { delNamespace, getCache, setCache } = useCache57(namespace_collection3);
87053
87480
  async function createIndexes() {
87054
87481
  try {
87055
87482
  await collection.createIndexes([
@@ -88054,7 +88481,7 @@ import {
88054
88481
  NotFoundError as NotFoundError72,
88055
88482
  paginate as paginate53,
88056
88483
  useAtlas as useAtlas117,
88057
- useCache as useCache57
88484
+ useCache as useCache58
88058
88485
  } from "@7365admin1/node-server-utils";
88059
88486
  import { ObjectId as ObjectId154 } from "mongodb";
88060
88487
  function useEntryPassSettingsRepo() {
@@ -88064,7 +88491,7 @@ function useEntryPassSettingsRepo() {
88064
88491
  }
88065
88492
  const namespace_collection3 = "site.entrypass-settings";
88066
88493
  const collection = db2.collection(namespace_collection3);
88067
- const { delNamespace, getCache, setCache } = useCache57(namespace_collection3);
88494
+ const { delNamespace, getCache, setCache } = useCache58(namespace_collection3);
88068
88495
  async function createTextIndex() {
88069
88496
  try {
88070
88497
  await collection.createIndex({
@@ -88640,7 +89067,7 @@ import {
88640
89067
  logger as logger169,
88641
89068
  makeCacheKey as makeCacheKey53,
88642
89069
  useAtlas as useAtlas118,
88643
- useCache as useCache58
89070
+ useCache as useCache59
88644
89071
  } from "@7365admin1/node-server-utils";
88645
89072
  function useDashboardRepo() {
88646
89073
  const db2 = useAtlas118.getDb();
@@ -88651,7 +89078,7 @@ function useDashboardRepo() {
88651
89078
  const work_order_collection = db2.collection("work-orders");
88652
89079
  const visitor_collection = db2.collection("visitor.transactions");
88653
89080
  const namespace_collection3 = "dashboard";
88654
- const { delNamespace, getCache, setCache } = useCache58(namespace_collection3);
89081
+ const { delNamespace, getCache, setCache } = useCache59(namespace_collection3);
88655
89082
  async function getAll({
88656
89083
  site = ""
88657
89084
  }, session) {
@@ -89294,7 +89721,7 @@ import {
89294
89721
  NotFoundError as NotFoundError74,
89295
89722
  paginate as paginate54,
89296
89723
  useAtlas as useAtlas120,
89297
- useCache as useCache59
89724
+ useCache as useCache60
89298
89725
  } from "@7365admin1/node-server-utils";
89299
89726
  import { ObjectId as ObjectId156 } from "mongodb";
89300
89727
  var incidents_namespace_collection = "incident-reports";
@@ -89325,7 +89752,7 @@ function useIncidentReportRepo() {
89325
89752
  }
89326
89753
  }
89327
89754
  const collection = db2.collection(incidents_namespace_collection);
89328
- const { delNamespace, getCache, setCache } = useCache59(
89755
+ const { delNamespace, getCache, setCache } = useCache60(
89329
89756
  incidents_namespace_collection
89330
89757
  );
89331
89758
  async function add(value, session) {
@@ -90317,7 +90744,7 @@ import {
90317
90744
  makeCacheKey as makeCacheKey55,
90318
90745
  NotFoundError as NotFoundError76,
90319
90746
  useAtlas as useAtlas122,
90320
- useCache as useCache60
90747
+ useCache as useCache61
90321
90748
  } from "@7365admin1/node-server-utils";
90322
90749
  import { ObjectId as ObjectId158 } from "mongodb";
90323
90750
  function useNfcPatrolSettingsRepository() {
@@ -90327,7 +90754,7 @@ function useNfcPatrolSettingsRepository() {
90327
90754
  }
90328
90755
  const namespace_collection3 = "site.nfc-patrol-settings";
90329
90756
  const collection = db2.collection(namespace_collection3);
90330
- const { delNamespace, setCache, getCache } = useCache60(namespace_collection3);
90757
+ const { delNamespace, setCache, getCache } = useCache61(namespace_collection3);
90331
90758
  async function createIndexes() {
90332
90759
  try {
90333
90760
  await collection.createIndexes([{ key: { site: 1 }, unique: true }]);
@@ -90575,7 +91002,7 @@ import {
90575
91002
  NotFoundError as NotFoundError77,
90576
91003
  paginate as paginate55,
90577
91004
  useAtlas as useAtlas124,
90578
- useCache as useCache61
91005
+ useCache as useCache62
90579
91006
  } from "@7365admin1/node-server-utils";
90580
91007
 
90581
91008
  // src/models/occurrence-subject.model.ts
@@ -90663,7 +91090,7 @@ function useOccurrenceSubjectRepo() {
90663
91090
  }
90664
91091
  const namespace_collection3 = "occurrence-subjects";
90665
91092
  const collection = db2.collection(namespace_collection3);
90666
- const { delNamespace, getCache, setCache } = useCache61(namespace_collection3);
91093
+ const { delNamespace, getCache, setCache } = useCache62(namespace_collection3);
90667
91094
  async function add(value, session) {
90668
91095
  try {
90669
91096
  value = MOccurrenceSubject(value);
@@ -91284,7 +91711,7 @@ import {
91284
91711
  NotFoundError as NotFoundError78,
91285
91712
  paginate as paginate56,
91286
91713
  useAtlas as useAtlas126,
91287
- useCache as useCache62
91714
+ useCache as useCache63
91288
91715
  } from "@7365admin1/node-server-utils";
91289
91716
  import { ObjectId as ObjectId163 } from "mongodb";
91290
91717
  function useOnlineFormRepo() {
@@ -91294,7 +91721,7 @@ function useOnlineFormRepo() {
91294
91721
  }
91295
91722
  const namespace_collection3 = "online-forms";
91296
91723
  const collection = db2.collection(namespace_collection3);
91297
- const { delNamespace, getCache, setCache } = useCache62(namespace_collection3);
91724
+ const { delNamespace, getCache, setCache } = useCache63(namespace_collection3);
91298
91725
  async function createTextIndex() {
91299
91726
  try {
91300
91727
  await collection.createIndex({
@@ -92092,7 +92519,7 @@ import {
92092
92519
  makeCacheKey as makeCacheKey58,
92093
92520
  paginate as paginate57,
92094
92521
  useAtlas as useAtlas128,
92095
- useCache as useCache63
92522
+ useCache as useCache64
92096
92523
  } from "@7365admin1/node-server-utils";
92097
92524
  import { ObjectId as ObjectId165 } from "mongodb";
92098
92525
  function useNfcPatrolLogRepo() {
@@ -92102,7 +92529,7 @@ function useNfcPatrolLogRepo() {
92102
92529
  }
92103
92530
  const namespace_collection3 = "nfc-patrol-logs";
92104
92531
  const collection = db2.collection(namespace_collection3);
92105
- const { delNamespace, getCache, setCache } = useCache63(namespace_collection3);
92532
+ const { delNamespace, getCache, setCache } = useCache64(namespace_collection3);
92106
92533
  async function createIndexes() {
92107
92534
  try {
92108
92535
  await collection.createIndexes([
@@ -95808,7 +96235,7 @@ import {
95808
96235
  makeCacheKey as makeCacheKey62,
95809
96236
  toObjectId as toObjectId20,
95810
96237
  useAtlas as useAtlas135,
95811
- useCache as useCache67
96238
+ useCache as useCache68
95812
96239
  } from "@7365admin1/node-server-utils";
95813
96240
  var overnight_parking_namespace_collection = "site.overnight-parking";
95814
96241
  function useOvernightParkingRepo() {
@@ -95817,7 +96244,7 @@ function useOvernightParkingRepo() {
95817
96244
  throw new InternalServerError80("Unable to connect to server.");
95818
96245
  }
95819
96246
  const collection = db2.collection(overnight_parking_namespace_collection);
95820
- const { delNamespace, setCache, getCache } = useCache67(
96247
+ const { delNamespace, setCache, getCache } = useCache68(
95821
96248
  overnight_parking_namespace_collection
95822
96249
  );
95823
96250
  async function createIndexes() {
@@ -96037,7 +96464,7 @@ import {
96037
96464
  paginate as paginate64,
96038
96465
  toObjectId as toObjectId22,
96039
96466
  useAtlas as useAtlas136,
96040
- useCache as useCache68
96467
+ useCache as useCache69
96041
96468
  } from "@7365admin1/node-server-utils";
96042
96469
  var overnight_parking_requests_namespace_collection = "site.overnight-parking-requests";
96043
96470
  function useOvernightParkingRequestRepo() {
@@ -96048,7 +96475,7 @@ function useOvernightParkingRequestRepo() {
96048
96475
  const collection = db2.collection(
96049
96476
  overnight_parking_requests_namespace_collection
96050
96477
  );
96051
- const { delNamespace, getCache, setCache } = useCache68(
96478
+ const { delNamespace, getCache, setCache } = useCache69(
96052
96479
  overnight_parking_requests_namespace_collection
96053
96480
  );
96054
96481
  async function createIndexes() {
@@ -97651,7 +98078,7 @@ function useManpowerSitesCtrl() {
97651
98078
  import {
97652
98079
  useAtlas as useAtlas140,
97653
98080
  useMailer as useMailer7,
97654
- useCache as useCache70,
98081
+ useCache as useCache71,
97655
98082
  compileHandlebar as compileHandlebar6,
97656
98083
  getDirectory as getDirectory6,
97657
98084
  logger as logger206
@@ -97822,7 +98249,7 @@ var updateRemarksisAcknowledged = async () => {
97822
98249
  },
97823
98250
  { $set: { "remarks.2.remark.isAcknowledged": false } }
97824
98251
  );
97825
- const { getCache, setCache } = useCache70("manpower-alerts");
98252
+ const { getCache, setCache } = useCache71("manpower-alerts");
97826
98253
  const capKey = `manpower-alert-count:${nowSGT}`;
97827
98254
  let sentToday = await getCache(capKey) ?? 0;
97828
98255
  const emailedSites = /* @__PURE__ */ new Set();
@@ -98038,7 +98465,7 @@ var isWithinHour = (alertTime, timeNow) => {
98038
98465
  };
98039
98466
 
98040
98467
  // src/events/manpower.event.ts
98041
- import { logger as logger207, useAtlas as useAtlas141, useCache as useCache71 } from "@7365admin1/node-server-utils";
98468
+ import { logger as logger207, useAtlas as useAtlas141, useCache as useCache72 } from "@7365admin1/node-server-utils";
98042
98469
  import { ObjectId as ObjectId176 } from "mongodb";
98043
98470
  import moment12 from "moment-timezone";
98044
98471
 
@@ -98197,7 +98624,7 @@ async function manpowerEvents(io) {
98197
98624
  const live2 = io.of(MANPOWER_LIVE_NAMESPACE);
98198
98625
  live2.use(async (socket, next) => {
98199
98626
  try {
98200
- const { getCache } = useCache71("sessions");
98627
+ const { getCache } = useCache72("sessions");
98201
98628
  socket.data.userId = await authoriseSocketSession(
98202
98629
  socket.handshake,
98203
98630
  (sid) => getCache(`sid:${sid}`)
@@ -99124,7 +99551,7 @@ import {
99124
99551
  InternalServerError as InternalServerError86,
99125
99552
  NotFoundError as NotFoundError87,
99126
99553
  useAtlas as useAtlas145,
99127
- useCache as useCache73
99554
+ useCache as useCache74
99128
99555
  } from "@7365admin1/node-server-utils";
99129
99556
  import { v4 as uuidv42 } from "uuid";
99130
99557
 
@@ -99138,7 +99565,7 @@ import {
99138
99565
  paginate as paginate68,
99139
99566
  NotFoundError as NotFoundError86,
99140
99567
  AppError as AppError48,
99141
- useCache as useCache72,
99568
+ useCache as useCache73,
99142
99569
  makeCacheKey as makeCacheKey65,
99143
99570
  toObjectId as toObjectId23
99144
99571
  } from "@7365admin1/node-server-utils";
@@ -99152,7 +99579,7 @@ function useUserRepoV2() {
99152
99579
  }
99153
99580
  const namespace_collection3 = "users";
99154
99581
  const collection = db2.collection(namespace_collection3);
99155
- const { delNamespace, setCache, getCache, delCache } = useCache72(namespace_collection3);
99582
+ const { delNamespace, setCache, getCache, delCache } = useCache73(namespace_collection3);
99156
99583
  async function createIndex() {
99157
99584
  try {
99158
99585
  await collection.createIndexes([{ key: { email: 1 } }]);
@@ -99611,7 +100038,7 @@ function useAuthServiceV2() {
99611
100038
  insertRotated: _insertRotated,
99612
100039
  revokeFamily: _revokeFamily
99613
100040
  } = useSessionRepo();
99614
- const { getCache, setCache, delCache } = useCache73("sessions");
100041
+ const { getCache, setCache, delCache } = useCache74("sessions");
99615
100042
  const { getByUserIdType } = useMemberRepo();
99616
100043
  async function issueSession(user) {
99617
100044
  await assertOrganizationNotSuspended(user?._id);
@@ -100991,6 +101418,9 @@ function useServiceProviderInviteController() {
100991
101418
  wrongJoinPreview: _wrongJoinPreview,
100992
101419
  repairWrongJoin: _repairWrongJoin,
100993
101420
  undoWrongJoin: _undoWrongJoin,
101421
+ finishSetupPreview: _finishSetupPreview,
101422
+ finishSetupApply: _finishSetupApply,
101423
+ finishSetupUndo: _finishSetupUndo,
100994
101424
  linkSite: _linkSite,
100995
101425
  listReceived: _listReceived,
100996
101426
  getForProvider: _getForProvider
@@ -101198,6 +101628,35 @@ function useServiceProviderInviteController() {
101198
101628
  const wrongJoinPreview = wrongJoin("preview");
101199
101629
  const wrongJoinRepair = wrongJoin("repair");
101200
101630
  const wrongJoinUndo = wrongJoin("undo");
101631
+ function finishSetup(action) {
101632
+ return async (req, res, next) => {
101633
+ try {
101634
+ await requireConsolePermission(req, "sp-approvals", "approve-sp");
101635
+ const { error, value } = Joi149.object({
101636
+ companyName: Joi149.string().trim().max(200).optional().allow("", null),
101637
+ country: Joi149.string().trim().max(100).optional().allow("", null)
101638
+ }).validate(action === "preview" ? req.query ?? {} : req.body ?? {}, {
101639
+ stripUnknown: true
101640
+ });
101641
+ if (error)
101642
+ throw new BadRequestError247(`Invalid input: ${error.message}`);
101643
+ const args = {
101644
+ id: inviteId(req),
101645
+ userId: callerId5(req),
101646
+ companyName: value.companyName ?? "",
101647
+ country: value.country ?? ""
101648
+ };
101649
+ res.json(
101650
+ action === "preview" ? await _finishSetupPreview(args) : action === "apply" ? await _finishSetupApply(args) : await _finishSetupUndo(args)
101651
+ );
101652
+ } catch (error) {
101653
+ next(error);
101654
+ }
101655
+ };
101656
+ }
101657
+ const finishSetupPreview = finishSetup("preview");
101658
+ const finishSetupApply = finishSetup("apply");
101659
+ const finishSetupUndo = finishSetup("undo");
101201
101660
  async function linkSite(req, res, next) {
101202
101661
  try {
101203
101662
  res.json(
@@ -101252,6 +101711,9 @@ function useServiceProviderInviteController() {
101252
101711
  wrongJoinPreview,
101253
101712
  wrongJoinRepair,
101254
101713
  wrongJoinUndo,
101714
+ finishSetupPreview,
101715
+ finishSetupApply,
101716
+ finishSetupUndo,
101255
101717
  linkSite,
101256
101718
  received,
101257
101719
  getOne
@@ -101986,7 +102448,7 @@ import {
101986
102448
  InternalServerError as InternalServerError89,
101987
102449
  useAtlas as useAtlas148,
101988
102450
  logger as logger218,
101989
- useCache as useCache74
102451
+ useCache as useCache75
101990
102452
  } from "@7365admin1/node-server-utils";
101991
102453
  function useRoleRepoV2() {
101992
102454
  const db2 = useAtlas148.getDb();
@@ -102023,7 +102485,7 @@ function useRoleRepoV2() {
102023
102485
  throw new InternalServerError89("Failed to create unique index on role.");
102024
102486
  }
102025
102487
  }
102026
- const { delNamespace } = useCache74(namespace_collection3);
102488
+ const { delNamespace } = useCache75(namespace_collection3);
102027
102489
  async function addRole(value, session) {
102028
102490
  value = new MRoleV2(value);
102029
102491
  try {
@@ -104550,7 +105012,7 @@ function useChatPrelovedController() {
104550
105012
 
104551
105013
  // src/events/chat-preloved.event.ts
104552
105014
  import Joi165 from "joi";
104553
- import { logger as logger225, useCache as useCache75 } from "@7365admin1/node-server-utils";
105015
+ import { logger as logger225, useCache as useCache76 } from "@7365admin1/node-server-utils";
104554
105016
  function parseSid2(cookieHeader) {
104555
105017
  const match = cookieHeader.match(/(?:^|;\s*)sid=([^;]*)/);
104556
105018
  return match ? decodeURIComponent(match[1]) : null;
@@ -104594,7 +105056,7 @@ function chatPrelovedEvents(io) {
104594
105056
  if (!sid) {
104595
105057
  return next(new Error("Unauthorized"));
104596
105058
  }
104597
- const { getCache } = useCache75("sessions");
105059
+ const { getCache } = useCache76("sessions");
104598
105060
  const sessionData = await getCache(`sid:${sid}`);
104599
105061
  if (!sessionData) {
104600
105062
  return next(new Error("Session expired or invalid"));
@@ -105123,7 +105585,7 @@ import {
105123
105585
  NotFoundError as NotFoundError96,
105124
105586
  paginate as paginate72,
105125
105587
  useAtlas as useAtlas161,
105126
- useCache as useCache76
105588
+ useCache as useCache77
105127
105589
  } from "@7365admin1/node-server-utils";
105128
105590
  import { ObjectId as ObjectId199 } from "mongodb";
105129
105591
  var online_forms_namespace_collection = "online-forms";
@@ -105133,7 +105595,7 @@ function useFormEntryRepo() {
105133
105595
  throw new InternalServerError100("Unable to connect to server.");
105134
105596
  }
105135
105597
  const collection = db2.collection(online_forms_namespace_collection);
105136
- const { delNamespace, getCache, setCache } = useCache76(
105598
+ const { delNamespace, getCache, setCache } = useCache77(
105137
105599
  online_forms_namespace_collection
105138
105600
  );
105139
105601
  const { getUserById } = useUserRepo();
@@ -108549,6 +109011,7 @@ export {
108549
109011
  robotTypesVisibleTo,
108550
109012
  rtspUrl,
108551
109013
  safeTopic,
109014
+ sanitizeCompanyName,
108552
109015
  scaleFromMeasurement,
108553
109016
  schema,
108554
109017
  schemaAppSlugNotification,