@activepieces/piece-gmail 0.12.5 → 0.12.6

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 (69) hide show
  1. package/package.json +7 -21
  2. package/src/index.js +217 -71
  3. package/src/index.d.ts +0 -6
  4. package/src/index.d.ts.map +0 -1
  5. package/src/index.js.map +0 -1
  6. package/src/lib/actions/create-draft-reply-action.d.ts +0 -17
  7. package/src/lib/actions/create-draft-reply-action.d.ts.map +0 -1
  8. package/src/lib/actions/create-draft-reply-action.js +0 -265
  9. package/src/lib/actions/create-draft-reply-action.js.map +0 -1
  10. package/src/lib/actions/get-mail-action.d.ts +0 -7
  11. package/src/lib/actions/get-mail-action.d.ts.map +0 -1
  12. package/src/lib/actions/get-mail-action.js +0 -40
  13. package/src/lib/actions/get-mail-action.js.map +0 -1
  14. package/src/lib/actions/get-thread-action.d.ts +0 -9
  15. package/src/lib/actions/get-thread-action.d.ts.map +0 -1
  16. package/src/lib/actions/get-thread-action.js +0 -44
  17. package/src/lib/actions/get-thread-action.js.map +0 -1
  18. package/src/lib/actions/reply-to-email-action.d.ts +0 -16
  19. package/src/lib/actions/reply-to-email-action.d.ts.map +0 -1
  20. package/src/lib/actions/reply-to-email-action.js +0 -198
  21. package/src/lib/actions/reply-to-email-action.js.map +0 -1
  22. package/src/lib/actions/request-approval-in-email.d.ts +0 -15
  23. package/src/lib/actions/request-approval-in-email.d.ts.map +0 -1
  24. package/src/lib/actions/request-approval-in-email.js +0 -175
  25. package/src/lib/actions/request-approval-in-email.js.map +0 -1
  26. package/src/lib/actions/search-email-action.d.ts +0 -22
  27. package/src/lib/actions/search-email-action.d.ts.map +0 -1
  28. package/src/lib/actions/search-email-action.js +0 -175
  29. package/src/lib/actions/search-email-action.js.map +0 -1
  30. package/src/lib/actions/send-email-action.d.ts +0 -18
  31. package/src/lib/actions/send-email-action.d.ts.map +0 -1
  32. package/src/lib/actions/send-email-action.js +0 -192
  33. package/src/lib/actions/send-email-action.js.map +0 -1
  34. package/src/lib/auth.d.ts +0 -12
  35. package/src/lib/auth.d.ts.map +0 -1
  36. package/src/lib/auth.js +0 -106
  37. package/src/lib/auth.js.map +0 -1
  38. package/src/lib/common/data.d.ts +0 -132
  39. package/src/lib/common/data.d.ts.map +0 -1
  40. package/src/lib/common/data.js +0 -209
  41. package/src/lib/common/data.js.map +0 -1
  42. package/src/lib/common/models.d.ts +0 -86
  43. package/src/lib/common/models.d.ts.map +0 -1
  44. package/src/lib/common/models.js +0 -26
  45. package/src/lib/common/models.js.map +0 -1
  46. package/src/lib/common/props.d.ts +0 -21
  47. package/src/lib/common/props.d.ts.map +0 -1
  48. package/src/lib/common/props.js +0 -226
  49. package/src/lib/common/props.js.map +0 -1
  50. package/src/lib/triggers/new-attachment.d.ts +0 -208
  51. package/src/lib/triggers/new-attachment.d.ts.map +0 -1
  52. package/src/lib/triggers/new-attachment.js +0 -142
  53. package/src/lib/triggers/new-attachment.js.map +0 -1
  54. package/src/lib/triggers/new-conversation.d.ts +0 -59
  55. package/src/lib/triggers/new-conversation.d.ts.map +0 -1
  56. package/src/lib/triggers/new-conversation.js +0 -306
  57. package/src/lib/triggers/new-conversation.js.map +0 -1
  58. package/src/lib/triggers/new-email.d.ts +0 -52
  59. package/src/lib/triggers/new-email.d.ts.map +0 -1
  60. package/src/lib/triggers/new-email.js +0 -131
  61. package/src/lib/triggers/new-email.js.map +0 -1
  62. package/src/lib/triggers/new-label.d.ts +0 -15
  63. package/src/lib/triggers/new-label.d.ts.map +0 -1
  64. package/src/lib/triggers/new-label.js +0 -78
  65. package/src/lib/triggers/new-label.js.map +0 -1
  66. package/src/lib/triggers/new-labeled-email.d.ts +0 -99
  67. package/src/lib/triggers/new-labeled-email.d.ts.map +0 -1
  68. package/src/lib/triggers/new-labeled-email.js +0 -141
  69. package/src/lib/triggers/new-labeled-email.js.map +0 -1
