@pnp/cli-microsoft365 7.8.0-beta.5f64790 → 7.8.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.
Files changed (49) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/cli/cli.js +3 -6
  4. package/dist/m365/entra/commands/app/app-permission-add.js +25 -6
  5. package/dist/m365/entra/commands/app/app-permission-list.js +17 -5
  6. package/dist/m365/entra/commands/group/group-add.js +12 -14
  7. package/dist/m365/entra/commands/group/group-user-add.js +6 -7
  8. package/dist/m365/entra/commands/user/user-registrationdetails-list.js +6 -7
  9. package/dist/m365/planner/commands/bucket/bucket-add.js +4 -7
  10. package/dist/m365/planner/commands/bucket/bucket-get.js +7 -30
  11. package/dist/m365/planner/commands/bucket/bucket-list.js +3 -6
  12. package/dist/m365/planner/commands/bucket/bucket-remove.js +8 -25
  13. package/dist/m365/planner/commands/bucket/bucket-set.js +12 -34
  14. package/dist/m365/planner/commands/plan/plan-add.js +17 -7
  15. package/dist/m365/planner/commands/plan/plan-get.js +12 -22
  16. package/dist/m365/planner/commands/plan/plan-list.js +1 -2
  17. package/dist/m365/planner/commands/plan/plan-remove.js +5 -3
  18. package/dist/m365/planner/commands/plan/plan-set.js +18 -10
  19. package/dist/m365/planner/commands/roster/roster-add.js +1 -2
  20. package/dist/m365/planner/commands/task/task-add.js +15 -21
  21. package/dist/m365/planner/commands/task/task-checklistitem-add.js +1 -1
  22. package/dist/m365/planner/commands/task/task-checklistitem-remove.js +1 -1
  23. package/dist/m365/planner/commands/task/task-get.js +5 -26
  24. package/dist/m365/planner/commands/task/task-list.js +11 -37
  25. package/dist/m365/planner/commands/task/task-reference-remove.js +1 -1
  26. package/dist/m365/planner/commands/task/task-remove.js +12 -29
  27. package/dist/m365/planner/commands/task/task-set.js +15 -21
  28. package/dist/m365/spfx/commands/project/project-doctor/{doctor-1.19.0-beta.0.js → doctor-1.19.0.js} +1 -1
  29. package/dist/m365/spfx/commands/project/project-doctor.js +1 -1
  30. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.19.0-beta.0.js → upgrade-1.19.0.js} +22 -22
  31. package/dist/m365/spfx/commands/project/project-upgrade.js +13 -15
  32. package/dist/m365/spfx/commands/spfx-doctor.js +1 -1
  33. package/dist/m365/spo/commands/listitem/listitem-batch-remove.js +222 -0
  34. package/dist/m365/spo/commands/navigation/navigation-node-add.js +3 -2
  35. package/dist/m365/spo/commands/navigation/navigation-node-set.js +3 -2
  36. package/dist/m365/spo/commands/site/site-recyclebinitem-move.js +5 -2
  37. package/dist/m365/spo/commands/site/site-recyclebinitem-remove.js +3 -2
  38. package/dist/m365/spo/commands/spo-set.js +6 -2
  39. package/dist/m365/spo/commands.js +1 -0
  40. package/dist/m365/teams/commands/meeting/meeting-add.js +3 -3
  41. package/dist/m365/teams/commands/team/team-add.js +22 -16
  42. package/dist/utils/planner.js +87 -8
  43. package/dist/utils/validation.js +8 -5
  44. package/docs/docs/cmd/entra/app/app-permission-add.mdx +7 -4
  45. package/docs/docs/cmd/entra/app/app-permission-list.mdx +14 -5
  46. package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
  47. package/docs/docs/cmd/spo/listitem/listitem-batch-remove.mdx +70 -0
  48. package/npm-shrinkwrap.json +168 -228
  49. package/package.json +17 -17
package/dist/cli/cli.js CHANGED
@@ -748,13 +748,10 @@ async function closeWithError(error, args, showHelpIfEnabled = false) {
748
748
  exitCode = error.code;
749
749
  }
750
750
  await cli.error(errorMessage);
