@mastra/mysql 0.14.0-alpha.1 → 0.14.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/_types/@internal_core/dist/memory/index.d.ts +12 -15
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +93 -106
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +93 -106
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/agents/index.d.ts.map +1 -1
- package/dist/storage/domains/favorites/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-clients/index.d.ts.map +1 -1
- package/dist/storage/domains/mcp-servers/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/skills/index.d.ts.map +1 -1
- package/dist/storage/domains/tool-provider-connections/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/domains/workspaces/index.d.ts.map +1 -1
- package/package.json +15 -16
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { parseSqlIdentifier } from "@mastra/core/utils";
|
|
|
5
5
|
import { createHash } from "crypto";
|
|
6
6
|
import { MessageList } from "@mastra/core/agent";
|
|
7
7
|
import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
|
|
8
|
-
|
|
8
|
+
// src/storage/db/schema-snapshot.ts
|
|
9
9
|
/** Builds the `table.index` presence key the snapshot uses. */
|
|
10
10
|
function indexKey(table, index) {
|
|
11
11
|
return `${table.toLowerCase()}.${index.toLowerCase()}`;
|
|
@@ -44,8 +44,7 @@ async function loadSchemaSnapshot(pool, schemaName) {
|
|
|
44
44
|
indexes
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
//#region src/storage/domains/utils.ts
|
|
47
|
+
// src/storage/domains/utils.ts
|
|
49
48
|
function quoteIdentifier(value, context) {
|
|
50
49
|
return `\`${parseSqlIdentifier(value, context)}\``;
|
|
51
50
|
}
|
|
@@ -85,13 +84,14 @@ function prepareWhereClause(filters) {
|
|
|
85
84
|
if (value === true) conditions.push(`${quoteIdentifier(fieldName, "column name")} IS NULL`);
|
|
86
85
|
else if (value === false) conditions.push(`${quoteIdentifier(fieldName, "column name")} IS NOT NULL`);
|
|
87
86
|
} else if (value === null) conditions.push(`${quoteIdentifier(key, "column name")} IS NULL`);
|
|
88
|
-
else if (Array.isArray(value))
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
else if (Array.isArray(value)) {
|
|
88
|
+
if (value.length === 0) conditions.push("FALSE");
|
|
89
|
+
else {
|
|
90
|
+
const placeholders = value.map(() => "?").join(", ");
|
|
91
|
+
conditions.push(`${quoteIdentifier(key, "column name")} IN (${placeholders})`);
|
|
92
|
+
args.push(...value.map(transformToSqlValue));
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
95
|
conditions.push(`${quoteIdentifier(key, "column name")} = ?`);
|
|
96
96
|
args.push(transformToSqlValue(value));
|
|
97
97
|
}
|
|
@@ -156,13 +156,14 @@ function transformFromSqlRow({ tableName, sqlRow }) {
|
|
|
156
156
|
const result = {};
|
|
157
157
|
Object.entries(sqlRow).forEach(([key, value]) => {
|
|
158
158
|
const columnSchema = schema?.[key];
|
|
159
|
-
if (columnSchema?.type === "jsonb")
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
if (columnSchema?.type === "jsonb") {
|
|
160
|
+
if (typeof value === "string") try {
|
|
161
|
+
result[key] = JSON.parse(value);
|
|
162
|
+
} catch {
|
|
163
|
+
result[key] = value;
|
|
164
|
+
}
|
|
165
|
+
else result[key] = value;
|
|
166
|
+
} else if (columnSchema?.type === "timestamp") result[key] = value === null ? null : parseDateTime(value);
|
|
166
167
|
else if (columnSchema?.type === "boolean") result[key] = value === true || value === 1 || value === "1";
|
|
167
168
|
else result[key] = value;
|
|
168
169
|
});
|
|
@@ -178,8 +179,7 @@ function parseDateTime(value) {
|
|
|
178
179
|
const withZone = /[zZ]|[+-]\d\d:?\d\d$/.test(normalized) ? normalized : `${normalized}Z`;
|
|
179
180
|
return new Date(withZone);
|
|
180
181
|
}
|
|
181
|
-
|
|
182
|
-
//#region src/storage/domains/operations/index.ts
|
|
182
|
+
// src/storage/domains/operations/index.ts
|
|
183
183
|
var StoreOperationsMySQL = class extends StoreOperations {
|
|
184
184
|
pool;
|
|
185
185
|
database;
|
|
@@ -773,8 +773,7 @@ function mapToMySqlType(type, isKey = false) {
|
|
|
773
773
|
default: return "TEXT";
|
|
774
774
|
}
|
|
775
775
|
}
|
|
776
|
-
|
|
777
|
-
//#region src/storage/domains/agents/index.ts
|
|
776
|
+
// src/storage/domains/agents/index.ts
|
|
778
777
|
var AgentsMySQL = class AgentsMySQL extends AgentsStorage {
|
|
779
778
|
pool;
|
|
780
779
|
operations;
|
|
@@ -1371,8 +1370,7 @@ var AgentsMySQL = class AgentsMySQL extends AgentsStorage {
|
|
|
1371
1370
|
};
|
|
1372
1371
|
}
|
|
1373
1372
|
};
|
|
1374
|
-
|
|
1375
|
-
//#region src/storage/domains/background-tasks/index.ts
|
|
1373
|
+
// src/storage/domains/background-tasks/index.ts
|
|
1376
1374
|
function serializeJson(v) {
|
|
1377
1375
|
if (typeof v === "object" && v != null) return JSON.stringify(v);
|
|
1378
1376
|
return v ?? null;
|
|
@@ -1564,15 +1562,19 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends BackgroundTasksSto
|
|
|
1564
1562
|
predicates.push(`${quoteIdentifier("status", "column name")} = ?`);
|
|
1565
1563
|
params.push(options.expectedStatus);
|
|
1566
1564
|
}
|
|
1567
|
-
if (options?.expectedOwnerId !== void 0)
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1565
|
+
if (options?.expectedOwnerId !== void 0) {
|
|
1566
|
+
if (options.expectedOwnerId === null) predicates.push(`${quoteIdentifier("ownerId", "column name")} IS NULL`);
|
|
1567
|
+
else {
|
|
1568
|
+
predicates.push(`${quoteIdentifier("ownerId", "column name")} = ?`);
|
|
1569
|
+
params.push(options.expectedOwnerId);
|
|
1570
|
+
}
|
|
1571
1571
|
}
|
|
1572
|
-
if (options?.expectedLeaseExpiresAt !== void 0)
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1572
|
+
if (options?.expectedLeaseExpiresAt !== void 0) {
|
|
1573
|
+
if (options.expectedLeaseExpiresAt === null) predicates.push(`${quoteIdentifier("leaseExpiresAt", "column name")} IS NULL`);
|
|
1574
|
+
else {
|
|
1575
|
+
predicates.push(`${quoteIdentifier("leaseExpiresAt", "column name")} = ?`);
|
|
1576
|
+
params.push(transformToSqlValue(options.expectedLeaseExpiresAt));
|
|
1577
|
+
}
|
|
1576
1578
|
}
|
|
1577
1579
|
const predicateSql = predicates.length > 0 ? ` AND ${predicates.join(" AND ")}` : "";
|
|
1578
1580
|
const [result] = await this.pool.execute(`UPDATE ${formatTableName(TABLE_BACKGROUND_TASKS)} SET ${setClauses.join(", ")} WHERE ${quoteIdentifier("id", "column name")} = ?${predicateSql}`, params);
|
|
@@ -1686,8 +1688,7 @@ var BackgroundTasksMySQL = class BackgroundTasksMySQL extends BackgroundTasksSto
|
|
|
1686
1688
|
return Number(rows[0]?.count ?? 0);
|
|
1687
1689
|
}
|
|
1688
1690
|
};
|
|
1689
|
-
|
|
1690
|
-
//#region src/storage/domains/blobs/index.ts
|
|
1691
|
+
// src/storage/domains/blobs/index.ts
|
|
1691
1692
|
const INSERT_IGNORE_SQL = `INSERT IGNORE INTO ${formatTableName(TABLE_SKILL_BLOBS)} (${[
|
|
1692
1693
|
"hash",
|
|
1693
1694
|
"content",
|
|
@@ -1768,8 +1769,7 @@ var BlobsMySQL = class extends BlobStore {
|
|
|
1768
1769
|
};
|
|
1769
1770
|
}
|
|
1770
1771
|
};
|
|
1771
|
-
|
|
1772
|
-
//#region src/storage/domains/channels/index.ts
|
|
1772
|
+
// src/storage/domains/channels/index.ts
|
|
1773
1773
|
var ChannelsMySQL = class ChannelsMySQL extends ChannelsStorage {
|
|
1774
1774
|
pool;
|
|
1775
1775
|
operations;
|
|
@@ -1903,8 +1903,7 @@ var ChannelsMySQL = class ChannelsMySQL extends ChannelsStorage {
|
|
|
1903
1903
|
};
|
|
1904
1904
|
}
|
|
1905
1905
|
};
|
|
1906
|
-
|
|
1907
|
-
//#region src/storage/domains/datasets/index.ts
|
|
1906
|
+
// src/storage/domains/datasets/index.ts
|
|
1908
1907
|
function parseJSON$3(value) {
|
|
1909
1908
|
if (value === null || value === void 0) return void 0;
|
|
1910
1909
|
if (typeof value === "string") try {
|
|
@@ -3055,8 +3054,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
3055
3054
|
}
|
|
3056
3055
|
}
|
|
3057
3056
|
};
|
|
3058
|
-
|
|
3059
|
-
//#region src/storage/domains/experiments/index.ts
|
|
3057
|
+
// src/storage/domains/experiments/index.ts
|
|
3060
3058
|
function parseJSON$2(value) {
|
|
3061
3059
|
if (value === null || value === void 0) return void 0;
|
|
3062
3060
|
if (typeof value === "string") {
|
|
@@ -3928,8 +3926,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3928
3926
|
}
|
|
3929
3927
|
}
|
|
3930
3928
|
};
|
|
3931
|
-
|
|
3932
|
-
//#region src/storage/domains/favorites/index.ts
|
|
3929
|
+
// src/storage/domains/favorites/index.ts
|
|
3933
3930
|
/**
|
|
3934
3931
|
* Maps a favorite entity type to its parent entity table.
|
|
3935
3932
|
*/
|
|
@@ -4165,8 +4162,7 @@ var FavoritesMySQL = class FavoritesMySQL extends FavoritesStorage {
|
|
|
4165
4162
|
}
|
|
4166
4163
|
}
|
|
4167
4164
|
};
|
|
4168
|
-
|
|
4169
|
-
//#region src/storage/domains/knowledge/index.ts
|
|
4165
|
+
// src/storage/domains/knowledge/index.ts
|
|
4170
4166
|
let assertDescriptionWithinBound;
|
|
4171
4167
|
async function assertKnowledgeDescriptionWithinBoundCompat(description) {
|
|
4172
4168
|
let assertWithinBound = assertDescriptionWithinBound;
|
|
@@ -5061,8 +5057,7 @@ var KnowledgeMySQL = class extends KnowledgeStorage {
|
|
|
5061
5057
|
});
|
|
5062
5058
|
}
|
|
5063
5059
|
};
|
|
5064
|
-
|
|
5065
|
-
//#region src/storage/domains/mcp-clients/index.ts
|
|
5060
|
+
// src/storage/domains/mcp-clients/index.ts
|
|
5066
5061
|
var MCPClientsMySQL = class MCPClientsMySQL extends MCPClientsStorage {
|
|
5067
5062
|
pool;
|
|
5068
5063
|
operations;
|
|
@@ -5535,8 +5530,7 @@ var MCPClientsMySQL = class MCPClientsMySQL extends MCPClientsStorage {
|
|
|
5535
5530
|
}
|
|
5536
5531
|
}
|
|
5537
5532
|
};
|
|
5538
|
-
|
|
5539
|
-
//#region src/storage/domains/mcp-servers/index.ts
|
|
5533
|
+
// src/storage/domains/mcp-servers/index.ts
|
|
5540
5534
|
var MCPServersMySQL = class MCPServersMySQL extends MCPServersStorage {
|
|
5541
5535
|
pool;
|
|
5542
5536
|
operations;
|
|
@@ -6025,8 +6019,7 @@ var MCPServersMySQL = class MCPServersMySQL extends MCPServersStorage {
|
|
|
6025
6019
|
}
|
|
6026
6020
|
}
|
|
6027
6021
|
};
|
|
6028
|
-
|
|
6029
|
-
//#region ../../packages/_internal-core/dist/memory/index.js
|
|
6022
|
+
// ../../packages/_internal-core/dist/memory/index.js
|
|
6030
6023
|
/**
|
|
6031
6024
|
* Shared rules for observational memory lifecycle writes. Every storage adapter applies
|
|
6032
6025
|
* these inside its own atomic section (lock, transaction, or conditional update), so the
|
|
@@ -6111,8 +6104,7 @@ function isAppendOnlySince(storedObservations, snapshotObservations) {
|
|
|
6111
6104
|
const snapshot = snapshotObservations ?? "";
|
|
6112
6105
|
return stored === snapshot || stored.startsWith(snapshot);
|
|
6113
6106
|
}
|
|
6114
|
-
|
|
6115
|
-
//#region src/storage/db/run-fencing.ts
|
|
6107
|
+
// src/storage/db/run-fencing.ts
|
|
6116
6108
|
/**
|
|
6117
6109
|
* Epoch milliseconds on the database clock. `UTC_TIMESTAMP` is the time the
|
|
6118
6110
|
* statement started and doesn't depend on the session time zone. Every lease
|
|
@@ -6133,10 +6125,11 @@ async function assertRunFence(q, claimsTable, fence, operation) {
|
|
|
6133
6125
|
const [rows] = await q.execute(`SELECT generation, ${quoteIdentifier("ownerId", "column name")} AS ownerId FROM ${claimsTable}
|
|
6134
6126
|
WHERE ${quoteIdentifier("runId", "column name")} = ? LOCK IN SHARE MODE`, [fence.runId]);
|
|
6135
6127
|
const row = rows[0];
|
|
6136
|
-
|
|
6128
|
+
const current = row ? {
|
|
6137
6129
|
generation: Number(row.generation),
|
|
6138
6130
|
ownerId: String(row.ownerId)
|
|
6139
|
-
} : null
|
|
6131
|
+
} : null;
|
|
6132
|
+
if (!matchesRunFence(current, fence)) throw new RunFenceConflictError(fence, operation);
|
|
6140
6133
|
}
|
|
6141
6134
|
/** Runs `fn` in a transaction on its own pooled connection. */
|
|
6142
6135
|
async function inTransaction(pool, fn) {
|
|
@@ -6179,8 +6172,7 @@ async function claimTransaction(pool, fn) {
|
|
|
6179
6172
|
if (attempt >= MAX_CLAIM_ATTEMPTS || errno !== ER_DUP_ENTRY && errno !== ER_LOCK_DEADLOCK) throw error;
|
|
6180
6173
|
}
|
|
6181
6174
|
}
|
|
6182
|
-
|
|
6183
|
-
//#region src/storage/domains/memory/index.ts
|
|
6175
|
+
// src/storage/domains/memory/index.ts
|
|
6184
6176
|
const OM_TABLE = "mastra_observational_memory";
|
|
6185
6177
|
const OM_TABLE_QUOTED = quoteIdentifier(OM_TABLE, "table name");
|
|
6186
6178
|
const RUN_FENCES_TABLE = formatTableName(TABLE_MEMORY_RUN_FENCES);
|
|
@@ -6470,13 +6462,14 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
6470
6462
|
for (const indexDef of this.#indexes) await this.operations.createIndex(indexDef);
|
|
6471
6463
|
}
|
|
6472
6464
|
async prune(policies, options) {
|
|
6465
|
+
const targets = resolveRetentionTargets({
|
|
6466
|
+
policies,
|
|
6467
|
+
descriptor: MemoryMySQL.retentionTables,
|
|
6468
|
+
order: ["runFences"]
|
|
6469
|
+
});
|
|
6473
6470
|
return executeRetentionPrune({
|
|
6474
6471
|
domain: "memory",
|
|
6475
|
-
targets
|
|
6476
|
-
policies,
|
|
6477
|
-
descriptor: MemoryMySQL.retentionTables,
|
|
6478
|
-
order: ["runFences"]
|
|
6479
|
-
}),
|
|
6472
|
+
targets,
|
|
6480
6473
|
options,
|
|
6481
6474
|
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
6482
6475
|
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
@@ -8370,8 +8363,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
8370
8363
|
};
|
|
8371
8364
|
}
|
|
8372
8365
|
};
|
|
8373
|
-
|
|
8374
|
-
//#region src/storage/domains/observability/index.ts
|
|
8366
|
+
// src/storage/domains/observability/index.ts
|
|
8375
8367
|
const JSON_SPAN_FIELDS = [
|
|
8376
8368
|
"input",
|
|
8377
8369
|
"output",
|
|
@@ -8404,13 +8396,14 @@ var ObservabilityMySQL = class ObservabilityMySQL extends ObservabilityStorage {
|
|
|
8404
8396
|
this.#indexes = indexes?.filter((idx) => ObservabilityMySQL.MANAGED_TABLES.includes(idx.table));
|
|
8405
8397
|
}
|
|
8406
8398
|
async prune(policies, options) {
|
|
8399
|
+
const targets = resolveRetentionTargets({
|
|
8400
|
+
policies,
|
|
8401
|
+
descriptor: ObservabilityMySQL.retentionTables,
|
|
8402
|
+
order: ["spans"]
|
|
8403
|
+
});
|
|
8407
8404
|
return executeRetentionPrune({
|
|
8408
8405
|
domain: "observability",
|
|
8409
|
-
targets
|
|
8410
|
-
policies,
|
|
8411
|
-
descriptor: ObservabilityMySQL.retentionTables,
|
|
8412
|
-
order: ["spans"]
|
|
8413
|
-
}),
|
|
8406
|
+
targets,
|
|
8414
8407
|
options,
|
|
8415
8408
|
cutoffFor: (target, now) => new Date(retentionCutoffMs(target.policy, now)),
|
|
8416
8409
|
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
@@ -8777,22 +8770,22 @@ var ObservabilityMySQL = class ObservabilityMySQL extends ObservabilityStorage {
|
|
|
8777
8770
|
case TraceStatus.RUNNING:
|
|
8778
8771
|
conditions.push(`${quoteIdentifier("endedAt", "column name")} IS NULL AND ${quoteIdentifier("error", "column name")} IS NULL`);
|
|
8779
8772
|
break;
|
|
8780
|
-
case TraceStatus.SUCCESS:
|
|
8781
|
-
conditions.push(`${quoteIdentifier("endedAt", "column name")} IS NOT NULL AND ${quoteIdentifier("error", "column name")} IS NULL`);
|
|
8782
|
-
break;
|
|
8773
|
+
case TraceStatus.SUCCESS: conditions.push(`${quoteIdentifier("endedAt", "column name")} IS NOT NULL AND ${quoteIdentifier("error", "column name")} IS NULL`);
|
|
8783
8774
|
}
|
|
8784
|
-
if (filters.hasChildError !== void 0)
|
|
8775
|
+
if (filters.hasChildError !== void 0) {
|
|
8776
|
+
if (filters.hasChildError) conditions.push(`EXISTS (
|
|
8785
8777
|
SELECT 1 FROM ${tbl} c
|
|
8786
8778
|
WHERE c.${quoteIdentifier("traceId", "column name")} = ${tbl}.${quoteIdentifier("traceId", "column name")}
|
|
8787
8779
|
AND c.${quoteIdentifier("parentSpanId", "column name")} IS NOT NULL
|
|
8788
8780
|
AND c.${quoteIdentifier("error", "column name")} IS NOT NULL
|
|
8789
8781
|
)`);
|
|
8790
|
-
|
|
8782
|
+
else conditions.push(`NOT EXISTS (
|
|
8791
8783
|
SELECT 1 FROM ${tbl} c
|
|
8792
8784
|
WHERE c.${quoteIdentifier("traceId", "column name")} = ${tbl}.${quoteIdentifier("traceId", "column name")}
|
|
8793
8785
|
AND c.${quoteIdentifier("parentSpanId", "column name")} IS NOT NULL
|
|
8794
8786
|
AND c.${quoteIdentifier("error", "column name")} IS NOT NULL
|
|
8795
8787
|
)`);
|
|
8788
|
+
}
|
|
8796
8789
|
}
|
|
8797
8790
|
const whereClause = conditions.length > 0 ? ` WHERE ${conditions.join(" AND ")}` : "";
|
|
8798
8791
|
const sortField = quoteIdentifier(orderBy.field, "column name");
|
|
@@ -8904,8 +8897,7 @@ var ObservabilityMySQL = class ObservabilityMySQL extends ObservabilityStorage {
|
|
|
8904
8897
|
}
|
|
8905
8898
|
}
|
|
8906
8899
|
};
|
|
8907
|
-
|
|
8908
|
-
//#region src/storage/domains/prompt-blocks/index.ts
|
|
8900
|
+
// src/storage/domains/prompt-blocks/index.ts
|
|
8909
8901
|
var PromptBlocksMySQL = class PromptBlocksMySQL extends PromptBlocksStorage {
|
|
8910
8902
|
pool;
|
|
8911
8903
|
operations;
|
|
@@ -9377,8 +9369,7 @@ var PromptBlocksMySQL = class PromptBlocksMySQL extends PromptBlocksStorage {
|
|
|
9377
9369
|
}
|
|
9378
9370
|
}
|
|
9379
9371
|
};
|
|
9380
|
-
|
|
9381
|
-
//#region src/storage/domains/schedules/index.ts
|
|
9372
|
+
// src/storage/domains/schedules/index.ts
|
|
9382
9373
|
function parseJson(val) {
|
|
9383
9374
|
if (val == null) return void 0;
|
|
9384
9375
|
if (typeof val === "string") try {
|
|
@@ -9528,15 +9519,19 @@ var SchedulesMySQL = class SchedulesMySQL extends SchedulesStorage {
|
|
|
9528
9519
|
conditions.push(`JSON_EXTRACT(${quoteIdentifier("target", "column name")}, '$.workflowId') = ?`);
|
|
9529
9520
|
params.push(filter.workflowId);
|
|
9530
9521
|
}
|
|
9531
|
-
if (filter?.ownerType !== void 0)
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9522
|
+
if (filter?.ownerType !== void 0) {
|
|
9523
|
+
if (filter.ownerType === null) conditions.push(`${quoteIdentifier("owner_type", "column name")} IS NULL`);
|
|
9524
|
+
else {
|
|
9525
|
+
conditions.push(`${quoteIdentifier("owner_type", "column name")} = ?`);
|
|
9526
|
+
params.push(filter.ownerType);
|
|
9527
|
+
}
|
|
9535
9528
|
}
|
|
9536
|
-
if (filter?.ownerId !== void 0)
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9529
|
+
if (filter?.ownerId !== void 0) {
|
|
9530
|
+
if (filter.ownerId === null) conditions.push(`${quoteIdentifier("owner_id", "column name")} IS NULL`);
|
|
9531
|
+
else {
|
|
9532
|
+
conditions.push(`${quoteIdentifier("owner_id", "column name")} = ?`);
|
|
9533
|
+
params.push(filter.ownerId);
|
|
9534
|
+
}
|
|
9540
9535
|
}
|
|
9541
9536
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
9542
9537
|
const [rows] = await this.pool.execute(`SELECT * FROM ${formatTableName(TABLE_SCHEDULES)} ${where} ORDER BY ${quoteIdentifier("created_at", "column name")} ASC`, params);
|
|
@@ -9643,8 +9638,7 @@ var SchedulesMySQL = class SchedulesMySQL extends SchedulesStorage {
|
|
|
9643
9638
|
return rows.map((r) => rowToTrigger(r));
|
|
9644
9639
|
}
|
|
9645
9640
|
};
|
|
9646
|
-
|
|
9647
|
-
//#region src/storage/domains/scorer-definitions/index.ts
|
|
9641
|
+
// src/storage/domains/scorer-definitions/index.ts
|
|
9648
9642
|
var ScorerDefinitionsMySQL = class ScorerDefinitionsMySQL extends ScorerDefinitionsStorage {
|
|
9649
9643
|
pool;
|
|
9650
9644
|
operations;
|
|
@@ -10119,8 +10113,7 @@ var ScorerDefinitionsMySQL = class ScorerDefinitionsMySQL extends ScorerDefiniti
|
|
|
10119
10113
|
}
|
|
10120
10114
|
}
|
|
10121
10115
|
};
|
|
10122
|
-
|
|
10123
|
-
//#region src/storage/domains/scores/index.ts
|
|
10116
|
+
// src/storage/domains/scores/index.ts
|
|
10124
10117
|
function parseJSON(value) {
|
|
10125
10118
|
if (value === null || value === void 0) return void 0;
|
|
10126
10119
|
if (typeof value === "string") {
|
|
@@ -10415,8 +10408,7 @@ var ScoresMySQL = class ScoresMySQL extends ScoresStorage {
|
|
|
10415
10408
|
}), pagination);
|
|
10416
10409
|
}
|
|
10417
10410
|
};
|
|
10418
|
-
|
|
10419
|
-
//#region src/storage/domains/skills/index.ts
|
|
10411
|
+
// src/storage/domains/skills/index.ts
|
|
10420
10412
|
const SNAPSHOT_FIELDS$1 = [
|
|
10421
10413
|
"name",
|
|
10422
10414
|
"description",
|
|
@@ -10976,8 +10968,7 @@ var SkillsMySQL = class SkillsMySQL extends SkillsStorage {
|
|
|
10976
10968
|
}
|
|
10977
10969
|
}
|
|
10978
10970
|
};
|
|
10979
|
-
|
|
10980
|
-
//#region src/storage/domains/tool-provider-connections/index.ts
|
|
10971
|
+
// src/storage/domains/tool-provider-connections/index.ts
|
|
10981
10972
|
function normaliseScope(raw) {
|
|
10982
10973
|
const value = raw == null ? "per-author" : String(raw);
|
|
10983
10974
|
if (value === "shared") return "shared";
|
|
@@ -11202,8 +11193,7 @@ var ToolProviderConnectionsMySQL = class ToolProviderConnectionsMySQL extends To
|
|
|
11202
11193
|
}
|
|
11203
11194
|
}
|
|
11204
11195
|
};
|
|
11205
|
-
|
|
11206
|
-
//#region src/storage/domains/workflow-definitions/index.ts
|
|
11196
|
+
// src/storage/domains/workflow-definitions/index.ts
|
|
11207
11197
|
function rowToDefinition(row) {
|
|
11208
11198
|
const transformed = transformFromSqlRow({
|
|
11209
11199
|
tableName: TABLE_WORKFLOW_DEFINITIONS,
|
|
@@ -11344,8 +11334,7 @@ var WorkflowDefinitionsMySQL = class extends WorkflowDefinitionsStorage {
|
|
|
11344
11334
|
await this.pool.execute(`DELETE FROM ${formatTableName(TABLE_WORKFLOW_DEFINITIONS, this.database)} WHERE ${quoteIdentifier("id", "column name")} = ?`, [id]);
|
|
11345
11335
|
}
|
|
11346
11336
|
};
|
|
11347
|
-
|
|
11348
|
-
//#region src/storage/domains/workflows/index.ts
|
|
11337
|
+
// src/storage/domains/workflows/index.ts
|
|
11349
11338
|
function parseSnapshot(snapshot) {
|
|
11350
11339
|
if (typeof snapshot === "string") try {
|
|
11351
11340
|
return JSON.parse(snapshot);
|
|
@@ -11471,13 +11460,14 @@ var WorkflowsMySQL = class WorkflowsMySQL extends WorkflowsStorage {
|
|
|
11471
11460
|
await this.createCustomIndexes();
|
|
11472
11461
|
}
|
|
11473
11462
|
async prune(policies, options) {
|
|
11463
|
+
const targets = resolveRetentionTargets({
|
|
11464
|
+
policies,
|
|
11465
|
+
descriptor: WorkflowsMySQL.retentionTables,
|
|
11466
|
+
order: ["runOwnership"]
|
|
11467
|
+
});
|
|
11474
11468
|
return executeRetentionPrune({
|
|
11475
11469
|
domain: "workflows",
|
|
11476
|
-
targets
|
|
11477
|
-
policies,
|
|
11478
|
-
descriptor: WorkflowsMySQL.retentionTables,
|
|
11479
|
-
order: ["runOwnership"]
|
|
11480
|
-
}),
|
|
11470
|
+
targets,
|
|
11481
11471
|
options,
|
|
11482
11472
|
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
11483
11473
|
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
@@ -11863,8 +11853,7 @@ var WorkflowsMySQL = class WorkflowsMySQL extends WorkflowsStorage {
|
|
|
11863
11853
|
}
|
|
11864
11854
|
}
|
|
11865
11855
|
};
|
|
11866
|
-
|
|
11867
|
-
//#region src/storage/domains/workspaces/index.ts
|
|
11856
|
+
// src/storage/domains/workspaces/index.ts
|
|
11868
11857
|
const SNAPSHOT_FIELDS = [
|
|
11869
11858
|
"name",
|
|
11870
11859
|
"description",
|
|
@@ -12382,8 +12371,7 @@ var WorkspacesMySQL = class WorkspacesMySQL extends WorkspacesStorage {
|
|
|
12382
12371
|
}
|
|
12383
12372
|
}
|
|
12384
12373
|
};
|
|
12385
|
-
|
|
12386
|
-
//#region src/storage/index.ts
|
|
12374
|
+
// src/storage/index.ts
|
|
12387
12375
|
function validateConfig(config) {
|
|
12388
12376
|
if ("connectionString" in config) {
|
|
12389
12377
|
if (!config.connectionString || typeof config.connectionString !== "string") throw new Error("MySQLStore: connectionString must be a non-empty string.");
|
|
@@ -12656,7 +12644,6 @@ var MySQLStore = class extends MastraCompositeStore {
|
|
|
12656
12644
|
await this.pool.end();
|
|
12657
12645
|
}
|
|
12658
12646
|
};
|
|
12659
|
-
//#endregion
|
|
12660
12647
|
export { AgentsMySQL, BlobsMySQL, DatasetsMySQL, ExperimentsMySQL, MCPClientsMySQL, MCPServersMySQL, MemoryMySQL, MySQLStore, ObservabilityMySQL, PromptBlocksMySQL, ScorerDefinitionsMySQL, ScoresMySQL, SkillsMySQL, StoreOperationsMySQL, WorkflowsMySQL, WorkspacesMySQL };
|
|
12661
12648
|
|
|
12662
12649
|
//# sourceMappingURL=index.js.map
|