@bernierllc/nevarmail 0.17.0 → 0.18.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 +7 -0
- package/dist/index.d.ts +71 -1
- package/dist/index.js +37 -1
- 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` |
|
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. */
|
|
@@ -739,6 +794,21 @@ export declare class NevarMail {
|
|
|
739
794
|
deleteSender(id: string): Promise<{
|
|
740
795
|
deleted: boolean;
|
|
741
796
|
}>;
|
|
797
|
+
/** GET /api/v1/use-cases — paged; every project the key can open, or `projectId`'s. */
|
|
798
|
+
listUseCases(options?: ListUseCasesOptions): Promise<Paginated<UseCase>>;
|
|
799
|
+
/** POST /api/v1/use-cases — 409 DUPLICATE_NAME when the name is taken in the project. */
|
|
800
|
+
createUseCase(input: CreateUseCaseInput): Promise<UseCase>;
|
|
801
|
+
/** GET /api/v1/use-cases/{id} — 404 NOT_FOUND; archived rows are returned too. */
|
|
802
|
+
getUseCase(id: string): Promise<UseCase>;
|
|
803
|
+
/** PATCH /api/v1/use-cases/{id} — partial; 409 USE_CASE_ARCHIVED until restored. */
|
|
804
|
+
updateUseCase(id: string, input: UpdateUseCaseInput): Promise<UseCase>;
|
|
805
|
+
/**
|
|
806
|
+
* DELETE /api/v1/use-cases/{id} — ARCHIVES (nothing is deleted; `restoreUseCase`
|
|
807
|
+
* undoes it). 409 IS_DEFAULT for the project default.
|
|
808
|
+
*/
|
|
809
|
+
archiveUseCase(id: string): Promise<UseCase>;
|
|
810
|
+
/** POST /api/v1/use-cases/{id}/restore — idempotent on an active use case. */
|
|
811
|
+
restoreUseCase(id: string): Promise<UseCase>;
|
|
742
812
|
/** GET /api/v1/domains — paged; list rows carry extras single reads do not. */
|
|
743
813
|
listDomains(options?: PageOptions): Promise<Paginated<Domain>>;
|
|
744
814
|
/**
|
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 = {}) {
|
package/package.json
CHANGED