@pnp/cli-microsoft365 5.9.0-beta.c3fe008 → 5.9.0-beta.e2c58c7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/m365/outlook/commands/mail/mail-send.js +1 -1
- package/dist/m365/pp/commands/Environment.js +3 -0
- package/dist/m365/pp/commands/environment/environment-get.js +75 -0
- package/dist/m365/pp/commands.js +1 -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-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 +1 -0
- package/dist/m365/todo/commands/task/task-set.js +53 -1
- package/docs/docs/cmd/pp/environment/environment-get.md +38 -0
- 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/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-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/todo/task/task-set.md +29 -2
- package/package.json +2 -1
|
@@ -132,7 +132,7 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
|
|
|
132
132
|
if (args.options.bodyContentType &&
|
|
133
133
|
args.options.bodyContentType !== 'Text' &&
|
|
134
134
|
args.options.bodyContentType !== 'HTML') {
|
|
135
|
-
return `${args.options.
|
|
135
|
+
return `${args.options.bodyContentType} is not a valid value for the bodyContentType option. Allowed values are Text|HTML`;
|
|
136
136
|
}
|
|
137
137
|
if (args.options.saveToSentItems &&
|
|
138
138
|
args.options.saveToSentItems !== 'true' &&
|
|
@@ -0,0 +1,75 @@
|
|
|
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 _PpEnvironmentGetCommand_instances, _PpEnvironmentGetCommand_initTelemetry, _PpEnvironmentGetCommand_initOptions;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const request_1 = require("../../../../request");
|
|
19
|
+
const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
|
|
20
|
+
const commands_1 = require("../../commands");
|
|
21
|
+
class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
_PpEnvironmentGetCommand_instances.add(this);
|
|
25
|
+
__classPrivateFieldGet(this, _PpEnvironmentGetCommand_instances, "m", _PpEnvironmentGetCommand_initTelemetry).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _PpEnvironmentGetCommand_instances, "m", _PpEnvironmentGetCommand_initOptions).call(this);
|
|
27
|
+
}
|
|
28
|
+
get name() {
|
|
29
|
+
return commands_1.default.ENVIRONMENT_GET;
|
|
30
|
+
}
|
|
31
|
+
get description() {
|
|
32
|
+
return 'Gets information about the specified Power Platform environment';
|
|
33
|
+
}
|
|
34
|
+
defaultProperties() {
|
|
35
|
+
return ['name', 'id'];
|
|
36
|
+
}
|
|
37
|
+
commandAction(logger, args) {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
let url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments`;
|
|
40
|
+
if (args.options.asAdmin) {
|
|
41
|
+
url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments`;
|
|
42
|
+
}
|
|
43
|
+
const requestOptions = {
|
|
44
|
+
url: `${url}?api-version=2020-10-01`,
|
|
45
|
+
headers: {
|
|
46
|
+
accept: 'application/json'
|
|
47
|
+
},
|
|
48
|
+
responseType: 'json'
|
|
49
|
+
};
|
|
50
|
+
const res = yield request_1.default.get(requestOptions);
|
|
51
|
+
const environmentItem = res.value.filter((env) => {
|
|
52
|
+
return env.name === args.options.name;
|
|
53
|
+
})[0];
|
|
54
|
+
if (!environmentItem) {
|
|
55
|
+
throw `The specified Power Platform environment does not exist`;
|
|
56
|
+
}
|
|
57
|
+
logger.log(environmentItem);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
_PpEnvironmentGetCommand_instances = new WeakSet(), _PpEnvironmentGetCommand_initTelemetry = function _PpEnvironmentGetCommand_initTelemetry() {
|
|
62
|
+
this.telemetry.push((args) => {
|
|
63
|
+
Object.assign(this.telemetryProperties, {
|
|
64
|
+
asAdmin: !!args.options.asAdmin
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}, _PpEnvironmentGetCommand_initOptions = function _PpEnvironmentGetCommand_initOptions() {
|
|
68
|
+
this.options.unshift({
|
|
69
|
+
option: '-n, --name <name>'
|
|
70
|
+
}, {
|
|
71
|
+
option: '-a, --asAdmin'
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
module.exports = new PpEnvironmentGetCommand();
|
|
75
|
+
//# sourceMappingURL=environment-get.js.map
|
package/dist/m365/pp/commands.js
CHANGED
|
@@ -4,6 +4,7 @@ const prefix = 'pp';
|
|
|
4
4
|
exports.default = {
|
|
5
5
|
CARD_LIST: `${prefix} card list`,
|
|
6
6
|
DATAVERSE_TABLE_LIST: `${prefix} dataverse table list`,
|
|
7
|
+
ENVIRONMENT_GET: `${prefix} environment get`,
|
|
7
8
|
ENVIRONMENT_LIST: `${prefix} environment list`,
|
|
8
9
|
GATEWAY_LIST: `${prefix} gateway list`,
|
|
9
10
|
MANAGEMENTAPP_ADD: `${prefix} managementapp add`,
|
|
@@ -0,0 +1,168 @@
|
|
|
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 _SpoFolderRoleAssignmentRemoveCommand_instances, _SpoFolderRoleAssignmentRemoveCommand_initTelemetry, _SpoFolderRoleAssignmentRemoveCommand_initOptions, _SpoFolderRoleAssignmentRemoveCommand_initValidators;
|
|
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 validation_1 = require("../../../../utils/validation");
|
|
22
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
23
|
+
const commands_1 = require("../../commands");
|
|
24
|
+
const SpoUserGetCommand = require("../user/user-get");
|
|
25
|
+
const SpoGroupGetCommand = require("../group/group-get");
|
|
26
|
+
class SpoFolderRoleAssignmentRemoveCommand extends SpoCommand_1.default {
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
_SpoFolderRoleAssignmentRemoveCommand_instances.add(this);
|
|
30
|
+
__classPrivateFieldGet(this, _SpoFolderRoleAssignmentRemoveCommand_instances, "m", _SpoFolderRoleAssignmentRemoveCommand_initTelemetry).call(this);
|
|
31
|
+
__classPrivateFieldGet(this, _SpoFolderRoleAssignmentRemoveCommand_instances, "m", _SpoFolderRoleAssignmentRemoveCommand_initOptions).call(this);
|
|
32
|
+
__classPrivateFieldGet(this, _SpoFolderRoleAssignmentRemoveCommand_instances, "m", _SpoFolderRoleAssignmentRemoveCommand_initValidators).call(this);
|
|
33
|
+
}
|
|
34
|
+
get name() {
|
|
35
|
+
return commands_1.default.FOLDER_ROLEASSIGNMENT_REMOVE;
|
|
36
|
+
}
|
|
37
|
+
get description() {
|
|
38
|
+
return 'Removes a role assignment from the specified folder';
|
|
39
|
+
}
|
|
40
|
+
commandAction(logger, args) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const removeRoleAssignment = () => __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
if (this.verbose) {
|
|
44
|
+
logger.logToStderr(`Removing role assignment from folder in site at ${args.options.webUrl}...`);
|
|
45
|
+
}
|
|
46
|
+
const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl);
|
|
47
|
+
const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${encodeURIComponent(serverRelativeUrl)}')/ListItemAllFields`;
|
|
48
|
+
try {
|
|
49
|
+
if (args.options.upn) {
|
|
50
|
+
args.options.principalId = yield this.getUserPrincipalId(args.options);
|
|
51
|
+
yield this.removeRoleAssignment(requestUrl, logger, args.options);
|
|
52
|
+
}
|
|
53
|
+
else if (args.options.groupName) {
|
|
54
|
+
args.options.principalId = yield this.getGroupPrincipalId(args.options);
|
|
55
|
+
yield this.removeRoleAssignment(requestUrl, logger, args.options);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
yield this.removeRoleAssignment(requestUrl, logger, args.options);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.handleRejectedODataJsonPromise(err);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
if (args.options.confirm) {
|
|
66
|
+
yield removeRoleAssignment();
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const result = yield Cli_1.Cli.prompt({
|
|
70
|
+
type: 'confirm',
|
|
71
|
+
name: 'continue',
|
|
72
|
+
default: false,
|
|
73
|
+
message: `Are you sure you want to remove a role assignment from the folder with url '${args.options.folderUrl}'?`
|
|
74
|
+
});
|
|
75
|
+
if (result.continue) {
|
|
76
|
+
yield removeRoleAssignment();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
removeRoleAssignment(requestUrl, logger, options) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const requestOptions = {
|
|
84
|
+
url: `${requestUrl}/roleassignments/removeroleassignment(principalid='${options.principalId}')`,
|
|
85
|
+
method: 'POST',
|
|
86
|
+
headers: {
|
|
87
|
+
'accept': 'application/json;odata=nometadata',
|
|
88
|
+
'content-type': 'application/json'
|
|
89
|
+
},
|
|
90
|
+
responseType: 'json'
|
|
91
|
+
};
|
|
92
|
+
yield request_1.default.post(requestOptions);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
getGroupPrincipalId(options) {
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
const groupGetCommandOptions = {
|
|
98
|
+
webUrl: options.webUrl,
|
|
99
|
+
name: options.groupName,
|
|
100
|
+
output: 'json',
|
|
101
|
+
debug: this.debug,
|
|
102
|
+
verbose: this.verbose
|
|
103
|
+
};
|
|
104
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) });
|
|
105
|
+
const getGroupOutput = JSON.parse(output.stdout);
|
|
106
|
+
return getGroupOutput.Id;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
getUserPrincipalId(options) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const userGetCommandOptions = {
|
|
112
|
+
webUrl: options.webUrl,
|
|
113
|
+
email: options.upn,
|
|
114
|
+
id: undefined,
|
|
115
|
+
output: 'json',
|
|
116
|
+
debug: this.debug,
|
|
117
|
+
verbose: this.verbose
|
|
118
|
+
};
|
|
119
|
+
const output = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) });
|
|
120
|
+
const getUserOutput = JSON.parse(output.stdout);
|
|
121
|
+
return getUserOutput.Id;
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_SpoFolderRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFolderRoleAssignmentRemoveCommand_initTelemetry = function _SpoFolderRoleAssignmentRemoveCommand_initTelemetry() {
|
|
126
|
+
this.telemetry.push((args) => {
|
|
127
|
+
Object.assign(this.telemetryProperties, {
|
|
128
|
+
principalId: typeof args.options.principalId !== 'undefined',
|
|
129
|
+
upn: typeof args.options.upn !== 'undefined',
|
|
130
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
131
|
+
confirm: (!(!args.options.confirm)).toString()
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}, _SpoFolderRoleAssignmentRemoveCommand_initOptions = function _SpoFolderRoleAssignmentRemoveCommand_initOptions() {
|
|
135
|
+
this.options.unshift({
|
|
136
|
+
option: '-u, --webUrl <webUrl>'
|
|
137
|
+
}, {
|
|
138
|
+
option: '-f, --folderUrl <folderUrl>'
|
|
139
|
+
}, {
|
|
140
|
+
option: '--principalId [principalId]'
|
|
141
|
+
}, {
|
|
142
|
+
option: '--upn [upn]'
|
|
143
|
+
}, {
|
|
144
|
+
option: '--groupName [groupName]'
|
|
145
|
+
}, {
|
|
146
|
+
option: '--confirm'
|
|
147
|
+
});
|
|
148
|
+
}, _SpoFolderRoleAssignmentRemoveCommand_initValidators = function _SpoFolderRoleAssignmentRemoveCommand_initValidators() {
|
|
149
|
+
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
151
|
+
if (isValidSharePointUrl !== true) {
|
|
152
|
+
return isValidSharePointUrl;
|
|
153
|
+
}
|
|
154
|
+
if (args.options.principalId && isNaN(args.options.principalId)) {
|
|
155
|
+
return `Specified principalId ${args.options.principalId} is not a number`;
|
|
156
|
+
}
|
|
157
|
+
const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
|
|
158
|
+
if (principalOptions.some(item => item !== undefined) && principalOptions.filter(item => item !== undefined).length > 1) {
|
|
159
|
+
return `Specify either principalId id, upn or groupName`;
|
|
160
|
+
}
|
|
161
|
+
if (principalOptions.filter(item => item !== undefined).length === 0) {
|
|
162
|
+
return `Specify at least principalId id, upn or groupName`;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}));
|
|
166
|
+
};
|
|
167
|
+
module.exports = new SpoFolderRoleAssignmentRemoveCommand();
|
|
168
|
+
//# sourceMappingURL=folder-roleassignment-remove.js.map
|
|
@@ -17,6 +17,7 @@ var _SpoListContentTypeAddCommand_instances, _SpoListContentTypeAddCommand_initT
|
|
|
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");
|
|
@@ -39,19 +40,25 @@ class SpoListContentTypeAddCommand extends SpoCommand_1.default {
|
|
|
39
40
|
commandAction(logger, args) {
|
|
40
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
42
|
if (this.verbose) {
|
|
42
|
-
const list = (args.options.listId ? args.options.listId : args.options.listTitle);
|
|
43
|
+
const list = (args.options.listId ? args.options.listId : args.options.listTitle ? args.options.listTitle : args.options.listUrl);
|
|
43
44
|
logger.logToStderr(`Adding content type ${args.options.contentTypeId} to list ${list} in site at ${args.options.webUrl}...`);
|
|
44
45
|
}
|
|
45
|
-
let requestUrl =
|
|
46
|
+
let requestUrl = `${args.options.webUrl}/_api/web/`;
|
|
46
47
|
if (args.options.listId) {
|
|
47
|
-
requestUrl
|
|
48
|
+
requestUrl += `lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
48
49
|
}
|
|
49
|
-
else {
|
|
50
|
-
requestUrl
|
|
50
|
+
else if (args.options.listTitle) {
|
|
51
|
+
requestUrl += `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
+
else if (args.options.listUrl) {
|
|
54
|
+
const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
|
|
55
|
+
requestUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
56
|
+
}
|
|
57
|
+
const requestBody = {
|
|
58
|
+
contentTypeId: args.options.contentTypeId
|
|
59
|
+
};
|
|
53
60
|
const requestOptions = {
|
|
54
|
-
url: requestUrl
|
|
61
|
+
url: `${requestUrl}/ContentTypes/AddAvailableContentType`,
|
|
55
62
|
headers: {
|
|
56
63
|
'accept': 'application/json;odata=nometadata'
|
|
57
64
|
},
|
|
@@ -67,17 +74,13 @@ class SpoListContentTypeAddCommand extends SpoCommand_1.default {
|
|
|
67
74
|
}
|
|
68
75
|
});
|
|
69
76
|
}
|
|
70
|
-
mapRequestBody(options) {
|
|
71
|
-
return {
|
|
72
|
-
contentTypeId: options.contentTypeId
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
77
|
}
|
|
76
78
|
_SpoListContentTypeAddCommand_instances = new WeakSet(), _SpoListContentTypeAddCommand_initTelemetry = function _SpoListContentTypeAddCommand_initTelemetry() {
|
|
77
79
|
this.telemetry.push((args) => {
|
|
78
80
|
Object.assign(this.telemetryProperties, {
|
|
79
81
|
listId: typeof args.options.listId !== 'undefined',
|
|
80
|
-
listTitle: typeof args.options.listTitle !== 'undefined'
|
|
82
|
+
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
83
|
+
listUrl: typeof args.options.listUrl !== 'undefined'
|
|
81
84
|
});
|
|
82
85
|
});
|
|
83
86
|
}, _SpoListContentTypeAddCommand_initOptions = function _SpoListContentTypeAddCommand_initOptions() {
|
|
@@ -87,6 +90,8 @@ _SpoListContentTypeAddCommand_instances = new WeakSet(), _SpoListContentTypeAddC
|
|
|
87
90
|
option: '-l, --listId [listId]'
|
|
88
91
|
}, {
|
|
89
92
|
option: '-t, --listTitle [listTitle]'
|
|
93
|
+
}, {
|
|
94
|
+
option: '--listUrl [listUrl]'
|
|
90
95
|
}, {
|
|
91
96
|
option: '-c, --contentTypeId <contentTypeId>'
|
|
92
97
|
});
|
|
@@ -96,17 +101,15 @@ _SpoListContentTypeAddCommand_instances = new WeakSet(), _SpoListContentTypeAddC
|
|
|
96
101
|
if (isValidSharePointUrl !== true) {
|
|
97
102
|
return isValidSharePointUrl;
|
|
98
103
|
}
|
|
99
|
-
if (args.options.listId) {
|
|
100
|
-
|
|
101
|
-
return `${args.options.listId} is not a valid GUID`;
|
|
102
|
-
}
|
|
104
|
+
if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
|
|
105
|
+
return `${args.options.listId} is not a valid GUID`;
|
|
103
106
|
}
|
|
104
107
|
return true;
|
|
105
108
|
}));
|
|
106
109
|
}, _SpoListContentTypeAddCommand_initTypes = function _SpoListContentTypeAddCommand_initTypes() {
|
|
107
110
|
this.types.string.push('contentTypeId', 'c');
|
|
108
111
|
}, _SpoListContentTypeAddCommand_initOptionSets = function _SpoListContentTypeAddCommand_initOptionSets() {
|
|
109
|
-
this.optionSets.push(['listId', 'listTitle']);
|
|
112
|
+
this.optionSets.push(['listId', 'listTitle', 'listUrl']);
|
|
110
113
|
};
|
|
111
114
|
module.exports = new SpoListContentTypeAddCommand();
|
|
112
115
|
//# sourceMappingURL=list-contenttype-add.js.map
|
|
@@ -17,6 +17,7 @@ var _SpoListContentTypeDefaultSetCommand_instances, _SpoListContentTypeDefaultSe
|
|
|
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,9 +39,17 @@ class SpoListContentTypeDefaultSetCommand extends SpoCommand_1.default {
|
|
|
38
39
|
}
|
|
39
40
|
commandAction(logger, args) {
|
|
40
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
let baseUrl = `${args.options.webUrl}/_api/web/`;
|
|
43
|
+
if (args.options.listId) {
|
|
44
|
+
baseUrl += `lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
45
|
+
}
|
|
46
|
+
else if (args.options.listTitle) {
|
|
47
|
+
baseUrl += `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
|
+
baseUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
52
|
+
}
|
|
44
53
|
if (this.verbose) {
|
|
45
54
|
logger.logToStderr('Retrieving content type order...');
|
|
46
55
|
}
|
|
@@ -49,7 +58,6 @@ class SpoListContentTypeDefaultSetCommand extends SpoCommand_1.default {
|
|
|
49
58
|
// see if the specified content type is among the registered content types
|
|
50
59
|
// if it is, it means it's visible
|
|
51
60
|
const contentTypeIndex = contentTypeOrder.findIndex(ct => ct.StringValue.toUpperCase() === args.options.contentTypeId.toUpperCase());
|
|
52
|
-
let res;
|
|
53
61
|
if (contentTypeIndex > -1) {
|
|
54
62
|
if (this.debug) {
|
|
55
63
|
logger.logToStderr(`Content type ${args.options.contentTypeId} is visible in the list`);
|
|
@@ -70,7 +78,7 @@ class SpoListContentTypeDefaultSetCommand extends SpoCommand_1.default {
|
|
|
70
78
|
contentTypeOrder.unshift({
|
|
71
79
|
StringValue: args.options.contentTypeId
|
|
72
80
|
});
|
|
73
|
-
|
|
81
|
+
yield this.updateContentTypeOrder(baseUrl, contentTypeOrder);
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
else {
|
|
@@ -90,9 +98,8 @@ class SpoListContentTypeDefaultSetCommand extends SpoCommand_1.default {
|
|
|
90
98
|
contentTypeOrder.unshift({
|
|
91
99
|
StringValue: args.options.contentTypeId
|
|
92
100
|
});
|
|
93
|
-
|
|
101
|
+
yield this.updateContentTypeOrder(baseUrl, contentTypeOrder);
|
|
94
102
|
}
|
|
95
|
-
logger.log(res);
|
|
96
103
|
}
|
|
97
104
|
catch (err) {
|
|
98
105
|
this.handleRejectedODataJsonPromise(err);
|
|
@@ -100,64 +107,67 @@ class SpoListContentTypeDefaultSetCommand extends SpoCommand_1.default {
|
|
|
100
107
|
});
|
|
101
108
|
}
|
|
102
109
|
getContentTypeOrder(baseUrl, logger) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
.get(requestOptions)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (contentTypeOrder.UniqueContentTypeOrder !== null) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const requestOptions = {
|
|
112
|
+
url: `${baseUrl}/RootFolder?$select=ContentTypeOrder,UniqueContentTypeOrder`,
|
|
113
|
+
headers: {
|
|
114
|
+
'accept': 'application/json;odata=nometadata'
|
|
115
|
+
},
|
|
116
|
+
responseType: 'json'
|
|
117
|
+
};
|
|
118
|
+
const response = yield request_1.default.get(requestOptions);
|
|
119
|
+
let uniqueContentTypeOrder = response.ContentTypeOrder;
|
|
120
|
+
if (response.UniqueContentTypeOrder !== null) {
|
|
115
121
|
if (this.debug) {
|
|
116
122
|
logger.logToStderr('Using unique content type order');
|
|
117
123
|
}
|
|
118
|
-
uniqueContentTypeOrder =
|
|
124
|
+
uniqueContentTypeOrder = response.UniqueContentTypeOrder;
|
|
119
125
|
}
|
|
120
126
|
else {
|
|
121
127
|
if (this.debug) {
|
|
122
128
|
logger.logToStderr('Unique content type order not defined. Using content type order');
|
|
123
129
|
}
|
|
124
130
|
}
|
|
125
|
-
return
|
|
126
|
-
}
|
|
131
|
+
return uniqueContentTypeOrder;
|
|
132
|
+
});
|
|
127
133
|
}
|
|
128
134
|
updateContentTypeOrder(baseUrl, contentTypeOrder) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
const requestOptions = {
|
|
137
|
+
url: `${baseUrl}/RootFolder`,
|
|
138
|
+
headers: {
|
|
139
|
+
'accept': 'application/json;odata=nometadata',
|
|
140
|
+
'content-type': 'application/json;odata=nometadata',
|
|
141
|
+
'x-http-method': 'MERGE'
|
|
142
|
+
},
|
|
143
|
+
data: {
|
|
144
|
+
UniqueContentTypeOrder: contentTypeOrder
|
|
145
|
+
},
|
|
146
|
+
responseType: 'json'
|
|
147
|
+
};
|
|
148
|
+
yield request_1.default.post(requestOptions);
|
|
149
|
+
});
|
|
142
150
|
}
|
|
143
151
|
getListContentTypes(baseUrl) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.get(requestOptions)
|
|
153
|
-
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
const requestOptions = {
|
|
154
|
+
url: `${baseUrl}/ContentTypes?$select=Id`,
|
|
155
|
+
headers: {
|
|
156
|
+
'accept': 'application/json;odata=nometadata'
|
|
157
|
+
},
|
|
158
|
+
responseType: 'json'
|
|
159
|
+
};
|
|
160
|
+
const response = yield request_1.default.get(requestOptions);
|
|
161
|
+
return response.value.map(ct => ct.Id.StringValue);
|
|
162
|
+
});
|
|
154
163
|
}
|
|
155
164
|
}
|
|
156
165
|
_SpoListContentTypeDefaultSetCommand_instances = new WeakSet(), _SpoListContentTypeDefaultSetCommand_initTelemetry = function _SpoListContentTypeDefaultSetCommand_initTelemetry() {
|
|
157
166
|
this.telemetry.push((args) => {
|
|
158
167
|
Object.assign(this.telemetryProperties, {
|
|
159
168
|
listId: typeof args.options.listId !== 'undefined',
|
|
160
|
-
listTitle: typeof args.options.listTitle !== 'undefined'
|
|
169
|
+
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
170
|
+
listUrl: typeof args.options.listUrl !== 'undefined'
|
|
161
171
|
});
|
|
162
172
|
});
|
|
163
173
|
}, _SpoListContentTypeDefaultSetCommand_initOptions = function _SpoListContentTypeDefaultSetCommand_initOptions() {
|
|
@@ -167,6 +177,8 @@ _SpoListContentTypeDefaultSetCommand_instances = new WeakSet(), _SpoListContentT
|
|
|
167
177
|
option: '-l, --listId [listId]'
|
|
168
178
|
}, {
|
|
169
179
|
option: '-t, --listTitle [listTitle]'
|
|
180
|
+
}, {
|
|
181
|
+
option: '--listUrl [listUrl]'
|
|
170
182
|
}, {
|
|
171
183
|
option: '-c, --contentTypeId <contentTypeId>'
|
|
172
184
|
});
|
|
@@ -186,7 +198,7 @@ _SpoListContentTypeDefaultSetCommand_instances = new WeakSet(), _SpoListContentT
|
|
|
186
198
|
}, _SpoListContentTypeDefaultSetCommand_initTypes = function _SpoListContentTypeDefaultSetCommand_initTypes() {
|
|
187
199
|
this.types.string.push('contentTypeId', 'c');
|
|
188
200
|
}, _SpoListContentTypeDefaultSetCommand_initOptionSets = function _SpoListContentTypeDefaultSetCommand_initOptionSets() {
|
|
189
|
-
this.optionSets.push(['listId', 'listTitle']);
|
|
201
|
+
this.optionSets.push(['listId', 'listTitle', 'listUrl']);
|
|
190
202
|
};
|
|
191
203
|
module.exports = new SpoListContentTypeDefaultSetCommand();
|
|
192
204
|
//# sourceMappingURL=list-contenttype-default-set.js.map
|
|
@@ -17,6 +17,7 @@ var _SpoListContentTypeListCommand_instances, _SpoListContentTypeListCommand_ini
|
|
|
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");
|
|
@@ -41,18 +42,22 @@ class SpoListContentTypeListCommand extends SpoCommand_1.default {
|
|
|
41
42
|
commandAction(logger, args) {
|
|
42
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
44
|
if (this.verbose) {
|
|
44
|
-
const list = (args.options.listId ? args.options.listId : args.options.listTitle);
|
|
45
|
+
const list = (args.options.listId ? args.options.listId : args.options.listTitle ? args.options.listTitle : args.options.listUrl);
|
|
45
46
|
logger.logToStderr(`Retrieving content types information for list ${list} in site at ${args.options.webUrl}...`);
|
|
46
47
|
}
|
|
47
|
-
let requestUrl =
|
|
48
|
+
let requestUrl = `${args.options.webUrl}/_api/web/`;
|
|
48
49
|
if (args.options.listId) {
|
|
49
|
-
requestUrl
|
|
50
|
+
requestUrl += `lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
|
|
50
51
|
}
|
|
51
|
-
else {
|
|
52
|
-
requestUrl
|
|
52
|
+
else if (args.options.listTitle) {
|
|
53
|
+
requestUrl += `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
|
|
54
|
+
}
|
|
55
|
+
else if (args.options.listUrl) {
|
|
56
|
+
const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
|
|
57
|
+
requestUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
53
58
|
}
|
|
54
59
|
const requestOptions = {
|
|
55
|
-
url: requestUrl
|
|
60
|
+
url: `${requestUrl}/ContentTypes`,
|
|
56
61
|
method: 'GET',
|
|
57
62
|
headers: {
|
|
58
63
|
'accept': 'application/json;odata=nometadata'
|
|
@@ -73,7 +78,8 @@ _SpoListContentTypeListCommand_instances = new WeakSet(), _SpoListContentTypeLis
|
|
|
73
78
|
this.telemetry.push((args) => {
|
|
74
79
|
Object.assign(this.telemetryProperties, {
|
|
75
80
|
listId: typeof args.options.listId !== 'undefined',
|
|
76
|
-
listTitle: typeof args.options.listTitle !== 'undefined'
|
|
81
|
+
listTitle: typeof args.options.listTitle !== 'undefined',
|
|
82
|
+
listUrl: typeof args.options.listUrl !== 'undefined'
|
|
77
83
|
});
|
|
78
84
|
});
|
|
79
85
|
}, _SpoListContentTypeListCommand_initOptions = function _SpoListContentTypeListCommand_initOptions() {
|
|
@@ -83,6 +89,8 @@ _SpoListContentTypeListCommand_instances = new WeakSet(), _SpoListContentTypeLis
|
|
|
83
89
|
option: '-l, --listId [listId]'
|
|
84
90
|
}, {
|
|
85
91
|
option: '-t, --listTitle [listTitle]'
|
|
92
|
+
}, {
|
|
93
|
+
option: '--listUrl [listUrl]'
|
|
86
94
|
});
|
|
87
95
|
}, _SpoListContentTypeListCommand_initValidators = function _SpoListContentTypeListCommand_initValidators() {
|
|
88
96
|
this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -98,7 +106,7 @@ _SpoListContentTypeListCommand_instances = new WeakSet(), _SpoListContentTypeLis
|
|
|
98
106
|
return true;
|
|
99
107
|
}));
|
|
100
108
|
}, _SpoListContentTypeListCommand_initOptionSets = function _SpoListContentTypeListCommand_initOptionSets() {
|
|
101
|
-
this.optionSets.push(['listId', 'listTitle']);
|
|
109
|
+
this.optionSets.push(['listId', 'listTitle', 'listUrl']);
|
|
102
110
|
};
|
|
103
111
|
module.exports = new SpoListContentTypeListCommand();
|
|
104
112
|
//# sourceMappingURL=list-contenttype-list.js.map
|