@pnp/cli-microsoft365 5.5.0-beta.e5cdbaf → 5.5.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 (27) hide show
  1. package/dist/m365/aad/commands/o365group/o365group-recyclebinitem-restore.js +60 -9
  2. package/dist/m365/spo/commands/customaction/customaction-get.js +32 -4
  3. package/dist/m365/spo/commands/customaction/customaction-remove.js +43 -8
  4. package/dist/m365/spo/commands/field/field-get.js +14 -5
  5. package/dist/m365/spo/commands/field/field-remove.js +19 -10
  6. package/dist/m365/spo/commands/site/site-classic-list.js +1 -0
  7. package/dist/m365/spo/commands/site/site-classic-set.js +1 -0
  8. package/dist/m365/spo/commands/site/site-list.js +59 -17
  9. package/dist/m365/spo/commands/site/site-set.js +322 -162
  10. package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +9 -6
  11. package/dist/m365/teams/commands/tab/tab-get.js +2 -2
  12. package/dist/m365/teams/commands/team/team-clone.js +33 -7
  13. package/dist/m365/teams/commands/team/team-set.js +25 -5
  14. package/docs/docs/cmd/aad/o365group/o365group-recyclebinitem-restore.md +21 -3
  15. package/docs/docs/cmd/spo/customaction/customaction-get.md +15 -2
  16. package/docs/docs/cmd/spo/customaction/customaction-remove.md +33 -2
  17. package/docs/docs/cmd/spo/field/field-get.md +6 -3
  18. package/docs/docs/cmd/spo/field/field-remove.md +9 -6
  19. package/docs/docs/cmd/spo/site/site-classic-list.md +3 -0
  20. package/docs/docs/cmd/spo/site/site-classic-set.md +3 -0
  21. package/docs/docs/cmd/spo/site/site-list.md +19 -7
  22. package/docs/docs/cmd/spo/site/site-set.md +50 -6
  23. package/docs/docs/cmd/teams/tab/tab-get.md +2 -2
  24. package/docs/docs/cmd/teams/team/team-clone.md +11 -5
  25. package/docs/docs/cmd/teams/team/team-set.md +10 -4
  26. package/npm-shrinkwrap.json +173 -158
  27. package/package.json +14 -14
