resend 0.11.1 → 0.12.1
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/build/package.json +11 -11
- package/build/src/api-keys/api-keys.d.ts +9 -0
- package/build/src/api-keys/api-keys.js +35 -0
- package/build/src/api-keys/api-keys.spec.d.ts +1 -0
- package/build/src/api-keys/api-keys.spec.js +35 -0
- package/build/src/api-keys/interfaces/create-api-key-options.interface.d.ts +9 -0
- package/build/src/api-keys/interfaces/create-api-key-options.interface.js +2 -0
- package/build/src/api-keys/interfaces/index.d.ts +1 -0
- package/build/src/api-keys/interfaces/index.js +17 -0
- package/build/src/common/interfaces/get-option.interface.d.ts +3 -0
- package/build/src/common/interfaces/get-option.interface.js +2 -0
- package/build/src/common/interfaces/index.d.ts +4 -0
- package/build/src/common/interfaces/index.js +20 -0
- package/build/src/common/interfaces/list-option.interface.d.ts +4 -0
- package/build/src/common/interfaces/list-option.interface.js +2 -0
- package/build/src/common/interfaces/post-option.interface.d.ts +5 -0
- package/build/src/common/interfaces/post-option.interface.js +2 -0
- package/build/src/common/interfaces/put-option.interface.d.ts +5 -0
- package/build/src/common/interfaces/put-option.interface.js +2 -0
- package/build/src/domains/domains.d.ts +9 -0
- package/build/src/domains/domains.js +34 -0
- package/build/src/domains/interfaces/create-domain-options.interface.d.ts +41 -0
- package/build/src/domains/interfaces/create-domain-options.interface.js +2 -0
- package/build/src/domains/interfaces/index.d.ts +1 -0
- package/build/src/domains/interfaces/index.js +17 -0
- package/build/src/index.d.ts +2 -2
- package/build/src/index.js +1 -1
- package/build/src/interfaces.d.ts +13 -5
- package/build/src/resend.d.ts +12 -2
- package/build/src/resend.js +63 -7
- package/build/src/resend.spec.js +5 -5
- package/package.json +11 -11
package/build/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.12.1",
|
|
4
|
+
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/resend-inc/resend-node#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@react-email/render": "0.0.
|
|
31
|
-
"axios": "
|
|
30
|
+
"@react-email/render": "0.0.6",
|
|
31
|
+
"axios": "1.3.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/jest": "
|
|
35
|
-
"@types/node": "18.6
|
|
36
|
-
"@types/react": "18.0.
|
|
34
|
+
"@types/jest": "29.5.0",
|
|
35
|
+
"@types/node": "18.15.6",
|
|
36
|
+
"@types/react": "18.0.29",
|
|
37
37
|
"axios-mock-adapter": "1.21.2",
|
|
38
|
-
"jest": "
|
|
39
|
-
"prettier": "2.8.
|
|
38
|
+
"jest": "29.5.0",
|
|
39
|
+
"prettier": "2.8.7",
|
|
40
40
|
"supertest": "6.3.3",
|
|
41
|
-
"ts-jest": "
|
|
41
|
+
"ts-jest": "29.0.5",
|
|
42
42
|
"tslint": "6.1.3",
|
|
43
|
-
"typescript": "
|
|
43
|
+
"typescript": "5.0.2"
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Resend } from '../resend';
|
|
2
|
+
import { CreateApiKeyOptions, CreateApiKeyRequestOptions, CreateApiKeyResponse } from './interfaces';
|
|
3
|
+
export declare class ApiKeys {
|
|
4
|
+
private readonly resend;
|
|
5
|
+
constructor(resend: Resend);
|
|
6
|
+
create(payload: CreateApiKeyOptions, options?: CreateApiKeyRequestOptions): Promise<CreateApiKeyResponse>;
|
|
7
|
+
list(): Promise<void>;
|
|
8
|
+
remove(id: string): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ApiKeys = void 0;
|
|
13
|
+
class ApiKeys {
|
|
14
|
+
constructor(resend) {
|
|
15
|
+
this.resend = resend;
|
|
16
|
+
}
|
|
17
|
+
create(payload, options = {}) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { data: apiKey } = yield this.resend.post('/api-keys', payload, options);
|
|
20
|
+
return { token: apiKey.data };
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
list() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const { data } = yield this.resend.get('/api-keys');
|
|
26
|
+
return data;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
remove(id) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
yield this.resend.delete(`/api-keys/${id}`);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ApiKeys = ApiKeys;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const axios_mock_adapter_1 = __importDefault(require("axios-mock-adapter"));
|
|
17
|
+
const resend_1 = require("../resend");
|
|
18
|
+
const mock = new axios_mock_adapter_1.default(axios_1.default);
|
|
19
|
+
describe('API Keys', () => {
|
|
20
|
+
describe('create', () => {
|
|
21
|
+
it('creates an api key', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
mock.onPost('/api-keys', { name: 'Test' }).replyOnce(201, {
|
|
23
|
+
data: 're_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk',
|
|
24
|
+
});
|
|
25
|
+
const resend = new resend_1.Resend('re_zKa4RCko_Lhm9ost2YjNCctnPjbLw8Nop');
|
|
26
|
+
yield expect(resend.apiKeys.create({ name: 'Test' })).resolves
|
|
27
|
+
.toMatchInlineSnapshot(`
|
|
28
|
+
{
|
|
29
|
+
"token": "re_PKr4RCko_Lhm9ost2YjNCctnPjbLw8Nqk",
|
|
30
|
+
}
|
|
31
|
+
`);
|
|
32
|
+
expect(mock.history.post.length).toBe(1);
|
|
33
|
+
}));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-api-key-options.interface';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create-api-key-options.interface"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./get-option.interface"), exports);
|
|
18
|
+
__exportStar(require("./list-option.interface"), exports);
|
|
19
|
+
__exportStar(require("./post-option.interface"), exports);
|
|
20
|
+
__exportStar(require("./put-option.interface"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Resend } from '../resend';
|
|
2
|
+
import { CreateDomainOptions, CreateDomainRequestOptions, CreateDomainResponse } from './interfaces';
|
|
3
|
+
export declare class Domains {
|
|
4
|
+
private readonly resend;
|
|
5
|
+
constructor(resend: Resend);
|
|
6
|
+
create(payload: CreateDomainOptions, options?: CreateDomainRequestOptions): Promise<CreateDomainResponse>;
|
|
7
|
+
remove(id: string): Promise<void>;
|
|
8
|
+
verify(id: string): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Domains = void 0;
|
|
13
|
+
class Domains {
|
|
14
|
+
constructor(resend) {
|
|
15
|
+
this.resend = resend;
|
|
16
|
+
}
|
|
17
|
+
create(payload, options = {}) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const { data } = yield this.resend.post('/domains', payload, options);
|
|
20
|
+
return data;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
remove(id) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
yield this.resend.delete(`/domains/${id}`);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
verify(id) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
yield this.resend.post(`/domains/${id}/verify`);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.Domains = Domains;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PostOptions } from '../../common/interfaces';
|
|
2
|
+
export type DomainRegion = 'us-east-1' | 'eu-west-1' | 'sa-east-1';
|
|
3
|
+
export interface CreateDomainOptions {
|
|
4
|
+
domain: string;
|
|
5
|
+
region?: DomainRegion;
|
|
6
|
+
}
|
|
7
|
+
export interface CreateDomainRequestOptions extends PostOptions {
|
|
8
|
+
}
|
|
9
|
+
export type DomainNameservers = 'Amazon Route 53' | 'Cloudflare' | 'Digital Ocean' | 'GoDaddy' | 'Google Domains' | 'Namecheap' | 'Unidentified' | 'Vercel';
|
|
10
|
+
export type DomainStatus = 'pending' | 'verified' | 'failed' | 'temporary_failure' | 'not_started';
|
|
11
|
+
export interface DomainSpfRecord {
|
|
12
|
+
record: 'SPF';
|
|
13
|
+
name: string;
|
|
14
|
+
value: string;
|
|
15
|
+
type: 'MX' | 'TXT';
|
|
16
|
+
ttl: string;
|
|
17
|
+
status: DomainStatus;
|
|
18
|
+
routingPolicy?: string;
|
|
19
|
+
priority?: number;
|
|
20
|
+
proxStatus?: 'enable' | 'disable';
|
|
21
|
+
}
|
|
22
|
+
export interface DomainDkimRecord {
|
|
23
|
+
record: 'DKIM';
|
|
24
|
+
name: string;
|
|
25
|
+
value: string;
|
|
26
|
+
type: 'CNAME';
|
|
27
|
+
ttl: string;
|
|
28
|
+
status: DomainStatus;
|
|
29
|
+
routingPolicy?: string;
|
|
30
|
+
priority?: number;
|
|
31
|
+
proxStatus?: 'enable' | 'disable';
|
|
32
|
+
}
|
|
33
|
+
export type CreateDomainResponse = {
|
|
34
|
+
name: string;
|
|
35
|
+
id: string;
|
|
36
|
+
dnsProvider: DomainNameservers;
|
|
37
|
+
status: DomainStatus;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
records: (DomainSpfRecord | DomainDkimRecord)[];
|
|
40
|
+
region: DomainRegion;
|
|
41
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './create-domain-options.interface';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./create-domain-options.interface"), exports);
|
package/build/src/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
1
|
+
export { Resend } from './resend';
|
|
2
|
+
export { SendEmailResponse, EmailResponse, ErrorResponse, SendEmailData, } from './interfaces';
|
package/build/src/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Resend = void 0;
|
|
4
|
-
|
|
4
|
+
var resend_1 = require("./resend");
|
|
5
5
|
Object.defineProperty(exports, "Resend", { enumerable: true, get: function () { return resend_1.Resend; } });
|
|
@@ -12,7 +12,7 @@ export interface SendEmailData {
|
|
|
12
12
|
/** Reply-to email address. Max 50. */
|
|
13
13
|
reply_to?: string | string[];
|
|
14
14
|
/** Email subject. */
|
|
15
|
-
subject
|
|
15
|
+
subject: string;
|
|
16
16
|
/** The plain text version of the message. */
|
|
17
17
|
text?: string;
|
|
18
18
|
/** The HTML version of the message. */
|
|
@@ -21,6 +21,8 @@ export interface SendEmailData {
|
|
|
21
21
|
react?: ReactElement;
|
|
22
22
|
/** Attachments */
|
|
23
23
|
attachments?: Attachment[];
|
|
24
|
+
/** Email tags */
|
|
25
|
+
tags?: Tag[];
|
|
24
26
|
}
|
|
25
27
|
interface Attachment {
|
|
26
28
|
content?: string | Buffer;
|
|
@@ -38,13 +40,15 @@ export interface SendEmailRequest {
|
|
|
38
40
|
/** Reply-to email address. Max 50. */
|
|
39
41
|
reply_to?: string | string[];
|
|
40
42
|
/** Email subject. */
|
|
41
|
-
subject
|
|
43
|
+
subject: string;
|
|
42
44
|
/** The HTML version of the message. */
|
|
43
45
|
text?: string;
|
|
44
46
|
/** The plain text version of the message. */
|
|
45
47
|
html?: string;
|
|
46
48
|
/** Attachments */
|
|
47
|
-
attachments?:
|
|
49
|
+
attachments?: Attachment[];
|
|
50
|
+
/** Email tags */
|
|
51
|
+
tags?: Tag[];
|
|
48
52
|
}
|
|
49
53
|
interface EmailResponse extends Pick<SendEmailRequest, 'to' | 'from'> {
|
|
50
54
|
id: string;
|
|
@@ -57,5 +61,9 @@ interface ErrorResponse {
|
|
|
57
61
|
type: string;
|
|
58
62
|
};
|
|
59
63
|
}
|
|
60
|
-
export
|
|
61
|
-
export {};
|
|
64
|
+
export type SendEmailResponse = EmailResponse | ErrorResponse;
|
|
65
|
+
export { EmailResponse, ErrorResponse };
|
|
66
|
+
export type Tag = {
|
|
67
|
+
name: string;
|
|
68
|
+
value: string;
|
|
69
|
+
};
|
package/build/src/resend.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
1
2
|
import { SendEmailData, SendEmailResponse } from './interfaces';
|
|
3
|
+
import { GetOptions, PostOptions, PutOptions } from './common/interfaces';
|
|
4
|
+
import { ApiKeys } from './api-keys/api-keys';
|
|
5
|
+
import { Domains } from './domains/domains';
|
|
2
6
|
export declare class Resend {
|
|
3
|
-
readonly
|
|
7
|
+
readonly key?: string | undefined;
|
|
4
8
|
readonly baseUrl: string;
|
|
5
9
|
private readonly headers;
|
|
6
10
|
private readonly request;
|
|
7
|
-
|
|
11
|
+
readonly apiKeys: ApiKeys;
|
|
12
|
+
readonly domains: Domains;
|
|
13
|
+
constructor(key?: string | undefined);
|
|
14
|
+
post(path: string, entity?: any, options?: PostOptions): Promise<AxiosResponse>;
|
|
15
|
+
get(path: string, options?: GetOptions): Promise<AxiosResponse>;
|
|
16
|
+
put(path: string, entity: any, options?: PutOptions): Promise<AxiosResponse>;
|
|
17
|
+
delete(path: string, query?: any): Promise<AxiosResponse>;
|
|
8
18
|
sendEmail(data: SendEmailData): Promise<SendEmailResponse>;
|
|
9
19
|
}
|
package/build/src/resend.js
CHANGED
|
@@ -16,19 +16,22 @@ exports.Resend = void 0;
|
|
|
16
16
|
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
const render_1 = require("@react-email/render");
|
|
18
18
|
const package_json_1 = require("../package.json");
|
|
19
|
+
const api_keys_1 = require("./api-keys/api-keys");
|
|
20
|
+
const domains_1 = require("./domains/domains");
|
|
19
21
|
class Resend {
|
|
20
|
-
constructor(
|
|
21
|
-
this.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
constructor(key) {
|
|
23
|
+
this.key = key;
|
|
24
|
+
this.apiKeys = new api_keys_1.ApiKeys(this);
|
|
25
|
+
this.domains = new domains_1.Domains(this);
|
|
26
|
+
if (!key) {
|
|
27
|
+
this.key = process.env.RESEND_API_KEY;
|
|
28
|
+
if (!this.key) {
|
|
25
29
|
throw new Error('Missing API key. Pass it to the constructor `new Resend("re_123")`');
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
this.apiKey = apiKey;
|
|
29
32
|
this.baseUrl = process.env.RESEND_BASE_URL || 'https://api.resend.com';
|
|
30
33
|
this.headers = {
|
|
31
|
-
Authorization: `Bearer ${this.
|
|
34
|
+
Authorization: `Bearer ${this.key}`,
|
|
32
35
|
'User-Agent': `node:${package_json_1.version}`,
|
|
33
36
|
'Content-Type': 'application/json',
|
|
34
37
|
};
|
|
@@ -51,6 +54,58 @@ class Resend {
|
|
|
51
54
|
return Promise.reject(error);
|
|
52
55
|
});
|
|
53
56
|
}
|
|
57
|
+
post(path, entity, options) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const requestHeaders = {};
|
|
60
|
+
try {
|
|
61
|
+
return yield this.request.post(path, entity, {
|
|
62
|
+
params: options === null || options === void 0 ? void 0 : options.query,
|
|
63
|
+
headers: requestHeaders,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
get(path, options = {}) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
try {
|
|
74
|
+
return yield this.request.get(path, {
|
|
75
|
+
params: options.query,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
put(path, entity, options = {}) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
const requestHeaders = {};
|
|
86
|
+
try {
|
|
87
|
+
return yield this.request.put(path, entity, {
|
|
88
|
+
params: options.query,
|
|
89
|
+
headers: requestHeaders,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
delete(path, query) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
try {
|
|
100
|
+
return yield this.request.delete(path, {
|
|
101
|
+
params: query,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
54
109
|
sendEmail(data) {
|
|
55
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
111
|
try {
|
|
@@ -69,6 +124,7 @@ class Resend {
|
|
|
69
124
|
text: data.text,
|
|
70
125
|
html: data.html,
|
|
71
126
|
attachments: data.attachments,
|
|
127
|
+
tags: data.tags,
|
|
72
128
|
};
|
|
73
129
|
const response = yield this.request(path, {
|
|
74
130
|
method: 'POST',
|
package/build/src/resend.spec.js
CHANGED
|
@@ -28,7 +28,7 @@ describe('Resend', () => {
|
|
|
28
28
|
to: 'zeno@resend.com',
|
|
29
29
|
subject: 'Hello World',
|
|
30
30
|
};
|
|
31
|
-
mock.onPost('
|
|
31
|
+
mock.onPost('/email', payload).replyOnce(200, {
|
|
32
32
|
id: '1234',
|
|
33
33
|
from: 'bu@resend.com',
|
|
34
34
|
to: 'zeno@resend.com',
|
|
@@ -43,7 +43,7 @@ describe('Resend', () => {
|
|
|
43
43
|
to: ['bu@resend.com', 'zeno@resend.com'],
|
|
44
44
|
subject: 'Hello World',
|
|
45
45
|
};
|
|
46
|
-
mock.onPost('
|
|
46
|
+
mock.onPost('/email', payload).replyOnce(200, {
|
|
47
47
|
id: '1234',
|
|
48
48
|
from: 'admin@resend.com',
|
|
49
49
|
to: ['bu@resend.com', 'zeno@resend.com'],
|
|
@@ -59,7 +59,7 @@ describe('Resend', () => {
|
|
|
59
59
|
bcc: ['foo@resend.com', 'bar@resend.com'],
|
|
60
60
|
subject: 'Hello World',
|
|
61
61
|
};
|
|
62
|
-
mock.onPost('
|
|
62
|
+
mock.onPost('/email', payload).replyOnce(200, {
|
|
63
63
|
id: '1234',
|
|
64
64
|
from: 'admin@resend.com',
|
|
65
65
|
to: 'bu@resend.com',
|
|
@@ -76,7 +76,7 @@ describe('Resend', () => {
|
|
|
76
76
|
cc: ['foo@resend.com', 'bar@resend.com'],
|
|
77
77
|
subject: 'Hello World',
|
|
78
78
|
};
|
|
79
|
-
mock.onPost('
|
|
79
|
+
mock.onPost('/email', payload).replyOnce(200, {
|
|
80
80
|
id: '1234',
|
|
81
81
|
from: 'admin@resend.com',
|
|
82
82
|
to: 'bu@resend.com',
|
|
@@ -93,7 +93,7 @@ describe('Resend', () => {
|
|
|
93
93
|
reply_to: ['foo@resend.com', 'bar@resend.com'],
|
|
94
94
|
subject: 'Hello World',
|
|
95
95
|
};
|
|
96
|
-
mock.onPost('
|
|
96
|
+
mock.onPost('/email', apiPayload).replyOnce(200, {
|
|
97
97
|
id: '1234',
|
|
98
98
|
from: 'admin@resend.com',
|
|
99
99
|
to: 'bu@resend.com',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "0.12.1",
|
|
4
|
+
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
},
|
|
28
28
|
"homepage": "https://github.com/resend-inc/resend-node#readme",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@react-email/render": "0.0.
|
|
31
|
-
"axios": "
|
|
30
|
+
"@react-email/render": "0.0.6",
|
|
31
|
+
"axios": "1.3.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/jest": "
|
|
35
|
-
"@types/node": "18.6
|
|
36
|
-
"@types/react": "18.0.
|
|
34
|
+
"@types/jest": "29.5.0",
|
|
35
|
+
"@types/node": "18.15.6",
|
|
36
|
+
"@types/react": "18.0.29",
|
|
37
37
|
"axios-mock-adapter": "1.21.2",
|
|
38
|
-
"jest": "
|
|
39
|
-
"prettier": "2.8.
|
|
38
|
+
"jest": "29.5.0",
|
|
39
|
+
"prettier": "2.8.7",
|
|
40
40
|
"supertest": "6.3.3",
|
|
41
|
-
"ts-jest": "
|
|
41
|
+
"ts-jest": "29.0.5",
|
|
42
42
|
"tslint": "6.1.3",
|
|
43
|
-
"typescript": "
|
|
43
|
+
"typescript": "5.0.2"
|
|
44
44
|
}
|
|
45
45
|
}
|