@upyo/plunk 0.3.0-dev.35
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/LICENSE +20 -0
- package/README.md +93 -0
- package/dist/index.cjs +434 -0
- package/dist/index.d.cts +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.js +433 -0
- package/package.json +70 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { Message, Receipt, Transport, TransportOptions } from "@upyo/core";
|
|
2
|
+
|
|
3
|
+
//#region src/config.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration interface for Plunk transport connection settings.
|
|
7
|
+
*
|
|
8
|
+
* This interface defines all available options for configuring a Plunk
|
|
9
|
+
* API connection including authentication, HTTP options, and base URL for
|
|
10
|
+
* self-hosted instances.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const config: PlunkConfig = {
|
|
15
|
+
* apiKey: 'your-api-key',
|
|
16
|
+
* baseUrl: 'https://api.useplunk.com', // or self-hosted URL
|
|
17
|
+
* timeout: 30000,
|
|
18
|
+
* retries: 3
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
interface PlunkConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Your Plunk API key.
|
|
25
|
+
*
|
|
26
|
+
* You can find your API key in your Plunk dashboard under Settings > API Keys.
|
|
27
|
+
* The key will be used as a Bearer token for authentication.
|
|
28
|
+
*/
|
|
29
|
+
readonly apiKey: string;
|
|
30
|
+
/**
|
|
31
|
+
* Base URL for the Plunk API.
|
|
32
|
+
*
|
|
33
|
+
* For Plunk's hosted service, use "https://api.useplunk.com" (default).
|
|
34
|
+
* For self-hosted instances, use your domain with "/api" path
|
|
35
|
+
* (e.g., "https://plunk.example.com/api").
|
|
36
|
+
*
|
|
37
|
+
* @default "https://api.useplunk.com"
|
|
38
|
+
*/
|
|
39
|
+
readonly baseUrl?: string;
|
|
40
|
+
/**
|
|
41
|
+
* HTTP request timeout in milliseconds.
|
|
42
|
+
*
|
|
43
|
+
* @default 30000
|
|
44
|
+
*/
|
|
45
|
+
readonly timeout?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Number of retry attempts for failed requests.
|
|
48
|
+
*
|
|
49
|
+
* @default 3
|
|
50
|
+
*/
|
|
51
|
+
readonly retries?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to validate SSL certificates.
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
readonly validateSsl?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Additional HTTP headers to include with requests.
|
|
60
|
+
*/
|
|
61
|
+
readonly headers?: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolved Plunk configuration with all optional fields filled with default values.
|
|
65
|
+
*
|
|
66
|
+
* This type represents the final configuration after applying defaults,
|
|
67
|
+
* used internally by the Plunk transport implementation.
|
|
68
|
+
*/
|
|
69
|
+
type ResolvedPlunkConfig = Required<PlunkConfig>;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a resolved Plunk configuration by applying default values to optional fields.
|
|
72
|
+
*
|
|
73
|
+
* This function takes a partial Plunk configuration and returns a complete
|
|
74
|
+
* configuration with all optional fields filled with sensible defaults.
|
|
75
|
+
* It is used internally by the Plunk transport.
|
|
76
|
+
*
|
|
77
|
+
* @param config - The Plunk configuration with optional fields
|
|
78
|
+
* @returns A resolved configuration with all defaults applied
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/plunk-transport.d.ts
|
|
83
|
+
/**
|
|
84
|
+
* Plunk transport implementation for sending emails via Plunk API.
|
|
85
|
+
*
|
|
86
|
+
* This transport provides efficient email delivery using Plunk's HTTP API,
|
|
87
|
+
* with support for both cloud-hosted and self-hosted instances, authentication,
|
|
88
|
+
* retry logic, and batch sending capabilities.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* import { PlunkTransport } from '@upyo/plunk';
|
|
93
|
+
*
|
|
94
|
+
* const transport = new PlunkTransport({
|
|
95
|
+
* apiKey: 'your-plunk-api-key',
|
|
96
|
+
* baseUrl: 'https://api.useplunk.com', // or self-hosted URL
|
|
97
|
+
* timeout: 30000,
|
|
98
|
+
* retries: 3
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* const receipt = await transport.send(message);
|
|
102
|
+
* if (receipt.successful) {
|
|
103
|
+
* console.log('Message sent with ID:', receipt.messageId);
|
|
104
|
+
* } else {
|
|
105
|
+
* console.error('Send failed:', receipt.errorMessages.join(', '));
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
declare class PlunkTransport implements Transport {
|
|
110
|
+
/**
|
|
111
|
+
* The resolved Plunk configuration used by this transport.
|
|
112
|
+
*/
|
|
113
|
+
config: ResolvedPlunkConfig;
|
|
114
|
+
private httpClient;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a new Plunk transport instance.
|
|
117
|
+
*
|
|
118
|
+
* @param config Plunk configuration including API key and options.
|
|
119
|
+
*/
|
|
120
|
+
constructor(config: PlunkConfig);
|
|
121
|
+
/**
|
|
122
|
+
* Sends a single email message via Plunk API.
|
|
123
|
+
*
|
|
124
|
+
* This method converts the message to Plunk format, makes an HTTP request
|
|
125
|
+
* to the Plunk API, and returns a receipt with the result.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const receipt = await transport.send({
|
|
130
|
+
* sender: { address: 'from@example.com' },
|
|
131
|
+
* recipients: [{ address: 'to@example.com' }],
|
|
132
|
+
* ccRecipients: [],
|
|
133
|
+
* bccRecipients: [],
|
|
134
|
+
* replyRecipients: [],
|
|
135
|
+
* subject: 'Hello',
|
|
136
|
+
* content: { text: 'Hello World!' },
|
|
137
|
+
* attachments: [],
|
|
138
|
+
* priority: 'normal',
|
|
139
|
+
* tags: [],
|
|
140
|
+
* headers: new Headers()
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* if (receipt.successful) {
|
|
144
|
+
* console.log('Message sent successfully');
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @param message The email message to send.
|
|
149
|
+
* @param options Optional transport options including `AbortSignal` for
|
|
150
|
+
* cancellation.
|
|
151
|
+
* @returns A promise that resolves to a receipt indicating success or
|
|
152
|
+
* failure.
|
|
153
|
+
*/
|
|
154
|
+
send(message: Message, options?: TransportOptions): Promise<Receipt>;
|
|
155
|
+
/**
|
|
156
|
+
* Sends multiple email messages efficiently via Plunk API.
|
|
157
|
+
*
|
|
158
|
+
* This method sends each message individually but provides a streamlined
|
|
159
|
+
* interface for processing multiple messages. Each message is sent as a
|
|
160
|
+
* separate API request to Plunk.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const messages = [
|
|
165
|
+
* {
|
|
166
|
+
* sender: { address: 'from@example.com' },
|
|
167
|
+
* recipients: [{ address: 'user1@example.com' }],
|
|
168
|
+
* ccRecipients: [],
|
|
169
|
+
* bccRecipients: [],
|
|
170
|
+
* replyRecipients: [],
|
|
171
|
+
* subject: 'Message 1',
|
|
172
|
+
* content: { text: 'Hello User 1!' },
|
|
173
|
+
* attachments: [],
|
|
174
|
+
* priority: 'normal',
|
|
175
|
+
* tags: [],
|
|
176
|
+
* headers: new Headers()
|
|
177
|
+
* },
|
|
178
|
+
* {
|
|
179
|
+
* sender: { address: 'from@example.com' },
|
|
180
|
+
* recipients: [{ address: 'user2@example.com' }],
|
|
181
|
+
* ccRecipients: [],
|
|
182
|
+
* bccRecipients: [],
|
|
183
|
+
* replyRecipients: [],
|
|
184
|
+
* subject: 'Message 2',
|
|
185
|
+
* content: { text: 'Hello User 2!' },
|
|
186
|
+
* attachments: [],
|
|
187
|
+
* priority: 'normal',
|
|
188
|
+
* tags: [],
|
|
189
|
+
* headers: new Headers()
|
|
190
|
+
* }
|
|
191
|
+
* ];
|
|
192
|
+
*
|
|
193
|
+
* for await (const receipt of transport.sendMany(messages)) {
|
|
194
|
+
* if (receipt.successful) {
|
|
195
|
+
* console.log('Sent:', receipt.messageId);
|
|
196
|
+
* } else {
|
|
197
|
+
* console.error('Failed:', receipt.errorMessages);
|
|
198
|
+
* }
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @param messages An iterable or async iterable of messages to send.
|
|
203
|
+
* @param options Optional transport options including `AbortSignal` for
|
|
204
|
+
* cancellation.
|
|
205
|
+
* @returns An async iterable of receipts, one for each message.
|
|
206
|
+
*/
|
|
207
|
+
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt>;
|
|
208
|
+
/**
|
|
209
|
+
* Extracts or generates a message ID from the Plunk response.
|
|
210
|
+
*
|
|
211
|
+
* Plunk returns email details in the response, so we can use the contact ID
|
|
212
|
+
* and timestamp to create a meaningful message ID.
|
|
213
|
+
*
|
|
214
|
+
* @param response The Plunk API response.
|
|
215
|
+
* @param message The original message for fallback ID generation.
|
|
216
|
+
* @returns A message ID string.
|
|
217
|
+
*/
|
|
218
|
+
private extractMessageId;
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/http-client.d.ts
|
|
222
|
+
/**
|
|
223
|
+
* Response from Plunk API for sending messages.
|
|
224
|
+
*/
|
|
225
|
+
interface PlunkResponse {
|
|
226
|
+
/**
|
|
227
|
+
* Indicates whether the API call was successful.
|
|
228
|
+
*/
|
|
229
|
+
readonly success: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Array of sent email details.
|
|
232
|
+
*/
|
|
233
|
+
readonly emails: readonly {
|
|
234
|
+
readonly contact: {
|
|
235
|
+
readonly id: string;
|
|
236
|
+
readonly email: string;
|
|
237
|
+
};
|
|
238
|
+
readonly email: string;
|
|
239
|
+
}[];
|
|
240
|
+
/**
|
|
241
|
+
* Timestamp of the send operation.
|
|
242
|
+
*/
|
|
243
|
+
readonly timestamp: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Error response from Plunk API.
|
|
247
|
+
*/
|
|
248
|
+
interface PlunkError {
|
|
249
|
+
/**
|
|
250
|
+
* Error message from Plunk.
|
|
251
|
+
*/
|
|
252
|
+
readonly message: string;
|
|
253
|
+
/**
|
|
254
|
+
* HTTP status code.
|
|
255
|
+
*/
|
|
256
|
+
readonly statusCode?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Additional error details from Plunk API.
|
|
259
|
+
*/
|
|
260
|
+
readonly details?: unknown;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* HTTP client wrapper for Plunk API requests.
|
|
264
|
+
*
|
|
265
|
+
* This class handles authentication, request formatting, error handling,
|
|
266
|
+
* and retry logic for the Plunk HTTP API.
|
|
267
|
+
*/
|
|
268
|
+
//#endregion
|
|
269
|
+
export { PlunkConfig, PlunkError, PlunkResponse, PlunkTransport, ResolvedPlunkConfig };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { Message, Receipt, Transport, TransportOptions } from "@upyo/core";
|
|
2
|
+
|
|
3
|
+
//#region src/config.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configuration interface for Plunk transport connection settings.
|
|
7
|
+
*
|
|
8
|
+
* This interface defines all available options for configuring a Plunk
|
|
9
|
+
* API connection including authentication, HTTP options, and base URL for
|
|
10
|
+
* self-hosted instances.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const config: PlunkConfig = {
|
|
15
|
+
* apiKey: 'your-api-key',
|
|
16
|
+
* baseUrl: 'https://api.useplunk.com', // or self-hosted URL
|
|
17
|
+
* timeout: 30000,
|
|
18
|
+
* retries: 3
|
|
19
|
+
* };
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
interface PlunkConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Your Plunk API key.
|
|
25
|
+
*
|
|
26
|
+
* You can find your API key in your Plunk dashboard under Settings > API Keys.
|
|
27
|
+
* The key will be used as a Bearer token for authentication.
|
|
28
|
+
*/
|
|
29
|
+
readonly apiKey: string;
|
|
30
|
+
/**
|
|
31
|
+
* Base URL for the Plunk API.
|
|
32
|
+
*
|
|
33
|
+
* For Plunk's hosted service, use "https://api.useplunk.com" (default).
|
|
34
|
+
* For self-hosted instances, use your domain with "/api" path
|
|
35
|
+
* (e.g., "https://plunk.example.com/api").
|
|
36
|
+
*
|
|
37
|
+
* @default "https://api.useplunk.com"
|
|
38
|
+
*/
|
|
39
|
+
readonly baseUrl?: string;
|
|
40
|
+
/**
|
|
41
|
+
* HTTP request timeout in milliseconds.
|
|
42
|
+
*
|
|
43
|
+
* @default 30000
|
|
44
|
+
*/
|
|
45
|
+
readonly timeout?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Number of retry attempts for failed requests.
|
|
48
|
+
*
|
|
49
|
+
* @default 3
|
|
50
|
+
*/
|
|
51
|
+
readonly retries?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Whether to validate SSL certificates.
|
|
54
|
+
*
|
|
55
|
+
* @default true
|
|
56
|
+
*/
|
|
57
|
+
readonly validateSsl?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Additional HTTP headers to include with requests.
|
|
60
|
+
*/
|
|
61
|
+
readonly headers?: Record<string, string>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolved Plunk configuration with all optional fields filled with default values.
|
|
65
|
+
*
|
|
66
|
+
* This type represents the final configuration after applying defaults,
|
|
67
|
+
* used internally by the Plunk transport implementation.
|
|
68
|
+
*/
|
|
69
|
+
type ResolvedPlunkConfig = Required<PlunkConfig>;
|
|
70
|
+
/**
|
|
71
|
+
* Creates a resolved Plunk configuration by applying default values to optional fields.
|
|
72
|
+
*
|
|
73
|
+
* This function takes a partial Plunk configuration and returns a complete
|
|
74
|
+
* configuration with all optional fields filled with sensible defaults.
|
|
75
|
+
* It is used internally by the Plunk transport.
|
|
76
|
+
*
|
|
77
|
+
* @param config - The Plunk configuration with optional fields
|
|
78
|
+
* @returns A resolved configuration with all defaults applied
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/plunk-transport.d.ts
|
|
83
|
+
/**
|
|
84
|
+
* Plunk transport implementation for sending emails via Plunk API.
|
|
85
|
+
*
|
|
86
|
+
* This transport provides efficient email delivery using Plunk's HTTP API,
|
|
87
|
+
* with support for both cloud-hosted and self-hosted instances, authentication,
|
|
88
|
+
* retry logic, and batch sending capabilities.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* import { PlunkTransport } from '@upyo/plunk';
|
|
93
|
+
*
|
|
94
|
+
* const transport = new PlunkTransport({
|
|
95
|
+
* apiKey: 'your-plunk-api-key',
|
|
96
|
+
* baseUrl: 'https://api.useplunk.com', // or self-hosted URL
|
|
97
|
+
* timeout: 30000,
|
|
98
|
+
* retries: 3
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* const receipt = await transport.send(message);
|
|
102
|
+
* if (receipt.successful) {
|
|
103
|
+
* console.log('Message sent with ID:', receipt.messageId);
|
|
104
|
+
* } else {
|
|
105
|
+
* console.error('Send failed:', receipt.errorMessages.join(', '));
|
|
106
|
+
* }
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
declare class PlunkTransport implements Transport {
|
|
110
|
+
/**
|
|
111
|
+
* The resolved Plunk configuration used by this transport.
|
|
112
|
+
*/
|
|
113
|
+
config: ResolvedPlunkConfig;
|
|
114
|
+
private httpClient;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a new Plunk transport instance.
|
|
117
|
+
*
|
|
118
|
+
* @param config Plunk configuration including API key and options.
|
|
119
|
+
*/
|
|
120
|
+
constructor(config: PlunkConfig);
|
|
121
|
+
/**
|
|
122
|
+
* Sends a single email message via Plunk API.
|
|
123
|
+
*
|
|
124
|
+
* This method converts the message to Plunk format, makes an HTTP request
|
|
125
|
+
* to the Plunk API, and returns a receipt with the result.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* const receipt = await transport.send({
|
|
130
|
+
* sender: { address: 'from@example.com' },
|
|
131
|
+
* recipients: [{ address: 'to@example.com' }],
|
|
132
|
+
* ccRecipients: [],
|
|
133
|
+
* bccRecipients: [],
|
|
134
|
+
* replyRecipients: [],
|
|
135
|
+
* subject: 'Hello',
|
|
136
|
+
* content: { text: 'Hello World!' },
|
|
137
|
+
* attachments: [],
|
|
138
|
+
* priority: 'normal',
|
|
139
|
+
* tags: [],
|
|
140
|
+
* headers: new Headers()
|
|
141
|
+
* });
|
|
142
|
+
*
|
|
143
|
+
* if (receipt.successful) {
|
|
144
|
+
* console.log('Message sent successfully');
|
|
145
|
+
* }
|
|
146
|
+
* ```
|
|
147
|
+
*
|
|
148
|
+
* @param message The email message to send.
|
|
149
|
+
* @param options Optional transport options including `AbortSignal` for
|
|
150
|
+
* cancellation.
|
|
151
|
+
* @returns A promise that resolves to a receipt indicating success or
|
|
152
|
+
* failure.
|
|
153
|
+
*/
|
|
154
|
+
send(message: Message, options?: TransportOptions): Promise<Receipt>;
|
|
155
|
+
/**
|
|
156
|
+
* Sends multiple email messages efficiently via Plunk API.
|
|
157
|
+
*
|
|
158
|
+
* This method sends each message individually but provides a streamlined
|
|
159
|
+
* interface for processing multiple messages. Each message is sent as a
|
|
160
|
+
* separate API request to Plunk.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const messages = [
|
|
165
|
+
* {
|
|
166
|
+
* sender: { address: 'from@example.com' },
|
|
167
|
+
* recipients: [{ address: 'user1@example.com' }],
|
|
168
|
+
* ccRecipients: [],
|
|
169
|
+
* bccRecipients: [],
|
|
170
|
+
* replyRecipients: [],
|
|
171
|
+
* subject: 'Message 1',
|
|
172
|
+
* content: { text: 'Hello User 1!' },
|
|
173
|
+
* attachments: [],
|
|
174
|
+
* priority: 'normal',
|
|
175
|
+
* tags: [],
|
|
176
|
+
* headers: new Headers()
|
|
177
|
+
* },
|
|
178
|
+
* {
|
|
179
|
+
* sender: { address: 'from@example.com' },
|
|
180
|
+
* recipients: [{ address: 'user2@example.com' }],
|
|
181
|
+
* ccRecipients: [],
|
|
182
|
+
* bccRecipients: [],
|
|
183
|
+
* replyRecipients: [],
|
|
184
|
+
* subject: 'Message 2',
|
|
185
|
+
* content: { text: 'Hello User 2!' },
|
|
186
|
+
* attachments: [],
|
|
187
|
+
* priority: 'normal',
|
|
188
|
+
* tags: [],
|
|
189
|
+
* headers: new Headers()
|
|
190
|
+
* }
|
|
191
|
+
* ];
|
|
192
|
+
*
|
|
193
|
+
* for await (const receipt of transport.sendMany(messages)) {
|
|
194
|
+
* if (receipt.successful) {
|
|
195
|
+
* console.log('Sent:', receipt.messageId);
|
|
196
|
+
* } else {
|
|
197
|
+
* console.error('Failed:', receipt.errorMessages);
|
|
198
|
+
* }
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*
|
|
202
|
+
* @param messages An iterable or async iterable of messages to send.
|
|
203
|
+
* @param options Optional transport options including `AbortSignal` for
|
|
204
|
+
* cancellation.
|
|
205
|
+
* @returns An async iterable of receipts, one for each message.
|
|
206
|
+
*/
|
|
207
|
+
sendMany(messages: Iterable<Message> | AsyncIterable<Message>, options?: TransportOptions): AsyncIterable<Receipt>;
|
|
208
|
+
/**
|
|
209
|
+
* Extracts or generates a message ID from the Plunk response.
|
|
210
|
+
*
|
|
211
|
+
* Plunk returns email details in the response, so we can use the contact ID
|
|
212
|
+
* and timestamp to create a meaningful message ID.
|
|
213
|
+
*
|
|
214
|
+
* @param response The Plunk API response.
|
|
215
|
+
* @param message The original message for fallback ID generation.
|
|
216
|
+
* @returns A message ID string.
|
|
217
|
+
*/
|
|
218
|
+
private extractMessageId;
|
|
219
|
+
}
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/http-client.d.ts
|
|
222
|
+
/**
|
|
223
|
+
* Response from Plunk API for sending messages.
|
|
224
|
+
*/
|
|
225
|
+
interface PlunkResponse {
|
|
226
|
+
/**
|
|
227
|
+
* Indicates whether the API call was successful.
|
|
228
|
+
*/
|
|
229
|
+
readonly success: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Array of sent email details.
|
|
232
|
+
*/
|
|
233
|
+
readonly emails: readonly {
|
|
234
|
+
readonly contact: {
|
|
235
|
+
readonly id: string;
|
|
236
|
+
readonly email: string;
|
|
237
|
+
};
|
|
238
|
+
readonly email: string;
|
|
239
|
+
}[];
|
|
240
|
+
/**
|
|
241
|
+
* Timestamp of the send operation.
|
|
242
|
+
*/
|
|
243
|
+
readonly timestamp: string;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Error response from Plunk API.
|
|
247
|
+
*/
|
|
248
|
+
interface PlunkError {
|
|
249
|
+
/**
|
|
250
|
+
* Error message from Plunk.
|
|
251
|
+
*/
|
|
252
|
+
readonly message: string;
|
|
253
|
+
/**
|
|
254
|
+
* HTTP status code.
|
|
255
|
+
*/
|
|
256
|
+
readonly statusCode?: number;
|
|
257
|
+
/**
|
|
258
|
+
* Additional error details from Plunk API.
|
|
259
|
+
*/
|
|
260
|
+
readonly details?: unknown;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* HTTP client wrapper for Plunk API requests.
|
|
264
|
+
*
|
|
265
|
+
* This class handles authentication, request formatting, error handling,
|
|
266
|
+
* and retry logic for the Plunk HTTP API.
|
|
267
|
+
*/
|
|
268
|
+
//#endregion
|
|
269
|
+
export { PlunkConfig, PlunkError, PlunkResponse, PlunkTransport, ResolvedPlunkConfig };
|