@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
@@ -7,8 +7,6 @@ var _SpfxProjectUpgradeCommand_instances, _a, _SpfxProjectUpgradeCommand_initTel
7
7
  import fs from 'fs';
8
8
  import os from 'os';
9
9
  import path from 'path';
10
- // uncomment to support upgrading to preview releases
11
- import { prerelease } from 'semver';
12
10
  import { CommandError } from '../../../../Command.js';
13
11
  import { fsUtil } from '../../../../utils/fsUtil.js';
14
12
  import { packageManager } from '../../../../utils/packageManager.js';
@@ -74,7 +72,7 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
74
72
  '1.18.0',
75
73
  '1.18.1',
76
74
  '1.18.2',
77
- '1.19.0-beta.0'
75
+ '1.19.0'
78
76
  ];
79
77
  __classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initTelemetry).call(this);
80
78
  __classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initOptions).call(this);
@@ -87,15 +85,15 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
87
85
  }
88
86
  this.toVersion = args.options.toVersion ? args.options.toVersion : this.supportedVersions[this.supportedVersions.length - 1];
89
87
  // uncomment to support upgrading to preview releases
90
- if (!args.options.toVersion &&
91
- !args.options.preview &&
92
- prerelease(this.toVersion)) {
93
- // no version and no preview specified while the current version to
94
- // upgrade to is a prerelease so let's grab the first non-preview version
95
- // since we're supporting only one preview version, it's sufficient for
96
- // us to take second to last version
97
- this.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
98
- }
88
+ // if (!args.options.toVersion &&
89
+ // !args.options.preview &&
90
+ // prerelease(this.toVersion)) {
91
+ // // no version and no preview specified while the current version to
92
+ // // upgrade to is a prerelease so let's grab the first non-preview version
93
+ // // since we're supporting only one preview version, it's sufficient for
94
+ // // us to take second to last version
95
+ // this.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
96
+ // }
99
97
  this.packageManager = args.options.packageManager || 'npm';
100
98
  this.shell = args.options.shell || 'bash';
101
99
  if (this.supportedVersions.indexOf(this.toVersion) < 0) {
@@ -484,9 +482,9 @@ _a = SpfxProjectUpgradeCommand, _SpfxProjectUpgradeCommand_instances = new WeakS
484
482
  preview: args.options.preview
485
483
  });
486
484
  // uncomment to support upgrading to preview releases
487
- if (prerelease(this.telemetryProperties.toVersion) && !args.options.preview) {
488
- this.telemetryProperties.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
489
- }
485
+ // if (prerelease(this.telemetryProperties.toVersion) && !args.options.preview) {
486
+ // this.telemetryProperties.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
487
+ // }
490
488
  });
