@pnp/cli-microsoft365 10.5.0-beta.094447f → 10.5.0-beta.31351d1

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.
Files changed (72) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +58 -2
  4. package/dist/m365/booking/commands/business/business-get.js +0 -3
  5. package/dist/m365/commands/login.js +3 -0
  6. package/dist/m365/entra/commands/user/user-guest-add.js +0 -3
  7. package/dist/m365/flow/commands/environment/environment-get.js +0 -3
  8. package/dist/m365/flow/commands/flow-get.js +0 -3
  9. package/dist/m365/flow/commands/run/run-get.js +0 -3
  10. package/dist/m365/pa/commands/app/app-get.js +0 -3
  11. package/dist/m365/pa/commands/environment/environment-get.js +0 -3
  12. package/dist/m365/planner/commands/bucket/bucket-add.js +0 -3
  13. package/dist/m365/planner/commands/plan/plan-add.js +0 -3
  14. package/dist/m365/planner/commands/plan/plan-get.js +0 -3
  15. package/dist/m365/planner/commands/plan/plan-set.js +0 -3
  16. package/dist/m365/planner/commands/task/task-checklistitem-add.js +0 -3
  17. package/dist/m365/pp/commands/aibuildermodel/aibuildermodel-get.js +0 -3
  18. package/dist/m365/pp/commands/card/card-get.js +0 -3
  19. package/dist/m365/pp/commands/copilot/copilot-get.js +0 -3
  20. package/dist/m365/pp/commands/dataverse/dataverse-table-get.js +0 -3
  21. package/dist/m365/pp/commands/environment/environment-get.js +0 -3
  22. package/dist/m365/pp/commands/solution/solution-get.js +0 -3
  23. package/dist/m365/pp/commands/solution/solution-publisher-get.js +0 -3
  24. package/dist/m365/pp/commands/website/website-get.js +0 -3
  25. package/dist/m365/spo/commands/group/group-member-add.js +0 -3
  26. package/dist/m365/spo/commands/homesite/homesite-add.js +66 -0
  27. package/dist/m365/spo/commands/page/page-copy.js +0 -3
  28. package/dist/m365/spo/commands/page/page-get.js +0 -3
  29. package/dist/m365/spo/commands/sitedesign/sitedesign-run-status-get.js +0 -3
  30. package/dist/m365/spo/commands.js +1 -0
  31. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +0 -3
  32. package/dist/m365/todo/commands/list/list-get.js +0 -3
  33. package/dist/m365/todo/commands/task/task-get.js +0 -3
  34. package/dist/m365/viva/commands/engage/engage-community-user-add.js +113 -0
  35. package/dist/m365/viva/commands/engage/engage-community-user-remove.js +107 -0
  36. package/dist/m365/viva/commands/engage/engage-message-add.js +0 -3
  37. package/dist/m365/viva/commands/engage/engage-message-get.js +0 -3
  38. package/dist/m365/viva/commands/engage/engage-user-get.js +0 -3
  39. package/dist/m365/viva/commands.js +2 -0
  40. package/docs/docs/cmd/booking/business/business-get.mdx +13 -0
  41. package/docs/docs/cmd/entra/user/user-guest-add.mdx +11 -0
  42. package/docs/docs/cmd/flow/environment/environment-get.mdx +2 -0
  43. package/docs/docs/cmd/flow/flow-get.mdx +2 -0
  44. package/docs/docs/cmd/flow/run/run-get.mdx +17 -13
  45. package/docs/docs/cmd/login.mdx +9 -1
  46. package/docs/docs/cmd/pa/app/app-get.mdx +8 -2
  47. package/docs/docs/cmd/pa/environment/environment-get.mdx +5 -3
  48. package/docs/docs/cmd/planner/plan/plan-add.mdx +2 -0
  49. package/docs/docs/cmd/planner/plan/plan-get.mdx +8 -4
  50. package/docs/docs/cmd/planner/plan/plan-set.mdx +2 -0
  51. package/docs/docs/cmd/planner/task/task-checklistitem-add.mdx +6 -3
  52. package/docs/docs/cmd/pp/aibuildermodel/aibuildermodel-get.mdx +12 -3
  53. package/docs/docs/cmd/pp/card/card-get.mdx +36 -5
  54. package/docs/docs/cmd/pp/copilot/copilot-get.mdx +41 -5
  55. package/docs/docs/cmd/pp/dataverse/dataverse-table-get.mdx +19 -4
  56. package/docs/docs/cmd/pp/environment/environment-get.mdx +5 -2
  57. package/docs/docs/cmd/pp/solution/solution-get.mdx +12 -7
  58. package/docs/docs/cmd/pp/solution/solution-publisher-get.mdx +12 -7
  59. package/docs/docs/cmd/pp/website/website-get.mdx +22 -4
  60. package/docs/docs/cmd/spo/group/group-member-add.mdx +12 -3
  61. package/docs/docs/cmd/spo/homesite/homesite-add.mdx +124 -0
  62. package/docs/docs/cmd/spo/page/page-copy.mdx +30 -4
  63. package/docs/docs/cmd/spo/page/page-get.mdx +44 -5
  64. package/docs/docs/cmd/spo/sitedesign/sitedesign-run-status-get.mdx +7 -0
  65. package/docs/docs/cmd/todo/list/list-get.mdx +7 -4
  66. package/docs/docs/cmd/todo/task/task-get.mdx +7 -2
  67. package/docs/docs/cmd/viva/engage/engage-community-user-add.mdx +67 -0
  68. package/docs/docs/cmd/viva/engage/engage-community-user-remove.mdx +55 -0
  69. package/docs/docs/cmd/viva/engage/engage-message-add.mdx +37 -12
  70. package/docs/docs/cmd/viva/engage/engage-message-get.mdx +27 -13
  71. package/docs/docs/cmd/viva/engage/engage-user-get.mdx +50 -8
  72. package/package.json +1 -1
