@7365admin1/core 2.75.0 → 2.76.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +575 -486
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +575 -486
- package/dist/index.mjs.map +1 -1
- package/dist/public/handlebars/registration-pending.hbs +131 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2725,6 +2725,20 @@ function useUserRepo() {
|
|
|
2725
2725
|
throw new InternalServerError5("Failed to update user.");
|
|
2726
2726
|
}
|
|
2727
2727
|
}
|
|
2728
|
+
async function updateUserOrgById(id, org, session) {
|
|
2729
|
+
const _id = toObjectId(id);
|
|
2730
|
+
const orgId = toObjectId(org);
|
|
2731
|
+
try {
|
|
2732
|
+
await collection.updateOne(
|
|
2733
|
+
{ _id },
|
|
2734
|
+
{ $set: { defaultOrg: orgId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
2735
|
+
{ session }
|
|
2736
|
+
);
|
|
2737
|
+
return "Successfully updated user organization.";
|
|
2738
|
+
} catch (error) {
|
|
2739
|
+
throw new InternalServerError5("Failed to update user organization.");
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2728
2742
|
return {
|
|
2729
2743
|
createIndex,
|
|
2730
2744
|
createTextIndex,
|
|
@@ -2742,7 +2756,8 @@ function useUserRepo() {
|
|
|
2742
2756
|
updateDefaultOrgByEmail,
|
|
2743
2757
|
getUserByEmailStatus,
|
|
2744
2758
|
updateUserSIDById,
|
|
2745
|
-
resetPassword
|
|
2759
|
+
resetPassword,
|
|
2760
|
+
updateUserOrgById
|
|
2746
2761
|
};
|
|
2747
2762
|
}
|
|
2748
2763
|
|
|
@@ -7533,7 +7548,8 @@ function useUserController() {
|
|
|
7533
7548
|
"dateOfBirth",
|
|
7534
7549
|
"profile",
|
|
7535
7550
|
"gender",
|
|
7536
|
-
"defaultOrg"
|
|
7551
|
+
"defaultOrg",
|
|
7552
|
+
"status"
|
|
7537
7553
|
).required(),
|
|
7538
7554
|
value: Joi13.when("field", {
|
|
7539
7555
|
switch: [
|
|
@@ -27330,6 +27346,7 @@ import {
|
|
|
27330
27346
|
compileHandlebar as compileHandlebar3,
|
|
27331
27347
|
getDirectory as getDirectory3
|
|
27332
27348
|
} from "@7365admin1/node-server-utils";
|
|
27349
|
+
import { ObjectId as ObjectId64 } from "mongodb";
|
|
27333
27350
|
function usePersonService() {
|
|
27334
27351
|
const MailerConfig = {
|
|
27335
27352
|
host: MAILER_TRANSPORT_HOST,
|
|
@@ -27351,7 +27368,8 @@ function usePersonService() {
|
|
|
27351
27368
|
createUser: addUser,
|
|
27352
27369
|
getUserByEmail,
|
|
27353
27370
|
updateUserFieldById: _updateUserFieldById,
|
|
27354
|
-
getUserById
|
|
27371
|
+
getUserById,
|
|
27372
|
+
updateUserOrgById: _updateUserOrgById
|
|
27355
27373
|
} = useUserRepo();
|
|
27356
27374
|
const { add: addMember } = useMemberRepo();
|
|
27357
27375
|
const { getById: _getUnitById, updateById: updateUnitById } = useBuildingUnitRepo();
|
|
@@ -27442,8 +27460,27 @@ function usePersonService() {
|
|
|
27442
27460
|
}
|
|
27443
27461
|
await _add(value, session);
|
|
27444
27462
|
await session.commitTransaction();
|
|
27463
|
+
if (value.email && isValidType && value.platform === "mobile") {
|
|
27464
|
+
const emailContent = compileHandlebar3({
|
|
27465
|
+
context: { name: value.name },
|
|
27466
|
+
filePath: getDirectory3(
|
|
27467
|
+
__dirname,
|
|
27468
|
+
"./public/handlebars/registration-pending"
|
|
27469
|
+
)
|
|
27470
|
+
});
|
|
27471
|
+
mailer.sendMail({
|
|
27472
|
+
to: value.email,
|
|
27473
|
+
subject: "Registration Received \u2013 Pending Review",
|
|
27474
|
+
html: emailContent,
|
|
27475
|
+
sender: "iService365"
|
|
27476
|
+
}).catch((error) => {
|
|
27477
|
+
logger84.error(`Failed to send registration pending email: ${error}`);
|
|
27478
|
+
});
|
|
27479
|
+
}
|
|
27445
27480
|
return "People added successfully.";
|
|
27446
27481
|
} catch (error) {
|
|
27482
|
+
console.log("error message service", error);
|
|
27483
|
+
console.log("error message service", error.message);
|
|
27447
27484
|
logger84.error("Error in people service add:", error);
|
|
27448
27485
|
await session.abortTransaction();
|
|
27449
27486
|
throw error;
|
|
@@ -27464,7 +27501,21 @@ function usePersonService() {
|
|
|
27464
27501
|
}
|
|
27465
27502
|
const isNameUpdated = typeof value.name === "string" && value.name.trim() !== person.name;
|
|
27466
27503
|
const isOwnerChanged = value.isOwner !== person.isOwner;
|
|
27504
|
+
if (value.org && typeof value.org === "string") {
|
|
27505
|
+
value.org = new ObjectId64(value.org);
|
|
27506
|
+
}
|
|
27507
|
+
if (value.site && typeof value.site === "string") {
|
|
27508
|
+
value.site = new ObjectId64(value.site);
|
|
27509
|
+
}
|
|
27510
|
+
const isOrgChanged = value.org && person.org?.toString() !== value.org.toString();
|
|
27467
27511
|
await _updateById(_id, value, session);
|
|
27512
|
+
if (isOrgChanged && person.user) {
|
|
27513
|
+
await _updateUserOrgById(
|
|
27514
|
+
person.user.toString(),
|
|
27515
|
+
value.org,
|
|
27516
|
+
session
|
|
27517
|
+
);
|
|
27518
|
+
}
|
|
27468
27519
|
if (value.unit && (isNameUpdated || isOwnerChanged || value.isOwner)) {
|
|
27469
27520
|
const unit = await _getUnitById(value.unit.toString());
|
|
27470
27521
|
if (unit) {
|
|
@@ -27486,7 +27537,11 @@ function usePersonService() {
|
|
|
27486
27537
|
updatePayload.ownerName = value.name || "";
|
|
27487
27538
|
}
|
|
27488
27539
|
if (Object.keys(updatePayload).length > 0 && unit && unit._id) {
|
|
27489
|
-
await updateUnitById(
|
|
27540
|
+
await updateUnitById(
|
|
27541
|
+
unit._id.toString(),
|
|
27542
|
+
updatePayload,
|
|
27543
|
+
session
|
|
27544
|
+
);
|
|
27490
27545
|
}
|
|
27491
27546
|
}
|
|
27492
27547
|
}
|
|
@@ -27576,13 +27631,13 @@ function usePersonService() {
|
|
|
27576
27631
|
title = "We request resubmission for your application";
|
|
27577
27632
|
hideLogin = false;
|
|
27578
27633
|
statusLogo = `${statusIconPath}/resubmission-icon.png`;
|
|
27579
|
-
message2 = `Hi ${person.name}, please resubmit your application with the required updates
|
|
27634
|
+
message2 = `Hi ${person.name}, please resubmit your application with the required updates.${value.remarks ? ` Remarks: ${value.remarks}` : ""}`;
|
|
27580
27635
|
break;
|
|
27581
27636
|
case "rejected":
|
|
27582
27637
|
userStatus = "rejected";
|
|
27583
|
-
title = "Your account request for
|
|
27638
|
+
title = "Your account request for application has been rejected.";
|
|
27584
27639
|
statusLogo = `${statusIconPath}/deleted-icon.png`;
|
|
27585
|
-
message2 = `Hi ${person.name}, unfortunately your application has been rejected. Please contact support for more information
|
|
27640
|
+
message2 = `Hi ${person.name}, unfortunately your application has been rejected.${value.remarks ? ` Remarks: ${value.remarks}` : " Please contact support for more information."}`;
|
|
27586
27641
|
break;
|
|
27587
27642
|
default:
|
|
27588
27643
|
throw new Error("Invalid review status");
|
|
@@ -28019,7 +28074,7 @@ function usePersonController() {
|
|
|
28019
28074
|
// src/models/robot.model.ts
|
|
28020
28075
|
import { BadRequestError as BadRequestError106, logger as logger86 } from "@7365admin1/node-server-utils";
|
|
28021
28076
|
import Joi61 from "joi";
|
|
28022
|
-
import { ObjectId as
|
|
28077
|
+
import { ObjectId as ObjectId65 } from "mongodb";
|
|
28023
28078
|
var metadataSchema4 = {
|
|
28024
28079
|
orgId: Joi61.string().hex().optional().allow("", null),
|
|
28025
28080
|
siteId: Joi61.string().hex().optional().allow("", null),
|
|
@@ -28044,21 +28099,21 @@ function MRobot(value) {
|
|
|
28044
28099
|
}
|
|
28045
28100
|
if (value.metadata?.orgId) {
|
|
28046
28101
|
try {
|
|
28047
|
-
value.metadata.orgId = new
|
|
28102
|
+
value.metadata.orgId = new ObjectId65(value.metadata.orgId);
|
|
28048
28103
|
} catch (error2) {
|
|
28049
28104
|
throw new BadRequestError106("Invalid organization ID format.");
|
|
28050
28105
|
}
|
|
28051
28106
|
}
|
|
28052
28107
|
if (value.metadata?.siteId) {
|
|
28053
28108
|
try {
|
|
28054
|
-
value.metadata.siteId = new
|
|
28109
|
+
value.metadata.siteId = new ObjectId65(value.metadata.siteId);
|
|
28055
28110
|
} catch (error2) {
|
|
28056
28111
|
throw new BadRequestError106("Invalid site ID format.");
|
|
28057
28112
|
}
|
|
28058
28113
|
}
|
|
28059
28114
|
if (value.metadata?.administratorId) {
|
|
28060
28115
|
try {
|
|
28061
|
-
value.metadata.administratorId = new
|
|
28116
|
+
value.metadata.administratorId = new ObjectId65(
|
|
28062
28117
|
value.metadata.administratorId
|
|
28063
28118
|
);
|
|
28064
28119
|
} catch (error2) {
|
|
@@ -28067,7 +28122,7 @@ function MRobot(value) {
|
|
|
28067
28122
|
}
|
|
28068
28123
|
if (value.createdBy) {
|
|
28069
28124
|
try {
|
|
28070
|
-
value.createdBy = new
|
|
28125
|
+
value.createdBy = new ObjectId65(value.createdBy);
|
|
28071
28126
|
} catch (error2) {
|
|
28072
28127
|
throw new BadRequestError106("Invalid created by ID format.");
|
|
28073
28128
|
}
|
|
@@ -28092,7 +28147,7 @@ function MRobot(value) {
|
|
|
28092
28147
|
}
|
|
28093
28148
|
|
|
28094
28149
|
// src/repositories/robot.repo.ts
|
|
28095
|
-
import { ObjectId as
|
|
28150
|
+
import { ObjectId as ObjectId66 } from "mongodb";
|
|
28096
28151
|
import {
|
|
28097
28152
|
useAtlas as useAtlas54,
|
|
28098
28153
|
InternalServerError as InternalServerError35,
|
|
@@ -28161,12 +28216,12 @@ function useRobotRepo() {
|
|
|
28161
28216
|
}) {
|
|
28162
28217
|
page = page > 0 ? page - 1 : 0;
|
|
28163
28218
|
try {
|
|
28164
|
-
organization = new
|
|
28219
|
+
organization = new ObjectId66(organization);
|
|
28165
28220
|
} catch (error) {
|
|
28166
28221
|
throw new BadRequestError107("Invalid organization ID format.");
|
|
28167
28222
|
}
|
|
28168
28223
|
try {
|
|
28169
|
-
site = new
|
|
28224
|
+
site = new ObjectId66(site);
|
|
28170
28225
|
} catch (error) {
|
|
28171
28226
|
throw new BadRequestError107("Invalid site ID format.");
|
|
28172
28227
|
}
|
|
@@ -28389,7 +28444,7 @@ function useRobotController() {
|
|
|
28389
28444
|
|
|
28390
28445
|
// src/models/patrol-question.model.ts
|
|
28391
28446
|
import { BadRequestError as BadRequestError110, logger as logger89 } from "@7365admin1/node-server-utils";
|
|
28392
|
-
import { ObjectId as
|
|
28447
|
+
import { ObjectId as ObjectId67 } from "mongodb";
|
|
28393
28448
|
import Joi63 from "joi";
|
|
28394
28449
|
var schemaPatrolQuestion = Joi63.object({
|
|
28395
28450
|
_id: Joi63.string().hex().optional(),
|
|
@@ -28415,14 +28470,14 @@ function MPatrolQuestion(value) {
|
|
|
28415
28470
|
}
|
|
28416
28471
|
if (value._id && typeof value._id === "string") {
|
|
28417
28472
|
try {
|
|
28418
|
-
value._id = new
|
|
28473
|
+
value._id = new ObjectId67(value._id);
|
|
28419
28474
|
} catch {
|
|
28420
28475
|
throw new BadRequestError110("Invalid _id format");
|
|
28421
28476
|
}
|
|
28422
28477
|
}
|
|
28423
28478
|
return {
|
|
28424
|
-
_id: value._id ?? new
|
|
28425
|
-
site: new
|
|
28479
|
+
_id: value._id ?? new ObjectId67(),
|
|
28480
|
+
site: new ObjectId67(value.site),
|
|
28426
28481
|
question: value.question,
|
|
28427
28482
|
answers: value.answers,
|
|
28428
28483
|
status: value.status ?? "active",
|
|
@@ -28443,7 +28498,7 @@ import {
|
|
|
28443
28498
|
useAtlas as useAtlas55,
|
|
28444
28499
|
useCache as useCache35
|
|
28445
28500
|
} from "@7365admin1/node-server-utils";
|
|
28446
|
-
import { ObjectId as
|
|
28501
|
+
import { ObjectId as ObjectId68 } from "mongodb";
|
|
28447
28502
|
function usePatrolQuestionRepo() {
|
|
28448
28503
|
const db = useAtlas55.getDb();
|
|
28449
28504
|
if (!db) {
|
|
@@ -28522,7 +28577,7 @@ function usePatrolQuestionRepo() {
|
|
|
28522
28577
|
{ answers: { $regex: search, $options: "i" } }
|
|
28523
28578
|
]
|
|
28524
28579
|
},
|
|
28525
|
-
...
|
|
28580
|
+
...ObjectId68.isValid(site) && { site: new ObjectId68(site) }
|
|
28526
28581
|
};
|
|
28527
28582
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
28528
28583
|
const cacheOptions = {
|
|
@@ -28562,7 +28617,7 @@ function usePatrolQuestionRepo() {
|
|
|
28562
28617
|
}
|
|
28563
28618
|
async function updateById(_id, value, session) {
|
|
28564
28619
|
try {
|
|
28565
|
-
_id = new
|
|
28620
|
+
_id = new ObjectId68(_id);
|
|
28566
28621
|
} catch (error) {
|
|
28567
28622
|
throw new BadRequestError111(
|
|
28568
28623
|
"Invalid patrol question transaction ID format."
|
|
@@ -28583,7 +28638,7 @@ function usePatrolQuestionRepo() {
|
|
|
28583
28638
|
}
|
|
28584
28639
|
async function deleteById(_id) {
|
|
28585
28640
|
try {
|
|
28586
|
-
_id = new
|
|
28641
|
+
_id = new ObjectId68(_id);
|
|
28587
28642
|
} catch (error) {
|
|
28588
28643
|
throw new BadRequestError111("Invalid customer ID format.");
|
|
28589
28644
|
}
|
|
@@ -28605,7 +28660,7 @@ function usePatrolQuestionRepo() {
|
|
|
28605
28660
|
}
|
|
28606
28661
|
async function getById(_id, session) {
|
|
28607
28662
|
try {
|
|
28608
|
-
_id = new
|
|
28663
|
+
_id = new ObjectId68(_id);
|
|
28609
28664
|
} catch (error) {
|
|
28610
28665
|
throw new BadRequestError111("Invalid patrol question ID format.");
|
|
28611
28666
|
}
|
|
@@ -28780,7 +28835,7 @@ function usePatrolQuestionController() {
|
|
|
28780
28835
|
|
|
28781
28836
|
// src/models/patrol-route.model.ts
|
|
28782
28837
|
import { BadRequestError as BadRequestError113, logger as logger92 } from "@7365admin1/node-server-utils";
|
|
28783
|
-
import { ObjectId as
|
|
28838
|
+
import { ObjectId as ObjectId69 } from "mongodb";
|
|
28784
28839
|
import Joi65 from "joi";
|
|
28785
28840
|
var schemeCamera = Joi65.object({
|
|
28786
28841
|
camera: Joi65.string().hex().required(),
|
|
@@ -28828,14 +28883,14 @@ function MPatrolRoute(value) {
|
|
|
28828
28883
|
}
|
|
28829
28884
|
if (value._id && typeof value._id === "string") {
|
|
28830
28885
|
try {
|
|
28831
|
-
value._id = new
|
|
28886
|
+
value._id = new ObjectId69(value._id);
|
|
28832
28887
|
} catch {
|
|
28833
28888
|
throw new BadRequestError113("Invalid _id format");
|
|
28834
28889
|
}
|
|
28835
28890
|
}
|
|
28836
28891
|
if (value.assignee && Array.isArray(value.assignee)) {
|
|
28837
28892
|
try {
|
|
28838
|
-
value.assignee = value.assignee.map((id) => new
|
|
28893
|
+
value.assignee = value.assignee.map((id) => new ObjectId69(id));
|
|
28839
28894
|
} catch {
|
|
28840
28895
|
throw new BadRequestError113("Invalid assignee id format");
|
|
28841
28896
|
}
|
|
@@ -28844,7 +28899,7 @@ function MPatrolRoute(value) {
|
|
|
28844
28899
|
value.cameras = value.cameras.map((camera) => {
|
|
28845
28900
|
if (typeof camera.camera === "string") {
|
|
28846
28901
|
try {
|
|
28847
|
-
camera.camera = new
|
|
28902
|
+
camera.camera = new ObjectId69(camera.camera);
|
|
28848
28903
|
} catch {
|
|
28849
28904
|
throw new BadRequestError113("Invalid camera id format");
|
|
28850
28905
|
}
|
|
@@ -28852,7 +28907,7 @@ function MPatrolRoute(value) {
|
|
|
28852
28907
|
camera.questions = camera.questions.map((question) => {
|
|
28853
28908
|
if (typeof question.questionId === "string") {
|
|
28854
28909
|
try {
|
|
28855
|
-
question.questionId = new
|
|
28910
|
+
question.questionId = new ObjectId69(question.questionId);
|
|
28856
28911
|
} catch {
|
|
28857
28912
|
throw new BadRequestError113("Invalid question id format");
|
|
28858
28913
|
}
|
|
@@ -28863,8 +28918,8 @@ function MPatrolRoute(value) {
|
|
|
28863
28918
|
});
|
|
28864
28919
|
}
|
|
28865
28920
|
return {
|
|
28866
|
-
_id: value._id ?? new
|
|
28867
|
-
site: new
|
|
28921
|
+
_id: value._id ?? new ObjectId69(),
|
|
28922
|
+
site: new ObjectId69(value.site),
|
|
28868
28923
|
name: value.name,
|
|
28869
28924
|
assignee: value.assignee,
|
|
28870
28925
|
start: value.start,
|
|
@@ -28890,7 +28945,7 @@ import {
|
|
|
28890
28945
|
useAtlas as useAtlas56,
|
|
28891
28946
|
useCache as useCache36
|
|
28892
28947
|
} from "@7365admin1/node-server-utils";
|
|
28893
|
-
import { ObjectId as
|
|
28948
|
+
import { ObjectId as ObjectId70 } from "mongodb";
|
|
28894
28949
|
function usePatrolRouteRepo() {
|
|
28895
28950
|
const db = useAtlas56.getDb();
|
|
28896
28951
|
if (!db) {
|
|
@@ -28966,7 +29021,7 @@ function usePatrolRouteRepo() {
|
|
|
28966
29021
|
page = page > 0 ? page - 1 : 0;
|
|
28967
29022
|
const query = {
|
|
28968
29023
|
status,
|
|
28969
|
-
...
|
|
29024
|
+
...ObjectId70.isValid(site) && { site: new ObjectId70(site) }
|
|
28970
29025
|
};
|
|
28971
29026
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
28972
29027
|
const cacheOptions = {
|
|
@@ -29049,20 +29104,20 @@ function usePatrolRouteRepo() {
|
|
|
29049
29104
|
}
|
|
29050
29105
|
async function updateById(_id, value, session) {
|
|
29051
29106
|
try {
|
|
29052
|
-
_id = new
|
|
29107
|
+
_id = new ObjectId70(_id);
|
|
29053
29108
|
} catch (error) {
|
|
29054
29109
|
throw new BadRequestError114("Invalid patrol route transaction ID format.");
|
|
29055
29110
|
}
|
|
29056
|
-
if (value.site &&
|
|
29111
|
+
if (value.site && ObjectId70.isValid(value.site.toString())) {
|
|
29057
29112
|
try {
|
|
29058
|
-
value.site = new
|
|
29113
|
+
value.site = new ObjectId70(value.site.toString());
|
|
29059
29114
|
} catch {
|
|
29060
29115
|
throw new BadRequestError114("Invalid _id format");
|
|
29061
29116
|
}
|
|
29062
29117
|
}
|
|
29063
29118
|
if (value.assignee && Array.isArray(value.assignee)) {
|
|
29064
29119
|
try {
|
|
29065
|
-
value.assignee = value.assignee.map((id) => new
|
|
29120
|
+
value.assignee = value.assignee.map((id) => new ObjectId70(id));
|
|
29066
29121
|
} catch {
|
|
29067
29122
|
throw new BadRequestError114("Invalid _id format");
|
|
29068
29123
|
}
|
|
@@ -29082,7 +29137,7 @@ function usePatrolRouteRepo() {
|
|
|
29082
29137
|
}
|
|
29083
29138
|
async function deleteById(_id) {
|
|
29084
29139
|
try {
|
|
29085
|
-
_id = new
|
|
29140
|
+
_id = new ObjectId70(_id);
|
|
29086
29141
|
} catch (error) {
|
|
29087
29142
|
throw new BadRequestError114("Invalid patrol route transaction ID format.");
|
|
29088
29143
|
}
|
|
@@ -29131,7 +29186,7 @@ function usePatrolRouteRepo() {
|
|
|
29131
29186
|
const query = {
|
|
29132
29187
|
status,
|
|
29133
29188
|
...search && { $text: { $search: search } },
|
|
29134
|
-
...
|
|
29189
|
+
...ObjectId70.isValid(site) && { site: new ObjectId70(site) }
|
|
29135
29190
|
};
|
|
29136
29191
|
if (day && start) {
|
|
29137
29192
|
const [hour, minute] = start?.split(":") ?? ["0", "0"];
|
|
@@ -29214,7 +29269,7 @@ function usePatrolRouteRepo() {
|
|
|
29214
29269
|
id: "$_id",
|
|
29215
29270
|
start: startOfDay,
|
|
29216
29271
|
end: endOfDay,
|
|
29217
|
-
site:
|
|
29272
|
+
site: ObjectId70.isValid(site) ? new ObjectId70(site) : null
|
|
29218
29273
|
},
|
|
29219
29274
|
pipeline: [
|
|
29220
29275
|
{
|
|
@@ -29260,7 +29315,7 @@ function usePatrolRouteRepo() {
|
|
|
29260
29315
|
}
|
|
29261
29316
|
async function getById(_id, session) {
|
|
29262
29317
|
try {
|
|
29263
|
-
_id = new
|
|
29318
|
+
_id = new ObjectId70(_id);
|
|
29264
29319
|
} catch (error) {
|
|
29265
29320
|
throw new BadRequestError114("Invalid patrol log ID format.");
|
|
29266
29321
|
}
|
|
@@ -29505,7 +29560,7 @@ function usePatrolRouteController() {
|
|
|
29505
29560
|
|
|
29506
29561
|
// src/models/patrol-log.model.ts
|
|
29507
29562
|
import { BadRequestError as BadRequestError116, logger as logger95 } from "@7365admin1/node-server-utils";
|
|
29508
|
-
import { ObjectId as
|
|
29563
|
+
import { ObjectId as ObjectId71 } from "mongodb";
|
|
29509
29564
|
import Joi67 from "joi";
|
|
29510
29565
|
var schemeLogCamera = Joi67.object({
|
|
29511
29566
|
camera: Joi67.string().hex().required(),
|
|
@@ -29566,41 +29621,41 @@ function MPatrolLog(value) {
|
|
|
29566
29621
|
}
|
|
29567
29622
|
if (value._id && typeof value._id === "string") {
|
|
29568
29623
|
try {
|
|
29569
|
-
value._id = new
|
|
29624
|
+
value._id = new ObjectId71(value._id);
|
|
29570
29625
|
} catch {
|
|
29571
29626
|
throw new BadRequestError116("Invalid _id format");
|
|
29572
29627
|
}
|
|
29573
29628
|
}
|
|
29574
29629
|
if (value.route && typeof value.route === "string") {
|
|
29575
29630
|
try {
|
|
29576
|
-
value.route = new
|
|
29631
|
+
value.route = new ObjectId71(value.route);
|
|
29577
29632
|
} catch {
|
|
29578
29633
|
throw new BadRequestError116("Invalid route id format");
|
|
29579
29634
|
}
|
|
29580
29635
|
}
|
|
29581
29636
|
if (value.site && typeof value.site === "string") {
|
|
29582
29637
|
try {
|
|
29583
|
-
value.site = new
|
|
29638
|
+
value.site = new ObjectId71(value.site);
|
|
29584
29639
|
} catch {
|
|
29585
29640
|
throw new BadRequestError116("Invalid site id format");
|
|
29586
29641
|
}
|
|
29587
29642
|
}
|
|
29588
29643
|
const assignee = (value.assignee || []).map((id) => {
|
|
29589
29644
|
try {
|
|
29590
|
-
return new
|
|
29645
|
+
return new ObjectId71(id);
|
|
29591
29646
|
} catch {
|
|
29592
29647
|
throw new BadRequestError116("Invalid assignee id format");
|
|
29593
29648
|
}
|
|
29594
29649
|
});
|
|
29595
29650
|
if (value.incidentReport && typeof value.incidentReport.id === "string") {
|
|
29596
29651
|
try {
|
|
29597
|
-
value.incidentReport.id = new
|
|
29652
|
+
value.incidentReport.id = new ObjectId71(value.incidentReport.id);
|
|
29598
29653
|
} catch {
|
|
29599
29654
|
throw new BadRequestError116("Invalid incident report id format");
|
|
29600
29655
|
}
|
|
29601
29656
|
}
|
|
29602
29657
|
return {
|
|
29603
|
-
_id: value._id ?? new
|
|
29658
|
+
_id: value._id ?? new ObjectId71(),
|
|
29604
29659
|
site: value.site,
|
|
29605
29660
|
name: value.name,
|
|
29606
29661
|
assignee,
|
|
@@ -29628,7 +29683,7 @@ import {
|
|
|
29628
29683
|
useAtlas as useAtlas57,
|
|
29629
29684
|
useCache as useCache37
|
|
29630
29685
|
} from "@7365admin1/node-server-utils";
|
|
29631
|
-
import { ObjectId as
|
|
29686
|
+
import { ObjectId as ObjectId72 } from "mongodb";
|
|
29632
29687
|
function usePatrolLogRepo() {
|
|
29633
29688
|
const db = useAtlas57.getDb();
|
|
29634
29689
|
if (!db) {
|
|
@@ -29719,7 +29774,7 @@ function usePatrolLogRepo() {
|
|
|
29719
29774
|
};
|
|
29720
29775
|
}
|
|
29721
29776
|
const query = {
|
|
29722
|
-
...
|
|
29777
|
+
...ObjectId72.isValid(site) && { site: new ObjectId72(site) },
|
|
29723
29778
|
...dateExpr
|
|
29724
29779
|
};
|
|
29725
29780
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -29859,7 +29914,7 @@ function usePatrolLogRepo() {
|
|
|
29859
29914
|
}
|
|
29860
29915
|
async function updateById(_id, value, session) {
|
|
29861
29916
|
try {
|
|
29862
|
-
_id = new
|
|
29917
|
+
_id = new ObjectId72(_id);
|
|
29863
29918
|
} catch (error) {
|
|
29864
29919
|
throw new BadRequestError117("Invalid patrol log transaction ID format.");
|
|
29865
29920
|
}
|
|
@@ -29878,7 +29933,7 @@ function usePatrolLogRepo() {
|
|
|
29878
29933
|
}
|
|
29879
29934
|
async function deleteById(_id, session) {
|
|
29880
29935
|
try {
|
|
29881
|
-
_id = new
|
|
29936
|
+
_id = new ObjectId72(_id);
|
|
29882
29937
|
} catch (error) {
|
|
29883
29938
|
throw new BadRequestError117("Invalid patrol log ID format.");
|
|
29884
29939
|
}
|
|
@@ -29892,7 +29947,7 @@ function usePatrolLogRepo() {
|
|
|
29892
29947
|
}
|
|
29893
29948
|
async function getById(_id, session) {
|
|
29894
29949
|
try {
|
|
29895
|
-
_id = new
|
|
29950
|
+
_id = new ObjectId72(_id);
|
|
29896
29951
|
} catch (error) {
|
|
29897
29952
|
throw new BadRequestError117("Invalid patrol log ID format.");
|
|
29898
29953
|
}
|
|
@@ -30145,7 +30200,7 @@ function usePatrolLogController() {
|
|
|
30145
30200
|
|
|
30146
30201
|
// src/models/site-facility.model.ts
|
|
30147
30202
|
import Joi69 from "joi";
|
|
30148
|
-
import { ObjectId as
|
|
30203
|
+
import { ObjectId as ObjectId73 } from "mongodb";
|
|
30149
30204
|
var timeSlotSchema = Joi69.array().items(
|
|
30150
30205
|
Joi69.object({
|
|
30151
30206
|
start: Joi69.string().optional().allow("", null),
|
|
@@ -30305,28 +30360,28 @@ function MSiteFacility(value) {
|
|
|
30305
30360
|
throw new Error(error.details[0].message);
|
|
30306
30361
|
if (value._id && typeof value._id === "string") {
|
|
30307
30362
|
try {
|
|
30308
|
-
value._id = new
|
|
30363
|
+
value._id = new ObjectId73(value._id);
|
|
30309
30364
|
} catch {
|
|
30310
30365
|
throw new Error("Invalid _id.");
|
|
30311
30366
|
}
|
|
30312
30367
|
}
|
|
30313
30368
|
if (value.site && typeof value.site === "string") {
|
|
30314
30369
|
try {
|
|
30315
|
-
value.site = new
|
|
30370
|
+
value.site = new ObjectId73(value.site);
|
|
30316
30371
|
} catch {
|
|
30317
30372
|
throw new Error("Invalid _id.");
|
|
30318
30373
|
}
|
|
30319
30374
|
}
|
|
30320
30375
|
if (value.featuredImage && typeof value.featuredImage === "string") {
|
|
30321
30376
|
try {
|
|
30322
|
-
value.featuredImage = new
|
|
30377
|
+
value.featuredImage = new ObjectId73(value.featuredImage);
|
|
30323
30378
|
} catch {
|
|
30324
30379
|
throw new Error("Invalid featuredImage ID.");
|
|
30325
30380
|
}
|
|
30326
30381
|
}
|
|
30327
30382
|
if (Array.isArray(value.gallery)) {
|
|
30328
30383
|
try {
|
|
30329
|
-
value.gallery = value.gallery.map((id) => new
|
|
30384
|
+
value.gallery = value.gallery.map((id) => new ObjectId73(id));
|
|
30330
30385
|
} catch {
|
|
30331
30386
|
throw new Error("Invalid ID in gallery array.");
|
|
30332
30387
|
}
|
|
@@ -30419,7 +30474,7 @@ import {
|
|
|
30419
30474
|
useAtlas as useAtlas59,
|
|
30420
30475
|
useCache as useCache38
|
|
30421
30476
|
} from "@7365admin1/node-server-utils";
|
|
30422
|
-
import { ObjectId as
|
|
30477
|
+
import { ObjectId as ObjectId74 } from "mongodb";
|
|
30423
30478
|
function useSiteFacilityRepo() {
|
|
30424
30479
|
const db = useAtlas59.getDb();
|
|
30425
30480
|
if (!db) {
|
|
@@ -30487,7 +30542,7 @@ function useSiteFacilityRepo() {
|
|
|
30487
30542
|
};
|
|
30488
30543
|
if (site) {
|
|
30489
30544
|
try {
|
|
30490
|
-
site = new
|
|
30545
|
+
site = new ObjectId74(site);
|
|
30491
30546
|
query.site = site;
|
|
30492
30547
|
cacheOptions.site = site.toString();
|
|
30493
30548
|
} catch (error) {
|
|
@@ -30532,7 +30587,7 @@ function useSiteFacilityRepo() {
|
|
|
30532
30587
|
}
|
|
30533
30588
|
async function getSiteFacilityById(_id, session) {
|
|
30534
30589
|
try {
|
|
30535
|
-
_id = new
|
|
30590
|
+
_id = new ObjectId74(_id);
|
|
30536
30591
|
} catch (error) {
|
|
30537
30592
|
throw new BadRequestError120("Invalid site facility ID format.");
|
|
30538
30593
|
}
|
|
@@ -30560,20 +30615,20 @@ function useSiteFacilityRepo() {
|
|
|
30560
30615
|
async function updateSiteFacilityById(_id, value, session) {
|
|
30561
30616
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
30562
30617
|
try {
|
|
30563
|
-
_id = new
|
|
30618
|
+
_id = new ObjectId74(_id);
|
|
30564
30619
|
} catch (error) {
|
|
30565
30620
|
throw new BadRequestError120("Invalid ID format.");
|
|
30566
30621
|
}
|
|
30567
30622
|
if (value.featuredImage) {
|
|
30568
30623
|
try {
|
|
30569
|
-
value.featuredImage = new
|
|
30624
|
+
value.featuredImage = new ObjectId74(value.featuredImage);
|
|
30570
30625
|
} catch (error) {
|
|
30571
30626
|
throw new BadRequestError120("Invalid ID format for featured image.");
|
|
30572
30627
|
}
|
|
30573
30628
|
}
|
|
30574
30629
|
if (Array.isArray(value.gallery)) {
|
|
30575
30630
|
try {
|
|
30576
|
-
value.gallery = value.gallery.map((id) => new
|
|
30631
|
+
value.gallery = value.gallery.map((id) => new ObjectId74(id));
|
|
30577
30632
|
} catch {
|
|
30578
30633
|
throw new Error("Invalid ID in gallery array.");
|
|
30579
30634
|
}
|
|
@@ -30619,7 +30674,7 @@ function useSiteFacilityRepo() {
|
|
|
30619
30674
|
}
|
|
30620
30675
|
async function deleteSiteFacilityById(_id) {
|
|
30621
30676
|
try {
|
|
30622
|
-
_id = new
|
|
30677
|
+
_id = new ObjectId74(_id);
|
|
30623
30678
|
} catch (error) {
|
|
30624
30679
|
throw new BadRequestError120("Invalid site facility ID format.");
|
|
30625
30680
|
}
|
|
@@ -30648,12 +30703,12 @@ function useSiteFacilityRepo() {
|
|
|
30648
30703
|
}
|
|
30649
30704
|
async function getSiteFacilityTimeSlotById(_id, site, session) {
|
|
30650
30705
|
try {
|
|
30651
|
-
_id = new
|
|
30706
|
+
_id = new ObjectId74(_id);
|
|
30652
30707
|
} catch (error) {
|
|
30653
30708
|
throw new BadRequestError120("Invalid facility ID format.");
|
|
30654
30709
|
}
|
|
30655
30710
|
try {
|
|
30656
|
-
site = new
|
|
30711
|
+
site = new ObjectId74(site);
|
|
30657
30712
|
} catch (error) {
|
|
30658
30713
|
throw new BadRequestError120("Invalid site ID format.");
|
|
30659
30714
|
}
|
|
@@ -30996,7 +31051,7 @@ function useSiteFacilityController() {
|
|
|
30996
31051
|
|
|
30997
31052
|
// src/models/service-provider-billing.model.ts
|
|
30998
31053
|
import Joi71 from "joi";
|
|
30999
|
-
import { ObjectId as
|
|
31054
|
+
import { ObjectId as ObjectId75 } from "mongodb";
|
|
31000
31055
|
var schemaServiceProviderBilling = Joi71.object({
|
|
31001
31056
|
_id: Joi71.string().hex().optional().allow("", null),
|
|
31002
31057
|
attachments: Joi71.array().items(Joi71.string().hex()).required(),
|
|
@@ -31030,7 +31085,7 @@ function MServiceProviderBilling(value) {
|
|
|
31030
31085
|
}
|
|
31031
31086
|
if (value._id && typeof value._id === "string") {
|
|
31032
31087
|
try {
|
|
31033
|
-
value._id = new
|
|
31088
|
+
value._id = new ObjectId75(value._id);
|
|
31034
31089
|
} catch {
|
|
31035
31090
|
throw new Error("Invalid ID.");
|
|
31036
31091
|
}
|
|
@@ -31039,7 +31094,7 @@ function MServiceProviderBilling(value) {
|
|
|
31039
31094
|
value.acknowledgedBy = value.acknowledgedBy.map((item) => {
|
|
31040
31095
|
if (item.user && typeof item.user === "string") {
|
|
31041
31096
|
try {
|
|
31042
|
-
item.user = new
|
|
31097
|
+
item.user = new ObjectId75(item.user);
|
|
31043
31098
|
} catch (error2) {
|
|
31044
31099
|
throw new Error("Invalid ID format for acknowledgedBy.user.");
|
|
31045
31100
|
}
|
|
@@ -31049,13 +31104,13 @@ function MServiceProviderBilling(value) {
|
|
|
31049
31104
|
}
|
|
31050
31105
|
if (value.orgId && typeof value.orgId === "string") {
|
|
31051
31106
|
try {
|
|
31052
|
-
value.orgId = new
|
|
31107
|
+
value.orgId = new ObjectId75(value.orgId);
|
|
31053
31108
|
} catch {
|
|
31054
31109
|
throw new Error("Invalid org ID.");
|
|
31055
31110
|
}
|
|
31056
31111
|
}
|
|
31057
31112
|
return {
|
|
31058
|
-
_id: value._id ?? new
|
|
31113
|
+
_id: value._id ?? new ObjectId75(),
|
|
31059
31114
|
attachments: value.attachments,
|
|
31060
31115
|
acknowledgedBy: value.acknowledgedBy || [],
|
|
31061
31116
|
status: value.status,
|
|
@@ -31077,7 +31132,7 @@ import {
|
|
|
31077
31132
|
useAtlas as useAtlas61,
|
|
31078
31133
|
useCache as useCache39
|
|
31079
31134
|
} from "@7365admin1/node-server-utils";
|
|
31080
|
-
import { ObjectId as
|
|
31135
|
+
import { ObjectId as ObjectId76 } from "mongodb";
|
|
31081
31136
|
function useServiceProviderBillingRepo() {
|
|
31082
31137
|
const db = useAtlas61.getDb();
|
|
31083
31138
|
if (!db) {
|
|
@@ -31124,7 +31179,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31124
31179
|
}, session) {
|
|
31125
31180
|
page = page > 0 ? page - 1 : 0;
|
|
31126
31181
|
try {
|
|
31127
|
-
org = new
|
|
31182
|
+
org = new ObjectId76(org);
|
|
31128
31183
|
} catch (error) {
|
|
31129
31184
|
throw new BadRequestError122("Invalid org ID format.");
|
|
31130
31185
|
}
|
|
@@ -31174,7 +31229,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31174
31229
|
}
|
|
31175
31230
|
async function getSiteServiceProviderBillingById(_id, session) {
|
|
31176
31231
|
try {
|
|
31177
|
-
_id = new
|
|
31232
|
+
_id = new ObjectId76(_id);
|
|
31178
31233
|
} catch (error) {
|
|
31179
31234
|
throw new BadRequestError122("Invalid service provider billing ID format.");
|
|
31180
31235
|
}
|
|
@@ -31202,7 +31257,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31202
31257
|
async function updateServiceProviderBillingById(_id, value, session) {
|
|
31203
31258
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
31204
31259
|
try {
|
|
31205
|
-
_id = new
|
|
31260
|
+
_id = new ObjectId76(_id);
|
|
31206
31261
|
} catch (error) {
|
|
31207
31262
|
throw new BadRequestError122("Invalid ID format.");
|
|
31208
31263
|
}
|
|
@@ -31210,7 +31265,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31210
31265
|
value.acknowledgedBy = value.acknowledgedBy.map((item) => {
|
|
31211
31266
|
if (item.user && typeof item.user === "string") {
|
|
31212
31267
|
try {
|
|
31213
|
-
item.user = new
|
|
31268
|
+
item.user = new ObjectId76(item.user);
|
|
31214
31269
|
} catch (error) {
|
|
31215
31270
|
throw new Error("Invalid ID format for acknowledgedBy.user.");
|
|
31216
31271
|
}
|
|
@@ -31244,7 +31299,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31244
31299
|
}
|
|
31245
31300
|
async function deleteServiceProviderBillingById(_id) {
|
|
31246
31301
|
try {
|
|
31247
|
-
_id = new
|
|
31302
|
+
_id = new ObjectId76(_id);
|
|
31248
31303
|
} catch (error) {
|
|
31249
31304
|
throw new BadRequestError122("Invalid service provider billing ID format.");
|
|
31250
31305
|
}
|
|
@@ -31482,7 +31537,7 @@ function useServiceProviderBillingController() {
|
|
|
31482
31537
|
|
|
31483
31538
|
// src/models/site-facility-booking.model.ts
|
|
31484
31539
|
import Joi73 from "joi";
|
|
31485
|
-
import { ObjectId as
|
|
31540
|
+
import { ObjectId as ObjectId77 } from "mongodb";
|
|
31486
31541
|
var FacilitySort = /* @__PURE__ */ ((FacilitySort2) => {
|
|
31487
31542
|
FacilitySort2["CREATED_AT"] = "createdAt";
|
|
31488
31543
|
FacilitySort2["NAME"] = "name";
|
|
@@ -31592,48 +31647,48 @@ function MSiteFacilityBooking(value) {
|
|
|
31592
31647
|
}
|
|
31593
31648
|
if (value._id && typeof value._id === "string") {
|
|
31594
31649
|
try {
|
|
31595
|
-
value._id = new
|
|
31650
|
+
value._id = new ObjectId77(value._id);
|
|
31596
31651
|
} catch {
|
|
31597
31652
|
throw new Error("Invalid ID.");
|
|
31598
31653
|
}
|
|
31599
31654
|
}
|
|
31600
31655
|
if (value.site && typeof value.site === "string") {
|
|
31601
31656
|
try {
|
|
31602
|
-
value.site = new
|
|
31657
|
+
value.site = new ObjectId77(value.site);
|
|
31603
31658
|
} catch {
|
|
31604
31659
|
throw new Error("Invalid site ID.");
|
|
31605
31660
|
}
|
|
31606
31661
|
}
|
|
31607
31662
|
if (value.user && typeof value.user === "string") {
|
|
31608
31663
|
try {
|
|
31609
|
-
value.user = new
|
|
31664
|
+
value.user = new ObjectId77(value.user);
|
|
31610
31665
|
} catch {
|
|
31611
31666
|
throw new Error("Invalid user ID.");
|
|
31612
31667
|
}
|
|
31613
31668
|
}
|
|
31614
31669
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
31615
31670
|
try {
|
|
31616
|
-
value.approvedBy = new
|
|
31671
|
+
value.approvedBy = new ObjectId77(value.approvedBy);
|
|
31617
31672
|
} catch {
|
|
31618
31673
|
throw new Error("Invalid approved by ID.");
|
|
31619
31674
|
}
|
|
31620
31675
|
}
|
|
31621
31676
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
31622
31677
|
try {
|
|
31623
|
-
value.createdBy = new
|
|
31678
|
+
value.createdBy = new ObjectId77(value.createdBy);
|
|
31624
31679
|
} catch {
|
|
31625
31680
|
throw new Error("Invalid created by ID.");
|
|
31626
31681
|
}
|
|
31627
31682
|
}
|
|
31628
31683
|
if (value.updatedBy && typeof value.updatedBy === "string") {
|
|
31629
31684
|
try {
|
|
31630
|
-
value.updatedBy = new
|
|
31685
|
+
value.updatedBy = new ObjectId77(value.updatedBy);
|
|
31631
31686
|
} catch {
|
|
31632
31687
|
throw new Error("Invalid updated by ID.");
|
|
31633
31688
|
}
|
|
31634
31689
|
}
|
|
31635
31690
|
return {
|
|
31636
|
-
_id: value._id ?? new
|
|
31691
|
+
_id: value._id ?? new ObjectId77(),
|
|
31637
31692
|
facility: value.facility ?? "",
|
|
31638
31693
|
slot: value.slot ?? "",
|
|
31639
31694
|
slotName: value.slotName ?? "",
|
|
@@ -31729,7 +31784,7 @@ import {
|
|
|
31729
31784
|
useAtlas as useAtlas63,
|
|
31730
31785
|
useCache as useCache40
|
|
31731
31786
|
} from "@7365admin1/node-server-utils";
|
|
31732
|
-
import { ObjectId as
|
|
31787
|
+
import { ObjectId as ObjectId78 } from "mongodb";
|
|
31733
31788
|
var facility_bookings_namespace_collection = "site.facilty-booking";
|
|
31734
31789
|
function useSiteFacilityBookingRepo() {
|
|
31735
31790
|
const db = useAtlas63.getDb();
|
|
@@ -31892,7 +31947,7 @@ function useSiteFacilityBookingRepo() {
|
|
|
31892
31947
|
}
|
|
31893
31948
|
async function deleteSiteFacilityBookingById(_id) {
|
|
31894
31949
|
try {
|
|
31895
|
-
_id = new
|
|
31950
|
+
_id = new ObjectId78(_id);
|
|
31896
31951
|
} catch (error) {
|
|
31897
31952
|
throw new BadRequestError124("Invalid site facility booking ID format.");
|
|
31898
31953
|
}
|
|
@@ -32129,7 +32184,7 @@ function useSiteFacilityBookingController() {
|
|
|
32129
32184
|
|
|
32130
32185
|
// src/models/document-management.model.ts
|
|
32131
32186
|
import Joi75 from "joi";
|
|
32132
|
-
import { ObjectId as
|
|
32187
|
+
import { ObjectId as ObjectId79 } from "mongodb";
|
|
32133
32188
|
var schemaDocumentManagement = Joi75.object({
|
|
32134
32189
|
_id: Joi75.string().hex().optional().allow("", null),
|
|
32135
32190
|
name: Joi75.string().required(),
|
|
@@ -32167,28 +32222,28 @@ function MDocumentManagement(value) {
|
|
|
32167
32222
|
}
|
|
32168
32223
|
if (value._id && typeof value._id === "string") {
|
|
32169
32224
|
try {
|
|
32170
|
-
value._id = new
|
|
32225
|
+
value._id = new ObjectId79(value._id);
|
|
32171
32226
|
} catch (error2) {
|
|
32172
32227
|
throw new Error("Invalid ID.");
|
|
32173
32228
|
}
|
|
32174
32229
|
}
|
|
32175
32230
|
if (value.org && typeof value.org === "string") {
|
|
32176
32231
|
try {
|
|
32177
|
-
value.org = new
|
|
32232
|
+
value.org = new ObjectId79(value.org);
|
|
32178
32233
|
} catch (error2) {
|
|
32179
32234
|
throw new Error("Invalid org ID.");
|
|
32180
32235
|
}
|
|
32181
32236
|
}
|
|
32182
32237
|
if (value.site && typeof value.site === "string") {
|
|
32183
32238
|
try {
|
|
32184
|
-
value.site = new
|
|
32239
|
+
value.site = new ObjectId79(value.site);
|
|
32185
32240
|
} catch (error2) {
|
|
32186
32241
|
throw new Error("Invalid site ID.");
|
|
32187
32242
|
}
|
|
32188
32243
|
}
|
|
32189
32244
|
if (value.parentId && typeof value.parentId === "string") {
|
|
32190
32245
|
try {
|
|
32191
|
-
value.parentId = new
|
|
32246
|
+
value.parentId = new ObjectId79(value.parentId);
|
|
32192
32247
|
} catch (error2) {
|
|
32193
32248
|
throw new Error("Invalid parentId.");
|
|
32194
32249
|
}
|
|
@@ -32222,7 +32277,7 @@ import {
|
|
|
32222
32277
|
useAtlas as useAtlas65,
|
|
32223
32278
|
useCache as useCache41
|
|
32224
32279
|
} from "@7365admin1/node-server-utils";
|
|
32225
|
-
import { ObjectId as
|
|
32280
|
+
import { ObjectId as ObjectId80 } from "mongodb";
|
|
32226
32281
|
function useDocumentManagementRepo() {
|
|
32227
32282
|
const db = useAtlas65.getDb();
|
|
32228
32283
|
if (!db) {
|
|
@@ -32284,7 +32339,7 @@ function useDocumentManagementRepo() {
|
|
|
32284
32339
|
}) {
|
|
32285
32340
|
page = page > 0 ? page - 1 : 0;
|
|
32286
32341
|
try {
|
|
32287
|
-
site = new
|
|
32342
|
+
site = new ObjectId80(site);
|
|
32288
32343
|
} catch (error) {
|
|
32289
32344
|
throw new BadRequestError126("Invalid site ID format.");
|
|
32290
32345
|
}
|
|
@@ -32301,12 +32356,12 @@ function useDocumentManagementRepo() {
|
|
|
32301
32356
|
cacheOptions.type = type;
|
|
32302
32357
|
}
|
|
32303
32358
|
if (org) {
|
|
32304
|
-
query.org = new
|
|
32359
|
+
query.org = new ObjectId80(org);
|
|
32305
32360
|
cacheOptions.org = org.toString();
|
|
32306
32361
|
}
|
|
32307
32362
|
if (parentId) {
|
|
32308
32363
|
try {
|
|
32309
|
-
query.parentId = new
|
|
32364
|
+
query.parentId = new ObjectId80(parentId);
|
|
32310
32365
|
cacheOptions.parentId = parentId.toString();
|
|
32311
32366
|
} catch (error) {
|
|
32312
32367
|
throw new BadRequestError126("Invalid parentId format.");
|
|
@@ -32360,7 +32415,7 @@ function useDocumentManagementRepo() {
|
|
|
32360
32415
|
}
|
|
32361
32416
|
async function getDocumentById(_id) {
|
|
32362
32417
|
try {
|
|
32363
|
-
_id = new
|
|
32418
|
+
_id = new ObjectId80(_id);
|
|
32364
32419
|
} catch (error) {
|
|
32365
32420
|
throw new BadRequestError126("Invalid document ID format.");
|
|
32366
32421
|
}
|
|
@@ -32405,7 +32460,7 @@ function useDocumentManagementRepo() {
|
|
|
32405
32460
|
}
|
|
32406
32461
|
async function updateDocumentById(_id, value) {
|
|
32407
32462
|
try {
|
|
32408
|
-
_id = new
|
|
32463
|
+
_id = new ObjectId80(_id);
|
|
32409
32464
|
} catch (error) {
|
|
32410
32465
|
throw new BadRequestError126("Invalid document ID format.");
|
|
32411
32466
|
}
|
|
@@ -32433,7 +32488,7 @@ function useDocumentManagementRepo() {
|
|
|
32433
32488
|
}
|
|
32434
32489
|
async function deleteDocumentById(_id, session) {
|
|
32435
32490
|
try {
|
|
32436
|
-
_id = new
|
|
32491
|
+
_id = new ObjectId80(_id);
|
|
32437
32492
|
} catch (error) {
|
|
32438
32493
|
throw new BadRequestError126("Invalid document ID format.");
|
|
32439
32494
|
}
|
|
@@ -32466,7 +32521,7 @@ function useDocumentManagementRepo() {
|
|
|
32466
32521
|
}
|
|
32467
32522
|
async function getDocumentManagementBySiteId(site, type) {
|
|
32468
32523
|
try {
|
|
32469
|
-
site = new
|
|
32524
|
+
site = new ObjectId80(site);
|
|
32470
32525
|
} catch (error) {
|
|
32471
32526
|
throw new BadRequestError126("Invalid document management site ID format.");
|
|
32472
32527
|
}
|
|
@@ -32796,7 +32851,7 @@ function useDocumentManagementController() {
|
|
|
32796
32851
|
|
|
32797
32852
|
// src/models/bulletin-board.model.ts
|
|
32798
32853
|
import Joi77 from "joi";
|
|
32799
|
-
import { ObjectId as
|
|
32854
|
+
import { ObjectId as ObjectId81 } from "mongodb";
|
|
32800
32855
|
var BulletinRecipient = /* @__PURE__ */ ((BulletinRecipient2) => {
|
|
32801
32856
|
BulletinRecipient2["RESIDENT"] = "resident";
|
|
32802
32857
|
BulletinRecipient2["SECURITY_AGENCY"] = "security_agency";
|
|
@@ -32876,21 +32931,21 @@ function MBulletinBoard(value) {
|
|
|
32876
32931
|
}
|
|
32877
32932
|
if (value._id && typeof value._id === "string") {
|
|
32878
32933
|
try {
|
|
32879
|
-
value._id = new
|
|
32934
|
+
value._id = new ObjectId81(value._id);
|
|
32880
32935
|
} catch {
|
|
32881
32936
|
throw new Error("Invalid ID.");
|
|
32882
32937
|
}
|
|
32883
32938
|
}
|
|
32884
32939
|
if (value.site && typeof value.site === "string") {
|
|
32885
32940
|
try {
|
|
32886
|
-
value.site = new
|
|
32941
|
+
value.site = new ObjectId81(value.site);
|
|
32887
32942
|
} catch {
|
|
32888
32943
|
throw new Error("Invalid site ID.");
|
|
32889
32944
|
}
|
|
32890
32945
|
}
|
|
32891
32946
|
if (value.orgId && typeof value.orgId === "string") {
|
|
32892
32947
|
try {
|
|
32893
|
-
value.orgId = new
|
|
32948
|
+
value.orgId = new ObjectId81(value.orgId);
|
|
32894
32949
|
} catch {
|
|
32895
32950
|
throw new Error("Invalid org ID.");
|
|
32896
32951
|
}
|
|
@@ -32899,7 +32954,7 @@ function MBulletinBoard(value) {
|
|
|
32899
32954
|
value.file = value.file.map((f) => {
|
|
32900
32955
|
if (f._id && typeof f._id === "string") {
|
|
32901
32956
|
try {
|
|
32902
|
-
return { ...f, _id: new
|
|
32957
|
+
return { ...f, _id: new ObjectId81(f._id) };
|
|
32903
32958
|
} catch {
|
|
32904
32959
|
throw new Error("Invalid file ID.");
|
|
32905
32960
|
}
|
|
@@ -32908,7 +32963,7 @@ function MBulletinBoard(value) {
|
|
|
32908
32963
|
});
|
|
32909
32964
|
}
|
|
32910
32965
|
return {
|
|
32911
|
-
_id: value._id ?? new
|
|
32966
|
+
_id: value._id ?? new ObjectId81(),
|
|
32912
32967
|
site: value.site ?? "",
|
|
32913
32968
|
orgId: value.orgId ?? "",
|
|
32914
32969
|
recipients: value.recipients ?? [],
|
|
@@ -32936,7 +32991,7 @@ import {
|
|
|
32936
32991
|
useAtlas as useAtlas67,
|
|
32937
32992
|
useCache as useCache42
|
|
32938
32993
|
} from "@7365admin1/node-server-utils";
|
|
32939
|
-
import { ObjectId as
|
|
32994
|
+
import { ObjectId as ObjectId82 } from "mongodb";
|
|
32940
32995
|
var bulletin_boards_namespace_collection = "bulletin-boards";
|
|
32941
32996
|
function useBulletinBoardRepo() {
|
|
32942
32997
|
const db = useAtlas67.getDb();
|
|
@@ -32989,7 +33044,7 @@ function useBulletinBoardRepo() {
|
|
|
32989
33044
|
}, session) {
|
|
32990
33045
|
page = page > 0 ? page - 1 : 0;
|
|
32991
33046
|
try {
|
|
32992
|
-
site = new
|
|
33047
|
+
site = new ObjectId82(site);
|
|
32993
33048
|
} catch (error) {
|
|
32994
33049
|
throw new BadRequestError129("Invalid site ID format.");
|
|
32995
33050
|
}
|
|
@@ -33048,7 +33103,7 @@ function useBulletinBoardRepo() {
|
|
|
33048
33103
|
}
|
|
33049
33104
|
async function getBulletinBoardById(_id, session) {
|
|
33050
33105
|
try {
|
|
33051
|
-
_id = new
|
|
33106
|
+
_id = new ObjectId82(_id);
|
|
33052
33107
|
} catch (error) {
|
|
33053
33108
|
throw new BadRequestError129("Invalid bulletin board ID format.");
|
|
33054
33109
|
}
|
|
@@ -33078,13 +33133,13 @@ function useBulletinBoardRepo() {
|
|
|
33078
33133
|
async function updateBulletinBoardById(_id, value, session) {
|
|
33079
33134
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
33080
33135
|
try {
|
|
33081
|
-
_id = new
|
|
33136
|
+
_id = new ObjectId82(_id);
|
|
33082
33137
|
} catch (error) {
|
|
33083
33138
|
throw new BadRequestError129("Invalid ID format.");
|
|
33084
33139
|
}
|
|
33085
33140
|
if (value.site && typeof value.site === "string") {
|
|
33086
33141
|
try {
|
|
33087
|
-
value.site = new
|
|
33142
|
+
value.site = new ObjectId82(value.site);
|
|
33088
33143
|
} catch {
|
|
33089
33144
|
throw new Error("Invalid site ID.");
|
|
33090
33145
|
}
|
|
@@ -33115,7 +33170,7 @@ function useBulletinBoardRepo() {
|
|
|
33115
33170
|
}
|
|
33116
33171
|
async function deleteBulletinBoardById(_id, session) {
|
|
33117
33172
|
try {
|
|
33118
|
-
_id = new
|
|
33173
|
+
_id = new ObjectId82(_id);
|
|
33119
33174
|
} catch (error) {
|
|
33120
33175
|
throw new BadRequestError129("Invalid bulletin board ID format.");
|
|
33121
33176
|
}
|
|
@@ -33549,7 +33604,7 @@ function useBulletinBoardController() {
|
|
|
33549
33604
|
|
|
33550
33605
|
// src/models/site-billing-item.model.ts
|
|
33551
33606
|
import { BadRequestError as BadRequestError131, logger as logger109 } from "@7365admin1/node-server-utils";
|
|
33552
|
-
import { ObjectId as
|
|
33607
|
+
import { ObjectId as ObjectId83 } from "mongodb";
|
|
33553
33608
|
import Joi79 from "joi";
|
|
33554
33609
|
|
|
33555
33610
|
// src/types/enums/billing-frequency.enum.ts
|
|
@@ -33620,21 +33675,21 @@ function MBillingItem(value) {
|
|
|
33620
33675
|
}
|
|
33621
33676
|
if (value._id && typeof value._id === "string") {
|
|
33622
33677
|
try {
|
|
33623
|
-
value._id = new
|
|
33678
|
+
value._id = new ObjectId83(value._id);
|
|
33624
33679
|
} catch {
|
|
33625
33680
|
throw new BadRequestError131("Invalid _id format");
|
|
33626
33681
|
}
|
|
33627
33682
|
}
|
|
33628
33683
|
if (value.site && typeof value.site === "string") {
|
|
33629
33684
|
try {
|
|
33630
|
-
value.site = new
|
|
33685
|
+
value.site = new ObjectId83(value.site);
|
|
33631
33686
|
} catch {
|
|
33632
33687
|
throw new BadRequestError131("Invalid site id format");
|
|
33633
33688
|
}
|
|
33634
33689
|
}
|
|
33635
33690
|
if (value.org && typeof value.org === "string") {
|
|
33636
33691
|
try {
|
|
33637
|
-
value.org = new
|
|
33692
|
+
value.org = new ObjectId83(value.org);
|
|
33638
33693
|
} catch {
|
|
33639
33694
|
throw new BadRequestError131("Invalid org id format");
|
|
33640
33695
|
}
|
|
@@ -33643,7 +33698,7 @@ function MBillingItem(value) {
|
|
|
33643
33698
|
value.units = value.units.map((unit) => {
|
|
33644
33699
|
if (unit._id && typeof unit._id === "string") {
|
|
33645
33700
|
try {
|
|
33646
|
-
unit._id = new
|
|
33701
|
+
unit._id = new ObjectId83(unit._id);
|
|
33647
33702
|
} catch {
|
|
33648
33703
|
throw new BadRequestError131("Invalid unit id format");
|
|
33649
33704
|
}
|
|
@@ -33652,7 +33707,7 @@ function MBillingItem(value) {
|
|
|
33652
33707
|
});
|
|
33653
33708
|
}
|
|
33654
33709
|
return {
|
|
33655
|
-
_id: value._id ?? new
|
|
33710
|
+
_id: value._id ?? new ObjectId83(),
|
|
33656
33711
|
site: value.site,
|
|
33657
33712
|
org: value.org,
|
|
33658
33713
|
name: value.name,
|
|
@@ -33689,7 +33744,7 @@ import {
|
|
|
33689
33744
|
paginate as paginate36,
|
|
33690
33745
|
makeCacheKey as makeCacheKey41
|
|
33691
33746
|
} from "@7365admin1/node-server-utils";
|
|
33692
|
-
import { ObjectId as
|
|
33747
|
+
import { ObjectId as ObjectId84 } from "mongodb";
|
|
33693
33748
|
function useSiteBillingItemRepo() {
|
|
33694
33749
|
const db = useAtlas69.getDb();
|
|
33695
33750
|
if (!db) {
|
|
@@ -33776,7 +33831,7 @@ function useSiteBillingItemRepo() {
|
|
|
33776
33831
|
}
|
|
33777
33832
|
]
|
|
33778
33833
|
},
|
|
33779
|
-
...
|
|
33834
|
+
...ObjectId84.isValid(site) && { site: new ObjectId84(site) }
|
|
33780
33835
|
};
|
|
33781
33836
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
33782
33837
|
const cacheOptions = {
|
|
@@ -33816,7 +33871,7 @@ function useSiteBillingItemRepo() {
|
|
|
33816
33871
|
}
|
|
33817
33872
|
async function getById(_id, session) {
|
|
33818
33873
|
try {
|
|
33819
|
-
_id = new
|
|
33874
|
+
_id = new ObjectId84(_id);
|
|
33820
33875
|
} catch (error) {
|
|
33821
33876
|
throw new BadRequestError132("Invalid ID.");
|
|
33822
33877
|
}
|
|
@@ -33855,22 +33910,22 @@ function useSiteBillingItemRepo() {
|
|
|
33855
33910
|
}
|
|
33856
33911
|
async function updateById(_id, value, session) {
|
|
33857
33912
|
try {
|
|
33858
|
-
_id = new
|
|
33913
|
+
_id = new ObjectId84(_id);
|
|
33859
33914
|
} catch (error) {
|
|
33860
33915
|
throw new BadRequestError132(
|
|
33861
33916
|
"Invalid site billing item transaction ID format."
|
|
33862
33917
|
);
|
|
33863
33918
|
}
|
|
33864
|
-
if (value.site &&
|
|
33919
|
+
if (value.site && ObjectId84.isValid(value.site.toString())) {
|
|
33865
33920
|
try {
|
|
33866
|
-
value.site = new
|
|
33921
|
+
value.site = new ObjectId84(value.site.toString());
|
|
33867
33922
|
} catch {
|
|
33868
33923
|
throw new BadRequestError132("Invalid _id format");
|
|
33869
33924
|
}
|
|
33870
33925
|
}
|
|
33871
|
-
if (value.org &&
|
|
33926
|
+
if (value.org && ObjectId84.isValid(value.org.toString())) {
|
|
33872
33927
|
try {
|
|
33873
|
-
value.org = new
|
|
33928
|
+
value.org = new ObjectId84(value.org.toString());
|
|
33874
33929
|
} catch {
|
|
33875
33930
|
throw new BadRequestError132("Invalid _id format");
|
|
33876
33931
|
}
|
|
@@ -33890,7 +33945,7 @@ function useSiteBillingItemRepo() {
|
|
|
33890
33945
|
}
|
|
33891
33946
|
async function deleteById(_id) {
|
|
33892
33947
|
try {
|
|
33893
|
-
_id = new
|
|
33948
|
+
_id = new ObjectId84(_id);
|
|
33894
33949
|
} catch (error) {
|
|
33895
33950
|
throw new BadRequestError132(
|
|
33896
33951
|
"Invalid site billing item transaction ID format."
|
|
@@ -33960,7 +34015,7 @@ import {
|
|
|
33960
34015
|
|
|
33961
34016
|
// src/models/site-billing-configuration.model.ts
|
|
33962
34017
|
import { BadRequestError as BadRequestError133, logger as logger111 } from "@7365admin1/node-server-utils";
|
|
33963
|
-
import { ObjectId as
|
|
34018
|
+
import { ObjectId as ObjectId85 } from "mongodb";
|
|
33964
34019
|
import Joi80 from "joi";
|
|
33965
34020
|
var schemaBillingConfiguration = Joi80.object({
|
|
33966
34021
|
_id: Joi80.string().hex().optional(),
|
|
@@ -34021,34 +34076,34 @@ function MBillingConfiguration(value) {
|
|
|
34021
34076
|
}
|
|
34022
34077
|
if (value._id && typeof value._id === "string") {
|
|
34023
34078
|
try {
|
|
34024
|
-
value._id = new
|
|
34079
|
+
value._id = new ObjectId85(value._id);
|
|
34025
34080
|
} catch {
|
|
34026
34081
|
throw new BadRequestError133("Invalid _id format");
|
|
34027
34082
|
}
|
|
34028
34083
|
}
|
|
34029
34084
|
if (value.site && typeof value.site === "string") {
|
|
34030
34085
|
try {
|
|
34031
|
-
value.site = new
|
|
34086
|
+
value.site = new ObjectId85(value.site);
|
|
34032
34087
|
} catch {
|
|
34033
34088
|
throw new BadRequestError133("Invalid site id format");
|
|
34034
34089
|
}
|
|
34035
34090
|
}
|
|
34036
34091
|
if (value.org && typeof value.org === "string") {
|
|
34037
34092
|
try {
|
|
34038
|
-
value.org = new
|
|
34093
|
+
value.org = new ObjectId85(value.org);
|
|
34039
34094
|
} catch {
|
|
34040
34095
|
throw new BadRequestError133("Invalid org id format");
|
|
34041
34096
|
}
|
|
34042
34097
|
}
|
|
34043
34098
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
34044
34099
|
try {
|
|
34045
|
-
value.createdBy = new
|
|
34100
|
+
value.createdBy = new ObjectId85(value.createdBy);
|
|
34046
34101
|
} catch {
|
|
34047
34102
|
throw new BadRequestError133("Invalid createdBy id format");
|
|
34048
34103
|
}
|
|
34049
34104
|
}
|
|
34050
34105
|
return {
|
|
34051
|
-
_id: value._id ?? new
|
|
34106
|
+
_id: value._id ?? new ObjectId85(),
|
|
34052
34107
|
site: value.site,
|
|
34053
34108
|
org: value.org,
|
|
34054
34109
|
siteName: value.siteName,
|
|
@@ -34077,7 +34132,7 @@ function MBillingConfiguration(value) {
|
|
|
34077
34132
|
}
|
|
34078
34133
|
|
|
34079
34134
|
// src/repositories/site-billing-configuration.repo.ts
|
|
34080
|
-
import { ObjectId as
|
|
34135
|
+
import { ObjectId as ObjectId86 } from "mongodb";
|
|
34081
34136
|
function useSiteBillingConfigurationRepo() {
|
|
34082
34137
|
const db = useAtlas70.getDb();
|
|
34083
34138
|
if (!db) {
|
|
@@ -34150,7 +34205,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34150
34205
|
const query = {
|
|
34151
34206
|
status,
|
|
34152
34207
|
...search && { $text: { $search: search } },
|
|
34153
|
-
...
|
|
34208
|
+
...ObjectId86.isValid(site) && { site: new ObjectId86(site) }
|
|
34154
34209
|
};
|
|
34155
34210
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
34156
34211
|
const cacheOptions = {
|
|
@@ -34190,7 +34245,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34190
34245
|
}
|
|
34191
34246
|
async function getById(_id) {
|
|
34192
34247
|
try {
|
|
34193
|
-
_id = new
|
|
34248
|
+
_id = new ObjectId86(_id);
|
|
34194
34249
|
} catch (error) {
|
|
34195
34250
|
throw new BadRequestError134("Invalid ID.");
|
|
34196
34251
|
}
|
|
@@ -34231,22 +34286,22 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34231
34286
|
}
|
|
34232
34287
|
async function updateById(_id, value, session) {
|
|
34233
34288
|
try {
|
|
34234
|
-
_id = new
|
|
34289
|
+
_id = new ObjectId86(_id);
|
|
34235
34290
|
} catch (error) {
|
|
34236
34291
|
throw new BadRequestError134(
|
|
34237
34292
|
"Invalid site billing configuration transaction ID format."
|
|
34238
34293
|
);
|
|
34239
34294
|
}
|
|
34240
|
-
if (value.site &&
|
|
34295
|
+
if (value.site && ObjectId86.isValid(value.site.toString())) {
|
|
34241
34296
|
try {
|
|
34242
|
-
value.site = new
|
|
34297
|
+
value.site = new ObjectId86(value.site.toString());
|
|
34243
34298
|
} catch {
|
|
34244
34299
|
throw new BadRequestError134("Invalid _id format");
|
|
34245
34300
|
}
|
|
34246
34301
|
}
|
|
34247
|
-
if (value.org &&
|
|
34302
|
+
if (value.org && ObjectId86.isValid(value.org.toString())) {
|
|
34248
34303
|
try {
|
|
34249
|
-
value.org = new
|
|
34304
|
+
value.org = new ObjectId86(value.org.toString());
|
|
34250
34305
|
} catch {
|
|
34251
34306
|
throw new BadRequestError134("Invalid _id format");
|
|
34252
34307
|
}
|
|
@@ -34266,7 +34321,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34266
34321
|
}
|
|
34267
34322
|
async function deleteById(_id) {
|
|
34268
34323
|
try {
|
|
34269
|
-
_id = new
|
|
34324
|
+
_id = new ObjectId86(_id);
|
|
34270
34325
|
} catch (error) {
|
|
34271
34326
|
throw new BadRequestError134(
|
|
34272
34327
|
"Invalid site billing configuration transaction ID format."
|
|
@@ -34848,7 +34903,7 @@ function useSiteBillingConfigurationController() {
|
|
|
34848
34903
|
}
|
|
34849
34904
|
|
|
34850
34905
|
// src/models/event-management.model.ts
|
|
34851
|
-
import { ObjectId as
|
|
34906
|
+
import { ObjectId as ObjectId87 } from "mongodb";
|
|
34852
34907
|
import Joi83 from "joi";
|
|
34853
34908
|
var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
|
|
34854
34909
|
EventStatus2["PLANNED"] = "planned";
|
|
@@ -34892,20 +34947,20 @@ var schemaUpdateEventManagement = Joi83.object({
|
|
|
34892
34947
|
function MEventManagement(value) {
|
|
34893
34948
|
if (value._id && typeof value._id === "string") {
|
|
34894
34949
|
try {
|
|
34895
|
-
value._id = new
|
|
34950
|
+
value._id = new ObjectId87(value._id);
|
|
34896
34951
|
} catch {
|
|
34897
34952
|
throw new Error("Invalid ID.");
|
|
34898
34953
|
}
|
|
34899
34954
|
}
|
|
34900
34955
|
if (value.site && typeof value.site === "string") {
|
|
34901
34956
|
try {
|
|
34902
|
-
value.site = new
|
|
34957
|
+
value.site = new ObjectId87(value.site);
|
|
34903
34958
|
} catch {
|
|
34904
34959
|
throw new Error("Invalid site ID.");
|
|
34905
34960
|
}
|
|
34906
34961
|
}
|
|
34907
34962
|
return {
|
|
34908
|
-
_id: value._id ?? new
|
|
34963
|
+
_id: value._id ?? new ObjectId87(),
|
|
34909
34964
|
site: value.site,
|
|
34910
34965
|
title: value.title,
|
|
34911
34966
|
description: value.description ?? "",
|
|
@@ -34929,7 +34984,7 @@ import {
|
|
|
34929
34984
|
useAtlas as useAtlas73,
|
|
34930
34985
|
useCache as useCache45
|
|
34931
34986
|
} from "@7365admin1/node-server-utils";
|
|
34932
|
-
import { ObjectId as
|
|
34987
|
+
import { ObjectId as ObjectId88 } from "mongodb";
|
|
34933
34988
|
var events_namespace_collection = "event-management";
|
|
34934
34989
|
function useEventManagementRepo() {
|
|
34935
34990
|
const db = useAtlas73.getDb();
|
|
@@ -34997,7 +35052,7 @@ function useEventManagementRepo() {
|
|
|
34997
35052
|
}, session) {
|
|
34998
35053
|
page = page > 0 ? page - 1 : 0;
|
|
34999
35054
|
try {
|
|
35000
|
-
site = new
|
|
35055
|
+
site = new ObjectId88(site);
|
|
35001
35056
|
} catch (error) {
|
|
35002
35057
|
throw new BadRequestError139("Invalid site ID format.");
|
|
35003
35058
|
}
|
|
@@ -35085,7 +35140,7 @@ function useEventManagementRepo() {
|
|
|
35085
35140
|
}
|
|
35086
35141
|
async function getEventManagementById(_id, session) {
|
|
35087
35142
|
try {
|
|
35088
|
-
_id = new
|
|
35143
|
+
_id = new ObjectId88(_id);
|
|
35089
35144
|
} catch (error) {
|
|
35090
35145
|
throw new BadRequestError139("Invalid event ID format.");
|
|
35091
35146
|
}
|
|
@@ -35113,13 +35168,13 @@ function useEventManagementRepo() {
|
|
|
35113
35168
|
async function updateEventManagementById(_id, value, session) {
|
|
35114
35169
|
value.updatedAt = /* @__PURE__ */ new Date();
|
|
35115
35170
|
try {
|
|
35116
|
-
_id = new
|
|
35171
|
+
_id = new ObjectId88(_id);
|
|
35117
35172
|
} catch (error) {
|
|
35118
35173
|
throw new BadRequestError139("Invalid ID format.");
|
|
35119
35174
|
}
|
|
35120
35175
|
if (value.site && typeof value.site === "string") {
|
|
35121
35176
|
try {
|
|
35122
|
-
value.site = new
|
|
35177
|
+
value.site = new ObjectId88(value.site);
|
|
35123
35178
|
} catch {
|
|
35124
35179
|
throw new Error("Invalid site ID.");
|
|
35125
35180
|
}
|
|
@@ -35150,7 +35205,7 @@ function useEventManagementRepo() {
|
|
|
35150
35205
|
}
|
|
35151
35206
|
async function deleteEventManagementById(_id) {
|
|
35152
35207
|
try {
|
|
35153
|
-
_id = new
|
|
35208
|
+
_id = new ObjectId88(_id);
|
|
35154
35209
|
} catch (error) {
|
|
35155
35210
|
throw new BadRequestError139("Invalid event ID format.");
|
|
35156
35211
|
}
|
|
@@ -35438,7 +35493,7 @@ function useEventManagementController() {
|
|
|
35438
35493
|
|
|
35439
35494
|
// src/models/site-unit-billing.model.ts
|
|
35440
35495
|
import { BadRequestError as BadRequestError141, logger as logger119 } from "@7365admin1/node-server-utils";
|
|
35441
|
-
import { ObjectId as
|
|
35496
|
+
import { ObjectId as ObjectId89 } from "mongodb";
|
|
35442
35497
|
import Joi85 from "joi";
|
|
35443
35498
|
var Status = /* @__PURE__ */ ((Status2) => {
|
|
35444
35499
|
Status2["PENDING"] = "pending";
|
|
@@ -35533,48 +35588,48 @@ function MUnitBilling(value) {
|
|
|
35533
35588
|
}
|
|
35534
35589
|
if (value._id && typeof value._id === "string") {
|
|
35535
35590
|
try {
|
|
35536
|
-
value._id = new
|
|
35591
|
+
value._id = new ObjectId89(value._id);
|
|
35537
35592
|
} catch {
|
|
35538
35593
|
throw new BadRequestError141("Invalid _id format");
|
|
35539
35594
|
}
|
|
35540
35595
|
}
|
|
35541
35596
|
if (value.site && typeof value.site === "string") {
|
|
35542
35597
|
try {
|
|
35543
|
-
value.site = new
|
|
35598
|
+
value.site = new ObjectId89(value.site);
|
|
35544
35599
|
} catch {
|
|
35545
35600
|
throw new BadRequestError141("Invalid site id format");
|
|
35546
35601
|
}
|
|
35547
35602
|
}
|
|
35548
35603
|
if (value.org && typeof value.org === "string") {
|
|
35549
35604
|
try {
|
|
35550
|
-
value.org = new
|
|
35605
|
+
value.org = new ObjectId89(value.org);
|
|
35551
35606
|
} catch {
|
|
35552
35607
|
throw new BadRequestError141("Invalid org id format");
|
|
35553
35608
|
}
|
|
35554
35609
|
}
|
|
35555
35610
|
if (value.paidBy && typeof value.paidBy === "string") {
|
|
35556
35611
|
try {
|
|
35557
|
-
value.paidBy = new
|
|
35612
|
+
value.paidBy = new ObjectId89(value.paidBy);
|
|
35558
35613
|
} catch {
|
|
35559
35614
|
throw new BadRequestError141("Invalid paidBy id format");
|
|
35560
35615
|
}
|
|
35561
35616
|
}
|
|
35562
35617
|
if (value.billItem && typeof value.billItem === "string") {
|
|
35563
35618
|
try {
|
|
35564
|
-
value.billItem = new
|
|
35619
|
+
value.billItem = new ObjectId89(value.billItem);
|
|
35565
35620
|
} catch {
|
|
35566
35621
|
throw new BadRequestError141("Invalid billItem id format");
|
|
35567
35622
|
}
|
|
35568
35623
|
}
|
|
35569
35624
|
if (value.unitId && typeof value.unitId === "string") {
|
|
35570
35625
|
try {
|
|
35571
|
-
value.unitId = new
|
|
35626
|
+
value.unitId = new ObjectId89(value.unitId);
|
|
35572
35627
|
} catch {
|
|
35573
35628
|
throw new BadRequestError141("Invalid unitId id format");
|
|
35574
35629
|
}
|
|
35575
35630
|
}
|
|
35576
35631
|
return {
|
|
35577
|
-
_id: value._id ?? new
|
|
35632
|
+
_id: value._id ?? new ObjectId89(),
|
|
35578
35633
|
site: value.site ?? "",
|
|
35579
35634
|
org: value.org ?? "",
|
|
35580
35635
|
billItem: value.billItem ?? "",
|
|
@@ -35619,7 +35674,7 @@ import {
|
|
|
35619
35674
|
paginate as paginate39,
|
|
35620
35675
|
makeCacheKey as makeCacheKey44
|
|
35621
35676
|
} from "@7365admin1/node-server-utils";
|
|
35622
|
-
import { ObjectId as
|
|
35677
|
+
import { ObjectId as ObjectId90 } from "mongodb";
|
|
35623
35678
|
function useSiteUnitBillingRepo() {
|
|
35624
35679
|
const db = useAtlas75.getDb();
|
|
35625
35680
|
if (!db) {
|
|
@@ -35669,7 +35724,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35669
35724
|
const res = await collection.insertOne(value, { session });
|
|
35670
35725
|
const acronym = createAcronym(value.billName || "NA");
|
|
35671
35726
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
|
|
35672
|
-
const newId = new
|
|
35727
|
+
const newId = new ObjectId90(res.insertedId).toString().slice(-6);
|
|
35673
35728
|
const referenceNumber = `${acronym}${newId}${dateFormatted}`;
|
|
35674
35729
|
await collection.updateOne(
|
|
35675
35730
|
{ _id: res.insertedId },
|
|
@@ -35747,7 +35802,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35747
35802
|
}
|
|
35748
35803
|
]
|
|
35749
35804
|
},
|
|
35750
|
-
...
|
|
35805
|
+
...ObjectId90.isValid(site) && { site: new ObjectId90(site) },
|
|
35751
35806
|
...dateExpr
|
|
35752
35807
|
};
|
|
35753
35808
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -35813,7 +35868,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35813
35868
|
}
|
|
35814
35869
|
async function getById(_id) {
|
|
35815
35870
|
try {
|
|
35816
|
-
_id = new
|
|
35871
|
+
_id = new ObjectId90(_id);
|
|
35817
35872
|
} catch (error) {
|
|
35818
35873
|
throw new BadRequestError142("Invalid ID.");
|
|
35819
35874
|
}
|
|
@@ -35872,8 +35927,8 @@ function useSiteUnitBillingRepo() {
|
|
|
35872
35927
|
}
|
|
35873
35928
|
const query = {
|
|
35874
35929
|
status,
|
|
35875
|
-
...unitId &&
|
|
35876
|
-
...site &&
|
|
35930
|
+
...unitId && ObjectId90.isValid(unitId) && { unitId: new ObjectId90(unitId) },
|
|
35931
|
+
...site && ObjectId90.isValid(site) && { site: new ObjectId90(site) },
|
|
35877
35932
|
...dateExpr
|
|
35878
35933
|
};
|
|
35879
35934
|
try {
|
|
@@ -35911,43 +35966,43 @@ function useSiteUnitBillingRepo() {
|
|
|
35911
35966
|
}
|
|
35912
35967
|
async function updateById(_id, value, session) {
|
|
35913
35968
|
try {
|
|
35914
|
-
_id = new
|
|
35969
|
+
_id = new ObjectId90(_id);
|
|
35915
35970
|
} catch (error) {
|
|
35916
35971
|
throw new BadRequestError142(
|
|
35917
35972
|
"Invalid site unit billing transaction ID format."
|
|
35918
35973
|
);
|
|
35919
35974
|
}
|
|
35920
|
-
if (value.site &&
|
|
35975
|
+
if (value.site && ObjectId90.isValid(value.site.toString())) {
|
|
35921
35976
|
try {
|
|
35922
|
-
value.site = new
|
|
35977
|
+
value.site = new ObjectId90(value.site.toString());
|
|
35923
35978
|
} catch {
|
|
35924
35979
|
throw new BadRequestError142("Invalid _id format");
|
|
35925
35980
|
}
|
|
35926
35981
|
}
|
|
35927
|
-
if (value.org &&
|
|
35982
|
+
if (value.org && ObjectId90.isValid(value.org.toString())) {
|
|
35928
35983
|
try {
|
|
35929
|
-
value.org = new
|
|
35984
|
+
value.org = new ObjectId90(value.org.toString());
|
|
35930
35985
|
} catch {
|
|
35931
35986
|
throw new BadRequestError142("Invalid _id format");
|
|
35932
35987
|
}
|
|
35933
35988
|
}
|
|
35934
|
-
if (value.paidBy &&
|
|
35989
|
+
if (value.paidBy && ObjectId90.isValid(value.paidBy.toString())) {
|
|
35935
35990
|
try {
|
|
35936
|
-
value.org = new
|
|
35991
|
+
value.org = new ObjectId90(value.paidBy.toString());
|
|
35937
35992
|
} catch {
|
|
35938
35993
|
throw new BadRequestError142("Invalid _id format");
|
|
35939
35994
|
}
|
|
35940
35995
|
}
|
|
35941
|
-
if (value.billItem &&
|
|
35996
|
+
if (value.billItem && ObjectId90.isValid(value.billItem.toString())) {
|
|
35942
35997
|
try {
|
|
35943
|
-
value.billItem = new
|
|
35998
|
+
value.billItem = new ObjectId90(value.billItem.toString());
|
|
35944
35999
|
} catch {
|
|
35945
36000
|
throw new BadRequestError142("Invalid _id format");
|
|
35946
36001
|
}
|
|
35947
36002
|
}
|
|
35948
|
-
if (value.unitId &&
|
|
36003
|
+
if (value.unitId && ObjectId90.isValid(value.unitId.toString())) {
|
|
35949
36004
|
try {
|
|
35950
|
-
value.unitId = new
|
|
36005
|
+
value.unitId = new ObjectId90(value.unitId.toString());
|
|
35951
36006
|
} catch {
|
|
35952
36007
|
throw new BadRequestError142("Invalid _id format");
|
|
35953
36008
|
}
|
|
@@ -35967,7 +36022,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35967
36022
|
}
|
|
35968
36023
|
async function deleteById(_id) {
|
|
35969
36024
|
try {
|
|
35970
|
-
_id = new
|
|
36025
|
+
_id = new ObjectId90(_id);
|
|
35971
36026
|
} catch (error) {
|
|
35972
36027
|
throw new BadRequestError142(
|
|
35973
36028
|
"Invalid site unit billing transaction ID format."
|
|
@@ -36033,9 +36088,9 @@ function useSiteUnitBillingRepo() {
|
|
|
36033
36088
|
}
|
|
36034
36089
|
]
|
|
36035
36090
|
},
|
|
36036
|
-
...
|
|
36091
|
+
...ObjectId90.isValid(site) && { site: new ObjectId90(site) },
|
|
36037
36092
|
...dateExpr,
|
|
36038
|
-
...
|
|
36093
|
+
...ObjectId90.isValid(unitId) && { unitId: new ObjectId90(unitId) }
|
|
36039
36094
|
};
|
|
36040
36095
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36041
36096
|
try {
|
|
@@ -36122,9 +36177,9 @@ function useSiteUnitBillingRepo() {
|
|
|
36122
36177
|
}
|
|
36123
36178
|
]
|
|
36124
36179
|
},
|
|
36125
|
-
...
|
|
36180
|
+
...ObjectId90.isValid(site) && { site: new ObjectId90(site) },
|
|
36126
36181
|
...dateExpr,
|
|
36127
|
-
...
|
|
36182
|
+
...ObjectId90.isValid(unitId) && { unitId: new ObjectId90(unitId) }
|
|
36128
36183
|
};
|
|
36129
36184
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36130
36185
|
try {
|
|
@@ -36211,7 +36266,7 @@ import {
|
|
|
36211
36266
|
logger as logger121,
|
|
36212
36267
|
useAtlas as useAtlas76
|
|
36213
36268
|
} from "@7365admin1/node-server-utils";
|
|
36214
|
-
import { ObjectId as
|
|
36269
|
+
import { ObjectId as ObjectId91 } from "mongodb";
|
|
36215
36270
|
function useSiteUnitBillingService() {
|
|
36216
36271
|
const {
|
|
36217
36272
|
add: _add,
|
|
@@ -36368,7 +36423,7 @@ function useSiteUnitBillingService() {
|
|
|
36368
36423
|
return unitsWithOwner || [];
|
|
36369
36424
|
} else {
|
|
36370
36425
|
if (units && units.length > 0) {
|
|
36371
|
-
const unitIds = units.map((unit) => new
|
|
36426
|
+
const unitIds = units.map((unit) => new ObjectId91(unit._id));
|
|
36372
36427
|
const specificUnitsWithOwner = await _getBuildingUnitsWithOwner(
|
|
36373
36428
|
site || "",
|
|
36374
36429
|
unitIds
|
|
@@ -36649,7 +36704,7 @@ function useSiteUnitBillingController() {
|
|
|
36649
36704
|
}
|
|
36650
36705
|
|
|
36651
36706
|
// src/models/access-management.model.ts
|
|
36652
|
-
import { ObjectId as
|
|
36707
|
+
import { ObjectId as ObjectId92 } from "mongodb";
|
|
36653
36708
|
var EAccessCardTypes = /* @__PURE__ */ ((EAccessCardTypes2) => {
|
|
36654
36709
|
EAccessCardTypes2["NFC"] = "NFC";
|
|
36655
36710
|
EAccessCardTypes2["QR"] = "QRCODE";
|
|
@@ -36671,7 +36726,7 @@ var AccessTypeProps = /* @__PURE__ */ ((AccessTypeProps2) => {
|
|
|
36671
36726
|
})(AccessTypeProps || {});
|
|
36672
36727
|
var MAccessCardTransaction = class {
|
|
36673
36728
|
constructor({
|
|
36674
|
-
_id = new
|
|
36729
|
+
_id = new ObjectId92(),
|
|
36675
36730
|
index,
|
|
36676
36731
|
site,
|
|
36677
36732
|
cardNo,
|
|
@@ -36698,7 +36753,7 @@ var MAccessCardTransaction = class {
|
|
|
36698
36753
|
};
|
|
36699
36754
|
var MAccessCard = class {
|
|
36700
36755
|
constructor({
|
|
36701
|
-
_id = new
|
|
36756
|
+
_id = new ObjectId92(),
|
|
36702
36757
|
userId,
|
|
36703
36758
|
site,
|
|
36704
36759
|
staffNo = null,
|
|
@@ -36760,7 +36815,7 @@ import {
|
|
|
36760
36815
|
paginate as paginate40,
|
|
36761
36816
|
useAtlas as useAtlas77
|
|
36762
36817
|
} from "@7365admin1/node-server-utils";
|
|
36763
|
-
import { ObjectId as
|
|
36818
|
+
import { ObjectId as ObjectId93 } from "mongodb";
|
|
36764
36819
|
|
|
36765
36820
|
// src/utils/access-management.ts
|
|
36766
36821
|
import fs3 from "fs";
|
|
@@ -37070,12 +37125,12 @@ function UseAccessManagementRepo() {
|
|
|
37070
37125
|
payload
|
|
37071
37126
|
}) {
|
|
37072
37127
|
try {
|
|
37073
|
-
payload.site = new
|
|
37128
|
+
payload.site = new ObjectId93(payload.site);
|
|
37074
37129
|
payload.startDate = new Date(payload.startDate);
|
|
37075
37130
|
payload.endDate = new Date(payload.endDate);
|
|
37076
37131
|
payload.createdAt = new Date(payload.createdAt);
|
|
37077
37132
|
payload.updatedAt = new Date(payload.updatedAt);
|
|
37078
|
-
payload.assignedUnit = payload.unit?.map((id) => new
|
|
37133
|
+
payload.assignedUnit = payload.unit?.map((id) => new ObjectId93(id));
|
|
37079
37134
|
delete payload.unit;
|
|
37080
37135
|
const accessCardObj = new MAccessCard(payload);
|
|
37081
37136
|
const result = await collection().insertOne(accessCardObj);
|
|
@@ -37114,7 +37169,7 @@ function UseAccessManagementRepo() {
|
|
|
37114
37169
|
async function addNonPhysicalCardRepo(params) {
|
|
37115
37170
|
try {
|
|
37116
37171
|
const MAX_RETRIES = 3;
|
|
37117
|
-
const site = new
|
|
37172
|
+
const site = new ObjectId93(params.site);
|
|
37118
37173
|
const date = /* @__PURE__ */ new Date();
|
|
37119
37174
|
const endDate = new Date(date.setFullYear(date.getFullYear() + 10));
|
|
37120
37175
|
const countPerUnit = params.quantity;
|
|
@@ -37146,7 +37201,7 @@ function UseAccessManagementRepo() {
|
|
|
37146
37201
|
userType: params.userType,
|
|
37147
37202
|
doorName: params.doorName,
|
|
37148
37203
|
liftName: params.liftName,
|
|
37149
|
-
assignedUnit: new
|
|
37204
|
+
assignedUnit: new ObjectId93(units[i]),
|
|
37150
37205
|
createdAt: new Date(params.createdAt),
|
|
37151
37206
|
updatedAt: new Date(params.updatedAt),
|
|
37152
37207
|
isWinsland: params.isWinsland
|
|
@@ -37232,7 +37287,7 @@ function UseAccessManagementRepo() {
|
|
|
37232
37287
|
}
|
|
37233
37288
|
async function accessManagementSettingsRepo(params) {
|
|
37234
37289
|
try {
|
|
37235
|
-
params.site = new
|
|
37290
|
+
params.site = new ObjectId93(params.site);
|
|
37236
37291
|
const result = collectionName("entrypass-settings").updateOne(
|
|
37237
37292
|
{ site: params.site },
|
|
37238
37293
|
{
|
|
@@ -37254,7 +37309,7 @@ function UseAccessManagementRepo() {
|
|
|
37254
37309
|
}
|
|
37255
37310
|
async function allAccessCardsCountsRepo(params) {
|
|
37256
37311
|
try {
|
|
37257
|
-
const site = new
|
|
37312
|
+
const site = new ObjectId93(params.site);
|
|
37258
37313
|
const userType = params.userType;
|
|
37259
37314
|
const result = await collection().aggregate([
|
|
37260
37315
|
{
|
|
@@ -37314,7 +37369,7 @@ function UseAccessManagementRepo() {
|
|
|
37314
37369
|
}
|
|
37315
37370
|
async function availableAccessCardsRepo(params) {
|
|
37316
37371
|
try {
|
|
37317
|
-
const site = new
|
|
37372
|
+
const site = new ObjectId93(params.site);
|
|
37318
37373
|
const userType = params.userType;
|
|
37319
37374
|
const type = params.type;
|
|
37320
37375
|
const query = {
|
|
@@ -37429,7 +37484,7 @@ function UseAccessManagementRepo() {
|
|
|
37429
37484
|
}
|
|
37430
37485
|
async function userTypeAccessCardsRepo(params) {
|
|
37431
37486
|
try {
|
|
37432
|
-
const site = new
|
|
37487
|
+
const site = new ObjectId93(params.site);
|
|
37433
37488
|
const userType = params.userType;
|
|
37434
37489
|
const page = params.page ? Number(params.page) - 1 : 0;
|
|
37435
37490
|
const limit = Number(params.limit) || 10;
|
|
@@ -37828,7 +37883,7 @@ function UseAccessManagementRepo() {
|
|
|
37828
37883
|
}
|
|
37829
37884
|
async function assignedAccessCardsRepo(params) {
|
|
37830
37885
|
try {
|
|
37831
|
-
const site = new
|
|
37886
|
+
const site = new ObjectId93(params.site);
|
|
37832
37887
|
const userType = params.userType;
|
|
37833
37888
|
const type = params.type;
|
|
37834
37889
|
const search = params.search;
|
|
@@ -38003,12 +38058,12 @@ function UseAccessManagementRepo() {
|
|
|
38003
38058
|
session?.startTransaction();
|
|
38004
38059
|
const { userId, cardId, site } = params;
|
|
38005
38060
|
const allUserId = await Promise.all(
|
|
38006
|
-
userId.map(async (id) => new
|
|
38061
|
+
userId.map(async (id) => new ObjectId93(id))
|
|
38007
38062
|
);
|
|
38008
38063
|
const allCardId = await Promise.all(
|
|
38009
|
-
cardId.map(async (id) => new
|
|
38064
|
+
cardId.map(async (id) => new ObjectId93(id))
|
|
38010
38065
|
);
|
|
38011
|
-
const siteId = new
|
|
38066
|
+
const siteId = new ObjectId93(site);
|
|
38012
38067
|
const result = await collection().updateMany(
|
|
38013
38068
|
{
|
|
38014
38069
|
$or: [
|
|
@@ -38039,7 +38094,7 @@ function UseAccessManagementRepo() {
|
|
|
38039
38094
|
async function accessandLiftCardsRepo(params) {
|
|
38040
38095
|
try {
|
|
38041
38096
|
const { accessLevel, liftAccessLevel, site, userType, type } = params;
|
|
38042
|
-
const siteId = new
|
|
38097
|
+
const siteId = new ObjectId93(site);
|
|
38043
38098
|
const query = {
|
|
38044
38099
|
site: { $in: [siteId] },
|
|
38045
38100
|
userType,
|
|
@@ -38072,9 +38127,9 @@ function UseAccessManagementRepo() {
|
|
|
38072
38127
|
const session = useAtlas77.getClient()?.startSession();
|
|
38073
38128
|
try {
|
|
38074
38129
|
session?.startTransaction();
|
|
38075
|
-
const siteId = new
|
|
38076
|
-
const userId = new
|
|
38077
|
-
const cardId = new
|
|
38130
|
+
const siteId = new ObjectId93(params.site);
|
|
38131
|
+
const userId = new ObjectId93(params.userId);
|
|
38132
|
+
const cardId = new ObjectId93(params.cardId);
|
|
38078
38133
|
const quantity = 1;
|
|
38079
38134
|
const cardCredentials = await collection().findOneAndUpdate(
|
|
38080
38135
|
{ _id: cardId },
|
|
@@ -38100,7 +38155,7 @@ function UseAccessManagementRepo() {
|
|
|
38100
38155
|
(no) => no.toString().padStart(10, "0")
|
|
38101
38156
|
);
|
|
38102
38157
|
const accessCards = [];
|
|
38103
|
-
const convertedUnits = unit.map((obj) => new
|
|
38158
|
+
const convertedUnits = unit.map((obj) => new ObjectId93(obj));
|
|
38104
38159
|
for (let j = 0; j < (unit.length > 0 ? unit.length : quantity); j++) {
|
|
38105
38160
|
accessCards.push(
|
|
38106
38161
|
new MAccessCard({
|
|
@@ -38189,7 +38244,7 @@ function UseAccessManagementRepo() {
|
|
|
38189
38244
|
session?.startTransaction();
|
|
38190
38245
|
const results = [];
|
|
38191
38246
|
for (let nfc of params.nfcList) {
|
|
38192
|
-
nfc._id = new
|
|
38247
|
+
nfc._id = new ObjectId93(nfc._id);
|
|
38193
38248
|
const card = await collection().findOne({ _id: nfc._id }, { session });
|
|
38194
38249
|
if (card) {
|
|
38195
38250
|
const updateFields = {
|
|
@@ -38223,7 +38278,7 @@ function UseAccessManagementRepo() {
|
|
|
38223
38278
|
async function doorAndLiftDropdownRepo(params) {
|
|
38224
38279
|
try {
|
|
38225
38280
|
const { site, type, userType } = params;
|
|
38226
|
-
const id = new
|
|
38281
|
+
const id = new ObjectId93(site);
|
|
38227
38282
|
const res = collection().aggregate([
|
|
38228
38283
|
{
|
|
38229
38284
|
$match: {
|
|
@@ -38310,10 +38365,10 @@ function UseAccessManagementRepo() {
|
|
|
38310
38365
|
const session = useAtlas77.getClient()?.startSession();
|
|
38311
38366
|
try {
|
|
38312
38367
|
const { cardId, remarks, issuedCardId, unitId, userId } = params;
|
|
38313
|
-
const id = new
|
|
38314
|
-
const newCardId = new
|
|
38315
|
-
const unit = new
|
|
38316
|
-
const user = new
|
|
38368
|
+
const id = new ObjectId93(cardId);
|
|
38369
|
+
const newCardId = new ObjectId93(issuedCardId);
|
|
38370
|
+
const unit = new ObjectId93(unitId);
|
|
38371
|
+
const user = new ObjectId93(userId);
|
|
38317
38372
|
session?.startTransaction();
|
|
38318
38373
|
const sessionResult = await Promise.all([
|
|
38319
38374
|
await collection().findOneAndUpdate(
|
|
@@ -38346,7 +38401,7 @@ function UseAccessManagementRepo() {
|
|
|
38346
38401
|
async function visitorAccessCardsRepo(params) {
|
|
38347
38402
|
try {
|
|
38348
38403
|
const page = params.page ? params.page - 1 : 0;
|
|
38349
|
-
const siteId = new
|
|
38404
|
+
const siteId = new ObjectId93(params.site);
|
|
38350
38405
|
const search = params.search;
|
|
38351
38406
|
const type = params.type;
|
|
38352
38407
|
const limit = Number(params.limit);
|
|
@@ -38414,7 +38469,7 @@ function UseAccessManagementRepo() {
|
|
|
38414
38469
|
}
|
|
38415
38470
|
async function getCardReplacementRepo(params) {
|
|
38416
38471
|
try {
|
|
38417
|
-
const site = new
|
|
38472
|
+
const site = new ObjectId93(params.site);
|
|
38418
38473
|
const search = params.search;
|
|
38419
38474
|
const statusFilter = params.statusFilter;
|
|
38420
38475
|
const dateFrom = params.dateFrom;
|
|
@@ -38586,7 +38641,7 @@ function UseAccessManagementRepo() {
|
|
|
38586
38641
|
async function getAccessManagementSettingsRepo(params) {
|
|
38587
38642
|
try {
|
|
38588
38643
|
const { site } = params;
|
|
38589
|
-
const siteId = new
|
|
38644
|
+
const siteId = new ObjectId93(site);
|
|
38590
38645
|
const res = await collectionName("entrypass-settings").findOne(
|
|
38591
38646
|
{ site: siteId },
|
|
38592
38647
|
{ allowDiskUse: true }
|
|
@@ -38620,7 +38675,7 @@ function UseAccessManagementRepo() {
|
|
|
38620
38675
|
const rawAccessGroup = item["accessGroup (value ex. Full Access, No Access)"];
|
|
38621
38676
|
const accessGroup = typeof rawAccessGroup === "string" ? rawAccessGroup.split(",").map((v) => v.trim()).filter((v) => v !== "") : [];
|
|
38622
38677
|
return new MAccessCard({
|
|
38623
|
-
site: new
|
|
38678
|
+
site: new ObjectId93(site),
|
|
38624
38679
|
type: "NFC" /* NFC */,
|
|
38625
38680
|
staffNo: null,
|
|
38626
38681
|
accessLevel,
|
|
@@ -38671,8 +38726,8 @@ function UseAccessManagementRepo() {
|
|
|
38671
38726
|
liftAccessLevel
|
|
38672
38727
|
} = params;
|
|
38673
38728
|
const [convertedUnits, convertedSite] = await Promise.all([
|
|
38674
|
-
Promise.all(units.map((id) => new
|
|
38675
|
-
new
|
|
38729
|
+
Promise.all(units.map((id) => new ObjectId93(id))),
|
|
38730
|
+
new ObjectId93(site)
|
|
38676
38731
|
]);
|
|
38677
38732
|
const totalRequired = quantity * convertedUnits.length;
|
|
38678
38733
|
const availableCards = await collection().find({
|
|
@@ -38724,7 +38779,7 @@ function UseAccessManagementRepo() {
|
|
|
38724
38779
|
async function deleteCardRepo(params) {
|
|
38725
38780
|
try {
|
|
38726
38781
|
const { cardId, remarks } = params;
|
|
38727
|
-
const id = new
|
|
38782
|
+
const id = new ObjectId93(cardId);
|
|
38728
38783
|
const result = await collection().findOneAndUpdate(
|
|
38729
38784
|
{ _id: id },
|
|
38730
38785
|
{
|
|
@@ -38745,8 +38800,8 @@ function UseAccessManagementRepo() {
|
|
|
38745
38800
|
async function getCardDetailsRepo(params) {
|
|
38746
38801
|
try {
|
|
38747
38802
|
const { siteId, cardId } = params;
|
|
38748
|
-
const convertedSiteId = new
|
|
38749
|
-
const convertedCardId = new
|
|
38803
|
+
const convertedSiteId = new ObjectId93(siteId);
|
|
38804
|
+
const convertedCardId = new ObjectId93(cardId);
|
|
38750
38805
|
const card = await collection().findOne(
|
|
38751
38806
|
{
|
|
38752
38807
|
_id: convertedCardId,
|
|
@@ -38795,7 +38850,7 @@ function UseAccessManagementRepo() {
|
|
|
38795
38850
|
async function addQrTagRepo(params) {
|
|
38796
38851
|
try {
|
|
38797
38852
|
const { site, payload } = params;
|
|
38798
|
-
const id = new
|
|
38853
|
+
const id = new ObjectId93(site);
|
|
38799
38854
|
const highestCardNo = await collection().aggregate([
|
|
38800
38855
|
{
|
|
38801
38856
|
$match: {
|
|
@@ -38829,7 +38884,7 @@ function UseAccessManagementRepo() {
|
|
|
38829
38884
|
);
|
|
38830
38885
|
const bulkOps = await Promise.all(
|
|
38831
38886
|
payload.map(async (doc, index) => {
|
|
38832
|
-
const id2 = new
|
|
38887
|
+
const id2 = new ObjectId93(doc._id);
|
|
38833
38888
|
return {
|
|
38834
38889
|
updateOne: {
|
|
38835
38890
|
filter: { _id: id2 },
|
|
@@ -38852,7 +38907,7 @@ function UseAccessManagementRepo() {
|
|
|
38852
38907
|
async function allQrTagRepo(params) {
|
|
38853
38908
|
try {
|
|
38854
38909
|
const { site } = params;
|
|
38855
|
-
const siteId = new
|
|
38910
|
+
const siteId = new ObjectId93(site);
|
|
38856
38911
|
const query = {
|
|
38857
38912
|
site: siteId,
|
|
38858
38913
|
assignedUnit: { $ne: null },
|
|
@@ -38901,8 +38956,8 @@ function UseAccessManagementRepo() {
|
|
|
38901
38956
|
}
|
|
38902
38957
|
async function availableCardContractorsRepo(params) {
|
|
38903
38958
|
try {
|
|
38904
|
-
const siteId = new
|
|
38905
|
-
const unitId = new
|
|
38959
|
+
const siteId = new ObjectId93(params.siteId);
|
|
38960
|
+
const unitId = new ObjectId93(params.unitId);
|
|
38906
38961
|
const page = Number(params.page) - 1;
|
|
38907
38962
|
const limit = Number(params.limit) || 10;
|
|
38908
38963
|
const type = params.type;
|
|
@@ -39003,8 +39058,8 @@ function UseAccessManagementRepo() {
|
|
|
39003
39058
|
}
|
|
39004
39059
|
async function vmsgenerateQrCodesRepo(params) {
|
|
39005
39060
|
try {
|
|
39006
|
-
const site = new
|
|
39007
|
-
const unitId = new
|
|
39061
|
+
const site = new ObjectId93(params.site);
|
|
39062
|
+
const unitId = new ObjectId93(params.unitId);
|
|
39008
39063
|
const quantity = Number(params.quantity);
|
|
39009
39064
|
const normalizedUnitId = params.normalizedUnitId;
|
|
39010
39065
|
const date = /* @__PURE__ */ new Date();
|
|
@@ -39059,11 +39114,11 @@ function UseAccessManagementRepo() {
|
|
|
39059
39114
|
let isAborted = false;
|
|
39060
39115
|
try {
|
|
39061
39116
|
await session?.startTransaction();
|
|
39062
|
-
const siteId = new
|
|
39063
|
-
const unitId = new
|
|
39117
|
+
const siteId = new ObjectId93(params.site);
|
|
39118
|
+
const unitId = new ObjectId93(params.unitId);
|
|
39064
39119
|
const quantity = params.quantity;
|
|
39065
39120
|
const type = params.type;
|
|
39066
|
-
const visitorId = new
|
|
39121
|
+
const visitorId = new ObjectId93(params.visitorId);
|
|
39067
39122
|
const nfcCards = params.nfcCards;
|
|
39068
39123
|
const acm_url = params.acm_url;
|
|
39069
39124
|
let cards = [];
|
|
@@ -39085,7 +39140,7 @@ function UseAccessManagementRepo() {
|
|
|
39085
39140
|
} else if (type === "NFC" /* NFC */) {
|
|
39086
39141
|
if (nfcCards && nfcCards.length > 0) {
|
|
39087
39142
|
const objectIds = nfcCards.map(
|
|
39088
|
-
(card) => new
|
|
39143
|
+
(card) => new ObjectId93(card._id)
|
|
39089
39144
|
);
|
|
39090
39145
|
cards = await collection().find({ _id: { $in: objectIds } }).toArray();
|
|
39091
39146
|
const nfcList = objectIds.map((card) => ({
|
|
@@ -39192,7 +39247,7 @@ function UseAccessManagementRepo() {
|
|
|
39192
39247
|
}
|
|
39193
39248
|
async function signQrCodeRepo(params) {
|
|
39194
39249
|
try {
|
|
39195
|
-
const cardId = new
|
|
39250
|
+
const cardId = new ObjectId93(params.cardId);
|
|
39196
39251
|
const purpose = params.purpose;
|
|
39197
39252
|
let validity = 5;
|
|
39198
39253
|
const card = await collection().findOne({ _id: cardId });
|
|
@@ -39217,7 +39272,7 @@ function UseAccessManagementRepo() {
|
|
|
39217
39272
|
const session = useAtlas77.getClient()?.startSession();
|
|
39218
39273
|
try {
|
|
39219
39274
|
await session?.startTransaction();
|
|
39220
|
-
const userId = new
|
|
39275
|
+
const userId = new ObjectId93(params.userId);
|
|
39221
39276
|
const result = await collection().updateMany(
|
|
39222
39277
|
{ userId },
|
|
39223
39278
|
{ $set: { userId: null, status: "Available", updatedAt: /* @__PURE__ */ new Date() } }
|
|
@@ -39232,7 +39287,7 @@ function UseAccessManagementRepo() {
|
|
|
39232
39287
|
}
|
|
39233
39288
|
}
|
|
39234
39289
|
async function getBlockLevelAndUnitListRepo(params) {
|
|
39235
|
-
const site = new
|
|
39290
|
+
const site = new ObjectId93(params.site);
|
|
39236
39291
|
try {
|
|
39237
39292
|
const blocks = await collectionName("buildings").aggregate([
|
|
39238
39293
|
{
|
|
@@ -39302,7 +39357,7 @@ function UseAccessManagementRepo() {
|
|
|
39302
39357
|
url
|
|
39303
39358
|
}) {
|
|
39304
39359
|
page = page ? page - 1 : 0;
|
|
39305
|
-
site = new
|
|
39360
|
+
site = new ObjectId93(site);
|
|
39306
39361
|
try {
|
|
39307
39362
|
let index = await collectionName("access-card-transactions").findOne(
|
|
39308
39363
|
{},
|
|
@@ -39437,9 +39492,9 @@ function UseAccessManagementRepo() {
|
|
|
39437
39492
|
throw new Error("No user to Assign.");
|
|
39438
39493
|
}
|
|
39439
39494
|
assignees = assignees.map(
|
|
39440
|
-
(data) => new
|
|
39495
|
+
(data) => new ObjectId93(data)
|
|
39441
39496
|
);
|
|
39442
|
-
unit = new
|
|
39497
|
+
unit = new ObjectId93(unit);
|
|
39443
39498
|
let availableCards = [];
|
|
39444
39499
|
let update = [];
|
|
39445
39500
|
let cards = [];
|
|
@@ -39472,13 +39527,13 @@ function UseAccessManagementRepo() {
|
|
|
39472
39527
|
throw new Error(`Not enough ${type} cards available.`);
|
|
39473
39528
|
}
|
|
39474
39529
|
cards = availableCards?.slice(0, assignees.length).map((card, index) => {
|
|
39475
|
-
const userId = new
|
|
39530
|
+
const userId = new ObjectId93(assignees[index].toString());
|
|
39476
39531
|
card.staffNo = userId.toString().slice(-10);
|
|
39477
39532
|
return card;
|
|
39478
39533
|
});
|
|
39479
39534
|
update = availableCards.slice(0, assignees.length).map((card, index) => ({
|
|
39480
39535
|
_id: card._id,
|
|
39481
|
-
userId: new
|
|
39536
|
+
userId: new ObjectId93(assignees[index])
|
|
39482
39537
|
}));
|
|
39483
39538
|
const commands = cards.map((item, index) => {
|
|
39484
39539
|
let ag = null;
|
|
@@ -39544,7 +39599,7 @@ function UseAccessManagementRepo() {
|
|
|
39544
39599
|
const session = useAtlas77.getClient()?.startSession();
|
|
39545
39600
|
try {
|
|
39546
39601
|
session?.startTransaction();
|
|
39547
|
-
const id = new
|
|
39602
|
+
const id = new ObjectId93(userId);
|
|
39548
39603
|
await collection().updateMany(
|
|
39549
39604
|
{ userId: id },
|
|
39550
39605
|
{ $set: { userId: null, status: "Available" } },
|
|
@@ -39564,8 +39619,8 @@ function UseAccessManagementRepo() {
|
|
|
39564
39619
|
id,
|
|
39565
39620
|
name
|
|
39566
39621
|
}) {
|
|
39567
|
-
site = new
|
|
39568
|
-
id = new
|
|
39622
|
+
site = new ObjectId93(site);
|
|
39623
|
+
id = new ObjectId93(id);
|
|
39569
39624
|
try {
|
|
39570
39625
|
const result = await collectionName("sites").updateOne(
|
|
39571
39626
|
{ _id: site },
|
|
@@ -39582,9 +39637,9 @@ function UseAccessManagementRepo() {
|
|
|
39582
39637
|
unitId
|
|
39583
39638
|
}) {
|
|
39584
39639
|
try {
|
|
39585
|
-
orgId = new
|
|
39586
|
-
siteId = new
|
|
39587
|
-
unitId = new
|
|
39640
|
+
orgId = new ObjectId93(orgId);
|
|
39641
|
+
siteId = new ObjectId93(siteId);
|
|
39642
|
+
unitId = new ObjectId93(unitId);
|
|
39588
39643
|
const result = await collectionName("users").aggregate([
|
|
39589
39644
|
{
|
|
39590
39645
|
$match: {
|
|
@@ -39622,8 +39677,8 @@ function UseAccessManagementRepo() {
|
|
|
39622
39677
|
isLiftCard
|
|
39623
39678
|
}) {
|
|
39624
39679
|
try {
|
|
39625
|
-
siteId = new
|
|
39626
|
-
userId = new
|
|
39680
|
+
siteId = new ObjectId93(siteId);
|
|
39681
|
+
userId = new ObjectId93(userId);
|
|
39627
39682
|
const query = {
|
|
39628
39683
|
site: siteId,
|
|
39629
39684
|
userId,
|
|
@@ -39644,7 +39699,7 @@ function UseAccessManagementRepo() {
|
|
|
39644
39699
|
}
|
|
39645
39700
|
}
|
|
39646
39701
|
async function removeTemplateRepo({ site }) {
|
|
39647
|
-
site = new
|
|
39702
|
+
site = new ObjectId93(site);
|
|
39648
39703
|
try {
|
|
39649
39704
|
const result = await collectionName("entrypass-settings").updateOne({ _id: site }, { $set: { "settings.template": {} } });
|
|
39650
39705
|
return result;
|
|
@@ -39657,8 +39712,8 @@ function UseAccessManagementRepo() {
|
|
|
39657
39712
|
page = page ? page - 1 : 0;
|
|
39658
39713
|
let defaultQuery = {};
|
|
39659
39714
|
let searchQuery = {};
|
|
39660
|
-
site = new
|
|
39661
|
-
userId = new
|
|
39715
|
+
site = new ObjectId93(site);
|
|
39716
|
+
userId = new ObjectId93(userId);
|
|
39662
39717
|
if (search) {
|
|
39663
39718
|
searchQuery = {
|
|
39664
39719
|
$or: [{ fullName: { $regex: search, $options: "i" } }, { cardNo: { $regex: search, $options: "i" } }]
|
|
@@ -41404,7 +41459,7 @@ function useAccessManagementController() {
|
|
|
41404
41459
|
}
|
|
41405
41460
|
|
|
41406
41461
|
// src/models/nfc-patrol-tag.model.ts
|
|
41407
|
-
import { ObjectId as
|
|
41462
|
+
import { ObjectId as ObjectId94 } from "mongodb";
|
|
41408
41463
|
import Joi88 from "joi";
|
|
41409
41464
|
import { BadRequestError as BadRequestError146 } from "@7365admin1/node-server-utils";
|
|
41410
41465
|
var DEVICE_STATUS = {
|
|
@@ -41431,27 +41486,27 @@ var schemaNfcPatrolTag = Joi88.object({
|
|
|
41431
41486
|
function MNfcPatrolTag(value) {
|
|
41432
41487
|
if (value._id && typeof value._id === "string") {
|
|
41433
41488
|
try {
|
|
41434
|
-
value._id = new
|
|
41489
|
+
value._id = new ObjectId94(value._id);
|
|
41435
41490
|
} catch {
|
|
41436
41491
|
throw new BadRequestError146("Invalid ID.");
|
|
41437
41492
|
}
|
|
41438
41493
|
}
|
|
41439
41494
|
if (value.site && typeof value.site === "string") {
|
|
41440
41495
|
try {
|
|
41441
|
-
value.site = new
|
|
41496
|
+
value.site = new ObjectId94(value.site);
|
|
41442
41497
|
} catch {
|
|
41443
41498
|
throw new BadRequestError146("Invalid site ID.");
|
|
41444
41499
|
}
|
|
41445
41500
|
}
|
|
41446
41501
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
41447
41502
|
try {
|
|
41448
|
-
value.createdBy = new
|
|
41503
|
+
value.createdBy = new ObjectId94(value.createdBy);
|
|
41449
41504
|
} catch {
|
|
41450
41505
|
throw new BadRequestError146("Invalid Created By ID.");
|
|
41451
41506
|
}
|
|
41452
41507
|
}
|
|
41453
41508
|
return {
|
|
41454
|
-
_id: value._id ?? new
|
|
41509
|
+
_id: value._id ?? new ObjectId94(),
|
|
41455
41510
|
site: value.site,
|
|
41456
41511
|
tagID: value.tagID,
|
|
41457
41512
|
name: value.name,
|
|
@@ -41471,7 +41526,7 @@ import {
|
|
|
41471
41526
|
useAtlas as useAtlas78,
|
|
41472
41527
|
useCache as useCache48
|
|
41473
41528
|
} from "@7365admin1/node-server-utils";
|
|
41474
|
-
import { ObjectId as
|
|
41529
|
+
import { ObjectId as ObjectId95 } from "mongodb";
|
|
41475
41530
|
function useNfcPatrolTagRepo() {
|
|
41476
41531
|
const db = useAtlas78.getDb();
|
|
41477
41532
|
if (!db) {
|
|
@@ -41525,7 +41580,7 @@ function useNfcPatrolTagRepo() {
|
|
|
41525
41580
|
}, session) {
|
|
41526
41581
|
page = page > 0 ? page - 1 : 0;
|
|
41527
41582
|
try {
|
|
41528
|
-
site = new
|
|
41583
|
+
site = new ObjectId95(site);
|
|
41529
41584
|
} catch (error) {
|
|
41530
41585
|
throw new BadRequestError147("Invalid site ID format.");
|
|
41531
41586
|
}
|
|
@@ -41569,19 +41624,19 @@ function useNfcPatrolTagRepo() {
|
|
|
41569
41624
|
const [updateType, findObject, setData, session] = args;
|
|
41570
41625
|
if (findObject?.site && typeof findObject.site === "string") {
|
|
41571
41626
|
try {
|
|
41572
|
-
findObject.site = new
|
|
41627
|
+
findObject.site = new ObjectId95(findObject.site);
|
|
41573
41628
|
} catch {
|
|
41574
41629
|
throw new BadRequestError147("Invalid site ID.");
|
|
41575
41630
|
}
|
|
41576
41631
|
}
|
|
41577
41632
|
if (updateType == "Edit" && findObject?._id && typeof findObject._id === "string") {
|
|
41578
41633
|
try {
|
|
41579
|
-
findObject._id = new
|
|
41634
|
+
findObject._id = new ObjectId95(findObject._id);
|
|
41580
41635
|
} catch {
|
|
41581
41636
|
throw new BadRequestError147("Invalid nfc patrol tag document ID.");
|
|
41582
41637
|
}
|
|
41583
41638
|
try {
|
|
41584
|
-
setData.updatedBy = new
|
|
41639
|
+
setData.updatedBy = new ObjectId95(setData.updatedBy);
|
|
41585
41640
|
} catch {
|
|
41586
41641
|
throw new BadRequestError147("Invalid updatedBy ID.");
|
|
41587
41642
|
}
|
|
@@ -41872,7 +41927,7 @@ function useNfcPatrolTagController() {
|
|
|
41872
41927
|
}
|
|
41873
41928
|
|
|
41874
41929
|
// src/models/occurrence-book.model.ts
|
|
41875
|
-
import { ObjectId as
|
|
41930
|
+
import { ObjectId as ObjectId96 } from "mongodb";
|
|
41876
41931
|
import Joi90 from "joi";
|
|
41877
41932
|
var DOBStatus = /* @__PURE__ */ ((DOBStatus3) => {
|
|
41878
41933
|
DOBStatus3["OPEN"] = "open";
|
|
@@ -41898,20 +41953,20 @@ var schemaUpdateOccurrenceBook = Joi90.object({
|
|
|
41898
41953
|
function MOccurrenceBook(value) {
|
|
41899
41954
|
if (value._id && typeof value._id === "string") {
|
|
41900
41955
|
try {
|
|
41901
|
-
value._id = new
|
|
41956
|
+
value._id = new ObjectId96(value._id);
|
|
41902
41957
|
} catch {
|
|
41903
41958
|
throw new Error("Invalid ID.");
|
|
41904
41959
|
}
|
|
41905
41960
|
}
|
|
41906
41961
|
if (value.site && typeof value.site === "string") {
|
|
41907
41962
|
try {
|
|
41908
|
-
value.site = new
|
|
41963
|
+
value.site = new ObjectId96(value.site);
|
|
41909
41964
|
} catch {
|
|
41910
41965
|
throw new Error("Invalid site ID.");
|
|
41911
41966
|
}
|
|
41912
41967
|
}
|
|
41913
41968
|
return {
|
|
41914
|
-
_id: value._id ?? new
|
|
41969
|
+
_id: value._id ?? new ObjectId96(),
|
|
41915
41970
|
site: value.site,
|
|
41916
41971
|
date: value.date ?? "",
|
|
41917
41972
|
totalInput: value.totalInput ?? 0,
|
|
@@ -41936,7 +41991,7 @@ import {
|
|
|
41936
41991
|
useAtlas as useAtlas80,
|
|
41937
41992
|
useCache as useCache49
|
|
41938
41993
|
} from "@7365admin1/node-server-utils";
|
|
41939
|
-
import { ObjectId as
|
|
41994
|
+
import { ObjectId as ObjectId97 } from "mongodb";
|
|
41940
41995
|
var occurrence_book_namespace_collection = "occurrence-books";
|
|
41941
41996
|
function useOccurrenceBookRepo() {
|
|
41942
41997
|
const db = useAtlas80.getDb();
|
|
@@ -42080,7 +42135,7 @@ function useOccurrenceBookRepo() {
|
|
|
42080
42135
|
}
|
|
42081
42136
|
async function getOccurrenceBookById(_id, session) {
|
|
42082
42137
|
try {
|
|
42083
|
-
_id = new
|
|
42138
|
+
_id = new ObjectId97(_id);
|
|
42084
42139
|
} catch (error) {
|
|
42085
42140
|
throw new BadRequestError150("Invalid occurrence book ID format.");
|
|
42086
42141
|
}
|
|
@@ -42110,7 +42165,7 @@ function useOccurrenceBookRepo() {
|
|
|
42110
42165
|
async function updateOccurrenceBookById(_id, value, session) {
|
|
42111
42166
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42112
42167
|
try {
|
|
42113
|
-
_id = new
|
|
42168
|
+
_id = new ObjectId97(_id);
|
|
42114
42169
|
} catch (error) {
|
|
42115
42170
|
throw new BadRequestError150("Invalid ID format.");
|
|
42116
42171
|
}
|
|
@@ -42142,7 +42197,7 @@ function useOccurrenceBookRepo() {
|
|
|
42142
42197
|
}
|
|
42143
42198
|
async function deleteOccurrenceBookById(_id) {
|
|
42144
42199
|
try {
|
|
42145
|
-
_id = new
|
|
42200
|
+
_id = new ObjectId97(_id);
|
|
42146
42201
|
} catch (error) {
|
|
42147
42202
|
throw new BadRequestError150("Invalid occurrence book ID format.");
|
|
42148
42203
|
}
|
|
@@ -42527,7 +42582,7 @@ function useOccurrenceBookController() {
|
|
|
42527
42582
|
}
|
|
42528
42583
|
|
|
42529
42584
|
// src/models/bulletin-video.model.ts
|
|
42530
|
-
import { ObjectId as
|
|
42585
|
+
import { ObjectId as ObjectId98 } from "mongodb";
|
|
42531
42586
|
import Joi92 from "joi";
|
|
42532
42587
|
var BulletinVideoSort = /* @__PURE__ */ ((BulletinVideoSort2) => {
|
|
42533
42588
|
BulletinVideoSort2["CREATED_AT"] = "createdAt";
|
|
@@ -42555,27 +42610,27 @@ var schemaUpdateBulletinVideo = Joi92.object({
|
|
|
42555
42610
|
function MBulletinVideo(value) {
|
|
42556
42611
|
if (value._id && typeof value._id === "string") {
|
|
42557
42612
|
try {
|
|
42558
|
-
value._id = new
|
|
42613
|
+
value._id = new ObjectId98(value._id);
|
|
42559
42614
|
} catch {
|
|
42560
42615
|
throw new Error("Invalid ID.");
|
|
42561
42616
|
}
|
|
42562
42617
|
}
|
|
42563
42618
|
if (value.site && typeof value.site === "string") {
|
|
42564
42619
|
try {
|
|
42565
|
-
value.site = new
|
|
42620
|
+
value.site = new ObjectId98(value.site);
|
|
42566
42621
|
} catch {
|
|
42567
42622
|
throw new Error("Invalid site ID.");
|
|
42568
42623
|
}
|
|
42569
42624
|
}
|
|
42570
42625
|
if (value.file && typeof value.file === "string") {
|
|
42571
42626
|
try {
|
|
42572
|
-
value.file = new
|
|
42627
|
+
value.file = new ObjectId98(value.file);
|
|
42573
42628
|
} catch {
|
|
42574
42629
|
throw new Error("Invalid file ID.");
|
|
42575
42630
|
}
|
|
42576
42631
|
}
|
|
42577
42632
|
return {
|
|
42578
|
-
_id: value._id ?? new
|
|
42633
|
+
_id: value._id ?? new ObjectId98(),
|
|
42579
42634
|
site: value.site,
|
|
42580
42635
|
title: value.title ?? "",
|
|
42581
42636
|
description: value.description ?? "",
|
|
@@ -42597,7 +42652,7 @@ import {
|
|
|
42597
42652
|
useAtlas as useAtlas82,
|
|
42598
42653
|
useCache as useCache50
|
|
42599
42654
|
} from "@7365admin1/node-server-utils";
|
|
42600
|
-
import { ObjectId as
|
|
42655
|
+
import { ObjectId as ObjectId99 } from "mongodb";
|
|
42601
42656
|
function useBulletinVideoRepo() {
|
|
42602
42657
|
const db = useAtlas82.getDb();
|
|
42603
42658
|
if (!db) {
|
|
@@ -42659,7 +42714,7 @@ function useBulletinVideoRepo() {
|
|
|
42659
42714
|
}, session) {
|
|
42660
42715
|
page = page > 0 ? page - 1 : 0;
|
|
42661
42716
|
try {
|
|
42662
|
-
site = new
|
|
42717
|
+
site = new ObjectId99(site);
|
|
42663
42718
|
} catch (error) {
|
|
42664
42719
|
throw new BadRequestError152("Invalid site ID format.");
|
|
42665
42720
|
}
|
|
@@ -42739,7 +42794,7 @@ function useBulletinVideoRepo() {
|
|
|
42739
42794
|
}
|
|
42740
42795
|
async function getBulletinVideoById(_id, session) {
|
|
42741
42796
|
try {
|
|
42742
|
-
_id = new
|
|
42797
|
+
_id = new ObjectId99(_id);
|
|
42743
42798
|
} catch (error) {
|
|
42744
42799
|
throw new BadRequestError152("Invalid bulletin video ID format.");
|
|
42745
42800
|
}
|
|
@@ -42770,13 +42825,13 @@ function useBulletinVideoRepo() {
|
|
|
42770
42825
|
async function updateBulletinVideoById(_id, value, session) {
|
|
42771
42826
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42772
42827
|
try {
|
|
42773
|
-
_id = new
|
|
42828
|
+
_id = new ObjectId99(_id);
|
|
42774
42829
|
} catch (error) {
|
|
42775
42830
|
throw new BadRequestError152("Invalid ID format.");
|
|
42776
42831
|
}
|
|
42777
42832
|
if (value.file && typeof value.file === "string") {
|
|
42778
42833
|
try {
|
|
42779
|
-
value.file = new
|
|
42834
|
+
value.file = new ObjectId99(value.file);
|
|
42780
42835
|
} catch {
|
|
42781
42836
|
throw new Error("Invalid file ID.");
|
|
42782
42837
|
}
|
|
@@ -42805,7 +42860,7 @@ function useBulletinVideoRepo() {
|
|
|
42805
42860
|
}
|
|
42806
42861
|
async function deleteBulletinVideoById(_id, session) {
|
|
42807
42862
|
try {
|
|
42808
|
-
_id = new
|
|
42863
|
+
_id = new ObjectId99(_id);
|
|
42809
42864
|
} catch (error) {
|
|
42810
42865
|
throw new BadRequestError152("Invalid bulletin video ID format.");
|
|
42811
42866
|
}
|
|
@@ -43069,7 +43124,7 @@ function useBulletinVideoController() {
|
|
|
43069
43124
|
|
|
43070
43125
|
// src/models/site-soa.model.ts
|
|
43071
43126
|
import { BadRequestError as BadRequestError154, logger as logger130 } from "@7365admin1/node-server-utils";
|
|
43072
|
-
import { ObjectId as
|
|
43127
|
+
import { ObjectId as ObjectId100 } from "mongodb";
|
|
43073
43128
|
import Joi94 from "joi";
|
|
43074
43129
|
var schemaSOABillingItem = Joi94.object({
|
|
43075
43130
|
_id: Joi94.string().required(),
|
|
@@ -43137,28 +43192,28 @@ function MStatementOfAccount(value) {
|
|
|
43137
43192
|
}
|
|
43138
43193
|
if (value._id && typeof value._id === "string") {
|
|
43139
43194
|
try {
|
|
43140
|
-
value._id = new
|
|
43195
|
+
value._id = new ObjectId100(value._id);
|
|
43141
43196
|
} catch {
|
|
43142
43197
|
throw new BadRequestError154("Invalid _id format");
|
|
43143
43198
|
}
|
|
43144
43199
|
}
|
|
43145
43200
|
if (value.site && typeof value.site === "string") {
|
|
43146
43201
|
try {
|
|
43147
|
-
value.site = new
|
|
43202
|
+
value.site = new ObjectId100(value.site);
|
|
43148
43203
|
} catch {
|
|
43149
43204
|
throw new BadRequestError154("Invalid site format");
|
|
43150
43205
|
}
|
|
43151
43206
|
}
|
|
43152
43207
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
43153
43208
|
try {
|
|
43154
|
-
value.createdBy = new
|
|
43209
|
+
value.createdBy = new ObjectId100(value.createdBy);
|
|
43155
43210
|
} catch {
|
|
43156
43211
|
throw new BadRequestError154("Invalid createBy format");
|
|
43157
43212
|
}
|
|
43158
43213
|
}
|
|
43159
43214
|
if (value.unitId && typeof value.unitId === "string") {
|
|
43160
43215
|
try {
|
|
43161
|
-
value.unitId = new
|
|
43216
|
+
value.unitId = new ObjectId100(value.unitId);
|
|
43162
43217
|
} catch {
|
|
43163
43218
|
throw new BadRequestError154("Invalid unitId format");
|
|
43164
43219
|
}
|
|
@@ -43167,7 +43222,7 @@ function MStatementOfAccount(value) {
|
|
|
43167
43222
|
value.billing = value.billing.map((bill) => {
|
|
43168
43223
|
if (bill._id && typeof bill._id === "string") {
|
|
43169
43224
|
try {
|
|
43170
|
-
bill._id = new
|
|
43225
|
+
bill._id = new ObjectId100(bill._id);
|
|
43171
43226
|
} catch {
|
|
43172
43227
|
throw new BadRequestError154("Invalid billing id format");
|
|
43173
43228
|
}
|
|
@@ -43176,7 +43231,7 @@ function MStatementOfAccount(value) {
|
|
|
43176
43231
|
});
|
|
43177
43232
|
}
|
|
43178
43233
|
return {
|
|
43179
|
-
_id: value._id ?? new
|
|
43234
|
+
_id: value._id ?? new ObjectId100(),
|
|
43180
43235
|
site: value.site,
|
|
43181
43236
|
unitId: value.unitId ?? "",
|
|
43182
43237
|
unit: value.unit ?? "",
|
|
@@ -43208,7 +43263,7 @@ import {
|
|
|
43208
43263
|
paginate as paginate44,
|
|
43209
43264
|
makeCacheKey as makeCacheKey49
|
|
43210
43265
|
} from "@7365admin1/node-server-utils";
|
|
43211
|
-
import { ObjectId as
|
|
43266
|
+
import { ObjectId as ObjectId101 } from "mongodb";
|
|
43212
43267
|
function useStatementOfAccountRepo() {
|
|
43213
43268
|
const db = useAtlas84.getDb();
|
|
43214
43269
|
if (!db) {
|
|
@@ -43306,7 +43361,7 @@ function useStatementOfAccountRepo() {
|
|
|
43306
43361
|
{ category: { $regex: search, $options: "i" } }
|
|
43307
43362
|
]
|
|
43308
43363
|
},
|
|
43309
|
-
...
|
|
43364
|
+
...ObjectId101.isValid(site) && { site: new ObjectId101(site) },
|
|
43310
43365
|
...dateExpr
|
|
43311
43366
|
};
|
|
43312
43367
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -43361,7 +43416,7 @@ function useStatementOfAccountRepo() {
|
|
|
43361
43416
|
}
|
|
43362
43417
|
async function getById(_id) {
|
|
43363
43418
|
try {
|
|
43364
|
-
_id = new
|
|
43419
|
+
_id = new ObjectId101(_id);
|
|
43365
43420
|
} catch (error) {
|
|
43366
43421
|
throw new BadRequestError155("Invalid ID.");
|
|
43367
43422
|
}
|
|
@@ -43400,7 +43455,7 @@ function useStatementOfAccountRepo() {
|
|
|
43400
43455
|
}
|
|
43401
43456
|
async function updateById(_id, value, session) {
|
|
43402
43457
|
try {
|
|
43403
|
-
_id = new
|
|
43458
|
+
_id = new ObjectId101(_id);
|
|
43404
43459
|
} catch (error) {
|
|
43405
43460
|
throw new BadRequestError155("Invalid site SOA transaction ID format.");
|
|
43406
43461
|
}
|
|
@@ -43419,7 +43474,7 @@ function useStatementOfAccountRepo() {
|
|
|
43419
43474
|
}
|
|
43420
43475
|
async function deleteById(_id) {
|
|
43421
43476
|
try {
|
|
43422
|
-
_id = new
|
|
43477
|
+
_id = new ObjectId101(_id);
|
|
43423
43478
|
} catch (error) {
|
|
43424
43479
|
throw new BadRequestError155("Invalid site SOA transaction ID format.");
|
|
43425
43480
|
}
|
|
@@ -43441,7 +43496,7 @@ function useStatementOfAccountRepo() {
|
|
|
43441
43496
|
}
|
|
43442
43497
|
async function updateStatusById(_id, value, session) {
|
|
43443
43498
|
try {
|
|
43444
|
-
_id = new
|
|
43499
|
+
_id = new ObjectId101(_id);
|
|
43445
43500
|
} catch (error) {
|
|
43446
43501
|
throw new BadRequestError155("Invalid file ID format.");
|
|
43447
43502
|
}
|
|
@@ -43496,9 +43551,9 @@ function useStatementOfAccountRepo() {
|
|
|
43496
43551
|
{ category: { $regex: search, $options: "i" } }
|
|
43497
43552
|
]
|
|
43498
43553
|
},
|
|
43499
|
-
...
|
|
43554
|
+
...ObjectId101.isValid(site) && { site: new ObjectId101(site) },
|
|
43500
43555
|
...dateExpr,
|
|
43501
|
-
...
|
|
43556
|
+
...ObjectId101.isValid(unitId) && { unitId: new ObjectId101(unitId) },
|
|
43502
43557
|
...category && { category }
|
|
43503
43558
|
};
|
|
43504
43559
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -43548,7 +43603,7 @@ function useStatementOfAccountRepo() {
|
|
|
43548
43603
|
async function reviewSOA(_id, value, session) {
|
|
43549
43604
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
43550
43605
|
try {
|
|
43551
|
-
_id = new
|
|
43606
|
+
_id = new ObjectId101(_id);
|
|
43552
43607
|
} catch (error) {
|
|
43553
43608
|
throw new BadRequestError155("Invalid ID format.");
|
|
43554
43609
|
}
|
|
@@ -43597,7 +43652,7 @@ import {
|
|
|
43597
43652
|
logger as logger132,
|
|
43598
43653
|
useAtlas as useAtlas85
|
|
43599
43654
|
} from "@7365admin1/node-server-utils";
|
|
43600
|
-
import { ObjectId as
|
|
43655
|
+
import { ObjectId as ObjectId102 } from "mongodb";
|
|
43601
43656
|
import { launch } from "puppeteer";
|
|
43602
43657
|
function useStatementOfAccountService() {
|
|
43603
43658
|
const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
|
|
@@ -43734,7 +43789,7 @@ function useStatementOfAccountService() {
|
|
|
43734
43789
|
if (!approvedBy || !approvedBy.name)
|
|
43735
43790
|
throw new BadRequestError156("Created by not found.");
|
|
43736
43791
|
value.approvedBy.name = approvedBy.name;
|
|
43737
|
-
value.approvedBy._id = new
|
|
43792
|
+
value.approvedBy._id = new ObjectId102(approvedBy._id);
|
|
43738
43793
|
}
|
|
43739
43794
|
await _reviewSOA(id, value, session);
|
|
43740
43795
|
await session?.commitTransaction();
|
|
@@ -44116,7 +44171,7 @@ function useStatementOfAccountController() {
|
|
|
44116
44171
|
|
|
44117
44172
|
// src/models/site-entrypass-settings.model.ts
|
|
44118
44173
|
import { BadRequestError as BadRequestError158, logger as logger134 } from "@7365admin1/node-server-utils";
|
|
44119
|
-
import { ObjectId as
|
|
44174
|
+
import { ObjectId as ObjectId103 } from "mongodb";
|
|
44120
44175
|
import Joi96 from "joi";
|
|
44121
44176
|
var schemaEntryPassSettings = Joi96.object({
|
|
44122
44177
|
_id: Joi96.string().hex().optional().allow("", null),
|
|
@@ -44164,21 +44219,21 @@ function MEntryPassSettings(value) {
|
|
|
44164
44219
|
}
|
|
44165
44220
|
if (value._id && typeof value._id === "string") {
|
|
44166
44221
|
try {
|
|
44167
|
-
value._id = new
|
|
44222
|
+
value._id = new ObjectId103(value._id);
|
|
44168
44223
|
} catch {
|
|
44169
44224
|
throw new BadRequestError158("Invalid _id format");
|
|
44170
44225
|
}
|
|
44171
44226
|
}
|
|
44172
44227
|
if (value.site && typeof value.site === "string") {
|
|
44173
44228
|
try {
|
|
44174
|
-
value.site = new
|
|
44229
|
+
value.site = new ObjectId103(value.site);
|
|
44175
44230
|
} catch {
|
|
44176
44231
|
throw new BadRequestError158("Invalid site format");
|
|
44177
44232
|
}
|
|
44178
44233
|
}
|
|
44179
44234
|
if (value.org && typeof value.org === "string") {
|
|
44180
44235
|
try {
|
|
44181
|
-
value.org = new
|
|
44236
|
+
value.org = new ObjectId103(value.org);
|
|
44182
44237
|
} catch {
|
|
44183
44238
|
throw new BadRequestError158("Invalid org format");
|
|
44184
44239
|
}
|
|
@@ -44217,7 +44272,7 @@ import {
|
|
|
44217
44272
|
useAtlas as useAtlas86,
|
|
44218
44273
|
useCache as useCache52
|
|
44219
44274
|
} from "@7365admin1/node-server-utils";
|
|
44220
|
-
import { ObjectId as
|
|
44275
|
+
import { ObjectId as ObjectId104 } from "mongodb";
|
|
44221
44276
|
function useEntryPassSettingsRepo() {
|
|
44222
44277
|
const db = useAtlas86.getDb();
|
|
44223
44278
|
if (!db) {
|
|
@@ -44327,7 +44382,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44327
44382
|
}
|
|
44328
44383
|
async function getEntryPassSettingsById(_id) {
|
|
44329
44384
|
try {
|
|
44330
|
-
_id = new
|
|
44385
|
+
_id = new ObjectId104(_id);
|
|
44331
44386
|
} catch (error) {
|
|
44332
44387
|
throw new BadRequestError159("Invalid entry pass settings ID format.");
|
|
44333
44388
|
}
|
|
@@ -44394,7 +44449,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44394
44449
|
}
|
|
44395
44450
|
async function updateEntryPassSettingsById(_id, value) {
|
|
44396
44451
|
try {
|
|
44397
|
-
_id = new
|
|
44452
|
+
_id = new ObjectId104(_id);
|
|
44398
44453
|
} catch (error) {
|
|
44399
44454
|
throw new BadRequestError159("Invalid entry pass settings ID format.");
|
|
44400
44455
|
}
|
|
@@ -44422,7 +44477,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44422
44477
|
}
|
|
44423
44478
|
async function deleteEntryPassSettingsById(_id, session) {
|
|
44424
44479
|
try {
|
|
44425
|
-
_id = new
|
|
44480
|
+
_id = new ObjectId104(_id);
|
|
44426
44481
|
} catch (error) {
|
|
44427
44482
|
throw new BadRequestError159("Invalid card ID format.");
|
|
44428
44483
|
}
|
|
@@ -44455,7 +44510,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44455
44510
|
}
|
|
44456
44511
|
async function getEntryPassSettingsBySiteId(site) {
|
|
44457
44512
|
try {
|
|
44458
|
-
site = new
|
|
44513
|
+
site = new ObjectId104(site);
|
|
44459
44514
|
} catch (error) {
|
|
44460
44515
|
throw new BadRequestError159("Invalid entry pass settings ID format.");
|
|
44461
44516
|
}
|
|
@@ -44522,7 +44577,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44522
44577
|
}
|
|
44523
44578
|
async function updateEntryPassSettingsBySiteId(site, value) {
|
|
44524
44579
|
try {
|
|
44525
|
-
site = new
|
|
44580
|
+
site = new ObjectId104(site);
|
|
44526
44581
|
} catch (error) {
|
|
44527
44582
|
throw new BadRequestError159("Invalid entry pass settings ID format.");
|
|
44528
44583
|
}
|
|
@@ -44887,7 +44942,7 @@ function useDashboardController() {
|
|
|
44887
44942
|
}
|
|
44888
44943
|
|
|
44889
44944
|
// src/models/nfc-patrol-route.model.ts
|
|
44890
|
-
import { ObjectId as
|
|
44945
|
+
import { ObjectId as ObjectId105 } from "mongodb";
|
|
44891
44946
|
import Joi99 from "joi";
|
|
44892
44947
|
import { BadRequestError as BadRequestError162, logger as logger139 } from "@7365admin1/node-server-utils";
|
|
44893
44948
|
var schemaNfcPatrolRoute = Joi99.object({
|
|
@@ -44923,23 +44978,23 @@ function MNfcPatrolRoute(value) {
|
|
|
44923
44978
|
}
|
|
44924
44979
|
if (value._id && typeof value._id === "string") {
|
|
44925
44980
|
try {
|
|
44926
|
-
value._id = new
|
|
44981
|
+
value._id = new ObjectId105(value._id);
|
|
44927
44982
|
} catch (error2) {
|
|
44928
44983
|
throw new BadRequestError162("Invalid _id format");
|
|
44929
44984
|
}
|
|
44930
44985
|
}
|
|
44931
44986
|
try {
|
|
44932
|
-
value.site = new
|
|
44987
|
+
value.site = new ObjectId105(value.site);
|
|
44933
44988
|
} catch (error2) {
|
|
44934
44989
|
throw new BadRequestError162("Invalid site format");
|
|
44935
44990
|
}
|
|
44936
44991
|
try {
|
|
44937
|
-
value.createdBy = new
|
|
44992
|
+
value.createdBy = new ObjectId105(value.createdBy);
|
|
44938
44993
|
} catch (error2) {
|
|
44939
44994
|
throw new BadRequestError162("Invalid createdBy format");
|
|
44940
44995
|
}
|
|
44941
44996
|
return {
|
|
44942
|
-
_id: value._id ?? new
|
|
44997
|
+
_id: value._id ?? new ObjectId105(),
|
|
44943
44998
|
site: value.site,
|
|
44944
44999
|
name: value.name,
|
|
44945
45000
|
checkPointNumber: value.checkPointNumber,
|
|
@@ -44964,7 +45019,7 @@ import {
|
|
|
44964
45019
|
useAtlas as useAtlas88,
|
|
44965
45020
|
useCache as useCache54
|
|
44966
45021
|
} from "@7365admin1/node-server-utils";
|
|
44967
|
-
import { ObjectId as
|
|
45022
|
+
import { ObjectId as ObjectId106 } from "mongodb";
|
|
44968
45023
|
function useNfcPatrolRouteRepo() {
|
|
44969
45024
|
const db = useAtlas88.getDb();
|
|
44970
45025
|
if (!db) {
|
|
@@ -45008,7 +45063,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
45008
45063
|
}, session) {
|
|
45009
45064
|
page = page > 0 ? page - 1 : 0;
|
|
45010
45065
|
try {
|
|
45011
|
-
site = new
|
|
45066
|
+
site = new ObjectId106(site);
|
|
45012
45067
|
} catch (error) {
|
|
45013
45068
|
throw new BadRequestError163("Invalid site ID format.");
|
|
45014
45069
|
}
|
|
@@ -45079,7 +45134,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
45079
45134
|
}
|
|
45080
45135
|
async function getById(_id, isStart) {
|
|
45081
45136
|
try {
|
|
45082
|
-
_id = new
|
|
45137
|
+
_id = new ObjectId106(_id);
|
|
45083
45138
|
} catch (error) {
|
|
45084
45139
|
throw new BadRequestError163("Invalid ID.");
|
|
45085
45140
|
}
|
|
@@ -45189,18 +45244,18 @@ function useNfcPatrolRouteRepo() {
|
|
|
45189
45244
|
throw new BadRequestError163(error.message);
|
|
45190
45245
|
}
|
|
45191
45246
|
try {
|
|
45192
|
-
_id = new
|
|
45247
|
+
_id = new ObjectId106(_id);
|
|
45193
45248
|
} catch (error2) {
|
|
45194
45249
|
throw new BadRequestError163("Invalid ID.");
|
|
45195
45250
|
}
|
|
45196
45251
|
try {
|
|
45197
|
-
value.site = new
|
|
45252
|
+
value.site = new ObjectId106(value.site);
|
|
45198
45253
|
} catch (error2) {
|
|
45199
45254
|
throw new BadRequestError163("Invalid site format");
|
|
45200
45255
|
}
|
|
45201
45256
|
if (value.updatedBy) {
|
|
45202
45257
|
try {
|
|
45203
|
-
value.updatedBy = new
|
|
45258
|
+
value.updatedBy = new ObjectId106(value.updatedBy);
|
|
45204
45259
|
} catch (error2) {
|
|
45205
45260
|
throw new BadRequestError163("Invalid createdBy format");
|
|
45206
45261
|
}
|
|
@@ -45433,7 +45488,7 @@ function useNfcPatrolRouteController() {
|
|
|
45433
45488
|
}
|
|
45434
45489
|
|
|
45435
45490
|
// src/models/incident-report.model.ts
|
|
45436
|
-
import { ObjectId as
|
|
45491
|
+
import { ObjectId as ObjectId107 } from "mongodb";
|
|
45437
45492
|
import Joi101 from "joi";
|
|
45438
45493
|
var residentSchema = Joi101.object({
|
|
45439
45494
|
_id: Joi101.string().hex().optional().allow(null, ""),
|
|
@@ -45639,28 +45694,28 @@ var schemaUpdateIncidentReport = Joi101.object({
|
|
|
45639
45694
|
function MIncidentReport(value) {
|
|
45640
45695
|
if (value._id && typeof value._id === "string") {
|
|
45641
45696
|
try {
|
|
45642
|
-
value._id = new
|
|
45697
|
+
value._id = new ObjectId107(value._id);
|
|
45643
45698
|
} catch {
|
|
45644
45699
|
throw new Error("Invalid incident report ID.");
|
|
45645
45700
|
}
|
|
45646
45701
|
}
|
|
45647
45702
|
if (value.organization && typeof value.organization === "string") {
|
|
45648
45703
|
try {
|
|
45649
|
-
value.organization = new
|
|
45704
|
+
value.organization = new ObjectId107(value.organization);
|
|
45650
45705
|
} catch {
|
|
45651
45706
|
throw new Error("Invalid organization ID.");
|
|
45652
45707
|
}
|
|
45653
45708
|
}
|
|
45654
45709
|
if (value.site && typeof value.site === "string") {
|
|
45655
45710
|
try {
|
|
45656
|
-
value.site = new
|
|
45711
|
+
value.site = new ObjectId107(value.site);
|
|
45657
45712
|
} catch {
|
|
45658
45713
|
throw new Error("Invalid site ID.");
|
|
45659
45714
|
}
|
|
45660
45715
|
}
|
|
45661
45716
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
45662
45717
|
try {
|
|
45663
|
-
value.approvedBy = new
|
|
45718
|
+
value.approvedBy = new ObjectId107(value.approvedBy);
|
|
45664
45719
|
} catch {
|
|
45665
45720
|
throw new Error("Invalid approvedBy ID.");
|
|
45666
45721
|
}
|
|
@@ -45668,7 +45723,7 @@ function MIncidentReport(value) {
|
|
|
45668
45723
|
const { incidentInformation } = value;
|
|
45669
45724
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
45670
45725
|
try {
|
|
45671
|
-
incidentInformation.siteInfo.site = new
|
|
45726
|
+
incidentInformation.siteInfo.site = new ObjectId107(
|
|
45672
45727
|
incidentInformation.siteInfo.site
|
|
45673
45728
|
);
|
|
45674
45729
|
} catch {
|
|
@@ -45682,7 +45737,7 @@ function MIncidentReport(value) {
|
|
|
45682
45737
|
incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
|
|
45683
45738
|
}
|
|
45684
45739
|
return {
|
|
45685
|
-
_id: value._id ?? new
|
|
45740
|
+
_id: value._id ?? new ObjectId107(),
|
|
45686
45741
|
reportId: value.reportId,
|
|
45687
45742
|
incidentInformation: value.incidentInformation,
|
|
45688
45743
|
affectedEntities: value.affectedEntities,
|
|
@@ -45720,7 +45775,7 @@ import {
|
|
|
45720
45775
|
useAtlas as useAtlas90,
|
|
45721
45776
|
useCache as useCache55
|
|
45722
45777
|
} from "@7365admin1/node-server-utils";
|
|
45723
|
-
import { ObjectId as
|
|
45778
|
+
import { ObjectId as ObjectId108 } from "mongodb";
|
|
45724
45779
|
var incidents_namespace_collection = "incident-reports";
|
|
45725
45780
|
function useIncidentReportRepo() {
|
|
45726
45781
|
const db = useAtlas90.getDb();
|
|
@@ -45787,7 +45842,7 @@ function useIncidentReportRepo() {
|
|
|
45787
45842
|
page = page > 0 ? page - 1 : 0;
|
|
45788
45843
|
let dateExpr = {};
|
|
45789
45844
|
try {
|
|
45790
|
-
site = new
|
|
45845
|
+
site = new ObjectId108(site);
|
|
45791
45846
|
} catch (error) {
|
|
45792
45847
|
throw new BadRequestError166("Invalid site ID format.");
|
|
45793
45848
|
}
|
|
@@ -45888,7 +45943,7 @@ function useIncidentReportRepo() {
|
|
|
45888
45943
|
page = page > 0 ? page - 1 : 0;
|
|
45889
45944
|
let dateExpr = {};
|
|
45890
45945
|
try {
|
|
45891
|
-
site = new
|
|
45946
|
+
site = new ObjectId108(site);
|
|
45892
45947
|
} catch (error) {
|
|
45893
45948
|
throw new BadRequestError166("Invalid site ID format.");
|
|
45894
45949
|
}
|
|
@@ -45957,7 +46012,7 @@ function useIncidentReportRepo() {
|
|
|
45957
46012
|
}
|
|
45958
46013
|
async function getIncidentReportById(_id, session) {
|
|
45959
46014
|
try {
|
|
45960
|
-
_id = new
|
|
46015
|
+
_id = new ObjectId108(_id);
|
|
45961
46016
|
} catch (error) {
|
|
45962
46017
|
throw new BadRequestError166("Invalid incident report ID format.");
|
|
45963
46018
|
}
|
|
@@ -45988,27 +46043,27 @@ function useIncidentReportRepo() {
|
|
|
45988
46043
|
async function updateIncidentReportById(_id, value, session) {
|
|
45989
46044
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
45990
46045
|
try {
|
|
45991
|
-
_id = new
|
|
46046
|
+
_id = new ObjectId108(_id);
|
|
45992
46047
|
} catch (error) {
|
|
45993
46048
|
throw new BadRequestError166("Invalid ID format.");
|
|
45994
46049
|
}
|
|
45995
46050
|
if (value.organization && typeof value.organization === "string") {
|
|
45996
46051
|
try {
|
|
45997
|
-
value.organization = new
|
|
46052
|
+
value.organization = new ObjectId108(value.organization);
|
|
45998
46053
|
} catch {
|
|
45999
46054
|
throw new Error("Invalid organization ID.");
|
|
46000
46055
|
}
|
|
46001
46056
|
}
|
|
46002
46057
|
if (value.site && typeof value.site === "string") {
|
|
46003
46058
|
try {
|
|
46004
|
-
value.site = new
|
|
46059
|
+
value.site = new ObjectId108(value.site);
|
|
46005
46060
|
} catch {
|
|
46006
46061
|
throw new Error("Invalid site ID.");
|
|
46007
46062
|
}
|
|
46008
46063
|
}
|
|
46009
46064
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
46010
46065
|
try {
|
|
46011
|
-
value.approvedBy = new
|
|
46066
|
+
value.approvedBy = new ObjectId108(value.approvedBy);
|
|
46012
46067
|
} catch {
|
|
46013
46068
|
throw new Error("Invalid approvedBy ID.");
|
|
46014
46069
|
}
|
|
@@ -46016,7 +46071,7 @@ function useIncidentReportRepo() {
|
|
|
46016
46071
|
const { incidentInformation } = value;
|
|
46017
46072
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
46018
46073
|
try {
|
|
46019
|
-
incidentInformation.siteInfo.site = new
|
|
46074
|
+
incidentInformation.siteInfo.site = new ObjectId108(
|
|
46020
46075
|
incidentInformation.siteInfo.site
|
|
46021
46076
|
);
|
|
46022
46077
|
} catch {
|
|
@@ -46051,7 +46106,7 @@ function useIncidentReportRepo() {
|
|
|
46051
46106
|
}
|
|
46052
46107
|
async function deleteIncidentReportById(_id) {
|
|
46053
46108
|
try {
|
|
46054
|
-
_id = new
|
|
46109
|
+
_id = new ObjectId108(_id);
|
|
46055
46110
|
} catch (error) {
|
|
46056
46111
|
throw new BadRequestError166("Invalid occurrence subject ID format.");
|
|
46057
46112
|
}
|
|
@@ -46083,7 +46138,7 @@ function useIncidentReportRepo() {
|
|
|
46083
46138
|
async function reviewIncidentReport(_id, value, session) {
|
|
46084
46139
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
46085
46140
|
try {
|
|
46086
|
-
_id = new
|
|
46141
|
+
_id = new ObjectId108(_id);
|
|
46087
46142
|
} catch (error) {
|
|
46088
46143
|
throw new BadRequestError166("Invalid ID format.");
|
|
46089
46144
|
}
|
|
@@ -46576,7 +46631,7 @@ function useIncidentReportController() {
|
|
|
46576
46631
|
}
|
|
46577
46632
|
|
|
46578
46633
|
// src/models/nfc-patrol-settings.model.ts
|
|
46579
|
-
import { ObjectId as
|
|
46634
|
+
import { ObjectId as ObjectId109 } from "mongodb";
|
|
46580
46635
|
import Joi103 from "joi";
|
|
46581
46636
|
import { BadRequestError as BadRequestError169, logger as logger145 } from "@7365admin1/node-server-utils";
|
|
46582
46637
|
var objectId = Joi103.string().hex().length(24);
|
|
@@ -46602,7 +46657,7 @@ function MNfcPatrolSettings(value) {
|
|
|
46602
46657
|
}
|
|
46603
46658
|
if (value.site) {
|
|
46604
46659
|
try {
|
|
46605
|
-
value.site = new
|
|
46660
|
+
value.site = new ObjectId109(value.site);
|
|
46606
46661
|
} catch (error2) {
|
|
46607
46662
|
throw new BadRequestError169("Invalid site ID format.");
|
|
46608
46663
|
}
|
|
@@ -46622,7 +46677,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
46622
46677
|
}
|
|
46623
46678
|
if (value.updatedBy) {
|
|
46624
46679
|
try {
|
|
46625
|
-
value.updatedBy = new
|
|
46680
|
+
value.updatedBy = new ObjectId109(value.updatedBy);
|
|
46626
46681
|
} catch (error2) {
|
|
46627
46682
|
throw new BadRequestError169("Invalid updatedBy ID format.");
|
|
46628
46683
|
}
|
|
@@ -46644,7 +46699,7 @@ import {
|
|
|
46644
46699
|
useAtlas as useAtlas92,
|
|
46645
46700
|
useCache as useCache56
|
|
46646
46701
|
} from "@7365admin1/node-server-utils";
|
|
46647
|
-
import { ObjectId as
|
|
46702
|
+
import { ObjectId as ObjectId110 } from "mongodb";
|
|
46648
46703
|
function useNfcPatrolSettingsRepository() {
|
|
46649
46704
|
const db = useAtlas92.getDb();
|
|
46650
46705
|
if (!db) {
|
|
@@ -46674,7 +46729,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
46674
46729
|
}
|
|
46675
46730
|
async function getNfcPatrolSettingsBySite(site, session) {
|
|
46676
46731
|
try {
|
|
46677
|
-
site = new
|
|
46732
|
+
site = new ObjectId110(site);
|
|
46678
46733
|
} catch (error) {
|
|
46679
46734
|
throw new BadRequestError170("Invalid nfc patrol settings site ID format.");
|
|
46680
46735
|
}
|
|
@@ -46718,7 +46773,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
46718
46773
|
}
|
|
46719
46774
|
async function updateNfcPatrolSettings(site, value, session) {
|
|
46720
46775
|
try {
|
|
46721
|
-
site = new
|
|
46776
|
+
site = new ObjectId110(site);
|
|
46722
46777
|
} catch (error) {
|
|
46723
46778
|
throw new BadRequestError170("Invalid attendance settings ID format.");
|
|
46724
46779
|
}
|
|
@@ -46887,7 +46942,7 @@ function useNfcPatrolSettingsController() {
|
|
|
46887
46942
|
|
|
46888
46943
|
// src/services/occurrence-entry.service.ts
|
|
46889
46944
|
import { useAtlas as useAtlas95 } from "@7365admin1/node-server-utils";
|
|
46890
|
-
import { ObjectId as
|
|
46945
|
+
import { ObjectId as ObjectId113 } from "mongodb";
|
|
46891
46946
|
|
|
46892
46947
|
// src/repositories/occurrence-subject.repo.ts
|
|
46893
46948
|
import {
|
|
@@ -46902,7 +46957,7 @@ import {
|
|
|
46902
46957
|
} from "@7365admin1/node-server-utils";
|
|
46903
46958
|
|
|
46904
46959
|
// src/models/occurrence-subject.model.ts
|
|
46905
|
-
import { ObjectId as
|
|
46960
|
+
import { ObjectId as ObjectId111 } from "mongodb";
|
|
46906
46961
|
import Joi105 from "joi";
|
|
46907
46962
|
var SubjectSort = /* @__PURE__ */ ((SubjectSort2) => {
|
|
46908
46963
|
SubjectSort2["CREATED_AT"] = "createdAt";
|
|
@@ -46927,27 +46982,27 @@ var schemaUpdateOccurrenceSubject = Joi105.object({
|
|
|
46927
46982
|
function MOccurrenceSubject(value) {
|
|
46928
46983
|
if (value._id && typeof value._id === "string") {
|
|
46929
46984
|
try {
|
|
46930
|
-
value._id = new
|
|
46985
|
+
value._id = new ObjectId111(value._id);
|
|
46931
46986
|
} catch {
|
|
46932
46987
|
throw new Error("Invalid ID.");
|
|
46933
46988
|
}
|
|
46934
46989
|
}
|
|
46935
46990
|
if (value.site && typeof value.site === "string") {
|
|
46936
46991
|
try {
|
|
46937
|
-
value.site = new
|
|
46992
|
+
value.site = new ObjectId111(value.site);
|
|
46938
46993
|
} catch {
|
|
46939
46994
|
throw new Error("Invalid site ID.");
|
|
46940
46995
|
}
|
|
46941
46996
|
}
|
|
46942
46997
|
if (value.addedBy && typeof value.addedBy === "string") {
|
|
46943
46998
|
try {
|
|
46944
|
-
value.addedBy = new
|
|
46999
|
+
value.addedBy = new ObjectId111(value.addedBy);
|
|
46945
47000
|
} catch {
|
|
46946
47001
|
throw new Error("Invalid addedBy ID.");
|
|
46947
47002
|
}
|
|
46948
47003
|
}
|
|
46949
47004
|
return {
|
|
46950
|
-
_id: value._id ?? new
|
|
47005
|
+
_id: value._id ?? new ObjectId111(),
|
|
46951
47006
|
site: value.site,
|
|
46952
47007
|
subject: value.subject,
|
|
46953
47008
|
addedBy: value.addedBy ?? "",
|
|
@@ -46958,7 +47013,7 @@ function MOccurrenceSubject(value) {
|
|
|
46958
47013
|
}
|
|
46959
47014
|
|
|
46960
47015
|
// src/repositories/occurrence-subject.repo.ts
|
|
46961
|
-
import { ObjectId as
|
|
47016
|
+
import { ObjectId as ObjectId112 } from "mongodb";
|
|
46962
47017
|
function useOccurrenceSubjectRepo() {
|
|
46963
47018
|
const db = useAtlas94.getDb();
|
|
46964
47019
|
if (!db) {
|
|
@@ -47017,7 +47072,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47017
47072
|
}, session) {
|
|
47018
47073
|
page = page > 0 ? page - 1 : 0;
|
|
47019
47074
|
try {
|
|
47020
|
-
site = new
|
|
47075
|
+
site = new ObjectId112(site);
|
|
47021
47076
|
} catch (error) {
|
|
47022
47077
|
throw new BadRequestError173("Invalid site ID format.");
|
|
47023
47078
|
}
|
|
@@ -47110,7 +47165,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47110
47165
|
}
|
|
47111
47166
|
async function getOccurrenceSubjectById(_id, session) {
|
|
47112
47167
|
try {
|
|
47113
|
-
_id = new
|
|
47168
|
+
_id = new ObjectId112(_id);
|
|
47114
47169
|
} catch (error) {
|
|
47115
47170
|
throw new BadRequestError173("Invalid occurrence subject ID format.");
|
|
47116
47171
|
}
|
|
@@ -47138,7 +47193,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47138
47193
|
async function updateOccurrenceSubjectById(_id, value, session) {
|
|
47139
47194
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47140
47195
|
try {
|
|
47141
|
-
_id = new
|
|
47196
|
+
_id = new ObjectId112(_id);
|
|
47142
47197
|
} catch (error) {
|
|
47143
47198
|
throw new BadRequestError173("Invalid ID format.");
|
|
47144
47199
|
}
|
|
@@ -47168,7 +47223,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47168
47223
|
}
|
|
47169
47224
|
async function deleteOccurrenceSubjectById(_id) {
|
|
47170
47225
|
try {
|
|
47171
|
-
_id = new
|
|
47226
|
+
_id = new ObjectId112(_id);
|
|
47172
47227
|
} catch (error) {
|
|
47173
47228
|
throw new BadRequestError173("Invalid occurrence subject ID format.");
|
|
47174
47229
|
}
|
|
@@ -47299,8 +47354,8 @@ function useOccurrenceEntryService() {
|
|
|
47299
47354
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
47300
47355
|
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
47301
47356
|
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
47302
|
-
value.signature = value.signature ? new
|
|
47303
|
-
value.eSignature = value.eSignature ? new
|
|
47357
|
+
value.signature = value.signature ? new ObjectId113(value.signature) : occurrenceEntry.signature._id;
|
|
47358
|
+
value.eSignature = value.eSignature ? new ObjectId113(value.eSignature) : occurrenceEntry.eSignature;
|
|
47304
47359
|
value.createdAt = /* @__PURE__ */ new Date();
|
|
47305
47360
|
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
47306
47361
|
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
@@ -47492,7 +47547,7 @@ function useOccurrenceEntryController() {
|
|
|
47492
47547
|
|
|
47493
47548
|
// src/models/online-form.model.ts
|
|
47494
47549
|
import Joi107 from "joi";
|
|
47495
|
-
import { ObjectId as
|
|
47550
|
+
import { ObjectId as ObjectId114 } from "mongodb";
|
|
47496
47551
|
var schemaOnlineForm = Joi107.object({
|
|
47497
47552
|
_id: Joi107.string().hex().optional().allow("", null),
|
|
47498
47553
|
name: Joi107.string().required(),
|
|
@@ -47540,21 +47595,21 @@ function MOnlineForm(value) {
|
|
|
47540
47595
|
}
|
|
47541
47596
|
if (value._id && typeof value._id === "string") {
|
|
47542
47597
|
try {
|
|
47543
|
-
value._id = new
|
|
47598
|
+
value._id = new ObjectId114(value._id);
|
|
47544
47599
|
} catch (error2) {
|
|
47545
47600
|
throw new Error("Invalid ID.");
|
|
47546
47601
|
}
|
|
47547
47602
|
}
|
|
47548
47603
|
if (value.org && typeof value.org === "string") {
|
|
47549
47604
|
try {
|
|
47550
|
-
value.org = new
|
|
47605
|
+
value.org = new ObjectId114(value.org);
|
|
47551
47606
|
} catch (error2) {
|
|
47552
47607
|
throw new Error("Invalid org ID.");
|
|
47553
47608
|
}
|
|
47554
47609
|
}
|
|
47555
47610
|
if (value.site && typeof value.site === "string") {
|
|
47556
47611
|
try {
|
|
47557
|
-
value.site = new
|
|
47612
|
+
value.site = new ObjectId114(value.site);
|
|
47558
47613
|
} catch (error2) {
|
|
47559
47614
|
throw new Error("Invalid site ID.");
|
|
47560
47615
|
}
|
|
@@ -47586,7 +47641,7 @@ import {
|
|
|
47586
47641
|
useAtlas as useAtlas96,
|
|
47587
47642
|
useCache as useCache58
|
|
47588
47643
|
} from "@7365admin1/node-server-utils";
|
|
47589
|
-
import { ObjectId as
|
|
47644
|
+
import { ObjectId as ObjectId115 } from "mongodb";
|
|
47590
47645
|
function useOnlineFormRepo() {
|
|
47591
47646
|
const db = useAtlas96.getDb();
|
|
47592
47647
|
if (!db) {
|
|
@@ -47638,7 +47693,7 @@ function useOnlineFormRepo() {
|
|
|
47638
47693
|
}) {
|
|
47639
47694
|
page = page > 0 ? page - 1 : 0;
|
|
47640
47695
|
try {
|
|
47641
|
-
site = new
|
|
47696
|
+
site = new ObjectId115(site);
|
|
47642
47697
|
} catch (error) {
|
|
47643
47698
|
throw new BadRequestError175("Invalid site ID format.");
|
|
47644
47699
|
}
|
|
@@ -47698,7 +47753,7 @@ function useOnlineFormRepo() {
|
|
|
47698
47753
|
}
|
|
47699
47754
|
async function getOnlineFormById(_id) {
|
|
47700
47755
|
try {
|
|
47701
|
-
_id = new
|
|
47756
|
+
_id = new ObjectId115(_id);
|
|
47702
47757
|
} catch (error) {
|
|
47703
47758
|
throw new BadRequestError175("Invalid online form ID format.");
|
|
47704
47759
|
}
|
|
@@ -47741,7 +47796,7 @@ function useOnlineFormRepo() {
|
|
|
47741
47796
|
}
|
|
47742
47797
|
async function updateOnlineFormById(_id, value) {
|
|
47743
47798
|
try {
|
|
47744
|
-
_id = new
|
|
47799
|
+
_id = new ObjectId115(_id);
|
|
47745
47800
|
} catch (error) {
|
|
47746
47801
|
throw new BadRequestError175("Invalid online form ID format.");
|
|
47747
47802
|
}
|
|
@@ -47769,7 +47824,7 @@ function useOnlineFormRepo() {
|
|
|
47769
47824
|
}
|
|
47770
47825
|
async function deleteOnlineFormById(_id, session) {
|
|
47771
47826
|
try {
|
|
47772
|
-
_id = new
|
|
47827
|
+
_id = new ObjectId115(_id);
|
|
47773
47828
|
} catch (error) {
|
|
47774
47829
|
throw new BadRequestError175("Invalid online form ID format.");
|
|
47775
47830
|
}
|
|
@@ -47802,7 +47857,7 @@ function useOnlineFormRepo() {
|
|
|
47802
47857
|
}
|
|
47803
47858
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
47804
47859
|
try {
|
|
47805
|
-
site = new
|
|
47860
|
+
site = new ObjectId115(site);
|
|
47806
47861
|
} catch (error) {
|
|
47807
47862
|
throw new BadRequestError175(
|
|
47808
47863
|
"Invalid online form configuration site ID format."
|
|
@@ -48234,7 +48289,7 @@ function useOccurrenceSubjectController() {
|
|
|
48234
48289
|
}
|
|
48235
48290
|
|
|
48236
48291
|
// src/models/nfc-patrol-log.model.ts
|
|
48237
|
-
import { ObjectId as
|
|
48292
|
+
import { ObjectId as ObjectId116 } from "mongodb";
|
|
48238
48293
|
import Joi110 from "joi";
|
|
48239
48294
|
import { BadRequestError as BadRequestError178, logger as logger154 } from "@7365admin1/node-server-utils";
|
|
48240
48295
|
var schemaNfcPatrolLog = Joi110.object({
|
|
@@ -48286,32 +48341,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
48286
48341
|
}
|
|
48287
48342
|
if (value._id && typeof value._id === "string") {
|
|
48288
48343
|
try {
|
|
48289
|
-
value._id = new
|
|
48344
|
+
value._id = new ObjectId116(value._id);
|
|
48290
48345
|
} catch (error2) {
|
|
48291
48346
|
throw new BadRequestError178("Invalid _id format");
|
|
48292
48347
|
}
|
|
48293
48348
|
}
|
|
48294
48349
|
try {
|
|
48295
|
-
value.site = new
|
|
48350
|
+
value.site = new ObjectId116(value.site);
|
|
48296
48351
|
} catch (error2) {
|
|
48297
48352
|
throw new BadRequestError178("Invalid site format");
|
|
48298
48353
|
}
|
|
48299
48354
|
if (value?.createdBy) {
|
|
48300
48355
|
try {
|
|
48301
|
-
value.createdBy = new
|
|
48356
|
+
value.createdBy = new ObjectId116(value.createdBy);
|
|
48302
48357
|
} catch (error2) {
|
|
48303
48358
|
throw new BadRequestError178("Invalid createdBy format");
|
|
48304
48359
|
}
|
|
48305
48360
|
}
|
|
48306
48361
|
if (value?.route?._id) {
|
|
48307
48362
|
try {
|
|
48308
|
-
value.route._id = new
|
|
48363
|
+
value.route._id = new ObjectId116(value.route._id);
|
|
48309
48364
|
} catch (error2) {
|
|
48310
48365
|
throw new BadRequestError178("Invalid route _id format");
|
|
48311
48366
|
}
|
|
48312
48367
|
}
|
|
48313
48368
|
return {
|
|
48314
|
-
_id: value._id ?? new
|
|
48369
|
+
_id: value._id ?? new ObjectId116(),
|
|
48315
48370
|
site: value.site,
|
|
48316
48371
|
route: value.route,
|
|
48317
48372
|
date: value.date,
|
|
@@ -48333,7 +48388,7 @@ import {
|
|
|
48333
48388
|
useAtlas as useAtlas98,
|
|
48334
48389
|
useCache as useCache59
|
|
48335
48390
|
} from "@7365admin1/node-server-utils";
|
|
48336
|
-
import { ObjectId as
|
|
48391
|
+
import { ObjectId as ObjectId117 } from "mongodb";
|
|
48337
48392
|
function useNfcPatrolLogRepo() {
|
|
48338
48393
|
const db = useAtlas98.getDb();
|
|
48339
48394
|
if (!db) {
|
|
@@ -48386,7 +48441,7 @@ function useNfcPatrolLogRepo() {
|
|
|
48386
48441
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
48387
48442
|
let siteId;
|
|
48388
48443
|
try {
|
|
48389
|
-
siteId = typeof site === "string" ? new
|
|
48444
|
+
siteId = typeof site === "string" ? new ObjectId117(site) : site;
|
|
48390
48445
|
} catch {
|
|
48391
48446
|
throw new BadRequestError179("Invalid site ID format.");
|
|
48392
48447
|
}
|
|
@@ -48397,7 +48452,7 @@ function useNfcPatrolLogRepo() {
|
|
|
48397
48452
|
query.date = date;
|
|
48398
48453
|
}
|
|
48399
48454
|
if (route?._id) {
|
|
48400
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
48455
|
+
query["route._id"] = typeof route._id === "string" ? new ObjectId117(route._id) : route._id;
|
|
48401
48456
|
}
|
|
48402
48457
|
if (route?.startTime) {
|
|
48403
48458
|
query["route.startTime"] = route.startTime;
|
|
@@ -49269,7 +49324,7 @@ function useNewDashboardController() {
|
|
|
49269
49324
|
|
|
49270
49325
|
// src/models/manpower-monitoring.model.ts
|
|
49271
49326
|
import Joi113 from "joi";
|
|
49272
|
-
import { ObjectId as
|
|
49327
|
+
import { ObjectId as ObjectId118 } from "mongodb";
|
|
49273
49328
|
var shiftSchema = Joi113.object({
|
|
49274
49329
|
name: Joi113.string().required(),
|
|
49275
49330
|
checkIn: Joi113.string().optional().allow("", null),
|
|
@@ -49294,7 +49349,7 @@ var manpowerMonitoringSchema = Joi113.object({
|
|
|
49294
49349
|
});
|
|
49295
49350
|
var MManpowerMonitoring = class {
|
|
49296
49351
|
constructor(data) {
|
|
49297
|
-
this._id = new
|
|
49352
|
+
this._id = new ObjectId118();
|
|
49298
49353
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
49299
49354
|
this.siteId = data.siteId || "";
|
|
49300
49355
|
this.siteName = data.siteName;
|
|
@@ -49767,7 +49822,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
49767
49822
|
};
|
|
49768
49823
|
|
|
49769
49824
|
// src/repositories/manpower-monitoring.repo.ts
|
|
49770
|
-
import { ObjectId as
|
|
49825
|
+
import { ObjectId as ObjectId119 } from "mongodb";
|
|
49771
49826
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
49772
49827
|
function useManpowerMonitoringRepo() {
|
|
49773
49828
|
const db = useAtlas101.getDb();
|
|
@@ -49802,11 +49857,11 @@ function useManpowerMonitoringRepo() {
|
|
|
49802
49857
|
try {
|
|
49803
49858
|
value = new MManpowerMonitoring(value);
|
|
49804
49859
|
if (value.createdBy)
|
|
49805
|
-
value.createdBy = new
|
|
49860
|
+
value.createdBy = new ObjectId119(value.createdBy);
|
|
49806
49861
|
if (value.siteId)
|
|
49807
|
-
value.siteId = new
|
|
49862
|
+
value.siteId = new ObjectId119(value.siteId);
|
|
49808
49863
|
if (value.serviceProviderId)
|
|
49809
|
-
value.serviceProviderId = new
|
|
49864
|
+
value.serviceProviderId = new ObjectId119(value.serviceProviderId);
|
|
49810
49865
|
const result = await collection.insertOne(value, { session });
|
|
49811
49866
|
return result;
|
|
49812
49867
|
} catch (error) {
|
|
@@ -49847,8 +49902,8 @@ function useManpowerMonitoringRepo() {
|
|
|
49847
49902
|
}
|
|
49848
49903
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
49849
49904
|
try {
|
|
49850
|
-
_id = new
|
|
49851
|
-
serviceProviderId = new
|
|
49905
|
+
_id = new ObjectId119(_id);
|
|
49906
|
+
serviceProviderId = new ObjectId119(serviceProviderId);
|
|
49852
49907
|
} catch (error) {
|
|
49853
49908
|
throw new Error("Invalid Site ID format.");
|
|
49854
49909
|
}
|
|
@@ -49864,7 +49919,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49864
49919
|
}
|
|
49865
49920
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
49866
49921
|
try {
|
|
49867
|
-
_id = new
|
|
49922
|
+
_id = new ObjectId119(_id);
|
|
49868
49923
|
} catch (error) {
|
|
49869
49924
|
throw new BadRequestError184("Invalid ID format.");
|
|
49870
49925
|
}
|
|
@@ -49891,7 +49946,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49891
49946
|
for (let item of value) {
|
|
49892
49947
|
item = new MManpowerMonitoring(item);
|
|
49893
49948
|
const data = await collection.findOne({
|
|
49894
|
-
siteId: new
|
|
49949
|
+
siteId: new ObjectId119(item.siteId)
|
|
49895
49950
|
});
|
|
49896
49951
|
if (data) {
|
|
49897
49952
|
let updateValue;
|
|
@@ -49916,11 +49971,11 @@ function useManpowerMonitoringRepo() {
|
|
|
49916
49971
|
}
|
|
49917
49972
|
} else {
|
|
49918
49973
|
if (item.createdBy)
|
|
49919
|
-
item.createdBy = new
|
|
49974
|
+
item.createdBy = new ObjectId119(item.createdBy);
|
|
49920
49975
|
if (item.siteId)
|
|
49921
|
-
item.siteId = new
|
|
49976
|
+
item.siteId = new ObjectId119(item.siteId);
|
|
49922
49977
|
if (item.serviceProviderId)
|
|
49923
|
-
item.serviceProviderId = new
|
|
49978
|
+
item.serviceProviderId = new ObjectId119(item.serviceProviderId);
|
|
49924
49979
|
const result = await collection.insertOne(item);
|
|
49925
49980
|
if (result.insertedId) {
|
|
49926
49981
|
results.inserted++;
|
|
@@ -49944,7 +49999,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49944
49999
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
49945
50000
|
try {
|
|
49946
50001
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
49947
|
-
_id: new
|
|
50002
|
+
_id: new ObjectId119(serviceProviderId)
|
|
49948
50003
|
});
|
|
49949
50004
|
if (!serviceProvider) {
|
|
49950
50005
|
throw new Error("Service Provider not found.");
|
|
@@ -49997,7 +50052,7 @@ import {
|
|
|
49997
50052
|
|
|
49998
50053
|
// src/models/manpower-remarks.model.ts
|
|
49999
50054
|
import Joi114 from "joi";
|
|
50000
|
-
import { ObjectId as
|
|
50055
|
+
import { ObjectId as ObjectId120 } from "mongodb";
|
|
50001
50056
|
var remarksSchema = Joi114.object({
|
|
50002
50057
|
name: Joi114.string().required(),
|
|
50003
50058
|
remark: Joi114.object({
|
|
@@ -50021,7 +50076,7 @@ var manpowerRemarksSchema = Joi114.object({
|
|
|
50021
50076
|
});
|
|
50022
50077
|
var MManpowerRemarks = class {
|
|
50023
50078
|
constructor(data) {
|
|
50024
|
-
this._id = new
|
|
50079
|
+
this._id = new ObjectId120();
|
|
50025
50080
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
50026
50081
|
this.siteId = data.siteId || "";
|
|
50027
50082
|
this.siteName = data.siteName || "";
|
|
@@ -50039,7 +50094,7 @@ var MManpowerRemarks = class {
|
|
|
50039
50094
|
};
|
|
50040
50095
|
|
|
50041
50096
|
// src/repositories/manpower-remarks.repo.ts
|
|
50042
|
-
import { ObjectId as
|
|
50097
|
+
import { ObjectId as ObjectId121 } from "mongodb";
|
|
50043
50098
|
import moment2 from "moment-timezone";
|
|
50044
50099
|
function useManpowerRemarksRepo() {
|
|
50045
50100
|
const db = useAtlas102.getDb();
|
|
@@ -50073,9 +50128,9 @@ function useManpowerRemarksRepo() {
|
|
|
50073
50128
|
try {
|
|
50074
50129
|
value = new MManpowerRemarks(value);
|
|
50075
50130
|
if (value.siteId)
|
|
50076
|
-
value.siteId = new
|
|
50131
|
+
value.siteId = new ObjectId121(value.siteId);
|
|
50077
50132
|
if (value.serviceProviderId)
|
|
50078
|
-
value.serviceProviderId = new
|
|
50133
|
+
value.serviceProviderId = new ObjectId121(value.serviceProviderId);
|
|
50079
50134
|
const result = await collection.insertOne(value, { session });
|
|
50080
50135
|
return result;
|
|
50081
50136
|
} catch (error) {
|
|
@@ -50095,7 +50150,7 @@ function useManpowerRemarksRepo() {
|
|
|
50095
50150
|
limit = limit || 10;
|
|
50096
50151
|
const searchQuery = {};
|
|
50097
50152
|
const nowSGT = moment2().tz("Asia/Singapore");
|
|
50098
|
-
searchQuery.serviceProviderId = new
|
|
50153
|
+
searchQuery.serviceProviderId = new ObjectId121(serviceProviderId);
|
|
50099
50154
|
if (search != "") {
|
|
50100
50155
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
50101
50156
|
}
|
|
@@ -50127,8 +50182,8 @@ function useManpowerRemarksRepo() {
|
|
|
50127
50182
|
}
|
|
50128
50183
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
50129
50184
|
try {
|
|
50130
|
-
_id = new
|
|
50131
|
-
serviceProviderId = new
|
|
50185
|
+
_id = new ObjectId121(_id);
|
|
50186
|
+
serviceProviderId = new ObjectId121(serviceProviderId);
|
|
50132
50187
|
} catch (error) {
|
|
50133
50188
|
throw new Error("Invalid Site ID format.");
|
|
50134
50189
|
}
|
|
@@ -50145,13 +50200,13 @@ function useManpowerRemarksRepo() {
|
|
|
50145
50200
|
}
|
|
50146
50201
|
async function updateManpowerRemarks(_id, value) {
|
|
50147
50202
|
try {
|
|
50148
|
-
_id = new
|
|
50203
|
+
_id = new ObjectId121(_id);
|
|
50149
50204
|
} catch (error) {
|
|
50150
50205
|
throw new BadRequestError185("Invalid ID format.");
|
|
50151
50206
|
}
|
|
50152
50207
|
try {
|
|
50153
50208
|
if (value.createdBy) {
|
|
50154
|
-
value.createdBy = new
|
|
50209
|
+
value.createdBy = new ObjectId121(value.createdBy);
|
|
50155
50210
|
}
|
|
50156
50211
|
const updateValue = {
|
|
50157
50212
|
...value,
|
|
@@ -50168,7 +50223,7 @@ function useManpowerRemarksRepo() {
|
|
|
50168
50223
|
}
|
|
50169
50224
|
async function updateRemarksStatus(_id, value) {
|
|
50170
50225
|
try {
|
|
50171
|
-
_id = new
|
|
50226
|
+
_id = new ObjectId121(_id);
|
|
50172
50227
|
} catch (error) {
|
|
50173
50228
|
throw new BadRequestError185("Invalid ID format.");
|
|
50174
50229
|
}
|
|
@@ -50438,7 +50493,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
50438
50493
|
|
|
50439
50494
|
// src/models/manpower-designations.model.ts
|
|
50440
50495
|
import Joi116 from "joi";
|
|
50441
|
-
import { ObjectId as
|
|
50496
|
+
import { ObjectId as ObjectId122 } from "mongodb";
|
|
50442
50497
|
var designationsSchema = Joi116.object({
|
|
50443
50498
|
title: Joi116.string().required(),
|
|
50444
50499
|
shifts: Joi116.object({
|
|
@@ -50457,7 +50512,7 @@ var manpowerDesignationsSchema = Joi116.object({
|
|
|
50457
50512
|
});
|
|
50458
50513
|
var MManpowerDesignations = class {
|
|
50459
50514
|
constructor(data) {
|
|
50460
|
-
this._id = new
|
|
50515
|
+
this._id = new ObjectId122();
|
|
50461
50516
|
this.siteId = data.siteId || "";
|
|
50462
50517
|
this.siteName = data.siteName || "";
|
|
50463
50518
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -50475,7 +50530,7 @@ import {
|
|
|
50475
50530
|
logger as logger164,
|
|
50476
50531
|
useAtlas as useAtlas104
|
|
50477
50532
|
} from "@7365admin1/node-server-utils";
|
|
50478
|
-
import { ObjectId as
|
|
50533
|
+
import { ObjectId as ObjectId123 } from "mongodb";
|
|
50479
50534
|
function useManpowerDesignationRepo() {
|
|
50480
50535
|
const db = useAtlas104.getDb();
|
|
50481
50536
|
if (!db) {
|
|
@@ -50507,11 +50562,11 @@ function useManpowerDesignationRepo() {
|
|
|
50507
50562
|
try {
|
|
50508
50563
|
value = new MManpowerDesignations(value);
|
|
50509
50564
|
if (value.createdBy)
|
|
50510
|
-
value.createdBy = new
|
|
50565
|
+
value.createdBy = new ObjectId123(value.createdBy);
|
|
50511
50566
|
if (value.siteId)
|
|
50512
|
-
value.siteId = new
|
|
50567
|
+
value.siteId = new ObjectId123(value.siteId);
|
|
50513
50568
|
if (value.serviceProviderId)
|
|
50514
|
-
value.serviceProviderId = new
|
|
50569
|
+
value.serviceProviderId = new ObjectId123(value.serviceProviderId);
|
|
50515
50570
|
const result = await collection.insertOne(value);
|
|
50516
50571
|
return result;
|
|
50517
50572
|
} catch (error) {
|
|
@@ -50520,8 +50575,8 @@ function useManpowerDesignationRepo() {
|
|
|
50520
50575
|
}
|
|
50521
50576
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
50522
50577
|
try {
|
|
50523
|
-
_id = new
|
|
50524
|
-
serviceProviderId = new
|
|
50578
|
+
_id = new ObjectId123(_id);
|
|
50579
|
+
serviceProviderId = new ObjectId123(serviceProviderId);
|
|
50525
50580
|
} catch (error) {
|
|
50526
50581
|
throw new Error("Invalid Site ID format.");
|
|
50527
50582
|
}
|
|
@@ -50537,7 +50592,7 @@ function useManpowerDesignationRepo() {
|
|
|
50537
50592
|
}
|
|
50538
50593
|
async function updateManpowerDesignations(_id, value) {
|
|
50539
50594
|
try {
|
|
50540
|
-
_id = new
|
|
50595
|
+
_id = new ObjectId123(_id);
|
|
50541
50596
|
} catch (error) {
|
|
50542
50597
|
throw new Error("Invalid ID format.");
|
|
50543
50598
|
}
|
|
@@ -50641,7 +50696,7 @@ function useManpowerDesignationCtrl() {
|
|
|
50641
50696
|
|
|
50642
50697
|
// src/models/overnight-parking.model.ts
|
|
50643
50698
|
import Joi118 from "joi";
|
|
50644
|
-
import { ObjectId as
|
|
50699
|
+
import { ObjectId as ObjectId124 } from "mongodb";
|
|
50645
50700
|
var dayScheduleSchema = Joi118.object({
|
|
50646
50701
|
isEnabled: Joi118.boolean().required(),
|
|
50647
50702
|
startTime: Joi118.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -50683,7 +50738,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
50683
50738
|
}
|
|
50684
50739
|
if (value.site && typeof value.site === "string") {
|
|
50685
50740
|
try {
|
|
50686
|
-
value.site = new
|
|
50741
|
+
value.site = new ObjectId124(value.site);
|
|
50687
50742
|
} catch {
|
|
50688
50743
|
throw new Error("Invalid site ID.");
|
|
50689
50744
|
}
|
|
@@ -52307,7 +52362,7 @@ function useManpowerRemarkCtrl() {
|
|
|
52307
52362
|
|
|
52308
52363
|
// src/models/manpower-sites.model.ts
|
|
52309
52364
|
import Joi124 from "joi";
|
|
52310
|
-
import { ObjectId as
|
|
52365
|
+
import { ObjectId as ObjectId125 } from "mongodb";
|
|
52311
52366
|
var manpowerSitesSchema = Joi124.object({
|
|
52312
52367
|
id: Joi124.string().hex().required(),
|
|
52313
52368
|
text: Joi124.string().hex().optional().allow("", null),
|
|
@@ -52318,7 +52373,7 @@ var manpowerSitesSchema = Joi124.object({
|
|
|
52318
52373
|
});
|
|
52319
52374
|
var MManpowerSites = class {
|
|
52320
52375
|
constructor(data) {
|
|
52321
|
-
this._id = new
|
|
52376
|
+
this._id = new ObjectId125();
|
|
52322
52377
|
this.id = data.id || "";
|
|
52323
52378
|
this.text = data.text || "";
|
|
52324
52379
|
this.contractID = data.contractID || "";
|
|
@@ -52540,7 +52595,7 @@ import {
|
|
|
52540
52595
|
getDirectory as getDirectory4,
|
|
52541
52596
|
logger as logger177
|
|
52542
52597
|
} from "@7365admin1/node-server-utils";
|
|
52543
|
-
import { ObjectId as
|
|
52598
|
+
import { ObjectId as ObjectId126 } from "mongodb";
|
|
52544
52599
|
import moment4 from "moment-timezone";
|
|
52545
52600
|
var createManpowerRemarksDaily = async () => {
|
|
52546
52601
|
const db = useAtlas110.getDb();
|
|
@@ -52700,7 +52755,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
52700
52755
|
for (const id of updatedIds) {
|
|
52701
52756
|
const doc = await remarks.findOne({ _id: id });
|
|
52702
52757
|
const setting = await settings.findOne(
|
|
52703
|
-
{ siteId: new
|
|
52758
|
+
{ siteId: new ObjectId126(doc?.siteId) },
|
|
52704
52759
|
{ projection: { emails: 1 } }
|
|
52705
52760
|
);
|
|
52706
52761
|
const payload = {
|
|
@@ -52786,7 +52841,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
52786
52841
|
for (const doc of docs) {
|
|
52787
52842
|
let shiftsToCheck = [];
|
|
52788
52843
|
const endShiftTime = await settings.findOne(
|
|
52789
|
-
{ siteId: new
|
|
52844
|
+
{ siteId: new ObjectId126(doc.siteId) },
|
|
52790
52845
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
52791
52846
|
);
|
|
52792
52847
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -52892,7 +52947,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
52892
52947
|
|
|
52893
52948
|
// src/events/manpower.event.ts
|
|
52894
52949
|
import { useAtlas as useAtlas111 } from "@7365admin1/node-server-utils";
|
|
52895
|
-
import { ObjectId as
|
|
52950
|
+
import { ObjectId as ObjectId127 } from "mongodb";
|
|
52896
52951
|
import moment5 from "moment-timezone";
|
|
52897
52952
|
async function manpowerEvents(io) {
|
|
52898
52953
|
let intervalId = null;
|
|
@@ -52918,7 +52973,7 @@ async function manpowerEvents(io) {
|
|
|
52918
52973
|
}).toArray();
|
|
52919
52974
|
for (const doc of docs) {
|
|
52920
52975
|
const siteSettings = await settings.findOne(
|
|
52921
|
-
{ siteId: new
|
|
52976
|
+
{ siteId: new ObjectId127(doc.siteId), enabled: true },
|
|
52922
52977
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
52923
52978
|
);
|
|
52924
52979
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -53037,11 +53092,11 @@ function genericSignature(params, secretKey) {
|
|
|
53037
53092
|
}
|
|
53038
53093
|
|
|
53039
53094
|
// src/repositories/reddot-payment.repository.ts
|
|
53040
|
-
import { ObjectId as
|
|
53095
|
+
import { ObjectId as ObjectId129 } from "mongodb";
|
|
53041
53096
|
|
|
53042
53097
|
// src/models/billing-payments.model.ts
|
|
53043
53098
|
import { BadRequestError as BadRequestError199, logger as logger178 } from "@7365admin1/node-server-utils";
|
|
53044
|
-
import { ObjectId as
|
|
53099
|
+
import { ObjectId as ObjectId128 } from "mongodb";
|
|
53045
53100
|
import Joi126 from "joi";
|
|
53046
53101
|
var schemaBillingItems = Joi126.object({
|
|
53047
53102
|
_id: Joi126.string().hex().optional(),
|
|
@@ -53075,21 +53130,21 @@ function MBillingItems(value) {
|
|
|
53075
53130
|
}
|
|
53076
53131
|
if (value._id && typeof value._id === "string") {
|
|
53077
53132
|
try {
|
|
53078
|
-
value._id = new
|
|
53133
|
+
value._id = new ObjectId128(value._id);
|
|
53079
53134
|
} catch {
|
|
53080
53135
|
throw new BadRequestError199("Invalid _id format");
|
|
53081
53136
|
}
|
|
53082
53137
|
}
|
|
53083
53138
|
if (value.unitId && typeof value.unitId === "string") {
|
|
53084
53139
|
try {
|
|
53085
|
-
value.unitId = new
|
|
53140
|
+
value.unitId = new ObjectId128(value.unitId);
|
|
53086
53141
|
} catch {
|
|
53087
53142
|
throw new BadRequestError199("Invalid unitId id format");
|
|
53088
53143
|
}
|
|
53089
53144
|
}
|
|
53090
53145
|
if (value.paidBy && typeof value.paidBy === "string") {
|
|
53091
53146
|
try {
|
|
53092
|
-
value.paidBy = new
|
|
53147
|
+
value.paidBy = new ObjectId128(value.paidBy);
|
|
53093
53148
|
} catch {
|
|
53094
53149
|
throw new BadRequestError199("Invalid paidBy id format");
|
|
53095
53150
|
}
|
|
@@ -53099,7 +53154,7 @@ function MBillingItems(value) {
|
|
|
53099
53154
|
value.unitBillingItems = value.unitBillingItems.map((unitBillingItem) => {
|
|
53100
53155
|
if (typeof unitBillingItem._id === "string") {
|
|
53101
53156
|
try {
|
|
53102
|
-
unitBillingItem._id = new
|
|
53157
|
+
unitBillingItem._id = new ObjectId128(unitBillingItem._id);
|
|
53103
53158
|
} catch {
|
|
53104
53159
|
throw new BadRequestError199("Invalid unit billing id format");
|
|
53105
53160
|
}
|
|
@@ -53111,7 +53166,7 @@ function MBillingItems(value) {
|
|
|
53111
53166
|
}
|
|
53112
53167
|
}
|
|
53113
53168
|
return {
|
|
53114
|
-
_id: value._id ?? new
|
|
53169
|
+
_id: value._id ?? new ObjectId128(),
|
|
53115
53170
|
unitBillingItems: value.unitBillingItems ?? [],
|
|
53116
53171
|
unitId: value.unitId ?? "",
|
|
53117
53172
|
unitOwner: value.unitOwner ?? "",
|
|
@@ -53185,7 +53240,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
53185
53240
|
const res = await paymentCollection().insertOne(payload, { session });
|
|
53186
53241
|
const unit = payload.unitId?.toString().slice(-4);
|
|
53187
53242
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
|
|
53188
|
-
const newId = new
|
|
53243
|
+
const newId = new ObjectId129(res.insertedId).toString().slice(-6);
|
|
53189
53244
|
const referenceNumber = `${unit}${newId}${dateFormatted}`;
|
|
53190
53245
|
await paymentCollection().updateOne(
|
|
53191
53246
|
{ _id: res.insertedId },
|
|
@@ -54301,7 +54356,7 @@ import {
|
|
|
54301
54356
|
import { v4 as uuidv42 } from "uuid";
|
|
54302
54357
|
|
|
54303
54358
|
// src/repositories/user-v2.repo.ts
|
|
54304
|
-
import { ObjectId as
|
|
54359
|
+
import { ObjectId as ObjectId130 } from "mongodb";
|
|
54305
54360
|
import {
|
|
54306
54361
|
useAtlas as useAtlas115,
|
|
54307
54362
|
InternalServerError as InternalServerError71,
|
|
@@ -54513,7 +54568,7 @@ function useUserRepoV2() {
|
|
|
54513
54568
|
}
|
|
54514
54569
|
if (organization) {
|
|
54515
54570
|
try {
|
|
54516
|
-
query.defaultOrg = new
|
|
54571
|
+
query.defaultOrg = new ObjectId130(organization);
|
|
54517
54572
|
cacheOptions.organization = organization.toString();
|
|
54518
54573
|
} catch (error) {
|
|
54519
54574
|
throw new BadRequestError204("Invalid organization ID format.");
|
|
@@ -54652,13 +54707,13 @@ function useUserRepoV2() {
|
|
|
54652
54707
|
);
|
|
54653
54708
|
}
|
|
54654
54709
|
try {
|
|
54655
|
-
_id = new
|
|
54710
|
+
_id = new ObjectId130(_id);
|
|
54656
54711
|
} catch (error) {
|
|
54657
54712
|
throw new BadRequestError204("Invalid ID.");
|
|
54658
54713
|
}
|
|
54659
54714
|
if (field === "defaultOrg") {
|
|
54660
54715
|
try {
|
|
54661
|
-
value = new
|
|
54716
|
+
value = new ObjectId130(value);
|
|
54662
54717
|
} catch (error) {
|
|
54663
54718
|
throw new BadRequestError204("Invalid organization ID.");
|
|
54664
54719
|
}
|
|
@@ -54699,7 +54754,7 @@ function useUserRepoV2() {
|
|
|
54699
54754
|
year
|
|
54700
54755
|
}, session) {
|
|
54701
54756
|
try {
|
|
54702
|
-
_id = new
|
|
54757
|
+
_id = new ObjectId130(_id);
|
|
54703
54758
|
} catch (error) {
|
|
54704
54759
|
throw new BadRequestError204("Invalid user ID format.");
|
|
54705
54760
|
}
|
|
@@ -54729,7 +54784,7 @@ function useUserRepoV2() {
|
|
|
54729
54784
|
}
|
|
54730
54785
|
async function updatePassword({ _id, password }, session) {
|
|
54731
54786
|
try {
|
|
54732
|
-
_id = new
|
|
54787
|
+
_id = new ObjectId130(_id);
|
|
54733
54788
|
} catch (error) {
|
|
54734
54789
|
throw new BadRequestError204("Invalid user ID format.");
|
|
54735
54790
|
}
|
|
@@ -55492,38 +55547,38 @@ function useUserControllerV2() {
|
|
|
55492
55547
|
|
|
55493
55548
|
// src/models/role-v2.model.ts
|
|
55494
55549
|
import { BadRequestError as BadRequestError209 } from "@7365admin1/node-server-utils";
|
|
55495
|
-
import { ObjectId as
|
|
55550
|
+
import { ObjectId as ObjectId131 } from "mongodb";
|
|
55496
55551
|
var MRoleV2 = class {
|
|
55497
55552
|
constructor(value) {
|
|
55498
55553
|
if (typeof value._id === "string") {
|
|
55499
55554
|
try {
|
|
55500
|
-
value._id = new
|
|
55555
|
+
value._id = new ObjectId131(value._id);
|
|
55501
55556
|
} catch (error) {
|
|
55502
55557
|
throw new BadRequestError209("Invalid role-v2 ID format.");
|
|
55503
55558
|
}
|
|
55504
55559
|
}
|
|
55505
55560
|
if (typeof value.site === "string" && value.site.length === 24) {
|
|
55506
55561
|
try {
|
|
55507
|
-
value.site = new
|
|
55562
|
+
value.site = new ObjectId131(value.site);
|
|
55508
55563
|
} catch (error) {
|
|
55509
55564
|
throw new BadRequestError209("Invalid site ID format.");
|
|
55510
55565
|
}
|
|
55511
55566
|
}
|
|
55512
55567
|
if (typeof value.org === "string" && value.org.length === 24) {
|
|
55513
55568
|
try {
|
|
55514
|
-
value.org = new
|
|
55569
|
+
value.org = new ObjectId131(value.org);
|
|
55515
55570
|
} catch (error) {
|
|
55516
55571
|
throw new BadRequestError209("Invalid org ID format.");
|
|
55517
55572
|
}
|
|
55518
55573
|
}
|
|
55519
55574
|
if (value.createdBy) {
|
|
55520
55575
|
try {
|
|
55521
|
-
value.createdBy = new
|
|
55576
|
+
value.createdBy = new ObjectId131(value.createdBy);
|
|
55522
55577
|
} catch (error) {
|
|
55523
55578
|
throw new BadRequestError209("Invalid created by ID format.");
|
|
55524
55579
|
}
|
|
55525
55580
|
}
|
|
55526
|
-
this._id = value._id ?? new
|
|
55581
|
+
this._id = value._id ?? new ObjectId131();
|
|
55527
55582
|
this.name = value.name ?? "";
|
|
55528
55583
|
this.permissions = value.permissions ?? [];
|
|
55529
55584
|
this.site = value.site ?? "";
|
|
@@ -55664,7 +55719,7 @@ function useRoleControllerV2() {
|
|
|
55664
55719
|
|
|
55665
55720
|
// src/models/post-preloved.model.ts
|
|
55666
55721
|
import Joi133 from "joi";
|
|
55667
|
-
import { ObjectId as
|
|
55722
|
+
import { ObjectId as ObjectId132 } from "mongodb";
|
|
55668
55723
|
var PostStatus = /* @__PURE__ */ ((PostStatus2) => {
|
|
55669
55724
|
PostStatus2["PUBLISHED"] = "published";
|
|
55670
55725
|
PostStatus2["RESERVED"] = "reserved";
|
|
@@ -55720,28 +55775,28 @@ function MPost(value) {
|
|
|
55720
55775
|
}
|
|
55721
55776
|
if (value._id && typeof value._id === "string") {
|
|
55722
55777
|
try {
|
|
55723
|
-
value._id = new
|
|
55778
|
+
value._id = new ObjectId132(value._id);
|
|
55724
55779
|
} catch {
|
|
55725
55780
|
throw new Error("Invalid ID.");
|
|
55726
55781
|
}
|
|
55727
55782
|
}
|
|
55728
55783
|
if (value.site && typeof value.site === "string") {
|
|
55729
55784
|
try {
|
|
55730
|
-
value.site = new
|
|
55785
|
+
value.site = new ObjectId132(value.site);
|
|
55731
55786
|
} catch {
|
|
55732
55787
|
throw new Error("Invalid site ID.");
|
|
55733
55788
|
}
|
|
55734
55789
|
}
|
|
55735
55790
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
55736
55791
|
try {
|
|
55737
|
-
value.createdBy = new
|
|
55792
|
+
value.createdBy = new ObjectId132(value.createdBy);
|
|
55738
55793
|
} catch {
|
|
55739
55794
|
throw new Error("Invalid createdBy ID.");
|
|
55740
55795
|
}
|
|
55741
55796
|
}
|
|
55742
55797
|
if (value.reserverId && typeof value.reserverId === "string") {
|
|
55743
55798
|
try {
|
|
55744
|
-
value.reserverId = new
|
|
55799
|
+
value.reserverId = new ObjectId132(value.reserverId);
|
|
55745
55800
|
} catch {
|
|
55746
55801
|
throw new Error("Invalid reserver ID.");
|
|
55747
55802
|
}
|
|
@@ -55750,7 +55805,7 @@ function MPost(value) {
|
|
|
55750
55805
|
value.attachments = value.attachments.map((id) => {
|
|
55751
55806
|
if (typeof id === "string") {
|
|
55752
55807
|
try {
|
|
55753
|
-
return new
|
|
55808
|
+
return new ObjectId132(id);
|
|
55754
55809
|
} catch {
|
|
55755
55810
|
throw new Error("Invalid attachment ID.");
|
|
55756
55811
|
}
|
|
@@ -55760,20 +55815,20 @@ function MPost(value) {
|
|
|
55760
55815
|
}
|
|
55761
55816
|
if (value.category && typeof value.category === "string") {
|
|
55762
55817
|
try {
|
|
55763
|
-
value.category = new
|
|
55818
|
+
value.category = new ObjectId132(value.category);
|
|
55764
55819
|
} catch {
|
|
55765
55820
|
throw new Error("Invalid category ID.");
|
|
55766
55821
|
}
|
|
55767
55822
|
}
|
|
55768
55823
|
if (value.subcategory && typeof value.subcategory === "string") {
|
|
55769
55824
|
try {
|
|
55770
|
-
value.subcategory = new
|
|
55825
|
+
value.subcategory = new ObjectId132(value.subcategory);
|
|
55771
55826
|
} catch {
|
|
55772
55827
|
throw new Error("Invalid subcategory ID.");
|
|
55773
55828
|
}
|
|
55774
55829
|
}
|
|
55775
55830
|
return {
|
|
55776
|
-
_id: value._id ?? new
|
|
55831
|
+
_id: value._id ?? new ObjectId132(),
|
|
55777
55832
|
title: value.title ?? "",
|
|
55778
55833
|
description: value.description ?? "",
|
|
55779
55834
|
attachments: value.attachments ?? [],
|
|
@@ -55799,7 +55854,7 @@ import {
|
|
|
55799
55854
|
paginate as paginate60,
|
|
55800
55855
|
useAtlas as useAtlas118
|
|
55801
55856
|
} from "@7365admin1/node-server-utils";
|
|
55802
|
-
import { ObjectId as
|
|
55857
|
+
import { ObjectId as ObjectId133 } from "mongodb";
|
|
55803
55858
|
function usePostPrelovedRepo() {
|
|
55804
55859
|
const db = useAtlas118.getDb();
|
|
55805
55860
|
if (!db) {
|
|
@@ -55863,7 +55918,7 @@ function usePostPrelovedRepo() {
|
|
|
55863
55918
|
}
|
|
55864
55919
|
async function getById(_id) {
|
|
55865
55920
|
try {
|
|
55866
|
-
_id = new
|
|
55921
|
+
_id = new ObjectId133(_id);
|
|
55867
55922
|
} catch {
|
|
55868
55923
|
throw new BadRequestError212("Invalid post ID format.");
|
|
55869
55924
|
}
|
|
@@ -55896,7 +55951,7 @@ function usePostPrelovedRepo() {
|
|
|
55896
55951
|
page = page > 0 ? page - 1 : 0;
|
|
55897
55952
|
if (site) {
|
|
55898
55953
|
try {
|
|
55899
|
-
site = new
|
|
55954
|
+
site = new ObjectId133(site);
|
|
55900
55955
|
} catch {
|
|
55901
55956
|
throw new BadRequestError212("Invalid site ID format.");
|
|
55902
55957
|
}
|
|
@@ -55905,14 +55960,14 @@ function usePostPrelovedRepo() {
|
|
|
55905
55960
|
let subcategoryIds = null;
|
|
55906
55961
|
if (category && subcategory) {
|
|
55907
55962
|
try {
|
|
55908
|
-
categoryId = new
|
|
55963
|
+
categoryId = new ObjectId133(category);
|
|
55909
55964
|
} catch {
|
|
55910
55965
|
throw new BadRequestError212("Invalid category ID format.");
|
|
55911
55966
|
}
|
|
55912
55967
|
if (subcategory.length > 0) {
|
|
55913
55968
|
subcategoryIds = subcategory.map((id) => {
|
|
55914
55969
|
try {
|
|
55915
|
-
return new
|
|
55970
|
+
return new ObjectId133(id);
|
|
55916
55971
|
} catch {
|
|
55917
55972
|
throw new BadRequestError212("Invalid subcategory ID format.");
|
|
55918
55973
|
}
|
|
@@ -55937,7 +55992,7 @@ function usePostPrelovedRepo() {
|
|
|
55937
55992
|
let userObjectId = null;
|
|
55938
55993
|
if (userId) {
|
|
55939
55994
|
try {
|
|
55940
|
-
userObjectId = new
|
|
55995
|
+
userObjectId = new ObjectId133(userId);
|
|
55941
55996
|
} catch {
|
|
55942
55997
|
throw new BadRequestError212("Invalid user ID format.");
|
|
55943
55998
|
}
|
|
@@ -55986,7 +56041,7 @@ function usePostPrelovedRepo() {
|
|
|
55986
56041
|
}
|
|
55987
56042
|
async function updateById(_id, value, session) {
|
|
55988
56043
|
try {
|
|
55989
|
-
_id = new
|
|
56044
|
+
_id = new ObjectId133(_id);
|
|
55990
56045
|
} catch {
|
|
55991
56046
|
throw new BadRequestError212("Invalid post ID format.");
|
|
55992
56047
|
}
|
|
@@ -56007,7 +56062,7 @@ function usePostPrelovedRepo() {
|
|
|
56007
56062
|
}
|
|
56008
56063
|
async function deleteById(_id, session) {
|
|
56009
56064
|
try {
|
|
56010
|
-
_id = new
|
|
56065
|
+
_id = new ObjectId133(_id);
|
|
56011
56066
|
} catch {
|
|
56012
56067
|
throw new BadRequestError212("Invalid post ID format.");
|
|
56013
56068
|
}
|
|
@@ -56033,7 +56088,7 @@ function usePostPrelovedRepo() {
|
|
|
56033
56088
|
}
|
|
56034
56089
|
async function updateStatus(_id, status, session) {
|
|
56035
56090
|
try {
|
|
56036
|
-
_id = new
|
|
56091
|
+
_id = new ObjectId133(_id);
|
|
56037
56092
|
} catch {
|
|
56038
56093
|
throw new BadRequestError212("Invalid post ID format.");
|
|
56039
56094
|
}
|
|
@@ -56245,7 +56300,7 @@ function usePostPrelovedController() {
|
|
|
56245
56300
|
|
|
56246
56301
|
// src/models/post-favorite.model.ts
|
|
56247
56302
|
import Joi135 from "joi";
|
|
56248
|
-
import { ObjectId as
|
|
56303
|
+
import { ObjectId as ObjectId134 } from "mongodb";
|
|
56249
56304
|
var schemaUpdatePostFavorite = Joi135.object({
|
|
56250
56305
|
userId: Joi135.string().hex().length(24).required()
|
|
56251
56306
|
});
|
|
@@ -56263,14 +56318,14 @@ function MPostFavorite(value) {
|
|
|
56263
56318
|
}
|
|
56264
56319
|
if (value._id && typeof value._id === "string") {
|
|
56265
56320
|
try {
|
|
56266
|
-
value._id = new
|
|
56321
|
+
value._id = new ObjectId134(value._id);
|
|
56267
56322
|
} catch {
|
|
56268
56323
|
throw new Error("Invalid ID.");
|
|
56269
56324
|
}
|
|
56270
56325
|
}
|
|
56271
56326
|
if (value.postId && typeof value.postId === "string") {
|
|
56272
56327
|
try {
|
|
56273
|
-
value.postId = new
|
|
56328
|
+
value.postId = new ObjectId134(value.postId);
|
|
56274
56329
|
} catch {
|
|
56275
56330
|
throw new Error("Invalid post ID.");
|
|
56276
56331
|
}
|
|
@@ -56279,7 +56334,7 @@ function MPostFavorite(value) {
|
|
|
56279
56334
|
value.userIds = value.userIds.map((id) => {
|
|
56280
56335
|
if (typeof id === "string") {
|
|
56281
56336
|
try {
|
|
56282
|
-
return new
|
|
56337
|
+
return new ObjectId134(id);
|
|
56283
56338
|
} catch {
|
|
56284
56339
|
throw new Error("Invalid user ID.");
|
|
56285
56340
|
}
|
|
@@ -56288,7 +56343,7 @@ function MPostFavorite(value) {
|
|
|
56288
56343
|
});
|
|
56289
56344
|
}
|
|
56290
56345
|
return {
|
|
56291
|
-
_id: value._id ?? new
|
|
56346
|
+
_id: value._id ?? new ObjectId134(),
|
|
56292
56347
|
postId: value.postId ?? "",
|
|
56293
56348
|
userIds: value.userIds ?? [],
|
|
56294
56349
|
createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -56303,7 +56358,7 @@ import {
|
|
|
56303
56358
|
NotFoundError as NotFoundError58,
|
|
56304
56359
|
useAtlas as useAtlas119
|
|
56305
56360
|
} from "@7365admin1/node-server-utils";
|
|
56306
|
-
import { ObjectId as
|
|
56361
|
+
import { ObjectId as ObjectId135 } from "mongodb";
|
|
56307
56362
|
function usePostFavoriteRepo() {
|
|
56308
56363
|
const db = useAtlas119.getDb();
|
|
56309
56364
|
if (!db) {
|
|
@@ -56325,7 +56380,7 @@ function usePostFavoriteRepo() {
|
|
|
56325
56380
|
}
|
|
56326
56381
|
async function getById(_id) {
|
|
56327
56382
|
try {
|
|
56328
|
-
_id = new
|
|
56383
|
+
_id = new ObjectId135(_id);
|
|
56329
56384
|
} catch {
|
|
56330
56385
|
throw new BadRequestError214("Invalid favorite ID format.");
|
|
56331
56386
|
}
|
|
@@ -56336,13 +56391,13 @@ function usePostFavoriteRepo() {
|
|
|
56336
56391
|
}
|
|
56337
56392
|
async function updateById(_id, userId, session) {
|
|
56338
56393
|
try {
|
|
56339
|
-
_id = new
|
|
56394
|
+
_id = new ObjectId135(_id);
|
|
56340
56395
|
} catch {
|
|
56341
56396
|
throw new BadRequestError214("Invalid favorite ID format.");
|
|
56342
56397
|
}
|
|
56343
56398
|
let userObjectId;
|
|
56344
56399
|
try {
|
|
56345
|
-
userObjectId = new
|
|
56400
|
+
userObjectId = new ObjectId135(userId);
|
|
56346
56401
|
} catch {
|
|
56347
56402
|
throw new BadRequestError214("Invalid user ID format.");
|
|
56348
56403
|
}
|
|
@@ -56482,7 +56537,7 @@ function usePostFavoriteController() {
|
|
|
56482
56537
|
|
|
56483
56538
|
// src/models/category-preloved.model.ts
|
|
56484
56539
|
import Joi137 from "joi";
|
|
56485
|
-
import { ObjectId as
|
|
56540
|
+
import { ObjectId as ObjectId136 } from "mongodb";
|
|
56486
56541
|
var schemaCategoryPreloved = Joi137.object({
|
|
56487
56542
|
name: Joi137.string().required(),
|
|
56488
56543
|
createdBy: Joi137.string().hex().optional().allow("", null),
|
|
@@ -56499,14 +56554,14 @@ function MCategoryPreloved(value) {
|
|
|
56499
56554
|
}
|
|
56500
56555
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
56501
56556
|
try {
|
|
56502
|
-
value.createdBy = new
|
|
56557
|
+
value.createdBy = new ObjectId136(value.createdBy);
|
|
56503
56558
|
} catch {
|
|
56504
56559
|
throw new Error("Invalid createdBy ID.");
|
|
56505
56560
|
}
|
|
56506
56561
|
}
|
|
56507
56562
|
if (value.site && typeof value.site === "string") {
|
|
56508
56563
|
try {
|
|
56509
|
-
value.site = new
|
|
56564
|
+
value.site = new ObjectId136(value.site);
|
|
56510
56565
|
} catch {
|
|
56511
56566
|
throw new Error("Invalid site ID.");
|
|
56512
56567
|
}
|
|
@@ -56527,7 +56582,7 @@ import {
|
|
|
56527
56582
|
NotFoundError as NotFoundError59,
|
|
56528
56583
|
useAtlas as useAtlas121
|
|
56529
56584
|
} from "@7365admin1/node-server-utils";
|
|
56530
|
-
import { ObjectId as
|
|
56585
|
+
import { ObjectId as ObjectId137 } from "mongodb";
|
|
56531
56586
|
function useCategoryPrelovedRepo() {
|
|
56532
56587
|
const db = useAtlas121.getDb();
|
|
56533
56588
|
if (!db) {
|
|
@@ -56541,7 +56596,7 @@ function useCategoryPrelovedRepo() {
|
|
|
56541
56596
|
} = {}) {
|
|
56542
56597
|
if (site) {
|
|
56543
56598
|
try {
|
|
56544
|
-
site = new
|
|
56599
|
+
site = new ObjectId137(site);
|
|
56545
56600
|
} catch {
|
|
56546
56601
|
throw new BadRequestError216("Invalid site ID format.");
|
|
56547
56602
|
}
|
|
@@ -56560,7 +56615,7 @@ function useCategoryPrelovedRepo() {
|
|
|
56560
56615
|
async function getById(_id) {
|
|
56561
56616
|
let objectId2;
|
|
56562
56617
|
try {
|
|
56563
|
-
objectId2 = new
|
|
56618
|
+
objectId2 = new ObjectId137(_id);
|
|
56564
56619
|
} catch {
|
|
56565
56620
|
throw new BadRequestError216("Invalid category-preloved ID format.");
|
|
56566
56621
|
}
|
|
@@ -56660,7 +56715,7 @@ function useCategoryPrelovedController() {
|
|
|
56660
56715
|
|
|
56661
56716
|
// src/models/subcategory-preloved.model.ts
|
|
56662
56717
|
import Joi139 from "joi";
|
|
56663
|
-
import { ObjectId as
|
|
56718
|
+
import { ObjectId as ObjectId138 } from "mongodb";
|
|
56664
56719
|
var schemaSubcategoryPreloved = Joi139.object({
|
|
56665
56720
|
name: Joi139.string().required(),
|
|
56666
56721
|
createdBy: Joi139.string().hex().optional().allow("", null),
|
|
@@ -56679,21 +56734,21 @@ function MSubcategoryPreloved(value) {
|
|
|
56679
56734
|
}
|
|
56680
56735
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
56681
56736
|
try {
|
|
56682
|
-
value.createdBy = new
|
|
56737
|
+
value.createdBy = new ObjectId138(value.createdBy);
|
|
56683
56738
|
} catch {
|
|
56684
56739
|
throw new Error("Invalid createdBy ID.");
|
|
56685
56740
|
}
|
|
56686
56741
|
}
|
|
56687
56742
|
if (value.site && typeof value.site === "string") {
|
|
56688
56743
|
try {
|
|
56689
|
-
value.site = new
|
|
56744
|
+
value.site = new ObjectId138(value.site);
|
|
56690
56745
|
} catch {
|
|
56691
56746
|
throw new Error("Invalid site ID.");
|
|
56692
56747
|
}
|
|
56693
56748
|
}
|
|
56694
56749
|
if (value.category_id && typeof value.category_id === "string") {
|
|
56695
56750
|
try {
|
|
56696
|
-
value.category_id = new
|
|
56751
|
+
value.category_id = new ObjectId138(value.category_id);
|
|
56697
56752
|
} catch {
|
|
56698
56753
|
throw new Error("Invalid category ID.");
|
|
56699
56754
|
}
|
|
@@ -56715,7 +56770,7 @@ import {
|
|
|
56715
56770
|
NotFoundError as NotFoundError60,
|
|
56716
56771
|
useAtlas as useAtlas122
|
|
56717
56772
|
} from "@7365admin1/node-server-utils";
|
|
56718
|
-
import { ObjectId as
|
|
56773
|
+
import { ObjectId as ObjectId139 } from "mongodb";
|
|
56719
56774
|
function useSubcategoryPrelovedRepo() {
|
|
56720
56775
|
const db = useAtlas122.getDb();
|
|
56721
56776
|
if (!db) {
|
|
@@ -56730,14 +56785,14 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56730
56785
|
} = {}) {
|
|
56731
56786
|
if (site) {
|
|
56732
56787
|
try {
|
|
56733
|
-
site = new
|
|
56788
|
+
site = new ObjectId139(site);
|
|
56734
56789
|
} catch {
|
|
56735
56790
|
throw new BadRequestError218("Invalid site ID format.");
|
|
56736
56791
|
}
|
|
56737
56792
|
}
|
|
56738
56793
|
if (category_id) {
|
|
56739
56794
|
try {
|
|
56740
|
-
category_id = new
|
|
56795
|
+
category_id = new ObjectId139(category_id);
|
|
56741
56796
|
} catch {
|
|
56742
56797
|
throw new BadRequestError218("Invalid category ID format.");
|
|
56743
56798
|
}
|
|
@@ -56756,7 +56811,7 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56756
56811
|
async function getById(_id) {
|
|
56757
56812
|
let objectId2;
|
|
56758
56813
|
try {
|
|
56759
|
-
objectId2 = new
|
|
56814
|
+
objectId2 = new ObjectId139(_id);
|
|
56760
56815
|
} catch {
|
|
56761
56816
|
throw new BadRequestError218("Invalid subcategory-preloved ID format.");
|
|
56762
56817
|
}
|
|
@@ -56770,14 +56825,30 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56770
56825
|
throw error;
|
|
56771
56826
|
}
|
|
56772
56827
|
}
|
|
56773
|
-
|
|
56828
|
+
async function addSubcategory(item, session) {
|
|
56829
|
+
const doc = MSubcategoryPreloved(item);
|
|
56830
|
+
try {
|
|
56831
|
+
const res = await collection.insertOne(doc, { session });
|
|
56832
|
+
return res.insertedId;
|
|
56833
|
+
} catch (error) {
|
|
56834
|
+
const isDuplicated = error.message?.includes("duplicate");
|
|
56835
|
+
if (isDuplicated)
|
|
56836
|
+
throw new BadRequestError218("Subcategory already exists.");
|
|
56837
|
+
throw error;
|
|
56838
|
+
}
|
|
56839
|
+
}
|
|
56840
|
+
return { getAll, getById, addSubcategory };
|
|
56774
56841
|
}
|
|
56775
56842
|
|
|
56776
56843
|
// src/controllers/subcategory-preloved.controller.ts
|
|
56777
56844
|
import { BadRequestError as BadRequestError219, logger as logger191 } from "@7365admin1/node-server-utils";
|
|
56778
56845
|
import Joi140 from "joi";
|
|
56779
56846
|
function useSubcategoryPrelovedController() {
|
|
56780
|
-
const {
|
|
56847
|
+
const {
|
|
56848
|
+
getAll: _getAll,
|
|
56849
|
+
getById: _getById,
|
|
56850
|
+
addSubcategory: _addSubcategory
|
|
56851
|
+
} = useSubcategoryPrelovedRepo();
|
|
56781
56852
|
async function getAll(req, res, next) {
|
|
56782
56853
|
const schema2 = Joi140.object({
|
|
56783
56854
|
search: Joi140.string().optional().allow("", null),
|
|
@@ -56821,12 +56892,30 @@ function useSubcategoryPrelovedController() {
|
|
|
56821
56892
|
return;
|
|
56822
56893
|
}
|
|
56823
56894
|
}
|
|
56824
|
-
|
|
56895
|
+
async function addSubcategory(req, res, next) {
|
|
56896
|
+
const { error, value } = schemaSubcategoryPreloved.validate(req.body, {
|
|
56897
|
+
abortEarly: false
|
|
56898
|
+
});
|
|
56899
|
+
if (error) {
|
|
56900
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
56901
|
+
logger191.log({ level: "error", message: messages });
|
|
56902
|
+
next(new BadRequestError219(messages));
|
|
56903
|
+
return;
|
|
56904
|
+
}
|
|
56905
|
+
try {
|
|
56906
|
+
const data = await _addSubcategory(value);
|
|
56907
|
+
res.status(201).json(data);
|
|
56908
|
+
} catch (error2) {
|
|
56909
|
+
logger191.log({ level: "error", message: error2.message });
|
|
56910
|
+
next(error2);
|
|
56911
|
+
}
|
|
56912
|
+
}
|
|
56913
|
+
return { getAll, getById, addSubcategory };
|
|
56825
56914
|
}
|
|
56826
56915
|
|
|
56827
56916
|
// src/models/online-forms-v2.model.ts
|
|
56828
56917
|
import Joi141 from "joi";
|
|
56829
|
-
import { ObjectId as
|
|
56918
|
+
import { ObjectId as ObjectId140 } from "mongodb";
|
|
56830
56919
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
56831
56920
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
56832
56921
|
FormEntryStatus2["INACTIVE"] = "inactive";
|
|
@@ -56881,21 +56970,21 @@ function MFormEntry(value) {
|
|
|
56881
56970
|
}
|
|
56882
56971
|
if (value._id && typeof value._id === "string") {
|
|
56883
56972
|
try {
|
|
56884
|
-
value._id = new
|
|
56973
|
+
value._id = new ObjectId140(value._id);
|
|
56885
56974
|
} catch {
|
|
56886
56975
|
throw new Error("Invalid ID.");
|
|
56887
56976
|
}
|
|
56888
56977
|
}
|
|
56889
56978
|
if (value.org && typeof value.org === "string") {
|
|
56890
56979
|
try {
|
|
56891
|
-
value.org = new
|
|
56980
|
+
value.org = new ObjectId140(value.org);
|
|
56892
56981
|
} catch {
|
|
56893
56982
|
throw new Error("Invalid org ID.");
|
|
56894
56983
|
}
|
|
56895
56984
|
}
|
|
56896
56985
|
if (value.site && typeof value.site === "string") {
|
|
56897
56986
|
try {
|
|
56898
|
-
value.site = new
|
|
56987
|
+
value.site = new ObjectId140(value.site);
|
|
56899
56988
|
} catch {
|
|
56900
56989
|
throw new Error("Invalid site ID.");
|
|
56901
56990
|
}
|