mirror of
https://github.com/lancedb/lancedb.git
synced 2026-03-30 12:30:39 +00:00
## Summary - Upgrades `@napi-rs/cli` from v2 to v3, `napi`/`napi-derive` Rust crates to 3.x - Fixes a bug ([napi-rs#1170](https://github.com/napi-rs/napi-rs/issues/1170)) where the CLI failed to locate the built `.node` binary when a custom Cargo target directory is set (via `config.toml`) ## Changes **package.json / CLI**: - `napi.name` → `napi.binaryName`, `napi.triples` → `napi.targets` - Removed `--no-const-enum` flag and fixed output dir arg - `napi universal` → `napi universalize` **Rust API migration**: - `#[napi::module_init]` → `#[napi_derive::module_init]` - `napi::JsObject` → `Object`, `.get::<_, T>()` → `.get::<T>()` - `ErrorStrategy` removed; `ThreadsafeFunction` now takes an explicit `Return` type with `CalleeHandled = false` const generic - `JsFunction` + `create_threadsafe_function` replaced by typed `Function<Args, Return>` + `build_threadsafe_function().build()` - `RerankerCallbacks` struct removed (`Function<'env,...>` can't be stored in structs); `VectorQuery::rerank` now accepts the function directly - `ClassInstance::clone()` now returns `ClassInstance`, fixed with explicit deref - `Vec<u8>` in `#[napi(object)]` now maps to `Array<number>` in v3; changed to `Buffer` to preserve the TypeScript `Buffer` type **TypeScript**: - `inner.rerank({ rerankHybrid: async (_, args) => ... })` → `inner.rerank(async (args) => ...)` - Header provider callback wrapped in `async` to match stricter typed constructor signature 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
2.4 KiB
Rust
70 lines
2.4 KiB
Rust
// SPDX-License-Identifier: Apache-2.0
|
|
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
|
|
|
use std::collections::HashMap;
|
|
|
|
use env_logger::Env;
|
|
use napi_derive::*;
|
|
|
|
mod connection;
|
|
mod error;
|
|
mod header;
|
|
mod index;
|
|
mod iterator;
|
|
pub mod merge;
|
|
pub mod permutation;
|
|
mod query;
|
|
pub mod remote;
|
|
mod rerankers;
|
|
mod session;
|
|
mod table;
|
|
mod util;
|
|
|
|
#[napi(object)]
|
|
#[derive(Debug)]
|
|
pub struct ConnectionOptions {
|
|
/// (For LanceDB OSS only): The interval, in seconds, at which to check for
|
|
/// updates to the table from other processes. If None, then consistency is not
|
|
/// checked. For performance reasons, this is the default. For strong
|
|
/// consistency, set this to zero seconds. Then every read will check for
|
|
/// updates from other processes. As a compromise, you can set this to a
|
|
/// non-zero value for eventual consistency. If more than that interval
|
|
/// has passed since the last check, then the table will be checked for updates.
|
|
/// Note: this consistency only applies to read operations. Write operations are
|
|
/// always consistent.
|
|
pub read_consistency_interval: Option<f64>,
|
|
/// (For LanceDB OSS only): configuration for object storage.
|
|
///
|
|
/// The available options are described at https://lancedb.com/docs/storage/
|
|
pub storage_options: Option<HashMap<String, String>>,
|
|
/// (For LanceDB OSS only): the session to use for this connection. Holds
|
|
/// shared caches and other session-specific state.
|
|
pub session: Option<session::Session>,
|
|
|
|
/// (For LanceDB cloud only): configuration for the remote HTTP client.
|
|
pub client_config: Option<remote::ClientConfig>,
|
|
/// (For LanceDB cloud only): the API key to use with LanceDB Cloud.
|
|
///
|
|
/// Can also be set via the environment variable `LANCEDB_API_KEY`.
|
|
pub api_key: Option<String>,
|
|
/// (For LanceDB cloud only): the region to use for LanceDB cloud.
|
|
/// Defaults to 'us-east-1'.
|
|
pub region: Option<String>,
|
|
/// (For LanceDB cloud only): the host to use for LanceDB cloud. Used
|
|
/// for testing purposes.
|
|
pub host_override: Option<String>,
|
|
}
|
|
|
|
#[napi(object)]
|
|
pub struct OpenTableOptions {
|
|
pub storage_options: Option<HashMap<String, String>>,
|
|
}
|
|
|
|
#[napi_derive::module_init]
|
|
fn init() {
|
|
let env = Env::new()
|
|
.filter_or("LANCEDB_LOG", "warn")
|
|
.write_style("LANCEDB_LOG_STYLE");
|
|
env_logger::init_from_env(env);
|
|
}
|