@mastra/lance 1.5.1-alpha.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.
@@ -3,7 +3,7 @@ name: mastra-lance
3
3
  description: Documentation for @mastra/lance. Use when working with @mastra/lance APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/lance"
6
- version: "1.5.1-alpha.0"
6
+ version: "1.5.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.1-alpha.0",
2
+ "version": "1.5.1",
3
3
  "package": "@mastra/lance",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -145,7 +145,7 @@ var LanceDB = class extends _mastra_core_base.MastraBase {
145
145
  return (await (await this.client.openTable(tableName)).schema()).fields.some((field) => field.name === columnName);
146
146
  }
147
147
  translateSchema(schema) {
148
- return new apache_arrow.Schema(Object.entries(schema).map(([name, column]) => {
148
+ const fields = Object.entries(schema).map(([name, column]) => {
149
149
  let arrowType;
150
150
  switch (column.type.toLowerCase()) {
151
151
  case "text":
@@ -175,7 +175,8 @@ var LanceDB = class extends _mastra_core_base.MastraBase {
175
175
  default: arrowType = new apache_arrow.Utf8();
176
176
  }
177
177
  return new apache_arrow.Field(name, arrowType, column.nullable ?? true);
178
- }));
178
+ });
179
+ return new apache_arrow.Schema(fields);
179
180
  }
180
181
  async createTable({ tableName, schema }) {
181
182
  try {
@@ -781,7 +782,7 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
781
782
  if (!updatedThread) throw new Error(`Failed to retrieve updated thread ${id}`);
782
783
  return updatedThread;
783
784
  } catch (error) {
784
- if (error.message?.includes("Commit conflict") && attempt < maxRetries - 1) {
785
+ if (error.message?.includes("Commit conflict") && attempt < 4) {
785
786
  const delay = Math.pow(2, attempt) * 10;
786
787
  await new Promise((resolve) => setTimeout(resolve, delay));
787
788
  continue;
@@ -1354,12 +1355,12 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
1354
1355
  updatedAt: updatedResource.updatedAt.getTime()
1355
1356
  };
1356
1357
  if ((await (await this.client.openTable(_mastra_core_storage.TABLE_RESOURCES)).mergeInsert("id").whenMatchedUpdateAll().execute([record])).numUpdatedRows === 0) {
1357
- if (attempt < maxRetries - 1) continue;
1358
+ if (attempt < 2) continue;
1358
1359
  throw new Error(`Resource ${resourceId} disappeared while it was being updated`);
1359
1360
  }
1360
1361
  return updatedResource;
1361
1362
  } catch (error) {
1362
- if (error.message?.includes("Commit conflict") && attempt < maxRetries - 1) {
1363
+ if (error.message?.includes("Commit conflict") && attempt < 2) {
1363
1364
  const delay = Math.pow(2, attempt) * 10;
1364
1365
  await new Promise((resolve) => setTimeout(resolve, delay));
1365
1366
  continue;
@@ -2011,8 +2012,10 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
2011
2012
  if (typeof condition !== "object" || condition === null) throw new Error(_mastra_core_vector_filter.BaseFilterTranslator.ErrorMessages.INVALID_LOGICAL_OPERATOR_CONTENT(operator));
2012
2013
  const condObj = condition;
2013
2014
  const keys = Object.keys(condObj);
2014
- if (keys.length === 1 && this.isOperator(keys[0])) if (this.isLogicalOperator(keys[0])) return `(${this.processLogicalOperator(keys[0], condObj[keys[0]])})`;
2015
- else throw new Error(_mastra_core_vector_filter.BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(keys[0]));
2015
+ if (keys.length === 1 && this.isOperator(keys[0])) {
2016
+ if (this.isLogicalOperator(keys[0])) return `(${this.processLogicalOperator(keys[0], condObj[keys[0]])})`;
2017
+ else throw new Error(_mastra_core_vector_filter.BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(keys[0]));
2018
+ }
2016
2019
  if (keys.length > 1) return `(${this.processFilter(condition)})`;
2017
2020
  return this.processFilter(condition);
2018
2021
  }).join(` ${sqlOperator} `);
@@ -2386,9 +2389,10 @@ var LanceVectorStore = class LanceVectorStore extends _mastra_core_vector.Mastra
2386
2389
  const processFilterKeys = (filterObj) => {
2387
2390
  const result = {};
2388
2391
  Object.entries(filterObj).forEach(([key, value]) => {
2389
- 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);
2390
- else result[key] = value;
2391
- else if (key.startsWith("metadata_")) result[key] = value;
2392
+ if (key === "$or" || key === "$and" || key === "$not" || key === "$in") {
2393
+ if (Array.isArray(value)) result[key] = value.map((item) => typeof item === "object" && item !== null ? processFilterKeys(item) : item);
2394
+ else result[key] = value;
2395
+ } else if (key.startsWith("metadata_")) result[key] = value;
2392
2396
  else if (key.includes(".")) {
2393
2397
  const convertedKey = `metadata_${key.replace(/\./g, "_")}`;
2394
2398
  result[convertedKey] = value;
@@ -2978,11 +2982,14 @@ var LanceVectorStore = class LanceVectorStore extends _mastra_core_vector.Mastra
2978
2982
  const updatedRecords = existingRecords.map((record) => {
2979
2983
  const rowData = {};
2980
2984
  Object.entries(record).forEach(([key, value]) => {
2981
- if (key !== "_distance") if (key === indexName) if (update.vector) rowData[key] = update.vector;
2982
- else if (Array.isArray(value)) rowData[key] = [...value];
2983
- else if (typeof value === "object" && value !== null) rowData[key] = Array.from(value);
2984
- else rowData[key] = value;
2985
- else rowData[key] = value;
2985
+ if (key !== "_distance") {
2986
+ if (key === indexName) {
2987
+ if (update.vector) rowData[key] = update.vector;
2988
+ else if (Array.isArray(value)) rowData[key] = [...value];
2989
+ else if (typeof value === "object" && value !== null) rowData[key] = Array.from(value);
2990
+ else rowData[key] = value;
2991
+ } else rowData[key] = value;
2992
+ }
2986
2993
  });
2987
2994
  if (update.metadata) {
2988
2995
  Object.entries(update.metadata).forEach(([key, value]) => {