@pnp/cli-microsoft365 7.0.0-beta.99e75a7 → 7.0.0-beta.b2eab57

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 (31) hide show
  1. package/dist/cli/Cli.js +19 -2
  2. package/dist/m365/spo/commands/file/file-move.js +73 -97
  3. package/dist/m365/spo/commands/folder/folder-copy.js +89 -45
  4. package/dist/m365/spo/commands/folder/folder-move.js +89 -47
  5. package/dist/m365/spo/commands/propertybag/propertybag-base.js +63 -59
  6. package/dist/m365/spo/commands/propertybag/propertybag-remove.js +28 -31
  7. package/dist/m365/spo/commands/site/FlowsPolicy.js +7 -0
  8. package/dist/m365/spo/commands/site/site-ensure.js +3 -3
  9. package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +22 -22
  10. package/dist/m365/spo/commands/site/site-list.js +29 -39
  11. package/dist/m365/spo/commands/site/site-set.js +58 -47
  12. package/dist/m365/spo/commands/theme/theme-remove.js +24 -24
  13. package/dist/m365/spo/commands/theme/theme-set.js +0 -1
  14. package/dist/m365/spo/commands/user/user-remove.js +27 -27
  15. package/dist/m365/spo/commands/web/web-reindex.js +35 -42
  16. package/dist/m365/spo/commands/web/web-remove.js +21 -21
  17. package/dist/m365/spo/commands/web/web-roleassignment-add.js +16 -31
  18. package/dist/m365/spo/commands/web/web-roleassignment-remove.js +33 -44
  19. package/dist/m365/spo/commands/web/web-roleinheritance-break.js +18 -18
  20. package/dist/m365/spo/commands/web/web-roleinheritance-reset.js +19 -19
  21. package/dist/m365/yammer/commands/message/message-like-set.js +27 -28
  22. package/dist/m365/yammer/commands/message/message-list.js +62 -81
  23. package/dist/m365/yammer/commands/message/message-remove.js +18 -18
  24. package/dist/m365/yammer/commands/yammer-search.js +53 -69
  25. package/dist/utils/spo.js +12 -53
  26. package/docs/docs/cmd/spo/file/file-move.mdx +36 -18
  27. package/docs/docs/cmd/spo/folder/folder-copy.mdx +39 -12
  28. package/docs/docs/cmd/spo/folder/folder-move.mdx +40 -13
  29. package/docs/docs/cmd/spo/site/site-ensure.mdx +1 -1
  30. package/npm-shrinkwrap.json +1 -1
  31. package/package.json +1 -1
@@ -13,7 +13,7 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
13
13
  * Gets property bag for a folder or site rootFolder of a site where return type is "_ObjectType_\":\"SP.Folder\".
14
14
  * This method is executed when folder option is specified. PnP PowerShell behaves the same way.
15
15
  */
