@absolutejs/dispatch-resend

中文文档
0.7.1发布于 2026/11/02Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 1986

Resend-backed EmailAdapter with credential-safe installed effects, signed evidence, and reference-gated query recovery.

原始使用文档
文档目录7 节
  1. Install
  2. Usage
  3. API
  4. tagsFromMetadata
  5. Error mapping
  6. License
  7. Durable effect webhook evidence

@absolutejs/dispatch-resend

Resend-backed EmailAdapter for @absolutejs/dispatch.

Docs: absolutejs.com/documentation/dispatch#adapters

Install

bun add @absolutejs/dispatch @absolutejs/dispatch-resend resend

Usage

import { Resend } from "resend";
import { createDispatcher } from "@absolutejs/dispatch";
import { createResendAdapter } from "@absolutejs/dispatch-resend";

const resend = new Resend(process.env.RESEND_KEY!);

const dispatcher = createDispatcher({
  email: createResendAdapter({
    client: resend,
    defaultFrom: "[email protected]",
  }),
});

const result = await dispatcher.email({
  to: "[email protected]",
  subject: "Welcome to Acme",
  text: "Click here to verify: ...",
  // String metadata becomes Resend tags by default:
  metadata: { campaign: "welcome-v2", priority: "high" },
});

console.log(result.id); // Resend's message id

API

createResendAdapter({
  client,         // Required — your `new Resend(apiKey)`
  defaultFrom?,   // Required if your messages don't set `from`
  tagsFromMetadata?,  // Customize metadata → Resend tags mapping
})

tagsFromMetadata

By default the adapter maps every string-valued entry in message.metadata to a Resend tag. Non-string values (numbers, booleans, objects) are filtered out — Resend requires string for both name and value.

Override to customize:

createResendAdapter({
  client: resend,
  tagsFromMetadata: (metadata) => [
    // Always include the tenant
    ...(typeof metadata.tenant === "string"
      ? [{ name: "tenant", value: metadata.tenant }]
      : []),
    // Drop debug-only entries
  ],
});

Error mapping

Resend's { data, error } response shape becomes:

  • error set → adapter throws (@absolutejs/dispatch records the exception on the dispatch.email.send span, bumps failed counter, emits dispatch.email.failed audit event).
  • data.id present → DispatchResult.id = the Resend message id.
  • data.id missing → DispatchResult.id is undefined, result.provider still 'resend'.

License

Apache 2.0. Tier B substrate-adjacent under the AbsoluteJS licensing policy — rides @absolutejs/dispatch (BSL Tier A) and resend (MIT). The package also exports resendEffectAdapterDescriptor and createResendEffectAdapterDriver() for @absolutejs/execution. The driver accepts resolved credentials only in its execution context, requires the exact Resend API destination and email.send effect, and forwards the durable effect idempotency key to Resend. Hosts retain ownership of secret storage and provide the narrow clientForKey factory at the final provider boundary.

Durable effect webhook evidence

The effect driver adds an abs_effect Resend tag containing the durable effect ID and declares its complete webhook setup: callback template, Standard Webhooks headers, supported outbound events, exact secret alias, last-verified-event health signal, and signed-event replacement rotation. Hosts can pass the exact raw request body, Standard Webhooks headers, project tenant ID, and that project's exact RESEND_WEBHOOK_SECRET to verifyResendEffectWebhook(). It uses Resend's SDK verifier before returning a normalized EffectEvidenceRecord; recipients, sender, subject, headers, and the raw payload are never returned for storage.

The descriptor uses webhook-query: signed webhooks remain primary, while createResendEffectQueryDriver() can retrieve an ambiguous send only when Execution retained the exact Resend email ID returned by the original call. The execution driver extracts that bounded reference without retaining the provider response. The query fallback verifies the retrieved email ID and its abs_effect tag before returning normalized evidence. If an ambiguous network call returned no ID, the runtime skips this fallback before resolving the API key and continues waiting for signed webhook or operator evidence; it never replays the send.

All supported outbound email.* webhook events confirm that the email.send effect was accepted by Resend, so the normalized effect outcome is confirmed_succeeded. Delivery state remains explicit in eventType (for example email.delivered, email.bounced, or email.failed) and must not be confused with successful inbox delivery. Inbound email.received, contact, domain, uncorrelated, and invalidly signed events are rejected.

Webhook signing secrets are host ingress credentials, not provider-send credentials. Store one under the exact project secret alias RESEND_WEBHOOK_SECRET; do not place it in an adapter installation or resolve it during email sends.

版本与发布记录

@absolutejs/dispatch-resend 共发布 18 个版本,首次发布于 2026/05/31;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.1latest2026/11/025 天前
0.7.02026/08/023 个月前
0.6.22026/07/253 个月前
0.6.12026/07/223 个月前
0.6.02026/07/223 个月前
0.5.12026/07/223 个月前

关于 @absolutejs/dispatch-resend 的常见问题

@absolutejs/dispatch-resend 是什么?

Resend-backed EmailAdapter with credential-safe installed effects, signed evidence, and reference-gated query recovery.

如何安装 @absolutejs/dispatch-resend?

在项目目录运行 npm install @absolutejs/dispatch-resend,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:resend(>=6.18.0 <7)、@absolutejs/dispatch(>=0.7.0 <0.10)、@absolutejs/execution(>=0.14.6 <0.15)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@absolutejs/dispatch-resend 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@absolutejs/dispatch-resend 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@absolutejs/dispatch-resend 可以商用吗?

@absolutejs/dispatch-resend 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@absolutejs/dispatch-resend 的下载量有多少?

根据 npm 官方下载统计,@absolutejs/dispatch-resend 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,986 次,日均约 66 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@absolutejs/dispatch-resend 还在维护吗?

最新版本 0.7.1 发布于 2026/11/02(5 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/05/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。