@bernierllc/nevarmail 0.5.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/README.md CHANGED
@@ -151,6 +151,7 @@ yourself can narrow a block; a default the server resolves cannot.
151
151
  | `listContacts` / `upsertContacts` / `updateContact` / `deleteContact` | `/api/v1/contacts` | `contacts:read` / `contacts:write` |
152
152
  | `listSenders` / `createSender(input)` — `input.projectId?` targets a project when the org has more than one | `/api/v1/senders` | `senders:read` / `senders:write` |
153
153
  | `getSender` / `updateSender` / `deleteSender` | `/api/v1/senders/{id}` | `senders:read` / `senders:write` |
154
+ | `importSenders({ projectId? })` — adopts the project's provider-account identities; re-run to pick up provider verification | `POST /api/v1/senders/import` | `senders:write` |
154
155
  | `listDomains` / `createDomain(domain, { projectId })` / `getDomain` / `deleteDomain` | `/api/v1/domains` | `domains:read` / `domains:write` |
155
156
  | `getDomainDnsRecords` / `verifyDomain` | `/api/v1/domains/{id}/…` | `domains:read` / `domains:write` |
156
157
  | `listSuppressions` / `addSuppressions` | `/api/v1/suppressions` | `org:read` / `org:write` |
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;
@@ -253,6 +263,17 @@ export interface CreateSenderInput {
253
263
  }
254
264
  /** A sender stays in the project it was created in, so `projectId` is create-only. */
255
265
  export type UpdateSenderInput = Partial<Omit<CreateSenderInput, "projectId">>;
266
+ /** Result of `importSenders`: counts per outcome, then the project's senders. */
267
+ export interface ImportSendersResult {
268
+ /** Provider identities with no NevarMail sender yet — created. */
269
+ imported: number;
270
+ /** Existing senders matched by address and stamped with the provider id. */
271
+ linked: number;
272
+ /** Already-imported senders whose address or verification changed at the provider. */
273
+ refreshed: number;
274
+ unchanged: number;
275
+ senders: Sender[];
276
+ }
256
277
  export interface DnsRecord {
257
278
  type: "TXT" | "CNAME" | "MX";
258
279
  host: string;
@@ -468,6 +489,18 @@ export declare class NevarMail {
468
489
  listSenders(options?: PageOptions): Promise<Paginated<Sender>>;
469
490
  /** POST /api/v1/senders */
470
491
  createSender(input: CreateSenderInput): Promise<Sender>;
492
+ /**
493
+ * POST /api/v1/senders/import — adopt the sender identities already at the
494
+ * project's connected provider account instead of creating parallel ones.
495
+ * Idempotent; re-run it to pick up verification completed at the provider.
496
+ * `projectId` follows `createSender`: omit it only when the org has one
497
+ * project (else 400 `PROJECT_REQUIRED`); 404 `NOT_FOUND` for a project the
498
+ * key's user can't open; 400 `VALIDATION_ERROR` when that project has no
499
+ * connected provider account.
500
+ */
501
+ importSenders(options?: {
502
+ projectId?: string;
503
+ }): Promise<ImportSendersResult>;
471
504
  /** GET /api/v1/senders/{id} — 404 NOT_FOUND. */
472
505
  getSender(id: string): Promise<Sender>;
473
506
  /** PATCH /api/v1/senders/{id} — a partial update; the route has no PUT. */
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).
@@ -311,6 +322,20 @@ export class NevarMail {
311
322
  createSender(input) {
312
323
  return this.request("POST", "/api/v1/senders", { body: input });
313
324
  }
325
+ /**
326
+ * POST /api/v1/senders/import — adopt the sender identities already at the
327
+ * project's connected provider account instead of creating parallel ones.
328
+ * Idempotent; re-run it to pick up verification completed at the provider.
329
+ * `projectId` follows `createSender`: omit it only when the org has one
330
+ * project (else 400 `PROJECT_REQUIRED`); 404 `NOT_FOUND` for a project the
331
+ * key's user can't open; 400 `VALIDATION_ERROR` when that project has no
332
+ * connected provider account.
333
+ */
334
+ importSenders(options = {}) {
335
+ return this.request("POST", "/api/v1/senders/import", {
336
+ query: { projectId: options.projectId },
337
+ });
338
+ }
314
339
  /** GET /api/v1/senders/{id} — 404 NOT_FOUND. */
315
340
  getSender(id) {
316
341
  return this.request("GET", `/api/v1/senders/${encodeURIComponent(id)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/nevarmail",
3
- "version": "0.5.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",