@bernierllc/nevarmail 0.30.0 → 0.32.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
@@ -180,6 +180,8 @@ the two, not both). The slug must exist in exactly one project the key can open:
180
180
  | `listUseCases({ projectId?, includeArchived? })` / `createUseCase(input)` — `input.projectId?` as for `createSender` | `/api/v1/use-cases` | `use-cases:read` / `use-cases:write` |
181
181
  | `getUseCase` / `updateUseCase` / `archiveUseCase` / `restoreUseCase` — delete archives; restore undoes it | `/api/v1/use-cases/{id}` | `use-cases:read` / `use-cases:write` |
182
182
  | `importSenders({ projectId? })` — adopts the project's provider-account identities; re-run to pick up provider verification | `POST /api/v1/senders/import` | `senders:write` |
183
+ | `getSendingPause({ projectId? })` — the org's pause, or one project's; `paused` is effective (an org pause covers every project), `local` is that scope alone | `GET /api/v1/safety/pause`, `GET /api/v1/projects/{id}/safety/pause` | `org:read` |
184
+ | `pauseSending({ projectId?, reason? })` / `resumeSending({ projectId? })` — stops or restarts all new mail; paused sends throw `423 SENDING_PAUSED`. A key pinned to one project cannot pause the org (`403 KEY_PROJECT_SCOPED`) | `PUT /api/v1/safety/pause`, `PUT /api/v1/projects/{id}/safety/pause` | `sending:pause` |
183
185
  | `listDomains` / `createDomain(domain, { projectId })` / `getDomain` / `deleteDomain` | `/api/v1/domains` | `domains:read` / `domains:write` |
184
186
  | `getDomainDnsRecords` / `verifyDomain` | `/api/v1/domains/{id}/…` | `domains:read` / `domains:write` |
185
187
  | `getDomainBrandedTracking` / `enableDomainBrandedTracking` | `GET` / `POST /api/v1/domains/{id}/branded-tracking` | `domains:read` / `domains:write` |
package/dist/index.d.ts CHANGED
@@ -439,6 +439,10 @@ export interface Sender {
439
439
  createdAt: string;
440
440
  updatedAt: string;
441
441
  }
