@pnp/cli-microsoft365 7.7.0 → 7.8.0-beta.4a6e6f7

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 (67) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/cli/cli.js +21 -9
  4. package/dist/index.js +13 -12
  5. package/dist/m365/cli/commands/config/config-set.js +4 -0
  6. package/dist/m365/commands/setup.js +3 -3
  7. package/dist/m365/entra/commands/app/app-permission-add.js +25 -6
  8. package/dist/m365/entra/commands/app/app-permission-list.js +17 -5
  9. package/dist/m365/entra/commands/group/group-add.js +12 -14
  10. package/dist/m365/entra/commands/group/group-user-add.js +6 -7
  11. package/dist/m365/entra/commands/m365group/m365group-add.js +4 -2
  12. package/dist/m365/entra/commands/user/user-registrationdetails-list.js +6 -7
  13. package/dist/m365/flow/commands/run/run-list.js +25 -0
  14. package/dist/m365/outlook/commands/message/message-list.js +87 -17
  15. package/dist/m365/planner/commands/bucket/bucket-add.js +4 -7
  16. package/dist/m365/planner/commands/bucket/bucket-get.js +7 -30
  17. package/dist/m365/planner/commands/bucket/bucket-list.js +3 -6
  18. package/dist/m365/planner/commands/bucket/bucket-remove.js +8 -25
  19. package/dist/m365/planner/commands/bucket/bucket-set.js +12 -34
  20. package/dist/m365/planner/commands/plan/plan-add.js +17 -7
  21. package/dist/m365/planner/commands/plan/plan-get.js +12 -22
  22. package/dist/m365/planner/commands/plan/plan-list.js +1 -2
  23. package/dist/m365/planner/commands/plan/plan-remove.js +5 -3
  24. package/dist/m365/planner/commands/plan/plan-set.js +18 -10
  25. package/dist/m365/planner/commands/roster/roster-add.js +1 -2
  26. package/dist/m365/planner/commands/task/task-add.js +15 -21
  27. package/dist/m365/planner/commands/task/task-checklistitem-add.js +1 -1
  28. package/dist/m365/planner/commands/task/task-checklistitem-remove.js +1 -1
  29. package/dist/m365/planner/commands/task/task-get.js +5 -26
  30. package/dist/m365/planner/commands/task/task-list.js +11 -37
  31. package/dist/m365/planner/commands/task/task-reference-remove.js +1 -1
  32. package/dist/m365/planner/commands/task/task-remove.js +12 -29
  33. package/dist/m365/planner/commands/task/task-set.js +15 -21
  34. package/dist/m365/spfx/commands/project/project-doctor/{doctor-1.19.0-beta.0.js → doctor-1.19.0.js} +1 -1
  35. package/dist/m365/spfx/commands/project/project-doctor.js +1 -1
  36. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.19.0-beta.0.js → upgrade-1.19.0.js} +22 -22
  37. package/dist/m365/spfx/commands/project/project-upgrade.js +13 -15
  38. package/dist/m365/spfx/commands/spfx-doctor.js +1 -1
  39. package/dist/m365/spo/commands/listitem/listitem-batch-remove.js +222 -0
  40. package/dist/m365/spo/commands/navigation/navigation-node-add.js +3 -2
  41. package/dist/m365/spo/commands/navigation/navigation-node-set.js +3 -2
  42. package/dist/m365/spo/commands/site/site-add.js +17 -26
  43. package/dist/m365/spo/commands/site/site-recyclebinitem-move.js +5 -2
  44. package/dist/m365/spo/commands/site/site-recyclebinitem-remove.js +3 -2
  45. package/dist/m365/spo/commands/site/site-remove.js +129 -159
  46. package/dist/m365/spo/commands/site/site-set.js +9 -13
  47. package/dist/m365/spo/commands/spo-set.js +6 -2
  48. package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-remove.js +9 -13
  49. package/dist/m365/spo/commands.js +1 -0
  50. package/dist/m365/teams/commands/meeting/meeting-add.js +3 -3
  51. package/dist/m365/teams/commands/team/team-add.js +22 -16
  52. package/dist/settingsNames.js +1 -0
  53. package/dist/utils/planner.js +87 -8
  54. package/dist/utils/spo.js +209 -278
  55. package/dist/utils/urlUtil.js +8 -0
  56. package/dist/utils/validation.js +8 -5
  57. package/docs/docs/_clisettings.mdx +1 -0
  58. package/docs/docs/cmd/entra/app/app-permission-add.mdx +7 -4
  59. package/docs/docs/cmd/entra/app/app-permission-list.mdx +14 -5
  60. package/docs/docs/cmd/entra/m365group/m365group-add.mdx +24 -24
  61. package/docs/docs/cmd/flow/run/run-list.mdx +74 -1
  62. package/docs/docs/cmd/outlook/message/message-list.mdx +18 -6
  63. package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
  64. package/docs/docs/cmd/spo/listitem/listitem-batch-remove.mdx +70 -0
  65. package/docs/docs/cmd/spo/site/site-remove.mdx +9 -19
  66. package/npm-shrinkwrap.json +170 -230
  67. package/package.json +17 -17
