@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/dist/index.mjs CHANGED
@@ -29301,7 +29301,9 @@ function useVerificationController() {
29301
29301
  name: Joi28.string().optional().allow("", null),
29302
29302
  org: Joi28.string().hex().optional().allow("", null),
29303
29303
  siteId: Joi28.string().hex().optional().allow("", null),
29304
- siteName: Joi28.string().optional().allow("", null)
29304
+ siteName: Joi28.string().optional().allow("", null),
29305
+ // The modules Seven365 gives a NEW client (the console's Invite Client).
29306
+ modules: modulesSchema.optional()
29305
29307
  });
29306
29308
  const { error, value } = validation.validate(payload);
29307
29309
  if (error) {
@@ -29316,12 +29318,24 @@ function useVerificationController() {
29316
29318
  const {
29317
29319
  email,
29318
29320
  app,
29319
- role,
29320
29321
  name,
29321
29322
  org,
29322
29323
  siteId,
29323
- siteName
29324
+ siteName,
29325
+ modules
29324
29326
  } = value;
29327
+ const newClient = !org && !app.includes(PLATFORM_STAFF_MEMBER_TYPE);
29328
+ const role = newClient ? "" : value.role;
29329
+ let clientModules;
29330
+ if (modules !== void 0) {
29331
+ const invitedBy = await requireConsolePermission(req, "organizations");
29332
+ if (!newClient || app.length !== 1) {
29333
+ throw new BadRequestError51(
29334
+ "Modules can only be chosen when inviting a new client, one application at a time."
29335
+ );
29336
+ }
29337
+ clientModules = { modules: normaliseModules(modules), invitedBy };
29338
+ }
29325
29339
  await requireInviteReach(req, org, app, role);
29326
29340
  const verificationIds = await _createSimpleUserInvite({
29327
29341
  email,
@@ -29331,7 +29345,8 @@ function useVerificationController() {
29331
29345
  name,
29332
29346
  org,
29333
29347
  siteId,
29334
- siteName
29348
+ siteName,
29349
+ ...clientModules
29335
29350
  }
29336
29351
  });
29337
29352
  const responseBody = {
@@ -31136,6 +31151,7 @@ function useOrgController() {
31136
31151
  let invitedFrom = null;
31137
31152
  let invitedRole = null;
31138
31153
  let inviteAlreadyComplete = false;
31154
+ let invitedModules = null;
31139
31155
  let self = null;
31140
31156
  if (inviteId) {
31141
31157
  const [invite, caller] = await Promise.all([
@@ -31148,6 +31164,11 @@ function useOrgController() {
31148
31164
  invitedFrom = String(invite._id);
31149
31165
  invitedRole = invite.metadata?.role ? String(invite.metadata.role) : null;
31150
31166
  inviteAlreadyComplete = invite.status === "complete" /* COMPLETE */;
31167
+ const chosen = normaliseModules(invite.metadata?.modules);
31168
+ const invitedBy = invite.metadata?.invitedBy;
31169
+ if (chosen.length && invitedBy && invite.metadata?.app === body.nature) {
31170
+ invitedModules = { modules: chosen, invitedBy: String(invitedBy) };
31171
+ }
31151
31172
  } else {
31152
31173
  logger41.log({
31153
31174
  level: "warn",
@@ -31163,7 +31184,29 @@ function useOrgController() {
31163
31184
  );
31164
31185
  }
31165
31186
  }
31166
- const _id = await _add({ ...body, createdBy, invitedFrom, invitedRole });
31187
+ const _id = await _add({
31188
+ ...body,
31189
+ createdBy,
31190
+ invitedFrom,
31191
+ invitedRole,
31192
+ ...invitedModules && { modules: invitedModules.modules }
31193
+ });
31194
+ if (invitedModules) {
31195
+ await recordConsoleAction({
31196
+ action: "client.modules-changed" /* CLIENT_MODULES_CHANGED */,
31197
+ actor: invitedModules.invitedBy,
31198
+ org: String(_id),
31199
+ target: String(_id).toLowerCase(),
31200
+ targetType: "organization" /* ORGANIZATION */,
31201
+ after: pickAuditFields("client.modules-changed" /* CLIENT_MODULES_CHANGED */, {
31202
+ modules: invitedModules.modules.join(", "),
31203
+ moduleCount: invitedModules.modules.length,
31204
+ gateListHash: moduleListHash(invitedModules.modules),
31205
+ acknowledged: false,
31206
+ impactMemberCount: 0
31207
+ })
31208
+ });
31209
+ }
31167
31210
  if (invitedFrom && !inviteAlreadyComplete) {
31168
31211
  try {
31169
31212
  await useVerificationRepoV2().updateStatusById(