@lancedb/lancedb 0.29.0 → 0.29.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -3,11 +3,11 @@ The core Rust library is in the `../rust/lancedb` directory, the rust binding
3
3
  code is in the `src/` directory and the typescript bindings are in
4
4
  the `lancedb/` directory.
5
5
 
6
- Whenever you change the Rust code, you will need to recompile: `npm run build`.
6
+ Whenever you change the Rust code, you will need to recompile: `pnpm build`.
7
7
 
8
8
  Common commands:
9
- * Build: `npm run build`
10
- * Lint: `npm run lint`
11
- * Fix lints: `npm run lint-fix`
12
- * Test: `npm test`
13
- * Run single test file: `npm test __test__/arrow.test.ts`
9
+ * Build: `pnpm build`
10
+ * Lint: `pnpm lint`
11
+ * Fix lints: `pnpm lint-fix`
12
+ * Test: `pnpm test`
13
+ * Run single test file: `pnpm test __test__/arrow.test.ts`
package/CONTRIBUTING.md CHANGED
@@ -12,20 +12,22 @@ Typescript.
12
12
  * `src/`: Rust bindings source code
13
13
  * `lancedb/`: Typescript package source code
14
14
  * `__test__/`: Unit tests
15
- * `examples/`: An npm package with the examples shown in the documentation
15
+ * `examples/`: A pnpm package with the examples shown in the documentation
16
16
 
17
17
  ## Development environment
18
18
 
19
19
  To set up your development environment, you will need to install the following:
20
20
 
21
- 1. Node.js 14 or later
22
- 2. Rust's package manager, Cargo. Use [rustup](https://rustup.rs/) to install.
23
- 3. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
21
+ 1. Node.js 22 or later (required by pnpm 11)
22
+ 2. [pnpm](https://pnpm.io/installation) 11 or later (or run via `corepack enable`,
23
+ which uses the `packageManager` field in `package.json`)
24
+ 3. Rust's package manager, Cargo. Use [rustup](https://rustup.rs/) to install.
25
+ 4. [protoc](https://grpc.io/docs/protoc-installation/) (Protocol Buffers compiler)
24
26
 
25
27
  Initial setup:
26
28
 
27
29
  ```shell
28
- npm install
30
+ pnpm install
29
31
  ```
30
32
 
31
33
  ### Commit Hooks
@@ -39,38 +41,38 @@ pre-commit install
39
41
 
40
42
  ## Development
41
43
 
42
- Most common development commands can be run using the npm scripts.
44
+ Most common development commands can be run using the pnpm scripts.
43
45
 
44
46
  Build the package
45
47
 
46
48
  ```shell
47
- npm install
48
- npm run build
49
+ pnpm install
50
+ pnpm build
49
51
  ```
50
52
 
51
53
  Lint:
52
54
 
53
55
  ```shell
54
- npm run lint
56
+ pnpm lint
55
57
  ```
56
58
 
57
59
  Format and fix lints:
58
60
 
59
61
  ```shell
60
- npm run lint-fix
62
+ pnpm lint-fix
61
63
  ```
62
64
 
63
65
  Run tests:
64
66
 
65
67
  ```shell
66
- npm test
68
+ pnpm test
67
69
  ```
68
70
 
69
71
  To run a single test:
70
72
 
71
73
  ```shell
72
74
  # Single file: table.test.ts
73
- npm test -- table.test.ts
75
+ pnpm test -- table.test.ts
74
76
  # Single test: 'merge insert' in table.test.ts
75
- npm test -- table.test.ts --testNamePattern=merge\ insert
77
+ pnpm test -- table.test.ts --testNamePattern=merge\ insert
76
78
  ```
package/dist/arrow.d.ts CHANGED
@@ -255,6 +255,12 @@ export declare function fromBufferToRecordBatch(data: Buffer): Promise<RecordBat
255
255
  * Create a buffer containing a single record batch
256
256
  */
257
257
  export declare function fromRecordBatchToBuffer(batch: RecordBatch): Promise<Buffer>;
258
+ /**
259
+ * Create a buffer containing a single record batch using the Arrow IPC Stream
260
+ * serialization. Each call produces a self-contained Stream message (schema +
261
+ * batch + EOS) suitable for incremental decode by `arrow_ipc::reader::StreamReader`.
262
+ */
263
+ export declare function fromRecordBatchToStreamBuffer(batch: RecordBatch): Promise<Buffer>;
258
264
  /**
259
265
  * Serialize an Arrow Table into a buffer using the Arrow IPC Stream serialization
260
266
  *
package/dist/arrow.js CHANGED
@@ -50,6 +50,7 @@ exports.fromTableToBuffer = fromTableToBuffer;
50
50
  exports.fromDataToBuffer = fromDataToBuffer;
51
51
  exports.fromBufferToRecordBatch = fromBufferToRecordBatch;
52
52
  exports.fromRecordBatchToBuffer = fromRecordBatchToBuffer;
53
+ exports.fromRecordBatchToStreamBuffer = fromRecordBatchToStreamBuffer;
53
54
  exports.fromTableToStreamBuffer = fromTableToStreamBuffer;
54
55
  exports.createEmptyTable = createEmptyTable;
55
56
  exports.ensureNestedFieldsExist = ensureNestedFieldsExist;
@@ -1056,6 +1057,15 @@ async function fromRecordBatchToBuffer(batch) {
1056
1057
  const writer = new apache_arrow_1.RecordBatchFileWriter().writeAll([batch]);
1057
1058
  return Buffer.from(await writer.toUint8Array());
1058
1059
  }
1060
+ /**
1061
+ * Create a buffer containing a single record batch using the Arrow IPC Stream
1062
+ * serialization. Each call produces a self-contained Stream message (schema +
1063
+ * batch + EOS) suitable for incremental decode by `arrow_ipc::reader::StreamReader`.
1064
+ */
1065
+ async function fromRecordBatchToStreamBuffer(batch) {
1066
+ const writer = apache_arrow_1.RecordBatchStreamWriter.writeAll([batch]);
1067
+ return Buffer.from(await writer.toUint8Array());
1068
+ }
1059
1069
  /**
1060
1070
  * Serialize an Arrow Table into a buffer using the Arrow IPC Stream serialization
1061
1071
  *
@@ -1,6 +1,8 @@
1
1
  import { Data, SchemaLike, TableLike } from "./arrow";
2
2
  import { EmbeddingFunctionConfig } from "./embedding/registry";
3
3
  import { Connection as LanceDbConnection } from "./native";
4
+ import type { CreateNamespaceResponse, DescribeNamespaceResponse, DropNamespaceResponse, ListNamespacesResponse } from "./native";
5
+ export type { CreateNamespaceResponse, DescribeNamespaceResponse, DropNamespaceResponse, ListNamespacesResponse, };
4
6
  import { Table } from "./table";
5
7
  export interface CreateTableOptions {
6
8
  /**
@@ -87,6 +89,24 @@ export interface TableNamesOptions {
87
89
  /** An optional limit to the number of results to return. */
88
90
  limit?: number;
89
91
  }
