automate.ax 0.3.1 → 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/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,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new Gmail draft.
|
|
4
|
+
*
|
|
5
|
+
* Recipients, subject, and body are optional so incomplete drafts remain valid.
|
|
6
|
+
* Plain text is derived automatically when only HTML is supplied.
|
|
7
|
+
*/
|
|
8
|
+
export declare const draftEmail: 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
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
50
|
+
to: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
51
|
+
address: z.ZodString;
|
|
52
|
+
name: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
54
|
+
address: z.ZodString;
|
|
55
|
+
name: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, z.core.$strip>]>>]>>;
|
|
57
|
+
html: z.ZodOptional<z.ZodString>;
|
|
58
|
+
text: z.ZodOptional<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
|
+
draftId: z.ZodString;
|
|
65
|
+
}, z.core.$strip>, "google">;
|
|
66
|
+
//# sourceMappingURL=draft-email.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-email.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/draft-email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAyBnB,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { buildRawMessage, getGmailApi, toDraftIdentifier } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_COMPOSE_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { COMPOSE_OPTIONS_SCHEMA, DRAFT_IDENTIFIER_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new Gmail draft.
|
|
8
|
+
*
|
|
9
|
+
* Recipients, subject, and body are optional so incomplete drafts remain valid.
|
|
10
|
+
* Plain text is derived automatically when only HTML is supplied.
|
|
11
|
+
*/
|
|
12
|
+
export const draftEmail = defineAction("Draft Gmail email")
|
|
13
|
+
.describe("Creates an incomplete or ready-to-send Gmail draft.")
|
|
14
|
+
.account("google", GMAIL_COMPOSE_REQUIREMENT)
|
|
15
|
+
.input(COMPOSE_OPTIONS_SCHEMA.extend({
|
|
16
|
+
/** Optional HTML draft body. */
|
|
17
|
+
html: z.string().optional(),
|
|
18
|
+
/** Optional plain-text draft body. */
|
|
19
|
+
text: z.string().optional(),
|
|
20
|
+
}))
|
|
21
|
+
.output(DRAFT_IDENTIFIER_SCHEMA)
|
|
22
|
+
.handler(async ({ account, input }) => {
|
|
23
|
+
const { data: draft } = await getGmailApi(account.secret).users.drafts.create({
|
|
24
|
+
requestBody: {
|
|
25
|
+
message: {
|
|
26
|
+
raw: await buildRawMessage(input),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
userId: "me",
|
|
30
|
+
});
|
|
31
|
+
return toDraftIdentifier(draft, "draft");
|
|
32
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a Gmail reply draft attached to the original conversation.
|
|
4
|
+
*
|
|
5
|
+
* Original recipients are derived from message headers, while optional To, Cc,
|
|
6
|
+
* and Bcc inputs add recipients to the draft.
|
|
7
|
+
*/
|
|
8
|
+
export declare const draftReply: 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
|
+
draftId: z.ZodString;
|
|
66
|
+
}, z.core.$strip>, "google">;
|
|
67
|
+
//# sourceMappingURL=draft-reply.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"draft-reply.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/draft-reply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAavB;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAoCnB,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { buildRawMessage, getGmailApi, getMessageMetadata, getReplyMessageOptions, getReplyOptions, toDraftIdentifier, } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_COMPOSE_AND_METADATA_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { DRAFT_IDENTIFIER_SCHEMA, REPLY_OPTIONS_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Gmail reply draft attached to the original conversation.
|
|
8
|
+
*
|
|
9
|
+
* Original recipients are derived from message headers, while optional To, Cc,
|
|
10
|
+
* and Bcc inputs add recipients to the draft.
|
|
11
|
+
*/
|
|
12
|
+
export const draftReply = defineAction("Draft Gmail reply")
|
|
13
|
+
.describe("Creates a reply draft for a Gmail message.")
|
|
14
|
+
.account("google", GMAIL_COMPOSE_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(DRAFT_IDENTIFIER_SCHEMA)
|
|
20
|
+
.handler(async ({ account, input }) => {
|
|
21
|
+
const gmailApi = getGmailApi(account.secret);
|
|
22
|
+
const reply = await getReplyOptions(gmailApi, await getMessageMetadata(gmailApi, input.messageId), input.replyAll ?? false);
|
|
23
|
+
const { data: draft } = await gmailApi.users.drafts.create({
|
|
24
|
+
requestBody: {
|
|
25
|
+
message: {
|
|
26
|
+
raw: await buildRawMessage({
|
|
27
|
+
...getReplyMessageOptions(reply, input),
|
|
28
|
+
bcc: input.bcc,
|
|
29
|
+
from: input.from,
|
|
30
|
+
headers: input.headers,
|
|
31
|
+
html: input.html,
|
|
32
|
+
priority: input.priority,
|
|
33
|
+
replyTo: input.replyTo,
|
|
34
|
+
text: input.text,
|
|
35
|
+
}),
|
|
36
|
+
threadId: reply.threadId,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
userId: "me",
|
|
40
|
+
});
|
|
41
|
+
return toDraftIdentifier(draft, "reply draft");
|
|
42
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Forwards a Gmail message with optional introductory content.
|
|
4
|
+
*
|
|
5
|
+
* Original attachments are preserved by default. Text and HTML introductions
|
|
6
|
+
* receive the same automatic plain-text fallback as newly composed messages.
|
|
7
|
+
*/
|
|
8
|
+
export declare const forward: 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
|
+
includeAttachments: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
messageId: z.ZodString;
|
|
52
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
53
|
+
text: z.ZodOptional<z.ZodString>;
|
|
54
|
+
to: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
55
|
+
address: z.ZodString;
|
|
56
|
+
name: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>]>, z.ZodArray<z.ZodUnion<readonly [z.ZodEmail, z.ZodObject<{
|
|
58
|
+
address: z.ZodString;
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, z.core.$strip>]>>]>;
|
|
61
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
|
+
messageId: z.ZodString;
|
|
63
|
+
threadId: z.ZodString;
|
|
64
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
65
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>, "google">;
|
|
67
|
+
//# sourceMappingURL=forward.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/forward.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAiBvB;;;;;GAKG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA0HhB,CAAA"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import escapeHtml from "escape-html";
|
|
2
|
+
import { convert } from "html-to-text";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
5
|
+
import { buildRawMessage, formatAddress, getGmailApi, parseRawMessage, toMessageMetadata, } from "../lib/gmail.js";
|
|
6
|
+
import { GMAIL_SEND_AND_READ_REQUIREMENT } from "../lib/scopes.js";
|
|
7
|
+
import { COMPOSE_OPTIONS_SCHEMA, MESSAGE_METADATA_SCHEMA, RECIPIENTS_SCHEMA, } from "../lib/schemas.js";
|
|
8
|
+
/**
|
|
9
|
+
* Forwards a Gmail message with optional introductory content.
|
|
10
|
+
*
|
|
11
|
+
* Original attachments are preserved by default. Text and HTML introductions
|
|
12
|
+
* receive the same automatic plain-text fallback as newly composed messages.
|
|
13
|
+
*/
|
|
14
|
+
export const forward = defineAction("Forward Gmail message")
|
|
15
|
+
.describe("Forwards a Gmail message with optional introductory content.")
|
|
16
|
+
.account("google", GMAIL_SEND_AND_READ_REQUIREMENT)
|
|
17
|
+
.input(COMPOSE_OPTIONS_SCHEMA.extend({
|
|
18
|
+
/** Optional HTML introduction inserted before the forwarded message. */
|
|
19
|
+
html: z.string().optional(),
|
|
20
|
+
/** Whether to preserve the original message's attachments. */
|
|
21
|
+
includeAttachments: z.boolean().optional(),
|
|
22
|
+
/** Immutable Gmail ID of the message to forward. */
|
|
23
|
+
messageId: z.string().min(1),
|
|
24
|
+
/**
|
|
25
|
+
* Optional subject override; defaults to the original subject prefixed
|
|
26
|
+
* with `Fwd:`.
|
|
27
|
+
*/
|
|
28
|
+
subject: z.string().optional(),
|
|
29
|
+
/** Optional plain-text introduction inserted before the forwarded message. */
|
|
30
|
+
text: z.string().optional(),
|
|
31
|
+
/** One or more primary recipients. */
|
|
32
|
+
to: RECIPIENTS_SCHEMA,
|
|
33
|
+
}))
|
|
34
|
+
.output(MESSAGE_METADATA_SCHEMA)
|
|
35
|
+
.handler(async ({ account, input }) => {
|
|
36
|
+
const gmailApi = getGmailApi(account.secret);
|
|
37
|
+
const { data: original } = await gmailApi.users.messages.get({
|
|
38
|
+
format: "raw",
|
|
39
|
+
id: input.messageId,
|
|
40
|
+
userId: "me",
|
|
41
|
+
});
|
|
42
|
+
if (!original.raw)
|
|
43
|
+
throw new Error("Gmail did not return the raw message.");
|
|
44
|
+
const parsed = await parseRawMessage(original.raw);
|
|
45
|
+
const originalSubject = parsed.subject ?? "";
|
|
46
|
+
const forwardedHeaders = [
|
|
47
|
+
"---------- Forwarded message ---------",
|
|
48
|
+
`From: ${formatAddresses(parsed.from)}`,
|
|
49
|
+
`Date: ${parsed.date ?? ""}`,
|
|
50
|
+
`Subject: ${originalSubject}`,
|
|
51
|
+
`To: ${formatAddresses(parsed.to)}`,
|
|
52
|
+
];
|
|
53
|
+
const originalText = parsed.text ??
|
|
54
|
+
(parsed.html === undefined
|
|
55
|
+
? undefined
|
|
56
|
+
: convert(parsed.html, { wordwrap: false }));
|
|
57
|
+
const introHtml = input.html ??
|
|
58
|
+
(input.text === undefined ? undefined : textToHtml(input.text));
|
|
59
|
+
const originalHtml = parsed.html ??
|
|
60
|
+
(parsed.text === undefined ? undefined : textToHtml(parsed.text));
|
|
61
|
+
// Keep the generated MIME alternatives named so their fallback behavior is readable.
|
|
62
|
+
const html = introHtml || originalHtml
|
|
63
|
+
? [
|
|
64
|
+
introHtml,
|
|
65
|
+
`<div>${forwardedHeaders.map(escapeHtml).join("<br>")}</div>`,
|
|
66
|
+
originalHtml,
|
|
67
|
+
]
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.join("<br><br>")
|
|
70
|
+
: undefined;
|
|
71
|
+
// See `html` above; this is the matching plain-text MIME alternative.
|
|
72
|
+
const text = input.text !== undefined || originalText !== undefined
|
|
73
|
+
? [input.text, forwardedHeaders.join("\r\n"), originalText]
|
|
74
|
+
.filter((part) => part !== undefined)
|
|
75
|
+
.join("\r\n\r\n")
|
|
76
|
+
: undefined;
|
|
77
|
+
const forwardedAttachments = input.includeAttachments === false
|
|
78
|
+
? []
|
|
79
|
+
: parsed.attachments.map((attachment) => ({
|
|
80
|
+
contentId: attachment.contentId,
|
|
81
|
+
disposition: attachment.disposition ?? undefined,
|
|
82
|
+
file: new File([
|
|
83
|
+
attachment.content instanceof ArrayBuffer
|
|
84
|
+
? new Uint8Array(attachment.content)
|
|
85
|
+
: attachment.content,
|
|
86
|
+
], attachment.filename || "attachment", { type: attachment.mimeType }),
|
|
87
|
+
}));
|
|
88
|
+
return toMessageMetadata((await gmailApi.users.messages.send({
|
|
89
|
+
requestBody: {
|
|
90
|
+
raw: await buildRawMessage({
|
|
91
|
+
attachments: [
|
|
92
|
+
...(input.attachments ?? []),
|
|
93
|
+
...forwardedAttachments,
|
|
94
|
+
],
|
|
95
|
+
bcc: input.bcc,
|
|
96
|
+
cc: input.cc,
|
|
97
|
+
from: input.from,
|
|
98
|
+
headers: input.headers,
|
|
99
|
+
html,
|
|
100
|
+
priority: input.priority,
|
|
101
|
+
replyTo: input.replyTo,
|
|
102
|
+
subject: input.subject ??
|
|
103
|
+
(originalSubject.startsWith("Fwd:")
|
|
104
|
+
? originalSubject
|
|
105
|
+
: `Fwd: ${originalSubject}`),
|
|
106
|
+
text,
|
|
107
|
+
to: input.to,
|
|
108
|
+
}),
|
|
109
|
+
},
|
|
110
|
+
userId: "me",
|
|
111
|
+
})).data, "forward");
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Converts plain text to safe HTML for a multipart forwarded message.
|
|
115
|
+
*
|
|
116
|
+
* @param text - Plain-text content.
|
|
117
|
+
*/
|
|
118
|
+
function textToHtml(text) {
|
|
119
|
+
return escapeHtml(text).replaceAll(/\r?\n/g, "<br>");
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Formats PostalMime addresses for a forwarded-message preamble.
|
|
123
|
+
*
|
|
124
|
+
* @param addresses - One address or an address list.
|
|
125
|
+
*/
|
|
126
|
+
function formatAddresses(addresses) {
|
|
127
|
+
return (Array.isArray(addresses) ? addresses : addresses ? [addresses] : [])
|
|
128
|
+
.map(formatAddress)
|
|
129
|
+
.join(", ");
|
|
130
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Retrieves and fully parses a Gmail draft and its message. */
|
|
3
|
+
export declare const getDraft: import("../../..").DefinedAction<z.ZodObject<{
|
|
4
|
+
draftId: z.ZodString;
|
|
5
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
6
|
+
draftId: z.ZodString;
|
|
7
|
+
message: z.ZodObject<{
|
|
8
|
+
messageId: z.ZodString;
|
|
9
|
+
threadId: z.ZodString;
|
|
10
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
11
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
12
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
13
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
14
|
+
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
disposition: z.ZodOptional<z.ZodEnum<{
|
|
16
|
+
attachment: "attachment";
|
|
17
|
+
inline: "inline";
|
|
18
|
+
}>>;
|
|
19
|
+
file: z.ZodCustom<File, File>;
|
|
20
|
+
filename: z.ZodString;
|
|
21
|
+
mimeType: z.ZodString;
|
|
22
|
+
related: z.ZodBoolean;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
bcc: z.ZodArray<z.ZodObject<{
|
|
25
|
+
address: z.ZodString;
|
|
26
|
+
name: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
cc: z.ZodArray<z.ZodObject<{
|
|
29
|
+
address: z.ZodString;
|
|
30
|
+
name: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>>;
|
|
32
|
+
deliveredTo: z.ZodOptional<z.ZodString>;
|
|
33
|
+
from: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
address: z.ZodString;
|
|
35
|
+
name: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
headers: z.ZodArray<z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
value: z.ZodString;
|
|
40
|
+
}, z.core.$strip>>;
|
|
41
|
+
html: z.ZodOptional<z.ZodString>;
|
|
42
|
+
inReplyTo: z.ZodOptional<z.ZodString>;
|
|
43
|
+
rfc822MessageId: z.ZodOptional<z.ZodString>;
|
|
44
|
+
receivedAt: z.ZodNullable<z.ZodDate>;
|
|
45
|
+
references: z.ZodArray<z.ZodString>;
|
|
46
|
+
replyTo: z.ZodArray<z.ZodObject<{
|
|
47
|
+
address: z.ZodString;
|
|
48
|
+
name: z.ZodOptional<z.ZodString>;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
returnPath: z.ZodOptional<z.ZodString>;
|
|
51
|
+
sender: z.ZodOptional<z.ZodObject<{
|
|
52
|
+
address: z.ZodString;
|
|
53
|
+
name: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
sentAt: z.ZodOptional<z.ZodDate>;
|
|
56
|
+
sizeEstimate: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
58
|
+
subject: z.ZodString;
|
|
59
|
+
text: z.ZodOptional<z.ZodString>;
|
|
60
|
+
to: z.ZodArray<z.ZodObject<{
|
|
61
|
+
address: z.ZodString;
|
|
62
|
+
name: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
}, z.core.$strip>, "google">;
|
|
66
|
+
//# sourceMappingURL=get-draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-draft.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/get-draft.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,gEAAgE;AAChE,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAuBjB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi, getGmailMessage } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_READ_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { DRAFT_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/** Retrieves and fully parses a Gmail draft and its message. */
|
|
7
|
+
export const getDraft = defineAction("Get Gmail draft")
|
|
8
|
+
.describe("Gets a Gmail draft with its parsed message and attachments.")
|
|
9
|
+
.account("google", GMAIL_READ_REQUIREMENT)
|
|
10
|
+
.input(z.object({
|
|
11
|
+
/** Immutable Gmail draft ID. */
|
|
12
|
+
draftId: z.string().min(1),
|
|
13
|
+
}))
|
|
14
|
+
.output(DRAFT_SCHEMA)
|
|
15
|
+
.handler(async ({ account, input }) => {
|
|
16
|
+
const { data: draft } = await getGmailApi(account.secret).users.drafts.get({
|
|
17
|
+
format: "raw",
|
|
18
|
+
id: input.draftId,
|
|
19
|
+
userId: "me",
|
|
20
|
+
});
|
|
21
|
+
if (!draft.id || !draft.message) {
|
|
22
|
+
throw new Error("Gmail returned an incomplete draft.");
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
draftId: draft.id,
|
|
26
|
+
message: await getGmailMessage(draft.message),
|
|
27
|
+
};
|
|
28
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves and fully parses one Gmail message.
|
|
4
|
+
*
|
|
5
|
+
* Attachments are always returned as Files because Gmail's raw-message response
|
|
6
|
+
* already includes their contents.
|
|
7
|
+
*/
|
|
8
|
+
export declare const getMessage: import("../../..").DefinedAction<z.ZodObject<{
|
|
9
|
+
messageId: z.ZodString;
|
|
10
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
messageId: z.ZodString;
|
|
12
|
+
threadId: z.ZodString;
|
|
13
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
14
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
15
|
+
attachments: z.ZodArray<z.ZodObject<{
|
|
16
|
+
contentId: z.ZodOptional<z.ZodString>;
|
|
17
|
+
description: z.ZodOptional<z.ZodString>;
|
|
18
|
+
disposition: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
attachment: "attachment";
|
|
20
|
+
inline: "inline";
|
|
21
|
+
}>>;
|
|
22
|
+
file: z.ZodCustom<File, File>;
|
|
23
|
+
filename: z.ZodString;
|
|
24
|
+
mimeType: z.ZodString;
|
|
25
|
+
related: z.ZodBoolean;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
bcc: z.ZodArray<z.ZodObject<{
|
|
28
|
+
address: z.ZodString;
|
|
29
|
+
name: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
cc: z.ZodArray<z.ZodObject<{
|
|
32
|
+
address: z.ZodString;
|
|
33
|
+
name: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>>;
|
|
35
|
+
deliveredTo: z.ZodOptional<z.ZodString>;
|
|
36
|
+
from: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
address: z.ZodString;
|
|
38
|
+
name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
headers: z.ZodArray<z.ZodObject<{
|
|
41
|
+
name: z.ZodString;
|
|
42
|
+
value: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
html: z.ZodOptional<z.ZodString>;
|
|
45
|
+
inReplyTo: z.ZodOptional<z.ZodString>;
|
|
46
|
+
rfc822MessageId: z.ZodOptional<z.ZodString>;
|
|
47
|
+
receivedAt: z.ZodNullable<z.ZodDate>;
|
|
48
|
+
references: z.ZodArray<z.ZodString>;
|
|
49
|
+
replyTo: z.ZodArray<z.ZodObject<{
|
|
50
|
+
address: z.ZodString;
|
|
51
|
+
name: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
returnPath: z.ZodOptional<z.ZodString>;
|
|
54
|
+
sender: z.ZodOptional<z.ZodObject<{
|
|
55
|
+
address: z.ZodString;
|
|
56
|
+
name: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strip>>;
|
|
58
|
+
sentAt: z.ZodOptional<z.ZodDate>;
|
|
59
|
+
sizeEstimate: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
61
|
+
subject: z.ZodString;
|
|
62
|
+
text: z.ZodOptional<z.ZodString>;
|
|
63
|
+
to: z.ZodArray<z.ZodObject<{
|
|
64
|
+
address: z.ZodString;
|
|
65
|
+
name: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
}, z.core.$strip>, "google">;
|
|
68
|
+
//# sourceMappingURL=get-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-message.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/get-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;;GAKG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAoBpB,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi, getGmailMessage } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_READ_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { MESSAGE_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Retrieves and fully parses one Gmail message.
|
|
8
|
+
*
|
|
9
|
+
* Attachments are always returned as Files because Gmail's raw-message response
|
|
10
|
+
* already includes their contents.
|
|
11
|
+
*/
|
|
12
|
+
export const getMessage = defineAction("Get Gmail message")
|
|
13
|
+
.describe("Gets a parsed Gmail message with headers and attachments.")
|
|
14
|
+
.account("google", GMAIL_READ_REQUIREMENT)
|
|
15
|
+
.input(z.object({
|
|
16
|
+
/** Immutable Gmail message ID. */
|
|
17
|
+
messageId: z.string().min(1),
|
|
18
|
+
}))
|
|
19
|
+
.output(MESSAGE_SCHEMA)
|
|
20
|
+
.handler(async ({ account, input }) => getGmailMessage((await getGmailApi(account.secret).users.messages.get({
|
|
21
|
+
format: "raw",
|
|
22
|
+
id: input.messageId,
|
|
23
|
+
userId: "me",
|
|
24
|
+
})).data));
|