@pnp/cli-microsoft365 6.6.0 → 6.7.0-beta.25f79a3

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 (55) hide show
  1. package/.devcontainer/Dockerfile +1 -1
  2. package/README.md +1 -1
  3. package/csom.json +2 -0
  4. package/dist/Auth.js +75 -4
  5. package/dist/AuthServer.js +2 -1
  6. package/dist/Command.js +56 -7
  7. package/dist/m365/aad/commands/user/user-set.js +145 -30
  8. package/dist/m365/base/AzmgmtCommand.js +11 -0
  9. package/dist/m365/base/PowerAppsCommand.js +11 -0
  10. package/dist/m365/base/PowerPlatformCommand.js +11 -0
  11. package/dist/m365/commands/login.js +17 -1
  12. package/dist/m365/commands/status.js +4 -2
  13. package/dist/m365/flow/commands/run/run-get.js +31 -1
  14. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +144 -0
  15. package/dist/m365/spo/commands/file/file-list.js +108 -32
  16. package/dist/m365/spo/commands/folder/folder-list.js +73 -16
  17. package/dist/m365/spo/commands/list/list-add.js +7 -0
  18. package/dist/m365/spo/commands/list/list-set.js +7 -0
  19. package/dist/m365/spo/commands/listitem/listitem-list.js +113 -55
  20. package/dist/m365/spo/commands/site/site-recyclebinitem-clear.js +115 -0
  21. package/dist/m365/spo/commands.js +2 -0
  22. package/dist/m365/teams/commands/team/team-add.js +2 -2
  23. package/dist/request.js +7 -0
  24. package/dist/utils/misc.js +11 -0
  25. package/docs/docs/cmd/aad/user/user-set.md +53 -8
  26. package/docs/docs/cmd/flow/run/run-get.md +110 -9
  27. package/docs/docs/cmd/login.md +5 -2
  28. package/docs/docs/cmd/planner/task/task-add.md +3 -1
  29. package/docs/docs/cmd/planner/task/task-set.md +6 -4
  30. package/docs/docs/cmd/pp/tenant/tenant-settings-list.md +25 -9
  31. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.md +145 -0
  32. package/docs/docs/cmd/spo/file/file-list.md +87 -2
  33. package/docs/docs/cmd/spo/folder/folder-list.md +36 -1
  34. package/docs/docs/cmd/spo/list/list-add.md +3 -0
  35. package/docs/docs/cmd/spo/list/list-set.md +3 -0
  36. package/docs/docs/cmd/spo/listitem/listitem-list.md +22 -8
  37. package/docs/docs/cmd/spo/site/site-recyclebinitem-clear.md +45 -0
  38. package/docs/docs/cmd/tenant/id/id-get.md +6 -0
  39. package/docs/docs/cmd/tenant/report/report-activeusercounts.md +7 -0
  40. package/docs/docs/cmd/tenant/report/report-activeuserdetail.md +7 -0
  41. package/docs/docs/cmd/tenant/report/report-office365activationcounts.md +7 -0
  42. package/docs/docs/cmd/tenant/report/report-office365activationsusercounts.md +7 -0
  43. package/docs/docs/cmd/tenant/report/report-office365activationsuserdetail.md +7 -0
  44. package/docs/docs/cmd/tenant/report/report-servicesusercounts.md +7 -0
  45. package/docs/docs/cmd/tenant/security/security-alerts-list.md +23 -0
  46. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +32 -0
  47. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +32 -0
  48. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +26 -0
  49. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +26 -0
  50. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +22 -0
  51. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +22 -0
  52. package/npm-shrinkwrap.json +2 -2
  53. package/package.json +3 -2
  54. package/dist/m365/spo/commands/file/FilePropertiesCollection.js +0 -3
  55. package/dist/m365/spo/commands/folder/FileFolderCollection.js +0 -3
@@ -13,10 +13,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
13
  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");
