@mastra/mysql 0.0.0 → 0.1.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/CHANGELOG.md +47 -0
- package/LICENSE.md +30 -0
- package/README.md +126 -55
- package/dist/index.cjs +34 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -16
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/blobs/index.d.ts +1 -1
- package/dist/storage/domains/blobs/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/operations/index.d.ts.map +1 -1
- package/package.json +20 -21
package/dist/index.js
CHANGED
|
@@ -404,12 +404,35 @@ var StoreOperationsMySQL = class extends StoreOperations {
|
|
|
404
404
|
if (existing.length > 0) {
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
|
+
const [columnMeta] = await this.pool.execute(
|
|
408
|
+
`SELECT COLUMN_NAME, DATA_TYPE FROM information_schema.COLUMNS
|
|
409
|
+
WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?`,
|
|
410
|
+
[db, table]
|
|
411
|
+
);
|
|
412
|
+
const dataTypeByColumn = new Map(
|
|
413
|
+
columnMeta.map((row) => [String(row.COLUMN_NAME).toLowerCase(), String(row.DATA_TYPE).toLowerCase()])
|
|
414
|
+
);
|
|
415
|
+
const PREFIX_TYPES = /* @__PURE__ */ new Set([
|
|
416
|
+
"tinytext",
|
|
417
|
+
"text",
|
|
418
|
+
"mediumtext",
|
|
419
|
+
"longtext",
|
|
420
|
+
"blob",
|
|
421
|
+
"tinyblob",
|
|
422
|
+
"mediumblob",
|
|
423
|
+
"longblob"
|
|
424
|
+
]);
|
|
425
|
+
const indexColumn = (colName) => {
|
|
426
|
+
const quoted = quoteIdentifier(colName, "column name");
|
|
427
|
+
const dataType = dataTypeByColumn.get(colName.toLowerCase());
|
|
428
|
+
return dataType && PREFIX_TYPES.has(dataType) ? `${quoted}(191)` : quoted;
|
|
429
|
+
};
|
|
407
430
|
const columnsStr = columns.map((col) => {
|
|
408
431
|
if (col.includes(" DESC") || col.includes(" ASC")) {
|
|
409
432
|
const [colName, ...modifiers] = col.split(" ");
|
|
410
|
-
return `${
|
|
433
|
+
return `${indexColumn(colName)} ${modifiers.join(" ")}`;
|
|
411
434
|
}
|
|
412
|
-
return
|
|
435
|
+
return indexColumn(col);
|
|
413
436
|
}).join(", ");
|
|
414
437
|
const uniqueStr = unique ? "UNIQUE " : "";
|
|
415
438
|
const sql = `CREATE ${uniqueStr}INDEX ${indexName} ON ${tableName} (${columnsStr})`;
|
|
@@ -3488,19 +3511,6 @@ var FavoritesMySQL = class _FavoritesMySQL extends FavoritesStorage {
|
|
|
3488
3511
|
tableName: TABLE_FAVORITES,
|
|
3489
3512
|
schema: FAVORITES_SCHEMA
|
|
3490
3513
|
});
|
|
3491
|
-
const tableName = formatTableName(TABLE_FAVORITES);
|
|
3492
|
-
const [idxCheck] = await this.pool.execute(
|
|
3493
|
-
`SELECT INDEX_NAME FROM information_schema.STATISTICS
|
|
3494
|
-
WHERE TABLE_SCHEMA = DATABASE()
|
|
3495
|
-
AND TABLE_NAME = ?
|
|
3496
|
-
AND INDEX_NAME = 'unique_favorite'`,
|
|
3497
|
-
[TABLE_FAVORITES]
|
|
3498
|
-
);
|
|
3499
|
-
if (idxCheck.length === 0) {
|
|
3500
|
-
await this.pool.execute(
|
|
3501
|
-
`CREATE UNIQUE INDEX unique_favorite ON ${tableName} (${quoteIdentifier("userId", "index column")}(255), ${quoteIdentifier("entityType", "index column")}(255), ${quoteIdentifier("entityId", "index column")}(255))`
|
|
3502
|
-
);
|
|
3503
|
-
}
|
|
3504
3514
|
await this.createDefaultIndexes();
|
|
3505
3515
|
await this.createCustomIndexes();
|
|
3506
3516
|
}
|
|
@@ -3887,7 +3897,15 @@ var MCPClientsMySQL = class _MCPClientsMySQL extends MCPClientsStorage {
|
|
|
3887
3897
|
const { id, ...updates } = input;
|
|
3888
3898
|
try {
|
|
3889
3899
|
const existing = await this.getById(id);
|
|
3890
|
-
if (!existing)
|
|
3900
|
+
if (!existing) {
|
|
3901
|
+
throw new MastraError({
|
|
3902
|
+
id: createStorageErrorId("MYSQL", "UPDATE_MCP_CLIENT", "NOT_FOUND"),
|
|
3903
|
+
domain: ErrorDomain.STORAGE,
|
|
3904
|
+
category: ErrorCategory.USER,
|
|
3905
|
+
text: `MCP client with id ${id} not found`,
|
|
3906
|
+
details: { id }
|
|
3907
|
+
});
|
|
3908
|
+
}
|
|
3891
3909
|
const { authorId, activeVersionId, metadata, status } = updates;
|
|
3892
3910
|
const updateData = { updatedAt: /* @__PURE__ */ new Date() };
|
|
3893
3911
|
if (authorId !== void 0) updateData.authorId = authorId;
|