491
489
  }, _SpfxProjectUpgradeCommand_initOptions = function _SpfxProjectUpgradeCommand_initOptions() {
492
490
  this.options.unshift({
@@ -561,7 +561,7 @@ class SpfxDoctorCommand extends BaseProjectCommand {
561
561
  fix: 'npm i -g yo@5'
562
562
  }
563
563
  },
564
- '1.19.0-beta.0': {
564
+ '1.19.0': {
565
565
  gulpCli: {
566
566
  range: '^1 || ^2',
567
567
  fix: 'npm i -g gulp-cli@2'
@@ -0,0 +1,222 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
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
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _SpoListItemBatchRemoveCommand_instances, _SpoListItemBatchRemoveCommand_initTelemetry, _SpoListItemBatchRemoveCommand_initOptions, _SpoListItemBatchRemoveCommand_initValidators, _SpoListItemBatchRemoveCommand_initTypes, _SpoListItemBatchRemoveCommand_initOptionSets;
7
+ import fs from 'fs';
8
+ import os from 'os';
9
+ import SpoCommand from '../../../base/SpoCommand.js';
10
+ import commands from '../../commands.js';
11
+ import { formatting } from '../../../../utils/formatting.js';
12
+ import { urlUtil } from '../../../../utils/urlUtil.js';
13
+ import { v4 } from 'uuid';
14
+ import request from '../../../../request.js';
15
+ import { validation } from '../../../../utils/validation.js';
16
+ import { cli } from '../../../../cli/cli.js';
17
+ class SpoListItemBatchRemoveCommand extends SpoCommand {
18
+ get name() {
19
+ return commands.LISTITEM_BATCH_REMOVE;
20
+ }
21
+ get description() {
22
+ return 'Removes items from a list in batch';
23
+ }
24
+ constructor() {
25
+ super();
26
+ _SpoListItemBatchRemoveCommand_instances.add(this);
27
+ __classPrivateFieldGet(this, _SpoListItemBatchRemoveCommand_instances, "m", _SpoListItemBatchRemoveCommand_initTelemetry).call(this);
28
+ __classPrivateFieldGet(this, _SpoListItemBatchRemoveCommand_instances, "m", _SpoListItemBatchRemoveCommand_initOptions).call(this);
29
+ __classPrivateFieldGet(this, _SpoListItemBatchRemoveCommand_instances, "m", _SpoListItemBatchRemoveCommand_initValidators).call(this);
30
+ __classPrivateFieldGet(this, _SpoListItemBatchRemoveCommand_instances, "m", _SpoListItemBatchRemoveCommand_initTypes).call(this);
31
+ __classPrivateFieldGet(this, _SpoListItemBatchRemoveCommand_instances, "m", _SpoListItemBatchRemoveCommand_initOptionSets).call(this);
32
+ }
33
+ async commandAction(logger, args) {
34
+ const removeListItems = async () => {
35
+ try {
36
+ if (this.verbose) {
37
+ logger.logToStderr('Removing the listitems from SharePoint...');
38
+ }
39
+ let idsToRemove = [];
40
+ if (args.options.filePath) {
41
+ const csvContent = fs.readFileSync(args.options.filePath, 'utf-8');
42
+ const jsonContent = formatting.parseCsvToJson(csvContent);
43
+ idsToRemove = jsonContent.map((item) => item['ID']);
44
+ }
45
+ else {
46
+ idsToRemove = formatting.splitAndTrim(args.options.ids);
47
+ }
48
+ await this.removeItemsAsBatch(idsToRemove, args.options, logger);
49
+ }
50
+ catch (err) {
51
+ this.handleRejectedODataJsonPromise(err);
52
+ }
53
+ };
54
+ if (args.options.force) {
55
+ await removeListItems();
56
+ }
57
+ else {
58
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to ${args.options.recycle ? "recycle" : "remove"} the list items from list ${args.options.listId || args.options.listTitle || args.options.listUrl} located in site ${args.options.webUrl}?` });
59
+ if (result) {
60
+ await removeListItems();
61
+ }
62
+ }
63
+ }
64
+ async removeItemsAsBatch(items, options, logger) {
65
+ const itemsChunks = this.getChunkedArray(items, 10);
66
+ for (const [index, chunk] of itemsChunks.entries()) {
67
+ if (this.verbose) {
68
+ await logger.logToStderr(`Processing chunk ${index + 1} of ${itemsChunks.length}...`);
69
+ }
70
+ await this.postBatchData(chunk, options.webUrl, options);
71
+ }
72
+ }
73
+ async postBatchData(chunk, webUrl, options) {
74
+ const batchId = v4();
75
+ const requestBody = this.getRequestBody(chunk, batchId, options);
76
+ const requestOptions = {
77
+ url: `${webUrl}/_api/$batch`,
78
+ headers: {
79
+ 'Content-Type': `multipart/mixed; boundary=batch_${batchId}`,
80
+ 'Accept': 'application/json;odata=verbose'
81
+ },
82
+ data: requestBody.join('')
83
+ };
84
+ const response = await request.post(requestOptions);
85
+ const errors = this.parseBatchResponseBody(response, chunk);
86
+ if (errors.length > 0) {
87
+ throw `Creating some items failed with the following errors: ${os.EOL}${errors.map(error => { return `- ${error}`; }).join(os.EOL)}`;
88
+ }
89
+ }
90
+ getRequestBody(chunk, batchId, options) {
91
+ const changeSetId = v4();
92
+ const batchBody = [];
93
+ batchBody.push(`--batch_${batchId}\n`);
94
+ batchBody.push(`Content-Type: multipart/mixed; boundary="changeset_${changeSetId}"\n\n`);
95
+ batchBody.push('Content-Transfer-Encoding: binary\n\n');
96
+ for (const item of chunk) {
97
+ const actionUrl = this.getActionUrl(options, item);
98
+ batchBody.push(`--changeset_${changeSetId}\n`);
99
+ batchBody.push('Content-Type: application/http\n');
100
+ batchBody.push('Content-Transfer-Encoding: binary\n\n');
101
+ batchBody.push(`DELETE ${actionUrl} HTTP/1.1\n`);
102
+ batchBody.push(`Accept: application/json;odata=nometadata\n`);
103
+ batchBody.push(`If-Match: *\n\n`);
104
+ }
105
+ batchBody.push(`\n\n`);
106
+ batchBody.push(`--changeset_${changeSetId}--\n\n`);
107
+ batchBody.push(`--batch_${batchId}--\n`);
108
+ return batchBody;
109
+ }
110
+ parseBatchResponseBody(response, chunk) {
111
+ const errors = [];
112
+ response.split('\r\n')
113
+ .filter((line) => line.startsWith('{'))
114
+ .forEach((line, index) => {
115
+ const parsedResponse = JSON.parse(line);
116
+ if (parsedResponse.error) {
117
+ const error = parsedResponse.error;
118
+ errors.push(`Item ID ${chunk[index]}: ${error.message.value}`);
119
+ }
120
+ });
121
+ return errors;
122
+ }
123
+ ;
124
+ getChunkedArray(inputArray, chunkSize) {
125
+ const result = [];
126
+ for (let i = 0; i < inputArray.length; i += chunkSize) {
127
+ result.push(inputArray.slice(i, i + chunkSize));
128
+ }
129
+ return result;
130
+ }
131
+ getActionUrl(options, item) {
132
+ let requestUrl = '';
133
+ if (options.listId) {
134
+ requestUrl += `lists(guid'${formatting.encodeQueryParameter(options.listId)}')`;
135
+ }
136
+ else if (options.listTitle) {
137
+ requestUrl += `lists/getByTitle('${formatting.encodeQueryParameter(options.listTitle)}')`;
138
+ }
139
+ else if (options.listUrl) {
140
+ const listServerRelativeUrl = urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
141
+ requestUrl += `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
142
+ }
143
+ requestUrl += `/items(${item})`;
144
+ if (options.recycle) {
145
+ requestUrl += '/recycle()';
146
+ }
147
+ return requestUrl;
148
+ }
149
+ }
150
+ _SpoListItemBatchRemoveCommand_instances = new WeakSet(), _SpoListItemBatchRemoveCommand_initTelemetry = function _SpoListItemBatchRemoveCommand_initTelemetry() {
151
+ this.telemetry.push((args) => {
152
+ Object.assign(this.telemetryProperties, {
153
+ filePath: typeof args.options.filePath !== 'undefined',
154
+ ids: typeof args.options.ids !== 'undefined',
155
+ listId: typeof args.options.listId !== 'undefined',
156
+ listTitle: typeof args.options.listTitle !== 'undefined',
157
+ listUrl: typeof args.options.listUrl !== 'undefined',
158
+ recycle: !!args.options.recycle,
159
+ force: !!args.options.force
160
+ });
161
+ });
162
+ }, _SpoListItemBatchRemoveCommand_initOptions = function _SpoListItemBatchRemoveCommand_initOptions() {
163
+ this.options.unshift({
164
+ option: '-u, --webUrl <webUrl>'
165
+ }, {
166
+ option: '-l, --listId [listId]'
167
+ }, {
168
+ option: '-t, --listTitle [listTitle]'
169
+ }, {
170
+ option: '--listUrl [listUrl]'
171
+ }, {
172
+ option: '-p, --filePath [filePath]'
173
+ }, {
174
+ option: '-i, --ids [ids]'
175
+ }, {
176
+ option: '-r, --recycle'
177
+ }, {
178
+ option: '-f, --force'
179
+ });
180
+ }, _SpoListItemBatchRemoveCommand_initValidators = function _SpoListItemBatchRemoveCommand_initValidators() {
181
+ this.validators.push(async (args) => {
182
+ const isValidSharePointUrl = validation.isValidSharePointUrl(args.options.webUrl);
183
+ if (isValidSharePointUrl !== true) {
184
+ return isValidSharePointUrl;
185
+ }
186
+ if (args.options.listId &&
187
+ !validation.isValidGuid(args.options.listId)) {
188
+ return `${args.options.listId} in option listId is not a valid GUID.`;
189
+ }
190
+ if (args.options.filePath) {
191
+ if (!fs.existsSync(args.options.filePath)) {
192
+ return `File with path ${args.options.filePath} does not exist.`;
193
+ }
194
+ const fileContent = fs.readFileSync(args.options.filePath, 'utf-8');
195
+ const jsonContent = formatting.parseCsvToJson(fileContent);
196
+ if (!jsonContent[0].hasOwnProperty('ID')) {
197
+ return `The file does not contain the required header row with the column name 'ID'.`;
198
+ }
199
+ const nonNumbers = jsonContent.filter(element => isNaN(Number(element['ID'].toString().trim()))).map(element => element['ID']);
200
+ if (nonNumbers.length > 0) {
201
+ return `The specified ids '${nonNumbers.join(', ')}' are invalid numbers.`;
202
+ }
203
+ }
204
+ if (args.options.ids) {
205
+ const nonNumbers = formatting.splitAndTrim(args.options.ids).filter(element => isNaN(Number(element)));
206
+ if (nonNumbers.length > 0) {
207
+ return `The specified ids '${nonNumbers.join(', ')}' are invalid numbers.`;
208
+ }
209
+ }
210
+ return true;
211
+ });
212
+ }, _SpoListItemBatchRemoveCommand_initTypes = function _SpoListItemBatchRemoveCommand_initTypes() {
213
+ this.types.string.push('webUrl', 'listId', 'listTitle', 'listUrl', 'ids', 'filePath');
214
+ }, _SpoListItemBatchRemoveCommand_initOptionSets = function _SpoListItemBatchRemoveCommand_initOptionSets() {
215
+ this.optionSets.push({
216
+ options: ['listId', 'listTitle', 'listUrl']
217
+ }, {
218
+ options: ['filePath', 'ids']
219
+ });
220
+ };
221
+ export default new SpoListItemBatchRemoveCommand();
222
+ //# sourceMappingURL=listitem-batch-remove.js.map
@@ -135,8 +135,9 @@ _SpoNavigationNodeAddCommand_instances = new WeakSet(), _SpoNavigationNodeAddCom
135
135
  if (audienceIdsSplitted.length > 10) {
136
136
  return 'The maximum amount of audienceIds per navigation node exceeded. The maximum amount of auciendeIds is 10.';
137
137
  }
138
- if (!validation.isValidGuidArray(audienceIdsSplitted)) {
139
- return 'The option audienceIds contains one or more invalid GUIDs';
138
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.audienceIds);
139
+ if (isValidGUIDArrayResult !== true) {
140
+ return `The following GUIDs are invalid for the option 'audienceIds': ${isValidGUIDArrayResult}.`;
140
141
  }
141
142
  }
142
143
  return true;
@@ -127,8 +127,9 @@ _SpoNavigationNodeSetCommand_instances = new WeakSet(), _SpoNavigationNodeSetCom
127
127
  if (audienceIdsSplitted.length > 10) {
128
128
  return 'The maximum amount of audienceIds per navigation node exceeded. The maximum amount of audienceIds is 10.';
129
129
  }
130
- if (!validation.isValidGuidArray(audienceIdsSplitted)) {
131
- return `The option audienceIds contains one or more invalid GUIDs`;
130
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.audienceIds);
131
+ if (isValidGUIDArrayResult !== true) {
132
+ return `The following GUIDs are invalid for the option 'audienceIds': ${isValidGUIDArrayResult}.`;
132
133
  }
133
134
  }
134
135
  return true;
@@ -89,8 +89,11 @@ _SpoSiteRecycleBinItemMoveCommand_instances = new WeakSet(), _SpoSiteRecycleBinI
89
89
  if (isValidSharePointUrl !== true) {
90
90
  return isValidSharePointUrl;
91
91
  }
92
- if (args.options.ids && !validation.isValidGuidArray(args.options.ids.split(','))) {
93
- return 'The option ids contains one or more invalid GUIDs';
92
+ if (args.options.ids) {
93
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
94
+ if (isValidGUIDArrayResult !== true) {
95
+ return `The following GUIDs are invalid for the option 'ids': ${isValidGUIDArrayResult}.`;
96
+ }
94
97
  }
95
98
  return true;
96
99
  });
@@ -76,8 +76,9 @@ _SpoSiteRecycleBinItemRemoveCommand_instances = new WeakSet(), _SpoSiteRecycleBi
76
76
  if (isValidSharePointUrl !== true) {
77
77
  return isValidSharePointUrl;
78
78
  }
79
- if (!validation.isValidGuidArray(args.options.ids.split(','))) {
80
- return 'The option ids contains one or more invalid GUIDs.';
79
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
80
+ if (isValidGUIDArrayResult !== true) {
81
+ return `The following GUIDs are invalid for the option 'ids': ${isValidGUIDArrayResult}.`;
81
82
  }
82
83
  return true;
83
84
  });
@@ -3,8 +3,9 @@ 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 _SpoSetCommand_instances, _SpoSetCommand_initOptions, _SpoSetCommand_initValidators;
6
+ var _SpoSetCommand_instances, _SpoSetCommand_initOptions, _SpoSetCommand_initValidators, _SpoSetCommand_initTypes;
7
7
  import auth from '../../../Auth.js';
8
+ import { urlUtil } from '../../../utils/urlUtil.js';
8
9
  import { validation } from '../../../utils/validation.js';
9
10
  import SpoCommand from '../../base/SpoCommand.js';
10
11
  import commands from '../commands.js';
@@ -20,9 +21,10 @@ class SpoSetCommand extends SpoCommand {
20
21
  _SpoSetCommand_instances.add(this);
21
22
  __classPrivateFieldGet(this, _SpoSetCommand_instances, "m", _SpoSetCommand_initOptions).call(this);
22
23
  __classPrivateFieldGet(this, _SpoSetCommand_instances, "m", _SpoSetCommand_initValidators).call(this);
24
+ __classPrivateFieldGet(this, _SpoSetCommand_instances, "m", _SpoSetCommand_initTypes).call(this);
23
25
  }
24
26
  async commandAction(logger, args) {
25
- auth.connection.spoUrl = args.options.url;
27
+ auth.connection.spoUrl = urlUtil.removeTrailingSlashes(args.options.url);
26
28
  try {
27
29
  await auth.storeConnectionInfo();
28
30
  }
@@ -37,6 +39,8 @@ _SpoSetCommand_instances = new WeakSet(), _SpoSetCommand_initOptions = function
37
39
  });