14
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
- var _FlowRunGetCommand_instances, _FlowRunGetCommand_initOptions;
16
+ var _FlowRunGetCommand_instances, _FlowRunGetCommand_initOptions, _FlowRunGetCommand_initValidators, _FlowRunGetCommand_initTelemetry;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const validation_1 = require("../../../../utils/validation");
20
21
  const AzmgmtCommand_1 = require("../../../base/AzmgmtCommand");
21
22
  const commands_1 = require("../../commands");
22
23
  class FlowRunGetCommand extends AzmgmtCommand_1.default {
@@ -32,7 +33,9 @@ class FlowRunGetCommand extends AzmgmtCommand_1.default {
32
33
  constructor() {
33
34
  super();
34
35
  _FlowRunGetCommand_instances.add(this);
36
+ __classPrivateFieldGet(this, _FlowRunGetCommand_instances, "m", _FlowRunGetCommand_initTelemetry).call(this);
35
37
  __classPrivateFieldGet(this, _FlowRunGetCommand_instances, "m", _FlowRunGetCommand_initOptions).call(this);
38
+ __classPrivateFieldGet(this, _FlowRunGetCommand_instances, "m", _FlowRunGetCommand_initValidators).call(this);
36
39
  }
37
40
  commandAction(logger, args) {
38
41
  return __awaiter(this, void 0, void 0, function* () {
@@ -52,6 +55,18 @@ class FlowRunGetCommand extends AzmgmtCommand_1.default {
52
55
  res.endTime = res.properties.endTime || '';
53
56
  res.status = res.properties.status;
54
57
  res.triggerName = res.properties.trigger.name;
58
+ if (args.options.includeTriggerInformation && res.properties.trigger.outputsLink) {
59
+ const triggerInformationOptions = {
60
+ url: res.properties.trigger.outputsLink.uri,
61
+ headers: {
62
+ accept: 'application/json',
63
+ 'x-anonymous': true
64
+ },
65
+ responseType: 'json'
66
+ };
67
+ const triggerInformationResponse = yield request_1.default.get(triggerInformationOptions);
68
+ res.triggerInformation = triggerInformationResponse.body;
69
+ }
55
70
  logger.log(res);
56
71
  }
57
72
  catch (err) {
@@ -67,6 +82,21 @@ _FlowRunGetCommand_instances = new WeakSet(), _FlowRunGetCommand_initOptions = f
67
82
  option: '-f, --flowName <flowName>'
68
83
  }, {
69
84
  option: '-e, --environmentName <environmentName>'
85
+ }, {
86
+ option: '--includeTriggerInformation'
87
+ });
88
+ }, _FlowRunGetCommand_initValidators = function _FlowRunGetCommand_initValidators() {
89
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
90
+ if (!validation_1.validation.isValidGuid(args.options.flowName)) {
91
+ return `${args.options.flowName} is not a valid GUID`;
92
+ }
93
+ return true;
94
+ }));
95
+ }, _FlowRunGetCommand_initTelemetry = function _FlowRunGetCommand_initTelemetry() {
96
+ this.telemetry.push((args) => {
97
+ Object.assign(this.telemetryProperties, {
98
+ includeTriggerInformation: !!args.options.includeTriggerInformation
99
+ });
70
100
  });
71
101
  };
72
102
  module.exports = new FlowRunGetCommand();
