import { S as Scalar, E as EntityId, J as Json, O as Op, a as EntityRef, c as Value } from './ops.d-D9oT7Y5m.cjs'; interface WhereOp { $gt?: Scalar; $gte?: Scalar; $lt?: Scalar; $lte?: Scalar; $ne?: Scalar; $in?: Scalar[]; $like?: string; } type WhereValue = Scalar | WhereOp; type WhereClause = { and: WhereClause[]; } | { or: WhereClause[]; } | { [field: string]: WhereValue | WhereClause[]; }; interface QueryOpts { where?: WhereClause; order?: Record; limit?: number; offset?: number; /** Full-text search over the row's text fields (FTS5). Tokens are prefix-matched * and AND-combined. Applies as an id filter, so it composes with `where`. */ search?: string; /** * Also report how many rows match, ignoring `limit`/`offset` — the total a * paginated view needs ("page 3 of 12"). Delivered alongside the rows and * recomputed with them, so a subscription's total stays live instead of * needing a separate one-shot `aggregate` that goes stale the moment anything * changes. * * OPT-IN because it is not free: the count is taken over the rows this caller * may actually SEE, so it evaluates view rules across every match rather than * just the returned page. That is the point — an unfiltered count would leak * the size of a result set you are not allowed to read — but it means the cost * scales with matches, not with `limit`. Ask for it on the views that page, * not by default. */ count?: boolean; } /** Aggregation request over a namespace's matching rows (one-shot, not reactive). */ interface AggregateSpec { count?: boolean; sum?: string; avg?: string; min?: string; max?: string; } interface AggregateResult { count?: number; sum?: number; avg?: number; min?: number | string | null; max?: number | string | null; } /** One item in a bounded aggregate batch. */ interface AggregateRequest { ns: string; aggregate: AggregateSpec; opts?: QueryOpts; } /** namespace -> aggregate result */ type AggregateResults = Record; /** A query node: `$` carries options; every other key is a nested relation. */ interface NodeQuery { $?: QueryOpts; [relation: string]: NodeQuery | QueryOpts | undefined; } /** Top-level query: namespace -> node query. */ type InstaQLQuery = Record; type Entity = { id: EntityId; } & Record; type QueryResult = Record; /** Incremental change to one namespace's result set (for `query-diff`). */ interface NamespaceDiff { /** Entities added or whose value changed (full entity). */ changed: Entity[]; /** Ids no longer in the result. */ removed: EntityId[]; /** The new full ordered id list, so the client can reconstruct order. */ order: EntityId[]; } /** Per-namespace match counts for the nodes that asked for `count`, ignoring * their `limit`/`offset`. Absent when no node asked. Counts are taken AFTER * view-rule filtering, so they never reveal rows the reader cannot see. */ type QueryTotals = Record; /** Stable SDK error shared by HTTP and realtime clients. Branch on `code`, not * message text; `status` is present for HTTP failures. */ declare class OdlaError extends Error { readonly code: string; readonly status?: number; readonly detail?: Json; readonly retryable: boolean; readonly requestId?: string; constructor(code: string, message: string, opts?: { status?: number; detail?: Json; retryable?: boolean; requestId?: string; cause?: unknown; }); } /** What a subscriber receives. `totals` is present only for queries whose nodes * asked for `count`; it is a second argument rather than a field on the result * so the plain `(result) => void` callback keeps working untouched. */ type QueryCallback = (result: QueryResult, totals?: QueryTotals) => void; type Attrs = Record; /** * Chainable builder for one entity's mutations. Created via the {@link tx} * proxy (`tx.[id]`), it accumulates ops in `ops`; each method * (`update`, `merge`, `delete`, `retract`, `link`, `unlink`) pushes one `Op` * and returns `this` so calls chain. Pass the chain (or an array of chains) to * `transact`. */ declare class TxChain { private ns; private id; readonly ops: Op[]; constructor(ns: string, id: EntityRef); update(attrs: Attrs): this; merge(attrs: Record): this; delete(): this; /** * Remove the named scalar/json attributes from this entity, returning them to * the absence-of-triple state — the scalar sibling of {@link unlink}. Use it * to CLEAR a value: a typed scalar attribute cannot store `null`, so * `retract(["dueAt"])` is how you unset one. A no-op for attributes already * absent; retracting a required attribute aborts the transaction. */ retract(attrs: string[]): this; link(label: string, target: EntityRef): this; unlink(label: string, target: EntityRef): this; } type TxInput = TxChain | Op | TxInput[]; /** * Flatten a transaction input into the wire `Op[]`. Accepts a {@link TxChain} * (returns its accumulated `ops`), a bare `Op` literal (wrapped in a * single-element array), or an arbitrarily nested array of either, recursing to * produce one flat, ordered op list — the shape sent to the `transact` endpoint. */ declare function flattenTx(input: TxInput): Op[]; type NamespaceProxy = Record; declare const tx: Record; export { type AggregateResult as A, type Entity as E, type InstaQLQuery as I, type NamespaceDiff as N, OdlaError as O, type QueryResult as Q, type TxInput as T, type WhereClause as W, type QueryCallback as a, type QueryOpts as b, TxChain as c, type AggregateSpec as d, type QueryTotals as e, flattenTx as f, type AggregateRequest as g, type WhereOp as h, type WhereValue as i, type AggregateResults as j, type NodeQuery as k, tx as t };