automate.ax 0.3.0 → 0.4.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/README.md +58 -6
- package/dist/automation/account-planning.d.ts +17 -0
- package/dist/automation/account-planning.d.ts.map +1 -0
- package/dist/automation/account-planning.js +48 -0
- package/dist/automation/actions.d.ts.map +1 -1
- package/dist/automation/actions.js +3 -36
- package/dist/automation/runtime.d.ts +5 -5
- package/dist/automation/runtime.d.ts.map +1 -1
- package/dist/automation/runtime.js +5 -4
- package/dist/cli/lib/api-client.d.ts +2 -2
- package/dist/cli/lib/api-client.d.ts.map +1 -1
- package/dist/cli/usage.d.ts +2 -1
- package/dist/cli/usage.d.ts.map +1 -1
- package/dist/cli/usage.js +2 -1
- package/dist/components/core/actions.d.ts +29 -0
- package/dist/components/core/actions.d.ts.map +1 -0
- package/dist/components/core/actions.js +57 -0
- package/dist/components/core/index.d.ts +3 -0
- package/dist/components/core/index.d.ts.map +1 -0
- package/dist/components/core/index.js +2 -0
- package/dist/components/core/triggers.d.ts +21 -0
- package/dist/components/core/triggers.d.ts.map +1 -0
- package/dist/components/core/triggers.js +9 -0
- package/dist/components/gmail/actions/add-label.d.ts +12 -0
- package/dist/components/gmail/actions/add-label.d.ts.map +1 -0
- package/dist/components/gmail/actions/add-label.js +33 -0
- package/dist/components/gmail/actions/archive.d.ts +9 -0
- package/dist/components/gmail/actions/archive.d.ts.map +1 -0
- package/dist/components/gmail/actions/archive.js +7 -0
- package/dist/components/gmail/actions/create-label.d.ts +43 -0
- package/dist/components/gmail/actions/create-label.d.ts.map +1 -0
- package/dist/components/gmail/actions/create-label.js +27 -0
- package/dist/components/gmail/actions/delete-draft.d.ts +6 -0
- package/dist/components/gmail/actions/delete-draft.d.ts.map +1 -0
- package/dist/components/gmail/actions/delete-draft.js +20 -0
- package/dist/components/gmail/actions/delete-label.d.ts +6 -0
- package/dist/components/gmail/actions/delete-label.d.ts.map +1 -0
- package/dist/components/gmail/actions/delete-label.js +22 -0
- package/dist/components/gmail/actions/draft-email.d.ts +66 -0
- package/dist/components/gmail/actions/draft-email.d.ts.map +1 -0
- package/dist/components/gmail/actions/draft-email.js +32 -0
- package/dist/components/gmail/actions/draft-reply.d.ts +67 -0
- package/dist/components/gmail/actions/draft-reply.d.ts.map +1 -0
- package/dist/components/gmail/actions/draft-reply.js +42 -0
- package/dist/components/gmail/actions/forward.d.ts +67 -0
- package/dist/components/gmail/actions/forward.d.ts.map +1 -0
- package/dist/components/gmail/actions/forward.js +130 -0
- package/dist/components/gmail/actions/get-draft.d.ts +66 -0
- package/dist/components/gmail/actions/get-draft.d.ts.map +1 -0
- package/dist/components/gmail/actions/get-draft.js +28 -0
- package/dist/components/gmail/actions/get-message.d.ts +68 -0
- package/dist/components/gmail/actions/get-message.d.ts.map +1 -0
- package/dist/components/gmail/actions/get-message.js +24 -0
- package/dist/components/gmail/actions/get-messages.d.ts +63 -0
- package/dist/components/gmail/actions/get-messages.d.ts.map +1 -0
- package/dist/components/gmail/actions/get-messages.js +23 -0
- package/dist/components/gmail/actions/get-profile.d.ts +8 -0
- package/dist/components/gmail/actions/get-profile.d.ts.map +1 -0
- package/dist/components/gmail/actions/get-profile.js +23 -0
- package/dist/components/gmail/actions/get-raw-message.d.ts +11 -0
- package/dist/components/gmail/actions/get-raw-message.d.ts.map +1 -0
- package/dist/components/gmail/actions/get-raw-message.js +28 -0
- package/dist/components/gmail/actions/get-thread.d.ts +67 -0
- package/dist/components/gmail/actions/get-thread.d.ts.map +1 -0
- package/dist/components/gmail/actions/get-thread.js +28 -0
- package/dist/components/gmail/actions/has-label.d.ts +7 -0
- package/dist/components/gmail/actions/has-label.d.ts.map +1 -0
- package/dist/components/gmail/actions/has-label.js +23 -0
- package/dist/components/gmail/actions/index.d.ts +42 -0
- package/dist/components/gmail/actions/index.d.ts.map +1 -0
- package/dist/components/gmail/actions/index.js +41 -0
- package/dist/components/gmail/actions/is-important.d.ts +5 -0
- package/dist/components/gmail/actions/is-important.d.ts.map +1 -0
- package/dist/components/gmail/actions/is-important.js +3 -0
- package/dist/components/gmail/actions/is-starred.d.ts +5 -0
- package/dist/components/gmail/actions/is-starred.d.ts.map +1 -0
- package/dist/components/gmail/actions/is-starred.js +3 -0
- package/dist/components/gmail/actions/is-unread.d.ts +5 -0
- package/dist/components/gmail/actions/is-unread.d.ts.map +1 -0
- package/dist/components/gmail/actions/is-unread.js +3 -0
- package/dist/components/gmail/actions/list-labels.d.ts +27 -0
- package/dist/components/gmail/actions/list-labels.d.ts.map +1 -0
- package/dist/components/gmail/actions/list-labels.js +15 -0
- package/dist/components/gmail/actions/mark-as-important.d.ts +5 -0
- package/dist/components/gmail/actions/mark-as-important.d.ts.map +1 -0
- package/dist/components/gmail/actions/mark-as-important.js +3 -0
- package/dist/components/gmail/actions/mark-as-not-spam.d.ts +5 -0
- package/dist/components/gmail/actions/mark-as-not-spam.d.ts.map +1 -0
- package/dist/components/gmail/actions/mark-as-not-spam.js +3 -0
- package/dist/components/gmail/actions/mark-as-read.d.ts +5 -0
- package/dist/components/gmail/actions/mark-as-read.d.ts.map +1 -0
- package/dist/components/gmail/actions/mark-as-read.js +3 -0
- package/dist/components/gmail/actions/mark-as-spam.d.ts +5 -0
- package/dist/components/gmail/actions/mark-as-spam.d.ts.map +1 -0
- package/dist/components/gmail/actions/mark-as-spam.js +3 -0
- package/dist/components/gmail/actions/mark-as-unread.d.ts +5 -0
- package/dist/components/gmail/actions/mark-as-unread.d.ts.map +1 -0
- package/dist/components/gmail/actions/mark-as-unread.js +3 -0
- package/dist/components/gmail/actions/modify-labels.d.ts +12 -0
- package/dist/components/gmail/actions/modify-labels.d.ts.map +1 -0
- package/dist/components/gmail/actions/modify-labels.js +41 -0
- package/dist/components/gmail/actions/move-to-inbox.d.ts +5 -0
- package/dist/components/gmail/actions/move-to-inbox.d.ts.map +1 -0
- package/dist/components/gmail/actions/move-to-inbox.js +3 -0
- package/dist/components/gmail/actions/remove-label.d.ts +12 -0
- package/dist/components/gmail/actions/remove-label.d.ts.map +1 -0
- package/dist/components/gmail/actions/remove-label.js +33 -0
- package/dist/components/gmail/actions/reply-thread.d.ts +65 -0
- package/dist/components/gmail/actions/reply-thread.d.ts.map +1 -0
- package/dist/components/gmail/actions/reply-thread.js +35 -0
- package/dist/components/gmail/actions/reply.d.ts +66 -0
- package/dist/components/gmail/actions/reply.d.ts.map +1 -0
- package/dist/components/gmail/actions/reply.js +23 -0
- package/dist/components/gmail/actions/search-drafts.d.ts +18 -0
- package/dist/components/gmail/actions/search-drafts.d.ts.map +1 -0
- package/dist/components/gmail/actions/search-drafts.js +50 -0
- package/dist/components/gmail/actions/search-messages.d.ts +16 -0
- package/dist/components/gmail/actions/search-messages.d.ts.map +1 -0
- package/dist/components/gmail/actions/search-messages.js +45 -0
- package/dist/components/gmail/actions/search-threads.d.ts +15 -0
- package/dist/components/gmail/actions/search-threads.d.ts.map +1 -0
- package/dist/components/gmail/actions/search-threads.js +43 -0
- package/dist/components/gmail/actions/send-draft.d.ts +11 -0
- package/dist/components/gmail/actions/send-draft.d.ts.map +1 -0
- package/dist/components/gmail/actions/send-draft.js +18 -0
- package/dist/components/gmail/actions/send-email.d.ts +65 -0
- package/dist/components/gmail/actions/send-email.d.ts.map +1 -0
- package/dist/components/gmail/actions/send-email.js +35 -0
- package/dist/components/gmail/actions/star.d.ts +5 -0
- package/dist/components/gmail/actions/star.d.ts.map +1 -0
- package/dist/components/gmail/actions/star.js +3 -0
- package/dist/components/gmail/actions/trash.d.ts +15 -0
- package/dist/components/gmail/actions/trash.d.ts.map +1 -0
- package/dist/components/gmail/actions/trash.js +26 -0
- package/dist/components/gmail/actions/unmark-as-important.d.ts +5 -0
- package/dist/components/gmail/actions/unmark-as-important.d.ts.map +1 -0
- package/dist/components/gmail/actions/unmark-as-important.js +3 -0
- package/dist/components/gmail/actions/unstar.d.ts +5 -0
- package/dist/components/gmail/actions/unstar.d.ts.map +1 -0
- package/dist/components/gmail/actions/unstar.js +3 -0
- package/dist/components/gmail/actions/untrash.d.ts +15 -0
- package/dist/components/gmail/actions/untrash.d.ts.map +1 -0
- package/dist/components/gmail/actions/untrash.js +26 -0
- package/dist/components/gmail/actions/update-draft.d.ts +67 -0
- package/dist/components/gmail/actions/update-draft.d.ts.map +1 -0
- package/dist/components/gmail/actions/update-draft.js +67 -0
- package/dist/components/gmail/actions/update-label.d.ts +44 -0
- package/dist/components/gmail/actions/update-label.d.ts.map +1 -0
- package/dist/components/gmail/actions/update-label.js +38 -0
- package/dist/components/gmail/index.d.ts +5 -0
- package/dist/components/gmail/index.d.ts.map +1 -0
- package/dist/components/gmail/index.js +4 -0
- package/dist/components/gmail/lib/action-factories.d.ts +27 -0
- package/dist/components/gmail/lib/action-factories.d.ts.map +1 -0
- package/dist/components/gmail/lib/action-factories.js +55 -0
- package/dist/components/gmail/lib/gmail.d.ts +178 -0
- package/dist/components/gmail/lib/gmail.d.ts.map +1 -0
- package/dist/components/gmail/lib/gmail.js +411 -0
- package/dist/components/gmail/lib/schemas.d.ts +380 -0
- package/dist/components/gmail/lib/schemas.d.ts.map +1 -0
- package/dist/components/gmail/lib/schemas.js +226 -0
- package/dist/components/gmail/lib/scopes.d.ts +10 -0
- package/dist/components/gmail/lib/scopes.d.ts.map +1 -0
- package/dist/components/gmail/lib/scopes.js +16 -0
- package/dist/components/gmail/triggers/index.d.ts +2 -0
- package/dist/components/gmail/triggers/index.d.ts.map +1 -0
- package/dist/components/gmail/triggers/index.js +1 -0
- package/dist/components/gmail/triggers/on-new-email.d.ts +75 -0
- package/dist/components/gmail/triggers/on-new-email.d.ts.map +1 -0
- package/dist/components/gmail/triggers/on-new-email.js +30 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +26 -6
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { findLabelIds, getGmailApi, normalizeMessageIds } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { MESSAGE_IDS_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Adds and removes multiple Gmail labels in one batch request.
|
|
8
|
+
*
|
|
9
|
+
* Label display names and immutable IDs may be mixed in either list.
|
|
10
|
+
*/
|
|
11
|
+
export const modifyLabels = defineAction("Modify Gmail labels")
|
|
12
|
+
.describe("Adds and removes Gmail labels in one batch request.")
|
|
13
|
+
.account("google", GMAIL_MODIFY_REQUIREMENT)
|
|
14
|
+
.input(z
|
|
15
|
+
.object({
|
|
16
|
+
/** Label names or IDs to add. */
|
|
17
|
+
add: z.string().min(1).array().optional(),
|
|
18
|
+
/** One ID or up to 1,000 immutable Gmail message IDs. */
|
|
19
|
+
messageIds: MESSAGE_IDS_SCHEMA,
|
|
20
|
+
/** Label names or IDs to remove. */
|
|
21
|
+
remove: z.string().min(1).array().optional(),
|
|
22
|
+
})
|
|
23
|
+
.refine((input) => Boolean(input.add?.length || input.remove?.length), "At least one label must be added or removed."))
|
|
24
|
+
.output(z.string().array())
|
|
25
|
+
.handler(async ({ account, input }) => {
|
|
26
|
+
const gmailApi = getGmailApi(account.secret);
|
|
27
|
+
const labelIds = await findLabelIds(gmailApi, [
|
|
28
|
+
...(input.add ?? []),
|
|
29
|
+
...(input.remove ?? []),
|
|
30
|
+
]);
|
|
31
|
+
const messageIds = normalizeMessageIds(input.messageIds);
|
|
32
|
+
await gmailApi.users.messages.batchModify({
|
|
33
|
+
requestBody: {
|
|
34
|
+
addLabelIds: labelIds.slice(0, input.add?.length ?? 0),
|
|
35
|
+
ids: messageIds,
|
|
36
|
+
removeLabelIds: labelIds.slice(input.add?.length ?? 0),
|
|
37
|
+
},
|
|
38
|
+
userId: "me",
|
|
39
|
+
});
|
|
40
|
+
return messageIds;
|
|
41
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Moves one or many Gmail messages into the inbox. */
|
|
2
|
+
export declare const moveToInbox: import("../../..").DefinedAction<import("zod").ZodObject<{
|
|
3
|
+
messageIds: import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>;
|
|
4
|
+
}, import("zod/v4/core").$strip>, import("zod").ZodArray<import("zod").ZodString>, "google">;
|
|
5
|
+
//# sourceMappingURL=move-to-inbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"move-to-inbox.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/move-to-inbox.ts"],"names":[],"mappings":"AAEA,uDAAuD;AACvD,eAAO,MAAM,WAAW;;4FAIvB,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { defineMessageLabelMutation } from "../lib/action-factories.js";
|
|
2
|
+
/** Moves one or many Gmail messages into the inbox. */
|
|
3
|
+
export const moveToInbox = defineMessageLabelMutation("Move Gmail messages to inbox", "Adds Gmail's Inbox label to messages.", { addLabelIds: ["INBOX"] });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Removes one Gmail label from one or many messages.
|
|
4
|
+
*
|
|
5
|
+
* Accepts a label display name or immutable label ID and returns the modified
|
|
6
|
+
* message IDs for action chaining.
|
|
7
|
+
*/
|
|
8
|
+
export declare const removeLabel: import("../../..").DefinedAction<z.ZodObject<{
|
|
9
|
+
label: z.ZodString;
|
|
10
|
+
messageIds: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
11
|
+
}, z.core.$strip>, z.ZodArray<z.ZodString>, "google">;
|
|
12
|
+
//# sourceMappingURL=remove-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remove-label.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/remove-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;qDAwBpB,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { findLabelId, getGmailApi, normalizeMessageIds } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { MESSAGE_IDS_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Removes one Gmail label from one or many messages.
|
|
8
|
+
*
|
|
9
|
+
* Accepts a label display name or immutable label ID and returns the modified
|
|
10
|
+
* message IDs for action chaining.
|
|
11
|
+
*/
|
|
12
|
+
export const removeLabel = defineAction("Remove Gmail label")
|
|
13
|
+
.describe("Removes a Gmail label from one or many messages.")
|
|
14
|
+
.account("google", GMAIL_MODIFY_REQUIREMENT)
|
|
15
|
+
.input(z.object({
|
|
16
|
+
/** Gmail label display name or immutable ID. */
|
|
17
|
+
label: z.string().min(1),
|
|
18
|
+
/** One ID or up to 1,000 immutable Gmail message IDs. */
|
|
19
|
+
messageIds: MESSAGE_IDS_SCHEMA,
|
|
20
|
+
}))
|
|
21
|
+
.output(z.string().array())
|
|
22
|
+
.handler(async ({ account, input }) => {
|
|
23
|
+
const gmailApi = getGmailApi(account.secret);
|
|
24
|
+
const messageIds = normalizeMessageIds(input.messageIds);
|
|
25
|
+
await gmailApi.users.messages.batchModify({
|
|
26
|
+
requestBody: {
|
|
27
|
+
ids: messageIds,
|
|
28
|
+
removeLabelIds: [await findLabelId(gmailApi, input.label)],
|
|
29
|
+
},
|
|
30
|
+
userId: "me",
|
|
31
|
+
});
|
|
32
|
+
return messageIds;
|
|
33
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Replies to the latest received message in a Gmail thread.
|
|
4
|
+
*
|
|
5
|
+
* Sent messages are ignored, so archived conversations remain replyable.
|
|
6
|
+
*/
|
|
7
|
+
export declare const replyThread: import("../../..").DefinedAction<z.ZodObject<{
|
|
8
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodObject<{
|
|
9
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
10
|
+
disposition: z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
attachment: "attachment";
|
|
12
|
+
inline: "inline";
|
|
13
|
+
}>>;
|
|
14
|
+
file: z.ZodCustom<File, File>;
|
|
15
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>]>>>;
|
|
17
|
+
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
18
|
+
address: z.ZodString;
|
|
19
|
+
name: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
21
|
+
address: z.ZodString;
|
|
22
|
+
name: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>]>>]>>;
|
|
24
|
+
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
25
|
+
address: z.ZodString;
|
|
26
|
+
name: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
28
|
+
address: z.ZodString;
|
|
29
|
+
name: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>]>>]>>;
|
|
31
|
+
from: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
32
|
+
address: z.ZodString;
|
|
33
|
+
name: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>]>>;
|
|
35
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
36
|
+
html: z.ZodOptional<z.ZodString>;
|
|
37
|
+
priority: z.ZodOptional<z.ZodEnum<{
|
|
38
|
+
high: "high";
|
|
39
|
+
normal: "normal";
|
|
40
|
+
low: "low";
|
|
41
|
+
}>>;
|
|
42
|
+
replyAll: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
replyTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
44
|
+
address: z.ZodString;
|
|
45
|
+
name: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
47
|
+
address: z.ZodString;
|
|
48
|
+
name: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>]>>]>>;
|
|
50
|
+
text: z.ZodOptional<z.ZodString>;
|
|
51
|
+
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
52
|
+
address: z.ZodString;
|
|
53
|
+
name: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
55
|
+
address: z.ZodString;
|
|
56
|
+
name: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>]>>]>>;
|
|
58
|
+
threadId: z.ZodString;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
messageId: z.ZodString;
|
|
61
|
+
threadId: z.ZodString;
|
|
62
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>, "google">;
|
|
65
|
+
//# sourceMappingURL=reply-thread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply-thread.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/reply-thread.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA+BpB,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi, sendReply } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_SEND_AND_METADATA_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { MESSAGE_METADATA_SCHEMA, REPLY_OPTIONS_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Replies to the latest received message in a Gmail thread.
|
|
8
|
+
*
|
|
9
|
+
* Sent messages are ignored, so archived conversations remain replyable.
|
|
10
|
+
*/
|
|
11
|
+
export const replyThread = defineAction("Reply to Gmail thread")
|
|
12
|
+
.describe("Replies to the latest received message in a Gmail thread.")
|
|
13
|
+
.account("google", GMAIL_SEND_AND_METADATA_REQUIREMENT)
|
|
14
|
+
.input(REPLY_OPTIONS_SCHEMA.extend({
|
|
15
|
+
/** Immutable Gmail thread ID receiving the reply. */
|
|
16
|
+
threadId: z.string().min(1),
|
|
17
|
+
}))
|
|
18
|
+
.output(MESSAGE_METADATA_SCHEMA)
|
|
19
|
+
.handler(async ({ account, input }) => {
|
|
20
|
+
const gmailApi = getGmailApi(account.secret);
|
|
21
|
+
const latestReceivedMessage = [
|
|
22
|
+
...((await gmailApi.users.threads.get({
|
|
23
|
+
format: "metadata",
|
|
24
|
+
id: input.threadId,
|
|
25
|
+
userId: "me",
|
|
26
|
+
})).data.messages ?? []),
|
|
27
|
+
]
|
|
28
|
+
.filter((message) => !message.labelIds?.includes("SENT"))
|
|
29
|
+
.toSorted((a, b) => Number(b.internalDate ?? "0") - Number(a.internalDate ?? "0"))
|
|
30
|
+
.at(0);
|
|
31
|
+
if (!latestReceivedMessage) {
|
|
32
|
+
throw new Error("Gmail thread has no received messages to reply to.");
|
|
33
|
+
}
|
|
34
|
+
return await sendReply(gmailApi, latestReceivedMessage, input);
|
|
35
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Replies to one Gmail message.
|
|
4
|
+
*
|
|
5
|
+
* Gmail derives the conversation headers and primary recipient. Optional To,
|
|
6
|
+
* Cc, and Bcc values add recipients to the outgoing reply.
|
|
7
|
+
*/
|
|
8
|
+
export declare const reply: import("../../..").DefinedAction<z.ZodObject<{
|
|
9
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodObject<{
|
|
10
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
disposition: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
attachment: "attachment";
|
|
13
|
+
inline: "inline";
|
|
14
|
+
}>>;
|
|
15
|
+
file: z.ZodCustom<File, File>;
|
|
16
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>]>>>;
|
|
18
|
+
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
19
|
+
address: z.ZodString;
|
|
20
|
+
name: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
22
|
+
address: z.ZodString;
|
|
23
|
+
name: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>]>>]>>;
|
|
25
|
+
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
26
|
+
address: z.ZodString;
|
|
27
|
+
name: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
29
|
+
address: z.ZodString;
|
|
30
|
+
name: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>]>>]>>;
|
|
32
|
+
from: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
33
|
+
address: z.ZodString;
|
|
34
|
+
name: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>]>>;
|
|
36
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
37
|
+
html: z.ZodOptional<z.ZodString>;
|
|
38
|
+
priority: z.ZodOptional<z.ZodEnum<{
|
|
39
|
+
high: "high";
|
|
40
|
+
normal: "normal";
|
|
41
|
+
low: "low";
|
|
42
|
+
}>>;
|
|
43
|
+
replyAll: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
replyTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
45
|
+
address: z.ZodString;
|
|
46
|
+
name: z.ZodOptional<z.ZodString>;
|
|
47
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
48
|
+
address: z.ZodString;
|
|
49
|
+
name: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>]>>]>>;
|
|
51
|
+
text: z.ZodOptional<z.ZodString>;
|
|
52
|
+
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
53
|
+
address: z.ZodString;
|
|
54
|
+
name: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
56
|
+
address: z.ZodString;
|
|
57
|
+
name: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>]>>]>>;
|
|
59
|
+
messageId: z.ZodString;
|
|
60
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
61
|
+
messageId: z.ZodString;
|
|
62
|
+
threadId: z.ZodString;
|
|
63
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
64
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>, "google">;
|
|
66
|
+
//# sourceMappingURL=reply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/reply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;;GAKG;AACH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAiBd,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi, getMessageMetadata, sendReply } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_SEND_AND_METADATA_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { MESSAGE_METADATA_SCHEMA, REPLY_OPTIONS_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Replies to one Gmail message.
|
|
8
|
+
*
|
|
9
|
+
* Gmail derives the conversation headers and primary recipient. Optional To,
|
|
10
|
+
* Cc, and Bcc values add recipients to the outgoing reply.
|
|
11
|
+
*/
|
|
12
|
+
export const reply = defineAction("Reply to Gmail message")
|
|
13
|
+
.describe("Replies to a Gmail message with optional additional recipients.")
|
|
14
|
+
.account("google", GMAIL_SEND_AND_METADATA_REQUIREMENT)
|
|
15
|
+
.input(REPLY_OPTIONS_SCHEMA.extend({
|
|
16
|
+
/** Immutable Gmail message ID receiving the reply. */
|
|
17
|
+
messageId: z.string().min(1),
|
|
18
|
+
}))
|
|
19
|
+
.output(MESSAGE_METADATA_SCHEMA)
|
|
20
|
+
.handler(async ({ account, input }) => {
|
|
21
|
+
const gmailApi = getGmailApi(account.secret);
|
|
22
|
+
return await sendReply(gmailApi, await getMessageMetadata(gmailApi, input.messageId), input);
|
|
23
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Searches Gmail drafts using Gmail's standard query syntax.
|
|
4
|
+
*
|
|
5
|
+
* Pagination is handled internally until the requested total limit is reached.
|
|
6
|
+
*/
|
|
7
|
+
export declare const searchDrafts: import("../../..").DefinedAction<z.ZodObject<{
|
|
8
|
+
includeSpamTrash: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
query: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
12
|
+
messageId: z.ZodString;
|
|
13
|
+
threadId: z.ZodString;
|
|
14
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
16
|
+
draftId: z.ZodString;
|
|
17
|
+
}, z.core.$strip>>, "google">;
|
|
18
|
+
//# sourceMappingURL=search-drafts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-drafts.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/search-drafts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;6BAiDrB,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_READ_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { DRAFT_IDENTIFIER_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Searches Gmail drafts using Gmail's standard query syntax.
|
|
8
|
+
*
|
|
9
|
+
* Pagination is handled internally until the requested total limit is reached.
|
|
10
|
+
*/
|
|
11
|
+
export const searchDrafts = defineAction("Search Gmail drafts")
|
|
12
|
+
.describe("Searches Gmail drafts and returns their stable identities.")
|
|
13
|
+
.account("google", GMAIL_READ_REQUIREMENT)
|
|
14
|
+
.input(z.object({
|
|
15
|
+
/** Whether drafts in Spam and Trash may match. */
|
|
16
|
+
includeSpamTrash: z.boolean().optional(),
|
|
17
|
+
/** Maximum total results returned across internally fetched pages. */
|
|
18
|
+
limit: z.number().int().min(1).max(10_000).optional(),
|
|
19
|
+
/** Standard Gmail search-box query. */
|
|
20
|
+
query: z.string().optional(),
|
|
21
|
+
}))
|
|
22
|
+
.output(DRAFT_IDENTIFIER_SCHEMA.array())
|
|
23
|
+
.handler(async ({ account, input }) => {
|
|
24
|
+
const gmailApi = getGmailApi(account.secret);
|
|
25
|
+
const limit = input.limit ?? 100;
|
|
26
|
+
const drafts = [];
|
|
27
|
+
let pageToken;
|
|
28
|
+
do {
|
|
29
|
+
const { data } = await gmailApi.users.drafts.list({
|
|
30
|
+
includeSpamTrash: input.includeSpamTrash ?? false,
|
|
31
|
+
maxResults: Math.min(500, limit - drafts.length),
|
|
32
|
+
pageToken,
|
|
33
|
+
q: input.query,
|
|
34
|
+
userId: "me",
|
|
35
|
+
});
|
|
36
|
+
drafts.push(...(data.drafts ?? []).flatMap((draft) => draft.id && draft.message?.id && draft.message.threadId
|
|
37
|
+
? [
|
|
38
|
+
{
|
|
39
|
+
draftId: draft.id,
|
|
40
|
+
historyId: draft.message.historyId ?? undefined,
|
|
41
|
+
labelIds: draft.message.labelIds ?? [],
|
|
42
|
+
messageId: draft.message.id,
|
|
43
|
+
threadId: draft.message.threadId,
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
: []));
|
|
47
|
+
pageToken = data.nextPageToken ?? undefined;
|
|
48
|
+
} while (pageToken && drafts.length < limit);
|
|
49
|
+
return drafts.slice(0, limit);
|
|
50
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Searches Gmail messages using Gmail's standard query syntax.
|
|
4
|
+
*
|
|
5
|
+
* Pagination is handled internally until the requested total limit is reached.
|
|
6
|
+
*/
|
|
7
|
+
export declare const searchMessages: import("../../..").DefinedAction<z.ZodObject<{
|
|
8
|
+
includeSpamTrash: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
query: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
13
|
+
messageId: z.ZodString;
|
|
14
|
+
threadId: z.ZodString;
|
|
15
|
+
}, z.core.$strip>>, "google">;
|
|
16
|
+
//# sourceMappingURL=search-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-messages.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/search-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;;6BA6CvB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_READ_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { MESSAGE_IDENTIFIER_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Searches Gmail messages using Gmail's standard query syntax.
|
|
8
|
+
*
|
|
9
|
+
* Pagination is handled internally until the requested total limit is reached.
|
|
10
|
+
*/
|
|
11
|
+
export const searchMessages = defineAction("Search Gmail messages")
|
|
12
|
+
.describe("Searches Gmail and returns matching message and thread IDs.")
|
|
13
|
+
.account("google", GMAIL_READ_REQUIREMENT)
|
|
14
|
+
.input(z.object({
|
|
15
|
+
/** Whether messages in Spam and Trash may match. */
|
|
16
|
+
includeSpamTrash: z.boolean().optional(),
|
|
17
|
+
/** Label IDs that every returned message must carry. */
|
|
18
|
+
labelIds: z.string().min(1).array().optional(),
|
|
19
|
+
/** Maximum total results returned across internally fetched pages. */
|
|
20
|
+
limit: z.number().int().min(1).max(10_000).optional(),
|
|
21
|
+
/** Standard Gmail search-box query. */
|
|
22
|
+
query: z.string().optional(),
|
|
23
|
+
}))
|
|
24
|
+
.output(MESSAGE_IDENTIFIER_SCHEMA.array())
|
|
25
|
+
.handler(async ({ account, input }) => {
|
|
26
|
+
const gmailApi = getGmailApi(account.secret);
|
|
27
|
+
const limit = input.limit ?? 100;
|
|
28
|
+
const messages = [];
|
|
29
|
+
let pageToken;
|
|
30
|
+
do {
|
|
31
|
+
const { data } = await gmailApi.users.messages.list({
|
|
32
|
+
includeSpamTrash: input.includeSpamTrash ?? false,
|
|
33
|
+
labelIds: input.labelIds,
|
|
34
|
+
maxResults: Math.min(500, limit - messages.length),
|
|
35
|
+
pageToken,
|
|
36
|
+
q: input.query,
|
|
37
|
+
userId: "me",
|
|
38
|
+
});
|
|
39
|
+
messages.push(...(data.messages ?? []).flatMap((message) => message.id && message.threadId
|
|
40
|
+
? [{ messageId: message.id, threadId: message.threadId }]
|
|
41
|
+
: []));
|
|
42
|
+
pageToken = data.nextPageToken ?? undefined;
|
|
43
|
+
} while (pageToken && messages.length < limit);
|
|
44
|
+
return messages.slice(0, limit);
|
|
45
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Searches Gmail threads using Gmail's standard query syntax.
|
|
4
|
+
*
|
|
5
|
+
* Pagination is handled internally until the requested total limit is reached.
|
|
6
|
+
*/
|
|
7
|
+
export declare const searchThreads: import("../../..").DefinedAction<z.ZodObject<{
|
|
8
|
+
includeSpamTrash: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
query: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
13
|
+
threadId: z.ZodString;
|
|
14
|
+
}, z.core.$strip>>, "google">;
|
|
15
|
+
//# sourceMappingURL=search-threads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-threads.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/search-threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;6BA2CtB,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_READ_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { THREAD_IDENTIFIER_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Searches Gmail threads using Gmail's standard query syntax.
|
|
8
|
+
*
|
|
9
|
+
* Pagination is handled internally until the requested total limit is reached.
|
|
10
|
+
*/
|
|
11
|
+
export const searchThreads = defineAction("Search Gmail threads")
|
|
12
|
+
.describe("Searches Gmail and returns matching thread IDs.")
|
|
13
|
+
.account("google", GMAIL_READ_REQUIREMENT)
|
|
14
|
+
.input(z.object({
|
|
15
|
+
/** Whether threads in Spam and Trash may match. */
|
|
16
|
+
includeSpamTrash: z.boolean().optional(),
|
|
17
|
+
/** Label IDs that every returned thread must carry. */
|
|
18
|
+
labelIds: z.string().min(1).array().optional(),
|
|
19
|
+
/** Maximum total results returned across internally fetched pages. */
|
|
20
|
+
limit: z.number().int().min(1).max(10_000).optional(),
|
|
21
|
+
/** Standard Gmail search-box query. */
|
|
22
|
+
query: z.string().optional(),
|
|
23
|
+
}))
|
|
24
|
+
.output(THREAD_IDENTIFIER_SCHEMA.array())
|
|
25
|
+
.handler(async ({ account, input }) => {
|
|
26
|
+
const gmailApi = getGmailApi(account.secret);
|
|
27
|
+
const limit = input.limit ?? 100;
|
|
28
|
+
const threads = [];
|
|
29
|
+
let pageToken;
|
|
30
|
+
do {
|
|
31
|
+
const { data } = await gmailApi.users.threads.list({
|
|
32
|
+
includeSpamTrash: input.includeSpamTrash ?? false,
|
|
33
|
+
labelIds: input.labelIds,
|
|
34
|
+
maxResults: Math.min(500, limit - threads.length),
|
|
35
|
+
pageToken,
|
|
36
|
+
q: input.query,
|
|
37
|
+
userId: "me",
|
|
38
|
+
});
|
|
39
|
+
threads.push(...(data.threads ?? []).flatMap((thread) => thread.id ? [{ threadId: thread.id }] : []));
|
|
40
|
+
pageToken = data.nextPageToken ?? undefined;
|
|
41
|
+
} while (pageToken && threads.length < limit);
|
|
42
|
+
return threads.slice(0, limit);
|
|
43
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Sends an existing Gmail draft and returns the sent message metadata. */
|
|
3
|
+
export declare const sendDraft: import("../../..").DefinedAction<z.ZodObject<{
|
|
4
|
+
draftId: z.ZodString;
|
|
5
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6
|
+
messageId: z.ZodString;
|
|
7
|
+
threadId: z.ZodString;
|
|
8
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
9
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>, "google">;
|
|
11
|
+
//# sourceMappingURL=send-draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-draft.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/send-draft.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,2EAA2E;AAC3E,eAAO,MAAM,SAAS;;;;;;;4BAoBnB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi, toMessageMetadata } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_SEND_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { MESSAGE_METADATA_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/** Sends an existing Gmail draft and returns the sent message metadata. */
|
|
7
|
+
export const sendDraft = defineAction("Send Gmail draft")
|
|
8
|
+
.describe("Sends an existing Gmail draft.")
|
|
9
|
+
.account("google", GMAIL_SEND_REQUIREMENT)
|
|
10
|
+
.input(z.object({
|
|
11
|
+
/** Immutable Gmail draft ID to send. */
|
|
12
|
+
draftId: z.string().min(1),
|
|
13
|
+
}))
|
|
14
|
+
.output(MESSAGE_METADATA_SCHEMA)
|
|
15
|
+
.handler(async ({ account, input }) => toMessageMetadata((await getGmailApi(account.secret).users.drafts.send({
|
|
16
|
+
requestBody: { id: input.draftId },
|
|
17
|
+
userId: "me",
|
|
18
|
+
})).data, "sent draft"));
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Sends a new Gmail message.
|
|
4
|
+
*
|
|
5
|
+
* Supports named recipients, send-as aliases, custom headers, priority, inline
|
|
6
|
+
* attachments, and automatic plain text derived from HTML.
|
|
7
|
+
*/
|
|
8
|
+
export declare const sendEmail: import("../../..").DefinedAction<z.ZodObject<{
|
|
9
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodObject<{
|
|
10
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
disposition: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
attachment: "attachment";
|
|
13
|
+
inline: "inline";
|
|
14
|
+
}>>;
|
|
15
|
+
file: z.ZodCustom<File, File>;
|
|
16
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, z.core.$strip>]>>>;
|
|
18
|
+
bcc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
19
|
+
address: z.ZodString;
|
|
20
|
+
name: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
22
|
+
address: z.ZodString;
|
|
23
|
+
name: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>]>>]>>;
|
|
25
|
+
cc: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
26
|
+
address: z.ZodString;
|
|
27
|
+
name: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
29
|
+
address: z.ZodString;
|
|
30
|
+
name: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>]>>]>>;
|
|
32
|
+
from: z.ZodOptional<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
33
|
+
address: z.ZodString;
|
|
34
|
+
name: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.core.$strip>]>>;
|
|
36
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
37
|
+
priority: z.ZodOptional<z.ZodEnum<{
|
|
38
|
+
high: "high";
|
|
39
|
+
normal: "normal";
|
|
40
|
+
low: "low";
|
|
41
|
+
}>>;
|
|
42
|
+
replyTo: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
43
|
+
address: z.ZodString;
|
|
44
|
+
name: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
46
|
+
address: z.ZodString;
|
|
47
|
+
name: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>]>>]>>;
|
|
49
|
+
html: z.ZodOptional<z.ZodString>;
|
|
50
|
+
subject: z.ZodString;
|
|
51
|
+
text: z.ZodOptional<z.ZodString>;
|
|
52
|
+
to: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
53
|
+
address: z.ZodString;
|
|
54
|
+
name: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
56
|
+
address: z.ZodString;
|
|
57
|
+
name: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>]>>]>;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
60
|
+
messageId: z.ZodString;
|
|
61
|
+
threadId: z.ZodString;
|
|
62
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
63
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
64
|
+
}, z.core.$strip>, "google">;
|
|
65
|
+
//# sourceMappingURL=send-email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-email.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/send-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB;;;;;GAKG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAsCnB,CAAA"}
|