@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.
- package/dist/cli/Cli.js +19 -2
- package/dist/m365/spo/commands/file/file-move.js +73 -97
- package/dist/m365/spo/commands/folder/folder-copy.js +89 -45
- package/dist/m365/spo/commands/folder/folder-move.js +89 -47
- package/dist/m365/spo/commands/propertybag/propertybag-base.js +63 -59
- package/dist/m365/spo/commands/propertybag/propertybag-remove.js +28 -31
- package/dist/m365/spo/commands/site/FlowsPolicy.js +7 -0
- package/dist/m365/spo/commands/site/site-ensure.js +3 -3
- package/dist/m365/spo/commands/site/site-hubsite-disconnect.js +22 -22
- package/dist/m365/spo/commands/site/site-list.js +29 -39
- package/dist/m365/spo/commands/site/site-set.js +58 -47
- package/dist/m365/spo/commands/theme/theme-remove.js +24 -24
- package/dist/m365/spo/commands/theme/theme-set.js +0 -1
- package/dist/m365/spo/commands/user/user-remove.js +27 -27
- package/dist/m365/spo/commands/web/web-reindex.js +35 -42
- package/dist/m365/spo/commands/web/web-remove.js +21 -21
- package/dist/m365/spo/commands/web/web-roleassignment-add.js +16 -31
- package/dist/m365/spo/commands/web/web-roleassignment-remove.js +33 -44
- package/dist/m365/spo/commands/web/web-roleinheritance-break.js +18 -18
- package/dist/m365/spo/commands/web/web-roleinheritance-reset.js +19 -19
- package/dist/m365/yammer/commands/message/message-like-set.js +27 -28
- package/dist/m365/yammer/commands/message/message-list.js +62 -81
- package/dist/m365/yammer/commands/message/message-remove.js +18 -18
- package/dist/m365/yammer/commands/yammer-search.js +53 -69
- package/dist/utils/spo.js +12 -53
- package/docs/docs/cmd/spo/file/file-move.mdx +36 -18
- package/docs/docs/cmd/spo/folder/folder-copy.mdx +39 -12
- package/docs/docs/cmd/spo/folder/folder-move.mdx +40 -13
- package/docs/docs/cmd/spo/site/site-ensure.mdx +1 -1
- package/npm-shrinkwrap.json +1 -1
- package/package.json +1 -1
|
@@ -23,30 +23,8 @@ class SpoThemeRemoveCommand extends SpoCommand {
|
|
|
23
23
|
__classPrivateFieldGet(this, _SpoThemeRemoveCommand_instances, "m", _SpoThemeRemoveCommand_initOptions).call(this);
|
|
24
24
|
}
|
|
25
25
|
async commandAction(logger, args) {
|
|
26
|
-
const removeTheme = async () => {
|
|
27
|
-
try {
|
|
28
|
-
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
29
|
-
if (this.verbose) {
|
|
30
|
-
await logger.logToStderr(`Removing theme from tenant...`);
|
|
31
|
-
}
|
|
32
|
-
const requestOptions = {
|
|
33
|
-
url: `${spoAdminUrl}/_api/thememanager/DeleteTenantTheme`,
|
|
34
|
-
headers: {
|
|
35
|
-
'accept': 'application/json;odata=nometadata'
|
|
36
|
-
},
|
|
37
|
-
data: {
|
|
38
|
-
name: args.options.name
|
|
39
|
-
},
|
|
40
|
-
responseType: 'json'
|
|
41
|
-
};
|
|
42
|
-
await request.post(requestOptions);
|
|
43
|
-
}
|
|
44
|
-
catch (err) {
|
|
45
|
-
this.handleRejectedODataJsonPromise(err);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
26
|
if (args.options.force) {
|
|
49
|
-
await removeTheme();
|
|
27
|
+
await this.removeTheme(logger, args.options);
|
|
50
28
|
}
|
|
51
29
|
else {
|
|
52
30
|
const result = await Cli.prompt({
|
|
@@ -56,8 +34,30 @@ class SpoThemeRemoveCommand extends SpoCommand {
|
|
|
56
34
|
message: `Are you sure you want to remove the theme`
|
|
57
35
|
});
|
|
58
36
|
if (result.continue) {
|
|
59
|
-
await removeTheme();
|
|
37
|
+
await this.removeTheme(logger, args.options);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async removeTheme(logger, options) {
|
|
42
|
+
try {
|
|
43
|
+
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
44
|
+
if (this.verbose) {
|
|
45
|
+
await logger.logToStderr(`Removing theme from tenant...`);
|
|
60
46
|
}
|
|
47
|
+
const requestOptions = {
|
|
48
|
+
url: `${spoAdminUrl}/_api/thememanager/DeleteTenantTheme`,
|
|
49
|
+
headers: {
|
|
50
|
+
'accept': 'application/json;odata=nometadata'
|
|
51
|
+
},
|
|
52
|
+
data: {
|
|
53
|
+
name: options.name
|
|
54
|
+
},
|
|
55
|
+
responseType: 'json'
|
|
56
|
+
};
|
|
57
|
+
await request.post(requestOptions);
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
this.handleRejectedODataJsonPromise(err);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -26,33 +26,8 @@ class SpoUserRemoveCommand extends SpoCommand {
|
|
|
26
26
|
__classPrivateFieldGet(this, _SpoUserRemoveCommand_instances, "m", _SpoUserRemoveCommand_initOptionSets).call(this);
|
|
27
27
|
}
|
|
28
28
|
async commandAction(logger, args) {
|
|
29
|
-
const removeUser = async () => {
|
|
30
|
-
if (this.verbose) {
|
|
31
|
-
await logger.logToStderr(`Removing user from subsite ${args.options.webUrl} ...`);
|
|
32
|
-
}
|
|
33
|
-
let requestUrl = '';
|
|
34
|
-
if (args.options.id) {
|
|
35
|
-
requestUrl = `${encodeURI(args.options.webUrl)}/_api/web/siteusers/removebyid(${args.options.id})`;
|
|
36
|
-
}
|
|
37
|
-
if (args.options.loginName) {
|
|
38
|
-
requestUrl = `${encodeURI(args.options.webUrl)}/_api/web/siteusers/removeByLoginName('${formatting.encodeQueryParameter(args.options.loginName)}')`;
|
|
39
|
-
}
|
|
40
|
-
const requestOptions = {
|
|
41
|
-
url: requestUrl,
|
|
42
|
-
headers: {
|
|
43
|
-
accept: 'application/json;odata=nometadata'
|
|
44
|
-
},
|
|
45
|
-
responseType: 'json'
|
|
46
|
-
};
|
|
47
|
-
try {
|
|
48
|
-
await request.post(requestOptions);
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
this.handleRejectedODataJsonPromise(err);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
29
|
if (args.options.force) {
|
|
55
|
-
await removeUser();
|
|
30
|
+
await this.removeUser(logger, args.options);
|
|
56
31
|
}
|
|
57
32
|
else {
|
|
58
33
|
const result = await Cli.prompt({
|
|
@@ -62,10 +37,35 @@ class SpoUserRemoveCommand extends SpoCommand {
|
|
|
62
37
|
message: `Are you sure you want to remove specified user from the site ${args.options.webUrl}`
|
|
63
38
|
});
|
|
64
39
|
if (result.continue) {
|
|
65
|
-
await removeUser();
|
|
40
|
+
await this.removeUser(logger, args.options);
|
|
66
41
|
}
|
|
67
42
|
}
|
|
68
43
|
}
|
|
44
|
+
async removeUser(logger, options) {
|
|
45
|
+
if (this.verbose) {
|
|
46
|
+
await logger.logToStderr(`Removing user from subsite ${options.webUrl} ...`);
|
|
47
|
+
}
|
|
48
|
+
let requestUrl = `${encodeURI(options.webUrl)}/_api/web/siteusers/`;
|
|
49
|
+
if (options.id) {
|
|
50
|
+
requestUrl += `removebyid(${options.id})`;
|
|
51
|
+
}
|
|
52
|
+
else if (options.loginName) {
|
|
53
|
+
requestUrl += `removeByLoginName('${formatting.encodeQueryParameter(options.loginName)}')`;
|
|
54
|
+
}
|
|
55
|
+
const requestOptions = {
|
|
56
|
+
url: requestUrl,
|
|
57
|
+
headers: {
|
|
58
|
+
accept: 'application/json;odata=nometadata'
|
|
59
|
+
},
|
|
60
|
+
responseType: 'json'
|
|
61
|
+
};
|
|
62
|
+
try {
|
|
63
|
+
await request.post(requestOptions);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
this.handleRejectedODataJsonPromise(err);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
69
|
}
|
|
70
70
|
_SpoUserRemoveCommand_instances = new WeakSet(), _SpoUserRemoveCommand_initTelemetry = function _SpoUserRemoveCommand_initTelemetry() {
|
|
71
71
|
this.telemetry.push((args) => {
|
|
@@ -66,50 +66,43 @@ class SpoWebReindexCommand extends SpoCommand {
|
|
|
66
66
|
this.handleRejectedPromise(err);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
reindexLists(webUrl, requestDigest, logger, webIdentityResp) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
.then(() => {
|
|
89
|
-
resolve();
|
|
90
|
-
}, (err) => reject(err));
|
|
91
|
-
});
|
|
69
|
+
async reindexLists(webUrl, requestDigest, logger, webIdentityResp) {
|
|
70
|
+
try {
|
|
71
|
+
if (this.debug) {
|
|
72
|
+
await logger.logToStderr(`Retrieving information about lists...`);
|
|
73
|
+
}
|
|
74
|
+
const requestOptions = {
|
|
75
|
+
url: `${webUrl}/_api/web/lists?$select=NoCrawl,Title,RootFolder/Properties,RootFolder/ServerRelativeUrl&$expand=RootFolder/Properties`,
|
|
76
|
+
headers: {
|
|
77
|
+
'accept': 'application/json;odata=nometadata'
|
|
78
|
+
},
|
|
79
|
+
responseType: 'json'
|
|
80
|
+
};
|
|
81
|
+
const lists = await request.get(requestOptions);
|
|
82
|
+
const promises = lists.value.map(l => this.reindexList(l, webUrl, requestDigest, webIdentityResp, logger));
|
|
83
|
+
await Promise.all(promises);
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
throw err;
|
|
87
|
+
}
|
|
92
88
|
}
|
|
93
|
-
reindexList(list, webUrl, requestDigest, webIdentityResp, logger) {
|
|
94
|
-
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
await logger.logToStderr(`List ${list.Title} is excluded from crawling`);
|
|
98
|
-
}
|
|
99
|
-
resolve();
|
|
100
|
-
return;
|
|
89
|
+
async reindexList(list, webUrl, requestDigest, webIdentityResp, logger) {
|
|
90
|
+
if (list.NoCrawl) {
|
|
91
|
+
if (this.debug) {
|
|
92
|
+
await logger.logToStderr(`List ${list.Title} is excluded from crawling`);
|
|
101
93
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
try {
|
|
97
|
+
const folderIdentityResp = await spo.getFolderIdentity(webIdentityResp.objectIdentity, webUrl, list.RootFolder.ServerRelativeUrl, requestDigest);
|
|
98
|
+
let searchversion = list.RootFolder.Properties.vti_x005f_searchversion || 0;
|
|
99
|
+
searchversion++;
|
|
100
|
+
await SpoPropertyBagBaseCommand.setProperty('vti_searchversion', searchversion.toString(), webUrl, requestDigest, folderIdentityResp, logger, this.debug, list.RootFolder.ServerRelativeUrl);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
catch (err) {
|
|
104
|
+
throw (err);
|
|
105
|
+
}
|
|
113
106
|
}
|
|
114
107
|
}
|
|
115
108
|
_SpoWebReindexCommand_instances = new WeakSet(), _SpoWebReindexCommand_initOptions = function _SpoWebReindexCommand_initOptions() {
|
|
@@ -24,27 +24,8 @@ class SpoWebRemoveCommand extends SpoCommand {
|
|
|
24
24
|
__classPrivateFieldGet(this, _SpoWebRemoveCommand_instances, "m", _SpoWebRemoveCommand_initValidators).call(this);
|
|
25
25
|
}
|
|
26
26
|
async commandAction(logger, args) {
|
|
27
|
-
const removeWeb = async () => {
|
|
28
|
-
const requestOptions = {
|
|
29
|
-
url: `${encodeURI(args.options.url)}/_api/web`,
|
|
30
|
-
headers: {
|
|
31
|
-
accept: 'application/json;odata=nometadata',
|
|
32
|
-
'X-HTTP-Method': 'DELETE'
|
|
33
|
-
},
|
|
34
|
-
responseType: 'json'
|
|
35
|
-
};
|
|
36
|
-
if (this.verbose) {
|
|
37
|
-
await logger.logToStderr(`Deleting subsite ${args.options.url} ...`);
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
await request.post(requestOptions);
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
this.handleRejectedODataJsonPromise(err);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
27
|
if (args.options.force) {
|
|
47
|
-
await removeWeb();
|
|
28
|
+
await this.removeWeb(logger, args.options.url);
|
|
48
29
|
}
|
|
49
30
|
else {
|
|
50
31
|
const result = await Cli.prompt({
|
|
@@ -54,10 +35,29 @@ class SpoWebRemoveCommand extends SpoCommand {
|
|
|
54
35
|
message: `Are you sure you want to remove the subsite ${args.options.url}`
|
|
55
36
|
});
|
|
56
37
|
if (result.continue) {
|
|
57
|
-
await removeWeb();
|
|
38
|
+
await this.removeWeb(logger, args.options.url);
|
|
58
39
|
}
|
|
59
40
|
}
|
|
60
41
|
}
|
|
42
|
+
async removeWeb(logger, url) {
|
|
43
|
+
const requestOptions = {
|
|
44
|
+
url: `${encodeURI(url)}/_api/web`,
|
|
45
|
+
headers: {
|
|
46
|
+
accept: 'application/json;odata=nometadata',
|
|
47
|
+
'X-HTTP-Method': 'DELETE'
|
|
48
|
+
},
|
|
49
|
+
responseType: 'json'
|
|
50
|
+
};
|
|
51
|
+
if (this.verbose) {
|
|
52
|
+
await logger.logToStderr(`Deleting subsite ${url} ...`);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
await request.post(requestOptions);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
this.handleRejectedODataJsonPromise(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
61
|
}
|
|
62
62
|
_SpoWebRemoveCommand_instances = new WeakSet(), _SpoWebRemoveCommand_initTelemetry = function _SpoWebRemoveCommand_initTelemetry() {
|
|
63
63
|
this.telemetry.push((args) => {
|
|
@@ -49,7 +49,7 @@ class SpoWebRoleAssignmentAddCommand extends SpoCommand {
|
|
|
49
49
|
this.handleRejectedODataJsonPromise(err);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
addRoleAssignment(logger, options) {
|
|
52
|
+
async addRoleAssignment(logger, options) {
|
|
53
53
|
const requestOptions = {
|
|
54
54
|
url: `${options.webUrl}/_api/web/roleassignments/addroleassignment(principalid='${options.principalId}',roledefid='${options.roleDefinitionId}')`,
|
|
55
55
|
method: 'POST',
|
|
@@ -59,14 +59,11 @@ class SpoWebRoleAssignmentAddCommand extends SpoCommand {
|
|
|
59
59
|
},
|
|
60
60
|
responseType: 'json'
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
.post(requestOptions)
|
|
64
|
-
.then(_ => Promise.resolve())
|
|
65
|
-
.catch((err) => Promise.reject(err));
|
|
62
|
+
await request.post(requestOptions);
|
|
66
63
|
}
|
|
67
|
-
getRoleDefinitionId(options) {
|
|
64
|
+
async getRoleDefinitionId(options) {
|
|
68
65
|
if (!options.roleDefinitionName) {
|
|
69
|
-
return
|
|
66
|
+
return options.roleDefinitionId;
|
|
70
67
|
}
|
|
71
68
|
const roleDefinitionListCommandOptions = {
|
|
72
69
|
webUrl: options.webUrl,
|
|
@@ -74,16 +71,12 @@ class SpoWebRoleAssignmentAddCommand extends SpoCommand {
|
|
|
74
71
|
debug: this.debug,
|
|
75
72
|
verbose: this.verbose
|
|
76
73
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return Promise.resolve(roleDefinitionId);
|
|
82
|
-
}, (err) => {
|
|
83
|
-
return Promise.reject(err);
|
|
84
|
-
});
|
|
74
|
+
const output = await Cli.executeCommandWithOutput(spoRoleDefinitionListCommand, { options: { ...roleDefinitionListCommandOptions, _: [] } });
|
|
75
|
+
const getRoleDefinitionListOutput = JSON.parse(output.stdout);
|
|
76
|
+
const roleDefinitionId = getRoleDefinitionListOutput.find((role) => role.Name === options.roleDefinitionName).Id;
|
|
77
|
+
return roleDefinitionId;
|
|
85
78
|
}
|
|
86
|
-
getGroupPrincipalId(options) {
|
|
79
|
+
async getGroupPrincipalId(options) {
|
|
87
80
|
const groupGetCommandOptions = {
|
|
88
81
|
webUrl: options.webUrl,
|
|
89
82
|
name: options.groupName,
|
|
@@ -91,15 +84,11 @@ class SpoWebRoleAssignmentAddCommand extends SpoCommand {
|
|
|
91
84
|
debug: this.debug,
|
|
92
85
|
verbose: this.verbose
|
|
93
86
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return Promise.resolve(getGroupOutput.Id);
|
|
98
|
-
}, (err) => {
|
|
99
|
-
return Promise.reject(err);
|
|
100
|
-
});
|
|
87
|
+
const output = await Cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
|
|
88
|
+
const getGroupOutput = JSON.parse(output.stdout);
|
|
89
|
+
return getGroupOutput.Id;
|
|
101
90
|
}
|
|
102
|
-
getUserPrincipalId(options) {
|
|
91
|
+
async getUserPrincipalId(options) {
|
|
103
92
|
const userGetCommandOptions = {
|
|
104
93
|
webUrl: options.webUrl,
|
|
105
94
|
email: options.upn,
|
|
@@ -108,13 +97,9 @@ class SpoWebRoleAssignmentAddCommand extends SpoCommand {
|
|
|
108
97
|
debug: this.debug,
|
|
109
98
|
verbose: this.verbose
|
|
110
99
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return Promise.resolve(getUserOutput.Id);
|
|
115
|
-
}, (err) => {
|
|
116
|
-
return Promise.reject(err);
|
|
117
|
-
});
|
|
100
|
+
const output = await Cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
|
|
101
|
+
const getUserOutput = JSON.parse(output.stdout);
|
|
102
|
+
return getUserOutput.Id;
|
|
118
103
|
}
|
|
119
104
|
}
|
|
120
105
|
_SpoWebRoleAssignmentAddCommand_instances = new WeakSet(), _SpoWebRoleAssignmentAddCommand_initTelemetry = function _SpoWebRoleAssignmentAddCommand_initTelemetry() {
|
|
@@ -27,29 +27,8 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
27
27
|
__classPrivateFieldGet(this, _SpoWebRoleAssignmentRemoveCommand_instances, "m", _SpoWebRoleAssignmentRemoveCommand_initOptionSets).call(this);
|
|
28
28
|
}
|
|
29
29
|
async commandAction(logger, args) {
|
|
30
|
-
const removeRoleAssignment = async () => {
|
|
31
|
-
if (this.verbose) {
|
|
32
|
-
await logger.logToStderr(`Removing role assignment from web ${args.options.webUrl}...`);
|
|
33
|
-
}
|
|
34
|
-
try {
|
|
35
|
-
if (args.options.upn) {
|
|
36
|
-
args.options.principalId = await this.getUserPrincipalId(args.options);
|
|
37
|
-
await this.removeRoleAssignment(logger, args.options);
|
|
38
|
-
}
|
|
39
|
-
else if (args.options.groupName) {
|
|
40
|
-
args.options.principalId = await this.getGroupPrincipalId(args.options);
|
|
41
|
-
await this.removeRoleAssignment(logger, args.options);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
await this.removeRoleAssignment(logger, args.options);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
this.handleRejectedODataJsonPromise(err);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
30
|
if (args.options.force) {
|
|
52
|
-
await removeRoleAssignment();
|
|
31
|
+
await this.removeRoleAssignment(logger, args.options);
|
|
53
32
|
}
|
|
54
33
|
else {
|
|
55
34
|
const result = await Cli.prompt({
|
|
@@ -59,11 +38,32 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
59
38
|
message: `Are you sure you want to remove role assignment from web ${args.options.webUrl}?`
|
|
60
39
|
});
|
|
61
40
|
if (result.continue) {
|
|
62
|
-
await removeRoleAssignment();
|
|
41
|
+
await this.removeRoleAssignment(logger, args.options);
|
|
63
42
|
}
|
|
64
43
|
}
|
|
65
44
|
}
|
|
66
|
-
removeRoleAssignment(logger, options) {
|
|
45
|
+
async removeRoleAssignment(logger, options) {
|
|
46
|
+
if (this.verbose) {
|
|
47
|
+
await logger.logToStderr(`Removing role assignment from web ${options.webUrl}...`);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
if (options.upn) {
|
|
51
|
+
options.principalId = await this.getUserPrincipalId(options);
|
|
52
|
+
await this.removeRoleAssignmentWithOptions(logger, options);
|
|
53
|
+
}
|
|
54
|
+
else if (options.groupName) {
|
|
55
|
+
options.principalId = await this.getGroupPrincipalId(options);
|
|
56
|
+
await this.removeRoleAssignmentWithOptions(logger, options);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
await this.removeRoleAssignmentWithOptions(logger, options);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
this.handleRejectedODataJsonPromise(err);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async removeRoleAssignmentWithOptions(logger, options) {
|
|
67
67
|
const requestOptions = {
|
|
68
68
|
url: `${options.webUrl}/_api/web/roleassignments/removeroleassignment(principalid='${options.principalId}')`,
|
|
69
69
|
method: 'POST',
|
|
@@ -73,12 +73,9 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
73
73
|
},
|
|
74
74
|
responseType: 'json'
|
|
75
75
|
};
|
|
76
|
-
|
|
77
|
-
.post(requestOptions)
|
|
78
|
-
.then(_ => Promise.resolve())
|
|
79
|
-
.catch((err) => Promise.reject(err));
|
|
76
|
+
await request.post(requestOptions);
|
|
80
77
|
}
|
|
81
|
-
getGroupPrincipalId(options) {
|
|
78
|
+
async getGroupPrincipalId(options) {
|
|
82
79
|
const groupGetCommandOptions = {
|
|
83
80
|
webUrl: options.webUrl,
|
|
84
81
|
name: options.groupName,
|
|
@@ -86,15 +83,11 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
86
83
|
debug: this.debug,
|
|
87
84
|
verbose: this.verbose
|
|
88
85
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return Promise.resolve(getGroupOutput.Id);
|
|
93
|
-
}, (err) => {
|
|
94
|
-
return Promise.reject(err);
|
|
95
|
-
});
|
|
86
|
+
const output = await Cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
|
|
87
|
+
const getGroupOutput = JSON.parse(output.stdout);
|
|
88
|
+
return getGroupOutput.Id;
|
|
96
89
|
}
|
|
97
|
-
getUserPrincipalId(options) {
|
|
90
|
+
async getUserPrincipalId(options) {
|
|
98
91
|
const userGetCommandOptions = {
|
|
99
92
|
webUrl: options.webUrl,
|
|
100
93
|
email: options.upn,
|
|
@@ -103,13 +96,9 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
103
96
|
debug: this.debug,
|
|
104
97
|
verbose: this.verbose
|
|
105
98
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return Promise.resolve(getUserOutput.Id);
|
|
110
|
-
}, (err) => {
|
|
111
|
-
return Promise.reject(err);
|
|
112
|
-
});
|
|
99
|
+
const output = await Cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
|
|
100
|
+
const getUserOutput = JSON.parse(output.stdout);
|
|
101
|
+
return getUserOutput.Id;
|
|
113
102
|
}
|
|
114
103
|
}
|
|
115
104
|
_SpoWebRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoWebRoleAssignmentRemoveCommand_initTelemetry = function _SpoWebRoleAssignmentRemoveCommand_initTelemetry() {
|
|
@@ -27,24 +27,8 @@ class SpoWebRoleInheritanceBreakCommand extends SpoCommand {
|
|
|
27
27
|
if (this.verbose) {
|
|
28
28
|
await logger.logToStderr(`Break role inheritance of subsite with URL ${args.options.webUrl}...`);
|
|
29
29
|
}
|
|
30
|
-
const breakroleInheritance = async () => {
|
|
31
|
-
const requestOptions = {
|
|
32
|
-
url: `${args.options.webUrl}/_api/web/breakroleinheritance(${!args.options.clearExistingPermissions})`,
|
|
33
|
-
headers: {
|
|
34
|
-
'accept': 'application/json;odata=nometadata',
|
|
35
|
-
'content-type': 'application/json'
|
|
36
|
-
},
|
|
37
|
-
responseType: 'json'
|
|
38
|
-
};
|
|
39
|
-
try {
|
|
40
|
-
await request.post(requestOptions);
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
this.handleRejectedODataJsonPromise(err);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
30
|
if (args.options.force) {
|
|
47
|
-
await breakroleInheritance();
|
|
31
|
+
await this.breakroleInheritance(args.options);
|
|
48
32
|
}
|
|
49
33
|
else {
|
|
50
34
|
const result = await Cli.prompt({
|
|
@@ -54,10 +38,26 @@ class SpoWebRoleInheritanceBreakCommand extends SpoCommand {
|
|
|
54
38
|
message: `Are you sure you want to break the role inheritance of subsite ${args.options.webUrl}`
|
|
55
39
|
});
|
|
56
40
|
if (result.continue) {
|
|
57
|
-
await breakroleInheritance();
|
|
41
|
+
await this.breakroleInheritance(args.options);
|
|
58
42
|
}
|
|
59
43
|
}
|
|
60
44
|
}
|
|
45
|
+
async breakroleInheritance(options) {
|
|
46
|
+
const requestOptions = {
|
|
47
|
+
url: `${options.webUrl}/_api/web/breakroleinheritance(${!options.clearExistingPermissions})`,
|
|
48
|
+
headers: {
|
|
49
|
+
'accept': 'application/json;odata=nometadata',
|
|
50
|
+
'content-type': 'application/json'
|
|
51
|
+
},
|
|
52
|
+
responseType: 'json'
|
|
53
|
+
};
|
|
54
|
+
try {
|
|
55
|
+
await request.post(requestOptions);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
this.handleRejectedODataJsonPromise(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
61
|
}
|
|
62
62
|
_SpoWebRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoWebRoleInheritanceBreakCommand_initTelemetry = function _SpoWebRoleInheritanceBreakCommand_initTelemetry() {
|
|
63
63
|
this.telemetry.push((args) => {
|
|
@@ -27,25 +27,8 @@ class SpoWebRoleInheritanceResetCommand extends SpoCommand {
|
|
|
27
27
|
if (this.verbose) {
|
|
28
28
|
await logger.logToStderr(`Restore role inheritance of subsite at ${args.options.webUrl}...`);
|
|
29
29
|
}
|
|
30
|
-
const resetWebRoleInheritance = async () => {
|
|
31
|
-
try {
|
|
32
|
-
const requestOptions = {
|
|
33
|
-
url: `${args.options.webUrl}/_api/web/resetroleinheritance`,
|
|
34
|
-
method: 'POST',
|
|
35
|
-
headers: {
|
|
36
|
-
'accept': 'application/json;odata=nometadata',
|
|
37
|
-
'content-type': 'application/json'
|
|
38
|
-
},
|
|
39
|
-
responseType: 'json'
|
|
40
|
-
};
|
|
41
|
-
await request.post(requestOptions);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
this.handleRejectedODataJsonPromise(err);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
30
|
if (args.options.force) {
|
|
48
|
-
await resetWebRoleInheritance();
|
|
31
|
+
await this.resetWebRoleInheritance(args.options);
|
|
49
32
|
}
|
|
50
33
|
else {
|
|
51
34
|
const result = await Cli.prompt({
|
|
@@ -55,10 +38,27 @@ class SpoWebRoleInheritanceResetCommand extends SpoCommand {
|
|
|
55
38
|
message: `Are you sure you want to reset the role inheritance of ${args.options.webUrl}`
|
|
56
39
|
});
|
|
57
40
|
if (result.continue) {
|
|
58
|
-
await resetWebRoleInheritance();
|
|
41
|
+
await this.resetWebRoleInheritance(args.options);
|
|
59
42
|
}
|
|
60
43
|
}
|
|
61
44
|
}
|
|
45
|
+
async resetWebRoleInheritance(options) {
|
|
46
|
+
try {
|
|
47
|
+
const requestOptions = {
|
|
48
|
+
url: `${options.webUrl}/_api/web/resetroleinheritance`,
|
|
49
|
+
method: 'POST',
|
|
50
|
+
headers: {
|
|
51
|
+
'accept': 'application/json;odata=nometadata',
|
|
52
|
+
'content-type': 'application/json'
|
|
53
|
+
},
|
|
54
|
+
responseType: 'json'
|
|
55
|
+
};
|
|
56
|
+
await request.post(requestOptions);
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
this.handleRejectedODataJsonPromise(err);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
62
|
}
|
|
63
63
|
_SpoWebRoleInheritanceResetCommand_instances = new WeakSet(), _SpoWebRoleInheritanceResetCommand_initTelemetry = function _SpoWebRoleInheritanceResetCommand_initTelemetry() {
|
|
64
64
|
this.telemetry.push((args) => {
|