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,35 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { buildRawMessage, getGmailApi, toMessageMetadata } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_SEND_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { COMPOSE_OPTIONS_SCHEMA, MESSAGE_METADATA_SCHEMA, RECIPIENTS_SCHEMA, } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Sends a new Gmail message.
|
|
8
|
+
*
|
|
9
|
+
* Supports named recipients, send-as aliases, custom headers, priority, inline
|
|
10
|
+
* attachments, and automatic plain text derived from HTML.
|
|
11
|
+
*/
|
|
12
|
+
export const sendEmail = defineAction("Send Gmail email")
|
|
13
|
+
.describe("Sends a richly formatted Gmail message.")
|
|
14
|
+
.account("google", GMAIL_SEND_REQUIREMENT)
|
|
15
|
+
.input(COMPOSE_OPTIONS_SCHEMA.extend({
|
|
16
|
+
/**
|
|
17
|
+
* HTML message body.
|
|
18
|
+
*
|
|
19
|
+
* Plain text is derived automatically when `text` is omitted.
|
|
20
|
+
*/
|
|
21
|
+
html: z.string().optional(),
|
|
22
|
+
/** Message subject line. */
|
|
23
|
+
subject: z.string(),
|
|
24
|
+
/** Optional plain-text message body. */
|
|
25
|
+
text: z.string().optional(),
|
|
26
|
+
/** One or more primary recipients. */
|
|
27
|
+
to: RECIPIENTS_SCHEMA,
|
|
28
|
+
}).refine(({ html, text }) => html !== undefined || text !== undefined, "At least one message body must be provided."))
|
|
29
|
+
.output(MESSAGE_METADATA_SCHEMA)
|
|
30
|
+
.handler(async ({ account, input }) => toMessageMetadata((await getGmailApi(account.secret).users.messages.send({
|
|
31
|
+
requestBody: {
|
|
32
|
+
raw: await buildRawMessage(input),
|
|
33
|
+
},
|
|
34
|
+
userId: "me",
|
|
35
|
+
})).data, "sent message"));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Stars one or many Gmail messages. */
|
|
2
|
+
export declare const star: 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=star.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"star.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/star.ts"],"names":[],"mappings":"AAEA,wCAAwC;AACxC,eAAO,MAAM,IAAI;;4FAIhB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Moves one or many Gmail messages to Trash.
|
|
4
|
+
*
|
|
5
|
+
* Returns Gmail's updated metadata for every message.
|
|
6
|
+
*/
|
|
7
|
+
export declare const trash: import("../../..").DefinedAction<z.ZodObject<{
|
|
8
|
+
messageIds: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
9
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
10
|
+
messageId: z.ZodString;
|
|
11
|
+
threadId: z.ZodString;
|
|
12
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
13
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>, "google">;
|
|
15
|
+
//# sourceMappingURL=trash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trash.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/trash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB;;;;GAIG;AACH,eAAO,MAAM,KAAK;;;;;;;6BA0Bd,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pMap from "p-map";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
4
|
+
import { getGmailApi, normalizeMessageIds, toMessageMetadata, } from "../lib/gmail.js";
|
|
5
|
+
import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
|
|
6
|
+
import { MESSAGE_IDS_SCHEMA, MESSAGE_METADATA_SCHEMA } from "../lib/schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* Moves one or many Gmail messages to Trash.
|
|
9
|
+
*
|
|
10
|
+
* Returns Gmail's updated metadata for every message.
|
|
11
|
+
*/
|
|
12
|
+
export const trash = defineAction("Trash Gmail messages")
|
|
13
|
+
.describe("Moves one or many Gmail messages to Trash.")
|
|
14
|
+
.account("google", GMAIL_MODIFY_REQUIREMENT)
|
|
15
|
+
.input(z.object({
|
|
16
|
+
/** One ID or up to 1,000 immutable Gmail message IDs. */
|
|
17
|
+
messageIds: MESSAGE_IDS_SCHEMA,
|
|
18
|
+
}))
|
|
19
|
+
.output(MESSAGE_METADATA_SCHEMA.array())
|
|
20
|
+
.handler(async ({ account, input }) => {
|
|
21
|
+
const gmailApi = getGmailApi(account.secret);
|
|
22
|
+
return await pMap(normalizeMessageIds(input.messageIds), async (messageId) => toMessageMetadata((await gmailApi.users.messages.trash({
|
|
23
|
+
id: messageId,
|
|
24
|
+
userId: "me",
|
|
25
|
+
})).data, "trashed message"), { concurrency: 20 });
|
|
26
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Removes Gmail's Important marker from one or many messages. */
|
|
2
|
+
export declare const unmarkAsImportant: 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=unmark-as-important.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unmark-as-important.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/unmark-as-important.ts"],"names":[],"mappings":"AAEA,kEAAkE;AAClE,eAAO,MAAM,iBAAiB;;4FAI7B,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { defineMessageLabelMutation } from "../lib/action-factories.js";
|
|
2
|
+
/** Removes Gmail's Important marker from one or many messages. */
|
|
3
|
+
export const unmarkAsImportant = defineMessageLabelMutation("Unmark Gmail messages as important", "Removes Gmail's Important marker from messages.", { removeLabelIds: ["IMPORTANT"] });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Removes the star from one or many Gmail messages. */
|
|
2
|
+
export declare const unstar: 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=unstar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unstar.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/unstar.ts"],"names":[],"mappings":"AAEA,wDAAwD;AACxD,eAAO,MAAM,MAAM;;4FAIlB,CAAA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { defineMessageLabelMutation } from "../lib/action-factories.js";
|
|
2
|
+
/** Removes the star from one or many Gmail messages. */
|
|
3
|
+
export const unstar = defineMessageLabelMutation("Unstar Gmail messages", "Removes the star from Gmail messages.", { removeLabelIds: ["STARRED"] });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Restores one or many Gmail messages from Trash.
|
|
4
|
+
*
|
|
5
|
+
* Returns Gmail's updated metadata for every message.
|
|
6
|
+
*/
|
|
7
|
+
export declare const untrash: import("../../..").DefinedAction<z.ZodObject<{
|
|
8
|
+
messageIds: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
9
|
+
}, z.core.$strip>, z.ZodArray<z.ZodObject<{
|
|
10
|
+
messageId: z.ZodString;
|
|
11
|
+
threadId: z.ZodString;
|
|
12
|
+
historyId: z.ZodOptional<z.ZodString>;
|
|
13
|
+
labelIds: z.ZodArray<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>>, "google">;
|
|
15
|
+
//# sourceMappingURL=untrash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"untrash.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/untrash.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAUvB;;;;GAIG;AACH,eAAO,MAAM,OAAO;;;;;;;6BA0BhB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pMap from "p-map";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
4
|
+
import { getGmailApi, normalizeMessageIds, toMessageMetadata, } from "../lib/gmail.js";
|
|
5
|
+
import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
|
|
6
|
+
import { MESSAGE_IDS_SCHEMA, MESSAGE_METADATA_SCHEMA } from "../lib/schemas.js";
|
|
7
|
+
/**
|
|
8
|
+
* Restores one or many Gmail messages from Trash.
|
|
9
|
+
*
|
|
10
|
+
* Returns Gmail's updated metadata for every message.
|
|
11
|
+
*/
|
|
12
|
+
export const untrash = defineAction("Untrash Gmail messages")
|
|
13
|
+
.describe("Restores one or many Gmail messages from Trash.")
|
|
14
|
+
.account("google", GMAIL_MODIFY_REQUIREMENT)
|
|
15
|
+
.input(z.object({
|
|
16
|
+
/** One ID or up to 1,000 immutable Gmail message IDs. */
|
|
17
|
+
messageIds: MESSAGE_IDS_SCHEMA,
|
|
18
|
+
}))
|
|
19
|
+
.output(MESSAGE_METADATA_SCHEMA.array())
|
|
20
|
+
.handler(async ({ account, input }) => {
|
|
21
|
+
const gmailApi = getGmailApi(account.secret);
|
|
22
|
+
return await pMap(normalizeMessageIds(input.messageIds), async (messageId) => toMessageMetadata((await gmailApi.users.messages.untrash({
|
|
23
|
+
id: messageId,
|
|
24
|
+
userId: "me",
|
|
25
|
+
})).data, "restored message"), { concurrency: 20 });
|
|
26
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Updates a Gmail draft while preserving fields omitted by the caller.
|
|
4
|
+
*
|
|
5
|
+
* Supplying either body representation replaces the existing body pair; missing
|
|
6
|
+
* plain text is then derived from replacement HTML.
|
|
7
|
+
*/
|
|
8
|
+
export declare const updateDraft: 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
|
+
draftId: z.ZodString;
|
|
58
|
+
html: z.ZodOptional<z.ZodString>;
|
|
59
|
+
text: z.ZodOptional<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=update-draft.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-draft.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/update-draft.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB;;;;;GAKG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA8DpB,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { buildRawMessage, getGmailApi, getGmailMessage, toDraftIdentifier, } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_COMPOSE_AND_READ_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { COMPOSE_OPTIONS_SCHEMA, DRAFT_IDENTIFIER_SCHEMA } from "../lib/schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Updates a Gmail draft while preserving fields omitted by the caller.
|
|
8
|
+
*
|
|
9
|
+
* Supplying either body representation replaces the existing body pair; missing
|
|
10
|
+
* plain text is then derived from replacement HTML.
|
|
11
|
+
*/
|
|
12
|
+
export const updateDraft = defineAction("Update Gmail draft")
|
|
13
|
+
.describe("Updates selected fields on an existing Gmail draft.")
|
|
14
|
+
.account("google", GMAIL_COMPOSE_AND_READ_REQUIREMENT)
|
|
15
|
+
.input(COMPOSE_OPTIONS_SCHEMA.extend({
|
|
16
|
+
/** Immutable Gmail draft ID to replace. */
|
|
17
|
+
draftId: z.string().min(1),
|
|
18
|
+
/** Optional HTML draft body. */
|
|
19
|
+
html: z.string().optional(),
|
|
20
|
+
/** Optional plain-text draft body. */
|
|
21
|
+
text: z.string().optional(),
|
|
22
|
+
}))
|
|
23
|
+
.output(DRAFT_IDENTIFIER_SCHEMA)
|
|
24
|
+
.handler(async ({ account, input }) => {
|
|
25
|
+
const gmailApi = getGmailApi(account.secret);
|
|
26
|
+
const { data: existingDraft } = await gmailApi.users.drafts.get({
|
|
27
|
+
format: "raw",
|
|
28
|
+
id: input.draftId,
|
|
29
|
+
userId: "me",
|
|
30
|
+
});
|
|
31
|
+
if (!existingDraft.message) {
|
|
32
|
+
throw new Error("Gmail returned an incomplete draft.");
|
|
33
|
+
}
|
|
34
|
+
const existing = await getGmailMessage(existingDraft.message);
|
|
35
|
+
const bodyChanged = input.html !== undefined || input.text !== undefined;
|
|
36
|
+
const { data: updatedDraft } = await gmailApi.users.drafts.update({
|
|
37
|
+
id: input.draftId,
|
|
38
|
+
requestBody: {
|
|
39
|
+
message: {
|
|
40
|
+
raw: await buildRawMessage({
|
|
41
|
+
attachments: input.attachments ??
|
|
42
|
+
existing.attachments.map(({ contentId, disposition, file, filename }) => ({
|
|
43
|
+
contentId,
|
|
44
|
+
disposition,
|
|
45
|
+
file,
|
|
46
|
+
filename,
|
|
47
|
+
})),
|
|
48
|
+
bcc: input.bcc ?? existing.bcc,
|
|
49
|
+
cc: input.cc ?? existing.cc,
|
|
50
|
+
from: input.from ?? existing.from,
|
|
51
|
+
headers: input.headers,
|
|
52
|
+
html: bodyChanged ? input.html : existing.html,
|
|
53
|
+
inReplyTo: existing.inReplyTo,
|
|
54
|
+
priority: input.priority,
|
|
55
|
+
references: existing.references,
|
|
56
|
+
replyTo: input.replyTo ?? existing.replyTo,
|
|
57
|
+
subject: input.subject ?? existing.subject,
|
|
58
|
+
text: bodyChanged ? input.text : existing.text,
|
|
59
|
+
to: input.to ?? existing.to,
|
|
60
|
+
}),
|
|
61
|
+
threadId: existing.threadId,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
userId: "me",
|
|
65
|
+
});
|
|
66
|
+
return toDraftIdentifier(updatedDraft, "updated draft");
|
|
67
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Updates selected metadata on a user-owned Gmail label. */
|
|
3
|
+
export declare const updateLabel: import("../../..").DefinedAction<z.ZodObject<{
|
|
4
|
+
color: z.ZodOptional<z.ZodObject<{
|
|
5
|
+
backgroundColor: z.ZodString;
|
|
6
|
+
textColor: z.ZodString;
|
|
7
|
+
}, z.core.$strip>>;
|
|
8
|
+
label: z.ZodString;
|
|
9
|
+
labelListVisibility: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
labelHide: "labelHide";
|
|
11
|
+
labelShow: "labelShow";
|
|
12
|
+
labelShowIfUnread: "labelShowIfUnread";
|
|
13
|
+
}>>;
|
|
14
|
+
messageListVisibility: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
hide: "hide";
|
|
16
|
+
show: "show";
|
|
17
|
+
}>>;
|
|
18
|
+
name: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
20
|
+
color: z.ZodOptional<z.ZodObject<{
|
|
21
|
+
backgroundColor: z.ZodString;
|
|
22
|
+
textColor: z.ZodString;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
labelId: z.ZodString;
|
|
25
|
+
labelListVisibility: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
labelHide: "labelHide";
|
|
27
|
+
labelShow: "labelShow";
|
|
28
|
+
labelShowIfUnread: "labelShowIfUnread";
|
|
29
|
+
}>>;
|
|
30
|
+
messageListVisibility: z.ZodOptional<z.ZodEnum<{
|
|
31
|
+
hide: "hide";
|
|
32
|
+
show: "show";
|
|
33
|
+
}>>;
|
|
34
|
+
messagesTotal: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
messagesUnread: z.ZodOptional<z.ZodNumber>;
|
|
36
|
+
name: z.ZodString;
|
|
37
|
+
threadsTotal: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
threadsUnread: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
40
|
+
system: "system";
|
|
41
|
+
user: "user";
|
|
42
|
+
}>>;
|
|
43
|
+
}, z.core.$strip>, "google">;
|
|
44
|
+
//# sourceMappingURL=update-label.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-label.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/actions/update-label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAWvB,6DAA6D;AAC7D,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BA2CpB,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { findLabelId, getGmailApi, toGmailLabel } from "../lib/gmail.js";
|
|
4
|
+
import { GMAIL_MODIFY_REQUIREMENT } from "../lib/scopes.js";
|
|
5
|
+
import { LABEL_COLOR_SCHEMA, LABEL_LIST_VISIBILITY_SCHEMA, LABEL_SCHEMA, MESSAGE_LIST_VISIBILITY_SCHEMA, } from "../lib/schemas.js";
|
|
6
|
+
/** Updates selected metadata on a user-owned Gmail label. */
|
|
7
|
+
export const updateLabel = defineAction("Update Gmail label")
|
|
8
|
+
.describe("Updates a user-owned Gmail label.")
|
|
9
|
+
.account("google", GMAIL_MODIFY_REQUIREMENT)
|
|
10
|
+
.input(z
|
|
11
|
+
.object({
|
|
12
|
+
/** Optional supported Gmail label color. */
|
|
13
|
+
color: LABEL_COLOR_SCHEMA.optional(),
|
|
14
|
+
/** Gmail label display name or immutable ID to update. */
|
|
15
|
+
label: z.string().min(1),
|
|
16
|
+
/** Visibility in Gmail's label list. */
|
|
17
|
+
labelListVisibility: LABEL_LIST_VISIBILITY_SCHEMA.optional(),
|
|
18
|
+
/** Visibility beside messages in Gmail's message list. */
|
|
19
|
+
messageListVisibility: MESSAGE_LIST_VISIBILITY_SCHEMA.optional(),
|
|
20
|
+
/** Optional replacement label name. */
|
|
21
|
+
name: z.string().min(1).optional(),
|
|
22
|
+
})
|
|
23
|
+
.refine(({ color, labelListVisibility, messageListVisibility, name }) => Boolean(color || labelListVisibility || messageListVisibility || name), "At least one label property must be updated."))
|
|
24
|
+
.output(LABEL_SCHEMA)
|
|
25
|
+
.handler(async ({ account, input }) => {
|
|
26
|
+
const gmailApi = getGmailApi(account.secret);
|
|
27
|
+
const { data: label } = await gmailApi.users.labels.patch({
|
|
28
|
+
id: await findLabelId(gmailApi, input.label),
|
|
29
|
+
requestBody: {
|
|
30
|
+
color: input.color,
|
|
31
|
+
labelListVisibility: input.labelListVisibility,
|
|
32
|
+
messageListVisibility: input.messageListVisibility,
|
|
33
|
+
name: input.name,
|
|
34
|
+
},
|
|
35
|
+
userId: "me",
|
|
36
|
+
});
|
|
37
|
+
return toGmailLabel(label);
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/gmail/index.ts"],"names":[],"mappings":"AAAA,mCAAyB;AACzB,oCAA0B;AAC1B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,uBAAmB;AAC1D,OAAO,EAAE,cAAc,EAAE,yBAAqB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Defines one fixed-label Gmail batch mutation.
|
|
4
|
+
*
|
|
5
|
+
* @param name - Action display name.
|
|
6
|
+
* @param description - Action description.
|
|
7
|
+
* @param labels - Fixed label mutation.
|
|
8
|
+
* @param labels.addLabelIds - Label IDs to add.
|
|
9
|
+
* @param labels.removeLabelIds - Label IDs to remove.
|
|
10
|
+
*/
|
|
11
|
+
export declare function defineMessageLabelMutation(name: string, description: string, labels: {
|
|
12
|
+
addLabelIds?: string[];
|
|
13
|
+
removeLabelIds?: string[];
|
|
14
|
+
}): import("../../..").DefinedAction<z.ZodObject<{
|
|
15
|
+
messageIds: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
16
|
+
}, z.core.$strip>, z.ZodArray<z.ZodString>, "google">;
|
|
17
|
+
/**
|
|
18
|
+
* Defines one fixed-label Gmail predicate.
|
|
19
|
+
*
|
|
20
|
+
* @param name - Action display name.
|
|
21
|
+
* @param description - Action description.
|
|
22
|
+
* @param labelId - Gmail system label ID.
|
|
23
|
+
*/
|
|
24
|
+
export declare function defineMessageLabelPredicate(name: string, description: string, labelId: string): import("../../..").DefinedAction<z.ZodObject<{
|
|
25
|
+
messageId: z.ZodString;
|
|
26
|
+
}, z.core.$strip>, z.ZodBoolean, "google">;
|
|
27
|
+
//# sourceMappingURL=action-factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-factories.d.ts","sourceRoot":"","sources":["../../../../src/components/gmail/lib/action-factories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE;IACN,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;CAC1B;;sDAuBF;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM;;2CAmBhB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineAction } from "../../../automation/actions.js";
|
|
3
|
+
import { getGmailApi, getMessageMetadata, normalizeMessageIds } from "./gmail.js";
|
|
4
|
+
import { GMAIL_METADATA_REQUIREMENT, GMAIL_MODIFY_REQUIREMENT } from "./scopes.js";
|
|
5
|
+
import { MESSAGE_IDS_SCHEMA } from "./schemas.js";
|
|
6
|
+
/**
|
|
7
|
+
* Defines one fixed-label Gmail batch mutation.
|
|
8
|
+
*
|
|
9
|
+
* @param name - Action display name.
|
|
10
|
+
* @param description - Action description.
|
|
11
|
+
* @param labels - Fixed label mutation.
|
|
12
|
+
* @param labels.addLabelIds - Label IDs to add.
|
|
13
|
+
* @param labels.removeLabelIds - Label IDs to remove.
|
|
14
|
+
*/
|
|
15
|
+
export function defineMessageLabelMutation(name, description, labels) {
|
|
16
|
+
return defineAction(name)
|
|
17
|
+
.describe(description)
|
|
18
|
+
.account("google", GMAIL_MODIFY_REQUIREMENT)
|
|
19
|
+
.input(z.object({
|
|
20
|
+
/** One ID or up to 1,000 immutable Gmail message IDs. */
|
|
21
|
+
messageIds: MESSAGE_IDS_SCHEMA,
|
|
22
|
+
}))
|
|
23
|
+
.output(z.string().array())
|
|
24
|
+
.handler(async ({ account, input }) => {
|
|
25
|
+
const messageIds = normalizeMessageIds(input.messageIds);
|
|
26
|
+
await getGmailApi(account.secret).users.messages.batchModify({
|
|
27
|
+
requestBody: {
|
|
28
|
+
ids: messageIds,
|
|
29
|
+
...labels,
|
|
30
|
+
},
|
|
31
|
+
userId: "me",
|
|
32
|
+
});
|
|
33
|
+
return messageIds;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Defines one fixed-label Gmail predicate.
|
|
38
|
+
*
|
|
39
|
+
* @param name - Action display name.
|
|
40
|
+
* @param description - Action description.
|
|
41
|
+
* @param labelId - Gmail system label ID.
|
|
42
|
+
*/
|
|
43
|
+
export function defineMessageLabelPredicate(name, description, labelId) {
|
|
44
|
+
return defineAction(name)
|
|
45
|
+
.describe(description)
|
|
46
|
+
.account("google", GMAIL_METADATA_REQUIREMENT)
|
|
47
|
+
.input(z.object({
|
|
48
|
+
/** Immutable Gmail message ID. */
|
|
49
|
+
messageId: z.string().min(1),
|
|
50
|
+
}))
|
|
51
|
+
.output(z.boolean())
|
|
52
|
+
.handler(async ({ account, input }) => {
|
|
53
|
+
return ((await getMessageMetadata(getGmailApi(account.secret), input.messageId)).labelIds?.includes(labelId) ?? false);
|
|
54
|
+
});
|
|
55
|
+
}
|