@mastra/mysql 0.10.0-alpha.1 → 0.10.0-alpha.2
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 +24 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -5
- 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/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorCategory, ErrorDomain, MastraError } from "@mastra/core/error";
|
|
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, resolveRetentionTargets, retentionCutoffMs, toTraceSpans, validateStorageMetadataFilter } from "@mastra/core/storage";
|
|
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
5
|
import { randomUUID } from "crypto";
|
|
@@ -2279,6 +2279,14 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2279
2279
|
}
|
|
2280
2280
|
async listDatasets(args) {
|
|
2281
2281
|
try {
|
|
2282
|
+
const orderBy = resolveListOrderBy(args.orderBy, [
|
|
2283
|
+
"createdAt",
|
|
2284
|
+
"updatedAt",
|
|
2285
|
+
"name"
|
|
2286
|
+
], {
|
|
2287
|
+
field: "createdAt",
|
|
2288
|
+
direction: "DESC"
|
|
2289
|
+
});
|
|
2282
2290
|
const { page, perPage: perPageInput } = args.pagination;
|
|
2283
2291
|
const filterParts = [];
|
|
2284
2292
|
const filterArgs = [];
|
|
@@ -2335,7 +2343,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2335
2343
|
datasets: (await this.operations.loadMany({
|
|
2336
2344
|
tableName: TABLE_DATASETS,
|
|
2337
2345
|
whereClause,
|
|
2338
|
-
orderBy: `${quoteIdentifier(
|
|
2346
|
+
orderBy: `${quoteIdentifier(orderBy.field, "column name")} ${orderBy.direction}, \`id\` ASC`,
|
|
2339
2347
|
offset,
|
|
2340
2348
|
limit: limitValue
|
|
2341
2349
|
})).map((row) => this.mapDataset(row)),
|
|
@@ -2698,6 +2706,10 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2698
2706
|
}
|
|
2699
2707
|
async listItems(args) {
|
|
2700
2708
|
try {
|
|
2709
|
+
const orderBy = resolveListOrderBy(args.orderBy, ["createdAt", "updatedAt"], {
|
|
2710
|
+
field: "createdAt",
|
|
2711
|
+
direction: "DESC"
|
|
2712
|
+
});
|
|
2701
2713
|
const { page, perPage: perPageInput } = args.pagination;
|
|
2702
2714
|
const tableItemsName = formatTableName(TABLE_DATASET_ITEMS);
|
|
2703
2715
|
const conditions = [`\`datasetId\` = ?`];
|
|
@@ -2739,7 +2751,7 @@ var DatasetsMySQL = class DatasetsMySQL extends DatasetsStorage {
|
|
|
2739
2751
|
const perPage = normalizePerPage(perPageInput, 100);
|
|
2740
2752
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
2741
2753
|
const limitValue = perPageInput === false ? total : perPage;
|
|
2742
|
-
const [rows] = await this.pool.execute(`SELECT * FROM ${tableItemsName}${whereSql} ORDER BY
|
|
2754
|
+
const [rows] = await this.pool.execute(`SELECT * FROM ${tableItemsName}${whereSql} ORDER BY ${quoteIdentifier(orderBy.field, "column name")} ${orderBy.direction}, \`id\` ASC LIMIT ${limitValue} OFFSET ${offset}`, params);
|
|
2743
2755
|
return {
|
|
2744
2756
|
items: rows.map((row) => this.mapItem(row)),
|
|
2745
2757
|
pagination: {
|
|
@@ -3354,6 +3366,10 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3354
3366
|
}
|
|
3355
3367
|
async listExperiments(args) {
|
|
3356
3368
|
try {
|
|
3369
|
+
const orderBy = resolveListOrderBy(args.orderBy, ["createdAt", "status"], {
|
|
3370
|
+
field: "createdAt",
|
|
3371
|
+
direction: "DESC"
|
|
3372
|
+
});
|
|
3357
3373
|
const { page, perPage: perPageInput } = args.pagination;
|
|
3358
3374
|
const conditions = [];
|
|
3359
3375
|
const params = [];
|
|
@@ -3428,7 +3444,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3428
3444
|
experiments: (await this.operations.loadMany({
|
|
3429
3445
|
tableName: TABLE_EXPERIMENTS,
|
|
3430
3446
|
whereClause,
|
|
3431
|
-
orderBy: `${quoteIdentifier(
|
|
3447
|
+
orderBy: `${quoteIdentifier(orderBy.field, "column name")} ${orderBy.direction}, \`id\` ASC`,
|
|
3432
3448
|
offset,
|
|
3433
3449
|
limit: limitValue
|
|
3434
3450
|
})).map((row) => this.mapExperiment(row)),
|
|
@@ -3759,6 +3775,10 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3759
3775
|
}
|
|
3760
3776
|
async listExperimentResults(args) {
|
|
3761
3777
|
try {
|
|
3778
|
+
const orderBy = resolveListOrderBy(args.orderBy, ["startedAt", "createdAt"], {
|
|
3779
|
+
field: "startedAt",
|
|
3780
|
+
direction: "ASC"
|
|
3781
|
+
});
|
|
3762
3782
|
const { page, perPage: perPageInput } = args.pagination;
|
|
3763
3783
|
const conditions = [`${quoteIdentifier("experimentId", "column name")} = ?`];
|
|
3764
3784
|
const params = [args.experimentId];
|
|
@@ -3809,7 +3829,7 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
|
|
|
3809
3829
|
results: (await this.operations.loadMany({
|
|
3810
3830
|
tableName: TABLE_EXPERIMENT_RESULTS,
|
|
3811
3831
|
whereClause,
|
|
3812
|
-
orderBy: `${quoteIdentifier(
|
|
3832
|
+
orderBy: `${quoteIdentifier(orderBy.field, "column name")} ${orderBy.direction}, \`id\` ASC`,
|
|
3813
3833
|
offset,
|
|
3814
3834
|
limit: limitValue
|
|
3815
3835
|
})).map((row) => this.mapExperimentResult(row)),
|