@weaver-conf/weaver-client
v0.1.0
Published
Configuration client SDK for Weaver
Readme
@weaver-conf/weaver-client
Configuration client SDK for Weaver — typed namespaces, transports, offline persistence, and real-time sync.
Installation
pnpm add @weaver-conf/weaver-clientUsage
import { createWeaverClient, createHttpTransport, defineNamespace } from "@weaver-conf/weaver-client";
import { z } from "zod";
// Define a typed namespace
const theme = defineNamespace("theme", {
mode: z.enum(["light", "dark"]),
accent: z.string(),
});
// Create client with HTTP transport
const client = await createWeaverClient({
transport: createHttpTransport({ baseUrl: "http://localhost:3399" }),
});
// Use typed namespace API
const ns = client.namespace(theme);
const mode = ns.get("mode"); // typed as "light" | "dark" | undefinedAPI
Client
createWeaverClient(options)— Creates a connected client with transport, persistence, and schema validationWeaverClient— Main interface for reading, writing, and subscribing to configuration
Namespaces
defineNamespace(prefix, shape)— Declares a typed configuration namespace with a Zod schemaTypedNamespaceClient— Strongly-typed get/set/onChange for a namespace
Transports
createHttpTransport(options)— HTTP/SSE transport connecting to weaver-servercreateLocalTransport(options)— In-memory transport for testing and offline usewithMiddleware(transport, ...middlewares)— Wraps a transport with lifecycle hooksWeaverTransport— Interface for implementing custom transports
Persistence
createFileSystemPersistence(options)— Node.js file-based offline cachecreateIndexedDbPersistence(options)— Browser IndexedDB offline cache
Utilities
createScopeLoader(options)— Lazy/eager scope resolutioncreateStalenessMonitor(config)— Detects stale configurationcreateWriteQueue()— Batches and deduplicates writesflattenObject(obj)— Flattens nested objects to dot-path keys
License
MIT
