@dbx-tools/shared-teams

中文文档
0.9.144发布于 2026/10/20Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 3033

Browser-safe Adaptive Card and Bot Framework activity schemas for the Teams add-on

原始使用文档
文档目录5 节
  1. Quick start
  2. Validate card fields
  3. Validate a compiled card
  4. Runtime boundary
  5. Package exports

@dbx-tools/shared-teams

Validate Microsoft Teams Adaptive Card and Bot Framework activity payloads in browser and server code. It defines the shared Zod schemas, inferred types, attachment helpers, and constants. The @dbx-tools/teams server package builds these payloads, and @dbx-tools/ui-teams renders them.

Quick start

import { card } from "@dbx-tools/shared-teams";

const spec = card.cardSpecSchema.parse({
  title: "Deployment succeeded",
  text: "The API service rolled out cleanly.",
});

Use these contracts and builders for:

  • High-level CardSpec contract: the small, model-friendly vocabulary a model drafts (title, subtitle, text, facts, link actions) instead of hand-authoring raw Adaptive Card JSON.
  • AdaptiveCard envelope schema for the compiled Adaptive Card 1.5 document the adaptivecards renderer consumes and Teams accepts.
  • CardResult schema for the build response returned to a model or a browser.
  • Activity contract for the conversation endpoint: the Bot Framework envelope a Teams channel exchanges, with CardAttachment tagging a card as application/vnd.microsoft.card.adaptive, plus the toCardAttachment / cardsOf helpers both sides use so attachments are wrapped and read identically. Unknown activity fields are preserved rather than stripped because a real channel sends far more than this package reads.
  • Model/tool-friendly schemas that avoid JSON Schema constraints known to cause problems with some serving endpoints (no array minItems).

Validate card fields

import { card, type CardSpec } from "@dbx-tools/shared-teams";

const spec: CardSpec = card.cardSpecSchema.parse({
  title: "Deployment succeeded",
  subtitle: "prod • 2m ago",
  text: "The **api** service rolled out cleanly.",
  facts: [
    { title: "Version", value: "1.4.2" },
    { title: "Owner", value: "alice" },
  ],
  actions: [{ title: "View run", url: "https://example.com/runs/42" }],
});

The spec schema is intentionally small so a model produces valid input rather than free-form card JSON the renderer would reject.

Validate a compiled card

const result = card.cardResultSchema.parse(await response.json());
// result.card is a full Adaptive Card document ready to render or post to Teams.

adaptiveCardSchema validates the common envelope fields: type, $schema, version, and body. The builder in @dbx-tools/teams defines the exact element shapes inside body and actions.

Runtime boundary

This package doesn't render cards, run agents, validate Microsoft Bot Framework tokens, or post to Teams. Use @dbx-tools/teams for those server operations and @dbx-tools/ui-teams for React rendering.

Package exports

  • card: cardFactSchema, cardActionSchema, cardSpecSchema, adaptiveCardSchema, cardResultSchema, the ADAPTIVE_CARD_VERSION / ADAPTIVE_CARD_SCHEMA_URL constants, and flat inferred types: CardFact, CardAction, CardSpec, AdaptiveCard, and CardResult.
  • teamsActivity: activitySchema, activityRequestSchema, activityResponseSchema, cardAttachmentSchema, channelAccountSchema, conversationAccountSchema, the ADAPTIVE_CARD_CONTENT_TYPE / ACTIVITY_TYPES constants, the toCardAttachment / cardsOf helpers, and the Activity, ActivityRequest, ActivityResponse, CardAttachment, ChannelAccount, ConversationAccount, and ActivityType types.

The schemas intentionally avoid array .min() constraints so they can be reused as model/tool JSON schemas for serving endpoints that reject minItems.

版本与发布记录

@dbx-tools/shared-teams 共发布 261 个版本,首次发布于 2026/07/28;过去 12 个月发布了 261 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.9.144latest2026/10/2022 天前
0.9.1432026/10/2022 天前
0.9.1412026/10/2023 天前
0.9.1402026/10/2023 天前
0.9.1392026/10/2023 天前
0.9.1382026/10/1923 天前

关于 @dbx-tools/shared-teams 的常见问题

@dbx-tools/shared-teams 是什么?

Browser-safe Adaptive Card and Bot Framework activity schemas for the Teams add-on

如何安装 @dbx-tools/shared-teams?

在项目目录运行 npm install @dbx-tools/shared-teams,或使用 pnpm add / yarn add / bun add。

@dbx-tools/shared-teams 支持 TypeScript 吗?

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

@dbx-tools/shared-teams 支持 ESM 还是 CommonJS?

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

@dbx-tools/shared-teams 可以商用吗?

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

@dbx-tools/shared-teams 的下载量有多少?

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

@dbx-tools/shared-teams 还在维护吗?

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