Skip to content

Commit bef974a

Browse files
authored
feat: allow creating domain with capabilities through the api (#682)
1 parent 9a59a06 commit bef974a

File tree

6 files changed

+72
-3
lines changed

6 files changed

+72
-3
lines changed

src/common/interfaces/domain-api-options.interface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export interface DomainApiOptions {
22
name: string;
33
region?: string;
44
custom_return_path?: string;
5+
capability?: 'send' | 'receive' | 'send-and-receive';
56
}

src/common/utils/parse-domain-to-api-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function parseDomainToApiOptions(
77
return {
88
name: domain.name,
99
region: domain.region,
10+
capability: domain.capability,
1011
custom_return_path: domain.customReturnPath,
1112
};
1213
}

src/domains/domains.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('Domains', () => {
2525
const response: CreateDomainResponseSuccess = {
2626
id: '3d4a472d-bc6d-4dd2-aa9d-d3d50ce87222',
2727
name: 'resend.com',
28+
capability: 'send-and-receive',
2829
created_at: '2023-04-07T22:48:33.420498+00:00',
2930
status: 'not_started',
3031
records: [
@@ -69,6 +70,15 @@ describe('Domains', () => {
6970
status: 'not_started',
7071
ttl: 'Auto',
7172
},
73+
{
74+
record: 'Receiving',
75+
name: 'resend.com',
76+
value: 'inbound-mx.resend.com',
77+
type: 'MX',
78+
ttl: 'Auto',
79+
status: 'not_started',
80+
priority: 10,
81+
},
7282
],
7383
region: 'us-east-1',
7484
};
@@ -87,6 +97,7 @@ describe('Domains', () => {
8797
).resolves.toMatchInlineSnapshot(`
8898
{
8999
"data": {
100+
"capability": "send-and-receive",
90101
"created_at": "2023-04-07T22:48:33.420498+00:00",
91102
"id": "3d4a472d-bc6d-4dd2-aa9d-d3d50ce87222",
92103
"name": "resend.com",
@@ -132,6 +143,15 @@ describe('Domains', () => {
132143
"type": "CNAME",
133144
"value": "eeaemodxoao5hxwjvhywx4bo5mswjw6v.dkim.com.",
134145
},
146+
{
147+
"name": "resend.com",
148+
"priority": 10,
149+
"record": "Receiving",
150+
"status": "not_started",
151+
"ttl": "Auto",
152+
"type": "MX",
153+
"value": "inbound-mx.resend.com",
154+
},
135155
],
136156
"region": "us-east-1",
137157
"status": "not_started",
@@ -179,6 +199,7 @@ describe('Domains', () => {
179199
const response: CreateDomainResponseSuccess = {
180200
id: '3d4a472d-bc6d-4dd2-aa9d-d3d50ce87222',
181201
name: 'resend.com',
202+
capability: 'send',
182203
created_at: '2023-04-07T22:48:33.420498+00:00',
183204
status: 'not_started',
184205
records: [
@@ -238,6 +259,7 @@ describe('Domains', () => {
238259
).resolves.toMatchInlineSnapshot(`
239260
{
240261
"data": {
262+
"capability": "send",
241263
"created_at": "2023-04-07T22:48:33.420498+00:00",
242264
"id": "3d4a472d-bc6d-4dd2-aa9d-d3d50ce87222",
243265
"name": "resend.com",
@@ -330,6 +352,7 @@ describe('Domains', () => {
330352
const response: CreateDomainResponseSuccess = {
331353
id: '3d4a472d-bc6d-4dd2-aa9d-d3d50ce87222',
332354
name: 'resend.com',
355+
capability: 'send',
333356
created_at: '2023-04-07T22:48:33.420498+00:00',
334357
status: 'not_started',
335358
records: [
@@ -381,6 +404,7 @@ describe('Domains', () => {
381404
).resolves.toMatchInlineSnapshot(`
382405
{
383406
"data": {
407+
"capability": "send",
384408
"created_at": "2023-04-07T22:48:33.420498+00:00",
385409
"id": "3d4a472d-bc6d-4dd2-aa9d-d3d50ce87222",
386410
"name": "resend.com",
@@ -432,13 +456,15 @@ describe('Domains', () => {
432456
status: 'not_started',
433457
created_at: '2023-04-07T23:13:52.669661+00:00',
434458
region: 'eu-west-1',
459+
capability: 'send',
435460
},
436461
{
437462
id: 'ac7503ac-e027-4aea-94b3-b0acd46f65f9',
438463
name: 'react.email',
439464
status: 'not_started',
440465
created_at: '2023-04-07T23:13:20.417116+00:00',
441466
region: 'us-east-1',
467+
capability: 'receive',
442468
},
443469
],
444470
};
@@ -576,6 +602,7 @@ describe('Domains', () => {
576602
object: 'domain',
577603
id: 'fd61172c-cafc-40f5-b049-b45947779a29',
578604
name: 'resend.com',
605+
capability: 'send-and-receive',
579606
status: 'not_started',
580607
created_at: '2023-06-21T06:10:36.144Z',
581608
region: 'us-east-1',
@@ -606,6 +633,15 @@ describe('Domains', () => {
606633
status: 'verified',
607634
ttl: 'Auto',
608635
},
636+
{
637+
record: 'Receiving',
638+
name: 'resend.com',
639+
value: 'inbound-mx.resend.com',
640+
type: 'MX',
641+
ttl: 'Auto',
642+
status: 'not_started',
643+
priority: 10,
644+
},
609645
],
610646
};
611647

@@ -622,6 +658,7 @@ describe('Domains', () => {
622658
await expect(resend.domains.get('1234')).resolves.toMatchInlineSnapshot(`
623659
{
624660
"data": {
661+
"capability": "send-and-receive",
625662
"created_at": "2023-06-21T06:10:36.144Z",
626663
"id": "fd61172c-cafc-40f5-b049-b45947779a29",
627664
"name": "resend.com",
@@ -652,6 +689,15 @@ describe('Domains', () => {
652689
"type": "TXT",
653690
"value": "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDZDhdsAKs5xdSj7h3v22wjx3WMWWADCHwxfef8U03JUbVM/sNSVuY5mbrdJKUoG6QBdfxsOGzhINmQnT89idjp5GdAUhx/KNpt8hcLXMID4nB0Gbcafn03/z5zEPxPfzVJqQd/UqOtZQcfxN9OrIhLiBsYTbcTBB7EvjCb3wEaBwIDAQAB",
654691
},
692+
{
693+
"name": "resend.com",
694+
"priority": 10,
695+
"record": "Receiving",
696+
"status": "not_started",
697+
"ttl": "Auto",
698+
"type": "MX",
699+
"value": "inbound-mx.resend.com",
700+
},
655701
],
656702
"region": "us-east-1",
657703
"status": "not_started",

src/domains/interfaces/create-domain-options.interface.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@ export interface CreateDomainOptions {
66
name: string;
77
region?: DomainRegion;
88
customReturnPath?: string;
9+
capability?: 'send' | 'receive' | 'send-and-receive';
910
}
1011

1112
export interface CreateDomainRequestOptions extends PostOptions {}
1213

1314
export interface CreateDomainResponseSuccess
14-
extends Pick<Domain, 'name' | 'id' | 'status' | 'created_at' | 'region'> {
15+
extends Pick<
16+
Domain,
17+
'name' | 'id' | 'status' | 'created_at' | 'region' | 'capability'
18+
> {
1519
records: DomainRecords[];
1620
}
1721

src/domains/interfaces/domain.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ export type DomainStatus =
2121
| 'temporary_failure'
2222
| 'not_started';
2323

24-
export type DomainRecords = DomainSpfRecord | DomainDkimRecord;
24+
export type DomainRecords =
25+
| DomainSpfRecord
26+
| DomainDkimRecord
27+
| ReceivingRecord;
2528

2629
export interface DomainSpfRecord {
2730
record: 'SPF';
@@ -47,10 +50,21 @@ export interface DomainDkimRecord {
4750
proxy_status?: 'enable' | 'disable';
4851
}
4952

53+
export interface ReceivingRecord {
54+
record: 'Receiving';
55+
name: string;
56+
value: string;
57+
type: 'MX';
58+
ttl: string;
59+
status: DomainStatus;
60+
priority: number;
61+
}
62+
5063
export interface Domain {
5164
id: string;
5265
name: string;
5366
status: DomainStatus;
5467
created_at: string;
5568
region: DomainRegion;
69+
capability: 'send' | 'receive' | 'send-and-receive';
5670
}

src/domains/interfaces/get-domain.interface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ import type { ErrorResponse } from '../../interfaces';
22
import type { Domain, DomainRecords } from './domain';
33

44
export interface GetDomainResponseSuccess
5-
extends Pick<Domain, 'id' | 'name' | 'created_at' | 'region' | 'status'> {
5+
extends Pick<
6+
Domain,
7+
'id' | 'name' | 'created_at' | 'region' | 'status' | 'capability'
8+
> {
69
object: 'domain';
710
records: DomainRecords[];
811
}

0 commit comments

Comments
 (0)