import { type SQLWrapper } from 'drizzle-orm'; import { type SQL } from 'drizzle-orm/sql/sql'; export type MotherDuckAccessTokenRow = { token_name: string; token_type: string; created_ts: Date | string; expire_at: Date | string | null; }; export interface MotherDuckAccessTokenOptions { activeOnly?: boolean; asOf?: string | SQLWrapper; } export type MotherDuckRequiredResource = { name: string | null; alias: string | null; url: string | null; id: string | null; resource_type: string | null; }; export type MotherDuckDiveStatus = 'draft' | 'ready' | 'endorsed' | 'archived'; export type MotherDuckDiveSummaryRow = { id: string; title: string; description: string | null; owner_id: string; current_version: number; created_at: Date | string; updated_at: Date | string; owner_name: string; /** One of MotherDuckDiveStatus on current MotherDuck releases. */ status?: MotherDuckDiveStatus | (string & {}) | null; status_changed_at?: Date | string | null; status_set_by?: string | null; status_applies_to_version?: number | null; required_resources?: MotherDuckRequiredResource[] | null; }; export type MotherDuckDiveDetailRow = MotherDuckDiveSummaryRow & { version_id: string; version_storage_url: string; version_description: string | null; version_created_at: Date | string; version_api_version: number; content: string; version_required_resources?: MotherDuckRequiredResource[] | null; }; export type MotherDuckDiveCreateRow = Omit; export type MotherDuckDiveVersionSummaryRow = { id: string; version: number; storage_url: string; description: string | null; created_at: Date | string; api_version: number; required_resources?: MotherDuckRequiredResource[] | null; }; export type MotherDuckDiveVersionDetailRow = MotherDuckDiveVersionSummaryRow & { content: string; }; export type MotherDuckFileRow = { name: string; type: 'file' | 'folder'; size: number | bigint | null; last_modified: Date | string | null; }; export type MotherDuckDiveDeleteRow = { success: boolean; }; export type MotherDuckFlightSummaryRow = { flight_id: string; flight_name: string; schedule_cron: string | null; schedule_status: string | null; status: string; current_version: number; created_at: Date | string; updated_at: Date | string; owner_name?: string | null; }; /** * Flight sizes. Each plan offers a subset and picks a default when none is * given. MotherDuck rejects a size the plan does not offer. */ export type MotherDuckFlightInstanceType = 'F4' | 'F8' | 'F16' | 'F32'; export type MotherDuckFlightVersionRow = { version_id: string; flight_id: string; flight_version: number; created_at: Date | string; access_token_name: string; flight_secret_names: string[]; config: Record | Map | null; source_code: string; requirements_txt: string | null; max_runtime_sec?: number; /** Returned by MotherDuck clients from 1.5.5 on. */ instance_type?: MotherDuckFlightInstanceType | (string & {}) | null; }; export type MotherDuckFlightRunRow = { run_id: string; flight_id: string; flight_name: string; flight_version: number; config: Record | Map | null; run_number: number | bigint; is_scheduled: boolean; status: string; created_at: Date | string; started_at: Date | string | null; ended_at: Date | string | null; scheduled_at: Date | string | null; cancelled_at: Date | string | null; exit_code: number | null; /** * The user who started the run. NULL for scheduled runs and for runs from * before MotherDuck recorded it. Returned by MotherDuck clients from 1.5.6. */ started_by_id?: string | null; /** Username of `started_by_id`. NULL once that user no longer exists. */ started_by_name?: string | null; }; export type MotherDuckFlightLogLineRow = { line_number: number | bigint | null; reported_at: Date | string | null; line: string | null; }; /** * @deprecated Flight logs are returned one line per row. Use * MotherDuckFlightLogLineRow. */ export type MotherDuckFlightLogsRow = { logs: string; }; export type MotherDuckFlightDeleteRow = { deleted_count: number | bigint; }; export type MotherDuckFlightCancelRunRow = { canceled_count: number | bigint; }; /** @deprecated Use MotherDuckFlightSummaryRow. */ export type MotherDuckJobSummaryRow = { job_id: string; job_name: string; schedule_cron: string | null; schedule_status: string | null; status: string; current_version: number; created_at: Date | string; updated_at: Date | string; }; /** @deprecated Use MotherDuckFlightVersionRow. */ export type MotherDuckJobVersionRow = { version_id: string; job_id: string; version: number; created_at: Date | string; md_token_name: string; md_secret_names: string[]; config: Record | Map | null; source_code: string; requirements_txt: string | null; }; /** @deprecated Use MotherDuckFlightRunRow. */ export type MotherDuckJobRunRow = { run_id: string; job_id: string; job_name: string; job_version: number; run_number: number | bigint; is_scheduled: boolean; status: string; created_at: Date | string; started_at: Date | string | null; ended_at: Date | string | null; scheduled_at: Date | string | null; cancelled_at: Date | string | null; exit_code: number | null; }; /** @deprecated Use MotherDuckFlightLogsRow. */ export type MotherDuckJobRunLogsRow = { logs: string; }; /** @deprecated Use MotherDuckFlightDeleteRow. */ export type MotherDuckJobDeleteRow = { deleted_count: number | bigint; }; /** @deprecated Use MotherDuckFlightCancelRunRow. */ export type MotherDuckJobCancelRunRow = { canceled_count: number | bigint; }; export interface MotherDuckPaginationOptions { limit?: number | SQLWrapper; offset?: number | SQLWrapper; } export interface MotherDuckListFlightsOptions extends MotherDuckPaginationOptions { /** Only list Flights the current user owns. */ ownerOnly?: boolean | SQLWrapper; } export interface MotherDuckFlightLogOptions extends MotherDuckPaginationOptions { order?: 'asc' | 'desc' | SQLWrapper; } export interface MotherDuckListDivesOptions extends MotherDuckPaginationOptions { includeOrgShares?: boolean | SQLWrapper; } /** A share or database a Dive reads from, as `md_create_dive` accepts it. */ export interface MotherDuckDiveResourceInput { url: string; alias?: string | null; } export interface MotherDuckCreateDiveOptions { title: string | SQLWrapper; content: string | SQLWrapper; description?: string | SQLWrapper | null; apiVersion?: number | SQLWrapper; requiredResources?: readonly MotherDuckDiveResourceInput[] | SQLWrapper; } export interface MotherDuckUpdateDiveMetadataOptions { id: string | SQLWrapper; title?: string | SQLWrapper | null; description?: string | SQLWrapper | null; } export interface MotherDuckUpdateDiveContentOptions { id: string | SQLWrapper; content: string | SQLWrapper; description?: string | SQLWrapper | null; apiVersion?: number | SQLWrapper; requiredResources?: readonly MotherDuckDiveResourceInput[] | SQLWrapper; } export interface MotherDuckUpdateDiveStatusOptions { id: string | SQLWrapper; status: MotherDuckDiveStatus | SQLWrapper; /** The Dive version the status applies to. */ version?: number | SQLWrapper; } export interface MotherDuckCreateFlightOptions { name: string | SQLWrapper; accessTokenName?: string | SQLWrapper; sourceCode: string | SQLWrapper; flightSecretNames?: readonly (string | null)[] | SQLWrapper | null; scheduleCron?: string | SQLWrapper | null; config?: Record | SQLWrapper | null; requirementsTxt?: string | SQLWrapper | null; maxRuntimeSec?: number | SQLWrapper; instanceType?: MotherDuckFlightInstanceType | SQLWrapper; } export interface MotherDuckUpdateFlightOptions { flightId: string | SQLWrapper; name?: string | SQLWrapper | null; scheduleCron?: string | SQLWrapper | null; config?: Record | SQLWrapper | null; sourceCode?: string | SQLWrapper | null; requirementsTxt?: string | SQLWrapper | null; accessTokenName?: string | SQLWrapper | null; flightSecretNames?: readonly (string | null)[] | SQLWrapper | null; maxRuntimeSec?: number | SQLWrapper; /** A different size creates a new Flight version. */ instanceType?: MotherDuckFlightInstanceType | SQLWrapper; } export interface MotherDuckRunFlightOptions { config?: Record | SQLWrapper | null; } /** @deprecated Use MotherDuckCreateFlightOptions. */ export interface MotherDuckCreateJobOptions { name: string | SQLWrapper; mdTokenName: string | SQLWrapper; sourceCode: string | SQLWrapper; mdSecretNames?: readonly (string | null)[] | SQLWrapper | null; scheduleCron?: string | SQLWrapper | null; config?: Record | SQLWrapper | null; requirementsTxt?: string | SQLWrapper | null; maxRuntimeSec?: number | SQLWrapper; } /** @deprecated Use MotherDuckUpdateFlightOptions. */ export interface MotherDuckUpdateJobOptions { jobId: string | SQLWrapper; name?: string | SQLWrapper | null; scheduleCron?: string | SQLWrapper | null; config?: Record | SQLWrapper | null; sourceCode?: string | SQLWrapper | null; requirementsTxt?: string | SQLWrapper | null; mdTokenName?: string | SQLWrapper | null; mdSecretNames?: readonly (string | null)[] | SQLWrapper | null; maxRuntimeSec?: number | SQLWrapper; } export type MotherDuckRunMode = 'auto' | 'local' | 'remote'; type MotherDuckSqlArgument = SQLWrapper | string | number | bigint | boolean | readonly unknown[] | null; export interface MotherDuckTableFunctionOptions { mdRun?: MotherDuckRunMode; named?: Record; } declare const motherDuckTableFunctionNameList: readonly ["read_parquet", "parquet_scan", "parquet_schema", "parquet_metadata", "parquet_file_metadata", "parquet_kv_metadata", "parquet_bloom_probe", "parquet_full_metadata", "read_csv", "read_csv_auto", "sniff_csv", "read_json", "read_json_auto", "read_ndjson", "read_ndjson_auto", "read_json_objects", "read_json_objects_auto", "read_ndjson_objects", "read_text", "read_blob", "read_duckdb", "read_avro", "glob", "dbgen", "dsdgen", "delta_scan", "delta_list_files", "iceberg_snapshots", "iceberg_metadata", "iceberg_scan", "iceberg_partition_stats", "iceberg_column_stats", "st_read", "st_readosm", "ducklake_snapshots", "ducklake_list_files", "ducklake_table_info", "ducklake_table_insertions", "ducklake_table_deletions", "ducklake_current_snapshot", "ducklake_last_committed_snapshot", "ducklake_merge_adjacent_files", "ducklake_cleanup_old_files", "ducklake_expire_snapshots", "ducklake_set_option", "ducklake_options", "ducklake_add_data_files", "ducklake_delete_orphaned_files", "ducklake_set_commit_message", "ducklake_rewrite_data_files", "ducklake_flush_inlined_data", "ducklake_settings"]; export type MotherDuckTableFunction = (typeof motherDuckTableFunctionNameList)[number]; export declare function mdAccessTokens(options?: MotherDuckAccessTokenOptions): SQL; /** List one level of an `s3://` or `azure://` path with MotherDuck secrets. */ export declare function mdListFiles(path: string | SQLWrapper, options?: { limit?: number | bigint | SQLWrapper; }): SQL; /** The session user's primary email. NULL for service accounts. */ export declare function mdCurrentEmail(): SQL; /** The session's roles, including inherited and preset roles. */ export declare function mdSessionRoles(): SQL; /** * Whether the session holds a role, or any of a list of roles. Matching is * case-insensitive and follows the role hierarchy. */ export declare function mdIsRoleInSession(role: string | readonly string[] | SQLWrapper): SQL; export declare function mdListDives(options?: MotherDuckListDivesOptions): SQL; export declare function mdGetDive(id: string | SQLWrapper): SQL; export declare function mdCreateDive(options: MotherDuckCreateDiveOptions): SQL; export declare function mdUpdateDiveMetadata(options: MotherDuckUpdateDiveMetadataOptions): SQL; export declare function mdUpdateDiveContent(options: MotherDuckUpdateDiveContentOptions): SQL; /** Set a Dive's governance status. Returns the Dive summary row. */ export declare function mdUpdateDiveStatus(options: MotherDuckUpdateDiveStatusOptions): SQL; export declare function mdDeleteDive(id: string | SQLWrapper): SQL; export declare function mdListDiveVersions(id: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL; export declare function mdGetDiveVersion(id: string | SQLWrapper, version: number | SQLWrapper): SQL; export declare function motherDuckTableFunction(name: MotherDuckTableFunction, args?: readonly MotherDuckSqlArgument[], options?: MotherDuckTableFunctionOptions): SQL; export declare const motherDuckReadParquet: (path: MotherDuckSqlArgument, options?: MotherDuckTableFunctionOptions) => SQL; export declare const motherDuckReadCsvAuto: (path: MotherDuckSqlArgument, options?: MotherDuckTableFunctionOptions) => SQL; export declare const motherDuckReadJsonAuto: (path: MotherDuckSqlArgument, options?: MotherDuckTableFunctionOptions) => SQL; /** Flights you hold only `run` access on are not listed. */ export declare function mdListFlights(options?: MotherDuckListFlightsOptions): SQL; /** @deprecated Use mdListFlights. */ export declare function mdFlights(options?: MotherDuckPaginationOptions): SQL; export declare function mdCreateFlight(options: MotherDuckCreateFlightOptions): SQL; export declare function mdGetFlight(flightId: string | SQLWrapper): SQL; export declare function mdUpdateFlight(options: MotherDuckUpdateFlightOptions): SQL; export declare function mdDeleteFlight(flightId: string | SQLWrapper): SQL; /** * Start a run of a Flight you own or hold `run` access on. The run uses the * owner's settings, secrets and token. `config` can only override keys the * Flight already defines. Run access alone does not allow reading the Flight's * runs or logs unless you are an organization admin. */ export declare function mdRunFlight(flightId: string | SQLWrapper, options?: MotherDuckRunFlightOptions): SQL; export declare function mdCancelFlightRun(flightId: string | SQLWrapper, runNumber: number | bigint | SQLWrapper): SQL; export declare function mdListFlightRuns(flightId: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL; export declare function mdGetFlightRun(flightId: string | SQLWrapper, runNumber: number | bigint | SQLWrapper): SQL; /** @deprecated Use mdListFlightRuns. */ export declare function mdFlightRuns(flightId: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL; /** Return the run log as oldest-first line rows. */ export declare function mdGetFlightLogs(flightId: string | SQLWrapper, runNumber: number | bigint | SQLWrapper, options?: MotherDuckFlightLogOptions): SQL; /** * @deprecated Use mdGetFlightLogs for line-oriented log rows. This alias keeps * returning the earlier single-row logs blob. */ export declare function mdFlightLogs(flightId: string | SQLWrapper, runNumber: number | bigint | SQLWrapper, options?: MotherDuckFlightLogOptions): SQL; export declare function mdListFlightVersions(flightId: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL; /** @deprecated Use mdListFlightVersions. */ export declare function mdFlightVersions(flightId: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL; export declare function mdGetFlightVersion(flightId: string | SQLWrapper, versionNumber: number | SQLWrapper): SQL; /** @deprecated Use mdListFlights. */ export declare function mdJobs(options?: MotherDuckPaginationOptions): SQL; /** @deprecated Use mdCreateFlight. */ export declare function mdCreateJob(options: MotherDuckCreateJobOptions): SQL; /** @deprecated Use mdGetFlight. */ export declare function mdGetJob(jobId: string | SQLWrapper): SQL; /** @deprecated Use mdUpdateFlight. */ export declare function mdUpdateJob(options: MotherDuckUpdateJobOptions): SQL; /** @deprecated Use mdDeleteFlight. */ export declare function mdDeleteJob(jobId: string | SQLWrapper): SQL; /** @deprecated Use mdRunFlight. */ export declare function mdRunJob(jobId: string | SQLWrapper): SQL; /** @deprecated Use mdCancelFlightRun. */ export declare function mdCancelJobRun(jobId: string | SQLWrapper, runNumber: number | bigint | SQLWrapper): SQL; /** @deprecated Use mdListFlightRuns. */ export declare function mdJobRuns(jobId: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL; /** * @deprecated Use mdGetFlightLogs for line-oriented log rows. This alias keeps * returning the earlier single-row logs blob. */ export declare function mdJobRunLogs(jobId: string | SQLWrapper, runNumber: number | bigint | SQLWrapper, options?: MotherDuckFlightLogOptions): SQL; /** @deprecated Use mdListFlightVersions. */ export declare function mdJobVersions(jobId: string | SQLWrapper, options?: MotherDuckPaginationOptions): SQL; /** @deprecated Use mdGetFlightVersion. */ export declare function mdGetJobVersion(jobId: string | SQLWrapper, versionNumber: number | SQLWrapper): SQL; export {};