@bernierllc/nevarmail 0.13.1 → 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 +12 -1
- package/dist/index.d.ts +105 -0
- package/dist/index.js +51 -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` |
|
|
@@ -162,6 +164,8 @@ Bounces, spam complaints and manual suppressions block every category regardless
|
|
|
162
164
|
| `listDomains` / `createDomain(domain, { projectId })` / `getDomain` / `deleteDomain` | `/api/v1/domains` | `domains:read` / `domains:write` |
|
|
163
165
|
| `getDomainDnsRecords` / `verifyDomain` | `/api/v1/domains/{id}/…` | `domains:read` / `domains:write` |
|
|
164
166
|
| `listSuppressions` / `addSuppressions` | `/api/v1/suppressions` | `org:read` / `org:write` |
|
|
167
|
+
| `getInboxDbStatus` | `GET /api/v1/inbox-db/status` | `org:read` |
|
|
168
|
+
| `connectInboxDb({ connectionString, provider? })` / `testInboxDbConnection` | `POST /api/v1/inbox-db/connection` / `…/connection/test` | `org:write` |
|
|
165
169
|
|
|
166
170
|
Application-level details worth knowing before you hit them:
|
|
167
171
|
|
|
@@ -170,6 +174,12 @@ Application-level details worth knowing before you hit them:
|
|
|
170
174
|
calling a list route, so it is not unwrapped away. Single-resource methods return the payload
|
|
171
175
|
directly, same as the send methods.
|
|
172
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`.
|
|
173
183
|
- **`renderTemplate(id, variables)` sends the variables map as the whole body** — not wrapped in
|
|
174
184
|
a `variables` key.
|
|
175
185
|
- **`deleteTemplate` never 404s**: an unknown id resolves `{ deleted: false }` on a 200. Every
|
|
@@ -179,8 +189,9 @@ Application-level details worth knowing before you hit them:
|
|
|
179
189
|
`use_case_id` with `scope: "account"` is a `400`. `projectId` names the project the rows land
|
|
180
190
|
in; omitted, they land in the use case's project, else in every project the key's owner can open.
|
|
181
191
|
- **Managed accounts cannot delete domains** — `deleteDomain` throws `403 MANAGED_ACCOUNT`.
|
|
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.
|
|
182
193
|
|
|
183
|
-
Anything still not covered — analytics
|
|
194
|
+
Anything still not covered — analytics summaries, webhook endpoints — goes through
|
|
184
195
|
`request()` (or `requestPaginated()` for list routes), which applies the same auth, envelope
|
|
185
196
|
unwrapping, throwing, and retries:
|
|
186
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;
|
|
@@ -439,6 +486,25 @@ export interface AddSuppressionsResult {
|
|
|
439
486
|
invalid: number;
|
|
440
487
|
provider_sync: "queued" | "skipped";
|
|
441
488
|
}
|
|
489
|
+
export type InboxDbProvider = "byo" | "supabase" | "neon";
|
|
490
|
+
/** The org's inbox database as NevarMail last recorded it. Never includes the connection string. */
|
|
491
|
+
export interface InboxDbStatus {
|
|
492
|
+
provider: InboxDbProvider;
|
|
493
|
+
/** `connected` | `error` | `schema_drift` | `schema_conflict` | `pending_verification`. */
|
|
494
|
+
status: string;
|
|
495
|
+
/** The Postgres schema NevarMail owns in the customer database (`nevarmail_<org-slug>_<hash8>`; bare `nevarmail` on connections made before per-org schemas). */
|
|
496
|
+
schemaName: string;
|
|
497
|
+
schemaVersion: string | null;
|
|
498
|
+
pgvectorAvailable: boolean;
|
|
499
|
+
lastHealthCheck: string | null;
|
|
500
|
+
createdAt: string;
|
|
501
|
+
}
|
|
502
|
+
export interface ConnectInboxDbInput {
|
|
503
|
+
/** Postgres connection string; sent once over TLS, stored encrypted, never returned. */
|
|
504
|
+
connectionString: string;
|
|
505
|
+
/** Defaults to `byo`. */
|
|
506
|
+
provider?: InboxDbProvider;
|
|
507
|
+
}
|
|
442
508
|
export interface NevarMailOptions {
|
|
443
509
|
/**
|
|
444
510
|
* A REST API key (`nvm_api_live_…` / `nvm_api_test_…`). An MCP key is
|
|
@@ -542,6 +608,36 @@ export declare class NevarMail {
|
|
|
542
608
|
* no wrapper key. Unknown template: 404 NOT_FOUND.
|
|
543
609
|
*/
|
|
544
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>;
|
|
545
641
|
/** GET /api/v1/lists — paged. */
|
|
546
642
|
listLists(options?: PageOptions): Promise<Paginated<SubscriberList>>;
|
|
547
643
|
/** POST /api/v1/lists — 409 DUPLICATE_NAME on a name the org already uses. */
|
|
@@ -626,5 +722,14 @@ export declare class NevarMail {
|
|
|
626
722
|
listSuppressions(options?: ListSuppressionsOptions): Promise<Paginated<Suppression>>;
|
|
627
723
|
/** POST /api/v1/suppressions — bulk add; see AddSuppressionsInput for the scope rules. */
|
|
628
724
|
addSuppressions(input: AddSuppressionsInput): Promise<AddSuppressionsResult>;
|
|
725
|
+
/** GET /api/v1/inbox-db/status — scope `org:read`; 404 when no connection is stored. */
|
|
726
|
+
getInboxDbStatus(): Promise<InboxDbStatus>;
|
|
727
|
+
/**
|
|
728
|
+
* POST /api/v1/inbox-db/connection — scope `org:write`; 201. Throws 422 when the database is
|
|
729
|
+
* unreachable, lacks pgvector/permissions, or already holds another org's schema.
|
|
730
|
+
*/
|
|
731
|
+
connectInboxDb(input: ConnectInboxDbInput): Promise<InboxDbStatus>;
|
|
732
|
+
/** POST /api/v1/inbox-db/connection/test — scope `org:write`; 404 when nothing is stored. */
|
|
733
|
+
testInboxDbConnection(): Promise<InboxDbStatus>;
|
|
629
734
|
}
|
|
630
735
|
export default NevarMail;
|
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 = {}) {
|
|
@@ -441,5 +476,21 @@ export class NevarMail {
|
|
|
441
476
|
addSuppressions(input) {
|
|
442
477
|
return this.request("POST", "/api/v1/suppressions", { body: input });
|
|
443
478
|
}
|
|
479
|
+
// ── Inbox database ─────────────────────────────────────────────────────
|
|
480
|
+
/** GET /api/v1/inbox-db/status — scope `org:read`; 404 when no connection is stored. */
|
|
481
|
+
getInboxDbStatus() {
|
|
482
|
+
return this.request("GET", "/api/v1/inbox-db/status");
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* POST /api/v1/inbox-db/connection — scope `org:write`; 201. Throws 422 when the database is
|
|
486
|
+
* unreachable, lacks pgvector/permissions, or already holds another org's schema.
|
|
487
|
+
*/
|
|
488
|
+
connectInboxDb(input) {
|
|
489
|
+
return this.request("POST", "/api/v1/inbox-db/connection", { body: input });
|
|
490
|
+
}
|
|
491
|
+
/** POST /api/v1/inbox-db/connection/test — scope `org:write`; 404 when nothing is stored. */
|
|
492
|
+
testInboxDbConnection() {
|
|
493
|
+
return this.request("POST", "/api/v1/inbox-db/connection/test");
|
|
494
|
+
}
|
|
444
495
|
}
|
|
445
496
|
export default NevarMail;
|
package/package.json
CHANGED