@pnp/cli-microsoft365 7.10.0-beta.a743796 → 7.10.0-beta.ebb7426
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-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 +2 -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/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
|
};
|
|
@@ -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
|
|
@@ -312,6 +312,8 @@ export default {
|
|
|
312
312
|
TENANT_RECYCLEBINITEM_RESTORE: `${prefix} tenant recyclebinitem restore`,
|
|
313
313
|
TENANT_SETTINGS_LIST: `${prefix} tenant settings list`,
|
|
314
314
|
TENANT_SETTINGS_SET: `${prefix} tenant settings set`,
|
|
315
|
+
TENANT_SITE_ARCHIVE: `${prefix} tenant site archive`,
|
|
316
|
+
TENANT_SITE_UNARCHIVE: `${prefix} tenant site unarchive`,
|
|
315
317
|
TERM_ADD: `${prefix} term add`,
|
|
316
318
|
TERM_GET: `${prefix} term get`,
|
|
317
319
|
TERM_LIST: `${prefix} term list`,
|
|
@@ -26,24 +26,24 @@ class TeamsUserAppAddCommand extends GraphCommand {
|
|
|
26
26
|
__classPrivateFieldGet(this, _TeamsUserAppAddCommand_instances, "m", _TeamsUserAppAddCommand_initOptionSets).call(this);
|
|
27
27
|
}
|
|
28
28
|
async commandAction(logger, args) {
|
|
29
|
-
const appId = await this.getAppId(args);
|
|
30
|
-
const userId = (args.options.userId ?? args.options.userName);
|
|
31
|
-
const endpoint = `${this.resource}/v1.0`;
|
|
32
|
-
if (this.verbose) {
|
|
33
|
-
await logger.logToStderr(`Removing app with ID ${appId} for user ${args.options.userId}`);
|
|
34
|
-
}
|
|
35
|
-
const requestOptions = {
|
|
36
|
-
url: `${endpoint}/users/${formatting.encodeQueryParameter(userId)}/teamwork/installedApps`,
|
|
37
|
-
headers: {
|
|
38
|
-
'content-type': 'application/json;odata=nometadata',
|
|
39
|
-
'accept': 'application/json;odata.metadata=none'
|
|
40
|
-
},
|
|
41
|
-
responseType: 'json',
|
|
42
|
-
data: {
|
|
43
|
-
'teamsApp@odata.bind': `${endpoint}/appCatalogs/teamsApps/${appId}`
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
29
|
try {
|
|
30
|
+
const appId = await this.getAppId(args);
|
|
31
|
+
const userId = (args.options.userId ?? args.options.userName);
|
|
32
|
+
const endpoint = `${this.resource}/v1.0`;
|
|
33
|
+
if (this.verbose) {
|
|
34
|
+
await logger.logToStderr(`Adding app with ID ${appId} for user ${args.options.userId}`);
|
|
35
|
+
}
|
|
36
|
+
const requestOptions = {
|
|
37
|
+
url: `${endpoint}/users/${formatting.encodeQueryParameter(userId)}/teamwork/installedApps`,
|
|
38
|
+
headers: {
|
|
39
|
+
'content-type': 'application/json;odata=nometadata',
|
|
40
|
+
'accept': 'application/json;odata.metadata=none'
|
|
41
|
+
},
|
|
42
|
+
responseType: 'json',
|
|
43
|
+
data: {
|
|
44
|
+
'teamsApp@odata.bind': `${endpoint}/appCatalogs/teamsApps/${appId}`
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
47
|
await request.post(requestOptions);
|
|
48
48
|
}
|
|
49
49
|
catch (err) {
|
|
@@ -0,0 +1,106 @@
|
|
|
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 _TeamsUserAppUpgradeCommand_instances, _TeamsUserAppUpgradeCommand_initTelemetry, _TeamsUserAppUpgradeCommand_initOptions, _TeamsUserAppUpgradeCommand_initValidators, _TeamsUserAppUpgradeCommand_initOptionSets, _TeamsUserAppUpgradeCommand_initTypes;
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import request from '../../../../request.js';
|
|
9
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
10
|
+
import { odata } from '../../../../utils/odata.js';
|
|
11
|
+
import { validation } from '../../../../utils/validation.js';
|
|
12
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
13
|
+
import commands from '../../commands.js';
|
|
14
|
+
class TeamsUserAppUpgradeCommand extends GraphCommand {
|
|
15
|
+
get name() {
|
|
16
|
+
return commands.USER_APP_UPGRADE;
|
|
17
|
+
}
|
|
18
|
+
get description() {
|
|
19
|
+
return 'Upgrade an app in the personal scope of the specified user';
|
|
20
|
+
}
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
_TeamsUserAppUpgradeCommand_instances.add(this);
|
|
24
|
+
__classPrivateFieldGet(this, _TeamsUserAppUpgradeCommand_instances, "m", _TeamsUserAppUpgradeCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _TeamsUserAppUpgradeCommand_instances, "m", _TeamsUserAppUpgradeCommand_initOptions).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _TeamsUserAppUpgradeCommand_instances, "m", _TeamsUserAppUpgradeCommand_initValidators).call(this);
|
|
27
|
+
__classPrivateFieldGet(this, _TeamsUserAppUpgradeCommand_instances, "m", _TeamsUserAppUpgradeCommand_initOptionSets).call(this);
|
|
28
|
+
__classPrivateFieldGet(this, _TeamsUserAppUpgradeCommand_instances, "m", _TeamsUserAppUpgradeCommand_initTypes).call(this);
|
|
29
|
+
}
|
|
30
|
+
async commandAction(logger, args) {
|
|
31
|
+
try {
|
|
32
|
+
if (this.verbose) {
|
|
33
|
+
await logger.logToStderr(`Upgrading app ${args.options.id || args.options.name} for user ${args.options.userId || args.options.userName}`);
|
|
34
|
+
}
|
|
35
|
+
const installedAppId = await this.getInstalledAppId(args.options, logger);
|
|
36
|
+
const requestOptions = {
|
|
37
|
+
url: `${this.resource}/v1.0/users/${formatting.encodeQueryParameter(args.options.userId || args.options.userName)}/teamwork/installedApps/${installedAppId}/upgrade`,
|
|
38
|
+
headers: {
|
|
39
|
+
'accept': 'application/json;odata.metadata=none'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
await request.post(requestOptions);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
this.handleRejectedODataJsonPromise(err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async getInstalledAppId(options, logger) {
|
|
49
|
+
if (this.verbose) {
|
|
50
|
+
await logger.logToStderr(`Retrieving app ID`);
|
|
51
|
+
}
|
|
52
|
+
if (options.id) {
|
|
53
|
+
return options.id;
|
|
54
|
+
}
|
|
55
|
+
const installedApps = await odata.getAllItems(`${this.resource}/v1.0/users/${formatting.encodeQueryParameter(options.userId || options.userName)}/teamwork/installedApps?$expand=teamsAppDefinition&$filter=teamsAppDefinition/displayName eq '${formatting.encodeQueryParameter(options.name)}'&$select=id`);
|
|
56
|
+
if (installedApps.length === 1) {
|
|
57
|
+
return installedApps[0].id;
|
|
58
|
+
}
|
|
59
|
+
if (installedApps.length === 0) {
|
|
60
|
+
throw `The specified Teams app ${options.name} does not exist or is not installed for the user`;
|
|
61
|
+
}
|
|
62
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', installedApps);
|
|
63
|
+
const result = (await cli.handleMultipleResultsFound(`Multiple installed Teams apps with name '${options.name}' found.`, resultAsKeyValuePair));
|
|
64
|
+
return result.id;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_TeamsUserAppUpgradeCommand_instances = new WeakSet(), _TeamsUserAppUpgradeCommand_initTelemetry = function _TeamsUserAppUpgradeCommand_initTelemetry() {
|
|
68
|
+
this.telemetry.push((args) => {
|
|
69
|
+
Object.assign(this.telemetryProperties, {
|
|
70
|
+
id: typeof args.options.id !== 'undefined',
|
|
71
|
+
name: typeof args.options.name !== 'undefined',
|
|
72
|
+
userId: typeof args.options.userId !== 'undefined',
|
|
73
|
+
userName: typeof args.options.userName !== 'undefined'
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}, _TeamsUserAppUpgradeCommand_initOptions = function _TeamsUserAppUpgradeCommand_initOptions() {
|
|
77
|
+
this.options.unshift({
|
|
78
|
+
option: '--id [id]'
|
|
79
|
+
}, {
|
|
80
|
+
option: '--name [name]'
|
|
81
|
+
}, {
|
|
82
|
+
option: '--userId [userId]'
|
|
83
|
+
}, {
|
|
84
|
+
option: '--userName [userName]'
|
|
85
|
+
});
|
|
86
|
+
}, _TeamsUserAppUpgradeCommand_initValidators = function _TeamsUserAppUpgradeCommand_initValidators() {
|
|
87
|
+
this.validators.push(async (args) => {
|
|
88
|
+
if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
|
|
89
|
+
return `${args.options.userId} is not a valid GUID`;
|
|
90
|
+
}
|
|
91
|
+
if (args.options.userName && !validation.isValidUserPrincipalName(args.options.userName)) {
|
|
92
|
+
return `${args.options.userName} is not a valid userName`;
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
});
|
|
96
|
+
}, _TeamsUserAppUpgradeCommand_initOptionSets = function _TeamsUserAppUpgradeCommand_initOptionSets() {
|
|
97
|
+
this.optionSets.push({
|
|
98
|
+
options: ['id', 'name']
|
|
99
|
+
}, {
|
|
100
|
+
options: ['userId', 'userName']
|
|
101
|
+
});
|
|
102
|
+
}, _TeamsUserAppUpgradeCommand_initTypes = function _TeamsUserAppUpgradeCommand_initTypes() {
|
|
103
|
+
this.types.string.push('id', 'name', 'userId', 'userName');
|
|
104
|
+
};
|
|
105
|
+
export default new TeamsUserAppUpgradeCommand();
|
|
106
|
+
//# sourceMappingURL=user-app-upgrade.js.map
|