/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ import { type UseQueryResult } from '@tanstack/react-query'; import type { RequestOptions } from '@elaraai/e3-api-client'; import { type EastTypeValue } from '@elaraai/east'; import type { PlatformFunction } from '@elaraai/east/internal'; import type { QueryOverrides } from './types.js'; export interface UseDatasetValueOptions { requestOptions?: RequestOptions; queryOverrides?: QueryOverrides; /** Set false to skip the fetch (e.g. when oversized). Defaults to true. */ enabled?: boolean; /** * Hash of the current dataset version. Used as part of the query key so * the cached value invalidates when the underlying data changes. Pass * `null` if not yet known — the fetch is gated on it being non-null. */ hash?: string | null; /** * Platform implementations passed to `decodeBeast2For`. Closures inside * the decoded value (callbacks, etc) close over these. Defaults to the * global Data/State/Overlay impls. Pass a manifest-scoped variant for * per-subtree read/write validation. */ platforms?: PlatformFunction[]; /** East type to decode against. Required. */ type: EastTypeValue; } export interface DatasetValueResult { decoded: unknown; sizeBytes: number; /** The content hash of the value read, as the response names it. */ hash: string | null; } /** * Fetch + decode a dataset value. Caller is responsible for size gating. * * @remarks * The value is read as the dataset holds it now, which is not always the * value of the `hash` asked for: the dataset may have moved on since its * status named that hash. A value is cached under the hash its response names, * and the status is fetched again, so a reader moves to the value it got; an * entry that holds another hash's value is never shown as this hash's. */ export declare function useDatasetValue(apiUrl: string, repo: string, workspace: string | null, datasetPath: string | null, options: UseDatasetValueOptions): UseQueryResult; /** * Downloads a dataset's value: its beast2 bytes, which the browser saves as * `.beast2`, the path's dots as underscores. What a preview's Download * does, for a host that draws Download itself (#1120). * * @param apiUrl - The e3 API's base URL * @param repo - The repository * @param workspace - The workspace * @param path - The dataset's dotted path, e.g. `"inputs.rows"` * @param requestOptions - The token, and the fetch the request goes through * @returns Once the browser has the file * * @example * ```tsx * * ``` */ export declare function downloadDataset(apiUrl: string, repo: string, workspace: string, path: string, requestOptions?: RequestOptions): Promise; /** Trigger a binary download of a dataset value: {@link downloadDataset}, once the workspace and path are known. */ export declare function useDatasetDownload(apiUrl: string, repo: string, workspace: string | null, datasetPath: string | null, requestOptions?: RequestOptions): () => Promise; //# sourceMappingURL=useDatasetValue.d.ts.map