@mastra/mysql 0.11.1 → 0.12.1-alpha.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.
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +27 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +1 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/schedules/index.d.ts +2 -2
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -6120,6 +6120,7 @@ function addMySQLMessageMetadataFilter(conditions, params, metadataFilter) {
|
|
|
6120
6120
|
var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
6121
6121
|
supportsPartialThreadUpdate = true;
|
|
6122
6122
|
supportsObservationalMemory = true;
|
|
6123
|
+
supportsObservationalMemoryHistorySearch = true;
|
|
6123
6124
|
pool;
|
|
6124
6125
|
operations;
|
|
6125
6126
|
#skipDefaultIndexes;
|
|
@@ -7322,6 +7323,10 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
7322
7323
|
const safeLimit = Math.max(1, Math.floor(Number(limit)) || 10);
|
|
7323
7324
|
const conditions = [`${omCol("lookupKey")} = ?`];
|
|
7324
7325
|
const params = [lookupKey];
|
|
7326
|
+
if (options?.recordId !== void 0) {
|
|
7327
|
+
conditions.push(`${omCol("id")} = ?`);
|
|
7328
|
+
params.push(options.recordId);
|
|
7329
|
+
}
|
|
7325
7330
|
if (options?.from) {
|
|
7326
7331
|
conditions.push(`${omCol("createdAt")} >= ?`);
|
|
7327
7332
|
params.push(transformToSqlValue(options.from));
|
|
@@ -7330,8 +7335,26 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
7330
7335
|
conditions.push(`${omCol("createdAt")} <= ?`);
|
|
7331
7336
|
params.push(transformToSqlValue(options.to));
|
|
7332
7337
|
}
|
|
7338
|
+
if (options?.groupId !== void 0) {
|
|
7339
|
+
conditions.push(`(LOCATE(CAST(? AS BINARY), CAST(${omCol("activeObservations")} AS BINARY)) > 0 OR EXISTS (
|
|
7340
|
+
SELECT 1 FROM JSON_TABLE(${omCol("bufferedObservationChunks")}, '$[*]'
|
|
7341
|
+
COLUMNS (observations LONGTEXT PATH '$.observations')) AS chunk
|
|
7342
|
+
WHERE LOCATE(CAST(? AS BINARY), CAST(chunk.observations AS BINARY)) > 0
|
|
7343
|
+
))`);
|
|
7344
|
+
const prefix = `<observation-group id="${options.groupId}"`;
|
|
7345
|
+
params.push(prefix, prefix);
|
|
7346
|
+
}
|
|
7347
|
+
if (options?.beforeGeneration !== void 0) {
|
|
7348
|
+
conditions.push(`${omCol("generationCount")} < ?`);
|
|
7349
|
+
params.push(options.beforeGeneration);
|
|
7350
|
+
}
|
|
7351
|
+
if (options?.afterGeneration !== void 0) {
|
|
7352
|
+
conditions.push(`${omCol("generationCount")} > ?`);
|
|
7353
|
+
params.push(options.afterGeneration);
|
|
7354
|
+
}
|
|
7355
|
+
const direction = options?.sortDirection === "ASC" ? "ASC" : "DESC";
|
|
7333
7356
|
const whereClause = conditions.join(" AND ");
|
|
7334
|
-
let sql = `SELECT * FROM ${OM_TABLE_QUOTED} WHERE ${whereClause} ORDER BY ${omCol("generationCount")}
|
|
7357
|
+
let sql = `SELECT * FROM ${OM_TABLE_QUOTED} WHERE ${whereClause} ORDER BY ${omCol("generationCount")} ${direction}, ${omCol("createdAt")} ASC, id ASC LIMIT ${safeLimit}`;
|
|
7335
7358
|
if (options?.offset != null && options.offset > 0) sql += ` OFFSET ${options.offset}`;
|
|
7336
7359
|
const [rows] = await this.pool.execute(sql, params);
|
|
7337
7360
|
if (!rows) return [];
|
|
@@ -9103,12 +9126,13 @@ var SchedulesMySQL = class SchedulesMySQL extends SchedulesStorage {
|
|
|
9103
9126
|
if (!updated) throw new Error(`Schedule ${id} not found`);
|
|
9104
9127
|
return updated;
|
|
9105
9128
|
}
|
|
9106
|
-
async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId) {
|
|
9107
|
-
const [result] = await this.pool.execute(`UPDATE ${formatTableName(TABLE_SCHEDULES)} SET ${quoteIdentifier("next_fire_at", "column name")} = ?, ${quoteIdentifier("last_fire_at", "column name")} = ?, ${quoteIdentifier("last_run_id", "column name")} = ?, ${quoteIdentifier("updated_at", "column name")} =
|
|
9129
|
+
async updateScheduleNextFire(id, expectedNextFireAt, newNextFireAt, lastFireAt, lastRunId, newStatus) {
|
|
9130
|
+
const [result] = await this.pool.execute(`UPDATE ${formatTableName(TABLE_SCHEDULES)} SET ${quoteIdentifier("next_fire_at", "column name")} = ?, ${quoteIdentifier("last_fire_at", "column name")} = ?, ${quoteIdentifier("last_run_id", "column name")} = ?, ${quoteIdentifier("updated_at", "column name")} = ?, ${quoteIdentifier("status", "column name")} = COALESCE(?, ${quoteIdentifier("status", "column name")}) WHERE ${quoteIdentifier("id", "column name")} = ? AND ${quoteIdentifier("next_fire_at", "column name")} = ? AND ${quoteIdentifier("status", "column name")} = ?`, [
|
|
9108
9131
|
newNextFireAt,
|
|
9109
9132
|
lastFireAt,
|
|
9110
9133
|
lastRunId,
|
|
9111
9134
|
Date.now(),
|
|
9135
|
+
newStatus ?? null,
|
|
9112
9136
|
id,
|
|
9113
9137
|
expectedNextFireAt,
|
|
9114
9138
|
"active"
|