@7365admin1/core 3.49.1-staging.213 → 3.49.1-staging.214
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 +12 -2
- package/dist/index.js +79 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +310 -240
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4487,7 +4487,9 @@ declare enum VisitorStatus {
|
|
|
4487
4487
|
UNREGISTERED = "unregistered",
|
|
4488
4488
|
PENDING = "pending",
|
|
4489
4489
|
APPROVED = "approved",
|
|
4490
|
-
REJECTED = "rejected"
|
|
4490
|
+
REJECTED = "rejected",
|
|
4491
|
+
PENDING_APPROVAL = "Pending Approval",
|
|
4492
|
+
APPROVAL_REJECTED = "Approval Rejected"
|
|
4491
4493
|
}
|
|
4492
4494
|
type TKeyRef = {
|
|
4493
4495
|
keyId: string | ObjectId;
|
|
@@ -4527,11 +4529,14 @@ type TVisitorTransaction = {
|
|
|
4527
4529
|
manualCheckout?: boolean;
|
|
4528
4530
|
direction?: string;
|
|
4529
4531
|
members?: {
|
|
4532
|
+
_id?: ObjectId;
|
|
4530
4533
|
name: string;
|
|
4531
4534
|
nric: string;
|
|
4532
4535
|
visitorPass?: TKeyRef[] | null;
|
|
4533
4536
|
passKeys?: TKeyRef[] | null;
|
|
4534
4537
|
contact: string;
|
|
4538
|
+
email?: string;
|
|
4539
|
+
plateNumber?: string;
|
|
4535
4540
|
}[];
|
|
4536
4541
|
visitorPass?: TKeyRef[] | null;
|
|
4537
4542
|
passKeys?: TKeyRef[] | null;
|
|
@@ -4548,6 +4553,7 @@ type TVisitorTransaction = {
|
|
|
4548
4553
|
deletedAt?: string | Date;
|
|
4549
4554
|
purpose?: string;
|
|
4550
4555
|
inviterId?: string | ObjectId;
|
|
4556
|
+
leadId?: ObjectId | null;
|
|
4551
4557
|
createdBy?: string | ObjectId;
|
|
4552
4558
|
updatedBy?: string | ObjectId;
|
|
4553
4559
|
isMembersAdded?: boolean;
|
|
@@ -4604,6 +4610,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
|
|
|
4604
4610
|
email: string | undefined;
|
|
4605
4611
|
isOvernightParking: boolean;
|
|
4606
4612
|
inviterId: string | ObjectId;
|
|
4613
|
+
leadId: ObjectId | null;
|
|
4607
4614
|
overnightParking: {
|
|
4608
4615
|
status: string;
|
|
4609
4616
|
remarks: string;
|
|
@@ -4612,11 +4619,14 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
|
|
|
4612
4619
|
arrivalTime: string | null | undefined;
|
|
4613
4620
|
duration: number | null | undefined;
|
|
4614
4621
|
members: {
|
|
4622
|
+
_id?: ObjectId | undefined;
|
|
4615
4623
|
name: string;
|
|
4616
4624
|
nric: string;
|
|
4617
4625
|
visitorPass?: TKeyRef[] | null | undefined;
|
|
4618
4626
|
passKeys?: TKeyRef[] | null | undefined;
|
|
4619
4627
|
contact: string;
|
|
4628
|
+
email?: string | undefined;
|
|
4629
|
+
plateNumber?: string | undefined;
|
|
4620
4630
|
}[] | undefined;
|
|
4621
4631
|
};
|
|
4622
4632
|
|
|
@@ -4663,7 +4673,7 @@ declare function useVisitorTransactionService(): {
|
|
|
4663
4673
|
add: (value: TVisitorTransaction) => Promise<any>;
|
|
4664
4674
|
updateVisitorTransactionById: (id: string | ObjectId, value: TVisitorTransaction) => Promise<string>;
|
|
4665
4675
|
processTransactionDahuaStatus: () => Promise<void>;
|
|
4666
|
-
inviteVisitor: (value: TVisitorTransaction, userId: string) => Promise<
|
|
4676
|
+
inviteVisitor: (value: TVisitorTransaction, userId: string) => Promise<ObjectId[]>;
|
|
4667
4677
|
deleteVisitorTransaction: (id: string) => Promise<void>;
|
|
4668
4678
|
};
|
|
4669
4679
|
|
package/dist/index.js
CHANGED
|
@@ -19497,6 +19497,8 @@ var VisitorStatus = /* @__PURE__ */ ((VisitorStatus2) => {
|
|
|
19497
19497
|
VisitorStatus2["PENDING"] = "pending";
|
|
19498
19498
|
VisitorStatus2["APPROVED"] = "approved";
|
|
19499
19499
|
VisitorStatus2["REJECTED"] = "rejected";
|
|
19500
|
+
VisitorStatus2["PENDING_APPROVAL"] = "Pending Approval";
|
|
19501
|
+
VisitorStatus2["APPROVAL_REJECTED"] = "Approval Rejected";
|
|
19500
19502
|
return VisitorStatus2;
|
|
19501
19503
|
})(VisitorStatus || {});
|
|
19502
19504
|
var schemaVisitorTransaction = import_joi21.default.object({
|
|
@@ -19812,6 +19814,7 @@ function MVisitorTransaction(value) {
|
|
|
19812
19814
|
email: value.email,
|
|
19813
19815
|
isOvernightParking: value.isOvernightParking ?? false,
|
|
19814
19816
|
inviterId: value.inviterId ?? "",
|
|
19817
|
+
leadId: value.leadId ?? null,
|
|
19815
19818
|
overnightParking: value.isOvernightParking == true ? {
|
|
19816
19819
|
status: "pending approval",
|
|
19817
19820
|
remarks: "",
|
|
@@ -49468,6 +49471,21 @@ function useHidAmicoService() {
|
|
|
49468
49471
|
};
|
|
49469
49472
|
}
|
|
49470
49473
|
|
|
49474
|
+
// src/repositories/settings-resident-contractors.repository.ts
|
|
49475
|
+
var SettingsResidentContractorsRepo = class {
|
|
49476
|
+
static collection() {
|
|
49477
|
+
return getDB().collection("settings-resident-contractors");
|
|
49478
|
+
}
|
|
49479
|
+
static async getSettings(site) {
|
|
49480
|
+
try {
|
|
49481
|
+
const siteId = await convertObjectIdUtil2(site, "site");
|
|
49482
|
+
return await this.collection().findOne({ site: siteId });
|
|
49483
|
+
} catch (error) {
|
|
49484
|
+
throw new Error(error.message || error);
|
|
49485
|
+
}
|
|
49486
|
+
}
|
|
49487
|
+
};
|
|
49488
|
+
|
|
49471
49489
|
// src/services/visitor-transaction.service.ts
|
|
49472
49490
|
function useVisitorTransactionService() {
|
|
49473
49491
|
const MailerConfig = {
|
|
@@ -50258,6 +50276,10 @@ function useVisitorTransactionService() {
|
|
|
50258
50276
|
session.startTransaction();
|
|
50259
50277
|
const inviter = await _getByUserId(userId);
|
|
50260
50278
|
const unit = await getById(inviter?.unit);
|
|
50279
|
+
const settings = await SettingsResidentContractorsRepo.getSettings(
|
|
50280
|
+
inviter?.site
|
|
50281
|
+
);
|
|
50282
|
+
const isAutoApprovedInvitation = settings?.isAutoApprovedInvitation === true;
|
|
50261
50283
|
value.checkIn = null;
|
|
50262
50284
|
const payload = {
|
|
50263
50285
|
...value,
|
|
@@ -50267,12 +50289,35 @@ function useVisitorTransactionService() {
|
|
|
50267
50289
|
unitName: unit?.name,
|
|
50268
50290
|
org: inviter?.org?.toString(),
|
|
50269
50291
|
site: inviter?.site.toString(),
|
|
50270
|
-
status: "approved" /* APPROVED */,
|
|
50292
|
+
status: value?.type === "contractor" ? isAutoApprovedInvitation ? "approved" /* APPROVED */ : "Pending Approval" /* PENDING_APPROVAL */ : "Pending Approval" /* PENDING_APPROVAL */,
|
|
50271
50293
|
inviterId: userId
|
|
50272
50294
|
};
|
|
50273
|
-
const
|
|
50295
|
+
const leadId = new import_mongodb85.ObjectId();
|
|
50296
|
+
const insertedIds = [];
|
|
50297
|
+
const { members, ...memberPayload } = payload;
|
|
50298
|
+
if (Array.isArray(members) && members.length > 0 && isAutoApprovedInvitation) {
|
|
50299
|
+
for (const member of members) {
|
|
50300
|
+
const memberId = await _add(
|
|
50301
|
+
{
|
|
50302
|
+
...memberPayload,
|
|
50303
|
+
...structuredClone(member),
|
|
50304
|
+
name: member.name ?? "",
|
|
50305
|
+
nric: member.nric ?? "",
|
|
50306
|
+
contact: member.contact ?? "",
|
|
50307
|
+
email: member.email ?? "",
|
|
50308
|
+
plateNumber: member.plateNumber ?? "",
|
|
50309
|
+
leadId
|
|
50310
|
+
},
|
|
50311
|
+
session
|
|
50312
|
+
);
|
|
50313
|
+
member._id = memberId;
|
|
50314
|
+
insertedIds.push(memberId);
|
|
50315
|
+
}
|
|
50316
|
+
}
|
|
50317
|
+
const result = await _add({ ...payload, _id: leadId }, session);
|
|
50318
|
+
insertedIds.push(result);
|
|
50274
50319
|
await session?.commitTransaction();
|
|
50275
|
-
return
|
|
50320
|
+
return insertedIds;
|
|
50276
50321
|
} catch (error) {
|
|
50277
50322
|
import_node_server_utils134.logger.error("Error in visitor transaction invite visitor:", error);
|
|
50278
50323
|
await session.abortTransaction();
|
|
@@ -54670,7 +54715,19 @@ function useVisitorTransactionController() {
|
|
|
54670
54715
|
isOvernightParking: import_joi65.default.boolean().optional().default(false),
|
|
54671
54716
|
numberOfPassengers: import_joi65.default.number().integer().optional().allow(null, ""),
|
|
54672
54717
|
purpose: import_joi65.default.string().optional().allow(null, ""),
|
|
54673
|
-
inviterUserId: import_joi65.default.string().hex().length(24).required()
|
|
54718
|
+
inviterUserId: import_joi65.default.string().hex().length(24).required(),
|
|
54719
|
+
type: import_joi65.default.string().valid("contractor", "guest").optional().allow(null, ""),
|
|
54720
|
+
contractorType: import_joi65.default.string().valid("home-contractor", "house-mover").optional().allow(null, ""),
|
|
54721
|
+
members: import_joi65.default.array().items(
|
|
54722
|
+
import_joi65.default.object({
|
|
54723
|
+
name: import_joi65.default.string().optional().allow(null, ""),
|
|
54724
|
+
nric: import_joi65.default.string().optional().allow(null, ""),
|
|
54725
|
+
contact: import_joi65.default.string().optional().allow(null, ""),
|
|
54726
|
+
email: import_joi65.default.string().email().optional().allow(null, ""),
|
|
54727
|
+
plateNumber: import_joi65.default.string().optional().allow(null, "")
|
|
54728
|
+
})
|
|
54729
|
+
).optional().allow(null),
|
|
54730
|
+
company: import_joi65.default.string().optional().allow(null, "")
|
|
54674
54731
|
});
|
|
54675
54732
|
const { error, value } = schema2.validate(
|
|
54676
54733
|
{ inviterUserId: req.params.inviterId, ...req.body },
|
|
@@ -54693,7 +54750,11 @@ function useVisitorTransactionController() {
|
|
|
54693
54750
|
isOvernightParking,
|
|
54694
54751
|
numberOfPassengers,
|
|
54695
54752
|
purpose,
|
|
54696
|
-
inviterUserId
|
|
54753
|
+
inviterUserId,
|
|
54754
|
+
type,
|
|
54755
|
+
contractorType,
|
|
54756
|
+
members,
|
|
54757
|
+
company
|
|
54697
54758
|
} = value;
|
|
54698
54759
|
const rest = {
|
|
54699
54760
|
expectedCheckIn,
|
|
@@ -54705,17 +54766,26 @@ function useVisitorTransactionController() {
|
|
|
54705
54766
|
plateNumber,
|
|
54706
54767
|
isOvernightParking,
|
|
54707
54768
|
numberOfPassengers,
|
|
54708
|
-
purpose
|
|
54769
|
+
purpose,
|
|
54770
|
+
type,
|
|
54771
|
+
contractorType,
|
|
54772
|
+
members,
|
|
54773
|
+
company
|
|
54709
54774
|
};
|
|
54710
54775
|
try {
|
|
54711
54776
|
const result = await _inviteVisitor(rest, inviterUserId);
|
|
54712
|
-
|
|
54713
|
-
|
|
54777
|
+
for (const insertedId of result) {
|
|
54778
|
+
resendEmailInvitedResident(String(insertedId), inviterUserId).catch((error2) => {
|
|
54714
54779
|
console.error(`Failed to send invitation email: ${error2.message}`);
|
|
54715
54780
|
import_node_server_utils137.logger.log({ level: "error", message: `Failed to send invitation email: ${error2.message}` });
|
|
54716
54781
|
});
|
|
54717
54782
|
}
|
|
54718
|
-
|
|
54783
|
+
const leadId = result[result.length - 1];
|
|
54784
|
+
if (!leadId) {
|
|
54785
|
+
next(new import_node_server_utils137.InternalServerError("Failed to create visitor invitation."));
|
|
54786
|
+
return;
|
|
54787
|
+
}
|
|
54788
|
+
res.status(200).json({ insertedId: leadId });
|
|
54719
54789
|
return;
|
|
54720
54790
|
} catch (error2) {
|
|
54721
54791
|
import_node_server_utils137.logger.log({ level: "error", message: error2.message });
|