/** * Genie space metadata helpers. * * Fetches a Genie space's definition (including the opt-in `serialized_space` * blob) and extracts the curated starter questions an author configured on the * space. The typed SDK `client.genie.getSpace` only returns the * directory-listing surface (`title` / `description` / `warehouse_id`); the * sample questions live inside `serialized_space`, which the REST API returns * only when `include_serialized_space=true`. We hit that endpoint through the * workspace client's raw `apiClient` since the typed request shape has no flag * for it. * * The serialized blob is also more privileged than the listing surface: the * workspace API requires `Can Edit` on the space to return it, while `Can Run` * is enough for title / description. A caller that only holds `Can Run` - an * app service principal granted just enough to ask questions is the common case * - would otherwise lose the whole space lookup to a `PERMISSION_DENIED` it * cannot act on, so the fetch degrades to the unserialized request instead of * failing (see {@link getGenieSpace}). * * @module */ import { type WorkspaceClient } from "@databricks/appkit"; import { databricks } from "@dbx-tools/appkit"; import { type GenieSpace } from "@dbx-tools/shared-genie"; /** Options for {@link getGenieSpace}. */ export interface GetGenieSpaceOptions { /** * Explicit `WorkspaceClient`. Defaults to `createWorkspaceClient()` * (env-var auth). Server callers should pass their OBO-scoped client so the * lookup runs as the user. */ workspaceClient?: WorkspaceClient; /** * Request the `serialized_space` blob (catalogs, tables, sample questions, * prompts). Defaults to `true` - the only reason to skip it is when the * caller just needs title / description and wants the smaller payload. * * Requesting it is best-effort: the blob needs `Can Edit` on the space, so a * caller without it gets the unserialized space back rather than an error, * and {@link genieSampleQuestions} then reports no suggestions. */ serialized?: boolean; /** * External cancellation. Accepts a WHATWG `AbortSignal` or a fully-built SDK * `Context` (see `databricks.ContextLike`). */ context?: databricks.ContextLike; } /** * Fetch a Genie space by id, optionally including its serialized definition. * Hits `GET /api/2.0/genie/spaces/` with `include_serialized_space=true` * through the raw `apiClient`, then validates the response against * {@link GenieSpaceSchema} (unknown fields like `etag` / * `parent_path` are stripped). * * When the serialized request is rejected for lack of permission (`403`, or a * `PERMISSION_DENIED` / `Can Edit` message - the workspace API gates the blob * behind `Can Edit`), it retries once without the flag so the caller still gets * the space. Any other failure, and a retry that fails too, is rethrown: a * cancelled request or a missing space must not look like an unserialized * space. */ export declare function getGenieSpace(spaceId: string, options?: GetGenieSpaceOptions): Promise; /** * Extract the curated starter questions an author configured on a Genie space. * Reads `serialized_space -> config.sample_questions[*].question`. Returns `[]` * when the space carries no serialized blob, the blob is unparseable, or no * sample questions are configured - so a missing or misconfigured space * degrades to "no suggestions" rather than throwing. Order is preserved (the * author's ordering) and duplicates are dropped. */ export declare function genieSampleQuestions(space: GenieSpace): string[];