92
+ export interface ListNamespacesOptions {
93
+ /** Token from a previous response for pagination. */
94
+ pageToken?: string;
95
+ /** An optional limit to the number of results to return. */
96
+ limit?: number;
97
+ }
98
+ export interface CreateNamespaceOptions {
99
+ /** Creation mode. */
100
+ mode?: "create" | "exist_ok" | "overwrite";
101
+ /** Properties to set on the new namespace. */
102
+ properties?: Record<string, string>;
103
+ }
104
+ export interface DropNamespaceOptions {
105
+ /** Whether to skip if the namespace doesn't exist, or fail. */
106
+ mode?: "skip" | "fail";
107
+ /** Refuse to drop if non-empty (restrict) or drop recursively (cascade). */
108
+ behavior?: "restrict" | "cascade";
109
+ }
90
110
  /**
91
111
  * A LanceDB Connection that allows you to open tables and create new ones.
92
112
  *
@@ -199,11 +219,60 @@ export declare abstract class Connection {
199
219
  * @param {string[]} namespacePath The namespace path of the table (defaults to root namespace).
200
220
  */
201
221
  abstract dropTable(name: string, namespacePath?: string[]): Promise<void>;
222
+ abstract renameTable(oldName: string, newName: string, namespacePath?: string[]): Promise<void>;
202
223
  /**
203
224
  * Drop all tables in the database.
204
225
  * @param {string[]} namespacePath The namespace path to drop tables from (defaults to root namespace).
205
226
  */
206
227
  abstract dropAllTables(namespacePath?: string[]): Promise<void>;
