@openclaw/memory-lancedb 2026.9.3 → 2026.9.5

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.
@@ -1,4 +1,49 @@
1
- import { a as __toCommonJS, i as __require, n as __esmMin, r as __exportAll, t as __commonJSMin } from "./rolldown-runtime-BMI-E3GI.js";
1
+ import { a as __toCommonJS, i as __require, n as __esmMin, r as __exportAll, t as __commonJSMin } from "./rolldown-runtime-BMI-E3GI.mjs";
2
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/arrow_type.js
3
+ var require_arrow_type = /* @__PURE__ */ __commonJSMin(((exports) => {
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.typedArrayToArrowType = typedArrayToArrowType;
6
+ const apache_arrow_1$4 = __require("apache-arrow");
7
+ /**
8
+ * Map a JS TypedArray instance to the corresponding Arrow element type and
9
+ * length. Returns undefined when the view is not a supported TypedArray.
10
+ */
11
+ function typedArrayToArrowType(value) {
12
+ if (value instanceof Float32Array) return {
13
+ elementType: new apache_arrow_1$4.Float32(),
14
+ length: value.length
15
+ };
16
+ if (value instanceof Float64Array) return {
17
+ elementType: new apache_arrow_1$4.Float64(),
18
+ length: value.length
19
+ };
20
+ if (value instanceof Uint8Array) return {
21
+ elementType: new apache_arrow_1$4.Uint8(),
22
+ length: value.length
23
+ };
24
+ if (value instanceof Uint16Array) return {
25
+ elementType: new apache_arrow_1$4.Uint16(),
26
+ length: value.length
27
+ };
28
+ if (value instanceof Uint32Array) return {
29
+ elementType: new apache_arrow_1$4.Uint32(),
30
+ length: value.length
31
+ };
32
+ if (value instanceof Int8Array) return {
33
+ elementType: new apache_arrow_1$4.Int8(),
34
+ length: value.length
35
+ };
36
+ if (value instanceof Int16Array) return {
37
+ elementType: new apache_arrow_1$4.Int16(),
38
+ length: value.length
39
+ };
40
+ if (value instanceof Int32Array) return {
41
+ elementType: new apache_arrow_1$4.Int32(),
42
+ length: value.length
43
+ };
44
+ }
45
+ }));
46
+ //#endregion
2
47
  //#region node_modules/.pnpm/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js
