/** * FeltDB HTTP Client - Lightweight client for remote FeltDB servers * * Provides a simple interface for connecting to and querying remote FeltDB instances. * For applications that only need HTTP access without the full core framework. */ import type { FeltDBProposalEvent, FeltDBProposalPreviewArtifact, FeltDBProposalRecord, ProposalReadiness, ProposalStatus } from './proposal.js'; import type { ApplicationUnderstanding } from './application-understanding.js'; import type { ConvergenceResult } from './convergence.js'; import type { ImplementationPlan, Intent, IntentEvent, IntentExecutionResult } from './intent.js'; import type { CanonicalQuery, QueryResult, TransactionResult } from './state-contract.js'; import { type DiscoveryState } from './managed-recovery.js'; export interface ClientOptions { url: string; token: string; applicationId?: string; environment?: string; revisionId?: string; fetch?: typeof globalThis.fetch; } export interface ServiceApiErrorBody { code?: string; error?: string; message?: string; request_id?: string; } export declare class FeltDBServiceApiError extends Error { readonly code: string; readonly status: number; readonly requestId?: string | undefined; constructor(code: string, message: string, status: number, requestId?: string | undefined); } export interface ApplicationInspection { application_id: string; application_name?: string; environment: string; version: number; revision_id: string; contract_hash: string; flow_hash?: string; snapshot: Record; } export interface ApplicationSchemaInspection { application: { application_id: string; environment: string; }; contract_version: number; collections: Array<{ collection: string; fields: Array<{ name: string; type: string; required?: boolean; reference?: string; }>; relationships: unknown[]; }>; } export interface InspectionPage { collection: string; records: T[]; pagination: { limit: number; nextCursor: string | null; }; state_version: number; } export interface InspectionRecord { collection: string; record: T; relationships: unknown[]; } export declare class FeltDBClient { private readonly url; private readonly token; private readonly applicationId?; private readonly environment; private readonly fetcher; private revisionId?; private readonly revisionCache; constructor(options: ClientOptions); private headers; private request; private scoped; private scopeBody; /** * The canonical revision for this client's application. * * Shared with `HttpJsDb` in shape and in reason. This one never poisoned * itself — it only assigned on success — but it did issue one * `GET /v1/application` per concurrent caller, so ten simultaneous queries * meant ten discovery requests against the authority. Sharing the in-flight * lookup fixes that, and using the same primitive means the two clients * cannot drift apart on the semantics that matter. */ private activeRevision; /** Discovery state, for diagnostics. */ revisionState(): DiscoveryState; /** Canonical application Contract Snapshot and schema inspection. */ readonly application: { get: () => Promise; schema: () => Promise; }; /** Bounded, authorized application-state inspection. Cursors remain opaque. */ readonly data: { list: >(collection: string, options?: { limit?: number; cursor?: string; filters?: Record; }) => Promise>; get: >(collection: string, id: string) => Promise>; }; /** Canonical application queries and atomic transactions against the active revision. */ readonly state: { query: >(query: CanonicalQuery) => Promise>; transaction: (transaction: Record) => Promise; version: () => Promise<{ state_version: number; }>; }; /** Public contract-declared application capability invocation. */ readonly capabilities: { run: (name: string, input: unknown) => Promise; }; /** Canonical intent execution and its durable semantic artifacts. */ readonly intents: { execute: (rawRequest: string) => Promise; list: () => Promise<{ intents: Intent[]; }>; get: (id: string) => Promise; understanding: (id: string) => Promise; plan: (id: string) => Promise; proposal: (id: string) => Promise; history: (id: string) => Promise<{ events: IntentEvent[]; }>; }; /** Canonical Proposal lifecycle. Repository application is intentionally absent. */ readonly proposals: { create: (proposal: { base_contract_hash: string; base_flow_hash: string; proposed_flow: string; summary: string; warnings?: string[]; metadata?: Record; parent_proposal_id?: string; expires_at?: string | number; contract_diff?: string[]; source_plan?: { files: Array<{ path: string; action: string; }>; }; understanding?: ApplicationUnderstanding; evidence_hash?: string; understanding_hash?: string; }) => Promise; list: (options?: { status?: ProposalStatus; limit?: number; cursor?: string; }) => Promise<{ proposals: FeltDBProposalRecord[]; pagination: { limit: number; nextCursor: string | null; }; }>; get: (id: string) => Promise; history: (id: string) => Promise<{ events: FeltDBProposalEvent[]; }>; status: (id: string, currentEvidenceHash?: string) => Promise; validate: (id: string, proposedManifest?: unknown) => Promise; createPreview: (id: string) => Promise; preview: (previewId: string) => Promise; previewData: >(previewId: string, collection: string, options?: { limit?: number; cursor?: string; }) => Promise>; simulatePreview: (previewId: string, event: string) => Promise<{ preview_id: string; event: string; status: "simulated"; external_side_effects: "none"; trace: string[]; }>; approve: (id: string, approveAuthorization?: boolean) => Promise; reject: (id: string, reason?: string) => Promise; convergence: (id: string) => Promise<{ convergence: ConvergenceResult[]; }>; recordConvergence: (id: string, result: ConvergenceResult) => Promise; }; } export declare function createClient(options: ClientOptions): FeltDBClient; //# sourceMappingURL=http-client.d.ts.map