@agentuity/core 1.0.29 → 1.0.30
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/dist/services/email.d.ts +507 -8
- package/dist/services/email.d.ts.map +1 -1
- package/dist/services/email.js +325 -1
- package/dist/services/email.js.map +1 -1
- package/dist/services/keyvalue.d.ts +5 -2
- package/dist/services/keyvalue.d.ts.map +1 -1
- package/dist/services/keyvalue.js +44 -1
- package/dist/services/keyvalue.js.map +1 -1
- package/dist/services/schedule.d.ts +413 -0
- package/dist/services/schedule.d.ts.map +1 -1
- package/dist/services/schedule.js +221 -0
- package/dist/services/schedule.js.map +1 -1
- package/dist/services/task.d.ts +1005 -1
- package/dist/services/task.d.ts.map +1 -1
- package/dist/services/task.js +518 -1
- package/dist/services/task.js.map +1 -1
- package/dist/services/webhook.d.ts +352 -0
- package/dist/services/webhook.d.ts.map +1 -1
- package/dist/services/webhook.js +254 -0
- package/dist/services/webhook.js.map +1 -1
- package/package.json +2 -2
- package/src/services/email.ts +560 -9
- package/src/services/keyvalue.ts +51 -3
- package/src/services/schedule.ts +442 -0
- package/src/services/task.ts +1158 -13
- package/src/services/webhook.ts +412 -0
package/dist/services/email.d.ts
CHANGED
|
@@ -1,72 +1,238 @@
|
|
|
1
1
|
import { FetchAdapter } from './adapter.ts';
|
|
2
2
|
/**
|
|
3
|
-
* An email address registered with the Agentuity email service
|
|
3
|
+
* An email address registered with the Agentuity email service.
|
|
4
|
+
*
|
|
5
|
+
* Email addresses are created under the `@agentuity.email` domain and can receive
|
|
6
|
+
* inbound emails (forwarded to configured destinations) and send outbound emails.
|
|
4
7
|
*/
|
|
5
8
|
export interface EmailAddress {
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier for the email address.
|
|
11
|
+
*
|
|
12
|
+
* @remarks Prefixed with `eaddr_`.
|
|
13
|
+
*/
|
|
6
14
|
id: string;
|
|
15
|
+
/**
|
|
16
|
+
* The full email address (e.g., `support@agentuity.email`).
|
|
17
|
+
*/
|
|
7
18
|
email: string;
|
|
19
|
+
/**
|
|
20
|
+
* Provider-specific configuration (e.g., inbound routing config).
|
|
21
|
+
*
|
|
22
|
+
* @remarks Opaque to callers — the structure is managed by the platform.
|
|
23
|
+
*/
|
|
8
24
|
config?: Record<string, unknown>;
|
|
25
|
+
/**
|
|
26
|
+
* ID of the user who registered this address.
|
|
27
|
+
*/
|
|
9
28
|
created_by?: string;
|
|
29
|
+
/**
|
|
30
|
+
* ISO 8601 timestamp when the address was created.
|
|
31
|
+
*/
|
|
10
32
|
created_at: string;
|
|
33
|
+
/**
|
|
34
|
+
* ISO 8601 timestamp when the address was last updated.
|
|
35
|
+
*/
|
|
11
36
|
updated_at?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Total number of inbound emails received at this address.
|
|
39
|
+
*/
|
|
12
40
|
inbound_count?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Total number of outbound emails sent from this address.
|
|
43
|
+
*/
|
|
13
44
|
outbound_count?: number;
|
|
45
|
+
/**
|
|
46
|
+
* ISO 8601 timestamp of the most recent inbound or outbound email activity.
|
|
47
|
+
*/
|
|
14
48
|
last_activity?: string;
|
|
15
49
|
}
|
|
16
50
|
/**
|
|
17
|
-
* A destination configuration for an email address
|
|
51
|
+
* A destination configuration for an email address.
|
|
52
|
+
*
|
|
53
|
+
* When an inbound email is received at the parent address, the platform forwards
|
|
54
|
+
* it to each configured destination via an HTTP request.
|
|
18
55
|
*/
|
|
19
56
|
export interface EmailDestination {
|
|
57
|
+
/**
|
|
58
|
+
* Unique identifier for the destination.
|
|
59
|
+
*
|
|
60
|
+
* @remarks Prefixed with `edst_`.
|
|
61
|
+
*/
|
|
20
62
|
id: string;
|
|
63
|
+
/**
|
|
64
|
+
* The destination type. Currently only `'url'` is supported.
|
|
65
|
+
*/
|
|
21
66
|
type: string;
|
|
67
|
+
/**
|
|
68
|
+
* Destination-specific configuration.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* For `'url'` type the shape is:
|
|
72
|
+
* ```typescript
|
|
73
|
+
* {
|
|
74
|
+
* url: string; // Must use http or https; must not point to private/loopback addresses
|
|
75
|
+
* headers?: Record<string, string>;
|
|
76
|
+
* method?: 'POST' | 'PUT' | 'PATCH';
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
22
80
|
config?: Record<string, unknown>;
|
|
81
|
+
/**
|
|
82
|
+
* ISO 8601 timestamp when the destination was created.
|
|
83
|
+
*/
|
|
23
84
|
created_at: string;
|
|
85
|
+
/**
|
|
86
|
+
* ISO 8601 timestamp when the destination was last updated.
|
|
87
|
+
*/
|
|
24
88
|
updated_at?: string;
|
|
25
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Connection settings for an email protocol (IMAP or POP3).
|
|
92
|
+
*
|
|
93
|
+
* Used to configure a mail client for accessing an Agentuity email address
|
|
94
|
+
* via standard mail protocols.
|
|
95
|
+
*/
|
|
26
96
|
export interface EmailProtocolConfig {
|
|
97
|
+
/**
|
|
98
|
+
* The mail server hostname.
|
|
99
|
+
*/
|
|
27
100
|
host: string;
|
|
101
|
+
/**
|
|
102
|
+
* The mail server port number.
|
|
103
|
+
*/
|
|
28
104
|
port: number;
|
|
105
|
+
/**
|
|
106
|
+
* TLS mode (e.g., `'starttls'`, `'ssl'`, `'none'`).
|
|
107
|
+
*/
|
|
29
108
|
tls: string;
|
|
109
|
+
/**
|
|
110
|
+
* The authentication username (typically the address ID).
|
|
111
|
+
*/
|
|
30
112
|
username: string;
|
|
113
|
+
/**
|
|
114
|
+
* The authentication password.
|
|
115
|
+
*/
|
|
31
116
|
password: string;
|
|
32
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Full connection configuration for accessing an email address via IMAP and POP3 protocols.
|
|
120
|
+
*
|
|
121
|
+
* Returned by {@link EmailService.getConnectionConfig} to allow external mail clients
|
|
122
|
+
* to connect to an Agentuity email address.
|
|
123
|
+
*/
|
|
33
124
|
export interface EmailConnectionConfig {
|
|
125
|
+
/**
|
|
126
|
+
* The full email address these settings are for.
|
|
127
|
+
*/
|
|
34
128
|
email: string;
|
|
129
|
+
/**
|
|
130
|
+
* IMAP protocol connection settings.
|
|
131
|
+
*/
|
|
35
132
|
imap: EmailProtocolConfig;
|
|
133
|
+
/**
|
|
134
|
+
* POP3 protocol connection settings.
|
|
135
|
+
*/
|
|
36
136
|
pop3: EmailProtocolConfig;
|
|
37
137
|
}
|
|
38
138
|
/**
|
|
39
|
-
* An inbound email message
|
|
139
|
+
* An inbound email message received at an Agentuity email address.
|
|
40
140
|
*/
|
|
41
141
|
export interface EmailInbound {
|
|
142
|
+
/**
|
|
143
|
+
* Unique identifier for the inbound email.
|
|
144
|
+
*
|
|
145
|
+
* @remarks Prefixed with `einb_`.
|
|
146
|
+
*/
|
|
42
147
|
id: string;
|
|
148
|
+
/**
|
|
149
|
+
* The sender's email address.
|
|
150
|
+
*/
|
|
43
151
|
from: string;
|
|
152
|
+
/**
|
|
153
|
+
* The recipient email address (comma-separated if multiple).
|
|
154
|
+
*/
|
|
44
155
|
to: string;
|
|
156
|
+
/**
|
|
157
|
+
* The email subject line.
|
|
158
|
+
*/
|
|
45
159
|
subject?: string;
|
|
160
|
+
/**
|
|
161
|
+
* Plain text body of the email.
|
|
162
|
+
*/
|
|
46
163
|
text?: string;
|
|
164
|
+
/**
|
|
165
|
+
* HTML body of the email.
|
|
166
|
+
*/
|
|
47
167
|
html?: string;
|
|
168
|
+
/**
|
|
169
|
+
* ISO 8601 timestamp when the email was received.
|
|
170
|
+
*/
|
|
48
171
|
received_at?: string;
|
|
172
|
+
/**
|
|
173
|
+
* Raw email headers as key-value pairs.
|
|
174
|
+
*/
|
|
49
175
|
headers?: Record<string, unknown>;
|
|
176
|
+
/**
|
|
177
|
+
* Array of stored attachment metadata with S3 locations.
|
|
178
|
+
*/
|
|
50
179
|
attachments?: EmailStoredAttachment[];
|
|
51
180
|
}
|
|
52
181
|
/**
|
|
53
|
-
* An outbound email message
|
|
182
|
+
* An outbound email message sent from an Agentuity email address.
|
|
54
183
|
*/
|
|
55
184
|
export interface EmailOutbound {
|
|
185
|
+
/**
|
|
186
|
+
* Unique identifier for the outbound email.
|
|
187
|
+
*
|
|
188
|
+
* @remarks Prefixed with `eout_`.
|
|
189
|
+
*/
|
|
56
190
|
id: string;
|
|
191
|
+
/**
|
|
192
|
+
* The sender's email address (must be owned by the organization).
|
|
193
|
+
*/
|
|
57
194
|
from: string;
|
|
195
|
+
/**
|
|
196
|
+
* The recipient email addresses (comma-separated).
|
|
197
|
+
*/
|
|
58
198
|
to: string;
|
|
199
|
+
/**
|
|
200
|
+
* The email subject line.
|
|
201
|
+
*/
|
|
59
202
|
subject?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Plain text body of the email.
|
|
205
|
+
*/
|
|
60
206
|
text?: string;
|
|
207
|
+
/**
|
|
208
|
+
* HTML body of the email.
|
|
209
|
+
*/
|
|
61
210
|
html?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Delivery status: `'pending'`, `'success'`, or `'failed'`.
|
|
213
|
+
*
|
|
214
|
+
* @remarks Emails are sent asynchronously, so the initial status is always `'pending'`.
|
|
215
|
+
*/
|
|
62
216
|
status?: string;
|
|
217
|
+
/**
|
|
218
|
+
* Error message if the delivery failed.
|
|
219
|
+
*/
|
|
63
220
|
error?: string;
|
|
221
|
+
/**
|
|
222
|
+
* ISO 8601 timestamp when the send was initiated.
|
|
223
|
+
*/
|
|
64
224
|
created_at?: string;
|
|
225
|
+
/**
|
|
226
|
+
* Custom email headers that were included.
|
|
227
|
+
*/
|
|
65
228
|
headers?: Record<string, unknown>;
|
|
229
|
+
/**
|
|
230
|
+
* Array of stored attachment metadata with S3 locations.
|
|
231
|
+
*/
|
|
66
232
|
attachments?: EmailStoredAttachment[];
|
|
67
233
|
}
|
|
68
234
|
/**
|
|
69
|
-
* An email attachment
|
|
235
|
+
* An email attachment to include when sending an outbound email.
|
|
70
236
|
*/
|
|
71
237
|
export interface EmailAttachment {
|
|
72
238
|
/**
|
|
@@ -134,24 +300,46 @@ export interface EmailSendParams {
|
|
|
134
300
|
headers?: Record<string, string>;
|
|
135
301
|
}
|
|
136
302
|
/**
|
|
137
|
-
* Parameters for email activity time-series
|
|
303
|
+
* Parameters for querying email activity time-series data.
|
|
138
304
|
*/
|
|
139
305
|
export interface EmailActivityParams {
|
|
306
|
+
/**
|
|
307
|
+
* Number of days of activity to retrieve.
|
|
308
|
+
*
|
|
309
|
+
* @remarks Values below 7 are clamped to 7; values above 365 are clamped to 365.
|
|
310
|
+
*
|
|
311
|
+
* @default 7
|
|
312
|
+
*/
|
|
140
313
|
days?: number;
|
|
141
314
|
}
|
|
142
315
|
/**
|
|
143
|
-
* A single data point in the email activity time-series
|
|
316
|
+
* A single data point in the email activity time-series.
|
|
144
317
|
*/
|
|
145
318
|
export interface EmailActivityDataPoint {
|
|
319
|
+
/**
|
|
320
|
+
* The date in `YYYY-MM-DD` format.
|
|
321
|
+
*/
|
|
146
322
|
date: string;
|
|
323
|
+
/**
|
|
324
|
+
* Number of inbound emails received on this date.
|
|
325
|
+
*/
|
|
147
326
|
inbound: number;
|
|
327
|
+
/**
|
|
328
|
+
* Number of outbound emails sent on this date.
|
|
329
|
+
*/
|
|
148
330
|
outbound: number;
|
|
149
331
|
}
|
|
150
332
|
/**
|
|
151
|
-
* Result of email activity query
|
|
333
|
+
* Result of an email activity query containing daily time-series data.
|
|
152
334
|
*/
|
|
153
335
|
export interface EmailActivityResult {
|
|
336
|
+
/**
|
|
337
|
+
* Array of daily activity data points, ordered chronologically.
|
|
338
|
+
*/
|
|
154
339
|
activity: EmailActivityDataPoint[];
|
|
340
|
+
/**
|
|
341
|
+
* The number of days of data returned.
|
|
342
|
+
*/
|
|
155
343
|
days: number;
|
|
156
344
|
}
|
|
157
345
|
/**
|
|
@@ -379,24 +567,335 @@ export interface EmailService {
|
|
|
379
567
|
*/
|
|
380
568
|
getActivity(params?: EmailActivityParams): Promise<EmailActivityResult>;
|
|
381
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
* Client for the Agentuity Email service.
|
|
572
|
+
*
|
|
573
|
+
* Provides methods for managing email addresses, configuring inbound email
|
|
574
|
+
* destinations, sending outbound emails, and querying email history.
|
|
575
|
+
*
|
|
576
|
+
* Email addresses are created under the `@agentuity.email` domain. Inbound emails
|
|
577
|
+
* can be forwarded to URL destinations. Outbound emails are sent asynchronously
|
|
578
|
+
* and support attachments up to 25 MB total.
|
|
579
|
+
*
|
|
580
|
+
* All methods are instrumented with OpenTelemetry spans for observability.
|
|
581
|
+
*
|
|
582
|
+
* @example
|
|
583
|
+
* ```typescript
|
|
584
|
+
* const email = new EmailStorageService(baseUrl, adapter);
|
|
585
|
+
*
|
|
586
|
+
* // Create an address
|
|
587
|
+
* const addr = await email.createAddress('notifications');
|
|
588
|
+
*
|
|
589
|
+
* // Send an email
|
|
590
|
+
* await email.send({
|
|
591
|
+
* from: addr.email,
|
|
592
|
+
* to: ['user@example.com'],
|
|
593
|
+
* subject: 'Hello',
|
|
594
|
+
* text: 'Hello from Agentuity!',
|
|
595
|
+
* });
|
|
596
|
+
* ```
|
|
597
|
+
*/
|
|
382
598
|
export declare class EmailStorageService implements EmailService {
|
|
383
599
|
#private;
|
|
600
|
+
/**
|
|
601
|
+
* Create a new EmailStorageService instance.
|
|
602
|
+
*
|
|
603
|
+
* @param baseUrl - The base URL for the Agentuity Email API (e.g., `https://api.agentuity.com`)
|
|
604
|
+
* @param adapter - The HTTP fetch adapter used for making API requests
|
|
605
|
+
*/
|
|
384
606
|
constructor(baseUrl: string, adapter: FetchAdapter);
|
|
607
|
+
/**
|
|
608
|
+
* Create a new email address under the `@agentuity.email` domain.
|
|
609
|
+
*
|
|
610
|
+
* @param localPart - The local part of the email address (the part before the `@`).
|
|
611
|
+
* For example, passing `'support'` creates `support@agentuity.email`.
|
|
612
|
+
* @returns The newly created email address record
|
|
613
|
+
* @throws ServiceException on API errors (e.g., duplicate address, invalid local part)
|
|
614
|
+
*
|
|
615
|
+
* @example
|
|
616
|
+
* ```typescript
|
|
617
|
+
* const addr = await email.createAddress('support');
|
|
618
|
+
* console.log('Created:', addr.email); // support@agentuity.email
|
|
619
|
+
* ```
|
|
620
|
+
*/
|
|
385
621
|
createAddress(localPart: string): Promise<EmailAddress>;
|
|
622
|
+
/**
|
|
623
|
+
* List all email addresses owned by the current organization.
|
|
624
|
+
*
|
|
625
|
+
* @returns An array of email address records. Returns an empty array if none exist.
|
|
626
|
+
* @throws ServiceException on API errors
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* const addresses = await email.listAddresses();
|
|
631
|
+
* for (const addr of addresses) {
|
|
632
|
+
* console.log(`${addr.email} — ${addr.inbound_count ?? 0} received`);
|
|
633
|
+
* }
|
|
634
|
+
* ```
|
|
635
|
+
*/
|
|
386
636
|
listAddresses(): Promise<EmailAddress[]>;
|
|
637
|
+
/**
|
|
638
|
+
* Get an email address by its ID.
|
|
639
|
+
*
|
|
640
|
+
* @param id - The email address ID (prefixed with `eaddr_`)
|
|
641
|
+
* @returns The email address record, or `null` if no address with the given ID exists
|
|
642
|
+
* @throws ServiceException on API errors (other than 404)
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```typescript
|
|
646
|
+
* const addr = await email.getAddress('eaddr_abc123');
|
|
647
|
+
* if (addr) {
|
|
648
|
+
* console.log('Found:', addr.email);
|
|
649
|
+
* }
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
387
652
|
getAddress(id: string): Promise<EmailAddress | null>;
|
|
653
|
+
/**
|
|
654
|
+
* Get IMAP and POP3 connection settings for an email address.
|
|
655
|
+
*
|
|
656
|
+
* These settings can be used to configure an external mail client (e.g., Thunderbird, Outlook)
|
|
657
|
+
* to access the mailbox associated with the given address.
|
|
658
|
+
*
|
|
659
|
+
* @param id - The email address ID (prefixed with `eaddr_`)
|
|
660
|
+
* @returns The connection configuration with IMAP and POP3 settings, or `null` if the address is not found
|
|
661
|
+
* @throws ServiceException on API errors (other than 404)
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* const config = await email.getConnectionConfig('eaddr_abc123');
|
|
666
|
+
* if (config) {
|
|
667
|
+
* console.log('IMAP host:', config.imap.host);
|
|
668
|
+
* console.log('POP3 host:', config.pop3.host);
|
|
669
|
+
* }
|
|
670
|
+
* ```
|
|
671
|
+
*/
|
|
388
672
|
getConnectionConfig(id: string): Promise<EmailConnectionConfig | null>;
|
|
673
|
+
/**
|
|
674
|
+
* Delete an email address and all associated destinations.
|
|
675
|
+
*
|
|
676
|
+
* @remarks This operation is idempotent — deleting a non-existent address does not throw.
|
|
677
|
+
*
|
|
678
|
+
* @param id - The email address ID (prefixed with `eaddr_`)
|
|
679
|
+
* @throws ServiceException on API errors (other than 404)
|
|
680
|
+
*
|
|
681
|
+
* @example
|
|
682
|
+
* ```typescript
|
|
683
|
+
* await email.deleteAddress('eaddr_abc123');
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
389
686
|
deleteAddress(id: string): Promise<void>;
|
|
687
|
+
/**
|
|
688
|
+
* Create a new destination for an email address.
|
|
689
|
+
*
|
|
690
|
+
* Destinations determine where inbound emails are forwarded when they arrive
|
|
691
|
+
* at the parent address.
|
|
692
|
+
*
|
|
693
|
+
* @param addressId - The email address ID (prefixed with `eaddr_`)
|
|
694
|
+
* @param type - The destination type (currently only `'url'` is supported)
|
|
695
|
+
* @param config - Type-specific destination configuration. For `'url'`:
|
|
696
|
+
* `{ url: string, headers?: Record<string, string>, method?: 'POST' | 'PUT' | 'PATCH' }`
|
|
697
|
+
* @returns The newly created destination record
|
|
698
|
+
* @throws ServiceException on API errors (e.g., invalid URL, address not found)
|
|
699
|
+
*
|
|
700
|
+
* @example
|
|
701
|
+
* ```typescript
|
|
702
|
+
* const dest = await email.createDestination('eaddr_abc123', 'url', {
|
|
703
|
+
* url: 'https://example.com/webhook',
|
|
704
|
+
* headers: { 'X-Secret': 'my-token' },
|
|
705
|
+
* });
|
|
706
|
+
* console.log('Destination created:', dest.id);
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
390
709
|
createDestination(addressId: string, type: string, config: Record<string, unknown>): Promise<EmailDestination>;
|
|
710
|
+
/**
|
|
711
|
+
* List all destinations configured for an email address.
|
|
712
|
+
*
|
|
713
|
+
* @param addressId - The email address ID (prefixed with `eaddr_`)
|
|
714
|
+
* @returns An array of destination records. Returns an empty array if none exist.
|
|
715
|
+
* @throws ServiceException on API errors
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```typescript
|
|
719
|
+
* const destinations = await email.listDestinations('eaddr_abc123');
|
|
720
|
+
* for (const dest of destinations) {
|
|
721
|
+
* console.log(`${dest.type}: ${dest.id}`);
|
|
722
|
+
* }
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
391
725
|
listDestinations(addressId: string): Promise<EmailDestination[]>;
|
|
726
|
+
/**
|
|
727
|
+
* Delete a destination from an email address.
|
|
728
|
+
*
|
|
729
|
+
* @remarks This operation is idempotent — deleting a non-existent destination does not throw.
|
|
730
|
+
*
|
|
731
|
+
* @param addressId - The email address ID (prefixed with `eaddr_`)
|
|
732
|
+
* @param destinationId - The destination ID (prefixed with `edst_`)
|
|
733
|
+
* @throws ServiceException on API errors (other than 404)
|
|
734
|
+
*
|
|
735
|
+
* @example
|
|
736
|
+
* ```typescript
|
|
737
|
+
* await email.deleteDestination('eaddr_abc123', 'edst_xyz789');
|
|
738
|
+
* ```
|
|
739
|
+
*/
|
|
392
740
|
deleteDestination(addressId: string, destinationId: string): Promise<void>;
|
|
741
|
+
/**
|
|
742
|
+
* Send an outbound email from an Agentuity email address.
|
|
743
|
+
*
|
|
744
|
+
* Emails are sent asynchronously — this method returns immediately with an outbound
|
|
745
|
+
* record whose status is `'pending'`. Use {@link getOutbound} to poll for delivery status.
|
|
746
|
+
*
|
|
747
|
+
* @remarks
|
|
748
|
+
* - The `from` address must be owned by the current organization.
|
|
749
|
+
* - Maximum 50 recipients per send.
|
|
750
|
+
* - Maximum 25 MB for the full RFC 822 body (including attachments).
|
|
751
|
+
*
|
|
752
|
+
* @param params - The email send parameters including from, to, subject, and body
|
|
753
|
+
* @returns The outbound email record with initial status `'pending'`
|
|
754
|
+
* @throws ServiceException on API errors (e.g., invalid sender, too many recipients)
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* ```typescript
|
|
758
|
+
* const result = await email.send({
|
|
759
|
+
* from: 'notifications@agentuity.email',
|
|
760
|
+
* to: ['user@example.com'],
|
|
761
|
+
* subject: 'Welcome!',
|
|
762
|
+
* text: 'Welcome to our platform.',
|
|
763
|
+
* html: '<h1>Welcome!</h1>',
|
|
764
|
+
* attachments: [{
|
|
765
|
+
* filename: 'guide.pdf',
|
|
766
|
+
* content: base64EncodedPdf,
|
|
767
|
+
* contentType: 'application/pdf',
|
|
768
|
+
* }],
|
|
769
|
+
* });
|
|
770
|
+
* console.log('Email queued:', result.id);
|
|
771
|
+
* ```
|
|
772
|
+
*/
|
|
393
773
|
send(params: EmailSendParams): Promise<EmailOutbound>;
|
|
774
|
+
/**
|
|
775
|
+
* List inbound emails, optionally filtered by email address.
|
|
776
|
+
*
|
|
777
|
+
* @param addressId - Optional email address ID (prefixed with `eaddr_`) to filter results.
|
|
778
|
+
* When omitted, returns inbound emails across all addresses in the organization.
|
|
779
|
+
* @returns An array of inbound email records. Returns an empty array if none exist.
|
|
780
|
+
* @throws ServiceException on API errors
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* ```typescript
|
|
784
|
+
* // List all inbound emails
|
|
785
|
+
* const all = await email.listInbound();
|
|
786
|
+
*
|
|
787
|
+
* // List inbound for a specific address
|
|
788
|
+
* const filtered = await email.listInbound('eaddr_abc123');
|
|
789
|
+
* for (const msg of filtered) {
|
|
790
|
+
* console.log(`From: ${msg.from}, Subject: ${msg.subject}`);
|
|
791
|
+
* }
|
|
792
|
+
* ```
|
|
793
|
+
*/
|
|
394
794
|
listInbound(addressId?: string): Promise<EmailInbound[]>;
|
|
795
|
+
/**
|
|
796
|
+
* Get an inbound email by its ID.
|
|
797
|
+
*
|
|
798
|
+
* @param id - The inbound email ID (prefixed with `einb_`)
|
|
799
|
+
* @returns The inbound email record, or `null` if not found
|
|
800
|
+
* @throws ServiceException on API errors (other than 404)
|
|
801
|
+
*
|
|
802
|
+
* @example
|
|
803
|
+
* ```typescript
|
|
804
|
+
* const msg = await email.getInbound('einb_abc123');
|
|
805
|
+
* if (msg) {
|
|
806
|
+
* console.log('Subject:', msg.subject);
|
|
807
|
+
* console.log('Attachments:', msg.attachments?.length ?? 0);
|
|
808
|
+
* }
|
|
809
|
+
* ```
|
|
810
|
+
*/
|
|
395
811
|
getInbound(id: string): Promise<EmailInbound | null>;
|
|
812
|
+
/**
|
|
813
|
+
* Delete an inbound email by its ID.
|
|
814
|
+
*
|
|
815
|
+
* @remarks This operation is idempotent — deleting a non-existent email does not throw.
|
|
816
|
+
*
|
|
817
|
+
* @param id - The inbound email ID (prefixed with `einb_`)
|
|
818
|
+
* @throws ServiceException on API errors (other than 404)
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```typescript
|
|
822
|
+
* await email.deleteInbound('einb_abc123');
|
|
823
|
+
* ```
|
|
824
|
+
*/
|
|
396
825
|
deleteInbound(id: string): Promise<void>;
|
|
826
|
+
/**
|
|
827
|
+
* List outbound emails, optionally filtered by email address.
|
|
828
|
+
*
|
|
829
|
+
* @param addressId - Optional email address ID (prefixed with `eaddr_`) to filter results.
|
|
830
|
+
* When omitted, returns outbound emails across all addresses in the organization.
|
|
831
|
+
* @returns An array of outbound email records. Returns an empty array if none exist.
|
|
832
|
+
* @throws ServiceException on API errors
|
|
833
|
+
*
|
|
834
|
+
* @example
|
|
835
|
+
* ```typescript
|
|
836
|
+
* // List all outbound emails
|
|
837
|
+
* const all = await email.listOutbound();
|
|
838
|
+
*
|
|
839
|
+
* // List outbound for a specific address
|
|
840
|
+
* const filtered = await email.listOutbound('eaddr_abc123');
|
|
841
|
+
* for (const msg of filtered) {
|
|
842
|
+
* console.log(`To: ${msg.to}, Status: ${msg.status}`);
|
|
843
|
+
* }
|
|
844
|
+
* ```
|
|
845
|
+
*/
|
|
397
846
|
listOutbound(addressId?: string): Promise<EmailOutbound[]>;
|
|
847
|
+
/**
|
|
848
|
+
* Get an outbound email by its ID.
|
|
849
|
+
*
|
|
850
|
+
* @param id - The outbound email ID (prefixed with `eout_`)
|
|
851
|
+
* @returns The outbound email record, or `null` if not found
|
|
852
|
+
* @throws ServiceException on API errors (other than 404)
|
|
853
|
+
*
|
|
854
|
+
* @example
|
|
855
|
+
* ```typescript
|
|
856
|
+
* const msg = await email.getOutbound('eout_abc123');
|
|
857
|
+
* if (msg) {
|
|
858
|
+
* console.log('Status:', msg.status);
|
|
859
|
+
* if (msg.error) {
|
|
860
|
+
* console.error('Delivery failed:', msg.error);
|
|
861
|
+
* }
|
|
862
|
+
* }
|
|
863
|
+
* ```
|
|
864
|
+
*/
|
|
398
865
|
getOutbound(id: string): Promise<EmailOutbound | null>;
|
|
866
|
+
/**
|
|
867
|
+
* Delete an outbound email by its ID.
|
|
868
|
+
*
|
|
869
|
+
* @remarks This operation is idempotent — deleting a non-existent email does not throw.
|
|
870
|
+
*
|
|
871
|
+
* @param id - The outbound email ID (prefixed with `eout_`)
|
|
872
|
+
* @throws ServiceException on API errors (other than 404)
|
|
873
|
+
*
|
|
874
|
+
* @example
|
|
875
|
+
* ```typescript
|
|
876
|
+
* await email.deleteOutbound('eout_abc123');
|
|
877
|
+
* ```
|
|
878
|
+
*/
|
|
399
879
|
deleteOutbound(id: string): Promise<void>;
|
|
880
|
+
/**
|
|
881
|
+
* Get email activity time-series data showing inbound and outbound counts per day.
|
|
882
|
+
*
|
|
883
|
+
* @param params - Optional query parameters. `days` controls the lookback window
|
|
884
|
+
* (minimum 7, maximum 365, server default 7).
|
|
885
|
+
* @returns An {@link EmailActivityResult} with daily data points ordered chronologically
|
|
886
|
+
* and the total number of days returned
|
|
887
|
+
* @throws ServiceException on API errors
|
|
888
|
+
*
|
|
889
|
+
* @example
|
|
890
|
+
* ```typescript
|
|
891
|
+
* // Get last 30 days of activity
|
|
892
|
+
* const result = await email.getActivity({ days: 30 });
|
|
893
|
+
* console.log(`Activity over ${result.days} days:`);
|
|
894
|
+
* for (const point of result.activity) {
|
|
895
|
+
* console.log(` ${point.date}: ${point.inbound} in, ${point.outbound} out`);
|
|
896
|
+
* }
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
400
899
|
getActivity(params?: EmailActivityParams): Promise<EmailActivityResult>;
|
|
401
900
|
}
|
|
402
901
|
//# sourceMappingURL=email.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/services/email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C
|
|
1
|
+
{"version":3,"file":"email.d.ts","sourceRoot":"","sources":["../../src/services/email.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC5B;;;;OAIG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEjC;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACv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