@@ -0,0 +1,144 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SpoApplicationCustomizerGetCommand_instances, _SpoApplicationCustomizerGetCommand_initTelemetry, _SpoApplicationCustomizerGetCommand_initOptions, _SpoApplicationCustomizerGetCommand_initValidators, _SpoApplicationCustomizerGetCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const formatting_1 = require("../../../../utils/formatting");
19
+ const spo_1 = require("../../../../utils/spo");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ class SpoApplicationCustomizerGetCommand extends SpoCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.APPLICATIONCUSTOMIZER_GET;
26
+ }
27
+ get description() {
28
+ return 'Get an application customizer that is added to a site.';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _SpoApplicationCustomizerGetCommand_instances.add(this);
33
+ this.allowedScopes = ['All', 'Site', 'Web'];
34
+ __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initTelemetry).call(this);
35
+ __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initOptions).call(this);
36
+ __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initValidators).call(this);
37
+ __classPrivateFieldGet(this, _SpoApplicationCustomizerGetCommand_instances, "m", _SpoApplicationCustomizerGetCommand_initOptionSets).call(this);
38
+ }
39
+ commandAction(logger, args) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ try {
42
+ const customAction = yield this.getCustomAction(args.options);
43
+ if (customAction) {
44
+ logger.log({
45
+ ClientSideComponentId: customAction.ClientSideComponentId,
46
+ ClientSideComponentProperties: customAction.ClientSideComponentProperties,
47
+ CommandUIExtension: customAction.CommandUIExtension,
48
+ Description: customAction.Description,
49
+ Group: customAction.Group,
50
+ Id: customAction.Id,
51
+ ImageUrl: customAction.ImageUrl,
52
+ Location: customAction.Location,
53
+ Name: customAction.Name,
54
+ RegistrationId: customAction.RegistrationId,
55
+ RegistrationType: customAction.RegistrationType,
56
+ Rights: JSON.stringify(customAction.Rights),
57
+ Scope: this.humanizeScope(customAction.Scope),
58
+ ScriptBlock: customAction.ScriptBlock,
59
+ ScriptSrc: customAction.ScriptSrc,
60
+ Sequence: customAction.Sequence,
61
+ Title: customAction.Title,
62
+ Url: customAction.Url,
63
+ VersionOfUserCustomAction: customAction.VersionOfUserCustomAction
64
+ });
65
+ }
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedPromise(err);
69
+ }
70
+ });
71
+ }
72
+ getCustomAction(options) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ if (options.id) {
75
+ const customAction = yield spo_1.spo.getCustomActionById(options.webUrl, options.id, options.scope);
76
+ if (!customAction || (customAction && customAction.Location !== 'ClientSideExtension.ApplicationCustomizer')) {
77
+ throw `No application customizer with id '${options.id}' found`;
78
+ }
79
+ return customAction;
80
+ }
81
+ const filter = options.title ? `Title eq '${formatting_1.formatting.encodeQueryParameter(options.title)}'` : `ClientSideComponentId eq guid'${formatting_1.formatting.encodeQueryParameter(options.clientSideComponentId)}'`;
82
+ const customActions = yield spo_1.spo.getCustomActions(options.webUrl, options.scope, `${filter} and Location eq 'ClientSideExtension.ApplicationCustomizer'`);
83
+ if (customActions.length === 1) {
84
+ return customActions[0];
85
+ }
86
+ const errorMessage = options.title ? `title '${options.title}'` : `Client Side Component Id '${options.clientSideComponentId}'`;
87
+ if (customActions.length === 0) {
88
+ throw `No application customizer with ${errorMessage} found`;
89
+ }
90
+ else {
91
+ throw `Multiple application customizers with ${errorMessage} found. Please disambiguate using IDs: ${customActions.map(a => a.Id).join(', ')}`;
92
+ }
93
+ });
94
+ }
95
+ humanizeScope(scope) {
96
+ switch (scope) {
97
+ case 2:
98
+ return "Site";
99
+ case 3:
100
+ return "Web";
101
+ }
102
+ return `${scope}`;
103
+ }
104
+ }
105
+ _SpoApplicationCustomizerGetCommand_instances = new WeakSet(), _SpoApplicationCustomizerGetCommand_initTelemetry = function _SpoApplicationCustomizerGetCommand_initTelemetry() {
106
+ this.telemetry.push((args) => {
107
+ Object.assign(this.telemetryProperties, {
108
+ title: typeof args.options.title !== 'undefined',
109
+ id: typeof args.options.id !== 'undefined',
110
+ clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
111
+ scope: typeof args.options.scope !== 'undefined'
112
+ });
113
+ });
114
+ }, _SpoApplicationCustomizerGetCommand_initOptions = function _SpoApplicationCustomizerGetCommand_initOptions() {
115
+ this.options.unshift({
116
+ option: '-u, --webUrl <webUrl>'
117
+ }, {
118
+ option: '-t, --title [title]'
119
+ }, {
120
+ option: '-i, --id [id]'
121
+ }, {
122
+ option: '-c, --clientSideComponentId [clientSideComponentId]'
123
+ }, {
124
+ option: '-s, --scope [scope]',
125
+ autocomplete: this.allowedScopes
126
+ });
127
+ }, _SpoApplicationCustomizerGetCommand_initValidators = function _SpoApplicationCustomizerGetCommand_initValidators() {
128
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
129
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
130
+ return `${args.options.id} is not a valid GUID`;
131
+ }
132
+ if (args.options.clientSideComponentId && !validation_1.validation.isValidGuid(args.options.clientSideComponentId)) {
133
+ return `${args.options.clientSideComponentId} is not a valid GUID`;
134
+ }
135
+ if (args.options.scope && this.allowedScopes.indexOf(args.options.scope) === -1) {
136
+ return `'${args.options.scope}' is not a valid application customizer scope. Allowed values are: ${this.allowedScopes.join(',')}`;
137
+ }
138
+ return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
139
+ }));
140
+ }, _SpoApplicationCustomizerGetCommand_initOptionSets = function _SpoApplicationCustomizerGetCommand_initOptionSets() {
141
+ this.optionSets.push({ options: ['title', 'id', 'clientSideComponentId'] });
142
+ };
143
+ module.exports = new SpoApplicationCustomizerGetCommand();
144
+ //# sourceMappingURL=applicationcustomizer-get.js.map
@@ -17,6 +17,7 @@ var _SpoFileListCommand_instances, _SpoFileListCommand_initTelemetry, _SpoFileLi
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
23
  const commands_1 = require("../../commands");
