import { type ComparisonOperator, type Field } from "./index.js"; export declare const DURABLE: boolean; /** * Run `fn` with a per-logical-task lock-owner store on its AsyncLocalStorage * context. Every await continuation below `fn` then shares that store, so * nested/reentrant acquisitions (put/delete id->line recursion, journal * recovery re-locks, transaction flows) see the SAME store the outermost * acquisition recorded as owner. * * Do NOT replace this with an enterWith() from inside lock(): that store is * created in lock()'s own frame and (a) never propagates back to the caller's * await continuation — every recursion then waits on its OWN lock until the * watchdog (LOCK_WAIT_TIMEOUT) — and (b) can leak into sibling tasks, which * then pass the writer lock as "reentrant" and re-race the Sep-2026 commit * interleave (ENOENT renames, duplicate ids). `run()` gives clean per-op * isolation and correct same-chain propagation. */ export declare const runWithLockStore: (fn: () => T) => T; export declare const lock: (folderPath: string, prefix?: string, ttl?: number) => Promise; /** * Non-blocking lock acquisition (used by the read path and the open-time * recovery sweep). Returns true when the lock was acquired (running crash * recovery for prefix-less locks, exactly like `lock`), false when another * process holds it. A single stale-lock steal (dead same-host owner, or aged * foreign/unknown owner) is attempted so a crashed owner can't wedge readers * behind it forever. */ export declare const tryLock: (folderPath: string, prefix?: string, ttl?: number) => Promise; export declare const unlock: (folderPath: string, prefix?: string) => Promise; export declare const write: (filePath: string, data: any) => Promise; /** * fsync an existing file. Used to flush temp files (written via streams or * shell pipelines) before they are renamed into place. */ export declare const syncFile: (filePath: string) => Promise; /** * fsync a directory so that renames performed inside it are durable. */ export declare const syncDir: (dirPath: string) => Promise; export declare const read: (filePath: string) => Promise; export declare function escapeShellPath(filePath: string): string; /** * Checks if a file or directory exists at the specified path. * * @param path - The path to the file or directory. * @returns A Promise that resolves to true if the file/directory exists, false otherwise. */ export declare const isExists: (path: string) => Promise; /** * Encodes the input using 'secureString' and 'Inison.stringify' functions. * If the input is an array, it is first secured and then joined into a string. * If the input is a single value, it is directly secured. * * @param input - A value or array of values (string, number, boolean, null). * @returns The secured and/or joined string. */ export declare const encode: (input: string | number | boolean | null | (string | number | boolean | null)[]) => string | number | boolean | null; /** * Decodes the input based on the specified field type(s) and an optional secret key. * Handles different formats of input, including strings, numbers, and their array representations. * * @param input - The input to be decoded, can be a string, number, or null. * @param field - Field object config. * @returns Decoded value as a string, number, boolean, or array of these, or null if no fieldType or input is null/empty. */ export declare const decode: (input: string | null | number, field: Field & { databasePath?: string; }) => string | number | boolean | null | undefined | (string | number | null | boolean)[]; export declare function _groupIntoRanges(arr: number[], action?: "p" | "d"): string | any[]; /** * Asynchronously reads and decodes data from a file at specified line numbers. * Decodes each line based on specified field types and an optional secret key. * * @param filePath - Path of the file to be read. * @param lineNumbers - Optional line number(s) to read from the file. If -1, reads the last line. * @param field - Field object config. * @param readWholeFile - Optional Flag to indicate whether to continue reading the file after reaching the limit. * @returns Promise resolving to a tuple: * 1. Record of line numbers and their decoded content or null if no lines are read. * 2. Total count of lines processed. */ export declare function get(filePath: string, lineNumbers?: number | number[], field?: Field & { databasePath?: string; }, readWholeFile?: false): Promise | null>; export declare function get(filePath: string, lineNumbers: undefined | number | number[], field: undefined | (Field & { databasePath?: string; }), readWholeFile: true): Promise<[ Record | null, number ]>; /** * Reads only the requested line numbers of one column file and decodes each * with `field`. Unlike the shell `sed -n` reader this stops as soon as the last * requested line has been seen, so a point lookup never scans the column to * EOF, and it decodes each column independently (no tab-delimited `paste` * alignment to break on values that contain a literal tab). Compression is * handled transparently: `.gz` columns are gunzipped on the fly. * * Every resource (readline, gunzip/source stream, file handle) is released on * both the normal and the early-exit path. */ export declare const getLines: (filePath: string, lineNumbers: number[], field?: Field & { databasePath?: string; }) => Promise>>; /** * Asynchronously replaces specific lines in a file based on the provided replacements map or string. * * @param filePath - Path of the file to modify. * @param replacements - Map of line numbers to replacement values, or a single replacement value for all lines. * Can be a string, number, boolean, null, array of these types, or a Record/Map of line numbers to these types. * @returns Promise * * Note: If the file doesn't exist and replacements is an object, it creates a new file with the specified replacements. */ export declare const replace: (filePath: string, replacements: string | number | boolean | null | (string | number | boolean | null)[] | Record, totalItems?: number) => Promise<(string | null)[]>; /** * Asynchronously appends data to the end of a file. * * @param filePath - Path of the file to append to. * @param data - Data to append. Can be a string, number, or an array of strings/numbers. * @returns Promise. Modifies the file by appending data. * */ export declare const append: (filePath: string, data: string | number | (string | number)[]) => Promise<(string | null)[]>; /** * Asynchronously prepends data to the beginning of a file. * * @param filePath - Path of the file to append to. * @param data - Data to append. Can be a string, number, or an array of strings/numbers. * @returns Promise. Modifies the file by appending data. * */ export declare const prepend: (filePath: string, data: string | number | (string | number)[]) => Promise<(string | null)[]>; /** * Asynchronously removes specified lines from a file. * * @param filePath - Path of the file from which lines are to be removed. * @param linesToDelete - A single line number or an array of line numbers to be deleted. * @returns Promise. Modifies the file by removing specified lines. * * Note: Creates a temporary file during the process and replaces the original file with it after removing lines. */ export declare const remove: (filePath: string, linesToDelete: number | number[]) => Promise<(string | null)[]>; /** * Asynchronously searches a file for lines matching specified criteria, using comparison and logical operators. * * @param filePath - Path of the file to search. * @param operator - Comparison operator(s) for evaluation (e.g., '=', '!=', '>', '<'). * @param comparedAtValue - Value(s) to compare each line against. * @param logicalOperator - Optional logical operator ('and' or 'or') for combining multiple comparisons. * @param field - Field object config. * @param limit - Optional limit on the number of results to return. * @param offset - Optional offset to start returning results from. * @param readWholeFile - Flag to indicate whether to continue reading the file after reaching the limit. * @returns Promise resolving to a tuple: * 1. Record of line numbers and their content that match the criteria or null if none. * 2. The count of found items or processed items based on the 'readWholeFile' flag. * * Note: Decodes each line for comparison and can handle complex queries with multiple conditions. */ export declare const search: (filePath: string, operator: ComparisonOperator | ComparisonOperator[], comparedAtValue: string | number | boolean | null | (string | number | boolean | null)[], logicalOperator?: "and" | "or", searchIn?: Set, field?: Field & { databasePath?: string; }, limit?: number, offset?: number, readWholeFile?: boolean, earlyStop?: boolean, /** * Per-line raw cell overrides (update-log overlay). When a line is present * the overridden raw value is decoded and compared instead of the file's * line, so a search reflects un-compacted `put`s. The native whole-line * grep fast path is bypassed whenever overrides are supplied. */ overrides?: Map) => Promise<[Record | null, number, Set | null]>; export declare const sum: (fp: string, ln?: number | number[], overrides?: Map) => Promise; export declare const avg: (fp: string, ln?: number | number[], overrides?: Map) => Promise; export declare const min: (fp: string, ln?: number | number[], overrides?: Map) => Promise; export declare const max: (fp: string, ln?: number | number[], overrides?: Map) => Promise; export declare const getFileDate: (path: string) => Promise;