@7365admin1/core 3.14.0 → 3.16.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 +12 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +758 -489
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +656 -389
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -537,13 +537,13 @@ var require_logger = __commonJS({
|
|
|
537
537
|
"use strict";
|
|
538
538
|
exports.__esModule = true;
|
|
539
539
|
var _utils = require_utils();
|
|
540
|
-
var
|
|
540
|
+
var logger201 = {
|
|
541
541
|
methodMap: ["debug", "info", "warn", "error"],
|
|
542
542
|
level: "info",
|
|
543
543
|
// Maps a given level value to the `methodMap` indexes above.
|
|
544
544
|
lookupLevel: function lookupLevel(level) {
|
|
545
545
|
if (typeof level === "string") {
|
|
546
|
-
var levelMap = _utils.indexOf(
|
|
546
|
+
var levelMap = _utils.indexOf(logger201.methodMap, level.toLowerCase());
|
|
547
547
|
if (levelMap >= 0) {
|
|
548
548
|
level = levelMap;
|
|
549
549
|
} else {
|
|
@@ -554,9 +554,9 @@ var require_logger = __commonJS({
|
|
|
554
554
|
},
|
|
555
555
|
// Can be overridden in the host environment
|
|
556
556
|
log: function log(level) {
|
|
557
|
-
level =
|
|
558
|
-
if (typeof console !== "undefined" &&
|
|
559
|
-
var method =
|
|
557
|
+
level = logger201.lookupLevel(level);
|
|
558
|
+
if (typeof console !== "undefined" && logger201.lookupLevel(logger201.level) <= level) {
|
|
559
|
+
var method = logger201.methodMap[level];
|
|
560
560
|
if (!console[method]) {
|
|
561
561
|
method = "log";
|
|
562
562
|
}
|
|
@@ -567,7 +567,7 @@ var require_logger = __commonJS({
|
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
|
-
exports["default"] =
|
|
570
|
+
exports["default"] = logger201;
|
|
571
571
|
module.exports = exports["default"];
|
|
572
572
|
}
|
|
573
573
|
});
|
|
@@ -8280,12 +8280,6 @@ function useUserRepo() {
|
|
|
8280
8280
|
throw new BadRequestError9("Invalid user ID format.");
|
|
8281
8281
|
}
|
|
8282
8282
|
try {
|
|
8283
|
-
const cacheKey = makeCacheKey5(namespace_collection, { _id });
|
|
8284
|
-
const cachedData = await getCache(cacheKey);
|
|
8285
|
-
if (cachedData) {
|
|
8286
|
-
logger7.info(`Cache hit for key: ${cacheKey}`);
|
|
8287
|
-
return cachedData;
|
|
8288
|
-
}
|
|
8289
8283
|
const results = await collection.aggregate([
|
|
8290
8284
|
{ $match: { _id } },
|
|
8291
8285
|
{
|
|
@@ -8309,17 +8303,42 @@ function useUserRepo() {
|
|
|
8309
8303
|
],
|
|
8310
8304
|
as: "serviceProviders"
|
|
8311
8305
|
}
|
|
8312
|
-
}
|
|
8306
|
+
},
|
|
8307
|
+
{
|
|
8308
|
+
$lookup: {
|
|
8309
|
+
from: "buildings",
|
|
8310
|
+
localField: "block",
|
|
8311
|
+
foreignField: "_id",
|
|
8312
|
+
pipeline: [{ $project: { _id: 0, name: 1, block: 1 } }],
|
|
8313
|
+
as: "blockInfo"
|
|
8314
|
+
}
|
|
8315
|
+
},
|
|
8316
|
+
{ $unwind: { path: "$blockInfo", preserveNullAndEmptyArrays: true } },
|
|
8317
|
+
{
|
|
8318
|
+
$lookup: {
|
|
8319
|
+
from: "building-levels",
|
|
8320
|
+
localField: "level",
|
|
8321
|
+
foreignField: "_id",
|
|
8322
|
+
pipeline: [{ $project: { _id: 0, name: 1 } }],
|
|
8323
|
+
as: "levelInfo"
|
|
8324
|
+
}
|
|
8325
|
+
},
|
|
8326
|
+
{ $unwind: { path: "$levelInfo", preserveNullAndEmptyArrays: true } },
|
|
8327
|
+
{
|
|
8328
|
+
$lookup: {
|
|
8329
|
+
from: "building-units",
|
|
8330
|
+
localField: "unitId",
|
|
8331
|
+
foreignField: "_id",
|
|
8332
|
+
pipeline: [{ $project: { _id: 0, name: 1 } }],
|
|
8333
|
+
as: "unitInfo"
|
|
8334
|
+
}
|
|
8335
|
+
},
|
|
8336
|
+
{ $unwind: { path: "$unitInfo", preserveNullAndEmptyArrays: true } }
|
|
8313
8337
|
]).toArray();
|
|
8314
8338
|
const data = results.length > 0 ? results[0] : null;
|
|
8315
8339
|
if (!data) {
|
|
8316
8340
|
throw new NotFoundError4("User not found.");
|
|
8317
8341
|
}
|
|
8318
|
-
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
8319
|
-
logger7.info(`Cache set for key: ${cacheKey}`);
|
|
8320
|
-
}).catch((err) => {
|
|
8321
|
-
logger7.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
8322
|
-
});
|
|
8323
8342
|
return data;
|
|
8324
8343
|
} catch (error) {
|
|
8325
8344
|
if (error instanceof AppError) {
|
|
@@ -23410,8 +23429,8 @@ function useDahuaService() {
|
|
|
23410
23429
|
name: resident?.name,
|
|
23411
23430
|
nric: resident?.nric,
|
|
23412
23431
|
contact: resident?.phoneNumber,
|
|
23413
|
-
block: resident?.block,
|
|
23414
|
-
level: resident?.level,
|
|
23432
|
+
block: resident?.block?.toString(),
|
|
23433
|
+
level: resident?.level?.toString(),
|
|
23415
23434
|
unit: resident?.unit?.toString(),
|
|
23416
23435
|
unitName: resident?.unitName,
|
|
23417
23436
|
type: resident?.category,
|
|
@@ -23432,20 +23451,21 @@ function useDahuaService() {
|
|
|
23432
23451
|
await checkOutBySiteAndPlate(camera.site, plateNumber2);
|
|
23433
23452
|
const resident = await getVehicleBySiteAndPlateNumber(plateNumber2, camera?.site, "resident", "active");
|
|
23434
23453
|
if (resident?._id) {
|
|
23435
|
-
|
|
23454
|
+
const data = {
|
|
23436
23455
|
site,
|
|
23437
23456
|
plateNumber: plateNumber2,
|
|
23438
23457
|
name: resident?.name,
|
|
23439
23458
|
nric: resident?.nric,
|
|
23440
23459
|
contact: resident?.phoneNumber,
|
|
23441
|
-
block: resident?.block,
|
|
23442
|
-
level: resident?.level,
|
|
23460
|
+
block: resident?.block?.toString(),
|
|
23461
|
+
level: resident?.level?.toString(),
|
|
23443
23462
|
unit: resident?.unit?.toString(),
|
|
23444
23463
|
unitName: resident?.unitName,
|
|
23445
23464
|
type: resident?.category,
|
|
23446
23465
|
status: "registered" /* REGISTERED */
|
|
23447
23466
|
// expiredAt: resident?.end,
|
|
23448
|
-
}
|
|
23467
|
+
};
|
|
23468
|
+
insert = await add(data, void 0, true);
|
|
23449
23469
|
loggerDahua.info(`${camera?.siteName}-${camera?.direction}] Resident with plate ${plateNumber2} and transaction ID ${insert?._id}`);
|
|
23450
23470
|
}
|
|
23451
23471
|
} else if (cameraType == "visitors" && ANPRSwitches?.enableUnregistered) {
|
|
@@ -25586,6 +25606,22 @@ function useBuildingUnitRepo() {
|
|
|
25586
25606
|
}
|
|
25587
25607
|
return [level];
|
|
25588
25608
|
}
|
|
25609
|
+
function escapeRegExp(value) {
|
|
25610
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25611
|
+
}
|
|
25612
|
+
function makeFlexibleRegex(value) {
|
|
25613
|
+
const pattern = value.trim().split(/\s+/).map(escapeRegExp).join("\\s*");
|
|
25614
|
+
return pattern ? new RegExp(pattern, "i") : null;
|
|
25615
|
+
}
|
|
25616
|
+
function getSearchParts(searchText) {
|
|
25617
|
+
const levelMatch = searchText.match(/\b(?:lvl|level)\s*([a-z0-9]+)\b/i);
|
|
25618
|
+
const levelSearch = levelMatch?.[0] ?? "";
|
|
25619
|
+
const unitSearch = levelSearch ? searchText.replace(levelSearch, "").trim() : "";
|
|
25620
|
+
return {
|
|
25621
|
+
levelRegex: makeFlexibleRegex(levelSearch),
|
|
25622
|
+
unitRegex: makeFlexibleRegex(unitSearch)
|
|
25623
|
+
};
|
|
25624
|
+
}
|
|
25589
25625
|
async function add(value, session) {
|
|
25590
25626
|
try {
|
|
25591
25627
|
value = MBuildingUnit(value);
|
|
@@ -25711,9 +25747,11 @@ function useBuildingUnitRepo() {
|
|
|
25711
25747
|
status = "active"
|
|
25712
25748
|
} = {}) {
|
|
25713
25749
|
page = page > 0 ? page - 1 : 0;
|
|
25750
|
+
const searchText = search.trim();
|
|
25751
|
+
const searchRegex = makeFlexibleRegex(searchText);
|
|
25752
|
+
const { levelRegex, unitRegex } = getSearchParts(searchText);
|
|
25714
25753
|
const query = {
|
|
25715
25754
|
status,
|
|
25716
|
-
...search && { $text: { $search: search } },
|
|
25717
25755
|
...site && { site: toObjectId11(site) },
|
|
25718
25756
|
...building && { building: toObjectId11(building) }
|
|
25719
25757
|
};
|
|
@@ -25722,7 +25760,7 @@ function useBuildingUnitRepo() {
|
|
|
25722
25760
|
page,
|
|
25723
25761
|
limit,
|
|
25724
25762
|
sort: JSON.stringify(sort),
|
|
25725
|
-
...
|
|
25763
|
+
...searchText && { search: searchText },
|
|
25726
25764
|
...site && { site },
|
|
25727
25765
|
...building && { building },
|
|
25728
25766
|
...status && { status }
|
|
@@ -25744,8 +25782,45 @@ function useBuildingUnitRepo() {
|
|
|
25744
25782
|
});
|
|
25745
25783
|
return cached;
|
|
25746
25784
|
}
|
|
25747
|
-
const
|
|
25785
|
+
const pipeline = [
|
|
25748
25786
|
{ $match: query },
|
|
25787
|
+
{
|
|
25788
|
+
$lookup: {
|
|
25789
|
+
from: "building-levels",
|
|
25790
|
+
localField: "level",
|
|
25791
|
+
foreignField: "_id",
|
|
25792
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
25793
|
+
as: "level"
|
|
25794
|
+
}
|
|
25795
|
+
},
|
|
25796
|
+
{ $set: { level: { $first: "$level" } } },
|
|
25797
|
+
...searchRegex ? [
|
|
25798
|
+
{
|
|
25799
|
+
$match: {
|
|
25800
|
+
$or: [
|
|
25801
|
+
{ name: searchRegex },
|
|
25802
|
+
{ buildingName: searchRegex },
|
|
25803
|
+
{ "level.name": searchRegex },
|
|
25804
|
+
...levelRegex && unitRegex ? [
|
|
25805
|
+
{
|
|
25806
|
+
$and: [
|
|
25807
|
+
{
|
|
25808
|
+
$or: [
|
|
25809
|
+
{ name: unitRegex },
|
|
25810
|
+
{ buildingName: unitRegex }
|
|
25811
|
+
]
|
|
25812
|
+
},
|
|
25813
|
+
{ "level.name": levelRegex }
|
|
25814
|
+
]
|
|
25815
|
+
}
|
|
25816
|
+
] : []
|
|
25817
|
+
]
|
|
25818
|
+
}
|
|
25819
|
+
}
|
|
25820
|
+
] : []
|
|
25821
|
+
];
|
|
25822
|
+
const items = await collection.aggregate([
|
|
25823
|
+
...pipeline,
|
|
25749
25824
|
{
|
|
25750
25825
|
$lookup: {
|
|
25751
25826
|
from: "sites",
|
|
@@ -25771,22 +25846,13 @@ function useBuildingUnitRepo() {
|
|
|
25771
25846
|
as: "site"
|
|
25772
25847
|
}
|
|
25773
25848
|
},
|
|
25774
|
-
{
|
|
25775
|
-
$lookup: {
|
|
25776
|
-
from: "building-levels",
|
|
25777
|
-
localField: "level",
|
|
25778
|
-
foreignField: "_id",
|
|
25779
|
-
pipeline: [{ $project: { name: 1 } }],
|
|
25780
|
-
as: "level"
|
|
25781
|
-
}
|
|
25782
|
-
},
|
|
25783
|
-
{ $set: { level: { $first: "$level" } } },
|
|
25784
25849
|
{ $set: { site: { $first: "$site" } } },
|
|
25785
25850
|
{ $sort: sort },
|
|
25786
25851
|
{ $skip: page * limit },
|
|
25787
25852
|
{ $limit: limit }
|
|
25788
25853
|
]).toArray();
|
|
25789
|
-
const
|
|
25854
|
+
const total = await collection.aggregate([...pipeline, { $count: "length" }]).toArray();
|
|
25855
|
+
const length = total[0]?.length ?? 0;
|
|
25790
25856
|
const data = paginate21(items, page, limit, length);
|
|
25791
25857
|
setCache(cacheKey, data, 600).then(() => {
|
|
25792
25858
|
logger54.log({
|
|
@@ -27889,6 +27955,7 @@ function useBuildingRepo() {
|
|
|
27889
27955
|
{ key: { name: "text" }, name: "text-index" },
|
|
27890
27956
|
// { key: { name: 1 }, unique: true, name: "unique-name-index" },
|
|
27891
27957
|
{ key: { site: 1 } },
|
|
27958
|
+
{ key: { block: 1 }, name: "block-index" },
|
|
27892
27959
|
{ key: { createdAt: 1 } },
|
|
27893
27960
|
{
|
|
27894
27961
|
key: { site: 1, block: 1 },
|
|
@@ -27991,17 +28058,25 @@ function useBuildingRepo() {
|
|
|
27991
28058
|
throw new BadRequestError80("Invalid site ID.");
|
|
27992
28059
|
}
|
|
27993
28060
|
}
|
|
28061
|
+
const searchText = search.trim();
|
|
28062
|
+
const blockSearch = Number(searchText);
|
|
28063
|
+
const canSearchBlock = searchText !== "" && Number.isFinite(blockSearch);
|
|
27994
28064
|
const query = {
|
|
27995
28065
|
status,
|
|
27996
|
-
...
|
|
27997
|
-
...
|
|
28066
|
+
...siteId && { site: siteId },
|
|
28067
|
+
...searchText && {
|
|
28068
|
+
$or: [
|
|
28069
|
+
{ $text: { $search: searchText } },
|
|
28070
|
+
...canSearchBlock ? [{ block: blockSearch }] : []
|
|
28071
|
+
]
|
|
28072
|
+
}
|
|
27998
28073
|
};
|
|
27999
28074
|
sort = Object.keys(sort).length ? sort : { _id: -1 };
|
|
28000
28075
|
const cacheParams = {
|
|
28001
28076
|
page,
|
|
28002
28077
|
limit,
|
|
28003
28078
|
sort: JSON.stringify(sort),
|
|
28004
|
-
...
|
|
28079
|
+
...searchText && { search: searchText },
|
|
28005
28080
|
...site && { site },
|
|
28006
28081
|
...status && { status }
|
|
28007
28082
|
};
|
|
@@ -29782,6 +29857,24 @@ function useBuildingUnitController() {
|
|
|
29782
29857
|
getAllLevelsWithUnits: _getAllLevelsWithUnits
|
|
29783
29858
|
} = useBuildingUnitRepo();
|
|
29784
29859
|
const { add: _add, updateById: _updateById } = useBuildingUnitService();
|
|
29860
|
+
function normalizeQueryString(value) {
|
|
29861
|
+
if (Array.isArray(value)) {
|
|
29862
|
+
for (const item of value) {
|
|
29863
|
+
const normalized = normalizeQueryString(item);
|
|
29864
|
+
if (normalized)
|
|
29865
|
+
return normalized;
|
|
29866
|
+
}
|
|
29867
|
+
return "";
|
|
29868
|
+
}
|
|
29869
|
+
if (value && typeof value === "object") {
|
|
29870
|
+
for (const item of Object.values(value)) {
|
|
29871
|
+
const normalized = normalizeQueryString(item);
|
|
29872
|
+
if (normalized)
|
|
29873
|
+
return normalized;
|
|
29874
|
+
}
|
|
29875
|
+
}
|
|
29876
|
+
return typeof value === "string" ? value : "";
|
|
29877
|
+
}
|
|
29785
29878
|
async function add(req, res, next) {
|
|
29786
29879
|
const data = req.body;
|
|
29787
29880
|
const validation = Joi47.object({
|
|
@@ -29855,7 +29948,11 @@ function useBuildingUnitController() {
|
|
|
29855
29948
|
sort: Joi47.string().valid(...Object.values(SortFields)).default("_id" /* ID */),
|
|
29856
29949
|
order: Joi47.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */)
|
|
29857
29950
|
});
|
|
29858
|
-
const
|
|
29951
|
+
const query = {
|
|
29952
|
+
...req.query,
|
|
29953
|
+
search: normalizeQueryString(req.query.search)
|
|
29954
|
+
};
|
|
29955
|
+
const { error, value } = validation.validate(query, {
|
|
29859
29956
|
abortEarly: false
|
|
29860
29957
|
});
|
|
29861
29958
|
if (error) {
|
|
@@ -30016,7 +30113,11 @@ function useBuildingUnitController() {
|
|
|
30016
30113
|
order: Joi47.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */),
|
|
30017
30114
|
level: Joi47.string().hex().length(24).optional().allow(null, "")
|
|
30018
30115
|
});
|
|
30019
|
-
const
|
|
30116
|
+
const query = {
|
|
30117
|
+
...req.query,
|
|
30118
|
+
search: normalizeQueryString(req.query.search)
|
|
30119
|
+
};
|
|
30120
|
+
const { error, value } = validation.validate(query, {
|
|
30020
30121
|
abortEarly: false
|
|
30021
30122
|
});
|
|
30022
30123
|
if (error) {
|
|
@@ -45272,6 +45373,31 @@ async function getTransactions(index, url) {
|
|
|
45272
45373
|
return Promise.reject(error);
|
|
45273
45374
|
}
|
|
45274
45375
|
}
|
|
45376
|
+
function encryptPayload(payloadHex) {
|
|
45377
|
+
const buffer = Buffer.from(payloadHex, "ascii");
|
|
45378
|
+
const encrypted = crypto.publicEncrypt(
|
|
45379
|
+
{
|
|
45380
|
+
key: "testing",
|
|
45381
|
+
padding: crypto.constants.RSA_PKCS1_PADDING
|
|
45382
|
+
},
|
|
45383
|
+
buffer
|
|
45384
|
+
);
|
|
45385
|
+
return encrypted.toString("base64");
|
|
45386
|
+
}
|
|
45387
|
+
function toHex(num, length) {
|
|
45388
|
+
return num.toString(16).padStart(length * 2, "0");
|
|
45389
|
+
}
|
|
45390
|
+
function buildPayload(cardNumber, validityMinutes) {
|
|
45391
|
+
const randomHex = crypto.randomBytes(2).toString("hex");
|
|
45392
|
+
const cardHex = toHex(cardNumber, 4);
|
|
45393
|
+
const epochHex = toHex(Math.floor(Date.now() / 1e3), 4);
|
|
45394
|
+
const validityHex = toHex(validityMinutes, 2);
|
|
45395
|
+
return randomHex + cardHex + epochHex + validityHex;
|
|
45396
|
+
}
|
|
45397
|
+
function generateQrCodeData(cardNumber, validityMinutes) {
|
|
45398
|
+
const payloadHex = buildPayload(cardNumber, validityMinutes);
|
|
45399
|
+
return encryptPayload(payloadHex);
|
|
45400
|
+
}
|
|
45275
45401
|
|
|
45276
45402
|
// src/repositories/access-management.repo.ts
|
|
45277
45403
|
import { parseStringPromise as parseStringPromise2 } from "xml2js";
|
|
@@ -48521,6 +48647,14 @@ function useAccessManagementSvc() {
|
|
|
48521
48647
|
throw new Error(err.message);
|
|
48522
48648
|
}
|
|
48523
48649
|
};
|
|
48650
|
+
const generateQrCodeWithExpirySvc = async ({ cardNumber, validityMinutes }) => {
|
|
48651
|
+
try {
|
|
48652
|
+
const response = generateQrCodeData(cardNumber, validityMinutes);
|
|
48653
|
+
return response;
|
|
48654
|
+
} catch (error) {
|
|
48655
|
+
throw new Error(error.message);
|
|
48656
|
+
}
|
|
48657
|
+
};
|
|
48524
48658
|
return {
|
|
48525
48659
|
addPhysicalCardSvc,
|
|
48526
48660
|
addNonPhysicalCardSvc,
|
|
@@ -48563,7 +48697,8 @@ function useAccessManagementSvc() {
|
|
|
48563
48697
|
getResidentsSvc,
|
|
48564
48698
|
userAccessCardsSvc,
|
|
48565
48699
|
removeTemplateSvc,
|
|
48566
|
-
qrCodeListSvc
|
|
48700
|
+
qrCodeListSvc,
|
|
48701
|
+
generateQrCodeWithExpirySvc
|
|
48567
48702
|
};
|
|
48568
48703
|
}
|
|
48569
48704
|
|
|
@@ -48611,7 +48746,8 @@ function useAccessManagementController() {
|
|
|
48611
48746
|
getResidentsSvc,
|
|
48612
48747
|
userAccessCardsSvc,
|
|
48613
48748
|
removeTemplateSvc,
|
|
48614
|
-
qrCodeListSvc
|
|
48749
|
+
qrCodeListSvc,
|
|
48750
|
+
generateQrCodeWithExpirySvc
|
|
48615
48751
|
} = useAccessManagementSvc();
|
|
48616
48752
|
const addPhysicalCard = async (req, res) => {
|
|
48617
48753
|
try {
|
|
@@ -49723,6 +49859,23 @@ function useAccessManagementController() {
|
|
|
49723
49859
|
});
|
|
49724
49860
|
}
|
|
49725
49861
|
};
|
|
49862
|
+
const generateQrCodeWithExpiry = async (req, res) => {
|
|
49863
|
+
try {
|
|
49864
|
+
const { cardNumber, validityMinutes } = req.body;
|
|
49865
|
+
const result = await generateQrCodeWithExpirySvc({ cardNumber, validityMinutes });
|
|
49866
|
+
return res.status(200).json({
|
|
49867
|
+
message: "successful!",
|
|
49868
|
+
data: {
|
|
49869
|
+
result
|
|
49870
|
+
}
|
|
49871
|
+
});
|
|
49872
|
+
} catch (error) {
|
|
49873
|
+
return res.status(400).json({
|
|
49874
|
+
data: null,
|
|
49875
|
+
message: error.message
|
|
49876
|
+
});
|
|
49877
|
+
}
|
|
49878
|
+
};
|
|
49726
49879
|
return {
|
|
49727
49880
|
addPhysicalCard,
|
|
49728
49881
|
addNonPhysicalCard,
|
|
@@ -49763,7 +49916,8 @@ function useAccessManagementController() {
|
|
|
49763
49916
|
getResidents,
|
|
49764
49917
|
userAccessCards,
|
|
49765
49918
|
removeTemplate,
|
|
49766
|
-
qrCodeList
|
|
49919
|
+
qrCodeList,
|
|
49920
|
+
generateQrCodeWithExpiry
|
|
49767
49921
|
};
|
|
49768
49922
|
}
|
|
49769
49923
|
|
|
@@ -57184,14 +57338,14 @@ function useNewDashboardRepo() {
|
|
|
57184
57338
|
site: { $in: [siteIdObj, siteId] },
|
|
57185
57339
|
service: "Security",
|
|
57186
57340
|
createdAt: periodRange,
|
|
57187
|
-
status: { $nin: ["
|
|
57341
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57188
57342
|
}
|
|
57189
57343
|
},
|
|
57190
57344
|
{
|
|
57191
57345
|
$facet: {
|
|
57192
57346
|
total: [{ $count: "count" }],
|
|
57193
57347
|
inProgress: [
|
|
57194
|
-
{ $match: { status: "
|
|
57348
|
+
{ $match: { status: "In-Progress" } },
|
|
57195
57349
|
{ $count: "count" }
|
|
57196
57350
|
]
|
|
57197
57351
|
}
|
|
@@ -57203,7 +57357,7 @@ function useNewDashboardRepo() {
|
|
|
57203
57357
|
site: { $in: [siteIdObj, siteId] },
|
|
57204
57358
|
service: "Security",
|
|
57205
57359
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd },
|
|
57206
|
-
status: { $nin: ["
|
|
57360
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57207
57361
|
}
|
|
57208
57362
|
},
|
|
57209
57363
|
{ $count: "count" }
|
|
@@ -57214,7 +57368,7 @@ function useNewDashboardRepo() {
|
|
|
57214
57368
|
site: { $in: [siteIdObj, siteId] },
|
|
57215
57369
|
service: "Security",
|
|
57216
57370
|
createdAt: { $gte: today, $lte: todayEnd },
|
|
57217
|
-
status: { $nin: ["
|
|
57371
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57218
57372
|
}
|
|
57219
57373
|
},
|
|
57220
57374
|
{ $count: "count" }
|
|
@@ -57223,7 +57377,7 @@ function useNewDashboardRepo() {
|
|
|
57223
57377
|
{
|
|
57224
57378
|
$match: {
|
|
57225
57379
|
site: { $in: [siteIdObj, siteId] },
|
|
57226
|
-
status: { $in: ["pending"
|
|
57380
|
+
status: { $in: ["pending"] },
|
|
57227
57381
|
createdAt: periodRange
|
|
57228
57382
|
}
|
|
57229
57383
|
},
|
|
@@ -57233,7 +57387,7 @@ function useNewDashboardRepo() {
|
|
|
57233
57387
|
{
|
|
57234
57388
|
$match: {
|
|
57235
57389
|
site: { $in: [siteIdObj, siteId] },
|
|
57236
|
-
status: { $in: ["pending"
|
|
57390
|
+
status: { $in: ["pending"] },
|
|
57237
57391
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd }
|
|
57238
57392
|
}
|
|
57239
57393
|
},
|
|
@@ -57243,7 +57397,7 @@ function useNewDashboardRepo() {
|
|
|
57243
57397
|
{
|
|
57244
57398
|
$match: {
|
|
57245
57399
|
site: { $in: [siteIdObj, siteId] },
|
|
57246
|
-
status: { $in: ["pending"
|
|
57400
|
+
status: { $in: ["pending"] },
|
|
57247
57401
|
createdAt: { $gte: today, $lte: todayEnd }
|
|
57248
57402
|
}
|
|
57249
57403
|
},
|
|
@@ -57525,11 +57679,11 @@ function useNewDashboardRepo() {
|
|
|
57525
57679
|
[
|
|
57526
57680
|
db.collection(incidents_namespace_collection).find({
|
|
57527
57681
|
site: { $in: [siteIdObj, siteId] },
|
|
57528
|
-
status: { $in: ["pending"
|
|
57682
|
+
status: { $in: ["pending"] }
|
|
57529
57683
|
}).sort({ createdAt: -1 }).toArray(),
|
|
57530
57684
|
db.collection(facility_bookings_namespace_collection2).find({
|
|
57531
57685
|
site: { $in: [siteIdObj, siteId] },
|
|
57532
|
-
status: { $in: ["Pending", "
|
|
57686
|
+
status: { $in: ["Pending", "For Review"] }
|
|
57533
57687
|
}).sort({ createdAt: -1 }).toArray()
|
|
57534
57688
|
]
|
|
57535
57689
|
);
|
|
@@ -57538,14 +57692,16 @@ function useNewDashboardRepo() {
|
|
|
57538
57692
|
const todayAttentions = [];
|
|
57539
57693
|
if (pendingIncidentCount > 0) {
|
|
57540
57694
|
todayAttentions.push({
|
|
57541
|
-
id:
|
|
57695
|
+
id: pendingIncidentDocs[0]._id.toString(),
|
|
57696
|
+
type: "incident",
|
|
57542
57697
|
title: `${pendingIncidentCount} incident${pendingIncidentCount === 1 ? "" : "s"} pending acknowledge`,
|
|
57543
57698
|
createdAt: pendingIncidentDocs[0].updatedAt || pendingIncidentDocs[0].createdAt || /* @__PURE__ */ new Date()
|
|
57544
57699
|
});
|
|
57545
57700
|
}
|
|
57546
57701
|
if (pendingFacilityBookingCount > 0) {
|
|
57547
57702
|
todayAttentions.push({
|
|
57548
|
-
id:
|
|
57703
|
+
id: pendingFacilityBookingDocs[0]._id.toString(),
|
|
57704
|
+
type: "facility-booking",
|
|
57549
57705
|
title: `${pendingFacilityBookingCount} facility booking${pendingFacilityBookingCount === 1 ? "" : "s"} need approval`,
|
|
57550
57706
|
createdAt: pendingFacilityBookingDocs[0].createdAt || /* @__PURE__ */ new Date()
|
|
57551
57707
|
});
|
|
@@ -57600,14 +57756,14 @@ function useNewDashboardRepo() {
|
|
|
57600
57756
|
$match: {
|
|
57601
57757
|
site: { $in: [siteIdObj, siteId] },
|
|
57602
57758
|
createdAt: periodRange,
|
|
57603
|
-
status: { $nin: ["
|
|
57759
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57604
57760
|
}
|
|
57605
57761
|
},
|
|
57606
57762
|
{
|
|
57607
57763
|
$facet: {
|
|
57608
57764
|
total: [{ $count: "count" }],
|
|
57609
57765
|
inProgress: [
|
|
57610
|
-
{ $match: { status: "
|
|
57766
|
+
{ $match: { status: "In-Progress" } },
|
|
57611
57767
|
{ $count: "count" }
|
|
57612
57768
|
]
|
|
57613
57769
|
}
|
|
@@ -57618,7 +57774,7 @@ function useNewDashboardRepo() {
|
|
|
57618
57774
|
$match: {
|
|
57619
57775
|
site: { $in: [siteIdObj, siteId] },
|
|
57620
57776
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd },
|
|
57621
|
-
status: { $nin: ["
|
|
57777
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57622
57778
|
}
|
|
57623
57779
|
},
|
|
57624
57780
|
{ $count: "count" }
|
|
@@ -57628,7 +57784,7 @@ function useNewDashboardRepo() {
|
|
|
57628
57784
|
$match: {
|
|
57629
57785
|
site: { $in: [siteIdObj, siteId] },
|
|
57630
57786
|
createdAt: { $gte: today, $lte: todayEnd },
|
|
57631
|
-
status: { $nin: ["
|
|
57787
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57632
57788
|
}
|
|
57633
57789
|
},
|
|
57634
57790
|
{ $count: "count" }
|
|
@@ -57637,7 +57793,7 @@ function useNewDashboardRepo() {
|
|
|
57637
57793
|
{
|
|
57638
57794
|
$match: {
|
|
57639
57795
|
site: { $in: [siteIdObj, siteId] },
|
|
57640
|
-
status: { $in: ["pending"
|
|
57796
|
+
status: { $in: ["pending"] },
|
|
57641
57797
|
createdAt: periodRange
|
|
57642
57798
|
}
|
|
57643
57799
|
},
|
|
@@ -57647,7 +57803,7 @@ function useNewDashboardRepo() {
|
|
|
57647
57803
|
{
|
|
57648
57804
|
$match: {
|
|
57649
57805
|
site: { $in: [siteIdObj, siteId] },
|
|
57650
|
-
status: { $in: ["pending"
|
|
57806
|
+
status: { $in: ["pending"] },
|
|
57651
57807
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd }
|
|
57652
57808
|
}
|
|
57653
57809
|
},
|
|
@@ -57657,7 +57813,7 @@ function useNewDashboardRepo() {
|
|
|
57657
57813
|
{
|
|
57658
57814
|
$match: {
|
|
57659
57815
|
site: { $in: [siteIdObj, siteId] },
|
|
57660
|
-
status: { $in: ["pending"
|
|
57816
|
+
status: { $in: ["pending"] },
|
|
57661
57817
|
createdAt: { $gte: today, $lte: todayEnd }
|
|
57662
57818
|
}
|
|
57663
57819
|
},
|
|
@@ -57907,6 +58063,13 @@ function useNewDashboardRepo() {
|
|
|
57907
58063
|
const periodRange = getDateRange(period);
|
|
57908
58064
|
try {
|
|
57909
58065
|
const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
|
|
58066
|
+
const workOrderMatchQuery = {
|
|
58067
|
+
site,
|
|
58068
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
58069
|
+
};
|
|
58070
|
+
if (serviceType !== "property_management_agency") {
|
|
58071
|
+
workOrderMatchQuery.service = workOrderService;
|
|
58072
|
+
}
|
|
57910
58073
|
const [
|
|
57911
58074
|
workOrderReport,
|
|
57912
58075
|
supplyAlertReport,
|
|
@@ -57919,17 +58082,15 @@ function useNewDashboardRepo() {
|
|
|
57919
58082
|
workOrderCollection.aggregate([
|
|
57920
58083
|
{
|
|
57921
58084
|
$match: {
|
|
57922
|
-
|
|
57923
|
-
|
|
57924
|
-
createdAt: periodRange,
|
|
57925
|
-
status: { $nin: ["completed"] }
|
|
58085
|
+
...workOrderMatchQuery,
|
|
58086
|
+
createdAt: periodRange
|
|
57926
58087
|
}
|
|
57927
58088
|
},
|
|
57928
58089
|
{
|
|
57929
58090
|
$facet: {
|
|
57930
58091
|
total: [{ $count: "count" }],
|
|
57931
58092
|
inProgress: [
|
|
57932
|
-
{ $match: { status: "
|
|
58093
|
+
{ $match: { status: "In-Progress" } },
|
|
57933
58094
|
{ $count: "count" }
|
|
57934
58095
|
]
|
|
57935
58096
|
}
|
|
@@ -57960,10 +58121,8 @@ function useNewDashboardRepo() {
|
|
|
57960
58121
|
workOrderCollection.aggregate([
|
|
57961
58122
|
{
|
|
57962
58123
|
$match: {
|
|
57963
|
-
|
|
57964
|
-
|
|
57965
|
-
createdAt: { $gte: yesterday, $lte: yesterdayEnd },
|
|
57966
|
-
status: { $nin: ["completed"] }
|
|
58124
|
+
...workOrderMatchQuery,
|
|
58125
|
+
createdAt: { $gte: yesterday, $lte: yesterdayEnd }
|
|
57967
58126
|
}
|
|
57968
58127
|
},
|
|
57969
58128
|
{ $count: "count" }
|
|
@@ -57971,10 +58130,8 @@ function useNewDashboardRepo() {
|
|
|
57971
58130
|
workOrderCollection.aggregate([
|
|
57972
58131
|
{
|
|
57973
58132
|
$match: {
|
|
57974
|
-
|
|
57975
|
-
|
|
57976
|
-
createdAt: { $gte: today, $lte: todayEnd },
|
|
57977
|
-
status: { $nin: ["completed"] }
|
|
58133
|
+
...workOrderMatchQuery,
|
|
58134
|
+
createdAt: { $gte: today, $lte: todayEnd }
|
|
57978
58135
|
}
|
|
57979
58136
|
},
|
|
57980
58137
|
{ $count: "count" }
|
|
@@ -58077,10 +58234,9 @@ function useNewDashboardRepo() {
|
|
|
58077
58234
|
throw new BadRequestError182("Invalid period.");
|
|
58078
58235
|
}
|
|
58079
58236
|
try {
|
|
58080
|
-
const
|
|
58237
|
+
const workOrderQuery = {
|
|
58081
58238
|
site,
|
|
58082
|
-
|
|
58083
|
-
status: { $nin: ["deleted", "Deleted"] },
|
|
58239
|
+
status: { $nin: ["Deleted"] },
|
|
58084
58240
|
$or: [
|
|
58085
58241
|
{ createdAt: { $gte: rangeStart, $lte: rangeEnd } },
|
|
58086
58242
|
{
|
|
@@ -58090,7 +58246,11 @@ function useNewDashboardRepo() {
|
|
|
58090
58246
|
}
|
|
58091
58247
|
}
|
|
58092
58248
|
]
|
|
58093
|
-
}
|
|
58249
|
+
};
|
|
58250
|
+
if (serviceType !== "property_management_agency") {
|
|
58251
|
+
workOrderQuery.service = workOrderService;
|
|
58252
|
+
}
|
|
58253
|
+
const workOrders = await workOrderCollection.find(workOrderQuery).project({ status: 1, createdAt: 1 }).toArray();
|
|
58094
58254
|
const chartData = labels.map((label) => ({
|
|
58095
58255
|
day: label,
|
|
58096
58256
|
label,
|
|
@@ -58187,6 +58347,7 @@ function useNewDashboardRepo() {
|
|
|
58187
58347
|
name: 1,
|
|
58188
58348
|
type: 1,
|
|
58189
58349
|
status: 1,
|
|
58350
|
+
schedule: 1,
|
|
58190
58351
|
assigneeName: { $arrayElemAt: ["$_assigneeDoc.name", 0] }
|
|
58191
58352
|
}
|
|
58192
58353
|
},
|
|
@@ -58351,7 +58512,10 @@ function useNewDashboardRepo() {
|
|
|
58351
58512
|
throw new BadRequestError182("Invalid site ID format.");
|
|
58352
58513
|
}
|
|
58353
58514
|
const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
|
|
58354
|
-
const matchQuery = { site
|
|
58515
|
+
const matchQuery = { site };
|
|
58516
|
+
if (serviceType !== "property_management_agency") {
|
|
58517
|
+
matchQuery.service = workOrderService;
|
|
58518
|
+
}
|
|
58355
58519
|
if (period) {
|
|
58356
58520
|
matchQuery.createdAt = getDateRange(period);
|
|
58357
58521
|
}
|
|
@@ -65677,7 +65841,7 @@ function usePostFavoriteService() {
|
|
|
65677
65841
|
});
|
|
65678
65842
|
}
|
|
65679
65843
|
await session?.commitTransaction();
|
|
65680
|
-
return "Successfully added to
|
|
65844
|
+
return "Successfully added to post-preloved.";
|
|
65681
65845
|
} catch (error) {
|
|
65682
65846
|
await session?.abortTransaction();
|
|
65683
65847
|
throw error;
|
|
@@ -67089,9 +67253,112 @@ function useChatPrelovedController() {
|
|
|
67089
67253
|
return { add, updateById, deleteById };
|
|
67090
67254
|
}
|
|
67091
67255
|
|
|
67092
|
-
// src/
|
|
67093
|
-
import { BadRequestError as BadRequestError223, logger as logger193 } from "@7365admin1/node-server-utils";
|
|
67256
|
+
// src/events/chat-preloved.event.ts
|
|
67094
67257
|
import Joi144 from "joi";
|
|
67258
|
+
import { logger as logger193, useCache as useCache69 } from "@7365admin1/node-server-utils";
|
|
67259
|
+
function parseSid(cookieHeader) {
|
|
67260
|
+
const match = cookieHeader.match(/(?:^|;\s*)sid=([^;]*)/);
|
|
67261
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
67262
|
+
}
|
|
67263
|
+
var schemaSendMessage = Joi144.object({
|
|
67264
|
+
receiverId: Joi144.string().hex().length(24).required(),
|
|
67265
|
+
channelId: Joi144.string().hex().length(24).optional().allow("", null),
|
|
67266
|
+
senderId: Joi144.string().hex().length(24).required(),
|
|
67267
|
+
postId: Joi144.string().hex().length(24).optional().allow("", null),
|
|
67268
|
+
message: Joi144.object({
|
|
67269
|
+
text: Joi144.string().required(),
|
|
67270
|
+
date: Joi144.date().optional().allow(null),
|
|
67271
|
+
time: Joi144.string().optional().allow("", null),
|
|
67272
|
+
senderId: Joi144.string().hex().length(24).required()
|
|
67273
|
+
}).required(),
|
|
67274
|
+
readMessage: Joi144.array().items(Joi144.string().hex()).optional().default([]),
|
|
67275
|
+
viewMessage: Joi144.array().items(Joi144.string().hex()).optional().default([]),
|
|
67276
|
+
attachments: Joi144.array().items(Joi144.string().hex()).optional().default([]),
|
|
67277
|
+
reactions: Joi144.string().optional().allow("", null).default(""),
|
|
67278
|
+
bidId: Joi144.string().hex().length(24).optional().allow("", null),
|
|
67279
|
+
edited: Joi144.boolean().optional().default(false)
|
|
67280
|
+
});
|
|
67281
|
+
var schemaTyping = Joi144.object({
|
|
67282
|
+
receiverId: Joi144.string().hex().length(24).required(),
|
|
67283
|
+
fromUserId: Joi144.string().hex().length(24).required(),
|
|
67284
|
+
senderName: Joi144.string().required()
|
|
67285
|
+
});
|
|
67286
|
+
var schemaChatMessageDeleted = Joi144.object({
|
|
67287
|
+
messageId: Joi144.string().hex().length(24).required(),
|
|
67288
|
+
receiverId: Joi144.string().hex().length(24).required()
|
|
67289
|
+
});
|
|
67290
|
+
function chatPrelovedEvents(io) {
|
|
67291
|
+
const namespace = io.of(/^\/chat-channel-[0-9a-fA-F]{24}$/);
|
|
67292
|
+
namespace.use(async (socket, next) => {
|
|
67293
|
+
try {
|
|
67294
|
+
const cookieHeader = socket.handshake.headers.cookie || "";
|
|
67295
|
+
let sid = parseSid(cookieHeader);
|
|
67296
|
+
if (!sid && socket.handshake.auth?.token) {
|
|
67297
|
+
sid = socket.handshake.auth.token;
|
|
67298
|
+
}
|
|
67299
|
+
if (!sid) {
|
|
67300
|
+
return next(new Error("Unauthorized"));
|
|
67301
|
+
}
|
|
67302
|
+
const { getCache } = useCache69("sessions");
|
|
67303
|
+
const sessionData = await getCache(`sid:${sid}`);
|
|
67304
|
+
if (!sessionData) {
|
|
67305
|
+
return next(new Error("Session expired or invalid"));
|
|
67306
|
+
}
|
|
67307
|
+
const session = sessionData;
|
|
67308
|
+
socket.data.userId = (session._id ?? sessionData).toString();
|
|
67309
|
+
next();
|
|
67310
|
+
} catch (error) {
|
|
67311
|
+
logger193.log({ level: "error", message: `Socket auth error: ${error.message}` });
|
|
67312
|
+
next(new Error("Authentication error"));
|
|
67313
|
+
}
|
|
67314
|
+
});
|
|
67315
|
+
namespace.on("connection", (socket) => {
|
|
67316
|
+
const userId = socket.data.userId;
|
|
67317
|
+
socket.join(userId);
|
|
67318
|
+
socket.on("sendMessage", (payload) => {
|
|
67319
|
+
const { error, value } = schemaSendMessage.validate(payload, {
|
|
67320
|
+
abortEarly: false
|
|
67321
|
+
});
|
|
67322
|
+
if (error) {
|
|
67323
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
67324
|
+
socket.emit("error", { event: "sendMessage", message });
|
|
67325
|
+
return;
|
|
67326
|
+
}
|
|
67327
|
+
namespace.to(value.receiverId).emit("receiveMessage", value);
|
|
67328
|
+
});
|
|
67329
|
+
socket.on("typing", (data) => {
|
|
67330
|
+
const { error, value } = schemaTyping.validate(data, {
|
|
67331
|
+
abortEarly: false
|
|
67332
|
+
});
|
|
67333
|
+
if (error) {
|
|
67334
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
67335
|
+
socket.emit("error", { event: "typing", message });
|
|
67336
|
+
return;
|
|
67337
|
+
}
|
|
67338
|
+
namespace.to(value.receiverId).emit("TypingNow", value);
|
|
67339
|
+
});
|
|
67340
|
+
socket.on("chatMessageDeleted", (data) => {
|
|
67341
|
+
const { error, value } = schemaChatMessageDeleted.validate(data, {
|
|
67342
|
+
abortEarly: false
|
|
67343
|
+
});
|
|
67344
|
+
if (error) {
|
|
67345
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
67346
|
+
socket.emit("error", { event: "chatMessageDeleted", message });
|
|
67347
|
+
return;
|
|
67348
|
+
}
|
|
67349
|
+
namespace.to(value.receiverId).emit("chatMessageDeleted", {
|
|
67350
|
+
messageId: value.messageId
|
|
67351
|
+
});
|
|
67352
|
+
});
|
|
67353
|
+
socket.on("disconnect", () => {
|
|
67354
|
+
socket.leave(userId);
|
|
67355
|
+
});
|
|
67356
|
+
});
|
|
67357
|
+
}
|
|
67358
|
+
|
|
67359
|
+
// src/controllers/channel-preloved.controller.ts
|
|
67360
|
+
import { BadRequestError as BadRequestError223, logger as logger194 } from "@7365admin1/node-server-utils";
|
|
67361
|
+
import Joi145 from "joi";
|
|
67095
67362
|
function useChannelPrelovedController() {
|
|
67096
67363
|
const {
|
|
67097
67364
|
add: _add,
|
|
@@ -67105,7 +67372,7 @@ function useChannelPrelovedController() {
|
|
|
67105
67372
|
});
|
|
67106
67373
|
if (error) {
|
|
67107
67374
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67108
|
-
|
|
67375
|
+
logger194.log({ level: "error", message: messages });
|
|
67109
67376
|
next(new BadRequestError223(messages));
|
|
67110
67377
|
return;
|
|
67111
67378
|
}
|
|
@@ -67113,31 +67380,31 @@ function useChannelPrelovedController() {
|
|
|
67113
67380
|
const data = await _add(value);
|
|
67114
67381
|
res.status(201).json(data);
|
|
67115
67382
|
} catch (error2) {
|
|
67116
|
-
|
|
67383
|
+
logger194.log({ level: "error", message: error2.message });
|
|
67117
67384
|
next(error2);
|
|
67118
67385
|
}
|
|
67119
67386
|
}
|
|
67120
67387
|
async function getChannelMessages(req, res, next) {
|
|
67121
|
-
const paramsSchema =
|
|
67122
|
-
id:
|
|
67388
|
+
const paramsSchema = Joi145.object({
|
|
67389
|
+
id: Joi145.string().hex().length(24).required()
|
|
67123
67390
|
});
|
|
67124
|
-
const querySchema =
|
|
67125
|
-
page:
|
|
67126
|
-
limit:
|
|
67127
|
-
isLoadMore:
|
|
67128
|
-
lastMessageId:
|
|
67391
|
+
const querySchema = Joi145.object({
|
|
67392
|
+
page: Joi145.number().integer().min(1).default(1),
|
|
67393
|
+
limit: Joi145.number().integer().min(1).max(100).default(10),
|
|
67394
|
+
isLoadMore: Joi145.boolean().default(false),
|
|
67395
|
+
lastMessageId: Joi145.string().hex().length(24).optional().allow("", null)
|
|
67129
67396
|
});
|
|
67130
67397
|
const { error: paramError, value: params } = paramsSchema.validate(
|
|
67131
67398
|
req.params
|
|
67132
67399
|
);
|
|
67133
67400
|
if (paramError) {
|
|
67134
|
-
|
|
67401
|
+
logger194.log({ level: "error", message: paramError.message });
|
|
67135
67402
|
next(new BadRequestError223(paramError.message));
|
|
67136
67403
|
return;
|
|
67137
67404
|
}
|
|
67138
67405
|
const { error: queryError, value: query } = querySchema.validate(req.query);
|
|
67139
67406
|
if (queryError) {
|
|
67140
|
-
|
|
67407
|
+
logger194.log({ level: "error", message: queryError.message });
|
|
67141
67408
|
next(new BadRequestError223(queryError.message));
|
|
67142
67409
|
return;
|
|
67143
67410
|
}
|
|
@@ -67151,19 +67418,19 @@ function useChannelPrelovedController() {
|
|
|
67151
67418
|
);
|
|
67152
67419
|
res.status(200).json(data);
|
|
67153
67420
|
} catch (error) {
|
|
67154
|
-
|
|
67421
|
+
logger194.log({ level: "error", message: error.message });
|
|
67155
67422
|
next(error);
|
|
67156
67423
|
}
|
|
67157
67424
|
}
|
|
67158
67425
|
async function getChannel(req, res, next) {
|
|
67159
|
-
const querySchema =
|
|
67160
|
-
postId:
|
|
67161
|
-
receiverId:
|
|
67162
|
-
senderId:
|
|
67426
|
+
const querySchema = Joi145.object({
|
|
67427
|
+
postId: Joi145.string().hex().length(24).required(),
|
|
67428
|
+
receiverId: Joi145.string().hex().length(24).required(),
|
|
67429
|
+
senderId: Joi145.string().hex().length(24).required()
|
|
67163
67430
|
});
|
|
67164
67431
|
const { error, value } = querySchema.validate(req.query);
|
|
67165
67432
|
if (error) {
|
|
67166
|
-
|
|
67433
|
+
logger194.log({ level: "error", message: error.message });
|
|
67167
67434
|
next(new BadRequestError223(error.message));
|
|
67168
67435
|
return;
|
|
67169
67436
|
}
|
|
@@ -67175,20 +67442,20 @@ function useChannelPrelovedController() {
|
|
|
67175
67442
|
);
|
|
67176
67443
|
res.status(200).json(data);
|
|
67177
67444
|
} catch (error2) {
|
|
67178
|
-
|
|
67445
|
+
logger194.log({ level: "error", message: error2.message });
|
|
67179
67446
|
next(error2);
|
|
67180
67447
|
}
|
|
67181
67448
|
}
|
|
67182
67449
|
async function getChatLists(req, res, next) {
|
|
67183
|
-
const querySchema =
|
|
67184
|
-
currentUserId:
|
|
67185
|
-
page:
|
|
67186
|
-
limit:
|
|
67187
|
-
search:
|
|
67450
|
+
const querySchema = Joi145.object({
|
|
67451
|
+
currentUserId: Joi145.string().hex().length(24).required(),
|
|
67452
|
+
page: Joi145.number().integer().min(1).default(1),
|
|
67453
|
+
limit: Joi145.number().integer().min(1).max(100).default(10),
|
|
67454
|
+
search: Joi145.string().optional().allow("", null)
|
|
67188
67455
|
});
|
|
67189
67456
|
const { error, value } = querySchema.validate(req.query);
|
|
67190
67457
|
if (error) {
|
|
67191
|
-
|
|
67458
|
+
logger194.log({ level: "error", message: error.message });
|
|
67192
67459
|
next(new BadRequestError223(error.message));
|
|
67193
67460
|
return;
|
|
67194
67461
|
}
|
|
@@ -67201,7 +67468,7 @@ function useChannelPrelovedController() {
|
|
|
67201
67468
|
);
|
|
67202
67469
|
res.status(200).json(data);
|
|
67203
67470
|
} catch (error2) {
|
|
67204
|
-
|
|
67471
|
+
logger194.log({ level: "error", message: error2.message });
|
|
67205
67472
|
next(error2);
|
|
67206
67473
|
}
|
|
67207
67474
|
}
|
|
@@ -67209,7 +67476,7 @@ function useChannelPrelovedController() {
|
|
|
67209
67476
|
}
|
|
67210
67477
|
|
|
67211
67478
|
// src/models/bid-preloved.model.ts
|
|
67212
|
-
import
|
|
67479
|
+
import Joi146 from "joi";
|
|
67213
67480
|
import { ObjectId as ObjectId149 } from "mongodb";
|
|
67214
67481
|
var BidType = /* @__PURE__ */ ((BidType2) => {
|
|
67215
67482
|
BidType2["BID"] = "bid";
|
|
@@ -67223,21 +67490,21 @@ var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
|
|
|
67223
67490
|
BidStatus3["CANCELLED"] = "cancelled";
|
|
67224
67491
|
return BidStatus3;
|
|
67225
67492
|
})(BidStatus || {});
|
|
67226
|
-
var schemaBidPreloved =
|
|
67227
|
-
type:
|
|
67228
|
-
postId:
|
|
67229
|
-
receiverId:
|
|
67230
|
-
buyerId:
|
|
67231
|
-
price:
|
|
67493
|
+
var schemaBidPreloved = Joi146.object({
|
|
67494
|
+
type: Joi146.string().valid(...Object.values(BidType)).required(),
|
|
67495
|
+
postId: Joi146.string().hex().length(24).required(),
|
|
67496
|
+
receiverId: Joi146.string().hex().length(24).required(),
|
|
67497
|
+
buyerId: Joi146.string().hex().length(24).required(),
|
|
67498
|
+
price: Joi146.when("type", {
|
|
67232
67499
|
is: "bid" /* BID */,
|
|
67233
|
-
then:
|
|
67234
|
-
otherwise:
|
|
67500
|
+
then: Joi146.number().required(),
|
|
67501
|
+
otherwise: Joi146.number().optional().allow(null)
|
|
67235
67502
|
}),
|
|
67236
|
-
message:
|
|
67237
|
-
status:
|
|
67503
|
+
message: Joi146.string().optional().allow("", null),
|
|
67504
|
+
status: Joi146.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
|
|
67238
67505
|
});
|
|
67239
|
-
var schemaUpdateBidPreloved =
|
|
67240
|
-
status:
|
|
67506
|
+
var schemaUpdateBidPreloved = Joi146.object({
|
|
67507
|
+
status: Joi146.string().valid(...Object.values(BidStatus)).required()
|
|
67241
67508
|
});
|
|
67242
67509
|
function MBidPreloved(value) {
|
|
67243
67510
|
const { error } = schemaBidPreloved.validate(value);
|
|
@@ -67305,10 +67572,6 @@ function useBidPrelovedRepo() {
|
|
|
67305
67572
|
return { add, getById, updateStatus };
|
|
67306
67573
|
}
|
|
67307
67574
|
|
|
67308
|
-
// src/controllers/bid-preloved.controller.ts
|
|
67309
|
-
import { BadRequestError as BadRequestError224, logger as logger194 } from "@7365admin1/node-server-utils";
|
|
67310
|
-
import Joi146 from "joi";
|
|
67311
|
-
|
|
67312
67575
|
// src/services/bid-preloved.service.ts
|
|
67313
67576
|
import { InternalServerError as InternalServerError83, useAtlas as useAtlas128 } from "@7365admin1/node-server-utils";
|
|
67314
67577
|
function useBidPrelovedService() {
|
|
@@ -67373,6 +67636,8 @@ function useBidPrelovedService() {
|
|
|
67373
67636
|
}
|
|
67374
67637
|
|
|
67375
67638
|
// src/controllers/bid-preloved.controller.ts
|
|
67639
|
+
import { BadRequestError as BadRequestError224, logger as logger195 } from "@7365admin1/node-server-utils";
|
|
67640
|
+
import Joi147 from "joi";
|
|
67376
67641
|
function useBidPrelovedController() {
|
|
67377
67642
|
const { createBid: _createBid } = useBidPrelovedService();
|
|
67378
67643
|
const { getById: _getById, updateStatus: _updateStatus } = useBidPrelovedRepo();
|
|
@@ -67382,7 +67647,7 @@ function useBidPrelovedController() {
|
|
|
67382
67647
|
});
|
|
67383
67648
|
if (error) {
|
|
67384
67649
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67385
|
-
|
|
67650
|
+
logger195.log({ level: "error", message: messages });
|
|
67386
67651
|
next(new BadRequestError224(messages));
|
|
67387
67652
|
return;
|
|
67388
67653
|
}
|
|
@@ -67391,19 +67656,19 @@ function useBidPrelovedController() {
|
|
|
67391
67656
|
res.status(201).json(data);
|
|
67392
67657
|
} catch (error2) {
|
|
67393
67658
|
console.log("error", error2);
|
|
67394
|
-
|
|
67659
|
+
logger195.log({ level: "error", message: error2.message });
|
|
67395
67660
|
next(error2);
|
|
67396
67661
|
}
|
|
67397
67662
|
}
|
|
67398
67663
|
async function updateStatus(req, res, next) {
|
|
67399
|
-
const paramsSchema =
|
|
67400
|
-
id:
|
|
67664
|
+
const paramsSchema = Joi147.object({
|
|
67665
|
+
id: Joi147.string().hex().length(24).required()
|
|
67401
67666
|
});
|
|
67402
67667
|
const { error: paramError, value: params } = paramsSchema.validate(
|
|
67403
67668
|
req.params
|
|
67404
67669
|
);
|
|
67405
67670
|
if (paramError) {
|
|
67406
|
-
|
|
67671
|
+
logger195.log({ level: "error", message: paramError.message });
|
|
67407
67672
|
next(new BadRequestError224(paramError.message));
|
|
67408
67673
|
return;
|
|
67409
67674
|
}
|
|
@@ -67411,7 +67676,7 @@ function useBidPrelovedController() {
|
|
|
67411
67676
|
req.body
|
|
67412
67677
|
);
|
|
67413
67678
|
if (bodyError) {
|
|
67414
|
-
|
|
67679
|
+
logger195.log({ level: "error", message: bodyError.message });
|
|
67415
67680
|
next(new BadRequestError224(bodyError.message));
|
|
67416
67681
|
return;
|
|
67417
67682
|
}
|
|
@@ -67419,17 +67684,17 @@ function useBidPrelovedController() {
|
|
|
67419
67684
|
const data = await _updateStatus(params.id, body.status);
|
|
67420
67685
|
res.status(200).json(data);
|
|
67421
67686
|
} catch (error) {
|
|
67422
|
-
|
|
67687
|
+
logger195.log({ level: "error", message: error.message });
|
|
67423
67688
|
next(error);
|
|
67424
67689
|
}
|
|
67425
67690
|
}
|
|
67426
67691
|
async function getById(req, res, next) {
|
|
67427
|
-
const paramsSchema =
|
|
67428
|
-
id:
|
|
67692
|
+
const paramsSchema = Joi147.object({
|
|
67693
|
+
id: Joi147.string().hex().length(24).required()
|
|
67429
67694
|
});
|
|
67430
67695
|
const { error, value: params } = paramsSchema.validate(req.params);
|
|
67431
67696
|
if (error) {
|
|
67432
|
-
|
|
67697
|
+
logger195.log({ level: "error", message: error.message });
|
|
67433
67698
|
next(new BadRequestError224(error.message));
|
|
67434
67699
|
return;
|
|
67435
67700
|
}
|
|
@@ -67437,7 +67702,7 @@ function useBidPrelovedController() {
|
|
|
67437
67702
|
const data = await _getById(params.id);
|
|
67438
67703
|
res.status(200).json(data);
|
|
67439
67704
|
} catch (error2) {
|
|
67440
|
-
|
|
67705
|
+
logger195.log({ level: "error", message: error2.message });
|
|
67441
67706
|
next(error2);
|
|
67442
67707
|
}
|
|
67443
67708
|
}
|
|
@@ -67445,7 +67710,7 @@ function useBidPrelovedController() {
|
|
|
67445
67710
|
}
|
|
67446
67711
|
|
|
67447
67712
|
// src/models/online-forms-v2.model.ts
|
|
67448
|
-
import
|
|
67713
|
+
import Joi148 from "joi";
|
|
67449
67714
|
import { ObjectId as ObjectId151 } from "mongodb";
|
|
67450
67715
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
67451
67716
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
@@ -67453,49 +67718,49 @@ var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
|
67453
67718
|
FormEntryStatus2["DELETED"] = "deleted";
|
|
67454
67719
|
return FormEntryStatus2;
|
|
67455
67720
|
})(FormEntryStatus || {});
|
|
67456
|
-
var schemaFormEntry =
|
|
67457
|
-
_id:
|
|
67458
|
-
formType:
|
|
67459
|
-
block:
|
|
67460
|
-
level:
|
|
67461
|
-
unit:
|
|
67462
|
-
name:
|
|
67463
|
-
phoneNumber:
|
|
67464
|
-
createdBy:
|
|
67465
|
-
fields:
|
|
67466
|
-
|
|
67467
|
-
|
|
67468
|
-
|
|
67469
|
-
|
|
67470
|
-
|
|
67471
|
-
|
|
67721
|
+
var schemaFormEntry = Joi148.object({
|
|
67722
|
+
_id: Joi148.string().hex().optional().allow("", null),
|
|
67723
|
+
formType: Joi148.string().required(),
|
|
67724
|
+
block: Joi148.string().optional().allow(null, ""),
|
|
67725
|
+
level: Joi148.string().optional().allow(null, ""),
|
|
67726
|
+
unit: Joi148.string().optional().allow(null, ""),
|
|
67727
|
+
name: Joi148.string().optional().allow(null, ""),
|
|
67728
|
+
phoneNumber: Joi148.string().optional().allow(null, ""),
|
|
67729
|
+
createdBy: Joi148.string().required(),
|
|
67730
|
+
fields: Joi148.object().pattern(
|
|
67731
|
+
Joi148.string(),
|
|
67732
|
+
Joi148.alternatives().try(
|
|
67733
|
+
Joi148.string(),
|
|
67734
|
+
Joi148.number(),
|
|
67735
|
+
Joi148.boolean(),
|
|
67736
|
+
Joi148.valid(null)
|
|
67472
67737
|
)
|
|
67473
67738
|
).required(),
|
|
67474
|
-
status:
|
|
67475
|
-
org:
|
|
67476
|
-
site:
|
|
67477
|
-
createdAt:
|
|
67478
|
-
updatedAt:
|
|
67479
|
-
deletedAt:
|
|
67739
|
+
status: Joi148.string().optional().allow("", null),
|
|
67740
|
+
org: Joi148.string().hex().optional().allow("", null),
|
|
67741
|
+
site: Joi148.string().hex().optional().allow("", null),
|
|
67742
|
+
createdAt: Joi148.date().optional().allow("", null),
|
|
67743
|
+
updatedAt: Joi148.date().optional().allow("", null),
|
|
67744
|
+
deletedAt: Joi148.date().optional().allow("", null)
|
|
67480
67745
|
});
|
|
67481
|
-
var schemaUpdateFormEntry =
|
|
67482
|
-
_id:
|
|
67483
|
-
formType:
|
|
67484
|
-
block:
|
|
67485
|
-
level:
|
|
67486
|
-
unit:
|
|
67487
|
-
fields:
|
|
67488
|
-
|
|
67489
|
-
|
|
67490
|
-
|
|
67491
|
-
|
|
67492
|
-
|
|
67493
|
-
|
|
67746
|
+
var schemaUpdateFormEntry = Joi148.object({
|
|
67747
|
+
_id: Joi148.string().hex().required(),
|
|
67748
|
+
formType: Joi148.string().optional().allow("", null),
|
|
67749
|
+
block: Joi148.string().optional().allow(null, ""),
|
|
67750
|
+
level: Joi148.string().optional().allow(null, ""),
|
|
67751
|
+
unit: Joi148.string().optional().allow(null, ""),
|
|
67752
|
+
fields: Joi148.object().pattern(
|
|
67753
|
+
Joi148.string(),
|
|
67754
|
+
Joi148.alternatives().try(
|
|
67755
|
+
Joi148.string(),
|
|
67756
|
+
Joi148.number(),
|
|
67757
|
+
Joi148.boolean(),
|
|
67758
|
+
Joi148.valid(null)
|
|
67494
67759
|
)
|
|
67495
67760
|
).optional(),
|
|
67496
|
-
status:
|
|
67497
|
-
updatedAt:
|
|
67498
|
-
deletedAt:
|
|
67761
|
+
status: Joi148.string().optional().allow("", null),
|
|
67762
|
+
updatedAt: Joi148.date().optional().allow("", null),
|
|
67763
|
+
deletedAt: Joi148.date().optional().allow("", null)
|
|
67499
67764
|
});
|
|
67500
67765
|
function MFormEntry(value) {
|
|
67501
67766
|
const { error } = schemaFormEntry.validate(value);
|
|
@@ -67540,34 +67805,34 @@ function MFormEntry(value) {
|
|
|
67540
67805
|
deletedAt: value.deletedAt ?? null
|
|
67541
67806
|
};
|
|
67542
67807
|
}
|
|
67543
|
-
var residentFormEntry =
|
|
67544
|
-
_id:
|
|
67545
|
-
typeOfForm:
|
|
67546
|
-
unitNumber:
|
|
67547
|
-
fields:
|
|
67548
|
-
|
|
67549
|
-
|
|
67550
|
-
|
|
67551
|
-
|
|
67552
|
-
|
|
67553
|
-
|
|
67808
|
+
var residentFormEntry = Joi148.object({
|
|
67809
|
+
_id: Joi148.string().hex().optional().allow("", null),
|
|
67810
|
+
typeOfForm: Joi148.string().optional().allow("", null),
|
|
67811
|
+
unitNumber: Joi148.string().optional().allow(null, ""),
|
|
67812
|
+
fields: Joi148.object().pattern(
|
|
67813
|
+
Joi148.string(),
|
|
67814
|
+
Joi148.alternatives().try(
|
|
67815
|
+
Joi148.string(),
|
|
67816
|
+
Joi148.number(),
|
|
67817
|
+
Joi148.boolean(),
|
|
67818
|
+
Joi148.valid(null)
|
|
67554
67819
|
)
|
|
67555
67820
|
).optional().allow(null, ""),
|
|
67556
|
-
status:
|
|
67557
|
-
org:
|
|
67558
|
-
site:
|
|
67559
|
-
userId:
|
|
67560
|
-
createdAt:
|
|
67561
|
-
updatedAt:
|
|
67562
|
-
deletedAt:
|
|
67563
|
-
remarks:
|
|
67564
|
-
managementValues:
|
|
67565
|
-
|
|
67566
|
-
|
|
67567
|
-
|
|
67568
|
-
|
|
67569
|
-
|
|
67570
|
-
|
|
67821
|
+
status: Joi148.string().optional().allow("", null),
|
|
67822
|
+
org: Joi148.string().hex().optional().allow("", null),
|
|
67823
|
+
site: Joi148.string().hex().optional().allow("", null),
|
|
67824
|
+
userId: Joi148.string().hex().optional().allow("", null),
|
|
67825
|
+
createdAt: Joi148.date().optional().allow("", null),
|
|
67826
|
+
updatedAt: Joi148.date().optional().allow("", null),
|
|
67827
|
+
deletedAt: Joi148.date().optional().allow("", null),
|
|
67828
|
+
remarks: Joi148.string().optional().allow("", null),
|
|
67829
|
+
managementValues: Joi148.object().pattern(
|
|
67830
|
+
Joi148.string(),
|
|
67831
|
+
Joi148.alternatives().try(
|
|
67832
|
+
Joi148.string(),
|
|
67833
|
+
Joi148.number(),
|
|
67834
|
+
Joi148.boolean(),
|
|
67835
|
+
Joi148.valid(null)
|
|
67571
67836
|
)
|
|
67572
67837
|
).optional().allow(null, "")
|
|
67573
67838
|
});
|
|
@@ -67576,12 +67841,12 @@ var residentFormEntry = Joi147.object({
|
|
|
67576
67841
|
import {
|
|
67577
67842
|
BadRequestError as BadRequestError225,
|
|
67578
67843
|
InternalServerError as InternalServerError84,
|
|
67579
|
-
logger as
|
|
67844
|
+
logger as logger196,
|
|
67580
67845
|
makeCacheKey as makeCacheKey65,
|
|
67581
67846
|
NotFoundError as NotFoundError62,
|
|
67582
67847
|
paginate as paginate64,
|
|
67583
67848
|
useAtlas as useAtlas129,
|
|
67584
|
-
useCache as
|
|
67849
|
+
useCache as useCache70
|
|
67585
67850
|
} from "@7365admin1/node-server-utils";
|
|
67586
67851
|
import { ObjectId as ObjectId152 } from "mongodb";
|
|
67587
67852
|
var online_forms_namespace_collection = "online-forms";
|
|
@@ -67591,7 +67856,7 @@ function useFormEntryRepo() {
|
|
|
67591
67856
|
throw new InternalServerError84("Unable to connect to server.");
|
|
67592
67857
|
}
|
|
67593
67858
|
const collection = db.collection(online_forms_namespace_collection);
|
|
67594
|
-
const { delNamespace, getCache, setCache } =
|
|
67859
|
+
const { delNamespace, getCache, setCache } = useCache70(
|
|
67595
67860
|
online_forms_namespace_collection
|
|
67596
67861
|
);
|
|
67597
67862
|
const { getUserById } = useUserRepo();
|
|
@@ -67804,7 +68069,7 @@ function useFormEntryRepo() {
|
|
|
67804
68069
|
);
|
|
67805
68070
|
const cachedData = await getCache(cacheKey);
|
|
67806
68071
|
if (cachedData) {
|
|
67807
|
-
|
|
68072
|
+
logger196.info(`Cache hit for key: ${cacheKey}`);
|
|
67808
68073
|
return cachedData;
|
|
67809
68074
|
}
|
|
67810
68075
|
try {
|
|
@@ -67817,9 +68082,9 @@ function useFormEntryRepo() {
|
|
|
67817
68082
|
const length = await collection.countDocuments(query);
|
|
67818
68083
|
const data = paginate64(items, page, limit, length);
|
|
67819
68084
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
67820
|
-
|
|
68085
|
+
logger196.info(`Cache set for key: ${cacheKey}`);
|
|
67821
68086
|
}).catch((err) => {
|
|
67822
|
-
|
|
68087
|
+
logger196.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
67823
68088
|
});
|
|
67824
68089
|
return data;
|
|
67825
68090
|
} catch (error) {
|
|
@@ -67839,8 +68104,8 @@ function useFormEntryRepo() {
|
|
|
67839
68104
|
}
|
|
67840
68105
|
|
|
67841
68106
|
// src/controllers/online-forms-v2.controller.ts
|
|
67842
|
-
import { BadRequestError as BadRequestError226, logger as
|
|
67843
|
-
import
|
|
68107
|
+
import { BadRequestError as BadRequestError226, logger as logger197 } from "@7365admin1/node-server-utils";
|
|
68108
|
+
import Joi149 from "joi";
|
|
67844
68109
|
import ExcelJS3 from "exceljs";
|
|
67845
68110
|
import fs6 from "fs";
|
|
67846
68111
|
function useFormEntryController() {
|
|
@@ -67901,7 +68166,7 @@ function useFormEntryController() {
|
|
|
67901
68166
|
});
|
|
67902
68167
|
if (error) {
|
|
67903
68168
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67904
|
-
|
|
68169
|
+
logger197.log({ level: "error", message: messages });
|
|
67905
68170
|
next(new BadRequestError226(messages));
|
|
67906
68171
|
return;
|
|
67907
68172
|
}
|
|
@@ -67910,24 +68175,24 @@ function useFormEntryController() {
|
|
|
67910
68175
|
fs6.unlink(req.file.path, () => {
|
|
67911
68176
|
});
|
|
67912
68177
|
} catch (error) {
|
|
67913
|
-
|
|
68178
|
+
logger197.log({ level: "error", message: error.message });
|
|
67914
68179
|
next(error);
|
|
67915
68180
|
}
|
|
67916
68181
|
}
|
|
67917
68182
|
async function getAll(req, res, next) {
|
|
67918
68183
|
try {
|
|
67919
|
-
const schema2 =
|
|
67920
|
-
search:
|
|
67921
|
-
page:
|
|
67922
|
-
limit:
|
|
67923
|
-
status:
|
|
67924
|
-
org:
|
|
67925
|
-
site:
|
|
68184
|
+
const schema2 = Joi149.object({
|
|
68185
|
+
search: Joi149.string().optional().allow("", null),
|
|
68186
|
+
page: Joi149.number().integer().min(1).allow("", null).default(1),
|
|
68187
|
+
limit: Joi149.number().integer().min(1).max(100).allow("", null).default(10),
|
|
68188
|
+
status: Joi149.string().optional().allow(null, ""),
|
|
68189
|
+
org: Joi149.string().hex().optional().allow("", null),
|
|
68190
|
+
site: Joi149.string().hex().optional().allow("", null)
|
|
67926
68191
|
});
|
|
67927
68192
|
const { error, value } = schema2.validate(req.query);
|
|
67928
68193
|
if (error) {
|
|
67929
68194
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67930
|
-
|
|
68195
|
+
logger197.log({ level: "error", message: messages });
|
|
67931
68196
|
next(new BadRequestError226(messages));
|
|
67932
68197
|
return;
|
|
67933
68198
|
}
|
|
@@ -67936,20 +68201,20 @@ function useFormEntryController() {
|
|
|
67936
68201
|
res.json(data);
|
|
67937
68202
|
return;
|
|
67938
68203
|
} catch (error) {
|
|
67939
|
-
|
|
68204
|
+
logger197.log({ level: "error", message: error.message });
|
|
67940
68205
|
next(error);
|
|
67941
68206
|
return;
|
|
67942
68207
|
}
|
|
67943
68208
|
}
|
|
67944
68209
|
async function getFormEntryById(req, res, next) {
|
|
67945
68210
|
try {
|
|
67946
|
-
const schema2 =
|
|
67947
|
-
_id:
|
|
68211
|
+
const schema2 = Joi149.object({
|
|
68212
|
+
_id: Joi149.string().hex().length(24).required()
|
|
67948
68213
|
});
|
|
67949
68214
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
67950
68215
|
if (error) {
|
|
67951
68216
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67952
|
-
|
|
68217
|
+
logger197.log({ level: "error", message: messages });
|
|
67953
68218
|
next(new BadRequestError226(messages));
|
|
67954
68219
|
return;
|
|
67955
68220
|
}
|
|
@@ -67958,7 +68223,7 @@ function useFormEntryController() {
|
|
|
67958
68223
|
res.json(data);
|
|
67959
68224
|
return;
|
|
67960
68225
|
} catch (error) {
|
|
67961
|
-
|
|
68226
|
+
logger197.log({ level: "error", message: error.message });
|
|
67962
68227
|
next(error);
|
|
67963
68228
|
return;
|
|
67964
68229
|
}
|
|
@@ -67971,7 +68236,7 @@ function useFormEntryController() {
|
|
|
67971
68236
|
});
|
|
67972
68237
|
if (error) {
|
|
67973
68238
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67974
|
-
|
|
68239
|
+
logger197.log({ level: "error", message: messages });
|
|
67975
68240
|
next(new BadRequestError226(messages));
|
|
67976
68241
|
return;
|
|
67977
68242
|
}
|
|
@@ -67980,18 +68245,18 @@ function useFormEntryController() {
|
|
|
67980
68245
|
res.json({ message: "Successfully updated online form." });
|
|
67981
68246
|
return;
|
|
67982
68247
|
} catch (error) {
|
|
67983
|
-
|
|
68248
|
+
logger197.log({ level: "error", message: error.message });
|
|
67984
68249
|
next(error);
|
|
67985
68250
|
return;
|
|
67986
68251
|
}
|
|
67987
68252
|
}
|
|
67988
68253
|
async function deleteFormEntryById(req, res, next) {
|
|
67989
68254
|
try {
|
|
67990
|
-
const validation =
|
|
68255
|
+
const validation = Joi149.string().hex().required();
|
|
67991
68256
|
const _id = req.params.id;
|
|
67992
68257
|
const { error } = validation.validate(_id);
|
|
67993
68258
|
if (error) {
|
|
67994
|
-
|
|
68259
|
+
logger197.log({ level: "error", message: error.message });
|
|
67995
68260
|
next(new BadRequestError226(error.message));
|
|
67996
68261
|
return;
|
|
67997
68262
|
}
|
|
@@ -67999,7 +68264,7 @@ function useFormEntryController() {
|
|
|
67999
68264
|
res.json({ message: "Successfully deleted online form." });
|
|
68000
68265
|
return;
|
|
68001
68266
|
} catch (error) {
|
|
68002
|
-
|
|
68267
|
+
logger197.log({ level: "error", message: error.message });
|
|
68003
68268
|
next(error);
|
|
68004
68269
|
return;
|
|
68005
68270
|
}
|
|
@@ -68016,7 +68281,7 @@ function useFormEntryController() {
|
|
|
68016
68281
|
});
|
|
68017
68282
|
if (error) {
|
|
68018
68283
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68019
|
-
|
|
68284
|
+
logger197.log({ level: "error", message: messages });
|
|
68020
68285
|
next(new BadRequestError226(messages));
|
|
68021
68286
|
return;
|
|
68022
68287
|
}
|
|
@@ -68025,7 +68290,7 @@ function useFormEntryController() {
|
|
|
68025
68290
|
res.status(201).json({ message: data });
|
|
68026
68291
|
return;
|
|
68027
68292
|
} catch (error2) {
|
|
68028
|
-
|
|
68293
|
+
logger197.log({ level: "error", message: error2.message });
|
|
68029
68294
|
next(error2);
|
|
68030
68295
|
return;
|
|
68031
68296
|
}
|
|
@@ -68037,7 +68302,7 @@ function useFormEntryController() {
|
|
|
68037
68302
|
});
|
|
68038
68303
|
if (error) {
|
|
68039
68304
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68040
|
-
|
|
68305
|
+
logger197.log({ level: "error", message: messages });
|
|
68041
68306
|
next(new BadRequestError226(messages));
|
|
68042
68307
|
return;
|
|
68043
68308
|
}
|
|
@@ -68046,27 +68311,27 @@ function useFormEntryController() {
|
|
|
68046
68311
|
res.status(201).json({ message: data });
|
|
68047
68312
|
return;
|
|
68048
68313
|
} catch (error2) {
|
|
68049
|
-
|
|
68314
|
+
logger197.log({ level: "error", message: error2.message });
|
|
68050
68315
|
next(error2);
|
|
68051
68316
|
return;
|
|
68052
68317
|
}
|
|
68053
68318
|
}
|
|
68054
68319
|
async function residentForm(req, res, next) {
|
|
68055
68320
|
try {
|
|
68056
|
-
const residentFormPayload =
|
|
68057
|
-
org:
|
|
68058
|
-
site:
|
|
68059
|
-
userId:
|
|
68060
|
-
search:
|
|
68061
|
-
page:
|
|
68062
|
-
limit:
|
|
68321
|
+
const residentFormPayload = Joi149.object({
|
|
68322
|
+
org: Joi149.string().hex().required(),
|
|
68323
|
+
site: Joi149.string().hex().required(),
|
|
68324
|
+
userId: Joi149.string().hex().required(),
|
|
68325
|
+
search: Joi149.string().optional().allow("", null),
|
|
68326
|
+
page: Joi149.number().integer().min(1).allow("", null).default(1),
|
|
68327
|
+
limit: Joi149.number().integer().min(1).max(100).allow("", null).default(10)
|
|
68063
68328
|
});
|
|
68064
68329
|
const { error, value } = residentFormPayload.validate(req.query, {
|
|
68065
68330
|
abortEarly: true
|
|
68066
68331
|
});
|
|
68067
68332
|
if (error) {
|
|
68068
68333
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68069
|
-
|
|
68334
|
+
logger197.log({ level: "error", message: messages });
|
|
68070
68335
|
next(new BadRequestError226(messages));
|
|
68071
68336
|
return;
|
|
68072
68337
|
}
|
|
@@ -68074,7 +68339,7 @@ function useFormEntryController() {
|
|
|
68074
68339
|
const result = await _residentForm({ userId, site, org, search, page, limit });
|
|
68075
68340
|
res.json(result);
|
|
68076
68341
|
} catch (error) {
|
|
68077
|
-
|
|
68342
|
+
logger197.log({ level: "error", message: error.message });
|
|
68078
68343
|
next(error);
|
|
68079
68344
|
return;
|
|
68080
68345
|
}
|
|
@@ -68130,8 +68395,8 @@ function useBuildingLevelService() {
|
|
|
68130
68395
|
}
|
|
68131
68396
|
|
|
68132
68397
|
// src/controllers/building-level.controller.ts
|
|
68133
|
-
import { BadRequestError as BadRequestError227, logger as
|
|
68134
|
-
import
|
|
68398
|
+
import { BadRequestError as BadRequestError227, logger as logger198 } from "@7365admin1/node-server-utils";
|
|
68399
|
+
import Joi150 from "joi";
|
|
68135
68400
|
function useBuildingLevelController() {
|
|
68136
68401
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
|
|
68137
68402
|
const {
|
|
@@ -68148,7 +68413,7 @@ function useBuildingLevelController() {
|
|
|
68148
68413
|
});
|
|
68149
68414
|
if (error) {
|
|
68150
68415
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68151
|
-
|
|
68416
|
+
logger198.log({ level: "error", message: messages });
|
|
68152
68417
|
next(new BadRequestError227(messages));
|
|
68153
68418
|
return;
|
|
68154
68419
|
}
|
|
@@ -68160,19 +68425,19 @@ function useBuildingLevelController() {
|
|
|
68160
68425
|
}
|
|
68161
68426
|
async function getAll(req, res, next) {
|
|
68162
68427
|
try {
|
|
68163
|
-
const validation =
|
|
68164
|
-
page:
|
|
68165
|
-
limit:
|
|
68166
|
-
search:
|
|
68167
|
-
site:
|
|
68168
|
-
status:
|
|
68428
|
+
const validation = Joi150.object({
|
|
68429
|
+
page: Joi150.number().min(1).optional().default(1),
|
|
68430
|
+
limit: Joi150.number().min(1).optional().default(20),
|
|
68431
|
+
search: Joi150.string().optional().allow("", null),
|
|
68432
|
+
site: Joi150.string().hex().length(24).optional().allow("", null),
|
|
68433
|
+
status: Joi150.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
|
|
68169
68434
|
});
|
|
68170
68435
|
const { error, value } = validation.validate(req.query, {
|
|
68171
68436
|
abortEarly: false
|
|
68172
68437
|
});
|
|
68173
68438
|
if (error) {
|
|
68174
68439
|
const messages = error.details.map((d) => d.message);
|
|
68175
|
-
|
|
68440
|
+
logger198.log({ level: "error", message: messages.join(", ") });
|
|
68176
68441
|
next(new BadRequestError227(messages.join(", ")));
|
|
68177
68442
|
return;
|
|
68178
68443
|
}
|
|
@@ -68192,13 +68457,13 @@ function useBuildingLevelController() {
|
|
|
68192
68457
|
}
|
|
68193
68458
|
async function getById(req, res, next) {
|
|
68194
68459
|
try {
|
|
68195
|
-
const schema2 =
|
|
68196
|
-
id:
|
|
68460
|
+
const schema2 = Joi150.object({
|
|
68461
|
+
id: Joi150.string().hex().length(24).required()
|
|
68197
68462
|
});
|
|
68198
68463
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
68199
68464
|
if (error) {
|
|
68200
68465
|
const messages = error.details.map((d) => d.message);
|
|
68201
|
-
|
|
68466
|
+
logger198.log({ level: "error", message: messages.join(", ") });
|
|
68202
68467
|
next(new BadRequestError227(messages.join(", ")));
|
|
68203
68468
|
return;
|
|
68204
68469
|
}
|
|
@@ -68218,7 +68483,7 @@ function useBuildingLevelController() {
|
|
|
68218
68483
|
});
|
|
68219
68484
|
if (error) {
|
|
68220
68485
|
const messages = error.details.map((d) => d.message);
|
|
68221
|
-
|
|
68486
|
+
logger198.log({ level: "error", message: messages.join(", ") });
|
|
68222
68487
|
next(new BadRequestError227(messages.join(", ")));
|
|
68223
68488
|
return;
|
|
68224
68489
|
}
|
|
@@ -68231,13 +68496,13 @@ function useBuildingLevelController() {
|
|
|
68231
68496
|
}
|
|
68232
68497
|
async function deleteById(req, res, next) {
|
|
68233
68498
|
try {
|
|
68234
|
-
const schema2 =
|
|
68235
|
-
id:
|
|
68499
|
+
const schema2 = Joi150.object({
|
|
68500
|
+
id: Joi150.string().hex().required()
|
|
68236
68501
|
});
|
|
68237
68502
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
68238
68503
|
if (error) {
|
|
68239
68504
|
const messages = error.details.map((d) => d.message);
|
|
68240
|
-
|
|
68505
|
+
logger198.log({ level: "error", message: messages.join(", ") });
|
|
68241
68506
|
next(new BadRequestError227(messages.join(", ")));
|
|
68242
68507
|
return;
|
|
68243
68508
|
}
|
|
@@ -68251,18 +68516,18 @@ function useBuildingLevelController() {
|
|
|
68251
68516
|
}
|
|
68252
68517
|
async function batchUpdateByIds(req, res, next) {
|
|
68253
68518
|
try {
|
|
68254
|
-
const schema2 =
|
|
68255
|
-
|
|
68256
|
-
_id:
|
|
68257
|
-
value:
|
|
68258
|
-
name:
|
|
68519
|
+
const schema2 = Joi150.array().items(
|
|
68520
|
+
Joi150.object({
|
|
68521
|
+
_id: Joi150.string().hex().length(24).required(),
|
|
68522
|
+
value: Joi150.object({
|
|
68523
|
+
name: Joi150.string().optional().allow("", null)
|
|
68259
68524
|
}).required()
|
|
68260
68525
|
})
|
|
68261
68526
|
);
|
|
68262
68527
|
const { error, value } = schema2.validate(req.body);
|
|
68263
68528
|
if (error) {
|
|
68264
68529
|
const messages = error.details.map((d) => d.message);
|
|
68265
|
-
|
|
68530
|
+
logger198.log({ level: "error", message: messages.join(", ") });
|
|
68266
68531
|
next(new BadRequestError227(messages.join(", ")));
|
|
68267
68532
|
return;
|
|
68268
68533
|
}
|
|
@@ -68278,9 +68543,9 @@ function useBuildingLevelController() {
|
|
|
68278
68543
|
}
|
|
68279
68544
|
async function getBuildingLevelList(req, res, next) {
|
|
68280
68545
|
try {
|
|
68281
|
-
const schema2 =
|
|
68282
|
-
site:
|
|
68283
|
-
block:
|
|
68546
|
+
const schema2 = Joi150.object({
|
|
68547
|
+
site: Joi150.string().hex().length(24).required(),
|
|
68548
|
+
block: Joi150.string().hex().length(24).required()
|
|
68284
68549
|
});
|
|
68285
68550
|
const { error, value } = schema2.validate({
|
|
68286
68551
|
site: req.params.siteId,
|
|
@@ -68288,7 +68553,7 @@ function useBuildingLevelController() {
|
|
|
68288
68553
|
});
|
|
68289
68554
|
if (error) {
|
|
68290
68555
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68291
|
-
|
|
68556
|
+
logger198.log({ level: "error", message: messages });
|
|
68292
68557
|
next(new BadRequestError227(messages));
|
|
68293
68558
|
return;
|
|
68294
68559
|
}
|
|
@@ -68312,9 +68577,9 @@ function useBuildingLevelController() {
|
|
|
68312
68577
|
}
|
|
68313
68578
|
|
|
68314
68579
|
// src/models/hid-amico.model.ts
|
|
68315
|
-
import { BadRequestError as BadRequestError228, logger as
|
|
68580
|
+
import { BadRequestError as BadRequestError228, logger as logger199 } from "@7365admin1/node-server-utils";
|
|
68316
68581
|
import { ObjectId as ObjectId153 } from "mongodb";
|
|
68317
|
-
import
|
|
68582
|
+
import Joi151 from "joi";
|
|
68318
68583
|
function canReadObjectId(value) {
|
|
68319
68584
|
if (value instanceof ObjectId153)
|
|
68320
68585
|
return true;
|
|
@@ -68354,159 +68619,159 @@ function toObjectId23(value, label = "ID") {
|
|
|
68354
68619
|
}
|
|
68355
68620
|
throw new BadRequestError228(`Invalid ${label} format`);
|
|
68356
68621
|
}
|
|
68357
|
-
var objectIdSchema2 =
|
|
68622
|
+
var objectIdSchema2 = Joi151.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
|
|
68358
68623
|
"any.invalid": "{{#label}} must be a valid ObjectId"
|
|
68359
68624
|
});
|
|
68360
|
-
var schemaHidAmicoReader =
|
|
68625
|
+
var schemaHidAmicoReader = Joi151.object({
|
|
68361
68626
|
_id: objectIdSchema2.optional(),
|
|
68362
68627
|
site: objectIdSchema2.required(),
|
|
68363
|
-
name:
|
|
68364
|
-
baseUrl:
|
|
68365
|
-
username:
|
|
68366
|
-
password:
|
|
68367
|
-
location:
|
|
68368
|
-
deviceId:
|
|
68369
|
-
monitorPath:
|
|
68370
|
-
enabled:
|
|
68371
|
-
status:
|
|
68372
|
-
lastSeenAt:
|
|
68373
|
-
lastSyncAt:
|
|
68374
|
-
lastSyncStatus:
|
|
68375
|
-
lastSyncMessage:
|
|
68376
|
-
createdAt:
|
|
68377
|
-
updatedAt:
|
|
68378
|
-
deletedAt:
|
|
68628
|
+
name: Joi151.string().trim().required(),
|
|
68629
|
+
baseUrl: Joi151.string().uri({ scheme: ["http", "https"] }).required(),
|
|
68630
|
+
username: Joi151.string().trim().required(),
|
|
68631
|
+
password: Joi151.string().required(),
|
|
68632
|
+
location: Joi151.string().allow(null, "").optional(),
|
|
68633
|
+
deviceId: Joi151.string().allow(null, "").optional(),
|
|
68634
|
+
monitorPath: Joi151.string().allow(null, "").optional(),
|
|
68635
|
+
enabled: Joi151.boolean().optional(),
|
|
68636
|
+
status: Joi151.string().valid("active", "inactive", "deleted", "offline").optional(),
|
|
68637
|
+
lastSeenAt: Joi151.date().optional(),
|
|
68638
|
+
lastSyncAt: Joi151.date().optional(),
|
|
68639
|
+
lastSyncStatus: Joi151.string().valid("idle", "running", "completed", "failed").optional(),
|
|
68640
|
+
lastSyncMessage: Joi151.string().allow(null, "").optional(),
|
|
68641
|
+
createdAt: Joi151.date().optional(),
|
|
68642
|
+
updatedAt: Joi151.date().optional(),
|
|
68643
|
+
deletedAt: Joi151.date().optional()
|
|
68379
68644
|
});
|
|
68380
|
-
var schemaUpdateHidAmicoReader =
|
|
68645
|
+
var schemaUpdateHidAmicoReader = Joi151.object({
|
|
68381
68646
|
site: objectIdSchema2.optional(),
|
|
68382
|
-
name:
|
|
68383
|
-
baseUrl:
|
|
68384
|
-
username:
|
|
68385
|
-
password:
|
|
68386
|
-
location:
|
|
68387
|
-
deviceId:
|
|
68388
|
-
monitorPath:
|
|
68389
|
-
enabled:
|
|
68390
|
-
status:
|
|
68391
|
-
lastSeenAt:
|
|
68392
|
-
lastSyncAt:
|
|
68393
|
-
lastSyncStatus:
|
|
68394
|
-
lastSyncMessage:
|
|
68395
|
-
deletedAt:
|
|
68647
|
+
name: Joi151.string().trim().optional(),
|
|
68648
|
+
baseUrl: Joi151.string().uri({ scheme: ["http", "https"] }).optional(),
|
|
68649
|
+
username: Joi151.string().trim().optional(),
|
|
68650
|
+
password: Joi151.string().allow(null, "").optional(),
|
|
68651
|
+
location: Joi151.string().allow(null, "").optional(),
|
|
68652
|
+
deviceId: Joi151.string().allow(null, "").optional(),
|
|
68653
|
+
monitorPath: Joi151.string().allow(null, "").optional(),
|
|
68654
|
+
enabled: Joi151.boolean().optional(),
|
|
68655
|
+
status: Joi151.string().valid("active", "inactive", "deleted", "offline").optional(),
|
|
68656
|
+
lastSeenAt: Joi151.date().optional(),
|
|
68657
|
+
lastSyncAt: Joi151.date().optional(),
|
|
68658
|
+
lastSyncStatus: Joi151.string().valid("idle", "running", "completed", "failed").optional(),
|
|
68659
|
+
lastSyncMessage: Joi151.string().allow(null, "").optional(),
|
|
68660
|
+
deletedAt: Joi151.date().optional()
|
|
68396
68661
|
});
|
|
68397
|
-
var schemaHidAmicoEvent =
|
|
68662
|
+
var schemaHidAmicoEvent = Joi151.object({
|
|
68398
68663
|
_id: objectIdSchema2.optional(),
|
|
68399
68664
|
reader: objectIdSchema2.required(),
|
|
68400
68665
|
site: objectIdSchema2.optional(),
|
|
68401
|
-
type:
|
|
68402
|
-
payload:
|
|
68403
|
-
status:
|
|
68404
|
-
createdAt:
|
|
68666
|
+
type: Joi151.string().required(),
|
|
68667
|
+
payload: Joi151.object().unknown(true).required(),
|
|
68668
|
+
status: Joi151.string().valid("received", "processed", "failed").optional(),
|
|
68669
|
+
createdAt: Joi151.date().optional()
|
|
68405
68670
|
});
|
|
68406
|
-
var schemaHidAmicoIdentity =
|
|
68671
|
+
var schemaHidAmicoIdentity = Joi151.object({
|
|
68407
68672
|
_id: objectIdSchema2.optional(),
|
|
68408
68673
|
reader: objectIdSchema2.required(),
|
|
68409
68674
|
site: objectIdSchema2.required(),
|
|
68410
|
-
hidUserId:
|
|
68411
|
-
registration:
|
|
68412
|
-
cardNo:
|
|
68675
|
+
hidUserId: Joi151.alternatives(Joi151.string(), Joi151.number()).optional().allow(null, ""),
|
|
68676
|
+
registration: Joi151.string().optional().allow(null, ""),
|
|
68677
|
+
cardNo: Joi151.string().optional().allow(null, ""),
|
|
68413
68678
|
person: objectIdSchema2.optional().allow(null, ""),
|
|
68414
68679
|
user: objectIdSchema2.optional().allow(null, ""),
|
|
68415
68680
|
member: objectIdSchema2.optional().allow(null, ""),
|
|
68416
68681
|
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
68417
|
-
type:
|
|
68418
|
-
status:
|
|
68419
|
-
metadata:
|
|
68420
|
-
createdAt:
|
|
68421
|
-
updatedAt:
|
|
68422
|
-
deletedAt:
|
|
68682
|
+
type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
|
|
68683
|
+
status: Joi151.string().valid("active", "inactive", "deleted").optional(),
|
|
68684
|
+
metadata: Joi151.object().unknown(true).optional(),
|
|
68685
|
+
createdAt: Joi151.date().optional(),
|
|
68686
|
+
updatedAt: Joi151.date().optional(),
|
|
68687
|
+
deletedAt: Joi151.date().optional()
|
|
68423
68688
|
}).or("hidUserId", "registration", "cardNo");
|
|
68424
|
-
var schemaCreateHidAmicoIdentity =
|
|
68689
|
+
var schemaCreateHidAmicoIdentity = Joi151.object({
|
|
68425
68690
|
site: objectIdSchema2.optional(),
|
|
68426
|
-
hidUserId:
|
|
68427
|
-
registration:
|
|
68428
|
-
cardNo:
|
|
68691
|
+
hidUserId: Joi151.alternatives(Joi151.string(), Joi151.number()).optional().allow(null, ""),
|
|
68692
|
+
registration: Joi151.string().optional().allow(null, ""),
|
|
68693
|
+
cardNo: Joi151.string().optional().allow(null, ""),
|
|
68429
68694
|
person: objectIdSchema2.optional().allow(null, ""),
|
|
68430
68695
|
user: objectIdSchema2.optional().allow(null, ""),
|
|
68431
68696
|
member: objectIdSchema2.optional().allow(null, ""),
|
|
68432
68697
|
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
68433
|
-
type:
|
|
68434
|
-
status:
|
|
68435
|
-
metadata:
|
|
68698
|
+
type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
|
|
68699
|
+
status: Joi151.string().valid("active", "inactive", "deleted").optional(),
|
|
68700
|
+
metadata: Joi151.object().unknown(true).optional()
|
|
68436
68701
|
}).or("hidUserId", "registration", "cardNo");
|
|
68437
|
-
var schemaUpdateHidAmicoIdentity =
|
|
68438
|
-
hidUserId:
|
|
68439
|
-
registration:
|
|
68440
|
-
cardNo:
|
|
68702
|
+
var schemaUpdateHidAmicoIdentity = Joi151.object({
|
|
68703
|
+
hidUserId: Joi151.alternatives(Joi151.string(), Joi151.number()).optional().allow(null, ""),
|
|
68704
|
+
registration: Joi151.string().optional().allow(null, ""),
|
|
68705
|
+
cardNo: Joi151.string().optional().allow(null, ""),
|
|
68441
68706
|
person: objectIdSchema2.optional().allow(null, ""),
|
|
68442
68707
|
user: objectIdSchema2.optional().allow(null, ""),
|
|
68443
68708
|
member: objectIdSchema2.optional().allow(null, ""),
|
|
68444
68709
|
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
68445
|
-
type:
|
|
68446
|
-
status:
|
|
68447
|
-
metadata:
|
|
68448
|
-
deletedAt:
|
|
68710
|
+
type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
|
|
68711
|
+
status: Joi151.string().valid("active", "inactive", "deleted").optional(),
|
|
68712
|
+
metadata: Joi151.object().unknown(true).optional(),
|
|
68713
|
+
deletedAt: Joi151.date().optional()
|
|
68449
68714
|
});
|
|
68450
|
-
var schemaHidAmicoReaderIdParams =
|
|
68451
|
-
readerId:
|
|
68715
|
+
var schemaHidAmicoReaderIdParams = Joi151.object({
|
|
68716
|
+
readerId: Joi151.string().hex().length(24).required()
|
|
68452
68717
|
});
|
|
68453
|
-
var schemaHidAmicoUserImageParams =
|
|
68454
|
-
readerId:
|
|
68455
|
-
hidUserId:
|
|
68718
|
+
var schemaHidAmicoUserImageParams = Joi151.object({
|
|
68719
|
+
readerId: Joi151.string().hex().length(24).required(),
|
|
68720
|
+
hidUserId: Joi151.alternatives().try(Joi151.string(), Joi151.number()).required()
|
|
68456
68721
|
});
|
|
68457
|
-
var schemaHidAmicoIdentityIdParams =
|
|
68458
|
-
identityId:
|
|
68722
|
+
var schemaHidAmicoIdentityIdParams = Joi151.object({
|
|
68723
|
+
identityId: Joi151.string().hex().length(24).required()
|
|
68459
68724
|
});
|
|
68460
|
-
var schemaHidAmicoReaderListQuery =
|
|
68461
|
-
site:
|
|
68462
|
-
page:
|
|
68463
|
-
limit:
|
|
68725
|
+
var schemaHidAmicoReaderListQuery = Joi151.object({
|
|
68726
|
+
site: Joi151.string().hex().length(24).optional(),
|
|
68727
|
+
page: Joi151.number().min(1).optional(),
|
|
68728
|
+
limit: Joi151.number().min(1).optional()
|
|
68464
68729
|
});
|
|
68465
|
-
var schemaHidAmicoLogQuery =
|
|
68466
|
-
page:
|
|
68467
|
-
limit:
|
|
68468
|
-
type:
|
|
68730
|
+
var schemaHidAmicoLogQuery = Joi151.object({
|
|
68731
|
+
page: Joi151.number().min(1).optional(),
|
|
68732
|
+
limit: Joi151.number().min(1).optional(),
|
|
68733
|
+
type: Joi151.string().optional()
|
|
68469
68734
|
});
|
|
68470
|
-
var schemaHidAmicoIdentityQuery =
|
|
68471
|
-
page:
|
|
68472
|
-
limit:
|
|
68473
|
-
type:
|
|
68474
|
-
status:
|
|
68475
|
-
search:
|
|
68735
|
+
var schemaHidAmicoIdentityQuery = Joi151.object({
|
|
68736
|
+
page: Joi151.number().min(1).optional(),
|
|
68737
|
+
limit: Joi151.number().min(1).optional(),
|
|
68738
|
+
type: Joi151.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
|
|
68739
|
+
status: Joi151.string().valid("active", "inactive", "deleted").optional(),
|
|
68740
|
+
search: Joi151.string().allow("").optional()
|
|
68476
68741
|
});
|
|
68477
|
-
var schemaHidAmicoSync =
|
|
68478
|
-
objects:
|
|
68479
|
-
|
|
68480
|
-
object:
|
|
68481
|
-
values:
|
|
68742
|
+
var schemaHidAmicoSync = Joi151.object({
|
|
68743
|
+
objects: Joi151.array().items(
|
|
68744
|
+
Joi151.object({
|
|
68745
|
+
object: Joi151.string().required(),
|
|
68746
|
+
values: Joi151.array().items(Joi151.object().unknown(true)).required()
|
|
68482
68747
|
}).unknown(true)
|
|
68483
68748
|
).optional(),
|
|
68484
|
-
users:
|
|
68485
|
-
cards:
|
|
68486
|
-
qrcodes:
|
|
68487
|
-
pins:
|
|
68749
|
+
users: Joi151.array().items(Joi151.object().unknown(true)).optional(),
|
|
68750
|
+
cards: Joi151.array().items(Joi151.object().unknown(true)).optional(),
|
|
68751
|
+
qrcodes: Joi151.array().items(Joi151.object().unknown(true)).optional(),
|
|
68752
|
+
pins: Joi151.array().items(Joi151.object().unknown(true)).optional()
|
|
68488
68753
|
}).unknown(true);
|
|
68489
|
-
var schemaHidAmicoExecuteActions =
|
|
68490
|
-
actions:
|
|
68754
|
+
var schemaHidAmicoExecuteActions = Joi151.object({
|
|
68755
|
+
actions: Joi151.array().items(Joi151.object().unknown(true)).min(1).required()
|
|
68491
68756
|
}).unknown(true);
|
|
68492
|
-
var schemaHidAmicoConfiguration =
|
|
68493
|
-
var schemaHidAmicoSetConfiguration =
|
|
68494
|
-
var schemaHidAmicoObjectOperation =
|
|
68495
|
-
operation:
|
|
68496
|
-
object:
|
|
68497
|
-
values:
|
|
68498
|
-
|
|
68499
|
-
|
|
68757
|
+
var schemaHidAmicoConfiguration = Joi151.object().pattern(Joi151.string(), Joi151.array().items(Joi151.string())).min(1).unknown(true);
|
|
68758
|
+
var schemaHidAmicoSetConfiguration = Joi151.object().unknown(true);
|
|
68759
|
+
var schemaHidAmicoObjectOperation = Joi151.object({
|
|
68760
|
+
operation: Joi151.string().valid("load", "create", "modify", "destroy").required(),
|
|
68761
|
+
object: Joi151.string().required(),
|
|
68762
|
+
values: Joi151.alternatives().try(
|
|
68763
|
+
Joi151.array().items(Joi151.object().unknown(true)),
|
|
68764
|
+
Joi151.object().unknown(true)
|
|
68500
68765
|
).optional(),
|
|
68501
|
-
where:
|
|
68502
|
-
fields:
|
|
68503
|
-
order:
|
|
68504
|
-
limit:
|
|
68505
|
-
offset:
|
|
68766
|
+
where: Joi151.object().unknown(true).optional(),
|
|
68767
|
+
fields: Joi151.array().items(Joi151.string()).optional(),
|
|
68768
|
+
order: Joi151.array().items(Joi151.string()).optional(),
|
|
68769
|
+
limit: Joi151.number().integer().min(1).optional(),
|
|
68770
|
+
offset: Joi151.number().integer().min(0).optional()
|
|
68506
68771
|
}).unknown(true);
|
|
68507
|
-
var schemaHidAmicoNotificationParams =
|
|
68508
|
-
readerId:
|
|
68509
|
-
type:
|
|
68772
|
+
var schemaHidAmicoNotificationParams = Joi151.object({
|
|
68773
|
+
readerId: Joi151.string().hex().length(24).required(),
|
|
68774
|
+
type: Joi151.string().valid(
|
|
68510
68775
|
"dao",
|
|
68511
68776
|
"template",
|
|
68512
68777
|
"user_image",
|
|
@@ -68524,7 +68789,7 @@ var schemaHidAmicoNotificationParams = Joi150.object({
|
|
|
68524
68789
|
function MHidAmicoReader(value) {
|
|
68525
68790
|
const { error } = schemaHidAmicoReader.validate(value);
|
|
68526
68791
|
if (error) {
|
|
68527
|
-
|
|
68792
|
+
logger199.info(`HID Amico reader: ${error.message}`);
|
|
68528
68793
|
throw new BadRequestError228(error.message);
|
|
68529
68794
|
}
|
|
68530
68795
|
return {
|
|
@@ -68551,7 +68816,7 @@ function MHidAmicoReader(value) {
|
|
|
68551
68816
|
function MHidAmicoEvent(value) {
|
|
68552
68817
|
const { error } = schemaHidAmicoEvent.validate(value);
|
|
68553
68818
|
if (error) {
|
|
68554
|
-
|
|
68819
|
+
logger199.info(`HID Amico event: ${error.message}`);
|
|
68555
68820
|
throw new BadRequestError228(error.message);
|
|
68556
68821
|
}
|
|
68557
68822
|
return {
|
|
@@ -68570,7 +68835,7 @@ function optionalObjectId(value) {
|
|
|
68570
68835
|
function MHidAmicoIdentity(value) {
|
|
68571
68836
|
const { error } = schemaHidAmicoIdentity.validate(value);
|
|
68572
68837
|
if (error) {
|
|
68573
|
-
|
|
68838
|
+
logger199.info(`HID Amico identity: ${error.message}`);
|
|
68574
68839
|
throw new BadRequestError228(error.message);
|
|
68575
68840
|
}
|
|
68576
68841
|
return {
|
|
@@ -68597,7 +68862,7 @@ function MHidAmicoIdentity(value) {
|
|
|
68597
68862
|
import {
|
|
68598
68863
|
BadRequestError as BadRequestError229,
|
|
68599
68864
|
InternalServerError as InternalServerError85,
|
|
68600
|
-
logger as
|
|
68865
|
+
logger as logger200,
|
|
68601
68866
|
paginate as paginate65,
|
|
68602
68867
|
useAtlas as useAtlas131
|
|
68603
68868
|
} from "@7365admin1/node-server-utils";
|
|
@@ -68674,7 +68939,7 @@ function useHidAmicoRepo() {
|
|
|
68674
68939
|
]);
|
|
68675
68940
|
return "HID Amico indexes created.";
|
|
68676
68941
|
} catch (error) {
|
|
68677
|
-
|
|
68942
|
+
logger200.error(error.message);
|
|
68678
68943
|
throw new Error("Failed to create HID Amico indexes.");
|
|
68679
68944
|
}
|
|
68680
68945
|
}
|
|
@@ -69809,6 +70074,7 @@ export {
|
|
|
69809
70074
|
building_units_namespace_collection,
|
|
69810
70075
|
buildings_namespace_collection,
|
|
69811
70076
|
bulletin_boards_namespace_collection,
|
|
70077
|
+
chatPrelovedEvents,
|
|
69812
70078
|
chatSchema,
|
|
69813
70079
|
createManpowerRemarksDaily,
|
|
69814
70080
|
customerSchema,
|
|
@@ -69964,6 +70230,7 @@ export {
|
|
|
69964
70230
|
useAuthServiceV2,
|
|
69965
70231
|
useBidPrelovedController,
|
|
69966
70232
|
useBidPrelovedRepo,
|
|
70233
|
+
useBidPrelovedService,
|
|
69967
70234
|
useBuildingController,
|
|
69968
70235
|
useBuildingLevelController,
|
|
69969
70236
|
useBuildingLevelRepo,
|