resend 6.31.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 +55 -0
- package/dist/index.d.mts +55 -0
- 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.31.0";
|
|
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
|
@@ -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
|
package/dist/index.d.mts
CHANGED
|
@@ -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
|
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.31.0";
|
|
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 {
|