@bernierllc/nevarmail 0.17.0 → 0.19.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 +93 -4
- package/dist/index.js +44 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,6 +139,11 @@ suppression blocks only its own.
|
|
|
139
139
|
Bounces, spam complaints and manual suppressions block every category regardless. Only a
|
|
140
140
|
`use_case_id` you passed yourself can narrow a block; a default the server resolves cannot.
|
|
141
141
|
|
|
142
|
+
`sendEmail` also takes the use case by slug — `useCase: "receipts"` — instead of its id (one of
|
|
143
|
+
the two, not both). The slug must exist in exactly one project the key can open: unknown is a
|
|
144
|
+
404, the same slug in several projects is `400 USE_CASE_AMBIGUOUS` (pass `use_case_id` then).
|
|
145
|
+
`listUseCases` shows the slugs.
|
|
146
|
+
|
|
142
147
|
## Methods
|
|
143
148
|
|
|
144
149
|
| Method | Route | Scope |
|
|
@@ -160,6 +165,8 @@ Bounces, spam complaints and manual suppressions block every category regardless
|
|
|
160
165
|
| `listContacts` / `upsertContacts` / `updateContact` / `deleteContact` | `/api/v1/contacts` | `contacts:read` / `contacts:write` |
|
|
161
166
|
| `listSenders` / `createSender(input)` — `input.projectId?` targets a project when the org has more than one | `/api/v1/senders` | `senders:read` / `senders:write` |
|
|
162
167
|
| `getSender` / `updateSender` / `deleteSender` | `/api/v1/senders/{id}` | `senders:read` / `senders:write` |
|
|
168
|
+
| `listUseCases({ projectId?, includeArchived? })` / `createUseCase(input)` — `input.projectId?` as for `createSender` | `/api/v1/use-cases` | `use-cases:read` / `use-cases:write` |
|
|
169
|
+
| `getUseCase` / `updateUseCase` / `archiveUseCase` / `restoreUseCase` — delete archives; restore undoes it | `/api/v1/use-cases/{id}` | `use-cases:read` / `use-cases:write` |
|
|
163
170
|
| `importSenders({ projectId? })` — adopts the project's provider-account identities; re-run to pick up provider verification | `POST /api/v1/senders/import` | `senders:write` |
|
|
164
171
|
| `listDomains` / `createDomain(domain, { projectId })` / `getDomain` / `deleteDomain` | `/api/v1/domains` | `domains:read` / `domains:write` |
|
|
165
172
|
| `getDomainDnsRecords` / `verifyDomain` | `/api/v1/domains/{id}/…` | `domains:read` / `domains:write` |
|
|
@@ -167,7 +174,8 @@ Bounces, spam complaints and manual suppressions block every category regardless
|
|
|
167
174
|
| `getProjectAddress(projectId)` / `setProjectAddress(projectId, { physicalAddress, addressComponents? })` | `GET` / `PUT /api/v1/projects/{id}/address` | `org:read` / `org:write` |
|
|
168
175
|
| `getProjectMarketing(projectId)` / `setProjectMarketing(projectId, { marketingEnabled })` | `GET` / `PUT /api/v1/projects/{id}/marketing` | `org:read` / `org:write` |
|
|
169
176
|
| `getInboxDbStatus` | `GET /api/v1/inbox-db/status` | `org:read` |
|
|
170
|
-
| `connectInboxDb({ connectionString, provider? })` / `testInboxDbConnection` | `POST /api/v1/inbox-db/connection` / `…/connection/test` | `org:write` |
|
|
177
|
+
| `connectInboxDb({ connectionString, provider? })` (202, starts a background connect) / `testInboxDbConnection` | `POST /api/v1/inbox-db/connection` / `…/connection/test` | `org:write` |
|
|
178
|
+
| `getInboxDbConnectAttempt` (poll until `status` is not `running`) | `GET /api/v1/inbox-db/connection` | `org:read` |
|
|
171
179
|
|
|
172
180
|
Application-level details worth knowing before you hit them:
|
|
173
181
|
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,12 @@ export interface SendEmailInput {
|
|
|
33
33
|
* omit it and every active suppression row applies. See the README.
|
|
34
34
|
*/
|
|
35
35
|
use_case_id?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The use case by SLUG instead of id (sent as `use_case`; pass one of the
|
|
38
|
+
* two, not both). The slug must exist in exactly one project the key can
|
|
39
|
+
* open: 404 when none, 400 `USE_CASE_AMBIGUOUS` when several.
|
|
40
|
+
*/
|
|
41
|
+
useCase?: string;
|
|
36
42
|
}
|
|
37
43
|
export interface SendToListResult {
|
|
38
44
|
id: string;
|
|
@@ -62,7 +68,7 @@ export interface SendToListInput {
|
|
|
62
68
|
tags?: string[];
|
|
63
69
|
use_case_id?: string;
|
|
64
70
|
}
|
|
65
|
-
export interface ScheduleEmailInput extends Omit<SendEmailInput, "templateId" | "variables"> {
|
|
71
|
+
export interface ScheduleEmailInput extends Omit<SendEmailInput, "templateId" | "variables" | "useCase"> {
|
|
66
72
|
/**
|
|
67
73
|
* An instant, not a wall-clock guess: the offset is mandatory (`Z` or
|
|
68
74
|
* `±HH:MM`). The API rejects a bare local time rather than guessing a zone.
|
|
@@ -356,6 +362,55 @@ export type UpdateSenderInput = Partial<Omit<CreateSenderInput, "projectId" | "f
|
|
|
356
362
|
provider?: string | null;
|
|
357
363
|
isActive?: boolean;
|
|
358
364
|
};
|
|
365
|
+
/** A use case: the message category a project files mail under (`use_case_id` / `useCase` on a send). */
|
|
366
|
+
export interface UseCase {
|
|
367
|
+
id: string;
|
|
368
|
+
orgId: string;
|
|
369
|
+
projectId: string;
|
|
370
|
+
name: string;
|
|
371
|
+
/** Unique within the project; what `sendEmail({ useCase })` names. */
|
|
372
|
+
slug: string | null;
|
|
373
|
+
description: string | null;
|
|
374
|
+
/** Whether recipients may opt out of this use case. */
|
|
375
|
+
suppressable: boolean;
|
|
376
|
+
category: string | null;
|
|
377
|
+
/** The project's default: sends that name no use case file under it. Never settable through the API. */
|
|
378
|
+
isDefault: boolean;
|
|
379
|
+
isSystem: boolean;
|
|
380
|
+
domainId: string | null;
|
|
381
|
+
senderId: string | null;
|
|
382
|
+
archivedAt: string | null;
|
|
383
|
+
createdAt: string;
|
|
384
|
+
updatedAt: string;
|
|
385
|
+
/** Linked lists; present on `getUseCase` and `updateUseCase`. */
|
|
386
|
+
lists?: {
|
|
387
|
+
id: string;
|
|
388
|
+
name: string;
|
|
389
|
+
}[];
|
|
390
|
+
}
|
|
391
|
+
export interface ListUseCasesOptions extends PageOptions {
|
|
392
|
+
/** Only this project's use cases. */
|
|
393
|
+
projectId?: string;
|
|
394
|
+
/** Include archived use cases. */
|
|
395
|
+
includeArchived?: boolean;
|
|
396
|
+
}
|
|
397
|
+
export interface CreateUseCaseInput {
|
|
398
|
+
name: string;
|
|
399
|
+
/** Same rule as `createSender`: omit it only when the org has one project (400 `PROJECT_REQUIRED` otherwise). */
|
|
400
|
+
projectId?: string;
|
|
401
|
+
description?: string;
|
|
402
|
+
/** Defaults to true. */
|
|
403
|
+
suppressable?: boolean;
|
|
404
|
+
category?: string;
|
|
405
|
+
}
|
|
406
|
+
export interface UpdateUseCaseInput {
|
|
407
|
+
name?: string;
|
|
408
|
+
description?: string;
|
|
409
|
+
suppressable?: boolean;
|
|
410
|
+
category?: string;
|
|
411
|
+
/** The complete set of lists to link; lists not named are unlinked. */
|
|
412
|
+
listIds?: string[];
|
|
413
|
+
}
|
|
359
414
|
/** Result of `importSenders`: counts per outcome, then the project's senders. */
|
|
360
415
|
export interface ImportSendersResult {
|
|
361
416
|
/** Provider identities with no NevarMail sender yet — created. */
|
|
@@ -520,6 +575,22 @@ export interface ConnectInboxDbInput {
|
|
|
520
575
|
/** Defaults to `byo`. */
|
|
521
576
|
provider?: InboxDbProvider;
|
|
522
577
|
}
|
|
578
|
+
/** Progress of the latest inbox database connect. Never includes the connection string. */
|
|
579
|
+
export interface InboxDbConnectAttempt {
|
|
580
|
+
provider: InboxDbProvider;
|
|
581
|
+
status: "running" | "failed" | "succeeded";
|
|
582
|
+
/** The step running now, or the one that failed. */
|
|
583
|
+
step: "connecting" | "pgvector" | "privileges" | "schema" | "done";
|
|
584
|
+
/** Why it failed, in words a person can act on. */
|
|
585
|
+
error: string | null;
|
|
586
|
+
/** Statement a database admin can run to fix a privilege failure. */
|
|
587
|
+
fixSql: string | null;
|
|
588
|
+
/** Whether someone asked to be emailed when it finishes. */
|
|
589
|
+
notify: boolean;
|
|
590
|
+
canRetry: boolean;
|
|
591
|
+
startedAt: string;
|
|
592
|
+
finishedAt: string | null;
|
|
593
|
+
}
|
|
523
594
|
/** One structured part of a postal address (Places-style `addressComponents`). */
|
|
524
595
|
export interface AddressComponent {
|
|
525
596
|
longText: string;
|
|
@@ -739,6 +810,21 @@ export declare class NevarMail {
|
|
|
739
810
|
deleteSender(id: string): Promise<{
|
|
740
811
|
deleted: boolean;
|
|
741
812
|
}>;
|
|
813
|
+
/** GET /api/v1/use-cases — paged; every project the key can open, or `projectId`'s. */
|
|
814
|
+
listUseCases(options?: ListUseCasesOptions): Promise<Paginated<UseCase>>;
|
|
815
|
+
/** POST /api/v1/use-cases — 409 DUPLICATE_NAME when the name is taken in the project. */
|
|
816
|
+
createUseCase(input: CreateUseCaseInput): Promise<UseCase>;
|
|
817
|
+
/** GET /api/v1/use-cases/{id} — 404 NOT_FOUND; archived rows are returned too. */
|
|
818
|
+
getUseCase(id: string): Promise<UseCase>;
|
|
819
|
+
/** PATCH /api/v1/use-cases/{id} — partial; 409 USE_CASE_ARCHIVED until restored. */
|
|
820
|
+
updateUseCase(id: string, input: UpdateUseCaseInput): Promise<UseCase>;
|
|
821
|
+
/**
|
|
822
|
+
* DELETE /api/v1/use-cases/{id} — ARCHIVES (nothing is deleted; `restoreUseCase`
|
|
823
|
+
* undoes it). 409 IS_DEFAULT for the project default.
|
|
824
|
+
*/
|
|
825
|
+
archiveUseCase(id: string): Promise<UseCase>;
|
|
826
|
+
/** POST /api/v1/use-cases/{id}/restore — idempotent on an active use case. */
|
|
827
|
+
restoreUseCase(id: string): Promise<UseCase>;
|
|
742
828
|
/** GET /api/v1/domains — paged; list rows carry extras single reads do not. */
|
|
743
829
|
listDomains(options?: PageOptions): Promise<Paginated<Domain>>;
|
|
744
830
|
/**
|
|
@@ -789,10 +875,13 @@ export declare class NevarMail {
|
|
|
789
875
|
/** GET /api/v1/inbox-db/status — scope `org:read`; 404 when no connection is stored. */
|
|
790
876
|
getInboxDbStatus(): Promise<InboxDbStatus>;
|
|
791
877
|
/**
|
|
792
|
-
* POST /api/v1/inbox-db/connection — scope `org:write`;
|
|
793
|
-
*
|
|
878
|
+
* POST /api/v1/inbox-db/connection — scope `org:write`; 202. Starts connecting in the
|
|
879
|
+
* background; poll {@link getInboxDbConnectAttempt} until `status` is not `running`.
|
|
880
|
+
* Throws 409 while another connect runs and 400 when Agent Inboxes isn't active.
|
|
794
881
|
*/
|
|
795
|
-
connectInboxDb(input: ConnectInboxDbInput): Promise<
|
|
882
|
+
connectInboxDb(input: ConnectInboxDbInput): Promise<InboxDbConnectAttempt>;
|
|
883
|
+
/** GET /api/v1/inbox-db/connection — scope `org:read`; the latest connect attempt, 404 when none. */
|
|
884
|
+
getInboxDbConnectAttempt(): Promise<InboxDbConnectAttempt>;
|
|
796
885
|
/** POST /api/v1/inbox-db/connection/test — scope `org:write`; 404 when nothing is stored. */
|
|
797
886
|
testInboxDbConnection(): Promise<InboxDbStatus>;
|
|
798
887
|
}
|
package/dist/index.js
CHANGED
|
@@ -203,7 +203,10 @@ export class NevarMail {
|
|
|
203
203
|
* a 409 LIST_UNSUB_PAGE_MISSING; the message names where to save one.
|
|
204
204
|
*/
|
|
205
205
|
sendEmail(input) {
|
|
206
|
-
|
|
206
|
+
const { useCase, ...body } = input;
|
|
207
|
+
return this.request("POST", "/api/v1/email/send", {
|
|
208
|
+
body: useCase === undefined ? body : { ...body, use_case: useCase },
|
|
209
|
+
});
|
|
207
210
|
}
|
|
208
211
|
/**
|
|
209
212
|
* POST /api/v1/email/send-to-list — one message to every contact on a list.
|
|
@@ -429,6 +432,39 @@ export class NevarMail {
|
|
|
429
432
|
deleteSender(id) {
|
|
430
433
|
return this.request("DELETE", `/api/v1/senders/${encodeURIComponent(id)}`);
|
|
431
434
|
}
|
|
435
|
+
// ── Use cases ──────────────────────────────────────────────────────────
|
|
436
|
+
/** GET /api/v1/use-cases — paged; every project the key can open, or `projectId`'s. */
|
|
437
|
+
listUseCases(options = {}) {
|
|
438
|
+
const { includeArchived, ...rest } = options;
|
|
439
|
+
return this.requestPaginated("GET", "/api/v1/use-cases", {
|
|
440
|
+
query: { ...rest, includeArchived: includeArchived ? "1" : undefined },
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
/** POST /api/v1/use-cases — 409 DUPLICATE_NAME when the name is taken in the project. */
|
|
444
|
+
createUseCase(input) {
|
|
445
|
+
return this.request("POST", "/api/v1/use-cases", { body: input });
|
|
446
|
+
}
|
|
447
|
+
/** GET /api/v1/use-cases/{id} — 404 NOT_FOUND; archived rows are returned too. */
|
|
448
|
+
getUseCase(id) {
|
|
449
|
+
return this.request("GET", `/api/v1/use-cases/${encodeURIComponent(id)}`);
|
|
450
|
+
}
|
|
451
|
+
/** PATCH /api/v1/use-cases/{id} — partial; 409 USE_CASE_ARCHIVED until restored. */
|
|
452
|
+
updateUseCase(id, input) {
|
|
453
|
+
return this.request("PATCH", `/api/v1/use-cases/${encodeURIComponent(id)}`, {
|
|
454
|
+
body: input,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* DELETE /api/v1/use-cases/{id} — ARCHIVES (nothing is deleted; `restoreUseCase`
|
|
459
|
+
* undoes it). 409 IS_DEFAULT for the project default.
|
|
460
|
+
*/
|
|
461
|
+
archiveUseCase(id) {
|
|
462
|
+
return this.request("DELETE", `/api/v1/use-cases/${encodeURIComponent(id)}`);
|
|
463
|
+
}
|
|
464
|
+
/** POST /api/v1/use-cases/{id}/restore — idempotent on an active use case. */
|
|
465
|
+
restoreUseCase(id) {
|
|
466
|
+
return this.request("POST", `/api/v1/use-cases/${encodeURIComponent(id)}/restore`);
|
|
467
|
+
}
|
|
432
468
|
// ── Domains ────────────────────────────────────────────────────────────
|
|
433
469
|
/** GET /api/v1/domains — paged; list rows carry extras single reads do not. */
|
|
434
470
|
listDomains(options = {}) {
|
|
@@ -512,12 +548,17 @@ export class NevarMail {
|
|
|
512
548
|
return this.request("GET", "/api/v1/inbox-db/status");
|
|
513
549
|
}
|
|
514
550
|
/**
|
|
515
|
-
* POST /api/v1/inbox-db/connection — scope `org:write`;
|
|
516
|
-
*
|
|
551
|
+
* POST /api/v1/inbox-db/connection — scope `org:write`; 202. Starts connecting in the
|
|
552
|
+
* background; poll {@link getInboxDbConnectAttempt} until `status` is not `running`.
|
|
553
|
+
* Throws 409 while another connect runs and 400 when Agent Inboxes isn't active.
|
|
517
554
|
*/
|
|
518
555
|
connectInboxDb(input) {
|
|
519
556
|
return this.request("POST", "/api/v1/inbox-db/connection", { body: input });
|
|
520
557
|
}
|
|
558
|
+
/** GET /api/v1/inbox-db/connection — scope `org:read`; the latest connect attempt, 404 when none. */
|
|
559
|
+
getInboxDbConnectAttempt() {
|
|
560
|
+
return this.request("GET", "/api/v1/inbox-db/connection");
|
|
561
|
+
}
|
|
521
562
|
/** POST /api/v1/inbox-db/connection/test — scope `org:write`; 404 when nothing is stored. */
|
|
522
563
|
testInboxDbConnection() {
|
|
523
564
|
return this.request("POST", "/api/v1/inbox-db/connection/test");
|
package/package.json
CHANGED