@upyo/sendgrid 0.1.0-dev.14 → 0.1.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/dist/index.cjs +6 -13
- package/dist/index.d.cts +27 -95
- package/dist/index.d.ts +27 -95
- package/dist/index.js +6 -12
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5,20 +5,11 @@
|
|
|
5
5
|
*
|
|
6
6
|
* This function takes a partial SendGrid configuration and returns a complete
|
|
7
7
|
* configuration with all optional fields filled with sensible defaults.
|
|
8
|
+
* It is used internally by the SendGrid transport.
|
|
8
9
|
*
|
|
9
10
|
* @param config - The SendGrid configuration with optional fields
|
|
10
11
|
* @returns A resolved configuration with all defaults applied
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const resolved = createSendGridConfig({
|
|
15
|
-
* apiKey: 'your-api-key'
|
|
16
|
-
* });
|
|
17
|
-
*
|
|
18
|
-
* // resolved.baseUrl will be 'https://api.sendgrid.com/v3' (default)
|
|
19
|
-
* // resolved.timeout will be 30000 (default)
|
|
20
|
-
* // resolved.retries will be 3 (default)
|
|
21
|
-
* ```
|
|
12
|
+
* @internal
|
|
22
13
|
*/
|
|
23
14
|
function createSendGridConfig(config) {
|
|
24
15
|
return {
|
|
@@ -321,6 +312,9 @@ function isStandardHeader(headerName) {
|
|
|
321
312
|
* ```
|
|
322
313
|
*/
|
|
323
314
|
var SendGridTransport = class {
|
|
315
|
+
/**
|
|
316
|
+
* The resolved SendGrid configuration used by this transport.
|
|
317
|
+
*/
|
|
324
318
|
config;
|
|
325
319
|
httpClient;
|
|
326
320
|
/**
|
|
@@ -468,5 +462,4 @@ var SendGridTransport = class {
|
|
|
468
462
|
|
|
469
463
|
//#endregion
|
|
470
464
|
exports.SendGridApiError = SendGridApiError;
|
|
471
|
-
exports.SendGridTransport = SendGridTransport;
|
|
472
|
-
exports.createSendGridConfig = createSendGridConfig;
|
|
465
|
+
exports.SendGridTransport = SendGridTransport;
|
package/dist/index.d.cts
CHANGED
|
@@ -91,102 +91,12 @@ type ResolvedSendGridConfig = Required<SendGridConfig>;
|
|
|
91
91
|
*
|
|
92
92
|
* This function takes a partial SendGrid configuration and returns a complete
|
|
93
93
|
* configuration with all optional fields filled with sensible defaults.
|
|
94
|
+
* It is used internally by the SendGrid transport.
|
|
94
95
|
*
|
|
95
96
|
* @param config - The SendGrid configuration with optional fields
|
|
96
97
|
* @returns A resolved configuration with all defaults applied
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* const resolved = createSendGridConfig({
|
|
101
|
-
* apiKey: 'your-api-key'
|
|
102
|
-
* });
|
|
103
|
-
*
|
|
104
|
-
* // resolved.baseUrl will be 'https://api.sendgrid.com/v3' (default)
|
|
105
|
-
* // resolved.timeout will be 30000 (default)
|
|
106
|
-
* // resolved.retries will be 3 (default)
|
|
107
|
-
* ```
|
|
98
|
+
* @internal
|
|
108
99
|
*/
|
|
109
|
-
declare function createSendGridConfig(config: SendGridConfig): ResolvedSendGridConfig;
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/http-client.d.ts
|
|
112
|
-
/**
|
|
113
|
-
* Response from SendGrid API for sending messages.
|
|
114
|
-
*/
|
|
115
|
-
interface SendGridResponse {
|
|
116
|
-
/**
|
|
117
|
-
* HTTP status code returned by SendGrid.
|
|
118
|
-
*/
|
|
119
|
-
readonly statusCode?: number;
|
|
120
|
-
/**
|
|
121
|
-
* Response body from SendGrid (usually empty on success).
|
|
122
|
-
*/
|
|
123
|
-
readonly body?: string;
|
|
124
|
-
/**
|
|
125
|
-
* Response headers from SendGrid.
|
|
126
|
-
*/
|
|
127
|
-
readonly headers?: Record<string, string>;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Error response from SendGrid API.
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* HTTP client wrapper for SendGrid API requests.
|
|
135
|
-
*
|
|
136
|
-
* This class handles authentication, request formatting, error handling,
|
|
137
|
-
* and retry logic for SendGrid API calls.
|
|
138
|
-
*/
|
|
139
|
-
declare class SendGridHttpClient {
|
|
140
|
-
config: ResolvedSendGridConfig;
|
|
141
|
-
constructor(config: ResolvedSendGridConfig);
|
|
142
|
-
/**
|
|
143
|
-
* Sends a message via SendGrid API.
|
|
144
|
-
*
|
|
145
|
-
* @param messageData The JSON data to send to SendGrid.
|
|
146
|
-
* @param signal Optional AbortSignal for cancellation.
|
|
147
|
-
* @returns Promise that resolves to the SendGrid response.
|
|
148
|
-
*/
|
|
149
|
-
sendMessage(messageData: Record<string, unknown>, signal?: AbortSignal): Promise<SendGridResponse>;
|
|
150
|
-
/**
|
|
151
|
-
* Makes an HTTP request to SendGrid API with retry logic.
|
|
152
|
-
*
|
|
153
|
-
* @param url The URL to make the request to.
|
|
154
|
-
* @param options Fetch options.
|
|
155
|
-
* @returns Promise that resolves to the parsed response.
|
|
156
|
-
*/
|
|
157
|
-
makeRequest(url: string, options: RequestInit): Promise<SendGridResponse>;
|
|
158
|
-
/**
|
|
159
|
-
* Makes a fetch request with SendGrid authentication.
|
|
160
|
-
*
|
|
161
|
-
* @param url The URL to make the request to.
|
|
162
|
-
* @param options Fetch options.
|
|
163
|
-
* @returns Promise that resolves to the fetch response.
|
|
164
|
-
*/
|
|
165
|
-
fetchWithAuth(url: string, options: RequestInit): Promise<Response>;
|
|
166
|
-
/**
|
|
167
|
-
* Converts Headers object to a plain Record.
|
|
168
|
-
*
|
|
169
|
-
* @param headers The Headers object to convert.
|
|
170
|
-
* @returns A plain object with header key-value pairs.
|
|
171
|
-
*/
|
|
172
|
-
headersToRecord(headers: Headers): Record<string, string>;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Custom error class for SendGrid API errors.
|
|
176
|
-
*/
|
|
177
|
-
declare class SendGridApiError extends Error {
|
|
178
|
-
readonly statusCode?: number;
|
|
179
|
-
readonly errors?: {
|
|
180
|
-
readonly message: string;
|
|
181
|
-
readonly field?: string;
|
|
182
|
-
readonly help?: string;
|
|
183
|
-
}[];
|
|
184
|
-
constructor(message: string, statusCode?: number, errors?: Array<{
|
|
185
|
-
message: string;
|
|
186
|
-
field?: string;
|
|
187
|
-
help?: string;
|
|
188
|
-
}>);
|
|
189
|
-
}
|
|
190
100
|
//#endregion
|
|
191
101
|
//#region src/sendgrid-transport.d.ts
|
|
192
102
|
/**
|
|
@@ -214,8 +124,11 @@ declare class SendGridApiError extends Error {
|
|
|
214
124
|
* ```
|
|
215
125
|
*/
|
|
216
126
|
declare class SendGridTransport implements Transport {
|
|
217
|
-
|
|
218
|
-
|
|
127
|
+
/**
|
|
128
|
+
* The resolved SendGrid configuration used by this transport.
|
|
129
|
+
*/
|
|
130
|
+
config: ResolvedSendGridConfig;
|
|
131
|
+
private httpClient;
|
|
219
132
|
/**
|
|
220
133
|
* Creates a new SendGrid transport instance.
|
|
221
134
|
*
|
|
@@ -321,4 +234,23 @@ declare class SendGridTransport implements Transport {
|
|
|
321
234
|
private extractMessageId;
|
|
322
235
|
}
|
|
323
236
|
//#endregion
|
|
324
|
-
|
|
237
|
+
//#region src/http-client.d.ts
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Custom error class for SendGrid API errors.
|
|
241
|
+
*/
|
|
242
|
+
declare class SendGridApiError extends Error {
|
|
243
|
+
readonly statusCode?: number;
|
|
244
|
+
readonly errors?: {
|
|
245
|
+
readonly message: string;
|
|
246
|
+
readonly field?: string;
|
|
247
|
+
readonly help?: string;
|
|
248
|
+
}[];
|
|
249
|
+
constructor(message: string, statusCode?: number, errors?: Array<{
|
|
250
|
+
message: string;
|
|
251
|
+
field?: string;
|
|
252
|
+
help?: string;
|
|
253
|
+
}>);
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { SendGridApiError, SendGridConfig, SendGridTransport };
|
package/dist/index.d.ts
CHANGED
|
@@ -91,102 +91,12 @@ type ResolvedSendGridConfig = Required<SendGridConfig>;
|
|
|
91
91
|
*
|
|
92
92
|
* This function takes a partial SendGrid configuration and returns a complete
|
|
93
93
|
* configuration with all optional fields filled with sensible defaults.
|
|
94
|
+
* It is used internally by the SendGrid transport.
|
|
94
95
|
*
|
|
95
96
|
* @param config - The SendGrid configuration with optional fields
|
|
96
97
|
* @returns A resolved configuration with all defaults applied
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* const resolved = createSendGridConfig({
|
|
101
|
-
* apiKey: 'your-api-key'
|
|
102
|
-
* });
|
|
103
|
-
*
|
|
104
|
-
* // resolved.baseUrl will be 'https://api.sendgrid.com/v3' (default)
|
|
105
|
-
* // resolved.timeout will be 30000 (default)
|
|
106
|
-
* // resolved.retries will be 3 (default)
|
|
107
|
-
* ```
|
|
98
|
+
* @internal
|
|
108
99
|
*/
|
|
109
|
-
declare function createSendGridConfig(config: SendGridConfig): ResolvedSendGridConfig;
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/http-client.d.ts
|
|
112
|
-
/**
|
|
113
|
-
* Response from SendGrid API for sending messages.
|
|
114
|
-
*/
|
|
115
|
-
interface SendGridResponse {
|
|
116
|
-
/**
|
|
117
|
-
* HTTP status code returned by SendGrid.
|
|
118
|
-
*/
|
|
119
|
-
readonly statusCode?: number;
|
|
120
|
-
/**
|
|
121
|
-
* Response body from SendGrid (usually empty on success).
|
|
122
|
-
*/
|
|
123
|
-
readonly body?: string;
|
|
124
|
-
/**
|
|
125
|
-
* Response headers from SendGrid.
|
|
126
|
-
*/
|
|
127
|
-
readonly headers?: Record<string, string>;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Error response from SendGrid API.
|
|
131
|
-
*/
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* HTTP client wrapper for SendGrid API requests.
|
|
135
|
-
*
|
|
136
|
-
* This class handles authentication, request formatting, error handling,
|
|
137
|
-
* and retry logic for SendGrid API calls.
|
|
138
|
-
*/
|
|
139
|
-
declare class SendGridHttpClient {
|
|
140
|
-
config: ResolvedSendGridConfig;
|
|
141
|
-
constructor(config: ResolvedSendGridConfig);
|
|
142
|
-
/**
|
|
143
|
-
* Sends a message via SendGrid API.
|
|
144
|
-
*
|
|
145
|
-
* @param messageData The JSON data to send to SendGrid.
|
|
146
|
-
* @param signal Optional AbortSignal for cancellation.
|
|
147
|
-
* @returns Promise that resolves to the SendGrid response.
|
|
148
|
-
*/
|
|
149
|
-
sendMessage(messageData: Record<string, unknown>, signal?: AbortSignal): Promise<SendGridResponse>;
|
|
150
|
-
/**
|
|
151
|
-
* Makes an HTTP request to SendGrid API with retry logic.
|
|
152
|
-
*
|
|
153
|
-
* @param url The URL to make the request to.
|
|
154
|
-
* @param options Fetch options.
|
|
155
|
-
* @returns Promise that resolves to the parsed response.
|
|
156
|
-
*/
|
|
157
|
-
makeRequest(url: string, options: RequestInit): Promise<SendGridResponse>;
|
|
158
|
-
/**
|
|
159
|
-
* Makes a fetch request with SendGrid authentication.
|
|
160
|
-
*
|
|
161
|
-
* @param url The URL to make the request to.
|
|
162
|
-
* @param options Fetch options.
|
|
163
|
-
* @returns Promise that resolves to the fetch response.
|
|
164
|
-
*/
|
|
165
|
-
fetchWithAuth(url: string, options: RequestInit): Promise<Response>;
|
|
166
|
-
/**
|
|
167
|
-
* Converts Headers object to a plain Record.
|
|
168
|
-
*
|
|
169
|
-
* @param headers The Headers object to convert.
|
|
170
|
-
* @returns A plain object with header key-value pairs.
|
|
171
|
-
*/
|
|
172
|
-
headersToRecord(headers: Headers): Record<string, string>;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Custom error class for SendGrid API errors.
|
|
176
|
-
*/
|
|
177
|
-
declare class SendGridApiError extends Error {
|
|
178
|
-
readonly statusCode?: number;
|
|
179
|
-
readonly errors?: {
|
|
180
|
-
readonly message: string;
|
|
181
|
-
readonly field?: string;
|
|
182
|
-
readonly help?: string;
|
|
183
|
-
}[];
|
|
184
|
-
constructor(message: string, statusCode?: number, errors?: Array<{
|
|
185
|
-
message: string;
|
|
186
|
-
field?: string;
|
|
187
|
-
help?: string;
|
|
188
|
-
}>);
|
|
189
|
-
}
|
|
190
100
|
//#endregion
|
|
191
101
|
//#region src/sendgrid-transport.d.ts
|
|
192
102
|
/**
|
|
@@ -214,8 +124,11 @@ declare class SendGridApiError extends Error {
|
|
|
214
124
|
* ```
|
|
215
125
|
*/
|
|
216
126
|
declare class SendGridTransport implements Transport {
|
|
217
|
-
|
|
218
|
-
|
|
127
|
+
/**
|
|
128
|
+
* The resolved SendGrid configuration used by this transport.
|
|
129
|
+
*/
|
|
130
|
+
config: ResolvedSendGridConfig;
|
|
131
|
+
private httpClient;
|
|
219
132
|
/**
|
|
220
133
|
* Creates a new SendGrid transport instance.
|
|
221
134
|
*
|
|
@@ -321,4 +234,23 @@ declare class SendGridTransport implements Transport {
|
|
|
321
234
|
private extractMessageId;
|
|
322
235
|
}
|
|
323
236
|
//#endregion
|
|
324
|
-
|
|
237
|
+
//#region src/http-client.d.ts
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Custom error class for SendGrid API errors.
|
|
241
|
+
*/
|
|
242
|
+
declare class SendGridApiError extends Error {
|
|
243
|
+
readonly statusCode?: number;
|
|
244
|
+
readonly errors?: {
|
|
245
|
+
readonly message: string;
|
|
246
|
+
readonly field?: string;
|
|
247
|
+
readonly help?: string;
|
|
248
|
+
}[];
|
|
249
|
+
constructor(message: string, statusCode?: number, errors?: Array<{
|
|
250
|
+
message: string;
|
|
251
|
+
field?: string;
|
|
252
|
+
help?: string;
|
|
253
|
+
}>);
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
export { SendGridApiError, SendGridConfig, SendGridTransport };
|
package/dist/index.js
CHANGED
|
@@ -4,20 +4,11 @@
|
|
|
4
4
|
*
|
|
5
5
|
* This function takes a partial SendGrid configuration and returns a complete
|
|
6
6
|
* configuration with all optional fields filled with sensible defaults.
|
|
7
|
+
* It is used internally by the SendGrid transport.
|
|
7
8
|
*
|
|
8
9
|
* @param config - The SendGrid configuration with optional fields
|
|
9
10
|
* @returns A resolved configuration with all defaults applied
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* const resolved = createSendGridConfig({
|
|
14
|
-
* apiKey: 'your-api-key'
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // resolved.baseUrl will be 'https://api.sendgrid.com/v3' (default)
|
|
18
|
-
* // resolved.timeout will be 30000 (default)
|
|
19
|
-
* // resolved.retries will be 3 (default)
|
|
20
|
-
* ```
|
|
11
|
+
* @internal
|
|
21
12
|
*/
|
|
22
13
|
function createSendGridConfig(config) {
|
|
23
14
|
return {
|
|
@@ -320,6 +311,9 @@ function isStandardHeader(headerName) {
|
|
|
320
311
|
* ```
|
|
321
312
|
*/
|
|
322
313
|
var SendGridTransport = class {
|
|
314
|
+
/**
|
|
315
|
+
* The resolved SendGrid configuration used by this transport.
|
|
316
|
+
*/
|
|
323
317
|
config;
|
|
324
318
|
httpClient;
|
|
325
319
|
/**
|
|
@@ -466,4 +460,4 @@ var SendGridTransport = class {
|
|
|
466
460
|
};
|
|
467
461
|
|
|
468
462
|
//#endregion
|
|
469
|
-
export { SendGridApiError, SendGridTransport
|
|
463
|
+
export { SendGridApiError, SendGridTransport };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upyo/sendgrid",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "SendGrid transport for Upyo email library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
"sideEffects": false,
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@upyo/core": "0.1.0
|
|
56
|
+
"@upyo/core": "0.1.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@dotenvx/dotenvx": "^1.47.3",
|