@particle-academy/gmail-inbox-ui 0.0.0 → 0.2.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/CHANGELOG.md +75 -0
- package/LICENSE +21 -0
- package/README.md +189 -2
- package/art/fancified.svg +26 -0
- package/dist/index.cjs +700 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +248 -0
- package/dist/index.d.ts +248 -0
- package/dist/index.js +653 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -6
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,700 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var connectors = require('@particle-academy/fancy-flow/connectors');
|
|
4
|
+
|
|
5
|
+
// src/service.ts
|
|
6
|
+
var CONNECTOR_API_VERSION = 1;
|
|
7
|
+
var GMAIL_INBOX_SERVICE = {
|
|
8
|
+
service: "gmail_inbox",
|
|
9
|
+
serviceTitle: "Gmail Inbox",
|
|
10
|
+
domain: "email",
|
|
11
|
+
sandbox: "none"
|
|
12
|
+
};
|
|
13
|
+
var GMAIL_INBOX_CREDENTIALS = [
|
|
14
|
+
{
|
|
15
|
+
"key": "clientId",
|
|
16
|
+
"label": "OAuth client ID",
|
|
17
|
+
"scope": "provider",
|
|
18
|
+
"secret": false,
|
|
19
|
+
"help": "A DIFFERENT OAuth app than `gmail`'s, from Google Cloud Console -> APIs & Services -> Credentials. This one requests a restricted scope and carries Google's annual CASA assessment; `gmail`'s does not. Do not reuse the same client for both."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"key": "clientSecret",
|
|
23
|
+
"label": "OAuth client secret",
|
|
24
|
+
"scope": "provider",
|
|
25
|
+
"secret": true,
|
|
26
|
+
"help": "The client secret for the same OAuth app. One value for the whole installation."
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"key": "accessToken",
|
|
30
|
+
"label": "Access token",
|
|
31
|
+
"scope": "account",
|
|
32
|
+
"secret": true,
|
|
33
|
+
"help": "Per connected Google account, and it expires after ONE HOUR. The host refreshes it with the refresh token."
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"key": "refreshToken",
|
|
37
|
+
"label": "Refresh token",
|
|
38
|
+
"scope": "account",
|
|
39
|
+
"secret": true,
|
|
40
|
+
"help": "Per connected Google account. Google issues one only when the consent request asks for offline access; without it the connection dies within the hour."
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"key": "pushAudience",
|
|
44
|
+
"label": "Push audience",
|
|
45
|
+
"scope": "provider",
|
|
46
|
+
"secret": false,
|
|
47
|
+
"optional": true,
|
|
48
|
+
"help": "The audience set on the Pub/Sub PUSH subscription (normally the endpoint URL your host mounts for message_received). Every push's Google-signed token must name it; an unchecked audience accepts any token Google signs for anyone. Needed only for the message_received trigger."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"key": "pushServiceAccount",
|
|
52
|
+
"label": "Push service account",
|
|
53
|
+
"scope": "provider",
|
|
54
|
+
"secret": false,
|
|
55
|
+
"optional": true,
|
|
56
|
+
"help": "The service account the push subscription authenticates as (its email). Every push's token must be for exactly this account: a stranger's subscription aimed at your URL carries a token Google signed correctly, and only this check refuses it. Needed only for message_received."
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
var GMAIL_INBOX_OAUTH = {
|
|
60
|
+
"flow": "authorization_code",
|
|
61
|
+
"authorizeUrl": "https://accounts.google.com/o/oauth2/v2/auth",
|
|
62
|
+
"tokenUrl": "https://oauth2.googleapis.com/token",
|
|
63
|
+
"scopes": [
|
|
64
|
+
"https://www.googleapis.com/auth/gmail.readonly"
|
|
65
|
+
],
|
|
66
|
+
"accessTokenCredential": "accessToken",
|
|
67
|
+
"refreshTokenCredential": "refreshToken",
|
|
68
|
+
"refreshTokenRotates": false,
|
|
69
|
+
"accessTokenTtlSeconds": 3600
|
|
70
|
+
};
|
|
71
|
+
function gmailInboxMeta(role, operation, docs) {
|
|
72
|
+
return { ...GMAIL_INBOX_SERVICE, role, operation, docs };
|
|
73
|
+
}
|
|
74
|
+
var GMAIL_INBOX_HISTORY_LIST_KIND = "@particle-academy/gmail_inbox_history_list";
|
|
75
|
+
var GMAIL_INBOX_HISTORY_LIST_OPERATION = "history_list";
|
|
76
|
+
var GMAIL_INBOX_HISTORY_LIST_META = gmailInboxMeta("action", "list mailbox history", "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.history/list");
|
|
77
|
+
var GMAIL_INBOX_HISTORY_LIST_OUTPUT = [
|
|
78
|
+
{
|
|
79
|
+
"path": "data.history",
|
|
80
|
+
"type": "array",
|
|
81
|
+
"description": "History records, oldest first. Each has an id and messagesAdded / messagesDeleted / labelsAdded / labelsRemoved; a message there carries only id and threadId: read its content with message_get."
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"path": "data.historyId",
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "The mailbox's CURRENT history id. Store it as the next start ONLY when there is no nextPageToken."
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"path": "data.nextPageToken",
|
|
90
|
+
"type": "string",
|
|
91
|
+
"description": "Present when there is another page."
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"path": "mode",
|
|
95
|
+
"type": "string",
|
|
96
|
+
"description": "Which estate this ran against. Google has no sandbox, so: fake or live."
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
var gmailInboxHistoryListKind = connectors.defineConnectorKind(GMAIL_INBOX_HISTORY_LIST_META, {
|
|
100
|
+
name: GMAIL_INBOX_HISTORY_LIST_KIND,
|
|
101
|
+
aliases: ["gmail_inbox_history_list"],
|
|
102
|
+
label: "List Gmail mailbox history",
|
|
103
|
+
description: "List what changed in a mailbox since a history id: messages added or deleted, labels added or removed.",
|
|
104
|
+
inputs: [{ id: "in" }],
|
|
105
|
+
outputs: [{ id: "out" }],
|
|
106
|
+
sideEffects: "none",
|
|
107
|
+
outputShape: GMAIL_INBOX_HISTORY_LIST_OUTPUT,
|
|
108
|
+
configSchema: [
|
|
109
|
+
{
|
|
110
|
+
"type": "text",
|
|
111
|
+
"key": "userId",
|
|
112
|
+
"label": "Mailbox",
|
|
113
|
+
"required": true,
|
|
114
|
+
"default": "me",
|
|
115
|
+
"description": "`me` is the connected account and is almost always what you want."
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"type": "text",
|
|
119
|
+
"key": "startHistoryId",
|
|
120
|
+
"label": "Start history id",
|
|
121
|
+
"required": true,
|
|
122
|
+
"description": "Changes AFTER this id. Take it from a watch, a message, or a previous list's historyId. Out of Gmail's range (typically older than a week) it answers 404."
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "select",
|
|
126
|
+
"key": "historyTypes",
|
|
127
|
+
"label": "Only this kind of change",
|
|
128
|
+
"description": "Blank: every kind. messageAdded is new mail (and sent mail and drafts, unless a label narrows it).",
|
|
129
|
+
"options": [
|
|
130
|
+
{
|
|
131
|
+
"value": "messageAdded",
|
|
132
|
+
"label": "Messages added"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"value": "messageDeleted",
|
|
136
|
+
"label": "Messages deleted"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"value": "labelAdded",
|
|
140
|
+
"label": "Labels added"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"value": "labelRemoved",
|
|
144
|
+
"label": "Labels removed"
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"type": "text",
|
|
150
|
+
"key": "labelId",
|
|
151
|
+
"label": "Only this label",
|
|
152
|
+
"description": "Only messages with this label, e.g. INBOX for received mail."
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"type": "number",
|
|
156
|
+
"key": "maxResults",
|
|
157
|
+
"label": "Page size",
|
|
158
|
+
"min": 1,
|
|
159
|
+
"max": 500,
|
|
160
|
+
"default": 100,
|
|
161
|
+
"description": "Gmail's own maximum is 500."
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"type": "text",
|
|
165
|
+
"key": "pageToken",
|
|
166
|
+
"label": "Page token",
|
|
167
|
+
"description": "From a previous page's nextPageToken."
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
defaultConfig: {
|
|
171
|
+
"mode": "auto"
|
|
172
|
+
},
|
|
173
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_HISTORY_LIST_META, config, "list mailbox history")
|
|
174
|
+
});
|
|
175
|
+
var GMAIL_INBOX_LABEL_LIST_KIND = "@particle-academy/gmail_inbox_label_list";
|
|
176
|
+
var GMAIL_INBOX_LABEL_LIST_OPERATION = "label_list";
|
|
177
|
+
var GMAIL_INBOX_LABEL_LIST_META = gmailInboxMeta("action", "list labels", "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.labels/list");
|
|
178
|
+
var GMAIL_INBOX_LABEL_LIST_OUTPUT = [
|
|
179
|
+
{
|
|
180
|
+
"path": "data.labels",
|
|
181
|
+
"type": "array",
|
|
182
|
+
"description": "Each with id, name and type (system or user). messagesTotal/messagesUnread/threadsTotal/threadsUnread are part of Label's schema but not confirmed present on every list row -- read one label with labels.get if a count comes back missing."
|
|
183
|
+
}
|
|
184
|
+
];
|
|
185
|
+
var gmailInboxLabelListKind = connectors.defineConnectorKind(GMAIL_INBOX_LABEL_LIST_META, {
|
|
186
|
+
name: GMAIL_INBOX_LABEL_LIST_KIND,
|
|
187
|
+
aliases: ["gmail_inbox_label_list"],
|
|
188
|
+
label: "List Gmail labels",
|
|
189
|
+
description: "List every label on the mailbox, system and user-created.",
|
|
190
|
+
inputs: [{ id: "in" }],
|
|
191
|
+
outputs: [{ id: "out" }],
|
|
192
|
+
sideEffects: "none",
|
|
193
|
+
outputShape: GMAIL_INBOX_LABEL_LIST_OUTPUT,
|
|
194
|
+
configSchema: [
|
|
195
|
+
{
|
|
196
|
+
"type": "text",
|
|
197
|
+
"key": "userId",
|
|
198
|
+
"label": "Mailbox",
|
|
199
|
+
"required": true,
|
|
200
|
+
"default": "me"
|
|
201
|
+
}
|
|
202
|
+
],
|
|
203
|
+
defaultConfig: {
|
|
204
|
+
"mode": "auto"
|
|
205
|
+
},
|
|
206
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_LABEL_LIST_META, config, "list labels")
|
|
207
|
+
});
|
|
208
|
+
var GMAIL_INBOX_MAILBOX_STOP_KIND = "@particle-academy/gmail_inbox_mailbox_stop";
|
|
209
|
+
var GMAIL_INBOX_MAILBOX_STOP_OPERATION = "mailbox_stop";
|
|
210
|
+
var GMAIL_INBOX_MAILBOX_STOP_META = gmailInboxMeta("action", "stop watching", "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users/stop");
|
|
211
|
+
var GMAIL_INBOX_MAILBOX_STOP_OUTPUT = [
|
|
212
|
+
{
|
|
213
|
+
"path": "mode",
|
|
214
|
+
"type": "string",
|
|
215
|
+
"description": "Which estate this ran against. Google has no sandbox, so: fake or live."
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
var gmailInboxMailboxStopKind = connectors.defineConnectorKind(GMAIL_INBOX_MAILBOX_STOP_META, {
|
|
219
|
+
name: GMAIL_INBOX_MAILBOX_STOP_KIND,
|
|
220
|
+
aliases: ["gmail_inbox_mailbox_stop"],
|
|
221
|
+
label: "Stop watching a Gmail mailbox",
|
|
222
|
+
description: "Turn off push notifications for a mailbox.",
|
|
223
|
+
inputs: [{ id: "in" }],
|
|
224
|
+
outputs: [{ id: "out" }],
|
|
225
|
+
sideEffects: "idempotent",
|
|
226
|
+
outputShape: GMAIL_INBOX_MAILBOX_STOP_OUTPUT,
|
|
227
|
+
configSchema: [
|
|
228
|
+
{
|
|
229
|
+
"type": "text",
|
|
230
|
+
"key": "userId",
|
|
231
|
+
"label": "Mailbox",
|
|
232
|
+
"required": true,
|
|
233
|
+
"default": "me",
|
|
234
|
+
"description": "`me` is the connected account and is almost always what you want."
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
defaultConfig: {
|
|
238
|
+
"mode": "auto"
|
|
239
|
+
},
|
|
240
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_MAILBOX_STOP_META, config, "stop watching")
|
|
241
|
+
});
|
|
242
|
+
var GMAIL_INBOX_MAILBOX_WATCH_KIND = "@particle-academy/gmail_inbox_mailbox_watch";
|
|
243
|
+
var GMAIL_INBOX_MAILBOX_WATCH_OPERATION = "mailbox_watch";
|
|
244
|
+
var GMAIL_INBOX_MAILBOX_WATCH_META = gmailInboxMeta("action", "watch a mailbox", "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users/watch");
|
|
245
|
+
var GMAIL_INBOX_MAILBOX_WATCH_OUTPUT = [
|
|
246
|
+
{
|
|
247
|
+
"path": "data.historyId",
|
|
248
|
+
"type": "string",
|
|
249
|
+
"description": "The mailbox's CURRENT history id: seed the trigger's stored cursor from it."
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"path": "data.expiration",
|
|
253
|
+
"type": "string",
|
|
254
|
+
"description": "When Gmail stops pushing, in epoch MILLISECONDS. Renew before it; Google recommends daily."
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"path": "mode",
|
|
258
|
+
"type": "string",
|
|
259
|
+
"description": "Which estate this ran against. Google has no sandbox, so: fake or live."
|
|
260
|
+
}
|
|
261
|
+
];
|
|
262
|
+
var gmailInboxMailboxWatchKind = connectors.defineConnectorKind(GMAIL_INBOX_MAILBOX_WATCH_META, {
|
|
263
|
+
name: GMAIL_INBOX_MAILBOX_WATCH_KIND,
|
|
264
|
+
aliases: ["gmail_inbox_mailbox_watch"],
|
|
265
|
+
label: "Watch a Gmail mailbox",
|
|
266
|
+
description: "Start (or renew) push notifications for a mailbox to a Cloud Pub/Sub topic.",
|
|
267
|
+
inputs: [{ id: "in" }],
|
|
268
|
+
outputs: [{ id: "out" }],
|
|
269
|
+
sideEffects: "idempotent",
|
|
270
|
+
outputShape: GMAIL_INBOX_MAILBOX_WATCH_OUTPUT,
|
|
271
|
+
configSchema: [
|
|
272
|
+
{
|
|
273
|
+
"type": "text",
|
|
274
|
+
"key": "userId",
|
|
275
|
+
"label": "Mailbox",
|
|
276
|
+
"required": true,
|
|
277
|
+
"default": "me",
|
|
278
|
+
"description": "`me` is the connected account and is almost always what you want."
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"type": "text",
|
|
282
|
+
"key": "topicName",
|
|
283
|
+
"label": "Pub/Sub topic",
|
|
284
|
+
"required": true,
|
|
285
|
+
"placeholder": "projects/my-project/topics/gmail-push",
|
|
286
|
+
"description": "The full topic name, in YOUR app's own Google Cloud project: Google requires its project id to match the project whose OAuth client makes this call. One topic serves every mailbox."
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"type": "text",
|
|
290
|
+
"key": "labelIds",
|
|
291
|
+
"label": "Only these labels",
|
|
292
|
+
"description": "Comma-separated label ids to restrict notifications to (e.g. INBOX). Blank: every change is pushed."
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
"type": "select",
|
|
296
|
+
"key": "labelFilterBehavior",
|
|
297
|
+
"label": "Label filter",
|
|
298
|
+
"description": "Whether the labels above are the ONLY ones notified (include) or the ones NOT notified (exclude).",
|
|
299
|
+
"options": [
|
|
300
|
+
{
|
|
301
|
+
"value": "include",
|
|
302
|
+
"label": "Only these labels"
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
"value": "exclude",
|
|
306
|
+
"label": "Every label except these"
|
|
307
|
+
}
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
],
|
|
311
|
+
defaultConfig: {
|
|
312
|
+
"mode": "auto"
|
|
313
|
+
},
|
|
314
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_MAILBOX_WATCH_META, config, "watch a mailbox")
|
|
315
|
+
});
|
|
316
|
+
var GMAIL_INBOX_MESSAGE_GET_KIND = "@particle-academy/gmail_inbox_message_get";
|
|
317
|
+
var GMAIL_INBOX_MESSAGE_GET_OPERATION = "message_get";
|
|
318
|
+
var GMAIL_INBOX_MESSAGE_GET_META = gmailInboxMeta("action", "read a message", "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages/get");
|
|
319
|
+
var GMAIL_INBOX_MESSAGE_GET_OUTPUT = [
|
|
320
|
+
{
|
|
321
|
+
"path": "data.id",
|
|
322
|
+
"type": "string",
|
|
323
|
+
"description": "The message id."
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"path": "data.threadId",
|
|
327
|
+
"type": "string",
|
|
328
|
+
"description": "The thread this message belongs to."
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"path": "data.labelIds",
|
|
332
|
+
"type": "array",
|
|
333
|
+
"description": "System and user label ids currently on this message."
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
"path": "data.snippet",
|
|
337
|
+
"type": "string",
|
|
338
|
+
"description": "Gmail's own short plain-text preview of the body -- a few hundred characters, not the whole message."
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
"path": "data.internalDate",
|
|
342
|
+
"type": "string",
|
|
343
|
+
"description": "Unix epoch MILLISECONDS, as a string -- when Gmail received it, which can differ from the Date header."
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
"path": "data.payload.headers",
|
|
347
|
+
"type": "array",
|
|
348
|
+
"description": "Every RFC 2822 header as { name, value }, unparsed. From/To/Subject/Date live here."
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
"path": "data.payload",
|
|
352
|
+
"type": "unknown",
|
|
353
|
+
"description": "The full MIME tree, raw -- mimeType, body (base64url in body.data for a leaf part), and nested parts for a multipart message. Decode it yourself for plain-text or HTML content; this connector does not flatten it."
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"path": "mode",
|
|
357
|
+
"type": "string",
|
|
358
|
+
"description": "Which estate this ran against. Google has no sandbox, so: fake or live."
|
|
359
|
+
}
|
|
360
|
+
];
|
|
361
|
+
var gmailInboxMessageGetKind = connectors.defineConnectorKind(GMAIL_INBOX_MESSAGE_GET_META, {
|
|
362
|
+
name: GMAIL_INBOX_MESSAGE_GET_KIND,
|
|
363
|
+
aliases: ["gmail_inbox_message_get"],
|
|
364
|
+
label: "Gmail message",
|
|
365
|
+
description: "Read one message's headers and preview. The body's plain/HTML text is NOT decoded -- see the raw payload for that.",
|
|
366
|
+
inputs: [{ id: "in" }],
|
|
367
|
+
outputs: [{ id: "out" }],
|
|
368
|
+
sideEffects: "none",
|
|
369
|
+
outputShape: GMAIL_INBOX_MESSAGE_GET_OUTPUT,
|
|
370
|
+
configSchema: [
|
|
371
|
+
{
|
|
372
|
+
"type": "text",
|
|
373
|
+
"key": "userId",
|
|
374
|
+
"label": "Mailbox",
|
|
375
|
+
"required": true,
|
|
376
|
+
"default": "me"
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
"type": "text",
|
|
380
|
+
"key": "id",
|
|
381
|
+
"label": "Message ID",
|
|
382
|
+
"required": true,
|
|
383
|
+
"description": "From message_list, or another node's output."
|
|
384
|
+
}
|
|
385
|
+
],
|
|
386
|
+
defaultConfig: {
|
|
387
|
+
"mode": "auto"
|
|
388
|
+
},
|
|
389
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_MESSAGE_GET_META, config, "read a message")
|
|
390
|
+
});
|
|
391
|
+
var GMAIL_INBOX_MESSAGE_LIST_KIND = "@particle-academy/gmail_inbox_message_list";
|
|
392
|
+
var GMAIL_INBOX_MESSAGE_LIST_OPERATION = "message_list";
|
|
393
|
+
var GMAIL_INBOX_MESSAGE_LIST_META = gmailInboxMeta("action", "list messages", "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages/list");
|
|
394
|
+
var GMAIL_INBOX_MESSAGE_LIST_OUTPUT = [
|
|
395
|
+
{
|
|
396
|
+
"path": "data.messages",
|
|
397
|
+
"type": "array",
|
|
398
|
+
"description": "Each row is { id, threadId } only. Read a message's content with message_get."
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"path": "data.nextPageToken",
|
|
402
|
+
"type": "string",
|
|
403
|
+
"description": "Present when there is another page."
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"path": "data.resultSizeEstimate",
|
|
407
|
+
"type": "number",
|
|
408
|
+
"description": "Gmail's own word for it: an ESTIMATE, not an exact count."
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
"path": "mode",
|
|
412
|
+
"type": "string",
|
|
413
|
+
"description": "Which estate this ran against. Google has no sandbox, so: fake or live."
|
|
414
|
+
}
|
|
415
|
+
];
|
|
416
|
+
var gmailInboxMessageListKind = connectors.defineConnectorKind(GMAIL_INBOX_MESSAGE_LIST_META, {
|
|
417
|
+
name: GMAIL_INBOX_MESSAGE_LIST_KIND,
|
|
418
|
+
aliases: ["gmail_inbox_message_list"],
|
|
419
|
+
label: "List Gmail messages",
|
|
420
|
+
description: "List message ids matching a search, newest first.",
|
|
421
|
+
inputs: [{ id: "in" }],
|
|
422
|
+
outputs: [{ id: "out" }],
|
|
423
|
+
sideEffects: "none",
|
|
424
|
+
outputShape: GMAIL_INBOX_MESSAGE_LIST_OUTPUT,
|
|
425
|
+
configSchema: [
|
|
426
|
+
{
|
|
427
|
+
"type": "text",
|
|
428
|
+
"key": "userId",
|
|
429
|
+
"label": "Mailbox",
|
|
430
|
+
"required": true,
|
|
431
|
+
"default": "me",
|
|
432
|
+
"description": "`me` is the connected account and is almost always what you want."
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"type": "text",
|
|
436
|
+
"key": "q",
|
|
437
|
+
"label": "Search",
|
|
438
|
+
"description": `Gmail's own search syntax, exactly as typed into the Gmail search box -- e.g. "from:ada@example.test has:attachment newer_than:7d". Leave blank to list everything.`
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"type": "text",
|
|
442
|
+
"key": "labelId",
|
|
443
|
+
"label": "Label ID",
|
|
444
|
+
"description": "Only messages with this label -- e.g. INBOX, or a label_list id. Gmail's own query parameter accepts several, repeated; this connector offers one for now -- combine more in the search field above instead, using Gmail's own label: search operator."
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
"type": "switch",
|
|
448
|
+
"key": "includeSpamTrash",
|
|
449
|
+
"label": "Include spam and trash",
|
|
450
|
+
"default": false
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
"type": "number",
|
|
454
|
+
"key": "maxResults",
|
|
455
|
+
"label": "Page size",
|
|
456
|
+
"min": 1,
|
|
457
|
+
"max": 500,
|
|
458
|
+
"default": 100,
|
|
459
|
+
"description": "Gmail's own maximum is 500."
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
"type": "text",
|
|
463
|
+
"key": "pageToken",
|
|
464
|
+
"label": "Page token",
|
|
465
|
+
"description": "From a previous page's nextPageToken."
|
|
466
|
+
}
|
|
467
|
+
],
|
|
468
|
+
defaultConfig: {
|
|
469
|
+
"mode": "auto"
|
|
470
|
+
},
|
|
471
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_MESSAGE_LIST_META, config, "list messages")
|
|
472
|
+
});
|
|
473
|
+
var GMAIL_INBOX_THREAD_GET_KIND = "@particle-academy/gmail_inbox_thread_get";
|
|
474
|
+
var GMAIL_INBOX_THREAD_GET_OPERATION = "thread_get";
|
|
475
|
+
var GMAIL_INBOX_THREAD_GET_META = gmailInboxMeta("action", "read a thread", "https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.threads/get");
|
|
476
|
+
var GMAIL_INBOX_THREAD_GET_OUTPUT = [
|
|
477
|
+
{
|
|
478
|
+
"path": "data.id",
|
|
479
|
+
"type": "string",
|
|
480
|
+
"description": "The thread id."
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"path": "data.historyId",
|
|
484
|
+
"type": "string",
|
|
485
|
+
"description": "Gmail's change-tracking cursor as of this read."
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"path": "data.messages",
|
|
489
|
+
"type": "array",
|
|
490
|
+
"description": "Every message in the thread, oldest first, each shaped like message_get's output."
|
|
491
|
+
},
|
|
492
|
+
{
|
|
493
|
+
"path": "mode",
|
|
494
|
+
"type": "string",
|
|
495
|
+
"description": "Which estate this ran against. Google has no sandbox, so: fake or live."
|
|
496
|
+
}
|
|
497
|
+
];
|
|
498
|
+
var gmailInboxThreadGetKind = connectors.defineConnectorKind(GMAIL_INBOX_THREAD_GET_META, {
|
|
499
|
+
name: GMAIL_INBOX_THREAD_GET_KIND,
|
|
500
|
+
aliases: ["gmail_inbox_thread_get"],
|
|
501
|
+
label: "Gmail thread",
|
|
502
|
+
description: "Read every message in a conversation thread, oldest first.",
|
|
503
|
+
inputs: [{ id: "in" }],
|
|
504
|
+
outputs: [{ id: "out" }],
|
|
505
|
+
sideEffects: "none",
|
|
506
|
+
outputShape: GMAIL_INBOX_THREAD_GET_OUTPUT,
|
|
507
|
+
configSchema: [
|
|
508
|
+
{
|
|
509
|
+
"type": "text",
|
|
510
|
+
"key": "userId",
|
|
511
|
+
"label": "Mailbox",
|
|
512
|
+
"required": true,
|
|
513
|
+
"default": "me"
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
"type": "text",
|
|
517
|
+
"key": "id",
|
|
518
|
+
"label": "Thread ID",
|
|
519
|
+
"required": true,
|
|
520
|
+
"description": "A message's threadId, from message_list or message_get."
|
|
521
|
+
}
|
|
522
|
+
],
|
|
523
|
+
defaultConfig: {
|
|
524
|
+
"mode": "auto"
|
|
525
|
+
},
|
|
526
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_THREAD_GET_META, config, "read a thread")
|
|
527
|
+
});
|
|
528
|
+
var GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_KIND = "@particle-academy/gmail_inbox_message_received_trigger";
|
|
529
|
+
var GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_OPERATION = "message_received";
|
|
530
|
+
var GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_META = gmailInboxMeta("trigger", "new mail", "https://developers.google.com/workspace/gmail/api/guides/push");
|
|
531
|
+
var GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_OUTPUT = [
|
|
532
|
+
{
|
|
533
|
+
"path": "messageId",
|
|
534
|
+
"type": "string",
|
|
535
|
+
"description": "Pub/Sub's id for this push. The same push may be delivered more than once."
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
"path": "publishTime",
|
|
539
|
+
"type": "string",
|
|
540
|
+
"description": "When Pub/Sub published it."
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
"path": "data.emailAddress",
|
|
544
|
+
"type": "string",
|
|
545
|
+
"description": "The mailbox. The ONLY routing key, and only after verification."
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
"path": "data.historyId",
|
|
549
|
+
"type": "number",
|
|
550
|
+
"description": "The mailbox's new position, as Gmail pushed it. The read below starts from the STORED cursor, not this."
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
"path": "history.history",
|
|
554
|
+
"type": "array",
|
|
555
|
+
"description": "Every change since the stored cursor, all pages, oldest first. New mail is history[].messagesAdded[].message {id, threadId}: read each with message_get."
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
"path": "history.historyId",
|
|
559
|
+
"type": "string",
|
|
560
|
+
"description": "The mailbox's position after the read."
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"path": "history.nextPageToken",
|
|
564
|
+
"type": "string",
|
|
565
|
+
"description": "Always absent here: every page was read."
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"path": "cursor.used",
|
|
569
|
+
"type": "string",
|
|
570
|
+
"description": "The stored cursor this read started from."
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
"path": "cursor.next",
|
|
574
|
+
"type": "string",
|
|
575
|
+
"description": "The cursor to store once this run succeeds (null: keep the one used)."
|
|
576
|
+
}
|
|
577
|
+
];
|
|
578
|
+
var gmailInboxMessageReceivedTriggerKind = connectors.defineConnectorKind(GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_META, {
|
|
579
|
+
name: GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_KIND,
|
|
580
|
+
aliases: ["gmail_inbox_message_received_trigger"],
|
|
581
|
+
label: "Gmail message received",
|
|
582
|
+
description: "Start when new mail arrives in a watched mailbox, with every new message since the last run.",
|
|
583
|
+
inputs: [],
|
|
584
|
+
outputs: [{ id: "out" }],
|
|
585
|
+
sideEffects: "none",
|
|
586
|
+
outputShape: GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_OUTPUT,
|
|
587
|
+
configSchema: [
|
|
588
|
+
{
|
|
589
|
+
"type": "text",
|
|
590
|
+
"key": "startHistoryId",
|
|
591
|
+
"label": "Stored cursor",
|
|
592
|
+
"description": "The host fills this on every run from the cursor it stored: seeded from mailbox_watch's historyId, then cursor.next after each successful run."
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
"type": "number",
|
|
596
|
+
"key": "resyncWindowDays",
|
|
597
|
+
"label": "Resync window (days)",
|
|
598
|
+
"min": 1,
|
|
599
|
+
"max": 30,
|
|
600
|
+
"description": "How far back the host re-lists after a lapse, never the whole mailbox."
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
"type": "text",
|
|
604
|
+
"key": "labelId",
|
|
605
|
+
"label": "Only this label",
|
|
606
|
+
"description": "INBOX: received mail only. Blank: every label, including sent mail and drafts."
|
|
607
|
+
},
|
|
608
|
+
{
|
|
609
|
+
"type": "select",
|
|
610
|
+
"key": "historyTypes",
|
|
611
|
+
"label": "Only this kind of change",
|
|
612
|
+
"options": [
|
|
613
|
+
{
|
|
614
|
+
"value": "messageAdded",
|
|
615
|
+
"label": "New messages"
|
|
616
|
+
},
|
|
617
|
+
{
|
|
618
|
+
"value": "messageDeleted",
|
|
619
|
+
"label": "Deleted messages"
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
"value": "labelAdded",
|
|
623
|
+
"label": "Labels added"
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
"value": "labelRemoved",
|
|
627
|
+
"label": "Labels removed"
|
|
628
|
+
}
|
|
629
|
+
]
|
|
630
|
+
}
|
|
631
|
+
],
|
|
632
|
+
defaultConfig: {
|
|
633
|
+
"mode": "auto",
|
|
634
|
+
"resyncWindowDays": 7,
|
|
635
|
+
"labelId": "INBOX",
|
|
636
|
+
"historyTypes": "messageAdded"
|
|
637
|
+
},
|
|
638
|
+
renderBody: ({ config }) => connectors.summarize(GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_META, config, "new mail")
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
// src/index.ts
|
|
642
|
+
var GMAIL_INBOX_KINDS = [
|
|
643
|
+
gmailInboxHistoryListKind,
|
|
644
|
+
gmailInboxLabelListKind,
|
|
645
|
+
gmailInboxMailboxStopKind,
|
|
646
|
+
gmailInboxMailboxWatchKind,
|
|
647
|
+
gmailInboxMessageGetKind,
|
|
648
|
+
gmailInboxMessageListKind,
|
|
649
|
+
gmailInboxThreadGetKind,
|
|
650
|
+
gmailInboxMessageReceivedTriggerKind
|
|
651
|
+
];
|
|
652
|
+
|
|
653
|
+
exports.CONNECTOR_API_VERSION = CONNECTOR_API_VERSION;
|
|
654
|
+
exports.GMAIL_INBOX_CREDENTIALS = GMAIL_INBOX_CREDENTIALS;
|
|
655
|
+
exports.GMAIL_INBOX_HISTORY_LIST_KIND = GMAIL_INBOX_HISTORY_LIST_KIND;
|
|
656
|
+
exports.GMAIL_INBOX_HISTORY_LIST_META = GMAIL_INBOX_HISTORY_LIST_META;
|
|
657
|
+
exports.GMAIL_INBOX_HISTORY_LIST_OPERATION = GMAIL_INBOX_HISTORY_LIST_OPERATION;
|
|
658
|
+
exports.GMAIL_INBOX_HISTORY_LIST_OUTPUT = GMAIL_INBOX_HISTORY_LIST_OUTPUT;
|
|
659
|
+
exports.GMAIL_INBOX_KINDS = GMAIL_INBOX_KINDS;
|
|
660
|
+
exports.GMAIL_INBOX_LABEL_LIST_KIND = GMAIL_INBOX_LABEL_LIST_KIND;
|
|
661
|
+
exports.GMAIL_INBOX_LABEL_LIST_META = GMAIL_INBOX_LABEL_LIST_META;
|
|
662
|
+
exports.GMAIL_INBOX_LABEL_LIST_OPERATION = GMAIL_INBOX_LABEL_LIST_OPERATION;
|
|
663
|
+
exports.GMAIL_INBOX_LABEL_LIST_OUTPUT = GMAIL_INBOX_LABEL_LIST_OUTPUT;
|
|
664
|
+
exports.GMAIL_INBOX_MAILBOX_STOP_KIND = GMAIL_INBOX_MAILBOX_STOP_KIND;
|
|
665
|
+
exports.GMAIL_INBOX_MAILBOX_STOP_META = GMAIL_INBOX_MAILBOX_STOP_META;
|
|
666
|
+
exports.GMAIL_INBOX_MAILBOX_STOP_OPERATION = GMAIL_INBOX_MAILBOX_STOP_OPERATION;
|
|
667
|
+
exports.GMAIL_INBOX_MAILBOX_STOP_OUTPUT = GMAIL_INBOX_MAILBOX_STOP_OUTPUT;
|
|
668
|
+
exports.GMAIL_INBOX_MAILBOX_WATCH_KIND = GMAIL_INBOX_MAILBOX_WATCH_KIND;
|
|
669
|
+
exports.GMAIL_INBOX_MAILBOX_WATCH_META = GMAIL_INBOX_MAILBOX_WATCH_META;
|
|
670
|
+
exports.GMAIL_INBOX_MAILBOX_WATCH_OPERATION = GMAIL_INBOX_MAILBOX_WATCH_OPERATION;
|
|
671
|
+
exports.GMAIL_INBOX_MAILBOX_WATCH_OUTPUT = GMAIL_INBOX_MAILBOX_WATCH_OUTPUT;
|
|
672
|
+
exports.GMAIL_INBOX_MESSAGE_GET_KIND = GMAIL_INBOX_MESSAGE_GET_KIND;
|
|
673
|
+
exports.GMAIL_INBOX_MESSAGE_GET_META = GMAIL_INBOX_MESSAGE_GET_META;
|
|
674
|
+
exports.GMAIL_INBOX_MESSAGE_GET_OPERATION = GMAIL_INBOX_MESSAGE_GET_OPERATION;
|
|
675
|
+
exports.GMAIL_INBOX_MESSAGE_GET_OUTPUT = GMAIL_INBOX_MESSAGE_GET_OUTPUT;
|
|
676
|
+
exports.GMAIL_INBOX_MESSAGE_LIST_KIND = GMAIL_INBOX_MESSAGE_LIST_KIND;
|
|
677
|
+
exports.GMAIL_INBOX_MESSAGE_LIST_META = GMAIL_INBOX_MESSAGE_LIST_META;
|
|
678
|
+
exports.GMAIL_INBOX_MESSAGE_LIST_OPERATION = GMAIL_INBOX_MESSAGE_LIST_OPERATION;
|
|
679
|
+
exports.GMAIL_INBOX_MESSAGE_LIST_OUTPUT = GMAIL_INBOX_MESSAGE_LIST_OUTPUT;
|
|
680
|
+
exports.GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_KIND = GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_KIND;
|
|
681
|
+
exports.GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_META = GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_META;
|
|
682
|
+
exports.GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_OPERATION = GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_OPERATION;
|
|
683
|
+
exports.GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_OUTPUT = GMAIL_INBOX_MESSAGE_RECEIVED_TRIGGER_OUTPUT;
|
|
684
|
+
exports.GMAIL_INBOX_OAUTH = GMAIL_INBOX_OAUTH;
|
|
685
|
+
exports.GMAIL_INBOX_SERVICE = GMAIL_INBOX_SERVICE;
|
|
686
|
+
exports.GMAIL_INBOX_THREAD_GET_KIND = GMAIL_INBOX_THREAD_GET_KIND;
|
|
687
|
+
exports.GMAIL_INBOX_THREAD_GET_META = GMAIL_INBOX_THREAD_GET_META;
|
|
688
|
+
exports.GMAIL_INBOX_THREAD_GET_OPERATION = GMAIL_INBOX_THREAD_GET_OPERATION;
|
|
689
|
+
exports.GMAIL_INBOX_THREAD_GET_OUTPUT = GMAIL_INBOX_THREAD_GET_OUTPUT;
|
|
690
|
+
exports.gmailInboxHistoryListKind = gmailInboxHistoryListKind;
|
|
691
|
+
exports.gmailInboxLabelListKind = gmailInboxLabelListKind;
|
|
692
|
+
exports.gmailInboxMailboxStopKind = gmailInboxMailboxStopKind;
|
|
693
|
+
exports.gmailInboxMailboxWatchKind = gmailInboxMailboxWatchKind;
|
|
694
|
+
exports.gmailInboxMessageGetKind = gmailInboxMessageGetKind;
|
|
695
|
+
exports.gmailInboxMessageListKind = gmailInboxMessageListKind;
|
|
696
|
+
exports.gmailInboxMessageReceivedTriggerKind = gmailInboxMessageReceivedTriggerKind;
|
|
697
|
+
exports.gmailInboxMeta = gmailInboxMeta;
|
|
698
|
+
exports.gmailInboxThreadGetKind = gmailInboxThreadGetKind;
|
|
699
|
+
//# sourceMappingURL=index.cjs.map
|
|
700
|
+
//# sourceMappingURL=index.cjs.map
|