@7365admin1/core 2.75.0 → 2.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +43 -6
- package/dist/index.js +1159 -603
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1162 -603
- package/dist/index.mjs.map +1 -1
- package/dist/public/handlebars/registration-pending.hbs +131 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3181,6 +3181,20 @@ function useUserRepo() {
|
|
|
3181
3181
|
throw new import_node_server_utils10.InternalServerError("Failed to update user.");
|
|
3182
3182
|
}
|
|
3183
3183
|
}
|
|
3184
|
+
async function updateUserOrgById(id, org, session) {
|
|
3185
|
+
const _id = (0, import_node_server_utils10.toObjectId)(id);
|
|
3186
|
+
const orgId = (0, import_node_server_utils10.toObjectId)(org);
|
|
3187
|
+
try {
|
|
3188
|
+
await collection.updateOne(
|
|
3189
|
+
{ _id },
|
|
3190
|
+
{ $set: { defaultOrg: orgId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
3191
|
+
{ session }
|
|
3192
|
+
);
|
|
3193
|
+
return "Successfully updated user organization.";
|
|
3194
|
+
} catch (error) {
|
|
3195
|
+
throw new import_node_server_utils10.InternalServerError("Failed to update user organization.");
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3184
3198
|
return {
|
|
3185
3199
|
createIndex,
|
|
3186
3200
|
createTextIndex,
|
|
@@ -3198,7 +3212,8 @@ function useUserRepo() {
|
|
|
3198
3212
|
updateDefaultOrgByEmail,
|
|
3199
3213
|
getUserByEmailStatus,
|
|
3200
3214
|
updateUserSIDById,
|
|
3201
|
-
resetPassword
|
|
3215
|
+
resetPassword,
|
|
3216
|
+
updateUserOrgById
|
|
3202
3217
|
};
|
|
3203
3218
|
}
|
|
3204
3219
|
|
|
@@ -3722,6 +3737,20 @@ function useMemberRepo() {
|
|
|
3722
3737
|
{ $sort: { _id: -1 } },
|
|
3723
3738
|
{ $skip: page * limit },
|
|
3724
3739
|
{ $limit: limit },
|
|
3740
|
+
{
|
|
3741
|
+
$lookup: {
|
|
3742
|
+
from: "organizations",
|
|
3743
|
+
localField: "org",
|
|
3744
|
+
foreignField: "_id",
|
|
3745
|
+
as: "orgData"
|
|
3746
|
+
}
|
|
3747
|
+
},
|
|
3748
|
+
{
|
|
3749
|
+
$unwind: {
|
|
3750
|
+
path: "$orgData",
|
|
3751
|
+
preserveNullAndEmptyArrays: true
|
|
3752
|
+
}
|
|
3753
|
+
},
|
|
3725
3754
|
{
|
|
3726
3755
|
$lookup: {
|
|
3727
3756
|
from: "organizations",
|
|
@@ -3741,7 +3770,16 @@ function useMemberRepo() {
|
|
|
3741
3770
|
_id: "$org",
|
|
3742
3771
|
text: { $first: "$orgName" },
|
|
3743
3772
|
value: { $first: "$org" },
|
|
3744
|
-
defaultSite: { $first: "$defaultSite.defaultSite" }
|
|
3773
|
+
defaultSite: { $first: "$defaultSite.defaultSite" },
|
|
3774
|
+
onboardingRequired: {
|
|
3775
|
+
$first: "$orgData.onboardingRequired"
|
|
3776
|
+
},
|
|
3777
|
+
onboardingCompleted: {
|
|
3778
|
+
$first: "$orgData.onboardingCompleted"
|
|
3779
|
+
},
|
|
3780
|
+
onboardingCompletedAt: {
|
|
3781
|
+
$first: "$orgData.onboardingCompletedAt"
|
|
3782
|
+
}
|
|
3745
3783
|
}
|
|
3746
3784
|
},
|
|
3747
3785
|
{
|
|
@@ -3749,15 +3787,16 @@ function useMemberRepo() {
|
|
|
3749
3787
|
_id: 0,
|
|
3750
3788
|
text: 1,
|
|
3751
3789
|
value: 1,
|
|
3752
|
-
defaultSite: 1
|
|
3790
|
+
defaultSite: 1,
|
|
3791
|
+
onboardingRequired: 1,
|
|
3792
|
+
onboardingCompleted: 1,
|
|
3793
|
+
onboardingCompletedAt: 1
|
|
3753
3794
|
}
|
|
3754
3795
|
}
|
|
3755
3796
|
]).toArray();
|
|
3756
3797
|
const length = await collection.distinct("org", query).then((orgs) => orgs.length);
|
|
3757
3798
|
const data = (0, import_node_server_utils12.paginate)(items, page, limit, length);
|
|
3758
|
-
setCache(cacheKey, data, 15 * 60).
|
|
3759
|
-
import_node_server_utils12.logger.info(`Cache set for key: ${cacheKey}`);
|
|
3760
|
-
}).catch((err) => {
|
|
3799
|
+
setCache(cacheKey, data, 15 * 60).catch((err) => {
|
|
3761
3800
|
import_node_server_utils12.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
3762
3801
|
});
|
|
3763
3802
|
return data;
|
|
@@ -4605,6 +4644,9 @@ var orgSchema = import_joi8.default.object({
|
|
|
4605
4644
|
busInst: import_joi8.default.string().optional().allow("", null),
|
|
4606
4645
|
status: import_joi8.default.string().optional().allow("", null),
|
|
4607
4646
|
defaultSite: import_joi8.default.string().hex().optional().allow("", null),
|
|
4647
|
+
onboardingRequired: import_joi8.default.boolean().optional(),
|
|
4648
|
+
onboardingCompleted: import_joi8.default.boolean().optional(),
|
|
4649
|
+
onboardingCompletedAt: import_joi8.default.date().optional().allow(null),
|
|
4608
4650
|
terms: import_joi8.default.string().optional().allow("", null),
|
|
4609
4651
|
policies: import_joi8.default.string().optional().allow("", null),
|
|
4610
4652
|
createdAt: import_joi8.default.string().optional().allow("", null),
|
|
@@ -4634,6 +4676,9 @@ function MOrg(value) {
|
|
|
4634
4676
|
busInst: value.busInst,
|
|
4635
4677
|
status: value.status || "active",
|
|
4636
4678
|
defaultSite: value.defaultSite,
|
|
4679
|
+
onboardingRequired: value.onboardingRequired || false,
|
|
4680
|
+
onboardingCompleted: value.onboardingCompleted || false,
|
|
4681
|
+
onboardingCompletedAt: value.onboardingCompletedAt || null,
|
|
4637
4682
|
terms: value.terms ?? "",
|
|
4638
4683
|
policies: value.policies ?? "",
|
|
4639
4684
|
createdAt: value.createdAt || /* @__PURE__ */ new Date(),
|
|
@@ -7897,7 +7942,8 @@ function useUserController() {
|
|
|
7897
7942
|
"dateOfBirth",
|
|
7898
7943
|
"profile",
|
|
7899
7944
|
"gender",
|
|
7900
|
-
"defaultOrg"
|
|
7945
|
+
"defaultOrg",
|
|
7946
|
+
"status"
|
|
7901
7947
|
).required(),
|
|
7902
7948
|
value: import_joi13.default.when("field", {
|
|
7903
7949
|
switch: [
|
|
@@ -9334,7 +9380,7 @@ function useOrgController() {
|
|
|
9334
9380
|
return;
|
|
9335
9381
|
}
|
|
9336
9382
|
try {
|
|
9337
|
-
const _id = await _add(req.body);
|
|
9383
|
+
const _id = await _add({ ...req.body, onboardingRequired: true, onboardingCompleted: false, onboardingCompletedAt: null });
|
|
9338
9384
|
const data = await _getById(_id);
|
|
9339
9385
|
res.status(201).json({
|
|
9340
9386
|
message: "Successfully created organization.",
|
|
@@ -15623,10 +15669,10 @@ var import_node_server_utils71 = require("@7365admin1/node-server-utils");
|
|
|
15623
15669
|
var import_node_server_utils70 = require("@7365admin1/node-server-utils");
|
|
15624
15670
|
var import_joi38 = __toESM(require("joi"));
|
|
15625
15671
|
var import_mongodb41 = require("mongodb");
|
|
15626
|
-
var VehicleType = /* @__PURE__ */ ((
|
|
15627
|
-
|
|
15628
|
-
|
|
15629
|
-
return
|
|
15672
|
+
var VehicleType = /* @__PURE__ */ ((VehicleType3) => {
|
|
15673
|
+
VehicleType3["WHITELIST"] = "whitelist";
|
|
15674
|
+
VehicleType3["BLOCKLIST"] = "blocklist";
|
|
15675
|
+
return VehicleType3;
|
|
15630
15676
|
})(VehicleType || {});
|
|
15631
15677
|
var VehicleCategory = /* @__PURE__ */ ((VehicleCategory2) => {
|
|
15632
15678
|
VehicleCategory2["RESIDENT"] = "resident";
|
|
@@ -16686,6 +16732,77 @@ function useDahuaDigest({
|
|
|
16686
16732
|
streaming
|
|
16687
16733
|
});
|
|
16688
16734
|
}
|
|
16735
|
+
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
16736
|
+
function isDahuaInvalidAuthority(value) {
|
|
16737
|
+
const text = String(value || "").toLowerCase();
|
|
16738
|
+
return text.includes("invalid authority");
|
|
16739
|
+
}
|
|
16740
|
+
function getDahuaResponseText(response) {
|
|
16741
|
+
return response?.data?.toString?.("utf-8") ?? "";
|
|
16742
|
+
}
|
|
16743
|
+
function getDahuaStatusCode(response) {
|
|
16744
|
+
return response?.statusCode || response?.status || response?.res?.status;
|
|
16745
|
+
}
|
|
16746
|
+
async function useDahuaDigestWithRetry({
|
|
16747
|
+
host,
|
|
16748
|
+
username,
|
|
16749
|
+
password,
|
|
16750
|
+
endpoint,
|
|
16751
|
+
method = "GET",
|
|
16752
|
+
headers = {},
|
|
16753
|
+
timeout = 1e4,
|
|
16754
|
+
streaming = false,
|
|
16755
|
+
retries = 3,
|
|
16756
|
+
retryDelayMs = 0
|
|
16757
|
+
}) {
|
|
16758
|
+
let lastError;
|
|
16759
|
+
for (let attempt = 1; attempt <= retries; attempt++) {
|
|
16760
|
+
try {
|
|
16761
|
+
const response = await useDahuaDigest({
|
|
16762
|
+
host,
|
|
16763
|
+
username,
|
|
16764
|
+
password,
|
|
16765
|
+
endpoint,
|
|
16766
|
+
method,
|
|
16767
|
+
headers,
|
|
16768
|
+
timeout,
|
|
16769
|
+
streaming
|
|
16770
|
+
});
|
|
16771
|
+
const text = getDahuaResponseText(response);
|
|
16772
|
+
const statusCode = getDahuaStatusCode(response);
|
|
16773
|
+
const isOk = statusCode === 200 && text.includes("OK");
|
|
16774
|
+
if (isOk) {
|
|
16775
|
+
return response;
|
|
16776
|
+
}
|
|
16777
|
+
const shouldRetry = isDahuaInvalidAuthority(text);
|
|
16778
|
+
if (shouldRetry && attempt < retries) {
|
|
16779
|
+
loggerDahua.warn(
|
|
16780
|
+
`[${host}] Dahua Invalid Authority. Retrying ${attempt}/${retries}`
|
|
16781
|
+
);
|
|
16782
|
+
if (retryDelayMs > 0) {
|
|
16783
|
+
await sleep(retryDelayMs);
|
|
16784
|
+
}
|
|
16785
|
+
continue;
|
|
16786
|
+
}
|
|
16787
|
+
throw new Error(`Dahua response: ${text || `HTTP ${statusCode}`}`);
|
|
16788
|
+
} catch (error) {
|
|
16789
|
+
lastError = error;
|
|
16790
|
+
const message = error?.message || String(error);
|
|
16791
|
+
const shouldRetry = isDahuaInvalidAuthority(message);
|
|
16792
|
+
if (shouldRetry && attempt < retries) {
|
|
16793
|
+
loggerDahua.warn(
|
|
16794
|
+
`[${host}] Dahua Invalid Authority error. Retrying ${attempt}/${retries}`
|
|
16795
|
+
);
|
|
16796
|
+
if (retryDelayMs > 0) {
|
|
16797
|
+
await sleep(retryDelayMs);
|
|
16798
|
+
}
|
|
16799
|
+
continue;
|
|
16800
|
+
}
|
|
16801
|
+
throw error;
|
|
16802
|
+
}
|
|
16803
|
+
}
|
|
16804
|
+
throw lastError;
|
|
16805
|
+
}
|
|
16689
16806
|
function createFileNameFromEvent(utcSeconds, utcMilliseconds) {
|
|
16690
16807
|
const date = new Date(utcSeconds * 1e3 + utcMilliseconds);
|
|
16691
16808
|
const year = date.getUTCFullYear();
|
|
@@ -17336,6 +17453,50 @@ function useDahuaService() {
|
|
|
17336
17453
|
);
|
|
17337
17454
|
}
|
|
17338
17455
|
}
|
|
17456
|
+
async function openBarrier(value) {
|
|
17457
|
+
const validation = import_joi40.default.object({
|
|
17458
|
+
host: import_joi40.default.string().required(),
|
|
17459
|
+
username: import_joi40.default.string().required(),
|
|
17460
|
+
password: import_joi40.default.string().required(),
|
|
17461
|
+
plateNumber: import_joi40.default.string().required(),
|
|
17462
|
+
channel: import_joi40.default.number().integer().min(1).default(1)
|
|
17463
|
+
});
|
|
17464
|
+
const { error, value: payload } = validation.validate(value, {
|
|
17465
|
+
stripUnknown: true
|
|
17466
|
+
});
|
|
17467
|
+
if (error) {
|
|
17468
|
+
throw new import_node_server_utils72.BadRequestError(`Validation error: ${error.message}`);
|
|
17469
|
+
}
|
|
17470
|
+
try {
|
|
17471
|
+
const query = new URLSearchParams({
|
|
17472
|
+
action: "openStrobe",
|
|
17473
|
+
channel: String(payload.channel),
|
|
17474
|
+
"info.openType": "Normal",
|
|
17475
|
+
"info.plateNumber": payload.plateNumber || "VISITOR"
|
|
17476
|
+
});
|
|
17477
|
+
const endpoint = `/cgi-bin/trafficSnap.cgi?${query.toString()}`;
|
|
17478
|
+
const response = await useDahuaDigestWithRetry({
|
|
17479
|
+
host: payload.host,
|
|
17480
|
+
username: payload.username,
|
|
17481
|
+
password: payload.password,
|
|
17482
|
+
endpoint,
|
|
17483
|
+
retries: 10,
|
|
17484
|
+
retryDelayMs: 0
|
|
17485
|
+
});
|
|
17486
|
+
const text = response?.data?.toString?.("utf-8") ?? "";
|
|
17487
|
+
if (!text.includes("OK")) {
|
|
17488
|
+
throw new Error(`Failed to open barrier. Dahua response: ${text}`);
|
|
17489
|
+
}
|
|
17490
|
+
return {
|
|
17491
|
+
success: true,
|
|
17492
|
+
message: "Barrier opened successfully",
|
|
17493
|
+
raw: text
|
|
17494
|
+
};
|
|
17495
|
+
} catch (error2) {
|
|
17496
|
+
loggerDahua.error(`[${value.host}] Error opening barrier:`, error2);
|
|
17497
|
+
throw error2;
|
|
17498
|
+
}
|
|
17499
|
+
}
|
|
17339
17500
|
return {
|
|
17340
17501
|
getSnapshot,
|
|
17341
17502
|
listenToCamera,
|
|
@@ -17343,7 +17504,8 @@ function useDahuaService() {
|
|
|
17343
17504
|
removePlateNumber,
|
|
17344
17505
|
updatePlateNumber,
|
|
17345
17506
|
getPlateNumber,
|
|
17346
|
-
bulkInsertPlateNumber
|
|
17507
|
+
bulkInsertPlateNumber,
|
|
17508
|
+
openBarrier
|
|
17347
17509
|
};
|
|
17348
17510
|
}
|
|
17349
17511
|
|
|
@@ -17550,6 +17712,43 @@ function useSiteCameraRepo() {
|
|
|
17550
17712
|
throw new import_node_server_utils73.BadRequestError("Failed to retrieve site cameras.");
|
|
17551
17713
|
}
|
|
17552
17714
|
}
|
|
17715
|
+
async function getVisitorsInBySite(site) {
|
|
17716
|
+
try {
|
|
17717
|
+
const pipeline = [
|
|
17718
|
+
{ $match: { site: (0, import_node_server_utils73.toObjectId)(site), type: "anpr", status: "active", direction: { $in: ["visitors", "entry", "both"] } } },
|
|
17719
|
+
{ $limit: 1 },
|
|
17720
|
+
{
|
|
17721
|
+
$lookup: {
|
|
17722
|
+
from: "anpr-settings",
|
|
17723
|
+
localField: "site",
|
|
17724
|
+
foreignField: "site",
|
|
17725
|
+
as: "anprSettingsDetails"
|
|
17726
|
+
}
|
|
17727
|
+
},
|
|
17728
|
+
{
|
|
17729
|
+
$unwind: {
|
|
17730
|
+
path: "$anprSettingsDetails",
|
|
17731
|
+
preserveNullAndEmptyArrays: true
|
|
17732
|
+
}
|
|
17733
|
+
},
|
|
17734
|
+
{
|
|
17735
|
+
$addFields: {
|
|
17736
|
+
ANPRSwitches: "$anprSettingsDetails.ANPRSwitches"
|
|
17737
|
+
}
|
|
17738
|
+
},
|
|
17739
|
+
{
|
|
17740
|
+
$project: { anprSettingsDetails: 0 }
|
|
17741
|
+
}
|
|
17742
|
+
];
|
|
17743
|
+
const cameras = await collection.aggregate(pipeline).toArray();
|
|
17744
|
+
return cameras?.find((cam) => cam.direction === "visitors" || cam.direction === "entry" || cam.direction === "both");
|
|
17745
|
+
} catch (error) {
|
|
17746
|
+
if (error instanceof import_node_server_utils73.BadRequestError) {
|
|
17747
|
+
throw error;
|
|
17748
|
+
}
|
|
17749
|
+
throw new import_node_server_utils73.BadRequestError("Failed to retrieve site cameras.");
|
|
17750
|
+
}
|
|
17751
|
+
}
|
|
17553
17752
|
async function getBySiteGuardPost(site, guardPost) {
|
|
17554
17753
|
try {
|
|
17555
17754
|
site = new import_mongodb43.ObjectId(site);
|
|
@@ -17904,6 +18103,7 @@ function useSiteCameraRepo() {
|
|
|
17904
18103
|
getAll,
|
|
17905
18104
|
findSiteCameras,
|
|
17906
18105
|
getBySite,
|
|
18106
|
+
getVisitorsInBySite,
|
|
17907
18107
|
getBySites,
|
|
17908
18108
|
delCachedData,
|
|
17909
18109
|
getBySiteGuardPost,
|
|
@@ -26098,13 +26298,14 @@ function useVisitorTransactionService() {
|
|
|
26098
26298
|
getByNRIC,
|
|
26099
26299
|
updateById: _updateById
|
|
26100
26300
|
} = usePersonRepo();
|
|
26101
|
-
const { getBySite: _getBySite } = useSiteCameraRepo();
|
|
26301
|
+
const { getBySite: _getBySite, getVisitorsInBySite: _getVisitorsInBySite } = useSiteCameraRepo();
|
|
26102
26302
|
const { getSiteById: _getSiteById } = useSiteRepo();
|
|
26103
26303
|
const {
|
|
26104
26304
|
addPlateNumber: _addPlateNumber,
|
|
26105
26305
|
removePlateNumber: _removePlateNumber,
|
|
26106
26306
|
getPlateNumber: _getPlateNumber,
|
|
26107
|
-
updatePlateNumber: _updatePlateNumber
|
|
26307
|
+
updatePlateNumber: _updatePlateNumber,
|
|
26308
|
+
openBarrier: _openBarrier
|
|
26108
26309
|
} = useDahuaService();
|
|
26109
26310
|
const { getAllSites: _getAllSites } = useSiteRepo();
|
|
26110
26311
|
const { getByUserId: _getByUserId } = usePersonRepo();
|
|
@@ -26180,28 +26381,30 @@ function useVisitorTransactionService() {
|
|
|
26180
26381
|
"contractor" /* CONTRACTOR */,
|
|
26181
26382
|
"walk-in" /* WALK_IN */,
|
|
26182
26383
|
"guest" /* GUEST */,
|
|
26183
|
-
"delivery" /* DELIVERY
|
|
26184
|
-
|
|
26384
|
+
"delivery" /* DELIVERY */
|
|
26385
|
+
// PersonTypes.PICK_UP,
|
|
26185
26386
|
];
|
|
26186
26387
|
const start = value.checkIn ? new Date(value.checkIn) : /* @__PURE__ */ new Date();
|
|
26187
26388
|
try {
|
|
26188
26389
|
session?.startTransaction();
|
|
26189
26390
|
let camera;
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
|
|
26193
|
-
|
|
26194
|
-
|
|
26195
|
-
|
|
26391
|
+
if (value.site && value.plateNumber) {
|
|
26392
|
+
try {
|
|
26393
|
+
camera = await _getVisitorsInBySite(value.site);
|
|
26394
|
+
if (!camera) {
|
|
26395
|
+
import_node_server_utils106.logger.warn(`No camera document found for site: ${value.site}`);
|
|
26396
|
+
}
|
|
26397
|
+
} catch (error) {
|
|
26398
|
+
import_node_server_utils106.logger.error(
|
|
26399
|
+
`Error _getVisitorsInBySite camera for site ${value.site}:`,
|
|
26400
|
+
error
|
|
26401
|
+
);
|
|
26402
|
+
}
|
|
26196
26403
|
}
|
|
26197
26404
|
if (!value.unitName && value.unit) {
|
|
26198
26405
|
const unit = await _getUnitById(value.unit);
|
|
26199
26406
|
value.unitName = unit?.name;
|
|
26200
26407
|
}
|
|
26201
|
-
const hourExpiration = site?.dahuaTimeExpiration ? site?.dahuaTimeExpiration : 24 * 60;
|
|
26202
|
-
const end = value.checkOut ? new Date(value.checkOut) : new Date(start.getTime() + hourExpiration * 60 * 1e3);
|
|
26203
|
-
const startDahuaDate = formatDahuaDate(start);
|
|
26204
|
-
const endDahuaDate = formatDahuaDate(end);
|
|
26205
26408
|
if (allowedPersonTypes.includes(value?.type)) {
|
|
26206
26409
|
const nric = value?.nric || "";
|
|
26207
26410
|
const person = await getByNRIC(nric);
|
|
@@ -26238,7 +26441,7 @@ function useVisitorTransactionService() {
|
|
|
26238
26441
|
block,
|
|
26239
26442
|
level,
|
|
26240
26443
|
unit,
|
|
26241
|
-
site
|
|
26444
|
+
site,
|
|
26242
26445
|
org,
|
|
26243
26446
|
type,
|
|
26244
26447
|
company,
|
|
@@ -26294,14 +26497,14 @@ function useVisitorTransactionService() {
|
|
|
26294
26497
|
level,
|
|
26295
26498
|
unit,
|
|
26296
26499
|
unitName,
|
|
26297
|
-
site
|
|
26500
|
+
site,
|
|
26298
26501
|
org,
|
|
26299
26502
|
type,
|
|
26300
26503
|
company,
|
|
26301
26504
|
remarks,
|
|
26302
26505
|
contractorType,
|
|
26303
26506
|
checkIn: start,
|
|
26304
|
-
expiredAt: end,
|
|
26507
|
+
// expiredAt: end,
|
|
26305
26508
|
visitorPass: visitorPass ?? [],
|
|
26306
26509
|
passKeys: passKeys ?? [],
|
|
26307
26510
|
status: "registered" /* REGISTERED */
|
|
@@ -26312,11 +26515,13 @@ function useVisitorTransactionService() {
|
|
|
26312
26515
|
);
|
|
26313
26516
|
}
|
|
26314
26517
|
}
|
|
26518
|
+
let host;
|
|
26519
|
+
let username;
|
|
26520
|
+
let password;
|
|
26315
26521
|
if (camera && value.plateNumber && camera.host && camera.username && camera.password) {
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
|
|
26319
|
-
const redlist = "TrafficRedList" /* TRAFFIC_REDLIST */;
|
|
26522
|
+
host = camera.host;
|
|
26523
|
+
username = camera.username;
|
|
26524
|
+
password = camera.password;
|
|
26320
26525
|
const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
|
|
26321
26526
|
const _plateNumber = value.plateNumber;
|
|
26322
26527
|
const dahuaBlocklistQuery = {
|
|
@@ -26332,74 +26537,6 @@ function useVisitorTransactionService() {
|
|
|
26332
26537
|
const found = foundMatch ? Number(foundMatch[1]) : 0;
|
|
26333
26538
|
if (found === 1)
|
|
26334
26539
|
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
26335
|
-
const dahuaQuery = {
|
|
26336
|
-
host,
|
|
26337
|
-
username,
|
|
26338
|
-
password,
|
|
26339
|
-
plateNumber: _plateNumber,
|
|
26340
|
-
mode: redlist
|
|
26341
|
-
};
|
|
26342
|
-
const raw = await _getPlateNumber(dahuaQuery);
|
|
26343
|
-
const parsed = parseDahuaFind(raw);
|
|
26344
|
-
if (!parsed.exists) {
|
|
26345
|
-
const dahuaPayload = {
|
|
26346
|
-
host,
|
|
26347
|
-
username,
|
|
26348
|
-
password,
|
|
26349
|
-
plateNumber: _plateNumber,
|
|
26350
|
-
mode: redlist,
|
|
26351
|
-
start: startDahuaDate,
|
|
26352
|
-
end: endDahuaDate,
|
|
26353
|
-
owner: value.name ?? "",
|
|
26354
|
-
isOpenGate: site?.isOpenGate ?? true
|
|
26355
|
-
};
|
|
26356
|
-
const dahuaResponse = await _addPlateNumber(dahuaPayload);
|
|
26357
|
-
if (dahuaResponse?.statusCode !== 200) {
|
|
26358
|
-
throw new import_node_server_utils106.BadRequestError(
|
|
26359
|
-
`Failed to add plate number to ANPR whitelist`
|
|
26360
|
-
);
|
|
26361
|
-
}
|
|
26362
|
-
const responseData = dahuaResponse?.data?.toString("utf-8") ?? "";
|
|
26363
|
-
value.recNo = responseData.split("=")[1]?.trim();
|
|
26364
|
-
value.checkIn = start;
|
|
26365
|
-
value.expiredAt = end;
|
|
26366
|
-
const vehiclePayload = {
|
|
26367
|
-
name: value.name ?? "",
|
|
26368
|
-
category: value.type,
|
|
26369
|
-
org: value.org,
|
|
26370
|
-
site: value.site,
|
|
26371
|
-
plateNumber: value.plateNumber,
|
|
26372
|
-
type: "whitelist" /* WHITELIST */,
|
|
26373
|
-
nric: value.nric,
|
|
26374
|
-
start,
|
|
26375
|
-
end,
|
|
26376
|
-
recNo: value.recNo,
|
|
26377
|
-
...value.block && { block: value.block },
|
|
26378
|
-
...value.level && { level: value.level },
|
|
26379
|
-
...value.unit && { unit: value.unit }
|
|
26380
|
-
};
|
|
26381
|
-
await addVehicle(vehiclePayload);
|
|
26382
|
-
} else {
|
|
26383
|
-
const dahuaPayload = {
|
|
26384
|
-
host,
|
|
26385
|
-
username,
|
|
26386
|
-
password,
|
|
26387
|
-
plateNumber: _plateNumber,
|
|
26388
|
-
recno: parsed.recNo,
|
|
26389
|
-
mode: redlist,
|
|
26390
|
-
start: startDahuaDate,
|
|
26391
|
-
end: endDahuaDate,
|
|
26392
|
-
owner: value.name ?? "",
|
|
26393
|
-
isOpenGate: site?.isOpenGate ?? true
|
|
26394
|
-
};
|
|
26395
|
-
const dahuaResponse = await _updatePlateNumber(dahuaPayload);
|
|
26396
|
-
if (dahuaResponse?.statusCode !== 200) {
|
|
26397
|
-
throw new import_node_server_utils106.BadRequestError(
|
|
26398
|
-
`Failed to update plate number to ANPR ${"whitelist" /* WHITELIST */}`
|
|
26399
|
-
);
|
|
26400
|
-
}
|
|
26401
|
-
value.recNo = parsed.recNo;
|
|
26402
|
-
}
|
|
26403
26540
|
}
|
|
26404
26541
|
if (value.visitorPass && Array.isArray(value.visitorPass) && value.visitorPass.length > 0 && value.visitorPass) {
|
|
26405
26542
|
for (const vp of value.visitorPass) {
|
|
@@ -26437,6 +26574,27 @@ function useVisitorTransactionService() {
|
|
|
26437
26574
|
}
|
|
26438
26575
|
const result = await _add(value, session);
|
|
26439
26576
|
await session?.commitTransaction();
|
|
26577
|
+
let openBarrier = null;
|
|
26578
|
+
const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
|
|
26579
|
+
if (isOpenBarrier && value.plateNumber && host && username && password) {
|
|
26580
|
+
try {
|
|
26581
|
+
import_node_server_utils106.logger.info(`Attempting to open barrier at host: ${host}`);
|
|
26582
|
+
openBarrier = await _openBarrier({
|
|
26583
|
+
host,
|
|
26584
|
+
username,
|
|
26585
|
+
password,
|
|
26586
|
+
plateNumber: value?.plateNumber
|
|
26587
|
+
});
|
|
26588
|
+
import_node_server_utils106.logger.info(`Barrier command sent successfully to ${host}`, { response: openBarrier });
|
|
26589
|
+
} catch (error) {
|
|
26590
|
+
import_node_server_utils106.logger.error(
|
|
26591
|
+
`Failed to open barrier at host ${host}. Critical system error:`,
|
|
26592
|
+
error
|
|
26593
|
+
);
|
|
26594
|
+
openBarrier = { success: false, error: error?.message };
|
|
26595
|
+
}
|
|
26596
|
+
}
|
|
26597
|
+
console.log("Open barrier response:", openBarrier);
|
|
26440
26598
|
return result;
|
|
26441
26599
|
} catch (error) {
|
|
26442
26600
|
await session?.abortTransaction();
|
|
@@ -26449,6 +26607,43 @@ function useVisitorTransactionService() {
|
|
|
26449
26607
|
const session = import_node_server_utils106.useAtlas.getClient()?.startSession();
|
|
26450
26608
|
session?.startTransaction();
|
|
26451
26609
|
try {
|
|
26610
|
+
let camera;
|
|
26611
|
+
let host;
|
|
26612
|
+
let username;
|
|
26613
|
+
let password;
|
|
26614
|
+
if (value.site && value.plateNumber) {
|
|
26615
|
+
try {
|
|
26616
|
+
camera = await _getVisitorsInBySite(value.site);
|
|
26617
|
+
if (!camera) {
|
|
26618
|
+
import_node_server_utils106.logger.warn(`No camera document found for site: ${value.site}`);
|
|
26619
|
+
}
|
|
26620
|
+
} catch (error) {
|
|
26621
|
+
import_node_server_utils106.logger.error(
|
|
26622
|
+
`Error _getVisitorsInBySite camera for site ${value.site}:`,
|
|
26623
|
+
error
|
|
26624
|
+
);
|
|
26625
|
+
}
|
|
26626
|
+
}
|
|
26627
|
+
if (camera && value.plateNumber && camera.host && camera.username && camera.password) {
|
|
26628
|
+
host = camera.host;
|
|
26629
|
+
username = camera.username;
|
|
26630
|
+
password = camera.password;
|
|
26631
|
+
const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
|
|
26632
|
+
const _plateNumber = value.plateNumber;
|
|
26633
|
+
const dahuaBlocklistQuery = {
|
|
26634
|
+
host,
|
|
26635
|
+
username,
|
|
26636
|
+
password,
|
|
26637
|
+
plateNumber: _plateNumber,
|
|
26638
|
+
mode: blacklist
|
|
26639
|
+
};
|
|
26640
|
+
const isBlocklistedRaw = await _getPlateNumber(dahuaBlocklistQuery);
|
|
26641
|
+
const rawString = isBlocklistedRaw?.toString?.("utf-8") ?? String(isBlocklistedRaw);
|
|
26642
|
+
const foundMatch = rawString.match(/found=(\d+)/);
|
|
26643
|
+
const found = foundMatch ? Number(foundMatch[1]) : 0;
|
|
26644
|
+
if (found === 1)
|
|
26645
|
+
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
26646
|
+
}
|
|
26452
26647
|
if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
26453
26648
|
const keptVisitorPass = [];
|
|
26454
26649
|
for (const vp of value.visitorPass) {
|
|
@@ -26512,6 +26707,34 @@ function useVisitorTransactionService() {
|
|
|
26512
26707
|
value.unitName = unit?.name;
|
|
26513
26708
|
}
|
|
26514
26709
|
await _updateVisitorTansactionById(id, value, session);
|
|
26710
|
+
const allowedPersonTypes = [
|
|
26711
|
+
"contractor" /* CONTRACTOR */,
|
|
26712
|
+
"walk-in" /* WALK_IN */,
|
|
26713
|
+
"guest" /* GUEST */,
|
|
26714
|
+
"delivery" /* DELIVERY */
|
|
26715
|
+
// PersonTypes.PICK_UP,
|
|
26716
|
+
];
|
|
26717
|
+
let openBarrier = null;
|
|
26718
|
+
const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
|
|
26719
|
+
if (isOpenBarrier && value.plateNumber && host && username && password) {
|
|
26720
|
+
try {
|
|
26721
|
+
import_node_server_utils106.logger.info(`Attempting to open barrier at host: ${host}`);
|
|
26722
|
+
openBarrier = await _openBarrier({
|
|
26723
|
+
host,
|
|
26724
|
+
username,
|
|
26725
|
+
password,
|
|
26726
|
+
plateNumber: value?.plateNumber
|
|
26727
|
+
});
|
|
26728
|
+
import_node_server_utils106.logger.info(`Barrier command sent successfully to ${host}`, { response: openBarrier });
|
|
26729
|
+
} catch (error) {
|
|
26730
|
+
import_node_server_utils106.logger.error(
|
|
26731
|
+
`Failed to open barrier at host ${host}. Critical system error:`,
|
|
26732
|
+
error
|
|
26733
|
+
);
|
|
26734
|
+
openBarrier = { success: false, error: error?.message };
|
|
26735
|
+
}
|
|
26736
|
+
}
|
|
26737
|
+
console.log("Open barrier response:", openBarrier);
|
|
26515
26738
|
await session?.commitTransaction();
|
|
26516
26739
|
return "Successfully updated visitor transaction.";
|
|
26517
26740
|
} catch (error) {
|
|
@@ -27458,6 +27681,7 @@ var import_node_server_utils112 = require("@7365admin1/node-server-utils");
|
|
|
27458
27681
|
|
|
27459
27682
|
// src/services/person.service.ts
|
|
27460
27683
|
var import_node_server_utils111 = require("@7365admin1/node-server-utils");
|
|
27684
|
+
var import_mongodb64 = require("mongodb");
|
|
27461
27685
|
function usePersonService() {
|
|
27462
27686
|
const MailerConfig = {
|
|
27463
27687
|
host: MAILER_TRANSPORT_HOST,
|
|
@@ -27479,7 +27703,8 @@ function usePersonService() {
|
|
|
27479
27703
|
createUser: addUser,
|
|
27480
27704
|
getUserByEmail,
|
|
27481
27705
|
updateUserFieldById: _updateUserFieldById,
|
|
27482
|
-
getUserById
|
|
27706
|
+
getUserById,
|
|
27707
|
+
updateUserOrgById: _updateUserOrgById
|
|
27483
27708
|
} = useUserRepo();
|
|
27484
27709
|
const { add: addMember } = useMemberRepo();
|
|
27485
27710
|
const { getById: _getUnitById, updateById: updateUnitById } = useBuildingUnitRepo();
|
|
@@ -27570,8 +27795,27 @@ function usePersonService() {
|
|
|
27570
27795
|
}
|
|
27571
27796
|
await _add(value, session);
|
|
27572
27797
|
await session.commitTransaction();
|
|
27798
|
+
if (value.email && isValidType && value.platform === "mobile") {
|
|
27799
|
+
const emailContent = (0, import_node_server_utils111.compileHandlebar)({
|
|
27800
|
+
context: { name: value.name },
|
|
27801
|
+
filePath: (0, import_node_server_utils111.getDirectory)(
|
|
27802
|
+
__dirname,
|
|
27803
|
+
"./public/handlebars/registration-pending"
|
|
27804
|
+
)
|
|
27805
|
+
});
|
|
27806
|
+
mailer.sendMail({
|
|
27807
|
+
to: value.email,
|
|
27808
|
+
subject: "Registration Received \u2013 Pending Review",
|
|
27809
|
+
html: emailContent,
|
|
27810
|
+
sender: "iService365"
|
|
27811
|
+
}).catch((error) => {
|
|
27812
|
+
import_node_server_utils111.logger.error(`Failed to send registration pending email: ${error}`);
|
|
27813
|
+
});
|
|
27814
|
+
}
|
|
27573
27815
|
return "People added successfully.";
|
|
27574
27816
|
} catch (error) {
|
|
27817
|
+
console.log("error message service", error);
|
|
27818
|
+
console.log("error message service", error.message);
|
|
27575
27819
|
import_node_server_utils111.logger.error("Error in people service add:", error);
|
|
27576
27820
|
await session.abortTransaction();
|
|
27577
27821
|
throw error;
|
|
@@ -27592,7 +27836,21 @@ function usePersonService() {
|
|
|
27592
27836
|
}
|
|
27593
27837
|
const isNameUpdated = typeof value.name === "string" && value.name.trim() !== person.name;
|
|
27594
27838
|
const isOwnerChanged = value.isOwner !== person.isOwner;
|
|
27839
|
+
if (value.org && typeof value.org === "string") {
|
|
27840
|
+
value.org = new import_mongodb64.ObjectId(value.org);
|
|
27841
|
+
}
|
|
27842
|
+
if (value.site && typeof value.site === "string") {
|
|
27843
|
+
value.site = new import_mongodb64.ObjectId(value.site);
|
|
27844
|
+
}
|
|
27845
|
+
const isOrgChanged = value.org && person.org?.toString() !== value.org.toString();
|
|
27595
27846
|
await _updateById(_id, value, session);
|
|
27847
|
+
if (isOrgChanged && person.user) {
|
|
27848
|
+
await _updateUserOrgById(
|
|
27849
|
+
person.user.toString(),
|
|
27850
|
+
value.org,
|
|
27851
|
+
session
|
|
27852
|
+
);
|
|
27853
|
+
}
|
|
27596
27854
|
if (value.unit && (isNameUpdated || isOwnerChanged || value.isOwner)) {
|
|
27597
27855
|
const unit = await _getUnitById(value.unit.toString());
|
|
27598
27856
|
if (unit) {
|
|
@@ -27614,7 +27872,11 @@ function usePersonService() {
|
|
|
27614
27872
|
updatePayload.ownerName = value.name || "";
|
|
27615
27873
|
}
|
|
27616
27874
|
if (Object.keys(updatePayload).length > 0 && unit && unit._id) {
|
|
27617
|
-
await updateUnitById(
|
|
27875
|
+
await updateUnitById(
|
|
27876
|
+
unit._id.toString(),
|
|
27877
|
+
updatePayload,
|
|
27878
|
+
session
|
|
27879
|
+
);
|
|
27618
27880
|
}
|
|
27619
27881
|
}
|
|
27620
27882
|
}
|
|
@@ -27704,13 +27966,13 @@ function usePersonService() {
|
|
|
27704
27966
|
title = "We request resubmission for your application";
|
|
27705
27967
|
hideLogin = false;
|
|
27706
27968
|
statusLogo = `${statusIconPath}/resubmission-icon.png`;
|
|
27707
|
-
message2 = `Hi ${person.name}, please resubmit your application with the required updates
|
|
27969
|
+
message2 = `Hi ${person.name}, please resubmit your application with the required updates.${value.remarks ? ` Remarks: ${value.remarks}` : ""}`;
|
|
27708
27970
|
break;
|
|
27709
27971
|
case "rejected":
|
|
27710
27972
|
userStatus = "rejected";
|
|
27711
|
-
title = "Your account request for
|
|
27973
|
+
title = "Your account request for application has been rejected.";
|
|
27712
27974
|
statusLogo = `${statusIconPath}/deleted-icon.png`;
|
|
27713
|
-
message2 = `Hi ${person.name}, unfortunately your application has been rejected. Please contact support for more information
|
|
27975
|
+
message2 = `Hi ${person.name}, unfortunately your application has been rejected.${value.remarks ? ` Remarks: ${value.remarks}` : " Please contact support for more information."}`;
|
|
27714
27976
|
break;
|
|
27715
27977
|
default:
|
|
27716
27978
|
throw new Error("Invalid review status");
|
|
@@ -28147,7 +28409,7 @@ function usePersonController() {
|
|
|
28147
28409
|
// src/models/robot.model.ts
|
|
28148
28410
|
var import_node_server_utils113 = require("@7365admin1/node-server-utils");
|
|
28149
28411
|
var import_joi61 = __toESM(require("joi"));
|
|
28150
|
-
var
|
|
28412
|
+
var import_mongodb65 = require("mongodb");
|
|
28151
28413
|
var metadataSchema4 = {
|
|
28152
28414
|
orgId: import_joi61.default.string().hex().optional().allow("", null),
|
|
28153
28415
|
siteId: import_joi61.default.string().hex().optional().allow("", null),
|
|
@@ -28172,21 +28434,21 @@ function MRobot(value) {
|
|
|
28172
28434
|
}
|
|
28173
28435
|
if (value.metadata?.orgId) {
|
|
28174
28436
|
try {
|
|
28175
|
-
value.metadata.orgId = new
|
|
28437
|
+
value.metadata.orgId = new import_mongodb65.ObjectId(value.metadata.orgId);
|
|
28176
28438
|
} catch (error2) {
|
|
28177
28439
|
throw new import_node_server_utils113.BadRequestError("Invalid organization ID format.");
|
|
28178
28440
|
}
|
|
28179
28441
|
}
|
|
28180
28442
|
if (value.metadata?.siteId) {
|
|
28181
28443
|
try {
|
|
28182
|
-
value.metadata.siteId = new
|
|
28444
|
+
value.metadata.siteId = new import_mongodb65.ObjectId(value.metadata.siteId);
|
|
28183
28445
|
} catch (error2) {
|
|
28184
28446
|
throw new import_node_server_utils113.BadRequestError("Invalid site ID format.");
|
|
28185
28447
|
}
|
|
28186
28448
|
}
|
|
28187
28449
|
if (value.metadata?.administratorId) {
|
|
28188
28450
|
try {
|
|
28189
|
-
value.metadata.administratorId = new
|
|
28451
|
+
value.metadata.administratorId = new import_mongodb65.ObjectId(
|
|
28190
28452
|
value.metadata.administratorId
|
|
28191
28453
|
);
|
|
28192
28454
|
} catch (error2) {
|
|
@@ -28195,7 +28457,7 @@ function MRobot(value) {
|
|
|
28195
28457
|
}
|
|
28196
28458
|
if (value.createdBy) {
|
|
28197
28459
|
try {
|
|
28198
|
-
value.createdBy = new
|
|
28460
|
+
value.createdBy = new import_mongodb65.ObjectId(value.createdBy);
|
|
28199
28461
|
} catch (error2) {
|
|
28200
28462
|
throw new import_node_server_utils113.BadRequestError("Invalid created by ID format.");
|
|
28201
28463
|
}
|
|
@@ -28220,7 +28482,7 @@ function MRobot(value) {
|
|
|
28220
28482
|
}
|
|
28221
28483
|
|
|
28222
28484
|
// src/repositories/robot.repo.ts
|
|
28223
|
-
var
|
|
28485
|
+
var import_mongodb66 = require("mongodb");
|
|
28224
28486
|
var import_node_server_utils114 = require("@7365admin1/node-server-utils");
|
|
28225
28487
|
function useRobotRepo() {
|
|
28226
28488
|
const db = import_node_server_utils114.useAtlas.getDb();
|
|
@@ -28281,12 +28543,12 @@ function useRobotRepo() {
|
|
|
28281
28543
|
}) {
|
|
28282
28544
|
page = page > 0 ? page - 1 : 0;
|
|
28283
28545
|
try {
|
|
28284
|
-
organization = new
|
|
28546
|
+
organization = new import_mongodb66.ObjectId(organization);
|
|
28285
28547
|
} catch (error) {
|
|
28286
28548
|
throw new import_node_server_utils114.BadRequestError("Invalid organization ID format.");
|
|
28287
28549
|
}
|
|
28288
28550
|
try {
|
|
28289
|
-
site = new
|
|
28551
|
+
site = new import_mongodb66.ObjectId(site);
|
|
28290
28552
|
} catch (error) {
|
|
28291
28553
|
throw new import_node_server_utils114.BadRequestError("Invalid site ID format.");
|
|
28292
28554
|
}
|
|
@@ -28509,7 +28771,7 @@ function useRobotController() {
|
|
|
28509
28771
|
|
|
28510
28772
|
// src/models/patrol-question.model.ts
|
|
28511
28773
|
var import_node_server_utils117 = require("@7365admin1/node-server-utils");
|
|
28512
|
-
var
|
|
28774
|
+
var import_mongodb67 = require("mongodb");
|
|
28513
28775
|
var import_joi63 = __toESM(require("joi"));
|
|
28514
28776
|
var schemaPatrolQuestion = import_joi63.default.object({
|
|
28515
28777
|
_id: import_joi63.default.string().hex().optional(),
|
|
@@ -28535,14 +28797,14 @@ function MPatrolQuestion(value) {
|
|
|
28535
28797
|
}
|
|
28536
28798
|
if (value._id && typeof value._id === "string") {
|
|
28537
28799
|
try {
|
|
28538
|
-
value._id = new
|
|
28800
|
+
value._id = new import_mongodb67.ObjectId(value._id);
|
|
28539
28801
|
} catch {
|
|
28540
28802
|
throw new import_node_server_utils117.BadRequestError("Invalid _id format");
|
|
28541
28803
|
}
|
|
28542
28804
|
}
|
|
28543
28805
|
return {
|
|
28544
|
-
_id: value._id ?? new
|
|
28545
|
-
site: new
|
|
28806
|
+
_id: value._id ?? new import_mongodb67.ObjectId(),
|
|
28807
|
+
site: new import_mongodb67.ObjectId(value.site),
|
|
28546
28808
|
question: value.question,
|
|
28547
28809
|
answers: value.answers,
|
|
28548
28810
|
status: value.status ?? "active",
|
|
@@ -28554,7 +28816,7 @@ function MPatrolQuestion(value) {
|
|
|
28554
28816
|
|
|
28555
28817
|
// src/repositories/patrol-question.repo.ts
|
|
28556
28818
|
var import_node_server_utils118 = require("@7365admin1/node-server-utils");
|
|
28557
|
-
var
|
|
28819
|
+
var import_mongodb68 = require("mongodb");
|
|
28558
28820
|
function usePatrolQuestionRepo() {
|
|
28559
28821
|
const db = import_node_server_utils118.useAtlas.getDb();
|
|
28560
28822
|
if (!db) {
|
|
@@ -28633,7 +28895,7 @@ function usePatrolQuestionRepo() {
|
|
|
28633
28895
|
{ answers: { $regex: search, $options: "i" } }
|
|
28634
28896
|
]
|
|
28635
28897
|
},
|
|
28636
|
-
...
|
|
28898
|
+
...import_mongodb68.ObjectId.isValid(site) && { site: new import_mongodb68.ObjectId(site) }
|
|
28637
28899
|
};
|
|
28638
28900
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
28639
28901
|
const cacheOptions = {
|
|
@@ -28673,7 +28935,7 @@ function usePatrolQuestionRepo() {
|
|
|
28673
28935
|
}
|
|
28674
28936
|
async function updateById(_id, value, session) {
|
|
28675
28937
|
try {
|
|
28676
|
-
_id = new
|
|
28938
|
+
_id = new import_mongodb68.ObjectId(_id);
|
|
28677
28939
|
} catch (error) {
|
|
28678
28940
|
throw new import_node_server_utils118.BadRequestError(
|
|
28679
28941
|
"Invalid patrol question transaction ID format."
|
|
@@ -28694,7 +28956,7 @@ function usePatrolQuestionRepo() {
|
|
|
28694
28956
|
}
|
|
28695
28957
|
async function deleteById(_id) {
|
|
28696
28958
|
try {
|
|
28697
|
-
_id = new
|
|
28959
|
+
_id = new import_mongodb68.ObjectId(_id);
|
|
28698
28960
|
} catch (error) {
|
|
28699
28961
|
throw new import_node_server_utils118.BadRequestError("Invalid customer ID format.");
|
|
28700
28962
|
}
|
|
@@ -28716,7 +28978,7 @@ function usePatrolQuestionRepo() {
|
|
|
28716
28978
|
}
|
|
28717
28979
|
async function getById(_id, session) {
|
|
28718
28980
|
try {
|
|
28719
|
-
_id = new
|
|
28981
|
+
_id = new import_mongodb68.ObjectId(_id);
|
|
28720
28982
|
} catch (error) {
|
|
28721
28983
|
throw new import_node_server_utils118.BadRequestError("Invalid patrol question ID format.");
|
|
28722
28984
|
}
|
|
@@ -28891,7 +29153,7 @@ function usePatrolQuestionController() {
|
|
|
28891
29153
|
|
|
28892
29154
|
// src/models/patrol-route.model.ts
|
|
28893
29155
|
var import_node_server_utils120 = require("@7365admin1/node-server-utils");
|
|
28894
|
-
var
|
|
29156
|
+
var import_mongodb69 = require("mongodb");
|
|
28895
29157
|
var import_joi65 = __toESM(require("joi"));
|
|
28896
29158
|
var schemeCamera = import_joi65.default.object({
|
|
28897
29159
|
camera: import_joi65.default.string().hex().required(),
|
|
@@ -28939,14 +29201,14 @@ function MPatrolRoute(value) {
|
|
|
28939
29201
|
}
|
|
28940
29202
|
if (value._id && typeof value._id === "string") {
|
|
28941
29203
|
try {
|
|
28942
|
-
value._id = new
|
|
29204
|
+
value._id = new import_mongodb69.ObjectId(value._id);
|
|
28943
29205
|
} catch {
|
|
28944
29206
|
throw new import_node_server_utils120.BadRequestError("Invalid _id format");
|
|
28945
29207
|
}
|
|
28946
29208
|
}
|
|
28947
29209
|
if (value.assignee && Array.isArray(value.assignee)) {
|
|
28948
29210
|
try {
|
|
28949
|
-
value.assignee = value.assignee.map((id) => new
|
|
29211
|
+
value.assignee = value.assignee.map((id) => new import_mongodb69.ObjectId(id));
|
|
28950
29212
|
} catch {
|
|
28951
29213
|
throw new import_node_server_utils120.BadRequestError("Invalid assignee id format");
|
|
28952
29214
|
}
|
|
@@ -28955,7 +29217,7 @@ function MPatrolRoute(value) {
|
|
|
28955
29217
|
value.cameras = value.cameras.map((camera) => {
|
|
28956
29218
|
if (typeof camera.camera === "string") {
|
|
28957
29219
|
try {
|
|
28958
|
-
camera.camera = new
|
|
29220
|
+
camera.camera = new import_mongodb69.ObjectId(camera.camera);
|
|
28959
29221
|
} catch {
|
|
28960
29222
|
throw new import_node_server_utils120.BadRequestError("Invalid camera id format");
|
|
28961
29223
|
}
|
|
@@ -28963,7 +29225,7 @@ function MPatrolRoute(value) {
|
|
|
28963
29225
|
camera.questions = camera.questions.map((question) => {
|
|
28964
29226
|
if (typeof question.questionId === "string") {
|
|
28965
29227
|
try {
|
|
28966
|
-
question.questionId = new
|
|
29228
|
+
question.questionId = new import_mongodb69.ObjectId(question.questionId);
|
|
28967
29229
|
} catch {
|
|
28968
29230
|
throw new import_node_server_utils120.BadRequestError("Invalid question id format");
|
|
28969
29231
|
}
|
|
@@ -28974,8 +29236,8 @@ function MPatrolRoute(value) {
|
|
|
28974
29236
|
});
|
|
28975
29237
|
}
|
|
28976
29238
|
return {
|
|
28977
|
-
_id: value._id ?? new
|
|
28978
|
-
site: new
|
|
29239
|
+
_id: value._id ?? new import_mongodb69.ObjectId(),
|
|
29240
|
+
site: new import_mongodb69.ObjectId(value.site),
|
|
28979
29241
|
name: value.name,
|
|
28980
29242
|
assignee: value.assignee,
|
|
28981
29243
|
start: value.start,
|
|
@@ -28992,7 +29254,7 @@ function MPatrolRoute(value) {
|
|
|
28992
29254
|
|
|
28993
29255
|
// src/repositories/patrol-route.repo.ts
|
|
28994
29256
|
var import_node_server_utils121 = require("@7365admin1/node-server-utils");
|
|
28995
|
-
var
|
|
29257
|
+
var import_mongodb70 = require("mongodb");
|
|
28996
29258
|
function usePatrolRouteRepo() {
|
|
28997
29259
|
const db = import_node_server_utils121.useAtlas.getDb();
|
|
28998
29260
|
if (!db) {
|
|
@@ -29068,7 +29330,7 @@ function usePatrolRouteRepo() {
|
|
|
29068
29330
|
page = page > 0 ? page - 1 : 0;
|
|
29069
29331
|
const query = {
|
|
29070
29332
|
status,
|
|
29071
|
-
...
|
|
29333
|
+
...import_mongodb70.ObjectId.isValid(site) && { site: new import_mongodb70.ObjectId(site) }
|
|
29072
29334
|
};
|
|
29073
29335
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
29074
29336
|
const cacheOptions = {
|
|
@@ -29151,20 +29413,20 @@ function usePatrolRouteRepo() {
|
|
|
29151
29413
|
}
|
|
29152
29414
|
async function updateById(_id, value, session) {
|
|
29153
29415
|
try {
|
|
29154
|
-
_id = new
|
|
29416
|
+
_id = new import_mongodb70.ObjectId(_id);
|
|
29155
29417
|
} catch (error) {
|
|
29156
29418
|
throw new import_node_server_utils121.BadRequestError("Invalid patrol route transaction ID format.");
|
|
29157
29419
|
}
|
|
29158
|
-
if (value.site &&
|
|
29420
|
+
if (value.site && import_mongodb70.ObjectId.isValid(value.site.toString())) {
|
|
29159
29421
|
try {
|
|
29160
|
-
value.site = new
|
|
29422
|
+
value.site = new import_mongodb70.ObjectId(value.site.toString());
|
|
29161
29423
|
} catch {
|
|
29162
29424
|
throw new import_node_server_utils121.BadRequestError("Invalid _id format");
|
|
29163
29425
|
}
|
|
29164
29426
|
}
|
|
29165
29427
|
if (value.assignee && Array.isArray(value.assignee)) {
|
|
29166
29428
|
try {
|
|
29167
|
-
value.assignee = value.assignee.map((id) => new
|
|
29429
|
+
value.assignee = value.assignee.map((id) => new import_mongodb70.ObjectId(id));
|
|
29168
29430
|
} catch {
|
|
29169
29431
|
throw new import_node_server_utils121.BadRequestError("Invalid _id format");
|
|
29170
29432
|
}
|
|
@@ -29184,7 +29446,7 @@ function usePatrolRouteRepo() {
|
|
|
29184
29446
|
}
|
|
29185
29447
|
async function deleteById(_id) {
|
|
29186
29448
|
try {
|
|
29187
|
-
_id = new
|
|
29449
|
+
_id = new import_mongodb70.ObjectId(_id);
|
|
29188
29450
|
} catch (error) {
|
|
29189
29451
|
throw new import_node_server_utils121.BadRequestError("Invalid patrol route transaction ID format.");
|
|
29190
29452
|
}
|
|
@@ -29233,7 +29495,7 @@ function usePatrolRouteRepo() {
|
|
|
29233
29495
|
const query = {
|
|
29234
29496
|
status,
|
|
29235
29497
|
...search && { $text: { $search: search } },
|
|
29236
|
-
...
|
|
29498
|
+
...import_mongodb70.ObjectId.isValid(site) && { site: new import_mongodb70.ObjectId(site) }
|
|
29237
29499
|
};
|
|
29238
29500
|
if (day && start) {
|
|
29239
29501
|
const [hour, minute] = start?.split(":") ?? ["0", "0"];
|
|
@@ -29316,7 +29578,7 @@ function usePatrolRouteRepo() {
|
|
|
29316
29578
|
id: "$_id",
|
|
29317
29579
|
start: startOfDay,
|
|
29318
29580
|
end: endOfDay,
|
|
29319
|
-
site:
|
|
29581
|
+
site: import_mongodb70.ObjectId.isValid(site) ? new import_mongodb70.ObjectId(site) : null
|
|
29320
29582
|
},
|
|
29321
29583
|
pipeline: [
|
|
29322
29584
|
{
|
|
@@ -29362,7 +29624,7 @@ function usePatrolRouteRepo() {
|
|
|
29362
29624
|
}
|
|
29363
29625
|
async function getById(_id, session) {
|
|
29364
29626
|
try {
|
|
29365
|
-
_id = new
|
|
29627
|
+
_id = new import_mongodb70.ObjectId(_id);
|
|
29366
29628
|
} catch (error) {
|
|
29367
29629
|
throw new import_node_server_utils121.BadRequestError("Invalid patrol log ID format.");
|
|
29368
29630
|
}
|
|
@@ -29607,7 +29869,7 @@ function usePatrolRouteController() {
|
|
|
29607
29869
|
|
|
29608
29870
|
// src/models/patrol-log.model.ts
|
|
29609
29871
|
var import_node_server_utils123 = require("@7365admin1/node-server-utils");
|
|
29610
|
-
var
|
|
29872
|
+
var import_mongodb71 = require("mongodb");
|
|
29611
29873
|
var import_joi67 = __toESM(require("joi"));
|
|
29612
29874
|
var schemeLogCamera = import_joi67.default.object({
|
|
29613
29875
|
camera: import_joi67.default.string().hex().required(),
|
|
@@ -29668,41 +29930,41 @@ function MPatrolLog(value) {
|
|
|
29668
29930
|
}
|
|
29669
29931
|
if (value._id && typeof value._id === "string") {
|
|
29670
29932
|
try {
|
|
29671
|
-
value._id = new
|
|
29933
|
+
value._id = new import_mongodb71.ObjectId(value._id);
|
|
29672
29934
|
} catch {
|
|
29673
29935
|
throw new import_node_server_utils123.BadRequestError("Invalid _id format");
|
|
29674
29936
|
}
|
|
29675
29937
|
}
|
|
29676
29938
|
if (value.route && typeof value.route === "string") {
|
|
29677
29939
|
try {
|
|
29678
|
-
value.route = new
|
|
29940
|
+
value.route = new import_mongodb71.ObjectId(value.route);
|
|
29679
29941
|
} catch {
|
|
29680
29942
|
throw new import_node_server_utils123.BadRequestError("Invalid route id format");
|
|
29681
29943
|
}
|
|
29682
29944
|
}
|
|
29683
29945
|
if (value.site && typeof value.site === "string") {
|
|
29684
29946
|
try {
|
|
29685
|
-
value.site = new
|
|
29947
|
+
value.site = new import_mongodb71.ObjectId(value.site);
|
|
29686
29948
|
} catch {
|
|
29687
29949
|
throw new import_node_server_utils123.BadRequestError("Invalid site id format");
|
|
29688
29950
|
}
|
|
29689
29951
|
}
|
|
29690
29952
|
const assignee = (value.assignee || []).map((id) => {
|
|
29691
29953
|
try {
|
|
29692
|
-
return new
|
|
29954
|
+
return new import_mongodb71.ObjectId(id);
|
|
29693
29955
|
} catch {
|
|
29694
29956
|
throw new import_node_server_utils123.BadRequestError("Invalid assignee id format");
|
|
29695
29957
|
}
|
|
29696
29958
|
});
|
|
29697
29959
|
if (value.incidentReport && typeof value.incidentReport.id === "string") {
|
|
29698
29960
|
try {
|
|
29699
|
-
value.incidentReport.id = new
|
|
29961
|
+
value.incidentReport.id = new import_mongodb71.ObjectId(value.incidentReport.id);
|
|
29700
29962
|
} catch {
|
|
29701
29963
|
throw new import_node_server_utils123.BadRequestError("Invalid incident report id format");
|
|
29702
29964
|
}
|
|
29703
29965
|
}
|
|
29704
29966
|
return {
|
|
29705
|
-
_id: value._id ?? new
|
|
29967
|
+
_id: value._id ?? new import_mongodb71.ObjectId(),
|
|
29706
29968
|
site: value.site,
|
|
29707
29969
|
name: value.name,
|
|
29708
29970
|
assignee,
|
|
@@ -29721,7 +29983,7 @@ function MPatrolLog(value) {
|
|
|
29721
29983
|
|
|
29722
29984
|
// src/repositories/patrol-log.repo.ts
|
|
29723
29985
|
var import_node_server_utils124 = require("@7365admin1/node-server-utils");
|
|
29724
|
-
var
|
|
29986
|
+
var import_mongodb72 = require("mongodb");
|
|
29725
29987
|
function usePatrolLogRepo() {
|
|
29726
29988
|
const db = import_node_server_utils124.useAtlas.getDb();
|
|
29727
29989
|
if (!db) {
|
|
@@ -29812,7 +30074,7 @@ function usePatrolLogRepo() {
|
|
|
29812
30074
|
};
|
|
29813
30075
|
}
|
|
29814
30076
|
const query = {
|
|
29815
|
-
...
|
|
30077
|
+
...import_mongodb72.ObjectId.isValid(site) && { site: new import_mongodb72.ObjectId(site) },
|
|
29816
30078
|
...dateExpr
|
|
29817
30079
|
};
|
|
29818
30080
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -29952,7 +30214,7 @@ function usePatrolLogRepo() {
|
|
|
29952
30214
|
}
|
|
29953
30215
|
async function updateById(_id, value, session) {
|
|
29954
30216
|
try {
|
|
29955
|
-
_id = new
|
|
30217
|
+
_id = new import_mongodb72.ObjectId(_id);
|
|
29956
30218
|
} catch (error) {
|
|
29957
30219
|
throw new import_node_server_utils124.BadRequestError("Invalid patrol log transaction ID format.");
|
|
29958
30220
|
}
|
|
@@ -29971,7 +30233,7 @@ function usePatrolLogRepo() {
|
|
|
29971
30233
|
}
|
|
29972
30234
|
async function deleteById(_id, session) {
|
|
29973
30235
|
try {
|
|
29974
|
-
_id = new
|
|
30236
|
+
_id = new import_mongodb72.ObjectId(_id);
|
|
29975
30237
|
} catch (error) {
|
|
29976
30238
|
throw new import_node_server_utils124.BadRequestError("Invalid patrol log ID format.");
|
|
29977
30239
|
}
|
|
@@ -29985,7 +30247,7 @@ function usePatrolLogRepo() {
|
|
|
29985
30247
|
}
|
|
29986
30248
|
async function getById(_id, session) {
|
|
29987
30249
|
try {
|
|
29988
|
-
_id = new
|
|
30250
|
+
_id = new import_mongodb72.ObjectId(_id);
|
|
29989
30251
|
} catch (error) {
|
|
29990
30252
|
throw new import_node_server_utils124.BadRequestError("Invalid patrol log ID format.");
|
|
29991
30253
|
}
|
|
@@ -30233,7 +30495,7 @@ function usePatrolLogController() {
|
|
|
30233
30495
|
|
|
30234
30496
|
// src/models/site-facility.model.ts
|
|
30235
30497
|
var import_joi69 = __toESM(require("joi"));
|
|
30236
|
-
var
|
|
30498
|
+
var import_mongodb73 = require("mongodb");
|
|
30237
30499
|
var timeSlotSchema = import_joi69.default.array().items(
|
|
30238
30500
|
import_joi69.default.object({
|
|
30239
30501
|
start: import_joi69.default.string().optional().allow("", null),
|
|
@@ -30393,28 +30655,28 @@ function MSiteFacility(value) {
|
|
|
30393
30655
|
throw new Error(error.details[0].message);
|
|
30394
30656
|
if (value._id && typeof value._id === "string") {
|
|
30395
30657
|
try {
|
|
30396
|
-
value._id = new
|
|
30658
|
+
value._id = new import_mongodb73.ObjectId(value._id);
|
|
30397
30659
|
} catch {
|
|
30398
30660
|
throw new Error("Invalid _id.");
|
|
30399
30661
|
}
|
|
30400
30662
|
}
|
|
30401
30663
|
if (value.site && typeof value.site === "string") {
|
|
30402
30664
|
try {
|
|
30403
|
-
value.site = new
|
|
30665
|
+
value.site = new import_mongodb73.ObjectId(value.site);
|
|
30404
30666
|
} catch {
|
|
30405
30667
|
throw new Error("Invalid _id.");
|
|
30406
30668
|
}
|
|
30407
30669
|
}
|
|
30408
30670
|
if (value.featuredImage && typeof value.featuredImage === "string") {
|
|
30409
30671
|
try {
|
|
30410
|
-
value.featuredImage = new
|
|
30672
|
+
value.featuredImage = new import_mongodb73.ObjectId(value.featuredImage);
|
|
30411
30673
|
} catch {
|
|
30412
30674
|
throw new Error("Invalid featuredImage ID.");
|
|
30413
30675
|
}
|
|
30414
30676
|
}
|
|
30415
30677
|
if (Array.isArray(value.gallery)) {
|
|
30416
30678
|
try {
|
|
30417
|
-
value.gallery = value.gallery.map((id) => new
|
|
30679
|
+
value.gallery = value.gallery.map((id) => new import_mongodb73.ObjectId(id));
|
|
30418
30680
|
} catch {
|
|
30419
30681
|
throw new Error("Invalid ID in gallery array.");
|
|
30420
30682
|
}
|
|
@@ -30498,7 +30760,7 @@ function MSiteFacility(value) {
|
|
|
30498
30760
|
|
|
30499
30761
|
// src/repositories/site-facility.repo.ts
|
|
30500
30762
|
var import_node_server_utils127 = require("@7365admin1/node-server-utils");
|
|
30501
|
-
var
|
|
30763
|
+
var import_mongodb74 = require("mongodb");
|
|
30502
30764
|
function useSiteFacilityRepo() {
|
|
30503
30765
|
const db = import_node_server_utils127.useAtlas.getDb();
|
|
30504
30766
|
if (!db) {
|
|
@@ -30566,7 +30828,7 @@ function useSiteFacilityRepo() {
|
|
|
30566
30828
|
};
|
|
30567
30829
|
if (site) {
|
|
30568
30830
|
try {
|
|
30569
|
-
site = new
|
|
30831
|
+
site = new import_mongodb74.ObjectId(site);
|
|
30570
30832
|
query.site = site;
|
|
30571
30833
|
cacheOptions.site = site.toString();
|
|
30572
30834
|
} catch (error) {
|
|
@@ -30611,7 +30873,7 @@ function useSiteFacilityRepo() {
|
|
|
30611
30873
|
}
|
|
30612
30874
|
async function getSiteFacilityById(_id, session) {
|
|
30613
30875
|
try {
|
|
30614
|
-
_id = new
|
|
30876
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30615
30877
|
} catch (error) {
|
|
30616
30878
|
throw new import_node_server_utils127.BadRequestError("Invalid site facility ID format.");
|
|
30617
30879
|
}
|
|
@@ -30639,20 +30901,20 @@ function useSiteFacilityRepo() {
|
|
|
30639
30901
|
async function updateSiteFacilityById(_id, value, session) {
|
|
30640
30902
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
30641
30903
|
try {
|
|
30642
|
-
_id = new
|
|
30904
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30643
30905
|
} catch (error) {
|
|
30644
30906
|
throw new import_node_server_utils127.BadRequestError("Invalid ID format.");
|
|
30645
30907
|
}
|
|
30646
30908
|
if (value.featuredImage) {
|
|
30647
30909
|
try {
|
|
30648
|
-
value.featuredImage = new
|
|
30910
|
+
value.featuredImage = new import_mongodb74.ObjectId(value.featuredImage);
|
|
30649
30911
|
} catch (error) {
|
|
30650
30912
|
throw new import_node_server_utils127.BadRequestError("Invalid ID format for featured image.");
|
|
30651
30913
|
}
|
|
30652
30914
|
}
|
|
30653
30915
|
if (Array.isArray(value.gallery)) {
|
|
30654
30916
|
try {
|
|
30655
|
-
value.gallery = value.gallery.map((id) => new
|
|
30917
|
+
value.gallery = value.gallery.map((id) => new import_mongodb74.ObjectId(id));
|
|
30656
30918
|
} catch {
|
|
30657
30919
|
throw new Error("Invalid ID in gallery array.");
|
|
30658
30920
|
}
|
|
@@ -30698,7 +30960,7 @@ function useSiteFacilityRepo() {
|
|
|
30698
30960
|
}
|
|
30699
30961
|
async function deleteSiteFacilityById(_id) {
|
|
30700
30962
|
try {
|
|
30701
|
-
_id = new
|
|
30963
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30702
30964
|
} catch (error) {
|
|
30703
30965
|
throw new import_node_server_utils127.BadRequestError("Invalid site facility ID format.");
|
|
30704
30966
|
}
|
|
@@ -30727,12 +30989,12 @@ function useSiteFacilityRepo() {
|
|
|
30727
30989
|
}
|
|
30728
30990
|
async function getSiteFacilityTimeSlotById(_id, site, session) {
|
|
30729
30991
|
try {
|
|
30730
|
-
_id = new
|
|
30992
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30731
30993
|
} catch (error) {
|
|
30732
30994
|
throw new import_node_server_utils127.BadRequestError("Invalid facility ID format.");
|
|
30733
30995
|
}
|
|
30734
30996
|
try {
|
|
30735
|
-
site = new
|
|
30997
|
+
site = new import_mongodb74.ObjectId(site);
|
|
30736
30998
|
} catch (error) {
|
|
30737
30999
|
throw new import_node_server_utils127.BadRequestError("Invalid site ID format.");
|
|
30738
31000
|
}
|
|
@@ -31075,7 +31337,7 @@ function useSiteFacilityController() {
|
|
|
31075
31337
|
|
|
31076
31338
|
// src/models/service-provider-billing.model.ts
|
|
31077
31339
|
var import_joi71 = __toESM(require("joi"));
|
|
31078
|
-
var
|
|
31340
|
+
var import_mongodb75 = require("mongodb");
|
|
31079
31341
|
var schemaServiceProviderBilling = import_joi71.default.object({
|
|
31080
31342
|
_id: import_joi71.default.string().hex().optional().allow("", null),
|
|
31081
31343
|
attachments: import_joi71.default.array().items(import_joi71.default.string().hex()).required(),
|
|
@@ -31109,7 +31371,7 @@ function MServiceProviderBilling(value) {
|
|
|
31109
31371
|
}
|
|
31110
31372
|
if (value._id && typeof value._id === "string") {
|
|
31111
31373
|
try {
|
|
31112
|
-
value._id = new
|
|
31374
|
+
value._id = new import_mongodb75.ObjectId(value._id);
|
|
31113
31375
|
} catch {
|
|
31114
31376
|
throw new Error("Invalid ID.");
|
|
31115
31377
|
}
|
|
@@ -31118,7 +31380,7 @@ function MServiceProviderBilling(value) {
|
|
|
31118
31380
|
value.acknowledgedBy = value.acknowledgedBy.map((item) => {
|
|
31119
31381
|
if (item.user && typeof item.user === "string") {
|
|
31120
31382
|
try {
|
|
31121
|
-
item.user = new
|
|
31383
|
+
item.user = new import_mongodb75.ObjectId(item.user);
|
|
31122
31384
|
} catch (error2) {
|
|
31123
31385
|
throw new Error("Invalid ID format for acknowledgedBy.user.");
|
|
31124
31386
|
}
|
|
@@ -31128,13 +31390,13 @@ function MServiceProviderBilling(value) {
|
|
|
31128
31390
|
}
|
|
31129
31391
|
if (value.orgId && typeof value.orgId === "string") {
|
|
31130
31392
|
try {
|
|
31131
|
-
value.orgId = new
|
|
31393
|
+
value.orgId = new import_mongodb75.ObjectId(value.orgId);
|
|
31132
31394
|
} catch {
|
|
31133
31395
|
throw new Error("Invalid org ID.");
|
|
31134
31396
|
}
|
|
31135
31397
|
}
|
|
31136
31398
|
return {
|
|
31137
|
-
_id: value._id ?? new
|
|
31399
|
+
_id: value._id ?? new import_mongodb75.ObjectId(),
|
|
31138
31400
|
attachments: value.attachments,
|
|
31139
31401
|
acknowledgedBy: value.acknowledgedBy || [],
|
|
31140
31402
|
status: value.status,
|
|
@@ -31147,7 +31409,7 @@ function MServiceProviderBilling(value) {
|
|
|
31147
31409
|
|
|
31148
31410
|
// src/repositories/service-provider-billing.repo.ts
|
|
31149
31411
|
var import_node_server_utils130 = require("@7365admin1/node-server-utils");
|
|
31150
|
-
var
|
|
31412
|
+
var import_mongodb76 = require("mongodb");
|
|
31151
31413
|
function useServiceProviderBillingRepo() {
|
|
31152
31414
|
const db = import_node_server_utils130.useAtlas.getDb();
|
|
31153
31415
|
if (!db) {
|
|
@@ -31194,7 +31456,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31194
31456
|
}, session) {
|
|
31195
31457
|
page = page > 0 ? page - 1 : 0;
|
|
31196
31458
|
try {
|
|
31197
|
-
org = new
|
|
31459
|
+
org = new import_mongodb76.ObjectId(org);
|
|
31198
31460
|
} catch (error) {
|
|
31199
31461
|
throw new import_node_server_utils130.BadRequestError("Invalid org ID format.");
|
|
31200
31462
|
}
|
|
@@ -31244,7 +31506,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31244
31506
|
}
|
|
31245
31507
|
async function getSiteServiceProviderBillingById(_id, session) {
|
|
31246
31508
|
try {
|
|
31247
|
-
_id = new
|
|
31509
|
+
_id = new import_mongodb76.ObjectId(_id);
|
|
31248
31510
|
} catch (error) {
|
|
31249
31511
|
throw new import_node_server_utils130.BadRequestError("Invalid service provider billing ID format.");
|
|
31250
31512
|
}
|
|
@@ -31272,7 +31534,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31272
31534
|
async function updateServiceProviderBillingById(_id, value, session) {
|
|
31273
31535
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
31274
31536
|
try {
|
|
31275
|
-
_id = new
|
|
31537
|
+
_id = new import_mongodb76.ObjectId(_id);
|
|
31276
31538
|
} catch (error) {
|
|
31277
31539
|
throw new import_node_server_utils130.BadRequestError("Invalid ID format.");
|
|
31278
31540
|
}
|
|
@@ -31280,7 +31542,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31280
31542
|
value.acknowledgedBy = value.acknowledgedBy.map((item) => {
|
|
31281
31543
|
if (item.user && typeof item.user === "string") {
|
|
31282
31544
|
try {
|
|
31283
|
-
item.user = new
|
|
31545
|
+
item.user = new import_mongodb76.ObjectId(item.user);
|
|
31284
31546
|
} catch (error) {
|
|
31285
31547
|
throw new Error("Invalid ID format for acknowledgedBy.user.");
|
|
31286
31548
|
}
|
|
@@ -31314,7 +31576,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31314
31576
|
}
|
|
31315
31577
|
async function deleteServiceProviderBillingById(_id) {
|
|
31316
31578
|
try {
|
|
31317
|
-
_id = new
|
|
31579
|
+
_id = new import_mongodb76.ObjectId(_id);
|
|
31318
31580
|
} catch (error) {
|
|
31319
31581
|
throw new import_node_server_utils130.BadRequestError("Invalid service provider billing ID format.");
|
|
31320
31582
|
}
|
|
@@ -31552,7 +31814,7 @@ function useServiceProviderBillingController() {
|
|
|
31552
31814
|
|
|
31553
31815
|
// src/models/site-facility-booking.model.ts
|
|
31554
31816
|
var import_joi73 = __toESM(require("joi"));
|
|
31555
|
-
var
|
|
31817
|
+
var import_mongodb77 = require("mongodb");
|
|
31556
31818
|
var FacilitySort = /* @__PURE__ */ ((FacilitySort2) => {
|
|
31557
31819
|
FacilitySort2["CREATED_AT"] = "createdAt";
|
|
31558
31820
|
FacilitySort2["NAME"] = "name";
|
|
@@ -31662,48 +31924,48 @@ function MSiteFacilityBooking(value) {
|
|
|
31662
31924
|
}
|
|
31663
31925
|
if (value._id && typeof value._id === "string") {
|
|
31664
31926
|
try {
|
|
31665
|
-
value._id = new
|
|
31927
|
+
value._id = new import_mongodb77.ObjectId(value._id);
|
|
31666
31928
|
} catch {
|
|
31667
31929
|
throw new Error("Invalid ID.");
|
|
31668
31930
|
}
|
|
31669
31931
|
}
|
|
31670
31932
|
if (value.site && typeof value.site === "string") {
|
|
31671
31933
|
try {
|
|
31672
|
-
value.site = new
|
|
31934
|
+
value.site = new import_mongodb77.ObjectId(value.site);
|
|
31673
31935
|
} catch {
|
|
31674
31936
|
throw new Error("Invalid site ID.");
|
|
31675
31937
|
}
|
|
31676
31938
|
}
|
|
31677
31939
|
if (value.user && typeof value.user === "string") {
|
|
31678
31940
|
try {
|
|
31679
|
-
value.user = new
|
|
31941
|
+
value.user = new import_mongodb77.ObjectId(value.user);
|
|
31680
31942
|
} catch {
|
|
31681
31943
|
throw new Error("Invalid user ID.");
|
|
31682
31944
|
}
|
|
31683
31945
|
}
|
|
31684
31946
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
31685
31947
|
try {
|
|
31686
|
-
value.approvedBy = new
|
|
31948
|
+
value.approvedBy = new import_mongodb77.ObjectId(value.approvedBy);
|
|
31687
31949
|
} catch {
|
|
31688
31950
|
throw new Error("Invalid approved by ID.");
|
|
31689
31951
|
}
|
|
31690
31952
|
}
|
|
31691
31953
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
31692
31954
|
try {
|
|
31693
|
-
value.createdBy = new
|
|
31955
|
+
value.createdBy = new import_mongodb77.ObjectId(value.createdBy);
|
|
31694
31956
|
} catch {
|
|
31695
31957
|
throw new Error("Invalid created by ID.");
|
|
31696
31958
|
}
|
|
31697
31959
|
}
|
|
31698
31960
|
if (value.updatedBy && typeof value.updatedBy === "string") {
|
|
31699
31961
|
try {
|
|
31700
|
-
value.updatedBy = new
|
|
31962
|
+
value.updatedBy = new import_mongodb77.ObjectId(value.updatedBy);
|
|
31701
31963
|
} catch {
|
|
31702
31964
|
throw new Error("Invalid updated by ID.");
|
|
31703
31965
|
}
|
|
31704
31966
|
}
|
|
31705
31967
|
return {
|
|
31706
|
-
_id: value._id ?? new
|
|
31968
|
+
_id: value._id ?? new import_mongodb77.ObjectId(),
|
|
31707
31969
|
facility: value.facility ?? "",
|
|
31708
31970
|
slot: value.slot ?? "",
|
|
31709
31971
|
slotName: value.slotName ?? "",
|
|
@@ -31789,7 +32051,7 @@ function MSiteFacilityBooking(value) {
|
|
|
31789
32051
|
|
|
31790
32052
|
// src/repositories/site-facility-booking.repo.ts
|
|
31791
32053
|
var import_node_server_utils133 = require("@7365admin1/node-server-utils");
|
|
31792
|
-
var
|
|
32054
|
+
var import_mongodb78 = require("mongodb");
|
|
31793
32055
|
var facility_bookings_namespace_collection = "site.facilty-booking";
|
|
31794
32056
|
function useSiteFacilityBookingRepo() {
|
|
31795
32057
|
const db = import_node_server_utils133.useAtlas.getDb();
|
|
@@ -31952,7 +32214,7 @@ function useSiteFacilityBookingRepo() {
|
|
|
31952
32214
|
}
|
|
31953
32215
|
async function deleteSiteFacilityBookingById(_id) {
|
|
31954
32216
|
try {
|
|
31955
|
-
_id = new
|
|
32217
|
+
_id = new import_mongodb78.ObjectId(_id);
|
|
31956
32218
|
} catch (error) {
|
|
31957
32219
|
throw new import_node_server_utils133.BadRequestError("Invalid site facility booking ID format.");
|
|
31958
32220
|
}
|
|
@@ -32189,7 +32451,7 @@ function useSiteFacilityBookingController() {
|
|
|
32189
32451
|
|
|
32190
32452
|
// src/models/document-management.model.ts
|
|
32191
32453
|
var import_joi75 = __toESM(require("joi"));
|
|
32192
|
-
var
|
|
32454
|
+
var import_mongodb79 = require("mongodb");
|
|
32193
32455
|
var schemaDocumentManagement = import_joi75.default.object({
|
|
32194
32456
|
_id: import_joi75.default.string().hex().optional().allow("", null),
|
|
32195
32457
|
name: import_joi75.default.string().required(),
|
|
@@ -32227,28 +32489,28 @@ function MDocumentManagement(value) {
|
|
|
32227
32489
|
}
|
|
32228
32490
|
if (value._id && typeof value._id === "string") {
|
|
32229
32491
|
try {
|
|
32230
|
-
value._id = new
|
|
32492
|
+
value._id = new import_mongodb79.ObjectId(value._id);
|
|
32231
32493
|
} catch (error2) {
|
|
32232
32494
|
throw new Error("Invalid ID.");
|
|
32233
32495
|
}
|
|
32234
32496
|
}
|
|
32235
32497
|
if (value.org && typeof value.org === "string") {
|
|
32236
32498
|
try {
|
|
32237
|
-
value.org = new
|
|
32499
|
+
value.org = new import_mongodb79.ObjectId(value.org);
|
|
32238
32500
|
} catch (error2) {
|
|
32239
32501
|
throw new Error("Invalid org ID.");
|
|
32240
32502
|
}
|
|
32241
32503
|
}
|
|
32242
32504
|
if (value.site && typeof value.site === "string") {
|
|
32243
32505
|
try {
|
|
32244
|
-
value.site = new
|
|
32506
|
+
value.site = new import_mongodb79.ObjectId(value.site);
|
|
32245
32507
|
} catch (error2) {
|
|
32246
32508
|
throw new Error("Invalid site ID.");
|
|
32247
32509
|
}
|
|
32248
32510
|
}
|
|
32249
32511
|
if (value.parentId && typeof value.parentId === "string") {
|
|
32250
32512
|
try {
|
|
32251
|
-
value.parentId = new
|
|
32513
|
+
value.parentId = new import_mongodb79.ObjectId(value.parentId);
|
|
32252
32514
|
} catch (error2) {
|
|
32253
32515
|
throw new Error("Invalid parentId.");
|
|
32254
32516
|
}
|
|
@@ -32273,7 +32535,7 @@ function MDocumentManagement(value) {
|
|
|
32273
32535
|
|
|
32274
32536
|
// src/repositories/document-management.repo.ts
|
|
32275
32537
|
var import_node_server_utils136 = require("@7365admin1/node-server-utils");
|
|
32276
|
-
var
|
|
32538
|
+
var import_mongodb80 = require("mongodb");
|
|
32277
32539
|
function useDocumentManagementRepo() {
|
|
32278
32540
|
const db = import_node_server_utils136.useAtlas.getDb();
|
|
32279
32541
|
if (!db) {
|
|
@@ -32335,7 +32597,7 @@ function useDocumentManagementRepo() {
|
|
|
32335
32597
|
}) {
|
|
32336
32598
|
page = page > 0 ? page - 1 : 0;
|
|
32337
32599
|
try {
|
|
32338
|
-
site = new
|
|
32600
|
+
site = new import_mongodb80.ObjectId(site);
|
|
32339
32601
|
} catch (error) {
|
|
32340
32602
|
throw new import_node_server_utils136.BadRequestError("Invalid site ID format.");
|
|
32341
32603
|
}
|
|
@@ -32352,12 +32614,12 @@ function useDocumentManagementRepo() {
|
|
|
32352
32614
|
cacheOptions.type = type;
|
|
32353
32615
|
}
|
|
32354
32616
|
if (org) {
|
|
32355
|
-
query.org = new
|
|
32617
|
+
query.org = new import_mongodb80.ObjectId(org);
|
|
32356
32618
|
cacheOptions.org = org.toString();
|
|
32357
32619
|
}
|
|
32358
32620
|
if (parentId) {
|
|
32359
32621
|
try {
|
|
32360
|
-
query.parentId = new
|
|
32622
|
+
query.parentId = new import_mongodb80.ObjectId(parentId);
|
|
32361
32623
|
cacheOptions.parentId = parentId.toString();
|
|
32362
32624
|
} catch (error) {
|
|
32363
32625
|
throw new import_node_server_utils136.BadRequestError("Invalid parentId format.");
|
|
@@ -32411,7 +32673,7 @@ function useDocumentManagementRepo() {
|
|
|
32411
32673
|
}
|
|
32412
32674
|
async function getDocumentById(_id) {
|
|
32413
32675
|
try {
|
|
32414
|
-
_id = new
|
|
32676
|
+
_id = new import_mongodb80.ObjectId(_id);
|
|
32415
32677
|
} catch (error) {
|
|
32416
32678
|
throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
|
|
32417
32679
|
}
|
|
@@ -32456,7 +32718,7 @@ function useDocumentManagementRepo() {
|
|
|
32456
32718
|
}
|
|
32457
32719
|
async function updateDocumentById(_id, value) {
|
|
32458
32720
|
try {
|
|
32459
|
-
_id = new
|
|
32721
|
+
_id = new import_mongodb80.ObjectId(_id);
|
|
32460
32722
|
} catch (error) {
|
|
32461
32723
|
throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
|
|
32462
32724
|
}
|
|
@@ -32484,7 +32746,7 @@ function useDocumentManagementRepo() {
|
|
|
32484
32746
|
}
|
|
32485
32747
|
async function deleteDocumentById(_id, session) {
|
|
32486
32748
|
try {
|
|
32487
|
-
_id = new
|
|
32749
|
+
_id = new import_mongodb80.ObjectId(_id);
|
|
32488
32750
|
} catch (error) {
|
|
32489
32751
|
throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
|
|
32490
32752
|
}
|
|
@@ -32517,7 +32779,7 @@ function useDocumentManagementRepo() {
|
|
|
32517
32779
|
}
|
|
32518
32780
|
async function getDocumentManagementBySiteId(site, type) {
|
|
32519
32781
|
try {
|
|
32520
|
-
site = new
|
|
32782
|
+
site = new import_mongodb80.ObjectId(site);
|
|
32521
32783
|
} catch (error) {
|
|
32522
32784
|
throw new import_node_server_utils136.BadRequestError("Invalid document management site ID format.");
|
|
32523
32785
|
}
|
|
@@ -32843,7 +33105,7 @@ function useDocumentManagementController() {
|
|
|
32843
33105
|
|
|
32844
33106
|
// src/models/bulletin-board.model.ts
|
|
32845
33107
|
var import_joi77 = __toESM(require("joi"));
|
|
32846
|
-
var
|
|
33108
|
+
var import_mongodb81 = require("mongodb");
|
|
32847
33109
|
var BulletinRecipient = /* @__PURE__ */ ((BulletinRecipient2) => {
|
|
32848
33110
|
BulletinRecipient2["RESIDENT"] = "resident";
|
|
32849
33111
|
BulletinRecipient2["SECURITY_AGENCY"] = "security_agency";
|
|
@@ -32923,21 +33185,21 @@ function MBulletinBoard(value) {
|
|
|
32923
33185
|
}
|
|
32924
33186
|
if (value._id && typeof value._id === "string") {
|
|
32925
33187
|
try {
|
|
32926
|
-
value._id = new
|
|
33188
|
+
value._id = new import_mongodb81.ObjectId(value._id);
|
|
32927
33189
|
} catch {
|
|
32928
33190
|
throw new Error("Invalid ID.");
|
|
32929
33191
|
}
|
|
32930
33192
|
}
|
|
32931
33193
|
if (value.site && typeof value.site === "string") {
|
|
32932
33194
|
try {
|
|
32933
|
-
value.site = new
|
|
33195
|
+
value.site = new import_mongodb81.ObjectId(value.site);
|
|
32934
33196
|
} catch {
|
|
32935
33197
|
throw new Error("Invalid site ID.");
|
|
32936
33198
|
}
|
|
32937
33199
|
}
|
|
32938
33200
|
if (value.orgId && typeof value.orgId === "string") {
|
|
32939
33201
|
try {
|
|
32940
|
-
value.orgId = new
|
|
33202
|
+
value.orgId = new import_mongodb81.ObjectId(value.orgId);
|
|
32941
33203
|
} catch {
|
|
32942
33204
|
throw new Error("Invalid org ID.");
|
|
32943
33205
|
}
|
|
@@ -32946,7 +33208,7 @@ function MBulletinBoard(value) {
|
|
|
32946
33208
|
value.file = value.file.map((f) => {
|
|
32947
33209
|
if (f._id && typeof f._id === "string") {
|
|
32948
33210
|
try {
|
|
32949
|
-
return { ...f, _id: new
|
|
33211
|
+
return { ...f, _id: new import_mongodb81.ObjectId(f._id) };
|
|
32950
33212
|
} catch {
|
|
32951
33213
|
throw new Error("Invalid file ID.");
|
|
32952
33214
|
}
|
|
@@ -32955,7 +33217,7 @@ function MBulletinBoard(value) {
|
|
|
32955
33217
|
});
|
|
32956
33218
|
}
|
|
32957
33219
|
return {
|
|
32958
|
-
_id: value._id ?? new
|
|
33220
|
+
_id: value._id ?? new import_mongodb81.ObjectId(),
|
|
32959
33221
|
site: value.site ?? "",
|
|
32960
33222
|
orgId: value.orgId ?? "",
|
|
32961
33223
|
recipients: value.recipients ?? [],
|
|
@@ -32974,7 +33236,7 @@ function MBulletinBoard(value) {
|
|
|
32974
33236
|
|
|
32975
33237
|
// src/repositories/bulletin-board.repo.ts
|
|
32976
33238
|
var import_node_server_utils139 = require("@7365admin1/node-server-utils");
|
|
32977
|
-
var
|
|
33239
|
+
var import_mongodb82 = require("mongodb");
|
|
32978
33240
|
var bulletin_boards_namespace_collection = "bulletin-boards";
|
|
32979
33241
|
function useBulletinBoardRepo() {
|
|
32980
33242
|
const db = import_node_server_utils139.useAtlas.getDb();
|
|
@@ -33027,7 +33289,7 @@ function useBulletinBoardRepo() {
|
|
|
33027
33289
|
}, session) {
|
|
33028
33290
|
page = page > 0 ? page - 1 : 0;
|
|
33029
33291
|
try {
|
|
33030
|
-
site = new
|
|
33292
|
+
site = new import_mongodb82.ObjectId(site);
|
|
33031
33293
|
} catch (error) {
|
|
33032
33294
|
throw new import_node_server_utils139.BadRequestError("Invalid site ID format.");
|
|
33033
33295
|
}
|
|
@@ -33086,7 +33348,7 @@ function useBulletinBoardRepo() {
|
|
|
33086
33348
|
}
|
|
33087
33349
|
async function getBulletinBoardById(_id, session) {
|
|
33088
33350
|
try {
|
|
33089
|
-
_id = new
|
|
33351
|
+
_id = new import_mongodb82.ObjectId(_id);
|
|
33090
33352
|
} catch (error) {
|
|
33091
33353
|
throw new import_node_server_utils139.BadRequestError("Invalid bulletin board ID format.");
|
|
33092
33354
|
}
|
|
@@ -33116,13 +33378,13 @@ function useBulletinBoardRepo() {
|
|
|
33116
33378
|
async function updateBulletinBoardById(_id, value, session) {
|
|
33117
33379
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
33118
33380
|
try {
|
|
33119
|
-
_id = new
|
|
33381
|
+
_id = new import_mongodb82.ObjectId(_id);
|
|
33120
33382
|
} catch (error) {
|
|
33121
33383
|
throw new import_node_server_utils139.BadRequestError("Invalid ID format.");
|
|
33122
33384
|
}
|
|
33123
33385
|
if (value.site && typeof value.site === "string") {
|
|
33124
33386
|
try {
|
|
33125
|
-
value.site = new
|
|
33387
|
+
value.site = new import_mongodb82.ObjectId(value.site);
|
|
33126
33388
|
} catch {
|
|
33127
33389
|
throw new Error("Invalid site ID.");
|
|
33128
33390
|
}
|
|
@@ -33153,7 +33415,7 @@ function useBulletinBoardRepo() {
|
|
|
33153
33415
|
}
|
|
33154
33416
|
async function deleteBulletinBoardById(_id, session) {
|
|
33155
33417
|
try {
|
|
33156
|
-
_id = new
|
|
33418
|
+
_id = new import_mongodb82.ObjectId(_id);
|
|
33157
33419
|
} catch (error) {
|
|
33158
33420
|
throw new import_node_server_utils139.BadRequestError("Invalid bulletin board ID format.");
|
|
33159
33421
|
}
|
|
@@ -33587,7 +33849,7 @@ function useBulletinBoardController() {
|
|
|
33587
33849
|
|
|
33588
33850
|
// src/models/site-billing-item.model.ts
|
|
33589
33851
|
var import_node_server_utils142 = require("@7365admin1/node-server-utils");
|
|
33590
|
-
var
|
|
33852
|
+
var import_mongodb83 = require("mongodb");
|
|
33591
33853
|
var import_joi79 = __toESM(require("joi"));
|
|
33592
33854
|
|
|
33593
33855
|
// src/types/enums/billing-frequency.enum.ts
|
|
@@ -33658,21 +33920,21 @@ function MBillingItem(value) {
|
|
|
33658
33920
|
}
|
|
33659
33921
|
if (value._id && typeof value._id === "string") {
|
|
33660
33922
|
try {
|
|
33661
|
-
value._id = new
|
|
33923
|
+
value._id = new import_mongodb83.ObjectId(value._id);
|
|
33662
33924
|
} catch {
|
|
33663
33925
|
throw new import_node_server_utils142.BadRequestError("Invalid _id format");
|
|
33664
33926
|
}
|
|
33665
33927
|
}
|
|
33666
33928
|
if (value.site && typeof value.site === "string") {
|
|
33667
33929
|
try {
|
|
33668
|
-
value.site = new
|
|
33930
|
+
value.site = new import_mongodb83.ObjectId(value.site);
|
|
33669
33931
|
} catch {
|
|
33670
33932
|
throw new import_node_server_utils142.BadRequestError("Invalid site id format");
|
|
33671
33933
|
}
|
|
33672
33934
|
}
|
|
33673
33935
|
if (value.org && typeof value.org === "string") {
|
|
33674
33936
|
try {
|
|
33675
|
-
value.org = new
|
|
33937
|
+
value.org = new import_mongodb83.ObjectId(value.org);
|
|
33676
33938
|
} catch {
|
|
33677
33939
|
throw new import_node_server_utils142.BadRequestError("Invalid org id format");
|
|
33678
33940
|
}
|
|
@@ -33681,7 +33943,7 @@ function MBillingItem(value) {
|
|
|
33681
33943
|
value.units = value.units.map((unit) => {
|
|
33682
33944
|
if (unit._id && typeof unit._id === "string") {
|
|
33683
33945
|
try {
|
|
33684
|
-
unit._id = new
|
|
33946
|
+
unit._id = new import_mongodb83.ObjectId(unit._id);
|
|
33685
33947
|
} catch {
|
|
33686
33948
|
throw new import_node_server_utils142.BadRequestError("Invalid unit id format");
|
|
33687
33949
|
}
|
|
@@ -33690,7 +33952,7 @@ function MBillingItem(value) {
|
|
|
33690
33952
|
});
|
|
33691
33953
|
}
|
|
33692
33954
|
return {
|
|
33693
|
-
_id: value._id ?? new
|
|
33955
|
+
_id: value._id ?? new import_mongodb83.ObjectId(),
|
|
33694
33956
|
site: value.site,
|
|
33695
33957
|
org: value.org,
|
|
33696
33958
|
name: value.name,
|
|
@@ -33718,7 +33980,7 @@ function MBillingItem(value) {
|
|
|
33718
33980
|
|
|
33719
33981
|
// src/repositories/site-billing-item.repo.ts
|
|
33720
33982
|
var import_node_server_utils143 = require("@7365admin1/node-server-utils");
|
|
33721
|
-
var
|
|
33983
|
+
var import_mongodb84 = require("mongodb");
|
|
33722
33984
|
function useSiteBillingItemRepo() {
|
|
33723
33985
|
const db = import_node_server_utils143.useAtlas.getDb();
|
|
33724
33986
|
if (!db) {
|
|
@@ -33805,7 +34067,7 @@ function useSiteBillingItemRepo() {
|
|
|
33805
34067
|
}
|
|
33806
34068
|
]
|
|
33807
34069
|
},
|
|
33808
|
-
...
|
|
34070
|
+
...import_mongodb84.ObjectId.isValid(site) && { site: new import_mongodb84.ObjectId(site) }
|
|
33809
34071
|
};
|
|
33810
34072
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
33811
34073
|
const cacheOptions = {
|
|
@@ -33845,7 +34107,7 @@ function useSiteBillingItemRepo() {
|
|
|
33845
34107
|
}
|
|
33846
34108
|
async function getById(_id, session) {
|
|
33847
34109
|
try {
|
|
33848
|
-
_id = new
|
|
34110
|
+
_id = new import_mongodb84.ObjectId(_id);
|
|
33849
34111
|
} catch (error) {
|
|
33850
34112
|
throw new import_node_server_utils143.BadRequestError("Invalid ID.");
|
|
33851
34113
|
}
|
|
@@ -33884,22 +34146,22 @@ function useSiteBillingItemRepo() {
|
|
|
33884
34146
|
}
|
|
33885
34147
|
async function updateById(_id, value, session) {
|
|
33886
34148
|
try {
|
|
33887
|
-
_id = new
|
|
34149
|
+
_id = new import_mongodb84.ObjectId(_id);
|
|
33888
34150
|
} catch (error) {
|
|
33889
34151
|
throw new import_node_server_utils143.BadRequestError(
|
|
33890
34152
|
"Invalid site billing item transaction ID format."
|
|
33891
34153
|
);
|
|
33892
34154
|
}
|
|
33893
|
-
if (value.site &&
|
|
34155
|
+
if (value.site && import_mongodb84.ObjectId.isValid(value.site.toString())) {
|
|
33894
34156
|
try {
|
|
33895
|
-
value.site = new
|
|
34157
|
+
value.site = new import_mongodb84.ObjectId(value.site.toString());
|
|
33896
34158
|
} catch {
|
|
33897
34159
|
throw new import_node_server_utils143.BadRequestError("Invalid _id format");
|
|
33898
34160
|
}
|
|
33899
34161
|
}
|
|
33900
|
-
if (value.org &&
|
|
34162
|
+
if (value.org && import_mongodb84.ObjectId.isValid(value.org.toString())) {
|
|
33901
34163
|
try {
|
|
33902
|
-
value.org = new
|
|
34164
|
+
value.org = new import_mongodb84.ObjectId(value.org.toString());
|
|
33903
34165
|
} catch {
|
|
33904
34166
|
throw new import_node_server_utils143.BadRequestError("Invalid _id format");
|
|
33905
34167
|
}
|
|
@@ -33919,7 +34181,7 @@ function useSiteBillingItemRepo() {
|
|
|
33919
34181
|
}
|
|
33920
34182
|
async function deleteById(_id) {
|
|
33921
34183
|
try {
|
|
33922
|
-
_id = new
|
|
34184
|
+
_id = new import_mongodb84.ObjectId(_id);
|
|
33923
34185
|
} catch (error) {
|
|
33924
34186
|
throw new import_node_server_utils143.BadRequestError(
|
|
33925
34187
|
"Invalid site billing item transaction ID format."
|
|
@@ -33976,7 +34238,7 @@ var import_node_server_utils145 = require("@7365admin1/node-server-utils");
|
|
|
33976
34238
|
|
|
33977
34239
|
// src/models/site-billing-configuration.model.ts
|
|
33978
34240
|
var import_node_server_utils144 = require("@7365admin1/node-server-utils");
|
|
33979
|
-
var
|
|
34241
|
+
var import_mongodb85 = require("mongodb");
|
|
33980
34242
|
var import_joi80 = __toESM(require("joi"));
|
|
33981
34243
|
var schemaBillingConfiguration = import_joi80.default.object({
|
|
33982
34244
|
_id: import_joi80.default.string().hex().optional(),
|
|
@@ -34037,34 +34299,34 @@ function MBillingConfiguration(value) {
|
|
|
34037
34299
|
}
|
|
34038
34300
|
if (value._id && typeof value._id === "string") {
|
|
34039
34301
|
try {
|
|
34040
|
-
value._id = new
|
|
34302
|
+
value._id = new import_mongodb85.ObjectId(value._id);
|
|
34041
34303
|
} catch {
|
|
34042
34304
|
throw new import_node_server_utils144.BadRequestError("Invalid _id format");
|
|
34043
34305
|
}
|
|
34044
34306
|
}
|
|
34045
34307
|
if (value.site && typeof value.site === "string") {
|
|
34046
34308
|
try {
|
|
34047
|
-
value.site = new
|
|
34309
|
+
value.site = new import_mongodb85.ObjectId(value.site);
|
|
34048
34310
|
} catch {
|
|
34049
34311
|
throw new import_node_server_utils144.BadRequestError("Invalid site id format");
|
|
34050
34312
|
}
|
|
34051
34313
|
}
|
|
34052
34314
|
if (value.org && typeof value.org === "string") {
|
|
34053
34315
|
try {
|
|
34054
|
-
value.org = new
|
|
34316
|
+
value.org = new import_mongodb85.ObjectId(value.org);
|
|
34055
34317
|
} catch {
|
|
34056
34318
|
throw new import_node_server_utils144.BadRequestError("Invalid org id format");
|
|
34057
34319
|
}
|
|
34058
34320
|
}
|
|
34059
34321
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
34060
34322
|
try {
|
|
34061
|
-
value.createdBy = new
|
|
34323
|
+
value.createdBy = new import_mongodb85.ObjectId(value.createdBy);
|
|
34062
34324
|
} catch {
|
|
34063
34325
|
throw new import_node_server_utils144.BadRequestError("Invalid createdBy id format");
|
|
34064
34326
|
}
|
|
34065
34327
|
}
|
|
34066
34328
|
return {
|
|
34067
|
-
_id: value._id ?? new
|
|
34329
|
+
_id: value._id ?? new import_mongodb85.ObjectId(),
|
|
34068
34330
|
site: value.site,
|
|
34069
34331
|
org: value.org,
|
|
34070
34332
|
siteName: value.siteName,
|
|
@@ -34093,7 +34355,7 @@ function MBillingConfiguration(value) {
|
|
|
34093
34355
|
}
|
|
34094
34356
|
|
|
34095
34357
|
// src/repositories/site-billing-configuration.repo.ts
|
|
34096
|
-
var
|
|
34358
|
+
var import_mongodb86 = require("mongodb");
|
|
34097
34359
|
function useSiteBillingConfigurationRepo() {
|
|
34098
34360
|
const db = import_node_server_utils145.useAtlas.getDb();
|
|
34099
34361
|
if (!db) {
|
|
@@ -34166,7 +34428,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34166
34428
|
const query = {
|
|
34167
34429
|
status,
|
|
34168
34430
|
...search && { $text: { $search: search } },
|
|
34169
|
-
...
|
|
34431
|
+
...import_mongodb86.ObjectId.isValid(site) && { site: new import_mongodb86.ObjectId(site) }
|
|
34170
34432
|
};
|
|
34171
34433
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
34172
34434
|
const cacheOptions = {
|
|
@@ -34206,7 +34468,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34206
34468
|
}
|
|
34207
34469
|
async function getById(_id) {
|
|
34208
34470
|
try {
|
|
34209
|
-
_id = new
|
|
34471
|
+
_id = new import_mongodb86.ObjectId(_id);
|
|
34210
34472
|
} catch (error) {
|
|
34211
34473
|
throw new import_node_server_utils145.BadRequestError("Invalid ID.");
|
|
34212
34474
|
}
|
|
@@ -34247,22 +34509,22 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34247
34509
|
}
|
|
34248
34510
|
async function updateById(_id, value, session) {
|
|
34249
34511
|
try {
|
|
34250
|
-
_id = new
|
|
34512
|
+
_id = new import_mongodb86.ObjectId(_id);
|
|
34251
34513
|
} catch (error) {
|
|
34252
34514
|
throw new import_node_server_utils145.BadRequestError(
|
|
34253
34515
|
"Invalid site billing configuration transaction ID format."
|
|
34254
34516
|
);
|
|
34255
34517
|
}
|
|
34256
|
-
if (value.site &&
|
|
34518
|
+
if (value.site && import_mongodb86.ObjectId.isValid(value.site.toString())) {
|
|
34257
34519
|
try {
|
|
34258
|
-
value.site = new
|
|
34520
|
+
value.site = new import_mongodb86.ObjectId(value.site.toString());
|
|
34259
34521
|
} catch {
|
|
34260
34522
|
throw new import_node_server_utils145.BadRequestError("Invalid _id format");
|
|
34261
34523
|
}
|
|
34262
34524
|
}
|
|
34263
|
-
if (value.org &&
|
|
34525
|
+
if (value.org && import_mongodb86.ObjectId.isValid(value.org.toString())) {
|
|
34264
34526
|
try {
|
|
34265
|
-
value.org = new
|
|
34527
|
+
value.org = new import_mongodb86.ObjectId(value.org.toString());
|
|
34266
34528
|
} catch {
|
|
34267
34529
|
throw new import_node_server_utils145.BadRequestError("Invalid _id format");
|
|
34268
34530
|
}
|
|
@@ -34282,7 +34544,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34282
34544
|
}
|
|
34283
34545
|
async function deleteById(_id) {
|
|
34284
34546
|
try {
|
|
34285
|
-
_id = new
|
|
34547
|
+
_id = new import_mongodb86.ObjectId(_id);
|
|
34286
34548
|
} catch (error) {
|
|
34287
34549
|
throw new import_node_server_utils145.BadRequestError(
|
|
34288
34550
|
"Invalid site billing configuration transaction ID format."
|
|
@@ -34860,7 +35122,7 @@ function useSiteBillingConfigurationController() {
|
|
|
34860
35122
|
}
|
|
34861
35123
|
|
|
34862
35124
|
// src/models/event-management.model.ts
|
|
34863
|
-
var
|
|
35125
|
+
var import_mongodb87 = require("mongodb");
|
|
34864
35126
|
var import_joi83 = __toESM(require("joi"));
|
|
34865
35127
|
var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
|
|
34866
35128
|
EventStatus2["PLANNED"] = "planned";
|
|
@@ -34904,20 +35166,20 @@ var schemaUpdateEventManagement = import_joi83.default.object({
|
|
|
34904
35166
|
function MEventManagement(value) {
|
|
34905
35167
|
if (value._id && typeof value._id === "string") {
|
|
34906
35168
|
try {
|
|
34907
|
-
value._id = new
|
|
35169
|
+
value._id = new import_mongodb87.ObjectId(value._id);
|
|
34908
35170
|
} catch {
|
|
34909
35171
|
throw new Error("Invalid ID.");
|
|
34910
35172
|
}
|
|
34911
35173
|
}
|
|
34912
35174
|
if (value.site && typeof value.site === "string") {
|
|
34913
35175
|
try {
|
|
34914
|
-
value.site = new
|
|
35176
|
+
value.site = new import_mongodb87.ObjectId(value.site);
|
|
34915
35177
|
} catch {
|
|
34916
35178
|
throw new Error("Invalid site ID.");
|
|
34917
35179
|
}
|
|
34918
35180
|
}
|
|
34919
35181
|
return {
|
|
34920
|
-
_id: value._id ?? new
|
|
35182
|
+
_id: value._id ?? new import_mongodb87.ObjectId(),
|
|
34921
35183
|
site: value.site,
|
|
34922
35184
|
title: value.title,
|
|
34923
35185
|
description: value.description ?? "",
|
|
@@ -34932,7 +35194,7 @@ function MEventManagement(value) {
|
|
|
34932
35194
|
|
|
34933
35195
|
// src/repositories/event-management.repo.ts
|
|
34934
35196
|
var import_node_server_utils150 = require("@7365admin1/node-server-utils");
|
|
34935
|
-
var
|
|
35197
|
+
var import_mongodb88 = require("mongodb");
|
|
34936
35198
|
var events_namespace_collection = "event-management";
|
|
34937
35199
|
function useEventManagementRepo() {
|
|
34938
35200
|
const db = import_node_server_utils150.useAtlas.getDb();
|
|
@@ -35000,7 +35262,7 @@ function useEventManagementRepo() {
|
|
|
35000
35262
|
}, session) {
|
|
35001
35263
|
page = page > 0 ? page - 1 : 0;
|
|
35002
35264
|
try {
|
|
35003
|
-
site = new
|
|
35265
|
+
site = new import_mongodb88.ObjectId(site);
|
|
35004
35266
|
} catch (error) {
|
|
35005
35267
|
throw new import_node_server_utils150.BadRequestError("Invalid site ID format.");
|
|
35006
35268
|
}
|
|
@@ -35088,7 +35350,7 @@ function useEventManagementRepo() {
|
|
|
35088
35350
|
}
|
|
35089
35351
|
async function getEventManagementById(_id, session) {
|
|
35090
35352
|
try {
|
|
35091
|
-
_id = new
|
|
35353
|
+
_id = new import_mongodb88.ObjectId(_id);
|
|
35092
35354
|
} catch (error) {
|
|
35093
35355
|
throw new import_node_server_utils150.BadRequestError("Invalid event ID format.");
|
|
35094
35356
|
}
|
|
@@ -35116,13 +35378,13 @@ function useEventManagementRepo() {
|
|
|
35116
35378
|
async function updateEventManagementById(_id, value, session) {
|
|
35117
35379
|
value.updatedAt = /* @__PURE__ */ new Date();
|
|
35118
35380
|
try {
|
|
35119
|
-
_id = new
|
|
35381
|
+
_id = new import_mongodb88.ObjectId(_id);
|
|
35120
35382
|
} catch (error) {
|
|
35121
35383
|
throw new import_node_server_utils150.BadRequestError("Invalid ID format.");
|
|
35122
35384
|
}
|
|
35123
35385
|
if (value.site && typeof value.site === "string") {
|
|
35124
35386
|
try {
|
|
35125
|
-
value.site = new
|
|
35387
|
+
value.site = new import_mongodb88.ObjectId(value.site);
|
|
35126
35388
|
} catch {
|
|
35127
35389
|
throw new Error("Invalid site ID.");
|
|
35128
35390
|
}
|
|
@@ -35153,7 +35415,7 @@ function useEventManagementRepo() {
|
|
|
35153
35415
|
}
|
|
35154
35416
|
async function deleteEventManagementById(_id) {
|
|
35155
35417
|
try {
|
|
35156
|
-
_id = new
|
|
35418
|
+
_id = new import_mongodb88.ObjectId(_id);
|
|
35157
35419
|
} catch (error) {
|
|
35158
35420
|
throw new import_node_server_utils150.BadRequestError("Invalid event ID format.");
|
|
35159
35421
|
}
|
|
@@ -35441,7 +35703,7 @@ function useEventManagementController() {
|
|
|
35441
35703
|
|
|
35442
35704
|
// src/models/site-unit-billing.model.ts
|
|
35443
35705
|
var import_node_server_utils153 = require("@7365admin1/node-server-utils");
|
|
35444
|
-
var
|
|
35706
|
+
var import_mongodb89 = require("mongodb");
|
|
35445
35707
|
var import_joi85 = __toESM(require("joi"));
|
|
35446
35708
|
var Status = /* @__PURE__ */ ((Status2) => {
|
|
35447
35709
|
Status2["PENDING"] = "pending";
|
|
@@ -35536,48 +35798,48 @@ function MUnitBilling(value) {
|
|
|
35536
35798
|
}
|
|
35537
35799
|
if (value._id && typeof value._id === "string") {
|
|
35538
35800
|
try {
|
|
35539
|
-
value._id = new
|
|
35801
|
+
value._id = new import_mongodb89.ObjectId(value._id);
|
|
35540
35802
|
} catch {
|
|
35541
35803
|
throw new import_node_server_utils153.BadRequestError("Invalid _id format");
|
|
35542
35804
|
}
|
|
35543
35805
|
}
|
|
35544
35806
|
if (value.site && typeof value.site === "string") {
|
|
35545
35807
|
try {
|
|
35546
|
-
value.site = new
|
|
35808
|
+
value.site = new import_mongodb89.ObjectId(value.site);
|
|
35547
35809
|
} catch {
|
|
35548
35810
|
throw new import_node_server_utils153.BadRequestError("Invalid site id format");
|
|
35549
35811
|
}
|
|
35550
35812
|
}
|
|
35551
35813
|
if (value.org && typeof value.org === "string") {
|
|
35552
35814
|
try {
|
|
35553
|
-
value.org = new
|
|
35815
|
+
value.org = new import_mongodb89.ObjectId(value.org);
|
|
35554
35816
|
} catch {
|
|
35555
35817
|
throw new import_node_server_utils153.BadRequestError("Invalid org id format");
|
|
35556
35818
|
}
|
|
35557
35819
|
}
|
|
35558
35820
|
if (value.paidBy && typeof value.paidBy === "string") {
|
|
35559
35821
|
try {
|
|
35560
|
-
value.paidBy = new
|
|
35822
|
+
value.paidBy = new import_mongodb89.ObjectId(value.paidBy);
|
|
35561
35823
|
} catch {
|
|
35562
35824
|
throw new import_node_server_utils153.BadRequestError("Invalid paidBy id format");
|
|
35563
35825
|
}
|
|
35564
35826
|
}
|
|
35565
35827
|
if (value.billItem && typeof value.billItem === "string") {
|
|
35566
35828
|
try {
|
|
35567
|
-
value.billItem = new
|
|
35829
|
+
value.billItem = new import_mongodb89.ObjectId(value.billItem);
|
|
35568
35830
|
} catch {
|
|
35569
35831
|
throw new import_node_server_utils153.BadRequestError("Invalid billItem id format");
|
|
35570
35832
|
}
|
|
35571
35833
|
}
|
|
35572
35834
|
if (value.unitId && typeof value.unitId === "string") {
|
|
35573
35835
|
try {
|
|
35574
|
-
value.unitId = new
|
|
35836
|
+
value.unitId = new import_mongodb89.ObjectId(value.unitId);
|
|
35575
35837
|
} catch {
|
|
35576
35838
|
throw new import_node_server_utils153.BadRequestError("Invalid unitId id format");
|
|
35577
35839
|
}
|
|
35578
35840
|
}
|
|
35579
35841
|
return {
|
|
35580
|
-
_id: value._id ?? new
|
|
35842
|
+
_id: value._id ?? new import_mongodb89.ObjectId(),
|
|
35581
35843
|
site: value.site ?? "",
|
|
35582
35844
|
org: value.org ?? "",
|
|
35583
35845
|
billItem: value.billItem ?? "",
|
|
@@ -35613,7 +35875,7 @@ function MUnitBilling(value) {
|
|
|
35613
35875
|
|
|
35614
35876
|
// src/repositories/site-unit-billing.repo.ts
|
|
35615
35877
|
var import_node_server_utils154 = require("@7365admin1/node-server-utils");
|
|
35616
|
-
var
|
|
35878
|
+
var import_mongodb90 = require("mongodb");
|
|
35617
35879
|
function useSiteUnitBillingRepo() {
|
|
35618
35880
|
const db = import_node_server_utils154.useAtlas.getDb();
|
|
35619
35881
|
if (!db) {
|
|
@@ -35663,7 +35925,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35663
35925
|
const res = await collection.insertOne(value, { session });
|
|
35664
35926
|
const acronym = createAcronym(value.billName || "NA");
|
|
35665
35927
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
|
|
35666
|
-
const newId = new
|
|
35928
|
+
const newId = new import_mongodb90.ObjectId(res.insertedId).toString().slice(-6);
|
|
35667
35929
|
const referenceNumber = `${acronym}${newId}${dateFormatted}`;
|
|
35668
35930
|
await collection.updateOne(
|
|
35669
35931
|
{ _id: res.insertedId },
|
|
@@ -35741,7 +36003,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35741
36003
|
}
|
|
35742
36004
|
]
|
|
35743
36005
|
},
|
|
35744
|
-
...
|
|
36006
|
+
...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
35745
36007
|
...dateExpr
|
|
35746
36008
|
};
|
|
35747
36009
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -35807,7 +36069,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35807
36069
|
}
|
|
35808
36070
|
async function getById(_id) {
|
|
35809
36071
|
try {
|
|
35810
|
-
_id = new
|
|
36072
|
+
_id = new import_mongodb90.ObjectId(_id);
|
|
35811
36073
|
} catch (error) {
|
|
35812
36074
|
throw new import_node_server_utils154.BadRequestError("Invalid ID.");
|
|
35813
36075
|
}
|
|
@@ -35866,8 +36128,8 @@ function useSiteUnitBillingRepo() {
|
|
|
35866
36128
|
}
|
|
35867
36129
|
const query = {
|
|
35868
36130
|
status,
|
|
35869
|
-
...unitId &&
|
|
35870
|
-
...site &&
|
|
36131
|
+
...unitId && import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) },
|
|
36132
|
+
...site && import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
35871
36133
|
...dateExpr
|
|
35872
36134
|
};
|
|
35873
36135
|
try {
|
|
@@ -35905,43 +36167,43 @@ function useSiteUnitBillingRepo() {
|
|
|
35905
36167
|
}
|
|
35906
36168
|
async function updateById(_id, value, session) {
|
|
35907
36169
|
try {
|
|
35908
|
-
_id = new
|
|
36170
|
+
_id = new import_mongodb90.ObjectId(_id);
|
|
35909
36171
|
} catch (error) {
|
|
35910
36172
|
throw new import_node_server_utils154.BadRequestError(
|
|
35911
36173
|
"Invalid site unit billing transaction ID format."
|
|
35912
36174
|
);
|
|
35913
36175
|
}
|
|
35914
|
-
if (value.site &&
|
|
36176
|
+
if (value.site && import_mongodb90.ObjectId.isValid(value.site.toString())) {
|
|
35915
36177
|
try {
|
|
35916
|
-
value.site = new
|
|
36178
|
+
value.site = new import_mongodb90.ObjectId(value.site.toString());
|
|
35917
36179
|
} catch {
|
|
35918
36180
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35919
36181
|
}
|
|
35920
36182
|
}
|
|
35921
|
-
if (value.org &&
|
|
36183
|
+
if (value.org && import_mongodb90.ObjectId.isValid(value.org.toString())) {
|
|
35922
36184
|
try {
|
|
35923
|
-
value.org = new
|
|
36185
|
+
value.org = new import_mongodb90.ObjectId(value.org.toString());
|
|
35924
36186
|
} catch {
|
|
35925
36187
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35926
36188
|
}
|
|
35927
36189
|
}
|
|
35928
|
-
if (value.paidBy &&
|
|
36190
|
+
if (value.paidBy && import_mongodb90.ObjectId.isValid(value.paidBy.toString())) {
|
|
35929
36191
|
try {
|
|
35930
|
-
value.org = new
|
|
36192
|
+
value.org = new import_mongodb90.ObjectId(value.paidBy.toString());
|
|
35931
36193
|
} catch {
|
|
35932
36194
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35933
36195
|
}
|
|
35934
36196
|
}
|
|
35935
|
-
if (value.billItem &&
|
|
36197
|
+
if (value.billItem && import_mongodb90.ObjectId.isValid(value.billItem.toString())) {
|
|
35936
36198
|
try {
|
|
35937
|
-
value.billItem = new
|
|
36199
|
+
value.billItem = new import_mongodb90.ObjectId(value.billItem.toString());
|
|
35938
36200
|
} catch {
|
|
35939
36201
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35940
36202
|
}
|
|
35941
36203
|
}
|
|
35942
|
-
if (value.unitId &&
|
|
36204
|
+
if (value.unitId && import_mongodb90.ObjectId.isValid(value.unitId.toString())) {
|
|
35943
36205
|
try {
|
|
35944
|
-
value.unitId = new
|
|
36206
|
+
value.unitId = new import_mongodb90.ObjectId(value.unitId.toString());
|
|
35945
36207
|
} catch {
|
|
35946
36208
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35947
36209
|
}
|
|
@@ -35961,7 +36223,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35961
36223
|
}
|
|
35962
36224
|
async function deleteById(_id) {
|
|
35963
36225
|
try {
|
|
35964
|
-
_id = new
|
|
36226
|
+
_id = new import_mongodb90.ObjectId(_id);
|
|
35965
36227
|
} catch (error) {
|
|
35966
36228
|
throw new import_node_server_utils154.BadRequestError(
|
|
35967
36229
|
"Invalid site unit billing transaction ID format."
|
|
@@ -36027,9 +36289,9 @@ function useSiteUnitBillingRepo() {
|
|
|
36027
36289
|
}
|
|
36028
36290
|
]
|
|
36029
36291
|
},
|
|
36030
|
-
...
|
|
36292
|
+
...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
36031
36293
|
...dateExpr,
|
|
36032
|
-
...
|
|
36294
|
+
...import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) }
|
|
36033
36295
|
};
|
|
36034
36296
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36035
36297
|
try {
|
|
@@ -36116,9 +36378,9 @@ function useSiteUnitBillingRepo() {
|
|
|
36116
36378
|
}
|
|
36117
36379
|
]
|
|
36118
36380
|
},
|
|
36119
|
-
...
|
|
36381
|
+
...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
36120
36382
|
...dateExpr,
|
|
36121
|
-
...
|
|
36383
|
+
...import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) }
|
|
36122
36384
|
};
|
|
36123
36385
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36124
36386
|
try {
|
|
@@ -36201,7 +36463,7 @@ function useSiteUnitBillingRepo() {
|
|
|
36201
36463
|
|
|
36202
36464
|
// src/services/site-unit-billing.service.ts
|
|
36203
36465
|
var import_node_server_utils155 = require("@7365admin1/node-server-utils");
|
|
36204
|
-
var
|
|
36466
|
+
var import_mongodb91 = require("mongodb");
|
|
36205
36467
|
function useSiteUnitBillingService() {
|
|
36206
36468
|
const {
|
|
36207
36469
|
add: _add,
|
|
@@ -36358,7 +36620,7 @@ function useSiteUnitBillingService() {
|
|
|
36358
36620
|
return unitsWithOwner || [];
|
|
36359
36621
|
} else {
|
|
36360
36622
|
if (units && units.length > 0) {
|
|
36361
|
-
const unitIds = units.map((unit) => new
|
|
36623
|
+
const unitIds = units.map((unit) => new import_mongodb91.ObjectId(unit._id));
|
|
36362
36624
|
const specificUnitsWithOwner = await _getBuildingUnitsWithOwner(
|
|
36363
36625
|
site || "",
|
|
36364
36626
|
unitIds
|
|
@@ -36639,7 +36901,7 @@ function useSiteUnitBillingController() {
|
|
|
36639
36901
|
}
|
|
36640
36902
|
|
|
36641
36903
|
// src/models/access-management.model.ts
|
|
36642
|
-
var
|
|
36904
|
+
var import_mongodb92 = require("mongodb");
|
|
36643
36905
|
var EAccessCardTypes = /* @__PURE__ */ ((EAccessCardTypes2) => {
|
|
36644
36906
|
EAccessCardTypes2["NFC"] = "NFC";
|
|
36645
36907
|
EAccessCardTypes2["QR"] = "QRCODE";
|
|
@@ -36661,7 +36923,7 @@ var AccessTypeProps = /* @__PURE__ */ ((AccessTypeProps2) => {
|
|
|
36661
36923
|
})(AccessTypeProps || {});
|
|
36662
36924
|
var MAccessCardTransaction = class {
|
|
36663
36925
|
constructor({
|
|
36664
|
-
_id = new
|
|
36926
|
+
_id = new import_mongodb92.ObjectId(),
|
|
36665
36927
|
index,
|
|
36666
36928
|
site,
|
|
36667
36929
|
cardNo,
|
|
@@ -36688,7 +36950,7 @@ var MAccessCardTransaction = class {
|
|
|
36688
36950
|
};
|
|
36689
36951
|
var MAccessCard = class {
|
|
36690
36952
|
constructor({
|
|
36691
|
-
_id = new
|
|
36953
|
+
_id = new import_mongodb92.ObjectId(),
|
|
36692
36954
|
userId,
|
|
36693
36955
|
site,
|
|
36694
36956
|
staffNo = null,
|
|
@@ -36746,7 +37008,7 @@ var MAccessCard = class {
|
|
|
36746
37008
|
|
|
36747
37009
|
// src/repositories/access-management.repo.ts
|
|
36748
37010
|
var import_node_server_utils157 = require("@7365admin1/node-server-utils");
|
|
36749
|
-
var
|
|
37011
|
+
var import_mongodb93 = require("mongodb");
|
|
36750
37012
|
|
|
36751
37013
|
// src/utils/access-management.ts
|
|
36752
37014
|
var import_fs4 = __toESM(require("fs"));
|
|
@@ -37056,12 +37318,12 @@ function UseAccessManagementRepo() {
|
|
|
37056
37318
|
payload
|
|
37057
37319
|
}) {
|
|
37058
37320
|
try {
|
|
37059
|
-
payload.site = new
|
|
37321
|
+
payload.site = new import_mongodb93.ObjectId(payload.site);
|
|
37060
37322
|
payload.startDate = new Date(payload.startDate);
|
|
37061
37323
|
payload.endDate = new Date(payload.endDate);
|
|
37062
37324
|
payload.createdAt = new Date(payload.createdAt);
|
|
37063
37325
|
payload.updatedAt = new Date(payload.updatedAt);
|
|
37064
|
-
payload.assignedUnit = payload.unit?.map((id) => new
|
|
37326
|
+
payload.assignedUnit = payload.unit?.map((id) => new import_mongodb93.ObjectId(id));
|
|
37065
37327
|
delete payload.unit;
|
|
37066
37328
|
const accessCardObj = new MAccessCard(payload);
|
|
37067
37329
|
const result = await collection().insertOne(accessCardObj);
|
|
@@ -37100,7 +37362,7 @@ function UseAccessManagementRepo() {
|
|
|
37100
37362
|
async function addNonPhysicalCardRepo(params) {
|
|
37101
37363
|
try {
|
|
37102
37364
|
const MAX_RETRIES = 3;
|
|
37103
|
-
const site = new
|
|
37365
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37104
37366
|
const date = /* @__PURE__ */ new Date();
|
|
37105
37367
|
const endDate = new Date(date.setFullYear(date.getFullYear() + 10));
|
|
37106
37368
|
const countPerUnit = params.quantity;
|
|
@@ -37132,7 +37394,7 @@ function UseAccessManagementRepo() {
|
|
|
37132
37394
|
userType: params.userType,
|
|
37133
37395
|
doorName: params.doorName,
|
|
37134
37396
|
liftName: params.liftName,
|
|
37135
|
-
assignedUnit: new
|
|
37397
|
+
assignedUnit: new import_mongodb93.ObjectId(units[i]),
|
|
37136
37398
|
createdAt: new Date(params.createdAt),
|
|
37137
37399
|
updatedAt: new Date(params.updatedAt),
|
|
37138
37400
|
isWinsland: params.isWinsland
|
|
@@ -37218,7 +37480,7 @@ function UseAccessManagementRepo() {
|
|
|
37218
37480
|
}
|
|
37219
37481
|
async function accessManagementSettingsRepo(params) {
|
|
37220
37482
|
try {
|
|
37221
|
-
params.site = new
|
|
37483
|
+
params.site = new import_mongodb93.ObjectId(params.site);
|
|
37222
37484
|
const result = collectionName("entrypass-settings").updateOne(
|
|
37223
37485
|
{ site: params.site },
|
|
37224
37486
|
{
|
|
@@ -37240,7 +37502,7 @@ function UseAccessManagementRepo() {
|
|
|
37240
37502
|
}
|
|
37241
37503
|
async function allAccessCardsCountsRepo(params) {
|
|
37242
37504
|
try {
|
|
37243
|
-
const site = new
|
|
37505
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37244
37506
|
const userType = params.userType;
|
|
37245
37507
|
const result = await collection().aggregate([
|
|
37246
37508
|
{
|
|
@@ -37300,7 +37562,7 @@ function UseAccessManagementRepo() {
|
|
|
37300
37562
|
}
|
|
37301
37563
|
async function availableAccessCardsRepo(params) {
|
|
37302
37564
|
try {
|
|
37303
|
-
const site = new
|
|
37565
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37304
37566
|
const userType = params.userType;
|
|
37305
37567
|
const type = params.type;
|
|
37306
37568
|
const query = {
|
|
@@ -37415,7 +37677,7 @@ function UseAccessManagementRepo() {
|
|
|
37415
37677
|
}
|
|
37416
37678
|
async function userTypeAccessCardsRepo(params) {
|
|
37417
37679
|
try {
|
|
37418
|
-
const site = new
|
|
37680
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37419
37681
|
const userType = params.userType;
|
|
37420
37682
|
const page = params.page ? Number(params.page) - 1 : 0;
|
|
37421
37683
|
const limit = Number(params.limit) || 10;
|
|
@@ -37814,7 +38076,7 @@ function UseAccessManagementRepo() {
|
|
|
37814
38076
|
}
|
|
37815
38077
|
async function assignedAccessCardsRepo(params) {
|
|
37816
38078
|
try {
|
|
37817
|
-
const site = new
|
|
38079
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37818
38080
|
const userType = params.userType;
|
|
37819
38081
|
const type = params.type;
|
|
37820
38082
|
const search = params.search;
|
|
@@ -37989,12 +38251,12 @@ function UseAccessManagementRepo() {
|
|
|
37989
38251
|
session?.startTransaction();
|
|
37990
38252
|
const { userId, cardId, site } = params;
|
|
37991
38253
|
const allUserId = await Promise.all(
|
|
37992
|
-
userId.map(async (id) => new
|
|
38254
|
+
userId.map(async (id) => new import_mongodb93.ObjectId(id))
|
|
37993
38255
|
);
|
|
37994
38256
|
const allCardId = await Promise.all(
|
|
37995
|
-
cardId.map(async (id) => new
|
|
38257
|
+
cardId.map(async (id) => new import_mongodb93.ObjectId(id))
|
|
37996
38258
|
);
|
|
37997
|
-
const siteId = new
|
|
38259
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
37998
38260
|
const result = await collection().updateMany(
|
|
37999
38261
|
{
|
|
38000
38262
|
$or: [
|
|
@@ -38025,7 +38287,7 @@ function UseAccessManagementRepo() {
|
|
|
38025
38287
|
async function accessandLiftCardsRepo(params) {
|
|
38026
38288
|
try {
|
|
38027
38289
|
const { accessLevel, liftAccessLevel, site, userType, type } = params;
|
|
38028
|
-
const siteId = new
|
|
38290
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
38029
38291
|
const query = {
|
|
38030
38292
|
site: { $in: [siteId] },
|
|
38031
38293
|
userType,
|
|
@@ -38058,9 +38320,9 @@ function UseAccessManagementRepo() {
|
|
|
38058
38320
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
38059
38321
|
try {
|
|
38060
38322
|
session?.startTransaction();
|
|
38061
|
-
const siteId = new
|
|
38062
|
-
const userId = new
|
|
38063
|
-
const cardId = new
|
|
38323
|
+
const siteId = new import_mongodb93.ObjectId(params.site);
|
|
38324
|
+
const userId = new import_mongodb93.ObjectId(params.userId);
|
|
38325
|
+
const cardId = new import_mongodb93.ObjectId(params.cardId);
|
|
38064
38326
|
const quantity = 1;
|
|
38065
38327
|
const cardCredentials = await collection().findOneAndUpdate(
|
|
38066
38328
|
{ _id: cardId },
|
|
@@ -38086,7 +38348,7 @@ function UseAccessManagementRepo() {
|
|
|
38086
38348
|
(no) => no.toString().padStart(10, "0")
|
|
38087
38349
|
);
|
|
38088
38350
|
const accessCards = [];
|
|
38089
|
-
const convertedUnits = unit.map((obj) => new
|
|
38351
|
+
const convertedUnits = unit.map((obj) => new import_mongodb93.ObjectId(obj));
|
|
38090
38352
|
for (let j = 0; j < (unit.length > 0 ? unit.length : quantity); j++) {
|
|
38091
38353
|
accessCards.push(
|
|
38092
38354
|
new MAccessCard({
|
|
@@ -38175,7 +38437,7 @@ function UseAccessManagementRepo() {
|
|
|
38175
38437
|
session?.startTransaction();
|
|
38176
38438
|
const results = [];
|
|
38177
38439
|
for (let nfc of params.nfcList) {
|
|
38178
|
-
nfc._id = new
|
|
38440
|
+
nfc._id = new import_mongodb93.ObjectId(nfc._id);
|
|
38179
38441
|
const card = await collection().findOne({ _id: nfc._id }, { session });
|
|
38180
38442
|
if (card) {
|
|
38181
38443
|
const updateFields = {
|
|
@@ -38209,7 +38471,7 @@ function UseAccessManagementRepo() {
|
|
|
38209
38471
|
async function doorAndLiftDropdownRepo(params) {
|
|
38210
38472
|
try {
|
|
38211
38473
|
const { site, type, userType } = params;
|
|
38212
|
-
const id = new
|
|
38474
|
+
const id = new import_mongodb93.ObjectId(site);
|
|
38213
38475
|
const res = collection().aggregate([
|
|
38214
38476
|
{
|
|
38215
38477
|
$match: {
|
|
@@ -38296,10 +38558,10 @@ function UseAccessManagementRepo() {
|
|
|
38296
38558
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
38297
38559
|
try {
|
|
38298
38560
|
const { cardId, remarks, issuedCardId, unitId, userId } = params;
|
|
38299
|
-
const id = new
|
|
38300
|
-
const newCardId = new
|
|
38301
|
-
const unit = new
|
|
38302
|
-
const user = new
|
|
38561
|
+
const id = new import_mongodb93.ObjectId(cardId);
|
|
38562
|
+
const newCardId = new import_mongodb93.ObjectId(issuedCardId);
|
|
38563
|
+
const unit = new import_mongodb93.ObjectId(unitId);
|
|
38564
|
+
const user = new import_mongodb93.ObjectId(userId);
|
|
38303
38565
|
session?.startTransaction();
|
|
38304
38566
|
const sessionResult = await Promise.all([
|
|
38305
38567
|
await collection().findOneAndUpdate(
|
|
@@ -38332,7 +38594,7 @@ function UseAccessManagementRepo() {
|
|
|
38332
38594
|
async function visitorAccessCardsRepo(params) {
|
|
38333
38595
|
try {
|
|
38334
38596
|
const page = params.page ? params.page - 1 : 0;
|
|
38335
|
-
const siteId = new
|
|
38597
|
+
const siteId = new import_mongodb93.ObjectId(params.site);
|
|
38336
38598
|
const search = params.search;
|
|
38337
38599
|
const type = params.type;
|
|
38338
38600
|
const limit = Number(params.limit);
|
|
@@ -38400,7 +38662,7 @@ function UseAccessManagementRepo() {
|
|
|
38400
38662
|
}
|
|
38401
38663
|
async function getCardReplacementRepo(params) {
|
|
38402
38664
|
try {
|
|
38403
|
-
const site = new
|
|
38665
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
38404
38666
|
const search = params.search;
|
|
38405
38667
|
const statusFilter = params.statusFilter;
|
|
38406
38668
|
const dateFrom = params.dateFrom;
|
|
@@ -38572,7 +38834,7 @@ function UseAccessManagementRepo() {
|
|
|
38572
38834
|
async function getAccessManagementSettingsRepo(params) {
|
|
38573
38835
|
try {
|
|
38574
38836
|
const { site } = params;
|
|
38575
|
-
const siteId = new
|
|
38837
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
38576
38838
|
const res = await collectionName("entrypass-settings").findOne(
|
|
38577
38839
|
{ site: siteId },
|
|
38578
38840
|
{ allowDiskUse: true }
|
|
@@ -38606,7 +38868,7 @@ function UseAccessManagementRepo() {
|
|
|
38606
38868
|
const rawAccessGroup = item["accessGroup (value ex. Full Access, No Access)"];
|
|
38607
38869
|
const accessGroup = typeof rawAccessGroup === "string" ? rawAccessGroup.split(",").map((v) => v.trim()).filter((v) => v !== "") : [];
|
|
38608
38870
|
return new MAccessCard({
|
|
38609
|
-
site: new
|
|
38871
|
+
site: new import_mongodb93.ObjectId(site),
|
|
38610
38872
|
type: "NFC" /* NFC */,
|
|
38611
38873
|
staffNo: null,
|
|
38612
38874
|
accessLevel,
|
|
@@ -38657,8 +38919,8 @@ function UseAccessManagementRepo() {
|
|
|
38657
38919
|
liftAccessLevel
|
|
38658
38920
|
} = params;
|
|
38659
38921
|
const [convertedUnits, convertedSite] = await Promise.all([
|
|
38660
|
-
Promise.all(units.map((id) => new
|
|
38661
|
-
new
|
|
38922
|
+
Promise.all(units.map((id) => new import_mongodb93.ObjectId(id))),
|
|
38923
|
+
new import_mongodb93.ObjectId(site)
|
|
38662
38924
|
]);
|
|
38663
38925
|
const totalRequired = quantity * convertedUnits.length;
|
|
38664
38926
|
const availableCards = await collection().find({
|
|
@@ -38710,7 +38972,7 @@ function UseAccessManagementRepo() {
|
|
|
38710
38972
|
async function deleteCardRepo(params) {
|
|
38711
38973
|
try {
|
|
38712
38974
|
const { cardId, remarks } = params;
|
|
38713
|
-
const id = new
|
|
38975
|
+
const id = new import_mongodb93.ObjectId(cardId);
|
|
38714
38976
|
const result = await collection().findOneAndUpdate(
|
|
38715
38977
|
{ _id: id },
|
|
38716
38978
|
{
|
|
@@ -38731,8 +38993,8 @@ function UseAccessManagementRepo() {
|
|
|
38731
38993
|
async function getCardDetailsRepo(params) {
|
|
38732
38994
|
try {
|
|
38733
38995
|
const { siteId, cardId } = params;
|
|
38734
|
-
const convertedSiteId = new
|
|
38735
|
-
const convertedCardId = new
|
|
38996
|
+
const convertedSiteId = new import_mongodb93.ObjectId(siteId);
|
|
38997
|
+
const convertedCardId = new import_mongodb93.ObjectId(cardId);
|
|
38736
38998
|
const card = await collection().findOne(
|
|
38737
38999
|
{
|
|
38738
39000
|
_id: convertedCardId,
|
|
@@ -38781,7 +39043,7 @@ function UseAccessManagementRepo() {
|
|
|
38781
39043
|
async function addQrTagRepo(params) {
|
|
38782
39044
|
try {
|
|
38783
39045
|
const { site, payload } = params;
|
|
38784
|
-
const id = new
|
|
39046
|
+
const id = new import_mongodb93.ObjectId(site);
|
|
38785
39047
|
const highestCardNo = await collection().aggregate([
|
|
38786
39048
|
{
|
|
38787
39049
|
$match: {
|
|
@@ -38815,7 +39077,7 @@ function UseAccessManagementRepo() {
|
|
|
38815
39077
|
);
|
|
38816
39078
|
const bulkOps = await Promise.all(
|
|
38817
39079
|
payload.map(async (doc, index) => {
|
|
38818
|
-
const id2 = new
|
|
39080
|
+
const id2 = new import_mongodb93.ObjectId(doc._id);
|
|
38819
39081
|
return {
|
|
38820
39082
|
updateOne: {
|
|
38821
39083
|
filter: { _id: id2 },
|
|
@@ -38838,7 +39100,7 @@ function UseAccessManagementRepo() {
|
|
|
38838
39100
|
async function allQrTagRepo(params) {
|
|
38839
39101
|
try {
|
|
38840
39102
|
const { site } = params;
|
|
38841
|
-
const siteId = new
|
|
39103
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
38842
39104
|
const query = {
|
|
38843
39105
|
site: siteId,
|
|
38844
39106
|
assignedUnit: { $ne: null },
|
|
@@ -38887,8 +39149,8 @@ function UseAccessManagementRepo() {
|
|
|
38887
39149
|
}
|
|
38888
39150
|
async function availableCardContractorsRepo(params) {
|
|
38889
39151
|
try {
|
|
38890
|
-
const siteId = new
|
|
38891
|
-
const unitId = new
|
|
39152
|
+
const siteId = new import_mongodb93.ObjectId(params.siteId);
|
|
39153
|
+
const unitId = new import_mongodb93.ObjectId(params.unitId);
|
|
38892
39154
|
const page = Number(params.page) - 1;
|
|
38893
39155
|
const limit = Number(params.limit) || 10;
|
|
38894
39156
|
const type = params.type;
|
|
@@ -38989,8 +39251,8 @@ function UseAccessManagementRepo() {
|
|
|
38989
39251
|
}
|
|
38990
39252
|
async function vmsgenerateQrCodesRepo(params) {
|
|
38991
39253
|
try {
|
|
38992
|
-
const site = new
|
|
38993
|
-
const unitId = new
|
|
39254
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
39255
|
+
const unitId = new import_mongodb93.ObjectId(params.unitId);
|
|
38994
39256
|
const quantity = Number(params.quantity);
|
|
38995
39257
|
const normalizedUnitId = params.normalizedUnitId;
|
|
38996
39258
|
const date = /* @__PURE__ */ new Date();
|
|
@@ -39045,11 +39307,11 @@ function UseAccessManagementRepo() {
|
|
|
39045
39307
|
let isAborted = false;
|
|
39046
39308
|
try {
|
|
39047
39309
|
await session?.startTransaction();
|
|
39048
|
-
const siteId = new
|
|
39049
|
-
const unitId = new
|
|
39310
|
+
const siteId = new import_mongodb93.ObjectId(params.site);
|
|
39311
|
+
const unitId = new import_mongodb93.ObjectId(params.unitId);
|
|
39050
39312
|
const quantity = params.quantity;
|
|
39051
39313
|
const type = params.type;
|
|
39052
|
-
const visitorId = new
|
|
39314
|
+
const visitorId = new import_mongodb93.ObjectId(params.visitorId);
|
|
39053
39315
|
const nfcCards = params.nfcCards;
|
|
39054
39316
|
const acm_url = params.acm_url;
|
|
39055
39317
|
let cards = [];
|
|
@@ -39071,7 +39333,7 @@ function UseAccessManagementRepo() {
|
|
|
39071
39333
|
} else if (type === "NFC" /* NFC */) {
|
|
39072
39334
|
if (nfcCards && nfcCards.length > 0) {
|
|
39073
39335
|
const objectIds = nfcCards.map(
|
|
39074
|
-
(card) => new
|
|
39336
|
+
(card) => new import_mongodb93.ObjectId(card._id)
|
|
39075
39337
|
);
|
|
39076
39338
|
cards = await collection().find({ _id: { $in: objectIds } }).toArray();
|
|
39077
39339
|
const nfcList = objectIds.map((card) => ({
|
|
@@ -39178,7 +39440,7 @@ function UseAccessManagementRepo() {
|
|
|
39178
39440
|
}
|
|
39179
39441
|
async function signQrCodeRepo(params) {
|
|
39180
39442
|
try {
|
|
39181
|
-
const cardId = new
|
|
39443
|
+
const cardId = new import_mongodb93.ObjectId(params.cardId);
|
|
39182
39444
|
const purpose = params.purpose;
|
|
39183
39445
|
let validity = 5;
|
|
39184
39446
|
const card = await collection().findOne({ _id: cardId });
|
|
@@ -39203,7 +39465,7 @@ function UseAccessManagementRepo() {
|
|
|
39203
39465
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
39204
39466
|
try {
|
|
39205
39467
|
await session?.startTransaction();
|
|
39206
|
-
const userId = new
|
|
39468
|
+
const userId = new import_mongodb93.ObjectId(params.userId);
|
|
39207
39469
|
const result = await collection().updateMany(
|
|
39208
39470
|
{ userId },
|
|
39209
39471
|
{ $set: { userId: null, status: "Available", updatedAt: /* @__PURE__ */ new Date() } }
|
|
@@ -39218,7 +39480,7 @@ function UseAccessManagementRepo() {
|
|
|
39218
39480
|
}
|
|
39219
39481
|
}
|
|
39220
39482
|
async function getBlockLevelAndUnitListRepo(params) {
|
|
39221
|
-
const site = new
|
|
39483
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
39222
39484
|
try {
|
|
39223
39485
|
const blocks = await collectionName("buildings").aggregate([
|
|
39224
39486
|
{
|
|
@@ -39288,7 +39550,7 @@ function UseAccessManagementRepo() {
|
|
|
39288
39550
|
url
|
|
39289
39551
|
}) {
|
|
39290
39552
|
page = page ? page - 1 : 0;
|
|
39291
|
-
site = new
|
|
39553
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39292
39554
|
try {
|
|
39293
39555
|
let index = await collectionName("access-card-transactions").findOne(
|
|
39294
39556
|
{},
|
|
@@ -39423,9 +39685,9 @@ function UseAccessManagementRepo() {
|
|
|
39423
39685
|
throw new Error("No user to Assign.");
|
|
39424
39686
|
}
|
|
39425
39687
|
assignees = assignees.map(
|
|
39426
|
-
(data) => new
|
|
39688
|
+
(data) => new import_mongodb93.ObjectId(data)
|
|
39427
39689
|
);
|
|
39428
|
-
unit = new
|
|
39690
|
+
unit = new import_mongodb93.ObjectId(unit);
|
|
39429
39691
|
let availableCards = [];
|
|
39430
39692
|
let update = [];
|
|
39431
39693
|
let cards = [];
|
|
@@ -39458,13 +39720,13 @@ function UseAccessManagementRepo() {
|
|
|
39458
39720
|
throw new Error(`Not enough ${type} cards available.`);
|
|
39459
39721
|
}
|
|
39460
39722
|
cards = availableCards?.slice(0, assignees.length).map((card, index) => {
|
|
39461
|
-
const userId = new
|
|
39723
|
+
const userId = new import_mongodb93.ObjectId(assignees[index].toString());
|
|
39462
39724
|
card.staffNo = userId.toString().slice(-10);
|
|
39463
39725
|
return card;
|
|
39464
39726
|
});
|
|
39465
39727
|
update = availableCards.slice(0, assignees.length).map((card, index) => ({
|
|
39466
39728
|
_id: card._id,
|
|
39467
|
-
userId: new
|
|
39729
|
+
userId: new import_mongodb93.ObjectId(assignees[index])
|
|
39468
39730
|
}));
|
|
39469
39731
|
const commands = cards.map((item, index) => {
|
|
39470
39732
|
let ag = null;
|
|
@@ -39530,7 +39792,7 @@ function UseAccessManagementRepo() {
|
|
|
39530
39792
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
39531
39793
|
try {
|
|
39532
39794
|
session?.startTransaction();
|
|
39533
|
-
const id = new
|
|
39795
|
+
const id = new import_mongodb93.ObjectId(userId);
|
|
39534
39796
|
await collection().updateMany(
|
|
39535
39797
|
{ userId: id },
|
|
39536
39798
|
{ $set: { userId: null, status: "Available" } },
|
|
@@ -39550,8 +39812,8 @@ function UseAccessManagementRepo() {
|
|
|
39550
39812
|
id,
|
|
39551
39813
|
name
|
|
39552
39814
|
}) {
|
|
39553
|
-
site = new
|
|
39554
|
-
id = new
|
|
39815
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39816
|
+
id = new import_mongodb93.ObjectId(id);
|
|
39555
39817
|
try {
|
|
39556
39818
|
const result = await collectionName("sites").updateOne(
|
|
39557
39819
|
{ _id: site },
|
|
@@ -39568,9 +39830,9 @@ function UseAccessManagementRepo() {
|
|
|
39568
39830
|
unitId
|
|
39569
39831
|
}) {
|
|
39570
39832
|
try {
|
|
39571
|
-
orgId = new
|
|
39572
|
-
siteId = new
|
|
39573
|
-
unitId = new
|
|
39833
|
+
orgId = new import_mongodb93.ObjectId(orgId);
|
|
39834
|
+
siteId = new import_mongodb93.ObjectId(siteId);
|
|
39835
|
+
unitId = new import_mongodb93.ObjectId(unitId);
|
|
39574
39836
|
const result = await collectionName("users").aggregate([
|
|
39575
39837
|
{
|
|
39576
39838
|
$match: {
|
|
@@ -39608,8 +39870,8 @@ function UseAccessManagementRepo() {
|
|
|
39608
39870
|
isLiftCard
|
|
39609
39871
|
}) {
|
|
39610
39872
|
try {
|
|
39611
|
-
siteId = new
|
|
39612
|
-
userId = new
|
|
39873
|
+
siteId = new import_mongodb93.ObjectId(siteId);
|
|
39874
|
+
userId = new import_mongodb93.ObjectId(userId);
|
|
39613
39875
|
const query = {
|
|
39614
39876
|
site: siteId,
|
|
39615
39877
|
userId,
|
|
@@ -39630,7 +39892,7 @@ function UseAccessManagementRepo() {
|
|
|
39630
39892
|
}
|
|
39631
39893
|
}
|
|
39632
39894
|
async function removeTemplateRepo({ site }) {
|
|
39633
|
-
site = new
|
|
39895
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39634
39896
|
try {
|
|
39635
39897
|
const result = await collectionName("entrypass-settings").updateOne({ _id: site }, { $set: { "settings.template": {} } });
|
|
39636
39898
|
return result;
|
|
@@ -39643,8 +39905,8 @@ function UseAccessManagementRepo() {
|
|
|
39643
39905
|
page = page ? page - 1 : 0;
|
|
39644
39906
|
let defaultQuery = {};
|
|
39645
39907
|
let searchQuery = {};
|
|
39646
|
-
site = new
|
|
39647
|
-
userId = new
|
|
39908
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39909
|
+
userId = new import_mongodb93.ObjectId(userId);
|
|
39648
39910
|
if (search) {
|
|
39649
39911
|
searchQuery = {
|
|
39650
39912
|
$or: [{ fullName: { $regex: search, $options: "i" } }, { cardNo: { $regex: search, $options: "i" } }]
|
|
@@ -41390,7 +41652,7 @@ function useAccessManagementController() {
|
|
|
41390
41652
|
}
|
|
41391
41653
|
|
|
41392
41654
|
// src/models/nfc-patrol-tag.model.ts
|
|
41393
|
-
var
|
|
41655
|
+
var import_mongodb94 = require("mongodb");
|
|
41394
41656
|
var import_joi88 = __toESM(require("joi"));
|
|
41395
41657
|
var import_node_server_utils158 = require("@7365admin1/node-server-utils");
|
|
41396
41658
|
var DEVICE_STATUS = {
|
|
@@ -41417,27 +41679,27 @@ var schemaNfcPatrolTag = import_joi88.default.object({
|
|
|
41417
41679
|
function MNfcPatrolTag(value) {
|
|
41418
41680
|
if (value._id && typeof value._id === "string") {
|
|
41419
41681
|
try {
|
|
41420
|
-
value._id = new
|
|
41682
|
+
value._id = new import_mongodb94.ObjectId(value._id);
|
|
41421
41683
|
} catch {
|
|
41422
41684
|
throw new import_node_server_utils158.BadRequestError("Invalid ID.");
|
|
41423
41685
|
}
|
|
41424
41686
|
}
|
|
41425
41687
|
if (value.site && typeof value.site === "string") {
|
|
41426
41688
|
try {
|
|
41427
|
-
value.site = new
|
|
41689
|
+
value.site = new import_mongodb94.ObjectId(value.site);
|
|
41428
41690
|
} catch {
|
|
41429
41691
|
throw new import_node_server_utils158.BadRequestError("Invalid site ID.");
|
|
41430
41692
|
}
|
|
41431
41693
|
}
|
|
41432
41694
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
41433
41695
|
try {
|
|
41434
|
-
value.createdBy = new
|
|
41696
|
+
value.createdBy = new import_mongodb94.ObjectId(value.createdBy);
|
|
41435
41697
|
} catch {
|
|
41436
41698
|
throw new import_node_server_utils158.BadRequestError("Invalid Created By ID.");
|
|
41437
41699
|
}
|
|
41438
41700
|
}
|
|
41439
41701
|
return {
|
|
41440
|
-
_id: value._id ?? new
|
|
41702
|
+
_id: value._id ?? new import_mongodb94.ObjectId(),
|
|
41441
41703
|
site: value.site,
|
|
41442
41704
|
tagID: value.tagID,
|
|
41443
41705
|
name: value.name,
|
|
@@ -41449,7 +41711,7 @@ function MNfcPatrolTag(value) {
|
|
|
41449
41711
|
|
|
41450
41712
|
// src/repositories/nfc-patrol-tag.repository.ts
|
|
41451
41713
|
var import_node_server_utils159 = require("@7365admin1/node-server-utils");
|
|
41452
|
-
var
|
|
41714
|
+
var import_mongodb95 = require("mongodb");
|
|
41453
41715
|
function useNfcPatrolTagRepo() {
|
|
41454
41716
|
const db = import_node_server_utils159.useAtlas.getDb();
|
|
41455
41717
|
if (!db) {
|
|
@@ -41503,7 +41765,7 @@ function useNfcPatrolTagRepo() {
|
|
|
41503
41765
|
}, session) {
|
|
41504
41766
|
page = page > 0 ? page - 1 : 0;
|
|
41505
41767
|
try {
|
|
41506
|
-
site = new
|
|
41768
|
+
site = new import_mongodb95.ObjectId(site);
|
|
41507
41769
|
} catch (error) {
|
|
41508
41770
|
throw new import_node_server_utils159.BadRequestError("Invalid site ID format.");
|
|
41509
41771
|
}
|
|
@@ -41547,19 +41809,19 @@ function useNfcPatrolTagRepo() {
|
|
|
41547
41809
|
const [updateType, findObject, setData, session] = args;
|
|
41548
41810
|
if (findObject?.site && typeof findObject.site === "string") {
|
|
41549
41811
|
try {
|
|
41550
|
-
findObject.site = new
|
|
41812
|
+
findObject.site = new import_mongodb95.ObjectId(findObject.site);
|
|
41551
41813
|
} catch {
|
|
41552
41814
|
throw new import_node_server_utils159.BadRequestError("Invalid site ID.");
|
|
41553
41815
|
}
|
|
41554
41816
|
}
|
|
41555
41817
|
if (updateType == "Edit" && findObject?._id && typeof findObject._id === "string") {
|
|
41556
41818
|
try {
|
|
41557
|
-
findObject._id = new
|
|
41819
|
+
findObject._id = new import_mongodb95.ObjectId(findObject._id);
|
|
41558
41820
|
} catch {
|
|
41559
41821
|
throw new import_node_server_utils159.BadRequestError("Invalid nfc patrol tag document ID.");
|
|
41560
41822
|
}
|
|
41561
41823
|
try {
|
|
41562
|
-
setData.updatedBy = new
|
|
41824
|
+
setData.updatedBy = new import_mongodb95.ObjectId(setData.updatedBy);
|
|
41563
41825
|
} catch {
|
|
41564
41826
|
throw new import_node_server_utils159.BadRequestError("Invalid updatedBy ID.");
|
|
41565
41827
|
}
|
|
@@ -41850,7 +42112,7 @@ function useNfcPatrolTagController() {
|
|
|
41850
42112
|
}
|
|
41851
42113
|
|
|
41852
42114
|
// src/models/occurrence-book.model.ts
|
|
41853
|
-
var
|
|
42115
|
+
var import_mongodb96 = require("mongodb");
|
|
41854
42116
|
var import_joi90 = __toESM(require("joi"));
|
|
41855
42117
|
var DOBStatus = /* @__PURE__ */ ((DOBStatus3) => {
|
|
41856
42118
|
DOBStatus3["OPEN"] = "open";
|
|
@@ -41876,20 +42138,20 @@ var schemaUpdateOccurrenceBook = import_joi90.default.object({
|
|
|
41876
42138
|
function MOccurrenceBook(value) {
|
|
41877
42139
|
if (value._id && typeof value._id === "string") {
|
|
41878
42140
|
try {
|
|
41879
|
-
value._id = new
|
|
42141
|
+
value._id = new import_mongodb96.ObjectId(value._id);
|
|
41880
42142
|
} catch {
|
|
41881
42143
|
throw new Error("Invalid ID.");
|
|
41882
42144
|
}
|
|
41883
42145
|
}
|
|
41884
42146
|
if (value.site && typeof value.site === "string") {
|
|
41885
42147
|
try {
|
|
41886
|
-
value.site = new
|
|
42148
|
+
value.site = new import_mongodb96.ObjectId(value.site);
|
|
41887
42149
|
} catch {
|
|
41888
42150
|
throw new Error("Invalid site ID.");
|
|
41889
42151
|
}
|
|
41890
42152
|
}
|
|
41891
42153
|
return {
|
|
41892
|
-
_id: value._id ?? new
|
|
42154
|
+
_id: value._id ?? new import_mongodb96.ObjectId(),
|
|
41893
42155
|
site: value.site,
|
|
41894
42156
|
date: value.date ?? "",
|
|
41895
42157
|
totalInput: value.totalInput ?? 0,
|
|
@@ -41904,7 +42166,7 @@ function MOccurrenceBook(value) {
|
|
|
41904
42166
|
|
|
41905
42167
|
// src/repositories/occurrence-book.repo.ts
|
|
41906
42168
|
var import_node_server_utils162 = require("@7365admin1/node-server-utils");
|
|
41907
|
-
var
|
|
42169
|
+
var import_mongodb97 = require("mongodb");
|
|
41908
42170
|
var occurrence_book_namespace_collection = "occurrence-books";
|
|
41909
42171
|
function useOccurrenceBookRepo() {
|
|
41910
42172
|
const db = import_node_server_utils162.useAtlas.getDb();
|
|
@@ -42048,7 +42310,7 @@ function useOccurrenceBookRepo() {
|
|
|
42048
42310
|
}
|
|
42049
42311
|
async function getOccurrenceBookById(_id, session) {
|
|
42050
42312
|
try {
|
|
42051
|
-
_id = new
|
|
42313
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
42052
42314
|
} catch (error) {
|
|
42053
42315
|
throw new import_node_server_utils162.BadRequestError("Invalid occurrence book ID format.");
|
|
42054
42316
|
}
|
|
@@ -42078,7 +42340,7 @@ function useOccurrenceBookRepo() {
|
|
|
42078
42340
|
async function updateOccurrenceBookById(_id, value, session) {
|
|
42079
42341
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42080
42342
|
try {
|
|
42081
|
-
_id = new
|
|
42343
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
42082
42344
|
} catch (error) {
|
|
42083
42345
|
throw new import_node_server_utils162.BadRequestError("Invalid ID format.");
|
|
42084
42346
|
}
|
|
@@ -42110,7 +42372,7 @@ function useOccurrenceBookRepo() {
|
|
|
42110
42372
|
}
|
|
42111
42373
|
async function deleteOccurrenceBookById(_id) {
|
|
42112
42374
|
try {
|
|
42113
|
-
_id = new
|
|
42375
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
42114
42376
|
} catch (error) {
|
|
42115
42377
|
throw new import_node_server_utils162.BadRequestError("Invalid occurrence book ID format.");
|
|
42116
42378
|
}
|
|
@@ -42495,7 +42757,7 @@ function useOccurrenceBookController() {
|
|
|
42495
42757
|
}
|
|
42496
42758
|
|
|
42497
42759
|
// src/models/bulletin-video.model.ts
|
|
42498
|
-
var
|
|
42760
|
+
var import_mongodb98 = require("mongodb");
|
|
42499
42761
|
var import_joi92 = __toESM(require("joi"));
|
|
42500
42762
|
var BulletinVideoSort = /* @__PURE__ */ ((BulletinVideoSort2) => {
|
|
42501
42763
|
BulletinVideoSort2["CREATED_AT"] = "createdAt";
|
|
@@ -42523,27 +42785,27 @@ var schemaUpdateBulletinVideo = import_joi92.default.object({
|
|
|
42523
42785
|
function MBulletinVideo(value) {
|
|
42524
42786
|
if (value._id && typeof value._id === "string") {
|
|
42525
42787
|
try {
|
|
42526
|
-
value._id = new
|
|
42788
|
+
value._id = new import_mongodb98.ObjectId(value._id);
|
|
42527
42789
|
} catch {
|
|
42528
42790
|
throw new Error("Invalid ID.");
|
|
42529
42791
|
}
|
|
42530
42792
|
}
|
|
42531
42793
|
if (value.site && typeof value.site === "string") {
|
|
42532
42794
|
try {
|
|
42533
|
-
value.site = new
|
|
42795
|
+
value.site = new import_mongodb98.ObjectId(value.site);
|
|
42534
42796
|
} catch {
|
|
42535
42797
|
throw new Error("Invalid site ID.");
|
|
42536
42798
|
}
|
|
42537
42799
|
}
|
|
42538
42800
|
if (value.file && typeof value.file === "string") {
|
|
42539
42801
|
try {
|
|
42540
|
-
value.file = new
|
|
42802
|
+
value.file = new import_mongodb98.ObjectId(value.file);
|
|
42541
42803
|
} catch {
|
|
42542
42804
|
throw new Error("Invalid file ID.");
|
|
42543
42805
|
}
|
|
42544
42806
|
}
|
|
42545
42807
|
return {
|
|
42546
|
-
_id: value._id ?? new
|
|
42808
|
+
_id: value._id ?? new import_mongodb98.ObjectId(),
|
|
42547
42809
|
site: value.site,
|
|
42548
42810
|
title: value.title ?? "",
|
|
42549
42811
|
description: value.description ?? "",
|
|
@@ -42556,7 +42818,7 @@ function MBulletinVideo(value) {
|
|
|
42556
42818
|
|
|
42557
42819
|
// src/repositories/bulletin-video.repo.ts
|
|
42558
42820
|
var import_node_server_utils165 = require("@7365admin1/node-server-utils");
|
|
42559
|
-
var
|
|
42821
|
+
var import_mongodb99 = require("mongodb");
|
|
42560
42822
|
function useBulletinVideoRepo() {
|
|
42561
42823
|
const db = import_node_server_utils165.useAtlas.getDb();
|
|
42562
42824
|
if (!db) {
|
|
@@ -42618,7 +42880,7 @@ function useBulletinVideoRepo() {
|
|
|
42618
42880
|
}, session) {
|
|
42619
42881
|
page = page > 0 ? page - 1 : 0;
|
|
42620
42882
|
try {
|
|
42621
|
-
site = new
|
|
42883
|
+
site = new import_mongodb99.ObjectId(site);
|
|
42622
42884
|
} catch (error) {
|
|
42623
42885
|
throw new import_node_server_utils165.BadRequestError("Invalid site ID format.");
|
|
42624
42886
|
}
|
|
@@ -42698,7 +42960,7 @@ function useBulletinVideoRepo() {
|
|
|
42698
42960
|
}
|
|
42699
42961
|
async function getBulletinVideoById(_id, session) {
|
|
42700
42962
|
try {
|
|
42701
|
-
_id = new
|
|
42963
|
+
_id = new import_mongodb99.ObjectId(_id);
|
|
42702
42964
|
} catch (error) {
|
|
42703
42965
|
throw new import_node_server_utils165.BadRequestError("Invalid bulletin video ID format.");
|
|
42704
42966
|
}
|
|
@@ -42729,13 +42991,13 @@ function useBulletinVideoRepo() {
|
|
|
42729
42991
|
async function updateBulletinVideoById(_id, value, session) {
|
|
42730
42992
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42731
42993
|
try {
|
|
42732
|
-
_id = new
|
|
42994
|
+
_id = new import_mongodb99.ObjectId(_id);
|
|
42733
42995
|
} catch (error) {
|
|
42734
42996
|
throw new import_node_server_utils165.BadRequestError("Invalid ID format.");
|
|
42735
42997
|
}
|
|
42736
42998
|
if (value.file && typeof value.file === "string") {
|
|
42737
42999
|
try {
|
|
42738
|
-
value.file = new
|
|
43000
|
+
value.file = new import_mongodb99.ObjectId(value.file);
|
|
42739
43001
|
} catch {
|
|
42740
43002
|
throw new Error("Invalid file ID.");
|
|
42741
43003
|
}
|
|
@@ -42764,7 +43026,7 @@ function useBulletinVideoRepo() {
|
|
|
42764
43026
|
}
|
|
42765
43027
|
async function deleteBulletinVideoById(_id, session) {
|
|
42766
43028
|
try {
|
|
42767
|
-
_id = new
|
|
43029
|
+
_id = new import_mongodb99.ObjectId(_id);
|
|
42768
43030
|
} catch (error) {
|
|
42769
43031
|
throw new import_node_server_utils165.BadRequestError("Invalid bulletin video ID format.");
|
|
42770
43032
|
}
|
|
@@ -43028,7 +43290,7 @@ function useBulletinVideoController() {
|
|
|
43028
43290
|
|
|
43029
43291
|
// src/models/site-soa.model.ts
|
|
43030
43292
|
var import_node_server_utils168 = require("@7365admin1/node-server-utils");
|
|
43031
|
-
var
|
|
43293
|
+
var import_mongodb100 = require("mongodb");
|
|
43032
43294
|
var import_joi94 = __toESM(require("joi"));
|
|
43033
43295
|
var schemaSOABillingItem = import_joi94.default.object({
|
|
43034
43296
|
_id: import_joi94.default.string().required(),
|
|
@@ -43096,28 +43358,28 @@ function MStatementOfAccount(value) {
|
|
|
43096
43358
|
}
|
|
43097
43359
|
if (value._id && typeof value._id === "string") {
|
|
43098
43360
|
try {
|
|
43099
|
-
value._id = new
|
|
43361
|
+
value._id = new import_mongodb100.ObjectId(value._id);
|
|
43100
43362
|
} catch {
|
|
43101
43363
|
throw new import_node_server_utils168.BadRequestError("Invalid _id format");
|
|
43102
43364
|
}
|
|
43103
43365
|
}
|
|
43104
43366
|
if (value.site && typeof value.site === "string") {
|
|
43105
43367
|
try {
|
|
43106
|
-
value.site = new
|
|
43368
|
+
value.site = new import_mongodb100.ObjectId(value.site);
|
|
43107
43369
|
} catch {
|
|
43108
43370
|
throw new import_node_server_utils168.BadRequestError("Invalid site format");
|
|
43109
43371
|
}
|
|
43110
43372
|
}
|
|
43111
43373
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
43112
43374
|
try {
|
|
43113
|
-
value.createdBy = new
|
|
43375
|
+
value.createdBy = new import_mongodb100.ObjectId(value.createdBy);
|
|
43114
43376
|
} catch {
|
|
43115
43377
|
throw new import_node_server_utils168.BadRequestError("Invalid createBy format");
|
|
43116
43378
|
}
|
|
43117
43379
|
}
|
|
43118
43380
|
if (value.unitId && typeof value.unitId === "string") {
|
|
43119
43381
|
try {
|
|
43120
|
-
value.unitId = new
|
|
43382
|
+
value.unitId = new import_mongodb100.ObjectId(value.unitId);
|
|
43121
43383
|
} catch {
|
|
43122
43384
|
throw new import_node_server_utils168.BadRequestError("Invalid unitId format");
|
|
43123
43385
|
}
|
|
@@ -43126,7 +43388,7 @@ function MStatementOfAccount(value) {
|
|
|
43126
43388
|
value.billing = value.billing.map((bill) => {
|
|
43127
43389
|
if (bill._id && typeof bill._id === "string") {
|
|
43128
43390
|
try {
|
|
43129
|
-
bill._id = new
|
|
43391
|
+
bill._id = new import_mongodb100.ObjectId(bill._id);
|
|
43130
43392
|
} catch {
|
|
43131
43393
|
throw new import_node_server_utils168.BadRequestError("Invalid billing id format");
|
|
43132
43394
|
}
|
|
@@ -43135,7 +43397,7 @@ function MStatementOfAccount(value) {
|
|
|
43135
43397
|
});
|
|
43136
43398
|
}
|
|
43137
43399
|
return {
|
|
43138
|
-
_id: value._id ?? new
|
|
43400
|
+
_id: value._id ?? new import_mongodb100.ObjectId(),
|
|
43139
43401
|
site: value.site,
|
|
43140
43402
|
unitId: value.unitId ?? "",
|
|
43141
43403
|
unit: value.unit ?? "",
|
|
@@ -43158,7 +43420,7 @@ function MStatementOfAccount(value) {
|
|
|
43158
43420
|
|
|
43159
43421
|
// src/repositories/site-soa.repo.ts
|
|
43160
43422
|
var import_node_server_utils169 = require("@7365admin1/node-server-utils");
|
|
43161
|
-
var
|
|
43423
|
+
var import_mongodb101 = require("mongodb");
|
|
43162
43424
|
function useStatementOfAccountRepo() {
|
|
43163
43425
|
const db = import_node_server_utils169.useAtlas.getDb();
|
|
43164
43426
|
if (!db) {
|
|
@@ -43256,7 +43518,7 @@ function useStatementOfAccountRepo() {
|
|
|
43256
43518
|
{ category: { $regex: search, $options: "i" } }
|
|
43257
43519
|
]
|
|
43258
43520
|
},
|
|
43259
|
-
...
|
|
43521
|
+
...import_mongodb101.ObjectId.isValid(site) && { site: new import_mongodb101.ObjectId(site) },
|
|
43260
43522
|
...dateExpr
|
|
43261
43523
|
};
|
|
43262
43524
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -43311,7 +43573,7 @@ function useStatementOfAccountRepo() {
|
|
|
43311
43573
|
}
|
|
43312
43574
|
async function getById(_id) {
|
|
43313
43575
|
try {
|
|
43314
|
-
_id = new
|
|
43576
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43315
43577
|
} catch (error) {
|
|
43316
43578
|
throw new import_node_server_utils169.BadRequestError("Invalid ID.");
|
|
43317
43579
|
}
|
|
@@ -43350,7 +43612,7 @@ function useStatementOfAccountRepo() {
|
|
|
43350
43612
|
}
|
|
43351
43613
|
async function updateById(_id, value, session) {
|
|
43352
43614
|
try {
|
|
43353
|
-
_id = new
|
|
43615
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43354
43616
|
} catch (error) {
|
|
43355
43617
|
throw new import_node_server_utils169.BadRequestError("Invalid site SOA transaction ID format.");
|
|
43356
43618
|
}
|
|
@@ -43369,7 +43631,7 @@ function useStatementOfAccountRepo() {
|
|
|
43369
43631
|
}
|
|
43370
43632
|
async function deleteById(_id) {
|
|
43371
43633
|
try {
|
|
43372
|
-
_id = new
|
|
43634
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43373
43635
|
} catch (error) {
|
|
43374
43636
|
throw new import_node_server_utils169.BadRequestError("Invalid site SOA transaction ID format.");
|
|
43375
43637
|
}
|
|
@@ -43391,7 +43653,7 @@ function useStatementOfAccountRepo() {
|
|
|
43391
43653
|
}
|
|
43392
43654
|
async function updateStatusById(_id, value, session) {
|
|
43393
43655
|
try {
|
|
43394
|
-
_id = new
|
|
43656
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43395
43657
|
} catch (error) {
|
|
43396
43658
|
throw new import_node_server_utils169.BadRequestError("Invalid file ID format.");
|
|
43397
43659
|
}
|
|
@@ -43446,9 +43708,9 @@ function useStatementOfAccountRepo() {
|
|
|
43446
43708
|
{ category: { $regex: search, $options: "i" } }
|
|
43447
43709
|
]
|
|
43448
43710
|
},
|
|
43449
|
-
...
|
|
43711
|
+
...import_mongodb101.ObjectId.isValid(site) && { site: new import_mongodb101.ObjectId(site) },
|
|
43450
43712
|
...dateExpr,
|
|
43451
|
-
...
|
|
43713
|
+
...import_mongodb101.ObjectId.isValid(unitId) && { unitId: new import_mongodb101.ObjectId(unitId) },
|
|
43452
43714
|
...category && { category }
|
|
43453
43715
|
};
|
|
43454
43716
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -43498,7 +43760,7 @@ function useStatementOfAccountRepo() {
|
|
|
43498
43760
|
async function reviewSOA(_id, value, session) {
|
|
43499
43761
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
43500
43762
|
try {
|
|
43501
|
-
_id = new
|
|
43763
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43502
43764
|
} catch (error) {
|
|
43503
43765
|
throw new import_node_server_utils169.BadRequestError("Invalid ID format.");
|
|
43504
43766
|
}
|
|
@@ -43543,7 +43805,7 @@ var import_node_server_utils171 = require("@7365admin1/node-server-utils");
|
|
|
43543
43805
|
|
|
43544
43806
|
// src/services/site-soa.service.ts
|
|
43545
43807
|
var import_node_server_utils170 = require("@7365admin1/node-server-utils");
|
|
43546
|
-
var
|
|
43808
|
+
var import_mongodb102 = require("mongodb");
|
|
43547
43809
|
var import_puppeteer = require("puppeteer");
|
|
43548
43810
|
function useStatementOfAccountService() {
|
|
43549
43811
|
const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
|
|
@@ -43680,7 +43942,7 @@ function useStatementOfAccountService() {
|
|
|
43680
43942
|
if (!approvedBy || !approvedBy.name)
|
|
43681
43943
|
throw new import_node_server_utils170.BadRequestError("Created by not found.");
|
|
43682
43944
|
value.approvedBy.name = approvedBy.name;
|
|
43683
|
-
value.approvedBy._id = new
|
|
43945
|
+
value.approvedBy._id = new import_mongodb102.ObjectId(approvedBy._id);
|
|
43684
43946
|
}
|
|
43685
43947
|
await _reviewSOA(id, value, session);
|
|
43686
43948
|
await session?.commitTransaction();
|
|
@@ -44062,7 +44324,7 @@ function useStatementOfAccountController() {
|
|
|
44062
44324
|
|
|
44063
44325
|
// src/models/site-entrypass-settings.model.ts
|
|
44064
44326
|
var import_node_server_utils172 = require("@7365admin1/node-server-utils");
|
|
44065
|
-
var
|
|
44327
|
+
var import_mongodb103 = require("mongodb");
|
|
44066
44328
|
var import_joi96 = __toESM(require("joi"));
|
|
44067
44329
|
var schemaEntryPassSettings = import_joi96.default.object({
|
|
44068
44330
|
_id: import_joi96.default.string().hex().optional().allow("", null),
|
|
@@ -44110,21 +44372,21 @@ function MEntryPassSettings(value) {
|
|
|
44110
44372
|
}
|
|
44111
44373
|
if (value._id && typeof value._id === "string") {
|
|
44112
44374
|
try {
|
|
44113
|
-
value._id = new
|
|
44375
|
+
value._id = new import_mongodb103.ObjectId(value._id);
|
|
44114
44376
|
} catch {
|
|
44115
44377
|
throw new import_node_server_utils172.BadRequestError("Invalid _id format");
|
|
44116
44378
|
}
|
|
44117
44379
|
}
|
|
44118
44380
|
if (value.site && typeof value.site === "string") {
|
|
44119
44381
|
try {
|
|
44120
|
-
value.site = new
|
|
44382
|
+
value.site = new import_mongodb103.ObjectId(value.site);
|
|
44121
44383
|
} catch {
|
|
44122
44384
|
throw new import_node_server_utils172.BadRequestError("Invalid site format");
|
|
44123
44385
|
}
|
|
44124
44386
|
}
|
|
44125
44387
|
if (value.org && typeof value.org === "string") {
|
|
44126
44388
|
try {
|
|
44127
|
-
value.org = new
|
|
44389
|
+
value.org = new import_mongodb103.ObjectId(value.org);
|
|
44128
44390
|
} catch {
|
|
44129
44391
|
throw new import_node_server_utils172.BadRequestError("Invalid org format");
|
|
44130
44392
|
}
|
|
@@ -44154,7 +44416,7 @@ function MEntryPassSettings(value) {
|
|
|
44154
44416
|
|
|
44155
44417
|
// src/repositories/site-entrypass-settings.repo.ts
|
|
44156
44418
|
var import_node_server_utils173 = require("@7365admin1/node-server-utils");
|
|
44157
|
-
var
|
|
44419
|
+
var import_mongodb104 = require("mongodb");
|
|
44158
44420
|
function useEntryPassSettingsRepo() {
|
|
44159
44421
|
const db = import_node_server_utils173.useAtlas.getDb();
|
|
44160
44422
|
if (!db) {
|
|
@@ -44264,7 +44526,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44264
44526
|
}
|
|
44265
44527
|
async function getEntryPassSettingsById(_id) {
|
|
44266
44528
|
try {
|
|
44267
|
-
_id = new
|
|
44529
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
44268
44530
|
} catch (error) {
|
|
44269
44531
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44270
44532
|
}
|
|
@@ -44331,7 +44593,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44331
44593
|
}
|
|
44332
44594
|
async function updateEntryPassSettingsById(_id, value) {
|
|
44333
44595
|
try {
|
|
44334
|
-
_id = new
|
|
44596
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
44335
44597
|
} catch (error) {
|
|
44336
44598
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44337
44599
|
}
|
|
@@ -44359,7 +44621,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44359
44621
|
}
|
|
44360
44622
|
async function deleteEntryPassSettingsById(_id, session) {
|
|
44361
44623
|
try {
|
|
44362
|
-
_id = new
|
|
44624
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
44363
44625
|
} catch (error) {
|
|
44364
44626
|
throw new import_node_server_utils173.BadRequestError("Invalid card ID format.");
|
|
44365
44627
|
}
|
|
@@ -44392,7 +44654,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44392
44654
|
}
|
|
44393
44655
|
async function getEntryPassSettingsBySiteId(site) {
|
|
44394
44656
|
try {
|
|
44395
|
-
site = new
|
|
44657
|
+
site = new import_mongodb104.ObjectId(site);
|
|
44396
44658
|
} catch (error) {
|
|
44397
44659
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44398
44660
|
}
|
|
@@ -44459,7 +44721,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44459
44721
|
}
|
|
44460
44722
|
async function updateEntryPassSettingsBySiteId(site, value) {
|
|
44461
44723
|
try {
|
|
44462
|
-
site = new
|
|
44724
|
+
site = new import_mongodb104.ObjectId(site);
|
|
44463
44725
|
} catch (error) {
|
|
44464
44726
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44465
44727
|
}
|
|
@@ -44818,7 +45080,7 @@ function useDashboardController() {
|
|
|
44818
45080
|
}
|
|
44819
45081
|
|
|
44820
45082
|
// src/models/nfc-patrol-route.model.ts
|
|
44821
|
-
var
|
|
45083
|
+
var import_mongodb105 = require("mongodb");
|
|
44822
45084
|
var import_joi99 = __toESM(require("joi"));
|
|
44823
45085
|
var import_node_server_utils177 = require("@7365admin1/node-server-utils");
|
|
44824
45086
|
var schemaNfcPatrolRoute = import_joi99.default.object({
|
|
@@ -44854,23 +45116,23 @@ function MNfcPatrolRoute(value) {
|
|
|
44854
45116
|
}
|
|
44855
45117
|
if (value._id && typeof value._id === "string") {
|
|
44856
45118
|
try {
|
|
44857
|
-
value._id = new
|
|
45119
|
+
value._id = new import_mongodb105.ObjectId(value._id);
|
|
44858
45120
|
} catch (error2) {
|
|
44859
45121
|
throw new import_node_server_utils177.BadRequestError("Invalid _id format");
|
|
44860
45122
|
}
|
|
44861
45123
|
}
|
|
44862
45124
|
try {
|
|
44863
|
-
value.site = new
|
|
45125
|
+
value.site = new import_mongodb105.ObjectId(value.site);
|
|
44864
45126
|
} catch (error2) {
|
|
44865
45127
|
throw new import_node_server_utils177.BadRequestError("Invalid site format");
|
|
44866
45128
|
}
|
|
44867
45129
|
try {
|
|
44868
|
-
value.createdBy = new
|
|
45130
|
+
value.createdBy = new import_mongodb105.ObjectId(value.createdBy);
|
|
44869
45131
|
} catch (error2) {
|
|
44870
45132
|
throw new import_node_server_utils177.BadRequestError("Invalid createdBy format");
|
|
44871
45133
|
}
|
|
44872
45134
|
return {
|
|
44873
|
-
_id: value._id ?? new
|
|
45135
|
+
_id: value._id ?? new import_mongodb105.ObjectId(),
|
|
44874
45136
|
site: value.site,
|
|
44875
45137
|
name: value.name,
|
|
44876
45138
|
checkPointNumber: value.checkPointNumber,
|
|
@@ -44886,7 +45148,7 @@ function MNfcPatrolRoute(value) {
|
|
|
44886
45148
|
|
|
44887
45149
|
// src/repositories/nfc-patrol-route.repository.ts
|
|
44888
45150
|
var import_node_server_utils178 = require("@7365admin1/node-server-utils");
|
|
44889
|
-
var
|
|
45151
|
+
var import_mongodb106 = require("mongodb");
|
|
44890
45152
|
function useNfcPatrolRouteRepo() {
|
|
44891
45153
|
const db = import_node_server_utils178.useAtlas.getDb();
|
|
44892
45154
|
if (!db) {
|
|
@@ -44930,7 +45192,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
44930
45192
|
}, session) {
|
|
44931
45193
|
page = page > 0 ? page - 1 : 0;
|
|
44932
45194
|
try {
|
|
44933
|
-
site = new
|
|
45195
|
+
site = new import_mongodb106.ObjectId(site);
|
|
44934
45196
|
} catch (error) {
|
|
44935
45197
|
throw new import_node_server_utils178.BadRequestError("Invalid site ID format.");
|
|
44936
45198
|
}
|
|
@@ -45001,7 +45263,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
45001
45263
|
}
|
|
45002
45264
|
async function getById(_id, isStart) {
|
|
45003
45265
|
try {
|
|
45004
|
-
_id = new
|
|
45266
|
+
_id = new import_mongodb106.ObjectId(_id);
|
|
45005
45267
|
} catch (error) {
|
|
45006
45268
|
throw new import_node_server_utils178.BadRequestError("Invalid ID.");
|
|
45007
45269
|
}
|
|
@@ -45111,18 +45373,18 @@ function useNfcPatrolRouteRepo() {
|
|
|
45111
45373
|
throw new import_node_server_utils178.BadRequestError(error.message);
|
|
45112
45374
|
}
|
|
45113
45375
|
try {
|
|
45114
|
-
_id = new
|
|
45376
|
+
_id = new import_mongodb106.ObjectId(_id);
|
|
45115
45377
|
} catch (error2) {
|
|
45116
45378
|
throw new import_node_server_utils178.BadRequestError("Invalid ID.");
|
|
45117
45379
|
}
|
|
45118
45380
|
try {
|
|
45119
|
-
value.site = new
|
|
45381
|
+
value.site = new import_mongodb106.ObjectId(value.site);
|
|
45120
45382
|
} catch (error2) {
|
|
45121
45383
|
throw new import_node_server_utils178.BadRequestError("Invalid site format");
|
|
45122
45384
|
}
|
|
45123
45385
|
if (value.updatedBy) {
|
|
45124
45386
|
try {
|
|
45125
|
-
value.updatedBy = new
|
|
45387
|
+
value.updatedBy = new import_mongodb106.ObjectId(value.updatedBy);
|
|
45126
45388
|
} catch (error2) {
|
|
45127
45389
|
throw new import_node_server_utils178.BadRequestError("Invalid createdBy format");
|
|
45128
45390
|
}
|
|
@@ -45347,7 +45609,7 @@ function useNfcPatrolRouteController() {
|
|
|
45347
45609
|
}
|
|
45348
45610
|
|
|
45349
45611
|
// src/models/incident-report.model.ts
|
|
45350
|
-
var
|
|
45612
|
+
var import_mongodb107 = require("mongodb");
|
|
45351
45613
|
var import_joi101 = __toESM(require("joi"));
|
|
45352
45614
|
var residentSchema = import_joi101.default.object({
|
|
45353
45615
|
_id: import_joi101.default.string().hex().optional().allow(null, ""),
|
|
@@ -45553,28 +45815,28 @@ var schemaUpdateIncidentReport = import_joi101.default.object({
|
|
|
45553
45815
|
function MIncidentReport(value) {
|
|
45554
45816
|
if (value._id && typeof value._id === "string") {
|
|
45555
45817
|
try {
|
|
45556
|
-
value._id = new
|
|
45818
|
+
value._id = new import_mongodb107.ObjectId(value._id);
|
|
45557
45819
|
} catch {
|
|
45558
45820
|
throw new Error("Invalid incident report ID.");
|
|
45559
45821
|
}
|
|
45560
45822
|
}
|
|
45561
45823
|
if (value.organization && typeof value.organization === "string") {
|
|
45562
45824
|
try {
|
|
45563
|
-
value.organization = new
|
|
45825
|
+
value.organization = new import_mongodb107.ObjectId(value.organization);
|
|
45564
45826
|
} catch {
|
|
45565
45827
|
throw new Error("Invalid organization ID.");
|
|
45566
45828
|
}
|
|
45567
45829
|
}
|
|
45568
45830
|
if (value.site && typeof value.site === "string") {
|
|
45569
45831
|
try {
|
|
45570
|
-
value.site = new
|
|
45832
|
+
value.site = new import_mongodb107.ObjectId(value.site);
|
|
45571
45833
|
} catch {
|
|
45572
45834
|
throw new Error("Invalid site ID.");
|
|
45573
45835
|
}
|
|
45574
45836
|
}
|
|
45575
45837
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
45576
45838
|
try {
|
|
45577
|
-
value.approvedBy = new
|
|
45839
|
+
value.approvedBy = new import_mongodb107.ObjectId(value.approvedBy);
|
|
45578
45840
|
} catch {
|
|
45579
45841
|
throw new Error("Invalid approvedBy ID.");
|
|
45580
45842
|
}
|
|
@@ -45582,7 +45844,7 @@ function MIncidentReport(value) {
|
|
|
45582
45844
|
const { incidentInformation } = value;
|
|
45583
45845
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
45584
45846
|
try {
|
|
45585
|
-
incidentInformation.siteInfo.site = new
|
|
45847
|
+
incidentInformation.siteInfo.site = new import_mongodb107.ObjectId(
|
|
45586
45848
|
incidentInformation.siteInfo.site
|
|
45587
45849
|
);
|
|
45588
45850
|
} catch {
|
|
@@ -45596,7 +45858,7 @@ function MIncidentReport(value) {
|
|
|
45596
45858
|
incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
|
|
45597
45859
|
}
|
|
45598
45860
|
return {
|
|
45599
|
-
_id: value._id ?? new
|
|
45861
|
+
_id: value._id ?? new import_mongodb107.ObjectId(),
|
|
45600
45862
|
reportId: value.reportId,
|
|
45601
45863
|
incidentInformation: value.incidentInformation,
|
|
45602
45864
|
affectedEntities: value.affectedEntities,
|
|
@@ -45621,7 +45883,7 @@ var import_node_server_utils182 = require("@7365admin1/node-server-utils");
|
|
|
45621
45883
|
|
|
45622
45884
|
// src/repositories/incident-report.repo.ts
|
|
45623
45885
|
var import_node_server_utils181 = require("@7365admin1/node-server-utils");
|
|
45624
|
-
var
|
|
45886
|
+
var import_mongodb108 = require("mongodb");
|
|
45625
45887
|
var incidents_namespace_collection = "incident-reports";
|
|
45626
45888
|
function useIncidentReportRepo() {
|
|
45627
45889
|
const db = import_node_server_utils181.useAtlas.getDb();
|
|
@@ -45688,7 +45950,7 @@ function useIncidentReportRepo() {
|
|
|
45688
45950
|
page = page > 0 ? page - 1 : 0;
|
|
45689
45951
|
let dateExpr = {};
|
|
45690
45952
|
try {
|
|
45691
|
-
site = new
|
|
45953
|
+
site = new import_mongodb108.ObjectId(site);
|
|
45692
45954
|
} catch (error) {
|
|
45693
45955
|
throw new import_node_server_utils181.BadRequestError("Invalid site ID format.");
|
|
45694
45956
|
}
|
|
@@ -45789,7 +46051,7 @@ function useIncidentReportRepo() {
|
|
|
45789
46051
|
page = page > 0 ? page - 1 : 0;
|
|
45790
46052
|
let dateExpr = {};
|
|
45791
46053
|
try {
|
|
45792
|
-
site = new
|
|
46054
|
+
site = new import_mongodb108.ObjectId(site);
|
|
45793
46055
|
} catch (error) {
|
|
45794
46056
|
throw new import_node_server_utils181.BadRequestError("Invalid site ID format.");
|
|
45795
46057
|
}
|
|
@@ -45858,7 +46120,7 @@ function useIncidentReportRepo() {
|
|
|
45858
46120
|
}
|
|
45859
46121
|
async function getIncidentReportById(_id, session) {
|
|
45860
46122
|
try {
|
|
45861
|
-
_id = new
|
|
46123
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45862
46124
|
} catch (error) {
|
|
45863
46125
|
throw new import_node_server_utils181.BadRequestError("Invalid incident report ID format.");
|
|
45864
46126
|
}
|
|
@@ -45889,27 +46151,27 @@ function useIncidentReportRepo() {
|
|
|
45889
46151
|
async function updateIncidentReportById(_id, value, session) {
|
|
45890
46152
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
45891
46153
|
try {
|
|
45892
|
-
_id = new
|
|
46154
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45893
46155
|
} catch (error) {
|
|
45894
46156
|
throw new import_node_server_utils181.BadRequestError("Invalid ID format.");
|
|
45895
46157
|
}
|
|
45896
46158
|
if (value.organization && typeof value.organization === "string") {
|
|
45897
46159
|
try {
|
|
45898
|
-
value.organization = new
|
|
46160
|
+
value.organization = new import_mongodb108.ObjectId(value.organization);
|
|
45899
46161
|
} catch {
|
|
45900
46162
|
throw new Error("Invalid organization ID.");
|
|
45901
46163
|
}
|
|
45902
46164
|
}
|
|
45903
46165
|
if (value.site && typeof value.site === "string") {
|
|
45904
46166
|
try {
|
|
45905
|
-
value.site = new
|
|
46167
|
+
value.site = new import_mongodb108.ObjectId(value.site);
|
|
45906
46168
|
} catch {
|
|
45907
46169
|
throw new Error("Invalid site ID.");
|
|
45908
46170
|
}
|
|
45909
46171
|
}
|
|
45910
46172
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
45911
46173
|
try {
|
|
45912
|
-
value.approvedBy = new
|
|
46174
|
+
value.approvedBy = new import_mongodb108.ObjectId(value.approvedBy);
|
|
45913
46175
|
} catch {
|
|
45914
46176
|
throw new Error("Invalid approvedBy ID.");
|
|
45915
46177
|
}
|
|
@@ -45917,7 +46179,7 @@ function useIncidentReportRepo() {
|
|
|
45917
46179
|
const { incidentInformation } = value;
|
|
45918
46180
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
45919
46181
|
try {
|
|
45920
|
-
incidentInformation.siteInfo.site = new
|
|
46182
|
+
incidentInformation.siteInfo.site = new import_mongodb108.ObjectId(
|
|
45921
46183
|
incidentInformation.siteInfo.site
|
|
45922
46184
|
);
|
|
45923
46185
|
} catch {
|
|
@@ -45952,7 +46214,7 @@ function useIncidentReportRepo() {
|
|
|
45952
46214
|
}
|
|
45953
46215
|
async function deleteIncidentReportById(_id) {
|
|
45954
46216
|
try {
|
|
45955
|
-
_id = new
|
|
46217
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45956
46218
|
} catch (error) {
|
|
45957
46219
|
throw new import_node_server_utils181.BadRequestError("Invalid occurrence subject ID format.");
|
|
45958
46220
|
}
|
|
@@ -45984,7 +46246,7 @@ function useIncidentReportRepo() {
|
|
|
45984
46246
|
async function reviewIncidentReport(_id, value, session) {
|
|
45985
46247
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
45986
46248
|
try {
|
|
45987
|
-
_id = new
|
|
46249
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45988
46250
|
} catch (error) {
|
|
45989
46251
|
throw new import_node_server_utils181.BadRequestError("Invalid ID format.");
|
|
45990
46252
|
}
|
|
@@ -46477,7 +46739,7 @@ function useIncidentReportController() {
|
|
|
46477
46739
|
}
|
|
46478
46740
|
|
|
46479
46741
|
// src/models/nfc-patrol-settings.model.ts
|
|
46480
|
-
var
|
|
46742
|
+
var import_mongodb109 = require("mongodb");
|
|
46481
46743
|
var import_joi103 = __toESM(require("joi"));
|
|
46482
46744
|
var import_node_server_utils184 = require("@7365admin1/node-server-utils");
|
|
46483
46745
|
var objectId = import_joi103.default.string().hex().length(24);
|
|
@@ -46503,7 +46765,7 @@ function MNfcPatrolSettings(value) {
|
|
|
46503
46765
|
}
|
|
46504
46766
|
if (value.site) {
|
|
46505
46767
|
try {
|
|
46506
|
-
value.site = new
|
|
46768
|
+
value.site = new import_mongodb109.ObjectId(value.site);
|
|
46507
46769
|
} catch (error2) {
|
|
46508
46770
|
throw new import_node_server_utils184.BadRequestError("Invalid site ID format.");
|
|
46509
46771
|
}
|
|
@@ -46523,7 +46785,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
46523
46785
|
}
|
|
46524
46786
|
if (value.updatedBy) {
|
|
46525
46787
|
try {
|
|
46526
|
-
value.updatedBy = new
|
|
46788
|
+
value.updatedBy = new import_mongodb109.ObjectId(value.updatedBy);
|
|
46527
46789
|
} catch (error2) {
|
|
46528
46790
|
throw new import_node_server_utils184.BadRequestError("Invalid updatedBy ID format.");
|
|
46529
46791
|
}
|
|
@@ -46537,7 +46799,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
46537
46799
|
|
|
46538
46800
|
// src/repositories/nfc-patrol-settings.repository.ts
|
|
46539
46801
|
var import_node_server_utils185 = require("@7365admin1/node-server-utils");
|
|
46540
|
-
var
|
|
46802
|
+
var import_mongodb110 = require("mongodb");
|
|
46541
46803
|
function useNfcPatrolSettingsRepository() {
|
|
46542
46804
|
const db = import_node_server_utils185.useAtlas.getDb();
|
|
46543
46805
|
if (!db) {
|
|
@@ -46567,7 +46829,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
46567
46829
|
}
|
|
46568
46830
|
async function getNfcPatrolSettingsBySite(site, session) {
|
|
46569
46831
|
try {
|
|
46570
|
-
site = new
|
|
46832
|
+
site = new import_mongodb110.ObjectId(site);
|
|
46571
46833
|
} catch (error) {
|
|
46572
46834
|
throw new import_node_server_utils185.BadRequestError("Invalid nfc patrol settings site ID format.");
|
|
46573
46835
|
}
|
|
@@ -46611,7 +46873,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
46611
46873
|
}
|
|
46612
46874
|
async function updateNfcPatrolSettings(site, value, session) {
|
|
46613
46875
|
try {
|
|
46614
|
-
site = new
|
|
46876
|
+
site = new import_mongodb110.ObjectId(site);
|
|
46615
46877
|
} catch (error) {
|
|
46616
46878
|
throw new import_node_server_utils185.BadRequestError("Invalid attendance settings ID format.");
|
|
46617
46879
|
}
|
|
@@ -46776,13 +47038,13 @@ function useNfcPatrolSettingsController() {
|
|
|
46776
47038
|
|
|
46777
47039
|
// src/services/occurrence-entry.service.ts
|
|
46778
47040
|
var import_node_server_utils189 = require("@7365admin1/node-server-utils");
|
|
46779
|
-
var
|
|
47041
|
+
var import_mongodb113 = require("mongodb");
|
|
46780
47042
|
|
|
46781
47043
|
// src/repositories/occurrence-subject.repo.ts
|
|
46782
47044
|
var import_node_server_utils188 = require("@7365admin1/node-server-utils");
|
|
46783
47045
|
|
|
46784
47046
|
// src/models/occurrence-subject.model.ts
|
|
46785
|
-
var
|
|
47047
|
+
var import_mongodb111 = require("mongodb");
|
|
46786
47048
|
var import_joi105 = __toESM(require("joi"));
|
|
46787
47049
|
var SubjectSort = /* @__PURE__ */ ((SubjectSort2) => {
|
|
46788
47050
|
SubjectSort2["CREATED_AT"] = "createdAt";
|
|
@@ -46807,27 +47069,27 @@ var schemaUpdateOccurrenceSubject = import_joi105.default.object({
|
|
|
46807
47069
|
function MOccurrenceSubject(value) {
|
|
46808
47070
|
if (value._id && typeof value._id === "string") {
|
|
46809
47071
|
try {
|
|
46810
|
-
value._id = new
|
|
47072
|
+
value._id = new import_mongodb111.ObjectId(value._id);
|
|
46811
47073
|
} catch {
|
|
46812
47074
|
throw new Error("Invalid ID.");
|
|
46813
47075
|
}
|
|
46814
47076
|
}
|
|
46815
47077
|
if (value.site && typeof value.site === "string") {
|
|
46816
47078
|
try {
|
|
46817
|
-
value.site = new
|
|
47079
|
+
value.site = new import_mongodb111.ObjectId(value.site);
|
|
46818
47080
|
} catch {
|
|
46819
47081
|
throw new Error("Invalid site ID.");
|
|
46820
47082
|
}
|
|
46821
47083
|
}
|
|
46822
47084
|
if (value.addedBy && typeof value.addedBy === "string") {
|
|
46823
47085
|
try {
|
|
46824
|
-
value.addedBy = new
|
|
47086
|
+
value.addedBy = new import_mongodb111.ObjectId(value.addedBy);
|
|
46825
47087
|
} catch {
|
|
46826
47088
|
throw new Error("Invalid addedBy ID.");
|
|
46827
47089
|
}
|
|
46828
47090
|
}
|
|
46829
47091
|
return {
|
|
46830
|
-
_id: value._id ?? new
|
|
47092
|
+
_id: value._id ?? new import_mongodb111.ObjectId(),
|
|
46831
47093
|
site: value.site,
|
|
46832
47094
|
subject: value.subject,
|
|
46833
47095
|
addedBy: value.addedBy ?? "",
|
|
@@ -46838,7 +47100,7 @@ function MOccurrenceSubject(value) {
|
|
|
46838
47100
|
}
|
|
46839
47101
|
|
|
46840
47102
|
// src/repositories/occurrence-subject.repo.ts
|
|
46841
|
-
var
|
|
47103
|
+
var import_mongodb112 = require("mongodb");
|
|
46842
47104
|
function useOccurrenceSubjectRepo() {
|
|
46843
47105
|
const db = import_node_server_utils188.useAtlas.getDb();
|
|
46844
47106
|
if (!db) {
|
|
@@ -46897,7 +47159,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
46897
47159
|
}, session) {
|
|
46898
47160
|
page = page > 0 ? page - 1 : 0;
|
|
46899
47161
|
try {
|
|
46900
|
-
site = new
|
|
47162
|
+
site = new import_mongodb112.ObjectId(site);
|
|
46901
47163
|
} catch (error) {
|
|
46902
47164
|
throw new import_node_server_utils188.BadRequestError("Invalid site ID format.");
|
|
46903
47165
|
}
|
|
@@ -46990,7 +47252,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
46990
47252
|
}
|
|
46991
47253
|
async function getOccurrenceSubjectById(_id, session) {
|
|
46992
47254
|
try {
|
|
46993
|
-
_id = new
|
|
47255
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
46994
47256
|
} catch (error) {
|
|
46995
47257
|
throw new import_node_server_utils188.BadRequestError("Invalid occurrence subject ID format.");
|
|
46996
47258
|
}
|
|
@@ -47018,7 +47280,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47018
47280
|
async function updateOccurrenceSubjectById(_id, value, session) {
|
|
47019
47281
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47020
47282
|
try {
|
|
47021
|
-
_id = new
|
|
47283
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
47022
47284
|
} catch (error) {
|
|
47023
47285
|
throw new import_node_server_utils188.BadRequestError("Invalid ID format.");
|
|
47024
47286
|
}
|
|
@@ -47048,7 +47310,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47048
47310
|
}
|
|
47049
47311
|
async function deleteOccurrenceSubjectById(_id) {
|
|
47050
47312
|
try {
|
|
47051
|
-
_id = new
|
|
47313
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
47052
47314
|
} catch (error) {
|
|
47053
47315
|
throw new import_node_server_utils188.BadRequestError("Invalid occurrence subject ID format.");
|
|
47054
47316
|
}
|
|
@@ -47179,8 +47441,8 @@ function useOccurrenceEntryService() {
|
|
|
47179
47441
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
47180
47442
|
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
47181
47443
|
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
47182
|
-
value.signature = value.signature ? new
|
|
47183
|
-
value.eSignature = value.eSignature ? new
|
|
47444
|
+
value.signature = value.signature ? new import_mongodb113.ObjectId(value.signature) : occurrenceEntry.signature._id;
|
|
47445
|
+
value.eSignature = value.eSignature ? new import_mongodb113.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
|
|
47184
47446
|
value.createdAt = /* @__PURE__ */ new Date();
|
|
47185
47447
|
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
47186
47448
|
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
@@ -47372,7 +47634,7 @@ function useOccurrenceEntryController() {
|
|
|
47372
47634
|
|
|
47373
47635
|
// src/models/online-form.model.ts
|
|
47374
47636
|
var import_joi107 = __toESM(require("joi"));
|
|
47375
|
-
var
|
|
47637
|
+
var import_mongodb114 = require("mongodb");
|
|
47376
47638
|
var schemaOnlineForm = import_joi107.default.object({
|
|
47377
47639
|
_id: import_joi107.default.string().hex().optional().allow("", null),
|
|
47378
47640
|
name: import_joi107.default.string().required(),
|
|
@@ -47420,21 +47682,21 @@ function MOnlineForm(value) {
|
|
|
47420
47682
|
}
|
|
47421
47683
|
if (value._id && typeof value._id === "string") {
|
|
47422
47684
|
try {
|
|
47423
|
-
value._id = new
|
|
47685
|
+
value._id = new import_mongodb114.ObjectId(value._id);
|
|
47424
47686
|
} catch (error2) {
|
|
47425
47687
|
throw new Error("Invalid ID.");
|
|
47426
47688
|
}
|
|
47427
47689
|
}
|
|
47428
47690
|
if (value.org && typeof value.org === "string") {
|
|
47429
47691
|
try {
|
|
47430
|
-
value.org = new
|
|
47692
|
+
value.org = new import_mongodb114.ObjectId(value.org);
|
|
47431
47693
|
} catch (error2) {
|
|
47432
47694
|
throw new Error("Invalid org ID.");
|
|
47433
47695
|
}
|
|
47434
47696
|
}
|
|
47435
47697
|
if (value.site && typeof value.site === "string") {
|
|
47436
47698
|
try {
|
|
47437
|
-
value.site = new
|
|
47699
|
+
value.site = new import_mongodb114.ObjectId(value.site);
|
|
47438
47700
|
} catch (error2) {
|
|
47439
47701
|
throw new Error("Invalid site ID.");
|
|
47440
47702
|
}
|
|
@@ -47457,7 +47719,7 @@ function MOnlineForm(value) {
|
|
|
47457
47719
|
|
|
47458
47720
|
// src/repositories/online-form.repo.ts
|
|
47459
47721
|
var import_node_server_utils191 = require("@7365admin1/node-server-utils");
|
|
47460
|
-
var
|
|
47722
|
+
var import_mongodb115 = require("mongodb");
|
|
47461
47723
|
function useOnlineFormRepo() {
|
|
47462
47724
|
const db = import_node_server_utils191.useAtlas.getDb();
|
|
47463
47725
|
if (!db) {
|
|
@@ -47509,7 +47771,7 @@ function useOnlineFormRepo() {
|
|
|
47509
47771
|
}) {
|
|
47510
47772
|
page = page > 0 ? page - 1 : 0;
|
|
47511
47773
|
try {
|
|
47512
|
-
site = new
|
|
47774
|
+
site = new import_mongodb115.ObjectId(site);
|
|
47513
47775
|
} catch (error) {
|
|
47514
47776
|
throw new import_node_server_utils191.BadRequestError("Invalid site ID format.");
|
|
47515
47777
|
}
|
|
@@ -47569,7 +47831,7 @@ function useOnlineFormRepo() {
|
|
|
47569
47831
|
}
|
|
47570
47832
|
async function getOnlineFormById(_id) {
|
|
47571
47833
|
try {
|
|
47572
|
-
_id = new
|
|
47834
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
47573
47835
|
} catch (error) {
|
|
47574
47836
|
throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
|
|
47575
47837
|
}
|
|
@@ -47612,7 +47874,7 @@ function useOnlineFormRepo() {
|
|
|
47612
47874
|
}
|
|
47613
47875
|
async function updateOnlineFormById(_id, value) {
|
|
47614
47876
|
try {
|
|
47615
|
-
_id = new
|
|
47877
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
47616
47878
|
} catch (error) {
|
|
47617
47879
|
throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
|
|
47618
47880
|
}
|
|
@@ -47640,7 +47902,7 @@ function useOnlineFormRepo() {
|
|
|
47640
47902
|
}
|
|
47641
47903
|
async function deleteOnlineFormById(_id, session) {
|
|
47642
47904
|
try {
|
|
47643
|
-
_id = new
|
|
47905
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
47644
47906
|
} catch (error) {
|
|
47645
47907
|
throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
|
|
47646
47908
|
}
|
|
@@ -47673,7 +47935,7 @@ function useOnlineFormRepo() {
|
|
|
47673
47935
|
}
|
|
47674
47936
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
47675
47937
|
try {
|
|
47676
|
-
site = new
|
|
47938
|
+
site = new import_mongodb115.ObjectId(site);
|
|
47677
47939
|
} catch (error) {
|
|
47678
47940
|
throw new import_node_server_utils191.BadRequestError(
|
|
47679
47941
|
"Invalid online form configuration site ID format."
|
|
@@ -48105,7 +48367,7 @@ function useOccurrenceSubjectController() {
|
|
|
48105
48367
|
}
|
|
48106
48368
|
|
|
48107
48369
|
// src/models/nfc-patrol-log.model.ts
|
|
48108
|
-
var
|
|
48370
|
+
var import_mongodb116 = require("mongodb");
|
|
48109
48371
|
var import_joi110 = __toESM(require("joi"));
|
|
48110
48372
|
var import_node_server_utils195 = require("@7365admin1/node-server-utils");
|
|
48111
48373
|
var schemaNfcPatrolLog = import_joi110.default.object({
|
|
@@ -48157,32 +48419,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
48157
48419
|
}
|
|
48158
48420
|
if (value._id && typeof value._id === "string") {
|
|
48159
48421
|
try {
|
|
48160
|
-
value._id = new
|
|
48422
|
+
value._id = new import_mongodb116.ObjectId(value._id);
|
|
48161
48423
|
} catch (error2) {
|
|
48162
48424
|
throw new import_node_server_utils195.BadRequestError("Invalid _id format");
|
|
48163
48425
|
}
|
|
48164
48426
|
}
|
|
48165
48427
|
try {
|
|
48166
|
-
value.site = new
|
|
48428
|
+
value.site = new import_mongodb116.ObjectId(value.site);
|
|
48167
48429
|
} catch (error2) {
|
|
48168
48430
|
throw new import_node_server_utils195.BadRequestError("Invalid site format");
|
|
48169
48431
|
}
|
|
48170
48432
|
if (value?.createdBy) {
|
|
48171
48433
|
try {
|
|
48172
|
-
value.createdBy = new
|
|
48434
|
+
value.createdBy = new import_mongodb116.ObjectId(value.createdBy);
|
|
48173
48435
|
} catch (error2) {
|
|
48174
48436
|
throw new import_node_server_utils195.BadRequestError("Invalid createdBy format");
|
|
48175
48437
|
}
|
|
48176
48438
|
}
|
|
48177
48439
|
if (value?.route?._id) {
|
|
48178
48440
|
try {
|
|
48179
|
-
value.route._id = new
|
|
48441
|
+
value.route._id = new import_mongodb116.ObjectId(value.route._id);
|
|
48180
48442
|
} catch (error2) {
|
|
48181
48443
|
throw new import_node_server_utils195.BadRequestError("Invalid route _id format");
|
|
48182
48444
|
}
|
|
48183
48445
|
}
|
|
48184
48446
|
return {
|
|
48185
|
-
_id: value._id ?? new
|
|
48447
|
+
_id: value._id ?? new import_mongodb116.ObjectId(),
|
|
48186
48448
|
site: value.site,
|
|
48187
48449
|
route: value.route,
|
|
48188
48450
|
date: value.date,
|
|
@@ -48196,7 +48458,7 @@ function MNfcPatrolLog(valueArg) {
|
|
|
48196
48458
|
|
|
48197
48459
|
// src/repositories/nfc-patrol-log.repository.ts
|
|
48198
48460
|
var import_node_server_utils196 = require("@7365admin1/node-server-utils");
|
|
48199
|
-
var
|
|
48461
|
+
var import_mongodb117 = require("mongodb");
|
|
48200
48462
|
function useNfcPatrolLogRepo() {
|
|
48201
48463
|
const db = import_node_server_utils196.useAtlas.getDb();
|
|
48202
48464
|
if (!db) {
|
|
@@ -48249,7 +48511,7 @@ function useNfcPatrolLogRepo() {
|
|
|
48249
48511
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
48250
48512
|
let siteId;
|
|
48251
48513
|
try {
|
|
48252
|
-
siteId = typeof site === "string" ? new
|
|
48514
|
+
siteId = typeof site === "string" ? new import_mongodb117.ObjectId(site) : site;
|
|
48253
48515
|
} catch {
|
|
48254
48516
|
throw new import_node_server_utils196.BadRequestError("Invalid site ID format.");
|
|
48255
48517
|
}
|
|
@@ -48260,7 +48522,7 @@ function useNfcPatrolLogRepo() {
|
|
|
48260
48522
|
query.date = date;
|
|
48261
48523
|
}
|
|
48262
48524
|
if (route?._id) {
|
|
48263
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
48525
|
+
query["route._id"] = typeof route._id === "string" ? new import_mongodb117.ObjectId(route._id) : route._id;
|
|
48264
48526
|
}
|
|
48265
48527
|
if (route?.startTime) {
|
|
48266
48528
|
query["route.startTime"] = route.startTime;
|
|
@@ -49119,7 +49381,7 @@ function useNewDashboardController() {
|
|
|
49119
49381
|
|
|
49120
49382
|
// src/models/manpower-monitoring.model.ts
|
|
49121
49383
|
var import_joi113 = __toESM(require("joi"));
|
|
49122
|
-
var
|
|
49384
|
+
var import_mongodb118 = require("mongodb");
|
|
49123
49385
|
var shiftSchema = import_joi113.default.object({
|
|
49124
49386
|
name: import_joi113.default.string().required(),
|
|
49125
49387
|
checkIn: import_joi113.default.string().optional().allow("", null),
|
|
@@ -49144,7 +49406,7 @@ var manpowerMonitoringSchema = import_joi113.default.object({
|
|
|
49144
49406
|
});
|
|
49145
49407
|
var MManpowerMonitoring = class {
|
|
49146
49408
|
constructor(data) {
|
|
49147
|
-
this._id = new
|
|
49409
|
+
this._id = new import_mongodb118.ObjectId();
|
|
49148
49410
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
49149
49411
|
this.siteId = data.siteId || "";
|
|
49150
49412
|
this.siteName = data.siteName;
|
|
@@ -49392,7 +49654,7 @@ function filterByStatus(attendance, shiftData, timezone, format2, status) {
|
|
|
49392
49654
|
}
|
|
49393
49655
|
});
|
|
49394
49656
|
}
|
|
49395
|
-
function
|
|
49657
|
+
function sleep2(ms) {
|
|
49396
49658
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
49397
49659
|
}
|
|
49398
49660
|
async function fetchSites({ siteUrl, token }) {
|
|
@@ -49419,7 +49681,7 @@ async function fetchSites({ siteUrl, token }) {
|
|
|
49419
49681
|
}
|
|
49420
49682
|
if (attempt < maxRetries) {
|
|
49421
49683
|
const delay = 1e3 * attempt;
|
|
49422
|
-
await
|
|
49684
|
+
await sleep2(delay);
|
|
49423
49685
|
}
|
|
49424
49686
|
}
|
|
49425
49687
|
} while (attempt < maxRetries);
|
|
@@ -49611,7 +49873,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
49611
49873
|
};
|
|
49612
49874
|
|
|
49613
49875
|
// src/repositories/manpower-monitoring.repo.ts
|
|
49614
|
-
var
|
|
49876
|
+
var import_mongodb119 = require("mongodb");
|
|
49615
49877
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
49616
49878
|
function useManpowerMonitoringRepo() {
|
|
49617
49879
|
const db = import_node_server_utils201.useAtlas.getDb();
|
|
@@ -49646,11 +49908,11 @@ function useManpowerMonitoringRepo() {
|
|
|
49646
49908
|
try {
|
|
49647
49909
|
value = new MManpowerMonitoring(value);
|
|
49648
49910
|
if (value.createdBy)
|
|
49649
|
-
value.createdBy = new
|
|
49911
|
+
value.createdBy = new import_mongodb119.ObjectId(value.createdBy);
|
|
49650
49912
|
if (value.siteId)
|
|
49651
|
-
value.siteId = new
|
|
49913
|
+
value.siteId = new import_mongodb119.ObjectId(value.siteId);
|
|
49652
49914
|
if (value.serviceProviderId)
|
|
49653
|
-
value.serviceProviderId = new
|
|
49915
|
+
value.serviceProviderId = new import_mongodb119.ObjectId(value.serviceProviderId);
|
|
49654
49916
|
const result = await collection.insertOne(value, { session });
|
|
49655
49917
|
return result;
|
|
49656
49918
|
} catch (error) {
|
|
@@ -49691,8 +49953,8 @@ function useManpowerMonitoringRepo() {
|
|
|
49691
49953
|
}
|
|
49692
49954
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
49693
49955
|
try {
|
|
49694
|
-
_id = new
|
|
49695
|
-
serviceProviderId = new
|
|
49956
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
49957
|
+
serviceProviderId = new import_mongodb119.ObjectId(serviceProviderId);
|
|
49696
49958
|
} catch (error) {
|
|
49697
49959
|
throw new Error("Invalid Site ID format.");
|
|
49698
49960
|
}
|
|
@@ -49708,7 +49970,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49708
49970
|
}
|
|
49709
49971
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
49710
49972
|
try {
|
|
49711
|
-
_id = new
|
|
49973
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
49712
49974
|
} catch (error) {
|
|
49713
49975
|
throw new import_node_server_utils201.BadRequestError("Invalid ID format.");
|
|
49714
49976
|
}
|
|
@@ -49735,7 +49997,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49735
49997
|
for (let item of value) {
|
|
49736
49998
|
item = new MManpowerMonitoring(item);
|
|
49737
49999
|
const data = await collection.findOne({
|
|
49738
|
-
siteId: new
|
|
50000
|
+
siteId: new import_mongodb119.ObjectId(item.siteId)
|
|
49739
50001
|
});
|
|
49740
50002
|
if (data) {
|
|
49741
50003
|
let updateValue;
|
|
@@ -49760,11 +50022,11 @@ function useManpowerMonitoringRepo() {
|
|
|
49760
50022
|
}
|
|
49761
50023
|
} else {
|
|
49762
50024
|
if (item.createdBy)
|
|
49763
|
-
item.createdBy = new
|
|
50025
|
+
item.createdBy = new import_mongodb119.ObjectId(item.createdBy);
|
|
49764
50026
|
if (item.siteId)
|
|
49765
|
-
item.siteId = new
|
|
50027
|
+
item.siteId = new import_mongodb119.ObjectId(item.siteId);
|
|
49766
50028
|
if (item.serviceProviderId)
|
|
49767
|
-
item.serviceProviderId = new
|
|
50029
|
+
item.serviceProviderId = new import_mongodb119.ObjectId(item.serviceProviderId);
|
|
49768
50030
|
const result = await collection.insertOne(item);
|
|
49769
50031
|
if (result.insertedId) {
|
|
49770
50032
|
results.inserted++;
|
|
@@ -49788,7 +50050,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49788
50050
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
49789
50051
|
try {
|
|
49790
50052
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
49791
|
-
_id: new
|
|
50053
|
+
_id: new import_mongodb119.ObjectId(serviceProviderId)
|
|
49792
50054
|
});
|
|
49793
50055
|
if (!serviceProvider) {
|
|
49794
50056
|
throw new Error("Service Provider not found.");
|
|
@@ -49831,7 +50093,7 @@ var import_node_server_utils202 = require("@7365admin1/node-server-utils");
|
|
|
49831
50093
|
|
|
49832
50094
|
// src/models/manpower-remarks.model.ts
|
|
49833
50095
|
var import_joi114 = __toESM(require("joi"));
|
|
49834
|
-
var
|
|
50096
|
+
var import_mongodb120 = require("mongodb");
|
|
49835
50097
|
var remarksSchema = import_joi114.default.object({
|
|
49836
50098
|
name: import_joi114.default.string().required(),
|
|
49837
50099
|
remark: import_joi114.default.object({
|
|
@@ -49855,7 +50117,7 @@ var manpowerRemarksSchema = import_joi114.default.object({
|
|
|
49855
50117
|
});
|
|
49856
50118
|
var MManpowerRemarks = class {
|
|
49857
50119
|
constructor(data) {
|
|
49858
|
-
this._id = new
|
|
50120
|
+
this._id = new import_mongodb120.ObjectId();
|
|
49859
50121
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
49860
50122
|
this.siteId = data.siteId || "";
|
|
49861
50123
|
this.siteName = data.siteName || "";
|
|
@@ -49873,7 +50135,7 @@ var MManpowerRemarks = class {
|
|
|
49873
50135
|
};
|
|
49874
50136
|
|
|
49875
50137
|
// src/repositories/manpower-remarks.repo.ts
|
|
49876
|
-
var
|
|
50138
|
+
var import_mongodb121 = require("mongodb");
|
|
49877
50139
|
var import_moment_timezone2 = __toESM(require("moment-timezone"));
|
|
49878
50140
|
function useManpowerRemarksRepo() {
|
|
49879
50141
|
const db = import_node_server_utils202.useAtlas.getDb();
|
|
@@ -49907,9 +50169,9 @@ function useManpowerRemarksRepo() {
|
|
|
49907
50169
|
try {
|
|
49908
50170
|
value = new MManpowerRemarks(value);
|
|
49909
50171
|
if (value.siteId)
|
|
49910
|
-
value.siteId = new
|
|
50172
|
+
value.siteId = new import_mongodb121.ObjectId(value.siteId);
|
|
49911
50173
|
if (value.serviceProviderId)
|
|
49912
|
-
value.serviceProviderId = new
|
|
50174
|
+
value.serviceProviderId = new import_mongodb121.ObjectId(value.serviceProviderId);
|
|
49913
50175
|
const result = await collection.insertOne(value, { session });
|
|
49914
50176
|
return result;
|
|
49915
50177
|
} catch (error) {
|
|
@@ -49929,7 +50191,7 @@ function useManpowerRemarksRepo() {
|
|
|
49929
50191
|
limit = limit || 10;
|
|
49930
50192
|
const searchQuery = {};
|
|
49931
50193
|
const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
|
|
49932
|
-
searchQuery.serviceProviderId = new
|
|
50194
|
+
searchQuery.serviceProviderId = new import_mongodb121.ObjectId(serviceProviderId);
|
|
49933
50195
|
if (search != "") {
|
|
49934
50196
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
49935
50197
|
}
|
|
@@ -49961,8 +50223,8 @@ function useManpowerRemarksRepo() {
|
|
|
49961
50223
|
}
|
|
49962
50224
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
49963
50225
|
try {
|
|
49964
|
-
_id = new
|
|
49965
|
-
serviceProviderId = new
|
|
50226
|
+
_id = new import_mongodb121.ObjectId(_id);
|
|
50227
|
+
serviceProviderId = new import_mongodb121.ObjectId(serviceProviderId);
|
|
49966
50228
|
} catch (error) {
|
|
49967
50229
|
throw new Error("Invalid Site ID format.");
|
|
49968
50230
|
}
|
|
@@ -49979,13 +50241,13 @@ function useManpowerRemarksRepo() {
|
|
|
49979
50241
|
}
|
|
49980
50242
|
async function updateManpowerRemarks(_id, value) {
|
|
49981
50243
|
try {
|
|
49982
|
-
_id = new
|
|
50244
|
+
_id = new import_mongodb121.ObjectId(_id);
|
|
49983
50245
|
} catch (error) {
|
|
49984
50246
|
throw new import_node_server_utils202.BadRequestError("Invalid ID format.");
|
|
49985
50247
|
}
|
|
49986
50248
|
try {
|
|
49987
50249
|
if (value.createdBy) {
|
|
49988
|
-
value.createdBy = new
|
|
50250
|
+
value.createdBy = new import_mongodb121.ObjectId(value.createdBy);
|
|
49989
50251
|
}
|
|
49990
50252
|
const updateValue = {
|
|
49991
50253
|
...value,
|
|
@@ -50002,7 +50264,7 @@ function useManpowerRemarksRepo() {
|
|
|
50002
50264
|
}
|
|
50003
50265
|
async function updateRemarksStatus(_id, value) {
|
|
50004
50266
|
try {
|
|
50005
|
-
_id = new
|
|
50267
|
+
_id = new import_mongodb121.ObjectId(_id);
|
|
50006
50268
|
} catch (error) {
|
|
50007
50269
|
throw new import_node_server_utils202.BadRequestError("Invalid ID format.");
|
|
50008
50270
|
}
|
|
@@ -50272,7 +50534,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
50272
50534
|
|
|
50273
50535
|
// src/models/manpower-designations.model.ts
|
|
50274
50536
|
var import_joi116 = __toESM(require("joi"));
|
|
50275
|
-
var
|
|
50537
|
+
var import_mongodb122 = require("mongodb");
|
|
50276
50538
|
var designationsSchema = import_joi116.default.object({
|
|
50277
50539
|
title: import_joi116.default.string().required(),
|
|
50278
50540
|
shifts: import_joi116.default.object({
|
|
@@ -50291,7 +50553,7 @@ var manpowerDesignationsSchema = import_joi116.default.object({
|
|
|
50291
50553
|
});
|
|
50292
50554
|
var MManpowerDesignations = class {
|
|
50293
50555
|
constructor(data) {
|
|
50294
|
-
this._id = new
|
|
50556
|
+
this._id = new import_mongodb122.ObjectId();
|
|
50295
50557
|
this.siteId = data.siteId || "";
|
|
50296
50558
|
this.siteName = data.siteName || "";
|
|
50297
50559
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -50305,7 +50567,7 @@ var MManpowerDesignations = class {
|
|
|
50305
50567
|
|
|
50306
50568
|
// src/repositories/manpower-designations.repo.ts
|
|
50307
50569
|
var import_node_server_utils205 = require("@7365admin1/node-server-utils");
|
|
50308
|
-
var
|
|
50570
|
+
var import_mongodb123 = require("mongodb");
|
|
50309
50571
|
function useManpowerDesignationRepo() {
|
|
50310
50572
|
const db = import_node_server_utils205.useAtlas.getDb();
|
|
50311
50573
|
if (!db) {
|
|
@@ -50337,11 +50599,11 @@ function useManpowerDesignationRepo() {
|
|
|
50337
50599
|
try {
|
|
50338
50600
|
value = new MManpowerDesignations(value);
|
|
50339
50601
|
if (value.createdBy)
|
|
50340
|
-
value.createdBy = new
|
|
50602
|
+
value.createdBy = new import_mongodb123.ObjectId(value.createdBy);
|
|
50341
50603
|
if (value.siteId)
|
|
50342
|
-
value.siteId = new
|
|
50604
|
+
value.siteId = new import_mongodb123.ObjectId(value.siteId);
|
|
50343
50605
|
if (value.serviceProviderId)
|
|
50344
|
-
value.serviceProviderId = new
|
|
50606
|
+
value.serviceProviderId = new import_mongodb123.ObjectId(value.serviceProviderId);
|
|
50345
50607
|
const result = await collection.insertOne(value);
|
|
50346
50608
|
return result;
|
|
50347
50609
|
} catch (error) {
|
|
@@ -50350,8 +50612,8 @@ function useManpowerDesignationRepo() {
|
|
|
50350
50612
|
}
|
|
50351
50613
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
50352
50614
|
try {
|
|
50353
|
-
_id = new
|
|
50354
|
-
serviceProviderId = new
|
|
50615
|
+
_id = new import_mongodb123.ObjectId(_id);
|
|
50616
|
+
serviceProviderId = new import_mongodb123.ObjectId(serviceProviderId);
|
|
50355
50617
|
} catch (error) {
|
|
50356
50618
|
throw new Error("Invalid Site ID format.");
|
|
50357
50619
|
}
|
|
@@ -50367,7 +50629,7 @@ function useManpowerDesignationRepo() {
|
|
|
50367
50629
|
}
|
|
50368
50630
|
async function updateManpowerDesignations(_id, value) {
|
|
50369
50631
|
try {
|
|
50370
|
-
_id = new
|
|
50632
|
+
_id = new import_mongodb123.ObjectId(_id);
|
|
50371
50633
|
} catch (error) {
|
|
50372
50634
|
throw new Error("Invalid ID format.");
|
|
50373
50635
|
}
|
|
@@ -50471,7 +50733,7 @@ function useManpowerDesignationCtrl() {
|
|
|
50471
50733
|
|
|
50472
50734
|
// src/models/overnight-parking.model.ts
|
|
50473
50735
|
var import_joi118 = __toESM(require("joi"));
|
|
50474
|
-
var
|
|
50736
|
+
var import_mongodb124 = require("mongodb");
|
|
50475
50737
|
var dayScheduleSchema = import_joi118.default.object({
|
|
50476
50738
|
isEnabled: import_joi118.default.boolean().required(),
|
|
50477
50739
|
startTime: import_joi118.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -50513,7 +50775,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
50513
50775
|
}
|
|
50514
50776
|
if (value.site && typeof value.site === "string") {
|
|
50515
50777
|
try {
|
|
50516
|
-
value.site = new
|
|
50778
|
+
value.site = new import_mongodb124.ObjectId(value.site);
|
|
50517
50779
|
} catch {
|
|
50518
50780
|
throw new Error("Invalid site ID.");
|
|
50519
50781
|
}
|
|
@@ -52118,7 +52380,7 @@ function useManpowerRemarkCtrl() {
|
|
|
52118
52380
|
|
|
52119
52381
|
// src/models/manpower-sites.model.ts
|
|
52120
52382
|
var import_joi124 = __toESM(require("joi"));
|
|
52121
|
-
var
|
|
52383
|
+
var import_mongodb125 = require("mongodb");
|
|
52122
52384
|
var manpowerSitesSchema = import_joi124.default.object({
|
|
52123
52385
|
id: import_joi124.default.string().hex().required(),
|
|
52124
52386
|
text: import_joi124.default.string().hex().optional().allow("", null),
|
|
@@ -52129,7 +52391,7 @@ var manpowerSitesSchema = import_joi124.default.object({
|
|
|
52129
52391
|
});
|
|
52130
52392
|
var MManpowerSites = class {
|
|
52131
52393
|
constructor(data) {
|
|
52132
|
-
this._id = new
|
|
52394
|
+
this._id = new import_mongodb125.ObjectId();
|
|
52133
52395
|
this.id = data.id || "";
|
|
52134
52396
|
this.text = data.text || "";
|
|
52135
52397
|
this.contractID = data.contractID || "";
|
|
@@ -52339,7 +52601,7 @@ function useManpowerSitesCtrl() {
|
|
|
52339
52601
|
|
|
52340
52602
|
// src/utils/cron.util.ts
|
|
52341
52603
|
var import_node_server_utils219 = require("@7365admin1/node-server-utils");
|
|
52342
|
-
var
|
|
52604
|
+
var import_mongodb126 = require("mongodb");
|
|
52343
52605
|
var import_moment_timezone4 = __toESM(require("moment-timezone"));
|
|
52344
52606
|
var createManpowerRemarksDaily = async () => {
|
|
52345
52607
|
const db = import_node_server_utils219.useAtlas.getDb();
|
|
@@ -52499,7 +52761,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
52499
52761
|
for (const id of updatedIds) {
|
|
52500
52762
|
const doc = await remarks.findOne({ _id: id });
|
|
52501
52763
|
const setting = await settings.findOne(
|
|
52502
|
-
{ siteId: new
|
|
52764
|
+
{ siteId: new import_mongodb126.ObjectId(doc?.siteId) },
|
|
52503
52765
|
{ projection: { emails: 1 } }
|
|
52504
52766
|
);
|
|
52505
52767
|
const payload = {
|
|
@@ -52585,7 +52847,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
52585
52847
|
for (const doc of docs) {
|
|
52586
52848
|
let shiftsToCheck = [];
|
|
52587
52849
|
const endShiftTime = await settings.findOne(
|
|
52588
|
-
{ siteId: new
|
|
52850
|
+
{ siteId: new import_mongodb126.ObjectId(doc.siteId) },
|
|
52589
52851
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
52590
52852
|
);
|
|
52591
52853
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -52691,7 +52953,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
52691
52953
|
|
|
52692
52954
|
// src/events/manpower.event.ts
|
|
52693
52955
|
var import_node_server_utils220 = require("@7365admin1/node-server-utils");
|
|
52694
|
-
var
|
|
52956
|
+
var import_mongodb127 = require("mongodb");
|
|
52695
52957
|
var import_moment_timezone5 = __toESM(require("moment-timezone"));
|
|
52696
52958
|
async function manpowerEvents(io) {
|
|
52697
52959
|
let intervalId = null;
|
|
@@ -52717,7 +52979,7 @@ async function manpowerEvents(io) {
|
|
|
52717
52979
|
}).toArray();
|
|
52718
52980
|
for (const doc of docs) {
|
|
52719
52981
|
const siteSettings = await settings.findOne(
|
|
52720
|
-
{ siteId: new
|
|
52982
|
+
{ siteId: new import_mongodb127.ObjectId(doc.siteId), enabled: true },
|
|
52721
52983
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
52722
52984
|
);
|
|
52723
52985
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -52836,11 +53098,11 @@ function genericSignature(params, secretKey) {
|
|
|
52836
53098
|
}
|
|
52837
53099
|
|
|
52838
53100
|
// src/repositories/reddot-payment.repository.ts
|
|
52839
|
-
var
|
|
53101
|
+
var import_mongodb129 = require("mongodb");
|
|
52840
53102
|
|
|
52841
53103
|
// src/models/billing-payments.model.ts
|
|
52842
53104
|
var import_node_server_utils221 = require("@7365admin1/node-server-utils");
|
|
52843
|
-
var
|
|
53105
|
+
var import_mongodb128 = require("mongodb");
|
|
52844
53106
|
var import_joi126 = __toESM(require("joi"));
|
|
52845
53107
|
var schemaBillingItems = import_joi126.default.object({
|
|
52846
53108
|
_id: import_joi126.default.string().hex().optional(),
|
|
@@ -52874,21 +53136,21 @@ function MBillingItems(value) {
|
|
|
52874
53136
|
}
|
|
52875
53137
|
if (value._id && typeof value._id === "string") {
|
|
52876
53138
|
try {
|
|
52877
|
-
value._id = new
|
|
53139
|
+
value._id = new import_mongodb128.ObjectId(value._id);
|
|
52878
53140
|
} catch {
|
|
52879
53141
|
throw new import_node_server_utils221.BadRequestError("Invalid _id format");
|
|
52880
53142
|
}
|
|
52881
53143
|
}
|
|
52882
53144
|
if (value.unitId && typeof value.unitId === "string") {
|
|
52883
53145
|
try {
|
|
52884
|
-
value.unitId = new
|
|
53146
|
+
value.unitId = new import_mongodb128.ObjectId(value.unitId);
|
|
52885
53147
|
} catch {
|
|
52886
53148
|
throw new import_node_server_utils221.BadRequestError("Invalid unitId id format");
|
|
52887
53149
|
}
|
|
52888
53150
|
}
|
|
52889
53151
|
if (value.paidBy && typeof value.paidBy === "string") {
|
|
52890
53152
|
try {
|
|
52891
|
-
value.paidBy = new
|
|
53153
|
+
value.paidBy = new import_mongodb128.ObjectId(value.paidBy);
|
|
52892
53154
|
} catch {
|
|
52893
53155
|
throw new import_node_server_utils221.BadRequestError("Invalid paidBy id format");
|
|
52894
53156
|
}
|
|
@@ -52898,7 +53160,7 @@ function MBillingItems(value) {
|
|
|
52898
53160
|
value.unitBillingItems = value.unitBillingItems.map((unitBillingItem) => {
|
|
52899
53161
|
if (typeof unitBillingItem._id === "string") {
|
|
52900
53162
|
try {
|
|
52901
|
-
unitBillingItem._id = new
|
|
53163
|
+
unitBillingItem._id = new import_mongodb128.ObjectId(unitBillingItem._id);
|
|
52902
53164
|
} catch {
|
|
52903
53165
|
throw new import_node_server_utils221.BadRequestError("Invalid unit billing id format");
|
|
52904
53166
|
}
|
|
@@ -52910,7 +53172,7 @@ function MBillingItems(value) {
|
|
|
52910
53172
|
}
|
|
52911
53173
|
}
|
|
52912
53174
|
return {
|
|
52913
|
-
_id: value._id ?? new
|
|
53175
|
+
_id: value._id ?? new import_mongodb128.ObjectId(),
|
|
52914
53176
|
unitBillingItems: value.unitBillingItems ?? [],
|
|
52915
53177
|
unitId: value.unitId ?? "",
|
|
52916
53178
|
unitOwner: value.unitOwner ?? "",
|
|
@@ -52978,7 +53240,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
52978
53240
|
const res = await paymentCollection().insertOne(payload, { session });
|
|
52979
53241
|
const unit = payload.unitId?.toString().slice(-4);
|
|
52980
53242
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
|
|
52981
|
-
const newId = new
|
|
53243
|
+
const newId = new import_mongodb129.ObjectId(res.insertedId).toString().slice(-6);
|
|
52982
53244
|
const referenceNumber = `${unit}${newId}${dateFormatted}`;
|
|
52983
53245
|
await paymentCollection().updateOne(
|
|
52984
53246
|
{ _id: res.insertedId },
|
|
@@ -54078,7 +54340,7 @@ var import_node_server_utils228 = require("@7365admin1/node-server-utils");
|
|
|
54078
54340
|
var import_uuid2 = require("uuid");
|
|
54079
54341
|
|
|
54080
54342
|
// src/repositories/user-v2.repo.ts
|
|
54081
|
-
var
|
|
54343
|
+
var import_mongodb130 = require("mongodb");
|
|
54082
54344
|
var import_node_server_utils227 = require("@7365admin1/node-server-utils");
|
|
54083
54345
|
function useUserRepoV2() {
|
|
54084
54346
|
const { updateFeedbackCreatedByName } = useFeedbackRepo();
|
|
@@ -54279,7 +54541,7 @@ function useUserRepoV2() {
|
|
|
54279
54541
|
}
|
|
54280
54542
|
if (organization) {
|
|
54281
54543
|
try {
|
|
54282
|
-
query.defaultOrg = new
|
|
54544
|
+
query.defaultOrg = new import_mongodb130.ObjectId(organization);
|
|
54283
54545
|
cacheOptions.organization = organization.toString();
|
|
54284
54546
|
} catch (error) {
|
|
54285
54547
|
throw new import_node_server_utils227.BadRequestError("Invalid organization ID format.");
|
|
@@ -54418,13 +54680,13 @@ function useUserRepoV2() {
|
|
|
54418
54680
|
);
|
|
54419
54681
|
}
|
|
54420
54682
|
try {
|
|
54421
|
-
_id = new
|
|
54683
|
+
_id = new import_mongodb130.ObjectId(_id);
|
|
54422
54684
|
} catch (error) {
|
|
54423
54685
|
throw new import_node_server_utils227.BadRequestError("Invalid ID.");
|
|
54424
54686
|
}
|
|
54425
54687
|
if (field === "defaultOrg") {
|
|
54426
54688
|
try {
|
|
54427
|
-
value = new
|
|
54689
|
+
value = new import_mongodb130.ObjectId(value);
|
|
54428
54690
|
} catch (error) {
|
|
54429
54691
|
throw new import_node_server_utils227.BadRequestError("Invalid organization ID.");
|
|
54430
54692
|
}
|
|
@@ -54465,7 +54727,7 @@ function useUserRepoV2() {
|
|
|
54465
54727
|
year
|
|
54466
54728
|
}, session) {
|
|
54467
54729
|
try {
|
|
54468
|
-
_id = new
|
|
54730
|
+
_id = new import_mongodb130.ObjectId(_id);
|
|
54469
54731
|
} catch (error) {
|
|
54470
54732
|
throw new import_node_server_utils227.BadRequestError("Invalid user ID format.");
|
|
54471
54733
|
}
|
|
@@ -54495,7 +54757,7 @@ function useUserRepoV2() {
|
|
|
54495
54757
|
}
|
|
54496
54758
|
async function updatePassword({ _id, password }, session) {
|
|
54497
54759
|
try {
|
|
54498
|
-
_id = new
|
|
54760
|
+
_id = new import_mongodb130.ObjectId(_id);
|
|
54499
54761
|
} catch (error) {
|
|
54500
54762
|
throw new import_node_server_utils227.BadRequestError("Invalid user ID format.");
|
|
54501
54763
|
}
|
|
@@ -55250,38 +55512,38 @@ function useUserControllerV2() {
|
|
|
55250
55512
|
|
|
55251
55513
|
// src/models/role-v2.model.ts
|
|
55252
55514
|
var import_node_server_utils232 = require("@7365admin1/node-server-utils");
|
|
55253
|
-
var
|
|
55515
|
+
var import_mongodb131 = require("mongodb");
|
|
55254
55516
|
var MRoleV2 = class {
|
|
55255
55517
|
constructor(value) {
|
|
55256
55518
|
if (typeof value._id === "string") {
|
|
55257
55519
|
try {
|
|
55258
|
-
value._id = new
|
|
55520
|
+
value._id = new import_mongodb131.ObjectId(value._id);
|
|
55259
55521
|
} catch (error) {
|
|
55260
55522
|
throw new import_node_server_utils232.BadRequestError("Invalid role-v2 ID format.");
|
|
55261
55523
|
}
|
|
55262
55524
|
}
|
|
55263
55525
|
if (typeof value.site === "string" && value.site.length === 24) {
|
|
55264
55526
|
try {
|
|
55265
|
-
value.site = new
|
|
55527
|
+
value.site = new import_mongodb131.ObjectId(value.site);
|
|
55266
55528
|
} catch (error) {
|
|
55267
55529
|
throw new import_node_server_utils232.BadRequestError("Invalid site ID format.");
|
|
55268
55530
|
}
|
|
55269
55531
|
}
|
|
55270
55532
|
if (typeof value.org === "string" && value.org.length === 24) {
|
|
55271
55533
|
try {
|
|
55272
|
-
value.org = new
|
|
55534
|
+
value.org = new import_mongodb131.ObjectId(value.org);
|
|
55273
55535
|
} catch (error) {
|
|
55274
55536
|
throw new import_node_server_utils232.BadRequestError("Invalid org ID format.");
|
|
55275
55537
|
}
|
|
55276
55538
|
}
|
|
55277
55539
|
if (value.createdBy) {
|
|
55278
55540
|
try {
|
|
55279
|
-
value.createdBy = new
|
|
55541
|
+
value.createdBy = new import_mongodb131.ObjectId(value.createdBy);
|
|
55280
55542
|
} catch (error) {
|
|
55281
55543
|
throw new import_node_server_utils232.BadRequestError("Invalid created by ID format.");
|
|
55282
55544
|
}
|
|
55283
55545
|
}
|
|
55284
|
-
this._id = value._id ?? new
|
|
55546
|
+
this._id = value._id ?? new import_mongodb131.ObjectId();
|
|
55285
55547
|
this.name = value.name ?? "";
|
|
55286
55548
|
this.permissions = value.permissions ?? [];
|
|
55287
55549
|
this.site = value.site ?? "";
|
|
@@ -55416,7 +55678,7 @@ function useRoleControllerV2() {
|
|
|
55416
55678
|
|
|
55417
55679
|
// src/models/post-preloved.model.ts
|
|
55418
55680
|
var import_joi133 = __toESM(require("joi"));
|
|
55419
|
-
var
|
|
55681
|
+
var import_mongodb132 = require("mongodb");
|
|
55420
55682
|
var PostStatus = /* @__PURE__ */ ((PostStatus2) => {
|
|
55421
55683
|
PostStatus2["PUBLISHED"] = "published";
|
|
55422
55684
|
PostStatus2["RESERVED"] = "reserved";
|
|
@@ -55472,28 +55734,28 @@ function MPost(value) {
|
|
|
55472
55734
|
}
|
|
55473
55735
|
if (value._id && typeof value._id === "string") {
|
|
55474
55736
|
try {
|
|
55475
|
-
value._id = new
|
|
55737
|
+
value._id = new import_mongodb132.ObjectId(value._id);
|
|
55476
55738
|
} catch {
|
|
55477
55739
|
throw new Error("Invalid ID.");
|
|
55478
55740
|
}
|
|
55479
55741
|
}
|
|
55480
55742
|
if (value.site && typeof value.site === "string") {
|
|
55481
55743
|
try {
|
|
55482
|
-
value.site = new
|
|
55744
|
+
value.site = new import_mongodb132.ObjectId(value.site);
|
|
55483
55745
|
} catch {
|
|
55484
55746
|
throw new Error("Invalid site ID.");
|
|
55485
55747
|
}
|
|
55486
55748
|
}
|
|
55487
55749
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
55488
55750
|
try {
|
|
55489
|
-
value.createdBy = new
|
|
55751
|
+
value.createdBy = new import_mongodb132.ObjectId(value.createdBy);
|
|
55490
55752
|
} catch {
|
|
55491
55753
|
throw new Error("Invalid createdBy ID.");
|
|
55492
55754
|
}
|
|
55493
55755
|
}
|
|
55494
55756
|
if (value.reserverId && typeof value.reserverId === "string") {
|
|
55495
55757
|
try {
|
|
55496
|
-
value.reserverId = new
|
|
55758
|
+
value.reserverId = new import_mongodb132.ObjectId(value.reserverId);
|
|
55497
55759
|
} catch {
|
|
55498
55760
|
throw new Error("Invalid reserver ID.");
|
|
55499
55761
|
}
|
|
@@ -55502,7 +55764,7 @@ function MPost(value) {
|
|
|
55502
55764
|
value.attachments = value.attachments.map((id) => {
|
|
55503
55765
|
if (typeof id === "string") {
|
|
55504
55766
|
try {
|
|
55505
|
-
return new
|
|
55767
|
+
return new import_mongodb132.ObjectId(id);
|
|
55506
55768
|
} catch {
|
|
55507
55769
|
throw new Error("Invalid attachment ID.");
|
|
55508
55770
|
}
|
|
@@ -55512,20 +55774,20 @@ function MPost(value) {
|
|
|
55512
55774
|
}
|
|
55513
55775
|
if (value.category && typeof value.category === "string") {
|
|
55514
55776
|
try {
|
|
55515
|
-
value.category = new
|
|
55777
|
+
value.category = new import_mongodb132.ObjectId(value.category);
|
|
55516
55778
|
} catch {
|
|
55517
55779
|
throw new Error("Invalid category ID.");
|
|
55518
55780
|
}
|
|
55519
55781
|
}
|
|
55520
55782
|
if (value.subcategory && typeof value.subcategory === "string") {
|
|
55521
55783
|
try {
|
|
55522
|
-
value.subcategory = new
|
|
55784
|
+
value.subcategory = new import_mongodb132.ObjectId(value.subcategory);
|
|
55523
55785
|
} catch {
|
|
55524
55786
|
throw new Error("Invalid subcategory ID.");
|
|
55525
55787
|
}
|
|
55526
55788
|
}
|
|
55527
55789
|
return {
|
|
55528
|
-
_id: value._id ?? new
|
|
55790
|
+
_id: value._id ?? new import_mongodb132.ObjectId(),
|
|
55529
55791
|
title: value.title ?? "",
|
|
55530
55792
|
description: value.description ?? "",
|
|
55531
55793
|
attachments: value.attachments ?? [],
|
|
@@ -55545,7 +55807,7 @@ function MPost(value) {
|
|
|
55545
55807
|
|
|
55546
55808
|
// src/repositories/post-preloved.repo.ts
|
|
55547
55809
|
var import_node_server_utils235 = require("@7365admin1/node-server-utils");
|
|
55548
|
-
var
|
|
55810
|
+
var import_mongodb133 = require("mongodb");
|
|
55549
55811
|
function usePostPrelovedRepo() {
|
|
55550
55812
|
const db = import_node_server_utils235.useAtlas.getDb();
|
|
55551
55813
|
if (!db) {
|
|
@@ -55609,7 +55871,7 @@ function usePostPrelovedRepo() {
|
|
|
55609
55871
|
}
|
|
55610
55872
|
async function getById(_id) {
|
|
55611
55873
|
try {
|
|
55612
|
-
_id = new
|
|
55874
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55613
55875
|
} catch {
|
|
55614
55876
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55615
55877
|
}
|
|
@@ -55642,7 +55904,7 @@ function usePostPrelovedRepo() {
|
|
|
55642
55904
|
page = page > 0 ? page - 1 : 0;
|
|
55643
55905
|
if (site) {
|
|
55644
55906
|
try {
|
|
55645
|
-
site = new
|
|
55907
|
+
site = new import_mongodb133.ObjectId(site);
|
|
55646
55908
|
} catch {
|
|
55647
55909
|
throw new import_node_server_utils235.BadRequestError("Invalid site ID format.");
|
|
55648
55910
|
}
|
|
@@ -55651,14 +55913,14 @@ function usePostPrelovedRepo() {
|
|
|
55651
55913
|
let subcategoryIds = null;
|
|
55652
55914
|
if (category && subcategory) {
|
|
55653
55915
|
try {
|
|
55654
|
-
categoryId = new
|
|
55916
|
+
categoryId = new import_mongodb133.ObjectId(category);
|
|
55655
55917
|
} catch {
|
|
55656
55918
|
throw new import_node_server_utils235.BadRequestError("Invalid category ID format.");
|
|
55657
55919
|
}
|
|
55658
55920
|
if (subcategory.length > 0) {
|
|
55659
55921
|
subcategoryIds = subcategory.map((id) => {
|
|
55660
55922
|
try {
|
|
55661
|
-
return new
|
|
55923
|
+
return new import_mongodb133.ObjectId(id);
|
|
55662
55924
|
} catch {
|
|
55663
55925
|
throw new import_node_server_utils235.BadRequestError("Invalid subcategory ID format.");
|
|
55664
55926
|
}
|
|
@@ -55683,7 +55945,7 @@ function usePostPrelovedRepo() {
|
|
|
55683
55945
|
let userObjectId = null;
|
|
55684
55946
|
if (userId) {
|
|
55685
55947
|
try {
|
|
55686
|
-
userObjectId = new
|
|
55948
|
+
userObjectId = new import_mongodb133.ObjectId(userId);
|
|
55687
55949
|
} catch {
|
|
55688
55950
|
throw new import_node_server_utils235.BadRequestError("Invalid user ID format.");
|
|
55689
55951
|
}
|
|
@@ -55732,7 +55994,7 @@ function usePostPrelovedRepo() {
|
|
|
55732
55994
|
}
|
|
55733
55995
|
async function updateById(_id, value, session) {
|
|
55734
55996
|
try {
|
|
55735
|
-
_id = new
|
|
55997
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55736
55998
|
} catch {
|
|
55737
55999
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55738
56000
|
}
|
|
@@ -55753,7 +56015,7 @@ function usePostPrelovedRepo() {
|
|
|
55753
56015
|
}
|
|
55754
56016
|
async function deleteById(_id, session) {
|
|
55755
56017
|
try {
|
|
55756
|
-
_id = new
|
|
56018
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55757
56019
|
} catch {
|
|
55758
56020
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55759
56021
|
}
|
|
@@ -55779,7 +56041,7 @@ function usePostPrelovedRepo() {
|
|
|
55779
56041
|
}
|
|
55780
56042
|
async function updateStatus(_id, status, session) {
|
|
55781
56043
|
try {
|
|
55782
|
-
_id = new
|
|
56044
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55783
56045
|
} catch {
|
|
55784
56046
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55785
56047
|
}
|
|
@@ -55870,7 +56132,7 @@ function usePostPrelovedController() {
|
|
|
55870
56132
|
import_joi134.default.string().valid(...Object.values(PostStatus))
|
|
55871
56133
|
).optional().allow(null),
|
|
55872
56134
|
category: import_joi134.default.string().hex().length(24).optional().allow("", null),
|
|
55873
|
-
subcategory: import_joi134.default.
|
|
56135
|
+
subcategory: import_joi134.default.array().items(import_joi134.default.string()).single().optional().allow(null),
|
|
55874
56136
|
userId: import_joi134.default.string().optional().allow("", null)
|
|
55875
56137
|
});
|
|
55876
56138
|
const { error, value } = validation.validate(req.query, {
|
|
@@ -55991,7 +56253,7 @@ function usePostPrelovedController() {
|
|
|
55991
56253
|
|
|
55992
56254
|
// src/models/post-favorite.model.ts
|
|
55993
56255
|
var import_joi135 = __toESM(require("joi"));
|
|
55994
|
-
var
|
|
56256
|
+
var import_mongodb134 = require("mongodb");
|
|
55995
56257
|
var schemaUpdatePostFavorite = import_joi135.default.object({
|
|
55996
56258
|
userId: import_joi135.default.string().hex().length(24).required()
|
|
55997
56259
|
});
|
|
@@ -56009,14 +56271,14 @@ function MPostFavorite(value) {
|
|
|
56009
56271
|
}
|
|
56010
56272
|
if (value._id && typeof value._id === "string") {
|
|
56011
56273
|
try {
|
|
56012
|
-
value._id = new
|
|
56274
|
+
value._id = new import_mongodb134.ObjectId(value._id);
|
|
56013
56275
|
} catch {
|
|
56014
56276
|
throw new Error("Invalid ID.");
|
|
56015
56277
|
}
|
|
56016
56278
|
}
|
|
56017
56279
|
if (value.postId && typeof value.postId === "string") {
|
|
56018
56280
|
try {
|
|
56019
|
-
value.postId = new
|
|
56281
|
+
value.postId = new import_mongodb134.ObjectId(value.postId);
|
|
56020
56282
|
} catch {
|
|
56021
56283
|
throw new Error("Invalid post ID.");
|
|
56022
56284
|
}
|
|
@@ -56025,7 +56287,7 @@ function MPostFavorite(value) {
|
|
|
56025
56287
|
value.userIds = value.userIds.map((id) => {
|
|
56026
56288
|
if (typeof id === "string") {
|
|
56027
56289
|
try {
|
|
56028
|
-
return new
|
|
56290
|
+
return new import_mongodb134.ObjectId(id);
|
|
56029
56291
|
} catch {
|
|
56030
56292
|
throw new Error("Invalid user ID.");
|
|
56031
56293
|
}
|
|
@@ -56034,7 +56296,7 @@ function MPostFavorite(value) {
|
|
|
56034
56296
|
});
|
|
56035
56297
|
}
|
|
56036
56298
|
return {
|
|
56037
|
-
_id: value._id ?? new
|
|
56299
|
+
_id: value._id ?? new import_mongodb134.ObjectId(),
|
|
56038
56300
|
postId: value.postId ?? "",
|
|
56039
56301
|
userIds: value.userIds ?? [],
|
|
56040
56302
|
createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -56044,7 +56306,7 @@ function MPostFavorite(value) {
|
|
|
56044
56306
|
|
|
56045
56307
|
// src/repositories/post-favorite.repo.ts
|
|
56046
56308
|
var import_node_server_utils237 = require("@7365admin1/node-server-utils");
|
|
56047
|
-
var
|
|
56309
|
+
var import_mongodb135 = require("mongodb");
|
|
56048
56310
|
function usePostFavoriteRepo() {
|
|
56049
56311
|
const db = import_node_server_utils237.useAtlas.getDb();
|
|
56050
56312
|
if (!db) {
|
|
@@ -56066,7 +56328,7 @@ function usePostFavoriteRepo() {
|
|
|
56066
56328
|
}
|
|
56067
56329
|
async function getById(_id) {
|
|
56068
56330
|
try {
|
|
56069
|
-
_id = new
|
|
56331
|
+
_id = new import_mongodb135.ObjectId(_id);
|
|
56070
56332
|
} catch {
|
|
56071
56333
|
throw new import_node_server_utils237.BadRequestError("Invalid favorite ID format.");
|
|
56072
56334
|
}
|
|
@@ -56075,15 +56337,26 @@ function usePostFavoriteRepo() {
|
|
|
56075
56337
|
throw new import_node_server_utils237.NotFoundError("Favorite not found.");
|
|
56076
56338
|
return result;
|
|
56077
56339
|
}
|
|
56340
|
+
async function getByPostId(postId) {
|
|
56341
|
+
try {
|
|
56342
|
+
postId = new import_mongodb135.ObjectId(postId);
|
|
56343
|
+
} catch {
|
|
56344
|
+
throw new import_node_server_utils237.BadRequestError("Invalid post ID format.");
|
|
56345
|
+
}
|
|
56346
|
+
const result = await collection.findOne({ postId });
|
|
56347
|
+
if (!result)
|
|
56348
|
+
throw new import_node_server_utils237.NotFoundError("Favorite not found.");
|
|
56349
|
+
return result;
|
|
56350
|
+
}
|
|
56078
56351
|
async function updateById(_id, userId, session) {
|
|
56079
56352
|
try {
|
|
56080
|
-
_id = new
|
|
56353
|
+
_id = new import_mongodb135.ObjectId(_id);
|
|
56081
56354
|
} catch {
|
|
56082
56355
|
throw new import_node_server_utils237.BadRequestError("Invalid favorite ID format.");
|
|
56083
56356
|
}
|
|
56084
56357
|
let userObjectId;
|
|
56085
56358
|
try {
|
|
56086
|
-
userObjectId = new
|
|
56359
|
+
userObjectId = new import_mongodb135.ObjectId(userId);
|
|
56087
56360
|
} catch {
|
|
56088
56361
|
throw new import_node_server_utils237.BadRequestError("Invalid user ID format.");
|
|
56089
56362
|
}
|
|
@@ -56100,6 +56373,7 @@ function usePostFavoriteRepo() {
|
|
|
56100
56373
|
return {
|
|
56101
56374
|
addFavorite,
|
|
56102
56375
|
getById,
|
|
56376
|
+
getByPostId,
|
|
56103
56377
|
updateById
|
|
56104
56378
|
};
|
|
56105
56379
|
}
|
|
@@ -56147,7 +56421,7 @@ var import_node_server_utils239 = require("@7365admin1/node-server-utils");
|
|
|
56147
56421
|
var import_joi136 = __toESM(require("joi"));
|
|
56148
56422
|
function usePostFavoriteController() {
|
|
56149
56423
|
const { addFavorite: _addFavorite, toggleFavorite: _toggleFavorite } = usePostFavoriteService();
|
|
56150
|
-
const { getById: _getById } = usePostFavoriteRepo();
|
|
56424
|
+
const { getById: _getById, getByPostId: _getByPostId } = usePostFavoriteRepo();
|
|
56151
56425
|
async function addFavorite(req, res, next) {
|
|
56152
56426
|
const { error, value } = schemaPostFavorite.validate(req.body, {
|
|
56153
56427
|
abortEarly: false
|
|
@@ -56188,6 +56462,26 @@ function usePostFavoriteController() {
|
|
|
56188
56462
|
return;
|
|
56189
56463
|
}
|
|
56190
56464
|
}
|
|
56465
|
+
async function getByPostId(req, res, next) {
|
|
56466
|
+
const schema2 = import_joi136.default.object({
|
|
56467
|
+
postId: import_joi136.default.string().hex().length(24).required()
|
|
56468
|
+
});
|
|
56469
|
+
const { error, value } = schema2.validate({ postId: req.params.postId });
|
|
56470
|
+
if (error) {
|
|
56471
|
+
import_node_server_utils239.logger.log({ level: "error", message: error.message });
|
|
56472
|
+
next(new import_node_server_utils239.BadRequestError(error.message));
|
|
56473
|
+
return;
|
|
56474
|
+
}
|
|
56475
|
+
try {
|
|
56476
|
+
const data = await _getByPostId(value.postId);
|
|
56477
|
+
res.status(200).json(data);
|
|
56478
|
+
return;
|
|
56479
|
+
} catch (error2) {
|
|
56480
|
+
import_node_server_utils239.logger.log({ level: "error", message: error2.message });
|
|
56481
|
+
next(error2);
|
|
56482
|
+
return;
|
|
56483
|
+
}
|
|
56484
|
+
}
|
|
56191
56485
|
async function updateById(req, res, next) {
|
|
56192
56486
|
const paramsSchema = import_joi136.default.object({
|
|
56193
56487
|
_id: import_joi136.default.string().hex().length(24).required()
|
|
@@ -56217,13 +56511,14 @@ function usePostFavoriteController() {
|
|
|
56217
56511
|
return {
|
|
56218
56512
|
addFavorite,
|
|
56219
56513
|
getById,
|
|
56514
|
+
getByPostId,
|
|
56220
56515
|
updateById
|
|
56221
56516
|
};
|
|
56222
56517
|
}
|
|
56223
56518
|
|
|
56224
56519
|
// src/models/category-preloved.model.ts
|
|
56225
56520
|
var import_joi137 = __toESM(require("joi"));
|
|
56226
|
-
var
|
|
56521
|
+
var import_mongodb136 = require("mongodb");
|
|
56227
56522
|
var schemaCategoryPreloved = import_joi137.default.object({
|
|
56228
56523
|
name: import_joi137.default.string().required(),
|
|
56229
56524
|
createdBy: import_joi137.default.string().hex().optional().allow("", null),
|
|
@@ -56240,14 +56535,14 @@ function MCategoryPreloved(value) {
|
|
|
56240
56535
|
}
|
|
56241
56536
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
56242
56537
|
try {
|
|
56243
|
-
value.createdBy = new
|
|
56538
|
+
value.createdBy = new import_mongodb136.ObjectId(value.createdBy);
|
|
56244
56539
|
} catch {
|
|
56245
56540
|
throw new Error("Invalid createdBy ID.");
|
|
56246
56541
|
}
|
|
56247
56542
|
}
|
|
56248
56543
|
if (value.site && typeof value.site === "string") {
|
|
56249
56544
|
try {
|
|
56250
|
-
value.site = new
|
|
56545
|
+
value.site = new import_mongodb136.ObjectId(value.site);
|
|
56251
56546
|
} catch {
|
|
56252
56547
|
throw new Error("Invalid site ID.");
|
|
56253
56548
|
}
|
|
@@ -56263,7 +56558,7 @@ function MCategoryPreloved(value) {
|
|
|
56263
56558
|
|
|
56264
56559
|
// src/repositories/category-preloved.repo.ts
|
|
56265
56560
|
var import_node_server_utils240 = require("@7365admin1/node-server-utils");
|
|
56266
|
-
var
|
|
56561
|
+
var import_mongodb137 = require("mongodb");
|
|
56267
56562
|
function useCategoryPrelovedRepo() {
|
|
56268
56563
|
const db = import_node_server_utils240.useAtlas.getDb();
|
|
56269
56564
|
if (!db) {
|
|
@@ -56277,7 +56572,7 @@ function useCategoryPrelovedRepo() {
|
|
|
56277
56572
|
} = {}) {
|
|
56278
56573
|
if (site) {
|
|
56279
56574
|
try {
|
|
56280
|
-
site = new
|
|
56575
|
+
site = new import_mongodb137.ObjectId(site);
|
|
56281
56576
|
} catch {
|
|
56282
56577
|
throw new import_node_server_utils240.BadRequestError("Invalid site ID format.");
|
|
56283
56578
|
}
|
|
@@ -56296,7 +56591,7 @@ function useCategoryPrelovedRepo() {
|
|
|
56296
56591
|
async function getById(_id) {
|
|
56297
56592
|
let objectId2;
|
|
56298
56593
|
try {
|
|
56299
|
-
objectId2 = new
|
|
56594
|
+
objectId2 = new import_mongodb137.ObjectId(_id);
|
|
56300
56595
|
} catch {
|
|
56301
56596
|
throw new import_node_server_utils240.BadRequestError("Invalid category-preloved ID format.");
|
|
56302
56597
|
}
|
|
@@ -56396,7 +56691,7 @@ function useCategoryPrelovedController() {
|
|
|
56396
56691
|
|
|
56397
56692
|
// src/models/subcategory-preloved.model.ts
|
|
56398
56693
|
var import_joi139 = __toESM(require("joi"));
|
|
56399
|
-
var
|
|
56694
|
+
var import_mongodb138 = require("mongodb");
|
|
56400
56695
|
var schemaSubcategoryPreloved = import_joi139.default.object({
|
|
56401
56696
|
name: import_joi139.default.string().required(),
|
|
56402
56697
|
createdBy: import_joi139.default.string().hex().optional().allow("", null),
|
|
@@ -56415,21 +56710,21 @@ function MSubcategoryPreloved(value) {
|
|
|
56415
56710
|
}
|
|
56416
56711
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
56417
56712
|
try {
|
|
56418
|
-
value.createdBy = new
|
|
56713
|
+
value.createdBy = new import_mongodb138.ObjectId(value.createdBy);
|
|
56419
56714
|
} catch {
|
|
56420
56715
|
throw new Error("Invalid createdBy ID.");
|
|
56421
56716
|
}
|
|
56422
56717
|
}
|
|
56423
56718
|
if (value.site && typeof value.site === "string") {
|
|
56424
56719
|
try {
|
|
56425
|
-
value.site = new
|
|
56720
|
+
value.site = new import_mongodb138.ObjectId(value.site);
|
|
56426
56721
|
} catch {
|
|
56427
56722
|
throw new Error("Invalid site ID.");
|
|
56428
56723
|
}
|
|
56429
56724
|
}
|
|
56430
56725
|
if (value.category_id && typeof value.category_id === "string") {
|
|
56431
56726
|
try {
|
|
56432
|
-
value.category_id = new
|
|
56727
|
+
value.category_id = new import_mongodb138.ObjectId(value.category_id);
|
|
56433
56728
|
} catch {
|
|
56434
56729
|
throw new Error("Invalid category ID.");
|
|
56435
56730
|
}
|
|
@@ -56446,7 +56741,7 @@ function MSubcategoryPreloved(value) {
|
|
|
56446
56741
|
|
|
56447
56742
|
// src/repositories/subcategory-preloved.repo.ts
|
|
56448
56743
|
var import_node_server_utils242 = require("@7365admin1/node-server-utils");
|
|
56449
|
-
var
|
|
56744
|
+
var import_mongodb139 = require("mongodb");
|
|
56450
56745
|
function useSubcategoryPrelovedRepo() {
|
|
56451
56746
|
const db = import_node_server_utils242.useAtlas.getDb();
|
|
56452
56747
|
if (!db) {
|
|
@@ -56461,14 +56756,14 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56461
56756
|
} = {}) {
|
|
56462
56757
|
if (site) {
|
|
56463
56758
|
try {
|
|
56464
|
-
site = new
|
|
56759
|
+
site = new import_mongodb139.ObjectId(site);
|
|
56465
56760
|
} catch {
|
|
56466
56761
|
throw new import_node_server_utils242.BadRequestError("Invalid site ID format.");
|
|
56467
56762
|
}
|
|
56468
56763
|
}
|
|
56469
56764
|
if (category_id) {
|
|
56470
56765
|
try {
|
|
56471
|
-
category_id = new
|
|
56766
|
+
category_id = new import_mongodb139.ObjectId(category_id);
|
|
56472
56767
|
} catch {
|
|
56473
56768
|
throw new import_node_server_utils242.BadRequestError("Invalid category ID format.");
|
|
56474
56769
|
}
|
|
@@ -56487,7 +56782,7 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56487
56782
|
async function getById(_id) {
|
|
56488
56783
|
let objectId2;
|
|
56489
56784
|
try {
|
|
56490
|
-
objectId2 = new
|
|
56785
|
+
objectId2 = new import_mongodb139.ObjectId(_id);
|
|
56491
56786
|
} catch {
|
|
56492
56787
|
throw new import_node_server_utils242.BadRequestError("Invalid subcategory-preloved ID format.");
|
|
56493
56788
|
}
|
|
@@ -56501,14 +56796,75 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56501
56796
|
throw error;
|
|
56502
56797
|
}
|
|
56503
56798
|
}
|
|
56504
|
-
|
|
56799
|
+
async function addSubcategory(item, session) {
|
|
56800
|
+
const doc = MSubcategoryPreloved(item);
|
|
56801
|
+
try {
|
|
56802
|
+
const res = await collection.insertOne(doc, { session });
|
|
56803
|
+
return res.insertedId;
|
|
56804
|
+
} catch (error) {
|
|
56805
|
+
const isDuplicated = error.message?.includes("duplicate");
|
|
56806
|
+
if (isDuplicated)
|
|
56807
|
+
throw new import_node_server_utils242.BadRequestError("Subcategory already exists.");
|
|
56808
|
+
throw error;
|
|
56809
|
+
}
|
|
56810
|
+
}
|
|
56811
|
+
async function updateById(_id, value, session) {
|
|
56812
|
+
let objectId2;
|
|
56813
|
+
try {
|
|
56814
|
+
objectId2 = new import_mongodb139.ObjectId(_id);
|
|
56815
|
+
} catch {
|
|
56816
|
+
throw new import_node_server_utils242.BadRequestError("Invalid subcategory ID format.");
|
|
56817
|
+
}
|
|
56818
|
+
if (value.category_id && typeof value.category_id === "string") {
|
|
56819
|
+
try {
|
|
56820
|
+
value.category_id = new import_mongodb139.ObjectId(value.category_id);
|
|
56821
|
+
} catch {
|
|
56822
|
+
throw new import_node_server_utils242.BadRequestError("Invalid category ID format.");
|
|
56823
|
+
}
|
|
56824
|
+
}
|
|
56825
|
+
if (value.site && typeof value.site === "string") {
|
|
56826
|
+
try {
|
|
56827
|
+
value.site = new import_mongodb139.ObjectId(value.site);
|
|
56828
|
+
} catch {
|
|
56829
|
+
throw new import_node_server_utils242.BadRequestError("Invalid site ID format.");
|
|
56830
|
+
}
|
|
56831
|
+
}
|
|
56832
|
+
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
56833
|
+
const res = await collection.updateOne(
|
|
56834
|
+
{ _id: objectId2 },
|
|
56835
|
+
{ $set: value },
|
|
56836
|
+
{ session }
|
|
56837
|
+
);
|
|
56838
|
+
if (res.modifiedCount === 0)
|
|
56839
|
+
throw new import_node_server_utils242.InternalServerError("Unable to update subcategory.");
|
|
56840
|
+
return res;
|
|
56841
|
+
}
|
|
56842
|
+
async function deleteById(_id, session) {
|
|
56843
|
+
let objectId2;
|
|
56844
|
+
try {
|
|
56845
|
+
objectId2 = new import_mongodb139.ObjectId(_id);
|
|
56846
|
+
} catch {
|
|
56847
|
+
throw new import_node_server_utils242.BadRequestError("Invalid subcategory ID format.");
|
|
56848
|
+
}
|
|
56849
|
+
const res = await collection.deleteOne({ _id: objectId2 }, { session });
|
|
56850
|
+
if (res.deletedCount === 0)
|
|
56851
|
+
throw new import_node_server_utils242.InternalServerError("Unable to delete subcategory.");
|
|
56852
|
+
return res.deletedCount;
|
|
56853
|
+
}
|
|
56854
|
+
return { getAll, getById, addSubcategory, updateById, deleteById };
|
|
56505
56855
|
}
|
|
56506
56856
|
|
|
56507
56857
|
// src/controllers/subcategory-preloved.controller.ts
|
|
56508
56858
|
var import_node_server_utils243 = require("@7365admin1/node-server-utils");
|
|
56509
56859
|
var import_joi140 = __toESM(require("joi"));
|
|
56510
56860
|
function useSubcategoryPrelovedController() {
|
|
56511
|
-
const {
|
|
56861
|
+
const {
|
|
56862
|
+
getAll: _getAll,
|
|
56863
|
+
getById: _getById,
|
|
56864
|
+
addSubcategory: _addSubcategory,
|
|
56865
|
+
updateById: _updateById,
|
|
56866
|
+
deleteById: _deleteById
|
|
56867
|
+
} = useSubcategoryPrelovedRepo();
|
|
56512
56868
|
async function getAll(req, res, next) {
|
|
56513
56869
|
const schema2 = import_joi140.default.object({
|
|
56514
56870
|
search: import_joi140.default.string().optional().allow("", null),
|
|
@@ -56552,12 +56908,73 @@ function useSubcategoryPrelovedController() {
|
|
|
56552
56908
|
return;
|
|
56553
56909
|
}
|
|
56554
56910
|
}
|
|
56555
|
-
|
|
56911
|
+
async function addSubcategory(req, res, next) {
|
|
56912
|
+
const { error, value } = schemaSubcategoryPreloved.validate(req.body, {
|
|
56913
|
+
abortEarly: false
|
|
56914
|
+
});
|
|
56915
|
+
if (error) {
|
|
56916
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
56917
|
+
import_node_server_utils243.logger.log({ level: "error", message: messages });
|
|
56918
|
+
next(new import_node_server_utils243.BadRequestError(messages));
|
|
56919
|
+
return;
|
|
56920
|
+
}
|
|
56921
|
+
try {
|
|
56922
|
+
const data = await _addSubcategory(value);
|
|
56923
|
+
res.status(201).json(data);
|
|
56924
|
+
} catch (error2) {
|
|
56925
|
+
import_node_server_utils243.logger.log({ level: "error", message: error2.message });
|
|
56926
|
+
next(error2);
|
|
56927
|
+
}
|
|
56928
|
+
}
|
|
56929
|
+
async function updateById(req, res, next) {
|
|
56930
|
+
const paramsSchema = import_joi140.default.object({
|
|
56931
|
+
_id: import_joi140.default.string().hex().length(24).required()
|
|
56932
|
+
});
|
|
56933
|
+
const { error: paramsError, value: paramsValue } = paramsSchema.validate({
|
|
56934
|
+
_id: req.params.id
|
|
56935
|
+
});
|
|
56936
|
+
if (paramsError) {
|
|
56937
|
+
next(new import_node_server_utils243.BadRequestError(paramsError.message));
|
|
56938
|
+
return;
|
|
56939
|
+
}
|
|
56940
|
+
const { error: bodyError, value: bodyValue } = schemaUpdateSubcategoryPreloved.validate(req.body, { abortEarly: false });
|
|
56941
|
+
if (bodyError) {
|
|
56942
|
+
const messages = bodyError.details.map((d) => d.message).join(", ");
|
|
56943
|
+
import_node_server_utils243.logger.log({ level: "error", message: messages });
|
|
56944
|
+
next(new import_node_server_utils243.BadRequestError(messages));
|
|
56945
|
+
return;
|
|
56946
|
+
}
|
|
56947
|
+
try {
|
|
56948
|
+
const data = await _updateById(paramsValue._id, bodyValue);
|
|
56949
|
+
res.status(200).json(data);
|
|
56950
|
+
} catch (error) {
|
|
56951
|
+
import_node_server_utils243.logger.log({ level: "error", message: error.message });
|
|
56952
|
+
next(error);
|
|
56953
|
+
}
|
|
56954
|
+
}
|
|
56955
|
+
async function deleteById(req, res, next) {
|
|
56956
|
+
const schema2 = import_joi140.default.object({
|
|
56957
|
+
_id: import_joi140.default.string().hex().length(24).required()
|
|
56958
|
+
});
|
|
56959
|
+
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
56960
|
+
if (error) {
|
|
56961
|
+
next(new import_node_server_utils243.BadRequestError(error.message));
|
|
56962
|
+
return;
|
|
56963
|
+
}
|
|
56964
|
+
try {
|
|
56965
|
+
const data = await _deleteById(value._id);
|
|
56966
|
+
res.status(200).json(data);
|
|
56967
|
+
} catch (error2) {
|
|
56968
|
+
import_node_server_utils243.logger.log({ level: "error", message: error2.message });
|
|
56969
|
+
next(error2);
|
|
56970
|
+
}
|
|
56971
|
+
}
|
|
56972
|
+
return { getAll, getById, addSubcategory, updateById, deleteById };
|
|
56556
56973
|
}
|
|
56557
56974
|
|
|
56558
56975
|
// src/models/online-forms-v2.model.ts
|
|
56559
56976
|
var import_joi141 = __toESM(require("joi"));
|
|
56560
|
-
var
|
|
56977
|
+
var import_mongodb140 = require("mongodb");
|
|
56561
56978
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
56562
56979
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
56563
56980
|
FormEntryStatus2["INACTIVE"] = "inactive";
|
|
@@ -56612,21 +57029,21 @@ function MFormEntry(value) {
|
|
|
56612
57029
|
}
|
|
56613
57030
|
if (value._id && typeof value._id === "string") {
|
|
56614
57031
|
try {
|
|
56615
|
-
value._id = new
|
|
57032
|
+
value._id = new import_mongodb140.ObjectId(value._id);
|
|
56616
57033
|
} catch {
|
|
56617
57034
|
throw new Error("Invalid ID.");
|
|
56618
57035
|
}
|
|
56619
57036
|
}
|
|
56620
57037
|
if (value.org && typeof value.org === "string") {
|
|
56621
57038
|
try {
|
|
56622
|
-
value.org = new
|
|
57039
|
+
value.org = new import_mongodb140.ObjectId(value.org);
|
|
56623
57040
|
} catch {
|
|
56624
57041
|
throw new Error("Invalid org ID.");
|
|
56625
57042
|
}
|
|
56626
57043
|
}
|
|
56627
57044
|
if (value.site && typeof value.site === "string") {
|
|
56628
57045
|
try {
|
|
56629
|
-
value.site = new
|
|
57046
|
+
value.site = new import_mongodb140.ObjectId(value.site);
|
|
56630
57047
|
} catch {
|
|
56631
57048
|
throw new Error("Invalid site ID.");
|
|
56632
57049
|
}
|
|
@@ -56646,6 +57063,7 @@ function MFormEntry(value) {
|
|
|
56646
57063
|
|
|
56647
57064
|
// src/repositories/online-forms-v2.repository.ts
|
|
56648
57065
|
var import_node_server_utils244 = require("@7365admin1/node-server-utils");
|
|
57066
|
+
var import_mongodb141 = require("mongodb");
|
|
56649
57067
|
var online_forms_namespace_collection = "online-forms";
|
|
56650
57068
|
function useFormEntryRepo() {
|
|
56651
57069
|
const db = import_node_server_utils244.useAtlas.getDb();
|
|
@@ -56690,18 +57108,105 @@ function useFormEntryRepo() {
|
|
|
56690
57108
|
throw error;
|
|
56691
57109
|
}
|
|
56692
57110
|
}
|
|
57111
|
+
async function getAll({
|
|
57112
|
+
search = "",
|
|
57113
|
+
page = 1,
|
|
57114
|
+
limit = 10,
|
|
57115
|
+
sort = {},
|
|
57116
|
+
status = "active",
|
|
57117
|
+
org = "",
|
|
57118
|
+
site = ""
|
|
57119
|
+
}) {
|
|
57120
|
+
page = page > 0 ? page - 1 : 0;
|
|
57121
|
+
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
57122
|
+
const cacheOptions = {
|
|
57123
|
+
page,
|
|
57124
|
+
limit,
|
|
57125
|
+
status,
|
|
57126
|
+
sort: JSON.stringify(sort),
|
|
57127
|
+
...site && { site },
|
|
57128
|
+
...search && { search }
|
|
57129
|
+
};
|
|
57130
|
+
const query = {
|
|
57131
|
+
...status ? { $and: [{ status }, { status: { $ne: "deleted" } }] } : { status: { $ne: "deleted" } },
|
|
57132
|
+
...site && { site: new import_mongodb141.ObjectId(site) },
|
|
57133
|
+
...search && { search: [{ name: { $regex: search, $options: "i" } }] }
|
|
57134
|
+
};
|
|
57135
|
+
const cacheKey = (0, import_node_server_utils244.makeCacheKey)(
|
|
57136
|
+
online_forms_namespace_collection,
|
|
57137
|
+
cacheOptions
|
|
57138
|
+
);
|
|
57139
|
+
const cachedData = await getCache(cacheKey);
|
|
57140
|
+
if (cachedData) {
|
|
57141
|
+
import_node_server_utils244.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
57142
|
+
return cachedData;
|
|
57143
|
+
}
|
|
57144
|
+
try {
|
|
57145
|
+
const items = await collection.aggregate([
|
|
57146
|
+
{ $match: query },
|
|
57147
|
+
{ $sort: sort },
|
|
57148
|
+
{ $skip: page * limit },
|
|
57149
|
+
{ $limit: limit }
|
|
57150
|
+
]).toArray();
|
|
57151
|
+
const length = await collection.countDocuments(query);
|
|
57152
|
+
const data = (0, import_node_server_utils244.paginate)(items, page, limit, length);
|
|
57153
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
57154
|
+
import_node_server_utils244.logger.info(`Cache set for key: ${cacheKey}`);
|
|
57155
|
+
}).catch((err) => {
|
|
57156
|
+
import_node_server_utils244.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
57157
|
+
});
|
|
57158
|
+
return data;
|
|
57159
|
+
} catch (error) {
|
|
57160
|
+
throw error;
|
|
57161
|
+
}
|
|
57162
|
+
}
|
|
57163
|
+
async function getFormEntryById(_id) {
|
|
57164
|
+
const cacheKey = (0, import_node_server_utils244.makeCacheKey)(online_forms_namespace_collection, { _id });
|
|
57165
|
+
const cachedData = await getCache(cacheKey);
|
|
57166
|
+
if (cachedData) {
|
|
57167
|
+
import_node_server_utils244.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
57168
|
+
return cachedData;
|
|
57169
|
+
}
|
|
57170
|
+
try {
|
|
57171
|
+
_id = new import_mongodb141.ObjectId(_id);
|
|
57172
|
+
} catch (error) {
|
|
57173
|
+
throw new import_node_server_utils244.BadRequestError("Invalid online form ID format.");
|
|
57174
|
+
}
|
|
57175
|
+
const query = { _id, status: { $ne: "deleted" } };
|
|
57176
|
+
try {
|
|
57177
|
+
const [data] = await collection.aggregate([{ $match: query }]).toArray();
|
|
57178
|
+
if (!data) {
|
|
57179
|
+
throw new import_node_server_utils244.NotFoundError("Document not found.");
|
|
57180
|
+
}
|
|
57181
|
+
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
57182
|
+
import_node_server_utils244.logger.info(`Cache set for key: ${cacheKey}`);
|
|
57183
|
+
}).catch((err) => {
|
|
57184
|
+
import_node_server_utils244.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
57185
|
+
});
|
|
57186
|
+
return data;
|
|
57187
|
+
} catch (error) {
|
|
57188
|
+
throw error;
|
|
57189
|
+
}
|
|
57190
|
+
}
|
|
56693
57191
|
return {
|
|
56694
57192
|
add,
|
|
57193
|
+
getAll,
|
|
57194
|
+
getFormEntryById,
|
|
56695
57195
|
createTextIndex
|
|
56696
57196
|
};
|
|
56697
57197
|
}
|
|
56698
57198
|
|
|
56699
57199
|
// src/controllers/online-forms-v2.controller.ts
|
|
56700
57200
|
var import_node_server_utils245 = require("@7365admin1/node-server-utils");
|
|
57201
|
+
var import_joi142 = __toESM(require("joi"));
|
|
56701
57202
|
var import_exceljs3 = __toESM(require("exceljs"));
|
|
56702
57203
|
var import_fs6 = __toESM(require("fs"));
|
|
56703
57204
|
function useFormEntryController() {
|
|
56704
|
-
const {
|
|
57205
|
+
const {
|
|
57206
|
+
add: _add,
|
|
57207
|
+
getAll: _getAll,
|
|
57208
|
+
getFormEntryById: _getFormEntryById
|
|
57209
|
+
} = useFormEntryRepo();
|
|
56705
57210
|
function toCamelCase(str) {
|
|
56706
57211
|
return str.replace(/\s(.)/g, (_, char) => char.toUpperCase()).replace(/\s+/g, "").replace(/^(.)/, (_, char) => char.toLowerCase());
|
|
56707
57212
|
}
|
|
@@ -56763,8 +57268,59 @@ function useFormEntryController() {
|
|
|
56763
57268
|
next(error);
|
|
56764
57269
|
}
|
|
56765
57270
|
}
|
|
57271
|
+
async function getAll(req, res, next) {
|
|
57272
|
+
try {
|
|
57273
|
+
const schema2 = import_joi142.default.object({
|
|
57274
|
+
search: import_joi142.default.string().optional().allow("", null),
|
|
57275
|
+
page: import_joi142.default.number().integer().min(1).allow("", null).default(1),
|
|
57276
|
+
limit: import_joi142.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
57277
|
+
status: import_joi142.default.string().optional().allow(null, ""),
|
|
57278
|
+
org: import_joi142.default.string().hex().optional().allow("", null),
|
|
57279
|
+
site: import_joi142.default.string().hex().optional().allow("", null)
|
|
57280
|
+
});
|
|
57281
|
+
const { error, value } = schema2.validate(req.query);
|
|
57282
|
+
if (error) {
|
|
57283
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
57284
|
+
import_node_server_utils245.logger.log({ level: "error", message: messages });
|
|
57285
|
+
next(new import_node_server_utils245.BadRequestError(messages));
|
|
57286
|
+
return;
|
|
57287
|
+
}
|
|
57288
|
+
const { search, page, limit, status, org, site } = value;
|
|
57289
|
+
const data = await _getAll({ search, page, limit, status, org, site });
|
|
57290
|
+
res.json(data);
|
|
57291
|
+
return;
|
|
57292
|
+
} catch (error) {
|
|
57293
|
+
import_node_server_utils245.logger.log({ level: "error", message: error.message });
|
|
57294
|
+
next(error);
|
|
57295
|
+
return;
|
|
57296
|
+
}
|
|
57297
|
+
}
|
|
57298
|
+
async function getFormEntryById(req, res, next) {
|
|
57299
|
+
try {
|
|
57300
|
+
const schema2 = import_joi142.default.object({
|
|
57301
|
+
_id: import_joi142.default.string().hex().length(24).required()
|
|
57302
|
+
});
|
|
57303
|
+
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
57304
|
+
if (error) {
|
|
57305
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
57306
|
+
import_node_server_utils245.logger.log({ level: "error", message: messages });
|
|
57307
|
+
next(new import_node_server_utils245.BadRequestError(messages));
|
|
57308
|
+
return;
|
|
57309
|
+
}
|
|
57310
|
+
const { _id } = value;
|
|
57311
|
+
const data = await _getFormEntryById(_id);
|
|
57312
|
+
res.json(data);
|
|
57313
|
+
return;
|
|
57314
|
+
} catch (error) {
|
|
57315
|
+
import_node_server_utils245.logger.log({ level: "error", message: error.message });
|
|
57316
|
+
next(error);
|
|
57317
|
+
return;
|
|
57318
|
+
}
|
|
57319
|
+
}
|
|
56766
57320
|
return {
|
|
56767
|
-
uploadFormEntrys
|
|
57321
|
+
uploadFormEntrys,
|
|
57322
|
+
getAll,
|
|
57323
|
+
getFormEntryById
|
|
56768
57324
|
};
|
|
56769
57325
|
}
|
|
56770
57326
|
|
|
@@ -56808,7 +57364,7 @@ function useBuildingLevelService() {
|
|
|
56808
57364
|
|
|
56809
57365
|
// src/controllers/building-level.controller.ts
|
|
56810
57366
|
var import_node_server_utils247 = require("@7365admin1/node-server-utils");
|
|
56811
|
-
var
|
|
57367
|
+
var import_joi143 = __toESM(require("joi"));
|
|
56812
57368
|
function useBuildingLevelController() {
|
|
56813
57369
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
|
|
56814
57370
|
const {
|
|
@@ -56835,12 +57391,12 @@ function useBuildingLevelController() {
|
|
|
56835
57391
|
}
|
|
56836
57392
|
async function getAll(req, res, next) {
|
|
56837
57393
|
try {
|
|
56838
|
-
const validation =
|
|
56839
|
-
page:
|
|
56840
|
-
limit:
|
|
56841
|
-
search:
|
|
56842
|
-
site:
|
|
56843
|
-
status:
|
|
57394
|
+
const validation = import_joi143.default.object({
|
|
57395
|
+
page: import_joi143.default.number().min(1).optional().default(1),
|
|
57396
|
+
limit: import_joi143.default.number().min(1).optional().default(20),
|
|
57397
|
+
search: import_joi143.default.string().optional().allow("", null),
|
|
57398
|
+
site: import_joi143.default.string().hex().length(24).optional().allow("", null),
|
|
57399
|
+
status: import_joi143.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
|
|
56844
57400
|
});
|
|
56845
57401
|
const { error, value } = validation.validate(req.query, {
|
|
56846
57402
|
abortEarly: false
|
|
@@ -56867,8 +57423,8 @@ function useBuildingLevelController() {
|
|
|
56867
57423
|
}
|
|
56868
57424
|
async function getById(req, res, next) {
|
|
56869
57425
|
try {
|
|
56870
|
-
const schema2 =
|
|
56871
|
-
id:
|
|
57426
|
+
const schema2 = import_joi143.default.object({
|
|
57427
|
+
id: import_joi143.default.string().hex().length(24).required()
|
|
56872
57428
|
});
|
|
56873
57429
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
56874
57430
|
if (error) {
|
|
@@ -56906,8 +57462,8 @@ function useBuildingLevelController() {
|
|
|
56906
57462
|
}
|
|
56907
57463
|
async function deleteById(req, res, next) {
|
|
56908
57464
|
try {
|
|
56909
|
-
const schema2 =
|
|
56910
|
-
id:
|
|
57465
|
+
const schema2 = import_joi143.default.object({
|
|
57466
|
+
id: import_joi143.default.string().hex().required()
|
|
56911
57467
|
});
|
|
56912
57468
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
56913
57469
|
if (error) {
|