@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.
- package/LICENSE +93 -0
- package/NOTICE +8 -0
- package/NOTICE.md +8 -0
- package/README.md +145 -2
- package/SKILL.md +159 -0
- package/cli.js +71 -0
- package/cli.ts +5 -0
- package/connections.ts +69 -0
- package/dist/cli.js +4 -0
- package/dist/index.js +1823 -0
- package/index.ts +103 -0
- package/package.json +65 -4
- package/preflight.sh +157 -0
- package/references/microsoft-outlook-api-gotchas.md +210 -0
- package/scripts/copyMessage.ts +68 -0
- package/scripts/createContact.ts +39 -0
- package/scripts/createDraft.ts +71 -0
- package/scripts/createEvent.ts +61 -0
- package/scripts/createMailFolder.ts +68 -0
- package/scripts/createReplyDraft.ts +81 -0
- package/scripts/deleteContact.ts +47 -0
- package/scripts/deleteEvent.ts +61 -0
- package/scripts/deleteMessage.ts +57 -0
- package/scripts/forwardMessage.ts +75 -0
- package/scripts/getAttachment.ts +60 -0
- package/scripts/getContact.ts +44 -0
- package/scripts/getEvent.ts +63 -0
- package/scripts/getMe.ts +42 -0
- package/scripts/getMessage.ts +68 -0
- package/scripts/listAttachments.ts +94 -0
- package/scripts/listCalendarView.ts +99 -0
- package/scripts/listCalendars.ts +85 -0
- package/scripts/listCategories.ts +49 -0
- package/scripts/listContacts.ts +81 -0
- package/scripts/listEvents.ts +94 -0
- package/scripts/listMailFolders.ts +98 -0
- package/scripts/listMessages.ts +106 -0
- package/scripts/moveMessage.ts +68 -0
- package/scripts/replyToMessage.ts +73 -0
- package/scripts/sendDraft.ts +55 -0
- package/scripts/sendMail.ts +68 -0
- package/scripts/updateContact.ts +49 -0
- package/scripts/updateEvent.ts +69 -0
- package/scripts/updateMessage.ts +99 -0
- package/tsup.config.ts +63 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import {
|
|
7
|
+
GRAPH_BASE,
|
|
8
|
+
mailboxRoot,
|
|
9
|
+
outlookFetch,
|
|
10
|
+
parseGraphResponse,
|
|
11
|
+
} from "../lib/graph.ts";
|
|
12
|
+
import {
|
|
13
|
+
outgoingMessageSchema,
|
|
14
|
+
recipientSchema,
|
|
15
|
+
toGraphOutgoingMessage,
|
|
16
|
+
} from "../lib/schemas.ts";
|
|
17
|
+
|
|
18
|
+
const inputSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
...outgoingMessageSchema.shape,
|
|
21
|
+
mailbox: z
|
|
22
|
+
.string()
|
|
23
|
+
.describe(
|
|
24
|
+
"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.",
|
|
25
|
+
)
|
|
26
|
+
.optional(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
|
|
30
|
+
const outputSchema = z.object({
|
|
31
|
+
id: z.string().describe("Draft id — pass to sendDraft to send it later."),
|
|
32
|
+
subject: z.string(),
|
|
33
|
+
isDraft: z.boolean(),
|
|
34
|
+
bodyPreview: z
|
|
35
|
+
.string()
|
|
36
|
+
.optional()
|
|
37
|
+
.describe(
|
|
38
|
+
"First ~255 chars of the body; use getMessage for the full body.",
|
|
39
|
+
),
|
|
40
|
+
toRecipients: z.array(recipientSchema).optional(),
|
|
41
|
+
webLink: z.string().optional(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const definition = defineTool({
|
|
45
|
+
name: "createDraft",
|
|
46
|
+
title: "Create Draft",
|
|
47
|
+
description:
|
|
48
|
+
"Compose an email and save it as a draft without sending. Returns the draft's id — 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).",
|
|
49
|
+
inputSchema,
|
|
50
|
+
outputSchema,
|
|
51
|
+
annotations: {
|
|
52
|
+
readOnlyHint: false,
|
|
53
|
+
destructiveHint: false,
|
|
54
|
+
idempotentHint: false,
|
|
55
|
+
openWorldHint: true,
|
|
56
|
+
},
|
|
57
|
+
connection: "microsoft-outlook",
|
|
58
|
+
run: async (input, ctx) => {
|
|
59
|
+
const { mailbox, ...message } = input;
|
|
60
|
+
const url = `${GRAPH_BASE}${mailboxRoot(mailbox)}/messages`;
|
|
61
|
+
const res = await outlookFetch(ctx.fetch, "createDraft", url, {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: JSON.stringify(toGraphOutgoingMessage(message)),
|
|
64
|
+
});
|
|
65
|
+
return parseGraphResponse(res);
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export default definition;
|
|
70
|
+
|
|
71
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import {
|
|
7
|
+
calendarRoot,
|
|
8
|
+
GRAPH_BASE,
|
|
9
|
+
outlookFetch,
|
|
10
|
+
parseGraphResponse,
|
|
11
|
+
} from "../lib/graph.ts";
|
|
12
|
+
import { eventSchema, outgoingEventSchema } from "../lib/schemas.ts";
|
|
13
|
+
|
|
14
|
+
const inputSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
...outgoingEventSchema.shape,
|
|
17
|
+
mailbox: z
|
|
18
|
+
.string()
|
|
19
|
+
.describe(
|
|
20
|
+
"Shared-mailbox address (UPN/email) to create the event in instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox.",
|
|
21
|
+
)
|
|
22
|
+
.optional(),
|
|
23
|
+
calendarId: z
|
|
24
|
+
.string()
|
|
25
|
+
.describe(
|
|
26
|
+
"Target a specific calendar (id from listCalendars). Omit to use the default calendar.",
|
|
27
|
+
)
|
|
28
|
+
.optional(),
|
|
29
|
+
})
|
|
30
|
+
.strict();
|
|
31
|
+
|
|
32
|
+
const outputSchema = eventSchema;
|
|
33
|
+
|
|
34
|
+
const definition = defineTool({
|
|
35
|
+
name: "createEvent",
|
|
36
|
+
title: "Create Event",
|
|
37
|
+
description:
|
|
38
|
+
"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.",
|
|
39
|
+
inputSchema,
|
|
40
|
+
outputSchema,
|
|
41
|
+
annotations: {
|
|
42
|
+
readOnlyHint: false,
|
|
43
|
+
destructiveHint: false,
|
|
44
|
+
idempotentHint: false,
|
|
45
|
+
openWorldHint: true,
|
|
46
|
+
},
|
|
47
|
+
connection: "microsoft-outlook",
|
|
48
|
+
run: async (input, ctx) => {
|
|
49
|
+
const { mailbox, calendarId, ...event } = input;
|
|
50
|
+
const url = `${GRAPH_BASE}${calendarRoot(mailbox, calendarId)}/events`;
|
|
51
|
+
const res = await outlookFetch(ctx.fetch, "createEvent", url, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
body: JSON.stringify(event),
|
|
54
|
+
});
|
|
55
|
+
return parseGraphResponse(res);
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export default definition;
|
|
60
|
+
|
|
61
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import {
|
|
7
|
+
GRAPH_BASE,
|
|
8
|
+
mailboxRoot,
|
|
9
|
+
outlookFetch,
|
|
10
|
+
parseGraphResponse,
|
|
11
|
+
} from "../lib/graph.ts";
|
|
12
|
+
|
|
13
|
+
const inputSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
displayName: z.string().describe("Folder name as shown in Outlook."),
|
|
16
|
+
parentFolderId: z
|
|
17
|
+
.string()
|
|
18
|
+
.describe(
|
|
19
|
+
"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.",
|
|
20
|
+
)
|
|
21
|
+
.optional(),
|
|
22
|
+
mailbox: z
|
|
23
|
+
.string()
|
|
24
|
+
.describe(
|
|
25
|
+
"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.",
|
|
26
|
+
)
|
|
27
|
+
.optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
|
|
31
|
+
const outputSchema = z.object({
|
|
32
|
+
id: z.string(),
|
|
33
|
+
displayName: z.string(),
|
|
34
|
+
parentFolderId: z.string().optional(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const definition = defineTool({
|
|
38
|
+
name: "createMailFolder",
|
|
39
|
+
title: "Create Mail Folder",
|
|
40
|
+
description:
|
|
41
|
+
"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.",
|
|
42
|
+
inputSchema,
|
|
43
|
+
outputSchema,
|
|
44
|
+
annotations: {
|
|
45
|
+
readOnlyHint: false,
|
|
46
|
+
destructiveHint: false,
|
|
47
|
+
idempotentHint: false,
|
|
48
|
+
openWorldHint: true,
|
|
49
|
+
},
|
|
50
|
+
connection: "microsoft-outlook",
|
|
51
|
+
run: async (input, ctx) => {
|
|
52
|
+
const root = mailboxRoot(input.mailbox);
|
|
53
|
+
const path =
|
|
54
|
+
input.parentFolderId !== undefined
|
|
55
|
+
? `${root}/mailFolders/${encodeURIComponent(input.parentFolderId)}/childFolders`
|
|
56
|
+
: `${root}/mailFolders`;
|
|
57
|
+
const url = `${GRAPH_BASE}${path}`;
|
|
58
|
+
const res = await outlookFetch(ctx.fetch, "createMailFolder", url, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
body: JSON.stringify({ displayName: input.displayName }),
|
|
61
|
+
});
|
|
62
|
+
return parseGraphResponse(res);
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export default definition;
|
|
67
|
+
|
|
68
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import {
|
|
7
|
+
GRAPH_BASE,
|
|
8
|
+
mailboxRoot,
|
|
9
|
+
outlookFetch,
|
|
10
|
+
parseGraphResponse,
|
|
11
|
+
} from "../lib/graph.ts";
|
|
12
|
+
|
|
13
|
+
const inputSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
messageId: z
|
|
16
|
+
.string()
|
|
17
|
+
.describe(
|
|
18
|
+
"Id of the message to reply to, from listMessages or getMessage. Opaque and case-sensitive; changes when the message is moved between folders.",
|
|
19
|
+
),
|
|
20
|
+
comment: z
|
|
21
|
+
.string()
|
|
22
|
+
.describe(
|
|
23
|
+
"Reply text to seed the draft body, above the quoted original. Plain text or HTML.",
|
|
24
|
+
)
|
|
25
|
+
.optional(),
|
|
26
|
+
replyAll: z
|
|
27
|
+
.boolean()
|
|
28
|
+
.describe(
|
|
29
|
+
"Draft a reply to all original recipients (To + Cc) instead of just the sender. Defaults to false.",
|
|
30
|
+
)
|
|
31
|
+
.optional(),
|
|
32
|
+
mailbox: z
|
|
33
|
+
.string()
|
|
34
|
+
.describe(
|
|
35
|
+
"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.",
|
|
36
|
+
)
|
|
37
|
+
.optional(),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
|
|
41
|
+
const outputSchema = z.object({
|
|
42
|
+
id: z
|
|
43
|
+
.string()
|
|
44
|
+
.describe("Draft reply id — edit further or pass to sendDraft."),
|
|
45
|
+
subject: z.string(),
|
|
46
|
+
isDraft: z.boolean(),
|
|
47
|
+
webLink: z.string().optional(),
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const definition = defineTool({
|
|
51
|
+
name: "createReplyDraft",
|
|
52
|
+
title: "Create Reply Draft",
|
|
53
|
+
description:
|
|
54
|
+
"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 — review/edit it, then send with sendDraft. Resolve the message id via listMessages first; to reply and send in one step, use replyToMessage.",
|
|
55
|
+
inputSchema,
|
|
56
|
+
outputSchema,
|
|
57
|
+
annotations: {
|
|
58
|
+
readOnlyHint: false,
|
|
59
|
+
destructiveHint: false,
|
|
60
|
+
idempotentHint: false,
|
|
61
|
+
openWorldHint: true,
|
|
62
|
+
},
|
|
63
|
+
connection: "microsoft-outlook",
|
|
64
|
+
run: async (input, ctx) => {
|
|
65
|
+
const action = input.replyAll ? "createReplyAll" : "createReply";
|
|
66
|
+
const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
|
|
67
|
+
input.messageId,
|
|
68
|
+
)}/${action}`;
|
|
69
|
+
const res = await outlookFetch(ctx.fetch, "createReplyDraft", url, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
body: JSON.stringify(
|
|
72
|
+
input.comment !== undefined ? { comment: input.comment } : {},
|
|
73
|
+
),
|
|
74
|
+
});
|
|
75
|
+
return parseGraphResponse(res);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
export default definition;
|
|
80
|
+
|
|
81
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import { GRAPH_BASE, outlookFetch } from "../lib/graph.ts";
|
|
7
|
+
|
|
8
|
+
const inputSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
contactId: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe("Contact id from listContacts. Opaque and case-sensitive."),
|
|
13
|
+
})
|
|
14
|
+
.strict();
|
|
15
|
+
|
|
16
|
+
// Graph's DELETE /me/contacts/{id} returns 204 with no body, so there is
|
|
17
|
+
// nothing to echo back — run() synthesizes a success result.
|
|
18
|
+
const outputSchema = z.object({
|
|
19
|
+
success: z.literal(true),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const definition = defineTool({
|
|
23
|
+
name: "deleteContact",
|
|
24
|
+
title: "Delete Contact",
|
|
25
|
+
description:
|
|
26
|
+
"Delete a personal contact by id. This cannot be undone — resolve the id via listContacts and confirm it's the right contact first.",
|
|
27
|
+
inputSchema,
|
|
28
|
+
outputSchema,
|
|
29
|
+
annotations: {
|
|
30
|
+
readOnlyHint: false,
|
|
31
|
+
destructiveHint: true,
|
|
32
|
+
idempotentHint: true,
|
|
33
|
+
openWorldHint: true,
|
|
34
|
+
},
|
|
35
|
+
connection: "microsoft-outlook",
|
|
36
|
+
run: async (input, ctx) => {
|
|
37
|
+
const url = `${GRAPH_BASE}/me/contacts/${encodeURIComponent(
|
|
38
|
+
input.contactId,
|
|
39
|
+
)}`;
|
|
40
|
+
await outlookFetch(ctx.fetch, "deleteContact", url, { method: "DELETE" });
|
|
41
|
+
return { success: true as const };
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default definition;
|
|
46
|
+
|
|
47
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import { calendarRoot, GRAPH_BASE, outlookFetch } from "../lib/graph.ts";
|
|
7
|
+
|
|
8
|
+
const inputSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
eventId: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe(
|
|
13
|
+
"Opaque event id from listEvents, listCalendarView, or getEvent.",
|
|
14
|
+
),
|
|
15
|
+
mailbox: z
|
|
16
|
+
.string()
|
|
17
|
+
.describe(
|
|
18
|
+
"Shared-mailbox address (UPN/email) holding the event instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox.",
|
|
19
|
+
)
|
|
20
|
+
.optional(),
|
|
21
|
+
calendarId: z
|
|
22
|
+
.string()
|
|
23
|
+
.describe(
|
|
24
|
+
"Target a specific calendar (id from listCalendars). Omit to use the default calendar.",
|
|
25
|
+
)
|
|
26
|
+
.optional(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
|
|
30
|
+
// Graph's DELETE /events/{id} returns 204 with no body — run() synthesizes a
|
|
31
|
+
// success result.
|
|
32
|
+
const outputSchema = z.object({
|
|
33
|
+
success: z.literal(true),
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const definition = defineTool({
|
|
37
|
+
name: "deleteEvent",
|
|
38
|
+
title: "Delete Event",
|
|
39
|
+
description:
|
|
40
|
+
"Delete (cancel) a calendar event. For events you organize, attendees are notified of the cancellation — this is not trivially reversible.",
|
|
41
|
+
inputSchema,
|
|
42
|
+
outputSchema,
|
|
43
|
+
annotations: {
|
|
44
|
+
readOnlyHint: false,
|
|
45
|
+
destructiveHint: true,
|
|
46
|
+
idempotentHint: true,
|
|
47
|
+
openWorldHint: true,
|
|
48
|
+
},
|
|
49
|
+
connection: "microsoft-outlook",
|
|
50
|
+
run: async (input, ctx) => {
|
|
51
|
+
const url = `${GRAPH_BASE}${calendarRoot(input.mailbox, input.calendarId)}/events/${encodeURIComponent(
|
|
52
|
+
input.eventId,
|
|
53
|
+
)}`;
|
|
54
|
+
await outlookFetch(ctx.fetch, "deleteEvent", url, { method: "DELETE" });
|
|
55
|
+
return { success: true as const };
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export default definition;
|
|
60
|
+
|
|
61
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import { GRAPH_BASE, mailboxRoot, outlookFetch } from "../lib/graph.ts";
|
|
7
|
+
|
|
8
|
+
const inputSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
messageId: z
|
|
11
|
+
.string()
|
|
12
|
+
.describe(
|
|
13
|
+
"Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders.",
|
|
14
|
+
),
|
|
15
|
+
mailbox: z
|
|
16
|
+
.string()
|
|
17
|
+
.describe(
|
|
18
|
+
"Shared-mailbox address (UPN/email) to delete from instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox.",
|
|
19
|
+
)
|
|
20
|
+
.optional(),
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
|
|
24
|
+
// Graph's DELETE /messages/{id} returns 204 with no body, so there is nothing
|
|
25
|
+
// to echo back — run() synthesizes a success result.
|
|
26
|
+
const outputSchema = z.object({
|
|
27
|
+
success: z.literal(true),
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const definition = defineTool({
|
|
31
|
+
name: "deleteMessage",
|
|
32
|
+
title: "Delete Message",
|
|
33
|
+
description:
|
|
34
|
+
"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.",
|
|
35
|
+
inputSchema,
|
|
36
|
+
outputSchema,
|
|
37
|
+
annotations: {
|
|
38
|
+
readOnlyHint: false,
|
|
39
|
+
destructiveHint: false,
|
|
40
|
+
idempotentHint: true,
|
|
41
|
+
openWorldHint: true,
|
|
42
|
+
},
|
|
43
|
+
connection: "microsoft-outlook",
|
|
44
|
+
run: async (input, ctx) => {
|
|
45
|
+
const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
|
|
46
|
+
input.messageId,
|
|
47
|
+
)}`;
|
|
48
|
+
await outlookFetch(ctx.fetch, "deleteMessage", url, {
|
|
49
|
+
method: "DELETE",
|
|
50
|
+
});
|
|
51
|
+
return { success: true as const };
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export default definition;
|
|
56
|
+
|
|
57
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import { GRAPH_BASE, mailboxRoot, outlookFetch } from "../lib/graph.ts";
|
|
7
|
+
import { recipientInputSchema } from "../lib/schemas.ts";
|
|
8
|
+
|
|
9
|
+
const inputSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
messageId: z
|
|
12
|
+
.string()
|
|
13
|
+
.describe(
|
|
14
|
+
"Id of the message to forward, from listMessages or getMessage. Opaque and case-sensitive; changes when the message is moved between folders.",
|
|
15
|
+
),
|
|
16
|
+
toRecipients: z
|
|
17
|
+
.array(recipientInputSchema)
|
|
18
|
+
.min(1)
|
|
19
|
+
.describe(
|
|
20
|
+
'Who to forward the message to, e.g. [{ "emailAddress": { "address": "jane@contoso.com" } }].',
|
|
21
|
+
),
|
|
22
|
+
comment: z
|
|
23
|
+
.string()
|
|
24
|
+
.describe(
|
|
25
|
+
"Note prepended above the forwarded original. Plain text or HTML.",
|
|
26
|
+
)
|
|
27
|
+
.optional(),
|
|
28
|
+
mailbox: z
|
|
29
|
+
.string()
|
|
30
|
+
.describe(
|
|
31
|
+
"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.",
|
|
32
|
+
)
|
|
33
|
+
.optional(),
|
|
34
|
+
})
|
|
35
|
+
.strict();
|
|
36
|
+
|
|
37
|
+
// Graph's POST /forward returns 202 with no body, so there is nothing to echo
|
|
38
|
+
// back — run() synthesizes a success result.
|
|
39
|
+
const outputSchema = z.object({
|
|
40
|
+
success: z.literal(true),
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const definition = defineTool({
|
|
44
|
+
name: "forwardMessage",
|
|
45
|
+
title: "Forward Message",
|
|
46
|
+
description:
|
|
47
|
+
"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.",
|
|
48
|
+
inputSchema,
|
|
49
|
+
outputSchema,
|
|
50
|
+
annotations: {
|
|
51
|
+
readOnlyHint: false,
|
|
52
|
+
destructiveHint: false,
|
|
53
|
+
idempotentHint: false,
|
|
54
|
+
openWorldHint: true,
|
|
55
|
+
},
|
|
56
|
+
connection: "microsoft-outlook",
|
|
57
|
+
run: async (input, ctx) => {
|
|
58
|
+
const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
|
|
59
|
+
input.messageId,
|
|
60
|
+
)}/forward`;
|
|
61
|
+
const body = {
|
|
62
|
+
toRecipients: input.toRecipients,
|
|
63
|
+
...(input.comment !== undefined ? { comment: input.comment } : {}),
|
|
64
|
+
};
|
|
65
|
+
await outlookFetch(ctx.fetch, "forwardMessage", url, {
|
|
66
|
+
method: "POST",
|
|
67
|
+
body: JSON.stringify(body),
|
|
68
|
+
});
|
|
69
|
+
return { success: true as const };
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export default definition;
|
|
74
|
+
|
|
75
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import {
|
|
7
|
+
GRAPH_BASE,
|
|
8
|
+
mailboxRoot,
|
|
9
|
+
outlookFetch,
|
|
10
|
+
parseGraphResponse,
|
|
11
|
+
} from "../lib/graph.ts";
|
|
12
|
+
import { attachmentSchema, normalizeAttachment } from "../lib/schemas.ts";
|
|
13
|
+
|
|
14
|
+
const inputSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
messageId: z
|
|
17
|
+
.string()
|
|
18
|
+
.describe(
|
|
19
|
+
"Message id from listMessages or another message tool. Opaque and case-sensitive; changes when the message is moved between folders.",
|
|
20
|
+
),
|
|
21
|
+
attachmentId: z.string().describe("Attachment id from listAttachments."),
|
|
22
|
+
mailbox: z
|
|
23
|
+
.string()
|
|
24
|
+
.describe(
|
|
25
|
+
"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.",
|
|
26
|
+
)
|
|
27
|
+
.optional(),
|
|
28
|
+
})
|
|
29
|
+
.strict();
|
|
30
|
+
|
|
31
|
+
const outputSchema = attachmentSchema;
|
|
32
|
+
|
|
33
|
+
const definition = defineTool({
|
|
34
|
+
name: "getAttachment",
|
|
35
|
+
title: "Get Attachment",
|
|
36
|
+
description:
|
|
37
|
+
"Retrieve one attachment by id, including its base64 contentBytes. Resolve the attachmentId via listAttachments first. contentBytes is present only for file attachments — item and reference attachments carry no inline bytes.",
|
|
38
|
+
inputSchema,
|
|
39
|
+
outputSchema,
|
|
40
|
+
annotations: {
|
|
41
|
+
readOnlyHint: true,
|
|
42
|
+
destructiveHint: false,
|
|
43
|
+
idempotentHint: true,
|
|
44
|
+
openWorldHint: true,
|
|
45
|
+
},
|
|
46
|
+
connection: "microsoft-outlook",
|
|
47
|
+
run: async (input, ctx) => {
|
|
48
|
+
const url = `${GRAPH_BASE}${mailboxRoot(input.mailbox)}/messages/${encodeURIComponent(
|
|
49
|
+
input.messageId,
|
|
50
|
+
)}/attachments/${encodeURIComponent(input.attachmentId)}`;
|
|
51
|
+
const res = await outlookFetch(ctx.fetch, "getAttachment", url);
|
|
52
|
+
return normalizeAttachment(
|
|
53
|
+
await parseGraphResponse<Record<string, unknown>>(res),
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default definition;
|
|
59
|
+
|
|
60
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import { GRAPH_BASE, outlookFetch, parseGraphResponse } from "../lib/graph.ts";
|
|
7
|
+
import { contactSchema } from "../lib/schemas.ts";
|
|
8
|
+
|
|
9
|
+
const inputSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
contactId: z
|
|
12
|
+
.string()
|
|
13
|
+
.describe("Contact id from listContacts. Opaque and case-sensitive."),
|
|
14
|
+
})
|
|
15
|
+
.strict();
|
|
16
|
+
|
|
17
|
+
const outputSchema = contactSchema;
|
|
18
|
+
|
|
19
|
+
const definition = defineTool({
|
|
20
|
+
name: "getContact",
|
|
21
|
+
title: "Get Contact",
|
|
22
|
+
description:
|
|
23
|
+
"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.",
|
|
24
|
+
inputSchema,
|
|
25
|
+
outputSchema,
|
|
26
|
+
annotations: {
|
|
27
|
+
readOnlyHint: true,
|
|
28
|
+
destructiveHint: false,
|
|
29
|
+
idempotentHint: true,
|
|
30
|
+
openWorldHint: true,
|
|
31
|
+
},
|
|
32
|
+
connection: "microsoft-outlook",
|
|
33
|
+
run: async (input, ctx) => {
|
|
34
|
+
const url = `${GRAPH_BASE}/me/contacts/${encodeURIComponent(
|
|
35
|
+
input.contactId,
|
|
36
|
+
)}`;
|
|
37
|
+
const res = await outlookFetch(ctx.fetch, "getContact", url);
|
|
38
|
+
return parseGraphResponse(res);
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export default definition;
|
|
43
|
+
|
|
44
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { defineTool, handleIfScriptMain } from "@zapier/connectors-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
import { connectionResolvers } from "../connections.ts";
|
|
6
|
+
import {
|
|
7
|
+
calendarRoot,
|
|
8
|
+
GRAPH_BASE,
|
|
9
|
+
outlookFetch,
|
|
10
|
+
parseGraphResponse,
|
|
11
|
+
} from "../lib/graph.ts";
|
|
12
|
+
import { eventSchema } from "../lib/schemas.ts";
|
|
13
|
+
|
|
14
|
+
const inputSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
eventId: z
|
|
17
|
+
.string()
|
|
18
|
+
.describe(
|
|
19
|
+
"Opaque event id from listEvents, listCalendarView, or getEvent.",
|
|
20
|
+
),
|
|
21
|
+
mailbox: z
|
|
22
|
+
.string()
|
|
23
|
+
.describe(
|
|
24
|
+
"Shared-mailbox address (UPN/email) to read from instead of your own. Requires shared-mailbox delegation. Omit for your own mailbox.",
|
|
25
|
+
)
|
|
26
|
+
.optional(),
|
|
27
|
+
calendarId: z
|
|
28
|
+
.string()
|
|
29
|
+
.describe(
|
|
30
|
+
"Target a specific calendar (id from listCalendars). Omit to use the default calendar.",
|
|
31
|
+
)
|
|
32
|
+
.optional(),
|
|
33
|
+
})
|
|
34
|
+
.strict();
|
|
35
|
+
|
|
36
|
+
const outputSchema = eventSchema;
|
|
37
|
+
|
|
38
|
+
const definition = defineTool({
|
|
39
|
+
name: "getEvent",
|
|
40
|
+
title: "Get Event",
|
|
41
|
+
description:
|
|
42
|
+
"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 — e.g. fetch the attendees, append, then update).",
|
|
43
|
+
inputSchema,
|
|
44
|
+
outputSchema,
|
|
45
|
+
annotations: {
|
|
46
|
+
readOnlyHint: true,
|
|
47
|
+
destructiveHint: false,
|
|
48
|
+
idempotentHint: true,
|
|
49
|
+
openWorldHint: true,
|
|
50
|
+
},
|
|
51
|
+
connection: "microsoft-outlook",
|
|
52
|
+
run: async (input, ctx) => {
|
|
53
|
+
const url = `${GRAPH_BASE}${calendarRoot(input.mailbox, input.calendarId)}/events/${encodeURIComponent(
|
|
54
|
+
input.eventId,
|
|
55
|
+
)}`;
|
|
56
|
+
const res = await outlookFetch(ctx.fetch, "getEvent", url);
|
|
57
|
+
return parseGraphResponse(res);
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export default definition;
|
|
62
|
+
|
|
63
|
+
await handleIfScriptMain(import.meta, definition, { connectionResolvers });
|