@pnp/cli-microsoft365 10.8.0-beta.a51d886 → 10.8.0-beta.cdb5c81
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/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- 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/cli/commands/app/app-reconsent.js +103 -0
- package/dist/m365/cli/commands.js +1 -0
- package/dist/m365/entra/commands/organization/organization-list.js +51 -0
- package/dist/m365/entra/commands.js +1 -0
- package/dist/m365/graph/commands/openextension/openextension-set.js +107 -0
- package/dist/m365/graph/commands.js +1 -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-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 +5 -1
- 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/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/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-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/package.json +1 -1
- package/dist/m365/spe/ContainerProperties.js +0 -2
|
@@ -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,11 +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`,
|
|
6
8
|
CONTAINER_PERMISSION_LIST: `${prefix} container permission list`,
|
|
9
|
+
CONTAINER_RECYCLEBINITEM_LIST: `${prefix} container recyclebinitem list`,
|
|
7
10
|
CONTAINERTYPE_ADD: `${prefix} containertype add`,
|
|
8
11
|
CONTAINERTYPE_GET: `${prefix} containertype get`,
|
|
9
|
-
CONTAINERTYPE_LIST: `${prefix} containertype list
|
|
12
|
+
CONTAINERTYPE_LIST: `${prefix} containertype list`,
|
|
13
|
+
CONTAINERTYPE_REMOVE: `${prefix} containertype remove`
|
|
10
14
|
};
|
|
11
15
|
//# sourceMappingURL=commands.js.map
|
|
@@ -41,6 +41,17 @@ export const entraServicePrincipal = {
|
|
|
41
41
|
return await cli.handleMultipleResultsFound(`Multiple service principals with name '${appName}' found in Microsoft Entra ID.`, resultAsKeyValuePair);
|
|
42
42
|
}
|
|
43
43
|
return apps[0];
|
|
44
|
+
},
|
|
45
|
+
/**
|
|
46
|
+
* Get all available service principals.
|
|
47
|
+
* @param properties Comma-separated list of properties to include in the response.
|
|
48
|
+
*/
|
|
49
|
+
async getServicePrincipals(properties) {
|
|
50
|
+
let url = `https://graph.microsoft.com/v1.0/servicePrincipals`;
|
|
51
|
+
if (properties) {
|
|
52
|
+
url += `?$select=${properties}`;
|
|
53
|
+
}
|
|
54
|
+
return odata.getAllItems(url);
|
|
44
55
|
}
|
|
45
56
|
};
|
|
46
57
|
//# sourceMappingURL=entraServicePrincipal.js.map
|
package/dist/utils/formatting.js
CHANGED
|
@@ -177,6 +177,18 @@ export const formatting = {
|
|
|
177
177
|
resultAsKeyValuePair[obj[key]] = obj;
|
|
178
178
|
});
|
|
179
179
|
return resultAsKeyValuePair;
|
|
180
|
+
},
|
|
181
|
+
/**
|
|
182
|
+
* Extracts the GUID from a string in CSOM format.
|
|
183
|
+
* @param str The string to extract the GUID from
|
|
184
|
+
* @description The string should be in the format /Guid(XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX)/
|
|
185
|
+
* @returns The extracted GUID or the original string if no match is found
|
|
186
|
+
* @example /Guid(eae15efb-ac09-49b9-8906-e579efd622e4)/ => eae15efb-ac09-49b9-8906-e579efd622e4
|
|
187
|
+
*/
|
|
188
|
+
extractCsomGuid(str) {
|
|
189
|
+
const guidPattern = /\/Guid\(([0-9a-f-]+)\)\//i;
|
|
190
|
+
const match = str.match(guidPattern);
|
|
191
|
+
return match ? match[1] : str;
|
|
180
192
|
}
|
|
181
193
|
};
|
|
182
194
|
//# sourceMappingURL=formatting.js.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import request from '../request.js';
|
|
2
|
+
import { formatting } from './formatting.js';
|
|
3
|
+
import { cli } from '../cli/cli.js';
|
|
4
|
+
import config from '../config.js';
|
|
5
|
+
import { odata } from './odata.js';
|
|
6
|
+
const graphResource = 'https://graph.microsoft.com';
|
|
7
|
+
export const spe = {
|
|
8
|
+
/**
|
|
9
|
+
* Get all container types.
|
|
10
|
+
* @param spoAdminUrl The URL of the SharePoint Online admin center site (e.g. https://contoso-admin.sharepoint.com)
|
|
11
|
+
* @returns Array of container types
|
|
12
|
+
*/
|
|
13
|
+
async getAllContainerTypes(spoAdminUrl) {
|
|
14
|
+
const requestOptions = {
|
|
15
|
+
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
16
|
+
headers: {
|
|
17
|
+
accept: 'application/json;odata=nometadata'
|
|
18
|
+
},
|
|
19
|
+
responseType: 'json',
|
|
20
|
+
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>`
|
|
21
|
+
};
|
|
22
|
+
const json = await request.post(requestOptions);
|
|
23
|
+
const response = json[0];
|
|
24
|
+
if (response.ErrorInfo) {
|
|
25
|
+
throw new Error(response.ErrorInfo.ErrorMessage);
|
|
26
|
+
}
|
|
27
|
+
const containerTypes = json[json.length - 1];
|
|
28
|
+
// Format the response to remove CSOM GUIDs and convert them to real GUIDs
|
|
29
|
+
containerTypes.forEach(ct => {
|
|
30
|
+
delete ct._ObjectType_;
|
|
31
|
+
ct.AzureSubscriptionId = formatting.extractCsomGuid(ct.AzureSubscriptionId);
|
|
32
|
+
ct.ContainerTypeId = formatting.extractCsomGuid(ct.ContainerTypeId);
|
|
33
|
+
ct.OwningAppId = formatting.extractCsomGuid(ct.OwningAppId);
|
|
34
|
+
ct.OwningTenantId = formatting.extractCsomGuid(ct.OwningTenantId);
|
|
35
|
+
});
|
|
36
|
+
return containerTypes;
|
|
37
|
+
},
|
|
38
|
+
/**
|
|
39
|
+
* Get the ID of a container type by its name.
|
|
40
|
+
* @param spoAdminUrl SharePoint Online admin center URL (e.g. https://contoso-admin.sharepoint.com)
|
|
41
|
+
* @param name Name of the container type to search for
|
|
42
|
+
* @returns ID of the container type
|
|
43
|
+
*/
|
|
44
|
+
async getContainerTypeIdByName(spoAdminUrl, name) {
|
|
45
|
+
const allContainerTypes = await this.getAllContainerTypes(spoAdminUrl);
|
|
46
|
+
const containerTypes = allContainerTypes.filter(ct => ct.DisplayName.toLowerCase() === name.toLowerCase());
|
|
47
|
+
if (containerTypes.length === 0) {
|
|
48
|
+
throw new Error(`The specified container type '${name}' does not exist.`);
|
|
49
|
+
}
|
|
50
|
+
if (containerTypes.length > 1) {
|
|
51
|
+
const containerTypeKeyValuePair = formatting.convertArrayToHashTable('ContainerTypeId', containerTypes);
|
|
52
|
+
const containerType = await cli.handleMultipleResultsFound(`Multiple container types with name '${name}' found.`, containerTypeKeyValuePair);
|
|
53
|
+
return containerType.ContainerTypeId;
|
|
54
|
+
}
|
|
55
|
+
return containerTypes[0].ContainerTypeId;
|
|
56
|
+
},
|
|
57
|
+
/**
|
|
58
|
+
* Get the ID of a container by its name.
|
|
59
|
+
* @param containerTypeId ID of the container type.
|
|
60
|
+
* @param name Name of the container to search for.
|
|
61
|
+
* @returns ID of the container.
|
|
62
|
+
*/
|
|
63
|
+
async getContainerIdByName(containerTypeId, name) {
|
|
64
|
+
const containers = await odata.getAllItems(`${graphResource}/v1.0/storage/fileStorage/containers?$filter=containerTypeId eq ${containerTypeId}&$select=id,displayName`);
|
|
65
|
+
const matchingContainers = containers.filter(c => c.displayName.toLowerCase() === name.toLowerCase());
|
|
66
|
+
if (matchingContainers.length === 0) {
|
|
67
|
+
throw new Error(`The specified container '${name}' does not exist.`);
|
|
68
|
+
}
|
|
69
|
+
if (matchingContainers.length > 1) {
|
|
70
|
+
const containerKeyValuePair = formatting.convertArrayToHashTable('id', matchingContainers);
|
|
71
|
+
const container = await cli.handleMultipleResultsFound(`Multiple containers with name '${name}' found.`, containerKeyValuePair);
|
|
72
|
+
return container.id;
|
|
73
|
+
}
|
|
74
|
+
return matchingContainers[0].id;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
//# sourceMappingURL=spe.js.map
|
package/dist/utils/spo.js
CHANGED
|
@@ -53,24 +53,6 @@ export const spo = {
|
|
|
53
53
|
};
|
|
54
54
|
return context;
|
|
55
55
|
},
|
|
56
|
-
async getAllContainerTypes(spoAdminUrl, logger, verbose) {
|
|
57
|
-
const formDigestInfo = await spo.ensureFormDigest(spoAdminUrl, logger, undefined, verbose);
|
|
58
|
-
const requestOptions = {
|
|
59
|
-
url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
|
|
60
|
-
headers: {
|
|
61
|
-
'X-RequestDigest': formDigestInfo.FormDigestValue
|
|
62
|
-
},
|
|
63
|
-
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>`
|
|
64
|
-
};
|
|
65
|
-
const res = await request.post(requestOptions);
|
|
66
|
-
const json = JSON.parse(res);
|
|
67
|
-
const response = json[0];
|
|
68
|
-
if (response.ErrorInfo) {
|
|
69
|
-
throw new Error(response.ErrorInfo.ErrorMessage);
|
|
70
|
-
}
|
|
71
|
-
const containerTypes = json[json.length - 1];
|
|
72
|
-
return containerTypes;
|
|
73
|
-
},
|
|
74
56
|
async waitUntilFinished({ operationId, siteUrl, logger, currentContext, debug, verbose }) {
|
|
75
57
|
const resFormDigest = await spo.ensureFormDigest(siteUrl, logger, currentContext, debug);
|
|
76
58
|
currentContext = resFormDigest;
|
package/dist/utils/zod.js
CHANGED
|
@@ -110,16 +110,41 @@ function parseDef(def, options, currentOption) {
|
|
|
110
110
|
}
|
|
111
111
|
} while (parsedDef);
|
|
112
112
|
}
|
|
113
|
+
function optionToString(optionInfo) {
|
|
114
|
+
let s = '';
|
|
115
|
+
if (optionInfo.short) {
|
|
116
|
+
s += `-${optionInfo.short}, `;
|
|
117
|
+
}
|
|
118
|
+
s += `--${optionInfo.long}`;
|
|
119
|
+
if (optionInfo.type !== 'boolean') {
|
|
120
|
+
s += ' ';
|
|
121
|
+
s += optionInfo.required ? '<' : '[';
|
|
122
|
+
s += optionInfo.long;
|
|
123
|
+
s += optionInfo.required ? '>' : ']';
|
|
124
|
+
}
|
|
125
|
+
return s;
|
|
126
|
+
}
|
|
127
|
+
;
|
|
113
128
|
export const zod = {
|
|
114
129
|
alias(alias, type) {
|
|
115
130
|
type._def.alias = alias;
|
|
116
131
|
return type;
|
|
117
132
|
},
|
|
118
|
-
|
|
133
|
+
schemaToOptionInfo(schema) {
|
|
119
134
|
const options = [];
|
|
120
135
|
parseDef(schema._def, options);
|
|
121
136
|
return options;
|
|
122
137
|
},
|
|
138
|
+
schemaToOptions(schema) {
|
|
139
|
+
const optionsInfo = this.schemaToOptionInfo(schema);
|
|
140
|
+
const options = optionsInfo.map(option => {
|
|
141
|
+
return {
|
|
142
|
+
option: optionToString(option),
|
|
143
|
+
autocomplete: option.autocomplete
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
return options;
|
|
147
|
+
},
|
|
123
148
|
coercedEnum: (e) => z.preprocess(val => {
|
|
124
149
|
const target = String(val)?.toLowerCase();
|
|
125
150
|
for (const k of Object.values(e)) {
|
|
@@ -17,7 +17,7 @@ m365 adaptivecard send [options]
|
|
|
17
17
|
: URL where to send the card to.
|
|
18
18
|
|
|
19
19
|
`-t, --title [title]`
|
|
20
|
-
: Title of the card.
|
|
20
|
+
: Title of the card. If you specify `title` and `card`, the `title` will be merged into the card.
|
|
21
21
|
|
|
22
22
|
`-d, --description [description]`
|
|
23
23
|
: Contents of the card.
|