groundmail 0.14.1 → 0.14.3

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/authjs.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as Groundmail } from './client-DdrSVDkA.js';
1
+ import { G as Groundmail } from './client-xZ_HIfb9.js';
2
2
 
3
3
  /** Subset of Auth.js theme used for the default magic-link email. */
4
4
  type AuthjsTheme = {
package/dist/authjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-IZYE7HGT.js";
4
+ } from "./chunk-2ZKYDDVV.js";
5
5
 
6
6
  // src/authjs.ts
7
7
  function escapeHtml(value) {
@@ -1,4 +1,4 @@
1
- import { S as SendEmailResult, G as Groundmail } from './client-DdrSVDkA.js';
1
+ import { S as SendEmailResult, G as Groundmail } from './client-xZ_HIfb9.js';
2
2
 
3
3
  type BetterAuthEmailUser = {
4
4
  email: string;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-IZYE7HGT.js";
4
+ } from "./chunk-2ZKYDDVV.js";
5
5
 
6
6
  // src/better-auth.ts
7
7
  function linkHtml(label, url) {
@@ -7,14 +7,44 @@ var GroundmailError = class _GroundmailError extends Error {
7
7
  this.details = details;
8
8
  this.code = options?.code;
9
9
  this.upgradeUrl = options?.upgradeUrl;
10
+ this.hint = options?.hint;
11
+ this.docsUrl = options?.docsUrl;
12
+ this.requiredScope = options?.requiredScope;
13
+ }
14
+ /** Same fields as the API's error body, snake_case, for logging. */
15
+ toJSON() {
16
+ return {
17
+ name: this.name,
18
+ message: this.message,
19
+ status: this.status,
20
+ ...this.code ? { code: this.code } : {},
21
+ ...this.hint ? { hint: this.hint } : {},
22
+ ...this.docsUrl ? { docs_url: this.docsUrl } : {},
23
+ ...this.requiredScope ? { required_scope: this.requiredScope } : {},
24
+ ...this.upgradeUrl ? { upgrade_url: this.upgradeUrl } : {},
25
+ ...this.details !== void 0 ? { details: this.details } : {}
26
+ };
10
27
  }
28
+ /**
29
+ * Reads both error shapes the API returns: `{ error: { message, code, hint,
30
+ * docs_url, … } }`, and the older `{ error: "<message>", code, hint, docs_url }`.
31
+ */
11
32
  static fromResponse(status, body) {
12
- const err = body.error;
13
- const message = typeof err === "string" ? err : err?.message || `Request failed with status ${status}`;
14
- const details = typeof err === "object" && err ? err.details : void 0;
15
- const code = typeof err === "object" && err && "code" in err ? String(err.code) : void 0;
16
- const upgradeUrl = typeof err === "object" && err && "upgrade_url" in err ? String(err.upgrade_url) : void 0;
17
- return new _GroundmailError(message, status, details, { code, upgradeUrl });
33
+ const err = body?.error;
34
+ const nested = typeof err === "object" && err ? err : void 0;
35
+ const top = body ?? {};
36
+ const pick = (key) => {
37
+ const value = nested?.[key] ?? top[key];
38
+ return typeof value === "string" && value ? value : void 0;
39
+ };
40
+ const message = typeof err === "string" && err || nested?.message || pick("message") || `Request failed with status ${status}`;
41
+ return new _GroundmailError(message, status, nested ? nested.details : top.details, {
42
+ code: pick("code"),
43
+ upgradeUrl: pick("upgrade_url"),
44
+ hint: pick("hint"),
45
+ docsUrl: pick("docs_url"),
46
+ requiredScope: pick("required_scope")
47
+ });
18
48
  }
19
49
  };
20
50
 
package/dist/clerk.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as Groundmail, S as SendEmailResult } from './client-DdrSVDkA.js';
1
+ import { G as Groundmail, S as SendEmailResult } from './client-xZ_HIfb9.js';
2
2
 
