/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** Named field-index reads, adapted through the existing pinned paged runtime. */ import { StructType, type EastType, type option } from "@elaraai/east"; import type { PlatformFunction } from "@elaraai/east/internal"; import { type TreePath } from "@elaraai/e3-types"; import { type RecordSliceBatches } from "@elaraai/east-ui-components/platform"; import type { PagedRuntime } from "./paged-runtime.js"; /** * An index's maintenance for one row (#1437): e3's, the function the record's commit runs — given a row's key, the * row before and after, and the patch an update sent, the changes the row makes to the index, by entry, each an op of * the index's own patch or a summary's add. */ export type IndexMaintenance = (key: unknown, held: option, next: option, patch: option) => ReadonlyMap; /** Each listed nested series and summary index's maintenance for one row, by its name; none where the binding lists neither. */ export type IndexMaintenances = option>>; /** * The listed nested series index's fill of a page (#1438): its lean rows, by key, filled with the entries read of it — * a beast2 Array of the index's `{ ik, value }` entries. None where the binding lists none. */ export type NestedFill = option<(rows: ReadonlyMap, items: Uint8Array) => ReadonlyMap>; /** An entries index a binding lists (#1522), as a reader reads it: the Dict field it files, the Dict's key and value types, and its lean rows' index. */ export interface IndexedEntries { /** The Dict field of the rows it files, entry by entry: what the rail names. */ readonly field: string; /** The Dict's key type: each entry's key, the index's own. */ readonly key: EastType; /** The Dict's value type: what each entry carries. */ readonly value: EastType; /** Its lean rows' index, the record's rows by key with the field emptied (e3-types' `entriesRowsName`). */ readonly rows: string; } /** * The reads a paged runtime batches for a binding an indexed runtime built * (#1351): several searches of one of its sources in one request, and the * entries of several runs of one in one — what a record Slice bound over it * reads a plan's searches and its windows through. * * @param binding - The binding: the handle `Data.bindPaged` over a record's indexes returned * @returns Its batched reads, or `undefined` for a handle no indexed runtime built here — one decoded from * elsewhere, whose Slice then reads its searches and runs one at a time */ export declare function recordSliceBatchesOf(binding: object): RecordSliceBatches | undefined; /** * A binding an indexed runtime built, as a reader of its nested series index * finds it by its id (#1438): a Plan's root names the binding its rows are * read through by id alone, its type the Plan's own. */ export interface IndexedBindingRead { /** The record's dataset path. */ readonly path: TreePath; /** The handle: its revision, and each listed nested series and summary index's maintenance for one row. */ readonly handle: { revision(): option; readonly maintenance: IndexMaintenances; }; /** Its batched reads. */ readonly batches: RecordSliceBatches; /** The record's key type. */ readonly key: EastType; /** The record's row type. */ readonly row: EastType; /** The listed nested series index: its name, and its entries' type, `{ ik, value }`; none where the binding lists none. */ readonly nested: { readonly index: string; readonly entry: StructType<{ ik: EastType; value: EastType; }>; } | undefined; /** Each listed entries index, by its name (#1522); empty where the binding lists none. */ readonly entries: ReadonlyMap; /** * Whether a read of the record's own rows by key reads them as the binding's windows hold them (#1596): it joins * them. Beside a nested series index a binding's windows hold lean rows, which a row read whole by key is not. */ readonly readsRows: boolean; /** The record's identity, as a record Slice bound over the binding names it (`sourceId`): what tells two records' bindings apart (#1522). */ readonly recordId: string; /** Asks every read of the record that failed again, at once — a Retry's, as a source of the rail asks (#1522). */ askAgain(): void; } /** * A binding an indexed runtime built, by its id (#1438). * * @param id - The binding's id, as its handle carries it * @returns The binding read; `undefined` for an id no runtime here built */ export declare function indexedBindingOf(id: string): IndexedBindingRead | undefined; /** * The binding a windowed source of its rows reads (#1596): the source's id is * the binding's own, or the binding's with what the source shows of it after — * its unfiltered view ({@link INDEXED_ROWS_SUFFIX}), or a record Slice's * narrowing of it ({@link RECORD_SLICE_DATA_MARK} and the Slice's key), the * marks the sources' builders add. A Slice's key is its author's, and may end * as the unfiltered view's id does: an id that is no binding's unfiltered view * is still read as a Slice's. * * @param id - The source's id, as its handle carries it * @returns The binding read; `undefined` for a source of no binding built here */ export declare function indexedBindingOfSource(id: string): IndexedBindingRead | undefined; /** * Serializable indexed handles backed by PagedRuntime's existing snapshots, * caches, error/retry handling and tracked reads. No second fetch cache lives here. */ export declare class IndexedPagedRuntime { private readonly paged; private readonly handles; private windows; private sources; private entryPrinters; private printedEntries; private entriesBySchema; constructor(paged: Pick); clear(): void; /** * An index's entry key, `(ik=…, k=…)`, as a membership read names it (#1349): * the index key's `.east` text, as the binding's maintained keys print it, * read back as the index key's type, beside the row's key. * * @param schema - The binding's types * @param name - The index * @returns The printer */ private entryPrinter; /** * Some entries' keys, `(ik=…, k=…)`, as a membership read names them (#1349): made once for the entries asked — * the same array whenever a reader asks of them again, every evaluation that reads them while their answer is in * flight among them — so no entry is read and printed again. * * @param schema - The binding's types * @param name - The index * @param entries - The entries asked of * @returns Each entry's key, in order */ private entryTexts; private schema; private defaultIndex; /** An index's metadata in the binding's type (#1432): its row fields' markers and its kind, `{ fields, kind }`. */ private metadataOf; /** The row fields an index is led by, each its marker. */ private fields; /** An index's kind, its metadata's one case (#1432): `plain`, `interval`, `area`, `series`, `summary` or `entries` (#1522). */ private kind; /** * Each entries index a binding lists (#1522), by its name: the Dict field * it files — its metadata's one field — the Dict's key and value types, * from the row's own field, and its lean rows' index. */ private entriesIndexes; /** The entries index whose lean rows an index is (#1522); `undefined` for any other. */ private entriesRowsOf; /** Whether an index is a summary index (#1039): its entries totals, naming no row. */ private isSummary; /** * Whether an index carries its rows (D29): an area index, or a series * index (#1039), whose entries hold the whole row as their projection, so * it is read without a join; and beside a nested series index, every index * but a summary, whose entries hold the lean row (#1435) — the binding * lists none with a value of its own there; and beside an entries index, * every index but a summary and an entries index, whose entries hold the * row with the fields filed entry by entry emptied (#1522). */ private carriesRow; private source; /** A window of a source as a binding's entries, each tagged with the * source that orders it: mapped once per window, so a window read again * keeps its identity. An index that carries its rows gives each entry's * projection as its row, and the binding's projection as its value: the * row itself, or Null beside indexes that carry nothing (D29). A summary * index's entry gives its totals as its value, and names no row (#1039); * a nested series index's its item, totals or subtotal (#1435); an * entries index's the Dict's value, and its lean rows' the lean row as * both (#1522). */ private entriesOf; /** * The reads the paged runtime batches for a binding this runtime built * (#1351): several searches of one of its sources in one request, the * entries of several runs of one in one, the rows of several of the * record's own keys in one (#1039), and another Dict's rows under the keys * some runs of one of its indexes name in one (#1393), each through the * source's own handle, so its channels are the ones the binding's single * reads use. * * @param binding - What the binding reads * @returns Its batched reads */ private batches; private primitives; /** Indexed bind and its serializable primitives, optionally manifest-scoped. */ platform(allowed: ReadonlySet | null): PlatformFunction[]; } //# sourceMappingURL=indexed-paged.d.ts.map