@pnp/cli-microsoft365 6.0.0-beta.f73c4f8 → 6.0.0-beta.f94d570
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/Auth.js +2 -2
- package/dist/m365/aad/commands/app/app-remove.js +0 -4
- package/dist/m365/aad/commands/app/app-role-remove.js +0 -4
- package/dist/m365/aad/commands/o365group/o365group-recyclebinitem-restore.js +60 -9
- package/dist/m365/aad/commands.js +0 -2
- package/dist/m365/base/PowerAppsCommand.js +10 -0
- package/dist/m365/pa/commands/app/app-get.js +3 -5
- package/dist/m365/pa/commands/app/app-list.js +10 -9
- package/dist/m365/pa/commands/app/app-remove.js +3 -3
- package/dist/m365/pa/commands/connector/connector-export.js +3 -3
- package/dist/m365/pa/commands/connector/connector-list.js +10 -9
- package/dist/m365/pa/commands/environment/environment-get.js +3 -3
- package/dist/m365/pa/commands/environment/environment-list.js +4 -4
- package/dist/m365/planner/commands/bucket/bucket-add.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-get.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-list.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-remove.js +4 -12
- package/dist/m365/planner/commands/bucket/bucket-set.js +4 -12
- package/dist/m365/planner/commands/plan/plan-add.js +98 -5
- package/dist/m365/planner/commands/plan/plan-get.js +0 -4
- package/dist/m365/planner/commands/task/task-add.js +4 -10
- package/dist/m365/planner/commands/task/task-get.js +4 -19
- package/dist/m365/planner/commands/task/task-list.js +4 -12
- package/dist/m365/planner/commands/task/task-set.js +4 -10
- package/dist/m365/planner/commands.js +0 -2
- package/dist/m365/spo/commands/customaction/customaction-get.js +32 -4
- package/dist/m365/spo/commands/customaction/customaction-remove.js +43 -8
- package/dist/m365/spo/commands/field/field-get.js +14 -5
- package/dist/m365/spo/commands/field/field-remove.js +19 -10
- package/dist/m365/spo/commands/field/field-set.js +16 -9
- package/dist/m365/spo/commands/file/file-rename.js +108 -0
- package/dist/m365/spo/commands/group/group-add.js +96 -0
- package/dist/m365/spo/commands/group/group-get.js +26 -6
- package/dist/m365/spo/commands/group/group-set.js +167 -0
- package/dist/m365/spo/commands/hubsite/hubsite-get.js +38 -2
- package/dist/m365/spo/commands/list/list-list.js +1 -10
- package/dist/m365/spo/commands/listitem/listitem-get.js +9 -9
- package/dist/m365/spo/commands/listitem/listitem-list.js +9 -26
- package/dist/m365/spo/commands/site/site-apppermission-add.js +3 -6
- package/dist/m365/spo/commands/site/site-apppermission-set.js +3 -6
- package/dist/m365/spo/commands/site/site-list.js +47 -16
- package/dist/m365/spo/commands/site/site-set.js +322 -162
- package/dist/m365/spo/commands/tenant/tenant-appcatalog-add.js +9 -6
- package/dist/m365/spo/commands.js +3 -3
- package/dist/m365/teams/commands/tab/tab-get.js +2 -2
- package/dist/m365/teams/commands/team/team-archive.js +51 -15
- package/dist/m365/teams/commands/team/team-clone.js +33 -7
- package/dist/m365/teams/commands/team/team-remove.js +47 -11
- package/dist/m365/teams/commands/team/team-set.js +25 -5
- package/dist/m365/teams/commands/team/team-unarchive.js +48 -12
- package/docs/docs/cmd/aad/app/app-remove.md +0 -6
- package/docs/docs/cmd/aad/app/app-role-remove.md +0 -6
- package/docs/docs/cmd/aad/o365group/o365group-recyclebinitem-restore.md +21 -3
- package/docs/docs/cmd/planner/bucket/bucket-add.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-get.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-list.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-remove.md +0 -3
- package/docs/docs/cmd/planner/bucket/bucket-set.md +0 -3
- package/docs/docs/cmd/planner/plan/plan-add.md +18 -2
- package/docs/docs/cmd/planner/plan/plan-get.md +0 -6
- package/docs/docs/cmd/planner/task/task-add.md +0 -3
- package/docs/docs/cmd/planner/task/task-get.md +6 -3
- package/docs/docs/cmd/planner/task/task-list.md +0 -3
- package/docs/docs/cmd/planner/task/task-set.md +0 -3
- package/docs/docs/cmd/spo/customaction/customaction-get.md +15 -2
- package/docs/docs/cmd/spo/customaction/customaction-remove.md +33 -2
- package/docs/docs/cmd/spo/field/field-get.md +6 -3
- package/docs/docs/cmd/spo/field/field-remove.md +9 -6
- package/docs/docs/cmd/spo/field/field-set.md +7 -4
- package/docs/docs/cmd/spo/file/file-rename.md +43 -0
- package/docs/docs/cmd/spo/group/group-add.md +51 -0
- package/docs/docs/cmd/spo/group/group-get.md +12 -3
- package/docs/docs/cmd/spo/group/group-set.md +69 -0
- package/docs/docs/cmd/spo/hubsite/hubsite-get.md +21 -0
- package/docs/docs/cmd/spo/list/list-list.md +0 -3
- package/docs/docs/cmd/spo/listitem/listitem-get.md +11 -2
- package/docs/docs/cmd/spo/listitem/listitem-list.md +8 -6
- package/docs/docs/cmd/spo/site/site-apppermission-add.md +1 -1
- package/docs/docs/cmd/spo/site/site-apppermission-set.md +1 -1
- package/docs/docs/cmd/spo/site/site-list.md +19 -7
- package/docs/docs/cmd/spo/site/site-set.md +50 -6
- package/docs/docs/cmd/teams/tab/tab-get.md +2 -2
- package/docs/docs/cmd/teams/team/team-archive.md +20 -5
- package/docs/docs/cmd/teams/team/team-clone.md +11 -5
- package/docs/docs/cmd/teams/team/team-remove.md +19 -5
- package/docs/docs/cmd/teams/team/team-set.md +10 -4
- package/docs/docs/cmd/teams/team/team-unarchive.md +18 -4
- package/npm-shrinkwrap.json +173 -158
- package/package.json +13 -13
- package/dist/m365/spo/commands/site/site-classic-add.js +0 -333
- package/dist/m365/spo/commands/site/site-classic-list.js +0 -98
- package/dist/m365/spo/commands/site/site-classic-set.js +0 -358
- package/docs/docs/cmd/spo/site/site-classic-add.md +0 -93
- package/docs/docs/cmd/spo/site/site-classic-list.md +0 -65
- package/docs/docs/cmd/spo/site/site-classic-set.md +0 -99
|
@@ -19,11 +19,20 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
19
19
|
telemetryProps.listUrl = typeof args.options.listUrl !== 'undefined';
|
|
20
20
|
telemetryProps.id = typeof args.options.id !== 'undefined';
|
|
21
21
|
telemetryProps.group = typeof args.options.group !== 'undefined';
|
|
22
|
-
telemetryProps.
|
|
22
|
+
telemetryProps.title = typeof args.options.title !== 'undefined';
|
|
23
23
|
telemetryProps.confirm = (!(!args.options.confirm)).toString();
|
|
24
24
|
return telemetryProps;
|
|
25
25
|
}
|
|
26
|
+
optionSets() {
|
|
27
|
+
return [
|
|
28
|
+
['id', 'title', 'fieldTitle', 'group']
|
|
29
|
+
];
|
|
30
|
+
}
|
|
26
31
|
commandAction(logger, args, cb) {
|
|
32
|
+
if (args.options.fieldTitle) {
|
|
33
|
+
args.options.title = args.options.fieldTitle;
|
|
34
|
+
this.warn(logger, `Option 'fieldTitle' is deprecated. Please use 'title' instead.`);
|
|
35
|
+
}
|
|
27
36
|
let messageEnd;
|
|
28
37
|
if (args.options.listId || args.options.listTitle) {
|
|
29
38
|
messageEnd = `in list ${args.options.listId || args.options.listTitle}`;
|
|
@@ -31,16 +40,16 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
31
40
|
else {
|
|
32
41
|
messageEnd = `in site ${args.options.webUrl}`;
|
|
33
42
|
}
|
|
34
|
-
const removeField = (listRestUrl, fieldId,
|
|
43
|
+
const removeField = (listRestUrl, fieldId, title) => {
|
|
35
44
|
if (this.verbose) {
|
|
36
|
-
logger.logToStderr(`Removing field ${fieldId ||
|
|
45
|
+
logger.logToStderr(`Removing field ${fieldId || title} ${messageEnd}...`);
|
|
37
46
|
}
|
|
38
47
|
let fieldRestUrl = '';
|
|
39
48
|
if (fieldId) {
|
|
40
49
|
fieldRestUrl = `/getbyid('${utils_1.formatting.encodeQueryParameter(fieldId)}')`;
|
|
41
50
|
}
|
|
42
51
|
else {
|
|
43
|
-
fieldRestUrl = `/getbyinternalnameortitle('${utils_1.formatting.encodeQueryParameter(
|
|
52
|
+
fieldRestUrl = `/getbyinternalnameortitle('${utils_1.formatting.encodeQueryParameter(title)}')`;
|
|
44
53
|
}
|
|
45
54
|
const requestOptions = {
|
|
46
55
|
url: `${args.options.webUrl}/_api/web/${listRestUrl}fields${fieldRestUrl}`,
|
|
@@ -97,7 +106,7 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
97
106
|
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
98
107
|
}
|
|
99
108
|
else {
|
|
100
|
-
removeField(listRestUrl, args.options.id, args.options.
|
|
109
|
+
removeField(listRestUrl, args.options.id, args.options.title)
|
|
101
110
|
.then(() => {
|
|
102
111
|
// REST post call doesn't return anything
|
|
103
112
|
cb();
|
|
@@ -108,7 +117,7 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
108
117
|
prepareRemoval();
|
|
109
118
|
}
|
|
110
119
|
else {
|
|
111
|
-
const confirmMessage = `Are you sure you want to remove the ${args.options.group ? 'fields' : 'field'} ${args.options.id || args.options.
|
|
120
|
+
const confirmMessage = `Are you sure you want to remove the ${args.options.group ? 'fields' : 'field'} ${args.options.id || args.options.title || 'from group ' + args.options.group} ${messageEnd}?`;
|
|
112
121
|
cli_1.Cli.prompt({
|
|
113
122
|
type: 'confirm',
|
|
114
123
|
name: 'continue',
|
|
@@ -142,7 +151,10 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
142
151
|
option: '-i, --id [id]'
|
|
143
152
|
},
|
|
144
153
|
{
|
|
145
|
-
option: '
|
|
154
|
+
option: '--fieldTitle [fieldTitle]'
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
option: '-t, --title [title]'
|
|
146
158
|
},
|
|
147
159
|
{
|
|
148
160
|
option: '-g, --group [group]'
|
|
@@ -159,9 +171,6 @@ class SpoFieldRemoveCommand extends SpoCommand_1.default {
|
|
|
159
171
|
if (isValidSharePointUrl !== true) {
|
|
160
172
|
return isValidSharePointUrl;
|
|
161
173
|
}
|
|
162
|
-
if (!args.options.id && !args.options.fieldTitle && !args.options.group) {
|
|
163
|
-
return 'Specify id, fieldTitle, or group. One is required';
|
|
164
|
-
}
|
|
165
174
|
if (args.options.id && !utils_1.validation.isValidGuid(args.options.id)) {
|
|
166
175
|
return `${args.options.id} is not a valid GUID`;
|
|
167
176
|
}
|
|
@@ -16,6 +16,7 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
|
|
|
16
16
|
getTelemetryProperties(args) {
|
|
17
17
|
const telemetryProps = super.getTelemetryProperties(args);
|
|
18
18
|
telemetryProps.id = typeof args.options.id !== 'undefined';
|
|
19
|
+
telemetryProps.title = typeof args.options.title !== 'undefined';
|
|
19
20
|
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
20
21
|
telemetryProps.listId = typeof args.options.listId !== 'undefined';
|
|
21
22
|
telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
|
|
@@ -26,6 +27,9 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
|
|
|
26
27
|
return true;
|
|
27
28
|
}
|
|
28
29
|
commandAction(logger, args, cb) {
|
|
30
|
+
if (args.options.name) {
|
|
31
|
+
this.warn(logger, `Option 'name' is deprecated. Please use 'title' instead.`);
|
|
32
|
+
}
|
|
29
33
|
let requestDigest = '';
|
|
30
34
|
utils_1.spo
|
|
31
35
|
.getRequestDigest(args.options.webUrl)
|
|
@@ -61,7 +65,7 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
|
|
|
61
65
|
// retrieve column CSOM object id
|
|
62
66
|
const fieldQuery = args.options.id ?
|
|
63
67
|
`<Method Id="663" ParentId="7" Name="GetById"><Parameters><Parameter Type="Guid">${utils_1.formatting.escapeXml(args.options.id)}</Parameter></Parameters></Method>` :
|
|
64
|
-
`<Method Id="663" ParentId="7" Name="GetByInternalNameOrTitle"><Parameters><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.name)}</Parameter></Parameters></Method>`;
|
|
68
|
+
`<Method Id="663" ParentId="7" Name="GetByInternalNameOrTitle"><Parameters><Parameter Type="String">${utils_1.formatting.escapeXml(args.options.name || args.options.title)}</Parameter></Parameters></Method>`;
|
|
65
69
|
const requestOptions = {
|
|
66
70
|
url: `${args.options.webUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
67
71
|
headers: {
|
|
@@ -105,6 +109,7 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
|
|
|
105
109
|
'listTitle',
|
|
106
110
|
'id',
|
|
107
111
|
'name',
|
|
112
|
+
'title',
|
|
108
113
|
'updateExistingLists',
|
|
109
114
|
'debug',
|
|
110
115
|
'verbose',
|
|
@@ -116,6 +121,11 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
|
|
|
116
121
|
}).join('');
|
|
117
122
|
return payload;
|
|
118
123
|
}
|
|
124
|
+
optionSets() {
|
|
125
|
+
return [
|
|
126
|
+
['id', 'title', 'name']
|
|
127
|
+
];
|
|
128
|
+
}
|
|
119
129
|
options() {
|
|
120
130
|
const options = [
|
|
121
131
|
{
|
|
@@ -128,10 +138,13 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
|
|
|
128
138
|
option: '--listTitle [listTitle]'
|
|
129
139
|
},
|
|
130
140
|
{
|
|
131
|
-
option: '-i
|
|
141
|
+
option: '-i, --id [id]'
|
|
132
142
|
},
|
|
133
143
|
{
|
|
134
|
-
option: '-n
|
|
144
|
+
option: '-n, --name [name]'
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
option: '-t, --title [title]'
|
|
135
148
|
},
|
|
136
149
|
{
|
|
137
150
|
option: '--updateExistingLists'
|
|
@@ -152,12 +165,6 @@ class SpoFieldSetCommand extends SpoCommand_1.default {
|
|
|
152
165
|
!utils_1.validation.isValidGuid(args.options.listId)) {
|
|
153
166
|
return `${args.options.listId} in option listId is not a valid GUID`;
|
|
154
167
|
}
|
|
155
|
-
if (!args.options.id && !args.options.name) {
|
|
156
|
-
return `Specify id or name`;
|
|
157
|
-
}
|
|
158
|
-
if (args.options.id && args.options.name) {
|
|
159
|
-
return `Specify viewId or viewTitle but not both`;
|
|
160
|
-
}
|
|
161
168
|
if (args.options.id &&
|
|
162
169
|
!utils_1.validation.isValidGuid(args.options.id)) {
|
|
163
170
|
return `${args.options.id} in option id is not a valid GUID`;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_1 = require("../../../../cli");
|
|
4
|
+
const request_1 = require("../../../../request");
|
|
5
|
+
const utils_1 = require("../../../../utils");
|
|
6
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
7
|
+
const commands_1 = require("../../commands");
|
|
8
|
+
const removeCommand = require('./file-remove');
|
|
9
|
+
class SpoFileRenameCommand extends SpoCommand_1.default {
|
|
10
|
+
get name() {
|
|
11
|
+
return commands_1.default.FILE_RENAME;
|
|
12
|
+
}
|
|
13
|
+
get description() {
|
|
14
|
+
return 'Renames a file';
|
|
15
|
+
}
|
|
16
|
+
getTelemetryProperties(args) {
|
|
17
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
18
|
+
telemetryProps.force = !!args.options.force;
|
|
19
|
+
return telemetryProps;
|
|
20
|
+
}
|
|
21
|
+
commandAction(logger, args, cb) {
|
|
22
|
+
const webUrl = args.options.webUrl;
|
|
23
|
+
const originalFileServerRelativeUrl = utils_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.sourceUrl);
|
|
24
|
+
this
|
|
25
|
+
.getFile(originalFileServerRelativeUrl, webUrl)
|
|
26
|
+
.then((_) => {
|
|
27
|
+
if (args.options.force) {
|
|
28
|
+
return this.deleteFile(webUrl, args.options.sourceUrl, args.options.targetFileName);
|
|
29
|
+
}
|
|
30
|
+
return Promise.resolve();
|
|
31
|
+
})
|
|
32
|
+
.then(_ => {
|
|
33
|
+
const requestBody = {
|
|
34
|
+
formValues: [{
|
|
35
|
+
FieldName: 'FileLeafRef',
|
|
36
|
+
FieldValue: args.options.targetFileName
|
|
37
|
+
}]
|
|
38
|
+
};
|
|
39
|
+
const requestOptions = {
|
|
40
|
+
url: `${webUrl}/_api/web/GetFileByServerRelativeUrl('${encodeURIComponent(originalFileServerRelativeUrl)}')/ListItemAllFields/ValidateUpdateListItem()`,
|
|
41
|
+
headers: {
|
|
42
|
+
'accept': 'application/json;odata=nometadata'
|
|
43
|
+
},
|
|
44
|
+
data: requestBody,
|
|
45
|
+
responseType: 'json'
|
|
46
|
+
};
|
|
47
|
+
return request_1.default.post(requestOptions);
|
|
48
|
+
})
|
|
49
|
+
.then((resp) => {
|
|
50
|
+
logger.log(resp.value);
|
|
51
|
+
cb();
|
|
52
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
53
|
+
}
|
|
54
|
+
getFile(originalFileServerRelativeUrl, webUrl) {
|
|
55
|
+
const requestUrl = `${webUrl}/_api/web/GetFileByServerRelativeUrl('${encodeURIComponent(originalFileServerRelativeUrl)}')?$select=UniqueId`;
|
|
56
|
+
const requestOptions = {
|
|
57
|
+
url: requestUrl,
|
|
58
|
+
headers: {
|
|
59
|
+
'accept': 'application/json;odata=nometadata'
|
|
60
|
+
},
|
|
61
|
+
responseType: 'json'
|
|
62
|
+
};
|
|
63
|
+
return request_1.default.get(requestOptions);
|
|
64
|
+
}
|
|
65
|
+
deleteFile(webUrl, sourceUrl, targetFileName) {
|
|
66
|
+
const targetFileServerRelativeUrl = `${utils_1.urlUtil.getServerRelativePath(webUrl, sourceUrl.substring(0, sourceUrl.lastIndexOf('/')))}/${targetFileName}`;
|
|
67
|
+
const options = {
|
|
68
|
+
webUrl: webUrl,
|
|
69
|
+
url: targetFileServerRelativeUrl,
|
|
70
|
+
recycle: true,
|
|
71
|
+
confirm: true,
|
|
72
|
+
debug: this.debug,
|
|
73
|
+
verbose: this.verbose
|
|
74
|
+
};
|
|
75
|
+
return cli_1.Cli.executeCommandWithOutput(removeCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) })
|
|
76
|
+
.then(_ => {
|
|
77
|
+
return Promise.resolve();
|
|
78
|
+
}, (err) => {
|
|
79
|
+
if (err.error !== null && err.error.message !== null && err.error.message.includes('does not exist')) {
|
|
80
|
+
return Promise.resolve();
|
|
81
|
+
}
|
|
82
|
+
return Promise.reject(err);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
options() {
|
|
86
|
+
const options = [
|
|
87
|
+
{
|
|
88
|
+
option: '-u, --webUrl <webUrl>'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
option: '-s, --sourceUrl <sourceUrl>'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
option: '-t, --targetFileName <targetFileName>'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
option: '--force'
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
const parentOptions = super.options();
|
|
101
|
+
return options.concat(parentOptions);
|
|
102
|
+
}
|
|
103
|
+
validate(args) {
|
|
104
|
+
return utils_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
module.exports = new SpoFileRenameCommand();
|
|
108
|
+
//# sourceMappingURL=file-rename.js.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../../../utils");
|
|
4
|
+
const request_1 = require("../../../../request");
|
|
5
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
6
|
+
const commands_1 = require("../../commands");
|
|
7
|
+
class SpoGroupAddCommand extends SpoCommand_1.default {
|
|
8
|
+
get name() {
|
|
9
|
+
return commands_1.default.GROUP_ADD;
|
|
10
|
+
}
|
|
11
|
+
get description() {
|
|
12
|
+
return 'Creates group in the specified site';
|
|
13
|
+
}
|
|
14
|
+
getTelemetryProperties(args) {
|
|
15
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
16
|
+
telemetryProps.description = typeof args.options.description !== 'undefined';
|
|
17
|
+
telemetryProps.allowMembersEditMembership = typeof args.options.allowMembersEditMembership !== 'undefined';
|
|
18
|
+
telemetryProps.onlyAllowMembersViewMembership = typeof args.options.onlyAllowMembersViewMembership !== 'undefined';
|
|
19
|
+
telemetryProps.allowRequestToJoinLeave = typeof args.options.allowRequestToJoinLeave !== 'undefined';
|
|
20
|
+
telemetryProps.autoAcceptRequestToJoinLeave = typeof args.options.autoAcceptRequestToJoinLeave !== 'undefined';
|
|
21
|
+
telemetryProps.requestToJoinLeaveEmailSetting = typeof args.options.requestToJoinLeaveEmailSetting !== 'undefined';
|
|
22
|
+
return telemetryProps;
|
|
23
|
+
}
|
|
24
|
+
commandAction(logger, args, cb) {
|
|
25
|
+
const requestOptions = {
|
|
26
|
+
url: `${args.options.webUrl}/_api/web/sitegroups`,
|
|
27
|
+
headers: {
|
|
28
|
+
accept: 'application/json;odata=nometadata'
|
|
29
|
+
},
|
|
30
|
+
responseType: 'json',
|
|
31
|
+
data: {
|
|
32
|
+
Title: args.options.name,
|
|
33
|
+
Description: args.options.description,
|
|
34
|
+
AllowMembersEditMembership: args.options.allowMembersEditMembership,
|
|
35
|
+
OnlyAllowMembersViewMembership: args.options.onlyAllowMembersViewMembership,
|
|
36
|
+
AllowRequestToJoinLeave: args.options.allowRequestToJoinLeave,
|
|
37
|
+
AutoAcceptRequestToJoinLeave: args.options.autoAcceptRequestToJoinLeave,
|
|
38
|
+
RequestToJoinLeaveEmailSetting: args.options.requestToJoinLeaveEmailSetting
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
request_1.default
|
|
42
|
+
.post(requestOptions)
|
|
43
|
+
.then((response) => {
|
|
44
|
+
logger.log(response);
|
|
45
|
+
cb();
|
|
46
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
47
|
+
}
|
|
48
|
+
options() {
|
|
49
|
+
const options = [
|
|
50
|
+
{
|
|
51
|
+
option: '-u, --webUrl <webUrl>'
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
option: '-n, --name <name>'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
option: '--description [description]'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
option: '--allowMembersEditMembership [allowMembersEditMembership]'
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
option: '--onlyAllowMembersViewMembership [onlyAllowMembersViewMembership]'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
option: '--allowRequestToJoinLeave [allowRequestToJoinLeave]'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
option: '--autoAcceptRequestToJoinLeave [autoAcceptRequestToJoinLeave]'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
option: '--requestToJoinLeaveEmailSetting [requestToJoinLeaveEmailSetting]'
|
|
73
|
+
}
|
|
74
|
+
];
|
|
75
|
+
const parentOptions = super.options();
|
|
76
|
+
return options.concat(parentOptions);
|
|
77
|
+
}
|
|
78
|
+
validate(args) {
|
|
79
|
+
const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
80
|
+
if (isValidSharePointUrl !== true) {
|
|
81
|
+
return isValidSharePointUrl;
|
|
82
|
+
}
|
|
83
|
+
const booleanOptions = [
|
|
84
|
+
args.options.allowMembersEditMembership, args.options.onlyAllowMembersViewMembership,
|
|
85
|
+
args.options.allowRequestToJoinLeave, args.options.autoAcceptRequestToJoinLeave
|
|
86
|
+
];
|
|
87
|
+
for (const option of booleanOptions) {
|
|
88
|
+
if (typeof option !== 'undefined' && !utils_1.validation.isValidBoolean(option)) {
|
|
89
|
+
return `Value '${option}' is not a valid boolean`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
module.exports = new SpoGroupAddCommand();
|
|
96
|
+
//# sourceMappingURL=group-add.js.map
|
|
@@ -15,6 +15,7 @@ class SpoGroupGetCommand extends SpoCommand_1.default {
|
|
|
15
15
|
const telemetryProps = super.getTelemetryProperties(args);
|
|
16
16
|
telemetryProps.id = (!(!args.options.id)).toString();
|
|
17
17
|
telemetryProps.name = (!(!args.options.name)).toString();
|
|
18
|
+
telemetryProps.associatedGroup = args.options.associatedGroup;
|
|
18
19
|
return telemetryProps;
|
|
19
20
|
}
|
|
20
21
|
commandAction(logger, args, cb) {
|
|
@@ -28,6 +29,19 @@ class SpoGroupGetCommand extends SpoCommand_1.default {
|
|
|
28
29
|
else if (args.options.name) {
|
|
29
30
|
requestUrl = `${args.options.webUrl}/_api/web/sitegroups/GetByName('${encodeURIComponent(args.options.name)}')`;
|
|
30
31
|
}
|
|
32
|
+
else if (args.options.associatedGroup) {
|
|
33
|
+
switch (args.options.associatedGroup.toLowerCase()) {
|
|
34
|
+
case 'owner':
|
|
35
|
+
requestUrl = `${args.options.webUrl}/_api/web/AssociatedOwnerGroup`;
|
|
36
|
+
break;
|
|
37
|
+
case 'member':
|
|
38
|
+
requestUrl = `${args.options.webUrl}/_api/web/AssociatedMemberGroup`;
|
|
39
|
+
break;
|
|
40
|
+
case 'visitor':
|
|
41
|
+
requestUrl = `${args.options.webUrl}/_api/web/AssociatedVisitorGroup`;
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
31
45
|
const requestOptions = {
|
|
32
46
|
url: requestUrl,
|
|
33
47
|
method: 'GET',
|
|
@@ -53,21 +67,27 @@ class SpoGroupGetCommand extends SpoCommand_1.default {
|
|
|
53
67
|
},
|
|
54
68
|
{
|
|
55
69
|
option: '--name [name]'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
option: '--associatedGroup [associatedGroup]',
|
|
73
|
+
autocomplete: ['Owner', 'Member', 'Visitor']
|
|
56
74
|
}
|
|
57
75
|
];
|
|
58
76
|
const parentOptions = super.options();
|
|
59
77
|
return options.concat(parentOptions);
|
|
60
78
|
}
|
|
79
|
+
optionSets() {
|
|
80
|
+
return [
|
|
81
|
+
['id', 'name', 'associatedGroup']
|
|
82
|
+
];
|
|
83
|
+
}
|
|
61
84
|
validate(args) {
|
|
62
|
-
if (args.options.id && args.options.name) {
|
|
63
|
-
return 'Use either "id" or "name", but not all.';
|
|
64
|
-
}
|
|
65
|
-
if (!args.options.id && !args.options.name) {
|
|
66
|
-
return 'Specify id or name, one is required';
|
|
67
|
-
}
|
|
68
85
|
if (args.options.id && isNaN(args.options.id)) {
|
|
69
86
|
return `Specified id ${args.options.id} is not a number`;
|
|
70
87
|
}
|
|
88
|
+
if (args.options.associatedGroup && ['owner', 'member', 'visitor'].indexOf(args.options.associatedGroup.toLowerCase()) === -1) {
|
|
89
|
+
return `${args.options.associatedGroup} is not a valid associatedGroup value. Allowed values are Owner|Member|Visitor.`;
|
|
90
|
+
}
|
|
71
91
|
return utils_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
72
92
|
}
|
|
73
93
|
}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const AadUserGetCommand = require("../../../aad/commands/user/user-get");
|
|
4
|
+
const cli_1 = require("../../../../cli");
|
|
5
|
+
const utils_1 = require("../../../../utils");
|
|
6
|
+
const request_1 = require("../../../../request");
|
|
7
|
+
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
8
|
+
const commands_1 = require("../../commands");
|
|
9
|
+
class SpoGroupSetCommand extends SpoCommand_1.default {
|
|
10
|
+
get name() {
|
|
11
|
+
return commands_1.default.GROUP_SET;
|
|
12
|
+
}
|
|
13
|
+
get description() {
|
|
14
|
+
return 'Updates a group in the specified site';
|
|
15
|
+
}
|
|
16
|
+
getTelemetryProperties(args) {
|
|
17
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
18
|
+
telemetryProps.id = typeof args.options.id !== 'undefined';
|
|
19
|
+
telemetryProps.name = typeof args.options.name !== 'undefined';
|
|
20
|
+
telemetryProps.newName = typeof args.options.newName !== 'undefined';
|
|
21
|
+
telemetryProps.description = typeof args.options.description !== 'undefined';
|
|
22
|
+
telemetryProps.allowMembersEditMembership = typeof args.options.allowMembersEditMembership !== 'undefined';
|
|
23
|
+
telemetryProps.onlyAllowMembersViewMembership = typeof args.options.onlyAllowMembersViewMembership !== 'undefined';
|
|
24
|
+
telemetryProps.allowRequestToJoinLeave = typeof args.options.allowRequestToJoinLeave !== 'undefined';
|
|
25
|
+
telemetryProps.autoAcceptRequestToJoinLeave = typeof args.options.autoAcceptRequestToJoinLeave !== 'undefined';
|
|
26
|
+
telemetryProps.requestToJoinLeaveEmailSetting = typeof args.options.requestToJoinLeaveEmailSetting !== 'undefined';
|
|
27
|
+
telemetryProps.ownerEmail = typeof args.options.ownerEmail !== 'undefined';
|
|
28
|
+
telemetryProps.ownerUserName = typeof args.options.ownerUserName !== 'undefined';
|
|
29
|
+
return telemetryProps;
|
|
30
|
+
}
|
|
31
|
+
commandAction(logger, args, cb) {
|
|
32
|
+
const requestOptions = {
|
|
33
|
+
url: `${args.options.webUrl}/_api/web/sitegroups/${args.options.id ? `GetById(${args.options.id})` : `GetByName('${args.options.name}')`}`,
|
|
34
|
+
headers: {
|
|
35
|
+
accept: 'application/json;odata.metadata=none',
|
|
36
|
+
'content-type': 'application/json'
|
|
37
|
+
},
|
|
38
|
+
responseType: 'json',
|
|
39
|
+
data: {
|
|
40
|
+
Title: args.options.newName,
|
|
41
|
+
Description: args.options.description,
|
|
42
|
+
AllowMembersEditMembership: args.options.allowMembersEditMembership,
|
|
43
|
+
OnlyAllowMembersViewMembership: args.options.onlyAllowMembersViewMembership,
|
|
44
|
+
AllowRequestToJoinLeave: args.options.allowRequestToJoinLeave,
|
|
45
|
+
AutoAcceptRequestToJoinLeave: args.options.autoAcceptRequestToJoinLeave,
|
|
46
|
+
RequestToJoinLeaveEmailSetting: args.options.requestToJoinLeaveEmailSetting
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
request_1.default
|
|
50
|
+
.patch(requestOptions)
|
|
51
|
+
.then(() => this.setGroupOwner(args.options))
|
|
52
|
+
.then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
53
|
+
}
|
|
54
|
+
setGroupOwner(options) {
|
|
55
|
+
if (!options.ownerEmail && !options.ownerUserName) {
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
}
|
|
58
|
+
return this
|
|
59
|
+
.getOwnerId(options)
|
|
60
|
+
.then((ownerId) => {
|
|
61
|
+
const requestOptions = {
|
|
62
|
+
url: `${options.webUrl}/_api/web/sitegroups/${options.id ? `GetById(${options.id})` : `GetByName('${options.name}')`}/SetUserAsOwner(${ownerId})`,
|
|
63
|
+
headers: {
|
|
64
|
+
accept: 'application/json;odata.metadata=none',
|
|
65
|
+
'content-type': 'application/json'
|
|
66
|
+
},
|
|
67
|
+
responseType: 'json'
|
|
68
|
+
};
|
|
69
|
+
return request_1.default.post(requestOptions);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
getOwnerId(options) {
|
|
73
|
+
const cmdOptions = {
|
|
74
|
+
userName: options.ownerUserName,
|
|
75
|
+
email: options.ownerEmail,
|
|
76
|
+
output: 'json',
|
|
77
|
+
debug: options.debug,
|
|
78
|
+
verbose: options.verbose
|
|
79
|
+
};
|
|
80
|
+
return cli_1.Cli
|
|
81
|
+
.executeCommandWithOutput(AadUserGetCommand, { options: Object.assign(Object.assign({}, cmdOptions), { _: [] }) })
|
|
82
|
+
.then((output) => {
|
|
83
|
+
const getUserOutput = JSON.parse(output.stdout);
|
|
84
|
+
const requestOptions = {
|
|
85
|
+
url: `${options.webUrl}/_api/web/ensureUser('${getUserOutput.userPrincipalName}')?$select=Id`,
|
|
86
|
+
headers: {
|
|
87
|
+
accept: 'application/json',
|
|
88
|
+
'content-type': 'application/json'
|
|
89
|
+
},
|
|
90
|
+
responseType: 'json'
|
|
91
|
+
};
|
|
92
|
+
return request_1.default.post(requestOptions);
|
|
93
|
+
})
|
|
94
|
+
.then((response) => response.Id);
|
|
95
|
+
}
|
|
96
|
+
options() {
|
|
97
|
+
const options = [
|
|
98
|
+
{
|
|
99
|
+
option: '-u, --webUrl <webUrl>'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
option: '-i, --id [id]'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
option: '-n, --name [name]'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
option: '--newName [newName]'
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
option: '--description [description]'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
option: '--allowMembersEditMembership [allowMembersEditMembership]'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
option: '--onlyAllowMembersViewMembership [onlyAllowMembersViewMembership]'
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
option: '--allowRequestToJoinLeave [allowRequestToJoinLeave]'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
option: '--autoAcceptRequestToJoinLeave [autoAcceptRequestToJoinLeave]'
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
option: '--requestToJoinLeaveEmailSetting [requestToJoinLeaveEmailSetting]'
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
option: '--ownerEmail [ownerEmail]'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
option: '--ownerUserName [ownerUserName]'
|
|
133
|
+
}
|
|
134
|
+
];
|
|
135
|
+
const parentOptions = super.options();
|
|
136
|
+
return options.concat(parentOptions);
|
|
137
|
+
}
|
|
138
|
+
optionSets() {
|
|
139
|
+
return [
|
|
140
|
+
['id', 'name']
|
|
141
|
+
];
|
|
142
|
+
}
|
|
143
|
+
validate(args) {
|
|
144
|
+
const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
|
|
145
|
+
if (isValidSharePointUrl !== true) {
|
|
146
|
+
return isValidSharePointUrl;
|
|
147
|
+
}
|
|
148
|
+
if (args.options.id && isNaN(args.options.id)) {
|
|
149
|
+
return `Specified id ${args.options.id} is not a number`;
|
|
150
|
+
}
|
|
151
|
+
if (args.options.ownerEmail && args.options.ownerUserName) {
|
|
152
|
+
return 'Specify either ownerEmail or ownerUserName but not both';
|
|
153
|
+
}
|
|
154
|
+
const booleanOptions = [
|
|
155
|
+
args.options.allowMembersEditMembership, args.options.onlyAllowMembersViewMembership,
|
|
156
|
+
args.options.allowRequestToJoinLeave, args.options.autoAcceptRequestToJoinLeave
|
|
157
|
+
];
|
|
158
|
+
for (const option of booleanOptions) {
|
|
159
|
+
if (typeof option !== 'undefined' && !utils_1.validation.isValidBoolean(option)) {
|
|
160
|
+
return `Value '${option}' is not a valid boolean`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
module.exports = new SpoGroupSetCommand();
|
|
167
|
+
//# sourceMappingURL=group-set.js.map
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cli_1 = require("../../../../cli");
|
|
3
4
|
const request_1 = require("../../../../request");
|
|
4
5
|
const utils_1 = require("../../../../utils");
|
|
5
6
|
const SpoCommand_1 = require("../../../base/SpoCommand");
|
|
6
7
|
const commands_1 = require("../../commands");
|
|
8
|
+
const SpoListItemListCommand = require("../listitem/listitem-list");
|
|
7
9
|
class SpoHubSiteGetCommand extends SpoCommand_1.default {
|
|
8
10
|
get name() {
|
|
9
11
|
return commands_1.default.HUBSITE_GET;
|
|
@@ -16,9 +18,24 @@ class SpoHubSiteGetCommand extends SpoCommand_1.default {
|
|
|
16
18
|
telemetryProps.id = typeof args.options.id !== 'undefined';
|
|
17
19
|
telemetryProps.title = typeof args.options.title !== 'undefined';
|
|
18
20
|
telemetryProps.url = typeof args.options.url !== 'undefined';
|
|
21
|
+
telemetryProps.includeAssociatedSites = args.options.includeAssociatedSites === true;
|
|
19
22
|
return telemetryProps;
|
|
20
23
|
}
|
|
24
|
+
getAssociatedSites(spoAdminUrl, hubSiteId, logger, args) {
|
|
25
|
+
const options = {
|
|
26
|
+
output: 'json',
|
|
27
|
+
debug: args.options.debug,
|
|
28
|
+
verbose: args.options.verbose,
|
|
29
|
+
listTitle: 'DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS',
|
|
30
|
+
webUrl: spoAdminUrl,
|
|
31
|
+
filter: `HubSiteId eq '${hubSiteId}'`,
|
|
32
|
+
fields: 'Title,SiteUrl,SiteId'
|
|
33
|
+
};
|
|
34
|
+
return cli_1.Cli
|
|
35
|
+
.executeCommandWithOutput(SpoListItemListCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
|
|
36
|
+
}
|
|
21
37
|
commandAction(logger, args, cb) {
|
|
38
|
+
let hubSite;
|
|
22
39
|
utils_1.spo
|
|
23
40
|
.getSpoUrl(logger, this.debug)
|
|
24
41
|
.then((spoUrl) => {
|
|
@@ -30,7 +47,25 @@ class SpoHubSiteGetCommand extends SpoCommand_1.default {
|
|
|
30
47
|
}
|
|
31
48
|
})
|
|
32
49
|
.then((res) => {
|
|
33
|
-
|
|
50
|
+
hubSite = res;
|
|
51
|
+
if (args.options.includeAssociatedSites && (args.options.output && args.options.output !== 'json')) {
|
|
52
|
+
throw Error('includeAssociatedSites option is only allowed with json output mode');
|
|
53
|
+
}
|
|
54
|
+
if (args.options.includeAssociatedSites !== true || args.options.output && args.options.output !== 'json') {
|
|
55
|
+
return Promise.resolve();
|
|
56
|
+
}
|
|
57
|
+
return utils_1.spo
|
|
58
|
+
.getSpoAdminUrl(logger, this.debug)
|
|
59
|
+
.then((spoAdminUrl) => {
|
|
60
|
+
return this.getAssociatedSites(spoAdminUrl, hubSite.SiteId, logger, args);
|
|
61
|
+
});
|
|
62
|
+
})
|
|
63
|
+
.then((associatedSitesCommandOutput) => {
|
|
64
|
+
if (args.options.includeAssociatedSites) {
|
|
65
|
+
const associatedSites = JSON.parse(associatedSitesCommandOutput.stdout);
|
|
66
|
+
hubSite.AssociatedSites = associatedSites.filter(s => s.SiteId !== hubSite.SiteId);
|
|
67
|
+
}
|
|
68
|
+
logger.log(hubSite);
|
|
34
69
|
cb();
|
|
35
70
|
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
36
71
|
}
|
|
@@ -75,7 +110,8 @@ class SpoHubSiteGetCommand extends SpoCommand_1.default {
|
|
|
75
110
|
const options = [
|
|
76
111
|
{ option: '-i, --id [id]' },
|
|
77
112
|
{ option: '-t, --title [title]' },
|
|
78
|
-
{ option: '-u, --url [url]' }
|
|
113
|
+
{ option: '-u, --url [url]' },
|
|
114
|
+
{ option: '--includeAssociatedSites' }
|
|
79
115
|
];
|
|
80
116
|
const parentOptions = super.options();
|
|
81
117
|
return options.concat(parentOptions);
|