@7365admin1/core 2.36.1 → 2.37.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +13 -5
- package/dist/index.js +54 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +54 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -13185,12 +13185,12 @@ var schemaVisitorTransaction = Joi36.object({
|
|
|
13185
13185
|
numberOfPassengers: Joi36.number().integer().optional().allow(null, ""),
|
|
13186
13186
|
visitorPass: Joi36.array().items(
|
|
13187
13187
|
Joi36.object({
|
|
13188
|
-
keyId: Joi36.string().hex().length(24).
|
|
13188
|
+
keyId: Joi36.string().hex().length(24).allow(null, "")
|
|
13189
13189
|
})
|
|
13190
13190
|
).optional().allow(null),
|
|
13191
13191
|
passKeys: Joi36.array().items(
|
|
13192
13192
|
Joi36.object({
|
|
13193
|
-
keyId: Joi36.string().hex().length(24).
|
|
13193
|
+
keyId: Joi36.string().hex().length(24).allow(null, "")
|
|
13194
13194
|
})
|
|
13195
13195
|
).optional().allow(null),
|
|
13196
13196
|
checkInRemarks: Joi36.string().optional().allow("", null),
|
|
@@ -13313,7 +13313,7 @@ function MVisitorTransaction(value) {
|
|
|
13313
13313
|
throw new Error("Invalid invited ID.");
|
|
13314
13314
|
}
|
|
13315
13315
|
}
|
|
13316
|
-
const newDate =
|
|
13316
|
+
const newDate = /* @__PURE__ */ new Date();
|
|
13317
13317
|
return {
|
|
13318
13318
|
_id: value._id,
|
|
13319
13319
|
name: value.name,
|
|
@@ -13328,7 +13328,7 @@ function MVisitorTransaction(value) {
|
|
|
13328
13328
|
plateNumber: value.plateNumber,
|
|
13329
13329
|
recNo: value.recNo,
|
|
13330
13330
|
checkIn: value.checkIn === void 0 ? newDate : value.checkIn,
|
|
13331
|
-
expectedCheckIn: value.expectedCheckIn,
|
|
13331
|
+
expectedCheckIn: value.expectedCheckIn ? new Date(value.expectedCheckIn) : void 0,
|
|
13332
13332
|
checkOut: value.checkOut,
|
|
13333
13333
|
status: value.status,
|
|
13334
13334
|
remarks: value.remarks,
|
|
@@ -13358,7 +13358,9 @@ function MVisitorTransaction(value) {
|
|
|
13358
13358
|
status: "pending approval",
|
|
13359
13359
|
remarks: "",
|
|
13360
13360
|
updatedBy: value.invitedId ?? ""
|
|
13361
|
-
} : null
|
|
13361
|
+
} : null,
|
|
13362
|
+
arrivalTime: value.arrivalTime,
|
|
13363
|
+
duration: value.duration
|
|
13362
13364
|
};
|
|
13363
13365
|
}
|
|
13364
13366
|
|
|
@@ -13417,34 +13419,27 @@ function useVisitorTransactionRepo() {
|
|
|
13417
13419
|
}) {
|
|
13418
13420
|
page = page > 0 ? page - 1 : 0;
|
|
13419
13421
|
const skip = page * limit;
|
|
13420
|
-
|
|
13421
|
-
const
|
|
13422
|
-
if (
|
|
13423
|
-
|
|
13424
|
-
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
};
|
|
13433
|
-
} else if (dateTo) {
|
|
13434
|
-
checkOutFilter = {
|
|
13435
|
-
$or: [
|
|
13436
|
-
{ checkOut: { $lte: new Date(dateTo).toISOString() } },
|
|
13437
|
-
{ checkOut: null }
|
|
13438
|
-
]
|
|
13439
|
-
};
|
|
13422
|
+
const checkInFilter = {};
|
|
13423
|
+
const expectedCheckInFilter = {};
|
|
13424
|
+
if (status != "approved") {
|
|
13425
|
+
if (dateFrom)
|
|
13426
|
+
checkInFilter.$gte = new Date(dateFrom);
|
|
13427
|
+
if (dateTo)
|
|
13428
|
+
checkInFilter.$lte = new Date(dateTo);
|
|
13429
|
+
} else {
|
|
13430
|
+
if (dateFrom)
|
|
13431
|
+
expectedCheckInFilter.$gte = new Date(dateFrom);
|
|
13432
|
+
if (dateTo)
|
|
13433
|
+
expectedCheckInFilter.$lte = new Date(dateTo);
|
|
13440
13434
|
}
|
|
13441
13435
|
const query = {
|
|
13442
13436
|
status,
|
|
13443
13437
|
...ObjectId40.isValid(org) && { org: new ObjectId40(org) },
|
|
13444
13438
|
...ObjectId40.isValid(site) && { site: new ObjectId40(site) },
|
|
13445
|
-
...
|
|
13439
|
+
...Object.keys(checkInFilter).length > 0 && { checkIn: checkInFilter },
|
|
13440
|
+
...Object.keys(expectedCheckInFilter).length > 0 && { expectedCheckIn: expectedCheckInFilter },
|
|
13446
13441
|
...Array.isArray(type) ? { type: { $in: type } } : type ? { type } : {},
|
|
13447
|
-
...
|
|
13442
|
+
...checkedOut == false && { checkOut: { $eq: null } },
|
|
13448
13443
|
...search && { $text: { $search: search } },
|
|
13449
13444
|
...plateNumber && { plateNumber }
|
|
13450
13445
|
};
|
|
@@ -13667,7 +13662,7 @@ function useVisitorTransactionRepo() {
|
|
|
13667
13662
|
} catch (error) {
|
|
13668
13663
|
throw new BadRequestError66("Invalid visitor transaction ID format.");
|
|
13669
13664
|
}
|
|
13670
|
-
value.updatedAt =
|
|
13665
|
+
value.updatedAt = /* @__PURE__ */ new Date();
|
|
13671
13666
|
if (value.checkOut) {
|
|
13672
13667
|
value.manualCheckout = true;
|
|
13673
13668
|
}
|
|
@@ -13691,8 +13686,8 @@ function useVisitorTransactionRepo() {
|
|
|
13691
13686
|
try {
|
|
13692
13687
|
const updateValue = {
|
|
13693
13688
|
status: "deleted",
|
|
13694
|
-
updatedAt:
|
|
13695
|
-
deletedAt:
|
|
13689
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
13690
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
13696
13691
|
};
|
|
13697
13692
|
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
13698
13693
|
if (res.modifiedCount === 0) {
|
|
@@ -13705,7 +13700,7 @@ function useVisitorTransactionRepo() {
|
|
|
13705
13700
|
}
|
|
13706
13701
|
async function getDeliveryPickupTransactions() {
|
|
13707
13702
|
try {
|
|
13708
|
-
const now =
|
|
13703
|
+
const now = /* @__PURE__ */ new Date();
|
|
13709
13704
|
const result = await collection.find(
|
|
13710
13705
|
{
|
|
13711
13706
|
type: {
|
|
@@ -13732,7 +13727,7 @@ function useVisitorTransactionRepo() {
|
|
|
13732
13727
|
async function getExpiredCheckedOutTransactionsBySite(siteId) {
|
|
13733
13728
|
const site = toObjectId7(siteId);
|
|
13734
13729
|
try {
|
|
13735
|
-
const now =
|
|
13730
|
+
const now = /* @__PURE__ */ new Date();
|
|
13736
13731
|
const expiredTransactions = await collection.find({
|
|
13737
13732
|
$or: [
|
|
13738
13733
|
{ expiredAt: { $lte: now } },
|
|
@@ -13758,7 +13753,7 @@ function useVisitorTransactionRepo() {
|
|
|
13758
13753
|
{
|
|
13759
13754
|
$set: {
|
|
13760
13755
|
dahuaSyncStatus,
|
|
13761
|
-
updatedAt:
|
|
13756
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
13762
13757
|
}
|
|
13763
13758
|
},
|
|
13764
13759
|
{ session }
|
|
@@ -16997,13 +16992,15 @@ var schemaBuilding = Joi43.object({
|
|
|
16997
16992
|
updatedAt: Joi43.date().optional().allow("", null),
|
|
16998
16993
|
deletedAt: Joi43.date().optional().allow("", null),
|
|
16999
16994
|
status: Joi43.string().optional().allow("", null),
|
|
17000
|
-
buildingFloorPlan:
|
|
16995
|
+
// buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
|
|
16996
|
+
buildingFiles: Joi43.array().items({ id: Joi43.string().hex().optional().allow("", null), name: Joi43.string().optional().allow("", null) }).optional().allow("", null)
|
|
17001
16997
|
});
|
|
17002
16998
|
var schemaBuildingUpdateOptions = Joi43.object({
|
|
17003
16999
|
name: Joi43.string().optional().allow("", null),
|
|
17004
17000
|
levels: Joi43.array().items(Joi43.string().required()).min(1).required(),
|
|
17005
17001
|
block: Joi43.number().integer().min(1).required(),
|
|
17006
|
-
buildingFloorPlan:
|
|
17002
|
+
// buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
|
|
17003
|
+
buildingFiles: Joi43.array().items({ id: Joi43.string().hex().optional().allow("", null), name: Joi43.string().optional().allow("", null) }).optional().allow("", null)
|
|
17007
17004
|
});
|
|
17008
17005
|
var schemaBilling = Joi43.object({
|
|
17009
17006
|
_id: Joi43.string().hex().optional(),
|
|
@@ -17069,7 +17066,8 @@ function MBuilding(value) {
|
|
|
17069
17066
|
block: value.block ?? 0,
|
|
17070
17067
|
levels: value.levels ?? "",
|
|
17071
17068
|
status: value.status ?? "active",
|
|
17072
|
-
buildingFloorPlan: value.buildingFloorPlan ?? [],
|
|
17069
|
+
// buildingFloorPlan: value.buildingFloorPlan ?? [],
|
|
17070
|
+
buildingFiles: value.buildingFiles ?? [],
|
|
17073
17071
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
17074
17072
|
updatedAt: value.updatedAt ?? "",
|
|
17075
17073
|
deletedAt: value.deletedAt ?? ""
|
|
@@ -17999,11 +17997,11 @@ function useBuildingService() {
|
|
|
17999
17997
|
}
|
|
18000
17998
|
try {
|
|
18001
17999
|
await session.startTransaction();
|
|
18002
|
-
const
|
|
18003
|
-
if (
|
|
18004
|
-
for (const
|
|
18000
|
+
const buildingFiles = value?.buildingFiles ?? [];
|
|
18001
|
+
if (buildingFiles.length > 0) {
|
|
18002
|
+
for (const buildingFile of buildingFiles) {
|
|
18005
18003
|
const file = await updateStatusById(
|
|
18006
|
-
|
|
18004
|
+
buildingFile.id,
|
|
18007
18005
|
{ status: "active" },
|
|
18008
18006
|
session
|
|
18009
18007
|
);
|
|
@@ -18037,12 +18035,12 @@ function useBuildingService() {
|
|
|
18037
18035
|
if (!building) {
|
|
18038
18036
|
throw new NotFoundError18("Building not found.");
|
|
18039
18037
|
}
|
|
18040
|
-
const
|
|
18041
|
-
const
|
|
18038
|
+
const dataFiles = data?.buildingFiles || [];
|
|
18039
|
+
const buildingFiles = building?.buildingFiles || [];
|
|
18042
18040
|
const deletedFiles = [];
|
|
18043
|
-
|
|
18044
|
-
if (!
|
|
18045
|
-
deletedFiles.push(
|
|
18041
|
+
buildingFiles.forEach((file) => {
|
|
18042
|
+
if (!dataFiles.find((f) => f.id === file.id)) {
|
|
18043
|
+
deletedFiles.push(file.id);
|
|
18046
18044
|
}
|
|
18047
18045
|
});
|
|
18048
18046
|
if (deletedFiles.length > 0) {
|
|
@@ -18138,7 +18136,8 @@ function useBuildingController() {
|
|
|
18138
18136
|
levels: Joi44.array().items(Joi44.string().required()).min(1).required(),
|
|
18139
18137
|
serial: Joi44.string().optional().allow("", null),
|
|
18140
18138
|
status: Joi44.string().optional().allow("", null),
|
|
18141
|
-
buildingFloorPlan:
|
|
18139
|
+
// buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
|
|
18140
|
+
buildingFiles: Joi44.array().items({ id: Joi44.string().hex().optional().allow("", null), name: Joi44.string().optional().allow("", null) }).optional().allow("", null)
|
|
18142
18141
|
});
|
|
18143
18142
|
const { error } = validation.validate(value);
|
|
18144
18143
|
if (error) {
|
|
@@ -21874,6 +21873,8 @@ function useVisitorTransactionService() {
|
|
|
21874
21873
|
try {
|
|
21875
21874
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21876
21875
|
const visitorPassId = typeof vp === "string" || vp instanceof ObjectId58 ? vp : vp.keyId;
|
|
21876
|
+
if (!visitorPassId)
|
|
21877
|
+
value.visitorPass = [];
|
|
21877
21878
|
await KeyRepo.updateKeyById(
|
|
21878
21879
|
visitorPassId,
|
|
21879
21880
|
updatePayload,
|
|
@@ -21889,6 +21890,8 @@ function useVisitorTransactionService() {
|
|
|
21889
21890
|
try {
|
|
21890
21891
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21891
21892
|
const passKeyId = typeof pk === "string" || pk instanceof ObjectId58 ? pk : pk.keyId;
|
|
21893
|
+
if (!passKeyId)
|
|
21894
|
+
value.passKeys = [];
|
|
21892
21895
|
await KeyRepo.updateKeyById(
|
|
21893
21896
|
passKeyId,
|
|
21894
21897
|
updatePayload,
|
|
@@ -22000,11 +22003,13 @@ function useVisitorTransactionService() {
|
|
|
22000
22003
|
value.recNo = parsed.recNo;
|
|
22001
22004
|
}
|
|
22002
22005
|
}
|
|
22003
|
-
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
22006
|
+
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0 && value.visitorPass) {
|
|
22004
22007
|
for (const vp of value.visitorPass) {
|
|
22005
22008
|
try {
|
|
22006
22009
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
22007
22010
|
const visitorPassId = typeof vp === "string" || vp instanceof ObjectId58 ? vp : vp.keyId;
|
|
22011
|
+
if (!visitorPassId)
|
|
22012
|
+
value.visitorPass = [];
|
|
22008
22013
|
await KeyRepo.updateKeyById(
|
|
22009
22014
|
visitorPassId,
|
|
22010
22015
|
updatePayload,
|
|
@@ -22020,6 +22025,8 @@ function useVisitorTransactionService() {
|
|
|
22020
22025
|
try {
|
|
22021
22026
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
22022
22027
|
const passKeyId = typeof pk === "string" || pk instanceof ObjectId58 ? pk : pk.keyId;
|
|
22028
|
+
if (!passKeyId)
|
|
22029
|
+
value.passKeys = [];
|
|
22023
22030
|
await KeyRepo.updateKeyById(
|
|
22024
22031
|
passKeyId,
|
|
22025
22032
|
updatePayload,
|