@pnp/cli-microsoft365 9.0.0-beta.62575a1 → 9.0.0-beta.834af0c

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 (109) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +9 -9
  4. package/dist/Command.js +49 -2
  5. package/dist/cli/cli.js +60 -38
  6. package/dist/config.js +1 -1
  7. package/dist/m365/app/commands/permission/permission-add.js +9 -9
  8. package/dist/m365/commands/login.js +44 -96
  9. package/dist/m365/commands/status.js +2 -2
  10. package/dist/m365/connection/commands/connection-remove.js +6 -2
  11. package/dist/m365/connection/commands/connection-set.js +4 -1
  12. package/dist/m365/connection/commands/connection-use.js +25 -4
  13. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +13 -13
  14. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +18 -18
  15. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +1 -1
  16. package/dist/m365/entra/commands/group/group-user-list.js +4 -4
  17. package/dist/m365/entra/commands/m365group/m365group-conversation-post-list.js +4 -4
  18. package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-list.js +3 -3
  19. package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
  20. package/dist/m365/entra/commands/m365group/m365group-user-list.js +6 -9
  21. package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
  22. package/dist/m365/entra/commands/multitenant/multitenant-add.js +65 -0
  23. package/dist/m365/entra/commands/multitenant/multitenant-remove.js +118 -0
  24. package/dist/m365/entra/commands/multitenant/multitenant-set.js +72 -0
  25. package/dist/m365/entra/commands.js +3 -0
  26. package/dist/m365/outlook/commands/message/message-get.js +11 -11
  27. package/dist/m365/spe/ContainerTypeProperties.js +2 -0
  28. package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
  29. package/dist/m365/spe/commands.js +2 -1
  30. package/dist/m365/spfx/commands/project/DeployWorkflow.js +1 -1
  31. package/dist/m365/spfx/commands/project/project-github-workflow-add.js +1 -10
  32. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
  33. package/dist/m365/spo/commands/commandset/commandset-get.js +31 -17
  34. package/dist/m365/spo/commands/file/file-copy.js +55 -34
  35. package/dist/m365/spo/commands/file/file-roleassignment-add.js +1 -1
  36. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +1 -1
  37. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
  38. package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +1 -1
  39. package/dist/m365/spo/commands/folder/folder-set.js +0 -4
  40. package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +86 -0
  41. package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
  42. package/dist/m365/spo/commands/list/ListInstance.js +6 -1
  43. package/dist/m365/spo/commands/list/list-get.js +9 -3
  44. package/dist/m365/spo/commands/list/list-list.js +1 -4
  45. package/dist/m365/spo/commands/list/list-roleassignment-add.js +46 -21
  46. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +48 -46
  47. package/dist/m365/spo/commands/site/site-appcatalog-remove.js +48 -24
  48. package/dist/m365/spo/commands/site/site-remove.js +1 -7
  49. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
  50. package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
  51. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-restore.js +2 -22
  52. package/dist/m365/spo/commands.js +2 -1
  53. package/dist/utils/drive.js +61 -0
  54. package/dist/utils/formatting.js +16 -0
  55. package/dist/utils/spo.js +143 -6
  56. package/dist/utils/zod.js +124 -0
  57. package/docs/docs/cmd/app/permission/permission-add.mdx +5 -5
  58. package/docs/docs/cmd/connection/connection-use.mdx +8 -2
  59. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-add.mdx +12 -12
  60. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-get.mdx +14 -14
  61. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-list.mdx +5 -5
  62. package/docs/docs/cmd/entra/group/group-user-list.mdx +7 -7
  63. package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +5 -5
  64. package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx +3 -3
  65. package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
  66. package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +1 -1
  67. package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
  68. package/docs/docs/cmd/entra/multitenant/multitenant-add.mdx +107 -0
  69. package/docs/docs/cmd/entra/multitenant/multitenant-remove.mdx +58 -0
  70. package/docs/docs/cmd/entra/multitenant/multitenant-set.mdx +53 -0
  71. package/docs/docs/cmd/outlook/message/message-get.mdx +5 -5
  72. package/docs/docs/cmd/planner/plan/plan-remove.mdx +1 -1
  73. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +102 -0
  74. package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +11 -12
  75. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +87 -38
  76. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +22 -28
  77. package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
  78. package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
  79. package/docs/docs/cmd/spo/file/file-copy.mdx +119 -12
  80. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +1 -1
  81. package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +2 -2
  82. package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
  83. package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +1 -1
  84. package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +1 -1
  85. package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +2 -2
  86. package/docs/docs/cmd/spo/folder/folder-set.mdx +0 -6
  87. package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
  88. package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
  89. package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
  90. package/docs/docs/cmd/spo/list/list-list.mdx +5 -7
  91. package/docs/docs/cmd/spo/list/list-roleassignment-add.mdx +15 -3
  92. package/docs/docs/cmd/spo/list/list-roleassignment-remove.mdx +15 -3
  93. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-ensure.mdx +4 -4
  94. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.mdx +1 -1
  95. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.mdx +9 -9
  96. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-remove.mdx +7 -7
  97. package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +11 -2
  98. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.mdx +1 -1
  99. package/docs/docs/cmd/spo/site/site-remove.mdx +0 -3
  100. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
  101. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
  102. package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
  103. package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
  104. package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.mdx +2 -49
  105. package/docs/docs/cmd/spo/web/web-roleassignment-add.mdx +1 -1
  106. package/docs/docs/cmd/spo/web/web-roleassignment-remove.mdx +1 -1
  107. package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
  108. package/npm-shrinkwrap.json +604 -843
  109. package/package.json +6 -2
