@pnp/cli-microsoft365 11.0.0-beta.1f852eb → 11.0.0-beta.3143306
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/.devproxy/api-specs/sharepoint.yaml +54 -0
- package/.eslintrc.cjs +2 -0
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Command.js +4 -0
- package/dist/config.js +1 -0
- package/dist/m365/adaptivecard/commands/adaptivecard-send.js +1 -1
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-add.js +13 -27
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-get.js +18 -43
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-list.js +10 -21
- package/dist/m365/entra/commands/administrativeunit/administrativeunit-remove.js +25 -49
- package/dist/m365/entra/commands/app/app-add.js +14 -2
- package/dist/m365/entra/commands/group/group-member-add.js +6 -27
- package/dist/m365/entra/commands/group/group-member-set.js +5 -26
- package/dist/m365/entra/commands/m365group/m365group-get.js +1 -7
- package/dist/m365/entra/commands/m365group/m365group-list.js +1 -7
- package/dist/m365/entra/commands/pim/pim-role-assignment-eligibility-list.js +1 -7
- package/dist/m365/entra/commands/pim/pim-role-assignment-list.js +1 -7
- package/dist/m365/entra/commands/pim/pim-role-request-list.js +1 -7
- package/dist/m365/entra/commands/roleassignment/roleassignment-add.js +146 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/flow/commands/environment/environment-get.js +19 -29
- package/dist/m365/flow/commands/flow-list.js +7 -14
- package/dist/m365/flow/commands/run/run-get.js +1 -7
- package/dist/m365/graph/commands/openextension/openextension-add.js +2 -2
- package/dist/m365/graph/commands/openextension/openextension-set.js +2 -6
- package/dist/m365/graph/commands/subscription/subscription-add.js +3 -10
- package/dist/m365/outlook/commands/mail/mail-searchfolder-add.js +85 -0
- package/dist/m365/outlook/commands.js +1 -0
- package/dist/m365/pa/commands/environment/environment-get.js +18 -23
- package/dist/m365/pp/commands/copilot/copilot-get.js +0 -4
- package/dist/m365/pp/commands/copilot/copilot-list.js +0 -4
- package/dist/m365/pp/commands/copilot/copilot-remove.js +0 -4
- package/dist/m365/pp/commands/environment/environment-get.js +19 -26
- package/dist/m365/pp/commands/solution/solution-publisher-list.js +1 -8
- package/dist/m365/pp/commands.js +0 -7
- package/dist/m365/purview/commands/threatassessment/threatassessment-get.js +1 -7
- package/dist/m365/spe/commands/container/container-add.js +1 -3
- package/dist/m365/spe/commands/container/container-list.js +1 -3
- package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +1 -3
- package/dist/m365/spe/commands/container/container-recyclebinitem-restore.js +1 -3
- package/dist/m365/spe/commands/container/container-remove.js +1 -3
- package/dist/m365/spe/commands/containertype/containertype-add.js +67 -90
- package/dist/m365/spe/commands/containertype/containertype-get.js +53 -81
- package/dist/m365/spe/commands/containertype/containertype-list.js +8 -19
- package/dist/m365/spe/commands/containertype/containertype-remove.js +27 -5
- package/dist/m365/spfx/commands/project/project-upgrade.js +23 -66
- package/dist/m365/spo/commands/customaction/customaction-list.js +3 -10
- package/dist/m365/spo/commands/file/file-move.js +2 -8
- package/dist/m365/spo/commands/file/file-version-keep.js +78 -0
- package/dist/m365/spo/commands/homesite/homesite-add.js +26 -2
- package/dist/m365/spo/commands/homesite/homesite-get.js +28 -14
- package/dist/m365/spo/commands/homesite/homesite-list.js +1 -12
- package/dist/m365/spo/commands/homesite/homesite-remove.js +6 -34
- package/dist/m365/spo/commands/homesite/homesite-set.js +88 -44
- package/dist/m365/spo/commands/hubsite/hubsite-get.js +4 -13
- package/dist/m365/spo/commands/hubsite/hubsite-list.js +1 -8
- package/dist/m365/spo/commands/list/list-view-add.js +1 -1
- package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-grant-list.js +17 -25
- package/dist/m365/spo/commands/{tenant/tenant-site-archive.js → site/site-archive.js} +14 -14
- package/dist/m365/spo/commands/{tenant/tenant-site-list.js → site/site-list.js} +16 -27
- package/dist/m365/spo/commands/{tenant/tenant-site-membership-list.js → site/site-membership-list.js} +15 -15
- package/dist/m365/spo/commands/{tenant/tenant-site-rename.js → site/site-rename.js} +14 -14
- package/dist/m365/spo/commands/{tenant/tenant-site-unarchive.js → site/site-unarchive.js} +14 -14
- package/dist/m365/spo/commands/term/term-list.js +1 -7
- package/dist/m365/spo/commands.js +5 -7
- package/dist/m365/teams/commands/chat/chat-member-add.js +3 -9
- package/dist/m365/teams/commands/report/report-directroutingcalls.js +5 -12
- package/dist/m365/teams/commands/report/report-pstncalls.js +5 -12
- package/dist/m365/viva/commands/engage/engage-network-list.js +1 -7
- package/dist/m365/viva/commands.js +0 -3
- package/dist/utils/entraAdministrativeUnit.js +1 -1
- package/dist/utils/entraApp.js +15 -0
- package/dist/utils/spe.js +5 -39
- package/docs/docs/cmd/entra/app/app-add.mdx +7 -1
- package/docs/docs/cmd/entra/group/group-member-add.mdx +7 -26
- package/docs/docs/cmd/entra/group/group-member-set.mdx +5 -23
- package/docs/docs/cmd/entra/m365group/m365group-get.mdx +0 -3
- package/docs/docs/cmd/entra/m365group/m365group-list.mdx +0 -3
- package/docs/docs/cmd/entra/pim/pim-role-assignment-eligibility-list.mdx +0 -3
- package/docs/docs/cmd/entra/pim/pim-role-assignment-list.mdx +0 -3
- package/docs/docs/cmd/entra/pim/pim-role-request-list.mdx +0 -3
- package/docs/docs/cmd/entra/roleassignment/roleassignment-add.mdx +163 -0
- package/docs/docs/cmd/flow/environment/environment-get.mdx +6 -5
- package/docs/docs/cmd/flow/flow-list.mdx +0 -3
- package/docs/docs/cmd/flow/run/run-get.mdx +0 -3
- package/docs/docs/cmd/graph/subscription/subscription-add.mdx +0 -3
- package/docs/docs/cmd/outlook/mail/mail-searchfolder-add.mdx +147 -0
- package/docs/docs/cmd/pa/environment/environment-get.mdx +5 -2
- package/docs/docs/cmd/pp/copilot/copilot-get.mdx +0 -6
- package/docs/docs/cmd/pp/copilot/copilot-list.mdx +0 -6
- package/docs/docs/cmd/pp/copilot/copilot-remove.mdx +0 -6
- package/docs/docs/cmd/pp/environment/environment-get.mdx +5 -2
- package/docs/docs/cmd/pp/solution/solution-publisher-list.mdx +0 -3
- package/docs/docs/cmd/purview/threatassessment/threatassessment-get.mdx +0 -3
- package/docs/docs/cmd/spe/container/container-activate.mdx +21 -0
- package/docs/docs/cmd/spe/container/container-add.mdx +29 -0
- package/docs/docs/cmd/spe/container/container-get.mdx +20 -1
- package/docs/docs/cmd/spe/container/container-list.mdx +29 -0
- package/docs/docs/cmd/spe/container/container-permission-list.mdx +19 -0
- package/docs/docs/cmd/spe/container/container-recyclebinitem-list.mdx +29 -0
- package/docs/docs/cmd/spe/container/container-recyclebinitem-restore.mdx +31 -0
- package/docs/docs/cmd/spe/container/container-remove.mdx +31 -0
- package/docs/docs/cmd/spe/containertype/containertype-add.mdx +111 -55
- package/docs/docs/cmd/spe/containertype/containertype-get.mdx +69 -38
- package/docs/docs/cmd/spe/containertype/containertype-list.mdx +59 -31
- package/docs/docs/cmd/spe/containertype/containertype-remove.mdx +31 -4
- package/docs/docs/cmd/spfx/project/project-upgrade.mdx +18 -5
- package/docs/docs/cmd/spo/file/file-move.mdx +0 -3
- package/docs/docs/cmd/spo/file/file-version-keep.mdx +68 -0
- package/docs/docs/cmd/spo/homesite/homesite-add.mdx +13 -4
- package/docs/docs/cmd/spo/homesite/homesite-get.mdx +44 -23
- package/docs/docs/cmd/spo/homesite/homesite-list.mdx +0 -6
- package/docs/docs/cmd/spo/homesite/homesite-remove.mdx +10 -35
- package/docs/docs/cmd/spo/homesite/homesite-set.mdx +84 -44
- package/docs/docs/cmd/spo/hubsite/hubsite-get.mdx +0 -3
- package/docs/docs/cmd/spo/hubsite/hubsite-list.mdx +0 -3
- package/docs/docs/cmd/spo/list/list-view-add.mdx +11 -11
- package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-list.mdx +18 -18
- package/docs/docs/cmd/spo/{tenant/tenant-site-archive.mdx → site/site-archive.mdx} +4 -4
- package/docs/docs/cmd/spo/{tenant/tenant-site-list.mdx → site/site-list.mdx} +7 -16
- package/docs/docs/cmd/spo/{tenant/tenant-site-membership-list.mdx → site/site-membership-list.mdx} +5 -5
- package/docs/docs/cmd/spo/{tenant/tenant-site-rename.mdx → site/site-rename.mdx} +7 -7
- package/docs/docs/cmd/spo/{tenant/tenant-site-unarchive.mdx → site/site-unarchive.mdx} +4 -4
- package/docs/docs/cmd/spo/term/term-list.mdx +0 -3
- package/docs/docs/cmd/teams/chat/chat-member-add.mdx +2 -5
- package/docs/docs/cmd/teams/report/report-directroutingcalls.mdx +25 -44
- package/docs/docs/cmd/teams/report/report-pstncalls.mdx +25 -48
- package/docs/docs/cmd/viva/engage/engage-community-list.mdx +19 -0
- package/docs/docs/cmd/viva/engage/engage-community-user-add.mdx +19 -0
- package/docs/docs/cmd/viva/engage/engage-community-user-remove.mdx +19 -0
- package/docs/docs/cmd/viva/engage/engage-network-list.mdx +0 -3
- package/npm-shrinkwrap.json +51 -51
- package/package.json +12 -12
- package/dist/m365/pp/commands/card/card-clone.js +0 -101
- package/dist/m365/pp/commands/card/card-get.js +0 -89
- package/dist/m365/pp/commands/card/card-list.js +0 -55
- package/dist/m365/pp/commands/card/card-remove.js +0 -105
- package/dist/m365/skype/commands/report/report-activitycounts.js +0 -15
- package/dist/m365/skype/commands/report/report-activityusercounts.js +0 -15
- package/dist/m365/skype/commands/report/report-activityuserdetail.js +0 -15
- package/dist/m365/skype/commands.js +0 -7
- package/dist/m365/spo/commands/mail/mail-send.js +0 -108
- package/dist/m365/spo/commands/tenant/SPOTenantSitePropertiesEnumerable.js +0 -2
- package/dist/m365/spo/commands/tenant/TenantSiteProperties.js +0 -2
- package/dist/m365/viva/commands/engage/engage-group-list.js +0 -93
- package/dist/m365/viva/commands/engage/engage-group-user-add.js +0 -73
- package/dist/m365/viva/commands/engage/engage-group-user-remove.js +0 -88
- package/docs/docs/cmd/pp/card/card-clone.mdx +0 -103
- package/docs/docs/cmd/pp/card/card-get.mdx +0 -212
- package/docs/docs/cmd/pp/card/card-list.mdx +0 -163
- package/docs/docs/cmd/pp/card/card-remove.mdx +0 -86
- package/docs/docs/cmd/skype/report/report-activitycounts.mdx +0 -96
- package/docs/docs/cmd/skype/report/report-activityusercounts.mdx +0 -96
- package/docs/docs/cmd/skype/report/report-activityuserdetail.mdx +0 -134
- package/docs/docs/cmd/spo/mail/mail-send.mdx +0 -69
- package/docs/docs/cmd/viva/engage/engage-group-list.mdx +0 -174
- package/docs/docs/cmd/viva/engage/engage-group-user-add.mdx +0 -60
- package/docs/docs/cmd/viva/engage/engage-group-user-remove.mdx +0 -58
|
@@ -1,99 +1,71 @@
|
|
|
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 _SpeContainerTypeGetCommand_instances, _SpeContainerTypeGetCommand_initTelemetry, _SpeContainerTypeGetCommand_initOptions, _SpeContainerTypeGetCommand_initOptionSets, _SpeContainerTypeGetCommand_initValidators, _SpeContainerTypeGetCommand_initTypes;
|
|
7
|
-
import config from '../../../../config.js';
|
|
8
|
-
import request from '../../../../request.js';
|
|
9
|
-
import { spe } from '../../../../utils/spe.js';
|
|
10
|
-
import { spo } from '../../../../utils/spo.js';
|
|
11
1
|
import { validation } from '../../../../utils/validation.js';
|
|
12
|
-
import SpoCommand from '../../../base/SpoCommand.js';
|
|
13
2
|
import commands from '../../commands.js';
|
|
14
|
-
|
|
3
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { zod } from '../../../../utils/zod.js';
|
|
6
|
+
import GraphDelegatedCommand from '../../../base/GraphDelegatedCommand.js';
|
|
7
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
8
|
+
import request from '../../../../request.js';
|
|
9
|
+
import { odata } from '../../../../utils/odata.js';
|
|
10
|
+
import { cli } from '../../../../cli/cli.js';
|
|
11
|
+
const options = globalOptionsZod
|
|
12
|
+
.extend({
|
|
13
|
+
id: zod.alias('i', z.string()
|
|
14
|
+
.refine(id => validation.isValidGuid(id), id => ({
|
|
15
|
+
message: `'${id}' is not a valid GUID.`
|
|
16
|
+
}))
|
|
17
|
+
.optional()),
|
|
18
|
+
name: zod.alias('n', z.string().optional())
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
class SpeContainerTypeGetCommand extends GraphDelegatedCommand {
|
|
15
22
|
get name() {
|
|
16
23
|
return commands.CONTAINERTYPE_GET;
|
|
17
24
|
}
|
|
18
25
|
get description() {
|
|
19
|
-
return '
|
|
26
|
+
return 'Gets a container type';
|
|
27
|
+
}
|
|
28
|
+
get schema() {
|
|
29
|
+
return options;
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initValidators).call(this);
|
|
27
|
-
__classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initOptionSets).call(this);
|
|
28
|
-
__classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initTypes).call(this);
|
|
31
|
+
getRefinedSchema(schema) {
|
|
32
|
+
return schema
|
|
33
|
+
.refine(options => [options.id, options.name].filter(o => o !== undefined).length === 1, {
|
|
34
|
+
message: 'Use one of the following options: id or name.'
|
|
35
|
+
});
|
|
29
36
|
}
|
|
30
37
|
async commandAction(logger, args) {
|
|
31
38
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
let result;
|
|
40
|
+
if (args.options.name) {
|
|
41
|
+
const containerTypes = await odata.getAllItems(`${this.resource}/beta/storage/fileStorage/containerTypes?$filter=name eq '${formatting.encodeQueryParameter(args.options.name)}'`);
|
|
42
|
+
if (containerTypes.length === 0) {
|
|
43
|
+
throw `The specified container type '${args.options.name}' does not exist.`;
|
|
44
|
+
}
|
|
45
|
+
if (containerTypes.length > 1) {
|
|
46
|
+
const containerKeyValuePair = formatting.convertArrayToHashTable('id', containerTypes);
|
|
47
|
+
result = await cli.handleMultipleResultsFound(`Multiple container types with name '${args.options.name}' found.`, containerKeyValuePair);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
result = containerTypes[0];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const requestOptions = {
|
|
55
|
+
url: `${this.resource}/beta/storage/fileStorage/containerTypes/${args.options.id}`,
|
|
56
|
+
headers: {
|
|
57
|
+
accept: 'application/json;odata.metadata=none'
|
|
58
|
+
},
|
|
59
|
+
responseType: 'json'
|
|
60
|
+
};
|
|
61
|
+
result = await request.get(requestOptions);
|
|
62
|
+
}
|
|
63
|
+
await logger.log(result);
|
|
36
64
|
}
|
|
37
65
|
catch (err) {
|
|
38
66
|
this.handleRejectedODataJsonPromise(err);
|
|
39
67
|
}
|
|
40
68
|
}
|
|
41
|
-
async getContainerTypeById(containerTypeId, spoAdminUrl, logger) {
|
|
42
|
-
if (this.verbose) {
|
|
43
|
-
await logger.logToStderr(`Getting the Container type...`);
|
|
44
|
-
}
|
|
45
|
-
const requestOptions = {
|
|
46
|
-
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
47
|
-
headers: {
|
|
48
|
-
accept: 'application/json;odata=nometadata'
|
|
49
|
-
},
|
|
50
|
-
responseType: 'json',
|
|
51
|
-
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"><Actions><ObjectPath Id="49" ObjectPathId="48" /><Method Name="GetSPOContainerTypeById" Id="50" ObjectPathId="48"><Parameters><Parameter Type="Guid">{${containerTypeId}}</Parameter><Parameter Type="Enum">1</Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="48" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
52
|
-
};
|
|
53
|
-
const res = await request.post(requestOptions);
|
|
54
|
-
const response = res[0];
|
|
55
|
-
if (response.ErrorInfo) {
|
|
56
|
-
throw response.ErrorInfo.ErrorMessage;
|
|
57
|
-
}
|
|
58
|
-
const containerTypes = res[res.length - 1];
|
|
59
|
-
return containerTypes;
|
|
60
|
-
}
|
|
61
|
-
async getContainerTypeId(options, spoAdminUrl, logger) {
|
|
62
|
-
if (options.id) {
|
|
63
|
-
return options.id;
|
|
64
|
-
}
|
|
65
|
-
if (this.verbose) {
|
|
66
|
-
await logger.logToStderr(`Retrieving container type id for container type '${options.containerTypeName}'...`);
|
|
67
|
-
}
|
|
68
|
-
return spe.getContainerTypeIdByName(spoAdminUrl, options.name);
|
|
69
|
-
}
|
|
70
69
|
}
|
|
71
|
-
_SpeContainerTypeGetCommand_instances = new WeakSet(), _SpeContainerTypeGetCommand_initTelemetry = function _SpeContainerTypeGetCommand_initTelemetry() {
|
|
72
|
-
this.telemetry.push((args) => {
|
|
73
|
-
Object.assign(this.telemetryProperties, {
|
|
74
|
-
id: typeof args.options.id !== 'undefined',
|
|
75
|
-
name: typeof args.options.name !== 'undefined'
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}, _SpeContainerTypeGetCommand_initOptions = function _SpeContainerTypeGetCommand_initOptions() {
|
|
79
|
-
this.options.unshift({
|
|
80
|
-
option: '-i, --id [id]'
|
|
81
|
-
}, {
|
|
82
|
-
option: '-n, --name [name]'
|
|
83
|
-
});
|
|
84
|
-
}, _SpeContainerTypeGetCommand_initOptionSets = function _SpeContainerTypeGetCommand_initOptionSets() {
|
|
85
|
-
this.optionSets.push({
|
|
86
|
-
options: ['id', 'name']
|
|
87
|
-
});
|
|
88
|
-
}, _SpeContainerTypeGetCommand_initValidators = function _SpeContainerTypeGetCommand_initValidators() {
|
|
89
|
-
this.validators.push(async (args) => {
|
|
90
|
-
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
91
|
-
return `${args.options.id} is not a valid GUID`;
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
});
|
|
95
|
-
}, _SpeContainerTypeGetCommand_initTypes = function _SpeContainerTypeGetCommand_initTypes() {
|
|
96
|
-
this.types.string.push('id', 'name');
|
|
97
|
-
};
|
|
98
70
|
export default new SpeContainerTypeGetCommand();
|
|
99
71
|
//# sourceMappingURL=containertype-get.js.map
|
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
import SpoCommand from '../../../base/SpoCommand.js';
|
|
2
1
|
import commands from '../../commands.js';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
class SpeContainerTypeListCommand extends
|
|
2
|
+
import GraphDelegatedCommand from '../../../base/GraphDelegatedCommand.js';
|
|
3
|
+
import { odata } from '../../../../utils/odata.js';
|
|
4
|
+
class SpeContainerTypeListCommand extends GraphDelegatedCommand {
|
|
6
5
|
get name() {
|
|
7
6
|
return commands.CONTAINERTYPE_LIST;
|
|
8
7
|
}
|
|
9
8
|
get description() {
|
|
10
|
-
return 'Lists all
|
|
9
|
+
return 'Lists all container types';
|
|
11
10
|
}
|
|
12
11
|
defaultProperties() {
|
|
13
|
-
return ['
|
|
12
|
+
return ['id', 'name', 'owningAppId'];
|
|
14
13
|
}
|
|
15
14
|
async commandAction(logger) {
|
|
16
15
|
try {
|
|
17
|
-
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
18
16
|
if (this.verbose) {
|
|
19
17
|
await logger.logToStderr(`Retrieving list of Container types...`);
|
|
20
18
|
}
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const result = allContainerTypes.map(ct => ({
|
|
24
|
-
_ObjectType_: 'Microsoft.Online.SharePoint.TenantAdministration.SPContainerTypeProperties',
|
|
25
|
-
...ct,
|
|
26
|
-
AzureSubscriptionId: `/Guid(${ct.AzureSubscriptionId})/`,
|
|
27
|
-
ContainerTypeId: `/Guid(${ct.ContainerTypeId})/`,
|
|
28
|
-
OwningAppId: `/Guid(${ct.OwningAppId})/`,
|
|
29
|
-
OwningTenantId: `/Guid(${ct.OwningTenantId})/`
|
|
30
|
-
}));
|
|
31
|
-
await logger.log(result);
|
|
19
|
+
const containerTypes = await odata.getAllItems(`${this.resource}/beta/storage/fileStorage/containerTypes`);
|
|
20
|
+
await logger.log(containerTypes);
|
|
32
21
|
}
|
|
33
22
|
catch (err) {
|
|
34
|
-
this.
|
|
23
|
+
this.handleRejectedODataJsonPromise(err);
|
|
35
24
|
}
|
|
36
25
|
}
|
|
37
26
|
}
|
|
@@ -4,11 +4,11 @@ import { zod } from '../../../../utils/zod.js';
|
|
|
4
4
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
5
5
|
import commands from '../../commands.js';
|
|
6
6
|
import { spo } from '../../../../utils/spo.js';
|
|
7
|
-
import { spe } from '../../../../utils/spe.js';
|
|
8
7
|
import { cli } from '../../../../cli/cli.js';
|
|
9
8
|
import { validation } from '../../../../utils/validation.js';
|
|
10
9
|
import request from '../../../../request.js';
|
|
11
10
|
import config from '../../../../config.js';
|
|
11
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
12
12
|
const options = globalOptionsZod
|
|
13
13
|
.extend({
|
|
14
14
|
id: zod.alias('i', z.string()
|
|
@@ -46,14 +46,13 @@ class SpeContainerTypeRemoveCommand extends SpoCommand {
|
|
|
46
46
|
try {
|
|
47
47
|
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
|
|
48
48
|
const containerTypeId = await this.getContainerTypeId(args.options, spoAdminUrl, logger);
|
|
49
|
-
const formDigestInfo = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, this.debug);
|
|
50
49
|
if (this.verbose) {
|
|
51
|
-
await logger.logToStderr(`Removing container type ${args.options.id || args.options.name}...`);
|
|
50
|
+
await logger.logToStderr(`Removing container type '${args.options.id || args.options.name}'...`);
|
|
52
51
|
}
|
|
53
52
|
const requestOptions = {
|
|
54
53
|
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
55
54
|
headers: {
|
|
56
|
-
'
|
|
55
|
+
accept: 'application/json;odata=nometadata'
|
|
57
56
|
},
|
|
58
57
|
responseType: 'json',
|
|
59
58
|
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"><Actions><ObjectPath Id="7" ObjectPathId="6" /><Method Name="RemoveSPOContainerType" Id="8" ObjectPathId="6"><Parameters><Parameter TypeId="{b66ab1ca-fd51-44f9-8cfc-01f5c2a21f99}"><Property Name="ContainerTypeId" Type="Guid">{${containerTypeId}}</Property></Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="6" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
@@ -74,7 +73,30 @@ class SpeContainerTypeRemoveCommand extends SpoCommand {
|
|
|
74
73
|
if (this.verbose) {
|
|
75
74
|
await logger.logToStderr(`Retrieving container type id for container type '${options.name}'...`);
|
|
76
75
|
}
|
|
77
|
-
|
|
76
|
+
const requestOptions = {
|
|
77
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
78
|
+
headers: {
|
|
79
|
+
accept: 'application/json;odata=nometadata'
|
|
80
|
+
},
|
|
81
|
+
responseType: 'json',
|
|
82
|
+
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"><Actions><ObjectPath Id="46" ObjectPathId="45" /><Method Name="GetSPOContainerTypes" Id="47" ObjectPathId="45"><Parameters><Parameter Type="Enum">1</Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="45" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
|
|
83
|
+
};
|
|
84
|
+
const json = await request.post(requestOptions);
|
|
85
|
+
const response = json[0];
|
|
86
|
+
if (response.ErrorInfo) {
|
|
87
|
+
throw new Error(response.ErrorInfo.ErrorMessage);
|
|
88
|
+
}
|
|
89
|
+
const allContainerTypes = json[json.length - 1];
|
|
90
|
+
const containerTypes = allContainerTypes.filter(ct => ct.DisplayName.toLowerCase() === options.name.toLowerCase());
|
|
91
|
+
if (containerTypes.length === 0) {
|
|
92
|
+
throw new Error(`The specified container type '${options.name}' does not exist.`);
|
|
93
|
+
}
|
|
94
|
+
if (containerTypes.length > 1) {
|
|
95
|
+
const containerTypeKeyValuePair = formatting.convertArrayToHashTable('ContainerTypeId', containerTypes);
|
|
96
|
+
const containerType = await cli.handleMultipleResultsFound(`Multiple container types with name '${options.name}' found.`, containerTypeKeyValuePair);
|
|
97
|
+
return formatting.extractCsomGuid(containerType.ContainerTypeId);
|
|
98
|
+
}
|
|
99
|
+
return formatting.extractCsomGuid(containerTypes[0].ContainerTypeId);
|
|
78
100
|
}
|
|
79
101
|
}
|
|
80
102
|
export default new SpeContainerTypeRemoveCommand();
|
|
@@ -1,20 +1,25 @@
|
|
|
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 _SpfxProjectUpgradeCommand_instances, _a, _SpfxProjectUpgradeCommand_initTelemetry, _SpfxProjectUpgradeCommand_initOptions, _SpfxProjectUpgradeCommand_initValidators;
|
|
7
1
|
import fs from 'fs';
|
|
8
2
|
import os from 'os';
|
|
9
3
|
import path from 'path';
|
|
10
4
|
// uncomment to support upgrading to preview releases
|
|
11
5
|
import { prerelease } from 'semver';
|
|
12
|
-
import {
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { CommandError, globalOptionsZod } from '../../../../Command.js';
|
|
13
8
|
import { fsUtil } from '../../../../utils/fsUtil.js';
|
|
14
9
|
import { packageManager } from '../../../../utils/packageManager.js';
|
|
10
|
+
import { zod } from '../../../../utils/zod.js';
|
|
15
11
|
import commands from '../../commands.js';
|
|
16
12
|
import { BaseProjectCommand } from './base-project-command.js';
|
|
17
13
|
import { FN017001_MISC_npm_dedupe } from './project-upgrade/rules/FN017001_MISC_npm_dedupe.js';
|
|
14
|
+
const options = globalOptionsZod
|
|
15
|
+
.extend({
|
|
16
|
+
packageManager: z.enum(['npm', 'pnpm', 'yarn']).default('npm'),
|
|
17
|
+
preview: z.boolean().optional(),
|
|
18
|
+
toVersion: zod.alias('v', z.string().optional()),
|
|
19
|
+
shell: z.enum(['bash', 'powershell', 'cmd']).default('powershell'),
|
|
20
|
+
output: z.enum(['json', 'text', 'md', 'tour', 'csv', 'none']).optional()
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
18
23
|
class SpfxProjectUpgradeCommand extends BaseProjectCommand {
|
|
19
24
|
get name() {
|
|
20
25
|
return commands.PROJECT_UPGRADE;
|
|
@@ -25,12 +30,14 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
|
|
|
25
30
|
get allowedOutputs() {
|
|
26
31
|
return ['json', 'text', 'md', 'tour'];
|
|
27
32
|
}
|
|
33
|
+
get schema() {
|
|
34
|
+
return options;
|
|
35
|
+
}
|
|
28
36
|
constructor() {
|
|
29
37
|
super();
|
|
30
|
-
_SpfxProjectUpgradeCommand_instances.add(this);
|
|
31
38
|
this.toVersion = '';
|
|
32
|
-
this.packageManager = '
|
|
33
|
-
this.shell = '
|
|
39
|
+
this.packageManager = '';
|
|
40
|
+
this.shell = '';
|
|
34
41
|
this.allFindings = [];
|
|
35
42
|
this.supportedVersions = [
|
|
36
43
|
'1.0.0',
|
|
@@ -80,14 +87,11 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
|
|
|
80
87
|
'1.21.1',
|
|
81
88
|
'1.22.0-beta.1'
|
|
82
89
|
];
|
|
83
|
-
__classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initTelemetry).call(this);
|
|
84
|
-
__classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initOptions).call(this);
|
|
85
|
-
__classPrivateFieldGet(this, _SpfxProjectUpgradeCommand_instances, "m", _SpfxProjectUpgradeCommand_initValidators).call(this);
|
|
86
90
|
}
|
|
87
91
|
async commandAction(logger, args) {
|
|
88
92
|
this.projectRootPath = this.getProjectRoot(process.cwd());
|
|
89
93
|
if (this.projectRootPath === null) {
|
|
90
|
-
throw new CommandError(`Couldn't find project root folder`,
|
|
94
|
+
throw new CommandError(`Couldn't find project root folder`, SpfxProjectUpgradeCommand.ERROR_NO_PROJECT_ROOT_FOLDER);
|
|
91
95
|
}
|
|
92
96
|
this.toVersion = args.options.toVersion ? args.options.toVersion : this.supportedVersions[this.supportedVersions.length - 1];
|
|
93
97
|
// uncomment to support upgrading to preview releases
|
|
@@ -101,21 +105,21 @@ class SpfxProjectUpgradeCommand extends BaseProjectCommand {
|
|
|
101
105
|
this.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
|
|
102
106
|
}
|
|
103
107
|
this.packageManager = args.options.packageManager || 'npm';
|
|
104
|
-
this.shell = args.options.shell || '
|
|
108
|
+
this.shell = args.options.shell || 'powershell';
|
|
105
109
|
if (this.supportedVersions.indexOf(this.toVersion) < 0) {
|
|
106
|
-
throw new CommandError(`CLI for Microsoft 365 doesn't support upgrading SharePoint Framework projects to version ${this.toVersion}. Supported versions are ${this.supportedVersions.join(', ')}`,
|
|
110
|
+
throw new CommandError(`CLI for Microsoft 365 doesn't support upgrading SharePoint Framework projects to version ${this.toVersion}. Supported versions are ${this.supportedVersions.join(', ')}`, SpfxProjectUpgradeCommand.ERROR_UNSUPPORTED_TO_VERSION);
|
|
107
111
|
}
|
|
108
112
|
this.projectVersion = this.getProjectVersion();
|
|
109
113
|
if (!this.projectVersion) {
|
|
110
|
-
throw new CommandError(`Unable to determine the version of the current SharePoint Framework project`,
|
|
114
|
+
throw new CommandError(`Unable to determine the version of the current SharePoint Framework project`, SpfxProjectUpgradeCommand.ERROR_NO_VERSION);
|
|
111
115
|
}
|
|
112
116
|
const pos = this.supportedVersions.indexOf(this.projectVersion);
|
|
113
117
|
if (pos < 0) {
|
|
114
|
-
throw new CommandError(`CLI for Microsoft 365 doesn't support upgrading projects built using SharePoint Framework v${this.projectVersion}`,
|
|
118
|
+
throw new CommandError(`CLI for Microsoft 365 doesn't support upgrading projects built using SharePoint Framework v${this.projectVersion}`, SpfxProjectUpgradeCommand.ERROR_UNSUPPORTED_FROM_VERSION);
|
|
115
119
|
}
|
|
116
120
|
const posTo = this.supportedVersions.indexOf(this.toVersion);
|
|
117
121
|
if (pos > posTo) {
|
|
118
|
-
throw new CommandError('You cannot downgrade a project',
|
|
122
|
+
throw new CommandError('You cannot downgrade a project', SpfxProjectUpgradeCommand.ERROR_NO_DOWNGRADE);
|
|
119
123
|
}
|
|
120
124
|
if (pos === posTo) {
|
|
121
125
|
await logger.log(`Project doesn't need to be upgraded`);
|
|
@@ -479,53 +483,6 @@ ${f.resolution}
|
|
|
479
483
|
};
|
|
480
484
|
}
|
|
481
485
|
}
|
|
482
|
-
_a = SpfxProjectUpgradeCommand, _SpfxProjectUpgradeCommand_instances = new WeakSet(), _SpfxProjectUpgradeCommand_initTelemetry = function _SpfxProjectUpgradeCommand_initTelemetry() {
|
|
483
|
-
this.telemetry.push((args) => {
|
|
484
|
-
Object.assign(this.telemetryProperties, {
|
|
485
|
-
toVersion: args.options.toVersion || this.supportedVersions[this.supportedVersions.length - 1],
|
|
486
|
-
packageManager: args.options.packageManager || 'npm',
|
|
487
|
-
shell: args.options.shell || 'bash',
|
|
488
|
-
preview: args.options.preview
|
|
489
|
-
});
|
|
490
|
-
// uncomment to support upgrading to preview releases
|
|
491
|
-
if (prerelease(this.telemetryProperties.toVersion) && !args.options.preview) {
|
|
492
|
-
this.telemetryProperties.toVersion = this.supportedVersions[this.supportedVersions.length - 2];
|
|
493
|
-
}
|
|
494
|
-
});
|
|
495
|
-
}, _SpfxProjectUpgradeCommand_initOptions = function _SpfxProjectUpgradeCommand_initOptions() {
|
|
496
|
-
this.options.unshift({
|
|
497
|
-
option: '-v, --toVersion [toVersion]'
|
|
498
|
-
}, {
|
|
499
|
-
option: '--packageManager [packageManager]',
|
|
500
|
-
autocomplete: _a.packageManagers
|
|
501
|
-
}, {
|
|
502
|
-
option: '--shell [shell]',
|
|
503
|
-
autocomplete: _a.shells
|
|
504
|
-
}, {
|
|
505
|
-
option: '--preview'
|
|
506
|
-
});
|
|
507
|
-
this.options.forEach(o => {
|
|
508
|
-
if (o.option.indexOf('--output') > -1) {
|
|
509
|
-
o.autocomplete = this.allowedOutputs;
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
}, _SpfxProjectUpgradeCommand_initValidators = function _SpfxProjectUpgradeCommand_initValidators() {
|
|
513
|
-
this.validators.push(async (args) => {
|
|
514
|
-
if (args.options.packageManager) {
|
|
515
|
-
if (_a.packageManagers.indexOf(args.options.packageManager) < 0) {
|
|
516
|
-
return `${args.options.packageManager} is not a supported package manager. Supported package managers are ${_a.packageManagers.join(', ')}`;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
if (args.options.shell) {
|
|
520
|
-
if (_a.shells.indexOf(args.options.shell) < 0) {
|
|
521
|
-
return `${args.options.shell} is not a supported shell. Supported shells are ${_a.shells.join(', ')}`;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
return true;
|
|
525
|
-
});
|
|
526
|
-
};
|
|
527
|
-
SpfxProjectUpgradeCommand.packageManagers = ['npm', 'pnpm', 'yarn'];
|
|
528
|
-
SpfxProjectUpgradeCommand.shells = ['bash', 'powershell', 'cmd'];
|
|
529
486
|
SpfxProjectUpgradeCommand.ERROR_NO_PROJECT_ROOT_FOLDER = 1;
|
|
530
487
|
SpfxProjectUpgradeCommand.ERROR_UNSUPPORTED_TO_VERSION = 2;
|
|
531
488
|
SpfxProjectUpgradeCommand.ERROR_NO_VERSION = 3;
|
|
@@ -33,17 +33,10 @@ class SpoCustomActionListCommand extends SpoCommand {
|
|
|
33
33
|
await logger.logToStderr('');
|
|
34
34
|
}
|
|
35
35
|
const customActions = await spo.getCustomActions(args.options.webUrl, args.options.scope);
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
await logger.logToStderr(`Custom actions not found`);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
if (args.options.output !== 'json') {
|
|
43
|
-
customActions.forEach(a => a.Scope = this.humanizeScope(a.Scope));
|
|
44
|
-
}
|
|
45
|
-
await logger.log(customActions);
|
|
36
|
+
if (args.options.output !== 'json') {
|
|
37
|
+
customActions.forEach(a => a.Scope = this.humanizeScope(a.Scope));
|
|
46
38
|
}
|
|
39
|
+
await logger.log(customActions);
|
|
47
40
|
}
|
|
48
41
|
catch (err) {
|
|
49
42
|
this.handleRejectedPromise(err);
|
|
@@ -35,9 +35,6 @@ class SpoFileMoveCommand extends SpoCommand {
|
|
|
35
35
|
const sourceServerRelativePath = await this.getSourcePath(logger, args.options);
|
|
36
36
|
const sourcePath = this.getAbsoluteUrl(args.options.webUrl, sourceServerRelativePath);
|
|
37
37
|
const destinationPath = this.getAbsoluteUrl(args.options.webUrl, args.options.targetUrl);
|
|
38
|
-
if (args.options.includeItemPermissions) {
|
|
39
|
-
await this.warn(logger, `Parameter 'includeItemPermissions' is deprecated. Please use 'withItemPermissions' instead`);
|
|
40
|
-
}
|
|
41
38
|
if (this.verbose) {
|
|
42
39
|
await logger.logToStderr(`Moving file '${sourceServerRelativePath}' to '${args.options.targetUrl}'...`);
|
|
43
40
|
}
|
|
@@ -49,7 +46,7 @@ class SpoFileMoveCommand extends SpoCommand {
|
|
|
49
46
|
const copyJobResponse = await spo.createFileCopyJob(args.options.webUrl, sourcePath, destinationPath, {
|
|
50
47
|
nameConflictBehavior: this.getNameConflictBehaviorValue(args.options.nameConflictBehavior),
|
|
51
48
|
bypassSharedLock: !!args.options.bypassSharedLock,
|
|
52
|
-
includeItemPermissions: !!args.options.
|
|
49
|
+
includeItemPermissions: !!args.options.withItemPermissions,
|
|
53
50
|
newName: newName,
|
|
54
51
|
operation: 'move'
|
|
55
52
|
});
|
|
@@ -121,7 +118,6 @@ _SpoFileMoveCommand_instances = new WeakSet(), _SpoFileMoveCommand_initTelemetry
|
|
|
121
118
|
sourceId: typeof args.options.sourceId !== 'undefined',
|
|
122
119
|
newName: typeof args.options.newName !== 'undefined',
|
|
123
120
|
nameConflictBehavior: typeof args.options.nameConflictBehavior !== 'undefined',
|
|
124
|
-
includeItemPermissions: !!args.options.includeItemPermissions,
|
|
125
121
|
withItemPermissions: !!args.options.withItemPermissions,
|
|
126
122
|
bypassSharedLock: !!args.options.bypassSharedLock,
|
|
127
123
|
skipWait: !!args.options.skipWait
|
|
@@ -141,8 +137,6 @@ _SpoFileMoveCommand_instances = new WeakSet(), _SpoFileMoveCommand_initTelemetry
|
|
|
141
137
|
}, {
|
|
142
138
|
option: '--nameConflictBehavior [nameConflictBehavior]',
|
|
143
139
|
autocomplete: this.nameConflictBehaviorOptions
|
|
144
|
-
}, {
|
|
145
|
-
option: '--includeItemPermissions'
|
|
146
140
|
}, {
|
|
147
141
|
option: '--withItemPermissions'
|
|
148
142
|
}, {
|
|
@@ -168,7 +162,7 @@ _SpoFileMoveCommand_instances = new WeakSet(), _SpoFileMoveCommand_initTelemetry
|
|
|
168
162
|
this.optionSets.push({ options: ['sourceUrl', 'sourceId'] });
|
|
169
163
|
}, _SpoFileMoveCommand_initTypes = function _SpoFileMoveCommand_initTypes() {
|
|
170
164
|
this.types.string.push('webUrl', 'sourceUrl', 'sourceId', 'targetUrl', 'newName', 'nameConflictBehavior');
|
|
171
|
-
this.types.boolean.push('
|
|
165
|
+
this.types.boolean.push('withItemPermissions', 'bypassSharedLock', 'skipWait');
|
|
172
166
|
};
|
|
173
167
|
export default new SpoFileMoveCommand();
|
|
174
168
|
//# sourceMappingURL=file-move.js.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import commands from '../../commands.js';
|
|
2
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
3
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { zod } from '../../../../utils/zod.js';
|
|
6
|
+
import { validation } from '../../../../utils/validation.js';
|
|
7
|
+
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
8
|
+
import request from '../../../../request.js';
|
|
9
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
10
|
+
import { odata } from '../../../../utils/odata.js';
|
|
11
|
+
export const options = globalOptionsZod
|
|
12
|
+
.extend({
|
|
13
|
+
webUrl: zod.alias('u', z.string()
|
|
14
|
+
.refine(url => validation.isValidSharePointUrl(url) === true, url => ({
|
|
15
|
+
message: `'${url}' is not a valid SharePoint Online site URL.`
|
|
16
|
+
}))),
|
|
17
|
+
fileUrl: z.string().optional(),
|
|
18
|
+
fileId: zod.alias('i', z.string()
|
|
19
|
+
.refine(id => validation.isValidGuid(id), id => ({
|
|
20
|
+
message: `'${id}' is not a valid GUID.`
|
|
21
|
+
})).optional()),
|
|
22
|
+
label: z.string()
|
|
23
|
+
})
|
|
24
|
+
.strict();
|
|
25
|
+
class SpoFileVersionKeepCommand extends SpoCommand {
|
|
26
|
+
get name() {
|
|
27
|
+
return commands.FILE_VERSION_KEEP;
|
|
28
|
+
}
|
|
29
|
+
get description() {
|
|
30
|
+
return 'Ensure that a specific file version will never expire';
|
|
31
|
+
}
|
|
32
|
+
get schema() {
|
|
33
|
+
return options;
|
|
34
|
+
}
|
|
35
|
+
getRefinedSchema(schema) {
|
|
36
|
+
return schema
|
|
37
|
+
.refine(options => [options.fileUrl, options.fileId].filter(o => o !== undefined).length === 1, {
|
|
38
|
+
message: `Specify 'fileUrl' or 'fileId', but not both.`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async commandAction(logger, args) {
|
|
42
|
+
if (this.verbose) {
|
|
43
|
+
await logger.logToStderr(`Ensuring version '${args.options.label}' of file '${args.options.fileUrl || args.options.fileId}' at site '${args.options.webUrl}' will never expire...`);
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
const baseApiUrl = this.getBaseApiUrl(args.options.webUrl, args.options.fileUrl, args.options.fileId);
|
|
47
|
+
const response = await odata.getAllItems(`${baseApiUrl}/versions?$filter=VersionLabel eq '${formatting.encodeQueryParameter(args.options.label)}'&$select=ID`);
|
|
48
|
+
if (response.length === 0) {
|
|
49
|
+
throw `Version with label '${args.options.label}' not found.`;
|
|
50
|
+
}
|
|
51
|
+
const requestExpirationOptions = {
|
|
52
|
+
url: `${baseApiUrl}/versions(${response[0].ID})/SetExpirationDate()`,
|
|
53
|
+
headers: {
|
|
54
|
+
accept: 'application/json;odata=nometadata',
|
|
55
|
+
'content-type': 'application/json'
|
|
56
|
+
},
|
|
57
|
+
responseType: 'json'
|
|
58
|
+
};
|
|
59
|
+
await request.post(requestExpirationOptions);
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
this.handleRejectedODataJsonPromise(err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
getBaseApiUrl(webUrl, fileUrl, fileId) {
|
|
66
|
+
let requestUrl;
|
|
67
|
+
if (fileUrl) {
|
|
68
|
+
const serverRelUrl = urlUtil.getServerRelativePath(webUrl, fileUrl);
|
|
69
|
+
requestUrl = `${webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(serverRelUrl)}')`;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
requestUrl = `${webUrl}/_api/web/GetFileById('${fileId}')`;
|
|
73
|
+
}
|
|
74
|
+
return requestUrl;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export default new SpoFileVersionKeepCommand();
|
|
78
|
+
//# sourceMappingURL=file-version-keep.js.map
|
|
@@ -6,16 +6,18 @@ import { validation } from '../../../../utils/validation.js';
|
|
|
6
6
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
7
7
|
import commands from '../../commands.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
+
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
9
10
|
const options = globalOptionsZod
|
|
10
11
|
.extend({
|
|
11
12
|
url: zod.alias('u', z.string()
|
|
12
13
|
.refine((url) => validation.isValidSharePointUrl(url) === true, url => ({
|
|
13
14
|
message: `'${url}' is not a valid SharePoint Online site URL.`
|
|
14
15
|
}))),
|
|
15
|
-
|
|
16
|
+
audienceIds: z.string()
|
|
16
17
|
.refine(audiences => validation.isValidGuidArray(audiences) === true, audiences => ({
|
|
17
18
|
message: `The following GUIDs are invalid: ${validation.isValidGuidArray(audiences)}.`
|
|
18
19
|
})).optional(),
|
|
20
|
+
audienceNames: z.string().optional(),
|
|
19
21
|
vivaConnectionsDefaultStart: z.boolean().optional(),
|
|
20
22
|
isInDraftMode: z.boolean().optional(),
|
|
21
23
|
order: z.number()
|
|
@@ -34,7 +36,20 @@ class SpoHomeSiteAddCommand extends SpoCommand {
|
|
|
34
36
|
get schema() {
|
|
35
37
|
return options;
|
|
36
38
|
}
|
|
39
|
+
getRefinedSchema(schema) {
|
|
40
|
+
return schema
|
|
41
|
+
.refine((options) => [options.audienceIds, options.audienceNames].filter(o => o !== undefined).length <= 1, {
|
|
42
|
+
message: 'You must specify either audienceIds or audienceNames but not both.'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
37
45
|
async commandAction(logger, args) {
|
|
46
|
+
let audiences = [];
|
|
47
|
+
if (args.options.audienceIds) {
|
|
48
|
+
audiences = args.options.audienceIds.split(',').map(id => id.trim());
|
|
49
|
+
}
|
|
50
|
+
else if (args.options.audienceNames) {
|
|
51
|
+
audiences = await this.transformAudienceNamesToIds(args.options.audienceNames);
|
|
52
|
+
}
|
|
38
53
|
try {
|
|
39
54
|
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
|
|
40
55
|
const requestOptions = {
|
|
@@ -45,7 +60,7 @@ class SpoHomeSiteAddCommand extends SpoCommand {
|
|
|
45
60
|
responseType: 'json',
|
|
46
61
|
data: {
|
|
47
62
|
siteUrl: args.options.url,
|
|
48
|
-
audiences:
|
|
63
|
+
audiences: audiences,
|
|
49
64
|
vivaConnectionsDefaultStart: args.options.vivaConnectionsDefaultStart ?? true,
|
|
50
65
|
isInDraftMode: args.options.isInDraftMode ?? false,
|
|
51
66
|
order: args.options.order
|
|
@@ -61,6 +76,15 @@ class SpoHomeSiteAddCommand extends SpoCommand {
|
|
|
61
76
|
this.handleRejectedODataJsonPromise(err);
|
|
62
77
|
}
|
|
63
78
|
}
|
|
79
|
+
async transformAudienceNamesToIds(audienceNames) {
|
|
80
|
+
const names = audienceNames.split(',');
|
|
81
|
+
const ids = [];
|
|
82
|
+
for (const name of names) {
|
|
83
|
+
const id = await entraGroup.getGroupIdByDisplayName(name.trim());
|
|
84
|
+
ids.push(id);
|
|
85
|
+
}
|
|
86
|
+
return ids;
|
|
87
|
+
}
|
|
64
88
|
}
|
|
65
89
|
export default new SpoHomeSiteAddCommand();
|
|
66
90
|
//# sourceMappingURL=homesite-add.js.map
|