228
+ /**
229
+ * Describe a namespace, returning its properties.
230
+ *
231
+ * @param {string[]} namespacePath - The namespace path to describe, in
232
+ * parent → child order, e.g. `["analytics", "sales"]`.
233
+ * @returns {Promise<DescribeNamespaceResponse>} The namespace's properties
234
+ * (may be undefined if the namespace has none).
235
+ */
236
+ abstract describeNamespace(namespacePath: string[]): Promise<DescribeNamespaceResponse>;
237
+ /**
238
+ * List the immediate child namespaces under the given parent.
239
+ *
240
+ * Results may be paginated. To retrieve subsequent pages, pass the
241
+ * `pageToken` returned by a previous call.
242
+ *
243
+ * @param {string[]} namespacePath - The parent namespace path. Defaults
244
+ * to the root namespace if omitted.
245
+ * @param {Partial<ListNamespacesOptions>} options - Pagination options
246
+ * (`pageToken`, `limit`).
247
+ * @returns {Promise<ListNamespacesResponse>} Child namespace names and
248
+ * an optional token for fetching the next page.
249
+ */
250
+ abstract listNamespaces(namespacePath?: string[], options?: Partial<ListNamespacesOptions>): Promise<ListNamespacesResponse>;
251
+ /**
252
+ * Create a new namespace at the given path.
253
+ *
254
+ * @param {string[]} namespacePath - The namespace path to create.
255
+ * @param {Partial<CreateNamespaceOptions>} options - Creation `mode`
256
+ * ("create" | "exist_ok" | "overwrite") and optional `properties`
257
+ * to attach to the namespace.
258
+ * @returns {Promise<CreateNamespaceResponse>} The properties of the
259
+ * created namespace and an optional transaction id.
260
+ */
261
+ abstract createNamespace(namespacePath: string[], options?: Partial<CreateNamespaceOptions>): Promise<CreateNamespaceResponse>;
262
+ /**
263
+ * Drop a namespace.
264
+ *
265
+ * Use `behavior: "cascade"` to also drop everything contained in the
266
+ * namespace (sub-namespaces and tables). The default `"restrict"`
267
+ * behavior refuses to drop a non-empty namespace.
268
+ *
269
+ * @param {string[]} namespacePath - The namespace path to drop.
270
+ * @param {Partial<DropNamespaceOptions>} options - `mode` ("skip" | "fail"
271
+ * for missing-namespace handling) and `behavior` ("restrict" | "cascade").
272
+ * @returns {Promise<DropNamespaceResponse>} Any properties returned by
273
+ * the server and an optional transaction id.
274
+ */
275
+ abstract dropNamespace(namespacePath: string[], options?: Partial<DropNamespaceOptions>): Promise<DropNamespaceResponse>;
207
276
  /**
208
277
  * Clone a table from a source table.
209
278
  *
@@ -251,7 +320,12 @@ export declare class LocalConnection extends Connection {
251
320
  private _createTableImpl;
252
321
  createEmptyTable(name: string, schema: import("./arrow").SchemaLike, namespacePathOrOptions?: string[] | Partial<CreateTableOptions>, options?: Partial<CreateTableOptions>): Promise<Table>;
253
322
  dropTable(name: string, namespacePath?: string[]): Promise<void>;
323
+ renameTable(oldName: string, newName: string, namespacePath?: string[]): Promise<void>;
254
324
  dropAllTables(namespacePath?: string[]): Promise<void>;
325
+ describeNamespace(namespacePath: string[]): Promise<DescribeNamespaceResponse>;
326
+ listNamespaces(namespacePath?: string[], options?: Partial<ListNamespacesOptions>): Promise<ListNamespacesResponse>;
327
+ createNamespace(namespacePath: string[], options?: Partial<CreateNamespaceOptions>): Promise<CreateNamespaceResponse>;
328
+ dropNamespace(namespacePath: string[], options?: Partial<DropNamespaceOptions>): Promise<DropNamespaceResponse>;
255
329
  }
256
330
  /**
257
331
  * Takes storage options and makes all the keys snake case.
@@ -160,9 +160,24 @@ class LocalConnection extends Connection {
160
160
  async dropTable(name, namespacePath) {
161
161
  return this.inner.dropTable(name, namespacePath ?? []);
162
162
  }
163
+ async renameTable(oldName, newName, namespacePath) {
164
+ return this.inner.renameTable(oldName, newName, namespacePath ?? []);
165
+ }
163
166
  async dropAllTables(namespacePath) {
164
167
  return this.inner.dropAllTables(namespacePath ?? []);
165
168
  }
169
+ describeNamespace(namespacePath) {
170
+ return this.inner.describeNamespace(namespacePath);
171
+ }
172
+ listNamespaces(namespacePath, options) {
173
+ return this.inner.listNamespaces(namespacePath ?? [], options?.pageToken, options?.limit);
174
+ }
175
+ createNamespace(namespacePath, options) {
176
+ return this.inner.createNamespace(namespacePath, options?.mode, options?.properties);
177
+ }
178
+ dropNamespace(namespacePath, options) {
179
+ return this.inner.dropNamespace(namespacePath, options?.mode, options?.behavior);
180
+ }
166
181
  }
167
182
  exports.LocalConnection = LocalConnection;
168
183
  /**
package/dist/index.d.ts CHANGED
@@ -1,18 +1,19 @@
1
1
  import { Connection } from "./connection";
2
- import { ConnectionOptions, Session } from "./native.js";
2
+ import { ConnectNamespaceOptions, ConnectionOptions, Session } from "./native.js";
3
3
  import { HeaderProvider } from "./header";
4
4
  export { JsHeaderProvider as NativeJsHeaderProvider } from "./native.js";
5
- export { AddColumnsSql, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, TlsConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, MergeResult, AddResult, AddColumnsResult, AlterColumnsResult, DeleteResult, DropColumnsResult, UpdateResult, SplitCalculatedOptions, SplitRandomOptions, SplitHashOptions, SplitSequentialOptions, ShuffleOptions, } from "./native.js";
5
+ export { AddColumnsSql, ConnectionOptions, ConnectNamespaceOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, TlsConfig, OptimizeStats, CompactionStats, RemovalStats, TableStatistics, FragmentStatistics, FragmentSummaryStats, Tags, TagContents, MergeResult, AddResult, AddColumnsResult, AlterColumnsResult, DeleteResult, DropColumnsResult, UpdateResult, SplitCalculatedOptions, SplitRandomOptions, SplitHashOptions, SplitSequentialOptions, ShuffleOptions, } from "./native.js";
6
6
  export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
7
- export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, } from "./connection";
7
+ export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, ListNamespacesOptions, CreateNamespaceOptions, DropNamespaceOptions, ListNamespacesResponse, CreateNamespaceResponse, DropNamespaceResponse, DescribeNamespaceResponse, } from "./connection";
8
8
  export { Session } from "./native.js";
9
- export { ExecutableQuery, Query, QueryBase, VectorQuery, TakeQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } from "./query";
9
+ export { ExecutableQuery, Query, QueryBase, VectorQuery, TakeQuery, QueryExecutionOptions, ColumnOrdering, FullTextSearchOptions, RecordBatchIterator, FullTextQuery, MatchQuery, PhraseQuery, BoostQuery, MultiMatchQuery, BooleanQuery, FullTextQueryType, Operator, Occur, } from "./query";
10
10
  export { Index, IndexOptions, IvfPqOptions, IvfRqOptions, IvfFlatOptions, HnswPqOptions, HnswSqOptions, FtsOptions, } from "./indices";
11
- export { Table, AddDataOptions, UpdateOptions, OptimizeOptions, Version, ColumnAlteration, } from "./table";
11
+ export { Table, AddDataOptions, UpdateOptions, OptimizeOptions, Version, LsmWriteSpec, ColumnAlteration, } from "./table";
12
12
  export { HeaderProvider, StaticHeaderProvider, OAuthHeaderProvider, TokenResponse, } from "./header";
13
13
  export { MergeInsertBuilder, WriteExecutionOptions } from "./merge";
14
14
  export * as embedding from "./embedding";
15
15
  export { permutationBuilder, PermutationBuilder } from "./permutation";
16
+ export { Scannable, ScannableOptions } from "./scannable";
16
17
  export * as rerankers from "./rerankers";
17
18
  export { SchemaLike, TableLike, FieldLike, RecordBatchLike, DataLike, IntoVector, MultiVector, } from "./arrow";
18
19
  export { IntoSql, packBits } from "./util";
@@ -83,3 +84,115 @@ export declare function connect(uri: string, options?: Partial<ConnectionOptions
83
84
  export declare function connect(options: Partial<ConnectionOptions> & {
84
85
  uri: string;
85
86
  }): Promise<Connection>;
87
+ /**
88
+ * Configuration for the built-in directory namespace (`"dir"`).
89
+ *
90
+ * The directory namespace stores tables under a single root path (local
91
+ * filesystem or object storage URI). See
92
+ * {@link https://docs.lancedb.com/namespaces} for the documented surface;
93
+ * less-common knobs live under {@link DirNamespaceConfig.extraProperties}.
94
+ */
95
+ export interface DirNamespaceConfig {
96
+ /** Root path or URI containing the LanceDB tables. */
97
+ root: string;
98
+ /**
99
+ * Whether to maintain a namespace manifest at the root. Required for
100
+ * child namespaces. Defaults to true on the impl side.
101
+ */
102
+ manifestEnabled?: boolean;
103
+ /**
104
+ * Additional raw properties passed verbatim to the namespace
105
+ * implementation (e.g. `storage.*`, `credential_vendor.*`). Typed
106
+ * fields above take precedence on key collision.
107
+ */
108
+ extraProperties?: Record<string, string>;
109
+ }
110
+ /**
111
+ * Configuration for the built-in REST namespace (`"rest"`).
112
+ *
113
+ * The REST namespace talks to a remote catalog server over HTTP. See
114
+ * {@link https://docs.lancedb.com/namespaces} for the documented surface;
115
+ * less-common knobs (TLS, metrics) live under
116
+ * {@link RestNamespaceConfig.extraProperties}.
117
+ */
118
+ export interface RestNamespaceConfig {
119
+ /** Catalog endpoint URL. */
120
+ uri: string;
121
+ /**
122
+ * HTTP headers forwarded with each request. Keys are passed through
123
+ * as-is (e.g. `"x-api-key"`, `"Authorization"`).
124
+ */
125
+ headers?: Record<string, string>;
126
+ /**
127
+ * Additional raw properties passed verbatim to the namespace
128
+ * implementation (e.g. `tls.*`, `ops_metrics_enabled`, `delimiter`).
129
+ * Typed fields above take precedence on key collision.
130
+ */
131
+ extraProperties?: Record<string, string>;
132
+ }
133
+ /**
134
+ * Connect to a LanceDB database through a namespace.
135
+ *
136
+ * Unlike {@link connect}, which routes by URI scheme (local path vs.
137
+ * `db://` cloud), `connectNamespace` always returns a namespace-backed
138
+ * connection. The `implName` selects the namespace implementation:
139
+ *
140
+ * - `"dir"` — directory namespace, configured with {@link DirNamespaceConfig}.
141
+ * - `"rest"` — remote REST catalog, configured with {@link RestNamespaceConfig}.
142
+ * - Any other string — full module path for a custom implementation,
143
+ * configured with a free-form string-keyed `properties` map.
144
+ *
145
+ * @example Typed dir namespace
146
+ * ```ts
147
+ * const db = await connectNamespace("dir", { root: "/path/to/db" });
148
+ * await db.createTable("users", [{ id: 1 }]);
149
+ * ```
150
+ *
151
+ * @example Typed REST namespace with auth headers
152
+ * ```ts
153
+ * const db = await connectNamespace("rest", {
154
+ * uri: "https://catalog.example.com",
155
+ * headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
156
+ * });
157
+ * ```
158
+ *
159
+ * @example Custom implementation with raw properties
160
+ * ```ts
161
+ * const db = await connectNamespace("my.custom.Namespace", {
162
+ * endpoint: "...",
163
+ * });
164
+ * ```
165
+ */
166
+ export declare function connectNamespace(implName: "dir", config: DirNamespaceConfig, options?: Partial<ConnectNamespaceOptions>): Promise<Connection>;
167
+ /**
168
+ * Connect through the built-in REST namespace.
169
+ *
170
+ * Configured with {@link RestNamespaceConfig}. See the function-level
171
+ * documentation above for the full surface, examples, and how this
172
+ * relates to {@link connect}.
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * const db = await connectNamespace("rest", {
177
+ * uri: "https://catalog.example.com",
178
+ * headers: { "x-api-key": process.env.CATALOG_KEY ?? "" },
179
+ * });
180
+ * ```
181
+ */
182
+ export declare function connectNamespace(implName: "rest", config: RestNamespaceConfig, options?: Partial<ConnectNamespaceOptions>): Promise<Connection>;
183
+ /**
184
+ * Connect through a custom namespace implementation by full module path,
185
+ * configured with a free-form string-keyed `properties` map. Use the
186
+ * typed overloads above for the built-in `"dir"` and `"rest"` impls.
187
+ *
188
+ * See the function-level documentation above for examples and how this
189
+ * relates to {@link connect}.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * const db = await connectNamespace("my.custom.Namespace", {
194
+ * endpoint: "...",
195
+ * });
196
+ * ```
197
+ */
198
+ export declare function connectNamespace(implName: string, properties: Record<string, string>, options?: Partial<ConnectNamespaceOptions>): Promise<Connection>;
package/dist/index.js CHANGED
@@ -2,8 +2,9 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // SPDX-FileCopyrightText: Copyright The LanceDB Authors
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.packBits = exports.rerankers = exports.PermutationBuilder = exports.permutationBuilder = exports.embedding = exports.MergeInsertBuilder = exports.OAuthHeaderProvider = exports.StaticHeaderProvider = exports.HeaderProvider = exports.Table = exports.Index = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.RecordBatchIterator = exports.TakeQuery = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Session = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.TagContents = exports.Tags = exports.NativeJsHeaderProvider = void 0;
5
+ exports.packBits = exports.rerankers = exports.Scannable = exports.PermutationBuilder = exports.permutationBuilder = exports.embedding = exports.MergeInsertBuilder = exports.OAuthHeaderProvider = exports.StaticHeaderProvider = exports.HeaderProvider = exports.Table = exports.Index = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.RecordBatchIterator = exports.TakeQuery = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Session = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.TagContents = exports.Tags = exports.NativeJsHeaderProvider = void 0;
6
6
  exports.connect = connect;