@@ -3,10 +3,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _ConnectionUseCommand_instances, _ConnectionUseCommand_initOptions;
6
+ var _ConnectionUseCommand_instances, _ConnectionUseCommand_initTelemetry, _ConnectionUseCommand_initOptions, _ConnectionUseCommand_initTypes;
7
7
  import auth from '../../../Auth.js';
8
8
  import commands from '../commands.js';
9
9
  import Command, { CommandError } from '../../../Command.js';
10
+ import { formatting } from '../../../utils/formatting.js';
11
+ import { cli } from '../../../cli/cli.js';
10
12
  class ConnectionUseCommand extends Command {
11
13
  get name() {
12
14
  return commands.USE;
@@ -18,9 +20,20 @@ class ConnectionUseCommand extends Command {
18
20
  super();
19
21
  _ConnectionUseCommand_instances.add(this);
20
22
  __classPrivateFieldGet(this, _ConnectionUseCommand_instances, "m", _ConnectionUseCommand_initOptions).call(this);
23
+ __classPrivateFieldGet(this, _ConnectionUseCommand_instances, "m", _ConnectionUseCommand_initTelemetry).call(this);
24
+ __classPrivateFieldGet(this, _ConnectionUseCommand_instances, "m", _ConnectionUseCommand_initTypes).call(this);
21
25
  }
22
26
  async commandAction(logger, args) {
23
- const connection = await auth.getConnection(args.options.name);
27
+ let connection;
28
+ if (args.options.name) {
29
+ connection = await auth.getConnection(args.options.name);
30
+ }
31
+ else {
32
+ const connections = await auth.getAllConnections();
33
+ connections.sort((a, b) => a.name.localeCompare(b.name));
34
+ const keyValuePair = formatting.convertArrayToHashTable('name', connections);
35
+ connection = await cli.handleMultipleResultsFound('Please select the connection you want to activate.', keyValuePair);
36
+ }
24
37
  if (this.verbose) {
25
38
  await logger.logToStderr(`Switching to connection '${connection.identityName}', appId: ${connection.appId}, tenantId: ${connection.identityTenantId}...`);
26
39
  }
@@ -42,10 +55,18 @@ class ConnectionUseCommand extends Command {
42
55
  await this.commandAction(logger, args);
43
56
  }
44
57
  }
45
- _ConnectionUseCommand_instances = new WeakSet(), _ConnectionUseCommand_initOptions = function _ConnectionUseCommand_initOptions() {
58
+ _ConnectionUseCommand_instances = new WeakSet(), _ConnectionUseCommand_initTelemetry = function _ConnectionUseCommand_initTelemetry() {
59
+ this.telemetry.push((args) => {
60
+ Object.assign(this.telemetryProperties, {
61
+ name: typeof args.options.name !== 'undefined'
62
+ });
63
+ });
64
+ }, _ConnectionUseCommand_initOptions = function _ConnectionUseCommand_initOptions() {
46
65
  this.options.unshift({
47
- option: '-n, --name <name>'
66
+ option: '-n, --name [name]'
48
67
  });
68
+ }, _ConnectionUseCommand_initTypes = function _ConnectionUseCommand_initTypes() {
69
+ this.types.string.push('name');
49
70
  };
50
71
  export default new ConnectionUseCommand();
51
72
  //# sourceMappingURL=connection-use.js.map
@@ -30,12 +30,12 @@ class EntraEnterpriseAppAddCommand extends GraphCommand {
30
30
  __classPrivateFieldGet(this, _EntraEnterpriseAppAddCommand_instances, "m", _EntraEnterpriseAppAddCommand_initOptionSets).call(this);
31
31
  }
32
32
  async getAppId(args) {
33
- if (args.options.appId) {
34
- return args.options.appId;
33
+ if (args.options.id) {
34
+ return args.options.id;
35
35
  }
36
36
  let spMatchQuery = '';
37
- if (args.options.appName) {
38
- spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.appName)}'`;
37
+ if (args.options.displayName) {
38
+ spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.displayName)}'`;
39
39
  }
40
40
  else if (args.options.objectId) {
41
41
  spMatchQuery = `id eq '${formatting.encodeQueryParameter(args.options.objectId)}'`;
@@ -54,7 +54,7 @@ class EntraEnterpriseAppAddCommand extends GraphCommand {
54
54
  }
55
55
  if (response.value.length > 1) {
56
56
  const resultAsKeyValuePair = formatting.convertArrayToHashTable('appId', response.value);
57
- const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.appName}' found.`, resultAsKeyValuePair);
57
+ const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.displayName}' found.`, resultAsKeyValuePair);
58
58
  return result.appId;
59
59
  }
60
60
  return spItem.appId;
@@ -85,31 +85,31 @@ class EntraEnterpriseAppAddCommand extends GraphCommand {
85
85
  _EntraEnterpriseAppAddCommand_instances = new WeakSet(), _EntraEnterpriseAppAddCommand_initTelemetry = function _EntraEnterpriseAppAddCommand_initTelemetry() {
86
86
  this.telemetry.push((args) => {
87
87
  Object.assign(this.telemetryProperties, {
88
- appId: (!(!args.options.appId)).toString(),
89
- appName: (!(!args.options.appName)).toString(),
88
+ id: (!(!args.options.id)).toString(),
89
+ displayName: (!(!args.options.displayName)).toString(),
90
90
  objectId: (!(!args.options.objectId)).toString()
91
91
  });
92
92
  });
93
93
  }, _EntraEnterpriseAppAddCommand_initOptions = function _EntraEnterpriseAppAddCommand_initOptions() {
94
94
  this.options.unshift({
95
- option: '--appId [appId]'
95
+ option: '-i, --id [id]'
96
96
  }, {
97
- option: '--appName [appName]'
97
+ option: '-n, --displayName [displayName]'
98
98
  }, {
99
99
  option: '--objectId [objectId]'
100
100
  });
101
101
  }, _EntraEnterpriseAppAddCommand_initValidators = function _EntraEnterpriseAppAddCommand_initValidators() {
102
102
  this.validators.push(async (args) => {
103
- if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
104
- return `${args.options.appId} is not a valid appId GUID`;
103
+ if (args.options.id && !validation.isValidGuid(args.options.id)) {
104
+ return `${args.options.id} is not a valid GUID`;
105
105
  }
106
106
  if (args.options.objectId && !validation.isValidGuid(args.options.objectId)) {
107
- return `${args.options.objectId} is not a valid objectId GUID`;
107
+ return `${args.options.objectId} is not a valid GUID`;
108
108
  }
109
109
  return true;
110
110
  });
111
111
  }, _EntraEnterpriseAppAddCommand_initOptionSets = function _EntraEnterpriseAppAddCommand_initOptionSets() {
112
- this.optionSets.push({ options: ['appId', 'appName', 'objectId'] });
112
+ this.optionSets.push({ options: ['id', 'displayName', 'objectId'] });
113
113
  };
114
114
  export default new EntraEnterpriseAppAddCommand();
115
115
  //# sourceMappingURL=enterpriseapp-add.js.map
@@ -30,15 +30,15 @@ class EntraEnterpriseAppGetCommand extends GraphCommand {
30
30
  __classPrivateFieldGet(this, _EntraEnterpriseAppGetCommand_instances, "m", _EntraEnterpriseAppGetCommand_initOptionSets).call(this);
31
31
  }
32
32
  async getSpId(args) {
33
- if (args.options.appObjectId) {
34
- return args.options.appObjectId;
33
+ if (args.options.objectId) {
34
+ return args.options.objectId;
35
35
  }
36
36
  let spMatchQuery = '';
37
- if (args.options.appDisplayName) {
38
- spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.appDisplayName)}'`;
37
+ if (args.options.displayName) {
38
+ spMatchQuery = `displayName eq '${formatting.encodeQueryParameter(args.options.displayName)}'`;
39
39
  }
40
- else if (args.options.appId) {
41
- spMatchQuery = `appId eq '${formatting.encodeQueryParameter(args.options.appId)}'`;
40
+ else if (args.options.id) {
41
+ spMatchQuery = `appId eq '${formatting.encodeQueryParameter(args.options.id)}'`;
42
42
  }
43
43
  const idRequestOptions = {
44
44
  url: `${this.resource}/v1.0/servicePrincipals?$filter=${spMatchQuery}`,
@@ -54,7 +54,7 @@ class EntraEnterpriseAppGetCommand extends GraphCommand {
54
54
  }
55
55
  if (response.value.length > 1) {
56
56
  const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', response.value);
57
- const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.appDisplayName}' found.`, resultAsKeyValuePair);
57
+ const result = await cli.handleMultipleResultsFound(`Multiple Entra apps with name '${args.options.displayName}' found.`, resultAsKeyValuePair);
58
58
  return result.id;
59
59
  }
60
60
  return spItem.id;
@@ -85,31 +85,31 @@ class EntraEnterpriseAppGetCommand extends GraphCommand {
85
85
  _EntraEnterpriseAppGetCommand_instances = new WeakSet(), _EntraEnterpriseAppGetCommand_initTelemetry = function _EntraEnterpriseAppGetCommand_initTelemetry() {
86
86
  this.telemetry.push((args) => {
87
87
  Object.assign(this.telemetryProperties, {
88
- appId: (!(!args.options.appId)).toString(),
89
- appDisplayName: (!(!args.options.appDisplayName)).toString(),
90
- appObjectId: (!(!args.options.appObjectId)).toString()
88
+ id: (!(!args.options.id)).toString(),
89
+ displayName: (!(!args.options.displayName)).toString(),
90
+ objectId: (!(!args.options.objectId)).toString()
91
91
  });
92
92
  });
93
93
  }, _EntraEnterpriseAppGetCommand_initOptions = function _EntraEnterpriseAppGetCommand_initOptions() {
94
94
  this.options.unshift({
95
- option: '-i, --appId [appId]'
95
+ option: '-i, --id [id]'
96
96
  }, {
97
- option: '-n, --appDisplayName [appDisplayName]'
97
+ option: '-n, --displayName [displayName]'
98
98
  }, {
99
- option: '--appObjectId [appObjectId]'
99
+ option: '--objectId [objectId]'
100
100
  });
101
101
  }, _EntraEnterpriseAppGetCommand_initValidators = function _EntraEnterpriseAppGetCommand_initValidators() {
102
102
  this.validators.push(async (args) => {
103
- if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
104
- return `${args.options.appId} is not a valid appId GUID`;
103
+ if (args.options.id && !validation.isValidGuid(args.options.id)) {
104
+ return `${args.options.id} is not a valid GUID`;
105
105
  }
106
- if (args.options.appObjectId && !validation.isValidGuid(args.options.appObjectId)) {
107
- return `${args.options.appObjectId} is not a valid objectId GUID`;
106
+ if (args.options.objectId && !validation.isValidGuid(args.options.objectId)) {
107
+ return `${args.options.objectId} is not a valid GUID`;
108
108
  }
109
109
  return true;
110
110
  });
111
111
  }, _EntraEnterpriseAppGetCommand_initOptionSets = function _EntraEnterpriseAppGetCommand_initOptionSets() {
112
- this.optionSets.push({ options: ['appId', 'appDisplayName', 'appObjectId'] });
112
+ this.optionSets.push({ options: ['id', 'displayName', 'objectId'] });
113
113
  };
114
114
  export default new EntraEnterpriseAppGetCommand();
115
115
  //# sourceMappingURL=enterpriseapp-get.js.map
@@ -61,7 +61,7 @@ _EntraEnterpriseAppListCommand_instances = new WeakSet(), _EntraEnterpriseAppLis
61
61
  });
62
62
  }, _EntraEnterpriseAppListCommand_initOptions = function _EntraEnterpriseAppListCommand_initOptions() {
63
63
  this.options.unshift({
64
- option: '--displayName [displayName]'
64
+ option: '-n, --displayName [displayName]'
65
65
  }, {
66
66
  option: '--tag [tag]'
67
67
  });
@@ -65,7 +65,7 @@ class EntraGroupUserListCommand extends GraphCommand {
65
65
  if (this.verbose) {
66
66
  await logger.logToStderr('Retrieving Group Id...');
67
67
  }
68
- return await entraGroup.getGroupIdByDisplayName(options.groupDisplayName);
68
+ return await entraGroup.getGroupIdByDisplayName(options.groupName);
69
69
  }
70
70
  async getUsers(options, role, groupId, logger) {
71
71
  const { properties, filter } = options;
@@ -111,7 +111,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
111
111
  this.telemetry.push((args) => {
112
112
  Object.assign(this.telemetryProperties, {
113
113
  groupId: typeof args.options.groupId !== 'undefined',
114
- groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
114
+ groupName: typeof args.options.groupName !== 'undefined',
115
115
  role: typeof args.options.role !== 'undefined',
116
116
  properties: typeof args.options.properties !== 'undefined',
117
117
  filter: typeof args.options.filter !== 'undefined'
@@ -121,7 +121,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
121
121
  this.options.unshift({
122
122
  option: "-i, --groupId [groupId]"
123
123
  }, {
124
- option: "-n, --groupDisplayName [groupDisplayName]"
124
+ option: "-n, --groupName [groupName]"
125
125
  }, {
126
126
  option: "-r, --role [role]",
127
127
  autocomplete: ["Owner", "Member"]
@@ -132,7 +132,7 @@ _EntraGroupUserListCommand_instances = new WeakSet(), _EntraGroupUserListCommand
132
132
  });
133
133
  }, _EntraGroupUserListCommand_initOptionSets = function _EntraGroupUserListCommand_initOptionSets() {
134
134
  this.optionSets.push({
135
- options: ['groupId', 'groupDisplayName']
135
+ options: ['groupId', 'groupName']
136
136
  });
137
137
  }, _EntraGroupUserListCommand_initValidators = function _EntraGroupUserListCommand_initValidators() {
138
138
  this.validators.push(async (args) => {
@@ -51,7 +51,7 @@ class EntraM365GroupConversationPostListCommand extends GraphCommand {
51
51
  if (args.options.groupId) {
52
52
  return formatting.encodeQueryParameter(args.options.groupId);
53
53
  }
54
- const group = await entraGroup.getGroupByDisplayName(args.options.groupDisplayName);
54
+ const group = await entraGroup.getGroupByDisplayName(args.options.groupName);
55
55
  return group.id;
56
56
  }
57
57
  }
@@ -59,14 +59,14 @@ _EntraM365GroupConversationPostListCommand_instances = new WeakSet(), _EntraM365
59
59
  this.telemetry.push((args) => {
60
60
  Object.assign(this.telemetryProperties, {
61
61
  groupId: typeof args.options.groupId !== 'undefined',
62
- groupDisplayName: typeof args.options.groupDisplayName !== 'undefined'
62
+ groupName: typeof args.options.groupName !== 'undefined'
63
63
  });
64
64
  });
65
65
  }, _EntraM365GroupConversationPostListCommand_initOptions = function _EntraM365GroupConversationPostListCommand_initOptions() {
66
66
  this.options.unshift({
67
67
  option: '-i, --groupId [groupId]'
68
68
  }, {
69
- option: '-d, --groupDisplayName [groupDisplayName]'
69
+ option: '-d, --groupName [groupName]'
70
70
  }, {
71
71
  option: '-t, --threadId <threadId>'
72
72
  });
@@ -78,7 +78,7 @@ _EntraM365GroupConversationPostListCommand_instances = new WeakSet(), _EntraM365
78
78
  return true;
79
79
  });
80
80
  }, _EntraM365GroupConversationPostListCommand_initOptionSets = function _EntraM365GroupConversationPostListCommand_initOptionSets() {
81
- this.optionSets.push({ options: ['groupId', 'groupDisplayName'] });
81
+ this.optionSets.push({ options: ['groupId', 'groupName'] });
82
82
  };
83
83
  export default new EntraM365GroupConversationPostListCommand();
84
84
  //# sourceMappingURL=m365group-conversation-post-list.js.map
@@ -32,7 +32,7 @@ class EntraM365GroupRecycleBinItemListCommand extends GraphCommand {
32
32
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_RECYCLEBINITEM_LIST, commands.M365GROUP_RECYCLEBINITEM_LIST);
33
33
  try {
34
34
  const filter = `?$filter=groupTypes/any(c:c+eq+'Unified')`;
35
- const displayNameFilter = args.options.groupDisplayName ? ` and startswith(DisplayName,'${formatting.encodeQueryParameter(args.options.groupDisplayName).replace(/'/g, `''`)}')` : '';
35
+ const displayNameFilter = args.options.groupName ? ` and startswith(DisplayName,'${formatting.encodeQueryParameter(args.options.groupName).replace(/'/g, `''`)}')` : '';
36
36
  const mailNicknameFilter = args.options.groupMailNickname ? ` and startswith(MailNickname,'${formatting.encodeQueryParameter(args.options.groupMailNickname).replace(/'/g, `''`)}')` : '';
37
37
  const topCount = '&$top=100';
38
38
  const endpoint = `${this.resource}/v1.0/directory/deletedItems/Microsoft.Graph.Group${filter}${displayNameFilter}${mailNicknameFilter}${topCount}`;
@@ -47,13 +47,13 @@ class EntraM365GroupRecycleBinItemListCommand extends GraphCommand {
47
47
  _EntraM365GroupRecycleBinItemListCommand_instances = new WeakSet(), _EntraM365GroupRecycleBinItemListCommand_initTelemetry = function _EntraM365GroupRecycleBinItemListCommand_initTelemetry() {
48
48
  this.telemetry.push((args) => {
49
49
  Object.assign(this.telemetryProperties, {
50
- groupDisplayName: typeof args.options.groupDisplayName !== 'undefined',
50
+ groupName: typeof args.options.groupName !== 'undefined',
51
51
  groupMailNickname: typeof args.options.groupMailNickname !== 'undefined'
52
52
  });
53
53
  });
54
54
  }, _EntraM365GroupRecycleBinItemListCommand_initOptions = function _EntraM365GroupRecycleBinItemListCommand_initOptions() {
55
55
  this.options.unshift({
56
- option: '-d, --groupDisplayName [groupDisplayName]'
56
+ option: '-d, --groupName [groupName]'
57
57
  }, {
58
58
  option: '-m, --groupMailNickname [groupMailNickname]'
59
59
  });
@@ -3,14 +3,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _EntraM365GroupUserAddCommand_instances, _EntraM365GroupUserAddCommand_initTelemetry, _EntraM365GroupUserAddCommand_initOptions, _EntraM365GroupUserAddCommand_initValidators, _EntraM365GroupUserAddCommand_initOptionSets;
6
+ var _EntraM365GroupUserAddCommand_instances, _EntraM365GroupUserAddCommand_initTelemetry, _EntraM365GroupUserAddCommand_initOptions, _EntraM365GroupUserAddCommand_initValidators, _EntraM365GroupUserAddCommand_initOptionSets, _EntraM365GroupUserAddCommand_initTypes;
7
7
  import request from '../../../../request.js';
8
8
  import { entraGroup } from '../../../../utils/entraGroup.js';
9
- import { formatting } from '../../../../utils/formatting.js';
10
9
  import { validation } from '../../../../utils/validation.js';
10
+ import { formatting } from '../../../../utils/formatting.js';
11
11
  import GraphCommand from '../../../base/GraphCommand.js';
12
12
  import teamsCommands from '../../../teams/commands.js';
13
13
  import aadCommands from '../../aadCommands.js';
14
+ import { entraUser } from '../../../../utils/entraUser.js';
14
15
  import commands from '../../commands.js';
15
16
  class EntraM365GroupUserAddCommand extends GraphCommand {
16
17
  get name() {
@@ -25,79 +26,155 @@ class EntraM365GroupUserAddCommand extends GraphCommand {
25
26
  constructor() {
26
27
  super();
27
28
  _EntraM365GroupUserAddCommand_instances.add(this);
29
+ this.allowedRoles = ['owner', 'member'];
28
30
  __classPrivateFieldGet(this, _EntraM365GroupUserAddCommand_instances, "m", _EntraM365GroupUserAddCommand_initTelemetry).call(this);
29
31
  __classPrivateFieldGet(this, _EntraM365GroupUserAddCommand_instances, "m", _EntraM365GroupUserAddCommand_initOptions).call(this);
30
32
  __classPrivateFieldGet(this, _EntraM365GroupUserAddCommand_instances, "m", _EntraM365GroupUserAddCommand_initValidators).call(this);
31
33
  __classPrivateFieldGet(this, _EntraM365GroupUserAddCommand_instances, "m", _EntraM365GroupUserAddCommand_initOptionSets).call(this);
34
+ __classPrivateFieldGet(this, _EntraM365GroupUserAddCommand_instances, "m", _EntraM365GroupUserAddCommand_initTypes).call(this);
32
35
  }
33
36
  async commandAction(logger, args) {
34
37
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_ADD, commands.M365GROUP_USER_ADD);
38
+ if (args.options.userName) {
39
+ await this.warn(logger, `Option 'userName' is deprecated. Please use 'ids' or 'userNames' instead.`);
40
+ }
35
41
  try {
36
- const providedGroupId = (typeof args.options.groupId !== 'undefined') ? args.options.groupId : args.options.teamId;
42
+ const userNames = args.options.userNames || args.options.userName;
43
+ const providedGroupId = await this.getGroupId(logger, args);
37
44
  const isUnifiedGroup = await entraGroup.isUnifiedGroup(providedGroupId);
38
45
  if (!isUnifiedGroup) {
39
46
  throw Error(`Specified group with id '${providedGroupId}' is not a Microsoft 365 group.`);
40
47
  }
41
- let requestOptions = {
42
- url: `${this.resource}/v1.0/users/${formatting.encodeQueryParameter(args.options.userName)}/id`,
43
- headers: {
44
- accept: 'application/json;odata.metadata=none'
45
- },
46
- responseType: 'json'
47
- };
48
- const res = await request.get(requestOptions);
49
- const endpoint = `${this.resource}/v1.0/groups/${providedGroupId}/${((typeof args.options.role !== 'undefined') ? args.options.role : '').toLowerCase() === 'owner' ? 'owners' : 'members'}/$ref`;
50
- requestOptions = {
51
- url: endpoint,
48
+ const userIds = await this.getUserIds(logger, args.options.ids, userNames);
49
+ if (this.verbose) {
50
+ await logger.logToStderr(`Adding user(s) ${args.options.ids || userNames} to group ${args.options.groupId || args.options.groupName || args.options.teamId || args.options.teamName}...`);
51
+ }
52
+ await this.addUsers(providedGroupId, userIds, args.options.role);
53
+ }
54
+ catch (err) {
55
+ this.handleRejectedODataJsonPromise(err);
56
+ }
57
+ }
58
+ async getGroupId(logger, args) {
59
+ if (args.options.groupId) {
60
+ return args.options.groupId;
61
+ }
62
+ if (args.options.teamId) {
63
+ return args.options.teamId;
64
+ }
65
+ const name = args.options.groupName || args.options.teamName;
66
+ if (this.verbose) {
67
+ await logger.logToStderr('Retrieving Group ID by display name...');
68
+ }
69
+ return entraGroup.getGroupIdByDisplayName(name);
70
+ }
71
+ async getUserIds(logger, userIds, userNames) {
72
+ if (userIds) {
73
+ return formatting.splitAndTrim(userIds);
74
+ }
75
+ if (this.verbose) {
76
+ await logger.logToStderr('Retrieving user ID(s) by username(s)...');
77
+ }
78
+ return entraUser.getUserIdsByUpns(formatting.splitAndTrim(userNames));
79
+ }
80
+ async addUsers(groupId, userIds, role) {
81
+ for (let i = 0; i < userIds.length; i += 400) {
82
+ const userIdsBatch = userIds.slice(i, i + 400);
83
+ const requestOptions = {
84
+ url: `${this.resource}/v1.0/$batch`,
52
85
  headers: {
53
- 'accept': 'application/json;odata.metadata=none'
86
+ 'content-type': 'application/json;odata.metadata=none'
54
87
  },
55
88
  responseType: 'json',
56
- data: { "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/" + res.value }
89
+ data: {
90
+ requests: []
91
+ }
57
92
  };
58
- await request.post(requestOptions);
59
- }
60
- catch (err) {
61
- this.handleRejectedODataJsonPromise(err);
93
+ for (let j = 0; j < userIdsBatch.length; j += 20) {
94
+ const userIdsChunk = userIdsBatch.slice(j, j + 20);
95
+ requestOptions.data.requests.push({
96
+ id: j + 1,
97
+ method: 'PATCH',
98
+ url: `/groups/${groupId}`,
99
+ headers: {
100
+ 'content-type': 'application/json;odata.metadata=none'
101
+ },
102
+ body: {
103
+ [`${((typeof role !== 'undefined') ? role : '').toLowerCase() === 'owner' ? 'owners' : 'members'}@odata.bind`]: userIdsChunk.map(u => `${this.resource}/v1.0/directoryObjects/${u}`)
104
+ }
105
+ });
106
+ }
107
+ const res = await request.post(requestOptions);
108
+ for (const response of res.responses) {
109
+ if (response.status !== 204) {
110
+ throw response.body;
111
+ }
112
+ }
62
113
  }
63
114
  }
64
115
  }
65
116
  _EntraM365GroupUserAddCommand_instances = new WeakSet(), _EntraM365GroupUserAddCommand_initTelemetry = function _EntraM365GroupUserAddCommand_initTelemetry() {
66
117
  this.telemetry.push((args) => {
67
118
  Object.assign(this.telemetryProperties, {
68
- role: args.options.role,
119
+ role: args.options.role !== 'undefined',
69
120
  teamId: typeof args.options.teamId !== 'undefined',
70
- groupId: typeof args.options.groupId !== 'undefined'
121
+ groupId: typeof args.options.groupId !== 'undefined',
122
+ teamName: typeof args.options.teamName !== 'undefined',
123
+ groupName: typeof args.options.groupName !== 'undefined',
124
+ ids: typeof args.options.ids !== 'undefined',
125
+ userNames: typeof args.options.userNames !== 'undefined',
126
+ userName: typeof args.options.userName !== 'undefined'
71
127
  });
72
128
  });
73
129
  }, _EntraM365GroupUserAddCommand_initOptions = function _EntraM365GroupUserAddCommand_initOptions() {
74
130
  this.options.unshift({
75
- option: '-n, --userName <userName>'
131
+ option: '-n, --userName [userName]'
76
132
  }, {
77
- option: "-i, --groupId [groupId]"
133
+ option: '--ids [ids]'
78
134
  }, {
79
- option: "--teamId [teamId]"
135
+ option: '--userNames [userNames]'
136
+ }, {
137
+ option: '-i, --groupId [groupId]'
138
+ }, {
139
+ option: '--groupName [groupName]'
140
+ }, {
141
+ option: '--teamId [teamId]'
142
+ }, {
143
+ option: '--teamName [teamName]'
80
144
  }, {
81
145
  option: '-r, --role [role]',
82
- autocomplete: ['Owner', 'Member']
146
+ autocomplete: this.allowedRoles
83
147
  });
84
148
  }, _EntraM365GroupUserAddCommand_initValidators = function _EntraM365GroupUserAddCommand_initValidators() {
85
149
  this.validators.push(async (args) => {
86
150
  if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
87
- return `${args.options.teamId} is not a valid GUID`;
151
+ return `'${args.options.teamId}' is not a valid GUID for option 'teamId'.`;
88
152
  }
89
153
  if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
90
- return `${args.options.groupId} is not a valid GUID`;
154
+ return `'${args.options.groupId}' is not a valid GUID for option 'groupId'.`;
91
155
  }
92
- if (args.options.role) {
93
- if (['owner', 'member'].indexOf(args.options.role.toLowerCase()) === -1) {
94
- return `${args.options.role} is not a valid role value. Allowed values Owner|Member`;
156
+ if (args.options.ids) {
157
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
158
+ if (isValidGUIDArrayResult !== true) {
159
+ return `The following GUIDs are invalid for the option 'ids': ${isValidGUIDArrayResult}.`;
95
160
  }
96
161
  }
162
+ if (args.options.userNames) {
163
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.userNames);
164
+ if (isValidUPNArrayResult !== true) {
165
+ return `The following user principal names are invalid for the option 'userNames': ${isValidUPNArrayResult}.`;
166
+ }
167
+ }
168
+ if (args.options.role && !this.allowedRoles.some(role => role.toLowerCase() === args.options.role.toLowerCase())) {
169
+ return `'${args.options.role}' is not a valid role. Allowed values are: ${this.allowedRoles.join(',')}`;
170
+ }
97
171
  return true;
98
172
  });
99
173
  }, _EntraM365GroupUserAddCommand_initOptionSets = function _EntraM365GroupUserAddCommand_initOptionSets() {
100
- this.optionSets.push({ options: ['groupId', 'teamId'] });
174
+ this.optionSets.push({ options: ['groupId', 'groupName', 'teamId', 'teamName'] });
175
+ this.optionSets.push({ options: ['userName', 'ids', 'userNames'] });
176
+ }, _EntraM365GroupUserAddCommand_initTypes = function _EntraM365GroupUserAddCommand_initTypes() {
177
+ this.types.string.push('userName', 'ids', 'userNames', 'groupId', 'groupName', 'teamId', 'teamName', 'role');
101
178
  };
102
179
  export default new EntraM365GroupUserAddCommand();
103
180
  //# sourceMappingURL=m365group-user-add.js.map
@@ -31,9 +31,6 @@ class EntraM365GroupUserListCommand extends GraphCommand {
31
31
  async commandAction(logger, args) {
32
32
  await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_LIST, commands.M365GROUP_USER_LIST);
33
33
  try {
34
- if (args.options.role === 'Guest') {
35
- await this.warn(logger, `Value 'Guest' for the option role is deprecated. Use --filter "userType eq 'Guest'" instead.`);
36
- }
37
34
  const groupId = await this.getGroupId(args.options, logger);
38
35
  const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
39
36
  if (!isUnifiedGroup) {
@@ -42,9 +39,9 @@ class EntraM365GroupUserListCommand extends GraphCommand {
42
39
  let users = [];
43
40
  if (!args.options.role || args.options.role === 'Owner') {
44
41
  const owners = await this.getUsers(args.options, 'Owners', groupId, logger);
45
- owners.forEach(owner => users.push({ ...owner, roles: ['Owner'], userType: 'Owner' }));
42
+ owners.forEach(owner => users.push({ ...owner, roles: ['Owner'] }));
46
43
  }
47
- if (!args.options.role || args.options.role === 'Member' || args.options.role === 'Guest') {
44
+ if (!args.options.role || args.options.role === 'Member') {
48
45
  const members = await this.getUsers(args.options, 'Members', groupId, logger);
49
46
  members.forEach((member) => {
50
47
  const user = users.find((u) => u.id === member.id);
@@ -57,7 +54,7 @@ class EntraM365GroupUserListCommand extends GraphCommand {
57
54
  });
58
55
  }
59
56
  if (args.options.role) {
60
- users = users.filter(i => i.userType === args.options.role);
57
+ users = users.filter(i => i.roles.indexOf(args.options.role) > -1);
61
58
  }
62
59
  await logger.log(users);
63
60
  }
@@ -128,7 +125,7 @@ _EntraM365GroupUserListCommand_instances = new WeakSet(), _EntraM365GroupUserLis
128
125
  option: "-n, --groupDisplayName [groupDisplayName]"
129
126
  }, {
130
127
  option: "-r, --role [type]",
131
- autocomplete: ["Owner", "Member", "Guest"]
128
+ autocomplete: ["Owner", "Member"]
132
129
  }, {
133
130
  option: "-p, --properties [properties]"
134
131
  }, {
@@ -144,8 +141,8 @@ _EntraM365GroupUserListCommand_instances = new WeakSet(), _EntraM365GroupUserLis
144
141
  return `${args.options.groupId} is not a valid GUID`;
145
142
  }
146
143
  if (args.options.role) {
147
- if (['Owner', 'Member', 'Guest'].indexOf(args.options.role) === -1) {
148
- return `${args.options.role} is not a valid role value. Allowed values Owner|Member|Guest`;
144
+ if (['Owner', 'Member'].indexOf(args.options.role) === -1) {
145
+ return `${args.options.role} is not a valid role value. Allowed values Owner|Member`;
149
146
  }
150
147
  }
151
148
  return true;