emailr 1.0.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +58 -18
- package/dist/index.d.ts +58 -18
- package/dist/index.js +60 -18
- package/dist/index.mjs +60 -18
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -170,6 +170,7 @@ interface Template {
|
|
|
170
170
|
subject: string;
|
|
171
171
|
html_content: string | null;
|
|
172
172
|
text_content: string | null;
|
|
173
|
+
preview_html: string | null;
|
|
173
174
|
variables: string[] | null;
|
|
174
175
|
from_email: string | null;
|
|
175
176
|
reply_to: string | null;
|
|
@@ -202,6 +203,12 @@ interface ListTemplatesParams {
|
|
|
202
203
|
page?: number;
|
|
203
204
|
limit?: number;
|
|
204
205
|
}
|
|
206
|
+
interface PushPreviewResponse {
|
|
207
|
+
preview_url: string;
|
|
208
|
+
}
|
|
209
|
+
interface FetchTemplateOptions {
|
|
210
|
+
preview?: boolean;
|
|
211
|
+
}
|
|
205
212
|
interface DnsRecord {
|
|
206
213
|
type: 'TXT' | 'MX' | 'CNAME';
|
|
207
214
|
name: string;
|
|
@@ -492,23 +499,6 @@ declare class EmailsResource {
|
|
|
492
499
|
* Forward an email to other recipients
|
|
493
500
|
*/
|
|
494
501
|
forward(data: ForwardEmailRequest): Promise<SendEmailResponse>;
|
|
495
|
-
/**
|
|
496
|
-
* Create an email forwarding rule
|
|
497
|
-
*/
|
|
498
|
-
createForwardingRule(data: CreateForwardingRuleRequest): Promise<{
|
|
499
|
-
id: string;
|
|
500
|
-
success: boolean;
|
|
501
|
-
}>;
|
|
502
|
-
/**
|
|
503
|
-
* List all forwarding rules
|
|
504
|
-
*/
|
|
505
|
-
listForwardingRules(): Promise<{
|
|
506
|
-
data: ForwardingRule[];
|
|
507
|
-
}>;
|
|
508
|
-
/**
|
|
509
|
-
* Delete a forwarding rule
|
|
510
|
-
*/
|
|
511
|
-
deleteForwardingRule(id: string): Promise<SuccessResponse>;
|
|
512
502
|
}
|
|
513
503
|
|
|
514
504
|
declare class ContactsResource {
|
|
@@ -575,6 +565,30 @@ declare class TemplatesResource {
|
|
|
575
565
|
* Duplicate a template
|
|
576
566
|
*/
|
|
577
567
|
duplicate(id: string): Promise<Template>;
|
|
568
|
+
/**
|
|
569
|
+
* Push preview HTML for a template
|
|
570
|
+
*
|
|
571
|
+
* Uploads HTML content to the template's preview, which can be accessed
|
|
572
|
+
* publicly at /preview/{template_id} without authentication.
|
|
573
|
+
* This is useful for sharing previews with AI agents for review.
|
|
574
|
+
*
|
|
575
|
+
* @param id - The template ID
|
|
576
|
+
* @param htmlContent - The HTML content for the preview
|
|
577
|
+
* @returns The public preview URL
|
|
578
|
+
*/
|
|
579
|
+
pushPreview(id: string, htmlContent: string): Promise<PushPreviewResponse>;
|
|
580
|
+
/**
|
|
581
|
+
* Fetch template HTML content
|
|
582
|
+
*
|
|
583
|
+
* Downloads the template's HTML content. By default, returns the published
|
|
584
|
+
* html_content. Use `{ preview: true }` to fetch the preview_html instead.
|
|
585
|
+
*
|
|
586
|
+
* @param id - The template ID
|
|
587
|
+
* @param options - Fetch options
|
|
588
|
+
* @param options.preview - If true, fetch preview_html instead of html_content
|
|
589
|
+
* @returns The HTML content as a string
|
|
590
|
+
*/
|
|
591
|
+
fetch(id: string, options?: FetchTemplateOptions): Promise<string>;
|
|
578
592
|
}
|
|
579
593
|
|
|
580
594
|
declare class DomainsResource {
|
|
@@ -825,6 +839,28 @@ declare class MetricsResource {
|
|
|
825
839
|
getEmailMetrics(): Promise<EmailMetrics>;
|
|
826
840
|
}
|
|
827
841
|
|
|
842
|
+
declare class ForwardingRulesResource {
|
|
843
|
+
private readonly http;
|
|
844
|
+
constructor(http: HttpClient);
|
|
845
|
+
/**
|
|
846
|
+
* Create an email forwarding rule
|
|
847
|
+
*/
|
|
848
|
+
create(data: CreateForwardingRuleRequest): Promise<{
|
|
849
|
+
id: string;
|
|
850
|
+
success: boolean;
|
|
851
|
+
}>;
|
|
852
|
+
/**
|
|
853
|
+
* List all forwarding rules
|
|
854
|
+
*/
|
|
855
|
+
list(): Promise<{
|
|
856
|
+
data: ForwardingRule[];
|
|
857
|
+
}>;
|
|
858
|
+
/**
|
|
859
|
+
* Delete a forwarding rule
|
|
860
|
+
*/
|
|
861
|
+
delete(id: string): Promise<SuccessResponse>;
|
|
862
|
+
}
|
|
863
|
+
|
|
828
864
|
/**
|
|
829
865
|
* Configuration options for the Emailr client
|
|
830
866
|
*/
|
|
@@ -908,6 +944,10 @@ declare class Emailr {
|
|
|
908
944
|
* Usage and email metrics
|
|
909
945
|
*/
|
|
910
946
|
readonly metrics: MetricsResource;
|
|
947
|
+
/**
|
|
948
|
+
* Email forwarding rules
|
|
949
|
+
*/
|
|
950
|
+
readonly forwardingRules: ForwardingRulesResource;
|
|
911
951
|
private readonly http;
|
|
912
952
|
constructor(config: EmailrConfig);
|
|
913
953
|
}
|
|
@@ -955,4 +995,4 @@ declare class ValidationError extends EmailrError {
|
|
|
955
995
|
constructor(message: string, details?: Record<string, unknown>, requestId?: string);
|
|
956
996
|
}
|
|
957
997
|
|
|
958
|
-
export { type AddDomainRequest, type ApiKey, type Attachment, AuthenticationError, type Broadcast, type BulkCreateContactsRequest, type BulkCreateContactsResponse, type Contact, type ContactListResponse, type CreateApiKeyRequest, type CreateBroadcastRequest, type CreateContactRequest, type CreateForwardingRuleRequest, type CreateSegmentRequest, type CreateTemplateRequest, type CreateWebhookRequest, type DnsRecord, type DnsVerificationStatus, type Domain, type DomainDnsRecords, type DomainVerificationStatus, type Email, Emailr, Emailr as EmailrClient, type EmailrConfig, EmailrError, type ForwardEmailRequest, type ForwardingRule, type ListApiKeysParams, type ListBroadcastsParams, type ListContactsParams, type ListEmailsParams, type ListSegmentsParams, type ListTemplatesParams, type ListWebhooksParams, NetworkError, NotFoundError, type PaginatedResponse, RateLimitError, type ReplyTo, type Segment, type SendBroadcastResponse, type SendEmailRequest, type SendEmailResponse, type SuccessResponse, type Template, type UpdateBroadcastRequest, type UpdateContactRequest, type UpdateDomainRequest, type UpdateSegmentRequest, type UpdateTemplateRequest, type UpdateWebhookRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookToggleResponse };
|
|
998
|
+
export { type AddDomainRequest, type ApiKey, type Attachment, AuthenticationError, type Broadcast, type BulkCreateContactsRequest, type BulkCreateContactsResponse, type Contact, type ContactListResponse, type CreateApiKeyRequest, type CreateBroadcastRequest, type CreateContactRequest, type CreateForwardingRuleRequest, type CreateSegmentRequest, type CreateTemplateRequest, type CreateWebhookRequest, type DnsRecord, type DnsVerificationStatus, type Domain, type DomainDnsRecords, type DomainVerificationStatus, type Email, Emailr, Emailr as EmailrClient, type EmailrConfig, EmailrError, type FetchTemplateOptions, type ForwardEmailRequest, type ForwardingRule, type ListApiKeysParams, type ListBroadcastsParams, type ListContactsParams, type ListEmailsParams, type ListSegmentsParams, type ListTemplatesParams, type ListWebhooksParams, NetworkError, NotFoundError, type PaginatedResponse, type PushPreviewResponse, RateLimitError, type ReplyTo, type Segment, type SendBroadcastResponse, type SendEmailRequest, type SendEmailResponse, type SuccessResponse, type Template, type UpdateBroadcastRequest, type UpdateContactRequest, type UpdateDomainRequest, type UpdateSegmentRequest, type UpdateTemplateRequest, type UpdateWebhookRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookToggleResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -170,6 +170,7 @@ interface Template {
|
|
|
170
170
|
subject: string;
|
|
171
171
|
html_content: string | null;
|
|
172
172
|
text_content: string | null;
|
|
173
|
+
preview_html: string | null;
|
|
173
174
|
variables: string[] | null;
|
|
174
175
|
from_email: string | null;
|
|
175
176
|
reply_to: string | null;
|
|
@@ -202,6 +203,12 @@ interface ListTemplatesParams {
|
|
|
202
203
|
page?: number;
|
|
203
204
|
limit?: number;
|
|
204
205
|
}
|
|
206
|
+
interface PushPreviewResponse {
|
|
207
|
+
preview_url: string;
|
|
208
|
+
}
|
|
209
|
+
interface FetchTemplateOptions {
|
|
210
|
+
preview?: boolean;
|
|
211
|
+
}
|
|
205
212
|
interface DnsRecord {
|
|
206
213
|
type: 'TXT' | 'MX' | 'CNAME';
|
|
207
214
|
name: string;
|
|
@@ -492,23 +499,6 @@ declare class EmailsResource {
|
|
|
492
499
|
* Forward an email to other recipients
|
|
493
500
|
*/
|
|
494
501
|
forward(data: ForwardEmailRequest): Promise<SendEmailResponse>;
|
|
495
|
-
/**
|
|
496
|
-
* Create an email forwarding rule
|
|
497
|
-
*/
|
|
498
|
-
createForwardingRule(data: CreateForwardingRuleRequest): Promise<{
|
|
499
|
-
id: string;
|
|
500
|
-
success: boolean;
|
|
501
|
-
}>;
|
|
502
|
-
/**
|
|
503
|
-
* List all forwarding rules
|
|
504
|
-
*/
|
|
505
|
-
listForwardingRules(): Promise<{
|
|
506
|
-
data: ForwardingRule[];
|
|
507
|
-
}>;
|
|
508
|
-
/**
|
|
509
|
-
* Delete a forwarding rule
|
|
510
|
-
*/
|
|
511
|
-
deleteForwardingRule(id: string): Promise<SuccessResponse>;
|
|
512
502
|
}
|
|
513
503
|
|
|
514
504
|
declare class ContactsResource {
|
|
@@ -575,6 +565,30 @@ declare class TemplatesResource {
|
|
|
575
565
|
* Duplicate a template
|
|
576
566
|
*/
|
|
577
567
|
duplicate(id: string): Promise<Template>;
|
|
568
|
+
/**
|
|
569
|
+
* Push preview HTML for a template
|
|
570
|
+
*
|
|
571
|
+
* Uploads HTML content to the template's preview, which can be accessed
|
|
572
|
+
* publicly at /preview/{template_id} without authentication.
|
|
573
|
+
* This is useful for sharing previews with AI agents for review.
|
|
574
|
+
*
|
|
575
|
+
* @param id - The template ID
|
|
576
|
+
* @param htmlContent - The HTML content for the preview
|
|
577
|
+
* @returns The public preview URL
|
|
578
|
+
*/
|
|
579
|
+
pushPreview(id: string, htmlContent: string): Promise<PushPreviewResponse>;
|
|
580
|
+
/**
|
|
581
|
+
* Fetch template HTML content
|
|
582
|
+
*
|
|
583
|
+
* Downloads the template's HTML content. By default, returns the published
|
|
584
|
+
* html_content. Use `{ preview: true }` to fetch the preview_html instead.
|
|
585
|
+
*
|
|
586
|
+
* @param id - The template ID
|
|
587
|
+
* @param options - Fetch options
|
|
588
|
+
* @param options.preview - If true, fetch preview_html instead of html_content
|
|
589
|
+
* @returns The HTML content as a string
|
|
590
|
+
*/
|
|
591
|
+
fetch(id: string, options?: FetchTemplateOptions): Promise<string>;
|
|
578
592
|
}
|
|
579
593
|
|
|
580
594
|
declare class DomainsResource {
|
|
@@ -825,6 +839,28 @@ declare class MetricsResource {
|
|
|
825
839
|
getEmailMetrics(): Promise<EmailMetrics>;
|
|
826
840
|
}
|
|
827
841
|
|
|
842
|
+
declare class ForwardingRulesResource {
|
|
843
|
+
private readonly http;
|
|
844
|
+
constructor(http: HttpClient);
|
|
845
|
+
/**
|
|
846
|
+
* Create an email forwarding rule
|
|
847
|
+
*/
|
|
848
|
+
create(data: CreateForwardingRuleRequest): Promise<{
|
|
849
|
+
id: string;
|
|
850
|
+
success: boolean;
|
|
851
|
+
}>;
|
|
852
|
+
/**
|
|
853
|
+
* List all forwarding rules
|
|
854
|
+
*/
|
|
855
|
+
list(): Promise<{
|
|
856
|
+
data: ForwardingRule[];
|
|
857
|
+
}>;
|
|
858
|
+
/**
|
|
859
|
+
* Delete a forwarding rule
|
|
860
|
+
*/
|
|
861
|
+
delete(id: string): Promise<SuccessResponse>;
|
|
862
|
+
}
|
|
863
|
+
|
|
828
864
|
/**
|
|
829
865
|
* Configuration options for the Emailr client
|
|
830
866
|
*/
|
|
@@ -908,6 +944,10 @@ declare class Emailr {
|
|
|
908
944
|
* Usage and email metrics
|
|
909
945
|
*/
|
|
910
946
|
readonly metrics: MetricsResource;
|
|
947
|
+
/**
|
|
948
|
+
* Email forwarding rules
|
|
949
|
+
*/
|
|
950
|
+
readonly forwardingRules: ForwardingRulesResource;
|
|
911
951
|
private readonly http;
|
|
912
952
|
constructor(config: EmailrConfig);
|
|
913
953
|
}
|
|
@@ -955,4 +995,4 @@ declare class ValidationError extends EmailrError {
|
|
|
955
995
|
constructor(message: string, details?: Record<string, unknown>, requestId?: string);
|
|
956
996
|
}
|
|
957
997
|
|
|
958
|
-
export { type AddDomainRequest, type ApiKey, type Attachment, AuthenticationError, type Broadcast, type BulkCreateContactsRequest, type BulkCreateContactsResponse, type Contact, type ContactListResponse, type CreateApiKeyRequest, type CreateBroadcastRequest, type CreateContactRequest, type CreateForwardingRuleRequest, type CreateSegmentRequest, type CreateTemplateRequest, type CreateWebhookRequest, type DnsRecord, type DnsVerificationStatus, type Domain, type DomainDnsRecords, type DomainVerificationStatus, type Email, Emailr, Emailr as EmailrClient, type EmailrConfig, EmailrError, type ForwardEmailRequest, type ForwardingRule, type ListApiKeysParams, type ListBroadcastsParams, type ListContactsParams, type ListEmailsParams, type ListSegmentsParams, type ListTemplatesParams, type ListWebhooksParams, NetworkError, NotFoundError, type PaginatedResponse, RateLimitError, type ReplyTo, type Segment, type SendBroadcastResponse, type SendEmailRequest, type SendEmailResponse, type SuccessResponse, type Template, type UpdateBroadcastRequest, type UpdateContactRequest, type UpdateDomainRequest, type UpdateSegmentRequest, type UpdateTemplateRequest, type UpdateWebhookRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookToggleResponse };
|
|
998
|
+
export { type AddDomainRequest, type ApiKey, type Attachment, AuthenticationError, type Broadcast, type BulkCreateContactsRequest, type BulkCreateContactsResponse, type Contact, type ContactListResponse, type CreateApiKeyRequest, type CreateBroadcastRequest, type CreateContactRequest, type CreateForwardingRuleRequest, type CreateSegmentRequest, type CreateTemplateRequest, type CreateWebhookRequest, type DnsRecord, type DnsVerificationStatus, type Domain, type DomainDnsRecords, type DomainVerificationStatus, type Email, Emailr, Emailr as EmailrClient, type EmailrConfig, EmailrError, type FetchTemplateOptions, type ForwardEmailRequest, type ForwardingRule, type ListApiKeysParams, type ListBroadcastsParams, type ListContactsParams, type ListEmailsParams, type ListSegmentsParams, type ListTemplatesParams, type ListWebhooksParams, NetworkError, NotFoundError, type PaginatedResponse, type PushPreviewResponse, RateLimitError, type ReplyTo, type Segment, type SendBroadcastResponse, type SendEmailRequest, type SendEmailResponse, type SuccessResponse, type Template, type UpdateBroadcastRequest, type UpdateContactRequest, type UpdateDomainRequest, type UpdateSegmentRequest, type UpdateTemplateRequest, type UpdateWebhookRequest, ValidationError, type Webhook, type WebhookDelivery, type WebhookToggleResponse };
|
package/dist/index.js
CHANGED
|
@@ -210,24 +210,6 @@ var EmailsResource = class {
|
|
|
210
210
|
async forward(data) {
|
|
211
211
|
return this.http.post("/v1/emails/forward", data);
|
|
212
212
|
}
|
|
213
|
-
/**
|
|
214
|
-
* Create an email forwarding rule
|
|
215
|
-
*/
|
|
216
|
-
async createForwardingRule(data) {
|
|
217
|
-
return this.http.post("/v1/emails/forwarding-rules", data);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* List all forwarding rules
|
|
221
|
-
*/
|
|
222
|
-
async listForwardingRules() {
|
|
223
|
-
return this.http.get("/v1/emails/forwarding-rules");
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Delete a forwarding rule
|
|
227
|
-
*/
|
|
228
|
-
async deleteForwardingRule(id) {
|
|
229
|
-
return this.http.delete(`/v1/emails/forwarding-rules/${id}`);
|
|
230
|
-
}
|
|
231
213
|
};
|
|
232
214
|
|
|
233
215
|
// src/resources/contacts.ts
|
|
@@ -330,6 +312,40 @@ var TemplatesResource = class {
|
|
|
330
312
|
async duplicate(id) {
|
|
331
313
|
return this.http.post(`/v1/templates/${id}/duplicate`);
|
|
332
314
|
}
|
|
315
|
+
/**
|
|
316
|
+
* Push preview HTML for a template
|
|
317
|
+
*
|
|
318
|
+
* Uploads HTML content to the template's preview, which can be accessed
|
|
319
|
+
* publicly at /preview/{template_id} without authentication.
|
|
320
|
+
* This is useful for sharing previews with AI agents for review.
|
|
321
|
+
*
|
|
322
|
+
* @param id - The template ID
|
|
323
|
+
* @param htmlContent - The HTML content for the preview
|
|
324
|
+
* @returns The public preview URL
|
|
325
|
+
*/
|
|
326
|
+
async pushPreview(id, htmlContent) {
|
|
327
|
+
return this.http.put(`/v1/templates/${id}/preview`, {
|
|
328
|
+
html_content: htmlContent
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Fetch template HTML content
|
|
333
|
+
*
|
|
334
|
+
* Downloads the template's HTML content. By default, returns the published
|
|
335
|
+
* html_content. Use `{ preview: true }` to fetch the preview_html instead.
|
|
336
|
+
*
|
|
337
|
+
* @param id - The template ID
|
|
338
|
+
* @param options - Fetch options
|
|
339
|
+
* @param options.preview - If true, fetch preview_html instead of html_content
|
|
340
|
+
* @returns The HTML content as a string
|
|
341
|
+
*/
|
|
342
|
+
async fetch(id, options) {
|
|
343
|
+
const template = await this.get(id);
|
|
344
|
+
if (options?.preview) {
|
|
345
|
+
return template.preview_html ?? "";
|
|
346
|
+
}
|
|
347
|
+
return template.html_content ?? "";
|
|
348
|
+
}
|
|
333
349
|
};
|
|
334
350
|
|
|
335
351
|
// src/resources/domains.ts
|
|
@@ -663,6 +679,31 @@ var MetricsResource = class {
|
|
|
663
679
|
}
|
|
664
680
|
};
|
|
665
681
|
|
|
682
|
+
// src/resources/forwarding-rules.ts
|
|
683
|
+
var ForwardingRulesResource = class {
|
|
684
|
+
constructor(http) {
|
|
685
|
+
this.http = http;
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Create an email forwarding rule
|
|
689
|
+
*/
|
|
690
|
+
async create(data) {
|
|
691
|
+
return this.http.post("/v1/forwarding-rules", data);
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* List all forwarding rules
|
|
695
|
+
*/
|
|
696
|
+
async list() {
|
|
697
|
+
return this.http.get("/v1/forwarding-rules");
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* Delete a forwarding rule
|
|
701
|
+
*/
|
|
702
|
+
async delete(id) {
|
|
703
|
+
return this.http.delete(`/v1/forwarding-rules/${id}`);
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
|
|
666
707
|
// src/client.ts
|
|
667
708
|
var Emailr = class {
|
|
668
709
|
constructor(config) {
|
|
@@ -685,6 +726,7 @@ var Emailr = class {
|
|
|
685
726
|
this.smtp = new SmtpResource(this.http);
|
|
686
727
|
this.settings = new SettingsResource(this.http);
|
|
687
728
|
this.metrics = new MetricsResource(this.http);
|
|
729
|
+
this.forwardingRules = new ForwardingRulesResource(this.http);
|
|
688
730
|
}
|
|
689
731
|
};
|
|
690
732
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.mjs
CHANGED
|
@@ -177,24 +177,6 @@ var EmailsResource = class {
|
|
|
177
177
|
async forward(data) {
|
|
178
178
|
return this.http.post("/v1/emails/forward", data);
|
|
179
179
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Create an email forwarding rule
|
|
182
|
-
*/
|
|
183
|
-
async createForwardingRule(data) {
|
|
184
|
-
return this.http.post("/v1/emails/forwarding-rules", data);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* List all forwarding rules
|
|
188
|
-
*/
|
|
189
|
-
async listForwardingRules() {
|
|
190
|
-
return this.http.get("/v1/emails/forwarding-rules");
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Delete a forwarding rule
|
|
194
|
-
*/
|
|
195
|
-
async deleteForwardingRule(id) {
|
|
196
|
-
return this.http.delete(`/v1/emails/forwarding-rules/${id}`);
|
|
197
|
-
}
|
|
198
180
|
};
|
|
199
181
|
|
|
200
182
|
// src/resources/contacts.ts
|
|
@@ -297,6 +279,40 @@ var TemplatesResource = class {
|
|
|
297
279
|
async duplicate(id) {
|
|
298
280
|
return this.http.post(`/v1/templates/${id}/duplicate`);
|
|
299
281
|
}
|
|
282
|
+
/**
|
|
283
|
+
* Push preview HTML for a template
|
|
284
|
+
*
|
|
285
|
+
* Uploads HTML content to the template's preview, which can be accessed
|
|
286
|
+
* publicly at /preview/{template_id} without authentication.
|
|
287
|
+
* This is useful for sharing previews with AI agents for review.
|
|
288
|
+
*
|
|
289
|
+
* @param id - The template ID
|
|
290
|
+
* @param htmlContent - The HTML content for the preview
|
|
291
|
+
* @returns The public preview URL
|
|
292
|
+
*/
|
|
293
|
+
async pushPreview(id, htmlContent) {
|
|
294
|
+
return this.http.put(`/v1/templates/${id}/preview`, {
|
|
295
|
+
html_content: htmlContent
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Fetch template HTML content
|
|
300
|
+
*
|
|
301
|
+
* Downloads the template's HTML content. By default, returns the published
|
|
302
|
+
* html_content. Use `{ preview: true }` to fetch the preview_html instead.
|
|
303
|
+
*
|
|
304
|
+
* @param id - The template ID
|
|
305
|
+
* @param options - Fetch options
|
|
306
|
+
* @param options.preview - If true, fetch preview_html instead of html_content
|
|
307
|
+
* @returns The HTML content as a string
|
|
308
|
+
*/
|
|
309
|
+
async fetch(id, options) {
|
|
310
|
+
const template = await this.get(id);
|
|
311
|
+
if (options?.preview) {
|
|
312
|
+
return template.preview_html ?? "";
|
|
313
|
+
}
|
|
314
|
+
return template.html_content ?? "";
|
|
315
|
+
}
|
|
300
316
|
};
|
|
301
317
|
|
|
302
318
|
// src/resources/domains.ts
|
|
@@ -630,6 +646,31 @@ var MetricsResource = class {
|
|
|
630
646
|
}
|
|
631
647
|
};
|
|
632
648
|
|
|
649
|
+
// src/resources/forwarding-rules.ts
|
|
650
|
+
var ForwardingRulesResource = class {
|
|
651
|
+
constructor(http) {
|
|
652
|
+
this.http = http;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Create an email forwarding rule
|
|
656
|
+
*/
|
|
657
|
+
async create(data) {
|
|
658
|
+
return this.http.post("/v1/forwarding-rules", data);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* List all forwarding rules
|
|
662
|
+
*/
|
|
663
|
+
async list() {
|
|
664
|
+
return this.http.get("/v1/forwarding-rules");
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Delete a forwarding rule
|
|
668
|
+
*/
|
|
669
|
+
async delete(id) {
|
|
670
|
+
return this.http.delete(`/v1/forwarding-rules/${id}`);
|
|
671
|
+
}
|
|
672
|
+
};
|
|
673
|
+
|
|
633
674
|
// src/client.ts
|
|
634
675
|
var Emailr = class {
|
|
635
676
|
constructor(config) {
|
|
@@ -652,6 +693,7 @@ var Emailr = class {
|
|
|
652
693
|
this.smtp = new SmtpResource(this.http);
|
|
653
694
|
this.settings = new SettingsResource(this.http);
|
|
654
695
|
this.metrics = new MetricsResource(this.http);
|
|
696
|
+
this.forwardingRules = new ForwardingRulesResource(this.http);
|
|
655
697
|
}
|
|
656
698
|
};
|
|
657
699
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "emailr",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Official Emailr API SDK for TypeScript/JavaScript",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
18
23
|
"keywords": [
|
|
19
24
|
"emailr",
|
|
20
25
|
"email",
|
|
@@ -31,10 +36,5 @@
|
|
|
31
36
|
},
|
|
32
37
|
"engines": {
|
|
33
38
|
"node": ">=18.0.0"
|
|
34
|
-
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --clean",
|
|
37
|
-
"test": "vitest run",
|
|
38
|
-
"typecheck": "tsc --noEmit"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|