@pnp/cli-microsoft365 6.0.0-beta.c5ce305 → 6.0.0-beta.da01a44
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/.eslintrc.js +13 -0
- package/README.md +5 -0
- package/dist/appInsights.js +2 -0
- package/dist/m365/pp/commands/dataverse/dataverse-table-list.js +75 -0
- package/dist/m365/pp/commands/solution/Solution.js +3 -0
- package/dist/m365/pp/commands/solution/solution-list.js +87 -0
- package/dist/m365/pp/commands/tenant/tenant-settings-list.js +45 -0
- package/dist/m365/pp/commands.js +4 -1
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0.js +0 -2
- package/dist/m365/spfx/commands/spfx-doctor.js +37 -7
- package/dist/m365/spo/commands/eventreceiver/EventReceiver.js +3 -0
- package/dist/m365/spo/commands/eventreceiver/eventreceiver-remove.js +182 -0
- package/dist/m365/spo/commands/file/file-copy.js +25 -39
- package/dist/m365/spo/commands/file/file-move.js +24 -37
- package/dist/m365/spo/commands/file/file-rename.js +19 -16
- package/dist/m365/spo/commands/file/file-roleassignment-add.js +231 -0
- package/dist/m365/spo/commands/file/file-roleassignment-remove.js +180 -0
- package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
- package/dist/m365/spo/commands/folder/folder-roleinheritance-break.js +94 -0
- package/dist/m365/spo/commands/folder/folder-roleinheritance-reset.js +1 -1
- package/dist/m365/spo/commands/group/AssociatedGroupPropertiesCollection.js +3 -0
- package/dist/m365/spo/commands/group/group-list.js +49 -10
- package/dist/m365/spo/commands/list/list-roleassignment-add.js +10 -10
- package/dist/m365/spo/commands/list/list-roleassignment-remove.js +8 -8
- package/dist/m365/spo/commands/listitem/listitem-roleassignment-remove.js +8 -8
- package/dist/m365/spo/commands/web/web-roleassignment-add.js +10 -10
- package/dist/m365/spo/commands/web/web-roleassignment-remove.js +8 -8
- package/dist/m365/spo/commands.js +4 -0
- package/dist/utils/cache.js +81 -0
- package/dist/utils/pid.js +57 -0
- package/dist/utils/powerPlatform.js +42 -0
- package/docs/docs/cmd/pp/dataverse/dataverse-table-list.md +33 -0
- package/docs/docs/cmd/pp/environment/environment-list.md +1 -1
- package/docs/docs/cmd/pp/solution/solution-list.md +33 -0
- package/docs/docs/cmd/pp/tenant/tenant-settings-list.md +26 -0
- package/docs/docs/cmd/spfx/spfx-doctor.md +10 -1
- package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.md +69 -0
- package/docs/docs/cmd/spo/file/file-roleassignment-add.md +57 -0
- package/docs/docs/cmd/spo/file/file-roleassignment-remove.md +54 -0
- package/docs/docs/cmd/spo/folder/folder-roleinheritance-break.md +39 -0
- package/docs/docs/cmd/spo/folder/folder-roleinheritance-reset.md +2 -2
- package/docs/docs/cmd/spo/group/group-list.md +10 -1
- package/docs/docs/cmd/spo/hubsite/hubsite-disconnect.md +1 -1
- package/docs/docs/cmd/spo/hubsite/hubsite-get.md +3 -3
- package/package.json +2 -1
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +0 -60
|
@@ -16,12 +16,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
16
16
|
var _SpoFileCopyCommand_instances, _SpoFileCopyCommand_initTelemetry, _SpoFileCopyCommand_initOptions, _SpoFileCopyCommand_initValidators;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const url = require("url");
|
|
19
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
19
20
|
const request_1 = require("../../../../request");
|
|
20
21
|
const spo_1 = require("../../../../utils/spo");
|
|
21
22
|
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
22
23
|
const validation_1 = require("../../../../utils/validation");
|
|
23
24
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
24
25
|
const commands_1 = require("../../commands");
|
|
26
|
+
const removeCommand = require('./file-remove');
|
|
25
27
|
class SpoFileCopyCommand extends SpoCommand_1.default {
|
|
26
28
|
constructor() {
|
|
27
29
|
super();
|
|
@@ -123,50 +125,34 @@ class SpoFileCopyCommand extends SpoCommand_1.default {
|
|
|
123
125
|
* Moves file in the site recycle bin
|
|
124
126
|
*/
|
|
125
127
|
recycleFile(tenantUrl, targetUrl, filename, logger) {
|
|
126
|
-
return
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
129
|
const targetFolderAbsoluteUrl = urlUtil_1.urlUtil.urlCombine(tenantUrl, targetUrl);
|
|
128
|
-
// since the target WebFullUrl is unknown we can use
|
|
130
|
+
// since the target WebFullUrl is unknown we can use getRequestDigest
|
|
129
131
|
// to get it from target folder absolute url.
|
|
130
132
|
// Similar approach used here Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect
|
|
131
|
-
spo_1.spo
|
|
132
|
-
|
|
133
|
-
.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
133
|
+
const contextResponse = yield spo_1.spo.getRequestDigest(targetFolderAbsoluteUrl);
|
|
134
|
+
if (this.debug) {
|
|
135
|
+
logger.logToStderr(`contextResponse.WebFullUrl: ${contextResponse.WebFullUrl}`);
|
|
136
|
+
}
|
|
137
|
+
const targetFileServerRelativeUrl = `${urlUtil_1.urlUtil.getServerRelativePath(contextResponse.WebFullUrl, targetUrl)}/${filename}`;
|
|
138
|
+
const removeOptions = {
|
|
139
|
+
webUrl: contextResponse.WebFullUrl,
|
|
140
|
+
url: targetFileServerRelativeUrl,
|
|
141
|
+
recycle: true,
|
|
142
|
+
confirm: true,
|
|
143
|
+
debug: this.debug,
|
|
144
|
+
verbose: this.verbose
|
|
145
|
+
};
|
|
146
|
+
try {
|
|
147
|
+
yield Cli_1.Cli.executeCommand(removeCommand, { options: Object.assign(Object.assign({}, removeOptions), { _: [] }) });
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
|
|
139
151
|
}
|
|
140
|
-
|
|
141
|
-
|
|
152
|
+
else {
|
|
153
|
+
throw err;
|
|
142
154
|
}
|
|
143
|
-
|
|
144
|
-
const requestOptions = {
|
|
145
|
-
url: requestUrl,
|
|
146
|
-
method: 'POST',
|
|
147
|
-
headers: {
|
|
148
|
-
'X-HTTP-Method': 'DELETE',
|
|
149
|
-
'If-Match': '*',
|
|
150
|
-
'accept': 'application/json;odata=nometadata'
|
|
151
|
-
},
|
|
152
|
-
responseType: 'json'
|
|
153
|
-
};
|
|
154
|
-
request_1.default.post(requestOptions)
|
|
155
|
-
.then(() => {
|
|
156
|
-
resolve();
|
|
157
|
-
})
|
|
158
|
-
.catch((err) => {
|
|
159
|
-
if (err.statusCode === 404) {
|
|
160
|
-
// file does not exist so can proceed
|
|
161
|
-
return resolve();
|
|
162
|
-
}
|
|
163
|
-
if (this.debug) {
|
|
164
|
-
logger.logToStderr(`recycleFile error...`);
|
|
165
|
-
logger.logToStderr(err);
|
|
166
|
-
}
|
|
167
|
-
reject(err);
|
|
168
|
-
});
|
|
169
|
-
}, (e) => reject(e));
|
|
155
|
+
}
|
|
170
156
|
});
|
|
171
157
|
}
|
|
172
158
|
}
|
|
@@ -16,12 +16,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
16
16
|
var _SpoFileMoveCommand_instances, _SpoFileMoveCommand_initTelemetry, _SpoFileMoveCommand_initOptions, _SpoFileMoveCommand_initValidators;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const url = require("url");
|
|
19
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
19
20
|
const request_1 = require("../../../../request");
|
|
20
21
|
const spo_1 = require("../../../../utils/spo");
|
|
21
22
|
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
22
23
|
const validation_1 = require("../../../../utils/validation");
|
|
23
24
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
24
25
|
const commands_1 = require("../../commands");
|
|
26
|
+
const removeCommand = require('./file-remove');
|
|
25
27
|
class SpoFileMoveCommand extends SpoCommand_1.default {
|
|
26
28
|
constructor() {
|
|
27
29
|
super();
|
|
@@ -124,49 +126,34 @@ class SpoFileMoveCommand extends SpoCommand_1.default {
|
|
|
124
126
|
* Moves file in the site recycle bin
|
|
125
127
|
*/
|
|
126
128
|
recycleFile(tenantUrl, targetUrl, filename, logger) {
|
|
127
|
-
return
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
130
|
const targetFolderAbsoluteUrl = urlUtil_1.urlUtil.urlCombine(tenantUrl, targetUrl);
|
|
129
131
|
// since the target WebFullUrl is unknown we can use getRequestDigest
|
|
130
132
|
// to get it from target folder absolute url.
|
|
131
133
|
// Similar approach used here Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect
|
|
132
|
-
spo_1.spo.getRequestDigest(targetFolderAbsoluteUrl)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
const contextResponse = yield spo_1.spo.getRequestDigest(targetFolderAbsoluteUrl);
|
|
135
|
+
if (this.debug) {
|
|
136
|
+
logger.logToStderr(`contextResponse.WebFullUrl: ${contextResponse.WebFullUrl}`);
|
|
137
|
+
}
|
|
138
|
+
const targetFileServerRelativeUrl = `${urlUtil_1.urlUtil.getServerRelativePath(contextResponse.WebFullUrl, targetUrl)}/${filename}`;
|
|
139
|
+
const removeOptions = {
|
|
140
|
+
webUrl: contextResponse.WebFullUrl,
|
|
141
|
+
url: targetFileServerRelativeUrl,
|
|
142
|
+
recycle: true,
|
|
143
|
+
confirm: true,
|
|
144
|
+
debug: this.debug,
|
|
145
|
+
verbose: this.verbose
|
|
146
|
+
};
|
|
147
|
+
try {
|
|
148
|
+
yield Cli_1.Cli.executeCommand(removeCommand, { options: Object.assign(Object.assign({}, removeOptions), { _: [] }) });
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
|
|
139
152
|
}
|
|
140
|
-
|
|
141
|
-
|
|
153
|
+
else {
|
|
154
|
+
throw err;
|
|
142
155
|
}
|
|
143
|
-
|
|
144
|
-
const requestOptions = {
|
|
145
|
-
url: requestUrl,
|
|
146
|
-
method: 'POST',
|
|
147
|
-
headers: {
|
|
148
|
-
'X-HTTP-Method': 'DELETE',
|
|
149
|
-
'If-Match': '*',
|
|
150
|
-
'accept': 'application/json;odata=nometadata'
|
|
151
|
-
},
|
|
152
|
-
responseType: 'json'
|
|
153
|
-
};
|
|
154
|
-
request_1.default.post(requestOptions)
|
|
155
|
-
.then(() => {
|
|
156
|
-
resolve();
|
|
157
|
-
})
|
|
158
|
-
.catch((err) => {
|
|
159
|
-
if (err.statusCode === 404) {
|
|
160
|
-
// file does not exist so can proceed
|
|
161
|
-
return resolve();
|
|
162
|
-
}
|
|
163
|
-
if (this.debug) {
|
|
164
|
-
logger.logToStderr(`recycleFile error...`);
|
|
165
|
-
logger.logToStderr(err);
|
|
166
|
-
}
|
|
167
|
-
reject(err);
|
|
168
|
-
});
|
|
169
|
-
}, (e) => reject(e));
|
|
156
|
+
}
|
|
170
157
|
});
|
|
171
158
|
}
|
|
172
159
|
}
|
|
@@ -79,23 +79,26 @@ class SpoFileRenameCommand extends SpoCommand_1.default {
|
|
|
79
79
|
return request_1.default.get(requestOptions);
|
|
80
80
|
}
|
|
81
81
|
deleteFile(webUrl, sourceUrl, targetFileName) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const targetFileServerRelativeUrl = `${urlUtil_1.urlUtil.getServerRelativePath(webUrl, sourceUrl.substring(0, sourceUrl.lastIndexOf('/')))}/${targetFileName}`;
|
|
84
|
+
const removeOptions = {
|
|
85
|
+
webUrl: webUrl,
|
|
86
|
+
url: targetFileServerRelativeUrl,
|
|
87
|
+
recycle: true,
|
|
88
|
+
confirm: true,
|
|
89
|
+
debug: this.debug,
|
|
90
|
+
verbose: this.verbose
|
|
91
|
+
};
|
|
92
|
+
try {
|
|
93
|
+
yield Cli_1.Cli.executeCommand(removeCommand, { options: Object.assign(Object.assign({}, removeOptions), { _: [] }) });
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
97
101
|
}
|
|
98
|
-
return Promise.reject(err);
|
|
99
102
|
});
|
|
100
103
|
}
|
|
101
104
|
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _SpoFileRoleAssignmentAddCommand_instances, _SpoFileRoleAssignmentAddCommand_initTelemetry, _SpoFileRoleAssignmentAddCommand_initOptions, _SpoFileRoleAssignmentAddCommand_initValidators, _SpoFileRoleAssignmentAddCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
19
|
+
const SpoUserGetCommand = require("../user/user-get");
|
|
20
|
+
const SpoGroupGetCommand = require("../group/group-get");
|
|
21
|
+
const SpoRoleDefinitionListCommand = require("../roledefinition/roledefinition-list");
|
|
22
|
+
const SpoFileGetCommand = require("./file-get");
|
|
23
|
+
const request_1 = require("../../../../request");
|
|
24
|
+
const validation_1 = require("../../../../utils/validation");
|
|
25
|
+
const formatting_1 = require("../../../../utils/formatting");
|
|
26
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
27
|
+
const commands_1 = require("../../commands");
|
|
28
|
+
class SpoFileRoleAssignmentAddCommand extends SpoCommand_1.default {
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
_SpoFileRoleAssignmentAddCommand_instances.add(this);
|
|
32
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initTelemetry).call(this);
|
|
33
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initOptions).call(this);
|
|
34
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initValidators).call(this);
|
|
35
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initOptionSets).call(this);
|
|
36
|
+
}
|
|
37
|
+
get name() {
|
|
38
|
+
return commands_1.default.FILE_ROLEASSIGNMENT_ADD;
|
|
39
|
+
}
|
|
40
|
+
get description() {
|
|
41
|
+
return 'Adds a role assignment to the specified file.';
|
|
42
|
+
}
|
|
43
|
+
commandAction(logger, args) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (this.verbose) {
|
|
46
|
+
logger.logToStderr(`Adding role assignment to file in site at ${args.options.webUrl}...`);
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const fileUrl = yield this.getFileURL(args);
|
|
50
|
+
const roleDefinitionId = yield this.getRoleDefinitionId(args.options);
|
|
51
|
+
if (args.options.upn) {
|
|
52
|
+
const upnPrincipalId = yield this.getUserPrincipalId(args.options);
|
|
53
|
+
yield this.addRoleAssignment(fileUrl, args.options.webUrl, upnPrincipalId, roleDefinitionId);
|
|
54
|
+
}
|
|
55
|
+
else if (args.options.groupName) {
|
|
56
|
+
const groupPrincipalId = yield this.getGroupPrincipalId(args.options);
|
|
57
|
+
yield this.addRoleAssignment(fileUrl, args.options.webUrl, groupPrincipalId, roleDefinitionId);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
yield this.addRoleAssignment(fileUrl, args.options.webUrl, args.options.principalId, roleDefinitionId);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
this.handleRejectedODataJsonPromise(err);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
addRoleAssignment(fileUrl, webUrl, principalId, roleDefinitionId) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
try {
|
|
71
|
+
const requestOptions = {
|
|
72
|
+
url: `${webUrl}/_api/web/GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(fileUrl)}')/ListItemAllFields/roleassignments/addroleassignment(principalid='${principalId}',roledefid='${roleDefinitionId}')`,
|
|
73
|
+
method: 'POST',
|
|
74
|
+
headers: {
|
|
75
|
+
'accept': 'application/json;odata=nometadata',
|
|
76
|
+
'content-type': 'application/json'
|
|
77
|
+
},
|
|
78
|
+
responseType: 'json'
|
|
79
|
+
};
|
|
80
|
+
yield request_1.default.post(requestOptions);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
return Promise.reject(err);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
getRoleDefinitionId(options) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
if (!options.roleDefinitionName) {
|
|
90
|
+
return options.roleDefinitionId;
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const roleDefinitionListCommandOptions = {
|
|
94
|
+
webUrl: options.webUrl,
|
|
95
|
+
output: 'json',
|
|
96
|
+
debug: this.debug,
|
|
97
|
+
verbose: this.verbose
|
|
98
|
+
};
|
|
99
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoRoleDefinitionListCommand, { options: Object.assign(Object.assign({}, roleDefinitionListCommandOptions), { _: [] }) });
|
|
100
|
+
const getRoleDefinitionListOutput = JSON.parse(output.stdout);
|
|
101
|
+
const roleDefinitionId = getRoleDefinitionListOutput.find((role) => role.Name === options.roleDefinitionName).Id;
|
|
102
|
+
return roleDefinitionId;
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
return Promise.reject(err);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
getGroupPrincipalId(options) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
try {
|
|
112
|
+
const groupGetCommandOptions = {
|
|
113
|
+
webUrl: options.webUrl,
|
|
114
|
+
name: options.groupName,
|
|
115
|
+
output: 'json',
|
|
116
|
+
debug: this.debug,
|
|
117
|
+
verbose: this.verbose
|
|
118
|
+
};
|
|
119
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) });
|
|
120
|
+
const getGroupOutput = JSON.parse(output.stdout);
|
|
121
|
+
return getGroupOutput.Id;
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
return Promise.reject(err);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
getUserPrincipalId(options) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
try {
|
|
131
|
+
const userGetCommandOptions = {
|
|
132
|
+
webUrl: options.webUrl,
|
|
133
|
+
email: options.upn,
|
|
134
|
+
id: undefined,
|
|
135
|
+
output: 'json',
|
|
136
|
+
debug: this.debug,
|
|
137
|
+
verbose: this.verbose
|
|
138
|
+
};
|
|
139
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) });
|
|
140
|
+
const getUserOutput = JSON.parse(output.stdout);
|
|
141
|
+
return getUserOutput.Id;
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
return Promise.reject(err);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
getFileURL(args) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
if (args.options.fileUrl) {
|
|
151
|
+
return args.options.fileUrl;
|
|
152
|
+
}
|
|
153
|
+
const options = {
|
|
154
|
+
webUrl: args.options.webUrl,
|
|
155
|
+
id: args.options.fileId,
|
|
156
|
+
output: 'json',
|
|
157
|
+
debug: this.debug,
|
|
158
|
+
verbose: this.verbose
|
|
159
|
+
};
|
|
160
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoFileGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
161
|
+
const getFileOutput = JSON.parse(output.stdout);
|
|
162
|
+
return getFileOutput.ServerRelativeUrl;
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
_SpoFileRoleAssignmentAddCommand_instances = new WeakSet(), _SpoFileRoleAssignmentAddCommand_initTelemetry = function _SpoFileRoleAssignmentAddCommand_initTelemetry() {
|
|
167
|
+
this.telemetry.push((args) => {
|
|
168
|
+
Object.assign(this.telemetryProperties, {
|
|
169
|
+
fileUrl: typeof args.options.fileUrl !== 'undefined',
|
|
170
|
+
fileId: typeof args.options.fileId !== 'undefined',
|
|
171
|
+
principalId: typeof args.options.principalId !== 'undefined',
|
|
172
|
+
upn: typeof args.options.upn !== 'undefined',
|
|
173
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
174
|
+
roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
|
|
175
|
+
roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}, _SpoFileRoleAssignmentAddCommand_initOptions = function _SpoFileRoleAssignmentAddCommand_initOptions() {
|
|
179
|
+
this.options.unshift({
|
|
180
|
+
option: '-u, --webUrl <webUrl>'
|
|
181
|
+
}, {
|
|
182
|
+
option: '--fileUrl [fileUrl]'
|
|
183
|
+
}, {
|
|
184
|
+
option: 'i, --fileId [fileId]'
|
|
185
|
+
}, {
|
|
186
|
+
option: '--principalId [principalId]'
|
|
187
|
+
}, {
|
|
188
|
+
option: '--upn [upn]'
|
|
189
|
+
}, {
|
|
190
|
+
option: '--groupName [groupName]'
|
|
191
|
+
}, {
|
|
192
|
+
option: '--roleDefinitionId [roleDefinitionId]'
|
|
193
|
+
}, {
|
|
194
|
+
option: '--roleDefinitionName [roleDefinitionName]'
|
|
195
|
+
});
|
|
196
|
+
}, _SpoFileRoleAssignmentAddCommand_initValidators = function _SpoFileRoleAssignmentAddCommand_initValidators() {
|
|
197
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
199
|
+
if (isValidSharePointUrl !== true) {
|
|
200
|
+
return isValidSharePointUrl;
|
|
201
|
+
}
|
|
202
|
+
if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
|
|
203
|
+
return `${args.options.fileId} is not a valid GUID`;
|
|
204
|
+
}
|
|
205
|
+
if (args.options.principalId && isNaN(args.options.principalId)) {
|
|
206
|
+
return `Specified principalId ${args.options.principalId} is not a number`;
|
|
207
|
+
}
|
|
208
|
+
if (args.options.roleDefinitionId && isNaN(args.options.roleDefinitionId)) {
|
|
209
|
+
return `Specified roleDefinitionId ${args.options.roleDefinitionId} is not a number`;
|
|
210
|
+
}
|
|
211
|
+
const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
|
|
212
|
+
if (!principalOptions.some(item => item !== undefined)) {
|
|
213
|
+
return `Specify either principalId, upn or groupName`;
|
|
214
|
+
}
|
|
215
|
+
if (principalOptions.filter(item => item !== undefined).length > 1) {
|
|
216
|
+
return `Specify either principalId, upn or groupName but not multiple`;
|
|
217
|
+
}
|
|
218
|
+
const roleDefinitionOptions = [args.options.roleDefinitionId, args.options.roleDefinitionName];
|
|
219
|
+
if (!roleDefinitionOptions.some(item => item !== undefined)) {
|
|
220
|
+
return `Specify either roleDefinitionId or roleDefinitionName`;
|
|
221
|
+
}
|
|
222
|
+
if (roleDefinitionOptions.filter(item => item !== undefined).length > 1) {
|
|
223
|
+
return `Specify either roleDefinitionId or roleDefinitionName but not multiple`;
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
226
|
+
}));
|
|
227
|
+
}, _SpoFileRoleAssignmentAddCommand_initOptionSets = function _SpoFileRoleAssignmentAddCommand_initOptionSets() {
|
|
228
|
+
this.optionSets.push(['fileId', 'fileUrl']);
|
|
229
|
+
};
|
|
230
|
+
module.exports = new SpoFileRoleAssignmentAddCommand();
|
|
231
|
+
//# sourceMappingURL=file-roleassignment-add.js.map
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _SpoFileRoleAssignmentRemoveCommand_instances, _SpoFileRoleAssignmentRemoveCommand_initTelemetry, _SpoFileRoleAssignmentRemoveCommand_initOptions, _SpoFileRoleAssignmentRemoveCommand_initValidators, _SpoFileRoleAssignmentRemoveCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
19
|
+
const request_1 = require("../../../../request");
|
|
20
|
+
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
21
|
+
const formatting_1 = require("../../../../utils/formatting");
|
|
22
|
+
const validation_1 = require("../../../../utils/validation");
|
|
23
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
24
|
+
const commands_1 = require("../../commands");
|
|
25
|
+
const SpoFileGetCommand = require("./file-get");
|
|
26
|
+
const SpoUserGetCommand = require("../user/user-get");
|
|
27
|
+
const SpoGroupGetCommand = require("../group/group-get");
|
|
28
|
+
class SpoFileRoleAssignmentRemoveCommand extends SpoCommand_1.default {
|
|
29
|
+
constructor() {
|
|
30
|
+
super();
|
|
31
|
+
_SpoFileRoleAssignmentRemoveCommand_instances.add(this);
|
|
32
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentRemoveCommand_instances, "m", _SpoFileRoleAssignmentRemoveCommand_initTelemetry).call(this);
|
|
33
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentRemoveCommand_instances, "m", _SpoFileRoleAssignmentRemoveCommand_initOptions).call(this);
|
|
34
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentRemoveCommand_instances, "m", _SpoFileRoleAssignmentRemoveCommand_initValidators).call(this);
|
|
35
|
+
__classPrivateFieldGet(this, _SpoFileRoleAssignmentRemoveCommand_instances, "m", _SpoFileRoleAssignmentRemoveCommand_initOptionSets).call(this);
|
|
36
|
+
}
|
|
37
|
+
get name() {
|
|
38
|
+
return commands_1.default.FILE_ROLEASSIGNMENT_REMOVE;
|
|
39
|
+
}
|
|
40
|
+
get description() {
|
|
41
|
+
return 'Removes a role assignment from a file.';
|
|
42
|
+
}
|
|
43
|
+
commandAction(logger, args) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
const removeRoleAssignment = () => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
const fileURL = yield this.getFileURL(args);
|
|
48
|
+
let principalId;
|
|
49
|
+
if (args.options.groupName) {
|
|
50
|
+
principalId = yield this.getGroupPrincipalId(args.options);
|
|
51
|
+
}
|
|
52
|
+
else if (args.options.upn) {
|
|
53
|
+
principalId = yield this.getUserPrincipalId(args.options);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
principalId = args.options.principalId;
|
|
57
|
+
}
|
|
58
|
+
const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, fileURL);
|
|
59
|
+
const requestOptions = {
|
|
60
|
+
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(serverRelativeUrl)}')/ListItemAllFields/roleassignments/removeroleassignment(principalid='${principalId}')`,
|
|
61
|
+
headers: {
|
|
62
|
+
accept: 'application/json;odata=nometadata'
|
|
63
|
+
},
|
|
64
|
+
responseType: 'json'
|
|
65
|
+
};
|
|
66
|
+
yield request_1.default.post(requestOptions);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
this.handleRejectedODataJsonPromise(err);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (args.options.confirm) {
|
|
73
|
+
yield removeRoleAssignment();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const result = yield Cli_1.Cli.prompt({
|
|
77
|
+
type: 'confirm',
|
|
78
|
+
name: 'continue',
|
|
79
|
+
default: false,
|
|
80
|
+
message: `Are you sure you want to remove role assignment from file ${args.options.fileUrl || args.options.fileId} from site ${args.options.webUrl}?`
|
|
81
|
+
});
|
|
82
|
+
if (result.continue) {
|
|
83
|
+
yield removeRoleAssignment();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
getFileURL(args) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
if (args.options.fileUrl) {
|
|
91
|
+
return args.options.fileUrl;
|
|
92
|
+
}
|
|
93
|
+
const options = {
|
|
94
|
+
webUrl: args.options.webUrl,
|
|
95
|
+
id: args.options.fileId,
|
|
96
|
+
output: 'json',
|
|
97
|
+
debug: this.debug,
|
|
98
|
+
verbose: this.verbose
|
|
99
|
+
};
|
|
100
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoFileGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
101
|
+
const getFileOutput = JSON.parse(output.stdout);
|
|
102
|
+
return getFileOutput.ServerRelativeUrl;
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
getUserPrincipalId(options) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const userGetCommandOptions = {
|
|
108
|
+
webUrl: options.webUrl,
|
|
109
|
+
email: options.upn,
|
|
110
|
+
id: undefined,
|
|
111
|
+
output: 'json',
|
|
112
|
+
debug: this.debug,
|
|
113
|
+
verbose: this.verbose
|
|
114
|
+
};
|
|
115
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) });
|
|
116
|
+
const getUserOutput = JSON.parse(output.stdout);
|
|
117
|
+
return getUserOutput.Id;
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
getGroupPrincipalId(options) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const groupGetCommandOptions = {
|
|
123
|
+
webUrl: options.webUrl,
|
|
124
|
+
name: options.groupName,
|
|
125
|
+
output: 'json',
|
|
126
|
+
debug: this.debug,
|
|
127
|
+
verbose: this.verbose
|
|
128
|
+
};
|
|
129
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) });
|
|
130
|
+
const getGroupOutput = JSON.parse(output.stdout);
|
|
131
|
+
return getGroupOutput.Id;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
_SpoFileRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFileRoleAssignmentRemoveCommand_initTelemetry = function _SpoFileRoleAssignmentRemoveCommand_initTelemetry() {
|
|
136
|
+
this.telemetry.push((args) => {
|
|
137
|
+
Object.assign(this.telemetryProperties, {
|
|
138
|
+
fileUrl: typeof args.options.fileUrl !== 'undefined',
|
|
139
|
+
fileId: typeof args.options.fileId !== 'undefined',
|
|
140
|
+
principalId: typeof args.options.principalId !== 'undefined',
|
|
141
|
+
upn: typeof args.options.upn !== 'undefined',
|
|
142
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
143
|
+
confirm: !!args.options.confirm
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}, _SpoFileRoleAssignmentRemoveCommand_initOptions = function _SpoFileRoleAssignmentRemoveCommand_initOptions() {
|
|
147
|
+
this.options.unshift({
|
|
148
|
+
option: '-u, --webUrl <webUrl>'
|
|
149
|
+
}, {
|
|
150
|
+
option: '--fileUrl [fileUrl]'
|
|
151
|
+
}, {
|
|
152
|
+
option: '-i, --fileId [fileId]'
|
|
153
|
+
}, {
|
|
154
|
+
option: '--principalId [principalId]'
|
|
155
|
+
}, {
|
|
156
|
+
option: '--upn [upn]'
|
|
157
|
+
}, {
|
|
158
|
+
option: '--groupName [groupName]'
|
|
159
|
+
}, {
|
|
160
|
+
option: '--confirm'
|
|
161
|
+
});
|
|
162
|
+
}, _SpoFileRoleAssignmentRemoveCommand_initValidators = function _SpoFileRoleAssignmentRemoveCommand_initValidators() {
|
|
163
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
165
|
+
if (isValidSharePointUrl !== true) {
|
|
166
|
+
return isValidSharePointUrl;
|
|
167
|
+
}
|
|
168
|
+
if (args.options.principalId && isNaN(args.options.principalId)) {
|
|
169
|
+
return `Specified principalId ${args.options.principalId} is not a number`;
|
|
170
|
+
}
|
|
171
|
+
if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
|
|
172
|
+
return `${args.options.fileId} is not a valid GUID`;
|
|
173
|
+
}
|
|
174
|
+
return true;
|
|
175
|
+
}));
|
|
176
|
+
}, _SpoFileRoleAssignmentRemoveCommand_initOptionSets = function _SpoFileRoleAssignmentRemoveCommand_initOptionSets() {
|
|
177
|
+
this.optionSets.push(['fileUrl', 'fileId'], ['upn', 'groupName', 'principalId']);
|
|
178
|
+
};
|
|
179
|
+
module.exports = new SpoFileRoleAssignmentRemoveCommand();
|
|
180
|
+
//# sourceMappingURL=file-roleassignment-remove.js.map
|
|
@@ -45,7 +45,7 @@ class SpoFileRoleInheritanceResetCommand extends SpoCommand_1.default {
|
|
|
45
45
|
const requestOptions = {
|
|
46
46
|
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(fileURL)}')/ListItemAllFields/resetroleinheritance`,
|
|
47
47
|
headers: {
|
|
48
|
-
accept: 'application/json;odata
|
|
48
|
+
accept: 'application/json;odata=nometadata'
|
|
49
49
|
},
|
|
50
50
|
responseType: 'json'
|
|
51
51
|
};
|