@@ -37,53 +38,123 @@ class SpoFileListCommand extends SpoCommand_1.default {
37
38
  commandAction(logger, args) {
38
39
  return __awaiter(this, void 0, void 0, function* () {
39
40
  if (this.verbose) {
40
- logger.logToStderr(`Retrieving all files in folder ${args.options.folder} at site ${args.options.webUrl}...`);
41
+ logger.logToStderr(`Retrieving all files in folder '${args.options.folder}' at site '${args.options.webUrl}'${args.options.recursive ? ' (recursive)' : ''}...`);
41
42
  }
42
43
  try {
43
- const files = yield this.getFiles(args.options.folder, args);
44
- logger.log(files.value);
44
+ const fieldProperties = this.formatSelectProperties(args.options.fields, args.options.output);
45
+ const allFiles = [];
46
+ const allFolders = args.options.recursive
47
+ ? [...yield this.getFolders(args.options.folder, args, logger), args.options.folder]
48
+ : [args.options.folder];
49
+ for (const folder of allFolders) {
50
+ const files = yield this.getFiles(folder, fieldProperties, args, logger);
51
+ files.forEach((file) => allFiles.push(file));
52
+ }
53
+ // Clean ListItemAllFields.ID property from the output if included
54
+ // Reason: It causes a casing conflict with 'Id' when parsing JSON in PowerShell
55
+ if (fieldProperties.selectProperties.some(p => p.toLowerCase().indexOf('listitemallfields') > -1)) {
56
+ allFiles.filter(file => { var _a; return ((_a = file.ListItemAllFields) === null || _a === void 0 ? void 0 : _a.ID) !== undefined; }).forEach(file => delete file.ListItemAllFields['ID']);
57
+ }
58
+ logger.log(allFiles);
45
59
  }
46
60
  catch (err) {
47
61
  this.handleRejectedODataJsonPromise(err);
48
62
  }
49
63
  });
50
64
  }
51
- // Gets files from a folder recursively.
52
- getFiles(folderUrl, args, files = { value: [] }) {
53
- // If --recursive option is specified, retrieve both Files and Folder details, otherwise only Files.
54
- const expandParameters = args.options.recursive ? 'Files,Folders' : 'Files';
55
- let requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(folderUrl)}')?$expand=${expandParameters}`;
56
- if (args.options.output !== 'json') {
57
- requestUrl += '&$select=Files/UniqueId,Files/Name,Files/ServerRelativeUrl';
58
- }
59
- const requestOptions = {
60
- url: requestUrl,
61
- method: 'GET',
62
- headers: {
63
- 'accept': 'application/json;odata=nometadata'
64
- },
65
- responseType: 'json'
66
- };
67
- return request_1.default
68
- .get(requestOptions)
69
- .then((filesAndFoldersResult) => {
70
- filesAndFoldersResult.Files.forEach((file) => files.value.push(file));
71
- // If the request is --recursive, call this method for other folders.
72
- if (args.options.recursive &&
73
- filesAndFoldersResult.Folders !== undefined &&
74
- filesAndFoldersResult.Folders.length !== 0) {
75
- return Promise.all(filesAndFoldersResult.Folders.map((folder) => this.getFiles(folder.ServerRelativeUrl, args, files)));
65
+ getFiles(folderUrl, fieldProperties, args, logger, skip = 0) {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ if (this.verbose) {
68
+ const page = Math.ceil(skip / SpoFileListCommand.pageSize) + 1;
69
+ logger.logToStderr(`Retrieving files in folder '${folderUrl}'${page > 1 ? ', page ' + page : ''}...`);
70
+ }
71
+ const allFiles = [];
72
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, folderUrl);
73
+ const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl(@url)/Files?@url='${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}'`;
74
+ const queryParams = [`$skip=${skip}`, `$top=${SpoFileListCommand.pageSize}`];
75
+ if (fieldProperties.expandProperties.length > 0) {
76
+ queryParams.push(`$expand=${fieldProperties.expandProperties.join(',')}`);
77
+ }
78
+ if (fieldProperties.selectProperties.length > 0) {
79
+ queryParams.push(`$select=${fieldProperties.selectProperties.join(',')}`);
76
80
  }
77
- else {
78
- return;
81
+ if (args.options.filter) {
82
+ queryParams.push(`$filter=${args.options.filter}`);
79
83
  }
80
- }).then(() => files);
84
+ const requestOptions = {
85
+ url: `${requestUrl}&${queryParams.join('&')}`,
86
+ method: 'GET',
87
+ headers: {
88
+ 'accept': 'application/json;odata=nometadata'
89
+ },
90
+ responseType: 'json'
91
+ };
92
+ const response = yield request_1.default.get(requestOptions);
93
+ response.value.forEach(file => allFiles.push(file));
94
+ if (response.value.length === SpoFileListCommand.pageSize) {
95
+ const files = yield this.getFiles(folderUrl, fieldProperties, args, logger, skip + SpoFileListCommand.pageSize);
96
+ files.forEach(file => allFiles.push(file));
97
+ }
98
+ return allFiles;
99
+ });
100
+ }
101
+ getFolders(folderUrl, args, logger, skip = 0) {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ if (this.verbose) {
104
+ const page = Math.ceil(skip / SpoFileListCommand.pageSize) + 1;
105
+ logger.logToStderr(`Retrieving folders in folder '${folderUrl}'${page > 1 ? ', page ' + page : ''}...`);
106
+ }
107
+ const allFolders = [];
108
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, folderUrl);
109
+ const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl(@url)/Folders?@url='${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}'`;
110
+ const requestOptions = {
111
+ url: `${requestUrl}&$skip=${skip}&$top=${SpoFileListCommand.pageSize}&$select=ServerRelativeUrl`,
112
+ method: 'GET',
113
+ headers: {
114
+ 'accept': 'application/json;odata=nometadata'
115
+ },
116
+ responseType: 'json'
117
+ };
118
+ const response = yield request_1.default.get(requestOptions);
119
+ for (const folder of response.value) {
120
+ allFolders.push(folder.ServerRelativeUrl);
121
+ const subfolders = yield this.getFolders(folder.ServerRelativeUrl, args, logger);
122
+ subfolders.forEach(folder => allFolders.push(folder));
123
+ }
124
+ if (response.value.length === SpoFileListCommand.pageSize) {
125
+ const folders = yield this.getFolders(folderUrl, args, logger, skip + SpoFileListCommand.pageSize);
126
+ folders.forEach(folder => allFolders.push(folder));
127
+ }
128
+ return allFolders;
129
+ });
130
+ }
131
+ formatSelectProperties(fields, output) {
132
+ let selectProperties = [];
133
+ const expandProperties = [];
134
+ if (output === 'text' && !fields) {
135
+ selectProperties = ['UniqueId', 'Name', 'ServerRelativeUrl'];
136
+ }
137
+ if (fields) {
138
+ fields.split(',').forEach((field) => {
139
+ const subparts = field.trim().split('/');
140
+ if (subparts.length > 1) {
141
+ expandProperties.push(subparts[0]);
142
+ }
143
+ selectProperties.push(field.trim());
144
+ });
145
+ }
146
+ return {
147
+ selectProperties: [...new Set(selectProperties)],
148
+ expandProperties: [...new Set(expandProperties)]
149
+ };
81
150
  }
82
151
  }