16
- getFolderPropertyBag(identityResp, webUrl, folder, logger) {
16
+ async getFolderPropertyBag(identityResp, webUrl, folder, logger) {
17
17
  let serverRelativeUrl = folder;
18
18
  if (identityResp.serverRelativeUrl !== '/') {
19
19
  serverRelativeUrl = `${identityResp.serverRelativeUrl}${serverRelativeUrl}`;
@@ -25,31 +25,31 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
25
25
  },
26
26
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="10" ObjectPathId="9" /><ObjectIdentityQuery Id="11" ObjectPathId="9" /><Query Id="12" ObjectPathId="9"><Query SelectAllProperties="false"><Properties><Property Name="Properties" SelectAll="true"><Query SelectAllProperties="false"><Properties /></Query></Property></Properties></Query></Query></Actions><ObjectPaths><Method Id="9" ParentId="5" Name="GetFolderByServerRelativeUrl"><Parameters><Parameter Type="String">${serverRelativeUrl}</Parameter></Parameters></Method><Identity Id="5" Name="${identityResp.objectIdentity}" /></ObjectPaths></Request>`
27
27
  };
28
- return new Promise((resolve, reject) => {
29
- return request
30
- .post(requestOptions)
31
- .then(async (res) => {
32
- if (this.debug) {
33
- await logger.logToStderr('Attempt to get Properties key values');
34
- }
35
- const json = JSON.parse(res);
36
- const contents = json.find(x => { return x['ErrorInfo']; });
37
- if (contents && contents.ErrorInfo) {
38
- return reject(contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error');
39
- }
40
- const propertiesObj = json.find(x => { return x['Properties']; });
41
- if (propertiesObj) {
42
- return resolve(propertiesObj['Properties']);
43
- }
44
- reject('Cannot proceed. Properties not found'); // this is not suppose to happen
45
- }, (err) => { reject(err); });
46
- });
28
+ try {
29
+ const res = await request.post(requestOptions);
30
+ if (this.debug) {
31
+ await logger.logToStderr('Attempt to get Properties key values');
32
+ }
33
+ const json = JSON.parse(res);
34
+ const contents = json.find(x => { return x['ErrorInfo']; });
35
+ if (contents && contents.ErrorInfo) {
36
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
37
+ }
38
+ const propertiesObj = json.find(x => { return x['Properties']; });
39
+ if (propertiesObj) {
40
+ return propertiesObj['Properties'];
41
+ }
42
+ throw 'Cannot proceed. Properties not found'; // this is not suppose to happen
43
+ }
44
+ catch (err) {
45
+ throw err;
46
+ }
47
47
  }
48
48
  /**
49
49
  * Gets property bag for site or sitecollection where return type is "_ObjectType_\":\"SP.Web\".
50
50
  * This method is executed when no folder specified. PnP PowerShell behaves the same way.
51
51
  */
52
- getWebPropertyBag(identityResp, webUrl, logger) {
52
+ async getWebPropertyBag(identityResp, webUrl, logger) {
53
53
  const requestOptions = {
54
54
  url: `${webUrl}/_vti_bin/client.svc/ProcessQuery`,
55
55
  headers: {
@@ -57,23 +57,25 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
57
57
  },
58
58
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Query Id="97" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="ServerRelativeUrl" ScalarProperty="true" /><Property Name="AllProperties" SelectAll="true"><Query SelectAllProperties="false"><Properties /></Query></Property></Properties></Query></Query></Actions><ObjectPaths><Identity Id="5" Name="${identityResp.objectIdentity}" /></ObjectPaths></Request>`
59
59
  };
60
- return new Promise((resolve, reject) => {
61
- request.post(requestOptions).then(async (res) => {
62
- if (this.debug) {
63
- await logger.logToStderr('Attempt to get AllProperties key values');
64
- }
65
- const json = JSON.parse(res);
66
- const contents = json.find(x => { return x['ErrorInfo']; });
67
- if (contents && contents.ErrorInfo) {
68
- return reject(contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error');
69
- }
70
- const allPropertiesObj = json.find(x => { return x['AllProperties']; });
71
- if (allPropertiesObj) {
72
- return resolve(allPropertiesObj['AllProperties']);
73
- }
74
- reject('Cannot proceed. AllProperties not found'); // this is not supposed to happen
75
- }, (err) => { reject(err); });
76
- });
60
+ try {
61
+ const res = await request.post(requestOptions);
62
+ if (this.debug) {
63
+ await logger.logToStderr('Attempt to get AllProperties key values');
64
+ }
65
+ const json = JSON.parse(res);
66
+ const contents = json.find(x => { return x['ErrorInfo']; });
67
+ if (contents && contents.ErrorInfo) {
68
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
69
+ }
70
+ const allPropertiesObj = json.find(x => { return x['AllProperties']; });
71
+ if (allPropertiesObj) {
72
+ return allPropertiesObj['AllProperties'];
73
+ }
74
+ throw 'Cannot proceed. AllProperties not found'; // this is not supposed to happen
75
+ }
76
+ catch (err) {
77
+ throw err;
78
+ }
77
79
  }
78
80
  /**
79
81
  * The property bag item data returned from the client.svc/ProcessQuery response
@@ -108,7 +110,7 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
108
110
  }
109
111
  return { key: objKey, value: objValue };
110
112
  }
111
- static setProperty(name, value, webUrl, formDigest, identityResp, logger, debug, folder) {
113
+ static async setProperty(name, value, webUrl, formDigest, identityResp, logger, debug, folder) {
112
114
  let objectType = 'AllProperties';
113
115
  if (folder) {
114
116
  objectType = 'Properties';
@@ -120,18 +122,20 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
120
122
  },
121
123
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Method Name="SetFieldValue" Id="206" ObjectPathId="205"><Parameters><Parameter Type="String">${formatting.escapeXml(name)}</Parameter><Parameter Type="String">${formatting.escapeXml(value)}</Parameter></Parameters></Method><Method Name="Update" Id="207" ObjectPathId="198" /></Actions><ObjectPaths><Property Id="205" ParentId="198" Name="${objectType}" /><Identity Id="198" Name="${identityResp.objectIdentity}" /></ObjectPaths></Request>`
122
124
  };
123
- return new Promise((resolve, reject) => {
124
- request.post(requestOptions).then((res) => {
125
- const json = JSON.parse(res);
126
- const contents = json.find(x => { return x['ErrorInfo']; });
127
- if (contents && contents.ErrorInfo) {
128
- reject(contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error');
129
- }
130
- else {
131
- resolve(res);
132
- }
133
- }, (err) => { reject(err); });
134
- });
125
+ try {
126
+ const res = await request.post(requestOptions);
127
+ const json = JSON.parse(res);
128
+ const contents = json.find(x => { return x['ErrorInfo']; });
129
+ if (contents && contents.ErrorInfo) {
130
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
131
+ }
132
+ else {
133
+ return res;
134
+ }
135
+ }
136
+ catch (err) {
137
+ throw err;
138
+ }
135
139
  }
136
140
  /**
137
141
  * Detects if the site in question has no script enabled or not. Detection is done
@@ -141,14 +145,14 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
141
145
  * @param options command options
142
146
  * @param cmd command instance
143
147
  */
144
- static isNoScriptSite(webUrl, formDigest, webIdentityResp, logger, debug) {
145
- return new Promise((resolve, reject) => {
146
- spo.getEffectiveBasePermissions(webIdentityResp.objectIdentity, webUrl, formDigest, logger, debug)
147
- .then((basePermissionsResp) => {
148
- resolve(basePermissionsResp.has(PermissionKind.AddAndCustomizePages) === false);
149
- })
150
- .catch(err => reject(err));
151
- });
148
+ static async isNoScriptSite(webUrl, formDigest, webIdentityResp, logger, debug) {
149
+ try {
150
+ const basePermissionsResp = await spo.getEffectiveBasePermissions(webIdentityResp.objectIdentity, webUrl, formDigest, logger, debug);
151
+ return basePermissionsResp.has(PermissionKind.AddAndCustomizePages) === false;
152
+ }
153
+ catch (err) {
154
+ throw err;
155
+ }
152
156
  }
153
157
  }
154
158
  //# sourceMappingURL=propertybag-base.js.map
@@ -27,24 +27,8 @@ class SpoPropertyBagRemoveCommand extends SpoPropertyBagBaseCommand {
27
27
  __classPrivateFieldGet(this, _SpoPropertyBagRemoveCommand_instances, "m", _SpoPropertyBagRemoveCommand_initValidators).call(this);
28
28
  }
29
29
  async commandAction(logger, args) {
30
- const removeProperty = async () => {
31
- try {
32
- const contextResponse = await spo.getRequestDigest(args.options.webUrl);
33
- this.formDigestValue = contextResponse.FormDigestValue;
34
- let identityResp = await spo.getCurrentWebIdentity(args.options.webUrl, this.formDigestValue);
35
- const opts = args.options;
36
- if (opts.folder) {
37
- // get the folder guid instead of the web guid
38
- identityResp = await spo.getFolderIdentity(identityResp.objectIdentity, opts.webUrl, opts.folder, this.formDigestValue);
39
- }
40
- await this.removeProperty(identityResp, args.options);
41
- }
42
- catch (err) {
43
- this.handleRejectedPromise(err);
44
- }
45
- };
46
30
  if (args.options.force) {
47
- await removeProperty();
31
+ await this.removeProperty(args);
48
32
  }
49
33
  else {
50
34
  const result = await Cli.prompt({
@@ -54,11 +38,27 @@ class SpoPropertyBagRemoveCommand extends SpoPropertyBagBaseCommand {
54
38
  message: `Are you sure you want to remove the ${args.options.key} property?`
55
39
  });
56
40
  if (result.continue) {
57
- await removeProperty();
41
+ await this.removeProperty(args);
58
42
  }
59
43
  }
60
44
  }
61
- removeProperty(identityResp, options) {
45
+ async removeProperty(args) {
46
+ try {
47
+ const contextResponse = await spo.getRequestDigest(args.options.webUrl);
48
+ this.formDigestValue = contextResponse.FormDigestValue;
49
+ let identityResp = await spo.getCurrentWebIdentity(args.options.webUrl, this.formDigestValue);
50
+ const opts = args.options;
51
+ if (opts.folder) {
52
+ // get the folder guid instead of the web guid
53
+ identityResp = await spo.getFolderIdentity(identityResp.objectIdentity, opts.webUrl, opts.folder, this.formDigestValue);
54
+ }
55
+ await this.removePropertyWithIdentityResp(identityResp, args.options);
56
+ }
57
+ catch (err) {
58
+ this.handleRejectedPromise(err);
59
+ }
60
+ }
61
+ async removePropertyWithIdentityResp(identityResp, options) {
62
62
  let objectType = 'AllProperties';
63
63
  if (options.folder) {
64
64
  objectType = 'Properties';
@@ -70,18 +70,15 @@ class SpoPropertyBagRemoveCommand extends SpoPropertyBagBaseCommand {
70
70
  },
71
71
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Method Name="SetFieldValue" Id="206" ObjectPathId="205"><Parameters><Parameter Type="String">${formatting.escapeXml(options.key)}</Parameter><Parameter Type="Null" /></Parameters></Method><Method Name="Update" Id="207" ObjectPathId="198" /></Actions><ObjectPaths><Property Id="205" ParentId="198" Name="${objectType}" /><Identity Id="198" Name="${identityResp.objectIdentity}" /></ObjectPaths></Request>`
72
72
  };
73
- return new Promise((resolve, reject) => {
74
- request.post(requestOptions).then((res) => {
75
- const json = JSON.parse(res);
76
- const contents = json.find(x => { return x['ErrorInfo']; });
77
- if (contents && contents.ErrorInfo) {
78
- reject(contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error');
79
- }
80
- else {
81
- resolve(res);
82
- }
83
- }, (err) => { reject(err); });
84
- });
73
+ const res = await request.post(requestOptions);
74
+ const json = JSON.parse(res);
75
+ const contents = json.find(x => { return x['ErrorInfo']; });
76
+ if (contents && contents.ErrorInfo) {
77
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
78
+ }
79
+ else {
80
+ return res;
81
+ }
85
82
  }
86
83
  }
87
84
  _SpoPropertyBagRemoveCommand_instances = new WeakSet(), _SpoPropertyBagRemoveCommand_initTelemetry = function _SpoPropertyBagRemoveCommand_initTelemetry() {
@@ -0,0 +1,7 @@
1
+ export var FlowsPolicy;
2
+ (function (FlowsPolicy) {
3
+ FlowsPolicy[FlowsPolicy["Unknown"] = 0] = "Unknown";
4
+ FlowsPolicy[FlowsPolicy["Disabled"] = 1] = "Disabled";
5
+ FlowsPolicy[FlowsPolicy["Enabled"] = 2] = "Enabled";
6
+ })(FlowsPolicy || (FlowsPolicy = {}));
7
+ //# sourceMappingURL=FlowsPolicy.js.map
@@ -79,7 +79,7 @@ class SpoSiteEnsureCommand extends SpoCommand {
79
79
  expectedWebTemplate = 'SITEPAGEPUBLISHING#0';
80
80
  break;
81
81
  case 'ClassicSite':
82
- expectedWebTemplate = args.options.webTemplate;
82
+ expectedWebTemplate = args.options.webTemplate || 'STS#0';
83
83
  break;
84
84
  default:
85
85
  throw `${args.options.type} is not a valid site type. Allowed types are TeamSite,CommunicationSite,ClassicSite`;
@@ -138,7 +138,7 @@ class SpoSiteEnsureCommand extends SpoCommand {
138
138
  };
139
139
  const validationResult = await spoSiteAddCommand.validate({ options: options }, Cli.getCommandInfo(spoSiteAddCommand));
140
140
  if (validationResult !== true) {
141
- return Promise.reject(validationResult);
141
+ throw validationResult;
142
142
  }
143
143
  return Cli.executeCommandWithOutput(spoSiteAddCommand, { options: { ...options, _: [] } });
144
144
  }
@@ -161,7 +161,7 @@ class SpoSiteEnsureCommand extends SpoCommand {
161
161
  };
162
162
  const validationResult = await spoSiteSetCommand.validate({ options: options }, Cli.getCommandInfo(spoSiteSetCommand));
163
163
  if (validationResult !== true) {
164
- return Promise.reject(validationResult);
164
+ throw validationResult;
165
165
  }
166
166
  return Cli.executeCommandWithOutput(spoSiteSetCommand, { options: { ...options, _: [] } });
167
167
  }
@@ -25,28 +25,8 @@ class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
25
25
  __classPrivateFieldGet(this, _SpoSiteHubSiteDisconnectCommand_instances, "m", _SpoSiteHubSiteDisconnectCommand_initValidators).call(this);
26
26
  }
27
27
  async commandAction(logger, args) {
28
- const disconnectHubSite = async () => {
29
- try {
30
- const res = await spo.getRequestDigest(args.options.siteUrl);
31
- if (this.verbose) {
32
- await logger.logToStderr(`Disconnecting site collection ${args.options.siteUrl} from its hubsite...`);
33
- }
34
- const requestOptions = {
35
- url: `${args.options.siteUrl}/_api/site/JoinHubSite('00000000-0000-0000-0000-000000000000')`,
36
- headers: {
37
- 'X-RequestDigest': res.FormDigestValue,
38
- accept: 'application/json;odata=nometadata'
39
- },
40
- responseType: 'json'
41
- };
42
- await request.post(requestOptions);
43
- }
44
- catch (err) {
45
- this.handleRejectedODataJsonPromise(err);
46
- }
47
- };
48
28
  if (args.options.force) {
49
- await disconnectHubSite();
29
+ await this.disconnectHubSite(logger, args);
50
30
  }
51
31
  else {
52
32
  const result = await Cli.prompt({
@@ -56,8 +36,28 @@ class SpoSiteHubSiteDisconnectCommand extends SpoCommand {
56
36
  message: `Are you sure you want to disconnect the site collection ${args.options.siteUrl} from its hub site?`
57
37
  });
58
38
  if (result.continue) {
59
- await disconnectHubSite();
39
+ await this.disconnectHubSite(logger, args);
40
+ }
41
+ }
42
+ }
43
+ async disconnectHubSite(logger, args) {
44
+ try {
45
+ const res = await spo.getRequestDigest(args.options.siteUrl);
46
+ if (this.verbose) {
47
+ await logger.logToStderr(`Disconnecting site collection ${args.options.siteUrl} from its hubsite...`);
60
48
  }
49
+ const requestOptions = {
50
+ url: `${args.options.siteUrl}/_api/site/JoinHubSite('00000000-0000-0000-0000-000000000000')`,
51
+ headers: {
52
+ 'X-RequestDigest': res.FormDigestValue,
53
+ accept: 'application/json;odata=nometadata'
54
+ },
55
+ responseType: 'json'
56
+ };
57
+ await request.post(requestOptions);
58
+ }
59
+ catch (err) {
60
+ this.handleRejectedODataJsonPromise(err);
61
61
  }
62
62
  }
63
63
  }
@@ -44,45 +44,35 @@ class SpoSiteListCommand extends SpoCommand {
44
44
  this.handleRejectedODataJsonPromise(err);
45
45
  }
46
46
  }
47
- getAllSites(spoAdminUrl, filter, startIndex, personalSite, webTemplate, formDigest, deleted, logger) {
48
- return new Promise((resolve, reject) => {
49
- spo
50
- .ensureFormDigest(spoAdminUrl, logger, formDigest, this.debug)
51
- .then((res) => {
52
- let requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.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>`;
53
- if (deleted) {
54
- requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.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>`;
55
- }
56
- const requestOptions = {
57
- url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
58
- headers: {
59
- 'X-RequestDigest': res.FormDigestValue
60
- },
61
- data: requestBody
62
- };
63
- return request.post(requestOptions);
64
- })
65
- .then((res) => {
66
- const json = JSON.parse(res);
67
- const response = json[0];
68
- if (response.ErrorInfo) {
69
- reject(response.ErrorInfo.ErrorMessage);
70
- return;
71
- }
72
- else {
73
- const sites = json[json.length - 1];
74
- this.allSites.push(...sites._Child_Items_);
75
- if (sites.NextStartIndexFromSharePoint) {
76
- this
77
- .getAllSites(spoAdminUrl, filter, sites.NextStartIndexFromSharePoint, personalSite, webTemplate, formDigest, deleted, logger)
78
- .then(_ => resolve(), err => reject(err));
79
- }
80
- else {
81
- resolve();
82
- }
83
- }
84
- }, err => reject(err));
85
- });
47
+ async getAllSites(spoAdminUrl, filter, startIndex, personalSite, webTemplate, formDigest, deleted, logger) {
48
+ const res = await spo.ensureFormDigest(spoAdminUrl, logger, formDigest, this.debug);
49
+ let requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.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
+ if (deleted) {
51
+ requestBody = `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.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
+ }
53
+ const requestOptions = {
54
+ url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
55
+ headers: {
56
+ 'X-RequestDigest': res.FormDigestValue
57
+ },
58
+ data: requestBody
59
+ };
60
+ const res1 = await request.post(requestOptions);
61
+ const json = JSON.parse(res1);
62
+ const response = json[0];
63
+ logger.log(response);
64
+ if (response.ErrorInfo) {
65
+ throw response.ErrorInfo.ErrorMessage;
66
+ }
67
+ else {
68
+ const sites = json[json.length - 1];
69
+ logger.log(sites);
70
+ this.allSites.push(...sites._Child_Items_);
71
+ if (sites.NextStartIndexFromSharePoint) {
72
+ await this.getAllSites(spoAdminUrl, filter, sites.NextStartIndexFromSharePoint, personalSite, webTemplate, formDigest, deleted, logger);
73
+ }
74
+ return;
75
+ }
86
76
  }
87
77
  getWebTemplateId(options) {
88
78
  if (options.webTemplate) {
@@ -17,6 +17,7 @@ import SpoCommand from '../../../base/SpoCommand.js';
17
17
  import commands from '../../commands.js';
18
18
  import { SharingCapabilities } from '../site/SharingCapabilities.js';
19
19
  import spoSiteDesignApplyCommand from '../sitedesign/sitedesign-apply.js';
20
+ import { FlowsPolicy } from './FlowsPolicy.js';
20
21
  class SpoSiteSetCommand extends SpoCommand {
21
22
  get name() {
22
23
  return commands.SITE_SET;
@@ -296,12 +297,11 @@ class SpoSiteSetCommand extends SpoCommand {
296
297
  }));
297
298
  });
298
299
  }
299
- updateSiteProperties(logger, args) {
300
+ async updateSiteProperties(logger, args) {
300
301
  const isGroupConnectedSite = this.isGroupConnectedSite();
301
302
  const sharedProperties = ['classification', 'disableFlows', 'socialBarOnSitePagesDisabled', 'shareByEmailEnabled', 'sharingCapability', 'noScriptSite'];
302
303
  const siteProperties = ['title', 'resourceQuota', 'resourceQuotaWarningLevel', 'storageQuota', 'storageQuotaWarningLevel', 'allowSelfServiceUpgrade'];
303
304
  let properties = sharedProperties;
304
- properties = properties;
305
305
  if (!isGroupConnectedSite) {
306
306
  properties = properties.concat(siteProperties);
307
307
  }
@@ -315,55 +315,65 @@ class SpoSiteSetCommand extends SpoCommand {
315
315
  if (!updatedProperties) {
316
316
  return Promise.resolve(undefined);
317
317
  }
318
- return spo
319
- .ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug)
320
- .then(async (res) => {
321
- this.context = res;
322
- if (this.verbose) {
323
- await logger.logToStderr(`Updating site ${args.options.url} properties...`);
324
- }
325
- let propertyId = 27;
326
- const payload = [];
327
- if (!isGroupConnectedSite) {
328
- if (args.options.title) {
329
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Title"><Parameter Type="String">${formatting.escapeXml(args.options.title)}</Parameter></SetProperty>`);
330
- }
331
- if (args.options.resourceQuota) {
332
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="UserCodeMaximumLevel"><Parameter Type="Double">${args.options.resourceQuota}</Parameter></SetProperty>`);
333
- }
334
- if (args.options.resourceQuotaWarningLevel) {
335
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="UserCodeWarningLevel"><Parameter Type="Double">${args.options.resourceQuotaWarningLevel}</Parameter></SetProperty>`);
336
- }
337
- if (args.options.storageQuota) {
338
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="StorageMaximumLevel"><Parameter Type="Int64">${args.options.storageQuota}</Parameter></SetProperty>`);
339
- }
340
- if (args.options.storageQuotaWarningLevel) {
341
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="StorageWarningLevel"><Parameter Type="Int64">${args.options.storageQuotaWarningLevel}</Parameter></SetProperty>`);
342
- }
343
- if (typeof args.options.allowSelfServiceUpgrade !== 'undefined') {
344
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="AllowSelfServiceUpgrade"><Parameter Type="Boolean">${args.options.allowSelfServiceUpgrade}</Parameter></SetProperty>`);
345
- }
346
- }
347
- if (typeof args.options.classification === 'string') {
348
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Classification"><Parameter Type="String">${formatting.escapeXml(args.options.classification)}</Parameter></SetProperty>`);
318
+ const res = await spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
319
+ this.context = res;
320
+ if (this.verbose) {
321
+ await logger.logToStderr(`Updating site ${args.options.url} properties...`);
322
+ }
323
+ let propertyId = 27;
324
+ const payload = [];
325
+ const sitePropertiesPayload = [];
326
+ if (!isGroupConnectedSite) {
327
+ if (args.options.title) {
328
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Title"><Parameter Type="String">${formatting.escapeXml(args.options.title)}</Parameter></SetProperty>`);
349
329
  }
350
- if (typeof args.options.disableFlows !== 'undefined') {
351
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="DisableFlows"><Parameter Type="Boolean">${args.options.disableFlows}</Parameter></SetProperty>`);
330
+ if (args.options.resourceQuota) {
331
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="UserCodeMaximumLevel"><Parameter Type="Double">${args.options.resourceQuota}</Parameter></SetProperty>`);
352
332
  }
353
- if (typeof args.options.socialBarOnSitePagesDisabled !== 'undefined') {
354
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="SocialBarOnSitePagesDisabled"><Parameter Type="Boolean">${args.options.socialBarOnSitePagesDisabled}</Parameter></SetProperty>`);
333
+ if (args.options.resourceQuotaWarningLevel) {
334
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="UserCodeWarningLevel"><Parameter Type="Double">${args.options.resourceQuotaWarningLevel}</Parameter></SetProperty>`);
355
335
  }
356
- if (typeof args.options.shareByEmailEnabled !== 'undefined') {
357
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="ShareByEmailEnabled"><Parameter Type="Boolean">${args.options.shareByEmailEnabled}</Parameter></SetProperty>`);
336
+ if (args.options.storageQuota) {
337
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="StorageMaximumLevel"><Parameter Type="Int64">${args.options.storageQuota}</Parameter></SetProperty>`);
358
338
  }
359
- if (args.options.sharingCapability) {
360
- const sharingCapability = SharingCapabilities[args.options.sharingCapability];
361
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="SharingCapability"><Parameter Type="Enum">${sharingCapability}</Parameter></SetProperty>`);
339
+ if (args.options.storageQuotaWarningLevel) {
340
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="StorageWarningLevel"><Parameter Type="Int64">${args.options.storageQuotaWarningLevel}</Parameter></SetProperty>`);
362
341
  }
363
- if (typeof args.options.noScriptSite !== 'undefined') {
364
- const noScriptSite = args.options.noScriptSite ? 2 : 1;
365
- payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="DenyAddAndCustomizePages"><Parameter Type="Enum">${noScriptSite}</Parameter></SetProperty>`);
342
+ if (args.options.allowSelfServiceUpgrade !== undefined) {
343
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="AllowSelfServiceUpgrade"><Parameter Type="Boolean">${args.options.allowSelfServiceUpgrade}</Parameter></SetProperty>`);
366
344
  }
345
+ }
346
+ if (typeof args.options.classification === 'string') {
347
+ sitePropertiesPayload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Classification"><Parameter Type="String">${formatting.escapeXml(args.options.classification)}</Parameter></SetProperty>`);
348
+ }
349
+ if (args.options.disableFlows !== undefined) {
350
+ const flowsPolicy = args.options.disableFlows ? FlowsPolicy.Disabled : FlowsPolicy.Enabled;
351
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="DisableFlows"><Parameter Type="Enum">${flowsPolicy}</Parameter></SetProperty>`);
352
+ }
353
+ if (args.options.shareByEmailEnabled !== undefined) {
354
+ sitePropertiesPayload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="ShareByEmailEnabled"><Parameter Type="Boolean">${args.options.shareByEmailEnabled}</Parameter></SetProperty>`);
355
+ }
356
+ if (args.options.sharingCapability) {
357
+ const sharingCapability = SharingCapabilities[args.options.sharingCapability];
358
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="SharingCapability"><Parameter Type="Enum">${sharingCapability}</Parameter></SetProperty>`);
359
+ }
360
+ if (args.options.noScriptSite !== undefined) {
361
+ const noScriptSite = args.options.noScriptSite ? 2 : 1;
362
+ payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="DenyAddAndCustomizePages"><Parameter Type="Enum">${noScriptSite}</Parameter></SetProperty>`);
363
+ }
364
+ let response;
365
+ let sitePropertiesResponse;
366
+ if (sitePropertiesPayload.length > 0) {
367
+ const requestOptions = {
368
+ url: `${args.options.url}/_vti_bin/client.svc/ProcessQuery`,
369
+ headers: {
370
+ 'X-RequestDigest': res.FormDigestValue
371
+ },
372
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions>${sitePropertiesPayload.join('')}</Actions><ObjectPaths><StaticProperty Id="1" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /><Property Id="5" ParentId="1" Name="Site" /></ObjectPaths></Request>`
373
+ };
374
+ sitePropertiesResponse = await request.post(requestOptions);
375
+ }
376
+ if (payload.length > 0) {
367
377
  const pos = this.tenantId.indexOf('|') + 1;
368
378
  const requestOptions = {
369
379
  url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
@@ -372,8 +382,9 @@ class SpoSiteSetCommand extends SpoCommand {
372
382
  },
373
383
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions>${payload.join('')}<ObjectPath Id="14" ObjectPathId="13" /><ObjectIdentityQuery Id="15" ObjectPathId="5" /><Query Id="16" ObjectPathId="13"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Identity Id="5" Name="53d8499e-d0d2-5000-cb83-9ade5be42ca4|${this.tenantId.substr(pos, this.tenantId.indexOf('&') - pos)}&#xA;SiteProperties&#xA;${formatting.encodeQueryParameter(args.options.url)}" /><Method Id="13" ParentId="5" Name="Update" /></ObjectPaths></Request>`
374
384
  };
375
- return request.post(requestOptions);
376
- });
385
+ response = await request.post(requestOptions);
386
+ }
387
+ return response || sitePropertiesResponse;
377
388
  }
378
389
  applySiteDesign(logger, args) {
379
390
  if (typeof args.options.siteDesignId === 'undefined') {