import { type AttachmentRef, type AttachmentStore, type JsonObject } from "@fabric-harness/sdk"; import type { JobsClient } from "@databricks/sdk-jobs/v2"; export type DatabricksJobsClient = Pick; export type DatabricksRunLifeCycleState = "PENDING" | "RUNNING" | "TERMINATING" | "TERMINATED" | "SKIPPED" | "INTERNAL_ERROR" | "BLOCKED" | "WAITING_FOR_RETRY" | "QUEUED" | string; export type DatabricksRunResultState = "SUCCESS" | "FAILED" | "TIMEDOUT" | "CANCELED" | "MAXIMUM_CONCURRENT_RUNS_REACHED" | "EXCLUDED" | "SUCCESS_WITH_FAILURES" | string; export interface DatabricksRunReceipt { runId: number; run_id: number; idempotencyToken: string; submittedAt: string; kind: "job" | "notebook"; numberInJob?: number; } export interface DatabricksRunState { runId: number; lifeCycleState: DatabricksRunLifeCycleState; resultState?: DatabricksRunResultState; stateMessage?: string; runPageUrl?: string; startTime?: number; endTime?: number; tasks?: Array<{ runId: number; taskKey?: string; state?: DatabricksRunState; }>; raw: Record; } export interface DatabricksRunOutput { runId: number; notebookResult?: string; logs?: string; logsTruncated?: boolean; error?: string; metadata: Record; raw: Record; } export interface DatabricksJobsWaitOptions { pollIntervalMs?: number; timeoutMs?: number; signal?: AbortSignal; } export interface RunDatabricksJobInput { jobId: number; idempotencyToken?: string; notebookParams?: JsonObject; pythonParams?: string[]; jarParams?: string[]; } export interface SubmitDatabricksNotebookInput { notebookPath: string; existingClusterId?: string; baseParameters?: JsonObject; runName?: string; idempotencyToken?: string; } export declare class DatabricksRunTimeoutError extends Error { readonly runId: number; constructor(runId: number, timeoutMs: number); } /** Raised before the Jobs API is called when a run target falls outside the configured bound. */ export declare class DatabricksRunNotAllowedError extends Error { constructor(message: string); } /** * Bound for triggering existing jobs. Ids, not names: the narrow run client cannot resolve names, * and call-time resolution would be a TOCTOU hole. `allowAnyJobId` is the explicit opt-out. */ export type DatabricksJobRunPolicy = { allowedJobIds: number[]; allowAnyJobId?: never; } | { allowAnyJobId: true; allowedJobIds?: never; }; /** Bound for one-off notebook submission. `allowAnyNotebookPath` is the explicit opt-out. */ export type DatabricksNotebookRunPolicy = { /** Exact workspace notebook paths. */ allowedNotebookPaths: string[]; /** Workspace subtree prefixes; matched on segment boundaries only. */ allowedNotebookPathPrefixes?: string[]; allowAnyNotebookPath?: never; } | { allowedNotebookPaths?: string[]; /** Workspace subtree prefixes; matched on segment boundaries only. */ allowedNotebookPathPrefixes: string[]; allowAnyNotebookPath?: never; } | { allowAnyNotebookPath: true; allowedNotebookPaths?: never; allowedNotebookPathPrefixes?: never; }; export interface DatabricksJobsOptions { runPolicy?: DatabricksJobRunPolicy; notebookPolicy?: DatabricksNotebookRunPolicy; } export declare function validateDatabricksJobRunPolicy(policy: DatabricksJobRunPolicy): void; export declare function validateDatabricksNotebookRunPolicy(policy: DatabricksNotebookRunPolicy): void; export declare class DatabricksJobs { private readonly client; private readonly runPolicy; private readonly notebookPolicy; constructor(client: DatabricksJobsClient, options?: DatabricksJobsOptions); runJob(input: RunDatabricksJobInput): Promise; submitNotebook(input: SubmitDatabricksNotebookInput): Promise; get(runId: number): Promise; wait(runId: number, options?: DatabricksJobsWaitOptions): Promise; cancel(runId: number): Promise; getOutput(runId: number): Promise; getOutputs(runId: number): Promise; exportOutput(runId: number, store: AttachmentStore, scope: string): Promise; /** Bound checked before `runNow`, so an out-of-policy id never reaches the workspace. */ private assertJobAllowed; /** Bound checked before `submitRun`, so an out-of-policy notebook is never executed. */ private assertNotebookAllowed; } export declare function databricksJobs(client: DatabricksJobsClient, options?: DatabricksJobsOptions): DatabricksJobs; //# sourceMappingURL=jobs.d.ts.map