7
+ exports.connectNamespace = connectNamespace;
7
8
  const connection_1 = require("./connection");
8
9
  const native_js_1 = require("./native.js");
9
10
  // Re-export native header provider for use with connectWithHeaderProvider
@@ -48,6 +49,8 @@ exports.embedding = require("./embedding");
48
49
  var permutation_1 = require("./permutation");
49
50
  Object.defineProperty(exports, "permutationBuilder", { enumerable: true, get: function () { return permutation_1.permutationBuilder; } });
50
51
  Object.defineProperty(exports, "PermutationBuilder", { enumerable: true, get: function () { return permutation_1.PermutationBuilder; } });
52
+ var scannable_1 = require("./scannable");
53
+ Object.defineProperty(exports, "Scannable", { enumerable: true, get: function () { return scannable_1.Scannable; } });
51
54
  exports.rerankers = require("./rerankers");
52
55
  var util_1 = require("./util");
53
56
  Object.defineProperty(exports, "packBits", { enumerable: true, get: function () { return util_1.packBits; } });
@@ -104,3 +107,47 @@ async function connect(uriOrOptions, optionsOrSession, sessionOrHeaderProvider,
104
107
  const nativeConn = await native_js_1.Connection.new(uri, finalOptions, nativeProvider);
105
108
  return new connection_1.LocalConnection(nativeConn);
106
109
  }
