@7365admin1/core 3.52.1-staging.230 → 3.52.1-staging.231

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.d.ts CHANGED
@@ -4664,6 +4664,7 @@ type TVisitorTransaction = {
4664
4664
  status?: VisitorStatus;
4665
4665
  nric?: string;
4666
4666
  remarks?: string;
4667
+ invitationNote?: string;
4667
4668
  org?: string | ObjectId;
4668
4669
  site?: string | ObjectId;
4669
4670
  plateNumber?: string;
@@ -4743,6 +4744,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
4743
4744
  checkOut: string | Date | null | undefined;
4744
4745
  status: VisitorStatus | undefined;
4745
4746
  remarks: string | undefined;
4747
+ invitationNote: string | undefined;
4746
4748
  deliveryType: string | undefined;
4747
4749
  attachments: string[] | undefined;
4748
4750
  snapshotEntryImage: string | undefined;
@@ -7023,6 +7025,10 @@ interface AdditionalSettings {
7023
7025
  vendorId: string | null | number;
7024
7026
  productId: string | null | number;
7025
7027
  };
7028
+ invitationNote?: {
7029
+ isEnabled: boolean;
7030
+ text: string;
7031
+ };
7026
7032
  };
7027
7033
  }
7028
7034
  type TAccessMngmntSettings = {
package/dist/index.js CHANGED
@@ -19589,6 +19589,7 @@ var schemaVisitorTransaction = import_joi21.default.object({
19589
19589
  deliveryType: import_joi21.default.string().optional().allow(null, ""),
19590
19590
  status: import_joi21.default.string().optional().valid(...Object.values(VisitorStatus)).default("registered" /* REGISTERED */),
19591
19591
  remarks: import_joi21.default.string().optional().allow(null, ""),
19592
+ invitationNote: import_joi21.default.string().optional().allow(null, ""),
19592
19593
  members: import_joi21.default.array().items(
19593
19594
  import_joi21.default.object({
19594
19595
  name: import_joi21.default.string().optional().allow(null, ""),
@@ -19899,6 +19900,7 @@ function MVisitorTransaction(value) {
19899
19900
  checkOut: value.checkOut,
19900
19901
  status: value.status,
19901
19902
  remarks: value.remarks,
19903
+ invitationNote: value.invitationNote,
19902
19904
  deliveryType: value.deliveryType,
19903
19905
  attachments: value.attachments,
19904
19906
  snapshotEntryImage: value.snapshotEntryImage,
@@ -20842,6 +20844,7 @@ function useVisitorTransactionRepo() {
20842
20844
  arrivalTime: 1,
20843
20845
  duration: 1,
20844
20846
  purpose: 1,
20847
+ invitationNote: 1,
20845
20848
  checkIn: 1
20846
20849
  }
20847
20850
  }
@@ -50609,6 +50612,7 @@ function useVisitorTransactionService() {
50609
50612
  type: type2,
50610
50613
  company: company2,
50611
50614
  remarks,
50615
+ invitationNote,
50612
50616
  contractorType,
50613
50617
  unitName
50614
50618
  } = value;
@@ -50655,6 +50659,10 @@ function useVisitorTransactionService() {
50655
50659
  type: type2,
50656
50660
  company: company2,
50657
50661
  remarks,
50662
+ // Every member holds their OWN invitation/pass link, so the
50663
+ // site's note has to ride along to each of them - otherwise
50664
+ // only the lead contractor ever sees it.
50665
+ invitationNote,
50658
50666
  contractorType,
50659
50667
  checkIn: start,
50660
50668
  visitorPass: preparedVisitorPass,
@@ -51324,7 +51332,7 @@ function useVisitorTransactionService() {
51324
51332
  }
51325
51333
  async function createInvitedMemberDocuments(leadId, status) {
51326
51334
  const lead = await _getVisitorTransactionById(String(leadId));
51327
- if (!lead?.inviterId)
51335
+ if (!lead)
51328
51336
  return [];
51329
51337
  const members = Array.isArray(lead.members) ? lead.members : [];
51330
51338
  if (members.length === 0)
@@ -51353,8 +51361,13 @@ function useVisitorTransactionService() {
51353
51361
  duration: lead.duration,
51354
51362
  isOvernightParking: lead.isOvernightParking,
51355
51363
  numberOfPassengers: lead.numberOfPassengers,
51364
+ // Site-configured note from the self-service settings. Each member
51365
+ // holds their own pass link, so the note has to ride along to all of
51366
+ // them - the same thing the creation-time fan-out does. Absent on
51367
+ // resident invitations, which never set it.
51368
+ invitationNote: lead.invitationNote,
51356
51369
  status,
51357
- inviterId: String(lead.inviterId),
51370
+ ...lead.inviterId ? { inviterId: String(lead.inviterId) } : {},
51358
51371
  leadId: String(lead._id),
51359
51372
  // Explicit - MVisitorTransaction defaults an undefined checkIn to now,
51360
51373
  // and an approved invitation hasn't arrived yet.
@@ -55446,12 +55459,17 @@ function useVisitorTransactionController() {
55446
55459
  return;
55447
55460
  }
55448
55461
  const leadId = new import_mongodb88.ObjectId();
55462
+ const invitationNote = value.type === "contractor" /* CONTRACTOR */ && onboardingSettings?.invitationNote?.isEnabled === true ? String(onboardingSettings.invitationNote.text ?? "").trim() : "";
55463
+ const members = Array.isArray(value.members) ? value.members : [];
55464
+ const deferMembers = value.type === "contractor" /* CONTRACTOR */ && members.length > 0 && status !== "approved" /* APPROVED */;
55465
+ const { members: _deferredMembers, ...valueWithoutMembers } = value;
55449
55466
  const insertedId = await _add({
55450
- ...value,
55467
+ ...deferMembers ? valueWithoutMembers : value,
55451
55468
  _id: leadId.toString(),
55452
55469
  org: site.orgId.toString(),
55453
55470
  site: siteId,
55454
55471
  status,
55472
+ ...invitationNote ? { invitationNote } : {},
55455
55473
  // MVisitorTransaction() defaults checkIn to "now" whenever it's
55456
55474
  // undefined - correct for the staff "walk-in" flow, where creating
55457
55475
  // the record IS the check-in event, but wrong here: a self-service
@@ -55460,8 +55478,10 @@ function useVisitorTransactionController() {
55460
55478
  // checked in later (inline button / Guests-tab action menu).
55461
55479
  checkIn: null
55462
55480
  });
55463
- const members = Array.isArray(value.members) ? value.members : [];
55464
- if (value.type === "contractor" /* CONTRACTOR */ && members.length) {
55481
+ if (deferMembers) {
55482
+ await _patchFields(insertedId, { members });
55483
+ }
55484
+ if (!deferMembers && value.type === "contractor" /* CONTRACTOR */ && members.length) {
55465
55485
  await Promise.all(
55466
55486
  members.filter((m) => m._id).map((m) => _patchFields(m._id, { checkIn: null, status }))
55467
55487
  );
@@ -55546,6 +55566,11 @@ function useVisitorTransactionController() {
55546
55566
  arrivalTime: data.arrivalTime || null,
55547
55567
  duration: data.duration ?? null,
55548
55568
  purpose: data.purpose || null,
55569
+ // Set by the site, not the registrant - see the Invitation Note
55570
+ // block in `createSelfServiceVisitor`. Safe to hand back here:
55571
+ // this is exactly the invitation link the note was written for,
55572
+ // and it's only reachable by someone already holding the ID.
55573
+ invitationNote: data.invitationNote || null,
55549
55574
  // Public response exposes whether check-in happened, not the raw
55550
55575
  // timestamp - the preview page needs it to know an already-arrived
55551
55576
  // visitor's lapsed arrival window isn't the same thing as an
@@ -55707,7 +55732,7 @@ function useVisitorTransactionController() {
55707
55732
  const remarks = approval?.remarks ?? req.body.remarks;
55708
55733
  const isApprovalTransition = nextStatus === "approved" /* APPROVED */ || nextStatus === "rejected" /* REJECTED */;
55709
55734
  const current = isApprovalTransition ? await _getVisitorTransactionById(_id) : null;
55710
- const needsMemberFanOut = nextStatus === "approved" /* APPROVED */ && !!current?.inviterId && Array.isArray(current.members) && current.members.length > 0 && current.members.every((member) => !member._id);
55735
+ const needsMemberFanOut = nextStatus === "approved" /* APPROVED */ && (!!current?.inviterId || current?.type === "contractor" /* CONTRACTOR */) && Array.isArray(current?.members) && current.members.length > 0 && current.members.every((member) => !member._id);
55711
55736
  const { members: _unusedMembers, ...bodyWithoutMembers } = req.body;
55712
55737
  const baseBody = needsMemberFanOut ? bodyWithoutMembers : req.body;
55713
55738
  const updateBody = approval ? { ...baseBody, status: nextStatus } : baseBody;
@@ -55726,7 +55751,7 @@ function useVisitorTransactionController() {
55726
55751
  });
55727
55752
  }
55728
55753
  }
55729
- for (const insertedId of invitedMemberIds) {
55754
+ for (const insertedId of current?.inviterId ? invitedMemberIds : []) {
55730
55755
  resendEmailInvitedResident(
55731
55756
  String(insertedId),
55732
55757
  String(current?.inviterId)
@@ -68061,7 +68086,14 @@ function useAccessManagementController() {
68061
68086
  return res.status(400).json({ message: error.message });
68062
68087
  }
68063
68088
  const result = await getOnboardingSettingsSvc(site);
68064
- return res.status(200).json({ message: "Success", data: result });
68089
+ return res.status(200).json({
68090
+ message: "Success",
68091
+ data: {
68092
+ enabled: result?.enabled ?? false,
68093
+ header: result?.header ?? "",
68094
+ subText: result?.subText ?? ""
68095
+ }
68096
+ });
68065
68097
  } catch (error) {
68066
68098
  return res.status(500).json({
68067
68099
  data: null,