@activepieces/piece-gmail 0.12.4 → 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.
- package/package.json +7 -21
- package/src/index.js +217 -71
- package/src/index.d.ts +0 -6
- package/src/index.d.ts.map +0 -1
- package/src/index.js.map +0 -1
- package/src/lib/actions/create-draft-reply-action.d.ts +0 -17
- package/src/lib/actions/create-draft-reply-action.d.ts.map +0 -1
- package/src/lib/actions/create-draft-reply-action.js +0 -260
- package/src/lib/actions/create-draft-reply-action.js.map +0 -1
- package/src/lib/actions/get-mail-action.d.ts +0 -7
- package/src/lib/actions/get-mail-action.d.ts.map +0 -1
- package/src/lib/actions/get-mail-action.js +0 -35
- package/src/lib/actions/get-mail-action.js.map +0 -1
- package/src/lib/actions/get-thread-action.d.ts +0 -9
- package/src/lib/actions/get-thread-action.d.ts.map +0 -1
- package/src/lib/actions/get-thread-action.js +0 -44
- package/src/lib/actions/get-thread-action.js.map +0 -1
- package/src/lib/actions/reply-to-email-action.d.ts +0 -16
- package/src/lib/actions/reply-to-email-action.d.ts.map +0 -1
- package/src/lib/actions/reply-to-email-action.js +0 -193
- package/src/lib/actions/reply-to-email-action.js.map +0 -1
- package/src/lib/actions/request-approval-in-email.d.ts +0 -15
- package/src/lib/actions/request-approval-in-email.d.ts.map +0 -1
- package/src/lib/actions/request-approval-in-email.js +0 -170
- package/src/lib/actions/request-approval-in-email.js.map +0 -1
- package/src/lib/actions/search-email-action.d.ts +0 -22
- package/src/lib/actions/search-email-action.d.ts.map +0 -1
- package/src/lib/actions/search-email-action.js +0 -170
- package/src/lib/actions/search-email-action.js.map +0 -1
- package/src/lib/actions/send-email-action.d.ts +0 -18
- package/src/lib/actions/send-email-action.d.ts.map +0 -1
- package/src/lib/actions/send-email-action.js +0 -187
- package/src/lib/actions/send-email-action.js.map +0 -1
- package/src/lib/auth.d.ts +0 -12
- package/src/lib/auth.d.ts.map +0 -1
- package/src/lib/auth.js +0 -106
- package/src/lib/auth.js.map +0 -1
- package/src/lib/common/data.d.ts +0 -132
- package/src/lib/common/data.d.ts.map +0 -1
- package/src/lib/common/data.js +0 -209
- package/src/lib/common/data.js.map +0 -1
- package/src/lib/common/models.d.ts +0 -86
- package/src/lib/common/models.d.ts.map +0 -1
- package/src/lib/common/models.js +0 -26
- package/src/lib/common/models.js.map +0 -1
- package/src/lib/common/props.d.ts +0 -21
- package/src/lib/common/props.d.ts.map +0 -1
- package/src/lib/common/props.js +0 -226
- package/src/lib/common/props.js.map +0 -1
- package/src/lib/triggers/new-attachment.d.ts +0 -208
- package/src/lib/triggers/new-attachment.d.ts.map +0 -1
- package/src/lib/triggers/new-attachment.js +0 -139
- package/src/lib/triggers/new-attachment.js.map +0 -1
- package/src/lib/triggers/new-conversation.d.ts +0 -59
- package/src/lib/triggers/new-conversation.d.ts.map +0 -1
- package/src/lib/triggers/new-conversation.js +0 -306
- package/src/lib/triggers/new-conversation.js.map +0 -1
- package/src/lib/triggers/new-email.d.ts +0 -52
- package/src/lib/triggers/new-email.d.ts.map +0 -1
- package/src/lib/triggers/new-email.js +0 -128
- package/src/lib/triggers/new-email.js.map +0 -1
- package/src/lib/triggers/new-label.d.ts +0 -15
- package/src/lib/triggers/new-label.d.ts.map +0 -1
- package/src/lib/triggers/new-label.js +0 -75
- package/src/lib/triggers/new-label.js.map +0 -1
- package/src/lib/triggers/new-labeled-email.d.ts +0 -99
- package/src/lib/triggers/new-labeled-email.d.ts.map +0 -1
- package/src/lib/triggers/new-labeled-email.js +0 -138
- package/src/lib/triggers/new-labeled-email.js.map +0 -1
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
-
import { GmailLabel } from '../common/models';
|
|
3
|
-
export declare const gmailNewAttachmentTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
4
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
5
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
|
-
}>)[], {
|
|
7
|
-
from: {
|
|
8
|
-
description: string;
|
|
9
|
-
displayName: string;
|
|
10
|
-
required: false;
|
|
11
|
-
valueSchema: string;
|
|
12
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
13
|
-
defaultValue?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
to: {
|
|
16
|
-
description: string;
|
|
17
|
-
displayName: string;
|
|
18
|
-
required: false;
|
|
19
|
-
valueSchema: string;
|
|
20
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
21
|
-
defaultValue?: string | undefined;
|
|
22
|
-
};
|
|
23
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
24
|
-
label: {
|
|
25
|
-
description: string;
|
|
26
|
-
displayName: string;
|
|
27
|
-
required: false;
|
|
28
|
-
auth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
29
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
30
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
31
|
-
}>)[];
|
|
32
|
-
refreshers: string[];
|
|
33
|
-
refreshOnSearch?: boolean;
|
|
34
|
-
options: (propsValue: Record<string, unknown> & {
|
|
35
|
-
auth?: import("@activepieces/shared").OAuth2ConnectionValueWithApp | import("@activepieces/shared").CustomAuthConnectionValue<import("@activepieces/pieces-framework").StaticPropsValue<{
|
|
36
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
37
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
38
|
-
}>> | undefined;
|
|
39
|
-
}, ctx: import("@activepieces/pieces-framework").PropertyContext) => Promise<import("@activepieces/pieces-framework").DropdownState<GmailLabel>>;
|
|
40
|
-
valueSchema: GmailLabel;
|
|
41
|
-
type: import("@activepieces/pieces-framework").PropertyType.DROPDOWN;
|
|
42
|
-
defaultValue?: unknown;
|
|
43
|
-
};
|
|
44
|
-
category: {
|
|
45
|
-
description: string;
|
|
46
|
-
displayName: string;
|
|
47
|
-
required: false;
|
|
48
|
-
options: import("@activepieces/pieces-framework").DropdownState<string>;
|
|
49
|
-
valueSchema: string;
|
|
50
|
-
type: import("@activepieces/pieces-framework").PropertyType.STATIC_DROPDOWN;
|
|
51
|
-
defaultValue?: unknown;
|
|
52
|
-
};
|
|
53
|
-
filenameExtension: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
54
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
55
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
56
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
57
|
-
}>)[], {
|
|
58
|
-
from: {
|
|
59
|
-
description: string;
|
|
60
|
-
displayName: string;
|
|
61
|
-
required: false;
|
|
62
|
-
valueSchema: string;
|
|
63
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
64
|
-
defaultValue?: string | undefined;
|
|
65
|
-
};
|
|
66
|
-
to: {
|
|
67
|
-
description: string;
|
|
68
|
-
displayName: string;
|
|
69
|
-
required: false;
|
|
70
|
-
valueSchema: string;
|
|
71
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
72
|
-
defaultValue?: string | undefined;
|
|
73
|
-
};
|
|
74
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
75
|
-
label: {
|
|
76
|
-
description: string;
|
|
77
|
-
displayName: string;
|
|
78
|
-
required: false;
|
|
79
|
-
auth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
80
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
81
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
82
|
-
}>)[];
|
|
83
|
-
refreshers: string[];
|
|
84
|
-
refreshOnSearch?: boolean;
|
|
85
|
-
options: (propsValue: Record<string, unknown> & {
|
|
86
|
-
auth?: import("@activepieces/shared").OAuth2ConnectionValueWithApp | import("@activepieces/shared").CustomAuthConnectionValue<import("@activepieces/pieces-framework").StaticPropsValue<{
|
|
87
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
88
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
89
|
-
}>> | undefined;
|
|
90
|
-
}, ctx: import("@activepieces/pieces-framework").PropertyContext) => Promise<import("@activepieces/pieces-framework").DropdownState<GmailLabel>>;
|
|
91
|
-
valueSchema: GmailLabel;
|
|
92
|
-
type: import("@activepieces/pieces-framework").PropertyType.DROPDOWN;
|
|
93
|
-
defaultValue?: unknown;
|
|
94
|
-
};
|
|
95
|
-
category: {
|
|
96
|
-
description: string;
|
|
97
|
-
displayName: string;
|
|
98
|
-
required: false;
|
|
99
|
-
options: import("@activepieces/pieces-framework").DropdownState<string>;
|
|
100
|
-
valueSchema: string;
|
|
101
|
-
type: import("@activepieces/pieces-framework").PropertyType.STATIC_DROPDOWN;
|
|
102
|
-
defaultValue?: unknown;
|
|
103
|
-
};
|
|
104
|
-
filenameExtension: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
105
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
106
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
107
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
108
|
-
}>)[], {
|
|
109
|
-
from: {
|
|
110
|
-
description: string;
|
|
111
|
-
displayName: string;
|
|
112
|
-
required: false;
|
|
113
|
-
valueSchema: string;
|
|
114
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
115
|
-
defaultValue?: string | undefined;
|
|
116
|
-
};
|
|
117
|
-
to: {
|
|
118
|
-
description: string;
|
|
119
|
-
displayName: string;
|
|
120
|
-
required: false;
|
|
121
|
-
valueSchema: string;
|
|
122
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
123
|
-
defaultValue?: string | undefined;
|
|
124
|
-
};
|
|
125
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
126
|
-
label: {
|
|
127
|
-
description: string;
|
|
128
|
-
displayName: string;
|
|
129
|
-
required: false;
|
|
130
|
-
auth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
131
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
132
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
133
|
-
}>)[];
|
|
134
|
-
refreshers: string[];
|
|
135
|
-
refreshOnSearch?: boolean;
|
|
136
|
-
options: (propsValue: Record<string, unknown> & {
|
|
137
|
-
auth?: import("@activepieces/shared").OAuth2ConnectionValueWithApp | import("@activepieces/shared").CustomAuthConnectionValue<import("@activepieces/pieces-framework").StaticPropsValue<{
|
|
138
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
139
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
140
|
-
}>> | undefined;
|
|
141
|
-
}, ctx: import("@activepieces/pieces-framework").PropertyContext) => Promise<import("@activepieces/pieces-framework").DropdownState<GmailLabel>>;
|
|
142
|
-
valueSchema: GmailLabel;
|
|
143
|
-
type: import("@activepieces/pieces-framework").PropertyType.DROPDOWN;
|
|
144
|
-
defaultValue?: unknown;
|
|
145
|
-
};
|
|
146
|
-
category: {
|
|
147
|
-
description: string;
|
|
148
|
-
displayName: string;
|
|
149
|
-
required: false;
|
|
150
|
-
options: import("@activepieces/pieces-framework").DropdownState<string>;
|
|
151
|
-
valueSchema: string;
|
|
152
|
-
type: import("@activepieces/pieces-framework").PropertyType.STATIC_DROPDOWN;
|
|
153
|
-
defaultValue?: unknown;
|
|
154
|
-
};
|
|
155
|
-
filenameExtension: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
156
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
157
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
158
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
159
|
-
}>)[], {
|
|
160
|
-
from: {
|
|
161
|
-
description: string;
|
|
162
|
-
displayName: string;
|
|
163
|
-
required: false;
|
|
164
|
-
valueSchema: string;
|
|
165
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
166
|
-
defaultValue?: string | undefined;
|
|
167
|
-
};
|
|
168
|
-
to: {
|
|
169
|
-
description: string;
|
|
170
|
-
displayName: string;
|
|
171
|
-
required: false;
|
|
172
|
-
valueSchema: string;
|
|
173
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
174
|
-
defaultValue?: string | undefined;
|
|
175
|
-
};
|
|
176
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
177
|
-
label: {
|
|
178
|
-
description: string;
|
|
179
|
-
displayName: string;
|
|
180
|
-
required: false;
|
|
181
|
-
auth: (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
182
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
183
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
184
|
-
}>)[];
|
|
185
|
-
refreshers: string[];
|
|
186
|
-
refreshOnSearch?: boolean;
|
|
187
|
-
options: (propsValue: Record<string, unknown> & {
|
|
188
|
-
auth?: import("@activepieces/shared").OAuth2ConnectionValueWithApp | import("@activepieces/shared").CustomAuthConnectionValue<import("@activepieces/pieces-framework").StaticPropsValue<{
|
|
189
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
190
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
191
|
-
}>> | undefined;
|
|
192
|
-
}, ctx: import("@activepieces/pieces-framework").PropertyContext) => Promise<import("@activepieces/pieces-framework").DropdownState<GmailLabel>>;
|
|
193
|
-
valueSchema: GmailLabel;
|
|
194
|
-
type: import("@activepieces/pieces-framework").PropertyType.DROPDOWN;
|
|
195
|
-
defaultValue?: unknown;
|
|
196
|
-
};
|
|
197
|
-
category: {
|
|
198
|
-
description: string;
|
|
199
|
-
displayName: string;
|
|
200
|
-
required: false;
|
|
201
|
-
options: import("@activepieces/pieces-framework").DropdownState<string>;
|
|
202
|
-
valueSchema: string;
|
|
203
|
-
type: import("@activepieces/pieces-framework").PropertyType.STATIC_DROPDOWN;
|
|
204
|
-
defaultValue?: unknown;
|
|
205
|
-
};
|
|
206
|
-
filenameExtension: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
207
|
-
}>;
|
|
208
|
-
//# sourceMappingURL=new-attachment.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-attachment.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,gCAAgC,CAAC;AASxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAW9C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkFpC,CAAC"}
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.gmailNewAttachmentTrigger = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
-
const props_1 = require("../common/props");
|
|
7
|
-
const auth_1 = require("../auth");
|
|
8
|
-
const googleapis_1 = require("googleapis");
|
|
9
|
-
const data_1 = require("../common/data");
|
|
10
|
-
exports.gmailNewAttachmentTrigger = (0, pieces_framework_1.createTrigger)({
|
|
11
|
-
auth: auth_1.gmailAuth,
|
|
12
|
-
name: 'new_attachment',
|
|
13
|
-
displayName: 'New Attachment',
|
|
14
|
-
description: 'Triggers when an email with an attachment arrives.',
|
|
15
|
-
props: {
|
|
16
|
-
from: Object.assign(Object.assign({}, props_1.GmailProps.from), { description: 'Filter by sender email.', displayName: 'From', required: false }),
|
|
17
|
-
to: Object.assign(Object.assign({}, props_1.GmailProps.to), { description: 'Filter by recipient email.', displayName: 'To', required: false }),
|
|
18
|
-
subject: pieces_framework_1.Property.ShortText({
|
|
19
|
-
displayName: 'Subject Contains',
|
|
20
|
-
description: 'Only trigger for emails containing this text in the subject.',
|
|
21
|
-
required: false,
|
|
22
|
-
}),
|
|
23
|
-
label: Object.assign(Object.assign({}, props_1.GmailProps.label), { description: 'Filter by Gmail label.', displayName: 'Label', required: false }),
|
|
24
|
-
category: Object.assign(Object.assign({}, props_1.GmailProps.category), { description: 'Filter by Gmail category.', displayName: 'Category', required: false }),
|
|
25
|
-
filenameExtension: pieces_framework_1.Property.ShortText({
|
|
26
|
-
displayName: 'File Extension',
|
|
27
|
-
description: 'Only trigger for attachments with this file extension (e.g., pdf, jpg, docx).',
|
|
28
|
-
required: false,
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
sampleData: {},
|
|
32
|
-
type: pieces_framework_1.TriggerStrategy.POLLING,
|
|
33
|
-
onEnable(context) {
|
|
34
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
yield context.store.put('lastPoll', Date.now());
|
|
36
|
-
});
|
|
37
|
-
},
|
|
38
|
-
onDisable(context) {
|
|
39
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
return;
|
|
41
|
-
});
|
|
42
|
-
},
|
|
43
|
-
run(context) {
|
|
44
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
var _a;
|
|
46
|
-
const lastFetchEpochMS = (_a = (yield context.store.get('lastPoll'))) !== null && _a !== void 0 ? _a : 0;
|
|
47
|
-
const items = yield pollRecentMessages({
|
|
48
|
-
auth: context.auth,
|
|
49
|
-
props: context.propsValue,
|
|
50
|
-
files: context.files,
|
|
51
|
-
lastFetchEpochMS: lastFetchEpochMS,
|
|
52
|
-
});
|
|
53
|
-
const newLastEpochMilliSeconds = items.reduce((acc, item) => Math.max(acc, item.epochMilliSeconds), lastFetchEpochMS);
|
|
54
|
-
yield context.store.put('lastPoll', newLastEpochMilliSeconds);
|
|
55
|
-
return items
|
|
56
|
-
.filter((f) => f.epochMilliSeconds > lastFetchEpochMS)
|
|
57
|
-
.map((item) => item.data);
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
test(context) {
|
|
61
|
-
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
var _a;
|
|
63
|
-
const lastFetchEpochMS = (_a = (yield context.store.get('lastPoll'))) !== null && _a !== void 0 ? _a : 0;
|
|
64
|
-
const items = yield pollRecentMessages({
|
|
65
|
-
auth: context.auth,
|
|
66
|
-
props: context.propsValue,
|
|
67
|
-
files: context.files,
|
|
68
|
-
lastFetchEpochMS: lastFetchEpochMS,
|
|
69
|
-
});
|
|
70
|
-
return (0, data_1.getFirstFiveOrAll)(items.map((item) => item.data));
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
function pollRecentMessages(_a) {
|
|
75
|
-
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, props, files, lastFetchEpochMS, }) {
|
|
76
|
-
var _b;
|
|
77
|
-
const authClient = yield (0, auth_1.createGoogleClient)(auth);
|
|
78
|
-
const gmail = googleapis_1.google.gmail({ version: 'v1', auth: authClient });
|
|
79
|
-
// construct query
|
|
80
|
-
const query = ['has:attachment'];
|
|
81
|
-
const maxResults = lastFetchEpochMS === 0 ? 5 : 20;
|
|
82
|
-
const afterUnixSeconds = Math.floor(lastFetchEpochMS / 1000);
|
|
83
|
-
if (props.from)
|
|
84
|
-
query.push(`from:(${props.from})`);
|
|
85
|
-
if (props.to)
|
|
86
|
-
query.push(`to:(${props.to})`);
|
|
87
|
-
if (props.subject)
|
|
88
|
-
query.push(`subject:(${props.subject})`);
|
|
89
|
-
if (props.label)
|
|
90
|
-
query.push(`label:${props.label.name}`);
|
|
91
|
-
if (props.category)
|
|
92
|
-
query.push(`category:${props.category}`);
|
|
93
|
-
if (props.filenameExtension)
|
|
94
|
-
query.push(`filename:${props.filenameExtension}`);
|
|
95
|
-
if (afterUnixSeconds != null && afterUnixSeconds > 0)
|
|
96
|
-
query.push(`after:${afterUnixSeconds}`);
|
|
97
|
-
// List Messages
|
|
98
|
-
const messagesResponse = yield gmail.users.messages.list({
|
|
99
|
-
userId: 'me',
|
|
100
|
-
q: query.join(' '),
|
|
101
|
-
maxResults,
|
|
102
|
-
});
|
|
103
|
-
// Reverse to process oldest-first so partial progress doesn't skip messages
|
|
104
|
-
const messages = (messagesResponse.data.messages || []).slice().reverse();
|
|
105
|
-
const pollingResponse = [];
|
|
106
|
-
for (const message of messages) {
|
|
107
|
-
try {
|
|
108
|
-
const rawMailResponse = yield gmail.users.messages.get({
|
|
109
|
-
userId: 'me',
|
|
110
|
-
id: message.id,
|
|
111
|
-
format: 'raw',
|
|
112
|
-
});
|
|
113
|
-
const parsedMailResponse = yield (0, data_1.parseStream)(Buffer.from(rawMailResponse.data.raw, 'base64').toString('utf-8'));
|
|
114
|
-
const { attachments } = parsedMailResponse, restOfParsedMailResponse = tslib_1.__rest(parsedMailResponse, ["attachments"]);
|
|
115
|
-
const parsedAttachments = yield (0, data_1.convertAttachment)(attachments, files);
|
|
116
|
-
for (const attachment of parsedAttachments) {
|
|
117
|
-
pollingResponse.push({
|
|
118
|
-
epochMilliSeconds: Number(rawMailResponse.data.internalDate),
|
|
119
|
-
data: {
|
|
120
|
-
attachment,
|
|
121
|
-
message: Object.assign({ id: message.id }, restOfParsedMailResponse),
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
const isRateLimit = error.status === 429 ||
|
|
128
|
-
(error.status === 403 &&
|
|
129
|
-
/quota|rate.?limit/i.test((_b = error.message) !== null && _b !== void 0 ? _b : ''));
|
|
130
|
-
if (isRateLimit) {
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
throw error;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return pollingResponse;
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
//# sourceMappingURL=new-attachment.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-attachment.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-attachment.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AAI,CAAC;wBACnB,iBAAiB,EAAE,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC;wBAC5D,IAAI,EAAE;4BACJ,UAAU;4BACV,OAAO,kBACL,EAAE,EAAE,OAAO,CAAC,EAAE,IACX,wBAAwB,CAC5B;yBACF;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,MAAM,WAAW,GACf,KAAK,CAAC,MAAM,KAAK,GAAG;oBACpB,CAAC,KAAK,CAAC,MAAM,KAAK,GAAG;wBACnB,oBAAoB,CAAC,IAAI,CAAC,MAAA,KAAK,CAAC,OAAO,mCAAI,EAAE,CAAC,CAAC,CAAC;gBACpD,IAAI,WAAW,EAAE,CAAC;oBAChB,MAAM;gBACR,CAAC;gBACD,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,eAAe,CAAC;IACzB,CAAC;CAAA"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { TriggerStrategy } from '@activepieces/pieces-framework';
|
|
2
|
-
export declare const gmailNewConversationTrigger: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
3
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
4
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
5
|
-
}>)[], {
|
|
6
|
-
from: {
|
|
7
|
-
description: string;
|
|
8
|
-
displayName: string;
|
|
9
|
-
required: false;
|
|
10
|
-
valueSchema: string;
|
|
11
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
12
|
-
defaultValue?: string | undefined;
|
|
13
|
-
};
|
|
14
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
15
|
-
maxAgeHours: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
16
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
17
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
18
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
19
|
-
}>)[], {
|
|
20
|
-
from: {
|
|
21
|
-
description: string;
|
|
22
|
-
displayName: string;
|
|
23
|
-
required: false;
|
|
24
|
-
valueSchema: string;
|
|
25
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
26
|
-
defaultValue?: string | undefined;
|
|
27
|
-
};
|
|
28
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
29
|
-
maxAgeHours: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
30
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
31
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
32
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
33
|
-
}>)[], {
|
|
34
|
-
from: {
|
|
35
|
-
description: string;
|
|
36
|
-
displayName: string;
|
|
37
|
-
required: false;
|
|
38
|
-
valueSchema: string;
|
|
39
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
40
|
-
defaultValue?: string | undefined;
|
|
41
|
-
};
|
|
42
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
43
|
-
maxAgeHours: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
44
|
-
}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, (import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props> | import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
45
|
-
serviceAccount: import("@activepieces/pieces-framework").LongTextProperty<true>;
|
|
46
|
-
userEmail: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
47
|
-
}>)[], {
|
|
48
|
-
from: {
|
|
49
|
-
description: string;
|
|
50
|
-
displayName: string;
|
|
51
|
-
required: false;
|
|
52
|
-
valueSchema: string;
|
|
53
|
-
type: import("@activepieces/pieces-framework").PropertyType.SHORT_TEXT;
|
|
54
|
-
defaultValue?: string | undefined;
|
|
55
|
-
};
|
|
56
|
-
subject: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
57
|
-
maxAgeHours: import("@activepieces/pieces-framework").NumberProperty<false>;
|
|
58
|
-
}>;
|
|
59
|
-
//# sourceMappingURL=new-conversation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"new-conversation.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-conversation.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EAGhB,MAAM,gCAAgC,CAAC;AAiIxC,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsRtC,CAAC"}
|