@7365admin1/core 3.68.3 → 3.69.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @iservice365/core
2
2
 
3
+ ## 3.69.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d2cf85f: Invite Client: Seven365 staff can choose a new client's modules (`modules` on `POST /api/auth/invite/user`, console `organizations` permission). Onboarding from that invitation stores the list on the organisation and records the save row that makes the module gate enforce it. A new-client invitation no longer carries a shared template role, so the owner holds the organisation's own seeded owner role.
8
+
3
9
  ## 3.68.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -11166,6 +11166,8 @@ type TVerificationMetadataV2 = {
11166
11166
  invitedByName?: string;
11167
11167
  /** True when the sender was a property management company — those need approval. */
11168
11168
  invitedByPropertyManagement?: boolean;
11169
+ /** A new client's modules, chosen by Seven365 on Invite Client. */
11170
+ modules?: string[];
11169
11171
  };
11170
11172
  /**
11171
11173
  * The one-time code an invitee types to prove they own the mailbox, held on the
package/dist/index.js CHANGED
@@ -29890,7 +29890,9 @@ function useVerificationController() {
29890
29890
  name: import_joi28.default.string().optional().allow("", null),
29891
29891
  org: import_joi28.default.string().hex().optional().allow("", null),
29892
29892
  siteId: import_joi28.default.string().hex().optional().allow("", null),
29893
- siteName: import_joi28.default.string().optional().allow("", null)
29893
+ siteName: import_joi28.default.string().optional().allow("", null),
29894
+ // The modules Seven365 gives a NEW client (the console's Invite Client).
29895
+ modules: modulesSchema.optional()
29894
29896
  });
29895
29897
  const { error, value } = validation.validate(payload);
29896
29898
  if (error) {
@@ -29905,12 +29907,24 @@ function useVerificationController() {
29905
29907
  const {
29906
29908
  email,
29907
29909
  app,
29908
- role,
29909
29910
  name,
29910
29911
  org,
29911
29912
  siteId,
29912
- siteName
29913
+ siteName,
29914
+ modules
29913
29915
  } = value;
29916
+ const newClient = !org && !app.includes(PLATFORM_STAFF_MEMBER_TYPE);
29917
+ const role = newClient ? "" : value.role;
29918
+ let clientModules;
29919
+ if (modules !== void 0) {
29920
+ const invitedBy = await requireConsolePermission(req, "organizations");
29921
+ if (!newClient || app.length !== 1) {
29922
+ throw new import_node_server_utils66.BadRequestError(
29923
+ "Modules can only be chosen when inviting a new client, one application at a time."
29924
+ );
29925
+ }
29926
+ clientModules = { modules: normaliseModules(modules), invitedBy };
29927
+ }
29914
29928
  await requireInviteReach(req, org, app, role);
29915
29929
  const verificationIds = await _createSimpleUserInvite({
29916
29930
  email,
@@ -29920,7 +29934,8 @@ function useVerificationController() {
29920
29934
  name,
29921
29935
  org,
29922
29936
  siteId,
29923
- siteName
29937
+ siteName,
29938
+ ...clientModules
29924
29939
  }
29925
29940
  });
29926
29941
  const responseBody = {
@@ -31708,6 +31723,7 @@ function useOrgController() {
31708
31723
  let invitedFrom = null;
31709
31724
  let invitedRole = null;
31710
31725
  let inviteAlreadyComplete = false;
31726
+ let invitedModules = null;
31711
31727
  let self = null;
31712
31728
  if (inviteId) {
31713
31729
  const [invite, caller] = await Promise.all([
@@ -31720,6 +31736,11 @@ function useOrgController() {
31720
31736
  invitedFrom = String(invite._id);
31721
31737
  invitedRole = invite.metadata?.role ? String(invite.metadata.role) : null;
31722
31738
  inviteAlreadyComplete = invite.status === "complete" /* COMPLETE */;
31739
+ const chosen = normaliseModules(invite.metadata?.modules);
31740
+ const invitedBy = invite.metadata?.invitedBy;
31741
+ if (chosen.length && invitedBy && invite.metadata?.app === body.nature) {
31742
+ invitedModules = { modules: chosen, invitedBy: String(invitedBy) };
31743
+ }
31723
31744
  } else {
31724
31745
  import_node_server_utils71.logger.log({
31725
31746
  level: "warn",
@@ -31735,7 +31756,29 @@ function useOrgController() {
31735
31756
  );
31736
31757
  }
31737
31758
  }
31738
- const _id = await _add({ ...body, createdBy, invitedFrom, invitedRole });
31759
+ const _id = await _add({
31760
+ ...body,
31761
+ createdBy,
31762
+ invitedFrom,
31763
+ invitedRole,
31764
+ ...invitedModules && { modules: invitedModules.modules }
31765
+ });
31766
+ if (invitedModules) {
31767
+ await recordConsoleAction({
31768
+ action: "client.modules-changed" /* CLIENT_MODULES_CHANGED */,
31769
+ actor: invitedModules.invitedBy,
31770
+ org: String(_id),
31771
+ target: String(_id).toLowerCase(),
31772
+ targetType: "organization" /* ORGANIZATION */,
31773
+ after: pickAuditFields("client.modules-changed" /* CLIENT_MODULES_CHANGED */, {
31774
+ modules: invitedModules.modules.join(", "),
31775
+ moduleCount: invitedModules.modules.length,
31776
+ gateListHash: moduleListHash(invitedModules.modules),
31777
+ acknowledged: false,
31778
+ impactMemberCount: 0
31779
+ })
31780
+ });
31781
+ }
31739
31782
  if (invitedFrom && !inviteAlreadyComplete) {
31740
31783
  try {
31741
31784
  await useVerificationRepoV2().updateStatusById(