83
152
  _SpoFileListCommand_instances = new WeakSet(), _SpoFileListCommand_initTelemetry = function _SpoFileListCommand_initTelemetry() {
84
153
  this.telemetry.push((args) => {
85
154
  Object.assign(this.telemetryProperties, {
86
- recursive: args.options.recursive
155
+ recursive: args.options.recursive,
156
+ fields: typeof args.options.fields !== 'undefined',
157
+ filter: typeof args.options.filter !== 'undefined'
87
158
  });
88
159
  });
89
160
  }, _SpoFileListCommand_initOptions = function _SpoFileListCommand_initOptions() {
@@ -91,11 +162,16 @@ _SpoFileListCommand_instances = new WeakSet(), _SpoFileListCommand_initTelemetry
91
162
  option: '-u, --webUrl <webUrl>'
92
163
  }, {
93
164
  option: '-f, --folder <folder>'
165
+ }, {
166
+ option: '--fields [fields]'
167
+ }, {
168
+ option: '--filter [filter]'
94
169
  }, {
95
170
  option: '-r, --recursive'
96
171
  });
97
172
  }, _SpoFileListCommand_initValidators = function _SpoFileListCommand_initValidators() {
98
173
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () { return validation_1.validation.isValidSharePointUrl(args.options.webUrl); }));
99
174
  };
