import { Applog, ApplogValue, DatalogQueryPattern, EntityID, SearchContext } from '../applog/datom-types.ts'; import { Thread } from '../thread/basic.ts'; import { ThreadOnlyCurrent } from '../thread/filters.ts'; import { MappedThread } from '../thread/mapped.ts'; import { SubscribableArrayImpl, SubscribableImpl } from './subscribable.ts'; import { LiveQueryResult, QueryNode, QueryResult } from './types.ts'; /** * Keep only the latest logs for each en&at (= last write wins) */ export declare const lastWriteWins: (thread: Thread, { inverseToOnlyReturnFirstLogs, tolerateAlreadyFiltered }?: { inverseToOnlyReturnFirstLogs?: boolean; tolerateAlreadyFiltered?: boolean; }) => ThreadOnlyCurrent; /** * Remove all applogs for entities that have an applog `{ at: 'isDeleted' | 'relation/isDeleted' | 'block/isDeleted', vl: true }`. * * Emits synthetic `removed` events for the entity's pre-existing applogs when an * entity becomes deleted (and synthetic `added` events for un-deletion). * * Un-deletion: canonical input is appending `{ at: 'isDeleted', vl: false }`. Requires * `lastWriteWins` upstream — without it, the `vl: true` log isn't superseded so we * can't observe a transition. Soft-warned at runtime. */ export declare const withoutDeleted: (thread: Thread) => MappedThread; /** * One-off query — returns a plain snapshot. No subscriptions, no stale-data risk. */ export declare const query: (threadOrLogs: Thread | Applog[], patternOrPatterns: DatalogQueryPattern | DatalogQueryPattern[], startVariables?: SearchContext, opts?: { debug?: boolean; }) => QueryResult; /** * One-off query step — pure filtering via makeFilter, no subscriptions. */ export declare function queryStepOnce(thread: Thread, prevNodes: readonly QueryNode[] | null, pattern: DatalogQueryPattern, opts?: { debug?: boolean; }): QueryResult; /** * Live query — eagerly activated, always up-to-date. * Returns LiveQueryResult with subscribe + dispose. */ export declare const liveQuery: (threadOrLogs: Thread | Applog[], patternOrPatterns: DatalogQueryPattern | DatalogQueryPattern[], startVariables?: SearchContext, opts?: { debug?: boolean; }) => LiveQueryResult; export declare const liveQueryStep: (thread: Thread, nodeSet: LiveQueryResult | null, pattern: DatalogQueryPattern, opts?: { debug?: boolean; }) => LiveQueryResult; export declare const queryNot: (thread: Thread, startNodes: QueryResult, patternOrPatterns: DatalogQueryPattern | DatalogQueryPattern[], opts?: { debug?: boolean; }) => QueryResult; /** Live variant: queryNot with incremental updates. * - Thread additions: O(new_applogs × included_nodes) — only checks new applogs * - Thread removals/resets: full recompute (rare for append-mostly logs) * - Upstream node additions: O(new_nodes × applogs) * - Upstream node removals: removed from output */ export declare const liveQueryNot: (thread: Thread, upstream: LiveQueryResult, patternOrPatterns: DatalogQueryPattern | DatalogQueryPattern[], opts?: { debug?: boolean; }) => LiveQueryResult; /** One-off: filter thread by pattern, map to values. Returns plain array. */ export declare const filterAndMap: (thread: Thread, pattern: DatalogQueryPattern, mapper: (keyof Applog) | (Partial<{ [key in keyof Applog]: string; }>) | ((applog: Applog) => R)) => R[]; /** Live variant: returns SubscribableArray that updates when thread changes. */ export declare const liveFilterAndMap: (thread: Thread, pattern: DatalogQueryPattern, mapper: (keyof Applog) | (Partial<{ [key in keyof Applog]: string; }>) | ((applog: Applog) => R)) => SubscribableArrayImpl; /** One-off: query and map results. Returns plain array. */ export declare const queryAndMap: (threadOrLogs: Thread | Applog[], patternOrPatterns: Parameters[1], mapDef: string | (Partial<{ [key in keyof SearchContext]: string; }>) | ((record: SearchContext) => R), variables?: SearchContext) => any[]; /** Live variant: query and map results, returns SubscribableArray that updates reactively. */ export declare const liveQueryAndMap: (thread: Thread, patternOrPatterns: Parameters[1], mapDef: string | (Partial<{ [key in keyof SearchContext]: string; }>) | ((record: SearchContext) => R)) => SubscribableArrayImpl; /** One-off: query entity attributes. Returns Record or null. Requires current-state thread (LWW). */ export declare const queryEntity: (thread: Thread, name: string, entityID: EntityID, attributes: readonly string[]) => { [k: string]: import("../applog.ts").JsonValue; }; /** Live variant: returns Subscribable that updates when entity attributes change. Requires current-state thread (LWW). */ export declare const liveQueryEntity: (thread: Thread, name: string, entityID: EntityID, attributes: readonly string[]) => SubscribableImpl>; /** Live single-attribute query. Requires current-state thread (LWW). Returns Subscribable. */ export declare const liveEntityAt: (thread: Thread, entityID: EntityID, at: string) => SubscribableImpl; export declare const agentsOfThread: (thread: Thread) => Map; export declare const entityOverlap: (threadA: Thread, threadB: Thread) => string[]; export declare const entityOverlapMap: (threadA: Thread, threadB: Thread, threadAName?: string, threadBName?: string) => void; export declare const entityOverlapCount: (threadA: Thread, threadB: Thread) => number; /** Live variant: entity overlap count as Subscribable. */ export declare const liveEntityOverlapCount: (threadA: Thread, threadB: Thread) => SubscribableImpl; export declare const querySingle: (threadOrLogs: Thread | Applog[], patternOrPatterns: Parameters[1], variables?: SearchContext) => Applog; export declare const querySingleAndMap: ))>(threadOrLogs: Thread | Applog[], patternOrPatterns: Parameters[1], mapDef: MAP, variables?: SearchContext) => any; /** Live variant: querySingle returning Subscribable. */ export declare const liveQuerySingle: (thread: Thread, patternOrPatterns: Parameters[1]) => SubscribableImpl; /** Live variant: querySingleAndMap returning Subscribable. */ export declare const liveQuerySingleAndMap: ))>(thread: Thread, patternOrPatterns: Parameters[1], mapDef: MAP) => SubscribableImpl; /** Create a single-applog mapper function from a mapDef */ export declare function makeApplogMapper(mapDef: (keyof Applog) | (Partial<{ [key in keyof Applog]: string; }>) | ((applog: Applog) => R)): (applog: Applog) => R; /** Map an array of applogs using a mapDef */ export declare function mapApplogsWith(applogs: readonly Applog[], mapDef: (keyof Applog) | (Partial<{ [key in keyof Applog]: string; }>) | ((applog: Applog) => R)): R[]; export declare const mapThreadWith: (thread: Thread, mapDef: (keyof Applog) | (Partial<{ [key in keyof Applog]: string; }>) | ((applog: Applog) => R)) => R[]; export declare const mapQueryResultWith: (queryResult: QueryResult, mapDef: string | (Partial<{ [key in keyof SearchContext]: string; }>) | ((record: SearchContext) => R)) => any[]; /** * Map Applog to custom named record, e.g.: * { en: 'movieID', vl: 'movieName' } * will map the applog to { movieID: .., movieName: .. } */ export declare function createObjMapper(applogFieldMap: Partial<{ [key in FROM]: TO; }>): (applog: { [key_1 in FROM]: any; }) => Partial<{ [key in TO]: import("../applog.ts").JsonValue; }>; export declare function startsWith(str: string): (value: any) => any; export declare function prefixAttrs(prefix: string, attrs: readonly string[]): string[]; export declare function prefixAt(prefix: string, attr: string): string; /** Inverse of prefixAt — strips everything up to and including the first `/` */ export declare function stripAtPrefix(attr: string): string; /** Create a key mapper from an explicit attribute→key record */ export declare function mapAttributes(mapping: Record): (attr: A) => string; /** Resolve key mapping options to a concrete mapper function */ export declare function resolveKeyMapper(opts?: { stripAtPrefix?: true | string; mapKeys?: (attr: string) => string; }): (attr: string) => string; export declare function threadFromMaybeArray(threadOrLogs: Thread | Applog[], name?: string): Thread; export declare function withTimeout(timeoutMilliseconds: number, func: () => R): R; export declare function throwOnTimeout(): void; //# sourceMappingURL=basic.d.ts.map