3
48
  var require_Reflect = /* @__PURE__ */ __commonJSMin((() => {
4
49
  /*! *****************************************************************************
@@ -1223,13 +1268,16 @@ var require_Reflect = /* @__PURE__ */ __commonJSMin((() => {
1223
1268
  })(Reflect || (Reflect = {}));
1224
1269
  }));
1225
1270
  //#endregion
1226
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/registry.js
1271
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/registry.js
1227
1272
  var require_registry = /* @__PURE__ */ __commonJSMin(((exports) => {
1228
1273
  Object.defineProperty(exports, "__esModule", { value: true });
1229
1274
  exports.EmbeddingFunctionRegistry = void 0;
1230
1275
  exports.register = register;
1276
+ exports.registerBuiltIn = registerBuiltIn;
1231
1277
  exports.getRegistry = getRegistry;
1278
+ exports.parseEmbeddingMetadata = parseEmbeddingMetadata;
1232
1279
  require_Reflect();
1280
+ const builtInFunctionsKey = Symbol.for("@lancedb/lancedb::embedding-built-in-functions::v1");
1233
1281
  /**
1234
1282
  * This is a singleton class used to register embedding functions
1235
1283
  * and fetch them by name. It also handles serializing and deserializing.
@@ -1259,6 +1307,12 @@ var require_registry = /* @__PURE__ */ __commonJSMin(((exports) => {
1259
1307
  return ctor;
1260
1308
  };
1261
1309
  }
1310
+ /** @ignore */
1311
+ setBuiltIn(name, ctor) {
1312
+ this.#functions.set(name, ctor);
1313
+ Reflect.defineMetadata("lancedb::embedding::name", name, ctor);
1314
+ return ctor;
1315
+ }
1262
1316
  /**
1263
1317
  * Fetch an embedding function by name
1264
1318
  * @param name The name of the function
@@ -1280,25 +1334,25 @@ var require_registry = /* @__PURE__ */ __commonJSMin(((exports) => {
1280
1334
  */
1281
1335
  reset() {
1282
1336
  this.#functions.clear();
1337
+ getBuiltInFunctions(this).clear();
1283
1338
  }
1284
1339
  /**
1285
1340
  * @ignore
1286
1341
  */
1287
1342
  async parseFunctions(metadata) {
1288
1343
  if (!metadata.has("embedding_functions")) return /* @__PURE__ */ new Map();
1289
- else {
1290
- const functions = JSON.parse(metadata.get("embedding_functions"));
1291
- const items = await Promise.all(functions.map(async (f) => {
1292
- if (!this.get(f.name)) throw new Error(`Function "${f.name}" not found in registry`);
1293
- const func = await this.get(f.name).create(f.model);
1294
- return [f.name, {
1295
- sourceColumn: f.sourceColumn,
1296
- vectorColumn: f.vectorColumn,
1297
- function: func
1298
- }];
1299
- }));
1300
- return new Map(items);
1301
- }
1344
+ const entries = parseEmbeddingMetadata(metadata.get("embedding_functions"));
1345
+ const items = await Promise.all(entries.map(async (f) => {
1346
+ const fn = this.get(f.name);
1347
+ if (!fn) throw new Error(`Function "${f.name}" not found in registry`);
1348
+ const func = await fn.create(f.model);
1349
+ return {
1350
+ sourceColumn: f.sourceColumn,
1351
+ vectorColumn: f.vectorColumn,
1352
+ function: func
1353
+ };
1354
+ }));
1355
+ return new Map(items.map((config) => [config.vectorColumn, config]));
1302
1356
  }
1303
1357
  functionToMetadata(conf) {
1304
1358
  const metadata = {};
@@ -1344,10 +1398,36 @@ var require_registry = /* @__PURE__ */ __commonJSMin(((exports) => {
1344
1398
  }
1345
1399
  };
1346
1400
  exports.EmbeddingFunctionRegistry = EmbeddingFunctionRegistry;
1347
- const _REGISTRY = new EmbeddingFunctionRegistry();
1401
+ function getBuiltInFunctions(registry) {
1402
+ const registryWithBuiltIns = registry;
1403
+ let builtInFunctions = registryWithBuiltIns[builtInFunctionsKey];
1404
+ if (builtInFunctions === void 0) {
1405
+ builtInFunctions = /* @__PURE__ */ new Set();
1406
+ registryWithBuiltIns[builtInFunctionsKey] = builtInFunctions;
1407
+ }
1408
+ return builtInFunctions;
1409
+ }
1410
+ const registryKey = Symbol.for("@lancedb/lancedb::embedding-function-registry::v1");
1411
+ const registryGlobal = globalThis;
1412
+ function getGlobalRegistry() {
1413
+ const existingRegistry = registryGlobal[registryKey];
1414
+ if (existingRegistry !== void 0) return existingRegistry;
1415
+ const registry = new EmbeddingFunctionRegistry();
1416
+ registryGlobal[registryKey] = registry;
1417
+ return registry;
1418
+ }
1419
+ const _REGISTRY = getGlobalRegistry();
1348
1420
  function register(name) {
1349
1421
  return _REGISTRY.register(name);
1350
1422
  }
1423
+ /** @ignore */
1424
+ function registerBuiltIn(name, ctor) {
1425
+ const builtInFunctions = getBuiltInFunctions(_REGISTRY);
1426
+ if (builtInFunctions.has(name)) return _REGISTRY.setBuiltIn(name, ctor);
1427
+ _REGISTRY.register(name)(ctor);
1428
+ builtInFunctions.add(name);
1429
+ return ctor;
1430
+ }
1351
1431
  /**
1352
1432
  * Utility function to get the global instance of the registry
1353
1433
  * @returns `EmbeddingFunctionRegistry` The global instance of the registry
@@ -1359,9 +1439,28 @@ var require_registry = /* @__PURE__ */ __commonJSMin(((exports) => {
1359
1439
  function getRegistry() {
1360
1440
  return _REGISTRY;
1361
1441
  }
1442
+ /** The single parser for `embedding_functions` schema metadata: every reader
1443
+ * goes through here, so the wire contract cannot fork between them. */
1444
+ function parseEmbeddingMetadata(json) {
1445
+ const entries = JSON.parse(json);
1446
+ const seen = /* @__PURE__ */ new Set();
1447
+ return entries.map((f) => {
1448
+ const sourceColumn = f.sourceColumn ?? f.source_column;
1449
+ const vectorColumn = f.vectorColumn ?? f.vector_column;
1450
+ if (sourceColumn === void 0 || vectorColumn === void 0) throw new Error(`Embedding function "${f.name}" metadata names no source or vector column`);
1451
+ if (seen.has(vectorColumn)) throw new Error(`Multiple embedding configs claim vector column "${vectorColumn}"`);
1452
+ seen.add(vectorColumn);
1453
+ return {
1454
+ name: f.name,
1455
+ sourceColumn,
1456
+ vectorColumn,
1457
+ model: f.model
1458
+ };
1459
+ });
1460
+ }
1362
1461
  }));
1363
1462
  //#endregion
1364
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/sanitize.js
1463
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/sanitize.js
1365
1464
  var require_sanitize = /* @__PURE__ */ __commonJSMin(((exports) => {
1366
1465
  Object.defineProperty(exports, "__esModule", { value: true });
1367
1466
  exports.sanitizeMetadata = sanitizeMetadata;
@@ -1387,7 +1486,7 @@ var require_sanitize = /* @__PURE__ */ __commonJSMin(((exports) => {
1387
1486
  exports.sanitizeSchema = sanitizeSchema;
1388
1487
  exports.sanitizeTable = sanitizeTable;
1389
1488
  exports.dataTypeFromName = dataTypeFromName;
1390
- const apache_arrow_1$2 = __require("apache-arrow");
1489
+ const apache_arrow_1$3 = __require("apache-arrow");
1391
1490
  const arrow_1 = require_arrow();
1392
1491
  function createSanitizationContext() {
1393
1492
  return {
@@ -1398,9 +1497,18 @@ var require_sanitize = /* @__PURE__ */ __commonJSMin(((exports) => {
1398
1497
  }
1399
1498
  function sanitizeMetadata(metadataLike) {
1400
1499
  if (metadataLike === void 0 || metadataLike === null) return;
1401
- if (!(metadataLike instanceof Map)) throw Error("Expected metadata, if present, to be a Map<string, string>");
1402
- for (const item of metadataLike) if (typeof item[0] !== "string" || typeof item[1] !== "string") throw Error("Expected metadata, if present, to be a Map<string, string> but it had non-string keys or values");
1403
- return metadataLike;
1500
+ let entries;
1501
+ try {
1502
+ entries = Map.prototype.entries.call(metadataLike);
1503
+ } catch {
1504
+ throw Error("Expected metadata, if present, to be a Map<string, string>");
1505
+ }
1506
+ const metadata = /* @__PURE__ */ new Map();
1507
+ for (const [key, value] of entries) {
1508
+ if (typeof key !== "string" || typeof value !== "string") throw Error("Expected metadata, if present, to be a Map<string, string> but it had non-string keys or values");
1509
+ metadata.set(key, value);
1510
+ }
1511
+ return metadata;
1404
1512
  }
1405
1513
  function sanitizeInt(typeLike) {
1406
1514
  if (!("bitWidth" in typeLike) || typeof typeLike.bitWidth !== "number" || !("isSigned" in typeLike) || typeof typeLike.isSigned !== "boolean") throw Error("Expected an Int Type to have a `bitWidth` and `isSigned` property");
@@ -1636,7 +1744,7 @@ var require_sanitize = /* @__PURE__ */ __commonJSMin(((exports) => {
1636
1744
  return new arrow_1.RecordBatch(schema, data);
1637
1745
  }
1638
1746
  function sanitizeData(dataLike, context) {
1639
- if (dataLike instanceof apache_arrow_1$2.Data) return dataLike;
1747
+ if (dataLike instanceof apache_arrow_1$3.Data) return dataLike;
1640
1748
  const cachedData = context.data.get(dataLike);
1641
1749
  if (cachedData !== void 0) return cachedData;
1642
1750
  const dictionaryLike = dataLike.dictionary;
@@ -1644,15 +1752,15 @@ var require_sanitize = /* @__PURE__ */ __commonJSMin(((exports) => {
1644
1752
  if (dictionaryLike !== void 0) {
1645
1753
  dictionary = context.vectors.get(dictionaryLike);
1646
1754
  if (dictionary === void 0) {
1647
- dictionary = new apache_arrow_1$2.Vector(dictionaryLike.data.map((data) => sanitizeData(data, context)));
1755
+ dictionary = new apache_arrow_1$3.Vector(dictionaryLike.data.map((data) => sanitizeData(data, context)));
1648
1756
  context.vectors.set(dictionaryLike, dictionary);
1649
1757
  }
1650
1758
  }
1651
- const data = new apache_arrow_1$2.Data(sanitizeTypeWithContext(dataLike.type, context), dataLike.offset, dataLike.length, dataLike.nullCount, {
1652
- [apache_arrow_1$2.BufferType.OFFSET]: dataLike.valueOffsets,
1653
- [apache_arrow_1$2.BufferType.DATA]: dataLike.values,
1654
- [apache_arrow_1$2.BufferType.VALIDITY]: dataLike.nullBitmap,
1655
- [apache_arrow_1$2.BufferType.TYPE]: dataLike.typeIds
1759
+ const data = new apache_arrow_1$3.Data(sanitizeTypeWithContext(dataLike.type, context), dataLike.offset, dataLike.length, dataLike.nullCount, {
1760
+ [apache_arrow_1$3.BufferType.OFFSET]: dataLike.valueOffsets,
1761
+ [apache_arrow_1$3.BufferType.DATA]: dataLike.values,
1762
+ [apache_arrow_1$3.BufferType.VALIDITY]: dataLike.nullBitmap,
1763
+ [apache_arrow_1$3.BufferType.TYPE]: dataLike.typeIds
1656
1764
  }, dataLike.children.map((child) => sanitizeData(child, context)), dictionary);
1657
1765
  context.data.set(dataLike, data);
1658
1766
  return data;
@@ -1694,7 +1802,264 @@ var require_sanitize = /* @__PURE__ */ __commonJSMin(((exports) => {
1694
1802
  }
1695
1803
  }));
1696
1804
  //#endregion
1697
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/arrow.js
1805
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/schema.js
1806
+ var require_schema = /* @__PURE__ */ __commonJSMin(((exports) => {
1807
+ Object.defineProperty(exports, "__esModule", { value: true });
1808
+ exports.inferSchema = inferSchema;
1809
+ const apache_arrow_1$2 = __require("apache-arrow");
1810
+ const arrow_type_1 = require_arrow_type();
1811
+ const sanitize_1 = require_sanitize();
1812
+ /**
1813
+ * Infer the Arrow schema represented by a set of records.
1814
+ *
1815
+ * This is the intentionally small interface to schema inference. The stateful
1816
+ * details of combining partial type evidence are encapsulated below so callers
1817
+ * only need to provide records, an optional schema, and inference options.
1818
+ */
1819
+ function inferSchema(data, schema, options) {
1820
+ return new SchemaInferrer(schema, options).infer(data);
1821
+ }
1822
+ var SchemaInferrer = class {
1823
+ providedSchema;
1824
+ options;
1825
+ fields = new FieldTree();
1826
+ constructor(providedSchema, options) {
1827
+ this.providedSchema = providedSchema;
1828
+ this.options = options;
1829
+ }
1830
+ infer(data) {
1831
+ for (const [row, record] of data.entries()) for (const [path, value] of recordPathsAndValues(record)) this.observe(path, value, row);
1832
+ return this.providedSchema === void 0 ? new apache_arrow_1$2.Schema(fieldsFromTree(this.fields)) : new apache_arrow_1$2.Schema(matchingFields(this.providedSchema.fields, this.fields));
1833
+ }
1834
+ observe(path, value, row) {
1835
+ const current = this.fields.get(path);
1836
+ if (current === void 0) this.addField(path, value, row);
1837
+ else if (this.providedSchema === void 0) this.updateInferredField(path, value, row, current);
1838
+ }
1839
+ addField(path, value, row) {
1840
+ if (this.providedSchema !== void 0) {
1841
+ this.addSchemaField(this.providedSchema, path, row);
1842
+ return;
1843
+ }
1844
+ const evidence = this.inferType(value, path) ?? DeferredTypeEvidence.from(value, row);
1845
+ if (evidence === void 0) throw typeInferenceError(path, row);
1846
+ const conflict = this.fields.set(path, evidence, (existing) => existing instanceof DeferredTypeEvidence && existing.isOnlyNulls());
1847
+ if (conflict !== void 0) throw branchConflictError(conflict, row, "Struct");
1848
+ }
1849
+ addSchemaField(schema, path, row) {
1850
+ const field = fieldAtPath(schema, path);
1851
+ if (field === void 0) throw new Error(`Found field not in schema: ${path.join(".")} at row ${row}`);
1852
+ const conflict = this.fields.set(path, field.type);
1853
+ if (conflict !== void 0) throw branchConflictError(conflict, row, "Struct");
1854
+ }
1855
+ updateInferredField(path, value, row, current) {
1856
+ const newType = this.inferType(value, path);
1857
+ const deferred = DeferredTypeEvidence.from(value, row);
1858
+ if (current instanceof FieldTree) {
1859
+ if (deferred?.isOnlyNulls()) return;
1860
+ throw schemaInferenceError(path, row, "Struct", describeEvidence(newType ?? deferred));
1861
+ }
1862
+ if (current instanceof DeferredTypeEvidence) {
1863
+ this.resolveDeferredField(path, row, current, newType, deferred);
1864
+ return;
1865
+ }
1866
+ if (newType !== void 0) {
1867
+ if (!inferredTypesEqual(current, newType)) throw schemaInferenceError(path, row, describeEvidence(current), describeEvidence(newType));
1868
+ return;
1869
+ }
1870
+ if (deferred === void 0 || !deferred.matches(current)) throw schemaInferenceError(path, row, describeEvidence(current), describeEvidence(deferred));
1871
+ }
1872
+ resolveDeferredField(path, row, current, newType, deferred) {
1873
+ if (newType !== void 0) {
1874
+ if (!current.matches(newType)) throw schemaInferenceError(path, row, current.describe(), describeEvidence(newType));
1875
+ this.fields.set(path, newType);
1876
+ return;
1877
+ }
1878
+ if (deferred !== void 0) {
1879
+ this.fields.set(path, current.merge(deferred));
1880
+ return;
1881
+ }
1882
+ throw schemaInferenceError(path, row, current.describe(), describeEvidence(newType));
1883
+ }
1884
+ inferType(value, path) {
1885
+ if (typeof value === "bigint") return new apache_arrow_1$2.Int64();
1886
+ if (typeof value === "number") return new apache_arrow_1$2.Float64();
1887
+ if (typeof value === "string") return this.options.dictionaryEncodeStrings ? new apache_arrow_1$2.Dictionary(new apache_arrow_1$2.Utf8(), new apache_arrow_1$2.Int32()) : new apache_arrow_1$2.Utf8();
1888
+ if (typeof value === "boolean") return new apache_arrow_1$2.Bool();
1889
+ if (value instanceof Buffer) return new apache_arrow_1$2.Binary();
1890
+ if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
1891
+ const typedArray = (0, arrow_type_1.typedArrayToArrowType)(value);
1892
+ return typedArray === void 0 ? void 0 : new apache_arrow_1$2.FixedSizeList(typedArray.length, new apache_arrow_1$2.Field("item", typedArray.elementType, true));
1893
+ }
1894
+ if (!Array.isArray(value) || value.length === 0) return;
1895
+ const configuredVector = path.length === 1 ? this.options.vectorColumns[path[0]] : void 0;
1896
+ if (configuredVector !== void 0) return new apache_arrow_1$2.FixedSizeList(value.length, new apache_arrow_1$2.Field("item", (0, sanitize_1.sanitizeType)(configuredVector.type), true));
1897
+ const itemType = this.inferArrayItemType(value, path);
1898
+ if (itemType === void 0) return;
1899
+ return nameSuggestsVectorColumn(path[path.length - 1]) ? new apache_arrow_1$2.FixedSizeList(value.length, new apache_arrow_1$2.Field("item", new apache_arrow_1$2.Float32(), true)) : new apache_arrow_1$2.List(new apache_arrow_1$2.Field("item", itemType, true));
1900
+ }
1901
+ inferArrayItemType(values, path) {
1902
+ let itemType;
1903
+ const deferredItems = [];
1904
+ for (const value of values) {
1905
+ const candidate = this.inferType(value, path);
1906
+ if (candidate === void 0) {
1907
+ if (!isDeferredValue(value)) return;
1908
+ deferredItems.push(value);
1909
+ } else if (itemType === void 0) itemType = candidate;
1910
+ else if (!inferredTypesEqual(itemType, candidate)) return;
1911
+ }
1912
+ if (itemType === void 0) return;
1913
+ return deferredItems.every((value) => deferredValueMatchesType(value, itemType)) ? itemType : void 0;
1914
+ }
1915
+ };
1916
+ /** Nulls and empty/all-null lists that do not determine a type by themselves. */
1917
+ var DeferredTypeEvidence = class DeferredTypeEvidence {
1918
+ values;
1919
+ constructor(values) {
1920
+ this.values = values;
1921
+ }
1922
+ static from(value, row) {
1923
+ return isDeferredValue(value) ? new DeferredTypeEvidence([{
1924
+ value,
1925
+ row
1926
+ }]) : void 0;
1927
+ }
1928
+ isOnlyNulls() {
1929
+ return this.values.every(({ value }) => value == null);
1930
+ }
1931
+ matches(type) {
1932
+ return this.values.every(({ value }) => deferredValueMatchesType(value, type));
1933
+ }
1934
+ merge(other) {
1935
+ return new DeferredTypeEvidence([...this.values, ...other.values]);
1936
+ }
1937
+ describe() {
1938
+ const list = this.values.find(({ value }) => Array.isArray(value));
1939
+ return list === void 0 ? "null" : `List[${list.value.length}]`;
1940
+ }
1941
+ firstRow() {
1942
+ return this.values[0].row;
1943
+ }
1944
+ };
1945
+ /** Nested field state, kept separate from Arrow's eventual Struct types. */
1946
+ var FieldTree = class FieldTree {
1947
+ children = /* @__PURE__ */ new Map();
1948
+ get(path) {
1949
+ let current = this;
1950
+ for (const part of path) {
1951
+ if (!(current instanceof FieldTree)) return;
1952
+ const child = current.children.get(part);
1953
+ if (child === void 0) return;
1954
+ current = child;
1955
+ }
1956
+ return current;
1957
+ }
1958
+ set(path, value, canReplaceLeaf = () => false) {
1959
+ let branch = this;
1960
+ for (const [index, part] of path.slice(0, -1).entries()) {
1961
+ const child = branch.children.get(part);
1962
+ if (child === void 0 || isLeaf(child) && canReplaceLeaf(child)) {
1963
+ const nextBranch = new FieldTree();
1964
+ branch.children.set(part, nextBranch);
1965
+ branch = nextBranch;
1966
+ } else if (child instanceof FieldTree) branch = child;
1967
+ else return {
1968
+ path: path.slice(0, index + 1),
1969
+ value: child
1970
+ };
1971
+ }
1972
+ const name = path[path.length - 1];
1973
+ const current = branch.children.get(name);
1974
+ if (current instanceof FieldTree) return {
1975
+ path,
1976
+ value: current
1977
+ };
1978
+ branch.children.set(name, value);
1979
+ }
1980
+ entries() {
1981
+ return this.children.entries();
1982
+ }
1983
+ has(name) {
1984
+ return this.children.has(name);
1985
+ }
1986
+ };
1987
+ function isLeaf(value) {
1988
+ return !(value instanceof FieldTree);
1989
+ }
1990
+ function fieldsFromTree(tree, path = []) {
1991
+ const fields = [];
1992
+ for (const [name, value] of tree.entries()) if (value instanceof FieldTree) fields.push(new apache_arrow_1$2.Field(name, new apache_arrow_1$2.Struct(fieldsFromTree(value, [...path, name])), true));
1993
+ else if (value instanceof DeferredTypeEvidence) throw typeInferenceError([...path, name], value.firstRow());
1994
+ else fields.push(new apache_arrow_1$2.Field(name, value, true));
1995
+ return fields;
1996
+ }
1997
+ function matchingFields(fields, tree) {
1998
+ const matches = [];
1999
+ for (const field of fields) {
2000
+ if (!tree.has(field.name)) continue;
2001
+ const value = tree.get([field.name]);
2002
+ if (value instanceof FieldTree) {
2003
+ const struct = field.type;
2004
+ matches.push(new apache_arrow_1$2.Field(field.name, new apache_arrow_1$2.Struct(matchingFields(struct.children, value)), field.nullable, field.metadata));
2005
+ } else matches.push(field);
2006
+ }
2007
+ return matches;
2008
+ }
2009
+ function* recordPathsAndValues(record, path = []) {
2010
+ for (const [name, value] of Object.entries(record)) if (isRecord(value)) yield* recordPathsAndValues(value, [...path, name]);
2011
+ else if (value !== void 0) yield [[...path, name], value];
2012
+ }
2013
+ function isRecord(value) {
2014
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof RegExp) && !(value instanceof Date) && !(value instanceof Set) && !(value instanceof Map) && !(value instanceof Buffer) && !ArrayBuffer.isView(value);
2015
+ }
2016
+ function fieldAtPath(schema, path) {
2017
+ let fields = schema.fields;
2018
+ let field;
2019
+ for (const [index, name] of path.entries()) {
2020
+ field = fields.find((candidate) => candidate.name === name);
2021
+ if (field === void 0 || index === path.length - 1) return field;
2022
+ if (!apache_arrow_1$2.DataType.isStruct(field.type)) return;
2023
+ fields = field.type.children;
2024
+ }
2025
+ return field;
2026
+ }
2027
+ function isDeferredValue(value) {
2028
+ return value == null || Array.isArray(value) && value.every(isDeferredValue);
2029
+ }
2030
+ function deferredValueMatchesType(value, type) {
2031
+ if (value == null) return true;
2032
+ if (!Array.isArray(value)) return false;
2033
+ if (apache_arrow_1$2.DataType.isList(type)) return value.every((item) => deferredValueMatchesType(item, type.valueType));
2034
+ if (apache_arrow_1$2.DataType.isFixedSizeList(type)) return value.length === type.listSize && value.every((item) => deferredValueMatchesType(item, type.valueType));
2035
+ return false;
2036
+ }
2037
+ function inferredTypesEqual(current, candidate) {
2038
+ if (apache_arrow_1$2.DataType.isDictionary(current)) return apache_arrow_1$2.DataType.isDictionary(candidate) && current.isOrdered === candidate.isOrdered && inferredTypesEqual(current.indices, candidate.indices) && inferredTypesEqual(current.dictionary, candidate.dictionary);
2039
+ if (apache_arrow_1$2.DataType.isList(current)) return apache_arrow_1$2.DataType.isList(candidate) && current.valueField.name === candidate.valueField.name && current.valueField.nullable === candidate.valueField.nullable && inferredTypesEqual(current.valueType, candidate.valueType);
2040
+ if (apache_arrow_1$2.DataType.isFixedSizeList(current)) return apache_arrow_1$2.DataType.isFixedSizeList(candidate) && current.listSize === candidate.listSize && current.valueField.name === candidate.valueField.name && current.valueField.nullable === candidate.valueField.nullable && inferredTypesEqual(current.valueType, candidate.valueType);
2041
+ return apache_arrow_1$2.util.compareTypes(current, candidate);
2042
+ }
2043
+ function describeEvidence(evidence) {
2044
+ if (evidence === void 0) return "an unsupported value";
2045
+ return evidence instanceof DeferredTypeEvidence ? evidence.describe() : evidence.toString();
2046
+ }
2047
+ function branchConflictError(conflict, row, candidate) {
2048
+ return schemaInferenceError(conflict.path, row, conflict.value instanceof FieldTree ? "Struct" : describeEvidence(conflict.value), candidate);
2049
+ }
2050
+ function schemaInferenceError(path, row, currentType, newType) {
2051
+ return /* @__PURE__ */ new Error(`Failed to infer schema for data. Previously inferred type ${currentType} but found ${newType} for field ${path.join(".")} at row ${row}. Consider providing an explicit schema.`);
2052
+ }
2053
+ function typeInferenceError(path, row) {
2054
+ return /* @__PURE__ */ new Error(`Failed to infer data type for field ${path.join(".")} at row ${row}. Consider providing an explicit schema.`);
2055
+ }
2056
+ function nameSuggestsVectorColumn(name) {
2057
+ const normalized = name.toLowerCase();
2058
+ return normalized.includes("vector") || normalized.includes("embedding");
2059
+ }
2060
+ }));
2061
+ //#endregion
2062
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/arrow.js
1698
2063
  var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
1699
2064
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
1700
2065
  if (k2 === void 0) k2 = k;
@@ -1710,8 +2075,8 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
1710
2075
  if (k2 === void 0) k2 = k;
1711
2076
  o[k2] = m[k];
1712
2077
  }));
1713
- var __exportStar = exports && exports.__exportStar || function(m, exports$3) {
1714
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$3, p)) __createBinding(exports$3, m, p);
2078
+ var __exportStar = exports && exports.__exportStar || function(m, exports$2) {
2079
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$2, p)) __createBinding(exports$2, m, p);
1715
2080
  };
1716
2081
  Object.defineProperty(exports, "__esModule", { value: true });
1717
2082
  exports.MakeArrowTableOptions = exports.VectorColumnOptions = void 0;
@@ -1754,15 +2119,10 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
1754
2119
  exports.ensureNestedFieldsExist = ensureNestedFieldsExist;
1755
2120
  exports.dataTypeToJson = dataTypeToJson;
1756
2121
  const apache_arrow_1$1 = __require("apache-arrow");
2122
+ const arrow_type_1 = require_arrow_type();
1757
2123
  const registry_1 = require_registry();
1758
2124
  const sanitize_1 = require_sanitize();
1759
- /**
1760
- * Check if a field name indicates a vector column.
1761
- */
1762
- function nameSuggestsVectorColumn(fieldName) {
1763
- const nameLower = fieldName.toLowerCase();
1764
- return nameLower.includes("vector") || nameLower.includes("embedding");
1765
- }
2125
+ const schema_1 = require_schema();
1766
2126
  __exportStar(__require("apache-arrow"), exports);
1767
2127
  function isMultiVector(value) {
1768
2128
  return Array.isArray(value) && isIntoVector(value[0]);
@@ -1997,176 +2357,41 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
1997
2357
  return new apache_arrow_1$1.Table(schema);
1998
2358
  }
1999
2359
  }
2000
- let inferredSchema = inferSchema(data, schema, opt);
2360
+ let inferredSchema = (0, schema_1.inferSchema)(data, schema, opt);
2001
2361
  inferredSchema = new apache_arrow_1$1.Schema(inferredSchema.fields, schemaMetadata);
2002
2362
  const finalColumns = {};
2003
2363
  for (const field of inferredSchema.fields) finalColumns[field.name] = transposeData(data, field);
2004
2364
  return new apache_arrow_1$1.Table(inferredSchema, finalColumns);
2005
2365
  }
2006
- function inferSchema(data, schema, opts) {
2007
- const pathTree = new PathTree();
2008
- for (const [rowI, row] of data.entries()) for (const [path, value] of rowPathsAndValues(row)) if (!pathTree.has(path)) {
2009
- if (schema !== void 0) {
2010
- const field = getFieldForPath(schema, path);
2011
- if (field === void 0) throw new Error(`Found field not in schema: ${path.join(".")} at row ${rowI}`);
2012
- else pathTree.set(path, field.type);
2013
- } else {
2014
- const inferredType = inferType(value, path, opts);
2015
- if (inferredType === void 0) throw new Error(`Failed to infer data type for field ${path.join(".")} at row ${rowI}. \
2016
- Consider providing an explicit schema.`);
2017
- pathTree.set(path, inferredType);
2018
- }
2019
- } else if (schema === void 0) {
2020
- const currentType = pathTree.get(path);
2021
- const newType = inferType(value, path, opts);
2022
- if (currentType !== newType) `${currentType}${newType}${rowI}`;
2023
- }
2024
- if (schema === void 0) {
2025
- function fieldsFromPathTree(pathTree) {
2026
- const fields = [];
2027
- for (const [name, value] of pathTree.map.entries()) if (value instanceof PathTree) {
2028
- const children = fieldsFromPathTree(value);
2029
- fields.push(new apache_arrow_1$1.Field(name, new apache_arrow_1$1.Struct(children), true));
2030
- } else fields.push(new apache_arrow_1$1.Field(name, value, true));
2031
- return fields;
2032
- }
2033
- const fields = fieldsFromPathTree(pathTree);
2034
- return new apache_arrow_1$1.Schema(fields);
2035
- } else {
2036
- function takeMatchingFields(fields, pathTree) {
2037
- const outFields = [];
2038
- for (const field of fields) if (pathTree.map.has(field.name)) {
2039
- const value = pathTree.get([field.name]);
2040
- if (value instanceof PathTree) {
2041
- const struct = field.type;
2042
- const children = takeMatchingFields(struct.children, value);
2043
- outFields.push(new apache_arrow_1$1.Field(field.name, new apache_arrow_1$1.Struct(children), field.nullable));
2044
- } else outFields.push(new apache_arrow_1$1.Field(field.name, value, field.nullable));
2045
- }
2046
- return outFields;
2047
- }
2048
- const fields = takeMatchingFields(schema.fields, pathTree);
2049
- return new apache_arrow_1$1.Schema(fields);
2050
- }
2051
- }
2052
- function* rowPathsAndValues(row, basePath = []) {
2053
- for (const [key, value] of Object.entries(row)) if (isObject(value)) yield* rowPathsAndValues(value, [...basePath, key]);
2054
- else if (value !== void 0) yield [[...basePath, key], value];
2055
- }
2056
2366
  function isObject(value) {
2057
2367
  return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof RegExp) && !(value instanceof Date) && !(value instanceof Set) && !(value instanceof Map) && !(value instanceof Buffer) && !ArrayBuffer.isView(value);
2058
2368
  }
2059
- function getFieldForPath(schema, path) {
2060
- let current = schema;
2061
- for (const key of path) if (current instanceof apache_arrow_1$1.Schema) {
2062
- const field = current.fields.find((f) => f.name === key);
2063
- if (field === void 0) return;
2064
- current = field;
2065
- } else if (current instanceof apache_arrow_1$1.Field && apache_arrow_1$1.DataType.isStruct(current.type)) {
2066
- const field = current.type.children.find((f) => f.name === key);
2067
- if (field === void 0) return;
2068
- current = field;
2069
- } else return;
2070
- if (current instanceof apache_arrow_1$1.Field) return current;
2071
- else return;
2072
- }
2073
- /**
2074
- * Try to infer which Arrow type to use for a given value.
2075
- *
2076
- * May return undefined if the type cannot be inferred.
2077
- */
2078
- function inferType(value, path, opts) {
2079
- if (typeof value === "bigint") return new apache_arrow_1$1.Int64();
2080
- else if (typeof value === "number") return new apache_arrow_1$1.Float64();
2081
- else if (typeof value === "string") {
2082
- if (opts.dictionaryEncodeStrings) return new apache_arrow_1$1.Dictionary(new apache_arrow_1$1.Utf8(), new apache_arrow_1$1.Int32());
2083
- else return new apache_arrow_1$1.Utf8();
2084
- } else if (typeof value === "boolean") return new apache_arrow_1$1.Bool();
2085
- else if (value instanceof Buffer) return new apache_arrow_1$1.Binary();
2086
- else if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
2087
- const info = typedArrayToArrowType(value);
2088
- if (info !== void 0) {
2089
- const child = new apache_arrow_1$1.Field("item", info.elementType, true);
2090
- return new apache_arrow_1$1.FixedSizeList(info.length, child);
2091
- }
2092
- return;
2093
- } else if (Array.isArray(value)) {
2094
- if (value.length === 0) return;
2095
- if (path.length === 1 && Object.hasOwn(opts.vectorColumns, path[0])) {
2096
- const floatType = (0, sanitize_1.sanitizeType)(opts.vectorColumns[path[0]].type);
2097
- return new apache_arrow_1$1.FixedSizeList(value.length, new apache_arrow_1$1.Field("item", floatType, true));
2098
- }
2099
- const valueType = inferType(value[0], path, opts);
2100
- if (valueType === void 0) return;
2101
- if (nameSuggestsVectorColumn(path[path.length - 1])) {
2102
- if (value instanceof Uint8Array) {
2103
- const child = new apache_arrow_1$1.Field("item", new apache_arrow_1$1.Uint8(), true);
2104
- return new apache_arrow_1$1.FixedSizeList(value.length, child);
2105
- } else {
2106
- const child = new apache_arrow_1$1.Field("item", new apache_arrow_1$1.Float32(), true);
2107
- return new apache_arrow_1$1.FixedSizeList(value.length, child);
2108
- }
2109
- } else {
2110
- const child = new apache_arrow_1$1.Field("item", valueType, true);
2111
- return new apache_arrow_1$1.List(child);
2112
- }
2113
- } else return;
2369
+ function valueAtPath(datum, path) {
2370
+ let current = datum;
2371
+ for (const key of path) {
2372
+ if (current == null) return null;
2373
+ if (isObject(current) && (Object.hasOwn(current, key) || key in current)) current = current[key];
2374
+ else return;
2375
+ }
2376
+ return current;
2114
2377
  }
2115
- var PathTree = class PathTree {
2116
- map;
2117
- constructor(entries) {
2118
- this.map = /* @__PURE__ */ new Map();
2119
- if (entries !== void 0) for (const [path, value] of entries) this.set(path, value);
2120
- }
2121
- has(path) {
2122
- let ref = this;
2123
- for (const part of path) {
2124
- if (!(ref instanceof PathTree) || !ref.map.has(part)) return false;
2125
- ref = ref.map.get(part);
2126
- }
2127
- return true;
2128
- }
2129
- get(path) {
2130
- let ref = this;
2131
- for (const part of path) {
2132
- if (!(ref instanceof PathTree) || !ref.map.has(part)) return;
2133
- ref = ref.map.get(part);
2134
- }
2135
- return ref;
2136
- }
2137
- set(path, value) {
2138
- let ref = this;
2139
- for (const part of path.slice(0, path.length - 1)) {
2140
- if (!ref.map.has(part)) ref.map.set(part, new PathTree());
2141
- ref = ref.map.get(part);
2142
- }
2143
- ref.map.set(path[path.length - 1], value);
2144
- }
2145
- };
2146
2378
  function transposeData(data, field, path = []) {
2379
+ const valuesPath = [...path, field.name];
2380
+ const values = data.map((datum) => valueAtPath(datum, valuesPath));
2147
2381
  if (field.type instanceof apache_arrow_1$1.Struct) {
2148
- const childFields = field.type.children;
2149
- const fullPath = [...path, field.name];
2150
- const childVectors = childFields.map((child) => {
2151
- return transposeData(data, child, fullPath);
2382
+ const childVectors = field.type.children.map((child) => {
2383
+ return transposeData(data, child, valuesPath);
2152
2384
  });
2385
+ const nullCount = values.filter((value) => value === null).length;
2153
2386
  const structData = (0, apache_arrow_1$1.makeData)({
2154
2387
  type: field.type,
2388
+ length: values.length,
2389
+ nullCount,
2390
+ nullBitmap: nullCount > 0 ? apache_arrow_1$1.util.packBools(values.map((value) => value !== null)) : void 0,
2155
2391
  children: childVectors
2156
2392
  });
2157
2393
  return (0, apache_arrow_1$1.makeVector)(structData);
2158
- } else {
2159
- const valuesPath = [...path, field.name];
2160
- return makeVector(data.map((datum) => {
2161
- let current = datum;
2162
- for (const key of valuesPath) {
2163
- if (current == null) return null;
2164
- if (isObject(current) && (Object.hasOwn(current, key) || key in current)) current = current[key];
2165
- else return null;
2166
- }
2167
- return current;
2168
- }), field.type, void 0, field.nullable);
2169
- }
2394
+ } else return makeVector(values, field.type, void 0, field.nullable);
2170
2395
  }
2171
2396
  /**
2172
2397
  * Create an empty Arrow table with the provided schema
@@ -2190,44 +2415,6 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
2190
2415
  for (const list of lists) listBuilder.append(list);
2191
2416
  return listBuilder.finish().toVector();
2192
2417
  }
2193
- /**
2194
- * Map a JS TypedArray instance to the corresponding Arrow element DataType
2195
- * and its length. Returns undefined if the value is not a recognized TypedArray.
2196
- */
2197
- function typedArrayToArrowType(value) {
2198
- if (value instanceof Float32Array) return {
2199
- elementType: new apache_arrow_1$1.Float32(),
2200
- length: value.length
2201
- };
2202
- if (value instanceof Float64Array) return {
2203
- elementType: new apache_arrow_1$1.Float64(),
2204
- length: value.length
2205
- };
2206
- if (value instanceof Uint8Array) return {
2207
- elementType: new apache_arrow_1$1.Uint8(),
2208
- length: value.length
2209
- };
2210
- if (value instanceof Uint16Array) return {
2211
- elementType: new apache_arrow_1$1.Uint16(),
2212
- length: value.length
2213
- };
2214
- if (value instanceof Uint32Array) return {
2215
- elementType: new apache_arrow_1$1.Uint32(),
2216
- length: value.length
2217
- };
2218
- if (value instanceof Int8Array) return {
2219
- elementType: new apache_arrow_1$1.Int8(),
2220
- length: value.length
2221
- };
2222
- if (value instanceof Int16Array) return {
2223
- elementType: new apache_arrow_1$1.Int16(),
2224
- length: value.length
2225
- };
2226
- if (value instanceof Int32Array) return {
2227
- elementType: new apache_arrow_1$1.Int32(),
2228
- length: value.length
2229
- };
2230
- }
2231
2418
  /** Helper function to convert an Array of JS values to an Arrow Vector */
2232
2419
  function makeVector(values, type, stringAsDictionary, nullable) {
2233
2420
  if (type !== void 0) {
@@ -2262,7 +2449,7 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
2262
2449
  const sampleValue = values.find((val) => val !== null && val !== void 0);
2263
2450
  if (sampleValue === void 0) throw Error("makeVector cannot infer the type if all values are null or undefined");
2264
2451
  if (ArrayBuffer.isView(sampleValue) && !(sampleValue instanceof DataView)) {
2265
- const info = typedArrayToArrowType(sampleValue);
2452
+ const info = (0, arrow_type_1.typedArrayToArrowType)(sampleValue);
2266
2453
  if (info !== void 0) {
2267
2454
  const fslType = new apache_arrow_1$1.FixedSizeList(info.length, new apache_arrow_1$1.Field("item", info.elementType, true));
2268
2455
  return vectorFromArray(values, fslType);
@@ -2279,7 +2466,7 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
2279
2466
  const columns = Object.fromEntries(table.schema.fields.map((field) => [field.name, table.getChild(field.name)]));
2280
2467
  for (const functionEntry of functions.values()) {
2281
2468
  const sourceColumn = columns[functionEntry.sourceColumn];
2282
- const destColumn = functionEntry.vectorColumn ?? "vector";
2469
+ const destColumn = functionEntry.vectorColumn;
2283
2470
  if (sourceColumn === void 0) throw new Error(`Cannot apply embedding function because the source column '${functionEntry.sourceColumn}' was not present in the data`);
2284
2471
  if (columns[destColumn] !== void 0) {
2285
2472
  const existingColumn = columns[destColumn];
@@ -2511,7 +2698,7 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
2511
2698
  if (data.length !== 0 && data?.[0]?.[field.name] === void 0) {
2512
2699
  let hasEmbeddingFunction = false;
2513
2700
  if (schema.metadata.has("embedding_functions")) {
2514
- if (JSON.parse(schema.metadata.get("embedding_functions")).find((f) => f["vectorColumn"] === field.name)) hasEmbeddingFunction = true;
2701
+ if ((0, registry_1.parseEmbeddingMetadata)(schema.metadata.get("embedding_functions")).some((f) => f.vectorColumn === field.name)) hasEmbeddingFunction = true;
2515
2702
  }
2516
2703
  if (embeddings && embeddings.vectorColumn === field.name) hasEmbeddingFunction = true;
2517
2704
  if (field.nullable && !hasEmbeddingFunction) fields.push(field);
@@ -2534,7 +2721,7 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
2534
2721
  const nestedValue = row[field.name];
2535
2722
  completeRow[field.name] = ensureStructFieldsExist(nestedValue, field.type);
2536
2723
  } else completeRow[field.name] = row[field.name];
2537
- } else completeRow[field.name] = null;
2724
+ } else completeRow[field.name] = field.type.constructor.name === "Struct" ? ensureStructFieldsExist({}, field.type) : null;
2538
2725
  return completeRow;
2539
2726
  });
2540
2727
  }
@@ -2547,7 +2734,7 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
2547
2734
  for (const childField of structType.children) if (childField.name in data) {
2548
2735
  if (childField.type.constructor.name === "Struct" && data[childField.name] !== null && data[childField.name] !== void 0) completeStruct[childField.name] = ensureStructFieldsExist(data[childField.name], childField.type);
2549
2736
  else completeStruct[childField.name] = data[childField.name];
2550
- } else completeStruct[childField.name] = null;
2737
+ } else completeStruct[childField.name] = childField.type.constructor.name === "Struct" ? ensureStructFieldsExist({}, childField.type) : null;
2551
2738
  return completeStruct;
2552
2739
  }
2553
2740
  function dataTypeToJson(dataType) {
@@ -2656,7 +2843,98 @@ var require_arrow = /* @__PURE__ */ __commonJSMin(((exports) => {
2656
2843
  }
2657
2844
  }));
2658
2845
  //#endregion
2659
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/merge.js
2846
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/materialized_view.js
2847
+ var require_materialized_view = /* @__PURE__ */ __commonJSMin(((exports) => {
2848
+ Object.defineProperty(exports, "__esModule", { value: true });
2849
+ exports.MaterializedView = exports.DEFINITION_META_KEY = void 0;
2850
+ exports.validateNonNegativeInteger = validateNonNegativeInteger;
2851
+ exports.normalizeSelect = normalizeSelect;
2852
+ exports.definitionFromMetadata = definitionFromMetadata;
2853
+ /** Schema metadata key holding a materialized view's definition. */
2854
+ exports.DEFINITION_META_KEY = "mv.definition";
2855
+ /**
2856
+ * @internal Reject a numeric option N-API would otherwise silently coerce:
2857
+ * `Infinity` reaches Rust as 0, `1.5` as 1.
2858
+ */
2859
+ function validateNonNegativeInteger(value, name) {
2860
+ if (value !== void 0 && !(Number.isSafeInteger(value) && value >= 0)) throw new Error(`${name} must be a non-negative integer`);
2861
+ }
2862
+ /** @internal Quote a column name as a Lance SQL identifier (backticks). */
2863
+ function quoteIdentifier(name) {
2864
+ return "`" + name.replace(/`/g, "``") + "`";
2865
+ }
2866
+ /**
2867
+ * @internal Normalize a select argument into `[alias, expression]` pairs.
2868
+ * A bare name projects itself and is quoted, so any valid column name works;
2869
+ * pair and record entries are kept verbatim because their right side is an
2870
+ * expression.
2871
+ */
2872
+ function normalizeSelect(select) {
2873
+ if (select === void 0) return;
2874
+ if (Array.isArray(select)) return select.map((item) => typeof item === "string" ? [item, quoteIdentifier(item)] : item);
2875
+ return Object.entries(select);
2876
+ }
2877
+ /** @internal Parse a definition off a table's stored schema metadata. */
2878
+ function definitionFromMetadata(metadata, name) {
2879
+ const raw = metadata.get(exports.DEFINITION_META_KEY);
2880
+ if (raw === void 0) throw new Error(`Table '${name}' is not a materialized view`);
2881
+ const value = JSON.parse(raw);
2882
+ if (value.kind !== "select") throw new Error(`materialized view '${name}' is defined by '${value.kind}', which this version of lancedb cannot refresh`);
2883
+ const limit = value.limit ?? void 0;
2884
+ if (limit !== void 0 && !Number.isSafeInteger(limit)) throw new Error(`materialized view '${name}' has a stored limit too large to represent exactly`);
2885
+ return {
2886
+ sourceTable: value.source_table,
2887
+ projections: (value.projections ?? []).map((p) => [p.output, p.expression]),
2888
+ filter: value.filter ?? void 0,
2889
+ limit,
2890
+ inputs: value.inputs ?? []
2891
+ };
2892
+ }
2893
+ /**
2894
+ * A handle on a materialized view: its table plus its definition.
2895
+ *
2896
+ * Obtained from {@link Connection#createMaterializedView} or
2897
+ * {@link Connection#openMaterializedView}. The view is a normal table --
2898
+ * queries, indexes and search all apply through {@link MaterializedView#table}
2899
+ * -- whose contents are maintained by {@link MaterializedView#refresh}.
2900
+ */
2901
+ var MaterializedView = class {
2902
+ inner;
2903
+ constructor(table) {
2904
+ this.inner = table;
2905
+ }
2906
+ get name() {
2907
+ return this.inner.name;
2908
+ }
2909
+ /** The view, as the table it is. */
2910
+ table() {
2911
+ return this.inner;
2912
+ }
2913
+ /** The query that defines the view, read from its stored schema. */
2914
+ async definition() {
2915
+ return definitionFromMetadata((await this.inner.schema()).metadata, this.name);
2916
+ }
2917
+ /**
2918
+ * Recompute the view from its source.
2919
+ *
2920
+ * The refresh is incremental when the source's changes can be reconciled
2921
+ * into the view -- rows added, changed or removed since the last one --
2922
+ * and otherwise rebuilds. `full` forces a rebuild; `sourceVersion`
2923
+ * refreshes to that source version instead of the latest.
2924
+ *
2925
+ * Concurrent refreshes of one view do not duplicate its rows. Two that
2926
+ * plan the same source rows conflict on commit, and the loser throws
2927
+ * rather than writing them a second time.
2928
+ */
2929
+ async refresh(options) {
2930
+ validateNonNegativeInteger(options?.sourceVersion, "sourceVersion");
2931
+ return await this.inner.refreshMaterializedView(options?.full, options?.sourceVersion);
2932
+ }
2933
+ };
2934
+ exports.MaterializedView = MaterializedView;
2935
+ }));
2936
+ //#endregion
2937
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/merge.js
2660
2938
  var require_merge = /* @__PURE__ */ __commonJSMin(((exports) => {
2661
2939
  Object.defineProperty(exports, "__esModule", { value: true });
2662
2940
  exports.MergeInsertBuilder = void 0;
@@ -2770,7 +3048,7 @@ var require_merge = /* @__PURE__ */ __commonJSMin(((exports) => {
2770
3048
  };
2771
3049
  }));
2772
3050
  //#endregion
2773
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/native.js
3051
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/native.js
2774
3052
  var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2775
3053
  const { readFileSync } = __require("node:fs");
2776
3054
  let nativeBinding = null;
@@ -2828,7 +3106,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2828
3106
  try {
2829
3107
  const binding = __require("@lancedb/lancedb-android-arm64");
2830
3108
  const bindingPackageVersion = __require("@lancedb/lancedb-android-arm64/package.json").version;
2831
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3109
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2832
3110
  return binding;
2833
3111
  } catch (e) {
2834
3112
  loadErrors.push(e);
@@ -2842,7 +3120,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2842
3120
  try {
2843
3121
  const binding = __require("@lancedb/lancedb-android-arm-eabi");
2844
3122
  const bindingPackageVersion = __require("@lancedb/lancedb-android-arm-eabi/package.json").version;
2845
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3123
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2846
3124
  return binding;
2847
3125
  } catch (e) {
2848
3126
  loadErrors.push(e);
@@ -2859,7 +3137,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2859
3137
  try {
2860
3138
  const binding = __require("@lancedb/lancedb-win32-x64-gnu");
2861
3139
  const bindingPackageVersion = __require("@lancedb/lancedb-win32-x64-gnu/package.json").version;
2862
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3140
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2863
3141
  return binding;
2864
3142
  } catch (e) {
2865
3143
  loadErrors.push(e);
@@ -2873,7 +3151,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2873
3151
  try {
2874
3152
  const binding = __require("@lancedb/lancedb-win32-x64-msvc");
2875
3153
  const bindingPackageVersion = __require("@lancedb/lancedb-win32-x64-msvc/package.json").version;
2876
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3154
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2877
3155
  return binding;
2878
3156
  } catch (e) {
2879
3157
  loadErrors.push(e);
@@ -2888,7 +3166,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2888
3166
  try {
2889
3167
  const binding = __require("@lancedb/lancedb-win32-ia32-msvc");
2890
3168
  const bindingPackageVersion = __require("@lancedb/lancedb-win32-ia32-msvc/package.json").version;
2891
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3169
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2892
3170
  return binding;
2893
3171
  } catch (e) {
2894
3172
  loadErrors.push(e);
@@ -2902,7 +3180,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2902
3180
  try {
2903
3181
  const binding = __require("@lancedb/lancedb-win32-arm64-msvc");
2904
3182
  const bindingPackageVersion = __require("@lancedb/lancedb-win32-arm64-msvc/package.json").version;
2905
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3183
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2906
3184
  return binding;
2907
3185
  } catch (e) {
2908
3186
  loadErrors.push(e);
@@ -2917,7 +3195,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2917
3195
  try {
2918
3196
  const binding = __require("@lancedb/lancedb-darwin-universal");
2919
3197
  const bindingPackageVersion = __require("@lancedb/lancedb-darwin-universal/package.json").version;
2920
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3198
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2921
3199
  return binding;
2922
3200
  } catch (e) {
2923
3201
  loadErrors.push(e);
@@ -2931,7 +3209,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2931
3209
  try {
2932
3210
  const binding = __require("@lancedb/lancedb-darwin-x64");
2933
3211
  const bindingPackageVersion = __require("@lancedb/lancedb-darwin-x64/package.json").version;
2934
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3212
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2935
3213
  return binding;
2936
3214
  } catch (e) {
2937
3215
  loadErrors.push(e);
@@ -2945,7 +3223,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2945
3223
  try {
2946
3224
  const binding = __require("@lancedb/lancedb-darwin-arm64");
2947
3225
  const bindingPackageVersion = __require("@lancedb/lancedb-darwin-arm64/package.json").version;
2948
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3226
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2949
3227
  return binding;
2950
3228
  } catch (e) {
2951
3229
  loadErrors.push(e);
@@ -2961,7 +3239,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2961
3239
  try {
2962
3240
  const binding = __require("@lancedb/lancedb-freebsd-x64");
2963
3241
  const bindingPackageVersion = __require("@lancedb/lancedb-freebsd-x64/package.json").version;
2964
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3242
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2965
3243
  return binding;
2966
3244
  } catch (e) {
2967
3245
  loadErrors.push(e);
@@ -2975,7 +3253,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2975
3253
  try {
2976
3254
  const binding = __require("@lancedb/lancedb-freebsd-arm64");
2977
3255
  const bindingPackageVersion = __require("@lancedb/lancedb-freebsd-arm64/package.json").version;
2978
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3256
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2979
3257
  return binding;
2980
3258
  } catch (e) {
2981
3259
  loadErrors.push(e);
@@ -2992,7 +3270,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2992
3270
  try {
2993
3271
  const binding = __require("@lancedb/lancedb-linux-x64-musl");
2994
3272
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-x64-musl/package.json").version;
2995
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3273
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
2996
3274
  return binding;
2997
3275
  } catch (e) {
2998
3276
  loadErrors.push(e);
@@ -3006,7 +3284,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3006
3284
  try {
3007
3285
  const binding = __require("@lancedb/lancedb-linux-x64-gnu");
3008
3286
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-x64-gnu/package.json").version;
3009
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3287
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3010
3288
  return binding;
3011
3289
  } catch (e) {
3012
3290
  loadErrors.push(e);
@@ -3022,7 +3300,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3022
3300
  try {
3023
3301
  const binding = __require("@lancedb/lancedb-linux-arm64-musl");
3024
3302
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-arm64-musl/package.json").version;
3025
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3303
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3026
3304
  return binding;
3027
3305
  } catch (e) {
3028
3306
  loadErrors.push(e);
@@ -3036,7 +3314,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3036
3314
  try {
3037
3315
  const binding = __require("@lancedb/lancedb-linux-arm64-gnu");
3038
3316
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-arm64-gnu/package.json").version;
3039
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3317
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3040
3318
  return binding;
3041
3319
  } catch (e) {
3042
3320
  loadErrors.push(e);
@@ -3052,7 +3330,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3052
3330
  try {
3053
3331
  const binding = __require("@lancedb/lancedb-linux-arm-musleabihf");
3054
3332
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-arm-musleabihf/package.json").version;
3055
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3333
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3056
3334
  return binding;
3057
3335
  } catch (e) {
3058
3336
  loadErrors.push(e);
@@ -3066,7 +3344,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3066
3344
  try {
3067
3345
  const binding = __require("@lancedb/lancedb-linux-arm-gnueabihf");
3068
3346
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-arm-gnueabihf/package.json").version;
3069
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3347
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3070
3348
  return binding;
3071
3349
  } catch (e) {
3072
3350
  loadErrors.push(e);
@@ -3082,7 +3360,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3082
3360
  try {
3083
3361
  const binding = __require("@lancedb/lancedb-linux-loong64-musl");
3084
3362
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-loong64-musl/package.json").version;
3085
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3363
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3086
3364
  return binding;
3087
3365
  } catch (e) {
3088
3366
  loadErrors.push(e);
@@ -3096,7 +3374,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3096
3374
  try {
3097
3375
  const binding = __require("@lancedb/lancedb-linux-loong64-gnu");
3098
3376
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-loong64-gnu/package.json").version;
3099
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3377
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3100
3378
  return binding;
3101
3379
  } catch (e) {
3102
3380
  loadErrors.push(e);
@@ -3112,7 +3390,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3112
3390
  try {
3113
3391
  const binding = __require("@lancedb/lancedb-linux-riscv64-musl");
3114
3392
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-riscv64-musl/package.json").version;
3115
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3393
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3116
3394
  return binding;
3117
3395
  } catch (e) {
3118
3396
  loadErrors.push(e);
@@ -3126,7 +3404,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3126
3404
  try {
3127
3405
  const binding = __require("@lancedb/lancedb-linux-riscv64-gnu");
3128
3406
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-riscv64-gnu/package.json").version;
3129
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3407
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3130
3408
  return binding;
3131
3409
  } catch (e) {
3132
3410
  loadErrors.push(e);
@@ -3141,7 +3419,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3141
3419
  try {
3142
3420
  const binding = __require("@lancedb/lancedb-linux-ppc64-gnu");
3143
3421
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-ppc64-gnu/package.json").version;
3144
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3422
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3145
3423
  return binding;
3146
3424
  } catch (e) {
3147
3425
  loadErrors.push(e);
@@ -3155,7 +3433,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3155
3433
  try {
3156
3434
  const binding = __require("@lancedb/lancedb-linux-s390x-gnu");
3157
3435
  const bindingPackageVersion = __require("@lancedb/lancedb-linux-s390x-gnu/package.json").version;
3158
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3436
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3159
3437
  return binding;
3160
3438
  } catch (e) {
3161
3439
  loadErrors.push(e);
@@ -3171,7 +3449,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3171
3449
  try {
3172
3450
  const binding = __require("@lancedb/lancedb-openharmony-arm64");
3173
3451
  const bindingPackageVersion = __require("@lancedb/lancedb-openharmony-arm64/package.json").version;
3174
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3452
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3175
3453
  return binding;
3176
3454
  } catch (e) {
3177
3455
  loadErrors.push(e);
@@ -3185,7 +3463,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3185
3463
  try {
3186
3464
  const binding = __require("@lancedb/lancedb-openharmony-x64");
3187
3465
  const bindingPackageVersion = __require("@lancedb/lancedb-openharmony-x64/package.json").version;
3188
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3466
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3189
3467
  return binding;
3190
3468
  } catch (e) {
3191
3469
  loadErrors.push(e);
@@ -3199,7 +3477,7 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3199
3477
  try {
3200
3478
  const binding = __require("@lancedb/lancedb-openharmony-arm");
3201
3479
  const bindingPackageVersion = __require("@lancedb/lancedb-openharmony-arm/package.json").version;
3202
- if (bindingPackageVersion !== "0.37.1" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.37.1 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3480
+ if (bindingPackageVersion !== "0.38.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") throw new Error(`Native binding package version mismatch, expected 0.38.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
3203
3481
  return binding;
3204
3482
  } catch (e) {
3205
3483
  loadErrors.push(e);
@@ -3269,11 +3547,12 @@ var require_native = /* @__PURE__ */ __commonJSMin(((exports, module) => {
3269
3547
  module.exports.tokenize = nativeBinding.tokenize;
3270
3548
  }));
3271
3549
  //#endregion
3272
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/query.js
3550
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/query.js
3273
3551
  var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3274
3552
  Object.defineProperty(exports, "__esModule", { value: true });
3275
- exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.Query = exports.TakeQuery = exports.VectorQuery = exports.StandardQueryBase = exports.QueryBase = void 0;
3553
+ exports.BooleanQuery = exports.MultiMatchQuery = exports.BoostQuery = exports.PhraseQuery = exports.MatchQuery = exports.Occur = exports.Operator = exports.FullTextQueryType = exports.Query = exports.AutoQuery = exports.TakeQuery = exports.VectorQuery = exports.StandardQueryBase = exports.QueryBase = void 0;
3276
3554
  exports.RecordBatchIterator = RecordBatchIterator;
3555
+ exports.createAutoQuery = createAutoQuery;
3277
3556
  exports.instanceOfFullTextQuery = instanceOfFullTextQuery;
3278
3557
  const arrow_1 = require_arrow();
3279
3558
  const native_1 = require_native();
@@ -3297,6 +3576,16 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3297
3576
  return RecordBatchIterator(this.inner.execute(this.options?.maxBatchLength, this.options?.timeoutMs));
3298
3577
  }
3299
3578
  };
3579
+ function nearestToNative(inner, vector) {
3580
+ const raw = Array.isArray(vector) ? null : (0, arrow_1.extractVectorBuffer)(vector);
3581
+ if (raw) return inner.nearestToRaw(raw.data, raw.dtype);
3582
+ return inner.nearestTo(Float32Array.from(vector));
3583
+ }
3584
+ function addQueryVectorToNative(inner, vector) {
3585
+ const raw = Array.isArray(vector) ? null : (0, arrow_1.extractVectorBuffer)(vector);
3586
+ if (raw) inner.addQueryVectorRaw(raw.data, raw.dtype);
3587
+ else inner.addQueryVector(Float32Array.from(vector));
3588
+ }
3300
3589
  /** Common methods supported by all query types
3301
3590
  *
3302
3591
  * @see {@link Query}
@@ -3310,7 +3599,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3310
3599
  * @hidden
3311
3600
  */
3312
3601
  constructor(inner) {
3313
- this.inner = inner;
3602
+ if (inner !== void 0) this.inner = inner;
3314
3603
  }
3315
3604
  /**
3316
3605
  * @hidden
@@ -3323,6 +3612,14 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3323
3612
  else fn(this.inner);
3324
3613
  }
3325
3614
  /**
3615
+ * Return the native query used by the next terminal operation.
3616
+ *
3617
+ * @hidden
3618
+ */
3619
+ async getInner() {
3620
+ return this.inner;
3621
+ }
3622
+ /**
3326
3623
  * Return only the specified columns.
3327
3624
  *
3328
3625
  * By default a query will return all columns from the table. However, this can have
@@ -3383,9 +3680,8 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3383
3680
  /**
3384
3681
  * @hidden
3385
3682
  */
3386
- nativeExecute(options) {
3387
- if (this.inner instanceof Promise) return this.inner.then((inner) => inner.execute(options?.maxBatchLength, options?.timeoutMs));
3388
- else return this.inner.execute(options?.maxBatchLength, options?.timeoutMs);
3683
+ async nativeExecute(options) {
3684
+ return (await this.getInner()).execute(options?.maxBatchLength, options?.timeoutMs);
3389
3685
  }
3390
3686
  /**
3391
3687
  * Execute the query and return the results as an @see {@link AsyncIterator}
@@ -3410,9 +3706,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3410
3706
  /** Collect the results as an Arrow @see {@link ArrowTable}. */
3411
3707
  async toArrow(options) {
3412
3708
  const batches = [];
3413
- let inner;
3414
- if (this.inner instanceof Promise) inner = await this.inner;
3415
- else inner = this.inner;
3709
+ const inner = await this.getInner();
3416
3710
  for await (const batch of new RecordBatchIterable(inner, options)) batches.push(batch);
3417
3711
  return new arrow_1.Table(batches);
3418
3712
  }
@@ -3435,8 +3729,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3435
3729
  * @returns A Promise that resolves to a string containing the query execution plan explanation.
3436
3730
  */
3437
3731
  async explainPlan(verbose = false) {
3438
- if (this.inner instanceof Promise) return this.inner.then((inner) => inner.explainPlan(verbose));
3439
- else return this.inner.explainPlan(verbose);
3732
+ return (await this.getInner()).explainPlan(verbose);
3440
3733
  }
3441
3734
  /**
3442
3735
  * Executes the query and returns the physical query plan annotated with runtime metrics.
@@ -3471,8 +3764,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3471
3764
  */
3472
3765
  async analyzePlan(distributedMetrics) {
3473
3766
  const distributedMetricsMode = distributedMetrics ?? "aggregate";
3474
- if (this.inner instanceof Promise) return this.inner.then((inner) => inner.analyzePlan(distributedMetricsMode));
3475
- else return this.inner.analyzePlan(distributedMetricsMode);
3767
+ return (await this.getInner()).analyzePlan(distributedMetricsMode);
3476
3768
  }
3477
3769
  /**
3478
3770
  * Returns the schema of the output that will be returned by this query.
@@ -3483,9 +3775,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3483
3775
  * @returns An Arrow Schema describing the output columns.
3484
3776
  */
3485
3777
  async outputSchema() {
3486
- let schemaBuffer;
3487
- if (this.inner instanceof Promise) schemaBuffer = await this.inner.then((inner) => inner.outputSchema());
3488
- else schemaBuffer = await this.inner.outputSchema();
3778
+ const schemaBuffer = await (await this.getInner()).outputSchema();
3489
3779
  return (0, arrow_1.tableFromIPC)(schemaBuffer).schema;
3490
3780
  }
3491
3781
  };
@@ -3620,6 +3910,12 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3620
3910
  super(inner);
3621
3911
  }
3622
3912
  /**
3913
+ * @hidden
3914
+ */
3915
+ doVectorCall(fn) {
3916
+ super.doCall(fn);
3917
+ }
3918
+ /**
3623
3919
  * Set the number of partitions to search (probe)
3624
3920
  *
3625
3921
  * This argument is only used when the vector column has an IVF PQ index.
@@ -3646,7 +3942,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3646
3942
  * the minimum and maximum to the same value.
3647
3943
  */
3648
3944
  nprobes(nprobes) {
3649
- super.doCall((inner) => inner.nprobes(nprobes));
3945
+ this.doVectorCall((inner) => inner.nprobes(nprobes));
3650
3946
  return this;
3651
3947
  }
3652
3948
  /**
@@ -3658,7 +3954,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3658
3954
  * but will also increase latency.
3659
3955
  */
3660
3956
  minimumNprobes(minimumNprobes) {
3661
- super.doCall((inner) => inner.minimumNprobes(minimumNprobes));
3957
+ this.doVectorCall((inner) => inner.minimumNprobes(minimumNprobes));
3662
3958
  return this;
3663
3959
  }
3664
3960
  /**
@@ -3671,11 +3967,11 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3671
3967
  * potential false negatives.
3672
3968
  */
3673
3969
  maximumNprobes(maximumNprobes) {
3674
- super.doCall((inner) => inner.maximumNprobes(maximumNprobes));
3970
+ this.doVectorCall((inner) => inner.maximumNprobes(maximumNprobes));
3675
3971
  return this;
3676
3972
  }
3677
3973
  distanceRange(lowerBound, upperBound) {
3678
- super.doCall((inner) => inner.distanceRange(lowerBound, upperBound));
3974
+ this.doVectorCall((inner) => inner.distanceRange(lowerBound, upperBound));
3679
3975
  return this;
3680
3976
  }
3681
3977
  /**
@@ -3688,7 +3984,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3688
3984
  * also increase the latency of your query. The default value is 1.5*limit.
3689
3985
  */
3690
3986
  ef(ef) {
3691
- super.doCall((inner) => inner.ef(ef));
3987
+ this.doVectorCall((inner) => inner.ef(ef));
3692
3988
  return this;
3693
3989
  }
3694
3990
  /**
@@ -3701,7 +3997,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3701
3997
  * whose data type is a fixed-size-list of floats.
3702
3998
  */
3703
3999
  column(column) {
3704
- super.doCall((inner) => inner.column(column));
4000
+ this.doVectorCall((inner) => inner.column(column));
3705
4001
  return this;
3706
4002
  }
3707
4003
  /**
@@ -3719,7 +4015,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3719
4015
  * By default "l2" is used.
3720
4016
  */
3721
4017
  distanceType(distanceType) {
3722
- super.doCall((inner) => inner.distanceType(distanceType));
4018
+ this.doVectorCall((inner) => inner.distanceType(distanceType));
3723
4019
  return this;
3724
4020
  }
3725
4021
  /**
@@ -3752,7 +4048,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3752
4048
  * distance between the query vector and the actual uncompressed vector.
3753
4049
  */
3754
4050
  refineFactor(refineFactor) {
3755
- super.doCall((inner) => inner.refineFactor(refineFactor));
4051
+ this.doVectorCall((inner) => inner.refineFactor(refineFactor));
3756
4052
  return this;
3757
4053
  }
3758
4054
  /**
@@ -3776,7 +4072,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3776
4072
  * factor can often help restore some of the results lost by post filtering.
3777
4073
  */
3778
4074
  postfilter() {
3779
- super.doCall((inner) => inner.postfilter());
4075
+ this.doVectorCall((inner) => inner.postfilter());
3780
4076
  return this;
3781
4077
  }
3782
4078
  /**
@@ -3789,31 +4085,33 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3789
4085
  * calculate your recall to select an appropriate value for nprobes.
3790
4086
  */
3791
4087
  bypassVectorIndex() {
3792
- super.doCall((inner) => inner.bypassVectorIndex());
4088
+ this.doVectorCall((inner) => inner.bypassVectorIndex());
3793
4089
  return this;
3794
4090
  }
3795
4091
  addQueryVector(vector) {
3796
4092
  if (vector instanceof Promise) {
4093
+ const settledVector = vector.then((value) => ({
4094
+ status: "fulfilled",
4095
+ value
4096
+ }), (reason) => ({
4097
+ status: "rejected",
4098
+ reason
4099
+ }));
3797
4100
  const res = (async () => {
3798
- try {
3799
- const v = await vector;
3800
- return this.addQueryVector(v).inner;
3801
- } catch (e) {
3802
- return Promise.reject(e);
3803
- }
4101
+ const inner = await this.getInner();
4102
+ const outcome = await settledVector;
4103
+ if (outcome.status === "rejected") throw outcome.reason;
4104
+ addQueryVectorToNative(inner, outcome.value);
4105
+ return inner;
3804
4106
  })();
3805
4107
  return new VectorQuery(res);
3806
4108
  } else {
3807
- super.doCall((inner) => {
3808
- const raw = Array.isArray(vector) ? null : (0, arrow_1.extractVectorBuffer)(vector);
3809
- if (raw) inner.addQueryVectorRaw(raw.data, raw.dtype);
3810
- else inner.addQueryVector(Float32Array.from(vector));
3811
- });
4109
+ this.doVectorCall((inner) => addQueryVectorToNative(inner, vector));
3812
4110
  return this;
3813
4111
  }
3814
4112
  }
3815
4113
  rerank(reranker) {
3816
- super.doCall((inner) => inner.rerank(async (args) => {
4114
+ this.doVectorCall((inner) => inner.rerank(async (args) => {
3817
4115
  const vecResults = await (0, arrow_1.fromBufferToRecordBatch)(args.vecResults);
3818
4116
  const ftsResults = await (0, arrow_1.fromBufferToRecordBatch)(args.ftsResults);
3819
4117
  const result = await reranker.rerankHybrid(args.query, vecResults, ftsResults);
@@ -3824,6 +4122,48 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3824
4122
  };
3825
4123
  exports.VectorQuery = VectorQuery;
3826
4124
  /**
4125
+ * Create a string query whose vector/FTS routing is resolved against the active
4126
+ * table schema when the query executes.
4127
+ *
4128
+ * @hidden
4129
+ */
4130
+ function createAutoQuery(table, query, columns, getVector) {
4131
+ let cachedPreparation;
4132
+ const snapshotRoute = async () => {
4133
+ const snapshot = await table.querySnapshot();
4134
+ return {
4135
+ table: snapshot,
4136
+ embeddingMetadata: (0, arrow_1.tableFromIPC)(await snapshot.schema()).schema.metadata.get("embedding_functions")
4137
+ };
4138
+ };
4139
+ const createInner = async () => {
4140
+ const route = await snapshotRoute();
4141
+ if (route.embeddingMetadata === void 0) {
4142
+ const inner = route.table.query();
4143
+ inner.fullTextSearch({
4144
+ query,
4145
+ columns
4146
+ });
4147
+ return inner;
4148
+ }
4149
+ const metadata = route.embeddingMetadata;
4150
+ if (cachedPreparation?.metadata !== metadata) cachedPreparation = {
4151
+ metadata,
4152
+ vector: Promise.resolve().then(() => getVector(metadata))
4153
+ };
4154
+ const preparation = cachedPreparation;
4155
+ let vector;
4156
+ try {
4157
+ vector = await preparation.vector;
4158
+ } catch (error) {
4159
+ if (cachedPreparation === preparation) cachedPreparation = void 0;
4160
+ throw error;
4161
+ }
4162
+ return nearestToNative(route.table.query(), vector);
4163
+ };
4164
+ return new AutoQuery(createInner);
4165
+ }
4166
+ /**
3827
4167
  * A query that returns a subset of the rows in the table.
3828
4168
  *
3829
4169
  * @hideconstructor
@@ -3847,6 +4187,36 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3847
4187
  }
3848
4188
  };
3849
4189
  exports.TakeQuery = TakeQuery;
4190
+ /**
4191
+ * A builder for automatic string searches.
4192
+ *
4193
+ * Automatic search determines whether to use full-text or vector search from
4194
+ * the table revision selected for each execution. This builder exposes the
4195
+ * common operations supported by both query families.
4196
+ *
4197
+ * @hideconstructor
4198
+ */
4199
+ var AutoQuery = class extends StandardQueryBase {
4200
+ createInner;
4201
+ calls = [];
4202
+ /** @hidden */
4203
+ constructor(createInner) {
4204
+ super();
4205
+ this.createInner = createInner;
4206
+ }
4207
+ /** @hidden */
4208
+ doCall(fn) {
4209
+ this.calls.push(fn);
4210
+ }
4211
+ /** @hidden */
4212
+ async getInner() {
4213
+ const calls = [...this.calls];
4214
+ const inner = await this.createInner();
4215
+ for (const call of calls) call(inner);
4216
+ return inner;
4217
+ }
4218
+ };
4219
+ exports.AutoQuery = AutoQuery;
3850
4220
  /** A builder for LanceDB queries.
3851
4221
  *
3852
4222
  * @see {@link Table#query}, {@link Table#search}
@@ -3898,24 +4268,10 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
3898
4268
  * a default `limit` of 10 will be used. @see {@link Query#limit}
3899
4269
  */
3900
4270
  nearestTo(vector) {
3901
- const callNearestTo = (inner, resolved) => {
3902
- const raw = Array.isArray(resolved) ? null : (0, arrow_1.extractVectorBuffer)(resolved);
3903
- if (raw) return inner.nearestToRaw(raw.data, raw.dtype);
3904
- return inner.nearestTo(Float32Array.from(resolved));
3905
- };
3906
- if (this.inner instanceof Promise) return new VectorQuery(this.inner.then(async (inner) => {
3907
- const resolved = vector instanceof Promise ? await vector : vector;
3908
- return callNearestTo(inner, resolved);
3909
- }));
3910
- if (vector instanceof Promise) return new VectorQuery((async () => {
3911
- try {
3912
- const v = await vector;
3913
- return this.nearestTo(v).inner;
3914
- } catch (e) {
3915
- return Promise.reject(e);
3916
- }
3917
- })());
3918
- else return new VectorQuery(callNearestTo(this.inner, vector));
4271
+ const inner = this.inner;
4272
+ if (inner instanceof Promise) return new VectorQuery(inner.then(async (resolvedInner) => nearestToNative(resolvedInner, await vector)));
4273
+ if (vector instanceof Promise) return new VectorQuery(vector.then((resolvedVector) => nearestToNative(inner, resolvedVector)));
4274
+ return new VectorQuery(nearestToNative(inner, vector));
3919
4275
  }
3920
4276
  nearestToText(query, columns) {
3921
4277
  this.doCall((inner) => {
@@ -4077,7 +4433,7 @@ var require_query = /* @__PURE__ */ __commonJSMin(((exports) => {
4077
4433
  exports.BooleanQuery = BooleanQuery;
4078
4434
  }));
4079
4435
  //#endregion
4080
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/util.js
4436
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/util.js
4081
4437
  var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
4082
4438
  Object.defineProperty(exports, "__esModule", { value: true });
4083
4439
  exports.TTLCache = void 0;
@@ -4135,7 +4491,7 @@ var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
4135
4491
  exports.TTLCache = TTLCache;
4136
4492
  }));
4137
4493
  //#endregion
4138
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/table.js
4494
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/table.js
4139
4495
  var require_table = /* @__PURE__ */ __commonJSMin(((exports) => {
4140
4496
  Object.defineProperty(exports, "__esModule", { value: true });
4141
4497
  exports.Branches = exports.LocalTable = exports.Table = void 0;
@@ -4187,8 +4543,9 @@ var require_table = /* @__PURE__ */ __commonJSMin(((exports) => {
4187
4543
  display() {
4188
4544
  return this.inner.display();
4189
4545
  }
4190
- async getEmbeddingFunctions() {
4191
- const schema = await this.schema();
4546
+ async getEmbeddingFunctions(inner = this.inner) {
4547
+ const schemaBuf = await inner.schema();
4548
+ const schema = (0, arrow_1.tableFromIPC)(schemaBuf).schema;
4192
4549
  return (0, registry_1.getRegistry)().parseFunctions(schema.metadata);
4193
4550
  }
4194
4551
  /** Get the schema of the table. */
@@ -4293,7 +4650,15 @@ var require_table = /* @__PURE__ */ __commonJSMin(((exports) => {
4293
4650
  return this.vectorSearch(query);
4294
4651
  }
4295
4652
  if (queryType === "fts") return this.query().fullTextSearch(query, { columns: ftsColumns });
4296
- if (queryType === "auto" && ((0, registry_1.getRegistry)().length() === 0 || (0, query_1.instanceOfFullTextQuery)(query))) return this.query().fullTextSearch(query, { columns: ftsColumns });
4653
+ if (queryType === "auto") {
4654
+ if ((0, query_1.instanceOfFullTextQuery)(query)) return this.query().fullTextSearch(query, { columns: ftsColumns });
4655
+ const columns = typeof ftsColumns === "string" ? [ftsColumns] : ftsColumns ?? null;
4656
+ return (0, query_1.createAutoQuery)(this.inner, query, columns, async (metadata) => {
4657
+ const embeddingFunc = (await (0, registry_1.getRegistry)().parseFunctions(/* @__PURE__ */ new Map([["embedding_functions", metadata]]))).values().next().value;
4658
+ if (!embeddingFunc) throw new Error("Invalid embedding function metadata");
4659
+ return await embeddingFunc.function.computeQueryEmbeddings(query);
4660
+ });
4661
+ }
4297
4662
  const queryPromise = this.getEmbeddingFunctions().then(async (functions) => {
4298
4663
  const embeddingFunc = functions.values().next().value;
4299
4664
  if (!embeddingFunc) return Promise.reject(/* @__PURE__ */ new Error("No embedding functions are defined in the table"));
@@ -4310,6 +4675,7 @@ var require_table = /* @__PURE__ */ __commonJSMin(((exports) => {
4310
4675
  return this.query().nearestTo(vector);
4311
4676
  }
4312
4677
  async addColumns(newColumnTransforms) {
4678
+ if (typeof newColumnTransforms === "object" && !Array.isArray(newColumnTransforms) && "computed" in newColumnTransforms) return await this.inner.addComputedColumns(newColumnTransforms.computed);
4313
4679
  if (newColumnTransforms instanceof arrow_1.Field) newColumnTransforms = [newColumnTransforms];
4314
4680
  if (Array.isArray(newColumnTransforms) && newColumnTransforms.length > 0 && newColumnTransforms[0] instanceof arrow_1.Field) {
4315
4681
  const fields = newColumnTransforms;
@@ -4324,6 +4690,15 @@ var require_table = /* @__PURE__ */ __commonJSMin(((exports) => {
4324
4690
  if (Array.isArray(newColumnTransforms)) return await this.inner.addColumns(newColumnTransforms);
4325
4691
  throw new Error("Invalid input type for addColumns");
4326
4692
  }
4693
+ async refreshColumn(column) {
4694
+ return await this.inner.refreshColumn(column);
4695
+ }
4696
+ async refreshColumnAsync(column) {
4697
+ return await this.inner.refreshColumnAsync(column);
4698
+ }
4699
+ async refreshMaterializedView(full, sourceVersion) {
4700
+ return await this.inner.refreshMaterializedView(full, sourceVersion);
4701
+ }
4327
4702
  async alterColumns(columnAlterations) {
4328
4703
  const processedAlterations = columnAlterations.map((alteration) => {
4329
4704
  if (typeof alteration.dataType === "string") return {
@@ -4366,6 +4741,18 @@ var require_table = /* @__PURE__ */ __commonJSMin(((exports) => {
4366
4741
  async closeLsmWriters() {
4367
4742
  return await this.inner.closeLsmWriters();
4368
4743
  }
4744
+ async flushLsm() {
4745
+ return await this.inner.flushLsm();
4746
+ }
4747
+ async compactLsm() {
4748
+ return await this.inner.compactLsm();
4749
+ }
4750
+ async checkpointLsm() {
4751
+ return await this.inner.checkpointLsm();
4752
+ }
4753
+ async getLsmStats(includeGenerationRows = false) {
4754
+ return await this.inner.getLsmStats(includeGenerationRows) ?? void 0;
4755
+ }
4369
4756
  async version() {
4370
4757
  return await this.inner.version();
4371
4758
  }
@@ -4502,22 +4889,22 @@ var require_table = /* @__PURE__ */ __commonJSMin(((exports) => {
4502
4889
  return await this.#inner.diff(fromBranch);
4503
4890
  }
4504
4891
  /**
4505
- * Merge a branch into main.
4892
+ * Cherry-pick a branch onto main.
4506
4893
  *
4507
- * Set `dryRun` to `true` to preview the merge. A rejected merge resolves
4508
- * with `status: "rejected"` instead of throwing.
4894
+ * Set `dryRun` to `true` to preview. A failed cherry-pick resolves
4895
+ * with `status: "failed"` instead of throwing.
4509
4896
  *
4510
- * @param fromBranch Branch to merge from.
4511
- * @param dryRun When true, only preview the merge. Defaults to false.
4897
+ * @param fromBranch Branch to cherry-pick from.
4898
+ * @param dryRun When true, only preview. Defaults to false.
4512
4899
  */
4513
- async merge(fromBranch, dryRun = false) {
4514
- return await this.#inner.merge(fromBranch, dryRun);
4900
+ async cherryPick(fromBranch, dryRun = false) {
4901
+ return await this.#inner.cherryPick(fromBranch, dryRun);
4515
4902
  }
4516
4903
  };
4517
4904
  exports.Branches = Branches;
4518
4905
  }));
4519
4906
  //#endregion
4520
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/connection.js
4907
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/connection.js
4521
4908
  var require_connection = /* @__PURE__ */ __commonJSMin(((exports) => {
4522
4909
  Object.defineProperty(exports, "__esModule", { value: true });
4523
4910
  exports.LocalConnection = exports.Connection = void 0;
@@ -4526,6 +4913,7 @@ var require_connection = /* @__PURE__ */ __commonJSMin(((exports) => {
4526
4913
  const arrow_1 = require_arrow();
4527
4914
  const arrow_2 = require_arrow();
4528
4915
  const registry_1 = require_registry();
4916
+ const materialized_view_1 = require_materialized_view();
4529
4917
  const sanitize_1 = require_sanitize();
4530
4918
  const table_1 = require_table();
4531
4919
  /**
@@ -4582,6 +4970,23 @@ var require_connection = /* @__PURE__ */ __commonJSMin(((exports) => {
4582
4970
  }
4583
4971
  return this.inner.tableNames(namespacePath ?? [], tableNamesOptions?.startAfter, tableNamesOptions?.limit);
4584
4972
  }
4973
+ async createMaterializedView(name, source, options) {
4974
+ (0, materialized_view_1.validateNonNegativeInteger)(options?.limit, "limit");
4975
+ const innerTable = await this.inner.createMaterializedView(name, source, (0, materialized_view_1.normalizeSelect)(options?.select), options?.where, options?.limit);
4976
+ return new materialized_view_1.MaterializedView(new table_1.LocalTable(innerTable));
4977
+ }
4978
+ async openMaterializedView(name) {
4979
+ const innerTable = await this.inner.openMaterializedView(name);
4980
+ return new materialized_view_1.MaterializedView(new table_1.LocalTable(innerTable));
4981
+ }
4982
+ async listMaterializedViews() {
4983
+ return await this.inner.listMaterializedViews();
4984
+ }
4985
+ async listTables(namespacePathOrOptions, options) {
4986
+ const namespacePath = Array.isArray(namespacePathOrOptions) ? namespacePathOrOptions : void 0;
4987
+ const listTablesOptions = Array.isArray(namespacePathOrOptions) ? options : namespacePathOrOptions;
4988
+ return this.inner.listTables(namespacePath ?? [], listTablesOptions?.pageToken, listTablesOptions?.limit);
4989
+ }
4585
4990
  async openTable(name, namespacePath, options) {
4586
4991
  const innerTable = await this.inner.openTable(name, namespacePath ?? [], cleanseStorageOptions(options?.storageOptions), options?.indexCacheSize);
4587
4992
  let table = new table_1.LocalTable(innerTable);
@@ -4658,6 +5063,9 @@ var require_connection = /* @__PURE__ */ __commonJSMin(((exports) => {
4658
5063
  async dropTable(name, namespacePath) {
4659
5064
  return this.inner.dropTable(name, namespacePath ?? []);
4660
5065
  }
5066
+ async dropTableAsync(name, namespacePath) {
5067
+ return this.inner.dropTableAsync(name, namespacePath ?? []);
5068
+ }
4661
5069
  async dropAllTables(namespacePath) {
4662
5070
  return this.inner.dropAllTables(namespacePath ?? []);
4663
5071
  }
@@ -6248,7 +6656,7 @@ var init_esm = __esmMin((() => {
6248
6656
  };
6249
6657
  }));
6250
6658
  //#endregion
6251
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/otel.js
6659
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/otel.js
6252
6660
  var require_otel = /* @__PURE__ */ __commonJSMin(((exports) => {
6253
6661
  Object.defineProperty(exports, "__esModule", { value: true });
6254
6662
  exports.instrumentLanceDbMetrics = instrumentLanceDbMetrics;
@@ -6332,7 +6740,7 @@ var require_otel = /* @__PURE__ */ __commonJSMin(((exports) => {
6332
6740
  }
6333
6741
  }));
6334
6742
  //#endregion
6335
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/indices.js
6743
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/indices.js
6336
6744
  var require_indices = /* @__PURE__ */ __commonJSMin(((exports) => {
6337
6745
  Object.defineProperty(exports, "__esModule", { value: true });
6338
6746
  exports.Index = void 0;
@@ -6498,7 +6906,7 @@ var require_indices = /* @__PURE__ */ __commonJSMin(((exports) => {
6498
6906
  };
6499
6907
  }));
6500
6908
  //#endregion
6501
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/header.js
6909
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/header.js
6502
6910
  var require_header = /* @__PURE__ */ __commonJSMin(((exports) => {
6503
6911
  Object.defineProperty(exports, "__esModule", { value: true });
6504
6912
  exports.OAuthHeaderProvider = exports.StaticHeaderProvider = exports.HeaderProvider = void 0;
@@ -6688,7 +7096,7 @@ var require_header = /* @__PURE__ */ __commonJSMin(((exports) => {
6688
7096
  exports.OAuthHeaderProvider = OAuthHeaderProvider;
6689
7097
  }));
6690
7098
  //#endregion
6691
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/oauth.js
7099
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/oauth.js
6692
7100
  var require_oauth = /* @__PURE__ */ __commonJSMin(((exports) => {
6693
7101
  Object.defineProperty(exports, "__esModule", { value: true });
6694
7102
  exports.OAuthFlowType = void 0;
@@ -6704,7 +7112,7 @@ var require_oauth = /* @__PURE__ */ __commonJSMin(((exports) => {
6704
7112
  })(OAuthFlowType || (exports.OAuthFlowType = OAuthFlowType = {}));
6705
7113
  }));
6706
7114
  //#endregion
6707
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/embedding_function.js
7115
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/embedding_function.js
6708
7116
  var require_embedding_function = /* @__PURE__ */ __commonJSMin(((exports) => {
6709
7117
  Object.defineProperty(exports, "__esModule", { value: true });
6710
7118
  exports.TextEmbeddingFunction = exports.EmbeddingFunction = void 0;
@@ -6852,27 +7260,162 @@ var require_embedding_function = /* @__PURE__ */ __commonJSMin(((exports) => {
6852
7260
  exports.TextEmbeddingFunction = TextEmbeddingFunction;
6853
7261
  }));
6854
7262
  //#endregion
6855
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/index.js
6856
- var require_embedding = /* @__PURE__ */ __commonJSMin(((exports) => {
6857
- var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
6858
- if (k2 === void 0) k2 = k;
6859
- var desc = Object.getOwnPropertyDescriptor(m, k);
6860
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
6861
- enumerable: true,
6862
- get: function() {
6863
- return m[k];
7263
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/openai.js
7264
+ var require_openai = /* @__PURE__ */ __commonJSMin(((exports) => {
7265
+ Object.defineProperty(exports, "__esModule", { value: true });
7266
+ exports.OpenAIEmbeddingFunction = void 0;
7267
+ const arrow_1 = require_arrow();
7268
+ const embedding_function_1 = require_embedding_function();
7269
+ const registry_1 = require_registry();
7270
+ var OpenAIEmbeddingFunction = class extends embedding_function_1.EmbeddingFunction {
7271
+ #openai;
7272
+ #modelName;
7273
+ constructor(optionsRaw = { model: "text-embedding-ada-002" }) {
7274
+ super();
7275
+ const options = this.resolveVariables(optionsRaw);
7276
+ const openAIKey = options?.apiKey ?? process.env.OPENAI_API_KEY;
7277
+ if (!openAIKey) throw new Error("OpenAI API key is required");
7278
+ const modelName = options?.model ?? "text-embedding-ada-002";
7279
+ /**
7280
+ * @type {import("openai").default}
7281
+ */
7282
+ let Openai;
7283
+ try {
7284
+ Openai = __require("openai");
7285
+ } catch {
7286
+ throw new Error("please install openai@^4.24.1 using npm install openai");
6864
7287
  }
6865
- };
6866
- Object.defineProperty(o, k2, desc);
6867
- }) : (function(o, m, k, k2) {
6868
- if (k2 === void 0) k2 = k;
6869
- o[k2] = m[k];
6870
- }));
6871
- var __exportStar = exports && exports.__exportStar || function(m, exports$2) {
6872
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$2, p)) __createBinding(exports$2, m, p);
7288
+ const configuration = { apiKey: openAIKey };
7289
+ this.#openai = new Openai(configuration);
7290
+ this.#modelName = modelName;
7291
+ }
7292
+ getSensitiveKeys() {
7293
+ return ["apiKey"];
7294
+ }
7295
+ ndims() {
7296
+ switch (this.#modelName) {
7297
+ case "text-embedding-ada-002": return 1536;
7298
+ case "text-embedding-3-large": return 3072;
7299
+ case "text-embedding-3-small": return 1536;
7300
+ default: throw new Error(`Unknown model: ${this.#modelName}`);
7301
+ }
7302
+ }
7303
+ embeddingDataType() {
7304
+ return new arrow_1.Float32();
7305
+ }
7306
+ async computeSourceEmbeddings(data) {
7307
+ const response = await this.#openai.embeddings.create({
7308
+ model: this.#modelName,
7309
+ input: data
7310
+ });
7311
+ const embeddings = [];
7312
+ for (let i = 0; i < response.data.length; i++) embeddings.push(response.data[i].embedding);
7313
+ return embeddings;
7314
+ }
7315
+ async computeQueryEmbeddings(data) {
7316
+ if (typeof data !== "string") throw new Error("Data must be a string");
7317
+ return (await this.#openai.embeddings.create({
7318
+ model: this.#modelName,
7319
+ input: data
7320
+ })).data[0].embedding;
7321
+ }
6873
7322
  };
7323
+ exports.OpenAIEmbeddingFunction = OpenAIEmbeddingFunction;
7324
+ (0, registry_1.registerBuiltIn)("openai", OpenAIEmbeddingFunction);
7325
+ }));
7326
+ //#endregion
7327
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/transformers.js
7328
+ var require_transformers = /* @__PURE__ */ __commonJSMin(((exports) => {
6874
7329
  Object.defineProperty(exports, "__esModule", { value: true });
6875
- exports.TextEmbeddingFunction = exports.EmbeddingFunction = void 0;
7330
+ exports.TransformersEmbeddingFunction = void 0;
7331
+ const arrow_1 = require_arrow();
7332
+ const embedding_function_1 = require_embedding_function();
7333
+ const registry_1 = require_registry();
7334
+ var TransformersEmbeddingFunction = class extends embedding_function_1.EmbeddingFunction {
7335
+ #model;
7336
+ #tokenizer;
7337
+ #modelName;
7338
+ #initialized = false;
7339
+ #tokenizerOptions;
7340
+ #ndims;
7341
+ constructor(optionsRaw = { model: "Xenova/all-MiniLM-L6-v2" }) {
7342
+ super();
7343
+ const options = this.resolveVariables(optionsRaw);
7344
+ const modelName = options?.model ?? "Xenova/all-MiniLM-L6-v2";
7345
+ this.#tokenizerOptions = {
7346
+ padding: true,
7347
+ ...options.tokenizerOptions
7348
+ };
7349
+ this.#ndims = options.ndims;
7350
+ this.#modelName = modelName;
7351
+ }
7352
+ async init() {
7353
+ let transformers;
7354
+ try {
7355
+ transformers = await eval("import(\"@huggingface/transformers\")");
7356
+ } catch (e) {
7357
+ throw new Error(`error loading @huggingface/transformers\nReason: ${e}`);
7358
+ }
7359
+ try {
7360
+ this.#model = await transformers.AutoModel.from_pretrained(this.#modelName, { dtype: "fp32" });
7361
+ } catch (e) {
7362
+ throw new Error(`error loading model ${this.#modelName}. Make sure you are using a wasm compatible model.\nReason: ${e}`);
7363
+ }
7364
+ try {
7365
+ this.#tokenizer = await transformers.AutoTokenizer.from_pretrained(this.#modelName);
7366
+ } catch (e) {
7367
+ throw new Error(`error loading tokenizer for ${this.#modelName}. Make sure you are using a wasm compatible model:\nReason: ${e}`);
7368
+ }
7369
+ this.#initialized = true;
7370
+ }
7371
+ ndims() {
7372
+ if (this.#ndims) return this.#ndims;
7373
+ else {
7374
+ const ndims = this.#model.config.hidden_size;
7375
+ if (!ndims) throw new Error("hidden_size not found in model config, you may need to manually specify the embedding dimensions. ");
7376
+ return ndims;
7377
+ }
7378
+ }
7379
+ embeddingDataType() {
7380
+ return new arrow_1.Float32();
7381
+ }
7382
+ async computeSourceEmbeddings(data) {
7383
+ if (!this.#initialized) return Promise.reject(/* @__PURE__ */ new Error("something went wrong: embedding function not initialized. Please call init()"));
7384
+ const tokenizer = this.#tokenizer;
7385
+ const model = this.#model;
7386
+ const inputs = await tokenizer(data, this.#tokenizerOptions);
7387
+ let tokens = await model.forward(inputs);
7388
+ tokens = tokens[Object.keys(tokens)[0]];
7389
+ const [nItems, nTokens] = tokens.dims;
7390
+ tokens = tensorDiv(tokens.sum(1), nTokens);
7391
+ const tokenData = tokens.data;
7392
+ const stride = this.ndims();
7393
+ const embeddings = [];
7394
+ for (let i = 0; i < nItems; i++) {
7395
+ const start = i * stride;
7396
+ const end = start + stride;
7397
+ const slice = tokenData.slice(start, end);
7398
+ embeddings.push(Array.from(slice));
7399
+ }
7400
+ return embeddings;
7401
+ }
7402
+ async computeQueryEmbeddings(data) {
7403
+ return (await this.computeSourceEmbeddings([data]))[0];
7404
+ }
7405
+ };
7406
+ exports.TransformersEmbeddingFunction = TransformersEmbeddingFunction;
7407
+ (0, registry_1.registerBuiltIn)("huggingface", TransformersEmbeddingFunction);
7408
+ const tensorDiv = (src, divBy) => {
7409
+ for (let i = 0; i < src.data.length; ++i) src.data[i] /= divBy;
7410
+ return src;
7411
+ };
7412
+ }));
7413
+ //#endregion
7414
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/embedding/index.js
7415
+ var require_embedding = /* @__PURE__ */ __commonJSMin(((exports) => {
7416
+ Object.defineProperty(exports, "__esModule", { value: true });
7417
+ exports.register = exports.parseEmbeddingMetadata = exports.EmbeddingFunctionRegistry = exports.TextEmbeddingFunction = exports.EmbeddingFunction = void 0;
7418
+ exports.getRegistry = getRegistry;
6876
7419
  exports.LanceSchema = LanceSchema;
6877
7420
  const arrow_1 = require_arrow();
6878
7421
  const sanitize_1 = require_sanitize();
@@ -6890,7 +7433,42 @@ var require_embedding = /* @__PURE__ */ __commonJSMin(((exports) => {
6890
7433
  return embedding_function_1.TextEmbeddingFunction;
6891
7434
  }
6892
7435
  });
6893
- __exportStar(require_registry(), exports);
7436
+ var registry_2 = require_registry();
7437
+ Object.defineProperty(exports, "EmbeddingFunctionRegistry", {
7438
+ enumerable: true,
7439
+ get: function() {
7440
+ return registry_2.EmbeddingFunctionRegistry;
7441
+ }
7442
+ });
7443
+ Object.defineProperty(exports, "parseEmbeddingMetadata", {
7444
+ enumerable: true,
7445
+ get: function() {
7446
+ return registry_2.parseEmbeddingMetadata;
7447
+ }
7448
+ });
7449
+ Object.defineProperty(exports, "register", {
7450
+ enumerable: true,
7451
+ get: function() {
7452
+ return registry_2.register;
7453
+ }
7454
+ });
7455
+ function initializeBuiltInProviders() {
7456
+ const { OpenAIEmbeddingFunction } = require_openai();
7457
+ const { TransformersEmbeddingFunction } = require_transformers();
7458
+ (0, registry_1.registerBuiltIn)("openai", OpenAIEmbeddingFunction);
7459
+ (0, registry_1.registerBuiltIn)("huggingface", TransformersEmbeddingFunction);
7460
+ }
7461
+ /**
7462
+ * Get the global embedding function registry.
7463
+ *
7464
+ * LanceDB built-in providers are initialized when this public API is first
7465
+ * used, so importing the root package does not change automatic search
7466
+ * selection for tables without embedding metadata.
7467
+ */
7468
+ function getRegistry() {
7469
+ initializeBuiltInProviders();
7470
+ return (0, registry_1.getRegistry)();
7471
+ }
6894
7472
  /**
6895
7473
  * Create a schema with embedding functions.
6896
7474
  *
@@ -6923,7 +7501,7 @@ var require_embedding = /* @__PURE__ */ __commonJSMin(((exports) => {
6923
7501
  parseEmbeddingFunctions(embeddingFunctions, key, metadata);
6924
7502
  } else arrowFields.push(new arrow_1.Field(key, (0, sanitize_1.sanitizeType)(value), true));
6925
7503
  });
6926
- const metadata = (0, registry_1.getRegistry)().getTableMetadata(Array.from(embeddingFunctions.values()));
7504
+ const metadata = getRegistry().getTableMetadata(Array.from(embeddingFunctions.values()));
6927
7505
  return new arrow_1.Schema(arrowFields, metadata);
6928
7506
  }
6929
7507
  function parseEmbeddingFunctions(embeddingFunctions, key, metadata) {
@@ -6953,7 +7531,7 @@ var require_embedding = /* @__PURE__ */ __commonJSMin(((exports) => {
6953
7531
  }
6954
7532
  }));
6955
7533
  //#endregion
6956
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/permutation.js
7534
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/permutation.js
6957
7535
  var require_permutation = /* @__PURE__ */ __commonJSMin(((exports) => {
6958
7536
  Object.defineProperty(exports, "__esModule", { value: true });
6959
7537
  exports.PermutationBuilder = void 0;
@@ -7133,7 +7711,7 @@ var require_permutation = /* @__PURE__ */ __commonJSMin(((exports) => {
7133
7711
  }
7134
7712
  }));
7135
7713
  //#endregion
7136
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/scannable.js
7714
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/scannable.js
7137
7715
  var require_scannable = /* @__PURE__ */ __commonJSMin(((exports) => {
7138
7716
  Object.defineProperty(exports, "__esModule", { value: true });
7139
7717
  exports.Scannable = void 0;
@@ -7268,7 +7846,7 @@ var require_scannable = /* @__PURE__ */ __commonJSMin(((exports) => {
7268
7846
  }
7269
7847
  }));
7270
7848
  //#endregion
7271
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/rerankers/rrf.js
7849
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/rerankers/rrf.js
7272
7850
  var require_rrf = /* @__PURE__ */ __commonJSMin(((exports) => {
7273
7851
  Object.defineProperty(exports, "__esModule", { value: true });
7274
7852
  exports.RRFReranker = void 0;
@@ -7290,7 +7868,7 @@ var require_rrf = /* @__PURE__ */ __commonJSMin(((exports) => {
7290
7868
  };
7291
7869
  }));
7292
7870
  //#endregion
7293
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/rerankers/index.js
7871
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/rerankers/index.js
7294
7872
  var require_rerankers = /* @__PURE__ */ __commonJSMin(((exports) => {
7295
7873
  var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
7296
7874
  if (k2 === void 0) k2 = k;
@@ -7313,15 +7891,22 @@ var require_rerankers = /* @__PURE__ */ __commonJSMin(((exports) => {
7313
7891
  __exportStar(require_rrf(), exports);
7314
7892
  }));
7315
7893
  //#endregion
7316
- //#region node_modules/.pnpm/@lancedb+lancedb@0.37.1_@types+node@26.4.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/index.js
7894
+ //#region node_modules/.pnpm/@lancedb+lancedb@0.38.0_@types+node@26.5.0_apache-arrow@18.1.0/node_modules/@lancedb/lancedb/dist/index.js
7317
7895
  var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
7318
7896
  Object.defineProperty(exports, "__esModule", { value: true });
7319
- exports.packBits = exports.rerankers = exports.Scannable = exports.PermutationBuilder = exports.permutationBuilder = exports.embedding = exports.MergeInsertBuilder = exports.OAuthFlowType = exports.OAuthHeaderProvider = exports.StaticHeaderProvider = exports.HeaderProvider = exports.Branches = 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.Job = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.BranchContents = exports.TagContents = exports.Tags = exports.instrumentLanceDbMetrics = exports.NativeJsHeaderProvider = void 0;
7897
+ exports.packBits = exports.rerankers = exports.Scannable = exports.PermutationBuilder = exports.permutationBuilder = exports.embedding = exports.MergeInsertBuilder = exports.OAuthFlowType = exports.OAuthHeaderProvider = exports.StaticHeaderProvider = exports.HeaderProvider = exports.Branches = 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.AutoQuery = exports.Session = exports.Job = exports.Connection = exports.VectorColumnOptions = exports.MakeArrowTableOptions = exports.makeArrowTable = exports.BranchContents = exports.TagContents = exports.Tags = exports.instrumentLanceDbMetrics = exports.NativeJsHeaderProvider = exports.MaterializedView = void 0;
7320
7898
  exports.tokenize = tokenize;
7321
7899
  exports.connect = connect;
7322
7900
  exports.connectNamespace = connectNamespace;
7323
7901
  const connection_1 = require_connection();
7324
7902
  const native_js_1 = require_native();
7903
+ var materialized_view_1 = require_materialized_view();
7904
+ Object.defineProperty(exports, "MaterializedView", {
7905
+ enumerable: true,
7906
+ get: function() {
7907
+ return materialized_view_1.MaterializedView;
7908
+ }
7909
+ });
7325
7910
  var native_js_2 = require_native();
7326
7911
  Object.defineProperty(exports, "NativeJsHeaderProvider", {
7327
7912
  enumerable: true,
@@ -7395,6 +7980,12 @@ var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
7395
7980
  }
7396
7981
  });
7397
7982
  var query_1 = require_query();
7983
+ Object.defineProperty(exports, "AutoQuery", {
7984
+ enumerable: true,
7985
+ get: function() {
7986
+ return query_1.AutoQuery;
7987
+ }
7988
+ });
7398
7989
  Object.defineProperty(exports, "Query", {
7399
7990
  enumerable: true,
7400
7991
  get: function() {