175
+ SpoFileListCommand.pageSize = 5000;
100
176
  module.exports = new SpoFileListCommand();
101
177
  //# sourceMappingURL=file-list.js.map
@@ -15,8 +15,8 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _SpoFolderListCommand_instances, _SpoFolderListCommand_initTelemetry, _SpoFolderListCommand_initOptions, _SpoFolderListCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
18
19
  const formatting_1 = require("../../../../utils/formatting");
19
- const odata_1 = require("../../../../utils/odata");
20
20
  const urlUtil_1 = require("../../../../utils/urlUtil");
21
21
  const validation_1 = require("../../../../utils/validation");
22
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
@@ -41,37 +41,89 @@ class SpoFolderListCommand extends SpoCommand_1.default {
41
41
  commandAction(logger, args) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
43
  if (this.verbose) {
44
- logger.logToStderr(`Retrieving folders from site ${args.options.webUrl} parent folder ${args.options.parentFolderUrl} ${args.options.recursive ? '(recursive)' : ''}...`);
44
+ logger.logToStderr(`Retrieving all folders in folder '${args.options.parentFolderUrl}' at site '${args.options.webUrl}'${args.options.recursive ? ' (recursive)' : ''}...`);
45
45
  }
46
46
  try {
47
- const resp = yield this.getFolderList(args.options.webUrl, args.options.parentFolderUrl, args.options.recursive);
48
- logger.log(resp);
47
+ const fieldProperties = this.formatSelectProperties(args.options.fields);
48
+ const allFiles = yield this.getFolders(args.options.parentFolderUrl, fieldProperties, args, logger);
49
+ // Clean ListItemAllFields.ID property from the output if included
50
+ // Reason: It causes a casing conflict with 'Id' when parsing JSON in PowerShell
51
+ if (fieldProperties.selectProperties.some(p => p.toLowerCase().indexOf('listitemallfields') > -1)) {
52
+ allFiles.filter(folder => { var _a; return ((_a = folder.ListItemAllFields) === null || _a === void 0 ? void 0 : _a.ID) !== undefined; }).forEach(folder => delete folder.ListItemAllFields['ID']);
53
+ }
54
+ logger.log(allFiles);
49
55
  }
50
56
  catch (err) {
51
57
  this.handleRejectedODataJsonPromise(err);
52
58
  }
53
59
  });
