@mastra/mysql 0.11.1-alpha.1 → 0.12.0

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-mysql
3
3
  description: Documentation for @mastra/mysql. Use when working with @mastra/mysql APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/mysql"
6
- version: "0.11.1-alpha.1"
6
+ version: "0.12.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.11.1-alpha.1",
2
+ "version": "0.12.0",
3
3
  "package": "@mastra/mysql",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -6121,6 +6121,7 @@ function addMySQLMessageMetadataFilter(conditions, params, metadataFilter) {
6121
6121
  var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
6122
6122
  supportsPartialThreadUpdate = true;
6123
6123
  supportsObservationalMemory = true;
6124
+ supportsObservationalMemoryHistorySearch = true;
6124
6125
  pool;
6125
6126
  operations;
6126
6127
  #skipDefaultIndexes;
@@ -7323,6 +7324,10 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
7323
7324
  const safeLimit = Math.max(1, Math.floor(Number(limit)) || 10);
7324
7325
  const conditions = [`${omCol("lookupKey")} = ?`];
7325
7326
  const params = [lookupKey];
7327
+ if (options?.recordId !== void 0) {
7328
+ conditions.push(`${omCol("id")} = ?`);
7329
+ params.push(options.recordId);
7330
+ }
7326
7331
  if (options?.from) {
7327
7332
  conditions.push(`${omCol("createdAt")} >= ?`);
7328
7333
  params.push(transformToSqlValue(options.from));
@@ -7331,8 +7336,26 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
7331
7336
  conditions.push(`${omCol("createdAt")} <= ?`);
7332
7337
  params.push(transformToSqlValue(options.to));
7333
7338
  }
7339
+ if (options?.groupId !== void 0) {
7340
+ conditions.push(`(LOCATE(CAST(? AS BINARY), CAST(${omCol("activeObservations")} AS BINARY)) > 0 OR EXISTS (
7341
+ SELECT 1 FROM JSON_TABLE(${omCol("bufferedObservationChunks")}, '$[*]'
7342
+ COLUMNS (observations LONGTEXT PATH '$.observations')) AS chunk
7343
+ WHERE LOCATE(CAST(? AS BINARY), CAST(chunk.observations AS BINARY)) > 0
7344
+ ))`);
7345
+ const prefix = `<observation-group id="${options.groupId}"`;
7346
+ params.push(prefix, prefix);
7347
+ }
7348
+ if (options?.beforeGeneration !== void 0) {
7349
+ conditions.push(`${omCol("generationCount")} < ?`);
7350
+ params.push(options.beforeGeneration);
7351
+ }
7352
+ if (options?.afterGeneration !== void 0) {
7353
+ conditions.push(`${omCol("generationCount")} > ?`);
7354
+ params.push(options.afterGeneration);
7355
+ }
7356
+ const direction = options?.sortDirection === "ASC" ? "ASC" : "DESC";
7334
7357
  const whereClause = conditions.join(" AND ");
7335
- let sql = `SELECT * FROM ${OM_TABLE_QUOTED} WHERE ${whereClause} ORDER BY ${omCol("generationCount")} DESC LIMIT ${safeLimit}`;
7358
+ let sql = `SELECT * FROM ${OM_TABLE_QUOTED} WHERE ${whereClause} ORDER BY ${omCol("generationCount")} ${direction}, ${omCol("createdAt")} ASC, id ASC LIMIT ${safeLimit}`;
7336
7359
  if (options?.offset != null && options.offset > 0) sql += ` OFFSET ${options.offset}`;
7337
7360
  const [rows] = await this.pool.execute(sql, params);
7338
7361
  if (!rows) return [];