@lancedb/lancedb 0.29.0 → 0.30.0-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,36 @@ 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
+ }
110
+ export interface RenameTableOptions {
111
+ /**
112
+ * The namespace path of the table being renamed. Defaults to the root
113
+ * namespace (`[]`) when omitted.
114
+ */
115
+ namespacePath?: string[];
116
+ /**
117
+ * The namespace path to move the table to as part of the rename. When
118
+ * omitted the table stays in `namespacePath`.
119
+ */
120
+ newNamespacePath?: string[];
121
+ }
90
122
  /**
91
123
  * A LanceDB Connection that allows you to open tables and create new ones.
92
124
  *
@@ -204,6 +236,54 @@ export declare abstract class Connection {
204
236
  * @param {string[]} namespacePath The namespace path to drop tables from (defaults to root namespace).
205
237
  */
206
238
  abstract dropAllTables(namespacePath?: string[]): Promise<void>;
239
+ /**
240
+ * Describe a namespace, returning its properties.
241
+ *
242
+ * @param {string[]} namespacePath - The namespace path to describe, in
243
+ * parent → child order, e.g. `["analytics", "sales"]`.
244
+ * @returns {Promise<DescribeNamespaceResponse>} The namespace's properties
245
+ * (may be undefined if the namespace has none).
246
+ */
247
+ abstract describeNamespace(namespacePath: string[]): Promise<DescribeNamespaceResponse>;
248
+ /**
249
+ * List the immediate child namespaces under the given parent.
250
+ *
251
+ * Results may be paginated. To retrieve subsequent pages, pass the
252
+ * `pageToken` returned by a previous call.
253
+ *
254
+ * @param {string[]} namespacePath - The parent namespace path. Defaults
255
+ * to the root namespace if omitted.
256
+ * @param {Partial<ListNamespacesOptions>} options - Pagination options
257
+ * (`pageToken`, `limit`).
258
+ * @returns {Promise<ListNamespacesResponse>} Child namespace names and
259
+ * an optional token for fetching the next page.
260
+ */
261
+ abstract listNamespaces(namespacePath?: string[], options?: Partial<ListNamespacesOptions>): Promise<ListNamespacesResponse>;
262
+ /**
263
+ * Create a new namespace at the given path.
264
+ *
265
+ * @param {string[]} namespacePath - The namespace path to create.
266
+ * @param {Partial<CreateNamespaceOptions>} options - Creation `mode`
267
+ * ("create" | "exist_ok" | "overwrite") and optional `properties`
268
+ * to attach to the namespace.
269
+ * @returns {Promise<CreateNamespaceResponse>} The properties of the
270
+ * created namespace and an optional transaction id.
271
+ */
272
+ abstract createNamespace(namespacePath: string[], options?: Partial<CreateNamespaceOptions>): Promise<CreateNamespaceResponse>;
273
+ /**
274
+ * Drop a namespace.
275
+ *
276
+ * Use `behavior: "cascade"` to also drop everything contained in the
277
+ * namespace (sub-namespaces and tables). The default `"restrict"`
278
+ * behavior refuses to drop a non-empty namespace.
279
+ *
280
+ * @param {string[]} namespacePath - The namespace path to drop.
281
+ * @param {Partial<DropNamespaceOptions>} options - `mode` ("skip" | "fail"
282
+ * for missing-namespace handling) and `behavior` ("restrict" | "cascade").
283
+ * @returns {Promise<DropNamespaceResponse>} Any properties returned by
284
+ * the server and an optional transaction id.
285
+ */
286
+ abstract dropNamespace(namespacePath: string[], options?: Partial<DropNamespaceOptions>): Promise<DropNamespaceResponse>;
207
287
  /**
208
288
  * Clone a table from a source table.
209
289
  *
@@ -226,6 +306,19 @@ export declare abstract class Connection {
226
306
  sourceTag?: string;
227
307
  isShallow?: boolean;
228
308
  }): Promise<Table>;
309
+ /**
310
+ * Rename a table.
311
+ *
312
+ * Currently only supported by LanceDB Cloud. Local OSS connections and
313
+ * namespace-backed connections (via {@link connectNamespace}) reject with
314
+ * a "not supported" error.
315
+ *
316
+ * @param {string} currentName - The current name of the table.
317
+ * @param {string} newName - The new name for the table.
318
+ * @param {RenameTableOptions} options - Optional namespace paths. When
319
+ * `newNamespacePath` is omitted the table stays in `namespacePath`.
320
+ */
321
+ abstract renameTable(currentName: string, newName: string, options?: RenameTableOptions): Promise<void>;
229
322
  }
230
323
  /** @hideconstructor */
231
324
  export declare class LocalConnection extends Connection {
@@ -252,6 +345,11 @@ export declare class LocalConnection extends Connection {
252
345
  createEmptyTable(name: string, schema: import("./arrow").SchemaLike, namespacePathOrOptions?: string[] | Partial<CreateTableOptions>, options?: Partial<CreateTableOptions>): Promise<Table>;
253
346
  dropTable(name: string, namespacePath?: string[]): Promise<void>;
254
347
  dropAllTables(namespacePath?: string[]): Promise<void>;
348
+ describeNamespace(namespacePath: string[]): Promise<DescribeNamespaceResponse>;
349
+ listNamespaces(namespacePath?: string[], options?: Partial<ListNamespacesOptions>): Promise<ListNamespacesResponse>;
350
+ createNamespace(namespacePath: string[], options?: Partial<CreateNamespaceOptions>): Promise<CreateNamespaceResponse>;
351
+ dropNamespace(namespacePath: string[], options?: Partial<DropNamespaceOptions>): Promise<DropNamespaceResponse>;
352
+ renameTable(currentName: string, newName: string, options?: RenameTableOptions): Promise<void>;
255
353
  }
256
354
  /**
257
355
  * Takes storage options and makes all the keys snake case.
@@ -163,6 +163,21 @@ class LocalConnection extends Connection {
163
163
  async dropAllTables(namespacePath) {
164
164
  return this.inner.dropAllTables(namespacePath ?? []);
165
165
  }
166
+ describeNamespace(namespacePath) {
167
+ return this.inner.describeNamespace(namespacePath);
168
+ }
169
+ listNamespaces(namespacePath, options) {
170
+ return this.inner.listNamespaces(namespacePath ?? [], options?.pageToken, options?.limit);
171
+ }
172
+ createNamespace(namespacePath, options) {
173
+ return this.inner.createNamespace(namespacePath, options?.mode, options?.properties);
174
+ }
175
+ dropNamespace(namespacePath, options) {
176
+ return this.inner.dropNamespace(namespacePath, options?.mode, options?.behavior);
177
+ }
178
+ async renameTable(currentName, newName, options) {
179
+ return this.inner.renameTable(currentName, newName, options?.namespacePath ?? [], options?.newNamespacePath);
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, RenameTableOptions, } 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, WriteProgress, 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
+ }