3
3
  /**
4
4
  * Subset of Clerk `email.created` webhook `data` used for delivery.
package/dist/clerk.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-IZYE7HGT.js";
4
+ } from "./chunk-2ZKYDDVV.js";
5
5
 
6
6
  // src/clerk.ts
7
7
  function resolveApiKey(options) {
@@ -582,6 +582,7 @@ type DomainDnsAnalysis = {
582
582
  dmarc: DomainDmarcAnalysis;
583
583
  bimi: DomainBimiAnalysis;
584
584
  };
585
+ type DomainTrackingStatus = 'disabled' | 'pending' | 'active' | 'error';
585
586
  type DomainTrackingDns = {
586
587
  required: boolean;
587
588
  host: string | null;
@@ -596,6 +597,14 @@ type Domain = {
596
597
  verified_at: string | null;
597
598
  open_tracking: boolean;
598
599
  click_tracking: boolean;
600
+ /**
601
+ * Whether open/click tracking is actually being applied to outgoing mail:
602
+ * `pending` until the tracking CNAME is accepted and a certificate is issued for the
603
+ * tracking hostname (a few minutes after the CNAME is added), `active` once both are done.
604
+ */
605
+ tracking_status?: DomainTrackingStatus | string;
606
+ /** Why tracking is not active yet, when `tracking_status` is `pending` or `error`. */
607
+ tracking_error?: string | null;
599
608
  tls_mode: DomainTlsMode | string;
600
609
  inbound_enabled: boolean;
601
610
  inbound_status: 'disabled' | 'pending' | 'active' | 'error' | string;
@@ -719,13 +728,24 @@ type ApplyDnsResult = {
719
728
  domain: string;
720
729
  results: ApplyDnsRecordResult[];
721
730
  };
731
+ /** Fields the API puts on an error, nested under `error` or (older routes) beside it. */
732
+ type ApiErrorFields = {
733
+ message?: string;
734
+ details?: unknown;
735
+ /** Stable machine-readable code, e.g. `insufficient_scope`. */
736
+ code?: string;
737
+ /** How to fix it. */
738
+ hint?: string;
739
+ /** https://docs.groundmail.dev/errors#<code> */
740
+ docs_url?: string;
741
+ /** With `insufficient_scope`: the scope(s) the endpoint needs, space-separated. */
742
+ required_scope?: string;
743
+ upgrade_url?: string;
744
+ };
722
745
  type ApiErrorBody = {
723
- error?: string | {
724
- message?: string;
725
- details?: unknown;
726
- code?: string;
727
- upgrade_url?: string;
728
- };
746
+ error?: string | ApiErrorFields;
747
+ } & Omit<ApiErrorFields, 'message'> & {
748
+ message?: string;
729
749
  };
730
750
 
