@bernierllc/nevarmail 0.8.0 → 0.10.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 +11 -4
- package/dist/index.d.ts +16 -3
- package/dist/index.js +16 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -123,14 +123,21 @@ request into three. Sends are not idempotent; a retry after a `5xx` may deliver
|
|
|
123
123
|
|
|
124
124
|
## Use cases and suppression scope
|
|
125
125
|
|
|
126
|
+
Suppressions are per project. `checkSuppression(email, useCaseId?, projectId?)` answers for
|
|
127
|
+
one project: `projectId`, else the project of `useCaseId`, else the organization's only
|
|
128
|
+
project. An organization with several projects gets `400 PROJECT_REQUIRED` when neither is
|
|
129
|
+
passed. A bounce or spam complaint on a provider account blocks every project; any other
|
|
130
|
+
suppression blocks only its own.
|
|
131
|
+
|
|
126
132
|
`use_case_id` names the message category a send belongs to. It is the difference between
|
|
127
133
|
"this person unsubscribed from your newsletter" and "this person can no longer be emailed":
|
|
128
134
|
|
|
129
|
-
- **Name it**, and an opt-out
|
|
130
|
-
|
|
135
|
+
- **Name it**, and an opt-out from a *different* category's list does not block the send,
|
|
136
|
+
and a category marked non-suppressable is exempt from opt-outs.
|
|
137
|
+
- **Omit it**, and every active suppression of the project applies — the strict reading.
|
|
131
138
|
|
|
132
|
-
Bounces
|
|
133
|
-
yourself can narrow a block; a default the server resolves cannot.
|
|
139
|
+
Bounces, spam complaints and manual suppressions block every category regardless. Only a
|
|
140
|
+
`use_case_id` you passed yourself can narrow a block; a default the server resolves cannot.
|
|
134
141
|
|
|
135
142
|
## Methods
|
|
136
143
|
|
package/dist/index.d.ts
CHANGED
|
@@ -153,6 +153,12 @@ export interface SubscriberList {
|
|
|
153
153
|
orgId: string;
|
|
154
154
|
name: string;
|
|
155
155
|
description: string | null;
|
|
156
|
+
/**
|
|
157
|
+
* @deprecated since 0.10.0; removed in 1.0.0; no replacement. A list
|
|
158
|
+
* opt-out applies to that list; a project-wide opt-out is its own
|
|
159
|
+
* suppression. The API no longer returns this field; the client fills it
|
|
160
|
+
* with `"list"` when the server leaves it out.
|
|
161
|
+
*/
|
|
156
162
|
unsubScope: string;
|
|
157
163
|
unsubHandler: string;
|
|
158
164
|
customUnsubHtml: string | null;
|
|
@@ -181,6 +187,10 @@ export interface SubscriberList {
|
|
|
181
187
|
export interface CreateListInput {
|
|
182
188
|
name: string;
|
|
183
189
|
description?: string;
|
|
190
|
+
/**
|
|
191
|
+
* @deprecated since 0.10.0; removed in 1.0.0; no replacement. The API
|
|
192
|
+
* ignores it: a list opt-out always applies to that list.
|
|
193
|
+
*/
|
|
184
194
|
unsubScope?: "list" | "global";
|
|
185
195
|
unsubHandler?: "provider" | "hosted" | "custom_html";
|
|
186
196
|
storageTier?: "provider" | "byo_database" | "local";
|
|
@@ -431,10 +441,13 @@ export declare class NevarMail {
|
|
|
431
441
|
cancelled: boolean;
|
|
432
442
|
}>;
|
|
433
443
|
/**
|
|
434
|
-
* GET /api/v1/suppressions/check — would a send
|
|
435
|
-
*
|
|
444
|
+
* GET /api/v1/suppressions/check — would a send from this project to this
|
|
445
|
+
* address be blocked? Suppressions are per project. `projectId` defaults to
|
|
446
|
+
* the use case's project, else the org's only one (400 PROJECT_REQUIRED in a
|
|
447
|
+
* multi-project org). Omitting `useCaseId` is the strict answer: every list
|
|
448
|
+
* opt-out of the project counts.
|
|
436
449
|
*/
|
|
437
|
-
checkSuppression(email: string, useCaseId?: string): Promise<SuppressionCheck>;
|
|
450
|
+
checkSuppression(email: string, useCaseId?: string, projectId?: string): Promise<SuppressionCheck>;
|
|
438
451
|
/** GET /api/v1/preferences — one recipient's per-category subscriptions. */
|
|
439
452
|
getPreferences(email: string): Promise<RecipientPreferences>;
|
|
440
453
|
/**
|
package/dist/index.js
CHANGED
|
@@ -34,13 +34,15 @@ function sleep(ms) {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* Fills `useCaseId` and the deprecated `campaignId` from whichever the server
|
|
37
|
-
* sent, so a pre-rename server still works
|
|
37
|
+
* sent, so a pre-rename server still works, and the deprecated `unsubScope`
|
|
38
|
+
* the server no longer sends; delete in 1.0.0.
|
|
38
39
|
*/
|
|
40
|
+
let warnedUnsubScope = false;
|
|
39
41
|
function withListAliases(list) {
|
|
40
42
|
if (!list || typeof list !== "object")
|
|
41
43
|
return list;
|
|
42
44
|
const useCaseId = list.useCaseId ?? list.campaignId ?? null;
|
|
43
|
-
return { ...list, useCaseId, campaignId: useCaseId };
|
|
45
|
+
return { ...list, useCaseId, campaignId: useCaseId, unsubScope: list.unsubScope ?? "list" };
|
|
44
46
|
}
|
|
45
47
|
export class NevarMail {
|
|
46
48
|
baseUrl;
|
|
@@ -216,12 +218,15 @@ export class NevarMail {
|
|
|
216
218
|
return this.request("DELETE", `/api/v1/email/schedule/${encodeURIComponent(id)}`);
|
|
217
219
|
}
|
|
218
220
|
/**
|
|
219
|
-
* GET /api/v1/suppressions/check — would a send
|
|
220
|
-
*
|
|
221
|
+
* GET /api/v1/suppressions/check — would a send from this project to this
|
|
222
|
+
* address be blocked? Suppressions are per project. `projectId` defaults to
|
|
223
|
+
* the use case's project, else the org's only one (400 PROJECT_REQUIRED in a
|
|
224
|
+
* multi-project org). Omitting `useCaseId` is the strict answer: every list
|
|
225
|
+
* opt-out of the project counts.
|
|
221
226
|
*/
|
|
222
|
-
checkSuppression(email, useCaseId) {
|
|
227
|
+
checkSuppression(email, useCaseId, projectId) {
|
|
223
228
|
return this.request("GET", "/api/v1/suppressions/check", {
|
|
224
|
-
query: { email, use_case_id: useCaseId },
|
|
229
|
+
query: { email, use_case_id: useCaseId, project_id: projectId },
|
|
225
230
|
});
|
|
226
231
|
}
|
|
227
232
|
/** GET /api/v1/preferences — one recipient's per-category subscriptions. */
|
|
@@ -278,6 +283,11 @@ export class NevarMail {
|
|
|
278
283
|
}
|
|
279
284
|
/** POST /api/v1/lists — 409 DUPLICATE_NAME on a name the org already uses. */
|
|
280
285
|
async createList(input) {
|
|
286
|
+
if (input.unsubScope !== undefined && !warnedUnsubScope) {
|
|
287
|
+
warnedUnsubScope = true;
|
|
288
|
+
console.warn("@bernierllc/nevarmail: createList unsubScope is deprecated and ignored by the API; " +
|
|
289
|
+
"an unsubscribe is scoped to its list and project. It is removed in 1.0.0.");
|
|
290
|
+
}
|
|
281
291
|
return withListAliases(await this.request("POST", "/api/v1/lists", { body: input }));
|
|
282
292
|
}
|
|
283
293
|
/** GET /api/v1/lists/{id} — the v1 surface has no list update/delete routes. */
|
package/package.json
CHANGED