@superdurable/connector-google-gmail 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dex-connector.json +28 -4
- package/dist/{chunk-OKDZ42YK.js → chunk-ALVG4HS2.js} +500 -38
- package/dist/index.cjs +495 -31
- package/dist/index.d.cts +212 -5
- package/dist/index.d.ts +212 -5
- package/dist/index.js +39 -1
- package/dist/mock/index.cjs +75 -2
- package/dist/mock/index.js +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -12,8 +12,15 @@ import {
|
|
|
12
12
|
GmailMessageResourceSchema,
|
|
13
13
|
GmailProvider,
|
|
14
14
|
GoogleOAuthAuthMethodID,
|
|
15
|
+
MessageEventSchema,
|
|
16
|
+
MessageMatcherSchema,
|
|
17
|
+
MessageReceivedTriggerConfigurationSchema,
|
|
18
|
+
MessageReceivedTriggerDefinition,
|
|
15
19
|
MessageSchema,
|
|
20
|
+
MessageTriggerRunner,
|
|
16
21
|
ProviderID,
|
|
22
|
+
ReplyReceivedTriggerConfigurationSchema,
|
|
23
|
+
ReplyReceivedTriggerDefinition,
|
|
17
24
|
ReplyToMessageBranch,
|
|
18
25
|
ReplyToMessageDefinition,
|
|
19
26
|
ReplyToMessageInputSchema,
|
|
@@ -23,18 +30,30 @@ import {
|
|
|
23
30
|
SendMessageInputSchema2 as SendMessageInputSchema,
|
|
24
31
|
SendMessageOperation,
|
|
25
32
|
SendMessageOutputSchema2 as SendMessageOutputSchema,
|
|
33
|
+
UIEmailListInputPortEmails,
|
|
34
|
+
UISearchQueryInputPortQuery,
|
|
35
|
+
UITextInputPortText,
|
|
36
|
+
UIUnitEmailListInput,
|
|
37
|
+
UIUnitSearchQueryInput,
|
|
38
|
+
UIUnitTextInput,
|
|
26
39
|
WorkspaceDomainDelegationAuthMethodID,
|
|
27
40
|
buildMIMEMessage,
|
|
28
41
|
buildReplyMIMEMessage,
|
|
29
42
|
decodeGmailMessage,
|
|
43
|
+
defineMessageReceivedTriggerBinding,
|
|
44
|
+
defineReplyReceivedTriggerBinding,
|
|
30
45
|
emptyMessage,
|
|
31
46
|
gmailClientSettings,
|
|
32
47
|
gmailFailure,
|
|
33
48
|
gmailRequestID,
|
|
34
49
|
gmailRetryAfterMs,
|
|
35
50
|
newGetMessageStep,
|
|
51
|
+
newMessageReceivedTrigger,
|
|
52
|
+
newMessageTriggerRunner,
|
|
36
53
|
newProjectConnection,
|
|
37
54
|
newProjectGmailClient,
|
|
55
|
+
newProjectMessageTriggerRunner,
|
|
56
|
+
newReplyReceivedTrigger,
|
|
38
57
|
newReplyToMessageStep,
|
|
39
58
|
newSendMessageStep,
|
|
40
59
|
parseMailbox,
|
|
@@ -44,7 +63,7 @@ import {
|
|
|
44
63
|
rfcMessageIDAddress,
|
|
45
64
|
statusFailureKind,
|
|
46
65
|
validateSendInput
|
|
47
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-ALVG4HS2.js";
|
|
48
67
|
export {
|
|
49
68
|
ConnectorID,
|
|
50
69
|
GetMessageBranch,
|
|
@@ -59,8 +78,15 @@ export {
|
|
|
59
78
|
GmailMessageResourceSchema,
|
|
60
79
|
GmailProvider,
|
|
61
80
|
GoogleOAuthAuthMethodID,
|
|
81
|
+
MessageEventSchema,
|
|
82
|
+
MessageMatcherSchema,
|
|
83
|
+
MessageReceivedTriggerConfigurationSchema,
|
|
84
|
+
MessageReceivedTriggerDefinition,
|
|
62
85
|
MessageSchema,
|
|
86
|
+
MessageTriggerRunner,
|
|
63
87
|
ProviderID,
|
|
88
|
+
ReplyReceivedTriggerConfigurationSchema,
|
|
89
|
+
ReplyReceivedTriggerDefinition,
|
|
64
90
|
ReplyToMessageBranch,
|
|
65
91
|
ReplyToMessageDefinition,
|
|
66
92
|
ReplyToMessageInputSchema,
|
|
@@ -70,18 +96,30 @@ export {
|
|
|
70
96
|
SendMessageInputSchema,
|
|
71
97
|
SendMessageOperation,
|
|
72
98
|
SendMessageOutputSchema,
|
|
99
|
+
UIEmailListInputPortEmails,
|
|
100
|
+
UISearchQueryInputPortQuery,
|
|
101
|
+
UITextInputPortText,
|
|
102
|
+
UIUnitEmailListInput,
|
|
103
|
+
UIUnitSearchQueryInput,
|
|
104
|
+
UIUnitTextInput,
|
|
73
105
|
WorkspaceDomainDelegationAuthMethodID,
|
|
74
106
|
buildMIMEMessage,
|
|
75
107
|
buildReplyMIMEMessage,
|
|
76
108
|
decodeGmailMessage,
|
|
109
|
+
defineMessageReceivedTriggerBinding,
|
|
110
|
+
defineReplyReceivedTriggerBinding,
|
|
77
111
|
emptyMessage,
|
|
78
112
|
gmailClientSettings,
|
|
79
113
|
gmailFailure,
|
|
80
114
|
gmailRequestID,
|
|
81
115
|
gmailRetryAfterMs,
|
|
82
116
|
newGetMessageStep,
|
|
117
|
+
newMessageReceivedTrigger,
|
|
118
|
+
newMessageTriggerRunner,
|
|
83
119
|
newProjectConnection,
|
|
84
120
|
newProjectGmailClient,
|
|
121
|
+
newProjectMessageTriggerRunner,
|
|
122
|
+
newReplyReceivedTrigger,
|
|
85
123
|
newReplyToMessageStep,
|
|
86
124
|
newSendMessageStep,
|
|
87
125
|
parseMailbox,
|
package/dist/mock/index.cjs
CHANGED
|
@@ -178,7 +178,9 @@ var SendMessageDefinition = {
|
|
|
178
178
|
{ id: "providerRejected", description: "Gmail conclusively rejected the message.", optional: true },
|
|
179
179
|
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
180
180
|
],
|
|
181
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts:
|
|
181
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 7, totalDurationMs: 3e5 } },
|
|
182
|
+
repeatOnUnknown: "limited",
|
|
183
|
+
maxSends: 3
|
|
182
184
|
};
|
|
183
185
|
var ReplyToMessageBranch = {
|
|
184
186
|
Sent: "sent",
|
|
@@ -198,7 +200,9 @@ var ReplyToMessageDefinition = {
|
|
|
198
200
|
{ id: "invalidResponse", description: "Gmail returned an invalid or oversized source message response before sending the reply.", optional: true },
|
|
199
201
|
{ id: "defect", description: "Local input, connection configuration, or connector definition is invalid.", optional: true }
|
|
200
202
|
],
|
|
201
|
-
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts:
|
|
203
|
+
stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "sync", executeRetry: { initialIntervalMs: 1e3, backoffCoefficient: 2, maximumIntervalMs: 3e4, maximumAttempts: 7, totalDurationMs: 3e5 } },
|
|
204
|
+
repeatOnUnknown: "limited",
|
|
205
|
+
maxSends: 3
|
|
202
206
|
};
|
|
203
207
|
|
|
204
208
|
// src/message.ts
|
|
@@ -218,6 +222,20 @@ var GmailMessageResourceSchema = import_zod3.z.object({
|
|
|
218
222
|
internalDate: import_zod3.z.string().nullish(),
|
|
219
223
|
payload: GmailMessagePartSchema.nullish()
|
|
220
224
|
});
|
|
225
|
+
function parseMailbox(value) {
|
|
226
|
+
if (Array.from(value).some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127)) return void 0;
|
|
227
|
+
const trimmed = value.trim();
|
|
228
|
+
const angle = /^(.*?)<([^<>]+)>$/.exec(trimmed);
|
|
229
|
+
if (!angle && /[<>]/.test(trimmed)) return void 0;
|
|
230
|
+
const address = angle?.[2]?.trim() ?? trimmed;
|
|
231
|
+
if (!/^[^<>\s,;@]+@[^<>\s,;@]+$/.test(address)) return void 0;
|
|
232
|
+
let display = angle?.[1]?.trim() ?? "";
|
|
233
|
+
if (display.startsWith('"')) {
|
|
234
|
+
if (!/^"(?:[^"\\]|\\.)*"$/.test(display)) return void 0;
|
|
235
|
+
display = display.slice(1, -1).replace(/\\(.)/g, "$1");
|
|
236
|
+
} else if (/[,:;<>@"\\()[\]]/.test(display)) return void 0;
|
|
237
|
+
return { display, address };
|
|
238
|
+
}
|
|
221
239
|
|
|
222
240
|
// src/http.ts
|
|
223
241
|
var import_connectors_sdk2 = require("@superdurable/connectors-sdk");
|
|
@@ -227,6 +245,7 @@ var import_providerhttp = require("@superdurable/connectors-sdk/providerhttp");
|
|
|
227
245
|
var import_zod4 = require("zod");
|
|
228
246
|
var SentMessageSchema = import_zod4.z.object({ id: import_zod4.z.string().optional(), threadId: import_zod4.z.string().optional() });
|
|
229
247
|
var SentSearchSchema = import_zod4.z.object({ messages: import_zod4.z.array(SentMessageSchema).nullish() });
|
|
248
|
+
var MessageListSchema = import_zod4.z.object({ messages: import_zod4.z.array(import_zod4.z.object({ id: import_zod4.z.string().nullish(), threadId: import_zod4.z.string().nullish() })).nullish() });
|
|
230
249
|
|
|
231
250
|
// src/refresh.ts
|
|
232
251
|
var import_connectors_sdk3 = require("@superdurable/connectors-sdk");
|
|
@@ -306,6 +325,60 @@ var ProjectGmailConfigurationSchema = import_zod5.z.object({
|
|
|
306
325
|
// src/generated/steps.ts
|
|
307
326
|
var import_connectors_sdk10 = require("@superdurable/connectors-sdk");
|
|
308
327
|
|
|
328
|
+
// src/trigger.ts
|
|
329
|
+
var import_connectors_sdk12 = require("@superdurable/connectors-sdk");
|
|
330
|
+
var import_projectconfig2 = require("@superdurable/connectors-sdk/projectconfig");
|
|
331
|
+
var import_zod6 = require("zod");
|
|
332
|
+
|
|
333
|
+
// src/trigger_source.ts
|
|
334
|
+
var import_node_crypto2 = require("crypto");
|
|
335
|
+
var import_connectors_sdk11 = require("@superdurable/connectors-sdk");
|
|
336
|
+
var uuidNamespaceURL = Buffer.from("6ba7b8119dad11d180b400c04fd430c8", "hex");
|
|
337
|
+
|
|
338
|
+
// src/trigger.ts
|
|
339
|
+
var MessageMatcherSchema = import_zod6.z.strictObject({
|
|
340
|
+
/** Case-insensitive substring of the subject or snippet, required when non-empty. */
|
|
341
|
+
messageContains: import_zod6.z.string().optional(),
|
|
342
|
+
/** Sender addresses allowed to match when non-empty; compared case-insensitively. */
|
|
343
|
+
senderEmails: import_zod6.z.array(import_zod6.z.string()).nullable().optional()
|
|
344
|
+
});
|
|
345
|
+
var MessageReceivedTriggerConfigurationSchema = import_zod6.z.strictObject({ searchQuery: import_zod6.z.string().optional(), messageMatcher: MessageMatcherSchema.optional() }).superRefine((configuration, context) => validateMessageMatcher(configuration.messageMatcher, context));
|
|
346
|
+
var ReplyReceivedTriggerConfigurationSchema = import_zod6.z.strictObject({ searchQuery: import_zod6.z.string().optional(), replyMatcher: MessageMatcherSchema.optional() }).superRefine((configuration, context) => validateMessageMatcher(configuration.replyMatcher, context));
|
|
347
|
+
var MessageEventSchema = import_zod6.z.object({
|
|
348
|
+
/** Mailbox that received the message. */
|
|
349
|
+
primaryEmail: import_zod6.z.string(),
|
|
350
|
+
/** Gmail message ID. */
|
|
351
|
+
messageId: import_zod6.z.string(),
|
|
352
|
+
/** Gmail thread ID. */
|
|
353
|
+
threadId: import_zod6.z.string(),
|
|
354
|
+
/** Sender header. */
|
|
355
|
+
from: import_zod6.z.string(),
|
|
356
|
+
/** Decoded subject. */
|
|
357
|
+
subject: import_zod6.z.string(),
|
|
358
|
+
/** Gmail snippet, omitted when empty. */
|
|
359
|
+
snippet: import_zod6.z.string().optional(),
|
|
360
|
+
/** Receive time as RFC 3339 UTC. */
|
|
361
|
+
receivedAt: import_zod6.z.string(),
|
|
362
|
+
/** Whether the message has In-Reply-To or References headers. */
|
|
363
|
+
isReply: import_zod6.z.boolean()
|
|
364
|
+
});
|
|
365
|
+
function validateMessageMatcher(matcher, context) {
|
|
366
|
+
const seen = /* @__PURE__ */ new Set();
|
|
367
|
+
for (const sender of matcher?.senderEmails ?? []) {
|
|
368
|
+
const address = parseMailbox(sender)?.address;
|
|
369
|
+
if (!address) {
|
|
370
|
+
context.addIssue({ code: "custom", message: "Gmail sender email is invalid" });
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const canonical = address.toLowerCase();
|
|
374
|
+
if (seen.has(canonical)) {
|
|
375
|
+
context.addIssue({ code: "custom", message: "Gmail sender emails must be unique" });
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
seen.add(canonical);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
309
382
|
// src/generated/mock.ts
|
|
310
383
|
var import_connectormock = require("@superdurable/connectors-sdk/connectormock");
|
|
311
384
|
var emptyGetMessageInput = GetMessageInputSchema.parse({
|
package/dist/mock/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
SendMessageInputSchema,
|
|
11
11
|
SendMessageOutputSchema,
|
|
12
12
|
SendMessageOutputSchema2
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-ALVG4HS2.js";
|
|
14
14
|
|
|
15
15
|
// src/mock/index.ts
|
|
16
16
|
import { branchCase as branchCase2, newMutation as newMutation2, newQuery as newQuery2, retryCase as retryCase2, uncertainCase } from "@superdurable/connectors-sdk/connectormock";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdurable/connector-google-gmail",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Dex Gmail connector for TypeScript",
|
|
6
6
|
"repository": {
|
|
@@ -49,14 +49,15 @@
|
|
|
49
49
|
"typecheck": "npm run build && tsc --noEmit",
|
|
50
50
|
"lint": "eslint src test test-d examples",
|
|
51
51
|
"test": "npm run build && vitest run test/*.test.ts",
|
|
52
|
-
"test:integration": "npm run build && vitest run examples/gmail-flow/integration.test.ts",
|
|
52
|
+
"test:integration": "npm run build && vitest run examples/gmail-flow/integration.test.ts examples/thread-reply/integration.test.ts",
|
|
53
53
|
"example:worker": "tsx examples/gmail-flow/main.ts",
|
|
54
54
|
"example:start": "tsx examples/gmail-flow/start.ts",
|
|
55
55
|
"test-d": "tsc -p test-d/tsconfig.json",
|
|
56
|
-
"check": "npm run typecheck && npm run test-d && npm run lint && npm test"
|
|
56
|
+
"check": "npm run typecheck && npm run test-d && npm run lint && npm test",
|
|
57
|
+
"example:thread-reply": "tsx examples/thread-reply/main.ts"
|
|
57
58
|
},
|
|
58
59
|
"dependencies": {
|
|
59
|
-
"@superdurable/connectors-sdk": "0.
|
|
60
|
+
"@superdurable/connectors-sdk": "0.11.0",
|
|
60
61
|
"@superdurable/dex": ">=1.28.0",
|
|
61
62
|
"zod": "^4.1.0"
|
|
62
63
|
},
|