@lancedb/lancedb 0.15.1-beta.2 → 0.15.1-beta.3

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/README.md CHANGED
@@ -32,7 +32,7 @@ const results = await table.vectorSearch([0.1, 0.3]).limit(20).toArray();
32
32
  console.log(results);
33
33
  ```
34
34
 
35
- The [quickstart](../basic.md) contains a more complete example.
35
+ The [quickstart](https://lancedb.github.io/lancedb/basic/) contains a more complete example.
36
36
 
37
37
  ## Development
38
38
 
package/dist/arrow.d.ts CHANGED
@@ -112,6 +112,7 @@ export declare class MakeArrowTableOptions {
112
112
  * - Record<String, any> => Struct
113
113
  * - Array<any> => List
114
114
  * @example
115
+ * ```ts
115
116
  * import { fromTableToBuffer, makeArrowTable } from "../arrow";
116
117
  * import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow";
117
118
  *
@@ -133,43 +134,41 @@ export declare class MakeArrowTableOptions {
133
134
  * names and data types.
134
135
  *
135
136
  * ```ts
136
- *
137
137
  * const schema = new Schema([
138
- new Field("a", new Float64()),
139
- new Field("b", new Float64()),
140
- new Field(
141
- "vector",
142
- new FixedSizeList(3, new Field("item", new Float32()))
143
- ),
144
- ]);
145
- const table = makeArrowTable([
146
- { a: 1, b: 2, vector: [1, 2, 3] },
147
- { a: 4, b: 5, vector: [4, 5, 6] },
148
- { a: 7, b: 8, vector: [7, 8, 9] },
149
- ]);
150
- assert.deepEqual(table.schema, schema);
138
+ * new Field("a", new Float64()),
139
+ * new Field("b", new Float64()),
140
+ * new Field(
141
+ * "vector",
142
+ * new FixedSizeList(3, new Field("item", new Float32()))
143
+ * ),
144
+ * ]);
145
+ * const table = makeArrowTable([
146
+ * { a: 1, b: 2, vector: [1, 2, 3] },
147
+ * { a: 4, b: 5, vector: [4, 5, 6] },
148
+ * { a: 7, b: 8, vector: [7, 8, 9] },
149
+ * ]);
150
+ * assert.deepEqual(table.schema, schema);
151
151
  * ```
152
152
  *
153
153
  * You can specify the vector column types and names using the options as well
154
154
  *
155
- * ```typescript
156
- *
155
+ * ```ts
157
156
  * const schema = new Schema([
158
- new Field('a', new Float64()),
159
- new Field('b', new Float64()),
160
- new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
161
- new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
162
- ]);
157
+ * new Field('a', new Float64()),
158
+ * new Field('b', new Float64()),
159
+ * new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
160
+ * new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
161
+ * ]);
163
162
  * const table = makeArrowTable([
164
- { a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
165
- { a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
166
- { a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
167
- ], {
168
- vectorColumns: {
169
- vec1: { type: new Float16() },
170
- vec2: { type: new Float16() }
171
- }
172
- }
163
+ * { a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
164
+ * { a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
165
+ * { a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
166
+ * ], {
167
+ * vectorColumns: {
168
+ * vec1: { type: new Float16() },
169
+ * vec2: { type: new Float16() }
170
+ * }
171
+ * }
173
172
  * assert.deepEqual(table.schema, schema)
174
173
  * ```
175
174
  */
package/dist/arrow.js CHANGED
@@ -207,6 +207,7 @@ exports.MakeArrowTableOptions = MakeArrowTableOptions;
207
207
  * - Record<String, any> => Struct
208
208
  * - Array<any> => List
209
209
  * @example
210
+ * ```ts
210
211
  * import { fromTableToBuffer, makeArrowTable } from "../arrow";
211
212
  * import { Field, FixedSizeList, Float16, Float32, Int32, Schema } from "apache-arrow";
212
213
  *
@@ -228,43 +229,41 @@ exports.MakeArrowTableOptions = MakeArrowTableOptions;
228
229
  * names and data types.
229
230
  *
230
231
  * ```ts
231
- *
232
232
  * const schema = new Schema([
233
- new Field("a", new Float64()),
234
- new Field("b", new Float64()),
235
- new Field(
236
- "vector",
237
- new FixedSizeList(3, new Field("item", new Float32()))
238
- ),
239
- ]);
240
- const table = makeArrowTable([
241
- { a: 1, b: 2, vector: [1, 2, 3] },
242
- { a: 4, b: 5, vector: [4, 5, 6] },
243
- { a: 7, b: 8, vector: [7, 8, 9] },
244
- ]);
245
- assert.deepEqual(table.schema, schema);
233
+ * new Field("a", new Float64()),
234
+ * new Field("b", new Float64()),
235
+ * new Field(
236
+ * "vector",
237
+ * new FixedSizeList(3, new Field("item", new Float32()))
238
+ * ),
239
+ * ]);
240
+ * const table = makeArrowTable([
241
+ * { a: 1, b: 2, vector: [1, 2, 3] },
242
+ * { a: 4, b: 5, vector: [4, 5, 6] },
243
+ * { a: 7, b: 8, vector: [7, 8, 9] },
244
+ * ]);
245
+ * assert.deepEqual(table.schema, schema);
246
246
  * ```
247
247
  *
248
248
  * You can specify the vector column types and names using the options as well
249
249
  *
250
- * ```typescript
251
- *
250
+ * ```ts
252
251
  * const schema = new Schema([
253
- new Field('a', new Float64()),
254
- new Field('b', new Float64()),
255
- new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
256
- new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
257
- ]);
252
+ * new Field('a', new Float64()),
253
+ * new Field('b', new Float64()),
254
+ * new Field('vec1', new FixedSizeList(3, new Field('item', new Float16()))),
255
+ * new Field('vec2', new FixedSizeList(3, new Field('item', new Float16())))
256
+ * ]);
258
257
  * const table = makeArrowTable([
259
- { a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
260
- { a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
261
- { a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
262
- ], {
263
- vectorColumns: {
264
- vec1: { type: new Float16() },
265
- vec2: { type: new Float16() }
266
- }
267
- }
258
+ * { a: 1, b: 2, vec1: [1, 2, 3], vec2: [2, 4, 6] },
259
+ * { a: 4, b: 5, vec1: [4, 5, 6], vec2: [8, 10, 12] },
260
+ * { a: 7, b: 8, vec1: [7, 8, 9], vec2: [14, 16, 18] }
261
+ * ], {
262
+ * vectorColumns: {
263
+ * vec1: { type: new Float16() },
264
+ * vec2: { type: new Float16() }
265
+ * }
266
+ * }
268
267
  * assert.deepEqual(table.schema, schema)
269
268
  * ```
270
269
  */
@@ -105,6 +105,7 @@ export interface TableNamesOptions {
105
105
  *
106
106
  * Any created tables are independent and will continue to work even if
107
107
  * the underlying connection has been closed.
108
+ * @hideconstructor
108
109
  */
109
110
  export declare abstract class Connection {
110
111
  /**
@@ -167,8 +168,10 @@ export declare abstract class Connection {
167
168
  */
168
169
  abstract dropTable(name: string): Promise<void>;
169
170
  }
171
+ /** @hideconstructor */
170
172
  export declare class LocalConnection extends Connection {
171
173
  readonly inner: LanceDbConnection;
174
+ /** @hidden */
172
175
  constructor(inner: LanceDbConnection);
173
176
  isOpen(): boolean;
174
177
  close(): void;
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.LocalConnection = exports.Connection = void 0;
6
6
  exports.cleanseStorageOptions = cleanseStorageOptions;
7
7
  const arrow_1 = require("./arrow");
8
+ const arrow_2 = require("./arrow");
8
9
  const registry_1 = require("./embedding/registry");
10
+ const sanitize_1 = require("./sanitize");
9
11
  const table_1 = require("./table");
10
12
  /**
11
13
  * A LanceDB Connection that allows you to open tables and create new ones.
@@ -24,6 +26,7 @@ const table_1 = require("./table");
24
26
  *
25
27
  * Any created tables are independent and will continue to work even if
26
28
  * the underlying connection has been closed.
29
+ * @hideconstructor
27
30
  */
28
31
  class Connection {
29
32
  [Symbol.for("nodejs.util.inspect.custom")]() {
@@ -31,8 +34,10 @@ class Connection {
31
34
  }
32
35
  }
33
36
  exports.Connection = Connection;
37
+ /** @hideconstructor */
34
38
  class LocalConnection extends Connection {
35
39
  inner;
40
+ /** @hidden */
36
41
  constructor(inner) {
37
42
  super();
38
43
  this.inner = inner;
@@ -61,7 +66,7 @@ class LocalConnection extends Connection {
61
66
  if (data === undefined) {
62
67
  throw new Error("data is required");
63
68
  }
64
- const { buf, mode } = await table_1.Table.parseTableData(data, options);
69
+ const { buf, mode } = await parseTableData(data, options);
65
70
  let dataStorageVersion = "stable";
66
71
  if (options?.dataStorageVersion !== undefined) {
67
72
  dataStorageVersion = options.dataStorageVersion;
@@ -91,8 +96,8 @@ class LocalConnection extends Connection {
91
96
  else if (options?.useLegacyFormat !== undefined) {
92
97
  dataStorageVersion = options.useLegacyFormat ? "legacy" : "stable";
93
98
  }
94
- const table = (0, arrow_1.makeEmptyTable)(schema, metadata);
95
- const buf = await (0, arrow_1.fromTableToBuffer)(table);
99
+ const table = (0, arrow_2.makeEmptyTable)(schema, metadata);
100
+ const buf = await (0, arrow_2.fromTableToBuffer)(table);
96
101
  const innerTable = await this.inner.createEmptyTable(name, buf, mode, cleanseStorageOptions(options?.storageOptions), dataStorageVersion, options?.enableV2ManifestPaths);
97
102
  return new table_1.LocalTable(innerTable);
98
103
  }
@@ -136,3 +141,25 @@ function camelToSnakeCase(camel) {
136
141
  }
137
142
  return result;
138
143
  }
144
+ async function parseTableData(data, options, streaming = false) {
145
+ let mode = options?.mode ?? "create";
146
+ const existOk = options?.existOk ?? false;
147
+ if (mode === "create" && existOk) {
148
+ mode = "exist_ok";
149
+ }
150
+ let table;
151
+ if ((0, arrow_1.isArrowTable)(data)) {
152
+ table = (0, sanitize_1.sanitizeTable)(data);
153
+ }
154
+ else {
155
+ table = (0, arrow_1.makeArrowTable)(data, options);
156
+ }
157
+ if (streaming) {
158
+ const buf = await (0, arrow_1.fromTableToStreamBuffer)(table, options?.embeddingFunction, options?.schema);
159
+ return { buf, mode };
160
+ }
161
+ else {
162
+ const buf = await (0, arrow_2.fromTableToBuffer)(table, options?.embeddingFunction, options?.schema);
163
+ return { buf, mode };
164
+ }
165
+ }
@@ -50,15 +50,15 @@ export declare abstract class EmbeddingFunction<T = any, M extends FunctionOptio
50
50
  *
51
51
  * @param optionsOrDatatype - The options for the field or the datatype
52
52
  *
53
- * @see {@link lancedb.LanceSchema}
53
+ * @see {@link LanceSchema}
54
54
  */
55
55
  sourceField(optionsOrDatatype: Partial<FieldOptions> | DataType): [DataType, Map<string, EmbeddingFunction>];
56
56
  /**
57
57
  * vectorField is used in combination with `LanceSchema` to provide a declarative data model
58
58
  *
59
- * @param options - The options for the field
59
+ * @param optionsOrDatatype - The options for the field
60
60
  *
61
- * @see {@link lancedb.LanceSchema}
61
+ * @see {@link LanceSchema}
62
62
  */
63
63
  vectorField(optionsOrDatatype?: Partial<FieldOptions> | DataType): [DataType, Map<string, EmbeddingFunction>];
64
64
  /** The number of dimensions of the embeddings */
@@ -21,7 +21,7 @@ class EmbeddingFunction {
21
21
  *
22
22
  * @param optionsOrDatatype - The options for the field or the datatype
23
23
  *
24
- * @see {@link lancedb.LanceSchema}
24
+ * @see {@link LanceSchema}
25
25
  */
26
26
  sourceField(optionsOrDatatype) {
27
27
  let datatype = "datatype" in optionsOrDatatype
@@ -38,9 +38,9 @@ class EmbeddingFunction {
38
38
  /**
39
39
  * vectorField is used in combination with `LanceSchema` to provide a declarative data model
40
40
  *
41
- * @param options - The options for the field
41
+ * @param optionsOrDatatype - The options for the field
42
42
  *
43
- * @see {@link lancedb.LanceSchema}
43
+ * @see {@link LanceSchema}
44
44
  */
45
45
  vectorField(optionsOrDatatype) {
46
46
  let dtype;
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "../arrow";
2
2
  import { EmbeddingFunction } from "./embedding_function";
3
- export { EmbeddingFunction, TextEmbeddingFunction } from "./embedding_function";
3
+ export { FieldOptions, EmbeddingFunction, TextEmbeddingFunction, FunctionOptions, EmbeddingFunctionConstructor, } from "./embedding_function";
4
4
  export * from "./registry";
5
5
  /**
6
6
  * Create a schema with embedding functions.
@@ -1,9 +1,9 @@
1
1
  import { type EmbeddingFunction, type EmbeddingFunctionConstructor } from "./embedding_function";
2
2
  import "reflect-metadata";
3
- type CreateReturnType<T> = T extends {
3
+ export type CreateReturnType<T> = T extends {
4
4
  init: () => Promise<void>;
5
5
  } ? Promise<T> : T;
6
- interface EmbeddingFunctionCreate<T extends EmbeddingFunction> {
6
+ export interface EmbeddingFunctionCreate<T extends EmbeddingFunction> {
7
7
  create(options?: T["TOptions"]): CreateReturnType<T>;
8
8
  }
9
9
  /**
@@ -20,8 +20,6 @@ export declare class EmbeddingFunctionRegistry {
20
20
  length(): number;
21
21
  /**
22
22
  * Register an embedding function
23
- * @param name The name of the function
24
- * @param func The function to register
25
23
  * @throws Error if the function is already registered
26
24
  */
27
25
  register<T extends EmbeddingFunctionConstructor = EmbeddingFunctionConstructor>(this: EmbeddingFunctionRegistry, alias?: string): (ctor: T) => any;
@@ -52,4 +50,3 @@ export interface EmbeddingFunctionConfig {
52
50
  vectorColumn?: string;
53
51
  function: EmbeddingFunction;
54
52
  }
55
- export {};
@@ -22,8 +22,6 @@ class EmbeddingFunctionRegistry {
22
22
  }
23
23
  /**
24
24
  * Register an embedding function
25
- * @param name The name of the function
26
- * @param func The function to register
27
25
  * @throws Error if the function is already registered
28
26
  */
29
27
  register(alias) {
package/dist/index.d.ts CHANGED
@@ -1,13 +1,16 @@
1
1
  import { Connection } from "./connection";
2
2
  import { ConnectionOptions } from "./native.js";
3
- export { WriteOptions, WriteMode, AddColumnsSql, ColumnAlteration, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, } from "./native.js";
3
+ export { AddColumnsSql, ColumnAlteration, ConnectionOptions, IndexStatistics, IndexConfig, ClientConfig, TimeoutConfig, RetryConfig, OptimizeStats, CompactionStats, RemovalStats, } from "./native.js";
4
4
  export { makeArrowTable, MakeArrowTableOptions, Data, VectorColumnOptions, } from "./arrow";
5
- export { Connection, CreateTableOptions, TableNamesOptions, } from "./connection";
6
- export { ExecutableQuery, Query, QueryBase, VectorQuery, RecordBatchIterator, } from "./query";
7
- export { Index, IndexOptions, IvfPqOptions } from "./indices";
8
- export { Table, AddDataOptions, UpdateOptions, OptimizeOptions } from "./table";
5
+ export { Connection, CreateTableOptions, TableNamesOptions, OpenTableOptions, } from "./connection";
6
+ export { ExecutableQuery, Query, QueryBase, VectorQuery, QueryExecutionOptions, FullTextSearchOptions, RecordBatchIterator, } from "./query";
7
+ export { Index, IndexOptions, IvfPqOptions, HnswPqOptions, HnswSqOptions, FtsOptions, } from "./indices";
8
+ export { Table, AddDataOptions, UpdateOptions, OptimizeOptions, Version, } from "./table";
9
+ export { MergeInsertBuilder } from "./merge";
9
10
  export * as embedding from "./embedding";
10
11
  export * as rerankers from "./rerankers";
12
+ export { SchemaLike, TableLike, FieldLike, RecordBatchLike, DataLike, IntoVector, } from "./arrow";
13
+ export { IntoSql } from "./util";
11
14
  /**
12
15
  * Connect to a LanceDB instance at the given URI.
13
16
  *
@@ -19,6 +22,7 @@ export * as rerankers from "./rerankers";
19
22
  * @param {string} uri - The uri of the database. If the database uri starts
20
23
  * with `db://` then it connects to a remote database.
21
24
  * @see {@link ConnectionOptions} for more details on the URI format.
25
+ * @param options - The options to use when connecting to the database
22
26
  * @example
23
27
  * ```ts
24
28
  * const conn = await connect("/path/to/database");
@@ -31,7 +35,7 @@ export * as rerankers from "./rerankers";
31
35
  * });
32
36
  * ```
33
37
  */
34
- export declare function connect(uri: string, opts?: Partial<ConnectionOptions>): Promise<Connection>;
38
+ export declare function connect(uri: string, options?: Partial<ConnectionOptions>): Promise<Connection>;
35
39
  /**
36
40
  * Connect to a LanceDB instance at the given URI.
37
41
  *
@@ -50,6 +54,6 @@ export declare function connect(uri: string, opts?: Partial<ConnectionOptions>):
50
54
  * });
51
55
  * ```
52
56
  */
53
- export declare function connect(opts: Partial<ConnectionOptions> & {
57
+ export declare function connect(options: Partial<ConnectionOptions> & {
54
58
  uri: string;
55
59
  }): Promise<Connection>;
package/dist/index.js CHANGED
@@ -2,12 +2,10 @@
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.rerankers = exports.embedding = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.WriteMode = void 0;
5
+ exports.rerankers = exports.embedding = exports.MergeInsertBuilder = exports.Table = exports.Index = exports.RecordBatchIterator = exports.VectorQuery = exports.QueryBase = exports.Query = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = void 0;
6
6
  exports.connect = connect;
7
7
  const connection_1 = require("./connection");
8
8
  const native_js_1 = require("./native.js");
9
- var native_js_2 = require("./native.js");
10
- Object.defineProperty(exports, "WriteMode", { enumerable: true, get: function () { return native_js_2.WriteMode; } });
11
9
  var arrow_1 = require("./arrow");
12
10
  Object.defineProperty(exports, "makeArrowTable", { enumerable: true, get: function () { return arrow_1.makeArrowTable; } });
13
11
  Object.defineProperty(exports, "MakeArrowTableOptions", { enumerable: true, get: function () { return arrow_1.MakeArrowTableOptions; } });
@@ -23,14 +21,16 @@ var indices_1 = require("./indices");
23
21
  Object.defineProperty(exports, "Index", { enumerable: true, get: function () { return indices_1.Index; } });
24
22
  var table_1 = require("./table");
25
23
  Object.defineProperty(exports, "Table", { enumerable: true, get: function () { return table_1.Table; } });
24
+ var merge_1 = require("./merge");
25
+ Object.defineProperty(exports, "MergeInsertBuilder", { enumerable: true, get: function () { return merge_1.MergeInsertBuilder; } });
26
26
  exports.embedding = require("./embedding");
27
27
  exports.rerankers = require("./rerankers");
28
- async function connect(uriOrOptions, opts = {}) {
28
+ async function connect(uriOrOptions, options = {}) {
29
29
  let uri;
30
30
  if (typeof uriOrOptions !== "string") {
31
- const { uri: uri_, ...options } = uriOrOptions;
31
+ const { uri: uri_, ...opts } = uriOrOptions;
32
32
  uri = uri_;
33
- opts = options;
33
+ options = opts;
34
34
  }
35
35
  else {
36
36
  uri = uriOrOptions;
@@ -38,8 +38,8 @@ async function connect(uriOrOptions, opts = {}) {
38
38
  if (!uri) {
39
39
  throw new Error("uri is required");
40
40
  }
41
- opts = opts ?? {};
42
- opts.storageOptions = (0, connection_1.cleanseStorageOptions)(opts.storageOptions);
43
- const nativeConn = await native_js_1.Connection.new(uri, opts);
41
+ options = options ?? {};
42
+ options.storageOptions = (0, connection_1.cleanseStorageOptions)(options.storageOptions);
43
+ const nativeConn = await native_js_1.Connection.new(uri, options);
44
44
  return new connection_1.LocalConnection(nativeConn);
45
45
  }
package/dist/indices.d.ts CHANGED
@@ -426,8 +426,6 @@ export declare class Index {
426
426
  * The results of a full text search are ordered by relevance measured by BM25.
427
427
  *
428
428
  * You can combine filters with full text search.
429
- *
430
- * For now, the full text search index only supports English, and doesn't support phrase search.
431
429
  */
432
430
  static fts(options?: Partial<FtsOptions>): Index;
433
431
  /**
package/dist/indices.js CHANGED
@@ -86,8 +86,6 @@ class Index {
86
86
  * The results of a full text search are ordered by relevance measured by BM25.
87
87
  *
88
88
  * You can combine filters with full text search.
89
- *
90
- * For now, the full text search index only supports English, and doesn't support phrase search.
91
89
  */
92
90
  static fts(options) {
93
91
  return new Index(native_1.Index.fts(options?.withPosition, options?.baseTokenizer, options?.language, options?.maxTokenLength, options?.lowercase, options?.stem, options?.removeStopWords, options?.asciiFolding));
package/dist/native.d.ts CHANGED
@@ -228,17 +228,6 @@ export interface ConnectionOptions {
228
228
  */
229
229
  hostOverride?: string
230
230
  }
231
- /** Write mode for writing a table. */
232
- export enum WriteMode {
233
- Create = 'Create',
234
- Append = 'Append',
235
- Overwrite = 'Overwrite'
236
- }
237
- /** Write options when creating a Table. */
238
- export interface WriteOptions {
239
- /** Write mode for writing to a table. */
240
- mode?: WriteMode
241
- }
242
231
  export interface OpenTableOptions {
243
232
  storageOptions?: Record<string, string>
244
233
  }
package/dist/native.js CHANGED
@@ -319,7 +319,7 @@ if (!nativeBinding) {
319
319
  }
320
320
  throw new Error(`Failed to load native binding`);
321
321
  }
322
- const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, Reranker, RrfReranker, Table, WriteMode } = nativeBinding;
322
+ const { Connection, Index, RecordBatchIterator, NativeMergeInsertBuilder, Query, VectorQuery, Reranker, RrfReranker, Table } = nativeBinding;
323
323
  module.exports.Connection = Connection;
324
324
  module.exports.Index = Index;
325
325
  module.exports.RecordBatchIterator = RecordBatchIterator;
@@ -329,4 +329,3 @@ module.exports.VectorQuery = VectorQuery;
329
329
  module.exports.Reranker = Reranker;
330
330
  module.exports.RrfReranker = RrfReranker;
331
331
  module.exports.Table = Table;
332
- module.exports.WriteMode = WriteMode;
package/dist/query.d.ts CHANGED
@@ -32,10 +32,22 @@ export interface FullTextSearchOptions {
32
32
  */
33
33
  columns?: string | string[];
34
34
  }
35
- /** Common methods supported by all query types */
35
+ /** Common methods supported by all query types
36
+ *
37
+ * @see {@link Query}
38
+ * @see {@link VectorQuery}
39
+ *
40
+ * @hideconstructor
41
+ */
36
42
  export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVectorQuery> implements AsyncIterable<RecordBatch> {
37
43
  protected inner: NativeQueryType | Promise<NativeQueryType>;
44
+ /**
45
+ * @hidden
46
+ */
38
47
  protected constructor(inner: NativeQueryType | Promise<NativeQueryType>);
48
+ /**
49
+ * @hidden
50
+ */
39
51
  protected doCall(fn: (inner: NativeQueryType) => void): void;
40
52
  /**
41
53
  * A filter statement to be applied to this query.
@@ -52,7 +64,7 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
52
64
  where(predicate: string): this;
53
65
  /**
54
66
  * A filter statement to be applied to this query.
55
- * @alias where
67
+ * @see where
56
68
  * @deprecated Use `where` instead
57
69
  */
58
70
  filter(predicate: string): this;
@@ -100,7 +112,7 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
100
112
  * Skip searching un-indexed data. This can make search faster, but will miss
101
113
  * any data that is not yet indexed.
102
114
  *
103
- * Use {@link lancedb.Table#optimize} to index all un-indexed data.
115
+ * Use {@link Table#optimize} to index all un-indexed data.
104
116
  */
105
117
  fastSearch(): this;
106
118
  /**
@@ -111,6 +123,9 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
111
123
  * order to perform hybrid search.
112
124
  */
113
125
  withRowId(): this;
126
+ /**
127
+ * @hidden
128
+ */
114
129
  protected nativeExecute(options?: Partial<QueryExecutionOptions>): Promise<NativeBatchIterator>;
115
130
  /**
116
131
  * Execute the query and return the results as an @see {@link AsyncIterator}
@@ -124,6 +139,9 @@ export declare class QueryBase<NativeQueryType extends NativeQuery | NativeVecto
124
139
  *
125
140
  */
126
141
  protected execute(options?: Partial<QueryExecutionOptions>): RecordBatchIterator;
142
+ /**
143
+ * @hidden
144
+ */
127
145
  [Symbol.asyncIterator](): AsyncIterator<RecordBatch<any>>;
128
146
  /** Collect the results as an Arrow @see {@link ArrowTable}. */
129
147
  toArrow(options?: Partial<QueryExecutionOptions>): Promise<ArrowTable>;
@@ -156,8 +174,15 @@ export interface ExecutableQuery {
156
174
  * A builder used to construct a vector search
157
175
  *
158
176
  * This builder can be reused to execute the query many times.
177
+ *
178
+ * @see {@link Query#nearestTo}
179
+ *
180
+ * @hideconstructor
159
181
  */
160
182
  export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
183
+ /**
184
+ * @hidden
185
+ */
161
186
  constructor(inner: NativeVectorQuery | Promise<NativeVectorQuery>);
162
187
  /**
163
188
  * Set the number of partitions to search (probe)
@@ -282,8 +307,16 @@ export declare class VectorQuery extends QueryBase<NativeVectorQuery> {
282
307
  addQueryVector(vector: IntoVector): VectorQuery;
283
308
  rerank(reranker: Reranker): VectorQuery;
284
309
  }
285
- /** A builder for LanceDB queries. */
310
+ /** A builder for LanceDB queries.
311
+ *
312
+ * @see {@link Table#query}, {@link Table#search}
313
+ *
314
+ * @hideconstructor
315
+ */
286
316
  export declare class Query extends QueryBase<NativeQuery> {
317
+ /**
318
+ * @hidden
319
+ */
287
320
  constructor(tbl: NativeTable);
288
321
  /**
289
322
  * Find the nearest vectors to the given query vector.
package/dist/query.js CHANGED
@@ -44,14 +44,26 @@ class RecordBatchIterable {
44
44
  return new RecordBatchIterator(this.inner.execute(this.options?.maxBatchLength));
45
45
  }
46
46
  }
47
- /** Common methods supported by all query types */
47
+ /** Common methods supported by all query types
48
+ *
49
+ * @see {@link Query}
50
+ * @see {@link VectorQuery}
51
+ *
52
+ * @hideconstructor
53
+ */
48
54
  class QueryBase {
49
55
  inner;
56
+ /**
57
+ * @hidden
58
+ */
50
59
  constructor(inner) {
51
60
  this.inner = inner;
52
61
  // intentionally empty
53
62
  }
54
63
  // call a function on the inner (either a promise or the actual object)
64
+ /**
65
+ * @hidden
66
+ */
55
67
  doCall(fn) {
56
68
  if (this.inner instanceof Promise) {
57
69
  this.inner = this.inner.then((inner) => {
@@ -81,7 +93,7 @@ class QueryBase {
81
93
  }
82
94
  /**
83
95
  * A filter statement to be applied to this query.
84
- * @alias where
96
+ * @see where
85
97
  * @deprecated Use `where` instead
86
98
  */
87
99
  filter(predicate) {
@@ -173,7 +185,7 @@ class QueryBase {
173
185
  * Skip searching un-indexed data. This can make search faster, but will miss
174
186
  * any data that is not yet indexed.
175
187
  *
176
- * Use {@link lancedb.Table#optimize} to index all un-indexed data.
188
+ * Use {@link Table#optimize} to index all un-indexed data.
177
189
  */
178
190
  fastSearch() {
179
191
  this.doCall((inner) => inner.fastSearch());
@@ -190,6 +202,9 @@ class QueryBase {
190
202
  this.doCall((inner) => inner.withRowId());
191
203
  return this;
192
204
  }
205
+ /**
206
+ * @hidden
207
+ */
193
208
  nativeExecute(options) {
194
209
  if (this.inner instanceof Promise) {
195
210
  return this.inner.then((inner) => inner.execute(options?.maxBatchLength));
@@ -212,6 +227,9 @@ class QueryBase {
212
227
  execute(options) {
213
228
  return new RecordBatchIterator(this.nativeExecute(options));
214
229
  }
230
+ /**
231
+ * @hidden
232
+ */
215
233
  // biome-ignore lint/suspicious/noExplicitAny: skip
216
234
  [Symbol.asyncIterator]() {
217
235
  const promise = this.nativeExecute();
@@ -266,8 +284,15 @@ exports.QueryBase = QueryBase;
266
284
  * A builder used to construct a vector search
267
285
  *
268
286
  * This builder can be reused to execute the query many times.
287
+ *
288
+ * @see {@link Query#nearestTo}
289
+ *
290
+ * @hideconstructor
269
291
  */
270
292
  class VectorQuery extends QueryBase {
293
+ /**
294
+ * @hidden
295
+ */
271
296
  constructor(inner) {
272
297
  super(inner);
273
298
  }
@@ -472,8 +497,16 @@ class VectorQuery extends QueryBase {
472
497
  }
473
498
  }
474
499
  exports.VectorQuery = VectorQuery;
475
- /** A builder for LanceDB queries. */
500
+ /** A builder for LanceDB queries.
501
+ *
502
+ * @see {@link Table#query}, {@link Table#search}
503
+ *
504
+ * @hideconstructor
505
+ */
476
506
  class Query extends QueryBase {
507
+ /**
508
+ * @hidden
509
+ */
477
510
  constructor(tbl) {
478
511
  super(tbl.query());
479
512
  }
@@ -3,10 +3,11 @@ import { RrfReranker as NativeRRFReranker } from "../native";
3
3
  /**
4
4
  * Reranks the results using the Reciprocal Rank Fusion (RRF) algorithm.
5
5
  *
6
- * Internally this uses the Rust implementation
6
+ * @hideconstructor
7
7
  */
8
8
  export declare class RRFReranker {
9
9
  private inner;
10
+ /** @ignore */
10
11
  constructor(inner: NativeRRFReranker);
11
12
  static create(k?: number): Promise<RRFReranker>;
12
13
  rerankHybrid(query: string, vecResults: RecordBatch, ftsResults: RecordBatch): Promise<RecordBatch>;
@@ -8,10 +8,11 @@ const native_1 = require("../native");
8
8
  /**
9
9
  * Reranks the results using the Reciprocal Rank Fusion (RRF) algorithm.
10
10
  *
11
- * Internally this uses the Rust implementation
11
+ * @hideconstructor
12
12
  */
13
13
  class RRFReranker {
14
14
  inner;
15
+ /** @ignore */
15
16
  constructor(inner) {
16
17
  this.inner = inner;
17
18
  }
package/dist/table.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { Table as ArrowTable, Data, IntoVector, Schema, TableLike } from "./arrow";
2
- import { CreateTableOptions } from "./connection";
1
+ import { Table as ArrowTable, Data, IntoVector, Schema } from "./arrow";
3
2
  import { IndexOptions } from "./indices";
4
3
  import { MergeInsertBuilder } from "./merge";
5
4
  import { AddColumnsSql, ColumnAlteration, IndexConfig, IndexStatistics, OptimizeStats, Table as _NativeTable } from "./native";
@@ -61,8 +60,14 @@ export interface Version {
61
60
  * can call the `close` method. Once the Table is closed, it cannot be used for any
62
61
  * further operations.
63
62
  *
63
+ * Tables are created using the methods {@link Connection#createTable}
64
+ * and {@link Connection#createEmptyTable}. Existing tables are opened
65
+ * using {@link Connection#openTable}.
66
+ *
64
67
  * Closing a table is optional. It not closed, it will be closed when it is garbage
65
68
  * collected.
69
+ *
70
+ * @hideconstructor
66
71
  */
67
72
  export declare abstract class Table {
68
73
  /** Returns the name of the table */
@@ -148,8 +153,9 @@ export declare abstract class Table {
148
153
  * Indices on scalar columns will speed up filtering (in both
149
154
  * vector and non-vector searches)
150
155
  *
151
- * @note We currently don't support custom named indexes,
152
- * The index name will always be `${column}_idx`
156
+ * We currently don't support custom named indexes.
157
+ * The index name will always be `${column}_idx`.
158
+ *
153
159
  * @example
154
160
  * // If the column has a vector (fixed size list) data type then
155
161
  * // an IvfPq vector index will be created.
@@ -175,7 +181,7 @@ export declare abstract class Table {
175
181
  *
176
182
  * @param name The name of the index.
177
183
  *
178
- * @note This does not delete the index from disk, it just removes it from the table.
184
+ * This does not delete the index from disk, it just removes it from the table.
179
185
  * To delete the index, run {@link Table#optimize} after dropping the index.
180
186
  *
181
187
  * Use {@link Table.listIndices} to find the names of the indices.
@@ -374,10 +380,6 @@ export declare abstract class Table {
374
380
  * Use {@link Table.listIndices} to find the names of the indices.
375
381
  */
376
382
  abstract indexStats(name: string): Promise<IndexStatistics | undefined>;
377
- static parseTableData(data: Record<string, unknown>[] | TableLike, options?: Partial<CreateTableOptions>, streaming?: boolean): Promise<{
378
- buf: Buffer;
379
- mode: string;
380
- }>;
381
383
  }
382
384
  export declare class LocalTable extends Table {
383
385
  private readonly inner;
package/dist/table.js CHANGED
@@ -7,7 +7,6 @@ const arrow_1 = require("./arrow");
7
7
  const registry_1 = require("./embedding/registry");
8
8
  const merge_1 = require("./merge");
9
9
  const query_1 = require("./query");
10
- const sanitize_1 = require("./sanitize");
11
10
  const util_1 = require("./util");
12
11
  /**
13
12
  * A Table is a collection of Records in a LanceDB Database.
@@ -18,35 +17,19 @@ const util_1 = require("./util");
18
17
  * can call the `close` method. Once the Table is closed, it cannot be used for any
19
18
  * further operations.
20
19
  *
20
+ * Tables are created using the methods {@link Connection#createTable}
21
+ * and {@link Connection#createEmptyTable}. Existing tables are opened
22
+ * using {@link Connection#openTable}.
23
+ *
21
24
  * Closing a table is optional. It not closed, it will be closed when it is garbage
22
25
  * collected.
26
+ *
27
+ * @hideconstructor
23
28
  */
24
29
  class Table {
25
30
  [Symbol.for("nodejs.util.inspect.custom")]() {
26
31
  return this.display();
27
32
  }
28
- static async parseTableData(data, options, streaming = false) {
29
- let mode = options?.mode ?? "create";
30
- const existOk = options?.existOk ?? false;
31
- if (mode === "create" && existOk) {
32
- mode = "exist_ok";
33
- }
34
- let table;
35
- if ((0, arrow_1.isArrowTable)(data)) {
36
- table = (0, sanitize_1.sanitizeTable)(data);
37
- }
38
- else {
39
- table = (0, arrow_1.makeArrowTable)(data, options);
40
- }
41
- if (streaming) {
42
- const buf = await (0, arrow_1.fromTableToStreamBuffer)(table, options?.embeddingFunction, options?.schema);
43
- return { buf, mode };
44
- }
45
- else {
46
- const buf = await (0, arrow_1.fromTableToBuffer)(table, options?.embeddingFunction, options?.schema);
47
- return { buf, mode };
48
- }
49
- }
50
33
  }
51
34
  exports.Table = Table;
52
35
  class LocalTable extends Table {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "ann"
12
12
  ],
13
13
  "private": false,
14
- "version": "0.15.1-beta.2",
14
+ "version": "0.15.1-beta.3",
15
15
  "main": "dist/index.js",
16
16
  "exports": {
17
17
  ".": "./dist/index.js",
@@ -84,7 +84,7 @@
84
84
  "build": "npm run build:debug && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts && shx cp lancedb/*.node dist/",
85
85
  "build-release": "npm run build:release && tsc -b && shx cp lancedb/native.d.ts dist/native.d.ts",
86
86
  "lint-ci": "biome ci .",
87
- "docs": "typedoc --plugin typedoc-plugin-markdown --out ../docs/src/js lancedb/index.ts",
87
+ "docs": "typedoc --plugin typedoc-plugin-markdown --treatWarningsAsErrors --out ../docs/src/js lancedb/index.ts",
88
88
  "postdocs": "node typedoc_post_process.js",
89
89
  "lint": "biome check . && biome format .",
90
90
  "lint-fix": "biome check --write . && biome format --write .",
@@ -98,14 +98,14 @@
98
98
  "reflect-metadata": "^0.2.2"
99
99
  },
100
100
  "optionalDependencies": {
101
- "@lancedb/lancedb-darwin-x64": "0.15.1-beta.2",
102
- "@lancedb/lancedb-darwin-arm64": "0.15.1-beta.2",
103
- "@lancedb/lancedb-linux-x64-gnu": "0.15.1-beta.2",
104
- "@lancedb/lancedb-linux-arm64-gnu": "0.15.1-beta.2",
105
- "@lancedb/lancedb-linux-x64-musl": "0.15.1-beta.2",
106
- "@lancedb/lancedb-linux-arm64-musl": "0.15.1-beta.2",
107
- "@lancedb/lancedb-win32-x64-msvc": "0.15.1-beta.2",
108
- "@lancedb/lancedb-win32-arm64-msvc": "0.15.1-beta.2"
101
+ "@lancedb/lancedb-darwin-x64": "0.15.1-beta.3",
102
+ "@lancedb/lancedb-darwin-arm64": "0.15.1-beta.3",
103
+ "@lancedb/lancedb-linux-x64-gnu": "0.15.1-beta.3",
104
+ "@lancedb/lancedb-linux-arm64-gnu": "0.15.1-beta.3",
105
+ "@lancedb/lancedb-linux-x64-musl": "0.15.1-beta.3",
106
+ "@lancedb/lancedb-linux-arm64-musl": "0.15.1-beta.3",
107
+ "@lancedb/lancedb-win32-x64-msvc": "0.15.1-beta.3",
108
+ "@lancedb/lancedb-win32-arm64-msvc": "0.15.1-beta.3"
109
109
  },
110
110
  "peerDependencies": {
111
111
  "apache-arrow": ">=15.0.0 <=18.1.0"
@@ -40,23 +40,28 @@ function processDirectory(directoryPath) {
40
40
  function processContents(contents) {
41
41
  // This changes the parameters section to put the parameter description on
42
42
  // the same line as the bullet with the parameter name and type.
43
- return contents.replace(/(## Parameters[\s\S]*?)(?=##|$)/g, (match) => {
44
- let lines = match
45
- .split("\n")
46
- .map((line) => line.trim())
47
-
48
- .filter((line) => line !== "")
49
- .map((line) => {
50
- if (line.startsWith("##")) {
51
- return line;
52
- } else if (line.startsWith("")) {
53
- return "\n*" + line.substring(1);
54
- } else {
55
- return " " + line;
56
- }
57
- });
58
- return lines.join("\n") + "\n\n";
59
- });
43
+ return (
44
+ contents
45
+ .replace(/(## Parameters[\s\S]*?)(?=##|$)/g, (match) => {
46
+ let lines = match
47
+ .split("\n")
48
+ .map((line) => line.trim())
49
+
50
+ .filter((line) => line !== "")
51
+ .map((line) => {
52
+ if (line.startsWith("##")) {
53
+ return line;
54
+ } else if (line.startsWith("•")) {
55
+ return "\n*" + line.substring(1);
56
+ } else {
57
+ return " " + line;
58
+ }
59
+ });
60
+ return lines.join("\n") + "\n\n";
61
+ })
62
+ // Also trim trailing whitespace
63
+ .replace(/([^ \t])[ \t]+\n/g, "$1\n")
64
+ );
60
65
  }
61
66
 
62
67
  // Start processing from the root directory