110
+ function dirConfigToProperties(config) {
111
+ // Spread the whole input so that unknown keys (e.g. a raw `manifest_enabled`
112
+ // passed via the dynamic-impl path) flow through instead of being dropped.
113
+ // Typed transformations layer on top.
114
+ const { manifestEnabled, extraProperties, ...rest } = config;
115
+ const properties = {
116
+ ...(extraProperties ?? {}),
117
+ ...rest,
118
+ };
119
+ if (manifestEnabled !== undefined) {
120
+ properties.manifest_enabled = String(manifestEnabled);
121
+ }
122
+ return properties;
123
+ }
124
+ function restConfigToProperties(config) {
125
+ const { headers, extraProperties, ...rest } = config;
126
+ const properties = {
127
+ ...(extraProperties ?? {}),
128
+ ...rest,
129
+ };
130
+ if (headers) {
131
+ for (const [name, value] of Object.entries(headers)) {
132
+ properties[`headers.${name}`] = value;
133
+ }
134
+ }
135
+ return properties;
136
+ }
137
+ async function connectNamespace(implName, configOrProperties, options) {
138
+ let properties;
139
+ if (implName === "dir") {
140
+ properties = dirConfigToProperties(configOrProperties);
141
+ }
142
+ else if (implName === "rest") {
143
+ properties = restConfigToProperties(configOrProperties);
144
+ }
145
+ else {
146
+ properties = configOrProperties;
147
+ }
148
+ const finalOptions = (options ??
149
+ {});
150
+ finalOptions.storageOptions = (0, connection_1.cleanseStorageOptions)(finalOptions.storageOptions);
151
+ const nativeConn = await native_js_1.Connection.newWithNamespace(implName, properties, finalOptions);
152
+ return new connection_1.LocalConnection(nativeConn);
153
+ }
package/dist/native.d.ts CHANGED
@@ -3,6 +3,8 @@
3
3
  export declare class Connection {
4
4
  /** Create a new Connection instance from the given URI. */
5
5
  static new(uri: string, options: ConnectionOptions, headerProvider?: JsHeaderProvider | undefined | null): Promise<Connection>
6
+ /** Create a new Connection instance backed by a namespace implementation. */
7
+ static newWithNamespace(implName: string, properties: Record<string, string>, options: ConnectNamespaceOptions): Promise<Connection>
6
8
  display(): string
7
9
  isOpen(): boolean
8
10
  close(): void
@@ -21,7 +23,16 @@ export declare class Connection {
21
23
  cloneTable(targetTableName: string, sourceUri: string, targetNamespacePath: Array<string> | undefined | null, sourceVersion: number | undefined | null, sourceTag: string | undefined | null, isShallow: boolean): Promise<Table>
22
24
  /** Drop table with the name. Or raise an error if the table does not exist. */
23
25
  dropTable(name: string, namespacePath?: Array<string> | undefined | null): Promise<void>
26
+ renameTable(oldName: string, newName: string, namespacePath?: Array<string> | undefined | null): Promise<void>
24
27
  dropAllTables(namespacePath?: Array<string> | undefined | null): Promise<void>
28
+ /** Describe a namespace and return its properties. */
29
+ describeNamespace(namespacePath: Array<string>): Promise<DescribeNamespaceResponse>
30
+ /** List child namespaces under the given namespace path */
31
+ listNamespaces(namespacePath?: Array<string> | undefined | null, pageToken?: string | undefined | null, limit?: number | undefined | null): Promise<ListNamespacesResponse>
32
+ /** Create a new namespace with optional properties. */
33
+ createNamespace(namespacePath: Array<string>, mode?: string | undefined | null, properties?: Record<string, string> | undefined | null): Promise<CreateNamespaceResponse>
34
+ /** Drop a namespace. */
35
+ dropNamespace(namespacePath: Array<string>, mode?: string | undefined | null, behavior?: string | undefined | null): Promise<DropNamespaceResponse>
25
36
  }
26
37
 
27
38
  export declare class Index {
@@ -55,6 +66,30 @@ export declare class JsHeaderProvider {
55
66
  constructor(getHeadersCallback: () => Promise<Record<string, string>>)
56
67
  }
57
68
 
69
+ /**
70
+ * A Rust-side view of a JS-constructed `Scannable`.
71
+ *
72
+ * Held in JS as the return value of the `Scannable` class constructor. When
73
+ * passed to a consumer that accepts `impl lancedb::data::scannable::Scannable`,
74
+ * the consumer invokes `scan_as_stream()` to pull batches through the JS
75
+ * callback.
76
+ */
77
+ export declare class NapiScannable {
78
+ /**
79
+ * Construct a new `NapiScannable`.
80
+ *
81
+ * - `schema_buf` — Arrow IPC File buffer carrying only the schema (no batches).
82
+ * - `num_rows` — optional row count hint; not validated against the stream.
83
+ * - `rescannable` — whether `get_next_batch` may be re-driven after the
84
+ * scan completes.
85
+ * - `get_next_batch` -- JS callback that yields the next batch as an Arrow
86
+ * IPC Stream message wrapped in a `Buffer`, or `null` at EOF. The
87
+ * `isStart` argument is `true` on the first call of each new scan;
88
+ * JS uses it to discard any cached iterator before pulling.
89
+ */
90
+ constructor(schemaBuf: Buffer, numRows: number | undefined | null, rescannable: boolean, getNextBatch: (arg: boolean) => Promise<Buffer | undefined | null>)
91
+ }
92
+
58
93
  /** A builder used to create and run a merge insert operation */
59
94
  export declare class NativeMergeInsertBuilder {
60
95
  whenMatchedUpdateAll(condition?: string | undefined | null): NativeMergeInsertBuilder
@@ -94,6 +129,7 @@ export declare class Query {
94
129
  nearestToRaw(data: Uint8Array, dtype: string): VectorQuery
95
130
  fastSearch(): void
96
131
  withRowId(): void
132
+ orderBy(ordering?: Array<ColumnOrdering> | undefined | null): void
97
133
  outputSchema(): Promise<Buffer>
98
134
  execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
99
135
  explainPlan(verbose: boolean): Promise<string>
@@ -174,6 +210,9 @@ export declare class Table {
174
210
  addColumnsWithSchema(schemaBuf: Buffer): Promise<AddColumnsResult>
175
211
  alterColumns(alterations: Array<ColumnAlteration>): Promise<AlterColumnsResult>
176
212
  dropColumns(columns: Array<string>): Promise<DropColumnsResult>
213
+ setUnenforcedPrimaryKey(columns: Array<string>): Promise<void>
214
+ setLsmWriteSpec(spec: LsmWriteSpec): Promise<void>
215
+ unsetLsmWriteSpec(): Promise<void>
177
216
  version(): Promise<number>
178
217
  checkout(version: number): Promise<void>
179
218
  checkoutTag(tag: string): Promise<void>
@@ -234,6 +273,7 @@ export declare class VectorQuery {
234
273
  fastSearch(): void
235
274
  withRowId(): void
236
275
  rerank(rerankHybrid: (arg: RerankHybridCallbackArgs) => Promise<Buffer>): void
276
+ orderBy(ordering?: Array<ColumnOrdering> | undefined | null): void
237
277
  outputSchema(): Promise<Buffer>
238
278
  execute(maxBatchLength?: number | undefined | null, timeoutMs?: number | undefined | null): Promise<RecordBatchIterator>
239
279
  explainPlan(verbose: boolean): Promise<string>
@@ -316,6 +356,12 @@ export interface ColumnAlteration {
316
356
  nullable?: boolean
317
357
  }
318
358
 
359
+ export interface ColumnOrdering {
360
+ ascending: boolean
361
+ nullsFirst: boolean
362
+ columnName: string
363
+ }
364
+
319
365
  /** Statistics about a compaction operation. */
320
366
  export interface CompactionStats {
321
367
  /** The number of fragments removed */
@@ -383,15 +429,53 @@ export interface ConnectionOptions {
383
429
  hostOverride?: string
384
430
  }
385
431
 
432
+ export interface ConnectNamespaceOptions {
433
+ /**
434
+ * The interval, in seconds, at which to check for updates to the table
435
+ * from other processes. If None, then consistency is not checked. For
436
+ * performance reasons, this is the default. For strong consistency, set
437
+ * this to zero seconds. Then every read will check for updates from other
438
+ * processes. As a compromise, you can set this to a non-zero value for
439
+ * eventual consistency.
440
+ */
441
+ readConsistencyInterval?: number
442
+ /**
443
+ * Configuration for object storage. The available options are described
444
+ * at https://docs.lancedb.com/storage/
445
+ */
446
+ storageOptions?: Record<string, string>
447
+ /** Extra properties for the backing namespace client. */
448
+ namespaceClientProperties?: Record<string, string>
449
+ /**
450
+ * The session to use for this connection. Holds shared caches and other
451
+ * session-specific state.
452
+ */
453
+ session?: Session
454
+ }
455
+
456
+ export interface CreateNamespaceResponse {
457
+ properties?: Record<string, string>
458
+ transactionId?: string
459
+ }
460
+
386
461
  export interface DeleteResult {
387
462
  numDeletedRows: number
388
463
  version: number
389
464
  }
390
465
 
466
+ export interface DescribeNamespaceResponse {
467
+ properties?: Record<string, string>
468
+ }
469
+
391
470
  export interface DropColumnsResult {
392
471
  version: number
393
472
  }
394
473
 
474
+ export interface DropNamespaceResponse {
475
+ properties?: Record<string, string>
476
+ transactionId?: Array<string>
477
+ }
478
+
395
479
  export interface FragmentStatistics {
396
480
  /** The number of fragments in the table */
397
481
  numFragments: number
@@ -455,6 +539,32 @@ export interface IndexStatistics {
455
539
  loss?: number
456
540
  }
457
541
 
542
+ export interface ListNamespacesResponse {
543
+ namespaces: Array<string>
544
+ pageToken?: string
545
+ }
546
+
547
+ /**
548
+ * Specification selecting Lance's MemWAL LSM-style write path for
549
+ * `mergeInsert`.
550
+ *
551
+ * `specType` must be `"bucket"`, `"identity"`, or `"unsharded"`. For
552
+ * `"bucket"`, `column` and `numBuckets` are required; for `"identity"`,
553
+ * `column` is required.
554
+ */
555
+ export interface LsmWriteSpec {
556
+ /** One of `"bucket"`, `"identity"`, or `"unsharded"`. */
557
+ specType: string
558
+ /** Bucket and identity variants: the sharding column. */
559
+ column?: string
560
+ /** Bucket variant: the number of buckets, in `[1, 1024]`. */
561
+ numBuckets?: number
562
+ /** Names of indexes the MemWAL should keep up to date during writes. */
563
+ maintainedIndexes?: Array<string>
564
+ /** Default `ShardWriter` configuration recorded in the MemWAL index. */
565
+ writerConfigDefaults?: Record<string, string>
566
+ }
567
+
458
568
  export interface MergeResult {
459
569
  version: number
460
570
  numInsertedRows: number