@bernierllc/nevarmail 0.6.0 → 0.8.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 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.js +17 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -169,7 +169,8 @@ Application-level details worth knowing before you hit them:
|
|
|
169
169
|
other delete throws on a missing resource.
|
|
170
170
|
- **Lists have no update or delete** — the API exposes none; the SDK does not invent them.
|
|
171
171
|
- **Suppression scope is cross-field**: `scope: "use_case"` requires `use_case_id`, and
|
|
172
|
-
`use_case_id` with `scope: "account"` is a `400`.
|
|
172
|
+
`use_case_id` with `scope: "account"` is a `400`. `projectId` names the project the rows land
|
|
173
|
+
in; omitted, they land in the use case's project, else in every project the key's owner can open.
|
|
173
174
|
- **Managed accounts cannot delete domains** — `deleteDomain` throws `403 MANAGED_ACCOUNT`.
|
|
174
175
|
|
|
175
176
|
Anything still not covered — analytics, campaigns, webhook endpoints — goes through
|
package/dist/index.d.ts
CHANGED
|
@@ -160,6 +160,16 @@ export interface SubscriberList {
|
|
|
160
160
|
storageTier: string;
|
|
161
161
|
primaryProviderId: string | null;
|
|
162
162
|
providerListIds: unknown;
|
|
163
|
+
/**
|
|
164
|
+
* The use case this list belongs to; a use case has at most one list.
|
|
165
|
+
* Optional until 1.0.0 so 0.6-shaped values still type-check; the client
|
|
166
|
+
* always fills it on lists it returns.
|
|
167
|
+
*/
|
|
168
|
+
useCaseId?: string | null;
|
|
169
|
+
/**
|
|
170
|
+
* @deprecated since 0.7.0; removed in 1.0.0; use `useCaseId`. The API no
|
|
171
|
+
* longer returns this field; the client fills it from `useCaseId`.
|
|
172
|
+
*/
|
|
163
173
|
campaignId: string | null;
|
|
164
174
|
syncStatus: string;
|
|
165
175
|
lastSyncedAt: string | null;
|
|
@@ -353,6 +363,12 @@ export interface AddSuppressionsInput {
|
|
|
353
363
|
/** Default `"account"`. `"use_case"` requires `use_case_id`; `use_case_id` with `"account"` is a 400. */
|
|
354
364
|
scope?: "account" | "use_case";
|
|
355
365
|
use_case_id?: string;
|
|
366
|
+
/**
|
|
367
|
+
* The project the rows land in. Omitted: the use case's project, else every
|
|
368
|
+
* project the key's owner can open (one row per project; counts are rows, summed). A
|
|
369
|
+
* `use_case_id` of another project is a `422 USE_CASE_PROJECT_MISMATCH`.
|
|
370
|
+
*/
|
|
371
|
+
projectId?: string;
|
|
356
372
|
/** Default `"unsubscribe"` — the only reason that queues provider sync. */
|
|
357
373
|
reason?: SuppressionReason;
|
|
358
374
|
}
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,16 @@ function isRetryableStatus(status) {
|
|
|
32
32
|
function sleep(ms) {
|
|
33
33
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Fills `useCaseId` and the deprecated `campaignId` from whichever the server
|
|
37
|
+
* sent, so a pre-rename server still works; delete in 1.0.0.
|
|
38
|
+
*/
|
|
39
|
+
function withListAliases(list) {
|
|
40
|
+
if (!list || typeof list !== "object")
|
|
41
|
+
return list;
|
|
42
|
+
const useCaseId = list.useCaseId ?? list.campaignId ?? null;
|
|
43
|
+
return { ...list, useCaseId, campaignId: useCaseId };
|
|
44
|
+
}
|
|
35
45
|
export class NevarMail {
|
|
36
46
|
baseUrl;
|
|
37
47
|
/** Derived from the key prefix, not configured — a mismatch is not possible. */
|
|
@@ -262,16 +272,17 @@ export class NevarMail {
|
|
|
262
272
|
}
|
|
263
273
|
// ── Lists & contacts ───────────────────────────────────────────────────
|
|
264
274
|
/** GET /api/v1/lists — paged. */
|
|
265
|
-
listLists(options = {}) {
|
|
266
|
-
|
|
275
|
+
async listLists(options = {}) {
|
|
276
|
+
const page = await this.requestPaginated("GET", "/api/v1/lists", { query: { ...options } });
|
|
277
|
+
return { ...page, data: page.data.map(withListAliases) };
|
|
267
278
|
}
|
|
268
279
|
/** POST /api/v1/lists — 409 DUPLICATE_NAME on a name the org already uses. */
|
|
269
|
-
createList(input) {
|
|
270
|
-
return this.request("POST", "/api/v1/lists", { body: input });
|
|
280
|
+
async createList(input) {
|
|
281
|
+
return withListAliases(await this.request("POST", "/api/v1/lists", { body: input }));
|
|
271
282
|
}
|
|
272
283
|
/** GET /api/v1/lists/{id} — the v1 surface has no list update/delete routes. */
|
|
273
|
-
getList(id) {
|
|
274
|
-
return this.request("GET", `/api/v1/lists/${encodeURIComponent(id)}`);
|
|
284
|
+
async getList(id) {
|
|
285
|
+
return withListAliases(await this.request("GET", `/api/v1/lists/${encodeURIComponent(id)}`));
|
|
275
286
|
}
|
|
276
287
|
/**
|
|
277
288
|
* POST /api/v1/lists/{id}/contacts — one contact or a batch (max 1000).
|
package/package.json
CHANGED