@pnp/cli-microsoft365 11.9.0-beta.93bd508 → 11.9.0-beta.9bd71dd

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 (86) hide show
  1. package/.devcontainer/Dockerfile +2 -2
  2. package/.devproxy/api-specs/sharepoint.yaml +84 -0
  3. package/allCommands.json +1 -1
  4. package/allCommandsFull.json +1 -1
  5. package/dist/m365/entra/commands/approleassignment/approleassignment-add.js +23 -48
  6. package/dist/m365/entra/commands/approleassignment/approleassignment-list.js +20 -43
  7. package/dist/m365/entra/commands/approleassignment/approleassignment-remove.js +24 -51
  8. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +20 -43
  9. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +20 -43
  10. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +9 -25
  11. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-remove.js +21 -50
  12. package/dist/m365/entra/commands/groupsetting/groupsetting-add.js +9 -25
  13. package/dist/m365/entra/commands/groupsetting/groupsetting-get.js +8 -24
  14. package/dist/m365/entra/commands/groupsetting/groupsetting-list.js +6 -0
  15. package/dist/m365/entra/commands/groupsetting/groupsetting-remove.js +9 -33
  16. package/dist/m365/entra/commands/groupsetting/groupsetting-set.js +8 -24
  17. package/dist/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-get.js +19 -38
  18. package/dist/m365/entra/commands/groupsettingtemplate/groupsettingtemplate-list.js +6 -0
  19. package/dist/m365/entra/commands/pim/pim-role-assignment-add.js +68 -114
  20. package/dist/m365/entra/commands/pim/pim-role-assignment-eligibility-list.js +28 -55
  21. package/dist/m365/entra/commands/pim/pim-role-assignment-list.js +30 -57
  22. package/dist/m365/entra/commands/pim/pim-role-assignment-remove.js +50 -90
  23. package/dist/m365/entra/commands/pim/pim-role-request-list.js +36 -69
  24. package/dist/m365/entra/commands/policy/policy-list.js +13 -56
  25. package/dist/m365/entra/commands/user/user-add.js +39 -118
  26. package/dist/m365/entra/commands/user/user-get.js +24 -49
  27. package/dist/m365/entra/commands/user/user-groupmembership-list.js +25 -48
  28. package/dist/m365/entra/commands/user/user-guest-add.js +14 -39
  29. package/dist/m365/entra/commands/user/user-hibp.js +12 -34
  30. package/dist/m365/entra/commands/user/user-license-add.js +23 -42
  31. package/dist/m365/entra/commands/user/user-license-list.js +21 -42
  32. package/dist/m365/entra/commands/user/user-license-remove.js +25 -47
  33. package/dist/m365/entra/commands/user/user-list.js +12 -39
  34. package/dist/m365/entra/commands/user/user-password-validate.js +8 -15
  35. package/dist/m365/entra/commands/user/user-recyclebinitem-clear.js +8 -22
  36. package/dist/m365/entra/commands/user/user-recyclebinitem-remove.js +9 -33
  37. package/dist/m365/entra/commands/user/user-recyclebinitem-restore.js +8 -24
  38. package/dist/m365/entra/commands/user/user-registrationdetails-list.js +43 -113
  39. package/dist/m365/entra/commands/user/user-remove.js +22 -42
  40. package/dist/m365/entra/commands/user/user-set.js +69 -149
  41. package/dist/m365/entra/commands/user/user-signin-list.js +22 -51
  42. package/dist/m365/external/commands/connection/connection-add.js +40 -65
  43. package/dist/m365/external/commands/connection/connection-doctor.js +14 -30
  44. package/dist/m365/external/commands/connection/connection-get.js +19 -28
  45. package/dist/m365/external/commands/connection/connection-remove.js +20 -25
  46. package/dist/m365/external/commands/connection/connection-schema-add.js +53 -42
  47. package/dist/m365/external/commands/connection/connection-urltoitemresolver-add.js +12 -23
  48. package/dist/m365/external/commands/item/item-add.js +37 -60
  49. package/dist/m365/file/commands/convert/convert-pdf.js +18 -33
  50. package/dist/m365/file/commands/file-add.js +28 -34
  51. package/dist/m365/file/commands/file-copy.js +18 -34
  52. package/dist/m365/file/commands/file-list.js +18 -24
  53. package/dist/m365/file/commands/file-move.js +22 -35
  54. package/dist/m365/flow/commands/flow-disable.js +10 -26
  55. package/dist/m365/flow/commands/flow-enable.js +10 -26
  56. package/dist/m365/flow/commands/flow-export.js +45 -71
  57. package/dist/m365/flow/commands/flow-get.js +10 -26
  58. package/dist/m365/flow/commands/flow-list.js +17 -48
  59. package/dist/m365/flow/commands/flow-remove.js +11 -38
  60. package/dist/m365/flow/commands/owner/owner-ensure.js +30 -65
  61. package/dist/m365/flow/commands/owner/owner-list.js +10 -35
  62. package/dist/m365/flow/commands/owner/owner-remove.js +30 -61
  63. package/dist/m365/flow/commands/run/run-cancel.js +11 -37
  64. package/dist/m365/flow/commands/run/run-get.js +12 -43
  65. package/dist/m365/flow/commands/run/run-list.js +29 -61
  66. package/dist/m365/flow/commands/run/run-resubmit.js +11 -37
  67. package/dist/m365/graph/commands/changelog/changelog-list.js +68 -67
  68. package/dist/m365/graph/commands/schemaextension/schemaextension-add.js +25 -31
  69. package/dist/m365/graph/commands/schemaextension/schemaextension-get.js +8 -15
  70. package/dist/m365/graph/commands/schemaextension/schemaextension-list.js +26 -50
  71. package/dist/m365/graph/commands/schemaextension/schemaextension-remove.js +9 -24
  72. package/dist/m365/graph/commands/schemaextension/schemaextension-set.js +32 -53
  73. package/dist/m365/graph/commands/subscription/subscription-add.js +63 -89
  74. package/dist/m365/outlook/commands/calendar/calendar-list.js +64 -0
  75. package/dist/m365/outlook/commands/mail/mail-send.js +55 -84
  76. package/dist/m365/outlook/commands/message/message-get.js +27 -27
  77. package/dist/m365/outlook/commands/message/message-list.js +53 -80
  78. package/dist/m365/outlook/commands/message/message-move.js +43 -40
  79. package/dist/m365/outlook/commands/message/message-remove.js +17 -45
  80. package/dist/m365/outlook/commands.js +1 -0
  81. package/dist/m365/spo/commands/list/list-sensitivitylabel-remove.js +83 -0
  82. package/dist/m365/spo/commands.js +1 -0
  83. package/docs/docs/cmd/outlook/calendar/calendar-list.mdx +155 -0
  84. package/docs/docs/cmd/spo/list/list-sensitivitylabel-remove.mdx +77 -0
  85. package/npm-shrinkwrap.json +7 -0
  86. package/package.json +1 -1
