@bernierllc/nevarmail 0.26.0 → 0.28.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/README.md CHANGED
@@ -163,6 +163,7 @@ the two, not both). The slug must exist in exactly one project the key can open:
163
163
  | `renderTemplate` | `POST /api/v1/templates/{id}/render` | `templates:read` |
164
164
  | `listCampaigns({ projectId?, page?, perPage? })` / `getCampaign(id, { projectId? })` — read-only | `GET /api/v1/campaigns`, `GET /api/v1/campaigns/{id}` | `campaigns:read` |
165
165
  | `getCampaignAnalytics(id, { projectId? })` — counts plus delivery/open/click/bounce/unsubscribe rates (0 to 1) | `GET /api/v1/campaigns/{id}/analytics` | `analytics:read` |
166
+ | `getAnalyticsSummary({ period? } \| { start, end })` — org-wide counts and rates for a trailing `7d`/`30d`/`90d` (default `30d`) or an inclusive UTC `YYYY-MM-DD` range | `GET /api/v1/analytics/summary` | `analytics:read` |
166
167
  | `listLists` / `createList` / `getList` | `/api/v1/lists` | `contacts:read` / `contacts:write` |
167
168
  | `addListContacts` | `POST /api/v1/lists/{id}/contacts` | `contacts:write` |
168
169
  | `removeListContact` | `DELETE /api/v1/lists/{id}/contacts?email=` (one list only; the contact is kept) | `contacts:write` |
@@ -217,12 +218,12 @@ Application-level details worth knowing before you hit them:
217
218
  - **Managed accounts cannot delete domains** — `deleteDomain` throws `403 MANAGED_ACCOUNT`.
218
219
  - **The inbox-db connection string is sent once and never echoed.** `connectInboxDb` stores it encrypted; `InboxDbStatus` omits it. `schemaName` is the Postgres schema NevarMail owns in your database.
219
220
 
220
- Anything still not covered — analytics summaries, webhook endpoints — goes through
221
+ Anything still not covered — webhook endpoints, for one — goes through
221
222
  `request()` (or `requestPaginated()` for list routes), which applies the same auth, envelope
222
223
  unwrapping, throwing, and retries:
223
224
 
224
225
  ```ts
225
- const summary = await nevarmail.request<AnalyticsSummary>("GET", "/api/v1/analytics/summary");
226
+ const endpoints = await nevarmail.request<unknown>("GET", "/api/v1/webhook-endpoints");
226
227
  ```
227
228
 
228
229
  Reach for `request()` rather than writing a second HTTP client beside this one. That is how
package/dist/index.d.ts CHANGED
@@ -235,6 +235,40 @@ export interface CampaignAnalytics {
235
235
  /** unsubscribes / delivered */
236
236
  unsubscribeRate: number;
237
237
  }
238
+ /**
239
+ * The window for `getAnalyticsSummary`: a trailing period ending now, or an
240
+ * inclusive UTC calendar-date range. Never both — the API answers 400
241
+ * `VALIDATION_ERROR`, and the union keeps you from building that call.
242
+ */
243
+ export type AnalyticsSummaryWindow = {
244
+ period?: "7d" | "30d" | "90d";
245
+ start?: never;
246
+ end?: never;
247
+ } | {
248
+ start: string;
249
+ end: string;
250
+ period?: never;
251
+ };
252
+ /** Org-wide counts and rates (0 to 1) for one window. */
253
+ export interface AnalyticsSummary {
254
+ /** The trailing period; null when a start/end range was asked for. */
255
+ period: "7d" | "30d" | "90d" | null;
256
+ /** The inclusive range (YYYY-MM-DD); null in period mode. */
257
+ start: string | null;
258
+ end: string | null;
259
+ totalSent: number;
260
+ totalDelivered: number;
261
+ totalOpened: number;
262
+ totalClicked: number;
263
+ totalBounced: number;
264
+ totalUnsubscribed: number;
265
+ deliveryRate: number;
266
+ openRate: number;
267
+ clickRate: number;
268
+ bounceRate: number;
269
+ /** True when part of `totalSent` is a campaign's provider-reported recipient estimate. */
270
+ sentIncludesCampaignEstimates: boolean;
271
+ }
238
272
  export interface TemplateVariable {
239
273
  name: string;
240
274
  type: string;
@@ -546,9 +580,17 @@ export interface DomainDmarc {
546
580
  status: "published" | "conflict" | "inherited" | "missing" | "unchecked";
547
581
  /** Where the record lives, or should be added (`_dmarc.<domain>`). */
548
582
  host: string;
549
- /** The record found, or the recommended `v=DMARC1; p=none;`. */
583
+ /**
584
+ * The record found, or the recommended `v=DMARC1; p=none;` (with
585
+ * `rua=mailto:<reportAddress>;` when a report address is set).
586
+ */
550
587
  value: string;
551
588
  checkedAt: string | null;
589
+ /**
590
+ * The mailbox the org chose for DMARC aggregate reports, or null. Only a
591
+ * recommended record carries it; a published record is never rewritten.
592
+ */
593
+ reportAddress: string | null;
552
594
  }
553
595
  export interface DomainDnsRecords {
554
596
  domainId: string;
@@ -876,6 +918,14 @@ export declare class NevarMail {
876
918
  getCampaignAnalytics(id: string, options?: {
877
919
  projectId?: string;
878
920
  }): Promise<CampaignAnalytics>;
921
+ /**
922
+ * GET /api/v1/analytics/summary — scope `analytics:read`. Pass `{ period }`
923
+ * (default `30d`) or `{ start, end }` as YYYY-MM-DD UTC dates, `end`
924
+ * inclusive. A send counts in the window it was sent in, with its events.
925
+ * 400 `VALIDATION_ERROR` for an invalid window. A project-pinned key reports
926
+ * on its project only.
927
+ */
928
+ getAnalyticsSummary(window?: AnalyticsSummaryWindow): Promise<AnalyticsSummary>;
879
929
  /** GET /api/v1/lists — paged. */
880
930
  listLists(options?: PageOptions): Promise<Paginated<SubscriberList>>;
881
931
  /** POST /api/v1/lists — 409 DUPLICATE_NAME on a name the org already uses. */
package/dist/index.js CHANGED
@@ -363,6 +363,18 @@ export class NevarMail {
363
363
  getCampaignAnalytics(id, options = {}) {
364
364
  return this.request("GET", `/api/v1/campaigns/${encodeURIComponent(id)}/analytics`, { query: { projectId: options.projectId } });
365
365
  }
366
+ /**
367
+ * GET /api/v1/analytics/summary — scope `analytics:read`. Pass `{ period }`
368
+ * (default `30d`) or `{ start, end }` as YYYY-MM-DD UTC dates, `end`
369
+ * inclusive. A send counts in the window it was sent in, with its events.
370
+ * 400 `VALIDATION_ERROR` for an invalid window. A project-pinned key reports
371
+ * on its project only.
372
+ */
373
+ getAnalyticsSummary(window = {}) {
374
+ return this.request("GET", "/api/v1/analytics/summary", {
375
+ query: { period: window.period, start: window.start, end: window.end },
376
+ });
377
+ }
366
378
  // ── Lists & contacts ───────────────────────────────────────────────────
367
379
  /** GET /api/v1/lists — paged. */
368
380
  async listLists(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/nevarmail",
3
- "version": "0.26.0",
3
+ "version": "0.28.0",
4
4
  "description": "Official client for the NevarMail v1 API. Typed, retries 429/5xx, throws NevarMailError on every non-2xx.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",