@pnp/cli-microsoft365 11.7.0-beta.b67a258 → 11.7.0-beta.bd906c5
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/config.js +1 -0
- package/dist/m365/entra/commands/user/user-license-add.js +2 -1
- package/dist/m365/entra/commands/user/user-license-list.js +4 -9
- package/dist/m365/entra/commands/user/user-license-remove.js +2 -1
- package/dist/m365/outlook/commands/calendar/calendar-add.js +85 -0
- package/dist/m365/outlook/commands/calendar/calendar-get.js +71 -0
- package/dist/m365/outlook/commands/calendar/calendar-remove.js +100 -0
- package/dist/m365/outlook/commands/calendargroup/calendargroup-set.js +115 -0
- package/dist/m365/outlook/commands/event/event-cancel.js +103 -0
- package/dist/m365/outlook/commands/event/event-list.js +115 -0
- package/dist/m365/outlook/commands/event/event-remove.js +104 -0
- package/dist/m365/outlook/commands.js +7 -0
- package/dist/m365/spfx/commands/SpfxCompatibilityMatrix.js +643 -0
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +2 -2
- package/dist/m365/spfx/commands/project/project-azuredevops-pipeline-add.js +13 -1
- package/dist/m365/spfx/commands/project/project-doctor/doctor-1.23.0-rc.0.js +19 -0
- package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +16 -1
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002021_DEVDEP_rushstack_eslint_config.js +2 -2
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002032_DEVDEP_typescript_eslint_parser.js +2 -2
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015008_FILE_eslintrc_js.js +1 -1
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015016_FILE_eslint_config_js.js +10 -0
- package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.23.0-rc.0.js +84 -0
- package/dist/m365/spfx/commands/project/project-upgrade.js +12 -11
- package/dist/m365/spfx/commands/spfx-doctor.js +5 -631
- package/dist/m365/teams/commands/chat/chat-message-list.js +43 -4
- package/dist/utils/calendar.js +37 -0
- package/dist/utils/calendarGroup.js +22 -0
- package/dist/utils/entraApp.js +9 -2
- package/dist/utils/spfx.js +59 -0
- package/docs/docs/cmd/entra/license/license-list.mdx +19 -0
- package/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx +19 -0
- package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +19 -0
- package/docs/docs/cmd/entra/user/user-groupmembership-list.mdx +19 -0
- package/docs/docs/cmd/entra/user/user-guest-add.mdx +19 -0
- package/docs/docs/cmd/entra/user/user-license-add.mdx +19 -0
- package/docs/docs/cmd/entra/user/user-license-list.mdx +18 -1
- package/docs/docs/cmd/entra/user/user-license-remove.mdx +21 -0
- package/docs/docs/cmd/entra/user/user-password-validate.mdx +12 -0
- package/docs/docs/cmd/entra/user/user-recyclebinitem-clear.mdx +21 -0
- package/docs/docs/cmd/entra/user/user-recyclebinitem-list.mdx +19 -0
- package/docs/docs/cmd/entra/user/user-recyclebinitem-remove.mdx +21 -0
- package/docs/docs/cmd/entra/user/user-recyclebinitem-restore.mdx +19 -0
- package/docs/docs/cmd/entra/user/user-registrationdetails-list.mdx +19 -0
- package/docs/docs/cmd/entra/user/user-session-revoke.mdx +21 -0
- package/docs/docs/cmd/entra/user/user-signin-list.mdx +19 -0
- package/docs/docs/cmd/exo/approleassignment/approleassignment-add.mdx +19 -0
- package/docs/docs/cmd/file/convert/convert-pdf.mdx +21 -0
- package/docs/docs/cmd/file/file-add.mdx +21 -0
- package/docs/docs/cmd/file/file-copy.mdx +21 -0
- package/docs/docs/cmd/file/file-list.mdx +19 -0
- package/docs/docs/cmd/file/file-move.mdx +21 -0
- package/docs/docs/cmd/outlook/calendar/calendar-add.mdx +165 -0
- package/docs/docs/cmd/outlook/calendar/calendar-get.mdx +165 -0
- package/docs/docs/cmd/outlook/calendar/calendar-remove.mdx +86 -0
- package/docs/docs/cmd/outlook/calendargroup/calendargroup-set.mdx +83 -0
- package/docs/docs/cmd/outlook/event/event-cancel.mdx +85 -0
- package/docs/docs/cmd/outlook/event/event-list.mdx +245 -0
- package/docs/docs/cmd/outlook/event/event-remove.mdx +85 -0
- package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
- package/docs/docs/cmd/teams/chat/chat-message-list.mdx +23 -2
- package/npm-shrinkwrap.json +0 -7
- package/package.json +2 -1
package/dist/config.js
CHANGED
|
@@ -7,6 +7,7 @@ export default {
|
|
|
7
7
|
'https://graph.microsoft.com/AuditLog.Read.All',
|
|
8
8
|
'https://graph.microsoft.com/Bookings.Read.All',
|
|
9
9
|
'https://graph.microsoft.com/Calendars.Read',
|
|
10
|
+
'https://graph.microsoft.com/Calendars.ReadWrite',
|
|
10
11
|
'https://graph.microsoft.com/ChannelMember.ReadWrite.All',
|
|
11
12
|
'https://graph.microsoft.com/ChannelMessage.Read.All',
|
|
12
13
|
'https://graph.microsoft.com/ChannelMessage.ReadWrite',
|
|
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _EntraUserLicenseAddCommand_instances, _EntraUserLicenseAddCommand_initTelemetry, _EntraUserLicenseAddCommand_initOptions, _EntraUserLicenseAddCommand_initValidators, _EntraUserLicenseAddCommand_initOptionSets;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
8
9
|
import { validation } from '../../../../utils/validation.js';
|
|
9
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
10
11
|
import commands from '../../commands.js';
|
|
@@ -27,7 +28,7 @@ class EntraUserLicenseAddCommand extends GraphCommand {
|
|
|
27
28
|
const addLicenses = args.options.ids.split(',').map(x => { return { "disabledPlans": [], "skuId": x }; });
|
|
28
29
|
const requestBody = { "addLicenses": addLicenses, "removeLicenses": [] };
|
|
29
30
|
const requestOptions = {
|
|
30
|
-
url: `${this.resource}/v1.0/users/${args.options.userId || args.options.userName}/assignLicense`,
|
|
31
|
+
url: `${this.resource}/v1.0/users/${formatting.encodeQueryParameter(args.options.userId || args.options.userName)}/assignLicense`,
|
|
31
32
|
headers: {
|
|
32
33
|
accept: 'application/json;odata.metadata=none'
|
|
33
34
|
},
|
|
@@ -4,13 +4,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _EntraUserLicenseListCommand_instances, _EntraUserLicenseListCommand_initTelemetry, _EntraUserLicenseListCommand_initOptions, _EntraUserLicenseListCommand_initValidators, _EntraUserLicenseListCommand_initOptionSets;
|
|
7
|
-
import { accessToken } from '../../../../utils/accessToken.js';
|
|
8
7
|
import { odata } from '../../../../utils/odata.js';
|
|
8
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
|
-
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
10
|
import commands from '../../commands.js';
|
|
12
|
-
import
|
|
13
|
-
class EntraUserLicenseListCommand extends
|
|
11
|
+
import GraphDelegatedCommand from '../../../base/GraphDelegatedCommand.js';
|
|
12
|
+
class EntraUserLicenseListCommand extends GraphDelegatedCommand {
|
|
14
13
|
get name() {
|
|
15
14
|
return commands.USER_LICENSE_LIST;
|
|
16
15
|
}
|
|
@@ -29,16 +28,12 @@ class EntraUserLicenseListCommand extends GraphCommand {
|
|
|
29
28
|
__classPrivateFieldGet(this, _EntraUserLicenseListCommand_instances, "m", _EntraUserLicenseListCommand_initOptionSets).call(this);
|
|
30
29
|
}
|
|
31
30
|
async commandAction(logger, args) {
|
|
32
|
-
const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[this.resource].accessToken);
|
|
33
|
-
if (isAppOnlyAccessToken && !args.options.userId && !args.options.userName) {
|
|
34
|
-
this.handleError(`Specify at least 'userId' or 'userName' when using application permissions.`);
|
|
35
|
-
}
|
|
36
31
|
if (this.verbose) {
|
|
37
32
|
await logger.logToStderr(`Retrieving licenses from user: ${args.options.userId || args.options.userName || 'current user'}.`);
|
|
38
33
|
}
|
|
39
34
|
let requestUrl = `${this.resource}/v1.0/`;
|
|
40
35
|
if (args.options.userId || args.options.userName) {
|
|
41
|
-
requestUrl += `users/${args.options.userId || args.options.userName}`;
|
|
36
|
+
requestUrl += `users/${formatting.encodeQueryParameter(args.options.userId || args.options.userName)}`;
|
|
42
37
|
}
|
|
43
38
|
else {
|
|
44
39
|
requestUrl += 'me';
|
|
@@ -7,6 +7,7 @@ var _EntraUserLicenseRemoveCommand_instances, _EntraUserLicenseRemoveCommand_ini
|
|
|
7
7
|
import commands from '../../commands.js';
|
|
8
8
|
import request from '../../../../request.js';
|
|
9
9
|
import { validation } from '../../../../utils/validation.js';
|
|
10
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
10
11
|
import { cli } from '../../../../cli/cli.js';
|
|
11
12
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
12
13
|
class EntraUserLicenseRemoveCommand extends GraphCommand {
|
|
@@ -42,7 +43,7 @@ class EntraUserLicenseRemoveCommand extends GraphCommand {
|
|
|
42
43
|
const removeLicenses = args.options.ids.split(',');
|
|
43
44
|
const requestBody = { "addLicenses": [], "removeLicenses": removeLicenses };
|
|
44
45
|
const requestOptions = {
|
|
45
|
-
url: `${this.resource}/v1.0/users/${args.options.userId || args.options.userName}/assignLicense`,
|
|
46
|
+
url: `${this.resource}/v1.0/users/${formatting.encodeQueryParameter(args.options.userId || args.options.userName)}/assignLicense`,
|
|
46
47
|
headers: {
|
|
47
48
|
accept: 'application/json;odata.metadata=none'
|
|
48
49
|
},
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import request from '../../../../request.js';
|
|
2
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
3
|
+
import commands from '../../commands.js';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
6
|
+
import { validation } from '../../../../utils/validation.js';
|
|
7
|
+
import { calendarGroup } from '../../../../utils/calendarGroup.js';
|
|
8
|
+
export const options = z.strictObject({
|
|
9
|
+
...globalOptionsZod.shape,
|
|
10
|
+
userId: z.string()
|
|
11
|
+
.refine(userId => validation.isValidGuid(userId), {
|
|
12
|
+
error: e => `'${e.input}' is not a valid GUID.`
|
|
13
|
+
}).optional(),
|
|
14
|
+
userName: z.string()
|
|
15
|
+
.refine(userName => validation.isValidUserPrincipalName(userName), {
|
|
16
|
+
error: e => `'${e.input}' is not a valid UPN.`
|
|
17
|
+
}).optional(),
|
|
18
|
+
name: z.string(),
|
|
19
|
+
calendarGroupId: z.string().optional(),
|
|
20
|
+
calendarGroupName: z.string().optional(),
|
|
21
|
+
color: z.enum(['auto', 'lightBlue', 'lightGreen', 'lightOrange', 'lightGray', 'lightYellow', 'lightTeal', 'lightPink', 'lightBrown', 'lightRed', 'maxColor']).optional().default('auto'),
|
|
22
|
+
defaultOnlineMeetingProvider: z.enum(['none', 'teamsForBusiness']).optional().default('teamsForBusiness'),
|
|
23
|
+
default: z.boolean().optional()
|
|
24
|
+
});
|
|
25
|
+
class OutlookCalendarAddCommand extends GraphCommand {
|
|
26
|
+
get name() {
|
|
27
|
+
return commands.CALENDAR_ADD;
|
|
28
|
+
}
|
|
29
|
+
get description() {
|
|
30
|
+
return 'Creates a new calendar for a user';
|
|
31
|
+
}
|
|
32
|
+
get schema() {
|
|
33
|
+
return options;
|
|
34
|
+
}
|
|
35
|
+
getRefinedSchema(schema) {
|
|
36
|
+
return schema
|
|
37
|
+
.refine(options => !(options.userId && options.userName), {
|
|
38
|
+
error: 'Specify either userId or userName, but not both'
|
|
39
|
+
})
|
|
40
|
+
.refine(options => !(options.calendarGroupId && options.calendarGroupName), {
|
|
41
|
+
error: 'Specify either calendarGroupId or calendarGroupName, but not both'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async commandAction(logger, args) {
|
|
45
|
+
try {
|
|
46
|
+
const userIdentifier = args.options.userId ?? args.options.userName;
|
|
47
|
+
let requestUrl = `${this.resource}/v1.0/users('${userIdentifier}')/`;
|
|
48
|
+
if (args.options.calendarGroupId || args.options.calendarGroupName) {
|
|
49
|
+
let calendarGroupId = args.options.calendarGroupId;
|
|
50
|
+
if (args.options.calendarGroupName) {
|
|
51
|
+
const group = await calendarGroup.getUserCalendarGroupByName(userIdentifier, args.options.calendarGroupName, 'id');
|
|
52
|
+
calendarGroupId = group.id;
|
|
53
|
+
}
|
|
54
|
+
requestUrl += `calendarGroups/${calendarGroupId}/calendars`;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
requestUrl += 'calendars';
|
|
58
|
+
}
|
|
59
|
+
if (args.options.verbose) {
|
|
60
|
+
await logger.logToStderr(`Creating a calendar for the user ${userIdentifier}...`);
|
|
61
|
+
}
|
|
62
|
+
const requestOptions = {
|
|
63
|
+
url: requestUrl,
|
|
64
|
+
headers: {
|
|
65
|
+
accept: 'application/json;odata.metadata=none',
|
|
66
|
+
'content-type': 'application/json'
|
|
67
|
+
},
|
|
68
|
+
responseType: 'json',
|
|
69
|
+
data: {
|
|
70
|
+
name: args.options.name,
|
|
71
|
+
color: args.options.color,
|
|
72
|
+
defaultOnlineMeetingProvider: args.options.defaultOnlineMeetingProvider,
|
|
73
|
+
isDefaultCalendar: args.options.default
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const result = await request.post(requestOptions);
|
|
77
|
+
await logger.log(result);
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
this.handleRejectedODataJsonPromise(err);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export default new OutlookCalendarAddCommand();
|
|
85
|
+
//# sourceMappingURL=calendar-add.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
2
|
+
import commands from '../../commands.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
5
|
+
import { validation } from '../../../../utils/validation.js';
|
|
6
|
+
import { calendarGroup } from '../../../../utils/calendarGroup.js';
|
|
7
|
+
import { calendar } from '../../../../utils/calendar.js';
|
|
8
|
+
export const options = z.strictObject({
|
|
9
|
+
...globalOptionsZod.shape,
|
|
10
|
+
id: z.string().alias('i').optional(),
|
|
11
|
+
name: z.string().alias('n').optional(),
|
|
12
|
+
userId: z.string()
|
|
13
|
+
.refine(userId => validation.isValidGuid(userId), {
|
|
14
|
+
error: e => `'${e.input}' is not a valid GUID.`
|
|
15
|
+
}).optional(),
|
|
16
|
+
userName: z.string()
|
|
17
|
+
.refine(userName => validation.isValidUserPrincipalName(userName), {
|
|
18
|
+
error: e => `'${e.input}' is not a valid UPN.`
|
|
19
|
+
}).optional(),
|
|
20
|
+
calendarGroupId: z.string().optional(),
|
|
21
|
+
calendarGroupName: z.string().optional()
|
|
22
|
+
});
|
|
23
|
+
class OutlookCalendarGetCommand extends GraphCommand {
|
|
24
|
+
get name() {
|
|
25
|
+
return commands.CALENDAR_GET;
|
|
26
|
+
}
|
|
27
|
+
get description() {
|
|
28
|
+
return 'Retrieves the calendar of a user or a group';
|
|
29
|
+
}
|
|
30
|
+
get schema() {
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
33
|
+
getRefinedSchema(schema) {
|
|
34
|
+
return schema
|
|
35
|
+
.refine(options => [options.id, options.name].filter(x => x !== undefined).length === 1, {
|
|
36
|
+
error: 'Specify either id or name, but not both'
|
|
37
|
+
})
|
|
38
|
+
.refine(options => !(options.userId && options.userName), {
|
|
39
|
+
error: 'Specify either userId or userName, but not both'
|
|
40
|
+
})
|
|
41
|
+
.refine(options => !(options.calendarGroupId && options.calendarGroupName), {
|
|
42
|
+
error: 'Specify either calendarGroupId or calendarGroupName, but not both'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async commandAction(logger, args) {
|
|
46
|
+
if (this.verbose) {
|
|
47
|
+
await logger.logToStderr('Getting calendar...');
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const userIdentifier = args.options.userId ?? args.options.userName;
|
|
51
|
+
let calendarGroupId = args.options.calendarGroupId;
|
|
52
|
+
if (args.options.calendarGroupName) {
|
|
53
|
+
const group = await calendarGroup.getUserCalendarGroupByName(userIdentifier, args.options.calendarGroupName, 'id');
|
|
54
|
+
calendarGroupId = group.id;
|
|
55
|
+
}
|
|
56
|
+
let result;
|
|
57
|
+
if (args.options.id) {
|
|
58
|
+
result = await calendar.getUserCalendarById(userIdentifier, args.options.id, calendarGroupId);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
result = await calendar.getUserCalendarByName(userIdentifier, args.options.name, calendarGroupId);
|
|
62
|
+
}
|
|
63
|
+
await logger.log(result);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
this.handleRejectedODataJsonPromise(err);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export default new OutlookCalendarGetCommand();
|
|
71
|
+
//# sourceMappingURL=calendar-get.js.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
2
|
+
import commands from '../../commands.js';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
5
|
+
import { validation } from '../../../../utils/validation.js';
|
|
6
|
+
import { calendarGroup } from '../../../../utils/calendarGroup.js';
|
|
7
|
+
import { calendar } from '../../../../utils/calendar.js';
|
|
8
|
+
import { cli } from '../../../../cli/cli.js';
|
|
9
|
+
import request from '../../../../request.js';
|
|
10
|
+
export const options = z.strictObject({
|
|
11
|
+
...globalOptionsZod.shape,
|
|
12
|
+
id: z.string().alias('i').optional(),
|
|
13
|
+
name: z.string().alias('n').optional(),
|
|
14
|
+
userId: z.string()
|
|
15
|
+
.refine(userId => validation.isValidGuid(userId), {
|
|
16
|
+
error: e => `'${e.input}' is not a valid GUID.`
|
|
17
|
+
}).optional(),
|
|
18
|
+
userName: z.string()
|
|
19
|
+
.refine(userName => validation.isValidUserPrincipalName(userName), {
|
|
20
|
+
error: e => `'${e.input}' is not a valid UPN.`
|
|
21
|
+
}).optional(),
|
|
22
|
+
calendarGroupId: z.string().optional(),
|
|
23
|
+
calendarGroupName: z.string().optional(),
|
|
24
|
+
permanent: z.boolean().optional(),
|
|
25
|
+
force: z.boolean().optional().alias('f')
|
|
26
|
+
});
|
|
27
|
+
class OutlookCalendarRemoveCommand extends GraphCommand {
|
|
28
|
+
get name() {
|
|
29
|
+
return commands.CALENDAR_REMOVE;
|
|
30
|
+
}
|
|
31
|
+
get description() {
|
|
32
|
+
return 'Removes the calendar of a user';
|
|
33
|
+
}
|
|
34
|
+
get schema() {
|
|
35
|
+
return options;
|
|
36
|
+
}
|
|
37
|
+
getRefinedSchema(schema) {
|
|
38
|
+
return schema
|
|
39
|
+
.refine(options => [options.id, options.name].filter(x => x !== undefined).length === 1, {
|
|
40
|
+
error: 'Specify either id or name, but not both'
|
|
41
|
+
})
|
|
42
|
+
.refine(options => [options.userId, options.userName].filter(x => x !== undefined).length === 1, {
|
|
43
|
+
error: 'Specify either userId or userName, but not both'
|
|
44
|
+
})
|
|
45
|
+
.refine(options => [options.calendarGroupId, options.calendarGroupName].filter(x => x !== undefined).length !== 2, {
|
|
46
|
+
error: 'Do not specify both calendarGroupId and calendarGroupName'
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
async commandAction(logger, args) {
|
|
50
|
+
const removeCalendar = async () => {
|
|
51
|
+
try {
|
|
52
|
+
const userIdentifier = args.options.userId ?? args.options.userName;
|
|
53
|
+
let calendarGroupId = args.options.calendarGroupId;
|
|
54
|
+
if (args.options.calendarGroupName) {
|
|
55
|
+
const group = await calendarGroup.getUserCalendarGroupByName(userIdentifier, args.options.calendarGroupName, 'id');
|
|
56
|
+
calendarGroupId = group.id;
|
|
57
|
+
}
|
|
58
|
+
let calendarId = args.options.id;
|
|
59
|
+
if (args.options.name) {
|
|
60
|
+
const result = await calendar.getUserCalendarByName(userIdentifier, args.options.name, calendarGroupId, 'id');
|
|
61
|
+
calendarId = result.id;
|
|
62
|
+
}
|
|
63
|
+
if (args.options.verbose) {
|
|
64
|
+
await logger.logToStderr(`Removing calendar with ID ${calendarId}...`);
|
|
65
|
+
}
|
|
66
|
+
let url = `${this.resource}/v1.0/users('${userIdentifier}')/${calendarGroupId ? `calendarGroups/${calendarGroupId}/` : ''}calendars/${calendarId}`;
|
|
67
|
+
if (args.options.permanent) {
|
|
68
|
+
url += '/permanentDelete';
|
|
69
|
+
}
|
|
70
|
+
const requestOptions = {
|
|
71
|
+
url: url,
|
|
72
|
+
headers: {
|
|
73
|
+
accept: 'application/json;odata.metadata=none'
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
if (args.options.permanent) {
|
|
77
|
+
await request.post(requestOptions);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
await request.delete(requestOptions);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
this.handleRejectedODataJsonPromise(err);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
if (args.options.force) {
|
|
88
|
+
await removeCalendar();
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const calendarIdentifier = args.options.id ?? args.options.name;
|
|
92
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove calendar '${calendarIdentifier}'?` });
|
|
93
|
+
if (result) {
|
|
94
|
+
await removeCalendar();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export default new OutlookCalendarRemoveCommand();
|
|
100
|
+
//# sourceMappingURL=calendar-remove.js.map
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
3
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
4
|
+
import commands from '../../commands.js';
|
|
5
|
+
import { validation } from '../../../../utils/validation.js';
|
|
6
|
+
import request from '../../../../request.js';
|
|
7
|
+
import { accessToken } from '../../../../utils/accessToken.js';
|
|
8
|
+
import auth from '../../../../Auth.js';
|
|
9
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
10
|
+
import { calendarGroup } from '../../../../utils/calendarGroup.js';
|
|
11
|
+
export const options = z.strictObject({
|
|
12
|
+
...globalOptionsZod.shape,
|
|
13
|
+
id: z.string().optional(),
|
|
14
|
+
name: z.string().optional(),
|
|
15
|
+
userId: z.string().refine(id => validation.isValidGuid(id), {
|
|
16
|
+
error: e => `'${e.input}' is not a valid GUID.`
|
|
17
|
+
}).optional(),
|
|
18
|
+
userName: z.string().refine(name => validation.isValidUserPrincipalName(name), {
|
|
19
|
+
error: e => `'${e.input}' is not a valid UPN.`
|
|
20
|
+
}).optional(),
|
|
21
|
+
newName: z.string()
|
|
22
|
+
});
|
|
23
|
+
class OutlookCalendarGroupSetCommand extends GraphCommand {
|
|
24
|
+
get name() {
|
|
25
|
+
return commands.CALENDARGROUP_SET;
|
|
26
|
+
}
|
|
27
|
+
get description() {
|
|
28
|
+
return 'Updates a calendar group for a user';
|
|
29
|
+
}
|
|
30
|
+
get schema() {
|
|
31
|
+
return options;
|
|
32
|
+
}
|
|
33
|
+
getRefinedSchema(schema) {
|
|
34
|
+
return schema
|
|
35
|
+
.refine(options => !(options.userId && options.userName), {
|
|
36
|
+
error: 'Specify either userId or userName, but not both.'
|
|
37
|
+
})
|
|
38
|
+
.refine(options => !(!options.id && !options.name), {
|
|
39
|
+
error: 'Specify either id or name.'
|
|
40
|
+
})
|
|
41
|
+
.refine(options => !(options.id && options.name), {
|
|
42
|
+
error: 'Specify either id or name, but not both.'
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async commandAction(logger, args) {
|
|
46
|
+
try {
|
|
47
|
+
const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
|
|
48
|
+
const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(token);
|
|
49
|
+
let userUrl;
|
|
50
|
+
let graphUserId;
|
|
51
|
+
if (isAppOnlyAccessToken) {
|
|
52
|
+
if (!args.options.userId && !args.options.userName) {
|
|
53
|
+
throw 'When running with application permissions either userId or userName is required.';
|
|
54
|
+
}
|
|
55
|
+
graphUserId = (args.options.userId ?? args.options.userName);
|
|
56
|
+
userUrl = `${this.resource}/v1.0/users('${formatting.encodeQueryParameter(graphUserId)}')`;
|
|
57
|
+
if (this.verbose) {
|
|
58
|
+
await logger.logToStderr(`Updating calendar group using application permissions for user '${graphUserId}'...`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else if (args.options.userId || args.options.userName) {
|
|
62
|
+
const currentUserId = accessToken.getUserIdFromAccessToken(token);
|
|
63
|
+
const currentUserName = accessToken.getUserNameFromAccessToken(token);
|
|
64
|
+
const isOtherUser = (args.options.userId && args.options.userId !== currentUserId) ||
|
|
65
|
+
(args.options.userName && args.options.userName.toLowerCase() !== currentUserName?.toLowerCase());
|
|
66
|
+
if (isOtherUser) {
|
|
67
|
+
const scopes = accessToken.getScopesFromAccessToken(token);
|
|
68
|
+
const hasSharedScope = scopes.some(s => s === 'Calendars.ReadWrite.Shared');
|
|
69
|
+
if (!hasSharedScope) {
|
|
70
|
+
throw `To update calendar groups of other users, the Entra ID application used for authentication must have the Calendars.ReadWrite.Shared delegated permission assigned.`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
graphUserId = (args.options.userId ?? args.options.userName);
|
|
74
|
+
userUrl = `${this.resource}/v1.0/users('${formatting.encodeQueryParameter(graphUserId)}')`;
|
|
75
|
+
if (this.verbose) {
|
|
76
|
+
await logger.logToStderr(`Updating calendar group using delegated permissions for user '${graphUserId}'...`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
graphUserId = accessToken.getUserIdFromAccessToken(token);
|
|
81
|
+
userUrl = `${this.resource}/v1.0/me`;
|
|
82
|
+
if (this.verbose) {
|
|
83
|
+
await logger.logToStderr('Updating calendar group for the signed-in user...');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
let calendarGroupId;
|
|
87
|
+
if (args.options.id) {
|
|
88
|
+
calendarGroupId = args.options.id;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const calendarGroupResult = await calendarGroup.getUserCalendarGroupByName(graphUserId, args.options.name);
|
|
92
|
+
calendarGroupId = calendarGroupResult.id;
|
|
93
|
+
}
|
|
94
|
+
if (this.verbose) {
|
|
95
|
+
await logger.logToStderr(`Updating calendar group '${calendarGroupId}'...`);
|
|
96
|
+
}
|
|
97
|
+
const requestOptions = {
|
|
98
|
+
url: `${userUrl}/calendarGroups/${calendarGroupId}`,
|
|
99
|
+
headers: {
|
|
100
|
+
accept: 'application/json;odata.metadata=none'
|
|
101
|
+
},
|
|
102
|
+
responseType: 'json',
|
|
103
|
+
data: {
|
|
104
|
+
name: args.options.newName
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
await request.patch(requestOptions);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
this.handleRejectedODataJsonPromise(err);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export default new OutlookCalendarGroupSetCommand();
|
|
115
|
+
//# sourceMappingURL=calendargroup-set.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import auth from '../../../../Auth.js';
|
|
2
|
+
import request from '../../../../request.js';
|
|
3
|
+
import { accessToken } from '../../../../utils/accessToken.js';
|
|
4
|
+
import { validation } from '../../../../utils/validation.js';
|
|
5
|
+
import GraphCommand from '../../../base/GraphCommand.js';
|
|
6
|
+
import commands from '../../commands.js';
|
|
7
|
+
import { cli } from '../../../../cli/cli.js';
|
|
8
|
+
import { globalOptionsZod } from '../../../../Command.js';
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
export const options = z.strictObject({
|
|
11
|
+
...globalOptionsZod.shape,
|
|
12
|
+
id: z.string().alias('i'),
|
|
13
|
+
userId: z.string().refine(id => validation.isValidGuid(id), {
|
|
14
|
+
error: e => `'${e.input}' is not a valid GUID.`
|
|
15
|
+
}).optional(),
|
|
16
|
+
userName: z.string()
|
|
17
|
+
.refine(upn => validation.isValidUserPrincipalName(upn) === true, {
|
|
18
|
+
error: e => `'${e.input}' is not a valid user principal name for option 'userName'.`
|
|
19
|
+
})
|
|
20
|
+
.optional(),
|
|
21
|
+
comment: z.string().optional(),
|
|
22
|
+
force: z.boolean().optional().alias('f')
|
|
23
|
+
});
|
|
24
|
+
class OutlookEventCancelCommand extends GraphCommand {
|
|
25
|
+
get name() {
|
|
26
|
+
return commands.EVENT_CANCEL;
|
|
27
|
+
}
|
|
28
|
+
get description() {
|
|
29
|
+
return 'Cancels a calendar event';
|
|
30
|
+
}
|
|
31
|
+
get schema() {
|
|
32
|
+
return options;
|
|
33
|
+
}
|
|
34
|
+
getRefinedSchema(schema) {
|
|
35
|
+
return schema
|
|
36
|
+
.refine(options => !(options.userId && options.userName), {
|
|
37
|
+
error: `Specify either 'userId' or 'userName', but not both.`
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async commandAction(logger, args) {
|
|
41
|
+
const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken);
|
|
42
|
+
let principalUrl = '';
|
|
43
|
+
const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
|
|
44
|
+
if (isAppOnlyAccessToken) {
|
|
45
|
+
if (!args.options.userId && !args.options.userName) {
|
|
46
|
+
throw `The option 'userId' or 'userName' is required when cancelling an event using application permissions.`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
if (args.options.userId) {
|
|
51
|
+
const currentUserId = accessToken.getUserIdFromAccessToken(token);
|
|
52
|
+
if (args.options.userId !== currentUserId) {
|
|
53
|
+
throw `You can only cancel your own events when using delegated permissions. The specified userId '${args.options.userId}' does not match the current user '${currentUserId}'.`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (args.options.userName) {
|
|
57
|
+
const currentUserName = accessToken.getUserNameFromAccessToken(token);
|
|
58
|
+
if (args.options.userName.toLowerCase() !== currentUserName.toLowerCase()) {
|
|
59
|
+
throw `You can only cancel your own events when using delegated permissions. The specified userName '${args.options.userName}' does not match the current user '${currentUserName}'.`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (args.options.userId || args.options.userName) {
|
|
64
|
+
const userIdentifier = args.options.userId ?? args.options.userName;
|
|
65
|
+
principalUrl += `users('${userIdentifier}')`;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
principalUrl += 'me';
|
|
69
|
+
}
|
|
70
|
+
const cancelEvent = async () => {
|
|
71
|
+
try {
|
|
72
|
+
if (this.verbose) {
|
|
73
|
+
await logger.logToStderr(`Cancelling event with id '${args.options.id}'...`);
|
|
74
|
+
}
|
|
75
|
+
const requestOptions = {
|
|
76
|
+
url: `${this.resource}/v1.0/${principalUrl}/events/${args.options.id}/cancel`,
|
|
77
|
+
headers: {
|
|
78
|
+
accept: 'application/json;odata.metadata=none',
|
|
79
|
+
'content-type': 'application/json'
|
|
80
|
+
},
|
|
81
|
+
data: {
|
|
82
|
+
comment: args.options.comment
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
await request.post(requestOptions);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
this.handleRejectedODataJsonPromise(err);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
if (args.options.force) {
|
|
92
|
+
await cancelEvent();
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const result = await cli.promptForConfirmation({ message: `Are you sure you want to cancel event with id '${args.options.id}'?` });
|
|
96
|
+
if (result) {
|
|
97
|
+
await cancelEvent();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
export default new OutlookEventCancelCommand();
|
|
103
|
+
//# sourceMappingURL=event-cancel.js.map
|