@7365admin1/core 3.8.0 → 3.10.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 +391 -11
- package/dist/index.js +2248 -516
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2226 -516
- package/dist/index.mjs.map +1 -1
- package/docs/hid-amico-diagram.md +201 -0
- package/docs/hid-amico-integration.md +491 -0
- package/docs/hid-amico-postman-api.md +614 -0
- package/docs/hid-amico-ui-design-scope.md +441 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -536,13 +536,13 @@ var require_logger = __commonJS({
|
|
|
536
536
|
"use strict";
|
|
537
537
|
exports.__esModule = true;
|
|
538
538
|
var _utils = require_utils();
|
|
539
|
-
var
|
|
539
|
+
var logger200 = {
|
|
540
540
|
methodMap: ["debug", "info", "warn", "error"],
|
|
541
541
|
level: "info",
|
|
542
542
|
// Maps a given level value to the `methodMap` indexes above.
|
|
543
543
|
lookupLevel: function lookupLevel(level) {
|
|
544
544
|
if (typeof level === "string") {
|
|
545
|
-
var levelMap = _utils.indexOf(
|
|
545
|
+
var levelMap = _utils.indexOf(logger200.methodMap, level.toLowerCase());
|
|
546
546
|
if (levelMap >= 0) {
|
|
547
547
|
level = levelMap;
|
|
548
548
|
} else {
|
|
@@ -553,9 +553,9 @@ var require_logger = __commonJS({
|
|
|
553
553
|
},
|
|
554
554
|
// Can be overridden in the host environment
|
|
555
555
|
log: function log(level) {
|
|
556
|
-
level =
|
|
557
|
-
if (typeof console !== "undefined" &&
|
|
558
|
-
var method =
|
|
556
|
+
level = logger200.lookupLevel(level);
|
|
557
|
+
if (typeof console !== "undefined" && logger200.lookupLevel(logger200.level) <= level) {
|
|
558
|
+
var method = logger200.methodMap[level];
|
|
559
559
|
if (!console[method]) {
|
|
560
560
|
method = "log";
|
|
561
561
|
}
|
|
@@ -566,7 +566,7 @@ var require_logger = __commonJS({
|
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
568
|
};
|
|
569
|
-
exports["default"] =
|
|
569
|
+
exports["default"] = logger200;
|
|
570
570
|
module2.exports = exports["default"];
|
|
571
571
|
}
|
|
572
572
|
});
|
|
@@ -5892,6 +5892,8 @@ __export(src_exports, {
|
|
|
5892
5892
|
ANPRMode: () => ANPRMode,
|
|
5893
5893
|
AccessTypeProps: () => AccessTypeProps,
|
|
5894
5894
|
AppServiceType: () => AppServiceType,
|
|
5895
|
+
BidStatus: () => BidStatus,
|
|
5896
|
+
BidType: () => BidType,
|
|
5895
5897
|
BuildingLevelStatus: () => BuildingLevelStatus,
|
|
5896
5898
|
BuildingStatus: () => BuildingStatus,
|
|
5897
5899
|
BulletinOrder: () => BulletinOrder,
|
|
@@ -5923,6 +5925,7 @@ __export(src_exports, {
|
|
|
5923
5925
|
MAddress: () => MAddress,
|
|
5924
5926
|
MAttendance: () => MAttendance,
|
|
5925
5927
|
MAttendanceSettings: () => MAttendanceSettings,
|
|
5928
|
+
MBidPreloved: () => MBidPreloved,
|
|
5926
5929
|
MBillingConfiguration: () => MBillingConfiguration,
|
|
5927
5930
|
MBillingItem: () => MBillingItem,
|
|
5928
5931
|
MBuilding: () => MBuilding,
|
|
@@ -5943,6 +5946,9 @@ __export(src_exports, {
|
|
|
5943
5946
|
MFile: () => MFile,
|
|
5944
5947
|
MFormEntry: () => MFormEntry,
|
|
5945
5948
|
MGuestManagement: () => MGuestManagement,
|
|
5949
|
+
MHidAmicoEvent: () => MHidAmicoEvent,
|
|
5950
|
+
MHidAmicoIdentity: () => MHidAmicoIdentity,
|
|
5951
|
+
MHidAmicoReader: () => MHidAmicoReader,
|
|
5946
5952
|
MIncidentReport: () => MIncidentReport,
|
|
5947
5953
|
MManpowerDesignations: () => MManpowerDesignations,
|
|
5948
5954
|
MManpowerMonitoring: () => MManpowerMonitoring,
|
|
@@ -6062,6 +6068,7 @@ __export(src_exports, {
|
|
|
6062
6068
|
schema: () => schema,
|
|
6063
6069
|
schemaApprovedBy: () => schemaApprovedBy,
|
|
6064
6070
|
schemaApprover: () => schemaApprover,
|
|
6071
|
+
schemaBidPreloved: () => schemaBidPreloved,
|
|
6065
6072
|
schemaBilling: () => schemaBilling,
|
|
6066
6073
|
schemaBillingConfiguration: () => schemaBillingConfiguration,
|
|
6067
6074
|
schemaBillingItem: () => schemaBillingItem,
|
|
@@ -6074,6 +6081,7 @@ __export(src_exports, {
|
|
|
6074
6081
|
schemaCategoryPreloved: () => schemaCategoryPreloved,
|
|
6075
6082
|
schemaChannelPreloved: () => schemaChannelPreloved,
|
|
6076
6083
|
schemaChatPreloved: () => schemaChatPreloved,
|
|
6084
|
+
schemaCreateHidAmicoIdentity: () => schemaCreateHidAmicoIdentity,
|
|
6077
6085
|
schemaCustomerSite: () => schemaCustomerSite,
|
|
6078
6086
|
schemaDocumentManagement: () => schemaDocumentManagement,
|
|
6079
6087
|
schemaEntryPassSettings: () => schemaEntryPassSettings,
|
|
@@ -6081,6 +6089,21 @@ __export(src_exports, {
|
|
|
6081
6089
|
schemaFiles: () => schemaFiles,
|
|
6082
6090
|
schemaFormEntry: () => schemaFormEntry,
|
|
6083
6091
|
schemaGuestManagement: () => schemaGuestManagement,
|
|
6092
|
+
schemaHidAmicoConfiguration: () => schemaHidAmicoConfiguration,
|
|
6093
|
+
schemaHidAmicoEvent: () => schemaHidAmicoEvent,
|
|
6094
|
+
schemaHidAmicoExecuteActions: () => schemaHidAmicoExecuteActions,
|
|
6095
|
+
schemaHidAmicoIdentity: () => schemaHidAmicoIdentity,
|
|
6096
|
+
schemaHidAmicoIdentityIdParams: () => schemaHidAmicoIdentityIdParams,
|
|
6097
|
+
schemaHidAmicoIdentityQuery: () => schemaHidAmicoIdentityQuery,
|
|
6098
|
+
schemaHidAmicoLogQuery: () => schemaHidAmicoLogQuery,
|
|
6099
|
+
schemaHidAmicoNotificationParams: () => schemaHidAmicoNotificationParams,
|
|
6100
|
+
schemaHidAmicoObjectOperation: () => schemaHidAmicoObjectOperation,
|
|
6101
|
+
schemaHidAmicoReader: () => schemaHidAmicoReader,
|
|
6102
|
+
schemaHidAmicoReaderIdParams: () => schemaHidAmicoReaderIdParams,
|
|
6103
|
+
schemaHidAmicoReaderListQuery: () => schemaHidAmicoReaderListQuery,
|
|
6104
|
+
schemaHidAmicoSetConfiguration: () => schemaHidAmicoSetConfiguration,
|
|
6105
|
+
schemaHidAmicoSync: () => schemaHidAmicoSync,
|
|
6106
|
+
schemaHidAmicoUserImageParams: () => schemaHidAmicoUserImageParams,
|
|
6084
6107
|
schemaIncidentReport: () => schemaIncidentReport,
|
|
6085
6108
|
schemaMultipleDocumentManagement: () => schemaMultipleDocumentManagement,
|
|
6086
6109
|
schemaNfcPatrolLog: () => schemaNfcPatrolLog,
|
|
@@ -6108,6 +6131,7 @@ __export(src_exports, {
|
|
|
6108
6131
|
schemaStatementOfAccount: () => schemaStatementOfAccount,
|
|
6109
6132
|
schemaSubcategoryPreloved: () => schemaSubcategoryPreloved,
|
|
6110
6133
|
schemaUnitBilling: () => schemaUnitBilling,
|
|
6134
|
+
schemaUpdateBidPreloved: () => schemaUpdateBidPreloved,
|
|
6111
6135
|
schemaUpdateBuildingLevel: () => schemaUpdateBuildingLevel,
|
|
6112
6136
|
schemaUpdateBulletinBoard: () => schemaUpdateBulletinBoard,
|
|
6113
6137
|
schemaUpdateBulletinVideo: () => schemaUpdateBulletinVideo,
|
|
@@ -6118,6 +6142,8 @@ __export(src_exports, {
|
|
|
6118
6142
|
schemaUpdateEventManagement: () => schemaUpdateEventManagement,
|
|
6119
6143
|
schemaUpdateFormEntry: () => schemaUpdateFormEntry,
|
|
6120
6144
|
schemaUpdateGuestManagement: () => schemaUpdateGuestManagement,
|
|
6145
|
+
schemaUpdateHidAmicoIdentity: () => schemaUpdateHidAmicoIdentity,
|
|
6146
|
+
schemaUpdateHidAmicoReader: () => schemaUpdateHidAmicoReader,
|
|
6121
6147
|
schemaUpdateIncidentReport: () => schemaUpdateIncidentReport,
|
|
6122
6148
|
schemaUpdateOccurrenceBook: () => schemaUpdateOccurrenceBook,
|
|
6123
6149
|
schemaUpdateOccurrenceEntry: () => schemaUpdateOccurrenceEntry,
|
|
@@ -6163,6 +6189,8 @@ __export(src_exports, {
|
|
|
6163
6189
|
useAuthControllerV2: () => useAuthControllerV2,
|
|
6164
6190
|
useAuthService: () => useAuthService,
|
|
6165
6191
|
useAuthServiceV2: () => useAuthServiceV2,
|
|
6192
|
+
useBidPrelovedController: () => useBidPrelovedController,
|
|
6193
|
+
useBidPrelovedRepo: () => useBidPrelovedRepo,
|
|
6166
6194
|
useBuildingController: () => useBuildingController,
|
|
6167
6195
|
useBuildingLevelController: () => useBuildingLevelController,
|
|
6168
6196
|
useBuildingLevelRepo: () => useBuildingLevelRepo,
|
|
@@ -6185,6 +6213,7 @@ __export(src_exports, {
|
|
|
6185
6213
|
useChatController: () => useChatController,
|
|
6186
6214
|
useChatPrelovedController: () => useChatPrelovedController,
|
|
6187
6215
|
useChatPrelovedRepo: () => useChatPrelovedRepo,
|
|
6216
|
+
useChatPrelovedService: () => useChatPrelovedService,
|
|
6188
6217
|
useChatRepo: () => useChatRepo,
|
|
6189
6218
|
useCounterModel: () => useCounterModel,
|
|
6190
6219
|
useCounterRepo: () => useCounterRepo,
|
|
@@ -6215,6 +6244,9 @@ __export(src_exports, {
|
|
|
6215
6244
|
useGuestManagementController: () => useGuestManagementController,
|
|
6216
6245
|
useGuestManagementRepo: () => useGuestManagementRepo,
|
|
6217
6246
|
useGuestManagementService: () => useGuestManagementService,
|
|
6247
|
+
useHidAmicoController: () => useHidAmicoController,
|
|
6248
|
+
useHidAmicoRepo: () => useHidAmicoRepo,
|
|
6249
|
+
useHidAmicoService: () => useHidAmicoService,
|
|
6218
6250
|
useHrmLabsAttendanceCtrl: () => useHrmLabsAttendanceCtrl,
|
|
6219
6251
|
useHrmLabsAttendanceSrvc: () => useHrmLabsAttendanceSrvc,
|
|
6220
6252
|
useIncidentReportController: () => useIncidentReportController,
|
|
@@ -11204,7 +11236,8 @@ var metadataSchema3 = import_joi9.default.object({
|
|
|
11204
11236
|
guardPosts: import_joi9.default.number().optional(),
|
|
11205
11237
|
gracePeriod: import_joi9.default.number().optional(),
|
|
11206
11238
|
incidentCounter: import_joi9.default.number().optional(),
|
|
11207
|
-
incidentLogo: import_joi9.default.string().optional().allow("", null)
|
|
11239
|
+
incidentLogo: import_joi9.default.string().optional().allow("", null),
|
|
11240
|
+
services: import_joi9.default.array().items(import_joi9.default.object().unknown(true)).optional()
|
|
11208
11241
|
});
|
|
11209
11242
|
var updateAddressSchema = import_joi9.default.object({
|
|
11210
11243
|
line1: import_joi9.default.string().min(3).allow("", null),
|
|
@@ -11234,7 +11267,8 @@ var allowedFieldsSite = [
|
|
|
11234
11267
|
"metadata.guardPosts",
|
|
11235
11268
|
"metadata.gracePeriod",
|
|
11236
11269
|
"metadata.incidentCounter",
|
|
11237
|
-
"metadata.incidentLogo"
|
|
11270
|
+
"metadata.incidentLogo",
|
|
11271
|
+
"metadata.services"
|
|
11238
11272
|
];
|
|
11239
11273
|
var siteSchema = import_joi9.default.object({
|
|
11240
11274
|
name: import_joi9.default.string().required(),
|
|
@@ -12108,9 +12142,7 @@ function useVerificationRepoV2() {
|
|
|
12108
12142
|
}
|
|
12109
12143
|
);
|
|
12110
12144
|
} catch (error) {
|
|
12111
|
-
throw new import_node_server_utils20.InternalServerError(
|
|
12112
|
-
"Failed to retrieve verification."
|
|
12113
|
-
);
|
|
12145
|
+
throw new import_node_server_utils20.InternalServerError("Failed to retrieve verification.");
|
|
12114
12146
|
}
|
|
12115
12147
|
}
|
|
12116
12148
|
async function updateVerificationCodeById(_id, verificationCode, expireAt, session) {
|
|
@@ -12128,9 +12160,7 @@ function useVerificationRepoV2() {
|
|
|
12128
12160
|
{ session }
|
|
12129
12161
|
);
|
|
12130
12162
|
} catch (error) {
|
|
12131
|
-
throw new import_node_server_utils20.InternalServerError(
|
|
12132
|
-
"Failed to update verification code."
|
|
12133
|
-
);
|
|
12163
|
+
throw new import_node_server_utils20.InternalServerError("Failed to update verification code.");
|
|
12134
12164
|
}
|
|
12135
12165
|
}
|
|
12136
12166
|
return {
|
|
@@ -21014,12 +21044,20 @@ var schemaVisitorTransaction = import_joi37.default.object({
|
|
|
21014
21044
|
nric: import_joi37.default.string().optional().allow(null, ""),
|
|
21015
21045
|
visitorPass: import_joi37.default.array().items(
|
|
21016
21046
|
import_joi37.default.object({
|
|
21017
|
-
keyId: import_joi37.default.string().hex().length(24).required()
|
|
21047
|
+
keyId: import_joi37.default.string().hex().length(24).required(),
|
|
21048
|
+
receivedDate: import_joi37.default.date().optional().allow(null),
|
|
21049
|
+
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21050
|
+
lastUpdate: import_joi37.default.date().optional().allow(null),
|
|
21051
|
+
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21018
21052
|
})
|
|
21019
21053
|
).optional().allow(null),
|
|
21020
21054
|
passKeys: import_joi37.default.array().items(
|
|
21021
21055
|
import_joi37.default.object({
|
|
21022
|
-
keyId: import_joi37.default.string().hex().length(24).required()
|
|
21056
|
+
keyId: import_joi37.default.string().hex().length(24).required(),
|
|
21057
|
+
receivedDate: import_joi37.default.date().optional().allow(null),
|
|
21058
|
+
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21059
|
+
lastUpdate: import_joi37.default.date().optional().allow(null),
|
|
21060
|
+
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21023
21061
|
})
|
|
21024
21062
|
).optional().allow(null),
|
|
21025
21063
|
contact: import_joi37.default.string().optional().allow(null, "")
|
|
@@ -21036,19 +21074,28 @@ var schemaVisitorTransaction = import_joi37.default.object({
|
|
|
21036
21074
|
numberOfPassengers: import_joi37.default.number().integer().optional().allow(null, ""),
|
|
21037
21075
|
visitorPass: import_joi37.default.array().items(
|
|
21038
21076
|
import_joi37.default.object({
|
|
21039
|
-
keyId: import_joi37.default.string().hex().length(24).allow(null, "")
|
|
21077
|
+
keyId: import_joi37.default.string().hex().length(24).allow(null, ""),
|
|
21078
|
+
receivedDate: import_joi37.default.date().optional().allow(null),
|
|
21079
|
+
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21080
|
+
lastUpdate: import_joi37.default.date().optional().allow(null),
|
|
21081
|
+
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21040
21082
|
})
|
|
21041
21083
|
).optional().allow(null),
|
|
21042
21084
|
passKeys: import_joi37.default.array().items(
|
|
21043
21085
|
import_joi37.default.object({
|
|
21044
|
-
keyId: import_joi37.default.string().hex().length(24).allow(null, "")
|
|
21086
|
+
keyId: import_joi37.default.string().hex().length(24).allow(null, ""),
|
|
21087
|
+
receivedDate: import_joi37.default.date().optional().allow(null),
|
|
21088
|
+
status: import_joi37.default.string().optional().allow(null, ""),
|
|
21089
|
+
lastUpdate: import_joi37.default.date().optional().allow(null),
|
|
21090
|
+
remarks: import_joi37.default.string().optional().allow(null, "")
|
|
21045
21091
|
})
|
|
21046
21092
|
).optional().allow(null),
|
|
21047
21093
|
checkInRemarks: import_joi37.default.string().optional().allow("", null),
|
|
21048
21094
|
checkOutRemarks: import_joi37.default.string().optional().allow("", null),
|
|
21049
21095
|
expectedCheckIn: import_joi37.default.string().isoDate().optional(),
|
|
21050
21096
|
purpose: import_joi37.default.string().optional().allow(null, ""),
|
|
21051
|
-
inviterId: import_joi37.default.any().optional().allow(null, "")
|
|
21097
|
+
inviterId: import_joi37.default.any().optional().allow(null, ""),
|
|
21098
|
+
createdBy: import_joi37.default.string().hex().length(24).optional().allow(null, "")
|
|
21052
21099
|
});
|
|
21053
21100
|
var schemaUpdateVisTrans = import_joi37.default.object({
|
|
21054
21101
|
_id: import_joi37.default.string().hex().length(24).required(),
|
|
@@ -21168,22 +21215,22 @@ function MVisitorTransaction(value) {
|
|
|
21168
21215
|
throw new Error("Invalid type for manualCheckout key.");
|
|
21169
21216
|
}
|
|
21170
21217
|
}
|
|
21171
|
-
if (
|
|
21218
|
+
if (Array.isArray(value.visitorPass)) {
|
|
21172
21219
|
value.visitorPass = value.visitorPass.map((v) => {
|
|
21173
|
-
|
|
21174
|
-
|
|
21175
|
-
|
|
21176
|
-
|
|
21220
|
+
try {
|
|
21221
|
+
v.keyId = new import_mongodb39.ObjectId(v.keyId);
|
|
21222
|
+
} catch (error2) {
|
|
21223
|
+
throw new Error("Invalid VisitorPass ID.");
|
|
21177
21224
|
}
|
|
21178
21225
|
return v;
|
|
21179
21226
|
});
|
|
21180
21227
|
}
|
|
21181
|
-
if (
|
|
21228
|
+
if (Array.isArray(value.passKeys)) {
|
|
21182
21229
|
value.passKeys = value.passKeys.map((p) => {
|
|
21183
|
-
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21230
|
+
try {
|
|
21231
|
+
p.keyId = new import_mongodb39.ObjectId(p.keyId);
|
|
21232
|
+
} catch (error2) {
|
|
21233
|
+
throw new Error("Invalid PassKey ID.");
|
|
21187
21234
|
}
|
|
21188
21235
|
return p;
|
|
21189
21236
|
});
|
|
@@ -21878,9 +21925,57 @@ function useVisitorTransactionRepo() {
|
|
|
21878
21925
|
}
|
|
21879
21926
|
}
|
|
21880
21927
|
async function resendEmailInvitedResident(visitorId, updatedBy) {
|
|
21881
|
-
const
|
|
21882
|
-
_id: await convertObjectIdUtil(visitorId)
|
|
21883
|
-
|
|
21928
|
+
const pipeline = [
|
|
21929
|
+
{ $match: { _id: await convertObjectIdUtil(visitorId) } },
|
|
21930
|
+
{
|
|
21931
|
+
$lookup: {
|
|
21932
|
+
from: "buildings",
|
|
21933
|
+
localField: "block",
|
|
21934
|
+
foreignField: "_id",
|
|
21935
|
+
as: "blockDetails"
|
|
21936
|
+
}
|
|
21937
|
+
},
|
|
21938
|
+
{
|
|
21939
|
+
$addFields: {
|
|
21940
|
+
blockName: {
|
|
21941
|
+
$ifNull: [
|
|
21942
|
+
{ $arrayElemAt: ["$blockDetails.name", 0] },
|
|
21943
|
+
"Unknown"
|
|
21944
|
+
]
|
|
21945
|
+
}
|
|
21946
|
+
}
|
|
21947
|
+
},
|
|
21948
|
+
{
|
|
21949
|
+
$project: {
|
|
21950
|
+
blockDetails: 0
|
|
21951
|
+
}
|
|
21952
|
+
},
|
|
21953
|
+
{
|
|
21954
|
+
$lookup: {
|
|
21955
|
+
from: "building-levels",
|
|
21956
|
+
localField: "level",
|
|
21957
|
+
foreignField: "_id",
|
|
21958
|
+
as: "levelDetails"
|
|
21959
|
+
}
|
|
21960
|
+
},
|
|
21961
|
+
{
|
|
21962
|
+
$addFields: {
|
|
21963
|
+
levelName: {
|
|
21964
|
+
$ifNull: [
|
|
21965
|
+
{ $arrayElemAt: ["$levelDetails.name", 0] },
|
|
21966
|
+
"Unknown"
|
|
21967
|
+
]
|
|
21968
|
+
}
|
|
21969
|
+
}
|
|
21970
|
+
},
|
|
21971
|
+
{
|
|
21972
|
+
$project: {
|
|
21973
|
+
levelDetails: 0
|
|
21974
|
+
}
|
|
21975
|
+
}
|
|
21976
|
+
];
|
|
21977
|
+
const results = await collection.aggregate(pipeline).toArray();
|
|
21978
|
+
const updatedDocument = results[0] || null;
|
|
21884
21979
|
if (!updatedDocument?.email)
|
|
21885
21980
|
return;
|
|
21886
21981
|
if (!updatedDocument?._id)
|
|
@@ -21895,7 +21990,7 @@ function useVisitorTransactionRepo() {
|
|
|
21895
21990
|
name: `${updatedDocument?.name}`,
|
|
21896
21991
|
plateNumber: updatedDocument?.plateNumber,
|
|
21897
21992
|
nric: updatedDocument?.nric,
|
|
21898
|
-
address: `${updatedDocument?.
|
|
21993
|
+
address: `${updatedDocument?.blockName} ${updatedDocument?.levelName} ${updatedDocument?.unitName}`,
|
|
21899
21994
|
contactNumber: updatedDocument?.contact ? updatedDocument?.contact : "N/A",
|
|
21900
21995
|
email: updatedDocument?.email ? updatedDocument?.email : "N/A",
|
|
21901
21996
|
duration: updatedDocument?.duration ? updatedDocument?.duration : "N/A",
|
|
@@ -27795,7 +27890,7 @@ function useBuildingRepo() {
|
|
|
27795
27890
|
try {
|
|
27796
27891
|
await collection.createIndexes([
|
|
27797
27892
|
{ key: { name: "text" }, name: "text-index" },
|
|
27798
|
-
{ key: { name: 1 }, unique: true, name: "unique-name-index" },
|
|
27893
|
+
// { key: { name: 1 }, unique: true, name: "unique-name-index" },
|
|
27799
27894
|
{ key: { site: 1 } },
|
|
27800
27895
|
{ key: { createdAt: 1 } },
|
|
27801
27896
|
{
|
|
@@ -28472,11 +28567,6 @@ function useBuildingLevelRepo() {
|
|
|
28472
28567
|
try {
|
|
28473
28568
|
await collection.createIndexes([
|
|
28474
28569
|
// Ensure name is unique per blockId
|
|
28475
|
-
{
|
|
28476
|
-
key: { blockId: 1, name: 1 },
|
|
28477
|
-
unique: true,
|
|
28478
|
-
name: "unique_name_per_blockId"
|
|
28479
|
-
},
|
|
28480
28570
|
// Other useful indexes
|
|
28481
28571
|
{ key: { site: 1 }, name: "idx_site" },
|
|
28482
28572
|
{ key: { blockId: 1 }, name: "idx_blockId" },
|
|
@@ -28737,7 +28827,11 @@ function useBuildingLevelRepo() {
|
|
|
28737
28827
|
const res = await collection.bulkWrite(operations, { session });
|
|
28738
28828
|
delCachedData();
|
|
28739
28829
|
return {
|
|
28740
|
-
insertedIds: res.insertedIds
|
|
28830
|
+
insertedIds: res.insertedIds,
|
|
28831
|
+
levels: levels.map((l, i) => ({
|
|
28832
|
+
_id: res.insertedIds[i],
|
|
28833
|
+
name: l.name
|
|
28834
|
+
}))
|
|
28741
28835
|
};
|
|
28742
28836
|
} catch (error) {
|
|
28743
28837
|
import_node_server_utils86.logger.log({
|
|
@@ -29021,8 +29115,8 @@ function useBuildingService() {
|
|
|
29021
29115
|
const name = row.name;
|
|
29022
29116
|
const rawLevel = row.level?.toString().trim();
|
|
29023
29117
|
const rawUnit = row.unit?.toString().trim();
|
|
29024
|
-
const normalizedLevel = /^(na|n\/a)$/i.test(rawLevel) ? null :
|
|
29025
|
-
const normalizedUnit = /^(na|n\/a)$/i.test(rawUnit) ? null :
|
|
29118
|
+
const normalizedLevel = /^(na|n\/a)$/i.test(rawLevel) ? null : rawLevel;
|
|
29119
|
+
const normalizedUnit = /^(na|n\/a)$/i.test(rawUnit) ? null : rawUnit;
|
|
29026
29120
|
if (!blockMap.has(block)) {
|
|
29027
29121
|
blockMap.set(block, { name, levels: [], unitsByLevel: /* @__PURE__ */ new Map() });
|
|
29028
29122
|
}
|
|
@@ -29043,57 +29137,76 @@ function useBuildingService() {
|
|
|
29043
29137
|
}
|
|
29044
29138
|
}
|
|
29045
29139
|
}
|
|
29046
|
-
const buildingPayloads =
|
|
29047
|
-
|
|
29140
|
+
const buildingPayloads = [];
|
|
29141
|
+
const buildingUnitPayloads = [];
|
|
29142
|
+
for (const [
|
|
29143
|
+
block,
|
|
29144
|
+
{ name, levels, unitsByLevel }
|
|
29145
|
+
] of blockMap.entries()) {
|
|
29146
|
+
const buildingId = new import_mongodb53.ObjectId();
|
|
29147
|
+
const levelsPayload = (levels ?? []).map((levelName) => ({
|
|
29148
|
+
blockId: buildingId.toString(),
|
|
29149
|
+
site: site.toString(),
|
|
29150
|
+
name: levelName,
|
|
29151
|
+
status: "active" /* ACTIVE */,
|
|
29152
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
29153
|
+
updatedAt: null,
|
|
29154
|
+
deletedAt: null
|
|
29155
|
+
}));
|
|
29156
|
+
let insertedLevels;
|
|
29157
|
+
if (levelsPayload.length > 0) {
|
|
29158
|
+
insertedLevels = await _bulkWriteLevels(levelsPayload, session);
|
|
29159
|
+
}
|
|
29160
|
+
const levelNameToId = /* @__PURE__ */ new Map();
|
|
29161
|
+
if (insertedLevels) {
|
|
29162
|
+
insertedLevels.levels.forEach((lvl) => {
|
|
29163
|
+
levelNameToId.set(lvl.name, lvl._id);
|
|
29164
|
+
});
|
|
29165
|
+
}
|
|
29166
|
+
const buildingPayload = {
|
|
29167
|
+
_id: buildingId,
|
|
29048
29168
|
site,
|
|
29049
29169
|
block,
|
|
29050
29170
|
name,
|
|
29051
|
-
levels
|
|
29052
|
-
}
|
|
29053
|
-
|
|
29054
|
-
|
|
29055
|
-
|
|
29056
|
-
|
|
29057
|
-
|
|
29058
|
-
|
|
29059
|
-
|
|
29060
|
-
|
|
29061
|
-
|
|
29062
|
-
|
|
29063
|
-
|
|
29064
|
-
|
|
29065
|
-
|
|
29066
|
-
|
|
29067
|
-
|
|
29068
|
-
|
|
29069
|
-
|
|
29070
|
-
|
|
29071
|
-
|
|
29072
|
-
|
|
29073
|
-
|
|
29074
|
-
|
|
29075
|
-
|
|
29076
|
-
|
|
29077
|
-
|
|
29078
|
-
companyRegistrationNumber: "",
|
|
29079
|
-
billing: [],
|
|
29080
|
-
unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null,
|
|
29081
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
29082
|
-
updatedAt: "",
|
|
29083
|
-
deletedAt: ""
|
|
29084
|
-
});
|
|
29171
|
+
levels: insertedLevels ? Object.values(insertedLevels.insertedIds) : []
|
|
29172
|
+
};
|
|
29173
|
+
const buildingResult = await _add(buildingPayload, session);
|
|
29174
|
+
Array.from(unitsByLevel.entries()).forEach(([levelName, units]) => {
|
|
29175
|
+
const levelId = levelNameToId.get(levelName);
|
|
29176
|
+
units.forEach((unit) => {
|
|
29177
|
+
buildingUnitPayloads.push({
|
|
29178
|
+
site: new import_mongodb53.ObjectId(site),
|
|
29179
|
+
name: unit,
|
|
29180
|
+
building: buildingId,
|
|
29181
|
+
// already an ObjectId
|
|
29182
|
+
buildingName: name,
|
|
29183
|
+
block,
|
|
29184
|
+
level: levelId,
|
|
29185
|
+
// ✅ use ObjectId instead of string
|
|
29186
|
+
category: "",
|
|
29187
|
+
status: "active" /* ACTIVE */,
|
|
29188
|
+
buildingUnitFiles: [],
|
|
29189
|
+
owner: "",
|
|
29190
|
+
ownerName: "",
|
|
29191
|
+
companyName: "",
|
|
29192
|
+
companyRegistrationNumber: "",
|
|
29193
|
+
billing: [],
|
|
29194
|
+
unitNumber: parseInt(unit.replace("Unit ", ""), 10) || null,
|
|
29195
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
29196
|
+
updatedAt: "",
|
|
29197
|
+
deletedAt: ""
|
|
29085
29198
|
});
|
|
29086
29199
|
});
|
|
29087
|
-
}
|
|
29088
|
-
|
|
29200
|
+
});
|
|
29201
|
+
}
|
|
29089
29202
|
await _bulkAddBuildingUnits(buildingUnitPayloads);
|
|
29090
|
-
await session
|
|
29203
|
+
await session.commitTransaction();
|
|
29091
29204
|
return { buildingPayloads, buildingUnitPayloads };
|
|
29092
29205
|
} catch (error) {
|
|
29093
|
-
await session
|
|
29206
|
+
await session.abortTransaction();
|
|
29094
29207
|
throw error;
|
|
29095
29208
|
} finally {
|
|
29096
|
-
session
|
|
29209
|
+
session.endSession();
|
|
29097
29210
|
}
|
|
29098
29211
|
}
|
|
29099
29212
|
return {
|
|
@@ -29364,9 +29477,9 @@ function useBuildingController() {
|
|
|
29364
29477
|
const lowerName = originalname.toLowerCase();
|
|
29365
29478
|
const rowSchema = import_joi46.default.object({
|
|
29366
29479
|
block: import_joi46.default.number().integer().min(0).required(),
|
|
29367
|
-
level: import_joi46.default.string().optional().allow(null, ""),
|
|
29368
|
-
unit: import_joi46.default.string().optional().allow(null, ""),
|
|
29369
|
-
category: import_joi46.default.string().trim().
|
|
29480
|
+
level: import_joi46.default.alternatives().try(import_joi46.default.string(), import_joi46.default.number()).custom((value) => String(value)).optional().allow(null, ""),
|
|
29481
|
+
unit: import_joi46.default.alternatives().try(import_joi46.default.string(), import_joi46.default.number()).custom((value) => String(value)).optional().allow(null, ""),
|
|
29482
|
+
category: import_joi46.default.string().trim().optional().allow(null, ""),
|
|
29370
29483
|
name: import_joi46.default.string().trim().optional().allow(null, ""),
|
|
29371
29484
|
email: import_joi46.default.string().email().lowercase().optional().allow(null, ""),
|
|
29372
29485
|
phoneNumber: import_joi46.default.string().trim().optional().allow(null, "")
|
|
@@ -29380,11 +29493,9 @@ function useBuildingController() {
|
|
|
29380
29493
|
{ abortEarly: false, convert: true }
|
|
29381
29494
|
);
|
|
29382
29495
|
if (queryError) {
|
|
29383
|
-
|
|
29384
|
-
|
|
29385
|
-
|
|
29386
|
-
)
|
|
29387
|
-
);
|
|
29496
|
+
const messages = queryError.details.map((d) => d.message).join(", ");
|
|
29497
|
+
import_node_server_utils88.logger.log({ level: "error", message: messages });
|
|
29498
|
+
next(new import_node_server_utils88.BadRequestError(messages));
|
|
29388
29499
|
return;
|
|
29389
29500
|
}
|
|
29390
29501
|
const { site, org } = queryValue;
|
|
@@ -29419,11 +29530,11 @@ function useBuildingController() {
|
|
|
29419
29530
|
} else if (lowerName.endsWith(".csv")) {
|
|
29420
29531
|
rows = await new Promise((resolve, reject) => {
|
|
29421
29532
|
const parsed = [];
|
|
29422
|
-
import_fs3.default.createReadStream(path5).pipe(
|
|
29423
|
-
|
|
29424
|
-
(
|
|
29425
|
-
)
|
|
29426
|
-
|
|
29533
|
+
import_fs3.default.createReadStream(path5).pipe(
|
|
29534
|
+
(0, import_csv_parser.default)({
|
|
29535
|
+
mapHeaders: ({ header }) => header.trim().replace(/\(.*\)/, "").trim()
|
|
29536
|
+
})
|
|
29537
|
+
).on("data", (row) => parsed.push(row)).on("end", () => resolve(parsed)).on("error", reject);
|
|
29427
29538
|
});
|
|
29428
29539
|
} else {
|
|
29429
29540
|
next(
|
|
@@ -29441,6 +29552,7 @@ function useBuildingController() {
|
|
|
29441
29552
|
if (error) {
|
|
29442
29553
|
invalidRows.push({
|
|
29443
29554
|
row: index + 2,
|
|
29555
|
+
// +2 because header is row 1
|
|
29444
29556
|
data: row,
|
|
29445
29557
|
errors: error.details.map((d) => d.message)
|
|
29446
29558
|
});
|
|
@@ -29462,6 +29574,7 @@ function useBuildingController() {
|
|
|
29462
29574
|
import_fs3.default.unlink(path5, () => {
|
|
29463
29575
|
});
|
|
29464
29576
|
} catch (error) {
|
|
29577
|
+
console.log(error);
|
|
29465
29578
|
import_node_server_utils88.logger.log({ level: "error", message: error.message });
|
|
29466
29579
|
next(error);
|
|
29467
29580
|
}
|
|
@@ -33390,17 +33503,13 @@ var KeyRepo = class {
|
|
|
33390
33503
|
}
|
|
33391
33504
|
}
|
|
33392
33505
|
static async updateKeyById(keyId, key, site, session, isChild) {
|
|
33393
|
-
|
|
33394
|
-
|
|
33395
|
-
|
|
33396
|
-
|
|
33397
|
-
|
|
33398
|
-
|
|
33399
|
-
|
|
33400
|
-
delete key.status;
|
|
33401
|
-
} catch (error) {
|
|
33402
|
-
return Promise.reject("Invalid key id");
|
|
33403
|
-
}
|
|
33506
|
+
keyId = await convertObjectIdUtil2(keyId, "keyId");
|
|
33507
|
+
if (site)
|
|
33508
|
+
site = await convertObjectIdUtil2(site, "Site");
|
|
33509
|
+
if (key.updatedBy)
|
|
33510
|
+
key.updatedBy = await convertObjectIdUtil2(key.updatedBy, "Updated By");
|
|
33511
|
+
if (!key.status)
|
|
33512
|
+
delete key.status;
|
|
33404
33513
|
try {
|
|
33405
33514
|
key.updatedAt = /* @__PURE__ */ new Date();
|
|
33406
33515
|
const query = { _id: keyId, ...site && { site } };
|
|
@@ -33413,6 +33522,7 @@ var KeyRepo = class {
|
|
|
33413
33522
|
{ session }
|
|
33414
33523
|
);
|
|
33415
33524
|
let setKeys = [];
|
|
33525
|
+
console.log("updateKeyById result", result);
|
|
33416
33526
|
if (result.modifiedCount > 0) {
|
|
33417
33527
|
const updatedDocs = await this.collection().find(find).toArray();
|
|
33418
33528
|
if (Array.isArray(updatedDocs) && updatedDocs.length > 0) {
|
|
@@ -33427,10 +33537,12 @@ var KeyRepo = class {
|
|
|
33427
33537
|
await this.collectionDynamic("keys-histories").insertMany(setKeys, {
|
|
33428
33538
|
session
|
|
33429
33539
|
});
|
|
33540
|
+
} else {
|
|
33541
|
+
throw new Error("Failed Updating Keys");
|
|
33430
33542
|
}
|
|
33431
33543
|
return result;
|
|
33432
33544
|
} catch (error) {
|
|
33433
|
-
|
|
33545
|
+
throw new Error(error);
|
|
33434
33546
|
}
|
|
33435
33547
|
}
|
|
33436
33548
|
static async deleteKeyById(_id, session) {
|
|
@@ -33580,7 +33692,7 @@ async function send(userIds, title, body, data, isForMAMobileApp = false, appSlu
|
|
|
33580
33692
|
if (isForMAMobileApp) {
|
|
33581
33693
|
tokens = await PushTokenRepo.findTokensByUserIds(userIds, appSlug);
|
|
33582
33694
|
} else {
|
|
33583
|
-
tokens = await PushTokenRepo.findTokensByUserIds(userIds);
|
|
33695
|
+
tokens = await PushTokenRepo.findTokensByUserIds(userIds, appSlug);
|
|
33584
33696
|
}
|
|
33585
33697
|
if (!tokens.length)
|
|
33586
33698
|
return;
|
|
@@ -33628,6 +33740,37 @@ var NotificationService = class {
|
|
|
33628
33740
|
"iservice365-resident-mobile-app"
|
|
33629
33741
|
);
|
|
33630
33742
|
}
|
|
33743
|
+
static async onlineFormRequestStatusUpdated(payload) {
|
|
33744
|
+
let screen = "";
|
|
33745
|
+
let params = {};
|
|
33746
|
+
if (payload.status === "pending" || payload.status === "resubmission") {
|
|
33747
|
+
screen = "/(user)/(online-forms)/form-fill";
|
|
33748
|
+
params = {
|
|
33749
|
+
id: payload.onlineFormId.toString(),
|
|
33750
|
+
submissionStatus: payload.status ?? ""
|
|
33751
|
+
};
|
|
33752
|
+
} else {
|
|
33753
|
+
screen = "/(user)/(online-forms)/submission-detail";
|
|
33754
|
+
params = {
|
|
33755
|
+
id: payload.onlineFormId.toString(),
|
|
33756
|
+
status: payload.status ?? ""
|
|
33757
|
+
};
|
|
33758
|
+
}
|
|
33759
|
+
await send(
|
|
33760
|
+
toStringArray(payload.to),
|
|
33761
|
+
"Online Form",
|
|
33762
|
+
`Your online form has been updated to ${payload.status}.`,
|
|
33763
|
+
{
|
|
33764
|
+
onlineFormId: payload.onlineFormId.toString(),
|
|
33765
|
+
status: payload.status,
|
|
33766
|
+
module: "onlineForm",
|
|
33767
|
+
screen,
|
|
33768
|
+
params: JSON.stringify(params)
|
|
33769
|
+
},
|
|
33770
|
+
false,
|
|
33771
|
+
"iservice365-resident-mobile-app"
|
|
33772
|
+
);
|
|
33773
|
+
}
|
|
33631
33774
|
static async bulletinBoardCreatedForMA(payload) {
|
|
33632
33775
|
await send(
|
|
33633
33776
|
toStringArray(payload.to),
|
|
@@ -33870,51 +34013,51 @@ function useVisitorTransactionService() {
|
|
|
33870
34013
|
for (let i = 0; i < value.members.length; i += chunkSize) {
|
|
33871
34014
|
const chunk = value.members.slice(i, i + chunkSize);
|
|
33872
34015
|
for (const member of chunk) {
|
|
33873
|
-
await KeyRepo.checkPassKeyAvailability(
|
|
33874
|
-
|
|
33875
|
-
member.
|
|
33876
|
-
|
|
33877
|
-
|
|
33878
|
-
|
|
33879
|
-
|
|
33880
|
-
|
|
33881
|
-
|
|
33882
|
-
|
|
33883
|
-
|
|
33884
|
-
|
|
33885
|
-
|
|
33886
|
-
|
|
33887
|
-
|
|
33888
|
-
|
|
33889
|
-
|
|
33890
|
-
|
|
33891
|
-
}
|
|
34016
|
+
await KeyRepo.checkPassKeyAvailability(member.visitorPass, member.passKeys);
|
|
34017
|
+
if (Array.isArray(member.visitorPass)) {
|
|
34018
|
+
for (const item of member.visitorPass) {
|
|
34019
|
+
console.log("Type of keyId:", typeof item.keyId);
|
|
34020
|
+
console.log("item visitorPass", item);
|
|
34021
|
+
await KeyRepo.updateKeyById(
|
|
34022
|
+
item.keyId,
|
|
34023
|
+
{
|
|
34024
|
+
status: "In Use" /* IN_USE */,
|
|
34025
|
+
updatedBy: value.createdBy
|
|
34026
|
+
},
|
|
34027
|
+
value.site,
|
|
34028
|
+
session
|
|
34029
|
+
);
|
|
34030
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34031
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34032
|
+
item.lastUpdate = null;
|
|
34033
|
+
item.remarks = "";
|
|
33892
34034
|
}
|
|
33893
34035
|
}
|
|
33894
|
-
if (
|
|
33895
|
-
for (const
|
|
33896
|
-
|
|
33897
|
-
|
|
33898
|
-
|
|
33899
|
-
|
|
33900
|
-
value.
|
|
33901
|
-
|
|
33902
|
-
|
|
33903
|
-
|
|
33904
|
-
|
|
33905
|
-
|
|
33906
|
-
|
|
33907
|
-
|
|
33908
|
-
|
|
34036
|
+
if (Array.isArray(member.passKeys)) {
|
|
34037
|
+
for (const item of member.passKeys) {
|
|
34038
|
+
await KeyRepo.updateKeyById(
|
|
34039
|
+
item.keyId,
|
|
34040
|
+
{
|
|
34041
|
+
status: "In Use" /* IN_USE */,
|
|
34042
|
+
updatedBy: value.createdBy
|
|
34043
|
+
},
|
|
34044
|
+
value.site,
|
|
34045
|
+
session
|
|
34046
|
+
);
|
|
34047
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34048
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34049
|
+
item.lastUpdate = null;
|
|
34050
|
+
item.remarks = "";
|
|
33909
34051
|
}
|
|
33910
34052
|
}
|
|
33911
34053
|
}
|
|
33912
34054
|
await Promise.all(
|
|
33913
34055
|
chunk.map((member) => {
|
|
33914
|
-
const
|
|
34056
|
+
const clonedMember = structuredClone(member);
|
|
34057
|
+
const { visitorPass, passKeys } = clonedMember;
|
|
33915
34058
|
return _add(
|
|
33916
34059
|
{
|
|
33917
|
-
...
|
|
34060
|
+
...clonedMember,
|
|
33918
34061
|
block,
|
|
33919
34062
|
level,
|
|
33920
34063
|
unit,
|
|
@@ -33961,184 +34104,184 @@ function useVisitorTransactionService() {
|
|
|
33961
34104
|
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
33962
34105
|
}
|
|
33963
34106
|
await KeyRepo.checkPassKeyAvailability(value.visitorPass, value.passKeys);
|
|
33964
|
-
if (
|
|
34107
|
+
if (Array.isArray(value.visitorPass)) {
|
|
34108
|
+
for (const item of value.visitorPass) {
|
|
34109
|
+
await KeyRepo.updateKeyById(
|
|
34110
|
+
item.keyId,
|
|
34111
|
+
{
|
|
34112
|
+
status: "In Use" /* IN_USE */,
|
|
34113
|
+
updatedBy: value.createdBy
|
|
34114
|
+
},
|
|
34115
|
+
value.site,
|
|
34116
|
+
session
|
|
34117
|
+
);
|
|
34118
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34119
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34120
|
+
item.lastUpdate = null;
|
|
34121
|
+
item.remarks = "";
|
|
34122
|
+
}
|
|
34123
|
+
}
|
|
34124
|
+
if (Array.isArray(value.passKeys)) {
|
|
34125
|
+
for (const item of value.passKeys) {
|
|
34126
|
+
await KeyRepo.updateKeyById(
|
|
34127
|
+
item.keyId,
|
|
34128
|
+
{
|
|
34129
|
+
status: "In Use" /* IN_USE */,
|
|
34130
|
+
updatedBy: value.createdBy
|
|
34131
|
+
},
|
|
34132
|
+
value.site,
|
|
34133
|
+
session
|
|
34134
|
+
);
|
|
34135
|
+
item.receivedDate = /* @__PURE__ */ new Date();
|
|
34136
|
+
item.status = "Not Returned" /* NOT_RETURNED */;
|
|
34137
|
+
item.lastUpdate = null;
|
|
34138
|
+
item.remarks = "";
|
|
34139
|
+
}
|
|
34140
|
+
}
|
|
34141
|
+
const result = await _add(value, session);
|
|
34142
|
+
await session?.commitTransaction();
|
|
34143
|
+
let openBarrier = null;
|
|
34144
|
+
const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
|
|
34145
|
+
if (isOpenBarrier && value.plateNumber && host && username && password) {
|
|
34146
|
+
try {
|
|
34147
|
+
import_node_server_utils106.logger.info(`Attempting to open barrier at host: ${host}`);
|
|
34148
|
+
openBarrier = await _openBarrier({
|
|
34149
|
+
host,
|
|
34150
|
+
username,
|
|
34151
|
+
password,
|
|
34152
|
+
plateNumber: value?.plateNumber
|
|
34153
|
+
});
|
|
34154
|
+
import_node_server_utils106.logger.info(`Barrier command sent successfully to ${host}`, {
|
|
34155
|
+
response: openBarrier
|
|
34156
|
+
});
|
|
34157
|
+
} catch (error) {
|
|
34158
|
+
import_node_server_utils106.logger.error(
|
|
34159
|
+
`Failed to open barrier at host ${host}. Critical system error:`,
|
|
34160
|
+
error
|
|
34161
|
+
);
|
|
34162
|
+
openBarrier = { success: false, error: error?.message };
|
|
34163
|
+
}
|
|
34164
|
+
}
|
|
34165
|
+
console.log("Open barrier response:", openBarrier);
|
|
34166
|
+
return result;
|
|
34167
|
+
} catch (error) {
|
|
34168
|
+
await session?.abortTransaction();
|
|
34169
|
+
throw error;
|
|
34170
|
+
} finally {
|
|
34171
|
+
session?.endSession();
|
|
34172
|
+
}
|
|
34173
|
+
}
|
|
34174
|
+
async function updateVisitorTransactionById(id, value) {
|
|
34175
|
+
const session = import_node_server_utils106.useAtlas.getClient()?.startSession();
|
|
34176
|
+
session?.startTransaction();
|
|
34177
|
+
try {
|
|
34178
|
+
let camera;
|
|
34179
|
+
let host;
|
|
34180
|
+
let username;
|
|
34181
|
+
let password;
|
|
34182
|
+
if (value.site && value.plateNumber) {
|
|
34183
|
+
try {
|
|
34184
|
+
camera = await _getVisitorsInBySite(value.site);
|
|
34185
|
+
if (!camera) {
|
|
34186
|
+
import_node_server_utils106.logger.warn(`No camera document found for site: ${value.site}`);
|
|
34187
|
+
}
|
|
34188
|
+
} catch (error) {
|
|
34189
|
+
import_node_server_utils106.logger.error(
|
|
34190
|
+
`Error _getVisitorsInBySite camera for site ${value.site}:`,
|
|
34191
|
+
error
|
|
34192
|
+
);
|
|
34193
|
+
}
|
|
34194
|
+
}
|
|
34195
|
+
if (camera && value.plateNumber && camera.host && camera.username && camera.password) {
|
|
34196
|
+
host = camera.host;
|
|
34197
|
+
username = camera.username;
|
|
34198
|
+
password = camera.password;
|
|
34199
|
+
const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
|
|
34200
|
+
const _plateNumber = value.plateNumber;
|
|
34201
|
+
const dahuaBlocklistQuery = {
|
|
34202
|
+
host,
|
|
34203
|
+
username,
|
|
34204
|
+
password,
|
|
34205
|
+
plateNumber: _plateNumber,
|
|
34206
|
+
mode: blacklist
|
|
34207
|
+
};
|
|
34208
|
+
const isBlocklistedRaw = await _getPlateNumber(dahuaBlocklistQuery);
|
|
34209
|
+
const rawString = isBlocklistedRaw?.toString?.("utf-8") ?? String(isBlocklistedRaw);
|
|
34210
|
+
const foundMatch = rawString.match(/found=(\d+)/);
|
|
34211
|
+
const found = foundMatch ? Number(foundMatch[1]) : 0;
|
|
34212
|
+
if (found === 1)
|
|
34213
|
+
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
34214
|
+
}
|
|
34215
|
+
if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
34216
|
+
const keptVisitorPass = [];
|
|
33965
34217
|
for (const vp of value.visitorPass) {
|
|
33966
|
-
|
|
33967
|
-
|
|
33968
|
-
|
|
33969
|
-
|
|
33970
|
-
|
|
33971
|
-
|
|
33972
|
-
|
|
33973
|
-
|
|
33974
|
-
|
|
33975
|
-
|
|
33976
|
-
|
|
33977
|
-
|
|
34218
|
+
const updatePayload = {
|
|
34219
|
+
...vp.status && { status: vp.status },
|
|
34220
|
+
...vp.remarks && { remarks: vp.remarks }
|
|
34221
|
+
};
|
|
34222
|
+
const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb62.ObjectId ? vp : vp.keyId;
|
|
34223
|
+
await KeyRepo.updateKeyById(
|
|
34224
|
+
visitorPassId,
|
|
34225
|
+
updatePayload,
|
|
34226
|
+
value.site
|
|
34227
|
+
);
|
|
34228
|
+
if (typeof vp !== "string" && !(vp instanceof import_mongodb62.ObjectId)) {
|
|
34229
|
+
keptVisitorPass.push({
|
|
34230
|
+
keyId: new import_mongodb62.ObjectId(visitorPassId)
|
|
34231
|
+
});
|
|
33978
34232
|
}
|
|
33979
34233
|
}
|
|
34234
|
+
value.visitorPass = keptVisitorPass;
|
|
33980
34235
|
}
|
|
33981
34236
|
if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
|
|
34237
|
+
const keptPassKeys = [];
|
|
33982
34238
|
for (const pk of value.passKeys) {
|
|
33983
34239
|
try {
|
|
33984
|
-
const updatePayload = {
|
|
34240
|
+
const updatePayload = {
|
|
34241
|
+
...pk.status && { status: pk.status },
|
|
34242
|
+
...pk.remarks && { remarks: pk.remarks }
|
|
34243
|
+
};
|
|
33985
34244
|
const passKeyId = typeof pk === "string" || pk instanceof import_mongodb62.ObjectId ? pk : pk.keyId;
|
|
33986
|
-
if (!passKeyId)
|
|
33987
|
-
value.passKeys = [];
|
|
33988
34245
|
await KeyRepo.updateKeyById(
|
|
33989
34246
|
passKeyId,
|
|
33990
34247
|
updatePayload,
|
|
33991
34248
|
value.site
|
|
33992
34249
|
);
|
|
34250
|
+
if (typeof pk !== "string" && !(pk instanceof import_mongodb62.ObjectId)) {
|
|
34251
|
+
keptPassKeys.push({
|
|
34252
|
+
keyId: new import_mongodb62.ObjectId(passKeyId)
|
|
34253
|
+
});
|
|
34254
|
+
}
|
|
33993
34255
|
} catch (error) {
|
|
33994
34256
|
throw error;
|
|
33995
34257
|
}
|
|
33996
34258
|
}
|
|
34259
|
+
value.passKeys = keptPassKeys;
|
|
33997
34260
|
}
|
|
33998
|
-
|
|
33999
|
-
|
|
34000
|
-
|
|
34001
|
-
|
|
34002
|
-
if (
|
|
34003
|
-
|
|
34004
|
-
|
|
34005
|
-
|
|
34006
|
-
|
|
34007
|
-
|
|
34008
|
-
|
|
34009
|
-
|
|
34010
|
-
|
|
34011
|
-
|
|
34012
|
-
|
|
34013
|
-
|
|
34014
|
-
|
|
34015
|
-
|
|
34016
|
-
|
|
34017
|
-
|
|
34018
|
-
|
|
34019
|
-
|
|
34020
|
-
|
|
34021
|
-
|
|
34022
|
-
console.log("Open barrier response:", openBarrier);
|
|
34023
|
-
return result;
|
|
34024
|
-
} catch (error) {
|
|
34025
|
-
await session?.abortTransaction();
|
|
34026
|
-
throw error;
|
|
34027
|
-
} finally {
|
|
34028
|
-
session?.endSession();
|
|
34029
|
-
}
|
|
34030
|
-
}
|
|
34031
|
-
async function updateVisitorTransactionById(id, value) {
|
|
34032
|
-
const session = import_node_server_utils106.useAtlas.getClient()?.startSession();
|
|
34033
|
-
session?.startTransaction();
|
|
34034
|
-
try {
|
|
34035
|
-
let camera;
|
|
34036
|
-
let host;
|
|
34037
|
-
let username;
|
|
34038
|
-
let password;
|
|
34039
|
-
if (value.site && value.plateNumber) {
|
|
34040
|
-
try {
|
|
34041
|
-
camera = await _getVisitorsInBySite(value.site);
|
|
34042
|
-
if (!camera) {
|
|
34043
|
-
import_node_server_utils106.logger.warn(`No camera document found for site: ${value.site}`);
|
|
34044
|
-
}
|
|
34045
|
-
} catch (error) {
|
|
34046
|
-
import_node_server_utils106.logger.error(
|
|
34047
|
-
`Error _getVisitorsInBySite camera for site ${value.site}:`,
|
|
34048
|
-
error
|
|
34049
|
-
);
|
|
34050
|
-
}
|
|
34051
|
-
}
|
|
34052
|
-
if (camera && value.plateNumber && camera.host && camera.username && camera.password) {
|
|
34053
|
-
host = camera.host;
|
|
34054
|
-
username = camera.username;
|
|
34055
|
-
password = camera.password;
|
|
34056
|
-
const blacklist = "TrafficBlackList" /* TRAFFIC_BLACKLIST */;
|
|
34057
|
-
const _plateNumber = value.plateNumber;
|
|
34058
|
-
const dahuaBlocklistQuery = {
|
|
34059
|
-
host,
|
|
34060
|
-
username,
|
|
34061
|
-
password,
|
|
34062
|
-
plateNumber: _plateNumber,
|
|
34063
|
-
mode: blacklist
|
|
34064
|
-
};
|
|
34065
|
-
const isBlocklistedRaw = await _getPlateNumber(dahuaBlocklistQuery);
|
|
34066
|
-
const rawString = isBlocklistedRaw?.toString?.("utf-8") ?? String(isBlocklistedRaw);
|
|
34067
|
-
const foundMatch = rawString.match(/found=(\d+)/);
|
|
34068
|
-
const found = foundMatch ? Number(foundMatch[1]) : 0;
|
|
34069
|
-
if (found === 1)
|
|
34070
|
-
throw new import_node_server_utils106.BadRequestError("This plate number is blocklisted");
|
|
34071
|
-
}
|
|
34072
|
-
if (Array.isArray(value.visitorPass) && value.visitorPass.length > 0) {
|
|
34073
|
-
const keptVisitorPass = [];
|
|
34074
|
-
for (const vp of value.visitorPass) {
|
|
34075
|
-
const updatePayload = {
|
|
34076
|
-
...vp.status && { status: vp.status },
|
|
34077
|
-
...vp.remarks && { remarks: vp.remarks }
|
|
34078
|
-
};
|
|
34079
|
-
const visitorPassId = typeof vp === "string" || vp instanceof import_mongodb62.ObjectId ? vp : vp.keyId;
|
|
34080
|
-
await KeyRepo.updateKeyById(
|
|
34081
|
-
visitorPassId,
|
|
34082
|
-
updatePayload,
|
|
34083
|
-
value.site
|
|
34084
|
-
);
|
|
34085
|
-
if (typeof vp !== "string" && !(vp instanceof import_mongodb62.ObjectId)) {
|
|
34086
|
-
keptVisitorPass.push({
|
|
34087
|
-
keyId: new import_mongodb62.ObjectId(visitorPassId)
|
|
34088
|
-
});
|
|
34089
|
-
}
|
|
34090
|
-
}
|
|
34091
|
-
value.visitorPass = keptVisitorPass;
|
|
34092
|
-
}
|
|
34093
|
-
if (value.passKeys && Array.isArray(value.passKeys) && value.passKeys.length > 0) {
|
|
34094
|
-
const keptPassKeys = [];
|
|
34095
|
-
for (const pk of value.passKeys) {
|
|
34096
|
-
try {
|
|
34097
|
-
const updatePayload = {
|
|
34098
|
-
...pk.status && { status: pk.status },
|
|
34099
|
-
...pk.remarks && { remarks: pk.remarks }
|
|
34100
|
-
};
|
|
34101
|
-
const passKeyId = typeof pk === "string" || pk instanceof import_mongodb62.ObjectId ? pk : pk.keyId;
|
|
34102
|
-
await KeyRepo.updateKeyById(
|
|
34103
|
-
passKeyId,
|
|
34104
|
-
updatePayload,
|
|
34105
|
-
value.site
|
|
34106
|
-
);
|
|
34107
|
-
if (typeof pk !== "string" && !(pk instanceof import_mongodb62.ObjectId)) {
|
|
34108
|
-
keptPassKeys.push({
|
|
34109
|
-
keyId: new import_mongodb62.ObjectId(passKeyId)
|
|
34110
|
-
});
|
|
34111
|
-
}
|
|
34112
|
-
} catch (error) {
|
|
34113
|
-
throw error;
|
|
34114
|
-
}
|
|
34115
|
-
}
|
|
34116
|
-
value.passKeys = keptPassKeys;
|
|
34117
|
-
}
|
|
34118
|
-
if (value.checkIn) {
|
|
34119
|
-
const parsed = new Date(value.checkIn);
|
|
34120
|
-
value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
|
|
34121
|
-
}
|
|
34122
|
-
if (value.checkOut) {
|
|
34123
|
-
const parsed = new Date(value.checkOut);
|
|
34124
|
-
value.checkOut = isNaN(parsed.getTime()) ? null : parsed;
|
|
34125
|
-
}
|
|
34126
|
-
if (value.site) {
|
|
34127
|
-
value.site = typeof value.site === "string" ? new import_mongodb62.ObjectId(value.site) : value.site;
|
|
34128
|
-
}
|
|
34129
|
-
if (value.unit) {
|
|
34130
|
-
value.unit = typeof value.unit === "string" ? new import_mongodb62.ObjectId(value.unit) : value.unit;
|
|
34131
|
-
const unit = await _getUnitById(value.unit);
|
|
34132
|
-
value.unitName = unit?.name;
|
|
34133
|
-
}
|
|
34134
|
-
await _updateVisitorTansactionById(id, value, session);
|
|
34135
|
-
const allowedPersonTypes = [
|
|
34136
|
-
"contractor" /* CONTRACTOR */,
|
|
34137
|
-
"walk-in" /* WALK_IN */,
|
|
34138
|
-
"guest" /* GUEST */,
|
|
34139
|
-
"delivery" /* DELIVERY */
|
|
34140
|
-
// PersonTypes.PICK_UP,
|
|
34141
|
-
];
|
|
34261
|
+
if (value.checkIn) {
|
|
34262
|
+
const parsed = new Date(value.checkIn);
|
|
34263
|
+
value.checkIn = isNaN(parsed.getTime()) ? null : parsed;
|
|
34264
|
+
}
|
|
34265
|
+
if (value.checkOut) {
|
|
34266
|
+
const parsed = new Date(value.checkOut);
|
|
34267
|
+
value.checkOut = isNaN(parsed.getTime()) ? null : parsed;
|
|
34268
|
+
}
|
|
34269
|
+
if (value.site) {
|
|
34270
|
+
value.site = typeof value.site === "string" ? new import_mongodb62.ObjectId(value.site) : value.site;
|
|
34271
|
+
}
|
|
34272
|
+
if (value.unit) {
|
|
34273
|
+
value.unit = typeof value.unit === "string" ? new import_mongodb62.ObjectId(value.unit) : value.unit;
|
|
34274
|
+
const unit = await _getUnitById(value.unit);
|
|
34275
|
+
value.unitName = unit?.name;
|
|
34276
|
+
}
|
|
34277
|
+
await _updateVisitorTansactionById(id, value, session);
|
|
34278
|
+
const allowedPersonTypes = [
|
|
34279
|
+
"contractor" /* CONTRACTOR */,
|
|
34280
|
+
"walk-in" /* WALK_IN */,
|
|
34281
|
+
"guest" /* GUEST */,
|
|
34282
|
+
"delivery" /* DELIVERY */
|
|
34283
|
+
// PersonTypes.PICK_UP,
|
|
34284
|
+
];
|
|
34142
34285
|
let openBarrier = null;
|
|
34143
34286
|
const isOpenBarrier = allowedPersonTypes.includes(value?.type) || camera?.ANPRSwitches?.openBarrierPickUpDropOff == true;
|
|
34144
34287
|
if (isOpenBarrier && value.plateNumber && host && username && password) {
|
|
@@ -34275,9 +34418,9 @@ function useVisitorTransactionService() {
|
|
|
34275
34418
|
value.checkIn = null;
|
|
34276
34419
|
const payload = {
|
|
34277
34420
|
...value,
|
|
34278
|
-
block: inviter?.block,
|
|
34279
|
-
level: inviter?.level,
|
|
34280
|
-
unit: inviter?.unit,
|
|
34421
|
+
block: inviter?.block?.toString(),
|
|
34422
|
+
level: inviter?.level?.toString(),
|
|
34423
|
+
unit: inviter?.unit?.toString(),
|
|
34281
34424
|
unitName: unit?.name,
|
|
34282
34425
|
org: inviter?.org.toString(),
|
|
34283
34426
|
site: inviter?.site.toString(),
|
|
@@ -34373,7 +34516,8 @@ function useVisitorTransactionController() {
|
|
|
34373
34516
|
} = useVisitorTransactionRepo();
|
|
34374
34517
|
async function add(req, res, next) {
|
|
34375
34518
|
try {
|
|
34376
|
-
const {
|
|
34519
|
+
const { companyName, firstName, lastName, ...restData } = req.body;
|
|
34520
|
+
const { error, value } = schemaVisitorTransaction.validate(restData, {
|
|
34377
34521
|
abortEarly: false
|
|
34378
34522
|
});
|
|
34379
34523
|
if (error) {
|
|
@@ -34605,8 +34749,11 @@ function useVisitorTransactionController() {
|
|
|
34605
34749
|
return;
|
|
34606
34750
|
} catch (error2) {
|
|
34607
34751
|
import_node_server_utils107.logger.log({ level: "error", message: error2.message });
|
|
34608
|
-
|
|
34609
|
-
|
|
34752
|
+
if (error2?.message) {
|
|
34753
|
+
next(new import_node_server_utils107.BadRequestError(error2?.message));
|
|
34754
|
+
} else {
|
|
34755
|
+
next(error2);
|
|
34756
|
+
}
|
|
34610
34757
|
}
|
|
34611
34758
|
}
|
|
34612
34759
|
async function changeVisitorTransactionKeysById(req, res, next) {
|
|
@@ -57654,7 +57801,8 @@ function useNewDashboardRepo() {
|
|
|
57654
57801
|
site,
|
|
57655
57802
|
serviceType,
|
|
57656
57803
|
page = 1,
|
|
57657
|
-
limit = 10
|
|
57804
|
+
limit = 10,
|
|
57805
|
+
period = "today" /* TODAY */
|
|
57658
57806
|
}) {
|
|
57659
57807
|
page = page > 0 ? page - 1 : 0;
|
|
57660
57808
|
const cacheOptions = { serviceType, page, limit };
|
|
@@ -57664,9 +57812,7 @@ function useNewDashboardRepo() {
|
|
|
57664
57812
|
} catch {
|
|
57665
57813
|
throw new import_node_server_utils199.BadRequestError("Invalid site ID format.");
|
|
57666
57814
|
}
|
|
57667
|
-
const
|
|
57668
|
-
const todayEnd = import_moment.default.tz("Asia/Singapore").endOf("day").toDate();
|
|
57669
|
-
const todayRange = { $gte: todayStart, $lte: todayEnd };
|
|
57815
|
+
const todayRange = getDateRange(period);
|
|
57670
57816
|
try {
|
|
57671
57817
|
const [items, countResult] = await Promise.all([
|
|
57672
57818
|
areaChecklistCollection.aggregate([
|
|
@@ -57742,7 +57888,8 @@ function useNewDashboardRepo() {
|
|
|
57742
57888
|
site,
|
|
57743
57889
|
serviceType,
|
|
57744
57890
|
page = 1,
|
|
57745
|
-
limit = 10
|
|
57891
|
+
limit = 10,
|
|
57892
|
+
period = "today" /* TODAY */
|
|
57746
57893
|
}) {
|
|
57747
57894
|
page = page > 0 ? page - 1 : 0;
|
|
57748
57895
|
const cacheOptions = { serviceType, page, limit };
|
|
@@ -57752,8 +57899,9 @@ function useNewDashboardRepo() {
|
|
|
57752
57899
|
} catch {
|
|
57753
57900
|
throw new import_node_server_utils199.BadRequestError("Invalid site ID format.");
|
|
57754
57901
|
}
|
|
57755
|
-
const
|
|
57756
|
-
const
|
|
57902
|
+
const periodRange = getDateRange(period);
|
|
57903
|
+
const todayStart = periodRange.$gte;
|
|
57904
|
+
const todayEnd = periodRange.$lte;
|
|
57757
57905
|
const todayStartStr = todayStart.toISOString();
|
|
57758
57906
|
const todayEndStr = todayEnd.toISOString();
|
|
57759
57907
|
try {
|
|
@@ -57870,7 +58018,8 @@ function useNewDashboardRepo() {
|
|
|
57870
58018
|
site,
|
|
57871
58019
|
serviceType,
|
|
57872
58020
|
page = 1,
|
|
57873
|
-
limit = 10
|
|
58021
|
+
limit = 10,
|
|
58022
|
+
period = "today" /* TODAY */
|
|
57874
58023
|
}) {
|
|
57875
58024
|
page = page > 0 ? page - 1 : 0;
|
|
57876
58025
|
const cacheOptions = { serviceType, page, limit };
|
|
@@ -57881,10 +58030,14 @@ function useNewDashboardRepo() {
|
|
|
57881
58030
|
throw new import_node_server_utils199.BadRequestError("Invalid site ID format.");
|
|
57882
58031
|
}
|
|
57883
58032
|
const workOrderService = workOrderServiceMap[serviceType] ?? serviceType;
|
|
58033
|
+
const matchQuery = { site, service: workOrderService };
|
|
58034
|
+
if (period) {
|
|
58035
|
+
matchQuery.createdAt = getDateRange(period);
|
|
58036
|
+
}
|
|
57884
58037
|
try {
|
|
57885
58038
|
const [items, length] = await Promise.all([
|
|
57886
58039
|
feedbackCollection.aggregate([
|
|
57887
|
-
{ $match:
|
|
58040
|
+
{ $match: matchQuery },
|
|
57888
58041
|
{ $sort: { createdAt: -1, _id: -1 } },
|
|
57889
58042
|
{
|
|
57890
58043
|
$lookup: {
|
|
@@ -57907,7 +58060,7 @@ function useNewDashboardRepo() {
|
|
|
57907
58060
|
{ $skip: page * limit },
|
|
57908
58061
|
{ $limit: limit }
|
|
57909
58062
|
]).toArray(),
|
|
57910
|
-
feedbackCollection.countDocuments(
|
|
58063
|
+
feedbackCollection.countDocuments(matchQuery)
|
|
57911
58064
|
]);
|
|
57912
58065
|
const data = (0, import_node_server_utils199.paginate)(items, page, limit, length);
|
|
57913
58066
|
return data;
|
|
@@ -58067,6 +58220,7 @@ function useNewDashboardController() {
|
|
|
58067
58220
|
const validation = import_joi112.default.object({
|
|
58068
58221
|
site: import_joi112.default.string().hex().required(),
|
|
58069
58222
|
serviceType: import_joi112.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
58223
|
+
period: import_joi112.default.string().valid(...Object.values(Period)).default("today" /* TODAY */),
|
|
58070
58224
|
page: import_joi112.default.number().min(1).optional().allow("", null),
|
|
58071
58225
|
limit: import_joi112.default.number().min(1).optional().allow("", null)
|
|
58072
58226
|
});
|
|
@@ -58078,12 +58232,14 @@ function useNewDashboardController() {
|
|
|
58078
58232
|
}
|
|
58079
58233
|
const site = req.params.site;
|
|
58080
58234
|
const serviceType = req.params.serviceType;
|
|
58235
|
+
const period = req.query.period;
|
|
58081
58236
|
const page = parseInt(req.query.page) ?? 1;
|
|
58082
58237
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
58083
58238
|
try {
|
|
58084
58239
|
const data = await _getServiceTodayTaskSchedule({
|
|
58085
58240
|
site,
|
|
58086
58241
|
serviceType,
|
|
58242
|
+
period,
|
|
58087
58243
|
page,
|
|
58088
58244
|
limit
|
|
58089
58245
|
});
|
|
@@ -58100,6 +58256,7 @@ function useNewDashboardController() {
|
|
|
58100
58256
|
const validation = import_joi112.default.object({
|
|
58101
58257
|
site: import_joi112.default.string().hex().required(),
|
|
58102
58258
|
serviceType: import_joi112.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
58259
|
+
period: import_joi112.default.string().valid(...Object.values(Period)).default("today" /* TODAY */),
|
|
58103
58260
|
page: import_joi112.default.number().min(1).optional().allow("", null),
|
|
58104
58261
|
limit: import_joi112.default.number().min(1).optional().allow("", null)
|
|
58105
58262
|
});
|
|
@@ -58111,12 +58268,14 @@ function useNewDashboardController() {
|
|
|
58111
58268
|
}
|
|
58112
58269
|
const site = req.params.site;
|
|
58113
58270
|
const serviceType = req.params.serviceType;
|
|
58271
|
+
const period = req.query.period;
|
|
58114
58272
|
const page = parseInt(req.query.page) ?? 1;
|
|
58115
58273
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
58116
58274
|
try {
|
|
58117
58275
|
const data = await _getServiceStaffAttendance({
|
|
58118
58276
|
site,
|
|
58119
58277
|
serviceType,
|
|
58278
|
+
period,
|
|
58120
58279
|
page,
|
|
58121
58280
|
limit
|
|
58122
58281
|
});
|
|
@@ -58133,6 +58292,7 @@ function useNewDashboardController() {
|
|
|
58133
58292
|
const validation = import_joi112.default.object({
|
|
58134
58293
|
site: import_joi112.default.string().hex().required(),
|
|
58135
58294
|
serviceType: import_joi112.default.string().valid(...Object.values(AppServiceType)).required(),
|
|
58295
|
+
period: import_joi112.default.string().valid(...Object.values(Period)).default("today" /* TODAY */),
|
|
58136
58296
|
page: import_joi112.default.number().min(1).optional().allow("", null),
|
|
58137
58297
|
limit: import_joi112.default.number().min(1).optional().allow("", null)
|
|
58138
58298
|
});
|
|
@@ -58144,12 +58304,14 @@ function useNewDashboardController() {
|
|
|
58144
58304
|
}
|
|
58145
58305
|
const site = req.params.site;
|
|
58146
58306
|
const serviceType = req.params.serviceType;
|
|
58307
|
+
const period = req.query.period;
|
|
58147
58308
|
const page = parseInt(req.query.page) ?? 1;
|
|
58148
58309
|
const limit = parseInt(req.query.limit) ?? 10;
|
|
58149
58310
|
try {
|
|
58150
58311
|
const data = await _getServiceRecentFeedbacks({
|
|
58151
58312
|
site,
|
|
58152
58313
|
serviceType,
|
|
58314
|
+
period,
|
|
58153
58315
|
page,
|
|
58154
58316
|
limit
|
|
58155
58317
|
});
|
|
@@ -66094,10 +66256,6 @@ function useChatPrelovedRepo() {
|
|
|
66094
66256
|
return { add, updateById, deleteById };
|
|
66095
66257
|
}
|
|
66096
66258
|
|
|
66097
|
-
// src/controllers/chat-preloved.controller.ts
|
|
66098
|
-
var import_node_server_utils248 = require("@7365admin1/node-server-utils");
|
|
66099
|
-
var import_joi143 = __toESM(require("joi"));
|
|
66100
|
-
|
|
66101
66259
|
// src/services/chat-preloved.service.ts
|
|
66102
66260
|
var import_node_server_utils247 = require("@7365admin1/node-server-utils");
|
|
66103
66261
|
|
|
@@ -66424,6 +66582,8 @@ function useChatPrelovedService() {
|
|
|
66424
66582
|
}
|
|
66425
66583
|
|
|
66426
66584
|
// src/controllers/chat-preloved.controller.ts
|
|
66585
|
+
var import_node_server_utils248 = require("@7365admin1/node-server-utils");
|
|
66586
|
+
var import_joi143 = __toESM(require("joi"));
|
|
66427
66587
|
function useChatPrelovedController() {
|
|
66428
66588
|
const { add: _add } = useChatPrelovedService();
|
|
66429
66589
|
const { updateById: _updateById, deleteById: _deleteById } = useChatPrelovedRepo();
|
|
@@ -66603,58 +66763,226 @@ function useChannelPrelovedController() {
|
|
|
66603
66763
|
return { add, getChannel, getChatLists, getChannelMessages };
|
|
66604
66764
|
}
|
|
66605
66765
|
|
|
66606
|
-
// src/models/
|
|
66766
|
+
// src/models/bid-preloved.model.ts
|
|
66607
66767
|
var import_joi145 = __toESM(require("joi"));
|
|
66608
66768
|
var import_mongodb149 = require("mongodb");
|
|
66769
|
+
var BidType = /* @__PURE__ */ ((BidType2) => {
|
|
66770
|
+
BidType2["BID"] = "bid";
|
|
66771
|
+
BidType2["RESERVE"] = "reserve";
|
|
66772
|
+
return BidType2;
|
|
66773
|
+
})(BidType || {});
|
|
66774
|
+
var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
|
|
66775
|
+
BidStatus3["PENDING"] = "pending";
|
|
66776
|
+
BidStatus3["ACCEPTED"] = "accepted";
|
|
66777
|
+
BidStatus3["RESERVED"] = "reserved";
|
|
66778
|
+
BidStatus3["CANCELLED"] = "cancelled";
|
|
66779
|
+
return BidStatus3;
|
|
66780
|
+
})(BidStatus || {});
|
|
66781
|
+
var schemaBidPreloved = import_joi145.default.object({
|
|
66782
|
+
type: import_joi145.default.string().valid(...Object.values(BidType)).required(),
|
|
66783
|
+
postId: import_joi145.default.string().hex().length(24).required(),
|
|
66784
|
+
price: import_joi145.default.when("type", {
|
|
66785
|
+
is: "bid" /* BID */,
|
|
66786
|
+
then: import_joi145.default.number().required(),
|
|
66787
|
+
otherwise: import_joi145.default.number().optional().allow(null)
|
|
66788
|
+
}),
|
|
66789
|
+
message: import_joi145.default.string().optional().allow("", null),
|
|
66790
|
+
buyerId: import_joi145.default.string().hex().length(24).optional().allow("", null),
|
|
66791
|
+
status: import_joi145.default.string().valid(...Object.values(BidStatus)).optional().default("pending" /* PENDING */)
|
|
66792
|
+
});
|
|
66793
|
+
var schemaUpdateBidPreloved = import_joi145.default.object({
|
|
66794
|
+
status: import_joi145.default.string().valid(...Object.values(BidStatus)).required()
|
|
66795
|
+
});
|
|
66796
|
+
function MBidPreloved(value) {
|
|
66797
|
+
const { error } = schemaBidPreloved.validate(value);
|
|
66798
|
+
if (error)
|
|
66799
|
+
throw new Error(error.details[0].message);
|
|
66800
|
+
if (value.postId && typeof value.postId === "string")
|
|
66801
|
+
value.postId = new import_mongodb149.ObjectId(value.postId);
|
|
66802
|
+
if (value.buyerId && typeof value.buyerId === "string")
|
|
66803
|
+
value.buyerId = new import_mongodb149.ObjectId(value.buyerId);
|
|
66804
|
+
return {
|
|
66805
|
+
_id: new import_mongodb149.ObjectId(),
|
|
66806
|
+
price: value.price ?? null,
|
|
66807
|
+
message: value.message ?? "",
|
|
66808
|
+
status: value.status ?? "pending" /* PENDING */,
|
|
66809
|
+
type: value.type,
|
|
66810
|
+
postId: value.postId,
|
|
66811
|
+
buyerId: value.buyerId ?? null,
|
|
66812
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
66813
|
+
updatedAt: null
|
|
66814
|
+
};
|
|
66815
|
+
}
|
|
66816
|
+
|
|
66817
|
+
// src/repositories/bid-preloved.repo.ts
|
|
66818
|
+
var import_node_server_utils250 = require("@7365admin1/node-server-utils");
|
|
66819
|
+
var import_mongodb150 = require("mongodb");
|
|
66820
|
+
function useBidPrelovedRepo() {
|
|
66821
|
+
const db = import_node_server_utils250.useAtlas.getDb();
|
|
66822
|
+
if (!db)
|
|
66823
|
+
throw new import_node_server_utils250.InternalServerError("Unable to connect to server.");
|
|
66824
|
+
const collection = db.collection("bid-preloved");
|
|
66825
|
+
async function add(value, session) {
|
|
66826
|
+
try {
|
|
66827
|
+
const doc = MBidPreloved(value);
|
|
66828
|
+
const res = await collection.insertOne(doc, { session });
|
|
66829
|
+
return res.insertedId;
|
|
66830
|
+
} catch (error) {
|
|
66831
|
+
throw error;
|
|
66832
|
+
}
|
|
66833
|
+
}
|
|
66834
|
+
async function updateStatus(_id, status) {
|
|
66835
|
+
const objectId2 = typeof _id === "string" ? new import_mongodb150.ObjectId(_id) : _id;
|
|
66836
|
+
const existing = await collection.findOne({ _id: objectId2 });
|
|
66837
|
+
if (!existing)
|
|
66838
|
+
throw new import_node_server_utils250.NotFoundError("Bid not found.");
|
|
66839
|
+
const res = await collection.updateOne(
|
|
66840
|
+
{ _id: objectId2 },
|
|
66841
|
+
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } }
|
|
66842
|
+
);
|
|
66843
|
+
if (res.modifiedCount === 0)
|
|
66844
|
+
throw new import_node_server_utils250.InternalServerError("Unable to update bid.");
|
|
66845
|
+
return "Bid updated successfully.";
|
|
66846
|
+
}
|
|
66847
|
+
async function getById(_id) {
|
|
66848
|
+
if (typeof _id === "string")
|
|
66849
|
+
_id = new import_mongodb150.ObjectId(_id);
|
|
66850
|
+
const result = await collection.findOne({ _id });
|
|
66851
|
+
if (!result)
|
|
66852
|
+
throw new import_node_server_utils250.NotFoundError("Bid not found.");
|
|
66853
|
+
return result;
|
|
66854
|
+
}
|
|
66855
|
+
return { add, getById, updateStatus };
|
|
66856
|
+
}
|
|
66857
|
+
|
|
66858
|
+
// src/controllers/bid-preloved.controller.ts
|
|
66859
|
+
var import_node_server_utils251 = require("@7365admin1/node-server-utils");
|
|
66860
|
+
var import_joi146 = __toESM(require("joi"));
|
|
66861
|
+
function useBidPrelovedController() {
|
|
66862
|
+
const {
|
|
66863
|
+
add: _add,
|
|
66864
|
+
getById: _getById,
|
|
66865
|
+
updateStatus: _updateStatus
|
|
66866
|
+
} = useBidPrelovedRepo();
|
|
66867
|
+
async function add(req, res, next) {
|
|
66868
|
+
const { error, value } = schemaBidPreloved.validate(req.body, {
|
|
66869
|
+
abortEarly: false
|
|
66870
|
+
});
|
|
66871
|
+
if (error) {
|
|
66872
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
66873
|
+
import_node_server_utils251.logger.log({ level: "error", message: messages });
|
|
66874
|
+
next(new import_node_server_utils251.BadRequestError(messages));
|
|
66875
|
+
return;
|
|
66876
|
+
}
|
|
66877
|
+
try {
|
|
66878
|
+
const data = await _add(value);
|
|
66879
|
+
res.status(201).json(data);
|
|
66880
|
+
} catch (error2) {
|
|
66881
|
+
import_node_server_utils251.logger.log({ level: "error", message: error2.message });
|
|
66882
|
+
next(error2);
|
|
66883
|
+
}
|
|
66884
|
+
}
|
|
66885
|
+
async function updateStatus(req, res, next) {
|
|
66886
|
+
const paramsSchema = import_joi146.default.object({
|
|
66887
|
+
id: import_joi146.default.string().hex().length(24).required()
|
|
66888
|
+
});
|
|
66889
|
+
const { error: paramError, value: params } = paramsSchema.validate(
|
|
66890
|
+
req.params
|
|
66891
|
+
);
|
|
66892
|
+
if (paramError) {
|
|
66893
|
+
import_node_server_utils251.logger.log({ level: "error", message: paramError.message });
|
|
66894
|
+
next(new import_node_server_utils251.BadRequestError(paramError.message));
|
|
66895
|
+
return;
|
|
66896
|
+
}
|
|
66897
|
+
const { error: bodyError, value: body } = schemaUpdateBidPreloved.validate(
|
|
66898
|
+
req.body
|
|
66899
|
+
);
|
|
66900
|
+
if (bodyError) {
|
|
66901
|
+
import_node_server_utils251.logger.log({ level: "error", message: bodyError.message });
|
|
66902
|
+
next(new import_node_server_utils251.BadRequestError(bodyError.message));
|
|
66903
|
+
return;
|
|
66904
|
+
}
|
|
66905
|
+
try {
|
|
66906
|
+
const data = await _updateStatus(params.id, body.status);
|
|
66907
|
+
res.status(200).json(data);
|
|
66908
|
+
} catch (error) {
|
|
66909
|
+
import_node_server_utils251.logger.log({ level: "error", message: error.message });
|
|
66910
|
+
next(error);
|
|
66911
|
+
}
|
|
66912
|
+
}
|
|
66913
|
+
async function getById(req, res, next) {
|
|
66914
|
+
const paramsSchema = import_joi146.default.object({
|
|
66915
|
+
id: import_joi146.default.string().hex().length(24).required()
|
|
66916
|
+
});
|
|
66917
|
+
const { error, value: params } = paramsSchema.validate(req.params);
|
|
66918
|
+
if (error) {
|
|
66919
|
+
import_node_server_utils251.logger.log({ level: "error", message: error.message });
|
|
66920
|
+
next(new import_node_server_utils251.BadRequestError(error.message));
|
|
66921
|
+
return;
|
|
66922
|
+
}
|
|
66923
|
+
try {
|
|
66924
|
+
const data = await _getById(params.id);
|
|
66925
|
+
res.status(200).json(data);
|
|
66926
|
+
} catch (error2) {
|
|
66927
|
+
import_node_server_utils251.logger.log({ level: "error", message: error2.message });
|
|
66928
|
+
next(error2);
|
|
66929
|
+
}
|
|
66930
|
+
}
|
|
66931
|
+
return { add, getById, updateStatus };
|
|
66932
|
+
}
|
|
66933
|
+
|
|
66934
|
+
// src/models/online-forms-v2.model.ts
|
|
66935
|
+
var import_joi147 = __toESM(require("joi"));
|
|
66936
|
+
var import_mongodb151 = require("mongodb");
|
|
66609
66937
|
var FormEntryStatus = /* @__PURE__ */ ((FormEntryStatus2) => {
|
|
66610
66938
|
FormEntryStatus2["ACTIVE"] = "active";
|
|
66611
66939
|
FormEntryStatus2["INACTIVE"] = "inactive";
|
|
66612
66940
|
FormEntryStatus2["DELETED"] = "deleted";
|
|
66613
66941
|
return FormEntryStatus2;
|
|
66614
66942
|
})(FormEntryStatus || {});
|
|
66615
|
-
var schemaFormEntry =
|
|
66616
|
-
_id:
|
|
66617
|
-
formType:
|
|
66618
|
-
block:
|
|
66619
|
-
level:
|
|
66620
|
-
unit:
|
|
66621
|
-
name:
|
|
66622
|
-
phoneNumber:
|
|
66623
|
-
createdBy:
|
|
66624
|
-
fields:
|
|
66625
|
-
|
|
66626
|
-
|
|
66627
|
-
|
|
66628
|
-
|
|
66629
|
-
|
|
66630
|
-
|
|
66943
|
+
var schemaFormEntry = import_joi147.default.object({
|
|
66944
|
+
_id: import_joi147.default.string().hex().optional().allow("", null),
|
|
66945
|
+
formType: import_joi147.default.string().required(),
|
|
66946
|
+
block: import_joi147.default.string().optional().allow(null, ""),
|
|
66947
|
+
level: import_joi147.default.string().optional().allow(null, ""),
|
|
66948
|
+
unit: import_joi147.default.string().optional().allow(null, ""),
|
|
66949
|
+
name: import_joi147.default.string().optional().allow(null, ""),
|
|
66950
|
+
phoneNumber: import_joi147.default.string().optional().allow(null, ""),
|
|
66951
|
+
createdBy: import_joi147.default.string().required(),
|
|
66952
|
+
fields: import_joi147.default.object().pattern(
|
|
66953
|
+
import_joi147.default.string(),
|
|
66954
|
+
import_joi147.default.alternatives().try(
|
|
66955
|
+
import_joi147.default.string(),
|
|
66956
|
+
import_joi147.default.number(),
|
|
66957
|
+
import_joi147.default.boolean(),
|
|
66958
|
+
import_joi147.default.valid(null)
|
|
66631
66959
|
)
|
|
66632
66960
|
).required(),
|
|
66633
|
-
status:
|
|
66634
|
-
org:
|
|
66635
|
-
site:
|
|
66636
|
-
createdAt:
|
|
66637
|
-
updatedAt:
|
|
66638
|
-
deletedAt:
|
|
66961
|
+
status: import_joi147.default.string().optional().allow("", null),
|
|
66962
|
+
org: import_joi147.default.string().hex().optional().allow("", null),
|
|
66963
|
+
site: import_joi147.default.string().hex().optional().allow("", null),
|
|
66964
|
+
createdAt: import_joi147.default.date().optional().allow("", null),
|
|
66965
|
+
updatedAt: import_joi147.default.date().optional().allow("", null),
|
|
66966
|
+
deletedAt: import_joi147.default.date().optional().allow("", null)
|
|
66639
66967
|
});
|
|
66640
|
-
var schemaUpdateFormEntry =
|
|
66641
|
-
_id:
|
|
66642
|
-
formType:
|
|
66643
|
-
block:
|
|
66644
|
-
level:
|
|
66645
|
-
unit:
|
|
66646
|
-
fields:
|
|
66647
|
-
|
|
66648
|
-
|
|
66649
|
-
|
|
66650
|
-
|
|
66651
|
-
|
|
66652
|
-
|
|
66968
|
+
var schemaUpdateFormEntry = import_joi147.default.object({
|
|
66969
|
+
_id: import_joi147.default.string().hex().required(),
|
|
66970
|
+
formType: import_joi147.default.string().optional().allow("", null),
|
|
66971
|
+
block: import_joi147.default.string().optional().allow(null, ""),
|
|
66972
|
+
level: import_joi147.default.string().optional().allow(null, ""),
|
|
66973
|
+
unit: import_joi147.default.string().optional().allow(null, ""),
|
|
66974
|
+
fields: import_joi147.default.object().pattern(
|
|
66975
|
+
import_joi147.default.string(),
|
|
66976
|
+
import_joi147.default.alternatives().try(
|
|
66977
|
+
import_joi147.default.string(),
|
|
66978
|
+
import_joi147.default.number(),
|
|
66979
|
+
import_joi147.default.boolean(),
|
|
66980
|
+
import_joi147.default.valid(null)
|
|
66653
66981
|
)
|
|
66654
66982
|
).optional(),
|
|
66655
|
-
status:
|
|
66656
|
-
updatedAt:
|
|
66657
|
-
deletedAt:
|
|
66983
|
+
status: import_joi147.default.string().optional().allow("", null),
|
|
66984
|
+
updatedAt: import_joi147.default.date().optional().allow("", null),
|
|
66985
|
+
deletedAt: import_joi147.default.date().optional().allow("", null)
|
|
66658
66986
|
});
|
|
66659
66987
|
function MFormEntry(value) {
|
|
66660
66988
|
const { error } = schemaFormEntry.validate(value);
|
|
@@ -66663,21 +66991,21 @@ function MFormEntry(value) {
|
|
|
66663
66991
|
}
|
|
66664
66992
|
if (value._id && typeof value._id === "string") {
|
|
66665
66993
|
try {
|
|
66666
|
-
value._id = new
|
|
66994
|
+
value._id = new import_mongodb151.ObjectId(value._id);
|
|
66667
66995
|
} catch {
|
|
66668
66996
|
throw new Error("Invalid ID.");
|
|
66669
66997
|
}
|
|
66670
66998
|
}
|
|
66671
66999
|
if (value.org && typeof value.org === "string") {
|
|
66672
67000
|
try {
|
|
66673
|
-
value.org = new
|
|
67001
|
+
value.org = new import_mongodb151.ObjectId(value.org);
|
|
66674
67002
|
} catch {
|
|
66675
67003
|
throw new Error("Invalid org ID.");
|
|
66676
67004
|
}
|
|
66677
67005
|
}
|
|
66678
67006
|
if (value.site && typeof value.site === "string") {
|
|
66679
67007
|
try {
|
|
66680
|
-
value.site = new
|
|
67008
|
+
value.site = new import_mongodb151.ObjectId(value.site);
|
|
66681
67009
|
} catch {
|
|
66682
67010
|
throw new Error("Invalid site ID.");
|
|
66683
67011
|
}
|
|
@@ -66699,58 +67027,59 @@ function MFormEntry(value) {
|
|
|
66699
67027
|
deletedAt: value.deletedAt ?? null
|
|
66700
67028
|
};
|
|
66701
67029
|
}
|
|
66702
|
-
var residentFormEntry =
|
|
66703
|
-
_id:
|
|
66704
|
-
typeOfForm:
|
|
66705
|
-
unitNumber:
|
|
66706
|
-
fields:
|
|
66707
|
-
|
|
66708
|
-
|
|
66709
|
-
|
|
66710
|
-
|
|
66711
|
-
|
|
66712
|
-
|
|
67030
|
+
var residentFormEntry = import_joi147.default.object({
|
|
67031
|
+
_id: import_joi147.default.string().hex().optional().allow("", null),
|
|
67032
|
+
typeOfForm: import_joi147.default.string().optional().allow("", null),
|
|
67033
|
+
unitNumber: import_joi147.default.string().optional().allow(null, ""),
|
|
67034
|
+
fields: import_joi147.default.object().pattern(
|
|
67035
|
+
import_joi147.default.string(),
|
|
67036
|
+
import_joi147.default.alternatives().try(
|
|
67037
|
+
import_joi147.default.string(),
|
|
67038
|
+
import_joi147.default.number(),
|
|
67039
|
+
import_joi147.default.boolean(),
|
|
67040
|
+
import_joi147.default.valid(null)
|
|
66713
67041
|
)
|
|
66714
67042
|
).optional().allow(null, ""),
|
|
66715
|
-
status:
|
|
66716
|
-
org:
|
|
66717
|
-
site:
|
|
66718
|
-
userId:
|
|
66719
|
-
createdAt:
|
|
66720
|
-
updatedAt:
|
|
66721
|
-
deletedAt:
|
|
66722
|
-
remarks:
|
|
66723
|
-
managementValues:
|
|
66724
|
-
|
|
66725
|
-
|
|
66726
|
-
|
|
66727
|
-
|
|
66728
|
-
|
|
66729
|
-
|
|
67043
|
+
status: import_joi147.default.string().optional().allow("", null),
|
|
67044
|
+
org: import_joi147.default.string().hex().optional().allow("", null),
|
|
67045
|
+
site: import_joi147.default.string().hex().optional().allow("", null),
|
|
67046
|
+
userId: import_joi147.default.string().hex().optional().allow("", null),
|
|
67047
|
+
createdAt: import_joi147.default.date().optional().allow("", null),
|
|
67048
|
+
updatedAt: import_joi147.default.date().optional().allow("", null),
|
|
67049
|
+
deletedAt: import_joi147.default.date().optional().allow("", null),
|
|
67050
|
+
remarks: import_joi147.default.string().optional().allow("", null),
|
|
67051
|
+
managementValues: import_joi147.default.object().pattern(
|
|
67052
|
+
import_joi147.default.string(),
|
|
67053
|
+
import_joi147.default.alternatives().try(
|
|
67054
|
+
import_joi147.default.string(),
|
|
67055
|
+
import_joi147.default.number(),
|
|
67056
|
+
import_joi147.default.boolean(),
|
|
67057
|
+
import_joi147.default.valid(null)
|
|
66730
67058
|
)
|
|
66731
67059
|
).optional().allow(null, "")
|
|
66732
67060
|
});
|
|
66733
67061
|
|
|
66734
67062
|
// src/repositories/online-forms-v2.repository.ts
|
|
66735
|
-
var
|
|
66736
|
-
var
|
|
67063
|
+
var import_node_server_utils252 = require("@7365admin1/node-server-utils");
|
|
67064
|
+
var import_mongodb152 = require("mongodb");
|
|
66737
67065
|
var online_forms_namespace_collection = "online-forms";
|
|
66738
67066
|
function useFormEntryRepo() {
|
|
66739
|
-
const db =
|
|
67067
|
+
const db = import_node_server_utils252.useAtlas.getDb();
|
|
66740
67068
|
if (!db) {
|
|
66741
|
-
throw new
|
|
67069
|
+
throw new import_node_server_utils252.InternalServerError("Unable to connect to server.");
|
|
66742
67070
|
}
|
|
66743
67071
|
const collection = db.collection(online_forms_namespace_collection);
|
|
66744
|
-
const { delNamespace, getCache, setCache } = (0,
|
|
67072
|
+
const { delNamespace, getCache, setCache } = (0, import_node_server_utils252.useCache)(
|
|
66745
67073
|
online_forms_namespace_collection
|
|
66746
67074
|
);
|
|
67075
|
+
const { getUserById } = useUserRepo();
|
|
66747
67076
|
async function createTextIndex() {
|
|
66748
67077
|
try {
|
|
66749
67078
|
await collection.createIndex({
|
|
66750
67079
|
name: "text"
|
|
66751
67080
|
});
|
|
66752
67081
|
} catch (error) {
|
|
66753
|
-
throw new
|
|
67082
|
+
throw new import_node_server_utils252.InternalServerError(
|
|
66754
67083
|
"Failed to create text index on online form."
|
|
66755
67084
|
);
|
|
66756
67085
|
}
|
|
@@ -66760,11 +67089,11 @@ function useFormEntryRepo() {
|
|
|
66760
67089
|
value = MFormEntry(value);
|
|
66761
67090
|
const res = await collection.insertOne(value, { session });
|
|
66762
67091
|
delNamespace().then(() => {
|
|
66763
|
-
|
|
67092
|
+
import_node_server_utils252.logger.info(
|
|
66764
67093
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
66765
67094
|
);
|
|
66766
67095
|
}).catch((err) => {
|
|
66767
|
-
|
|
67096
|
+
import_node_server_utils252.logger.error(
|
|
66768
67097
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
66769
67098
|
err
|
|
66770
67099
|
);
|
|
@@ -66773,7 +67102,7 @@ function useFormEntryRepo() {
|
|
|
66773
67102
|
} catch (error) {
|
|
66774
67103
|
const isDuplicated = error.message.includes("duplicate");
|
|
66775
67104
|
if (isDuplicated) {
|
|
66776
|
-
throw new
|
|
67105
|
+
throw new import_node_server_utils252.BadRequestError("Online Form already exists.");
|
|
66777
67106
|
}
|
|
66778
67107
|
throw error;
|
|
66779
67108
|
}
|
|
@@ -66789,8 +67118,8 @@ function useFormEntryRepo() {
|
|
|
66789
67118
|
}) {
|
|
66790
67119
|
page = page > 0 ? page - 1 : 0;
|
|
66791
67120
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
66792
|
-
site = new
|
|
66793
|
-
org = new
|
|
67121
|
+
site = new import_mongodb152.ObjectId(site);
|
|
67122
|
+
org = new import_mongodb152.ObjectId(org);
|
|
66794
67123
|
const cacheOptions = {
|
|
66795
67124
|
page,
|
|
66796
67125
|
limit,
|
|
@@ -66810,13 +67139,13 @@ function useFormEntryRepo() {
|
|
|
66810
67139
|
{ unitNumber: { $regex: search, $options: "i" } }
|
|
66811
67140
|
];
|
|
66812
67141
|
}
|
|
66813
|
-
const cacheKey = (0,
|
|
67142
|
+
const cacheKey = (0, import_node_server_utils252.makeCacheKey)(
|
|
66814
67143
|
online_forms_namespace_collection,
|
|
66815
67144
|
cacheOptions
|
|
66816
67145
|
);
|
|
66817
67146
|
const cachedData = await getCache(cacheKey);
|
|
66818
67147
|
if (cachedData) {
|
|
66819
|
-
|
|
67148
|
+
import_node_server_utils252.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
66820
67149
|
return cachedData;
|
|
66821
67150
|
}
|
|
66822
67151
|
try {
|
|
@@ -66843,11 +67172,11 @@ function useFormEntryRepo() {
|
|
|
66843
67172
|
{ $project: { user: 0 } }
|
|
66844
67173
|
]).toArray();
|
|
66845
67174
|
const length = await collection.countDocuments(query);
|
|
66846
|
-
const data = (0,
|
|
67175
|
+
const data = (0, import_node_server_utils252.paginate)(items, page, limit, length);
|
|
66847
67176
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
66848
|
-
|
|
67177
|
+
import_node_server_utils252.logger.info(`Cache set for key: ${cacheKey}`);
|
|
66849
67178
|
}).catch((err) => {
|
|
66850
|
-
|
|
67179
|
+
import_node_server_utils252.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
66851
67180
|
});
|
|
66852
67181
|
return data;
|
|
66853
67182
|
} catch (error) {
|
|
@@ -66855,27 +67184,27 @@ function useFormEntryRepo() {
|
|
|
66855
67184
|
}
|
|
66856
67185
|
}
|
|
66857
67186
|
async function getFormEntryById(_id) {
|
|
66858
|
-
const cacheKey = (0,
|
|
67187
|
+
const cacheKey = (0, import_node_server_utils252.makeCacheKey)(online_forms_namespace_collection, { _id });
|
|
66859
67188
|
const cachedData = await getCache(cacheKey);
|
|
66860
67189
|
if (cachedData) {
|
|
66861
|
-
|
|
67190
|
+
import_node_server_utils252.logger.info(`Cache hit for key: ${cacheKey}`);
|
|
66862
67191
|
return cachedData;
|
|
66863
67192
|
}
|
|
66864
67193
|
try {
|
|
66865
|
-
_id = new
|
|
67194
|
+
_id = new import_mongodb152.ObjectId(_id);
|
|
66866
67195
|
} catch (error) {
|
|
66867
|
-
throw new
|
|
67196
|
+
throw new import_node_server_utils252.BadRequestError("Invalid online form ID format.");
|
|
66868
67197
|
}
|
|
66869
67198
|
const query = { _id, status: { $ne: "deleted" } };
|
|
66870
67199
|
try {
|
|
66871
67200
|
const [data] = await collection.aggregate([{ $match: query }]).toArray();
|
|
66872
67201
|
if (!data) {
|
|
66873
|
-
throw new
|
|
67202
|
+
throw new import_node_server_utils252.NotFoundError("Document not found.");
|
|
66874
67203
|
}
|
|
66875
67204
|
setCache(cacheKey, data, 15 * 60).then(() => {
|
|
66876
|
-
|
|
67205
|
+
import_node_server_utils252.logger.info(`Cache set for key: ${cacheKey}`);
|
|
66877
67206
|
}).catch((err) => {
|
|
66878
|
-
|
|
67207
|
+
import_node_server_utils252.logger.error(`Failed to set cache for key: ${cacheKey}`, err);
|
|
66879
67208
|
});
|
|
66880
67209
|
return data;
|
|
66881
67210
|
} catch (error) {
|
|
@@ -66884,9 +67213,9 @@ function useFormEntryRepo() {
|
|
|
66884
67213
|
}
|
|
66885
67214
|
async function updateFormEntryById(_id, value) {
|
|
66886
67215
|
try {
|
|
66887
|
-
_id = new
|
|
67216
|
+
_id = new import_mongodb152.ObjectId(_id);
|
|
66888
67217
|
} catch (error) {
|
|
66889
|
-
throw new
|
|
67218
|
+
throw new import_node_server_utils252.BadRequestError("Invalid online form ID format.");
|
|
66890
67219
|
}
|
|
66891
67220
|
try {
|
|
66892
67221
|
const updateValue = {
|
|
@@ -66895,14 +67224,34 @@ function useFormEntryRepo() {
|
|
|
66895
67224
|
};
|
|
66896
67225
|
const res = await collection.updateOne({ _id }, { $set: updateValue });
|
|
66897
67226
|
if (res.modifiedCount === 0) {
|
|
66898
|
-
throw new
|
|
66899
|
-
}
|
|
67227
|
+
throw new import_node_server_utils252.InternalServerError("Unable to update online form.");
|
|
67228
|
+
}
|
|
67229
|
+
const onlineFormRequest = await collection.findOne({ _id });
|
|
67230
|
+
if (!onlineFormRequest) {
|
|
67231
|
+
throw new import_node_server_utils252.NotFoundError("Online form not found.");
|
|
67232
|
+
}
|
|
67233
|
+
const user = await getUserById(onlineFormRequest.userId.toString());
|
|
67234
|
+
if (!user || !user._id) {
|
|
67235
|
+
throw new import_node_server_utils252.NotFoundError("User not found.");
|
|
67236
|
+
}
|
|
67237
|
+
const userId = user._id.toString();
|
|
67238
|
+
await NotificationService.onlineFormRequestStatusUpdated({
|
|
67239
|
+
to: userId,
|
|
67240
|
+
onlineFormId: onlineFormRequest._id,
|
|
67241
|
+
// typeOfForm: onlineFormRequest.typeOfForm,
|
|
67242
|
+
// unitNumber: onlineFormRequest.unitNumber,
|
|
67243
|
+
status: onlineFormRequest.status
|
|
67244
|
+
// createdAt: onlineFormRequest.createdAt ?? "",
|
|
67245
|
+
// fields: onlineFormRequest.fields ?? {},
|
|
67246
|
+
// remarks: onlineFormRequest.remarks ?? "",
|
|
67247
|
+
// managementValuesJson: onlineFormRequest.managementValues ?? {},
|
|
67248
|
+
});
|
|
66900
67249
|
delNamespace().then(() => {
|
|
66901
|
-
|
|
67250
|
+
import_node_server_utils252.logger.info(
|
|
66902
67251
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
66903
67252
|
);
|
|
66904
67253
|
}).catch((err) => {
|
|
66905
|
-
|
|
67254
|
+
import_node_server_utils252.logger.error(
|
|
66906
67255
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
66907
67256
|
err
|
|
66908
67257
|
);
|
|
@@ -66914,9 +67263,9 @@ function useFormEntryRepo() {
|
|
|
66914
67263
|
}
|
|
66915
67264
|
async function deleteOnlineFormById(_id, session) {
|
|
66916
67265
|
try {
|
|
66917
|
-
_id = new
|
|
67266
|
+
_id = new import_mongodb152.ObjectId(_id);
|
|
66918
67267
|
} catch (error) {
|
|
66919
|
-
throw new
|
|
67268
|
+
throw new import_node_server_utils252.BadRequestError("Invalid online form ID format.");
|
|
66920
67269
|
}
|
|
66921
67270
|
try {
|
|
66922
67271
|
const updateValue = {
|
|
@@ -66930,12 +67279,14 @@ function useFormEntryRepo() {
|
|
|
66930
67279
|
{ session }
|
|
66931
67280
|
);
|
|
66932
67281
|
if (res.modifiedCount === 0) {
|
|
66933
|
-
throw new
|
|
67282
|
+
throw new import_node_server_utils252.InternalServerError("Unable to delete online form.");
|
|
66934
67283
|
}
|
|
66935
67284
|
delNamespace().then(() => {
|
|
66936
|
-
|
|
67285
|
+
import_node_server_utils252.logger.info(
|
|
67286
|
+
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
67287
|
+
);
|
|
66937
67288
|
}).catch((err) => {
|
|
66938
|
-
|
|
67289
|
+
import_node_server_utils252.logger.error(
|
|
66939
67290
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
66940
67291
|
err
|
|
66941
67292
|
);
|
|
@@ -66947,16 +67298,16 @@ function useFormEntryRepo() {
|
|
|
66947
67298
|
}
|
|
66948
67299
|
async function addResidentForm(value, session) {
|
|
66949
67300
|
try {
|
|
66950
|
-
value.site = new
|
|
66951
|
-
value.org = new
|
|
66952
|
-
value.userId = new
|
|
67301
|
+
value.site = new import_mongodb152.ObjectId(value.site);
|
|
67302
|
+
value.org = new import_mongodb152.ObjectId(value.org);
|
|
67303
|
+
value.userId = new import_mongodb152.ObjectId(value.userId);
|
|
66953
67304
|
const res = await collection.insertOne(value, { session });
|
|
66954
67305
|
delNamespace().then(() => {
|
|
66955
|
-
|
|
67306
|
+
import_node_server_utils252.logger.info(
|
|
66956
67307
|
`Cache cleared for namespace: ${online_forms_namespace_collection}`
|
|
66957
67308
|
);
|
|
66958
67309
|
}).catch((err) => {
|
|
66959
|
-
|
|
67310
|
+
import_node_server_utils252.logger.error(
|
|
66960
67311
|
`Failed to clear cache for namespace: ${online_forms_namespace_collection}`,
|
|
66961
67312
|
err
|
|
66962
67313
|
);
|
|
@@ -66965,16 +67316,20 @@ function useFormEntryRepo() {
|
|
|
66965
67316
|
} catch (error) {
|
|
66966
67317
|
const isDuplicated = error.message.includes("duplicate");
|
|
66967
67318
|
if (isDuplicated) {
|
|
66968
|
-
throw new
|
|
67319
|
+
throw new import_node_server_utils252.BadRequestError("Online Form already exists.");
|
|
66969
67320
|
}
|
|
66970
67321
|
throw error;
|
|
66971
67322
|
}
|
|
66972
67323
|
}
|
|
66973
|
-
async function residentForm({
|
|
67324
|
+
async function residentForm({
|
|
67325
|
+
userId,
|
|
67326
|
+
site,
|
|
67327
|
+
org
|
|
67328
|
+
}) {
|
|
66974
67329
|
try {
|
|
66975
|
-
const user = new
|
|
66976
|
-
const siteId = new
|
|
66977
|
-
const orgId = new
|
|
67330
|
+
const user = new import_mongodb152.ObjectId(userId);
|
|
67331
|
+
const siteId = new import_mongodb152.ObjectId(site);
|
|
67332
|
+
const orgId = new import_mongodb152.ObjectId(org);
|
|
66978
67333
|
const res = await collection.aggregate([
|
|
66979
67334
|
{
|
|
66980
67335
|
$match: {
|
|
@@ -67002,8 +67357,8 @@ function useFormEntryRepo() {
|
|
|
67002
67357
|
}
|
|
67003
67358
|
|
|
67004
67359
|
// src/controllers/online-forms-v2.controller.ts
|
|
67005
|
-
var
|
|
67006
|
-
var
|
|
67360
|
+
var import_node_server_utils253 = require("@7365admin1/node-server-utils");
|
|
67361
|
+
var import_joi148 = __toESM(require("joi"));
|
|
67007
67362
|
var import_exceljs3 = __toESM(require("exceljs"));
|
|
67008
67363
|
var import_fs7 = __toESM(require("fs"));
|
|
67009
67364
|
function useFormEntryController() {
|
|
@@ -67029,14 +67384,14 @@ function useFormEntryController() {
|
|
|
67029
67384
|
async function uploadFormEntrys(req, res, next) {
|
|
67030
67385
|
try {
|
|
67031
67386
|
if (!req.file) {
|
|
67032
|
-
next(new
|
|
67387
|
+
next(new import_node_server_utils253.BadRequestError("Excel file is required."));
|
|
67033
67388
|
return;
|
|
67034
67389
|
}
|
|
67035
67390
|
const workbook = new import_exceljs3.default.Workbook();
|
|
67036
67391
|
await workbook.xlsx.readFile(req.file.path);
|
|
67037
67392
|
const worksheet = workbook.worksheets[0];
|
|
67038
67393
|
if (!worksheet) {
|
|
67039
|
-
next(new
|
|
67394
|
+
next(new import_node_server_utils253.BadRequestError("No worksheet found in uploaded Excel file."));
|
|
67040
67395
|
return;
|
|
67041
67396
|
}
|
|
67042
67397
|
const headerRow = worksheet.getRow(1);
|
|
@@ -67064,8 +67419,8 @@ function useFormEntryController() {
|
|
|
67064
67419
|
});
|
|
67065
67420
|
if (error) {
|
|
67066
67421
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67067
|
-
|
|
67068
|
-
next(new
|
|
67422
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67423
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67069
67424
|
return;
|
|
67070
67425
|
}
|
|
67071
67426
|
const result = await _add(value);
|
|
@@ -67073,25 +67428,25 @@ function useFormEntryController() {
|
|
|
67073
67428
|
import_fs7.default.unlink(req.file.path, () => {
|
|
67074
67429
|
});
|
|
67075
67430
|
} catch (error) {
|
|
67076
|
-
|
|
67431
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67077
67432
|
next(error);
|
|
67078
67433
|
}
|
|
67079
67434
|
}
|
|
67080
67435
|
async function getAll(req, res, next) {
|
|
67081
67436
|
try {
|
|
67082
|
-
const schema2 =
|
|
67083
|
-
search:
|
|
67084
|
-
page:
|
|
67085
|
-
limit:
|
|
67086
|
-
status:
|
|
67087
|
-
org:
|
|
67088
|
-
site:
|
|
67437
|
+
const schema2 = import_joi148.default.object({
|
|
67438
|
+
search: import_joi148.default.string().optional().allow("", null),
|
|
67439
|
+
page: import_joi148.default.number().integer().min(1).allow("", null).default(1),
|
|
67440
|
+
limit: import_joi148.default.number().integer().min(1).max(100).allow("", null).default(10),
|
|
67441
|
+
status: import_joi148.default.string().optional().allow(null, ""),
|
|
67442
|
+
org: import_joi148.default.string().hex().optional().allow("", null),
|
|
67443
|
+
site: import_joi148.default.string().hex().optional().allow("", null)
|
|
67089
67444
|
});
|
|
67090
67445
|
const { error, value } = schema2.validate(req.query);
|
|
67091
67446
|
if (error) {
|
|
67092
67447
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67093
|
-
|
|
67094
|
-
next(new
|
|
67448
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67449
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67095
67450
|
return;
|
|
67096
67451
|
}
|
|
67097
67452
|
const { search, page, limit, status, org, site } = value;
|
|
@@ -67099,21 +67454,21 @@ function useFormEntryController() {
|
|
|
67099
67454
|
res.json(data);
|
|
67100
67455
|
return;
|
|
67101
67456
|
} catch (error) {
|
|
67102
|
-
|
|
67457
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67103
67458
|
next(error);
|
|
67104
67459
|
return;
|
|
67105
67460
|
}
|
|
67106
67461
|
}
|
|
67107
67462
|
async function getFormEntryById(req, res, next) {
|
|
67108
67463
|
try {
|
|
67109
|
-
const schema2 =
|
|
67110
|
-
_id:
|
|
67464
|
+
const schema2 = import_joi148.default.object({
|
|
67465
|
+
_id: import_joi148.default.string().hex().length(24).required()
|
|
67111
67466
|
});
|
|
67112
67467
|
const { error, value } = schema2.validate({ _id: req.params.id });
|
|
67113
67468
|
if (error) {
|
|
67114
67469
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67115
|
-
|
|
67116
|
-
next(new
|
|
67470
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67471
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67117
67472
|
return;
|
|
67118
67473
|
}
|
|
67119
67474
|
const { _id } = value;
|
|
@@ -67121,7 +67476,7 @@ function useFormEntryController() {
|
|
|
67121
67476
|
res.json(data);
|
|
67122
67477
|
return;
|
|
67123
67478
|
} catch (error) {
|
|
67124
|
-
|
|
67479
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67125
67480
|
next(error);
|
|
67126
67481
|
return;
|
|
67127
67482
|
}
|
|
@@ -67134,8 +67489,8 @@ function useFormEntryController() {
|
|
|
67134
67489
|
});
|
|
67135
67490
|
if (error) {
|
|
67136
67491
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67137
|
-
|
|
67138
|
-
next(new
|
|
67492
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67493
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67139
67494
|
return;
|
|
67140
67495
|
}
|
|
67141
67496
|
const { _id, ...rest } = value;
|
|
@@ -67143,26 +67498,26 @@ function useFormEntryController() {
|
|
|
67143
67498
|
res.json({ message: "Successfully updated online form." });
|
|
67144
67499
|
return;
|
|
67145
67500
|
} catch (error) {
|
|
67146
|
-
|
|
67501
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67147
67502
|
next(error);
|
|
67148
67503
|
return;
|
|
67149
67504
|
}
|
|
67150
67505
|
}
|
|
67151
67506
|
async function deleteFormEntryById(req, res, next) {
|
|
67152
67507
|
try {
|
|
67153
|
-
const validation =
|
|
67508
|
+
const validation = import_joi148.default.string().hex().required();
|
|
67154
67509
|
const _id = req.params.id;
|
|
67155
67510
|
const { error } = validation.validate(_id);
|
|
67156
67511
|
if (error) {
|
|
67157
|
-
|
|
67158
|
-
next(new
|
|
67512
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67513
|
+
next(new import_node_server_utils253.BadRequestError(error.message));
|
|
67159
67514
|
return;
|
|
67160
67515
|
}
|
|
67161
67516
|
await _deleteOnlineFormById(_id);
|
|
67162
67517
|
res.json({ message: "Successfully deleted online form." });
|
|
67163
67518
|
return;
|
|
67164
67519
|
} catch (error) {
|
|
67165
|
-
|
|
67520
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67166
67521
|
next(error);
|
|
67167
67522
|
return;
|
|
67168
67523
|
}
|
|
@@ -67179,8 +67534,8 @@ function useFormEntryController() {
|
|
|
67179
67534
|
});
|
|
67180
67535
|
if (error) {
|
|
67181
67536
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67182
|
-
|
|
67183
|
-
next(new
|
|
67537
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67538
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67184
67539
|
return;
|
|
67185
67540
|
}
|
|
67186
67541
|
try {
|
|
@@ -67188,7 +67543,7 @@ function useFormEntryController() {
|
|
|
67188
67543
|
res.status(201).json({ message: data });
|
|
67189
67544
|
return;
|
|
67190
67545
|
} catch (error2) {
|
|
67191
|
-
|
|
67546
|
+
import_node_server_utils253.logger.log({ level: "error", message: error2.message });
|
|
67192
67547
|
next(error2);
|
|
67193
67548
|
return;
|
|
67194
67549
|
}
|
|
@@ -67200,8 +67555,8 @@ function useFormEntryController() {
|
|
|
67200
67555
|
});
|
|
67201
67556
|
if (error) {
|
|
67202
67557
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67203
|
-
|
|
67204
|
-
next(new
|
|
67558
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67559
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67205
67560
|
return;
|
|
67206
67561
|
}
|
|
67207
67562
|
try {
|
|
@@ -67209,7 +67564,7 @@ function useFormEntryController() {
|
|
|
67209
67564
|
res.status(201).json({ message: data });
|
|
67210
67565
|
return;
|
|
67211
67566
|
} catch (error2) {
|
|
67212
|
-
|
|
67567
|
+
import_node_server_utils253.logger.log({ level: "error", message: error2.message });
|
|
67213
67568
|
next(error2);
|
|
67214
67569
|
return;
|
|
67215
67570
|
}
|
|
@@ -67217,22 +67572,22 @@ function useFormEntryController() {
|
|
|
67217
67572
|
async function residentForm(req, res, next) {
|
|
67218
67573
|
try {
|
|
67219
67574
|
const { site, userId, org } = req.query;
|
|
67220
|
-
const residentFormPayload =
|
|
67221
|
-
org:
|
|
67222
|
-
site:
|
|
67223
|
-
userId:
|
|
67575
|
+
const residentFormPayload = import_joi148.default.object({
|
|
67576
|
+
org: import_joi148.default.string().hex().required(),
|
|
67577
|
+
site: import_joi148.default.string().hex().required(),
|
|
67578
|
+
userId: import_joi148.default.string().hex().required()
|
|
67224
67579
|
});
|
|
67225
67580
|
const { error } = residentFormPayload.validate({ site, userId, org }, { abortEarly: true });
|
|
67226
67581
|
if (error) {
|
|
67227
67582
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67228
|
-
|
|
67229
|
-
next(new
|
|
67583
|
+
import_node_server_utils253.logger.log({ level: "error", message: messages });
|
|
67584
|
+
next(new import_node_server_utils253.BadRequestError(messages));
|
|
67230
67585
|
return;
|
|
67231
67586
|
}
|
|
67232
67587
|
const result = await _residentForm({ userId, site, org });
|
|
67233
67588
|
res.json(result);
|
|
67234
67589
|
} catch (error) {
|
|
67235
|
-
|
|
67590
|
+
import_node_server_utils253.logger.log({ level: "error", message: error.message });
|
|
67236
67591
|
next(error);
|
|
67237
67592
|
return;
|
|
67238
67593
|
}
|
|
@@ -67250,11 +67605,11 @@ function useFormEntryController() {
|
|
|
67250
67605
|
}
|
|
67251
67606
|
|
|
67252
67607
|
// src/services/building-level.service.ts
|
|
67253
|
-
var
|
|
67608
|
+
var import_node_server_utils254 = require("@7365admin1/node-server-utils");
|
|
67254
67609
|
function useBuildingLevelService() {
|
|
67255
67610
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelRepo();
|
|
67256
67611
|
async function add(value) {
|
|
67257
|
-
const session =
|
|
67612
|
+
const session = import_node_server_utils254.useAtlas.getClient()?.startSession();
|
|
67258
67613
|
try {
|
|
67259
67614
|
session?.startTransaction();
|
|
67260
67615
|
await _add(value, session);
|
|
@@ -67268,7 +67623,7 @@ function useBuildingLevelService() {
|
|
|
67268
67623
|
}
|
|
67269
67624
|
}
|
|
67270
67625
|
async function updateLevelById(_id, value) {
|
|
67271
|
-
const session =
|
|
67626
|
+
const session = import_node_server_utils254.useAtlas.getClient()?.startSession();
|
|
67272
67627
|
try {
|
|
67273
67628
|
session?.startTransaction();
|
|
67274
67629
|
await _updateLevelById(_id, value, session);
|
|
@@ -67288,8 +67643,8 @@ function useBuildingLevelService() {
|
|
|
67288
67643
|
}
|
|
67289
67644
|
|
|
67290
67645
|
// src/controllers/building-level.controller.ts
|
|
67291
|
-
var
|
|
67292
|
-
var
|
|
67646
|
+
var import_node_server_utils255 = require("@7365admin1/node-server-utils");
|
|
67647
|
+
var import_joi149 = __toESM(require("joi"));
|
|
67293
67648
|
function useBuildingLevelController() {
|
|
67294
67649
|
const { add: _add, updateLevelById: _updateLevelById } = useBuildingLevelService();
|
|
67295
67650
|
const {
|
|
@@ -67306,8 +67661,8 @@ function useBuildingLevelController() {
|
|
|
67306
67661
|
});
|
|
67307
67662
|
if (error) {
|
|
67308
67663
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67309
|
-
|
|
67310
|
-
next(new
|
|
67664
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
67665
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67311
67666
|
return;
|
|
67312
67667
|
}
|
|
67313
67668
|
const result = await _add(value);
|
|
@@ -67318,20 +67673,20 @@ function useBuildingLevelController() {
|
|
|
67318
67673
|
}
|
|
67319
67674
|
async function getAll(req, res, next) {
|
|
67320
67675
|
try {
|
|
67321
|
-
const validation =
|
|
67322
|
-
page:
|
|
67323
|
-
limit:
|
|
67324
|
-
search:
|
|
67325
|
-
site:
|
|
67326
|
-
status:
|
|
67676
|
+
const validation = import_joi149.default.object({
|
|
67677
|
+
page: import_joi149.default.number().min(1).optional().default(1),
|
|
67678
|
+
limit: import_joi149.default.number().min(1).optional().default(20),
|
|
67679
|
+
search: import_joi149.default.string().optional().allow("", null),
|
|
67680
|
+
site: import_joi149.default.string().hex().length(24).optional().allow("", null),
|
|
67681
|
+
status: import_joi149.default.string().valid(...Object.values(BuildingLevelStatus)).default("active" /* ACTIVE */)
|
|
67327
67682
|
});
|
|
67328
67683
|
const { error, value } = validation.validate(req.query, {
|
|
67329
67684
|
abortEarly: false
|
|
67330
67685
|
});
|
|
67331
67686
|
if (error) {
|
|
67332
67687
|
const messages = error.details.map((d) => d.message);
|
|
67333
|
-
|
|
67334
|
-
next(new
|
|
67688
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
|
|
67689
|
+
next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
|
|
67335
67690
|
return;
|
|
67336
67691
|
}
|
|
67337
67692
|
const { page, limit, status, site, search } = value;
|
|
@@ -67350,14 +67705,14 @@ function useBuildingLevelController() {
|
|
|
67350
67705
|
}
|
|
67351
67706
|
async function getById(req, res, next) {
|
|
67352
67707
|
try {
|
|
67353
|
-
const schema2 =
|
|
67354
|
-
id:
|
|
67708
|
+
const schema2 = import_joi149.default.object({
|
|
67709
|
+
id: import_joi149.default.string().hex().length(24).required()
|
|
67355
67710
|
});
|
|
67356
67711
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
67357
67712
|
if (error) {
|
|
67358
67713
|
const messages = error.details.map((d) => d.message);
|
|
67359
|
-
|
|
67360
|
-
next(new
|
|
67714
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
|
|
67715
|
+
next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
|
|
67361
67716
|
return;
|
|
67362
67717
|
}
|
|
67363
67718
|
const { id } = value;
|
|
@@ -67376,8 +67731,8 @@ function useBuildingLevelController() {
|
|
|
67376
67731
|
});
|
|
67377
67732
|
if (error) {
|
|
67378
67733
|
const messages = error.details.map((d) => d.message);
|
|
67379
|
-
|
|
67380
|
-
next(new
|
|
67734
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
|
|
67735
|
+
next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
|
|
67381
67736
|
return;
|
|
67382
67737
|
}
|
|
67383
67738
|
const { _id, ...rest } = value;
|
|
@@ -67389,14 +67744,14 @@ function useBuildingLevelController() {
|
|
|
67389
67744
|
}
|
|
67390
67745
|
async function deleteById(req, res, next) {
|
|
67391
67746
|
try {
|
|
67392
|
-
const schema2 =
|
|
67393
|
-
id:
|
|
67747
|
+
const schema2 = import_joi149.default.object({
|
|
67748
|
+
id: import_joi149.default.string().hex().required()
|
|
67394
67749
|
});
|
|
67395
67750
|
const { error, value } = schema2.validate({ id: req.params.id });
|
|
67396
67751
|
if (error) {
|
|
67397
67752
|
const messages = error.details.map((d) => d.message);
|
|
67398
|
-
|
|
67399
|
-
next(new
|
|
67753
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
|
|
67754
|
+
next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
|
|
67400
67755
|
return;
|
|
67401
67756
|
}
|
|
67402
67757
|
const { id } = value;
|
|
@@ -67409,19 +67764,19 @@ function useBuildingLevelController() {
|
|
|
67409
67764
|
}
|
|
67410
67765
|
async function batchUpdateByIds(req, res, next) {
|
|
67411
67766
|
try {
|
|
67412
|
-
const schema2 =
|
|
67413
|
-
|
|
67414
|
-
_id:
|
|
67415
|
-
value:
|
|
67416
|
-
name:
|
|
67767
|
+
const schema2 = import_joi149.default.array().items(
|
|
67768
|
+
import_joi149.default.object({
|
|
67769
|
+
_id: import_joi149.default.string().hex().length(24).required(),
|
|
67770
|
+
value: import_joi149.default.object({
|
|
67771
|
+
name: import_joi149.default.string().optional().allow("", null)
|
|
67417
67772
|
}).required()
|
|
67418
67773
|
})
|
|
67419
67774
|
);
|
|
67420
67775
|
const { error, value } = schema2.validate(req.body);
|
|
67421
67776
|
if (error) {
|
|
67422
67777
|
const messages = error.details.map((d) => d.message);
|
|
67423
|
-
|
|
67424
|
-
next(new
|
|
67778
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages.join(", ") });
|
|
67779
|
+
next(new import_node_server_utils255.BadRequestError(messages.join(", ")));
|
|
67425
67780
|
return;
|
|
67426
67781
|
}
|
|
67427
67782
|
const updates = value.map((item) => ({
|
|
@@ -67436,9 +67791,9 @@ function useBuildingLevelController() {
|
|
|
67436
67791
|
}
|
|
67437
67792
|
async function getBuildingLevelList(req, res, next) {
|
|
67438
67793
|
try {
|
|
67439
|
-
const schema2 =
|
|
67440
|
-
site:
|
|
67441
|
-
block:
|
|
67794
|
+
const schema2 = import_joi149.default.object({
|
|
67795
|
+
site: import_joi149.default.string().hex().length(24).required(),
|
|
67796
|
+
block: import_joi149.default.string().hex().length(24).required()
|
|
67442
67797
|
});
|
|
67443
67798
|
const { error, value } = schema2.validate({
|
|
67444
67799
|
site: req.params.siteId,
|
|
@@ -67446,8 +67801,8 @@ function useBuildingLevelController() {
|
|
|
67446
67801
|
});
|
|
67447
67802
|
if (error) {
|
|
67448
67803
|
const messages = error.details.map((d) => d.message).join(", ");
|
|
67449
|
-
|
|
67450
|
-
next(new
|
|
67804
|
+
import_node_server_utils255.logger.log({ level: "error", message: messages });
|
|
67805
|
+
next(new import_node_server_utils255.BadRequestError(messages));
|
|
67451
67806
|
return;
|
|
67452
67807
|
}
|
|
67453
67808
|
const { site, block } = value;
|
|
@@ -67468,11 +67823,1358 @@ function useBuildingLevelController() {
|
|
|
67468
67823
|
getBuildingLevelList
|
|
67469
67824
|
};
|
|
67470
67825
|
}
|
|
67826
|
+
|
|
67827
|
+
// src/models/hid-amico.model.ts
|
|
67828
|
+
var import_node_server_utils256 = require("@7365admin1/node-server-utils");
|
|
67829
|
+
var import_mongodb153 = require("mongodb");
|
|
67830
|
+
var import_joi150 = __toESM(require("joi"));
|
|
67831
|
+
function canReadObjectId(value) {
|
|
67832
|
+
if (value instanceof import_mongodb153.ObjectId)
|
|
67833
|
+
return true;
|
|
67834
|
+
if (typeof value === "string")
|
|
67835
|
+
return import_mongodb153.ObjectId.isValid(value);
|
|
67836
|
+
if (value && typeof value === "object") {
|
|
67837
|
+
const candidate = value;
|
|
67838
|
+
if (canReadObjectId(candidate._id) || canReadObjectId(candidate.$oid))
|
|
67839
|
+
return true;
|
|
67840
|
+
if (typeof candidate.toHexString === "function" && import_mongodb153.ObjectId.isValid(candidate.toHexString()))
|
|
67841
|
+
return true;
|
|
67842
|
+
if (typeof candidate.toString === "function") {
|
|
67843
|
+
const text = candidate.toString();
|
|
67844
|
+
return text !== "[object Object]" && import_mongodb153.ObjectId.isValid(text);
|
|
67845
|
+
}
|
|
67846
|
+
}
|
|
67847
|
+
return false;
|
|
67848
|
+
}
|
|
67849
|
+
function toObjectId23(value, label = "ID") {
|
|
67850
|
+
if (value instanceof import_mongodb153.ObjectId)
|
|
67851
|
+
return value;
|
|
67852
|
+
if (typeof value === "string" && import_mongodb153.ObjectId.isValid(value))
|
|
67853
|
+
return new import_mongodb153.ObjectId(value);
|
|
67854
|
+
if (value && typeof value === "object") {
|
|
67855
|
+
const candidate = value;
|
|
67856
|
+
if (candidate._id)
|
|
67857
|
+
return toObjectId23(candidate._id, label);
|
|
67858
|
+
if (candidate.$oid)
|
|
67859
|
+
return toObjectId23(candidate.$oid, label);
|
|
67860
|
+
if (typeof candidate.toHexString === "function")
|
|
67861
|
+
return toObjectId23(candidate.toHexString(), label);
|
|
67862
|
+
if (typeof candidate.toString === "function") {
|
|
67863
|
+
const text = candidate.toString();
|
|
67864
|
+
if (text !== "[object Object]")
|
|
67865
|
+
return toObjectId23(text, label);
|
|
67866
|
+
}
|
|
67867
|
+
}
|
|
67868
|
+
throw new import_node_server_utils256.BadRequestError(`Invalid ${label} format`);
|
|
67869
|
+
}
|
|
67870
|
+
var objectIdSchema2 = import_joi150.default.custom((value, helpers) => canReadObjectId(value) ? value : helpers.error("any.invalid"), "ObjectId").messages({
|
|
67871
|
+
"any.invalid": "{{#label}} must be a valid ObjectId"
|
|
67872
|
+
});
|
|
67873
|
+
var schemaHidAmicoReader = import_joi150.default.object({
|
|
67874
|
+
_id: objectIdSchema2.optional(),
|
|
67875
|
+
site: objectIdSchema2.required(),
|
|
67876
|
+
name: import_joi150.default.string().trim().required(),
|
|
67877
|
+
baseUrl: import_joi150.default.string().uri({ scheme: ["http", "https"] }).required(),
|
|
67878
|
+
username: import_joi150.default.string().trim().required(),
|
|
67879
|
+
password: import_joi150.default.string().required(),
|
|
67880
|
+
location: import_joi150.default.string().allow(null, "").optional(),
|
|
67881
|
+
deviceId: import_joi150.default.string().allow(null, "").optional(),
|
|
67882
|
+
monitorPath: import_joi150.default.string().allow(null, "").optional(),
|
|
67883
|
+
enabled: import_joi150.default.boolean().optional(),
|
|
67884
|
+
status: import_joi150.default.string().valid("active", "inactive", "deleted", "offline").optional(),
|
|
67885
|
+
lastSeenAt: import_joi150.default.date().optional(),
|
|
67886
|
+
lastSyncAt: import_joi150.default.date().optional(),
|
|
67887
|
+
lastSyncStatus: import_joi150.default.string().valid("idle", "running", "completed", "failed").optional(),
|
|
67888
|
+
lastSyncMessage: import_joi150.default.string().allow(null, "").optional(),
|
|
67889
|
+
createdAt: import_joi150.default.date().optional(),
|
|
67890
|
+
updatedAt: import_joi150.default.date().optional(),
|
|
67891
|
+
deletedAt: import_joi150.default.date().optional()
|
|
67892
|
+
});
|
|
67893
|
+
var schemaUpdateHidAmicoReader = import_joi150.default.object({
|
|
67894
|
+
site: objectIdSchema2.optional(),
|
|
67895
|
+
name: import_joi150.default.string().trim().optional(),
|
|
67896
|
+
baseUrl: import_joi150.default.string().uri({ scheme: ["http", "https"] }).optional(),
|
|
67897
|
+
username: import_joi150.default.string().trim().optional(),
|
|
67898
|
+
password: import_joi150.default.string().allow(null, "").optional(),
|
|
67899
|
+
location: import_joi150.default.string().allow(null, "").optional(),
|
|
67900
|
+
deviceId: import_joi150.default.string().allow(null, "").optional(),
|
|
67901
|
+
monitorPath: import_joi150.default.string().allow(null, "").optional(),
|
|
67902
|
+
enabled: import_joi150.default.boolean().optional(),
|
|
67903
|
+
status: import_joi150.default.string().valid("active", "inactive", "deleted", "offline").optional(),
|
|
67904
|
+
lastSeenAt: import_joi150.default.date().optional(),
|
|
67905
|
+
lastSyncAt: import_joi150.default.date().optional(),
|
|
67906
|
+
lastSyncStatus: import_joi150.default.string().valid("idle", "running", "completed", "failed").optional(),
|
|
67907
|
+
lastSyncMessage: import_joi150.default.string().allow(null, "").optional(),
|
|
67908
|
+
deletedAt: import_joi150.default.date().optional()
|
|
67909
|
+
});
|
|
67910
|
+
var schemaHidAmicoEvent = import_joi150.default.object({
|
|
67911
|
+
_id: objectIdSchema2.optional(),
|
|
67912
|
+
reader: objectIdSchema2.required(),
|
|
67913
|
+
site: objectIdSchema2.optional(),
|
|
67914
|
+
type: import_joi150.default.string().required(),
|
|
67915
|
+
payload: import_joi150.default.object().unknown(true).required(),
|
|
67916
|
+
status: import_joi150.default.string().valid("received", "processed", "failed").optional(),
|
|
67917
|
+
createdAt: import_joi150.default.date().optional()
|
|
67918
|
+
});
|
|
67919
|
+
var schemaHidAmicoIdentity = import_joi150.default.object({
|
|
67920
|
+
_id: objectIdSchema2.optional(),
|
|
67921
|
+
reader: objectIdSchema2.required(),
|
|
67922
|
+
site: objectIdSchema2.required(),
|
|
67923
|
+
hidUserId: import_joi150.default.alternatives(import_joi150.default.string(), import_joi150.default.number()).optional().allow(null, ""),
|
|
67924
|
+
registration: import_joi150.default.string().optional().allow(null, ""),
|
|
67925
|
+
cardNo: import_joi150.default.string().optional().allow(null, ""),
|
|
67926
|
+
person: objectIdSchema2.optional().allow(null, ""),
|
|
67927
|
+
user: objectIdSchema2.optional().allow(null, ""),
|
|
67928
|
+
member: objectIdSchema2.optional().allow(null, ""),
|
|
67929
|
+
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
67930
|
+
type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
|
|
67931
|
+
status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
|
|
67932
|
+
metadata: import_joi150.default.object().unknown(true).optional(),
|
|
67933
|
+
createdAt: import_joi150.default.date().optional(),
|
|
67934
|
+
updatedAt: import_joi150.default.date().optional(),
|
|
67935
|
+
deletedAt: import_joi150.default.date().optional()
|
|
67936
|
+
}).or("hidUserId", "registration", "cardNo");
|
|
67937
|
+
var schemaCreateHidAmicoIdentity = import_joi150.default.object({
|
|
67938
|
+
site: objectIdSchema2.optional(),
|
|
67939
|
+
hidUserId: import_joi150.default.alternatives(import_joi150.default.string(), import_joi150.default.number()).optional().allow(null, ""),
|
|
67940
|
+
registration: import_joi150.default.string().optional().allow(null, ""),
|
|
67941
|
+
cardNo: import_joi150.default.string().optional().allow(null, ""),
|
|
67942
|
+
person: objectIdSchema2.optional().allow(null, ""),
|
|
67943
|
+
user: objectIdSchema2.optional().allow(null, ""),
|
|
67944
|
+
member: objectIdSchema2.optional().allow(null, ""),
|
|
67945
|
+
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
67946
|
+
type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").required(),
|
|
67947
|
+
status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
|
|
67948
|
+
metadata: import_joi150.default.object().unknown(true).optional()
|
|
67949
|
+
}).or("hidUserId", "registration", "cardNo");
|
|
67950
|
+
var schemaUpdateHidAmicoIdentity = import_joi150.default.object({
|
|
67951
|
+
hidUserId: import_joi150.default.alternatives(import_joi150.default.string(), import_joi150.default.number()).optional().allow(null, ""),
|
|
67952
|
+
registration: import_joi150.default.string().optional().allow(null, ""),
|
|
67953
|
+
cardNo: import_joi150.default.string().optional().allow(null, ""),
|
|
67954
|
+
person: objectIdSchema2.optional().allow(null, ""),
|
|
67955
|
+
user: objectIdSchema2.optional().allow(null, ""),
|
|
67956
|
+
member: objectIdSchema2.optional().allow(null, ""),
|
|
67957
|
+
visitor: objectIdSchema2.optional().allow(null, ""),
|
|
67958
|
+
type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
|
|
67959
|
+
status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
|
|
67960
|
+
metadata: import_joi150.default.object().unknown(true).optional(),
|
|
67961
|
+
deletedAt: import_joi150.default.date().optional()
|
|
67962
|
+
});
|
|
67963
|
+
var schemaHidAmicoReaderIdParams = import_joi150.default.object({
|
|
67964
|
+
readerId: import_joi150.default.string().hex().length(24).required()
|
|
67965
|
+
});
|
|
67966
|
+
var schemaHidAmicoUserImageParams = import_joi150.default.object({
|
|
67967
|
+
readerId: import_joi150.default.string().hex().length(24).required(),
|
|
67968
|
+
hidUserId: import_joi150.default.alternatives().try(import_joi150.default.string(), import_joi150.default.number()).required()
|
|
67969
|
+
});
|
|
67970
|
+
var schemaHidAmicoIdentityIdParams = import_joi150.default.object({
|
|
67971
|
+
identityId: import_joi150.default.string().hex().length(24).required()
|
|
67972
|
+
});
|
|
67973
|
+
var schemaHidAmicoReaderListQuery = import_joi150.default.object({
|
|
67974
|
+
site: import_joi150.default.string().hex().length(24).optional(),
|
|
67975
|
+
page: import_joi150.default.number().min(1).optional(),
|
|
67976
|
+
limit: import_joi150.default.number().min(1).optional()
|
|
67977
|
+
});
|
|
67978
|
+
var schemaHidAmicoLogQuery = import_joi150.default.object({
|
|
67979
|
+
page: import_joi150.default.number().min(1).optional(),
|
|
67980
|
+
limit: import_joi150.default.number().min(1).optional(),
|
|
67981
|
+
type: import_joi150.default.string().optional()
|
|
67982
|
+
});
|
|
67983
|
+
var schemaHidAmicoIdentityQuery = import_joi150.default.object({
|
|
67984
|
+
page: import_joi150.default.number().min(1).optional(),
|
|
67985
|
+
limit: import_joi150.default.number().min(1).optional(),
|
|
67986
|
+
type: import_joi150.default.string().valid("resident", "staff", "contractor", "visitor", "admin", "unknown").optional(),
|
|
67987
|
+
status: import_joi150.default.string().valid("active", "inactive", "deleted").optional(),
|
|
67988
|
+
search: import_joi150.default.string().allow("").optional()
|
|
67989
|
+
});
|
|
67990
|
+
var schemaHidAmicoSync = import_joi150.default.object({
|
|
67991
|
+
objects: import_joi150.default.array().items(
|
|
67992
|
+
import_joi150.default.object({
|
|
67993
|
+
object: import_joi150.default.string().required(),
|
|
67994
|
+
values: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).required()
|
|
67995
|
+
}).unknown(true)
|
|
67996
|
+
).optional(),
|
|
67997
|
+
users: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional(),
|
|
67998
|
+
cards: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional(),
|
|
67999
|
+
qrcodes: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional(),
|
|
68000
|
+
pins: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).optional()
|
|
68001
|
+
}).unknown(true);
|
|
68002
|
+
var schemaHidAmicoExecuteActions = import_joi150.default.object({
|
|
68003
|
+
actions: import_joi150.default.array().items(import_joi150.default.object().unknown(true)).min(1).required()
|
|
68004
|
+
}).unknown(true);
|
|
68005
|
+
var schemaHidAmicoConfiguration = import_joi150.default.object().pattern(import_joi150.default.string(), import_joi150.default.array().items(import_joi150.default.string())).min(1).unknown(true);
|
|
68006
|
+
var schemaHidAmicoSetConfiguration = import_joi150.default.object().unknown(true);
|
|
68007
|
+
var schemaHidAmicoObjectOperation = import_joi150.default.object({
|
|
68008
|
+
operation: import_joi150.default.string().valid("load", "create", "modify", "destroy").required(),
|
|
68009
|
+
object: import_joi150.default.string().required(),
|
|
68010
|
+
values: import_joi150.default.alternatives().try(
|
|
68011
|
+
import_joi150.default.array().items(import_joi150.default.object().unknown(true)),
|
|
68012
|
+
import_joi150.default.object().unknown(true)
|
|
68013
|
+
).optional(),
|
|
68014
|
+
where: import_joi150.default.object().unknown(true).optional(),
|
|
68015
|
+
fields: import_joi150.default.array().items(import_joi150.default.string()).optional(),
|
|
68016
|
+
order: import_joi150.default.array().items(import_joi150.default.string()).optional(),
|
|
68017
|
+
limit: import_joi150.default.number().integer().min(1).optional(),
|
|
68018
|
+
offset: import_joi150.default.number().integer().min(0).optional()
|
|
68019
|
+
}).unknown(true);
|
|
68020
|
+
var schemaHidAmicoNotificationParams = import_joi150.default.object({
|
|
68021
|
+
readerId: import_joi150.default.string().hex().length(24).required(),
|
|
68022
|
+
type: import_joi150.default.string().valid(
|
|
68023
|
+
"dao",
|
|
68024
|
+
"template",
|
|
68025
|
+
"user_image",
|
|
68026
|
+
"card",
|
|
68027
|
+
"pin",
|
|
68028
|
+
"password",
|
|
68029
|
+
"operation_mode",
|
|
68030
|
+
"door",
|
|
68031
|
+
"secbox",
|
|
68032
|
+
"access_photo",
|
|
68033
|
+
"new_user_identified",
|
|
68034
|
+
"push_result"
|
|
68035
|
+
).required()
|
|
68036
|
+
});
|
|
68037
|
+
function MHidAmicoReader(value) {
|
|
68038
|
+
const { error } = schemaHidAmicoReader.validate(value);
|
|
68039
|
+
if (error) {
|
|
68040
|
+
import_node_server_utils256.logger.info(`HID Amico reader: ${error.message}`);
|
|
68041
|
+
throw new import_node_server_utils256.BadRequestError(error.message);
|
|
68042
|
+
}
|
|
68043
|
+
return {
|
|
68044
|
+
_id: value._id ? toObjectId23(value._id, "reader ID") : new import_mongodb153.ObjectId(),
|
|
68045
|
+
site: toObjectId23(value.site, "site ID"),
|
|
68046
|
+
name: value.name,
|
|
68047
|
+
baseUrl: value.baseUrl.replace(/\/+$/, ""),
|
|
68048
|
+
username: value.username,
|
|
68049
|
+
password: value.password,
|
|
68050
|
+
location: value.location ?? "",
|
|
68051
|
+
deviceId: value.deviceId ?? "",
|
|
68052
|
+
monitorPath: value.monitorPath ?? "api/notifications",
|
|
68053
|
+
enabled: value.enabled ?? true,
|
|
68054
|
+
status: value.status ?? "active",
|
|
68055
|
+
lastSeenAt: value.lastSeenAt ?? "",
|
|
68056
|
+
lastSyncAt: value.lastSyncAt ?? "",
|
|
68057
|
+
lastSyncStatus: value.lastSyncStatus ?? "idle",
|
|
68058
|
+
lastSyncMessage: value.lastSyncMessage ?? "",
|
|
68059
|
+
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
68060
|
+
updatedAt: value.updatedAt ?? /* @__PURE__ */ new Date(),
|
|
68061
|
+
deletedAt: value.deletedAt ?? ""
|
|
68062
|
+
};
|
|
68063
|
+
}
|
|
68064
|
+
function MHidAmicoEvent(value) {
|
|
68065
|
+
const { error } = schemaHidAmicoEvent.validate(value);
|
|
68066
|
+
if (error) {
|
|
68067
|
+
import_node_server_utils256.logger.info(`HID Amico event: ${error.message}`);
|
|
68068
|
+
throw new import_node_server_utils256.BadRequestError(error.message);
|
|
68069
|
+
}
|
|
68070
|
+
return {
|
|
68071
|
+
_id: value._id ? toObjectId23(value._id, "event ID") : new import_mongodb153.ObjectId(),
|
|
68072
|
+
reader: toObjectId23(value.reader, "reader ID"),
|
|
68073
|
+
site: value.site ? toObjectId23(value.site, "site ID") : void 0,
|
|
68074
|
+
type: value.type,
|
|
68075
|
+
payload: value.payload,
|
|
68076
|
+
status: value.status ?? "received",
|
|
68077
|
+
createdAt: value.createdAt ?? /* @__PURE__ */ new Date()
|
|
68078
|
+
};
|
|
68079
|
+
}
|
|
68080
|
+
function optionalObjectId(value) {
|
|
68081
|
+
return value ? toObjectId23(value) : void 0;
|
|
68082
|
+
}
|
|
68083
|
+
function MHidAmicoIdentity(value) {
|
|
68084
|
+
const { error } = schemaHidAmicoIdentity.validate(value);
|
|
68085
|
+
if (error) {
|
|
68086
|
+
import_node_server_utils256.logger.info(`HID Amico identity: ${error.message}`);
|
|
68087
|
+
throw new import_node_server_utils256.BadRequestError(error.message);
|
|
68088
|
+
}
|
|
68089
|
+
return {
|
|
68090
|
+
_id: value._id ? toObjectId23(value._id, "identity ID") : new import_mongodb153.ObjectId(),
|
|
68091
|
+
reader: toObjectId23(value.reader, "reader ID"),
|
|
68092
|
+
site: toObjectId23(value.site, "site ID"),
|
|
68093
|
+
hidUserId: value.hidUserId === void 0 || value.hidUserId === null ? "" : String(value.hidUserId),
|
|
68094
|
+
registration: value.registration ?? "",
|
|
68095
|
+
cardNo: value.cardNo ?? "",
|
|
68096
|
+
person: optionalObjectId(value.person),
|
|
68097
|
+
user: optionalObjectId(value.user),
|
|
68098
|
+
member: optionalObjectId(value.member),
|
|
68099
|
+
visitor: optionalObjectId(value.visitor),
|
|
68100
|
+
type: value.type,
|
|
68101
|
+
status: value.status ?? "active",
|
|
68102
|
+
metadata: value.metadata ?? {},
|
|
68103
|
+
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
68104
|
+
updatedAt: value.updatedAt ?? /* @__PURE__ */ new Date(),
|
|
68105
|
+
deletedAt: value.deletedAt ?? ""
|
|
68106
|
+
};
|
|
68107
|
+
}
|
|
68108
|
+
|
|
68109
|
+
// src/repositories/hid-amico.repo.ts
|
|
68110
|
+
var import_node_server_utils257 = require("@7365admin1/node-server-utils");
|
|
68111
|
+
var import_mongodb154 = require("mongodb");
|
|
68112
|
+
function useHidAmicoRepo() {
|
|
68113
|
+
function db() {
|
|
68114
|
+
const instance = import_node_server_utils257.useAtlas.getDb();
|
|
68115
|
+
if (!instance) {
|
|
68116
|
+
throw new import_node_server_utils257.InternalServerError("Unable to connect to server.");
|
|
68117
|
+
}
|
|
68118
|
+
return instance;
|
|
68119
|
+
}
|
|
68120
|
+
function readers() {
|
|
68121
|
+
return db().collection("hid-amico-readers");
|
|
68122
|
+
}
|
|
68123
|
+
function events() {
|
|
68124
|
+
return db().collection("hid-amico-events");
|
|
68125
|
+
}
|
|
68126
|
+
function identities() {
|
|
68127
|
+
return db().collection("hid-amico-identities");
|
|
68128
|
+
}
|
|
68129
|
+
function toId(id, label = "ID") {
|
|
68130
|
+
try {
|
|
68131
|
+
return new import_mongodb154.ObjectId(id);
|
|
68132
|
+
} catch {
|
|
68133
|
+
throw new import_node_server_utils257.BadRequestError(`Invalid ${label} format`);
|
|
68134
|
+
}
|
|
68135
|
+
}
|
|
68136
|
+
function hideSecret(reader) {
|
|
68137
|
+
if (!reader) {
|
|
68138
|
+
return reader;
|
|
68139
|
+
}
|
|
68140
|
+
const { password, ...safeReader } = reader;
|
|
68141
|
+
const status = safeReader.lastSyncStatus === "failed" && safeReader.status === "active" ? "offline" : safeReader.status;
|
|
68142
|
+
return {
|
|
68143
|
+
...safeReader,
|
|
68144
|
+
status,
|
|
68145
|
+
passwordSet: Boolean(password)
|
|
68146
|
+
};
|
|
68147
|
+
}
|
|
68148
|
+
function escapeRegex(value) {
|
|
68149
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
68150
|
+
}
|
|
68151
|
+
function buildIdentityKeyQuery(value) {
|
|
68152
|
+
const or = [];
|
|
68153
|
+
if (value.hidUserId !== void 0 && value.hidUserId !== null && String(value.hidUserId) !== "") {
|
|
68154
|
+
or.push({ hidUserId: String(value.hidUserId) });
|
|
68155
|
+
}
|
|
68156
|
+
if (value.registration) {
|
|
68157
|
+
or.push({ registration: value.registration });
|
|
68158
|
+
}
|
|
68159
|
+
if (value.cardNo) {
|
|
68160
|
+
or.push({ cardNo: value.cardNo });
|
|
68161
|
+
}
|
|
68162
|
+
return or;
|
|
68163
|
+
}
|
|
68164
|
+
async function createIndexes() {
|
|
68165
|
+
try {
|
|
68166
|
+
await Promise.all([
|
|
68167
|
+
readers().createIndex({ site: 1, status: 1 }),
|
|
68168
|
+
readers().createIndex(
|
|
68169
|
+
{ site: 1, baseUrl: 1 },
|
|
68170
|
+
{ unique: true, partialFilterExpression: { status: "active" } }
|
|
68171
|
+
),
|
|
68172
|
+
readers().createIndex({ deviceId: 1 }),
|
|
68173
|
+
events().createIndex({ reader: 1, createdAt: -1 }),
|
|
68174
|
+
events().createIndex({ site: 1, createdAt: -1 }),
|
|
68175
|
+
events().createIndex({ type: 1, createdAt: -1 }),
|
|
68176
|
+
identities().createIndex({ reader: 1, status: 1 }),
|
|
68177
|
+
identities().createIndex({ site: 1, status: 1 }),
|
|
68178
|
+
identities().createIndex({ reader: 1, hidUserId: 1 }),
|
|
68179
|
+
identities().createIndex({ reader: 1, registration: 1 }),
|
|
68180
|
+
identities().createIndex({ reader: 1, cardNo: 1 })
|
|
68181
|
+
]);
|
|
68182
|
+
return "HID Amico indexes created.";
|
|
68183
|
+
} catch (error) {
|
|
68184
|
+
import_node_server_utils257.logger.error(error.message);
|
|
68185
|
+
throw new Error("Failed to create HID Amico indexes.");
|
|
68186
|
+
}
|
|
68187
|
+
}
|
|
68188
|
+
async function add(value, session) {
|
|
68189
|
+
try {
|
|
68190
|
+
const doc = MHidAmicoReader(value);
|
|
68191
|
+
await readers().insertOne(doc, { session });
|
|
68192
|
+
return hideSecret(doc);
|
|
68193
|
+
} catch (error) {
|
|
68194
|
+
if (error.message?.includes("duplicate")) {
|
|
68195
|
+
throw new import_node_server_utils257.BadRequestError("HID Amico reader already exists for this site and URL.");
|
|
68196
|
+
}
|
|
68197
|
+
throw error;
|
|
68198
|
+
}
|
|
68199
|
+
}
|
|
68200
|
+
async function list(value) {
|
|
68201
|
+
const page = value.page ? value.page - 1 : 0;
|
|
68202
|
+
const limit = value.limit || 10;
|
|
68203
|
+
const query = { status: { $ne: "deleted" } };
|
|
68204
|
+
if (value.site) {
|
|
68205
|
+
query.site = toId(value.site, "site ID");
|
|
68206
|
+
}
|
|
68207
|
+
const items = await readers().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
68208
|
+
const total = await readers().countDocuments(query);
|
|
68209
|
+
return (0, import_node_server_utils257.paginate)(items.map(hideSecret), page, limit, total);
|
|
68210
|
+
}
|
|
68211
|
+
async function getById(id, options = {}) {
|
|
68212
|
+
const _id = toId(id, "reader ID");
|
|
68213
|
+
const reader = await readers().findOne(
|
|
68214
|
+
{ _id, status: { $ne: "deleted" } }
|
|
68215
|
+
);
|
|
68216
|
+
if (!reader) {
|
|
68217
|
+
throw new import_node_server_utils257.BadRequestError("HID Amico reader not found.");
|
|
68218
|
+
}
|
|
68219
|
+
return options.includePassword ? reader : hideSecret(reader);
|
|
68220
|
+
}
|
|
68221
|
+
async function updateById(id, value, session) {
|
|
68222
|
+
const { error } = schemaUpdateHidAmicoReader.validate(value);
|
|
68223
|
+
if (error) {
|
|
68224
|
+
throw new import_node_server_utils257.BadRequestError(error.message);
|
|
68225
|
+
}
|
|
68226
|
+
const _id = toId(id, "reader ID");
|
|
68227
|
+
const payload = {
|
|
68228
|
+
...value,
|
|
68229
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
68230
|
+
};
|
|
68231
|
+
if (payload.site) {
|
|
68232
|
+
payload.site = toId(payload.site, "site ID");
|
|
68233
|
+
}
|
|
68234
|
+
if (payload.baseUrl) {
|
|
68235
|
+
payload.baseUrl = payload.baseUrl.replace(/\/+$/, "");
|
|
68236
|
+
}
|
|
68237
|
+
const updated = await readers().findOneAndUpdate(
|
|
68238
|
+
{ _id, status: { $ne: "deleted" } },
|
|
68239
|
+
{ $set: payload },
|
|
68240
|
+
{ returnDocument: "after", session }
|
|
68241
|
+
);
|
|
68242
|
+
if (!updated) {
|
|
68243
|
+
throw new import_node_server_utils257.BadRequestError("HID Amico reader not found.");
|
|
68244
|
+
}
|
|
68245
|
+
return hideSecret(updated);
|
|
68246
|
+
}
|
|
68247
|
+
async function markDeleted(id, session) {
|
|
68248
|
+
return updateById(
|
|
68249
|
+
id,
|
|
68250
|
+
{
|
|
68251
|
+
status: "deleted",
|
|
68252
|
+
enabled: false,
|
|
68253
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
68254
|
+
},
|
|
68255
|
+
session
|
|
68256
|
+
);
|
|
68257
|
+
}
|
|
68258
|
+
async function addEvent(value, session) {
|
|
68259
|
+
const event = MHidAmicoEvent(value);
|
|
68260
|
+
await events().insertOne(event, { session });
|
|
68261
|
+
return event;
|
|
68262
|
+
}
|
|
68263
|
+
async function listEvents(value) {
|
|
68264
|
+
const page = value.page ? value.page - 1 : 0;
|
|
68265
|
+
const limit = value.limit || 20;
|
|
68266
|
+
const query = { reader: toId(value.reader, "reader ID") };
|
|
68267
|
+
if (value.type) {
|
|
68268
|
+
query.type = value.type;
|
|
68269
|
+
}
|
|
68270
|
+
const items = await events().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
68271
|
+
const total = await events().countDocuments(query);
|
|
68272
|
+
return (0, import_node_server_utils257.paginate)(items, page, limit, total);
|
|
68273
|
+
}
|
|
68274
|
+
async function addIdentity(value, session) {
|
|
68275
|
+
try {
|
|
68276
|
+
const identity = MHidAmicoIdentity(value);
|
|
68277
|
+
const existing = await findExistingIdentity({
|
|
68278
|
+
reader: identity.reader,
|
|
68279
|
+
hidUserId: identity.hidUserId,
|
|
68280
|
+
registration: identity.registration,
|
|
68281
|
+
cardNo: identity.cardNo
|
|
68282
|
+
});
|
|
68283
|
+
if (existing) {
|
|
68284
|
+
throw new import_node_server_utils257.BadRequestError("HID Amico identity already exists for this reader.");
|
|
68285
|
+
}
|
|
68286
|
+
await identities().insertOne(identity, { session });
|
|
68287
|
+
return identity;
|
|
68288
|
+
} catch (error) {
|
|
68289
|
+
if (error instanceof import_node_server_utils257.BadRequestError) {
|
|
68290
|
+
throw error;
|
|
68291
|
+
}
|
|
68292
|
+
if (error.message?.includes("duplicate")) {
|
|
68293
|
+
throw new import_node_server_utils257.BadRequestError("HID Amico identity already exists for this reader.");
|
|
68294
|
+
}
|
|
68295
|
+
throw error;
|
|
68296
|
+
}
|
|
68297
|
+
}
|
|
68298
|
+
async function listIdentities(value) {
|
|
68299
|
+
const page = value.page ? value.page - 1 : 0;
|
|
68300
|
+
const limit = value.limit || 20;
|
|
68301
|
+
const query = {
|
|
68302
|
+
reader: toId(value.reader, "reader ID"),
|
|
68303
|
+
status: value.status || { $ne: "deleted" }
|
|
68304
|
+
};
|
|
68305
|
+
if (value.type) {
|
|
68306
|
+
query.type = value.type;
|
|
68307
|
+
}
|
|
68308
|
+
if (value.search) {
|
|
68309
|
+
const search = escapeRegex(value.search);
|
|
68310
|
+
query.$or = [
|
|
68311
|
+
{ hidUserId: { $regex: search, $options: "i" } },
|
|
68312
|
+
{ registration: { $regex: search, $options: "i" } },
|
|
68313
|
+
{ cardNo: { $regex: search, $options: "i" } }
|
|
68314
|
+
];
|
|
68315
|
+
}
|
|
68316
|
+
const items = await identities().find(query).sort({ createdAt: -1 }).skip(page * limit).limit(limit).toArray();
|
|
68317
|
+
const total = await identities().countDocuments(query);
|
|
68318
|
+
return (0, import_node_server_utils257.paginate)(items, page, limit, total);
|
|
68319
|
+
}
|
|
68320
|
+
async function updateIdentity(id, value, session) {
|
|
68321
|
+
const { error } = schemaUpdateHidAmicoIdentity.validate(value);
|
|
68322
|
+
if (error) {
|
|
68323
|
+
throw new import_node_server_utils257.BadRequestError(error.message);
|
|
68324
|
+
}
|
|
68325
|
+
const payload = {
|
|
68326
|
+
...value,
|
|
68327
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
68328
|
+
};
|
|
68329
|
+
const unsetPayload = {};
|
|
68330
|
+
["person", "user", "member", "visitor"].forEach((field) => {
|
|
68331
|
+
if (payload[field]) {
|
|
68332
|
+
payload[field] = toId(payload[field], `${field} ID`);
|
|
68333
|
+
}
|
|
68334
|
+
if (payload[field] === "" || payload[field] === null) {
|
|
68335
|
+
delete payload[field];
|
|
68336
|
+
unsetPayload[field] = "";
|
|
68337
|
+
}
|
|
68338
|
+
});
|
|
68339
|
+
if (payload.hidUserId !== void 0 && payload.hidUserId !== null) {
|
|
68340
|
+
payload.hidUserId = String(payload.hidUserId);
|
|
68341
|
+
}
|
|
68342
|
+
const updated = await identities().findOneAndUpdate(
|
|
68343
|
+
{ _id: toId(id, "identity ID"), status: { $ne: "deleted" } },
|
|
68344
|
+
{
|
|
68345
|
+
$set: payload,
|
|
68346
|
+
...Object.keys(unsetPayload).length ? { $unset: unsetPayload } : {}
|
|
68347
|
+
},
|
|
68348
|
+
{ returnDocument: "after", session }
|
|
68349
|
+
);
|
|
68350
|
+
if (!updated) {
|
|
68351
|
+
throw new import_node_server_utils257.BadRequestError("HID Amico identity not found.");
|
|
68352
|
+
}
|
|
68353
|
+
return updated;
|
|
68354
|
+
}
|
|
68355
|
+
async function deleteIdentity(id, session) {
|
|
68356
|
+
return updateIdentity(
|
|
68357
|
+
id,
|
|
68358
|
+
{
|
|
68359
|
+
status: "deleted",
|
|
68360
|
+
deletedAt: /* @__PURE__ */ new Date()
|
|
68361
|
+
},
|
|
68362
|
+
session
|
|
68363
|
+
);
|
|
68364
|
+
}
|
|
68365
|
+
async function findIdentity(value) {
|
|
68366
|
+
const or = buildIdentityKeyQuery(value);
|
|
68367
|
+
if (!or.length) {
|
|
68368
|
+
return null;
|
|
68369
|
+
}
|
|
68370
|
+
return identities().findOne({
|
|
68371
|
+
reader: toId(value.reader, "reader ID"),
|
|
68372
|
+
status: "active",
|
|
68373
|
+
$or: or
|
|
68374
|
+
});
|
|
68375
|
+
}
|
|
68376
|
+
async function findExistingIdentity(value) {
|
|
68377
|
+
const or = buildIdentityKeyQuery(value);
|
|
68378
|
+
if (!or.length) {
|
|
68379
|
+
return null;
|
|
68380
|
+
}
|
|
68381
|
+
return identities().findOne({
|
|
68382
|
+
reader: toId(value.reader, "reader ID"),
|
|
68383
|
+
status: { $ne: "deleted" },
|
|
68384
|
+
$or: or
|
|
68385
|
+
});
|
|
68386
|
+
}
|
|
68387
|
+
return {
|
|
68388
|
+
createIndexes,
|
|
68389
|
+
add,
|
|
68390
|
+
list,
|
|
68391
|
+
getById,
|
|
68392
|
+
updateById,
|
|
68393
|
+
markDeleted,
|
|
68394
|
+
addEvent,
|
|
68395
|
+
listEvents,
|
|
68396
|
+
addIdentity,
|
|
68397
|
+
listIdentities,
|
|
68398
|
+
updateIdentity,
|
|
68399
|
+
deleteIdentity,
|
|
68400
|
+
findIdentity,
|
|
68401
|
+
findExistingIdentity
|
|
68402
|
+
};
|
|
68403
|
+
}
|
|
68404
|
+
|
|
68405
|
+
// src/services/hid-amico.service.ts
|
|
68406
|
+
var import_crypto3 = __toESM(require("crypto"));
|
|
68407
|
+
var import_axios4 = __toESM(require("axios"));
|
|
68408
|
+
var import_node_server_utils258 = require("@7365admin1/node-server-utils");
|
|
68409
|
+
var PASSWORD_PREFIX = "v1";
|
|
68410
|
+
function getSecretKey() {
|
|
68411
|
+
const secret = process.env.HID_AMICO_SECRET || process.env.ACCESS_TOKEN_SECRET || "iservice365-hid-amico";
|
|
68412
|
+
return import_crypto3.default.createHash("sha256").update(secret).digest();
|
|
68413
|
+
}
|
|
68414
|
+
function encryptSecret(value) {
|
|
68415
|
+
const iv = import_crypto3.default.randomBytes(12);
|
|
68416
|
+
const cipher = import_crypto3.default.createCipheriv("aes-256-gcm", getSecretKey(), iv);
|
|
68417
|
+
const encrypted = Buffer.concat([cipher.update(value, "utf8"), cipher.final()]);
|
|
68418
|
+
const tag = cipher.getAuthTag();
|
|
68419
|
+
return [PASSWORD_PREFIX, iv.toString("hex"), tag.toString("hex"), encrypted.toString("hex")].join(":");
|
|
68420
|
+
}
|
|
68421
|
+
function decryptSecret(value) {
|
|
68422
|
+
if (!value?.startsWith(`${PASSWORD_PREFIX}:`)) {
|
|
68423
|
+
return value;
|
|
68424
|
+
}
|
|
68425
|
+
const [, ivHex, tagHex, encryptedHex] = value.split(":");
|
|
68426
|
+
const decipher = import_crypto3.default.createDecipheriv("aes-256-gcm", getSecretKey(), Buffer.from(ivHex, "hex"));
|
|
68427
|
+
decipher.setAuthTag(Buffer.from(tagHex, "hex"));
|
|
68428
|
+
return Buffer.concat([
|
|
68429
|
+
decipher.update(Buffer.from(encryptedHex, "hex")),
|
|
68430
|
+
decipher.final()
|
|
68431
|
+
]).toString("utf8");
|
|
68432
|
+
}
|
|
68433
|
+
function formatHidResponse(data) {
|
|
68434
|
+
if (data === void 0 || data === null) {
|
|
68435
|
+
return "";
|
|
68436
|
+
}
|
|
68437
|
+
const text = typeof data === "string" ? data : JSON.stringify(data);
|
|
68438
|
+
return text.length > 300 ? `${text.slice(0, 300)}...` : text;
|
|
68439
|
+
}
|
|
68440
|
+
function sanitizeHidPath(path5) {
|
|
68441
|
+
return path5.replace(/([?&]session=)[^&]+/i, "$1<redacted>");
|
|
68442
|
+
}
|
|
68443
|
+
function toHidRequestError(error, path5) {
|
|
68444
|
+
if (import_axios4.default.isAxiosError(error)) {
|
|
68445
|
+
const status = error.response?.status;
|
|
68446
|
+
const payload = formatHidResponse(error.response?.data);
|
|
68447
|
+
const detail = [
|
|
68448
|
+
`HID Amico request failed: ${sanitizeHidPath(path5)}`,
|
|
68449
|
+
status ? `status ${status}` : "",
|
|
68450
|
+
payload ? `response ${payload}` : error.message
|
|
68451
|
+
].filter(Boolean).join(" - ");
|
|
68452
|
+
return new import_node_server_utils258.BadRequestError(detail);
|
|
68453
|
+
}
|
|
68454
|
+
return error;
|
|
68455
|
+
}
|
|
68456
|
+
var HidAmicoClient = class {
|
|
68457
|
+
constructor(reader) {
|
|
68458
|
+
this.reader = reader;
|
|
68459
|
+
this.session = "";
|
|
68460
|
+
this.http = import_axios4.default.create({
|
|
68461
|
+
baseURL: reader.baseUrl.replace(/\/+$/, ""),
|
|
68462
|
+
timeout: 15e3,
|
|
68463
|
+
headers: { "Content-Type": "application/json" }
|
|
68464
|
+
});
|
|
68465
|
+
}
|
|
68466
|
+
async post(path5, body) {
|
|
68467
|
+
try {
|
|
68468
|
+
return await this.http.post(path5, body);
|
|
68469
|
+
} catch (error) {
|
|
68470
|
+
throw toHidRequestError(error, path5);
|
|
68471
|
+
}
|
|
68472
|
+
}
|
|
68473
|
+
async get(path5, responseType = "json") {
|
|
68474
|
+
try {
|
|
68475
|
+
return await this.http.get(path5, { responseType });
|
|
68476
|
+
} catch (error) {
|
|
68477
|
+
throw toHidRequestError(error, path5);
|
|
68478
|
+
}
|
|
68479
|
+
}
|
|
68480
|
+
url(path5) {
|
|
68481
|
+
const normalizedPath = path5.startsWith("/") ? path5 : `/${path5}`;
|
|
68482
|
+
if (!this.session) {
|
|
68483
|
+
return normalizedPath;
|
|
68484
|
+
}
|
|
68485
|
+
const separator = normalizedPath.includes("?") ? "&" : "?";
|
|
68486
|
+
return `${normalizedPath}${separator}session=${encodeURIComponent(this.session)}`;
|
|
68487
|
+
}
|
|
68488
|
+
async login() {
|
|
68489
|
+
const res = await this.post("/hidlogin.fcgi", {
|
|
68490
|
+
login: this.reader.username,
|
|
68491
|
+
password: decryptSecret(this.reader.password)
|
|
68492
|
+
});
|
|
68493
|
+
if (!res.data?.session) {
|
|
68494
|
+
throw new import_node_server_utils258.BadRequestError("HID Amico login failed: missing session.");
|
|
68495
|
+
}
|
|
68496
|
+
this.session = res.data.session;
|
|
68497
|
+
return this.session;
|
|
68498
|
+
}
|
|
68499
|
+
async sessionIsValid() {
|
|
68500
|
+
if (!this.session) {
|
|
68501
|
+
await this.login();
|
|
68502
|
+
}
|
|
68503
|
+
const res = await this.post(this.url("/session_is_valid.fcgi"), {});
|
|
68504
|
+
return Boolean(res.data?.session_is_valid ?? res.data?.valid ?? true);
|
|
68505
|
+
}
|
|
68506
|
+
async getUserImage(hidUserId) {
|
|
68507
|
+
if (!this.session) {
|
|
68508
|
+
await this.login();
|
|
68509
|
+
}
|
|
68510
|
+
const path5 = this.url(`/user_get_image.fcgi?user_id=${encodeURIComponent(String(hidUserId))}`);
|
|
68511
|
+
const res = await this.get(path5, "arraybuffer");
|
|
68512
|
+
const contentType = String(res.headers?.["content-type"] || "");
|
|
68513
|
+
const buffer = Buffer.from(res.data);
|
|
68514
|
+
if (contentType.includes("application/json")) {
|
|
68515
|
+
const payload = JSON.parse(buffer.toString("utf8"));
|
|
68516
|
+
const image = payload.image || payload.photo || payload.data?.image || payload.data?.photo;
|
|
68517
|
+
if (!image) {
|
|
68518
|
+
throw new import_node_server_utils258.BadRequestError("HID Amico user image response did not include an image.");
|
|
68519
|
+
}
|
|
68520
|
+
return {
|
|
68521
|
+
contentType: payload.contentType || payload.mimeType || "image/jpeg",
|
|
68522
|
+
base64: String(image).replace(/^data:image\/[a-zA-Z0-9.+-]+;base64,/, "")
|
|
68523
|
+
};
|
|
68524
|
+
}
|
|
68525
|
+
return {
|
|
68526
|
+
contentType: contentType || "image/jpeg",
|
|
68527
|
+
base64: buffer.toString("base64")
|
|
68528
|
+
};
|
|
68529
|
+
}
|
|
68530
|
+
async logout() {
|
|
68531
|
+
if (!this.session) {
|
|
68532
|
+
return;
|
|
68533
|
+
}
|
|
68534
|
+
const logoutUrl = this.url("/logout.fcgi");
|
|
68535
|
+
try {
|
|
68536
|
+
this.session = "";
|
|
68537
|
+
await this.post(logoutUrl, {});
|
|
68538
|
+
} catch {
|
|
68539
|
+
this.session = "";
|
|
68540
|
+
}
|
|
68541
|
+
}
|
|
68542
|
+
async createObjects(batch) {
|
|
68543
|
+
if (!this.session) {
|
|
68544
|
+
await this.login();
|
|
68545
|
+
}
|
|
68546
|
+
const res = await this.post(this.url("/create_objects.fcgi"), {
|
|
68547
|
+
object: batch.object,
|
|
68548
|
+
values: batch.values
|
|
68549
|
+
});
|
|
68550
|
+
return res.data;
|
|
68551
|
+
}
|
|
68552
|
+
async loadObjects(query) {
|
|
68553
|
+
if (!this.session) {
|
|
68554
|
+
await this.login();
|
|
68555
|
+
}
|
|
68556
|
+
const res = await this.post(this.url("/load_objects.fcgi"), query);
|
|
68557
|
+
return res.data;
|
|
68558
|
+
}
|
|
68559
|
+
async modifyObjects(payload) {
|
|
68560
|
+
if (!this.session) {
|
|
68561
|
+
await this.login();
|
|
68562
|
+
}
|
|
68563
|
+
const res = await this.post(this.url("/modify_objects.fcgi"), payload);
|
|
68564
|
+
return res.data;
|
|
68565
|
+
}
|
|
68566
|
+
async destroyObjects(payload) {
|
|
68567
|
+
if (!this.session) {
|
|
68568
|
+
await this.login();
|
|
68569
|
+
}
|
|
68570
|
+
const res = await this.post(this.url("/destroy_objects.fcgi"), payload);
|
|
68571
|
+
return res.data;
|
|
68572
|
+
}
|
|
68573
|
+
async doorState() {
|
|
68574
|
+
if (!this.session) {
|
|
68575
|
+
await this.login();
|
|
68576
|
+
}
|
|
68577
|
+
const res = await this.post(this.url("/door_state.fcgi"), {});
|
|
68578
|
+
return res.data;
|
|
68579
|
+
}
|
|
68580
|
+
async executeActions(actions) {
|
|
68581
|
+
if (!this.session) {
|
|
68582
|
+
await this.login();
|
|
68583
|
+
}
|
|
68584
|
+
const res = await this.post(this.url("/execute_actions.fcgi"), { actions });
|
|
68585
|
+
return res.data;
|
|
68586
|
+
}
|
|
68587
|
+
async getConfiguration(payload) {
|
|
68588
|
+
if (!this.session) {
|
|
68589
|
+
await this.login();
|
|
68590
|
+
}
|
|
68591
|
+
const res = await this.post(this.url("/get_configuration.fcgi"), payload);
|
|
68592
|
+
return res.data;
|
|
68593
|
+
}
|
|
68594
|
+
async setConfiguration(payload) {
|
|
68595
|
+
if (!this.session) {
|
|
68596
|
+
await this.login();
|
|
68597
|
+
}
|
|
68598
|
+
const res = await this.post(this.url("/set_configuration.fcgi"), payload);
|
|
68599
|
+
return res.data;
|
|
68600
|
+
}
|
|
68601
|
+
};
|
|
68602
|
+
function normalizeBatches(payload) {
|
|
68603
|
+
if (Array.isArray(payload?.objects)) {
|
|
68604
|
+
return payload.objects.filter((batch) => batch?.object && Array.isArray(batch?.values));
|
|
68605
|
+
}
|
|
68606
|
+
const batches = [];
|
|
68607
|
+
const mappings = [
|
|
68608
|
+
["users", "users"],
|
|
68609
|
+
["cards", "cards"],
|
|
68610
|
+
["qrcodes", "qrcodes"],
|
|
68611
|
+
["pins", "pins"]
|
|
68612
|
+
];
|
|
68613
|
+
mappings.forEach(([key, object]) => {
|
|
68614
|
+
if (Array.isArray(payload?.[key]) && payload[key].length) {
|
|
68615
|
+
batches.push({ object, values: payload[key] });
|
|
68616
|
+
}
|
|
68617
|
+
});
|
|
68618
|
+
return batches;
|
|
68619
|
+
}
|
|
68620
|
+
function firstValue(payload, keys) {
|
|
68621
|
+
for (const key of keys) {
|
|
68622
|
+
const value = payload?.[key];
|
|
68623
|
+
if (value !== void 0 && value !== null && value !== "") {
|
|
68624
|
+
return value;
|
|
68625
|
+
}
|
|
68626
|
+
}
|
|
68627
|
+
return void 0;
|
|
68628
|
+
}
|
|
68629
|
+
function extractIdentityKeys(payload) {
|
|
68630
|
+
const nested = payload?.user || payload?.person || payload?.data || {};
|
|
68631
|
+
const merged = { ...payload, ...nested };
|
|
68632
|
+
return {
|
|
68633
|
+
hidUserId: firstValue(merged, ["hidUserId", "hid_user_id", "user_id", "userId", "id", "user"]),
|
|
68634
|
+
registration: firstValue(merged, ["registration", "register", "employeeNo", "staffNo", "memberNo"]),
|
|
68635
|
+
cardNo: firstValue(merged, ["cardNo", "card_no", "card", "cardNumber", "value"])
|
|
68636
|
+
};
|
|
68637
|
+
}
|
|
68638
|
+
function useHidAmicoService() {
|
|
68639
|
+
const repo = useHidAmicoRepo();
|
|
68640
|
+
async function getActiveReader(id) {
|
|
68641
|
+
const reader = await repo.getById(id, { includePassword: true });
|
|
68642
|
+
if (reader.enabled === false || reader.status === "inactive" || reader.status === "deleted") {
|
|
68643
|
+
throw new import_node_server_utils258.BadRequestError("HID Amico reader is not active.");
|
|
68644
|
+
}
|
|
68645
|
+
return reader;
|
|
68646
|
+
}
|
|
68647
|
+
async function createReader(value) {
|
|
68648
|
+
return repo.add({
|
|
68649
|
+
...value,
|
|
68650
|
+
baseUrl: value.baseUrl.replace(/\/+$/, ""),
|
|
68651
|
+
password: encryptSecret(value.password)
|
|
68652
|
+
});
|
|
68653
|
+
}
|
|
68654
|
+
async function updateReader(id, value) {
|
|
68655
|
+
const payload = { ...value };
|
|
68656
|
+
if (payload.password) {
|
|
68657
|
+
payload.password = encryptSecret(payload.password);
|
|
68658
|
+
} else {
|
|
68659
|
+
delete payload.password;
|
|
68660
|
+
}
|
|
68661
|
+
return repo.updateById(id, payload);
|
|
68662
|
+
}
|
|
68663
|
+
async function listReaders(value) {
|
|
68664
|
+
return repo.list(value);
|
|
68665
|
+
}
|
|
68666
|
+
async function deleteReader(id) {
|
|
68667
|
+
return repo.markDeleted(id);
|
|
68668
|
+
}
|
|
68669
|
+
async function testReader(id) {
|
|
68670
|
+
const reader = await repo.getById(id, { includePassword: true });
|
|
68671
|
+
const client = new HidAmicoClient(reader);
|
|
68672
|
+
try {
|
|
68673
|
+
await client.login();
|
|
68674
|
+
const valid = await client.sessionIsValid();
|
|
68675
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date(), lastSyncMessage: "Connection test succeeded." });
|
|
68676
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "test", payload: { valid } });
|
|
68677
|
+
return { valid, message: "HID Amico connection test succeeded." };
|
|
68678
|
+
} catch (error) {
|
|
68679
|
+
await repo.updateById(id, {
|
|
68680
|
+
status: "offline",
|
|
68681
|
+
lastSyncAt: /* @__PURE__ */ new Date(),
|
|
68682
|
+
lastSyncStatus: "failed",
|
|
68683
|
+
lastSyncMessage: error.message
|
|
68684
|
+
});
|
|
68685
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "test_failed", payload: { message: error.message } });
|
|
68686
|
+
throw error;
|
|
68687
|
+
} finally {
|
|
68688
|
+
await client.logout();
|
|
68689
|
+
}
|
|
68690
|
+
}
|
|
68691
|
+
async function syncReader(id, payload) {
|
|
68692
|
+
const reader = await getActiveReader(id);
|
|
68693
|
+
const batches = normalizeBatches(payload);
|
|
68694
|
+
const client = new HidAmicoClient(reader);
|
|
68695
|
+
const results = [];
|
|
68696
|
+
await repo.updateById(id, { lastSyncStatus: "running", lastSyncMessage: "Sync started." });
|
|
68697
|
+
try {
|
|
68698
|
+
await client.login();
|
|
68699
|
+
for (const batch of batches) {
|
|
68700
|
+
const result = await client.createObjects(batch);
|
|
68701
|
+
results.push({ object: batch.object, count: batch.values.length, result });
|
|
68702
|
+
}
|
|
68703
|
+
const message = batches.length ? `Synced ${batches.length} HID object batch(es).` : "HID reader session verified. No sync payload was supplied.";
|
|
68704
|
+
await repo.updateById(id, {
|
|
68705
|
+
lastSeenAt: /* @__PURE__ */ new Date(),
|
|
68706
|
+
lastSyncAt: /* @__PURE__ */ new Date(),
|
|
68707
|
+
lastSyncStatus: "completed",
|
|
68708
|
+
lastSyncMessage: message
|
|
68709
|
+
});
|
|
68710
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "sync", payload: { message, results } });
|
|
68711
|
+
return { message, results };
|
|
68712
|
+
} catch (error) {
|
|
68713
|
+
await repo.updateById(id, {
|
|
68714
|
+
status: "offline",
|
|
68715
|
+
lastSyncAt: /* @__PURE__ */ new Date(),
|
|
68716
|
+
lastSyncStatus: "failed",
|
|
68717
|
+
lastSyncMessage: error.message
|
|
68718
|
+
});
|
|
68719
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "sync_failed", payload: { message: error.message } });
|
|
68720
|
+
throw error;
|
|
68721
|
+
} finally {
|
|
68722
|
+
await client.logout();
|
|
68723
|
+
}
|
|
68724
|
+
}
|
|
68725
|
+
async function receiveNotification(readerId, type, payload) {
|
|
68726
|
+
const reader = await repo.getById(readerId);
|
|
68727
|
+
const identityKeys = extractIdentityKeys(payload);
|
|
68728
|
+
const identity = await repo.findIdentity({
|
|
68729
|
+
reader: readerId,
|
|
68730
|
+
...identityKeys
|
|
68731
|
+
});
|
|
68732
|
+
const enrichedPayload = identity ? {
|
|
68733
|
+
...payload,
|
|
68734
|
+
identity: {
|
|
68735
|
+
_id: identity._id,
|
|
68736
|
+
type: identity.type,
|
|
68737
|
+
hidUserId: identity.hidUserId,
|
|
68738
|
+
registration: identity.registration,
|
|
68739
|
+
cardNo: identity.cardNo,
|
|
68740
|
+
person: identity.person,
|
|
68741
|
+
user: identity.user,
|
|
68742
|
+
member: identity.member,
|
|
68743
|
+
visitor: identity.visitor
|
|
68744
|
+
}
|
|
68745
|
+
} : {
|
|
68746
|
+
...payload,
|
|
68747
|
+
identity: null,
|
|
68748
|
+
identityLookup: identityKeys
|
|
68749
|
+
};
|
|
68750
|
+
await repo.updateById(readerId, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
68751
|
+
return repo.addEvent({
|
|
68752
|
+
reader: readerId,
|
|
68753
|
+
site: reader.site,
|
|
68754
|
+
type,
|
|
68755
|
+
payload: enrichedPayload,
|
|
68756
|
+
status: identity ? "processed" : "received"
|
|
68757
|
+
});
|
|
68758
|
+
}
|
|
68759
|
+
async function listLogs(value) {
|
|
68760
|
+
return repo.listEvents(value);
|
|
68761
|
+
}
|
|
68762
|
+
async function listIdentities(value) {
|
|
68763
|
+
return repo.listIdentities(value);
|
|
68764
|
+
}
|
|
68765
|
+
async function createIdentity(readerId, value) {
|
|
68766
|
+
const reader = await repo.getById(readerId);
|
|
68767
|
+
return repo.addIdentity({
|
|
68768
|
+
...value,
|
|
68769
|
+
reader: readerId,
|
|
68770
|
+
site: value.site || reader?.site?.toString()
|
|
68771
|
+
});
|
|
68772
|
+
}
|
|
68773
|
+
async function updateIdentity(identityId, value) {
|
|
68774
|
+
return repo.updateIdentity(identityId, value);
|
|
68775
|
+
}
|
|
68776
|
+
async function deleteIdentity(identityId) {
|
|
68777
|
+
return repo.deleteIdentity(identityId);
|
|
68778
|
+
}
|
|
68779
|
+
async function runObjectOperation(id, operation, payload) {
|
|
68780
|
+
const reader = await getActiveReader(id);
|
|
68781
|
+
const client = new HidAmicoClient(reader);
|
|
68782
|
+
try {
|
|
68783
|
+
await client.login();
|
|
68784
|
+
let result;
|
|
68785
|
+
if (operation === "load") {
|
|
68786
|
+
result = await client.loadObjects(payload);
|
|
68787
|
+
} else if (operation === "create") {
|
|
68788
|
+
result = await client.createObjects(payload);
|
|
68789
|
+
} else if (operation === "modify") {
|
|
68790
|
+
result = await client.modifyObjects(payload);
|
|
68791
|
+
} else {
|
|
68792
|
+
result = await client.destroyObjects(payload);
|
|
68793
|
+
}
|
|
68794
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
68795
|
+
await repo.addEvent({ reader: id, site: reader.site, type: `objects_${operation}`, payload: { request: payload, result } });
|
|
68796
|
+
return result;
|
|
68797
|
+
} catch (error) {
|
|
68798
|
+
await repo.addEvent({ reader: id, site: reader.site, type: `objects_${operation}_failed`, payload: { request: payload, message: error.message } });
|
|
68799
|
+
throw error;
|
|
68800
|
+
} finally {
|
|
68801
|
+
await client.logout();
|
|
68802
|
+
}
|
|
68803
|
+
}
|
|
68804
|
+
async function getUserImage(readerId, hidUserId) {
|
|
68805
|
+
const reader = await getActiveReader(readerId);
|
|
68806
|
+
const client = new HidAmicoClient(reader);
|
|
68807
|
+
try {
|
|
68808
|
+
await client.login();
|
|
68809
|
+
return await client.getUserImage(hidUserId);
|
|
68810
|
+
} finally {
|
|
68811
|
+
await client.logout();
|
|
68812
|
+
}
|
|
68813
|
+
}
|
|
68814
|
+
async function getDoorState(id) {
|
|
68815
|
+
const reader = await getActiveReader(id);
|
|
68816
|
+
const client = new HidAmicoClient(reader);
|
|
68817
|
+
try {
|
|
68818
|
+
await client.login();
|
|
68819
|
+
const state = await client.doorState();
|
|
68820
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
68821
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "door_state", payload: state });
|
|
68822
|
+
return state;
|
|
68823
|
+
} finally {
|
|
68824
|
+
await client.logout();
|
|
68825
|
+
}
|
|
68826
|
+
}
|
|
68827
|
+
async function executeActions(id, actions) {
|
|
68828
|
+
const reader = await getActiveReader(id);
|
|
68829
|
+
const client = new HidAmicoClient(reader);
|
|
68830
|
+
try {
|
|
68831
|
+
await client.login();
|
|
68832
|
+
const result = await client.executeActions(actions);
|
|
68833
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
68834
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "execute_actions", payload: { actions, result } });
|
|
68835
|
+
return result;
|
|
68836
|
+
} catch (error) {
|
|
68837
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "execute_actions_failed", payload: { actions, message: error.message } });
|
|
68838
|
+
throw error;
|
|
68839
|
+
} finally {
|
|
68840
|
+
await client.logout();
|
|
68841
|
+
}
|
|
68842
|
+
}
|
|
68843
|
+
async function getConfiguration(id, payload) {
|
|
68844
|
+
const reader = await getActiveReader(id);
|
|
68845
|
+
const client = new HidAmicoClient(reader);
|
|
68846
|
+
try {
|
|
68847
|
+
await client.login();
|
|
68848
|
+
const result = await client.getConfiguration(payload);
|
|
68849
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
68850
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "configuration", payload: { request: payload, result } });
|
|
68851
|
+
return result;
|
|
68852
|
+
} catch (error) {
|
|
68853
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "configuration_failed", payload: { request: payload, message: error.message } });
|
|
68854
|
+
throw error;
|
|
68855
|
+
} finally {
|
|
68856
|
+
await client.logout();
|
|
68857
|
+
}
|
|
68858
|
+
}
|
|
68859
|
+
async function setConfiguration(id, payload) {
|
|
68860
|
+
const reader = await getActiveReader(id);
|
|
68861
|
+
const client = new HidAmicoClient(reader);
|
|
68862
|
+
try {
|
|
68863
|
+
await client.login();
|
|
68864
|
+
const result = await client.setConfiguration(payload);
|
|
68865
|
+
await repo.updateById(id, { lastSeenAt: /* @__PURE__ */ new Date() });
|
|
68866
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "set_configuration", payload: { request: payload, result } });
|
|
68867
|
+
return result;
|
|
68868
|
+
} catch (error) {
|
|
68869
|
+
await repo.addEvent({ reader: id, site: reader.site, type: "set_configuration_failed", payload: { request: payload, message: error.message } });
|
|
68870
|
+
throw error;
|
|
68871
|
+
} finally {
|
|
68872
|
+
await client.logout();
|
|
68873
|
+
}
|
|
68874
|
+
}
|
|
68875
|
+
return {
|
|
68876
|
+
listReaders,
|
|
68877
|
+
createReader,
|
|
68878
|
+
updateReader,
|
|
68879
|
+
deleteReader,
|
|
68880
|
+
testReader,
|
|
68881
|
+
syncReader,
|
|
68882
|
+
receiveNotification,
|
|
68883
|
+
listLogs,
|
|
68884
|
+
listIdentities,
|
|
68885
|
+
createIdentity,
|
|
68886
|
+
updateIdentity,
|
|
68887
|
+
deleteIdentity,
|
|
68888
|
+
runObjectOperation,
|
|
68889
|
+
getUserImage,
|
|
68890
|
+
getDoorState,
|
|
68891
|
+
executeActions,
|
|
68892
|
+
getConfiguration,
|
|
68893
|
+
setConfiguration
|
|
68894
|
+
};
|
|
68895
|
+
}
|
|
68896
|
+
|
|
68897
|
+
// src/controllers/hid-amico.controller.ts
|
|
68898
|
+
var import_node_server_utils259 = require("@7365admin1/node-server-utils");
|
|
68899
|
+
function useHidAmicoController() {
|
|
68900
|
+
const service = useHidAmicoService();
|
|
68901
|
+
async function listReaders(req, res, next) {
|
|
68902
|
+
const { error, value } = schemaHidAmicoReaderListQuery.validate(req.query);
|
|
68903
|
+
if (error) {
|
|
68904
|
+
next(new import_node_server_utils259.BadRequestError(error.message));
|
|
68905
|
+
return;
|
|
68906
|
+
}
|
|
68907
|
+
try {
|
|
68908
|
+
res.json(await service.listReaders(value));
|
|
68909
|
+
} catch (error2) {
|
|
68910
|
+
next(error2);
|
|
68911
|
+
}
|
|
68912
|
+
}
|
|
68913
|
+
async function createReader(req, res, next) {
|
|
68914
|
+
const { error, value } = schemaHidAmicoReader.validate(req.body);
|
|
68915
|
+
if (error) {
|
|
68916
|
+
next(new import_node_server_utils259.BadRequestError(error.message));
|
|
68917
|
+
return;
|
|
68918
|
+
}
|
|
68919
|
+
try {
|
|
68920
|
+
res.status(201).json({ data: await service.createReader(value) });
|
|
68921
|
+
} catch (error2) {
|
|
68922
|
+
next(error2);
|
|
68923
|
+
}
|
|
68924
|
+
}
|
|
68925
|
+
async function updateReader(req, res, next) {
|
|
68926
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
68927
|
+
const body = schemaUpdateHidAmicoReader.validate(req.body);
|
|
68928
|
+
if (params.error || body.error) {
|
|
68929
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
|
|
68930
|
+
return;
|
|
68931
|
+
}
|
|
68932
|
+
try {
|
|
68933
|
+
res.json({ data: await service.updateReader(params.value.readerId, body.value) });
|
|
68934
|
+
} catch (error) {
|
|
68935
|
+
next(error);
|
|
68936
|
+
}
|
|
68937
|
+
}
|
|
68938
|
+
async function deleteReader(req, res, next) {
|
|
68939
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
68940
|
+
if (error) {
|
|
68941
|
+
next(new import_node_server_utils259.BadRequestError(error.message));
|
|
68942
|
+
return;
|
|
68943
|
+
}
|
|
68944
|
+
try {
|
|
68945
|
+
res.json({ data: await service.deleteReader(value.readerId), message: "HID Amico reader deleted." });
|
|
68946
|
+
} catch (error2) {
|
|
68947
|
+
next(error2);
|
|
68948
|
+
}
|
|
68949
|
+
}
|
|
68950
|
+
async function testReader(req, res, next) {
|
|
68951
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
68952
|
+
if (error) {
|
|
68953
|
+
next(new import_node_server_utils259.BadRequestError(error.message));
|
|
68954
|
+
return;
|
|
68955
|
+
}
|
|
68956
|
+
try {
|
|
68957
|
+
res.json({ data: await service.testReader(value.readerId) });
|
|
68958
|
+
} catch (error2) {
|
|
68959
|
+
next(error2);
|
|
68960
|
+
}
|
|
68961
|
+
}
|
|
68962
|
+
async function syncReader(req, res, next) {
|
|
68963
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
68964
|
+
const body = schemaHidAmicoSync.validate(req.body ?? {});
|
|
68965
|
+
if (params.error || body.error) {
|
|
68966
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
|
|
68967
|
+
return;
|
|
68968
|
+
}
|
|
68969
|
+
try {
|
|
68970
|
+
res.json({ data: await service.syncReader(params.value.readerId, body.value) });
|
|
68971
|
+
} catch (error) {
|
|
68972
|
+
next(error);
|
|
68973
|
+
}
|
|
68974
|
+
}
|
|
68975
|
+
async function listLogs(req, res, next) {
|
|
68976
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
68977
|
+
const query = schemaHidAmicoLogQuery.validate(req.query);
|
|
68978
|
+
if (params.error || query.error) {
|
|
68979
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || query.error?.message));
|
|
68980
|
+
return;
|
|
68981
|
+
}
|
|
68982
|
+
try {
|
|
68983
|
+
res.json(await service.listLogs({ reader: params.value.readerId, ...query.value }));
|
|
68984
|
+
} catch (error) {
|
|
68985
|
+
next(error);
|
|
68986
|
+
}
|
|
68987
|
+
}
|
|
68988
|
+
async function listIdentities(req, res, next) {
|
|
68989
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
68990
|
+
const query = schemaHidAmicoIdentityQuery.validate(req.query);
|
|
68991
|
+
if (params.error || query.error) {
|
|
68992
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || query.error?.message));
|
|
68993
|
+
return;
|
|
68994
|
+
}
|
|
68995
|
+
try {
|
|
68996
|
+
res.json(await service.listIdentities({ reader: params.value.readerId, ...query.value }));
|
|
68997
|
+
} catch (error) {
|
|
68998
|
+
next(error);
|
|
68999
|
+
}
|
|
69000
|
+
}
|
|
69001
|
+
async function createIdentity(req, res, next) {
|
|
69002
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69003
|
+
if (params.error) {
|
|
69004
|
+
next(new import_node_server_utils259.BadRequestError(params.error.message));
|
|
69005
|
+
return;
|
|
69006
|
+
}
|
|
69007
|
+
try {
|
|
69008
|
+
const body = schemaCreateHidAmicoIdentity.validate(req.body);
|
|
69009
|
+
if (body.error) {
|
|
69010
|
+
next(new import_node_server_utils259.BadRequestError(body.error.message));
|
|
69011
|
+
return;
|
|
69012
|
+
}
|
|
69013
|
+
res.status(201).json({ data: await service.createIdentity(params.value.readerId, body.value) });
|
|
69014
|
+
} catch (error) {
|
|
69015
|
+
next(error);
|
|
69016
|
+
}
|
|
69017
|
+
}
|
|
69018
|
+
async function updateIdentity(req, res, next) {
|
|
69019
|
+
const params = schemaHidAmicoIdentityIdParams.validate(req.params);
|
|
69020
|
+
const body = schemaUpdateHidAmicoIdentity.validate(req.body ?? {});
|
|
69021
|
+
if (params.error || body.error) {
|
|
69022
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
|
|
69023
|
+
return;
|
|
69024
|
+
}
|
|
69025
|
+
try {
|
|
69026
|
+
res.json({ data: await service.updateIdentity(params.value.identityId, body.value) });
|
|
69027
|
+
} catch (error) {
|
|
69028
|
+
next(error);
|
|
69029
|
+
}
|
|
69030
|
+
}
|
|
69031
|
+
async function deleteIdentity(req, res, next) {
|
|
69032
|
+
const { error, value } = schemaHidAmicoIdentityIdParams.validate(req.params);
|
|
69033
|
+
if (error) {
|
|
69034
|
+
next(new import_node_server_utils259.BadRequestError(error.message));
|
|
69035
|
+
return;
|
|
69036
|
+
}
|
|
69037
|
+
try {
|
|
69038
|
+
res.json({ data: await service.deleteIdentity(value.identityId), message: "HID Amico identity deleted." });
|
|
69039
|
+
} catch (error2) {
|
|
69040
|
+
next(error2);
|
|
69041
|
+
}
|
|
69042
|
+
}
|
|
69043
|
+
async function receiveNotification(req, res, next) {
|
|
69044
|
+
const validation = schemaHidAmicoNotificationParams.validate(req.params);
|
|
69045
|
+
if (validation.error) {
|
|
69046
|
+
next(new import_node_server_utils259.BadRequestError(validation.error.message));
|
|
69047
|
+
return;
|
|
69048
|
+
}
|
|
69049
|
+
try {
|
|
69050
|
+
const event = await service.receiveNotification(
|
|
69051
|
+
validation.value.readerId,
|
|
69052
|
+
validation.value.type,
|
|
69053
|
+
req.body ?? {}
|
|
69054
|
+
);
|
|
69055
|
+
res.status(202).json({ data: event });
|
|
69056
|
+
} catch (error) {
|
|
69057
|
+
next(error);
|
|
69058
|
+
}
|
|
69059
|
+
}
|
|
69060
|
+
async function getDoorState(req, res, next) {
|
|
69061
|
+
const { error, value } = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69062
|
+
if (error) {
|
|
69063
|
+
next(new import_node_server_utils259.BadRequestError(error.message));
|
|
69064
|
+
return;
|
|
69065
|
+
}
|
|
69066
|
+
try {
|
|
69067
|
+
res.json({ data: await service.getDoorState(value.readerId) });
|
|
69068
|
+
} catch (error2) {
|
|
69069
|
+
next(error2);
|
|
69070
|
+
}
|
|
69071
|
+
}
|
|
69072
|
+
async function getUserImage(req, res, next) {
|
|
69073
|
+
const { error, value } = schemaHidAmicoUserImageParams.validate(req.params);
|
|
69074
|
+
if (error) {
|
|
69075
|
+
next(new import_node_server_utils259.BadRequestError(error.message));
|
|
69076
|
+
return;
|
|
69077
|
+
}
|
|
69078
|
+
try {
|
|
69079
|
+
const image = await service.getUserImage(value.readerId, value.hidUserId);
|
|
69080
|
+
res.json({ data: image });
|
|
69081
|
+
} catch (error2) {
|
|
69082
|
+
next(error2);
|
|
69083
|
+
}
|
|
69084
|
+
}
|
|
69085
|
+
async function executeActions(req, res, next) {
|
|
69086
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69087
|
+
const body = schemaHidAmicoExecuteActions.validate(req.body ?? {});
|
|
69088
|
+
if (params.error || body.error) {
|
|
69089
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
|
|
69090
|
+
return;
|
|
69091
|
+
}
|
|
69092
|
+
try {
|
|
69093
|
+
res.json({ data: await service.executeActions(params.value.readerId, body.value.actions) });
|
|
69094
|
+
} catch (error) {
|
|
69095
|
+
next(error);
|
|
69096
|
+
}
|
|
69097
|
+
}
|
|
69098
|
+
async function getConfiguration(req, res, next) {
|
|
69099
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69100
|
+
const body = schemaHidAmicoConfiguration.validate(req.body ?? {});
|
|
69101
|
+
if (params.error || body.error) {
|
|
69102
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
|
|
69103
|
+
return;
|
|
69104
|
+
}
|
|
69105
|
+
try {
|
|
69106
|
+
res.json({ data: await service.getConfiguration(params.value.readerId, body.value) });
|
|
69107
|
+
} catch (error) {
|
|
69108
|
+
next(error);
|
|
69109
|
+
}
|
|
69110
|
+
}
|
|
69111
|
+
async function setConfiguration(req, res, next) {
|
|
69112
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69113
|
+
const body = schemaHidAmicoSetConfiguration.validate(req.body ?? {});
|
|
69114
|
+
if (params.error || body.error) {
|
|
69115
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
|
|
69116
|
+
return;
|
|
69117
|
+
}
|
|
69118
|
+
try {
|
|
69119
|
+
res.json({ data: await service.setConfiguration(params.value.readerId, body.value) });
|
|
69120
|
+
} catch (error) {
|
|
69121
|
+
next(error);
|
|
69122
|
+
}
|
|
69123
|
+
}
|
|
69124
|
+
async function runObjectOperation(req, res, next) {
|
|
69125
|
+
const params = schemaHidAmicoReaderIdParams.validate(req.params);
|
|
69126
|
+
const body = schemaHidAmicoObjectOperation.validate(req.body ?? {});
|
|
69127
|
+
if (params.error || body.error) {
|
|
69128
|
+
next(new import_node_server_utils259.BadRequestError(params.error?.message || body.error?.message));
|
|
69129
|
+
return;
|
|
69130
|
+
}
|
|
69131
|
+
const { operation, ...payload } = body.value;
|
|
69132
|
+
if (operation === "create" && !Array.isArray(payload.values)) {
|
|
69133
|
+
next(new import_node_server_utils259.BadRequestError("values array is required for HID object create operations."));
|
|
69134
|
+
return;
|
|
69135
|
+
}
|
|
69136
|
+
if (operation === "modify" && (!payload.values || Array.isArray(payload.values) || !payload.where)) {
|
|
69137
|
+
next(new import_node_server_utils259.BadRequestError("values object and where are required for HID object modify operations."));
|
|
69138
|
+
return;
|
|
69139
|
+
}
|
|
69140
|
+
if (operation === "destroy" && !payload.where) {
|
|
69141
|
+
next(new import_node_server_utils259.BadRequestError("where is required for HID object destroy operations."));
|
|
69142
|
+
return;
|
|
69143
|
+
}
|
|
69144
|
+
try {
|
|
69145
|
+
res.json({ data: await service.runObjectOperation(params.value.readerId, operation, payload) });
|
|
69146
|
+
} catch (error) {
|
|
69147
|
+
next(error);
|
|
69148
|
+
}
|
|
69149
|
+
}
|
|
69150
|
+
return {
|
|
69151
|
+
listReaders,
|
|
69152
|
+
createReader,
|
|
69153
|
+
updateReader,
|
|
69154
|
+
deleteReader,
|
|
69155
|
+
testReader,
|
|
69156
|
+
syncReader,
|
|
69157
|
+
listLogs,
|
|
69158
|
+
listIdentities,
|
|
69159
|
+
createIdentity,
|
|
69160
|
+
updateIdentity,
|
|
69161
|
+
deleteIdentity,
|
|
69162
|
+
receiveNotification,
|
|
69163
|
+
getUserImage,
|
|
69164
|
+
getDoorState,
|
|
69165
|
+
executeActions,
|
|
69166
|
+
getConfiguration,
|
|
69167
|
+
setConfiguration,
|
|
69168
|
+
runObjectOperation
|
|
69169
|
+
};
|
|
69170
|
+
}
|
|
67471
69171
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67472
69172
|
0 && (module.exports = {
|
|
67473
69173
|
ANPRMode,
|
|
67474
69174
|
AccessTypeProps,
|
|
67475
69175
|
AppServiceType,
|
|
69176
|
+
BidStatus,
|
|
69177
|
+
BidType,
|
|
67476
69178
|
BuildingLevelStatus,
|
|
67477
69179
|
BuildingStatus,
|
|
67478
69180
|
BulletinOrder,
|
|
@@ -67504,6 +69206,7 @@ function useBuildingLevelController() {
|
|
|
67504
69206
|
MAddress,
|
|
67505
69207
|
MAttendance,
|
|
67506
69208
|
MAttendanceSettings,
|
|
69209
|
+
MBidPreloved,
|
|
67507
69210
|
MBillingConfiguration,
|
|
67508
69211
|
MBillingItem,
|
|
67509
69212
|
MBuilding,
|
|
@@ -67524,6 +69227,9 @@ function useBuildingLevelController() {
|
|
|
67524
69227
|
MFile,
|
|
67525
69228
|
MFormEntry,
|
|
67526
69229
|
MGuestManagement,
|
|
69230
|
+
MHidAmicoEvent,
|
|
69231
|
+
MHidAmicoIdentity,
|
|
69232
|
+
MHidAmicoReader,
|
|
67527
69233
|
MIncidentReport,
|
|
67528
69234
|
MManpowerDesignations,
|
|
67529
69235
|
MManpowerMonitoring,
|
|
@@ -67643,6 +69349,7 @@ function useBuildingLevelController() {
|
|
|
67643
69349
|
schema,
|
|
67644
69350
|
schemaApprovedBy,
|
|
67645
69351
|
schemaApprover,
|
|
69352
|
+
schemaBidPreloved,
|
|
67646
69353
|
schemaBilling,
|
|
67647
69354
|
schemaBillingConfiguration,
|
|
67648
69355
|
schemaBillingItem,
|
|
@@ -67655,6 +69362,7 @@ function useBuildingLevelController() {
|
|
|
67655
69362
|
schemaCategoryPreloved,
|
|
67656
69363
|
schemaChannelPreloved,
|
|
67657
69364
|
schemaChatPreloved,
|
|
69365
|
+
schemaCreateHidAmicoIdentity,
|
|
67658
69366
|
schemaCustomerSite,
|
|
67659
69367
|
schemaDocumentManagement,
|
|
67660
69368
|
schemaEntryPassSettings,
|
|
@@ -67662,6 +69370,21 @@ function useBuildingLevelController() {
|
|
|
67662
69370
|
schemaFiles,
|
|
67663
69371
|
schemaFormEntry,
|
|
67664
69372
|
schemaGuestManagement,
|
|
69373
|
+
schemaHidAmicoConfiguration,
|
|
69374
|
+
schemaHidAmicoEvent,
|
|
69375
|
+
schemaHidAmicoExecuteActions,
|
|
69376
|
+
schemaHidAmicoIdentity,
|
|
69377
|
+
schemaHidAmicoIdentityIdParams,
|
|
69378
|
+
schemaHidAmicoIdentityQuery,
|
|
69379
|
+
schemaHidAmicoLogQuery,
|
|
69380
|
+
schemaHidAmicoNotificationParams,
|
|
69381
|
+
schemaHidAmicoObjectOperation,
|
|
69382
|
+
schemaHidAmicoReader,
|
|
69383
|
+
schemaHidAmicoReaderIdParams,
|
|
69384
|
+
schemaHidAmicoReaderListQuery,
|
|
69385
|
+
schemaHidAmicoSetConfiguration,
|
|
69386
|
+
schemaHidAmicoSync,
|
|
69387
|
+
schemaHidAmicoUserImageParams,
|
|
67665
69388
|
schemaIncidentReport,
|
|
67666
69389
|
schemaMultipleDocumentManagement,
|
|
67667
69390
|
schemaNfcPatrolLog,
|
|
@@ -67689,6 +69412,7 @@ function useBuildingLevelController() {
|
|
|
67689
69412
|
schemaStatementOfAccount,
|
|
67690
69413
|
schemaSubcategoryPreloved,
|
|
67691
69414
|
schemaUnitBilling,
|
|
69415
|
+
schemaUpdateBidPreloved,
|
|
67692
69416
|
schemaUpdateBuildingLevel,
|
|
67693
69417
|
schemaUpdateBulletinBoard,
|
|
67694
69418
|
schemaUpdateBulletinVideo,
|
|
@@ -67699,6 +69423,8 @@ function useBuildingLevelController() {
|
|
|
67699
69423
|
schemaUpdateEventManagement,
|
|
67700
69424
|
schemaUpdateFormEntry,
|
|
67701
69425
|
schemaUpdateGuestManagement,
|
|
69426
|
+
schemaUpdateHidAmicoIdentity,
|
|
69427
|
+
schemaUpdateHidAmicoReader,
|
|
67702
69428
|
schemaUpdateIncidentReport,
|
|
67703
69429
|
schemaUpdateOccurrenceBook,
|
|
67704
69430
|
schemaUpdateOccurrenceEntry,
|
|
@@ -67744,6 +69470,8 @@ function useBuildingLevelController() {
|
|
|
67744
69470
|
useAuthControllerV2,
|
|
67745
69471
|
useAuthService,
|
|
67746
69472
|
useAuthServiceV2,
|
|
69473
|
+
useBidPrelovedController,
|
|
69474
|
+
useBidPrelovedRepo,
|
|
67747
69475
|
useBuildingController,
|
|
67748
69476
|
useBuildingLevelController,
|
|
67749
69477
|
useBuildingLevelRepo,
|
|
@@ -67766,6 +69494,7 @@ function useBuildingLevelController() {
|
|
|
67766
69494
|
useChatController,
|
|
67767
69495
|
useChatPrelovedController,
|
|
67768
69496
|
useChatPrelovedRepo,
|
|
69497
|
+
useChatPrelovedService,
|
|
67769
69498
|
useChatRepo,
|
|
67770
69499
|
useCounterModel,
|
|
67771
69500
|
useCounterRepo,
|
|
@@ -67796,6 +69525,9 @@ function useBuildingLevelController() {
|
|
|
67796
69525
|
useGuestManagementController,
|
|
67797
69526
|
useGuestManagementRepo,
|
|
67798
69527
|
useGuestManagementService,
|
|
69528
|
+
useHidAmicoController,
|
|
69529
|
+
useHidAmicoRepo,
|
|
69530
|
+
useHidAmicoService,
|
|
67799
69531
|
useHrmLabsAttendanceCtrl,
|
|
67800
69532
|
useHrmLabsAttendanceSrvc,
|
|
67801
69533
|
useIncidentReportController,
|