@7365admin1/core 3.27.0 → 3.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +55 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4887,8 +4887,8 @@ declare function UseAccessManagementRepo(): {
|
|
|
4887
4887
|
_id: string;
|
|
4888
4888
|
cardNo: string;
|
|
4889
4889
|
}[];
|
|
4890
|
-
visitorId: string;
|
|
4891
4890
|
acm_url: string;
|
|
4891
|
+
user: Record<string, unknown>;
|
|
4892
4892
|
}) => Promise<{
|
|
4893
4893
|
visitorId: ObjectId | undefined;
|
|
4894
4894
|
registeredAt: Date;
|
|
@@ -5055,6 +5055,7 @@ declare function useNfcPatrolTagController(): {
|
|
|
5055
5055
|
add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
5056
5056
|
getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
5057
5057
|
updateNfcPatrolTagBySite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
5058
|
+
getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
5058
5059
|
};
|
|
5059
5060
|
|
|
5060
5061
|
declare function useNfcPatrolTagRepo(): {
|
|
@@ -6062,6 +6063,7 @@ declare function useNfcPatrolLogController(): {
|
|
|
6062
6063
|
add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6063
6064
|
getAllBySite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6064
6065
|
completeCheckpoint: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6066
|
+
getLog: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
6065
6067
|
};
|
|
6066
6068
|
|
|
6067
6069
|
declare function useAddressRepo(): {
|
package/dist/index.js
CHANGED
|
@@ -48014,7 +48014,8 @@ function UseAccessManagementRepo() {
|
|
|
48014
48014
|
remarks: 1,
|
|
48015
48015
|
requestDate: 1,
|
|
48016
48016
|
createdAt: 1,
|
|
48017
|
-
updatedAt: 1
|
|
48017
|
+
updatedAt: 1,
|
|
48018
|
+
userCred: 1
|
|
48018
48019
|
}
|
|
48019
48020
|
}
|
|
48020
48021
|
);
|
|
@@ -48310,7 +48311,7 @@ function UseAccessManagementRepo() {
|
|
|
48310
48311
|
const unitId = new import_mongodb97.ObjectId(params.unitId);
|
|
48311
48312
|
const quantity = params.quantity;
|
|
48312
48313
|
const type = params.type;
|
|
48313
|
-
const visitorId = new import_mongodb97.ObjectId(params.visitorId);
|
|
48314
|
+
const visitorId = new import_mongodb97.ObjectId(params.user?.visitorId);
|
|
48314
48315
|
const nfcCards = params.nfcCards;
|
|
48315
48316
|
const acm_url = params.acm_url;
|
|
48316
48317
|
let cards = [];
|
|
@@ -48357,7 +48358,10 @@ function UseAccessManagementRepo() {
|
|
|
48357
48358
|
const updateFields = {
|
|
48358
48359
|
staffNo: `STAFF-${cardId.toString().slice(-10)}`,
|
|
48359
48360
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
48360
|
-
userId: updatedVisitor
|
|
48361
|
+
userId: updatedVisitor,
|
|
48362
|
+
userCred: {
|
|
48363
|
+
...params.user
|
|
48364
|
+
}
|
|
48361
48365
|
};
|
|
48362
48366
|
if (type === "QRCODE" /* QR */) {
|
|
48363
48367
|
updateFields.one_time = true;
|
|
@@ -50363,7 +50367,7 @@ function useAccessManagementController() {
|
|
|
50363
50367
|
quantity = 1,
|
|
50364
50368
|
type,
|
|
50365
50369
|
nfcCards,
|
|
50366
|
-
|
|
50370
|
+
user,
|
|
50367
50371
|
acm_url
|
|
50368
50372
|
} = req.body;
|
|
50369
50373
|
const schema2 = import_joi87.default.object({
|
|
@@ -50378,7 +50382,7 @@ function useAccessManagementController() {
|
|
|
50378
50382
|
})
|
|
50379
50383
|
).required(),
|
|
50380
50384
|
acm_url: import_joi87.default.string().required(),
|
|
50381
|
-
|
|
50385
|
+
user: import_joi87.default.object().optional().allow("", null)
|
|
50382
50386
|
});
|
|
50383
50387
|
const { error } = schema2.validate({
|
|
50384
50388
|
site,
|
|
@@ -50386,7 +50390,7 @@ function useAccessManagementController() {
|
|
|
50386
50390
|
quantity,
|
|
50387
50391
|
type,
|
|
50388
50392
|
nfcCards,
|
|
50389
|
-
|
|
50393
|
+
user,
|
|
50390
50394
|
acm_url
|
|
50391
50395
|
});
|
|
50392
50396
|
if (error) {
|
|
@@ -50398,7 +50402,7 @@ function useAccessManagementController() {
|
|
|
50398
50402
|
quantity,
|
|
50399
50403
|
type,
|
|
50400
50404
|
nfcCards,
|
|
50401
|
-
|
|
50405
|
+
user,
|
|
50402
50406
|
acm_url
|
|
50403
50407
|
});
|
|
50404
50408
|
return res.status(200).json({ message: "Success", data: result });
|
|
@@ -51111,7 +51115,7 @@ var import_node_server_utils163 = require("@7365admin1/node-server-utils");
|
|
|
51111
51115
|
var import_joi89 = __toESM(require("joi"));
|
|
51112
51116
|
function useNfcPatrolTagController() {
|
|
51113
51117
|
const { add: _add, updateNfcPatrolTagBySite: _updateNfcPatrolTagBySite } = useNfcPatrolTagService();
|
|
51114
|
-
const { getAll: _getAll } = useNfcPatrolTagRepo();
|
|
51118
|
+
const { getAll: _getAll, getById: _getById } = useNfcPatrolTagRepo();
|
|
51115
51119
|
async function add(req, res, next) {
|
|
51116
51120
|
const cookies = req.headers.cookie ? req.headers.cookie.split(";").map((cookie) => cookie.trim().split("=")).reduce(
|
|
51117
51121
|
(acc, [key, value2]) => ({ ...acc, [key]: value2 }),
|
|
@@ -51201,10 +51205,34 @@ function useNfcPatrolTagController() {
|
|
|
51201
51205
|
return;
|
|
51202
51206
|
}
|
|
51203
51207
|
}
|
|
51208
|
+
async function getById(req, res, next) {
|
|
51209
|
+
const validation = import_joi89.default.object({
|
|
51210
|
+
id: import_joi89.default.string().length(24).hex().required()
|
|
51211
|
+
});
|
|
51212
|
+
const { error } = validation.validate(req.params, {
|
|
51213
|
+
abortEarly: false
|
|
51214
|
+
});
|
|
51215
|
+
if (error) {
|
|
51216
|
+
const messages = error.details.map((d) => d.message).join(", ");
|
|
51217
|
+
import_node_server_utils163.logger.log({ level: "error", message: messages });
|
|
51218
|
+
next(new import_node_server_utils163.BadRequestError(messages));
|
|
51219
|
+
return;
|
|
51220
|
+
}
|
|
51221
|
+
try {
|
|
51222
|
+
const tag = await _getById(req.params.id);
|
|
51223
|
+
res.status(200).json(tag);
|
|
51224
|
+
return;
|
|
51225
|
+
} catch (error2) {
|
|
51226
|
+
import_node_server_utils163.logger.log({ level: "error", message: error2.message });
|
|
51227
|
+
next(error2);
|
|
51228
|
+
return;
|
|
51229
|
+
}
|
|
51230
|
+
}
|
|
51204
51231
|
return {
|
|
51205
51232
|
add,
|
|
51206
51233
|
getAll,
|
|
51207
|
-
updateNfcPatrolTagBySite
|
|
51234
|
+
updateNfcPatrolTagBySite,
|
|
51235
|
+
getById
|
|
51208
51236
|
};
|
|
51209
51237
|
}
|
|
51210
51238
|
|
|
@@ -57894,14 +57922,6 @@ function useNfcPatrolLogService() {
|
|
|
57894
57922
|
if (!log) {
|
|
57895
57923
|
throw new import_node_server_utils199.BadRequestError("Patrol Log not found.");
|
|
57896
57924
|
}
|
|
57897
|
-
const route = await routeRepo.getById(log.route._id);
|
|
57898
|
-
if (!route) {
|
|
57899
|
-
throw new import_node_server_utils199.BadRequestError("Route not found.");
|
|
57900
|
-
}
|
|
57901
|
-
const checkpoint = route.checkPoints[payload.checkpointIndex];
|
|
57902
|
-
if (!checkpoint) {
|
|
57903
|
-
throw new import_node_server_utils199.BadRequestError("Checkpoint not found.");
|
|
57904
|
-
}
|
|
57905
57925
|
const logCheckpoint = log.checkPoints[payload.checkpointIndex];
|
|
57906
57926
|
if (!logCheckpoint) {
|
|
57907
57927
|
throw new import_node_server_utils199.BadRequestError("Checkpoint log not found.");
|
|
@@ -57913,11 +57933,14 @@ function useNfcPatrolLogService() {
|
|
|
57913
57933
|
throw new import_node_server_utils199.BadRequestError("Skipped remarks are required.");
|
|
57914
57934
|
}
|
|
57915
57935
|
if (payload.action === "complete") {
|
|
57916
|
-
const tag = await tagRepo.getById(
|
|
57917
|
-
if (!tag
|
|
57936
|
+
const tag = await tagRepo.getById(logCheckpoint.nfcTag_id);
|
|
57937
|
+
if (!tag) {
|
|
57938
|
+
throw new import_node_server_utils199.BadRequestError("NFC Tag not found.");
|
|
57939
|
+
}
|
|
57940
|
+
if (!tag.tagID) {
|
|
57918
57941
|
throw new import_node_server_utils199.BadRequestError("NFC Tag has not been configured.");
|
|
57919
57942
|
}
|
|
57920
|
-
if (tag.
|
|
57943
|
+
if (tag.tagID !== payload.uid) {
|
|
57921
57944
|
throw new import_node_server_utils199.BadRequestError("Invalid NFC Tag.");
|
|
57922
57945
|
}
|
|
57923
57946
|
}
|
|
@@ -57933,7 +57956,7 @@ function useNfcPatrolLogService() {
|
|
|
57933
57956
|
await session?.abortTransaction();
|
|
57934
57957
|
throw error;
|
|
57935
57958
|
} finally {
|
|
57936
|
-
session?.endSession();
|
|
57959
|
+
await session?.endSession();
|
|
57937
57960
|
}
|
|
57938
57961
|
}
|
|
57939
57962
|
return {
|
|
@@ -57947,7 +57970,7 @@ var import_node_server_utils200 = require("@7365admin1/node-server-utils");
|
|
|
57947
57970
|
var import_joi111 = __toESM(require("joi"));
|
|
57948
57971
|
function useNfcPatrolLogController() {
|
|
57949
57972
|
const { add: _add, completeCheckpoint: _completeCheckpoint } = useNfcPatrolLogService();
|
|
57950
|
-
const { getAllBySite: _getAllBySite } = useNfcPatrolLogRepo();
|
|
57973
|
+
const { getAllBySite: _getAllBySite, getById: _getById } = useNfcPatrolLogRepo();
|
|
57951
57974
|
async function add(req, res, next) {
|
|
57952
57975
|
const payload = { ...req.body };
|
|
57953
57976
|
try {
|
|
@@ -58026,10 +58049,19 @@ function useNfcPatrolLogController() {
|
|
|
58026
58049
|
next(error);
|
|
58027
58050
|
}
|
|
58028
58051
|
}
|
|
58052
|
+
async function getLog(req, res, next) {
|
|
58053
|
+
try {
|
|
58054
|
+
const log = await _getById(req.params.id);
|
|
58055
|
+
res.json(log);
|
|
58056
|
+
} catch (error) {
|
|
58057
|
+
next(error);
|
|
58058
|
+
}
|
|
58059
|
+
}
|
|
58029
58060
|
return {
|
|
58030
58061
|
add,
|
|
58031
58062
|
getAllBySite,
|
|
58032
|
-
completeCheckpoint
|
|
58063
|
+
completeCheckpoint,
|
|
58064
|
+
getLog
|
|
58033
58065
|
};
|
|
58034
58066
|
}
|
|
58035
58067
|
|