@dbx-tools/shared-teams
v0.6.4
Published
Browser-safe Adaptive Card and Bot Framework activity schemas (plus inferred types) for the Teams add-on.
Readme
@dbx-tools/shared-teams
Browser-safe Adaptive Card and Bot Framework activity schemas (plus inferred types) for the Teams add-on.
Import this package when a UI, Mastra tool schema, server route, or test needs
to validate the same Adaptive Card payloads that
@dbx-tools/teams builds and
@dbx-tools/ui-teams renders.
Key features:
- High-level
CardSpeccontract - the small, model-friendly vocabulary a model drafts (title, subtitle, text, facts, link actions) instead of hand-authoring raw Adaptive Card JSON. AdaptiveCardenvelope schema for the compiled Adaptive Card 1.5 document theadaptivecardsrenderer consumes and Teams accepts.CardResultschema for the build response returned to a model or a browser.Activitycontract for the conversation endpoint - the Bot Framework envelope a Teams channel exchanges, withCardAttachmenttagging a card asapplication/vnd.microsoft.card.adaptive, plus thetoCardAttachment/cardsOfhelpers both sides use so attachments are wrapped and read identically. Unknown activity fields are preserved rather than stripped, since a real channel sends far more than this reads.- Model/tool-friendly schemas that avoid JSON Schema constraints known to cause
problems with some serving endpoints (no array
minItems).
Validate A Drafted Card
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 pins the envelope every consumer relies on (type,
$schema, version, body); the builder in @dbx-tools/teams owns the exact
element shapes inside body / actions.
Modules
card-cardFactSchema,cardActionSchema,cardSpecSchema,adaptiveCardSchema,cardResultSchema, theADAPTIVE_CARD_VERSION/ADAPTIVE_CARD_SCHEMA_URLconstants, and flat inferred types:CardFact,CardAction,CardSpec,AdaptiveCard, andCardResult.activity-activitySchema,activityRequestSchema,activityResponseSchema,cardAttachmentSchema,channelAccountSchema,conversationAccountSchema, theADAPTIVE_CARD_CONTENT_TYPE/ACTIVITY_TYPESconstants, thetoCardAttachment/cardsOfhelpers, and theActivity,ActivityRequest,ActivityResponse,CardAttachment,ChannelAccount,ConversationAccount, andActivityTypetypes.
The schemas intentionally avoid array .min() constraints so they can be reused
as model/tool JSON schemas for serving endpoints that reject minItems.