@7365admin1/core 2.33.0 → 2.35.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 +23 -3
- package/dist/index.js +591 -190
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +635 -234
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -175,6 +175,7 @@ __export(src_exports, {
|
|
|
175
175
|
remarksSchema: () => remarksSchema,
|
|
176
176
|
robotSchema: () => robotSchema,
|
|
177
177
|
schema: () => schema,
|
|
178
|
+
schemaApprovedBy: () => schemaApprovedBy,
|
|
178
179
|
schemaBilling: () => schemaBilling,
|
|
179
180
|
schemaBillingConfiguration: () => schemaBillingConfiguration,
|
|
180
181
|
schemaBillingItem: () => schemaBillingItem,
|
|
@@ -2604,20 +2605,9 @@ function useUserRepo() {
|
|
|
2604
2605
|
}
|
|
2605
2606
|
async function getUserByEmail(email) {
|
|
2606
2607
|
try {
|
|
2607
|
-
const cacheKey = (0, import_node_server_utils10.makeCacheKey)(namespace_collection, { email });
|
|
2608
|
-
const cachedData = await getCache(cacheKey);
|
|
2609
|
-
if (cachedData) {
|
|
2610
|
-
import_node_server_utils10.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
2611
|
-
return cachedData;
|
|
2612
|
-
}
|
|
2613
2608
|
const data = await collection.findOne({
|
|
2614
2609
|
email: { $regex: `^${email}$`, $options: "i" }
|
|
2615
2610
|
});
|
|
2616
|
-
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
2617
|
-
import_node_server_utils10.logger.info(`Cache set for key: ${cacheKey}`);
|
|
2618
|
-
}).catch((err) => {
|
|
2619
|
-
import_node_server_utils10.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
2620
|
-
});
|
|
2621
2611
|
return data;
|
|
2622
2612
|
} catch (error) {
|
|
2623
2613
|
throw new import_node_server_utils10.InternalServerError("Failed to get user by email.");
|
|
@@ -2924,6 +2914,39 @@ function useUserRepo() {
|
|
|
2924
2914
|
throw new import_node_server_utils10.InternalServerError("Failed to update user password.");
|
|
2925
2915
|
}
|
|
2926
2916
|
}
|
|
2917
|
+
async function resetPassword({
|
|
2918
|
+
_id,
|
|
2919
|
+
password,
|
|
2920
|
+
sid
|
|
2921
|
+
}, session) {
|
|
2922
|
+
try {
|
|
2923
|
+
_id = new import_mongodb9.ObjectId(_id);
|
|
2924
|
+
} catch (error) {
|
|
2925
|
+
throw new import_node_server_utils10.BadRequestError("Invalid user ID format.");
|
|
2926
|
+
}
|
|
2927
|
+
try {
|
|
2928
|
+
const result = await collection.updateOne(
|
|
2929
|
+
{ _id },
|
|
2930
|
+
{ $set: { password, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
2931
|
+
{ session }
|
|
2932
|
+
);
|
|
2933
|
+
const cacheKey = (0, import_node_server_utils10.makeCacheKey)(namespace_collection, { _id });
|
|
2934
|
+
delCache(cacheKey).then(() => {
|
|
2935
|
+
import_node_server_utils10.logger.info(`Cache deleted for key: ${cacheKey}`);
|
|
2936
|
+
}).catch((err) => {
|
|
2937
|
+
import_node_server_utils10.logger.error(`Failed to delete cache for key: ${cacheKey}`, err);
|
|
2938
|
+
});
|
|
2939
|
+
const authCacheKey = `sid:${sid}`;
|
|
2940
|
+
delCache(authCacheKey).then(() => {
|
|
2941
|
+
import_node_server_utils10.logger.info(`Cache deleted for key: ${authCacheKey}`);
|
|
2942
|
+
}).catch((err) => {
|
|
2943
|
+
import_node_server_utils10.logger.error(`Failed to delete cache for key: ${authCacheKey}`, err);
|
|
2944
|
+
});
|
|
2945
|
+
return result;
|
|
2946
|
+
} catch (error) {
|
|
2947
|
+
throw new import_node_server_utils10.InternalServerError("Failed to update user password.");
|
|
2948
|
+
}
|
|
2949
|
+
}
|
|
2927
2950
|
async function updateBirthday({
|
|
2928
2951
|
_id,
|
|
2929
2952
|
month,
|
|
@@ -3016,6 +3039,19 @@ function useUserRepo() {
|
|
|
3016
3039
|
throw new import_node_server_utils10.InternalServerError(`Failed to update user ${field}.`);
|
|
3017
3040
|
}
|
|
3018
3041
|
}
|
|
3042
|
+
async function updateUserSIDById(id, sid, session) {
|
|
3043
|
+
const _id = (0, import_node_server_utils10.toObjectId)(id);
|
|
3044
|
+
try {
|
|
3045
|
+
const result = await collection.updateOne(
|
|
3046
|
+
{ _id },
|
|
3047
|
+
{ $set: { sid, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
3048
|
+
{ session }
|
|
3049
|
+
);
|
|
3050
|
+
return result;
|
|
3051
|
+
} catch (error) {
|
|
3052
|
+
throw new import_node_server_utils10.InternalServerError("Failed to update user.");
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3019
3055
|
return {
|
|
3020
3056
|
createIndex,
|
|
3021
3057
|
createTextIndex,
|
|
@@ -3031,7 +3067,9 @@ function useUserRepo() {
|
|
|
3031
3067
|
updateBirthday,
|
|
3032
3068
|
updateUserFieldById,
|
|
3033
3069
|
updateDefaultOrgByEmail,
|
|
3034
|
-
getUserByEmailStatus
|
|
3070
|
+
getUserByEmailStatus,
|
|
3071
|
+
updateUserSIDById,
|
|
3072
|
+
resetPassword
|
|
3035
3073
|
};
|
|
3036
3074
|
}
|
|
3037
3075
|
|
|
@@ -3859,7 +3897,11 @@ function useMemberRepo() {
|
|
|
3859
3897
|
|
|
3860
3898
|
// src/services/auth.service.ts
|
|
3861
3899
|
function useAuthService() {
|
|
3862
|
-
const {
|
|
3900
|
+
const {
|
|
3901
|
+
getUserByEmail,
|
|
3902
|
+
getUserById: _getUserById,
|
|
3903
|
+
updateUserSIDById: _updateUserSIDById
|
|
3904
|
+
} = useUserRepo();
|
|
3863
3905
|
const { getByToken, deleteByToken } = useSessionRepo();
|
|
3864
3906
|
const expiresIn = "15m";
|
|
3865
3907
|
const { setCache, delCache } = (0, import_node_server_utils13.useCache)("sessions");
|
|
@@ -3897,7 +3939,9 @@ function useAuthService() {
|
|
|
3897
3939
|
}
|
|
3898
3940
|
const sid = (0, import_uuid.v4)();
|
|
3899
3941
|
const cacheKey = `sid:${sid}`;
|
|
3900
|
-
|
|
3942
|
+
await _updateUserSIDById(user._id, sid);
|
|
3943
|
+
const updatedUser = await _getUserById(user._id);
|
|
3944
|
+
setCache(cacheKey, updatedUser, 14400).then(() => {
|
|
3901
3945
|
console.log("Session ID cached successfully");
|
|
3902
3946
|
}).catch((error) => {
|
|
3903
3947
|
console.error("Error caching session ID:", error);
|
|
@@ -5866,6 +5910,7 @@ function useRoleRepo() {
|
|
|
5866
5910
|
}).catch((err) => {
|
|
5867
5911
|
import_node_server_utils22.logger.error(`Failed to clear cache for namespace: dashboard`, err);
|
|
5868
5912
|
});
|
|
5913
|
+
return "Successfully deleted role permission.";
|
|
5869
5914
|
} catch (error) {
|
|
5870
5915
|
throw new import_node_server_utils22.InternalServerError("Failed to delete role.");
|
|
5871
5916
|
}
|
|
@@ -6061,7 +6106,8 @@ function useUserService() {
|
|
|
6061
6106
|
getUserById,
|
|
6062
6107
|
getUserByEmail,
|
|
6063
6108
|
updatePassword,
|
|
6064
|
-
updateUserFieldById: _updateUserFieldById
|
|
6109
|
+
updateUserFieldById: _updateUserFieldById,
|
|
6110
|
+
resetPassword: _resetPassword
|
|
6065
6111
|
} = useUserRepo();
|
|
6066
6112
|
const { getRoleByName, addRole } = useRoleRepo();
|
|
6067
6113
|
const { add: addMember } = useMemberRepo();
|
|
@@ -6237,8 +6283,12 @@ function useUserService() {
|
|
|
6237
6283
|
throw new import_node_server_utils24.InternalServerError("Invalid user ID.");
|
|
6238
6284
|
}
|
|
6239
6285
|
await updateStatusById(id, "complete", session);
|
|
6240
|
-
await
|
|
6241
|
-
{
|
|
6286
|
+
await _resetPassword(
|
|
6287
|
+
{
|
|
6288
|
+
_id: user._id.toString(),
|
|
6289
|
+
password: hashedPassword,
|
|
6290
|
+
sid: user.sid
|
|
6291
|
+
},
|
|
6242
6292
|
session
|
|
6243
6293
|
);
|
|
6244
6294
|
await session?.commitTransaction();
|
|
@@ -8922,7 +8972,7 @@ var import_node_server_utils42 = require("@7365admin1/node-server-utils");
|
|
|
8922
8972
|
var import_zod = require("zod");
|
|
8923
8973
|
var import_mongodb26 = require("mongodb");
|
|
8924
8974
|
var import_node_server_utils41 = require("@7365admin1/node-server-utils");
|
|
8925
|
-
function
|
|
8975
|
+
function toObjectId4(value) {
|
|
8926
8976
|
if (typeof value === "string") {
|
|
8927
8977
|
if (!/^[a-fA-F0-9]{24}$/.test(value)) {
|
|
8928
8978
|
throw new import_node_server_utils41.BadRequestError(`Invalid ObjectId format: ${value}`);
|
|
@@ -8974,7 +9024,7 @@ var TInvoice = import_zod.z.object({
|
|
|
8974
9024
|
message: "Invalid ObjectId: Must be a 24-character hex string."
|
|
8975
9025
|
}),
|
|
8976
9026
|
import_zod.z.instanceof(import_mongodb26.ObjectId, { message: "Invalid ObjectId instance." })
|
|
8977
|
-
]).optional().transform((val) => val ?
|
|
9027
|
+
]).optional().transform((val) => val ? toObjectId4(val) : void 0),
|
|
8978
9028
|
invoiceNumber: import_zod.z.string({ required_error: "Invoice number is required." }),
|
|
8979
9029
|
type: TInvoiceType.default("other"),
|
|
8980
9030
|
amount: import_zod.z.number().min(0, { message: "Invoice amount must be at least 0." }),
|
|
@@ -19418,16 +19468,30 @@ function useCustomerSiteRepo() {
|
|
|
19418
19468
|
return cachedData;
|
|
19419
19469
|
}
|
|
19420
19470
|
try {
|
|
19471
|
+
const distinctPipeline = [
|
|
19472
|
+
{ $match: query },
|
|
19473
|
+
{ $sort: sort },
|
|
19474
|
+
{ $group: { _id: { name: "$name", site: "$site" }, doc: { $first: "$$ROOT" } } },
|
|
19475
|
+
{ $replaceRoot: { newRoot: "$doc" } },
|
|
19476
|
+
{ $sort: sort }
|
|
19477
|
+
];
|
|
19421
19478
|
const items = await collection.aggregate(
|
|
19422
19479
|
[
|
|
19423
|
-
|
|
19424
|
-
{ $sort: sort },
|
|
19480
|
+
...distinctPipeline,
|
|
19425
19481
|
{ $skip: page * limit },
|
|
19426
19482
|
{ $limit: limit }
|
|
19427
19483
|
],
|
|
19428
19484
|
{ session }
|
|
19429
19485
|
).toArray();
|
|
19430
|
-
const
|
|
19486
|
+
const countResult = await collection.aggregate(
|
|
19487
|
+
[
|
|
19488
|
+
{ $match: query },
|
|
19489
|
+
{ $group: { _id: { name: "$name", site: "$site" } } },
|
|
19490
|
+
{ $count: "total" }
|
|
19491
|
+
],
|
|
19492
|
+
{ session }
|
|
19493
|
+
).toArray();
|
|
19494
|
+
const length = countResult[0]?.total ?? 0;
|
|
19431
19495
|
const data = (0, import_node_server_utils89.paginate)(items, page, limit, length);
|
|
19432
19496
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
19433
19497
|
import_node_server_utils89.logger.info(`Cache set for key: ${cacheKey}`);
|
|
@@ -21512,7 +21576,8 @@ var KeyRepo = class {
|
|
|
21512
21576
|
location: 1,
|
|
21513
21577
|
prefix: 1,
|
|
21514
21578
|
keyNo: 1,
|
|
21515
|
-
parentId: 1
|
|
21579
|
+
parentId: 1,
|
|
21580
|
+
status: 1
|
|
21516
21581
|
}
|
|
21517
21582
|
}
|
|
21518
21583
|
]).toArray();
|
|
@@ -21755,7 +21820,8 @@ function useVisitorTransactionService() {
|
|
|
21755
21820
|
add: _add,
|
|
21756
21821
|
updateById: _updateVisitorTansactionById,
|
|
21757
21822
|
getExpiredCheckedOutTransactionsBySite: _getExpiredCheckedOutTransactionsBySite,
|
|
21758
|
-
updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus
|
|
21823
|
+
updateManyDahuaSyncStatus: _updateManyDahuaSyncStatus,
|
|
21824
|
+
getVisitorTransactionById: _getVisitorTransactionById
|
|
21759
21825
|
} = useVisitorTransactionRepo();
|
|
21760
21826
|
const { getById } = useBuildingUnitRepo();
|
|
21761
21827
|
const {
|
|
@@ -21774,6 +21840,70 @@ function useVisitorTransactionService() {
|
|
|
21774
21840
|
const { getAllSites: _getAllSites } = useSiteRepo();
|
|
21775
21841
|
const { getByUserId: _getByUserId } = usePersonRepo();
|
|
21776
21842
|
const { add: addVehicle } = useVehicleRepo();
|
|
21843
|
+
function extractKeyId(item) {
|
|
21844
|
+
if (!item)
|
|
21845
|
+
return null;
|
|
21846
|
+
if (typeof item === "string") {
|
|
21847
|
+
return import_mongodb58.ObjectId.isValid(item) ? item : null;
|
|
21848
|
+
}
|
|
21849
|
+
if (typeof item === "object" && item !== null) {
|
|
21850
|
+
if ("keyId" in item) {
|
|
21851
|
+
const keyId = String(item.keyId);
|
|
21852
|
+
return import_mongodb58.ObjectId.isValid(keyId) ? keyId : null;
|
|
21853
|
+
}
|
|
21854
|
+
const value = String(item);
|
|
21855
|
+
return import_mongodb58.ObjectId.isValid(value) ? value : null;
|
|
21856
|
+
}
|
|
21857
|
+
return null;
|
|
21858
|
+
}
|
|
21859
|
+
function normalizeKeyRefs(items) {
|
|
21860
|
+
if (!Array.isArray(items))
|
|
21861
|
+
return [];
|
|
21862
|
+
const seen = /* @__PURE__ */ new Set();
|
|
21863
|
+
const normalized = [];
|
|
21864
|
+
for (const item of items) {
|
|
21865
|
+
const keyId = extractKeyId(item);
|
|
21866
|
+
if (!keyId || seen.has(keyId))
|
|
21867
|
+
continue;
|
|
21868
|
+
seen.add(keyId);
|
|
21869
|
+
normalized.push({ keyId: new import_mongodb58.ObjectId(keyId) });
|
|
21870
|
+
}
|
|
21871
|
+
return normalized;
|
|
21872
|
+
}
|
|
21873
|
+
async function syncTransactionKeys({
|
|
21874
|
+
current,
|
|
21875
|
+
incoming,
|
|
21876
|
+
site,
|
|
21877
|
+
session
|
|
21878
|
+
}) {
|
|
21879
|
+
const currentIds = current.map((item) => item.keyId.toString());
|
|
21880
|
+
const incomingIds = incoming.map((item) => item.keyId.toString());
|
|
21881
|
+
const currentSet = new Set(currentIds);
|
|
21882
|
+
const incomingSet = new Set(incomingIds);
|
|
21883
|
+
const removedIds = currentIds.filter((id) => !incomingSet.has(id));
|
|
21884
|
+
const addedIds = incomingIds.filter((id) => !currentSet.has(id));
|
|
21885
|
+
for (const keyId of removedIds) {
|
|
21886
|
+
const existingKey = await KeyRepo.getById(keyId);
|
|
21887
|
+
if (!existingKey)
|
|
21888
|
+
continue;
|
|
21889
|
+
if (existingKey.status === "In Use" /* IN_USE */) {
|
|
21890
|
+
await KeyRepo.updateKeyById(
|
|
21891
|
+
keyId,
|
|
21892
|
+
{ status: "Available" /* AVAILABLE */ },
|
|
21893
|
+
site,
|
|
21894
|
+
session
|
|
21895
|
+
);
|
|
21896
|
+
}
|
|
21897
|
+
}
|
|
21898
|
+
for (const keyId of addedIds) {
|
|
21899
|
+
await KeyRepo.updateKeyById(
|
|
21900
|
+
keyId,
|
|
21901
|
+
{ status: "In Use" /* IN_USE */ },
|
|
21902
|
+
site,
|
|
21903
|
+
session
|
|
21904
|
+
);
|
|
21905
|
+
}
|
|
21906
|
+
}
|
|
21777
21907
|
async function add(value) {
|
|
21778
21908
|
const session = import_node_server_utils101.useAtlas.getClient()?.startSession();
|
|
21779
21909
|
const allowedPersonTypes = [
|
|
@@ -22018,7 +22148,7 @@ function useVisitorTransactionService() {
|
|
|
22018
22148
|
session?.endSession();
|
|
22019
22149
|
}
|
|
22020
22150
|
}
|
|
22021
|
-
async function
|
|
22151
|
+
async function updateVisitorTransactionById(id, value) {
|
|
22022
22152
|
const session = import_node_server_utils101.useAtlas.getClient()?.startSession();
|
|
22023
22153
|
session?.startTransaction();
|
|
22024
22154
|
try {
|
|
@@ -22194,18 +22324,70 @@ function useVisitorTransactionService() {
|
|
|
22194
22324
|
await session?.commitTransaction();
|
|
22195
22325
|
return result;
|
|
22196
22326
|
} catch (error) {
|
|
22197
|
-
import_node_server_utils101.logger.error("Error in
|
|
22327
|
+
import_node_server_utils101.logger.error("Error in visitor transaction invite visitor:", error);
|
|
22198
22328
|
await session.abortTransaction();
|
|
22199
22329
|
throw error;
|
|
22200
22330
|
} finally {
|
|
22201
22331
|
session?.endSession();
|
|
22202
22332
|
}
|
|
22203
22333
|
}
|
|
22334
|
+
async function changeVisitorTransactionKeysById(id, visitorPass, passKeys) {
|
|
22335
|
+
const session = import_node_server_utils101.useAtlas.getClient()?.startSession();
|
|
22336
|
+
if (!session) {
|
|
22337
|
+
throw new Error(
|
|
22338
|
+
"Unable to start session for visitor transaction service."
|
|
22339
|
+
);
|
|
22340
|
+
}
|
|
22341
|
+
try {
|
|
22342
|
+
session.startTransaction();
|
|
22343
|
+
const visitorTransaction = await _getVisitorTransactionById(id);
|
|
22344
|
+
if (!visitorTransaction) {
|
|
22345
|
+
throw new Error("Visitor transaction not found.");
|
|
22346
|
+
}
|
|
22347
|
+
const updatePayload = {};
|
|
22348
|
+
if (visitorPass !== void 0) {
|
|
22349
|
+
const currentVisitorPass = normalizeKeyRefs(
|
|
22350
|
+
visitorTransaction.visitorPass
|
|
22351
|
+
);
|
|
22352
|
+
const incomingVisitorPass = normalizeKeyRefs(visitorPass);
|
|
22353
|
+
await syncTransactionKeys({
|
|
22354
|
+
current: currentVisitorPass,
|
|
22355
|
+
incoming: incomingVisitorPass,
|
|
22356
|
+
site: visitorTransaction.site,
|
|
22357
|
+
session
|
|
22358
|
+
});
|
|
22359
|
+
updatePayload.visitorPass = incomingVisitorPass;
|
|
22360
|
+
}
|
|
22361
|
+
if (passKeys !== void 0) {
|
|
22362
|
+
const currentPassKeys = normalizeKeyRefs(visitorTransaction.passKeys);
|
|
22363
|
+
const incomingPassKeys = normalizeKeyRefs(passKeys);
|
|
22364
|
+
await syncTransactionKeys({
|
|
22365
|
+
current: currentPassKeys,
|
|
22366
|
+
incoming: incomingPassKeys,
|
|
22367
|
+
site: visitorTransaction.site,
|
|
22368
|
+
session
|
|
22369
|
+
});
|
|
22370
|
+
updatePayload.passKeys = incomingPassKeys;
|
|
22371
|
+
}
|
|
22372
|
+
if (Object.keys(updatePayload).length > 0) {
|
|
22373
|
+
await _updateVisitorTansactionById(id, updatePayload, session);
|
|
22374
|
+
}
|
|
22375
|
+
await session.commitTransaction();
|
|
22376
|
+
return "Successfully changed visitor transaction keys.";
|
|
22377
|
+
} catch (error) {
|
|
22378
|
+
await session.abortTransaction();
|
|
22379
|
+
import_node_server_utils101.logger.error("Error in visitor transaction change keys by id:", error);
|
|
22380
|
+
throw error;
|
|
22381
|
+
} finally {
|
|
22382
|
+
session.endSession();
|
|
22383
|
+
}
|
|
22384
|
+
}
|
|
22204
22385
|
return {
|
|
22205
22386
|
add,
|
|
22206
|
-
|
|
22387
|
+
updateVisitorTransactionById,
|
|
22207
22388
|
processTransactionDahuaStatus,
|
|
22208
|
-
inviteVisitor
|
|
22389
|
+
inviteVisitor,
|
|
22390
|
+
changeVisitorTransactionKeysById
|
|
22209
22391
|
};
|
|
22210
22392
|
}
|
|
22211
22393
|
|
|
@@ -22215,8 +22397,9 @@ var import_node_server_utils102 = require("@7365admin1/node-server-utils");
|
|
|
22215
22397
|
function useVisitorTransactionController() {
|
|
22216
22398
|
const {
|
|
22217
22399
|
add: _add,
|
|
22218
|
-
|
|
22219
|
-
inviteVisitor: _inviteVisitor
|
|
22400
|
+
updateVisitorTransactionById: _updateVisitorTransactionById,
|
|
22401
|
+
inviteVisitor: _inviteVisitor,
|
|
22402
|
+
changeVisitorTransactionKeysById: _changeVisitorTransactionKeysById
|
|
22220
22403
|
} = useVisitorTransactionService();
|
|
22221
22404
|
const {
|
|
22222
22405
|
getAll: _getAll,
|
|
@@ -22358,7 +22541,7 @@ function useVisitorTransactionController() {
|
|
|
22358
22541
|
return;
|
|
22359
22542
|
}
|
|
22360
22543
|
try {
|
|
22361
|
-
await
|
|
22544
|
+
await _updateVisitorTransactionById(_id, req.body);
|
|
22362
22545
|
res.status(200).json({ message: "Successfully updated visitor transaction." });
|
|
22363
22546
|
return;
|
|
22364
22547
|
} catch (error2) {
|
|
@@ -22412,8 +22595,31 @@ function useVisitorTransactionController() {
|
|
|
22412
22595
|
next(new import_node_server_utils102.BadRequestError(messages));
|
|
22413
22596
|
return;
|
|
22414
22597
|
}
|
|
22415
|
-
const {
|
|
22416
|
-
|
|
22598
|
+
const {
|
|
22599
|
+
expectedCheckIn,
|
|
22600
|
+
arrivalTime,
|
|
22601
|
+
duration,
|
|
22602
|
+
name,
|
|
22603
|
+
contact,
|
|
22604
|
+
email,
|
|
22605
|
+
plateNumber,
|
|
22606
|
+
isOvernightParking,
|
|
22607
|
+
numberOfPassengers,
|
|
22608
|
+
purpose,
|
|
22609
|
+
inviterUserId
|
|
22610
|
+
} = value;
|
|
22611
|
+
const rest = {
|
|
22612
|
+
expectedCheckIn,
|
|
22613
|
+
arrivalTime,
|
|
22614
|
+
duration,
|
|
22615
|
+
name,
|
|
22616
|
+
contact,
|
|
22617
|
+
email,
|
|
22618
|
+
plateNumber,
|
|
22619
|
+
isOvernightParking,
|
|
22620
|
+
numberOfPassengers,
|
|
22621
|
+
purpose
|
|
22622
|
+
};
|
|
22417
22623
|
try {
|
|
22418
22624
|
const result = await _inviteVisitor(rest, inviterUserId);
|
|
22419
22625
|
res.status(200).json({ insertedId: result });
|
|
@@ -22424,13 +22630,61 @@ function useVisitorTransactionController() {
|
|
|
22424
22630
|
return;
|
|
22425
22631
|
}
|
|
22426
22632
|
}
|
|
22633
|
+
async function changeVisitorTransactionKeysById(req, res, next) {
|
|
22634
|
+
const idValidation = import_joi55.default.string().hex().length(24).required();
|
|
22635
|
+
const bodyValidation = import_joi55.default.object({
|
|
22636
|
+
visitorPass: import_joi55.default.array().items(
|
|
22637
|
+
import_joi55.default.object({
|
|
22638
|
+
keyId: import_joi55.default.string().hex().length(24).required()
|
|
22639
|
+
})
|
|
22640
|
+
).optional(),
|
|
22641
|
+
passKeys: import_joi55.default.array().items(
|
|
22642
|
+
import_joi55.default.object({
|
|
22643
|
+
keyId: import_joi55.default.string().hex().length(24).required()
|
|
22644
|
+
})
|
|
22645
|
+
).optional()
|
|
22646
|
+
}).or("visitorPass", "passKeys");
|
|
22647
|
+
const _id = req.params.id;
|
|
22648
|
+
const { error: idError } = idValidation.validate(_id);
|
|
22649
|
+
if (idError) {
|
|
22650
|
+
import_node_server_utils102.logger.log({ level: "error", message: idError.message });
|
|
22651
|
+
next(new import_node_server_utils102.BadRequestError(idError.message));
|
|
22652
|
+
return;
|
|
22653
|
+
}
|
|
22654
|
+
const { error, value } = bodyValidation.validate(req.body, {
|
|
22655
|
+
abortEarly: false
|
|
22656
|
+
});
|
|
22657
|
+
if (error) {
|
|
22658
|
+
const message = error.details.map((d) => d.message).join(", ");
|
|
22659
|
+
import_node_server_utils102.logger.log({ level: "error", message });
|
|
22660
|
+
next(new import_node_server_utils102.BadRequestError(message));
|
|
22661
|
+
return;
|
|
22662
|
+
}
|
|
22663
|
+
try {
|
|
22664
|
+
const { visitorPass, passKeys } = value;
|
|
22665
|
+
const result = await _changeVisitorTransactionKeysById(
|
|
22666
|
+
_id,
|
|
22667
|
+
visitorPass,
|
|
22668
|
+
passKeys
|
|
22669
|
+
);
|
|
22670
|
+
res.status(200).json({
|
|
22671
|
+
message: result || "Successfully changed visitor transaction keys."
|
|
22672
|
+
});
|
|
22673
|
+
return;
|
|
22674
|
+
} catch (error2) {
|
|
22675
|
+
import_node_server_utils102.logger.log({ level: "error", message: error2.message });
|
|
22676
|
+
next(error2);
|
|
22677
|
+
return;
|
|
22678
|
+
}
|
|
22679
|
+
}
|
|
22427
22680
|
return {
|
|
22428
22681
|
add,
|
|
22429
22682
|
getAll,
|
|
22430
22683
|
updateVisitorTansactionById,
|
|
22431
22684
|
deleteVisitorTransaction,
|
|
22432
22685
|
inviteVisitor,
|
|
22433
|
-
getVisitorTransactionById
|
|
22686
|
+
getVisitorTransactionById,
|
|
22687
|
+
changeVisitorTransactionKeysById
|
|
22434
22688
|
};
|
|
22435
22689
|
}
|
|
22436
22690
|
|
|
@@ -36444,6 +36698,10 @@ var schemaSOABillingItem = import_joi92.default.object({
|
|
|
36444
36698
|
taxPercentage: import_joi92.default.number().optional().allow(null),
|
|
36445
36699
|
taxAmount: import_joi92.default.number().optional().allow(null)
|
|
36446
36700
|
});
|
|
36701
|
+
var schemaApprovedBy = import_joi92.default.object({
|
|
36702
|
+
_id: import_joi92.default.string().hex().optional().allow(null, ""),
|
|
36703
|
+
name: import_joi92.default.string().optional().allow(null, "")
|
|
36704
|
+
});
|
|
36447
36705
|
var schemaStatementOfAccount = import_joi92.default.object({
|
|
36448
36706
|
_id: import_joi92.default.string().hex().optional(),
|
|
36449
36707
|
site: import_joi92.default.string().hex().required(),
|
|
@@ -36457,6 +36715,7 @@ var schemaStatementOfAccount = import_joi92.default.object({
|
|
|
36457
36715
|
category: import_joi92.default.string().optional().allow(null, ""),
|
|
36458
36716
|
status: import_joi92.default.string().valid("pending", "approved", "rejected", "deleted").optional().allow(null, ""),
|
|
36459
36717
|
billing: import_joi92.default.array().items(schemaSOABillingItem).optional().allow(null, ""),
|
|
36718
|
+
approvedBy: schemaApprovedBy.optional().allow(null, ""),
|
|
36460
36719
|
createdBy: import_joi92.default.string().hex().required(),
|
|
36461
36720
|
createdByName: import_joi92.default.string().optional().allow(null, ""),
|
|
36462
36721
|
createdAt: import_joi92.default.date().optional(),
|
|
@@ -36476,6 +36735,7 @@ var schemaUpdateStatementOfAccount = import_joi92.default.object({
|
|
|
36476
36735
|
category: import_joi92.default.string().optional().allow(null, ""),
|
|
36477
36736
|
status: import_joi92.default.string().valid("pending", "approved", "rejected", "deleted").optional().allow(null, ""),
|
|
36478
36737
|
billing: import_joi92.default.array().items(schemaSOABillingItem).optional().allow(null, ""),
|
|
36738
|
+
approvedBy: schemaApprovedBy.optional().allow(null, ""),
|
|
36479
36739
|
createdBy: import_joi92.default.string().optional().allow(null, ""),
|
|
36480
36740
|
createdByName: import_joi92.default.string().optional().allow(null, "")
|
|
36481
36741
|
});
|
|
@@ -36540,6 +36800,7 @@ function MStatementOfAccount(value) {
|
|
|
36540
36800
|
status: value.status ?? "pending",
|
|
36541
36801
|
createdBy: value.createdBy,
|
|
36542
36802
|
createdByName: value.createdByName ?? "",
|
|
36803
|
+
approvedBy: value.approvedBy,
|
|
36543
36804
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
36544
36805
|
updatedAt: value.updatedAt ?? "",
|
|
36545
36806
|
deletedAt: value.deletedAt ?? ""
|
|
@@ -36869,6 +37130,35 @@ function useStatementOfAccountRepo() {
|
|
|
36869
37130
|
});
|
|
36870
37131
|
});
|
|
36871
37132
|
}
|
|
37133
|
+
async function reviewSOA(_id, value, session) {
|
|
37134
|
+
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
37135
|
+
try {
|
|
37136
|
+
_id = new import_mongodb97.ObjectId(_id);
|
|
37137
|
+
} catch (error) {
|
|
37138
|
+
throw new import_node_server_utils164.BadRequestError("Invalid ID format.");
|
|
37139
|
+
}
|
|
37140
|
+
try {
|
|
37141
|
+
const res = await collection.updateOne(
|
|
37142
|
+
{ _id },
|
|
37143
|
+
{ $set: value },
|
|
37144
|
+
{ session }
|
|
37145
|
+
);
|
|
37146
|
+
if (res.modifiedCount === 0) {
|
|
37147
|
+
throw new import_node_server_utils164.InternalServerError(`Unable to ${value.status} soa.`);
|
|
37148
|
+
}
|
|
37149
|
+
delNamespace().then(() => {
|
|
37150
|
+
import_node_server_utils164.logger.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
37151
|
+
}).catch((err) => {
|
|
37152
|
+
import_node_server_utils164.logger.error(
|
|
37153
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
37154
|
+
err
|
|
37155
|
+
);
|
|
37156
|
+
});
|
|
37157
|
+
return res;
|
|
37158
|
+
} catch (error) {
|
|
37159
|
+
throw error;
|
|
37160
|
+
}
|
|
37161
|
+
}
|
|
36872
37162
|
return {
|
|
36873
37163
|
createTextIndex,
|
|
36874
37164
|
add,
|
|
@@ -36877,7 +37167,8 @@ function useStatementOfAccountRepo() {
|
|
|
36877
37167
|
updateById,
|
|
36878
37168
|
deleteById,
|
|
36879
37169
|
updateStatusById,
|
|
36880
|
-
getResidentUserSoa
|
|
37170
|
+
getResidentUserSoa,
|
|
37171
|
+
reviewSOA
|
|
36881
37172
|
};
|
|
36882
37173
|
}
|
|
36883
37174
|
|
|
@@ -36886,9 +37177,10 @@ var import_node_server_utils166 = require("@7365admin1/node-server-utils");
|
|
|
36886
37177
|
|
|
36887
37178
|
// src/services/site-soa.service.ts
|
|
36888
37179
|
var import_node_server_utils165 = require("@7365admin1/node-server-utils");
|
|
37180
|
+
var import_mongodb98 = require("mongodb");
|
|
36889
37181
|
var import_puppeteer = require("puppeteer");
|
|
36890
37182
|
function useStatementOfAccountService() {
|
|
36891
|
-
const { add: _add } = useStatementOfAccountRepo();
|
|
37183
|
+
const { add: _add, reviewSOA: _reviewSOA } = useStatementOfAccountRepo();
|
|
36892
37184
|
const { getUnitBillingBySite } = useSiteUnitBillingRepo();
|
|
36893
37185
|
const { getUserById } = useUserRepo();
|
|
36894
37186
|
async function add(value, dateFrom, dateTo) {
|
|
@@ -37016,9 +37308,31 @@ function useStatementOfAccountService() {
|
|
|
37016
37308
|
throw error;
|
|
37017
37309
|
}
|
|
37018
37310
|
}
|
|
37311
|
+
async function reviewSOA(id, value) {
|
|
37312
|
+
const session = import_node_server_utils165.useAtlas.getClient()?.startSession();
|
|
37313
|
+
session?.startTransaction();
|
|
37314
|
+
try {
|
|
37315
|
+
if (value?.approvedBy?._id) {
|
|
37316
|
+
const approvedBy = await getUserById(value?.approvedBy?._id);
|
|
37317
|
+
if (!approvedBy || !approvedBy.name)
|
|
37318
|
+
throw new import_node_server_utils165.BadRequestError("Created by not found.");
|
|
37319
|
+
value.approvedBy.name = approvedBy.name;
|
|
37320
|
+
value.approvedBy._id = new import_mongodb98.ObjectId(approvedBy._id);
|
|
37321
|
+
}
|
|
37322
|
+
await _reviewSOA(id, value, session);
|
|
37323
|
+
await session?.commitTransaction();
|
|
37324
|
+
return `Successfully ${value.status} soa.`;
|
|
37325
|
+
} catch (error) {
|
|
37326
|
+
await session?.abortTransaction();
|
|
37327
|
+
throw error;
|
|
37328
|
+
} finally {
|
|
37329
|
+
session?.endSession();
|
|
37330
|
+
}
|
|
37331
|
+
}
|
|
37019
37332
|
return {
|
|
37020
37333
|
add,
|
|
37021
|
-
generatePDF
|
|
37334
|
+
generatePDF,
|
|
37335
|
+
reviewSOA
|
|
37022
37336
|
};
|
|
37023
37337
|
}
|
|
37024
37338
|
|
|
@@ -37033,7 +37347,11 @@ function useStatementOfAccountController() {
|
|
|
37033
37347
|
updateStatusById: _updateStatusById,
|
|
37034
37348
|
getResidentUserSoa: _getResidentUserSoa
|
|
37035
37349
|
} = useStatementOfAccountRepo();
|
|
37036
|
-
const {
|
|
37350
|
+
const {
|
|
37351
|
+
add: _add,
|
|
37352
|
+
generatePDF: _generatePDF,
|
|
37353
|
+
reviewSOA: _reviewSOA
|
|
37354
|
+
} = useStatementOfAccountService();
|
|
37037
37355
|
async function add(req, res, next) {
|
|
37038
37356
|
const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
37039
37357
|
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
@@ -37333,6 +37651,40 @@ function useStatementOfAccountController() {
|
|
|
37333
37651
|
return;
|
|
37334
37652
|
}
|
|
37335
37653
|
}
|
|
37654
|
+
async function reviewSOA(req, res, next) {
|
|
37655
|
+
const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
37656
|
+
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
37657
|
+
{}
|
|
37658
|
+
);
|
|
37659
|
+
req.body.approvedBy = {
|
|
37660
|
+
_id: "",
|
|
37661
|
+
name: ""
|
|
37662
|
+
};
|
|
37663
|
+
req.body.approvedBy._id = cookies?.["user"] ? cookies["user"].toString() : req.body.approvedBy._id;
|
|
37664
|
+
const _id = req.params.id;
|
|
37665
|
+
const payload = { _id, ...req.body };
|
|
37666
|
+
const schema2 = import_joi93.default.object({
|
|
37667
|
+
_id: import_joi93.default.string().hex().required(),
|
|
37668
|
+
status: import_joi93.default.string().valid("approved", "rejected").required(),
|
|
37669
|
+
approvedBy: schemaApprovedBy
|
|
37670
|
+
});
|
|
37671
|
+
const { error } = schema2.validate(payload);
|
|
37672
|
+
if (error) {
|
|
37673
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
37674
|
+
import_node_server_utils166.logger.log({ level: "error", message: messages });
|
|
37675
|
+
next(new import_node_server_utils166.BadRequestError(messages));
|
|
37676
|
+
return;
|
|
37677
|
+
}
|
|
37678
|
+
try {
|
|
37679
|
+
const result = await _reviewSOA(_id, req.body);
|
|
37680
|
+
res.status(200).json({ message: result });
|
|
37681
|
+
return;
|
|
37682
|
+
} catch (error2) {
|
|
37683
|
+
import_node_server_utils166.logger.log({ level: "error", message: error2.message });
|
|
37684
|
+
next(error2);
|
|
37685
|
+
return;
|
|
37686
|
+
}
|
|
37687
|
+
}
|
|
37336
37688
|
return {
|
|
37337
37689
|
add,
|
|
37338
37690
|
getAll,
|
|
@@ -37341,13 +37693,14 @@ function useStatementOfAccountController() {
|
|
|
37341
37693
|
deleteById,
|
|
37342
37694
|
generatePDF,
|
|
37343
37695
|
updateStatusById,
|
|
37344
|
-
getResidentUserSoa
|
|
37696
|
+
getResidentUserSoa,
|
|
37697
|
+
reviewSOA
|
|
37345
37698
|
};
|
|
37346
37699
|
}
|
|
37347
37700
|
|
|
37348
37701
|
// src/models/site-entrypass-settings.model.ts
|
|
37349
37702
|
var import_node_server_utils167 = require("@7365admin1/node-server-utils");
|
|
37350
|
-
var
|
|
37703
|
+
var import_mongodb99 = require("mongodb");
|
|
37351
37704
|
var import_joi94 = __toESM(require("joi"));
|
|
37352
37705
|
var schemaEntryPassSettings = import_joi94.default.object({
|
|
37353
37706
|
_id: import_joi94.default.string().hex().optional().allow("", null),
|
|
@@ -37395,21 +37748,21 @@ function MEntryPassSettings(value) {
|
|
|
37395
37748
|
}
|
|
37396
37749
|
if (value._id && typeof value._id === "string") {
|
|
37397
37750
|
try {
|
|
37398
|
-
value._id = new
|
|
37751
|
+
value._id = new import_mongodb99.ObjectId(value._id);
|
|
37399
37752
|
} catch {
|
|
37400
37753
|
throw new import_node_server_utils167.BadRequestError("Invalid _id format");
|
|
37401
37754
|
}
|
|
37402
37755
|
}
|
|
37403
37756
|
if (value.site && typeof value.site === "string") {
|
|
37404
37757
|
try {
|
|
37405
|
-
value.site = new
|
|
37758
|
+
value.site = new import_mongodb99.ObjectId(value.site);
|
|
37406
37759
|
} catch {
|
|
37407
37760
|
throw new import_node_server_utils167.BadRequestError("Invalid site format");
|
|
37408
37761
|
}
|
|
37409
37762
|
}
|
|
37410
37763
|
if (value.org && typeof value.org === "string") {
|
|
37411
37764
|
try {
|
|
37412
|
-
value.org = new
|
|
37765
|
+
value.org = new import_mongodb99.ObjectId(value.org);
|
|
37413
37766
|
} catch {
|
|
37414
37767
|
throw new import_node_server_utils167.BadRequestError("Invalid org format");
|
|
37415
37768
|
}
|
|
@@ -37439,7 +37792,7 @@ function MEntryPassSettings(value) {
|
|
|
37439
37792
|
|
|
37440
37793
|
// src/repositories/site-entrypass-settings.repo.ts
|
|
37441
37794
|
var import_node_server_utils168 = require("@7365admin1/node-server-utils");
|
|
37442
|
-
var
|
|
37795
|
+
var import_mongodb100 = require("mongodb");
|
|
37443
37796
|
function useEntryPassSettingsRepo() {
|
|
37444
37797
|
const db = import_node_server_utils168.useAtlas.getDb();
|
|
37445
37798
|
if (!db) {
|
|
@@ -37549,7 +37902,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37549
37902
|
}
|
|
37550
37903
|
async function getEntryPassSettingsById(_id) {
|
|
37551
37904
|
try {
|
|
37552
|
-
_id = new
|
|
37905
|
+
_id = new import_mongodb100.ObjectId(_id);
|
|
37553
37906
|
} catch (error) {
|
|
37554
37907
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37555
37908
|
}
|
|
@@ -37616,7 +37969,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37616
37969
|
}
|
|
37617
37970
|
async function updateEntryPassSettingsById(_id, value) {
|
|
37618
37971
|
try {
|
|
37619
|
-
_id = new
|
|
37972
|
+
_id = new import_mongodb100.ObjectId(_id);
|
|
37620
37973
|
} catch (error) {
|
|
37621
37974
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37622
37975
|
}
|
|
@@ -37644,7 +37997,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37644
37997
|
}
|
|
37645
37998
|
async function deleteEntryPassSettingsById(_id, session) {
|
|
37646
37999
|
try {
|
|
37647
|
-
_id = new
|
|
38000
|
+
_id = new import_mongodb100.ObjectId(_id);
|
|
37648
38001
|
} catch (error) {
|
|
37649
38002
|
throw new import_node_server_utils168.BadRequestError("Invalid card ID format.");
|
|
37650
38003
|
}
|
|
@@ -37677,7 +38030,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37677
38030
|
}
|
|
37678
38031
|
async function getEntryPassSettingsBySiteId(site) {
|
|
37679
38032
|
try {
|
|
37680
|
-
site = new
|
|
38033
|
+
site = new import_mongodb100.ObjectId(site);
|
|
37681
38034
|
} catch (error) {
|
|
37682
38035
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37683
38036
|
}
|
|
@@ -37744,7 +38097,7 @@ function useEntryPassSettingsRepo() {
|
|
|
37744
38097
|
}
|
|
37745
38098
|
async function updateEntryPassSettingsBySiteId(site, value) {
|
|
37746
38099
|
try {
|
|
37747
|
-
site = new
|
|
38100
|
+
site = new import_mongodb100.ObjectId(site);
|
|
37748
38101
|
} catch (error) {
|
|
37749
38102
|
throw new import_node_server_utils168.BadRequestError("Invalid entry pass settings ID format.");
|
|
37750
38103
|
}
|
|
@@ -38103,7 +38456,7 @@ function useDashboardController() {
|
|
|
38103
38456
|
}
|
|
38104
38457
|
|
|
38105
38458
|
// src/models/nfc-patrol-route.model.ts
|
|
38106
|
-
var
|
|
38459
|
+
var import_mongodb101 = require("mongodb");
|
|
38107
38460
|
var import_joi97 = __toESM(require("joi"));
|
|
38108
38461
|
var import_node_server_utils172 = require("@7365admin1/node-server-utils");
|
|
38109
38462
|
var schemaNfcPatrolRoute = import_joi97.default.object({
|
|
@@ -38139,23 +38492,23 @@ function MNfcPatrolRoute(value) {
|
|
|
38139
38492
|
}
|
|
38140
38493
|
if (value._id && typeof value._id === "string") {
|
|
38141
38494
|
try {
|
|
38142
|
-
value._id = new
|
|
38495
|
+
value._id = new import_mongodb101.ObjectId(value._id);
|
|
38143
38496
|
} catch (error2) {
|
|
38144
38497
|
throw new import_node_server_utils172.BadRequestError("Invalid _id format");
|
|
38145
38498
|
}
|
|
38146
38499
|
}
|
|
38147
38500
|
try {
|
|
38148
|
-
value.site = new
|
|
38501
|
+
value.site = new import_mongodb101.ObjectId(value.site);
|
|
38149
38502
|
} catch (error2) {
|
|
38150
38503
|
throw new import_node_server_utils172.BadRequestError("Invalid site format");
|
|
38151
38504
|
}
|
|
38152
38505
|
try {
|
|
38153
|
-
value.createdBy = new
|
|
38506
|
+
value.createdBy = new import_mongodb101.ObjectId(value.createdBy);
|
|
38154
38507
|
} catch (error2) {
|
|
38155
38508
|
throw new import_node_server_utils172.BadRequestError("Invalid createdBy format");
|
|
38156
38509
|
}
|
|
38157
38510
|
return {
|
|
38158
|
-
_id: value._id ?? new
|
|
38511
|
+
_id: value._id ?? new import_mongodb101.ObjectId(),
|
|
38159
38512
|
site: value.site,
|
|
38160
38513
|
name: value.name,
|
|
38161
38514
|
checkPointNumber: value.checkPointNumber,
|
|
@@ -38171,7 +38524,7 @@ function MNfcPatrolRoute(value) {
|
|
|
38171
38524
|
|
|
38172
38525
|
// src/repositories/nfc-patrol-route.repository.ts
|
|
38173
38526
|
var import_node_server_utils173 = require("@7365admin1/node-server-utils");
|
|
38174
|
-
var
|
|
38527
|
+
var import_mongodb102 = require("mongodb");
|
|
38175
38528
|
function useNfcPatrolRouteRepo() {
|
|
38176
38529
|
const db = import_node_server_utils173.useAtlas.getDb();
|
|
38177
38530
|
if (!db) {
|
|
@@ -38215,7 +38568,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
38215
38568
|
}, session) {
|
|
38216
38569
|
page = page > 0 ? page - 1 : 0;
|
|
38217
38570
|
try {
|
|
38218
|
-
site = new
|
|
38571
|
+
site = new import_mongodb102.ObjectId(site);
|
|
38219
38572
|
} catch (error) {
|
|
38220
38573
|
throw new import_node_server_utils173.BadRequestError("Invalid site ID format.");
|
|
38221
38574
|
}
|
|
@@ -38286,7 +38639,7 @@ function useNfcPatrolRouteRepo() {
|
|
|
38286
38639
|
}
|
|
38287
38640
|
async function getById(_id, isStart) {
|
|
38288
38641
|
try {
|
|
38289
|
-
_id = new
|
|
38642
|
+
_id = new import_mongodb102.ObjectId(_id);
|
|
38290
38643
|
} catch (error) {
|
|
38291
38644
|
throw new import_node_server_utils173.BadRequestError("Invalid ID.");
|
|
38292
38645
|
}
|
|
@@ -38396,18 +38749,18 @@ function useNfcPatrolRouteRepo() {
|
|
|
38396
38749
|
throw new import_node_server_utils173.BadRequestError(error.message);
|
|
38397
38750
|
}
|
|
38398
38751
|
try {
|
|
38399
|
-
_id = new
|
|
38752
|
+
_id = new import_mongodb102.ObjectId(_id);
|
|
38400
38753
|
} catch (error2) {
|
|
38401
38754
|
throw new import_node_server_utils173.BadRequestError("Invalid ID.");
|
|
38402
38755
|
}
|
|
38403
38756
|
try {
|
|
38404
|
-
value.site = new
|
|
38757
|
+
value.site = new import_mongodb102.ObjectId(value.site);
|
|
38405
38758
|
} catch (error2) {
|
|
38406
38759
|
throw new import_node_server_utils173.BadRequestError("Invalid site format");
|
|
38407
38760
|
}
|
|
38408
38761
|
if (value.updatedBy) {
|
|
38409
38762
|
try {
|
|
38410
|
-
value.updatedBy = new
|
|
38763
|
+
value.updatedBy = new import_mongodb102.ObjectId(value.updatedBy);
|
|
38411
38764
|
} catch (error2) {
|
|
38412
38765
|
throw new import_node_server_utils173.BadRequestError("Invalid createdBy format");
|
|
38413
38766
|
}
|
|
@@ -38632,7 +38985,7 @@ function useNfcPatrolRouteController() {
|
|
|
38632
38985
|
}
|
|
38633
38986
|
|
|
38634
38987
|
// src/models/incident-report.model.ts
|
|
38635
|
-
var
|
|
38988
|
+
var import_mongodb103 = require("mongodb");
|
|
38636
38989
|
var import_joi99 = __toESM(require("joi"));
|
|
38637
38990
|
var residentSchema = import_joi99.default.object({
|
|
38638
38991
|
_id: import_joi99.default.string().hex().optional().allow(null, ""),
|
|
@@ -38836,28 +39189,28 @@ var schemaUpdateIncidentReport = import_joi99.default.object({
|
|
|
38836
39189
|
function MIncidentReport(value) {
|
|
38837
39190
|
if (value._id && typeof value._id === "string") {
|
|
38838
39191
|
try {
|
|
38839
|
-
value._id = new
|
|
39192
|
+
value._id = new import_mongodb103.ObjectId(value._id);
|
|
38840
39193
|
} catch {
|
|
38841
39194
|
throw new Error("Invalid incident report ID.");
|
|
38842
39195
|
}
|
|
38843
39196
|
}
|
|
38844
39197
|
if (value.organization && typeof value.organization === "string") {
|
|
38845
39198
|
try {
|
|
38846
|
-
value.organization = new
|
|
39199
|
+
value.organization = new import_mongodb103.ObjectId(value.organization);
|
|
38847
39200
|
} catch {
|
|
38848
39201
|
throw new Error("Invalid organization ID.");
|
|
38849
39202
|
}
|
|
38850
39203
|
}
|
|
38851
39204
|
if (value.site && typeof value.site === "string") {
|
|
38852
39205
|
try {
|
|
38853
|
-
value.site = new
|
|
39206
|
+
value.site = new import_mongodb103.ObjectId(value.site);
|
|
38854
39207
|
} catch {
|
|
38855
39208
|
throw new Error("Invalid site ID.");
|
|
38856
39209
|
}
|
|
38857
39210
|
}
|
|
38858
39211
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
38859
39212
|
try {
|
|
38860
|
-
value.approvedBy = new
|
|
39213
|
+
value.approvedBy = new import_mongodb103.ObjectId(value.approvedBy);
|
|
38861
39214
|
} catch {
|
|
38862
39215
|
throw new Error("Invalid approvedBy ID.");
|
|
38863
39216
|
}
|
|
@@ -38865,7 +39218,7 @@ function MIncidentReport(value) {
|
|
|
38865
39218
|
const { incidentInformation } = value;
|
|
38866
39219
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
38867
39220
|
try {
|
|
38868
|
-
incidentInformation.siteInfo.site = new
|
|
39221
|
+
incidentInformation.siteInfo.site = new import_mongodb103.ObjectId(
|
|
38869
39222
|
incidentInformation.siteInfo.site
|
|
38870
39223
|
);
|
|
38871
39224
|
} catch {
|
|
@@ -38879,7 +39232,7 @@ function MIncidentReport(value) {
|
|
|
38879
39232
|
incidentInformation.submissionForm.dateOfReport = incidentInformation.submissionForm.dateOfReport.toISOString();
|
|
38880
39233
|
}
|
|
38881
39234
|
return {
|
|
38882
|
-
_id: value._id ?? new
|
|
39235
|
+
_id: value._id ?? new import_mongodb103.ObjectId(),
|
|
38883
39236
|
reportId: value.reportId,
|
|
38884
39237
|
incidentInformation: value.incidentInformation,
|
|
38885
39238
|
affectedEntities: value.affectedEntities,
|
|
@@ -38903,7 +39256,7 @@ var import_node_server_utils177 = require("@7365admin1/node-server-utils");
|
|
|
38903
39256
|
|
|
38904
39257
|
// src/repositories/incident-report.repo.ts
|
|
38905
39258
|
var import_node_server_utils176 = require("@7365admin1/node-server-utils");
|
|
38906
|
-
var
|
|
39259
|
+
var import_mongodb104 = require("mongodb");
|
|
38907
39260
|
var incidents_namespace_collection = "incident-reports";
|
|
38908
39261
|
function useIncidentReportRepo() {
|
|
38909
39262
|
const db = import_node_server_utils176.useAtlas.getDb();
|
|
@@ -38970,7 +39323,7 @@ function useIncidentReportRepo() {
|
|
|
38970
39323
|
page = page > 0 ? page - 1 : 0;
|
|
38971
39324
|
let dateExpr = {};
|
|
38972
39325
|
try {
|
|
38973
|
-
site = new
|
|
39326
|
+
site = new import_mongodb104.ObjectId(site);
|
|
38974
39327
|
} catch (error) {
|
|
38975
39328
|
throw new import_node_server_utils176.BadRequestError("Invalid site ID format.");
|
|
38976
39329
|
}
|
|
@@ -39071,7 +39424,7 @@ function useIncidentReportRepo() {
|
|
|
39071
39424
|
page = page > 0 ? page - 1 : 0;
|
|
39072
39425
|
let dateExpr = {};
|
|
39073
39426
|
try {
|
|
39074
|
-
site = new
|
|
39427
|
+
site = new import_mongodb104.ObjectId(site);
|
|
39075
39428
|
} catch (error) {
|
|
39076
39429
|
throw new import_node_server_utils176.BadRequestError("Invalid site ID format.");
|
|
39077
39430
|
}
|
|
@@ -39140,7 +39493,7 @@ function useIncidentReportRepo() {
|
|
|
39140
39493
|
}
|
|
39141
39494
|
async function getIncidentReportById(_id, session) {
|
|
39142
39495
|
try {
|
|
39143
|
-
_id = new
|
|
39496
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39144
39497
|
} catch (error) {
|
|
39145
39498
|
throw new import_node_server_utils176.BadRequestError("Invalid incident report ID format.");
|
|
39146
39499
|
}
|
|
@@ -39171,27 +39524,27 @@ function useIncidentReportRepo() {
|
|
|
39171
39524
|
async function updateIncidentReportById(_id, value, session) {
|
|
39172
39525
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
39173
39526
|
try {
|
|
39174
|
-
_id = new
|
|
39527
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39175
39528
|
} catch (error) {
|
|
39176
39529
|
throw new import_node_server_utils176.BadRequestError("Invalid ID format.");
|
|
39177
39530
|
}
|
|
39178
39531
|
if (value.organization && typeof value.organization === "string") {
|
|
39179
39532
|
try {
|
|
39180
|
-
value.organization = new
|
|
39533
|
+
value.organization = new import_mongodb104.ObjectId(value.organization);
|
|
39181
39534
|
} catch {
|
|
39182
39535
|
throw new Error("Invalid organization ID.");
|
|
39183
39536
|
}
|
|
39184
39537
|
}
|
|
39185
39538
|
if (value.site && typeof value.site === "string") {
|
|
39186
39539
|
try {
|
|
39187
|
-
value.site = new
|
|
39540
|
+
value.site = new import_mongodb104.ObjectId(value.site);
|
|
39188
39541
|
} catch {
|
|
39189
39542
|
throw new Error("Invalid site ID.");
|
|
39190
39543
|
}
|
|
39191
39544
|
}
|
|
39192
39545
|
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
39193
39546
|
try {
|
|
39194
|
-
value.approvedBy = new
|
|
39547
|
+
value.approvedBy = new import_mongodb104.ObjectId(value.approvedBy);
|
|
39195
39548
|
} catch {
|
|
39196
39549
|
throw new Error("Invalid approvedBy ID.");
|
|
39197
39550
|
}
|
|
@@ -39199,7 +39552,7 @@ function useIncidentReportRepo() {
|
|
|
39199
39552
|
const { incidentInformation } = value;
|
|
39200
39553
|
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
39201
39554
|
try {
|
|
39202
|
-
incidentInformation.siteInfo.site = new
|
|
39555
|
+
incidentInformation.siteInfo.site = new import_mongodb104.ObjectId(
|
|
39203
39556
|
incidentInformation.siteInfo.site
|
|
39204
39557
|
);
|
|
39205
39558
|
} catch {
|
|
@@ -39234,7 +39587,7 @@ function useIncidentReportRepo() {
|
|
|
39234
39587
|
}
|
|
39235
39588
|
async function deleteIncidentReportById(_id) {
|
|
39236
39589
|
try {
|
|
39237
|
-
_id = new
|
|
39590
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39238
39591
|
} catch (error) {
|
|
39239
39592
|
throw new import_node_server_utils176.BadRequestError("Invalid occurrence subject ID format.");
|
|
39240
39593
|
}
|
|
@@ -39266,7 +39619,7 @@ function useIncidentReportRepo() {
|
|
|
39266
39619
|
async function reviewIncidentReport(_id, value, session) {
|
|
39267
39620
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
39268
39621
|
try {
|
|
39269
|
-
_id = new
|
|
39622
|
+
_id = new import_mongodb104.ObjectId(_id);
|
|
39270
39623
|
} catch (error) {
|
|
39271
39624
|
throw new import_node_server_utils176.BadRequestError("Invalid ID format.");
|
|
39272
39625
|
}
|
|
@@ -39758,7 +40111,7 @@ function useIncidentReportController() {
|
|
|
39758
40111
|
}
|
|
39759
40112
|
|
|
39760
40113
|
// src/models/nfc-patrol-settings.model.ts
|
|
39761
|
-
var
|
|
40114
|
+
var import_mongodb105 = require("mongodb");
|
|
39762
40115
|
var import_joi101 = __toESM(require("joi"));
|
|
39763
40116
|
var import_node_server_utils179 = require("@7365admin1/node-server-utils");
|
|
39764
40117
|
var objectId = import_joi101.default.string().hex().length(24);
|
|
@@ -39784,7 +40137,7 @@ function MNfcPatrolSettings(value) {
|
|
|
39784
40137
|
}
|
|
39785
40138
|
if (value.site) {
|
|
39786
40139
|
try {
|
|
39787
|
-
value.site = new
|
|
40140
|
+
value.site = new import_mongodb105.ObjectId(value.site);
|
|
39788
40141
|
} catch (error2) {
|
|
39789
40142
|
throw new import_node_server_utils179.BadRequestError("Invalid site ID format.");
|
|
39790
40143
|
}
|
|
@@ -39804,7 +40157,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
39804
40157
|
}
|
|
39805
40158
|
if (value.updatedBy) {
|
|
39806
40159
|
try {
|
|
39807
|
-
value.updatedBy = new
|
|
40160
|
+
value.updatedBy = new import_mongodb105.ObjectId(value.updatedBy);
|
|
39808
40161
|
} catch (error2) {
|
|
39809
40162
|
throw new import_node_server_utils179.BadRequestError("Invalid updatedBy ID format.");
|
|
39810
40163
|
}
|
|
@@ -39818,7 +40171,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
39818
40171
|
|
|
39819
40172
|
// src/repositories/nfc-patrol-settings.repository.ts
|
|
39820
40173
|
var import_node_server_utils180 = require("@7365admin1/node-server-utils");
|
|
39821
|
-
var
|
|
40174
|
+
var import_mongodb106 = require("mongodb");
|
|
39822
40175
|
function useNfcPatrolSettingsRepository() {
|
|
39823
40176
|
const db = import_node_server_utils180.useAtlas.getDb();
|
|
39824
40177
|
if (!db) {
|
|
@@ -39848,7 +40201,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
39848
40201
|
}
|
|
39849
40202
|
async function getNfcPatrolSettingsBySite(site, session) {
|
|
39850
40203
|
try {
|
|
39851
|
-
site = new
|
|
40204
|
+
site = new import_mongodb106.ObjectId(site);
|
|
39852
40205
|
} catch (error) {
|
|
39853
40206
|
throw new import_node_server_utils180.BadRequestError("Invalid nfc patrol settings site ID format.");
|
|
39854
40207
|
}
|
|
@@ -39892,7 +40245,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
39892
40245
|
}
|
|
39893
40246
|
async function updateNfcPatrolSettings(site, value, session) {
|
|
39894
40247
|
try {
|
|
39895
|
-
site = new
|
|
40248
|
+
site = new import_mongodb106.ObjectId(site);
|
|
39896
40249
|
} catch (error) {
|
|
39897
40250
|
throw new import_node_server_utils180.BadRequestError("Invalid attendance settings ID format.");
|
|
39898
40251
|
}
|
|
@@ -40057,13 +40410,13 @@ function useNfcPatrolSettingsController() {
|
|
|
40057
40410
|
|
|
40058
40411
|
// src/services/occurrence-entry.service.ts
|
|
40059
40412
|
var import_node_server_utils184 = require("@7365admin1/node-server-utils");
|
|
40060
|
-
var
|
|
40413
|
+
var import_mongodb109 = require("mongodb");
|
|
40061
40414
|
|
|
40062
40415
|
// src/repositories/occurrence-subject.repo.ts
|
|
40063
40416
|
var import_node_server_utils183 = require("@7365admin1/node-server-utils");
|
|
40064
40417
|
|
|
40065
40418
|
// src/models/occurrence-subject.model.ts
|
|
40066
|
-
var
|
|
40419
|
+
var import_mongodb107 = require("mongodb");
|
|
40067
40420
|
var import_joi103 = __toESM(require("joi"));
|
|
40068
40421
|
var schemaOccurrenceSubject = import_joi103.default.object({
|
|
40069
40422
|
site: import_joi103.default.string().hex().required(),
|
|
@@ -40077,27 +40430,27 @@ var schemaUpdateOccurrenceSubject = import_joi103.default.object({
|
|
|
40077
40430
|
function MOccurrenceSubject(value) {
|
|
40078
40431
|
if (value._id && typeof value._id === "string") {
|
|
40079
40432
|
try {
|
|
40080
|
-
value._id = new
|
|
40433
|
+
value._id = new import_mongodb107.ObjectId(value._id);
|
|
40081
40434
|
} catch {
|
|
40082
40435
|
throw new Error("Invalid ID.");
|
|
40083
40436
|
}
|
|
40084
40437
|
}
|
|
40085
40438
|
if (value.site && typeof value.site === "string") {
|
|
40086
40439
|
try {
|
|
40087
|
-
value.site = new
|
|
40440
|
+
value.site = new import_mongodb107.ObjectId(value.site);
|
|
40088
40441
|
} catch {
|
|
40089
40442
|
throw new Error("Invalid site ID.");
|
|
40090
40443
|
}
|
|
40091
40444
|
}
|
|
40092
40445
|
if (value.addedBy && typeof value.addedBy === "string") {
|
|
40093
40446
|
try {
|
|
40094
|
-
value.addedBy = new
|
|
40447
|
+
value.addedBy = new import_mongodb107.ObjectId(value.addedBy);
|
|
40095
40448
|
} catch {
|
|
40096
40449
|
throw new Error("Invalid addedBy ID.");
|
|
40097
40450
|
}
|
|
40098
40451
|
}
|
|
40099
40452
|
return {
|
|
40100
|
-
_id: value._id ?? new
|
|
40453
|
+
_id: value._id ?? new import_mongodb107.ObjectId(),
|
|
40101
40454
|
site: value.site,
|
|
40102
40455
|
subject: value.subject,
|
|
40103
40456
|
addedBy: value.addedBy ?? "",
|
|
@@ -40108,7 +40461,7 @@ function MOccurrenceSubject(value) {
|
|
|
40108
40461
|
}
|
|
40109
40462
|
|
|
40110
40463
|
// src/repositories/occurrence-subject.repo.ts
|
|
40111
|
-
var
|
|
40464
|
+
var import_mongodb108 = require("mongodb");
|
|
40112
40465
|
function useOccurrenceSubjectRepo() {
|
|
40113
40466
|
const db = import_node_server_utils183.useAtlas.getDb();
|
|
40114
40467
|
if (!db) {
|
|
@@ -40167,7 +40520,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40167
40520
|
}, session) {
|
|
40168
40521
|
page = page > 0 ? page - 1 : 0;
|
|
40169
40522
|
try {
|
|
40170
|
-
site = new
|
|
40523
|
+
site = new import_mongodb108.ObjectId(site);
|
|
40171
40524
|
} catch (error) {
|
|
40172
40525
|
throw new import_node_server_utils183.BadRequestError("Invalid site ID format.");
|
|
40173
40526
|
}
|
|
@@ -40262,7 +40615,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40262
40615
|
}
|
|
40263
40616
|
async function getOccurrenceSubjectById(_id, session) {
|
|
40264
40617
|
try {
|
|
40265
|
-
_id = new
|
|
40618
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
40266
40619
|
} catch (error) {
|
|
40267
40620
|
throw new import_node_server_utils183.BadRequestError("Invalid occurrence subject ID format.");
|
|
40268
40621
|
}
|
|
@@ -40279,7 +40632,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40279
40632
|
async function updateOccurrenceSubjectById(_id, value, session) {
|
|
40280
40633
|
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
40281
40634
|
try {
|
|
40282
|
-
_id = new
|
|
40635
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
40283
40636
|
} catch (error) {
|
|
40284
40637
|
throw new import_node_server_utils183.BadRequestError("Invalid ID format.");
|
|
40285
40638
|
}
|
|
@@ -40309,7 +40662,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
40309
40662
|
}
|
|
40310
40663
|
async function deleteOccurrenceSubjectById(_id) {
|
|
40311
40664
|
try {
|
|
40312
|
-
_id = new
|
|
40665
|
+
_id = new import_mongodb108.ObjectId(_id);
|
|
40313
40666
|
} catch (error) {
|
|
40314
40667
|
throw new import_node_server_utils183.BadRequestError("Invalid occurrence subject ID format.");
|
|
40315
40668
|
}
|
|
@@ -40421,8 +40774,8 @@ function useOccurrenceEntryService() {
|
|
|
40421
40774
|
value.dailyOccurrenceBookId = occurrenceEntry.dailyOccurrenceBookId;
|
|
40422
40775
|
value.bookEntryCount = value.bookEntryCount ? value.bookEntryCount : occurrenceEntry.bookEntryCount;
|
|
40423
40776
|
value.occurrence = value.occurrence ? value.occurrence : occurrenceEntry.occurrence;
|
|
40424
|
-
value.signature = value.signature ? new
|
|
40425
|
-
value.eSignature = value.eSignature ? new
|
|
40777
|
+
value.signature = value.signature ? new import_mongodb109.ObjectId(value.signature) : occurrenceEntry.signature._id;
|
|
40778
|
+
value.eSignature = value.eSignature ? new import_mongodb109.ObjectId(value.eSignature) : occurrenceEntry.eSignature;
|
|
40426
40779
|
value.createdAt = /* @__PURE__ */ new Date();
|
|
40427
40780
|
value.date = value.date ? value.date : occurrenceEntry.date;
|
|
40428
40781
|
value.userName = value.userName ? value.userName : occurrenceEntry.signature.name;
|
|
@@ -40622,7 +40975,7 @@ function useOccurrenceEntryController() {
|
|
|
40622
40975
|
|
|
40623
40976
|
// src/models/online-form.model.ts
|
|
40624
40977
|
var import_joi105 = __toESM(require("joi"));
|
|
40625
|
-
var
|
|
40978
|
+
var import_mongodb110 = require("mongodb");
|
|
40626
40979
|
var schemaOnlineForm = import_joi105.default.object({
|
|
40627
40980
|
_id: import_joi105.default.string().hex().optional().allow("", null),
|
|
40628
40981
|
name: import_joi105.default.string().required(),
|
|
@@ -40670,21 +41023,21 @@ function MOnlineForm(value) {
|
|
|
40670
41023
|
}
|
|
40671
41024
|
if (value._id && typeof value._id === "string") {
|
|
40672
41025
|
try {
|
|
40673
|
-
value._id = new
|
|
41026
|
+
value._id = new import_mongodb110.ObjectId(value._id);
|
|
40674
41027
|
} catch (error2) {
|
|
40675
41028
|
throw new Error("Invalid ID.");
|
|
40676
41029
|
}
|
|
40677
41030
|
}
|
|
40678
41031
|
if (value.org && typeof value.org === "string") {
|
|
40679
41032
|
try {
|
|
40680
|
-
value.org = new
|
|
41033
|
+
value.org = new import_mongodb110.ObjectId(value.org);
|
|
40681
41034
|
} catch (error2) {
|
|
40682
41035
|
throw new Error("Invalid org ID.");
|
|
40683
41036
|
}
|
|
40684
41037
|
}
|
|
40685
41038
|
if (value.site && typeof value.site === "string") {
|
|
40686
41039
|
try {
|
|
40687
|
-
value.site = new
|
|
41040
|
+
value.site = new import_mongodb110.ObjectId(value.site);
|
|
40688
41041
|
} catch (error2) {
|
|
40689
41042
|
throw new Error("Invalid site ID.");
|
|
40690
41043
|
}
|
|
@@ -40707,7 +41060,7 @@ function MOnlineForm(value) {
|
|
|
40707
41060
|
|
|
40708
41061
|
// src/repositories/online-form.repo.ts
|
|
40709
41062
|
var import_node_server_utils186 = require("@7365admin1/node-server-utils");
|
|
40710
|
-
var
|
|
41063
|
+
var import_mongodb111 = require("mongodb");
|
|
40711
41064
|
function useOnlineFormRepo() {
|
|
40712
41065
|
const db = import_node_server_utils186.useAtlas.getDb();
|
|
40713
41066
|
if (!db) {
|
|
@@ -40759,7 +41112,7 @@ function useOnlineFormRepo() {
|
|
|
40759
41112
|
}) {
|
|
40760
41113
|
page = page > 0 ? page - 1 : 0;
|
|
40761
41114
|
try {
|
|
40762
|
-
site = new
|
|
41115
|
+
site = new import_mongodb111.ObjectId(site);
|
|
40763
41116
|
} catch (error) {
|
|
40764
41117
|
throw new import_node_server_utils186.BadRequestError("Invalid site ID format.");
|
|
40765
41118
|
}
|
|
@@ -40819,7 +41172,7 @@ function useOnlineFormRepo() {
|
|
|
40819
41172
|
}
|
|
40820
41173
|
async function getOnlineFormById(_id) {
|
|
40821
41174
|
try {
|
|
40822
|
-
_id = new
|
|
41175
|
+
_id = new import_mongodb111.ObjectId(_id);
|
|
40823
41176
|
} catch (error) {
|
|
40824
41177
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40825
41178
|
}
|
|
@@ -40862,7 +41215,7 @@ function useOnlineFormRepo() {
|
|
|
40862
41215
|
}
|
|
40863
41216
|
async function updateOnlineFormById(_id, value) {
|
|
40864
41217
|
try {
|
|
40865
|
-
_id = new
|
|
41218
|
+
_id = new import_mongodb111.ObjectId(_id);
|
|
40866
41219
|
} catch (error) {
|
|
40867
41220
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40868
41221
|
}
|
|
@@ -40890,7 +41243,7 @@ function useOnlineFormRepo() {
|
|
|
40890
41243
|
}
|
|
40891
41244
|
async function deleteOnlineFormById(_id, session) {
|
|
40892
41245
|
try {
|
|
40893
|
-
_id = new
|
|
41246
|
+
_id = new import_mongodb111.ObjectId(_id);
|
|
40894
41247
|
} catch (error) {
|
|
40895
41248
|
throw new import_node_server_utils186.BadRequestError("Invalid online form ID format.");
|
|
40896
41249
|
}
|
|
@@ -40923,7 +41276,7 @@ function useOnlineFormRepo() {
|
|
|
40923
41276
|
}
|
|
40924
41277
|
async function getOnlineFormsBySiteId(site, { search = "", page = 1, limit = 10, status = "active" }) {
|
|
40925
41278
|
try {
|
|
40926
|
-
site = new
|
|
41279
|
+
site = new import_mongodb111.ObjectId(site);
|
|
40927
41280
|
} catch (error) {
|
|
40928
41281
|
throw new import_node_server_utils186.BadRequestError(
|
|
40929
41282
|
"Invalid online form configuration site ID format."
|
|
@@ -41364,7 +41717,7 @@ function useOccurrenceSubjectController() {
|
|
|
41364
41717
|
}
|
|
41365
41718
|
|
|
41366
41719
|
// src/models/nfc-patrol-log.model.ts
|
|
41367
|
-
var
|
|
41720
|
+
var import_mongodb112 = require("mongodb");
|
|
41368
41721
|
var import_joi108 = __toESM(require("joi"));
|
|
41369
41722
|
var import_node_server_utils190 = require("@7365admin1/node-server-utils");
|
|
41370
41723
|
var schemaNfcPatrolLog = import_joi108.default.object({
|
|
@@ -41416,32 +41769,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41416
41769
|
}
|
|
41417
41770
|
if (value._id && typeof value._id === "string") {
|
|
41418
41771
|
try {
|
|
41419
|
-
value._id = new
|
|
41772
|
+
value._id = new import_mongodb112.ObjectId(value._id);
|
|
41420
41773
|
} catch (error2) {
|
|
41421
41774
|
throw new import_node_server_utils190.BadRequestError("Invalid _id format");
|
|
41422
41775
|
}
|
|
41423
41776
|
}
|
|
41424
41777
|
try {
|
|
41425
|
-
value.site = new
|
|
41778
|
+
value.site = new import_mongodb112.ObjectId(value.site);
|
|
41426
41779
|
} catch (error2) {
|
|
41427
41780
|
throw new import_node_server_utils190.BadRequestError("Invalid site format");
|
|
41428
41781
|
}
|
|
41429
41782
|
if (value?.createdBy) {
|
|
41430
41783
|
try {
|
|
41431
|
-
value.createdBy = new
|
|
41784
|
+
value.createdBy = new import_mongodb112.ObjectId(value.createdBy);
|
|
41432
41785
|
} catch (error2) {
|
|
41433
41786
|
throw new import_node_server_utils190.BadRequestError("Invalid createdBy format");
|
|
41434
41787
|
}
|
|
41435
41788
|
}
|
|
41436
41789
|
if (value?.route?._id) {
|
|
41437
41790
|
try {
|
|
41438
|
-
value.route._id = new
|
|
41791
|
+
value.route._id = new import_mongodb112.ObjectId(value.route._id);
|
|
41439
41792
|
} catch (error2) {
|
|
41440
41793
|
throw new import_node_server_utils190.BadRequestError("Invalid route _id format");
|
|
41441
41794
|
}
|
|
41442
41795
|
}
|
|
41443
41796
|
return {
|
|
41444
|
-
_id: value._id ?? new
|
|
41797
|
+
_id: value._id ?? new import_mongodb112.ObjectId(),
|
|
41445
41798
|
site: value.site,
|
|
41446
41799
|
route: value.route,
|
|
41447
41800
|
date: value.date,
|
|
@@ -41455,7 +41808,7 @@ function MNfcPatrolLog(valueArg) {
|
|
|
41455
41808
|
|
|
41456
41809
|
// src/repositories/nfc-patrol-log.repository.ts
|
|
41457
41810
|
var import_node_server_utils191 = require("@7365admin1/node-server-utils");
|
|
41458
|
-
var
|
|
41811
|
+
var import_mongodb113 = require("mongodb");
|
|
41459
41812
|
function useNfcPatrolLogRepo() {
|
|
41460
41813
|
const db = import_node_server_utils191.useAtlas.getDb();
|
|
41461
41814
|
if (!db) {
|
|
@@ -41508,7 +41861,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41508
41861
|
const pageIndex = page > 0 ? page - 1 : 0;
|
|
41509
41862
|
let siteId;
|
|
41510
41863
|
try {
|
|
41511
|
-
siteId = typeof site === "string" ? new
|
|
41864
|
+
siteId = typeof site === "string" ? new import_mongodb113.ObjectId(site) : site;
|
|
41512
41865
|
} catch {
|
|
41513
41866
|
throw new import_node_server_utils191.BadRequestError("Invalid site ID format.");
|
|
41514
41867
|
}
|
|
@@ -41519,7 +41872,7 @@ function useNfcPatrolLogRepo() {
|
|
|
41519
41872
|
query.date = date;
|
|
41520
41873
|
}
|
|
41521
41874
|
if (route?._id) {
|
|
41522
|
-
query["route._id"] = typeof route._id === "string" ? new
|
|
41875
|
+
query["route._id"] = typeof route._id === "string" ? new import_mongodb113.ObjectId(route._id) : route._id;
|
|
41523
41876
|
}
|
|
41524
41877
|
if (route?.startTime) {
|
|
41525
41878
|
query["route.startTime"] = route.startTime;
|
|
@@ -42378,7 +42731,7 @@ function useNewDashboardController() {
|
|
|
42378
42731
|
|
|
42379
42732
|
// src/models/manpower-monitoring.model.ts
|
|
42380
42733
|
var import_joi111 = __toESM(require("joi"));
|
|
42381
|
-
var
|
|
42734
|
+
var import_mongodb114 = require("mongodb");
|
|
42382
42735
|
var shiftSchema = import_joi111.default.object({
|
|
42383
42736
|
name: import_joi111.default.string().required(),
|
|
42384
42737
|
checkIn: import_joi111.default.string().optional().allow("", null),
|
|
@@ -42403,7 +42756,7 @@ var manpowerMonitoringSchema = import_joi111.default.object({
|
|
|
42403
42756
|
});
|
|
42404
42757
|
var MManpowerMonitoring = class {
|
|
42405
42758
|
constructor(data) {
|
|
42406
|
-
this._id = new
|
|
42759
|
+
this._id = new import_mongodb114.ObjectId();
|
|
42407
42760
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
42408
42761
|
this.siteId = data.siteId || "";
|
|
42409
42762
|
this.siteName = data.siteName;
|
|
@@ -42869,7 +43222,7 @@ var hrmlabs_attendance_util_default = {
|
|
|
42869
43222
|
};
|
|
42870
43223
|
|
|
42871
43224
|
// src/repositories/manpower-monitoring.repo.ts
|
|
42872
|
-
var
|
|
43225
|
+
var import_mongodb115 = require("mongodb");
|
|
42873
43226
|
var { hrmLabsAuthentication: hrmLabsAuthentication2, fetchSites: fetchSites2 } = hrmlabs_attendance_util_default;
|
|
42874
43227
|
function useManpowerMonitoringRepo() {
|
|
42875
43228
|
const db = import_node_server_utils196.useAtlas.getDb();
|
|
@@ -42883,11 +43236,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42883
43236
|
try {
|
|
42884
43237
|
value = new MManpowerMonitoring(value);
|
|
42885
43238
|
if (value.createdBy)
|
|
42886
|
-
value.createdBy = new
|
|
43239
|
+
value.createdBy = new import_mongodb115.ObjectId(value.createdBy);
|
|
42887
43240
|
if (value.siteId)
|
|
42888
|
-
value.siteId = new
|
|
43241
|
+
value.siteId = new import_mongodb115.ObjectId(value.siteId);
|
|
42889
43242
|
if (value.serviceProviderId)
|
|
42890
|
-
value.serviceProviderId = new
|
|
43243
|
+
value.serviceProviderId = new import_mongodb115.ObjectId(value.serviceProviderId);
|
|
42891
43244
|
const result = await collection.insertOne(value, { session });
|
|
42892
43245
|
return result;
|
|
42893
43246
|
} catch (error) {
|
|
@@ -42928,8 +43281,8 @@ function useManpowerMonitoringRepo() {
|
|
|
42928
43281
|
}
|
|
42929
43282
|
async function getManpowerSettingsBySiteId(_id, serviceProviderId) {
|
|
42930
43283
|
try {
|
|
42931
|
-
_id = new
|
|
42932
|
-
serviceProviderId = new
|
|
43284
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
43285
|
+
serviceProviderId = new import_mongodb115.ObjectId(serviceProviderId);
|
|
42933
43286
|
} catch (error) {
|
|
42934
43287
|
throw new Error("Invalid Site ID format.");
|
|
42935
43288
|
}
|
|
@@ -42945,7 +43298,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42945
43298
|
}
|
|
42946
43299
|
async function updateManpowerMonitoringSettings(_id, value) {
|
|
42947
43300
|
try {
|
|
42948
|
-
_id = new
|
|
43301
|
+
_id = new import_mongodb115.ObjectId(_id);
|
|
42949
43302
|
} catch (error) {
|
|
42950
43303
|
throw new import_node_server_utils196.BadRequestError("Invalid ID format.");
|
|
42951
43304
|
}
|
|
@@ -42972,7 +43325,7 @@ function useManpowerMonitoringRepo() {
|
|
|
42972
43325
|
for (let item of value) {
|
|
42973
43326
|
item = new MManpowerMonitoring(item);
|
|
42974
43327
|
const data = await collection.findOne({
|
|
42975
|
-
siteId: new
|
|
43328
|
+
siteId: new import_mongodb115.ObjectId(item.siteId)
|
|
42976
43329
|
});
|
|
42977
43330
|
if (data) {
|
|
42978
43331
|
let updateValue;
|
|
@@ -42997,11 +43350,11 @@ function useManpowerMonitoringRepo() {
|
|
|
42997
43350
|
}
|
|
42998
43351
|
} else {
|
|
42999
43352
|
if (item.createdBy)
|
|
43000
|
-
item.createdBy = new
|
|
43353
|
+
item.createdBy = new import_mongodb115.ObjectId(item.createdBy);
|
|
43001
43354
|
if (item.siteId)
|
|
43002
|
-
item.siteId = new
|
|
43355
|
+
item.siteId = new import_mongodb115.ObjectId(item.siteId);
|
|
43003
43356
|
if (item.serviceProviderId)
|
|
43004
|
-
item.serviceProviderId = new
|
|
43357
|
+
item.serviceProviderId = new import_mongodb115.ObjectId(item.serviceProviderId);
|
|
43005
43358
|
const result = await collection.insertOne(item);
|
|
43006
43359
|
if (result.insertedId) {
|
|
43007
43360
|
results.inserted++;
|
|
@@ -43025,7 +43378,7 @@ function useManpowerMonitoringRepo() {
|
|
|
43025
43378
|
const siteUrl = process.env.HRMLABS_SITE_URL;
|
|
43026
43379
|
try {
|
|
43027
43380
|
const serviceProvider = await serviceProviderCollection.findOne({
|
|
43028
|
-
_id: new
|
|
43381
|
+
_id: new import_mongodb115.ObjectId(serviceProviderId)
|
|
43029
43382
|
});
|
|
43030
43383
|
if (!serviceProvider) {
|
|
43031
43384
|
throw new Error("Service Provider not found.");
|
|
@@ -43067,7 +43420,7 @@ var import_node_server_utils197 = require("@7365admin1/node-server-utils");
|
|
|
43067
43420
|
|
|
43068
43421
|
// src/models/manpower-remarks.model.ts
|
|
43069
43422
|
var import_joi112 = __toESM(require("joi"));
|
|
43070
|
-
var
|
|
43423
|
+
var import_mongodb116 = require("mongodb");
|
|
43071
43424
|
var remarksSchema = import_joi112.default.object({
|
|
43072
43425
|
name: import_joi112.default.string().required(),
|
|
43073
43426
|
remark: import_joi112.default.object({
|
|
@@ -43091,7 +43444,7 @@ var manpowerRemarksSchema = import_joi112.default.object({
|
|
|
43091
43444
|
});
|
|
43092
43445
|
var MManpowerRemarks = class {
|
|
43093
43446
|
constructor(data) {
|
|
43094
|
-
this._id = new
|
|
43447
|
+
this._id = new import_mongodb116.ObjectId();
|
|
43095
43448
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
43096
43449
|
this.siteId = data.siteId || "";
|
|
43097
43450
|
this.siteName = data.siteName || "";
|
|
@@ -43109,7 +43462,7 @@ var MManpowerRemarks = class {
|
|
|
43109
43462
|
};
|
|
43110
43463
|
|
|
43111
43464
|
// src/repositories/manpower-remarks.repo.ts
|
|
43112
|
-
var
|
|
43465
|
+
var import_mongodb117 = require("mongodb");
|
|
43113
43466
|
var import_moment_timezone2 = __toESM(require("moment-timezone"));
|
|
43114
43467
|
function useManpowerRemarksRepo() {
|
|
43115
43468
|
const db = import_node_server_utils197.useAtlas.getDb();
|
|
@@ -43122,9 +43475,9 @@ function useManpowerRemarksRepo() {
|
|
|
43122
43475
|
try {
|
|
43123
43476
|
value = new MManpowerRemarks(value);
|
|
43124
43477
|
if (value.siteId)
|
|
43125
|
-
value.siteId = new
|
|
43478
|
+
value.siteId = new import_mongodb117.ObjectId(value.siteId);
|
|
43126
43479
|
if (value.serviceProviderId)
|
|
43127
|
-
value.serviceProviderId = new
|
|
43480
|
+
value.serviceProviderId = new import_mongodb117.ObjectId(value.serviceProviderId);
|
|
43128
43481
|
const result = await collection.insertOne(value, { session });
|
|
43129
43482
|
return result;
|
|
43130
43483
|
} catch (error) {
|
|
@@ -43144,7 +43497,7 @@ function useManpowerRemarksRepo() {
|
|
|
43144
43497
|
limit = limit || 10;
|
|
43145
43498
|
const searchQuery = {};
|
|
43146
43499
|
const nowSGT = (0, import_moment_timezone2.default)().tz("Asia/Singapore");
|
|
43147
|
-
searchQuery.serviceProviderId = new
|
|
43500
|
+
searchQuery.serviceProviderId = new import_mongodb117.ObjectId(serviceProviderId);
|
|
43148
43501
|
if (search != "") {
|
|
43149
43502
|
searchQuery.siteName = { $regex: search, $options: "i" };
|
|
43150
43503
|
}
|
|
@@ -43176,8 +43529,8 @@ function useManpowerRemarksRepo() {
|
|
|
43176
43529
|
}
|
|
43177
43530
|
async function getManpowerRemarksBySiteId(_id, date, serviceProviderId) {
|
|
43178
43531
|
try {
|
|
43179
|
-
_id = new
|
|
43180
|
-
serviceProviderId = new
|
|
43532
|
+
_id = new import_mongodb117.ObjectId(_id);
|
|
43533
|
+
serviceProviderId = new import_mongodb117.ObjectId(serviceProviderId);
|
|
43181
43534
|
} catch (error) {
|
|
43182
43535
|
throw new Error("Invalid Site ID format.");
|
|
43183
43536
|
}
|
|
@@ -43194,13 +43547,13 @@ function useManpowerRemarksRepo() {
|
|
|
43194
43547
|
}
|
|
43195
43548
|
async function updateManpowerRemarks(_id, value) {
|
|
43196
43549
|
try {
|
|
43197
|
-
_id = new
|
|
43550
|
+
_id = new import_mongodb117.ObjectId(_id);
|
|
43198
43551
|
} catch (error) {
|
|
43199
43552
|
throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
|
|
43200
43553
|
}
|
|
43201
43554
|
try {
|
|
43202
43555
|
if (value.createdBy) {
|
|
43203
|
-
value.createdBy = new
|
|
43556
|
+
value.createdBy = new import_mongodb117.ObjectId(value.createdBy);
|
|
43204
43557
|
}
|
|
43205
43558
|
const updateValue = {
|
|
43206
43559
|
...value,
|
|
@@ -43217,7 +43570,7 @@ function useManpowerRemarksRepo() {
|
|
|
43217
43570
|
}
|
|
43218
43571
|
async function updateRemarksStatus(_id, value) {
|
|
43219
43572
|
try {
|
|
43220
|
-
_id = new
|
|
43573
|
+
_id = new import_mongodb117.ObjectId(_id);
|
|
43221
43574
|
} catch (error) {
|
|
43222
43575
|
throw new import_node_server_utils197.BadRequestError("Invalid ID format.");
|
|
43223
43576
|
}
|
|
@@ -43489,7 +43842,7 @@ function useManpowerMonitoringCtrl() {
|
|
|
43489
43842
|
|
|
43490
43843
|
// src/models/manpower-designations.model.ts
|
|
43491
43844
|
var import_joi114 = __toESM(require("joi"));
|
|
43492
|
-
var
|
|
43845
|
+
var import_mongodb118 = require("mongodb");
|
|
43493
43846
|
var designationsSchema = import_joi114.default.object({
|
|
43494
43847
|
title: import_joi114.default.string().required(),
|
|
43495
43848
|
shifts: import_joi114.default.object({
|
|
@@ -43508,7 +43861,7 @@ var manpowerDesignationsSchema = import_joi114.default.object({
|
|
|
43508
43861
|
});
|
|
43509
43862
|
var MManpowerDesignations = class {
|
|
43510
43863
|
constructor(data) {
|
|
43511
|
-
this._id = new
|
|
43864
|
+
this._id = new import_mongodb118.ObjectId();
|
|
43512
43865
|
this.siteId = data.siteId || "";
|
|
43513
43866
|
this.siteName = data.siteName || "";
|
|
43514
43867
|
this.serviceProviderId = data.serviceProviderId || "";
|
|
@@ -43522,7 +43875,7 @@ var MManpowerDesignations = class {
|
|
|
43522
43875
|
|
|
43523
43876
|
// src/repositories/manpower-designations.repo.ts
|
|
43524
43877
|
var import_node_server_utils200 = require("@7365admin1/node-server-utils");
|
|
43525
|
-
var
|
|
43878
|
+
var import_mongodb119 = require("mongodb");
|
|
43526
43879
|
function useManpowerDesignationRepo() {
|
|
43527
43880
|
const db = import_node_server_utils200.useAtlas.getDb();
|
|
43528
43881
|
if (!db) {
|
|
@@ -43534,11 +43887,11 @@ function useManpowerDesignationRepo() {
|
|
|
43534
43887
|
try {
|
|
43535
43888
|
value = new MManpowerDesignations(value);
|
|
43536
43889
|
if (value.createdBy)
|
|
43537
|
-
value.createdBy = new
|
|
43890
|
+
value.createdBy = new import_mongodb119.ObjectId(value.createdBy);
|
|
43538
43891
|
if (value.siteId)
|
|
43539
|
-
value.siteId = new
|
|
43892
|
+
value.siteId = new import_mongodb119.ObjectId(value.siteId);
|
|
43540
43893
|
if (value.serviceProviderId)
|
|
43541
|
-
value.serviceProviderId = new
|
|
43894
|
+
value.serviceProviderId = new import_mongodb119.ObjectId(value.serviceProviderId);
|
|
43542
43895
|
const result = await collection.insertOne(value);
|
|
43543
43896
|
return result;
|
|
43544
43897
|
} catch (error) {
|
|
@@ -43547,8 +43900,8 @@ function useManpowerDesignationRepo() {
|
|
|
43547
43900
|
}
|
|
43548
43901
|
async function getManpowerDesignationsBySiteId(_id, serviceProviderId) {
|
|
43549
43902
|
try {
|
|
43550
|
-
_id = new
|
|
43551
|
-
serviceProviderId = new
|
|
43903
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
43904
|
+
serviceProviderId = new import_mongodb119.ObjectId(serviceProviderId);
|
|
43552
43905
|
} catch (error) {
|
|
43553
43906
|
throw new Error("Invalid Site ID format.");
|
|
43554
43907
|
}
|
|
@@ -43564,7 +43917,7 @@ function useManpowerDesignationRepo() {
|
|
|
43564
43917
|
}
|
|
43565
43918
|
async function updateManpowerDesignations(_id, value) {
|
|
43566
43919
|
try {
|
|
43567
|
-
_id = new
|
|
43920
|
+
_id = new import_mongodb119.ObjectId(_id);
|
|
43568
43921
|
} catch (error) {
|
|
43569
43922
|
throw new Error("Invalid ID format.");
|
|
43570
43923
|
}
|
|
@@ -43667,7 +44020,7 @@ function useManpowerDesignationCtrl() {
|
|
|
43667
44020
|
|
|
43668
44021
|
// src/models/overnight-parking.model.ts
|
|
43669
44022
|
var import_joi116 = __toESM(require("joi"));
|
|
43670
|
-
var
|
|
44023
|
+
var import_mongodb120 = require("mongodb");
|
|
43671
44024
|
var dayScheduleSchema = import_joi116.default.object({
|
|
43672
44025
|
isEnabled: import_joi116.default.boolean().required(),
|
|
43673
44026
|
startTime: import_joi116.default.string().pattern(/^([01]\d|2[0-3]):([0-5]\d)$/).optional().allow(null, "").messages({
|
|
@@ -43709,7 +44062,7 @@ function MOvernightParkingApprovalHours(value) {
|
|
|
43709
44062
|
}
|
|
43710
44063
|
if (value.site && typeof value.site === "string") {
|
|
43711
44064
|
try {
|
|
43712
|
-
value.site = new
|
|
44065
|
+
value.site = new import_mongodb120.ObjectId(value.site);
|
|
43713
44066
|
} catch {
|
|
43714
44067
|
throw new Error("Invalid site ID.");
|
|
43715
44068
|
}
|
|
@@ -45314,7 +45667,7 @@ function useManpowerRemarkCtrl() {
|
|
|
45314
45667
|
|
|
45315
45668
|
// src/models/manpower-sites.model.ts
|
|
45316
45669
|
var import_joi122 = __toESM(require("joi"));
|
|
45317
|
-
var
|
|
45670
|
+
var import_mongodb121 = require("mongodb");
|
|
45318
45671
|
var manpowerSitesSchema = import_joi122.default.object({
|
|
45319
45672
|
id: import_joi122.default.string().hex().required(),
|
|
45320
45673
|
text: import_joi122.default.string().hex().optional().allow("", null),
|
|
@@ -45325,7 +45678,7 @@ var manpowerSitesSchema = import_joi122.default.object({
|
|
|
45325
45678
|
});
|
|
45326
45679
|
var MManpowerSites = class {
|
|
45327
45680
|
constructor(data) {
|
|
45328
|
-
this._id = new
|
|
45681
|
+
this._id = new import_mongodb121.ObjectId();
|
|
45329
45682
|
this.id = data.id || "";
|
|
45330
45683
|
this.text = data.text || "";
|
|
45331
45684
|
this.contractID = data.contractID || "";
|
|
@@ -45535,7 +45888,7 @@ function useManpowerSitesCtrl() {
|
|
|
45535
45888
|
|
|
45536
45889
|
// src/utils/cron.util.ts
|
|
45537
45890
|
var import_node_server_utils214 = require("@7365admin1/node-server-utils");
|
|
45538
|
-
var
|
|
45891
|
+
var import_mongodb122 = require("mongodb");
|
|
45539
45892
|
var import_moment_timezone4 = __toESM(require("moment-timezone"));
|
|
45540
45893
|
var createManpowerRemarksDaily = async () => {
|
|
45541
45894
|
const db = import_node_server_utils214.useAtlas.getDb();
|
|
@@ -45695,7 +46048,7 @@ var updateRemarksisAcknowledged = async () => {
|
|
|
45695
46048
|
for (const id of updatedIds) {
|
|
45696
46049
|
const doc = await remarks.findOne({ _id: id });
|
|
45697
46050
|
const setting = await settings.findOne(
|
|
45698
|
-
{ siteId: new
|
|
46051
|
+
{ siteId: new import_mongodb122.ObjectId(doc?.siteId) },
|
|
45699
46052
|
{ projection: { emails: 1 } }
|
|
45700
46053
|
);
|
|
45701
46054
|
const payload = {
|
|
@@ -45781,7 +46134,7 @@ var updateRemarksStatusEod = async () => {
|
|
|
45781
46134
|
for (const doc of docs) {
|
|
45782
46135
|
let shiftsToCheck = [];
|
|
45783
46136
|
const endShiftTime = await settings.findOne(
|
|
45784
|
-
{ siteId: new
|
|
46137
|
+
{ siteId: new import_mongodb122.ObjectId(doc.siteId) },
|
|
45785
46138
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45786
46139
|
);
|
|
45787
46140
|
if (doc.createdAtSGT === nowSGT) {
|
|
@@ -45887,7 +46240,7 @@ var isWithinHour = (alertTime, timeNow) => {
|
|
|
45887
46240
|
|
|
45888
46241
|
// src/events/manpower.event.ts
|
|
45889
46242
|
var import_node_server_utils215 = require("@7365admin1/node-server-utils");
|
|
45890
|
-
var
|
|
46243
|
+
var import_mongodb123 = require("mongodb");
|
|
45891
46244
|
var import_moment_timezone5 = __toESM(require("moment-timezone"));
|
|
45892
46245
|
async function manpowerEvents(io) {
|
|
45893
46246
|
let intervalId = null;
|
|
@@ -45913,7 +46266,7 @@ async function manpowerEvents(io) {
|
|
|
45913
46266
|
}).toArray();
|
|
45914
46267
|
for (const doc of docs) {
|
|
45915
46268
|
const siteSettings = await settings.findOne(
|
|
45916
|
-
{ siteId: new
|
|
46269
|
+
{ siteId: new import_mongodb123.ObjectId(doc.siteId), enabled: true },
|
|
45917
46270
|
{ projection: { shifts: 1, shiftType: 1 } }
|
|
45918
46271
|
);
|
|
45919
46272
|
const shiftType = siteSettings?.shiftType || "2-shifts";
|
|
@@ -46032,7 +46385,7 @@ function genericSignature(params, secretKey) {
|
|
|
46032
46385
|
}
|
|
46033
46386
|
|
|
46034
46387
|
// src/repositories/reddot-payment.repository.ts
|
|
46035
|
-
var
|
|
46388
|
+
var import_mongodb127 = require("mongodb");
|
|
46036
46389
|
|
|
46037
46390
|
// src/utils/date-format.util.ts
|
|
46038
46391
|
var import_moment_timezone6 = __toESM(require("moment-timezone"));
|
|
@@ -46057,11 +46410,11 @@ function formatDateString(today, format, dateRange) {
|
|
|
46057
46410
|
}
|
|
46058
46411
|
|
|
46059
46412
|
// src/models/credit-card.model.ts
|
|
46060
|
-
var
|
|
46413
|
+
var import_mongodb124 = require("mongodb");
|
|
46061
46414
|
var MCardInfo = class {
|
|
46062
46415
|
// this is coming from RDP transaction
|
|
46063
46416
|
constructor({
|
|
46064
|
-
_id = new
|
|
46417
|
+
_id = new import_mongodb124.ObjectId(),
|
|
46065
46418
|
userId,
|
|
46066
46419
|
cardType,
|
|
46067
46420
|
cardNumber,
|
|
@@ -46096,11 +46449,11 @@ var MCardInfo = class {
|
|
|
46096
46449
|
};
|
|
46097
46450
|
|
|
46098
46451
|
// src/models/cart.model.ts
|
|
46099
|
-
var
|
|
46452
|
+
var import_mongodb125 = require("mongodb");
|
|
46100
46453
|
var MUnitBillings = class {
|
|
46101
46454
|
// transaction response messages
|
|
46102
46455
|
constructor({
|
|
46103
|
-
_id = new
|
|
46456
|
+
_id = new import_mongodb125.ObjectId(),
|
|
46104
46457
|
unit,
|
|
46105
46458
|
unitId,
|
|
46106
46459
|
unitBill,
|
|
@@ -46141,7 +46494,7 @@ var MUnitBillings = class {
|
|
|
46141
46494
|
};
|
|
46142
46495
|
|
|
46143
46496
|
// src/repositories/payment.repository.ts
|
|
46144
|
-
var
|
|
46497
|
+
var import_mongodb126 = require("mongodb");
|
|
46145
46498
|
var import_node_server_utils216 = require("@7365admin1/node-server-utils");
|
|
46146
46499
|
var PaymentBillRepo = () => {
|
|
46147
46500
|
const getDB2 = () => {
|
|
@@ -46175,7 +46528,7 @@ var PaymentBillRepo = () => {
|
|
|
46175
46528
|
if (unitBillInfo?.status === "Inactive" /* inactive */) {
|
|
46176
46529
|
throw new Error("This Bill is Inactive!");
|
|
46177
46530
|
}
|
|
46178
|
-
const billId = new
|
|
46531
|
+
const billId = new import_mongodb126.ObjectId(unitBillInfo?.billId);
|
|
46179
46532
|
const billInfo = await billCollection().findOne({ _id: billId });
|
|
46180
46533
|
if (!billInfo) {
|
|
46181
46534
|
throw new Error("Bill info not found");
|
|
@@ -46214,13 +46567,13 @@ var PaymentBillRepo = () => {
|
|
|
46214
46567
|
const saveCreditCardInfo = async (payload) => {
|
|
46215
46568
|
try {
|
|
46216
46569
|
if (payload.userId)
|
|
46217
|
-
payload.userId = new
|
|
46570
|
+
payload.userId = new import_mongodb126.ObjectId(payload.userId);
|
|
46218
46571
|
if (payload.site)
|
|
46219
|
-
payload.site = new
|
|
46572
|
+
payload.site = new import_mongodb126.ObjectId(payload.site);
|
|
46220
46573
|
if (payload.organization)
|
|
46221
|
-
payload.organization = new
|
|
46574
|
+
payload.organization = new import_mongodb126.ObjectId(payload.organization);
|
|
46222
46575
|
if (payload.createdBy)
|
|
46223
|
-
payload.createdBy = new
|
|
46576
|
+
payload.createdBy = new import_mongodb126.ObjectId(payload.createdBy);
|
|
46224
46577
|
const createdAt = formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46225
46578
|
payload.createdAt = createdAt;
|
|
46226
46579
|
const result = await creditCollection().insertOne(new MCardInfo(payload));
|
|
@@ -46232,19 +46585,19 @@ var PaymentBillRepo = () => {
|
|
|
46232
46585
|
const checkOutUnitBills = async (payload) => {
|
|
46233
46586
|
try {
|
|
46234
46587
|
if (payload.unitId)
|
|
46235
|
-
payload.unitId = new
|
|
46588
|
+
payload.unitId = new import_mongodb126.ObjectId(payload.unitId);
|
|
46236
46589
|
if (payload.site)
|
|
46237
|
-
payload.site = new
|
|
46590
|
+
payload.site = new import_mongodb126.ObjectId(payload.site);
|
|
46238
46591
|
if (payload.organization)
|
|
46239
|
-
payload.organization = new
|
|
46592
|
+
payload.organization = new import_mongodb126.ObjectId(payload.organization);
|
|
46240
46593
|
payload.createdAt = await formatDateString(/* @__PURE__ */ new Date(), "mm-dd-yyyy");
|
|
46241
46594
|
const addToCart = await cartCollection().insertOne(new MUnitBillings(payload));
|
|
46242
46595
|
const unitId = payload.unitId;
|
|
46243
46596
|
const dateFormatted = formatDateString(/* @__PURE__ */ new Date(), "for-ref");
|
|
46244
46597
|
const unit = unitId?.toString().slice(-4);
|
|
46245
|
-
const newId = new
|
|
46598
|
+
const newId = new import_mongodb126.ObjectId(addToCart?.insertedId).toString().slice(-4);
|
|
46246
46599
|
const referenceNumber = `CRT${unit}${newId}${dateFormatted}`;
|
|
46247
|
-
const result = await cartCollection().findOneAndUpdate({ _id: new
|
|
46600
|
+
const result = await cartCollection().findOneAndUpdate({ _id: new import_mongodb126.ObjectId(addToCart.insertedId) }, { $set: { referenceNumber } }, { returnDocument: "after" });
|
|
46248
46601
|
return result;
|
|
46249
46602
|
} catch (error) {
|
|
46250
46603
|
throw new Error(error.message || error || "Server Internal Error");
|
|
@@ -46275,7 +46628,7 @@ var PaymentBillRepo = () => {
|
|
|
46275
46628
|
for (const ref of refNumber) {
|
|
46276
46629
|
const unitBillInfo = await collection().findOne({ referenceNumber: ref });
|
|
46277
46630
|
const billId = unitBillInfo?.billId;
|
|
46278
|
-
const billInfo = await billCollection().findOne({ _id: new
|
|
46631
|
+
const billInfo = await billCollection().findOne({ _id: new import_mongodb126.ObjectId(billId) });
|
|
46279
46632
|
const billAmount = billInfo?.price;
|
|
46280
46633
|
payload.updatedAt = updatedAt;
|
|
46281
46634
|
payload.amountPaid = billAmount;
|
|
@@ -46426,7 +46779,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46426
46779
|
throw new Error("Failed to Add Merchant Details");
|
|
46427
46780
|
}
|
|
46428
46781
|
const merchantId = merchant?.insertedId;
|
|
46429
|
-
const orgId = new
|
|
46782
|
+
const orgId = new import_mongodb127.ObjectId(_id);
|
|
46430
46783
|
const result = await orgCollection().findOneAndUpdate({ _id: orgId }, { $push: { merchant: merchantId } }, {
|
|
46431
46784
|
returnDocument: "after"
|
|
46432
46785
|
});
|
|
@@ -46455,7 +46808,7 @@ var useRedDotPaymentRepo = () => {
|
|
|
46455
46808
|
const getMerchantDetailsById = async (_id) => {
|
|
46456
46809
|
try {
|
|
46457
46810
|
if (_id)
|
|
46458
|
-
_id = new
|
|
46811
|
+
_id = new import_mongodb127.ObjectId(_id);
|
|
46459
46812
|
const result = await redDotMerchantCollection().aggregate([
|
|
46460
46813
|
{
|
|
46461
46814
|
$match: {
|
|
@@ -46710,7 +47063,7 @@ function useRedDotPaymentController() {
|
|
|
46710
47063
|
|
|
46711
47064
|
// src/repositories/verification-v2.repo.ts
|
|
46712
47065
|
var import_node_server_utils218 = require("@7365admin1/node-server-utils");
|
|
46713
|
-
var
|
|
47066
|
+
var import_mongodb128 = require("mongodb");
|
|
46714
47067
|
function useVerificationRepoV2() {
|
|
46715
47068
|
const db = import_node_server_utils218.useAtlas.getDb();
|
|
46716
47069
|
if (!db) {
|
|
@@ -46763,7 +47116,7 @@ function useVerificationRepoV2() {
|
|
|
46763
47116
|
}
|
|
46764
47117
|
async function updateVerificationStatusById(_id, status, session) {
|
|
46765
47118
|
try {
|
|
46766
|
-
_id = new
|
|
47119
|
+
_id = new import_mongodb128.ObjectId(_id);
|
|
46767
47120
|
} catch (error) {
|
|
46768
47121
|
throw new import_node_server_utils218.BadRequestError("Invalid verification ID format.");
|
|
46769
47122
|
}
|
|
@@ -46906,7 +47259,7 @@ function useVerificationRepoV2() {
|
|
|
46906
47259
|
}
|
|
46907
47260
|
async function updateStatusById(_id, status, session) {
|
|
46908
47261
|
try {
|
|
46909
|
-
_id = new
|
|
47262
|
+
_id = new import_mongodb128.ObjectId(_id);
|
|
46910
47263
|
} catch (error) {
|
|
46911
47264
|
throw new import_node_server_utils218.BadRequestError("Invalid verification ID format.");
|
|
46912
47265
|
}
|
|
@@ -47492,7 +47845,7 @@ var import_node_server_utils222 = require("@7365admin1/node-server-utils");
|
|
|
47492
47845
|
var import_uuid2 = require("uuid");
|
|
47493
47846
|
|
|
47494
47847
|
// src/repositories/user-v2.repo.ts
|
|
47495
|
-
var
|
|
47848
|
+
var import_mongodb129 = require("mongodb");
|
|
47496
47849
|
var import_node_server_utils221 = require("@7365admin1/node-server-utils");
|
|
47497
47850
|
function useUserRepoV2() {
|
|
47498
47851
|
const { updateFeedbackCreatedByName } = useFeedbackRepo();
|
|
@@ -47693,7 +48046,7 @@ function useUserRepoV2() {
|
|
|
47693
48046
|
}
|
|
47694
48047
|
if (organization) {
|
|
47695
48048
|
try {
|
|
47696
|
-
query.defaultOrg = new
|
|
48049
|
+
query.defaultOrg = new import_mongodb129.ObjectId(organization);
|
|
47697
48050
|
cacheOptions.organization = organization.toString();
|
|
47698
48051
|
} catch (error) {
|
|
47699
48052
|
throw new import_node_server_utils221.BadRequestError("Invalid organization ID format.");
|
|
@@ -47832,13 +48185,13 @@ function useUserRepoV2() {
|
|
|
47832
48185
|
);
|
|
47833
48186
|
}
|
|
47834
48187
|
try {
|
|
47835
|
-
_id = new
|
|
48188
|
+
_id = new import_mongodb129.ObjectId(_id);
|
|
47836
48189
|
} catch (error) {
|
|
47837
48190
|
throw new import_node_server_utils221.BadRequestError("Invalid ID.");
|
|
47838
48191
|
}
|
|
47839
48192
|
if (field === "defaultOrg") {
|
|
47840
48193
|
try {
|
|
47841
|
-
value = new
|
|
48194
|
+
value = new import_mongodb129.ObjectId(value);
|
|
47842
48195
|
} catch (error) {
|
|
47843
48196
|
throw new import_node_server_utils221.BadRequestError("Invalid organization ID.");
|
|
47844
48197
|
}
|
|
@@ -47879,7 +48232,7 @@ function useUserRepoV2() {
|
|
|
47879
48232
|
year
|
|
47880
48233
|
}, session) {
|
|
47881
48234
|
try {
|
|
47882
|
-
_id = new
|
|
48235
|
+
_id = new import_mongodb129.ObjectId(_id);
|
|
47883
48236
|
} catch (error) {
|
|
47884
48237
|
throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
|
|
47885
48238
|
}
|
|
@@ -47909,7 +48262,7 @@ function useUserRepoV2() {
|
|
|
47909
48262
|
}
|
|
47910
48263
|
async function updatePassword({ _id, password }, session) {
|
|
47911
48264
|
try {
|
|
47912
|
-
_id = new
|
|
48265
|
+
_id = new import_mongodb129.ObjectId(_id);
|
|
47913
48266
|
} catch (error) {
|
|
47914
48267
|
throw new import_node_server_utils221.BadRequestError("Invalid user ID format.");
|
|
47915
48268
|
}
|
|
@@ -48004,9 +48357,25 @@ function useAuthServiceV2() {
|
|
|
48004
48357
|
throw new import_node_server_utils222.InternalServerError("Error deleting token");
|
|
48005
48358
|
}
|
|
48006
48359
|
}
|
|
48360
|
+
async function verifyPassword(_id, password) {
|
|
48361
|
+
try {
|
|
48362
|
+
const user = await _getUserById(_id);
|
|
48363
|
+
const isPasswordMatch = await (0, import_node_server_utils222.comparePassword)(password, user.password);
|
|
48364
|
+
if (!isPasswordMatch) {
|
|
48365
|
+
throw new import_node_server_utils222.BadRequestError("Invalid credentials");
|
|
48366
|
+
}
|
|
48367
|
+
return "Verification successful.";
|
|
48368
|
+
} catch (error) {
|
|
48369
|
+
if (error instanceof import_node_server_utils222.BadRequestError) {
|
|
48370
|
+
throw error;
|
|
48371
|
+
}
|
|
48372
|
+
throw new import_node_server_utils222.InternalServerError("Error during password verification");
|
|
48373
|
+
}
|
|
48374
|
+
}
|
|
48007
48375
|
return {
|
|
48008
48376
|
login,
|
|
48009
|
-
logout
|
|
48377
|
+
logout,
|
|
48378
|
+
verifyPassword
|
|
48010
48379
|
};
|
|
48011
48380
|
}
|
|
48012
48381
|
|
|
@@ -48214,7 +48583,11 @@ function useUserServiceV2() {
|
|
|
48214
48583
|
// src/controllers/auth-v2.controller.ts
|
|
48215
48584
|
function useAuthControllerV2() {
|
|
48216
48585
|
const { signUp: _signUp } = useVerificationServiceV2();
|
|
48217
|
-
const {
|
|
48586
|
+
const {
|
|
48587
|
+
login: _login,
|
|
48588
|
+
logout: _logout,
|
|
48589
|
+
verifyPassword: _verifyPassword
|
|
48590
|
+
} = useAuthServiceV2();
|
|
48218
48591
|
const { resetPassword: _resetPassword } = useUserServiceV2();
|
|
48219
48592
|
async function signUp(req, res, next) {
|
|
48220
48593
|
try {
|
|
@@ -48328,11 +48701,38 @@ function useAuthControllerV2() {
|
|
|
48328
48701
|
return;
|
|
48329
48702
|
}
|
|
48330
48703
|
}
|
|
48704
|
+
async function verifyPassword(req, res, next) {
|
|
48705
|
+
const schema2 = import_joi127.default.object({
|
|
48706
|
+
_id: import_joi127.default.string().hex().required(),
|
|
48707
|
+
password: import_joi127.default.string().required().min(8)
|
|
48708
|
+
});
|
|
48709
|
+
const { error, value } = schema2.validate(
|
|
48710
|
+
{ _id: req.params.id, ...req.body },
|
|
48711
|
+
{ abortEarly: false }
|
|
48712
|
+
);
|
|
48713
|
+
if (error) {
|
|
48714
|
+
const messages = error.details.map((d) => d.message);
|
|
48715
|
+
import_node_server_utils224.logger.log({ level: "error", message: messages.join(", ") });
|
|
48716
|
+
next(new import_node_server_utils224.BadRequestError(messages.join(", ")));
|
|
48717
|
+
return;
|
|
48718
|
+
}
|
|
48719
|
+
const { _id, password } = value;
|
|
48720
|
+
try {
|
|
48721
|
+
const message = await _verifyPassword(_id, password);
|
|
48722
|
+
res.json({ message });
|
|
48723
|
+
return;
|
|
48724
|
+
} catch (error2) {
|
|
48725
|
+
import_node_server_utils224.logger.log({ level: "error", message: error2.message });
|
|
48726
|
+
next(error2);
|
|
48727
|
+
return;
|
|
48728
|
+
}
|
|
48729
|
+
}
|
|
48331
48730
|
return {
|
|
48332
48731
|
signUp,
|
|
48333
48732
|
login,
|
|
48334
48733
|
logout,
|
|
48335
|
-
resetPassword
|
|
48734
|
+
resetPassword,
|
|
48735
|
+
verifyPassword
|
|
48336
48736
|
};
|
|
48337
48737
|
}
|
|
48338
48738
|
|
|
@@ -48756,6 +49156,7 @@ function useUserControllerV2() {
|
|
|
48756
49156
|
remarksSchema,
|
|
48757
49157
|
robotSchema,
|
|
48758
49158
|
schema,
|
|
49159
|
+
schemaApprovedBy,
|
|
48759
49160
|
schemaBilling,
|
|
48760
49161
|
schemaBillingConfiguration,
|
|
48761
49162
|
schemaBillingItem,
|