@bernierllc/nevarmail 0.10.0 → 0.11.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 +32 -9
- package/dist/index.js +25 -7
- 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 {
|
|
@@ -448,13 +466,18 @@ export declare class NevarMail {
|
|
|
448
466
|
* opt-out of the project counts.
|
|
449
467
|
*/
|
|
450
468
|
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
469
|
/**
|
|
454
|
-
*
|
|
455
|
-
*
|
|
470
|
+
* GET /api/v1/preferences — one recipient's lists in one project. `projectId`
|
|
471
|
+
* is required when the org has more than one project (400 PROJECT_REQUIRED).
|
|
472
|
+
*/
|
|
473
|
+
getPreferences(email: string, projectId?: string): Promise<RecipientPreferences>;
|
|
474
|
+
/**
|
|
475
|
+
* PUT /api/v1/preferences — a COMPLETE set, not a delta: any shown list
|
|
476
|
+
* missing from `subscribedListIds` is left. Turning a list back on releases
|
|
477
|
+
* the opt-out but does not re-add the address to the list. A `blocked`
|
|
478
|
+
* list cannot be turned on: 409 LIST_BLOCKED.
|
|
456
479
|
*/
|
|
457
|
-
setPreferences(email: string,
|
|
480
|
+
setPreferences(email: string, input: SetPreferencesInput): Promise<RecipientPreferences>;
|
|
458
481
|
/** GET /api/v1/templates — paged; the route ignores search/category filters today. */
|
|
459
482
|
listTemplates(options?: PageOptions): Promise<Paginated<Template>>;
|
|
460
483
|
/** 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 ──────────────────────────────────────────────────────────
|
package/package.json
CHANGED