groundmail 0.14.1 → 0.14.2

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-B8xoWTgr.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-B8xoWTgr.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-B8xoWTgr.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) {
@@ -719,13 +719,24 @@ type ApplyDnsResult = {
719
719
  domain: string;
720
720
  results: ApplyDnsRecordResult[];
721
721
  };
722
+ /** Fields the API puts on an error, nested under `error` or (older routes) beside it. */
723
+ type ApiErrorFields = {
724
+ message?: string;
725
+ details?: unknown;
726
+ /** Stable machine-readable code, e.g. `insufficient_scope`. */
727
+ code?: string;
728
+ /** How to fix it. */
729
+ hint?: string;
730
+ /** https://docs.groundmail.dev/errors#<code> */
731
+ docs_url?: string;
732
+ /** With `insufficient_scope`: the scope(s) the endpoint needs, space-separated. */
733
+ required_scope?: string;
734
+ upgrade_url?: string;
735
+ };
722
736
  type ApiErrorBody = {
723
- error?: string | {
724
- message?: string;
725
- details?: unknown;
726
- code?: string;
727
- upgrade_url?: string;
728
- };
737
+ error?: string | ApiErrorFields;
738
+ } & Omit<ApiErrorFields, 'message'> & {
739
+ message?: string;
729
740
  };
730
741
 
731
742
  declare class AutomationsResource {
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-B8xoWTgr.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-B8xoWTgr.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-B8xoWTgr.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.2",
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.2"
93
93
  },
94
94
  "devDependencies": {
95
95
  "@types/nodemailer": "^8.0.1",