@7365admin1/core 3.48.1-staging.197 → 3.48.1-staging.199

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.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Stop the every-minute manpower-sites sync from deleting the whole catalogue when the HRM Labs lookup returns nothing.
@@ -0,0 +1,5 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Scope the patrol log email route to its estate. `POST /api/patrol-logs/email` carried `requireAuth` and nothing more and the controller held no authorization identifier, so any signed-in account on the platform could name another client's site and that site's patrol log ids and have the report emailed — to a list of up to 25 addresses of their own choosing, from the platform's sending address. The service's own log-belongs-to-site check is internal consistency, not reach: name the other estate's site and its own logs and the two agree. Reach is now decided from the session, on the site named in the request body, before anything is read, recorded, rendered or sent. `createdBy` — the audit row for who emailed patrol logs out of the system — is taken from the session rather than from the request body.
package/dist/index.d.ts CHANGED
@@ -9256,7 +9256,7 @@ declare function useManpowerSitesRepo(): {
9256
9256
 
9257
9257
  declare function useManpowerSitesSrvc(): {
9258
9258
  createManpowerSites: (payload: string) => Promise<string>;
9259
- checkManpowerSites: () => Promise<string>;
9259
+ checkManpowerSites: () => Promise<"Manpower Sites Unchanged - No Sites Returned" | "Manpower Sites Updated Successfully">;
9260
9260
  };
9261
9261
 
9262
9262
  declare function useManpowerSitesCtrl(): {
package/dist/index.js CHANGED
@@ -53606,9 +53606,12 @@ var schemaSendPatrolEmail = import_joi77.default.object({
53606
53606
  "string.pattern.base": '"url" must be a root-relative path, for example "/org/site/patrol-logs/report?ids=..."'
53607
53607
  }),
53608
53608
  site: import_joi77.default.string().hex().length(24).required(),
53609
+ // Pinned from the session by the controller, never taken from the request.
53610
+ // `name` allows "" because it is denormalised from the account and an account
53611
+ // may hold none - the same shape `schemaPatrolEmailCreatedBy` already stores.
53609
53612
  createdBy: import_joi77.default.object({
53610
53613
  _id: import_joi77.default.string().hex().length(24).required(),
53611
- name: import_joi77.default.string().trim().max(200).required()
53614
+ name: import_joi77.default.string().trim().max(200).required().allow("")
53612
53615
  }).required()
53613
53616
  });
53614
53617
  function toObjectId15(value, label) {
@@ -54049,10 +54052,15 @@ function usePatrolEmailService() {
54049
54052
  var import_node_server_utils159 = require("@7365admin1/node-server-utils");
54050
54053
  function usePatrolEmailController() {
54051
54054
  const { send: _send } = usePatrolEmailService();
54055
+ async function requirePatrolEmailReach(req, site) {
54056
+ await requireSiteReach(req, site);
54057
+ }
54052
54058
  async function send2(req, res, next) {
54053
- const { error, value } = schemaSendPatrolEmail.validate(req.body, {
54054
- abortEarly: false
54055
- });
54059
+ const actor = await resolveInviteActor(callerId(req));
54060
+ const { error, value } = schemaSendPatrolEmail.validate(
54061
+ { ...req.body, createdBy: { _id: actor.id, name: actor.name } },
54062
+ { abortEarly: false }
54063
+ );
54056
54064
  if (error) {
54057
54065
  const messages = error.details.map((d) => d.message).join(", ");
54058
54066
  import_node_server_utils159.logger.log({ level: "error", message: messages });
@@ -54060,6 +54068,7 @@ function usePatrolEmailController() {
54060
54068
  return;
54061
54069
  }
54062
54070
  try {
54071
+ await requirePatrolEmailReach(req, value.site);
54063
54072
  const cookieHeader = req.headers.cookie;
54064
54073
  const data = await _send({
54065
54074
  site: value.site,
@@ -54075,7 +54084,6 @@ function usePatrolEmailController() {
54075
54084
  res.status(201).json({ message: "success", data });
54076
54085
  return;
54077
54086
  } catch (err) {
54078
- console.log("err", err);
54079
54087
  import_node_server_utils159.logger.log({ level: "error", message: `${err.message}` });
54080
54088
  next(err);
54081
54089
  return;
@@ -78980,6 +78988,12 @@ function useManpowerSitesSrvc() {
78980
78988
  const hrmLabsSites = await manpowerMonitoringRepo.getAllSites(
78981
78989
  serviceProviderId
78982
78990
  );
78991
+ if (!Array.isArray(hrmLabsSites) || hrmLabsSites.length === 0) {
78992
+ import_node_server_utils252.logger.error(
78993
+ `checkManpowerSites: HRMLabs returned no sites for service provider ${serviceProviderId} - skipping sync, nothing added or deleted.`
78994
+ );
78995
+ return "Manpower Sites Unchanged - No Sites Returned";
78996
+ }
78983
78997
  const manpowerSites = await manpowerSitesRepo.getAllManpowerSites({
78984
78998
  page: 1,
78985
78999
  limit: 1e3,