@bernierllc/nevarmail 0.10.0 → 0.12.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 +2 -2
- package/dist/index.d.ts +60 -9
- package/dist/index.js +29 -9
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -149,8 +149,8 @@ Bounces, spam complaints and manual suppressions block every category regardless
|
|
|
149
149
|
| `listScheduledEmails` | `GET /api/v1/email/schedule` | `email:send` |
|
|
150
150
|
| `cancelScheduledEmail` | `DELETE /api/v1/email/schedule/{id}` | `email:send` |
|
|
151
151
|
| `checkSuppression` | `GET /api/v1/suppressions/check` | `org:read` |
|
|
152
|
-
| `getPreferences` | `GET /api/v1/preferences` | `contacts:read` |
|
|
153
|
-
| `setPreferences` | `PUT /api/v1/preferences` | `contacts:write` |
|
|
152
|
+
| `getPreferences(email, projectId?)` — one address's lists in one project; `projectId` required when the org has more than one | `GET /api/v1/preferences` | `contacts:read` |
|
|
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
156
|
| `listLists` / `createList` / `getList` | `/api/v1/lists` | `contacts:read` / `contacts:write` |
|
package/dist/index.d.ts
CHANGED
|
@@ -89,18 +89,36 @@ export interface SuppressionCheck {
|
|
|
89
89
|
/** Absent when nothing is suppressed. */
|
|
90
90
|
reason?: SuppressionReason;
|
|
91
91
|
}
|
|
92
|
-
export interface
|
|
93
|
-
|
|
92
|
+
export interface ListPreference {
|
|
93
|
+
listId: string;
|
|
94
94
|
name: string;
|
|
95
95
|
description: string | null;
|
|
96
|
-
category: string | null;
|
|
97
96
|
subscribed: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* The sender suppressed this list for the address (a list-scoped manual
|
|
99
|
+
* suppression): off, and not the recipient's to turn on. Including it in
|
|
100
|
+
* `subscribedListIds` is a 409 LIST_BLOCKED.
|
|
101
|
+
*/
|
|
102
|
+
blocked: boolean;
|
|
98
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* One address's lists in one project: only the lists it is on or has left —
|
|
106
|
+
* an address never mailed gets `lists: []`, not the project's whole catalogue.
|
|
107
|
+
*/
|
|
99
108
|
export interface RecipientPreferences {
|
|
100
109
|
email: string;
|
|
110
|
+
senderName: string;
|
|
101
111
|
unsubscribedAll: boolean;
|
|
102
112
|
deliverable: boolean;
|
|
103
|
-
|
|
113
|
+
lists: ListPreference[];
|
|
114
|
+
}
|
|
115
|
+
export interface SetPreferencesInput {
|
|
116
|
+
/** COMPLETE set of the shown lists to stay on; every other shown list is left. */
|
|
117
|
+
subscribedListIds: string[];
|
|
118
|
+
/** Stop all email from the project. Cannot be combined with list ids. */
|
|
119
|
+
unsubscribeAll: boolean;
|
|
120
|
+
/** Required when the org has more than one project. */
|
|
121
|
+
projectId?: string;
|
|
104
122
|
}
|
|
105
123
|
/** Accepted by every list method. The server clamps `perPage` to 1–100 (default 25). */
|
|
106
124
|
export interface PageOptions {
|
|
@@ -350,12 +368,40 @@ export interface Suppression {
|
|
|
350
368
|
email: string;
|
|
351
369
|
reason: SuppressionReason;
|
|
352
370
|
source: SuppressionSource;
|
|
371
|
+
/**
|
|
372
|
+
* @deprecated since 0.12.0; removed in 1.0.0; use sourceOrgProviderId.
|
|
373
|
+
* The API never sent it; the client now fills it from `sourceOrgProviderId`.
|
|
374
|
+
*/
|
|
353
375
|
providerId: string | null;
|
|
376
|
+
/** The provider connection that reported the row, when a provider did. */
|
|
377
|
+
sourceOrgProviderId?: string | null;
|
|
354
378
|
useCaseId: string | null;
|
|
379
|
+
/** The project the row belongs to; for a provider-account row, the project that reported it. */
|
|
380
|
+
projectId?: string;
|
|
381
|
+
/** Name of `projectId`'s project. */
|
|
382
|
+
projectName?: string | null;
|
|
383
|
+
/** The one list an opt-out blocks; null = the whole project. */
|
|
384
|
+
listId?: string | null;
|
|
385
|
+
/** Name of `listId`'s list. */
|
|
386
|
+
listName?: string | null;
|
|
387
|
+
/**
|
|
388
|
+
* Set on a provider-reported bounce or complaint: the row blocks every
|
|
389
|
+
* project sending through this provider account, not only `projectId`.
|
|
390
|
+
*/
|
|
391
|
+
scopeProviderAccountId?: string | null;
|
|
392
|
+
/** The account's connection name, else its provider type; null when it could not be read. */
|
|
393
|
+
scopeProviderAccountName?: string | null;
|
|
394
|
+
/** Enhanced status code of a hard bounce (e.g. "5.1.1"), when the provider reported one. */
|
|
395
|
+
bounceCode?: string | null;
|
|
396
|
+
/** When a bounce's strike expires (ISO 8601); null = permanent, or not a bounce. */
|
|
397
|
+
expiresAt?: string | null;
|
|
398
|
+
/** Which bounce strike this row is (1, 2, 3...); 1 for every other reason. */
|
|
399
|
+
strikeCount?: number;
|
|
355
400
|
providerSyncStatus: string | null;
|
|
356
401
|
isActive: boolean;
|
|
357
402
|
createdAt: string;
|
|
358
403
|
deactivatedAt: string | null;
|
|
404
|
+
/** Null while active, or when the recipient removed it themselves. */
|
|
359
405
|
deactivatedBy: string | null;
|
|
360
406
|
deactivatedByName: string | null;
|
|
361
407
|
deactivationReason: string | null;
|
|
@@ -448,13 +494,18 @@ export declare class NevarMail {
|
|
|
448
494
|
* opt-out of the project counts.
|
|
449
495
|
*/
|
|
450
496
|
checkSuppression(email: string, useCaseId?: string, projectId?: string): Promise<SuppressionCheck>;
|
|
451
|
-
/** GET /api/v1/preferences — one recipient's per-category subscriptions. */
|
|
452
|
-
getPreferences(email: string): Promise<RecipientPreferences>;
|
|
453
497
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
498
|
+
* GET /api/v1/preferences — one recipient's lists in one project. `projectId`
|
|
499
|
+
* is required when the org has more than one project (400 PROJECT_REQUIRED).
|
|
500
|
+
*/
|
|
501
|
+
getPreferences(email: string, projectId?: string): Promise<RecipientPreferences>;
|
|
502
|
+
/**
|
|
503
|
+
* PUT /api/v1/preferences — a COMPLETE set, not a delta: any shown list
|
|
504
|
+
* missing from `subscribedListIds` is left. Turning a list back on releases
|
|
505
|
+
* the opt-out but does not re-add the address to the list. A `blocked`
|
|
506
|
+
* list cannot be turned on: 409 LIST_BLOCKED.
|
|
456
507
|
*/
|
|
457
|
-
setPreferences(email: string,
|
|
508
|
+
setPreferences(email: string, input: SetPreferencesInput): Promise<RecipientPreferences>;
|
|
458
509
|
/** GET /api/v1/templates — paged; the route ignores search/category filters today. */
|
|
459
510
|
listTemplates(options?: PageOptions): Promise<Paginated<Template>>;
|
|
460
511
|
/** POST /api/v1/templates */
|
package/dist/index.js
CHANGED
|
@@ -229,17 +229,35 @@ export class NevarMail {
|
|
|
229
229
|
query: { email, use_case_id: useCaseId, project_id: projectId },
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
/**
|
|
233
|
+
* GET /api/v1/preferences — one recipient's lists in one project. `projectId`
|
|
234
|
+
* is required when the org has more than one project (400 PROJECT_REQUIRED).
|
|
235
|
+
*/
|
|
236
|
+
getPreferences(email, projectId) {
|
|
237
|
+
return this.request("GET", "/api/v1/preferences", {
|
|
238
|
+
query: { email, project_id: projectId },
|
|
239
|
+
});
|
|
235
240
|
}
|
|
236
241
|
/**
|
|
237
|
-
* PUT /api/v1/preferences — a COMPLETE set, not a delta: any
|
|
238
|
-
*
|
|
242
|
+
* PUT /api/v1/preferences — a COMPLETE set, not a delta: any shown list
|
|
243
|
+
* missing from `subscribedListIds` is left. Turning a list back on releases
|
|
244
|
+
* the opt-out but does not re-add the address to the list. A `blocked`
|
|
245
|
+
* list cannot be turned on: 409 LIST_BLOCKED.
|
|
239
246
|
*/
|
|
240
|
-
setPreferences(email,
|
|
247
|
+
setPreferences(email, input) {
|
|
248
|
+
// The pre-list form took a use-case id array. The server contract it
|
|
249
|
+
// targeted is gone, so no alias can keep it working; fail loudly instead
|
|
250
|
+
// of sending `{ email }` alone.
|
|
251
|
+
if (Array.isArray(input)) {
|
|
252
|
+
return Promise.reject(new NevarMailError("setPreferences(email, useCaseIds[]) was removed: pass { subscribedListIds, unsubscribeAll, projectId? }.", { status: 0, code: "PREFERENCES_INPUT_CHANGED" }));
|
|
253
|
+
}
|
|
241
254
|
return this.request("PUT", "/api/v1/preferences", {
|
|
242
|
-
body: {
|
|
255
|
+
body: {
|
|
256
|
+
email,
|
|
257
|
+
project_id: input.projectId,
|
|
258
|
+
subscribed_list_ids: input.subscribedListIds,
|
|
259
|
+
unsubscribe_all: input.unsubscribeAll,
|
|
260
|
+
},
|
|
243
261
|
});
|
|
244
262
|
}
|
|
245
263
|
// ── Templates ──────────────────────────────────────────────────────────
|
|
@@ -400,11 +418,13 @@ export class NevarMail {
|
|
|
400
418
|
}
|
|
401
419
|
// ── Suppressions ───────────────────────────────────────────────────────
|
|
402
420
|
/** GET /api/v1/suppressions — paged, newest first. */
|
|
403
|
-
listSuppressions(options = {}) {
|
|
421
|
+
async listSuppressions(options = {}) {
|
|
404
422
|
const { isActive, ...rest } = options;
|
|
405
|
-
|
|
423
|
+
const page = await this.requestPaginated("GET", "/api/v1/suppressions", {
|
|
406
424
|
query: { ...rest, is_active: isActive },
|
|
407
425
|
});
|
|
426
|
+
// Deprecated alias resolves until 1.0.0 (see Suppression.providerId).
|
|
427
|
+
return { ...page, data: page.data.map((s) => ({ ...s, providerId: s.sourceOrgProviderId ?? null })) };
|
|
408
428
|
}
|
|
409
429
|
/** POST /api/v1/suppressions — bulk add; see AddSuppressionsInput for the scope rules. */
|
|
410
430
|
addSuppressions(input) {
|
package/package.json
CHANGED