@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/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1709,7 +1709,10 @@ type TBuilding = {
|
|
|
1709
1709
|
updatedAt?: Date | string;
|
|
1710
1710
|
deletedAt?: Date | string;
|
|
1711
1711
|
status?: string;
|
|
1712
|
-
|
|
1712
|
+
buildingFiles?: Array<{
|
|
1713
|
+
id: string;
|
|
1714
|
+
name: string;
|
|
1715
|
+
}>;
|
|
1713
1716
|
};
|
|
1714
1717
|
declare const schemaBuilding: Joi.ObjectSchema<any>;
|
|
1715
1718
|
declare const schemaBuildingUpdateOptions: Joi.ObjectSchema<any>;
|
|
@@ -1749,7 +1752,10 @@ declare function MBuilding(value: TBuilding): {
|
|
|
1749
1752
|
block: number;
|
|
1750
1753
|
levels: string[];
|
|
1751
1754
|
status: string;
|
|
1752
|
-
|
|
1755
|
+
buildingFiles: {
|
|
1756
|
+
id: string;
|
|
1757
|
+
name: string;
|
|
1758
|
+
}[];
|
|
1753
1759
|
createdAt: string | Date;
|
|
1754
1760
|
updatedAt: string | Date;
|
|
1755
1761
|
deletedAt: string | Date;
|
|
@@ -1790,14 +1796,14 @@ declare function useBuildingRepo(): {
|
|
|
1790
1796
|
status?: BuildingStatus | undefined;
|
|
1791
1797
|
}) => Promise<Record<string, any>>;
|
|
1792
1798
|
getById: (_id: string | ObjectId) => Promise<TBuilding | null>;
|
|
1793
|
-
updateById: (_id: ObjectId | string, value: Pick<TBuilding, "name" | "block" | "levels" | "
|
|
1799
|
+
updateById: (_id: ObjectId | string, value: Pick<TBuilding, "name" | "block" | "levels" | "buildingFiles">, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
1794
1800
|
deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
1795
1801
|
getBuildingLevel: (site: string | ObjectId, block: number) => Promise<mongodb.WithId<bson.Document> | TBuilding | null>;
|
|
1796
1802
|
};
|
|
1797
1803
|
|
|
1798
1804
|
declare function useBuildingService(): {
|
|
1799
1805
|
add: (value: TBuilding) => Promise<bson.ObjectId>;
|
|
1800
|
-
updateById: (id: string, data: Pick<TBuilding, "name" | "block" | "levels" | "
|
|
1806
|
+
updateById: (id: string, data: Pick<TBuilding, "name" | "block" | "levels" | "buildingFiles">) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
1801
1807
|
deleteById: (id: string) => Promise<string>;
|
|
1802
1808
|
};
|
|
1803
1809
|
|
|
@@ -2577,7 +2583,7 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
|
|
|
2577
2583
|
plateNumber: string | undefined;
|
|
2578
2584
|
recNo: string | undefined;
|
|
2579
2585
|
checkIn: string | Date | null;
|
|
2580
|
-
expectedCheckIn:
|
|
2586
|
+
expectedCheckIn: Date | undefined;
|
|
2581
2587
|
checkOut: string | Date | undefined;
|
|
2582
2588
|
status: VisitorStatus | undefined;
|
|
2583
2589
|
remarks: string | undefined;
|
|
@@ -2608,6 +2614,8 @@ declare function MVisitorTransaction(value: TVisitorTransaction): {
|
|
|
2608
2614
|
remarks: string;
|
|
2609
2615
|
updatedBy: string | ObjectId;
|
|
2610
2616
|
} | null;
|
|
2617
|
+
arrivalTime: string | null | undefined;
|
|
2618
|
+
duration: number | null | undefined;
|
|
2611
2619
|
};
|
|
2612
2620
|
|
|
2613
2621
|
declare const visitors_namespace_collection = "visitor.transactions";
|
package/dist/index.js
CHANGED
|
@@ -13387,12 +13387,12 @@ var schemaVisitorTransaction = import_joi36.default.object({
|
|
|
13387
13387
|
numberOfPassengers: import_joi36.default.number().integer().optional().allow(null, ""),
|
|
13388
13388
|
visitorPass: import_joi36.default.array().items(
|
|
13389
13389
|
import_joi36.default.object({
|
|
13390
|
-
keyId: import_joi36.default.string().hex().length(24).
|
|
13390
|
+
keyId: import_joi36.default.string().hex().length(24).allow(null, "")
|
|
13391
13391
|
})
|
|
13392
13392
|
).optional().allow(null),
|
|
13393
13393
|
passKeys: import_joi36.default.array().items(
|
|
13394
13394
|
import_joi36.default.object({
|
|
13395
|
-
keyId: import_joi36.default.string().hex().length(24).
|
|
13395
|
+
keyId: import_joi36.default.string().hex().length(24).allow(null, "")
|
|
13396
13396
|
})
|
|
13397
13397
|
).optional().allow(null),
|
|
13398
13398
|
checkInRemarks: import_joi36.default.string().optional().allow("", null),
|
|
@@ -13515,7 +13515,7 @@ function MVisitorTransaction(value) {
|
|
|
13515
13515
|
throw new Error("Invalid invited ID.");
|
|
13516
13516
|
}
|
|
13517
13517
|
}
|
|
13518
|
-
const newDate =
|
|
13518
|
+
const newDate = /* @__PURE__ */ new Date();
|
|
13519
13519
|
return {
|
|
13520
13520
|
_id: value._id,
|
|
13521
13521
|
name: value.name,
|
|
@@ -13530,7 +13530,7 @@ function MVisitorTransaction(value) {
|
|
|
13530
13530
|
plateNumber: value.plateNumber,
|
|
13531
13531
|
recNo: value.recNo,
|
|
13532
13532
|
checkIn: value.checkIn === void 0 ? newDate : value.checkIn,
|
|
13533
|
-
expectedCheckIn: value.expectedCheckIn,
|
|
13533
|
+
expectedCheckIn: value.expectedCheckIn ? new Date(value.expectedCheckIn) : void 0,
|
|
13534
13534
|
checkOut: value.checkOut,
|
|
13535
13535
|
status: value.status,
|
|
13536
13536
|
remarks: value.remarks,
|
|
@@ -13560,7 +13560,9 @@ function MVisitorTransaction(value) {
|
|
|
13560
13560
|
status: "pending approval",
|
|
13561
13561
|
remarks: "",
|
|
13562
13562
|
updatedBy: value.invitedId ?? ""
|
|
13563
|
-
} : null
|
|
13563
|
+
} : null,
|
|
13564
|
+
arrivalTime: value.arrivalTime,
|
|
13565
|
+
duration: value.duration
|
|
13564
13566
|
};
|
|
13565
13567
|
}
|
|
13566
13568
|
|
|
@@ -13619,34 +13621,27 @@ function useVisitorTransactionRepo() {
|
|
|
13619
13621
|
}) {
|
|
13620
13622
|
page = page > 0 ? page - 1 : 0;
|
|
13621
13623
|
const skip = page * limit;
|
|
13622
|
-
|
|
13623
|
-
const
|
|
13624
|
-
if (
|
|
13625
|
-
|
|
13626
|
-
|
|
13627
|
-
|
|
13628
|
-
|
|
13629
|
-
|
|
13630
|
-
|
|
13631
|
-
|
|
13632
|
-
|
|
13633
|
-
|
|
13634
|
-
};
|
|
13635
|
-
} else if (dateTo) {
|
|
13636
|
-
checkOutFilter = {
|
|
13637
|
-
$or: [
|
|
13638
|
-
{ checkOut: { $lte: new Date(dateTo).toISOString() } },
|
|
13639
|
-
{ checkOut: null }
|
|
13640
|
-
]
|
|
13641
|
-
};
|
|
13624
|
+
const checkInFilter = {};
|
|
13625
|
+
const expectedCheckInFilter = {};
|
|
13626
|
+
if (status != "approved") {
|
|
13627
|
+
if (dateFrom)
|
|
13628
|
+
checkInFilter.$gte = new Date(dateFrom);
|
|
13629
|
+
if (dateTo)
|
|
13630
|
+
checkInFilter.$lte = new Date(dateTo);
|
|
13631
|
+
} else {
|
|
13632
|
+
if (dateFrom)
|
|
13633
|
+
expectedCheckInFilter.$gte = new Date(dateFrom);
|
|
13634
|
+
if (dateTo)
|
|
13635
|
+
expectedCheckInFilter.$lte = new Date(dateTo);
|
|
13642
13636
|
}
|
|
13643
13637
|
const query = {
|
|
13644
13638
|
status,
|
|
13645
13639
|
...import_mongodb40.ObjectId.isValid(org) && { org: new import_mongodb40.ObjectId(org) },
|
|
13646
13640
|
...import_mongodb40.ObjectId.isValid(site) && { site: new import_mongodb40.ObjectId(site) },
|
|
13647
|
-
...
|
|
13641
|
+
...Object.keys(checkInFilter).length > 0 && { checkIn: checkInFilter },
|
|
13642
|
+
...Object.keys(expectedCheckInFilter).length > 0 && { expectedCheckIn: expectedCheckInFilter },
|
|
13648
13643
|
...Array.isArray(type) ? { type: { $in: type } } : type ? { type } : {},
|
|
13649
|
-
...
|
|
13644
|
+
...checkedOut == false && { checkOut: { $eq: null } },
|
|
13650
13645
|
...search && { $text: { $search: search } },
|
|
13651
13646
|
...plateNumber && { plateNumber }
|
|
13652
13647
|
};
|
|
@@ -13869,7 +13864,7 @@ function useVisitorTransactionRepo() {
|
|
|
13869
13864
|
} catch (error) {
|
|
13870
13865
|
throw new import_node_server_utils68.BadRequestError("Invalid visitor transaction ID format.");
|
|
13871
13866
|
}
|
|
13872
|
-
value.updatedAt =
|
|
13867
|
+
value.updatedAt = /* @__PURE__ */ new Date();
|
|
13873
13868
|
if (value.checkOut) {
|
|
13874
13869
|
value.manualCheckout = true;
|
|
13875
13870
|
}
|
|
@@ -13893,8 +13888,8 @@ function useVisitorTransactionRepo() {
|
|
|
13893
13888
|
try {
|
|
13894
13889
|
const updateValue = {
|
|
13895
13890
|
status: "deleted",
|
|
13896
|
-
updatedAt:
|
|
13897
|
-
deletedAt:
|
|
13891
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
13892
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
13898
13893
|
};
|
|
13899
13894
|
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
13900
13895
|
if (res.modifiedCount === 0) {
|
|
@@ -13907,7 +13902,7 @@ function useVisitorTransactionRepo() {
|
|
|
13907
13902
|
}
|
|
13908
13903
|
async function getDeliveryPickupTransactions() {
|
|
13909
13904
|
try {
|
|
13910
|
-
const now =
|
|
13905
|
+
const now = /* @__PURE__ */ new Date();
|
|
13911
13906
|
const result = await collection.find(
|
|
13912
13907
|
{
|
|
13913
13908
|
type: {
|
|
@@ -13934,7 +13929,7 @@ function useVisitorTransactionRepo() {
|
|
|
13934
13929
|
async function getExpiredCheckedOutTransactionsBySite(siteId) {
|
|
13935
13930
|
const site = (0, import_node_server_utils68.toObjectId)(siteId);
|
|
13936
13931
|
try {
|
|
13937
|
-
const now =
|
|
13932
|
+
const now = /* @__PURE__ */ new Date();
|
|
13938
13933
|
const expiredTransactions = await collection.find({
|
|
13939
13934
|
$or: [
|
|
13940
13935
|
{ expiredAt: { $lte: now } },
|
|
@@ -13960,7 +13955,7 @@ function useVisitorTransactionRepo() {
|
|
|
13960
13955
|
{
|
|
13961
13956
|
$set: {
|
|
13962
13957
|
dahuaSyncStatus,
|
|
13963
|
-
updatedAt:
|
|
13958
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
13964
13959
|
}
|
|
13965
13960
|
},
|
|
13966
13961
|
{ session }
|
|
@@ -17171,13 +17166,15 @@ var schemaBuilding = import_joi43.default.object({
|
|
|
17171
17166
|
updatedAt: import_joi43.default.date().optional().allow("", null),
|
|
17172
17167
|
deletedAt: import_joi43.default.date().optional().allow("", null),
|
|
17173
17168
|
status: import_joi43.default.string().optional().allow("", null),
|
|
17174
|
-
buildingFloorPlan:
|
|
17169
|
+
// buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
|
|
17170
|
+
buildingFiles: import_joi43.default.array().items({ id: import_joi43.default.string().hex().optional().allow("", null), name: import_joi43.default.string().optional().allow("", null) }).optional().allow("", null)
|
|
17175
17171
|
});
|
|
17176
17172
|
var schemaBuildingUpdateOptions = import_joi43.default.object({
|
|
17177
17173
|
name: import_joi43.default.string().optional().allow("", null),
|
|
17178
17174
|
levels: import_joi43.default.array().items(import_joi43.default.string().required()).min(1).required(),
|
|
17179
17175
|
block: import_joi43.default.number().integer().min(1).required(),
|
|
17180
|
-
buildingFloorPlan:
|
|
17176
|
+
// buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
|
|
17177
|
+
buildingFiles: import_joi43.default.array().items({ id: import_joi43.default.string().hex().optional().allow("", null), name: import_joi43.default.string().optional().allow("", null) }).optional().allow("", null)
|
|
17181
17178
|
});
|
|
17182
17179
|
var schemaBilling = import_joi43.default.object({
|
|
17183
17180
|
_id: import_joi43.default.string().hex().optional(),
|
|
@@ -17243,7 +17240,8 @@ function MBuilding(value) {
|
|
|
17243
17240
|
block: value.block ?? 0,
|
|
17244
17241
|
levels: value.levels ?? "",
|
|
17245
17242
|
status: value.status ?? "active",
|
|
17246
|
-
buildingFloorPlan: value.buildingFloorPlan ?? [],
|
|
17243
|
+
// buildingFloorPlan: value.buildingFloorPlan ?? [],
|
|
17244
|
+
buildingFiles: value.buildingFiles ?? [],
|
|
17247
17245
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
17248
17246
|
updatedAt: value.updatedAt ?? "",
|
|
17249
17247
|
deletedAt: value.deletedAt ?? ""
|
|
@@ -18149,11 +18147,11 @@ function useBuildingService() {
|
|
|
18149
18147
|
}
|
|
18150
18148
|
try {
|
|
18151
18149
|
await session.startTransaction();
|
|
18152
|
-
const
|
|
18153
|
-
if (
|
|
18154
|
-
for (const
|
|
18150
|
+
const buildingFiles = value?.buildingFiles ?? [];
|
|
18151
|
+
if (buildingFiles.length > 0) {
|
|
18152
|
+
for (const buildingFile of buildingFiles) {
|
|
18155
18153
|
const file = await updateStatusById(
|
|
18156
|
-
|
|
18154
|
+
buildingFile.id,
|
|
18157
18155
|
{ status: "active" },
|
|
18158
18156
|
session
|
|
18159
18157
|
);
|
|
@@ -18187,12 +18185,12 @@ function useBuildingService() {
|
|
|
18187
18185
|
if (!building) {
|
|
18188
18186
|
throw new import_node_server_utils82.NotFoundError("Building not found.");
|
|
18189
18187
|
}
|
|
18190
|
-
const
|
|
18191
|
-
const
|
|
18188
|
+
const dataFiles = data?.buildingFiles || [];
|
|
18189
|
+
const buildingFiles = building?.buildingFiles || [];
|
|
18192
18190
|
const deletedFiles = [];
|
|
18193
|
-
|
|
18194
|
-
if (!
|
|
18195
|
-
deletedFiles.push(
|
|
18191
|
+
buildingFiles.forEach((file) => {
|
|
18192
|
+
if (!dataFiles.find((f) => f.id === file.id)) {
|
|
18193
|
+
deletedFiles.push(file.id);
|
|
18196
18194
|
}
|
|
18197
18195
|
});
|
|
18198
18196
|
if (deletedFiles.length > 0) {
|
|
@@ -18288,7 +18286,8 @@ function useBuildingController() {
|
|
|
18288
18286
|
levels: import_joi44.default.array().items(import_joi44.default.string().required()).min(1).required(),
|
|
18289
18287
|
serial: import_joi44.default.string().optional().allow("", null),
|
|
18290
18288
|
status: import_joi44.default.string().optional().allow("", null),
|
|
18291
|
-
buildingFloorPlan:
|
|
18289
|
+
// buildingFloorPlan: Joi.array().items(Joi.string()).optional(),
|
|
18290
|
+
buildingFiles: import_joi44.default.array().items({ id: import_joi44.default.string().hex().optional().allow("", null), name: import_joi44.default.string().optional().allow("", null) }).optional().allow("", null)
|
|
18292
18291
|
});
|
|
18293
18292
|
const { error } = validation.validate(value);
|
|
18294
18293
|
if (error) {
|
|
@@ -21976,6 +21975,8 @@ function useVisitorTransactionService() {
|
|
|
21976
21975
|
try {
|
|
21977
21976
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21978
21977
|
const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb58.ObjectId ? vp : vp.keyId;
|
|
21978
|
+
if (!visitorPassId)
|
|
21979
|
+
value.visitorPass = [];
|
|
21979
21980
|
await KeyRepo.updateKeyById(
|
|
21980
21981
|
visitorPassId,
|
|
21981
21982
|
updatePayload,
|
|
@@ -21991,6 +21992,8 @@ function useVisitorTransactionService() {
|
|
|
21991
21992
|
try {
|
|
21992
21993
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
21993
21994
|
const passKeyId = typeof pk === "string" || pk instanceof import_mongodb58.ObjectId ? pk : pk.keyId;
|
|
21995
|
+
if (!passKeyId)
|
|
21996
|
+
value.passKeys = [];
|
|
21994
21997
|
await KeyRepo.updateKeyById(
|
|
21995
21998
|
passKeyId,
|
|
21996
21999
|
updatePayload,
|
|
@@ -22102,11 +22105,13 @@ function useVisitorTransactionService() {
|
|
|
22102
22105
|
value.recNo = parsed.recNo;
|
|
22103
22106
|
}
|
|
22104
22107
|
}
|
|
22105
|
-
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
22108
|
+
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0 && value.visitorPass) {
|
|
22106
22109
|
for (const vp of value.visitorPass) {
|
|
22107
22110
|
try {
|
|
22108
22111
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
22109
22112
|
const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb58.ObjectId ? vp : vp.keyId;
|
|
22113
|
+
if (!visitorPassId)
|
|
22114
|
+
value.visitorPass = [];
|
|
22110
22115
|
await KeyRepo.updateKeyById(
|
|
22111
22116
|
visitorPassId,
|
|
22112
22117
|
updatePayload,
|
|
@@ -22122,6 +22127,8 @@ function useVisitorTransactionService() {
|
|
|
22122
22127
|
try {
|
|
22123
22128
|
const updatePayload = { status: "In Use" /* IN_USE */ };
|
|
22124
22129
|
const passKeyId = typeof pk === "string" || pk instanceof import_mongodb58.ObjectId ? pk : pk.keyId;
|
|
22130
|
+
if (!passKeyId)
|
|
22131
|
+
value.passKeys = [];
|
|
22125
22132
|
await KeyRepo.updateKeyById(
|
|
22126
22133
|
passKeyId,
|
|
22127
22134
|
updatePayload,
|