@7365admin1/core 3.14.0 → 3.15.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 +15 -2
- package/dist/index.js +751 -483
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +649 -383
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -536,13 +536,13 @@ var require_logger = __commonJS({
|
|
|
536
536
|
"use strict";
|
|
537
537
|
exports.__esModule = true;
|
|
538
538
|
var _utils = require_utils();
|
|
539
|
-
var
|
|
539
|
+
var logger201 = {
|
|
540
540
|
methodMap: ["debug", "info", "warn", "error"],
|
|
541
541
|
level: "info",
|
|
542
542
|
// Maps a given level value to the `methodMap` indexes above.
|
|
543
543
|
lookupLevel: function lookupLevel(level) {
|
|
544
544
|
if (typeof level === "string") {
|
|
545
|
-
var levelMap = _utils.indexOf(
|
|
545
|
+
var levelMap = _utils.indexOf(logger201.methodMap, level.toLowerCase());
|
|
546
546
|
if (levelMap >= 0) {
|
|
547
547
|
level = levelMap;
|
|
548
548
|
} else {
|
|
@@ -553,9 +553,9 @@ var require_logger = __commonJS({
|
|
|
553
553
|
},
|
|
554
554
|
// Can be overridden in the host environment
|
|
555
555
|
log: function log(level) {
|
|
556
|
-
level =
|
|
557
|
-
if (typeof console !== "undefined" &&
|
|
558
|
-
var method =
|
|
556
|
+
level = logger201.lookupLevel(level);
|
|
557
|
+
if (typeof console !== "undefined" && logger201.lookupLevel(logger201.level) <= level) {
|
|
558
|
+
var method = logger201.methodMap[level];
|
|
559
559
|
if (!console[method]) {
|
|
560
560
|
method = "log";
|
|
561
561
|
}
|
|
@@ -566,7 +566,7 @@ var require_logger = __commonJS({
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
};
|
|
569
|
-
exports["default"] =
|
|
569
|
+
exports["default"] = logger201;
|
|
570
570
|
module2.exports = exports["default"];
|
|
571
571
|
}
|
|
572
572
|
});
|
|
@@ -6036,6 +6036,7 @@ __export(src_exports, {
|
|
|
6036
6036
|
building_units_namespace_collection: () => building_units_namespace_collection,
|
|
6037
6037
|
buildings_namespace_collection: () => buildings_namespace_collection,
|
|
6038
6038
|
bulletin_boards_namespace_collection: () => bulletin_boards_namespace_collection,
|
|
6039
|
+
chatPrelovedEvents: () => chatPrelovedEvents,
|
|
6039
6040
|
chatSchema: () => chatSchema,
|
|
6040
6041
|
createManpowerRemarksDaily: () => createManpowerRemarksDaily,
|
|
6041
6042
|
customerSchema: () => customerSchema,
|
|
@@ -6191,6 +6192,7 @@ __export(src_exports, {
|
|
|
6191
6192
|
useAuthServiceV2: () => useAuthServiceV2,
|
|
6192
6193
|
useBidPrelovedController: () => useBidPrelovedController,
|
|
6193
6194
|
useBidPrelovedRepo: () => useBidPrelovedRepo,
|
|
6195
|
+
useBidPrelovedService: () => useBidPrelovedService,
|
|
6194
6196
|
useBuildingController: () => useBuildingController,
|
|
6195
6197
|
useBuildingLevelController: () => useBuildingLevelController,
|
|
6196
6198
|
useBuildingLevelRepo: () => useBuildingLevelRepo,
|
|
@@ -8742,12 +8744,6 @@ function useUserRepo() {
|
|
|
8742
8744
|
throw new import_node_server_utils10.BadRequestError("Invalid user ID format.");
|
|
8743
8745
|
}
|
|
8744
8746
|
try {
|
|
8745
|
-
const cacheKey = (0, import_node_server_utils10.makeCacheKey)(namespace_collection, { _id });
|
|
8746
|
-
const cachedData = await getCache(cacheKey);
|
|
8747
|
-
if (cachedData) {
|
|
8748
|
-
import_node_server_utils10.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
8749
|
-
return cachedData;
|
|
8750
|
-
}
|
|
8751
8747
|
const results = await collection.aggregate([
|
|
8752
8748
|
{ $match: { _id } },
|
|
8753
8749
|
{
|
|
@@ -8771,17 +8767,42 @@ function useUserRepo() {
|
|
|
8771
8767
|
],
|
|
8772
8768
|
as: "serviceProviders"
|
|
8773
8769
|
}
|
|
8774
|
-
}
|
|
8770
|
+
},
|
|
8771
|
+
{
|
|
8772
|
+
$lookup: {
|
|
8773
|
+
from: "buildings",
|
|
8774
|
+
localField: "block",
|
|
8775
|
+
foreignField: "_id",
|
|
8776
|
+
pipeline: [{ $project: { _id: 0, name: 1, block: 1 } }],
|
|
8777
|
+
as: "blockInfo"
|
|
8778
|
+
}
|
|
8779
|
+
},
|
|
8780
|
+
{ $unwind: { path: "$blockInfo", preserveNullAndEmptyArrays: true } },
|
|
8781
|
+
{
|
|
8782
|
+
$lookup: {
|
|
8783
|
+
from: "building-levels",
|
|
8784
|
+
localField: "level",
|
|
8785
|
+
foreignField: "_id",
|
|
8786
|
+
pipeline: [{ $project: { _id: 0, name: 1 } }],
|
|
8787
|
+
as: "levelInfo"
|
|
8788
|
+
}
|
|
8789
|
+
},
|
|
8790
|
+
{ $unwind: { path: "$levelInfo", preserveNullAndEmptyArrays: true } },
|
|
8791
|
+
{
|
|
8792
|
+
$lookup: {
|
|
8793
|
+
from: "building-units",
|
|
8794
|
+
localField: "unitId",
|
|
8795
|
+
foreignField: "_id",
|
|
8796
|
+
pipeline: [{ $project: { _id: 0, name: 1 } }],
|
|
8797
|
+
as: "unitInfo"
|
|
8798
|
+
}
|
|
8799
|
+
},
|
|
8800
|
+
{ $unwind: { path: "$unitInfo", preserveNullAndEmptyArrays: true } }
|
|
8775
8801
|
]).toArray();
|
|
8776
8802
|
const data = results.length > 0 ? results[0] : null;
|
|
8777
8803
|
if (!data) {
|
|
8778
8804
|
throw new import_node_server_utils10.NotFoundError("User not found.");
|
|
8779
8805
|
}
|
|
8780
|
-
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
8781
|
-
import_node_server_utils10.logger.info(`Cache set for key: ${cacheKey}`);
|
|
8782
|
-
}).catch((err) => {
|
|
8783
|
-
import_node_server_utils10.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
8784
|
-
});
|
|
8785
8806
|
return data;
|
|
8786
8807
|
} catch (error) {
|
|
8787
8808
|
if (error instanceof import_node_server_utils10.AppError) {
|
|
@@ -25813,6 +25834,22 @@ function useBuildingUnitRepo() {
|
|
|
25813
25834
|
}
|
|
25814
25835
|
return [level];
|
|
25815
25836
|
}
|
|
25837
|
+
function escapeRegExp(value) {
|
|
25838
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
25839
|
+
}
|
|
25840
|
+
function makeFlexibleRegex(value) {
|
|
25841
|
+
const pattern = value.trim().split(/\s+/).map(escapeRegExp).join("\\s*");
|
|
25842
|
+
return pattern ? new RegExp(pattern, "i") : null;
|
|
25843
|
+
}
|
|
25844
|
+
function getSearchParts(searchText) {
|
|
25845
|
+
const levelMatch = searchText.match(/\b(?:lvl|level)\s*([a-z0-9]+)\b/i);
|
|
25846
|
+
const levelSearch = levelMatch?.[0] ?? "";
|
|
25847
|
+
const unitSearch = levelSearch ? searchText.replace(levelSearch, "").trim() : "";
|
|
25848
|
+
return {
|
|
25849
|
+
levelRegex: makeFlexibleRegex(levelSearch),
|
|
25850
|
+
unitRegex: makeFlexibleRegex(unitSearch)
|
|
25851
|
+
};
|
|
25852
|
+
}
|
|
25816
25853
|
async function add(value, session) {
|
|
25817
25854
|
try {
|
|
25818
25855
|
value = MBuildingUnit(value);
|
|
@@ -25938,9 +25975,11 @@ function useBuildingUnitRepo() {
|
|
|
25938
25975
|
status = "active"
|
|
25939
25976
|
} = {}) {
|
|
25940
25977
|
page = page > 0 ? page - 1 : 0;
|
|
25978
|
+
const searchText = search.trim();
|
|
25979
|
+
const searchRegex = makeFlexibleRegex(searchText);
|
|
25980
|
+
const { levelRegex, unitRegex } = getSearchParts(searchText);
|
|
25941
25981
|
const query = {
|
|
25942
25982
|
status,
|
|
25943
|
-
...search && { $text: { $search: search } },
|
|
25944
25983
|
...site && { site: (0, import_node_server_utils76.toObjectId)(site) },
|
|
25945
25984
|
...building && { building: (0, import_node_server_utils76.toObjectId)(building) }
|
|
25946
25985
|
};
|
|
@@ -25949,7 +25988,7 @@ function useBuildingUnitRepo() {
|
|
|
25949
25988
|
page,
|
|
25950
25989
|
limit,
|
|
25951
25990
|
sort: JSON.stringify(sort),
|
|
25952
|
-
...
|
|
25991
|
+
...searchText && { search: searchText },
|
|
25953
25992
|
...site && { site },
|
|
25954
25993
|
...building && { building },
|
|
25955
25994
|
...status && { status }
|
|
@@ -25971,8 +26010,45 @@ function useBuildingUnitRepo() {
|
|
|
25971
26010
|
});
|
|
25972
26011
|
return cached;
|
|
25973
26012
|
}
|
|
25974
|
-
const
|
|
26013
|
+
const pipeline = [
|
|
25975
26014
|
{ $match: query },
|
|
26015
|
+
{
|
|
26016
|
+
$lookup: {
|
|
26017
|
+
from: "building-levels",
|
|
26018
|
+
localField: "level",
|
|
26019
|
+
foreignField: "_id",
|
|
26020
|
+
pipeline: [{ $project: { name: 1 } }],
|
|
26021
|
+
as: "level"
|
|
26022
|
+
}
|
|
26023
|
+
},
|
|
26024
|
+
{ $set: { level: { $first: "$level" } } },
|
|
26025
|
+
...searchRegex ? [
|
|
26026
|
+
{
|
|
26027
|
+
$match: {
|
|
26028
|
+
$or: [
|
|
26029
|
+
{ name: searchRegex },
|
|
26030
|
+
{ buildingName: searchRegex },
|
|
26031
|
+
{ "level.name": searchRegex },
|
|
26032
|
+
...levelRegex && unitRegex ? [
|
|
26033
|
+
{
|
|
26034
|
+
$and: [
|
|
26035
|
+
{
|
|
26036
|
+
$or: [
|
|
26037
|
+
{ name: unitRegex },
|
|
26038
|
+
{ buildingName: unitRegex }
|
|
26039
|
+
]
|
|
26040
|
+
},
|
|
26041
|
+
{ "level.name": levelRegex }
|
|
26042
|
+
]
|
|
26043
|
+
}
|
|
26044
|
+
] : []
|
|
26045
|
+
]
|
|
26046
|
+
}
|
|
26047
|
+
}
|
|
26048
|
+
] : []
|
|
26049
|
+
];
|
|
26050
|
+
const items = await collection.aggregate([
|
|
26051
|
+
...pipeline,
|
|
25976
26052
|
{
|
|
25977
26053
|
$lookup: {
|
|
25978
26054
|
from: "sites",
|
|
@@ -25998,22 +26074,13 @@ function useBuildingUnitRepo() {
|
|
|
25998
26074
|
as: "site"
|
|
25999
26075
|
}
|
|
26000
26076
|
},
|
|
26001
|
-
{
|
|
26002
|
-
$lookup: {
|
|
26003
|
-
from: "building-levels",
|
|
26004
|
-
localField: "level",
|
|
26005
|
-
foreignField: "_id",
|
|
26006
|
-
pipeline: [{ $project: { name: 1 } }],
|
|
26007
|
-
as: "level"
|
|
26008
|
-
}
|
|
26009
|
-
},
|
|
26010
|
-
{ $set: { level: { $first: "$level" } } },
|
|
26011
26077
|
{ $set: { site: { $first: "$site" } } },
|
|
26012
26078
|
{ $sort: sort },
|
|
26013
26079
|
{ $skip: page * limit },
|
|
26014
26080
|
{ $limit: limit }
|
|
26015
26081
|
]).toArray();
|
|
26016
|
-
const
|
|
26082
|
+
const total = await collection.aggregate([...pipeline, { $count: "length" }]).toArray();
|
|
26083
|
+
const length = total[0]?.length ?? 0;
|
|
26017
26084
|
const data = (0, import_node_server_utils76.paginate)(items, page, limit, length);
|
|
26018
26085
|
setCache(cacheKey, data, 600).then(() => {
|
|
26019
26086
|
import_node_server_utils76.logger.log({
|
|
@@ -28102,6 +28169,7 @@ function useBuildingRepo() {
|
|
|
28102
28169
|
{ key: { name: "text" }, name: "text-index" },
|
|
28103
28170
|
// { key: { name: 1 }, unique: true, name: "unique-name-index" },
|
|
28104
28171
|
{ key: { site: 1 } },
|
|
28172
|
+
{ key: { block: 1 }, name: "block-index" },
|
|
28105
28173
|
{ key: { createdAt: 1 } },
|
|
28106
28174
|
{
|
|
28107
28175
|
key: { site: 1, block: 1 },
|
|
@@ -28204,17 +28272,25 @@ function useBuildingRepo() {
|
|
|
28204
28272
|
throw new import_node_server_utils83.BadRequestError("Invalid site ID.");
|
|
28205
28273
|
}
|
|
28206
28274
|
}
|
|
28275
|
+
const searchText = search.trim();
|
|
28276
|
+
const blockSearch = Number(searchText);
|
|
28277
|
+
const canSearchBlock = searchText !== "" && Number.isFinite(blockSearch);
|
|
28207
28278
|
const query = {
|
|
28208
28279
|
status,
|
|
28209
|
-
...
|
|
28210
|
-
...
|
|
28280
|
+
...siteId && { site: siteId },
|
|
28281
|
+
...searchText && {
|
|
28282
|
+
$or: [
|
|
28283
|
+
{ $text: { $search: searchText } },
|
|
28284
|
+
...canSearchBlock ? [{ block: blockSearch }] : []
|
|
28285
|
+
]
|
|
28286
|
+
}
|
|
28211
28287
|
};
|
|
28212
28288
|
sort = Object.keys(sort).length ? sort : { _id: -1 };
|
|
28213
28289
|
const cacheParams = {
|
|
28214
28290
|
page,
|
|
28215
28291
|
limit,
|
|
28216
28292
|
sort: JSON.stringify(sort),
|
|
28217
|
-
...
|
|
28293
|
+
...searchText && { search: searchText },
|
|
28218
28294
|
...site && { site },
|
|
28219
28295
|
...status && { status }
|
|
28220
28296
|
};
|
|
@@ -29975,6 +30051,24 @@ function useBuildingUnitController() {
|
|
|
29975
30051
|
getAllLevelsWithUnits: _getAllLevelsWithUnits
|
|
29976
30052
|
} = useBuildingUnitRepo();
|
|
29977
30053
|
const { add: _add, updateById: _updateById } = useBuildingUnitService();
|
|
30054
|
+
function normalizeQueryString(value) {
|
|
30055
|
+
if (Array.isArray(value)) {
|
|
30056
|
+
for (const item of value) {
|
|
30057
|
+
const normalized = normalizeQueryString(item);
|
|
30058
|
+
if (normalized)
|
|
30059
|
+
return normalized;
|
|
30060
|
+
}
|
|
30061
|
+
return "";
|
|
30062
|
+
}
|
|
30063
|
+
if (value && typeof value === "object") {
|
|
30064
|
+
for (const item of Object.values(value)) {
|
|
30065
|
+
const normalized = normalizeQueryString(item);
|
|
30066
|
+
if (normalized)
|
|
30067
|
+
return normalized;
|
|
30068
|
+
}
|
|
30069
|
+
}
|
|
30070
|
+
return typeof value === "string" ? value : "";
|
|
30071
|
+
}
|
|
29978
30072
|
async function add(req, res, next) {
|
|
29979
30073
|
const data = req.body;
|
|
29980
30074
|
const validation = import_joi47.default.object({
|
|
@@ -30048,7 +30142,11 @@ function useBuildingUnitController() {
|
|
|
30048
30142
|
sort: import_joi47.default.string().valid(...Object.values(SortFields)).default("_id" /* ID */),
|
|
30049
30143
|
order: import_joi47.default.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */)
|
|
30050
30144
|
});
|
|
30051
|
-
const
|
|
30145
|
+
const query = {
|
|
30146
|
+
...req.query,
|
|
30147
|
+
search: normalizeQueryString(req.query.search)
|
|
30148
|
+
};
|
|
30149
|
+
const { error, value } = validation.validate(query, {
|
|
30052
30150
|
abortEarly: false
|
|
30053
30151
|
});
|
|
30054
30152
|
if (error) {
|
|
@@ -30209,7 +30307,11 @@ function useBuildingUnitController() {
|
|
|
30209
30307
|
order: import_joi47.default.string().valid(...Object.values(SortOrder)).default("asc" /* ASC */),
|
|
30210
30308
|
level: import_joi47.default.string().hex().length(24).optional().allow(null, "")
|
|
30211
30309
|
});
|
|
30212
|
-
const
|
|
30310
|
+
const query = {
|
|
30311
|
+
...req.query,
|
|
30312
|
+
search: normalizeQueryString(req.query.search)
|
|
30313
|
+
};
|
|
30314
|
+
const { error, value } = validation.validate(query, {
|
|
30213
30315
|
abortEarly: false
|
|
30214
30316
|
});
|
|
30215
30317
|
if (error) {
|
|
@@ -45266,6 +45368,31 @@ async function getTransactions(index, url) {
|
|
|
45266
45368
|
return Promise.reject(error);
|
|
45267
45369
|
}
|
|
45268
45370
|
}
|
|
45371
|
+
function encryptPayload(payloadHex) {
|
|
45372
|
+
const buffer = Buffer.from(payloadHex, "ascii");
|
|
45373
|
+
const encrypted = import_crypto.default.publicEncrypt(
|
|
45374
|
+
{
|
|
45375
|
+
key: "testing",
|
|
45376
|
+
padding: import_crypto.default.constants.RSA_PKCS1_PADDING
|
|
45377
|
+
},
|
|
45378
|
+
buffer
|
|
45379
|
+
);
|
|
45380
|
+
return encrypted.toString("base64");
|
|
45381
|
+
}
|
|
45382
|
+
function toHex(num, length) {
|
|
45383
|
+
return num.toString(16).padStart(length * 2, "0");
|
|
45384
|
+
}
|
|
45385
|
+
function buildPayload(cardNumber, validityMinutes) {
|
|
45386
|
+
const randomHex = import_crypto.default.randomBytes(2).toString("hex");
|
|
45387
|
+
const cardHex = toHex(cardNumber, 4);
|
|
45388
|
+
const epochHex = toHex(Math.floor(Date.now() / 1e3), 4);
|
|
45389
|
+
const validityHex = toHex(validityMinutes, 2);
|
|
45390
|
+
return randomHex + cardHex + epochHex + validityHex;
|
|
45391
|
+
}
|
|
45392
|
+
function generateQrCodeData(cardNumber, validityMinutes) {
|
|
45393
|
+
const payloadHex = buildPayload(cardNumber, validityMinutes);
|
|
45394
|
+
return encryptPayload(payloadHex);
|
|
45395
|
+
}
|
|
45269
45396
|
|
|
45270
45397
|
// src/repositories/access-management.repo.ts
|
|
45271
45398
|
var import_xml2js2 = require("xml2js");
|
|
@@ -48515,6 +48642,14 @@ function useAccessManagementSvc() {
|
|
|
48515
48642
|
throw new Error(err.message);
|
|
48516
48643
|
}
|
|
48517
48644
|
};
|
|
48645
|
+
const generateQrCodeWithExpirySvc = async ({ cardNumber, validityMinutes }) => {
|
|
48646
|
+
try {
|
|
48647
|
+
const response = generateQrCodeData(cardNumber, validityMinutes);
|
|
48648
|
+
return response;
|
|
48649
|
+
} catch (error) {
|
|
48650
|
+
throw new Error(error.message);
|
|
48651
|
+
}
|
|
48652
|
+
};
|
|
48518
48653
|
return {
|
|
48519
48654
|
addPhysicalCardSvc,
|
|
48520
48655
|
addNonPhysicalCardSvc,
|
|
@@ -48557,7 +48692,8 @@ function useAccessManagementSvc() {
|
|
|
48557
48692
|
getResidentsSvc,
|
|
48558
48693
|
userAccessCardsSvc,
|
|
48559
48694
|
removeTemplateSvc,
|
|
48560
|
-
qrCodeListSvc
|
|
48695
|
+
qrCodeListSvc,
|
|
48696
|
+
generateQrCodeWithExpirySvc
|
|
48561
48697
|
};
|
|
48562
48698
|
}
|
|
48563
48699
|
|
|
@@ -48605,7 +48741,8 @@ function useAccessManagementController() {
|
|
|
48605
48741
|
getResidentsSvc,
|
|
48606
48742
|
userAccessCardsSvc,
|
|
48607
48743
|
removeTemplateSvc,
|
|
48608
|
-
qrCodeListSvc
|
|
48744
|
+
qrCodeListSvc,
|
|
48745
|
+
generateQrCodeWithExpirySvc
|
|
48609
48746
|
} = useAccessManagementSvc();
|
|
48610
48747
|
const addPhysicalCard = async (req, res) => {
|
|
48611
48748
|
try {
|
|
@@ -49717,6 +49854,23 @@ function useAccessManagementController() {
|
|
|
49717
49854
|
});
|
|
49718
49855
|
}
|
|
49719
49856
|
};
|
|
49857
|
+
const generateQrCodeWithExpiry = async (req, res) => {
|
|
49858
|
+
try {
|
|
49859
|
+
const { cardNumber, validityMinutes } = req.body;
|
|
49860
|
+
const result = await generateQrCodeWithExpirySvc({ cardNumber, validityMinutes });
|
|
49861
|
+
return res.status(200).json({
|
|
49862
|
+
message: "successful!",
|
|
49863
|
+
data: {
|
|
49864
|
+
result
|
|
49865
|
+
}
|
|
49866
|
+
});
|
|
49867
|
+
} catch (error) {
|
|
49868
|
+
return res.status(400).json({
|
|
49869
|
+
data: null,
|
|
49870
|
+
message: error.message
|
|
49871
|
+
});
|
|
49872
|
+
}
|
|
49873
|
+
};
|
|
49720
49874
|
return {
|
|
49721
49875
|
addPhysicalCard,
|
|
49722
49876
|
addNonPhysicalCard,
|
|
@@ -49757,7 +49911,8 @@ function useAccessManagementController() {
|
|
|
49757
49911
|
getResidents,
|
|
49758
49912
|
userAccessCards,
|
|
49759
49913
|
removeTemplate,
|
|
49760
|
-
qrCodeList
|
|
49914
|
+
qrCodeList,
|
|
49915
|
+
generateQrCodeWithExpiry
|
|
49761
49916
|
};
|
|
49762
49917
|
}
|
|
49763
49918
|
|
|
@@ -57044,14 +57199,14 @@ function useNewDashboardRepo() {
|
|
|
57044
57199
|
site: { $in: [siteIdObj, siteId] },
|
|
57045
57200
|
service: "Security",
|
|
57046
57201
|
createdAt: periodRange,
|
|
57047
|
-
status: { $nin: ["
|
|
57202
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57048
57203
|
}
|
|
57049
57204
|
},
|
|
57050
57205
|
{
|
|
57051
57206
|
$facet: {
|
|
57052
57207
|
total: [{ $count: "count" }],
|
|
57053
57208
|
inProgress: [
|
|
57054
|
-
{ $match: { status: "
|
|
57209
|
+
{ $match: { status: "In-Progress" } },
|
|
57055
57210
|
{ $count: "count" }
|
|
57056
57211
|
]
|
|
57057
57212
|
}
|
|
@@ -57063,7 +57218,7 @@ function useNewDashboardRepo() {
|
|
|
57063
57218
|
site: { $in: [siteIdObj, siteId] },
|
|
57064
57219
|
service: "Security",
|
|
57065
57220
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd },
|
|
57066
|
-
status: { $nin: ["
|
|
57221
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57067
57222
|
}
|
|
57068
57223
|
},
|
|
57069
57224
|
{ $count: "count" }
|
|
@@ -57074,7 +57229,7 @@ function useNewDashboardRepo() {
|
|
|
57074
57229
|
site: { $in: [siteIdObj, siteId] },
|
|
57075
57230
|
service: "Security",
|
|
57076
57231
|
createdAt: { $gte: today, $lte: todayEnd },
|
|
57077
|
-
status: { $nin: ["
|
|
57232
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57078
57233
|
}
|
|
57079
57234
|
},
|
|
57080
57235
|
{ $count: "count" }
|
|
@@ -57083,7 +57238,7 @@ function useNewDashboardRepo() {
|
|
|
57083
57238
|
{
|
|
57084
57239
|
$match: {
|
|
57085
57240
|
site: { $in: [siteIdObj, siteId] },
|
|
57086
|
-
status: { $in: ["pending"
|
|
57241
|
+
status: { $in: ["pending"] },
|
|
57087
57242
|
createdAt: periodRange
|
|
57088
57243
|
}
|
|
57089
57244
|
},
|
|
@@ -57093,7 +57248,7 @@ function useNewDashboardRepo() {
|
|
|
57093
57248
|
{
|
|
57094
57249
|
$match: {
|
|
57095
57250
|
site: { $in: [siteIdObj, siteId] },
|
|
57096
|
-
status: { $in: ["pending"
|
|
57251
|
+
status: { $in: ["pending"] },
|
|
57097
57252
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd }
|
|
57098
57253
|
}
|
|
57099
57254
|
},
|
|
@@ -57103,7 +57258,7 @@ function useNewDashboardRepo() {
|
|
|
57103
57258
|
{
|
|
57104
57259
|
$match: {
|
|
57105
57260
|
site: { $in: [siteIdObj, siteId] },
|
|
57106
|
-
status: { $in: ["pending"
|
|
57261
|
+
status: { $in: ["pending"] },
|
|
57107
57262
|
createdAt: { $gte: today, $lte: todayEnd }
|
|
57108
57263
|
}
|
|
57109
57264
|
},
|
|
@@ -57385,11 +57540,11 @@ function useNewDashboardRepo() {
|
|
|
57385
57540
|
[
|
|
57386
57541
|
db.collection(incidents_namespace_collection).find({
|
|
57387
57542
|
site: { $in: [siteIdObj, siteId] },
|
|
57388
|
-
status: { $in: ["pending"
|
|
57543
|
+
status: { $in: ["pending"] }
|
|
57389
57544
|
}).sort({ createdAt: -1 }).toArray(),
|
|
57390
57545
|
db.collection(facility_bookings_namespace_collection2).find({
|
|
57391
57546
|
site: { $in: [siteIdObj, siteId] },
|
|
57392
|
-
status: { $in: ["Pending", "
|
|
57547
|
+
status: { $in: ["Pending", "For Review"] }
|
|
57393
57548
|
}).sort({ createdAt: -1 }).toArray()
|
|
57394
57549
|
]
|
|
57395
57550
|
);
|
|
@@ -57398,14 +57553,16 @@ function useNewDashboardRepo() {
|
|
|
57398
57553
|
const todayAttentions = [];
|
|
57399
57554
|
if (pendingIncidentCount > 0) {
|
|
57400
57555
|
todayAttentions.push({
|
|
57401
|
-
id:
|
|
57556
|
+
id: pendingIncidentDocs[0]._id.toString(),
|
|
57557
|
+
type: "incident",
|
|
57402
57558
|
title: `${pendingIncidentCount} incident${pendingIncidentCount === 1 ? "" : "s"} pending acknowledge`,
|
|
57403
57559
|
createdAt: pendingIncidentDocs[0].updatedAt || pendingIncidentDocs[0].createdAt || /* @__PURE__ */ new Date()
|
|
57404
57560
|
});
|
|
57405
57561
|
}
|
|
57406
57562
|
if (pendingFacilityBookingCount > 0) {
|
|
57407
57563
|
todayAttentions.push({
|
|
57408
|
-
id:
|
|
57564
|
+
id: pendingFacilityBookingDocs[0]._id.toString(),
|
|
57565
|
+
type: "facility-booking",
|
|
57409
57566
|
title: `${pendingFacilityBookingCount} facility booking${pendingFacilityBookingCount === 1 ? "" : "s"} need approval`,
|
|
57410
57567
|
createdAt: pendingFacilityBookingDocs[0].createdAt || /* @__PURE__ */ new Date()
|
|
57411
57568
|
});
|
|
@@ -57460,14 +57617,14 @@ function useNewDashboardRepo() {
|
|
|
57460
57617
|
$match: {
|
|
57461
57618
|
site: { $in: [siteIdObj, siteId] },
|
|
57462
57619
|
createdAt: periodRange,
|
|
57463
|
-
status: { $nin: ["
|
|
57620
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57464
57621
|
}
|
|
57465
57622
|
},
|
|
57466
57623
|
{
|
|
57467
57624
|
$facet: {
|
|
57468
57625
|
total: [{ $count: "count" }],
|
|
57469
57626
|
inProgress: [
|
|
57470
|
-
{ $match: { status: "
|
|
57627
|
+
{ $match: { status: "In-Progress" } },
|
|
57471
57628
|
{ $count: "count" }
|
|
57472
57629
|
]
|
|
57473
57630
|
}
|
|
@@ -57478,7 +57635,7 @@ function useNewDashboardRepo() {
|
|
|
57478
57635
|
$match: {
|
|
57479
57636
|
site: { $in: [siteIdObj, siteId] },
|
|
57480
57637
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd },
|
|
57481
|
-
status: { $nin: ["
|
|
57638
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57482
57639
|
}
|
|
57483
57640
|
},
|
|
57484
57641
|
{ $count: "count" }
|
|
@@ -57488,7 +57645,7 @@ function useNewDashboardRepo() {
|
|
|
57488
57645
|
$match: {
|
|
57489
57646
|
site: { $in: [siteIdObj, siteId] },
|
|
57490
57647
|
createdAt: { $gte: today, $lte: todayEnd },
|
|
57491
|
-
status: { $nin: ["
|
|
57648
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57492
57649
|
}
|
|
57493
57650
|
},
|
|
57494
57651
|
{ $count: "count" }
|
|
@@ -57497,7 +57654,7 @@ function useNewDashboardRepo() {
|
|
|
57497
57654
|
{
|
|
57498
57655
|
$match: {
|
|
57499
57656
|
site: { $in: [siteIdObj, siteId] },
|
|
57500
|
-
status: { $in: ["pending"
|
|
57657
|
+
status: { $in: ["pending"] },
|
|
57501
57658
|
createdAt: periodRange
|
|
57502
57659
|
}
|
|
57503
57660
|
},
|
|
@@ -57507,7 +57664,7 @@ function useNewDashboardRepo() {
|
|
|
57507
57664
|
{
|
|
57508
57665
|
$match: {
|
|
57509
57666
|
site: { $in: [siteIdObj, siteId] },
|
|
57510
|
-
status: { $in: ["pending"
|
|
57667
|
+
status: { $in: ["pending"] },
|
|
57511
57668
|
createdAt: { $gte: yesterday, $lte: yesterdayEnd }
|
|
57512
57669
|
}
|
|
57513
57670
|
},
|
|
@@ -57517,7 +57674,7 @@ function useNewDashboardRepo() {
|
|
|
57517
57674
|
{
|
|
57518
57675
|
$match: {
|
|
57519
57676
|
site: { $in: [siteIdObj, siteId] },
|
|
57520
|
-
status: { $in: ["pending"
|
|
57677
|
+
status: { $in: ["pending"] },
|
|
57521
57678
|
createdAt: { $gte: today, $lte: todayEnd }
|
|
57522
57679
|
}
|
|
57523
57680
|
},
|
|
@@ -57767,6 +57924,13 @@ function useNewDashboardRepo() {
|
|
|
57767
57924
|
const periodRange = getDateRange(period);
|
|
57768
57925
|
try {
|
|
57769
57926
|
const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
|
|
57927
|
+
const workOrderMatchQuery = {
|
|
57928
|
+
site,
|
|
57929
|
+
status: { $nin: ["Completed", "Deleted"] }
|
|
57930
|
+
};
|
|
57931
|
+
if (serviceType !== "property_management_agency") {
|
|
57932
|
+
workOrderMatchQuery.service = workOrderService;
|
|
57933
|
+
}
|
|
57770
57934
|
const [
|
|
57771
57935
|
workOrderReport,
|
|
57772
57936
|
supplyAlertReport,
|
|
@@ -57779,17 +57943,15 @@ function useNewDashboardRepo() {
|
|
|
57779
57943
|
workOrderCollection.aggregate([
|
|
57780
57944
|
{
|
|
57781
57945
|
$match: {
|
|
57782
|
-
|
|
57783
|
-
|
|
57784
|
-
createdAt: periodRange,
|
|
57785
|
-
status: { $nin: ["completed"] }
|
|
57946
|
+
...workOrderMatchQuery,
|
|
57947
|
+
createdAt: periodRange
|
|
57786
57948
|
}
|
|
57787
57949
|
},
|
|
57788
57950
|
{
|
|
57789
57951
|
$facet: {
|
|
57790
57952
|
total: [{ $count: "count" }],
|
|
57791
57953
|
inProgress: [
|
|
57792
|
-
{ $match: { status: "
|
|
57954
|
+
{ $match: { status: "In-Progress" } },
|
|
57793
57955
|
{ $count: "count" }
|
|
57794
57956
|
]
|
|
57795
57957
|
}
|
|
@@ -57820,10 +57982,8 @@ function useNewDashboardRepo() {
|
|
|
57820
57982
|
workOrderCollection.aggregate([
|
|
57821
57983
|
{
|
|
57822
57984
|
$match: {
|
|
57823
|
-
|
|
57824
|
-
|
|
57825
|
-
createdAt: { $gte: yesterday, $lte: yesterdayEnd },
|
|
57826
|
-
status: { $nin: ["completed"] }
|
|
57985
|
+
...workOrderMatchQuery,
|
|
57986
|
+
createdAt: { $gte: yesterday, $lte: yesterdayEnd }
|
|
57827
57987
|
}
|
|
57828
57988
|
},
|
|
57829
57989
|
{ $count: "count" }
|
|
@@ -57831,10 +57991,8 @@ function useNewDashboardRepo() {
|
|
|
57831
57991
|
workOrderCollection.aggregate([
|
|
57832
57992
|
{
|
|
57833
57993
|
$match: {
|
|
57834
|
-
|
|
57835
|
-
|
|
57836
|
-
createdAt: { $gte: today, $lte: todayEnd },
|
|
57837
|
-
status: { $nin: ["completed"] }
|
|
57994
|
+
...workOrderMatchQuery,
|
|
57995
|
+
createdAt: { $gte: today, $lte: todayEnd }
|
|
57838
57996
|
}
|
|
57839
57997
|
},
|
|
57840
57998
|
{ $count: "count" }
|
|
@@ -57937,10 +58095,9 @@ function useNewDashboardRepo() {
|
|
|
57937
58095
|
throw new import_node_server_utils199.BadRequestError("Invalid period.");
|
|
57938
58096
|
}
|
|
57939
58097
|
try {
|
|
57940
|
-
const
|
|
58098
|
+
const workOrderQuery = {
|
|
57941
58099
|
site,
|
|
57942
|
-
|
|
57943
|
-
status: { $nin: ["deleted", "Deleted"] },
|
|
58100
|
+
status: { $nin: ["Deleted"] },
|
|
57944
58101
|
$or: [
|
|
57945
58102
|
{ createdAt: { $gte: rangeStart, $lte: rangeEnd } },
|
|
57946
58103
|
{
|
|
@@ -57950,7 +58107,11 @@ function useNewDashboardRepo() {
|
|
|
57950
58107
|
}
|
|
57951
58108
|
}
|
|
57952
58109
|
]
|
|
57953
|
-
}
|
|
58110
|
+
};
|
|
58111
|
+
if (serviceType !== "property_management_agency") {
|
|
58112
|
+
workOrderQuery.service = workOrderService;
|
|
58113
|
+
}
|
|
58114
|
+
const workOrders = await workOrderCollection.find(workOrderQuery).project({ status: 1, createdAt: 1 }).toArray();
|
|
57954
58115
|
const chartData = labels.map((label) => ({
|
|
57955
58116
|
day: label,
|
|
57956
58117
|
label,
|
|
@@ -58047,6 +58208,7 @@ function useNewDashboardRepo() {
|
|
|
58047
58208
|
name: 1,
|
|
58048
58209
|
type: 1,
|
|
58049
58210
|
status: 1,
|
|
58211
|
+
schedule: 1,
|
|
58050
58212
|
assigneeName: { $arrayElemAt: ["$_assigneeDoc.name", 0] }
|
|
58051
58213
|
}
|
|
58052
58214
|
},
|
|
@@ -58211,7 +58373,10 @@ function useNewDashboardRepo() {
|
|
|
58211
58373
|
throw new import_node_server_utils199.BadRequestError("Invalid site ID format.");
|
|
58212
58374
|
}
|
|
58213
58375
|
const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
|
|
58214
|
-
const matchQuery = { site
|
|
58376
|
+
const matchQuery = { site };
|
|
58377
|
+
if (serviceType !== "property_management_agency") {
|
|
58378
|
+
matchQuery.service = workOrderService;
|
|
58379
|
+
}
|
|
58215
58380
|
if (period) {
|
|
58216
58381
|
matchQuery.createdAt = getDateRange(period);
|
|
58217
58382
|
}
|
|
@@ -65428,7 +65593,7 @@ function usePostFavoriteService() {
|
|
|
65428
65593
|
});
|
|
65429
65594
|
}
|
|
65430
65595
|
await session?.commitTransaction();
|
|
65431
|
-
return "Successfully added to
|
|
65596
|
+
return "Successfully added to post-preloved.";
|
|
65432
65597
|
} catch (error) {
|
|
65433
65598
|
await session?.abortTransaction();
|
|
65434
65599
|
throw error;
|
|
@@ -66821,9 +66986,112 @@ function useChatPrelovedController() {
|
|
|
66821
66986
|
return { add, updateById, deleteById };
|
|
66822
66987
|
}
|
|
66823
66988
|
|
|
66824
|
-
// src/
|
|
66825
|
-
var import_node_server_utils249 = require("@7365admin1/node-server-utils");
|
|
66989
|
+
// src/events/chat-preloved.event.ts
|
|
66826
66990
|
var import_joi144 = __toESM(require("joi"));
|
|
66991
|
+
var import_node_server_utils249 = require("@7365admin1/node-server-utils");
|
|
66992
|
+
function parseSid(cookieHeader) {
|
|
66993
|
+
const match = cookieHeader.match(/(?:^|;\s*)sid=([^;]*)/);
|
|
66994
|
+
return match ? decodeURIComponent(match[1]) : null;
|
|
66995
|
+
}
|
|
66996
|
+
var schemaSendMessage = import_joi144.default.object({
|
|
66997
|
+
receiverId: import_joi144.default.string().hex().length(24).required(),
|
|
66998
|
+
channelId: import_joi144.default.string().hex().length(24).optional().allow("", null),
|
|
66999
|
+
senderId: import_joi144.default.string().hex().length(24).required(),
|
|
67000
|
+
postId: import_joi144.default.string().hex().length(24).optional().allow("", null),
|
|
67001
|
+
message: import_joi144.default.object({
|
|
67002
|
+
text: import_joi144.default.string().required(),
|
|
67003
|
+
date: import_joi144.default.date().optional().allow(null),
|
|
67004
|
+
time: import_joi144.default.string().optional().allow("", null),
|
|
67005
|
+
senderId: import_joi144.default.string().hex().length(24).required()
|
|
67006
|
+
}).required(),
|
|
67007
|
+
readMessage: import_joi144.default.array().items(import_joi144.default.string().hex()).optional().default([]),
|
|
67008
|
+
viewMessage: import_joi144.default.array().items(import_joi144.default.string().hex()).optional().default([]),
|
|
67009
|
+
attachments: import_joi144.default.array().items(import_joi144.default.string().hex()).optional().default([]),
|
|
67010
|
+
reactions: import_joi144.default.string().optional().allow("", null).default(""),
|
|
67011
|
+
bidId: import_joi144.default.string().hex().length(24).optional().allow("", null),
|
|
67012
|
+
edited: import_joi144.default.boolean().optional().default(false)
|
|
67013
|
+
});
|
|
67014
|
+
var schemaTyping = import_joi144.default.object({
|
|
67015
|
+
receiverId: import_joi144.default.string().hex().length(24).required(),
|
|
67016
|
+
fromUserId: import_joi144.default.string().hex().length(24).required(),
|
|
67017
|
+
senderName: import_joi144.default.string().required()
|
|
67018
|
+
});
|
|
67019
|
+
var schemaChatMessageDeleted = import_joi144.default.object({
|
|
67020
|
+
messageId: import_joi144.default.string().hex().length(24).required(),
|
|
67021
|
+
receiverId: import_joi144.default.string().hex().length(24).required()
|
|
67022
|
+
});
|
|
67023
|
+
function chatPrelovedEvents(io) {
|
|
67024
|
+
const namespace = io.of(/^\/chat-channel-[0-9a-fA-F]{24}$/);
|
|
67025
|
+
namespace.use(async (socket, next) => {
|
|
67026
|
+
try {
|
|
67027
|
+
const cookieHeader = socket.handshake.headers.cookie || "";
|
|
67028
|
+
let sid = parseSid(cookieHeader);
|
|
67029
|
+
if (!sid && socket.handshake.auth?.token) {
|
|
67030
|
+
sid = socket.handshake.auth.token;
|
|
67031
|
+
}
|
|
67032
|
+
if (!sid) {
|
|
67033
|
+
return next(new Error("Unauthorized"));
|
|
67034
|
+
}
|
|
67035
|
+
const { getCache } = (0, import_node_server_utils249.useCache)("sessions");
|
|
67036
|
+
const sessionData = await getCache(`sid:${sid}`);
|
|
67037
|
+
if (!sessionData) {
|
|
67038
|
+
return next(new Error("Session expired or invalid"));
|
|
67039
|
+
}
|
|
67040
|
+
const session = sessionData;
|
|
67041
|
+
socket.data.userId = (session._id ?? sessionData).toString();
|
|
67042
|
+
next();
|
|
67043
|
+
} catch (error) {
|
|
67044
|
+
import_node_server_utils249.logger.log({ level: "error", message: `Socket auth error: ${error.message}` });
|
|
67045
|
+
next(new Error("Authentication error"));
|
|
67046
|
+
}
|
|
67047
|
+
});
|
|
67048
|
+
namespace.on("connection", (socket) => {
|
|
67049
|
+
const userId = socket.data.userId;
|
|
67050
|
+
socket.join(userId);
|
|
67051
|
+
socket.on("sendMessage", (payload) => {
|
|
67052
|
+
const { error, value } = schemaSendMessage.validate(payload, {
|
|
67053
|
+
abortEarly: false
|
|
67054
|
+
});
|
|
67055
|
+
if (error) {
|
|
67056
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
67057
|
+
socket.emit("error", { event: "sendMessage", message });
|
|
67058
|
+
return;
|
|
67059
|
+
}
|
|
67060
|
+
namespace.to(value.receiverId).emit("receiveMessage", value);
|
|
67061
|
+
});
|
|
67062
|
+
socket.on("typing", (data) => {
|
|
67063
|
+
const { error, value } = schemaTyping.validate(data, {
|
|
67064
|
+
abortEarly: false
|
|
67065
|
+
});
|
|
67066
|
+
if (error) {
|
|
67067
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
67068
|
+
socket.emit("error", { event: "typing", message });
|
|
67069
|
+
return;
|
|
67070
|
+
}
|
|
67071
|
+
namespace.to(value.receiverId).emit("TypingNow", value);
|
|
67072
|
+
});
|
|
67073
|
+
socket.on("chatMessageDeleted", (data) => {
|
|
67074
|
+
const { error, value } = schemaChatMessageDeleted.validate(data, {
|
|
67075
|
+
abortEarly: false
|
|
67076
|
+
});
|
|
67077
|
+
if (error) {
|
|
67078
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
67079
|
+
socket.emit("error", { event: "chatMessageDeleted", message });
|
|
67080
|
+
return;
|
|
67081
|
+
}
|
|
67082
|
+
namespace.to(value.receiverId).emit("chatMessageDeleted", {
|
|
67083
|
+
messageId: value.messageId
|
|
67084
|
+
});
|
|
67085
|
+
});
|
|
67086
|
+
socket.on("disconnect", () => {
|
|
67087
|
+
socket.leave(userId);
|
|
67088
|
+
});
|
|
67089
|
+
});
|
|
67090
|
+
}
|
|
67091
|
+
|
|
67092
|
+
// src/controllers/channel-preloved.controller.ts
|
|
67093
|
+
var import_node_server_utils250 = require("@7365admin1/node-server-utils");
|
|
67094
|
+
var import_joi145 = __toESM(require("joi"));
|
|
66827
67095
|
function useChannelPrelovedController() {
|
|
66828
67096
|
const {
|
|
66829
67097
|
add: _add,
|
|
@@ -66837,40 +67105,40 @@ function useChannelPrelovedController() {
|
|
|
66837
67105
|
});
|
|
66838
67106
|
if (error) {
|
|
66839
67107
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
66840
|
-
|
|
66841
|
-
next(new
|
|
67108
|
+
import_node_server_utils250.logger.log({ level: "error", message: messages });
|
|
67109
|
+
next(new import_node_server_utils250.BadRequestError(messages));
|
|
66842
67110
|
return;
|
|
66843
67111
|
}
|
|
66844
67112
|
try {
|
|
66845
67113
|
const data = await _add(value);
|
|
66846
67114
|
res.status(201).json(data);
|
|
66847
67115
|
} catch (error2) {
|
|
66848
|
-
|
|
67116
|
+
import_node_server_utils250.logger.log({ level: "error", message: error2.message });
|
|
66849
67117
|
next(error2);
|
|
66850
67118
|
}
|
|
66851
67119
|
}
|
|
66852
67120
|
async function getChannelMessages(req, res, next) {
|
|
66853
|
-
const paramsSchema =
|
|
66854
|
-
id:
|
|
67121
|
+
const paramsSchema = import_joi145.default.object({
|
|
67122
|
+
id: import_joi145.default.string().hex().length(24).required()
|
|
66855
67123
|
});
|
|
66856
|
-
const querySchema =
|
|
66857
|
-
page:
|
|
66858
|
-
limit:
|
|
66859
|
-
isLoadMore:
|
|
66860
|
-
lastMessageId:
|
|
67124
|
+
const querySchema = import_joi145.default.object({
|
|
67125
|
+
page: import_joi145.default.number().integer().min(1).default(1),
|
|
67126
|
+
limit: import_joi145.default.number().integer().min(1).max(100).default(10),
|
|
67127
|
+
isLoadMore: import_joi145.default.boolean().default(false),
|
|
67128
|
+
lastMessageId: import_joi145.default.string().hex().length(24).optional().allow("", null)
|
|
66861
67129
|
});
|
|
66862
67130
|
const { error: paramError, value: params } = paramsSchema.validate(
|
|
66863
67131
|
req.params
|
|
66864
67132
|
);
|
|
66865
67133
|
if (paramError) {
|
|
66866
|
-
|
|
66867
|
-
next(new
|
|
67134
|
+
import_node_server_utils250.logger.log({ level: "error", message: paramError.message });
|
|
67135
|
+
next(new import_node_server_utils250.BadRequestError(paramError.message));
|
|
66868
67136
|
return;
|
|
66869
67137
|
}
|
|
66870
67138
|
const { error: queryError, value: query } = querySchema.validate(req.query);
|
|
66871
67139
|
if (queryError) {
|
|
66872
|
-
|
|
66873
|
-
next(new
|
|
67140
|
+
import_node_server_utils250.logger.log({ level: "error", message: queryError.message });
|
|
67141
|
+
next(new import_node_server_utils250.BadRequestError(queryError.message));
|
|
66874
67142
|
return;
|
|
66875
67143
|
}
|
|
66876
67144
|
try {
|
|
@@ -66883,20 +67151,20 @@ function useChannelPrelovedController() {
|
|
|
66883
67151
|
);
|
|
66884
67152
|
res.status(200).json(data);
|
|
66885
67153
|
} catch (error) {
|
|
66886
|
-
|
|
67154
|
+
import_node_server_utils250.logger.log({ level: "error", message: error.message });
|
|
66887
67155
|
next(error);
|
|
66888
67156
|
}
|
|
66889
67157
|
}
|
|
66890
67158
|
async function getChannel(req, res, next) {
|
|
66891
|
-
const querySchema =
|
|
66892
|
-
postId:
|
|
66893
|
-
receiverId:
|
|
66894
|
-
senderId:
|
|
67159
|
+
const querySchema = import_joi145.default.object({
|
|
67160
|
+
postId: import_joi145.default.string().hex().length(24).required(),
|
|
67161
|
+
receiverId: import_joi145.default.string().hex().length(24).required(),
|
|
67162
|
+
senderId: import_joi145.default.string().hex().length(24).required()
|
|
66895
67163
|
});
|
|
66896
67164
|
const { error, value } = querySchema.validate(req.query);
|
|
66897
67165
|
if (error) {
|
|
66898
|
-
|
|
66899
|
-
next(new
|
|
67166
|
+
import_node_server_utils250.logger.log({ level: "error", message: error.message });
|
|
67167
|
+
next(new import_node_server_utils250.BadRequestError(error.message));
|
|
66900
67168
|
return;
|
|
66901
67169
|
}
|
|
66902
67170
|
try {
|
|
@@ -66907,21 +67175,21 @@ function useChannelPrelovedController() {
|
|
|
66907
67175
|
);
|
|
66908
67176
|
res.status(200).json(data);
|
|
66909
67177
|
} catch (error2) {
|
|
66910
|
-
|
|
67178
|
+
import_node_server_utils250.logger.log({ level: "error", message: error2.message });
|
|
66911
67179
|
next(error2);
|
|
66912
67180
|
}
|
|
66913
67181
|
}
|
|
66914
67182
|
async function getChatLists(req, res, next) {
|
|
66915
|
-
const querySchema =
|
|
66916
|
-
currentUserId:
|
|
66917
|
-
page:
|
|
66918
|
-
limit:
|
|
66919
|
-
search:
|
|
67183
|
+
const querySchema = import_joi145.default.object({
|
|
67184
|
+
currentUserId: import_joi145.default.string().hex().length(24).required(),
|
|
67185
|
+
page: import_joi145.default.number().integer().min(1).default(1),
|
|
67186
|
+
limit: import_joi145.default.number().integer().min(1).max(100).default(10),
|
|
67187
|
+
search: import_joi145.default.string().optional().allow("", null)
|
|
66920
67188
|
});
|
|
66921
67189
|
const { error, value } = querySchema.validate(req.query);
|
|
66922
67190
|
if (error) {
|
|
66923
|
-
|
|
66924
|
-
next(new
|
|
67191
|
+
import_node_server_utils250.logger.log({ level: "error", message: error.message });
|
|
67192
|
+
next(new import_node_server_utils250.BadRequestError(error.message));
|
|
66925
67193
|
return;
|
|
66926
67194
|
}
|
|
66927
67195
|
try {
|
|
@@ -66933,7 +67201,7 @@ function useChannelPrelovedController() {
|
|
|
66933
67201
|
);
|
|
66934
67202
|
res.status(200).json(data);
|
|
66935
67203
|
} catch (error2) {
|
|
66936
|
-
|
|
67204
|
+
import_node_server_utils250.logger.log({ level: "error", message: error2.message });
|
|
66937
67205
|
next(error2);
|
|
66938
67206
|
}
|
|
66939
67207
|
}
|
|
@@ -66941,7 +67209,7 @@ function useChannelPrelovedController() {
|
|
|
66941
67209
|
}
|
|
66942
67210
|
|
|
66943
67211
|
// src/models/bid-preloved.model.ts
|
|
66944
|
-
var
|
|
67212
|
+
var import_joi146 = __toESM(require("joi"));
|
|
66945
67213
|
var import_mongodb149 = require("mongodb");
|
|
66946
67214
|
var BidType = /* @__PURE__ */ ((BidType2) => {
|
|
66947
67215
|
BidType2["BID"] = "bid";
|
|
@@ -66955,21 +67223,21 @@ var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
|
|
|
66955
67223
|
BidStatus3["CANCELLED"] = "cancelled";
|
|
66956
67224
|
return BidStatus3;
|
|
66957
67225
|
})(BidStatus || {});
|
|
66958
|
-
var schemaBidPreloved =
|
|
66959
|
-
type:
|
|
66960
|
-
postId:
|
|
66961
|
-
receiverId:
|
|
66962
|
-
buyerId:
|
|
66963
|
-
price:
|
|
67226
|
+
var schemaBidPreloved = import_joi146.default.object({
|
|
67227
|
+
type: import_joi146.default.string().valid(...Object.values(BidType)).required(),
|
|
67228
|
+
postId: import_joi146.default.string().hex().length(24).required(),
|
|
67229
|
+
receiverId: import_joi146.default.string().hex().length(24).required(),
|
|
67230
|
+
buyerId: import_joi146.default.string().hex().length(24).required(),
|
|
67231
|
+
price: import_joi146.default.when("type", {
|
|
66964
67232
|
is: "bid" /* BID */,
|
|
66965
|
-
then:
|
|
66966
|
-
otherwise:
|
|
67233
|
+
then: import_joi146.default.number().required(),
|
|
67234
|
+
otherwise: import_joi146.default.number().optional().allow(null)
|
|
66967
67235
|
}),
|
|
66968
|
-
message:
|
|
66969
|
-
status:
|
|
67236
|
+
message: import_joi146.default.string().optional().allow("", null),
|
|
67237
|
+
status: import_joi146.default.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
|
|
66970
67238
|
});
|
|
66971
|
-
var schemaUpdateBidPreloved =
|
|
66972
|
-
status:
|
|
67239
|
+
var schemaUpdateBidPreloved = import_joi146.default.object({
|
|
67240
|
+
status: import_joi146.default.string().valid(...Object.values(BidStatus)).required()
|
|
66973
67241
|
});
|
|
66974
67242
|
function MBidPreloved(value) {
|
|
66975
67243
|
const { error } = schemaBidPreloved.validate(value);
|
|
@@ -66993,12 +67261,12 @@ function MBidPreloved(value) {
|
|
|
66993
67261
|
}
|
|
66994
67262
|
|
|
66995
67263
|
// src/repositories/bid-preloved.repo.ts
|
|
66996
|
-
var
|
|
67264
|
+
var import_node_server_utils251 = require("@7365admin1/node-server-utils");
|
|
66997
67265
|
var import_mongodb150 = require("mongodb");
|
|
66998
67266
|
function useBidPrelovedRepo() {
|
|
66999
|
-
const db =
|
|
67267
|
+
const db = import_node_server_utils251.useAtlas.getDb();
|
|
67000
67268
|
if (!db)
|
|
67001
|
-
throw new
|
|
67269
|
+
throw new import_node_server_utils251.InternalServerError("Unable to connect to server.");
|
|
67002
67270
|
const collection = db.collection("bid-preloved");
|
|
67003
67271
|
async function add(value, session) {
|
|
67004
67272
|
try {
|
|
@@ -67013,13 +67281,13 @@ function useBidPrelovedRepo() {
|
|
|
67013
67281
|
const objectId2 = typeof _id === "string" ? new import_mongodb150.ObjectId(_id) : _id;
|
|
67014
67282
|
const existing = await collection.findOne({ _id: objectId2 });
|
|
67015
67283
|
if (!existing)
|
|
67016
|
-
throw new
|
|
67284
|
+
throw new import_node_server_utils251.NotFoundError("Bid not found.");
|
|
67017
67285
|
const res = await collection.updateOne(
|
|
67018
67286
|
{ _id: objectId2 },
|
|
67019
67287
|
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
67020
67288
|
);
|
|
67021
67289
|
if (res.modifiedCount === 0)
|
|
67022
|
-
throw new
|
|
67290
|
+
throw new import_node_server_utils251.InternalServerError("Unable to update bid.");
|
|
67023
67291
|
return "Bid updated successfully.";
|
|
67024
67292
|
}
|
|
67025
67293
|
async function getById(_id) {
|
|
@@ -67027,26 +67295,22 @@ function useBidPrelovedRepo() {
|
|
|
67027
67295
|
_id = new import_mongodb150.ObjectId(_id);
|
|
67028
67296
|
const result = await collection.findOne({ _id });
|
|
67029
67297
|
if (!result)
|
|
67030
|
-
throw new
|
|
67298
|
+
throw new import_node_server_utils251.NotFoundError("Bid not found.");
|
|
67031
67299
|
return result;
|
|
67032
67300
|
}
|
|
67033
67301
|
return { add, getById, updateStatus };
|
|
67034
67302
|
}
|
|
67035
67303
|
|
|
67036
|
-
// src/controllers/bid-preloved.controller.ts
|
|
67037
|
-
var import_node_server_utils252 = require("@7365admin1/node-server-utils");
|
|
67038
|
-
var import_joi146 = __toESM(require("joi"));
|
|
67039
|
-
|
|
67040
67304
|
// src/services/bid-preloved.service.ts
|
|
67041
|
-
var
|
|
67305
|
+
var import_node_server_utils252 = require("@7365admin1/node-server-utils");
|
|
67042
67306
|
function useBidPrelovedService() {
|
|
67043
67307
|
const { add: _addBid } = useBidPrelovedRepo();
|
|
67044
67308
|
const { add: _addChannel, getByParticipants: _getByParticipants } = useChannelPrelovedRepo();
|
|
67045
67309
|
const { add: _addChat } = useChatPrelovedRepo();
|
|
67046
67310
|
async function createBid(value) {
|
|
67047
|
-
const client =
|
|
67311
|
+
const client = import_node_server_utils252.useAtlas.getClient();
|
|
67048
67312
|
if (!client)
|
|
67049
|
-
throw new
|
|
67313
|
+
throw new import_node_server_utils252.InternalServerError("Unable to connect to server.");
|
|
67050
67314
|
const buyerId = value.buyerId;
|
|
67051
67315
|
const receiverId = value.receiverId;
|
|
67052
67316
|
const postId = value.postId;
|
|
@@ -67101,6 +67365,8 @@ function useBidPrelovedService() {
|
|
|
67101
67365
|
}
|
|
67102
67366
|
|
|
67103
67367
|
// src/controllers/bid-preloved.controller.ts
|
|
67368
|
+
var import_node_server_utils253 = require("@7365admin1/node-server-utils");
|
|
67369
|
+
var import_joi147 = __toESM(require("joi"));
|
|
67104
67370
|
function useBidPrelovedController() {
|
|
67105
67371
|
const { createBid: _createBid } = useBidPrelovedService();
|
|
67106
67372
|
const { getById: _getById, updateStatus: _updateStatus } = useBidPrelovedRepo();
|
|
@@ -67110,8 +67376,8 @@ function useBidPrelovedController() {
|
|
|
67110
67376
|
});
|
|
67111
67377
|
if (error) {
|
|
67112
67378
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67113
|
-
|
|
67114
|
-
next(new
|
|
67379
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67380
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67115
67381
|
return;
|
|
67116
67382
|
}
|
|
67117
67383
|
try {
|
|
@@ -67119,53 +67385,53 @@ function useBidPrelovedController() {
|
|
|
67119
67385
|
res.status(201).json(data);
|
|
67120
67386
|
} catch (error2) {
|
|
67121
67387
|
console.log("error", error2);
|
|
67122
|
-
|
|
67388
|
+
import_node_server_utils253.logger.log({ level: "error", message: error2.message });
|
|
67123
67389
|
next(error2);
|
|
67124
67390
|
}
|
|
67125
67391
|
}
|
|
67126
67392
|
async function updateStatus(req, res, next) {
|
|
67127
|
-
const paramsSchema =
|
|
67128
|
-
id:
|
|
67393
|
+
const paramsSchema = import_joi147.default.object({
|
|
67394
|
+
id: import_joi147.default.string().hex().length(24).required()
|
|
67129
67395
|
});
|
|
67130
67396
|
const { error: paramError, value: params } = paramsSchema.validate(
|
|
67131
67397
|
req.params
|
|
67132
67398
|
);
|
|
67133
67399
|
if (paramError) {
|
|
67134
|
-
|
|
67135
|
-
next(new
|
|
67400
|
+
import_node_server_utils253.logger.log({ level: "error", message: paramError.message });
|
|
67401
|
+
next(new import_node_server_utils253.BadRequestError(paramError.message));
|
|
67136
67402
|
return;
|
|
67137
67403
|
}
|
|
67138
67404
|
const { error: bodyError, value: body } = schemaUpdateBidPreloved.validate(
|
|
67139
67405
|
req.body
|
|
67140
67406
|
);
|
|
67141
67407
|
if (bodyError) {
|
|
67142
|
-
|
|
67143
|
-
next(new
|
|
67408
|
+
import_node_server_utils253.logger.log({ level: "error", message: bodyError.message });
|
|
67409
|
+
next(new import_node_server_utils253.BadRequestError(bodyError.message));
|
|
67144
67410
|
return;
|
|
67145
67411
|
}
|
|
67146
67412
|
try {
|
|
67147
67413
|
const data = await _updateStatus(params.id, body.status);
|
|
67148
67414
|
res.status(200).json(data);
|
|
67149
67415
|
} catch (error) {
|
|
67150
|
-
|
|
67416
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67151
67417
|
next(error);
|
|
67152
67418
|
}
|
|
67153
67419
|
}
|
|
67154
67420
|
async function getById(req, res, next) {
|
|
67155
|
-
const paramsSchema =
|
|
67156
|
-
id:
|
|
67421
|
+
const paramsSchema = import_joi147.default.object({
|
|
67422
|
+
id: import_joi147.default.string().hex().length(24).required()
|
|
67157
67423
|
});
|
|
67158
67424
|
const { error, value: params } = paramsSchema.validate(req.params);
|
|
67159
67425
|
if (error) {
|
|
67160
|
-
|
|
67161
|
-
next(new
|
|
67426
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67427
|
+
next(new import_node_server_utils253.BadRequestError(error.message));
|
|
67162
67428
|
return;
|
|
67163
67429
|
}
|
|
67164
67430
|
try {
|
|
67165
67431
|
const data = await _getById(params.id);
|
|
67166
67432
|
res.status(200).json(data);
|
|
67167
67433
|
} catch (error2) {
|
|
67168
|
-
|
|
67434
|
+
import_node_server_utils253.logger.log({ level: "error", message: error2.message });
|
|
67169
67435
|
next(error2);
|
|
67170
67436
|
}
|
|
67171
67437
|
}
|
|
@@ -67173,7 +67439,7 @@ function useBidPrelovedController() {
|
|
|
67173
67439
|
}
|
|
67174
67440
|
|
|
67175
67441
|
// src/models/online-forms-v2.model.ts
|
|
67176
|
-
var
|
|
67442
|
+
var import_joi148 = __toESM(require("joi"));
|
|
67177
67443
|
var import_mongodb151 = require("mongodb");
|
|
67178
67444
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
67179
67445
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
@@ -67181,49 +67447,49 @@ var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
|
67181
67447
|
FormEntryStatus2["DELETED"] = "deleted";
|
|
67182
67448
|
return FormEntryStatus2;
|
|
67183
67449
|
})(FormEntryStatus || {});
|
|
67184
|
-
var schemaFormEntry =
|
|
67185
|
-
_id:
|
|
67186
|
-
formType:
|
|
67187
|
-
block:
|
|
67188
|
-
level:
|
|
67189
|
-
unit:
|
|
67190
|
-
name:
|
|
67191
|
-
phoneNumber:
|
|
67192
|
-
createdBy:
|
|
67193
|
-
fields:
|
|
67194
|
-
|
|
67195
|
-
|
|
67196
|
-
|
|
67197
|
-
|
|
67198
|
-
|
|
67199
|
-
|
|
67450
|
+
var schemaFormEntry = import_joi148.default.object({
|
|
67451
|
+
_id: import_joi148.default.string().hex().optional().allow("", null),
|
|
67452
|
+
formType: import_joi148.default.string().required(),
|
|
67453
|
+
block: import_joi148.default.string().optional().allow(null, ""),
|
|
67454
|
+
level: import_joi148.default.string().optional().allow(null, ""),
|
|
67455
|
+
unit: import_joi148.default.string().optional().allow(null, ""),
|
|
67456
|
+
name: import_joi148.default.string().optional().allow(null, ""),
|
|
67457
|
+
phoneNumber: import_joi148.default.string().optional().allow(null, ""),
|
|
67458
|
+
createdBy: import_joi148.default.string().required(),
|
|
67459
|
+
fields: import_joi148.default.object().pattern(
|
|
67460
|
+
import_joi148.default.string(),
|
|
67461
|
+
import_joi148.default.alternatives().try(
|
|
67462
|
+
import_joi148.default.string(),
|
|
67463
|
+
import_joi148.default.number(),
|
|
67464
|
+
import_joi148.default.boolean(),
|
|
67465
|
+
import_joi148.default.valid(null)
|
|
67200
67466
|
)
|
|
67201
67467
|
).required(),
|
|
67202
|
-
status:
|
|
67203
|
-
org:
|
|
67204
|
-
site:
|
|
67205
|
-
createdAt:
|
|
67206
|
-
updatedAt:
|
|
67207
|
-
deletedAt:
|
|
67468
|
+
status: import_joi148.default.string().optional().allow("", null),
|
|
67469
|
+
org: import_joi148.default.string().hex().optional().allow("", null),
|
|
67470
|
+
site: import_joi148.default.string().hex().optional().allow("", null),
|
|
67471
|
+
createdAt: import_joi148.default.date().optional().allow("", null),
|
|
67472
|
+
updatedAt: import_joi148.default.date().optional().allow("", null),
|
|
67473
|
+
deletedAt: import_joi148.default.date().optional().allow("", null)
|
|
67208
67474
|
});
|
|
67209
|
-
var schemaUpdateFormEntry =
|
|
67210
|
-
_id:
|
|
67211
|
-
formType:
|
|
67212
|
-
block:
|
|
67213
|
-
level:
|
|
67214
|
-
unit:
|
|
67215
|
-
fields:
|
|
67216
|
-
|
|
67217
|
-
|
|
67218
|
-
|
|
67219
|
-
|
|
67220
|
-
|
|
67221
|
-
|
|
67475
|
+
var schemaUpdateFormEntry = import_joi148.default.object({
|
|
67476
|
+
_id: import_joi148.default.string().hex().required(),
|
|
67477
|
+
formType: import_joi148.default.string().optional().allow("", null),
|
|
67478
|
+
block: import_joi148.default.string().optional().allow(null, ""),
|
|
67479
|
+
level: import_joi148.default.string().optional().allow(null, ""),
|
|
67480
|
+
unit: import_joi148.default.string().optional().allow(null, ""),
|
|
67481
|
+
fields: import_joi148.default.object().pattern(
|
|
67482
|
+
import_joi148.default.string(),
|
|
67483
|
+
import_joi148.default.alternatives().try(
|
|
67484
|
+
import_joi148.default.string(),
|
|
67485
|
+
import_joi148.default.number(),
|
|
67486
|
+
import_joi148.default.boolean(),
|
|
67487
|
+
import_joi148.default.valid(null)
|
|
67222
67488
|
)
|
|
67223
67489
|
).optional(),
|
|
67224
|
-
status:
|
|
67225
|
-
updatedAt:
|
|
67226
|
-
deletedAt:
|
|
67490
|
+
status: import_joi148.default.string().optional().allow("", null),
|
|
67491
|
+
updatedAt: import_joi148.default.date().optional().allow("", null),
|
|
67492
|
+
deletedAt: import_joi148.default.date().optional().allow("", null)
|
|
67227
67493
|
});
|
|
67228
67494
|
function MFormEntry(value) {
|
|
67229
67495
|
const { error } = schemaFormEntry.validate(value);
|
|
@@ -67268,49 +67534,49 @@ function MFormEntry(value) {
|
|
|
67268
67534
|
deletedAt: value.deletedAt ?? null
|
|
67269
67535
|
};
|
|
67270
67536
|
}
|
|
67271
|
-
var residentFormEntry =
|
|
67272
|
-
_id:
|
|
67273
|
-
typeOfForm:
|
|
67274
|
-
unitNumber:
|
|
67275
|
-
fields:
|
|
67276
|
-
|
|
67277
|
-
|
|
67278
|
-
|
|
67279
|
-
|
|
67280
|
-
|
|
67281
|
-
|
|
67537
|
+
var residentFormEntry = import_joi148.default.object({
|
|
67538
|
+
_id: import_joi148.default.string().hex().optional().allow("", null),
|
|
67539
|
+
typeOfForm: import_joi148.default.string().optional().allow("", null),
|
|
67540
|
+
unitNumber: import_joi148.default.string().optional().allow(null, ""),
|
|
67541
|
+
fields: import_joi148.default.object().pattern(
|
|
67542
|
+
import_joi148.default.string(),
|
|
67543
|
+
import_joi148.default.alternatives().try(
|
|
67544
|
+
import_joi148.default.string(),
|
|
67545
|
+
import_joi148.default.number(),
|
|
67546
|
+
import_joi148.default.boolean(),
|
|
67547
|
+
import_joi148.default.valid(null)
|
|
67282
67548
|
)
|
|
67283
67549
|
).optional().allow(null, ""),
|
|
67284
|
-
status:
|
|
67285
|
-
org:
|
|
67286
|
-
site:
|
|
67287
|
-
userId:
|
|
67288
|
-
createdAt:
|
|
67289
|
-
updatedAt:
|
|
67290
|
-
deletedAt:
|
|
67291
|
-
remarks:
|
|
67292
|
-
managementValues:
|
|
67293
|
-
|
|
67294
|
-
|
|
67295
|
-
|
|
67296
|
-
|
|
67297
|
-
|
|
67298
|
-
|
|
67550
|
+
status: import_joi148.default.string().optional().allow("", null),
|
|
67551
|
+
org: import_joi148.default.string().hex().optional().allow("", null),
|
|
67552
|
+
site: import_joi148.default.string().hex().optional().allow("", null),
|
|
67553
|
+
userId: import_joi148.default.string().hex().optional().allow("", null),
|
|
67554
|
+
createdAt: import_joi148.default.date().optional().allow("", null),
|
|
67555
|
+
updatedAt: import_joi148.default.date().optional().allow("", null),
|
|
67556
|
+
deletedAt: import_joi148.default.date().optional().allow("", null),
|
|
67557
|
+
remarks: import_joi148.default.string().optional().allow("", null),
|
|
67558
|
+
managementValues: import_joi148.default.object().pattern(
|
|
67559
|
+
import_joi148.default.string(),
|
|
67560
|
+
import_joi148.default.alternatives().try(
|
|
67561
|
+
import_joi148.default.string(),
|
|
67562
|
+
import_joi148.default.number(),
|
|
67563
|
+
import_joi148.default.boolean(),
|
|
67564
|
+
import_joi148.default.valid(null)
|
|
67299
67565
|
)
|
|
67300
67566
|
).optional().allow(null, "")
|
|
67301
67567
|
});
|
|
67302
67568
|
|
|
67303
67569
|
// src/repositories/online-forms-v2.repository.ts
|
|
67304
|
-
var
|
|
67570
|
+
var import_node_server_utils254 = require("@7365admin1/node-server-utils");
|
|
67305
67571
|
var import_mongodb152 = require("mongodb");
|
|
67306
67572
|
var online_forms_namespace_collection = "online-forms";
|
|
67307
67573
|
function useFormEntryRepo() {
|
|
67308
|
-
const db =
|
|
67574
|
+
const db = import_node_server_utils254.useAtlas.getDb();
|
|
67309
67575
|
if (!db) {
|
|
67310
|
-
throw new
|
|
67576
|
+
throw new import_node_server_utils254.InternalServerError("Unable to connect to server.");
|
|
67311
67577
|
}
|
|
67312
67578
|
const collection = db.collection(online_forms_namespace_collection);
|
|
67313
|
-
const { delNamespace, getCache, setCache } = (0,
|
|
67579
|
+
const { delNamespace, getCache, setCache } = (0, import_node_server_utils254.useCache)(
|
|
67314
67580
|
online_forms_namespace_collection
|
|
67315
67581
|
);
|
|
67316
67582
|
const { getUserById } = useUserRepo();
|
|
@@ -67320,7 +67586,7 @@ function useFormEntryRepo() {
|
|
|
67320
67586
|
name: "text"
|
|
67321
67587
|
});
|
|
67322
67588
|
} catch (error) {
|
|
67323
|
-
throw new
|
|
67589
|
+
throw new import_node_server_utils254.InternalServerError(
|
|
67324
67590
|
"Failed to create text index on online form."
|
|
67325
67591
|
);
|
|
67326
67592
|
}
|
|
@@ -67333,7 +67599,7 @@ function useFormEntryRepo() {
|
|
|
67333
67599
|
} catch (error) {
|
|
67334
67600
|
const isDuplicated = error.message.includes("duplicate");
|
|
67335
67601
|
if (isDuplicated) {
|
|
67336
|
-
throw new
|
|
67602
|
+
throw new import_node_server_utils254.BadRequestError("Online Form already exists.");
|
|
67337
67603
|
}
|
|
67338
67604
|
throw error;
|
|
67339
67605
|
}
|
|
@@ -67386,7 +67652,7 @@ function useFormEntryRepo() {
|
|
|
67386
67652
|
{ $project: { user: 0 } }
|
|
67387
67653
|
]).toArray();
|
|
67388
67654
|
const length = await collection.countDocuments(query);
|
|
67389
|
-
const data = (0,
|
|
67655
|
+
const data = (0, import_node_server_utils254.paginate)(items, page, limit, length);
|
|
67390
67656
|
return data;
|
|
67391
67657
|
} catch (error) {
|
|
67392
67658
|
throw error;
|
|
@@ -67396,13 +67662,13 @@ function useFormEntryRepo() {
|
|
|
67396
67662
|
try {
|
|
67397
67663
|
_id = new import_mongodb152.ObjectId(_id);
|
|
67398
67664
|
} catch (error) {
|
|
67399
|
-
throw new
|
|
67665
|
+
throw new import_node_server_utils254.BadRequestError("Invalid online form ID format.");
|
|
67400
67666
|
}
|
|
67401
67667
|
const query = { _id, status: { $ne: "deleted" } };
|
|
67402
67668
|
try {
|
|
67403
67669
|
const [data] = await collection.aggregate([{ $match: query }]).toArray();
|
|
67404
67670
|
if (!data) {
|
|
67405
|
-
throw new
|
|
67671
|
+
throw new import_node_server_utils254.NotFoundError("Document not found.");
|
|
67406
67672
|
}
|
|
67407
67673
|
return data;
|
|
67408
67674
|
} catch (error) {
|
|
@@ -67413,7 +67679,7 @@ function useFormEntryRepo() {
|
|
|
67413
67679
|
try {
|
|
67414
67680
|
_id = new import_mongodb152.ObjectId(_id);
|
|
67415
67681
|
} catch (error) {
|
|
67416
|
-
throw new
|
|
67682
|
+
throw new import_node_server_utils254.BadRequestError("Invalid online form ID format.");
|
|
67417
67683
|
}
|
|
67418
67684
|
try {
|
|
67419
67685
|
const updateValue = {
|
|
@@ -67422,15 +67688,15 @@ function useFormEntryRepo() {
|
|
|
67422
67688
|
};
|
|
67423
67689
|
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
67424
67690
|
if (res.modifiedCount === 0) {
|
|
67425
|
-
throw new
|
|
67691
|
+
throw new import_node_server_utils254.InternalServerError("Unable to update online form.");
|
|
67426
67692
|
}
|
|
67427
67693
|
const onlineFormRequest = await collection.findOne({ _id });
|
|
67428
67694
|
if (!onlineFormRequest) {
|
|
67429
|
-
throw new
|
|
67695
|
+
throw new import_node_server_utils254.NotFoundError("Online form not found.");
|
|
67430
67696
|
}
|
|
67431
67697
|
const user = await getUserById(onlineFormRequest.userId.toString());
|
|
67432
67698
|
if (!user || !user._id) {
|
|
67433
|
-
throw new
|
|
67699
|
+
throw new import_node_server_utils254.NotFoundError("User not found.");
|
|
67434
67700
|
}
|
|
67435
67701
|
const userId = user._id.toString();
|
|
67436
67702
|
await NotificationService.onlineFormRequestStatusUpdated({
|
|
@@ -67447,7 +67713,7 @@ function useFormEntryRepo() {
|
|
|
67447
67713
|
try {
|
|
67448
67714
|
_id = new import_mongodb152.ObjectId(_id);
|
|
67449
67715
|
} catch (error) {
|
|
67450
|
-
throw new
|
|
67716
|
+
throw new import_node_server_utils254.BadRequestError("Invalid online form ID format.");
|
|
67451
67717
|
}
|
|
67452
67718
|
try {
|
|
67453
67719
|
const updateValue = {
|
|
@@ -67461,7 +67727,7 @@ function useFormEntryRepo() {
|
|
|
67461
67727
|
{ session }
|
|
67462
67728
|
);
|
|
67463
67729
|
if (res.modifiedCount === 0) {
|
|
67464
|
-
throw new
|
|
67730
|
+
throw new import_node_server_utils254.InternalServerError("Unable to delete online form.");
|
|
67465
67731
|
}
|
|
67466
67732
|
return res.modifiedCount;
|
|
67467
67733
|
} catch (error) {
|
|
@@ -67478,7 +67744,7 @@ function useFormEntryRepo() {
|
|
|
67478
67744
|
} catch (error) {
|
|
67479
67745
|
const isDuplicated = error.message.includes("duplicate");
|
|
67480
67746
|
if (isDuplicated) {
|
|
67481
|
-
throw new
|
|
67747
|
+
throw new import_node_server_utils254.BadRequestError("Online Form already exists.");
|
|
67482
67748
|
}
|
|
67483
67749
|
throw error;
|
|
67484
67750
|
}
|
|
@@ -67517,13 +67783,13 @@ function useFormEntryRepo() {
|
|
|
67517
67783
|
{ unitNumber: { $regex: search, $options: "i" } }
|
|
67518
67784
|
];
|
|
67519
67785
|
}
|
|
67520
|
-
const cacheKey = (0,
|
|
67786
|
+
const cacheKey = (0, import_node_server_utils254.makeCacheKey)(
|
|
67521
67787
|
online_forms_namespace_collection,
|
|
67522
67788
|
cacheOptions
|
|
67523
67789
|
);
|
|
67524
67790
|
const cachedData = await getCache(cacheKey);
|
|
67525
67791
|
if (cachedData) {
|
|
67526
|
-
|
|
67792
|
+
import_node_server_utils254.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
67527
67793
|
return cachedData;
|
|
67528
67794
|
}
|
|
67529
67795
|
try {
|
|
@@ -67534,11 +67800,11 @@ function useFormEntryRepo() {
|
|
|
67534
67800
|
{ $limit: limit }
|
|
67535
67801
|
]).toArray();
|
|
67536
67802
|
const length = await collection.countDocuments(query);
|
|
67537
|
-
const data = (0,
|
|
67803
|
+
const data = (0, import_node_server_utils254.paginate)(items, page, limit, length);
|
|
67538
67804
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
67539
|
-
|
|
67805
|
+
import_node_server_utils254.logger.info(`Cache set for key: ${cacheKey}`);
|
|
67540
67806
|
}).catch((err) => {
|
|
67541
|
-
|
|
67807
|
+
import_node_server_utils254.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
67542
67808
|
});
|
|
67543
67809
|
return data;
|
|
67544
67810
|
} catch (error) {
|
|
@@ -67558,8 +67824,8 @@ function useFormEntryRepo() {
|
|
|
67558
67824
|
}
|
|
67559
67825
|
|
|
67560
67826
|
// src/controllers/online-forms-v2.controller.ts
|
|
67561
|
-
var
|
|
67562
|
-
var
|
|
67827
|
+
var import_node_server_utils255 = require("@7365admin1/node-server-utils");
|
|
67828
|
+
var import_joi149 = __toESM(require("joi"));
|
|
67563
67829
|
var import_exceljs3 = __toESM(require("exceljs"));
|
|
67564
67830
|
var import_fs7 = __toESM(require("fs"));
|
|
67565
67831
|
function useFormEntryController() {
|
|
@@ -67585,14 +67851,14 @@ function useFormEntryController() {
|
|
|
67585
67851
|
async function uploadFormEntrys(req, res, next) {
|
|
67586
67852
|
try {
|
|
67587
67853
|
if (!req.file) {
|
|
67588
|
-
next(new
|
|
67854
|
+
next(new import_node_server_utils255.BadRequestError("Excel file is required."));
|
|
67589
67855
|
return;
|
|
67590
67856
|
}
|
|
67591
67857
|
const workbook = new import_exceljs3.default.Workbook();
|
|
67592
67858
|
await workbook.xlsx.readFile(req.file.path);
|
|
67593
67859
|
const worksheet = workbook.worksheets[0];
|
|
67594
67860
|
if (!worksheet) {
|
|
67595
|
-
next(new
|
|
67861
|
+
next(new import_node_server_utils255.BadRequestError("No worksheet found in uploaded Excel file."));
|
|
67596
67862
|
return;
|
|
67597
67863
|
}
|
|
67598
67864
|
const headerRow = worksheet.getRow(1);
|
|
@@ -67620,8 +67886,8 @@ function useFormEntryController() {
|
|
|
67620
67886
|
});
|
|
67621
67887
|
if (error) {
|
|
67622
67888
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67623
|
-
|
|
67624
|
-
next(new
|
|
67889
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
67890
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67625
67891
|
return;
|
|
67626
67892
|
}
|
|
67627
67893
|
const result = await _add(value);
|
|
@@ -67629,25 +67895,25 @@ function useFormEntryController() {
|
|
|
67629
67895
|
import_fs7.default.unlink(req.file.path, () => {
|
|
67630
67896
|
});
|
|
67631
67897
|
} catch (error) {
|
|
67632
|
-
|
|
67898
|
+
import_node_server_utils255.logger.log({ level: "error", message: error.message });
|
|
67633
67899
|
next(error);
|
|
67634
67900
|
}
|
|
67635
67901
|
}
|
|
67636
67902
|
async function getAll(req, res, next) {
|
|
67637
67903
|
try {
|
|
67638
|
-
const schema2 =
|
|
67639
|
-
search:
|
|
67640
|
-
page:
|
|
67641
|
-
limit:
|
|
67642
|
-
status:
|
|
67643
|
-
org:
|
|
67644
|
-
site:
|
|
67904
|
+
const schema2 = import_joi149.default.object({
|
|
67905
|
+
search: import_joi149.default.string().optional().allow("", null),
|
|
67906
|
+
page: import_joi149.default.number().integer().min(1).allow("", null).default(1),
|
|
67907
|
+
limit: import_joi149.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
67908
|
+
status: import_joi149.default.string().optional().allow(null, ""),
|
|
67909
|
+
org: import_joi149.default.string().hex().optional().allow("", null),
|
|
67910
|
+
site: import_joi149.default.string().hex().optional().allow("", null)
|
|
67645
67911
|
});
|
|
67646
67912
|
const { error, value } = schema2.validate(req.query);
|
|
67647
67913
|
if (error) {
|
|
67648
67914
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67649
|
-
|
|
67650
|
-
next(new
|
|
67915
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
67916
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67651
67917
|
return;
|
|
67652
67918
|
}
|
|
67653
67919
|
const { search, page, limit, status, org, site } = value;
|
|
@@ -67655,21 +67921,21 @@ function useFormEntryController() {
|
|
|
67655
67921
|
res.json(data);
|
|
67656
67922
|
return;
|
|
67657
67923
|
} catch (error) {
|
|
67658
|
-
|
|
67924
|
+
import_node_server_utils255.logger.log({ level: "error", message: error.message });
|
|
67659
67925
|
next(error);
|
|
67660
67926
|
return;
|
|
67661
67927
|
}
|
|
67662
67928
|
}
|
|
67663
67929
|
async function getFormEntryById(req, res, next) {
|
|
67664
67930
|
try {
|
|
67665
|
-
const schema2 =
|
|
67666
|
-
_id:
|
|
67931
|
+
const schema2 = import_joi149.default.object({
|
|
67932
|
+
_id: import_joi149.default.string().hex().length(24).required()
|
|
67667
67933
|
});
|
|
67668
67934
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
67669
67935
|
if (error) {
|
|
67670
67936
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67671
|
-
|
|
67672
|
-
next(new
|
|
67937
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
67938
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67673
67939
|
return;
|
|
67674
67940
|
}
|
|
67675
67941
|
const { _id } = value;
|
|
@@ -67677,7 +67943,7 @@ function useFormEntryController() {
|
|
|
67677
67943
|
res.json(data);
|
|
67678
67944
|
return;
|
|
67679
67945
|
} catch (error) {
|
|
67680
|
-
|
|
67946
|
+
import_node_server_utils255.logger.log({ level: "error", message: error.message });
|
|
67681
67947
|
next(error);
|
|
67682
67948
|
return;
|
|
67683
67949
|
}
|
|
@@ -67690,8 +67956,8 @@ function useFormEntryController() {
|
|
|
67690
67956
|
});
|
|
67691
67957
|
if (error) {
|
|
67692
67958
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67693
|
-
|
|
67694
|
-
next(new
|
|
67959
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
67960
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67695
67961
|
return;
|
|
67696
67962
|
}
|
|
67697
67963
|
const { _id, ...rest } = value;
|
|
@@ -67699,26 +67965,26 @@ function useFormEntryController() {
|
|
|
67699
67965
|
res.json({ message: "Successfully updated online form." });
|
|
67700
67966
|
return;
|
|
67701
67967
|
} catch (error) {
|
|
67702
|
-
|
|
67968
|
+
import_node_server_utils255.logger.log({ level: "error", message: error.message });
|
|
67703
67969
|
next(error);
|
|
67704
67970
|
return;
|
|
67705
67971
|
}
|
|
67706
67972
|
}
|
|
67707
67973
|
async function deleteFormEntryById(req, res, next) {
|
|
67708
67974
|
try {
|
|
67709
|
-
const validation =
|
|
67975
|
+
const validation = import_joi149.default.string().hex().required();
|
|
67710
67976
|
const _id = req.params.id;
|
|
67711
67977
|
const { error } = validation.validate(_id);
|
|
67712
67978
|
if (error) {
|
|
67713
|
-
|
|
67714
|
-
next(new
|
|
67979
|
+
import_node_server_utils255.logger.log({ level: "error", message: error.message });
|
|
67980
|
+
next(new import_node_server_utils255.BadRequestError(error.message));
|
|
67715
67981
|
return;
|
|
67716
67982
|
}
|
|
67717
67983
|
await _deleteOnlineFormById(_id);
|
|
67718
67984
|
res.json({ message: "Successfully deleted online form." });
|
|
67719
67985
|
return;
|
|
67720
67986
|
} catch (error) {
|
|
67721
|
-
|
|
67987
|
+
import_node_server_utils255.logger.log({ level: "error", message: error.message });
|
|
67722
67988
|
next(error);
|
|
67723
67989
|
return;
|
|
67724
67990
|
}
|
|
@@ -67735,8 +68001,8 @@ function useFormEntryController() {
|
|
|
67735
68001
|
});
|
|
67736
68002
|
if (error) {
|
|
67737
68003
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67738
|
-
|
|
67739
|
-
next(new
|
|
68004
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
68005
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67740
68006
|
return;
|
|
67741
68007
|
}
|
|
67742
68008
|
try {
|
|
@@ -67744,7 +68010,7 @@ function useFormEntryController() {
|
|
|
67744
68010
|
res.status(201).json({ message: data });
|
|
67745
68011
|
return;
|
|
67746
68012
|
} catch (error2) {
|
|
67747
|
-
|
|
68013
|
+
import_node_server_utils255.logger.log({ level: "error", message: error2.message });
|
|
67748
68014
|
next(error2);
|
|
67749
68015
|
return;
|
|
67750
68016
|
}
|
|
@@ -67756,8 +68022,8 @@ function useFormEntryController() {
|
|
|
67756
68022
|
});
|
|
67757
68023
|
if (error) {
|
|
67758
68024
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67759
|
-
|
|
67760
|
-
next(new
|
|
68025
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
68026
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67761
68027
|
return;
|
|
67762
68028
|
}
|
|
67763
68029
|
try {
|
|
@@ -67765,35 +68031,35 @@ function useFormEntryController() {
|
|
|
67765
68031
|
res.status(201).json({ message: data });
|
|
67766
68032
|
return;
|
|
67767
68033
|
} catch (error2) {
|
|
67768
|
-
|
|
68034
|
+
import_node_server_utils255.logger.log({ level: "error", message: error2.message });
|
|
67769
68035
|
next(error2);
|
|
67770
68036
|
return;
|
|
67771
68037
|
}
|
|
67772
68038
|
}
|
|
67773
68039
|
async function residentForm(req, res, next) {
|
|
67774
68040
|
try {
|
|
67775
|
-
const residentFormPayload =
|
|
67776
|
-
org:
|
|
67777
|
-
site:
|
|
67778
|
-
userId:
|
|
67779
|
-
search:
|
|
67780
|
-
page:
|
|
67781
|
-
limit:
|
|
68041
|
+
const residentFormPayload = import_joi149.default.object({
|
|
68042
|
+
org: import_joi149.default.string().hex().required(),
|
|
68043
|
+
site: import_joi149.default.string().hex().required(),
|
|
68044
|
+
userId: import_joi149.default.string().hex().required(),
|
|
68045
|
+
search: import_joi149.default.string().optional().allow("", null),
|
|
68046
|
+
page: import_joi149.default.number().integer().min(1).allow("", null).default(1),
|
|
68047
|
+
limit: import_joi149.default.number().integer().min(1).max(100).allow("", null).default(10)
|
|
67782
68048
|
});
|
|
67783
68049
|
const { error, value } = residentFormPayload.validate(req.query, {
|
|
67784
68050
|
abortEarly: true
|
|
67785
68051
|
});
|
|
67786
68052
|
if (error) {
|
|
67787
68053
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67788
|
-
|
|
67789
|
-
next(new
|
|
68054
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
68055
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67790
68056
|
return;
|
|
67791
68057
|
}
|
|
67792
68058
|
const { site, userId, org, search, page, limit } = value;
|
|
67793
68059
|
const result = await _residentForm({ userId, site, org, search, page, limit });
|
|
67794
68060
|
res.json(result);
|
|
67795
68061
|
} catch (error) {
|
|
67796
|
-
|
|
68062
|
+
import_node_server_utils255.logger.log({ level: "error", message: error.message });
|
|
67797
68063
|
next(error);
|
|
67798
68064
|
return;
|
|
67799
68065
|
}
|
|
@@ -67811,11 +68077,11 @@ function useFormEntryController() {
|
|
|
67811
68077
|
}
|
|
67812
68078
|
|
|
67813
68079
|
// src/services/building-level.service.ts
|
|
67814
|
-
var
|
|
68080
|
+
var import_node_server_utils256 = require("@7365admin1/node-server-utils");
|
|
67815
68081
|
function useBuildingLevelService() {
|
|
67816
68082
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
|
|
67817
68083
|
async function add(value) {
|
|
67818
|
-
const session =
|
|
68084
|
+
const session = import_node_server_utils256.useAtlas.getClient()?.startSession();
|
|
67819
68085
|
try {
|
|
67820
68086
|
session?.startTransaction();
|
|
67821
68087
|
await _add(value, session);
|
|
@@ -67829,7 +68095,7 @@ function useBuildingLevelService() {
|
|
|
67829
68095
|
}
|
|
67830
68096
|
}
|
|
67831
68097
|
async function updateLevelById(_id, value) {
|
|
67832
|
-
const session =
|
|
68098
|
+
const session = import_node_server_utils256.useAtlas.getClient()?.startSession();
|
|
67833
68099
|
try {
|
|
67834
68100
|
session?.startTransaction();
|
|
67835
68101
|
await _updateLevelById(_id, value, session);
|
|
@@ -67849,8 +68115,8 @@ function useBuildingLevelService() {
|
|
|
67849
68115
|
}
|
|
67850
68116
|
|
|
67851
68117
|
// src/controllers/building-level.controller.ts
|
|
67852
|
-
var
|
|
67853
|
-
var
|
|
68118
|
+
var import_node_server_utils257 = require("@7365admin1/node-server-utils");
|
|
68119
|
+
var import_joi150 = __toESM(require("joi"));
|
|
67854
68120
|
function useBuildingLevelController() {
|
|
67855
68121
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
|
|
67856
68122
|
const {
|
|
@@ -67867,8 +68133,8 @@ function useBuildingLevelController() {
|
|
|
67867
68133
|
});
|
|
67868
68134
|
if (error) {
|
|
67869
68135
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67870
|
-
|
|
67871
|
-
next(new
|
|
68136
|
+
import_node_server_utils257.logger.log({ level: "error", message: messages });
|
|
68137
|
+
next(new import_node_server_utils257.BadRequestError(messages));
|
|
67872
68138
|
return;
|
|
67873
68139
|
}
|
|
67874
68140
|
const result = await _add(value);
|
|
@@ -67879,20 +68145,20 @@ function useBuildingLevelController() {
|
|
|
67879
68145
|
}
|
|
67880
68146
|
async function getAll(req, res, next) {
|
|
67881
68147
|
try {
|
|
67882
|
-
const validation =
|
|
67883
|
-
page:
|
|
67884
|
-
limit:
|
|
67885
|
-
search:
|
|
67886
|
-
site:
|
|
67887
|
-
status:
|
|
68148
|
+
const validation = import_joi150.default.object({
|
|
68149
|
+
page: import_joi150.default.number().min(1).optional().default(1),
|
|
68150
|
+
limit: import_joi150.default.number().min(1).optional().default(20),
|
|
68151
|
+
search: import_joi150.default.string().optional().allow("", null),
|
|
68152
|
+
site: import_joi150.default.string().hex().length(24).optional().allow("", null),
|
|
68153
|
+
status: import_joi150.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
|
|
67888
68154
|
});
|
|
67889
68155
|
const { error, value } = validation.validate(req.query, {
|
|
67890
68156
|
abortEarly: false
|
|
67891
68157
|
});
|
|
67892
68158
|
if (error) {
|
|
67893
68159
|
const messages = error.details.map((d) => d.message);
|
|
67894
|
-
|
|
67895
|
-
next(new
|
|
68160
|
+
import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
|
|
68161
|
+
next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
|
|
67896
68162
|
return;
|
|
67897
68163
|
}
|
|
67898
68164
|
const { page, limit, status, site, search } = value;
|
|
@@ -67911,14 +68177,14 @@ function useBuildingLevelController() {
|
|
|
67911
68177
|
}
|
|
67912
68178
|
async function getById(req, res, next) {
|
|
67913
68179
|
try {
|
|
67914
|
-
const schema2 =
|
|
67915
|
-
id:
|
|
68180
|
+
const schema2 = import_joi150.default.object({
|
|
68181
|
+
id: import_joi150.default.string().hex().length(24).required()
|
|
67916
68182
|
});
|
|
67917
68183
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
67918
68184
|
if (error) {
|
|
67919
68185
|
const messages = error.details.map((d) => d.message);
|
|
67920
|
-
|
|
67921
|
-
next(new
|
|
68186
|
+
import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
|
|
68187
|
+
next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
|
|
67922
68188
|
return;
|
|
67923
68189
|
}
|
|
67924
68190
|
const { id } = value;
|
|
@@ -67937,8 +68203,8 @@ function useBuildingLevelController() {
|
|
|
67937
68203
|
});
|
|
67938
68204
|
if (error) {
|
|
67939
68205
|
const messages = error.details.map((d) => d.message);
|
|
67940
|
-
|
|
67941
|
-
next(new
|
|
68206
|
+
import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
|
|
68207
|
+
next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
|
|
67942
68208
|
return;
|
|
67943
68209
|
}
|
|
67944
68210
|
const { _id, ...rest } = value;
|
|
@@ -67950,14 +68216,14 @@ function useBuildingLevelController() {
|
|
|
67950
68216
|
}
|
|
67951
68217
|
async function deleteById(req, res, next) {
|
|
67952
68218
|
try {
|
|
67953
|
-
const schema2 =
|
|
67954
|
-
id:
|
|
68219
|
+
const schema2 = import_joi150.default.object({
|
|
68220
|
+
id: import_joi150.default.string().hex().required()
|
|
67955
68221
|
});
|
|
67956
68222
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
67957
68223
|
if (error) {
|
|
67958
68224
|
const messages = error.details.map((d) => d.message);
|
|
67959
|
-
|
|
67960
|
-
next(new
|
|
68225
|
+
import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
|
|
68226
|
+
next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
|
|
67961
68227
|
return;
|
|
67962
68228
|
}
|
|
67963
68229
|
const { id } = value;
|
|
@@ -67970,19 +68236,19 @@ function useBuildingLevelController() {
|
|
|
67970
68236
|
}
|
|
67971
68237
|
async function batchUpdateByIds(req, res, next) {
|
|
67972
68238
|
try {
|
|
67973
|
-
const schema2 =
|
|
67974
|
-
|
|
67975
|
-
_id:
|
|
67976
|
-
value:
|
|
67977
|
-
name:
|
|
68239
|
+
const schema2 = import_joi150.default.array().items(
|
|
68240
|
+
import_joi150.default.object({
|
|
68241
|
+
_id: import_joi150.default.string().hex().length(24).required(),
|
|
68242
|
+
value: import_joi150.default.object({
|
|
68243
|
+
name: import_joi150.default.string().optional().allow("", null)
|
|
67978
68244
|
}).required()
|
|
67979
68245
|
})
|
|
67980
68246
|
);
|
|
67981
68247
|
const { error, value } = schema2.validate(req.body);
|
|
67982
68248
|
if (error) {
|
|
67983
68249
|
const messages = error.details.map((d) => d.message);
|
|
67984
|
-
|
|
67985
|
-
next(new
|
|
68250
|
+
import_node_server_utils257.logger.log({ level: "error", message: messages.join(", ") });
|
|
68251
|
+
next(new import_node_server_utils257.BadRequestError(messages.join(", ")));
|
|
67986
68252
|
return;
|
|
67987
68253
|
}
|
|
67988
68254
|
const updates = value.map((item) => ({
|
|
@@ -67997,9 +68263,9 @@ function useBuildingLevelController() {
|
|
|
67997
68263
|
}
|
|
67998
68264
|
async function getBuildingLevelList(req, res, next) {
|
|
67999
68265
|
try {
|
|
68000
|
-
const schema2 =
|
|
68001
|
-
site:
|
|
68002
|
-
block:
|
|
68266
|
+
const schema2 = import_joi150.default.object({
|
|
68267
|
+
site: import_joi150.default.string().hex().length(24).required(),
|
|
68268
|
+
block: import_joi150.default.string().hex().length(24).required()
|
|
68003
68269
|
});
|
|
68004
68270
|
const { error, value } = schema2.validate({
|
|
68005
68271
|
site: req.params.siteId,
|
|
@@ -68007,8 +68273,8 @@ function useBuildingLevelController() {
|
|
|
68007
68273
|
});
|
|
68008
68274
|
if (error) {
|
|
68009
68275
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
68010
|
-
|
|
68011
|
-
next(new
|
|
68276
|
+
import_node_server_utils257.logger.log({ level: "error", message: messages });
|
|
68277
|
+
next(new import_node_server_utils257.BadRequestError(messages));
|
|
68012
68278
|
return;
|
|
68013
68279
|
}
|
|
68014
68280
|
const { site, block } = value;
|
|
@@ -68031,9 +68297,9 @@ function useBuildingLevelController() {
|
|
|
68031
68297
|
}
|
|
68032
68298
|
|
|
68033
68299
|
// src/models/hid-amico.model.ts
|
|
68034
|
-
var
|
|
68300
|
+
var import_node_server_utils258 = require("@7365admin1/node-server-utils");
|
|
68035
68301
|
var import_mongodb153 = require("mongodb");
|
|
68036
|
-
var
|
|
68302
|
+
var import_joi151 = __toESM(require("joi"));
|
|
68037
68303
|
function canReadObjectId(value) {
|
|
68038
68304
|
if (value instanceof import_mongodb153.ObjectId)
|
|
68039
68305
|
return true;
|
|
@@ -68071,161 +68337,161 @@ function toObjectId23(value, label = "ID") {
|
|
|
68071
68337
|
return toObjectId23(text, label);
|
|
68072
68338
|
}
|
|
68073
68339
|
}
|
|
68074
|
-
throw new
|
|
68340
|
+
throw new import_node_server_utils258.BadRequestError(`Invalid ${label} format`);
|
|
68075
68341
|
}
|
|
68076
|
-
var objectIdSchema2 =
|
|
68342
|
+
var objectIdSchema2 = import_joi151.default.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
|
|
68077
68343
|
"any.invalid": "{{#label}} must be a valid ObjectId"
|
|
68078
68344
|
});
|
|
68079
|
-
var schemaHidAmicoReader =
|
|
68345
|
+
var schemaHidAmicoReader = import_joi151.default.object({
|
|
68080
68346
|
_id: objectIdSchema2.optional(),
|
|
68081
68347
|
site: objectIdSchema2.required(),
|
|
68082
|
-
name:
|
|
68083
|
-
baseUrl:
|
|
68084
|
-
username:
|
|
68085
|
-
password:
|
|
68086
|
-
location:
|
|
68087
|
-
deviceId:
|
|
68088
|
-
monitorPath:
|
|
68089
|
-
enabled:
|
|
68090
|
-
status:
|
|
68091
|
-
lastSeenAt:
|
|
68092
|
-
lastSyncAt:
|
|
68093
|
-
lastSyncStatus:
|
|
68094
|
-
lastSyncMessage:
|
|
68095
|
-
createdAt:
|
|
68096
|
-
updatedAt:
|
|
68097
|
-
deletedAt:
|
|
68348
|
+
name: import_joi151.default.string().trim().required(),
|
|
68349
|
+
baseUrl: import_joi151.default.string().uri({ scheme: ["http", "https"] }).required(),
|
|
68350
|
+
username: import_joi151.default.string().trim().required(),
|
|
68351
|
+
password: import_joi151.default.string().required(),
|
|
68352
|
+
location: import_joi151.default.string().allow(null, "").optional(),
|
|
68353
|
+
deviceId: import_joi151.default.string().allow(null, "").optional(),
|
|
68354
|
+
monitorPath: import_joi151.default.string().allow(null, "").optional(),
|
|
68355
|
+
enabled: import_joi151.default.boolean().optional(),
|
|
68356
|
+
status: import_joi151.default.string().valid("active", "inactive", "deleted", "offline").optional(),
|
|
68357
|
+
lastSeenAt: import_joi151.default.date().optional(),
|
|
68358
|
+
lastSyncAt: import_joi151.default.date().optional(),
|
|
68359
|
+
lastSyncStatus: import_joi151.default.string().valid("idle", "running", "completed", "failed").optional(),
|
|
68360
|
+
lastSyncMessage: import_joi151.default.string().allow(null, "").optional(),
|
|
68361
|
+
createdAt: import_joi151.default.date().optional(),
|
|
68362
|
+
updatedAt: import_joi151.default.date().optional(),
|
|
68363
|
+
deletedAt: import_joi151.default.date().optional()
|
|
68098
68364
|
});
|
|
68099
|
-
var schemaUpdateHidAmicoReader =
|
|
68365
|
+
var schemaUpdateHidAmicoReader = import_joi151.default.object({
|
|
68100
68366
|
site: objectIdSchema2.optional(),
|
|
68101
|
-
name:
|
|
68102
|
-
baseUrl:
|
|
68103
|
-
username:
|
|
68104
|
-
password:
|
|
68105
|
-
location:
|
|
68106
|
-
deviceId:
|
|
68107
|
-
monitorPath:
|
|
68108
|
-
enabled:
|
|
68109
|
-
status:
|
|
68110
|
-
lastSeenAt:
|
|
68111
|
-
lastSyncAt:
|
|
68112
|
-
lastSyncStatus:
|
|
68113
|
-
lastSyncMessage:
|
|
68114
|
-
deletedAt:
|
|
68367
|
+
name: import_joi151.default.string().trim().optional(),
|
|
68368
|
+
baseUrl: import_joi151.default.string().uri({ scheme: ["http", "https"] }).optional(),
|
|
68369
|
+
username: import_joi151.default.string().trim().optional(),
|
|
68370
|
+
password: import_joi151.default.string().allow(null, "").optional(),
|
|
68371
|
+
location: import_joi151.default.string().allow(null, "").optional(),
|
|
68372
|
+
deviceId: import_joi151.default.string().allow(null, "").optional(),
|
|
68373
|
+
monitorPath: import_joi151.default.string().allow(null, "").optional(),
|
|
68374
|
+
enabled: import_joi151.default.boolean().optional(),
|
|
68375
|
+
status: import_joi151.default.string().valid("active", "inactive", "deleted", "offline").optional(),
|
|
68376
|
+
lastSeenAt: import_joi151.default.date().optional(),
|
|
68377
|
+
lastSyncAt: import_joi151.default.date().optional(),
|
|
68378
|
+
lastSyncStatus: import_joi151.default.string().valid("idle", "running", "completed", "failed").optional(),
|
|
68379
|
+
lastSyncMessage: import_joi151.default.string().allow(null, "").optional(),
|
|
68380
|
+
deletedAt: import_joi151.default.date().optional()
|
|
68115
68381
|
});
|
|
68116
|
-
var schemaHidAmicoEvent =
|
|
68382
|
+
var schemaHidAmicoEvent = import_joi151.default.object({
|
|
68117
68383
|
_id: objectIdSchema2.optional(),
|
|
68118
68384
|
reader: objectIdSchema2.required(),
|
|
68119
68385
|
site: objectIdSchema2.optional(),
|
|
68120
|
-
type:
|
|
68121
|
-
payload:
|
|
68122
|
-
status:
|
|
68123
|
-
createdAt:
|
|
68386
|
+
type: import_joi151.default.string().required(),
|
|
68387
|
+
payload: import_joi151.default.object().unknown(true).required(),
|
|
68388
|
+
status: import_joi151.default.string().valid("received", "processed", "failed").optional(),
|
|
68389
|
+
createdAt: import_joi151.default.date().optional()
|
|
68124
68390
|
});
|
|
68125
|
-
var schemaHidAmicoIdentity =
|
|
68391
|
+
var schemaHidAmicoIdentity = import_joi151.default.object({
|
|
68126
68392
|
_id: objectIdSchema2.optional(),
|
|
68127
68393
|
reader: objectIdSchema2.required(),
|
|
68128
68394
|
site: objectIdSchema2.required(),
|
|
68129
|
-
hidUserId:
|
|
68130
|
-
registration:
|
|
68131
|
-
cardNo:
|
|
68395
|
+
hidUserId: import_joi151.default.alternatives(import_joi151.default.string(), import_joi151.default.number()).optional().allow(null, ""),
|
|
68396
|
+
registration: import_joi151.default.string().optional().allow(null, ""),
|
|
68397
|
+
cardNo: import_joi151.default.string().optional().allow(null, ""),
|
|
68132
68398
|
person: objectIdSchema2.optional().allow(null, ""),
|
|
68133
68399
|
user: objectIdSchema2.optional().allow(null, ""),
|
|
68134
68400
|
member: objectIdSchema2.optional().allow(null, ""),
|
|
68135
68401
|
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
68136
|
-
type:
|
|
68137
|
-
status:
|
|
68138
|
-
metadata:
|
|
68139
|
-
createdAt:
|
|
68140
|
-
updatedAt:
|
|
68141
|
-
deletedAt:
|
|
68402
|
+
type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
|
|
68403
|
+
status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
|
|
68404
|
+
metadata: import_joi151.default.object().unknown(true).optional(),
|
|
68405
|
+
createdAt: import_joi151.default.date().optional(),
|
|
68406
|
+
updatedAt: import_joi151.default.date().optional(),
|
|
68407
|
+
deletedAt: import_joi151.default.date().optional()
|
|
68142
68408
|
}).or("hidUserId", "registration", "cardNo");
|
|
68143
|
-
var schemaCreateHidAmicoIdentity =
|
|
68409
|
+
var schemaCreateHidAmicoIdentity = import_joi151.default.object({
|
|
68144
68410
|
site: objectIdSchema2.optional(),
|
|
68145
|
-
hidUserId:
|
|
68146
|
-
registration:
|
|
68147
|
-
cardNo:
|
|
68411
|
+
hidUserId: import_joi151.default.alternatives(import_joi151.default.string(), import_joi151.default.number()).optional().allow(null, ""),
|
|
68412
|
+
registration: import_joi151.default.string().optional().allow(null, ""),
|
|
68413
|
+
cardNo: import_joi151.default.string().optional().allow(null, ""),
|
|
68148
68414
|
person: objectIdSchema2.optional().allow(null, ""),
|
|
68149
68415
|
user: objectIdSchema2.optional().allow(null, ""),
|
|
68150
68416
|
member: objectIdSchema2.optional().allow(null, ""),
|
|
68151
68417
|
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
68152
|
-
type:
|
|
68153
|
-
status:
|
|
68154
|
-
metadata:
|
|
68418
|
+
type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
|
|
68419
|
+
status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
|
|
68420
|
+
metadata: import_joi151.default.object().unknown(true).optional()
|
|
68155
68421
|
}).or("hidUserId", "registration", "cardNo");
|
|
68156
|
-
var schemaUpdateHidAmicoIdentity =
|
|
68157
|
-
hidUserId:
|
|
68158
|
-
registration:
|
|
68159
|
-
cardNo:
|
|
68422
|
+
var schemaUpdateHidAmicoIdentity = import_joi151.default.object({
|
|
68423
|
+
hidUserId: import_joi151.default.alternatives(import_joi151.default.string(), import_joi151.default.number()).optional().allow(null, ""),
|
|
68424
|
+
registration: import_joi151.default.string().optional().allow(null, ""),
|
|
68425
|
+
cardNo: import_joi151.default.string().optional().allow(null, ""),
|
|
68160
68426
|
person: objectIdSchema2.optional().allow(null, ""),
|
|
68161
68427
|
user: objectIdSchema2.optional().allow(null, ""),
|
|
68162
68428
|
member: objectIdSchema2.optional().allow(null, ""),
|
|
68163
68429
|
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
68164
|
-
type:
|
|
68165
|
-
status:
|
|
68166
|
-
metadata:
|
|
68167
|
-
deletedAt:
|
|
68430
|
+
type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
|
|
68431
|
+
status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
|
|
68432
|
+
metadata: import_joi151.default.object().unknown(true).optional(),
|
|
68433
|
+
deletedAt: import_joi151.default.date().optional()
|
|
68168
68434
|
});
|
|
68169
|
-
var schemaHidAmicoReaderIdParams =
|
|
68170
|
-
readerId:
|
|
68435
|
+
var schemaHidAmicoReaderIdParams = import_joi151.default.object({
|
|
68436
|
+
readerId: import_joi151.default.string().hex().length(24).required()
|
|
68171
68437
|
});
|
|
68172
|
-
var schemaHidAmicoUserImageParams =
|
|
68173
|
-
readerId:
|
|
68174
|
-
hidUserId:
|
|
68438
|
+
var schemaHidAmicoUserImageParams = import_joi151.default.object({
|
|
68439
|
+
readerId: import_joi151.default.string().hex().length(24).required(),
|
|
68440
|
+
hidUserId: import_joi151.default.alternatives().try(import_joi151.default.string(), import_joi151.default.number()).required()
|
|
68175
68441
|
});
|
|
68176
|
-
var schemaHidAmicoIdentityIdParams =
|
|
68177
|
-
identityId:
|
|
68442
|
+
var schemaHidAmicoIdentityIdParams = import_joi151.default.object({
|
|
68443
|
+
identityId: import_joi151.default.string().hex().length(24).required()
|
|
68178
68444
|
});
|
|
68179
|
-
var schemaHidAmicoReaderListQuery =
|
|
68180
|
-
site:
|
|
68181
|
-
page:
|
|
68182
|
-
limit:
|
|
68445
|
+
var schemaHidAmicoReaderListQuery = import_joi151.default.object({
|
|
68446
|
+
site: import_joi151.default.string().hex().length(24).optional(),
|
|
68447
|
+
page: import_joi151.default.number().min(1).optional(),
|
|
68448
|
+
limit: import_joi151.default.number().min(1).optional()
|
|
68183
68449
|
});
|
|
68184
|
-
var schemaHidAmicoLogQuery =
|
|
68185
|
-
page:
|
|
68186
|
-
limit:
|
|
68187
|
-
type:
|
|
68450
|
+
var schemaHidAmicoLogQuery = import_joi151.default.object({
|
|
68451
|
+
page: import_joi151.default.number().min(1).optional(),
|
|
68452
|
+
limit: import_joi151.default.number().min(1).optional(),
|
|
68453
|
+
type: import_joi151.default.string().optional()
|
|
68188
68454
|
});
|
|
68189
|
-
var schemaHidAmicoIdentityQuery =
|
|
68190
|
-
page:
|
|
68191
|
-
limit:
|
|
68192
|
-
type:
|
|
68193
|
-
status:
|
|
68194
|
-
search:
|
|
68455
|
+
var schemaHidAmicoIdentityQuery = import_joi151.default.object({
|
|
68456
|
+
page: import_joi151.default.number().min(1).optional(),
|
|
68457
|
+
limit: import_joi151.default.number().min(1).optional(),
|
|
68458
|
+
type: import_joi151.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
|
|
68459
|
+
status: import_joi151.default.string().valid("active", "inactive", "deleted").optional(),
|
|
68460
|
+
search: import_joi151.default.string().allow("").optional()
|
|
68195
68461
|
});
|
|
68196
|
-
var schemaHidAmicoSync =
|
|
68197
|
-
objects:
|
|
68198
|
-
|
|
68199
|
-
object:
|
|
68200
|
-
values:
|
|
68462
|
+
var schemaHidAmicoSync = import_joi151.default.object({
|
|
68463
|
+
objects: import_joi151.default.array().items(
|
|
68464
|
+
import_joi151.default.object({
|
|
68465
|
+
object: import_joi151.default.string().required(),
|
|
68466
|
+
values: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).required()
|
|
68201
68467
|
}).unknown(true)
|
|
68202
68468
|
).optional(),
|
|
68203
|
-
users:
|
|
68204
|
-
cards:
|
|
68205
|
-
qrcodes:
|
|
68206
|
-
pins:
|
|
68469
|
+
users: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional(),
|
|
68470
|
+
cards: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional(),
|
|
68471
|
+
qrcodes: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional(),
|
|
68472
|
+
pins: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).optional()
|
|
68207
68473
|
}).unknown(true);
|
|
68208
|
-
var schemaHidAmicoExecuteActions =
|
|
68209
|
-
actions:
|
|
68474
|
+
var schemaHidAmicoExecuteActions = import_joi151.default.object({
|
|
68475
|
+
actions: import_joi151.default.array().items(import_joi151.default.object().unknown(true)).min(1).required()
|
|
68210
68476
|
}).unknown(true);
|
|
68211
|
-
var schemaHidAmicoConfiguration =
|
|
68212
|
-
var schemaHidAmicoSetConfiguration =
|
|
68213
|
-
var schemaHidAmicoObjectOperation =
|
|
68214
|
-
operation:
|
|
68215
|
-
object:
|
|
68216
|
-
values:
|
|
68217
|
-
|
|
68218
|
-
|
|
68477
|
+
var schemaHidAmicoConfiguration = import_joi151.default.object().pattern(import_joi151.default.string(), import_joi151.default.array().items(import_joi151.default.string())).min(1).unknown(true);
|
|
68478
|
+
var schemaHidAmicoSetConfiguration = import_joi151.default.object().unknown(true);
|
|
68479
|
+
var schemaHidAmicoObjectOperation = import_joi151.default.object({
|
|
68480
|
+
operation: import_joi151.default.string().valid("load", "create", "modify", "destroy").required(),
|
|
68481
|
+
object: import_joi151.default.string().required(),
|
|
68482
|
+
values: import_joi151.default.alternatives().try(
|
|
68483
|
+
import_joi151.default.array().items(import_joi151.default.object().unknown(true)),
|
|
68484
|
+
import_joi151.default.object().unknown(true)
|
|
68219
68485
|
).optional(),
|
|
68220
|
-
where:
|
|
68221
|
-
fields:
|
|
68222
|
-
order:
|
|
68223
|
-
limit:
|
|
68224
|
-
offset:
|
|
68486
|
+
where: import_joi151.default.object().unknown(true).optional(),
|
|
68487
|
+
fields: import_joi151.default.array().items(import_joi151.default.string()).optional(),
|
|
68488
|
+
order: import_joi151.default.array().items(import_joi151.default.string()).optional(),
|
|
68489
|
+
limit: import_joi151.default.number().integer().min(1).optional(),
|
|
68490
|
+
offset: import_joi151.default.number().integer().min(0).optional()
|
|
68225
68491
|
}).unknown(true);
|
|
68226
|
-
var schemaHidAmicoNotificationParams =
|
|
68227
|
-
readerId:
|
|
68228
|
-
type:
|
|
68492
|
+
var schemaHidAmicoNotificationParams = import_joi151.default.object({
|
|
68493
|
+
readerId: import_joi151.default.string().hex().length(24).required(),
|
|
68494
|
+
type: import_joi151.default.string().valid(
|
|
68229
68495
|
"dao",
|
|
68230
68496
|
"template",
|
|
68231
68497
|
"user_image",
|
|
@@ -68243,8 +68509,8 @@ var schemaHidAmicoNotificationParams = import_joi150.default.object({
|
|
|
68243
68509
|
function MHidAmicoReader(value) {
|
|
68244
68510
|
const { error } = schemaHidAmicoReader.validate(value);
|
|
68245
68511
|
if (error) {
|
|
68246
|
-
|
|
68247
|
-
throw new
|
|
68512
|
+
import_node_server_utils258.logger.info(`HID Amico reader: ${error.message}`);
|
|
68513
|
+
throw new import_node_server_utils258.BadRequestError(error.message);
|
|
68248
68514
|
}
|
|
68249
68515
|
return {
|
|
68250
68516
|
_id: value._id ? toObjectId23(value._id, "reader ID") : new import_mongodb153.ObjectId(),
|
|
@@ -68270,8 +68536,8 @@ function MHidAmicoReader(value) {
|
|
|
68270
68536
|
function MHidAmicoEvent(value) {
|
|
68271
68537
|
const { error } = schemaHidAmicoEvent.validate(value);
|
|
68272
68538
|
if (error) {
|
|
68273
|
-
|
|
68274
|
-
throw new
|
|
68539
|
+
import_node_server_utils258.logger.info(`HID Amico event: ${error.message}`);
|
|
68540
|
+
throw new import_node_server_utils258.BadRequestError(error.message);
|
|
68275
68541
|
}
|
|
68276
68542
|
return {
|
|
68277
68543
|
_id: value._id ? toObjectId23(value._id, "event ID") : new import_mongodb153.ObjectId(),
|
|
@@ -68289,8 +68555,8 @@ function optionalObjectId(value) {
|
|
|
68289
68555
|
function MHidAmicoIdentity(value) {
|
|
68290
68556
|
const { error } = schemaHidAmicoIdentity.validate(value);
|
|
68291
68557
|
if (error) {
|
|
68292
|
-
|
|
68293
|
-
throw new
|
|
68558
|
+
import_node_server_utils258.logger.info(`HID Amico identity: ${error.message}`);
|
|
68559
|
+
throw new import_node_server_utils258.BadRequestError(error.message);
|
|
68294
68560
|
}
|
|
68295
68561
|
return {
|
|
68296
68562
|
_id: value._id ? toObjectId23(value._id, "identity ID") : new import_mongodb153.ObjectId(),
|
|
@@ -68313,13 +68579,13 @@ function MHidAmicoIdentity(value) {
|
|
|
68313
68579
|
}
|
|
68314
68580
|
|
|
68315
68581
|
// src/repositories/hid-amico.repo.ts
|
|
68316
|
-
var
|
|
68582
|
+
var import_node_server_utils259 = require("@7365admin1/node-server-utils");
|
|
68317
68583
|
var import_mongodb154 = require("mongodb");
|
|
68318
68584
|
function useHidAmicoRepo() {
|
|
68319
68585
|
function db() {
|
|
68320
|
-
const instance =
|
|
68586
|
+
const instance = import_node_server_utils259.useAtlas.getDb();
|
|
68321
68587
|
if (!instance) {
|
|
68322
|
-
throw new
|
|
68588
|
+
throw new import_node_server_utils259.InternalServerError("Unable to connect to server.");
|
|
68323
68589
|
}
|
|
68324
68590
|
return instance;
|
|
68325
68591
|
}
|
|
@@ -68336,7 +68602,7 @@ function useHidAmicoRepo() {
|
|
|
68336
68602
|
try {
|
|
68337
68603
|
return new import_mongodb154.ObjectId(id);
|
|
68338
68604
|
} catch {
|
|
68339
|
-
throw new
|
|
68605
|
+
throw new import_node_server_utils259.BadRequestError(`Invalid ${label} format`);
|
|
68340
68606
|
}
|
|
68341
68607
|
}
|
|
68342
68608
|
function hideSecret(reader) {
|
|
@@ -68387,7 +68653,7 @@ function useHidAmicoRepo() {
|
|
|
68387
68653
|
]);
|
|
68388
68654
|
return "HID Amico indexes created.";
|
|
68389
68655
|
} catch (error) {
|
|
68390
|
-
|
|
68656
|
+
import_node_server_utils259.logger.error(error.message);
|
|
68391
68657
|
throw new Error("Failed to create HID Amico indexes.");
|
|
68392
68658
|
}
|
|
68393
68659
|
}
|
|
@@ -68398,7 +68664,7 @@ function useHidAmicoRepo() {
|
|
|
68398
68664
|
return hideSecret(doc);
|
|
68399
68665
|
} catch (error) {
|
|
68400
68666
|
if (error.message?.includes("duplicate")) {
|
|
68401
|
-
throw new
|
|
68667
|
+
throw new import_node_server_utils259.BadRequestError("HID Amico reader already exists for this site and URL.");
|
|
68402
68668
|
}
|
|
68403
68669
|
throw error;
|
|
68404
68670
|
}
|
|
@@ -68412,7 +68678,7 @@ function useHidAmicoRepo() {
|
|
|
68412
68678
|
}
|
|
68413
68679
|
const items = await readers().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
68414
68680
|
const total = await readers().countDocuments(query);
|
|
68415
|
-
return (0,
|
|
68681
|
+
return (0, import_node_server_utils259.paginate)(items.map(hideSecret), page, limit, total);
|
|
68416
68682
|
}
|
|
68417
68683
|
async function getById(id, options = {}) {
|
|
68418
68684
|
const _id = toId(id, "reader ID");
|
|
@@ -68420,14 +68686,14 @@ function useHidAmicoRepo() {
|
|
|
68420
68686
|
{ _id, status: { $ne: "deleted" } }
|
|
68421
68687
|
);
|
|
68422
68688
|
if (!reader) {
|
|
68423
|
-
throw new
|
|
68689
|
+
throw new import_node_server_utils259.BadRequestError("HID Amico reader not found.");
|
|
68424
68690
|
}
|
|
68425
68691
|
return options.includePassword ? reader : hideSecret(reader);
|
|
68426
68692
|
}
|
|
68427
68693
|
async function updateById(id, value, session) {
|
|
68428
68694
|
const { error } = schemaUpdateHidAmicoReader.validate(value);
|
|
68429
68695
|
if (error) {
|
|
68430
|
-
throw new
|
|
68696
|
+
throw new import_node_server_utils259.BadRequestError(error.message);
|
|
68431
68697
|
}
|
|
68432
68698
|
const _id = toId(id, "reader ID");
|
|
68433
68699
|
const payload = {
|
|
@@ -68446,7 +68712,7 @@ function useHidAmicoRepo() {
|
|
|
68446
68712
|
{ returnDocument: "after", session }
|
|
68447
68713
|
);
|
|
68448
68714
|
if (!updated) {
|
|
68449
|
-
throw new
|
|
68715
|
+
throw new import_node_server_utils259.BadRequestError("HID Amico reader not found.");
|
|
68450
68716
|
}
|
|
68451
68717
|
return hideSecret(updated);
|
|
68452
68718
|
}
|
|
@@ -68475,7 +68741,7 @@ function useHidAmicoRepo() {
|
|
|
68475
68741
|
}
|
|
68476
68742
|
const items = await events().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
68477
68743
|
const total = await events().countDocuments(query);
|
|
68478
|
-
return (0,
|
|
68744
|
+
return (0, import_node_server_utils259.paginate)(items, page, limit, total);
|
|
68479
68745
|
}
|
|
68480
68746
|
async function addIdentity(value, session) {
|
|
68481
68747
|
try {
|
|
@@ -68487,16 +68753,16 @@ function useHidAmicoRepo() {
|
|
|
68487
68753
|
cardNo: identity.cardNo
|
|
68488
68754
|
});
|
|
68489
68755
|
if (existing) {
|
|
68490
|
-
throw new
|
|
68756
|
+
throw new import_node_server_utils259.BadRequestError("HID Amico identity already exists for this reader.");
|
|
68491
68757
|
}
|
|
68492
68758
|
await identities().insertOne(identity, { session });
|
|
68493
68759
|
return identity;
|
|
68494
68760
|
} catch (error) {
|
|
68495
|
-
if (error instanceof
|
|
68761
|
+
if (error instanceof import_node_server_utils259.BadRequestError) {
|
|
68496
68762
|
throw error;
|
|
68497
68763
|
}
|
|
68498
68764
|
if (error.message?.includes("duplicate")) {
|
|
68499
|
-
throw new
|
|
68765
|
+
throw new import_node_server_utils259.BadRequestError("HID Amico identity already exists for this reader.");
|
|
68500
68766
|
}
|
|
68501
68767
|
throw error;
|
|
68502
68768
|
}
|
|
@@ -68521,12 +68787,12 @@ function useHidAmicoRepo() {
|
|
|
68521
68787
|
}
|
|
68522
68788
|
const items = await identities().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
68523
68789
|
const total = await identities().countDocuments(query);
|
|
68524
|
-
return (0,
|
|
68790
|
+
return (0, import_node_server_utils259.paginate)(items, page, limit, total);
|
|
68525
68791
|
}
|
|
68526
68792
|
async function updateIdentity(id, value, session) {
|
|
68527
68793
|
const { error } = schemaUpdateHidAmicoIdentity.validate(value);
|
|
68528
68794
|
if (error) {
|
|
68529
|
-
throw new
|
|
68795
|
+
throw new import_node_server_utils259.BadRequestError(error.message);
|
|
68530
68796
|
}
|
|
68531
68797
|
const payload = {
|
|
68532
68798
|
...value,
|
|
@@ -68554,7 +68820,7 @@ function useHidAmicoRepo() {
|
|
|
68554
68820
|
{ returnDocument: "after", session }
|
|
68555
68821
|
);
|
|
68556
68822
|
if (!updated) {
|
|
68557
|
-
throw new
|
|
68823
|
+
throw new import_node_server_utils259.BadRequestError("HID Amico identity not found.");
|
|
68558
68824
|
}
|
|
68559
68825
|
return updated;
|
|
68560
68826
|
}
|
|
@@ -68611,7 +68877,7 @@ function useHidAmicoRepo() {
|
|
|
68611
68877
|
// src/services/hid-amico.service.ts
|
|
68612
68878
|
var import_crypto3 = __toESM(require("crypto"));
|
|
68613
68879
|
var import_axios4 = __toESM(require("axios"));
|
|
68614
|
-
var
|
|
68880
|
+
var import_node_server_utils260 = require("@7365admin1/node-server-utils");
|
|
68615
68881
|
var PASSWORD_PREFIX = "v1";
|
|
68616
68882
|
function getSecretKey() {
|
|
68617
68883
|
const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
|
|
@@ -68655,7 +68921,7 @@ function toHidRequestError(error, path5) {
|
|
|
68655
68921
|
status ? `status ${status}` : "",
|
|
68656
68922
|
payload ? `response ${payload}` : error.message
|
|
68657
68923
|
].filter(Boolean).join(" - ");
|
|
68658
|
-
return new
|
|
68924
|
+
return new import_node_server_utils260.BadRequestError(detail);
|
|
68659
68925
|
}
|
|
68660
68926
|
return error;
|
|
68661
68927
|
}
|
|
@@ -68697,7 +68963,7 @@ var HidAmicoClient = class {
|
|
|
68697
68963
|
password: decryptSecret(this.reader.password)
|
|
68698
68964
|
});
|
|
68699
68965
|
if (!res.data?.session) {
|
|
68700
|
-
throw new
|
|
68966
|
+
throw new import_node_server_utils260.BadRequestError("HID Amico login failed: missing session.");
|
|
68701
68967
|
}
|
|
68702
68968
|
this.session = res.data.session;
|
|
68703
68969
|
return this.session;
|
|
@@ -68721,7 +68987,7 @@ var HidAmicoClient = class {
|
|
|
68721
68987
|
const payload = JSON.parse(buffer.toString("utf8"));
|
|
68722
68988
|
const image = payload.image || payload.photo || payload.data?.image || payload.data?.photo;
|
|
68723
68989
|
if (!image) {
|
|
68724
|
-
throw new
|
|
68990
|
+
throw new import_node_server_utils260.BadRequestError("HID Amico user image response did not include an image.");
|
|
68725
68991
|
}
|
|
68726
68992
|
return {
|
|
68727
68993
|
contentType: payload.contentType || payload.mimeType || "image/jpeg",
|
|
@@ -68846,7 +69112,7 @@ function useHidAmicoService() {
|
|
|
68846
69112
|
async function getActiveReader(id) {
|
|
68847
69113
|
const reader = await repo.getById(id, { includePassword: true });
|
|
68848
69114
|
if (reader.enabled === false || reader.status === "inactive" || reader.status === "deleted") {
|
|
68849
|
-
throw new
|
|
69115
|
+
throw new import_node_server_utils260.BadRequestError("HID Amico reader is not active.");
|
|
68850
69116
|
}
|
|
68851
69117
|
return reader;
|
|
68852
69118
|
}
|
|
@@ -69101,13 +69367,13 @@ function useHidAmicoService() {
|
|
|
69101
69367
|
}
|
|
69102
69368
|
|
|
69103
69369
|
// src/controllers/hid-amico.controller.ts
|
|
69104
|
-
var
|
|
69370
|
+
var import_node_server_utils261 = require("@7365admin1/node-server-utils");
|
|
69105
69371
|
function useHidAmicoController() {
|
|
69106
69372
|
const service = useHidAmicoService();
|
|
69107
69373
|
async function listReaders(req, res, next) {
|
|
69108
69374
|
const { error, value } = schemaHidAmicoReaderListQuery.validate(req.query);
|
|
69109
69375
|
if (error) {
|
|
69110
|
-
next(new
|
|
69376
|
+
next(new import_node_server_utils261.BadRequestError(error.message));
|
|
69111
69377
|
return;
|
|
69112
69378
|
}
|
|
69113
69379
|
try {
|
|
@@ -69119,7 +69385,7 @@ function useHidAmicoController() {
|
|
|
69119
69385
|
async function createReader(req, res, next) {
|
|
69120
69386
|
const { error, value } = schemaHidAmicoReader.validate(req.body);
|
|
69121
69387
|
if (error) {
|
|
69122
|
-
next(new
|
|
69388
|
+
next(new import_node_server_utils261.BadRequestError(error.message));
|
|
69123
69389
|
return;
|
|
69124
69390
|
}
|
|
69125
69391
|
try {
|
|
@@ -69132,7 +69398,7 @@ function useHidAmicoController() {
|
|
|
69132
69398
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69133
69399
|
const body = schemaUpdateHidAmicoReader.validate(req.body);
|
|
69134
69400
|
if (params.error || body.error) {
|
|
69135
|
-
next(new
|
|
69401
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
|
|
69136
69402
|
return;
|
|
69137
69403
|
}
|
|
69138
69404
|
try {
|
|
@@ -69144,7 +69410,7 @@ function useHidAmicoController() {
|
|
|
69144
69410
|
async function deleteReader(req, res, next) {
|
|
69145
69411
|
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69146
69412
|
if (error) {
|
|
69147
|
-
next(new
|
|
69413
|
+
next(new import_node_server_utils261.BadRequestError(error.message));
|
|
69148
69414
|
return;
|
|
69149
69415
|
}
|
|
69150
69416
|
try {
|
|
@@ -69156,7 +69422,7 @@ function useHidAmicoController() {
|
|
|
69156
69422
|
async function testReader(req, res, next) {
|
|
69157
69423
|
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69158
69424
|
if (error) {
|
|
69159
|
-
next(new
|
|
69425
|
+
next(new import_node_server_utils261.BadRequestError(error.message));
|
|
69160
69426
|
return;
|
|
69161
69427
|
}
|
|
69162
69428
|
try {
|
|
@@ -69169,7 +69435,7 @@ function useHidAmicoController() {
|
|
|
69169
69435
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69170
69436
|
const body = schemaHidAmicoSync.validate(req.body ?? {});
|
|
69171
69437
|
if (params.error || body.error) {
|
|
69172
|
-
next(new
|
|
69438
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
|
|
69173
69439
|
return;
|
|
69174
69440
|
}
|
|
69175
69441
|
try {
|
|
@@ -69182,7 +69448,7 @@ function useHidAmicoController() {
|
|
|
69182
69448
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69183
69449
|
const query = schemaHidAmicoLogQuery.validate(req.query);
|
|
69184
69450
|
if (params.error || query.error) {
|
|
69185
|
-
next(new
|
|
69451
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || query.error?.message));
|
|
69186
69452
|
return;
|
|
69187
69453
|
}
|
|
69188
69454
|
try {
|
|
@@ -69195,7 +69461,7 @@ function useHidAmicoController() {
|
|
|
69195
69461
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69196
69462
|
const query = schemaHidAmicoIdentityQuery.validate(req.query);
|
|
69197
69463
|
if (params.error || query.error) {
|
|
69198
|
-
next(new
|
|
69464
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || query.error?.message));
|
|
69199
69465
|
return;
|
|
69200
69466
|
}
|
|
69201
69467
|
try {
|
|
@@ -69207,13 +69473,13 @@ function useHidAmicoController() {
|
|
|
69207
69473
|
async function createIdentity(req, res, next) {
|
|
69208
69474
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69209
69475
|
if (params.error) {
|
|
69210
|
-
next(new
|
|
69476
|
+
next(new import_node_server_utils261.BadRequestError(params.error.message));
|
|
69211
69477
|
return;
|
|
69212
69478
|
}
|
|
69213
69479
|
try {
|
|
69214
69480
|
const body = schemaCreateHidAmicoIdentity.validate(req.body);
|
|
69215
69481
|
if (body.error) {
|
|
69216
|
-
next(new
|
|
69482
|
+
next(new import_node_server_utils261.BadRequestError(body.error.message));
|
|
69217
69483
|
return;
|
|
69218
69484
|
}
|
|
69219
69485
|
res.status(201).json({ data: await service.createIdentity(params.value.readerId, body.value) });
|
|
@@ -69225,7 +69491,7 @@ function useHidAmicoController() {
|
|
|
69225
69491
|
const params = schemaHidAmicoIdentityIdParams.validate(req.params);
|
|
69226
69492
|
const body = schemaUpdateHidAmicoIdentity.validate(req.body ?? {});
|
|
69227
69493
|
if (params.error || body.error) {
|
|
69228
|
-
next(new
|
|
69494
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
|
|
69229
69495
|
return;
|
|
69230
69496
|
}
|
|
69231
69497
|
try {
|
|
@@ -69237,7 +69503,7 @@ function useHidAmicoController() {
|
|
|
69237
69503
|
async function deleteIdentity(req, res, next) {
|
|
69238
69504
|
const { error, value } = schemaHidAmicoIdentityIdParams.validate(req.params);
|
|
69239
69505
|
if (error) {
|
|
69240
|
-
next(new
|
|
69506
|
+
next(new import_node_server_utils261.BadRequestError(error.message));
|
|
69241
69507
|
return;
|
|
69242
69508
|
}
|
|
69243
69509
|
try {
|
|
@@ -69249,7 +69515,7 @@ function useHidAmicoController() {
|
|
|
69249
69515
|
async function receiveNotification(req, res, next) {
|
|
69250
69516
|
const validation = schemaHidAmicoNotificationParams.validate(req.params);
|
|
69251
69517
|
if (validation.error) {
|
|
69252
|
-
next(new
|
|
69518
|
+
next(new import_node_server_utils261.BadRequestError(validation.error.message));
|
|
69253
69519
|
return;
|
|
69254
69520
|
}
|
|
69255
69521
|
try {
|
|
@@ -69266,7 +69532,7 @@ function useHidAmicoController() {
|
|
|
69266
69532
|
async function getDoorState(req, res, next) {
|
|
69267
69533
|
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69268
69534
|
if (error) {
|
|
69269
|
-
next(new
|
|
69535
|
+
next(new import_node_server_utils261.BadRequestError(error.message));
|
|
69270
69536
|
return;
|
|
69271
69537
|
}
|
|
69272
69538
|
try {
|
|
@@ -69278,7 +69544,7 @@ function useHidAmicoController() {
|
|
|
69278
69544
|
async function getUserImage(req, res, next) {
|
|
69279
69545
|
const { error, value } = schemaHidAmicoUserImageParams.validate(req.params);
|
|
69280
69546
|
if (error) {
|
|
69281
|
-
next(new
|
|
69547
|
+
next(new import_node_server_utils261.BadRequestError(error.message));
|
|
69282
69548
|
return;
|
|
69283
69549
|
}
|
|
69284
69550
|
try {
|
|
@@ -69292,7 +69558,7 @@ function useHidAmicoController() {
|
|
|
69292
69558
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69293
69559
|
const body = schemaHidAmicoExecuteActions.validate(req.body ?? {});
|
|
69294
69560
|
if (params.error || body.error) {
|
|
69295
|
-
next(new
|
|
69561
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
|
|
69296
69562
|
return;
|
|
69297
69563
|
}
|
|
69298
69564
|
try {
|
|
@@ -69305,7 +69571,7 @@ function useHidAmicoController() {
|
|
|
69305
69571
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69306
69572
|
const body = schemaHidAmicoConfiguration.validate(req.body ?? {});
|
|
69307
69573
|
if (params.error || body.error) {
|
|
69308
|
-
next(new
|
|
69574
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
|
|
69309
69575
|
return;
|
|
69310
69576
|
}
|
|
69311
69577
|
try {
|
|
@@ -69318,7 +69584,7 @@ function useHidAmicoController() {
|
|
|
69318
69584
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69319
69585
|
const body = schemaHidAmicoSetConfiguration.validate(req.body ?? {});
|
|
69320
69586
|
if (params.error || body.error) {
|
|
69321
|
-
next(new
|
|
69587
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
|
|
69322
69588
|
return;
|
|
69323
69589
|
}
|
|
69324
69590
|
try {
|
|
@@ -69331,20 +69597,20 @@ function useHidAmicoController() {
|
|
|
69331
69597
|
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69332
69598
|
const body = schemaHidAmicoObjectOperation.validate(req.body ?? {});
|
|
69333
69599
|
if (params.error || body.error) {
|
|
69334
|
-
next(new
|
|
69600
|
+
next(new import_node_server_utils261.BadRequestError(params.error?.message || body.error?.message));
|
|
69335
69601
|
return;
|
|
69336
69602
|
}
|
|
69337
69603
|
const { operation, ...payload } = body.value;
|
|
69338
69604
|
if (operation === "create" && !Array.isArray(payload.values)) {
|
|
69339
|
-
next(new
|
|
69605
|
+
next(new import_node_server_utils261.BadRequestError("values array is required for HID object create operations."));
|
|
69340
69606
|
return;
|
|
69341
69607
|
}
|
|
69342
69608
|
if (operation === "modify" && (!payload.values || Array.isArray(payload.values) || !payload.where)) {
|
|
69343
|
-
next(new
|
|
69609
|
+
next(new import_node_server_utils261.BadRequestError("values object and where are required for HID object modify operations."));
|
|
69344
69610
|
return;
|
|
69345
69611
|
}
|
|
69346
69612
|
if (operation === "destroy" && !payload.where) {
|
|
69347
|
-
next(new
|
|
69613
|
+
next(new import_node_server_utils261.BadRequestError("where is required for HID object destroy operations."));
|
|
69348
69614
|
return;
|
|
69349
69615
|
}
|
|
69350
69616
|
try {
|
|
@@ -69523,6 +69789,7 @@ function useHidAmicoController() {
|
|
|
69523
69789
|
building_units_namespace_collection,
|
|
69524
69790
|
buildings_namespace_collection,
|
|
69525
69791
|
bulletin_boards_namespace_collection,
|
|
69792
|
+
chatPrelovedEvents,
|
|
69526
69793
|
chatSchema,
|
|
69527
69794
|
createManpowerRemarksDaily,
|
|
69528
69795
|
customerSchema,
|
|
@@ -69678,6 +69945,7 @@ function useHidAmicoController() {
|
|
|
69678
69945
|
useAuthServiceV2,
|
|
69679
69946
|
useBidPrelovedController,
|
|
69680
69947
|
useBidPrelovedRepo,
|
|
69948
|
+
useBidPrelovedService,
|
|
69681
69949
|
useBuildingController,
|
|
69682
69950
|
useBuildingLevelController,
|
|
69683
69951
|
useBuildingLevelRepo,
|