@@ -1,18 +0,0 @@
1
- export declare const gmailSendEmailAction: import("@activepieces/pieces-framework").IAction<(import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
3
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- }>)[], {
5
- receiver: import("@activepieces/pieces-framework").ArrayProperty<true>;
6
- cc: import("@activepieces/pieces-framework").ArrayProperty<false>;
7
- bcc: import("@activepieces/pieces-framework").ArrayProperty<false>;
8
- subject: import("@activepieces/pieces-framework").ShortTextProperty<true>;
9
- body_type: import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
10
- body: import("@activepieces/pieces-framework").ShortTextProperty<true>;
11
- reply_to: import("@activepieces/pieces-framework").ArrayProperty<false>;
12
- sender_name: import("@activepieces/pieces-framework").ShortTextProperty<false>;
13
- from: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
- attachments: import("@activepieces/pieces-framework").ArrayProperty<true> | import("@activepieces/pieces-framework").ArrayProperty<false>;
15
- in_reply_to: import("@activepieces/pieces-framework").ShortTextProperty<false>;
16
- draft: import("@activepieces/pieces-framework").CheckboxProperty<true>;
17
- }>;
18
- //# sourceMappingURL=send-email-action.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-email-action.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/send-email-action.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;EA2M/B,CAAC"}
@@ -1,192 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.gmailSendEmailAction = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const mime_types_1 = tslib_1.__importDefault(require("mime-types"));
7
- const mail_composer_1 = tslib_1.__importDefault(require("nodemailer/lib/mail-composer"));
8
- const auth_1 = require("../auth");
9
- const googleapis_1 = require("googleapis");
10
- exports.gmailSendEmailAction = (0, pieces_framework_1.createAction)({
11
- auth: auth_1.gmailAuth,
12
- name: 'send_email',
13
- description: 'Send an email through a Gmail account',
14
- audience: 'both',
15
- aiMetadata: {
16
- description: 'Composes and sends a new email from the connected Gmail account to one or more recipients, with optional CC/BCC, attachments, and plain-text or HTML body. Use this to originate a fresh message; to answer an existing thread prefer Reply to Email instead, or pass an original Message-ID to send this message into that existing thread. Set the draft flag to save it as a draft instead of sending. Not idempotent: each call sends (or drafts) a separate message.',
17
- idempotent: false,
18
- },
19
- displayName: 'Send Email',
20
- props: {
21
- receiver: pieces_framework_1.Property.Array({
22
- displayName: 'Receiver Email (To)',
23
- description: undefined,
24
- required: true,
25
- }),
26
- cc: pieces_framework_1.Property.Array({
27
- displayName: 'CC Email',
28
- description: undefined,
29
- required: false,
30
- }),
31
- bcc: pieces_framework_1.Property.Array({
32
- displayName: 'BCC Email',
33
- description: undefined,
34
- required: false,
35
- }),
36
- subject: pieces_framework_1.Property.ShortText({
37
- displayName: 'Subject',
38
- description: undefined,
39
- required: true,
40
- }),
41
- body_type: pieces_framework_1.Property.StaticDropdown({
42
- displayName: 'Body Type',
43
- required: true,
44
- defaultValue: 'plain_text',
45
- options: {
46
- disabled: false,
47
- options: [
48
- {
49
- label: 'plain text',
50
- value: 'plain_text',
51
- },
52
- {
53
- label: 'html',
54
- value: 'html',
55
- },
56
- ],
57
- },
58
- }),
59
- body: pieces_framework_1.Property.ShortText({
60
- displayName: 'Body',
61
- description: 'Body for the email you want to send',
62
- required: true,
63
- }),
64
- reply_to: pieces_framework_1.Property.Array({
65
- displayName: 'Reply-To Email',
66
- description: 'Email address to set as the "Reply-To" header',
67
- required: false,
68
- }),
69
- sender_name: pieces_framework_1.Property.ShortText({
70
- displayName: 'Sender Name',
71
- required: false,
72
- }),
73
- from: pieces_framework_1.Property.ShortText({
74
- displayName: 'Sender Email',
75
- description: "The address must be listed in your GMail account's settings",
76
- required: false,
77
- }),
78
- attachments: pieces_framework_1.Property.Array({
79
- displayName: 'Attachments',
80
- required: false,
81
- properties: {
82
- file: pieces_framework_1.Property.File({
83
- displayName: 'File',
84
- description: 'File to attach to the email you want to send.',
85
- required: true,
86
- }),
87
- name: pieces_framework_1.Property.ShortText({
88
- displayName: 'Attachment Name',
89
- description: 'In case you want to change the name of the attachment.',
90
- required: false,
91
- }),
92
- },
93
- }),
94
- in_reply_to: pieces_framework_1.Property.ShortText({
95
- displayName: 'In reply to',
96
- description: 'Reply to this Message-ID',
97
- required: false,
98
- }),
99
- draft: pieces_framework_1.Property.Checkbox({
100
- displayName: 'Create draft',
101
- description: 'Create draft without sending the actual email',
102
- required: true,
103
- defaultValue: false,
104
- }),
105
- },
106
- run(context) {
107
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
108
- var _a, _b, _c, _d, _e;
109
- const authClient = yield (0, auth_1.createGoogleClient)(context.auth);
110
- const gmail = googleapis_1.google.gmail({ version: 'v1', auth: authClient });
111
- const subjectBase64 = Buffer.from(context.propsValue['subject']).toString('base64');
112
- const attachments = context.propsValue.attachments;
113
- const replyTo = (_a = context.propsValue['reply_to']) === null || _a === void 0 ? void 0 : _a.filter((email) => email !== '');
114
- const receiver = (_b = context.propsValue['receiver']) === null || _b === void 0 ? void 0 : _b.filter((email) => email !== '');
115
- const cc = (_c = context.propsValue['cc']) === null || _c === void 0 ? void 0 : _c.filter((email) => email !== '');
116
- const bcc = (_d = context.propsValue['bcc']) === null || _d === void 0 ? void 0 : _d.filter((email) => email !== '');
117
- const mailOptions = {
118
- to: receiver.join(', '), // Join all email addresses with a comma
119
- cc: cc ? cc.join(', ') : undefined,
120
- bcc: bcc ? bcc.join(', ') : undefined,
121
- subject: `=?UTF-8?B?${subjectBase64}?=`,
122
- replyTo: replyTo ? replyTo.join(', ') : '',
123
- text: context.propsValue.body_type === 'plain_text'
124
- ? context.propsValue['body']
125
- : undefined,
126
- html: context.propsValue.body_type === 'html'
127
- ? context.propsValue['body']
128
- : undefined,
129
- attachments: [],
130
- };
131
- let threadId = undefined;
132
- if (context.propsValue.in_reply_to) {
133
- mailOptions.headers = [
134
- {
135
- key: 'References',
136
- value: context.propsValue.in_reply_to,
137
- },
138
- {
139
- key: 'In-Reply-To',
140
- value: context.propsValue.in_reply_to,
141
- },
142
- ];
143
- const messages = yield gmail.users.messages.list({
144
- userId: 'me',
145
- q: `Rfc822msgid:${context.propsValue.in_reply_to}`,
146
- });
147
- threadId = (_e = messages.data.messages) === null || _e === void 0 ? void 0 : _e[0].threadId;
148
- }
149
- const senderEmail = context.propsValue.from || (yield (0, auth_1.getUserEmail)(context.auth, authClient));
150
- if (senderEmail) {
151
- mailOptions.from = context.propsValue.sender_name
152
- ? `${context.propsValue['sender_name']} <${senderEmail}>`
153
- : senderEmail;
154
- }
155
- if (attachments && attachments.length > 0) {
156
- const attachmentOption = attachments.map(({ file, name }) => {
157
- const lookupResult = mime_types_1.default.lookup(file.extension ? file.extension : '');
158
- return {
159
- filename: name !== null && name !== void 0 ? name : file.filename,
160
- content: file === null || file === void 0 ? void 0 : file.base64,
161
- contentType: lookupResult ? lookupResult : undefined,
162
- encoding: 'base64',
163
- };
164
- });
165
- mailOptions.attachments = attachmentOption;
166
- }
167
- const mail = new mail_composer_1.default(mailOptions).compile();
168
- mail.keepBcc = true;
169
- const mailBody = yield mail.build();
170
- const encodedPayload = Buffer.from(mailBody)
171
- .toString('base64')
172
- .replace(/\+/g, '-')
173
- .replace(/\//g, '_');
174
- if (context.propsValue.draft) {
175
- return yield gmail.users.drafts.create({
176
- userId: 'me',
177
- requestBody: { message: { threadId, raw: encodedPayload } },
178
- });
179
- }
180
- else {
181
- return yield gmail.users.messages.send({
182
- userId: 'me',
183
- requestBody: {
184
- threadId,
185
- raw: encodedPayload,
186
- },
187
- });
188
- }
189
- });
190
- },
191
- });
192
- //# sourceMappingURL=send-email-action.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-email-action.js","sourceRoot":"","sources":["../../../../src/lib/actions/send-email-action.ts"],"names":[],"mappings":";;;;AAAA,qEA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EAAE,CAAC;gBAC7B,OAAO,MAAM,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;oBACrC,MAAM,EAAE,IAAI;oBACZ,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,cAAc,EAAE,EAAE;iBAC5D,CAAC,CAAC;YACL,CAAC;iBAAM,CAAC;gBACN,OAAO,MAAM,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;oBACrC,MAAM,EAAE,IAAI;oBACZ,WAAW,EAAE;wBACX,QAAQ;wBACR,GAAG,EAAE,cAAc;qBACpB;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
package/src/lib/auth.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
2
- import { OAuth2Client } from 'googleapis-common';
3
- export declare const gmailScopes: string[];
4
- export declare const gmailAuth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
5
- serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
6
- userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
- }>)[];
8
- export type GmailAuthValue = AppConnectionValueForAuthProperty<typeof gmailAuth>;
9
- export declare function createGoogleClient(auth: GmailAuthValue): Promise<OAuth2Client>;
10
- export declare const getAccessToken: (auth: GmailAuthValue) => Promise<string>;
11
- export declare function getUserEmail(auth: GmailAuthValue, authClient: OAuth2Client): Promise<string | undefined>;
12
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD,eAAO,MAAM,WAAW,UAA0C,CAAC;AAEnE,eAAO,MAAM,SAAS;;;KA0CrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,iCAAiC,CAC5D,OAAO,SAAS,CACjB,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,cAAc,GACnB,OAAO,CAAC,YAAY,CAAC,CAoBvB;AAED,eAAO,MAAM,cAAc,SAAgB,cAAc,KAAG,OAAO,CAAC,MAAM,CAazE,CAAC;AAEF,wBAAsB,YAAY,CAChC,IAAI,EAAE,cAAc,EACpB,UAAU,EAAE,YAAY,GACvB,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAQ7B"}
package/src/lib/auth.js DELETED
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAccessToken = exports.gmailAuth = exports.gmailScopes = void 0;
4
- exports.createGoogleClient = createGoogleClient;
5
- exports.getUserEmail = getUserEmail;
6
- const tslib_1 = require("tslib");
7
- const pieces_framework_1 = require("@activepieces/pieces-framework");
8
- const shared_1 = require("@activepieces/shared");
9
- const googleapis_1 = require("googleapis");
10
- const googleapis_common_1 = require("googleapis-common");
11
- const gmailServiceAccountScopes = [
12
- 'https://www.googleapis.com/auth/gmail.send',
13
- 'https://www.googleapis.com/auth/gmail.readonly',
14
- 'https://www.googleapis.com/auth/gmail.compose',
15
- ];
16
- exports.gmailScopes = [...gmailServiceAccountScopes, 'email'];
17
- exports.gmailAuth = [
18
- pieces_framework_1.PieceAuth.OAuth2({
19
- description: '',
20
- authUrl: 'https://accounts.google.com/o/oauth2/auth',
21
- tokenUrl: 'https://oauth2.googleapis.com/token',
22
- required: true,
23
- scope: exports.gmailScopes,
24
- }),
25
- pieces_framework_1.PieceAuth.CustomAuth({
26
- displayName: 'Service Account (Advanced)',
27
- description: 'Authenticate via service account from https://console.cloud.google.com/ > IAM & Admin > Service Accounts > Create Service Account > Keys > Add key. <br> <br> You can optionally use domain-wide delegation (https://support.google.com/a/answer/162106?hl=en#zippy=%2Cset-up-domain-wide-delegation-for-a-client) to access Gmail without adding the service account to each mailbox. <br> <br> **Note:** A user email with domain-wide delegation is required for Gmail service account access.',
28
- required: true,
29
- props: {
30
- serviceAccount: pieces_framework_1.Property.LongText({
31
- displayName: 'Service Account JSON Key',
32
- required: true,
33
- }),
34
- userEmail: pieces_framework_1.Property.ShortText({
35
- displayName: 'User Email',
36
- required: true,
37
- description: 'Email address of the user to impersonate. Required for Gmail service account access via domain-wide delegation.',
38
- }),
39
- },
40
- validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
41
- try {
42
- yield (0, exports.getAccessToken)({
43
- type: shared_1.AppConnectionType.CUSTOM_AUTH,
44
- props: Object.assign({}, auth),
45
- });
46
- }
47
- catch (e) {
48
- return {
49
- valid: false,
50
- error: e.message,
51
- };
52
- }
53
- return {
54
- valid: true,
55
- };
56
- }),
57
- }),
58
- ];
59
- function createGoogleClient(auth) {
60
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
61
- var _a;
62
- if (auth.type === shared_1.AppConnectionType.CUSTOM_AUTH) {
63
- let serviceAccount;
64
- try {
65
- serviceAccount = JSON.parse(auth.props.serviceAccount);
66
- }
67
- catch (_b) {
68
- throw new Error('Invalid Service Account JSON Key. Please provide a valid JSON string.');
69
- }
70
- return new googleapis_1.google.auth.JWT({
71
- email: serviceAccount.client_email,
72
- key: serviceAccount.private_key,
73
- scopes: gmailServiceAccountScopes,
74
- subject: ((_a = auth.props.userEmail) === null || _a === void 0 ? void 0 : _a.trim()) || undefined,
75
- });
76
- }
77
- const authClient = new googleapis_common_1.OAuth2Client();
78
- authClient.setCredentials(auth);
79
- return authClient;
80
- });
81
- }
82
- const getAccessToken = (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
83
- if (auth.type === shared_1.AppConnectionType.CUSTOM_AUTH) {
84
- const googleClient = yield createGoogleClient(auth);
85
- const response = yield googleClient.getAccessToken();
86
- if (response.token) {
87
- return response.token;
88
- }
89
- else {
90
- throw new Error('Could not retrieve access token from service account json');
91
- }
92
- }
93
- return auth.access_token;
94
- });
95
- exports.getAccessToken = getAccessToken;
96
- function getUserEmail(auth, authClient) {
97
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
98
- var _a, _b;
99
- if (auth.type === shared_1.AppConnectionType.CUSTOM_AUTH) {
100
- return (_a = auth.props.userEmail) === null || _a === void 0 ? void 0 : _a.trim();
101
- }
102
- return ((_b = (yield googleapis_1.google.oauth2({ version: 'v2', auth: authClient }).userinfo.get())
103
- .data.email) !== null && _b !== void 0 ? _b : undefined);
104
- });
105
- }
106
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAiEA,gDAsBC;AAiBD,oCAWC;;AAnHD,qEAIwC;AACxC,iDAAyD;AACzD,2CAAoC;AACpC,yDAAiD;AAEjD,MAAM,yBAAyB,GAAG;IAChC,4CAA4C;IAC5C,gDAAgD;IAChD,+CAA+C;CAChD,CAAC;AAEW,QAAA,WAAW,GAAG,CAAC,GAAG,yBAAyB,EAAE,OAAO,CAAC,CAAC;AAEtD,QAAA,SAAS,GAAG;IACvB,4BAAS,CAAC,MAAM,CAAC;QACf,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,2CAA2C;QACpD,QAAQ,EAAE,qCAAqC;QAC/C,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE,mBAAW;KACnB,CAAC;IACF,4BAAS,CAAC,UAAU,CAAC;QACnB,WAAW,EAAE,4BAA4B;QACzC,WAAW,EACT,oeAAoe;QACte,QAAQ,EAAE,IAAI;QACd,KAAK,EAAE;YACL,cAAc,EAAE,2BAAQ,CAAC,QAAQ,CAAC;gBAChC,WAAW,EAAE,0BAA0B;gBACvC,QAAQ,EAAE,IAAI;aACf,CAAC;YACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;g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UAAU,CAAC;IACpB,CAAC;CAAA;AAEM,MAAM,cAAc,GAAG,CAAO,IAAoB,EAAmB,EAAE;IAC5E,IAAI,IAAI,CAAC,IAAI,KAAK,0BAAiB,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,cAAc,EAAE,CAAC;QACrD,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,YAAY,CAAC;AAC3B,CAAC,CAAA,CAAC;AAbW,QAAA,cAAc,kBAazB;AAEF,SAAsB,YAAY,CAChC,IAAoB,EACpB,UAAwB;;;QAExB,IAAI,IAAI,CAAC,IAAI,KAAK,0BAAiB,CAAC,WAAW,EAAE,CAAC;YAChD,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,SAAS,0CAAE,IAAI,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,CACL,MAAA,CAAC,MAAM,mBAAM,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;aACtE,IAAI,CAAC,KAAK,mCAAI,SAAS,CAC3B,CAAC;IACJ,CAAC;CAAA"}
@@ -1,132 +0,0 @@
1
- import { FilesService } from '@activepieces/pieces-framework';
2
- import { GmailLabel, GmailThread, GmailMessageFormat, GmailMessageResponse as GmailMessageList } from './models';
3
- import { Attachment, ParsedMail } from 'mailparser';
4
- import { GmailAuthValue } from '../auth';
5
- interface SearchMailProps {
6
- access_token: string;
7
- from: string;
8
- to: string;
9
- subject?: string;
10
- label: GmailLabel;
11
- category: string;
12
- after?: number;
13
- before?: number;
14
- max_results?: number;
15
- page_token?: string;
16
- }
17
- interface GetMailProps {
18
- access_token: string;
19
- message_id?: string;
20
- thread_id?: string;
21
- format: GmailMessageFormat;
22
- }
23
- export declare const GmailRequests: {
24
- getMail: ({ access_token, format, message_id }: GetMailProps) => Promise<{
25
- id: string;
26
- threadId: string;
27
- labelIds: [string];
28
- snippet: string;
29
- historyId: string;
30
- internalDate: number;
31
- payload: {
32
- partId: string;
33
- mimeType: string;
34
- filename: string;
35
- headers: {
36
- name: string;
37
- value: string;
38
- }[];
39
- body: {
40
- data: any;
41
- size: number;
42
- };
43
- parts: {
44
- parts: any[];
45
- partId: string;
46
- mimeType: string;
47
- filename: string;
48
- headers: {
49
- name: string;
50
- value: string;
51
- }[];
52
- body: {
53
- size: number;
54
- data: string;
55
- };
56
- }[];
57
- };
58
- sizeEstimate: number;
59
- raw: string;
60
- subject: string;
61
- body_html: string;
62
- body_plain: string;
63
- }>;
64
- getThread: ({ access_token, format, thread_id }: GetMailProps) => Promise<GmailThread>;
65
- getLabels: (authentication: GmailAuthValue) => Promise<import("@activepieces/pieces-common").HttpResponse<{
66
- labels: GmailLabel[];
67
- }>>;
68
- searchMail: ({ access_token, max_results, page_token: pageToken, ...mail }: SearchMailProps) => Promise<GmailMessageList | {
69
- nextPageToken?: string | undefined;
70
- messages: {
71
- message: {
72
- id: string;
73
- threadId: string;
74
- labelIds: [string];
75
- snippet: string;
76
- historyId: string;
77
- internalDate: number;
78
- payload: {
79
- partId: string;
80
- mimeType: string;
81
- filename: string;
82
- headers: {
83
- name: string;
84
- value: string;
85
- }[];
86
- body: {
87
- data: any;
88
- size: number;
89
- };
90
- parts: {
91
- parts: any[];
92
- partId: string;
93
- mimeType: string;
94
- filename: string;
95
- headers: {
96
- name: string;
97
- value: string;
98
- }[];
99
- body: {
100
- size: number;
101
- data: string;
102
- };
103
- }[];
104
- };
105
- sizeEstimate: number;
106
- raw: string;
107
- subject: string;
108
- body_html: string;
109
- body_plain: string;
110
- };
111
- thread: GmailThread;
112
- }[];
113
- resultSizeEstimate: number;
114
- }>;
115
- getRecentMessages: (authentication: GmailAuthValue, maxResults?: number) => Promise<import("@activepieces/pieces-common").HttpResponse<GmailMessageList>>;
116
- getRecentThreads: (authentication: GmailAuthValue, maxResults?: number) => Promise<import("@activepieces/pieces-common").HttpResponse<{
117
- threads: {
118
- id: string;
119
- snippet?: string;
120
- }[];
121
- }>>;
122
- };
123
- export declare function parseStream(stream: any): Promise<ParsedMail>;
124
- export declare function convertAttachment(attachments: Attachment[], files: FilesService): Promise<{
125
- fileName: string;
126
- mimeType: string;
127
- size: number;
128
- data: string;
129
- }[]>;
130
- export declare function getFirstFiveOrAll(array: unknown[]): unknown[];
131
- export {};
132
- //# sourceMappingURL=data.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EACL,UAAU,EAEV,WAAW,EACX,kBAAkB,EAClB,oBAAoB,IAAI,gBAAgB,EACzC,MAAM,UAAU,CAAC;AAMlB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,cAAc,EAAkB,MAAM,SAAS,CAAC;AAEzD,UAAU,eAAe;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,YAAY;IACpB,YAAY,EAAE,MAAM,CA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