@pnp/cli-microsoft365 7.10.0-beta.a743796 → 7.10.0
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Auth.js +1 -1
- package/dist/chili/chili.js +9 -77
- package/dist/m365/entra/commands/app/app-permission-remove.js +287 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/spo/commands/file/file-add.js +41 -38
- package/dist/m365/spo/commands/site/site-admin-list.js +144 -0
- package/dist/m365/spo/commands/site/site-set.js +22 -24
- package/dist/m365/spo/commands/tenant/tenant-site-archive.js +99 -0
- package/dist/m365/spo/commands/tenant/tenant-site-unarchive.js +98 -0
- package/dist/m365/spo/commands.js +3 -0
- package/dist/m365/teams/commands/user/user-app-add.js +17 -17
- package/dist/m365/teams/commands/user/user-app-upgrade.js +106 -0
- package/dist/m365/teams/commands.js +2 -1
- package/dist/utils/md.js +2 -2
- package/docs/docs/cmd/entra/app/app-permission-remove.mdx +60 -0
- package/docs/docs/cmd/spo/site/site-admin-list.mdx +115 -0
- package/docs/docs/cmd/spo/tenant/tenant-site-archive.mdx +63 -0
- package/docs/docs/cmd/spo/tenant/tenant-site-unarchive.mdx +67 -0
- package/docs/docs/cmd/status.mdx +10 -9
- package/docs/docs/cmd/teams/user/user-app-upgrade.mdx +59 -0
- package/npm-shrinkwrap.json +181 -90
- package/package.json +16 -15
|
@@ -42,29 +42,27 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
42
42
|
const fileName = fsUtil.getSafeFileName(path.basename(fullPath));
|
|
43
43
|
let isCheckedOut = false;
|
|
44
44
|
let listSettings;
|
|
45
|
-
if (this.
|
|
46
|
-
await logger.logToStderr(`folder path: ${folderPath}...`);
|
|
47
|
-
}
|
|
48
|
-
if (this.debug) {
|
|
49
|
-
await logger.logToStderr('Check if the specified folder exists.');
|
|
50
|
-
await logger.logToStderr('');
|
|
51
|
-
}
|
|
52
|
-
if (this.debug) {
|
|
45
|
+
if (this.verbose) {
|
|
53
46
|
await logger.logToStderr(`file name: ${fileName}...`);
|
|
47
|
+
await logger.logToStderr(`folder path: ${folderPath}...`);
|
|
54
48
|
}
|
|
55
49
|
try {
|
|
56
50
|
try {
|
|
51
|
+
if (this.verbose) {
|
|
52
|
+
await logger.logToStderr('Check if the specified folder exists.');
|
|
53
|
+
}
|
|
57
54
|
const requestOptions = {
|
|
58
55
|
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')`,
|
|
59
56
|
headers: {
|
|
60
|
-
|
|
61
|
-
}
|
|
57
|
+
accept: 'application/json;odata=nometadata'
|
|
58
|
+
},
|
|
59
|
+
responseType: 'json'
|
|
62
60
|
};
|
|
63
61
|
await request.get(requestOptions);
|
|
64
62
|
}
|
|
65
63
|
catch (err) {
|
|
66
64
|
// folder does not exist so will attempt to create the folder tree
|
|
67
|
-
await spo.ensureFolder(args.options.webUrl, folderPath, logger, this.
|
|
65
|
+
await spo.ensureFolder(args.options.webUrl, folderPath, logger, this.verbose);
|
|
68
66
|
}
|
|
69
67
|
if (args.options.checkOut) {
|
|
70
68
|
await this.fileCheckOut(fileName, args.options.webUrl, folderPath);
|
|
@@ -77,7 +75,7 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
77
75
|
}
|
|
78
76
|
const fileStats = fs.statSync(fullPath);
|
|
79
77
|
const fileSize = fileStats.size;
|
|
80
|
-
if (this.
|
|
78
|
+
if (this.verbose) {
|
|
81
79
|
await logger.logToStderr(`File size is ${fileSize} bytes`);
|
|
82
80
|
}
|
|
83
81
|
// only up to 250 MB are allowed in a single request
|
|
@@ -91,8 +89,9 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
91
89
|
const requestOptions = {
|
|
92
90
|
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files/GetByPathOrAddStub(DecodedUrl='${formatting.encodeQueryParameter(fileName)}')/StartUpload(uploadId=guid'${uploadId}')`,
|
|
93
91
|
headers: {
|
|
94
|
-
|
|
95
|
-
}
|
|
92
|
+
accept: 'application/json;odata=nometadata'
|
|
93
|
+
},
|
|
94
|
+
responseType: 'json'
|
|
96
95
|
};
|
|
97
96
|
await request.post(requestOptions);
|
|
98
97
|
// session started successfully, now upload our file chunks
|
|
@@ -119,8 +118,9 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
119
118
|
const requestOptions = {
|
|
120
119
|
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files('${formatting.encodeQueryParameter(fileName)}')/cancelupload(uploadId=guid'${uploadId}')`,
|
|
121
120
|
headers: {
|
|
122
|
-
|
|
123
|
-
}
|
|
121
|
+
accept: 'application/json;odata=nometadata'
|
|
122
|
+
},
|
|
123
|
+
responseType: 'json'
|
|
124
124
|
};
|
|
125
125
|
try {
|
|
126
126
|
await request.post(requestOptions);
|
|
@@ -142,7 +142,7 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
142
142
|
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files/Add(url='${formatting.encodeQueryParameter(fileName)}', overwrite=true)`,
|
|
143
143
|
data: fileBody,
|
|
144
144
|
headers: {
|
|
145
|
-
|
|
145
|
+
accept: 'application/json;odata=nometadata',
|
|
146
146
|
'content-length': bodyLength
|
|
147
147
|
},
|
|
148
148
|
maxBodyLength: this.fileChunkingThreshold
|
|
@@ -165,12 +165,12 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
if (fieldsToUpdate.length > 0) {
|
|
168
|
-
// perform list item update and
|
|
168
|
+
// perform list item update and check-in
|
|
169
169
|
await this.validateUpdateListItem(args.options.webUrl, folderPath, fileName, fieldsToUpdate, logger, args.options.checkInComment);
|
|
170
170
|
}
|
|
171
171
|
else if (isCheckedOut) {
|
|
172
|
-
// perform
|
|
173
|
-
await this.fileCheckIn(args, fileName);
|
|
172
|
+
// perform check-in
|
|
173
|
+
await this.fileCheckIn(args.options.webUrl, folderPath, fileName, args.options.checkInComment);
|
|
174
174
|
}
|
|
175
175
|
// approve and publish cannot be used together
|
|
176
176
|
// when approve is used it will automatically publish the file
|
|
@@ -183,7 +183,7 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
183
183
|
const requestOptions = {
|
|
184
184
|
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files('${formatting.encodeQueryParameter(fileName)}')/approve(comment='${formatting.encodeQueryParameter(args.options.approveComment || '')}')`,
|
|
185
185
|
headers: {
|
|
186
|
-
|
|
186
|
+
accept: 'application/json;odata=nometadata'
|
|
187
187
|
},
|
|
188
188
|
responseType: 'json'
|
|
189
189
|
};
|
|
@@ -200,7 +200,7 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
200
200
|
const requestOptions = {
|
|
201
201
|
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files('${formatting.encodeQueryParameter(fileName)}')/publish(comment='${formatting.encodeQueryParameter(args.options.publishComment || '')}')`,
|
|
202
202
|
headers: {
|
|
203
|
-
|
|
203
|
+
accept: 'application/json;odata=nometadata'
|
|
204
204
|
},
|
|
205
205
|
responseType: 'json'
|
|
206
206
|
};
|
|
@@ -212,7 +212,11 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
212
212
|
// in a case the command has done checkout
|
|
213
213
|
// then have to rollback the checkout
|
|
214
214
|
const requestOptions = {
|
|
215
|
-
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files('${formatting.encodeQueryParameter(fileName)}')/UndoCheckOut()
|
|
215
|
+
url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files('${formatting.encodeQueryParameter(fileName)}')/UndoCheckOut()`,
|
|
216
|
+
headers: {
|
|
217
|
+
accept: 'application/json;odata=nometadata'
|
|
218
|
+
},
|
|
219
|
+
responseType: 'json'
|
|
216
220
|
};
|
|
217
221
|
try {
|
|
218
222
|
await request.post(requestOptions);
|
|
@@ -221,7 +225,6 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
221
225
|
if (this.verbose) {
|
|
222
226
|
await logger.logToStderr('Could not rollback file checkout');
|
|
223
227
|
await logger.logToStderr(err);
|
|
224
|
-
await logger.logToStderr('');
|
|
225
228
|
}
|
|
226
229
|
}
|
|
227
230
|
}
|
|
@@ -235,7 +238,7 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
235
238
|
const requestOptions = {
|
|
236
239
|
url: `${webUrl}/_api/web/lists('${listSettings.Id}')/contenttypes?$select=Name,Id`,
|
|
237
240
|
headers: {
|
|
238
|
-
|
|
241
|
+
accept: 'application/json;odata=nometadata'
|
|
239
242
|
},
|
|
240
243
|
responseType: 'json'
|
|
241
244
|
};
|
|
@@ -253,14 +256,15 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
253
256
|
const requestOptionsGetFile = {
|
|
254
257
|
url: `${webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folder)}')/Files('${formatting.encodeQueryParameter(fileName)}')`,
|
|
255
258
|
headers: {
|
|
256
|
-
|
|
257
|
-
}
|
|
259
|
+
accept: 'application/json;odata=nometadata'
|
|
260
|
+
},
|
|
261
|
+
responseType: 'json'
|
|
258
262
|
};
|
|
259
263
|
await request.get(requestOptionsGetFile);
|
|
260
264
|
const requestOptionsCheckOut = {
|
|
261
265
|
url: `${webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folder)}')/Files('${formatting.encodeQueryParameter(fileName)}')/CheckOut()`,
|
|
262
266
|
headers: {
|
|
263
|
-
|
|
267
|
+
accept: 'application/json;odata=nometadata'
|
|
264
268
|
},
|
|
265
269
|
responseType: 'json'
|
|
266
270
|
};
|
|
@@ -285,7 +289,7 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
285
289
|
url: `${info.WebUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(info.FolderPath)}')/Files('${formatting.encodeQueryParameter(info.Name)}')/${isLastChunk ? 'Finish' : 'Continue'}Upload(uploadId=guid'${info.Id}',fileOffset=${offset})`,
|
|
286
290
|
data: fileBuffer,
|
|
287
291
|
headers: {
|
|
288
|
-
|
|
292
|
+
accept: 'application/json;odata=nometadata',
|
|
289
293
|
'content-length': readCount
|
|
290
294
|
},
|
|
291
295
|
maxBodyLength: this.fileChunkingThreshold
|
|
@@ -341,7 +345,7 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
341
345
|
const requestOptions = {
|
|
342
346
|
url: `${webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folder)}')/Files('${formatting.encodeQueryParameter(fileName)}')/ListItemAllFields/ParentList?$Select=Id,EnableModeration,EnableVersioning,EnableMinorVersions`,
|
|
343
347
|
headers: {
|
|
344
|
-
|
|
348
|
+
accept: 'application/json;odata=nometadata'
|
|
345
349
|
},
|
|
346
350
|
responseType: 'json'
|
|
347
351
|
};
|
|
@@ -353,18 +357,17 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
353
357
|
}
|
|
354
358
|
const requestBody = {
|
|
355
359
|
formValues: fieldsToUpdate,
|
|
356
|
-
bNewDocumentUpdate: true, // true = will automatically
|
|
360
|
+
bNewDocumentUpdate: true, // true = will automatically check-in the item, but we will use it to perform system update and also do a check-in
|
|
357
361
|
checkInComment: checkInComment || ''
|
|
358
362
|
};
|
|
359
|
-
if (this.
|
|
360
|
-
await logger.logToStderr('ValidateUpdateListItem will perform the
|
|
361
|
-
await logger.logToStderr('');
|
|
363
|
+
if (this.verbose) {
|
|
364
|
+
await logger.logToStderr('ValidateUpdateListItem will perform the check-in ...');
|
|
362
365
|
}
|
|
363
366
|
// update the existing file list item fields
|
|
364
367
|
const requestOptions = {
|
|
365
368
|
url: `${webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderPath)}')/Files('${formatting.encodeQueryParameter(fileName)}')/ListItemAllFields/ValidateUpdateListItem()`,
|
|
366
369
|
headers: {
|
|
367
|
-
|
|
370
|
+
accept: 'application/json;odata=nometadata'
|
|
368
371
|
},
|
|
369
372
|
data: requestBody,
|
|
370
373
|
responseType: 'json'
|
|
@@ -379,11 +382,11 @@ class SpoFileAddCommand extends SpoCommand {
|
|
|
379
382
|
}
|
|
380
383
|
return;
|
|
381
384
|
}
|
|
382
|
-
async fileCheckIn(
|
|
385
|
+
async fileCheckIn(webUrl, folderUrl, fileName, checkInComment) {
|
|
383
386
|
const requestOptions = {
|
|
384
|
-
url: `${
|
|
387
|
+
url: `${webUrl}/_api/web/GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(folderUrl)}')/Files('${formatting.encodeQueryParameter(fileName)}')/CheckIn(comment='${formatting.encodeQueryParameter(checkInComment || '')}',checkintype=0)`,
|
|
385
388
|
headers: {
|
|
386
|
-
|
|
389
|
+
accept: 'application/json;odata=nometadata'
|
|
387
390
|
},
|
|
388
391
|
responseType: 'json'
|
|
389
392
|
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
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");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _SpoSiteAdminListCommand_instances, _SpoSiteAdminListCommand_initTelemetry, _SpoSiteAdminListCommand_initOptions, _SpoSiteAdminListCommand_initValidators, _SpoSiteAdminListCommand_initTypes;
|
|
7
|
+
import request from '../../../../request.js';
|
|
8
|
+
import { spo } from '../../../../utils/spo.js';
|
|
9
|
+
import { validation } from '../../../../utils/validation.js';
|
|
10
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
11
|
+
import commands from '../../commands.js';
|
|
12
|
+
import { ListPrincipalType } from '../list/ListPrincipalType.js';
|
|
13
|
+
class SpoSiteAdminListCommand extends SpoCommand {
|
|
14
|
+
get name() {
|
|
15
|
+
return commands.SITE_ADMIN_LIST;
|
|
16
|
+
}
|
|
17
|
+
get description() {
|
|
18
|
+
return 'Lists all administrators of a specific SharePoint site';
|
|
19
|
+
}
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
_SpoSiteAdminListCommand_instances.add(this);
|
|
23
|
+
__classPrivateFieldGet(this, _SpoSiteAdminListCommand_instances, "m", _SpoSiteAdminListCommand_initTelemetry).call(this);
|
|
24
|
+
__classPrivateFieldGet(this, _SpoSiteAdminListCommand_instances, "m", _SpoSiteAdminListCommand_initOptions).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _SpoSiteAdminListCommand_instances, "m", _SpoSiteAdminListCommand_initValidators).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _SpoSiteAdminListCommand_instances, "m", _SpoSiteAdminListCommand_initTypes).call(this);
|
|
27
|
+
}
|
|
28
|
+
async commandAction(logger, args) {
|
|
29
|
+
try {
|
|
30
|
+
if (args.options.asAdmin) {
|
|
31
|
+
await this.callActionAsAdmin(logger, args);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
await this.callAction(logger, args);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
this.handleRejectedODataJsonPromise(err);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async callActionAsAdmin(logger, args) {
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
await logger.logToStderr('Retrieving site administrators as an administrator...');
|
|
43
|
+
}
|
|
44
|
+
const adminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
45
|
+
const siteId = await this.getSiteId(args.options.siteUrl, logger);
|
|
46
|
+
const requestOptions = {
|
|
47
|
+
url: `${adminUrl}/_api/SPO.Tenant/GetSiteAdministrators?siteId='${siteId}'`,
|
|
48
|
+
headers: {
|
|
49
|
+
accept: 'application/json;odata=nometadata',
|
|
50
|
+
'content-type': 'application/json;charset=utf-8'
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const response = await request.post(requestOptions);
|
|
54
|
+
const responseContent = JSON.parse(response);
|
|
55
|
+
const primaryAdminLoginName = await this.getPrimaryAdminLoginNameFromAdmin(adminUrl, siteId);
|
|
56
|
+
const mappedResult = responseContent.value.map((u) => ({
|
|
57
|
+
Id: null,
|
|
58
|
+
Email: u.email,
|
|
59
|
+
LoginName: u.loginName,
|
|
60
|
+
Title: u.name,
|
|
61
|
+
PrincipalType: null,
|
|
62
|
+
PrincipalTypeString: null,
|
|
63
|
+
IsPrimaryAdmin: u.loginName === primaryAdminLoginName
|
|
64
|
+
}));
|
|
65
|
+
await logger.log(mappedResult);
|
|
66
|
+
}
|
|
67
|
+
async getSiteId(siteUrl, logger) {
|
|
68
|
+
const siteGraphId = await spo.getSiteId(siteUrl, logger, this.verbose);
|
|
69
|
+
const match = siteGraphId.match(/,([a-f0-9\-]{36}),/i);
|
|
70
|
+
if (!match) {
|
|
71
|
+
throw `Site with URL ${siteUrl} not found`;
|
|
72
|
+
}
|
|
73
|
+
return match[1];
|
|
74
|
+
}
|
|
75
|
+
async getPrimaryAdminLoginNameFromAdmin(adminUrl, siteId) {
|
|
76
|
+
const requestOptions = {
|
|
77
|
+
url: `${adminUrl}/_api/SPO.Tenant/sites('${siteId}')?$select=OwnerLoginName`,
|
|
78
|
+
headers: {
|
|
79
|
+
accept: 'application/json;odata=nometadata',
|
|
80
|
+
'content-type': 'application/json;charset=utf-8'
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const response = await request.get(requestOptions);
|
|
84
|
+
const responseContent = JSON.parse(response);
|
|
85
|
+
return responseContent.OwnerLoginName;
|
|
86
|
+
}
|
|
87
|
+
async callAction(logger, args) {
|
|
88
|
+
if (this.verbose) {
|
|
89
|
+
await logger.logToStderr('Retrieving site administrators...');
|
|
90
|
+
}
|
|
91
|
+
const requestOptions = {
|
|
92
|
+
url: `${args.options.siteUrl}/_api/web/siteusers?$filter=IsSiteAdmin eq true`,
|
|
93
|
+
method: 'GET',
|
|
94
|
+
headers: {
|
|
95
|
+
'accept': 'application/json;odata=nometadata'
|
|
96
|
+
},
|
|
97
|
+
responseType: 'json'
|
|
98
|
+
};
|
|
99
|
+
const responseContent = await request.get(requestOptions);
|
|
100
|
+
const primaryOwnerLogin = await this.getPrimaryOwnerLoginFromSite(args.options.siteUrl);
|
|
101
|
+
const mappedResult = responseContent.value.map((u) => ({
|
|
102
|
+
Id: u.Id,
|
|
103
|
+
LoginName: u.LoginName,
|
|
104
|
+
Title: u.Title,
|
|
105
|
+
PrincipalType: u.PrincipalType,
|
|
106
|
+
PrincipalTypeString: ListPrincipalType[u.PrincipalType],
|
|
107
|
+
Email: u.Email,
|
|
108
|
+
IsPrimaryAdmin: u.LoginName === primaryOwnerLogin
|
|
109
|
+
}));
|
|
110
|
+
await logger.log(mappedResult);
|
|
111
|
+
}
|
|
112
|
+
async getPrimaryOwnerLoginFromSite(siteUrl) {
|
|
113
|
+
const requestOptions = {
|
|
114
|
+
url: `${siteUrl}/_api/site/owner`,
|
|
115
|
+
method: 'GET',
|
|
116
|
+
headers: {
|
|
117
|
+
'accept': 'application/json;odata=nometadata'
|
|
118
|
+
},
|
|
119
|
+
responseType: 'json'
|
|
120
|
+
};
|
|
121
|
+
const responseContent = await request.get(requestOptions);
|
|
122
|
+
return responseContent?.LoginName ?? null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
_SpoSiteAdminListCommand_instances = new WeakSet(), _SpoSiteAdminListCommand_initTelemetry = function _SpoSiteAdminListCommand_initTelemetry() {
|
|
126
|
+
this.telemetry.push((args) => {
|
|
127
|
+
Object.assign(this.telemetryProperties, {
|
|
128
|
+
siteUrl: typeof args.options.siteUrl !== 'undefined',
|
|
129
|
+
asAdmin: !!args.options.asAdmin
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}, _SpoSiteAdminListCommand_initOptions = function _SpoSiteAdminListCommand_initOptions() {
|
|
133
|
+
this.options.unshift({
|
|
134
|
+
option: '-u, --siteUrl <siteUrl>'
|
|
135
|
+
}, {
|
|
136
|
+
option: '--asAdmin'
|
|
137
|
+
});
|
|
138
|
+
}, _SpoSiteAdminListCommand_initValidators = function _SpoSiteAdminListCommand_initValidators() {
|
|
139
|
+
this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.siteUrl));
|
|
140
|
+
}, _SpoSiteAdminListCommand_initTypes = function _SpoSiteAdminListCommand_initTypes() {
|
|
141
|
+
this.types.string.push('siteUrl');
|
|
142
|
+
};
|
|
143
|
+
export default new SpoSiteAdminListCommand();
|
|
144
|
+
//# sourceMappingURL=site-admin-list.js.map
|
|
@@ -430,33 +430,35 @@ class SpoSiteSetCommand extends SpoCommand {
|
|
|
430
430
|
_SpoSiteSetCommand_instances = new WeakSet(), _SpoSiteSetCommand_initTelemetry = function _SpoSiteSetCommand_initTelemetry() {
|
|
431
431
|
this.telemetry.push((args) => {
|
|
432
432
|
Object.assign(this.telemetryProperties, {
|
|
433
|
-
classification: typeof args.options.classification
|
|
434
|
-
disableFlows: args.options.disableFlows,
|
|
435
|
-
socialBarOnSitePagesDisabled: args.options.socialBarOnSitePagesDisabled,
|
|
436
|
-
isPublic: args.options.isPublic,
|
|
433
|
+
classification: typeof args.options.classification !== 'undefined',
|
|
434
|
+
disableFlows: !!args.options.disableFlows,
|
|
435
|
+
socialBarOnSitePagesDisabled: !!args.options.socialBarOnSitePagesDisabled,
|
|
436
|
+
isPublic: !!args.options.isPublic,
|
|
437
437
|
owners: typeof args.options.owners !== 'undefined',
|
|
438
|
-
shareByEmailEnabled: args.options.shareByEmailEnabled,
|
|
439
|
-
title: typeof args.options.title
|
|
440
|
-
description: typeof args.options.description
|
|
441
|
-
siteDesignId: typeof args.options.siteDesignId !== undefined,
|
|
442
|
-
sharingCapabilities: args.options.sharingCapability,
|
|
438
|
+
shareByEmailEnabled: !!args.options.shareByEmailEnabled,
|
|
439
|
+
title: typeof args.options.title !== 'undefined',
|
|
440
|
+
description: typeof args.options.description !== 'undefined',
|
|
441
|
+
siteDesignId: typeof args.options.siteDesignId !== 'undefined',
|
|
442
|
+
sharingCapabilities: typeof args.options.sharingCapability !== 'undefined',
|
|
443
443
|
siteLogoUrl: typeof args.options.siteLogoUrl !== 'undefined',
|
|
444
444
|
siteThumbnailUrl: typeof args.options.siteThumbnailUrl !== 'undefined',
|
|
445
|
-
resourceQuota: args.options.resourceQuota,
|
|
446
|
-
resourceQuotaWarningLevel: args.options.resourceQuotaWarningLevel,
|
|
447
|
-
storageQuota: args.options.storageQuota,
|
|
448
|
-
storageQuotaWarningLevel: args.options.storageQuotaWarningLevel,
|
|
449
|
-
allowSelfServiceUpgrade: args.options.allowSelfServiceUpgrade,
|
|
450
|
-
lockState: args.options.lockState,
|
|
451
|
-
noScriptSite: args.options.noScriptSite,
|
|
452
|
-
wait: args.options.wait
|
|
445
|
+
resourceQuota: typeof args.options.resourceQuota !== 'undefined',
|
|
446
|
+
resourceQuotaWarningLevel: typeof args.options.resourceQuotaWarningLevel !== 'undefined',
|
|
447
|
+
storageQuota: typeof args.options.storageQuota !== 'undefined',
|
|
448
|
+
storageQuotaWarningLevel: typeof args.options.storageQuotaWarningLevel !== 'undefined',
|
|
449
|
+
allowSelfServiceUpgrade: !!args.options.allowSelfServiceUpgrade,
|
|
450
|
+
lockState: typeof args.options.lockState !== 'undefined',
|
|
451
|
+
noScriptSite: !!args.options.noScriptSite,
|
|
452
|
+
wait: !!args.options.wait
|
|
453
453
|
});
|
|
454
454
|
});
|
|
455
455
|
}, _SpoSiteSetCommand_initOptions = function _SpoSiteSetCommand_initOptions() {
|
|
456
456
|
this.options.unshift({
|
|
457
457
|
option: '-u, --url <url>'
|
|
458
458
|
}, {
|
|
459
|
-
option: '-
|
|
459
|
+
option: '-t, --title [title]'
|
|
460
|
+
}, {
|
|
461
|
+
option: '-d, --description [description]'
|
|
460
462
|
}, {
|
|
461
463
|
option: '--classification [classification]'
|
|
462
464
|
}, {
|
|
@@ -476,16 +478,12 @@ _SpoSiteSetCommand_instances = new WeakSet(), _SpoSiteSetCommand_initTelemetry =
|
|
|
476
478
|
}, {
|
|
477
479
|
option: '--siteDesignId [siteDesignId]'
|
|
478
480
|
}, {
|
|
479
|
-
option: '--
|
|
480
|
-
|
|
481
|
-
option: '--description [description]'
|
|
481
|
+
option: '--sharingCapability [sharingCapability]',
|
|
482
|
+
autocomplete: this.sharingCapabilities
|
|
482
483
|
}, {
|
|
483
484
|
option: '--siteLogoUrl [siteLogoUrl]'
|
|
484
485
|
}, {
|
|
485
486
|
option: '--siteThumbnailUrl [siteThumbnailUrl]'
|
|
486
|
-
}, {
|
|
487
|
-
option: '--sharingCapability [sharingCapability]',
|
|
488
|
-
autocomplete: this.sharingCapabilities
|
|
489
487
|
}, {
|
|
490
488
|
option: '--resourceQuota [resourceQuota]'
|
|
491
489
|
}, {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
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");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _SpoTenantSiteArchiveCommand_instances, _SpoTenantSiteArchiveCommand_initTelemetry, _SpoTenantSiteArchiveCommand_initOptions, _SpoTenantSiteArchiveCommand_initValidators, _SpoTenantSiteArchiveCommand_initTypes;
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import config from '../../../../config.js';
|
|
9
|
+
import request from '../../../../request.js';
|
|
10
|
+
import { validation } from '../../../../utils/validation.js';
|
|
11
|
+
import { spo } from '../../../../utils/spo.js';
|
|
12
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
13
|
+
import commands from '../../commands.js';
|
|
14
|
+
class SpoTenantSiteArchiveCommand extends SpoCommand {
|
|
15
|
+
get name() {
|
|
16
|
+
return commands.TENANT_SITE_ARCHIVE;
|
|
17
|
+
}
|
|
18
|
+
get description() {
|
|
19
|
+
return 'Archives a site collection';
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
_SpoTenantSiteArchiveCommand_instances.add(this);
|
|
24
|
+
__classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initOptions).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initValidators).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initTypes).call(this);
|
|
28
|
+
}
|
|
29
|
+
async commandAction(logger, args) {
|
|
30
|
+
const archiveSite = async () => {
|
|
31
|
+
try {
|
|
32
|
+
if (this.verbose) {
|
|
33
|
+
await logger.logToStderr(`Archiving site ${args.options.url}...`);
|
|
34
|
+
}
|
|
35
|
+
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
|
|
36
|
+
const reqDigest = await spo.getRequestDigest(spoAdminUrl);
|
|
37
|
+
const requestOptions = {
|
|
38
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
39
|
+
headers: {
|
|
40
|
+
'X-RequestDigest': reqDigest.FormDigestValue
|
|
41
|
+
},
|
|
42
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
|
|
43
|
+
<Actions>
|
|
44
|
+
<ObjectPath Id="2" ObjectPathId="1" />
|
|
45
|
+
<ObjectPath Id="4" ObjectPathId="3" />
|
|
46
|
+
<Query Id="5" ObjectPathId="3">
|
|
47
|
+
<Query SelectAllProperties="true">
|
|
48
|
+
<Properties />
|
|
49
|
+
</Query>
|
|
50
|
+
</Query>
|
|
51
|
+
</Actions>
|
|
52
|
+
<ObjectPaths>
|
|
53
|
+
<Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" />
|
|
54
|
+
<Method Id="3" ParentId="1" Name="ArchiveSiteByUrl">
|
|
55
|
+
<Parameters>
|
|
56
|
+
<Parameter Type="String">${args.options.url}</Parameter>
|
|
57
|
+
</Parameters>
|
|
58
|
+
</Method>
|
|
59
|
+
</ObjectPaths>
|
|
60
|
+
</Request>`
|
|
61
|
+
};
|
|
62
|
+
const res = await request.post(requestOptions);
|
|
63
|
+
const json = JSON.parse(res);
|
|
64
|
+
const response = json[0];
|
|
65
|
+
if (response.ErrorInfo) {
|
|
66
|
+
throw response.ErrorInfo.ErrorMessage;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
this.handleRejectedPromise(err);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
if (args.options.force) {
|
|
74
|
+
await archiveSite();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to archive site '${args.options.url}'?` });
|
|
78
|
+
if (result) {
|
|
79
|
+
await archiveSite();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
_SpoTenantSiteArchiveCommand_instances = new WeakSet(), _SpoTenantSiteArchiveCommand_initTelemetry = function _SpoTenantSiteArchiveCommand_initTelemetry() {
|
|
85
|
+
this.telemetry.push((args) => {
|
|
86
|
+
Object.assign(this.telemetryProperties, {
|
|
87
|
+
force: !!args.options.force
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}, _SpoTenantSiteArchiveCommand_initOptions = function _SpoTenantSiteArchiveCommand_initOptions() {
|
|
91
|
+
this.options.unshift({ option: '-u, --url <url>' }, { option: '-f, --force' });
|
|
92
|
+
}, _SpoTenantSiteArchiveCommand_initValidators = function _SpoTenantSiteArchiveCommand_initValidators() {
|
|
93
|
+
this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.url));
|
|
94
|
+
}, _SpoTenantSiteArchiveCommand_initTypes = function _SpoTenantSiteArchiveCommand_initTypes() {
|
|
95
|
+
this.types.string.push('url');
|
|
96
|
+
this.types.boolean.push('force');
|
|
97
|
+
};
|
|
98
|
+
export default new SpoTenantSiteArchiveCommand();
|
|
99
|
+
//# sourceMappingURL=tenant-site-archive.js.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
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");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _SpoTenantSiteUnarchiveCommand_instances, _SpoTenantSiteUnarchiveCommand_initTelemetry, _SpoTenantSiteUnarchiveCommand_initOptions, _SpoTenantSiteUnarchiveCommand_initValidators, _SpoTenantSiteUnarchiveCommand_initTypes;
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import config from '../../../../config.js';
|
|
9
|
+
import request from '../../../../request.js';
|
|
10
|
+
import { spo } from '../../../../utils/spo.js';
|
|
11
|
+
import { validation } from '../../../../utils/validation.js';
|
|
12
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
13
|
+
import commands from '../../commands.js';
|
|
14
|
+
class SpoTenantSiteUnarchiveCommand extends SpoCommand {
|
|
15
|
+
get name() {
|
|
16
|
+
return commands.TENANT_SITE_UNARCHIVE;
|
|
17
|
+
}
|
|
18
|
+
get description() {
|
|
19
|
+
return 'Unarchives a site collection';
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
_SpoTenantSiteUnarchiveCommand_instances.add(this);
|
|
24
|
+
__classPrivateFieldGet(this, _SpoTenantSiteUnarchiveCommand_instances, "m", _SpoTenantSiteUnarchiveCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _SpoTenantSiteUnarchiveCommand_instances, "m", _SpoTenantSiteUnarchiveCommand_initOptions).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _SpoTenantSiteUnarchiveCommand_instances, "m", _SpoTenantSiteUnarchiveCommand_initValidators).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _SpoTenantSiteUnarchiveCommand_instances, "m", _SpoTenantSiteUnarchiveCommand_initTypes).call(this);
|
|
28
|
+
}
|
|
29
|
+
async commandAction(logger, args) {
|
|
30
|
+
if (args.options.force) {
|
|
31
|
+
await this.unarchiveSite(logger, args.options.url);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to unarchive site '${args.options.url}'? This may cause additional billing costs.` });
|
|
35
|
+
if (result) {
|
|
36
|
+
await this.unarchiveSite(logger, args.options.url);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async unarchiveSite(logger, url) {
|
|
41
|
+
if (this.verbose) {
|
|
42
|
+
await logger.logToStderr(`Unarchiving site '${url}'...`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const adminCenterUrl = await spo.getSpoAdminUrl(logger, this.verbose);
|
|
46
|
+
const requestDigest = await spo.getRequestDigest(adminCenterUrl);
|
|
47
|
+
const requestOptions = {
|
|
48
|
+
url: `${adminCenterUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
49
|
+
headers: {
|
|
50
|
+
'X-RequestDigest': requestDigest.FormDigestValue
|
|
51
|
+
},
|
|
52
|
+
data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
|
|
53
|
+
<Actions>
|
|
54
|
+
<ObjectPath Id="2" ObjectPathId="1" />
|
|
55
|
+
<ObjectPath Id="4" ObjectPathId="3" />
|
|
56
|
+
</Actions>
|
|
57
|
+
<ObjectPaths>
|
|
58
|
+
<Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" />
|
|
59
|
+
<Method Id="3" ParentId="1" Name="UnarchiveSiteByUrl">
|
|
60
|
+
<Parameters>
|
|
61
|
+
<Parameter Type="String">${url}</Parameter>
|
|
62
|
+
</Parameters>
|
|
63
|
+
</Method>
|
|
64
|
+
</ObjectPaths>
|
|
65
|
+
</Request>`
|
|
66
|
+
};
|
|
67
|
+
const response = await request.post(requestOptions);
|
|
68
|
+
const json = JSON.parse(response);
|
|
69
|
+
const responseContent = json[0];
|
|
70
|
+
if (responseContent.ErrorInfo) {
|
|
71
|
+
throw responseContent.ErrorInfo.ErrorMessage;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
this.handleRejectedPromise(err);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
_SpoTenantSiteUnarchiveCommand_instances = new WeakSet(), _SpoTenantSiteUnarchiveCommand_initTelemetry = function _SpoTenantSiteUnarchiveCommand_initTelemetry() {
|
|
80
|
+
this.telemetry.push((args) => {
|
|
81
|
+
Object.assign(this.telemetryProperties, {
|
|
82
|
+
force: !!args.options.force
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}, _SpoTenantSiteUnarchiveCommand_initOptions = function _SpoTenantSiteUnarchiveCommand_initOptions() {
|
|
86
|
+
this.options.unshift({
|
|
87
|
+
option: '-u, --url <url>'
|
|
88
|
+
}, {
|
|
89
|
+
option: '-f, --force'
|
|
90
|
+
});
|
|
91
|
+
}, _SpoTenantSiteUnarchiveCommand_initValidators = function _SpoTenantSiteUnarchiveCommand_initValidators() {
|
|
92
|
+
this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.url));
|
|
93
|
+
}, _SpoTenantSiteUnarchiveCommand_initTypes = function _SpoTenantSiteUnarchiveCommand_initTypes() {
|
|
94
|
+
this.types.string.push('url');
|
|
95
|
+
this.types.boolean.push('force');
|
|
96
|
+
};
|
|
97
|
+
export default new SpoTenantSiteUnarchiveCommand();
|
|
98
|
+
//# sourceMappingURL=tenant-site-unarchive.js.map
|
|
@@ -239,6 +239,7 @@ export default {
|
|
|
239
239
|
SERVICEPRINCIPAL_SET: `${prefix} serviceprincipal set`,
|
|
240
240
|
SET: `${prefix} set`,
|
|
241
241
|
SITE_ADD: `${prefix} site add`,
|
|
242
|
+
SITE_ADMIN_LIST: `${prefix} site admin list`,
|
|
242
243
|
SITE_APPCATALOG_ADD: `${prefix} site appcatalog add`,
|
|
243
244
|
SITE_APPCATALOG_LIST: `${prefix} site appcatalog list`,
|
|
244
245
|
SITE_APPCATALOG_REMOVE: `${prefix} site appcatalog remove`,
|
|
@@ -312,6 +313,8 @@ export default {
|
|
|
312
313
|
TENANT_RECYCLEBINITEM_RESTORE: `${prefix} tenant recyclebinitem restore`,
|
|
313
314
|
TENANT_SETTINGS_LIST: `${prefix} tenant settings list`,
|
|
314
315
|
TENANT_SETTINGS_SET: `${prefix} tenant settings set`,
|
|
316
|
+
TENANT_SITE_ARCHIVE: `${prefix} tenant site archive`,
|
|
317
|
+
TENANT_SITE_UNARCHIVE: `${prefix} tenant site unarchive`,
|
|
315
318
|
TERM_ADD: `${prefix} term add`,
|
|
316
319
|
TERM_GET: `${prefix} term get`,
|
|
317
320
|
TERM_LIST: `${prefix} term list`,
|