@@ -1,13 +1,24 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _GraphSubscriptionAddCommand_instances, _GraphSubscriptionAddCommand_initTelemetry, _GraphSubscriptionAddCommand_initOptions, _GraphSubscriptionAddCommand_initValidators;
1
+ import { z } from 'zod';
2
+ import { globalOptionsZod } from '../../../../Command.js';
7
3
  import request from '../../../../request.js';
8
4
  import { validation } from '../../../../utils/validation.js';
9
5
  import GraphCommand from '../../../base/GraphCommand.js';
10
6
  import commands from '../../commands.js';
7
+ const allowedTlsVersions = ['v1_0', 'v1_1', 'v1_2', 'v1_3'];
8
+ export const options = z.strictObject({
9
+ ...globalOptionsZod.shape,
10
+ resource: z.string().alias('r'),
11
+ notificationUrl: z.string().alias('u'),
12
+ changeTypes: z.string().alias('c'),
13
+ expirationDateTime: z.string().optional().alias('e'),
14
+ clientState: z.string().optional().alias('s'),
15
+ lifecycleNotificationUrl: z.string().optional(),
16
+ notificationUrlAppId: z.string().optional(),
17
+ latestTLSVersion: z.enum(allowedTlsVersions).optional(),
18
+ withResourceData: z.boolean().optional(),
19
+ encryptionCertificate: z.string().optional(),
20
+ encryptionCertificateId: z.string().optional()
21
+ });
11
22
  const DEFAULT_EXPIRATION_DELAY_IN_MINUTES_PER_RESOURCE_TYPE = {
12
23
  // User, group, other directory resources 4230 minutes (under 3 days)
13
24
  "users": 4230,
@@ -34,13 +45,52 @@ class GraphSubscriptionAddCommand extends GraphCommand {
34
45
  get description() {
35
46
  return 'Creates a Microsoft Graph subscription';
36
47
  }
37
- constructor() {
38
- super();
39
- _GraphSubscriptionAddCommand_instances.add(this);
40
- this.allowedTlsVersions = ['v1_0', 'v1_1', 'v1_2', 'v1_3'];
41
- __classPrivateFieldGet(this, _GraphSubscriptionAddCommand_instances, "m", _GraphSubscriptionAddCommand_initTelemetry).call(this);
42
- __classPrivateFieldGet(this, _GraphSubscriptionAddCommand_instances, "m", _GraphSubscriptionAddCommand_initOptions).call(this);
43
- __classPrivateFieldGet(this, _GraphSubscriptionAddCommand_instances, "m", _GraphSubscriptionAddCommand_initValidators).call(this);
48
+ get schema() {
49
+ return options;
50
+ }
51
+ getRefinedSchema(schema) {
52
+ return schema
53
+ .refine(options => {
54
+ const url = options.notificationUrl.toLowerCase();
55
+ return url.startsWith('https://') || url.startsWith('eventhub:https://') || url.startsWith('eventgrid:?azuresubscriptionid=');
56
+ }, {
57
+ error: e => `The specified notification URL '${e.input.notificationUrl}' does not start with either 'https://' or 'EventHub:https://' or 'EventGrid:?azuresubscriptionid='`,
58
+ path: ['notificationUrl']
59
+ })
60
+ .refine(options => this.isValidChangeTypes(options.changeTypes), {
61
+ error: `The specified changeTypes are invalid. Valid options are 'created', 'updated' and 'deleted'`,
62
+ path: ['changeTypes']
63
+ })
64
+ .refine(options => !options.expirationDateTime || validation.isValidISODateTime(options.expirationDateTime), {
65
+ error: 'The expirationDateTime is not a valid ISO date string',
66
+ path: ['expirationDateTime']
67
+ })
68
+ .refine(options => !options.clientState || options.clientState.length <= 128, {
69
+ error: 'The clientState value exceeds the maximum length of 128 characters',
70
+ path: ['clientState']
71
+ })
72
+ .refine(options => {
73
+ if (!options.lifecycleNotificationUrl) {
74
+ return true;
75
+ }
76
+ const url = options.lifecycleNotificationUrl.toLowerCase();
77
+ return url.startsWith('https://') || url.startsWith('eventhub:https://') || url.startsWith('eventgrid:?azuresubscriptionid=');
78
+ }, {
79
+ error: e => `The lifecycle notification URL '${e.input.lifecycleNotificationUrl}' does not start with either 'https://' or 'EventHub:https://' or 'EventGrid:?azuresubscriptionid='`,
80
+ path: ['lifecycleNotificationUrl']
81
+ })
82
+ .refine(options => !options.withResourceData || options.encryptionCertificate, {
83
+ error: `The 'encryptionCertificate' options is required to include the changed resource data`,
84
+ path: ['encryptionCertificate']
85
+ })
86
+ .refine(options => !options.withResourceData || options.encryptionCertificateId, {
87
+ error: `The 'encryptionCertificateId' options is required to include the changed resource data`,
88
+ path: ['encryptionCertificateId']
89
+ })
90
+ .refine(options => !options.notificationUrlAppId || validation.isValidGuid(options.notificationUrlAppId), {
91
+ error: e => `${e.input.notificationUrlAppId} is not a valid GUID for the 'notificationUrlAppId'`,
92
+ path: ['notificationUrlAppId']
93
+ });
44
94
  }
45
95
  async commandAction(logger, args) {
46
96
  const data = {
@@ -123,81 +173,5 @@ class GraphSubscriptionAddCommand extends GraphCommand {
123
173
  return invalidChangesTypes.length === 0;
124
174
  }
125
175
  }
126
- _GraphSubscriptionAddCommand_instances = new WeakSet(), _GraphSubscriptionAddCommand_initTelemetry = function _GraphSubscriptionAddCommand_initTelemetry() {
127
- this.telemetry.push((args) => {
128
- Object.assign(this.telemetryProperties, {
129
- changeTypes: args.options.changeTypes,
130
- expirationDateTime: typeof args.options.expirationDateTime !== 'undefined',
131
- clientState: typeof args.options.clientState !== 'undefined',
132
- lifecycleNotificationUrl: typeof args.options.lifecycleNotificationUrl !== 'undefined',
133
- notificationUrlAppId: typeof args.options.notificationUrlAppId !== 'undefined',
134
- latestTLSVersion: typeof args.options.latestTLSVersion !== 'undefined',
135
- withResourceData: !!args.options.withResourceData,
136
- encryptionCertificate: typeof args.options.encryptionCertificate !== 'undefined',
137
- encryptionCertificateId: typeof args.options.encryptionCertificateId !== 'undefined'
138
- });
139
- });
140
- }, _GraphSubscriptionAddCommand_initOptions = function _GraphSubscriptionAddCommand_initOptions() {
141
- this.options.unshift({
142
- option: '-r, --resource <resource>'
143
- }, {
144
- option: '-u, --notificationUrl <notificationUrl>'
145
- }, {
146
- option: '-c, --changeTypes <changeTypes>',
147
- autocomplete: ['created', 'updated', 'deleted']
148
- }, {
149
- option: '-e, --expirationDateTime [expirationDateTime]'
150
- }, {
151
- option: '-s, --clientState [clientState]'
152
- }, {
153
- option: '--lifecycleNotificationUrl [lifecycleNotificationUrl]'
154
- }, {
155
- option: '--notificationUrlAppId [notificationUrlAppId]'
156
- }, {
157
- option: '--latestTLSVersion [latestTLSVersion]',
158
- autocomplete: this.allowedTlsVersions
159
- }, {
160
- option: '--withResourceData [withResourceData]'
161
- }, {
162
- option: '--encryptionCertificate [encryptionCertificate]'
163
- }, {
164
- option: '--encryptionCertificateId [encryptionCertificateId]'
165
- });
166
- }, _GraphSubscriptionAddCommand_initValidators = function _GraphSubscriptionAddCommand_initValidators() {
167
- this.validators.push(async (args) => {
168
- if (!args.options.notificationUrl.toLowerCase().startsWith('https://')
169
- && !args.options.notificationUrl.toLowerCase().startsWith('eventhub:https://')
170
- && !args.options.notificationUrl.toLowerCase().startsWith('eventgrid:?azuresubscriptionid=')) {
171
- return `The specified notification URL '${args.options.notificationUrl}' does not start with either 'https://' or 'EventHub:https://' or 'EventGrid:?azuresubscriptionid='`;
172
- }
173
- if (!this.isValidChangeTypes(args.options.changeTypes)) {
174
- return `The specified changeTypes are invalid. Valid options are 'created', 'updated' and 'deleted'`;
175
- }
176
- if (args.options.expirationDateTime && !validation.isValidISODateTime(args.options.expirationDateTime)) {
177
- return 'The expirationDateTime is not a valid ISO date string';
178
- }
179
- if (args.options.clientState && args.options.clientState.length > 128) {
180
- return 'The clientState value exceeds the maximum length of 128 characters';
181
- }
182
- if (args.options.lifecycleNotificationUrl && !args.options.lifecycleNotificationUrl.toLowerCase().startsWith('https://')
183
- && !args.options.lifecycleNotificationUrl.toLowerCase().startsWith('eventhub:https://')
184
- && !args.options.lifecycleNotificationUrl.toLowerCase().startsWith('eventgrid:?azuresubscriptionid=')) {
185
- return `The lifecycle notification URL '${args.options.lifecycleNotificationUrl}' does not start with either 'https://' or 'EventHub:https://' or 'EventGrid:?azuresubscriptionid='`;
186
- }
187
- if (args.options.latestTLSVersion && this.allowedTlsVersions.map(x => x.toLowerCase()).indexOf(args.options.latestTLSVersion.toLowerCase()) === -1) {
188
- return `${args.options.latestTLSVersion} is not a valid TLS version. Allowed values are ${this.allowedTlsVersions.join(', ')}`;
189
- }
190
- if (args.options.withResourceData && !args.options.encryptionCertificate) {
191
- return `The 'encryptionCertificate' options is required to include the changed resource data`;
192
- }
193
- if (args.options.withResourceData && !args.options.encryptionCertificateId) {
194
- return `The 'encryptionCertificateId' options is required to include the changed resource data`;
195
- }
196
- if (args.options.notificationUrlAppId && !validation.isValidGuid(args.options.notificationUrlAppId)) {
197
- return `${args.options.notificationUrlAppId} is not a valid GUID for the 'notificationUrlAppId'`;
198
- }
199
- return true;
200
- });
201
- };
202
176
  export default new GraphSubscriptionAddCommand();
203
177
  //# sourceMappingURL=subscription-add.js.map
@@ -0,0 +1,64 @@
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 { odata } from '../../../../utils/odata.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
+ calendarGroupId: z.string().optional(),
19
+ calendarGroupName: z.string().optional()
20
+ });
21
+ class OutlookCalendarListCommand extends GraphCommand {
22
+ get name() {
23
+ return commands.CALENDAR_LIST;
24
+ }
25
+ get description() {
26
+ return 'Retrieves a list of all calendars of a user or a group';
27
+ }
28
+ get schema() {
29
+ return options;
30
+ }
31
+ getRefinedSchema(schema) {
32
+ return schema
33
+ .refine(options => [options.userId, options.userName].filter(x => x !== undefined).length === 1, {
34
+ error: 'Specify either userId or userName, but not both'
35
+ })
36
+ .refine(options => !(options.calendarGroupId && options.calendarGroupName), {
37
+ error: 'Specify either calendarGroupId or calendarGroupName, but not both'
38
+ });
39
+ }
40
+ defaultProperties() {
41
+ return ['id', 'name'];
42
+ }
43
+ async commandAction(logger, args) {
44
+ if (this.verbose) {
45
+ await logger.logToStderr(`Retrieving calendars for ${args.options.userId ?? args.options.userName}...`);
46
+ }
47
+ try {
48
+ const userIdentifier = args.options.userId ?? args.options.userName;
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
+ const url = `${this.resource}/v1.0/users('${userIdentifier}')/${calendarGroupId ? `calendarGroups/${calendarGroupId}/` : ''}calendars`;
55
+ const calendars = await odata.getAllItems(url);
56
+ await logger.log(calendars);
57
+ }
58
+ catch (err) {
59
+ this.handleRejectedODataJsonPromise(err);
60
+ }
61
+ }
62
+ }
63
+ export default new OutlookCalendarListCommand();
64
+ //# sourceMappingURL=calendar-list.js.map
@@ -1,17 +1,27 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _OutlookMailSendCommand_instances, _OutlookMailSendCommand_initTelemetry, _OutlookMailSendCommand_initOptions, _OutlookMailSendCommand_initTypes, _OutlookMailSendCommand_initValidators;
7
1
  import fs from 'fs';
8
2
  import path from 'path';
9
3
  import auth from '../../../../Auth.js';
4
+ import { globalOptionsZod } from '../../../../Command.js';
10
5
  import request from '../../../../request.js';
11
6
  import { accessToken } from '../../../../utils/accessToken.js';
12
7
  import { formatting } from '../../../../utils/formatting.js';
13
8
  import GraphCommand from '../../../base/GraphCommand.js';
14
9
  import commands from '../../commands.js';
10
+ import { z } from 'zod';
11
+ export const options = z.strictObject({
12
+ ...globalOptionsZod.shape,
13
+ subject: z.string().alias('s'),
14
+ to: z.string().alias('t'),
15
+ cc: z.string().optional(),
16
+ bcc: z.string().optional(),
17
+ sender: z.string().optional(),
18
+ mailbox: z.string().optional().alias('m'),
19
+ bodyContents: z.string(),
20
+ bodyContentType: z.enum(['Text', 'HTML']).optional(),
21
+ importance: z.enum(['low', 'normal', 'high']).optional(),
22
+ attachment: z.union([z.string(), z.string().array()]).optional(),
23
+ saveToSentItems: z.boolean().optional()
24
+ });
15
25
  class OutlookMailSendCommand extends GraphCommand {
16
26
  get name() {
17
27
  return commands.MAIL_SEND;
@@ -19,13 +29,45 @@ class OutlookMailSendCommand extends GraphCommand {
19
29
  get description() {
20
30
  return 'Sends an email';
21
31
  }
22
- constructor() {
23
- super();
24
- _OutlookMailSendCommand_instances.add(this);
25
- __classPrivateFieldGet(this, _OutlookMailSendCommand_instances, "m", _OutlookMailSendCommand_initTelemetry).call(this);
26
- __classPrivateFieldGet(this, _OutlookMailSendCommand_instances, "m", _OutlookMailSendCommand_initOptions).call(this);
27
- __classPrivateFieldGet(this, _OutlookMailSendCommand_instances, "m", _OutlookMailSendCommand_initTypes).call(this);
28
- __classPrivateFieldGet(this, _OutlookMailSendCommand_instances, "m", _OutlookMailSendCommand_initValidators).call(this);
32
+ get schema() {
33
+ return options;
34
+ }
35
+ getRefinedSchema(schema) {
36
+ return schema
37
+ .refine(options => {
38
+ if (!options.attachment) {
39
+ return true;
40
+ }
41
+ const attachments = typeof options.attachment === 'string' ? [options.attachment] : options.attachment;
42
+ for (const attachment of attachments) {
43
+ if (!fs.existsSync(attachment)) {
44
+ return false;
45
+ }
46
+ if (!fs.lstatSync(attachment).isFile()) {
47
+ return false;
48
+ }
49
+ }
50
+ const requestBody = this.getRequestBody(options);
51
+ // The max body size of the request is 4 194 304 chars before getting a 413 response
52
+ if (JSON.stringify(requestBody).length > 4194304) {
53
+ return false;
54
+ }
55
+ return true;
56
+ }, {
57
+ error: (ctx) => {
58
+ const opts = ctx.input;
59
+ const attachments = typeof opts.attachment === 'string' ? [opts.attachment] : opts.attachment;
60
+ for (const attachment of attachments) {
61
+ if (!fs.existsSync(attachment)) {
62
+ return `File with path '${attachment}' was not found.`;
63
+ }
64
+ if (!fs.lstatSync(attachment).isFile()) {
65
+ return `'${attachment}' is not a file.`;
66
+ }
67
+ }
68
+ return 'Exceeded the max total size of attachments which is 3MB.';
69
+ }
70
+ });
29
71
  }
30
72
  async commandAction(logger, args) {
31
73
  try {
@@ -83,76 +125,5 @@ class OutlookMailSendCommand extends GraphCommand {
83
125
  });
84
126
  }
85
127
  }
86
- _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initTelemetry = function _OutlookMailSendCommand_initTelemetry() {
87
- this.telemetry.push((args) => {
88
- Object.assign(this.telemetryProperties, {
89
- cc: typeof args.options.cc !== 'undefined',
90
- bcc: typeof args.options.bcc !== 'undefined',
91
- bodyContentType: args.options.bodyContentType,
92
- saveToSentItems: args.options.saveToSentItems,
93
- importance: args.options.importance,
94
- mailbox: typeof args.options.mailbox !== 'undefined',
95
- sender: typeof args.options.sender !== 'undefined',
96
- attachment: typeof args.options.attachment !== 'undefined'
97
- });
98
- });
99
- }, _OutlookMailSendCommand_initOptions = function _OutlookMailSendCommand_initOptions() {
100
- this.options.unshift({
101
- option: '-s, --subject <subject>'
102
- }, {
103
- option: '-t, --to <to>'
104
- }, {
105
- option: '--cc [cc]'
106
- }, {
107
- option: '--bcc [bcc]'
108
- }, {
109
- option: '--sender [sender]'
110
- }, {
111
- option: '-m, --mailbox [mailbox]'
112
- }, {
113
- option: '--bodyContents <bodyContents>'
114
- }, {
115
- option: '--bodyContentType [bodyContentType]',
116
- autocomplete: ['Text', 'HTML']
117
- }, {
118
- option: '--importance [importance]',
119
- autocomplete: ['low', 'normal', 'high']
120
- }, {
121
- option: '--attachment [attachment]'
122
- }, {
123
- option: '--saveToSentItems [saveToSentItems]',
124
- autocomplete: ['true', 'false']
125
- });
126
- }, _OutlookMailSendCommand_initTypes = function _OutlookMailSendCommand_initTypes() {
127
- this.types.boolean.push('saveToSentItems');
128
- }, _OutlookMailSendCommand_initValidators = function _OutlookMailSendCommand_initValidators() {
129
- this.validators.push(async (args) => {
130
- if (args.options.bodyContentType &&
131
- args.options.bodyContentType !== 'Text' &&
132
- args.options.bodyContentType !== 'HTML') {
133
- return `${args.options.bodyContentType} is not a valid value for the bodyContentType option. Allowed values are Text|HTML`;
134
- }
135
- if (args.options.importance && ['low', 'normal', 'high'].indexOf(args.options.importance) === -1) {
136
- return `'${args.options.importance}' is not a valid value for the importance option. Allowed values are low|normal|high`;
137
- }
138
- if (args.options.attachment) {
139
- const attachments = typeof args.options.attachment === 'string' ? [args.options.attachment] : args.options.attachment;
140
- for (const attachment of attachments) {
141
- if (!fs.existsSync(attachment)) {
142
- return `File with path '${attachment}' was not found.`;
143
- }
144
- if (!fs.lstatSync(attachment).isFile()) {
145
- return `'${attachment}' is not a file.`;
146
- }
147
- }
148
- const requestBody = this.getRequestBody(args.options);
149
- // The max body size of the request is 4 194 304 chars before getting a 413 response
150
- if (JSON.stringify(requestBody).length > 4194304) {
151
- return 'Exceeded the max total size of attachments which is 3MB.';
152
- }
153
- }
154
- return true;
155
- });
156
- };
157
128
  export default new OutlookMailSendCommand();
158
129
  //# sourceMappingURL=mail-send.js.map
@@ -1,14 +1,23 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _OutlookMessageGetCommand_instances, _OutlookMessageGetCommand_initTelemetry, _OutlookMessageGetCommand_initOptions;
7
1
  import auth from '../../../../Auth.js';
2
+ import { globalOptionsZod } from '../../../../Command.js';
8
3
  import request from '../../../../request.js';
9
4
  import { accessToken } from '../../../../utils/accessToken.js';
10
5
  import GraphCommand from '../../../base/GraphCommand.js';
11
6
  import commands from '../../commands.js';
7
+ import { z } from 'zod';
8
+ import { validation } from '../../../../utils/validation.js';
9
+ export const options = z.strictObject({
10
+ ...globalOptionsZod.shape,
11
+ id: z.string().alias('i'),
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
+ });
12
21
  class OutlookMessageGetCommand extends GraphCommand {
13
22
  get name() {
14
23
  return commands.MESSAGE_GET;
@@ -16,11 +25,18 @@ class OutlookMessageGetCommand extends GraphCommand {
16
25
  get description() {
17
26
  return 'Retrieves specified message';
18
27
  }
19
- constructor() {
20
- super();
21
- _OutlookMessageGetCommand_instances.add(this);
22
- __classPrivateFieldGet(this, _OutlookMessageGetCommand_instances, "m", _OutlookMessageGetCommand_initTelemetry).call(this);
23
- __classPrivateFieldGet(this, _OutlookMessageGetCommand_instances, "m", _OutlookMessageGetCommand_initOptions).call(this);
28
+ get schema() {
29
+ return options;
30
+ }
31
+ getRefinedSchema(schema) {
32
+ return schema
33
+ .refine(options => !(options.userId && options.userName), {
34
+ error: 'Specify either userId or userName, but not both',
35
+ params: {
36
+ customCode: 'optionSet',
37
+ options: ['userId', 'userName']
38
+ }
39
+ });
24
40
  }
25
41
  async commandAction(logger, args) {
26
42
  try {
@@ -65,21 +81,5 @@ class OutlookMessageGetCommand extends GraphCommand {
65
81
  }
66
82
  }
67
83
  }
68
- _OutlookMessageGetCommand_instances = new WeakSet(), _OutlookMessageGetCommand_initTelemetry = function _OutlookMessageGetCommand_initTelemetry() {
69
- this.telemetry.push((args) => {
70
- Object.assign(this.telemetryProperties, {
71
- userId: typeof args.options.userId !== 'undefined',
72
- userName: typeof args.options.userName !== 'undefined'
73
- });
74
- });
75
- }, _OutlookMessageGetCommand_initOptions = function _OutlookMessageGetCommand_initOptions() {
76
- this.options.unshift({
77
- option: '-i, --id <id>'
78
- }, {
79
- option: '--userId [userId]'
80
- }, {
81
- option: '--userName [userName]'
82
- });
83
- };
84
84
  export default new OutlookMessageGetCommand();
85
85
  //# sourceMappingURL=message-get.js.map
@@ -1,9 +1,4 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var _OutlookMessageListCommand_instances, _OutlookMessageListCommand_initTelemetry, _OutlookMessageListCommand_initOptions, _OutlookMessageListCommand_initValidators, _OutlookMessageListCommand_initTypes, _OutlookMessageListCommand_initOptionSets;
1
+ import { globalOptionsZod } from '../../../../Command.js';
7
2
  import request from '../../../../request.js';
8
3
  import { formatting } from '../../../../utils/formatting.js';
9
4
  import { odata } from '../../../../utils/odata.js';
@@ -14,6 +9,36 @@ import { cli } from '../../../../cli/cli.js';
14
9
  import { validation } from '../../../../utils/validation.js';
15
10
  import { accessToken } from '../../../../utils/accessToken.js';
16
11
  import auth from '../../../../Auth.js';
12
+ import { z } from 'zod';
13
+ export const options = z.strictObject({
14
+ ...globalOptionsZod.shape,
15
+ folderId: z.string().optional(),
16
+ folderName: z.string().optional(),
17
+ startTime: z.string()
18
+ .refine(startTime => validation.isValidISODateTime(startTime), {
19
+ error: e => `'${e.input}' is not a valid ISO date string for option startTime.`
20
+ })
21
+ .refine(startTime => new Date(startTime) <= new Date(), {
22
+ error: 'startTime value cannot be in the future.'
23
+ })
24
+ .optional(),
25
+ endTime: z.string()
26
+ .refine(endTime => validation.isValidISODateTime(endTime), {
27
+ error: e => `'${e.input}' is not a valid ISO date string for option endTime.`
28
+ })
29
+ .refine(endTime => new Date(endTime) <= new Date(), {
30
+ error: 'endTime value cannot be in the future.'
31
+ })
32
+ .optional(),
33
+ userId: z.string()
34
+ .refine(userId => validation.isValidGuid(userId), {
35
+ error: e => `${e.input} is not a valid GUID for option userId.`
36
+ }).optional(),
37
+ userName: z.string()
38
+ .refine(userName => validation.isValidUserPrincipalName(userName), {
39
+ error: e => `${e.input} is not a valid UPN for option userName.`
40
+ }).optional()
41
+ });
17
42
  class OutlookMessageListCommand extends GraphCommand {
18
43
  get name() {
19
44
  return commands.MESSAGE_LIST;
@@ -21,14 +46,28 @@ class OutlookMessageListCommand extends GraphCommand {
21
46
  get description() {
22
47
  return 'Gets all mail messages from the specified folder';
23
48
  }
24
- constructor() {
25
- super();
26
- _OutlookMessageListCommand_instances.add(this);
27
- __classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initTelemetry).call(this);
28
- __classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initOptions).call(this);
29
- __classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initValidators).call(this);
30
- __classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initTypes).call(this);
31
- __classPrivateFieldGet(this, _OutlookMessageListCommand_instances, "m", _OutlookMessageListCommand_initOptionSets).call(this);
49
+ get schema() {
50
+ return options;
51
+ }
52
+ getRefinedSchema(schema) {
53
+ return schema
54
+ .refine(options => !(options.folderId && options.folderName), {
55
+ error: 'Specify either folderId or folderName, but not both',
56
+ params: {
57
+ customCode: 'optionSet',
58
+ options: ['folderId', 'folderName']
59
+ }
60
+ })
61
+ .refine(options => !(options.userId && options.userName), {
62
+ error: 'Specify either userId or userName, but not both',
63
+ params: {
64
+ customCode: 'optionSet',
65
+ options: ['userId', 'userName']
66
+ }
67
+ })
68
+ .refine(options => !(options.startTime && options.endTime && new Date(options.startTime) >= new Date(options.endTime)), {
69
+ error: 'startTime must be before endTime.'
70
+ });
32
71
  }
33
72
  defaultProperties() {
34
73
  return ['subject', 'receivedDateTime'];
@@ -90,71 +129,5 @@ class OutlookMessageListCommand extends GraphCommand {
90
129
  return response.value[0].id;
91
130
  }
92
131
  }
93
- _OutlookMessageListCommand_instances = new WeakSet(), _OutlookMessageListCommand_initTelemetry = function _OutlookMessageListCommand_initTelemetry() {
94
- this.telemetry.push((args) => {
95
- Object.assign(this.telemetryProperties, {
96
- folderId: typeof args.options.folderId !== 'undefined',
97
- folderName: typeof args.options.folderName !== 'undefined',
98
- startTime: typeof args.options.startTime !== 'undefined',
99
- endTime: typeof args.options.endTime !== 'undefined',
100
- userId: typeof args.options.userId !== 'undefined',
101
- userName: typeof args.options.userName !== 'undefined'
102
- });
103
- });
104
- }, _OutlookMessageListCommand_initOptions = function _OutlookMessageListCommand_initOptions() {
105
- this.options.unshift({
106
- option: '--folderName [folderName]',
107
- autocomplete: Outlook.wellKnownFolderNames
108
- }, {
109
- option: '--folderId [folderId]'
110
- }, {
111
- option: '--startTime [startTime]'
112
- }, {
113
- option: '--endTime [endTime]'
114
- }, {
115
- option: '--userId [userId]'
116
- }, {
117
- option: '--userName [userName]'
118
- });
119
- }, _OutlookMessageListCommand_initValidators = function _OutlookMessageListCommand_initValidators() {
120
- this.validators.push(async (args) => {
121
- if (args.options.startTime) {
122
- if (!validation.isValidISODateTime(args.options.startTime)) {
123
- return `'${args.options.startTime}' is not a valid ISO date string for option startTime.`;
124
- }
125
- if (new Date(args.options.startTime) > new Date()) {
126
- return 'startTime value cannot be in the future.';
127
- }
128
- }
129
- if (args.options.endTime) {
130
- if (!validation.isValidISODateTime(args.options.endTime)) {
131
- return `'${args.options.endTime}' is not a valid ISO date string for option endTime.`;
132
- }
133
- if (new Date(args.options.endTime) > new Date()) {
134
- return 'endTime value cannot be in the future.';
135
- }
136
- }
137
- if (args.options.startTime && args.options.endTime && new Date(args.options.startTime) >= new Date(args.options.endTime)) {
138
- return 'startTime must be before endTime.';
139
- }
140
- if (args.options.userId && !validation.isValidGuid(args.options.userId)) {
141
- return `${args.options.userId} is not a valid GUID for option userId.`;
142
- }
143
- if (args.options.userName && !validation.isValidUserPrincipalName(args.options.userName)) {
144
- return `${args.options.userName} is not a valid UPN for option userName.`;
145
- }
146
- return true;
147
- });
148
- }, _OutlookMessageListCommand_initTypes = function _OutlookMessageListCommand_initTypes() {
149
- this.types.string.push('folderName', 'folderId', 'startTime', 'endTime', 'userId', 'userName');
150
- }, _OutlookMessageListCommand_initOptionSets = function _OutlookMessageListCommand_initOptionSets() {
151
- this.optionSets.push({
152
- options: ['folderId', 'folderName'],
153
- runsWhen: (args) => args.options.folderId || args.options.folderName
154
- }, {
155
- options: ['userId', 'userName'],
156
- runsWhen: (args) => args.options.userId || args.options.userName
157
- });
158
- };
159
132
  export default new OutlookMessageListCommand();
160
133
  //# sourceMappingURL=message-list.js.map