@bernierllc/nevarmail 0.6.0 → 0.7.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/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;
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
- return this.requestPaginated("GET", "/api/v1/lists", { query: { ...options } });
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/nevarmail",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Official client for the NevarMail v1 API. Typed, retries 429/5xx, throws NevarMailError on every non-2xx.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",