@pnp/cli-microsoft365 10.8.0-beta.708bf27 → 10.8.0-beta.a1c69a6
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/.eslintrc.cjs +2 -1
- package/README.md +3 -1
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Auth.js +82 -22
- package/dist/cli/cli.js +1 -1
- package/dist/config.js +1 -0
- package/dist/m365/adaptivecard/commands/adaptivecard-send.js +54 -67
- package/dist/m365/app/commands/app-get.js +5 -2
- package/dist/m365/app/commands/app-open.js +9 -22
- package/dist/m365/app/commands/permission/permission-add.js +18 -30
- package/dist/m365/app/commands/permission/permission-list.js +5 -2
- package/dist/m365/base/AppCommand.js +9 -25
- package/dist/m365/booking/commands/business/business-get.js +18 -25
- package/dist/m365/cli/commands/app/app-reconsent.js +103 -0
- package/dist/m365/cli/commands.js +1 -0
- package/dist/m365/commands/login.js +1 -1
- package/dist/m365/commands/setup.js +1 -2
- package/dist/m365/context/commands/context-remove.js +12 -25
- package/dist/m365/context/commands/option/option-remove.js +11 -25
- package/dist/m365/entra/commands/organization/organization-list.js +51 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/graph/commands/directoryextension/directoryextension-list.js +74 -0
- package/dist/m365/graph/commands/openextension/openextension-set.js +107 -0
- package/dist/m365/graph/commands.js +2 -0
- package/dist/m365/spe/commands/container/container-add.js +85 -0
- package/dist/m365/spe/commands/container/container-list.js +2 -9
- package/dist/m365/spe/commands/container/container-permission-list.js +52 -0
- package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +62 -0
- package/dist/m365/spe/commands/container/container-remove.js +99 -0
- package/dist/m365/spe/commands/containertype/containertype-add.js +11 -11
- package/dist/m365/spe/commands/containertype/containertype-get.js +28 -32
- package/dist/m365/spe/commands/containertype/containertype-list.js +14 -4
- package/dist/m365/spe/commands/containertype/containertype-remove.js +81 -0
- package/dist/m365/spe/commands.js +6 -1
- package/dist/m365/spo/commands/list/list-get.js +12 -6
- package/dist/m365/spo/commands/page/page-section-add.js +20 -23
- package/dist/m365/spp/commands/model/model-apply.js +130 -0
- package/dist/m365/spp/commands/model/model-get.js +7 -24
- package/dist/m365/spp/commands/model/model-list.js +1 -1
- package/dist/m365/spp/commands/model/model-remove.js +1 -1
- package/dist/m365/spp/commands.js +1 -0
- package/dist/utils/entraServicePrincipal.js +11 -0
- package/dist/utils/formatting.js +12 -0
- package/dist/utils/spe.js +77 -0
- package/dist/utils/spo.js +0 -18
- package/dist/utils/spp.js +59 -1
- package/dist/utils/zod.js +26 -1
- package/docs/docs/cmd/adaptivecard/adaptivecard-send.mdx +1 -1
- package/docs/docs/cmd/cli/app/app-reconsent.mdx +63 -0
- package/docs/docs/cmd/entra/organization/organization-list.mdx +154 -0
- package/docs/docs/cmd/graph/directoryextension/directoryextension-list.mdx +135 -0
- package/docs/docs/cmd/graph/openextension/openextension-set.mdx +97 -0
- package/docs/docs/cmd/spe/container/container-activate.mdx +0 -2
- package/docs/docs/cmd/spe/container/container-add.mdx +128 -0
- package/docs/docs/cmd/spe/container/container-permission-list.mdx +90 -0
- package/docs/docs/cmd/spe/container/container-recyclebinitem-list.mdx +96 -0
- package/docs/docs/cmd/spe/container/container-remove.mdx +65 -0
- package/docs/docs/cmd/spe/containertype/containertype-add.mdx +9 -1
- package/docs/docs/cmd/spe/containertype/containertype-get.mdx +8 -0
- package/docs/docs/cmd/spe/containertype/containertype-list.mdx +8 -0
- package/docs/docs/cmd/spe/containertype/containertype-remove.mdx +52 -0
- package/docs/docs/cmd/spo/field/field-get.mdx +0 -1
- package/docs/docs/cmd/spo/list/list-get.mdx +12 -3
- package/docs/docs/cmd/spp/model/model-apply.mdx +79 -0
- package/npm-shrinkwrap.json +894 -477
- package/package.json +11 -11
- package/dist/m365/spe/ContainerProperties.js +0 -2
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { cli } from '../../../../cli/cli.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { zod } from '../../../../utils/zod.js';
|
|
4
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
5
|
+
import commands from '../../commands.js';
|
|
6
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
7
|
+
import { odata } from '../../../../utils/odata.js';
|
|
8
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
9
|
+
const options = globalOptionsZod
|
|
10
|
+
.extend({
|
|
11
|
+
containerId: zod.alias('i', z.string())
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
class SpeContainerPermissionListCommand extends GraphCommand {
|
|
15
|
+
get name() {
|
|
16
|
+
return commands.CONTAINER_PERMISSION_LIST;
|
|
17
|
+
}
|
|
18
|
+
get description() {
|
|
19
|
+
return 'Lists permissions of a SharePoint Embedded Container';
|
|
20
|
+
}
|
|
21
|
+
defaultProperties() {
|
|
22
|
+
return ['id', 'userPrincipalName', 'roles'];
|
|
23
|
+
}
|
|
24
|
+
get schema() {
|
|
25
|
+
return options;
|
|
26
|
+
}
|
|
27
|
+
async commandAction(logger, args) {
|
|
28
|
+
try {
|
|
29
|
+
if (this.verbose) {
|
|
30
|
+
await logger.logToStderr(`Retrieving permissions of a SharePoint Embedded Container with id '${args.options.containerId}'...`);
|
|
31
|
+
}
|
|
32
|
+
const containerPermission = await odata.getAllItems(`${this.resource}/v1.0/storage/fileStorage/containers/${formatting.encodeQueryParameter(args.options.containerId)}/permissions`);
|
|
33
|
+
if (!cli.shouldTrimOutput(args.options.output)) {
|
|
34
|
+
await logger.log(containerPermission);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
await logger.log(containerPermission.map(i => {
|
|
38
|
+
return {
|
|
39
|
+
id: i.id,
|
|
40
|
+
roles: i.roles.join(','),
|
|
41
|
+
userPrincipalName: i.grantedToV2.user.userPrincipalName
|
|
42
|
+
};
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
this.handleRejectedODataJsonPromise(err);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export default new SpeContainerPermissionListCommand();
|
|
52
|
+
//# sourceMappingURL=container-permission-list.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import commands from '../../commands.js';
|
|
4
|
+
import { validation } from '../../../../utils/validation.js';
|
|
5
|
+
import { spo } from '../../../../utils/spo.js';
|
|
6
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
7
|
+
import { spe } from '../../../../utils/spe.js';
|
|
8
|
+
import { odata } from '../../../../utils/odata.js';
|
|
9
|
+
const options = globalOptionsZod
|
|
10
|
+
.extend({
|
|
11
|
+
containerTypeId: z.string()
|
|
12
|
+
.refine(id => validation.isValidGuid(id), id => ({
|
|
13
|
+
message: `'${id}' is not a valid GUID.`
|
|
14
|
+
})).optional(),
|
|
15
|
+
containerTypeName: z.string().optional()
|
|
16
|
+
})
|
|
17
|
+
.strict();
|
|
18
|
+
class SpeContainerRecycleBinItemListCommand extends GraphCommand {
|
|
19
|
+
get name() {
|
|
20
|
+
return commands.CONTAINER_RECYCLEBINITEM_LIST;
|
|
21
|
+
}
|
|
22
|
+
get description() {
|
|
23
|
+
return 'Lists deleted containers of a specific container type';
|
|
24
|
+
}
|
|
25
|
+
get schema() {
|
|
26
|
+
return options;
|
|
27
|
+
}
|
|
28
|
+
defaultProperties() {
|
|
29
|
+
return ['id', 'displayName'];
|
|
30
|
+
}
|
|
31
|
+
getRefinedSchema(schema) {
|
|
32
|
+
return schema
|
|
33
|
+
.refine((options) => [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 1, {
|
|
34
|
+
message: 'Use one of the following options: containerTypeId or containerTypeName.'
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async commandAction(logger, args) {
|
|
38
|
+
try {
|
|
39
|
+
const containerTypeId = await this.getContainerTypeId(args.options, logger);
|
|
40
|
+
if (this.verbose) {
|
|
41
|
+
await logger.logToStderr(`Retrieving deleted containers of container type with ID '${containerTypeId}'...`);
|
|
42
|
+
}
|
|
43
|
+
const deletedContainers = await odata.getAllItems(`${this.resource}/v1.0/storage/fileStorage/deletedContainers?$filter=containerTypeId eq ${containerTypeId}`);
|
|
44
|
+
await logger.log(deletedContainers);
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
this.handleRejectedODataJsonPromise(err);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async getContainerTypeId(options, logger) {
|
|
51
|
+
if (options.containerTypeId) {
|
|
52
|
+
return options.containerTypeId;
|
|
53
|
+
}
|
|
54
|
+
if (this.verbose) {
|
|
55
|
+
await logger.logToStderr(`Retrieving container type id for container type '${options.containerTypeName}'...`);
|
|
56
|
+
}
|
|
57
|
+
const adminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
|
|
58
|
+
return spe.getContainerTypeIdByName(adminUrl, options.containerTypeName);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export default new SpeContainerRecycleBinItemListCommand();
|
|
62
|
+
//# sourceMappingURL=container-recyclebinitem-list.js.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { zod } from '../../../../utils/zod.js';
|
|
4
|
+
import commands from '../../commands.js';
|
|
5
|
+
import { validation } from '../../../../utils/validation.js';
|
|
6
|
+
import { spe } from '../../../../utils/spe.js';
|
|
7
|
+
import { spo } from '../../../../utils/spo.js';
|
|
8
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
9
|
+
import request from '../../../../request.js';
|
|
10
|
+
import { cli } from '../../../../cli/cli.js';
|
|
11
|
+
const options = globalOptionsZod
|
|
12
|
+
.extend({
|
|
13
|
+
id: zod.alias('i', z.string()).optional(),
|
|
14
|
+
name: zod.alias('n', z.string()).optional(),
|
|
15
|
+
containerTypeId: z.string()
|
|
16
|
+
.refine(id => validation.isValidGuid(id), id => ({
|
|
17
|
+
message: `'${id}' is not a valid GUID.`
|
|
18
|
+
})).optional(),
|
|
19
|
+
containerTypeName: z.string().optional(),
|
|
20
|
+
recycle: z.boolean().optional(),
|
|
21
|
+
force: zod.alias('f', z.boolean().optional())
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
class SpeContainerRemoveCommand extends GraphCommand {
|
|
25
|
+
get name() {
|
|
26
|
+
return commands.CONTAINER_REMOVE;
|
|
27
|
+
}
|
|
28
|
+
get description() {
|
|
29
|
+
return 'Removes a container';
|
|
30
|
+
}
|
|
31
|
+
get schema() {
|
|
32
|
+
return options;
|
|
33
|
+
}
|
|
34
|
+
getRefinedSchema(schema) {
|
|
35
|
+
return schema
|
|
36
|
+
.refine((options) => [options.id, options.name].filter(o => o !== undefined).length === 1, {
|
|
37
|
+
message: 'Use one of the following options: id or name.'
|
|
38
|
+
})
|
|
39
|
+
.refine((options) => !options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 1, {
|
|
40
|
+
message: 'Use one of the following options when specifying the container name: containerTypeId or containerTypeName.'
|
|
41
|
+
})
|
|
42
|
+
.refine((options) => options.name || [options.containerTypeId, options.containerTypeName].filter(o => o !== undefined).length === 0, {
|
|
43
|
+
message: 'Options containerTypeId and containerTypeName are only required when deleting a container by name.'
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
async commandAction(logger, args) {
|
|
47
|
+
if (!args.options.force) {
|
|
48
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove container '${args.options.id || args.options.name}'${!args.options.recycle ? ' permanently' : ''}?` });
|
|
49
|
+
if (!result) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const containerId = await this.getContainerId(args.options, logger);
|
|
55
|
+
if (this.verbose) {
|
|
56
|
+
await logger.logToStderr(`Removing container with ID '${containerId}'...`);
|
|
57
|
+
}
|
|
58
|
+
const requestOptions = {
|
|
59
|
+
url: `${this.resource}/v1.0/storage/fileStorage/containers/${containerId}`,
|
|
60
|
+
headers: {
|
|
61
|
+
accept: 'application/json;odata.metadata=none'
|
|
62
|
+
},
|
|
63
|
+
responseType: 'json'
|
|
64
|
+
};
|
|
65
|
+
if (args.options.recycle) {
|
|
66
|
+
await request.delete(requestOptions);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
// Container should be permanently deleted
|
|
70
|
+
requestOptions.url += '/permanentDelete';
|
|
71
|
+
await request.post(requestOptions);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
this.handleRejectedODataJsonPromise(err);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async getContainerId(options, logger) {
|
|
78
|
+
if (options.id) {
|
|
79
|
+
return options.id;
|
|
80
|
+
}
|
|
81
|
+
const containerTypeId = await this.getContainerTypeId(options, logger);
|
|
82
|
+
if (this.verbose) {
|
|
83
|
+
await logger.logToStderr(`Getting container ID for container with name '${options.name}'...`);
|
|
84
|
+
}
|
|
85
|
+
return spe.getContainerIdByName(containerTypeId, options.name);
|
|
86
|
+
}
|
|
87
|
+
async getContainerTypeId(options, logger) {
|
|
88
|
+
if (options.containerTypeId) {
|
|
89
|
+
return options.containerTypeId;
|
|
90
|
+
}
|
|
91
|
+
if (this.verbose) {
|
|
92
|
+
await logger.logToStderr(`Getting container type with name '${options.containerTypeName}'...`);
|
|
93
|
+
}
|
|
94
|
+
const adminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
|
|
95
|
+
return spe.getContainerTypeIdByName(adminUrl, options.containerTypeName);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export default new SpeContainerRemoveCommand();
|
|
99
|
+
//# sourceMappingURL=container-remove.js.map
|
|
@@ -3,14 +3,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
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
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var
|
|
6
|
+
var _SpeContainerTypeAddCommand_instances, _SpeContainerTypeAddCommand_initTelemetry, _SpeContainerTypeAddCommand_initOptions, _SpeContainerTypeAddCommand_initValidators;
|
|
7
7
|
import config from '../../../../config.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
9
|
import { spo } from '../../../../utils/spo.js';
|
|
10
10
|
import { validation } from '../../../../utils/validation.js';
|
|
11
11
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
|
-
class
|
|
13
|
+
class SpeContainerTypeAddCommand extends SpoCommand {
|
|
14
14
|
get name() {
|
|
15
15
|
return commands.CONTAINERTYPE_ADD;
|
|
16
16
|
}
|
|
@@ -19,10 +19,10 @@ class SpeContainertypeAddCommand extends SpoCommand {
|
|
|
19
19
|
}
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
22
|
-
|
|
23
|
-
__classPrivateFieldGet(this,
|
|
24
|
-
__classPrivateFieldGet(this,
|
|
25
|
-
__classPrivateFieldGet(this,
|
|
22
|
+
_SpeContainerTypeAddCommand_instances.add(this);
|
|
23
|
+
__classPrivateFieldGet(this, _SpeContainerTypeAddCommand_instances, "m", _SpeContainerTypeAddCommand_initTelemetry).call(this);
|
|
24
|
+
__classPrivateFieldGet(this, _SpeContainerTypeAddCommand_instances, "m", _SpeContainerTypeAddCommand_initOptions).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _SpeContainerTypeAddCommand_instances, "m", _SpeContainerTypeAddCommand_initValidators).call(this);
|
|
26
26
|
}
|
|
27
27
|
async commandAction(logger, args) {
|
|
28
28
|
try {
|
|
@@ -55,7 +55,7 @@ class SpeContainertypeAddCommand extends SpoCommand {
|
|
|
55
55
|
await logger.log(result);
|
|
56
56
|
}
|
|
57
57
|
catch (err) {
|
|
58
|
-
this.
|
|
58
|
+
this.handleRejectedODataJsonPromise(err);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
replaceString(s) {
|
|
@@ -68,7 +68,7 @@ class SpeContainertypeAddCommand extends SpoCommand {
|
|
|
68
68
|
return `<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><Method Name="NewSPOContainerType" Id="4" ObjectPathId="1"><Parameters><Parameter TypeId="{5466648e-c306-441b-9df4-c09deef25cb1}"><Property Name="AzureSubscriptionId" Type="Guid">{${options.azureSubscriptionId}}</Property><Property Name="ContainerTypeId" Type="Guid">{00000000-0000-0000-0000-000000000000}</Property><Property Name="CreationDate" Type="Null" /><Property Name="DisplayName" Type="String">${options.name}</Property><Property Name="ExpiryDate" Type="Null" /><Property Name="IsBillingProfileRequired" Type="Boolean">false</Property><Property Name="OwningAppId" Type="Guid">{${options.applicationId}}</Property><Property Name="OwningTenantId" Type="Guid">{00000000-0000-0000-0000-000000000000}</Property><Property Name="Region" Type="String">${options.region}</Property><Property Name="ResourceGroup" Type="String">${options.resourceGroup}</Property><Property Name="SPContainerTypeBillingClassification" Type="Enum">0</Property></Parameter></Parameters></Method></Actions><ObjectPaths><Constructor Id="1" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
_SpeContainerTypeAddCommand_instances = new WeakSet(), _SpeContainerTypeAddCommand_initTelemetry = function _SpeContainerTypeAddCommand_initTelemetry() {
|
|
72
72
|
this.telemetry.push((args) => {
|
|
73
73
|
Object.assign(this.telemetryProperties, {
|
|
74
74
|
trial: !!args.options.trial,
|
|
@@ -77,7 +77,7 @@ _SpeContainertypeAddCommand_instances = new WeakSet(), _SpeContainertypeAddComma
|
|
|
77
77
|
region: typeof args.options.region !== 'undefined'
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
|
-
},
|
|
80
|
+
}, _SpeContainerTypeAddCommand_initOptions = function _SpeContainerTypeAddCommand_initOptions() {
|
|
81
81
|
this.options.unshift({
|
|
82
82
|
option: '-n, --name <name>'
|
|
83
83
|
}, {
|
|
@@ -91,7 +91,7 @@ _SpeContainertypeAddCommand_instances = new WeakSet(), _SpeContainertypeAddComma
|
|
|
91
91
|
}, {
|
|
92
92
|
option: '--region [region]'
|
|
93
93
|
});
|
|
94
|
-
},
|
|
94
|
+
}, _SpeContainerTypeAddCommand_initValidators = function _SpeContainerTypeAddCommand_initValidators() {
|
|
95
95
|
this.validators.push(async (args) => {
|
|
96
96
|
if (!validation.isValidGuid(args.options.applicationId)) {
|
|
97
97
|
return `${args.options.applicationId} is not a valid GUID for option applicationId.`;
|
|
@@ -111,5 +111,5 @@ _SpeContainertypeAddCommand_instances = new WeakSet(), _SpeContainertypeAddComma
|
|
|
111
111
|
return true;
|
|
112
112
|
});
|
|
113
113
|
};
|
|
114
|
-
export default new
|
|
114
|
+
export default new SpeContainerTypeAddCommand();
|
|
115
115
|
//# sourceMappingURL=containertype-add.js.map
|
|
@@ -3,14 +3,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
3
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
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
|
-
var
|
|
6
|
+
var _SpeContainerTypeGetCommand_instances, _SpeContainerTypeGetCommand_initTelemetry, _SpeContainerTypeGetCommand_initOptions, _SpeContainerTypeGetCommand_initOptionSets, _SpeContainerTypeGetCommand_initValidators, _SpeContainerTypeGetCommand_initTypes;
|
|
7
7
|
import config from '../../../../config.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
|
+
import { spe } from '../../../../utils/spe.js';
|
|
9
10
|
import { spo } from '../../../../utils/spo.js';
|
|
10
11
|
import { validation } from '../../../../utils/validation.js';
|
|
11
12
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
12
13
|
import commands from '../../commands.js';
|
|
13
|
-
class
|
|
14
|
+
class SpeContainerTypeGetCommand extends SpoCommand {
|
|
14
15
|
get name() {
|
|
15
16
|
return commands.CONTAINERTYPE_GET;
|
|
16
17
|
}
|
|
@@ -19,85 +20,80 @@ class SpeContainertypeGetCommand extends SpoCommand {
|
|
|
19
20
|
}
|
|
20
21
|
constructor() {
|
|
21
22
|
super();
|
|
22
|
-
|
|
23
|
-
__classPrivateFieldGet(this,
|
|
24
|
-
__classPrivateFieldGet(this,
|
|
25
|
-
__classPrivateFieldGet(this,
|
|
26
|
-
__classPrivateFieldGet(this,
|
|
27
|
-
__classPrivateFieldGet(this,
|
|
23
|
+
_SpeContainerTypeGetCommand_instances.add(this);
|
|
24
|
+
__classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initTelemetry).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _SpeContainerTypeGetCommand_instances, "m", _SpeContainerTypeGetCommand_initOptions).call(this);
|
|
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);
|
|
28
29
|
}
|
|
29
30
|
async commandAction(logger, args) {
|
|
30
31
|
try {
|
|
31
32
|
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
|
|
32
|
-
if (this.verbose) {
|
|
33
|
-
await logger.logToStderr(`Getting the Container type...`);
|
|
34
|
-
}
|
|
35
33
|
const containerTypeId = await this.getContainerTypeId(args.options, spoAdminUrl, logger);
|
|
36
|
-
const
|
|
37
|
-
await logger.log(
|
|
34
|
+
const containerType = await this.getContainerTypeById(containerTypeId, spoAdminUrl, logger);
|
|
35
|
+
await logger.log(containerType);
|
|
38
36
|
}
|
|
39
37
|
catch (err) {
|
|
40
|
-
this.
|
|
38
|
+
this.handleRejectedODataJsonPromise(err);
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
async getContainerTypeById(containerTypeId, spoAdminUrl, logger) {
|
|
44
|
-
|
|
42
|
+
if (this.verbose) {
|
|
43
|
+
await logger.logToStderr(`Getting the Container type...`);
|
|
44
|
+
}
|
|
45
45
|
const requestOptions = {
|
|
46
46
|
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
47
47
|
headers: {
|
|
48
|
-
'
|
|
48
|
+
accept: 'application/json;odata=nometadata'
|
|
49
49
|
},
|
|
50
|
+
responseType: 'json',
|
|
50
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>`
|
|
51
52
|
};
|
|
52
53
|
const res = await request.post(requestOptions);
|
|
53
|
-
const
|
|
54
|
-
const response = json[0];
|
|
54
|
+
const response = res[0];
|
|
55
55
|
if (response.ErrorInfo) {
|
|
56
56
|
throw response.ErrorInfo.ErrorMessage;
|
|
57
57
|
}
|
|
58
|
-
const containerTypes =
|
|
58
|
+
const containerTypes = res[res.length - 1];
|
|
59
59
|
return containerTypes;
|
|
60
60
|
}
|
|
61
61
|
async getContainerTypeId(options, spoAdminUrl, logger) {
|
|
62
62
|
if (options.id) {
|
|
63
63
|
return options.id;
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const containerType = containerTypes.find(c => c.DisplayName === options.name);
|
|
68
|
-
if (!containerType) {
|
|
69
|
-
throw new Error(`Container type with name ${options.name} not found`);
|
|
65
|
+
if (this.verbose) {
|
|
66
|
+
await logger.logToStderr(`Retrieving container type id for container type '${options.containerTypeName}'...`);
|
|
70
67
|
}
|
|
71
|
-
|
|
72
|
-
return match[1];
|
|
68
|
+
return spe.getContainerTypeIdByName(spoAdminUrl, options.name);
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
|
-
|
|
71
|
+
_SpeContainerTypeGetCommand_instances = new WeakSet(), _SpeContainerTypeGetCommand_initTelemetry = function _SpeContainerTypeGetCommand_initTelemetry() {
|
|
76
72
|
this.telemetry.push((args) => {
|
|
77
73
|
Object.assign(this.telemetryProperties, {
|
|
78
74
|
id: typeof args.options.id !== 'undefined',
|
|
79
75
|
name: typeof args.options.name !== 'undefined'
|
|
80
76
|
});
|
|
81
77
|
});
|
|
82
|
-
},
|
|
78
|
+
}, _SpeContainerTypeGetCommand_initOptions = function _SpeContainerTypeGetCommand_initOptions() {
|
|
83
79
|
this.options.unshift({
|
|
84
80
|
option: '-i, --id [id]'
|
|
85
81
|
}, {
|
|
86
82
|
option: '-n, --name [name]'
|
|
87
83
|
});
|
|
88
|
-
},
|
|
84
|
+
}, _SpeContainerTypeGetCommand_initOptionSets = function _SpeContainerTypeGetCommand_initOptionSets() {
|
|
89
85
|
this.optionSets.push({
|
|
90
86
|
options: ['id', 'name']
|
|
91
87
|
});
|
|
92
|
-
},
|
|
88
|
+
}, _SpeContainerTypeGetCommand_initValidators = function _SpeContainerTypeGetCommand_initValidators() {
|
|
93
89
|
this.validators.push(async (args) => {
|
|
94
90
|
if (args.options.id && !validation.isValidGuid(args.options.id)) {
|
|
95
91
|
return `${args.options.id} is not a valid GUID`;
|
|
96
92
|
}
|
|
97
93
|
return true;
|
|
98
94
|
});
|
|
99
|
-
},
|
|
95
|
+
}, _SpeContainerTypeGetCommand_initTypes = function _SpeContainerTypeGetCommand_initTypes() {
|
|
100
96
|
this.types.string.push('id', 'name');
|
|
101
97
|
};
|
|
102
|
-
export default new
|
|
98
|
+
export default new SpeContainerTypeGetCommand();
|
|
103
99
|
//# sourceMappingURL=containertype-get.js.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
2
2
|
import commands from '../../commands.js';
|
|
3
|
+
import { spe } from '../../../../utils/spe.js';
|
|
3
4
|
import { spo } from '../../../../utils/spo.js';
|
|
4
|
-
class
|
|
5
|
+
class SpeContainerTypeListCommand extends SpoCommand {
|
|
5
6
|
get name() {
|
|
6
7
|
return commands.CONTAINERTYPE_LIST;
|
|
7
8
|
}
|
|
@@ -17,13 +18,22 @@ class SpeContainertypeListCommand extends SpoCommand {
|
|
|
17
18
|
if (this.verbose) {
|
|
18
19
|
await logger.logToStderr(`Retrieving list of Container types...`);
|
|
19
20
|
}
|
|
20
|
-
const allContainerTypes = await
|
|
21
|
-
|
|
21
|
+
const allContainerTypes = await spe.getAllContainerTypes(spoAdminUrl);
|
|
22
|
+
// The following conversion is done in order not to make breaking changes
|
|
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);
|
|
22
32
|
}
|
|
23
33
|
catch (err) {
|
|
24
34
|
this.handleRejectedPromise(err);
|
|
25
35
|
}
|
|
26
36
|
}
|
|
27
37
|
}
|
|
28
|
-
export default new
|
|
38
|
+
export default new SpeContainerTypeListCommand();
|
|
29
39
|
//# sourceMappingURL=containertype-list.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { zod } from '../../../../utils/zod.js';
|
|
4
|
+
import SpoCommand from '../../../base/SpoCommand.js';
|
|
5
|
+
import commands from '../../commands.js';
|
|
6
|
+
import { spo } from '../../../../utils/spo.js';
|
|
7
|
+
import { spe } from '../../../../utils/spe.js';
|
|
8
|
+
import { cli } from '../../../../cli/cli.js';
|
|
9
|
+
import { validation } from '../../../../utils/validation.js';
|
|
10
|
+
import request from '../../../../request.js';
|
|
11
|
+
import config from '../../../../config.js';
|
|
12
|
+
const options = globalOptionsZod
|
|
13
|
+
.extend({
|
|
14
|
+
id: zod.alias('i', z.string()
|
|
15
|
+
.refine(id => validation.isValidGuid(id), id => ({
|
|
16
|
+
message: `'${id}' is not a valid GUID.`
|
|
17
|
+
}))
|
|
18
|
+
.optional()),
|
|
19
|
+
name: zod.alias('n', z.string().optional()),
|
|
20
|
+
force: zod.alias('f', z.boolean().optional())
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
class SpeContainerTypeRemoveCommand extends SpoCommand {
|
|
24
|
+
get name() {
|
|
25
|
+
return commands.CONTAINERTYPE_REMOVE;
|
|
26
|
+
}
|
|
27
|
+
get description() {
|
|
28
|
+
return 'Remove a specific container type';
|
|
29
|
+
}
|
|
30
|
+
get schema() {
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
33
|
+
getRefinedSchema(schema) {
|
|
34
|
+
return schema
|
|
35
|
+
.refine(options => [options.id, options.name].filter(o => o !== undefined).length === 1, {
|
|
36
|
+
message: 'Use one of the following options: id, name.'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async commandAction(logger, args) {
|
|
40
|
+
if (!args.options.force) {
|
|
41
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove container type ${args.options.id || args.options.name}?` });
|
|
42
|
+
if (!result) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
|
|
48
|
+
const containerTypeId = await this.getContainerTypeId(args.options, spoAdminUrl, logger);
|
|
49
|
+
const formDigestInfo = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, this.debug);
|
|
50
|
+
if (this.verbose) {
|
|
51
|
+
await logger.logToStderr(`Removing container type ${args.options.id || args.options.name}...`);
|
|
52
|
+
}
|
|
53
|
+
const requestOptions = {
|
|
54
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
55
|
+
headers: {
|
|
56
|
+
'X-RequestDigest': formDigestInfo.FormDigestValue
|
|
57
|
+
},
|
|
58
|
+
responseType: 'json',
|
|
59
|
+
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>`
|
|
60
|
+
};
|
|
61
|
+
const result = await request.post(requestOptions);
|
|
62
|
+
if (result[0].ErrorInfo) {
|
|
63
|
+
throw result[0].ErrorInfo.ErrorMessage;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
this.handleRejectedODataJsonPromise(err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async getContainerTypeId(options, spoAdminUrl, logger) {
|
|
71
|
+
if (options.id) {
|
|
72
|
+
return options.id;
|
|
73
|
+
}
|
|
74
|
+
if (this.verbose) {
|
|
75
|
+
await logger.logToStderr(`Retrieving container type id for container type '${options.name}'...`);
|
|
76
|
+
}
|
|
77
|
+
return spe.getContainerTypeIdByName(spoAdminUrl, options.name);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export default new SpeContainerTypeRemoveCommand();
|
|
81
|
+
//# sourceMappingURL=containertype-remove.js.map
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
const prefix = 'spe';
|
|
2
2
|
export default {
|
|
3
3
|
CONTAINER_ACTIVATE: `${prefix} container activate`,
|
|
4
|
+
CONTAINER_ADD: `${prefix} container add`,
|
|
4
5
|
CONTAINER_GET: `${prefix} container get`,
|
|
5
6
|
CONTAINER_LIST: `${prefix} container list`,
|
|
7
|
+
CONTAINER_REMOVE: `${prefix} container remove`,
|
|
8
|
+
CONTAINER_PERMISSION_LIST: `${prefix} container permission list`,
|
|
9
|
+
CONTAINER_RECYCLEBINITEM_LIST: `${prefix} container recyclebinitem list`,
|
|
6
10
|
CONTAINERTYPE_ADD: `${prefix} containertype add`,
|
|
7
11
|
CONTAINERTYPE_GET: `${prefix} containertype get`,
|
|
8
|
-
CONTAINERTYPE_LIST: `${prefix} containertype list
|
|
12
|
+
CONTAINERTYPE_LIST: `${prefix} containertype list`,
|
|
13
|
+
CONTAINERTYPE_REMOVE: `${prefix} containertype remove`
|
|
9
14
|
};
|
|
10
15
|
//# sourceMappingURL=commands.js.map
|
|
@@ -43,6 +43,9 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
43
43
|
const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.url);
|
|
44
44
|
requestUrl += `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
|
|
45
45
|
}
|
|
46
|
+
else if (args.options.default) {
|
|
47
|
+
requestUrl += `DefaultDocumentLibrary`;
|
|
48
|
+
}
|
|
46
49
|
const fieldsProperties = this.formatSelectProperties(args.options.properties, args.options.withPermissions);
|
|
47
50
|
const queryParams = [];
|
|
48
51
|
if (fieldsProperties.selectProperties.length > 0) {
|
|
@@ -113,11 +116,12 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
113
116
|
_SpoListGetCommand_instances = new WeakSet(), _SpoListGetCommand_initTelemetry = function _SpoListGetCommand_initTelemetry() {
|
|
114
117
|
this.telemetry.push((args) => {
|
|
115
118
|
Object.assign(this.telemetryProperties, {
|
|
116
|
-
id:
|
|
117
|
-
title:
|
|
118
|
-
url:
|
|
119
|
-
properties:
|
|
120
|
-
withPermissions:
|
|
119
|
+
id: typeof args.options.id !== 'undefined',
|
|
120
|
+
title: typeof args.options.title !== 'undefined',
|
|
121
|
+
url: typeof args.options.url !== 'undefined',
|
|
122
|
+
properties: typeof args.options.properties !== 'undefined',
|
|
123
|
+
withPermissions: !!args.options.withPermissions,
|
|
124
|
+
default: !!args.options.default
|
|
121
125
|
});
|
|
122
126
|
});
|
|
123
127
|
}, _SpoListGetCommand_initOptions = function _SpoListGetCommand_initOptions() {
|
|
@@ -129,6 +133,8 @@ _SpoListGetCommand_instances = new WeakSet(), _SpoListGetCommand_initTelemetry =
|
|
|
129
133
|
option: '-t, --title [title]'
|
|
130
134
|
}, {
|
|
131
135
|
option: '--url [url]'
|
|
136
|
+
}, {
|
|
137
|
+
option: '--default'
|
|
132
138
|
}, {
|
|
133
139
|
option: '-p, --properties [properties]'
|
|
134
140
|
}, {
|
|
@@ -148,7 +154,7 @@ _SpoListGetCommand_instances = new WeakSet(), _SpoListGetCommand_initTelemetry =
|
|
|
148
154
|
return true;
|
|
149
155
|
});
|
|
150
156
|
}, _SpoListGetCommand_initOptionSets = function _SpoListGetCommand_initOptionSets() {
|
|
151
|
-
this.optionSets.push({ options: ['id', 'title', 'url'] });
|
|
157
|
+
this.optionSets.push({ options: ['id', 'title', 'url', 'default'] });
|
|
152
158
|
};
|
|
153
159
|
export default new SpoListGetCommand();
|
|
154
160
|
//# sourceMappingURL=list-get.js.map
|