@bernierllc/nevarmail 0.14.0 → 0.15.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 +9 -1
- package/dist/index.d.ts +77 -0
- package/dist/index.js +35 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -153,6 +153,8 @@ Bounces, spam complaints and manual suppressions block every category regardless
|
|
|
153
153
|
| `setPreferences(email, { subscribedListIds, unsubscribeAll, projectId? })` — the complete set of lists to stay on | `PUT /api/v1/preferences` | `contacts:write` |
|
|
154
154
|
| `listTemplates` / `createTemplate` / `getTemplate` / `updateTemplate` / `deleteTemplate` | `/api/v1/templates` | `templates:read` / `templates:write` |
|
|
155
155
|
| `renderTemplate` | `POST /api/v1/templates/{id}/render` | `templates:read` |
|
|
156
|
+
| `listCampaigns({ projectId?, page?, perPage? })` / `getCampaign(id, { projectId? })` — read-only | `GET /api/v1/campaigns`, `GET /api/v1/campaigns/{id}` | `campaigns:read` |
|
|
157
|
+
| `getCampaignAnalytics(id, { projectId? })` — counts plus delivery/open/click/bounce/unsubscribe rates (0 to 1) | `GET /api/v1/campaigns/{id}/analytics` | `analytics:read` |
|
|
156
158
|
| `listLists` / `createList` / `getList` | `/api/v1/lists` | `contacts:read` / `contacts:write` |
|
|
157
159
|
| `addListContacts` | `POST /api/v1/lists/{id}/contacts` | `contacts:write` |
|
|
158
160
|
| `listContacts` / `upsertContacts` / `updateContact` / `deleteContact` | `/api/v1/contacts` | `contacts:read` / `contacts:write` |
|
|
@@ -172,6 +174,12 @@ Application-level details worth knowing before you hit them:
|
|
|
172
174
|
calling a list route, so it is not unwrapped away. Single-resource methods return the payload
|
|
173
175
|
directly, same as the send methods.
|
|
174
176
|
- **Updates are `PATCH`, and partial.** Send only the fields you are changing.
|
|
177
|
+
- **Campaign reads take an optional `projectId`.** Omit it only when the org has one project;
|
|
178
|
+
otherwise the server answers 400 `PROJECT_REQUIRED`. A campaign in another project is a 404
|
|
179
|
+
`NOT_FOUND`, same as a missing one. An org with no project gets 422 `NO_PROJECT`; one with no
|
|
180
|
+
marketing provider gets 404 `NO_MARKETING_PROVIDER`. `listCampaigns` filters after the provider's page, so a page
|
|
181
|
+
can hold fewer than `perPage` rows. The analytics route needs `analytics:read`, not
|
|
182
|
+
`campaigns:read`.
|
|
175
183
|
- **`renderTemplate(id, variables)` sends the variables map as the whole body** — not wrapped in
|
|
176
184
|
a `variables` key.
|
|
177
185
|
- **`deleteTemplate` never 404s**: an unknown id resolves `{ deleted: false }` on a 200. Every
|
|
@@ -183,7 +191,7 @@ Application-level details worth knowing before you hit them:
|
|
|
183
191
|
- **Managed accounts cannot delete domains** — `deleteDomain` throws `403 MANAGED_ACCOUNT`.
|
|
184
192
|
- **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.
|
|
185
193
|
|
|
186
|
-
Anything still not covered — analytics
|
|
194
|
+
Anything still not covered — analytics summaries, webhook endpoints — goes through
|
|
187
195
|
`request()` (or `requestPaginated()` for list routes), which applies the same auth, envelope
|
|
188
196
|
unwrapping, throwing, and retries:
|
|
189
197
|
|
package/dist/index.d.ts
CHANGED
|
@@ -130,6 +130,53 @@ export interface Paginated<T> {
|
|
|
130
130
|
data: T[];
|
|
131
131
|
pagination: V1Pagination;
|
|
132
132
|
}
|
|
133
|
+
/** Delivery counters for one campaign, as the provider reports them. */
|
|
134
|
+
export interface CampaignStats {
|
|
135
|
+
sent: number;
|
|
136
|
+
delivered: number;
|
|
137
|
+
opens: number;
|
|
138
|
+
clicks: number;
|
|
139
|
+
bounces: number;
|
|
140
|
+
unsubscribes: number;
|
|
141
|
+
}
|
|
142
|
+
/** A marketing campaign as listed by `listCampaigns`. Timestamps are ISO strings. */
|
|
143
|
+
export interface CampaignSummary {
|
|
144
|
+
id: string;
|
|
145
|
+
name: string;
|
|
146
|
+
subject: string;
|
|
147
|
+
status: "draft" | "scheduled" | "sending" | "sent" | "cancelled" | "unknown";
|
|
148
|
+
listId: string | null;
|
|
149
|
+
sendAt: string | null;
|
|
150
|
+
sentAt: string | null;
|
|
151
|
+
createdAt: string | null;
|
|
152
|
+
}
|
|
153
|
+
/** One campaign with its body and counters. `stats` is null until the provider reports them. */
|
|
154
|
+
export interface Campaign extends CampaignSummary {
|
|
155
|
+
htmlContent: string | null;
|
|
156
|
+
stats: CampaignStats | null;
|
|
157
|
+
}
|
|
158
|
+
/** Counts plus derived rates (0 to 1, 0 when the denominator is 0). All numbers. */
|
|
159
|
+
export interface CampaignAnalytics {
|
|
160
|
+
campaignId: string;
|
|
161
|
+
campaignName: string;
|
|
162
|
+
status: CampaignSummary["status"];
|
|
163
|
+
sent: number;
|
|
164
|
+
delivered: number;
|
|
165
|
+
opens: number;
|
|
166
|
+
clicks: number;
|
|
167
|
+
bounces: number;
|
|
168
|
+
unsubscribes: number;
|
|
169
|
+
/** delivered / sent */
|
|
170
|
+
deliveryRate: number;
|
|
171
|
+
/** opens / delivered */
|
|
172
|
+
openRate: number;
|
|
173
|
+
/** clicks / delivered */
|
|
174
|
+
clickRate: number;
|
|
175
|
+
/** bounces / sent */
|
|
176
|
+
bounceRate: number;
|
|
177
|
+
/** unsubscribes / delivered */
|
|
178
|
+
unsubscribeRate: number;
|
|
179
|
+
}
|
|
133
180
|
export interface TemplateVariable {
|
|
134
181
|
name: string;
|
|
135
182
|
type: string;
|
|
@@ -561,6 +608,36 @@ export declare class NevarMail {
|
|
|
561
608
|
* no wrapper key. Unknown template: 404 NOT_FOUND.
|
|
562
609
|
*/
|
|
563
610
|
renderTemplate(id: string, variables?: Record<string, unknown>): Promise<RenderedTemplate>;
|
|
611
|
+
/**
|
|
612
|
+
* GET /api/v1/campaigns — paged; scope `campaigns:read`. Returns the
|
|
613
|
+
* project's campaigns plus those in no project. `projectId` may be omitted
|
|
614
|
+
* only when the org has one project (else 400 `PROJECT_REQUIRED`). The
|
|
615
|
+
* server filters after the provider's page, so a page can hold fewer than
|
|
616
|
+
* `perPage` rows and `total` counts the whole provider account. 404
|
|
617
|
+
* `NO_MARKETING_PROVIDER` when the project has none connected.
|
|
618
|
+
*/
|
|
619
|
+
listCampaigns(options?: PageOptions & {
|
|
620
|
+
projectId?: string;
|
|
621
|
+
}): Promise<Paginated<CampaignSummary>>;
|
|
622
|
+
/**
|
|
623
|
+
* GET /api/v1/campaigns/{id} — scope `campaigns:read`. `projectId` follows
|
|
624
|
+
* `listCampaigns` (400 `PROJECT_REQUIRED` when omitted with several
|
|
625
|
+
* projects). 404 `NOT_FOUND` for a missing campaign or one in another project.
|
|
626
|
+
* 404 `NO_MARKETING_PROVIDER` with no marketing provider; 422 `NO_PROJECT` when
|
|
627
|
+
* the org has no project.
|
|
628
|
+
*/
|
|
629
|
+
getCampaign(id: string, options?: {
|
|
630
|
+
projectId?: string;
|
|
631
|
+
}): Promise<Campaign>;
|
|
632
|
+
/**
|
|
633
|
+
* GET /api/v1/campaigns/{id}/analytics — scope `analytics:read` (the route
|
|
634
|
+
* does not use `campaigns:read`). Counters are 0 while the provider has not
|
|
635
|
+
* reported stats. Same `projectId` rules and 400 `PROJECT_REQUIRED` /
|
|
636
|
+
* 404 `NOT_FOUND` / `NO_MARKETING_PROVIDER` / 422 `NO_PROJECT` as `getCampaign`.
|
|
637
|
+
*/
|
|
638
|
+
getCampaignAnalytics(id: string, options?: {
|
|
639
|
+
projectId?: string;
|
|
640
|
+
}): Promise<CampaignAnalytics>;
|
|
564
641
|
/** GET /api/v1/lists — paged. */
|
|
565
642
|
listLists(options?: PageOptions): Promise<Paginated<SubscriberList>>;
|
|
566
643
|
/** POST /api/v1/lists — 409 DUPLICATE_NAME on a name the org already uses. */
|
package/dist/index.js
CHANGED
|
@@ -304,6 +304,41 @@ export class NevarMail {
|
|
|
304
304
|
renderTemplate(id, variables = {}) {
|
|
305
305
|
return this.request("POST", `/api/v1/templates/${encodeURIComponent(id)}/render`, { body: variables });
|
|
306
306
|
}
|
|
307
|
+
// ── Campaigns ──────────────────────────────────────────────────────────
|
|
308
|
+
/**
|
|
309
|
+
* GET /api/v1/campaigns — paged; scope `campaigns:read`. Returns the
|
|
310
|
+
* project's campaigns plus those in no project. `projectId` may be omitted
|
|
311
|
+
* only when the org has one project (else 400 `PROJECT_REQUIRED`). The
|
|
312
|
+
* server filters after the provider's page, so a page can hold fewer than
|
|
313
|
+
* `perPage` rows and `total` counts the whole provider account. 404
|
|
314
|
+
* `NO_MARKETING_PROVIDER` when the project has none connected.
|
|
315
|
+
*/
|
|
316
|
+
listCampaigns(options = {}) {
|
|
317
|
+
return this.requestPaginated("GET", "/api/v1/campaigns", {
|
|
318
|
+
query: { ...options },
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* GET /api/v1/campaigns/{id} — scope `campaigns:read`. `projectId` follows
|
|
323
|
+
* `listCampaigns` (400 `PROJECT_REQUIRED` when omitted with several
|
|
324
|
+
* projects). 404 `NOT_FOUND` for a missing campaign or one in another project.
|
|
325
|
+
* 404 `NO_MARKETING_PROVIDER` with no marketing provider; 422 `NO_PROJECT` when
|
|
326
|
+
* the org has no project.
|
|
327
|
+
*/
|
|
328
|
+
getCampaign(id, options = {}) {
|
|
329
|
+
return this.request("GET", `/api/v1/campaigns/${encodeURIComponent(id)}`, {
|
|
330
|
+
query: { projectId: options.projectId },
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* GET /api/v1/campaigns/{id}/analytics — scope `analytics:read` (the route
|
|
335
|
+
* does not use `campaigns:read`). Counters are 0 while the provider has not
|
|
336
|
+
* reported stats. Same `projectId` rules and 400 `PROJECT_REQUIRED` /
|
|
337
|
+
* 404 `NOT_FOUND` / `NO_MARKETING_PROVIDER` / 422 `NO_PROJECT` as `getCampaign`.
|
|
338
|
+
*/
|
|
339
|
+
getCampaignAnalytics(id, options = {}) {
|
|
340
|
+
return this.request("GET", `/api/v1/campaigns/${encodeURIComponent(id)}/analytics`, { query: { projectId: options.projectId } });
|
|
341
|
+
}
|
|
307
342
|
// ── Lists & contacts ───────────────────────────────────────────────────
|
|
308
343
|
/** GET /api/v1/lists — paged. */
|
|
309
344
|
async listLists(options = {}) {
|
package/package.json
CHANGED