442
+ /** What `createSender` and `updateSender` return: the sender, plus the default it displaced (else `null`). */
443
+ export type SenderWriteResult = Sender & {
444
+ replacedDefaultSenderId: string | null;
445
+ };
442
446
  export interface CreateSenderInput {
443
447
  name: string;
444
448
  /** Must be on a verified sending domain of the sender's project, else 400 `VALIDATION_ERROR`. */
@@ -448,7 +452,20 @@ export interface CreateSenderInput {
448
452
  provider?: string;
449
453
  providerSenderId?: string;
450
454
  priority?: number;
455
+ /**
456
+ * Make this the project's default sender. When the project already has a default, the call
457
+ * fails with 409 `DEFAULT_SENDER_EXISTS` (`error.body.details` names `current_default_sender_id`
458
+ * and `current_default_from_email`) unless `replaceDefault: true` is also sent. A project's first
459
+ * sender becomes the default without it.
460
+ */
451
461
  isDefault?: boolean;
462
+ /** Confirms that `isDefault: true` may take the default from the sender that holds it. Ignored otherwise. */
463
+ replaceDefault?: boolean;
464
+ /**
465
+ * The default sender you were shown (`details.current_default_sender_id` of the 409) and confirmed
466
+ * replacing. If the default changed since, the call fails with 409 again. Optional with `replaceDefault`.
467
+ */
468
+ replaceDefaultSenderId?: string;
452
469
  /**
453
470
  * Target project (UUID). Omit it when the org has only one project — it goes there.
454
471
  * Several projects and no `projectId`: 400 `PROJECT_REQUIRED`. No project on the org:
@@ -470,6 +487,34 @@ export type UpdateSenderInput = Partial<Omit<CreateSenderInput, "projectId" | "f
470
487
  provider?: string | null;
471
488
  isActive?: boolean;
472
489
  };
490
+ /** Who paused a scope. `apiKeyId` is set when a key or OAuth token did it. */
491
+ export interface SendingPauseActor {
492
+ kind: "user" | "api_key" | "oauth";
493
+ userId: string;
494
+ apiKeyId: string | null;
495
+ }
496
+ /**
497
+ * GET/PUT `/api/v1/safety/pause` and `/api/v1/projects/{id}/safety/pause`.
498
+ * `paused` is the effective answer (an org pause covers every project);
499
+ * `local` is the scope asked about on its own.
500
+ */
501
+ export interface SendingPause {
502
+ paused: boolean;
503
+ /** Which pause is in force; the org's wins. Null while sending. */
504
+ level: "org" | "project" | null;
505
+ local: {
506
+ paused: boolean;
507
+ pausedAt: string | null;
508
+ pausedBy: SendingPauseActor | null;
509
+ reason: string | null;
510
+ };
511
+ /** Whether this key may change the pause (holds `sending:pause` and is not pinned elsewhere). */
512
+ canPause: boolean;
513
+ }
514
+ /** `projectId` omitted: the whole org. */
515
+ export interface SendingPauseScope {
516
+ projectId?: string;
517
+ }
473
518
  /** A use case: the message category a project files mail under (`use_case_id` / `useCase` on a send). */
474
519
  export interface UseCase {
475
520
  groupId?: string | null;
@@ -1106,7 +1151,7 @@ export declare class NevarMail {
1106
1151
  /** GET /api/v1/senders — paged. */
1107
1152
  listSenders(options?: PageOptions): Promise<Paginated<Sender>>;
1108
1153
  /** POST /api/v1/senders */
1109
- createSender(input: CreateSenderInput): Promise<Sender>;
1154
+ createSender(input: CreateSenderInput): Promise<SenderWriteResult>;
1110
1155
  /**
1111
1156
  * POST /api/v1/senders/import — adopt the sender identities already at the
1112
1157
  * project's connected provider account instead of creating parallel ones.
@@ -1122,7 +1167,7 @@ export declare class NevarMail {
1122
1167
  /** GET /api/v1/senders/{id} — 404 NOT_FOUND. */
1123
1168
  getSender(id: string): Promise<Sender>;
1124
1169
  /** PATCH /api/v1/senders/{id} — a partial update; the route has no PUT. */
1125
- updateSender(id: string, input: UpdateSenderInput): Promise<Sender>;
1170
+ updateSender(id: string, input: UpdateSenderInput): Promise<SenderWriteResult>;
1126
1171
  /**
1127
1172
  * DELETE /api/v1/senders/{id} — 404 NOT_FOUND. A sender linked to a provider identity
1128
1173
  * (`providerSenderId`) returns 400 `VALIDATION_ERROR`: a re-sync would bring it back, so
@@ -1159,6 +1204,22 @@ export declare class NevarMail {
1159
1204
  archiveUseCase(id: string): Promise<UseCase>;
1160
1205
  /** POST /api/v1/use-cases/{id}/restore — idempotent on an active use case. */
1161
1206
  restoreUseCase(id: string): Promise<UseCase>;
1207
+ /**
1208
+ * GET /api/v1/safety/pause, or /api/v1/projects/{id}/safety/pause with
1209
+ * `projectId`. Scope `org:read`.
1210
+ */
1211
+ getSendingPause(options?: SendingPauseScope): Promise<SendingPause>;
1212
+ /**
1213
+ * Stops all new mail for the org, or one project with `projectId`, until
1214
+ * `resumeSending`. Sends then fail with 423 `SENDING_PAUSED`. Scope
1215
+ * `sending:pause`; a key pinned to one project cannot pause the org
1216
+ * (403 `KEY_PROJECT_SCOPED`). `reason` (max 500 chars) is shown to the team.
1217
+ */
1218
+ pauseSending(options?: SendingPauseScope & {
1219
+ reason?: string;
1220
+ }): Promise<SendingPause>;
1221
+ /** Lifts the org's or one project's pause. A project stays paused while its org is. Scope `sending:pause`. */
1222
+ resumeSending(options?: SendingPauseScope): Promise<SendingPause>;
1162
1223
  /** GET /api/v1/domains — paged; list rows carry extras single reads do not. */
1163
1224
  listDomains(options?: PageOptions): Promise<Paginated<Domain>>;
1164
1225
  /**
package/dist/index.js CHANGED
@@ -608,6 +608,35 @@ export class NevarMail {
608
608
  restoreUseCase(id) {
609
609
  return this.request("POST", `/api/v1/use-cases/${encodeURIComponent(id)}/restore`);
610
610
  }
611
+ // ── Sending pause ──────────────────────────────────────────────────────
612
+ /**
613
+ * GET /api/v1/safety/pause, or /api/v1/projects/{id}/safety/pause with
614
+ * `projectId`. Scope `org:read`.
615
+ */
616
+ getSendingPause(options = {}) {
617
+ return options.projectId !== undefined
618
+ ? this.request("GET", `/api/v1/projects/${encodeURIComponent(options.projectId)}/safety/pause`)
619
+ : this.request("GET", "/api/v1/safety/pause");
620
+ }
621
+ /**
622
+ * Stops all new mail for the org, or one project with `projectId`, until
623
+ * `resumeSending`. Sends then fail with 423 `SENDING_PAUSED`. Scope
624
+ * `sending:pause`; a key pinned to one project cannot pause the org
625
+ * (403 `KEY_PROJECT_SCOPED`). `reason` (max 500 chars) is shown to the team.
626
+ */
627
+ pauseSending(options = {}) {
628
+ const body = { paused: true, reason: options.reason };
629
+ return options.projectId !== undefined
630
+ ? this.request("PUT", `/api/v1/projects/${encodeURIComponent(options.projectId)}/safety/pause`, { body })
631
+ : this.request("PUT", "/api/v1/safety/pause", { body });
632
+ }
633
+ /** Lifts the org's or one project's pause. A project stays paused while its org is. Scope `sending:pause`. */
634
+ resumeSending(options = {}) {
635
+ const body = { paused: false };
636
+ return options.projectId !== undefined
637
+ ? this.request("PUT", `/api/v1/projects/${encodeURIComponent(options.projectId)}/safety/pause`, { body })
638
+ : this.request("PUT", "/api/v1/safety/pause", { body });
639
+ }
611
640
  // ── Domains ────────────────────────────────────────────────────────────
612
641
  /** GET /api/v1/domains — paged; list rows carry extras single reads do not. */
613
642
  listDomains(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/nevarmail",
3
- "version": "0.30.0",
3
+ "version": "0.32.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",