@pnp/cli-microsoft365 5.2.0 → 5.3.0-beta.d2ec1f4
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/planner/commands/bucket/bucket-remove.js +214 -0
- package/dist/m365/planner/commands.js +1 -0
- package/dist/m365/spo/commands/field/field-list.js +84 -0
- package/dist/m365/spo/commands.js +1 -0
- package/docs/docs/cmd/planner/bucket/bucket-remove.md +60 -0
- package/docs/docs/cmd/spo/field/field-list.md +51 -0
- package/npm-shrinkwrap.json +1517 -1284
- package/package.json +25 -25
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_1 = require("../../../../cli");
|
|
4
|
+
const utils_1 = require("../../../../utils");
|
|
5
|
+
const request_1 = require("../../../../request");
|
|
6
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
7
|
+
const commands_1 = require("../../commands");
|
|
8
|
+
class PlannerBucketRemoveCommand extends GraphCommand_1.default {
|
|
9
|
+
get name() {
|
|
10
|
+
return commands_1.default.BUCKET_REMOVE;
|
|
11
|
+
}
|
|
12
|
+
get description() {
|
|
13
|
+
return 'Removes the Microsoft Planner bucket from a plan';
|
|
14
|
+
}
|
|
15
|
+
getTelemetryProperties(args) {
|
|
16
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
17
|
+
telemetryProps.id = typeof args.options.id !== 'undefined';
|
|
18
|
+
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
19
|
+
telemetryProps.planId = typeof args.options.planId !== 'undefined';
|
|
20
|
+
telemetryProps.planName = typeof args.options.planName !== 'undefined';
|
|
21
|
+
telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
|
|
22
|
+
telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
|
|
23
|
+
telemetryProps.confirm = args.options.confirm || false;
|
|
24
|
+
return telemetryProps;
|
|
25
|
+
}
|
|
26
|
+
commandAction(logger, args, cb) {
|
|
27
|
+
const removeBucket = () => {
|
|
28
|
+
this
|
|
29
|
+
.getBucket(args)
|
|
30
|
+
.then(bucket => {
|
|
31
|
+
const requestOptions = {
|
|
32
|
+
url: `${this.resource}/v1.0/planner/buckets/${bucket.id}`,
|
|
33
|
+
headers: {
|
|
34
|
+
accept: 'application/json;odata.metadata=none',
|
|
35
|
+
'if-match': bucket['@odata.etag']
|
|
36
|
+
},
|
|
37
|
+
responseType: 'json'
|
|
38
|
+
};
|
|
39
|
+
return request_1.default.delete(requestOptions);
|
|
40
|
+
})
|
|
41
|
+
.then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
42
|
+
};
|
|
43
|
+
if (args.options.confirm) {
|
|
44
|
+
removeBucket();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
cli_1.Cli.prompt({
|
|
48
|
+
type: 'confirm',
|
|
49
|
+
name: 'continue',
|
|
50
|
+
default: false,
|
|
51
|
+
message: `Are you sure you want to remove the bucket ${args.options.id || args.options.name}?`
|
|
52
|
+
}, (result) => {
|
|
53
|
+
if (!result.continue) {
|
|
54
|
+
cb();
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
removeBucket();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getBucket(args) {
|
|
63
|
+
if (args.options.id) {
|
|
64
|
+
const requestOptions = {
|
|
65
|
+
url: `${this.resource}/v1.0/planner/buckets/${args.options.id}`,
|
|
66
|
+
headers: {
|
|
67
|
+
accept: 'application/json'
|
|
68
|
+
},
|
|
69
|
+
responseType: 'json'
|
|
70
|
+
};
|
|
71
|
+
return request_1.default.get(requestOptions);
|
|
72
|
+
}
|
|
73
|
+
return this
|
|
74
|
+
.getPlanId(args)
|
|
75
|
+
.then(planId => {
|
|
76
|
+
const requestOptions = {
|
|
77
|
+
url: `${this.resource}/v1.0/planner/plans/${planId}/buckets`,
|
|
78
|
+
headers: {
|
|
79
|
+
accept: 'application/json'
|
|
80
|
+
},
|
|
81
|
+
responseType: 'json'
|
|
82
|
+
};
|
|
83
|
+
return request_1.default.get(requestOptions);
|
|
84
|
+
})
|
|
85
|
+
.then(buckets => {
|
|
86
|
+
const filteredBuckets = buckets.value.filter(b => args.options.name.toLowerCase() === b.name.toLowerCase());
|
|
87
|
+
if (!filteredBuckets.length) {
|
|
88
|
+
return Promise.reject(`The specified bucket ${args.options.name} does not exist`);
|
|
89
|
+
}
|
|
90
|
+
if (filteredBuckets.length > 1) {
|
|
91
|
+
return Promise.reject(`Multiple buckets with name ${args.options.name} found: ${filteredBuckets.map(x => x.id)}`);
|
|
92
|
+
}
|
|
93
|
+
return Promise.resolve(filteredBuckets[0]);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
getPlanId(args) {
|
|
97
|
+
const { planId, planName } = args.options;
|
|
98
|
+
if (planId) {
|
|
99
|
+
return Promise.resolve(planId);
|
|
100
|
+
}
|
|
101
|
+
return this
|
|
102
|
+
.getGroupId(args)
|
|
103
|
+
.then(groupId => {
|
|
104
|
+
const requestOptions = {
|
|
105
|
+
url: `${this.resource}/v1.0/planner/plans?$filter=owner eq '${groupId}'`,
|
|
106
|
+
headers: {
|
|
107
|
+
accept: 'application/json;odata.metadata=none'
|
|
108
|
+
},
|
|
109
|
+
responseType: 'json'
|
|
110
|
+
};
|
|
111
|
+
return request_1.default.get(requestOptions);
|
|
112
|
+
})
|
|
113
|
+
.then(plans => {
|
|
114
|
+
const filteredPlans = plans.value.filter(p => p.title.toLowerCase() === planName.toLowerCase());
|
|
115
|
+
if (!filteredPlans.length) {
|
|
116
|
+
return Promise.reject(`The specified plan ${planName} does not exist`);
|
|
117
|
+
}
|
|
118
|
+
if (filteredPlans.length > 1) {
|
|
119
|
+
return Promise.reject(`Multiple plans with name ${planName} found: ${filteredPlans.map(x => x.id)}`);
|
|
120
|
+
}
|
|
121
|
+
return Promise.resolve(filteredPlans[0].id);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
getGroupId(args) {
|
|
125
|
+
const { ownerGroupId, ownerGroupName } = args.options;
|
|
126
|
+
if (ownerGroupId) {
|
|
127
|
+
return Promise.resolve(ownerGroupId);
|
|
128
|
+
}
|
|
129
|
+
const requestOptions = {
|
|
130
|
+
url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(ownerGroupName)}'`,
|
|
131
|
+
headers: {
|
|
132
|
+
accept: 'application/json;odata.metadata=none'
|
|
133
|
+
},
|
|
134
|
+
responseType: 'json'
|
|
135
|
+
};
|
|
136
|
+
return request_1.default
|
|
137
|
+
.get(requestOptions)
|
|
138
|
+
.then(response => {
|
|
139
|
+
if (!response.value.length) {
|
|
140
|
+
return Promise.reject(`The specified owner group ${ownerGroupName} does not exist`);
|
|
141
|
+
}
|
|
142
|
+
if (response.value.length > 1) {
|
|
143
|
+
return Promise.reject(`Multiple owner groups with name ${ownerGroupName} found: ${response.value.map(x => x.id)}`);
|
|
144
|
+
}
|
|
145
|
+
return Promise.resolve(response.value[0].id);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
options() {
|
|
149
|
+
const options = [
|
|
150
|
+
{
|
|
151
|
+
option: '--id [id]'
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
option: '--name [name]'
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
option: '--planId [planId]'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
option: '--planName [planName]'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
option: '--ownerGroupId [ownerGroupId]'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
option: '--ownerGroupName [ownerGroupName]'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
option: '--confirm'
|
|
170
|
+
}
|
|
171
|
+
];
|
|
172
|
+
const parentOptions = super.options();
|
|
173
|
+
return options.concat(parentOptions);
|
|
174
|
+
}
|
|
175
|
+
optionSets() {
|
|
176
|
+
return [
|
|
177
|
+
['id', 'name']
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
validate(args) {
|
|
181
|
+
if (args.options.id) {
|
|
182
|
+
if (args.options.planId || args.options.planName || args.options.ownerGroupId || args.options.ownerGroupName) {
|
|
183
|
+
return 'Don\'t specify planId, planName, ownerGroupId or ownerGroupName when using id';
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
if (!args.options.planId && !args.options.planName) {
|
|
188
|
+
return 'Specify either planId or planName when using name';
|
|
189
|
+
}
|
|
190
|
+
if (args.options.planId && args.options.planName) {
|
|
191
|
+
return 'Specify either planId or planName when using name but not both';
|
|
192
|
+
}
|
|
193
|
+
if (args.options.planName) {
|
|
194
|
+
if (!args.options.ownerGroupId && !args.options.ownerGroupName) {
|
|
195
|
+
return 'Specify either ownerGroupId or ownerGroupName when using planName';
|
|
196
|
+
}
|
|
197
|
+
if (args.options.ownerGroupId && args.options.ownerGroupName) {
|
|
198
|
+
return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
|
|
199
|
+
}
|
|
200
|
+
if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
|
|
201
|
+
return `${args.options.ownerGroupId} is not a valid GUID`;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
if (args.options.ownerGroupId || args.options.ownerGroupName) {
|
|
206
|
+
return 'Don\'t specify ownerGroupId or ownerGroupName when using planId';
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
module.exports = new PlannerBucketRemoveCommand();
|
|
214
|
+
//# sourceMappingURL=bucket-remove.js.map
|
|
@@ -5,6 +5,7 @@ exports.default = {
|
|
|
5
5
|
BUCKET_ADD: `${prefix} bucket add`,
|
|
6
6
|
BUCKET_LIST: `${prefix} bucket list`,
|
|
7
7
|
BUCKET_SET: `${prefix} bucket set`,
|
|
8
|
+
BUCKET_REMOVE: `${prefix} bucket remove`,
|
|
8
9
|
PLAN_ADD: `${prefix} plan add`,
|
|
9
10
|
PLAN_GET: `${prefix} plan get`,
|
|
10
11
|
PLAN_DETAILS_GET: `${prefix} plan details get`,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const request_1 = require("../../../../request");
|
|
4
|
+
const utils_1 = require("../../../../utils");
|
|
5
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
6
|
+
const commands_1 = require("../../commands");
|
|
7
|
+
class SpoFieldListCommand extends SpoCommand_1.default {
|
|
8
|
+
get name() {
|
|
9
|
+
return commands_1.default.FIELD_LIST;
|
|
10
|
+
}
|
|
11
|
+
get description() {
|
|
12
|
+
return 'Retrieves columns for the specified list or site';
|
|
13
|
+
}
|
|
14
|
+
getTelemetryProperties(args) {
|
|
15
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
16
|
+
telemetryProps.listId = typeof args.options.listId !== 'undefined';
|
|
17
|
+
telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
|
|
18
|
+
telemetryProps.listUrl = typeof args.options.listUrl !== 'undefined';
|
|
19
|
+
return telemetryProps;
|
|
20
|
+
}
|
|
21
|
+
defaultProperties() {
|
|
22
|
+
return ['Id', 'Title', 'Group', 'Hidden'];
|
|
23
|
+
}
|
|
24
|
+
commandAction(logger, args, cb) {
|
|
25
|
+
let listUrl = '';
|
|
26
|
+
if (args.options.listId) {
|
|
27
|
+
listUrl = `lists(guid'${encodeURIComponent(args.options.listId)}')/`;
|
|
28
|
+
}
|
|
29
|
+
else if (args.options.listTitle) {
|
|
30
|
+
listUrl = `lists/getByTitle('${encodeURIComponent(args.options.listTitle)}')/`;
|
|
31
|
+
}
|
|
32
|
+
else if (args.options.listUrl) {
|
|
33
|
+
const listServerRelativeUrl = utils_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
|
|
34
|
+
listUrl = `GetList('${encodeURIComponent(listServerRelativeUrl)}')/`;
|
|
35
|
+
}
|
|
36
|
+
const requestOptions = {
|
|
37
|
+
url: `${args.options.webUrl}/_api/web/${listUrl}fields`,
|
|
38
|
+
headers: {
|
|
39
|
+
accept: 'application/json;odata=nometadata'
|
|
40
|
+
},
|
|
41
|
+
responseType: 'json'
|
|
42
|
+
};
|
|
43
|
+
request_1.default
|
|
44
|
+
.get(requestOptions)
|
|
45
|
+
.then((res) => {
|
|
46
|
+
logger.log(res.value);
|
|
47
|
+
cb();
|
|
48
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
49
|
+
}
|
|
50
|
+
options() {
|
|
51
|
+
const options = [
|
|
52
|
+
{
|
|
53
|
+
option: '-u, --webUrl <webUrl>'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
option: '-t, --listTitle [listTitle]'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
option: '-i, --listId [listId]'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
option: '--listUrl [listUrl]'
|
|
63
|
+
}
|
|
64
|
+
];
|
|
65
|
+
const parentOptions = super.options();
|
|
66
|
+
return options.concat(parentOptions);
|
|
67
|
+
}
|
|
68
|
+
validate(args) {
|
|
69
|
+
const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
70
|
+
if (isValidSharePointUrl !== true) {
|
|
71
|
+
return isValidSharePointUrl;
|
|
72
|
+
}
|
|
73
|
+
if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
|
|
74
|
+
return `${args.options.listId} is not a valid GUID`;
|
|
75
|
+
}
|
|
76
|
+
const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
|
|
77
|
+
if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
|
|
78
|
+
return `Specify either list id or title or list url`;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
module.exports = new SpoFieldListCommand();
|
|
84
|
+
//# sourceMappingURL=field-list.js.map
|
|
@@ -41,6 +41,7 @@ exports.default = {
|
|
|
41
41
|
FEATURE_LIST: `${prefix} feature list`,
|
|
42
42
|
FIELD_ADD: `${prefix} field add`,
|
|
43
43
|
FIELD_GET: `${prefix} field get`,
|
|
44
|
+
FIELD_LIST: `${prefix} field list`,
|
|
44
45
|
FIELD_REMOVE: `${prefix} field remove`,
|
|
45
46
|
FIELD_SET: `${prefix} field set`,
|
|
46
47
|
FILE_ADD: `${prefix} file add`,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# planner bucket remove
|
|
2
|
+
|
|
3
|
+
Removes the Microsoft Planner bucket from a plan
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
m365 planner bucket remove [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
`--id [id]`
|
|
14
|
+
: ID of the bucket to remove. Specify either `id` or `name` but not both.
|
|
15
|
+
|
|
16
|
+
`--name [name]`
|
|
17
|
+
: Name of the bucket to remove. Specify either `id` or `name` but not both.
|
|
18
|
+
|
|
19
|
+
`--planId [planId]`
|
|
20
|
+
: ID of the plan to which the bucket to remove belongs. Specify either `planId` or `planName` when using `name`.
|
|
21
|
+
|
|
22
|
+
`--planName [planName]`
|
|
23
|
+
: Name of the plan to which the bucket to remove belongs. Specify either `planId` or `planName` when using `name`.
|
|
24
|
+
|
|
25
|
+
`--ownerGroupId [ownerGroupId]`
|
|
26
|
+
: ID of the group to which the plan belongs. Specify either `ownerGroupId` or `ownerGroupName` when using `planName`.
|
|
27
|
+
|
|
28
|
+
`--ownerGroupName [ownerGroupName]`
|
|
29
|
+
: Name of the group to which the plan belongs. Specify either `ownerGroupId` or `ownerGroupName` when using `planName`.
|
|
30
|
+
|
|
31
|
+
`--confirm`
|
|
32
|
+
: Don't prompt for confirmation
|
|
33
|
+
|
|
34
|
+
--8<-- "docs/cmd/_global.md"
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
Removes the Microsoft Planner bucket by ID
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
m365 planner bucket remove --id "vncYUXCRBke28qMLB-d4xJcACtNz"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Removes the Microsoft Planner bucket by ID without confirmation
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
m365 planner bucket remove --id "vncYUXCRBke28qMLB-d4xJcACtNz" --confirm
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Removes the Microsoft Planner bucket with name _My Bucket_ in the Plan with ID _oUHpnKBFekqfGE_PS6GGUZcAFY7b_
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
m365 planner bucket remove --name "My Bucket" --planId "oUHpnKBFekqfGE_PS6GGUZcAFY7b"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Removes the Microsoft Planner bucket with name _My Bucket_ in the Plan _My Plan_ owned by group _My Group_
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
m365 planner bucket remove --name "My Bucket" --planName "My Plan" --ownerGroupName "My Group"
|
|
60
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# spo field list
|
|
2
|
+
|
|
3
|
+
Retrieves columns for the specified list or site
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
m365 spo field list [options]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
`-u, --webUrl <webUrl>`
|
|
14
|
+
: Absolute URL of the site where fields are located
|
|
15
|
+
|
|
16
|
+
`-t, --listTitle [listTitle]`
|
|
17
|
+
: Title of the list where fields are located. Specify `listTitle`, `listId` or `listUrl`
|
|
18
|
+
|
|
19
|
+
`-i --listId [listId]`
|
|
20
|
+
: ID of the list where fields are located. Specify `listTitle`, `listId` or `listUrl`
|
|
21
|
+
|
|
22
|
+
`--listUrl [listUrl]`
|
|
23
|
+
: Server- or web-relative URL of the list where fields are located. Specify `listTitle`, `listId` or `listUrl`
|
|
24
|
+
|
|
25
|
+
--8<-- "docs/cmd/_global.md"
|
|
26
|
+
|
|
27
|
+
## Examples
|
|
28
|
+
|
|
29
|
+
Retrieves site columns for site _https://contoso.sharepoint.com/sites/contoso-sales_.
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Retrieves list columns for list _Events_ in site _https://contoso.sharepoint.com/sites/contoso-sales_
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales --listTitle Events
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Retrieves list columns for list _202b8199-b9de-43fd-9737-7f213f51c991_ in site _https://contoso.sharepoint.com/sites/contoso-sales_
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales --listId '202b8199-b9de-43fd-9737-7f213f51c991'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Retrieves list columns for list _/sites/contoso-sales/lists/Events_ in site _https://contoso.sharepoint.com/sites/contoso-sales_
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
m365 spo field list --webUrl https://contoso.sharepoint.com/sites/contoso-sales --listUrl '/sites/contoso-sales/lists/Events'
|
|
51
|
+
```
|