@pnp/cli-microsoft365 5.9.0-beta.86c5624 → 5.9.0-beta.a3284ab
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 +4 -2
- package/dist/m365/aad/commands/app/app-add.js +37 -13
- package/dist/m365/outlook/commands/mail/mail-send.js +55 -31
- package/dist/m365/planner/commands/bucket/bucket-get.js +1 -1
- package/dist/m365/pp/commands/Environment.js +3 -0
- package/dist/m365/pp/commands/card/card-get.js +110 -0
- package/dist/m365/pp/commands/card/card-list.js +68 -0
- package/dist/m365/pp/commands/dataverse/dataverse-table-list.js +6 -12
- package/dist/m365/pp/commands/environment/environment-get.js +75 -0
- package/dist/m365/pp/commands/gateway/gateway-get.js +70 -0
- package/dist/m365/pp/commands/solution/solution-get.js +117 -0
- package/dist/m365/pp/commands.js +5 -0
- package/dist/m365/spo/commands/contenttype/contenttype-add.js +82 -43
- package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +53 -21
- package/dist/m365/spo/commands/contenttype/contenttype-get.js +35 -14
- package/dist/m365/spo/commands/file/file-roleinheritance-break.js +129 -0
- package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +168 -0
- package/dist/m365/spo/commands/list/list-contenttype-add.js +21 -18
- package/dist/m365/spo/commands/list/list-contenttype-default-set.js +59 -47
- package/dist/m365/spo/commands/list/list-contenttype-list.js +16 -8
- package/dist/m365/spo/commands/list/list-contenttype-remove.js +16 -8
- package/dist/m365/spo/commands/list/list-roleinheritance-break.js +14 -6
- package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +15 -7
- package/dist/m365/spo/commands/list/list-webhook-add.js +19 -11
- package/dist/m365/spo/commands/list/list-webhook-get.js +17 -9
- package/dist/m365/spo/commands/list/list-webhook-list.js +23 -24
- package/dist/m365/spo/commands/list/list-webhook-remove.js +19 -11
- package/dist/m365/spo/commands/list/list-webhook-set.js +18 -10
- package/dist/m365/spo/commands.js +2 -0
- package/dist/m365/teams/commands/channel/channel-add.js +9 -9
- package/dist/m365/todo/commands/task/task-add.js +55 -3
- package/dist/m365/todo/commands/task/task-set.js +53 -1
- package/docs/docs/_clisettings.md +19 -0
- package/docs/docs/cmd/outlook/mail/mail-send.md +13 -0
- package/docs/docs/cmd/pp/card/card-get.md +51 -0
- package/docs/docs/cmd/pp/card/card-list.md +33 -0
- package/docs/docs/cmd/pp/environment/environment-get.md +38 -0
- package/docs/docs/cmd/pp/gateway/gateway-get.md +24 -0
- package/docs/docs/cmd/pp/solution/solution-get.md +51 -0
- package/docs/docs/cmd/spo/contenttype/contenttype-add.md +20 -2
- package/docs/docs/cmd/spo/contenttype/contenttype-field-remove.md +22 -4
- package/docs/docs/cmd/spo/contenttype/contenttype-get.md +21 -3
- package/docs/docs/cmd/spo/eventreceiver/eventreceiver-get.md +2 -2
- package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.md +2 -2
- package/docs/docs/cmd/spo/file/file-roleinheritance-break.md +54 -0
- package/docs/docs/cmd/spo/folder/folder-roleassignment-remove.md +57 -0
- package/docs/docs/cmd/spo/list/list-contenttype-add.md +16 -7
- package/docs/docs/cmd/spo/list/list-contenttype-default-set.md +16 -7
- package/docs/docs/cmd/spo/list/list-contenttype-list.md +15 -6
- package/docs/docs/cmd/spo/list/list-contenttype-remove.md +17 -8
- package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +11 -8
- package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +14 -5
- package/docs/docs/cmd/spo/list/list-webhook-add.md +15 -16
- package/docs/docs/cmd/spo/list/list-webhook-get.md +15 -6
- package/docs/docs/cmd/spo/list/list-webhook-list.md +16 -7
- package/docs/docs/cmd/spo/list/list-webhook-remove.md +12 -10
- package/docs/docs/cmd/spo/list/list-webhook-set.md +13 -11
- package/docs/docs/cmd/teams/channel/channel-add.md +4 -4
- package/docs/docs/cmd/todo/task/task-add.md +32 -5
- package/docs/docs/cmd/todo/task/task-set.md +29 -2
- package/package.json +6 -1
|
@@ -0,0 +1,117 @@
|
|
|
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 _PpSolutionGetCommand_instances, _PpSolutionGetCommand_initTelemetry, _PpSolutionGetCommand_initOptions, _PpSolutionGetCommand_initOptionSets, _PpSolutionGetCommand_initValidators;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const request_1 = require("../../../../request");
|
|
19
|
+
const powerPlatform_1 = require("../../../../utils/powerPlatform");
|
|
20
|
+
const validation_1 = require("../../../../utils/validation");
|
|
21
|
+
const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
|
|
22
|
+
const commands_1 = require("../../commands");
|
|
23
|
+
class PpSolutionGetCommand extends PowerPlatformCommand_1.default {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
_PpSolutionGetCommand_instances.add(this);
|
|
27
|
+
__classPrivateFieldGet(this, _PpSolutionGetCommand_instances, "m", _PpSolutionGetCommand_initTelemetry).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _PpSolutionGetCommand_instances, "m", _PpSolutionGetCommand_initOptions).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _PpSolutionGetCommand_instances, "m", _PpSolutionGetCommand_initValidators).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _PpSolutionGetCommand_instances, "m", _PpSolutionGetCommand_initOptionSets).call(this);
|
|
31
|
+
}
|
|
32
|
+
get name() {
|
|
33
|
+
return commands_1.default.SOLUTION_GET;
|
|
34
|
+
}
|
|
35
|
+
get description() {
|
|
36
|
+
return 'Gets a specific solution in a given environment.';
|
|
37
|
+
}
|
|
38
|
+
defaultProperties() {
|
|
39
|
+
return ['uniquename', 'version', 'publisher'];
|
|
40
|
+
}
|
|
41
|
+
commandAction(logger, args) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (this.verbose) {
|
|
44
|
+
logger.logToStderr(`Retrieving a specific solution '${args.options.id || args.options.name}'...`);
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
|
|
48
|
+
const res = yield this.getSolution(dynamicsApiUrl, args.options);
|
|
49
|
+
if (!args.options.output || args.options.output === 'json') {
|
|
50
|
+
logger.log(res);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Converted to text friendly output
|
|
54
|
+
logger.log({
|
|
55
|
+
uniquename: res.uniquename,
|
|
56
|
+
version: res.version,
|
|
57
|
+
publisher: res.publisherid.friendlyname
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.handleRejectedODataJsonPromise(err);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
getSolution(dynamicsApiUrl, options) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const requestOptions = {
|
|
69
|
+
headers: {
|
|
70
|
+
accept: 'application/json;odata.metadata=none'
|
|
71
|
+
},
|
|
72
|
+
responseType: 'json'
|
|
73
|
+
};
|
|
74
|
+
if (options.id) {
|
|
75
|
+
requestOptions.url = `${dynamicsApiUrl}/api/data/v9.0/solutions(${options.id})?$expand=publisherid($select=friendlyname)&$select=solutionid,uniquename,version,publisherid,installedon,solutionpackageversion,friendlyname,versionnumber&api-version=9.1`;
|
|
76
|
+
const result = yield request_1.default.get(requestOptions);
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
requestOptions.url = `${dynamicsApiUrl}/api/data/v9.0/solutions?$filter=isvisible eq true and uniquename eq \'${options.name}\'&$expand=publisherid($select=friendlyname)&$select=solutionid,uniquename,version,publisherid,installedon,solutionpackageversion,friendlyname,versionnumber&api-version=9.1`;
|
|
80
|
+
const result = yield request_1.default.get(requestOptions);
|
|
81
|
+
if (result.value.length === 0) {
|
|
82
|
+
throw `The specified solution '${options.name}' does not exist.`;
|
|
83
|
+
}
|
|
84
|
+
return result.value[0];
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
_PpSolutionGetCommand_instances = new WeakSet(), _PpSolutionGetCommand_initTelemetry = function _PpSolutionGetCommand_initTelemetry() {
|
|
89
|
+
this.telemetry.push((args) => {
|
|
90
|
+
Object.assign(this.telemetryProperties, {
|
|
91
|
+
id: typeof args.options.id !== 'undefined',
|
|
92
|
+
name: typeof args.options.name !== 'undefined',
|
|
93
|
+
asAdmin: !!args.options.asAdmin
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}, _PpSolutionGetCommand_initOptions = function _PpSolutionGetCommand_initOptions() {
|
|
97
|
+
this.options.unshift({
|
|
98
|
+
option: '-e, --environment <environment>'
|
|
99
|
+
}, {
|
|
100
|
+
option: '-i, --id [id]'
|
|
101
|
+
}, {
|
|
102
|
+
option: '-n, --name [name]'
|
|
103
|
+
}, {
|
|
104
|
+
option: '-a, --asAdmin'
|
|
105
|
+
});
|
|
106
|
+
}, _PpSolutionGetCommand_initOptionSets = function _PpSolutionGetCommand_initOptionSets() {
|
|
107
|
+
this.optionSets.push(['id', 'name']);
|
|
108
|
+
}, _PpSolutionGetCommand_initValidators = function _PpSolutionGetCommand_initValidators() {
|
|
109
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
|
|
111
|
+
return `${args.options.id} is not a valid GUID`;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}));
|
|
115
|
+
};
|
|
116
|
+
module.exports = new PpSolutionGetCommand();
|
|
117
|
+
//# sourceMappingURL=solution-get.js.map
|
package/dist/m365/pp/commands.js
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const prefix = 'pp';
|
|
4
4
|
exports.default = {
|
|
5
|
+
CARD_GET: `${prefix} card get`,
|
|
6
|
+
CARD_LIST: `${prefix} card list`,
|
|
5
7
|
DATAVERSE_TABLE_LIST: `${prefix} dataverse table list`,
|
|
8
|
+
ENVIRONMENT_GET: `${prefix} environment get`,
|
|
6
9
|
ENVIRONMENT_LIST: `${prefix} environment list`,
|
|
10
|
+
GATEWAY_GET: `${prefix} gateway get`,
|
|
7
11
|
GATEWAY_LIST: `${prefix} gateway list`,
|
|
8
12
|
MANAGEMENTAPP_ADD: `${prefix} managementapp add`,
|
|
9
13
|
MANAGEMENTAPP_LIST: `${prefix} managementapp list`,
|
|
14
|
+
SOLUTION_GET: `${prefix} solution get`,
|
|
10
15
|
SOLUTION_LIST: `${prefix} solution list`,
|
|
11
16
|
TENANT_SETTINGS_LIST: `${prefix} tenant settings list`
|
|
12
17
|
};
|
|
@@ -20,6 +20,7 @@ const config_1 = require("../../../../config");
|
|
|
20
20
|
const request_1 = require("../../../../request");
|
|
21
21
|
const formatting_1 = require("../../../../utils/formatting");
|
|
22
22
|
const spo_1 = require("../../../../utils/spo");
|
|
23
|
+
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
23
24
|
const validation_1 = require("../../../../utils/validation");
|
|
24
25
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
25
26
|
const commands_1 = require("../../commands");
|
|
@@ -42,7 +43,13 @@ class SpoContentTypeAddCommand extends SpoCommand_1.default {
|
|
|
42
43
|
commandAction(logger, args) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
45
|
try {
|
|
45
|
-
|
|
46
|
+
let parentInfo = '';
|
|
47
|
+
if (!args.options.listId && !args.options.listTitle && !args.options.listUrl) {
|
|
48
|
+
parentInfo = '<Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" />';
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
parentInfo = yield this.getParentInfo(args.options, logger);
|
|
52
|
+
}
|
|
46
53
|
if (this.verbose) {
|
|
47
54
|
logger.logToStderr(`Retrieving request digest...`);
|
|
48
55
|
}
|
|
@@ -69,6 +76,8 @@ class SpoContentTypeAddCommand extends SpoCommand_1.default {
|
|
|
69
76
|
const options = {
|
|
70
77
|
webUrl: args.options.webUrl,
|
|
71
78
|
listTitle: args.options.listTitle,
|
|
79
|
+
listUrl: args.options.listUrl,
|
|
80
|
+
listId: args.options.listId,
|
|
72
81
|
id: args.options.id,
|
|
73
82
|
output: 'json',
|
|
74
83
|
debug: this.debug,
|
|
@@ -90,60 +99,79 @@ class SpoContentTypeAddCommand extends SpoCommand_1.default {
|
|
|
90
99
|
}
|
|
91
100
|
});
|
|
92
101
|
}
|
|
93
|
-
getParentInfo(
|
|
94
|
-
return
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
getParentInfo(options, logger) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const siteId = yield this.getSiteId(options.webUrl, logger);
|
|
105
|
+
const webId = yield this.getWebId(options.webUrl, logger);
|
|
106
|
+
const listId = yield this.getListId(options, logger);
|
|
107
|
+
return `<Identity Id="5" Name="1a48869e-c092-0000-1f61-81ec89809537|740c6a0b-85e2-48a0-a494-e0f1759d4aa7:site:${siteId}:web:${webId}:list:${listId}" />`;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
getSiteId(webUrl, logger) {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
if (this.verbose) {
|
|
113
|
+
logger.logToStderr(`Retrieving site collection id...`);
|
|
98
114
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
const requestOptions = {
|
|
116
|
+
url: `${webUrl}/_api/site?$select=Id`,
|
|
117
|
+
headers: {
|
|
118
|
+
accept: 'application/json;odata=nometadata'
|
|
119
|
+
},
|
|
120
|
+
responseType: 'json'
|
|
121
|
+
};
|
|
122
|
+
const siteResponse = yield request_1.default.get(requestOptions);
|
|
123
|
+
return siteResponse.Id;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
getWebId(webUrl, logger) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
if (this.verbose) {
|
|
129
|
+
logger.logToStderr(`Retrieving web id...`);
|
|
130
|
+
}
|
|
131
|
+
const requestOptions = {
|
|
132
|
+
url: `${webUrl}/_api/web?$select=Id`,
|
|
133
|
+
headers: {
|
|
134
|
+
accept: 'application/json;odata=nometadata'
|
|
135
|
+
},
|
|
136
|
+
responseType: 'json'
|
|
137
|
+
};
|
|
138
|
+
const webResponse = yield request_1.default.get(requestOptions);
|
|
139
|
+
return webResponse.Id;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
getListId(options, logger) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
if (this.verbose) {
|
|
145
|
+
logger.logToStderr(`Retrieving list id...`);
|
|
146
|
+
}
|
|
147
|
+
let listId = '';
|
|
148
|
+
if (options.listId) {
|
|
149
|
+
return options.listId;
|
|
150
|
+
}
|
|
151
|
+
else if (options.listTitle) {
|
|
119
152
|
const requestOptions = {
|
|
120
|
-
url: `${webUrl}/_api/web?$select=Id`,
|
|
153
|
+
url: `${options.webUrl}/_api/web/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(options.listTitle)}')?$select=Id`,
|
|
121
154
|
headers: {
|
|
122
155
|
accept: 'application/json;odata=nometadata'
|
|
123
156
|
},
|
|
124
157
|
responseType: 'json'
|
|
125
158
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
logger.logToStderr(`Retrieving list id...`);
|
|
132
|
-
}
|
|
159
|
+
const listResponse = yield request_1.default.get(requestOptions);
|
|
160
|
+
listId = listResponse.Id;
|
|
161
|
+
}
|
|
162
|
+
else if (options.listUrl) {
|
|
163
|
+
const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
|
|
133
164
|
const requestOptions = {
|
|
134
|
-
url: `${webUrl}/_api/web/
|
|
165
|
+
url: `${options.webUrl}/_api/web/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')?$select=Id`,
|
|
135
166
|
headers: {
|
|
136
167
|
accept: 'application/json;odata=nometadata'
|
|
137
168
|
},
|
|
138
169
|
responseType: 'json'
|
|
139
170
|
};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}, (error) => {
|
|
145
|
-
reject(error);
|
|
146
|
-
});
|
|
171
|
+
const listResponse = yield request_1.default.get(requestOptions);
|
|
172
|
+
listId = listResponse.Id;
|
|
173
|
+
}
|
|
174
|
+
return listId;
|
|
147
175
|
});
|
|
148
176
|
}
|
|
149
177
|
}
|
|
@@ -160,6 +188,10 @@ _SpoContentTypeAddCommand_instances = new WeakSet(), _SpoContentTypeAddCommand_i
|
|
|
160
188
|
option: '-u, --webUrl <webUrl>'
|
|
161
189
|
}, {
|
|
162
190
|
option: '-l, --listTitle [listTitle]'
|
|
191
|
+
}, {
|
|
192
|
+
option: '--listId [listId]'
|
|
193
|
+
}, {
|
|
194
|
+
option: '--listUrl [listUrl]'
|
|
163
195
|
}, {
|
|
164
196
|
option: '-i, --id <id>'
|
|
165
197
|
}, {
|
|
@@ -170,7 +202,14 @@ _SpoContentTypeAddCommand_instances = new WeakSet(), _SpoContentTypeAddCommand_i
|
|
|
170
202
|
option: '-g, --group [group]'
|
|
171
203
|
});
|
|
172
204
|
}, _SpoContentTypeAddCommand_initValidators = function _SpoContentTypeAddCommand_initValidators() {
|
|
173
|
-
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
205
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
if (args.options.listId) {
|
|
207
|
+
if (!validation_1.validation.isValidGuid(args.options.listId)) {
|
|
208
|
+
return `${args.options.listId} is not a valid GUID`;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
212
|
+
}));
|
|
174
213
|
}, _SpoContentTypeAddCommand_initTypes = function _SpoContentTypeAddCommand_initTypes() {
|
|
175
214
|
this.types.string.push('id', 'i');
|
|
176
215
|
};
|
|
@@ -19,6 +19,7 @@ const Cli_1 = require("../../../../cli/Cli");
|
|
|
19
19
|
const request_1 = require("../../../../request");
|
|
20
20
|
const formatting_1 = require("../../../../utils/formatting");
|
|
21
21
|
const spo_1 = require("../../../../utils/spo");
|
|
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");
|
|
@@ -72,30 +73,25 @@ class SpoContentTypeFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
72
73
|
logger.logToStderr(`WebId: ${webId}`);
|
|
73
74
|
}
|
|
74
75
|
let listId = undefined;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
listId = list.Id;
|
|
87
|
-
if (this.debug) {
|
|
88
|
-
logger.logToStderr(`ListId: ${listId}`);
|
|
89
|
-
}
|
|
76
|
+
if (args.options.listId) {
|
|
77
|
+
listId = args.options.listId;
|
|
78
|
+
}
|
|
79
|
+
else if (args.options.listTitle) {
|
|
80
|
+
listId = yield this.getListIdFromListTitle(args.options.webUrl, args.options.listTitle);
|
|
81
|
+
}
|
|
82
|
+
else if (args.options.listUrl) {
|
|
83
|
+
listId = yield this.getListIdFromListUrl(args.options.webUrl, args.options.listUrl);
|
|
84
|
+
}
|
|
85
|
+
if (this.debug) {
|
|
86
|
+
logger.logToStderr(`ListId: ${listId}`);
|
|
90
87
|
}
|
|
91
88
|
const reqDigest = yield spo_1.spo.getRequestDigest(args.options.webUrl);
|
|
92
89
|
const requestDigest = reqDigest.FormDigestValue;
|
|
93
|
-
const updateChildContentTypes = args.options.listTitle ? false : args.options.updateChildContentTypes === true;
|
|
90
|
+
const updateChildContentTypes = args.options.listTitle || args.options.listId || args.options.listUrl ? false : args.options.updateChildContentTypes === true;
|
|
94
91
|
if (this.debug) {
|
|
95
|
-
const additionalLog = args.options.listTitle ? `; ListTitle='${args.options.listTitle}'` : ` ; UpdateChildContentTypes='${updateChildContentTypes}`;
|
|
92
|
+
const additionalLog = args.options.listTitle ? `; ListTitle='${args.options.listTitle}'` : args.options.listId ? `; ListId='${args.options.listId}'` : args.options.listUrl ? `; ListUrl='${args.options.listUrl}'` : ` ; UpdateChildContentTypes='${updateChildContentTypes}`;
|
|
96
93
|
logger.logToStderr(`Remove FieldLink from ContentType. FieldLinkId='${args.options.fieldLinkId}' ; ContentTypeId='${args.options.contentTypeId}' ${additionalLog}`);
|
|
97
94
|
logger.logToStderr(`Execute ProcessQuery.`);
|
|
98
|
-
logger.logToStderr('');
|
|
99
95
|
}
|
|
100
96
|
let requestBody = '';
|
|
101
97
|
if (listId) {
|
|
@@ -138,13 +134,42 @@ class SpoContentTypeFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
138
134
|
}
|
|
139
135
|
});
|
|
140
136
|
}
|
|
137
|
+
getListIdFromListTitle(webUrl, listTitle) {
|
|
138
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const requestOptions = {
|
|
140
|
+
url: `${webUrl}/_api/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(listTitle)}')?$select=Id`,
|
|
141
|
+
headers: {
|
|
142
|
+
accept: 'application/json;odata=nometadata'
|
|
143
|
+
},
|
|
144
|
+
responseType: 'json'
|
|
145
|
+
};
|
|
146
|
+
const list = yield request_1.default.get(requestOptions);
|
|
147
|
+
return list.Id;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
getListIdFromListUrl(webUrl, listUrl) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
152
|
+
const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(webUrl, listUrl);
|
|
153
|
+
const requestOptions = {
|
|
154
|
+
url: `${webUrl}/_api/web/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')?$select=Id`,
|
|
155
|
+
headers: {
|
|
156
|
+
accept: 'application/json;odata=nometadata'
|
|
157
|
+
},
|
|
158
|
+
responseType: 'json'
|
|
159
|
+
};
|
|
160
|
+
const list = yield request_1.default.get(requestOptions);
|
|
161
|
+
return list.Id;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
141
164
|
}
|
|
142
165
|
_SpoContentTypeFieldRemoveCommand_instances = new WeakSet(), _SpoContentTypeFieldRemoveCommand_initTelemetry = function _SpoContentTypeFieldRemoveCommand_initTelemetry() {
|
|
143
166
|
this.telemetry.push((args) => {
|
|
144
167
|
Object.assign(this.telemetryProperties, {
|
|
145
|
-
listTitle:
|
|
146
|
-
|
|
147
|
-
|
|
168
|
+
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
169
|
+
listId: typeof args.options.listId !== 'undefined',
|
|
170
|
+
listUrl: typeof args.options.listUrl !== 'undefined',
|
|
171
|
+
updateChildContentTypes: !!args.options.updateChildContentTypes,
|
|
172
|
+
confirm: !!args.options.confirm
|
|
148
173
|
});
|
|
149
174
|
});
|
|
150
175
|
}, _SpoContentTypeFieldRemoveCommand_initOptions = function _SpoContentTypeFieldRemoveCommand_initOptions() {
|
|
@@ -152,6 +177,10 @@ _SpoContentTypeFieldRemoveCommand_instances = new WeakSet(), _SpoContentTypeFiel
|
|
|
152
177
|
option: '-u, --webUrl <webUrl>'
|
|
153
178
|
}, {
|
|
154
179
|
option: '-l, --listTitle [listTitle]'
|
|
180
|
+
}, {
|
|
181
|
+
option: '--listId [listId]'
|
|
182
|
+
}, {
|
|
183
|
+
option: '--listUrl [listUrl]'
|
|
155
184
|
}, {
|
|
156
185
|
option: '-i, --contentTypeId <contentTypeId>'
|
|
157
186
|
}, {
|
|
@@ -166,6 +195,9 @@ _SpoContentTypeFieldRemoveCommand_instances = new WeakSet(), _SpoContentTypeFiel
|
|
|
166
195
|
if (!validation_1.validation.isValidGuid(args.options.fieldLinkId)) {
|
|
167
196
|
return `${args.options.fieldLinkId} is not a valid GUID`;
|
|
168
197
|
}
|
|
198
|
+
if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
|
|
199
|
+
return `${args.options.listId} is not a valid GUID`;
|
|
200
|
+
}
|
|
169
201
|
return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
170
202
|
}));
|
|
171
203
|
}, _SpoContentTypeFieldRemoveCommand_initTypes = function _SpoContentTypeFieldRemoveCommand_initTypes() {
|
|
@@ -17,6 +17,7 @@ var _SpoContentTypeGetCommand_instances, _SpoContentTypeGetCommand_initTelemetry
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
const request_1 = require("../../../../request");
|
|
19
19
|
const formatting_1 = require("../../../../utils/formatting");
|
|
20
|
+
const urlUtil_1 = require("../../../../utils/urlUtil");
|
|
20
21
|
const validation_1 = require("../../../../utils/validation");
|
|
21
22
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
22
23
|
const commands_1 = require("../../commands");
|
|
@@ -38,21 +39,32 @@ class SpoContentTypeGetCommand extends SpoCommand_1.default {
|
|
|
38
39
|
}
|
|
39
40
|
commandAction(logger, args) {
|
|
40
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
let requestUrl = `${args.options.webUrl}/_api/web`;
|
|
43
|
+
if (args.options.listId) {
|
|
44
|
+
requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
45
|
+
}
|
|
46
|
+
else if (args.options.listTitle) {
|
|
47
|
+
requestUrl += `/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
|
|
48
|
+
}
|
|
49
|
+
else if (args.options.listUrl) {
|
|
50
|
+
const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
|
|
51
|
+
requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
52
|
+
}
|
|
53
|
+
requestUrl += "/contenttypes";
|
|
54
|
+
if (args.options.id) {
|
|
55
|
+
requestUrl += `('${encodeURIComponent(args.options.id)}')`;
|
|
56
|
+
}
|
|
57
|
+
else if (args.options.name) {
|
|
58
|
+
requestUrl += `?$filter=Name eq '${encodeURIComponent(args.options.name)}'`;
|
|
59
|
+
}
|
|
60
|
+
const requestOptions = {
|
|
61
|
+
url: requestUrl,
|
|
62
|
+
headers: {
|
|
63
|
+
accept: 'application/json;odata=nometadata'
|
|
64
|
+
},
|
|
65
|
+
responseType: 'json'
|
|
66
|
+
};
|
|
41
67
|
try {
|
|
42
|
-
let requestUrl = `${args.options.webUrl}/_api/web/${(args.options.listTitle ? `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/` : '')}contenttypes`;
|
|
43
|
-
if (args.options.id) {
|
|
44
|
-
requestUrl += `('${encodeURIComponent(args.options.id)}')`;
|
|
45
|
-
}
|
|
46
|
-
else if (args.options.name) {
|
|
47
|
-
requestUrl += `?$filter=Name eq '${encodeURIComponent(args.options.name)}'`;
|
|
48
|
-
}
|
|
49
|
-
const requestOptions = {
|
|
50
|
-
url: requestUrl,
|
|
51
|
-
headers: {
|
|
52
|
-
accept: 'application/json;odata=nometadata'
|
|
53
|
-
},
|
|
54
|
-
responseType: 'json'
|
|
55
|
-
};
|
|
56
68
|
let res = yield request_1.default.get(requestOptions);
|
|
57
69
|
let errorMessage = '';
|
|
58
70
|
if (args.options.name) {
|
|
@@ -80,7 +92,9 @@ class SpoContentTypeGetCommand extends SpoCommand_1.default {
|
|
|
80
92
|
_SpoContentTypeGetCommand_instances = new WeakSet(), _SpoContentTypeGetCommand_initTelemetry = function _SpoContentTypeGetCommand_initTelemetry() {
|
|
81
93
|
this.telemetry.push((args) => {
|
|
82
94
|
Object.assign(this.telemetryProperties, {
|
|
95
|
+
listId: typeof args.options.listId !== 'undefined',
|
|
83
96
|
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
97
|
+
listUrl: typeof args.options.listUrl !== 'undefined',
|
|
84
98
|
id: typeof args.options.id !== 'undefined',
|
|
85
99
|
name: typeof args.options.name !== 'undefined'
|
|
86
100
|
});
|
|
@@ -90,6 +104,10 @@ _SpoContentTypeGetCommand_instances = new WeakSet(), _SpoContentTypeGetCommand_i
|
|
|
90
104
|
option: '-u, --webUrl <webUrl>'
|
|
91
105
|
}, {
|
|
92
106
|
option: '-l, --listTitle [listTitle]'
|
|
107
|
+
}, {
|
|
108
|
+
option: '--listId [listId]'
|
|
109
|
+
}, {
|
|
110
|
+
option: '--listUrl [listUrl]'
|
|
93
111
|
}, {
|
|
94
112
|
option: '-i, --id [id]'
|
|
95
113
|
}, {
|
|
@@ -101,6 +119,9 @@ _SpoContentTypeGetCommand_instances = new WeakSet(), _SpoContentTypeGetCommand_i
|
|
|
101
119
|
if (isValidSharePointUrl !== true) {
|
|
102
120
|
return isValidSharePointUrl;
|
|
103
121
|
}
|
|
122
|
+
if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
|
|
123
|
+
return `${args.options.listId} is not a valid GUID`;
|
|
124
|
+
}
|
|
104
125
|
return true;
|
|
105
126
|
}));
|
|
106
127
|
}, _SpoContentTypeGetCommand_initTypes = function _SpoContentTypeGetCommand_initTypes() {
|
|
@@ -0,0 +1,129 @@
|
|
|
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 _SpoFileRoleInheritanceBreakCommand_instances, _SpoFileRoleInheritanceBreakCommand_initTelemetry, _SpoFileRoleInheritanceBreakCommand_initOptions, _SpoFileRoleInheritanceBreakCommand_initValidators, _SpoFileRoleInheritanceBreakCommand_initOptionSets;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const Cli_1 = require("../../../../cli/Cli");
|
|
19
|
+
const request_1 = require("../../../../request");
|
|
20
|
+
const validation_1 = require("../../../../utils/validation");
|
|
21
|
+
const formatting_1 = require("../../../../utils/formatting");
|
|
22
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
23
|
+
const commands_1 = require("../../commands");
|
|
24
|
+
const SpoFileGetCommand = require("./file-get");
|
|
25
|
+
class SpoFileRoleInheritanceBreakCommand extends SpoCommand_1.default {
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
_SpoFileRoleInheritanceBreakCommand_instances.add(this);
|
|
29
|
+
__classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initTelemetry).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initOptions).call(this);
|
|
31
|
+
__classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initValidators).call(this);
|
|
32
|
+
__classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initOptionSets).call(this);
|
|
33
|
+
}
|
|
34
|
+
get name() {
|
|
35
|
+
return commands_1.default.FILE_ROLEINHERITANCE_BREAK;
|
|
36
|
+
}
|
|
37
|
+
get description() {
|
|
38
|
+
return 'Breaks inheritance of a file. Keeping existing permissions is the default behavior.';
|
|
39
|
+
}
|
|
40
|
+
commandAction(logger, args) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const breakFileRoleInheritance = () => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
try {
|
|
44
|
+
const fileURL = yield this.getFileURL(args);
|
|
45
|
+
const keepExistingPermissions = !args.options.clearExistingPermissions;
|
|
46
|
+
const requestOptions = {
|
|
47
|
+
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(fileURL)}')/ListItemAllFields/breakroleinheritance(${keepExistingPermissions})`,
|
|
48
|
+
headers: {
|
|
49
|
+
accept: 'application/json;odata=nometadata'
|
|
50
|
+
},
|
|
51
|
+
responseType: 'json'
|
|
52
|
+
};
|
|
53
|
+
yield request_1.default.post(requestOptions);
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
this.handleRejectedODataJsonPromise(err);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
if (args.options.confirm) {
|
|
60
|
+
yield breakFileRoleInheritance();
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
const result = yield Cli_1.Cli.prompt({
|
|
64
|
+
type: 'confirm',
|
|
65
|
+
name: 'continue',
|
|
66
|
+
default: false,
|
|
67
|
+
message: `Are you sure you want to break the role inheritance of file ${args.options.fileUrl || args.options.fileId} located in site ${args.options.webUrl}?`
|
|
68
|
+
});
|
|
69
|
+
if (result.continue) {
|
|
70
|
+
yield breakFileRoleInheritance();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
getFileURL(args) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
if (args.options.fileUrl) {
|
|
78
|
+
return args.options.fileUrl;
|
|
79
|
+
}
|
|
80
|
+
const options = {
|
|
81
|
+
webUrl: args.options.webUrl,
|
|
82
|
+
id: args.options.fileId,
|
|
83
|
+
output: 'json',
|
|
84
|
+
debug: this.debug,
|
|
85
|
+
verbose: this.verbose
|
|
86
|
+
};
|
|
87
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoFileGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
88
|
+
const getFileOutput = JSON.parse(output.stdout);
|
|
89
|
+
return getFileOutput.ServerRelativeUrl;
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
_SpoFileRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoFileRoleInheritanceBreakCommand_initTelemetry = function _SpoFileRoleInheritanceBreakCommand_initTelemetry() {
|
|
94
|
+
this.telemetry.push((args) => {
|
|
95
|
+
Object.assign(this.telemetryProperties, {
|
|
96
|
+
fileUrl: typeof args.options.fileUrl !== 'undefined',
|
|
97
|
+
fileId: typeof args.options.fileId !== 'undefined',
|
|
98
|
+
clearExistingPermissions: !!args.options.clearExistingPermissions,
|
|
99
|
+
confirm: !!args.options.confirm
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}, _SpoFileRoleInheritanceBreakCommand_initOptions = function _SpoFileRoleInheritanceBreakCommand_initOptions() {
|
|
103
|
+
this.options.unshift({
|
|
104
|
+
option: '-u, --webUrl <webUrl>'
|
|
105
|
+
}, {
|
|
106
|
+
option: '--fileUrl [fileUrl]'
|
|
107
|
+
}, {
|
|
108
|
+
option: 'i, --fileId [fileId]'
|
|
109
|
+
}, {
|
|
110
|
+
option: '-c, --clearExistingPermissions'
|
|
111
|
+
}, {
|
|
112
|
+
option: '--confirm'
|
|
113
|
+
});
|
|
114
|
+
}, _SpoFileRoleInheritanceBreakCommand_initValidators = function _SpoFileRoleInheritanceBreakCommand_initValidators() {
|
|
115
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
117
|
+
if (isValidSharePointUrl !== true) {
|
|
118
|
+
return isValidSharePointUrl;
|
|
119
|
+
}
|
|
120
|
+
if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
|
|
121
|
+
return `${args.options.fileId} is not a valid GUID`;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}));
|
|
125
|
+
}, _SpoFileRoleInheritanceBreakCommand_initOptionSets = function _SpoFileRoleInheritanceBreakCommand_initOptionSets() {
|
|
126
|
+
this.optionSets.push(['fileId', 'fileUrl']);
|
|
127
|
+
};
|
|
128
|
+
module.exports = new SpoFileRoleInheritanceBreakCommand();
|
|
129
|
+
//# sourceMappingURL=file-roleinheritance-break.js.map
|