@zapier/microsoft-outlook-connector 0.0.0 → 0.1.0

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 (45) hide show
  1. package/LICENSE +93 -0
  2. package/NOTICE +8 -0
  3. package/NOTICE.md +8 -0
  4. package/README.md +145 -2
  5. package/SKILL.md +159 -0
  6. package/cli.js +71 -0
  7. package/cli.ts +5 -0
  8. package/connections.ts +69 -0
  9. package/dist/cli.js +4 -0
  10. package/dist/index.js +1823 -0
  11. package/index.ts +103 -0
  12. package/package.json +65 -4
  13. package/preflight.sh +157 -0
  14. package/references/microsoft-outlook-api-gotchas.md +210 -0
  15. package/scripts/copyMessage.ts +68 -0
  16. package/scripts/createContact.ts +39 -0
  17. package/scripts/createDraft.ts +71 -0
  18. package/scripts/createEvent.ts +61 -0
  19. package/scripts/createMailFolder.ts +68 -0
  20. package/scripts/createReplyDraft.ts +81 -0
  21. package/scripts/deleteContact.ts +47 -0
  22. package/scripts/deleteEvent.ts +61 -0
  23. package/scripts/deleteMessage.ts +57 -0
  24. package/scripts/forwardMessage.ts +75 -0
  25. package/scripts/getAttachment.ts +60 -0
  26. package/scripts/getContact.ts +44 -0
  27. package/scripts/getEvent.ts +63 -0
  28. package/scripts/getMe.ts +42 -0
  29. package/scripts/getMessage.ts +68 -0
  30. package/scripts/listAttachments.ts +94 -0
  31. package/scripts/listCalendarView.ts +99 -0
  32. package/scripts/listCalendars.ts +85 -0
  33. package/scripts/listCategories.ts +49 -0
  34. package/scripts/listContacts.ts +81 -0
  35. package/scripts/listEvents.ts +94 -0
  36. package/scripts/listMailFolders.ts +98 -0
  37. package/scripts/listMessages.ts +106 -0
  38. package/scripts/moveMessage.ts +68 -0
  39. package/scripts/replyToMessage.ts +73 -0
  40. package/scripts/sendDraft.ts +55 -0
  41. package/scripts/sendMail.ts +68 -0
  42. package/scripts/updateContact.ts +49 -0
  43. package/scripts/updateEvent.ts +69 -0
  44. package/scripts/updateMessage.ts +99 -0
  45. package/tsup.config.ts +63 -0
