@7365admin1/core 2.74.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 +12 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +580 -487
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +580 -487
- package/dist/index.mjs.map +1 -1
- package/dist/public/handlebars/registration-pending.hbs +131 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3181,6 +3181,20 @@ function useUserRepo() {
|
|
|
3181
3181
|
throw new import_node_server_utils10.InternalServerError("Failed to update user.");
|
|
3182
3182
|
}
|
|
3183
3183
|
}
|
|
3184
|
+
async function updateUserOrgById(id, org, session) {
|
|
3185
|
+
const _id = (0, import_node_server_utils10.toObjectId)(id);
|
|
3186
|
+
const orgId = (0, import_node_server_utils10.toObjectId)(org);
|
|
3187
|
+
try {
|
|
3188
|
+
await collection.updateOne(
|
|
3189
|
+
{ _id },
|
|
3190
|
+
{ $set: { defaultOrg: orgId, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
3191
|
+
{ session }
|
|
3192
|
+
);
|
|
3193
|
+
return "Successfully updated user organization.";
|
|
3194
|
+
} catch (error) {
|
|
3195
|
+
throw new import_node_server_utils10.InternalServerError("Failed to update user organization.");
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3184
3198
|
return {
|
|
3185
3199
|
createIndex,
|
|
3186
3200
|
createTextIndex,
|
|
@@ -3198,7 +3212,8 @@ function useUserRepo() {
|
|
|
3198
3212
|
updateDefaultOrgByEmail,
|
|
3199
3213
|
getUserByEmailStatus,
|
|
3200
3214
|
updateUserSIDById,
|
|
3201
|
-
resetPassword
|
|
3215
|
+
resetPassword,
|
|
3216
|
+
updateUserOrgById
|
|
3202
3217
|
};
|
|
3203
3218
|
}
|
|
3204
3219
|
|
|
@@ -7897,7 +7912,8 @@ function useUserController() {
|
|
|
7897
7912
|
"dateOfBirth",
|
|
7898
7913
|
"profile",
|
|
7899
7914
|
"gender",
|
|
7900
|
-
"defaultOrg"
|
|
7915
|
+
"defaultOrg",
|
|
7916
|
+
"status"
|
|
7901
7917
|
).required(),
|
|
7902
7918
|
value: import_joi13.default.when("field", {
|
|
7903
7919
|
switch: [
|
|
@@ -14727,7 +14743,8 @@ var schemaPlate = import_joi36.default.object({
|
|
|
14727
14743
|
});
|
|
14728
14744
|
var schemaFiles = import_joi36.default.object({
|
|
14729
14745
|
id: import_joi36.default.string().hex().required(),
|
|
14730
|
-
name: import_joi36.default.string().optional().allow(null, "")
|
|
14746
|
+
name: import_joi36.default.string().optional().allow(null, ""),
|
|
14747
|
+
mimeType: import_joi36.default.string().optional().allow(null, "")
|
|
14731
14748
|
});
|
|
14732
14749
|
var schemaApprover = import_joi36.default.object({
|
|
14733
14750
|
id: import_joi36.default.string().hex().required(),
|
|
@@ -14776,6 +14793,9 @@ var schemaUpdatePerson = import_joi36.default.object({
|
|
|
14776
14793
|
email: import_joi36.default.string().email().optional().allow(null, ""),
|
|
14777
14794
|
nric: import_joi36.default.string().optional().allow(null, ""),
|
|
14778
14795
|
remarks: import_joi36.default.string().optional().allow(null, ""),
|
|
14796
|
+
type: import_joi36.default.string().valid(...PERSON_TYPES).optional().allow(null, ""),
|
|
14797
|
+
org: import_joi36.default.string().hex().optional().allow(null, ""),
|
|
14798
|
+
site: import_joi36.default.string().hex().optional().allow(null, ""),
|
|
14779
14799
|
companyName: import_joi36.default.array().items(import_joi36.default.string()).optional().allow(null, ""),
|
|
14780
14800
|
plates: import_joi36.default.array().items(schemaFiles).optional().allow(null, ""),
|
|
14781
14801
|
isOwner: import_joi36.default.boolean().optional().allow(null, ""),
|
|
@@ -27454,6 +27474,7 @@ var import_node_server_utils112 = require("@7365admin1/node-server-utils");
|
|
|
27454
27474
|
|
|
27455
27475
|
// src/services/person.service.ts
|
|
27456
27476
|
var import_node_server_utils111 = require("@7365admin1/node-server-utils");
|
|
27477
|
+
var import_mongodb64 = require("mongodb");
|
|
27457
27478
|
function usePersonService() {
|
|
27458
27479
|
const MailerConfig = {
|
|
27459
27480
|
host: MAILER_TRANSPORT_HOST,
|
|
@@ -27475,7 +27496,8 @@ function usePersonService() {
|
|
|
27475
27496
|
createUser: addUser,
|
|
27476
27497
|
getUserByEmail,
|
|
27477
27498
|
updateUserFieldById: _updateUserFieldById,
|
|
27478
|
-
getUserById
|
|
27499
|
+
getUserById,
|
|
27500
|
+
updateUserOrgById: _updateUserOrgById
|
|
27479
27501
|
} = useUserRepo();
|
|
27480
27502
|
const { add: addMember } = useMemberRepo();
|
|
27481
27503
|
const { getById: _getUnitById, updateById: updateUnitById } = useBuildingUnitRepo();
|
|
@@ -27566,8 +27588,27 @@ function usePersonService() {
|
|
|
27566
27588
|
}
|
|
27567
27589
|
await _add(value, session);
|
|
27568
27590
|
await session.commitTransaction();
|
|
27591
|
+
if (value.email && isValidType && value.platform === "mobile") {
|
|
27592
|
+
const emailContent = (0, import_node_server_utils111.compileHandlebar)({
|
|
27593
|
+
context: { name: value.name },
|
|
27594
|
+
filePath: (0, import_node_server_utils111.getDirectory)(
|
|
27595
|
+
__dirname,
|
|
27596
|
+
"./public/handlebars/registration-pending"
|
|
27597
|
+
)
|
|
27598
|
+
});
|
|
27599
|
+
mailer.sendMail({
|
|
27600
|
+
to: value.email,
|
|
27601
|
+
subject: "Registration Received \u2013 Pending Review",
|
|
27602
|
+
html: emailContent,
|
|
27603
|
+
sender: "iService365"
|
|
27604
|
+
}).catch((error) => {
|
|
27605
|
+
import_node_server_utils111.logger.error(`Failed to send registration pending email: ${error}`);
|
|
27606
|
+
});
|
|
27607
|
+
}
|
|
27569
27608
|
return "People added successfully.";
|
|
27570
27609
|
} catch (error) {
|
|
27610
|
+
console.log("error message service", error);
|
|
27611
|
+
console.log("error message service", error.message);
|
|
27571
27612
|
import_node_server_utils111.logger.error("Error in people service add:", error);
|
|
27572
27613
|
await session.abortTransaction();
|
|
27573
27614
|
throw error;
|
|
@@ -27588,7 +27629,21 @@ function usePersonService() {
|
|
|
27588
27629
|
}
|
|
27589
27630
|
const isNameUpdated = typeof value.name === "string" && value.name.trim() !== person.name;
|
|
27590
27631
|
const isOwnerChanged = value.isOwner !== person.isOwner;
|
|
27632
|
+
if (value.org && typeof value.org === "string") {
|
|
27633
|
+
value.org = new import_mongodb64.ObjectId(value.org);
|
|
27634
|
+
}
|
|
27635
|
+
if (value.site && typeof value.site === "string") {
|
|
27636
|
+
value.site = new import_mongodb64.ObjectId(value.site);
|
|
27637
|
+
}
|
|
27638
|
+
const isOrgChanged = value.org && person.org?.toString() !== value.org.toString();
|
|
27591
27639
|
await _updateById(_id, value, session);
|
|
27640
|
+
if (isOrgChanged && person.user) {
|
|
27641
|
+
await _updateUserOrgById(
|
|
27642
|
+
person.user.toString(),
|
|
27643
|
+
value.org,
|
|
27644
|
+
session
|
|
27645
|
+
);
|
|
27646
|
+
}
|
|
27592
27647
|
if (value.unit && (isNameUpdated || isOwnerChanged || value.isOwner)) {
|
|
27593
27648
|
const unit = await _getUnitById(value.unit.toString());
|
|
27594
27649
|
if (unit) {
|
|
@@ -27610,7 +27665,11 @@ function usePersonService() {
|
|
|
27610
27665
|
updatePayload.ownerName = value.name || "";
|
|
27611
27666
|
}
|
|
27612
27667
|
if (Object.keys(updatePayload).length > 0 && unit && unit._id) {
|
|
27613
|
-
await updateUnitById(
|
|
27668
|
+
await updateUnitById(
|
|
27669
|
+
unit._id.toString(),
|
|
27670
|
+
updatePayload,
|
|
27671
|
+
session
|
|
27672
|
+
);
|
|
27614
27673
|
}
|
|
27615
27674
|
}
|
|
27616
27675
|
}
|
|
@@ -27700,13 +27759,13 @@ function usePersonService() {
|
|
|
27700
27759
|
title = "We request resubmission for your application";
|
|
27701
27760
|
hideLogin = false;
|
|
27702
27761
|
statusLogo = `${statusIconPath}/resubmission-icon.png`;
|
|
27703
|
-
message2 = `Hi ${person.name}, please resubmit your application with the required updates
|
|
27762
|
+
message2 = `Hi ${person.name}, please resubmit your application with the required updates.${value.remarks ? ` Remarks: ${value.remarks}` : ""}`;
|
|
27704
27763
|
break;
|
|
27705
27764
|
case "rejected":
|
|
27706
27765
|
userStatus = "rejected";
|
|
27707
|
-
title = "Your account request for
|
|
27766
|
+
title = "Your account request for application has been rejected.";
|
|
27708
27767
|
statusLogo = `${statusIconPath}/deleted-icon.png`;
|
|
27709
|
-
message2 = `Hi ${person.name}, unfortunately your application has been rejected. Please contact support for more information
|
|
27768
|
+
message2 = `Hi ${person.name}, unfortunately your application has been rejected.${value.remarks ? ` Remarks: ${value.remarks}` : " Please contact support for more information."}`;
|
|
27710
27769
|
break;
|
|
27711
27770
|
default:
|
|
27712
27771
|
throw new Error("Invalid review status");
|
|
@@ -28143,7 +28202,7 @@ function usePersonController() {
|
|
|
28143
28202
|
// src/models/robot.model.ts
|
|
28144
28203
|
var import_node_server_utils113 = require("@7365admin1/node-server-utils");
|
|
28145
28204
|
var import_joi61 = __toESM(require("joi"));
|
|
28146
|
-
var
|
|
28205
|
+
var import_mongodb65 = require("mongodb");
|
|
28147
28206
|
var metadataSchema4 = {
|
|
28148
28207
|
orgId: import_joi61.default.string().hex().optional().allow("", null),
|
|
28149
28208
|
siteId: import_joi61.default.string().hex().optional().allow("", null),
|
|
@@ -28168,21 +28227,21 @@ function MRobot(value) {
|
|
|
28168
28227
|
}
|
|
28169
28228
|
if (value.metadata?.orgId) {
|
|
28170
28229
|
try {
|
|
28171
|
-
value.metadata.orgId = new
|
|
28230
|
+
value.metadata.orgId = new import_mongodb65.ObjectId(value.metadata.orgId);
|
|
28172
28231
|
} catch (error2) {
|
|
28173
28232
|
throw new import_node_server_utils113.BadRequestError("Invalid organization ID format.");
|
|
28174
28233
|
}
|
|
28175
28234
|
}
|
|
28176
28235
|
if (value.metadata?.siteId) {
|
|
28177
28236
|
try {
|
|
28178
|
-
value.metadata.siteId = new
|
|
28237
|
+
value.metadata.siteId = new import_mongodb65.ObjectId(value.metadata.siteId);
|
|
28179
28238
|
} catch (error2) {
|
|
28180
28239
|
throw new import_node_server_utils113.BadRequestError("Invalid site ID format.");
|
|
28181
28240
|
}
|
|
28182
28241
|
}
|
|
28183
28242
|
if (value.metadata?.administratorId) {
|
|
28184
28243
|
try {
|
|
28185
|
-
value.metadata.administratorId = new
|
|
28244
|
+
value.metadata.administratorId = new import_mongodb65.ObjectId(
|
|
28186
28245
|
value.metadata.administratorId
|
|
28187
28246
|
);
|
|
28188
28247
|
} catch (error2) {
|
|
@@ -28191,7 +28250,7 @@ function MRobot(value) {
|
|
|
28191
28250
|
}
|
|
28192
28251
|
if (value.createdBy) {
|
|
28193
28252
|
try {
|
|
28194
|
-
value.createdBy = new
|
|
28253
|
+
value.createdBy = new import_mongodb65.ObjectId(value.createdBy);
|
|
28195
28254
|
} catch (error2) {
|
|
28196
28255
|
throw new import_node_server_utils113.BadRequestError("Invalid created by ID format.");
|
|
28197
28256
|
}
|
|
@@ -28216,7 +28275,7 @@ function MRobot(value) {
|
|
|
28216
28275
|
}
|
|
28217
28276
|
|
|
28218
28277
|
// src/repositories/robot.repo.ts
|
|
28219
|
-
var
|
|
28278
|
+
var import_mongodb66 = require("mongodb");
|
|
28220
28279
|
var import_node_server_utils114 = require("@7365admin1/node-server-utils");
|
|
28221
28280
|
function useRobotRepo() {
|
|
28222
28281
|
const db = import_node_server_utils114.useAtlas.getDb();
|
|
@@ -28277,12 +28336,12 @@ function useRobotRepo() {
|
|
|
28277
28336
|
}) {
|
|
28278
28337
|
page = page > 0 ? page - 1 : 0;
|
|
28279
28338
|
try {
|
|
28280
|
-
organization = new
|
|
28339
|
+
organization = new import_mongodb66.ObjectId(organization);
|
|
28281
28340
|
} catch (error) {
|
|
28282
28341
|
throw new import_node_server_utils114.BadRequestError("Invalid organization ID format.");
|
|
28283
28342
|
}
|
|
28284
28343
|
try {
|
|
28285
|
-
site = new
|
|
28344
|
+
site = new import_mongodb66.ObjectId(site);
|
|
28286
28345
|
} catch (error) {
|
|
28287
28346
|
throw new import_node_server_utils114.BadRequestError("Invalid site ID format.");
|
|
28288
28347
|
}
|
|
@@ -28505,7 +28564,7 @@ function useRobotController() {
|
|
|
28505
28564
|
|
|
28506
28565
|
// src/models/patrol-question.model.ts
|
|
28507
28566
|
var import_node_server_utils117 = require("@7365admin1/node-server-utils");
|
|
28508
|
-
var
|
|
28567
|
+
var import_mongodb67 = require("mongodb");
|
|
28509
28568
|
var import_joi63 = __toESM(require("joi"));
|
|
28510
28569
|
var schemaPatrolQuestion = import_joi63.default.object({
|
|
28511
28570
|
_id: import_joi63.default.string().hex().optional(),
|
|
@@ -28531,14 +28590,14 @@ function MPatrolQuestion(value) {
|
|
|
28531
28590
|
}
|
|
28532
28591
|
if (value._id && typeof value._id === "string") {
|
|
28533
28592
|
try {
|
|
28534
|
-
value._id = new
|
|
28593
|
+
value._id = new import_mongodb67.ObjectId(value._id);
|
|
28535
28594
|
} catch {
|
|
28536
28595
|
throw new import_node_server_utils117.BadRequestError("Invalid _id format");
|
|
28537
28596
|
}
|
|
28538
28597
|
}
|
|
28539
28598
|
return {
|
|
28540
|
-
_id: value._id ?? new
|
|
28541
|
-
site: new
|
|
28599
|
+
_id: value._id ?? new import_mongodb67.ObjectId(),
|
|
28600
|
+
site: new import_mongodb67.ObjectId(value.site),
|
|
28542
28601
|
question: value.question,
|
|
28543
28602
|
answers: value.answers,
|
|
28544
28603
|
status: value.status ?? "active",
|
|
@@ -28550,7 +28609,7 @@ function MPatrolQuestion(value) {
|
|
|
28550
28609
|
|
|
28551
28610
|
// src/repositories/patrol-question.repo.ts
|
|
28552
28611
|
var import_node_server_utils118 = require("@7365admin1/node-server-utils");
|
|
28553
|
-
var
|
|
28612
|
+
var import_mongodb68 = require("mongodb");
|
|
28554
28613
|
function usePatrolQuestionRepo() {
|
|
28555
28614
|
const db = import_node_server_utils118.useAtlas.getDb();
|
|
28556
28615
|
if (!db) {
|
|
@@ -28629,7 +28688,7 @@ function usePatrolQuestionRepo() {
|
|
|
28629
28688
|
{ answers: { $regex: search, $options: "i" } }
|
|
28630
28689
|
]
|
|
28631
28690
|
},
|
|
28632
|
-
...
|
|
28691
|
+
...import_mongodb68.ObjectId.isValid(site) && { site: new import_mongodb68.ObjectId(site) }
|
|
28633
28692
|
};
|
|
28634
28693
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
28635
28694
|
const cacheOptions = {
|
|
@@ -28669,7 +28728,7 @@ function usePatrolQuestionRepo() {
|
|
|
28669
28728
|
}
|
|
28670
28729
|
async function updateById(_id, value, session) {
|
|
28671
28730
|
try {
|
|
28672
|
-
_id = new
|
|
28731
|
+
_id = new import_mongodb68.ObjectId(_id);
|
|
28673
28732
|
} catch (error) {
|
|
28674
28733
|
throw new import_node_server_utils118.BadRequestError(
|
|
28675
28734
|
"Invalid patrol question transaction ID format."
|
|
@@ -28690,7 +28749,7 @@ function usePatrolQuestionRepo() {
|
|
|
28690
28749
|
}
|
|
28691
28750
|
async function deleteById(_id) {
|
|
28692
28751
|
try {
|
|
28693
|
-
_id = new
|
|
28752
|
+
_id = new import_mongodb68.ObjectId(_id);
|
|
28694
28753
|
} catch (error) {
|
|
28695
28754
|
throw new import_node_server_utils118.BadRequestError("Invalid customer ID format.");
|
|
28696
28755
|
}
|
|
@@ -28712,7 +28771,7 @@ function usePatrolQuestionRepo() {
|
|
|
28712
28771
|
}
|
|
28713
28772
|
async function getById(_id, session) {
|
|
28714
28773
|
try {
|
|
28715
|
-
_id = new
|
|
28774
|
+
_id = new import_mongodb68.ObjectId(_id);
|
|
28716
28775
|
} catch (error) {
|
|
28717
28776
|
throw new import_node_server_utils118.BadRequestError("Invalid patrol question ID format.");
|
|
28718
28777
|
}
|
|
@@ -28887,7 +28946,7 @@ function usePatrolQuestionController() {
|
|
|
28887
28946
|
|
|
28888
28947
|
// src/models/patrol-route.model.ts
|
|
28889
28948
|
var import_node_server_utils120 = require("@7365admin1/node-server-utils");
|
|
28890
|
-
var
|
|
28949
|
+
var import_mongodb69 = require("mongodb");
|
|
28891
28950
|
var import_joi65 = __toESM(require("joi"));
|
|
28892
28951
|
var schemeCamera = import_joi65.default.object({
|
|
28893
28952
|
camera: import_joi65.default.string().hex().required(),
|
|
@@ -28935,14 +28994,14 @@ function MPatrolRoute(value) {
|
|
|
28935
28994
|
}
|
|
28936
28995
|
if (value._id && typeof value._id === "string") {
|
|
28937
28996
|
try {
|
|
28938
|
-
value._id = new
|
|
28997
|
+
value._id = new import_mongodb69.ObjectId(value._id);
|
|
28939
28998
|
} catch {
|
|
28940
28999
|
throw new import_node_server_utils120.BadRequestError("Invalid _id format");
|
|
28941
29000
|
}
|
|
28942
29001
|
}
|
|
28943
29002
|
if (value.assignee && Array.isArray(value.assignee)) {
|
|
28944
29003
|
try {
|
|
28945
|
-
value.assignee = value.assignee.map((id) => new
|
|
29004
|
+
value.assignee = value.assignee.map((id) => new import_mongodb69.ObjectId(id));
|
|
28946
29005
|
} catch {
|
|
28947
29006
|
throw new import_node_server_utils120.BadRequestError("Invalid assignee id format");
|
|
28948
29007
|
}
|
|
@@ -28951,7 +29010,7 @@ function MPatrolRoute(value) {
|
|
|
28951
29010
|
value.cameras = value.cameras.map((camera) => {
|
|
28952
29011
|
if (typeof camera.camera === "string") {
|
|
28953
29012
|
try {
|
|
28954
|
-
camera.camera = new
|
|
29013
|
+
camera.camera = new import_mongodb69.ObjectId(camera.camera);
|
|
28955
29014
|
} catch {
|
|
28956
29015
|
throw new import_node_server_utils120.BadRequestError("Invalid camera id format");
|
|
28957
29016
|
}
|
|
@@ -28959,7 +29018,7 @@ function MPatrolRoute(value) {
|
|
|
28959
29018
|
camera.questions = camera.questions.map((question) => {
|
|
28960
29019
|
if (typeof question.questionId === "string") {
|
|
28961
29020
|
try {
|
|
28962
|
-
question.questionId = new
|
|
29021
|
+
question.questionId = new import_mongodb69.ObjectId(question.questionId);
|
|
28963
29022
|
} catch {
|
|
28964
29023
|
throw new import_node_server_utils120.BadRequestError("Invalid question id format");
|
|
28965
29024
|
}
|
|
@@ -28970,8 +29029,8 @@ function MPatrolRoute(value) {
|
|
|
28970
29029
|
});
|
|
28971
29030
|
}
|
|
28972
29031
|
return {
|
|
28973
|
-
_id: value._id ?? new
|
|
28974
|
-
site: new
|
|
29032
|
+
_id: value._id ?? new import_mongodb69.ObjectId(),
|
|
29033
|
+
site: new import_mongodb69.ObjectId(value.site),
|
|
28975
29034
|
name: value.name,
|
|
28976
29035
|
assignee: value.assignee,
|
|
28977
29036
|
start: value.start,
|
|
@@ -28988,7 +29047,7 @@ function MPatrolRoute(value) {
|
|
|
28988
29047
|
|
|
28989
29048
|
// src/repositories/patrol-route.repo.ts
|
|
28990
29049
|
var import_node_server_utils121 = require("@7365admin1/node-server-utils");
|
|
28991
|
-
var
|
|
29050
|
+
var import_mongodb70 = require("mongodb");
|
|
28992
29051
|
function usePatrolRouteRepo() {
|
|
28993
29052
|
const db = import_node_server_utils121.useAtlas.getDb();
|
|
28994
29053
|
if (!db) {
|
|
@@ -29064,7 +29123,7 @@ function usePatrolRouteRepo() {
|
|
|
29064
29123
|
page = page > 0 ? page - 1 : 0;
|
|
29065
29124
|
const query = {
|
|
29066
29125
|
status,
|
|
29067
|
-
...
|
|
29126
|
+
...import_mongodb70.ObjectId.isValid(site) && { site: new import_mongodb70.ObjectId(site) }
|
|
29068
29127
|
};
|
|
29069
29128
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
29070
29129
|
const cacheOptions = {
|
|
@@ -29147,20 +29206,20 @@ function usePatrolRouteRepo() {
|
|
|
29147
29206
|
}
|
|
29148
29207
|
async function updateById(_id, value, session) {
|
|
29149
29208
|
try {
|
|
29150
|
-
_id = new
|
|
29209
|
+
_id = new import_mongodb70.ObjectId(_id);
|
|
29151
29210
|
} catch (error) {
|
|
29152
29211
|
throw new import_node_server_utils121.BadRequestError("Invalid patrol route transaction ID format.");
|
|
29153
29212
|
}
|
|
29154
|
-
if (value.site &&
|
|
29213
|
+
if (value.site && import_mongodb70.ObjectId.isValid(value.site.toString())) {
|
|
29155
29214
|
try {
|
|
29156
|
-
value.site = new
|
|
29215
|
+
value.site = new import_mongodb70.ObjectId(value.site.toString());
|
|
29157
29216
|
} catch {
|
|
29158
29217
|
throw new import_node_server_utils121.BadRequestError("Invalid _id format");
|
|
29159
29218
|
}
|
|
29160
29219
|
}
|
|
29161
29220
|
if (value.assignee && Array.isArray(value.assignee)) {
|
|
29162
29221
|
try {
|
|
29163
|
-
value.assignee = value.assignee.map((id) => new
|
|
29222
|
+
value.assignee = value.assignee.map((id) => new import_mongodb70.ObjectId(id));
|
|
29164
29223
|
} catch {
|
|
29165
29224
|
throw new import_node_server_utils121.BadRequestError("Invalid _id format");
|
|
29166
29225
|
}
|
|
@@ -29180,7 +29239,7 @@ function usePatrolRouteRepo() {
|
|
|
29180
29239
|
}
|
|
29181
29240
|
async function deleteById(_id) {
|
|
29182
29241
|
try {
|
|
29183
|
-
_id = new
|
|
29242
|
+
_id = new import_mongodb70.ObjectId(_id);
|
|
29184
29243
|
} catch (error) {
|
|
29185
29244
|
throw new import_node_server_utils121.BadRequestError("Invalid patrol route transaction ID format.");
|
|
29186
29245
|
}
|
|
@@ -29229,7 +29288,7 @@ function usePatrolRouteRepo() {
|
|
|
29229
29288
|
const query = {
|
|
29230
29289
|
status,
|
|
29231
29290
|
...search && { $text: { $search: search } },
|
|
29232
|
-
...
|
|
29291
|
+
...import_mongodb70.ObjectId.isValid(site) && { site: new import_mongodb70.ObjectId(site) }
|
|
29233
29292
|
};
|
|
29234
29293
|
if (day && start) {
|
|
29235
29294
|
const [hour, minute] = start?.split(":") ?? ["0", "0"];
|
|
@@ -29312,7 +29371,7 @@ function usePatrolRouteRepo() {
|
|
|
29312
29371
|
id: "$_id",
|
|
29313
29372
|
start: startOfDay,
|
|
29314
29373
|
end: endOfDay,
|
|
29315
|
-
site:
|
|
29374
|
+
site: import_mongodb70.ObjectId.isValid(site) ? new import_mongodb70.ObjectId(site) : null
|
|
29316
29375
|
},
|
|
29317
29376
|
pipeline: [
|
|
29318
29377
|
{
|
|
@@ -29358,7 +29417,7 @@ function usePatrolRouteRepo() {
|
|
|
29358
29417
|
}
|
|
29359
29418
|
async function getById(_id, session) {
|
|
29360
29419
|
try {
|
|
29361
|
-
_id = new
|
|
29420
|
+
_id = new import_mongodb70.ObjectId(_id);
|
|
29362
29421
|
} catch (error) {
|
|
29363
29422
|
throw new import_node_server_utils121.BadRequestError("Invalid patrol log ID format.");
|
|
29364
29423
|
}
|
|
@@ -29603,7 +29662,7 @@ function usePatrolRouteController() {
|
|
|
29603
29662
|
|
|
29604
29663
|
// src/models/patrol-log.model.ts
|
|
29605
29664
|
var import_node_server_utils123 = require("@7365admin1/node-server-utils");
|
|
29606
|
-
var
|
|
29665
|
+
var import_mongodb71 = require("mongodb");
|
|
29607
29666
|
var import_joi67 = __toESM(require("joi"));
|
|
29608
29667
|
var schemeLogCamera = import_joi67.default.object({
|
|
29609
29668
|
camera: import_joi67.default.string().hex().required(),
|
|
@@ -29664,41 +29723,41 @@ function MPatrolLog(value) {
|
|
|
29664
29723
|
}
|
|
29665
29724
|
if (value._id && typeof value._id === "string") {
|
|
29666
29725
|
try {
|
|
29667
|
-
value._id = new
|
|
29726
|
+
value._id = new import_mongodb71.ObjectId(value._id);
|
|
29668
29727
|
} catch {
|
|
29669
29728
|
throw new import_node_server_utils123.BadRequestError("Invalid _id format");
|
|
29670
29729
|
}
|
|
29671
29730
|
}
|
|
29672
29731
|
if (value.route && typeof value.route === "string") {
|
|
29673
29732
|
try {
|
|
29674
|
-
value.route = new
|
|
29733
|
+
value.route = new import_mongodb71.ObjectId(value.route);
|
|
29675
29734
|
} catch {
|
|
29676
29735
|
throw new import_node_server_utils123.BadRequestError("Invalid route id format");
|
|
29677
29736
|
}
|
|
29678
29737
|
}
|
|
29679
29738
|
if (value.site && typeof value.site === "string") {
|
|
29680
29739
|
try {
|
|
29681
|
-
value.site = new
|
|
29740
|
+
value.site = new import_mongodb71.ObjectId(value.site);
|
|
29682
29741
|
} catch {
|
|
29683
29742
|
throw new import_node_server_utils123.BadRequestError("Invalid site id format");
|
|
29684
29743
|
}
|
|
29685
29744
|
}
|
|
29686
29745
|
const assignee = (value.assignee || []).map((id) => {
|
|
29687
29746
|
try {
|
|
29688
|
-
return new
|
|
29747
|
+
return new import_mongodb71.ObjectId(id);
|
|
29689
29748
|
} catch {
|
|
29690
29749
|
throw new import_node_server_utils123.BadRequestError("Invalid assignee id format");
|
|
29691
29750
|
}
|
|
29692
29751
|
});
|
|
29693
29752
|
if (value.incidentReport && typeof value.incidentReport.id === "string") {
|
|
29694
29753
|
try {
|
|
29695
|
-
value.incidentReport.id = new
|
|
29754
|
+
value.incidentReport.id = new import_mongodb71.ObjectId(value.incidentReport.id);
|
|
29696
29755
|
} catch {
|
|
29697
29756
|
throw new import_node_server_utils123.BadRequestError("Invalid incident report id format");
|
|
29698
29757
|
}
|
|
29699
29758
|
}
|
|
29700
29759
|
return {
|
|
29701
|
-
_id: value._id ?? new
|
|
29760
|
+
_id: value._id ?? new import_mongodb71.ObjectId(),
|
|
29702
29761
|
site: value.site,
|
|
29703
29762
|
name: value.name,
|
|
29704
29763
|
assignee,
|
|
@@ -29717,7 +29776,7 @@ function MPatrolLog(value) {
|
|
|
29717
29776
|
|
|
29718
29777
|
// src/repositories/patrol-log.repo.ts
|
|
29719
29778
|
var import_node_server_utils124 = require("@7365admin1/node-server-utils");
|
|
29720
|
-
var
|
|
29779
|
+
var import_mongodb72 = require("mongodb");
|
|
29721
29780
|
function usePatrolLogRepo() {
|
|
29722
29781
|
const db = import_node_server_utils124.useAtlas.getDb();
|
|
29723
29782
|
if (!db) {
|
|
@@ -29808,7 +29867,7 @@ function usePatrolLogRepo() {
|
|
|
29808
29867
|
};
|
|
29809
29868
|
}
|
|
29810
29869
|
const query = {
|
|
29811
|
-
...
|
|
29870
|
+
...import_mongodb72.ObjectId.isValid(site) && { site: new import_mongodb72.ObjectId(site) },
|
|
29812
29871
|
...dateExpr
|
|
29813
29872
|
};
|
|
29814
29873
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -29948,7 +30007,7 @@ function usePatrolLogRepo() {
|
|
|
29948
30007
|
}
|
|
29949
30008
|
async function updateById(_id, value, session) {
|
|
29950
30009
|
try {
|
|
29951
|
-
_id = new
|
|
30010
|
+
_id = new import_mongodb72.ObjectId(_id);
|
|
29952
30011
|
} catch (error) {
|
|
29953
30012
|
throw new import_node_server_utils124.BadRequestError("Invalid patrol log transaction ID format.");
|
|
29954
30013
|
}
|
|
@@ -29967,7 +30026,7 @@ function usePatrolLogRepo() {
|
|
|
29967
30026
|
}
|
|
29968
30027
|
async function deleteById(_id, session) {
|
|
29969
30028
|
try {
|
|
29970
|
-
_id = new
|
|
30029
|
+
_id = new import_mongodb72.ObjectId(_id);
|
|
29971
30030
|
} catch (error) {
|
|
29972
30031
|
throw new import_node_server_utils124.BadRequestError("Invalid patrol log ID format.");
|
|
29973
30032
|
}
|
|
@@ -29981,7 +30040,7 @@ function usePatrolLogRepo() {
|
|
|
29981
30040
|
}
|
|
29982
30041
|
async function getById(_id, session) {
|
|
29983
30042
|
try {
|
|
29984
|
-
_id = new
|
|
30043
|
+
_id = new import_mongodb72.ObjectId(_id);
|
|
29985
30044
|
} catch (error) {
|
|
29986
30045
|
throw new import_node_server_utils124.BadRequestError("Invalid patrol log ID format.");
|
|
29987
30046
|
}
|
|
@@ -30229,7 +30288,7 @@ function usePatrolLogController() {
|
|
|
30229
30288
|
|
|
30230
30289
|
// src/models/site-facility.model.ts
|
|
30231
30290
|
var import_joi69 = __toESM(require("joi"));
|
|
30232
|
-
var
|
|
30291
|
+
var import_mongodb73 = require("mongodb");
|
|
30233
30292
|
var timeSlotSchema = import_joi69.default.array().items(
|
|
30234
30293
|
import_joi69.default.object({
|
|
30235
30294
|
start: import_joi69.default.string().optional().allow("", null),
|
|
@@ -30389,28 +30448,28 @@ function MSiteFacility(value) {
|
|
|
30389
30448
|
throw new Error(error.details[0].message);
|
|
30390
30449
|
if (value._id && typeof value._id === "string") {
|
|
30391
30450
|
try {
|
|
30392
|
-
value._id = new
|
|
30451
|
+
value._id = new import_mongodb73.ObjectId(value._id);
|
|
30393
30452
|
} catch {
|
|
30394
30453
|
throw new Error("Invalid _id.");
|
|
30395
30454
|
}
|
|
30396
30455
|
}
|
|
30397
30456
|
if (value.site && typeof value.site === "string") {
|
|
30398
30457
|
try {
|
|
30399
|
-
value.site = new
|
|
30458
|
+
value.site = new import_mongodb73.ObjectId(value.site);
|
|
30400
30459
|
} catch {
|
|
30401
30460
|
throw new Error("Invalid _id.");
|
|
30402
30461
|
}
|
|
30403
30462
|
}
|
|
30404
30463
|
if (value.featuredImage && typeof value.featuredImage === "string") {
|
|
30405
30464
|
try {
|
|
30406
|
-
value.featuredImage = new
|
|
30465
|
+
value.featuredImage = new import_mongodb73.ObjectId(value.featuredImage);
|
|
30407
30466
|
} catch {
|
|
30408
30467
|
throw new Error("Invalid featuredImage ID.");
|
|
30409
30468
|
}
|
|
30410
30469
|
}
|
|
30411
30470
|
if (Array.isArray(value.gallery)) {
|
|
30412
30471
|
try {
|
|
30413
|
-
value.gallery = value.gallery.map((id) => new
|
|
30472
|
+
value.gallery = value.gallery.map((id) => new import_mongodb73.ObjectId(id));
|
|
30414
30473
|
} catch {
|
|
30415
30474
|
throw new Error("Invalid ID in gallery array.");
|
|
30416
30475
|
}
|
|
@@ -30494,7 +30553,7 @@ function MSiteFacility(value) {
|
|
|
30494
30553
|
|
|
30495
30554
|
// src/repositories/site-facility.repo.ts
|
|
30496
30555
|
var import_node_server_utils127 = require("@7365admin1/node-server-utils");
|
|
30497
|
-
var
|
|
30556
|
+
var import_mongodb74 = require("mongodb");
|
|
30498
30557
|
function useSiteFacilityRepo() {
|
|
30499
30558
|
const db = import_node_server_utils127.useAtlas.getDb();
|
|
30500
30559
|
if (!db) {
|
|
@@ -30562,7 +30621,7 @@ function useSiteFacilityRepo() {
|
|
|
30562
30621
|
};
|
|
30563
30622
|
if (site) {
|
|
30564
30623
|
try {
|
|
30565
|
-
site = new
|
|
30624
|
+
site = new import_mongodb74.ObjectId(site);
|
|
30566
30625
|
query.site = site;
|
|
30567
30626
|
cacheOptions.site = site.toString();
|
|
30568
30627
|
} catch (error) {
|
|
@@ -30607,7 +30666,7 @@ function useSiteFacilityRepo() {
|
|
|
30607
30666
|
}
|
|
30608
30667
|
async function getSiteFacilityById(_id, session) {
|
|
30609
30668
|
try {
|
|
30610
|
-
_id = new
|
|
30669
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30611
30670
|
} catch (error) {
|
|
30612
30671
|
throw new import_node_server_utils127.BadRequestError("Invalid site facility ID format.");
|
|
30613
30672
|
}
|
|
@@ -30635,20 +30694,20 @@ function useSiteFacilityRepo() {
|
|
|
30635
30694
|
async function updateSiteFacilityById(_id, value, session) {
|
|
30636
30695
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
30637
30696
|
try {
|
|
30638
|
-
_id = new
|
|
30697
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30639
30698
|
} catch (error) {
|
|
30640
30699
|
throw new import_node_server_utils127.BadRequestError("Invalid ID format.");
|
|
30641
30700
|
}
|
|
30642
30701
|
if (value.featuredImage) {
|
|
30643
30702
|
try {
|
|
30644
|
-
value.featuredImage = new
|
|
30703
|
+
value.featuredImage = new import_mongodb74.ObjectId(value.featuredImage);
|
|
30645
30704
|
} catch (error) {
|
|
30646
30705
|
throw new import_node_server_utils127.BadRequestError("Invalid ID format for featured image.");
|
|
30647
30706
|
}
|
|
30648
30707
|
}
|
|
30649
30708
|
if (Array.isArray(value.gallery)) {
|
|
30650
30709
|
try {
|
|
30651
|
-
value.gallery = value.gallery.map((id) => new
|
|
30710
|
+
value.gallery = value.gallery.map((id) => new import_mongodb74.ObjectId(id));
|
|
30652
30711
|
} catch {
|
|
30653
30712
|
throw new Error("Invalid ID in gallery array.");
|
|
30654
30713
|
}
|
|
@@ -30694,7 +30753,7 @@ function useSiteFacilityRepo() {
|
|
|
30694
30753
|
}
|
|
30695
30754
|
async function deleteSiteFacilityById(_id) {
|
|
30696
30755
|
try {
|
|
30697
|
-
_id = new
|
|
30756
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30698
30757
|
} catch (error) {
|
|
30699
30758
|
throw new import_node_server_utils127.BadRequestError("Invalid site facility ID format.");
|
|
30700
30759
|
}
|
|
@@ -30723,12 +30782,12 @@ function useSiteFacilityRepo() {
|
|
|
30723
30782
|
}
|
|
30724
30783
|
async function getSiteFacilityTimeSlotById(_id, site, session) {
|
|
30725
30784
|
try {
|
|
30726
|
-
_id = new
|
|
30785
|
+
_id = new import_mongodb74.ObjectId(_id);
|
|
30727
30786
|
} catch (error) {
|
|
30728
30787
|
throw new import_node_server_utils127.BadRequestError("Invalid facility ID format.");
|
|
30729
30788
|
}
|
|
30730
30789
|
try {
|
|
30731
|
-
site = new
|
|
30790
|
+
site = new import_mongodb74.ObjectId(site);
|
|
30732
30791
|
} catch (error) {
|
|
30733
30792
|
throw new import_node_server_utils127.BadRequestError("Invalid site ID format.");
|
|
30734
30793
|
}
|
|
@@ -31071,7 +31130,7 @@ function useSiteFacilityController() {
|
|
|
31071
31130
|
|
|
31072
31131
|
// src/models/service-provider-billing.model.ts
|
|
31073
31132
|
var import_joi71 = __toESM(require("joi"));
|
|
31074
|
-
var
|
|
31133
|
+
var import_mongodb75 = require("mongodb");
|
|
31075
31134
|
var schemaServiceProviderBilling = import_joi71.default.object({
|
|
31076
31135
|
_id: import_joi71.default.string().hex().optional().allow("", null),
|
|
31077
31136
|
attachments: import_joi71.default.array().items(import_joi71.default.string().hex()).required(),
|
|
@@ -31105,7 +31164,7 @@ function MServiceProviderBilling(value) {
|
|
|
31105
31164
|
}
|
|
31106
31165
|
if (value._id && typeof value._id === "string") {
|
|
31107
31166
|
try {
|
|
31108
|
-
value._id = new
|
|
31167
|
+
value._id = new import_mongodb75.ObjectId(value._id);
|
|
31109
31168
|
} catch {
|
|
31110
31169
|
throw new Error("Invalid ID.");
|
|
31111
31170
|
}
|
|
@@ -31114,7 +31173,7 @@ function MServiceProviderBilling(value) {
|
|
|
31114
31173
|
value.acknowledgedBy = value.acknowledgedBy.map((item) => {
|
|
31115
31174
|
if (item.user && typeof item.user === "string") {
|
|
31116
31175
|
try {
|
|
31117
|
-
item.user = new
|
|
31176
|
+
item.user = new import_mongodb75.ObjectId(item.user);
|
|
31118
31177
|
} catch (error2) {
|
|
31119
31178
|
throw new Error("Invalid ID format for acknowledgedBy.user.");
|
|
31120
31179
|
}
|
|
@@ -31124,13 +31183,13 @@ function MServiceProviderBilling(value) {
|
|
|
31124
31183
|
}
|
|
31125
31184
|
if (value.orgId && typeof value.orgId === "string") {
|
|
31126
31185
|
try {
|
|
31127
|
-
value.orgId = new
|
|
31186
|
+
value.orgId = new import_mongodb75.ObjectId(value.orgId);
|
|
31128
31187
|
} catch {
|
|
31129
31188
|
throw new Error("Invalid org ID.");
|
|
31130
31189
|
}
|
|
31131
31190
|
}
|
|
31132
31191
|
return {
|
|
31133
|
-
_id: value._id ?? new
|
|
31192
|
+
_id: value._id ?? new import_mongodb75.ObjectId(),
|
|
31134
31193
|
attachments: value.attachments,
|
|
31135
31194
|
acknowledgedBy: value.acknowledgedBy || [],
|
|
31136
31195
|
status: value.status,
|
|
@@ -31143,7 +31202,7 @@ function MServiceProviderBilling(value) {
|
|
|
31143
31202
|
|
|
31144
31203
|
// src/repositories/service-provider-billing.repo.ts
|
|
31145
31204
|
var import_node_server_utils130 = require("@7365admin1/node-server-utils");
|
|
31146
|
-
var
|
|
31205
|
+
var import_mongodb76 = require("mongodb");
|
|
31147
31206
|
function useServiceProviderBillingRepo() {
|
|
31148
31207
|
const db = import_node_server_utils130.useAtlas.getDb();
|
|
31149
31208
|
if (!db) {
|
|
@@ -31190,7 +31249,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31190
31249
|
}, session) {
|
|
31191
31250
|
page = page > 0 ? page - 1 : 0;
|
|
31192
31251
|
try {
|
|
31193
|
-
org = new
|
|
31252
|
+
org = new import_mongodb76.ObjectId(org);
|
|
31194
31253
|
} catch (error) {
|
|
31195
31254
|
throw new import_node_server_utils130.BadRequestError("Invalid org ID format.");
|
|
31196
31255
|
}
|
|
@@ -31240,7 +31299,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31240
31299
|
}
|
|
31241
31300
|
async function getSiteServiceProviderBillingById(_id, session) {
|
|
31242
31301
|
try {
|
|
31243
|
-
_id = new
|
|
31302
|
+
_id = new import_mongodb76.ObjectId(_id);
|
|
31244
31303
|
} catch (error) {
|
|
31245
31304
|
throw new import_node_server_utils130.BadRequestError("Invalid service provider billing ID format.");
|
|
31246
31305
|
}
|
|
@@ -31268,7 +31327,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31268
31327
|
async function updateServiceProviderBillingById(_id, value, session) {
|
|
31269
31328
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
31270
31329
|
try {
|
|
31271
|
-
_id = new
|
|
31330
|
+
_id = new import_mongodb76.ObjectId(_id);
|
|
31272
31331
|
} catch (error) {
|
|
31273
31332
|
throw new import_node_server_utils130.BadRequestError("Invalid ID format.");
|
|
31274
31333
|
}
|
|
@@ -31276,7 +31335,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31276
31335
|
value.acknowledgedBy = value.acknowledgedBy.map((item) => {
|
|
31277
31336
|
if (item.user && typeof item.user === "string") {
|
|
31278
31337
|
try {
|
|
31279
|
-
item.user = new
|
|
31338
|
+
item.user = new import_mongodb76.ObjectId(item.user);
|
|
31280
31339
|
} catch (error) {
|
|
31281
31340
|
throw new Error("Invalid ID format for acknowledgedBy.user.");
|
|
31282
31341
|
}
|
|
@@ -31310,7 +31369,7 @@ function useServiceProviderBillingRepo() {
|
|
|
31310
31369
|
}
|
|
31311
31370
|
async function deleteServiceProviderBillingById(_id) {
|
|
31312
31371
|
try {
|
|
31313
|
-
_id = new
|
|
31372
|
+
_id = new import_mongodb76.ObjectId(_id);
|
|
31314
31373
|
} catch (error) {
|
|
31315
31374
|
throw new import_node_server_utils130.BadRequestError("Invalid service provider billing ID format.");
|
|
31316
31375
|
}
|
|
@@ -31548,7 +31607,7 @@ function useServiceProviderBillingController() {
|
|
|
31548
31607
|
|
|
31549
31608
|
// src/models/site-facility-booking.model.ts
|
|
31550
31609
|
var import_joi73 = __toESM(require("joi"));
|
|
31551
|
-
var
|
|
31610
|
+
var import_mongodb77 = require("mongodb");
|
|
31552
31611
|
var FacilitySort = /* @__PURE__ */ ((FacilitySort2) => {
|
|
31553
31612
|
FacilitySort2["CREATED_AT"] = "createdAt";
|
|
31554
31613
|
FacilitySort2["NAME"] = "name";
|
|
@@ -31658,48 +31717,48 @@ function MSiteFacilityBooking(value) {
|
|
|
31658
31717
|
}
|
|
31659
31718
|
if (value._id && typeof value._id === "string") {
|
|
31660
31719
|
try {
|
|
31661
|
-
value._id = new
|
|
31720
|
+
value._id = new import_mongodb77.ObjectId(value._id);
|
|
31662
31721
|
} catch {
|
|
31663
31722
|
throw new Error("Invalid ID.");
|
|
31664
31723
|
}
|
|
31665
31724
|
}
|
|
31666
31725
|
if (value.site && typeof value.site === "string") {
|
|
31667
31726
|
try {
|
|
31668
|
-
value.site = new
|
|
31727
|
+
value.site = new import_mongodb77.ObjectId(value.site);
|
|
31669
31728
|
} catch {
|
|
31670
31729
|
throw new Error("Invalid site ID.");
|
|
31671
31730
|
}
|
|
31672
31731
|
}
|
|
31673
31732
|
if (value.user && typeof value.user === "string") {
|
|
31674
31733
|
try {
|
|
31675
|
-
value.user = new
|
|
31734
|
+
value.user = new import_mongodb77.ObjectId(value.user);
|
|
31676
31735
|
} catch {
|
|
31677
31736
|
throw new Error("Invalid user ID.");
|
|
31678
31737
|
}
|
|
31679
31738
|
}
|
|
31680
31739
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
31681
31740
|
try {
|
|
31682
|
-
value.approvedBy = new
|
|
31741
|
+
value.approvedBy = new import_mongodb77.ObjectId(value.approvedBy);
|
|
31683
31742
|
} catch {
|
|
31684
31743
|
throw new Error("Invalid approved by ID.");
|
|
31685
31744
|
}
|
|
31686
31745
|
}
|
|
31687
31746
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
31688
31747
|
try {
|
|
31689
|
-
value.createdBy = new
|
|
31748
|
+
value.createdBy = new import_mongodb77.ObjectId(value.createdBy);
|
|
31690
31749
|
} catch {
|
|
31691
31750
|
throw new Error("Invalid created by ID.");
|
|
31692
31751
|
}
|
|
31693
31752
|
}
|
|
31694
31753
|
if (value.updatedBy && typeof value.updatedBy === "string") {
|
|
31695
31754
|
try {
|
|
31696
|
-
value.updatedBy = new
|
|
31755
|
+
value.updatedBy = new import_mongodb77.ObjectId(value.updatedBy);
|
|
31697
31756
|
} catch {
|
|
31698
31757
|
throw new Error("Invalid updated by ID.");
|
|
31699
31758
|
}
|
|
31700
31759
|
}
|
|
31701
31760
|
return {
|
|
31702
|
-
_id: value._id ?? new
|
|
31761
|
+
_id: value._id ?? new import_mongodb77.ObjectId(),
|
|
31703
31762
|
facility: value.facility ?? "",
|
|
31704
31763
|
slot: value.slot ?? "",
|
|
31705
31764
|
slotName: value.slotName ?? "",
|
|
@@ -31785,7 +31844,7 @@ function MSiteFacilityBooking(value) {
|
|
|
31785
31844
|
|
|
31786
31845
|
// src/repositories/site-facility-booking.repo.ts
|
|
31787
31846
|
var import_node_server_utils133 = require("@7365admin1/node-server-utils");
|
|
31788
|
-
var
|
|
31847
|
+
var import_mongodb78 = require("mongodb");
|
|
31789
31848
|
var facility_bookings_namespace_collection = "site.facilty-booking";
|
|
31790
31849
|
function useSiteFacilityBookingRepo() {
|
|
31791
31850
|
const db = import_node_server_utils133.useAtlas.getDb();
|
|
@@ -31948,7 +32007,7 @@ function useSiteFacilityBookingRepo() {
|
|
|
31948
32007
|
}
|
|
31949
32008
|
async function deleteSiteFacilityBookingById(_id) {
|
|
31950
32009
|
try {
|
|
31951
|
-
_id = new
|
|
32010
|
+
_id = new import_mongodb78.ObjectId(_id);
|
|
31952
32011
|
} catch (error) {
|
|
31953
32012
|
throw new import_node_server_utils133.BadRequestError("Invalid site facility booking ID format.");
|
|
31954
32013
|
}
|
|
@@ -32185,7 +32244,7 @@ function useSiteFacilityBookingController() {
|
|
|
32185
32244
|
|
|
32186
32245
|
// src/models/document-management.model.ts
|
|
32187
32246
|
var import_joi75 = __toESM(require("joi"));
|
|
32188
|
-
var
|
|
32247
|
+
var import_mongodb79 = require("mongodb");
|
|
32189
32248
|
var schemaDocumentManagement = import_joi75.default.object({
|
|
32190
32249
|
_id: import_joi75.default.string().hex().optional().allow("", null),
|
|
32191
32250
|
name: import_joi75.default.string().required(),
|
|
@@ -32223,28 +32282,28 @@ function MDocumentManagement(value) {
|
|
|
32223
32282
|
}
|
|
32224
32283
|
if (value._id && typeof value._id === "string") {
|
|
32225
32284
|
try {
|
|
32226
|
-
value._id = new
|
|
32285
|
+
value._id = new import_mongodb79.ObjectId(value._id);
|
|
32227
32286
|
} catch (error2) {
|
|
32228
32287
|
throw new Error("Invalid ID.");
|
|
32229
32288
|
}
|
|
32230
32289
|
}
|
|
32231
32290
|
if (value.org && typeof value.org === "string") {
|
|
32232
32291
|
try {
|
|
32233
|
-
value.org = new
|
|
32292
|
+
value.org = new import_mongodb79.ObjectId(value.org);
|
|
32234
32293
|
} catch (error2) {
|
|
32235
32294
|
throw new Error("Invalid org ID.");
|
|
32236
32295
|
}
|
|
32237
32296
|
}
|
|
32238
32297
|
if (value.site && typeof value.site === "string") {
|
|
32239
32298
|
try {
|
|
32240
|
-
value.site = new
|
|
32299
|
+
value.site = new import_mongodb79.ObjectId(value.site);
|
|
32241
32300
|
} catch (error2) {
|
|
32242
32301
|
throw new Error("Invalid site ID.");
|
|
32243
32302
|
}
|
|
32244
32303
|
}
|
|
32245
32304
|
if (value.parentId && typeof value.parentId === "string") {
|
|
32246
32305
|
try {
|
|
32247
|
-
value.parentId = new
|
|
32306
|
+
value.parentId = new import_mongodb79.ObjectId(value.parentId);
|
|
32248
32307
|
} catch (error2) {
|
|
32249
32308
|
throw new Error("Invalid parentId.");
|
|
32250
32309
|
}
|
|
@@ -32269,7 +32328,7 @@ function MDocumentManagement(value) {
|
|
|
32269
32328
|
|
|
32270
32329
|
// src/repositories/document-management.repo.ts
|
|
32271
32330
|
var import_node_server_utils136 = require("@7365admin1/node-server-utils");
|
|
32272
|
-
var
|
|
32331
|
+
var import_mongodb80 = require("mongodb");
|
|
32273
32332
|
function useDocumentManagementRepo() {
|
|
32274
32333
|
const db = import_node_server_utils136.useAtlas.getDb();
|
|
32275
32334
|
if (!db) {
|
|
@@ -32331,7 +32390,7 @@ function useDocumentManagementRepo() {
|
|
|
32331
32390
|
}) {
|
|
32332
32391
|
page = page > 0 ? page - 1 : 0;
|
|
32333
32392
|
try {
|
|
32334
|
-
site = new
|
|
32393
|
+
site = new import_mongodb80.ObjectId(site);
|
|
32335
32394
|
} catch (error) {
|
|
32336
32395
|
throw new import_node_server_utils136.BadRequestError("Invalid site ID format.");
|
|
32337
32396
|
}
|
|
@@ -32348,12 +32407,12 @@ function useDocumentManagementRepo() {
|
|
|
32348
32407
|
cacheOptions.type = type;
|
|
32349
32408
|
}
|
|
32350
32409
|
if (org) {
|
|
32351
|
-
query.org = new
|
|
32410
|
+
query.org = new import_mongodb80.ObjectId(org);
|
|
32352
32411
|
cacheOptions.org = org.toString();
|
|
32353
32412
|
}
|
|
32354
32413
|
if (parentId) {
|
|
32355
32414
|
try {
|
|
32356
|
-
query.parentId = new
|
|
32415
|
+
query.parentId = new import_mongodb80.ObjectId(parentId);
|
|
32357
32416
|
cacheOptions.parentId = parentId.toString();
|
|
32358
32417
|
} catch (error) {
|
|
32359
32418
|
throw new import_node_server_utils136.BadRequestError("Invalid parentId format.");
|
|
@@ -32407,7 +32466,7 @@ function useDocumentManagementRepo() {
|
|
|
32407
32466
|
}
|
|
32408
32467
|
async function getDocumentById(_id) {
|
|
32409
32468
|
try {
|
|
32410
|
-
_id = new
|
|
32469
|
+
_id = new import_mongodb80.ObjectId(_id);
|
|
32411
32470
|
} catch (error) {
|
|
32412
32471
|
throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
|
|
32413
32472
|
}
|
|
@@ -32452,7 +32511,7 @@ function useDocumentManagementRepo() {
|
|
|
32452
32511
|
}
|
|
32453
32512
|
async function updateDocumentById(_id, value) {
|
|
32454
32513
|
try {
|
|
32455
|
-
_id = new
|
|
32514
|
+
_id = new import_mongodb80.ObjectId(_id);
|
|
32456
32515
|
} catch (error) {
|
|
32457
32516
|
throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
|
|
32458
32517
|
}
|
|
@@ -32480,7 +32539,7 @@ function useDocumentManagementRepo() {
|
|
|
32480
32539
|
}
|
|
32481
32540
|
async function deleteDocumentById(_id, session) {
|
|
32482
32541
|
try {
|
|
32483
|
-
_id = new
|
|
32542
|
+
_id = new import_mongodb80.ObjectId(_id);
|
|
32484
32543
|
} catch (error) {
|
|
32485
32544
|
throw new import_node_server_utils136.BadRequestError("Invalid document ID format.");
|
|
32486
32545
|
}
|
|
@@ -32513,7 +32572,7 @@ function useDocumentManagementRepo() {
|
|
|
32513
32572
|
}
|
|
32514
32573
|
async function getDocumentManagementBySiteId(site, type) {
|
|
32515
32574
|
try {
|
|
32516
|
-
site = new
|
|
32575
|
+
site = new import_mongodb80.ObjectId(site);
|
|
32517
32576
|
} catch (error) {
|
|
32518
32577
|
throw new import_node_server_utils136.BadRequestError("Invalid document management site ID format.");
|
|
32519
32578
|
}
|
|
@@ -32839,7 +32898,7 @@ function useDocumentManagementController() {
|
|
|
32839
32898
|
|
|
32840
32899
|
// src/models/bulletin-board.model.ts
|
|
32841
32900
|
var import_joi77 = __toESM(require("joi"));
|
|
32842
|
-
var
|
|
32901
|
+
var import_mongodb81 = require("mongodb");
|
|
32843
32902
|
var BulletinRecipient = /* @__PURE__ */ ((BulletinRecipient2) => {
|
|
32844
32903
|
BulletinRecipient2["RESIDENT"] = "resident";
|
|
32845
32904
|
BulletinRecipient2["SECURITY_AGENCY"] = "security_agency";
|
|
@@ -32919,21 +32978,21 @@ function MBulletinBoard(value) {
|
|
|
32919
32978
|
}
|
|
32920
32979
|
if (value._id && typeof value._id === "string") {
|
|
32921
32980
|
try {
|
|
32922
|
-
value._id = new
|
|
32981
|
+
value._id = new import_mongodb81.ObjectId(value._id);
|
|
32923
32982
|
} catch {
|
|
32924
32983
|
throw new Error("Invalid ID.");
|
|
32925
32984
|
}
|
|
32926
32985
|
}
|
|
32927
32986
|
if (value.site && typeof value.site === "string") {
|
|
32928
32987
|
try {
|
|
32929
|
-
value.site = new
|
|
32988
|
+
value.site = new import_mongodb81.ObjectId(value.site);
|
|
32930
32989
|
} catch {
|
|
32931
32990
|
throw new Error("Invalid site ID.");
|
|
32932
32991
|
}
|
|
32933
32992
|
}
|
|
32934
32993
|
if (value.orgId && typeof value.orgId === "string") {
|
|
32935
32994
|
try {
|
|
32936
|
-
value.orgId = new
|
|
32995
|
+
value.orgId = new import_mongodb81.ObjectId(value.orgId);
|
|
32937
32996
|
} catch {
|
|
32938
32997
|
throw new Error("Invalid org ID.");
|
|
32939
32998
|
}
|
|
@@ -32942,7 +33001,7 @@ function MBulletinBoard(value) {
|
|
|
32942
33001
|
value.file = value.file.map((f) => {
|
|
32943
33002
|
if (f._id && typeof f._id === "string") {
|
|
32944
33003
|
try {
|
|
32945
|
-
return { ...f, _id: new
|
|
33004
|
+
return { ...f, _id: new import_mongodb81.ObjectId(f._id) };
|
|
32946
33005
|
} catch {
|
|
32947
33006
|
throw new Error("Invalid file ID.");
|
|
32948
33007
|
}
|
|
@@ -32951,7 +33010,7 @@ function MBulletinBoard(value) {
|
|
|
32951
33010
|
});
|
|
32952
33011
|
}
|
|
32953
33012
|
return {
|
|
32954
|
-
_id: value._id ?? new
|
|
33013
|
+
_id: value._id ?? new import_mongodb81.ObjectId(),
|
|
32955
33014
|
site: value.site ?? "",
|
|
32956
33015
|
orgId: value.orgId ?? "",
|
|
32957
33016
|
recipients: value.recipients ?? [],
|
|
@@ -32970,7 +33029,7 @@ function MBulletinBoard(value) {
|
|
|
32970
33029
|
|
|
32971
33030
|
// src/repositories/bulletin-board.repo.ts
|
|
32972
33031
|
var import_node_server_utils139 = require("@7365admin1/node-server-utils");
|
|
32973
|
-
var
|
|
33032
|
+
var import_mongodb82 = require("mongodb");
|
|
32974
33033
|
var bulletin_boards_namespace_collection = "bulletin-boards";
|
|
32975
33034
|
function useBulletinBoardRepo() {
|
|
32976
33035
|
const db = import_node_server_utils139.useAtlas.getDb();
|
|
@@ -33023,7 +33082,7 @@ function useBulletinBoardRepo() {
|
|
|
33023
33082
|
}, session) {
|
|
33024
33083
|
page = page > 0 ? page - 1 : 0;
|
|
33025
33084
|
try {
|
|
33026
|
-
site = new
|
|
33085
|
+
site = new import_mongodb82.ObjectId(site);
|
|
33027
33086
|
} catch (error) {
|
|
33028
33087
|
throw new import_node_server_utils139.BadRequestError("Invalid site ID format.");
|
|
33029
33088
|
}
|
|
@@ -33082,7 +33141,7 @@ function useBulletinBoardRepo() {
|
|
|
33082
33141
|
}
|
|
33083
33142
|
async function getBulletinBoardById(_id, session) {
|
|
33084
33143
|
try {
|
|
33085
|
-
_id = new
|
|
33144
|
+
_id = new import_mongodb82.ObjectId(_id);
|
|
33086
33145
|
} catch (error) {
|
|
33087
33146
|
throw new import_node_server_utils139.BadRequestError("Invalid bulletin board ID format.");
|
|
33088
33147
|
}
|
|
@@ -33112,13 +33171,13 @@ function useBulletinBoardRepo() {
|
|
|
33112
33171
|
async function updateBulletinBoardById(_id, value, session) {
|
|
33113
33172
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
33114
33173
|
try {
|
|
33115
|
-
_id = new
|
|
33174
|
+
_id = new import_mongodb82.ObjectId(_id);
|
|
33116
33175
|
} catch (error) {
|
|
33117
33176
|
throw new import_node_server_utils139.BadRequestError("Invalid ID format.");
|
|
33118
33177
|
}
|
|
33119
33178
|
if (value.site && typeof value.site === "string") {
|
|
33120
33179
|
try {
|
|
33121
|
-
value.site = new
|
|
33180
|
+
value.site = new import_mongodb82.ObjectId(value.site);
|
|
33122
33181
|
} catch {
|
|
33123
33182
|
throw new Error("Invalid site ID.");
|
|
33124
33183
|
}
|
|
@@ -33149,7 +33208,7 @@ function useBulletinBoardRepo() {
|
|
|
33149
33208
|
}
|
|
33150
33209
|
async function deleteBulletinBoardById(_id, session) {
|
|
33151
33210
|
try {
|
|
33152
|
-
_id = new
|
|
33211
|
+
_id = new import_mongodb82.ObjectId(_id);
|
|
33153
33212
|
} catch (error) {
|
|
33154
33213
|
throw new import_node_server_utils139.BadRequestError("Invalid bulletin board ID format.");
|
|
33155
33214
|
}
|
|
@@ -33583,7 +33642,7 @@ function useBulletinBoardController() {
|
|
|
33583
33642
|
|
|
33584
33643
|
// src/models/site-billing-item.model.ts
|
|
33585
33644
|
var import_node_server_utils142 = require("@7365admin1/node-server-utils");
|
|
33586
|
-
var
|
|
33645
|
+
var import_mongodb83 = require("mongodb");
|
|
33587
33646
|
var import_joi79 = __toESM(require("joi"));
|
|
33588
33647
|
|
|
33589
33648
|
// src/types/enums/billing-frequency.enum.ts
|
|
@@ -33654,21 +33713,21 @@ function MBillingItem(value) {
|
|
|
33654
33713
|
}
|
|
33655
33714
|
if (value._id && typeof value._id === "string") {
|
|
33656
33715
|
try {
|
|
33657
|
-
value._id = new
|
|
33716
|
+
value._id = new import_mongodb83.ObjectId(value._id);
|
|
33658
33717
|
} catch {
|
|
33659
33718
|
throw new import_node_server_utils142.BadRequestError("Invalid _id format");
|
|
33660
33719
|
}
|
|
33661
33720
|
}
|
|
33662
33721
|
if (value.site && typeof value.site === "string") {
|
|
33663
33722
|
try {
|
|
33664
|
-
value.site = new
|
|
33723
|
+
value.site = new import_mongodb83.ObjectId(value.site);
|
|
33665
33724
|
} catch {
|
|
33666
33725
|
throw new import_node_server_utils142.BadRequestError("Invalid site id format");
|
|
33667
33726
|
}
|
|
33668
33727
|
}
|
|
33669
33728
|
if (value.org && typeof value.org === "string") {
|
|
33670
33729
|
try {
|
|
33671
|
-
value.org = new
|
|
33730
|
+
value.org = new import_mongodb83.ObjectId(value.org);
|
|
33672
33731
|
} catch {
|
|
33673
33732
|
throw new import_node_server_utils142.BadRequestError("Invalid org id format");
|
|
33674
33733
|
}
|
|
@@ -33677,7 +33736,7 @@ function MBillingItem(value) {
|
|
|
33677
33736
|
value.units = value.units.map((unit) => {
|
|
33678
33737
|
if (unit._id && typeof unit._id === "string") {
|
|
33679
33738
|
try {
|
|
33680
|
-
unit._id = new
|
|
33739
|
+
unit._id = new import_mongodb83.ObjectId(unit._id);
|
|
33681
33740
|
} catch {
|
|
33682
33741
|
throw new import_node_server_utils142.BadRequestError("Invalid unit id format");
|
|
33683
33742
|
}
|
|
@@ -33686,7 +33745,7 @@ function MBillingItem(value) {
|
|
|
33686
33745
|
});
|
|
33687
33746
|
}
|
|
33688
33747
|
return {
|
|
33689
|
-
_id: value._id ?? new
|
|
33748
|
+
_id: value._id ?? new import_mongodb83.ObjectId(),
|
|
33690
33749
|
site: value.site,
|
|
33691
33750
|
org: value.org,
|
|
33692
33751
|
name: value.name,
|
|
@@ -33714,7 +33773,7 @@ function MBillingItem(value) {
|
|
|
33714
33773
|
|
|
33715
33774
|
// src/repositories/site-billing-item.repo.ts
|
|
33716
33775
|
var import_node_server_utils143 = require("@7365admin1/node-server-utils");
|
|
33717
|
-
var
|
|
33776
|
+
var import_mongodb84 = require("mongodb");
|
|
33718
33777
|
function useSiteBillingItemRepo() {
|
|
33719
33778
|
const db = import_node_server_utils143.useAtlas.getDb();
|
|
33720
33779
|
if (!db) {
|
|
@@ -33801,7 +33860,7 @@ function useSiteBillingItemRepo() {
|
|
|
33801
33860
|
}
|
|
33802
33861
|
]
|
|
33803
33862
|
},
|
|
33804
|
-
...
|
|
33863
|
+
...import_mongodb84.ObjectId.isValid(site) && { site: new import_mongodb84.ObjectId(site) }
|
|
33805
33864
|
};
|
|
33806
33865
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
33807
33866
|
const cacheOptions = {
|
|
@@ -33841,7 +33900,7 @@ function useSiteBillingItemRepo() {
|
|
|
33841
33900
|
}
|
|
33842
33901
|
async function getById(_id, session) {
|
|
33843
33902
|
try {
|
|
33844
|
-
_id = new
|
|
33903
|
+
_id = new import_mongodb84.ObjectId(_id);
|
|
33845
33904
|
} catch (error) {
|
|
33846
33905
|
throw new import_node_server_utils143.BadRequestError("Invalid ID.");
|
|
33847
33906
|
}
|
|
@@ -33880,22 +33939,22 @@ function useSiteBillingItemRepo() {
|
|
|
33880
33939
|
}
|
|
33881
33940
|
async function updateById(_id, value, session) {
|
|
33882
33941
|
try {
|
|
33883
|
-
_id = new
|
|
33942
|
+
_id = new import_mongodb84.ObjectId(_id);
|
|
33884
33943
|
} catch (error) {
|
|
33885
33944
|
throw new import_node_server_utils143.BadRequestError(
|
|
33886
33945
|
"Invalid site billing item transaction ID format."
|
|
33887
33946
|
);
|
|
33888
33947
|
}
|
|
33889
|
-
if (value.site &&
|
|
33948
|
+
if (value.site && import_mongodb84.ObjectId.isValid(value.site.toString())) {
|
|
33890
33949
|
try {
|
|
33891
|
-
value.site = new
|
|
33950
|
+
value.site = new import_mongodb84.ObjectId(value.site.toString());
|
|
33892
33951
|
} catch {
|
|
33893
33952
|
throw new import_node_server_utils143.BadRequestError("Invalid _id format");
|
|
33894
33953
|
}
|
|
33895
33954
|
}
|
|
33896
|
-
if (value.org &&
|
|
33955
|
+
if (value.org && import_mongodb84.ObjectId.isValid(value.org.toString())) {
|
|
33897
33956
|
try {
|
|
33898
|
-
value.org = new
|
|
33957
|
+
value.org = new import_mongodb84.ObjectId(value.org.toString());
|
|
33899
33958
|
} catch {
|
|
33900
33959
|
throw new import_node_server_utils143.BadRequestError("Invalid _id format");
|
|
33901
33960
|
}
|
|
@@ -33915,7 +33974,7 @@ function useSiteBillingItemRepo() {
|
|
|
33915
33974
|
}
|
|
33916
33975
|
async function deleteById(_id) {
|
|
33917
33976
|
try {
|
|
33918
|
-
_id = new
|
|
33977
|
+
_id = new import_mongodb84.ObjectId(_id);
|
|
33919
33978
|
} catch (error) {
|
|
33920
33979
|
throw new import_node_server_utils143.BadRequestError(
|
|
33921
33980
|
"Invalid site billing item transaction ID format."
|
|
@@ -33972,7 +34031,7 @@ var import_node_server_utils145 = require("@7365admin1/node-server-utils");
|
|
|
33972
34031
|
|
|
33973
34032
|
// src/models/site-billing-configuration.model.ts
|
|
33974
34033
|
var import_node_server_utils144 = require("@7365admin1/node-server-utils");
|
|
33975
|
-
var
|
|
34034
|
+
var import_mongodb85 = require("mongodb");
|
|
33976
34035
|
var import_joi80 = __toESM(require("joi"));
|
|
33977
34036
|
var schemaBillingConfiguration = import_joi80.default.object({
|
|
33978
34037
|
_id: import_joi80.default.string().hex().optional(),
|
|
@@ -34033,34 +34092,34 @@ function MBillingConfiguration(value) {
|
|
|
34033
34092
|
}
|
|
34034
34093
|
if (value._id && typeof value._id === "string") {
|
|
34035
34094
|
try {
|
|
34036
|
-
value._id = new
|
|
34095
|
+
value._id = new import_mongodb85.ObjectId(value._id);
|
|
34037
34096
|
} catch {
|
|
34038
34097
|
throw new import_node_server_utils144.BadRequestError("Invalid _id format");
|
|
34039
34098
|
}
|
|
34040
34099
|
}
|
|
34041
34100
|
if (value.site && typeof value.site === "string") {
|
|
34042
34101
|
try {
|
|
34043
|
-
value.site = new
|
|
34102
|
+
value.site = new import_mongodb85.ObjectId(value.site);
|
|
34044
34103
|
} catch {
|
|
34045
34104
|
throw new import_node_server_utils144.BadRequestError("Invalid site id format");
|
|
34046
34105
|
}
|
|
34047
34106
|
}
|
|
34048
34107
|
if (value.org && typeof value.org === "string") {
|
|
34049
34108
|
try {
|
|
34050
|
-
value.org = new
|
|
34109
|
+
value.org = new import_mongodb85.ObjectId(value.org);
|
|
34051
34110
|
} catch {
|
|
34052
34111
|
throw new import_node_server_utils144.BadRequestError("Invalid org id format");
|
|
34053
34112
|
}
|
|
34054
34113
|
}
|
|
34055
34114
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
34056
34115
|
try {
|
|
34057
|
-
value.createdBy = new
|
|
34116
|
+
value.createdBy = new import_mongodb85.ObjectId(value.createdBy);
|
|
34058
34117
|
} catch {
|
|
34059
34118
|
throw new import_node_server_utils144.BadRequestError("Invalid createdBy id format");
|
|
34060
34119
|
}
|
|
34061
34120
|
}
|
|
34062
34121
|
return {
|
|
34063
|
-
_id: value._id ?? new
|
|
34122
|
+
_id: value._id ?? new import_mongodb85.ObjectId(),
|
|
34064
34123
|
site: value.site,
|
|
34065
34124
|
org: value.org,
|
|
34066
34125
|
siteName: value.siteName,
|
|
@@ -34089,7 +34148,7 @@ function MBillingConfiguration(value) {
|
|
|
34089
34148
|
}
|
|
34090
34149
|
|
|
34091
34150
|
// src/repositories/site-billing-configuration.repo.ts
|
|
34092
|
-
var
|
|
34151
|
+
var import_mongodb86 = require("mongodb");
|
|
34093
34152
|
function useSiteBillingConfigurationRepo() {
|
|
34094
34153
|
const db = import_node_server_utils145.useAtlas.getDb();
|
|
34095
34154
|
if (!db) {
|
|
@@ -34162,7 +34221,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34162
34221
|
const query = {
|
|
34163
34222
|
status,
|
|
34164
34223
|
...search && { $text: { $search: search } },
|
|
34165
|
-
...
|
|
34224
|
+
...import_mongodb86.ObjectId.isValid(site) && { site: new import_mongodb86.ObjectId(site) }
|
|
34166
34225
|
};
|
|
34167
34226
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
34168
34227
|
const cacheOptions = {
|
|
@@ -34202,7 +34261,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34202
34261
|
}
|
|
34203
34262
|
async function getById(_id) {
|
|
34204
34263
|
try {
|
|
34205
|
-
_id = new
|
|
34264
|
+
_id = new import_mongodb86.ObjectId(_id);
|
|
34206
34265
|
} catch (error) {
|
|
34207
34266
|
throw new import_node_server_utils145.BadRequestError("Invalid ID.");
|
|
34208
34267
|
}
|
|
@@ -34243,22 +34302,22 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34243
34302
|
}
|
|
34244
34303
|
async function updateById(_id, value, session) {
|
|
34245
34304
|
try {
|
|
34246
|
-
_id = new
|
|
34305
|
+
_id = new import_mongodb86.ObjectId(_id);
|
|
34247
34306
|
} catch (error) {
|
|
34248
34307
|
throw new import_node_server_utils145.BadRequestError(
|
|
34249
34308
|
"Invalid site billing configuration transaction ID format."
|
|
34250
34309
|
);
|
|
34251
34310
|
}
|
|
34252
|
-
if (value.site &&
|
|
34311
|
+
if (value.site && import_mongodb86.ObjectId.isValid(value.site.toString())) {
|
|
34253
34312
|
try {
|
|
34254
|
-
value.site = new
|
|
34313
|
+
value.site = new import_mongodb86.ObjectId(value.site.toString());
|
|
34255
34314
|
} catch {
|
|
34256
34315
|
throw new import_node_server_utils145.BadRequestError("Invalid _id format");
|
|
34257
34316
|
}
|
|
34258
34317
|
}
|
|
34259
|
-
if (value.org &&
|
|
34318
|
+
if (value.org && import_mongodb86.ObjectId.isValid(value.org.toString())) {
|
|
34260
34319
|
try {
|
|
34261
|
-
value.org = new
|
|
34320
|
+
value.org = new import_mongodb86.ObjectId(value.org.toString());
|
|
34262
34321
|
} catch {
|
|
34263
34322
|
throw new import_node_server_utils145.BadRequestError("Invalid _id format");
|
|
34264
34323
|
}
|
|
@@ -34278,7 +34337,7 @@ function useSiteBillingConfigurationRepo() {
|
|
|
34278
34337
|
}
|
|
34279
34338
|
async function deleteById(_id) {
|
|
34280
34339
|
try {
|
|
34281
|
-
_id = new
|
|
34340
|
+
_id = new import_mongodb86.ObjectId(_id);
|
|
34282
34341
|
} catch (error) {
|
|
34283
34342
|
throw new import_node_server_utils145.BadRequestError(
|
|
34284
34343
|
"Invalid site billing configuration transaction ID format."
|
|
@@ -34856,7 +34915,7 @@ function useSiteBillingConfigurationController() {
|
|
|
34856
34915
|
}
|
|
34857
34916
|
|
|
34858
34917
|
// src/models/event-management.model.ts
|
|
34859
|
-
var
|
|
34918
|
+
var import_mongodb87 = require("mongodb");
|
|
34860
34919
|
var import_joi83 = __toESM(require("joi"));
|
|
34861
34920
|
var EventStatus = /* @__PURE__ */ ((EventStatus2) => {
|
|
34862
34921
|
EventStatus2["PLANNED"] = "planned";
|
|
@@ -34900,20 +34959,20 @@ var schemaUpdateEventManagement = import_joi83.default.object({
|
|
|
34900
34959
|
function MEventManagement(value) {
|
|
34901
34960
|
if (value._id && typeof value._id === "string") {
|
|
34902
34961
|
try {
|
|
34903
|
-
value._id = new
|
|
34962
|
+
value._id = new import_mongodb87.ObjectId(value._id);
|
|
34904
34963
|
} catch {
|
|
34905
34964
|
throw new Error("Invalid ID.");
|
|
34906
34965
|
}
|
|
34907
34966
|
}
|
|
34908
34967
|
if (value.site && typeof value.site === "string") {
|
|
34909
34968
|
try {
|
|
34910
|
-
value.site = new
|
|
34969
|
+
value.site = new import_mongodb87.ObjectId(value.site);
|
|
34911
34970
|
} catch {
|
|
34912
34971
|
throw new Error("Invalid site ID.");
|
|
34913
34972
|
}
|
|
34914
34973
|
}
|
|
34915
34974
|
return {
|
|
34916
|
-
_id: value._id ?? new
|
|
34975
|
+
_id: value._id ?? new import_mongodb87.ObjectId(),
|
|
34917
34976
|
site: value.site,
|
|
34918
34977
|
title: value.title,
|
|
34919
34978
|
description: value.description ?? "",
|
|
@@ -34928,7 +34987,7 @@ function MEventManagement(value) {
|
|
|
34928
34987
|
|
|
34929
34988
|
// src/repositories/event-management.repo.ts
|
|
34930
34989
|
var import_node_server_utils150 = require("@7365admin1/node-server-utils");
|
|
34931
|
-
var
|
|
34990
|
+
var import_mongodb88 = require("mongodb");
|
|
34932
34991
|
var events_namespace_collection = "event-management";
|
|
34933
34992
|
function useEventManagementRepo() {
|
|
34934
34993
|
const db = import_node_server_utils150.useAtlas.getDb();
|
|
@@ -34996,7 +35055,7 @@ function useEventManagementRepo() {
|
|
|
34996
35055
|
}, session) {
|
|
34997
35056
|
page = page > 0 ? page - 1 : 0;
|
|
34998
35057
|
try {
|
|
34999
|
-
site = new
|
|
35058
|
+
site = new import_mongodb88.ObjectId(site);
|
|
35000
35059
|
} catch (error) {
|
|
35001
35060
|
throw new import_node_server_utils150.BadRequestError("Invalid site ID format.");
|
|
35002
35061
|
}
|
|
@@ -35084,7 +35143,7 @@ function useEventManagementRepo() {
|
|
|
35084
35143
|
}
|
|
35085
35144
|
async function getEventManagementById(_id, session) {
|
|
35086
35145
|
try {
|
|
35087
|
-
_id = new
|
|
35146
|
+
_id = new import_mongodb88.ObjectId(_id);
|
|
35088
35147
|
} catch (error) {
|
|
35089
35148
|
throw new import_node_server_utils150.BadRequestError("Invalid event ID format.");
|
|
35090
35149
|
}
|
|
@@ -35112,13 +35171,13 @@ function useEventManagementRepo() {
|
|
|
35112
35171
|
async function updateEventManagementById(_id, value, session) {
|
|
35113
35172
|
value.updatedAt = /* @__PURE__ */ new Date();
|
|
35114
35173
|
try {
|
|
35115
|
-
_id = new
|
|
35174
|
+
_id = new import_mongodb88.ObjectId(_id);
|
|
35116
35175
|
} catch (error) {
|
|
35117
35176
|
throw new import_node_server_utils150.BadRequestError("Invalid ID format.");
|
|
35118
35177
|
}
|
|
35119
35178
|
if (value.site && typeof value.site === "string") {
|
|
35120
35179
|
try {
|
|
35121
|
-
value.site = new
|
|
35180
|
+
value.site = new import_mongodb88.ObjectId(value.site);
|
|
35122
35181
|
} catch {
|
|
35123
35182
|
throw new Error("Invalid site ID.");
|
|
35124
35183
|
}
|
|
@@ -35149,7 +35208,7 @@ function useEventManagementRepo() {
|
|
|
35149
35208
|
}
|
|
35150
35209
|
async function deleteEventManagementById(_id) {
|
|
35151
35210
|
try {
|
|
35152
|
-
_id = new
|
|
35211
|
+
_id = new import_mongodb88.ObjectId(_id);
|
|
35153
35212
|
} catch (error) {
|
|
35154
35213
|
throw new import_node_server_utils150.BadRequestError("Invalid event ID format.");
|
|
35155
35214
|
}
|
|
@@ -35437,7 +35496,7 @@ function useEventManagementController() {
|
|
|
35437
35496
|
|
|
35438
35497
|
// src/models/site-unit-billing.model.ts
|
|
35439
35498
|
var import_node_server_utils153 = require("@7365admin1/node-server-utils");
|
|
35440
|
-
var
|
|
35499
|
+
var import_mongodb89 = require("mongodb");
|
|
35441
35500
|
var import_joi85 = __toESM(require("joi"));
|
|
35442
35501
|
var Status = /* @__PURE__ */ ((Status2) => {
|
|
35443
35502
|
Status2["PENDING"] = "pending";
|
|
@@ -35532,48 +35591,48 @@ function MUnitBilling(value) {
|
|
|
35532
35591
|
}
|
|
35533
35592
|
if (value._id && typeof value._id === "string") {
|
|
35534
35593
|
try {
|
|
35535
|
-
value._id = new
|
|
35594
|
+
value._id = new import_mongodb89.ObjectId(value._id);
|
|
35536
35595
|
} catch {
|
|
35537
35596
|
throw new import_node_server_utils153.BadRequestError("Invalid _id format");
|
|
35538
35597
|
}
|
|
35539
35598
|
}
|
|
35540
35599
|
if (value.site && typeof value.site === "string") {
|
|
35541
35600
|
try {
|
|
35542
|
-
value.site = new
|
|
35601
|
+
value.site = new import_mongodb89.ObjectId(value.site);
|
|
35543
35602
|
} catch {
|
|
35544
35603
|
throw new import_node_server_utils153.BadRequestError("Invalid site id format");
|
|
35545
35604
|
}
|
|
35546
35605
|
}
|
|
35547
35606
|
if (value.org && typeof value.org === "string") {
|
|
35548
35607
|
try {
|
|
35549
|
-
value.org = new
|
|
35608
|
+
value.org = new import_mongodb89.ObjectId(value.org);
|
|
35550
35609
|
} catch {
|
|
35551
35610
|
throw new import_node_server_utils153.BadRequestError("Invalid org id format");
|
|
35552
35611
|
}
|
|
35553
35612
|
}
|
|
35554
35613
|
if (value.paidBy && typeof value.paidBy === "string") {
|
|
35555
35614
|
try {
|
|
35556
|
-
value.paidBy = new
|
|
35615
|
+
value.paidBy = new import_mongodb89.ObjectId(value.paidBy);
|
|
35557
35616
|
} catch {
|
|
35558
35617
|
throw new import_node_server_utils153.BadRequestError("Invalid paidBy id format");
|
|
35559
35618
|
}
|
|
35560
35619
|
}
|
|
35561
35620
|
if (value.billItem && typeof value.billItem === "string") {
|
|
35562
35621
|
try {
|
|
35563
|
-
value.billItem = new
|
|
35622
|
+
value.billItem = new import_mongodb89.ObjectId(value.billItem);
|
|
35564
35623
|
} catch {
|
|
35565
35624
|
throw new import_node_server_utils153.BadRequestError("Invalid billItem id format");
|
|
35566
35625
|
}
|
|
35567
35626
|
}
|
|
35568
35627
|
if (value.unitId && typeof value.unitId === "string") {
|
|
35569
35628
|
try {
|
|
35570
|
-
value.unitId = new
|
|
35629
|
+
value.unitId = new import_mongodb89.ObjectId(value.unitId);
|
|
35571
35630
|
} catch {
|
|
35572
35631
|
throw new import_node_server_utils153.BadRequestError("Invalid unitId id format");
|
|
35573
35632
|
}
|
|
35574
35633
|
}
|
|
35575
35634
|
return {
|
|
35576
|
-
_id: value._id ?? new
|
|
35635
|
+
_id: value._id ?? new import_mongodb89.ObjectId(),
|
|
35577
35636
|
site: value.site ?? "",
|
|
35578
35637
|
org: value.org ?? "",
|
|
35579
35638
|
billItem: value.billItem ?? "",
|
|
@@ -35609,7 +35668,7 @@ function MUnitBilling(value) {
|
|
|
35609
35668
|
|
|
35610
35669
|
// src/repositories/site-unit-billing.repo.ts
|
|
35611
35670
|
var import_node_server_utils154 = require("@7365admin1/node-server-utils");
|
|
35612
|
-
var
|
|
35671
|
+
var import_mongodb90 = require("mongodb");
|
|
35613
35672
|
function useSiteUnitBillingRepo() {
|
|
35614
35673
|
const db = import_node_server_utils154.useAtlas.getDb();
|
|
35615
35674
|
if (!db) {
|
|
@@ -35659,7 +35718,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35659
35718
|
const res = await collection.insertOne(value, { session });
|
|
35660
35719
|
const acronym = createAcronym(value.billName || "NA");
|
|
35661
35720
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
|
|
35662
|
-
const newId = new
|
|
35721
|
+
const newId = new import_mongodb90.ObjectId(res.insertedId).toString().slice(-6);
|
|
35663
35722
|
const referenceNumber = `${acronym}${newId}${dateFormatted}`;
|
|
35664
35723
|
await collection.updateOne(
|
|
35665
35724
|
{ _id: res.insertedId },
|
|
@@ -35737,7 +35796,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35737
35796
|
}
|
|
35738
35797
|
]
|
|
35739
35798
|
},
|
|
35740
|
-
...
|
|
35799
|
+
...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
35741
35800
|
...dateExpr
|
|
35742
35801
|
};
|
|
35743
35802
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -35803,7 +35862,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35803
35862
|
}
|
|
35804
35863
|
async function getById(_id) {
|
|
35805
35864
|
try {
|
|
35806
|
-
_id = new
|
|
35865
|
+
_id = new import_mongodb90.ObjectId(_id);
|
|
35807
35866
|
} catch (error) {
|
|
35808
35867
|
throw new import_node_server_utils154.BadRequestError("Invalid ID.");
|
|
35809
35868
|
}
|
|
@@ -35862,8 +35921,8 @@ function useSiteUnitBillingRepo() {
|
|
|
35862
35921
|
}
|
|
35863
35922
|
const query = {
|
|
35864
35923
|
status,
|
|
35865
|
-
...unitId &&
|
|
35866
|
-
...site &&
|
|
35924
|
+
...unitId && import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) },
|
|
35925
|
+
...site && import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
35867
35926
|
...dateExpr
|
|
35868
35927
|
};
|
|
35869
35928
|
try {
|
|
@@ -35901,43 +35960,43 @@ function useSiteUnitBillingRepo() {
|
|
|
35901
35960
|
}
|
|
35902
35961
|
async function updateById(_id, value, session) {
|
|
35903
35962
|
try {
|
|
35904
|
-
_id = new
|
|
35963
|
+
_id = new import_mongodb90.ObjectId(_id);
|
|
35905
35964
|
} catch (error) {
|
|
35906
35965
|
throw new import_node_server_utils154.BadRequestError(
|
|
35907
35966
|
"Invalid site unit billing transaction ID format."
|
|
35908
35967
|
);
|
|
35909
35968
|
}
|
|
35910
|
-
if (value.site &&
|
|
35969
|
+
if (value.site && import_mongodb90.ObjectId.isValid(value.site.toString())) {
|
|
35911
35970
|
try {
|
|
35912
|
-
value.site = new
|
|
35971
|
+
value.site = new import_mongodb90.ObjectId(value.site.toString());
|
|
35913
35972
|
} catch {
|
|
35914
35973
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35915
35974
|
}
|
|
35916
35975
|
}
|
|
35917
|
-
if (value.org &&
|
|
35976
|
+
if (value.org && import_mongodb90.ObjectId.isValid(value.org.toString())) {
|
|
35918
35977
|
try {
|
|
35919
|
-
value.org = new
|
|
35978
|
+
value.org = new import_mongodb90.ObjectId(value.org.toString());
|
|
35920
35979
|
} catch {
|
|
35921
35980
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35922
35981
|
}
|
|
35923
35982
|
}
|
|
35924
|
-
if (value.paidBy &&
|
|
35983
|
+
if (value.paidBy && import_mongodb90.ObjectId.isValid(value.paidBy.toString())) {
|
|
35925
35984
|
try {
|
|
35926
|
-
value.org = new
|
|
35985
|
+
value.org = new import_mongodb90.ObjectId(value.paidBy.toString());
|
|
35927
35986
|
} catch {
|
|
35928
35987
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35929
35988
|
}
|
|
35930
35989
|
}
|
|
35931
|
-
if (value.billItem &&
|
|
35990
|
+
if (value.billItem && import_mongodb90.ObjectId.isValid(value.billItem.toString())) {
|
|
35932
35991
|
try {
|
|
35933
|
-
value.billItem = new
|
|
35992
|
+
value.billItem = new import_mongodb90.ObjectId(value.billItem.toString());
|
|
35934
35993
|
} catch {
|
|
35935
35994
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35936
35995
|
}
|
|
35937
35996
|
}
|
|
35938
|
-
if (value.unitId &&
|
|
35997
|
+
if (value.unitId && import_mongodb90.ObjectId.isValid(value.unitId.toString())) {
|
|
35939
35998
|
try {
|
|
35940
|
-
value.unitId = new
|
|
35999
|
+
value.unitId = new import_mongodb90.ObjectId(value.unitId.toString());
|
|
35941
36000
|
} catch {
|
|
35942
36001
|
throw new import_node_server_utils154.BadRequestError("Invalid _id format");
|
|
35943
36002
|
}
|
|
@@ -35957,7 +36016,7 @@ function useSiteUnitBillingRepo() {
|
|
|
35957
36016
|
}
|
|
35958
36017
|
async function deleteById(_id) {
|
|
35959
36018
|
try {
|
|
35960
|
-
_id = new
|
|
36019
|
+
_id = new import_mongodb90.ObjectId(_id);
|
|
35961
36020
|
} catch (error) {
|
|
35962
36021
|
throw new import_node_server_utils154.BadRequestError(
|
|
35963
36022
|
"Invalid site unit billing transaction ID format."
|
|
@@ -36023,9 +36082,9 @@ function useSiteUnitBillingRepo() {
|
|
|
36023
36082
|
}
|
|
36024
36083
|
]
|
|
36025
36084
|
},
|
|
36026
|
-
...
|
|
36085
|
+
...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
36027
36086
|
...dateExpr,
|
|
36028
|
-
...
|
|
36087
|
+
...import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) }
|
|
36029
36088
|
};
|
|
36030
36089
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36031
36090
|
try {
|
|
@@ -36112,9 +36171,9 @@ function useSiteUnitBillingRepo() {
|
|
|
36112
36171
|
}
|
|
36113
36172
|
]
|
|
36114
36173
|
},
|
|
36115
|
-
...
|
|
36174
|
+
...import_mongodb90.ObjectId.isValid(site) && { site: new import_mongodb90.ObjectId(site) },
|
|
36116
36175
|
...dateExpr,
|
|
36117
|
-
...
|
|
36176
|
+
...import_mongodb90.ObjectId.isValid(unitId) && { unitId: new import_mongodb90.ObjectId(unitId) }
|
|
36118
36177
|
};
|
|
36119
36178
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
36120
36179
|
try {
|
|
@@ -36197,7 +36256,7 @@ function useSiteUnitBillingRepo() {
|
|
|
36197
36256
|
|
|
36198
36257
|
// src/services/site-unit-billing.service.ts
|
|
36199
36258
|
var import_node_server_utils155 = require("@7365admin1/node-server-utils");
|
|
36200
|
-
var
|
|
36259
|
+
var import_mongodb91 = require("mongodb");
|
|
36201
36260
|
function useSiteUnitBillingService() {
|
|
36202
36261
|
const {
|
|
36203
36262
|
add: _add,
|
|
@@ -36354,7 +36413,7 @@ function useSiteUnitBillingService() {
|
|
|
36354
36413
|
return unitsWithOwner || [];
|
|
36355
36414
|
} else {
|
|
36356
36415
|
if (units && units.length > 0) {
|
|
36357
|
-
const unitIds = units.map((unit) => new
|
|
36416
|
+
const unitIds = units.map((unit) => new import_mongodb91.ObjectId(unit._id));
|
|
36358
36417
|
const specificUnitsWithOwner = await _getBuildingUnitsWithOwner(
|
|
36359
36418
|
site || "",
|
|
36360
36419
|
unitIds
|
|
@@ -36635,7 +36694,7 @@ function useSiteUnitBillingController() {
|
|
|
36635
36694
|
}
|
|
36636
36695
|
|
|
36637
36696
|
// src/models/access-management.model.ts
|
|
36638
|
-
var
|
|
36697
|
+
var import_mongodb92 = require("mongodb");
|
|
36639
36698
|
var EAccessCardTypes = /* @__PURE__ */ ((EAccessCardTypes2) => {
|
|
36640
36699
|
EAccessCardTypes2["NFC"] = "NFC";
|
|
36641
36700
|
EAccessCardTypes2["QR"] = "QRCODE";
|
|
@@ -36657,7 +36716,7 @@ var AccessTypeProps = /* @__PURE__ */ ((AccessTypeProps2) => {
|
|
|
36657
36716
|
})(AccessTypeProps || {});
|
|
36658
36717
|
var MAccessCardTransaction = class {
|
|
36659
36718
|
constructor({
|
|
36660
|
-
_id = new
|
|
36719
|
+
_id = new import_mongodb92.ObjectId(),
|
|
36661
36720
|
index,
|
|
36662
36721
|
site,
|
|
36663
36722
|
cardNo,
|
|
@@ -36684,7 +36743,7 @@ var MAccessCardTransaction = class {
|
|
|
36684
36743
|
};
|
|
36685
36744
|
var MAccessCard = class {
|
|
36686
36745
|
constructor({
|
|
36687
|
-
_id = new
|
|
36746
|
+
_id = new import_mongodb92.ObjectId(),
|
|
36688
36747
|
userId,
|
|
36689
36748
|
site,
|
|
36690
36749
|
staffNo = null,
|
|
@@ -36742,7 +36801,7 @@ var MAccessCard = class {
|
|
|
36742
36801
|
|
|
36743
36802
|
// src/repositories/access-management.repo.ts
|
|
36744
36803
|
var import_node_server_utils157 = require("@7365admin1/node-server-utils");
|
|
36745
|
-
var
|
|
36804
|
+
var import_mongodb93 = require("mongodb");
|
|
36746
36805
|
|
|
36747
36806
|
// src/utils/access-management.ts
|
|
36748
36807
|
var import_fs4 = __toESM(require("fs"));
|
|
@@ -37052,12 +37111,12 @@ function UseAccessManagementRepo() {
|
|
|
37052
37111
|
payload
|
|
37053
37112
|
}) {
|
|
37054
37113
|
try {
|
|
37055
|
-
payload.site = new
|
|
37114
|
+
payload.site = new import_mongodb93.ObjectId(payload.site);
|
|
37056
37115
|
payload.startDate = new Date(payload.startDate);
|
|
37057
37116
|
payload.endDate = new Date(payload.endDate);
|
|
37058
37117
|
payload.createdAt = new Date(payload.createdAt);
|
|
37059
37118
|
payload.updatedAt = new Date(payload.updatedAt);
|
|
37060
|
-
payload.assignedUnit = payload.unit?.map((id) => new
|
|
37119
|
+
payload.assignedUnit = payload.unit?.map((id) => new import_mongodb93.ObjectId(id));
|
|
37061
37120
|
delete payload.unit;
|
|
37062
37121
|
const accessCardObj = new MAccessCard(payload);
|
|
37063
37122
|
const result = await collection().insertOne(accessCardObj);
|
|
@@ -37096,7 +37155,7 @@ function UseAccessManagementRepo() {
|
|
|
37096
37155
|
async function addNonPhysicalCardRepo(params) {
|
|
37097
37156
|
try {
|
|
37098
37157
|
const MAX_RETRIES = 3;
|
|
37099
|
-
const site = new
|
|
37158
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37100
37159
|
const date = /* @__PURE__ */ new Date();
|
|
37101
37160
|
const endDate = new Date(date.setFullYear(date.getFullYear() + 10));
|
|
37102
37161
|
const countPerUnit = params.quantity;
|
|
@@ -37128,7 +37187,7 @@ function UseAccessManagementRepo() {
|
|
|
37128
37187
|
userType: params.userType,
|
|
37129
37188
|
doorName: params.doorName,
|
|
37130
37189
|
liftName: params.liftName,
|
|
37131
|
-
assignedUnit: new
|
|
37190
|
+
assignedUnit: new import_mongodb93.ObjectId(units[i]),
|
|
37132
37191
|
createdAt: new Date(params.createdAt),
|
|
37133
37192
|
updatedAt: new Date(params.updatedAt),
|
|
37134
37193
|
isWinsland: params.isWinsland
|
|
@@ -37214,7 +37273,7 @@ function UseAccessManagementRepo() {
|
|
|
37214
37273
|
}
|
|
37215
37274
|
async function accessManagementSettingsRepo(params) {
|
|
37216
37275
|
try {
|
|
37217
|
-
params.site = new
|
|
37276
|
+
params.site = new import_mongodb93.ObjectId(params.site);
|
|
37218
37277
|
const result = collectionName("entrypass-settings").updateOne(
|
|
37219
37278
|
{ site: params.site },
|
|
37220
37279
|
{
|
|
@@ -37236,7 +37295,7 @@ function UseAccessManagementRepo() {
|
|
|
37236
37295
|
}
|
|
37237
37296
|
async function allAccessCardsCountsRepo(params) {
|
|
37238
37297
|
try {
|
|
37239
|
-
const site = new
|
|
37298
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37240
37299
|
const userType = params.userType;
|
|
37241
37300
|
const result = await collection().aggregate([
|
|
37242
37301
|
{
|
|
@@ -37296,7 +37355,7 @@ function UseAccessManagementRepo() {
|
|
|
37296
37355
|
}
|
|
37297
37356
|
async function availableAccessCardsRepo(params) {
|
|
37298
37357
|
try {
|
|
37299
|
-
const site = new
|
|
37358
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37300
37359
|
const userType = params.userType;
|
|
37301
37360
|
const type = params.type;
|
|
37302
37361
|
const query = {
|
|
@@ -37411,7 +37470,7 @@ function UseAccessManagementRepo() {
|
|
|
37411
37470
|
}
|
|
37412
37471
|
async function userTypeAccessCardsRepo(params) {
|
|
37413
37472
|
try {
|
|
37414
|
-
const site = new
|
|
37473
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37415
37474
|
const userType = params.userType;
|
|
37416
37475
|
const page = params.page ? Number(params.page) - 1 : 0;
|
|
37417
37476
|
const limit = Number(params.limit) || 10;
|
|
@@ -37810,7 +37869,7 @@ function UseAccessManagementRepo() {
|
|
|
37810
37869
|
}
|
|
37811
37870
|
async function assignedAccessCardsRepo(params) {
|
|
37812
37871
|
try {
|
|
37813
|
-
const site = new
|
|
37872
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
37814
37873
|
const userType = params.userType;
|
|
37815
37874
|
const type = params.type;
|
|
37816
37875
|
const search = params.search;
|
|
@@ -37985,12 +38044,12 @@ function UseAccessManagementRepo() {
|
|
|
37985
38044
|
session?.startTransaction();
|
|
37986
38045
|
const { userId, cardId, site } = params;
|
|
37987
38046
|
const allUserId = await Promise.all(
|
|
37988
|
-
userId.map(async (id) => new
|
|
38047
|
+
userId.map(async (id) => new import_mongodb93.ObjectId(id))
|
|
37989
38048
|
);
|
|
37990
38049
|
const allCardId = await Promise.all(
|
|
37991
|
-
cardId.map(async (id) => new
|
|
38050
|
+
cardId.map(async (id) => new import_mongodb93.ObjectId(id))
|
|
37992
38051
|
);
|
|
37993
|
-
const siteId = new
|
|
38052
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
37994
38053
|
const result = await collection().updateMany(
|
|
37995
38054
|
{
|
|
37996
38055
|
$or: [
|
|
@@ -38021,7 +38080,7 @@ function UseAccessManagementRepo() {
|
|
|
38021
38080
|
async function accessandLiftCardsRepo(params) {
|
|
38022
38081
|
try {
|
|
38023
38082
|
const { accessLevel, liftAccessLevel, site, userType, type } = params;
|
|
38024
|
-
const siteId = new
|
|
38083
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
38025
38084
|
const query = {
|
|
38026
38085
|
site: { $in: [siteId] },
|
|
38027
38086
|
userType,
|
|
@@ -38054,9 +38113,9 @@ function UseAccessManagementRepo() {
|
|
|
38054
38113
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
38055
38114
|
try {
|
|
38056
38115
|
session?.startTransaction();
|
|
38057
|
-
const siteId = new
|
|
38058
|
-
const userId = new
|
|
38059
|
-
const cardId = new
|
|
38116
|
+
const siteId = new import_mongodb93.ObjectId(params.site);
|
|
38117
|
+
const userId = new import_mongodb93.ObjectId(params.userId);
|
|
38118
|
+
const cardId = new import_mongodb93.ObjectId(params.cardId);
|
|
38060
38119
|
const quantity = 1;
|
|
38061
38120
|
const cardCredentials = await collection().findOneAndUpdate(
|
|
38062
38121
|
{ _id: cardId },
|
|
@@ -38082,7 +38141,7 @@ function UseAccessManagementRepo() {
|
|
|
38082
38141
|
(no) => no.toString().padStart(10, "0")
|
|
38083
38142
|
);
|
|
38084
38143
|
const accessCards = [];
|
|
38085
|
-
const convertedUnits = unit.map((obj) => new
|
|
38144
|
+
const convertedUnits = unit.map((obj) => new import_mongodb93.ObjectId(obj));
|
|
38086
38145
|
for (let j = 0; j < (unit.length > 0 ? unit.length : quantity); j++) {
|
|
38087
38146
|
accessCards.push(
|
|
38088
38147
|
new MAccessCard({
|
|
@@ -38171,7 +38230,7 @@ function UseAccessManagementRepo() {
|
|
|
38171
38230
|
session?.startTransaction();
|
|
38172
38231
|
const results = [];
|
|
38173
38232
|
for (let nfc of params.nfcList) {
|
|
38174
|
-
nfc._id = new
|
|
38233
|
+
nfc._id = new import_mongodb93.ObjectId(nfc._id);
|
|
38175
38234
|
const card = await collection().findOne({ _id: nfc._id }, { session });
|
|
38176
38235
|
if (card) {
|
|
38177
38236
|
const updateFields = {
|
|
@@ -38205,7 +38264,7 @@ function UseAccessManagementRepo() {
|
|
|
38205
38264
|
async function doorAndLiftDropdownRepo(params) {
|
|
38206
38265
|
try {
|
|
38207
38266
|
const { site, type, userType } = params;
|
|
38208
|
-
const id = new
|
|
38267
|
+
const id = new import_mongodb93.ObjectId(site);
|
|
38209
38268
|
const res = collection().aggregate([
|
|
38210
38269
|
{
|
|
38211
38270
|
$match: {
|
|
@@ -38292,10 +38351,10 @@ function UseAccessManagementRepo() {
|
|
|
38292
38351
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
38293
38352
|
try {
|
|
38294
38353
|
const { cardId, remarks, issuedCardId, unitId, userId } = params;
|
|
38295
|
-
const id = new
|
|
38296
|
-
const newCardId = new
|
|
38297
|
-
const unit = new
|
|
38298
|
-
const user = new
|
|
38354
|
+
const id = new import_mongodb93.ObjectId(cardId);
|
|
38355
|
+
const newCardId = new import_mongodb93.ObjectId(issuedCardId);
|
|
38356
|
+
const unit = new import_mongodb93.ObjectId(unitId);
|
|
38357
|
+
const user = new import_mongodb93.ObjectId(userId);
|
|
38299
38358
|
session?.startTransaction();
|
|
38300
38359
|
const sessionResult = await Promise.all([
|
|
38301
38360
|
await collection().findOneAndUpdate(
|
|
@@ -38328,7 +38387,7 @@ function UseAccessManagementRepo() {
|
|
|
38328
38387
|
async function visitorAccessCardsRepo(params) {
|
|
38329
38388
|
try {
|
|
38330
38389
|
const page = params.page ? params.page - 1 : 0;
|
|
38331
|
-
const siteId = new
|
|
38390
|
+
const siteId = new import_mongodb93.ObjectId(params.site);
|
|
38332
38391
|
const search = params.search;
|
|
38333
38392
|
const type = params.type;
|
|
38334
38393
|
const limit = Number(params.limit);
|
|
@@ -38396,7 +38455,7 @@ function UseAccessManagementRepo() {
|
|
|
38396
38455
|
}
|
|
38397
38456
|
async function getCardReplacementRepo(params) {
|
|
38398
38457
|
try {
|
|
38399
|
-
const site = new
|
|
38458
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
38400
38459
|
const search = params.search;
|
|
38401
38460
|
const statusFilter = params.statusFilter;
|
|
38402
38461
|
const dateFrom = params.dateFrom;
|
|
@@ -38568,7 +38627,7 @@ function UseAccessManagementRepo() {
|
|
|
38568
38627
|
async function getAccessManagementSettingsRepo(params) {
|
|
38569
38628
|
try {
|
|
38570
38629
|
const { site } = params;
|
|
38571
|
-
const siteId = new
|
|
38630
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
38572
38631
|
const res = await collectionName("entrypass-settings").findOne(
|
|
38573
38632
|
{ site: siteId },
|
|
38574
38633
|
{ allowDiskUse: true }
|
|
@@ -38602,7 +38661,7 @@ function UseAccessManagementRepo() {
|
|
|
38602
38661
|
const rawAccessGroup = item["accessGroup (value ex. Full Access, No Access)"];
|
|
38603
38662
|
const accessGroup = typeof rawAccessGroup === "string" ? rawAccessGroup.split(",").map((v) => v.trim()).filter((v) => v !== "") : [];
|
|
38604
38663
|
return new MAccessCard({
|
|
38605
|
-
site: new
|
|
38664
|
+
site: new import_mongodb93.ObjectId(site),
|
|
38606
38665
|
type: "NFC" /* NFC */,
|
|
38607
38666
|
staffNo: null,
|
|
38608
38667
|
accessLevel,
|
|
@@ -38653,8 +38712,8 @@ function UseAccessManagementRepo() {
|
|
|
38653
38712
|
liftAccessLevel
|
|
38654
38713
|
} = params;
|
|
38655
38714
|
const [convertedUnits, convertedSite] = await Promise.all([
|
|
38656
|
-
Promise.all(units.map((id) => new
|
|
38657
|
-
new
|
|
38715
|
+
Promise.all(units.map((id) => new import_mongodb93.ObjectId(id))),
|
|
38716
|
+
new import_mongodb93.ObjectId(site)
|
|
38658
38717
|
]);
|
|
38659
38718
|
const totalRequired = quantity * convertedUnits.length;
|
|
38660
38719
|
const availableCards = await collection().find({
|
|
@@ -38706,7 +38765,7 @@ function UseAccessManagementRepo() {
|
|
|
38706
38765
|
async function deleteCardRepo(params) {
|
|
38707
38766
|
try {
|
|
38708
38767
|
const { cardId, remarks } = params;
|
|
38709
|
-
const id = new
|
|
38768
|
+
const id = new import_mongodb93.ObjectId(cardId);
|
|
38710
38769
|
const result = await collection().findOneAndUpdate(
|
|
38711
38770
|
{ _id: id },
|
|
38712
38771
|
{
|
|
@@ -38727,8 +38786,8 @@ function UseAccessManagementRepo() {
|
|
|
38727
38786
|
async function getCardDetailsRepo(params) {
|
|
38728
38787
|
try {
|
|
38729
38788
|
const { siteId, cardId } = params;
|
|
38730
|
-
const convertedSiteId = new
|
|
38731
|
-
const convertedCardId = new
|
|
38789
|
+
const convertedSiteId = new import_mongodb93.ObjectId(siteId);
|
|
38790
|
+
const convertedCardId = new import_mongodb93.ObjectId(cardId);
|
|
38732
38791
|
const card = await collection().findOne(
|
|
38733
38792
|
{
|
|
38734
38793
|
_id: convertedCardId,
|
|
@@ -38777,7 +38836,7 @@ function UseAccessManagementRepo() {
|
|
|
38777
38836
|
async function addQrTagRepo(params) {
|
|
38778
38837
|
try {
|
|
38779
38838
|
const { site, payload } = params;
|
|
38780
|
-
const id = new
|
|
38839
|
+
const id = new import_mongodb93.ObjectId(site);
|
|
38781
38840
|
const highestCardNo = await collection().aggregate([
|
|
38782
38841
|
{
|
|
38783
38842
|
$match: {
|
|
@@ -38811,7 +38870,7 @@ function UseAccessManagementRepo() {
|
|
|
38811
38870
|
);
|
|
38812
38871
|
const bulkOps = await Promise.all(
|
|
38813
38872
|
payload.map(async (doc, index) => {
|
|
38814
|
-
const id2 = new
|
|
38873
|
+
const id2 = new import_mongodb93.ObjectId(doc._id);
|
|
38815
38874
|
return {
|
|
38816
38875
|
updateOne: {
|
|
38817
38876
|
filter: { _id: id2 },
|
|
@@ -38834,7 +38893,7 @@ function UseAccessManagementRepo() {
|
|
|
38834
38893
|
async function allQrTagRepo(params) {
|
|
38835
38894
|
try {
|
|
38836
38895
|
const { site } = params;
|
|
38837
|
-
const siteId = new
|
|
38896
|
+
const siteId = new import_mongodb93.ObjectId(site);
|
|
38838
38897
|
const query = {
|
|
38839
38898
|
site: siteId,
|
|
38840
38899
|
assignedUnit: { $ne: null },
|
|
@@ -38883,8 +38942,8 @@ function UseAccessManagementRepo() {
|
|
|
38883
38942
|
}
|
|
38884
38943
|
async function availableCardContractorsRepo(params) {
|
|
38885
38944
|
try {
|
|
38886
|
-
const siteId = new
|
|
38887
|
-
const unitId = new
|
|
38945
|
+
const siteId = new import_mongodb93.ObjectId(params.siteId);
|
|
38946
|
+
const unitId = new import_mongodb93.ObjectId(params.unitId);
|
|
38888
38947
|
const page = Number(params.page) - 1;
|
|
38889
38948
|
const limit = Number(params.limit) || 10;
|
|
38890
38949
|
const type = params.type;
|
|
@@ -38985,8 +39044,8 @@ function UseAccessManagementRepo() {
|
|
|
38985
39044
|
}
|
|
38986
39045
|
async function vmsgenerateQrCodesRepo(params) {
|
|
38987
39046
|
try {
|
|
38988
|
-
const site = new
|
|
38989
|
-
const unitId = new
|
|
39047
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
39048
|
+
const unitId = new import_mongodb93.ObjectId(params.unitId);
|
|
38990
39049
|
const quantity = Number(params.quantity);
|
|
38991
39050
|
const normalizedUnitId = params.normalizedUnitId;
|
|
38992
39051
|
const date = /* @__PURE__ */ new Date();
|
|
@@ -39041,11 +39100,11 @@ function UseAccessManagementRepo() {
|
|
|
39041
39100
|
let isAborted = false;
|
|
39042
39101
|
try {
|
|
39043
39102
|
await session?.startTransaction();
|
|
39044
|
-
const siteId = new
|
|
39045
|
-
const unitId = new
|
|
39103
|
+
const siteId = new import_mongodb93.ObjectId(params.site);
|
|
39104
|
+
const unitId = new import_mongodb93.ObjectId(params.unitId);
|
|
39046
39105
|
const quantity = params.quantity;
|
|
39047
39106
|
const type = params.type;
|
|
39048
|
-
const visitorId = new
|
|
39107
|
+
const visitorId = new import_mongodb93.ObjectId(params.visitorId);
|
|
39049
39108
|
const nfcCards = params.nfcCards;
|
|
39050
39109
|
const acm_url = params.acm_url;
|
|
39051
39110
|
let cards = [];
|
|
@@ -39067,7 +39126,7 @@ function UseAccessManagementRepo() {
|
|
|
39067
39126
|
} else if (type === "NFC" /* NFC */) {
|
|
39068
39127
|
if (nfcCards && nfcCards.length > 0) {
|
|
39069
39128
|
const objectIds = nfcCards.map(
|
|
39070
|
-
(card) => new
|
|
39129
|
+
(card) => new import_mongodb93.ObjectId(card._id)
|
|
39071
39130
|
);
|
|
39072
39131
|
cards = await collection().find({ _id: { $in: objectIds } }).toArray();
|
|
39073
39132
|
const nfcList = objectIds.map((card) => ({
|
|
@@ -39174,7 +39233,7 @@ function UseAccessManagementRepo() {
|
|
|
39174
39233
|
}
|
|
39175
39234
|
async function signQrCodeRepo(params) {
|
|
39176
39235
|
try {
|
|
39177
|
-
const cardId = new
|
|
39236
|
+
const cardId = new import_mongodb93.ObjectId(params.cardId);
|
|
39178
39237
|
const purpose = params.purpose;
|
|
39179
39238
|
let validity = 5;
|
|
39180
39239
|
const card = await collection().findOne({ _id: cardId });
|
|
@@ -39199,7 +39258,7 @@ function UseAccessManagementRepo() {
|
|
|
39199
39258
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
39200
39259
|
try {
|
|
39201
39260
|
await session?.startTransaction();
|
|
39202
|
-
const userId = new
|
|
39261
|
+
const userId = new import_mongodb93.ObjectId(params.userId);
|
|
39203
39262
|
const result = await collection().updateMany(
|
|
39204
39263
|
{ userId },
|
|
39205
39264
|
{ $set: { userId: null, status: "Available", updatedAt: /* @__PURE__ */ new Date() } }
|
|
@@ -39214,7 +39273,7 @@ function UseAccessManagementRepo() {
|
|
|
39214
39273
|
}
|
|
39215
39274
|
}
|
|
39216
39275
|
async function getBlockLevelAndUnitListRepo(params) {
|
|
39217
|
-
const site = new
|
|
39276
|
+
const site = new import_mongodb93.ObjectId(params.site);
|
|
39218
39277
|
try {
|
|
39219
39278
|
const blocks = await collectionName("buildings").aggregate([
|
|
39220
39279
|
{
|
|
@@ -39284,7 +39343,7 @@ function UseAccessManagementRepo() {
|
|
|
39284
39343
|
url
|
|
39285
39344
|
}) {
|
|
39286
39345
|
page = page ? page - 1 : 0;
|
|
39287
|
-
site = new
|
|
39346
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39288
39347
|
try {
|
|
39289
39348
|
let index = await collectionName("access-card-transactions").findOne(
|
|
39290
39349
|
{},
|
|
@@ -39419,9 +39478,9 @@ function UseAccessManagementRepo() {
|
|
|
39419
39478
|
throw new Error("No user to Assign.");
|
|
39420
39479
|
}
|
|
39421
39480
|
assignees = assignees.map(
|
|
39422
|
-
(data) => new
|
|
39481
|
+
(data) => new import_mongodb93.ObjectId(data)
|
|
39423
39482
|
);
|
|
39424
|
-
unit = new
|
|
39483
|
+
unit = new import_mongodb93.ObjectId(unit);
|
|
39425
39484
|
let availableCards = [];
|
|
39426
39485
|
let update = [];
|
|
39427
39486
|
let cards = [];
|
|
@@ -39454,13 +39513,13 @@ function UseAccessManagementRepo() {
|
|
|
39454
39513
|
throw new Error(`Not enough ${type} cards available.`);
|
|
39455
39514
|
}
|
|
39456
39515
|
cards = availableCards?.slice(0, assignees.length).map((card, index) => {
|
|
39457
|
-
const userId = new
|
|
39516
|
+
const userId = new import_mongodb93.ObjectId(assignees[index].toString());
|
|
39458
39517
|
card.staffNo = userId.toString().slice(-10);
|
|
39459
39518
|
return card;
|
|
39460
39519
|
});
|
|
39461
39520
|
update = availableCards.slice(0, assignees.length).map((card, index) => ({
|
|
39462
39521
|
_id: card._id,
|
|
39463
|
-
userId: new
|
|
39522
|
+
userId: new import_mongodb93.ObjectId(assignees[index])
|
|
39464
39523
|
}));
|
|
39465
39524
|
const commands = cards.map((item, index) => {
|
|
39466
39525
|
let ag = null;
|
|
@@ -39526,7 +39585,7 @@ function UseAccessManagementRepo() {
|
|
|
39526
39585
|
const session = import_node_server_utils157.useAtlas.getClient()?.startSession();
|
|
39527
39586
|
try {
|
|
39528
39587
|
session?.startTransaction();
|
|
39529
|
-
const id = new
|
|
39588
|
+
const id = new import_mongodb93.ObjectId(userId);
|
|
39530
39589
|
await collection().updateMany(
|
|
39531
39590
|
{ userId: id },
|
|
39532
39591
|
{ $set: { userId: null, status: "Available" } },
|
|
@@ -39546,8 +39605,8 @@ function UseAccessManagementRepo() {
|
|
|
39546
39605
|
id,
|
|
39547
39606
|
name
|
|
39548
39607
|
}) {
|
|
39549
|
-
site = new
|
|
39550
|
-
id = new
|
|
39608
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39609
|
+
id = new import_mongodb93.ObjectId(id);
|
|
39551
39610
|
try {
|
|
39552
39611
|
const result = await collectionName("sites").updateOne(
|
|
39553
39612
|
{ _id: site },
|
|
@@ -39564,9 +39623,9 @@ function UseAccessManagementRepo() {
|
|
|
39564
39623
|
unitId
|
|
39565
39624
|
}) {
|
|
39566
39625
|
try {
|
|
39567
|
-
orgId = new
|
|
39568
|
-
siteId = new
|
|
39569
|
-
unitId = new
|
|
39626
|
+
orgId = new import_mongodb93.ObjectId(orgId);
|
|
39627
|
+
siteId = new import_mongodb93.ObjectId(siteId);
|
|
39628
|
+
unitId = new import_mongodb93.ObjectId(unitId);
|
|
39570
39629
|
const result = await collectionName("users").aggregate([
|
|
39571
39630
|
{
|
|
39572
39631
|
$match: {
|
|
@@ -39604,8 +39663,8 @@ function UseAccessManagementRepo() {
|
|
|
39604
39663
|
isLiftCard
|
|
39605
39664
|
}) {
|
|
39606
39665
|
try {
|
|
39607
|
-
siteId = new
|
|
39608
|
-
userId = new
|
|
39666
|
+
siteId = new import_mongodb93.ObjectId(siteId);
|
|
39667
|
+
userId = new import_mongodb93.ObjectId(userId);
|
|
39609
39668
|
const query = {
|
|
39610
39669
|
site: siteId,
|
|
39611
39670
|
userId,
|
|
@@ -39626,7 +39685,7 @@ function UseAccessManagementRepo() {
|
|
|
39626
39685
|
}
|
|
39627
39686
|
}
|
|
39628
39687
|
async function removeTemplateRepo({ site }) {
|
|
39629
|
-
site = new
|
|
39688
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39630
39689
|
try {
|
|
39631
39690
|
const result = await collectionName("entrypass-settings").updateOne({ _id: site }, { $set: { "settings.template": {} } });
|
|
39632
39691
|
return result;
|
|
@@ -39639,8 +39698,8 @@ function UseAccessManagementRepo() {
|
|
|
39639
39698
|
page = page ? page - 1 : 0;
|
|
39640
39699
|
let defaultQuery = {};
|
|
39641
39700
|
let searchQuery = {};
|
|
39642
|
-
site = new
|
|
39643
|
-
userId = new
|
|
39701
|
+
site = new import_mongodb93.ObjectId(site);
|
|
39702
|
+
userId = new import_mongodb93.ObjectId(userId);
|
|
39644
39703
|
if (search) {
|
|
39645
39704
|
searchQuery = {
|
|
39646
39705
|
$or: [{ fullName: { $regex: search, $options: "i" } }, { cardNo: { $regex: search, $options: "i" } }]
|
|
@@ -41386,7 +41445,7 @@ function useAccessManagementController() {
|
|
|
41386
41445
|
}
|
|
41387
41446
|
|
|
41388
41447
|
// src/models/nfc-patrol-tag.model.ts
|
|
41389
|
-
var
|
|
41448
|
+
var import_mongodb94 = require("mongodb");
|
|
41390
41449
|
var import_joi88 = __toESM(require("joi"));
|
|
41391
41450
|
var import_node_server_utils158 = require("@7365admin1/node-server-utils");
|
|
41392
41451
|
var DEVICE_STATUS = {
|
|
@@ -41413,27 +41472,27 @@ var schemaNfcPatrolTag = import_joi88.default.object({
|
|
|
41413
41472
|
function MNfcPatrolTag(value) {
|
|
41414
41473
|
if (value._id && typeof value._id === "string") {
|
|
41415
41474
|
try {
|
|
41416
|
-
value._id = new
|
|
41475
|
+
value._id = new import_mongodb94.ObjectId(value._id);
|
|
41417
41476
|
} catch {
|
|
41418
41477
|
throw new import_node_server_utils158.BadRequestError("Invalid ID.");
|
|
41419
41478
|
}
|
|
41420
41479
|
}
|
|
41421
41480
|
if (value.site && typeof value.site === "string") {
|
|
41422
41481
|
try {
|
|
41423
|
-
value.site = new
|
|
41482
|
+
value.site = new import_mongodb94.ObjectId(value.site);
|
|
41424
41483
|
} catch {
|
|
41425
41484
|
throw new import_node_server_utils158.BadRequestError("Invalid site ID.");
|
|
41426
41485
|
}
|
|
41427
41486
|
}
|
|
41428
41487
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
41429
41488
|
try {
|
|
41430
|
-
value.createdBy = new
|
|
41489
|
+
value.createdBy = new import_mongodb94.ObjectId(value.createdBy);
|
|
41431
41490
|
} catch {
|
|
41432
41491
|
throw new import_node_server_utils158.BadRequestError("Invalid Created By ID.");
|
|
41433
41492
|
}
|
|
41434
41493
|
}
|
|
41435
41494
|
return {
|
|
41436
|
-
_id: value._id ?? new
|
|
41495
|
+
_id: value._id ?? new import_mongodb94.ObjectId(),
|
|
41437
41496
|
site: value.site,
|
|
41438
41497
|
tagID: value.tagID,
|
|
41439
41498
|
name: value.name,
|
|
@@ -41445,7 +41504,7 @@ function MNfcPatrolTag(value) {
|
|
|
41445
41504
|
|
|
41446
41505
|
// src/repositories/nfc-patrol-tag.repository.ts
|
|
41447
41506
|
var import_node_server_utils159 = require("@7365admin1/node-server-utils");
|
|
41448
|
-
var
|
|
41507
|
+
var import_mongodb95 = require("mongodb");
|
|
41449
41508
|
function useNfcPatrolTagRepo() {
|
|
41450
41509
|
const db = import_node_server_utils159.useAtlas.getDb();
|
|
41451
41510
|
if (!db) {
|
|
@@ -41499,7 +41558,7 @@ function useNfcPatrolTagRepo() {
|
|
|
41499
41558
|
}, session) {
|
|
41500
41559
|
page = page > 0 ? page - 1 : 0;
|
|
41501
41560
|
try {
|
|
41502
|
-
site = new
|
|
41561
|
+
site = new import_mongodb95.ObjectId(site);
|
|
41503
41562
|
} catch (error) {
|
|
41504
41563
|
throw new import_node_server_utils159.BadRequestError("Invalid site ID format.");
|
|
41505
41564
|
}
|
|
@@ -41543,19 +41602,19 @@ function useNfcPatrolTagRepo() {
|
|
|
41543
41602
|
const [updateType, findObject, setData, session] = args;
|
|
41544
41603
|
if (findObject?.site && typeof findObject.site === "string") {
|
|
41545
41604
|
try {
|
|
41546
|
-
findObject.site = new
|
|
41605
|
+
findObject.site = new import_mongodb95.ObjectId(findObject.site);
|
|
41547
41606
|
} catch {
|
|
41548
41607
|
throw new import_node_server_utils159.BadRequestError("Invalid site ID.");
|
|
41549
41608
|
}
|
|
41550
41609
|
}
|
|
41551
41610
|
if (updateType == "Edit" && findObject?._id && typeof findObject._id === "string") {
|
|
41552
41611
|
try {
|
|
41553
|
-
findObject._id = new
|
|
41612
|
+
findObject._id = new import_mongodb95.ObjectId(findObject._id);
|
|
41554
41613
|
} catch {
|
|
41555
41614
|
throw new import_node_server_utils159.BadRequestError("Invalid nfc patrol tag document ID.");
|
|
41556
41615
|
}
|
|
41557
41616
|
try {
|
|
41558
|
-
setData.updatedBy = new
|
|
41617
|
+
setData.updatedBy = new import_mongodb95.ObjectId(setData.updatedBy);
|
|
41559
41618
|
} catch {
|
|
41560
41619
|
throw new import_node_server_utils159.BadRequestError("Invalid updatedBy ID.");
|
|
41561
41620
|
}
|
|
@@ -41846,7 +41905,7 @@ function useNfcPatrolTagController() {
|
|
|
41846
41905
|
}
|
|
41847
41906
|
|
|
41848
41907
|
// src/models/occurrence-book.model.ts
|
|
41849
|
-
var
|
|
41908
|
+
var import_mongodb96 = require("mongodb");
|
|
41850
41909
|
var import_joi90 = __toESM(require("joi"));
|
|
41851
41910
|
var DOBStatus = /* @__PURE__ */ ((DOBStatus3) => {
|
|
41852
41911
|
DOBStatus3["OPEN"] = "open";
|
|
@@ -41872,20 +41931,20 @@ var schemaUpdateOccurrenceBook = import_joi90.default.object({
|
|
|
41872
41931
|
function MOccurrenceBook(value) {
|
|
41873
41932
|
if (value._id && typeof value._id === "string") {
|
|
41874
41933
|
try {
|
|
41875
|
-
value._id = new
|
|
41934
|
+
value._id = new import_mongodb96.ObjectId(value._id);
|
|
41876
41935
|
} catch {
|
|
41877
41936
|
throw new Error("Invalid ID.");
|
|
41878
41937
|
}
|
|
41879
41938
|
}
|
|
41880
41939
|
if (value.site && typeof value.site === "string") {
|
|
41881
41940
|
try {
|
|
41882
|
-
value.site = new
|
|
41941
|
+
value.site = new import_mongodb96.ObjectId(value.site);
|
|
41883
41942
|
} catch {
|
|
41884
41943
|
throw new Error("Invalid site ID.");
|
|
41885
41944
|
}
|
|
41886
41945
|
}
|
|
41887
41946
|
return {
|
|
41888
|
-
_id: value._id ?? new
|
|
41947
|
+
_id: value._id ?? new import_mongodb96.ObjectId(),
|
|
41889
41948
|
site: value.site,
|
|
41890
41949
|
date: value.date ?? "",
|
|
41891
41950
|
totalInput: value.totalInput ?? 0,
|
|
@@ -41900,7 +41959,7 @@ function MOccurrenceBook(value) {
|
|
|
41900
41959
|
|
|
41901
41960
|
// src/repositories/occurrence-book.repo.ts
|
|
41902
41961
|
var import_node_server_utils162 = require("@7365admin1/node-server-utils");
|
|
41903
|
-
var
|
|
41962
|
+
var import_mongodb97 = require("mongodb");
|
|
41904
41963
|
var occurrence_book_namespace_collection = "occurrence-books";
|
|
41905
41964
|
function useOccurrenceBookRepo() {
|
|
41906
41965
|
const db = import_node_server_utils162.useAtlas.getDb();
|
|
@@ -42044,7 +42103,7 @@ function useOccurrenceBookRepo() {
|
|
|
42044
42103
|
}
|
|
42045
42104
|
async function getOccurrenceBookById(_id, session) {
|
|
42046
42105
|
try {
|
|
42047
|
-
_id = new
|
|
42106
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
42048
42107
|
} catch (error) {
|
|
42049
42108
|
throw new import_node_server_utils162.BadRequestError("Invalid occurrence book ID format.");
|
|
42050
42109
|
}
|
|
@@ -42074,7 +42133,7 @@ function useOccurrenceBookRepo() {
|
|
|
42074
42133
|
async function updateOccurrenceBookById(_id, value, session) {
|
|
42075
42134
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42076
42135
|
try {
|
|
42077
|
-
_id = new
|
|
42136
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
42078
42137
|
} catch (error) {
|
|
42079
42138
|
throw new import_node_server_utils162.BadRequestError("Invalid ID format.");
|
|
42080
42139
|
}
|
|
@@ -42106,7 +42165,7 @@ function useOccurrenceBookRepo() {
|
|
|
42106
42165
|
}
|
|
42107
42166
|
async function deleteOccurrenceBookById(_id) {
|
|
42108
42167
|
try {
|
|
42109
|
-
_id = new
|
|
42168
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
42110
42169
|
} catch (error) {
|
|
42111
42170
|
throw new import_node_server_utils162.BadRequestError("Invalid occurrence book ID format.");
|
|
42112
42171
|
}
|
|
@@ -42491,7 +42550,7 @@ function useOccurrenceBookController() {
|
|
|
42491
42550
|
}
|
|
42492
42551
|
|
|
42493
42552
|
// src/models/bulletin-video.model.ts
|
|
42494
|
-
var
|
|
42553
|
+
var import_mongodb98 = require("mongodb");
|
|
42495
42554
|
var import_joi92 = __toESM(require("joi"));
|
|
42496
42555
|
var BulletinVideoSort = /* @__PURE__ */ ((BulletinVideoSort2) => {
|
|
42497
42556
|
BulletinVideoSort2["CREATED_AT"] = "createdAt";
|
|
@@ -42519,27 +42578,27 @@ var schemaUpdateBulletinVideo = import_joi92.default.object({
|
|
|
42519
42578
|
function MBulletinVideo(value) {
|
|
42520
42579
|
if (value._id && typeof value._id === "string") {
|
|
42521
42580
|
try {
|
|
42522
|
-
value._id = new
|
|
42581
|
+
value._id = new import_mongodb98.ObjectId(value._id);
|
|
42523
42582
|
} catch {
|
|
42524
42583
|
throw new Error("Invalid ID.");
|
|
42525
42584
|
}
|
|
42526
42585
|
}
|
|
42527
42586
|
if (value.site && typeof value.site === "string") {
|
|
42528
42587
|
try {
|
|
42529
|
-
value.site = new
|
|
42588
|
+
value.site = new import_mongodb98.ObjectId(value.site);
|
|
42530
42589
|
} catch {
|
|
42531
42590
|
throw new Error("Invalid site ID.");
|
|
42532
42591
|
}
|
|
42533
42592
|
}
|
|
42534
42593
|
if (value.file && typeof value.file === "string") {
|
|
42535
42594
|
try {
|
|
42536
|
-
value.file = new
|
|
42595
|
+
value.file = new import_mongodb98.ObjectId(value.file);
|
|
42537
42596
|
} catch {
|
|
42538
42597
|
throw new Error("Invalid file ID.");
|
|
42539
42598
|
}
|
|
42540
42599
|
}
|
|
42541
42600
|
return {
|
|
42542
|
-
_id: value._id ?? new
|
|
42601
|
+
_id: value._id ?? new import_mongodb98.ObjectId(),
|
|
42543
42602
|
site: value.site,
|
|
42544
42603
|
title: value.title ?? "",
|
|
42545
42604
|
description: value.description ?? "",
|
|
@@ -42552,7 +42611,7 @@ function MBulletinVideo(value) {
|
|
|
42552
42611
|
|
|
42553
42612
|
// src/repositories/bulletin-video.repo.ts
|
|
42554
42613
|
var import_node_server_utils165 = require("@7365admin1/node-server-utils");
|
|
42555
|
-
var
|
|
42614
|
+
var import_mongodb99 = require("mongodb");
|
|
42556
42615
|
function useBulletinVideoRepo() {
|
|
42557
42616
|
const db = import_node_server_utils165.useAtlas.getDb();
|
|
42558
42617
|
if (!db) {
|
|
@@ -42614,7 +42673,7 @@ function useBulletinVideoRepo() {
|
|
|
42614
42673
|
}, session) {
|
|
42615
42674
|
page = page > 0 ? page - 1 : 0;
|
|
42616
42675
|
try {
|
|
42617
|
-
site = new
|
|
42676
|
+
site = new import_mongodb99.ObjectId(site);
|
|
42618
42677
|
} catch (error) {
|
|
42619
42678
|
throw new import_node_server_utils165.BadRequestError("Invalid site ID format.");
|
|
42620
42679
|
}
|
|
@@ -42694,7 +42753,7 @@ function useBulletinVideoRepo() {
|
|
|
42694
42753
|
}
|
|
42695
42754
|
async function getBulletinVideoById(_id, session) {
|
|
42696
42755
|
try {
|
|
42697
|
-
_id = new
|
|
42756
|
+
_id = new import_mongodb99.ObjectId(_id);
|
|
42698
42757
|
} catch (error) {
|
|
42699
42758
|
throw new import_node_server_utils165.BadRequestError("Invalid bulletin video ID format.");
|
|
42700
42759
|
}
|
|
@@ -42725,13 +42784,13 @@ function useBulletinVideoRepo() {
|
|
|
42725
42784
|
async function updateBulletinVideoById(_id, value, session) {
|
|
42726
42785
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42727
42786
|
try {
|
|
42728
|
-
_id = new
|
|
42787
|
+
_id = new import_mongodb99.ObjectId(_id);
|
|
42729
42788
|
} catch (error) {
|
|
42730
42789
|
throw new import_node_server_utils165.BadRequestError("Invalid ID format.");
|
|
42731
42790
|
}
|
|
42732
42791
|
if (value.file && typeof value.file === "string") {
|
|
42733
42792
|
try {
|
|
42734
|
-
value.file = new
|
|
42793
|
+
value.file = new import_mongodb99.ObjectId(value.file);
|
|
42735
42794
|
} catch {
|
|
42736
42795
|
throw new Error("Invalid file ID.");
|
|
42737
42796
|
}
|
|
@@ -42760,7 +42819,7 @@ function useBulletinVideoRepo() {
|
|
|
42760
42819
|
}
|
|
42761
42820
|
async function deleteBulletinVideoById(_id, session) {
|
|
42762
42821
|
try {
|
|
42763
|
-
_id = new
|
|
42822
|
+
_id = new import_mongodb99.ObjectId(_id);
|
|
42764
42823
|
} catch (error) {
|
|
42765
42824
|
throw new import_node_server_utils165.BadRequestError("Invalid bulletin video ID format.");
|
|
42766
42825
|
}
|
|
@@ -43024,7 +43083,7 @@ function useBulletinVideoController() {
|
|
|
43024
43083
|
|
|
43025
43084
|
// src/models/site-soa.model.ts
|
|
43026
43085
|
var import_node_server_utils168 = require("@7365admin1/node-server-utils");
|
|
43027
|
-
var
|
|
43086
|
+
var import_mongodb100 = require("mongodb");
|
|
43028
43087
|
var import_joi94 = __toESM(require("joi"));
|
|
43029
43088
|
var schemaSOABillingItem = import_joi94.default.object({
|
|
43030
43089
|
_id: import_joi94.default.string().required(),
|
|
@@ -43092,28 +43151,28 @@ function MStatementOfAccount(value) {
|
|
|
43092
43151
|
}
|
|
43093
43152
|
if (value._id && typeof value._id === "string") {
|
|
43094
43153
|
try {
|
|
43095
|
-
value._id = new
|
|
43154
|
+
value._id = new import_mongodb100.ObjectId(value._id);
|
|
43096
43155
|
} catch {
|
|
43097
43156
|
throw new import_node_server_utils168.BadRequestError("Invalid _id format");
|
|
43098
43157
|
}
|
|
43099
43158
|
}
|
|
43100
43159
|
if (value.site && typeof value.site === "string") {
|
|
43101
43160
|
try {
|
|
43102
|
-
value.site = new
|
|
43161
|
+
value.site = new import_mongodb100.ObjectId(value.site);
|
|
43103
43162
|
} catch {
|
|
43104
43163
|
throw new import_node_server_utils168.BadRequestError("Invalid site format");
|
|
43105
43164
|
}
|
|
43106
43165
|
}
|
|
43107
43166
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
43108
43167
|
try {
|
|
43109
|
-
value.createdBy = new
|
|
43168
|
+
value.createdBy = new import_mongodb100.ObjectId(value.createdBy);
|
|
43110
43169
|
} catch {
|
|
43111
43170
|
throw new import_node_server_utils168.BadRequestError("Invalid createBy format");
|
|
43112
43171
|
}
|
|
43113
43172
|
}
|
|
43114
43173
|
if (value.unitId && typeof value.unitId === "string") {
|
|
43115
43174
|
try {
|
|
43116
|
-
value.unitId = new
|
|
43175
|
+
value.unitId = new import_mongodb100.ObjectId(value.unitId);
|
|
43117
43176
|
} catch {
|
|
43118
43177
|
throw new import_node_server_utils168.BadRequestError("Invalid unitId format");
|
|
43119
43178
|
}
|
|
@@ -43122,7 +43181,7 @@ function MStatementOfAccount(value) {
|
|
|
43122
43181
|
value.billing = value.billing.map((bill) => {
|
|
43123
43182
|
if (bill._id && typeof bill._id === "string") {
|
|
43124
43183
|
try {
|
|
43125
|
-
bill._id = new
|
|
43184
|
+
bill._id = new import_mongodb100.ObjectId(bill._id);
|
|
43126
43185
|
} catch {
|
|
43127
43186
|
throw new import_node_server_utils168.BadRequestError("Invalid billing id format");
|
|
43128
43187
|
}
|
|
@@ -43131,7 +43190,7 @@ function MStatementOfAccount(value) {
|
|
|
43131
43190
|
});
|
|
43132
43191
|
}
|
|
43133
43192
|
return {
|
|
43134
|
-
_id: value._id ?? new
|
|
43193
|
+
_id: value._id ?? new import_mongodb100.ObjectId(),
|
|
43135
43194
|
site: value.site,
|
|
43136
43195
|
unitId: value.unitId ?? "",
|
|
43137
43196
|
unit: value.unit ?? "",
|
|
@@ -43154,7 +43213,7 @@ function MStatementOfAccount(value) {
|
|
|
43154
43213
|
|
|
43155
43214
|
// src/repositories/site-soa.repo.ts
|
|
43156
43215
|
var import_node_server_utils169 = require("@7365admin1/node-server-utils");
|
|
43157
|
-
var
|
|
43216
|
+
var import_mongodb101 = require("mongodb");
|
|
43158
43217
|
function useStatementOfAccountRepo() {
|
|
43159
43218
|
const db = import_node_server_utils169.useAtlas.getDb();
|
|
43160
43219
|
if (!db) {
|
|
@@ -43252,7 +43311,7 @@ function useStatementOfAccountRepo() {
|
|
|
43252
43311
|
{ category: { $regex: search, $options: "i" } }
|
|
43253
43312
|
]
|
|
43254
43313
|
},
|
|
43255
|
-
...
|
|
43314
|
+
...import_mongodb101.ObjectId.isValid(site) && { site: new import_mongodb101.ObjectId(site) },
|
|
43256
43315
|
...dateExpr
|
|
43257
43316
|
};
|
|
43258
43317
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -43307,7 +43366,7 @@ function useStatementOfAccountRepo() {
|
|
|
43307
43366
|
}
|
|
43308
43367
|
async function getById(_id) {
|
|
43309
43368
|
try {
|
|
43310
|
-
_id = new
|
|
43369
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43311
43370
|
} catch (error) {
|
|
43312
43371
|
throw new import_node_server_utils169.BadRequestError("Invalid ID.");
|
|
43313
43372
|
}
|
|
@@ -43346,7 +43405,7 @@ function useStatementOfAccountRepo() {
|
|
|
43346
43405
|
}
|
|
43347
43406
|
async function updateById(_id, value, session) {
|
|
43348
43407
|
try {
|
|
43349
|
-
_id = new
|
|
43408
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43350
43409
|
} catch (error) {
|
|
43351
43410
|
throw new import_node_server_utils169.BadRequestError("Invalid site SOA transaction ID format.");
|
|
43352
43411
|
}
|
|
@@ -43365,7 +43424,7 @@ function useStatementOfAccountRepo() {
|
|
|
43365
43424
|
}
|
|
43366
43425
|
async function deleteById(_id) {
|
|
43367
43426
|
try {
|
|
43368
|
-
_id = new
|
|
43427
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43369
43428
|
} catch (error) {
|
|
43370
43429
|
throw new import_node_server_utils169.BadRequestError("Invalid site SOA transaction ID format.");
|
|
43371
43430
|
}
|
|
@@ -43387,7 +43446,7 @@ function useStatementOfAccountRepo() {
|
|
|
43387
43446
|
}
|
|
43388
43447
|
async function updateStatusById(_id, value, session) {
|
|
43389
43448
|
try {
|
|
43390
|
-
_id = new
|
|
43449
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43391
43450
|
} catch (error) {
|
|
43392
43451
|
throw new import_node_server_utils169.BadRequestError("Invalid file ID format.");
|
|
43393
43452
|
}
|
|
@@ -43442,9 +43501,9 @@ function useStatementOfAccountRepo() {
|
|
|
43442
43501
|
{ category: { $regex: search, $options: "i" } }
|
|
43443
43502
|
]
|
|
43444
43503
|
},
|
|
43445
|
-
...
|
|
43504
|
+
...import_mongodb101.ObjectId.isValid(site) && { site: new import_mongodb101.ObjectId(site) },
|
|
43446
43505
|
...dateExpr,
|
|
43447
|
-
...
|
|
43506
|
+
...import_mongodb101.ObjectId.isValid(unitId) && { unitId: new import_mongodb101.ObjectId(unitId) },
|
|
43448
43507
|
...category && { category }
|
|
43449
43508
|
};
|
|
43450
43509
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
@@ -43494,7 +43553,7 @@ function useStatementOfAccountRepo() {
|
|
|
43494
43553
|
async function reviewSOA(_id, value, session) {
|
|
43495
43554
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
43496
43555
|
try {
|
|
43497
|
-
_id = new
|
|
43556
|
+
_id = new import_mongodb101.ObjectId(_id);
|
|
43498
43557
|
} catch (error) {
|
|
43499
43558
|
throw new import_node_server_utils169.BadRequestError("Invalid ID format.");
|
|
43500
43559
|
}
|
|
@@ -43539,7 +43598,7 @@ var import_node_server_utils171 = require("@7365admin1/node-server-utils");
|
|
|
43539
43598
|
|
|
43540
43599
|
// src/services/site-soa.service.ts
|
|
43541
43600
|
var import_node_server_utils170 = require("@7365admin1/node-server-utils");
|
|
43542
|
-
var
|
|
43601
|
+
var import_mongodb102 = require("mongodb");
|
|
43543
43602
|
var import_puppeteer = require("puppeteer");
|
|
43544
43603
|
function useStatementOfAccountService() {
|
|
43545
43604
|
const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
|
|
@@ -43676,7 +43735,7 @@ function useStatementOfAccountService() {
|
|
|
43676
43735
|
if (!approvedBy || !approvedBy.name)
|
|
43677
43736
|
throw new import_node_server_utils170.BadRequestError("Created by not found.");
|
|
43678
43737
|
value.approvedBy.name = approvedBy.name;
|
|
43679
|
-
value.approvedBy._id = new
|
|
43738
|
+
value.approvedBy._id = new import_mongodb102.ObjectId(approvedBy._id);
|
|
43680
43739
|
}
|
|
43681
43740
|
await _reviewSOA(id, value, session);
|
|
43682
43741
|
await session?.commitTransaction();
|
|
@@ -44058,7 +44117,7 @@ function useStatementOfAccountController() {
|
|
|
44058
44117
|
|
|
44059
44118
|
// src/models/site-entrypass-settings.model.ts
|
|
44060
44119
|
var import_node_server_utils172 = require("@7365admin1/node-server-utils");
|
|
44061
|
-
var
|
|
44120
|
+
var import_mongodb103 = require("mongodb");
|
|
44062
44121
|
var import_joi96 = __toESM(require("joi"));
|
|
44063
44122
|
var schemaEntryPassSettings = import_joi96.default.object({
|
|
44064
44123
|
_id: import_joi96.default.string().hex().optional().allow("", null),
|
|
@@ -44106,21 +44165,21 @@ function MEntryPassSettings(value) {
|
|
|
44106
44165
|
}
|
|
44107
44166
|
if (value._id && typeof value._id === "string") {
|
|
44108
44167
|
try {
|
|
44109
|
-
value._id = new
|
|
44168
|
+
value._id = new import_mongodb103.ObjectId(value._id);
|
|
44110
44169
|
} catch {
|
|
44111
44170
|
throw new import_node_server_utils172.BadRequestError("Invalid _id format");
|
|
44112
44171
|
}
|
|
44113
44172
|
}
|
|
44114
44173
|
if (value.site && typeof value.site === "string") {
|
|
44115
44174
|
try {
|
|
44116
|
-
value.site = new
|
|
44175
|
+
value.site = new import_mongodb103.ObjectId(value.site);
|
|
44117
44176
|
} catch {
|
|
44118
44177
|
throw new import_node_server_utils172.BadRequestError("Invalid site format");
|
|
44119
44178
|
}
|
|
44120
44179
|
}
|
|
44121
44180
|
if (value.org && typeof value.org === "string") {
|
|
44122
44181
|
try {
|
|
44123
|
-
value.org = new
|
|
44182
|
+
value.org = new import_mongodb103.ObjectId(value.org);
|
|
44124
44183
|
} catch {
|
|
44125
44184
|
throw new import_node_server_utils172.BadRequestError("Invalid org format");
|
|
44126
44185
|
}
|
|
@@ -44150,7 +44209,7 @@ function MEntryPassSettings(value) {
|
|
|
44150
44209
|
|
|
44151
44210
|
// src/repositories/site-entrypass-settings.repo.ts
|
|
44152
44211
|
var import_node_server_utils173 = require("@7365admin1/node-server-utils");
|
|
44153
|
-
var
|
|
44212
|
+
var import_mongodb104 = require("mongodb");
|
|
44154
44213
|
function useEntryPassSettingsRepo() {
|
|
44155
44214
|
const db = import_node_server_utils173.useAtlas.getDb();
|
|
44156
44215
|
if (!db) {
|
|
@@ -44260,7 +44319,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44260
44319
|
}
|
|
44261
44320
|
async function getEntryPassSettingsById(_id) {
|
|
44262
44321
|
try {
|
|
44263
|
-
_id = new
|
|
44322
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
44264
44323
|
} catch (error) {
|
|
44265
44324
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44266
44325
|
}
|
|
@@ -44327,7 +44386,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44327
44386
|
}
|
|
44328
44387
|
async function updateEntryPassSettingsById(_id, value) {
|
|
44329
44388
|
try {
|
|
44330
|
-
_id = new
|
|
44389
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
44331
44390
|
} catch (error) {
|
|
44332
44391
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44333
44392
|
}
|
|
@@ -44355,7 +44414,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44355
44414
|
}
|
|
44356
44415
|
async function deleteEntryPassSettingsById(_id, session) {
|
|
44357
44416
|
try {
|
|
44358
|
-
_id = new
|
|
44417
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
44359
44418
|
} catch (error) {
|
|
44360
44419
|
throw new import_node_server_utils173.BadRequestError("Invalid card ID format.");
|
|
44361
44420
|
}
|
|
@@ -44388,7 +44447,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44388
44447
|
}
|
|
44389
44448
|
async function getEntryPassSettingsBySiteId(site) {
|
|
44390
44449
|
try {
|
|
44391
|
-
site = new
|
|
44450
|
+
site = new import_mongodb104.ObjectId(site);
|
|
44392
44451
|
} catch (error) {
|
|
44393
44452
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44394
44453
|
}
|
|
@@ -44455,7 +44514,7 @@ function useEntryPassSettingsRepo() {
|
|
|
44455
44514
|
}
|
|
44456
44515
|
async function updateEntryPassSettingsBySiteId(site, value) {
|
|
44457
44516
|
try {
|
|
44458
|
-
site = new
|
|
44517
|
+
site = new import_mongodb104.ObjectId(site);
|
|
44459
44518
|
} catch (error) {
|
|
44460
44519
|
throw new import_node_server_utils173.BadRequestError("Invalid entry pass settings ID format.");
|
|
44461
44520
|
}
|
|
@@ -44814,7 +44873,7 @@ function useDashboardController() {
|
|
|
44814
44873
|
}
|
|
44815
44874
|
|
|
44816
44875
|
// src/models/nfc-patrol-route.model.ts
|
|
44817
|
-
var
|
|
44876
|
+
var import_mongodb105 = require("mongodb");
|
|
44818
44877
|
var import_joi99 = __toESM(require("joi"));
|
|
44819
44878
|
var import_node_server_utils177 = require("@7365admin1/node-server-utils");
|
|
44820
44879
|
var schemaNfcPatrolRoute = import_joi99.default.object({
|
|
@@ -44850,23 +44909,23 @@ function MNfcPatrolRoute(value) {
|
|
|
44850
44909
|
}
|
|
44851
44910
|
if (value._id && typeof value._id === "string") {
|
|
44852
44911
|
try {
|
|
44853
|
-
value._id = new
|
|
44912
|
+
value._id = new import_mongodb105.ObjectId(value._id);
|
|
44854
44913
|
} catch (error2) {
|
|
44855
44914
|
throw new import_node_server_utils177.BadRequestError("Invalid _id format");
|
|
44856
44915
|
}
|
|
44857
44916
|
}
|
|
44858
44917
|
try {
|
|
44859
|
-
value.site = new
|
|
44918
|
+
value.site = new import_mongodb105.ObjectId(value.site);
|
|
44860
44919
|
} catch (error2) {
|
|
44861
44920
|
throw new import_node_server_utils177.BadRequestError("Invalid site format");
|
|
44862
44921
|
}
|
|
44863
44922
|
try {
|
|
44864
|
-
value.createdBy = new
|
|
44923
|
+
value.createdBy = new import_mongodb105.ObjectId(value.createdBy);
|
|
44865
44924
|
} catch (error2) {
|
|
44866
44925
|
throw new import_node_server_utils177.BadRequestError("Invalid createdBy format");
|
|
44867
44926
|
}
|
|
44868
44927
|
return {
|
|
44869
|
-
_id: value._id ?? new
|
|
44928
|
+
_id: value._id ?? new import_mongodb105.ObjectId(),
|
|
44870
44929
|
site: value.site,
|
|
44871
44930
|
name: value.name,
|
|
44872
44931
|
checkPointNumber: value.checkPointNumber,
|
|
@@ -44882,7 +44941,7 @@ function MNfcPatrolRoute(value) {
|
|
|
44882
44941
|
|
|
44883
44942
|
// src/repositories/nfc-patrol-route.repository.ts
|
|
44884
44943
|
var import_node_server_utils178 = require("@7365admin1/node-server-utils");
|
|
44885
|
-
var
|
|
44944
|
+
var import_mongodb106 = require("mongodb");
|
|
44886
44945
|
function useNfcPatrolRouteRepo() {
|
|
44887
44946
|
const db = import_node_server_utils178.useAtlas.getDb();
|
|
44888
44947
|
if (!db) {
|
|
@@ -44926,7 +44985,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
44926
44985
|
}, session) {
|
|
44927
44986
|
page = page > 0 ? page - 1 : 0;
|
|
44928
44987
|
try {
|
|
44929
|
-
site = new
|
|
44988
|
+
site = new import_mongodb106.ObjectId(site);
|
|
44930
44989
|
} catch (error) {
|
|
44931
44990
|
throw new import_node_server_utils178.BadRequestError("Invalid site ID format.");
|
|
44932
44991
|
}
|
|
@@ -44997,7 +45056,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
44997
45056
|
}
|
|
44998
45057
|
async function getById(_id, isStart) {
|
|
44999
45058
|
try {
|
|
45000
|
-
_id = new
|
|
45059
|
+
_id = new import_mongodb106.ObjectId(_id);
|
|
45001
45060
|
} catch (error) {
|
|
45002
45061
|
throw new import_node_server_utils178.BadRequestError("Invalid ID.");
|
|
45003
45062
|
}
|
|
@@ -45107,18 +45166,18 @@ function useNfcPatrolRouteRepo() {
|
|
|
45107
45166
|
throw new import_node_server_utils178.BadRequestError(error.message);
|
|
45108
45167
|
}
|
|
45109
45168
|
try {
|
|
45110
|
-
_id = new
|
|
45169
|
+
_id = new import_mongodb106.ObjectId(_id);
|
|
45111
45170
|
} catch (error2) {
|
|
45112
45171
|
throw new import_node_server_utils178.BadRequestError("Invalid ID.");
|
|
45113
45172
|
}
|
|
45114
45173
|
try {
|
|
45115
|
-
value.site = new
|
|
45174
|
+
value.site = new import_mongodb106.ObjectId(value.site);
|
|
45116
45175
|
} catch (error2) {
|
|
45117
45176
|
throw new import_node_server_utils178.BadRequestError("Invalid site format");
|
|
45118
45177
|
}
|
|
45119
45178
|
if (value.updatedBy) {
|
|
45120
45179
|
try {
|
|
45121
|
-
value.updatedBy = new
|
|
45180
|
+
value.updatedBy = new import_mongodb106.ObjectId(value.updatedBy);
|
|
45122
45181
|
} catch (error2) {
|
|
45123
45182
|
throw new import_node_server_utils178.BadRequestError("Invalid createdBy format");
|
|
45124
45183
|
}
|
|
@@ -45343,7 +45402,7 @@ function useNfcPatrolRouteController() {
|
|
|
45343
45402
|
}
|
|
45344
45403
|
|
|
45345
45404
|
// src/models/incident-report.model.ts
|
|
45346
|
-
var
|
|
45405
|
+
var import_mongodb107 = require("mongodb");
|
|
45347
45406
|
var import_joi101 = __toESM(require("joi"));
|
|
45348
45407
|
var residentSchema = import_joi101.default.object({
|
|
45349
45408
|
_id: import_joi101.default.string().hex().optional().allow(null, ""),
|
|
@@ -45549,28 +45608,28 @@ var schemaUpdateIncidentReport = import_joi101.default.object({
|
|
|
45549
45608
|
function MIncidentReport(value) {
|
|
45550
45609
|
if (value._id && typeof value._id === "string") {
|
|
45551
45610
|
try {
|
|
45552
|
-
value._id = new
|
|
45611
|
+
value._id = new import_mongodb107.ObjectId(value._id);
|
|
45553
45612
|
} catch {
|
|
45554
45613
|
throw new Error("Invalid incident report ID.");
|
|
45555
45614
|
}
|
|
45556
45615
|
}
|
|
45557
45616
|
if (value.organization && typeof value.organization === "string") {
|
|
45558
45617
|
try {
|
|
45559
|
-
value.organization = new
|
|
45618
|
+
value.organization = new import_mongodb107.ObjectId(value.organization);
|
|
45560
45619
|
} catch {
|
|
45561
45620
|
throw new Error("Invalid organization ID.");
|
|
45562
45621
|
}
|
|
45563
45622
|
}
|
|
45564
45623
|
if (value.site && typeof value.site === "string") {
|
|
45565
45624
|
try {
|
|
45566
|
-
value.site = new
|
|
45625
|
+
value.site = new import_mongodb107.ObjectId(value.site);
|
|
45567
45626
|
} catch {
|
|
45568
45627
|
throw new Error("Invalid site ID.");
|
|
45569
45628
|
}
|
|
45570
45629
|
}
|
|
45571
45630
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
45572
45631
|
try {
|
|
45573
|
-
value.approvedBy = new
|
|
45632
|
+
value.approvedBy = new import_mongodb107.ObjectId(value.approvedBy);
|
|
45574
45633
|
} catch {
|
|
45575
45634
|
throw new Error("Invalid approvedBy ID.");
|
|
45576
45635
|
}
|
|
@@ -45578,7 +45637,7 @@ function MIncidentReport(value) {
|
|
|
45578
45637
|
const { incidentInformation } = value;
|
|
45579
45638
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
45580
45639
|
try {
|
|
45581
|
-
incidentInformation.siteInfo.site = new
|
|
45640
|
+
incidentInformation.siteInfo.site = new import_mongodb107.ObjectId(
|
|
45582
45641
|
incidentInformation.siteInfo.site
|
|
45583
45642
|
);
|
|
45584
45643
|
} catch {
|
|
@@ -45592,7 +45651,7 @@ function MIncidentReport(value) {
|
|
|
45592
45651
|
incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
|
|
45593
45652
|
}
|
|
45594
45653
|
return {
|
|
45595
|
-
_id: value._id ?? new
|
|
45654
|
+
_id: value._id ?? new import_mongodb107.ObjectId(),
|
|
45596
45655
|
reportId: value.reportId,
|
|
45597
45656
|
incidentInformation: value.incidentInformation,
|
|
45598
45657
|
affectedEntities: value.affectedEntities,
|
|
@@ -45617,7 +45676,7 @@ var import_node_server_utils182 = require("@7365admin1/node-server-utils");
|
|
|
45617
45676
|
|
|
45618
45677
|
// src/repositories/incident-report.repo.ts
|
|
45619
45678
|
var import_node_server_utils181 = require("@7365admin1/node-server-utils");
|
|
45620
|
-
var
|
|
45679
|
+
var import_mongodb108 = require("mongodb");
|
|
45621
45680
|
var incidents_namespace_collection = "incident-reports";
|
|
45622
45681
|
function useIncidentReportRepo() {
|
|
45623
45682
|
const db = import_node_server_utils181.useAtlas.getDb();
|
|
@@ -45684,7 +45743,7 @@ function useIncidentReportRepo() {
|
|
|
45684
45743
|
page = page > 0 ? page - 1 : 0;
|
|
45685
45744
|
let dateExpr = {};
|
|
45686
45745
|
try {
|
|
45687
|
-
site = new
|
|
45746
|
+
site = new import_mongodb108.ObjectId(site);
|
|
45688
45747
|
} catch (error) {
|
|
45689
45748
|
throw new import_node_server_utils181.BadRequestError("Invalid site ID format.");
|
|
45690
45749
|
}
|
|
@@ -45785,7 +45844,7 @@ function useIncidentReportRepo() {
|
|
|
45785
45844
|
page = page > 0 ? page - 1 : 0;
|
|
45786
45845
|
let dateExpr = {};
|
|
45787
45846
|
try {
|
|
45788
|
-
site = new
|
|
45847
|
+
site = new import_mongodb108.ObjectId(site);
|
|
45789
45848
|
} catch (error) {
|
|
45790
45849
|
throw new import_node_server_utils181.BadRequestError("Invalid site ID format.");
|
|
45791
45850
|
}
|
|
@@ -45854,7 +45913,7 @@ function useIncidentReportRepo() {
|
|
|
45854
45913
|
}
|
|
45855
45914
|
async function getIncidentReportById(_id, session) {
|
|
45856
45915
|
try {
|
|
45857
|
-
_id = new
|
|
45916
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45858
45917
|
} catch (error) {
|
|
45859
45918
|
throw new import_node_server_utils181.BadRequestError("Invalid incident report ID format.");
|
|
45860
45919
|
}
|
|
@@ -45885,27 +45944,27 @@ function useIncidentReportRepo() {
|
|
|
45885
45944
|
async function updateIncidentReportById(_id, value, session) {
|
|
45886
45945
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
45887
45946
|
try {
|
|
45888
|
-
_id = new
|
|
45947
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45889
45948
|
} catch (error) {
|
|
45890
45949
|
throw new import_node_server_utils181.BadRequestError("Invalid ID format.");
|
|
45891
45950
|
}
|
|
45892
45951
|
if (value.organization && typeof value.organization === "string") {
|
|
45893
45952
|
try {
|
|
45894
|
-
value.organization = new
|
|
45953
|
+
value.organization = new import_mongodb108.ObjectId(value.organization);
|
|
45895
45954
|
} catch {
|
|
45896
45955
|
throw new Error("Invalid organization ID.");
|
|
45897
45956
|
}
|
|
45898
45957
|
}
|
|
45899
45958
|
if (value.site && typeof value.site === "string") {
|
|
45900
45959
|
try {
|
|
45901
|
-
value.site = new
|
|
45960
|
+
value.site = new import_mongodb108.ObjectId(value.site);
|
|
45902
45961
|
} catch {
|
|
45903
45962
|
throw new Error("Invalid site ID.");
|
|
45904
45963
|
}
|
|
45905
45964
|
}
|
|
45906
45965
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
45907
45966
|
try {
|
|
45908
|
-
value.approvedBy = new
|
|
45967
|
+
value.approvedBy = new import_mongodb108.ObjectId(value.approvedBy);
|
|
45909
45968
|
} catch {
|
|
45910
45969
|
throw new Error("Invalid approvedBy ID.");
|
|
45911
45970
|
}
|
|
@@ -45913,7 +45972,7 @@ function useIncidentReportRepo() {
|
|
|
45913
45972
|
const { incidentInformation } = value;
|
|
45914
45973
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
45915
45974
|
try {
|
|
45916
|
-
incidentInformation.siteInfo.site = new
|
|
45975
|
+
incidentInformation.siteInfo.site = new import_mongodb108.ObjectId(
|
|
45917
45976
|
incidentInformation.siteInfo.site
|
|
45918
45977
|
);
|
|
45919
45978
|
} catch {
|
|
@@ -45948,7 +46007,7 @@ function useIncidentReportRepo() {
|
|
|
45948
46007
|
}
|
|
45949
46008
|
async function deleteIncidentReportById(_id) {
|
|
45950
46009
|
try {
|
|
45951
|
-
_id = new
|
|
46010
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45952
46011
|
} catch (error) {
|
|
45953
46012
|
throw new import_node_server_utils181.BadRequestError("Invalid occurrence subject ID format.");
|
|
45954
46013
|
}
|
|
@@ -45980,7 +46039,7 @@ function useIncidentReportRepo() {
|
|
|
45980
46039
|
async function reviewIncidentReport(_id, value, session) {
|
|
45981
46040
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
45982
46041
|
try {
|
|
45983
|
-
_id = new
|
|
46042
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
45984
46043
|
} catch (error) {
|
|
45985
46044
|
throw new import_node_server_utils181.BadRequestError("Invalid ID format.");
|
|
45986
46045
|
}
|
|
@@ -46473,7 +46532,7 @@ function useIncidentReportController() {
|
|
|
46473
46532
|
}
|
|
46474
46533
|
|
|
46475
46534
|
// src/models/nfc-patrol-settings.model.ts
|
|
46476
|
-
var
|
|
46535
|
+
var import_mongodb109 = require("mongodb");
|
|
46477
46536
|
var import_joi103 = __toESM(require("joi"));
|
|
46478
46537
|
var import_node_server_utils184 = require("@7365admin1/node-server-utils");
|
|
46479
46538
|
var objectId = import_joi103.default.string().hex().length(24);
|
|
@@ -46499,7 +46558,7 @@ function MNfcPatrolSettings(value) {
|
|
|
46499
46558
|
}
|
|
46500
46559
|
if (value.site) {
|
|
46501
46560
|
try {
|
|
46502
|
-
value.site = new
|
|
46561
|
+
value.site = new import_mongodb109.ObjectId(value.site);
|
|
46503
46562
|
} catch (error2) {
|
|
46504
46563
|
throw new import_node_server_utils184.BadRequestError("Invalid site ID format.");
|
|
46505
46564
|
}
|
|
@@ -46519,7 +46578,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
46519
46578
|
}
|
|
46520
46579
|
if (value.updatedBy) {
|
|
46521
46580
|
try {
|
|
46522
|
-
value.updatedBy = new
|
|
46581
|
+
value.updatedBy = new import_mongodb109.ObjectId(value.updatedBy);
|
|
46523
46582
|
} catch (error2) {
|
|
46524
46583
|
throw new import_node_server_utils184.BadRequestError("Invalid updatedBy ID format.");
|
|
46525
46584
|
}
|
|
@@ -46533,7 +46592,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
46533
46592
|
|
|
46534
46593
|
// src/repositories/nfc-patrol-settings.repository.ts
|
|
46535
46594
|
var import_node_server_utils185 = require("@7365admin1/node-server-utils");
|
|
46536
|
-
var
|
|
46595
|
+
var import_mongodb110 = require("mongodb");
|
|
46537
46596
|
function useNfcPatrolSettingsRepository() {
|
|
46538
46597
|
const db = import_node_server_utils185.useAtlas.getDb();
|
|
46539
46598
|
if (!db) {
|
|
@@ -46563,7 +46622,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
46563
46622
|
}
|
|
46564
46623
|
async function getNfcPatrolSettingsBySite(site, session) {
|
|
46565
46624
|
try {
|
|
46566
|
-
site = new
|
|
46625
|
+
site = new import_mongodb110.ObjectId(site);
|
|
46567
46626
|
} catch (error) {
|
|
46568
46627
|
throw new import_node_server_utils185.BadRequestError("Invalid nfc patrol settings site ID format.");
|
|
46569
46628
|
}
|
|
@@ -46607,7 +46666,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
46607
46666
|
}
|
|
46608
46667
|
async function updateNfcPatrolSettings(site, value, session) {
|
|
46609
46668
|
try {
|
|
46610
|
-
site = new
|
|
46669
|
+
site = new import_mongodb110.ObjectId(site);
|
|
46611
46670
|
} catch (error) {
|
|
46612
46671
|
throw new import_node_server_utils185.BadRequestError("Invalid attendance settings ID format.");
|
|
46613
46672
|
}
|
|
@@ -46772,13 +46831,13 @@ function useNfcPatrolSettingsController() {
|
|
|
46772
46831
|
|
|
46773
46832
|
// src/services/occurrence-entry.service.ts
|
|
46774
46833
|
var import_node_server_utils189 = require("@7365admin1/node-server-utils");
|
|
46775
|
-
var
|
|
46834
|
+
var import_mongodb113 = require("mongodb");
|
|
46776
46835
|
|
|
46777
46836
|
// src/repositories/occurrence-subject.repo.ts
|
|
46778
46837
|
var import_node_server_utils188 = require("@7365admin1/node-server-utils");
|
|
46779
46838
|
|
|
46780
46839
|
// src/models/occurrence-subject.model.ts
|
|
46781
|
-
var
|
|
46840
|
+
var import_mongodb111 = require("mongodb");
|
|
46782
46841
|
var import_joi105 = __toESM(require("joi"));
|
|
46783
46842
|
var SubjectSort = /* @__PURE__ */ ((SubjectSort2) => {
|
|
46784
46843
|
SubjectSort2["CREATED_AT"] = "createdAt";
|
|
@@ -46803,27 +46862,27 @@ var schemaUpdateOccurrenceSubject = import_joi105.default.object({
|
|
|
46803
46862
|
function MOccurrenceSubject(value) {
|
|
46804
46863
|
if (value._id && typeof value._id === "string") {
|
|
46805
46864
|
try {
|
|
46806
|
-
value._id = new
|
|
46865
|
+
value._id = new import_mongodb111.ObjectId(value._id);
|
|
46807
46866
|
} catch {
|
|
46808
46867
|
throw new Error("Invalid ID.");
|
|
46809
46868
|
}
|
|
46810
46869
|
}
|
|
46811
46870
|
if (value.site && typeof value.site === "string") {
|
|
46812
46871
|
try {
|
|
46813
|
-
value.site = new
|
|
46872
|
+
value.site = new import_mongodb111.ObjectId(value.site);
|
|
46814
46873
|
} catch {
|
|
46815
46874
|
throw new Error("Invalid site ID.");
|
|
46816
46875
|
}
|
|
46817
46876
|
}
|
|
46818
46877
|
if (value.addedBy && typeof value.addedBy === "string") {
|
|
46819
46878
|
try {
|
|
46820
|
-
value.addedBy = new
|
|
46879
|
+
value.addedBy = new import_mongodb111.ObjectId(value.addedBy);
|
|
46821
46880
|
} catch {
|
|
46822
46881
|
throw new Error("Invalid addedBy ID.");
|
|
46823
46882
|
}
|
|
46824
46883
|
}
|
|
46825
46884
|
return {
|
|
46826
|
-
_id: value._id ?? new
|
|
46885
|
+
_id: value._id ?? new import_mongodb111.ObjectId(),
|
|
46827
46886
|
site: value.site,
|
|
46828
46887
|
subject: value.subject,
|
|
46829
46888
|
addedBy: value.addedBy ?? "",
|
|
@@ -46834,7 +46893,7 @@ function MOccurrenceSubject(value) {
|
|
|
46834
46893
|
}
|
|
46835
46894
|
|
|
46836
46895
|
// src/repositories/occurrence-subject.repo.ts
|
|
46837
|
-
var
|
|
46896
|
+
var import_mongodb112 = require("mongodb");
|
|
46838
46897
|
function useOccurrenceSubjectRepo() {
|
|
46839
46898
|
const db = import_node_server_utils188.useAtlas.getDb();
|
|
46840
46899
|
if (!db) {
|
|
@@ -46893,7 +46952,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
46893
46952
|
}, session) {
|
|
46894
46953
|
page = page > 0 ? page - 1 : 0;
|
|
46895
46954
|
try {
|
|
46896
|
-
site = new
|
|
46955
|
+
site = new import_mongodb112.ObjectId(site);
|
|
46897
46956
|
} catch (error) {
|
|
46898
46957
|
throw new import_node_server_utils188.BadRequestError("Invalid site ID format.");
|
|
46899
46958
|
}
|
|
@@ -46986,7 +47045,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
46986
47045
|
}
|
|
46987
47046
|
async function getOccurrenceSubjectById(_id, session) {
|
|
46988
47047
|
try {
|
|
46989
|
-
_id = new
|
|
47048
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
46990
47049
|
} catch (error) {
|
|
46991
47050
|
throw new import_node_server_utils188.BadRequestError("Invalid occurrence subject ID format.");
|
|
46992
47051
|
}
|
|
@@ -47014,7 +47073,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47014
47073
|
async function updateOccurrenceSubjectById(_id, value, session) {
|
|
47015
47074
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47016
47075
|
try {
|
|
47017
|
-
_id = new
|
|
47076
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
47018
47077
|
} catch (error) {
|
|
47019
47078
|
throw new import_node_server_utils188.BadRequestError("Invalid ID format.");
|
|
47020
47079
|
}
|
|
@@ -47044,7 +47103,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
47044
47103
|
}
|
|
47045
47104
|
async function deleteOccurrenceSubjectById(_id) {
|
|
47046
47105
|
try {
|
|
47047
|
-
_id = new
|
|
47106
|
+
_id = new import_mongodb112.ObjectId(_id);
|
|
47048
47107
|
} catch (error) {
|
|
47049
47108
|
throw new import_node_server_utils188.BadRequestError("Invalid occurrence subject ID format.");
|
|
47050
47109
|
}
|
|
@@ -47175,8 +47234,8 @@ function useOccurrenceEntryService() {
|
|
|
47175
47234
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
47176
47235
|
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
47177
47236
|
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
47178
|
-
value.signature = value.signature ? new
|
|
47179
|
-
value.eSignature = value.eSignature ? new
|
|
47237
|
+
value.signature = value.signature ? new import_mongodb113.ObjectId(value.signature) : occurrenceEntry.signature._id;
|
|
47238
|
+
value.eSignature = value.eSignature ? new import_mongodb113.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
|
|
47180
47239
|
value.createdAt = /* @__PURE__ */ new Date();
|
|
47181
47240
|
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
47182
47241
|
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
@@ -47368,7 +47427,7 @@ function useOccurrenceEntryController() {
|
|
|
47368
47427
|
|
|
47369
47428
|
// src/models/online-form.model.ts
|
|
47370
47429
|
var import_joi107 = __toESM(require("joi"));
|
|
47371
|
-
var
|
|
47430
|
+
var import_mongodb114 = require("mongodb");
|
|
47372
47431
|
var schemaOnlineForm = import_joi107.default.object({
|
|
47373
47432
|
_id: import_joi107.default.string().hex().optional().allow("", null),
|
|
47374
47433
|
name: import_joi107.default.string().required(),
|
|
@@ -47416,21 +47475,21 @@ function MOnlineForm(value) {
|
|
|
47416
47475
|
}
|
|
47417
47476
|
if (value._id && typeof value._id === "string") {
|
|
47418
47477
|
try {
|
|
47419
|
-
value._id = new
|
|
47478
|
+
value._id = new import_mongodb114.ObjectId(value._id);
|
|
47420
47479
|
} catch (error2) {
|
|
47421
47480
|
throw new Error("Invalid ID.");
|
|
47422
47481
|
}
|
|
47423
47482
|
}
|
|
47424
47483
|
if (value.org && typeof value.org === "string") {
|
|
47425
47484
|
try {
|
|
47426
|
-
value.org = new
|
|
47485
|
+
value.org = new import_mongodb114.ObjectId(value.org);
|
|
47427
47486
|
} catch (error2) {
|
|
47428
47487
|
throw new Error("Invalid org ID.");
|
|
47429
47488
|
}
|
|
47430
47489
|
}
|
|
47431
47490
|
if (value.site && typeof value.site === "string") {
|
|
47432
47491
|
try {
|
|
47433
|
-
value.site = new
|
|
47492
|
+
value.site = new import_mongodb114.ObjectId(value.site);
|
|
47434
47493
|
} catch (error2) {
|
|
47435
47494
|
throw new Error("Invalid site ID.");
|
|
47436
47495
|
}
|
|
@@ -47453,7 +47512,7 @@ function MOnlineForm(value) {
|
|
|
47453
47512
|
|
|
47454
47513
|
// src/repositories/online-form.repo.ts
|
|
47455
47514
|
var import_node_server_utils191 = require("@7365admin1/node-server-utils");
|
|
47456
|
-
var
|
|
47515
|
+
var import_mongodb115 = require("mongodb");
|
|
47457
47516
|
function useOnlineFormRepo() {
|
|
47458
47517
|
const db = import_node_server_utils191.useAtlas.getDb();
|
|
47459
47518
|
if (!db) {
|
|
@@ -47505,7 +47564,7 @@ function useOnlineFormRepo() {
|
|
|
47505
47564
|
}) {
|
|
47506
47565
|
page = page > 0 ? page - 1 : 0;
|
|
47507
47566
|
try {
|
|
47508
|
-
site = new
|
|
47567
|
+
site = new import_mongodb115.ObjectId(site);
|
|
47509
47568
|
} catch (error) {
|
|
47510
47569
|
throw new import_node_server_utils191.BadRequestError("Invalid site ID format.");
|
|
47511
47570
|
}
|
|
@@ -47565,7 +47624,7 @@ function useOnlineFormRepo() {
|
|
|
47565
47624
|
}
|
|
47566
47625
|
async function getOnlineFormById(_id) {
|
|
47567
47626
|
try {
|
|
47568
|
-
_id = new
|
|
47627
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
47569
47628
|
} catch (error) {
|
|
47570
47629
|
throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
|
|
47571
47630
|
}
|
|
@@ -47608,7 +47667,7 @@ function useOnlineFormRepo() {
|
|
|
47608
47667
|
}
|
|
47609
47668
|
async function updateOnlineFormById(_id, value) {
|
|
47610
47669
|
try {
|
|
47611
|
-
_id = new
|
|
47670
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
47612
47671
|
} catch (error) {
|
|
47613
47672
|
throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
|
|
47614
47673
|
}
|
|
@@ -47636,7 +47695,7 @@ function useOnlineFormRepo() {
|
|
|
47636
47695
|
}
|
|
47637
47696
|
async function deleteOnlineFormById(_id, session) {
|
|
47638
47697
|
try {
|
|
47639
|
-
_id = new
|
|
47698
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
47640
47699
|
} catch (error) {
|
|
47641
47700
|
throw new import_node_server_utils191.BadRequestError("Invalid online form ID format.");
|
|
47642
47701
|
}
|
|
@@ -47669,7 +47728,7 @@ function useOnlineFormRepo() {
|
|
|
47669
47728
|
}
|
|
47670
47729
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
47671
47730
|
try {
|
|
47672
|
-
site = new
|
|
47731
|
+
site = new import_mongodb115.ObjectId(site);
|
|
47673
47732
|
} catch (error) {
|
|
47674
47733
|
throw new import_node_server_utils191.BadRequestError(
|
|
47675
47734
|
"Invalid online form configuration site ID format."
|
|
@@ -48101,7 +48160,7 @@ function useOccurrenceSubjectController() {
|
|
|
48101
48160
|
}
|
|
48102
48161
|
|
|
48103
48162
|
// src/models/nfc-patrol-log.model.ts
|
|
48104
|
-
var
|
|
48163
|
+
var import_mongodb116 = require("mongodb");
|
|
48105
48164
|
var import_joi110 = __toESM(require("joi"));
|
|
48106
48165
|
var import_node_server_utils195 = require("@7365admin1/node-server-utils");
|
|
48107
48166
|
var schemaNfcPatrolLog = import_joi110.default.object({
|
|
@@ -48153,32 +48212,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
48153
48212
|
}
|
|
48154
48213
|
if (value._id && typeof value._id === "string") {
|
|
48155
48214
|
try {
|
|
48156
|
-
value._id = new
|
|
48215
|
+
value._id = new import_mongodb116.ObjectId(value._id);
|
|
48157
48216
|
} catch (error2) {
|
|
48158
48217
|
throw new import_node_server_utils195.BadRequestError("Invalid _id format");
|
|
48159
48218
|
}
|
|
48160
48219
|
}
|
|
48161
48220
|
try {
|
|
48162
|
-
value.site = new
|
|
48221
|
+
value.site = new import_mongodb116.ObjectId(value.site);
|
|
48163
48222
|
} catch (error2) {
|
|
48164
48223
|
throw new import_node_server_utils195.BadRequestError("Invalid site format");
|
|
48165
48224
|
}
|
|
48166
48225
|
if (value?.createdBy) {
|
|
48167
48226
|
try {
|
|
48168
|
-
value.createdBy = new
|
|
48227
|
+
value.createdBy = new import_mongodb116.ObjectId(value.createdBy);
|
|
48169
48228
|
} catch (error2) {
|
|
48170
48229
|
throw new import_node_server_utils195.BadRequestError("Invalid createdBy format");
|
|
48171
48230
|
}
|
|
48172
48231
|
}
|
|
48173
48232
|
if (value?.route?._id) {
|
|
48174
48233
|
try {
|
|
48175
|
-
value.route._id = new
|
|
48234
|
+
value.route._id = new import_mongodb116.ObjectId(value.route._id);
|
|
48176
48235
|
} catch (error2) {
|
|
48177
48236
|
throw new import_node_server_utils195.BadRequestError("Invalid route _id format");
|
|
48178
48237
|
}
|
|
48179
48238
|
}
|
|
48180
48239
|
return {
|
|
48181
|
-
_id: value._id ?? new
|
|
48240
|
+
_id: value._id ?? new import_mongodb116.ObjectId(),
|
|
48182
48241
|
site: value.site,
|
|
48183
48242
|
route: value.route,
|
|
48184
48243
|
date: value.date,
|
|
@@ -48192,7 +48251,7 @@ function MNfcPatrolLog(valueArg) {
|
|
|
48192
48251
|
|
|
48193
48252
|
// src/repositories/nfc-patrol-log.repository.ts
|
|
48194
48253
|
var import_node_server_utils196 = require("@7365admin1/node-server-utils");
|
|
48195
|
-
var
|
|
48254
|
+
var import_mongodb117 = require("mongodb");
|
|
48196
48255
|
function useNfcPatrolLogRepo() {
|
|
48197
48256
|
const db = import_node_server_utils196.useAtlas.getDb();
|
|
48198
48257
|
if (!db) {
|
|
@@ -48245,7 +48304,7 @@ function useNfcPatrolLogRepo() {
|
|
|
48245
48304
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
48246
48305
|
let siteId;
|
|
48247
48306
|
try {
|
|
48248
|
-
siteId = typeof site === "string" ? new
|
|
48307
|
+
siteId = typeof site === "string" ? new import_mongodb117.ObjectId(site) : site;
|
|
48249
48308
|
} catch {
|
|
48250
48309
|
throw new import_node_server_utils196.BadRequestError("Invalid site ID format.");
|
|
48251
48310
|
}
|
|
@@ -48256,7 +48315,7 @@ function useNfcPatrolLogRepo() {
|
|
|
48256
48315
|
query.date = date;
|
|
48257
48316
|
}
|
|
48258
48317
|
if (route?._id) {
|
|
48259
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
48318
|
+
query["route._id"] = typeof route._id === "string" ? new import_mongodb117.ObjectId(route._id) : route._id;
|
|
48260
48319
|
}
|
|
48261
48320
|
if (route?.startTime) {
|
|
48262
48321
|
query["route.startTime"] = route.startTime;
|
|
@@ -49115,7 +49174,7 @@ function useNewDashboardController() {
|
|
|
49115
49174
|
|
|
49116
49175
|
// src/models/manpower-monitoring.model.ts
|
|
49117
49176
|
var import_joi113 = __toESM(require("joi"));
|
|
49118
|
-
var
|
|
49177
|
+
var import_mongodb118 = require("mongodb");
|
|
49119
49178
|
var shiftSchema = import_joi113.default.object({
|
|
49120
49179
|
name: import_joi113.default.string().required(),
|
|
49121
49180
|
checkIn: import_joi113.default.string().optional().allow("", null),
|
|
@@ -49140,7 +49199,7 @@ var manpowerMonitoringSchema = import_joi113.default.object({
|
|
|
49140
49199
|
});
|
|
49141
49200
|
var MManpowerMonitoring = class {
|
|
49142
49201
|
constructor(data) {
|
|
49143
|
-
this._id = new
|
|
49202
|
+
this._id = new import_mongodb118.ObjectId();
|
|
49144
49203
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
49145
49204
|
this.siteId = data.siteId || "";
|
|
49146
49205
|
this.siteName = data.siteName;
|
|
@@ -49607,7 +49666,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
49607
49666
|
};
|
|
49608
49667
|
|
|
49609
49668
|
// src/repositories/manpower-monitoring.repo.ts
|
|
49610
|
-
var
|
|
49669
|
+
var import_mongodb119 = require("mongodb");
|
|
49611
49670
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
49612
49671
|
function useManpowerMonitoringRepo() {
|
|
49613
49672
|
const db = import_node_server_utils201.useAtlas.getDb();
|
|
@@ -49642,11 +49701,11 @@ function useManpowerMonitoringRepo() {
|
|
|
49642
49701
|
try {
|
|
49643
49702
|
value = new MManpowerMonitoring(value);
|
|
49644
49703
|
if (value.createdBy)
|
|
49645
|
-
value.createdBy = new
|
|
49704
|
+
value.createdBy = new import_mongodb119.ObjectId(value.createdBy);
|
|
49646
49705
|
if (value.siteId)
|
|
49647
|
-
value.siteId = new
|
|
49706
|
+
value.siteId = new import_mongodb119.ObjectId(value.siteId);
|
|
49648
49707
|
if (value.serviceProviderId)
|
|
49649
|
-
value.serviceProviderId = new
|
|
49708
|
+
value.serviceProviderId = new import_mongodb119.ObjectId(value.serviceProviderId);
|
|
49650
49709
|
const result = await collection.insertOne(value, { session });
|
|
49651
49710
|
return result;
|
|
49652
49711
|
} catch (error) {
|
|
@@ -49687,8 +49746,8 @@ function useManpowerMonitoringRepo() {
|
|
|
49687
49746
|
}
|
|
49688
49747
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
49689
49748
|
try {
|
|
49690
|
-
_id = new
|
|
49691
|
-
serviceProviderId = new
|
|
49749
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
49750
|
+
serviceProviderId = new import_mongodb119.ObjectId(serviceProviderId);
|
|
49692
49751
|
} catch (error) {
|
|
49693
49752
|
throw new Error("Invalid Site ID format.");
|
|
49694
49753
|
}
|
|
@@ -49704,7 +49763,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49704
49763
|
}
|
|
49705
49764
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
49706
49765
|
try {
|
|
49707
|
-
_id = new
|
|
49766
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
49708
49767
|
} catch (error) {
|
|
49709
49768
|
throw new import_node_server_utils201.BadRequestError("Invalid ID format.");
|
|
49710
49769
|
}
|
|
@@ -49731,7 +49790,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49731
49790
|
for (let item of value) {
|
|
49732
49791
|
item = new MManpowerMonitoring(item);
|
|
49733
49792
|
const data = await collection.findOne({
|
|
49734
|
-
siteId: new
|
|
49793
|
+
siteId: new import_mongodb119.ObjectId(item.siteId)
|
|
49735
49794
|
});
|
|
49736
49795
|
if (data) {
|
|
49737
49796
|
let updateValue;
|
|
@@ -49756,11 +49815,11 @@ function useManpowerMonitoringRepo() {
|
|
|
49756
49815
|
}
|
|
49757
49816
|
} else {
|
|
49758
49817
|
if (item.createdBy)
|
|
49759
|
-
item.createdBy = new
|
|
49818
|
+
item.createdBy = new import_mongodb119.ObjectId(item.createdBy);
|
|
49760
49819
|
if (item.siteId)
|
|
49761
|
-
item.siteId = new
|
|
49820
|
+
item.siteId = new import_mongodb119.ObjectId(item.siteId);
|
|
49762
49821
|
if (item.serviceProviderId)
|
|
49763
|
-
item.serviceProviderId = new
|
|
49822
|
+
item.serviceProviderId = new import_mongodb119.ObjectId(item.serviceProviderId);
|
|
49764
49823
|
const result = await collection.insertOne(item);
|
|
49765
49824
|
if (result.insertedId) {
|
|
49766
49825
|
results.inserted++;
|
|
@@ -49784,7 +49843,7 @@ function useManpowerMonitoringRepo() {
|
|
|
49784
49843
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
49785
49844
|
try {
|
|
49786
49845
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
49787
|
-
_id: new
|
|
49846
|
+
_id: new import_mongodb119.ObjectId(serviceProviderId)
|
|
49788
49847
|
});
|
|
49789
49848
|
if (!serviceProvider) {
|
|
49790
49849
|
throw new Error("Service Provider not found.");
|
|
@@ -49827,7 +49886,7 @@ var import_node_server_utils202 = require("@7365admin1/node-server-utils");
|
|
|
49827
49886
|
|
|
49828
49887
|
// src/models/manpower-remarks.model.ts
|
|
49829
49888
|
var import_joi114 = __toESM(require("joi"));
|
|
49830
|
-
var
|
|
49889
|
+
var import_mongodb120 = require("mongodb");
|
|
49831
49890
|
var remarksSchema = import_joi114.default.object({
|
|
49832
49891
|
name: import_joi114.default.string().required(),
|
|
49833
49892
|
remark: import_joi114.default.object({
|
|
@@ -49851,7 +49910,7 @@ var manpowerRemarksSchema = import_joi114.default.object({
|
|
|
49851
49910
|
});
|
|
49852
49911
|
var MManpowerRemarks = class {
|
|
49853
49912
|
constructor(data) {
|
|
49854
|
-
this._id = new
|
|
49913
|
+
this._id = new import_mongodb120.ObjectId();
|
|
49855
49914
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
49856
49915
|
this.siteId = data.siteId || "";
|
|
49857
49916
|
this.siteName = data.siteName || "";
|
|
@@ -49869,7 +49928,7 @@ var MManpowerRemarks = class {
|
|
|
49869
49928
|
};
|
|
49870
49929
|
|
|
49871
49930
|
// src/repositories/manpower-remarks.repo.ts
|
|
49872
|
-
var
|
|
49931
|
+
var import_mongodb121 = require("mongodb");
|
|
49873
49932
|
var import_moment_timezone2 = __toESM(require("moment-timezone"));
|
|
49874
49933
|
function useManpowerRemarksRepo() {
|
|
49875
49934
|
const db = import_node_server_utils202.useAtlas.getDb();
|
|
@@ -49903,9 +49962,9 @@ function useManpowerRemarksRepo() {
|
|
|
49903
49962
|
try {
|
|
49904
49963
|
value = new MManpowerRemarks(value);
|
|
49905
49964
|
if (value.siteId)
|
|
49906
|
-
value.siteId = new
|
|
49965
|
+
value.siteId = new import_mongodb121.ObjectId(value.siteId);
|
|
49907
49966
|
if (value.serviceProviderId)
|
|
49908
|
-
value.serviceProviderId = new
|
|
49967
|
+
value.serviceProviderId = new import_mongodb121.ObjectId(value.serviceProviderId);
|
|
49909
49968
|
const result = await collection.insertOne(value, { session });
|
|
49910
49969
|
return result;
|
|
49911
49970
|
} catch (error) {
|
|
@@ -49925,7 +49984,7 @@ function useManpowerRemarksRepo() {
|
|
|
49925
49984
|
limit = limit || 10;
|
|
49926
49985
|
const searchQuery = {};
|
|
49927
49986
|
const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
|
|
49928
|
-
searchQuery.serviceProviderId = new
|
|
49987
|
+
searchQuery.serviceProviderId = new import_mongodb121.ObjectId(serviceProviderId);
|
|
49929
49988
|
if (search != "") {
|
|
49930
49989
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
49931
49990
|
}
|
|
@@ -49957,8 +50016,8 @@ function useManpowerRemarksRepo() {
|
|
|
49957
50016
|
}
|
|
49958
50017
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
49959
50018
|
try {
|
|
49960
|
-
_id = new
|
|
49961
|
-
serviceProviderId = new
|
|
50019
|
+
_id = new import_mongodb121.ObjectId(_id);
|
|
50020
|
+
serviceProviderId = new import_mongodb121.ObjectId(serviceProviderId);
|
|
49962
50021
|
} catch (error) {
|
|
49963
50022
|
throw new Error("Invalid Site ID format.");
|
|
49964
50023
|
}
|
|
@@ -49975,13 +50034,13 @@ function useManpowerRemarksRepo() {
|
|
|
49975
50034
|
}
|
|
49976
50035
|
async function updateManpowerRemarks(_id, value) {
|
|
49977
50036
|
try {
|
|
49978
|
-
_id = new
|
|
50037
|
+
_id = new import_mongodb121.ObjectId(_id);
|
|
49979
50038
|
} catch (error) {
|
|
49980
50039
|
throw new import_node_server_utils202.BadRequestError("Invalid ID format.");
|
|
49981
50040
|
}
|
|
49982
50041
|
try {
|
|
49983
50042
|
if (value.createdBy) {
|
|
49984
|
-
value.createdBy = new
|
|
50043
|
+
value.createdBy = new import_mongodb121.ObjectId(value.createdBy);
|
|
49985
50044
|
}
|
|
49986
50045
|
const updateValue = {
|
|
49987
50046
|
...value,
|
|
@@ -49998,7 +50057,7 @@ function useManpowerRemarksRepo() {
|
|
|
49998
50057
|
}
|
|
49999
50058
|
async function updateRemarksStatus(_id, value) {
|
|
50000
50059
|
try {
|
|
50001
|
-
_id = new
|
|
50060
|
+
_id = new import_mongodb121.ObjectId(_id);
|
|
50002
50061
|
} catch (error) {
|
|
50003
50062
|
throw new import_node_server_utils202.BadRequestError("Invalid ID format.");
|
|
50004
50063
|
}
|
|
@@ -50268,7 +50327,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
50268
50327
|
|
|
50269
50328
|
// src/models/manpower-designations.model.ts
|
|
50270
50329
|
var import_joi116 = __toESM(require("joi"));
|
|
50271
|
-
var
|
|
50330
|
+
var import_mongodb122 = require("mongodb");
|
|
50272
50331
|
var designationsSchema = import_joi116.default.object({
|
|
50273
50332
|
title: import_joi116.default.string().required(),
|
|
50274
50333
|
shifts: import_joi116.default.object({
|
|
@@ -50287,7 +50346,7 @@ var manpowerDesignationsSchema = import_joi116.default.object({
|
|
|
50287
50346
|
});
|
|
50288
50347
|
var MManpowerDesignations = class {
|
|
50289
50348
|
constructor(data) {
|
|
50290
|
-
this._id = new
|
|
50349
|
+
this._id = new import_mongodb122.ObjectId();
|
|
50291
50350
|
this.siteId = data.siteId || "";
|
|
50292
50351
|
this.siteName = data.siteName || "";
|
|
50293
50352
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -50301,7 +50360,7 @@ var MManpowerDesignations = class {
|
|
|
50301
50360
|
|
|
50302
50361
|
// src/repositories/manpower-designations.repo.ts
|
|
50303
50362
|
var import_node_server_utils205 = require("@7365admin1/node-server-utils");
|
|
50304
|
-
var
|
|
50363
|
+
var import_mongodb123 = require("mongodb");
|
|
50305
50364
|
function useManpowerDesignationRepo() {
|
|
50306
50365
|
const db = import_node_server_utils205.useAtlas.getDb();
|
|
50307
50366
|
if (!db) {
|
|
@@ -50333,11 +50392,11 @@ function useManpowerDesignationRepo() {
|
|
|
50333
50392
|
try {
|
|
50334
50393
|
value = new MManpowerDesignations(value);
|
|
50335
50394
|
if (value.createdBy)
|
|
50336
|
-
value.createdBy = new
|
|
50395
|
+
value.createdBy = new import_mongodb123.ObjectId(value.createdBy);
|
|
50337
50396
|
if (value.siteId)
|
|
50338
|
-
value.siteId = new
|
|
50397
|
+
value.siteId = new import_mongodb123.ObjectId(value.siteId);
|
|
50339
50398
|
if (value.serviceProviderId)
|
|
50340
|
-
value.serviceProviderId = new
|
|
50399
|
+
value.serviceProviderId = new import_mongodb123.ObjectId(value.serviceProviderId);
|
|
50341
50400
|
const result = await collection.insertOne(value);
|
|
50342
50401
|
return result;
|
|
50343
50402
|
} catch (error) {
|
|
@@ -50346,8 +50405,8 @@ function useManpowerDesignationRepo() {
|
|
|
50346
50405
|
}
|
|
50347
50406
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
50348
50407
|
try {
|
|
50349
|
-
_id = new
|
|
50350
|
-
serviceProviderId = new
|
|
50408
|
+
_id = new import_mongodb123.ObjectId(_id);
|
|
50409
|
+
serviceProviderId = new import_mongodb123.ObjectId(serviceProviderId);
|
|
50351
50410
|
} catch (error) {
|
|
50352
50411
|
throw new Error("Invalid Site ID format.");
|
|
50353
50412
|
}
|
|
@@ -50363,7 +50422,7 @@ function useManpowerDesignationRepo() {
|
|
|
50363
50422
|
}
|
|
50364
50423
|
async function updateManpowerDesignations(_id, value) {
|
|
50365
50424
|
try {
|
|
50366
|
-
_id = new
|
|
50425
|
+
_id = new import_mongodb123.ObjectId(_id);
|
|
50367
50426
|
} catch (error) {
|
|
50368
50427
|
throw new Error("Invalid ID format.");
|
|
50369
50428
|
}
|
|
@@ -50467,7 +50526,7 @@ function useManpowerDesignationCtrl() {
|
|
|
50467
50526
|
|
|
50468
50527
|
// src/models/overnight-parking.model.ts
|
|
50469
50528
|
var import_joi118 = __toESM(require("joi"));
|
|
50470
|
-
var
|
|
50529
|
+
var import_mongodb124 = require("mongodb");
|
|
50471
50530
|
var dayScheduleSchema = import_joi118.default.object({
|
|
50472
50531
|
isEnabled: import_joi118.default.boolean().required(),
|
|
50473
50532
|
startTime: import_joi118.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -50509,7 +50568,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
50509
50568
|
}
|
|
50510
50569
|
if (value.site && typeof value.site === "string") {
|
|
50511
50570
|
try {
|
|
50512
|
-
value.site = new
|
|
50571
|
+
value.site = new import_mongodb124.ObjectId(value.site);
|
|
50513
50572
|
} catch {
|
|
50514
50573
|
throw new Error("Invalid site ID.");
|
|
50515
50574
|
}
|
|
@@ -52114,7 +52173,7 @@ function useManpowerRemarkCtrl() {
|
|
|
52114
52173
|
|
|
52115
52174
|
// src/models/manpower-sites.model.ts
|
|
52116
52175
|
var import_joi124 = __toESM(require("joi"));
|
|
52117
|
-
var
|
|
52176
|
+
var import_mongodb125 = require("mongodb");
|
|
52118
52177
|
var manpowerSitesSchema = import_joi124.default.object({
|
|
52119
52178
|
id: import_joi124.default.string().hex().required(),
|
|
52120
52179
|
text: import_joi124.default.string().hex().optional().allow("", null),
|
|
@@ -52125,7 +52184,7 @@ var manpowerSitesSchema = import_joi124.default.object({
|
|
|
52125
52184
|
});
|
|
52126
52185
|
var MManpowerSites = class {
|
|
52127
52186
|
constructor(data) {
|
|
52128
|
-
this._id = new
|
|
52187
|
+
this._id = new import_mongodb125.ObjectId();
|
|
52129
52188
|
this.id = data.id || "";
|
|
52130
52189
|
this.text = data.text || "";
|
|
52131
52190
|
this.contractID = data.contractID || "";
|
|
@@ -52335,7 +52394,7 @@ function useManpowerSitesCtrl() {
|
|
|
52335
52394
|
|
|
52336
52395
|
// src/utils/cron.util.ts
|
|
52337
52396
|
var import_node_server_utils219 = require("@7365admin1/node-server-utils");
|
|
52338
|
-
var
|
|
52397
|
+
var import_mongodb126 = require("mongodb");
|
|
52339
52398
|
var import_moment_timezone4 = __toESM(require("moment-timezone"));
|
|
52340
52399
|
var createManpowerRemarksDaily = async () => {
|
|
52341
52400
|
const db = import_node_server_utils219.useAtlas.getDb();
|
|
@@ -52495,7 +52554,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
52495
52554
|
for (const id of updatedIds) {
|
|
52496
52555
|
const doc = await remarks.findOne({ _id: id });
|
|
52497
52556
|
const setting = await settings.findOne(
|
|
52498
|
-
{ siteId: new
|
|
52557
|
+
{ siteId: new import_mongodb126.ObjectId(doc?.siteId) },
|
|
52499
52558
|
{ projection: { emails: 1 } }
|
|
52500
52559
|
);
|
|
52501
52560
|
const payload = {
|
|
@@ -52581,7 +52640,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
52581
52640
|
for (const doc of docs) {
|
|
52582
52641
|
let shiftsToCheck = [];
|
|
52583
52642
|
const endShiftTime = await settings.findOne(
|
|
52584
|
-
{ siteId: new
|
|
52643
|
+
{ siteId: new import_mongodb126.ObjectId(doc.siteId) },
|
|
52585
52644
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
52586
52645
|
);
|
|
52587
52646
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -52687,7 +52746,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
52687
52746
|
|
|
52688
52747
|
// src/events/manpower.event.ts
|
|
52689
52748
|
var import_node_server_utils220 = require("@7365admin1/node-server-utils");
|
|
52690
|
-
var
|
|
52749
|
+
var import_mongodb127 = require("mongodb");
|
|
52691
52750
|
var import_moment_timezone5 = __toESM(require("moment-timezone"));
|
|
52692
52751
|
async function manpowerEvents(io) {
|
|
52693
52752
|
let intervalId = null;
|
|
@@ -52713,7 +52772,7 @@ async function manpowerEvents(io) {
|
|
|
52713
52772
|
}).toArray();
|
|
52714
52773
|
for (const doc of docs) {
|
|
52715
52774
|
const siteSettings = await settings.findOne(
|
|
52716
|
-
{ siteId: new
|
|
52775
|
+
{ siteId: new import_mongodb127.ObjectId(doc.siteId), enabled: true },
|
|
52717
52776
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
52718
52777
|
);
|
|
52719
52778
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -52832,11 +52891,11 @@ function genericSignature(params, secretKey) {
|
|
|
52832
52891
|
}
|
|
52833
52892
|
|
|
52834
52893
|
// src/repositories/reddot-payment.repository.ts
|
|
52835
|
-
var
|
|
52894
|
+
var import_mongodb129 = require("mongodb");
|
|
52836
52895
|
|
|
52837
52896
|
// src/models/billing-payments.model.ts
|
|
52838
52897
|
var import_node_server_utils221 = require("@7365admin1/node-server-utils");
|
|
52839
|
-
var
|
|
52898
|
+
var import_mongodb128 = require("mongodb");
|
|
52840
52899
|
var import_joi126 = __toESM(require("joi"));
|
|
52841
52900
|
var schemaBillingItems = import_joi126.default.object({
|
|
52842
52901
|
_id: import_joi126.default.string().hex().optional(),
|
|
@@ -52870,21 +52929,21 @@ function MBillingItems(value) {
|
|
|
52870
52929
|
}
|
|
52871
52930
|
if (value._id && typeof value._id === "string") {
|
|
52872
52931
|
try {
|
|
52873
|
-
value._id = new
|
|
52932
|
+
value._id = new import_mongodb128.ObjectId(value._id);
|
|
52874
52933
|
} catch {
|
|
52875
52934
|
throw new import_node_server_utils221.BadRequestError("Invalid _id format");
|
|
52876
52935
|
}
|
|
52877
52936
|
}
|
|
52878
52937
|
if (value.unitId && typeof value.unitId === "string") {
|
|
52879
52938
|
try {
|
|
52880
|
-
value.unitId = new
|
|
52939
|
+
value.unitId = new import_mongodb128.ObjectId(value.unitId);
|
|
52881
52940
|
} catch {
|
|
52882
52941
|
throw new import_node_server_utils221.BadRequestError("Invalid unitId id format");
|
|
52883
52942
|
}
|
|
52884
52943
|
}
|
|
52885
52944
|
if (value.paidBy && typeof value.paidBy === "string") {
|
|
52886
52945
|
try {
|
|
52887
|
-
value.paidBy = new
|
|
52946
|
+
value.paidBy = new import_mongodb128.ObjectId(value.paidBy);
|
|
52888
52947
|
} catch {
|
|
52889
52948
|
throw new import_node_server_utils221.BadRequestError("Invalid paidBy id format");
|
|
52890
52949
|
}
|
|
@@ -52894,7 +52953,7 @@ function MBillingItems(value) {
|
|
|
52894
52953
|
value.unitBillingItems = value.unitBillingItems.map((unitBillingItem) => {
|
|
52895
52954
|
if (typeof unitBillingItem._id === "string") {
|
|
52896
52955
|
try {
|
|
52897
|
-
unitBillingItem._id = new
|
|
52956
|
+
unitBillingItem._id = new import_mongodb128.ObjectId(unitBillingItem._id);
|
|
52898
52957
|
} catch {
|
|
52899
52958
|
throw new import_node_server_utils221.BadRequestError("Invalid unit billing id format");
|
|
52900
52959
|
}
|
|
@@ -52906,7 +52965,7 @@ function MBillingItems(value) {
|
|
|
52906
52965
|
}
|
|
52907
52966
|
}
|
|
52908
52967
|
return {
|
|
52909
|
-
_id: value._id ?? new
|
|
52968
|
+
_id: value._id ?? new import_mongodb128.ObjectId(),
|
|
52910
52969
|
unitBillingItems: value.unitBillingItems ?? [],
|
|
52911
52970
|
unitId: value.unitId ?? "",
|
|
52912
52971
|
unitOwner: value.unitOwner ?? "",
|
|
@@ -52974,7 +53033,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
52974
53033
|
const res = await paymentCollection().insertOne(payload, { session });
|
|
52975
53034
|
const unit = payload.unitId?.toString().slice(-4);
|
|
52976
53035
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date());
|
|
52977
|
-
const newId = new
|
|
53036
|
+
const newId = new import_mongodb129.ObjectId(res.insertedId).toString().slice(-6);
|
|
52978
53037
|
const referenceNumber = `${unit}${newId}${dateFormatted}`;
|
|
52979
53038
|
await paymentCollection().updateOne(
|
|
52980
53039
|
{ _id: res.insertedId },
|
|
@@ -54074,7 +54133,7 @@ var import_node_server_utils228 = require("@7365admin1/node-server-utils");
|
|
|
54074
54133
|
var import_uuid2 = require("uuid");
|
|
54075
54134
|
|
|
54076
54135
|
// src/repositories/user-v2.repo.ts
|
|
54077
|
-
var
|
|
54136
|
+
var import_mongodb130 = require("mongodb");
|
|
54078
54137
|
var import_node_server_utils227 = require("@7365admin1/node-server-utils");
|
|
54079
54138
|
function useUserRepoV2() {
|
|
54080
54139
|
const { updateFeedbackCreatedByName } = useFeedbackRepo();
|
|
@@ -54275,7 +54334,7 @@ function useUserRepoV2() {
|
|
|
54275
54334
|
}
|
|
54276
54335
|
if (organization) {
|
|
54277
54336
|
try {
|
|
54278
|
-
query.defaultOrg = new
|
|
54337
|
+
query.defaultOrg = new import_mongodb130.ObjectId(organization);
|
|
54279
54338
|
cacheOptions.organization = organization.toString();
|
|
54280
54339
|
} catch (error) {
|
|
54281
54340
|
throw new import_node_server_utils227.BadRequestError("Invalid organization ID format.");
|
|
@@ -54414,13 +54473,13 @@ function useUserRepoV2() {
|
|
|
54414
54473
|
);
|
|
54415
54474
|
}
|
|
54416
54475
|
try {
|
|
54417
|
-
_id = new
|
|
54476
|
+
_id = new import_mongodb130.ObjectId(_id);
|
|
54418
54477
|
} catch (error) {
|
|
54419
54478
|
throw new import_node_server_utils227.BadRequestError("Invalid ID.");
|
|
54420
54479
|
}
|
|
54421
54480
|
if (field === "defaultOrg") {
|
|
54422
54481
|
try {
|
|
54423
|
-
value = new
|
|
54482
|
+
value = new import_mongodb130.ObjectId(value);
|
|
54424
54483
|
} catch (error) {
|
|
54425
54484
|
throw new import_node_server_utils227.BadRequestError("Invalid organization ID.");
|
|
54426
54485
|
}
|
|
@@ -54461,7 +54520,7 @@ function useUserRepoV2() {
|
|
|
54461
54520
|
year
|
|
54462
54521
|
}, session) {
|
|
54463
54522
|
try {
|
|
54464
|
-
_id = new
|
|
54523
|
+
_id = new import_mongodb130.ObjectId(_id);
|
|
54465
54524
|
} catch (error) {
|
|
54466
54525
|
throw new import_node_server_utils227.BadRequestError("Invalid user ID format.");
|
|
54467
54526
|
}
|
|
@@ -54491,7 +54550,7 @@ function useUserRepoV2() {
|
|
|
54491
54550
|
}
|
|
54492
54551
|
async function updatePassword({ _id, password }, session) {
|
|
54493
54552
|
try {
|
|
54494
|
-
_id = new
|
|
54553
|
+
_id = new import_mongodb130.ObjectId(_id);
|
|
54495
54554
|
} catch (error) {
|
|
54496
54555
|
throw new import_node_server_utils227.BadRequestError("Invalid user ID format.");
|
|
54497
54556
|
}
|
|
@@ -55246,38 +55305,38 @@ function useUserControllerV2() {
|
|
|
55246
55305
|
|
|
55247
55306
|
// src/models/role-v2.model.ts
|
|
55248
55307
|
var import_node_server_utils232 = require("@7365admin1/node-server-utils");
|
|
55249
|
-
var
|
|
55308
|
+
var import_mongodb131 = require("mongodb");
|
|
55250
55309
|
var MRoleV2 = class {
|
|
55251
55310
|
constructor(value) {
|
|
55252
55311
|
if (typeof value._id === "string") {
|
|
55253
55312
|
try {
|
|
55254
|
-
value._id = new
|
|
55313
|
+
value._id = new import_mongodb131.ObjectId(value._id);
|
|
55255
55314
|
} catch (error) {
|
|
55256
55315
|
throw new import_node_server_utils232.BadRequestError("Invalid role-v2 ID format.");
|
|
55257
55316
|
}
|
|
55258
55317
|
}
|
|
55259
55318
|
if (typeof value.site === "string" && value.site.length === 24) {
|
|
55260
55319
|
try {
|
|
55261
|
-
value.site = new
|
|
55320
|
+
value.site = new import_mongodb131.ObjectId(value.site);
|
|
55262
55321
|
} catch (error) {
|
|
55263
55322
|
throw new import_node_server_utils232.BadRequestError("Invalid site ID format.");
|
|
55264
55323
|
}
|
|
55265
55324
|
}
|
|
55266
55325
|
if (typeof value.org === "string" && value.org.length === 24) {
|
|
55267
55326
|
try {
|
|
55268
|
-
value.org = new
|
|
55327
|
+
value.org = new import_mongodb131.ObjectId(value.org);
|
|
55269
55328
|
} catch (error) {
|
|
55270
55329
|
throw new import_node_server_utils232.BadRequestError("Invalid org ID format.");
|
|
55271
55330
|
}
|
|
55272
55331
|
}
|
|
55273
55332
|
if (value.createdBy) {
|
|
55274
55333
|
try {
|
|
55275
|
-
value.createdBy = new
|
|
55334
|
+
value.createdBy = new import_mongodb131.ObjectId(value.createdBy);
|
|
55276
55335
|
} catch (error) {
|
|
55277
55336
|
throw new import_node_server_utils232.BadRequestError("Invalid created by ID format.");
|
|
55278
55337
|
}
|
|
55279
55338
|
}
|
|
55280
|
-
this._id = value._id ?? new
|
|
55339
|
+
this._id = value._id ?? new import_mongodb131.ObjectId();
|
|
55281
55340
|
this.name = value.name ?? "";
|
|
55282
55341
|
this.permissions = value.permissions ?? [];
|
|
55283
55342
|
this.site = value.site ?? "";
|
|
@@ -55412,7 +55471,7 @@ function useRoleControllerV2() {
|
|
|
55412
55471
|
|
|
55413
55472
|
// src/models/post-preloved.model.ts
|
|
55414
55473
|
var import_joi133 = __toESM(require("joi"));
|
|
55415
|
-
var
|
|
55474
|
+
var import_mongodb132 = require("mongodb");
|
|
55416
55475
|
var PostStatus = /* @__PURE__ */ ((PostStatus2) => {
|
|
55417
55476
|
PostStatus2["PUBLISHED"] = "published";
|
|
55418
55477
|
PostStatus2["RESERVED"] = "reserved";
|
|
@@ -55468,28 +55527,28 @@ function MPost(value) {
|
|
|
55468
55527
|
}
|
|
55469
55528
|
if (value._id && typeof value._id === "string") {
|
|
55470
55529
|
try {
|
|
55471
|
-
value._id = new
|
|
55530
|
+
value._id = new import_mongodb132.ObjectId(value._id);
|
|
55472
55531
|
} catch {
|
|
55473
55532
|
throw new Error("Invalid ID.");
|
|
55474
55533
|
}
|
|
55475
55534
|
}
|
|
55476
55535
|
if (value.site && typeof value.site === "string") {
|
|
55477
55536
|
try {
|
|
55478
|
-
value.site = new
|
|
55537
|
+
value.site = new import_mongodb132.ObjectId(value.site);
|
|
55479
55538
|
} catch {
|
|
55480
55539
|
throw new Error("Invalid site ID.");
|
|
55481
55540
|
}
|
|
55482
55541
|
}
|
|
55483
55542
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
55484
55543
|
try {
|
|
55485
|
-
value.createdBy = new
|
|
55544
|
+
value.createdBy = new import_mongodb132.ObjectId(value.createdBy);
|
|
55486
55545
|
} catch {
|
|
55487
55546
|
throw new Error("Invalid createdBy ID.");
|
|
55488
55547
|
}
|
|
55489
55548
|
}
|
|
55490
55549
|
if (value.reserverId && typeof value.reserverId === "string") {
|
|
55491
55550
|
try {
|
|
55492
|
-
value.reserverId = new
|
|
55551
|
+
value.reserverId = new import_mongodb132.ObjectId(value.reserverId);
|
|
55493
55552
|
} catch {
|
|
55494
55553
|
throw new Error("Invalid reserver ID.");
|
|
55495
55554
|
}
|
|
@@ -55498,7 +55557,7 @@ function MPost(value) {
|
|
|
55498
55557
|
value.attachments = value.attachments.map((id) => {
|
|
55499
55558
|
if (typeof id === "string") {
|
|
55500
55559
|
try {
|
|
55501
|
-
return new
|
|
55560
|
+
return new import_mongodb132.ObjectId(id);
|
|
55502
55561
|
} catch {
|
|
55503
55562
|
throw new Error("Invalid attachment ID.");
|
|
55504
55563
|
}
|
|
@@ -55508,20 +55567,20 @@ function MPost(value) {
|
|
|
55508
55567
|
}
|
|
55509
55568
|
if (value.category && typeof value.category === "string") {
|
|
55510
55569
|
try {
|
|
55511
|
-
value.category = new
|
|
55570
|
+
value.category = new import_mongodb132.ObjectId(value.category);
|
|
55512
55571
|
} catch {
|
|
55513
55572
|
throw new Error("Invalid category ID.");
|
|
55514
55573
|
}
|
|
55515
55574
|
}
|
|
55516
55575
|
if (value.subcategory && typeof value.subcategory === "string") {
|
|
55517
55576
|
try {
|
|
55518
|
-
value.subcategory = new
|
|
55577
|
+
value.subcategory = new import_mongodb132.ObjectId(value.subcategory);
|
|
55519
55578
|
} catch {
|
|
55520
55579
|
throw new Error("Invalid subcategory ID.");
|
|
55521
55580
|
}
|
|
55522
55581
|
}
|
|
55523
55582
|
return {
|
|
55524
|
-
_id: value._id ?? new
|
|
55583
|
+
_id: value._id ?? new import_mongodb132.ObjectId(),
|
|
55525
55584
|
title: value.title ?? "",
|
|
55526
55585
|
description: value.description ?? "",
|
|
55527
55586
|
attachments: value.attachments ?? [],
|
|
@@ -55541,7 +55600,7 @@ function MPost(value) {
|
|
|
55541
55600
|
|
|
55542
55601
|
// src/repositories/post-preloved.repo.ts
|
|
55543
55602
|
var import_node_server_utils235 = require("@7365admin1/node-server-utils");
|
|
55544
|
-
var
|
|
55603
|
+
var import_mongodb133 = require("mongodb");
|
|
55545
55604
|
function usePostPrelovedRepo() {
|
|
55546
55605
|
const db = import_node_server_utils235.useAtlas.getDb();
|
|
55547
55606
|
if (!db) {
|
|
@@ -55605,7 +55664,7 @@ function usePostPrelovedRepo() {
|
|
|
55605
55664
|
}
|
|
55606
55665
|
async function getById(_id) {
|
|
55607
55666
|
try {
|
|
55608
|
-
_id = new
|
|
55667
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55609
55668
|
} catch {
|
|
55610
55669
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55611
55670
|
}
|
|
@@ -55638,7 +55697,7 @@ function usePostPrelovedRepo() {
|
|
|
55638
55697
|
page = page > 0 ? page - 1 : 0;
|
|
55639
55698
|
if (site) {
|
|
55640
55699
|
try {
|
|
55641
|
-
site = new
|
|
55700
|
+
site = new import_mongodb133.ObjectId(site);
|
|
55642
55701
|
} catch {
|
|
55643
55702
|
throw new import_node_server_utils235.BadRequestError("Invalid site ID format.");
|
|
55644
55703
|
}
|
|
@@ -55647,14 +55706,14 @@ function usePostPrelovedRepo() {
|
|
|
55647
55706
|
let subcategoryIds = null;
|
|
55648
55707
|
if (category && subcategory) {
|
|
55649
55708
|
try {
|
|
55650
|
-
categoryId = new
|
|
55709
|
+
categoryId = new import_mongodb133.ObjectId(category);
|
|
55651
55710
|
} catch {
|
|
55652
55711
|
throw new import_node_server_utils235.BadRequestError("Invalid category ID format.");
|
|
55653
55712
|
}
|
|
55654
55713
|
if (subcategory.length > 0) {
|
|
55655
55714
|
subcategoryIds = subcategory.map((id) => {
|
|
55656
55715
|
try {
|
|
55657
|
-
return new
|
|
55716
|
+
return new import_mongodb133.ObjectId(id);
|
|
55658
55717
|
} catch {
|
|
55659
55718
|
throw new import_node_server_utils235.BadRequestError("Invalid subcategory ID format.");
|
|
55660
55719
|
}
|
|
@@ -55679,7 +55738,7 @@ function usePostPrelovedRepo() {
|
|
|
55679
55738
|
let userObjectId = null;
|
|
55680
55739
|
if (userId) {
|
|
55681
55740
|
try {
|
|
55682
|
-
userObjectId = new
|
|
55741
|
+
userObjectId = new import_mongodb133.ObjectId(userId);
|
|
55683
55742
|
} catch {
|
|
55684
55743
|
throw new import_node_server_utils235.BadRequestError("Invalid user ID format.");
|
|
55685
55744
|
}
|
|
@@ -55728,7 +55787,7 @@ function usePostPrelovedRepo() {
|
|
|
55728
55787
|
}
|
|
55729
55788
|
async function updateById(_id, value, session) {
|
|
55730
55789
|
try {
|
|
55731
|
-
_id = new
|
|
55790
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55732
55791
|
} catch {
|
|
55733
55792
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55734
55793
|
}
|
|
@@ -55749,7 +55808,7 @@ function usePostPrelovedRepo() {
|
|
|
55749
55808
|
}
|
|
55750
55809
|
async function deleteById(_id, session) {
|
|
55751
55810
|
try {
|
|
55752
|
-
_id = new
|
|
55811
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55753
55812
|
} catch {
|
|
55754
55813
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55755
55814
|
}
|
|
@@ -55775,7 +55834,7 @@ function usePostPrelovedRepo() {
|
|
|
55775
55834
|
}
|
|
55776
55835
|
async function updateStatus(_id, status, session) {
|
|
55777
55836
|
try {
|
|
55778
|
-
_id = new
|
|
55837
|
+
_id = new import_mongodb133.ObjectId(_id);
|
|
55779
55838
|
} catch {
|
|
55780
55839
|
throw new import_node_server_utils235.BadRequestError("Invalid post ID format.");
|
|
55781
55840
|
}
|
|
@@ -55987,7 +56046,7 @@ function usePostPrelovedController() {
|
|
|
55987
56046
|
|
|
55988
56047
|
// src/models/post-favorite.model.ts
|
|
55989
56048
|
var import_joi135 = __toESM(require("joi"));
|
|
55990
|
-
var
|
|
56049
|
+
var import_mongodb134 = require("mongodb");
|
|
55991
56050
|
var schemaUpdatePostFavorite = import_joi135.default.object({
|
|
55992
56051
|
userId: import_joi135.default.string().hex().length(24).required()
|
|
55993
56052
|
});
|
|
@@ -56005,14 +56064,14 @@ function MPostFavorite(value) {
|
|
|
56005
56064
|
}
|
|
56006
56065
|
if (value._id && typeof value._id === "string") {
|
|
56007
56066
|
try {
|
|
56008
|
-
value._id = new
|
|
56067
|
+
value._id = new import_mongodb134.ObjectId(value._id);
|
|
56009
56068
|
} catch {
|
|
56010
56069
|
throw new Error("Invalid ID.");
|
|
56011
56070
|
}
|
|
56012
56071
|
}
|
|
56013
56072
|
if (value.postId && typeof value.postId === "string") {
|
|
56014
56073
|
try {
|
|
56015
|
-
value.postId = new
|
|
56074
|
+
value.postId = new import_mongodb134.ObjectId(value.postId);
|
|
56016
56075
|
} catch {
|
|
56017
56076
|
throw new Error("Invalid post ID.");
|
|
56018
56077
|
}
|
|
@@ -56021,7 +56080,7 @@ function MPostFavorite(value) {
|
|
|
56021
56080
|
value.userIds = value.userIds.map((id) => {
|
|
56022
56081
|
if (typeof id === "string") {
|
|
56023
56082
|
try {
|
|
56024
|
-
return new
|
|
56083
|
+
return new import_mongodb134.ObjectId(id);
|
|
56025
56084
|
} catch {
|
|
56026
56085
|
throw new Error("Invalid user ID.");
|
|
56027
56086
|
}
|
|
@@ -56030,7 +56089,7 @@ function MPostFavorite(value) {
|
|
|
56030
56089
|
});
|
|
56031
56090
|
}
|
|
56032
56091
|
return {
|
|
56033
|
-
_id: value._id ?? new
|
|
56092
|
+
_id: value._id ?? new import_mongodb134.ObjectId(),
|
|
56034
56093
|
postId: value.postId ?? "",
|
|
56035
56094
|
userIds: value.userIds ?? [],
|
|
56036
56095
|
createdAt: value.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -56040,7 +56099,7 @@ function MPostFavorite(value) {
|
|
|
56040
56099
|
|
|
56041
56100
|
// src/repositories/post-favorite.repo.ts
|
|
56042
56101
|
var import_node_server_utils237 = require("@7365admin1/node-server-utils");
|
|
56043
|
-
var
|
|
56102
|
+
var import_mongodb135 = require("mongodb");
|
|
56044
56103
|
function usePostFavoriteRepo() {
|
|
56045
56104
|
const db = import_node_server_utils237.useAtlas.getDb();
|
|
56046
56105
|
if (!db) {
|
|
@@ -56062,7 +56121,7 @@ function usePostFavoriteRepo() {
|
|
|
56062
56121
|
}
|
|
56063
56122
|
async function getById(_id) {
|
|
56064
56123
|
try {
|
|
56065
|
-
_id = new
|
|
56124
|
+
_id = new import_mongodb135.ObjectId(_id);
|
|
56066
56125
|
} catch {
|
|
56067
56126
|
throw new import_node_server_utils237.BadRequestError("Invalid favorite ID format.");
|
|
56068
56127
|
}
|
|
@@ -56073,13 +56132,13 @@ function usePostFavoriteRepo() {
|
|
|
56073
56132
|
}
|
|
56074
56133
|
async function updateById(_id, userId, session) {
|
|
56075
56134
|
try {
|
|
56076
|
-
_id = new
|
|
56135
|
+
_id = new import_mongodb135.ObjectId(_id);
|
|
56077
56136
|
} catch {
|
|
56078
56137
|
throw new import_node_server_utils237.BadRequestError("Invalid favorite ID format.");
|
|
56079
56138
|
}
|
|
56080
56139
|
let userObjectId;
|
|
56081
56140
|
try {
|
|
56082
|
-
userObjectId = new
|
|
56141
|
+
userObjectId = new import_mongodb135.ObjectId(userId);
|
|
56083
56142
|
} catch {
|
|
56084
56143
|
throw new import_node_server_utils237.BadRequestError("Invalid user ID format.");
|
|
56085
56144
|
}
|
|
@@ -56219,7 +56278,7 @@ function usePostFavoriteController() {
|
|
|
56219
56278
|
|
|
56220
56279
|
// src/models/category-preloved.model.ts
|
|
56221
56280
|
var import_joi137 = __toESM(require("joi"));
|
|
56222
|
-
var
|
|
56281
|
+
var import_mongodb136 = require("mongodb");
|
|
56223
56282
|
var schemaCategoryPreloved = import_joi137.default.object({
|
|
56224
56283
|
name: import_joi137.default.string().required(),
|
|
56225
56284
|
createdBy: import_joi137.default.string().hex().optional().allow("", null),
|
|
@@ -56236,14 +56295,14 @@ function MCategoryPreloved(value) {
|
|
|
56236
56295
|
}
|
|
56237
56296
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
56238
56297
|
try {
|
|
56239
|
-
value.createdBy = new
|
|
56298
|
+
value.createdBy = new import_mongodb136.ObjectId(value.createdBy);
|
|
56240
56299
|
} catch {
|
|
56241
56300
|
throw new Error("Invalid createdBy ID.");
|
|
56242
56301
|
}
|
|
56243
56302
|
}
|
|
56244
56303
|
if (value.site && typeof value.site === "string") {
|
|
56245
56304
|
try {
|
|
56246
|
-
value.site = new
|
|
56305
|
+
value.site = new import_mongodb136.ObjectId(value.site);
|
|
56247
56306
|
} catch {
|
|
56248
56307
|
throw new Error("Invalid site ID.");
|
|
56249
56308
|
}
|
|
@@ -56259,7 +56318,7 @@ function MCategoryPreloved(value) {
|
|
|
56259
56318
|
|
|
56260
56319
|
// src/repositories/category-preloved.repo.ts
|
|
56261
56320
|
var import_node_server_utils240 = require("@7365admin1/node-server-utils");
|
|
56262
|
-
var
|
|
56321
|
+
var import_mongodb137 = require("mongodb");
|
|
56263
56322
|
function useCategoryPrelovedRepo() {
|
|
56264
56323
|
const db = import_node_server_utils240.useAtlas.getDb();
|
|
56265
56324
|
if (!db) {
|
|
@@ -56273,7 +56332,7 @@ function useCategoryPrelovedRepo() {
|
|
|
56273
56332
|
} = {}) {
|
|
56274
56333
|
if (site) {
|
|
56275
56334
|
try {
|
|
56276
|
-
site = new
|
|
56335
|
+
site = new import_mongodb137.ObjectId(site);
|
|
56277
56336
|
} catch {
|
|
56278
56337
|
throw new import_node_server_utils240.BadRequestError("Invalid site ID format.");
|
|
56279
56338
|
}
|
|
@@ -56292,7 +56351,7 @@ function useCategoryPrelovedRepo() {
|
|
|
56292
56351
|
async function getById(_id) {
|
|
56293
56352
|
let objectId2;
|
|
56294
56353
|
try {
|
|
56295
|
-
objectId2 = new
|
|
56354
|
+
objectId2 = new import_mongodb137.ObjectId(_id);
|
|
56296
56355
|
} catch {
|
|
56297
56356
|
throw new import_node_server_utils240.BadRequestError("Invalid category-preloved ID format.");
|
|
56298
56357
|
}
|
|
@@ -56392,7 +56451,7 @@ function useCategoryPrelovedController() {
|
|
|
56392
56451
|
|
|
56393
56452
|
// src/models/subcategory-preloved.model.ts
|
|
56394
56453
|
var import_joi139 = __toESM(require("joi"));
|
|
56395
|
-
var
|
|
56454
|
+
var import_mongodb138 = require("mongodb");
|
|
56396
56455
|
var schemaSubcategoryPreloved = import_joi139.default.object({
|
|
56397
56456
|
name: import_joi139.default.string().required(),
|
|
56398
56457
|
createdBy: import_joi139.default.string().hex().optional().allow("", null),
|
|
@@ -56411,21 +56470,21 @@ function MSubcategoryPreloved(value) {
|
|
|
56411
56470
|
}
|
|
56412
56471
|
if (value.createdBy && typeof value.createdBy === "string") {
|
|
56413
56472
|
try {
|
|
56414
|
-
value.createdBy = new
|
|
56473
|
+
value.createdBy = new import_mongodb138.ObjectId(value.createdBy);
|
|
56415
56474
|
} catch {
|
|
56416
56475
|
throw new Error("Invalid createdBy ID.");
|
|
56417
56476
|
}
|
|
56418
56477
|
}
|
|
56419
56478
|
if (value.site && typeof value.site === "string") {
|
|
56420
56479
|
try {
|
|
56421
|
-
value.site = new
|
|
56480
|
+
value.site = new import_mongodb138.ObjectId(value.site);
|
|
56422
56481
|
} catch {
|
|
56423
56482
|
throw new Error("Invalid site ID.");
|
|
56424
56483
|
}
|
|
56425
56484
|
}
|
|
56426
56485
|
if (value.category_id && typeof value.category_id === "string") {
|
|
56427
56486
|
try {
|
|
56428
|
-
value.category_id = new
|
|
56487
|
+
value.category_id = new import_mongodb138.ObjectId(value.category_id);
|
|
56429
56488
|
} catch {
|
|
56430
56489
|
throw new Error("Invalid category ID.");
|
|
56431
56490
|
}
|
|
@@ -56442,7 +56501,7 @@ function MSubcategoryPreloved(value) {
|
|
|
56442
56501
|
|
|
56443
56502
|
// src/repositories/subcategory-preloved.repo.ts
|
|
56444
56503
|
var import_node_server_utils242 = require("@7365admin1/node-server-utils");
|
|
56445
|
-
var
|
|
56504
|
+
var import_mongodb139 = require("mongodb");
|
|
56446
56505
|
function useSubcategoryPrelovedRepo() {
|
|
56447
56506
|
const db = import_node_server_utils242.useAtlas.getDb();
|
|
56448
56507
|
if (!db) {
|
|
@@ -56457,14 +56516,14 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56457
56516
|
} = {}) {
|
|
56458
56517
|
if (site) {
|
|
56459
56518
|
try {
|
|
56460
|
-
site = new
|
|
56519
|
+
site = new import_mongodb139.ObjectId(site);
|
|
56461
56520
|
} catch {
|
|
56462
56521
|
throw new import_node_server_utils242.BadRequestError("Invalid site ID format.");
|
|
56463
56522
|
}
|
|
56464
56523
|
}
|
|
56465
56524
|
if (category_id) {
|
|
56466
56525
|
try {
|
|
56467
|
-
category_id = new
|
|
56526
|
+
category_id = new import_mongodb139.ObjectId(category_id);
|
|
56468
56527
|
} catch {
|
|
56469
56528
|
throw new import_node_server_utils242.BadRequestError("Invalid category ID format.");
|
|
56470
56529
|
}
|
|
@@ -56483,7 +56542,7 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56483
56542
|
async function getById(_id) {
|
|
56484
56543
|
let objectId2;
|
|
56485
56544
|
try {
|
|
56486
|
-
objectId2 = new
|
|
56545
|
+
objectId2 = new import_mongodb139.ObjectId(_id);
|
|
56487
56546
|
} catch {
|
|
56488
56547
|
throw new import_node_server_utils242.BadRequestError("Invalid subcategory-preloved ID format.");
|
|
56489
56548
|
}
|
|
@@ -56497,14 +56556,30 @@ function useSubcategoryPrelovedRepo() {
|
|
|
56497
56556
|
throw error;
|
|
56498
56557
|
}
|
|
56499
56558
|
}
|
|
56500
|
-
|
|
56559
|
+
async function addSubcategory(item, session) {
|
|
56560
|
+
const doc = MSubcategoryPreloved(item);
|
|
56561
|
+
try {
|
|
56562
|
+
const res = await collection.insertOne(doc, { session });
|
|
56563
|
+
return res.insertedId;
|
|
56564
|
+
} catch (error) {
|
|
56565
|
+
const isDuplicated = error.message?.includes("duplicate");
|
|
56566
|
+
if (isDuplicated)
|
|
56567
|
+
throw new import_node_server_utils242.BadRequestError("Subcategory already exists.");
|
|
56568
|
+
throw error;
|
|
56569
|
+
}
|
|
56570
|
+
}
|
|
56571
|
+
return { getAll, getById, addSubcategory };
|
|
56501
56572
|
}
|
|
56502
56573
|
|
|
56503
56574
|
// src/controllers/subcategory-preloved.controller.ts
|
|
56504
56575
|
var import_node_server_utils243 = require("@7365admin1/node-server-utils");
|
|
56505
56576
|
var import_joi140 = __toESM(require("joi"));
|
|
56506
56577
|
function useSubcategoryPrelovedController() {
|
|
56507
|
-
const {
|
|
56578
|
+
const {
|
|
56579
|
+
getAll: _getAll,
|
|
56580
|
+
getById: _getById,
|
|
56581
|
+
addSubcategory: _addSubcategory
|
|
56582
|
+
} = useSubcategoryPrelovedRepo();
|
|
56508
56583
|
async function getAll(req, res, next) {
|
|
56509
56584
|
const schema2 = import_joi140.default.object({
|
|
56510
56585
|
search: import_joi140.default.string().optional().allow("", null),
|
|
@@ -56548,12 +56623,30 @@ function useSubcategoryPrelovedController() {
|
|
|
56548
56623
|
return;
|
|
56549
56624
|
}
|
|
56550
56625
|
}
|
|
56551
|
-
|
|
56626
|
+
async function addSubcategory(req, res, next) {
|
|
56627
|
+
const { error, value } = schemaSubcategoryPreloved.validate(req.body, {
|
|
56628
|
+
abortEarly: false
|
|
56629
|
+
});
|
|
56630
|
+
if (error) {
|
|
56631
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
56632
|
+
import_node_server_utils243.logger.log({ level: "error", message: messages });
|
|
56633
|
+
next(new import_node_server_utils243.BadRequestError(messages));
|
|
56634
|
+
return;
|
|
56635
|
+
}
|
|
56636
|
+
try {
|
|
56637
|
+
const data = await _addSubcategory(value);
|
|
56638
|
+
res.status(201).json(data);
|
|
56639
|
+
} catch (error2) {
|
|
56640
|
+
import_node_server_utils243.logger.log({ level: "error", message: error2.message });
|
|
56641
|
+
next(error2);
|
|
56642
|
+
}
|
|
56643
|
+
}
|
|
56644
|
+
return { getAll, getById, addSubcategory };
|
|
56552
56645
|
}
|
|
56553
56646
|
|
|
56554
56647
|
// src/models/online-forms-v2.model.ts
|
|
56555
56648
|
var import_joi141 = __toESM(require("joi"));
|
|
56556
|
-
var
|
|
56649
|
+
var import_mongodb140 = require("mongodb");
|
|
56557
56650
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
56558
56651
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
56559
56652
|
FormEntryStatus2["INACTIVE"] = "inactive";
|
|
@@ -56608,21 +56701,21 @@ function MFormEntry(value) {
|
|
|
56608
56701
|
}
|
|
56609
56702
|
if (value._id && typeof value._id === "string") {
|
|
56610
56703
|
try {
|
|
56611
|
-
value._id = new
|
|
56704
|
+
value._id = new import_mongodb140.ObjectId(value._id);
|
|
56612
56705
|
} catch {
|
|
56613
56706
|
throw new Error("Invalid ID.");
|
|
56614
56707
|
}
|
|
56615
56708
|
}
|
|
56616
56709
|
if (value.org && typeof value.org === "string") {
|
|
56617
56710
|
try {
|
|
56618
|
-
value.org = new
|
|
56711
|
+
value.org = new import_mongodb140.ObjectId(value.org);
|
|
56619
56712
|
} catch {
|
|
56620
56713
|
throw new Error("Invalid org ID.");
|
|
56621
56714
|
}
|
|
56622
56715
|
}
|
|
56623
56716
|
if (value.site && typeof value.site === "string") {
|
|
56624
56717
|
try {
|
|
56625
|
-
value.site = new
|
|
56718
|
+
value.site = new import_mongodb140.ObjectId(value.site);
|
|
56626
56719
|
} catch {
|
|
56627
56720
|
throw new Error("Invalid site ID.");
|
|
56628
56721
|
}
|