import { Result, ResultAsync } from "neverthrow"; import { z } from "zod"; export declare class DataStoreError extends Error { constructor(...args: ConstructorParameters); } /** * A list containing a combination of namespace ids, and namespace/document id tuples. */ export declare const dataKeysSchema: z.ZodArray]>, z.ZodTuple<[z.ZodString, z.ZodString], null>]>>; /** * A list containing a combination of namespace ids, and namespace/document id tuples. */ export type DataKeys = z.infer; /** * A document represents a single file or resource. * It is a proxy for the underlying file, and provides a simple api for updating the file. * When the document is updated, a copy of the original file is created with the `.original` suffix. */ export declare abstract class Document { protected _id: string; constructor(id: string); get id(): string; /** * Read the document. Should only be used internally. Exposed for testing purposes. * @internal */ abstract _read(): Promise; read(): ResultAsync; /** * Update the document with the given callback. * @param cb A function that takes the current data and returns the new data. */ abstract _update(cb: (data: T) => T | Promise): Promise; update(cb: (data: T) => T | Promise): ResultAsync; /** * Apply a function to each element matching the given jsonpath. */ abstract _apply(pathExpression: string, fn: (x: unknown) => unknown): Promise; apply(pathExpression: string, fn: (x: unknown) => unknown): ResultAsync; abstract _query(pathExpression: string): Promise; query(pathExpression: string): ResultAsync; /** * Close the file handle. */ abstract _close(): Promise; close(): ResultAsync; } /** * A namespace represents a collection of documents for a single source. */ declare class Namespace { #private; constructor(parentDirectory: string, id: string); get id(): string; initialize(): ResultAsync; /** * Returns a ResultAsync that resolves when the document is available, or fails if the document fails to insert. * @param documentId */ waitFor(documentId: string): ResultAsync; _insert(id: string, data: Promise | AsyncIterable): Promise>; insert(id: string, data: Promise | AsyncIterable): ResultAsync, DataStoreError>; /** * Get a document from the namespace. */ document(id: string): Result; /** * Get all documents in the namespace. */ documents(): MapIterator>; } /** * File system abstraction for interacting with content. Used to store content during the fetch process, * and to provide an easy api for transforming and querying written content without needing to load everything into memory. */ export declare class DataStore { #private; constructor(directory: string); /** * Get a namespace from the data store. */ namespace(namespaceId: string): Result; getDocument(namespaceId: string, documentId: string): Result; /** * Create a new namespace in the data store. */ createNamespace(namespaceId: string): ResultAsync; allDocuments(): Iterable; close(): ResultAsync; /** * Clear all namespaces and documents from the data store. * Does not delete any files on disk. * @internal */ _clear(): void; /** * Get lists of documents matching the passed DataKeys grouped by namespace. * @param ids A list containing a combination of namespace ids, and namespace/document id tuples. If not provided, all documents will be matched. */ filter(ids?: DataKeys): Result; }>, DataStoreError>; } export {}; //# sourceMappingURL=data-store.d.ts.map