@@ -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;
@@ -4,6 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _SpoSiteAddCommand_instances, _SpoSiteAddCommand_initTelemetry, _SpoSiteAddCommand_initOptions, _SpoSiteAddCommand_initValidators;
7
+ import { setTimeout } from 'timers/promises';
7
8
  import config from '../../../../config.js';
8
9
  import request from '../../../../request.js';
9
10
  import { formatting } from '../../../../utils/formatting.js';
@@ -198,19 +199,14 @@ class SpoSiteAddCommand extends SpoCommand {
198
199
  if ((!args.options.wait && !args.options.withAppCatalog) || isComplete) {
199
200
  return args.options.url;
200
201
  }
201
- await new Promise((resolve, reject) => {
202
- setTimeout(() => {
203
- spo.waitUntilFinished({
204
- operationId: JSON.stringify(operation._ObjectIdentity_),
205
- siteUrl: this.spoAdminUrl,
206
- resolve,
207
- reject,
208
- logger,
209
- currentContext: this.context,
210
- verbose: this.verbose,
211
- debug: this.debug
212
- });
213
- }, operation.PollingInterval);
202
+ await setTimeout(operation.PollingInterval);
203
+ await spo.waitUntilFinished({
204
+ operationId: JSON.stringify(operation._ObjectIdentity_),
205
+ siteUrl: this.spoAdminUrl,
206
+ logger,
207
+ currentContext: this.context,
208
+ verbose: this.verbose,
209
+ debug: this.debug
214
210
  });
215
211
  return args.options.url;
216
212
  }
@@ -291,19 +287,14 @@ class SpoSiteAddCommand extends SpoCommand {
291
287
  if (!wait || isComplete) {
292
288
  return;
293
289
  }
294
- await new Promise((resolve, reject) => {
295
- setTimeout(() => {
296
- spo.waitUntilFinished({
297
- operationId: JSON.stringify(operation._ObjectIdentity_),
298
- siteUrl: this.spoAdminUrl,
299
- resolve,
300
- reject,
301
- logger,
302
- currentContext: this.context,
303
- verbose: this.verbose,
304
- debug: this.debug
305
- });
306
- }, operation.PollingInterval);
290
+ await setTimeout(operation.PollingInterval);
291
+ await spo.waitUntilFinished({
292
+ operationId: JSON.stringify(operation._ObjectIdentity_),
293
+ siteUrl: this.spoAdminUrl,
294
+ logger,
295
+ currentContext: this.context,
296
+ verbose: this.verbose,
297
+ debug: this.debug
307
298
  });
308
299
  }
309
300
  async addAppCatalog(url, logger) {
@@ -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
  });