@pnp/cli-microsoft365 6.7.0-beta.f5f5666 → 6.8.0-beta.e41be56

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.
package/README.md CHANGED
@@ -31,7 +31,7 @@
31
31
  <img src="https://img.shields.io/npm/v/@pnp/cli-microsoft365/latest?style=flat-square"
32
32
  alt="npm @pnp/cli-microsoft365@latest" />
33
33
  </a>
34
-
34
+
35
35
  <a href="https://www.npmjs.com/package/@pnp/cli-microsoft365">
36
36
  <img src="https://img.shields.io/npm/v/@pnp/cli-microsoft365/next?style=flat-square"
37
37
  alt="npm @pnp/cli-microsoft365@next" />
@@ -41,16 +41,16 @@
41
41
  <p align="center">CLI for Microsoft 365 helps you manage your Microsoft 365 tenant and SharePoint Framework projects.</p>
42
42
 
43
43
  <p align="center">
44
- <a href="https://pnp.github.io/cli-microsoft365">Website</a> |
44
+ <a href="https://pnp.github.io/cli-microsoft365">Website</a> |
45
45
  <a href="#features">Features</a> |
46
- <a href="#install">Install</a> |
47
- <a href="#usage">Usage</a> |
48
- <a href="#build">Build</a> |
46
+ <a href="#install">Install</a> |
47
+ <a href="#usage">Usage</a> |
48
+ <a href="#build">Build</a> |
49
49
  <a href="#contribute">Contribute</a>
50
50
  </p>
51
51
  <p align="center">
52
52
  <a href="#sharing-is-caring">Sharing is Caring</a> |
53
- <a href="#code-of-conduct">Code of Conduct</a> |
53
+ <a href="#code-of-conduct">Code of Conduct</a> |
54
54
  <a href="#disclaimer">Disclaimer</a>
55
55
  </p>
56
56
 
@@ -91,7 +91,7 @@
91
91
  - Device Code
92
92
  - Username and Password
93
93
  - Manage your SharePoint Framework projects
94
- - Uprade your projects
94
+ - Upgrade your projects
95
95
  - Check your environment compatibility
96
96
 
97
97
  > Follow our [Twitter](https://twitter.com/climicrosoft365) account to keep yourself updated about new features, improvements, and bug fixes.
@@ -105,7 +105,7 @@ npm install -g @pnp/cli-microsoft365
105
105
  ```
106
106
 
107
107
  <details>
108
- <summary>Install beta version β</summary>
108
+ <summary>Install beta version β</summary>
109
109
 
110
110
  ```
111
111
  npm install -g @pnp/cli-microsoft365@next
@@ -140,7 +140,7 @@ npm install -g @pnp/cli-microsoft365
140
140
 
141
141
  ## Usage
142
142
 
143
- Use the `login` command to start the Device Code login flow to authenticate with your Microsoft 365 tenant.
143
+ Use the `login` command to start the Device Code login flow to authenticate with your Microsoft 365 tenant.
144
144
 
145
145
  ```sh
146
146
  m365 login
package/dist/Command.js CHANGED
@@ -127,21 +127,70 @@ class Command {
127
127
  if (!optionsSets || optionsSets.length === 0) {
128
128
  return true;
129
129
  }
130
+ let inquirer;
131
+ const shouldPrompt = Cli_1.Cli.getInstance().getSettingWithDefaultValue(settingsNames_1.settingsNames.prompt, false);
130
132
  const argsOptions = Object.keys(args.options);
131
- for (const optionSet of optionsSets) {
132
- if (optionSet.runsWhen === undefined || optionSet.runsWhen(args)) {
133
- const commonOptions = argsOptions.filter(opt => optionSet.options.includes(opt));
134
- if (commonOptions.length === 0) {
135
- return `Specify one of the following options: ${optionSet.options.map(opt => opt).join(', ')}.`;
133
+ for (const optionSet of optionsSets.sort(opt => opt.runsWhen ? 0 : 1)) {
134
+ if (optionSet.runsWhen && !optionSet.runsWhen(args)) {
135
+ continue;
136
+ }
137
+ const commonOptions = argsOptions.filter(opt => optionSet.options.includes(opt));
138
+ if (commonOptions.length === 0) {
139
+ if (!shouldPrompt) {
140
+ return `Specify one of the following options: ${optionSet.options.join(', ')}.`;
136
141
  }
137
- if (commonOptions.length > 1) {
138
- return `Specify one of the following options: ${optionSet.options.map(opt => opt).join(', ')}, but not multiple.`;
142
+ yield this.promptForOptionSetNameAndValue(args, optionSet, inquirer);
143
+ }
144
+ if (commonOptions.length > 1) {
145
+ if (!shouldPrompt) {
146
+ return `Specify one of the following options: ${optionSet.options.join(', ')}, but not multiple.`;
139
147
  }
148
+ yield this.promptForSpecificOption(args, commonOptions, inquirer);
140
149
  }
141
150
  }
142
151
  return true;
143
152
  });
144
153
  }
154
+ promptForOptionSetNameAndValue(args, optionSet, inquirer) {
155
+ return __awaiter(this, void 0, void 0, function* () {
156
+ if (!inquirer) {
157
+ inquirer = require('inquirer');
158
+ }
159
+ Cli_1.Cli.log(`Please specify one of the following options:`);
160
+ const resultOptionName = yield inquirer
161
+ .prompt({
162
+ type: 'list',
163
+ name: 'missingRequiredOptionName',
164
+ message: `Option to use:`,
165
+ choices: optionSet.options
166
+ });
167
+ const missingRequiredOptionName = resultOptionName.missingRequiredOptionName;
168
+ const resultOptionValue = yield inquirer
169
+ .prompt({
170
+ name: 'missingRequiredOptionValue',
171
+ message: `Value for '${missingRequiredOptionName}':`
172
+ });
173
+ args.options[missingRequiredOptionName] = resultOptionValue.missingRequiredOptionValue;
174
+ Cli_1.Cli.log();
175
+ });
176
+ }
177
+ promptForSpecificOption(args, commonOptions, inquirer) {
178
+ return __awaiter(this, void 0, void 0, function* () {
179
+ if (!inquirer) {
180
+ inquirer = require('inquirer');
181
+ }
182
+ Cli_1.Cli.log(`Multiple options for an option set specified. Please specify the correct option that you wish to use.`);
183
+ const requiredOptionNameResult = yield inquirer
184
+ .prompt({
185
+ type: 'list',
186
+ name: 'missingRequiredOptionName',
187
+ message: `Option to use:`,
188
+ choices: commonOptions
189
+ });
190
+ commonOptions.filter(y => y !== requiredOptionNameResult.missingRequiredOptionName).map(optionName => args.options[optionName] = undefined);
191
+ Cli_1.Cli.log();
192
+ });
193
+ }
145
194
  validateOutput(args) {
146
195
  return __awaiter(this, void 0, void 0, function* () {
147
196
  if (args.options.output &&
@@ -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();
@@ -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