731
751
  declare class AutomationsResource {
@@ -947,4 +967,4 @@ declare class Groundmail {
947
967
  request<T>(path: string, init: RequestInit): Promise<T>;
948
968
  }
949
969
 
950
- export { type ListAutomationRunsParams as $, type ApiErrorBody as A, type BatchSendEmailResult as B, type CategoryUnsubscribedErrorDetails as C, type DnsRecord as D, DEFAULT_API_BASE_URL as E, type DeliverabilityBucket as F, Groundmail as G, type DeliverabilityDomainInsight as H, type DeliverabilityInsightsResult as I, type DeliverabilityMailServerRelay as J, type DeliverabilityWindow as K, type DnsProviderName as L, type Domain as M, type DomainBimiAnalysis as N, type DomainDetailResult as O, type DomainDmarcAnalysis as P, type DomainDnsAnalysis as Q, type DomainStatus as R, type SendEmailResult as S, type DomainTlsMode as T, type DomainTrackingDns as U, type EmailListItem as V, type EmailWebhookEventType as W, type EventRecord as X, type GroundmailOptions as Y, type ListApiKeysParams as Z, type ListApiKeysResult as _, type ApiErrorCode as a, type ListAutomationRunsResult as a0, type ListAutomationsResult as a1, type ListDomainsParams as a2, type ListDomainsResult as a3, type ListEmailsParams as a4, type ListEmailsResult as a5, type ListReceivedEmailsParams as a6, type ListReceivedEmailsResult as a7, type ListSuppressionsParams as a8, type ListSuppressionsResult as a9, type UpdateWebhookParams as aA, type VerifyDomainResult as aB, type WebhookEndpoint as aC, type WebhookEndpointWithSecret as aD, type WebhookEventType as aE, type ListTemplatesParams as aa, type ListTemplatesResult as ab, type MailServerSigningStatus as ac, type ReceivedEmail as ad, type ReceivedEmailAttachment as ae, type ReceivedEmailAttachmentMeta as af, type RemoteApplyDnsCredentials as ag, type SendEmailParams as ah, type SuppressedErrorDetails as ai, type Suppression as aj, type Template as ak, type TemplateFormat as al, type TemplateLintWarning as am, type TemplateStarter as an, type TemplateStatus as ao, type TemplateVersion as ap, type TestEmailWebhookParams as aq, type TestEmailWebhookResult as ar, type TriggerEventParams as as, type TriggerEventResult as at, type TwilioIntegrationResponse as au, type TwilioIntegrationStatus as av, type UpdateAutomationParams as aw, type UpdateDomainParams as ax, type UpdateEmailParams as ay, type UpdateTemplateParams as az, type ApiKey as b, type ApiKeyScope as c, type ApplyDnsParams as d, type ApplyDnsRecordResult as e, type ApplyDnsResult as f, type Asset as g, type Automation as h, type AutomationRun as i, type AutomationRunResponse as j, type AutomationRunStatus as k, type AutomationRunStep as l, type AutomationRunStepStatus as m, type AutomationStatus as n, type AutomationStep as o, type AutomationTrigger as p, type ConnectTwilioParams as q, type ContactWebhookEventPayload as r, type CreateApiKeyParams as s, type CreateApiKeyResult as t, type CreateAutomationParams as u, type CreateDomainParams as v, type CreateDomainResult as w, type CreateSuppressionParams as x, type CreateTemplateParams as y, type CreateWebhookParams as z };
970
+ export { type ListApiKeysResult as $, type ApiErrorBody as A, type BatchSendEmailResult as B, type CategoryUnsubscribedErrorDetails as C, type DnsRecord as D, DEFAULT_API_BASE_URL as E, type DeliverabilityBucket as F, Groundmail as G, type DeliverabilityDomainInsight as H, type DeliverabilityInsightsResult as I, type DeliverabilityMailServerRelay as J, type DeliverabilityWindow as K, type DnsProviderName as L, type Domain as M, type DomainBimiAnalysis as N, type DomainDetailResult as O, type DomainDmarcAnalysis as P, type DomainDnsAnalysis as Q, type DomainStatus as R, type SendEmailResult as S, type DomainTlsMode as T, type DomainTrackingDns as U, type DomainTrackingStatus as V, type EmailListItem as W, type EmailWebhookEventType as X, type EventRecord as Y, type GroundmailOptions as Z, type ListApiKeysParams as _, type ApiErrorCode as a, type ListAutomationRunsParams as a0, type ListAutomationRunsResult as a1, type ListAutomationsResult as a2, type ListDomainsParams as a3, type ListDomainsResult as a4, type ListEmailsParams as a5, type ListEmailsResult as a6, type ListReceivedEmailsParams as a7, type ListReceivedEmailsResult as a8, type ListSuppressionsParams as a9, type UpdateTemplateParams as aA, type UpdateWebhookParams as aB, type VerifyDomainResult as aC, type WebhookEndpoint as aD, type WebhookEndpointWithSecret as aE, type WebhookEventType as aF, type ListSuppressionsResult as aa, type ListTemplatesParams as ab, type ListTemplatesResult as ac, type MailServerSigningStatus as ad, type ReceivedEmail as ae, type ReceivedEmailAttachment as af, type ReceivedEmailAttachmentMeta as ag, type RemoteApplyDnsCredentials as ah, type SendEmailParams as ai, type SuppressedErrorDetails as aj, type Suppression as ak, type Template as al, type TemplateFormat as am, type TemplateLintWarning as an, type TemplateStarter as ao, type TemplateStatus as ap, type TemplateVersion as aq, type TestEmailWebhookParams as ar, type TestEmailWebhookResult as as, type TriggerEventParams as at, type TriggerEventResult as au, type TwilioIntegrationResponse as av, type TwilioIntegrationStatus as aw, type UpdateAutomationParams as ax, type UpdateDomainParams as ay, type UpdateEmailParams as az, type ApiKey as b, type ApiKeyScope as c, type ApplyDnsParams as d, type ApplyDnsRecordResult as e, type ApplyDnsResult as f, type Asset as g, type Automation as h, type AutomationRun as i, type AutomationRunResponse as j, type AutomationRunStatus as k, type AutomationRunStep as l, type AutomationRunStepStatus as m, type AutomationStatus as n, type AutomationStep as o, type AutomationTrigger as p, type ConnectTwilioParams as q, type ContactWebhookEventPayload as r, type CreateApiKeyParams as s, type CreateApiKeyResult as t, type CreateAutomationParams as u, type CreateDomainParams as v, type CreateDomainResult as w, type CreateSuppressionParams as x, type CreateTemplateParams as y, type CreateWebhookParams as z };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,37 @@
1
- import { A as ApiErrorBody, D as DnsRecord } from './client-DdrSVDkA.js';
2
- export { a as ApiErrorCode, b as ApiKey, c as ApiKeyScope, d as ApplyDnsParams, e as ApplyDnsRecordResult, f as ApplyDnsResult, g as Asset, h as Automation, i as AutomationRun, j as AutomationRunResponse, k as AutomationRunStatus, l as AutomationRunStep, m as AutomationRunStepStatus, n as AutomationStatus, o as AutomationStep, p as AutomationTrigger, B as BatchSendEmailResult, C as CategoryUnsubscribedErrorDetails, q as ConnectTwilioParams, r as ContactWebhookEventPayload, s as CreateApiKeyParams, t as CreateApiKeyResult, u as CreateAutomationParams, v as CreateDomainParams, w as CreateDomainResult, x as CreateSuppressionParams, y as CreateTemplateParams, z as CreateWebhookParams, E as DEFAULT_API_BASE_URL, F as DeliverabilityBucket, H as DeliverabilityDomainInsight, I as DeliverabilityInsightsResult, J as DeliverabilityMailServerRelay, K as DeliverabilityWindow, L as DnsProviderName, M as Domain, N as DomainBimiAnalysis, O as DomainDetailResult, P as DomainDmarcAnalysis, Q as DomainDnsAnalysis, R as DomainStatus, T as DomainTlsMode, U as DomainTrackingDns, V as EmailListItem, W as EmailWebhookEventType, X as EventRecord, G as Groundmail, Y as GroundmailOptions, Z as ListApiKeysParams, _ as ListApiKeysResult, $ as ListAutomationRunsParams, a0 as ListAutomationRunsResult, a1 as ListAutomationsResult, a2 as ListDomainsParams, a3 as ListDomainsResult, a4 as ListEmailsParams, a5 as ListEmailsResult, a6 as ListReceivedEmailsParams, a7 as ListReceivedEmailsResult, a8 as ListSuppressionsParams, a9 as ListSuppressionsResult, aa as ListTemplatesParams, ab as ListTemplatesResult, ac as MailServerSigningStatus, ad as ReceivedEmail, ae as ReceivedEmailAttachment, af as ReceivedEmailAttachmentMeta, ag as RemoteApplyDnsCredentials, ah as SendEmailParams, S as SendEmailResult, ai as SuppressedErrorDetails, aj as Suppression, ak as Template, al as TemplateFormat, am as TemplateLintWarning, an as TemplateStarter, ao as TemplateStatus, ap as TemplateVersion, aq as TestEmailWebhookParams, ar as TestEmailWebhookResult, as as TriggerEventParams, at as TriggerEventResult, au as TwilioIntegrationResponse, av as TwilioIntegrationStatus, aw as UpdateAutomationParams, ax as UpdateDomainParams, ay as UpdateEmailParams, az as UpdateTemplateParams, aA as UpdateWebhookParams, aB as VerifyDomainResult, aC as WebhookEndpoint, aD as WebhookEndpointWithSecret, aE as WebhookEventType } from './client-DdrSVDkA.js';
1
+ import { A as ApiErrorBody, D as DnsRecord } from './client-xZ_HIfb9.js';
2
+ export { a as ApiErrorCode, b as ApiKey, c as ApiKeyScope, d as ApplyDnsParams, e as ApplyDnsRecordResult, f as ApplyDnsResult, g as Asset, h as Automation, i as AutomationRun, j as AutomationRunResponse, k as AutomationRunStatus, l as AutomationRunStep, m as AutomationRunStepStatus, n as AutomationStatus, o as AutomationStep, p as AutomationTrigger, B as BatchSendEmailResult, C as CategoryUnsubscribedErrorDetails, q as ConnectTwilioParams, r as ContactWebhookEventPayload, s as CreateApiKeyParams, t as CreateApiKeyResult, u as CreateAutomationParams, v as CreateDomainParams, w as CreateDomainResult, x as CreateSuppressionParams, y as CreateTemplateParams, z as CreateWebhookParams, E as DEFAULT_API_BASE_URL, F as DeliverabilityBucket, H as DeliverabilityDomainInsight, I as DeliverabilityInsightsResult, J as DeliverabilityMailServerRelay, K as DeliverabilityWindow, L as DnsProviderName, M as Domain, N as DomainBimiAnalysis, O as DomainDetailResult, P as DomainDmarcAnalysis, Q as DomainDnsAnalysis, R as DomainStatus, T as DomainTlsMode, U as DomainTrackingDns, V as DomainTrackingStatus, W as EmailListItem, X as EmailWebhookEventType, Y as EventRecord, G as Groundmail, Z as GroundmailOptions, _ as ListApiKeysParams, $ as ListApiKeysResult, a0 as ListAutomationRunsParams, a1 as ListAutomationRunsResult, a2 as ListAutomationsResult, a3 as ListDomainsParams, a4 as ListDomainsResult, a5 as ListEmailsParams, a6 as ListEmailsResult, a7 as ListReceivedEmailsParams, a8 as ListReceivedEmailsResult, a9 as ListSuppressionsParams, aa as ListSuppressionsResult, ab as ListTemplatesParams, ac as ListTemplatesResult, ad as MailServerSigningStatus, ae as ReceivedEmail, af as ReceivedEmailAttachment, ag as ReceivedEmailAttachmentMeta, ah as RemoteApplyDnsCredentials, ai as SendEmailParams, S as SendEmailResult, aj as SuppressedErrorDetails, ak as Suppression, al as Template, am as TemplateFormat, an as TemplateLintWarning, ao as TemplateStarter, ap as TemplateStatus, aq as TemplateVersion, ar as TestEmailWebhookParams, as as TestEmailWebhookResult, at as TriggerEventParams, au as TriggerEventResult, av as TwilioIntegrationResponse, aw as TwilioIntegrationStatus, ax as UpdateAutomationParams, ay as UpdateDomainParams, az as UpdateEmailParams, aA as UpdateTemplateParams, aB as UpdateWebhookParams, aC as VerifyDomainResult, aD as WebhookEndpoint, aE as WebhookEndpointWithSecret, aF as WebhookEventType } from './client-xZ_HIfb9.js';
3
3
 
4
+ type GroundmailErrorOptions = {
5
+ code?: string;
6
+ upgradeUrl?: string;
7
+ hint?: string;
8
+ docsUrl?: string;
9
+ requiredScope?: string;
10
+ };
11
+ /**
12
+ * An API error. Besides `message` and `status`, the API says how to recover:
13
+ * `code` (stable, e.g. `insufficient_scope`), `hint` (what to do next),
14
+ * `docsUrl` (the errors page entry for the code), `requiredScope` (with
15
+ * `insufficient_scope`) and `upgradeUrl` (with plan limits).
16
+ */
4
17
  declare class GroundmailError extends Error {
5
18
  readonly status: number;
6
19
  readonly details?: unknown;
7
20
  readonly code?: string;
8
21
  readonly upgradeUrl?: string;
9
- constructor(message: string, status: number, details?: unknown, options?: {
10
- code?: string;
11
- upgradeUrl?: string;
12
- });
22
+ /** How to fix it, from the API. */
23
+ readonly hint?: string;
24
+ /** Docs for this error code, e.g. https://docs.groundmail.dev/errors#insufficient_scope */
25
+ readonly docsUrl?: string;
26
+ /** With `insufficient_scope`: the scope(s) the endpoint needs, space-separated. */
27
+ readonly requiredScope?: string;
28
+ constructor(message: string, status: number, details?: unknown, options?: GroundmailErrorOptions);
29
+ /** Same fields as the API's error body, snake_case, for logging. */
30
+ toJSON(): Record<string, unknown>;
31
+ /**
32
+ * Reads both error shapes the API returns: `{ error: { message, code, hint,
33
+ * docs_url, … } }`, and the older `{ error: "<message>", code, hint, docs_url }`.
34
+ */
13
35
  static fromResponse(status: number, body: ApiErrorBody): GroundmailError;
14
36
  }
15
37
 
@@ -53,4 +75,4 @@ declare function applyDnsRecords(input: {
53
75
  fetchImpl?: typeof fetch;
54
76
  }): Promise<ApplyDnsResult>;
55
77
 
56
- export { DnsRecord, GroundmailError, applyDnsRecords, buildSignatureHeader, mergeSpfInclude, signWebhookPayload, verifyWebhookSignature };
78
+ export { DnsRecord, GroundmailError, type GroundmailErrorOptions, applyDnsRecords, buildSignatureHeader, mergeSpfInclude, signWebhookPayload, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  mergeSpfInclude,
8
8
  signWebhookPayload,
9
9
  verifyWebhookSignature
10
- } from "./chunk-IZYE7HGT.js";
10
+ } from "./chunk-2ZKYDDVV.js";
11
11
  export {
12
12
  DEFAULT_API_BASE_URL,
13
13
  Groundmail,
package/dist/payload.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as Groundmail } from './client-DdrSVDkA.js';
1
+ import { G as Groundmail } from './client-xZ_HIfb9.js';
2
2
 
3
3
  /**
4
4
  * Minimal Payload `SendEmailOptions` / address shapes used by this adapter.
package/dist/payload.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_API_BASE_URL,
3
3
  Groundmail
4
- } from "./chunk-IZYE7HGT.js";
4
+ } from "./chunk-2ZKYDDVV.js";
5
5
 
6
6
  // src/payload.ts
7
7
  function resolveApiKey(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "groundmail",
3
- "version": "0.14.1",
3
+ "version": "0.14.3",
4
4
  "description": "Groundmail transactional email API client",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -89,7 +89,7 @@
89
89
  "prepublishOnly": "npm run build && npm run build:nodemailer-bridge"
90
90
  },
91
91
  "dependencies": {
92
- "groundmail-nodemailer": "0.14.1"
92
+ "groundmail-nodemailer": "0.14.3"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/nodemailer": "^8.0.1",