@pnp/cli-microsoft365 6.11.0-beta.ee225fb → 6.11.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.
- package/dist/Auth.js +2 -1
- package/dist/Command.js +1 -1
- package/dist/m365/pa/commands/app/app-permission-ensure.js +177 -0
- package/dist/m365/pa/commands/app/app-permission-remove.js +170 -0
- package/dist/m365/pa/commands.js +2 -0
- package/dist/m365/planner/commands/task/task-add.js +17 -11
- package/dist/m365/planner/commands/task/task-get.js +35 -25
- package/dist/m365/planner/commands/task/task-list.js +26 -19
- package/dist/m365/planner/commands/task/task-remove.js +40 -35
- package/dist/m365/planner/commands/task/task-set.js +35 -23
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +58 -0
- package/dist/m365/spfx/commands/project/project-doctor/{doctor-1.18.0-beta.1.js → doctor-1.18.0-beta.5.js} +1 -1
- package/dist/m365/spfx/commands/project/project-doctor.js +1 -1
- package/dist/m365/spfx/commands/project/project-externalize/rules/PnPJsRule.js +34 -23
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +171 -0
- package/dist/m365/spfx/commands/project/project-github-workflow-model.js +3 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.15.2.js +1 -1
- package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.18.0-beta.1.js → upgrade-1.18.0-beta.5.js} +26 -26
- package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
- package/dist/m365/spfx/commands/spfx-doctor.js +35 -51
- package/dist/m365/spfx/commands.js +1 -0
- package/dist/m365/spo/commands/app/SpoAppBaseCommand.js +26 -14
- package/dist/m365/spo/commands/app/app-add.js +9 -9
- package/dist/m365/spo/commands/file/file-add.js +13 -13
- package/dist/m365/spo/commands/file/file-checkin.js +1 -1
- package/dist/m365/spo/commands/file/file-checkout.js +1 -1
- package/dist/m365/spo/commands/file/file-copy.js +38 -4
- package/dist/m365/spo/commands/file/file-list.js +4 -4
- package/dist/m365/spo/commands/file/file-move.js +2 -2
- package/dist/m365/spo/commands/file/file-remove.js +6 -6
- package/dist/m365/spo/commands/file/file-rename.js +2 -2
- package/dist/m365/spo/commands/file/file-retentionlabel-ensure.js +1 -1
- package/dist/m365/spo/commands/file/file-retentionlabel-remove.js +1 -1
- package/dist/m365/spo/commands/file/file-roleassignment-add.js +1 -1
- package/dist/m365/spo/commands/file/file-roleassignment-remove.js +1 -1
- package/dist/m365/spo/commands/file/file-roleinheritance-break.js +1 -1
- package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
- package/dist/m365/spo/commands/file/file-version-clear.js +1 -1
- package/dist/m365/spo/commands/file/file-version-get.js +1 -1
- package/dist/m365/spo/commands/file/file-version-list.js +1 -1
- package/dist/m365/spo/commands/file/file-version-remove.js +1 -1
- package/dist/m365/spo/commands/file/file-version-restore.js +1 -1
- package/dist/m365/spo/commands/folder/folder-add.js +2 -4
- package/dist/m365/spo/commands/folder/folder-get.js +1 -1
- package/dist/m365/spo/commands/folder/folder-list.js +2 -2
- package/dist/m365/spo/commands/folder/folder-remove.js +7 -4
- package/dist/m365/spo/commands/folder/folder-rename.js +13 -17
- package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +1 -1
- package/dist/m365/spo/commands/folder/folder-retentionlabel-remove.js +1 -1
- package/dist/m365/spo/commands/folder/folder-roleassignment-add.js +1 -1
- package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +1 -1
- package/dist/m365/spo/commands/folder/folder-roleinheritance-break.js +1 -1
- package/dist/m365/spo/commands/folder/folder-roleinheritance-reset.js +1 -1
- package/dist/m365/spo/commands/group/group-list.js +0 -1
- package/dist/m365/spo/commands/orgassetslibrary/orgassetslibrary-add.js +32 -3
- package/dist/m365/spo/commands/page/Page.js +24 -32
- package/dist/m365/spo/commands/propertybag/propertybag-base.js +75 -54
- package/dist/m365/spo/commands/propertybag/propertybag-remove.js +41 -40
- package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-set.js +32 -32
- package/dist/m365/spo/commands/site/FlowsPolicy.js +10 -0
- package/dist/m365/spo/commands/site/site-add.js +113 -154
- package/dist/m365/spo/commands/site/site-apppermission-add.js +26 -27
- package/dist/m365/spo/commands/site/site-apppermission-remove.js +37 -37
- package/dist/m365/spo/commands/site/site-apppermission-set.js +15 -16
- package/dist/m365/spo/commands/site/site-ensure.js +19 -70
- package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +24 -22
- package/dist/m365/spo/commands/site/site-list.js +28 -36
- package/dist/m365/spo/commands/site/site-remove.js +139 -171
- package/dist/m365/spo/commands/site/site-set.js +179 -178
- package/dist/m365/spo/commands/theme/theme-remove.js +26 -24
- package/dist/m365/spo/commands/theme/theme-set.js +0 -1
- package/dist/m365/spo/commands/user/user-remove.js +29 -27
- package/dist/m365/spo/commands/web/web-reindex.js +17 -20
- package/dist/m365/spo/commands/web/web-remove.js +23 -21
- package/dist/m365/spo/commands/web/web-roleassignment-add.js +45 -52
- package/dist/m365/spo/commands/web/web-roleassignment-remove.js +58 -61
- package/dist/m365/spo/commands/web/web-roleinheritance-break.js +20 -18
- package/dist/m365/spo/commands/web/web-roleinheritance-reset.js +21 -19
- package/dist/m365/yammer/commands/message/message-like-set.js +29 -28
- package/dist/m365/yammer/commands/message/message-list.js +9 -26
- package/dist/m365/yammer/commands/message/message-remove.js +20 -18
- package/dist/m365/yammer/commands/yammer-search.js +42 -56
- package/dist/utils/aadGroup.js +20 -0
- package/dist/utils/fsUtil.js +5 -0
- package/dist/utils/spo.js +601 -1
- package/docs/docs/cmd/pa/app/app-permission-ensure.mdx +85 -0
- package/docs/docs/cmd/pa/app/app-permission-remove.mdx +74 -0
- package/docs/docs/cmd/planner/task/task-add.mdx +22 -7
- package/docs/docs/cmd/planner/task/task-get.mdx +13 -4
- package/docs/docs/cmd/planner/task/task-list.mdx +22 -7
- package/docs/docs/cmd/planner/task/task-remove.mdx +25 -8
- package/docs/docs/cmd/planner/task/task-set.mdx +22 -7
- package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +94 -0
- package/docs/docs/cmd/spo/file/file-add.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-checkin.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-checkout-undo.mdx +1 -9
- package/docs/docs/cmd/spo/file/file-checkout.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-copy.mdx +20 -16
- package/docs/docs/cmd/spo/file/file-get.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-list.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-move.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-remove.mdx +8 -8
- package/docs/docs/cmd/spo/file/file-rename.mdx +3 -3
- package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-retentionlabel-remove.mdx +3 -3
- package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinginfo-get.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-add.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-clear.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-get.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-list.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-remove.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-sharinglink-set.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-clear.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-get.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-list.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-remove.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-version-restore.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-add.mdx +76 -1
- package/docs/docs/cmd/spo/folder/folder-get.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-list.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-remove.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-rename.mdx +5 -1
- package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-retentionlabel-remove.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-roleassignment-add.mdx +2 -2
- package/docs/docs/cmd/spo/folder/folder-roleassignment-remove.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-roleinheritance-break.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-roleinheritance-reset.mdx +1 -1
- package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-add.mdx +14 -1
- package/docs/docs/cmd/spo/site/site-ensure.mdx +1 -1
- package/npm-shrinkwrap.json +698 -345
- package/package.json +16 -15
|
@@ -141,18 +141,16 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
141
141
|
requestOptions.data.request.Owner = args.options.owners;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const response = yield request_1.default.post(requestOptions);
|
|
145
145
|
if (isTeamSite) {
|
|
146
|
-
if (
|
|
147
|
-
throw
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
logger.log(res.SiteUrl);
|
|
146
|
+
if (response.ErrorMessage !== null) {
|
|
147
|
+
throw response.ErrorMessage;
|
|
151
148
|
}
|
|
149
|
+
logger.log(response.SiteUrl);
|
|
152
150
|
}
|
|
153
151
|
else {
|
|
154
|
-
if (
|
|
155
|
-
logger.log(
|
|
152
|
+
if (response.SiteStatus === 2) {
|
|
153
|
+
logger.log(response.SiteUrl);
|
|
156
154
|
}
|
|
157
155
|
else {
|
|
158
156
|
throw 'An error has occurred while creating the site';
|
|
@@ -171,7 +169,7 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
171
169
|
this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
172
170
|
let exists;
|
|
173
171
|
if (args.options.removeDeletedSite) {
|
|
174
|
-
exists = yield this.
|
|
172
|
+
exists = yield this.siteExists(args.options.url, logger);
|
|
175
173
|
}
|
|
176
174
|
else {
|
|
177
175
|
// assume site doesn't exist
|
|
@@ -205,153 +203,18 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
205
203
|
},
|
|
206
204
|
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="4" ObjectPathId="3" /><ObjectPath Id="6" ObjectPathId="5" /><Query Id="7" ObjectPathId="3"><Query SelectAllProperties="true"><Properties /></Query></Query><Query Id="8" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Constructor Id="3" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="5" ParentId="3" Name="CreateSite"><Parameters><Parameter TypeId="{11f84fff-b8cf-47b6-8b50-34e692656606}"><Property Name="CompatibilityLevel" Type="Int32">0</Property><Property Name="Lcid" Type="UInt32">${lcid}</Property><Property Name="Owner" Type="String">${formatting_1.formatting.escapeXml(args.options.owners)}</Property><Property Name="StorageMaximumLevel" Type="Int64">${storageQuota}</Property><Property Name="StorageWarningLevel" Type="Int64">${storageQuotaWarningLevel}</Property><Property Name="Template" Type="String">${formatting_1.formatting.escapeXml(webTemplate)}</Property><Property Name="TimeZoneId" Type="Int32">${args.options.timeZone}</Property><Property Name="Title" Type="String">${formatting_1.formatting.escapeXml(args.options.title)}</Property><Property Name="Url" Type="String">${formatting_1.formatting.escapeXml(args.options.url)}</Property><Property Name="UserCodeMaximumLevel" Type="Double">${resourceQuota}</Property><Property Name="UserCodeWarningLevel" Type="Double">${resourceQuotaWarningLevel}</Property></Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
207
205
|
};
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
const operation = json[json.length - 1];
|
|
217
|
-
const isComplete = operation.IsComplete;
|
|
218
|
-
if (!args.options.wait || isComplete) {
|
|
219
|
-
resolve();
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
setTimeout(() => {
|
|
223
|
-
spo_1.spo.waitUntilFinished({
|
|
224
|
-
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
225
|
-
siteUrl: this.spoAdminUrl,
|
|
226
|
-
resolve,
|
|
227
|
-
reject,
|
|
228
|
-
logger,
|
|
229
|
-
currentContext: this.context,
|
|
230
|
-
verbose: this.verbose,
|
|
231
|
-
debug: this.debug
|
|
232
|
-
});
|
|
233
|
-
}, operation.PollingInterval);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
catch (err) {
|
|
238
|
-
this.handleRejectedPromise(err);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
siteExistsInTheRecycleBin(url, logger) {
|
|
243
|
-
return new Promise((resolve, reject) => {
|
|
244
|
-
spo_1.spo
|
|
245
|
-
.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug)
|
|
246
|
-
.then((res) => {
|
|
247
|
-
this.context = res;
|
|
248
|
-
if (this.verbose) {
|
|
249
|
-
logger.logToStderr(`Checking if the site ${url} exists...`);
|
|
250
|
-
}
|
|
251
|
-
const requestOptions = {
|
|
252
|
-
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
253
|
-
headers: {
|
|
254
|
-
'X-RequestDigest': this.context.FormDigestValue
|
|
255
|
-
},
|
|
256
|
-
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="197" ObjectPathId="196" /><ObjectPath Id="199" ObjectPathId="198" /><Query Id="200" ObjectPathId="198"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Constructor Id="196" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="198" ParentId="196" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter><Parameter Type="Boolean">false</Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
257
|
-
};
|
|
258
|
-
return request_1.default.post(requestOptions);
|
|
259
|
-
})
|
|
260
|
-
.then((res) => {
|
|
261
|
-
const json = JSON.parse(res);
|
|
262
|
-
const response = json[0];
|
|
263
|
-
if (response.ErrorInfo) {
|
|
264
|
-
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.Online.SharePoint.Common.SpoNoSiteException') {
|
|
265
|
-
return Promise.resolve(false);
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
return Promise.reject(response.ErrorInfo.ErrorMessage);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
const site = json[json.length - 1];
|
|
273
|
-
if (site.Status === 'Recycled') {
|
|
274
|
-
return Promise.reject(true);
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
return Promise.resolve(false);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
})
|
|
281
|
-
.then(() => {
|
|
282
|
-
if (this.verbose) {
|
|
283
|
-
logger.logToStderr(`Site doesn't exist. Checking if the site ${url} exists in the recycle bin...`);
|
|
206
|
+
const response = yield request_1.default.post(requestOptions);
|
|
207
|
+
const json = JSON.parse(response);
|
|
208
|
+
const responseContent = json[0];
|
|
209
|
+
if (responseContent.ErrorInfo) {
|
|
210
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
284
211
|
}
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
},
|
|
290
|
-
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="181" ObjectPathId="180" /><Query Id="182" ObjectPathId="180"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="180" ParentId="175" Name="GetDeletedSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
291
|
-
};
|
|
292
|
-
return request_1.default.post(requestOptions);
|
|
293
|
-
})
|
|
294
|
-
.then((res) => {
|
|
295
|
-
const json = JSON.parse(res);
|
|
296
|
-
const response = json[0];
|
|
297
|
-
if (response.ErrorInfo) {
|
|
298
|
-
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.SharePoint.Client.UnknownError') {
|
|
299
|
-
resolve(false);
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
303
|
-
}
|
|
212
|
+
const operation = json[json.length - 1];
|
|
213
|
+
const isComplete = operation.IsComplete;
|
|
214
|
+
if (!args.options.wait || isComplete) {
|
|
215
|
+
return;
|
|
304
216
|
}
|
|
305
|
-
|
|
306
|
-
const site = json[json.length - 1];
|
|
307
|
-
if (site.Status === 'Recycled') {
|
|
308
|
-
resolve(true);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
resolve(false);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}, (error) => {
|
|
315
|
-
if (typeof error === 'boolean') {
|
|
316
|
-
resolve(error);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
reject(error);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
deleteSiteFromTheRecycleBin(url, wait, logger) {
|
|
325
|
-
return new Promise((resolve, reject) => {
|
|
326
|
-
spo_1.spo
|
|
327
|
-
.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug)
|
|
328
|
-
.then((res) => {
|
|
329
|
-
this.context = res;
|
|
330
|
-
if (this.verbose) {
|
|
331
|
-
logger.logToStderr(`Deleting site ${url} from the recycle bin...`);
|
|
332
|
-
}
|
|
333
|
-
const requestOptions = {
|
|
334
|
-
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
335
|
-
headers: {
|
|
336
|
-
'X-RequestDigest': this.context.FormDigestValue
|
|
337
|
-
},
|
|
338
|
-
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="185" ObjectPathId="184" /><Query Id="186" ObjectPathId="184"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="184" ParentId="175" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
339
|
-
};
|
|
340
|
-
return request_1.default.post(requestOptions);
|
|
341
|
-
})
|
|
342
|
-
.then((res) => {
|
|
343
|
-
const json = JSON.parse(res);
|
|
344
|
-
const response = json[0];
|
|
345
|
-
if (response.ErrorInfo) {
|
|
346
|
-
reject(response.ErrorInfo.ErrorMessage);
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
const operation = json[json.length - 1];
|
|
350
|
-
const isComplete = operation.IsComplete;
|
|
351
|
-
if (!wait || isComplete) {
|
|
352
|
-
resolve();
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
217
|
+
yield new Promise((resolve, reject) => {
|
|
355
218
|
setTimeout(() => {
|
|
356
219
|
spo_1.spo.waitUntilFinished({
|
|
357
220
|
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
@@ -364,7 +227,103 @@ class SpoSiteAddCommand extends SpoCommand_1.default {
|
|
|
364
227
|
debug: this.debug
|
|
365
228
|
});
|
|
366
229
|
}, operation.PollingInterval);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
this.handleRejectedPromise(err);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
siteExists(url, logger) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
+
this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
240
|
+
if (this.verbose) {
|
|
241
|
+
logger.logToStderr(`Checking if the site ${url} exists...`);
|
|
242
|
+
}
|
|
243
|
+
const requestOptions = {
|
|
244
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
245
|
+
headers: {
|
|
246
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
247
|
+
},
|
|
248
|
+
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="197" ObjectPathId="196" /><ObjectPath Id="199" ObjectPathId="198" /><Query Id="200" ObjectPathId="198"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Constructor Id="196" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /><Method Id="198" ParentId="196" Name="GetSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter><Parameter Type="Boolean">false</Parameter></Parameters></Method></ObjectPaths></Request>`
|
|
249
|
+
};
|
|
250
|
+
const response = yield request_1.default.post(requestOptions);
|
|
251
|
+
const json = JSON.parse(response);
|
|
252
|
+
const responseContent = json[0];
|
|
253
|
+
if (responseContent.ErrorInfo) {
|
|
254
|
+
if (responseContent.ErrorInfo.ErrorTypeName === 'Microsoft.Online.SharePoint.Common.SpoNoSiteException') {
|
|
255
|
+
return yield this.siteExistsInTheRecycleBin(url, logger);
|
|
367
256
|
}
|
|
257
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
const site = json[json.length - 1];
|
|
261
|
+
return site.Status === 'Recycled';
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
siteExistsInTheRecycleBin(url, logger) {
|
|
266
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
+
if (this.verbose) {
|
|
268
|
+
logger.logToStderr(`Site doesn't exist. Checking if the site ${url} exists in the recycle bin...`);
|
|
269
|
+
}
|
|
270
|
+
const requestOptions = {
|
|
271
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
272
|
+
headers: {
|
|
273
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
274
|
+
},
|
|
275
|
+
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="181" ObjectPathId="180" /><Query Id="182" ObjectPathId="180"><Query SelectAllProperties="true"><Properties /></Query></Query></Actions><ObjectPaths><Method Id="180" ParentId="175" Name="GetDeletedSitePropertiesByUrl"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
276
|
+
};
|
|
277
|
+
const res = yield request_1.default.post(requestOptions);
|
|
278
|
+
const json = JSON.parse(res);
|
|
279
|
+
const response = json[0];
|
|
280
|
+
if (response.ErrorInfo) {
|
|
281
|
+
if (response.ErrorInfo.ErrorTypeName === 'Microsoft.SharePoint.Client.UnknownError') {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
285
|
+
}
|
|
286
|
+
const site = json[json.length - 1];
|
|
287
|
+
return site.Status === 'Recycled';
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
deleteSiteFromTheRecycleBin(url, wait, logger) {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
292
|
+
this.context = yield spo_1.spo.ensureFormDigest(this.spoAdminUrl, logger, this.context, this.debug);
|
|
293
|
+
if (this.verbose) {
|
|
294
|
+
logger.logToStderr(`Deleting site ${url} from the recycle bin...`);
|
|
295
|
+
}
|
|
296
|
+
const requestOptions = {
|
|
297
|
+
url: `${this.spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
298
|
+
headers: {
|
|
299
|
+
'X-RequestDigest': this.context.FormDigestValue
|
|
300
|
+
},
|
|
301
|
+
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="185" ObjectPathId="184" /><Query Id="186" ObjectPathId="184"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Method Id="184" ParentId="175" Name="RemoveDeletedSite"><Parameters><Parameter Type="String">${formatting_1.formatting.escapeXml(url)}</Parameter></Parameters></Method><Constructor Id="175" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
302
|
+
};
|
|
303
|
+
const response = yield request_1.default.post(requestOptions);
|
|
304
|
+
const json = JSON.parse(response);
|
|
305
|
+
const responseContent = json[0];
|
|
306
|
+
if (responseContent.ErrorInfo) {
|
|
307
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
308
|
+
}
|
|
309
|
+
const operation = json[json.length - 1];
|
|
310
|
+
const isComplete = operation.IsComplete;
|
|
311
|
+
if (!wait || isComplete) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
yield new Promise((resolve, reject) => {
|
|
315
|
+
setTimeout(() => {
|
|
316
|
+
spo_1.spo.waitUntilFinished({
|
|
317
|
+
operationId: JSON.stringify(operation._ObjectIdentity_),
|
|
318
|
+
siteUrl: this.spoAdminUrl,
|
|
319
|
+
resolve,
|
|
320
|
+
reject,
|
|
321
|
+
logger,
|
|
322
|
+
currentContext: this.context,
|
|
323
|
+
verbose: this.verbose,
|
|
324
|
+
debug: this.debug
|
|
325
|
+
});
|
|
326
|
+
}, operation.PollingInterval);
|
|
368
327
|
});
|
|
369
328
|
});
|
|
370
329
|
}
|
|
@@ -39,40 +39,39 @@ class SpoSiteAppPermissionAddCommand extends GraphCommand_1.default {
|
|
|
39
39
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionAddCommand_instances, "m", _SpoSiteAppPermissionAddCommand_initOptionSets).call(this);
|
|
40
40
|
}
|
|
41
41
|
getAppInfo(args) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
.get(appRequestOptions)
|
|
64
|
-
.then(response => {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (args.options.appId && args.options.appDisplayName) {
|
|
44
|
+
return {
|
|
45
|
+
appId: args.options.appId,
|
|
46
|
+
displayName: args.options.appDisplayName
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
let endpoint = "";
|
|
50
|
+
if (args.options.appId) {
|
|
51
|
+
endpoint = `${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,displayName&$filter=appId eq '${formatting_1.formatting.encodeQueryParameter(args.options.appId)}'`;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
endpoint = `${this.resource}/v1.0/myorganization/servicePrincipals?$select=appId,displayName&$filter=displayName eq '${formatting_1.formatting.encodeQueryParameter(args.options.appDisplayName)}'`;
|
|
55
|
+
}
|
|
56
|
+
const appRequestOptions = {
|
|
57
|
+
url: endpoint,
|
|
58
|
+
headers: {
|
|
59
|
+
accept: 'application/json;odata.metadata=none'
|
|
60
|
+
},
|
|
61
|
+
responseType: 'json'
|
|
62
|
+
};
|
|
63
|
+
const response = yield request_1.default.get(appRequestOptions);
|
|
65
64
|
const appItem = response.value[0];
|
|
66
65
|
if (!appItem) {
|
|
67
|
-
|
|
66
|
+
throw "The specified Azure AD app does not exist";
|
|
68
67
|
}
|
|
69
68
|
if (response.value.length > 1) {
|
|
70
|
-
|
|
69
|
+
throw `Multiple Azure AD app with displayName ${args.options.appDisplayName} found: ${response.value.map(x => x.appId)}`;
|
|
71
70
|
}
|
|
72
|
-
return
|
|
71
|
+
return {
|
|
73
72
|
appId: appItem.appId,
|
|
74
73
|
displayName: appItem.displayName
|
|
75
|
-
}
|
|
74
|
+
};
|
|
76
75
|
});
|
|
77
76
|
}
|
|
78
77
|
/**
|
|
@@ -31,15 +31,14 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
31
31
|
constructor() {
|
|
32
32
|
super();
|
|
33
33
|
_SpoSiteAppPermissionRemoveCommand_instances.add(this);
|
|
34
|
-
this.siteId = '';
|
|
35
34
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initTelemetry).call(this);
|
|
36
35
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initOptions).call(this);
|
|
37
36
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initValidators).call(this);
|
|
38
37
|
__classPrivateFieldGet(this, _SpoSiteAppPermissionRemoveCommand_instances, "m", _SpoSiteAppPermissionRemoveCommand_initOptionSets).call(this);
|
|
39
38
|
}
|
|
40
|
-
getPermissions() {
|
|
39
|
+
getPermissions(siteId) {
|
|
41
40
|
const requestOptions = {
|
|
42
|
-
url: `${this.resource}/v1.0/sites/${
|
|
41
|
+
url: `${this.resource}/v1.0/sites/${siteId}/permissions`,
|
|
43
42
|
headers: {
|
|
44
43
|
accept: 'application/json;odata.metadata=none'
|
|
45
44
|
},
|
|
@@ -47,34 +46,33 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
47
46
|
};
|
|
48
47
|
return request_1.default.get(requestOptions);
|
|
49
48
|
}
|
|
50
|
-
getFilteredPermissions(
|
|
49
|
+
getFilteredPermissions(options, permissions) {
|
|
51
50
|
let filterProperty = 'displayName';
|
|
52
|
-
let filterValue =
|
|
53
|
-
if (
|
|
51
|
+
let filterValue = options.appDisplayName;
|
|
52
|
+
if (options.appId) {
|
|
54
53
|
filterProperty = 'id';
|
|
55
|
-
filterValue =
|
|
54
|
+
filterValue = options.appId;
|
|
56
55
|
}
|
|
57
56
|
return permissions.filter((p) => {
|
|
58
57
|
return p.grantedToIdentities.some(({ application }) => application[filterProperty] === filterValue);
|
|
59
58
|
});
|
|
60
59
|
}
|
|
61
|
-
getPermissionIds(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
.getPermissions()
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
permissions = this.getFilteredPermissions(args, res.value);
|
|
60
|
+
getPermissionIds(siteId, options) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
if (options.id) {
|
|
63
|
+
return Promise.resolve([options.id]);
|
|
64
|
+
}
|
|
65
|
+
const permissionsObject = yield this.getPermissions(siteId);
|
|
66
|
+
let permissions = permissionsObject.value;
|
|
67
|
+
if (options.appId || options.appDisplayName) {
|
|
68
|
+
permissions = this.getFilteredPermissions(options, permissionsObject.value);
|
|
71
69
|
}
|
|
72
|
-
return
|
|
70
|
+
return permissions.map(x => x.id);
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
|
-
removePermissions(permissionId) {
|
|
73
|
+
removePermissions(siteId, permissionId) {
|
|
76
74
|
const spRequestOptions = {
|
|
77
|
-
url: `${this.resource}/v1.0/sites/${
|
|
75
|
+
url: `${this.resource}/v1.0/sites/${siteId}/permissions/${permissionId}`,
|
|
78
76
|
headers: {
|
|
79
77
|
'accept': 'application/json;odata.metadata=none'
|
|
80
78
|
},
|
|
@@ -84,23 +82,8 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
84
82
|
}
|
|
85
83
|
commandAction(logger, args) {
|
|
86
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
87
|
-
const removeSiteAppPermission = () => __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
try {
|
|
89
|
-
this.siteId = yield spo_1.spo.getSpoGraphSiteId(args.options.siteUrl);
|
|
90
|
-
const permissionIdsToRemove = yield this.getPermissionIds(args);
|
|
91
|
-
const tasks = [];
|
|
92
|
-
for (const permissionId of permissionIdsToRemove) {
|
|
93
|
-
tasks.push(this.removePermissions(permissionId));
|
|
94
|
-
}
|
|
95
|
-
const res = yield Promise.all(tasks);
|
|
96
|
-
logger.log(res);
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
this.handleRejectedODataJsonPromise(err);
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
85
|
if (args.options.confirm) {
|
|
103
|
-
yield removeSiteAppPermission();
|
|
86
|
+
yield this.removeSiteAppPermission(logger, args.options);
|
|
104
87
|
}
|
|
105
88
|
else {
|
|
106
89
|
const result = yield Cli_1.Cli.prompt({
|
|
@@ -110,11 +93,28 @@ class SpoSiteAppPermissionRemoveCommand extends GraphCommand_1.default {
|
|
|
110
93
|
message: `Are you sure you want to remove the specified application permission from site ${args.options.siteUrl}?`
|
|
111
94
|
});
|
|
112
95
|
if (result.continue) {
|
|
113
|
-
yield removeSiteAppPermission();
|
|
96
|
+
yield this.removeSiteAppPermission(logger, args.options);
|
|
114
97
|
}
|
|
115
98
|
}
|
|
116
99
|
});
|
|
117
100
|
}
|
|
101
|
+
removeSiteAppPermission(logger, options) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
try {
|
|
104
|
+
const siteId = yield spo_1.spo.getSpoGraphSiteId(options.siteUrl);
|
|
105
|
+
const permissionIdsToRemove = yield this.getPermissionIds(siteId, options);
|
|
106
|
+
const tasks = [];
|
|
107
|
+
for (const permissionId of permissionIdsToRemove) {
|
|
108
|
+
tasks.push(this.removePermissions(siteId, permissionId));
|
|
109
|
+
}
|
|
110
|
+
const response = yield Promise.all(tasks);
|
|
111
|
+
logger.log(response);
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
this.handleRejectedODataJsonPromise(err);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
118
|
}
|
|
119
119
|
_SpoSiteAppPermissionRemoveCommand_instances = new WeakSet(), _SpoSiteAppPermissionRemoveCommand_initTelemetry = function _SpoSiteAppPermissionRemoveCommand_initTelemetry() {
|
|
120
120
|
this.telemetry.push((args) => {
|
|
@@ -47,27 +47,26 @@ class SpoSiteAppPermissionSetCommand extends GraphCommand_1.default {
|
|
|
47
47
|
return permissions.filter((p) => p.grantedToIdentities.some(({ application }) => application[filterProperty] === filterValue));
|
|
48
48
|
}
|
|
49
49
|
getPermission(args) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.get(permissionRequestOptions)
|
|
62
|
-
.then(response => {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (args.options.id) {
|
|
52
|
+
return args.options.id;
|
|
53
|
+
}
|
|
54
|
+
const permissionRequestOptions = {
|
|
55
|
+
url: `${this.resource}/v1.0/sites/${this.siteId}/permissions`,
|
|
56
|
+
headers: {
|
|
57
|
+
accept: 'application/json;odata.metadata=none'
|
|
58
|
+
},
|
|
59
|
+
responseType: 'json'
|
|
60
|
+
};
|
|
61
|
+
const response = yield request_1.default.get(permissionRequestOptions);
|
|
63
62
|
const sitePermissionItems = this.getFilteredPermissions(args, response.value);
|
|
64
63
|
if (sitePermissionItems.length === 0) {
|
|
65
|
-
|
|
64
|
+
throw 'The specified app permission does not exist';
|
|
66
65
|
}
|
|
67
66
|
if (sitePermissionItems.length > 1) {
|
|
68
|
-
|
|
67
|
+
throw `Multiple app permissions with displayName ${args.options.appDisplayName} found: ${response.value.map(x => x.grantedToIdentities.map(y => y.application.id))}`;
|
|
69
68
|
}
|
|
70
|
-
return
|
|
69
|
+
return sitePermissionItems[0].id;
|
|
71
70
|
});
|
|
72
71
|
}
|
|
73
72
|
commandAction(logger, args) {
|