54
60
  }
55
- getFolderList(webUrl, parentFolderUrl, recursive, folders = []) {
61
+ getFolders(parentFolderUrl, fieldProperties, args, logger, skip = 0) {
56
62
  return __awaiter(this, void 0, void 0, function* () {
57
- const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(webUrl, parentFolderUrl);
58
- const resp = yield odata_1.odata.getAllItems(`${webUrl}/_api/web/GetFolderByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}')/folders`);
59
- if (resp.length > 0) {
60
- for (const folder of resp) {
61
- folders.push(folder);
62
- if (recursive) {
63
- yield this.getFolderList(webUrl, folder.ServerRelativeUrl, recursive, folders);
64
- }
63
+ if (this.verbose) {
64
+ const page = Math.ceil(skip / SpoFolderListCommand.pageSize) + 1;
65
+ logger.logToStderr(`Retrieving folders in folder '${parentFolderUrl}'${page > 1 ? ', page ' + page : ''}...`);
66
+ }
67
+ const allFolders = [];
68
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, parentFolderUrl);
69
+ const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl(@url)/Folders?@url='${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}'`;
70
+ const queryParams = [`$skip=${skip}`, `$top=${SpoFolderListCommand.pageSize}`];
71
+ if (fieldProperties.expandProperties.length > 0) {
72
+ queryParams.push(`$expand=${fieldProperties.expandProperties.join(',')}`);
73
+ }
74
+ if (fieldProperties.selectProperties.length > 0) {
75
+ queryParams.push(`$select=${fieldProperties.selectProperties.join(',')}`);
76
+ }
77
+ if (args.options.filter) {
78
+ queryParams.push(`$filter=${args.options.filter}`);
79
+ }
80
+ const requestOptions = {
81
+ url: `${requestUrl}&${queryParams.join('&')}`,
82
+ method: 'GET',
83
+ headers: {
84
+ 'accept': 'application/json;odata=nometadata'
85
+ },
86
+ responseType: 'json'
87
+ };
88
+ const response = yield request_1.default.get(requestOptions);
89
+ for (const folder of response.value) {
90
+ allFolders.push(folder);
91
+ if (args.options.recursive) {
92
+ const subFolders = yield this.getFolders(folder.ServerRelativeUrl, fieldProperties, args, logger);
93
+ subFolders.forEach(subFolder => allFolders.push(subFolder));
65
94
  }
66
95
  }
67
- return folders;
96
+ if (response.value.length === SpoFolderListCommand.pageSize) {
97
+ const folders = yield this.getFolders(parentFolderUrl, fieldProperties, args, logger, skip + SpoFolderListCommand.pageSize);
98
+ folders.forEach(folder => allFolders.push(folder));
99
+ }
100
+ return allFolders;
68
101
  });
69
102
  }
103
+ formatSelectProperties(fields) {
104
+ const selectProperties = [];
105
+ const expandProperties = [];
106
+ if (fields) {
107
+ fields.split(',').forEach((field) => {
108
+ const subparts = field.trim().split('/');
109
+ if (subparts.length > 1) {
110
+ expandProperties.push(subparts[0]);
111
+ }
112
+ selectProperties.push(field.trim());
113
+ });
114
+ }
115
+ return {
116
+ selectProperties: [...new Set(selectProperties)],
117
+ expandProperties: [...new Set(expandProperties)]
118
+ };
119
+ }
70
120
  }
71
121
  _SpoFolderListCommand_instances = new WeakSet(), _SpoFolderListCommand_initTelemetry = function _SpoFolderListCommand_initTelemetry() {
72
122
  this.telemetry.push((args) => {
73
123
  Object.assign(this.telemetryProperties, {
74
- recursive: !!args.options.recursive
124
+ recursive: !!args.options.recursive,
125
+ fields: typeof args.options.fields !== 'undefined',
126
+ filter: typeof args.options.filter !== 'undefined'
75
127
  });
76
128
  });
77
129
  }, _SpoFolderListCommand_initOptions = function _SpoFolderListCommand_initOptions() {
@@ -80,10 +132,15 @@ _SpoFolderListCommand_instances = new WeakSet(), _SpoFolderListCommand_initTelem
80
132
  }, {
81
133
  option: '-p, --parentFolderUrl <parentFolderUrl>'
82
134
  }, {
83
- option: '--recursive [recursive]'
135
+ option: '-f, --fields [fields]'
136
+ }, {
137
+ option: '--filter [filter]'
138
+ }, {
139
+ option: '-r, --recursive [recursive]'
84
140
  });
85
141
  }, _SpoFolderListCommand_initValidators = function _SpoFolderListCommand_initValidators() {
86
142
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () { return validation_1.validation.isValidSharePointUrl(args.options.webUrl); }));
87
143
  };
144
+ SpoFolderListCommand.pageSize = 5000;
88
145
  module.exports = new SpoFolderListCommand();
89
146
  //# sourceMappingURL=folder-list.js.map
@@ -144,6 +144,9 @@ class SpoListAddCommand extends SpoCommand_1.default {
144
144
  if (options.direction) {
145
145
  requestBody.Direction = options.direction;
146
146
  }
147
+ if (options.disableCommenting !== undefined) {
148
+ requestBody.DisableCommenting = options.disableCommenting;
149
+ }
147
150
  if (options.disableGridEditing !== undefined) {
148
151
  requestBody.DisableGridEditing = options.disableGridEditing;
149
152
  }
@@ -377,6 +380,9 @@ _SpoListAddCommand_instances = new WeakSet(), _SpoListAddCommand_initTelemetry =
377
380
  }, {
378
381
  option: '--direction [direction]',
379
382
  autocomplete: ['NONE', 'LTR', 'RTL']
383
+ }, {
384
+ option: '--disableCommenting [disableCommenting]',
385
+ autocomplete: ['true', 'false']
380
386
  }, {
381
387
  option: '--disableGridEditing [disableGridEditing]',
382
388
  autocomplete: ['true', 'false']
@@ -585,6 +591,7 @@ SpoListAddCommand.booleanOptions = [
585
591
  'allowMultiResponses',
586
592
  'contentTypesEnabled',
587
593
  'crawlNonDefaultViews',
594
+ 'disableCommenting',
588
595
  'disableGridEditing',
589
596
  'enableAssignToEmail',
590
597
  'enableAttachments',
@@ -146,6 +146,9 @@ class SpoListSetCommand extends SpoCommand_1.default {
146
146
  if (options.direction) {
147
147
  requestBody.Direction = options.direction;
148
148
  }
149
+ if (options.disableCommenting !== undefined) {
150
+ requestBody.DisableCommenting = options.disableCommenting;
151
+ }
149
152
  if (options.disableGridEditing !== undefined) {
150
153
  requestBody.DisableGridEditing = options.disableGridEditing;
151
154
  }
@@ -380,6 +383,9 @@ _SpoListSetCommand_instances = new WeakSet(), _SpoListSetCommand_initTelemetry =
380
383
  }, {
381
384
  option: '--direction [direction]',
382
385
  autocomplete: ['NONE', 'LTR', 'RTL']
386
+ }, {
387
+ option: '--disableCommenting [disableCommenting]',
388
+ autocomplete: ['true', 'false']
383
389
  }, {
384
390
  option: '--disableGridEditing [disableGridEditing]',
385
391
  autocomplete: ['true', 'false']
@@ -591,6 +597,7 @@ SpoListSetCommand.booleanOptions = [
591
597
  'allowMultiResponses',
592
598
  'contentTypesEnabled',
593
599
  'crawlNonDefaultViews',
600
+ 'disableCommenting',
594
601
  'disableGridEditing',
595
602
  'enableAssignToEmail',
596
603
  'enableAttachments',