@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
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',
@@ -1,7 +1,9 @@
1
1
  import fs from 'fs';
2
- import { CommandError } from '../../../../Command.js';
2
+ import { z } from 'zod';
3
+ import { CommandError, globalOptionsZod } from '../../../../Command.js';
3
4
  import ContextCommand from '../../../base/ContextCommand.js';
4
5
  import commands from '../../commands.js';
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
5
7
  class ContextOptionListCommand extends ContextCommand {
6
8
  get name() {
7
9
  return commands.OPTION_LIST;
@@ -9,6 +11,9 @@ class ContextOptionListCommand extends ContextCommand {
9
11
  get description() {
10
12
  return 'List all options added to the context';
11
13
  }
14
+ get schema() {
15
+ return options;
16
+ }
12
17
  async commandAction(logger) {
13
18
  if (this.verbose) {
14
19
  await logger.logToStderr(`Retrieving context options...`);
@@ -1,6 +1,9 @@
1
1
  import { odata } from '../../../../utils/odata.js';
2
2
  import GraphCommand from '../../../base/GraphCommand.js';
3
3
  import commands from '../../commands.js';
4
+ import { z } from 'zod';
5
+ import { globalOptionsZod } from '../../../../Command.js';
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
4
7
  class EntraResourcenamespaceListCommand extends GraphCommand {
5
8
  get name() {
6
9
  return commands.RESOURCENAMESPACE_LIST;
@@ -8,6 +11,9 @@ class EntraResourcenamespaceListCommand extends GraphCommand {
8
11
  get description() {
9
12
  return 'Get a list of the RBAC resource namespaces and their properties';
10
13
  }
14
+ get schema() {
15
+ return options;
16
+ }
11
17
  defaultProperties() {
12
18
  return ['id', 'name'];
13
19
  }
@@ -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 auth from '../../../../Auth.js';
13
- class EntraUserLicenseListCommand extends GraphCommand {
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
  },
@@ -1,6 +1,9 @@
1
1
  import { odata } from '../../../../utils/odata.js';
2
2
  import GraphCommand from '../../../base/GraphCommand.js';
3
3
  import commands from '../../commands.js';
4
+ import { z } from 'zod';
5
+ import { globalOptionsZod } from '../../../../Command.js';
6
+ export const options = z.strictObject({ ...globalOptionsZod.shape });
4
7
  class ExternalConnectionListCommand extends GraphCommand {
5
8
  get name() {
6
9
  return commands.CONNECTION_LIST;
@@ -11,6 +14,9 @@ class ExternalConnectionListCommand extends GraphCommand {
11
14
  alias() {
12
15
  return [commands.EXTERNALCONNECTION_LIST];
13
16
  }
17
+ get schema() {
18
+ return options;
19
+ }
14
20
  defaultProperties() {
15
21
  return ['id', 'name', 'state'];
16
22
  }
@@ -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,132 @@
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 { calendarGroup } from '../../../../utils/calendarGroup.js';
10
+ const calendarColors = ['auto', 'lightBlue', 'lightGreen', 'lightOrange', 'lightGray', 'lightYellow', 'lightTeal', 'lightPink', 'lightBrown', 'lightRed', 'maxColor'];
11
+ export const options = z.strictObject({
12
+ ...globalOptionsZod.shape,
13
+ id: z.string().alias('i'),
14
+ name: z.string().optional().alias('n'),
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
+ calendarGroupId: z.string().optional(),
22
+ calendarGroupName: z.string().optional(),
23
+ color: z.enum(calendarColors).optional(),
24
+ isDefault: z.boolean().optional()
25
+ });
26
+ class OutlookCalendarSetCommand extends GraphCommand {
27
+ get name() {
28
+ return commands.CALENDAR_SET;
29
+ }
30
+ get description() {
31
+ return 'Updates a calendar for a user';
32
+ }
33
+ get schema() {
34
+ return options;
35
+ }
36
+ getRefinedSchema(schema) {
37
+ return schema
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
+ .refine(options => [options.name, options.color, options.isDefault].filter(o => o !== undefined).length > 0, {
45
+ error: 'Specify at least one of the following options: name, color, or isDefault.'
46
+ });
47
+ }
48
+ async commandAction(logger, args) {
49
+ try {
50
+ const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
51
+ const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(token);
52
+ let requestUrl;
53
+ if (isAppOnlyAccessToken) {
54
+ if (!args.options.userId && !args.options.userName) {
55
+ throw 'When running with application permissions either userId or userName is required.';
56
+ }
57
+ const userIdentifier = args.options.userId ?? args.options.userName;
58
+ requestUrl = this.buildRequestUrl(userIdentifier);
59
+ }
60
+ else {
61
+ 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 calendars of other users, the Entra ID application used for authentication must have the Calendars.ReadWrite.Shared delegated permission assigned.';
71
+ }
72
+ }
73
+ const userIdentifier = args.options.userId ?? args.options.userName;
74
+ requestUrl = this.buildRequestUrl(userIdentifier);
75
+ }
76
+ else {
77
+ requestUrl = this.buildRequestUrl(undefined);
78
+ }
79
+ }
80
+ if (this.verbose) {
81
+ await logger.logToStderr(`Updating calendar '${args.options.id}'...`);
82
+ }
83
+ let calendarGroupId = args.options.calendarGroupId;
84
+ if (args.options.calendarGroupName) {
85
+ const userIdForGroup = args.options.userId ?? args.options.userName ?? accessToken.getUserIdFromAccessToken(token);
86
+ const calendarGroupResult = await calendarGroup.getUserCalendarGroupByName(userIdForGroup, args.options.calendarGroupName, 'id');
87
+ calendarGroupId = calendarGroupResult.id;
88
+ }
89
+ const url = this.buildCalendarUrl(requestUrl, args.options.id, calendarGroupId);
90
+ const requestOptions = {
91
+ url,
92
+ headers: {
93
+ accept: 'application/json;odata.metadata=none'
94
+ },
95
+ responseType: 'json',
96
+ data: this.createRequestBody(args)
97
+ };
98
+ const result = await request.patch(requestOptions);
99
+ await logger.log(result);
100
+ }
101
+ catch (err) {
102
+ this.handleRejectedODataJsonPromise(err);
103
+ }
104
+ }
105
+ buildRequestUrl(userIdentifier) {
106
+ if (userIdentifier) {
107
+ return `${this.resource}/v1.0/users('${userIdentifier}')`;
108
+ }
109
+ return `${this.resource}/v1.0/me`;
110
+ }
111
+ buildCalendarUrl(baseUrl, calendarId, calendarGroupId) {
112
+ if (calendarGroupId) {
113
+ return `${baseUrl}/calendarGroups/${calendarGroupId}/calendars/${calendarId}`;
114
+ }
115
+ return `${baseUrl}/calendars/${calendarId}`;
116
+ }
117
+ createRequestBody(args) {
118
+ const data = {};
119
+ if (args.options.name !== undefined) {
120
+ data.name = args.options.name;
121
+ }
122
+ if (args.options.color !== undefined) {
123
+ data.color = args.options.color;
124
+ }
125
+ if (args.options.isDefault !== undefined) {
126
+ data.isDefaultCalendar = args.options.isDefault;
127
+ }
128
+ return data;
129
+ }
130
+ }
131
+ export default new OutlookCalendarSetCommand();
132
+ //# sourceMappingURL=calendar-set.js.map
@@ -0,0 +1,114 @@
1
+ import { z } from 'zod';
2
+ import GraphCommand from '../../../base/GraphCommand.js';
3
+ import commands from '../../commands.js';
4
+ import { validation } from '../../../../utils/validation.js';
5
+ import { globalOptionsZod } from '../../../../Command.js';
6
+ import { formatting } from '../../../../utils/formatting.js';
7
+ import { odata } from '../../../../utils/odata.js';
8
+ import request from '../../../../request.js';
9
+ import { accessToken } from '../../../../utils/accessToken.js';
10
+ import auth from '../../../../Auth.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
+ });
22
+ class OutlookCalendarGroupGetCommand extends GraphCommand {
23
+ get name() {
24
+ return commands.CALENDARGROUP_GET;
25
+ }
26
+ get description() {
27
+ return 'Retrieve information about a calendar group for a user';
28
+ }
29
+ get schema() {
30
+ return options;
31
+ }
32
+ getRefinedSchema(schema) {
33
+ return schema
34
+ .refine(o => !(o.id && o.name), {
35
+ error: 'Specify either id or name, but not both.'
36
+ })
37
+ .refine(o => Boolean(o.id || o.name), {
38
+ error: 'Specify either id or name.'
39
+ })
40
+ .refine(o => !(o.userId && o.userName), {
41
+ error: 'Specify either userId or userName, but not both.'
42
+ });
43
+ }
44
+ async commandAction(logger, args) {
45
+ try {
46
+ const token = auth.connection.accessTokens[auth.defaultResource].accessToken;
47
+ const isAppOnlyAccessToken = accessToken.isAppOnlyAccessToken(token);
48
+ let userIdentifier = undefined;
49
+ if (args.options.userId || args.options.userName) {
50
+ userIdentifier = args.options.userId ?? args.options.userName;
51
+ }
52
+ const encodedUserIdentifier = userIdentifier
53
+ ? formatting.encodeQueryParameter(userIdentifier)
54
+ : undefined;
55
+ if (isAppOnlyAccessToken) {
56
+ if (!args.options.userId && !args.options.userName) {
57
+ throw 'When running with application permissions either userId or userName is required.';
58
+ }
59
+ }
60
+ else {
61
+ 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.Read.Shared' || s === 'Calendars.ReadWrite.Shared');
69
+ if (!hasSharedScope) {
70
+ throw `To retrieve calendar groups of other users, the Entra ID application used for authentication must have either the Calendars.Read.Shared or Calendars.ReadWrite.Shared delegated permission assigned.`;
71
+ }
72
+ }
73
+ }
74
+ }
75
+ const getCalendarGroupByName = async (calendarGroupName) => {
76
+ const userPath = encodedUserIdentifier ? `users('${encodedUserIdentifier}')` : 'me';
77
+ const calendarGroups = await odata.getAllItems(`${this.resource}/v1.0/${userPath}/calendarGroups?$filter=name eq '${formatting.encodeQueryParameter(calendarGroupName)}'`);
78
+ if (calendarGroups.length === 0) {
79
+ throw `The specified calendar group '${calendarGroupName}' does not exist.`;
80
+ }
81
+ return calendarGroups[0];
82
+ };
83
+ if (args.options.name) {
84
+ if (this.verbose) {
85
+ await logger.logToStderr(`Retrieving calendar group '${args.options.name}'...`);
86
+ }
87
+ const result = await getCalendarGroupByName(args.options.name);
88
+ await logger.log(result);
89
+ }
90
+ else {
91
+ const calendarGroupId = args.options.id;
92
+ const userPath = encodedUserIdentifier ? `users('${encodedUserIdentifier}')` : 'me';
93
+ const requestUrl = `${this.resource}/v1.0/${userPath}/calendarGroups/${calendarGroupId}`;
94
+ if (this.verbose) {
95
+ await logger.logToStderr(`Retrieving calendar group '${calendarGroupId}'...`);
96
+ }
97
+ const requestOptions = {
98
+ url: requestUrl,
99
+ headers: {
100
+ accept: 'application/json;odata.metadata=none'
101
+ },
102
+ responseType: 'json'
103
+ };
104
+ const result = await request.get(requestOptions);
105
+ await logger.log(result);
106
+ }
107
+ }
108
+ catch (err) {
109
+ this.handleRejectedODataJsonPromise(err);
110
+ }
111
+ }
112
+ }
113
+ export default new OutlookCalendarGroupGetCommand();
114
+ //# sourceMappingURL=calendargroup-get.js.map