@bernierllc/email-sender 3.0.3 → 3.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/README.md +138 -0
- package/dist/core/email-safety-manager.d.ts +30 -0
- package/dist/core/email-safety-manager.d.ts.map +1 -0
- package/dist/core/email-safety-manager.js +106 -0
- package/dist/core/email-safety-manager.js.map +1 -0
- package/dist/core/email-sender.d.ts +23 -5
- package/dist/core/email-sender.d.ts.map +1 -1
- package/dist/core/email-sender.js +55 -2
- package/dist/core/email-sender.js.map +1 -1
- package/dist/errors.d.ts +112 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +176 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/dist/providers/sendgrid/client.d.ts.map +1 -1
- package/dist/providers/sendgrid/client.js +9 -3
- package/dist/providers/sendgrid/client.js.map +1 -1
- package/dist/providers/sendgrid/errors.d.ts +58 -15
- package/dist/providers/sendgrid/errors.d.ts.map +1 -1
- package/dist/providers/sendgrid/errors.js +130 -23
- package/dist/providers/sendgrid/errors.js.map +1 -1
- package/dist/providers/sendgrid/sender-manager.d.ts.map +1 -1
- package/dist/providers/sendgrid/sender-manager.js +4 -1
- package/dist/providers/sendgrid/sender-manager.js.map +1 -1
- package/dist/providers/sendgrid/template-manager.d.ts.map +1 -1
- package/dist/providers/sendgrid/template-manager.js +24 -6
- package/dist/providers/sendgrid/template-manager.js.map +1 -1
- package/dist/providers/sendgrid.d.ts +4 -0
- package/dist/providers/sendgrid.d.ts.map +1 -1
- package/dist/providers/sendgrid.js +157 -98
- package/dist/providers/sendgrid.js.map +1 -1
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +5 -1
package/dist/errors.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TimeoutError = exports.NetworkError = exports.RateLimitError = exports.ProviderError = exports.EmailValidationError = exports.EmailSenderError = exports.EmailSenderErrorCode = void 0;
|
|
11
|
+
/**
|
|
12
|
+
* Email sender error classes with ES2022 Error.cause support
|
|
13
|
+
*
|
|
14
|
+
* These errors follow the error propagation standard defined in:
|
|
15
|
+
* plans/standards/error-propagation-standard.md
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Error codes for programmatic error handling
|
|
19
|
+
*/
|
|
20
|
+
exports.EmailSenderErrorCode = {
|
|
21
|
+
// Provider errors
|
|
22
|
+
PROVIDER_ERROR: 'PROVIDER_ERROR',
|
|
23
|
+
PROVIDER_AUTH_ERROR: 'PROVIDER_AUTH_ERROR',
|
|
24
|
+
PROVIDER_RATE_LIMITED: 'PROVIDER_RATE_LIMITED',
|
|
25
|
+
PROVIDER_UNAVAILABLE: 'PROVIDER_UNAVAILABLE',
|
|
26
|
+
// Validation errors
|
|
27
|
+
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
28
|
+
INVALID_EMAIL: 'INVALID_EMAIL',
|
|
29
|
+
INVALID_TEMPLATE: 'INVALID_TEMPLATE',
|
|
30
|
+
// Template errors
|
|
31
|
+
TEMPLATE_NOT_FOUND: 'TEMPLATE_NOT_FOUND',
|
|
32
|
+
TEMPLATE_UNAUTHORIZED: 'TEMPLATE_UNAUTHORIZED',
|
|
33
|
+
TEMPLATE_CONFLICT: 'TEMPLATE_CONFLICT',
|
|
34
|
+
// Network errors
|
|
35
|
+
NETWORK_ERROR: 'NETWORK_ERROR',
|
|
36
|
+
TIMEOUT_ERROR: 'TIMEOUT_ERROR',
|
|
37
|
+
// General errors
|
|
38
|
+
SEND_ERROR: 'SEND_ERROR',
|
|
39
|
+
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Base error class for all email sender errors
|
|
43
|
+
*
|
|
44
|
+
* Supports ES2022 Error.cause for error chaining.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* try {
|
|
49
|
+
* await sendGridClient.send(email);
|
|
50
|
+
* } catch (error) {
|
|
51
|
+
* throw new EmailSenderError('Failed to send email via SendGrid', {
|
|
52
|
+
* cause: error,
|
|
53
|
+
* code: 'PROVIDER_ERROR',
|
|
54
|
+
* context: { provider: 'sendgrid', to: email.to }
|
|
55
|
+
* });
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
class EmailSenderError extends Error {
|
|
60
|
+
constructor(message, options) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.name = 'EmailSenderError';
|
|
63
|
+
this.code = options?.code ?? exports.EmailSenderErrorCode.UNKNOWN_ERROR;
|
|
64
|
+
this.context = options?.context;
|
|
65
|
+
this.retryable = options?.retryable ?? false;
|
|
66
|
+
this.retryAfter = options?.retryAfter;
|
|
67
|
+
// Set cause using ES2022 pattern (works at runtime in Node 16.9+)
|
|
68
|
+
if (options?.cause) {
|
|
69
|
+
this.cause = options.cause;
|
|
70
|
+
}
|
|
71
|
+
// Maintains proper stack trace in V8 engines
|
|
72
|
+
Error.captureStackTrace?.(this, this.constructor);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if the error or any error in its cause chain is retryable
|
|
76
|
+
*/
|
|
77
|
+
isRetryable() {
|
|
78
|
+
if (this.retryable)
|
|
79
|
+
return true;
|
|
80
|
+
// Check cause chain
|
|
81
|
+
let current = this.cause;
|
|
82
|
+
while (current instanceof Error) {
|
|
83
|
+
if ('retryable' in current && current.retryable === true) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
current = current.cause;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get retry timing from this error or its cause chain
|
|
92
|
+
*/
|
|
93
|
+
getRetryAfter() {
|
|
94
|
+
if (this.retryAfter !== undefined)
|
|
95
|
+
return this.retryAfter;
|
|
96
|
+
// Check cause chain
|
|
97
|
+
let current = this.cause;
|
|
98
|
+
while (current instanceof Error) {
|
|
99
|
+
if ('retryAfter' in current && typeof current.retryAfter === 'number') {
|
|
100
|
+
return current.retryAfter;
|
|
101
|
+
}
|
|
102
|
+
current = current.cause;
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.EmailSenderError = EmailSenderError;
|
|
108
|
+
/**
|
|
109
|
+
* Error thrown when email validation fails
|
|
110
|
+
*/
|
|
111
|
+
class EmailValidationError extends EmailSenderError {
|
|
112
|
+
constructor(message, options) {
|
|
113
|
+
super(message, { ...options, code: exports.EmailSenderErrorCode.VALIDATION_ERROR });
|
|
114
|
+
this.name = 'EmailValidationError';
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.EmailValidationError = EmailValidationError;
|
|
118
|
+
/**
|
|
119
|
+
* Error thrown when a provider operation fails
|
|
120
|
+
*/
|
|
121
|
+
class ProviderError extends EmailSenderError {
|
|
122
|
+
constructor(message, options) {
|
|
123
|
+
super(message, { ...options, code: options?.code ?? exports.EmailSenderErrorCode.PROVIDER_ERROR });
|
|
124
|
+
this.name = 'ProviderError';
|
|
125
|
+
this.statusCode = options?.statusCode;
|
|
126
|
+
this.providerResponse = options?.providerResponse;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.ProviderError = ProviderError;
|
|
130
|
+
/**
|
|
131
|
+
* Error thrown when rate limited by a provider
|
|
132
|
+
*/
|
|
133
|
+
class RateLimitError extends EmailSenderError {
|
|
134
|
+
constructor(message, options) {
|
|
135
|
+
const baseOptions = {
|
|
136
|
+
...options,
|
|
137
|
+
code: exports.EmailSenderErrorCode.PROVIDER_RATE_LIMITED,
|
|
138
|
+
retryable: true,
|
|
139
|
+
};
|
|
140
|
+
if (options?.retryAfter !== undefined) {
|
|
141
|
+
baseOptions.retryAfter = options.retryAfter;
|
|
142
|
+
}
|
|
143
|
+
super(message, baseOptions);
|
|
144
|
+
this.name = 'RateLimitError';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.RateLimitError = RateLimitError;
|
|
148
|
+
/**
|
|
149
|
+
* Error thrown when network communication fails
|
|
150
|
+
*/
|
|
151
|
+
class NetworkError extends EmailSenderError {
|
|
152
|
+
constructor(message, options) {
|
|
153
|
+
super(message, {
|
|
154
|
+
...options,
|
|
155
|
+
code: exports.EmailSenderErrorCode.NETWORK_ERROR,
|
|
156
|
+
retryable: true, // Network errors are generally retryable
|
|
157
|
+
});
|
|
158
|
+
this.name = 'NetworkError';
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
exports.NetworkError = NetworkError;
|
|
162
|
+
/**
|
|
163
|
+
* Error thrown when a request times out
|
|
164
|
+
*/
|
|
165
|
+
class TimeoutError extends EmailSenderError {
|
|
166
|
+
constructor(message, options) {
|
|
167
|
+
super(message, {
|
|
168
|
+
...options,
|
|
169
|
+
code: exports.EmailSenderErrorCode.TIMEOUT_ERROR,
|
|
170
|
+
retryable: true,
|
|
171
|
+
});
|
|
172
|
+
this.name = 'TimeoutError';
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.TimeoutError = TimeoutError;
|
|
176
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF;;;;;GAKG;AAEH;;GAEG;AACU,QAAA,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
|
|
|
3
3
|
* Main entry point for the email sending system
|
|
4
4
|
*/
|
|
5
5
|
export * from './types';
|
|
6
|
-
export { EmailSender } from './core/email-sender';
|
|
6
|
+
export { EmailSender, EmailSenderConfig } from './core/email-sender';
|
|
7
|
+
export { EmailSafetyManager } from './core/email-safety-manager';
|
|
7
8
|
export { EmailProvider } from './providers/base';
|
|
8
9
|
export { SmtpProvider } from './providers/smtp';
|
|
9
10
|
export { SendGridProvider } from './providers/sendgrid';
|
|
10
11
|
export { SesProvider } from './providers/ses';
|
|
11
12
|
export { MailgunProvider } from './providers/mailgun';
|
|
12
13
|
export { PostmarkProvider } from './providers/postmark';
|
|
13
|
-
export type { EmailMessage, SendResult, DeliveryStatus, WebhookEvent, EmailProviderConfig, EmailProviderCapabilities, EmailValidationResult, EmailAttachment, BatchEmailOptions, EmailTemplate } from './types';
|
|
14
|
+
export type { EmailMessage, SendResult, DeliveryStatus, WebhookEvent, EmailProviderConfig, EmailProviderCapabilities, EmailValidationResult, EmailAttachment, BatchEmailOptions, EmailTemplate, StagingSafetyConfig, EmailSafetyResult } from './types';
|
|
15
|
+
export { EmailSenderError, EmailSenderErrorCode, EmailValidationError, ProviderError, RateLimitError, NetworkError, TimeoutError, } from './errors';
|
|
16
|
+
export type { EmailSenderErrorOptions, EmailSenderErrorCodeType, } from './errors';
|
|
14
17
|
export type { VerifiedSender, SenderValidationResult, Template, ProviderTemplate, TemplateVersion, SyncResult, TemplateAnalytics, SendGridAdvancedConfig } from './providers/sendgrid/types';
|
|
15
|
-
export { SendGridApiError, TemplateNotFoundError, UnauthorizedTemplateAccessError, TemplateConflictError,
|
|
18
|
+
export { SendGridApiError, TemplateNotFoundError, UnauthorizedTemplateAccessError, TemplateConflictError, SendGridRateLimitError, SendGridErrorCode, } from './providers/sendgrid/errors';
|
|
19
|
+
export type { SendGridErrorCodeType } from './providers/sendgrid/errors';
|
|
16
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA;;;GAGG;AAGH,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGjE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,YAAY,EACV,YAAY,EACZ,UAAU,EACV,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,UAAU,CAAC;AAGlB,YAAY,EACV,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACrB,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
21
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
22
|
};
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.
|
|
24
|
+
exports.SendGridErrorCode = exports.SendGridRateLimitError = exports.TemplateConflictError = exports.UnauthorizedTemplateAccessError = exports.TemplateNotFoundError = exports.SendGridApiError = exports.TimeoutError = exports.NetworkError = exports.RateLimitError = exports.ProviderError = exports.EmailValidationError = exports.EmailSenderErrorCode = exports.EmailSenderError = exports.PostmarkProvider = exports.MailgunProvider = exports.SesProvider = exports.SendGridProvider = exports.SmtpProvider = exports.EmailProvider = exports.EmailSafetyManager = exports.EmailSender = void 0;
|
|
25
25
|
/**
|
|
26
26
|
* Email Sender - Core Library
|
|
27
27
|
* Main entry point for the email sending system
|
|
@@ -31,6 +31,8 @@ __exportStar(require("./types"), exports);
|
|
|
31
31
|
// Core classes
|
|
32
32
|
var email_sender_1 = require("./core/email-sender");
|
|
33
33
|
Object.defineProperty(exports, "EmailSender", { enumerable: true, get: function () { return email_sender_1.EmailSender; } });
|
|
34
|
+
var email_safety_manager_1 = require("./core/email-safety-manager");
|
|
35
|
+
Object.defineProperty(exports, "EmailSafetyManager", { enumerable: true, get: function () { return email_safety_manager_1.EmailSafetyManager; } });
|
|
34
36
|
// Provider classes
|
|
35
37
|
var base_1 = require("./providers/base");
|
|
36
38
|
Object.defineProperty(exports, "EmailProvider", { enumerable: true, get: function () { return base_1.EmailProvider; } });
|
|
@@ -44,10 +46,21 @@ var mailgun_1 = require("./providers/mailgun");
|
|
|
44
46
|
Object.defineProperty(exports, "MailgunProvider", { enumerable: true, get: function () { return mailgun_1.MailgunProvider; } });
|
|
45
47
|
var postmark_1 = require("./providers/postmark");
|
|
46
48
|
Object.defineProperty(exports, "PostmarkProvider", { enumerable: true, get: function () { return postmark_1.PostmarkProvider; } });
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Object.defineProperty(exports, "
|
|
50
|
-
Object.defineProperty(exports, "
|
|
51
|
-
Object.defineProperty(exports, "
|
|
49
|
+
// Error classes and types (v3.1.0 - Error propagation standard)
|
|
50
|
+
var errors_1 = require("./errors");
|
|
51
|
+
Object.defineProperty(exports, "EmailSenderError", { enumerable: true, get: function () { return errors_1.EmailSenderError; } });
|
|
52
|
+
Object.defineProperty(exports, "EmailSenderErrorCode", { enumerable: true, get: function () { return errors_1.EmailSenderErrorCode; } });
|
|
53
|
+
Object.defineProperty(exports, "EmailValidationError", { enumerable: true, get: function () { return errors_1.EmailValidationError; } });
|
|
54
|
+
Object.defineProperty(exports, "ProviderError", { enumerable: true, get: function () { return errors_1.ProviderError; } });
|
|
52
55
|
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return errors_1.RateLimitError; } });
|
|
56
|
+
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return errors_1.NetworkError; } });
|
|
57
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return errors_1.TimeoutError; } });
|
|
58
|
+
// SendGrid-specific errors
|
|
59
|
+
var errors_2 = require("./providers/sendgrid/errors");
|
|
60
|
+
Object.defineProperty(exports, "SendGridApiError", { enumerable: true, get: function () { return errors_2.SendGridApiError; } });
|
|
61
|
+
Object.defineProperty(exports, "TemplateNotFoundError", { enumerable: true, get: function () { return errors_2.TemplateNotFoundError; } });
|
|
62
|
+
Object.defineProperty(exports, "UnauthorizedTemplateAccessError", { enumerable: true, get: function () { return errors_2.UnauthorizedTemplateAccessError; } });
|
|
63
|
+
Object.defineProperty(exports, "TemplateConflictError", { enumerable: true, get: function () { return errors_2.TemplateConflictError; } });
|
|
64
|
+
Object.defineProperty(exports, "SendGridRateLimitError", { enumerable: true, get: function () { return errors_2.SendGridRateLimitError; } });
|
|
65
|
+
Object.defineProperty(exports, "SendGridErrorCode", { enumerable: true, get: function () { return errors_2.SendGridErrorCode; } });
|
|
53
66
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;;;;;AAEF;;;GAGG;AAEH,aAAa;AACb,0CAAwB;AAExB,eAAe;AACf,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;;;;;;;;;;;;;;;AAEF;;;GAGG;AAEH,aAAa;AACb,0CAAwB;AAExB,eAAe;AACf,oDAAqE;AAA5D,2GAAA,WAAW,OAAA;AACpB,oEAAiE;AAAxD,0HAAA,kBAAkB,OAAA;AAE3B,mBAAmB;AACnB,yCAAiD;AAAxC,qGAAA,aAAa,OAAA;AACtB,yCAAgD;AAAvC,oGAAA,YAAY,OAAA;AACrB,iDAAwD;AAA/C,4GAAA,gBAAgB,OAAA;AACzB,uCAA8C;AAArC,kGAAA,WAAW,OAAA;AACpB,+CAAsD;AAA7C,0GAAA,eAAe,OAAA;AACxB,iDAAwD;AAA/C,4GAAA,gBAAgB,OAAA;AAkBzB,gEAAgE;AAChE,mCAQkB;AAPhB,0GAAA,gBAAgB,OAAA;AAChB,8GAAA,oBAAoB,OAAA;AACpB,8GAAA,oBAAoB,OAAA;AACpB,uGAAA,aAAa,OAAA;AACb,wGAAA,cAAc,OAAA;AACd,sGAAA,YAAY,OAAA;AACZ,sGAAA,YAAY,OAAA;AAmBd,2BAA2B;AAC3B,sDAOqC;AANnC,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,yHAAA,+BAA+B,OAAA;AAC/B,+GAAA,qBAAqB,OAAA;AACrB,gHAAA,sBAAsB,OAAA;AACtB,2GAAA,iBAAiB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/providers/sendgrid/client.ts"],"names":[],"mappings":"AAQA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC5C,MAAM,CAAC,EAAE;QACP,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QACjC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QACjC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;KACjC,GAAG,SAAS,CAAC;CACf;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAA6C;IACrE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;gBAE7C,MAAM,EAAE,oBAAoB;IAMlC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/providers/sendgrid/client.ts"],"names":[],"mappings":"AAQA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC5C,MAAM,CAAC,EAAE;QACP,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QACjC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QACjC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;KACjC,GAAG,SAAS,CAAC;CACf;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAA6C;IACrE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;gBAE7C,MAAM,EAAE,oBAAoB;IAMlC,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IA+CjF,iBAAiB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO;IAIjD,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,GAAG,CAAC;CAW/C"}
|
|
@@ -47,7 +47,9 @@ class SendGridClient {
|
|
|
47
47
|
catch (error) {
|
|
48
48
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
49
49
|
this.logger?.error(`SendGrid API error: ${errorMessage}`);
|
|
50
|
-
throw new errors_1.SendGridApiError(`API request failed: ${errorMessage}`,
|
|
50
|
+
throw new errors_1.SendGridApiError(`API request failed: ${errorMessage}`, {
|
|
51
|
+
cause: error instanceof Error ? error : new Error(String(error)),
|
|
52
|
+
});
|
|
51
53
|
}
|
|
52
54
|
finally {
|
|
53
55
|
if (this.rateLimiter) {
|
|
@@ -62,8 +64,12 @@ class SendGridClient {
|
|
|
62
64
|
try {
|
|
63
65
|
return JSON.parse(response.body);
|
|
64
66
|
}
|
|
65
|
-
catch (
|
|
66
|
-
throw new errors_1.SendGridApiError('Failed to parse response body',
|
|
67
|
+
catch (parseError) {
|
|
68
|
+
throw new errors_1.SendGridApiError('Failed to parse response body', {
|
|
69
|
+
statusCode: response.statusCode,
|
|
70
|
+
response: response.body,
|
|
71
|
+
cause: parseError instanceof Error ? parseError : new Error(String(parseError)),
|
|
72
|
+
});
|
|
67
73
|
}
|
|
68
74
|
}
|
|
69
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/providers/sendgrid/client.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAQF,qCAA4C;AAa5C,MAAa,cAAc;IAMzB,YAAY,MAA4B;QAFvB,YAAO,GAAG,6BAA6B,CAAC;QAGvD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,OAA0B;QACxD,oCAAoC;QACpC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QACnC,CAAC;QAED,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,QAAQ,EAAE,CAAC;YAEzC,MAAM,WAAW,GAAgB;gBAC/B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,OAAO,EAAE;oBACP,eAAe,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;oBACxC,cAAc,EAAE,kBAAkB;oBAClC,GAAG,OAAO,CAAC,OAAO;iBACnB;aACF,CAAC;YAEF,IA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C,uBAAuB,YAAY,EAAE,EAAE;gBAChE,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;aACjE,CAAC,CAAC;QACL,CAAC;gBAAS,CAAC;YACT,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IAED,iBAAiB,CAAC,QAAqB;QACrC,OAAO,QAAQ,CAAC,UAAU,IAAI,GAAG,IAAI,QAAQ,CAAC,UAAU,GAAG,GAAG,CAAC;IACjE,CAAC;IAED,iBAAiB,CAAI,QAAqB;QACxC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAM,CAAC;QACxC,CAAC;QAAC,OAAO,UAAU,EAAE,CAAC;YACpB,MAAM,IAAI,yBAAgB,CAAC,+BAA+B,EAAE;gBAC1D,UAAU,EAAE,QAAQ,CAAC,UAAU;gBAC/B,QAAQ,EAAE,QAAQ,CAAC,IAAI;gBACvB,KAAK,EAAE,UAAU,YAAY,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;aAChF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AA1ED,wCA0EC"}
|
|
@@ -1,23 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SendGrid-specific error classes
|
|
3
|
-
*
|
|
2
|
+
* SendGrid-specific error classes with ES2022 Error.cause support
|
|
3
|
+
*
|
|
4
|
+
* These errors follow the error propagation standard defined in:
|
|
5
|
+
* plans/standards/error-propagation-standard.md
|
|
4
6
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
import { ProviderError, EmailSenderError, EmailSenderErrorCode, type EmailSenderErrorOptions } from '../../errors';
|
|
8
|
+
export { EmailSenderError, EmailSenderErrorCode };
|
|
9
|
+
/**
|
|
10
|
+
* Error codes specific to SendGrid operations
|
|
11
|
+
*/
|
|
12
|
+
export declare const SendGridErrorCode: {
|
|
13
|
+
readonly API_ERROR: "SENDGRID_API_ERROR";
|
|
14
|
+
readonly TEMPLATE_NOT_FOUND: "SENDGRID_TEMPLATE_NOT_FOUND";
|
|
15
|
+
readonly TEMPLATE_UNAUTHORIZED: "SENDGRID_TEMPLATE_UNAUTHORIZED";
|
|
16
|
+
readonly TEMPLATE_CONFLICT: "SENDGRID_TEMPLATE_CONFLICT";
|
|
17
|
+
readonly RATE_LIMITED: "SENDGRID_RATE_LIMITED";
|
|
18
|
+
readonly INVALID_SENDER: "SENDGRID_INVALID_SENDER";
|
|
19
|
+
};
|
|
20
|
+
export type SendGridErrorCodeType = typeof SendGridErrorCode[keyof typeof SendGridErrorCode];
|
|
21
|
+
/**
|
|
22
|
+
* SendGrid API error with status code and response details
|
|
23
|
+
*/
|
|
24
|
+
export declare class SendGridApiError extends ProviderError {
|
|
25
|
+
readonly sendGridErrors: Array<{
|
|
26
|
+
message: string;
|
|
27
|
+
field?: string;
|
|
28
|
+
}>;
|
|
29
|
+
constructor(message: string, options?: EmailSenderErrorOptions & {
|
|
30
|
+
statusCode?: number;
|
|
31
|
+
response?: unknown;
|
|
32
|
+
});
|
|
33
|
+
private extractErrors;
|
|
9
34
|
}
|
|
10
|
-
|
|
11
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Error thrown when a SendGrid template is not found
|
|
37
|
+
*/
|
|
38
|
+
export declare class TemplateNotFoundError extends EmailSenderError {
|
|
39
|
+
readonly templateId: string;
|
|
40
|
+
constructor(templateId: string, options?: Omit<EmailSenderErrorOptions, 'code'>);
|
|
12
41
|
}
|
|
13
|
-
|
|
14
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Error thrown when access to a template is unauthorized
|
|
44
|
+
*/
|
|
45
|
+
export declare class UnauthorizedTemplateAccessError extends EmailSenderError {
|
|
46
|
+
readonly templateId: string;
|
|
47
|
+
constructor(templateId: string, options?: Omit<EmailSenderErrorOptions, 'code'>);
|
|
15
48
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Error thrown when template operations conflict
|
|
51
|
+
*/
|
|
52
|
+
export declare class TemplateConflictError extends EmailSenderError {
|
|
53
|
+
readonly templateId: string;
|
|
54
|
+
readonly conflicts: string[];
|
|
55
|
+
constructor(templateId: string, conflicts: string[], options?: Omit<EmailSenderErrorOptions, 'code'>);
|
|
19
56
|
}
|
|
20
|
-
|
|
21
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Error thrown when SendGrid rate limits are exceeded
|
|
59
|
+
*/
|
|
60
|
+
export declare class SendGridRateLimitError extends EmailSenderError {
|
|
61
|
+
constructor(message: string, options?: Omit<EmailSenderErrorOptions, 'code' | 'retryable'> & {
|
|
62
|
+
retryAfter?: number;
|
|
63
|
+
});
|
|
22
64
|
}
|
|
65
|
+
export { SendGridRateLimitError as RateLimitError };
|
|
23
66
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/providers/sendgrid/errors.ts"],"names":[],"mappings":"AAQA
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/providers/sendgrid/errors.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,oBAAoB,EACpB,KAAK,uBAAuB,EAC7B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;CAOpB,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAA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,sBAAsB,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -7,47 +7,154 @@ The client may use and modify this code *only within the scope of the project it
|
|
|
7
7
|
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
8
|
*/
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.RateLimitError = exports.TemplateConflictError = exports.UnauthorizedTemplateAccessError = exports.TemplateNotFoundError = exports.SendGridApiError = void 0;
|
|
10
|
+
exports.RateLimitError = exports.SendGridRateLimitError = exports.TemplateConflictError = exports.UnauthorizedTemplateAccessError = exports.TemplateNotFoundError = exports.SendGridApiError = exports.SendGridErrorCode = exports.EmailSenderErrorCode = exports.EmailSenderError = void 0;
|
|
11
11
|
/**
|
|
12
|
-
* SendGrid-specific error classes
|
|
13
|
-
*
|
|
12
|
+
* SendGrid-specific error classes with ES2022 Error.cause support
|
|
13
|
+
*
|
|
14
|
+
* These errors follow the error propagation standard defined in:
|
|
15
|
+
* plans/standards/error-propagation-standard.md
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const errors_1 = require("../../errors");
|
|
18
|
+
Object.defineProperty(exports, "EmailSenderError", { enumerable: true, get: function () { return errors_1.EmailSenderError; } });
|
|
19
|
+
Object.defineProperty(exports, "EmailSenderErrorCode", { enumerable: true, get: function () { return errors_1.EmailSenderErrorCode; } });
|
|
20
|
+
/**
|
|
21
|
+
* Error codes specific to SendGrid operations
|
|
22
|
+
*/
|
|
23
|
+
exports.SendGridErrorCode = {
|
|
24
|
+
API_ERROR: 'SENDGRID_API_ERROR',
|
|
25
|
+
TEMPLATE_NOT_FOUND: 'SENDGRID_TEMPLATE_NOT_FOUND',
|
|
26
|
+
TEMPLATE_UNAUTHORIZED: 'SENDGRID_TEMPLATE_UNAUTHORIZED',
|
|
27
|
+
TEMPLATE_CONFLICT: 'SENDGRID_TEMPLATE_CONFLICT',
|
|
28
|
+
RATE_LIMITED: 'SENDGRID_RATE_LIMITED',
|
|
29
|
+
INVALID_SENDER: 'SENDGRID_INVALID_SENDER',
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* SendGrid API error with status code and response details
|
|
33
|
+
*/
|
|
34
|
+
class SendGridApiError extends errors_1.ProviderError {
|
|
35
|
+
constructor(message, options) {
|
|
36
|
+
// Determine if retryable based on status code
|
|
37
|
+
const retryable = options?.statusCode !== undefined &&
|
|
38
|
+
(options.statusCode >= 500 || options.statusCode === 429);
|
|
39
|
+
super(message, {
|
|
40
|
+
...options,
|
|
41
|
+
code: errors_1.EmailSenderErrorCode.PROVIDER_ERROR,
|
|
42
|
+
retryable,
|
|
43
|
+
providerResponse: options?.response,
|
|
44
|
+
context: {
|
|
45
|
+
...options?.context,
|
|
46
|
+
provider: 'sendgrid',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
20
49
|
this.name = 'SendGridApiError';
|
|
50
|
+
this.sendGridErrors = this.extractErrors(options?.response);
|
|
51
|
+
}
|
|
52
|
+
extractErrors(response) {
|
|
53
|
+
if (!response || typeof response !== 'object')
|
|
54
|
+
return [];
|
|
55
|
+
const resp = response;
|
|
56
|
+
const errors = resp['errors'];
|
|
57
|
+
if (Array.isArray(errors)) {
|
|
58
|
+
return errors.map((e) => {
|
|
59
|
+
if (typeof e === 'object' && e !== null) {
|
|
60
|
+
const err = e;
|
|
61
|
+
const msg = err['message'];
|
|
62
|
+
const fld = err['field'];
|
|
63
|
+
const result = {
|
|
64
|
+
message: typeof msg === 'string' ? msg : 'Unknown error',
|
|
65
|
+
};
|
|
66
|
+
if (typeof fld === 'string') {
|
|
67
|
+
result.field = fld;
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
return { message: 'Unknown error' };
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return [];
|
|
21
75
|
}
|
|
22
76
|
}
|
|
23
77
|
exports.SendGridApiError = SendGridApiError;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Error thrown when a SendGrid template is not found
|
|
80
|
+
*/
|
|
81
|
+
class TemplateNotFoundError extends errors_1.EmailSenderError {
|
|
82
|
+
constructor(templateId, options) {
|
|
83
|
+
super(`Template not found: ${templateId}`, {
|
|
84
|
+
...options,
|
|
85
|
+
code: errors_1.EmailSenderErrorCode.TEMPLATE_NOT_FOUND,
|
|
86
|
+
context: {
|
|
87
|
+
...options?.context,
|
|
88
|
+
templateId,
|
|
89
|
+
provider: 'sendgrid',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
27
92
|
this.name = 'TemplateNotFoundError';
|
|
93
|
+
this.templateId = templateId;
|
|
28
94
|
}
|
|
29
95
|
}
|
|
30
96
|
exports.TemplateNotFoundError = TemplateNotFoundError;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
97
|
+
/**
|
|
98
|
+
* Error thrown when access to a template is unauthorized
|
|
99
|
+
*/
|
|
100
|
+
class UnauthorizedTemplateAccessError extends errors_1.EmailSenderError {
|
|
101
|
+
constructor(templateId, options) {
|
|
102
|
+
super(`Unauthorized access to template: ${templateId}`, {
|
|
103
|
+
...options,
|
|
104
|
+
code: errors_1.EmailSenderErrorCode.TEMPLATE_UNAUTHORIZED,
|
|
105
|
+
context: {
|
|
106
|
+
...options?.context,
|
|
107
|
+
templateId,
|
|
108
|
+
provider: 'sendgrid',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
34
111
|
this.name = 'UnauthorizedTemplateAccessError';
|
|
112
|
+
this.templateId = templateId;
|
|
35
113
|
}
|
|
36
114
|
}
|
|
37
115
|
exports.UnauthorizedTemplateAccessError = UnauthorizedTemplateAccessError;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Error thrown when template operations conflict
|
|
118
|
+
*/
|
|
119
|
+
class TemplateConflictError extends errors_1.EmailSenderError {
|
|
120
|
+
constructor(templateId, conflicts, options) {
|
|
121
|
+
super(`Template conflict detected for ${templateId}: ${conflicts.join(', ')}`, {
|
|
122
|
+
...options,
|
|
123
|
+
code: errors_1.EmailSenderErrorCode.TEMPLATE_CONFLICT,
|
|
124
|
+
context: {
|
|
125
|
+
...options?.context,
|
|
126
|
+
templateId,
|
|
127
|
+
conflicts,
|
|
128
|
+
provider: 'sendgrid',
|
|
129
|
+
},
|
|
130
|
+
});
|
|
42
131
|
this.name = 'TemplateConflictError';
|
|
132
|
+
this.templateId = templateId;
|
|
133
|
+
this.conflicts = conflicts;
|
|
43
134
|
}
|
|
44
135
|
}
|
|
45
136
|
exports.TemplateConflictError = TemplateConflictError;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Error thrown when SendGrid rate limits are exceeded
|
|
139
|
+
*/
|
|
140
|
+
class SendGridRateLimitError extends errors_1.EmailSenderError {
|
|
141
|
+
constructor(message, options) {
|
|
142
|
+
const baseOptions = {
|
|
143
|
+
...options,
|
|
144
|
+
code: errors_1.EmailSenderErrorCode.PROVIDER_RATE_LIMITED,
|
|
145
|
+
retryable: true,
|
|
146
|
+
context: {
|
|
147
|
+
...options?.context,
|
|
148
|
+
provider: 'sendgrid',
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
if (options?.retryAfter !== undefined) {
|
|
152
|
+
baseOptions.retryAfter = options.retryAfter;
|
|
153
|
+
}
|
|
154
|
+
super(message, baseOptions);
|
|
155
|
+
this.name = 'SendGridRateLimitError';
|
|
50
156
|
}
|
|
51
157
|
}
|
|
52
|
-
exports.
|
|
158
|
+
exports.SendGridRateLimitError = SendGridRateLimitError;
|
|
159
|
+
exports.RateLimitError = SendGridRateLimitError;
|
|
53
160
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/providers/sendgrid/errors.ts"],"names":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CAAC;YACtC,WAAW,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAC9C,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAtBD,wDAsBC;AAGkC,gDAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sender-manager.d.ts","sourceRoot":"","sources":["../../../src/providers/sendgrid/sender-manager.ts"],"names":[],"mappings":"AAQA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAEjB,qBAAa,aAAa;IAMtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAP1B,OAAO,CAAC,YAAY,CAAC,CAAmB;IACxC,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAGhB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,eAAe,EAC1B,MAAM,CAAC,EAAE;QACxB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QAChC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;KAClC,YAAA;IAGG,kBAAkB,CAAC,QAAQ,UAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"sender-manager.d.ts","sourceRoot":"","sources":["../../../src/providers/sendgrid/sender-manager.ts"],"names":[],"mappings":"AAQA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,sBAAsB,EAEvB,MAAM,SAAS,CAAC;AAEjB,qBAAa,aAAa;IAMtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAP1B,OAAO,CAAC,YAAY,CAAC,CAAmB;IACxC,OAAO,CAAC,cAAc,CAAC,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;gBAGhB,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,eAAe,EAC1B,MAAM,CAAC,EAAE;QACxB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;QAChC,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;KAClC,YAAA;IAGG,kBAAkB,CAAC,QAAQ,UAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAmC9D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA8C9D,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IA0BzE,UAAU,IAAI,IAAI;IAMlB,OAAO,CAAC,oBAAoB;CAsB7B"}
|
|
@@ -29,7 +29,10 @@ class SenderManager {
|
|
|
29
29
|
method: 'GET'
|
|
30
30
|
});
|
|
31
31
|
if (!this.client.isSuccessResponse(response)) {
|
|
32
|
-
throw new errors_1.SendGridApiError('Failed to fetch verified senders',
|
|
32
|
+
throw new errors_1.SendGridApiError('Failed to fetch verified senders', {
|
|
33
|
+
statusCode: response.statusCode,
|
|
34
|
+
response: response.body,
|
|
35
|
+
});
|
|
33
36
|
}
|
|
34
37
|
const data = this.client.parseResponseBody(response);
|
|
35
38
|
const senders = data.results.map(sender => this.converter.convertToVerifiedSender(sender));
|