@mastra/lance 1.5.2-alpha.0 → 1.5.2

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.2-alpha.0"
6
+ version: "1.5.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.2-alpha.0",
2
+ "version": "1.5.2",
3
3
  "package": "@mastra/lance",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -8,7 +8,7 @@ let _mastra_core_agent = require("@mastra/core/agent");
8
8
  let _mastra_core_evals = require("@mastra/core/evals");
9
9
  let _mastra_core_vector = require("@mastra/core/vector");
10
10
  let _mastra_core_vector_filter = require("@mastra/core/vector/filter");
11
- //#region src/storage/db/utils.ts
11
+ // src/storage/db/utils.ts
12
12
  function getPrimaryKeys(tableName) {
13
13
  let primaryId = ["id"];
14
14
  if (tableName === _mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT) primaryId = ["workflow_name", "run_id"];
@@ -81,8 +81,7 @@ async function getTableSchema({ tableName, client }) {
81
81
  }, error);
82
82
  }
83
83
  }
84
- //#endregion
85
- //#region src/storage/db/index.ts
84
+ // src/storage/db/index.ts
86
85
  /**
87
86
  * Resolves LanceDomainConfig to a LanceDB Connection.
88
87
  */
@@ -413,7 +412,7 @@ var LanceDB = class extends _mastra_core_base.MastraBase {
413
412
  const quotedKey = /^[a-z][a-zA-Z]*$/.test(key) && /[A-Z]/.test(key) ? `\`${key}\`` : key;
414
413
  if (typeof value === "string") return `${quotedKey} = '${value}'`;
415
414
  else if (value === null) return `${quotedKey} IS NULL`;
416
- else return `${quotedKey} = ${value}`;
415
+ return `${quotedKey} = ${value}`;
417
416
  }).join(" AND ");
418
417
  this.logger.debug("where clause generated: " + filterConditions);
419
418
  query.where(filterConditions);
@@ -439,8 +438,7 @@ var LanceDB = class extends _mastra_core_base.MastraBase {
439
438
  }
440
439
  }
441
440
  };
442
- //#endregion
443
- //#region src/storage/domains/background-tasks/index.ts
441
+ // src/storage/domains/background-tasks/index.ts
444
442
  function serializeJson(v) {
445
443
  if (typeof v === "object" && v != null) return JSON.stringify(v);
446
444
  return v ?? void 0;
@@ -643,8 +641,7 @@ var StoreBackgroundTasksLance = class extends _mastra_core_storage.BackgroundTas
643
641
  return total;
644
642
  }
645
643
  };
646
- //#endregion
647
- //#region src/storage/domains/memory/index.ts
644
+ // src/storage/domains/memory/index.ts
648
645
  var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
649
646
  client;
650
647
  #db;
@@ -1374,8 +1371,7 @@ var StoreMemoryLance = class extends _mastra_core_storage.MemoryStorage {
1374
1371
  throw new Error("Unexpected end of retry loop");
1375
1372
  }
1376
1373
  };
1377
- //#endregion
1378
- //#region src/storage/domains/scores/index.ts
1374
+ // src/storage/domains/scores/index.ts
1379
1375
  /** Escapes a value for safe inclusion in a single-quoted Lance SQL string literal. */
1380
1376
  function lanceStringLiteral(value) {
1381
1377
  return `'${value.replaceAll("'", "''")}'`;
@@ -1645,8 +1641,7 @@ var StoreScoresLance = class extends _mastra_core_storage.ScoresStorage {
1645
1641
  }
1646
1642
  }
1647
1643
  };
1648
- //#endregion
1649
- //#region src/storage/domains/workflows/index.ts
1644
+ // src/storage/domains/workflows/index.ts
1650
1645
  /**
1651
1646
  * Escapes single quotes in SQL string values to prevent SQL injection.
1652
1647
  */
@@ -1841,8 +1836,7 @@ var StoreWorkflowsLance = class extends _mastra_core_storage.WorkflowsStorage {
1841
1836
  }
1842
1837
  }
1843
1838
  };