package/dist/Auth.js CHANGED
@@ -53,6 +53,7 @@ export var AuthType;
53
53
  AuthType["Password"] = "password";
54
54
  AuthType["Certificate"] = "certificate";
55
55
  AuthType["Identity"] = "identity";
56
+ AuthType["FederatedIdentity"] = "federatedIdentity";
56
57
  AuthType["Browser"] = "browser";
57
58
  AuthType["Secret"] = "secret";
58
59
  })(AuthType || (AuthType = {}));
@@ -153,7 +154,8 @@ export class Auth {
153
154
  // wasn't specified
154
155
  if (this.connection.authType !== AuthType.Certificate &&
155
156
  this.connection.authType !== AuthType.Secret &&
156
- this.connection.authType !== AuthType.Identity) {
157
+ this.connection.authType !== AuthType.Identity &&
158
+ this.connection.authType !== AuthType.FederatedIdentity) {
157
159
  this.clientApplication = await this.getPublicClient(logger, debug);
158
160
  if (this.clientApplication) {
159
161
  const accounts = await this.clientApplication.getTokenCache().getAllAccounts();
@@ -177,6 +179,9 @@ export class Auth {
177
179
  case AuthType.Identity:
178
180
  getTokenPromise = this.ensureAccessTokenWithIdentity.bind(this);
179
181
  break;
182
+ case AuthType.FederatedIdentity:
183
+ getTokenPromise = this.ensureAccessTokenWithFederatedIdentity.bind(this);
184
+ break;
180
185
  case AuthType.Browser:
181
186
  getTokenPromise = this.ensureAccessTokenWithBrowser.bind(this);
182
187
  break;
@@ -552,6 +557,56 @@ export class Auth {
552
557
  }
553
558
  }
554
559
  }
560
+ async ensureAccessTokenWithFederatedIdentity(resource, logger, debug) {
561
+ if (debug) {
562
+ await logger.logToStderr('Trying to retrieve access token using federated identity...');
563
+ }
564
+ if (!process.env.ACTIONS_ID_TOKEN_REQUEST_URL || !process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN) {
565
+ throw new CommandError('Federated identity is currently only supported in GitHub Actions.');
566
+ }
567
+ if (debug) {
568
+ await logger.logToStderr('ACTIONS_ID_TOKEN_REQUEST_URL and ACTIONS_ID_TOKEN_REQUEST_TOKEN env variables found. The context is GitHub Actions...');
569
+ }
570
+ const federationToken = await this.getFederationTokenFromGithub(logger, debug);
571
+ const queryParams = [
572
+ 'grant_type=client_credentials',
573
+ `scope=${encodeURIComponent(`${resource}/.default`)}`,
574
+ `client_id=${this.connection.appId}`,
575
+ `client_assertion_type=${encodeURIComponent('urn:ietf:params:oauth:client-assertion-type:jwt-bearer')}`,
576
+ `client_assertion=${federationToken}`
577
+ ];
578
+ const requestOptions = {
579
+ url: `https://login.microsoftonline.com/${this.connection.tenant}/oauth2/v2.0/token`,
580
+ headers: {
581
+ accept: 'application/json',
582
+ 'x-anonymous': true,
583
+ 'Content-Type': 'application/x-www-form-urlencoded'
584
+ },
585
+ data: queryParams.join('&'),
586
+ responseType: 'json'
587
+ };
588
+ const accessTokenResponse = await request.post(requestOptions);
589
+ return {
590
+ accessToken: accessTokenResponse.access_token,
591
+ expiresOn: new Date(parseInt(accessTokenResponse.expires_on) * 1000)
592
+ };
593
+ }
594
+ async getFederationTokenFromGithub(logger, debug) {
595
+ if (debug) {
596
+ await logger.logToStderr('Retrieving GitHub federation token...');
597
+ }
598
+ const requestOptions = {
599
+ url: `${process.env.ACTIONS_ID_TOKEN_REQUEST_URL}&audience=${encodeURIComponent('api://AzureADTokenExchange')}`,
600
+ headers: {
601
+ Authorization: `Bearer ${process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN}`,
602
+ accept: 'application/json',
603
+ 'x-anonymous': true
604
+ },
605
+ responseType: 'json'
606
+ };
607
+ const accessTokenResponse = await request.get(requestOptions);
608
+ return accessTokenResponse.value;
609
+ }
555
610
  async ensureAccessTokenWithSecret(resource, logger, debug, fetchNew) {
556
611
  this.clientApplication = await this.getConfidentialClient(logger, debug, undefined, undefined, this.connection.secret);
557
612
  return this.clientApplication.acquireTokenByClientCredential({
@@ -626,7 +681,8 @@ export class Auth {
626
681
  // When using an application identity, there is no account in the MSAL TokenCache
627
682
  if (this.connection.authType !== AuthType.Certificate &&
628
683
  this.connection.authType !== AuthType.Secret &&
629
- this.connection.authType !== AuthType.Identity) {
684
+ this.connection.authType !== AuthType.Identity &&
685
+ this.connection.authType !== AuthType.FederatedIdentity) {
630
686
  this.clientApplication = await this.getPublicClient(logger, debug);
631
687
  if (this.clientApplication) {
632
688
  const tokenCache = this.clientApplication.getTokenCache();
@@ -16,9 +16,6 @@ class BookingBusinessGetCommand extends GraphCommand {
16
16
  get description() {
17
17
  return 'Retrieve the specified Microsoft Bookings business.';
18
18
  }
19
- defaultProperties() {
20
- return ['id', 'displayName', 'businessType', 'phone', 'email', 'defaultCurrencyIso'];
21
- }
22
19
  constructor() {
23
20
  super();
24
21
  _BookingBusinessGetCommand_instances.add(this);
@@ -184,6 +184,9 @@ class LoginCommand extends Command {
184
184
  auth.connection.authType = AuthType.Identity;
185
185
  auth.connection.userName = args.options.userName;
186
186
  break;
187
+ case 'federatedIdentity':
188
+ auth.connection.authType = AuthType.FederatedIdentity;
189
+ break;
187
190
  case 'browser':
188
191
  auth.connection.authType = AuthType.Browser;
189
192
  break;
@@ -20,9 +20,6 @@ class EntraUserGuestAddCommand extends GraphCommand {
20
20
  __classPrivateFieldGet(this, _EntraUserGuestAddCommand_instances, "m", _EntraUserGuestAddCommand_initTelemetry).call(this);
21
21
  __classPrivateFieldGet(this, _EntraUserGuestAddCommand_instances, "m", _EntraUserGuestAddCommand_initOptions).call(this);
22
22
  }
23
- defaultProperties() {
24
- return ['id', 'inviteRedeemUrl', 'invitedUserDisplayName', 'invitedUserEmailAddress', 'invitedUserType', 'resetRedemption', 'sendInvitationMessage', 'status'];
25
- }
26
23
  async commandAction(logger, args) {
27
24
  try {
28
25
  const requestOptions = {
@@ -15,9 +15,6 @@ class FlowEnvironmentGetCommand extends PowerAutomateCommand {
15
15
  get description() {
16
16
  return 'Gets information about the specified Microsoft Flow environment';
17
17
  }
18
- defaultProperties() {
19
- return ['name', 'id', 'location', 'displayName', 'provisioningState', 'environmentSku', 'azureRegionHint', 'isDefault'];
20
- }
21
18
  constructor() {
22
19
  super();
23
20
  _FlowEnvironmentGetCommand_instances.add(this);
@@ -15,9 +15,6 @@ class FlowGetCommand extends PowerAutomateCommand {
15
15
  get description() {
16
16
  return 'Gets information about the specified Microsoft Flow';
17
17
  }
18
- defaultProperties() {
19
- return ['name', 'displayName', 'description', 'triggers', 'actions'];
20
- }
21
18
  constructor() {
22
19
  super();
23
20
  _FlowGetCommand_instances.add(this);
@@ -16,9 +16,6 @@ class FlowRunGetCommand extends PowerAutomateCommand {
16
16
  get description() {
17
17
  return 'Gets information about a specific run of the specified Microsoft Flow';
18
18
  }
19
- defaultProperties() {
20
- return ['name', 'startTime', 'endTime', 'status', 'triggerName'];
21
- }
22
19
  constructor() {
23
20
  super();
24
21
  _FlowRunGetCommand_instances.add(this);
@@ -18,9 +18,6 @@ class PaAppGetCommand extends PowerAppsCommand {
18
18
  get description() {
19
19
  return 'Gets information about the specified Microsoft Power App';
20
20
  }
21
- defaultProperties() {
22
- return ['name', 'displayName', 'description', 'appVersion', 'owner'];
23
- }
24
21
  constructor() {
25
22
  super();
26
23
  _PaAppGetCommand_instances.add(this);
@@ -15,9 +15,6 @@ class PaEnvironmentGetCommand extends PowerAppsCommand {
15
15
  get description() {
16
16
  return 'Gets information about the specified Microsoft Power Apps environment';
17
17
  }
18
- defaultProperties() {
19
- return ['name', 'id', 'location', 'displayName', 'provisioningState', 'environmentSku', 'azureRegionHint', 'isDefault'];
20
- }
21
18
  constructor() {
22
19
  super();
23
20
  _PaEnvironmentGetCommand_instances.add(this);
@@ -17,9 +17,6 @@ class PlannerBucketAddCommand extends GraphCommand {
17
17
  get description() {
18
18
  return 'Adds a new Microsoft Planner bucket';
19
19
  }
20
- defaultProperties() {
21
- return ['id', 'name', 'planId', 'orderHint'];
22
- }
23
20
  constructor() {
24
21
  super();
25
22
  _PlannerBucketAddCommand_instances.add(this);
@@ -18,9 +18,6 @@ class PlannerPlanAddCommand extends GraphCommand {
18
18
  get description() {
19
19
  return 'Adds a new Microsoft Planner plan';
20
20
  }
21
- defaultProperties() {
22
- return ['id', 'title', 'createdDateTime', 'owner'];
23
- }
24
21
  constructor() {
25
22
  super();
26
23
  _PlannerPlanAddCommand_instances.add(this);
@@ -17,9 +17,6 @@ class PlannerPlanGetCommand extends GraphCommand {
17
17
  get description() {
18
18
  return 'Get a Microsoft Planner plan';
19
19
  }
20
- defaultProperties() {
21
- return ['id', 'title', 'createdDateTime', 'owner', '@odata.etag'];
22
- }
23
20
  constructor() {
24
21
  super();
25
22
  _PlannerPlanGetCommand_instances.add(this);
@@ -18,9 +18,6 @@ class PlannerPlanSetCommand extends GraphCommand {
18
18
  get description() {
19
19
  return 'Updates a Microsoft Planner plan';
20
20
  }
21
- defaultProperties() {
22
- return ['id', 'title', 'createdDateTime', 'owner'];
23
- }
24
21
  constructor() {
25
22
  super();
26
23
  _PlannerPlanSetCommand_instances.add(this);
@@ -17,9 +17,6 @@ class PlannerTaskChecklistItemAddCommand extends GraphCommand {
17
17
  get description() {
18
18
  return 'Adds a new checklist item to a Planner task.';
19
19
  }
20
- defaultProperties() {
21
- return ['id', 'title', 'isChecked'];
22
- }
23
20
  constructor() {
24
21
  super();
25
22
  _PlannerTaskChecklistItemAddCommand_instances.add(this);
@@ -18,9 +18,6 @@ class PpAiBuilderModelGetCommand extends PowerPlatformCommand {
18
18
  get description() {
19
19
  return 'Get an AI builder model in the specified Power Platform environment.';
20
20
  }
21
- defaultProperties() {
22
- return ['msdyn_name', 'msdyn_aimodelid', 'createdon', 'modifiedon'];
23
- }
24
21
  constructor() {
25
22
  super();
26
23
  _PpAiBuilderModelGetCommand_instances.add(this);
@@ -18,9 +18,6 @@ class PpCardGetCommand extends PowerPlatformCommand {
18
18
  get description() {
19
19
  return 'Get specific Microsoft Power Platform card in the specified Power Platform environment.';
20
20
  }
21
- defaultProperties() {
22
- return ['name', 'cardid', 'publishdate', 'createdon', 'modifiedon'];
23
- }
24
21
  constructor() {
25
22
  super();
26
23
  _PpCardGetCommand_instances.add(this);
@@ -21,9 +21,6 @@ class PpCopilotGetCommand extends PowerPlatformCommand {
21
21
  alias() {
22
22
  return [commands.CHATBOT_GET];
23
23
  }
24
- defaultProperties() {
25
- return ['name', 'botid', 'publishedon', 'createdon', 'modifiedon'];
26
- }
27
24
  constructor() {
28
25
  super();
29
26
  _PpCopilotGetCommand_instances.add(this);
@@ -15,9 +15,6 @@ class PpDataverseTableGetCommand extends PowerPlatformCommand {
15
15
  get description() {
16
16
  return 'Gets a dataverse table in a given environment';
17
17
  }
18
- defaultProperties() {
19
- return ['SchemaName', 'EntitySetName', 'LogicalName', 'IsManaged'];
20
- }
21
18
  constructor() {
22
19
  super();
23
20
  _PpDataverseTableGetCommand_instances.add(this);
@@ -15,9 +15,6 @@ class PpEnvironmentGetCommand extends PowerPlatformCommand {
15
15
  get description() {
16
16
  return 'Gets information about the specified Power Platform environment';
17
17
  }
18
- defaultProperties() {
19
- return ['name', 'id'];
20
- }
21
18
  constructor() {
22
19
  super();
23
20
  _PpEnvironmentGetCommand_instances.add(this);
@@ -17,9 +17,6 @@ class PpSolutionGetCommand extends PowerPlatformCommand {
17
17
  get description() {
18
18
  return 'Gets a specific solution in a given environment.';
19
19
  }
20
- defaultProperties() {
21
- return ['uniquename', 'version', 'publisher'];
22
- }
23
20
  constructor() {
24
21
  super();
25
22
  _PpSolutionGetCommand_instances.add(this);
@@ -16,9 +16,6 @@ class PpSolutionPublisherGetCommand extends PowerPlatformCommand {
16
16
  get description() {
17
17
  return 'Get information about the specified publisher in a given environment.';
18
18
  }
19
- defaultProperties() {
20
- return ['publisherid', 'uniquename', 'friendlyname'];
21
- }
22
19
  constructor() {
23
20
  super();
24
21
  _PpSolutionPublisherGetCommand_instances.add(this);
@@ -22,9 +22,6 @@ class PpWebSiteGetCommand extends PowerPlatformCommand {
22
22
  get description() {
23
23
  return 'Gets information about the specified Power Pages website.';
24
24
  }
25
- defaultProperties() {
26
- return ['id', 'name', 'websiteUrl', 'tenantId', 'subdomain', 'type', 'status', 'siteVisibility'];
27
- }
28
25
  get schema() {
29
26
  return options;
30
27
  }
@@ -17,9 +17,6 @@ class SpoGroupMemberAddCommand extends SpoCommand {
17
17
  get description() {
18
18
  return 'Add members to a SharePoint Group';
19
19
  }
20
- defaultProperties() {
21
- return ['Title', 'UserPrincipalName'];
22
- }
23
20
  constructor() {
24
21
  super();
25
22
  _SpoGroupMemberAddCommand_instances.add(this);
@@ -0,0 +1,66 @@
1
+ import { z } from 'zod';
2
+ import { zod } from '../../../../utils/zod.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
4
+ import { spo } from '../../../../utils/spo.js';
5
+ import { validation } from '../../../../utils/validation.js';
6
+ import SpoCommand from '../../../base/SpoCommand.js';
7
+ import commands from '../../commands.js';
8
+ import request from '../../../../request.js';
9
+ const options = globalOptionsZod
10
+ .extend({
11
+ url: zod.alias('u', z.string()
12
+ .refine((url) => validation.isValidSharePointUrl(url) === true, url => ({
13
+ message: `'${url}' is not a valid SharePoint Online site URL.`
14
+ }))),
15
+ audiences: z.string()
16
+ .refine(audiences => validation.isValidGuidArray(audiences) === true, audiences => ({
17
+ message: `The following GUIDs are invalid: ${validation.isValidGuidArray(audiences)}.`
18
+ })).optional(),
19
+ vivaConnectionsDefaultStart: z.boolean().optional(),
20
+ isInDraftMode: z.boolean().optional(),
21
+ order: z.number()
22
+ .refine(order => validation.isValidPositiveInteger(order) === true, order => ({
23
+ message: `'${order}' is not a positive integer.`
24
+ })).optional()
25
+ })
26
+ .strict();
27
+ class SpoHomeSiteAddCommand extends SpoCommand {
28
+ get name() {
29
+ return commands.HOMESITE_ADD;
30
+ }
31
+ get description() {
32
+ return 'Adds a home site';
33
+ }
34
+ get schema() {
35
+ return options;
36
+ }
37
+ async commandAction(logger, args) {
38
+ try {
39
+ const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
40
+ const requestOptions = {
41
+ url: `${spoAdminUrl}/_api/SPHSite/AddHomeSite`,
42
+ headers: {
43
+ accept: 'application/json;odata=nometadata'
44
+ },
45
+ responseType: 'json',
46
+ data: {
47
+ siteUrl: args.options.url,
48
+ audiences: args.options.audiences?.split(','),
49
+ vivaConnectionsDefaultStart: args.options.vivaConnectionsDefaultStart ?? true,
50
+ isInDraftMode: args.options.isInDraftMode ?? false,
51
+ order: args.options.order
52
+ }
53
+ };
54
+ if (this.verbose) {
55
+ await logger.logToStderr(`Adding home site with URL: ${args.options.url}...`);
56
+ }
57
+ const res = await request.post(requestOptions);
58
+ await logger.log(res);
59
+ }
60
+ catch (err) {
61
+ this.handleRejectedODataJsonPromise(err);
62
+ }
63
+ }
64
+ }
65
+ export default new SpoHomeSiteAddCommand();
66
+ //# sourceMappingURL=homesite-add.js.map
@@ -16,9 +16,6 @@ class SpoPageCopyCommand extends SpoCommand {
16
16
  get description() {
17
17
  return 'Creates a copy of a modern page or template';
18
18
  }
19
- defaultProperties() {
20
- return ['Id', 'PageLayoutType', 'Title', 'Url'];
21
- }
22
19
  constructor() {
23
20
  super();
24
21
  _SpoPageCopyCommand_instances.add(this);
@@ -25,9 +25,6 @@ class SpoPageGetCommand extends SpoCommand {
25
25
  get description() {
26
26
  return 'Gets information about the specific modern page';
27
27
  }
28
- defaultProperties() {
29
- return ['commentsDisabled', 'numSections', 'numControls', 'title', 'layoutType'];
30
- }
31
28
  get schema() {
32
29
  return options;
33
30
  }
@@ -15,9 +15,6 @@ class SpoSiteDesignRunStatusGetCommand extends SpoCommand {
15
15
  get description() {
16
16
  return 'Gets information about the site scripts executed for the specified site design';
17
17
  }
18
- defaultProperties() {
19
- return ['ActionTitle', 'SiteScriptTitle', 'OutcomeText'];
20
- }
21
18
  constructor() {
22
19
  super();
23
20
  _SpoSiteDesignRunStatusGetCommand_instances.add(this);
@@ -116,6 +116,7 @@ export default {
116
116
  GROUP_MEMBER_REMOVE: `${prefix} group member remove`,
117
117
  HIDEDEFAULTTHEMES_GET: `${prefix} hidedefaultthemes get`,
118
118
  HIDEDEFAULTTHEMES_SET: `${prefix} hidedefaultthemes set`,
119
+ HOMESITE_ADD: `${prefix} homesite add`,
119
120
  HOMESITE_GET: `${prefix} homesite get`,
120
121
  HOMESITE_LIST: `${prefix} homesite list`,
121
122
  HOMESITE_REMOVE: `${prefix} homesite remove`,
@@ -14,9 +14,6 @@ class TenantServiceAnnouncementHealthGetCommand extends GraphCommand {
14
14
  get description() {
15
15
  return 'This operation provides the health information of a specified service for a tenant';
16
16
  }
17
- defaultProperties() {
18
- return ['id', 'status', 'service'];
19
- }
20
17
  constructor() {
21
18
  super();
22
19
  _TenantServiceAnnouncementHealthGetCommand_instances.add(this);
@@ -15,9 +15,6 @@ class TodoListGetCommand extends DelegatedGraphCommand {
15
15
  get description() {
16
16
  return 'Gets a specific list of Microsoft To Do task lists';
17
17
  }
18
- defaultProperties() {
19
- return ['displayName', 'id'];
20
- }
21
18
  constructor() {
22
19
  super();
23
20
  _TodoListGetCommand_instances.add(this);
@@ -16,9 +16,6 @@ class TodoTaskGetCommand extends DelegatedGraphCommand {
16
16
  get description() {
17
17
  return 'Get a specific task from a Microsoft To Do task list';
18
18
  }
19
- defaultProperties() {
20
- return ['id', 'title', 'status', 'createdDateTime', 'lastModifiedDateTime'];
21
- }
22
19
  constructor() {
23
20
  super();
24
21
  _TodoTaskGetCommand_instances.add(this);
@@ -0,0 +1,113 @@
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import { zod } from '../../../../utils/zod.js';
4
+ import GraphCommand from '../../../base/GraphCommand.js';
5
+ import commands from '../../commands.js';
6
+ import { validation } from '../../../../utils/validation.js';
7
+ import { vivaEngage } from '../../../../utils/vivaEngage.js';
8
+ import request from '../../../../request.js';
9
+ import { entraUser } from '../../../../utils/entraUser.js';
10
+ import { formatting } from '../../../../utils/formatting.js';
11
+ const options = globalOptionsZod
12
+ .extend({
13
+ communityId: z.string().optional(),
14
+ communityDisplayName: zod.alias('n', z.string().optional()),
15
+ entraGroupId: z.string()
16
+ .refine(id => validation.isValidGuid(id), id => ({
17
+ message: `'${id}' is not a valid GUID.`
18
+ })).optional(),
19
+ ids: z.string()
20
+ .refine(ids => validation.isValidGuidArray(ids) === true, invalidIds => ({
21
+ message: `The following GUIDs are invalid: ${invalidIds}.`
22
+ })).optional(),
23
+ userNames: z.string()
24
+ .refine(userNames => validation.isValidUserPrincipalNameArray(userNames) === true, invalidUserNames => ({
25
+ message: `The following user principal names are invalid: ${invalidUserNames}.`
26
+ })).optional(),
27
+ role: zod.alias('r', z.enum(['Admin', 'Member']))
28
+ })
29
+ .strict();
30
+ class VivaEngageCommunityUserAddCommand extends GraphCommand {
31
+ get name() {
32
+ return commands.ENGAGE_COMMUNITY_USER_ADD;
33
+ }
34
+ get description() {
35
+ return 'Adds a user to a specific Microsoft 365 Viva Engage community';
36
+ }
37
+ get schema() {
38
+ return options;
39
+ }
40
+ getRefinedSchema(schema) {
41
+ return schema
42
+ .refine(options => [options.communityId, options.communityDisplayName, options.entraGroupId].filter(x => x !== undefined).length === 1, {
43
+ message: 'Specify either communityId, communityDisplayName, or entraGroupId, but not multiple.'
44
+ })
45
+ .refine(options => options.communityId || options.communityDisplayName || options.entraGroupId, {
46
+ message: 'Specify at least one of communityId, communityDisplayName, or entraGroupId.'
47
+ })
48
+ .refine(options => options.ids || options.userNames, {
49
+ message: 'Specify either of ids or userNames.'
50
+ })
51
+ .refine(options => typeof options.userNames !== undefined && typeof options.ids !== undefined, {
52
+ message: 'Specify either ids or userNames, but not both.'
53
+ });
54
+ }
55
+ async commandAction(logger, args) {
56
+ try {
57
+ if (this.verbose) {
58
+ await logger.logToStderr('Adding users to community...');
59
+ }
60
+ let entraGroupId = args.options.entraGroupId;
61
+ if (args.options.communityDisplayName) {
62
+ const community = await vivaEngage.getCommunityByDisplayName(args.options.communityDisplayName, ['groupId']);
63
+ entraGroupId = community.groupId;
64
+ }
65
+ if (args.options.communityId) {
66
+ const community = await vivaEngage.getCommunityById(args.options.communityId, ['groupId']);
67
+ entraGroupId = community.groupId;
68
+ }
69
+ const userIds = args.options.ids ? formatting.splitAndTrim(args.options.ids) : await entraUser.getUserIdsByUpns(formatting.splitAndTrim(args.options.userNames));
70
+ const role = args.options.role === 'Member' ? 'members' : 'owners';
71
+ for (let i = 0; i < userIds.length; i += 400) {
72
+ const userIdsBatch = userIds.slice(i, i + 400);
73
+ const requestOptions = {
74
+ url: `${this.resource}/v1.0/$batch`,
75
+ headers: {
76
+ 'content-type': 'application/json;odata.metadata=none'
77
+ },
78
+ responseType: 'json',
79
+ data: {
80
+ requests: []
81
+ }
82
+ };
83
+ // only 20 requests per one batch are allowed
84
+ for (let j = 0; j < userIdsBatch.length; j += 20) {
85
+ // only 20 users can be added in one request
86
+ const userIdsChunk = userIdsBatch.slice(j, j + 20);
87
+ requestOptions.data.requests.push({
88
+ id: j + 1,
89
+ method: 'PATCH',
90
+ url: `/groups/${entraGroupId}`,
91
+ headers: {
92
+ 'content-type': 'application/json;odata.metadata=none'
93
+ },
94
+ body: {
95
+ [`${role}@odata.bind`]: userIdsChunk.map((u) => `${this.resource}/v1.0/directoryObjects/${u}`)
96
+ }
97
+ });
98
+ }
99
+ const res = await request.post(requestOptions);
100
+ for (const response of res.responses) {
101
+ if (response.status !== 204) {
102
+ throw response.body;
103
+ }
104
+ }
105
+ }
106
+ }
107
+ catch (err) {
108
+ this.handleRejectedODataJsonPromise(err);
109
+ }
110
+ }
111
+ }
112
+ export default new VivaEngageCommunityUserAddCommand();
113
+ //# sourceMappingURL=engage-community-user-add.js.map