@7365admin1/core 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +38 -7
- package/dist/index.js +191 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +252 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1805,6 +1805,14 @@ function useOccurrenceEntryRepo() {
|
|
|
1805
1805
|
throw new Error("Invalid signature ID.");
|
|
1806
1806
|
}
|
|
1807
1807
|
}
|
|
1808
|
+
if (value.incidentReportId && typeof value.incidentReportId === "string") {
|
|
1809
|
+
try {
|
|
1810
|
+
value.incidentReportId = new ObjectId7(value.incidentReportId);
|
|
1811
|
+
} catch {
|
|
1812
|
+
throw new Error("Invalid incident report ID.");
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
console.log("Updating occurrence entry:", _id, value);
|
|
1808
1816
|
try {
|
|
1809
1817
|
const res = await collection.updateOne(
|
|
1810
1818
|
{ _id },
|
|
@@ -12905,8 +12913,8 @@ var schemaBuildingUnit = Joi38.object({
|
|
|
12905
12913
|
buildingUnitFiles: Joi38.array().items(Joi38.string()).optional().allow("", null),
|
|
12906
12914
|
companyName: Joi38.string().optional().allow("", null),
|
|
12907
12915
|
companyRegistrationNumber: Joi38.string().optional().allow("", null),
|
|
12908
|
-
leaseStart: Joi38.date().
|
|
12909
|
-
leaseEnd: Joi38.date().
|
|
12916
|
+
leaseStart: Joi38.date().optional(),
|
|
12917
|
+
leaseEnd: Joi38.date().optional(),
|
|
12910
12918
|
owner: Joi38.string().hex().optional().allow("", null),
|
|
12911
12919
|
ownerName: Joi38.string().optional().allow("", null),
|
|
12912
12920
|
billing: Joi38.array().items(schemaBilling).optional().allow("", null)
|
|
@@ -14276,8 +14284,8 @@ function useBuildingUnitController() {
|
|
|
14276
14284
|
buildingUnitFiles: Joi40.array().items(Joi40.string()).optional(),
|
|
14277
14285
|
companyName: Joi40.string().optional().allow("", null),
|
|
14278
14286
|
companyRegistrationNumber: Joi40.string().optional().allow("", null),
|
|
14279
|
-
leaseStart: Joi40.date().
|
|
14280
|
-
leaseEnd: Joi40.date().
|
|
14287
|
+
leaseStart: Joi40.date().optional(),
|
|
14288
|
+
leaseEnd: Joi40.date().optional()
|
|
14281
14289
|
}),
|
|
14282
14290
|
qty: Joi40.number().integer().min(1).max(20).optional().default(1)
|
|
14283
14291
|
});
|
|
@@ -17514,7 +17522,11 @@ function useAttendanceSettingsRepository() {
|
|
|
17514
17522
|
isLocationEnabled: 1,
|
|
17515
17523
|
location: 1,
|
|
17516
17524
|
isGeofencingEnabled: 1,
|
|
17517
|
-
mile: 1
|
|
17525
|
+
mile: 1,
|
|
17526
|
+
postalCode: 1,
|
|
17527
|
+
country: 1,
|
|
17528
|
+
city: 1,
|
|
17529
|
+
address: 1
|
|
17518
17530
|
}
|
|
17519
17531
|
}
|
|
17520
17532
|
]).toArray();
|
|
@@ -29896,6 +29908,7 @@ function useStatementOfAccountService() {
|
|
|
29896
29908
|
try {
|
|
29897
29909
|
const browser = await launch({
|
|
29898
29910
|
headless: true,
|
|
29911
|
+
executablePath: process.env.CHROME_BINARY,
|
|
29899
29912
|
args: [`--no-sandbox`, `--disable-gpu`, `--disable-dev-shm-usage`]
|
|
29900
29913
|
});
|
|
29901
29914
|
const page = await browser.newPage();
|
|
@@ -31552,6 +31565,27 @@ var actionStatusSchema = Joi99.object({
|
|
|
31552
31565
|
status: Joi99.string().optional(),
|
|
31553
31566
|
time: Joi99.string().optional()
|
|
31554
31567
|
});
|
|
31568
|
+
var affectedInjuredStatusSchema = Joi99.object({
|
|
31569
|
+
name: Joi99.string().required(),
|
|
31570
|
+
contact: Joi99.string().optional().allow(null, ""),
|
|
31571
|
+
nric: Joi99.string().optional().allow(null, "")
|
|
31572
|
+
});
|
|
31573
|
+
var anyoneDamageToPropertyStatusSchema = Joi99.object({
|
|
31574
|
+
description: Joi99.string().optional().allow(null, ""),
|
|
31575
|
+
block: Joi99.number().optional().allow(null, ""),
|
|
31576
|
+
level: Joi99.string().optional().allow(null, ""),
|
|
31577
|
+
unit: Joi99.string().optional().allow(null, ""),
|
|
31578
|
+
blkLevelUnit: Joi99.string().optional().allow(null, ""),
|
|
31579
|
+
name: Joi99.string().optional().allow(null, ""),
|
|
31580
|
+
contact: Joi99.string().optional().allow(null, "")
|
|
31581
|
+
});
|
|
31582
|
+
var authoritiesCalledStatusSchema = Joi99.object({
|
|
31583
|
+
type: Joi99.string().optional().allow(null, ""),
|
|
31584
|
+
vehicleNumber: Joi99.string().optional().allow(null, ""),
|
|
31585
|
+
personInCharge: Joi99.string().optional().allow(null, ""),
|
|
31586
|
+
caseReportReference: Joi99.string().optional().allow(null, ""),
|
|
31587
|
+
description: Joi99.string().optional().allow(null, "")
|
|
31588
|
+
});
|
|
31555
31589
|
var schemaIncidentReport = Joi99.object({
|
|
31556
31590
|
reportId: Joi99.string().required(),
|
|
31557
31591
|
incidentInformation: Joi99.object({
|
|
@@ -31564,7 +31598,7 @@ var schemaIncidentReport = Joi99.object({
|
|
|
31564
31598
|
placeOfIncident: Joi99.object({
|
|
31565
31599
|
block: Joi99.number().optional().allow(null, ""),
|
|
31566
31600
|
level: Joi99.string().optional().allow(null, ""),
|
|
31567
|
-
unit: Joi99.string().
|
|
31601
|
+
unit: Joi99.string().optional().allow(null, ""),
|
|
31568
31602
|
other: Joi99.string().allow(null, "").optional().allow(null, ""),
|
|
31569
31603
|
isOther: Joi99.boolean().required(),
|
|
31570
31604
|
incidentLocation: Joi99.string().optional().allow(null, "")
|
|
@@ -31601,13 +31635,13 @@ var schemaIncidentReport = Joi99.object({
|
|
|
31601
31635
|
anyUnitAffectedValue: Joi99.string().valid("yes", "no").required(),
|
|
31602
31636
|
affectedUnit: Joi99.any().optional(),
|
|
31603
31637
|
anyoneAffectedValue: Joi99.string().valid("yes", "no").required(),
|
|
31604
|
-
affectedInjured: Joi99.array().items(
|
|
31638
|
+
affectedInjured: Joi99.array().items(affectedInjuredStatusSchema).optional().allow(null, ""),
|
|
31605
31639
|
anyPropertyAffectedValue: Joi99.string().valid("yes", "no").required(),
|
|
31606
|
-
anyoneDamageToProperty: Joi99.array().items(
|
|
31607
|
-
}).
|
|
31640
|
+
anyoneDamageToProperty: Joi99.array().items(anyoneDamageToPropertyStatusSchema).optional()
|
|
31641
|
+
}).optional().allow(null, ""),
|
|
31608
31642
|
authorities: Joi99.object({
|
|
31609
31643
|
authoritiesValue: Joi99.string().valid("yes", "no").required(),
|
|
31610
|
-
authoritiesCalled: Joi99.array().items(
|
|
31644
|
+
authoritiesCalled: Joi99.array().items(authoritiesCalledStatusSchema).optional().allow(null, ""),
|
|
31611
31645
|
incidentThereAfter: Joi99.string().optional().allow("", null),
|
|
31612
31646
|
managementNotified: actionStatusSchema.optional(),
|
|
31613
31647
|
incidentResolved: Joi99.string().optional().allow("", null),
|
|
@@ -31631,7 +31665,7 @@ var schemaIncidentReport = Joi99.object({
|
|
|
31631
31665
|
photos: Joi99.array().items(Joi99.string()).optional(),
|
|
31632
31666
|
approvedBy: Joi99.string().hex().allow(null, "").optional(),
|
|
31633
31667
|
approvedByName: Joi99.string().optional().allow("", null),
|
|
31634
|
-
|
|
31668
|
+
remarks: Joi99.string().optional().allow("", null),
|
|
31635
31669
|
status: Joi99.string().valid("pending", "approved", "rejected").default("pending")
|
|
31636
31670
|
});
|
|
31637
31671
|
var schemaUpdateIncidentReport = Joi99.object({
|
|
@@ -31646,7 +31680,7 @@ var schemaUpdateIncidentReport = Joi99.object({
|
|
|
31646
31680
|
placeOfIncident: Joi99.object({
|
|
31647
31681
|
block: Joi99.number().optional().allow(null, ""),
|
|
31648
31682
|
level: Joi99.string().optional().allow(null, ""),
|
|
31649
|
-
unit: Joi99.string().
|
|
31683
|
+
unit: Joi99.string().optional().allow(null, ""),
|
|
31650
31684
|
other: Joi99.string().allow(null, "").optional().allow(null, ""),
|
|
31651
31685
|
isOther: Joi99.boolean().allow(null, ""),
|
|
31652
31686
|
incidentLocation: Joi99.string().optional().allow(null, "")
|
|
@@ -31683,13 +31717,13 @@ var schemaUpdateIncidentReport = Joi99.object({
|
|
|
31683
31717
|
anyUnitAffectedValue: Joi99.string().valid("yes", "no").allow(null, ""),
|
|
31684
31718
|
affectedUnit: Joi99.any().optional(),
|
|
31685
31719
|
anyoneAffectedValue: Joi99.string().valid("yes", "no").allow(null, ""),
|
|
31686
|
-
affectedInjured: Joi99.array().items(
|
|
31720
|
+
affectedInjured: Joi99.array().items(affectedInjuredStatusSchema).optional().allow(null, ""),
|
|
31687
31721
|
anyPropertyAffectedValue: Joi99.string().valid("yes", "no").allow(null, ""),
|
|
31688
|
-
anyoneDamageToProperty: Joi99.array().items(
|
|
31689
|
-
}).allow(null, ""),
|
|
31722
|
+
anyoneDamageToProperty: Joi99.array().items(anyoneDamageToPropertyStatusSchema).optional().allow(null, "")
|
|
31723
|
+
}).optional().allow(null, ""),
|
|
31690
31724
|
authorities: Joi99.object({
|
|
31691
31725
|
authoritiesValue: Joi99.string().valid("yes", "no").allow(null, ""),
|
|
31692
|
-
authoritiesCalled: Joi99.array().items(
|
|
31726
|
+
authoritiesCalled: Joi99.array().items(authoritiesCalledStatusSchema).optional().allow(null, ""),
|
|
31693
31727
|
incidentThereAfter: Joi99.string().optional().allow("", null),
|
|
31694
31728
|
managementNotified: actionStatusSchema.optional(),
|
|
31695
31729
|
incidentResolved: Joi99.string().optional().allow("", null),
|
|
@@ -31713,7 +31747,7 @@ var schemaUpdateIncidentReport = Joi99.object({
|
|
|
31713
31747
|
photos: Joi99.array().items(Joi99.string()).optional(),
|
|
31714
31748
|
approvedBy: Joi99.string().hex().allow(null, "").optional(),
|
|
31715
31749
|
approvedByName: Joi99.string().optional().allow("", null),
|
|
31716
|
-
|
|
31750
|
+
remarks: Joi99.string().optional().allow("", null),
|
|
31717
31751
|
status: Joi99.string().valid("pending", "approved", "rejected").default("pending")
|
|
31718
31752
|
});
|
|
31719
31753
|
function MIncidentReport(value) {
|
|
@@ -31755,14 +31789,6 @@ function MIncidentReport(value) {
|
|
|
31755
31789
|
throw new Error("Invalid siteInfo.site ID.");
|
|
31756
31790
|
}
|
|
31757
31791
|
}
|
|
31758
|
-
const place = incidentInformation?.placeOfIncident;
|
|
31759
|
-
if (place?.unit && typeof place.unit === "string") {
|
|
31760
|
-
try {
|
|
31761
|
-
place.unit = new ObjectId96(place.unit);
|
|
31762
|
-
} catch {
|
|
31763
|
-
throw new Error("Invalid unit ID.");
|
|
31764
|
-
}
|
|
31765
|
-
}
|
|
31766
31792
|
if (incidentInformation?.incidentTypeAndTime?.dateOfIncident && typeof incidentInformation.incidentTypeAndTime.dateOfIncident !== "string") {
|
|
31767
31793
|
incidentInformation.incidentTypeAndTime.dateOfIncident = incidentInformation.incidentTypeAndTime.dateOfIncident.toISOString();
|
|
31768
31794
|
}
|
|
@@ -31784,7 +31810,7 @@ function MIncidentReport(value) {
|
|
|
31784
31810
|
photos: value.photos ?? [],
|
|
31785
31811
|
approvedBy: value.approvedBy ?? null,
|
|
31786
31812
|
approvedByName: value.approvedByName ?? "",
|
|
31787
|
-
|
|
31813
|
+
remarks: value.remarks ?? null,
|
|
31788
31814
|
status: value.status ?? "pending",
|
|
31789
31815
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
31790
31816
|
updatedAt: value.updatedAt,
|
|
@@ -31793,7 +31819,7 @@ function MIncidentReport(value) {
|
|
|
31793
31819
|
}
|
|
31794
31820
|
|
|
31795
31821
|
// src/services/incident-report.service.ts
|
|
31796
|
-
import { useAtlas as useAtlas88 } from "@7365admin1/node-server-utils";
|
|
31822
|
+
import { useAtlas as useAtlas88, BadRequestError as BadRequestError160 } from "@7365admin1/node-server-utils";
|
|
31797
31823
|
|
|
31798
31824
|
// src/repositories/incident-report.repo.ts
|
|
31799
31825
|
import {
|
|
@@ -31992,6 +32018,37 @@ function useIncidentReportRepo() {
|
|
|
31992
32018
|
} catch (error) {
|
|
31993
32019
|
throw new BadRequestError159("Invalid ID format.");
|
|
31994
32020
|
}
|
|
32021
|
+
if (value.organization && typeof value.organization === "string") {
|
|
32022
|
+
try {
|
|
32023
|
+
value.organization = new ObjectId97(value.organization);
|
|
32024
|
+
} catch {
|
|
32025
|
+
throw new Error("Invalid organization ID.");
|
|
32026
|
+
}
|
|
32027
|
+
}
|
|
32028
|
+
if (value.site && typeof value.site === "string") {
|
|
32029
|
+
try {
|
|
32030
|
+
value.site = new ObjectId97(value.site);
|
|
32031
|
+
} catch {
|
|
32032
|
+
throw new Error("Invalid site ID.");
|
|
32033
|
+
}
|
|
32034
|
+
}
|
|
32035
|
+
if (value.approvedBy && typeof value.approvedBy === "string") {
|
|
32036
|
+
try {
|
|
32037
|
+
value.approvedBy = new ObjectId97(value.approvedBy);
|
|
32038
|
+
} catch {
|
|
32039
|
+
throw new Error("Invalid approvedBy ID.");
|
|
32040
|
+
}
|
|
32041
|
+
}
|
|
32042
|
+
const { incidentInformation } = value;
|
|
32043
|
+
if (incidentInformation?.siteInfo?.site && typeof incidentInformation.siteInfo.site === "string") {
|
|
32044
|
+
try {
|
|
32045
|
+
incidentInformation.siteInfo.site = new ObjectId97(
|
|
32046
|
+
incidentInformation.siteInfo.site
|
|
32047
|
+
);
|
|
32048
|
+
} catch {
|
|
32049
|
+
throw new Error("Invalid siteInfo.site ID.");
|
|
32050
|
+
}
|
|
32051
|
+
}
|
|
31995
32052
|
try {
|
|
31996
32053
|
const res = await collection.updateOne(
|
|
31997
32054
|
{ _id },
|
|
@@ -32045,6 +32102,37 @@ function useIncidentReportRepo() {
|
|
|
32045
32102
|
throw error;
|
|
32046
32103
|
}
|
|
32047
32104
|
}
|
|
32105
|
+
async function reviewIncidentReport(_id, value, session) {
|
|
32106
|
+
value.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
32107
|
+
try {
|
|
32108
|
+
_id = new ObjectId97(_id);
|
|
32109
|
+
} catch (error) {
|
|
32110
|
+
throw new BadRequestError159("Invalid ID format.");
|
|
32111
|
+
}
|
|
32112
|
+
try {
|
|
32113
|
+
const res = await collection.updateOne(
|
|
32114
|
+
{ _id },
|
|
32115
|
+
{ $set: value },
|
|
32116
|
+
{ session }
|
|
32117
|
+
);
|
|
32118
|
+
if (res.modifiedCount === 0) {
|
|
32119
|
+
throw new InternalServerError55(
|
|
32120
|
+
`Unable to ${value.status} incident report.`
|
|
32121
|
+
);
|
|
32122
|
+
}
|
|
32123
|
+
delNamespace().then(() => {
|
|
32124
|
+
logger139.info(`Cache cleared for namespace: ${namespace_collection}`);
|
|
32125
|
+
}).catch((err) => {
|
|
32126
|
+
logger139.error(
|
|
32127
|
+
`Failed to clear cache for namespace: ${namespace_collection}`,
|
|
32128
|
+
err
|
|
32129
|
+
);
|
|
32130
|
+
});
|
|
32131
|
+
return res;
|
|
32132
|
+
} catch (error) {
|
|
32133
|
+
throw error;
|
|
32134
|
+
}
|
|
32135
|
+
}
|
|
32048
32136
|
return {
|
|
32049
32137
|
add,
|
|
32050
32138
|
getAll,
|
|
@@ -32052,18 +32140,24 @@ function useIncidentReportRepo() {
|
|
|
32052
32140
|
updateIncidentReportById,
|
|
32053
32141
|
deleteIncidentReportById,
|
|
32054
32142
|
createIndexes,
|
|
32055
|
-
createTextIndex
|
|
32143
|
+
createTextIndex,
|
|
32144
|
+
reviewIncidentReport
|
|
32056
32145
|
};
|
|
32057
32146
|
}
|
|
32058
32147
|
|
|
32059
32148
|
// src/services/incident-report.service.ts
|
|
32060
32149
|
import OpenAI from "openai";
|
|
32061
32150
|
function useIncidentReportService() {
|
|
32062
|
-
const {
|
|
32151
|
+
const {
|
|
32152
|
+
add: _add,
|
|
32153
|
+
updateIncidentReportById: _updateIncidentReportById,
|
|
32154
|
+
reviewIncidentReport: _reviewIncidentReport
|
|
32155
|
+
} = useIncidentReportRepo();
|
|
32063
32156
|
const {
|
|
32064
32157
|
updateSiteIncidentCounter: _updateSiteIncidentCounter,
|
|
32065
32158
|
getSiteById: _getSiteById
|
|
32066
32159
|
} = useSiteRepo();
|
|
32160
|
+
const { getUserById } = useUserRepo();
|
|
32067
32161
|
const { getById: _getUnitById } = useBuildingUnitRepo();
|
|
32068
32162
|
const { getById: _getOrganizationById } = useOrgRepo();
|
|
32069
32163
|
async function add(value) {
|
|
@@ -32083,23 +32177,9 @@ function useIncidentReportService() {
|
|
|
32083
32177
|
);
|
|
32084
32178
|
}
|
|
32085
32179
|
}
|
|
32086
|
-
|
|
32087
|
-
const unit = await _getUnitById(
|
|
32088
|
-
value.incidentInformation.placeOfIncident.unit,
|
|
32089
|
-
session
|
|
32090
|
-
);
|
|
32091
|
-
if (!unit) {
|
|
32092
|
-
throw new Error(
|
|
32093
|
-
"Building unit not found for the provided place of incident."
|
|
32094
|
-
);
|
|
32095
|
-
}
|
|
32096
|
-
value.incidentInformation.placeOfIncident.incidentLocation = value.incidentInformation.placeOfIncident.block?.toString() + "-" + value.incidentInformation.placeOfIncident.level + "-" + unit?.name;
|
|
32097
|
-
} else {
|
|
32098
|
-
value.incidentInformation.placeOfIncident.incidentLocation = value.incidentInformation.placeOfIncident.other;
|
|
32099
|
-
}
|
|
32100
|
-
await _add(value, session);
|
|
32180
|
+
const result = await _add(value, session);
|
|
32101
32181
|
await session?.commitTransaction();
|
|
32102
|
-
return
|
|
32182
|
+
return result;
|
|
32103
32183
|
} catch (error) {
|
|
32104
32184
|
await session?.abortTransaction();
|
|
32105
32185
|
throw error;
|
|
@@ -32146,19 +32226,10 @@ function useIncidentReportService() {
|
|
|
32146
32226
|
value.site = site.name;
|
|
32147
32227
|
}
|
|
32148
32228
|
}
|
|
32149
|
-
if (value?.
|
|
32150
|
-
const
|
|
32151
|
-
|
|
32152
|
-
|
|
32153
|
-
);
|
|
32154
|
-
if (unit) {
|
|
32155
|
-
value.incidentInformation.placeOfIncident.unit = unit.name;
|
|
32156
|
-
}
|
|
32157
|
-
if (value?.organization) {
|
|
32158
|
-
const org = await _getOrganizationById(value.organization);
|
|
32159
|
-
if (org) {
|
|
32160
|
-
value.organization = org.name;
|
|
32161
|
-
}
|
|
32229
|
+
if (value?.organization) {
|
|
32230
|
+
const org = await _getOrganizationById(value.organization);
|
|
32231
|
+
if (org) {
|
|
32232
|
+
value.organization = org.name;
|
|
32162
32233
|
}
|
|
32163
32234
|
}
|
|
32164
32235
|
const completion = await openai.chat.completions.create({
|
|
@@ -32181,21 +32252,44 @@ function useIncidentReportService() {
|
|
|
32181
32252
|
throw error;
|
|
32182
32253
|
}
|
|
32183
32254
|
}
|
|
32255
|
+
async function reviewIncidentReport(id, value) {
|
|
32256
|
+
const session = useAtlas88.getClient()?.startSession();
|
|
32257
|
+
session?.startTransaction();
|
|
32258
|
+
try {
|
|
32259
|
+
if (value.approvedBy) {
|
|
32260
|
+
const approvedBy = await getUserById(value.approvedBy);
|
|
32261
|
+
if (!approvedBy || !approvedBy.name)
|
|
32262
|
+
throw new BadRequestError160("Created by not found.");
|
|
32263
|
+
value.approvedByName = approvedBy.name;
|
|
32264
|
+
value.approvedBy = approvedBy._id;
|
|
32265
|
+
}
|
|
32266
|
+
await _reviewIncidentReport(id, value, session);
|
|
32267
|
+
await session?.commitTransaction();
|
|
32268
|
+
return `Successfully ${value.status} incident report.`;
|
|
32269
|
+
} catch (error) {
|
|
32270
|
+
await session?.abortTransaction();
|
|
32271
|
+
throw error;
|
|
32272
|
+
} finally {
|
|
32273
|
+
session?.endSession();
|
|
32274
|
+
}
|
|
32275
|
+
}
|
|
32184
32276
|
return {
|
|
32185
32277
|
add,
|
|
32186
32278
|
updateIncidentReportById,
|
|
32187
|
-
createIncidentSummary
|
|
32279
|
+
createIncidentSummary,
|
|
32280
|
+
reviewIncidentReport
|
|
32188
32281
|
};
|
|
32189
32282
|
}
|
|
32190
32283
|
|
|
32191
32284
|
// src/controllers/incident-report.controller.ts
|
|
32192
|
-
import { BadRequestError as
|
|
32285
|
+
import { BadRequestError as BadRequestError161, logger as logger140 } from "@7365admin1/node-server-utils";
|
|
32193
32286
|
import Joi100 from "joi";
|
|
32194
32287
|
function useIncidentReportController() {
|
|
32195
32288
|
const {
|
|
32196
32289
|
add: _add,
|
|
32197
32290
|
updateIncidentReportById: _updateIncidentReportById,
|
|
32198
|
-
createIncidentSummary: _createIncidentSummary
|
|
32291
|
+
createIncidentSummary: _createIncidentSummary,
|
|
32292
|
+
reviewIncidentReport: _reviewIncidentReport
|
|
32199
32293
|
} = useIncidentReportService();
|
|
32200
32294
|
const {
|
|
32201
32295
|
getAll: _getAll,
|
|
@@ -32210,12 +32304,12 @@ function useIncidentReportController() {
|
|
|
32210
32304
|
if (error) {
|
|
32211
32305
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
32212
32306
|
logger140.log({ level: "error", message: messages });
|
|
32213
|
-
next(new
|
|
32307
|
+
next(new BadRequestError161(messages));
|
|
32214
32308
|
return;
|
|
32215
32309
|
}
|
|
32216
32310
|
try {
|
|
32217
32311
|
const data = await _add(payload);
|
|
32218
|
-
res.status(201).json(data);
|
|
32312
|
+
res.status(201).json({ data });
|
|
32219
32313
|
return;
|
|
32220
32314
|
} catch (error2) {
|
|
32221
32315
|
logger140.log({ level: "error", message: error2.message });
|
|
@@ -32243,7 +32337,7 @@ function useIncidentReportController() {
|
|
|
32243
32337
|
if (error) {
|
|
32244
32338
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
32245
32339
|
logger140.log({ level: "error", message: messages });
|
|
32246
|
-
next(new
|
|
32340
|
+
next(new BadRequestError161(messages));
|
|
32247
32341
|
return;
|
|
32248
32342
|
}
|
|
32249
32343
|
const search = req.query.search ?? "";
|
|
@@ -32285,7 +32379,7 @@ function useIncidentReportController() {
|
|
|
32285
32379
|
const { error } = validation.validate(_id);
|
|
32286
32380
|
if (error) {
|
|
32287
32381
|
logger140.log({ level: "error", message: error.message });
|
|
32288
|
-
next(new
|
|
32382
|
+
next(new BadRequestError161(error.message));
|
|
32289
32383
|
return;
|
|
32290
32384
|
}
|
|
32291
32385
|
try {
|
|
@@ -32307,7 +32401,7 @@ function useIncidentReportController() {
|
|
|
32307
32401
|
if (error) {
|
|
32308
32402
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
32309
32403
|
logger140.log({ level: "error", message: messages });
|
|
32310
|
-
next(new
|
|
32404
|
+
next(new BadRequestError161(messages));
|
|
32311
32405
|
return;
|
|
32312
32406
|
}
|
|
32313
32407
|
try {
|
|
@@ -32326,7 +32420,7 @@ function useIncidentReportController() {
|
|
|
32326
32420
|
const { error } = validation.validate(_id);
|
|
32327
32421
|
if (error) {
|
|
32328
32422
|
logger140.log({ level: "error", message: error.message });
|
|
32329
|
-
next(new
|
|
32423
|
+
next(new BadRequestError161(error.message));
|
|
32330
32424
|
return;
|
|
32331
32425
|
}
|
|
32332
32426
|
try {
|
|
@@ -32347,7 +32441,7 @@ function useIncidentReportController() {
|
|
|
32347
32441
|
if (error) {
|
|
32348
32442
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
32349
32443
|
logger140.log({ level: "error", message: messages });
|
|
32350
|
-
next(new
|
|
32444
|
+
next(new BadRequestError161(messages));
|
|
32351
32445
|
return;
|
|
32352
32446
|
}
|
|
32353
32447
|
try {
|
|
@@ -32363,20 +32457,52 @@ function useIncidentReportController() {
|
|
|
32363
32457
|
return;
|
|
32364
32458
|
}
|
|
32365
32459
|
}
|
|
32460
|
+
async function reviewIncidentReport(req, res, next) {
|
|
32461
|
+
const cookies = req.headers.cookie?.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
32462
|
+
(acc, [key, value]) => ({ ...acc, [key]: value }),
|
|
32463
|
+
{}
|
|
32464
|
+
);
|
|
32465
|
+
req.body.approvedBy = cookies?.["user"].toString() ?? "";
|
|
32466
|
+
const _id = req.params.id;
|
|
32467
|
+
const payload = { _id, ...req.body };
|
|
32468
|
+
const schema2 = Joi100.object({
|
|
32469
|
+
_id: Joi100.string().hex().required(),
|
|
32470
|
+
status: Joi100.string().valid("approved", "rejected").required(),
|
|
32471
|
+
approvedBy: Joi100.string().required(),
|
|
32472
|
+
remarks: Joi100.string().optional().allow("", null)
|
|
32473
|
+
});
|
|
32474
|
+
const { error } = schema2.validate(payload);
|
|
32475
|
+
if (error) {
|
|
32476
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
32477
|
+
logger140.log({ level: "error", message: messages });
|
|
32478
|
+
next(new BadRequestError161(messages));
|
|
32479
|
+
return;
|
|
32480
|
+
}
|
|
32481
|
+
try {
|
|
32482
|
+
const result = await _reviewIncidentReport(_id, req.body);
|
|
32483
|
+
res.status(200).json({ message: result });
|
|
32484
|
+
return;
|
|
32485
|
+
} catch (error2) {
|
|
32486
|
+
logger140.log({ level: "error", message: error2.message });
|
|
32487
|
+
next(error2);
|
|
32488
|
+
return;
|
|
32489
|
+
}
|
|
32490
|
+
}
|
|
32366
32491
|
return {
|
|
32367
32492
|
add,
|
|
32368
32493
|
getAll,
|
|
32369
32494
|
getIncidentReportById,
|
|
32370
32495
|
updateIncidentReportById,
|
|
32371
32496
|
deleteIncidentReportById,
|
|
32372
|
-
createIncidentSummary
|
|
32497
|
+
createIncidentSummary,
|
|
32498
|
+
reviewIncidentReport
|
|
32373
32499
|
};
|
|
32374
32500
|
}
|
|
32375
32501
|
|
|
32376
32502
|
// src/models/nfc-patrol-settings.model.ts
|
|
32377
32503
|
import { ObjectId as ObjectId98 } from "mongodb";
|
|
32378
32504
|
import Joi101 from "joi";
|
|
32379
|
-
import { BadRequestError as
|
|
32505
|
+
import { BadRequestError as BadRequestError162, logger as logger141 } from "@7365admin1/node-server-utils";
|
|
32380
32506
|
var objectId = Joi101.string().hex().length(24);
|
|
32381
32507
|
var nfcPatrolSettingsSchema = Joi101.object({
|
|
32382
32508
|
site: objectId.required(),
|
|
@@ -32396,13 +32522,13 @@ function MNfcPatrolSettings(value) {
|
|
|
32396
32522
|
const { error } = nfcPatrolSettingsSchema.validate(value);
|
|
32397
32523
|
if (error) {
|
|
32398
32524
|
logger141.info(`NFC Patrol Settings Model: ${error.message}`);
|
|
32399
|
-
throw new
|
|
32525
|
+
throw new BadRequestError162(error.message);
|
|
32400
32526
|
}
|
|
32401
32527
|
if (value.site) {
|
|
32402
32528
|
try {
|
|
32403
32529
|
value.site = new ObjectId98(value.site);
|
|
32404
32530
|
} catch (error2) {
|
|
32405
|
-
throw new
|
|
32531
|
+
throw new BadRequestError162("Invalid site ID format.");
|
|
32406
32532
|
}
|
|
32407
32533
|
}
|
|
32408
32534
|
return {
|
|
@@ -32416,13 +32542,13 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
32416
32542
|
const { error } = nfcPatrolSettingsSchemaUpdate.validate(value);
|
|
32417
32543
|
if (error) {
|
|
32418
32544
|
logger141.info(`NFC Patrol Settings Model: ${error.message}`);
|
|
32419
|
-
throw new
|
|
32545
|
+
throw new BadRequestError162(error.message);
|
|
32420
32546
|
}
|
|
32421
32547
|
if (value.updatedBy) {
|
|
32422
32548
|
try {
|
|
32423
32549
|
value.updatedBy = new ObjectId98(value.updatedBy);
|
|
32424
32550
|
} catch (error2) {
|
|
32425
|
-
throw new
|
|
32551
|
+
throw new BadRequestError162("Invalid updatedBy ID format.");
|
|
32426
32552
|
}
|
|
32427
32553
|
}
|
|
32428
32554
|
return {
|
|
@@ -32434,7 +32560,7 @@ function MNfcPatrolSettingsUpdate(value) {
|
|
|
32434
32560
|
|
|
32435
32561
|
// src/repositories/nfc-patrol-settings.repository.ts
|
|
32436
32562
|
import {
|
|
32437
|
-
BadRequestError as
|
|
32563
|
+
BadRequestError as BadRequestError163,
|
|
32438
32564
|
InternalServerError as InternalServerError56,
|
|
32439
32565
|
logger as logger142,
|
|
32440
32566
|
makeCacheKey as makeCacheKey53,
|
|
@@ -32474,7 +32600,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
32474
32600
|
try {
|
|
32475
32601
|
site = new ObjectId99(site);
|
|
32476
32602
|
} catch (error) {
|
|
32477
|
-
throw new
|
|
32603
|
+
throw new BadRequestError163("Invalid nfc patrol settings site ID format.");
|
|
32478
32604
|
}
|
|
32479
32605
|
const query = { site };
|
|
32480
32606
|
const cacheKey = makeCacheKey53(namespace_collection, {
|
|
@@ -32518,7 +32644,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
32518
32644
|
try {
|
|
32519
32645
|
site = new ObjectId99(site);
|
|
32520
32646
|
} catch (error) {
|
|
32521
|
-
throw new
|
|
32647
|
+
throw new BadRequestError163("Invalid attendance settings ID format.");
|
|
32522
32648
|
}
|
|
32523
32649
|
try {
|
|
32524
32650
|
value = MNfcPatrolSettingsUpdate(value);
|
|
@@ -32566,7 +32692,7 @@ function useNfcPatrolSettingsRepository() {
|
|
|
32566
32692
|
|
|
32567
32693
|
// src/services/nfc-patrol-settings.service.ts
|
|
32568
32694
|
import {
|
|
32569
|
-
BadRequestError as
|
|
32695
|
+
BadRequestError as BadRequestError164,
|
|
32570
32696
|
logger as logger143,
|
|
32571
32697
|
useAtlas as useAtlas90
|
|
32572
32698
|
} from "@7365admin1/node-server-utils";
|
|
@@ -32612,7 +32738,7 @@ function useNfcPatrolSettingsService() {
|
|
|
32612
32738
|
async function updateNfcPatrolSettings(site, value) {
|
|
32613
32739
|
const session = useAtlas90.getClient()?.startSession();
|
|
32614
32740
|
if (!session) {
|
|
32615
|
-
throw new
|
|
32741
|
+
throw new BadRequestError164("Database session not available.");
|
|
32616
32742
|
}
|
|
32617
32743
|
try {
|
|
32618
32744
|
await session.startTransaction();
|
|
@@ -32635,7 +32761,7 @@ function useNfcPatrolSettingsService() {
|
|
|
32635
32761
|
|
|
32636
32762
|
// src/controllers/nfc-patrol-settings.controller.ts
|
|
32637
32763
|
import Joi102 from "joi";
|
|
32638
|
-
import { BadRequestError as
|
|
32764
|
+
import { BadRequestError as BadRequestError165, logger as logger144 } from "@7365admin1/node-server-utils";
|
|
32639
32765
|
function useNfcPatrolSettingsController() {
|
|
32640
32766
|
const { getNfcPatrolSettingsBySite: _getNfcPatrolSettingsBySite } = useNfcPatrolSettingsService();
|
|
32641
32767
|
const { updateNfcPatrolSettings: _updateNfcPatrolSettings } = useNfcPatrolSettingsService();
|
|
@@ -32645,7 +32771,7 @@ function useNfcPatrolSettingsController() {
|
|
|
32645
32771
|
const { error } = validation.validate(site);
|
|
32646
32772
|
if (error) {
|
|
32647
32773
|
logger144.log({ level: "error", message: error.message });
|
|
32648
|
-
next(new
|
|
32774
|
+
next(new BadRequestError165(error.message));
|
|
32649
32775
|
return;
|
|
32650
32776
|
}
|
|
32651
32777
|
try {
|
|
@@ -32688,7 +32814,7 @@ import { useAtlas as useAtlas92 } from "@7365admin1/node-server-utils";
|
|
|
32688
32814
|
|
|
32689
32815
|
// src/repositories/occurrence-subject.repo.ts
|
|
32690
32816
|
import {
|
|
32691
|
-
BadRequestError as
|
|
32817
|
+
BadRequestError as BadRequestError166,
|
|
32692
32818
|
InternalServerError as InternalServerError57,
|
|
32693
32819
|
logger as logger145,
|
|
32694
32820
|
makeCacheKey as makeCacheKey54,
|
|
@@ -32789,7 +32915,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
32789
32915
|
} catch (error) {
|
|
32790
32916
|
const isDuplicated = error.message.includes("duplicate");
|
|
32791
32917
|
if (isDuplicated) {
|
|
32792
|
-
throw new
|
|
32918
|
+
throw new BadRequestError166("Occurrence subject already exists.");
|
|
32793
32919
|
}
|
|
32794
32920
|
throw error;
|
|
32795
32921
|
}
|
|
@@ -32805,7 +32931,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
32805
32931
|
try {
|
|
32806
32932
|
site = new ObjectId101(site);
|
|
32807
32933
|
} catch (error) {
|
|
32808
|
-
throw new
|
|
32934
|
+
throw new BadRequestError166("Invalid site ID format.");
|
|
32809
32935
|
}
|
|
32810
32936
|
const baseQuery = {
|
|
32811
32937
|
site,
|
|
@@ -32900,7 +33026,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
32900
33026
|
try {
|
|
32901
33027
|
_id = new ObjectId101(_id);
|
|
32902
33028
|
} catch (error) {
|
|
32903
|
-
throw new
|
|
33029
|
+
throw new BadRequestError166("Invalid occurrence subject ID format.");
|
|
32904
33030
|
}
|
|
32905
33031
|
const cacheKey = makeCacheKey54(namespace_collection, { _id });
|
|
32906
33032
|
const cachedData = await getCache(cacheKey);
|
|
@@ -32928,7 +33054,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
32928
33054
|
try {
|
|
32929
33055
|
_id = new ObjectId101(_id);
|
|
32930
33056
|
} catch (error) {
|
|
32931
|
-
throw new
|
|
33057
|
+
throw new BadRequestError166("Invalid ID format.");
|
|
32932
33058
|
}
|
|
32933
33059
|
try {
|
|
32934
33060
|
const res = await collection.updateOne(
|
|
@@ -32958,7 +33084,7 @@ function useOccurrenceSubjectRepo() {
|
|
|
32958
33084
|
try {
|
|
32959
33085
|
_id = new ObjectId101(_id);
|
|
32960
33086
|
} catch (error) {
|
|
32961
|
-
throw new
|
|
33087
|
+
throw new BadRequestError166("Invalid occurrence subject ID format.");
|
|
32962
33088
|
}
|
|
32963
33089
|
try {
|
|
32964
33090
|
const updateValue = {
|
|
@@ -33073,7 +33199,7 @@ function useOccurrenceEntryService() {
|
|
|
33073
33199
|
}
|
|
33074
33200
|
|
|
33075
33201
|
// src/controllers/occurrence-entry.controller.ts
|
|
33076
|
-
import { BadRequestError as
|
|
33202
|
+
import { BadRequestError as BadRequestError167, logger as logger146 } from "@7365admin1/node-server-utils";
|
|
33077
33203
|
import Joi104 from "joi";
|
|
33078
33204
|
function useOccurrenceEntryController() {
|
|
33079
33205
|
const { add: _add, updateOccurrenceEntryById: _updateOccurrenceEntryById } = useOccurrenceEntryService();
|
|
@@ -33091,7 +33217,7 @@ function useOccurrenceEntryController() {
|
|
|
33091
33217
|
if (error) {
|
|
33092
33218
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
33093
33219
|
logger146.log({ level: "error", message: messages });
|
|
33094
|
-
next(new
|
|
33220
|
+
next(new BadRequestError167(messages));
|
|
33095
33221
|
return;
|
|
33096
33222
|
}
|
|
33097
33223
|
try {
|
|
@@ -33123,7 +33249,7 @@ function useOccurrenceEntryController() {
|
|
|
33123
33249
|
if (error) {
|
|
33124
33250
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
33125
33251
|
logger146.log({ level: "error", message: messages });
|
|
33126
|
-
next(new
|
|
33252
|
+
next(new BadRequestError167(messages));
|
|
33127
33253
|
return;
|
|
33128
33254
|
}
|
|
33129
33255
|
const search = req.query.search ?? "";
|
|
@@ -33163,7 +33289,7 @@ function useOccurrenceEntryController() {
|
|
|
33163
33289
|
const { error } = validation.validate(_id);
|
|
33164
33290
|
if (error) {
|
|
33165
33291
|
logger146.log({ level: "error", message: error.message });
|
|
33166
|
-
next(new
|
|
33292
|
+
next(new BadRequestError167(error.message));
|
|
33167
33293
|
return;
|
|
33168
33294
|
}
|
|
33169
33295
|
try {
|
|
@@ -33185,7 +33311,7 @@ function useOccurrenceEntryController() {
|
|
|
33185
33311
|
if (error) {
|
|
33186
33312
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
33187
33313
|
logger146.log({ level: "error", message: messages });
|
|
33188
|
-
next(new
|
|
33314
|
+
next(new BadRequestError167(messages));
|
|
33189
33315
|
return;
|
|
33190
33316
|
}
|
|
33191
33317
|
try {
|
|
@@ -33204,7 +33330,7 @@ function useOccurrenceEntryController() {
|
|
|
33204
33330
|
const { error } = validation.validate(_id);
|
|
33205
33331
|
if (error) {
|
|
33206
33332
|
logger146.log({ level: "error", message: error.message });
|
|
33207
|
-
next(new
|
|
33333
|
+
next(new BadRequestError167(error.message));
|
|
33208
33334
|
return;
|
|
33209
33335
|
}
|
|
33210
33336
|
try {
|
|
@@ -33223,7 +33349,7 @@ function useOccurrenceEntryController() {
|
|
|
33223
33349
|
const { error } = validation.validate(_id);
|
|
33224
33350
|
if (error) {
|
|
33225
33351
|
logger146.log({ level: "error", message: error.message });
|
|
33226
|
-
next(new
|
|
33352
|
+
next(new BadRequestError167(error.message));
|
|
33227
33353
|
return;
|
|
33228
33354
|
}
|
|
33229
33355
|
try {
|
|
@@ -33333,7 +33459,7 @@ function MOnlineForm(value) {
|
|
|
33333
33459
|
|
|
33334
33460
|
// src/repositories/online-form.repo.ts
|
|
33335
33461
|
import {
|
|
33336
|
-
BadRequestError as
|
|
33462
|
+
BadRequestError as BadRequestError168,
|
|
33337
33463
|
InternalServerError as InternalServerError58,
|
|
33338
33464
|
logger as logger147,
|
|
33339
33465
|
makeCacheKey as makeCacheKey55,
|
|
@@ -33378,7 +33504,7 @@ function useOnlineFormRepo() {
|
|
|
33378
33504
|
} catch (error) {
|
|
33379
33505
|
const isDuplicated = error.message.includes("duplicate");
|
|
33380
33506
|
if (isDuplicated) {
|
|
33381
|
-
throw new
|
|
33507
|
+
throw new BadRequestError168("Online Form already exists.");
|
|
33382
33508
|
}
|
|
33383
33509
|
throw error;
|
|
33384
33510
|
}
|
|
@@ -33446,7 +33572,7 @@ function useOnlineFormRepo() {
|
|
|
33446
33572
|
try {
|
|
33447
33573
|
_id = new ObjectId103(_id);
|
|
33448
33574
|
} catch (error) {
|
|
33449
|
-
throw new
|
|
33575
|
+
throw new BadRequestError168("Invalid online form ID format.");
|
|
33450
33576
|
}
|
|
33451
33577
|
const cacheKey = makeCacheKey55(namespace_collection, { _id });
|
|
33452
33578
|
const cachedData = await getCache(cacheKey);
|
|
@@ -33489,7 +33615,7 @@ function useOnlineFormRepo() {
|
|
|
33489
33615
|
try {
|
|
33490
33616
|
_id = new ObjectId103(_id);
|
|
33491
33617
|
} catch (error) {
|
|
33492
|
-
throw new
|
|
33618
|
+
throw new BadRequestError168("Invalid online form ID format.");
|
|
33493
33619
|
}
|
|
33494
33620
|
try {
|
|
33495
33621
|
const updateValue = {
|
|
@@ -33517,7 +33643,7 @@ function useOnlineFormRepo() {
|
|
|
33517
33643
|
try {
|
|
33518
33644
|
_id = new ObjectId103(_id);
|
|
33519
33645
|
} catch (error) {
|
|
33520
|
-
throw new
|
|
33646
|
+
throw new BadRequestError168("Invalid online form ID format.");
|
|
33521
33647
|
}
|
|
33522
33648
|
try {
|
|
33523
33649
|
const updateValue = {
|
|
@@ -33550,7 +33676,7 @@ function useOnlineFormRepo() {
|
|
|
33550
33676
|
try {
|
|
33551
33677
|
site = new ObjectId103(site);
|
|
33552
33678
|
} catch (error) {
|
|
33553
|
-
throw new
|
|
33679
|
+
throw new BadRequestError168(
|
|
33554
33680
|
"Invalid online form configuration site ID format."
|
|
33555
33681
|
);
|
|
33556
33682
|
}
|
|
@@ -33614,7 +33740,7 @@ function useOnlineFormRepo() {
|
|
|
33614
33740
|
}
|
|
33615
33741
|
|
|
33616
33742
|
// src/controllers/online-form.controller.ts
|
|
33617
|
-
import { BadRequestError as
|
|
33743
|
+
import { BadRequestError as BadRequestError169, logger as logger148 } from "@7365admin1/node-server-utils";
|
|
33618
33744
|
import Joi106 from "joi";
|
|
33619
33745
|
function useOnlineFormController() {
|
|
33620
33746
|
const {
|
|
@@ -33638,7 +33764,7 @@ function useOnlineFormController() {
|
|
|
33638
33764
|
if (error) {
|
|
33639
33765
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
33640
33766
|
logger148.log({ level: "error", message: messages });
|
|
33641
|
-
next(new
|
|
33767
|
+
next(new BadRequestError169(messages));
|
|
33642
33768
|
return;
|
|
33643
33769
|
}
|
|
33644
33770
|
try {
|
|
@@ -33665,7 +33791,7 @@ function useOnlineFormController() {
|
|
|
33665
33791
|
const { error } = validation.validate(query);
|
|
33666
33792
|
if (error) {
|
|
33667
33793
|
logger148.log({ level: "error", message: error.message });
|
|
33668
|
-
next(new
|
|
33794
|
+
next(new BadRequestError169(error.message));
|
|
33669
33795
|
return;
|
|
33670
33796
|
}
|
|
33671
33797
|
const search = req.query.search ?? "";
|
|
@@ -33690,7 +33816,7 @@ function useOnlineFormController() {
|
|
|
33690
33816
|
const { error } = validation.validate(_id);
|
|
33691
33817
|
if (error) {
|
|
33692
33818
|
logger148.log({ level: "error", message: error.message });
|
|
33693
|
-
next(new
|
|
33819
|
+
next(new BadRequestError169(error.message));
|
|
33694
33820
|
return;
|
|
33695
33821
|
}
|
|
33696
33822
|
try {
|
|
@@ -33731,7 +33857,7 @@ function useOnlineFormController() {
|
|
|
33731
33857
|
const { error } = validation.validate({ _id, ...payload });
|
|
33732
33858
|
if (error) {
|
|
33733
33859
|
logger148.log({ level: "error", message: error.message });
|
|
33734
|
-
next(new
|
|
33860
|
+
next(new BadRequestError169(error.message));
|
|
33735
33861
|
return;
|
|
33736
33862
|
}
|
|
33737
33863
|
try {
|
|
@@ -33750,7 +33876,7 @@ function useOnlineFormController() {
|
|
|
33750
33876
|
const { error } = validation.validate(_id);
|
|
33751
33877
|
if (error) {
|
|
33752
33878
|
logger148.log({ level: "error", message: error.message });
|
|
33753
|
-
next(new
|
|
33879
|
+
next(new BadRequestError169(error.message));
|
|
33754
33880
|
return;
|
|
33755
33881
|
}
|
|
33756
33882
|
try {
|
|
@@ -33771,7 +33897,7 @@ function useOnlineFormController() {
|
|
|
33771
33897
|
const { error } = validation.validate(_id);
|
|
33772
33898
|
if (error) {
|
|
33773
33899
|
logger148.log({ level: "error", message: error.message });
|
|
33774
|
-
next(new
|
|
33900
|
+
next(new BadRequestError169(error.message));
|
|
33775
33901
|
return;
|
|
33776
33902
|
}
|
|
33777
33903
|
try {
|
|
@@ -33836,7 +33962,7 @@ function useOccurrenceSubjectService() {
|
|
|
33836
33962
|
}
|
|
33837
33963
|
|
|
33838
33964
|
// src/controllers/occurrence-subject.controller.ts
|
|
33839
|
-
import { BadRequestError as
|
|
33965
|
+
import { BadRequestError as BadRequestError170, logger as logger149 } from "@7365admin1/node-server-utils";
|
|
33840
33966
|
import Joi107 from "joi";
|
|
33841
33967
|
function useOccurrenceSubjectController() {
|
|
33842
33968
|
const {
|
|
@@ -33856,7 +33982,7 @@ function useOccurrenceSubjectController() {
|
|
|
33856
33982
|
if (error) {
|
|
33857
33983
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
33858
33984
|
logger149.log({ level: "error", message: messages });
|
|
33859
|
-
next(new
|
|
33985
|
+
next(new BadRequestError170(messages));
|
|
33860
33986
|
return;
|
|
33861
33987
|
}
|
|
33862
33988
|
try {
|
|
@@ -33887,7 +34013,7 @@ function useOccurrenceSubjectController() {
|
|
|
33887
34013
|
if (error) {
|
|
33888
34014
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
33889
34015
|
logger149.log({ level: "error", message: messages });
|
|
33890
|
-
next(new
|
|
34016
|
+
next(new BadRequestError170(messages));
|
|
33891
34017
|
return;
|
|
33892
34018
|
}
|
|
33893
34019
|
const search = req.query.search ?? "";
|
|
@@ -33925,7 +34051,7 @@ function useOccurrenceSubjectController() {
|
|
|
33925
34051
|
const { error } = validation.validate(_id);
|
|
33926
34052
|
if (error) {
|
|
33927
34053
|
logger149.log({ level: "error", message: error.message });
|
|
33928
|
-
next(new
|
|
34054
|
+
next(new BadRequestError170(error.message));
|
|
33929
34055
|
return;
|
|
33930
34056
|
}
|
|
33931
34057
|
try {
|
|
@@ -33947,7 +34073,7 @@ function useOccurrenceSubjectController() {
|
|
|
33947
34073
|
if (error) {
|
|
33948
34074
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
33949
34075
|
logger149.log({ level: "error", message: messages });
|
|
33950
|
-
next(new
|
|
34076
|
+
next(new BadRequestError170(messages));
|
|
33951
34077
|
return;
|
|
33952
34078
|
}
|
|
33953
34079
|
try {
|
|
@@ -33966,7 +34092,7 @@ function useOccurrenceSubjectController() {
|
|
|
33966
34092
|
const { error } = validation.validate(_id);
|
|
33967
34093
|
if (error) {
|
|
33968
34094
|
logger149.log({ level: "error", message: error.message });
|
|
33969
|
-
next(new
|
|
34095
|
+
next(new BadRequestError170(error.message));
|
|
33970
34096
|
return;
|
|
33971
34097
|
}
|
|
33972
34098
|
try {
|
|
@@ -33991,7 +34117,7 @@ function useOccurrenceSubjectController() {
|
|
|
33991
34117
|
// src/models/nfc-patrol-log.model.ts
|
|
33992
34118
|
import { ObjectId as ObjectId104 } from "mongodb";
|
|
33993
34119
|
import Joi108 from "joi";
|
|
33994
|
-
import { BadRequestError as
|
|
34120
|
+
import { BadRequestError as BadRequestError171, logger as logger150 } from "@7365admin1/node-server-utils";
|
|
33995
34121
|
var schemaNfcPatrolLog = Joi108.object({
|
|
33996
34122
|
_id: Joi108.string().length(24).hex().optional().allow(null, ""),
|
|
33997
34123
|
site: Joi108.string().length(24).hex().required(),
|
|
@@ -34037,32 +34163,32 @@ function MNfcPatrolLog(valueArg) {
|
|
|
34037
34163
|
const { error, value } = schemaNfcPatrolLog.validate(valueArg);
|
|
34038
34164
|
if (error) {
|
|
34039
34165
|
logger150.info(`NFC Patrol Log Model: ${error.message}`);
|
|
34040
|
-
throw new
|
|
34166
|
+
throw new BadRequestError171(error.message);
|
|
34041
34167
|
}
|
|
34042
34168
|
if (value._id && typeof value._id === "string") {
|
|
34043
34169
|
try {
|
|
34044
34170
|
value._id = new ObjectId104(value._id);
|
|
34045
34171
|
} catch (error2) {
|
|
34046
|
-
throw new
|
|
34172
|
+
throw new BadRequestError171("Invalid _id format");
|
|
34047
34173
|
}
|
|
34048
34174
|
}
|
|
34049
34175
|
try {
|
|
34050
34176
|
value.site = new ObjectId104(value.site);
|
|
34051
34177
|
} catch (error2) {
|
|
34052
|
-
throw new
|
|
34178
|
+
throw new BadRequestError171("Invalid site format");
|
|
34053
34179
|
}
|
|
34054
34180
|
if (value?.createdBy) {
|
|
34055
34181
|
try {
|
|
34056
34182
|
value.createdBy = new ObjectId104(value.createdBy);
|
|
34057
34183
|
} catch (error2) {
|
|
34058
|
-
throw new
|
|
34184
|
+
throw new BadRequestError171("Invalid createdBy format");
|
|
34059
34185
|
}
|
|
34060
34186
|
}
|
|
34061
34187
|
if (value?.route?._id) {
|
|
34062
34188
|
try {
|
|
34063
34189
|
value.route._id = new ObjectId104(value.route._id);
|
|
34064
34190
|
} catch (error2) {
|
|
34065
|
-
throw new
|
|
34191
|
+
throw new BadRequestError171("Invalid route _id format");
|
|
34066
34192
|
}
|
|
34067
34193
|
}
|
|
34068
34194
|
return {
|
|
@@ -34080,7 +34206,7 @@ function MNfcPatrolLog(valueArg) {
|
|
|
34080
34206
|
|
|
34081
34207
|
// src/repositories/nfc-patrol-log.repository.ts
|
|
34082
34208
|
import {
|
|
34083
|
-
BadRequestError as
|
|
34209
|
+
BadRequestError as BadRequestError172,
|
|
34084
34210
|
InternalServerError as InternalServerError59,
|
|
34085
34211
|
logger as logger151,
|
|
34086
34212
|
makeCacheKey as makeCacheKey56,
|
|
@@ -34126,7 +34252,7 @@ function useNfcPatrolLogRepo() {
|
|
|
34126
34252
|
} catch (error) {
|
|
34127
34253
|
const isDuplicated = error.message.includes("duplicate");
|
|
34128
34254
|
if (isDuplicated) {
|
|
34129
|
-
throw new
|
|
34255
|
+
throw new BadRequestError172("NFC Patrol Log already exists.");
|
|
34130
34256
|
}
|
|
34131
34257
|
throw error;
|
|
34132
34258
|
}
|
|
@@ -34143,7 +34269,7 @@ function useNfcPatrolLogRepo() {
|
|
|
34143
34269
|
try {
|
|
34144
34270
|
siteId = typeof site === "string" ? new ObjectId105(site) : site;
|
|
34145
34271
|
} catch {
|
|
34146
|
-
throw new
|
|
34272
|
+
throw new BadRequestError172("Invalid site ID format.");
|
|
34147
34273
|
}
|
|
34148
34274
|
const query = {
|
|
34149
34275
|
site: siteId
|
|
@@ -34245,7 +34371,7 @@ function useNfcPatrolLogService() {
|
|
|
34245
34371
|
|
|
34246
34372
|
// src/controllers/nfc-patrol-log.controller.ts
|
|
34247
34373
|
import {
|
|
34248
|
-
BadRequestError as
|
|
34374
|
+
BadRequestError as BadRequestError174,
|
|
34249
34375
|
logger as logger153
|
|
34250
34376
|
} from "@7365admin1/node-server-utils";
|
|
34251
34377
|
import Joi109 from "joi";
|
|
@@ -34293,7 +34419,7 @@ function useNfcPatrolLogController() {
|
|
|
34293
34419
|
if (error) {
|
|
34294
34420
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
34295
34421
|
logger153.log({ level: "error", message: messages });
|
|
34296
|
-
next(new
|
|
34422
|
+
next(new BadRequestError174(messages));
|
|
34297
34423
|
return;
|
|
34298
34424
|
}
|
|
34299
34425
|
const { page, limit, site, date, route } = value;
|
|
@@ -34325,6 +34451,7 @@ export {
|
|
|
34325
34451
|
EAccessCardUserTypes,
|
|
34326
34452
|
MAccessCard,
|
|
34327
34453
|
MAccessCardTransaction,
|
|
34454
|
+
MAddress,
|
|
34328
34455
|
MAttendance,
|
|
34329
34456
|
MAttendanceSettings,
|
|
34330
34457
|
MBillingConfiguration,
|
|
@@ -34459,6 +34586,7 @@ export {
|
|
|
34459
34586
|
siteSchema,
|
|
34460
34587
|
tokenSchema,
|
|
34461
34588
|
useAccessManagementController,
|
|
34589
|
+
useAddressRepo,
|
|
34462
34590
|
useAttendanceController,
|
|
34463
34591
|
useAttendanceRepository,
|
|
34464
34592
|
useAttendanceSettingsController,
|