@superdurable/connector-google-gmail 0.2.1 → 0.3.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 +14 -2
- package/dex-connector.json +27 -3
- package/dist/{chunk-KVNIQW5Y.js → chunk-PW3NTBVH.js} +466 -23
- package/dist/index.cjs +468 -22
- package/dist/index.d.cts +218 -6
- package/dist/index.d.ts +218 -6
- 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.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { M as Message, R as ReplyToMessageInput, S as SendMessageInput, C as Config, a as CredentialSource, b as Credentials, c as SendMessageOutput, G as GetMessageInput, d as GmailOperations, e as GmailConnection } from './connection-D8OV_Hfe.cjs';
|
|
2
2
|
export { f as ConnectorID, g as GetMessageInputSchema, h as GoogleOAuthAuthMethodID, i as MessageSchema, P as ProviderID, j as ReplyToMessageInputSchema, k as SendMessageInputSchema, l as SendMessageOutputSchema, W as WorkspaceDomainDelegationAuthMethodID } from './connection-D8OV_Hfe.cjs';
|
|
3
3
|
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
|
-
import { QueryDefinition, MutationDefinition, CredentialRefreshDriver, Call, FailureKind, CredentialRefreshState, CredentialRefreshResult, Mutation, MutationAttempt, Query, QueryAttempt, Failure, ReceiptDraft, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep } from '@superdurable/connectors-sdk';
|
|
4
|
+
import { QueryDefinition, MutationDefinition, CredentialRefreshDriver, Call, FailureKind, CredentialRefreshState, CredentialRefreshResult, Mutation, MutationAttempt, Query, QueryAttempt, TriggerLogger, Failure, ReceiptDraft, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep, ConnectionRef, TriggerContext, TriggerTarget, ConnectorConfigurationUI, TriggerDefinition, TriggerBindingDefinition, TriggerRunner } from '@superdurable/connectors-sdk';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { ProviderRequest, ProviderResponse, AddressPolicy } from '@superdurable/connectors-sdk/providerhttp';
|
|
7
7
|
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
@@ -73,8 +73,16 @@ declare function parseMailbox(value: string): {
|
|
|
73
73
|
declare function replyRecipient(message: Message): string;
|
|
74
74
|
/** Validate sender, recipients, subject, and body before sending. */
|
|
75
75
|
declare function validateSendInput(input: SendMessageInput, sender: string): string[];
|
|
76
|
-
/**
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Deterministic provider search identity for one Dex run and connector call.
|
|
78
|
+
*
|
|
79
|
+
* A valid `flowStartedAt` keeps the Go connector's derivation. An absent or
|
|
80
|
+
* invalid one derives the identity from the key and run ID alone, which stays
|
|
81
|
+
* stable across retries of the call within one run.
|
|
82
|
+
*
|
|
83
|
+
* @throws TypeError when `runId` is empty.
|
|
84
|
+
*/
|
|
85
|
+
declare function rfcMessageIDAddress(idempotencyKey: string, runId: string, flowStartedAt?: Date | null): string;
|
|
78
86
|
/** Build the exact raw RFC 5322 request body shared by sends and replies. */
|
|
79
87
|
declare function buildMIMEMessage(callId: string, idempotencyKey: string, messageIdAddress: string, sender: string, recipients: string[], subject: string, textBody: string, htmlBody?: string, replyHeaders?: {
|
|
80
88
|
inReplyTo: string;
|
|
@@ -91,6 +99,8 @@ interface GmailClientSettings {
|
|
|
91
99
|
/** Maximum complete response bytes. */ readonly maxResponseBytes: number;
|
|
92
100
|
/** Maximum encoded MIME message bytes. */ readonly maxMessageBytes: number;
|
|
93
101
|
/** Address policy for the configured endpoint. */ readonly addressPolicy: AddressPolicy;
|
|
102
|
+
/** Delay between Trigger polls in milliseconds. */ readonly pollIntervalMs: number;
|
|
103
|
+
/** Recent inbox messages inspected per Trigger poll. */ readonly pollPageSize: number;
|
|
94
104
|
}
|
|
95
105
|
/** Apply and validate the Gmail manifest's transport defaults. */
|
|
96
106
|
declare function gmailClientSettings(config?: Config): GmailClientSettings;
|
|
@@ -120,6 +130,11 @@ declare function gmailRetryAfterMs(headers: Record<string, string | string[] | u
|
|
|
120
130
|
/** Read the safe Gmail request correlation ID. */
|
|
121
131
|
declare function gmailRequestID(headers: Record<string, string | string[] | undefined>): string;
|
|
122
132
|
|
|
133
|
+
/** One message reference in an inbox listing, newest first as Gmail lists it. */
|
|
134
|
+
interface GmailMessageReference {
|
|
135
|
+
/** Gmail message ID; empty when Gmail omitted it. */ id: string;
|
|
136
|
+
/** Gmail thread ID; empty when Gmail omitted it. */ threadId: string;
|
|
137
|
+
}
|
|
123
138
|
/** Provider identity returned by a Gmail send or Sent Mail lookup. */
|
|
124
139
|
interface SentMessageIdentity {
|
|
125
140
|
/** Gmail message ID. */ id: string;
|
|
@@ -138,6 +153,14 @@ declare class GmailProvider {
|
|
|
138
153
|
constructor(http: GmailHTTPClient);
|
|
139
154
|
/** Read one full or metadata message, returning the raw response on refusal or malformed JSON. */
|
|
140
155
|
readMessage(call: Call, credentials: Credentials, messageId: string, format: 'full' | 'metadata' | 'minimal', signal?: AbortSignal): Promise<GmailReadResult>;
|
|
156
|
+
/**
|
|
157
|
+
* List the newest inbox page that matches searchQuery, as the Go Trigger poller does. It rejects with
|
|
158
|
+
* an error that names no query value when Gmail does not answer 2xx with a usable listing.
|
|
159
|
+
*/
|
|
160
|
+
listInboxMessages(call: Call, credentials: Credentials, searchQuery: string, pageSize: number, signal?: AbortSignal): Promise<{
|
|
161
|
+
messages: GmailMessageReference[];
|
|
162
|
+
credentials: Credentials;
|
|
163
|
+
}>;
|
|
141
164
|
/** Search Sent Mail once for the run-specific RFC Message-ID. */
|
|
142
165
|
findSentMessage(call: Call, credentials: Credentials, messageIdAddress: string, signal?: AbortSignal): Promise<SentMessageIdentity | undefined>;
|
|
143
166
|
/** Post one encoded Gmail messages.send request without redirects or transport replay. */
|
|
@@ -166,7 +189,7 @@ declare class SendMessageOperation implements Mutation<SendMessageInput, SendMes
|
|
|
166
189
|
/** Inject the provider sender used by each Dex attempt. */
|
|
167
190
|
constructor(sender: GmailSender);
|
|
168
191
|
/** Return the immutable manifest operation definition. */
|
|
169
|
-
definition(): _superdurable_connectors_sdk.
|
|
192
|
+
definition(): _superdurable_connectors_sdk.MutationDefinition;
|
|
170
193
|
/** Use the stable connector Call ID as the send correlation key. */
|
|
171
194
|
idempotencyKey(callId: string, input: SendMessageInput): string;
|
|
172
195
|
/** Classify a send using Dex's public current-attempt deadline. */
|
|
@@ -178,7 +201,7 @@ declare class ReplyToMessageOperation implements Mutation<ReplyToMessageInput, S
|
|
|
178
201
|
/** Inject the provider sender used by each Dex attempt. */
|
|
179
202
|
constructor(sender: GmailSender);
|
|
180
203
|
/** Return the immutable manifest operation definition. */
|
|
181
|
-
definition(): _superdurable_connectors_sdk.
|
|
204
|
+
definition(): _superdurable_connectors_sdk.MutationDefinition;
|
|
182
205
|
/** Use the stable connector Call ID as the reply correlation key. */
|
|
183
206
|
idempotencyKey(callId: string, input: ReplyToMessageInput): string;
|
|
184
207
|
/** Classify a reply using Dex's public current-attempt deadline. */
|
|
@@ -203,12 +226,25 @@ interface GmailClientOptions {
|
|
|
203
226
|
transport?: GmailTransport;
|
|
204
227
|
/** Observation clock for receipts. */
|
|
205
228
|
now?: () => Date;
|
|
229
|
+
/**
|
|
230
|
+
* Receives the Trigger pollers' records: failed polls, ignored and skipped messages, delivery retries,
|
|
231
|
+
* and the durable inboxes that newProjectMessageTriggerRunner creates. Omitted uses
|
|
232
|
+
* defaultTriggerLogger. Records carry message and thread IDs, never senders, subjects, snippets,
|
|
233
|
+
* bodies, or tokens.
|
|
234
|
+
*/
|
|
235
|
+
logger?: TriggerLogger;
|
|
206
236
|
}
|
|
207
237
|
/** Gmail connection with operation-specific provider interfaces. */
|
|
208
238
|
declare class GmailClient implements GmailOperations {
|
|
209
239
|
#private;
|
|
240
|
+
/** Trigger record destination. */ readonly triggerLogger: TriggerLogger;
|
|
210
241
|
/** Validate settings and inject a host-owned credential source. */
|
|
211
242
|
constructor(config: Config, credentials: CredentialSource, options?: GmailClientOptions);
|
|
243
|
+
/** @internal The authenticated transport and provider methods that the Trigger pollers share. */
|
|
244
|
+
triggerTransport(): {
|
|
245
|
+
http: GmailHTTPClient;
|
|
246
|
+
provider: GmailProvider;
|
|
247
|
+
};
|
|
212
248
|
/** Return the getMessage Query bound to this connection. */
|
|
213
249
|
getMessage(): GetMessageOperation;
|
|
214
250
|
/** Return the sendMessage Mutation bound to this connection. */
|
|
@@ -272,4 +308,180 @@ declare function newSendMessageStep<StepInput>(configuration: SendMessageStepCon
|
|
|
272
308
|
/** Build a Gmail reply Step with its typed connection. */
|
|
273
309
|
declare function newReplyToMessageStep<StepInput>(configuration: ReplyToMessageStepConfig<StepInput>): MutationStep<StepInput, ReplyToMessageInput, SendMessageOutput>;
|
|
274
310
|
|
|
275
|
-
|
|
311
|
+
/** One poller's source and the target it delivers to. */
|
|
312
|
+
interface MessageTriggerRoute {
|
|
313
|
+
source: MessagePollingTriggerSource;
|
|
314
|
+
target: TriggerTarget<MessageEvent>;
|
|
315
|
+
}
|
|
316
|
+
/** One inbox list call, delivered later by MessagePollingTriggerSource.deliver. */
|
|
317
|
+
interface MessageListing {
|
|
318
|
+
credentials: Credentials;
|
|
319
|
+
messages: GmailMessageReference[];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Polls one Gmail binding: it lists the newest inbox page, reads each new message's metadata, and
|
|
323
|
+
* delivers matching roots or replies oldest first, as the Go connector's poller does. The delivered set
|
|
324
|
+
* covers the last listed page in memory; a restart rescans the page, and the Flow start request ID and
|
|
325
|
+
* the application's RPC absorb the duplicates.
|
|
326
|
+
*/
|
|
327
|
+
declare class MessagePollingTriggerSource {
|
|
328
|
+
#private;
|
|
329
|
+
/** Bind one binding's query and matcher; an empty bindingName omits the binding log attribute. */
|
|
330
|
+
constructor(client: GmailClient, connection: ConnectionRef, triggerName: string, bindingName: string, searchQuery: string, matcher: MessageMatcher, requiresReply: boolean);
|
|
331
|
+
/** Scan, then wait one poll interval, until the context ends. */
|
|
332
|
+
run(context: TriggerContext, target: TriggerTarget<MessageEvent>): Promise<void>;
|
|
333
|
+
/** List the inbox and deliver the listed messages. */
|
|
334
|
+
scan(context: TriggerContext, target: TriggerTarget<MessageEvent>): Promise<void>;
|
|
335
|
+
/** Read the newest inbox page that matches the source's search query. */
|
|
336
|
+
list(context: TriggerContext): Promise<MessageListing>;
|
|
337
|
+
/**
|
|
338
|
+
* Hand target the event that failed on an earlier poll, if any, then every new matching message in
|
|
339
|
+
* listing, oldest first. It stops at the first failure, so the next poll retries that event before any
|
|
340
|
+
* later message, even after newer mail pushes it off the listed page.
|
|
341
|
+
*/
|
|
342
|
+
deliver(context: TriggerContext, target: TriggerTarget<MessageEvent>, listing: MessageListing): Promise<void>;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** Filters received Gmail messages by sender and text. */
|
|
346
|
+
declare const MessageMatcherSchema: z.ZodObject<{
|
|
347
|
+
messageContains: z.ZodOptional<z.ZodString>;
|
|
348
|
+
senderEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
349
|
+
}, z.core.$strict>;
|
|
350
|
+
/** Sender and text filter of one Gmail message Trigger binding. */
|
|
351
|
+
type MessageMatcher = z.infer<typeof MessageMatcherSchema>;
|
|
352
|
+
/** Configuration of messageReceived: an optional Gmail search query and the root-message matcher. */
|
|
353
|
+
declare const MessageReceivedTriggerConfigurationSchema: z.ZodObject<{
|
|
354
|
+
searchQuery: z.ZodOptional<z.ZodString>;
|
|
355
|
+
messageMatcher: z.ZodOptional<z.ZodObject<{
|
|
356
|
+
messageContains: z.ZodOptional<z.ZodString>;
|
|
357
|
+
senderEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
358
|
+
}, z.core.$strict>>;
|
|
359
|
+
}, z.core.$strict>;
|
|
360
|
+
/** Search query and root-message matcher of one messageReceived binding. */
|
|
361
|
+
type MessageReceivedTriggerConfiguration = z.infer<typeof MessageReceivedTriggerConfigurationSchema>;
|
|
362
|
+
/** Configuration of replyReceived: an optional Gmail search query and the reply matcher. */
|
|
363
|
+
declare const ReplyReceivedTriggerConfigurationSchema: z.ZodObject<{
|
|
364
|
+
searchQuery: z.ZodOptional<z.ZodString>;
|
|
365
|
+
replyMatcher: z.ZodOptional<z.ZodObject<{
|
|
366
|
+
messageContains: z.ZodOptional<z.ZodString>;
|
|
367
|
+
senderEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
368
|
+
}, z.core.$strict>>;
|
|
369
|
+
}, z.core.$strict>;
|
|
370
|
+
/** Search query and reply matcher of one replyReceived binding. */
|
|
371
|
+
type ReplyReceivedTriggerConfiguration = z.infer<typeof ReplyReceivedTriggerConfigurationSchema>;
|
|
372
|
+
/** The metadata-only payload of both Gmail Triggers; field names and order match the Go connector. */
|
|
373
|
+
declare const MessageEventSchema: z.ZodObject<{
|
|
374
|
+
primaryEmail: z.ZodString;
|
|
375
|
+
messageId: z.ZodString;
|
|
376
|
+
threadId: z.ZodString;
|
|
377
|
+
from: z.ZodString;
|
|
378
|
+
subject: z.ZodString;
|
|
379
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
380
|
+
receivedAt: z.ZodString;
|
|
381
|
+
isReply: z.ZodBoolean;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
/** One received Gmail message. */
|
|
384
|
+
type MessageEvent = z.infer<typeof MessageEventSchema>;
|
|
385
|
+
/** Manifest definition of messageReceived. */
|
|
386
|
+
declare const MessageReceivedTriggerDefinition: TriggerDefinition;
|
|
387
|
+
/** Manifest definition of replyReceived. */
|
|
388
|
+
declare const ReplyReceivedTriggerDefinition: TriggerDefinition;
|
|
389
|
+
/** Gmail search query input UI unit. */ declare const UIUnitSearchQueryInput = "searchQueryInput";
|
|
390
|
+
/** Search query input output port. */ declare const UISearchQueryInputPortQuery = "query";
|
|
391
|
+
/** Email address list input UI unit. */ declare const UIUnitEmailListInput = "emailListInput";
|
|
392
|
+
/** Email list input output port. */ declare const UIEmailListInputPortEmails = "emails";
|
|
393
|
+
/** Plain text input UI unit. */ declare const UIUnitTextInput = "textInput";
|
|
394
|
+
/** Text input output port. */ declare const UITextInputPortText = "text";
|
|
395
|
+
/** One static application binding of a Gmail message Trigger. */
|
|
396
|
+
interface GmailTriggerBindingConfig {
|
|
397
|
+
/** Static connection name. */ connectionName: string;
|
|
398
|
+
/** Static binding name. */ bindingName: string;
|
|
399
|
+
/** Connector Studio configuration units for the binding. */ configurationUI: ConnectorConfigurationUI;
|
|
400
|
+
}
|
|
401
|
+
/** Declare a static messageReceived binding for Flow Definition tooling and Dex Web. */
|
|
402
|
+
declare function defineMessageReceivedTriggerBinding(config: GmailTriggerBindingConfig): TriggerBindingDefinition;
|
|
403
|
+
/** Declare a static replyReceived binding for Flow Definition tooling and Dex Web. */
|
|
404
|
+
declare function defineReplyReceivedTriggerBinding(config: GmailTriggerBindingConfig): TriggerBindingDefinition;
|
|
405
|
+
/** Configuration of one standalone Gmail message Trigger. */
|
|
406
|
+
interface GmailMessageTriggerConfig<Configuration> {
|
|
407
|
+
/** Gmail connection bound to a GmailClient. */ connection: GmailConnection;
|
|
408
|
+
/** Static connection name; must equal the connection's name. */ connectionName: string;
|
|
409
|
+
/** Static binding name. */ bindingName: string;
|
|
410
|
+
/** Search query and matcher. */ configuration: Configuration;
|
|
411
|
+
/** Routes accepted events into the application. */ target: TriggerTarget<MessageEvent>;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Create one messageReceived Trigger that polls on its own. Prefer one MessageTriggerRunner per
|
|
415
|
+
* connection, which delivers every root before any reply.
|
|
416
|
+
*/
|
|
417
|
+
declare function newMessageReceivedTrigger(config: GmailMessageTriggerConfig<MessageReceivedTriggerConfiguration>): TriggerRunner;
|
|
418
|
+
/**
|
|
419
|
+
* Create one replyReceived Trigger that polls on its own. Prefer one MessageTriggerRunner per
|
|
420
|
+
* connection, which delivers every root before any reply.
|
|
421
|
+
*/
|
|
422
|
+
declare function newReplyReceivedTrigger(config: GmailMessageTriggerConfig<ReplyReceivedTriggerConfiguration>): TriggerRunner;
|
|
423
|
+
/** One root-message binding and its application target. */
|
|
424
|
+
interface MessageReceivedTriggerRoute {
|
|
425
|
+
/** Configured binding name. */ bindingName: string;
|
|
426
|
+
/** Search query and root-message matcher. */ configuration: MessageReceivedTriggerConfiguration;
|
|
427
|
+
/** Routes accepted events into the application. */ target: TriggerTarget<MessageEvent>;
|
|
428
|
+
}
|
|
429
|
+
/** One reply binding and its application target. */
|
|
430
|
+
interface ReplyReceivedTriggerRoute {
|
|
431
|
+
/** Configured binding name. */ bindingName: string;
|
|
432
|
+
/** Search query and reply matcher. */ configuration: ReplyReceivedTriggerConfiguration;
|
|
433
|
+
/** Routes accepted events into the application. */ target: TriggerTarget<MessageEvent>;
|
|
434
|
+
}
|
|
435
|
+
/** Gmail message Triggers that share one ordered poller. */
|
|
436
|
+
interface MessageTriggerRunnerConfig {
|
|
437
|
+
/** Gmail connection bound to a GmailClient. */ connection: GmailConnection;
|
|
438
|
+
/** Root-message bindings. */ messageReceivedRoutes?: readonly MessageReceivedTriggerRoute[];
|
|
439
|
+
/** Reply bindings. */ replyReceivedRoutes?: readonly ReplyReceivedTriggerRoute[];
|
|
440
|
+
}
|
|
441
|
+
/** One root-message binding saved in the project configuration and its application target. */
|
|
442
|
+
interface ProjectMessageReceivedTriggerRoute {
|
|
443
|
+
bindingName: string; /** Application target. */
|
|
444
|
+
target: TriggerTarget<MessageEvent>;
|
|
445
|
+
}
|
|
446
|
+
/** One reply binding saved in the project configuration and its application target. */
|
|
447
|
+
interface ProjectReplyReceivedTriggerRoute {
|
|
448
|
+
bindingName: string; /** Application target. */
|
|
449
|
+
target: TriggerTarget<MessageEvent>;
|
|
450
|
+
}
|
|
451
|
+
/** Gmail message Trigger bindings selected from the project configuration. */
|
|
452
|
+
interface ProjectMessageTriggerRunnerConfig {
|
|
453
|
+
/** Root-message bindings. */ messageReceivedRoutes?: readonly ProjectMessageReceivedTriggerRoute[];
|
|
454
|
+
/** Reply bindings. */ replyReceivedRoutes?: readonly ProjectReplyReceivedTriggerRoute[];
|
|
455
|
+
}
|
|
456
|
+
/** Polls every configured Gmail route of one connection and delivers root messages before replies. */
|
|
457
|
+
declare class MessageTriggerRunner {
|
|
458
|
+
#private;
|
|
459
|
+
/** @internal Use newMessageTriggerRunner or newProjectMessageTriggerRunner. */
|
|
460
|
+
constructor(rootRoutes: readonly MessageTriggerRoute[], replyRoutes: readonly MessageTriggerRoute[], pollIntervalMs: number);
|
|
461
|
+
/**
|
|
462
|
+
* Replay each route's durable inbox in order, roots first, then poll until the context ends. Each poll
|
|
463
|
+
* lists every reply route before any root route, then delivers every root before any reply, and ends
|
|
464
|
+
* at the first failure. Every later poll retries the failed event before that route's listed messages,
|
|
465
|
+
* even after Gmail stops listing it. Gmail receives a thread's root before any reply to it, so the
|
|
466
|
+
* root of every listed reply is in the later root listing and reaches Dex first.
|
|
467
|
+
*
|
|
468
|
+
* It logs through the client's logger: WARN "gmail poll failed; retrying" with the consecutive failed
|
|
469
|
+
* polls as attempt and the poll interval as delay_ms when a list or read fails, WARN "trigger delivery
|
|
470
|
+
* failed; retrying" with the attempt number when a target fails, INFO "trigger delivered after retry"
|
|
471
|
+
* when a later poll delivers that message, DEBUG "trigger event ignored" with its reason, and the
|
|
472
|
+
* durable inbox records. It rejects with TriggerDeliveryAbortedError once the context ends, and when
|
|
473
|
+
* an inbox replay fails.
|
|
474
|
+
*/
|
|
475
|
+
run(context: TriggerContext): Promise<void>;
|
|
476
|
+
}
|
|
477
|
+
/** Create one ordered runner for every configured Gmail message Trigger route of a connection; throws on invalid wiring. */
|
|
478
|
+
declare function newMessageTriggerRunner(config: MessageTriggerRunnerConfig): MessageTriggerRunner;
|
|
479
|
+
/**
|
|
480
|
+
* Open connectionName from the loaded project, load the selected bindings' saved configuration, and
|
|
481
|
+
* create one durable, ordered runner. Each route keeps acknowledged events in its binding's project
|
|
482
|
+
* Trigger inbox until its target consumes them, so a restarted or replaced replica replays them. A
|
|
483
|
+
* route whose binding is not configured throws. The options' logger also applies to those inboxes.
|
|
484
|
+
*/
|
|
485
|
+
declare function newProjectMessageTriggerRunner(project: LoadedProject, connectionName: string, config: ProjectMessageTriggerRunnerConfig, options?: GmailClientOptions): MessageTriggerRunner;
|
|
486
|
+
|
|
487
|
+
export { Config, CredentialSource, Credentials, GetMessageBranch, GetMessageDefinition, GetMessageInput, GetMessageOperation, type GetMessageStepConfig, GmailClient, type GmailClientOptions, type GmailClientSettings, GmailConnection, GmailCredentialError, GmailCredentialRefreshDriver, GmailHTTPClient, type GmailMessagePart, type GmailMessageReference, type GmailMessageResource, GmailMessageResourceSchema, type GmailMessageTriggerConfig, GmailOperations, GmailProvider, type GmailReadResult, type GmailTransport, type GmailTriggerBindingConfig, Message, type MessageEvent, MessageEventSchema, type MessageMatcher, MessageMatcherSchema, type MessageReceivedTriggerConfiguration, MessageReceivedTriggerConfigurationSchema, MessageReceivedTriggerDefinition, type MessageReceivedTriggerRoute, MessageTriggerRunner, type MessageTriggerRunnerConfig, type ProjectMessageReceivedTriggerRoute, type ProjectMessageTriggerRunnerConfig, type ProjectReplyReceivedTriggerRoute, type ReplyReceivedTriggerConfiguration, ReplyReceivedTriggerConfigurationSchema, ReplyReceivedTriggerDefinition, type ReplyReceivedTriggerRoute, ReplyToMessageBranch, ReplyToMessageDefinition, ReplyToMessageInput, ReplyToMessageOperation, type ReplyToMessageStepConfig, SendMessageBranch, SendMessageDefinition, SendMessageInput, SendMessageOperation, SendMessageOutput, type SendMessageStepConfig, type SentMessageIdentity, UIEmailListInputPortEmails, UISearchQueryInputPortQuery, UITextInputPortText, UIUnitEmailListInput, UIUnitSearchQueryInput, UIUnitTextInput, buildMIMEMessage, buildReplyMIMEMessage, decodeGmailMessage, defineMessageReceivedTriggerBinding, defineReplyReceivedTriggerBinding, emptyMessage, gmailClientSettings, gmailFailure, gmailRequestID, gmailRetryAfterMs, newGetMessageStep, newMessageReceivedTrigger, newMessageTriggerRunner, newProjectConnection, newProjectGmailClient, newProjectMessageTriggerRunner, newReplyReceivedTrigger, newReplyToMessageStep, newSendMessageStep, parseMailbox, parseSentResponse, receiptFor, replyRecipient, rfcMessageIDAddress, statusFailureKind, validateSendInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { M as Message, R as ReplyToMessageInput, S as SendMessageInput, C as Config, a as CredentialSource, b as Credentials, c as SendMessageOutput, G as GetMessageInput, d as GmailOperations, e as GmailConnection } from './connection-D8OV_Hfe.js';
|
|
2
2
|
export { f as ConnectorID, g as GetMessageInputSchema, h as GoogleOAuthAuthMethodID, i as MessageSchema, P as ProviderID, j as ReplyToMessageInputSchema, k as SendMessageInputSchema, l as SendMessageOutputSchema, W as WorkspaceDomainDelegationAuthMethodID } from './connection-D8OV_Hfe.js';
|
|
3
3
|
import * as _superdurable_connectors_sdk from '@superdurable/connectors-sdk';
|
|
4
|
-
import { QueryDefinition, MutationDefinition, CredentialRefreshDriver, Call, FailureKind, CredentialRefreshState, CredentialRefreshResult, Mutation, MutationAttempt, Query, QueryAttempt, Failure, ReceiptDraft, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep } from '@superdurable/connectors-sdk';
|
|
4
|
+
import { QueryDefinition, MutationDefinition, CredentialRefreshDriver, Call, FailureKind, CredentialRefreshState, CredentialRefreshResult, Mutation, MutationAttempt, Query, QueryAttempt, TriggerLogger, Failure, ReceiptDraft, QueryStepConfig, QueryResult, MutationStepConfig, MutationResult, QueryStep, MutationStep, ConnectionRef, TriggerContext, TriggerTarget, ConnectorConfigurationUI, TriggerDefinition, TriggerBindingDefinition, TriggerRunner } from '@superdurable/connectors-sdk';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { ProviderRequest, ProviderResponse, AddressPolicy } from '@superdurable/connectors-sdk/providerhttp';
|
|
7
7
|
import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
|
|
@@ -73,8 +73,16 @@ declare function parseMailbox(value: string): {
|
|
|
73
73
|
declare function replyRecipient(message: Message): string;
|
|
74
74
|
/** Validate sender, recipients, subject, and body before sending. */
|
|
75
75
|
declare function validateSendInput(input: SendMessageInput, sender: string): string[];
|
|
76
|
-
/**
|
|
77
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Deterministic provider search identity for one Dex run and connector call.
|
|
78
|
+
*
|
|
79
|
+
* A valid `flowStartedAt` keeps the Go connector's derivation. An absent or
|
|
80
|
+
* invalid one derives the identity from the key and run ID alone, which stays
|
|
81
|
+
* stable across retries of the call within one run.
|
|
82
|
+
*
|
|
83
|
+
* @throws TypeError when `runId` is empty.
|
|
84
|
+
*/
|
|
85
|
+
declare function rfcMessageIDAddress(idempotencyKey: string, runId: string, flowStartedAt?: Date | null): string;
|
|
78
86
|
/** Build the exact raw RFC 5322 request body shared by sends and replies. */
|
|
79
87
|
declare function buildMIMEMessage(callId: string, idempotencyKey: string, messageIdAddress: string, sender: string, recipients: string[], subject: string, textBody: string, htmlBody?: string, replyHeaders?: {
|
|
80
88
|
inReplyTo: string;
|
|
@@ -91,6 +99,8 @@ interface GmailClientSettings {
|
|
|
91
99
|
/** Maximum complete response bytes. */ readonly maxResponseBytes: number;
|
|
92
100
|
/** Maximum encoded MIME message bytes. */ readonly maxMessageBytes: number;
|
|
93
101
|
/** Address policy for the configured endpoint. */ readonly addressPolicy: AddressPolicy;
|
|
102
|
+
/** Delay between Trigger polls in milliseconds. */ readonly pollIntervalMs: number;
|
|
103
|
+
/** Recent inbox messages inspected per Trigger poll. */ readonly pollPageSize: number;
|
|
94
104
|
}
|
|
95
105
|
/** Apply and validate the Gmail manifest's transport defaults. */
|
|
96
106
|
declare function gmailClientSettings(config?: Config): GmailClientSettings;
|
|
@@ -120,6 +130,11 @@ declare function gmailRetryAfterMs(headers: Record<string, string | string[] | u
|
|
|
120
130
|
/** Read the safe Gmail request correlation ID. */
|
|
121
131
|
declare function gmailRequestID(headers: Record<string, string | string[] | undefined>): string;
|
|
122
132
|
|
|
133
|
+
/** One message reference in an inbox listing, newest first as Gmail lists it. */
|
|
134
|
+
interface GmailMessageReference {
|
|
135
|
+
/** Gmail message ID; empty when Gmail omitted it. */ id: string;
|
|
136
|
+
/** Gmail thread ID; empty when Gmail omitted it. */ threadId: string;
|
|
137
|
+
}
|
|
123
138
|
/** Provider identity returned by a Gmail send or Sent Mail lookup. */
|
|
124
139
|
interface SentMessageIdentity {
|
|
125
140
|
/** Gmail message ID. */ id: string;
|
|
@@ -138,6 +153,14 @@ declare class GmailProvider {
|
|
|
138
153
|
constructor(http: GmailHTTPClient);
|
|
139
154
|
/** Read one full or metadata message, returning the raw response on refusal or malformed JSON. */
|
|
140
155
|
readMessage(call: Call, credentials: Credentials, messageId: string, format: 'full' | 'metadata' | 'minimal', signal?: AbortSignal): Promise<GmailReadResult>;
|
|
156
|
+
/**
|
|
157
|
+
* List the newest inbox page that matches searchQuery, as the Go Trigger poller does. It rejects with
|
|
158
|
+
* an error that names no query value when Gmail does not answer 2xx with a usable listing.
|
|
159
|
+
*/
|
|
160
|
+
listInboxMessages(call: Call, credentials: Credentials, searchQuery: string, pageSize: number, signal?: AbortSignal): Promise<{
|
|
161
|
+
messages: GmailMessageReference[];
|
|
162
|
+
credentials: Credentials;
|
|
163
|
+
}>;
|
|
141
164
|
/** Search Sent Mail once for the run-specific RFC Message-ID. */
|
|
142
165
|
findSentMessage(call: Call, credentials: Credentials, messageIdAddress: string, signal?: AbortSignal): Promise<SentMessageIdentity | undefined>;
|
|
143
166
|
/** Post one encoded Gmail messages.send request without redirects or transport replay. */
|
|
@@ -166,7 +189,7 @@ declare class SendMessageOperation implements Mutation<SendMessageInput, SendMes
|
|
|
166
189
|
/** Inject the provider sender used by each Dex attempt. */
|
|
167
190
|
constructor(sender: GmailSender);
|
|
168
191
|
/** Return the immutable manifest operation definition. */
|
|
169
|
-
definition(): _superdurable_connectors_sdk.
|
|
192
|
+
definition(): _superdurable_connectors_sdk.MutationDefinition;
|
|
170
193
|
/** Use the stable connector Call ID as the send correlation key. */
|
|
171
194
|
idempotencyKey(callId: string, input: SendMessageInput): string;
|
|
172
195
|
/** Classify a send using Dex's public current-attempt deadline. */
|
|
@@ -178,7 +201,7 @@ declare class ReplyToMessageOperation implements Mutation<ReplyToMessageInput, S
|
|
|
178
201
|
/** Inject the provider sender used by each Dex attempt. */
|
|
179
202
|
constructor(sender: GmailSender);
|
|
180
203
|
/** Return the immutable manifest operation definition. */
|
|
181
|
-
definition(): _superdurable_connectors_sdk.
|
|
204
|
+
definition(): _superdurable_connectors_sdk.MutationDefinition;
|
|
182
205
|
/** Use the stable connector Call ID as the reply correlation key. */
|
|
183
206
|
idempotencyKey(callId: string, input: ReplyToMessageInput): string;
|
|
184
207
|
/** Classify a reply using Dex's public current-attempt deadline. */
|
|
@@ -203,12 +226,25 @@ interface GmailClientOptions {
|
|
|
203
226
|
transport?: GmailTransport;
|
|
204
227
|
/** Observation clock for receipts. */
|
|
205
228
|
now?: () => Date;
|
|
229
|
+
/**
|
|
230
|
+
* Receives the Trigger pollers' records: failed polls, ignored and skipped messages, delivery retries,
|
|
231
|
+
* and the durable inboxes that newProjectMessageTriggerRunner creates. Omitted uses
|
|
232
|
+
* defaultTriggerLogger. Records carry message and thread IDs, never senders, subjects, snippets,
|
|
233
|
+
* bodies, or tokens.
|
|
234
|
+
*/
|
|
235
|
+
logger?: TriggerLogger;
|
|
206
236
|
}
|
|
207
237
|
/** Gmail connection with operation-specific provider interfaces. */
|
|
208
238
|
declare class GmailClient implements GmailOperations {
|
|
209
239
|
#private;
|
|
240
|
+
/** Trigger record destination. */ readonly triggerLogger: TriggerLogger;
|
|
210
241
|
/** Validate settings and inject a host-owned credential source. */
|
|
211
242
|
constructor(config: Config, credentials: CredentialSource, options?: GmailClientOptions);
|
|
243
|
+
/** @internal The authenticated transport and provider methods that the Trigger pollers share. */
|
|
244
|
+
triggerTransport(): {
|
|
245
|
+
http: GmailHTTPClient;
|
|
246
|
+
provider: GmailProvider;
|
|
247
|
+
};
|
|
212
248
|
/** Return the getMessage Query bound to this connection. */
|
|
213
249
|
getMessage(): GetMessageOperation;
|
|
214
250
|
/** Return the sendMessage Mutation bound to this connection. */
|
|
@@ -272,4 +308,180 @@ declare function newSendMessageStep<StepInput>(configuration: SendMessageStepCon
|
|
|
272
308
|
/** Build a Gmail reply Step with its typed connection. */
|
|
273
309
|
declare function newReplyToMessageStep<StepInput>(configuration: ReplyToMessageStepConfig<StepInput>): MutationStep<StepInput, ReplyToMessageInput, SendMessageOutput>;
|
|
274
310
|
|
|
275
|
-
|
|
311
|
+
/** One poller's source and the target it delivers to. */
|
|
312
|
+
interface MessageTriggerRoute {
|
|
313
|
+
source: MessagePollingTriggerSource;
|
|
314
|
+
target: TriggerTarget<MessageEvent>;
|
|
315
|
+
}
|
|
316
|
+
/** One inbox list call, delivered later by MessagePollingTriggerSource.deliver. */
|
|
317
|
+
interface MessageListing {
|
|
318
|
+
credentials: Credentials;
|
|
319
|
+
messages: GmailMessageReference[];
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Polls one Gmail binding: it lists the newest inbox page, reads each new message's metadata, and
|
|
323
|
+
* delivers matching roots or replies oldest first, as the Go connector's poller does. The delivered set
|
|
324
|
+
* covers the last listed page in memory; a restart rescans the page, and the Flow start request ID and
|
|
325
|
+
* the application's RPC absorb the duplicates.
|
|
326
|
+
*/
|
|
327
|
+
declare class MessagePollingTriggerSource {
|
|
328
|
+
#private;
|
|
329
|
+
/** Bind one binding's query and matcher; an empty bindingName omits the binding log attribute. */
|
|
330
|
+
constructor(client: GmailClient, connection: ConnectionRef, triggerName: string, bindingName: string, searchQuery: string, matcher: MessageMatcher, requiresReply: boolean);
|
|
331
|
+
/** Scan, then wait one poll interval, until the context ends. */
|
|
332
|
+
run(context: TriggerContext, target: TriggerTarget<MessageEvent>): Promise<void>;
|
|
333
|
+
/** List the inbox and deliver the listed messages. */
|
|
334
|
+
scan(context: TriggerContext, target: TriggerTarget<MessageEvent>): Promise<void>;
|
|
335
|
+
/** Read the newest inbox page that matches the source's search query. */
|
|
336
|
+
list(context: TriggerContext): Promise<MessageListing>;
|
|
337
|
+
/**
|
|
338
|
+
* Hand target the event that failed on an earlier poll, if any, then every new matching message in
|
|
339
|
+
* listing, oldest first. It stops at the first failure, so the next poll retries that event before any
|
|
340
|
+
* later message, even after newer mail pushes it off the listed page.
|
|
341
|
+
*/
|
|
342
|
+
deliver(context: TriggerContext, target: TriggerTarget<MessageEvent>, listing: MessageListing): Promise<void>;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** Filters received Gmail messages by sender and text. */
|
|
346
|
+
declare const MessageMatcherSchema: z.ZodObject<{
|
|
347
|
+
messageContains: z.ZodOptional<z.ZodString>;
|
|
348
|
+
senderEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
349
|
+
}, z.core.$strict>;
|
|
350
|
+
/** Sender and text filter of one Gmail message Trigger binding. */
|
|
351
|
+
type MessageMatcher = z.infer<typeof MessageMatcherSchema>;
|
|
352
|
+
/** Configuration of messageReceived: an optional Gmail search query and the root-message matcher. */
|
|
353
|
+
declare const MessageReceivedTriggerConfigurationSchema: z.ZodObject<{
|
|
354
|
+
searchQuery: z.ZodOptional<z.ZodString>;
|
|
355
|
+
messageMatcher: z.ZodOptional<z.ZodObject<{
|
|
356
|
+
messageContains: z.ZodOptional<z.ZodString>;
|
|
357
|
+
senderEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
358
|
+
}, z.core.$strict>>;
|
|
359
|
+
}, z.core.$strict>;
|
|
360
|
+
/** Search query and root-message matcher of one messageReceived binding. */
|
|
361
|
+
type MessageReceivedTriggerConfiguration = z.infer<typeof MessageReceivedTriggerConfigurationSchema>;
|
|
362
|
+
/** Configuration of replyReceived: an optional Gmail search query and the reply matcher. */
|
|
363
|
+
declare const ReplyReceivedTriggerConfigurationSchema: z.ZodObject<{
|
|
364
|
+
searchQuery: z.ZodOptional<z.ZodString>;
|
|
365
|
+
replyMatcher: z.ZodOptional<z.ZodObject<{
|
|
366
|
+
messageContains: z.ZodOptional<z.ZodString>;
|
|
367
|
+
senderEmails: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
368
|
+
}, z.core.$strict>>;
|
|
369
|
+
}, z.core.$strict>;
|
|
370
|
+
/** Search query and reply matcher of one replyReceived binding. */
|
|
371
|
+
type ReplyReceivedTriggerConfiguration = z.infer<typeof ReplyReceivedTriggerConfigurationSchema>;
|
|
372
|
+
/** The metadata-only payload of both Gmail Triggers; field names and order match the Go connector. */
|
|
373
|
+
declare const MessageEventSchema: z.ZodObject<{
|
|
374
|
+
primaryEmail: z.ZodString;
|
|
375
|
+
messageId: z.ZodString;
|
|
376
|
+
threadId: z.ZodString;
|
|
377
|
+
from: z.ZodString;
|
|
378
|
+
subject: z.ZodString;
|
|
379
|
+
snippet: z.ZodOptional<z.ZodString>;
|
|
380
|
+
receivedAt: z.ZodString;
|
|
381
|
+
isReply: z.ZodBoolean;
|
|
382
|
+
}, z.core.$strip>;
|
|
383
|
+
/** One received Gmail message. */
|
|
384
|
+
type MessageEvent = z.infer<typeof MessageEventSchema>;
|
|
385
|
+
/** Manifest definition of messageReceived. */
|
|
386
|
+
declare const MessageReceivedTriggerDefinition: TriggerDefinition;
|
|
387
|
+
/** Manifest definition of replyReceived. */
|
|
388
|
+
declare const ReplyReceivedTriggerDefinition: TriggerDefinition;
|
|
389
|
+
/** Gmail search query input UI unit. */ declare const UIUnitSearchQueryInput = "searchQueryInput";
|
|
390
|
+
/** Search query input output port. */ declare const UISearchQueryInputPortQuery = "query";
|
|
391
|
+
/** Email address list input UI unit. */ declare const UIUnitEmailListInput = "emailListInput";
|
|
392
|
+
/** Email list input output port. */ declare const UIEmailListInputPortEmails = "emails";
|
|
393
|
+
/** Plain text input UI unit. */ declare const UIUnitTextInput = "textInput";
|
|
394
|
+
/** Text input output port. */ declare const UITextInputPortText = "text";
|
|
395
|
+
/** One static application binding of a Gmail message Trigger. */
|
|
396
|
+
interface GmailTriggerBindingConfig {
|
|
397
|
+
/** Static connection name. */ connectionName: string;
|
|
398
|
+
/** Static binding name. */ bindingName: string;
|
|
399
|
+
/** Connector Studio configuration units for the binding. */ configurationUI: ConnectorConfigurationUI;
|
|
400
|
+
}
|
|
401
|
+
/** Declare a static messageReceived binding for Flow Definition tooling and Dex Web. */
|
|
402
|
+
declare function defineMessageReceivedTriggerBinding(config: GmailTriggerBindingConfig): TriggerBindingDefinition;
|
|
403
|
+
/** Declare a static replyReceived binding for Flow Definition tooling and Dex Web. */
|
|
404
|
+
declare function defineReplyReceivedTriggerBinding(config: GmailTriggerBindingConfig): TriggerBindingDefinition;
|
|
405
|
+
/** Configuration of one standalone Gmail message Trigger. */
|
|
406
|
+
interface GmailMessageTriggerConfig<Configuration> {
|
|
407
|
+
/** Gmail connection bound to a GmailClient. */ connection: GmailConnection;
|
|
408
|
+
/** Static connection name; must equal the connection's name. */ connectionName: string;
|
|
409
|
+
/** Static binding name. */ bindingName: string;
|
|
410
|
+
/** Search query and matcher. */ configuration: Configuration;
|
|
411
|
+
/** Routes accepted events into the application. */ target: TriggerTarget<MessageEvent>;
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Create one messageReceived Trigger that polls on its own. Prefer one MessageTriggerRunner per
|
|
415
|
+
* connection, which delivers every root before any reply.
|
|
416
|
+
*/
|
|
417
|
+
declare function newMessageReceivedTrigger(config: GmailMessageTriggerConfig<MessageReceivedTriggerConfiguration>): TriggerRunner;
|
|
418
|
+
/**
|
|
419
|
+
* Create one replyReceived Trigger that polls on its own. Prefer one MessageTriggerRunner per
|
|
420
|
+
* connection, which delivers every root before any reply.
|
|
421
|
+
*/
|
|
422
|
+
declare function newReplyReceivedTrigger(config: GmailMessageTriggerConfig<ReplyReceivedTriggerConfiguration>): TriggerRunner;
|
|
423
|
+
/** One root-message binding and its application target. */
|
|
424
|
+
interface MessageReceivedTriggerRoute {
|
|
425
|
+
/** Configured binding name. */ bindingName: string;
|
|
426
|
+
/** Search query and root-message matcher. */ configuration: MessageReceivedTriggerConfiguration;
|
|
427
|
+
/** Routes accepted events into the application. */ target: TriggerTarget<MessageEvent>;
|
|
428
|
+
}
|
|
429
|
+
/** One reply binding and its application target. */
|
|
430
|
+
interface ReplyReceivedTriggerRoute {
|
|
431
|
+
/** Configured binding name. */ bindingName: string;
|
|
432
|
+
/** Search query and reply matcher. */ configuration: ReplyReceivedTriggerConfiguration;
|
|
433
|
+
/** Routes accepted events into the application. */ target: TriggerTarget<MessageEvent>;
|
|
434
|
+
}
|
|
435
|
+
/** Gmail message Triggers that share one ordered poller. */
|
|
436
|
+
interface MessageTriggerRunnerConfig {
|
|
437
|
+
/** Gmail connection bound to a GmailClient. */ connection: GmailConnection;
|
|
438
|
+
/** Root-message bindings. */ messageReceivedRoutes?: readonly MessageReceivedTriggerRoute[];
|
|
439
|
+
/** Reply bindings. */ replyReceivedRoutes?: readonly ReplyReceivedTriggerRoute[];
|
|
440
|
+
}
|
|
441
|
+
/** One root-message binding saved in the project configuration and its application target. */
|
|
442
|
+
interface ProjectMessageReceivedTriggerRoute {
|
|
443
|
+
bindingName: string; /** Application target. */
|
|
444
|
+
target: TriggerTarget<MessageEvent>;
|
|
445
|
+
}
|
|
446
|
+
/** One reply binding saved in the project configuration and its application target. */
|
|
447
|
+
interface ProjectReplyReceivedTriggerRoute {
|
|
448
|
+
bindingName: string; /** Application target. */
|
|
449
|
+
target: TriggerTarget<MessageEvent>;
|
|
450
|
+
}
|
|
451
|
+
/** Gmail message Trigger bindings selected from the project configuration. */
|
|
452
|
+
interface ProjectMessageTriggerRunnerConfig {
|
|
453
|
+
/** Root-message bindings. */ messageReceivedRoutes?: readonly ProjectMessageReceivedTriggerRoute[];
|
|
454
|
+
/** Reply bindings. */ replyReceivedRoutes?: readonly ProjectReplyReceivedTriggerRoute[];
|
|
455
|
+
}
|
|
456
|
+
/** Polls every configured Gmail route of one connection and delivers root messages before replies. */
|
|
457
|
+
declare class MessageTriggerRunner {
|
|
458
|
+
#private;
|
|
459
|
+
/** @internal Use newMessageTriggerRunner or newProjectMessageTriggerRunner. */
|
|
460
|
+
constructor(rootRoutes: readonly MessageTriggerRoute[], replyRoutes: readonly MessageTriggerRoute[], pollIntervalMs: number);
|
|
461
|
+
/**
|
|
462
|
+
* Replay each route's durable inbox in order, roots first, then poll until the context ends. Each poll
|
|
463
|
+
* lists every reply route before any root route, then delivers every root before any reply, and ends
|
|
464
|
+
* at the first failure. Every later poll retries the failed event before that route's listed messages,
|
|
465
|
+
* even after Gmail stops listing it. Gmail receives a thread's root before any reply to it, so the
|
|
466
|
+
* root of every listed reply is in the later root listing and reaches Dex first.
|
|
467
|
+
*
|
|
468
|
+
* It logs through the client's logger: WARN "gmail poll failed; retrying" with the consecutive failed
|
|
469
|
+
* polls as attempt and the poll interval as delay_ms when a list or read fails, WARN "trigger delivery
|
|
470
|
+
* failed; retrying" with the attempt number when a target fails, INFO "trigger delivered after retry"
|
|
471
|
+
* when a later poll delivers that message, DEBUG "trigger event ignored" with its reason, and the
|
|
472
|
+
* durable inbox records. It rejects with TriggerDeliveryAbortedError once the context ends, and when
|
|
473
|
+
* an inbox replay fails.
|
|
474
|
+
*/
|
|
475
|
+
run(context: TriggerContext): Promise<void>;
|
|
476
|
+
}
|
|
477
|
+
/** Create one ordered runner for every configured Gmail message Trigger route of a connection; throws on invalid wiring. */
|
|
478
|
+
declare function newMessageTriggerRunner(config: MessageTriggerRunnerConfig): MessageTriggerRunner;
|
|
479
|
+
/**
|
|
480
|
+
* Open connectionName from the loaded project, load the selected bindings' saved configuration, and
|
|
481
|
+
* create one durable, ordered runner. Each route keeps acknowledged events in its binding's project
|
|
482
|
+
* Trigger inbox until its target consumes them, so a restarted or replaced replica replays them. A
|
|
483
|
+
* route whose binding is not configured throws. The options' logger also applies to those inboxes.
|
|
484
|
+
*/
|
|
485
|
+
declare function newProjectMessageTriggerRunner(project: LoadedProject, connectionName: string, config: ProjectMessageTriggerRunnerConfig, options?: GmailClientOptions): MessageTriggerRunner;
|
|
486
|
+
|
|
487
|
+
export { Config, CredentialSource, Credentials, GetMessageBranch, GetMessageDefinition, GetMessageInput, GetMessageOperation, type GetMessageStepConfig, GmailClient, type GmailClientOptions, type GmailClientSettings, GmailConnection, GmailCredentialError, GmailCredentialRefreshDriver, GmailHTTPClient, type GmailMessagePart, type GmailMessageReference, type GmailMessageResource, GmailMessageResourceSchema, type GmailMessageTriggerConfig, GmailOperations, GmailProvider, type GmailReadResult, type GmailTransport, type GmailTriggerBindingConfig, Message, type MessageEvent, MessageEventSchema, type MessageMatcher, MessageMatcherSchema, type MessageReceivedTriggerConfiguration, MessageReceivedTriggerConfigurationSchema, MessageReceivedTriggerDefinition, type MessageReceivedTriggerRoute, MessageTriggerRunner, type MessageTriggerRunnerConfig, type ProjectMessageReceivedTriggerRoute, type ProjectMessageTriggerRunnerConfig, type ProjectReplyReceivedTriggerRoute, type ReplyReceivedTriggerConfiguration, ReplyReceivedTriggerConfigurationSchema, ReplyReceivedTriggerDefinition, type ReplyReceivedTriggerRoute, ReplyToMessageBranch, ReplyToMessageDefinition, ReplyToMessageInput, ReplyToMessageOperation, type ReplyToMessageStepConfig, SendMessageBranch, SendMessageDefinition, SendMessageInput, SendMessageOperation, SendMessageOutput, type SendMessageStepConfig, type SentMessageIdentity, UIEmailListInputPortEmails, UISearchQueryInputPortQuery, UITextInputPortText, UIUnitEmailListInput, UIUnitSearchQueryInput, UIUnitTextInput, buildMIMEMessage, buildReplyMIMEMessage, decodeGmailMessage, defineMessageReceivedTriggerBinding, defineReplyReceivedTriggerBinding, emptyMessage, gmailClientSettings, gmailFailure, gmailRequestID, gmailRetryAfterMs, newGetMessageStep, newMessageReceivedTrigger, newMessageTriggerRunner, newProjectConnection, newProjectGmailClient, newProjectMessageTriggerRunner, newReplyReceivedTrigger, newReplyToMessageStep, newSendMessageStep, parseMailbox, parseSentResponse, receiptFor, replyRecipient, rfcMessageIDAddress, statusFailureKind, validateSendInput };
|