/** * Lazy loader for the SEA (Statement Execution API) native binding. * * Mirrors the load-failure-tolerant pattern of `lib/utils/lz4.ts`: the * `.node` artifact ships via per-platform optional dependencies * (`@databricks/databricks-sql-kernel-`), so its absence must not crash * a Thrift-only consumer of the driver. Callers that actually need * kernel construct a {@link KernelNativeLoader} (or use the process-global * {@link getKernelNative}) which throws a structured error if the binding * could not be loaded. * * M0 publishes a single triple (`linux-x64-gnu`); see * `native/kernel/README.md` for the supported-platform policy. */ import type { Connection as NativeConnection, Statement as NativeStatement, ConnectionOptions as NativeConnectionOptions, ArrowBatch as NativeArrowBatch, ArrowSchema as NativeArrowSchema, ExecuteOptions as NativeExecuteOptions, TypedValueInput as NativeTypedValueInput, NamedTypedValueInput as NativeNamedTypedValueInput, AsyncStatement as NativeAsyncStatement, AsyncResultHandle as NativeAsyncResultHandle, CancellableExecution as NativeCancellableExecution, LogRecord as NativeLogRecord } from '../../native/kernel'; export type KernelConnectionOptions = NativeConnectionOptions; export type KernelArrowBatch = NativeArrowBatch; export type KernelArrowSchema = NativeArrowSchema; export type KernelConnection = NativeConnection; export type KernelStatement = NativeStatement; export type KernelNativeExecuteOptions = NativeExecuteOptions; export type KernelNativeTypedValueInput = NativeTypedValueInput; export type KernelNativeNamedTypedValueInput = NativeNamedTypedValueInput; export type KernelNativeAsyncStatement = NativeAsyncStatement; export type KernelNativeAsyncResultHandle = NativeAsyncResultHandle; export type KernelNativeCancellableExecution = NativeCancellableExecution; export type KernelNativeLogRecord = NativeLogRecord; /** * The full native binding surface, derived from the generated module * so it can never drift from the `.d.ts` contract: when the kernel * adds or renames a free function / class, this type follows * automatically and `defaultRequire`'s cast stays correct. */ export type KernelNativeBinding = typeof import('../../native/kernel'); /** * Loads and caches the kernel native binding. Exposed as a class with an * injectable `load` seam so consumers (e.g. `KernelBackend`) can be unit * tested with a stub binding instead of requiring a real `.node` on the * test machine. Most production code uses the process-global default * via {@link getKernelNative} / {@link tryGetKernelNative}. */ export declare class KernelNativeLoader { private readonly load; private readonly nodeMajor; private cached; private cachedError; /** * @param load injectable module-require seam (stub a binding in tests) * @param nodeMajor injectable Node-major detector. Defaults to reading the * live `process.version`; injected in unit tests so the * load/shape branches are exercised independently of the * runner's actual Node version (the matrix spans 14–20). */ constructor(load?: () => KernelNativeBinding, nodeMajor?: () => number); private tryLoad; /** * Returns the loaded native binding. Throws a structured error if the * binding is unavailable on this platform / Node version. */ get(): KernelNativeBinding; /** * Returns the loaded binding or `undefined` if it could not be * loaded. Use this for capability-detection at startup; use * {@link get} at the point where kernel is actually required. */ tryGet(): KernelNativeBinding | undefined; } /** * Returns the loaded native binding from the process-global loader. * Throws a structured error if the binding is unavailable. */ export declare function getKernelNative(): KernelNativeBinding; /** * Returns the loaded binding from the process-global loader, or * `undefined` if it could not be loaded. */ export declare function tryGetKernelNative(): KernelNativeBinding | undefined;