@7365admin1/core 3.64.3-staging.286 → 3.64.3-staging.287

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,16 @@
1
+ ---
2
+ "@7365admin1/core": patch
3
+ ---
4
+
5
+ Stop refusing Site Settings saves that send back `metadata.residentAppModulesEffective`.
6
+
7
+ `GET /api/sites/:id` attaches the derived `residentAppModulesEffective` to
8
+ `metadata` on every read, and the Site Settings screens save by sending the
9
+ metadata they read straight back. `updateSiteSchema` does not allow that key, so
10
+ `PATCH /api/sites/id/:id` refused the whole save with "is not allowed" — the
11
+ resident-app configuration panel, the HID QR code pass and the HID face-reader
12
+ toggle all failed.
13
+
14
+ `updateById` now drops the derived key before validating. It is never stored and
15
+ is recomputed on the next read, so nothing is lost; every stored key, including
16
+ `residentAppModules`, is validated and saved exactly as before.
package/dist/index.js CHANGED
@@ -38517,6 +38517,13 @@ function residentAppModulesAboveCeiling(orgModules, requested) {
38517
38517
  function residentAppModulesAboveCeilingMessage(rejected) {
38518
38518
  return `This client has not been given ${rejected.join(", ")} in the resident app, so a site cannot switch it on. Ask Seven365 to add it to the organisation first.`;
38519
38519
  }
38520
+ function withoutDerivedSiteMetadata(metadata) {
38521
+ if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
38522
+ return metadata;
38523
+ }
38524
+ const { residentAppModulesEffective: _derived, ...stored } = metadata;
38525
+ return stored;
38526
+ }
38520
38527
  function asModules(value) {
38521
38528
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
38522
38529
  }
@@ -38704,8 +38711,9 @@ function useSiteController() {
38704
38711
  }
38705
38712
  async function updateById(req, res, next) {
38706
38713
  try {
38714
+ const body = req.body?.metadata ? { ...req.body, metadata: withoutDerivedSiteMetadata(req.body.metadata) } : req.body;
38707
38715
  const { error, value } = updateSiteSchema.validate(
38708
- { _id: req.params.id, ...req.body },
38716
+ { _id: req.params.id, ...body },
38709
38717
  { abortEarly: false }
38710
38718
  );
38711
38719
  if (error) {