/** * Trellis Client — browser SDK * * Remote-only runtime for browser bundles. It intentionally excludes local * embedded-kernel mode, filesystem config reads, and server tenancy imports. * * @module trellis/client */ import type { SchemaDefinition } from '../core/ontology/types.js'; import type { ResolveSpec } from '../schema/resolve.js'; import type { AuthResult, CreateEntityOptions, EntityData, ListResult, QueryResult, Subscription, SubscriptionCallback, TrellisDbOptions, UploadResult } from './sdk.js'; export type { AuthResult, CreateEntityOptions, EntityData, ListResult, QueryResult, Subscription, SubscriptionCallback, TrellisDbLocalOptions, TrellisDbOptions, TrellisDbRemoteOptions, UploadResult, } from './sdk.js'; export interface SubscribeOptions { /** Entity type name (e.g. `NavSection`) for server `resolve`. */ entityType?: string; resolve?: ResolveSpec; } declare global { interface Window { /** Set by host app when WKWebView drops fetch POST bodies (XHR fallback). */ __TRELLIS_USE_XHR__?: boolean; /** Host patched fetch via Tauri plugin-http — always use fetch, never XHR. */ __TRELLIS_NATIVE_HTTP__?: boolean; } } export declare class TrellisDb { private opts; private _ws; /** In-flight connect — concurrent subscribe() shares one socket open. */ private _wsPromise; private _subCallbacks; constructor(opts: TrellisDbOptions); /** * Browser bundles cannot read `.trellis-db.json`. */ static fromConfig(_dir?: string): Promise; /** * Create a new entity. * Returns the entity ID (generated or caller-supplied via options.id). */ create(type: string, attributes?: Record, links?: Array<{ attribute: string; targetEntityId: string; }>, options?: CreateEntityOptions): Promise; /** * Read an entity by ID. * Returns null if not found. */ read(id: string): Promise; /** * Update an entity's attributes (partial update). */ update(id: string, attributes: Record): Promise; /** * Delete an entity by ID. */ delete(id: string): Promise; /** * List entities of a given type. */ list(type?: string, opts?: { limit?: number; offset?: number; filters?: Record; }): Promise>; /** * Run an EQL-S query string. */ query(eql: string): Promise; /** * Register a user/system-tier ontology schema with a remote Trellis server. */ registerType(schema: SchemaDefinition | { definition: SchemaDefinition; }): Promise; /** * Upload a file to the blob store. * Returns a content-addressed hash. */ upload(data: Uint8Array | ArrayBuffer, contentType?: string): Promise; /** * Download a file by its blob hash. */ getFile(hash: string): Promise; register(email: string, password: string, name?: string): Promise; login(email: string, password: string): Promise; /** * Set the active API key / JWT token for subsequent requests. */ setToken(token: string): void; /** * Subscribe to a live EQL-S query. * Callback is fired immediately with the initial result, then on every update. */ subscribe(eql: string, callback: SubscriptionCallback, opts?: SubscribeOptions): Subscription; /** * Close the WebSocket connection. */ disconnect(): void; /** * Close open client resources. */ close(): void; /** * Tenant isolation, not authorization: when `tenantId` is supplied out-of-band * (not bound to the JWT), the server trusts the query param. Safe for ephemeral * showcase rooms with unguessable ids; real multi-tenant auth must bind the * tenant to the auth token instead. Skipped when the JWT already carries it. */ private _applyTenant; private _fetch; private _ensureWs; } export interface FetchErrorContext { method?: string; path?: string; url?: string; operation?: string; requestBodyBytes?: number; responseBytes?: number; transport?: 'fetch' | 'xhr'; } export declare class FetchError extends Error { status: number; body?: unknown | undefined; readonly context: FetchErrorContext; constructor(status: number, message: string, body?: unknown | undefined, context?: FetchErrorContext); static format(status: number, message: string, ctx: FetchErrorContext): string; toString(): string; } export { clearDevRegistry, getDevRegistry, registerDevRegistry, type FractalShellName, type TrellisDevRegistry, type TrellisFractalDev, } from './dev-registry.js'; //# sourceMappingURL=sdk.browser.d.ts.map