Relocate the ~6k-file docs tree from the repo root into plugins/document-navigator/docs/ so the plugin is self-contained and portable. docs/superpowers/ (specs and plans) stays at the repo root. Moved via cp+rm rather than git mv because directory rename() fails with EPERM on this WSL /mnt DrvFs mount; git rename-detection pairs the identical-content files at commit time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
5.4 KiB
5.4 KiB
@suaveplan/slack-client - Typed deterministic Slack client — Slack Web API + incoming-webhook surface, Zod-validated boundaries, OpenTelemetry-instrumented hot paths, injectable Clock/Rng/Logger/FetchLike, stable defineCodes('SLACK', [...]) error registry. Universal: runs unchanged in Bun, Node, and the browser.
Typed, deterministic Slack client — Web API + incoming-webhook surface — with Zod-validated boundaries, OpenTelemetry-instrumented hot paths, injectable Clock / Rng / LoggerLike / FetchLike, and a stable defineCodes("SLACK", […]) error registry.
Universal: runs unchanged in Bun, Node, and the browser.
Documentation tree
- classify —
classify.tsexports two pure mapping functions that fold transport-level failure signals into the stable `SLACK_CODES… - retry-after —
retry-after.tsexports a single pure functionparseRetryAfterMs(response, clock?)that converts an HTTP `Retry-Afte… - slack-api-client —
SlackApiClientis the typed transport for the Slack Web API. It exposes the six methods downstream packages rely on —… - error-codes —
error-codes.tsis the single source of truth for every error the@suaveplan/slack-clientpackage can throw. It regi…- error-codes —
error-codes.tsis the single source of truth for every error the@suaveplan/slack-clientpackage can throw. It regi…
- error-codes —
- fakes —
fake-fetch.tsexportsFakeFetch, the deterministic test double the package's own unit tests use to exercise every t…- fake-fetch —
fake-fetch.tsexportsFakeFetch, the deterministic test double the package's own unit tests use to exercise every t…
- fake-fetch —
- otel —
metrics.tsregisters four OpenTelemetry instruments under the meter name@suaveplan/slack-clientand exports the he…- metrics —
metrics.tsregisters four OpenTelemetry instruments under the meter name@suaveplan/slack-clientand exports the he…
- metrics —
- schemas —
schemas.tsexports the Zod schemas that validate every public option bag and every Slack Web API request payload that…- schemas —
schemas.tsexports the Zod schemas that validate every public option bag and every Slack Web API request payload that…
- schemas —
- webhook —
SlackWebhookis the simpler half of the package — a typed wrapper around Slack's incoming-webhook URLs. Where `SlackA…- slack-webhook —
SlackWebhookis the simpler half of the package — a typed wrapper around Slack's incoming-webhook URLs. Where `SlackA…
- slack-webhook —
Install
bun add @suaveplan/slack-client
Two clients
SlackApiClient— Slack Web API. Token-authenticated. SupportssendMessage,updateMessage,deleteMessage,listChannels,getChannelInfo,listUsers,getStatus.SlackWebhook— Slack incoming webhooks. URL-authenticated. SupportssendandsendText.
Quickstart
import { SlackApiClient, SlackWebhook } from "@suaveplan/slack-client";
const api = new SlackApiClient({ token: process.env["SLACK_TOKEN"]! });
await api.sendMessage({ channel: "C0123", text: "Deploy succeeded." });
const hook = new SlackWebhook({
webhookUrl: "https://hooks.slack.com/services/T/B/X",
});
await hook.sendText("Build broken on main.");
Modules
error-codes—SLACK_CODESregistry + 8 typed error subclasses.types/slack-client— public shapes.schemas/schemas— Zod boundary schemas.client/slack-api-client— Slack Web API client.client/retry-after—Retry-After/x-ratelimit-resetparser.client/classify— HTTP-status + Slack-error string classifier.webhook/slack-webhook— incoming-webhook client.otel/metrics— four OpenTelemetry instruments.fakes/fake-fetch— deterministicFetchLiketest double.
Error codes
All eight reasons land under the SLACK.* namespace:
SLACK.API_ERROR— generic non-ok response from the Slack API.SLACK.AUTH_ERROR— token rejected (HTTP 401/403,invalid_auth,token_revoked,account_inactive).SLACK.RATE_LIMITED— HTTP 429;context.retryAfterMscarries parsed delay.SLACK.CHANNEL_NOT_FOUND— HTTP 404 orchannel_not_found/is_archived/not_in_channel.SLACK.WORKSPACE_NOT_FOUND—team_not_found/no_workspace.SLACK.CONFIG_MISSING— empty/invalid token or webhook URL at construct time.SLACK.WEBHOOK_FAILED— webhook POST returned non-2xx (non-auth).SLACK.TIMEOUT— internaltimeoutMsfired OR callerAbortSignalaborted OR network failure.
OpenTelemetry
Four instruments under meter @suaveplan/slack-client@0.1.0:
slack.requests(counter) —{ method, outcome }slack.errors(counter) —{ method, code }slack.latency_ms(histogram, unitms) —{ method, outcome }slack.webhook_sends(counter) —{ outcome }
License
MIT