@pnp/cli-microsoft365 11.7.0-beta.b67a258 → 11.7.0-beta.ba78c1f

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.
Files changed (112) hide show
  1. package/.devproxy/api-specs/sharepoint.yaml +53 -0
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/config.js +1 -0
  5. package/dist/m365/context/commands/option/option-list.js +6 -1
  6. package/dist/m365/entra/commands/resourcenamespace/resourcenamespace-list.js +6 -0
  7. package/dist/m365/entra/commands/user/user-license-add.js +2 -1
  8. package/dist/m365/entra/commands/user/user-license-list.js +4 -9
  9. package/dist/m365/entra/commands/user/user-license-remove.js +2 -1
  10. package/dist/m365/external/commands/connection/connection-list.js +6 -0
  11. package/dist/m365/outlook/commands/calendar/calendar-add.js +85 -0
  12. package/dist/m365/outlook/commands/calendar/calendar-get.js +71 -0
  13. package/dist/m365/outlook/commands/calendar/calendar-remove.js +100 -0
  14. package/dist/m365/outlook/commands/calendar/calendar-set.js +132 -0
  15. package/dist/m365/outlook/commands/calendargroup/calendargroup-get.js +114 -0
  16. package/dist/m365/outlook/commands/calendargroup/calendargroup-set.js +115 -0
  17. package/dist/m365/outlook/commands/event/event-cancel.js +103 -0
  18. package/dist/m365/outlook/commands/event/event-list.js +115 -0
  19. package/dist/m365/outlook/commands/event/event-remove.js +104 -0
  20. package/dist/m365/outlook/commands.js +9 -0
  21. package/dist/m365/spfx/commands/SpfxCompatibilityMatrix.js +643 -0
  22. package/dist/m365/spfx/commands/project/DeployWorkflow.js +2 -2
  23. package/dist/m365/spfx/commands/project/project-azuredevops-pipeline-add.js +13 -1
  24. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.23.0-rc.0.js +19 -0
  25. package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
  26. package/dist/m365/spfx/commands/project/project-github-workflow-add.js +16 -1
  27. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002021_DEVDEP_rushstack_eslint_config.js +2 -2
  28. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002032_DEVDEP_typescript_eslint_parser.js +2 -2
  29. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015008_FILE_eslintrc_js.js +1 -1
  30. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015016_FILE_eslint_config_js.js +10 -0
  31. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.23.0-rc.0.js +84 -0
  32. package/dist/m365/spfx/commands/project/project-upgrade.js +12 -11
  33. package/dist/m365/spfx/commands/spfx-doctor.js +5 -631
  34. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-add.js +13 -1
  35. package/dist/m365/spo/commands/applicationcustomizer/applicationcustomizer-set.js +24 -3
  36. package/dist/m365/spo/commands/brandcenter/brandcenter-colors-list.js +59 -0
  37. package/dist/m365/spo/commands/file/file-archive.js +83 -0
  38. package/dist/m365/spo/commands/propertybag/propertybag-set.js +3 -9
  39. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-add.js +20 -0
  40. package/dist/m365/spo/commands/tenant/tenant-applicationcustomizer-set.js +27 -2
  41. package/dist/m365/spo/commands/tenant/tenant-settings-set.js +5 -1
  42. package/dist/m365/spo/commands.js +2 -0
  43. package/dist/m365/teams/commands/chat/chat-message-list.js +43 -4
  44. package/dist/request.js +0 -16
  45. package/dist/utils/calendar.js +37 -0
  46. package/dist/utils/calendarGroup.js +22 -0
  47. package/dist/utils/entraApp.js +9 -2
  48. package/dist/utils/spfx.js +59 -0
  49. package/docs/docs/cmd/entra/license/license-list.mdx +19 -0
  50. package/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx +19 -0
  51. package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +19 -0
  52. package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +21 -0
  53. package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +19 -0
  54. package/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx +21 -0
  55. package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +21 -0
  56. package/docs/docs/cmd/entra/roledefinition/roledefinition-add.mdx +19 -0
  57. package/docs/docs/cmd/entra/roledefinition/roledefinition-get.mdx +19 -0
  58. package/docs/docs/cmd/entra/roledefinition/roledefinition-list.mdx +19 -0
  59. package/docs/docs/cmd/entra/roledefinition/roledefinition-remove.mdx +21 -0
  60. package/docs/docs/cmd/entra/roledefinition/roledefinition-set.mdx +21 -0
  61. package/docs/docs/cmd/entra/siteclassification/siteclassification-disable.mdx +21 -0
  62. package/docs/docs/cmd/entra/siteclassification/siteclassification-enable.mdx +21 -0
  63. package/docs/docs/cmd/entra/siteclassification/siteclassification-get.mdx +19 -0
  64. package/docs/docs/cmd/entra/siteclassification/siteclassification-set.mdx +20 -0
  65. package/docs/docs/cmd/entra/user/user-groupmembership-list.mdx +19 -0
  66. package/docs/docs/cmd/entra/user/user-guest-add.mdx +19 -0
  67. package/docs/docs/cmd/entra/user/user-license-add.mdx +19 -0
  68. package/docs/docs/cmd/entra/user/user-license-list.mdx +18 -1
  69. package/docs/docs/cmd/entra/user/user-license-remove.mdx +21 -0
  70. package/docs/docs/cmd/entra/user/user-password-validate.mdx +12 -0
  71. package/docs/docs/cmd/entra/user/user-recyclebinitem-clear.mdx +21 -0
  72. package/docs/docs/cmd/entra/user/user-recyclebinitem-list.mdx +19 -0
  73. package/docs/docs/cmd/entra/user/user-recyclebinitem-remove.mdx +21 -0
  74. package/docs/docs/cmd/entra/user/user-recyclebinitem-restore.mdx +19 -0
  75. package/docs/docs/cmd/entra/user/user-registrationdetails-list.mdx +19 -0
  76. package/docs/docs/cmd/entra/user/user-session-revoke.mdx +21 -0
  77. package/docs/docs/cmd/entra/user/user-signin-list.mdx +19 -0
  78. package/docs/docs/cmd/exo/approleassignment/approleassignment-add.mdx +19 -0
  79. package/docs/docs/cmd/external/connection/connection-add.mdx +21 -0
  80. package/docs/docs/cmd/external/connection/connection-doctor.mdx +19 -0
  81. package/docs/docs/cmd/external/connection/connection-get.mdx +19 -0
  82. package/docs/docs/cmd/external/connection/connection-list.mdx +19 -0
  83. package/docs/docs/cmd/external/connection/connection-remove.mdx +21 -0
  84. package/docs/docs/cmd/external/connection/connection-schema-add.mdx +21 -0
  85. package/docs/docs/cmd/external/connection/connection-urltoitemresolver-add.mdx +21 -0
  86. package/docs/docs/cmd/external/item/item-add.mdx +19 -0
  87. package/docs/docs/cmd/file/convert/convert-pdf.mdx +21 -0
  88. package/docs/docs/cmd/file/file-add.mdx +21 -0
  89. package/docs/docs/cmd/file/file-copy.mdx +21 -0
  90. package/docs/docs/cmd/file/file-list.mdx +19 -0
  91. package/docs/docs/cmd/file/file-move.mdx +21 -0
  92. package/docs/docs/cmd/outlook/calendar/calendar-add.mdx +165 -0
  93. package/docs/docs/cmd/outlook/calendar/calendar-get.mdx +165 -0
  94. package/docs/docs/cmd/outlook/calendar/calendar-remove.mdx +86 -0
  95. package/docs/docs/cmd/outlook/calendar/calendar-set.mdx +178 -0
  96. package/docs/docs/cmd/outlook/calendargroup/calendargroup-get.mdx +125 -0
  97. package/docs/docs/cmd/outlook/calendargroup/calendargroup-set.mdx +83 -0
  98. package/docs/docs/cmd/outlook/event/event-cancel.mdx +85 -0
  99. package/docs/docs/cmd/outlook/event/event-list.mdx +245 -0
  100. package/docs/docs/cmd/outlook/event/event-remove.mdx +85 -0
  101. package/docs/docs/cmd/spfx/project/project-upgrade.mdx +1 -1
  102. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-add.mdx +14 -11
  103. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-set.mdx +9 -6
  104. package/docs/docs/cmd/spo/brandcenter/brandcenter-colors-list.mdx +115 -0
  105. package/docs/docs/cmd/spo/file/file-archive.mdx +68 -0
  106. package/docs/docs/cmd/spo/propertybag/propertybag-set.mdx +1 -1
  107. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-add.mdx +13 -10
  108. package/docs/docs/cmd/spo/tenant/tenant-applicationcustomizer-set.mdx +7 -4
  109. package/docs/docs/cmd/spo/tenant/tenant-settings-set.mdx +3 -0
  110. package/docs/docs/cmd/teams/chat/chat-message-list.mdx +23 -2
  111. package/npm-shrinkwrap.json +0 -7
  112. package/package.json +2 -1
