@mastra/mysql 0.6.0 → 0.7.0-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/index.js CHANGED
@@ -2837,15 +2837,28 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
2837
2837
  * Returns default index definitions for the experiments domain tables.
2838
2838
  */
2839
2839
  static getDefaultIndexDefs(_prefix = "") {
2840
- return [{
2841
- name: "idx_experiments_org_project",
2842
- table: TABLE_EXPERIMENTS,
2843
- columns: ["organizationId", "projectId"]
2844
- }, {
2845
- name: "idx_experiment_results_org_project",
2846
- table: TABLE_EXPERIMENT_RESULTS,
2847
- columns: ["organizationId", "projectId"]
2848
- }];
2840
+ return [
2841
+ {
2842
+ name: "idx_experiments_grouping",
2843
+ table: TABLE_EXPERIMENTS,
2844
+ columns: [
2845
+ "experimentSetId",
2846
+ "comparisonId",
2847
+ "variantId",
2848
+ "trialIndex"
2849
+ ]
2850
+ },
2851
+ {
2852
+ name: "idx_experiments_org_project",
2853
+ table: TABLE_EXPERIMENTS,
2854
+ columns: ["organizationId", "projectId"]
2855
+ },
2856
+ {
2857
+ name: "idx_experiment_results_org_project",
2858
+ table: TABLE_EXPERIMENT_RESULTS,
2859
+ columns: ["organizationId", "projectId"]
2860
+ }
2861
+ ];
2849
2862
  }
