@mastra/lance 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -144,7 +144,7 @@ var LanceDB = class extends MastraBase {
144
144
  return (await (await this.client.openTable(tableName)).schema()).fields.some((field) => field.name === columnName);
145
145
  }
146
146
  translateSchema(schema) {
147
- return new Schema(Object.entries(schema).map(([name, column]) => {
147
+ const fields = Object.entries(schema).map(([name, column]) => {
148
148
  let arrowType;
149
149
  switch (column.type.toLowerCase()) {
150
150
  case "text":
@@ -174,7 +174,8 @@ var LanceDB = class extends MastraBase {
174
174
  default: arrowType = new Utf8();
175
175
  }
176
176
  return new Field(name, arrowType, column.nullable ?? true);
177
- }));
177
+ });
178
+ return new Schema(fields);
178
179
  }
179
180
  async createTable({ tableName, schema }) {
180
181
  try {
@@ -780,7 +781,7 @@ var StoreMemoryLance = class extends MemoryStorage {
780
781
  if (!updatedThread) throw new Error(`Failed to retrieve updated thread ${id}`);
781
782
  return updatedThread;
782
783
  } catch (error) {
783
- if (error.message?.includes("Commit conflict") && attempt < maxRetries - 1) {
784
+ if (error.message?.includes("Commit conflict") && attempt < 4) {
784
785
  const delay = Math.pow(2, attempt) * 10;
785
786
  await new Promise((resolve) => setTimeout(resolve, delay));
786
787
  continue;
@@ -1353,12 +1354,12 @@ var StoreMemoryLance = class extends MemoryStorage {
1353
1354
  updatedAt: updatedResource.updatedAt.getTime()
1354
1355
  };
1355
1356
  if ((await (await this.client.openTable(TABLE_RESOURCES)).mergeInsert("id").whenMatchedUpdateAll().execute([record])).numUpdatedRows === 0) {
1356
- if (attempt < maxRetries - 1) continue;
1357
+ if (attempt < 2) continue;
1357
1358
  throw new Error(`Resource ${resourceId} disappeared while it was being updated`);
1358
1359
  }
1359
1360
  return updatedResource;
1360
1361
  } catch (error) {
1361
- if (error.message?.includes("Commit conflict") && attempt < maxRetries - 1) {
1362
+ if (error.message?.includes("Commit conflict") && attempt < 2) {
1362
1363
  const delay = Math.pow(2, attempt) * 10;
1363
1364
  await new Promise((resolve) => setTimeout(resolve, delay));
1364
1365
  continue;
@@ -2010,8 +2011,10 @@ var LanceFilterTranslator = class extends BaseFilterTranslator {
2010
2011
  if (typeof condition !== "object" || condition === null) throw new Error(BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_CONTENT(operator));
2011
2012
  const condObj = condition;
2012
2013
  const keys = Object.keys(condObj);
2013
- if (keys.length === 1 && this.isOperator(keys[0])) if (this.isLogicalOperator(keys[0])) return `(${this.processLogicalOperator(keys[0], condObj[keys[0]])})`;
2014
- else throw new Error(BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(keys[0]));
2014
+ if (keys.length === 1 && this.isOperator(keys[0])) {
2015
+ if (this.isLogicalOperator(keys[0])) return `(${this.processLogicalOperator(keys[0], condObj[keys[0]])})`;
2016
+ else throw new Error(BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(keys[0]));
2017
+ }
2015
2018
  if (keys.length > 1) return `(${this.processFilter(condition)})`;
2016
2019
  return this.processFilter(condition);
2017
2020
  }).join(` ${sqlOperator} `);
@@ -2385,9 +2388,10 @@ var LanceVectorStore = class LanceVectorStore extends MastraVector {
2385
2388
  const processFilterKeys = (filterObj) => {
2386
2389
  const result = {};
2387
2390
  Object.entries(filterObj).forEach(([key, value]) => {
2388
- if (key === "$or" || key === "$and" || key === "$not" || key === "$in") if (Array.isArray(value)) result[key] = value.map((item) => typeof item === "object" && item !== null ? processFilterKeys(item) : item);
2389
- else result[key] = value;
2390
- else if (key.startsWith("metadata_")) result[key] = value;
2391
+ if (key === "$or" || key === "$and" || key === "$not" || key === "$in") {
2392
+ if (Array.isArray(value)) result[key] = value.map((item) => typeof item === "object" && item !== null ? processFilterKeys(item) : item);
2393
+ else result[key] = value;
2394
+ } else if (key.startsWith("metadata_")) result[key] = value;
2391
2395
  else if (key.includes(".")) {
2392
2396
  const convertedKey = `metadata_${key.replace(/\./g, "_")}`;
2393
2397
  result[convertedKey] = value;
@@ -2977,11 +2981,14 @@ var LanceVectorStore = class LanceVectorStore extends MastraVector {
2977
2981
  const updatedRecords = existingRecords.map((record) => {
2978
2982
  const rowData = {};
2979
2983
  Object.entries(record).forEach(([key, value]) => {
2980
- if (key !== "_distance") if (key === indexName) if (update.vector) rowData[key] = update.vector;
2981
- else if (Array.isArray(value)) rowData[key] = [...value];
2982
- else if (typeof value === "object" && value !== null) rowData[key] = Array.from(value);
2983
- else rowData[key] = value;
2984
- else rowData[key] = value;
2984
+ if (key !== "_distance") {
2985
+ if (key === indexName) {
2986
+ if (update.vector) rowData[key] = update.vector;
2987
+ else if (Array.isArray(value)) rowData[key] = [...value];
2988
+ else if (typeof value === "object" && value !== null) rowData[key] = Array.from(value);
2989
+ else rowData[key] = value;
2990
+ } else rowData[key] = value;
2991
+ }
2985
2992
  });
2986
2993
  if (update.metadata) {
2987
2994
  Object.entries(update.metadata).forEach(([key, value]) => {