@consciousclouds/activity-client
v0.1.1
Published
ConsciousClouds Activity Client — the product-neutral consumer transport for the Eventing plane's live-activity feed. Wire types (ActivityItem, ActivityRecentResponse), the two thin same-origin BFF wrappers (fetchRecentActivity over /recent, streamActivit
Readme
@consciousclouds/activity-client
The product-neutral consumer transport for the Eventing plane's live-activity feed.
Graduated out of consciousclouds-admin (Stage 9 Wave B) so any enrolled product
can consume the feed without importing admin internals. Three thin layers:
- types — the activity wire types (
ActivityItem,ActivityRecentResponse). - client — the two same-origin BFF wrappers:
fetchRecentActivity(the durable recovery view over<base>/recent) andstreamActivity(the live SSE tail over<base>/stream). Base path defaults to/api/activity; override viabasePath. - hook —
useActivityFeed, the read model: durable recovery seed → live prepend → resume-from-cursor →event_iddedupe, with explicit (never silent) degradation.
SDK-law boundary
Types + thin HTTP wrappers + a framework-thin read model. What stays product-owned:
- The BFF routes (
<base>/recent,<base>/stream) — the server proxy to the Operator Gateway with operator auth. This package never opens a cross-origin call, never carries a gateway URL, never holds a credential. - The enablement flag — deployment config (e.g. a
NEXT_PUBLIC_*env). The product computes it and passesenabled; the hook never reads a framework env.
Usage
import { useActivityFeed } from "@consciousclouds/activity-client";
// A product computes its own flag (here a Next public env) and injects it.
const enabled =
(process.env.NEXT_PUBLIC_ACTIVITY_LIVE ?? "true") !== "false" &&
(process.env.NEXT_PUBLIC_ACTIVITY_LIVE ?? "true") !== "0";
const feed = useActivityFeed({ enabled }); // default basePath: /api/activity
// or point at a product's own proxy routes:
const feed2 = useActivityFeed({ enabled, basePath: "/eno/api/activity" });Design references
eventing-plane-lock§4/§7/§11 — the envelope, the idempotent read model, recovery.docs/design/universal-adoption-doctrine.md— a second product consumes it unchanged.
