@7365admin1/core 3.73.1 → 3.74.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/dist/index.mjs CHANGED
@@ -23571,6 +23571,44 @@ function useMemberController() {
23571
23571
  // src/controllers/verification.controller.ts
23572
23572
  import { BadRequestError as BadRequestError51, logger as logger38 } from "@7365admin1/node-server-utils";
23573
23573
  import Joi28 from "joi";
23574
+
23575
+ // src/utils/resident-app-modules.util.ts
23576
+ var RESIDENT_APP_NATURES = Object.freeze([
23577
+ "property_management_agency",
23578
+ "real_estate_developer"
23579
+ ]);
23580
+ function effectiveResidentAppModules(orgModules, siteModules) {
23581
+ const org = asModules(orgModules);
23582
+ const site = asModules(siteModules);
23583
+ const effective = {};
23584
+ for (const key of residentAppModuleKeys) {
23585
+ effective[key] = org[key] !== false && site[key] !== false;
23586
+ }
23587
+ return effective;
23588
+ }
23589
+ function residentAppModulesAboveCeiling(orgModules, requested, stored) {
23590
+ const org = asModules(orgModules);
23591
+ const wanted = asModules(requested);
23592
+ const had = asModules(stored);
23593
+ return residentAppModuleKeys.filter(
23594
+ (key) => org[key] === false && wanted[key] === true && had[key] === false
23595
+ );
23596
+ }
23597
+ function residentAppModulesAboveCeilingMessage(rejected) {
23598
+ 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.`;
23599
+ }
23600
+ function withoutDerivedSiteMetadata(metadata) {
23601
+ if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
23602
+ return metadata;
23603
+ }
23604
+ const { residentAppModulesEffective: _derived, ...stored } = metadata;
23605
+ return stored;
23606
+ }
23607
+ function asModules(value) {
23608
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
23609
+ }
23610
+
23611
+ // src/controllers/verification.controller.ts
23574
23612
  var withoutEmail = (payload) => JSON.stringify({ ...payload, email: payload?.email ? "[redacted]" : void 0 });
23575
23613
  function callerId2(req) {
23576
23614
  const user = req.user;
@@ -23652,7 +23690,11 @@ function useVerificationController() {
23652
23690
  modules: modulesSchema.optional(),
23653
23691
  // The new client owner's permissions in that application, chosen with
23654
23692
  // the modules (owner, 2026-09-15). Only accepted together with modules.
23655
- permissions: permissionsSchema.optional()
23693
+ permissions: permissionsSchema.optional(),
23694
+ // The Service365 resident app switches for a Property Management (or
23695
+ // real estate developer) client, same shape the Client details card saves
23696
+ // to `organizations.residentAppModules`. Only accepted with modules.
23697
+ residentAppModules: residentAppModulesSchema.optional()
23656
23698
  });
23657
23699
  const { error, value } = validation.validate(payload);
23658
23700
  if (error) {
@@ -23672,7 +23714,8 @@ function useVerificationController() {
23672
23714
  siteId,
23673
23715
  siteName,
23674
23716
  modules,
23675
- permissions
23717
+ permissions,
23718
+ residentAppModules
23676
23719
  } = value;
23677
23720
  const newClient = !org && !app.includes(PLATFORM_STAFF_MEMBER_TYPE);
23678
23721
  const role = newClient ? "" : value.role;
@@ -23702,6 +23745,14 @@ function useVerificationController() {
23702
23745
  }
23703
23746
  clientModules.permissions = chosen;
23704
23747
  }
23748
+ if (residentAppModules !== void 0) {
23749
+ if (!clientModules || !RESIDENT_APP_NATURES.includes(app[0])) {
23750
+ throw new BadRequestError51(
23751
+ "Service365 resident app modules can only be chosen with the modules of a new Property Management client."
23752
+ );
23753
+ }
23754
+ clientModules.residentAppModules = residentAppModules;
23755
+ }
23705
23756
  await requireInviteReach(req, org, app, role);
23706
23757
  const verificationIds = await _createSimpleUserInvite({
23707
23758
  email,
@@ -25535,10 +25586,12 @@ function useOrgController() {
25535
25586
  const invitedBy = invite.metadata?.invitedBy;
25536
25587
  if (chosen.length && invitedBy && invite.metadata?.app === body.nature) {
25537
25588
  const permissions = clientInviteOwnerPermissionsOn() ? normalisePermissions(invite.metadata?.permissions) : [];
25589
+ const residentApp = RESIDENT_APP_NATURES.includes(body.nature) ? residentAppModulesSchema.validate(invite.metadata?.residentAppModules) : null;
25538
25590
  invitedModules = {
25539
25591
  modules: chosen,
25540
25592
  invitedBy: String(invitedBy),
25541
- permissions: permissionsOutsideModules(permissions, chosen).length ? [] : permissions
25593
+ permissions: permissionsOutsideModules(permissions, chosen).length ? [] : permissions,
25594
+ ...residentApp?.value && !residentApp.error ? { residentAppModules: residentApp.value } : {}
25542
25595
  };
25543
25596
  }
25544
25597
  } else {
@@ -25561,7 +25614,10 @@ function useOrgController() {
25561
25614
  createdBy,
25562
25615
  invitedFrom,
25563
25616
  invitedRole,
25564
- ...invitedModules && { modules: invitedModules.modules }
25617
+ ...invitedModules && { modules: invitedModules.modules },
25618
+ ...invitedModules?.residentAppModules && {
25619
+ residentAppModules: invitedModules.residentAppModules
25620
+ }
25565
25621
  });
25566
25622
  if (invitedModules) {
25567
25623
  await recordConsoleAction({
@@ -25575,7 +25631,10 @@ function useOrgController() {
25575
25631
  moduleCount: invitedModules.modules.length,
25576
25632
  gateListHash: moduleListHash(invitedModules.modules),
25577
25633
  acknowledged: false,
25578
- impactMemberCount: 0
25634
+ impactMemberCount: 0,
25635
+ ...invitedModules.residentAppModules && {
25636
+ residentAppModulesOff: Object.keys(invitedModules.residentAppModules).filter((key) => invitedModules.residentAppModules[key] === false).join(", ")
25637
+ }
25579
25638
  })
25580
25639
  });
25581
25640
  }
@@ -34301,40 +34360,6 @@ import {
34301
34360
  UnauthorizedError as UnauthorizedError14,
34302
34361
  useAtlas as useAtlas56
34303
34362
  } from "@7365admin1/node-server-utils";
34304
-
34305
- // src/utils/resident-app-modules.util.ts
34306
- function effectiveResidentAppModules(orgModules, siteModules) {
34307
- const org = asModules(orgModules);
34308
- const site = asModules(siteModules);
34309
- const effective = {};
34310
- for (const key of residentAppModuleKeys) {
34311
- effective[key] = org[key] !== false && site[key] !== false;
34312
- }
34313
- return effective;
34314
- }
34315
- function residentAppModulesAboveCeiling(orgModules, requested, stored) {
34316
- const org = asModules(orgModules);
34317
- const wanted = asModules(requested);
34318
- const had = asModules(stored);
34319
- return residentAppModuleKeys.filter(
34320
- (key) => org[key] === false && wanted[key] === true && had[key] === false
34321
- );
34322
- }
34323
- function residentAppModulesAboveCeilingMessage(rejected) {
34324
- 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.`;
34325
- }
34326
- function withoutDerivedSiteMetadata(metadata) {
34327
- if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
34328
- return metadata;
34329
- }
34330
- const { residentAppModulesEffective: _derived, ...stored } = metadata;
34331
- return stored;
34332
- }
34333
- function asModules(value) {
34334
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
34335
- }
34336
-
34337
- // src/controllers/site.controller.ts
34338
34363
  import Joi51 from "joi";
34339
34364
  import { ObjectId as ObjectId74 } from "mongodb";
34340
34365
  async function requireSiteWrite(req, siteId) {