@pnp/cli-microsoft365 11.7.0-beta.537911c → 11.7.0-beta.71e4ac5
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/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/event/event-list.js +115 -0
- package/dist/m365/outlook/commands.js +4 -0
- package/dist/utils/calendar.js +37 -0
- package/dist/utils/calendarGroup.js +22 -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/event/event-list.mdx +245 -0
- package/npm-shrinkwrap.json +320 -304
- package/package.json +32 -20
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',
|
|
@@ -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 { odata } from '../../../../utils/odata.js';
|
|
7
|
+
import { calendar } from '../../../../utils/calendar.js';
|
|
8
|
+
export const options = z.strictObject({
|
|
9
|
+
...globalOptionsZod.shape,
|
|
10
|
+
userId: z.string().refine(id => validation.isValidGuid(id), {
|
|
11
|
+
error: e => `'${e.input}' is not a valid GUID.`
|
|
12
|
+
}).optional(),
|
|
13
|
+
userName: z.string().refine(name => validation.isValidUserPrincipalName(name), {
|
|
14
|
+
error: e => `'${e.input}' is not a valid UPN.`
|
|
15
|
+
}).optional(),
|
|
16
|
+
calendarId: z.string().optional(),
|
|
17
|
+
calendarName: z.string().optional(),
|
|
18
|
+
startDateTime: z.string().refine(date => validation.isValidISODateTime(date), {
|
|
19
|
+
error: e => `'${e.input}' is not a valid ISO date-time.`
|
|
20
|
+
}).optional(),
|
|
21
|
+
endDateTime: z.string().refine(date => validation.isValidISODateTime(date), {
|
|
22
|
+
error: e => `'${e.input}' is not a valid ISO date-time.`
|
|
23
|
+
}).optional(),
|
|
24
|
+
timeZone: z.string().optional(),
|
|
25
|
+
properties: z.string().optional(),
|
|
26
|
+
filter: z.string().optional()
|
|
27
|
+
});
|
|
28
|
+
class OutlookEventListCommand extends GraphCommand {
|
|
29
|
+
get name() {
|
|
30
|
+
return commands.EVENT_LIST;
|
|
31
|
+
}
|
|
32
|
+
get description() {
|
|
33
|
+
return 'Retrieves a list of events from a specific calendar of a user.';
|
|
34
|
+
}
|
|
35
|
+
get schema() {
|
|
36
|
+
return options;
|
|
37
|
+
}
|
|
38
|
+
getRefinedSchema(schema) {
|
|
39
|
+
return schema
|
|
40
|
+
.refine(options => [options.userId, options.userName].filter(x => x !== undefined).length === 1, {
|
|
41
|
+
error: 'Specify either userId or userName, but not both'
|
|
42
|
+
})
|
|
43
|
+
.refine(options => !(options.calendarId && options.calendarName), {
|
|
44
|
+
error: 'Specify either calendarId or calendarName, but not both.'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
defaultProperties() {
|
|
48
|
+
return ['id', 'subject'];
|
|
49
|
+
}
|
|
50
|
+
async commandAction(logger, args) {
|
|
51
|
+
try {
|
|
52
|
+
if (this.verbose) {
|
|
53
|
+
await logger.logToStderr('Getting a list of the events...');
|
|
54
|
+
}
|
|
55
|
+
let events;
|
|
56
|
+
const endpoint = await this.getRequestUrl(args.options);
|
|
57
|
+
if (args.options.timeZone) {
|
|
58
|
+
const requestOptions = {
|
|
59
|
+
url: endpoint,
|
|
60
|
+
headers: {
|
|
61
|
+
accept: 'application/json;odata.metadata=none',
|
|
62
|
+
Prefer: `outlook.timezone="${args.options.timeZone}"`
|
|
63
|
+
},
|
|
64
|
+
responseType: 'json'
|
|
65
|
+
};
|
|
66
|
+
events = await odata.getAllItems(requestOptions);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
events = await odata.getAllItems(endpoint);
|
|
70
|
+
}
|
|
71
|
+
await logger.log(events);
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
this.handleRejectedODataJsonPromise(err);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async getRequestUrl(options) {
|
|
78
|
+
const queryParameters = [];
|
|
79
|
+
if (options.properties) {
|
|
80
|
+
const allProperties = options.properties.split(',');
|
|
81
|
+
const selectProperties = allProperties.filter(prop => !prop.includes('/'));
|
|
82
|
+
const expandProperties = allProperties.filter(prop => prop.includes('/'));
|
|
83
|
+
if (selectProperties.length > 0) {
|
|
84
|
+
queryParameters.push(`$select=${selectProperties}`);
|
|
85
|
+
}
|
|
86
|
+
if (expandProperties.length > 0) {
|
|
87
|
+
const fieldExpands = expandProperties.map(p => `${p.split('/')[0]}($select=${p.split('/')[1]})`);
|
|
88
|
+
queryParameters.push(`$expand=${fieldExpands.join(',')}`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (options.filter || options.startDateTime || options.endDateTime) {
|
|
92
|
+
let filter = options.filter || '';
|
|
93
|
+
if (options.startDateTime) {
|
|
94
|
+
filter += `${filter ? ' and ' : ''}start/dateTime ge '${options.startDateTime}'`;
|
|
95
|
+
}
|
|
96
|
+
if (options.endDateTime) {
|
|
97
|
+
filter += `${filter ? ' and ' : ''}start/dateTime lt '${options.endDateTime}'`;
|
|
98
|
+
}
|
|
99
|
+
queryParameters.push(`$filter=${filter}`);
|
|
100
|
+
}
|
|
101
|
+
const queryString = queryParameters.length > 0
|
|
102
|
+
? `?${queryParameters.join('&')}`
|
|
103
|
+
: '';
|
|
104
|
+
const userIdentifier = options.userId ?? options.userName;
|
|
105
|
+
let calendarId = options.calendarId;
|
|
106
|
+
if (options.calendarName) {
|
|
107
|
+
calendarId = (await calendar.getUserCalendarByName(userIdentifier, options.calendarName)).id;
|
|
108
|
+
}
|
|
109
|
+
return calendarId
|
|
110
|
+
? `${this.resource}/v1.0/users('${userIdentifier}')/calendars/${calendarId}/events${queryString}`
|
|
111
|
+
: `${this.resource}/v1.0/users('${userIdentifier}')/events${queryString}`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
export default new OutlookEventListCommand();
|
|
115
|
+
//# sourceMappingURL=event-list.js.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
const prefix = 'outlook';
|
|
2
2
|
export default {
|
|
3
|
+
CALENDAR_ADD: `${prefix} calendar add`,
|
|
4
|
+
CALENDAR_GET: `${prefix} calendar get`,
|
|
5
|
+
CALENDAR_REMOVE: `${prefix} calendar remove`,
|
|
3
6
|
CALENDARGROUP_LIST: `${prefix} calendargroup list`,
|
|
7
|
+
EVENT_LIST: `${prefix} event list`,
|
|
4
8
|
MAIL_SEARCHFOLDER_ADD: `${prefix} mail searchfolder add`,
|
|
5
9
|
MAIL_SEND: `${prefix} mail send`,
|
|
6
10
|
MAILBOX_SETTINGS_GET: `${prefix} mailbox settings get`,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { odata } from './odata.js';
|
|
2
|
+
import { formatting } from './formatting.js';
|
|
3
|
+
import { cli } from '../cli/cli.js';
|
|
4
|
+
import request from '../request.js';
|
|
5
|
+
export const calendar = {
|
|
6
|
+
async getUserCalendarById(userId, calendarId, calendarGroupId, properties) {
|
|
7
|
+
let url = `https://graph.microsoft.com/v1.0/users('${userId}')/${calendarGroupId ? `calendarGroups/${calendarGroupId}/` : ''}calendars/${calendarId}`;
|
|
8
|
+
if (properties) {
|
|
9
|
+
url += `?$select=${properties}`;
|
|
10
|
+
}
|
|
11
|
+
const requestOptions = {
|
|
12
|
+
url: url,
|
|
13
|
+
headers: {
|
|
14
|
+
accept: 'application/json;odata.metadata=none'
|
|
15
|
+
},
|
|
16
|
+
responseType: 'json'
|
|
17
|
+
};
|
|
18
|
+
return await request.get(requestOptions);
|
|
19
|
+
},
|
|
20
|
+
async getUserCalendarByName(userId, name, calendarGroupId, properties) {
|
|
21
|
+
let url = `https://graph.microsoft.com/v1.0/users('${userId}')/${calendarGroupId ? `calendarGroups/${calendarGroupId}/` : ''}calendars?$filter=name eq '${formatting.encodeQueryParameter(name)}'`;
|
|
22
|
+
if (properties) {
|
|
23
|
+
url += `&$select=${properties}`;
|
|
24
|
+
}
|
|
25
|
+
const calendars = await odata.getAllItems(url);
|
|
26
|
+
if (calendars.length === 0) {
|
|
27
|
+
throw new Error(`The specified calendar '${name}' does not exist.`);
|
|
28
|
+
}
|
|
29
|
+
if (calendars.length > 1) {
|
|
30
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', calendars);
|
|
31
|
+
const selectedCalendar = await cli.handleMultipleResultsFound(`Multiple calendars with name '${name}' found.`, resultAsKeyValuePair);
|
|
32
|
+
return selectedCalendar;
|
|
33
|
+
}
|
|
34
|
+
return calendars[0];
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=calendar.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { odata } from './odata.js';
|
|
2
|
+
import { formatting } from './formatting.js';
|
|
3
|
+
import { cli } from '../cli/cli.js';
|
|
4
|
+
export const calendarGroup = {
|
|
5
|
+
async getUserCalendarGroupByName(userId, displayName, properties) {
|
|
6
|
+
let url = `https://graph.microsoft.com/v1.0/users('${userId}')/calendarGroups?$filter=name eq '${formatting.encodeQueryParameter(displayName)}'`;
|
|
7
|
+
if (properties) {
|
|
8
|
+
url += `&$select=${properties}`;
|
|
9
|
+
}
|
|
10
|
+
const calendarGroups = await odata.getAllItems(url);
|
|
11
|
+
if (calendarGroups.length === 0) {
|
|
12
|
+
throw new Error(`The specified calendar group '${displayName}' does not exist.`);
|
|
13
|
+
}
|
|
14
|
+
if (calendarGroups.length > 1) {
|
|
15
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', calendarGroups);
|
|
16
|
+
const selectedCalendarGroup = await cli.handleMultipleResultsFound(`Multiple calendar groups with name '${displayName}' found.`, resultAsKeyValuePair);
|
|
17
|
+
return selectedCalendarGroup;
|
|
18
|
+
}
|
|
19
|
+
return calendarGroups[0];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=calendarGroup.js.map
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import Global from '../../_global.mdx';
|
|
2
|
+
import Tabs from '@theme/Tabs';
|
|
3
|
+
import TabItem from '@theme/TabItem';
|
|
4
|
+
|
|
5
|
+
# outlook calendar add
|
|
6
|
+
|
|
7
|
+
Creates a new calendar for a user
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
m365 outlook calendar add [options]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Options
|
|
16
|
+
|
|
17
|
+
```md definition-list
|
|
18
|
+
`--userId [userId]`
|
|
19
|
+
: ID of the user. Specify either `userId` or `userName`, but not both.
|
|
20
|
+
|
|
21
|
+
`--userName [userName]`
|
|
22
|
+
: UPN of the user. Specify either `userId` or `userName`, but not both.
|
|
23
|
+
|
|
24
|
+
`--name <name>`
|
|
25
|
+
: Name of the calendar.
|
|
26
|
+
|
|
27
|
+
`--calendarGroupId [calendarGroupId]`
|
|
28
|
+
: Id of the group where the calendar will belong. Specify either `calendarGroupId` or `calendarGroupName`, but not both.
|
|
29
|
+
|
|
30
|
+
`--calendarGroupName [calendarGroupName]`
|
|
31
|
+
: Name of the group where the calendar will belong. Specify either `calendarGroupId` or `calendarGroupName`, but not both.
|
|
32
|
+
|
|
33
|
+
`--color [color]`
|
|
34
|
+
: The color of the calendar in UI. Allowed values are `auto`, `lightBlue`, `lightGreen`, `lightOrange`, `lightGray`, `lightYellow`, `lightTeal`, `lightPink`, `lightBrown`, `lightRed`, `maxColor`. Defaults to `auto`.
|
|
35
|
+
|
|
36
|
+
`--defaultOnlineMeetingProvider [defaultOnlineMeetingProvider]`
|
|
37
|
+
: The default online meeting provider for meetings sent from the calendar. Allowed values are `none`, `teamsForBusiness`. Defaults to `teamsForBusiness`.
|
|
38
|
+
|
|
39
|
+
`--default`
|
|
40
|
+
: Specify whether the calendar will be the default calendar for new events.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<Global />
|
|
44
|
+
|
|
45
|
+
## Permissions
|
|
46
|
+
|
|
47
|
+
<Tabs>
|
|
48
|
+
<TabItem value="Delegated">
|
|
49
|
+
|
|
50
|
+
| Resource | Permissions |
|
|
51
|
+
|-----------------|---------------------|
|
|
52
|
+
| Microsoft Graph | Calendars.ReadWrite |
|
|
53
|
+
|
|
54
|
+
</TabItem>
|
|
55
|
+
<TabItem value="Application">
|
|
56
|
+
|
|
57
|
+
| Resource | Permissions |
|
|
58
|
+
|-----------------|---------------------|
|
|
59
|
+
| Microsoft Graph | Calendars.ReadWrite |
|
|
60
|
+
|
|
61
|
+
</TabItem>
|
|
62
|
+
</Tabs>
|
|
63
|
+
|
|
64
|
+
## Examples
|
|
65
|
+
|
|
66
|
+
Create a new calendar for a user in a default calendar's group
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
m365 outlook calendar add --userId '@meId' --name 'Holidays'
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Create a new calendar for a user specified by email in a specific calendar group and defined color
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
m365 outlook calendar add --userName 'john.doe@contoso.com' --name 'Interviews' --calendarGroupId 'AAMkADY1YmE3N2FhLWEwMz' --color 'lightBlue'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Response
|
|
79
|
+
|
|
80
|
+
<Tabs>
|
|
81
|
+
<TabItem value="JSON">
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"id": "AQMkAGRlMCQAAAA==",
|
|
86
|
+
"name": "My Calendars",
|
|
87
|
+
"color": "auto",
|
|
88
|
+
"hexColor": "",
|
|
89
|
+
"groupClassId": "0006f0b7-0000-0000-c000-000000000046",
|
|
90
|
+
"isDefaultCalendar": false,
|
|
91
|
+
"changeKey": "fJKVL07sbkmIfHqjbDnRgQACxSYYpw==",
|
|
92
|
+
"canShare": true,
|
|
93
|
+
"canViewPrivateItems": true,
|
|
94
|
+
"canEdit": true,
|
|
95
|
+
"allowedOnlineMeetingProviders": [
|
|
96
|
+
"teamsForBusiness"
|
|
97
|
+
],
|
|
98
|
+
"defaultOnlineMeetingProvider": "teamsForBusiness",
|
|
99
|
+
"isTallyingResponses": false,
|
|
100
|
+
"isRemovable": true,
|
|
101
|
+
"owner": {
|
|
102
|
+
"name": "John Doe",
|
|
103
|
+
"address": "john.doe@contoso.com"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
</TabItem>
|
|
109
|
+
<TabItem value="Text">
|
|
110
|
+
|
|
111
|
+
```text
|
|
112
|
+
allowedOnlineMeetingProviders: ["teamsForBusiness"]
|
|
113
|
+
canEdit : true
|
|
114
|
+
canShare : true
|
|
115
|
+
canViewPrivateItems : true
|
|
116
|
+
changeKey : fJKVL07sbkmIfHqjbDnRgQACxSYYug==
|
|
117
|
+
color : auto
|
|
118
|
+
defaultOnlineMeetingProvider : teamsForBusiness
|
|
119
|
+
groupClassId : 0006f0b7-0000-0000-c000-000000000046
|
|
120
|
+
hexColor :
|
|
121
|
+
id : AQMkAGRlMCQAAAA==
|
|
122
|
+
isDefaultCalendar : false
|
|
123
|
+
isRemovable : true
|
|
124
|
+
isTallyingResponses : false
|
|
125
|
+
name : My Calendars
|
|
126
|
+
owner : {"name":"John Doe","address":"john.doe@contoso.com"}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
</TabItem>
|
|
130
|
+
<TabItem value="CSV">
|
|
131
|
+
|
|
132
|
+
```csv
|
|
133
|
+
id,name,color,hexColor,groupClassId,isDefaultCalendar,changeKey,canShare,canViewPrivateItems,canEdit,defaultOnlineMeetingProvider,isTallyingResponses,isRemovable
|
|
134
|
+
AQMkAGRlMCQAAAA==,My Calendars,auto,,0006f0b7-0000-0000-c000-000000000046,0,fJKVL07sbkmIfHqjbDnRgQACxSYYzQ==,1,1,1,teamsForBusiness,0,1
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
</TabItem>
|
|
138
|
+
<TabItem value="Markdown">
|
|
139
|
+
|
|
140
|
+
```md
|
|
141
|
+
# outlook calendar add --userId "893f9116-e024-4bc6-8e98-54c245129485" --name "My Calendars"
|
|
142
|
+
|
|
143
|
+
Date: 2/5/2026
|
|
144
|
+
|
|
145
|
+
## My Calendars (AQMkAGRlMCQAAAA==)
|
|
146
|
+
|
|
147
|
+
Property | Value
|
|
148
|
+
---------|-------
|
|
149
|
+
id | AQMkAGRlMCQAAAA==
|
|
150
|
+
name | My Calendars
|
|
151
|
+
color | auto
|
|
152
|
+
hexColor |
|
|
153
|
+
groupClassId | 0006f0b7-0000-0000-c000-000000000046
|
|
154
|
+
isDefaultCalendar | false
|
|
155
|
+
changeKey | fJKVL07sbkmIfHqjbDnRgQACxSYY4A==
|
|
156
|
+
canShare | true
|
|
157
|
+
canViewPrivateItems | true
|
|
158
|
+
canEdit | true
|
|
159
|
+
defaultOnlineMeetingProvider | teamsForBusiness
|
|
160
|
+
isTallyingResponses | false
|
|
161
|
+
isRemovable | true
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
</TabItem>
|
|
165
|
+
</Tabs>
|