@pnp/cli-microsoft365 8.0.0 → 8.1.0-beta.309a9b8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/Auth.js +9 -9
- package/dist/Command.js +50 -5
- package/dist/cli/cli.js +101 -39
- package/dist/m365/commands/login.js +49 -96
- package/dist/m365/connection/commands/connection-remove.js +6 -2
- package/dist/m365/connection/commands/connection-set.js +4 -1
- package/dist/m365/connection/commands/connection-use.js +25 -4
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-remove.js +123 -0
- package/dist/m365/entra/commands/group/group-set.js +256 -0
- package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
- package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
- package/dist/m365/entra/commands/multitenant/multitenant-add.js +65 -0
- package/dist/m365/entra/commands/multitenant/multitenant-remove.js +118 -0
- package/dist/m365/entra/commands/multitenant/multitenant-set.js +72 -0
- package/dist/m365/entra/commands.js +6 -0
- package/dist/m365/flow/commands/flow-get.js +1 -1
- package/dist/m365/onenote/commands/notebook/notebook-add.js +132 -0
- package/dist/m365/onenote/commands.js +1 -0
- package/dist/m365/pa/commands/app/app-export.js +13 -7
- package/dist/m365/spe/ContainerTypeProperties.js +2 -0
- package/dist/m365/spe/commands/containertype/containertype-list.js +49 -0
- package/dist/m365/spe/commands.js +2 -1
- package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-get.js +16 -21
- package/dist/m365/spo/commands/commandset/commandset-get.js +31 -17
- package/dist/m365/spo/commands/file/file-roleassignment-add.js +1 -1
- package/dist/m365/spo/commands/file/file-roleinheritance-break.js +1 -1
- package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
- package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +1 -1
- package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +86 -0
- package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
- package/dist/m365/spo/commands/list/ListInstance.js +6 -1
- package/dist/m365/spo/commands/list/list-get.js +9 -3
- package/dist/m365/spo/commands/list/list-roleassignment-add.js +46 -21
- package/dist/m365/spo/commands/list/list-roleassignment-remove.js +48 -46
- package/dist/m365/spo/commands/site/site-get.js +12 -16
- package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-get.js +19 -5
- package/dist/m365/spo/commands/tenant/tenant-commandset-get.js +20 -6
- package/dist/m365/spo/commands.js +2 -0
- package/dist/m365/teams/commands/message/message-restore.js +106 -0
- package/dist/m365/teams/commands.js +1 -0
- package/dist/utils/drive.js +61 -0
- package/dist/utils/formatting.js +16 -0
- package/dist/utils/spo.js +69 -6
- package/dist/utils/zod.js +124 -0
- package/docs/docs/cmd/connection/connection-use.mdx +8 -2
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-remove.mdx +65 -0
- package/docs/docs/cmd/entra/group/group-add.mdx +0 -4
- package/docs/docs/cmd/entra/group/group-set.mdx +89 -0
- package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
- package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
- package/docs/docs/cmd/entra/multitenant/multitenant-add.mdx +107 -0
- package/docs/docs/cmd/entra/multitenant/multitenant-remove.mdx +58 -0
- package/docs/docs/cmd/entra/multitenant/multitenant-set.mdx +53 -0
- package/docs/docs/cmd/flow/flow-get.mdx +149 -283
- package/docs/docs/cmd/onenote/notebook/notebook-add.mdx +169 -0
- package/docs/docs/cmd/pa/app/app-export.mdx +15 -9
- package/docs/docs/cmd/planner/plan/plan-remove.mdx +1 -1
- package/docs/docs/cmd/spe/containertype/containertype-list.mdx +102 -0
- package/docs/docs/cmd/spo/app/app-uninstall.mdx +1 -1
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +87 -38
- package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +22 -28
- package/docs/docs/cmd/spo/commandset/commandset-get.mdx +75 -24
- package/docs/docs/cmd/spo/commandset/commandset-list.mdx +26 -32
- package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +2 -2
- package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +1 -1
- package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +2 -2
- package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
- package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
- package/docs/docs/cmd/spo/list/list-roleassignment-add.mdx +15 -3
- package/docs/docs/cmd/spo/list/list-roleassignment-remove.mdx +15 -3
- package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-ensure.mdx +4 -4
- package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.mdx +1 -1
- package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.mdx +9 -9
- package/docs/docs/cmd/spo/listitem/listitem-roleassignment-remove.mdx +7 -7
- package/docs/docs/cmd/spo/site/site-recyclebinitem-list.mdx +1 -1
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-get.mdx +79 -30
- package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-list.mdx +20 -19
- package/docs/docs/cmd/spo/tenant/tenant-commandset-get.mdx +84 -38
- package/docs/docs/cmd/spo/tenant/tenant-commandset-list.mdx +20 -19
- package/docs/docs/cmd/spo/web/web-roleassignment-add.mdx +1 -1
- package/docs/docs/cmd/spo/web/web-roleassignment-remove.mdx +1 -1
- package/docs/docs/cmd/teams/meeting/meeting-list.mdx +7 -3
- package/docs/docs/cmd/teams/message/message-remove.mdx +2 -1
- package/docs/docs/cmd/teams/message/message-restore.mdx +62 -0
- package/npm-shrinkwrap.json +1003 -1148
- package/package.json +27 -24
|
@@ -3,7 +3,7 @@ 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 _SpoTenantCommandSetGetCommand_instances, _SpoTenantCommandSetGetCommand_initTelemetry, _SpoTenantCommandSetGetCommand_initOptions, _SpoTenantCommandSetGetCommand_initValidators, _SpoTenantCommandSetGetCommand_initOptionSets;
|
|
6
|
+
var _SpoTenantCommandSetGetCommand_instances, _SpoTenantCommandSetGetCommand_initTelemetry, _SpoTenantCommandSetGetCommand_initOptions, _SpoTenantCommandSetGetCommand_initValidators, _SpoTenantCommandSetGetCommand_initOptionSets, _SpoTenantCommandSetGetCommand_initTypes;
|
|
7
7
|
import { cli } from '../../../../cli/cli.js';
|
|
8
8
|
import { CommandError } from '../../../../Command.js';
|
|
9
9
|
import request from '../../../../request.js';
|
|
@@ -27,6 +27,7 @@ class SpoTenantCommandSetGetCommand extends SpoCommand {
|
|
|
27
27
|
__classPrivateFieldGet(this, _SpoTenantCommandSetGetCommand_instances, "m", _SpoTenantCommandSetGetCommand_initOptions).call(this);
|
|
28
28
|
__classPrivateFieldGet(this, _SpoTenantCommandSetGetCommand_instances, "m", _SpoTenantCommandSetGetCommand_initValidators).call(this);
|
|
29
29
|
__classPrivateFieldGet(this, _SpoTenantCommandSetGetCommand_instances, "m", _SpoTenantCommandSetGetCommand_initOptionSets).call(this);
|
|
30
|
+
__classPrivateFieldGet(this, _SpoTenantCommandSetGetCommand_instances, "m", _SpoTenantCommandSetGetCommand_initTypes).call(this);
|
|
30
31
|
}
|
|
31
32
|
async commandAction(logger, args) {
|
|
32
33
|
const appCatalogUrl = await spo.getTenantAppCatalogUrl(logger, this.debug);
|
|
@@ -47,7 +48,7 @@ class SpoTenantCommandSetGetCommand extends SpoCommand {
|
|
|
47
48
|
const reqOptions = {
|
|
48
49
|
url: `${appCatalogUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')/items?$filter=${filter}`,
|
|
49
50
|
headers: {
|
|
50
|
-
|
|
51
|
+
accept: 'application/json;odata=nometadata'
|
|
51
52
|
},
|
|
52
53
|
responseType: 'json'
|
|
53
54
|
};
|
|
@@ -55,13 +56,20 @@ class SpoTenantCommandSetGetCommand extends SpoCommand {
|
|
|
55
56
|
const listItemInstances = await request.get(reqOptions);
|
|
56
57
|
if (listItemInstances?.value.length > 0) {
|
|
57
58
|
listItemInstances.value.forEach(v => delete v['ID']);
|
|
59
|
+
let listItemInstance;
|
|
58
60
|
if (listItemInstances.value.length > 1) {
|
|
59
61
|
const resultAsKeyValuePair = formatting.convertArrayToHashTable('Id', listItemInstances.value);
|
|
60
|
-
|
|
61
|
-
await logger.log(result);
|
|
62
|
+
listItemInstance = await cli.handleMultipleResultsFound(`Multiple ListView Command Sets with ${args.options.title || args.options.clientSideComponentId} were found.`, resultAsKeyValuePair);
|
|
62
63
|
}
|
|
63
64
|
else {
|
|
64
|
-
|
|
65
|
+
listItemInstance = listItemInstances.value[0];
|
|
66
|
+
}
|
|
67
|
+
if (!args.options.tenantWideExtensionComponentProperties) {
|
|
68
|
+
await logger.log(listItemInstance);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const properties = formatting.tryParseJson(listItemInstance.TenantWideExtensionComponentProperties);
|
|
72
|
+
await logger.log(properties);
|
|
65
73
|
}
|
|
66
74
|
}
|
|
67
75
|
else {
|
|
@@ -78,7 +86,8 @@ _SpoTenantCommandSetGetCommand_instances = new WeakSet(), _SpoTenantCommandSetGe
|
|
|
78
86
|
Object.assign(this.telemetryProperties, {
|
|
79
87
|
title: typeof args.options.title !== 'undefined',
|
|
80
88
|
id: typeof args.options.id !== 'undefined',
|
|
81
|
-
clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined'
|
|
89
|
+
clientSideComponentId: typeof args.options.clientSideComponentId !== 'undefined',
|
|
90
|
+
tenantWideExtensionComponentProperties: !!args.options.tenantWideExtensionComponentProperties
|
|
82
91
|
});
|
|
83
92
|
});
|
|
84
93
|
}, _SpoTenantCommandSetGetCommand_initOptions = function _SpoTenantCommandSetGetCommand_initOptions() {
|
|
@@ -88,6 +97,8 @@ _SpoTenantCommandSetGetCommand_instances = new WeakSet(), _SpoTenantCommandSetGe
|
|
|
88
97
|
option: '-i, --id [id]'
|
|
89
98
|
}, {
|
|
90
99
|
option: '-c, --clientSideComponentId [clientSideComponentId]'
|
|
100
|
+
}, {
|
|
101
|
+
option: '-p, --tenantWideExtensionComponentProperties'
|
|
91
102
|
});
|
|
92
103
|
}, _SpoTenantCommandSetGetCommand_initValidators = function _SpoTenantCommandSetGetCommand_initValidators() {
|
|
93
104
|
this.validators.push(async (args) => {
|
|
@@ -101,6 +112,9 @@ _SpoTenantCommandSetGetCommand_instances = new WeakSet(), _SpoTenantCommandSetGe
|
|
|
101
112
|
});
|
|
102
113
|
}, _SpoTenantCommandSetGetCommand_initOptionSets = function _SpoTenantCommandSetGetCommand_initOptionSets() {
|
|
103
114
|
this.optionSets.push({ options: ['title', 'id', 'clientSideComponentId'] });
|
|
115
|
+
}, _SpoTenantCommandSetGetCommand_initTypes = function _SpoTenantCommandSetGetCommand_initTypes() {
|
|
116
|
+
this.types.string.push('title', 'id', 'clientSideComponentId');
|
|
117
|
+
this.types.boolean.push('tenantWideExtensionComponentProperties');
|
|
104
118
|
};
|
|
105
119
|
export default new SpoTenantCommandSetGetCommand();
|
|
106
120
|
//# sourceMappingURL=tenant-commandset-get.js.map
|
|
@@ -100,6 +100,8 @@ export default {
|
|
|
100
100
|
FOLDER_ROLEASSIGNMENT_ADD: `${prefix} folder roleassignment add`,
|
|
101
101
|
FOLDER_ROLEINHERITANCE_BREAK: `${prefix} folder roleinheritance break`,
|
|
102
102
|
FOLDER_ROLEINHERITANCE_RESET: `${prefix} folder roleinheritance reset`,
|
|
103
|
+
FOLDER_SHARINGLINK_GET: `${prefix} folder sharinglink get`,
|
|
104
|
+
FOLDER_SHARINGLINK_LIST: `${prefix} folder sharinglink list`,
|
|
103
105
|
GET: `${prefix} get`,
|
|
104
106
|
GROUP_ADD: `${prefix} group add`,
|
|
105
107
|
GROUP_GET: `${prefix} group get`,
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _TeamsMessageRestoreCommand_instances, _TeamsMessageRestoreCommand_initTelemetry, _TeamsMessageRestoreCommand_initOptions, _TeamsMessageRestoreCommand_initValidators, _TeamsMessageRestoreCommand_initOptionSets, _TeamsMessageRestoreCommand_initTypes;
|
|
7
|
+
import request from '../../../../request.js';
|
|
8
|
+
import { validation } from '../../../../utils/validation.js';
|
|
9
|
+
import commands from '../../commands.js';
|
|
10
|
+
import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
|
|
11
|
+
import { teams } from '../../../../utils/teams.js';
|
|
12
|
+
class TeamsMessageRestoreCommand extends DelegatedGraphCommand {
|
|
13
|
+
get name() {
|
|
14
|
+
return commands.MESSAGE_RESTORE;
|
|
15
|
+
}
|
|
16
|
+
get description() {
|
|
17
|
+
return 'Restores a deleted message from a channel in a Microsoft Teams team';
|
|
18
|
+
}
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
_TeamsMessageRestoreCommand_instances.add(this);
|
|
22
|
+
__classPrivateFieldGet(this, _TeamsMessageRestoreCommand_instances, "m", _TeamsMessageRestoreCommand_initTelemetry).call(this);
|
|
23
|
+
__classPrivateFieldGet(this, _TeamsMessageRestoreCommand_instances, "m", _TeamsMessageRestoreCommand_initOptions).call(this);
|
|
24
|
+
__classPrivateFieldGet(this, _TeamsMessageRestoreCommand_instances, "m", _TeamsMessageRestoreCommand_initValidators).call(this);
|
|
25
|
+
__classPrivateFieldGet(this, _TeamsMessageRestoreCommand_instances, "m", _TeamsMessageRestoreCommand_initOptionSets).call(this);
|
|
26
|
+
__classPrivateFieldGet(this, _TeamsMessageRestoreCommand_instances, "m", _TeamsMessageRestoreCommand_initTypes).call(this);
|
|
27
|
+
}
|
|
28
|
+
async commandAction(logger, args) {
|
|
29
|
+
try {
|
|
30
|
+
if (this.verbose) {
|
|
31
|
+
await logger.logToStderr(`Restoring deleted message '${args.options.id}' from channel '${args.options.channelId || args.options.channelName}' in the Microsoft Teams team '${args.options.teamId || args.options.teamName}'.`);
|
|
32
|
+
}
|
|
33
|
+
const teamId = await this.getTeamId(args.options, logger);
|
|
34
|
+
const channelId = await this.getChannelId(args.options, teamId, logger);
|
|
35
|
+
const requestOptions = {
|
|
36
|
+
url: `${this.resource}/v1.0/teams/${teamId}/channels/${channelId}/messages/${args.options.id}/undoSoftDelete`,
|
|
37
|
+
headers: {
|
|
38
|
+
accept: 'application/json;odata.metadata=none'
|
|
39
|
+
},
|
|
40
|
+
responseType: 'json'
|
|
41
|
+
};
|
|
42
|
+
await request.post(requestOptions);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
this.handleRejectedODataJsonPromise(err);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async getTeamId(options, logger) {
|
|
49
|
+
if (options.teamId) {
|
|
50
|
+
return options.teamId;
|
|
51
|
+
}
|
|
52
|
+
if (this.verbose) {
|
|
53
|
+
await logger.logToStderr(`Getting the Team ID.`);
|
|
54
|
+
}
|
|
55
|
+
const groupId = await teams.getTeamIdByDisplayName(options.teamName);
|
|
56
|
+
return groupId;
|
|
57
|
+
}
|
|
58
|
+
async getChannelId(options, teamId, logger) {
|
|
59
|
+
if (options.channelId) {
|
|
60
|
+
return options.channelId;
|
|
61
|
+
}
|
|
62
|
+
if (this.verbose) {
|
|
63
|
+
await logger.logToStderr(`Getting the channel ID.`);
|
|
64
|
+
}
|
|
65
|
+
const channelId = await teams.getChannelIdByDisplayName(teamId, options.channelName);
|
|
66
|
+
return channelId;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_TeamsMessageRestoreCommand_instances = new WeakSet(), _TeamsMessageRestoreCommand_initTelemetry = function _TeamsMessageRestoreCommand_initTelemetry() {
|
|
70
|
+
this.telemetry.push((args) => {
|
|
71
|
+
Object.assign(this.telemetryProperties, {
|
|
72
|
+
teamId: typeof args.options.teamId !== 'undefined',
|
|
73
|
+
teamName: typeof args.options.teamName !== 'undefined',
|
|
74
|
+
channelId: typeof args.options.channelId !== 'undefined',
|
|
75
|
+
channelName: typeof args.options.channelName !== 'undefined'
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
}, _TeamsMessageRestoreCommand_initOptions = function _TeamsMessageRestoreCommand_initOptions() {
|
|
79
|
+
this.options.unshift({
|
|
80
|
+
option: '--teamId [teamId]'
|
|
81
|
+
}, {
|
|
82
|
+
option: '--teamName [teamName]'
|
|
83
|
+
}, {
|
|
84
|
+
option: '--channelId [channelId]'
|
|
85
|
+
}, {
|
|
86
|
+
option: '--channelName [channelName]'
|
|
87
|
+
}, {
|
|
88
|
+
option: '-i, --id <id>'
|
|
89
|
+
});
|
|
90
|
+
}, _TeamsMessageRestoreCommand_initValidators = function _TeamsMessageRestoreCommand_initValidators() {
|
|
91
|
+
this.validators.push(async (args) => {
|
|
92
|
+
if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
|
|
93
|
+
return `'${args.options.teamId}' is not a valid GUID for 'teamId'.`;
|
|
94
|
+
}
|
|
95
|
+
if (args.options.channelId && !validation.isValidTeamsChannelId(args.options.channelId)) {
|
|
96
|
+
return `'${args.options.channelId}' is not a valid ID for 'channelId'.`;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
});
|
|
100
|
+
}, _TeamsMessageRestoreCommand_initOptionSets = function _TeamsMessageRestoreCommand_initOptionSets() {
|
|
101
|
+
this.optionSets.push({ options: ['teamId', 'teamName'] }, { options: ['channelId', 'channelName'] });
|
|
102
|
+
}, _TeamsMessageRestoreCommand_initTypes = function _TeamsMessageRestoreCommand_initTypes() {
|
|
103
|
+
this.types.string.push('teamId', 'teamName', 'channelId', 'channelName', 'id');
|
|
104
|
+
};
|
|
105
|
+
export default new TeamsMessageRestoreCommand();
|
|
106
|
+
//# sourceMappingURL=message-restore.js.map
|
|
@@ -39,6 +39,7 @@ export default {
|
|
|
39
39
|
MESSAGE_LIST: `${prefix} message list`,
|
|
40
40
|
MESSAGE_REMOVE: `${prefix} message remove`,
|
|
41
41
|
MESSAGE_REPLY_LIST: `${prefix} message reply list`,
|
|
42
|
+
MESSAGE_RESTORE: `${prefix} message restore`,
|
|
42
43
|
MESSAGE_SEND: `${prefix} message send`,
|
|
43
44
|
MESSAGINGSETTINGS_LIST: `${prefix} messagingsettings list`,
|
|
44
45
|
MESSAGINGSETTINGS_SET: `${prefix} messagingsettings set`,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import request from "../request.js";
|
|
2
|
+
export const drive = {
|
|
3
|
+
/**
|
|
4
|
+
* Retrieves the Drive associated with the specified site and URL.
|
|
5
|
+
* @param siteId Site ID
|
|
6
|
+
* @param url Drive URL
|
|
7
|
+
* @param logger The logger object
|
|
8
|
+
* @param verbose Set for verbose logging
|
|
9
|
+
* @returns The Drive associated with the drive URL.
|
|
10
|
+
*/
|
|
11
|
+
async getDriveByUrl(siteId, url, logger, verbose) {
|
|
12
|
+
if (verbose && logger) {
|
|
13
|
+
await logger.logToStderr(`Retrieving drive information for URL: ${url.href}`);
|
|
14
|
+
}
|
|
15
|
+
const requestOptions = {
|
|
16
|
+
url: `https://graph.microsoft.com/v1.0/sites/${siteId}/drives?$select=webUrl,id`,
|
|
17
|
+
headers: {
|
|
18
|
+
accept: 'application/json;odata.metadata=none'
|
|
19
|
+
},
|
|
20
|
+
responseType: 'json'
|
|
21
|
+
};
|
|
22
|
+
const drives = await request.get(requestOptions);
|
|
23
|
+
const lowerCaseFolderUrl = url.href.toLowerCase();
|
|
24
|
+
const drive = drives.value
|
|
25
|
+
.sort((a, b) => b.webUrl.localeCompare(a.webUrl))
|
|
26
|
+
.find((d) => {
|
|
27
|
+
const driveUrl = d.webUrl.toLowerCase();
|
|
28
|
+
return lowerCaseFolderUrl.startsWith(driveUrl) &&
|
|
29
|
+
(driveUrl.length === lowerCaseFolderUrl.length ||
|
|
30
|
+
lowerCaseFolderUrl[driveUrl.length] === '/');
|
|
31
|
+
});
|
|
32
|
+
if (!drive) {
|
|
33
|
+
throw new Error(`Drive '${url.href}' not found`);
|
|
34
|
+
}
|
|
35
|
+
return drive;
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the ID of a drive item (file, folder, etc.) associated with the given drive and item URL.
|
|
39
|
+
* @param drive The Drive object containing the item
|
|
40
|
+
* @param itemUrl Item URL
|
|
41
|
+
* @param logger The logger object
|
|
42
|
+
* @param verbose Set for verbose logging
|
|
43
|
+
* @returns Drive item ID
|
|
44
|
+
*/
|
|
45
|
+
async getDriveItemId(drive, itemUrl, logger, verbose) {
|
|
46
|
+
const relativeItemUrl = itemUrl.href.replace(new RegExp(`${drive.webUrl}`, 'i'), '').replace(/\/+$/, '');
|
|
47
|
+
if (verbose && logger) {
|
|
48
|
+
await logger.logToStderr(`Retrieving drive item ID for URL: ${relativeItemUrl}`);
|
|
49
|
+
}
|
|
50
|
+
const requestOptions = {
|
|
51
|
+
url: `https://graph.microsoft.com/v1.0/drives/${drive.id}/root${relativeItemUrl ? `:${relativeItemUrl}` : ''}?$select=id`,
|
|
52
|
+
headers: {
|
|
53
|
+
accept: 'application/json;odata.metadata=none'
|
|
54
|
+
},
|
|
55
|
+
responseType: 'json'
|
|
56
|
+
};
|
|
57
|
+
const driveItem = await request.get(requestOptions);
|
|
58
|
+
return driveItem?.id;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=drive.js.map
|
package/dist/utils/formatting.js
CHANGED
|
@@ -39,6 +39,22 @@ export const formatting = {
|
|
|
39
39
|
parseJsonWithBom(s) {
|
|
40
40
|
return JSON.parse(s.replace(/^\uFEFF/, ''));
|
|
41
41
|
},
|
|
42
|
+
/**
|
|
43
|
+
* Tries to parse a string as JSON. If it fails, returns the original string.
|
|
44
|
+
* @param value JSON string to parse.
|
|
45
|
+
* @returns JSON object or the original string if parsing fails.
|
|
46
|
+
*/
|
|
47
|
+
tryParseJson(value) {
|
|
48
|
+
try {
|
|
49
|
+
if (typeof value !== 'string') {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
return JSON.parse(value);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
42
58
|
filterObject(obj, propertiesToInclude) {
|
|
43
59
|
const objKeys = Object.keys(obj);
|
|
44
60
|
return propertiesToInclude
|
package/dist/utils/spo.js
CHANGED
|
@@ -454,15 +454,46 @@ export const spo = {
|
|
|
454
454
|
const res = await request.get(requestOptions);
|
|
455
455
|
return res.AadObjectId.NameId;
|
|
456
456
|
},
|
|
457
|
+
/**
|
|
458
|
+
* Ensure a user exists on a specific SharePoint site.
|
|
459
|
+
* @param webUrl URL of the SharePoint site.
|
|
460
|
+
* @param logonName Logon name of the user to ensure on the SharePoint site.
|
|
461
|
+
* @returns SharePoint user object.
|
|
462
|
+
*/
|
|
463
|
+
async ensureUser(webUrl, logonName) {
|
|
464
|
+
const requestOptions = {
|
|
465
|
+
url: `${webUrl}/_api/web/EnsureUser`,
|
|
466
|
+
headers: {
|
|
467
|
+
accept: 'application/json;odata=nometadata'
|
|
468
|
+
},
|
|
469
|
+
responseType: 'json',
|
|
470
|
+
data: {
|
|
471
|
+
logonName: logonName
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
return request.post(requestOptions);
|
|
475
|
+
},
|
|
476
|
+
/**
|
|
477
|
+
* Ensure a Microsoft Entra ID group exists on a specific SharePoint site.
|
|
478
|
+
* @param webUrl URL of the SharePoint site.
|
|
479
|
+
* @param group Microsoft Entra ID group.
|
|
480
|
+
* @returns SharePoint user object.
|
|
481
|
+
*/
|
|
482
|
+
async ensureEntraGroup(webUrl, group) {
|
|
483
|
+
if (!group.securityEnabled) {
|
|
484
|
+
throw new Error('Cannot ensure a Microsoft Entra ID group that is not security enabled.');
|
|
485
|
+
}
|
|
486
|
+
return this.ensureUser(webUrl, group.mailEnabled ? `c:0o.c|federateddirectoryclaimprovider|${group.id}` : `c:0t.c|tenant|${group.id}`);
|
|
487
|
+
},
|
|
457
488
|
/**
|
|
458
489
|
* Retrieves the spo user by email.
|
|
459
490
|
* @param webUrl Web url
|
|
460
491
|
* @param email The email of the user
|
|
461
492
|
* @param logger the Logger object
|
|
462
|
-
* @param
|
|
493
|
+
* @param verbose set if verbose logging should be logged
|
|
463
494
|
*/
|
|
464
|
-
async getUserByEmail(webUrl, email, logger,
|
|
465
|
-
if (
|
|
495
|
+
async getUserByEmail(webUrl, email, logger, verbose) {
|
|
496
|
+
if (verbose) {
|
|
466
497
|
await logger.logToStderr(`Retrieving the spo user by email ${email}`);
|
|
467
498
|
}
|
|
468
499
|
const requestUrl = `${webUrl}/_api/web/siteusers/GetByEmail('${formatting.encodeQueryParameter(email)}')`;
|
|
@@ -533,10 +564,10 @@ export const spo = {
|
|
|
533
564
|
* @param webUrl Web url
|
|
534
565
|
* @param name The name of the group
|
|
535
566
|
* @param logger the Logger object
|
|
536
|
-
* @param
|
|
567
|
+
* @param verbose set if verbose logging should be logged
|
|
537
568
|
*/
|
|
538
|
-
async getGroupByName(webUrl, name, logger,
|
|
539
|
-
if (
|
|
569
|
+
async getGroupByName(webUrl, name, logger, verbose) {
|
|
570
|
+
if (verbose) {
|
|
540
571
|
await logger.logToStderr(`Retrieving the group by name ${name}`);
|
|
541
572
|
}
|
|
542
573
|
const requestUrl = `${webUrl}/_api/web/sitegroups/GetByName('${formatting.encodeQueryParameter(name)}')`;
|
|
@@ -1374,6 +1405,38 @@ export const spo = {
|
|
|
1374
1405
|
const site = await request.get(requestOptions);
|
|
1375
1406
|
return site.id;
|
|
1376
1407
|
},
|
|
1408
|
+
/**
|
|
1409
|
+
* Retrieves the server-relative URL of a folder.
|
|
1410
|
+
* @param webUrl Web URL
|
|
1411
|
+
* @param folderUrl Folder URL
|
|
1412
|
+
* @param folderId Folder ID
|
|
1413
|
+
* @param logger The logger object
|
|
1414
|
+
* @param verbose Set for verbose logging
|
|
1415
|
+
* @returns The server-relative URL of the folder
|
|
1416
|
+
*/
|
|
1417
|
+
async getFolderServerRelativeUrl(webUrl, folderUrl, folderId, logger, verbose) {
|
|
1418
|
+
if (verbose && logger) {
|
|
1419
|
+
await logger.logToStderr(`Retrieving server-relative URL for folder ${folderUrl ? `URL: ${folderUrl}` : `ID: ${folderId}`}`);
|
|
1420
|
+
}
|
|
1421
|
+
let requestUrl = `${webUrl}/_api/web/`;
|
|
1422
|
+
if (folderUrl) {
|
|
1423
|
+
const folderServerRelativeUrl = urlUtil.getServerRelativePath(webUrl, folderUrl);
|
|
1424
|
+
requestUrl += `GetFolderByServerRelativePath(decodedUrl='${formatting.encodeQueryParameter(folderServerRelativeUrl)}')`;
|
|
1425
|
+
}
|
|
1426
|
+
else {
|
|
1427
|
+
requestUrl += `GetFolderById('${folderId}')`;
|
|
1428
|
+
}
|
|
1429
|
+
requestUrl += '?$select=ServerRelativeUrl';
|
|
1430
|
+
const requestOptions = {
|
|
1431
|
+
url: requestUrl,
|
|
1432
|
+
headers: {
|
|
1433
|
+
accept: 'application/json;odata=nometadata'
|
|
1434
|
+
},
|
|
1435
|
+
responseType: 'json'
|
|
1436
|
+
};
|
|
1437
|
+
const res = await request.get(requestOptions);
|
|
1438
|
+
return res.ServerRelativeUrl;
|
|
1439
|
+
},
|
|
1377
1440
|
/**
|
|
1378
1441
|
* Retrieves the ObjectIdentity from a SharePoint site
|
|
1379
1442
|
* @param webUrl web url
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
function parseEffect(def, _options, _currentOption) {
|
|
3
|
+
return def.schema._def;
|
|
4
|
+
}
|
|
5
|
+
function parseIntersection(def, _options, _currentOption) {
|
|
6
|
+
if (def.left._def.typeName !== z.ZodFirstPartyTypeKind.ZodAny) {
|
|
7
|
+
return def.left._def;
|
|
8
|
+
}
|
|
9
|
+
if (def.right._def.typeName !== z.ZodFirstPartyTypeKind.ZodAny) {
|
|
10
|
+
return def.right._def;
|
|
11
|
+
}
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
function parseObject(def, options, _currentOption) {
|
|
15
|
+
const properties = def.shape();
|
|
16
|
+
for (const key in properties) {
|
|
17
|
+
const property = properties[key];
|
|
18
|
+
const option = {
|
|
19
|
+
name: key,
|
|
20
|
+
long: key,
|
|
21
|
+
short: property._def.alias,
|
|
22
|
+
required: true,
|
|
23
|
+
type: 'string'
|
|
24
|
+
};
|
|
25
|
+
parseDef(property._def, options, option);
|
|
26
|
+
options.push(option);
|
|
27
|
+
}
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
function parseString(_def, _options, currentOption) {
|
|
31
|
+
if (currentOption) {
|
|
32
|
+
currentOption.type = 'string';
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
function parseNumber(_def, _options, currentOption) {
|
|
37
|
+
if (currentOption) {
|
|
38
|
+
currentOption.type = 'number';
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
function parseBoolean(_def, _options, currentOption) {
|
|
43
|
+
if (currentOption) {
|
|
44
|
+
currentOption.type = 'boolean';
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
function parseOptional(def, _options, currentOption) {
|
|
49
|
+
if (currentOption) {
|
|
50
|
+
currentOption.required = false;
|
|
51
|
+
}
|
|
52
|
+
return def.innerType._def;
|
|
53
|
+
}
|
|
54
|
+
function parseDefault(def, _options, currentOption) {
|
|
55
|
+
if (currentOption) {
|
|
56
|
+
currentOption.required = false;
|
|
57
|
+
}
|
|
58
|
+
return def.innerType._def;
|
|
59
|
+
}
|
|
60
|
+
function parseEnum(def, _options, currentOption) {
|
|
61
|
+
if (currentOption) {
|
|
62
|
+
currentOption.type = 'string';
|
|
63
|
+
currentOption.autocomplete = def.values;
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
function parseNativeEnum(def, _options, currentOption) {
|
|
68
|
+
if (currentOption) {
|
|
69
|
+
currentOption.type = 'string';
|
|
70
|
+
currentOption.autocomplete = Object.getOwnPropertyNames(def.values);
|
|
71
|
+
}
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
function getParseFn(typeName) {
|
|
75
|
+
switch (typeName) {
|
|
76
|
+
case z.ZodFirstPartyTypeKind.ZodEffects:
|
|
77
|
+
return parseEffect;
|
|
78
|
+
case z.ZodFirstPartyTypeKind.ZodObject:
|
|
79
|
+
return parseObject;
|
|
80
|
+
case z.ZodFirstPartyTypeKind.ZodOptional:
|
|
81
|
+
return parseOptional;
|
|
82
|
+
case z.ZodFirstPartyTypeKind.ZodString:
|
|
83
|
+
return parseString;
|
|
84
|
+
case z.ZodFirstPartyTypeKind.ZodNumber:
|
|
85
|
+
return parseNumber;
|
|
86
|
+
case z.ZodFirstPartyTypeKind.ZodBoolean:
|
|
87
|
+
return parseBoolean;
|
|
88
|
+
case z.ZodFirstPartyTypeKind.ZodEnum:
|
|
89
|
+
return parseEnum;
|
|
90
|
+
case z.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
91
|
+
return parseNativeEnum;
|
|
92
|
+
case z.ZodFirstPartyTypeKind.ZodDefault:
|
|
93
|
+
return parseDefault;
|
|
94
|
+
case z.ZodFirstPartyTypeKind.ZodIntersection:
|
|
95
|
+
return parseIntersection;
|
|
96
|
+
default:
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function parseDef(def, options, currentOption) {
|
|
101
|
+
let parsedDef = def;
|
|
102
|
+
do {
|
|
103
|
+
const parse = getParseFn(parsedDef.typeName);
|
|
104
|
+
if (!parse) {
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
parsedDef = parse(parsedDef, options, currentOption);
|
|
108
|
+
if (!parsedDef) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
} while (parsedDef);
|
|
112
|
+
}
|
|
113
|
+
export const zod = {
|
|
114
|
+
alias(alias, type) {
|
|
115
|
+
type._def.alias = alias;
|
|
116
|
+
return type;
|
|
117
|
+
},
|
|
118
|
+
schemaToOptions(schema) {
|
|
119
|
+
const options = [];
|
|
120
|
+
parseDef(schema._def, options);
|
|
121
|
+
return options;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=zod.js.map
|
|
@@ -15,7 +15,7 @@ m365 connection use [options]
|
|
|
15
15
|
## Options
|
|
16
16
|
|
|
17
17
|
```md definition-list
|
|
18
|
-
`-n, --name
|
|
18
|
+
`-n, --name [name]`
|
|
19
19
|
: The name of the connection to switch to.
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -23,7 +23,13 @@ m365 connection use [options]
|
|
|
23
23
|
|
|
24
24
|
## Remarks
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
:::tip
|
|
27
|
+
|
|
28
|
+
If you haven't disabled the "prompt" setting, running this command without options will show a list of available connections. You can then select the connection to activate it.
|
|
29
|
+
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
You can update the name of a connection by running [m365 connection set](connection-set.mdx).
|
|
27
33
|
|
|
28
34
|
## Examples
|
|
29
35
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import Global from '/docs/cmd/_global.mdx';
|
|
2
|
+
import Tabs from '@theme/Tabs';
|
|
3
|
+
import TabItem from '@theme/TabItem';
|
|
4
|
+
|
|
5
|
+
# entra enterpriseapp remove
|
|
6
|
+
|
|
7
|
+
Deletes an enterprise application (or service principal)
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
m365 entra enterpriseapp remove [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Alias
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
m365 entra sp remove [options]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Options
|
|
22
|
+
|
|
23
|
+
```md definition-list
|
|
24
|
+
`-i, --id [id]`
|
|
25
|
+
: ID of the enterprise application.
|
|
26
|
+
|
|
27
|
+
`-n, --displayName [displayName]`
|
|
28
|
+
: Display name of the enterprise application.
|
|
29
|
+
|
|
30
|
+
`--objectId [objectId]`
|
|
31
|
+
: ObjectId of the enterprise application.
|
|
32
|
+
|
|
33
|
+
`-f, --force`
|
|
34
|
+
: Don't prompt for confirmation.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
<Global />
|
|
38
|
+
|
|
39
|
+
## Examples
|
|
40
|
+
|
|
41
|
+
Delete an enterprise application by application ID.
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
m365 entra enterpriseapp remove --id b2307a39-e878-458b-bc90-03bc578531d6 --force
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Delete an enterprise application by display name.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
m365 entra enterpriseapp remove --displayName "Contoso app"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Delete an enterprise application by object ID.
|
|
54
|
+
|
|
55
|
+
```sh
|
|
56
|
+
m365 entra enterpriseapp remove --objectId b2307a39-e878-458b-bc90-03bc578531dd
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Response
|
|
60
|
+
|
|
61
|
+
The command won't return a response on success.
|
|
62
|
+
|
|
63
|
+
## More information
|
|
64
|
+
|
|
65
|
+
- Application and service principal objects in Microsoft Entra ID: [https://learn.microsoft.com/azure/active-directory/develop/active-directory-application-objects](https://learn.microsoft.com/azure/active-directory/develop/active-directory-application-objects)
|
|
@@ -53,8 +53,6 @@ m365 aad group add [options]
|
|
|
53
53
|
|
|
54
54
|
## Remarks
|
|
55
55
|
|
|
56
|
-
:::info
|
|
57
|
-
|
|
58
56
|
The `visibility` option affects the behavior of the group.
|
|
59
57
|
|
|
60
58
|
With the `Public` visibility:
|
|
@@ -74,8 +72,6 @@ With the `HiddenMembership` visibility:
|
|
|
74
72
|
- Administrators (global, company, user, and helpdesk) can view the membership of the group.
|
|
75
73
|
- The group appears in the global address book (GAL).
|
|
76
74
|
|
|
77
|
-
:::
|
|
78
|
-
|
|
79
75
|
:::note
|
|
80
76
|
|
|
81
77
|
The `HiddenMembership` visibility can be set only for Microsoft 365 groups when the groups are created. It can't be updated later.
|