38
40
  }, _SpoSetCommand_initValidators = function _SpoSetCommand_initValidators() {
39
41
  this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.url));
42
+ }, _SpoSetCommand_initTypes = function _SpoSetCommand_initTypes() {
43
+ this.types.string.push('url');
40
44
  };
41
45
  export default new SpoSetCommand();
42
46
  //# sourceMappingURL=spo-set.js.map
@@ -164,6 +164,7 @@ export default {
164
164
  LISTITEM_ATTACHMENT_REMOVE: `${prefix} listitem attachment remove`,
165
165
  LISTITEM_ATTACHMENT_SET: `${prefix} listitem attachment set`,
166
166
  LISTITEM_BATCH_ADD: `${prefix} listitem batch add`,
167
+ LISTITEM_BATCH_REMOVE: `${prefix} listitem batch remove`,
167
168
  LISTITEM_BATCH_SET: `${prefix} listitem batch set`,
168
169
  LISTITEM_GET: `${prefix} listitem get`,
169
170
  LISTITEM_ISRECORD: `${prefix} listitem isrecord`,
@@ -136,9 +136,9 @@ _TeamsMeetingAddCommand_instances = new WeakSet(), _TeamsMeetingAddCommand_initT
136
136
  return 'The endTime value must be in the future.';
137
137
  }