751
- if (showHelpIfEnabled &&
752
- cli.getSettingWithDefaultValue(settingsNames.showHelpOnFailure, showHelpIfEnabled)) {
753
- await printHelp(await getHelpMode(args.options), exitCode);
754
- }
755
- else {
756
- process.exit(exitCode);
751
+ if (showHelpIfEnabled && cli.getSettingWithDefaultValue(settingsNames.showHelpOnFailure, showHelpIfEnabled)) {
752
+ await cli.error(`Run 'm365 ${cli.commandToExecute.name} -h' for help.`);
757
753
  }
754
+ process.exit(exitCode);
758
755
  // will never be run. Required for testing where we're stubbing process.exit
759
756
  /* c8 ignore next */
760
757
  throw new Error(errorMessage);
@@ -10,6 +10,8 @@ import commands from "../../commands.js";
10
10
  import request from "../../../../request.js";
11
11
  import { validation } from "../../../../utils/validation.js";
12
12
  import aadCommands from "../../aadCommands.js";
13
+ import { formatting } from "../../../../utils/formatting.js";
14
+ import { cli } from "../../../../cli/cli.js";
13
15
  var ScopeType;
14
16
  (function (ScopeType) {
15
17
  ScopeType["Role"] = "Role";
@@ -68,11 +70,27 @@ class EntraAppPermissionAddCommand extends GraphCommand {
68
70
  }
69
71
  }
70
72
  async getAppObject(options) {
71
- const apps = options.appObjectId
72
- ? await odata.getAllItems(`${this.resource}/v1.0/applications?$filter=id eq '${options.appObjectId}'&$select=id,appId,requiredResourceAccess`)
73
- : await odata.getAllItems(`${this.resource}/v1.0/applications?$filter=appId eq '${options.appId}'&$select=id,appId,requiredResourceAccess`);
73
+ let appNotFoundMessage = '';
74
+ let apps = [];
75
+ if (options.appId) {
76
+ apps = await odata.getAllItems(`${this.resource}/v1.0/applications?$filter=appId eq '${options.appId}'&$select=id,appId,requiredResourceAccess`);
77
+ appNotFoundMessage = `client id ${options.appId}`;
78
+ }
79
+ else if (options.appName) {
80
+ apps = await odata.getAllItems(`${this.resource}/v1.0/applications?$filter=displayName eq '${formatting.encodeQueryParameter(options.appName)}'&$select=id,appId,requiredResourceAccess`);
81
+ appNotFoundMessage = `name ${options.appName}`;
82
+ if (apps.length > 1) {
83
+ const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', apps);
84
+ const result = await cli.handleMultipleResultsFound(`Multiple Entra application registrations with name '${options.appName}' found.`, resultAsKeyValuePair);
85
+ return result;
86
+ }
87
+ }
88
+ else if (options.appObjectId) {
89
+ apps = await odata.getAllItems(`${this.resource}/v1.0/applications?$filter=id eq '${options.appObjectId}'&$select=id,appId,requiredResourceAccess`);
90
+ appNotFoundMessage = `object id ${options.appObjectId}`;
91
+ }
74
92
  if (apps.length === 0) {
75
- throw `App with ${options.appObjectId ? 'object id' : 'client id'} ${options.appObjectId ? options.appObjectId : options.appId} not found in Microsoft Entra ID`;
93
+ throw `App with ${appNotFoundMessage} not found in Microsoft Entra ID`;
76
94
  }
77
95
  return apps[0];
78
96
  }
@@ -209,6 +227,7 @@ _EntraAppPermissionAddCommand_instances = new WeakSet(), _EntraAppPermissionAddC
209
227
  this.telemetry.push((args) => {
210
228
  Object.assign(this.telemetryProperties, {
211
229
  appId: typeof args.options.appId !== 'undefined',
230
+ appName: typeof args.options.appName !== 'undefined',
212
231
  appObjectId: typeof args.options.appObjectId !== 'undefined',
213
232
  applicationPermissions: typeof args.options.applicationPermissions !== 'undefined',
214
233
  delegatedPermissions: typeof args.options.delegatedPermissions !== 'undefined',
@@ -216,7 +235,7 @@ _EntraAppPermissionAddCommand_instances = new WeakSet(), _EntraAppPermissionAddC
216
235
  });
217
236
  });
218
237
  }, _EntraAppPermissionAddCommand_initOptions = function _EntraAppPermissionAddCommand_initOptions() {
219
- this.options.unshift({ option: '-i, --appId [appId]' }, { option: '--appObjectId [appObjectId]' }, { option: '-a, --applicationPermissions [applicationPermissions]' }, { option: '-d, --delegatedPermissions [delegatedPermissions]' }, { option: '--grantAdminConsent' });
238
+ this.options.unshift({ option: '-i, --appId [appId]' }, { option: '-n, --appName [appName]' }, { option: '--appObjectId [appObjectId]' }, { option: '-a, --applicationPermissions [applicationPermissions]' }, { option: '-d, --delegatedPermissions [delegatedPermissions]' }, { option: '--grantAdminConsent' });
220
239
  }, _EntraAppPermissionAddCommand_initValidators = function _EntraAppPermissionAddCommand_initValidators() {
221
240
  this.validators.push(async (args) => {
222
241
  if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
@@ -228,7 +247,7 @@ _EntraAppPermissionAddCommand_instances = new WeakSet(), _EntraAppPermissionAddC
228
247
  return true;
229
248
  });
230
249
  }, _EntraAppPermissionAddCommand_initOptionSets = function _EntraAppPermissionAddCommand_initOptionSets() {
231
- this.optionSets.push({ options: ['appId', 'appObjectId'] });
250
+ this.optionSets.push({ options: ['appId', 'appName', 'appObjectId'] });
232
251
  this.optionSets.push({
233
252
  options: ['applicationPermissions', 'delegatedPermissions'],
234
253
  runsWhen: (args) => args.options.delegatedPermissions === undefined && args.options.applicationPermissions === undefined
@@ -9,6 +9,7 @@ import commands from "../../commands.js";
9
9
  import request from "../../../../request.js";
10
10
  import { validation } from "../../../../utils/validation.js";
11
11
  import { formatting } from "../../../../utils/formatting.js";
12
+ import { cli } from "../../../../cli/cli.js";
12
13
  class EntraAppPermissionListCommand extends GraphCommand {
13
14
  get name() {
14
15
  return commands.APP_PERMISSION_LIST;
@@ -40,18 +41,28 @@ class EntraAppPermissionListCommand extends GraphCommand {
40
41
  if (options.appObjectId) {
41
42
  return options.appObjectId;
42
43
  }
44
+ const { appId, appName } = options;
45
+ const filter = appId ?
46
+ `appId eq '${formatting.encodeQueryParameter(appId)}'` :
47
+ `displayName eq '${formatting.encodeQueryParameter(appName)}'`;
43
48
  const requestOptions = {
44
- url: `${this.resource}/v1.0/myorganization/applications?$filter=appId eq '${formatting.encodeQueryParameter(options.appId)}'&$select=id`,
49
+ url: `${this.resource}/v1.0/myorganization/applications?$filter=${filter}&$select=id`,
45
50
  headers: {
46
51
  accept: 'application/json;odata.metadata=none'
47
52
  },
48
53
  responseType: 'json'
49
54
  };
50
55
  const res = await request.get(requestOptions);
56
+ if (res.value.length === 1) {
57
+ return res.value[0].id;
58
+ }
51
59
  if (res.value.length === 0) {
52
- throw `No Microsoft Entra application registration with ID ${options.appId} found`;
60
+ const applicationIdentifier = appId ? `ID ${appId}` : `name ${appName}`;
61
+ throw `No Microsoft Entra application registration with ${applicationIdentifier} found`;
53
62
  }
54
- return res.value[0].id;
63
+ const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', res.value);
64
+ const result = await cli.handleMultipleResultsFound(`Multiple Entra application registrations with name '${appName}' found.`, resultAsKeyValuePair);
65
+ return result.id;
55
66
  }
56
67
  async getAppRegPermissions(appObjectId, permissionType, logger) {
57
68
  const requestOptions = {
@@ -156,12 +167,13 @@ _EntraAppPermissionListCommand_instances = new WeakSet(), _EntraAppPermissionLis
156
167
  this.telemetry.push((args) => {
157
168
  Object.assign(this.telemetryProperties, {
158
169
  appId: typeof args.options.appId !== 'undefined',
170
+ appName: typeof args.options.appName !== 'undefined',
159
171
  appObjectId: typeof args.options.appObjectId !== 'undefined',
160
172
  type: typeof args.options.type !== 'undefined'
161
173
  });
162
174
  });
163
175
  }, _EntraAppPermissionListCommand_initOptions = function _EntraAppPermissionListCommand_initOptions() {
164
- this.options.unshift({ option: '-i, --appId [appId]' }, { option: '--appObjectId [appObjectId]' }, { option: '--type [type]', autocomplete: this.allowedTypes });
176
+ this.options.unshift({ option: '-i, --appId [appId]' }, { option: '-n, --appName [appName]' }, { option: '--appObjectId [appObjectId]' }, { option: '--type [type]', autocomplete: this.allowedTypes });
165
177
  }, _EntraAppPermissionListCommand_initValidators = function _EntraAppPermissionListCommand_initValidators() {
166
178
  this.validators.push(async (args) => {
167
179
  if (args.options.appId && !validation.isValidGuid(args.options.appId)) {
@@ -176,7 +188,7 @@ _EntraAppPermissionListCommand_instances = new WeakSet(), _EntraAppPermissionLis
176
188
  return true;
177
189
  });
178
190
  }, _EntraAppPermissionListCommand_initOptionSets = function _EntraAppPermissionListCommand_initOptionSets() {
179
- this.optionSets.push({ options: ['appId', 'appObjectId'] });
191
+ this.optionSets.push({ options: ['appId', 'appName', 'appObjectId'] });
180
192
  };
181
193
  export default new EntraAppPermissionListCommand();
182
194
  //# sourceMappingURL=app-permission-list.js.map
@@ -169,29 +169,27 @@ _EntraGroupAddCommand_instances = new WeakSet(), _EntraGroupAddCommand_initOptio
169
169
  }
170
170
  }
171
171
  if (args.options.ownerIds) {
172
- const ids = args.options.ownerIds.split(',').map(i => i.trim());
173
- if (!validation.isValidGuidArray(ids)) {
174
- const invalidGuid = ids.find(id => !validation.isValidGuid(id));
175
- return `'${invalidGuid}' is not a valid GUID for option 'ownerIds'.`;
172
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ownerIds);
173
+ if (isValidGUIDArrayResult !== true) {
174
+ return `The following GUIDs are invalid for the option 'ownerIds': ${isValidGUIDArrayResult}.`;
176
175
  }
177
176
  }
178
177
  if (args.options.ownerUserNames) {
179
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(args.options.ownerUserNames.split(',').map(u => u.trim()));
180
- if (isValidUserPrincipalNameArray !== true) {
181
- return `User principal name '${isValidUserPrincipalNameArray}' is invalid for option 'ownerUserNames'.`;
178
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.ownerUserNames);
179
+ if (isValidUPNArrayResult !== true) {
180
+ return `The following user principal names are invalid for the option 'ownerUserNames': ${isValidUPNArrayResult}.`;
182
181
  }
183
182
  }
184
183
  if (args.options.memberIds) {
185
- const ids = args.options.memberIds.split(',').map(i => i.trim());
186
- if (!validation.isValidGuidArray(ids)) {
187
- const invalidGuid = ids.find(id => !validation.isValidGuid(id));
188
- return `'${invalidGuid}' is not a valid GUID for option 'memberIds'.`;
184
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.memberIds);
185
+ if (isValidGUIDArrayResult !== true) {
186
+ return `The following GUIDs are invalid for the option 'memberIds': ${isValidGUIDArrayResult}.`;
189
187
  }
190
188
  }
191
189
  if (args.options.memberUserNames) {
192
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(args.options.memberUserNames.split(',').map(u => u.trim()));
193
- if (isValidUserPrincipalNameArray !== true) {
194
- return `User principal name '${isValidUserPrincipalNameArray}' is invalid for option 'memberUserNames'.`;
190
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.memberUserNames);
191
+ if (isValidUPNArrayResult !== true) {
192
+ return `The following user principal names are invalid for the option 'memberUserNames': ${isValidUPNArrayResult}.`;
195
193
  }
196
194
  }
197
195
  if (['microsoft365', 'security'].indexOf(args.options.type) === -1) {
@@ -119,16 +119,15 @@ _EntraGroupUserAddCommand_instances = new WeakSet(), _EntraGroupUserAddCommand_i
119
119
  return `${args.options.groupId} is not a valid GUID for option groupId.`;
120
120
  }
121
121
  if (args.options.ids) {
122
- const ids = args.options.ids.split(',').map(i => i.trim());
123
- if (!validation.isValidGuidArray(ids)) {
124
- const invalidGuid = ids.find(id => !validation.isValidGuid(id));
125
- return `'${invalidGuid}' is not a valid GUID for option 'ids'.`;
122
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
123
+ if (isValidGUIDArrayResult !== true) {
124
+ return `The following GUIDs are invalid for the option 'ids': ${isValidGUIDArrayResult}.`;
126
125
  }
127
126
  }
128
127
  if (args.options.userNames) {
129
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(args.options.userNames.split(',').map(u => u.trim()));
130
- if (isValidUserPrincipalNameArray !== true) {
131
- return `User principal name '${isValidUserPrincipalNameArray}' is invalid for option 'userNames'.`;
128
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.userNames);
129
+ if (isValidUPNArrayResult !== true) {
130
+ return `The following user principal names are invalid for the option 'userNames': ${isValidUPNArrayResult}.`;
132
131
  }
133
132
  }
134
133
  if (this.roleValues.indexOf(args.options.role) === -1) {
@@ -205,16 +205,15 @@ _EntraUserRegistrationDetailsListCommand_instances = new WeakSet(), _EntraUserRe
205
205
  }
206
206
  }
207
207
  if (args.options.userIds) {
208
- const ids = args.options.userIds.split(',').map(i => i.trim());
209
- if (!validation.isValidGuidArray(ids)) {
210
- const invalidGuid = ids.find(id => !validation.isValidGuid(id));
211
- return `'${invalidGuid}' is not a valid GUID for option 'userIds'.`;
208
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.userIds);
209
+ if (isValidGUIDArrayResult !== true) {
210
+ return `The following GUIDs are invalid for the option 'userIds': ${isValidGUIDArrayResult}.`;
212
211
  }
213
212
  }
214
213
  if (args.options.userPrincipalNames) {
215
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(args.options.userPrincipalNames.split(',').map(u => u.trim()));
216
- if (isValidUserPrincipalNameArray !== true) {
217
- return `User principal name '${isValidUserPrincipalNameArray}' is invalid for option 'userPrincipalNames'.`;
214
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.userPrincipalNames);
215
+ if (isValidUPNArrayResult !== true) {
216
+ return `The following user principal names are invalid for the option 'userPrincipalNames': ${isValidUPNArrayResult}.`;
218
217
  }
219
218
  }
220
219
  return true;
@@ -35,7 +35,7 @@ class PlannerBucketAddCommand extends GraphCommand {
35
35
  const requestOptions = {
36
36
  url: `${this.resource}/v1.0/planner/buckets`,
37
37
  headers: {
38
- 'accept': 'application/json;odata.metadata=none'
38
+ accept: 'application/json;odata.metadata=none'
39
39
  },
40
40
  responseType: 'json',
41
41
  data: {
@@ -57,18 +57,15 @@ class PlannerBucketAddCommand extends GraphCommand {
57
57
  }
58
58
  if (args.options.planTitle) {
59
59
  const groupId = await this.getGroupId(args);
60
- const plan = await planner.getPlanByTitle(args.options.planTitle, groupId);
61
- return plan.id;
60
+ return planner.getPlanIdByTitle(args.options.planTitle, groupId);
62
61
  }
63
- const plan = await planner.getPlanByRosterId(args.options.rosterId);
64
- return plan.id;
62
+ return planner.getPlanIdByRosterId(args.options.rosterId);
65
63
  }
66
64
  async getGroupId(args) {
67
65
  if (args.options.ownerGroupId) {
68
66
  return args.options.ownerGroupId;
69
67
  }
70
- const group = await entraGroup.getGroupByDisplayName(args.options.ownerGroupName);
71
- return group.id;
68
+ return entraGroup.getGroupIdByDisplayName(args.options.ownerGroupName);
72
69
  }
73
70
  }
74
71
  _PlannerBucketAddCommand_instances = new WeakSet(), _PlannerBucketAddCommand_initTelemetry = function _PlannerBucketAddCommand_initTelemetry() {
@@ -10,8 +10,6 @@ import { planner } from '../../../../utils/planner.js';
10
10
  import { validation } from '../../../../utils/validation.js';
11
11
  import GraphCommand from '../../../base/GraphCommand.js';
12
12
  import commands from '../../commands.js';
13
- import { cli } from '../../../../cli/cli.js';
14
- import { formatting } from '../../../../utils/formatting.js';
15
13
  class PlannerBucketGetCommand extends GraphCommand {
16
14
  get name() {
17
15
  return commands.BUCKET_GET;
@@ -30,38 +28,20 @@ class PlannerBucketGetCommand extends GraphCommand {
30
28
  }
31
29
  async commandAction(logger, args) {
32
30
  try {
33
- const bucketId = await this.getBucketId(args);
34
- const bucket = await this.getBucketById(bucketId);
31
+ const bucket = await this.getBucket(args);
35
32
  await logger.log(bucket);
36
33
  }
37
34
  catch (err) {
38
35
  this.handleRejectedODataJsonPromise(err);
39
36
  }
40
37
  }
41
- async getBucketId(args) {
38
+ async getBucket(args) {
42
39
  const { id, name } = args.options;
43
40
  if (id) {
44
- return id;
41
+ return this.getBucketById(id);
45
42
  }
46
43
  const planId = await this.getPlanId(args);
47
- const requestOptions = {
48
- url: `${this.resource}/v1.0/planner/plans/${planId}/buckets`,
49
- headers: {
50
- accept: 'application/json;odata.metadata=none'
51
- },
52
- responseType: 'json'
53
- };
54
- const buckets = await request.get(requestOptions);
55
- const filteredBuckets = buckets.value.filter(b => name.toLowerCase() === b.name.toLowerCase());
56
- if (!filteredBuckets.length) {
57
- throw `The specified bucket ${name} does not exist`;
58
- }
59
- if (filteredBuckets.length > 1) {
60
- const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
61
- const result = await cli.handleMultipleResultsFound(`Multiple buckets with name '${name}' found.`, resultAsKeyValuePair);
62
- return result.id.toString();
63
- }
64
- return filteredBuckets[0].id.toString();
44
+ return planner.getBucketByTitle(name, planId);
65
45
  }
66
46
  async getPlanId(args) {
67
47
  const { planId, planTitle, rosterId } = args.options;
@@ -70,11 +50,9 @@ class PlannerBucketGetCommand extends GraphCommand {
70
50
  }
71
51
  if (planTitle) {
72
52
  const groupId = await this.getGroupId(args);
73
- const plan = await planner.getPlanByTitle(planTitle, groupId);
74
- return plan.id;
53
+ return planner.getPlanIdByTitle(planTitle, groupId);
75
54
  }
76
- const plan = await planner.getPlanByRosterId(rosterId);
77
- return plan.id;
55
+ return planner.getPlanIdByRosterId(rosterId);
78
56
  }
79
57
  async getBucketById(id) {
80
58
  const requestOptions = {
@@ -91,8 +69,7 @@ class PlannerBucketGetCommand extends GraphCommand {
91
69
  if (ownerGroupId) {
92
70
  return ownerGroupId;
93
71
  }
94
- const group = await entraGroup.getGroupByDisplayName(ownerGroupName);
95
- return group.id;
72
+ return entraGroup.getGroupIdByDisplayName(ownerGroupName);
96
73
  }
97
74
  }
98
75
  _PlannerBucketGetCommand_instances = new WeakSet(), _PlannerBucketGetCommand_initTelemetry = function _PlannerBucketGetCommand_initTelemetry() {
@@ -45,18 +45,15 @@ class PlannerBucketListCommand extends GraphCommand {
45
45
  }
46
46
  if (args.options.planTitle) {
47
47
  const groupId = await this.getGroupId(args);
48
- const plan = await planner.getPlanByTitle(args.options.planTitle, groupId);
49
- return plan.id;
48
+ return planner.getPlanIdByTitle(args.options.planTitle, groupId);
50
49
  }
51
- const plan = await planner.getPlanByRosterId(args.options.rosterId);
52
- return plan.id;
50
+ return planner.getPlanIdByRosterId(args.options.rosterId);
53
51
  }
54
52
  async getGroupId(args) {
55
53
  if (args.options.ownerGroupId) {
56
54
  return args.options.ownerGroupId;
57
55
  }
58
- const group = await entraGroup.getGroupByDisplayName(args.options.ownerGroupName);
59
- return group.id;
56
+ return entraGroup.getGroupIdByDisplayName(args.options.ownerGroupName);
60
57
  }
61
58
  }
62
59
  _PlannerBucketListCommand_instances = new WeakSet(), _PlannerBucketListCommand_initTelemetry = function _PlannerBucketListCommand_initTelemetry() {
@@ -11,7 +11,6 @@ import { planner } from '../../../../utils/planner.js';
11
11
  import { validation } from '../../../../utils/validation.js';
12
12
  import GraphCommand from '../../../base/GraphCommand.js';
13
13
  import commands from '../../commands.js';
14
- import { formatting } from '../../../../utils/formatting.js';
15
14
  class PlannerBucketRemoveCommand extends GraphCommand {
16
15
  get name() {
17
16
  return commands.BUCKET_REMOVE;
@@ -30,6 +29,9 @@ class PlannerBucketRemoveCommand extends GraphCommand {
30
29
  }
31
30
  async commandAction(logger, args) {
32
31
  const removeBucket = async () => {
32
+ if (this.verbose) {
33
+ await logger.logToStderr(`Removing bucket...`);
34
+ }
33
35
  try {
34
36
  const bucket = await this.getBucket(args);
35
37
  const requestOptions = {
@@ -61,30 +63,14 @@ class PlannerBucketRemoveCommand extends GraphCommand {
61
63
  const requestOptions = {
62
64
  url: `${this.resource}/v1.0/planner/buckets/${args.options.id}`,
63
65
  headers: {
64
- accept: 'application/json'
66
+ accept: 'application/json;odata.metadata=minimal'
65
67
  },
66
68
  responseType: 'json'
67
69
  };
68
70
  return await request.get(requestOptions);
69
71
  }
70
72
  const planId = await this.getPlanId(args);
71
- const requestOptions = {
72
- url: `${this.resource}/v1.0/planner/plans/${planId}/buckets`,
73
- headers: {
74
- accept: 'application/json'
75
- },
76
- responseType: 'json'
77
- };
78
- const buckets = await request.get(requestOptions);
79
- const filteredBuckets = buckets.value.filter(b => args.options.name.toLowerCase() === b.name.toLowerCase());
80
- if (!filteredBuckets.length) {
81
- throw `The specified bucket ${args.options.name} does not exist`;
82
- }
83
- if (filteredBuckets.length > 1) {
84
- const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
85
- return await cli.handleMultipleResultsFound(`Multiple buckets with name '${args.options.name}' found.`, resultAsKeyValuePair);
86
- }
87
- return filteredBuckets[0];
73
+ return planner.getBucketByTitle(args.options.name, planId, 'minimal');
88
74
  }
89
75
  async getPlanId(args) {
90
76
  const { planId, planTitle, rosterId } = args.options;
@@ -93,19 +79,16 @@ class PlannerBucketRemoveCommand extends GraphCommand {
93
79
  }
94
80
  if (planTitle) {
95
81
  const groupId = await this.getGroupId(args);
96
- const plan = await planner.getPlanByTitle(planTitle, groupId);
97
- return plan.id;
82
+ return planner.getPlanIdByTitle(planTitle, groupId);
98
83
  }
99
- const plan = await planner.getPlanByRosterId(rosterId);
100
- return plan.id;
84
+ return planner.getPlanIdByRosterId(rosterId);
101
85
  }
102
86
  async getGroupId(args) {
103
87
  const { ownerGroupId, ownerGroupName } = args.options;
104
88
  if (ownerGroupId) {
105
89
  return ownerGroupId;
106
90
  }
107
- const group = await entraGroup.getGroupByDisplayName(ownerGroupName);
108
- return group.id;
91
+ return entraGroup.getGroupIdByDisplayName(ownerGroupName);
109
92
  }
110
93
  }
111
94
  _PlannerBucketRemoveCommand_instances = new WeakSet(), _PlannerBucketRemoveCommand_initTelemetry = function _PlannerBucketRemoveCommand_initTelemetry() {
@@ -10,8 +10,6 @@ import { planner } from '../../../../utils/planner.js';
10
10
  import { validation } from '../../../../utils/validation.js';
11
11
  import GraphCommand from '../../../base/GraphCommand.js';
12
12
  import commands from '../../commands.js';
13
- import { cli } from '../../../../cli/cli.js';
14
- import { formatting } from '../../../../utils/formatting.js';
15
13
  class PlannerBucketSetCommand extends GraphCommand {
16
14
  get name() {
17
15
  return commands.BUCKET_SET;
@@ -29,6 +27,9 @@ class PlannerBucketSetCommand extends GraphCommand {
29
27
  __classPrivateFieldGet(this, _PlannerBucketSetCommand_instances, "m", _PlannerBucketSetCommand_initTypes).call(this);
30
28
  }
31
29
  async commandAction(logger, args) {
30
+ if (this.verbose) {
31
+ await logger.logToStderr(`Updating bucket...`);
32
+ }
32
33
  try {
33
34
  const bucket = await this.getBucket(args);
34
35
  const requestOptions = {
@@ -38,15 +39,11 @@ class PlannerBucketSetCommand extends GraphCommand {
38
39
  'if-match': bucket['@odata.etag']
39
40
  },
40
41
  responseType: 'json',
41
- data: {}
42
+ data: {
43
+ name: args.options.newName,
44
+ orderHint: args.options.orderHint
45
+ }
42
46
  };
43
- const { newName, orderHint } = args.options;
44
- if (newName) {
45
- requestOptions.data.name = newName;
46
- }
47
- if (orderHint) {
48
- requestOptions.data.orderHint = orderHint;
49
- }
50
47
  await request.patch(requestOptions);
51
48
  }
52
49
  catch (err) {
@@ -58,30 +55,14 @@ class PlannerBucketSetCommand extends GraphCommand {
58
55
  const requestOptions = {
59
56
  url: `${this.resource}/v1.0/planner/buckets/${args.options.id}`,
60
57
  headers: {
61
- accept: 'application/json'
58
+ accept: 'application/json;odata.metadata=minimal'
62
59
  },
63
60
  responseType: 'json'
64
61
  };
65
62
  return await request.get(requestOptions);
66
63
  }
67
64
  const planId = await this.getPlanId(args);
68
- const requestOptions = {
69
- url: `${this.resource}/v1.0/planner/plans/${planId}/buckets`,
70
- headers: {
71
- accept: 'application/json'
72
- },
73
- responseType: 'json'
74
- };
75
- const buckets = await request.get(requestOptions);
76
- const filteredBuckets = buckets.value.filter(b => args.options.name.toLowerCase() === b.name.toLowerCase());
77
- if (!filteredBuckets.length) {
78
- throw `The specified bucket ${args.options.name} does not exist`;
79
- }
80
- if (filteredBuckets.length > 1) {
81
- const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
82
- return await cli.handleMultipleResultsFound(`Multiple buckets with name '${args.options.name}' found.`, resultAsKeyValuePair);
83
- }
84
- return filteredBuckets[0];
65
+ return planner.getBucketByTitle(args.options.name, planId, 'minimal');
85
66
  }
86
67
  async getPlanId(args) {
87
68
  const { planId, planTitle, rosterId } = args.options;
@@ -90,19 +71,16 @@ class PlannerBucketSetCommand extends GraphCommand {
90
71
  }
91
72
  if (planTitle) {
92
73
  const groupId = await this.getGroupId(args);
93
- const plan = await planner.getPlanByTitle(planTitle, groupId);
94
- return plan.id;
74
+ return planner.getPlanIdByTitle(planTitle, groupId);
95
75
  }
96
- const plan = await planner.getPlanByRosterId(rosterId);
97
- return plan.id;
76
+ return planner.getPlanIdByRosterId(rosterId);
98
77
  }
99
78
  async getGroupId(args) {
100
79
  const { ownerGroupId, ownerGroupName } = args.options;
101
80
  if (ownerGroupId) {
102
81
  return ownerGroupId;
103
82
  }
104
- const group = await entraGroup.getGroupByDisplayName(ownerGroupName);
105
- return group.id;
83
+ return entraGroup.getGroupIdByDisplayName(ownerGroupName);
106
84
  }
107
85
  }
108
86
  _PlannerBucketSetCommand_instances = new WeakSet(), _PlannerBucketSetCommand_initTelemetry = function _PlannerBucketSetCommand_initTelemetry() {
@@ -37,12 +37,14 @@ class PlannerPlanAddCommand extends GraphCommand {
37
37
  };
38
38
  if (args.options.rosterId) {
39
39
  data.container = {
40
- "url": `https://graph.microsoft.com/v1.0/planner/rosters/${args.options.rosterId}`
40
+ url: `https://graph.microsoft.com/v1.0/planner/rosters/${args.options.rosterId}`
41
41
  };
42
42
  }
43
43
  else {
44
44
  const groupId = await this.getGroupId(args);
45
- data.owner = groupId;
45
+ data.container = {
46
+ url: `https://graph.microsoft.com/v1.0/groups/${groupId}`
47
+ };
46
48
  }
47
49
  const requestOptions = {
48
50
  url: `${this.resource}/v1.0/planner/plans`,
@@ -57,7 +59,7 @@ class PlannerPlanAddCommand extends GraphCommand {
57
59
  await logger.log(result);
58
60
  }
59
61
  catch (err) {
60
- if (err.error && err.error.error.message === "You do not have the required permissions to access this item, or the item may not exist.") {
62
+ if (args.options.rosterId && err.error?.error.message === "You do not have the required permissions to access this item, or the item may not exist.") {
61
63
  throw new CommandError("You can only add 1 plan to a Roster");
62
64
  }
63
65
  this.handleRejectedODataJsonPromise(err);
@@ -134,8 +136,7 @@ class PlannerPlanAddCommand extends GraphCommand {
134
136
  if (args.options.ownerGroupId) {
135
137
  return args.options.ownerGroupId;
136
138
  }
137
- const group = await entraGroup.getGroupByDisplayName(args.options.ownerGroupName);
138
- return group.id;
139
+ return entraGroup.getGroupIdByDisplayName(args.options.ownerGroupName);
139
140
  }
140
141
  }
141
142
  _PlannerPlanAddCommand_instances = new WeakSet(), _PlannerPlanAddCommand_initTelemetry = function _PlannerPlanAddCommand_initTelemetry() {
@@ -169,8 +170,17 @@ _PlannerPlanAddCommand_instances = new WeakSet(), _PlannerPlanAddCommand_initTel
169
170
  if (args.options.shareWithUserIds && args.options.shareWithUserNames) {
170
171
  return 'Specify either shareWithUserIds or shareWithUserNames but not both';
171
172
  }
172
- if (args.options.shareWithUserIds && !validation.isValidGuidArray(args.options.shareWithUserIds.split(','))) {
173
- return 'shareWithUserIds contains invalid GUID';
173
+ if (args.options.shareWithUserIds) {
174
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.shareWithUserIds);
175
+ if (isValidGUIDArrayResult !== true) {
176
+ return `The following GUIDs are invalid for the option 'shareWithUserIds': ${isValidGUIDArrayResult}.`;
177
+ }
178
+ }
179
+ if (args.options.shareWithUserNames) {
180
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.shareWithUserNames);
181
+ if (isValidUPNArrayResult !== true) {
182
+ return `The following user principal names are invalid for the option 'shareWithUserNames': ${isValidUPNArrayResult}.`;
183
+ }
174
184
  }
175
185
  return true;
176
186
  });