@mastra/mysql 0.11.0 → 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/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 +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
|
2
2
|
import { AGENTS_SCHEMA, AGENT_VERSIONS_SCHEMA, AgentsStorage, BackgroundTasksStorage, BlobStore, ChannelsStorage, DATASETS_SCHEMA, DATASET_ITEMS_SCHEMA, DATASET_VERSIONS_SCHEMA, DatasetsStorage, EXPERIMENTS_SCHEMA, EXPERIMENT_RESULTS_SCHEMA, ExperimentsStorage, FAVORITES_SCHEMA, FavoritesStorage, KNOWLEDGE_ACTIVITY_SCHEMA, KNOWLEDGE_CURSORS_SCHEMA, KNOWLEDGE_MENTIONS_SCHEMA, KNOWLEDGE_NODES_SCHEMA, KNOWLEDGE_RECORDS_SCHEMA, KNOWLEDGE_SEMANTIC_OUTBOX_SCHEMA, KnowledgeConflictError, KnowledgeNotFoundError, KnowledgeStorage, MCPClientsStorage, MCPServersStorage, MCP_CLIENTS_SCHEMA, MCP_CLIENT_VERSIONS_SCHEMA, MCP_SERVERS_SCHEMA, MCP_SERVER_VERSIONS_SCHEMA, MastraCompositeStore, MemoryStorage, OBSERVATIONAL_MEMORY_TABLE_SCHEMA, ObservabilityStorage, PROMPT_BLOCKS_SCHEMA, PROMPT_BLOCK_VERSIONS_SCHEMA, PromptBlocksStorage, SCORERS_SCHEMA, SCORER_DEFINITIONS_SCHEMA, SCORER_DEFINITION_VERSIONS_SCHEMA, SKILLS_SCHEMA, SKILL_BLOBS_SCHEMA, SKILL_VERSIONS_SCHEMA, SPAN_SCHEMA, SchedulesStorage, ScorerDefinitionsStorage, ScoresStorage, SkillsStorage, StoreOperations, TABLE_AGENTS, TABLE_AGENT_VERSIONS, TABLE_BACKGROUND_TASKS, TABLE_CHANNEL_CONFIG, TABLE_CHANNEL_INSTALLATIONS, TABLE_CONFIGS, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, TABLE_FAVORITES, TABLE_KNOWLEDGE_ACTIVITY, TABLE_KNOWLEDGE_CURSORS, TABLE_KNOWLEDGE_MENTIONS, TABLE_KNOWLEDGE_NODES, TABLE_KNOWLEDGE_RECORDS, TABLE_KNOWLEDGE_SEMANTIC_OUTBOX, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, TABLE_MESSAGES, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, TABLE_RESOURCES, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, TABLE_SCHEMAS, TABLE_SCORERS, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, TABLE_SKILLS, TABLE_SKILL_BLOBS, TABLE_SKILL_VERSIONS, TABLE_SPANS, TABLE_THREADS, TABLE_TOOL_PROVIDER_CONNECTIONS, TABLE_WORKFLOW_DEFINITIONS, TABLE_WORKFLOW_SNAPSHOT, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, TOOL_PROVIDER_CONNECTIONS_SCHEMA, ToolProviderConnectionsStorage, TraceStatus, WORKFLOW_DEFINITIONS_SCHEMA, WORKSPACES_SCHEMA, WORKSPACE_VERSIONS_SCHEMA, WorkflowDefinitionsStorage, WorkflowsStorage, WorkspacesStorage, assertKnowledgeCeilingRaised, assertKnowledgeScopeWithinCeiling, calculatePagination, canonicalizeKnowledgeScope, createKnowledgeUlid, createStorageErrorId, executeRetentionPrune, hasErrorCode, isKnowledgeScopeVisible, knowledgeScopeKey, knowledgeSemanticDocumentId, knowledgeSemanticIdempotencyKey, listTracesArgsSchema, matchesExpectedWorkflowStatus, normalizePerPage, normalizeScheduleTarget, parseKnowledgeNodeCursor, parseKnowledgeWikilinks, resolveListOrderBy, resolveRetentionTargets, retentionCutoffMs, toTraceSpans, validateStorageMetadataFilter } from "@mastra/core/storage";
|
|
3
3
|
import { createPool } from "mysql2/promise";
|
|
4
4
|
import { parseSqlIdentifier } from "@mastra/core/utils";
|
|
5
|
-
import { randomUUID } from "crypto";
|
|
6
5
|
import { MessageList } from "@mastra/core/agent";
|
|
7
6
|
import { skillSnapshotFieldValuesEqual } from "@mastra/core/storage/domains/skills";
|
|
8
7
|
//#region src/storage/db/schema-snapshot.ts
|
|
@@ -2154,7 +2153,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2154
2153
|
}
|
|
2155
2154
|
async createDataset(input) {
|
|
2156
2155
|
try {
|
|
2157
|
-
const id = input.id ?? randomUUID();
|
|
2156
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
2158
2157
|
if (input.id !== void 0) this.validateCallerDefinedDatasetId(input.id);
|
|
2159
2158
|
const now = /* @__PURE__ */ new Date();
|
|
2160
2159
|
await (input.id === void 0 ? this.operations.insert.bind(this.operations) : this.operations.insertOnly.bind(this.operations))({
|
|
@@ -2414,8 +2413,8 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2414
2413
|
const connection = await this.pool.getConnection();
|
|
2415
2414
|
try {
|
|
2416
2415
|
await connection.beginTransaction();
|
|
2417
|
-
const id = randomUUID();
|
|
2418
|
-
const versionId = randomUUID();
|
|
2416
|
+
const id = globalThis.crypto.randomUUID();
|
|
2417
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2419
2418
|
const now = /* @__PURE__ */ new Date();
|
|
2420
2419
|
const tableDatasetsName = formatTableName(TABLE_DATASETS);
|
|
2421
2420
|
const tableItemsName = formatTableName(TABLE_DATASET_ITEMS);
|
|
@@ -2478,7 +2477,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2478
2477
|
const connection = await this.pool.getConnection();
|
|
2479
2478
|
try {
|
|
2480
2479
|
await connection.beginTransaction();
|
|
2481
|
-
const versionId = randomUUID();
|
|
2480
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2482
2481
|
const now = /* @__PURE__ */ new Date();
|
|
2483
2482
|
const tableDatasetsName = formatTableName(TABLE_DATASETS);
|
|
2484
2483
|
const tableItemsName = formatTableName(TABLE_DATASET_ITEMS);
|
|
@@ -2587,7 +2586,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2587
2586
|
const connection = await this.pool.getConnection();
|
|
2588
2587
|
try {
|
|
2589
2588
|
await connection.beginTransaction();
|
|
2590
|
-
const versionId = randomUUID();
|
|
2589
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2591
2590
|
const now = /* @__PURE__ */ new Date();
|
|
2592
2591
|
const tableDatasetsName = formatTableName(TABLE_DATASETS);
|
|
2593
2592
|
const tableItemsName = formatTableName(TABLE_DATASET_ITEMS);
|
|
@@ -2818,7 +2817,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2818
2817
|
}
|
|
2819
2818
|
async createDatasetVersion(datasetId, version) {
|
|
2820
2819
|
try {
|
|
2821
|
-
const id = randomUUID();
|
|
2820
|
+
const id = globalThis.crypto.randomUUID();
|
|
2822
2821
|
const now = /* @__PURE__ */ new Date();
|
|
2823
2822
|
await this.operations.insert({
|
|
2824
2823
|
tableName: TABLE_DATASET_VERSIONS,
|
|
@@ -2912,7 +2911,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2912
2911
|
const [rows] = await connection.execute(`SELECT ${ITEM_SELECT_COLUMNS} FROM ${tableItemsName} WHERE \`datasetId\` = ? AND \`externalId\` IN (${placeholders}) ORDER BY \`datasetVersion\` ASC`, [input.datasetId, ...externalIds]);
|
|
2913
2912
|
historyRows = rows.map((row) => this.mapItemFull(row));
|
|
2914
2913
|
}
|
|
2915
|
-
const plan = this.planDatasetItemBatch(input.items, historyRows, randomUUID);
|
|
2914
|
+
const plan = this.planDatasetItemBatch(input.items, historyRows, () => globalThis.crypto.randomUUID());
|
|
2916
2915
|
const existingItems = new Map([...plan.existingCurrentItems].map(([id, row]) => [id, this.datasetItemFromRow(row)]));
|
|
2917
2916
|
if (plan.inserts.length === 0) {
|
|
2918
2917
|
await connection.commit();
|
|
@@ -2955,7 +2954,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2955
2954
|
});
|
|
2956
2955
|
}
|
|
2957
2956
|
await connection.execute(`INSERT INTO ${tableVersionsName} (\`id\`, \`datasetId\`, \`version\`, \`createdAt\`) VALUES (?, ?, ?, ?)`, [
|
|
2958
|
-
randomUUID(),
|
|
2957
|
+
globalThis.crypto.randomUUID(),
|
|
2959
2958
|
input.datasetId,
|
|
2960
2959
|
newVersion,
|
|
2961
2960
|
transformToSqlValue(now)
|
|
@@ -2986,7 +2985,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2986
2985
|
try {
|
|
2987
2986
|
await connection.beginTransaction();
|
|
2988
2987
|
const now = /* @__PURE__ */ new Date();
|
|
2989
|
-
const versionId = randomUUID();
|
|
2988
|
+
const versionId = globalThis.crypto.randomUUID();
|
|
2990
2989
|
const tableDatasetsName = formatTableName(TABLE_DATASETS);
|
|
2991
2990
|
const tableItemsName = formatTableName(TABLE_DATASET_ITEMS);
|
|
2992
2991
|
const tableVersionsName = formatTableName(TABLE_DATASET_VERSIONS);
|
|
@@ -3287,7 +3286,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3287
3286
|
}
|
|
3288
3287
|
async createExperiment(input) {
|
|
3289
3288
|
try {
|
|
3290
|
-
const id = input.id ?? randomUUID();
|
|
3289
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
3291
3290
|
const now = /* @__PURE__ */ new Date();
|
|
3292
3291
|
await this.operations.insert({
|
|
3293
3292
|
tableName: TABLE_EXPERIMENTS,
|
|
@@ -3566,7 +3565,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3566
3565
|
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."
|
|
3567
3566
|
});
|
|
3568
3567
|
try {
|
|
3569
|
-
const id = input.id ?? randomUUID();
|
|
3568
|
+
const id = input.id ?? globalThis.crypto.randomUUID();
|
|
3570
3569
|
const now = /* @__PURE__ */ new Date();
|
|
3571
3570
|
const purgeMetadata = await this.#withPurgeBarrier(input.experimentId, input.itemId, async (connection, marker) => {
|
|
3572
3571
|
await connection.execute(`INSERT INTO ${formatTableName(TABLE_EXPERIMENT_RESULTS)} (
|
|
@@ -3717,7 +3716,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3717
3716
|
await connection.execute(`INSERT INTO ${tableName} (${columns.map((column) => quoteIdentifier(column, "column name")).join(", ")})
|
|
3718
3717
|
VALUES (${Array.from({ length: columns.length }, () => "?").join(", ")})
|
|
3719
3718
|
ON DUPLICATE KEY UPDATE ${updateColumns.map((column) => `${quoteIdentifier(column, "column name")} = VALUES(${quoteIdentifier(column, "column name")})`).join(", ")}`, [
|
|
3720
|
-
randomUUID(),
|
|
3719
|
+
globalThis.crypto.randomUUID(),
|
|
3721
3720
|
input.experimentId,
|
|
3722
3721
|
input.itemId,
|
|
3723
3722
|
...updateValues,
|
|
@@ -6720,7 +6719,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
6720
6719
|
});
|
|
6721
6720
|
const createdAt = message.createdAt ? new Date(message.createdAt) : /* @__PURE__ */ new Date();
|
|
6722
6721
|
const record = {
|
|
6723
|
-
id: message.id ?? randomUUID(),
|
|
6722
|
+
id: message.id ?? globalThis.crypto.randomUUID(),
|
|
6724
6723
|
thread_id: message.threadId,
|
|
6725
6724
|
content: JSON.stringify(message.content ?? message),
|
|
6726
6725
|
role: message.role,
|
|
@@ -6852,7 +6851,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
6852
6851
|
text: `Source thread with id ${sourceThreadId} not found`,
|
|
6853
6852
|
details: { sourceThreadId }
|
|
6854
6853
|
});
|
|
6855
|
-
const newThreadId = providedThreadId || randomUUID();
|
|
6854
|
+
const newThreadId = providedThreadId || globalThis.crypto.randomUUID();
|
|
6856
6855
|
if (await this.getThreadById({ threadId: newThreadId })) throw new MastraError({
|
|
6857
6856
|
id: createStorageErrorId("MYSQL", "CLONE_THREAD", "THREAD_EXISTS"),
|
|
6858
6857
|
domain: ErrorDomain.STORAGE,
|
|
@@ -6918,7 +6917,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
6918
6917
|
const targetResourceId = resourceId || sourceThread.resourceId;
|
|
6919
6918
|
for (const sourceRow of sourceMessageRows) {
|
|
6920
6919
|
const row = sourceRow;
|
|
6921
|
-
const newMessageId = randomUUID();
|
|
6920
|
+
const newMessageId = globalThis.crypto.randomUUID();
|
|
6922
6921
|
messageIdMap[row.id] = newMessageId;
|
|
6923
6922
|
let content = row.content;
|
|
6924
6923
|
try {
|
|
@@ -7345,7 +7344,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
7345
7344
|
}
|
|
7346
7345
|
async initializeObservationalMemory(input) {
|
|
7347
7346
|
try {
|
|
7348
|
-
const id = randomUUID();
|
|
7347
|
+
const id = globalThis.crypto.randomUUID();
|
|
7349
7348
|
const now = /* @__PURE__ */ new Date();
|
|
7350
7349
|
const lookupKey = this.getOMKey(input.threadId, input.resourceId);
|
|
7351
7350
|
const record = {
|
|
@@ -7461,7 +7460,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
7461
7460
|
}
|
|
7462
7461
|
async createReflectionGeneration(input) {
|
|
7463
7462
|
try {
|
|
7464
|
-
const id = randomUUID();
|
|
7463
|
+
const id = globalThis.crypto.randomUUID();
|
|
7465
7464
|
const now = /* @__PURE__ */ new Date();
|
|
7466
7465
|
const lookupKey = this.getOMKey(input.currentRecord.threadId, input.currentRecord.resourceId);
|
|
7467
7466
|
const record = {
|
|
@@ -7616,7 +7615,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
7616
7615
|
return;
|
|
7617
7616
|
}
|
|
7618
7617
|
const newChunk = {
|
|
7619
|
-
id: `ombuf-${randomUUID()}`,
|
|
7618
|
+
id: `ombuf-${globalThis.crypto.randomUUID()}`,
|
|
7620
7619
|
cycleId: input.chunk.cycleId,
|
|
7621
7620
|
observations: input.chunk.observations,
|
|
7622
7621
|
tokenCount: input.chunk.tokenCount,
|
|
@@ -9119,7 +9118,7 @@ var SchedulesMySQL = class SchedulesMySQL extends SchedulesStorage {
|
|
|
9119
9118
|
await this.pool.execute(`DELETE FROM ${formatTableName(TABLE_SCHEDULES)} WHERE ${quoteIdentifier("id", "column name")} = ?`, [id]);
|
|
9120
9119
|
}
|
|
9121
9120
|
async recordTrigger(trigger) {
|
|
9122
|
-
const id = trigger.id ?? randomUUID();
|
|
9121
|
+
const id = trigger.id ?? globalThis.crypto.randomUUID();
|
|
9123
9122
|
await this.pool.execute(`INSERT INTO ${formatTableName(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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
9124
9123
|
id,
|
|
9125
9124
|
trigger.scheduleId,
|