2850
2863
  /**
2851
2864
  * Exports DDL statements for all managed tables.
@@ -2901,7 +2914,13 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
2901
2914
  ifNotExists: [
2902
2915
  "agentVersion",
2903
2916
  "organizationId",
2904
- "projectId"
2917
+ "projectId",
2918
+ "provenance",
2919
+ "runnerAttestation",
2920
+ "experimentSetId",
2921
+ "comparisonId",
2922
+ "variantId",
2923
+ "trialIndex"
2905
2924
  ]
2906
2925
  });
2907
2926
  await this.operations.alterTable({
@@ -2933,6 +2952,12 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
2933
2952
  name: row.name ?? void 0,
2934
2953
  description: row.description ?? void 0,
2935
2954
  metadata: parseJSON$2(row.metadata),
2955
+ provenance: parseJSON$2(row.provenance) ?? null,
2956
+ runnerAttestation: parseJSON$2(row.runnerAttestation) ?? null,
2957
+ experimentSetId: row.experimentSetId ?? null,
2958
+ comparisonId: row.comparisonId ?? null,
2959
+ variantId: row.variantId ?? null,
2960
+ trialIndex: row.trialIndex ?? null,
2936
2961
  status: row.status,
2937
2962
  totalItems: row.totalItems,
2938
2963
  succeededCount: row.succeededCount,
@@ -2984,6 +3009,12 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
2984
3009
  name: input.name ?? null,
2985
3010
  description: input.description ?? null,
2986
3011
  metadata: input.metadata ? JSON.stringify(input.metadata) : null,
3012
+ provenance: input.provenance ? JSON.stringify(input.provenance) : null,
3013
+ runnerAttestation: input.runnerAttestation ? JSON.stringify(input.runnerAttestation) : null,
3014
+ experimentSetId: input.experimentSetId ?? null,
3015
+ comparisonId: input.comparisonId ?? null,
3016
+ variantId: input.variantId ?? null,
3017
+ trialIndex: input.trialIndex ?? null,
2987
3018
  status: "pending",
2988
3019
  totalItems: input.totalItems,
2989
3020
  succeededCount: 0,
@@ -3007,6 +3038,12 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
3007
3038
  name: input.name,
3008
3039
  description: input.description,
3009
3040
  metadata: input.metadata,
3041
+ provenance: input.provenance ?? null,
3042
+ runnerAttestation: input.runnerAttestation ?? null,
3043
+ experimentSetId: input.experimentSetId ?? null,
3044
+ comparisonId: input.comparisonId ?? null,
3045
+ variantId: input.variantId ?? null,
3046
+ trialIndex: input.trialIndex ?? null,
3010
3047
  status: "pending",
3011
3048
  totalItems: input.totalItems,
3012
3049
  succeededCount: 0,
@@ -3103,6 +3140,22 @@ var ExperimentsMySQL = class ExperimentsMySQL extends ExperimentsStorage {
3103
3140
  conditions.push(`${quoteIdentifier("status", "column name")} = ?`);
3104
3141
  params.push(args.status);
3105
3142
  }
3143
+ if (args.experimentSetId !== void 0) {
3144
+ conditions.push(`${quoteIdentifier("experimentSetId", "column name")} = ?`);
3145
+ params.push(args.experimentSetId);
3146
+ }
3147
+ if (args.comparisonId !== void 0) {
3148
+ conditions.push(`${quoteIdentifier("comparisonId", "column name")} = ?`);
3149
+ params.push(args.comparisonId);
3150
+ }
3151
+ if (args.variantId !== void 0) {
3152
+ conditions.push(`${quoteIdentifier("variantId", "column name")} = ?`);
3153
+ params.push(args.variantId);
3154
+ }
3155
+ if (args.trialIndex !== void 0) {
3156
+ conditions.push(`${quoteIdentifier("trialIndex", "column name")} = ?`);
3157
+ params.push(args.trialIndex);
3158
+ }
3106
3159
  if (args.filters) {
3107
3160
  const { organizationId, projectId } = args.filters;
3108
3161
  if (organizationId !== void 0) {
@@ -5065,12 +5118,16 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
5065
5118
  hasMore: perPageInput === false ? false : offset + perPageNormalized < total
5066
5119
  };
5067
5120
  } catch (error) {
5068
- throw new MastraError({
5069
- id: "MYSQL_MEMORY_LIST_THREADS_FAILED",
5121
+ if (error instanceof MastraError && error.category === ErrorCategory.USER) throw error;
5122
+ const mastraError = new MastraError({
5123
+ id: createStorageErrorId("MYSQL", "LIST_THREADS", "FAILED"),
5070
5124
  domain: ErrorDomain.STORAGE,
5071
5125
  category: ErrorCategory.THIRD_PARTY,
5072
5126
  details: { filter: JSON.stringify(filter ?? {}) }
5073
5127
  }, error);
5128
+ this.logger?.error?.(mastraError.toString());
5129
+ this.logger?.trackException?.(mastraError);
5130
+ throw mastraError;
5074
5131
  }
5075
5132
  }
5076
5133
  async getThreadsByResourceId(args) {
@@ -5596,8 +5653,9 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
5596
5653
  hasMore: metadataFilter || !include?.length || mainThreadMessageCount < total ? baseHasMore : false
5597
5654
  };
5598
5655
  } catch (error) {
5656
+ if (error instanceof MastraError && error.category === ErrorCategory.USER) throw error;
5599
5657
  const mastraError = new MastraError({
5600
- id: "MYSQL_MEMORY_GET_MESSAGES_PAGINATED_FAILED",
5658
+ id: createStorageErrorId("MYSQL", "LIST_MESSAGES", "FAILED"),
5601
5659
  domain: ErrorDomain.STORAGE,
5602
5660
  category: ErrorCategory.THIRD_PARTY,
5603
5661
  details: {
@@ -5608,13 +5666,7 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
5608
5666
  }, error);
5609
5667
  this.logger?.error?.(mastraError.toString());
5610
5668
  this.logger?.trackException?.(mastraError);
5611
- return {
5612
- messages: [],
5613
- total: 0,
5614
- page,
5615
- perPage,
5616
- hasMore: false
5617
- };
5669
+ throw mastraError;
5618
5670
  }
5619
5671
  }
5620
5672
  async listMessagesByResourceId(args) {
@@ -5706,21 +5758,16 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
5706
5758
  hasMore
5707
5759
  };
5708
5760
  } catch (error) {
5761
+ if (error instanceof MastraError && error.category === ErrorCategory.USER) throw error;
5709
5762
  const mastraError = new MastraError({
5710
- id: createStorageErrorId("MYSQL", "LIST_MESSAGES", "FAILED"),
5763
+ id: createStorageErrorId("MYSQL", "LIST_MESSAGES_BY_RESOURCE_ID", "FAILED"),
5711
5764
  domain: ErrorDomain.STORAGE,
5712
5765
  category: ErrorCategory.THIRD_PARTY,
5713
5766
  details: { resourceId }
5714
5767
  }, error);
5715
5768
  this.logger?.error?.(mastraError.toString());
5716
5769
  this.logger?.trackException?.(mastraError);
5717
- return {
5718
- messages: [],
5719
- total: 0,
5720
- page,
5721
- perPage: perPageForResponse,
5722
- hasMore: false
5723
- };
5770
+ throw mastraError;
5724
5771
  }
5725
5772
  }
5726
5773
  async getResourceById({ resourceId }) {