@7365admin1/core 3.48.1-staging.148 → 3.48.1-staging.149
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/dist/index.d.ts +7 -0
- package/dist/index.js +50 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -4890,6 +4890,12 @@ type TPatrolLog = {
|
|
|
4890
4890
|
cameras: Array<logCamera>;
|
|
4891
4891
|
status: Array<string>;
|
|
4892
4892
|
incidentReport: incidentReport;
|
|
4893
|
+
/**
|
|
4894
|
+
* The user who created the log. Stored as a reference only — the name is
|
|
4895
|
+
* resolved from `users` at read time, so a renamed account shows its current
|
|
4896
|
+
* name rather than whatever it was called when the log was filed.
|
|
4897
|
+
*/
|
|
4898
|
+
createdBy?: string | ObjectId | null;
|
|
4893
4899
|
platform?: string;
|
|
4894
4900
|
createdAt?: Date | string;
|
|
4895
4901
|
updatedAt?: Date | string;
|
|
@@ -4910,6 +4916,7 @@ declare function MPatrolLog(value: TPatrolLog): {
|
|
|
4910
4916
|
status: string[];
|
|
4911
4917
|
route: string | ObjectId | undefined;
|
|
4912
4918
|
incidentReport: incidentReport;
|
|
4919
|
+
createdBy: string | ObjectId | null;
|
|
4913
4920
|
platForm: string;
|
|
4914
4921
|
createdAt: string | Date;
|
|
4915
4922
|
updatedAt: string | Date;
|
package/dist/index.js
CHANGED
|
@@ -52384,6 +52384,9 @@ var schemaPatrolLog = import_joi75.default.object({
|
|
|
52384
52384
|
cameras: import_joi75.default.array().items(schemeLogCamera).required(),
|
|
52385
52385
|
status: import_joi75.default.array().items(import_joi75.default.string().valid("complete", "late", "incomplete")).required(),
|
|
52386
52386
|
incidentReport: incidentReportLog,
|
|
52387
|
+
// Optional: existing clients do not send it, and requiring it would reject
|
|
52388
|
+
// every patrol log currently being posted.
|
|
52389
|
+
createdBy: import_joi75.default.string().hex().length(24).optional().allow(null, ""),
|
|
52387
52390
|
platform: import_joi75.default.string().valid("web", "mobile").optional().allow(null, ""),
|
|
52388
52391
|
createdAt: import_joi75.default.date().optional(),
|
|
52389
52392
|
updatedAt: import_joi75.default.date().optional(),
|
|
@@ -52442,6 +52445,13 @@ function MPatrolLog(value) {
|
|
|
52442
52445
|
throw new import_node_server_utils151.BadRequestError("Invalid incident report id format");
|
|
52443
52446
|
}
|
|
52444
52447
|
}
|
|
52448
|
+
if (value.createdBy && typeof value.createdBy === "string") {
|
|
52449
|
+
try {
|
|
52450
|
+
value.createdBy = new import_mongodb93.ObjectId(value.createdBy);
|
|
52451
|
+
} catch {
|
|
52452
|
+
throw new import_node_server_utils151.BadRequestError("Invalid createdBy id format");
|
|
52453
|
+
}
|
|
52454
|
+
}
|
|
52445
52455
|
return {
|
|
52446
52456
|
_id: value._id ?? new import_mongodb93.ObjectId(),
|
|
52447
52457
|
site: value.site,
|
|
@@ -52453,6 +52463,7 @@ function MPatrolLog(value) {
|
|
|
52453
52463
|
status: value.status ?? [],
|
|
52454
52464
|
route: value.route,
|
|
52455
52465
|
incidentReport: value.incidentReport,
|
|
52466
|
+
createdBy: value.createdBy ?? null,
|
|
52456
52467
|
platForm: value.platform ?? "",
|
|
52457
52468
|
createdAt: value.createdAt ?? /* @__PURE__ */ new Date(),
|
|
52458
52469
|
updatedAt: value.updatedAt ?? "",
|
|
@@ -52621,7 +52632,45 @@ function usePatrolLogRepo() {
|
|
|
52621
52632
|
},
|
|
52622
52633
|
{ $sort: sort },
|
|
52623
52634
|
{ $skip: page * limit },
|
|
52624
|
-
{ $limit: limit }
|
|
52635
|
+
{ $limit: limit },
|
|
52636
|
+
// Both lookups sit after $limit on purpose: they are projection only,
|
|
52637
|
+
// nothing above filters or sorts on them, so they run for the page
|
|
52638
|
+
// being returned rather than for the whole collection.
|
|
52639
|
+
{
|
|
52640
|
+
$lookup: {
|
|
52641
|
+
from: "users",
|
|
52642
|
+
localField: "createdBy",
|
|
52643
|
+
foreignField: "_id",
|
|
52644
|
+
// Name only. The users collection holds password hashes and session
|
|
52645
|
+
// fields, none of which belong in a patrol log response.
|
|
52646
|
+
pipeline: [{ $project: { _id: 1, name: 1 } }],
|
|
52647
|
+
as: "createdByData"
|
|
52648
|
+
}
|
|
52649
|
+
},
|
|
52650
|
+
{
|
|
52651
|
+
$unwind: { path: "$createdByData", preserveNullAndEmptyArrays: true }
|
|
52652
|
+
},
|
|
52653
|
+
{
|
|
52654
|
+
$lookup: {
|
|
52655
|
+
from: "patrol.route",
|
|
52656
|
+
localField: "route",
|
|
52657
|
+
foreignField: "_id",
|
|
52658
|
+
pipeline: [{ $project: { _id: 1, repeat: 1 } }],
|
|
52659
|
+
as: "routeData"
|
|
52660
|
+
}
|
|
52661
|
+
},
|
|
52662
|
+
{ $unwind: { path: "$routeData", preserveNullAndEmptyArrays: true } },
|
|
52663
|
+
{
|
|
52664
|
+
// Flattened to match the `approvedByName` shape used elsewhere.
|
|
52665
|
+
// `repeat` is read live rather than snapshotted on the log: it is the
|
|
52666
|
+
// route's current configuration, so editing a route must change what
|
|
52667
|
+
// the list shows.
|
|
52668
|
+
$addFields: {
|
|
52669
|
+
createdByName: "$createdByData.name",
|
|
52670
|
+
repeat: "$routeData.repeat"
|
|
52671
|
+
}
|
|
52672
|
+
},
|
|
52673
|
+
{ $project: { createdByData: 0, routeData: 0 } }
|
|
52625
52674
|
];
|
|
52626
52675
|
const countPipeline = [
|
|
52627
52676
|
{
|