@7365admin1/core 3.50.1-staging.219 → 3.50.1-staging.220
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 +5 -5
- package/dist/index.js +33 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4504,7 +4504,7 @@ type TKeyRef = {
|
|
|
4504
4504
|
add?: boolean;
|
|
4505
4505
|
};
|
|
4506
4506
|
type TVisitorTransaction = {
|
|
4507
|
-
_id?: ObjectId;
|
|
4507
|
+
_id?: ObjectId | string;
|
|
4508
4508
|
name?: string;
|
|
4509
4509
|
contact?: string;
|
|
4510
4510
|
type?: PersonTypes;
|
|
@@ -4533,7 +4533,7 @@ type TVisitorTransaction = {
|
|
|
4533
4533
|
manualCheckout?: boolean;
|
|
4534
4534
|
direction?: string;
|
|
4535
4535
|
members?: {
|
|
4536
|
-
_id?: ObjectId;
|
|
4536
|
+
_id?: ObjectId | string;
|
|
4537
4537
|
name: string;
|
|
4538
4538
|
nric: string;
|
|
4539
4539
|
visitorPass?: TKeyRef[] | null;
|
|
@@ -4557,7 +4557,7 @@ type TVisitorTransaction = {
|
|
|
4557
4557
|
deletedAt?: string | Date;
|
|
4558
4558
|
purpose?: string;
|
|
4559
4559
|
inviterId?: string | ObjectId;
|
|
4560
|
-
leadId?: ObjectId | null;
|
|
4560
|
+
leadId?: string | ObjectId | null;
|
|
4561
4561
|
createdBy?: string | ObjectId;
|
|
4562
4562
|
updatedBy?: string | ObjectId;
|
|
4563
4563
|
isMembersAdded?: boolean;
|
|
@@ -4620,7 +4620,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
|
|
|
4620
4620
|
email: string | undefined;
|
|
4621
4621
|
isOvernightParking: boolean;
|
|
4622
4622
|
inviterId: string | ObjectId;
|
|
4623
|
-
leadId: ObjectId | null;
|
|
4623
|
+
leadId: string | ObjectId | null;
|
|
4624
4624
|
overnightParking: {
|
|
4625
4625
|
status: string;
|
|
4626
4626
|
remarks: string;
|
|
@@ -4629,7 +4629,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
|
|
|
4629
4629
|
arrivalTime: string | null | undefined;
|
|
4630
4630
|
duration: number | null | undefined;
|
|
4631
4631
|
members: {
|
|
4632
|
-
_id?: ObjectId | undefined;
|
|
4632
|
+
_id?: string | ObjectId | undefined;
|
|
4633
4633
|
name: string;
|
|
4634
4634
|
nric: string;
|
|
4635
4635
|
visitorPass?: TKeyRef[] | null | undefined;
|
package/dist/index.js
CHANGED
|
@@ -19570,7 +19570,10 @@ var schemaVisitorTransaction = import_joi21.default.object({
|
|
|
19570
19570
|
remarks: import_joi21.default.string().optional().allow(null, "")
|
|
19571
19571
|
})
|
|
19572
19572
|
).optional().allow(null),
|
|
19573
|
-
contact: import_joi21.default.string().optional().allow(null, "")
|
|
19573
|
+
contact: import_joi21.default.string().optional().allow(null, ""),
|
|
19574
|
+
_id: import_joi21.default.string().hex().length(24).optional().allow(null, ""),
|
|
19575
|
+
email: import_joi21.default.string().email().optional().allow(null, ""),
|
|
19576
|
+
plateNumber: import_joi21.default.string().optional().allow(null, "")
|
|
19574
19577
|
})
|
|
19575
19578
|
).optional().allow(null),
|
|
19576
19579
|
unitName: import_joi21.default.string().optional().allow(null, ""),
|
|
@@ -19605,7 +19608,8 @@ var schemaVisitorTransaction = import_joi21.default.object({
|
|
|
19605
19608
|
expectedCheckIn: import_joi21.default.string().isoDate().optional(),
|
|
19606
19609
|
purpose: import_joi21.default.string().optional().allow(null, ""),
|
|
19607
19610
|
inviterId: import_joi21.default.any().optional().allow(null, ""),
|
|
19608
|
-
createdBy: import_joi21.default.string().hex().length(24).optional().allow(null, "")
|
|
19611
|
+
createdBy: import_joi21.default.string().hex().length(24).optional().allow(null, ""),
|
|
19612
|
+
leadId: import_joi21.default.string().hex().length(24).optional().allow(null, "")
|
|
19609
19613
|
});
|
|
19610
19614
|
var schemaSelfServiceVisitor = import_joi21.default.object({
|
|
19611
19615
|
// Only "Visitor" (wire value "guest", matching where staff already expect
|
|
@@ -19808,8 +19812,27 @@ function MVisitorTransaction(value) {
|
|
|
19808
19812
|
throw new Error("Invalid inviter ID.");
|
|
19809
19813
|
}
|
|
19810
19814
|
}
|
|
19815
|
+
if (value.leadId && typeof value.leadId === "string") {
|
|
19816
|
+
try {
|
|
19817
|
+
value.leadId = new import_mongodb39.ObjectId(value.leadId);
|
|
19818
|
+
} catch (error2) {
|
|
19819
|
+
throw new Error("Invalid lead ID.");
|
|
19820
|
+
}
|
|
19821
|
+
}
|
|
19822
|
+
if (Array.isArray(value.members)) {
|
|
19823
|
+
value.members = value.members.map((m) => {
|
|
19824
|
+
if (!m._id || typeof m._id !== "string")
|
|
19825
|
+
return m;
|
|
19826
|
+
try {
|
|
19827
|
+
return { ...m, _id: new import_mongodb39.ObjectId(m._id) };
|
|
19828
|
+
} catch (error2) {
|
|
19829
|
+
throw new Error("Invalid member ID.");
|
|
19830
|
+
}
|
|
19831
|
+
});
|
|
19832
|
+
}
|
|
19811
19833
|
const newDate = /* @__PURE__ */ new Date();
|
|
19812
19834
|
return {
|
|
19835
|
+
// guaranteed to be an ObjectId by the string cast above
|
|
19813
19836
|
_id: value._id,
|
|
19814
19837
|
name: value.name,
|
|
19815
19838
|
type: value.type ?? "guest" /* GUEST */,
|
|
@@ -19932,11 +19955,11 @@ function useVisitorTransactionRepo() {
|
|
|
19932
19955
|
}
|
|
19933
19956
|
async function add(value, session, returnValue = false) {
|
|
19934
19957
|
try {
|
|
19935
|
-
|
|
19936
|
-
const res = await collection.insertOne(
|
|
19958
|
+
const doc = MVisitorTransaction(value);
|
|
19959
|
+
const res = await collection.insertOne(doc, { session });
|
|
19937
19960
|
if (returnValue) {
|
|
19938
19961
|
return {
|
|
19939
|
-
...
|
|
19962
|
+
...doc,
|
|
19940
19963
|
_id: res.insertedId
|
|
19941
19964
|
};
|
|
19942
19965
|
} else {
|
|
@@ -19980,10 +20003,11 @@ function useVisitorTransactionRepo() {
|
|
|
19980
20003
|
}) {
|
|
19981
20004
|
page = page > 0 ? page - 1 : 0;
|
|
19982
20005
|
const skip = page * limit;
|
|
19983
|
-
const
|
|
20006
|
+
const isGuest = Array.isArray(status) && status.includes("approved") && status.includes("pending");
|
|
20007
|
+
console.log("isGuest: ", isGuest);
|
|
19984
20008
|
const checkInFilter = {};
|
|
19985
20009
|
const expectedCheckInFilter = {};
|
|
19986
|
-
if (!
|
|
20010
|
+
if (!isGuest) {
|
|
19987
20011
|
if (dateFrom)
|
|
19988
20012
|
checkInFilter.$gte = new Date(dateFrom);
|
|
19989
20013
|
if (dateTo)
|
|
@@ -50813,11 +50837,11 @@ function useVisitorTransactionService() {
|
|
|
50813
50837
|
contact: member.contact ?? "",
|
|
50814
50838
|
email: member.email ?? "",
|
|
50815
50839
|
plateNumber: member.plateNumber ?? "",
|
|
50816
|
-
leadId
|
|
50840
|
+
leadId: leadId.toString()
|
|
50817
50841
|
},
|
|
50818
50842
|
session
|
|
50819
50843
|
);
|
|
50820
|
-
member._id = memberId;
|
|
50844
|
+
member._id = memberId.toString();
|
|
50821
50845
|
insertedIds.push(memberId);
|
|
50822
50846
|
}
|
|
50823
50847
|
}
|
|
@@ -54979,10 +55003,6 @@ function useVisitorTransactionController() {
|
|
|
54979
55003
|
page: import_joi65.default.number().integer().min(1).allow("", null).default(1),
|
|
54980
55004
|
limit: import_joi65.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
54981
55005
|
sort: import_joi65.default.string().valid(...Object.values(VisitorSort)).optional().allow(null, ""),
|
|
54982
|
-
// Comma-separated, same shape as `type` below - the Guests tab needs
|
|
54983
|
-
// both "approved" and "pending" rows in one request so a
|
|
54984
|
-
// self-service submission awaiting Approve/Reject shows up
|
|
54985
|
-
// alongside already-approved guests.
|
|
54986
55006
|
status: import_joi65.default.alternatives().try(
|
|
54987
55007
|
import_joi65.default.array().items(
|
|
54988
55008
|
import_joi65.default.string().valid(...Object.values(VisitorStatus))
|