@mastra/mysql 0.11.0-alpha.1 → 0.11.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/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +19 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -20
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/datasets/index.d.ts.map +1 -1
- package/dist/storage/domains/experiments/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/docs/SKILL.md
CHANGED
|
@@ -202,7 +202,7 @@ async function retentionTick() {
|
|
|
202
202
|
}
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false
|
|
205
|
+
You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`. The next run resumes cleanly.
|
|
206
206
|
|
|
207
207
|
## ClickHouse native TTL
|
|
208
208
|
|
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,6 @@ let _mastra_core_error = require("@mastra/core/error");
|
|
|
3
3
|
let _mastra_core_storage = require("@mastra/core/storage");
|
|
4
4
|
let mysql2_promise = require("mysql2/promise");
|
|
5
5
|
let _mastra_core_utils = require("@mastra/core/utils");
|
|
6
|
-
let crypto$1 = require("crypto");
|
|
7
6
|
let _mastra_core_agent = require("@mastra/core/agent");
|
|
8
7
|
let _mastra_core_storage_domains_skills = require("@mastra/core/storage/domains/skills");
|
|
9
8
|
//#region src/storage/db/schema-snapshot.ts
|
|
@@ -2155,7 +2154,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2155
2154
|
}
|
|
2156
2155
|
async createDataset(input) {
|
|
2157
2156
|
try {
|
|
2158
|
-
const id = input.id ??
|
|
2157
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
2159
2158
|
if (input.id !== void 0) this.validateCallerDefinedDatasetId(input.id);
|
|
2160
2159
|
const now = /* @__PURE__ */ new Date();
|
|
2161
2160
|
await (input.id === void 0 ? this.operations.insert.bind(this.operations) : this.operations.insertOnly.bind(this.operations))({
|
|
@@ -2415,8 +2414,8 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2415
2414
|
const connection = await this.pool.getConnection();
|
|
2416
2415
|
try {
|
|
2417
2416
|
await connection.beginTransaction();
|
|
2418
|
-
const id =
|
|
2419
|
-
const versionId =
|
|
2417
|
+
const id = globalThis.crypto.randomUUID();
|
|
2418
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2420
2419
|
const now = /* @__PURE__ */ new Date();
|
|
2421
2420
|
const tableDatasetsName = formatTableName(_mastra_core_storage.TABLE_DATASETS);
|
|
2422
2421
|
const tableItemsName = formatTableName(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
@@ -2479,7 +2478,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2479
2478
|
const connection = await this.pool.getConnection();
|
|
2480
2479
|
try {
|
|
2481
2480
|
await connection.beginTransaction();
|
|
2482
|
-
const versionId =
|
|
2481
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2483
2482
|
const now = /* @__PURE__ */ new Date();
|
|
2484
2483
|
const tableDatasetsName = formatTableName(_mastra_core_storage.TABLE_DATASETS);
|
|
2485
2484
|
const tableItemsName = formatTableName(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
@@ -2588,7 +2587,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2588
2587
|
const connection = await this.pool.getConnection();
|
|
2589
2588
|
try {
|
|
2590
2589
|
await connection.beginTransaction();
|
|
2591
|
-
const versionId =
|
|
2590
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2592
2591
|
const now = /* @__PURE__ */ new Date();
|
|
2593
2592
|
const tableDatasetsName = formatTableName(_mastra_core_storage.TABLE_DATASETS);
|
|
2594
2593
|
const tableItemsName = formatTableName(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
@@ -2819,7 +2818,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2819
2818
|
}
|
|
2820
2819
|
async createDatasetVersion(datasetId, version) {
|
|
2821
2820
|
try {
|
|
2822
|
-
const id =
|
|
2821
|
+
const id = globalThis.crypto.randomUUID();
|
|
2823
2822
|
const now = /* @__PURE__ */ new Date();
|
|
2824
2823
|
await this.operations.insert({
|
|
2825
2824
|
tableName: _mastra_core_storage.TABLE_DATASET_VERSIONS,
|
|
@@ -2913,7 +2912,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2913
2912
|
const [rows] = await connection.execute(`SELECT ${ITEM_SELECT_COLUMNS} FROM ${tableItemsName} WHERE \`datasetId\` = ? AND \`externalId\` IN (${placeholders}) ORDER BY \`datasetVersion\` ASC`, [input.datasetId, ...externalIds]);
|
|
2914
2913
|
historyRows = rows.map((row) => this.mapItemFull(row));
|
|
2915
2914
|
}
|
|
2916
|
-
const plan = this.planDatasetItemBatch(input.items, historyRows, crypto
|
|
2915
|
+
const plan = this.planDatasetItemBatch(input.items, historyRows, () => globalThis.crypto.randomUUID());
|
|
2917
2916
|
const existingItems = new Map([...plan.existingCurrentItems].map(([id, row]) => [id, this.datasetItemFromRow(row)]));
|
|
2918
2917
|
if (plan.inserts.length === 0) {
|
|
2919
2918
|
await connection.commit();
|
|
@@ -2956,7 +2955,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2956
2955
|
});
|
|
2957
2956
|
}
|
|
2958
2957
|
await connection.execute(`INSERT INTO ${tableVersionsName} (\`id\`, \`datasetId\`, \`version\`, \`createdAt\`) VALUES (?, ?, ?, ?)`, [
|
|
2959
|
-
|
|
2958
|
+
globalThis.crypto.randomUUID(),
|
|
2960
2959
|
input.datasetId,
|
|
2961
2960
|
newVersion,
|
|
2962
2961
|
transformToSqlValue(now)
|
|
@@ -2987,7 +2986,7 @@ var DatasetsMySQL = class DatasetsMySQL extends _mastra_core_storage.DatasetsSto
|
|
|
2987
2986
|
try {
|
|
2988
2987
|
await connection.beginTransaction();
|
|
2989
2988
|
const now = /* @__PURE__ */ new Date();
|
|
2990
|
-
const versionId =
|
|
2989
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2991
2990
|
const tableDatasetsName = formatTableName(_mastra_core_storage.TABLE_DATASETS);
|
|
2992
2991
|
const tableItemsName = formatTableName(_mastra_core_storage.TABLE_DATASET_ITEMS);
|
|
2993
2992
|
const tableVersionsName = formatTableName(_mastra_core_storage.TABLE_DATASET_VERSIONS);
|
|
@@ -3288,7 +3287,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
3288
3287
|
}
|
|
3289
3288
|
async createExperiment(input) {
|
|
3290
3289
|
try {
|
|
3291
|
-
const id = input.id ??
|
|
3290
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
3292
3291
|
const now = /* @__PURE__ */ new Date();
|
|
3293
3292
|
await this.operations.insert({
|
|
3294
3293
|
tableName: _mastra_core_storage.TABLE_EXPERIMENTS,
|
|
@@ -3567,7 +3566,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
3567
3566
|
text: "Tool mock reports are not supported on the MySQL storage adapter. Use a supported adapter (LibSQL, PostgreSQL, MongoDB, or Spanner) to persist experiment tool mock reports."
|
|
3568
3567
|
});
|
|
3569
3568
|
try {
|
|
3570
|
-
const id = input.id ??
|
|
3569
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
3571
3570
|
const now = /* @__PURE__ */ new Date();
|
|
3572
3571
|
const purgeMetadata = await this.#withPurgeBarrier(input.experimentId, input.itemId, async (connection, marker) => {
|
|
3573
3572
|
await connection.execute(`INSERT INTO ${formatTableName(_mastra_core_storage.TABLE_EXPERIMENT_RESULTS)} (
|
|
@@ -3718,7 +3717,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends _mastra_core_storage.Exper
|
|
|
3718
3717
|
await connection.execute(`INSERT INTO ${tableName} (${columns.map((column) => quoteIdentifier(column, "column name")).join(", ")})
|
|
3719
3718
|
VALUES (${Array.from({ length: columns.length }, () => "?").join(", ")})
|
|
3720
3719
|
ON DUPLICATE KEY UPDATE ${updateColumns.map((column) => `${quoteIdentifier(column, "column name")} = VALUES(${quoteIdentifier(column, "column name")})`).join(", ")}`, [
|
|
3721
|
-
|
|
3720
|
+
globalThis.crypto.randomUUID(),
|
|
3722
3721
|
input.experimentId,
|
|
3723
3722
|
input.itemId,
|
|
3724
3723
|
...updateValues,
|
|
@@ -6721,7 +6720,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
6721
6720
|
});
|
|
6722
6721
|
const createdAt = message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date();
|
|
6723
6722
|
const record = {
|
|
6724
|
-
id: message.id ??
|
|
6723
|
+
id: message.id ?? globalThis.crypto.randomUUID(),
|
|
6725
6724
|
thread_id: message.threadId,
|
|
6726
6725
|
content: JSON.stringify(message.content ?? message),
|
|
6727
6726
|
role: message.role,
|
|
@@ -6853,7 +6852,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
6853
6852
|
text: `Source thread with id ${sourceThreadId} not found`,
|
|
6854
6853
|
details: { sourceThreadId }
|
|
6855
6854
|
});
|
|
6856
|
-
const newThreadId = providedThreadId ||
|
|
6855
|
+
const newThreadId = providedThreadId || globalThis.crypto.randomUUID();
|
|
6857
6856
|
if (await this.getThreadById({ threadId: newThreadId })) throw new _mastra_core_error.MastraError({
|
|
6858
6857
|
id: (0, _mastra_core_storage.createStorageErrorId)("MYSQL", "CLONE_THREAD", "THREAD_EXISTS"),
|
|
6859
6858
|
domain: _mastra_core_error.ErrorDomain.STORAGE,
|
|
@@ -6919,7 +6918,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
6919
6918
|
const targetResourceId = resourceId || sourceThread.resourceId;
|
|
6920
6919
|
for (const sourceRow of sourceMessageRows) {
|
|
6921
6920
|
const row = sourceRow;
|
|
6922
|
-
const newMessageId =
|
|
6921
|
+
const newMessageId = globalThis.crypto.randomUUID();
|
|
6923
6922
|
messageIdMap[row.id] = newMessageId;
|
|
6924
6923
|
let content = row.content;
|
|
6925
6924
|
try {
|
|
@@ -7346,7 +7345,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
7346
7345
|
}
|
|
7347
7346
|
async initializeObservationalMemory(input) {
|
|
7348
7347
|
try {
|
|
7349
|
-
const id =
|
|
7348
|
+
const id = globalThis.crypto.randomUUID();
|
|
7350
7349
|
const now = /* @__PURE__ */ new Date();
|
|
7351
7350
|
const lookupKey = this.getOMKey(input.threadId, input.resourceId);
|
|
7352
7351
|
const record = {
|
|
@@ -7462,7 +7461,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
7462
7461
|
}
|
|
7463
7462
|
async createReflectionGeneration(input) {
|
|
7464
7463
|
try {
|
|
7465
|
-
const id =
|
|
7464
|
+
const id = globalThis.crypto.randomUUID();
|
|
7466
7465
|
const now = /* @__PURE__ */ new Date();
|
|
7467
7466
|
const lookupKey = this.getOMKey(input.currentRecord.threadId, input.currentRecord.resourceId);
|
|
7468
7467
|
const record = {
|
|
@@ -7617,7 +7616,7 @@ var MemoryMySQL = class MemoryMySQL extends _mastra_core_storage.MemoryStorage {
|
|
|
7617
7616
|
return;
|
|
7618
7617
|
}
|
|
7619
7618
|
const newChunk = {
|
|
7620
|
-
id: `ombuf-${
|
|
7619
|
+
id: `ombuf-${globalThis.crypto.randomUUID()}`,
|
|
7621
7620
|
cycleId: input.chunk.cycleId,
|
|
7622
7621
|
observations: input.chunk.observations,
|
|
7623
7622
|
tokenCount: input.chunk.tokenCount,
|
|
@@ -9120,7 +9119,7 @@ var SchedulesMySQL = class SchedulesMySQL extends _mastra_core_storage.Schedules
|
|
|
9120
9119
|
await this.pool.execute(`DELETE FROM ${formatTableName(_mastra_core_storage.TABLE_SCHEDULES)} WHERE ${quoteIdentifier("id", "column name")} = ?`, [id]);
|
|
9121
9120
|
}
|
|
9122
9121
|
async recordTrigger(trigger) {
|
|
9123
|
-
const id = trigger.id ??
|
|
9122
|
+
const id = trigger.id ?? globalThis.crypto.randomUUID();
|
|
9124
9123
|
await this.pool.execute(`INSERT INTO ${formatTableName(_mastra_core_storage.TABLE_SCHEDULE_TRIGGERS)} (${quoteIdentifier("id", "column name")}, ${quoteIdentifier("schedule_id", "column name")}, ${quoteIdentifier("run_id", "column name")}, ${quoteIdentifier("scheduled_fire_at", "column name")}, ${quoteIdentifier("actual_fire_at", "column name")}, ${quoteIdentifier("outcome", "column name")}, ${quoteIdentifier("error", "column name")}, ${quoteIdentifier("trigger_kind", "column name")}, ${quoteIdentifier("parent_trigger_id", "column name")}, ${quoteIdentifier("metadata", "column name")}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
9125
9124
|
id,
|
|
9126
9125
|
trigger.scheduleId,
|