@stambha/transform
v1.3.2
Published
Stambha transform layer — gateway payloads to slim context shapes and REST bodies
Maintainers
Readme
@stambha/transform
Payload normalization — convert gateway events into slim Stambha contexts and build REST request bodies.
Part of the @stambha monorepo · GitHub
Install
npm install @stambha/transform @stambha/coreRequires Node.js 20+. No discord.js or Discordeno dependency.
Quick start (native)
import type { StambhaMessage, StambhaSlashInteraction } from "@stambha/transform";
import { interactionFromDispatch, interactionReplyBody } from "@stambha/transform";
const message: StambhaMessage = {
id: "1",
content: "!ping",
channelId: "c1",
guildId: "g1",
author: { id: "u1", bot: false },
};
await restPort.request({
method: "POST",
route: `/interactions/${id}/${token}/callback`,
body: interactionReplyBody("Hello!"),
});Split-tier context builders
import {
scoutContextFromStambhaMessage,
commandContextFromStambhaSlashViaRest,
} from "@stambha/transform";Use with createNativeGatewayClient + attachStambhaClient — see Gateway.
Key exports
| Export | Purpose |
|--------|---------|
| StambhaMessage, StambhaInteraction, … | Core shapes |
| interactionFromDispatch, messageFromDispatch | Native gateway parsing |
| channelMessageBody, interactionReplyBody | REST payloads |
| commandContextFromStambhaSlashViaRest | Command routing via RestPort |
Related packages
| Package | Role |
|---------|------|
| @stambha/gateway | Emits Stambha* events into the hub |
| @stambha/rest | Sends bodies built here |
| @stambha/core | DesiredProperties, slim contexts |
Development
pnpm --filter @stambha/transform build
pnpm --filter @stambha/transform test