@@ -14,33 +14,84 @@ class AadO365GroupRecycleBinItemRestoreCommand extends GraphCommand_1.default {
14
14
  alias() {
15
15
  return [commands_1.default.O365GROUP_RESTORE];
16
16
  }
17
+ getTelemetryProperties(args) {
18
+ const telemetryProps = super.getTelemetryProperties(args);
19
+ telemetryProps.id = typeof args.options.id !== 'undefined';
20
+ telemetryProps.displayName = typeof args.options.displayName !== 'undefined';
21
+ telemetryProps.mailNickname = typeof args.options.mailNickname !== 'undefined';
22
+ return telemetryProps;
23
+ }
17
24
  commandAction(logger, args, cb) {
18
25
  if (this.verbose) {
19
- logger.logToStderr(`Restoring Microsoft 365 Group: ${args.options.id}...`);
26
+ logger.logToStderr(`Restoring Microsoft 365 Group: ${args.options.id || args.options.displayName || args.options.mailNickname}...`);
27
+ }
28
+ this
29
+ .getGroupId(args.options)
30
+ .then((groupId) => {
31
+ const requestOptions = {
32
+ url: `${this.resource}/v1.0/directory/deleteditems/${groupId}/restore`,
33
+ headers: {
34
+ accept: 'application/json;odata.metadata=none',
35
+ 'content-type': 'application/json'
36
+ },
37
+ responseType: 'json'
38
+ };
39
+ return request_1.default.post(requestOptions);
40
+ })
41
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
42
+ }
43
+ getGroupId(options) {
44
+ const { id, displayName, mailNickname } = options;
45
+ if (id) {
46
+ return Promise.resolve(id);
47
+ }
48
+ let filterValue = '';
49
+ if (displayName) {
50
+ filterValue = `displayName eq '${utils_1.formatting.encodeQueryParameter(displayName)}'`;
51
+ }
52
+ if (mailNickname) {
53
+ filterValue = `mailNickname eq '${utils_1.formatting.encodeQueryParameter(mailNickname)}'`;
20
54
  }
21
55
  const requestOptions = {
22
- url: `${this.resource}/v1.0/directory/deleteditems/${args.options.id}/restore/`,
56
+ url: `${this.resource}/v1.0/directory/deletedItems/Microsoft.Graph.Group?$filter=${filterValue}`,
23
57
  headers: {
24
- 'accept': 'application/json;odata.metadata=none',
25
- 'content-type': 'application/json'
58
+ accept: 'application/json;odata.metadata=none'
26
59
  },
27
60
  responseType: 'json'
28
61
  };
29
- request_1.default
30
- .post(requestOptions)
31
- .then(_ => cb(), (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
62
+ return request_1.default
63
+ .get(requestOptions)
64
+ .then((response) => {
65
+ const groups = response.value;
66
+ if (groups.length === 0) {
67
+ return Promise.reject(`The specified group '${displayName || mailNickname}' does not exist.`);
68
+ }
69
+ if (groups.length > 1) {
70
+ return Promise.reject(`Multiple groups with name '${displayName || mailNickname}' found: ${groups.map(x => x.id).join(',')}.`);
71
+ }
72
+ return Promise.resolve(groups[0].id);
73
+ });
74
+ }
75
+ optionSets() {
76
+ return [['id', 'displayName', 'mailNickname']];
32
77
  }
33
78
  options() {
34
79
  const options = [
35
80
  {
36
- option: '-i, --id <id>'
81
+ option: '-i, --id [id]'
82
+ },
83
+ {
84
+ option: '-d, --displayName [displayName]'
85
+ },
86
+ {
87
+ option: '-m, --mailNickname [mailNickname]'
37
88
  }
38
89
  ];
39
90
  const parentOptions = super.options();
40
91
  return options.concat(parentOptions);
41
92
  }
42
93
  validate(args) {
43
- if (!utils_1.validation.isValidGuid(args.options.id)) {
94
+ if (args.options.id && !utils_1.validation.isValidGuid(args.options.id)) {
44
95
  return `${args.options.id} is not a valid GUID`;
45
96
  }
46
97
  return true;
@@ -11,6 +11,11 @@ class SpoCustomActionGetCommand extends SpoCommand_1.default {
11
11
  get description() {
12
12
  return 'Gets details for the specified custom action';
13
13
  }
14
+ optionSets() {
15
+ return [
16
+ ['id', 'title']
17
+ ];
18
+ }
14
19
  getTelemetryProperties(args) {
15
20
  const telemetryProps = super.getTelemetryProperties(args);
16
21
  telemetryProps.scope = args.options.scope || 'All';
@@ -56,14 +61,34 @@ class SpoCustomActionGetCommand extends SpoCommand_1.default {
56
61
  }, (err) => this.handleRejectedPromise(err, logger, cb));
57
62
  }
58
63
  getCustomAction(options) {
64
+ const filter = options.id ?
65
+ `('${encodeURIComponent(options.id)}')` :
66
+ `?$filter=Title eq '${encodeURIComponent(options.title)}'`;
59
67
  const requestOptions = {
60
- url: `${options.url}/_api/${options.scope}/UserCustomActions('${encodeURIComponent(options.id)}')`,
68
+ url: `${options.url}/_api/${options.scope}/UserCustomActions${filter}`,
61
69
  headers: {
62
70
  accept: 'application/json;odata=nometadata'
63
71
  },
64
72
  responseType: 'json'
65
73
  };
66
- return request_1.default.get(requestOptions);
74
+ if (options.id) {
75
+ return request_1.default
76
+ .get(requestOptions)
77
+ .then((res) => {
78
+ return Promise.resolve(res);
79
+ });
80
+ }
81
+ return request_1.default
82
+ .get(requestOptions)
83
+ .then((res) => {
84
+ if (res.value.length === 1) {
85
+ return Promise.resolve(res.value[0]);
86
+ }
87
+ if (res.value.length === 0) {
88
+ return Promise.reject(`No user custom action with title '${options.title}' found`);
89
+ }
90
+ return Promise.reject(`Multiple user custom actions with title '${options.title}' found. Please disambiguate using IDs: ${res.value.map(a => a.Id).join(', ')}`);
91
+ });
67
92
  }
68
93
  /**
69
94
  * Get request with `web` scope is send first.
@@ -104,7 +129,10 @@ class SpoCustomActionGetCommand extends SpoCommand_1.default {
104
129
  options() {
105
130
  const options = [
106
131
  {
107
- option: '-i, --id <id>'
132
+ option: '-i, --id [id]'
133
+ },
134
+ {
135
+ option: '-t, --title [title]'
108
136
  },
109
137
  {
110
138
  option: '-u, --url <url>'
@@ -118,7 +146,7 @@ class SpoCustomActionGetCommand extends SpoCommand_1.default {
118
146
  return options.concat(parentOptions);
119
147
  }
120
148
  validate(args) {
121
- if (utils_1.validation.isValidGuid(args.options.id) === false) {
149
+ if (args.options.id && utils_1.validation.isValidGuid(args.options.id) === false) {
122
150
  return `${args.options.id} is not valid. Custom action id (Guid) expected.`;
123
151
  }
124
152
  if (utils_1.validation.isValidSharePointUrl(args.options.url) !== true) {
@@ -12,6 +12,11 @@ class SpoCustomActionRemoveCommand extends SpoCommand_1.default {
12
12
  get description() {
13
13
  return 'Removes the specified custom action';
14
14
  }
15
+ optionSets() {
16
+ return [
17
+ ['id', 'title']
18
+ ];
19
+ }
15
20
  getTelemetryProperties(args) {
16
21
  const telemetryProps = super.getTelemetryProperties(args);
17
22
  telemetryProps.scope = args.options.scope || 'All';
@@ -54,16 +59,43 @@ class SpoCustomActionRemoveCommand extends SpoCommand_1.default {
54
59
  });
55
60
  }
56
61
  }
57
- removeScopedCustomAction(options) {
58
- const requestOptions = {
59
- url: `${options.url}/_api/${options.scope}/UserCustomActions('${encodeURIComponent(options.id)}')`,
62
+ getCustomActionId(options) {
63
+ if (options.id) {
64
+ return Promise.resolve(options.id);
65
+ }
66
+ const customActionRequestOptions = {
67
+ url: `${options.url}/_api/${options.scope}/UserCustomActions?$filter=Title eq '${encodeURIComponent(options.title)}'`,
60
68
  headers: {
61
- accept: 'application/json;odata=nometadata',
62
- 'X-HTTP-Method': 'DELETE'
69
+ accept: 'application/json;odata=nometadata'
63
70
  },
64
71
  responseType: 'json'
65
72
  };
66
- return request_1.default.post(requestOptions);
73
+ return request_1.default
74
+ .get(customActionRequestOptions)
75
+ .then((res) => {
76
+ if (res.value.length === 1) {
77
+ return Promise.resolve(res.value[0].Id);
78
+ }
79
+ if (res.value.length === 0) {
80
+ return Promise.reject(`No user custom action with title '${options.title}' found`);
81
+ }
82
+ return Promise.reject(`Multiple user custom actions with title '${options.title}' found. Please disambiguate using IDs: ${res.value.map(a => a.Id).join(', ')}`);
83
+ });
84
+ }
85
+ removeScopedCustomAction(options) {
86
+ return this
87
+ .getCustomActionId(options)
88
+ .then((customActionId) => {
89
+ const requestOptions = {
90
+ url: `${options.url}/_api/${options.scope}/UserCustomActions('${encodeURIComponent(customActionId)}')')`,
91
+ headers: {
92
+ accept: 'application/json;odata=nometadata',
93
+ 'X-HTTP-Method': 'DELETE'
94
+ },
95
+ responseType: 'json'
96
+ };
97
+ return request_1.default.post(requestOptions);
98
+ });
67
99
  }
68
100
  /**
69
101
  * Remove request with `web` scope is send first.
@@ -95,7 +127,10 @@ class SpoCustomActionRemoveCommand extends SpoCommand_1.default {
95
127
  options() {
96
128
  const options = [
97
129
  {
98
- option: '-i, --id <id>'
130
+ option: '-i, --id [id]'
131
+ },
132
+ {
133
+ option: '-t, --title [title]'
99
134
  },
100
135
  {
101
136
  option: '-u, --url <url>'
@@ -112,7 +147,7 @@ class SpoCustomActionRemoveCommand extends SpoCommand_1.default {
112
147
  return options.concat(parentOptions);
113
148
  }
114
149
  validate(args) {
115
- if (utils_1.validation.isValidGuid(args.options.id) === false) {
150
+ if (args.options.id && utils_1.validation.isValidGuid(args.options.id) === false) {
116
151
  return `${args.options.id} is not valid. Custom action Id (GUID) expected.`;
117
152
  }
118
153
  if (utils_1.validation.isValidSharePointUrl(args.options.url) !== true) {
@@ -17,10 +17,19 @@ class SpoFieldGetCommand extends SpoCommand_1.default {
17
17
  telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
18
18
  telemetryProps.listUrl = typeof args.options.listUrl !== 'undefined';
19
19
  telemetryProps.id = typeof args.options.id !== 'undefined';
20
- telemetryProps.fieldTitle = typeof args.options.fieldTitle !== 'undefined';
20
+ telemetryProps.title = typeof args.options.title !== 'undefined';
21
21
  return telemetryProps;
22
22
  }
23
+ optionSets() {
24
+ return [
25
+ ['id', 'title', 'fieldTitle']
26
+ ];
27
+ }
23
28
  commandAction(logger, args, cb) {
29
+ if (args.options.fieldTitle) {
30
+ args.options.title = args.options.fieldTitle;
31
+ this.warn(logger, `Option 'fieldTitle' is deprecated. Please use 'title' instead.`);
32
+ }
24
33
  let listRestUrl = '';
25
34
  if (args.options.listId) {
26
35
  listRestUrl = `lists(guid'${utils_1.formatting.encodeQueryParameter(args.options.listId)}')/`;
@@ -37,7 +46,7 @@ class SpoFieldGetCommand extends SpoCommand_1.default {
37
46
  fieldRestUrl = `/getbyid('${utils_1.formatting.encodeQueryParameter(args.options.id)}')`;
38
47
  }
39
48
  else {
40
- fieldRestUrl = `/getbyinternalnameortitle('${utils_1.formatting.encodeQueryParameter(args.options.fieldTitle)}')`;
49
+ fieldRestUrl = `/getbyinternalnameortitle('${utils_1.formatting.encodeQueryParameter(args.options.title)}')`;
41
50
  }
42
51
  const requestOptions = {
43
52
  url: `${args.options.webUrl}/_api/web/${listRestUrl}fields${fieldRestUrl}`,
@@ -72,6 +81,9 @@ class SpoFieldGetCommand extends SpoCommand_1.default {
72
81
  },
73
82
  {
74
83
  option: '--fieldTitle [fieldTitle]'
84
+ },
85
+ {
86
+ option: '-t, --title [title]'
75
87
  }
76
88
  ];
77
89
  const parentOptions = super.options();
@@ -82,9 +94,6 @@ class SpoFieldGetCommand extends SpoCommand_1.default {
82
94
  if (isValidSharePointUrl !== true) {
83
95
  return isValidSharePointUrl;
84
96
  }
85
- if (!args.options.id && !args.options.fieldTitle) {
86
- return 'Specify id or fieldTitle, one is required';
87
- }
88
97
  if (args.options.id && !utils_1.validation.isValidGuid(args.options.id)) {
89
98
  return `${args.options.id} is not a valid GUID`;
90
99
  }
@@ -19,11 +19,20 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
19
19
  telemetryProps.listUrl = typeof args.options.listUrl !== 'undefined';
20
20
  telemetryProps.id = typeof args.options.id !== 'undefined';
21
21
  telemetryProps.group = typeof args.options.group !== 'undefined';
22
- telemetryProps.fieldTitle = typeof args.options.fieldTitle !== 'undefined';
22
+ telemetryProps.title = typeof args.options.title !== 'undefined';
23
23
  telemetryProps.confirm = (!(!args.options.confirm)).toString();
24
24
  return telemetryProps;
25
25
  }
26
+ optionSets() {
27
+ return [
28
+ ['id', 'title', 'fieldTitle', 'group']
29
+ ];
30
+ }
26
31
  commandAction(logger, args, cb) {
32
+ if (args.options.fieldTitle) {
33
+ args.options.title = args.options.fieldTitle;
34
+ this.warn(logger, `Option 'fieldTitle' is deprecated. Please use 'title' instead.`);
35
+ }
27
36
  let messageEnd;
28
37
  if (args.options.listId || args.options.listTitle) {
29
38
  messageEnd = `in list ${args.options.listId || args.options.listTitle}`;
@@ -31,16 +40,16 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
31
40
  else {
32
41
  messageEnd = `in site ${args.options.webUrl}`;
33
42
  }
34
- const removeField = (listRestUrl, fieldId, fieldTitle) => {
43
+ const removeField = (listRestUrl, fieldId, title) => {
35
44
  if (this.verbose) {
36
- logger.logToStderr(`Removing field ${fieldId || fieldTitle} ${messageEnd}...`);
45
+ logger.logToStderr(`Removing field ${fieldId || title} ${messageEnd}...`);
37
46
  }
38
47
  let fieldRestUrl = '';
39
48
  if (fieldId) {
40
49
  fieldRestUrl = `/getbyid('${utils_1.formatting.encodeQueryParameter(fieldId)}')`;
41
50
  }
42
51
  else {
43
- fieldRestUrl = `/getbyinternalnameortitle('${utils_1.formatting.encodeQueryParameter(fieldTitle)}')`;
52
+ fieldRestUrl = `/getbyinternalnameortitle('${utils_1.formatting.encodeQueryParameter(title)}')`;
44
53
  }
45
54
  const requestOptions = {
46
55
  url: `${args.options.webUrl}/_api/web/${listRestUrl}fields${fieldRestUrl}`,
@@ -97,7 +106,7 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
97
106
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
98
107
  }
99
108
  else {
100
- removeField(listRestUrl, args.options.id, args.options.fieldTitle)
109
+ removeField(listRestUrl, args.options.id, args.options.title)
101
110
  .then(() => {
102
111
  // REST post call doesn't return anything
103
112
  cb();
@@ -108,7 +117,7 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
108
117
  prepareRemoval();
109
118
  }
110
119
  else {
111
- const confirmMessage = `Are you sure you want to remove the ${args.options.group ? 'fields' : 'field'} ${args.options.id || args.options.fieldTitle || 'from group ' + args.options.group} ${messageEnd}?`;
120
+ const confirmMessage = `Are you sure you want to remove the ${args.options.group ? 'fields' : 'field'} ${args.options.id || args.options.title || 'from group ' + args.options.group} ${messageEnd}?`;
112
121
  cli_1.Cli.prompt({
113
122
  type: 'confirm',
114
123
  name: 'continue',
@@ -142,7 +151,10 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
142
151
  option: '-i, --id [id]'
143
152
  },
144
153
  {
145
- option: '-t, --fieldTitle [fieldTitle]'
154
+ option: '--fieldTitle [fieldTitle]'
155
+ },
156
+ {
157
+ option: '-t, --title [title]'
146
158
  },
147
159
  {
148
160
  option: '-g, --group [group]'
@@ -159,9 +171,6 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
159
171
  if (isValidSharePointUrl !== true) {
160
172
  return isValidSharePointUrl;
161
173
  }
162
- if (!args.options.id && !args.options.fieldTitle && !args.options.group) {
163
- return 'Specify id, fieldTitle, or group. One is required';
164
- }
165
174
  if (args.options.id && !utils_1.validation.isValidGuid(args.options.id)) {
166
175
  return `${args.options.id} is not a valid GUID`;
167
176
  }
@@ -23,6 +23,7 @@ class SpoSiteClassicListCommand extends SpoCommand_1.default {
23
23
  return ['Title', 'Url'];
24
24
  }
25
25
  commandAction(logger, args, cb) {
26
+ this.showDeprecationWarning(logger, commands_1.default.SITE_CLASSIC_LIST, commands_1.default.SITE_LIST);
26
27
  const webTemplate = args.options.webTemplate || '';
27
28
  const includeOneDriveSites = args.options.includeOneDriveSites || false;
28
29
  const personalSite = includeOneDriveSites === false ? '0' : '1';
@@ -29,6 +29,7 @@ class SpoSiteClassicSetCommand extends SpoCommand_1.default {
29
29
  return telemetryProps;
30
30
  }
31
31
  commandAction(logger, args, cb) {
32
+ this.showDeprecationWarning(logger, commands_1.default.SITE_CLASSIC_SET, commands_1.default.SITE_SET);
32
33
  this.dots = '';
33
34
  utils_1.spo
34
35
  .getTenantId(logger, this.debug)
@@ -10,22 +10,25 @@ class SpoSiteListCommand extends SpoCommand_1.default {
10
10
  return commands_1.default.SITE_LIST;
11
11
  }
12
12
  get description() {
13
- return 'Lists modern sites of the given type';
13
+ return 'Lists sites of the given type';
14
14
  }
15
15
  getTelemetryProperties(args) {
16
16
  const telemetryProps = super.getTelemetryProperties(args);
17
- telemetryProps.siteType = args.options.type || 'TeamSite';
17
+ telemetryProps.webTemplate = args.options.webTemplate;
18
18
  telemetryProps.filter = (!(!args.options.filter)).toString();
19
- telemetryProps.deleted = args.options.deleted;
19
+ telemetryProps.includeOneDriveSites = typeof args.options.includeOneDriveSites !== 'undefined';
20
+ telemetryProps.deleted = typeof args.options.deleted !== 'undefined';
21
+ telemetryProps.siteType = args.options.type || 'TeamSite';
20
22
  return telemetryProps;
21
23
  }
22
24
  defaultProperties() {
23
25
  return ['Title', 'Url'];
24
26
  }
25
27
  commandAction(logger, args, cb) {
26
- const siteType = args.options.type || 'TeamSite';
27
- const webTemplate = siteType === 'TeamSite' ? 'GROUP#0' : 'SITEPAGEPUBLISHING#0';
28
- let spoAdminUrl;
28
+ const webTemplate = this.getWebTemplateId(args.options);
29
+ const includeOneDriveSites = args.options.includeOneDriveSites || false;
30
+ const personalSite = includeOneDriveSites === false ? '0' : '1';
31
+ let spoAdminUrl = '';
29
32
  utils_1.spo
30
33
  .getSpoAdminUrl(logger, this.debug)
31
34
  .then((_spoAdminUrl) => {
@@ -34,19 +37,19 @@ class SpoSiteListCommand extends SpoCommand_1.default {
34
37
  logger.logToStderr(`Retrieving list of site collections...`);
35
38
  }
36
39
  this.allSites = [];
37
- return this.getAllSites(spoAdminUrl, utils_1.formatting.escapeXml(args.options.filter || ''), '0', webTemplate, undefined, args.options.deleted, logger);
40
+ return this.getAllSites(spoAdminUrl, utils_1.formatting.escapeXml(args.options.filter || ''), '0', personalSite, webTemplate, undefined, args.options.deleted, logger);
38
41
  })
39
42
  .then(_ => {
40
43
  logger.log(this.allSites);
41
44
  cb();
42
45
  }, (err) => this.handleRejectedPromise(err, logger, cb));
43
46
  }
44
- getAllSites(spoAdminUrl, filter, startIndex, webTemplate, formDigest, deleted, logger) {
47
+ getAllSites(spoAdminUrl, filter, startIndex, personalSite, webTemplate, formDigest, deleted, logger) {
45
48
  return new Promise((resolve, reject) => {
46
49
  utils_1.spo
47
50
  .ensureFormDigest(spoAdminUrl, logger, formDigest, this.debug)
48
51
  .then((res) => {
49
- let requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectPath Id="4" ObjectPathId="3" /><Query Id="5" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="3" ParentId="1" Name="GetSitePropertiesFromSharePointByFilters"><Parameters><Parameter TypeId="{b92aeee2-c92c-4b67-abcc-024e471bc140}"><Property Name="Filter" Type="String">${filter}</Property><Property Name="IncludeDetail" Type="Boolean">false</Property><Property Name="IncludePersonalSite" Type="Enum">0</Property><Property Name="StartIndex" Type="String">${startIndex}</Property><Property Name="Template" Type="String">${webTemplate}</Property></Parameter></Parameters></Method></ObjectPaths></Request>`;
52
+ let requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="2" ObjectPathId="1" /><ObjectPath Id="4" ObjectPathId="3" /><Query Id="5" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="3" ParentId="1" Name="GetSitePropertiesFromSharePointByFilters"><Parameters><Parameter TypeId="{b92aeee2-c92c-4b67-abcc-024e471bc140}"><Property Name="Filter" Type="String">${filter}</Property><Property Name="IncludeDetail" Type="Boolean">false</Property><Property Name="IncludePersonalSite" Type="Enum">${personalSite}</Property><Property Name="StartIndex" Type="String">${startIndex}</Property><Property Name="Template" Type="String">${webTemplate}</Property></Parameter></Parameters></Method></ObjectPaths></Request>`;
50
53
  if (deleted) {
51
54
  requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="4" ObjectPathId="3" /><ObjectPath Id="6" ObjectPathId="5" /><Query Id="7" ObjectPathId="5"><Query SelectAllProperties="true"><Properties><Property Name="NextStartIndexFromSharePoint" ScalarProperty="true" /></Properties></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="3" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="5" ParentId="3" Name="GetDeletedSitePropertiesFromSharePoint"><Parameters><Parameter Type="String">${startIndex}</Parameter></Parameters></Method></ObjectPaths></Request>`;
52
55
  }
@@ -71,7 +74,7 @@ class SpoSiteListCommand extends SpoCommand_1.default {
71
74
  this.allSites.push(...sites._Child_Items_);
72
75
  if (sites.NextStartIndexFromSharePoint) {
73
76
  this
74
- .getAllSites(spoAdminUrl, filter, sites.NextStartIndexFromSharePoint, webTemplate, formDigest, deleted, logger)
77
+ .getAllSites(spoAdminUrl, filter, sites.NextStartIndexFromSharePoint, personalSite, webTemplate, formDigest, deleted, logger)
75
78
  .then(_ => resolve(), err => reject(err));
76
79
  }
77
80
  else {
@@ -81,15 +84,48 @@ class SpoSiteListCommand extends SpoCommand_1.default {
81
84
  }, err => reject(err));
82
85
  });
83
86
  }
87
+ /*
88
+ The type property currently defaults to Teamsite.
89
+ It makes more sense to default to All. Certainly after adding the 'includeOneDriveSites' option.
90
+ Changing this will be a breaking change. We'll remove the default the next major version.
91
+ */
92
+ getWebTemplateId(options) {
93
+ if (options.webTemplate) {
94
+ return options.webTemplate;
95
+ }
96
+ if (options.includeOneDriveSites) {
97
+ return '';
98
+ }
99
+ let siteType = options.type;
100
+ if (!siteType) {
101
+ siteType = 'TeamSite';
102
+ }
103
+ switch (siteType) {
104
+ case "TeamSite":
105
+ return 'GROUP#0';
106
+ case "CommunicationSite":
107
+ return 'SITEPAGEPUBLISHING#0';
108
+ default:
109
+ return '';
110
+ }
111
+ }
84
112
  options() {
85
113
  const options = [
86
114
  {
87
- option: '--type [type]',
88
- autocomplete: ['TeamSite', 'CommunicationSite']
115
+ option: '-t, --type [type]',
116
+ // To not introduce a breaking change, 'All' has been added.
117
+ // You should use all when using '--includeOneDriveSites'
118
+ autocomplete: ['TeamSite', 'CommunicationSite', 'All']
119
+ },
120
+ {
121
+ option: '--webTemplate [webTemplate]'
89
122
  },
90
123
  {
91
124
  option: '-f, --filter [filter]'
92
125
  },
126
+ {
127
+ option: '--includeOneDriveSites'
128
+ },
93
129
  {
94
130
  option: '--deleted'
95
131
  }
@@ -98,11 +134,17 @@ class SpoSiteListCommand extends SpoCommand_1.default {
98
134
  return options.concat(parentOptions);
99
135
  }
100
136
  validate(args) {
101
- if (args.options.type) {
102
- if (args.options.type !== 'TeamSite' &&
103
- args.options.type !== 'CommunicationSite') {
104
- return `${args.options.type} is not a valid modern site type. Allowed types are TeamSite and CommunicationSite`;
105
- }
137
+ if (args.options.type && args.options.webTemplate) {
138
+ return 'Specify either type or webTemplate, but not both';
139
+ }
140
+ const typeValues = ['TeamSite', 'CommunicationSite', 'All'];
141
+ if (args.options.type &&
142
+ typeValues.indexOf(args.options.type) < 0) {
143
+ return `${args.options.type} is not a valid value for the type option. Allowed values are ${typeValues.join('|')}`;
144
+ }
145
+ if (args.options.includeOneDriveSites
146
+ && (!args.options.type || args.options.type !== 'All')) {
147
+ return 'When using includeOneDriveSites, specify All as value for type';
106
148
  }
107
149
  return true;
108
150
  }