package/dist/index.js ADDED
@@ -0,0 +1,1823 @@
1
+ // index.ts
2
+ import { defineConnector, toFunctions } from "@zapier/connectors-sdk";
3
+
4
+ // connections.ts
5
+ import {
6
+ defineEnvResolver,
7
+ zapierConnectionResolver
8
+ } from "@zapier/connectors-sdk";
9
+ var IMMUTABLE_ID_PREFER = 'IdType="ImmutableId"';
10
+ function withImmutableId(fetchImpl) {
11
+ return ((input, init = {}) => {
12
+ const headers = new Headers(init.headers ?? void 0);
13
+ const existing = headers.get("Prefer");
14
+ headers.set(
15
+ "Prefer",
16
+ existing ? `${existing}, ${IMMUTABLE_ID_PREFER}` : IMMUTABLE_ID_PREFER
17
+ );
18
+ return fetchImpl(input, { ...init, headers });
19
+ });
20
+ }
21
+ function bearerFetch(token) {
22
+ return ((input, init = {}) => {
23
+ const headers = new Headers(init.headers ?? void 0);
24
+ headers.set("Authorization", `Bearer ${token}`);
25
+ return globalThis.fetch(input, { ...init, headers });
26
+ });
27
+ }
28
+ var zapierOutlookResolver = {
29
+ ...zapierConnectionResolver,
30
+ resolve: async (value) => withImmutableId(await zapierConnectionResolver.resolve(value))
31
+ };
32
+ var directOutlookResolver = defineEnvResolver({
33
+ name: "env",
34
+ valueDescription: "env var holding a Microsoft Graph access token, sent as `Authorization: Bearer <token>`; matches when the var is set",
35
+ build: (token) => withImmutableId(bearerFetch(token))
36
+ });
37
+ var connectionResolvers = {
38
+ "microsoft-outlook": [zapierOutlookResolver, directOutlookResolver]
39
+ };
40
+
41
+ // scripts/copyMessage.ts
42
+ import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
43
+ import { z } from "zod";
44
+
45
+ // lib/graph.ts
46
+ var GRAPH_BASE = "https://graph.microsoft.com/v1.0";
47
+ function mailboxRoot(mailbox) {
48
+ return mailbox ? `/users/${encodeURIComponent(mailbox)}` : "/me";
49
+ }
50
+ function calendarRoot(mailbox, calendarId) {
51
+ const base = mailboxRoot(mailbox);
52
+ return calendarId ? `${base}/calendars/${encodeURIComponent(calendarId)}` : base;
53
+ }
54
+ function buildListQuery(params) {
55
+ const sp = new URLSearchParams();
56
+ if (params.limit !== void 0) sp.set("$top", String(params.limit));
57
+ if (params.search !== void 0) sp.set("$search", `"${params.search}"`);
58
+ if (params.filter !== void 0) sp.set("$filter", params.filter);
59
+ if (params.orderBy !== void 0) sp.set("$orderby", params.orderBy);
60
+ if (params.select !== void 0) sp.set("$select", params.select);
61
+ const qs = sp.toString();
62
+ return qs ? `?${qs}` : "";
63
+ }
64
+ function stripNullsDeep(value) {
65
+ if (Array.isArray(value)) {
66
+ return value.map((v) => stripNullsDeep(v));
67
+ }
68
+ if (value !== null && typeof value === "object") {
69
+ const out = {};
70
+ for (const [k, v] of Object.entries(value)) {
71
+ if (v === null || v === void 0) continue;
72
+ out[k] = stripNullsDeep(v);
73
+ }
74
+ return out;
75
+ }
76
+ return value;
77
+ }
78
+ async function parseGraphResponse(res) {
79
+ return stripNullsDeep(await res.json());
80
+ }
81
+ function toListResult(payload) {
82
+ const p = payload ?? {};
83
+ const nextLink = p["@odata.nextLink"];
84
+ return {
85
+ items: (p.value ?? []).map((item) => stripNullsDeep(item)),
86
+ ...nextLink ? { next_cursor: nextLink } : {}
87
+ };
88
+ }
89
+ async function graphError(toolName, res) {
90
+ const raw = await res.text().catch(() => "");
91
+ let code = "";
92
+ let message = "";
93
+ if (raw) {
94
+ try {
95
+ const body = JSON.parse(raw);
96
+ code = body.error?.code ?? "";
97
+ message = body.error?.message ?? "";
98
+ } catch {
99
+ message = raw;
100
+ }
101
+ }
102
+ const prefix = `Microsoft Outlook ${toolName} ${res.status}`;
103
+ const detail = code ? `${code}: ${message}` : message || res.statusText;
104
+ if (res.status === 404 || code === "ErrorItemNotFound") {
105
+ return new Error(
106
+ `${prefix}: ${detail}. The id may be stale \u2014 message and event ids change when an item moves between folders. Re-fetch the id from the relevant list/get tool and retry.`
107
+ );
108
+ }
109
+ if (code === "ErrorInvalidIdMalformed") {
110
+ return new Error(
111
+ `${prefix}: ${detail}. One of the ids is malformed \u2014 obtain a valid id from a list or get tool.`
112
+ );
113
+ }
114
+ if (res.status === 403 || code === "ErrorAccessDenied") {
115
+ return new Error(
116
+ `${prefix}: ${detail}. Reconnect your Outlook account to grant the permission this action needs (shared-mailbox access also requires Exchange-side delegation).`
117
+ );
118
+ }
119
+ if (res.status === 401) {
120
+ return new Error(
121
+ `${prefix}: ${detail}. The access token is invalid or expired \u2014 reconnect your Outlook account.`
122
+ );
123
+ }
124
+ if (res.status === 413) {
125
+ return new Error(
126
+ `${prefix}: ${detail}. Attachments must be under 3 MB and sent inline; larger files are not supported.`
127
+ );
128
+ }
129
+ if (res.status === 429) {
130
+ const retryAfter = res.headers?.get?.("Retry-After");
131
+ return new Error(
132
+ `${prefix}: throttled by Microsoft Graph${retryAfter ? ` \u2014 retry after ${retryAfter}s` : ""}. ${message}`.trim()
133
+ );
134
+ }
135
+ return new Error(`${prefix}: ${detail}`);
136
+ }
137
+ async function outlookFetch(fetch, toolName, url, init = {}) {
138
+ const headers = new Headers(init.headers);
139
+ if (init.body !== void 0 && !headers.has("Content-Type")) {
140
+ headers.set("Content-Type", "application/json");
141
+ }
142
+ const res = await fetch(url, { ...init, headers });
143
+ if (!res.ok) throw await graphError(toolName, res);
144
+ return res;
145
+ }
146
+
147
+ // scripts/copyMessage.ts
148
+ var inputSchema = z.object({
149
+ messageId: z.string().describe(
150
+ "Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders."
151
+ ),
152
+ destinationId: z.string().describe(
153
+ "Target folder: a folder id from listMailFolders, or a well-known name (inbox, archive, deleteditems, junkemail, drafts, sentitems)."
154
+ ),
155
+ mailbox: z.string().describe(
156
+ "Shared-mailbox address (UPN/email) to copy within instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
157
+ ).optional()
158
+ }).strict();
159
+ var outputSchema = z.object({
160
+ id: z.string(),
161
+ parentFolderId: z.string(),
162
+ subject: z.string()
163
+ });
164
+ var definition = defineTool({
165
+ name: "copyMessage",
166
+ title: "Copy Message",
167
+ description: "Copy a message into another folder, leaving the original in place. Resolve the message id via listMessages first. Returns the new copy, which has its own id distinct from the original.",
168
+ inputSchema,
169
+ outputSchema,
170
+ annotations: {
171
+ readOnlyHint: false,
172
+ destructiveHint: false,
173
+ idempotentHint: false,
174
+ openWorldHint: true
175
+ },
176
+ connection: "microsoft-outlook",
177
+ run: async (input, ctx) => {
178
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
179
+ input.messageId
180
+ )}/copy`;
181
+ const res = await outlookFetch(ctx.fetch, "copyMessage", url, {
182
+ method: "POST",
183
+ body: JSON.stringify({ destinationId: input.destinationId })
184
+ });
185
+ return parseGraphResponse(res);
186
+ }
187
+ });
188
+ var copyMessage_default = definition;
189
+ await handleIfScriptMain(import.meta, definition, { connectionResolvers });
190
+
191
+ // scripts/createContact.ts
192
+ import { defineTool as defineTool2, handleIfScriptMain as handleIfScriptMain2 } from "@zapier/connectors-sdk";
193
+ import { z as z3 } from "zod";
194
+
195
+ // lib/schemas.ts
196
+ import { z as z2 } from "zod";
197
+ var emailAddressSchema = z2.object({
198
+ address: z2.string().describe("Email address, e.g. jane@contoso.com."),
199
+ name: z2.string().optional().describe("Display name, when known.")
200
+ });
201
+ var recipientSchema = z2.object({
202
+ emailAddress: emailAddressSchema
203
+ });
204
+ var dateTimeTimeZoneSchema = z2.object({
205
+ dateTime: z2.string().describe("Local date-time without offset, e.g. 2026-07-01T15:30:00."),
206
+ timeZone: z2.string().describe(
207
+ "Time-zone name, e.g. Pacific Standard Time or America/Los_Angeles."
208
+ )
209
+ });
210
+ var itemBodySchema = z2.object({
211
+ contentType: z2.enum(["text", "html"]).describe("Body content type."),
212
+ content: z2.string().describe("Body content, as text or HTML.")
213
+ });
214
+ var followupFlagSchema = z2.object({
215
+ flagStatus: z2.enum(["notFlagged", "flagged", "complete"]).describe("Follow-up flag state."),
216
+ startDateTime: dateTimeTimeZoneSchema.optional(),
217
+ dueDateTime: dateTimeTimeZoneSchema.optional()
218
+ });
219
+ var locationSchema = z2.object({
220
+ displayName: z2.string().optional().describe("Location name.")
221
+ });
222
+ var attendeeSchema = z2.object({
223
+ emailAddress: emailAddressSchema,
224
+ type: z2.string().optional().describe("Attendee type: required, optional, or resource."),
225
+ status: z2.object({
226
+ response: z2.string().optional().describe(
227
+ "Response: none, accepted, tentativelyAccepted, declined, organizer."
228
+ ),
229
+ time: z2.string().optional()
230
+ }).optional()
231
+ });
232
+ var messageListItemSchema = z2.object({
233
+ id: z2.string(),
234
+ subject: z2.string(),
235
+ bodyPreview: z2.string().optional().describe(
236
+ "First ~255 chars of the body; use getMessage for the full body."
237
+ ),
238
+ from: recipientSchema.optional(),
239
+ receivedDateTime: z2.string().optional(),
240
+ isRead: z2.boolean(),
241
+ hasAttachments: z2.boolean().optional().describe("False when a message has only inline attachments."),
242
+ importance: z2.string().optional(),
243
+ webLink: z2.string().optional()
244
+ });
245
+ var messageSchema = z2.object({
246
+ id: z2.string(),
247
+ subject: z2.string(),
248
+ body: itemBodySchema.optional(),
249
+ bodyPreview: z2.string().optional(),
250
+ from: recipientSchema.optional(),
251
+ sender: recipientSchema.optional(),
252
+ toRecipients: z2.array(recipientSchema).optional(),
253
+ ccRecipients: z2.array(recipientSchema).optional(),
254
+ receivedDateTime: z2.string().optional(),
255
+ sentDateTime: z2.string().optional(),
256
+ isRead: z2.boolean(),
257
+ isDraft: z2.boolean().optional(),
258
+ hasAttachments: z2.boolean().optional(),
259
+ importance: z2.string().optional(),
260
+ categories: z2.array(z2.string()).optional(),
261
+ flag: followupFlagSchema.optional(),
262
+ parentFolderId: z2.string().optional(),
263
+ internetMessageId: z2.string().optional().describe("The RFC 2822 Internet message id."),
264
+ conversationId: z2.string().optional(),
265
+ webLink: z2.string().optional()
266
+ });
267
+ var attachmentBaseSchema = z2.object({
268
+ id: z2.string(),
269
+ name: z2.string(),
270
+ contentType: z2.string().optional(),
271
+ size: z2.number().optional().describe("Size in bytes."),
272
+ type: z2.string().optional().describe('Attachment kind: "file", "item", or "reference".')
273
+ });
274
+ function attachmentKind(odataType) {
275
+ if (typeof odataType !== "string") return void 0;
276
+ const match = /#microsoft\.graph\.(file|item|reference)Attachment/i.exec(
277
+ odataType
278
+ );
279
+ return match ? match[1].toLowerCase() : void 0;
280
+ }
281
+ function normalizeAttachment(attachment) {
282
+ return { ...attachment, type: attachmentKind(attachment["@odata.type"]) };
283
+ }
284
+ var attachmentListItemSchema = attachmentBaseSchema.extend({
285
+ isInline: z2.boolean().optional()
286
+ });
287
+ var attachmentSchema = attachmentBaseSchema.extend({
288
+ contentBytes: z2.string().optional().describe("Base64 content \u2014 present only for file attachments.")
289
+ });
290
+ var eventListItemSchema = z2.object({
291
+ id: z2.string(),
292
+ subject: z2.string(),
293
+ start: dateTimeTimeZoneSchema.optional(),
294
+ end: dateTimeTimeZoneSchema.optional(),
295
+ isAllDay: z2.boolean().optional(),
296
+ location: locationSchema.optional(),
297
+ organizer: recipientSchema.optional(),
298
+ type: z2.string().optional().describe("singleInstance, seriesMaster, occurrence, or exception."),
299
+ seriesMasterId: z2.string().optional().describe(
300
+ "For occurrences/exceptions: the id of the recurring series master."
301
+ ),
302
+ webLink: z2.string().optional()
303
+ });
304
+ var eventSchema = z2.object({
305
+ id: z2.string(),
306
+ subject: z2.string(),
307
+ body: itemBodySchema.optional(),
308
+ start: dateTimeTimeZoneSchema,
309
+ end: dateTimeTimeZoneSchema,
310
+ isAllDay: z2.boolean().optional(),
311
+ location: locationSchema.optional(),
312
+ organizer: recipientSchema.optional(),
313
+ attendees: z2.array(attendeeSchema).optional(),
314
+ isOnlineMeeting: z2.boolean().optional(),
315
+ onlineMeeting: z2.object({ joinUrl: z2.string().optional() }).optional().describe("Online-meeting join details, when the event has one."),
316
+ showAs: z2.string().optional().describe("free, tentative, busy, oof, workingElsewhere, or unknown."),
317
+ type: z2.string().optional(),
318
+ seriesMasterId: z2.string().optional(),
319
+ categories: z2.array(z2.string()).optional(),
320
+ webLink: z2.string().optional()
321
+ });
322
+ var emailAddressInputSchema = z2.strictObject({
323
+ address: z2.string().describe("Email address, e.g. jane@contoso.com."),
324
+ name: z2.string().describe("Display name, optional.").optional()
325
+ });
326
+ var recipientInputSchema = z2.strictObject({
327
+ emailAddress: emailAddressInputSchema
328
+ });
329
+ var dateTimeTimeZoneInputSchema = z2.strictObject({
330
+ dateTime: z2.string().describe(
331
+ "Naive local date-time, no trailing Z or offset, e.g. 2026-07-01T15:30:00. The zone goes in timeZone, not here."
332
+ ),
333
+ timeZone: z2.string().describe(
334
+ "Time-zone name, e.g. Pacific Standard Time or America/Los_Angeles. Prefer an IANA name for correct DST."
335
+ )
336
+ });
337
+ var fileAttachmentInputSchema = z2.strictObject({
338
+ name: z2.string().describe('File name shown in the email, e.g. "report.pdf".'),
339
+ contentType: z2.string().describe('MIME type, e.g. "application/pdf".').optional(),
340
+ contentBytes: z2.string().describe(
341
+ "Base64-encoded file bytes (no data: prefix). Decoded size must be under 3 MB."
342
+ )
343
+ });
344
+ var outgoingMessageSchema = z2.strictObject({
345
+ subject: z2.string().describe("Subject line."),
346
+ body: z2.strictObject({
347
+ contentType: z2.enum(["text", "html"]).describe("Body format. Defaults to text.").optional(),
348
+ content: z2.string().describe("Body text or HTML.")
349
+ }).describe("Message body.").optional(),
350
+ toRecipients: z2.array(recipientInputSchema).describe(
351
+ 'Primary recipients, e.g. [{ "emailAddress": { "address": "jane@contoso.com" } }].'
352
+ ),
353
+ ccRecipients: z2.array(recipientInputSchema).describe("Cc recipients.").optional(),
354
+ bccRecipients: z2.array(recipientInputSchema).describe("Bcc recipients.").optional(),
355
+ importance: z2.enum(["low", "normal", "high"]).describe("Importance level. Defaults to normal.").optional(),
356
+ attachments: z2.array(fileAttachmentInputSchema).describe("Inline file attachments, each under 3 MB.").optional()
357
+ });
358
+ function toGraphOutgoingMessage(message) {
359
+ if (!message.attachments?.length) return message;
360
+ return {
361
+ ...message,
362
+ attachments: message.attachments.map((attachment) => ({
363
+ "@odata.type": "#microsoft.graph.fileAttachment",
364
+ ...attachment
365
+ }))
366
+ };
367
+ }
368
+ var attendeeInputSchema = z2.strictObject({
369
+ emailAddress: emailAddressInputSchema,
370
+ type: z2.enum(["required", "optional", "resource"]).describe("Attendee type. Defaults to required.").optional()
371
+ });
372
+ var outgoingEventSchema = z2.strictObject({
373
+ subject: z2.string().describe("Event title."),
374
+ start: dateTimeTimeZoneInputSchema.describe("Start date-time and time zone."),
375
+ end: dateTimeTimeZoneInputSchema.describe("End date-time and time zone."),
376
+ body: z2.strictObject({
377
+ contentType: z2.enum(["text", "html"]).describe("Body format. Defaults to text.").optional(),
378
+ content: z2.string().describe("Body text or HTML.")
379
+ }).describe("Event body / description.").optional(),
380
+ isAllDay: z2.boolean().describe(
381
+ "All-day event. Set start and end to midnight in the same time zone; end is midnight of the day AFTER the last day."
382
+ ).optional(),
383
+ location: z2.strictObject({ displayName: z2.string().describe("Location name.") }).describe("Event location.").optional(),
384
+ attendees: z2.array(attendeeInputSchema).describe("Attendees. Replaces the existing list on updateEvent.").optional(),
385
+ isOnlineMeeting: z2.boolean().describe(
386
+ "Add a Teams online meeting (Microsoft Graph populates the join URL)."
387
+ ).optional(),
388
+ showAs: z2.enum(["free", "tentative", "busy", "oof", "workingElsewhere", "unknown"]).describe("Free/busy status to show.").optional(),
389
+ sensitivity: z2.enum(["normal", "personal", "private", "confidential"]).describe("Event sensitivity.").optional(),
390
+ reminderMinutesBeforeStart: z2.number().int().describe("Minutes before start to remind.").optional(),
391
+ categories: z2.array(z2.string()).describe("Category names (see listCategories).").optional()
392
+ });
393
+ var outgoingContactSchema = z2.strictObject({
394
+ givenName: z2.string().describe("First name.").optional(),
395
+ surname: z2.string().describe("Last name.").optional(),
396
+ displayName: z2.string().describe("Full display name.").optional(),
397
+ companyName: z2.string().describe("Company name.").optional(),
398
+ jobTitle: z2.string().describe("Job title.").optional(),
399
+ emailAddresses: z2.array(emailAddressInputSchema).max(3).describe("Email addresses (Microsoft allows a maximum of 3).").optional(),
400
+ businessPhones: z2.array(z2.string()).describe("Business phone numbers.").optional(),
401
+ mobilePhone: z2.string().describe("Mobile phone number.").optional()
402
+ });
403
+ var contactSchema = z2.object({
404
+ id: z2.string(),
405
+ displayName: z2.string().optional(),
406
+ givenName: z2.string().optional(),
407
+ surname: z2.string().optional(),
408
+ companyName: z2.string().optional(),
409
+ jobTitle: z2.string().optional(),
410
+ emailAddresses: z2.array(emailAddressSchema).optional(),
411
+ businessPhones: z2.array(z2.string()).optional(),
412
+ mobilePhone: z2.string().optional()
413
+ });
414
+
415
+ // scripts/createContact.ts
416
+ var inputSchema2 = z3.object({ ...outgoingContactSchema.shape }).strict();
417
+ var outputSchema2 = contactSchema;
418
+ var definition2 = defineTool2({
419
+ name: "createContact",
420
+ title: "Create Contact",
421
+ description: "Create a personal contact. No single field is required, but set at least a name (givenName/surname/displayName) or an email address so the contact is identifiable. Microsoft allows a maximum of 3 email addresses per contact.",
422
+ inputSchema: inputSchema2,
423
+ outputSchema: outputSchema2,
424
+ annotations: {
425
+ readOnlyHint: false,
426
+ destructiveHint: false,
427
+ idempotentHint: false,
428
+ openWorldHint: true
429
+ },
430
+ connection: "microsoft-outlook",
431
+ run: async (input, ctx) => {
432
+ const url = `${GRAPH_BASE}/me/contacts`;
433
+ const res = await outlookFetch(ctx.fetch, "createContact", url, {
434
+ method: "POST",
435
+ body: JSON.stringify(input)
436
+ });
437
+ return parseGraphResponse(res);
438
+ }
439
+ });
440
+ var createContact_default = definition2;
441
+ await handleIfScriptMain2(import.meta, definition2, { connectionResolvers });
442
+
443
+ // scripts/createDraft.ts
444
+ import { defineTool as defineTool3, handleIfScriptMain as handleIfScriptMain3 } from "@zapier/connectors-sdk";
445
+ import { z as z4 } from "zod";
446
+ var inputSchema3 = z4.object({
447
+ ...outgoingMessageSchema.shape,
448
+ mailbox: z4.string().describe(
449
+ "Shared-mailbox address (UPN/email) to draft in instead of your own, e.g. team@contoso.com. Requires Send-as/Send-on-behalf delegation. Omit to draft in your own mailbox."
450
+ ).optional()
451
+ }).strict();
452
+ var outputSchema3 = z4.object({
453
+ id: z4.string().describe("Draft id \u2014 pass to sendDraft to send it later."),
454
+ subject: z4.string(),
455
+ isDraft: z4.boolean(),
456
+ bodyPreview: z4.string().optional().describe(
457
+ "First ~255 chars of the body; use getMessage for the full body."
458
+ ),
459
+ toRecipients: z4.array(recipientSchema).optional(),
460
+ webLink: z4.string().optional()
461
+ });
462
+ var definition3 = defineTool3({
463
+ name: "createDraft",
464
+ title: "Create Draft",
465
+ description: "Compose an email and save it as a draft without sending. Returns the draft's id \u2014 the id-bearing path: pair with sendDraft when you need to reference or send the message later, or leave the draft for a human to review. Use sendMail to compose and send in one step (no id returned).",
466
+ inputSchema: inputSchema3,
467
+ outputSchema: outputSchema3,
468
+ annotations: {
469
+ readOnlyHint: false,
470
+ destructiveHint: false,
471
+ idempotentHint: false,
472
+ openWorldHint: true
473
+ },
474
+ connection: "microsoft-outlook",
475
+ run: async (input, ctx) => {
476
+ const { mailbox, ...message } = input;
477
+ const url = `${GRAPH_BASE}${mailboxRoot(mailbox)}/messages`;
478
+ const res = await outlookFetch(ctx.fetch, "createDraft", url, {
479
+ method: "POST",
480
+ body: JSON.stringify(toGraphOutgoingMessage(message))
481
+ });
482
+ return parseGraphResponse(res);
483
+ }
484
+ });
485
+ var createDraft_default = definition3;
486
+ await handleIfScriptMain3(import.meta, definition3, { connectionResolvers });
487
+
488
+ // scripts/createEvent.ts
489
+ import { defineTool as defineTool4, handleIfScriptMain as handleIfScriptMain4 } from "@zapier/connectors-sdk";
490
+ import { z as z5 } from "zod";
491
+ var inputSchema4 = z5.object({
492
+ ...outgoingEventSchema.shape,
493
+ mailbox: z5.string().describe(
494
+ "Shared-mailbox address (UPN/email) to create the event in instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
495
+ ).optional(),
496
+ calendarId: z5.string().describe(
497
+ "Target a specific calendar (id from listCalendars). Omit to use the default calendar."
498
+ ).optional()
499
+ }).strict();
500
+ var outputSchema4 = eventSchema;
501
+ var definition4 = defineTool4({
502
+ name: "createEvent",
503
+ title: "Create Event",
504
+ description: "Create a calendar event. Targets the default calendar unless calendarId is set. start and end are { dateTime, timeZone } objects where dateTime is a naive local timestamp (no trailing Z or offset). For an all-day event set isAllDay with start/end at midnight in the same time zone (end is midnight of the day AFTER the last day). Set isOnlineMeeting to add a Teams online meeting.",
505
+ inputSchema: inputSchema4,
506
+ outputSchema: outputSchema4,
507
+ annotations: {
508
+ readOnlyHint: false,
509
+ destructiveHint: false,
510
+ idempotentHint: false,
511
+ openWorldHint: true
512
+ },
513
+ connection: "microsoft-outlook",
514
+ run: async (input, ctx) => {
515
+ const { mailbox, calendarId, ...event } = input;
516
+ const url = `${GRAPH_BASE}${calendarRoot(mailbox, calendarId)}/events`;
517
+ const res = await outlookFetch(ctx.fetch, "createEvent", url, {
518
+ method: "POST",
519
+ body: JSON.stringify(event)
520
+ });
521
+ return parseGraphResponse(res);
522
+ }
523
+ });
524
+ var createEvent_default = definition4;
525
+ await handleIfScriptMain4(import.meta, definition4, { connectionResolvers });
526
+
527
+ // scripts/createMailFolder.ts
528
+ import { defineTool as defineTool5, handleIfScriptMain as handleIfScriptMain5 } from "@zapier/connectors-sdk";
529
+ import { z as z6 } from "zod";
530
+ var inputSchema5 = z6.object({
531
+ displayName: z6.string().describe("Folder name as shown in Outlook."),
532
+ parentFolderId: z6.string().describe(
533
+ "Set a folder id (or well-known name from listMailFolders) to create the folder as a subfolder of it. Omit to create at the top level."
534
+ ).optional(),
535
+ mailbox: z6.string().describe(
536
+ "Shared-mailbox address (UPN/email) to create the folder in instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
537
+ ).optional()
538
+ }).strict();
539
+ var outputSchema5 = z6.object({
540
+ id: z6.string(),
541
+ displayName: z6.string(),
542
+ parentFolderId: z6.string().optional()
543
+ });
544
+ var definition5 = defineTool5({
545
+ name: "createMailFolder",
546
+ title: "Create Mail Folder",
547
+ description: "Create a mail folder, returning its id. Creates a top-level folder by default, or a subfolder when parentFolderId is set (resolve the parent id via listMailFolders). Use the returned id as folderId/destinationId in other mail tools.",
548
+ inputSchema: inputSchema5,
549
+ outputSchema: outputSchema5,
550
+ annotations: {
551
+ readOnlyHint: false,
552
+ destructiveHint: false,
553
+ idempotentHint: false,
554
+ openWorldHint: true
555
+ },
556
+ connection: "microsoft-outlook",
557
+ run: async (input, ctx) => {
558
+ const root = mailboxRoot(input.mailbox);
559
+ const path = input.parentFolderId !== void 0 ? `${root}/mailFolders/${encodeURIComponent(input.parentFolderId)}/childFolders` : `${root}/mailFolders`;
560
+ const url = `${GRAPH_BASE}${path}`;
561
+ const res = await outlookFetch(ctx.fetch, "createMailFolder", url, {
562
+ method: "POST",
563
+ body: JSON.stringify({ displayName: input.displayName })
564
+ });
565
+ return parseGraphResponse(res);
566
+ }
567
+ });
568
+ var createMailFolder_default = definition5;
569
+ await handleIfScriptMain5(import.meta, definition5, { connectionResolvers });
570
+
571
+ // scripts/createReplyDraft.ts
572
+ import { defineTool as defineTool6, handleIfScriptMain as handleIfScriptMain6 } from "@zapier/connectors-sdk";
573
+ import { z as z7 } from "zod";
574
+ var inputSchema6 = z7.object({
575
+ messageId: z7.string().describe(
576
+ "Id of the message to reply to, from listMessages or getMessage. Opaque and case-sensitive; changes when the message is moved between folders."
577
+ ),
578
+ comment: z7.string().describe(
579
+ "Reply text to seed the draft body, above the quoted original. Plain text or HTML."
580
+ ).optional(),
581
+ replyAll: z7.boolean().describe(
582
+ "Draft a reply to all original recipients (To + Cc) instead of just the sender. Defaults to false."
583
+ ).optional(),
584
+ mailbox: z7.string().describe(
585
+ "Shared-mailbox address (UPN/email) to draft the reply in instead of your own, e.g. team@contoso.com. Requires Send-as/Send-on-behalf delegation. Omit for your own mailbox."
586
+ ).optional()
587
+ }).strict();
588
+ var outputSchema6 = z7.object({
589
+ id: z7.string().describe("Draft reply id \u2014 edit further or pass to sendDraft."),
590
+ subject: z7.string(),
591
+ isDraft: z7.boolean(),
592
+ webLink: z7.string().optional()
593
+ });
594
+ var definition6 = defineTool6({
595
+ name: "createReplyDraft",
596
+ title: "Create Reply Draft",
597
+ description: "Create a draft reply (not sent), pre-populated with the original recipients and quoted body. Set replyAll to draft a reply to all original recipients (To + Cc). Returns the draft's id \u2014 review/edit it, then send with sendDraft. Resolve the message id via listMessages first; to reply and send in one step, use replyToMessage.",
598
+ inputSchema: inputSchema6,
599
+ outputSchema: outputSchema6,
600
+ annotations: {
601
+ readOnlyHint: false,
602
+ destructiveHint: false,
603
+ idempotentHint: false,
604
+ openWorldHint: true
605
+ },
606
+ connection: "microsoft-outlook",
607
+ run: async (input, ctx) => {
608
+ const action = input.replyAll ? "createReplyAll" : "createReply";
609
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
610
+ input.messageId
611
+ )}/${action}`;
612
+ const res = await outlookFetch(ctx.fetch, "createReplyDraft", url, {
613
+ method: "POST",
614
+ body: JSON.stringify(
615
+ input.comment !== void 0 ? { comment: input.comment } : {}
616
+ )
617
+ });
618
+ return parseGraphResponse(res);
619
+ }
620
+ });
621
+ var createReplyDraft_default = definition6;
622
+ await handleIfScriptMain6(import.meta, definition6, { connectionResolvers });
623
+
624
+ // scripts/deleteContact.ts
625
+ import { defineTool as defineTool7, handleIfScriptMain as handleIfScriptMain7 } from "@zapier/connectors-sdk";
626
+ import { z as z8 } from "zod";
627
+ var inputSchema7 = z8.object({
628
+ contactId: z8.string().describe("Contact id from listContacts. Opaque and case-sensitive.")
629
+ }).strict();
630
+ var outputSchema7 = z8.object({
631
+ success: z8.literal(true)
632
+ });
633
+ var definition7 = defineTool7({
634
+ name: "deleteContact",
635
+ title: "Delete Contact",
636
+ description: "Delete a personal contact by id. This cannot be undone \u2014 resolve the id via listContacts and confirm it's the right contact first.",
637
+ inputSchema: inputSchema7,
638
+ outputSchema: outputSchema7,
639
+ annotations: {
640
+ readOnlyHint: false,
641
+ destructiveHint: true,
642
+ idempotentHint: true,
643
+ openWorldHint: true
644
+ },
645
+ connection: "microsoft-outlook",
646
+ run: async (input, ctx) => {
647
+ const url = `${GRAPH_BASE}/me/contacts/${encodeURIComponent(
648
+ input.contactId
649
+ )}`;
650
+ await outlookFetch(ctx.fetch, "deleteContact", url, { method: "DELETE" });
651
+ return { success: true };
652
+ }
653
+ });
654
+ var deleteContact_default = definition7;
655
+ await handleIfScriptMain7(import.meta, definition7, { connectionResolvers });
656
+
657
+ // scripts/deleteEvent.ts
658
+ import { defineTool as defineTool8, handleIfScriptMain as handleIfScriptMain8 } from "@zapier/connectors-sdk";
659
+ import { z as z9 } from "zod";
660
+ var inputSchema8 = z9.object({
661
+ eventId: z9.string().describe(
662
+ "Opaque event id from listEvents, listCalendarView, or getEvent."
663
+ ),
664
+ mailbox: z9.string().describe(
665
+ "Shared-mailbox address (UPN/email) holding the event instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
666
+ ).optional(),
667
+ calendarId: z9.string().describe(
668
+ "Target a specific calendar (id from listCalendars). Omit to use the default calendar."
669
+ ).optional()
670
+ }).strict();
671
+ var outputSchema8 = z9.object({
672
+ success: z9.literal(true)
673
+ });
674
+ var definition8 = defineTool8({
675
+ name: "deleteEvent",
676
+ title: "Delete Event",
677
+ description: "Delete (cancel) a calendar event. For events you organize, attendees are notified of the cancellation \u2014 this is not trivially reversible.",
678
+ inputSchema: inputSchema8,
679
+ outputSchema: outputSchema8,
680
+ annotations: {
681
+ readOnlyHint: false,
682
+ destructiveHint: true,
683
+ idempotentHint: true,
684
+ openWorldHint: true
685
+ },
686
+ connection: "microsoft-outlook",
687
+ run: async (input, ctx) => {
688
+ const url = `${GRAPH_BASE}${calendarRoot(input.mailbox, input.calendarId)}/events/${encodeURIComponent(
689
+ input.eventId
690
+ )}`;
691
+ await outlookFetch(ctx.fetch, "deleteEvent", url, { method: "DELETE" });
692
+ return { success: true };
693
+ }
694
+ });
695
+ var deleteEvent_default = definition8;
696
+ await handleIfScriptMain8(import.meta, definition8, { connectionResolvers });
697
+
698
+ // scripts/deleteMessage.ts
699
+ import { defineTool as defineTool9, handleIfScriptMain as handleIfScriptMain9 } from "@zapier/connectors-sdk";
700
+ import { z as z10 } from "zod";
701
+ var inputSchema9 = z10.object({
702
+ messageId: z10.string().describe(
703
+ "Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders."
704
+ ),
705
+ mailbox: z10.string().describe(
706
+ "Shared-mailbox address (UPN/email) to delete from instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
707
+ ).optional()
708
+ }).strict();
709
+ var outputSchema9 = z10.object({
710
+ success: z10.literal(true)
711
+ });
712
+ var definition9 = defineTool9({
713
+ name: "deleteMessage",
714
+ title: "Delete Message",
715
+ description: "Soft-delete a message: it moves to the Deleted Items folder and is reversible (move it back out to restore). Resolve the message id via listMessages first.",
716
+ inputSchema: inputSchema9,
717
+ outputSchema: outputSchema9,
718
+ annotations: {
719
+ readOnlyHint: false,
720
+ destructiveHint: false,
721
+ idempotentHint: true,
722
+ openWorldHint: true
723
+ },
724
+ connection: "microsoft-outlook",
725
+ run: async (input, ctx) => {
726
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
727
+ input.messageId
728
+ )}`;
729
+ await outlookFetch(ctx.fetch, "deleteMessage", url, {
730
+ method: "DELETE"
731
+ });
732
+ return { success: true };
733
+ }
734
+ });
735
+ var deleteMessage_default = definition9;
736
+ await handleIfScriptMain9(import.meta, definition9, { connectionResolvers });
737
+
738
+ // scripts/forwardMessage.ts
739
+ import { defineTool as defineTool10, handleIfScriptMain as handleIfScriptMain10 } from "@zapier/connectors-sdk";
740
+ import { z as z11 } from "zod";
741
+ var inputSchema10 = z11.object({
742
+ messageId: z11.string().describe(
743
+ "Id of the message to forward, from listMessages or getMessage. Opaque and case-sensitive; changes when the message is moved between folders."
744
+ ),
745
+ toRecipients: z11.array(recipientInputSchema).min(1).describe(
746
+ 'Who to forward the message to, e.g. [{ "emailAddress": { "address": "jane@contoso.com" } }].'
747
+ ),
748
+ comment: z11.string().describe(
749
+ "Note prepended above the forwarded original. Plain text or HTML."
750
+ ).optional(),
751
+ mailbox: z11.string().describe(
752
+ "Shared-mailbox address (UPN/email) to forward from instead of your own, e.g. team@contoso.com. Requires Send-as/Send-on-behalf delegation. Omit to forward as yourself."
753
+ ).optional()
754
+ }).strict();
755
+ var outputSchema10 = z11.object({
756
+ success: z11.literal(true)
757
+ });
758
+ var definition10 = defineTool10({
759
+ name: "forwardMessage",
760
+ title: "Forward Message",
761
+ description: "Forward a message to new recipients and send immediately, quoting the original. Returns only a success flag (202 accepted, no id). Resolve the message id via listMessages first.",
762
+ inputSchema: inputSchema10,
763
+ outputSchema: outputSchema10,
764
+ annotations: {
765
+ readOnlyHint: false,
766
+ destructiveHint: false,
767
+ idempotentHint: false,
768
+ openWorldHint: true
769
+ },
770
+ connection: "microsoft-outlook",
771
+ run: async (input, ctx) => {
772
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
773
+ input.messageId
774
+ )}/forward`;
775
+ const body = {
776
+ toRecipients: input.toRecipients,
777
+ ...input.comment !== void 0 ? { comment: input.comment } : {}
778
+ };
779
+ await outlookFetch(ctx.fetch, "forwardMessage", url, {
780
+ method: "POST",
781
+ body: JSON.stringify(body)
782
+ });
783
+ return { success: true };
784
+ }
785
+ });
786
+ var forwardMessage_default = definition10;
787
+ await handleIfScriptMain10(import.meta, definition10, { connectionResolvers });
788
+
789
+ // scripts/getAttachment.ts
790
+ import { defineTool as defineTool11, handleIfScriptMain as handleIfScriptMain11 } from "@zapier/connectors-sdk";
791
+ import { z as z12 } from "zod";
792
+ var inputSchema11 = z12.object({
793
+ messageId: z12.string().describe(
794
+ "Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders."
795
+ ),
796
+ attachmentId: z12.string().describe("Attachment id from listAttachments."),
797
+ mailbox: z12.string().describe(
798
+ "Shared-mailbox address (UPN/email) to read from instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
799
+ ).optional()
800
+ }).strict();
801
+ var outputSchema11 = attachmentSchema;
802
+ var definition11 = defineTool11({
803
+ name: "getAttachment",
804
+ title: "Get Attachment",
805
+ description: "Retrieve one attachment by id, including its base64 contentBytes. Resolve the attachmentId via listAttachments first. contentBytes is present only for file attachments \u2014 item and reference attachments carry no inline bytes.",
806
+ inputSchema: inputSchema11,
807
+ outputSchema: outputSchema11,
808
+ annotations: {
809
+ readOnlyHint: true,
810
+ destructiveHint: false,
811
+ idempotentHint: true,
812
+ openWorldHint: true
813
+ },
814
+ connection: "microsoft-outlook",
815
+ run: async (input, ctx) => {
816
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
817
+ input.messageId
818
+ )}/attachments/${encodeURIComponent(input.attachmentId)}`;
819
+ const res = await outlookFetch(ctx.fetch, "getAttachment", url);
820
+ return normalizeAttachment(
821
+ await parseGraphResponse(res)
822
+ );
823
+ }
824
+ });
825
+ var getAttachment_default = definition11;
826
+ await handleIfScriptMain11(import.meta, definition11, { connectionResolvers });
827
+
828
+ // scripts/getContact.ts
829
+ import { defineTool as defineTool12, handleIfScriptMain as handleIfScriptMain12 } from "@zapier/connectors-sdk";
830
+ import { z as z13 } from "zod";
831
+ var inputSchema12 = z13.object({
832
+ contactId: z13.string().describe("Contact id from listContacts. Opaque and case-sensitive.")
833
+ }).strict();
834
+ var outputSchema12 = contactSchema;
835
+ var definition12 = defineTool12({
836
+ name: "getContact",
837
+ title: "Get Contact",
838
+ description: "Retrieve a single personal contact by id, including names, company, email addresses, and phone numbers. Resolve the id via listContacts first. The resolver getter for updateContact.",
839
+ inputSchema: inputSchema12,
840
+ outputSchema: outputSchema12,
841
+ annotations: {
842
+ readOnlyHint: true,
843
+ destructiveHint: false,
844
+ idempotentHint: true,
845
+ openWorldHint: true
846
+ },
847
+ connection: "microsoft-outlook",
848
+ run: async (input, ctx) => {
849
+ const url = `${GRAPH_BASE}/me/contacts/${encodeURIComponent(
850
+ input.contactId
851
+ )}`;
852
+ const res = await outlookFetch(ctx.fetch, "getContact", url);
853
+ return parseGraphResponse(res);
854
+ }
855
+ });
856
+ var getContact_default = definition12;
857
+ await handleIfScriptMain12(import.meta, definition12, { connectionResolvers });
858
+
859
+ // scripts/getEvent.ts
860
+ import { defineTool as defineTool13, handleIfScriptMain as handleIfScriptMain13 } from "@zapier/connectors-sdk";
861
+ import { z as z14 } from "zod";
862
+ var inputSchema13 = z14.object({
863
+ eventId: z14.string().describe(
864
+ "Opaque event id from listEvents, listCalendarView, or getEvent."
865
+ ),
866
+ mailbox: z14.string().describe(
867
+ "Shared-mailbox address (UPN/email) to read from instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
868
+ ).optional(),
869
+ calendarId: z14.string().describe(
870
+ "Target a specific calendar (id from listCalendars). Omit to use the default calendar."
871
+ ).optional()
872
+ }).strict();
873
+ var outputSchema13 = eventSchema;
874
+ var definition13 = defineTool13({
875
+ name: "getEvent",
876
+ title: "Get Event",
877
+ description: "Retrieve a single calendar event by id, including attendees, body, and online-meeting details. Resolve the id via listEvents or listCalendarView first. Use this to read the current state before updateEvent (read-modify-write \u2014 e.g. fetch the attendees, append, then update).",
878
+ inputSchema: inputSchema13,
879
+ outputSchema: outputSchema13,
880
+ annotations: {
881
+ readOnlyHint: true,
882
+ destructiveHint: false,
883
+ idempotentHint: true,
884
+ openWorldHint: true
885
+ },
886
+ connection: "microsoft-outlook",
887
+ run: async (input, ctx) => {
888
+ const url = `${GRAPH_BASE}${calendarRoot(input.mailbox, input.calendarId)}/events/${encodeURIComponent(
889
+ input.eventId
890
+ )}`;
891
+ const res = await outlookFetch(ctx.fetch, "getEvent", url);
892
+ return parseGraphResponse(res);
893
+ }
894
+ });
895
+ var getEvent_default = definition13;
896
+ await handleIfScriptMain13(import.meta, definition13, { connectionResolvers });
897
+
898
+ // scripts/getMe.ts
899
+ import { defineTool as defineTool14, handleIfScriptMain as handleIfScriptMain14 } from "@zapier/connectors-sdk";
900
+ import { z as z15 } from "zod";
901
+ var inputSchema14 = z15.object({}).strict();
902
+ var outputSchema14 = z15.object({
903
+ id: z15.string(),
904
+ displayName: z15.string().optional(),
905
+ mail: z15.string().optional(),
906
+ userPrincipalName: z15.string(),
907
+ jobTitle: z15.string().optional(),
908
+ mobilePhone: z15.string().optional()
909
+ });
910
+ var definition14 = defineTool14({
911
+ name: "getMe",
912
+ title: "Get Me",
913
+ description: `Retrieve the signed-in user's profile \u2014 id, displayName, mail, and userPrincipalName. Doubles as the auth probe (a 200 confirms the connection works). Call this first to resolve "my email" before composing or filtering mail.`,
914
+ inputSchema: inputSchema14,
915
+ outputSchema: outputSchema14,
916
+ annotations: {
917
+ readOnlyHint: true,
918
+ destructiveHint: false,
919
+ idempotentHint: true,
920
+ openWorldHint: true
921
+ },
922
+ connection: "microsoft-outlook",
923
+ run: async (_input, ctx) => {
924
+ const url = `${GRAPH_BASE}/me`;
925
+ const res = await outlookFetch(ctx.fetch, "getMe", url);
926
+ return parseGraphResponse(res);
927
+ }
928
+ });
929
+ var getMe_default = definition14;
930
+ await handleIfScriptMain14(import.meta, definition14, { connectionResolvers });
931
+
932
+ // scripts/getMessage.ts
933
+ import { defineTool as defineTool15, handleIfScriptMain as handleIfScriptMain15 } from "@zapier/connectors-sdk";
934
+ import { z as z16 } from "zod";
935
+ var inputSchema15 = z16.object({
936
+ messageId: z16.string().describe(
937
+ "Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders."
938
+ ),
939
+ bodyContentType: z16.enum(["text", "html"]).describe(
940
+ "Format for the returned body. Defaults to text (smaller, keeps visible URLs); pass html to preserve formatting."
941
+ ).optional(),
942
+ mailbox: z16.string().describe(
943
+ "Shared-mailbox address (UPN/email) to read from instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
944
+ ).optional()
945
+ }).strict();
946
+ var outputSchema15 = messageSchema;
947
+ var definition15 = defineTool15({
948
+ name: "getMessage",
949
+ title: "Get Message",
950
+ description: "Retrieve a single message by id, including its full body, recipient lists, flag, and categories. Resolve the id via listMessages first. The body is returned as plain text by default; pass bodyContentType: html for the original markup.",
951
+ inputSchema: inputSchema15,
952
+ outputSchema: outputSchema15,
953
+ annotations: {
954
+ readOnlyHint: true,
955
+ destructiveHint: false,
956
+ idempotentHint: true,
957
+ openWorldHint: true
958
+ },
959
+ connection: "microsoft-outlook",
960
+ run: async (input, ctx) => {
961
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
962
+ input.messageId
963
+ )}`;
964
+ const res = await outlookFetch(ctx.fetch, "getMessage", url, {
965
+ headers: {
966
+ Prefer: `outlook.body-content-type="${input.bodyContentType ?? "text"}"`
967
+ }
968
+ });
969
+ return parseGraphResponse(res);
970
+ }
971
+ });
972
+ var getMessage_default = definition15;
973
+ await handleIfScriptMain15(import.meta, definition15, { connectionResolvers });
974
+
975
+ // scripts/listAttachments.ts
976
+ import { defineTool as defineTool16, handleIfScriptMain as handleIfScriptMain16 } from "@zapier/connectors-sdk";
977
+ import { z as z17 } from "zod";
978
+ var inputSchema16 = z17.object({
979
+ messageId: z17.string().describe(
980
+ "Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders."
981
+ ),
982
+ mailbox: z17.string().describe(
983
+ "Shared-mailbox address (UPN/email) to read from instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
984
+ ).optional(),
985
+ limit: z17.number().int().gte(1).describe(
986
+ "Attachments per page. Defaults to 20 when omitted; pass a value when you need a specific number."
987
+ ).optional(),
988
+ cursor: z17.string().describe(
989
+ "Pagination cursor from a previous response's next_cursor. Omit for the first page."
990
+ ).optional()
991
+ }).strict();
992
+ var outputSchema16 = z17.object({
993
+ items: z17.array(attachmentListItemSchema),
994
+ next_cursor: z17.string().describe("Pass as cursor to fetch the next page. Absent on the last page.").optional()
995
+ });
996
+ var definition16 = defineTool16({
997
+ name: "listAttachments",
998
+ title: "List Attachments",
999
+ description: "List the attachments on a message \u2014 name, content type, size, kind, and inline flag. Resolve the messageId via listMessages first, then use getAttachment to download a specific one's bytes. A message's hasAttachments is false when it has only inline attachments, so still call this to check for them.",
1000
+ inputSchema: inputSchema16,
1001
+ outputSchema: outputSchema16,
1002
+ annotations: {
1003
+ readOnlyHint: true,
1004
+ destructiveHint: false,
1005
+ idempotentHint: true,
1006
+ openWorldHint: true
1007
+ },
1008
+ connection: "microsoft-outlook",
1009
+ run: async (input, ctx) => {
1010
+ let url;
1011
+ if (input.cursor !== void 0) {
1012
+ url = input.cursor;
1013
+ } else {
1014
+ const path = `${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
1015
+ input.messageId
1016
+ )}/attachments`;
1017
+ const query = buildListQuery({ limit: input.limit ?? 20 });
1018
+ url = `${GRAPH_BASE}${path}${query}`;
1019
+ }
1020
+ const res = await outlookFetch(ctx.fetch, "listAttachments", url);
1021
+ const result = toListResult(await res.json());
1022
+ return {
1023
+ ...result,
1024
+ items: result.items.map((item) => normalizeAttachment(item))
1025
+ };
1026
+ }
1027
+ });
1028
+ var listAttachments_default = definition16;
1029
+ await handleIfScriptMain16(import.meta, definition16, { connectionResolvers });
1030
+
1031
+ // scripts/listCalendars.ts
1032
+ import { defineTool as defineTool17, handleIfScriptMain as handleIfScriptMain17 } from "@zapier/connectors-sdk";
1033
+ import { z as z18 } from "zod";
1034
+ var inputSchema17 = z18.object({
1035
+ mailbox: z18.string().describe(
1036
+ "Shared-mailbox address (UPN/email) to read instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
1037
+ ).optional(),
1038
+ limit: z18.number().int().gte(1).describe(
1039
+ "Calendars per page. Defaults to 20 when omitted; pass a value when you need a specific number of results."
1040
+ ).optional(),
1041
+ cursor: z18.string().describe(
1042
+ "Pagination cursor from a previous response's next_cursor. Omit for the first page."
1043
+ ).optional()
1044
+ }).strict();
1045
+ var outputSchema17 = z18.object({
1046
+ items: z18.array(
1047
+ z18.object({
1048
+ id: z18.string(),
1049
+ name: z18.string(),
1050
+ isDefaultCalendar: z18.boolean().optional(),
1051
+ canEdit: z18.boolean().optional()
1052
+ })
1053
+ ),
1054
+ next_cursor: z18.string().describe("Pass as cursor to fetch the next page. Absent on the last page.").optional()
1055
+ });
1056
+ var definition17 = defineTool17({
1057
+ name: "listCalendars",
1058
+ title: "List Calendars",
1059
+ description: "List the available calendars in a mailbox. The entry point for resolving a calendarId to pass to the event tools (listEvents, listCalendarView, createEvent, ...); omit calendarId on those tools to use the default calendar.",
1060
+ inputSchema: inputSchema17,
1061
+ outputSchema: outputSchema17,
1062
+ annotations: {
1063
+ readOnlyHint: true,
1064
+ destructiveHint: false,
1065
+ idempotentHint: true,
1066
+ openWorldHint: true
1067
+ },
1068
+ connection: "microsoft-outlook",
1069
+ run: async (input, ctx) => {
1070
+ let url;
1071
+ if (input.cursor !== void 0) {
1072
+ url = input.cursor;
1073
+ } else {
1074
+ const query = buildListQuery({ limit: input.limit ?? 20 });
1075
+ url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/calendars${query}`;
1076
+ }
1077
+ const res = await outlookFetch(ctx.fetch, "listCalendars", url);
1078
+ return toListResult(await res.json());
1079
+ }
1080
+ });
1081
+ var listCalendars_default = definition17;
1082
+ await handleIfScriptMain17(import.meta, definition17, { connectionResolvers });
1083
+
1084
+ // scripts/listCalendarView.ts
1085
+ import { defineTool as defineTool18, handleIfScriptMain as handleIfScriptMain18 } from "@zapier/connectors-sdk";
1086
+ import { z as z19 } from "zod";
1087
+ var inputSchema18 = z19.object({
1088
+ startDateTime: z19.string().describe(
1089
+ 'Window start, ISO 8601 (e.g. "2026-07-01T00:00:00"). Interpreted as UTC unless it carries an offset.'
1090
+ ),
1091
+ endDateTime: z19.string().describe(
1092
+ "Window end, ISO 8601. Interpreted as UTC unless it carries an offset."
1093
+ ),
1094
+ mailbox: z19.string().describe(
1095
+ "Shared-mailbox address (UPN/email) to read instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
1096
+ ).optional(),
1097
+ calendarId: z19.string().describe(
1098
+ "Target a specific calendar (id from listCalendars). Omit to use the default calendar."
1099
+ ).optional(),
1100
+ limit: z19.number().int().gte(1).describe(
1101
+ "Events per page. Defaults to 20 when omitted; pass a value when you need a specific number of results."
1102
+ ).optional(),
1103
+ cursor: z19.string().describe(
1104
+ "Pagination cursor from a previous response's next_cursor. Omit for the first page."
1105
+ ).optional()
1106
+ }).strict();
1107
+ var outputSchema18 = z19.object({
1108
+ items: z19.array(eventListItemSchema),
1109
+ next_cursor: z19.string().describe("Pass as cursor to fetch the next page. Absent on the last page.").optional()
1110
+ });
1111
+ var definition18 = defineTool18({
1112
+ name: "listCalendarView",
1113
+ title: "List Calendar View",
1114
+ description: `The primary "what's on my calendar" tool: list everything occurring between startDateTime and endDateTime, expanding recurring series into their individual occurrences. Targets the default calendar unless calendarId is set.`,
1115
+ inputSchema: inputSchema18,
1116
+ outputSchema: outputSchema18,
1117
+ annotations: {
1118
+ readOnlyHint: true,
1119
+ destructiveHint: false,
1120
+ idempotentHint: true,
1121
+ openWorldHint: true
1122
+ },
1123
+ connection: "microsoft-outlook",
1124
+ run: async (input, ctx) => {
1125
+ let url;
1126
+ if (input.cursor !== void 0) {
1127
+ url = input.cursor;
1128
+ } else {
1129
+ const sp = new URLSearchParams();
1130
+ sp.set("startDateTime", input.startDateTime);
1131
+ sp.set("endDateTime", input.endDateTime);
1132
+ sp.set("$top", String(input.limit ?? 20));
1133
+ url = `${GRAPH_BASE}${calendarRoot(input.mailbox, input.calendarId)}/calendarView?${sp.toString()}`;
1134
+ }
1135
+ const res = await outlookFetch(ctx.fetch, "listCalendarView", url);
1136
+ return toListResult(await res.json());
1137
+ }
1138
+ });
1139
+ var listCalendarView_default = definition18;
1140
+ await handleIfScriptMain18(import.meta, definition18, { connectionResolvers });
1141
+
1142
+ // scripts/listCategories.ts
1143
+ import { defineTool as defineTool19, handleIfScriptMain as handleIfScriptMain19 } from "@zapier/connectors-sdk";
1144
+ import { z as z20 } from "zod";
1145
+ var inputSchema19 = z20.object({}).strict();
1146
+ var outputSchema19 = z20.object({
1147
+ items: z20.array(
1148
+ z20.object({
1149
+ id: z20.string().optional(),
1150
+ displayName: z20.string(),
1151
+ color: z20.string().describe('Preset color name, e.g. "preset0".').optional()
1152
+ })
1153
+ )
1154
+ });
1155
+ var definition19 = defineTool19({
1156
+ name: "listCategories",
1157
+ title: "List Categories",
1158
+ description: "List the signed-in user's category names and colors. A discovery tool for the valid category names passed to updateMessage or createEvent \u2014 a category's color comes from the user's master list (you apply a category by its displayName). Only your own categories (no mailbox option).",
1159
+ inputSchema: inputSchema19,
1160
+ outputSchema: outputSchema19,
1161
+ annotations: {
1162
+ readOnlyHint: true,
1163
+ destructiveHint: false,
1164
+ idempotentHint: true,
1165
+ openWorldHint: true
1166
+ },
1167
+ connection: "microsoft-outlook",
1168
+ run: async (_input, ctx) => {
1169
+ const url = `${GRAPH_BASE}/me/outlook/masterCategories`;
1170
+ const res = await outlookFetch(ctx.fetch, "listCategories", url);
1171
+ const body = await res.json();
1172
+ return { items: (body.value ?? []).map((c) => stripNullsDeep(c)) };
1173
+ }
1174
+ });
1175
+ var listCategories_default = definition19;
1176
+ await handleIfScriptMain19(import.meta, definition19, { connectionResolvers });
1177
+
1178
+ // scripts/listContacts.ts
1179
+ import { defineTool as defineTool20, handleIfScriptMain as handleIfScriptMain20 } from "@zapier/connectors-sdk";
1180
+ import { z as z21 } from "zod";
1181
+ var inputSchema20 = z21.object({
1182
+ filter: z21.string().describe(
1183
+ `OData $filter predicate. Only the email-match form is supported server-side, e.g. "emailAddresses/any(a:a/address eq 'jane@contoso.com')". Name search is NOT filterable \u2014 list and filter the returned results client-side instead. Omit to list all contacts.`
1184
+ ).optional(),
1185
+ limit: z21.number().int().gte(1).describe(
1186
+ "Contacts per page. Defaults to 20 when omitted; pass a value when you need a specific number of results."
1187
+ ).optional(),
1188
+ cursor: z21.string().describe(
1189
+ "Pagination cursor from a previous response's next_cursor. Omit for the first page."
1190
+ ).optional()
1191
+ }).strict();
1192
+ var outputSchema20 = z21.object({
1193
+ items: z21.array(contactSchema),
1194
+ next_cursor: z21.string().describe("Pass as cursor to fetch the next page. Absent on the last page.").optional()
1195
+ });
1196
+ var definition20 = defineTool20({
1197
+ name: "listContacts",
1198
+ title: "List Contacts",
1199
+ description: `List or search the user's personal contacts. Use filter to match by email, e.g. "emailAddresses/any(a:a/address eq 'jane@contoso.com')"; name search isn't filterable server-side, so list and match the returned results yourself. The entry point for resolving a contact id before getContact/updateContact/deleteContact.`,
1200
+ inputSchema: inputSchema20,
1201
+ outputSchema: outputSchema20,
1202
+ annotations: {
1203
+ readOnlyHint: true,
1204
+ destructiveHint: false,
1205
+ idempotentHint: true,
1206
+ openWorldHint: true
1207
+ },
1208
+ connection: "microsoft-outlook",
1209
+ run: async (input, ctx) => {
1210
+ let url;
1211
+ if (input.cursor !== void 0) {
1212
+ url = input.cursor;
1213
+ } else {
1214
+ const query = buildListQuery({
1215
+ limit: input.limit ?? 20,
1216
+ filter: input.filter
1217
+ });
1218
+ url = `${GRAPH_BASE}/me/contacts${query}`;
1219
+ }
1220
+ const res = await outlookFetch(ctx.fetch, "listContacts", url);
1221
+ return toListResult(await res.json());
1222
+ }
1223
+ });
1224
+ var listContacts_default = definition20;
1225
+ await handleIfScriptMain20(import.meta, definition20, { connectionResolvers });
1226
+
1227
+ // scripts/listEvents.ts
1228
+ import { defineTool as defineTool21, handleIfScriptMain as handleIfScriptMain21 } from "@zapier/connectors-sdk";
1229
+ import { z as z22 } from "zod";
1230
+ var inputSchema21 = z22.object({
1231
+ filter: z22.string().describe(
1232
+ `OData $filter predicate for exact matches, e.g. "subject eq 'Standup'" or "showAs eq 'busy'". Omit to list all events.`
1233
+ ).optional(),
1234
+ mailbox: z22.string().describe(
1235
+ "Shared-mailbox address (UPN/email) to read instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
1236
+ ).optional(),
1237
+ calendarId: z22.string().describe(
1238
+ "Target a specific calendar (id from listCalendars). Omit to use the default calendar."
1239
+ ).optional(),
1240
+ limit: z22.number().int().gte(1).describe(
1241
+ "Events per page. Defaults to 20 when omitted; pass a value when you need a specific number of results."
1242
+ ).optional(),
1243
+ cursor: z22.string().describe(
1244
+ "Pagination cursor from a previous response's next_cursor. Omit for the first page."
1245
+ ).optional()
1246
+ }).strict();
1247
+ var outputSchema21 = z22.object({
1248
+ items: z22.array(eventListItemSchema),
1249
+ next_cursor: z22.string().describe("Pass as cursor to fetch the next page. Absent on the last page.").optional()
1250
+ });
1251
+ var definition21 = defineTool21({
1252
+ name: "listEvents",
1253
+ title: "List Events",
1254
+ description: "List a calendar's events: single events plus recurring SERIES MASTERS (the recurrence definition, not expanded occurrences). Use filter for exact predicates. To see what actually occurs within a date range \u2014 including each occurrence of a recurring series \u2014 use listCalendarView instead.",
1255
+ inputSchema: inputSchema21,
1256
+ outputSchema: outputSchema21,
1257
+ annotations: {
1258
+ readOnlyHint: true,
1259
+ destructiveHint: false,
1260
+ idempotentHint: true,
1261
+ openWorldHint: true
1262
+ },
1263
+ connection: "microsoft-outlook",
1264
+ run: async (input, ctx) => {
1265
+ let url;
1266
+ if (input.cursor !== void 0) {
1267
+ url = input.cursor;
1268
+ } else {
1269
+ const query = buildListQuery({
1270
+ limit: input.limit ?? 20,
1271
+ filter: input.filter
1272
+ });
1273
+ url = `${GRAPH_BASE}${calendarRoot(input.mailbox, input.calendarId)}/events${query}`;
1274
+ }
1275
+ const res = await outlookFetch(ctx.fetch, "listEvents", url);
1276
+ return toListResult(await res.json());
1277
+ }
1278
+ });
1279
+ var listEvents_default = definition21;
1280
+ await handleIfScriptMain21(import.meta, definition21, { connectionResolvers });
1281
+
1282
+ // scripts/listMailFolders.ts
1283
+ import { defineTool as defineTool22, handleIfScriptMain as handleIfScriptMain22 } from "@zapier/connectors-sdk";
1284
+ import { z as z23 } from "zod";
1285
+ var inputSchema22 = z23.object({
1286
+ parentFolderId: z23.string().describe(
1287
+ "Omit to list top-level folders. Set a folder id (from a previous call) or a well-known name (inbox, drafts, sentitems, deleteditems, archive, junkemail) to list that folder's subfolders."
1288
+ ).optional(),
1289
+ mailbox: z23.string().describe(
1290
+ "Shared-mailbox address (UPN/email) to read instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
1291
+ ).optional(),
1292
+ limit: z23.number().int().gte(1).describe(
1293
+ "Folders per page. Defaults to 20 when omitted; pass a value when you need a specific number."
1294
+ ).optional(),
1295
+ cursor: z23.string().describe(
1296
+ "Pagination cursor from a previous response's next_cursor. Omit for the first page."
1297
+ ).optional()
1298
+ }).strict();
1299
+ var outputSchema22 = z23.object({
1300
+ items: z23.array(
1301
+ z23.object({
1302
+ id: z23.string(),
1303
+ displayName: z23.string(),
1304
+ parentFolderId: z23.string().optional(),
1305
+ childFolderCount: z23.number().optional(),
1306
+ unreadItemCount: z23.number().optional(),
1307
+ totalItemCount: z23.number().optional()
1308
+ })
1309
+ ),
1310
+ next_cursor: z23.string().describe("Pass as cursor to fetch the next page. Absent on the last page.").optional()
1311
+ });
1312
+ var definition22 = defineTool22({
1313
+ name: "listMailFolders",
1314
+ title: "List Mail Folders",
1315
+ description: "List mail folders. Returns top-level folders by default; pass parentFolderId to list a folder's subfolders. The entry point for resolving a folder id to pass as folderId to listMessages or destinationId to moveMessage.",
1316
+ inputSchema: inputSchema22,
1317
+ outputSchema: outputSchema22,
1318
+ annotations: {
1319
+ readOnlyHint: true,
1320
+ destructiveHint: false,
1321
+ idempotentHint: true,
1322
+ openWorldHint: true
1323
+ },
1324
+ connection: "microsoft-outlook",
1325
+ run: async (input, ctx) => {
1326
+ let url;
1327
+ if (input.cursor !== void 0) {
1328
+ url = input.cursor;
1329
+ } else {
1330
+ const root = mailboxRoot(input.mailbox);
1331
+ const path = input.parentFolderId !== void 0 ? `${root}/mailFolders/${encodeURIComponent(input.parentFolderId)}/childFolders` : `${root}/mailFolders`;
1332
+ const query = buildListQuery({ limit: input.limit ?? 20 });
1333
+ url = `${GRAPH_BASE}${path}${query}`;
1334
+ }
1335
+ const res = await outlookFetch(ctx.fetch, "listMailFolders", url);
1336
+ return toListResult(await res.json());
1337
+ }
1338
+ });
1339
+ var listMailFolders_default = definition22;
1340
+ await handleIfScriptMain22(import.meta, definition22, { connectionResolvers });
1341
+
1342
+ // scripts/listMessages.ts
1343
+ import { defineTool as defineTool23, handleIfScriptMain as handleIfScriptMain23 } from "@zapier/connectors-sdk";
1344
+ import { z as z24 } from "zod";
1345
+ var inputSchema23 = z24.object({
1346
+ folderId: z24.string().describe(
1347
+ "Restrict to one folder: a folder id from listMailFolders, or a well-known name (inbox, drafts, sentitems, deleteditems, archive, junkemail). Omit to list across all folders."
1348
+ ).optional(),
1349
+ search: z24.string().describe(
1350
+ 'Full-text KQL search over the default from/subject/body properties, e.g. "subject:invoice from:acme". Results are sorted by the date and time sent. Omit to list newest-first.'
1351
+ ).optional(),
1352
+ filter: z24.string().describe(
1353
+ `OData $filter predicate for exact matches, e.g. "isRead eq false" or "importance eq 'high'". Use search for free-text instead.`
1354
+ ).optional(),
1355
+ mailbox: z24.string().describe(
1356
+ "Shared-mailbox address (UPN/email) to read instead of your own, e.g. team@contoso.com. Requires shared-mailbox delegation. Omit for your own mailbox."
1357
+ ).optional(),
1358
+ limit: z24.number().int().gte(1).describe(
1359
+ "Messages per page. Defaults to 10 when omitted; pass a value when you need a specific number of results."
1360
+ ).optional(),
1361
+ cursor: z24.string().describe(
1362
+ "Pagination cursor from a previous response's next_cursor. Omit for the first page."
1363
+ ).optional()
1364
+ }).strict();
1365
+ var outputSchema23 = z24.object({
1366
+ items: z24.array(messageListItemSchema),
1367
+ next_cursor: z24.string().describe("Pass as cursor to fetch the next page. Absent on the last page.").optional()
1368
+ });
1369
+ var definition23 = defineTool23({
1370
+ name: "listMessages",
1371
+ title: "List Messages",
1372
+ description: 'Search or list mailbox messages. Listing is newest-first; search results (KQL, e.g. "subject:invoice from:acme") are ordered by sent date, not recency. Scope with folderId; exact-match with filter. The entry point for resolving a message id before getMessage/updateMessage/moveMessage.',
1373
+ inputSchema: inputSchema23,
1374
+ outputSchema: outputSchema23,
1375
+ annotations: {
1376
+ readOnlyHint: true,
1377
+ destructiveHint: false,
1378
+ idempotentHint: true,
1379
+ openWorldHint: true
1380
+ },
1381
+ connection: "microsoft-outlook",
1382
+ run: async (input, ctx) => {
1383
+ let url;
1384
+ if (input.cursor !== void 0) {
1385
+ url = input.cursor;
1386
+ } else {
1387
+ const root = mailboxRoot(input.mailbox);
1388
+ const path = input.folderId !== void 0 ? `${root}/mailFolders/${encodeURIComponent(input.folderId)}/messages` : `${root}/messages`;
1389
+ const query = buildListQuery({
1390
+ limit: input.limit ?? 10,
1391
+ search: input.search,
1392
+ filter: input.filter
1393
+ });
1394
+ url = `${GRAPH_BASE}${path}${query}`;
1395
+ }
1396
+ const res = await outlookFetch(ctx.fetch, "listMessages", url);
1397
+ return toListResult(await res.json());
1398
+ }
1399
+ });
1400
+ var listMessages_default = definition23;
1401
+ await handleIfScriptMain23(import.meta, definition23, { connectionResolvers });
1402
+
1403
+ // scripts/moveMessage.ts
1404
+ import { defineTool as defineTool24, handleIfScriptMain as handleIfScriptMain24 } from "@zapier/connectors-sdk";
1405
+ import { z as z25 } from "zod";
1406
+ var inputSchema24 = z25.object({
1407
+ messageId: z25.string().describe(
1408
+ "Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders."
1409
+ ),
1410
+ destinationId: z25.string().describe(
1411
+ "Target folder: a folder id from listMailFolders, or a well-known name (inbox, archive, deleteditems, junkemail, drafts, sentitems)."
1412
+ ),
1413
+ mailbox: z25.string().describe(
1414
+ "Shared-mailbox address (UPN/email) to move within instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
1415
+ ).optional()
1416
+ }).strict();
1417
+ var outputSchema24 = z25.object({
1418
+ id: z25.string(),
1419
+ parentFolderId: z25.string(),
1420
+ subject: z25.string()
1421
+ });
1422
+ var definition24 = defineTool24({
1423
+ name: "moveMessage",
1424
+ title: "Move Message",
1425
+ description: "Move a message into another folder. Resolve the message id via listMessages first. IMPORTANT: the message id CHANGES after a move \u2014 use the id from this response for any follow-up call, not the id you passed in.",
1426
+ inputSchema: inputSchema24,
1427
+ outputSchema: outputSchema24,
1428
+ annotations: {
1429
+ readOnlyHint: false,
1430
+ destructiveHint: false,
1431
+ idempotentHint: false,
1432
+ openWorldHint: true
1433
+ },
1434
+ connection: "microsoft-outlook",
1435
+ run: async (input, ctx) => {
1436
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
1437
+ input.messageId
1438
+ )}/move`;
1439
+ const res = await outlookFetch(ctx.fetch, "moveMessage", url, {
1440
+ method: "POST",
1441
+ body: JSON.stringify({ destinationId: input.destinationId })
1442
+ });
1443
+ return parseGraphResponse(res);
1444
+ }
1445
+ });
1446
+ var moveMessage_default = definition24;
1447
+ await handleIfScriptMain24(import.meta, definition24, { connectionResolvers });
1448
+
1449
+ // scripts/replyToMessage.ts
1450
+ import { defineTool as defineTool25, handleIfScriptMain as handleIfScriptMain25 } from "@zapier/connectors-sdk";
1451
+ import { z as z26 } from "zod";
1452
+ var inputSchema25 = z26.object({
1453
+ messageId: z26.string().describe(
1454
+ "Id of the message to reply to, from listMessages or getMessage. Opaque and case-sensitive; changes when the message is moved between folders."
1455
+ ),
1456
+ comment: z26.string().describe(
1457
+ "Reply text prepended above the quoted original. Plain text or HTML. Omit to send an empty-bodied reply."
1458
+ ).optional(),
1459
+ replyAll: z26.boolean().describe(
1460
+ "Reply to all original recipients (To + Cc) instead of just the sender. Defaults to false."
1461
+ ).optional(),
1462
+ mailbox: z26.string().describe(
1463
+ "Shared-mailbox address (UPN/email) to reply from instead of your own, e.g. team@contoso.com. Requires Send-as/Send-on-behalf delegation. Omit to reply as yourself."
1464
+ ).optional()
1465
+ }).strict();
1466
+ var outputSchema25 = z26.object({
1467
+ success: z26.literal(true)
1468
+ });
1469
+ var definition25 = defineTool25({
1470
+ name: "replyToMessage",
1471
+ title: "Reply To Message",
1472
+ description: "Reply to a message and send immediately, quoting the original. Set replyAll to reply to all original recipients (To + Cc). Returns only a success flag (202 accepted, no id). Resolve the message id via listMessages first; to draft a reply for review instead, use createReplyDraft.",
1473
+ inputSchema: inputSchema25,
1474
+ outputSchema: outputSchema25,
1475
+ annotations: {
1476
+ readOnlyHint: false,
1477
+ destructiveHint: false,
1478
+ idempotentHint: false,
1479
+ openWorldHint: true
1480
+ },
1481
+ connection: "microsoft-outlook",
1482
+ run: async (input, ctx) => {
1483
+ const action = input.replyAll ? "replyAll" : "reply";
1484
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
1485
+ input.messageId
1486
+ )}/${action}`;
1487
+ await outlookFetch(ctx.fetch, "replyToMessage", url, {
1488
+ method: "POST",
1489
+ body: JSON.stringify(
1490
+ input.comment !== void 0 ? { comment: input.comment } : {}
1491
+ )
1492
+ });
1493
+ return { success: true };
1494
+ }
1495
+ });
1496
+ var replyToMessage_default = definition25;
1497
+ await handleIfScriptMain25(import.meta, definition25, { connectionResolvers });
1498
+
1499
+ // scripts/sendDraft.ts
1500
+ import { defineTool as defineTool26, handleIfScriptMain as handleIfScriptMain26 } from "@zapier/connectors-sdk";
1501
+ import { z as z27 } from "zod";
1502
+ var inputSchema26 = z27.object({
1503
+ messageId: z27.string().describe(
1504
+ "Draft id from createDraft. Opaque and case-sensitive; the id is dead once the draft is sent."
1505
+ ),
1506
+ mailbox: z27.string().describe(
1507
+ "Shared-mailbox address (UPN/email) the draft lives in instead of your own, e.g. team@contoso.com. Requires Send-as/Send-on-behalf delegation. Omit for your own mailbox."
1508
+ ).optional()
1509
+ }).strict();
1510
+ var outputSchema26 = z27.object({
1511
+ success: z27.literal(true)
1512
+ });
1513
+ var definition26 = defineTool26({
1514
+ name: "sendDraft",
1515
+ title: "Send Draft",
1516
+ description: "Send a draft email created by createDraft. Returns only a success flag (the send is accepted asynchronously, and 202 \u2260 delivered); the draft id is dead after sending. Resolve the draft id from createDraft first.",
1517
+ inputSchema: inputSchema26,
1518
+ outputSchema: outputSchema26,
1519
+ annotations: {
1520
+ readOnlyHint: false,
1521
+ destructiveHint: false,
1522
+ idempotentHint: false,
1523
+ openWorldHint: true
1524
+ },
1525
+ connection: "microsoft-outlook",
1526
+ run: async (input, ctx) => {
1527
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
1528
+ input.messageId
1529
+ )}/send`;
1530
+ await outlookFetch(ctx.fetch, "sendDraft", url, { method: "POST" });
1531
+ return { success: true };
1532
+ }
1533
+ });
1534
+ var sendDraft_default = definition26;
1535
+ await handleIfScriptMain26(import.meta, definition26, { connectionResolvers });
1536
+
1537
+ // scripts/sendMail.ts
1538
+ import { defineTool as defineTool27, handleIfScriptMain as handleIfScriptMain27 } from "@zapier/connectors-sdk";
1539
+ import { z as z28 } from "zod";
1540
+ var inputSchema27 = z28.object({
1541
+ message: outgoingMessageSchema.describe(
1542
+ "The email to send. subject and toRecipients are required."
1543
+ ),
1544
+ saveToSentItems: z28.boolean().describe("Keep a copy in Sent Items. Defaults to true.").optional(),
1545
+ mailbox: z28.string().describe(
1546
+ "Shared-mailbox address (UPN/email) to send as instead of your own, e.g. team@contoso.com. Requires Send-as/Send-on-behalf delegation. Omit to send as yourself."
1547
+ ).optional()
1548
+ }).strict();
1549
+ var outputSchema27 = z28.object({
1550
+ success: z28.literal(true)
1551
+ });
1552
+ var definition27 = defineTool27({
1553
+ name: "sendMail",
1554
+ title: "Send Mail",
1555
+ description: "Compose and send an email in one step. Returns only a success flag \u2014 the send is accepted asynchronously with no message id (and 202 \u2260 delivered). When you need the sent message's id, use createDraft then sendDraft instead.",
1556
+ inputSchema: inputSchema27,
1557
+ outputSchema: outputSchema27,
1558
+ annotations: {
1559
+ readOnlyHint: false,
1560
+ destructiveHint: false,
1561
+ idempotentHint: false,
1562
+ openWorldHint: true
1563
+ },
1564
+ connection: "microsoft-outlook",
1565
+ run: async (input, ctx) => {
1566
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/sendMail`;
1567
+ const body = {
1568
+ message: toGraphOutgoingMessage(input.message)
1569
+ };
1570
+ if (input.saveToSentItems !== void 0) {
1571
+ body.saveToSentItems = input.saveToSentItems;
1572
+ }
1573
+ await outlookFetch(ctx.fetch, "sendMail", url, {
1574
+ method: "POST",
1575
+ body: JSON.stringify(body)
1576
+ });
1577
+ return { success: true };
1578
+ }
1579
+ });
1580
+ var sendMail_default = definition27;
1581
+ await handleIfScriptMain27(import.meta, definition27, { connectionResolvers });
1582
+
1583
+ // scripts/updateContact.ts
1584
+ import { defineTool as defineTool28, handleIfScriptMain as handleIfScriptMain28 } from "@zapier/connectors-sdk";
1585
+ import { z as z29 } from "zod";
1586
+ var inputSchema28 = z29.object({
1587
+ contactId: z29.string().describe("Contact id from listContacts. Opaque and case-sensitive."),
1588
+ ...outgoingContactSchema.shape
1589
+ }).strict();
1590
+ var outputSchema28 = contactSchema;
1591
+ var definition28 = defineTool28({
1592
+ name: "updateContact",
1593
+ title: "Update Contact",
1594
+ description: "Update fields on a personal contact. Set only the fields you want to change. Array fields (emailAddresses, businessPhones) REPLACE the existing values \u2014 read current via getContact, merge, then update.",
1595
+ inputSchema: inputSchema28,
1596
+ outputSchema: outputSchema28,
1597
+ annotations: {
1598
+ readOnlyHint: false,
1599
+ destructiveHint: false,
1600
+ idempotentHint: true,
1601
+ openWorldHint: true
1602
+ },
1603
+ connection: "microsoft-outlook",
1604
+ run: async (input, ctx) => {
1605
+ const { contactId, ...patch } = input;
1606
+ const url = `${GRAPH_BASE}/me/contacts/${encodeURIComponent(contactId)}`;
1607
+ const res = await outlookFetch(ctx.fetch, "updateContact", url, {
1608
+ method: "PATCH",
1609
+ body: JSON.stringify(patch)
1610
+ });
1611
+ return parseGraphResponse(res);
1612
+ }
1613
+ });
1614
+ var updateContact_default = definition28;
1615
+ await handleIfScriptMain28(import.meta, definition28, { connectionResolvers });
1616
+
1617
+ // scripts/updateEvent.ts
1618
+ import { defineTool as defineTool29, handleIfScriptMain as handleIfScriptMain29 } from "@zapier/connectors-sdk";
1619
+ import { z as z30 } from "zod";
1620
+ var inputSchema29 = z30.object({
1621
+ eventId: z30.string().describe(
1622
+ "Opaque event id from listEvents, listCalendarView, or getEvent."
1623
+ ),
1624
+ ...outgoingEventSchema.partial().shape,
1625
+ mailbox: z30.string().describe(
1626
+ "Shared-mailbox address (UPN/email) holding the event instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
1627
+ ).optional(),
1628
+ calendarId: z30.string().describe(
1629
+ "Target a specific calendar (id from listCalendars). Omit to use the default calendar."
1630
+ ).optional()
1631
+ }).strict();
1632
+ var outputSchema29 = eventSchema;
1633
+ var definition29 = defineTool29({
1634
+ name: "updateEvent",
1635
+ title: "Update Event",
1636
+ description: "Update a calendar event \u2014 change subject, time, location, body, attendees, or categories. Set only the fields you want to change. The attendees array REPLACES the existing list, so read the current attendees via getEvent, append, then update.",
1637
+ inputSchema: inputSchema29,
1638
+ outputSchema: outputSchema29,
1639
+ annotations: {
1640
+ readOnlyHint: false,
1641
+ destructiveHint: false,
1642
+ idempotentHint: true,
1643
+ openWorldHint: true
1644
+ },
1645
+ connection: "microsoft-outlook",
1646
+ run: async (input, ctx) => {
1647
+ const { eventId, mailbox, calendarId, ...patch } = input;
1648
+ const url = `${GRAPH_BASE}${calendarRoot(mailbox, calendarId)}/events/${encodeURIComponent(
1649
+ eventId
1650
+ )}`;
1651
+ const res = await outlookFetch(ctx.fetch, "updateEvent", url, {
1652
+ method: "PATCH",
1653
+ body: JSON.stringify(patch)
1654
+ });
1655
+ return parseGraphResponse(res);
1656
+ }
1657
+ });
1658
+ var updateEvent_default = definition29;
1659
+ await handleIfScriptMain29(import.meta, definition29, { connectionResolvers });
1660
+
1661
+ // scripts/updateMessage.ts
1662
+ import { defineTool as defineTool30, handleIfScriptMain as handleIfScriptMain30 } from "@zapier/connectors-sdk";
1663
+ import { z as z31 } from "zod";
1664
+ var inputSchema30 = z31.object({
1665
+ messageId: z31.string().describe(
1666
+ "Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders."
1667
+ ),
1668
+ isRead: z31.boolean().describe("Mark the message read (true) or unread (false).").optional(),
1669
+ importance: z31.enum(["low", "normal", "high"]).describe("Importance level.").optional(),
1670
+ categories: z31.array(z31.string()).describe(
1671
+ "Category names to assign. REPLACES the existing set \u2014 read the current categories via getMessage and include them if you want to append rather than overwrite."
1672
+ ).optional(),
1673
+ flag: z31.strictObject({
1674
+ flagStatus: z31.enum(["notFlagged", "flagged", "complete"]).describe("Follow-up flag state."),
1675
+ startDateTime: dateTimeTimeZoneInputSchema.optional(),
1676
+ dueDateTime: dateTimeTimeZoneInputSchema.optional()
1677
+ }).describe("Follow-up flag to set on the message.").optional(),
1678
+ mailbox: z31.string().describe(
1679
+ "Shared-mailbox address (UPN/email) to update instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox."
1680
+ ).optional()
1681
+ }).strict();
1682
+ var outputSchema30 = z31.object({
1683
+ id: z31.string(),
1684
+ subject: z31.string(),
1685
+ isRead: z31.boolean(),
1686
+ importance: z31.string().optional(),
1687
+ categories: z31.array(z31.string()).optional(),
1688
+ flag: followupFlagSchema.optional()
1689
+ });
1690
+ var definition30 = defineTool30({
1691
+ name: "updateMessage",
1692
+ title: "Update Message",
1693
+ description: "Update a message's state \u2014 mark read/unread, change importance, replace its categories, or set a follow-up flag. Set only the fields you want to change; everything else is left untouched. Resolve the message id via listMessages first. Subject/body are editable only on drafts.",
1694
+ inputSchema: inputSchema30,
1695
+ outputSchema: outputSchema30,
1696
+ annotations: {
1697
+ readOnlyHint: false,
1698
+ destructiveHint: false,
1699
+ idempotentHint: true,
1700
+ openWorldHint: true
1701
+ },
1702
+ connection: "microsoft-outlook",
1703
+ run: async (input, ctx) => {
1704
+ const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
1705
+ input.messageId
1706
+ )}`;
1707
+ const body = {};
1708
+ if (input.isRead !== void 0) body.isRead = input.isRead;
1709
+ if (input.importance !== void 0) body.importance = input.importance;
1710
+ if (input.categories !== void 0) body.categories = input.categories;
1711
+ if (input.flag !== void 0) body.flag = input.flag;
1712
+ const res = await outlookFetch(ctx.fetch, "updateMessage", url, {
1713
+ method: "PATCH",
1714
+ body: JSON.stringify(body)
1715
+ });
1716
+ return parseGraphResponse(res);
1717
+ }
1718
+ });
1719
+ var updateMessage_default = definition30;
1720
+ await handleIfScriptMain30(import.meta, definition30, { connectionResolvers });
1721
+
1722
+ // index.ts
1723
+ var connector = defineConnector({
1724
+ scripts: {
1725
+ copyMessage: copyMessage_default,
1726
+ createContact: createContact_default,
1727
+ createDraft: createDraft_default,
1728
+ createEvent: createEvent_default,
1729
+ createMailFolder: createMailFolder_default,
1730
+ createReplyDraft: createReplyDraft_default,
1731
+ deleteContact: deleteContact_default,
1732
+ deleteEvent: deleteEvent_default,
1733
+ deleteMessage: deleteMessage_default,
1734
+ forwardMessage: forwardMessage_default,
1735
+ getAttachment: getAttachment_default,
1736
+ getContact: getContact_default,
1737
+ getEvent: getEvent_default,
1738
+ getMe: getMe_default,
1739
+ getMessage: getMessage_default,
1740
+ listAttachments: listAttachments_default,
1741
+ listCalendars: listCalendars_default,
1742
+ listCalendarView: listCalendarView_default,
1743
+ listCategories: listCategories_default,
1744
+ listContacts: listContacts_default,
1745
+ listEvents: listEvents_default,
1746
+ listMailFolders: listMailFolders_default,
1747
+ listMessages: listMessages_default,
1748
+ moveMessage: moveMessage_default,
1749
+ replyToMessage: replyToMessage_default,
1750
+ sendDraft: sendDraft_default,
1751
+ sendMail: sendMail_default,
1752
+ updateContact: updateContact_default,
1753
+ updateEvent: updateEvent_default,
1754
+ updateMessage: updateMessage_default
1755
+ },
1756
+ connectionResolvers
1757
+ });
1758
+ var index_default = connector;
1759
+ var {
1760
+ copyMessage,
1761
+ createContact,
1762
+ createDraft,
1763
+ createEvent,
1764
+ createMailFolder,
1765
+ createReplyDraft,
1766
+ deleteContact,
1767
+ deleteEvent,
1768
+ deleteMessage,
1769
+ forwardMessage,
1770
+ getAttachment,
1771
+ getContact,
1772
+ getEvent,
1773
+ getMe,
1774
+ getMessage,
1775
+ listAttachments,
1776
+ listCalendars,
1777
+ listCalendarView,
1778
+ listCategories,
1779
+ listContacts,
1780
+ listEvents,
1781
+ listMailFolders,
1782
+ listMessages,
1783
+ moveMessage,
1784
+ replyToMessage,
1785
+ sendDraft,
1786
+ sendMail,
1787
+ updateContact,
1788
+ updateEvent,
1789
+ updateMessage
1790
+ } = toFunctions(connector);
1791
+ export {
1792
+ copyMessage,
1793
+ createContact,
1794
+ createDraft,
1795
+ createEvent,
1796
+ createMailFolder,
1797
+ createReplyDraft,
1798
+ index_default as default,
1799
+ deleteContact,
1800
+ deleteEvent,
1801
+ deleteMessage,
1802
+ forwardMessage,
1803
+ getAttachment,
1804
+ getContact,
1805
+ getEvent,
1806
+ getMe,
1807
+ getMessage,
1808
+ listAttachments,
1809
+ listCalendarView,
1810
+ listCalendars,
1811
+ listCategories,
1812
+ listContacts,
1813
+ listEvents,
1814
+ listMailFolders,
1815
+ listMessages,
1816
+ moveMessage,
1817
+ replyToMessage,
1818
+ sendDraft,
1819
+ sendMail,
1820
+ updateContact,
1821
+ updateEvent,
1822
+ updateMessage
1823
+ };