@stambha/transform
v0.3.5
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. Discordeno-style desired properties for memory-conscious bots.
Part of the @stambha monorepo · GitHub
Install
npm install @stambha/transform @stambha/coreRequires Node.js 20+.
Quick start
Native shapes (recommended)
Define interactions with transport-neutral types:
import type { StambhaMessage, StambhaSlashInteraction } from "@stambha/transform";
const message: StambhaMessage = {
id: "1",
content: "!ping",
channelId: "c1",
guildId: "g1",
author: { id: "u1", bot: false },
};Build REST bodies
import { channelMessageBody, interactionReplyBody } from "@stambha/transform";
await restPort.request({
method: "POST",
route: `/channels/${channelId}/messages`,
body: channelMessageBody({ content: "Hello!" }),
});Split-tier context builders
import {
scoutContextFromStambhaMessage,
commandContextFromStambhaSlashViaRest,
} from "@stambha/transform";Adapters (optional)
Migrating from another library? Use adapters — they are not required for the native stack.
| Adapter | Exports |
|---------|---------|
| discord.js | messageFromDiscordJs, slashInteractionFromDiscordJs, … |
| Discordeno | messageFromDiscordeno, defaultDiscordenoDesiredProperties, … |
Key exports
| Export | Purpose |
|--------|---------|
| StambhaMessage, StambhaUser, StambhaSlashInteraction | Core shapes |
| channelMessageBody, interactionReplyBody | REST payloads |
| scoutContextFromStambhaMessage | Scout routing |
| 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