1844
- //#endregion
1845
- //#region src/storage/index.ts
1839
+ // src/storage/index.ts
1846
1840
  /**
1847
1841
  * LanceDB storage adapter for Mastra.
1848
1842
  *
@@ -1963,8 +1957,7 @@ var LanceStorage = class LanceStorage extends _mastra_core_storage.MastraComposi
1963
1957
  this.stores = {};
1964
1958
  }
1965
1959
  };
1966
- //#endregion
1967
- //#region src/vector/filter.ts
1960
+ // src/vector/filter.ts
1968
1961
  var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterTranslator {
1969
1962
  translate(filter) {
1970
1963
  if (!filter || Object.keys(filter).length === 0) return "";
@@ -1993,13 +1986,13 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
1993
1986
  if (keys.length > 1) return keys.map((key) => {
1994
1987
  const value = obj[key];
1995
1988
  if (this.isNestedObject(value) && !this.isDateObject(value)) return this.processNestedObject(key, value);
1996
- else return this.processField(key, value);
1989
+ return this.processField(key, value);
1997
1990
  }).join(" AND ");
1998
1991
  if (keys.length === 1) {
1999
1992
  const key = keys[0];
2000
1993
  const value = obj[key];
2001
1994
  if (this.isNestedObject(value) && !this.isDateObject(value)) return this.processNestedObject(key, value);
2002
- else return this.processField(key, value);
1995
+ return this.processField(key, value);
2003
1996
  }
2004
1997
  }
2005
1998
  return "";
@@ -2014,7 +2007,7 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
2014
2007
  const keys = Object.keys(condObj);
2015
2008
  if (keys.length === 1 && this.isOperator(keys[0])) {
2016
2009
  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]));
2010
+ throw new Error(_mastra_core_vector_filter.BaseFilterTranslator.ErrorMessages.UNSUPPORTED_OPERATOR(keys[0]));
2018
2011
  }
2019
2012
  if (keys.length > 1) return `(${this.processFilter(condition)})`;
2020
2013
  return this.processFilter(condition);
@@ -2029,7 +2022,7 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
2029
2022
  return keys.map((key) => {
2030
2023
  const nestedPath = key.includes(".") ? `${path}.${key}` : `${path}.${key}`;
2031
2024
  if (this.isNestedObject(obj[key]) && !this.isDateObject(obj[key])) return this.processNestedObject(nestedPath, obj[key]);
2032
- else return this.processField(nestedPath, obj[key]);
2025
+ return this.processField(nestedPath, obj[key]);
2033
2026
  }).join(" AND ");
2034
2027
  }
2035
2028
  processField(field, value) {
@@ -2191,8 +2184,7 @@ var LanceFilterTranslator = class extends _mastra_core_vector_filter.BaseFilterT
2191
2184
  };
2192
2185
  }
2193
2186
  };
2194
- //#endregion
2195
- //#region src/vector/index.ts
2187
+ // src/vector/index.ts
2196
2188
  const LANCE_INDEX_FINGERPRINT_KEY = "mastra.index.fingerprint";
2197
2189
  const LANCE_INDEX_UUID_KEY = "mastra.index.uuid";
2198
2190
  var LanceVectorStore = class LanceVectorStore extends _mastra_core_vector.MastraVector {
@@ -2602,7 +2594,8 @@ var LanceVectorStore = class LanceVectorStore extends _mastra_core_vector.Mastra
2602
2594
  }
2603
2595
  this.logger.debug(`Table ${resolvedTableName} created. Index creation deferred until data is available.`);
2604
2596
  return;
2605
- } else table = await this.lanceClient.openTable(resolvedTableName);
2597
+ }
2598
+ table = await this.lanceClient.openTable(resolvedTableName);
2606
2599
  const metricType = this.mastraMetricToLance(metric);
2607
2600
  const rowCount = await table.countRows();
2608
2601
  if (rowCount < 256) {
@@ -3181,7 +3174,6 @@ var LanceVectorStore = class LanceVectorStore extends _mastra_core_vector.Mastra
3181
3174
  }
3182
3175
  }
3183
3176
  };
3184
- //#endregion
3185
3177
  exports.LanceStorage = LanceStorage;
3186
3178
  exports.LanceVectorStore = LanceVectorStore;
3187
3179
  exports.StoreBackgroundTasksLance = StoreBackgroundTasksLance;