138
138
  if (args.options.participantUserNames) {
139
- const participants = args.options.participantUserNames.trim().toLowerCase().split(',').filter(e => e && e !== '');
140
- if (!participants || participants.length === 0 || participants.some(e => !validation.isValidUserPrincipalName(e))) {
141
- return `'${args.options.participantUserNames}' contains one or more invalid UPN.`;
139
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.participantUserNames);
140
+ if (isValidUPNArrayResult !== true) {
141
+ return `The following user principal names are invalid for the option 'participantUserNames': ${isValidUPNArrayResult}.`;
142
142
  }
143
143
  }
144
144
  if (args.options.organizerEmail && !validation.isValidUserPrincipalName(args.options.organizerEmail)) {
@@ -226,34 +226,40 @@ _TeamsTeamAddCommand_instances = new WeakSet(), _TeamsTeamAddCommand_initTelemet
226
226
  }, _TeamsTeamAddCommand_initValidators = function _TeamsTeamAddCommand_initValidators() {
227
227
  this.validators.push(async (args) => {
228
228
  if (args.options.ownerUserNames) {
229
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(formatting.splitAndTrim(args.options.ownerUserNames));
230
- if (isValidUserPrincipalNameArray !== true) {
231
- return `Owner username '${isValidUserPrincipalNameArray}' is invalid for option 'ownerUserNames'.`;
229
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.ownerUserNames);
230
+ if (isValidUPNArrayResult !== true) {
231
+ return `The following user principal names are invalid for the option 'ownerUserNames': ${isValidUPNArrayResult}.`;
232
232
  }
233
233
  }
234
234
  if (args.options.ownerEmails) {
235
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(formatting.splitAndTrim(args.options.ownerEmails));
236
- if (isValidUserPrincipalNameArray !== true) {
237
- return `Owner email '${isValidUserPrincipalNameArray}' is invalid for option 'ownerEmails'.`;
235
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.ownerEmails);
236
+ if (isValidUPNArrayResult !== true) {
237
+ return `The following user principal names are invalid for the option 'ownerEmails': ${isValidUPNArrayResult}.`;
238
238
  }
239
239
  }
240
- if (args.options.ownerIds && !validation.isValidGuidArray(formatting.splitAndTrim(args.options.ownerIds))) {
241
- return `The option 'ownerIds' contains one or more invalid GUIDs.`;
240
+ if (args.options.ownerIds) {
241
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ownerIds);
242
+ if (isValidGUIDArrayResult !== true) {
243
+ return `The following GUIDs are invalid for the option 'ownerIds': ${isValidGUIDArrayResult}.`;
244
+ }
242
245
  }
243
246
  if (args.options.memberUserNames) {
244
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(formatting.splitAndTrim(args.options.memberUserNames));
245
- if (isValidUserPrincipalNameArray !== true) {
246
- return `Member username '${isValidUserPrincipalNameArray}' is invalid for option 'memberUserNames'.`;
247
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.memberUserNames);
248
+ if (isValidUPNArrayResult !== true) {
249
+ return `The following user principal names are invalid for the option 'memberUserNames': ${isValidUPNArrayResult}.`;
247
250
  }
248
251
  }
249
252
  if (args.options.memberEmails) {
250
- const isValidUserPrincipalNameArray = validation.isValidUserPrincipalNameArray(formatting.splitAndTrim(args.options.memberEmails));
251
- if (isValidUserPrincipalNameArray !== true) {
252
- return `Member email '${isValidUserPrincipalNameArray}' is invalid for option 'memberEmails'.`;
253
+ const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.memberEmails);
254
+ if (isValidUPNArrayResult !== true) {
255
+ return `The following user principal names are invalid for the option 'memberEmails': ${isValidUPNArrayResult}.`;
253
256
  }
254
257
  }
255
- if (args.options.memberIds && !validation.isValidGuidArray(formatting.splitAndTrim(args.options.memberIds))) {
256
- return `The option 'memberIds' contains one or more invalid GUIDs`;
258
+ if (args.options.memberIds) {
259
+ const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.memberIds);
260
+ if (isValidGUIDArrayResult !== true) {
261
+ return `The following GUIDs are invalid for the option 'memberIds': ${isValidGUIDArrayResult}.`;
262
+ }
257
263
  }
258
264
  return true;
259
265
  });
@@ -1,4 +1,6 @@
1
+ import { cli } from "../cli/cli.js";
1
2
  import request from "../request.js";
3
+ import { formatting } from "./formatting.js";
2
4
  import { odata } from "./odata.js";
3
5
  const graphResource = 'https://graph.microsoft.com';
4
6
  const getRequestOptions = (url, metadata) => ({
@@ -12,7 +14,8 @@ export const planner = {
12
14
  /**
13
15
  * Get Planner plan by ID.
14
16
  * @param id Planner ID.
15
- * @param metadata OData metadata level. Default is none
17
+ * @param metadata OData metadata level. Default is none.
18
+ * @throws Error when the plan is not found.
16
19
  */
17
20
  async getPlanById(id, metadata = 'none') {
18
21
  const requestOptions = getRequestOptions(`${graphResource}/v1.0/planner/plans/${id}`, metadata);
@@ -26,6 +29,7 @@ export const planner = {
26
29
  /**
27
30
  * Get all Planner plans for a specific group.
28
31
  * @param groupId Group ID.
32
+ * @param metadata OData metadata level. Default is none.
29
33
  */
30
34
  getPlansByGroupId(groupId, metadata = 'none') {
31
35
  return odata.getAllItems(`${graphResource}/v1.0/groups/${groupId}/planner/plans`, metadata);
@@ -33,30 +37,105 @@ export const planner = {
33
37
  /**
34
38
  * Get the Planner plan for a specific Roster.
35
39
  * @param rosterId Roster ID.
40
+ * @param metadata OData metadata level. Default is none.
41
+ * @throws Error when the roster has no plan.
36
42
  */
37
43
  async getPlanByRosterId(rosterId, metadata = 'none') {
38
44
  const plans = await odata.getAllItems(`${graphResource}/beta/planner/rosters/${rosterId}/plans`, metadata);
45
+ if (plans.length === 0) {
46
+ throw Error(`The specified roster '${rosterId}' does not have a plan.`);
47
+ }
39
48
  return plans[0];
40
49
  },
50
+ /**
51
+ * Get the Planner plan ID for a specific Roster.
52
+ * @param rosterId Roster ID.
53
+ * @throws Error when the roster has no plan.
54
+ */
55
+ async getPlanIdByRosterId(rosterId) {
56
+ const plans = await odata.getAllItems(`${graphResource}/beta/planner/rosters/${rosterId}/plans?$select=id`);
57
+ if (plans.length === 0) {
58
+ throw Error(`The specified roster '${rosterId}' does not have a plan.`);
59
+ }
60
+ return plans[0].id;
61
+ },
41
62
  /**
42
63
  * Get Planner plan by title in a specific group.
43
64
  * @param title Title of the Planner plan. Case insensitive.
44
65
  * @param groupId Owner group ID.
45
- * @param rosterId Roster ID.
66
+ * @param metadata OData metadata level. Default is none.
67
+ * @throws Error when the plan is not found.
46
68
  */
47
69
  async getPlanByTitle(title, groupId, metadata = 'none') {
48
- let plans = [];
49
- if (groupId) {
50
- plans = await this.getPlansByGroupId(groupId, metadata);
51
- }
70
+ const plans = await this.getPlansByGroupId(groupId, metadata);
52
71
  const filteredPlans = plans.filter(p => p.title && p.title.toLowerCase() === title.toLowerCase());
53
- if (!filteredPlans.length) {
72
+ if (filteredPlans.length === 0) {
54
73
  throw Error(`The specified plan '${title}' does not exist.`);
55
74
  }
56
75
  if (filteredPlans.length > 1) {
57
- throw Error(`Multiple plans with title '${title}' found: ${filteredPlans.map(x => x.id)}.`);
76
+ const plansKeyValuePair = formatting.convertArrayToHashTable('id', filteredPlans);
77
+ const plan = await cli.handleMultipleResultsFound(`Multiple plans with title '${title}' found.`, plansKeyValuePair);
78
+ return plan;
58
79
  }
59
80
  return filteredPlans[0];
81
+ },
82
+ /**
83
+ * Get Planner plan ID by title in a specific group.
84
+ * @param title Title of the Planner plan. Case insensitive.
85
+ * @param groupId Owner group ID.
86
+ * @throws Error when the plan is not found.
87
+ */
88
+ async getPlanIdByTitle(title, groupId) {
89
+ const plans = await odata.getAllItems(`${graphResource}/v1.0/groups/${groupId}/planner/plans?$select=id,title`);
90
+ const filteredPlans = plans.filter(p => p.title && p.title.toLowerCase() === title.toLowerCase());
91
+ if (filteredPlans.length === 0) {
92
+ throw Error(`The specified plan '${title}' does not exist.`);
93
+ }
94
+ if (filteredPlans.length > 1) {
95
+ const plansKeyValuePair = formatting.convertArrayToHashTable('id', filteredPlans);
96
+ const plan = await cli.handleMultipleResultsFound(`Multiple plans with title '${title}' found.`, plansKeyValuePair);
97
+ return plan.id;
98
+ }
99
+ return filteredPlans[0].id;
100
+ },
101
+ /**
102
+ * Get Planner bucket by title in a specific plan.
103
+ * @param title Title of the Planner bucket. Case insensitive.
104
+ * @param planId ID of the plan that contains the bucket.
105
+ * @param metadata OData metadata level. Default is none.
106
+ * @throws Error when the bucket is not found.
107
+ */
108
+ async getBucketByTitle(title, planId, metadata = 'none') {
109
+ const buckets = await odata.getAllItems(`${graphResource}/v1.0/planner/plans/${planId}/buckets`, metadata);
110
+ const filteredBuckets = buckets.filter(b => b.name && b.name.toLowerCase() === title.toLowerCase());
111
+ if (filteredBuckets.length === 0) {
112
+ throw Error(`The specified bucket '${title}' does not exist.`);
113
+ }
114
+ if (filteredBuckets.length > 1) {
115
+ const bucketsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
116
+ const bucket = await cli.handleMultipleResultsFound(`Multiple buckets with name '${title}' found.`, bucketsKeyValuePair);
117
+ return bucket;
118
+ }
119
+ return filteredBuckets[0];
120
+ },
121
+ /**
122
+ * Get Planner bucket ID by title in a specific plan.
123
+ * @param title Title of the Planner bucket. Case insensitive.
124
+ * @param planId ID of the plan that contains the bucket.
125
+ * @throws Error when the bucket is not found.
126
+ */
127
+ async getBucketIdByTitle(title, planId) {
128
+ const buckets = await odata.getAllItems(`${graphResource}/v1.0/planner/plans/${planId}/buckets?$select=id,name`);
129
+ const filteredBuckets = buckets.filter(b => b.name && b.name.toLowerCase() === title.toLowerCase());
130
+ if (filteredBuckets.length === 0) {
131
+ throw Error(`The specified bucket '${title}' does not exist.`);
132
+ }
133
+ if (filteredBuckets.length > 1) {
134
+ const bucketsKeyValuePair = formatting.convertArrayToHashTable('id', filteredBuckets);
135
+ const bucket = await cli.handleMultipleResultsFound(`Multiple buckets with name '${title}' found.`, bucketsKeyValuePair);
136
+ return bucket.id;
137
+ }
138
+ return filteredBuckets[0].id;
60
139
  }
61
140
  };
62
141
  //# sourceMappingURL=planner.js.map
@@ -1,6 +1,8 @@
1
1
  export const validation = {
2
- isValidGuidArray(guids) {
3
- return guids.every(guid => this.isValidGuid(guid));
2
+ isValidGuidArray(guidsString) {
3
+ const guids = guidsString.split(',').map(guid => guid.trim());
4
+ const invalidGuids = guids.filter(guid => !this.isValidGuid(guid));
5
+ return invalidGuids.length > 0 ? invalidGuids.join(', ') : true;
4
6
  },
5
7
  isValidGuid(guid) {
6
8
  if (!guid) {
@@ -21,9 +23,10 @@ export const validation = {
21
23
  const guidRegEx = new RegExp(/^19:[0-9a-zA-Z-_]+(@thread\.v2|@unq\.gbl\.spaces)$/i);
22
24
  return guidRegEx.test(guid);
23
25
  },
24
- isValidUserPrincipalNameArray(upns) {
25
- const invalidGuid = upns.find(upn => !this.isValidUserPrincipalName(upn));
26
- return invalidGuid || true;
26
+ isValidUserPrincipalNameArray(upnsString) {
27
+ const upns = upnsString.split(',').map(upn => upn.trim());
28
+ const invalidUPNs = upns.filter(upn => !this.isValidUserPrincipalName(upn));
29
+ return invalidUPNs.length > 0 ? invalidUPNs.join(', ') : true;
27
30
  },
28
31
  isValidUserPrincipalName(upn) {
29
32
  const upnRegEx = new RegExp(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/i);