@frogbotai/piece-gmail 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +34 -0
  2. package/dist/actions/customApiCall.d.ts +36 -0
  3. package/dist/actions/customApiCall.d.ts.map +1 -0
  4. package/dist/actions/customApiCall.js +27 -0
  5. package/dist/actions/customApiCall.js.map +1 -0
  6. package/dist/actions/getEmail.d.ts +53 -0
  7. package/dist/actions/getEmail.d.ts.map +1 -0
  8. package/dist/actions/getEmail.js +18 -0
  9. package/dist/actions/getEmail.js.map +1 -0
  10. package/dist/actions/replyToEmail.d.ts +75 -0
  11. package/dist/actions/replyToEmail.d.ts.map +1 -0
  12. package/dist/actions/replyToEmail.js +45 -0
  13. package/dist/actions/replyToEmail.js.map +1 -0
  14. package/dist/actions/searchEmails.d.ts +36 -0
  15. package/dist/actions/searchEmails.d.ts.map +1 -0
  16. package/dist/actions/searchEmails.js +29 -0
  17. package/dist/actions/searchEmails.js.map +1 -0
  18. package/dist/actions/send.d.ts +56 -0
  19. package/dist/actions/send.d.ts.map +1 -0
  20. package/dist/actions/send.js +35 -0
  21. package/dist/actions/send.js.map +1 -0
  22. package/dist/client.d.ts +6 -0
  23. package/dist/client.d.ts.map +1 -0
  24. package/dist/client.js +12 -0
  25. package/dist/client.js.map +1 -0
  26. package/dist/config.d.ts +7 -0
  27. package/dist/config.d.ts.map +1 -0
  28. package/dist/config.js +11 -0
  29. package/dist/config.js.map +1 -0
  30. package/dist/files.d.ts +12 -0
  31. package/dist/files.d.ts.map +1 -0
  32. package/dist/files.js +41 -0
  33. package/dist/files.js.map +1 -0
  34. package/dist/index.d.ts +314 -19
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +35 -40
  37. package/dist/index.js.map +1 -1
  38. package/dist/mail.d.ts +77 -0
  39. package/dist/mail.d.ts.map +1 -0
  40. package/dist/mail.js +136 -0
  41. package/dist/mail.js.map +1 -0
  42. package/dist/triggers/newEmail.d.ts +42 -0
  43. package/dist/triggers/newEmail.d.ts.map +1 -0
  44. package/dist/triggers/newEmail.js +32 -0
  45. package/dist/triggers/newEmail.js.map +1 -0
  46. package/package.json +6 -4
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # `@frogbotai/piece-gmail`
2
+
3
+ Send, draft, read, search, and poll Gmail messages.
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { createGmail } from '@frogbotai/piece-gmail';
9
+
10
+ export const gmail = createGmail({
11
+ oauth: {
12
+ clientId: process.env.GOOGLE_CLIENT_ID!,
13
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
14
+ },
15
+ });
16
+ ```
17
+
18
+ ## Actions
19
+
20
+ | Upstream action slug | Previous wrapper export | Native action | Notes |
21
+ | -------------------------- | ----------------------- | ------------------ | ------------------------------------------------------ |
22
+ | `send_email` | `sendEmail` | `send` | Supports sending, drafts, reply headers, and file IDs. |
23
+ | `request_approval_in_mail` | `requestApprovalInMail` | Dropped | Durable approval waits belong to F8 workflows. |
24
+ | `reply_to_email` | `replyToEmail` | `replyToEmail` | |
25
+ | `create_draft_reply` | `createDraftReply` | `createDraftReply` | |
26
+ | `gmail_get_mail` | `gmailGetMail` | `getEmail` | |
27
+ | `gmail_search_mail` | `gmailSearchMail` | `searchEmails` | |
28
+ | `custom_api_call` | `customApiCall` | `customApiCall` | Restricted to Gmail API paths. |
29
+
30
+ ## Triggers
31
+
32
+ | Upstream trigger slug | Native trigger | Type | Notes |
33
+ | -------------------------- | -------------- | --------- | ------------------------------------------------------- |
34
+ | `gmail_new_email_received` | `newEmail` | `polling` | Uses the previous poll time as a Gmail `after:` cursor. |
@@ -0,0 +1,36 @@
1
+ import { type PieceRunArgs } from 'frogbot/pieces';
2
+ import { z } from 'zod';
3
+ import type { Gmail } from '../client.js';
4
+ declare const inputSchema: z.ZodObject<{
5
+ method: z.ZodEnum<{
6
+ GET: "GET";
7
+ POST: "POST";
8
+ PUT: "PUT";
9
+ PATCH: "PATCH";
10
+ DELETE: "DELETE";
11
+ }>;
12
+ path: z.ZodString;
13
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
14
+ body: z.ZodOptional<z.ZodUnknown>;
15
+ }, z.core.$strip>;
16
+ export declare const customApiCall: {
17
+ slug: string;
18
+ description: string;
19
+ input: z.ZodObject<{
20
+ method: z.ZodEnum<{
21
+ GET: "GET";
22
+ POST: "POST";
23
+ PUT: "PUT";
24
+ PATCH: "PATCH";
25
+ DELETE: "DELETE";
26
+ }>;
27
+ path: z.ZodString;
28
+ query: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
29
+ body: z.ZodOptional<z.ZodUnknown>;
30
+ }, z.core.$strip>;
31
+ output: z.ZodUnknown;
32
+ idempotent: boolean;
33
+ run({ client, input }: PieceRunArgs<z.output<typeof inputSchema>, object, Gmail>): Promise<unknown>;
34
+ };
35
+ export {};
36
+ //# sourceMappingURL=customApiCall.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customApiCall.d.ts","sourceRoot":"","sources":["../../src/actions/customApiCall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAE1C,QAAA,MAAM,WAAW;;;;;;;;;;;iBAKf,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;2BAMK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;CAcvF,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { z } from 'zod';
2
+ const inputSchema = z.object({
3
+ method: z.enum(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']),
4
+ path: z.string().startsWith('/'),
5
+ query: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(),
6
+ body: z.unknown().optional(),
7
+ });
8
+ export const customApiCall = {
9
+ slug: 'customApiCall',
10
+ description: 'Make an authenticated Gmail API call.',
11
+ input: inputSchema,
12
+ output: z.unknown(),
13
+ idempotent: false,
14
+ async run({ client, input }) {
15
+ const request = client.context._options.auth;
16
+ if (!request || typeof request === 'string' || !('request' in request)) {
17
+ throw new Error('[frogbot] Gmail client is missing authenticated transport.');
18
+ }
19
+ return (await request.request({
20
+ method: input.method,
21
+ url: `https://gmail.googleapis.com/gmail/v1${input.path}`,
22
+ params: input.query,
23
+ data: input.body,
24
+ })).data;
25
+ },
26
+ };
27
+ //# sourceMappingURL=customApiCall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customApiCall.js","sourceRoot":"","sources":["../../src/actions/customApiCall.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;IACzD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACtF,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAC7B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE,uCAAuC;IACpD,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,UAAU,EAAE,KAAK;IACjB,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAA6D;QACpF,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;QAC7C,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,EAAE,CAAC;YACvE,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,CACL,MAAM,OAAO,CAAC,OAAO,CAAC;YACpB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,GAAG,EAAE,wCAAwC,KAAK,CAAC,IAAI,EAAE;YACzD,MAAM,EAAE,KAAK,CAAC,KAAK;YACnB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CACH,CAAC,IAAI,CAAC;IACT,CAAC;CACF,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { type PieceRunArgs } from 'frogbot/pieces';
2
+ import { z } from 'zod';
3
+ import type { Gmail } from '../client.js';
4
+ declare const inputSchema: z.ZodObject<{
5
+ messageId: z.ZodString;
6
+ format: z.ZodDefault<z.ZodEnum<{
7
+ full: "full";
8
+ minimal: "minimal";
9
+ raw: "raw";
10
+ metadata: "metadata";
11
+ }>>;
12
+ }, z.core.$strip>;
13
+ export declare const getEmail: {
14
+ slug: string;
15
+ description: string;
16
+ input: z.ZodObject<{
17
+ messageId: z.ZodString;
18
+ format: z.ZodDefault<z.ZodEnum<{
19
+ full: "full";
20
+ minimal: "minimal";
21
+ raw: "raw";
22
+ metadata: "metadata";
23
+ }>>;
24
+ }, z.core.$strip>;
25
+ output: z.ZodObject<{
26
+ id: z.ZodOptional<z.ZodString>;
27
+ threadId: z.ZodOptional<z.ZodString>;
28
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
+ snippet: z.ZodOptional<z.ZodString>;
30
+ payload: z.ZodOptional<z.ZodUnknown>;
31
+ }, z.core.$loose>;
32
+ idempotent: boolean;
33
+ run({ client, input, req }: PieceRunArgs<z.output<typeof inputSchema>, object, Gmail>): Promise<import("googleapis").gmail_v1.Schema$Message | {
34
+ attachments: {
35
+ id: string | number;
36
+ name: string;
37
+ mimeType: string;
38
+ url: unknown;
39
+ }[];
40
+ classificationLabelValues?: import("googleapis").gmail_v1.Schema$ClassificationLabelValue[];
41
+ historyId?: string | null;
42
+ id?: string | null;
43
+ internalDate?: string | null;
44
+ labelIds?: string[] | null;
45
+ payload?: import("googleapis").gmail_v1.Schema$MessagePart;
46
+ raw?: string | null;
47
+ sizeEstimate?: number | null;
48
+ snippet?: string | null;
49
+ threadId?: string | null;
50
+ }>;
51
+ };
52
+ export {};
53
+ //# sourceMappingURL=getEmail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEmail.d.ts","sourceRoot":"","sources":["../../src/actions/getEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,QAAA,MAAM,WAAW;;;;;;;;iBAGf,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;gCAMe,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;;;;;;;;;;;;;;;;;;CAM5F,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ import { emailOutput, saveAttachments } from '../mail.js';
3
+ const inputSchema = z.object({
4
+ messageId: z.string(),
5
+ format: z.enum(['minimal', 'full', 'raw', 'metadata']).default('full'),
6
+ });
7
+ export const getEmail = {
8
+ slug: 'getEmail',
9
+ description: 'Get an email by ID.',
10
+ input: inputSchema,
11
+ output: emailOutput,
12
+ idempotent: true,
13
+ async run({ client, input, req }) {
14
+ const message = (await client.users.messages.get({ userId: 'me', id: input.messageId, format: input.format })).data;
15
+ return input.format === 'full' ? saveAttachments(client, req, message) : message;
16
+ },
17
+ };
18
+ //# sourceMappingURL=getEmail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEmail.js","sourceRoot":"","sources":["../../src/actions/getEmail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;CACvE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,qBAAqB;IAClC,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,WAAW;IACnB,UAAU,EAAE,IAAI;IAChB,KAAK,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAA6D;QACzF,MAAM,OAAO,GAAG,CACd,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAC7F,CAAC,IAAI,CAAC;QACP,OAAO,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACnF,CAAC;CACF,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { type PieceRunArgs } from 'frogbot/pieces';
2
+ import { z } from 'zod';
3
+ import type { Gmail } from '../client.js';
4
+ declare const inputSchema: z.ZodObject<{
5
+ body: z.ZodString;
6
+ bodyType: z.ZodDefault<z.ZodEnum<{
7
+ plainText: "plainText";
8
+ html: "html";
9
+ }>>;
10
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
11
+ fileId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
12
+ name: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$strip>>>;
14
+ messageId: z.ZodString;
15
+ replyType: z.ZodDefault<z.ZodEnum<{
16
+ reply: "reply";
17
+ replyAll: "replyAll";
18
+ }>>;
19
+ }, z.core.$strip>;
20
+ export declare const replyToEmail: {
21
+ slug: string;
22
+ description: string;
23
+ input: z.ZodObject<{
24
+ body: z.ZodString;
25
+ bodyType: z.ZodDefault<z.ZodEnum<{
26
+ plainText: "plainText";
27
+ html: "html";
28
+ }>>;
29
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
30
+ fileId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
31
+ name: z.ZodOptional<z.ZodString>;
32
+ }, z.core.$strip>>>;
33
+ messageId: z.ZodString;
34
+ replyType: z.ZodDefault<z.ZodEnum<{
35
+ reply: "reply";
36
+ replyAll: "replyAll";
37
+ }>>;
38
+ }, z.core.$strip>;
39
+ output: z.ZodObject<{
40
+ id: z.ZodOptional<z.ZodString>;
41
+ threadId: z.ZodOptional<z.ZodString>;
42
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
43
+ }, z.core.$loose>;
44
+ idempotent: boolean;
45
+ run: (args: PieceRunArgs<z.output<typeof inputSchema>, object, Gmail>) => Promise<import("googleapis").gmail_v1.Schema$Message>;
46
+ };
47
+ export declare const createDraftReply: {
48
+ slug: string;
49
+ description: string;
50
+ input: z.ZodObject<{
51
+ body: z.ZodString;
52
+ bodyType: z.ZodDefault<z.ZodEnum<{
53
+ plainText: "plainText";
54
+ html: "html";
55
+ }>>;
56
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
57
+ fileId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
58
+ name: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strip>>>;
60
+ messageId: z.ZodString;
61
+ replyType: z.ZodDefault<z.ZodEnum<{
62
+ reply: "reply";
63
+ replyAll: "replyAll";
64
+ }>>;
65
+ }, z.core.$strip>;
66
+ output: z.ZodObject<{
67
+ id: z.ZodOptional<z.ZodString>;
68
+ threadId: z.ZodOptional<z.ZodString>;
69
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
70
+ }, z.core.$loose>;
71
+ idempotent: boolean;
72
+ run: (args: PieceRunArgs<z.output<typeof inputSchema>, object, Gmail>) => Promise<import("googleapis").gmail_v1.Schema$Message>;
73
+ };
74
+ export {};
75
+ //# sourceMappingURL=replyToEmail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replyToEmail.d.ts","sourceRoot":"","sources":["../../src/actions/replyToEmail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAU1C,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;iBAIf,CAAC;AAkCH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;gBAMX,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;CAEtE,CAAC;AACF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;gBAMf,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;CAEtE,CAAC"}
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ import { createRawMessage, findHeader, getOriginal, messageBody, messageOutput, splitAddresses, } from '../mail.js';
3
+ const inputSchema = z.object({
4
+ messageId: z.string(),
5
+ replyType: z.enum(['reply', 'replyAll']).default('reply'),
6
+ ...messageBody,
7
+ });
8
+ async function replyMessage({ client, input, req, draft, }) {
9
+ const original = await getOriginal(client, input.messageId);
10
+ const messageId = findHeader(original, 'Message-ID') ?? '';
11
+ const subject = findHeader(original, 'Subject')?.replace(/^Re:\s*/i, '') ?? '';
12
+ const to = (input.replyType === 'replyAll'
13
+ ? [findHeader(original, 'From'), ...splitAddresses(findHeader(original, 'To'))].filter(Boolean)
14
+ : [findHeader(original, 'From')].filter(Boolean));
15
+ const cc = input.replyType === 'replyAll' ? splitAddresses(findHeader(original, 'Cc')) : undefined;
16
+ const message = {
17
+ threadId: original.threadId ?? undefined,
18
+ raw: await createRawMessage({
19
+ input: { ...input, to, cc, subject: `Re: ${subject}` },
20
+ req,
21
+ extraHeaders: [`In-Reply-To: ${messageId}`, `References: ${messageId}`],
22
+ }),
23
+ };
24
+ return draft
25
+ ? ((await client.users.drafts.create({ userId: 'me', requestBody: { message } })).data
26
+ .message ?? {})
27
+ : (await client.users.messages.send({ userId: 'me', requestBody: message })).data;
28
+ }
29
+ export const replyToEmail = {
30
+ slug: 'replyToEmail',
31
+ description: 'Reply to an existing email.',
32
+ input: inputSchema,
33
+ output: messageOutput,
34
+ idempotent: false,
35
+ run: (args) => replyMessage({ ...args, draft: false }),
36
+ };
37
+ export const createDraftReply = {
38
+ slug: 'createDraftReply',
39
+ description: 'Create a draft reply to an existing email.',
40
+ input: inputSchema,
41
+ output: messageOutput,
42
+ idempotent: false,
43
+ run: (args) => replyMessage({ ...args, draft: true }),
44
+ };
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AAE,4CAA4C;IACzD,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,aAAa;IACrB,UAAU,EAAE,KAAK;IACjB,GAAG,EAAE,CAAC,IAA+D,EAAE,EAAE,CACvE,YAAY,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;CACzC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { type PieceRunArgs } from 'frogbot/pieces';
2
+ import { z } from 'zod';
3
+ import type { Gmail } from '../client.js';
4
+ declare const inputSchema: z.ZodObject<{
5
+ query: z.ZodOptional<z.ZodString>;
6
+ from: z.ZodOptional<z.ZodString>;
7
+ to: z.ZodOptional<z.ZodString>;
8
+ subject: z.ZodOptional<z.ZodString>;
9
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
+ maxResults: z.ZodDefault<z.ZodNumber>;
11
+ includeSpamTrash: z.ZodDefault<z.ZodBoolean>;
12
+ }, z.core.$strip>;
13
+ export declare const searchEmails: {
14
+ slug: string;
15
+ description: string;
16
+ input: z.ZodObject<{
17
+ query: z.ZodOptional<z.ZodString>;
18
+ from: z.ZodOptional<z.ZodString>;
19
+ to: z.ZodOptional<z.ZodString>;
20
+ subject: z.ZodOptional<z.ZodString>;
21
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
+ maxResults: z.ZodDefault<z.ZodNumber>;
23
+ includeSpamTrash: z.ZodDefault<z.ZodBoolean>;
24
+ }, z.core.$strip>;
25
+ output: z.ZodArray<z.ZodObject<{
26
+ id: z.ZodOptional<z.ZodString>;
27
+ threadId: z.ZodOptional<z.ZodString>;
28
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
+ snippet: z.ZodOptional<z.ZodString>;
30
+ payload: z.ZodOptional<z.ZodUnknown>;
31
+ }, z.core.$loose>>;
32
+ idempotent: boolean;
33
+ run({ client, input, req }: PieceRunArgs<z.output<typeof inputSchema>, object, Gmail>): Promise<{}[]>;
34
+ };
35
+ export {};
36
+ //# sourceMappingURL=searchEmails.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchEmails.d.ts","sourceRoot":"","sources":["../../src/actions/searchEmails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,QAAA,MAAM,WAAW;;;;;;;;iBAQf,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;gCAMW,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;CAc5F,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { z } from 'zod';
2
+ import { emailOutput, getOriginal, saveAttachments, searchQuery } from '../mail.js';
3
+ const inputSchema = z.object({
4
+ query: z.string().optional(),
5
+ from: z.string().optional(),
6
+ to: z.string().optional(),
7
+ subject: z.string().optional(),
8
+ labelIds: z.array(z.string()).optional(),
9
+ maxResults: z.number().int().min(1).max(500).default(20),
10
+ includeSpamTrash: z.boolean().default(false),
11
+ });
12
+ export const searchEmails = {
13
+ slug: 'searchEmails',
14
+ description: 'Search emails using Gmail search syntax and common filters.',
15
+ input: inputSchema,
16
+ output: z.array(emailOutput),
17
+ idempotent: true,
18
+ async run({ client, input, req }) {
19
+ const list = await client.users.messages.list({
20
+ userId: 'me',
21
+ q: searchQuery(input),
22
+ labelIds: input.labelIds,
23
+ maxResults: input.maxResults,
24
+ includeSpamTrash: input.includeSpamTrash,
25
+ });
26
+ return Promise.all((list.data.messages ?? []).map(async ({ id }) => id ? saveAttachments(client, req, await getOriginal(client, id)) : {}));
27
+ },
28
+ };
29
+ //# sourceMappingURL=searchEmails.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchEmails.js","sourceRoot":"","sources":["../../src/actions/searchEmails.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AQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;SACzC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,GAAG,CAChB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAC9C,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CACtE,CACF,CAAC;IACJ,CAAC;CACF,CAAC"}
@@ -0,0 +1,56 @@
1
+ import { type PieceRunArgs } from 'frogbot/pieces';
2
+ import { z } from 'zod';
3
+ import type { Gmail } from '../client.js';
4
+ declare const inputSchema: z.ZodObject<{
5
+ replyTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
6
+ senderName: z.ZodOptional<z.ZodString>;
7
+ from: z.ZodOptional<z.ZodString>;
8
+ inReplyTo: z.ZodOptional<z.ZodString>;
9
+ draft: z.ZodDefault<z.ZodBoolean>;
10
+ body: z.ZodString;
11
+ bodyType: z.ZodDefault<z.ZodEnum<{
12
+ plainText: "plainText";
13
+ html: "html";
14
+ }>>;
15
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
16
+ fileId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
17
+ name: z.ZodOptional<z.ZodString>;
18
+ }, z.core.$strip>>>;
19
+ subject: z.ZodString;
20
+ to: z.ZodArray<z.ZodString>;
21
+ cc: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
+ bcc: z.ZodOptional<z.ZodArray<z.ZodString>>;
23
+ }, z.core.$strip>;
24
+ export declare const send: {
25
+ slug: string;
26
+ description: string;
27
+ input: z.ZodObject<{
28
+ replyTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
29
+ senderName: z.ZodOptional<z.ZodString>;
30
+ from: z.ZodOptional<z.ZodString>;
31
+ inReplyTo: z.ZodOptional<z.ZodString>;
32
+ draft: z.ZodDefault<z.ZodBoolean>;
33
+ body: z.ZodString;
34
+ bodyType: z.ZodDefault<z.ZodEnum<{
35
+ plainText: "plainText";
36
+ html: "html";
37
+ }>>;
38
+ attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
39
+ fileId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
40
+ name: z.ZodOptional<z.ZodString>;
41
+ }, z.core.$strip>>>;
42
+ subject: z.ZodString;
43
+ to: z.ZodArray<z.ZodString>;
44
+ cc: z.ZodOptional<z.ZodArray<z.ZodString>>;
45
+ bcc: z.ZodOptional<z.ZodArray<z.ZodString>>;
46
+ }, z.core.$strip>;
47
+ output: z.ZodObject<{
48
+ id: z.ZodOptional<z.ZodString>;
49
+ threadId: z.ZodOptional<z.ZodString>;
50
+ labelIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
51
+ }, z.core.$loose>;
52
+ idempotent: boolean;
53
+ run({ client, input, req }: PieceRunArgs<z.output<typeof inputSchema>, object, Gmail>): Promise<import("googleapis").gmail_v1.Schema$Message>;
54
+ };
55
+ export {};
56
+ //# sourceMappingURL=send.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/actions/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG1C,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;iBASf,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAMmB,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC;CAe5F,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { z } from 'zod';
2
+ import { createRawMessage, messageBody, messageOutput, recipients } from '../mail.js';
3
+ const inputSchema = z.object({
4
+ ...recipients,
5
+ subject: z.string(),
6
+ ...messageBody,
7
+ replyTo: z.array(z.string().email()).optional(),
8
+ senderName: z.string().optional(),
9
+ from: z.string().email().optional(),
10
+ inReplyTo: z.string().optional(),
11
+ draft: z.boolean().default(false),
12
+ });
13
+ export const send = {
14
+ slug: 'send',
15
+ description: 'Send an email or save it as a draft.',
16
+ input: inputSchema,
17
+ output: messageOutput,
18
+ idempotent: false,
19
+ async run({ client, input, req }) {
20
+ let threadId;
21
+ const extraHeaders = [];
22
+ if (input.inReplyTo) {
23
+ extraHeaders.push(`References: ${input.inReplyTo}`, `In-Reply-To: ${input.inReplyTo}`);
24
+ threadId =
25
+ (await client.users.messages.list({ userId: 'me', q: `Rfc822msgid:${input.inReplyTo}` }))
26
+ .data.messages?.[0]?.threadId ?? undefined;
27
+ }
28
+ const message = { threadId, raw: await createRawMessage({ input, req, extraHeaders }) };
29
+ return input.draft
30
+ ? ((await client.users.drafts.create({ userId: 'me', requestBody: { message } })).data
31
+ .message ?? {})
32
+ : (await client.users.messages.send({ userId: 'me', requestBody: message })).data;
33
+ },
34
+ };
35
+ //# sourceMappingURL=send.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"send.js","sourceRoot":"","sources":["../../src/actions/send.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEtF,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3B,GAAG,UAAU;IACb,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,GAAG,WAAW;IACd,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,E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AC,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;iBACjF,OAAO,IAAI,EAAE,CAAC;YACnB,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACtF,CAAC;CACF,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { type gmail_v1 } from 'googleapis';
2
+ export type Gmail = gmail_v1.Gmail;
3
+ export declare function createGmailClient({ auth }: {
4
+ auth: unknown;
5
+ }): gmail_v1.Gmail;
6
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAU,MAAM,YAAY,CAAC;AAInD,MAAM,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;AAEnC,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,kBAQ5D"}
package/dist/client.js ADDED
@@ -0,0 +1,12 @@
1
+ import { google } from 'googleapis';
2
+ import { gmailAuth } from './config.js';
3
+ export function createGmailClient({ auth }) {
4
+ const credential = gmailAuth.parse(auth);
5
+ const oauth = new google.auth.OAuth2();
6
+ oauth.setCredentials({
7
+ access_token: credential.accessToken,
8
+ refresh_token: credential.refreshToken,
9
+ });
10
+ return google.gmail({ version: 'v1', auth: oauth });
11
+ }
12
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,MAAM,UAAU,iBAAiB,CAAC,EAAE,IAAI,EAAqB;IAC3D,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACvC,KAAK,CAAC,cAAc,CAAC;QACnB,YAAY,EAAE,UAAU,CAAC,WAAW;QACpC,aAAa,EAAE,UAAU,CAAC,YAAY;KACvC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { z } from 'zod';
2
+ export declare const gmailAuth: z.ZodObject<{
3
+ accessToken: z.ZodString;
4
+ refreshToken: z.ZodOptional<z.ZodString>;
5
+ }, z.core.$strip>;
6
+ export declare const gmailScopes: readonly ["https://www.googleapis.com/auth/gmail.send", "https://www.googleapis.com/auth/gmail.readonly", "https://www.googleapis.com/auth/gmail.compose"];
7
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS;;;iBAGpB,CAAC;AACH,eAAO,MAAM,WAAW,4JAId,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,11 @@
1
+ import { z } from 'zod';
2
+ export const gmailAuth = z.object({
3
+ accessToken: z.string().min(1).meta({ label: 'Access token', secret: true }),
4
+ refreshToken: z.string().optional().meta({ label: 'Refresh token', secret: true }),
5
+ });
6
+ export const gmailScopes = [
7
+ 'https://www.googleapis.com/auth/gmail.send',
8
+ 'https://www.googleapis.com/auth/gmail.readonly',
9
+ 'https://www.googleapis.com/auth/gmail.compose',
10
+ ];
11
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC5E,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;CACnF,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,4CAA4C;IAC5C,gDAAgD;IAChD,+CAA+C;CACvC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { FrogbotRequest } from 'frogbot';
2
+ import { z } from 'zod';
3
+ export declare const attachment: z.ZodObject<{
4
+ fileId: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
5
+ name: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export declare function loadFileAttachment(req: FrogbotRequest, value: z.output<typeof attachment>): Promise<{
8
+ name: {};
9
+ type: {};
10
+ data: Buffer;
11
+ }>;
12
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,UAAU;;;iBAGrB,CAAC;AAEH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,cAAc,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC;;;;GAiC/F"}
package/dist/files.js ADDED
@@ -0,0 +1,41 @@
1
+ import { z } from 'zod';
2
+ export const attachment = z.object({
3
+ fileId: z.union([z.string(), z.number()]),
4
+ name: z.string().optional(),
5
+ });
6
+ export async function loadFileAttachment(req, value) {
7
+ const collection = req.frogbot.config.files?.slug;
8
+ if (!collection) {
9
+ throw new Error('[frogbot] Gmail attachments require the files collection to be configured.');
10
+ }
11
+ const doc = await req.frogbot.findByID({
12
+ collection,
13
+ id: value.fileId,
14
+ depth: 0,
15
+ req,
16
+ overrideAccess: false,
17
+ });
18
+ if (typeof doc.url !== 'string') {
19
+ throw new Error(`[frogbot] File '${value.fileId}' is unavailable.`);
20
+ }
21
+ const config = await req.frogbot.config._internal.payloadConfig;
22
+ const headers = new Headers();
23
+ for (const name of ['authorization', 'cookie']) {
24
+ const value = req.headers.get(name);
25
+ if (value)
26
+ headers.set(name, value);
27
+ }
28
+ const response = await fetch(new URL(doc.url, config.serverURL || req.url), {
29
+ headers,
30
+ signal: req.signal ?? undefined,
31
+ });
32
+ if (!response.ok) {
33
+ throw new Error(`[frogbot] File '${value.fileId}' is unavailable (${response.status}).`);
34
+ }
35
+ return {
36
+ name: value.name ?? doc.filename ?? doc.name ?? 'attachment',
37
+ type: doc.mimeType ?? 'application/octet-stream',
38
+ data: Buffer.from(await response.arrayBuffer()),
39
+ };
40
+ }
41
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE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