@pnp/cli-microsoft365 6.0.0-beta.a644c64 → 6.0.0-beta.b689fd4
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/dist/m365/aad/commands/o365group/o365group-recyclebinitem-restore.js +60 -9
- package/dist/m365/planner/commands/bucket/bucket-add.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-get.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-list.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-remove.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-set.js +4 -12
- package/dist/m365/planner/commands/plan/plan-get.js +0 -4
- package/dist/m365/planner/commands/task/task-add.js +4 -10
- package/dist/m365/planner/commands/task/task-get.js +4 -19
- package/dist/m365/planner/commands/task/task-list.js +4 -12
- package/dist/m365/planner/commands/task/task-set.js +4 -10
- package/dist/m365/planner/commands.js +0 -2
- package/dist/m365/spo/commands/customaction/customaction-get.js +32 -4
- package/dist/m365/spo/commands/customaction/customaction-remove.js +43 -8
- package/dist/m365/spo/commands/list/list-list.js +1 -10
- package/dist/m365/spo/commands/site/site-list.js +47 -16
- package/dist/m365/spo/commands/site/site-set.js +322 -162
- package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +9 -6
- package/dist/m365/spo/commands.js +0 -3
- package/dist/m365/teams/commands/team/team-clone.js +33 -7
- package/dist/m365/teams/commands/team/team-set.js +25 -5
- package/docs/docs/cmd/aad/o365group/o365group-recyclebinitem-restore.md +21 -3
- package/docs/docs/cmd/planner/bucket/bucket-add.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-get.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-list.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-remove.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-set.md +0 -3
- package/docs/docs/cmd/planner/plan/plan-get.md +0 -6
- package/docs/docs/cmd/planner/task/task-add.md +0 -3
- package/docs/docs/cmd/planner/task/task-get.md +0 -3
- package/docs/docs/cmd/planner/task/task-list.md +0 -3
- package/docs/docs/cmd/planner/task/task-set.md +0 -3
- package/docs/docs/cmd/spo/customaction/customaction-get.md +15 -2
- package/docs/docs/cmd/spo/customaction/customaction-remove.md +33 -2
- package/docs/docs/cmd/spo/list/list-list.md +0 -3
- package/docs/docs/cmd/spo/site/site-list.md +19 -7
- package/docs/docs/cmd/spo/site/site-set.md +50 -6
- package/docs/docs/cmd/teams/team/team-clone.md +11 -5
- package/docs/docs/cmd/teams/team/team-set.md +10 -4
- package/package.json +1 -1
- package/dist/m365/spo/commands/site/site-classic-add.js +0 -333
- package/dist/m365/spo/commands/site/site-classic-list.js +0 -98
- package/dist/m365/spo/commands/site/site-classic-set.js +0 -358
- package/docs/docs/cmd/spo/site/site-classic-add.md +0 -93
- package/docs/docs/cmd/spo/site/site-classic-list.md +0 -65
- package/docs/docs/cmd/spo/site/site-classic-set.md +0 -99
|
@@ -10,7 +10,6 @@ const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
|
10
10
|
const commands_1 = require("../../commands");
|
|
11
11
|
const SharingCapabilities_1 = require("../site/SharingCapabilities");
|
|
12
12
|
const spoSiteDesignApplyCommand = require("../sitedesign/sitedesign-apply");
|
|
13
|
-
const spoSiteClassicSetCommand = require("./site-classic-set");
|
|
14
13
|
class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
15
14
|
get name() {
|
|
16
15
|
return commands_1.default.SITE_SET;
|
|
@@ -30,29 +29,44 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
30
29
|
telemetryProps.siteDesignId = typeof args.options.siteDesignId !== undefined;
|
|
31
30
|
telemetryProps.sharingCapabilities = args.options.sharingCapability;
|
|
32
31
|
telemetryProps.siteLogoUrl = typeof args.options.siteLogoUrl !== 'undefined';
|
|
32
|
+
telemetryProps.resourceQuota = args.options.resourceQuota;
|
|
33
|
+
telemetryProps.resourceQuotaWarningLevel = args.options.resourceQuotaWarningLevel;
|
|
34
|
+
telemetryProps.storageQuota = args.options.storageQuota;
|
|
35
|
+
telemetryProps.storageQuotaWarningLevel = args.options.storageQuotaWarningLevel;
|
|
36
|
+
telemetryProps.allowSelfServiceUpgrade = args.options.allowSelfServiceUpgrade;
|
|
37
|
+
telemetryProps.lockState = args.options.lockState;
|
|
38
|
+
telemetryProps.noScriptSite = args.options.noScriptSite;
|
|
39
|
+
telemetryProps.wait = args.options.wait === true;
|
|
33
40
|
return telemetryProps;
|
|
34
41
|
}
|
|
35
42
|
commandAction(logger, args, cb) {
|
|
36
|
-
this
|
|
37
|
-
|
|
38
|
-
.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (this.debug) {
|
|
47
|
-
logger.logToStderr(`Site attached to group ${this.groupId}`);
|
|
48
|
-
}
|
|
49
|
-
return this.updateGroupifiedSite(logger, args);
|
|
50
|
-
}
|
|
43
|
+
this.dots = '';
|
|
44
|
+
utils_1.spo
|
|
45
|
+
.getTenantId(logger, this.debug)
|
|
46
|
+
.then((_tenantId) => {
|
|
47
|
+
this.tenantId = _tenantId;
|
|
48
|
+
return utils_1.spo.getSpoAdminUrl(logger, this.debug);
|
|
49
|
+
})
|
|
50
|
+
.then(spoAdminUrl => {
|
|
51
|
+
this.spoAdminUrl = spoAdminUrl;
|
|
52
|
+
return utils_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
51
53
|
})
|
|
52
|
-
.then(
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
.then(formDigestInfo => {
|
|
55
|
+
this.context = formDigestInfo;
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
})
|
|
58
|
+
.then(_ => this.loadSiteIds(args.options.url, logger))
|
|
59
|
+
.then(_ => {
|
|
60
|
+
return this.isGroupConnectedSite()
|
|
61
|
+
? this.updateGroupConnectedSite(logger, args)
|
|
62
|
+
: this.updateSharePointOnlySite(logger, args);
|
|
63
|
+
})
|
|
64
|
+
.then(_ => this.updateSiteProperties(logger, args))
|
|
65
|
+
.then(res => this.waitForSiteUpdateCompletion(logger, args, res))
|
|
66
|
+
.then(_ => this.applySiteDesign(logger, args))
|
|
67
|
+
.then(_ => this.setLogo(logger, args))
|
|
68
|
+
.then(_ => this.updateSiteLockState(logger, args))
|
|
69
|
+
.then(res => this.waitForSiteUpdateCompletion(logger, args, res))
|
|
56
70
|
.then(_ => cb(), (err) => {
|
|
57
71
|
if (err instanceof Command_1.CommandError) {
|
|
58
72
|
err = err.message;
|
|
@@ -80,27 +94,135 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
80
94
|
};
|
|
81
95
|
return request_1.default.post(requestOptions);
|
|
82
96
|
}
|
|
83
|
-
|
|
97
|
+
updateSharePointOnlySite(logger, args) {
|
|
98
|
+
if (this.debug) {
|
|
99
|
+
logger.logToStderr('Site is not group connected');
|
|
100
|
+
}
|
|
84
101
|
if (typeof args.options.isPublic !== 'undefined') {
|
|
85
102
|
return Promise.reject(`The isPublic option can't be set on a site that is not groupified`);
|
|
86
103
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
104
|
+
return this.updateSiteDescription(logger, args)
|
|
105
|
+
.then(_ => this.updateSiteOwners(logger, args));
|
|
106
|
+
}
|
|
107
|
+
waitForSiteUpdateCompletion(logger, args, res) {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
if (!res) {
|
|
110
|
+
resolve();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const json = JSON.parse(res);
|
|
114
|
+
const response = json[0];
|
|
115
|
+
if (response.ErrorInfo) {
|
|
116
|
+
reject(response.ErrorInfo.ErrorMessage);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const operation = json[json.length - 1];
|
|
120
|
+
const isComplete = operation.IsComplete;
|
|
121
|
+
if (!args.options.wait || isComplete) {
|
|
122
|
+
resolve();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
utils_1.spo.waitUntilFinished({
|
|
127
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
128
|
+
siteUrl: this.spoAdminUrl,
|
|
129
|
+
resolve,
|
|
130
|
+
reject,
|
|
131
|
+
logger,
|
|
132
|
+
currentContext: this.context,
|
|
133
|
+
dots: this.dots,
|
|
134
|
+
debug: this.debug,
|
|
135
|
+
verbose: this.verbose
|
|
136
|
+
});
|
|
137
|
+
}, operation.PollingInterval);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
updateSiteOwners(logger, args) {
|
|
142
|
+
if (!args.options.owners) {
|
|
90
143
|
return Promise.resolve();
|
|
91
144
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
if (this.verbose) {
|
|
147
|
+
logger.logToStderr(`Updating site owners ${args.options.url}...`);
|
|
148
|
+
}
|
|
149
|
+
Promise.all(args.options.owners.split(',').map(o => {
|
|
150
|
+
return this.setAdmin(args.options.url, o.trim());
|
|
151
|
+
}))
|
|
152
|
+
.then(() => {
|
|
153
|
+
resolve();
|
|
154
|
+
}, (err) => {
|
|
155
|
+
reject(err);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
setAdmin(siteUrl, principal) {
|
|
160
|
+
return new Promise((resolve, reject) => {
|
|
161
|
+
const requestOptions = {
|
|
162
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
163
|
+
headers: {
|
|
164
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
165
|
+
},
|
|
166
|
+
data: `<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="48" ObjectPathId="47" /></Actions><ObjectPaths><Method Id="47" ParentId="34" Name="SetSiteAdmin"><Parameters><Parameter Type="String">${utils_1.formatting.escapeXml(siteUrl)}</Parameter><Parameter Type="String">${utils_1.formatting.escapeXml(principal)}</Parameter><Parameter Type="Boolean">true</Parameter></Parameters></Method><Constructor Id="34" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
167
|
+
};
|
|
168
|
+
return request_1.default.post(requestOptions)
|
|
169
|
+
.then((res) => {
|
|
170
|
+
const json = JSON.parse(res);
|
|
171
|
+
const response = json[0];
|
|
172
|
+
if (response.ErrorInfo) {
|
|
173
|
+
reject(response.ErrorInfo.ErrorMessage);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
resolve();
|
|
177
|
+
}
|
|
178
|
+
}, (err) => {
|
|
179
|
+
reject(err);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
updateSiteDescription(logger, args) {
|
|
184
|
+
if (!args.options.description) {
|
|
185
|
+
return Promise.resolve(undefined);
|
|
186
|
+
}
|
|
187
|
+
if (this.verbose) {
|
|
188
|
+
logger.logToStderr(`Setting site description ${args.options.url}...`);
|
|
189
|
+
}
|
|
190
|
+
const requestOptions = {
|
|
191
|
+
url: `${args.options.url}/_api/web`,
|
|
192
|
+
headers: {
|
|
193
|
+
'IF-MATCH': '*',
|
|
194
|
+
'Accept': 'application/json;odata=nometadata',
|
|
195
|
+
'content-type': 'application/json;odata=nometadata',
|
|
196
|
+
'X-RequestDigest': this.context.FormDigestValue,
|
|
197
|
+
'X-HTTP-Method': 'MERGE'
|
|
198
|
+
},
|
|
199
|
+
data: {
|
|
200
|
+
Description: args.options.description
|
|
201
|
+
},
|
|
202
|
+
json: true
|
|
203
|
+
};
|
|
204
|
+
return request_1.default.post(requestOptions);
|
|
205
|
+
}
|
|
206
|
+
updateSiteLockState(logger, args) {
|
|
207
|
+
if (!args.options.lockState) {
|
|
208
|
+
return Promise.resolve(undefined);
|
|
209
|
+
}
|
|
210
|
+
if (this.verbose) {
|
|
211
|
+
logger.logToStderr(`Setting site lock state ${args.options.url}...`);
|
|
212
|
+
}
|
|
213
|
+
const requestOptions = {
|
|
214
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
215
|
+
headers: {
|
|
216
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
217
|
+
},
|
|
218
|
+
data: `<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><SetProperty Id="7" ObjectPathId="5" Name="LockState"><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.lockState)}</Parameter></SetProperty><ObjectPath Id="9" ObjectPathId="8" /><ObjectIdentityQuery Id="10" ObjectPathId="5" /><Query Id="11" ObjectPathId="8"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="5" ParentId="3" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.url)}</Parameter><Parameter Type="Boolean">false</Parameter></Parameters></Method><Method Id="8" ParentId="5" Name="Update" /><Constructor Id="3" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
100
219
|
};
|
|
101
|
-
return
|
|
220
|
+
return request_1.default.post(requestOptions);
|
|
102
221
|
}
|
|
103
|
-
|
|
222
|
+
updateGroupConnectedSite(logger, args) {
|
|
223
|
+
if (this.debug) {
|
|
224
|
+
logger.logToStderr(`Site attached to group ${this.groupId}`);
|
|
225
|
+
}
|
|
104
226
|
return new Promise((resolve, reject) => {
|
|
105
227
|
if (typeof args.options.title === 'undefined' &&
|
|
106
228
|
typeof args.options.description === 'undefined' &&
|
|
@@ -108,32 +230,23 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
108
230
|
typeof args.options.owners === 'undefined') {
|
|
109
231
|
return resolve();
|
|
110
232
|
}
|
|
111
|
-
let spoAdminUrl;
|
|
112
233
|
const promises = [];
|
|
113
234
|
if (typeof args.options.title !== 'undefined') {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
groupId: this.groupId,
|
|
130
|
-
siteId: this.siteId,
|
|
131
|
-
displayName: args.options.title
|
|
132
|
-
},
|
|
133
|
-
responseType: 'json'
|
|
134
|
-
};
|
|
135
|
-
return request_1.default.post(requestOptions);
|
|
136
|
-
}));
|
|
235
|
+
const requestOptions = {
|
|
236
|
+
url: `${this.spoAdminUrl}/_api/SPOGroup/UpdateGroupPropertiesBySiteId`,
|
|
237
|
+
headers: {
|
|
238
|
+
accept: 'application/json;odata=nometadata',
|
|
239
|
+
'content-type': 'application/json;charset=utf-8',
|
|
240
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
241
|
+
},
|
|
242
|
+
data: {
|
|
243
|
+
groupId: this.groupId,
|
|
244
|
+
siteId: this.siteId,
|
|
245
|
+
displayName: args.options.title
|
|
246
|
+
},
|
|
247
|
+
responseType: 'json'
|
|
248
|
+
};
|
|
249
|
+
promises.push(request_1.default.post(requestOptions));
|
|
137
250
|
}
|
|
138
251
|
if (typeof args.options.isPublic !== 'undefined') {
|
|
139
252
|
const commandOptions = {
|
|
@@ -177,27 +290,21 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
177
290
|
if (this.verbose) {
|
|
178
291
|
logger.logToStderr('Retrieving user information to set group owners...');
|
|
179
292
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
'content-type': 'application/json;odata.metadata=none'
|
|
189
|
-
},
|
|
190
|
-
responseType: 'json'
|
|
191
|
-
};
|
|
192
|
-
return request_1.default.get(requestOptions);
|
|
193
|
-
})
|
|
293
|
+
const requestOptions = {
|
|
294
|
+
url: `https://graph.microsoft.com/v1.0/users?$filter=${owners.map(o => `userPrincipalName eq '${o}'`).join(' or ')}&$select=id`,
|
|
295
|
+
headers: {
|
|
296
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
297
|
+
},
|
|
298
|
+
responseType: 'json'
|
|
299
|
+
};
|
|
300
|
+
return request_1.default.get(requestOptions)
|
|
194
301
|
.then((res) => {
|
|
195
302
|
if (res.value.length === 0) {
|
|
196
303
|
return Promise.resolve();
|
|
197
304
|
}
|
|
198
305
|
return Promise.all(res.value.map(user => {
|
|
199
306
|
const requestOptions = {
|
|
200
|
-
url: `${spoAdminUrl}/_api/SP.Directory.DirectorySession/Group('${this.groupId}')/Owners/Add(objectId='${user.id}', principalName='')`,
|
|
307
|
+
url: `${this.spoAdminUrl}/_api/SP.Directory.DirectorySession/Group('${this.groupId}')/Owners/Add(objectId='${user.id}', principalName='')`,
|
|
201
308
|
headers: {
|
|
202
309
|
'content-type': 'application/json;odata=verbose'
|
|
203
310
|
}
|
|
@@ -206,55 +313,80 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
206
313
|
}));
|
|
207
314
|
});
|
|
208
315
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
316
|
+
updateSiteProperties(logger, args) {
|
|
317
|
+
const isGroupConnectedSite = this.isGroupConnectedSite();
|
|
318
|
+
const sharedProperties = ['classification', 'disableFlows', 'shareByEmailEnabled', 'sharingCapability', 'noScriptSite'];
|
|
319
|
+
const siteProperties = ['title', 'resourceQuota', 'resourceQuotaWarningLevel', 'storageQuota', 'storageQuotaWarningLevel', 'allowSelfServiceUpgrade'];
|
|
320
|
+
let properties = sharedProperties;
|
|
321
|
+
properties = properties;
|
|
322
|
+
if (!isGroupConnectedSite) {
|
|
323
|
+
properties = properties.concat(siteProperties);
|
|
214
324
|
}
|
|
215
|
-
|
|
325
|
+
let updatedProperties = false;
|
|
326
|
+
for (let i = 0; i < properties.length; i++) {
|
|
327
|
+
if (typeof args.options[properties[i]] !== 'undefined') {
|
|
328
|
+
updatedProperties = true;
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (!updatedProperties) {
|
|
333
|
+
return Promise.resolve(undefined);
|
|
334
|
+
}
|
|
335
|
+
return utils_1.spo
|
|
336
|
+
.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug)
|
|
337
|
+
.then(res => {
|
|
338
|
+
this.context = res;
|
|
216
339
|
if (this.verbose) {
|
|
217
|
-
logger.logToStderr(`
|
|
340
|
+
logger.logToStderr(`Updating site ${args.options.url} properties...`);
|
|
218
341
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (
|
|
223
|
-
|
|
342
|
+
let propertyId = 27;
|
|
343
|
+
const payload = [];
|
|
344
|
+
if (!isGroupConnectedSite) {
|
|
345
|
+
if (args.options.title) {
|
|
346
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Title"><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.title)}</Parameter></SetProperty>`);
|
|
224
347
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
if (typeof args.options.classification === 'string') {
|
|
228
|
-
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Classification"><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.classification)}</Parameter></SetProperty>`);
|
|
348
|
+
if (args.options.resourceQuota) {
|
|
349
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="UserCodeMaximumLevel"><Parameter Type="Double">${args.options.resourceQuota}</Parameter></SetProperty>`);
|
|
229
350
|
}
|
|
230
|
-
if (
|
|
231
|
-
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="
|
|
351
|
+
if (args.options.resourceQuotaWarningLevel) {
|
|
352
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="UserCodeWarningLevel"><Parameter Type="Double">${args.options.resourceQuotaWarningLevel}</Parameter></SetProperty>`);
|
|
232
353
|
}
|
|
233
|
-
if (
|
|
234
|
-
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="
|
|
354
|
+
if (args.options.storageQuota) {
|
|
355
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="StorageMaximumLevel"><Parameter Type="Int64">${args.options.storageQuota}</Parameter></SetProperty>`);
|
|
235
356
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
url: `${args.options.url}/_vti_bin/client.svc/ProcessQuery`,
|
|
239
|
-
headers: {
|
|
240
|
-
'X-RequestDigest': res.FormDigestValue
|
|
241
|
-
},
|
|
242
|
-
data: `<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>${payload.join('')}</Actions><ObjectPaths><Identity Id="5" Name="e10a459e-60c8-4000-8240-a68d6a12d39e|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${this.siteId}" /></ObjectPaths></Request>`
|
|
243
|
-
};
|
|
244
|
-
return request_1.default.post(requestOptions);
|
|
245
|
-
})
|
|
246
|
-
.then((res) => {
|
|
247
|
-
const json = JSON.parse(res);
|
|
248
|
-
const response = json[0];
|
|
249
|
-
if (response.ErrorInfo) {
|
|
250
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
357
|
+
if (args.options.storageQuotaWarningLevel) {
|
|
358
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="StorageWarningLevel"><Parameter Type="Int64">${args.options.storageQuotaWarningLevel}</Parameter></SetProperty>`);
|
|
251
359
|
}
|
|
252
|
-
|
|
253
|
-
|
|
360
|
+
if (typeof args.options.allowSelfServiceUpgrade !== 'undefined') {
|
|
361
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="AllowSelfServiceUpgrade"><Parameter Type="Boolean">${args.options.allowSelfServiceUpgrade}</Parameter></SetProperty>`);
|
|
254
362
|
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
|
|
363
|
+
}
|
|
364
|
+
if (typeof args.options.classification === 'string') {
|
|
365
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="Classification"><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.classification)}</Parameter></SetProperty>`);
|
|
366
|
+
}
|
|
367
|
+
if (typeof args.options.disableFlows === 'string') {
|
|
368
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="DisableFlows"><Parameter Type="Boolean">${args.options.disableFlows === 'true'}</Parameter></SetProperty>`);
|
|
369
|
+
}
|
|
370
|
+
if (typeof args.options.shareByEmailEnabled === 'string') {
|
|
371
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="ShareByEmailEnabled"><Parameter Type="Boolean">${args.options.shareByEmailEnabled === 'true'}</Parameter></SetProperty>`);
|
|
372
|
+
}
|
|
373
|
+
if (args.options.sharingCapability) {
|
|
374
|
+
const sharingCapability = SharingCapabilities_1.SharingCapabilities[args.options.sharingCapability];
|
|
375
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="SharingCapability"><Parameter Type="Enum">${sharingCapability}</Parameter></SetProperty>`);
|
|
376
|
+
}
|
|
377
|
+
if (typeof args.options.noScriptSite !== 'undefined') {
|
|
378
|
+
const noScriptSite = args.options.noScriptSite === 'true' ? 2 : 1;
|
|
379
|
+
payload.push(`<SetProperty Id="${propertyId++}" ObjectPathId="5" Name="DenyAddAndCustomizePages"><Parameter Type="Enum">${noScriptSite}</Parameter></SetProperty>`);
|
|
380
|
+
}
|
|
381
|
+
const pos = this.tenantId.indexOf('|') + 1;
|
|
382
|
+
const requestOptions = {
|
|
383
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
384
|
+
headers: {
|
|
385
|
+
'X-RequestDigest': res.FormDigestValue
|
|
386
|
+
},
|
|
387
|
+
data: `<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>${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)}
SiteProperties
${encodeURIComponent(args.options.url)}" /><Method Id="13" ParentId="5" Name="Update" /></ObjectPaths></Request>`
|
|
388
|
+
};
|
|
389
|
+
return request_1.default.post(requestOptions);
|
|
258
390
|
});
|
|
259
391
|
}
|
|
260
392
|
applySiteDesign(logger, args) {
|
|
@@ -270,48 +402,6 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
270
402
|
};
|
|
271
403
|
return cli_1.Cli.executeCommand(spoSiteDesignApplyCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
272
404
|
}
|
|
273
|
-
setSharingCapabilities(logger, args) {
|
|
274
|
-
if (typeof args.options.sharingCapability === 'undefined') {
|
|
275
|
-
return Promise.resolve();
|
|
276
|
-
}
|
|
277
|
-
return new Promise((resolve, reject) => {
|
|
278
|
-
if (this.verbose) {
|
|
279
|
-
logger.logToStderr(`Retrieving request digest...`);
|
|
280
|
-
}
|
|
281
|
-
const sharingCapability = SharingCapabilities_1.SharingCapabilities[args.options.sharingCapability];
|
|
282
|
-
utils_1.spo
|
|
283
|
-
.getSpoAdminUrl(logger, this.debug)
|
|
284
|
-
.then((_spoAdminUrl) => {
|
|
285
|
-
this.spoAdminUrl = _spoAdminUrl;
|
|
286
|
-
return utils_1.spo.getRequestDigest(this.spoAdminUrl);
|
|
287
|
-
})
|
|
288
|
-
.then((res) => {
|
|
289
|
-
if (this.verbose) {
|
|
290
|
-
logger.logToStderr(`Setting sharing for site ${args.options.url} as ${args.options.sharingCapability}`);
|
|
291
|
-
}
|
|
292
|
-
const requestOptions = {
|
|
293
|
-
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
294
|
-
headers: {
|
|
295
|
-
'X-RequestDigest': res.FormDigestValue
|
|
296
|
-
},
|
|
297
|
-
data: `<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"/><SetProperty Id="5" ObjectPathId="3" Name="SharingCapability"><Parameter Type="Enum">${sharingCapability}</Parameter></SetProperty><ObjectPath Id="7" ObjectPathId="6"/><ObjectIdentityQuery Id="8" ObjectPathId="3"/></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}"/><Method Id="3" ParentId="1" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.url)}</Parameter><Parameter Type="Boolean">false</Parameter></Parameters></Method><Method Id="6" ParentId="3" Name="Update"/></ObjectPaths></Request>`
|
|
298
|
-
};
|
|
299
|
-
return request_1.default.post(requestOptions);
|
|
300
|
-
})
|
|
301
|
-
.then((res) => {
|
|
302
|
-
const json = JSON.parse(res);
|
|
303
|
-
const response = json[0];
|
|
304
|
-
if (response.ErrorInfo) {
|
|
305
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
306
|
-
}
|
|
307
|
-
else {
|
|
308
|
-
resolve();
|
|
309
|
-
}
|
|
310
|
-
}, (err) => {
|
|
311
|
-
reject(err);
|
|
312
|
-
});
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
405
|
loadSiteIds(siteUrl, logger) {
|
|
316
406
|
if (this.debug) {
|
|
317
407
|
logger.logToStderr('Loading site IDs...');
|
|
@@ -334,6 +424,9 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
334
424
|
return Promise.resolve();
|
|
335
425
|
});
|
|
336
426
|
}
|
|
427
|
+
isGroupConnectedSite() {
|
|
428
|
+
return this.groupId !== '00000000-0000-0000-0000-000000000000';
|
|
429
|
+
}
|
|
337
430
|
/**
|
|
338
431
|
* Maps the base sharingCapability enum to string array so it can
|
|
339
432
|
* more easily be used in validation or descriptions.
|
|
@@ -385,6 +478,31 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
385
478
|
{
|
|
386
479
|
option: '--sharingCapability [sharingCapability]',
|
|
387
480
|
autocomplete: this.sharingCapabilities
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
option: '--resourceQuota [resourceQuota]'
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
option: '--resourceQuotaWarningLevel [resourceQuotaWarningLevel]'
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
option: '--storageQuota [storageQuota]'
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
option: '--storageQuotaWarningLevel [storageQuotaWarningLevel]'
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
option: '--allowSelfServiceUpgrade [allowSelfServiceUpgrade]'
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
option: '--lockState [lockState]',
|
|
499
|
+
autocomplete: ['Unlock', 'NoAdditions', 'ReadOnly', 'NoAccess']
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
option: '--noScriptSite [noScriptSite]'
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
option: '--wait'
|
|
388
506
|
}
|
|
389
507
|
];
|
|
390
508
|
const parentOptions = super.options();
|
|
@@ -404,25 +522,29 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
404
522
|
typeof args.options.shareByEmailEnabled === 'undefined' &&
|
|
405
523
|
typeof args.options.siteDesignId === 'undefined' &&
|
|
406
524
|
typeof args.options.sharingCapability === 'undefined' &&
|
|
407
|
-
typeof args.options.siteLogoUrl === 'undefined'
|
|
525
|
+
typeof args.options.siteLogoUrl === 'undefined' &&
|
|
526
|
+
typeof args.options.resourceQuota === 'undefined' &&
|
|
527
|
+
typeof args.options.resourceQuotaWarningLevel === 'undefined' &&
|
|
528
|
+
typeof args.options.storageQuota === 'undefined' &&
|
|
529
|
+
typeof args.options.storageQuotaWarningLevel === 'undefined' &&
|
|
530
|
+
typeof args.options.noScriptSite === 'undefined' &&
|
|
531
|
+
typeof args.options.allowSelfServiceUpgrade === 'undefined' &&
|
|
532
|
+
typeof args.options.lockState === 'undefined') {
|
|
408
533
|
return 'Specify at least one property to update';
|
|
409
534
|
}
|
|
410
535
|
if (typeof args.options.siteLogoUrl !== 'undefined' && typeof args.options.siteLogoUrl !== 'string') {
|
|
411
536
|
return `${args.options.siteLogoUrl} is not a valid value for the siteLogoUrl option. Specify the logo URL or an empty string "" to unset the logo.`;
|
|
412
537
|
}
|
|
413
538
|
if (typeof args.options.disableFlows === 'string' &&
|
|
414
|
-
args.options.disableFlows
|
|
415
|
-
args.options.disableFlows !== 'false') {
|
|
539
|
+
!utils_1.validation.isValidBoolean(args.options.disableFlows)) {
|
|
416
540
|
return `${args.options.disableFlows} is not a valid value for the disableFlow option. Allowed values are true|false`;
|
|
417
541
|
}
|
|
418
542
|
if (typeof args.options.isPublic === 'string' &&
|
|
419
|
-
args.options.isPublic
|
|
420
|
-
args.options.isPublic !== 'false') {
|
|
543
|
+
!utils_1.validation.isValidBoolean(args.options.isPublic)) {
|
|
421
544
|
return `${args.options.isPublic} is not a valid value for the isPublic option. Allowed values are true|false`;
|
|
422
545
|
}
|
|
423
546
|
if (typeof args.options.shareByEmailEnabled === 'string' &&
|
|
424
|
-
args.options.shareByEmailEnabled
|
|
425
|
-
args.options.shareByEmailEnabled !== 'false') {
|
|
547
|
+
!utils_1.validation.isValidBoolean(args.options.shareByEmailEnabled)) {
|
|
426
548
|
return `${args.options.shareByEmailEnabled} is not a valid value for the shareByEmailEnabled option. Allowed values are true|false`;
|
|
427
549
|
}
|
|
428
550
|
if (args.options.siteDesignId) {
|
|
@@ -434,6 +556,44 @@ class SpoSiteSetCommand extends SpoCommand_1.default {
|
|
|
434
556
|
this.sharingCapabilities.indexOf(args.options.sharingCapability) < 0) {
|
|
435
557
|
return `${args.options.sharingCapability} is not a valid value for the sharingCapability option. Allowed values are ${this.sharingCapabilities.join('|')}`;
|
|
436
558
|
}
|
|
559
|
+
if (args.options.resourceQuota &&
|
|
560
|
+
typeof args.options.resourceQuota !== 'number') {
|
|
561
|
+
return `${args.options.resourceQuota} is not a number`;
|
|
562
|
+
}
|
|
563
|
+
if (args.options.resourceQuotaWarningLevel &&
|
|
564
|
+
typeof args.options.resourceQuotaWarningLevel !== 'number') {
|
|
565
|
+
return `${args.options.resourceQuotaWarningLevel} is not a number`;
|
|
566
|
+
}
|
|
567
|
+
if (args.options.resourceQuota &&
|
|
568
|
+
args.options.resourceQuotaWarningLevel &&
|
|
569
|
+
args.options.resourceQuotaWarningLevel > args.options.resourceQuota) {
|
|
570
|
+
return `resourceQuotaWarningLevel must not exceed the resourceQuota`;
|
|
571
|
+
}
|
|
572
|
+
if (args.options.storageQuota &&
|
|
573
|
+
typeof args.options.storageQuota !== 'number') {
|
|
574
|
+
return `${args.options.storageQuota} is not a number`;
|
|
575
|
+
}
|
|
576
|
+
if (args.options.storageQuotaWarningLevel &&
|
|
577
|
+
typeof args.options.storageQuotaWarningLevel !== 'number') {
|
|
578
|
+
return `${args.options.storageQuotaWarningLevel} is not a number`;
|
|
579
|
+
}
|
|
580
|
+
if (args.options.storageQuota &&
|
|
581
|
+
args.options.storageQuotaWarningLevel &&
|
|
582
|
+
args.options.storageQuotaWarningLevel > args.options.storageQuota) {
|
|
583
|
+
return `storageQuotaWarningLevel must not exceed the storageQuota`;
|
|
584
|
+
}
|
|
585
|
+
if (args.options.allowSelfServiceUpgrade &&
|
|
586
|
+
!utils_1.validation.isValidBoolean(args.options.allowSelfServiceUpgrade)) {
|
|
587
|
+
return `${args.options.allowSelfServiceUpgrade} is not a valid boolean value`;
|
|
588
|
+
}
|
|
589
|
+
if (args.options.lockState &&
|
|
590
|
+
['Unlock', 'NoAdditions', 'ReadOnly', 'NoAccess'].indexOf(args.options.lockState) === -1) {
|
|
591
|
+
return `${args.options.lockState} is not a valid value for the lockState option. Allowed values Unlock|NoAdditions|ReadOnly|NoAccess`;
|
|
592
|
+
}
|
|
593
|
+
if (args.options.noScriptSite &&
|
|
594
|
+
!utils_1.validation.isValidBoolean(args.options.noScriptSite)) {
|
|
595
|
+
return `${args.options.noScriptSite} is not a valid boolean value`;
|
|
596
|
+
}
|
|
437
597
|
return true;
|
|
438
598
|
}
|
|
439
599
|
types() {
|