resend 6.1.2-preview-templates.1 → 6.1.3
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.d.mts +11 -201
- package/dist/index.d.ts +11 -201
- package/dist/index.js +2 -151
- package/dist/index.mjs +2 -151
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -48,9 +48,9 @@ interface EmailApiAttachment {
|
|
|
48
48
|
content_id?: string;
|
|
49
49
|
}
|
|
50
50
|
interface EmailApiOptions {
|
|
51
|
-
from
|
|
51
|
+
from: string;
|
|
52
52
|
to: string | string[];
|
|
53
|
-
subject
|
|
53
|
+
subject: string;
|
|
54
54
|
region?: string;
|
|
55
55
|
headers?: Record<string, string>;
|
|
56
56
|
html?: string;
|
|
@@ -61,10 +61,6 @@ interface EmailApiOptions {
|
|
|
61
61
|
scheduled_at?: string;
|
|
62
62
|
tags?: Tag$1[];
|
|
63
63
|
attachments?: EmailApiAttachment[];
|
|
64
|
-
template?: {
|
|
65
|
-
id: string;
|
|
66
|
-
variables?: Record<string, string | number | boolean>;
|
|
67
|
-
};
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
interface GetOptions {
|
|
@@ -81,6 +77,11 @@ interface IdempotentRequest {
|
|
|
81
77
|
idempotencyKey?: string;
|
|
82
78
|
}
|
|
83
79
|
|
|
80
|
+
interface List<T> {
|
|
81
|
+
readonly object: 'list';
|
|
82
|
+
data: T[];
|
|
83
|
+
}
|
|
84
|
+
|
|
84
85
|
type PaginationOptions = {
|
|
85
86
|
/**
|
|
86
87
|
* Maximum number of items to return (1-100, default: 20)
|
|
@@ -246,16 +247,6 @@ interface EmailRenderOptions$1 {
|
|
|
246
247
|
*/
|
|
247
248
|
text: string;
|
|
248
249
|
}
|
|
249
|
-
interface EmailTemplateOptions {
|
|
250
|
-
template: {
|
|
251
|
-
id: string;
|
|
252
|
-
variables?: Record<string, string | number | boolean>;
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
interface CreateEmailBaseOptionsWithTemplate extends Omit<CreateEmailBaseOptions, 'from' | 'subject'> {
|
|
256
|
-
from?: string;
|
|
257
|
-
subject?: string;
|
|
258
|
-
}
|
|
259
250
|
interface CreateEmailBaseOptions {
|
|
260
251
|
/**
|
|
261
252
|
* Filename and content of attachments (max 40mb per email)
|
|
@@ -319,13 +310,7 @@ interface CreateEmailBaseOptions {
|
|
|
319
310
|
*/
|
|
320
311
|
scheduledAt?: string;
|
|
321
312
|
}
|
|
322
|
-
type CreateEmailOptions =
|
|
323
|
-
template?: never;
|
|
324
|
-
}) | ((EmailTemplateOptions & CreateEmailBaseOptionsWithTemplate) & {
|
|
325
|
-
react?: never;
|
|
326
|
-
html?: never;
|
|
327
|
-
text?: never;
|
|
328
|
-
});
|
|
313
|
+
type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions$1> & CreateEmailBaseOptions;
|
|
329
314
|
interface CreateEmailRequestOptions extends PostOptions, IdempotentRequest {
|
|
330
315
|
}
|
|
331
316
|
interface CreateEmailResponseSuccess {
|
|
@@ -412,6 +397,8 @@ interface Broadcast {
|
|
|
412
397
|
created_at: string;
|
|
413
398
|
scheduled_at: string | null;
|
|
414
399
|
sent_at: string | null;
|
|
400
|
+
html: string | null;
|
|
401
|
+
text: string | null;
|
|
415
402
|
}
|
|
416
403
|
|
|
417
404
|
interface EmailRenderOptions {
|
|
@@ -945,182 +932,6 @@ declare class Emails {
|
|
|
945
932
|
cancel(id: string): Promise<CancelEmailResponse>;
|
|
946
933
|
}
|
|
947
934
|
|
|
948
|
-
interface Template {
|
|
949
|
-
id: string;
|
|
950
|
-
name: string;
|
|
951
|
-
subject: string | null;
|
|
952
|
-
html: string;
|
|
953
|
-
text: string | null;
|
|
954
|
-
status: 'draft' | 'published';
|
|
955
|
-
variables: TemplateVariable[] | null;
|
|
956
|
-
alias: string | null;
|
|
957
|
-
from: string | null;
|
|
958
|
-
reply_to: string[] | null;
|
|
959
|
-
published_at: string | null;
|
|
960
|
-
created_at: string;
|
|
961
|
-
updated_at: string;
|
|
962
|
-
has_unpublished_versions: boolean;
|
|
963
|
-
current_version_id: string;
|
|
964
|
-
}
|
|
965
|
-
type TemplateVariableListFallbackType = string[] | number[] | boolean[] | Record<string, unknown>[];
|
|
966
|
-
interface TemplateVariable {
|
|
967
|
-
key: string;
|
|
968
|
-
fallback_value: string | number | boolean | Record<string, unknown> | TemplateVariableListFallbackType | null;
|
|
969
|
-
type: 'string' | 'number' | 'boolean' | 'object' | 'list';
|
|
970
|
-
created_at: string;
|
|
971
|
-
updated_at: string;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
type TemplateContentCreationOptions = RequireAtLeastOne<{
|
|
975
|
-
html: string;
|
|
976
|
-
react: React.ReactNode;
|
|
977
|
-
}>;
|
|
978
|
-
type TemplateVariableCreationOptions = Pick<TemplateVariable, 'key' | 'type'> & ({
|
|
979
|
-
type: 'string';
|
|
980
|
-
fallbackValue?: string | null;
|
|
981
|
-
} | {
|
|
982
|
-
type: 'number';
|
|
983
|
-
fallbackValue?: number | null;
|
|
984
|
-
} | {
|
|
985
|
-
type: 'boolean';
|
|
986
|
-
fallbackValue?: boolean | null;
|
|
987
|
-
} | {
|
|
988
|
-
type: 'object';
|
|
989
|
-
fallbackValue: Record<string, unknown>;
|
|
990
|
-
} | {
|
|
991
|
-
type: 'list';
|
|
992
|
-
fallbackValue: TemplateVariableListFallbackType;
|
|
993
|
-
});
|
|
994
|
-
type TemplateOptionalFieldsForCreation = Partial<Pick<Template, 'subject' | 'text' | 'alias' | 'from'>> & {
|
|
995
|
-
replyTo?: string[] | string;
|
|
996
|
-
variables?: TemplateVariableCreationOptions[];
|
|
997
|
-
};
|
|
998
|
-
type CreateTemplateOptions = Pick<Template, 'name'> & TemplateOptionalFieldsForCreation & TemplateContentCreationOptions;
|
|
999
|
-
interface CreateTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1000
|
-
object: 'template';
|
|
1001
|
-
}
|
|
1002
|
-
type CreateTemplateResponse = {
|
|
1003
|
-
data: CreateTemplateResponseSuccess;
|
|
1004
|
-
error: null;
|
|
1005
|
-
} | {
|
|
1006
|
-
data: null;
|
|
1007
|
-
error: ErrorResponse;
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
interface DuplicateTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1011
|
-
object: 'template';
|
|
1012
|
-
}
|
|
1013
|
-
type DuplicateTemplateResponse = {
|
|
1014
|
-
data: DuplicateTemplateResponseSuccess;
|
|
1015
|
-
error: null;
|
|
1016
|
-
} | {
|
|
1017
|
-
data: null;
|
|
1018
|
-
error: ErrorResponse;
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
interface PublishTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1022
|
-
object: 'template';
|
|
1023
|
-
}
|
|
1024
|
-
type PublishTemplateResponse = {
|
|
1025
|
-
data: PublishTemplateResponseSuccess;
|
|
1026
|
-
error: null;
|
|
1027
|
-
} | {
|
|
1028
|
-
data: null;
|
|
1029
|
-
error: ErrorResponse;
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
declare class ChainableTemplateResult<T extends CreateTemplateResponse | DuplicateTemplateResponse> implements PromiseLike<T> {
|
|
1033
|
-
private readonly promise;
|
|
1034
|
-
private readonly publishFn;
|
|
1035
|
-
constructor(promise: Promise<T>, publishFn: (id: string) => Promise<PublishTemplateResponse>);
|
|
1036
|
-
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
1037
|
-
publish(): Promise<PublishTemplateResponse>;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
interface GetTemplateResponseSuccess extends Template {
|
|
1041
|
-
object: 'template';
|
|
1042
|
-
}
|
|
1043
|
-
type GetTemplateResponse = {
|
|
1044
|
-
data: GetTemplateResponseSuccess;
|
|
1045
|
-
error: null;
|
|
1046
|
-
} | {
|
|
1047
|
-
data: null;
|
|
1048
|
-
error: ErrorResponse;
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
interface TemplateListItem extends Pick<Template, 'id' | 'name' | 'created_at' | 'updated_at' | 'status' | 'published_at' | 'alias'> {
|
|
1052
|
-
}
|
|
1053
|
-
interface ListTemplatesResponseSuccess {
|
|
1054
|
-
object: 'list';
|
|
1055
|
-
data: TemplateListItem[];
|
|
1056
|
-
has_more: boolean;
|
|
1057
|
-
}
|
|
1058
|
-
type ListTemplatesResponse = {
|
|
1059
|
-
data: ListTemplatesResponseSuccess;
|
|
1060
|
-
error: null;
|
|
1061
|
-
} | {
|
|
1062
|
-
data: null;
|
|
1063
|
-
error: ErrorResponse;
|
|
1064
|
-
};
|
|
1065
|
-
|
|
1066
|
-
interface RemoveTemplateResponseSuccess {
|
|
1067
|
-
object: 'template';
|
|
1068
|
-
id: string;
|
|
1069
|
-
deleted: boolean;
|
|
1070
|
-
}
|
|
1071
|
-
type RemoveTemplateResponse = {
|
|
1072
|
-
data: RemoveTemplateResponseSuccess;
|
|
1073
|
-
error: null;
|
|
1074
|
-
} | {
|
|
1075
|
-
data: null;
|
|
1076
|
-
error: ErrorResponse;
|
|
1077
|
-
};
|
|
1078
|
-
|
|
1079
|
-
type TemplateVariableUpdateOptions = Pick<TemplateVariable, 'key' | 'type'> & ({
|
|
1080
|
-
type: 'string';
|
|
1081
|
-
fallbackValue?: string | null;
|
|
1082
|
-
} | {
|
|
1083
|
-
type: 'number';
|
|
1084
|
-
fallbackValue?: number | null;
|
|
1085
|
-
} | {
|
|
1086
|
-
type: 'boolean';
|
|
1087
|
-
fallbackValue?: boolean | null;
|
|
1088
|
-
} | {
|
|
1089
|
-
type: 'object';
|
|
1090
|
-
fallbackValue: Record<string, unknown>;
|
|
1091
|
-
} | {
|
|
1092
|
-
type: 'list';
|
|
1093
|
-
fallbackValue: TemplateVariableListFallbackType;
|
|
1094
|
-
});
|
|
1095
|
-
interface UpdateTemplateOptions extends Partial<Pick<Template, 'name' | 'subject' | 'html' | 'text' | 'from' | 'alias'>> {
|
|
1096
|
-
variables?: TemplateVariableUpdateOptions[];
|
|
1097
|
-
replyTo?: string[] | string;
|
|
1098
|
-
}
|
|
1099
|
-
interface UpdateTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1100
|
-
object: 'template';
|
|
1101
|
-
}
|
|
1102
|
-
type UpdateTemplateResponse = {
|
|
1103
|
-
data: UpdateTemplateResponseSuccess;
|
|
1104
|
-
error: null;
|
|
1105
|
-
} | {
|
|
1106
|
-
data: null;
|
|
1107
|
-
error: ErrorResponse;
|
|
1108
|
-
};
|
|
1109
|
-
|
|
1110
|
-
declare class Templates {
|
|
1111
|
-
private readonly resend;
|
|
1112
|
-
private renderAsync?;
|
|
1113
|
-
constructor(resend: Resend);
|
|
1114
|
-
create(payload: CreateTemplateOptions): ChainableTemplateResult<CreateTemplateResponse>;
|
|
1115
|
-
private performCreate;
|
|
1116
|
-
remove(identifier: string): Promise<RemoveTemplateResponse>;
|
|
1117
|
-
get(identifier: string): Promise<GetTemplateResponse>;
|
|
1118
|
-
list(options?: PaginationOptions): Promise<ListTemplatesResponse>;
|
|
1119
|
-
duplicate(identifier: string): ChainableTemplateResult<DuplicateTemplateResponse>;
|
|
1120
|
-
publish(identifier: string): Promise<PublishTemplateResponse>;
|
|
1121
|
-
update(identifier: string, payload: UpdateTemplateOptions): Promise<UpdateTemplateResponse>;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
935
|
declare class Resend {
|
|
1125
936
|
readonly key?: string | undefined;
|
|
1126
937
|
private readonly headers;
|
|
@@ -1131,7 +942,6 @@ declare class Resend {
|
|
|
1131
942
|
readonly contacts: Contacts;
|
|
1132
943
|
readonly domains: Domains;
|
|
1133
944
|
readonly emails: Emails;
|
|
1134
|
-
readonly templates: Templates;
|
|
1135
945
|
constructor(key?: string | undefined);
|
|
1136
946
|
fetchRequest<T>(path: string, options?: {}): Promise<{
|
|
1137
947
|
data: T;
|
|
@@ -1177,4 +987,4 @@ declare class Resend {
|
|
|
1177
987
|
}>;
|
|
1178
988
|
}
|
|
1179
989
|
|
|
1180
|
-
export { type ApiKey, type Attachment, type Audience, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, type CreateBatchOptions, type CreateBatchRequestOptions, type CreateBatchResponse, type CreateBatchSuccessResponse, type CreateBroadcastOptions, type CreateBroadcastRequestOptions, type CreateBroadcastResponse, type CreateBroadcastResponseSuccess, type CreateContactOptions, type CreateContactRequestOptions, type CreateContactResponse, type CreateContactResponseSuccess, type CreateDomainOptions, type CreateDomainRequestOptions, type CreateDomainResponse, type CreateDomainResponseSuccess, type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, type CreateEmailResponseSuccess, type Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type IdempotentRequest, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RequireAtLeastOne, Resend, type SelectingField, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateBroadcastOptions, type UpdateBroadcastResponse, type UpdateBroadcastResponseSuccess, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type UpdateEmailOptions, type UpdateEmailResponse, type UpdateEmailResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
|
|
990
|
+
export { type ApiKey, type Attachment, type Audience, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, type CreateBatchOptions, type CreateBatchRequestOptions, type CreateBatchResponse, type CreateBatchSuccessResponse, type CreateBroadcastOptions, type CreateBroadcastRequestOptions, type CreateBroadcastResponse, type CreateBroadcastResponseSuccess, type CreateContactOptions, type CreateContactRequestOptions, type CreateContactResponse, type CreateContactResponseSuccess, type CreateDomainOptions, type CreateDomainRequestOptions, type CreateDomainResponse, type CreateDomainResponseSuccess, type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, type CreateEmailResponseSuccess, type Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type IdempotentRequest, type List, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RequireAtLeastOne, Resend, type SelectingField, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateBroadcastOptions, type UpdateBroadcastResponse, type UpdateBroadcastResponseSuccess, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type UpdateEmailOptions, type UpdateEmailResponse, type UpdateEmailResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
|
package/dist/index.d.ts
CHANGED
|
@@ -48,9 +48,9 @@ interface EmailApiAttachment {
|
|
|
48
48
|
content_id?: string;
|
|
49
49
|
}
|
|
50
50
|
interface EmailApiOptions {
|
|
51
|
-
from
|
|
51
|
+
from: string;
|
|
52
52
|
to: string | string[];
|
|
53
|
-
subject
|
|
53
|
+
subject: string;
|
|
54
54
|
region?: string;
|
|
55
55
|
headers?: Record<string, string>;
|
|
56
56
|
html?: string;
|
|
@@ -61,10 +61,6 @@ interface EmailApiOptions {
|
|
|
61
61
|
scheduled_at?: string;
|
|
62
62
|
tags?: Tag$1[];
|
|
63
63
|
attachments?: EmailApiAttachment[];
|
|
64
|
-
template?: {
|
|
65
|
-
id: string;
|
|
66
|
-
variables?: Record<string, string | number | boolean>;
|
|
67
|
-
};
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
interface GetOptions {
|
|
@@ -81,6 +77,11 @@ interface IdempotentRequest {
|
|
|
81
77
|
idempotencyKey?: string;
|
|
82
78
|
}
|
|
83
79
|
|
|
80
|
+
interface List<T> {
|
|
81
|
+
readonly object: 'list';
|
|
82
|
+
data: T[];
|
|
83
|
+
}
|
|
84
|
+
|
|
84
85
|
type PaginationOptions = {
|
|
85
86
|
/**
|
|
86
87
|
* Maximum number of items to return (1-100, default: 20)
|
|
@@ -246,16 +247,6 @@ interface EmailRenderOptions$1 {
|
|
|
246
247
|
*/
|
|
247
248
|
text: string;
|
|
248
249
|
}
|
|
249
|
-
interface EmailTemplateOptions {
|
|
250
|
-
template: {
|
|
251
|
-
id: string;
|
|
252
|
-
variables?: Record<string, string | number | boolean>;
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
interface CreateEmailBaseOptionsWithTemplate extends Omit<CreateEmailBaseOptions, 'from' | 'subject'> {
|
|
256
|
-
from?: string;
|
|
257
|
-
subject?: string;
|
|
258
|
-
}
|
|
259
250
|
interface CreateEmailBaseOptions {
|
|
260
251
|
/**
|
|
261
252
|
* Filename and content of attachments (max 40mb per email)
|
|
@@ -319,13 +310,7 @@ interface CreateEmailBaseOptions {
|
|
|
319
310
|
*/
|
|
320
311
|
scheduledAt?: string;
|
|
321
312
|
}
|
|
322
|
-
type CreateEmailOptions =
|
|
323
|
-
template?: never;
|
|
324
|
-
}) | ((EmailTemplateOptions & CreateEmailBaseOptionsWithTemplate) & {
|
|
325
|
-
react?: never;
|
|
326
|
-
html?: never;
|
|
327
|
-
text?: never;
|
|
328
|
-
});
|
|
313
|
+
type CreateEmailOptions = RequireAtLeastOne<EmailRenderOptions$1> & CreateEmailBaseOptions;
|
|
329
314
|
interface CreateEmailRequestOptions extends PostOptions, IdempotentRequest {
|
|
330
315
|
}
|
|
331
316
|
interface CreateEmailResponseSuccess {
|
|
@@ -412,6 +397,8 @@ interface Broadcast {
|
|
|
412
397
|
created_at: string;
|
|
413
398
|
scheduled_at: string | null;
|
|
414
399
|
sent_at: string | null;
|
|
400
|
+
html: string | null;
|
|
401
|
+
text: string | null;
|
|
415
402
|
}
|
|
416
403
|
|
|
417
404
|
interface EmailRenderOptions {
|
|
@@ -945,182 +932,6 @@ declare class Emails {
|
|
|
945
932
|
cancel(id: string): Promise<CancelEmailResponse>;
|
|
946
933
|
}
|
|
947
934
|
|
|
948
|
-
interface Template {
|
|
949
|
-
id: string;
|
|
950
|
-
name: string;
|
|
951
|
-
subject: string | null;
|
|
952
|
-
html: string;
|
|
953
|
-
text: string | null;
|
|
954
|
-
status: 'draft' | 'published';
|
|
955
|
-
variables: TemplateVariable[] | null;
|
|
956
|
-
alias: string | null;
|
|
957
|
-
from: string | null;
|
|
958
|
-
reply_to: string[] | null;
|
|
959
|
-
published_at: string | null;
|
|
960
|
-
created_at: string;
|
|
961
|
-
updated_at: string;
|
|
962
|
-
has_unpublished_versions: boolean;
|
|
963
|
-
current_version_id: string;
|
|
964
|
-
}
|
|
965
|
-
type TemplateVariableListFallbackType = string[] | number[] | boolean[] | Record<string, unknown>[];
|
|
966
|
-
interface TemplateVariable {
|
|
967
|
-
key: string;
|
|
968
|
-
fallback_value: string | number | boolean | Record<string, unknown> | TemplateVariableListFallbackType | null;
|
|
969
|
-
type: 'string' | 'number' | 'boolean' | 'object' | 'list';
|
|
970
|
-
created_at: string;
|
|
971
|
-
updated_at: string;
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
type TemplateContentCreationOptions = RequireAtLeastOne<{
|
|
975
|
-
html: string;
|
|
976
|
-
react: React.ReactNode;
|
|
977
|
-
}>;
|
|
978
|
-
type TemplateVariableCreationOptions = Pick<TemplateVariable, 'key' | 'type'> & ({
|
|
979
|
-
type: 'string';
|
|
980
|
-
fallbackValue?: string | null;
|
|
981
|
-
} | {
|
|
982
|
-
type: 'number';
|
|
983
|
-
fallbackValue?: number | null;
|
|
984
|
-
} | {
|
|
985
|
-
type: 'boolean';
|
|
986
|
-
fallbackValue?: boolean | null;
|
|
987
|
-
} | {
|
|
988
|
-
type: 'object';
|
|
989
|
-
fallbackValue: Record<string, unknown>;
|
|
990
|
-
} | {
|
|
991
|
-
type: 'list';
|
|
992
|
-
fallbackValue: TemplateVariableListFallbackType;
|
|
993
|
-
});
|
|
994
|
-
type TemplateOptionalFieldsForCreation = Partial<Pick<Template, 'subject' | 'text' | 'alias' | 'from'>> & {
|
|
995
|
-
replyTo?: string[] | string;
|
|
996
|
-
variables?: TemplateVariableCreationOptions[];
|
|
997
|
-
};
|
|
998
|
-
type CreateTemplateOptions = Pick<Template, 'name'> & TemplateOptionalFieldsForCreation & TemplateContentCreationOptions;
|
|
999
|
-
interface CreateTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1000
|
-
object: 'template';
|
|
1001
|
-
}
|
|
1002
|
-
type CreateTemplateResponse = {
|
|
1003
|
-
data: CreateTemplateResponseSuccess;
|
|
1004
|
-
error: null;
|
|
1005
|
-
} | {
|
|
1006
|
-
data: null;
|
|
1007
|
-
error: ErrorResponse;
|
|
1008
|
-
};
|
|
1009
|
-
|
|
1010
|
-
interface DuplicateTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1011
|
-
object: 'template';
|
|
1012
|
-
}
|
|
1013
|
-
type DuplicateTemplateResponse = {
|
|
1014
|
-
data: DuplicateTemplateResponseSuccess;
|
|
1015
|
-
error: null;
|
|
1016
|
-
} | {
|
|
1017
|
-
data: null;
|
|
1018
|
-
error: ErrorResponse;
|
|
1019
|
-
};
|
|
1020
|
-
|
|
1021
|
-
interface PublishTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1022
|
-
object: 'template';
|
|
1023
|
-
}
|
|
1024
|
-
type PublishTemplateResponse = {
|
|
1025
|
-
data: PublishTemplateResponseSuccess;
|
|
1026
|
-
error: null;
|
|
1027
|
-
} | {
|
|
1028
|
-
data: null;
|
|
1029
|
-
error: ErrorResponse;
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
declare class ChainableTemplateResult<T extends CreateTemplateResponse | DuplicateTemplateResponse> implements PromiseLike<T> {
|
|
1033
|
-
private readonly promise;
|
|
1034
|
-
private readonly publishFn;
|
|
1035
|
-
constructor(promise: Promise<T>, publishFn: (id: string) => Promise<PublishTemplateResponse>);
|
|
1036
|
-
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): PromiseLike<TResult1 | TResult2>;
|
|
1037
|
-
publish(): Promise<PublishTemplateResponse>;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
interface GetTemplateResponseSuccess extends Template {
|
|
1041
|
-
object: 'template';
|
|
1042
|
-
}
|
|
1043
|
-
type GetTemplateResponse = {
|
|
1044
|
-
data: GetTemplateResponseSuccess;
|
|
1045
|
-
error: null;
|
|
1046
|
-
} | {
|
|
1047
|
-
data: null;
|
|
1048
|
-
error: ErrorResponse;
|
|
1049
|
-
};
|
|
1050
|
-
|
|
1051
|
-
interface TemplateListItem extends Pick<Template, 'id' | 'name' | 'created_at' | 'updated_at' | 'status' | 'published_at' | 'alias'> {
|
|
1052
|
-
}
|
|
1053
|
-
interface ListTemplatesResponseSuccess {
|
|
1054
|
-
object: 'list';
|
|
1055
|
-
data: TemplateListItem[];
|
|
1056
|
-
has_more: boolean;
|
|
1057
|
-
}
|
|
1058
|
-
type ListTemplatesResponse = {
|
|
1059
|
-
data: ListTemplatesResponseSuccess;
|
|
1060
|
-
error: null;
|
|
1061
|
-
} | {
|
|
1062
|
-
data: null;
|
|
1063
|
-
error: ErrorResponse;
|
|
1064
|
-
};
|
|
1065
|
-
|
|
1066
|
-
interface RemoveTemplateResponseSuccess {
|
|
1067
|
-
object: 'template';
|
|
1068
|
-
id: string;
|
|
1069
|
-
deleted: boolean;
|
|
1070
|
-
}
|
|
1071
|
-
type RemoveTemplateResponse = {
|
|
1072
|
-
data: RemoveTemplateResponseSuccess;
|
|
1073
|
-
error: null;
|
|
1074
|
-
} | {
|
|
1075
|
-
data: null;
|
|
1076
|
-
error: ErrorResponse;
|
|
1077
|
-
};
|
|
1078
|
-
|
|
1079
|
-
type TemplateVariableUpdateOptions = Pick<TemplateVariable, 'key' | 'type'> & ({
|
|
1080
|
-
type: 'string';
|
|
1081
|
-
fallbackValue?: string | null;
|
|
1082
|
-
} | {
|
|
1083
|
-
type: 'number';
|
|
1084
|
-
fallbackValue?: number | null;
|
|
1085
|
-
} | {
|
|
1086
|
-
type: 'boolean';
|
|
1087
|
-
fallbackValue?: boolean | null;
|
|
1088
|
-
} | {
|
|
1089
|
-
type: 'object';
|
|
1090
|
-
fallbackValue: Record<string, unknown>;
|
|
1091
|
-
} | {
|
|
1092
|
-
type: 'list';
|
|
1093
|
-
fallbackValue: TemplateVariableListFallbackType;
|
|
1094
|
-
});
|
|
1095
|
-
interface UpdateTemplateOptions extends Partial<Pick<Template, 'name' | 'subject' | 'html' | 'text' | 'from' | 'alias'>> {
|
|
1096
|
-
variables?: TemplateVariableUpdateOptions[];
|
|
1097
|
-
replyTo?: string[] | string;
|
|
1098
|
-
}
|
|
1099
|
-
interface UpdateTemplateResponseSuccess extends Pick<Template, 'id'> {
|
|
1100
|
-
object: 'template';
|
|
1101
|
-
}
|
|
1102
|
-
type UpdateTemplateResponse = {
|
|
1103
|
-
data: UpdateTemplateResponseSuccess;
|
|
1104
|
-
error: null;
|
|
1105
|
-
} | {
|
|
1106
|
-
data: null;
|
|
1107
|
-
error: ErrorResponse;
|
|
1108
|
-
};
|
|
1109
|
-
|
|
1110
|
-
declare class Templates {
|
|
1111
|
-
private readonly resend;
|
|
1112
|
-
private renderAsync?;
|
|
1113
|
-
constructor(resend: Resend);
|
|
1114
|
-
create(payload: CreateTemplateOptions): ChainableTemplateResult<CreateTemplateResponse>;
|
|
1115
|
-
private performCreate;
|
|
1116
|
-
remove(identifier: string): Promise<RemoveTemplateResponse>;
|
|
1117
|
-
get(identifier: string): Promise<GetTemplateResponse>;
|
|
1118
|
-
list(options?: PaginationOptions): Promise<ListTemplatesResponse>;
|
|
1119
|
-
duplicate(identifier: string): ChainableTemplateResult<DuplicateTemplateResponse>;
|
|
1120
|
-
publish(identifier: string): Promise<PublishTemplateResponse>;
|
|
1121
|
-
update(identifier: string, payload: UpdateTemplateOptions): Promise<UpdateTemplateResponse>;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
935
|
declare class Resend {
|
|
1125
936
|
readonly key?: string | undefined;
|
|
1126
937
|
private readonly headers;
|
|
@@ -1131,7 +942,6 @@ declare class Resend {
|
|
|
1131
942
|
readonly contacts: Contacts;
|
|
1132
943
|
readonly domains: Domains;
|
|
1133
944
|
readonly emails: Emails;
|
|
1134
|
-
readonly templates: Templates;
|
|
1135
945
|
constructor(key?: string | undefined);
|
|
1136
946
|
fetchRequest<T>(path: string, options?: {}): Promise<{
|
|
1137
947
|
data: T;
|
|
@@ -1177,4 +987,4 @@ declare class Resend {
|
|
|
1177
987
|
}>;
|
|
1178
988
|
}
|
|
1179
989
|
|
|
1180
|
-
export { type ApiKey, type Attachment, type Audience, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, type CreateBatchOptions, type CreateBatchRequestOptions, type CreateBatchResponse, type CreateBatchSuccessResponse, type CreateBroadcastOptions, type CreateBroadcastRequestOptions, type CreateBroadcastResponse, type CreateBroadcastResponseSuccess, type CreateContactOptions, type CreateContactRequestOptions, type CreateContactResponse, type CreateContactResponseSuccess, type CreateDomainOptions, type CreateDomainRequestOptions, type CreateDomainResponse, type CreateDomainResponseSuccess, type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, type CreateEmailResponseSuccess, type Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type IdempotentRequest, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RequireAtLeastOne, Resend, type SelectingField, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateBroadcastOptions, type UpdateBroadcastResponse, type UpdateBroadcastResponseSuccess, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type UpdateEmailOptions, type UpdateEmailResponse, type UpdateEmailResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
|
|
990
|
+
export { type ApiKey, type Attachment, type Audience, type Broadcast, type CancelEmailResponse, type CancelEmailResponseSuccess, type Contact, type CreateApiKeyOptions, type CreateApiKeyRequestOptions, type CreateApiKeyResponse, type CreateApiKeyResponseSuccess, type CreateAudienceOptions, type CreateAudienceRequestOptions, type CreateAudienceResponse, type CreateAudienceResponseSuccess, type CreateBatchOptions, type CreateBatchRequestOptions, type CreateBatchResponse, type CreateBatchSuccessResponse, type CreateBroadcastOptions, type CreateBroadcastRequestOptions, type CreateBroadcastResponse, type CreateBroadcastResponseSuccess, type CreateContactOptions, type CreateContactRequestOptions, type CreateContactResponse, type CreateContactResponseSuccess, type CreateDomainOptions, type CreateDomainRequestOptions, type CreateDomainResponse, type CreateDomainResponseSuccess, type CreateEmailOptions, type CreateEmailRequestOptions, type CreateEmailResponse, type CreateEmailResponseSuccess, type Domain, type DomainApiOptions, type DomainDkimRecord, type DomainNameservers, type DomainRecords, type DomainRegion, type DomainSpfRecord, type DomainStatus, type EmailApiAttachment, type EmailApiOptions, type ErrorResponse, type GetAudienceResponse, type GetAudienceResponseSuccess, type GetBroadcastResponse, type GetBroadcastResponseSuccess, type GetContactOptions, type GetContactResponse, type GetContactResponseSuccess, type GetDomainResponse, type GetDomainResponseSuccess, type GetEmailResponse, type GetEmailResponseSuccess, type GetOptions, type IdempotentRequest, type List, type ListApiKeysOptions, type ListApiKeysResponse, type ListApiKeysResponseSuccess, type ListAudiencesOptions, type ListAudiencesResponse, type ListAudiencesResponseSuccess, type ListBroadcastsOptions, type ListBroadcastsResponse, type ListBroadcastsResponseSuccess, type ListContactsOptions, type ListContactsResponse, type ListContactsResponseSuccess, type ListDomainsOptions, type ListDomainsResponse, type ListDomainsResponseSuccess, type PaginationOptions, type PatchOptions, type PostOptions, type PutOptions, type RemoveApiKeyResponse, type RemoveApiKeyResponseSuccess, type RemoveAudiencesResponse, type RemoveAudiencesResponseSuccess, type RemoveBroadcastResponse, type RemoveBroadcastResponseSuccess, type RemoveContactOptions, type RemoveContactsResponse, type RemoveContactsResponseSuccess, type RemoveDomainsResponse, type RemoveDomainsResponseSuccess, type RequireAtLeastOne, Resend, type SelectingField, type SendBroadcastOptions, type SendBroadcastRequestOptions, type SendBroadcastResponse, type SendBroadcastResponseSuccess, type Tag, type UpdateBroadcastOptions, type UpdateBroadcastResponse, type UpdateBroadcastResponseSuccess, type UpdateContactOptions, type UpdateContactResponse, type UpdateContactResponseSuccess, type UpdateDomainsOptions, type UpdateDomainsResponse, type UpdateDomainsResponseSuccess, type UpdateEmailOptions, type UpdateEmailResponse, type UpdateEmailResponseSuccess, type VerifyDomainsResponse, type VerifyDomainsResponseSuccess };
|
package/dist/index.js
CHANGED
|
@@ -84,7 +84,7 @@ __export(index_exports, {
|
|
|
84
84
|
module.exports = __toCommonJS(index_exports);
|
|
85
85
|
|
|
86
86
|
// package.json
|
|
87
|
-
var version = "6.1.
|
|
87
|
+
var version = "6.1.3";
|
|
88
88
|
|
|
89
89
|
// src/common/utils/build-pagination-query.ts
|
|
90
90
|
function buildPaginationQuery(options) {
|
|
@@ -198,11 +198,7 @@ function parseEmailToApiOptions(email) {
|
|
|
198
198
|
subject: email.subject,
|
|
199
199
|
tags: email.tags,
|
|
200
200
|
text: email.text,
|
|
201
|
-
to: email.to
|
|
202
|
-
template: email.template ? {
|
|
203
|
-
id: email.template.id,
|
|
204
|
-
variables: email.template.variables
|
|
205
|
-
} : void 0
|
|
201
|
+
to: email.to
|
|
206
202
|
};
|
|
207
203
|
}
|
|
208
204
|
|
|
@@ -557,150 +553,6 @@ var Emails = class {
|
|
|
557
553
|
}
|
|
558
554
|
};
|
|
559
555
|
|
|
560
|
-
// src/common/utils/get-pagination-query-properties.ts
|
|
561
|
-
function getPaginationQueryProperties(options = {}) {
|
|
562
|
-
const query = new URLSearchParams();
|
|
563
|
-
if (options.before) query.set("before", options.before);
|
|
564
|
-
if (options.after) query.set("after", options.after);
|
|
565
|
-
if (options.limit) query.set("limit", options.limit.toString());
|
|
566
|
-
return query.size > 0 ? `?${query.toString()}` : "";
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// src/common/utils/parse-template-to-api-options.ts
|
|
570
|
-
function parseVariables(variables) {
|
|
571
|
-
return variables == null ? void 0 : variables.map((variable) => ({
|
|
572
|
-
key: variable.key,
|
|
573
|
-
type: variable.type,
|
|
574
|
-
fallback_value: variable.fallbackValue
|
|
575
|
-
}));
|
|
576
|
-
}
|
|
577
|
-
function parseTemplateToApiOptions(template) {
|
|
578
|
-
return {
|
|
579
|
-
name: "name" in template ? template.name : void 0,
|
|
580
|
-
subject: template.subject,
|
|
581
|
-
html: template.html,
|
|
582
|
-
text: template.text,
|
|
583
|
-
alias: template.alias,
|
|
584
|
-
from: template.from,
|
|
585
|
-
reply_to: template.replyTo,
|
|
586
|
-
variables: parseVariables(template.variables)
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// src/templates/chainable-template-result.ts
|
|
591
|
-
var ChainableTemplateResult = class {
|
|
592
|
-
constructor(promise, publishFn) {
|
|
593
|
-
this.promise = promise;
|
|
594
|
-
this.publishFn = publishFn;
|
|
595
|
-
}
|
|
596
|
-
// If user calls `then` or only awaits for the result of create() or duplicate(), the behavior should be
|
|
597
|
-
// exactly as if they called create() or duplicate() directly. This will act as a normal promise
|
|
598
|
-
// biome-ignore lint/suspicious/noThenProperty: This class intentionally implements PromiseLike
|
|
599
|
-
then(onfulfilled, onrejected) {
|
|
600
|
-
return this.promise.then(onfulfilled, onrejected);
|
|
601
|
-
}
|
|
602
|
-
publish() {
|
|
603
|
-
return __async(this, null, function* () {
|
|
604
|
-
const { data, error } = yield this.promise;
|
|
605
|
-
if (error) {
|
|
606
|
-
return {
|
|
607
|
-
data: null,
|
|
608
|
-
error
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
const publishResult = yield this.publishFn(data.id);
|
|
612
|
-
return publishResult;
|
|
613
|
-
});
|
|
614
|
-
}
|
|
615
|
-
};
|
|
616
|
-
|
|
617
|
-
// src/templates/templates.ts
|
|
618
|
-
var Templates = class {
|
|
619
|
-
constructor(resend) {
|
|
620
|
-
this.resend = resend;
|
|
621
|
-
}
|
|
622
|
-
create(payload) {
|
|
623
|
-
const createPromise = this.performCreate(payload);
|
|
624
|
-
return new ChainableTemplateResult(createPromise, this.publish.bind(this));
|
|
625
|
-
}
|
|
626
|
-
// This creation process is being done separately from the public create so that
|
|
627
|
-
// the user can chain the publish operation after the create operation. Otherwise, due
|
|
628
|
-
// to the async nature of the renderAsync, the return type would be
|
|
629
|
-
// Promise<ChainableTemplateResult<CreateTemplateResponse>> which wouldn't be chainable.
|
|
630
|
-
performCreate(payload) {
|
|
631
|
-
return __async(this, null, function* () {
|
|
632
|
-
if (payload.react) {
|
|
633
|
-
if (!this.renderAsync) {
|
|
634
|
-
try {
|
|
635
|
-
const { renderAsync } = yield import("@react-email/render");
|
|
636
|
-
this.renderAsync = renderAsync;
|
|
637
|
-
} catch (e) {
|
|
638
|
-
throw new Error(
|
|
639
|
-
"Failed to render React component. Make sure to install `@react-email/render`"
|
|
640
|
-
);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
payload.html = yield this.renderAsync(
|
|
644
|
-
payload.react
|
|
645
|
-
);
|
|
646
|
-
}
|
|
647
|
-
return this.resend.post(
|
|
648
|
-
"/templates",
|
|
649
|
-
parseTemplateToApiOptions(payload)
|
|
650
|
-
);
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
remove(identifier) {
|
|
654
|
-
return __async(this, null, function* () {
|
|
655
|
-
const data = yield this.resend.delete(
|
|
656
|
-
`/templates/${identifier}`
|
|
657
|
-
);
|
|
658
|
-
return data;
|
|
659
|
-
});
|
|
660
|
-
}
|
|
661
|
-
get(identifier) {
|
|
662
|
-
return __async(this, null, function* () {
|
|
663
|
-
const data = yield this.resend.get(
|
|
664
|
-
`/templates/${identifier}`
|
|
665
|
-
);
|
|
666
|
-
return data;
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
list() {
|
|
670
|
-
return __async(this, arguments, function* (options = {}) {
|
|
671
|
-
return this.resend.get(
|
|
672
|
-
`/templates${getPaginationQueryProperties(options)}`
|
|
673
|
-
);
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
duplicate(identifier) {
|
|
677
|
-
const promiseDuplicate = this.resend.post(
|
|
678
|
-
`/templates/${identifier}/duplicate`
|
|
679
|
-
);
|
|
680
|
-
return new ChainableTemplateResult(
|
|
681
|
-
promiseDuplicate,
|
|
682
|
-
this.publish.bind(this)
|
|
683
|
-
);
|
|
684
|
-
}
|
|
685
|
-
publish(identifier) {
|
|
686
|
-
return __async(this, null, function* () {
|
|
687
|
-
const data = yield this.resend.post(
|
|
688
|
-
`/templates/${identifier}/publish`
|
|
689
|
-
);
|
|
690
|
-
return data;
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
update(identifier, payload) {
|
|
694
|
-
return __async(this, null, function* () {
|
|
695
|
-
const data = yield this.resend.patch(
|
|
696
|
-
`/templates/${identifier}`,
|
|
697
|
-
parseTemplateToApiOptions(payload)
|
|
698
|
-
);
|
|
699
|
-
return data;
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
};
|
|
703
|
-
|
|
704
556
|
// src/resend.ts
|
|
705
557
|
var defaultBaseUrl = "https://api.resend.com";
|
|
706
558
|
var defaultUserAgent = `resend-node:${version}`;
|
|
@@ -716,7 +568,6 @@ var Resend = class {
|
|
|
716
568
|
this.contacts = new Contacts(this);
|
|
717
569
|
this.domains = new Domains(this);
|
|
718
570
|
this.emails = new Emails(this);
|
|
719
|
-
this.templates = new Templates(this);
|
|
720
571
|
if (!key) {
|
|
721
572
|
if (typeof process !== "undefined" && process.env) {
|
|
722
573
|
this.key = process.env.RESEND_API_KEY;
|
package/dist/index.mjs
CHANGED
|
@@ -51,7 +51,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// package.json
|
|
54
|
-
var version = "6.1.
|
|
54
|
+
var version = "6.1.3";
|
|
55
55
|
|
|
56
56
|
// src/common/utils/build-pagination-query.ts
|
|
57
57
|
function buildPaginationQuery(options) {
|
|
@@ -165,11 +165,7 @@ function parseEmailToApiOptions(email) {
|
|
|
165
165
|
subject: email.subject,
|
|
166
166
|
tags: email.tags,
|
|
167
167
|
text: email.text,
|
|
168
|
-
to: email.to
|
|
169
|
-
template: email.template ? {
|
|
170
|
-
id: email.template.id,
|
|
171
|
-
variables: email.template.variables
|
|
172
|
-
} : void 0
|
|
168
|
+
to: email.to
|
|
173
169
|
};
|
|
174
170
|
}
|
|
175
171
|
|
|
@@ -524,150 +520,6 @@ var Emails = class {
|
|
|
524
520
|
}
|
|
525
521
|
};
|
|
526
522
|
|
|
527
|
-
// src/common/utils/get-pagination-query-properties.ts
|
|
528
|
-
function getPaginationQueryProperties(options = {}) {
|
|
529
|
-
const query = new URLSearchParams();
|
|
530
|
-
if (options.before) query.set("before", options.before);
|
|
531
|
-
if (options.after) query.set("after", options.after);
|
|
532
|
-
if (options.limit) query.set("limit", options.limit.toString());
|
|
533
|
-
return query.size > 0 ? `?${query.toString()}` : "";
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// src/common/utils/parse-template-to-api-options.ts
|
|
537
|
-
function parseVariables(variables) {
|
|
538
|
-
return variables == null ? void 0 : variables.map((variable) => ({
|
|
539
|
-
key: variable.key,
|
|
540
|
-
type: variable.type,
|
|
541
|
-
fallback_value: variable.fallbackValue
|
|
542
|
-
}));
|
|
543
|
-
}
|
|
544
|
-
function parseTemplateToApiOptions(template) {
|
|
545
|
-
return {
|
|
546
|
-
name: "name" in template ? template.name : void 0,
|
|
547
|
-
subject: template.subject,
|
|
548
|
-
html: template.html,
|
|
549
|
-
text: template.text,
|
|
550
|
-
alias: template.alias,
|
|
551
|
-
from: template.from,
|
|
552
|
-
reply_to: template.replyTo,
|
|
553
|
-
variables: parseVariables(template.variables)
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// src/templates/chainable-template-result.ts
|
|
558
|
-
var ChainableTemplateResult = class {
|
|
559
|
-
constructor(promise, publishFn) {
|
|
560
|
-
this.promise = promise;
|
|
561
|
-
this.publishFn = publishFn;
|
|
562
|
-
}
|
|
563
|
-
// If user calls `then` or only awaits for the result of create() or duplicate(), the behavior should be
|
|
564
|
-
// exactly as if they called create() or duplicate() directly. This will act as a normal promise
|
|
565
|
-
// biome-ignore lint/suspicious/noThenProperty: This class intentionally implements PromiseLike
|
|
566
|
-
then(onfulfilled, onrejected) {
|
|
567
|
-
return this.promise.then(onfulfilled, onrejected);
|
|
568
|
-
}
|
|
569
|
-
publish() {
|
|
570
|
-
return __async(this, null, function* () {
|
|
571
|
-
const { data, error } = yield this.promise;
|
|
572
|
-
if (error) {
|
|
573
|
-
return {
|
|
574
|
-
data: null,
|
|
575
|
-
error
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
const publishResult = yield this.publishFn(data.id);
|
|
579
|
-
return publishResult;
|
|
580
|
-
});
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
|
|
584
|
-
// src/templates/templates.ts
|
|
585
|
-
var Templates = class {
|
|
586
|
-
constructor(resend) {
|
|
587
|
-
this.resend = resend;
|
|
588
|
-
}
|
|
589
|
-
create(payload) {
|
|
590
|
-
const createPromise = this.performCreate(payload);
|
|
591
|
-
return new ChainableTemplateResult(createPromise, this.publish.bind(this));
|
|
592
|
-
}
|
|
593
|
-
// This creation process is being done separately from the public create so that
|
|
594
|
-
// the user can chain the publish operation after the create operation. Otherwise, due
|
|
595
|
-
// to the async nature of the renderAsync, the return type would be
|
|
596
|
-
// Promise<ChainableTemplateResult<CreateTemplateResponse>> which wouldn't be chainable.
|
|
597
|
-
performCreate(payload) {
|
|
598
|
-
return __async(this, null, function* () {
|
|
599
|
-
if (payload.react) {
|
|
600
|
-
if (!this.renderAsync) {
|
|
601
|
-
try {
|
|
602
|
-
const { renderAsync } = yield import("@react-email/render");
|
|
603
|
-
this.renderAsync = renderAsync;
|
|
604
|
-
} catch (e) {
|
|
605
|
-
throw new Error(
|
|
606
|
-
"Failed to render React component. Make sure to install `@react-email/render`"
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
payload.html = yield this.renderAsync(
|
|
611
|
-
payload.react
|
|
612
|
-
);
|
|
613
|
-
}
|
|
614
|
-
return this.resend.post(
|
|
615
|
-
"/templates",
|
|
616
|
-
parseTemplateToApiOptions(payload)
|
|
617
|
-
);
|
|
618
|
-
});
|
|
619
|
-
}
|
|
620
|
-
remove(identifier) {
|
|
621
|
-
return __async(this, null, function* () {
|
|
622
|
-
const data = yield this.resend.delete(
|
|
623
|
-
`/templates/${identifier}`
|
|
624
|
-
);
|
|
625
|
-
return data;
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
get(identifier) {
|
|
629
|
-
return __async(this, null, function* () {
|
|
630
|
-
const data = yield this.resend.get(
|
|
631
|
-
`/templates/${identifier}`
|
|
632
|
-
);
|
|
633
|
-
return data;
|
|
634
|
-
});
|
|
635
|
-
}
|
|
636
|
-
list() {
|
|
637
|
-
return __async(this, arguments, function* (options = {}) {
|
|
638
|
-
return this.resend.get(
|
|
639
|
-
`/templates${getPaginationQueryProperties(options)}`
|
|
640
|
-
);
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
duplicate(identifier) {
|
|
644
|
-
const promiseDuplicate = this.resend.post(
|
|
645
|
-
`/templates/${identifier}/duplicate`
|
|
646
|
-
);
|
|
647
|
-
return new ChainableTemplateResult(
|
|
648
|
-
promiseDuplicate,
|
|
649
|
-
this.publish.bind(this)
|
|
650
|
-
);
|
|
651
|
-
}
|
|
652
|
-
publish(identifier) {
|
|
653
|
-
return __async(this, null, function* () {
|
|
654
|
-
const data = yield this.resend.post(
|
|
655
|
-
`/templates/${identifier}/publish`
|
|
656
|
-
);
|
|
657
|
-
return data;
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
update(identifier, payload) {
|
|
661
|
-
return __async(this, null, function* () {
|
|
662
|
-
const data = yield this.resend.patch(
|
|
663
|
-
`/templates/${identifier}`,
|
|
664
|
-
parseTemplateToApiOptions(payload)
|
|
665
|
-
);
|
|
666
|
-
return data;
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
|
|
671
523
|
// src/resend.ts
|
|
672
524
|
var defaultBaseUrl = "https://api.resend.com";
|
|
673
525
|
var defaultUserAgent = `resend-node:${version}`;
|
|
@@ -683,7 +535,6 @@ var Resend = class {
|
|
|
683
535
|
this.contacts = new Contacts(this);
|
|
684
536
|
this.domains = new Domains(this);
|
|
685
537
|
this.emails = new Emails(this);
|
|
686
|
-
this.templates = new Templates(this);
|
|
687
538
|
if (!key) {
|
|
688
539
|
if (typeof process !== "undefined" && process.env) {
|
|
689
540
|
this.key = process.env.RESEND_API_KEY;
|