@bernierllc/nevarmail 0.27.0 → 0.29.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 +4 -2
- package/dist/index.d.ts +64 -0
- package/dist/index.js +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -163,6 +163,8 @@ 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` |
|
|
167
|
+
| `getUsage({ start, end })` — metered outbound email counts (billable and test-mode apart) for an inclusive UTC `YYYY-MM-DD` range of at most 366 days, current hour included; counts only, no cost | `GET /api/v1/usage` | `usage:read` |
|
|
166
168
|
| `listLists` / `createList` / `getList` | `/api/v1/lists` | `contacts:read` / `contacts:write` |
|
|
167
169
|
| `addListContacts` | `POST /api/v1/lists/{id}/contacts` | `contacts:write` |
|
|
168
170
|
| `removeListContact` | `DELETE /api/v1/lists/{id}/contacts?email=` (one list only; the contact is kept) | `contacts:write` |
|
|
@@ -217,12 +219,12 @@ Application-level details worth knowing before you hit them:
|
|
|
217
219
|
- **Managed accounts cannot delete domains** — `deleteDomain` throws `403 MANAGED_ACCOUNT`.
|
|
218
220
|
- **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
221
|
|
|
220
|
-
Anything still not covered —
|
|
222
|
+
Anything still not covered — webhook endpoints, for one — goes through
|
|
221
223
|
`request()` (or `requestPaginated()` for list routes), which applies the same auth, envelope
|
|
222
224
|
unwrapping, throwing, and retries:
|
|
223
225
|
|
|
224
226
|
```ts
|
|
225
|
-
const
|
|
227
|
+
const endpoints = await nevarmail.request<unknown>("GET", "/api/v1/webhook-endpoints");
|
|
226
228
|
```
|
|
227
229
|
|
|
228
230
|
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,51 @@ 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
|
+
}
|
|
272
|
+
/** Metered outbound email counts for an inclusive UTC date range. */
|
|
273
|
+
export interface Usage {
|
|
274
|
+
/** First day of the range (YYYY-MM-DD, UTC). */
|
|
275
|
+
start: string;
|
|
276
|
+
/** Last day of the range (YYYY-MM-DD, UTC, inclusive). */
|
|
277
|
+
end: string;
|
|
278
|
+
/** Billable outbound emails sent in the range, including the current hour. */
|
|
279
|
+
outboundEmails: number;
|
|
280
|
+
/** Test-mode outbound emails sent in the range; never billed. */
|
|
281
|
+
outboundEmailsTest: number;
|
|
282
|
+
}
|
|
238
283
|
export interface TemplateVariable {
|
|
239
284
|
name: string;
|
|
240
285
|
type: string;
|
|
@@ -884,6 +929,25 @@ export declare class NevarMail {
|
|
|
884
929
|
getCampaignAnalytics(id: string, options?: {
|
|
885
930
|
projectId?: string;
|
|
886
931
|
}): Promise<CampaignAnalytics>;
|
|
932
|
+
/**
|
|
933
|
+
* GET /api/v1/analytics/summary — scope `analytics:read`. Pass `{ period }`
|
|
934
|
+
* (default `30d`) or `{ start, end }` as YYYY-MM-DD UTC dates, `end`
|
|
935
|
+
* inclusive. A send counts in the window it was sent in, with its events.
|
|
936
|
+
* 400 `VALIDATION_ERROR` for an invalid window. A project-pinned key reports
|
|
937
|
+
* on its project only.
|
|
938
|
+
*/
|
|
939
|
+
getAnalyticsSummary(window?: AnalyticsSummaryWindow): Promise<AnalyticsSummary>;
|
|
940
|
+
/**
|
|
941
|
+
* GET /api/v1/usage — scope `usage:read`. `start` and `end` are YYYY-MM-DD
|
|
942
|
+
* UTC dates, `end` inclusive, at most 366 days apart. Counts only: billing
|
|
943
|
+
* prices per month and tier, so no cost is returned. 400
|
|
944
|
+
* `VALIDATION_ERROR` for an invalid range; 403 `PROJECT_PINNED_CREDENTIAL` for a key
|
|
945
|
+
* pinned to a project, since usage is metered per organization.
|
|
946
|
+
*/
|
|
947
|
+
getUsage(range: {
|
|
948
|
+
start: string;
|
|
949
|
+
end: string;
|
|
950
|
+
}): Promise<Usage>;
|
|
887
951
|
/** GET /api/v1/lists — paged. */
|
|
888
952
|
listLists(options?: PageOptions): Promise<Paginated<SubscriberList>>;
|
|
889
953
|
/** POST /api/v1/lists — 409 DUPLICATE_NAME on a name the org already uses. */
|
package/dist/index.js
CHANGED
|
@@ -363,6 +363,30 @@ 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
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* GET /api/v1/usage — scope `usage:read`. `start` and `end` are YYYY-MM-DD
|
|
380
|
+
* UTC dates, `end` inclusive, at most 366 days apart. Counts only: billing
|
|
381
|
+
* prices per month and tier, so no cost is returned. 400
|
|
382
|
+
* `VALIDATION_ERROR` for an invalid range; 403 `PROJECT_PINNED_CREDENTIAL` for a key
|
|
383
|
+
* pinned to a project, since usage is metered per organization.
|
|
384
|
+
*/
|
|
385
|
+
getUsage(range) {
|
|
386
|
+
return this.request("GET", "/api/v1/usage", {
|
|
387
|
+
query: { start: range.start, end: range.end },
|
|
388
|
+
});
|
|
389
|
+
}
|
|
366
390
|
// ── Lists & contacts ───────────────────────────────────────────────────
|
|
367
391
|
/** GET /api/v1/lists — paged. */
|
|
368
392
|
async listLists(options = {}) {
|
package/package.json
CHANGED