@@ -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
@@ -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
@@ -0,0 +1,104 @@
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
+ permanent: z.boolean().optional(),
22
+ force: z.boolean().optional().alias('f')
23
+ });
24
+ class OutlookEventRemoveCommand extends GraphCommand {
25
+ get name() {
26
+ return commands.EVENT_REMOVE;
27
+ }
28
+ get description() {
29
+ return 'Removes an event from a calendar';
30
+ }
31
+ get schema() {
32
+ return options;
33
+ }
34
+ getRefinedSchema(schema) {
35
+ return schema.refine(options => !options.userId || !options.userName, {
36
+ error: 'Specify either userId or userName, but not both.'
37
+ });
38
+ }
39
+ async commandAction(logger, args) {
40
+ const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(auth.connection.accessTokens[auth.defaultResource].accessToken);
41
+ const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
42
+ if (isAppOnlyAccessToken) {
43
+ if (!args.options.userId && !args.options.userName) {
44
+ throw `The option 'userId' or 'userName' is required when removing an event using application permissions.`;
45
+ }
46
+ }
47
+ else {
48
+ if (args.options.userId) {
49
+ const currentUserId = accessToken.getUserIdFromAccessToken(token);
50
+ if (args.options.userId !== currentUserId) {
51
+ throw `You can only remove your own events when using delegated permissions. The specified userId '${args.options.userId}' does not match the current user '${currentUserId}'.`;
52
+ }
53
+ }
54
+ if (args.options.userName) {
55
+ const currentUserName = accessToken.getUserNameFromAccessToken(token);
56
+ if (args.options.userName.toLowerCase() !== currentUserName.toLowerCase()) {
57
+ throw `You can only remove your own events when using delegated permissions. The specified userName '${args.options.userName}' does not match the current user '${currentUserName}'.`;
58
+ }
59
+ }
60
+ }
61
+ let principalUrl = '';
62
+ const userIdentifier = args.options.userId ?? args.options.userName;
63
+ if (userIdentifier) {
64
+ principalUrl += `users('${userIdentifier}')`;
65
+ }
66
+ else {
67
+ principalUrl += 'me';
68
+ }
69
+ const removeEvent = async () => {
70
+ try {
71
+ if (this.verbose) {
72
+ await logger.logToStderr(`Removing event with id '${args.options.id}'...`);
73
+ }
74
+ const requestOptions = {
75
+ url: `${this.resource}/v1.0/${principalUrl}/events/${args.options.id}`,
76
+ headers: {
77
+ accept: 'application/json;odata.metadata=none'
78
+ }
79
+ };
80
+ if (args.options.permanent) {
81
+ requestOptions.url += '/permanentDelete';
82
+ await request.post(requestOptions);
83
+ }
84
+ else {
85
+ await request.delete(requestOptions);
86
+ }
87
+ }
88
+ catch (err) {
89
+ this.handleRejectedODataJsonPromise(err);
90
+ }
91
+ };
92
+ if (args.options.force) {
93
+ await removeEvent();
94
+ }
95
+ else {
96
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove event with id '${args.options.id}'?` });
97
+ if (result) {
98
+ await removeEvent();
99
+ }
100
+ }
101
+ }
102
+ }
103
+ export default new OutlookEventRemoveCommand();
104
+ //# sourceMappingURL=event-remove.js.map
@@ -1,6 +1,15 @@
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`,
6
+ CALENDAR_SET: `${prefix} calendar set`,
7
+ CALENDARGROUP_GET: `${prefix} calendargroup get`,
3
8
  CALENDARGROUP_LIST: `${prefix} calendargroup list`,
9
+ CALENDARGROUP_SET: `${prefix} calendargroup set`,
10
+ EVENT_CANCEL: `${prefix} event cancel`,
11
+ EVENT_LIST: `${prefix} event list`,
12
+ EVENT_REMOVE: `${prefix} event remove`,
4
13
  MAIL_SEARCHFOLDER_ADD: `${prefix} mail searchfolder add`,
5
14
  MAIL_SEND: `${prefix} mail send`,
6
15
  MAILBOX_SETTINGS_GET: `${prefix} mailbox settings get`,