resend 6.30.0 → 6.31.1-preview-headless-dashboard.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.cjs +20 -3
- package/dist/index.d.cts +109 -18
- package/dist/index.d.mts +109 -18
- package/dist/index.mjs +20 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,7 @@ let postal_mime = require("postal-mime");
|
|
|
25
25
|
postal_mime = __toESM(postal_mime);
|
|
26
26
|
let standardwebhooks = require("standardwebhooks");
|
|
27
27
|
//#region package.json
|
|
28
|
-
var version = "6.
|
|
28
|
+
var version = "6.31.1-preview-headless-dashboard.0";
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/common/utils/build-pagination-query.ts
|
|
31
31
|
function buildPaginationUrl(base, options) {
|
|
@@ -916,12 +916,12 @@ var Emails = class {
|
|
|
916
916
|
return await this.resend.post(`/emails/${id}/share`, { expires_in: payload?.expiresIn });
|
|
917
917
|
}
|
|
918
918
|
async metrics(options = {}) {
|
|
919
|
-
const queryString = buildMetricsQuery(options);
|
|
919
|
+
const queryString = buildMetricsQuery$1(options);
|
|
920
920
|
const url = queryString ? `/emails/metrics?${queryString}` : "/emails/metrics";
|
|
921
921
|
return await this.resend.get(url);
|
|
922
922
|
}
|
|
923
923
|
};
|
|
924
|
-
function buildMetricsQuery(options) {
|
|
924
|
+
function buildMetricsQuery$1(options) {
|
|
925
925
|
const params = {
|
|
926
926
|
start_date: options.startDate,
|
|
927
927
|
end_date: options.endDate,
|
|
@@ -1013,7 +1013,24 @@ var Segments = class {
|
|
|
1013
1013
|
async remove(id) {
|
|
1014
1014
|
return await this.resend.delete(`/segments/${id}`);
|
|
1015
1015
|
}
|
|
1016
|
+
async metrics(options = {}) {
|
|
1017
|
+
const queryString = buildMetricsQuery(options);
|
|
1018
|
+
const url = queryString ? `/segments/metrics?${queryString}` : "/segments/metrics";
|
|
1019
|
+
return await this.resend.get(url);
|
|
1020
|
+
}
|
|
1016
1021
|
};
|
|
1022
|
+
function buildMetricsQuery(options) {
|
|
1023
|
+
const params = {
|
|
1024
|
+
metrics: options.metrics?.join(","),
|
|
1025
|
+
dimensions: options.dimensions?.join(","),
|
|
1026
|
+
segment_id: options.filter?.segmentId?.join(","),
|
|
1027
|
+
sort_by: options.sortBy,
|
|
1028
|
+
sort_order: options.sortOrder
|
|
1029
|
+
};
|
|
1030
|
+
const searchParams = new URLSearchParams();
|
|
1031
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== "") searchParams.set(key, value);
|
|
1032
|
+
return searchParams.toString();
|
|
1033
|
+
}
|
|
1017
1034
|
//#endregion
|
|
1018
1035
|
//#region src/suppressions/batch/batch.ts
|
|
1019
1036
|
var Batch = class {
|
package/dist/index.d.cts
CHANGED
|
@@ -716,19 +716,19 @@ interface EmailRenderOptions {
|
|
|
716
716
|
/**
|
|
717
717
|
* The React component used to write the message.
|
|
718
718
|
*
|
|
719
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
719
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
720
720
|
*/
|
|
721
721
|
react: React$1.ReactNode;
|
|
722
722
|
/**
|
|
723
723
|
* The HTML version of the message.
|
|
724
724
|
*
|
|
725
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
725
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
726
726
|
*/
|
|
727
727
|
html: string;
|
|
728
728
|
/**
|
|
729
729
|
* The plain text version of the message.
|
|
730
730
|
*
|
|
731
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
731
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
732
732
|
*/
|
|
733
733
|
text: string;
|
|
734
734
|
}
|
|
@@ -736,7 +736,7 @@ interface SegmentOptions {
|
|
|
736
736
|
/**
|
|
737
737
|
* The id of the segment you want to send to
|
|
738
738
|
*
|
|
739
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
739
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
740
740
|
*/
|
|
741
741
|
segmentId: string;
|
|
742
742
|
/**
|
|
@@ -749,7 +749,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
749
749
|
* Whether to send the broadcast immediately or keep it as a draft.
|
|
750
750
|
* If not provided or set to false, the broadcast will be created as a draft.
|
|
751
751
|
*
|
|
752
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
752
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
753
753
|
*/
|
|
754
754
|
send: true;
|
|
755
755
|
/**
|
|
@@ -757,7 +757,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
757
757
|
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
|
|
758
758
|
* or relative time (eg: in 2 days).
|
|
759
759
|
*
|
|
760
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
760
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
761
761
|
*/
|
|
762
762
|
scheduledAt?: string;
|
|
763
763
|
} | {
|
|
@@ -765,7 +765,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
765
765
|
* Whether to send the broadcast immediately or keep it as a draft.
|
|
766
766
|
* If not provided or set to false, the broadcast will be created as a draft.
|
|
767
767
|
*
|
|
768
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
768
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
769
769
|
*/
|
|
770
770
|
send?: false;
|
|
771
771
|
/**
|
|
@@ -773,7 +773,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
773
773
|
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
|
|
774
774
|
* or relative time (eg: in 2 days).
|
|
775
775
|
*
|
|
776
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
776
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
777
777
|
*/
|
|
778
778
|
scheduledAt?: never;
|
|
779
779
|
};
|
|
@@ -781,37 +781,37 @@ interface CreateBroadcastBaseOptions {
|
|
|
781
781
|
/**
|
|
782
782
|
* The name of the broadcast
|
|
783
783
|
*
|
|
784
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
784
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
785
785
|
*/
|
|
786
786
|
name?: string;
|
|
787
787
|
/**
|
|
788
788
|
* A short snippet of text displayed as a preview in recipients' inboxes, often shown below or beside the subject line.
|
|
789
789
|
*
|
|
790
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
790
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
791
791
|
*/
|
|
792
792
|
previewText?: string;
|
|
793
793
|
/**
|
|
794
794
|
* Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
|
|
795
795
|
*
|
|
796
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
796
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
797
797
|
*/
|
|
798
798
|
from: string;
|
|
799
799
|
/**
|
|
800
800
|
* Reply-to email address. For multiple addresses, send as an array of strings.
|
|
801
801
|
*
|
|
802
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
802
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
803
803
|
*/
|
|
804
804
|
replyTo?: string | string[];
|
|
805
805
|
/**
|
|
806
806
|
* Email subject.
|
|
807
807
|
*
|
|
808
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
808
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
809
809
|
*/
|
|
810
810
|
subject: string;
|
|
811
811
|
/**
|
|
812
812
|
* The id of the topic you want to send to
|
|
813
813
|
*
|
|
814
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
814
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
815
815
|
*/
|
|
816
816
|
topicId?: string | null;
|
|
817
817
|
}
|
|
@@ -917,7 +917,7 @@ interface SendBroadcastBaseOptions {
|
|
|
917
917
|
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
|
|
918
918
|
* or relative time (eg: in 2 days).
|
|
919
919
|
*
|
|
920
|
-
* @link https://resend.com/docs/api-reference/broadcasts/send#body-parameters
|
|
920
|
+
* @link https://resend.com/docs/api-reference/broadcasts/send-broadcast#body-parameters
|
|
921
921
|
*/
|
|
922
922
|
scheduledAt?: string;
|
|
923
923
|
}
|
|
@@ -2034,6 +2034,60 @@ export interface CreateSegmentResponseSuccess extends Pick<Segment, 'name' | 'id
|
|
|
2034
2034
|
}
|
|
2035
2035
|
export type CreateSegmentResponse = Response<CreateSegmentResponseSuccess>;
|
|
2036
2036
|
//#endregion
|
|
2037
|
+
//#region src/segments/interfaces/get-metrics.interface.d.ts
|
|
2038
|
+
export type SegmentMetric = 'all_contacts' | 'subscribers' | 'unsubscribers';
|
|
2039
|
+
export type SegmentMetricsDimension = 'segment';
|
|
2040
|
+
export type SegmentMetricsSortBy = 'date' | SegmentMetric;
|
|
2041
|
+
export type SegmentMetricsSortOrder = 'asc' | 'desc';
|
|
2042
|
+
export type GetSegmentsMetricsOptions = {
|
|
2043
|
+
/**
|
|
2044
|
+
* The metrics to include in the response. Defaults to all metrics.
|
|
2045
|
+
*
|
|
2046
|
+
* @link https://resend.com/docs/api-reference/segments/get-segment-metrics#query-parameters
|
|
2047
|
+
*/
|
|
2048
|
+
metrics?: SegmentMetric[];
|
|
2049
|
+
/**
|
|
2050
|
+
* The dimensions to break `data` down by. Defaults to `[]`, which returns
|
|
2051
|
+
* only `totals` with no `data`.
|
|
2052
|
+
*/
|
|
2053
|
+
dimensions?: SegmentMetricsDimension[];
|
|
2054
|
+
filter?: {
|
|
2055
|
+
/**
|
|
2056
|
+
* Restrict `totals` (and `data`, when requested) to these segment IDs,
|
|
2057
|
+
* without double-counting contacts that belong to more than one.
|
|
2058
|
+
*/
|
|
2059
|
+
segmentId?: string[];
|
|
2060
|
+
};
|
|
2061
|
+
/**
|
|
2062
|
+
* What to sort the segment breakdown by: `date` (each segment's creation
|
|
2063
|
+
* date), or a metric key to sort by that value instead. Only applies to
|
|
2064
|
+
* `data` (when `dimensions` includes `segment`) — `totals` ignores sort
|
|
2065
|
+
* params. Defaults to `date`.
|
|
2066
|
+
*
|
|
2067
|
+
* @link https://resend.com/docs/api-reference/segments/get-segment-metrics#query-parameters
|
|
2068
|
+
*/
|
|
2069
|
+
sortBy?: SegmentMetricsSortBy;
|
|
2070
|
+
/**
|
|
2071
|
+
* The sort direction for `sortBy`. Defaults to `desc`.
|
|
2072
|
+
*/
|
|
2073
|
+
sortOrder?: SegmentMetricsSortOrder;
|
|
2074
|
+
};
|
|
2075
|
+
export type SegmentMetricsTotals = Partial<Record<SegmentMetric, number>>;
|
|
2076
|
+
export type SegmentMetricsDataRow = SegmentMetricsTotals & {
|
|
2077
|
+
segment_id: string;
|
|
2078
|
+
segment_name: string;
|
|
2079
|
+
};
|
|
2080
|
+
export interface GetSegmentsMetricsResponseSuccess {
|
|
2081
|
+
object: 'segments_metrics';
|
|
2082
|
+
metrics: SegmentMetric[];
|
|
2083
|
+
dimensions: SegmentMetricsDimension[];
|
|
2084
|
+
sort_by: SegmentMetricsSortBy;
|
|
2085
|
+
sort_order: SegmentMetricsSortOrder;
|
|
2086
|
+
totals: SegmentMetricsTotals;
|
|
2087
|
+
data?: SegmentMetricsDataRow[];
|
|
2088
|
+
}
|
|
2089
|
+
export type GetSegmentsMetricsResponse = Response<GetSegmentsMetricsResponseSuccess>;
|
|
2090
|
+
//#endregion
|
|
2037
2091
|
//#region src/segments/interfaces/get-segment.interface.d.ts
|
|
2038
2092
|
export interface GetSegmentResponseSuccess extends Pick<Segment, 'id' | 'name' | 'created_at'> {
|
|
2039
2093
|
object: 'segment';
|
|
@@ -2074,6 +2128,7 @@ declare class Segments {
|
|
|
2074
2128
|
get(id: string): Promise<GetSegmentResponse>;
|
|
2075
2129
|
update(id: string, payload: UpdateSegmentOptions): Promise<UpdateSegmentResponse>;
|
|
2076
2130
|
remove(id: string): Promise<RemoveSegmentResponse>;
|
|
2131
|
+
metrics(options?: GetSegmentsMetricsOptions): Promise<GetSegmentsMetricsResponse>;
|
|
2077
2132
|
}
|
|
2078
2133
|
//#endregion
|
|
2079
2134
|
//#region src/suppressions/batch/interfaces/batch-add-suppressions.interface.d.ts
|
|
@@ -2408,7 +2463,7 @@ declare class Usage {
|
|
|
2408
2463
|
}
|
|
2409
2464
|
//#endregion
|
|
2410
2465
|
//#region src/webhooks/interfaces/webhook-event.interface.d.ts
|
|
2411
|
-
type WebhookEvent = 'email.sent' | 'email.scheduled' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.received' | 'email.failed' | 'email.suppressed' | 'contact.created' | 'contact.updated' | 'contact.deleted' | 'domain.created' | 'domain.updated' | 'domain.deleted' | 'suppression.added' | 'suppression.removed';
|
|
2466
|
+
type WebhookEvent = 'email.sent' | 'email.scheduled' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.received' | 'email.failed' | 'email.suppressed' | 'contact.created' | 'contact.updated' | 'contact.deleted' | 'contact.topics.updated' | 'domain.created' | 'domain.updated' | 'domain.deleted' | 'suppression.added' | 'suppression.removed' | 'topic.created' | 'topic.updated' | 'topic.deleted';
|
|
2412
2467
|
interface BaseEmailEventData {
|
|
2413
2468
|
broadcast_id?: string;
|
|
2414
2469
|
created_at: string;
|
|
@@ -2468,6 +2523,13 @@ interface ContactEventData {
|
|
|
2468
2523
|
last_name?: string | null;
|
|
2469
2524
|
unsubscribed: boolean;
|
|
2470
2525
|
}
|
|
2526
|
+
interface ContactTopicsEventData {
|
|
2527
|
+
email: string;
|
|
2528
|
+
topics: {
|
|
2529
|
+
id: string;
|
|
2530
|
+
subscription: 'opt_in' | 'opt_out';
|
|
2531
|
+
}[];
|
|
2532
|
+
}
|
|
2471
2533
|
interface DomainRecord {
|
|
2472
2534
|
record: string;
|
|
2473
2535
|
name: string;
|
|
@@ -2492,6 +2554,15 @@ interface SuppressionEventData {
|
|
|
2492
2554
|
source_id: string | null;
|
|
2493
2555
|
created_at: string;
|
|
2494
2556
|
}
|
|
2557
|
+
interface TopicEventData {
|
|
2558
|
+
id: string;
|
|
2559
|
+
name: string;
|
|
2560
|
+
description: string | null;
|
|
2561
|
+
default_subscription: 'opt_in' | 'opt_out';
|
|
2562
|
+
deleted: boolean;
|
|
2563
|
+
created_at: string;
|
|
2564
|
+
updated_at: string;
|
|
2565
|
+
}
|
|
2495
2566
|
interface EmailSentEvent {
|
|
2496
2567
|
type: 'email.sent';
|
|
2497
2568
|
created_at: string;
|
|
@@ -2570,6 +2641,11 @@ interface ContactDeletedEvent {
|
|
|
2570
2641
|
created_at: string;
|
|
2571
2642
|
data: ContactEventData;
|
|
2572
2643
|
}
|
|
2644
|
+
interface ContactTopicsUpdatedEvent {
|
|
2645
|
+
type: 'contact.topics.updated';
|
|
2646
|
+
created_at: string;
|
|
2647
|
+
data: ContactTopicsEventData;
|
|
2648
|
+
}
|
|
2573
2649
|
interface DomainCreatedEvent {
|
|
2574
2650
|
type: 'domain.created';
|
|
2575
2651
|
created_at: string;
|
|
@@ -2595,7 +2671,22 @@ interface SuppressionRemovedEvent {
|
|
|
2595
2671
|
created_at: string;
|
|
2596
2672
|
data: SuppressionEventData;
|
|
2597
2673
|
}
|
|
2598
|
-
|
|
2674
|
+
interface TopicCreatedEvent {
|
|
2675
|
+
type: 'topic.created';
|
|
2676
|
+
created_at: string;
|
|
2677
|
+
data: TopicEventData;
|
|
2678
|
+
}
|
|
2679
|
+
interface TopicUpdatedEvent {
|
|
2680
|
+
type: 'topic.updated';
|
|
2681
|
+
created_at: string;
|
|
2682
|
+
data: TopicEventData;
|
|
2683
|
+
}
|
|
2684
|
+
interface TopicDeletedEvent {
|
|
2685
|
+
type: 'topic.deleted';
|
|
2686
|
+
created_at: string;
|
|
2687
|
+
data: TopicEventData;
|
|
2688
|
+
}
|
|
2689
|
+
type WebhookEventPayload = EmailSentEvent | EmailScheduledEvent | EmailDeliveredEvent | EmailDeliveryDelayedEvent | EmailComplainedEvent | EmailBouncedEvent | EmailOpenedEvent | EmailClickedEvent | EmailReceivedEvent | EmailFailedEvent | EmailSuppressedEvent | ContactCreatedEvent | ContactUpdatedEvent | ContactDeletedEvent | ContactTopicsUpdatedEvent | DomainCreatedEvent | DomainUpdatedEvent | DomainDeletedEvent | SuppressionAddedEvent | SuppressionRemovedEvent | TopicCreatedEvent | TopicUpdatedEvent | TopicDeletedEvent;
|
|
2599
2690
|
//#endregion
|
|
2600
2691
|
//#region src/webhooks/interfaces/list-webhook-events.interface.d.ts
|
|
2601
2692
|
type WebhookEventLogStatus = 'success' | 'pending' | 'failed' | 'attempting';
|
|
@@ -2814,4 +2905,4 @@ export declare class Resend {
|
|
|
2814
2905
|
delete<T>(path: string, query?: unknown, options?: DeleteOptions): Promise<Response<T>>;
|
|
2815
2906
|
}
|
|
2816
2907
|
//#endregion
|
|
2817
|
-
export type { ContactCreatedEvent, ContactDeletedEvent, ContactUpdatedEvent, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DomainCreatedEvent, DomainDeletedEvent, DomainUpdatedEvent, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, ErrorResponse, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetWebhookEventOptions, GetWebhookEventResponse, GetWebhookEventResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListOAuthGrantsOptions, ListOAuthGrantsResponse, ListOAuthGrantsResponseSuccess, ListWebhookEventAttemptsOptions, ListWebhookEventAttemptsResponse, ListWebhookEventAttemptsResponseSuccess, ListWebhookEventsOptions, ListWebhookEventsResponse, ListWebhookEventsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, OAuthGrant, RemoveWebhookResponse, RemoveWebhookResponseSuccess, ReplayWebhookEventOptions, ReplayWebhookEventResponse, ReplayWebhookEventResponseSuccess, ResendOptions, Response, RevokeOAuthGrantResponse, RevokeOAuthGrantResponseSuccess, RotateWebhookSigningSecretResponse, RotateWebhookSigningSecretResponseSuccess, SuppressionAddedEvent, SuppressionRemovedEvent, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, Webhook, WebhookEvent, WebhookEventAttempt, WebhookEventLog, WebhookEventLogStatus, WebhookEventPayload };
|
|
2908
|
+
export type { ContactCreatedEvent, ContactDeletedEvent, ContactTopicsUpdatedEvent, ContactUpdatedEvent, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DomainCreatedEvent, DomainDeletedEvent, DomainUpdatedEvent, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, ErrorResponse, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetWebhookEventOptions, GetWebhookEventResponse, GetWebhookEventResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListOAuthGrantsOptions, ListOAuthGrantsResponse, ListOAuthGrantsResponseSuccess, ListWebhookEventAttemptsOptions, ListWebhookEventAttemptsResponse, ListWebhookEventAttemptsResponseSuccess, ListWebhookEventsOptions, ListWebhookEventsResponse, ListWebhookEventsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, OAuthGrant, RemoveWebhookResponse, RemoveWebhookResponseSuccess, ReplayWebhookEventOptions, ReplayWebhookEventResponse, ReplayWebhookEventResponseSuccess, ResendOptions, Response, RevokeOAuthGrantResponse, RevokeOAuthGrantResponseSuccess, RotateWebhookSigningSecretResponse, RotateWebhookSigningSecretResponseSuccess, SuppressionAddedEvent, SuppressionRemovedEvent, TopicCreatedEvent, TopicDeletedEvent, TopicUpdatedEvent, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, Webhook, WebhookEvent, WebhookEventAttempt, WebhookEventLog, WebhookEventLogStatus, WebhookEventPayload };
|
package/dist/index.d.mts
CHANGED
|
@@ -716,19 +716,19 @@ interface EmailRenderOptions {
|
|
|
716
716
|
/**
|
|
717
717
|
* The React component used to write the message.
|
|
718
718
|
*
|
|
719
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
719
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
720
720
|
*/
|
|
721
721
|
react: React$1.ReactNode;
|
|
722
722
|
/**
|
|
723
723
|
* The HTML version of the message.
|
|
724
724
|
*
|
|
725
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
725
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
726
726
|
*/
|
|
727
727
|
html: string;
|
|
728
728
|
/**
|
|
729
729
|
* The plain text version of the message.
|
|
730
730
|
*
|
|
731
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
731
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
732
732
|
*/
|
|
733
733
|
text: string;
|
|
734
734
|
}
|
|
@@ -736,7 +736,7 @@ interface SegmentOptions {
|
|
|
736
736
|
/**
|
|
737
737
|
* The id of the segment you want to send to
|
|
738
738
|
*
|
|
739
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
739
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
740
740
|
*/
|
|
741
741
|
segmentId: string;
|
|
742
742
|
/**
|
|
@@ -749,7 +749,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
749
749
|
* Whether to send the broadcast immediately or keep it as a draft.
|
|
750
750
|
* If not provided or set to false, the broadcast will be created as a draft.
|
|
751
751
|
*
|
|
752
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
752
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
753
753
|
*/
|
|
754
754
|
send: true;
|
|
755
755
|
/**
|
|
@@ -757,7 +757,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
757
757
|
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
|
|
758
758
|
* or relative time (eg: in 2 days).
|
|
759
759
|
*
|
|
760
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
760
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
761
761
|
*/
|
|
762
762
|
scheduledAt?: string;
|
|
763
763
|
} | {
|
|
@@ -765,7 +765,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
765
765
|
* Whether to send the broadcast immediately or keep it as a draft.
|
|
766
766
|
* If not provided or set to false, the broadcast will be created as a draft.
|
|
767
767
|
*
|
|
768
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
768
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
769
769
|
*/
|
|
770
770
|
send?: false;
|
|
771
771
|
/**
|
|
@@ -773,7 +773,7 @@ type SendBroadcastOnCreationOptions = {
|
|
|
773
773
|
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
|
|
774
774
|
* or relative time (eg: in 2 days).
|
|
775
775
|
*
|
|
776
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
776
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
777
777
|
*/
|
|
778
778
|
scheduledAt?: never;
|
|
779
779
|
};
|
|
@@ -781,37 +781,37 @@ interface CreateBroadcastBaseOptions {
|
|
|
781
781
|
/**
|
|
782
782
|
* The name of the broadcast
|
|
783
783
|
*
|
|
784
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
784
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
785
785
|
*/
|
|
786
786
|
name?: string;
|
|
787
787
|
/**
|
|
788
788
|
* A short snippet of text displayed as a preview in recipients' inboxes, often shown below or beside the subject line.
|
|
789
789
|
*
|
|
790
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
790
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
791
791
|
*/
|
|
792
792
|
previewText?: string;
|
|
793
793
|
/**
|
|
794
794
|
* Sender email address. To include a friendly name, use the format `"Your Name <sender@domain.com>"`
|
|
795
795
|
*
|
|
796
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
796
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
797
797
|
*/
|
|
798
798
|
from: string;
|
|
799
799
|
/**
|
|
800
800
|
* Reply-to email address. For multiple addresses, send as an array of strings.
|
|
801
801
|
*
|
|
802
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
802
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
803
803
|
*/
|
|
804
804
|
replyTo?: string | string[];
|
|
805
805
|
/**
|
|
806
806
|
* Email subject.
|
|
807
807
|
*
|
|
808
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
808
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
809
809
|
*/
|
|
810
810
|
subject: string;
|
|
811
811
|
/**
|
|
812
812
|
* The id of the topic you want to send to
|
|
813
813
|
*
|
|
814
|
-
* @link https://resend.com/docs/api-reference/broadcasts/create#body-parameters
|
|
814
|
+
* @link https://resend.com/docs/api-reference/broadcasts/create-broadcast#body-parameters
|
|
815
815
|
*/
|
|
816
816
|
topicId?: string | null;
|
|
817
817
|
}
|
|
@@ -917,7 +917,7 @@ interface SendBroadcastBaseOptions {
|
|
|
917
917
|
* The date should be in ISO 8601 format (e.g: 2024-08-05T11:52:01.858Z)
|
|
918
918
|
* or relative time (eg: in 2 days).
|
|
919
919
|
*
|
|
920
|
-
* @link https://resend.com/docs/api-reference/broadcasts/send#body-parameters
|
|
920
|
+
* @link https://resend.com/docs/api-reference/broadcasts/send-broadcast#body-parameters
|
|
921
921
|
*/
|
|
922
922
|
scheduledAt?: string;
|
|
923
923
|
}
|
|
@@ -2034,6 +2034,60 @@ export interface CreateSegmentResponseSuccess extends Pick<Segment, 'name' | 'id
|
|
|
2034
2034
|
}
|
|
2035
2035
|
export type CreateSegmentResponse = Response<CreateSegmentResponseSuccess>;
|
|
2036
2036
|
//#endregion
|
|
2037
|
+
//#region src/segments/interfaces/get-metrics.interface.d.ts
|
|
2038
|
+
export type SegmentMetric = 'all_contacts' | 'subscribers' | 'unsubscribers';
|
|
2039
|
+
export type SegmentMetricsDimension = 'segment';
|
|
2040
|
+
export type SegmentMetricsSortBy = 'date' | SegmentMetric;
|
|
2041
|
+
export type SegmentMetricsSortOrder = 'asc' | 'desc';
|
|
2042
|
+
export type GetSegmentsMetricsOptions = {
|
|
2043
|
+
/**
|
|
2044
|
+
* The metrics to include in the response. Defaults to all metrics.
|
|
2045
|
+
*
|
|
2046
|
+
* @link https://resend.com/docs/api-reference/segments/get-segment-metrics#query-parameters
|
|
2047
|
+
*/
|
|
2048
|
+
metrics?: SegmentMetric[];
|
|
2049
|
+
/**
|
|
2050
|
+
* The dimensions to break `data` down by. Defaults to `[]`, which returns
|
|
2051
|
+
* only `totals` with no `data`.
|
|
2052
|
+
*/
|
|
2053
|
+
dimensions?: SegmentMetricsDimension[];
|
|
2054
|
+
filter?: {
|
|
2055
|
+
/**
|
|
2056
|
+
* Restrict `totals` (and `data`, when requested) to these segment IDs,
|
|
2057
|
+
* without double-counting contacts that belong to more than one.
|
|
2058
|
+
*/
|
|
2059
|
+
segmentId?: string[];
|
|
2060
|
+
};
|
|
2061
|
+
/**
|
|
2062
|
+
* What to sort the segment breakdown by: `date` (each segment's creation
|
|
2063
|
+
* date), or a metric key to sort by that value instead. Only applies to
|
|
2064
|
+
* `data` (when `dimensions` includes `segment`) — `totals` ignores sort
|
|
2065
|
+
* params. Defaults to `date`.
|
|
2066
|
+
*
|
|
2067
|
+
* @link https://resend.com/docs/api-reference/segments/get-segment-metrics#query-parameters
|
|
2068
|
+
*/
|
|
2069
|
+
sortBy?: SegmentMetricsSortBy;
|
|
2070
|
+
/**
|
|
2071
|
+
* The sort direction for `sortBy`. Defaults to `desc`.
|
|
2072
|
+
*/
|
|
2073
|
+
sortOrder?: SegmentMetricsSortOrder;
|
|
2074
|
+
};
|
|
2075
|
+
export type SegmentMetricsTotals = Partial<Record<SegmentMetric, number>>;
|
|
2076
|
+
export type SegmentMetricsDataRow = SegmentMetricsTotals & {
|
|
2077
|
+
segment_id: string;
|
|
2078
|
+
segment_name: string;
|
|
2079
|
+
};
|
|
2080
|
+
export interface GetSegmentsMetricsResponseSuccess {
|
|
2081
|
+
object: 'segments_metrics';
|
|
2082
|
+
metrics: SegmentMetric[];
|
|
2083
|
+
dimensions: SegmentMetricsDimension[];
|
|
2084
|
+
sort_by: SegmentMetricsSortBy;
|
|
2085
|
+
sort_order: SegmentMetricsSortOrder;
|
|
2086
|
+
totals: SegmentMetricsTotals;
|
|
2087
|
+
data?: SegmentMetricsDataRow[];
|
|
2088
|
+
}
|
|
2089
|
+
export type GetSegmentsMetricsResponse = Response<GetSegmentsMetricsResponseSuccess>;
|
|
2090
|
+
//#endregion
|
|
2037
2091
|
//#region src/segments/interfaces/get-segment.interface.d.ts
|
|
2038
2092
|
export interface GetSegmentResponseSuccess extends Pick<Segment, 'id' | 'name' | 'created_at'> {
|
|
2039
2093
|
object: 'segment';
|
|
@@ -2074,6 +2128,7 @@ declare class Segments {
|
|
|
2074
2128
|
get(id: string): Promise<GetSegmentResponse>;
|
|
2075
2129
|
update(id: string, payload: UpdateSegmentOptions): Promise<UpdateSegmentResponse>;
|
|
2076
2130
|
remove(id: string): Promise<RemoveSegmentResponse>;
|
|
2131
|
+
metrics(options?: GetSegmentsMetricsOptions): Promise<GetSegmentsMetricsResponse>;
|
|
2077
2132
|
}
|
|
2078
2133
|
//#endregion
|
|
2079
2134
|
//#region src/suppressions/batch/interfaces/batch-add-suppressions.interface.d.ts
|
|
@@ -2408,7 +2463,7 @@ declare class Usage {
|
|
|
2408
2463
|
}
|
|
2409
2464
|
//#endregion
|
|
2410
2465
|
//#region src/webhooks/interfaces/webhook-event.interface.d.ts
|
|
2411
|
-
type WebhookEvent = 'email.sent' | 'email.scheduled' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.received' | 'email.failed' | 'email.suppressed' | 'contact.created' | 'contact.updated' | 'contact.deleted' | 'domain.created' | 'domain.updated' | 'domain.deleted' | 'suppression.added' | 'suppression.removed';
|
|
2466
|
+
type WebhookEvent = 'email.sent' | 'email.scheduled' | 'email.delivered' | 'email.delivery_delayed' | 'email.complained' | 'email.bounced' | 'email.opened' | 'email.clicked' | 'email.received' | 'email.failed' | 'email.suppressed' | 'contact.created' | 'contact.updated' | 'contact.deleted' | 'contact.topics.updated' | 'domain.created' | 'domain.updated' | 'domain.deleted' | 'suppression.added' | 'suppression.removed' | 'topic.created' | 'topic.updated' | 'topic.deleted';
|
|
2412
2467
|
interface BaseEmailEventData {
|
|
2413
2468
|
broadcast_id?: string;
|
|
2414
2469
|
created_at: string;
|
|
@@ -2468,6 +2523,13 @@ interface ContactEventData {
|
|
|
2468
2523
|
last_name?: string | null;
|
|
2469
2524
|
unsubscribed: boolean;
|
|
2470
2525
|
}
|
|
2526
|
+
interface ContactTopicsEventData {
|
|
2527
|
+
email: string;
|
|
2528
|
+
topics: {
|
|
2529
|
+
id: string;
|
|
2530
|
+
subscription: 'opt_in' | 'opt_out';
|
|
2531
|
+
}[];
|
|
2532
|
+
}
|
|
2471
2533
|
interface DomainRecord {
|
|
2472
2534
|
record: string;
|
|
2473
2535
|
name: string;
|
|
@@ -2492,6 +2554,15 @@ interface SuppressionEventData {
|
|
|
2492
2554
|
source_id: string | null;
|
|
2493
2555
|
created_at: string;
|
|
2494
2556
|
}
|
|
2557
|
+
interface TopicEventData {
|
|
2558
|
+
id: string;
|
|
2559
|
+
name: string;
|
|
2560
|
+
description: string | null;
|
|
2561
|
+
default_subscription: 'opt_in' | 'opt_out';
|
|
2562
|
+
deleted: boolean;
|
|
2563
|
+
created_at: string;
|
|
2564
|
+
updated_at: string;
|
|
2565
|
+
}
|
|
2495
2566
|
interface EmailSentEvent {
|
|
2496
2567
|
type: 'email.sent';
|
|
2497
2568
|
created_at: string;
|
|
@@ -2570,6 +2641,11 @@ interface ContactDeletedEvent {
|
|
|
2570
2641
|
created_at: string;
|
|
2571
2642
|
data: ContactEventData;
|
|
2572
2643
|
}
|
|
2644
|
+
interface ContactTopicsUpdatedEvent {
|
|
2645
|
+
type: 'contact.topics.updated';
|
|
2646
|
+
created_at: string;
|
|
2647
|
+
data: ContactTopicsEventData;
|
|
2648
|
+
}
|
|
2573
2649
|
interface DomainCreatedEvent {
|
|
2574
2650
|
type: 'domain.created';
|
|
2575
2651
|
created_at: string;
|
|
@@ -2595,7 +2671,22 @@ interface SuppressionRemovedEvent {
|
|
|
2595
2671
|
created_at: string;
|
|
2596
2672
|
data: SuppressionEventData;
|
|
2597
2673
|
}
|
|
2598
|
-
|
|
2674
|
+
interface TopicCreatedEvent {
|
|
2675
|
+
type: 'topic.created';
|
|
2676
|
+
created_at: string;
|
|
2677
|
+
data: TopicEventData;
|
|
2678
|
+
}
|
|
2679
|
+
interface TopicUpdatedEvent {
|
|
2680
|
+
type: 'topic.updated';
|
|
2681
|
+
created_at: string;
|
|
2682
|
+
data: TopicEventData;
|
|
2683
|
+
}
|
|
2684
|
+
interface TopicDeletedEvent {
|
|
2685
|
+
type: 'topic.deleted';
|
|
2686
|
+
created_at: string;
|
|
2687
|
+
data: TopicEventData;
|
|
2688
|
+
}
|
|
2689
|
+
type WebhookEventPayload = EmailSentEvent | EmailScheduledEvent | EmailDeliveredEvent | EmailDeliveryDelayedEvent | EmailComplainedEvent | EmailBouncedEvent | EmailOpenedEvent | EmailClickedEvent | EmailReceivedEvent | EmailFailedEvent | EmailSuppressedEvent | ContactCreatedEvent | ContactUpdatedEvent | ContactDeletedEvent | ContactTopicsUpdatedEvent | DomainCreatedEvent | DomainUpdatedEvent | DomainDeletedEvent | SuppressionAddedEvent | SuppressionRemovedEvent | TopicCreatedEvent | TopicUpdatedEvent | TopicDeletedEvent;
|
|
2599
2690
|
//#endregion
|
|
2600
2691
|
//#region src/webhooks/interfaces/list-webhook-events.interface.d.ts
|
|
2601
2692
|
type WebhookEventLogStatus = 'success' | 'pending' | 'failed' | 'attempting';
|
|
@@ -2814,4 +2905,4 @@ export declare class Resend {
|
|
|
2814
2905
|
delete<T>(path: string, query?: unknown, options?: DeleteOptions): Promise<Response<T>>;
|
|
2815
2906
|
}
|
|
2816
2907
|
//#endregion
|
|
2817
|
-
export type { ContactCreatedEvent, ContactDeletedEvent, ContactUpdatedEvent, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DomainCreatedEvent, DomainDeletedEvent, DomainUpdatedEvent, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, ErrorResponse, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetWebhookEventOptions, GetWebhookEventResponse, GetWebhookEventResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListOAuthGrantsOptions, ListOAuthGrantsResponse, ListOAuthGrantsResponseSuccess, ListWebhookEventAttemptsOptions, ListWebhookEventAttemptsResponse, ListWebhookEventAttemptsResponseSuccess, ListWebhookEventsOptions, ListWebhookEventsResponse, ListWebhookEventsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, OAuthGrant, RemoveWebhookResponse, RemoveWebhookResponseSuccess, ReplayWebhookEventOptions, ReplayWebhookEventResponse, ReplayWebhookEventResponseSuccess, ResendOptions, Response, RevokeOAuthGrantResponse, RevokeOAuthGrantResponseSuccess, RotateWebhookSigningSecretResponse, RotateWebhookSigningSecretResponseSuccess, SuppressionAddedEvent, SuppressionRemovedEvent, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, Webhook, WebhookEvent, WebhookEventAttempt, WebhookEventLog, WebhookEventLogStatus, WebhookEventPayload };
|
|
2908
|
+
export type { ContactCreatedEvent, ContactDeletedEvent, ContactTopicsUpdatedEvent, ContactUpdatedEvent, CreateWebhookOptions, CreateWebhookRequestOptions, CreateWebhookResponse, CreateWebhookResponseSuccess, DomainCreatedEvent, DomainDeletedEvent, DomainUpdatedEvent, EmailBouncedEvent, EmailClickedEvent, EmailComplainedEvent, EmailDeliveredEvent, EmailDeliveryDelayedEvent, EmailFailedEvent, EmailOpenedEvent, EmailReceivedEvent, EmailScheduledEvent, EmailSentEvent, EmailSuppressedEvent, ErrorResponse, GetAttachmentOptions, GetAttachmentResponse, GetAttachmentResponseSuccess, GetWebhookEventOptions, GetWebhookEventResponse, GetWebhookEventResponseSuccess, GetWebhookResponse, GetWebhookResponseSuccess, ListAttachmentsOptions, ListAttachmentsResponse, ListAttachmentsResponseSuccess, ListOAuthGrantsOptions, ListOAuthGrantsResponse, ListOAuthGrantsResponseSuccess, ListWebhookEventAttemptsOptions, ListWebhookEventAttemptsResponse, ListWebhookEventAttemptsResponseSuccess, ListWebhookEventsOptions, ListWebhookEventsResponse, ListWebhookEventsResponseSuccess, ListWebhooksOptions, ListWebhooksResponse, ListWebhooksResponseSuccess, OAuthGrant, RemoveWebhookResponse, RemoveWebhookResponseSuccess, ReplayWebhookEventOptions, ReplayWebhookEventResponse, ReplayWebhookEventResponseSuccess, ResendOptions, Response, RevokeOAuthGrantResponse, RevokeOAuthGrantResponseSuccess, RotateWebhookSigningSecretResponse, RotateWebhookSigningSecretResponseSuccess, SuppressionAddedEvent, SuppressionRemovedEvent, TopicCreatedEvent, TopicDeletedEvent, TopicUpdatedEvent, UpdateWebhookOptions, UpdateWebhookResponse, UpdateWebhookResponseSuccess, Webhook, WebhookEvent, WebhookEventAttempt, WebhookEventLog, WebhookEventLogStatus, WebhookEventPayload };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import PostalMime from "postal-mime";
|
|
2
2
|
import { Webhook } from "standardwebhooks";
|
|
3
3
|
//#region package.json
|
|
4
|
-
var version = "6.
|
|
4
|
+
var version = "6.31.1-preview-headless-dashboard.0";
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/common/utils/build-pagination-query.ts
|
|
7
7
|
function buildPaginationUrl(base, options) {
|
|
@@ -892,12 +892,12 @@ var Emails = class {
|
|
|
892
892
|
return await this.resend.post(`/emails/${id}/share`, { expires_in: payload?.expiresIn });
|
|
893
893
|
}
|
|
894
894
|
async metrics(options = {}) {
|
|
895
|
-
const queryString = buildMetricsQuery(options);
|
|
895
|
+
const queryString = buildMetricsQuery$1(options);
|
|
896
896
|
const url = queryString ? `/emails/metrics?${queryString}` : "/emails/metrics";
|
|
897
897
|
return await this.resend.get(url);
|
|
898
898
|
}
|
|
899
899
|
};
|
|
900
|
-
function buildMetricsQuery(options) {
|
|
900
|
+
function buildMetricsQuery$1(options) {
|
|
901
901
|
const params = {
|
|
902
902
|
start_date: options.startDate,
|
|
903
903
|
end_date: options.endDate,
|
|
@@ -989,7 +989,24 @@ var Segments = class {
|
|
|
989
989
|
async remove(id) {
|
|
990
990
|
return await this.resend.delete(`/segments/${id}`);
|
|
991
991
|
}
|
|
992
|
+
async metrics(options = {}) {
|
|
993
|
+
const queryString = buildMetricsQuery(options);
|
|
994
|
+
const url = queryString ? `/segments/metrics?${queryString}` : "/segments/metrics";
|
|
995
|
+
return await this.resend.get(url);
|
|
996
|
+
}
|
|
992
997
|
};
|
|
998
|
+
function buildMetricsQuery(options) {
|
|
999
|
+
const params = {
|
|
1000
|
+
metrics: options.metrics?.join(","),
|
|
1001
|
+
dimensions: options.dimensions?.join(","),
|
|
1002
|
+
segment_id: options.filter?.segmentId?.join(","),
|
|
1003
|
+
sort_by: options.sortBy,
|
|
1004
|
+
sort_order: options.sortOrder
|
|
1005
|
+
};
|
|
1006
|
+
const searchParams = new URLSearchParams();
|
|
1007
|
+
for (const [key, value] of Object.entries(params)) if (value !== void 0 && value !== "") searchParams.set(key, value);
|
|
1008
|
+
return searchParams.toString();
|
|
1009
|
+
}
|
|
993
1010
|
//#endregion
|
|
994
1011
|
//#region src/suppressions/batch/batch.ts
|
|
995
1012
|
var Batch = class {
|