/** * Trellis CMS Client * * Thin HTTP client for reading content collections from a Trellis-compatible store * (currently opencode's /store/* routes). Reads only; writes happen through the * IDE's CMS panel or the agent's `cms` tool. * * @example * import { createCmsClient } from "trellis/cms"; * * const cms = createCmsClient({ url: "http://localhost:4096" }); * * // List published blog posts with author resolved * const posts = await cms.collection("blog_post").list({ * status: "published", * expand: ["author"], * }); * * // Subscribe to live updates (polling for now, SSE later) * const off = cms.collection("blog_post").subscribe((entries) => { * console.log(entries); * }); * * @module trellis/cms */ import type { CmsClientOptions, Collection, Entry, EntrySubscribeOptions, EntrySubscriber, GetOptions, ListOptions, ListSubscribeOptions, ListSubscriber, Unsubscribe, FieldDefinition } from './types.js'; import { type RawEntity, type RawFact } from './internal.js'; export declare class CmsClient { private readonly url; private readonly basePath; private readonly directory?; readonly pollIntervalMs: number; private readonly fetchFn; private readonly apiKey?; private readonly subscriptions; constructor(opts: CmsClientOptions); collection = Record>(key: string): CollectionRef; entry = Record>(id: string): EntryRef; /** List CMS collections (TypeSchema entities marked cms=true). */ collections(): Promise; close(): void; /** * Shared polling subscription. Multiple subscribers to the same key share a * single timer and one HTTP request per poll cycle. New subscribers receive * the most recently fetched value immediately if one is cached. * * @internal */ _share(key: string, fetcher: () => Promise, callback: (value: T) => void, extras?: { equals?: (prev: unknown, next: unknown) => boolean; onError?: (err: unknown) => void; }): Unsubscribe; /** @internal */ _get(path: string): Promise; /** @internal */ _entities(): Promise; _facts(): Promise; /** @internal */ _entryById(id: string, schemaFacts?: RawFact[]): Promise; } export declare class CollectionRef = Record> { private readonly client; readonly key: string; constructor(client: CmsClient, key: string); list(opts?: ListOptions): Promise[]>; get(id: string, opts?: GetOptions): Promise | null>; /** * Subscribe to changes. Currently implemented as polling; a future SSE-backed * upgrade will replace the transport without changing this API. * * Multiple subscribers to the same collection + opts share one polling timer * and one HTTP request per cycle. */ subscribe(callback: ListSubscriber, opts?: ListSubscribeOptions): Unsubscribe; schema(): Promise; } export declare class EntryRef = Record> { private readonly client; readonly id: string; constructor(client: CmsClient, id: string); get(opts?: GetOptions): Promise | null>; subscribe(callback: EntrySubscriber, opts?: EntrySubscribeOptions): Unsubscribe; } export declare function createCmsClient(opts: CmsClientOptions): CmsClient; //# sourceMappingURL=client.d.ts.map