@mastra/mssql 0.4.2-alpha.0 → 0.4.3-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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @mastra/mssql
2
2
 
3
+ ## 0.4.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Update peer deps ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
8
+
9
+ - MSSQL support fetch scores by trace and span id ([#8154](https://github.com/mastra-ai/mastra/pull/8154))
10
+
11
+ - Updated dependencies [[`504438b`](https://github.com/mastra-ai/mastra/commit/504438b961bde211071186bba63a842c4e3db879), [`a7243e2`](https://github.com/mastra-ai/mastra/commit/a7243e2e58762667a6e3921e755e89d6bb0a3282), [`7fceb0a`](https://github.com/mastra-ai/mastra/commit/7fceb0a327d678e812f90f5387c5bc4f38bd039e), [`df64f9e`](https://github.com/mastra-ai/mastra/commit/df64f9ef814916fff9baedd861c988084e7c41de), [`809eea0`](https://github.com/mastra-ai/mastra/commit/809eea092fa80c3f69b9eaf078d843b57fd2a88e), [`683e5a1`](https://github.com/mastra-ai/mastra/commit/683e5a1466e48b686825b2c11f84680f296138e4), [`3679378`](https://github.com/mastra-ai/mastra/commit/3679378673350aa314741dc826f837b1984149bc), [`7775bc2`](https://github.com/mastra-ai/mastra/commit/7775bc20bb1ad1ab24797fb420e4f96c65b0d8ec), [`db1891a`](https://github.com/mastra-ai/mastra/commit/db1891a4707443720b7cd8a260dc7e1d49b3609c), [`e8f379d`](https://github.com/mastra-ai/mastra/commit/e8f379d390efa264c4e0874f9ac0cf8839b07777), [`652066b`](https://github.com/mastra-ai/mastra/commit/652066bd1efc6bb6813ba950ed1d7573e8b7d9d4), [`ea8d386`](https://github.com/mastra-ai/mastra/commit/ea8d386cd8c5593664515fd5770c06bf2aa980ef), [`c2a4919`](https://github.com/mastra-ai/mastra/commit/c2a4919ba6797d8bdb1509e02287496eef69303e), [`0130986`](https://github.com/mastra-ai/mastra/commit/0130986fc62d0edcc626dd593282661dbb9af141)]:
12
+ - @mastra/core@0.19.0-alpha.1
13
+
14
+ ## 0.4.2
15
+
16
+ ### Patch Changes
17
+
18
+ - Update Peerdeps for packages based on core minor bump ([#8025](https://github.com/mastra-ai/mastra/pull/8025))
19
+
20
+ - Updated dependencies [[`cf34503`](https://github.com/mastra-ai/mastra/commit/cf345031de4e157f29087946449e60b965e9c8a9), [`6b4b1e4`](https://github.com/mastra-ai/mastra/commit/6b4b1e4235428d39e51cbda9832704c0ba70ab32), [`3469fca`](https://github.com/mastra-ai/mastra/commit/3469fca7bb7e5e19369ff9f7044716a5e4b02585), [`a61f23f`](https://github.com/mastra-ai/mastra/commit/a61f23fbbca4b88b763d94f1d784c47895ed72d7), [`4b339b8`](https://github.com/mastra-ai/mastra/commit/4b339b8141c20d6a6d80583c7e8c5c05d8c19492), [`d1dc606`](https://github.com/mastra-ai/mastra/commit/d1dc6067b0557a71190b68d56ee15b48c26d2411), [`c45298a`](https://github.com/mastra-ai/mastra/commit/c45298a0a0791db35cf79f1199d77004da0704cb), [`c4a8204`](https://github.com/mastra-ai/mastra/commit/c4a82046bfd241d6044e234bc5917d5a01fe6b55), [`d3bd4d4`](https://github.com/mastra-ai/mastra/commit/d3bd4d482a685bbb67bfa89be91c90dca3fa71ad), [`c591dfc`](https://github.com/mastra-ai/mastra/commit/c591dfc1e600fae1dedffe239357d250e146378f), [`1920c5c`](https://github.com/mastra-ai/mastra/commit/1920c5c6d666f687785c73021196aa551e579e0d), [`b6a3b65`](https://github.com/mastra-ai/mastra/commit/b6a3b65d830fa0ca7754ad6481661d1f2c878f21), [`af3abb6`](https://github.com/mastra-ai/mastra/commit/af3abb6f7c7585d856e22d27f4e7d2ece2186b9a)]:
21
+ - @mastra/core@0.18.0
22
+
3
23
  ## 0.4.2-alpha.0
4
24
 
5
25
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -5,6 +5,7 @@ var storage = require('@mastra/core/storage');
5
5
  var sql2 = require('mssql');
6
6
  var utils = require('@mastra/core/utils');
7
7
  var agent = require('@mastra/core/agent');
8
+ var scores = require('@mastra/core/scores');
8
9
 
9
10
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
11
 
@@ -1479,6 +1480,19 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
1479
1480
  }
1480
1481
  }
1481
1482
  async saveScore(score) {
1483
+ let validatedScore;
1484
+ try {
1485
+ validatedScore = scores.saveScorePayloadSchema.parse(score);
1486
+ } catch (error$1) {
1487
+ throw new error.MastraError(
1488
+ {
1489
+ id: "MASTRA_STORAGE_MSSQL_STORE_SAVE_SCORE_VALIDATION_FAILED",
1490
+ domain: error.ErrorDomain.STORAGE,
1491
+ category: error.ErrorCategory.THIRD_PARTY
1492
+ },
1493
+ error$1
1494
+ );
1495
+ }
1482
1496
  try {
1483
1497
  const scoreId = crypto.randomUUID();
1484
1498
  const {
@@ -1492,7 +1506,7 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
1492
1506
  runtimeContext,
1493
1507
  entity,
1494
1508
  ...rest
1495
- } = score;
1509
+ } = validatedScore;
1496
1510
  await this.operations.insert({
1497
1511
  tableName: storage.TABLE_SCORERS,
1498
1512
  record: {
@@ -1677,6 +1691,60 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
1677
1691
  );
1678
1692
  }
1679
1693
  }
1694
+ async getScoresBySpan({
1695
+ traceId,
1696
+ spanId,
1697
+ pagination
1698
+ }) {
1699
+ try {
1700
+ const request = this.pool.request();
1701
+ request.input("p1", traceId);
1702
+ request.input("p2", spanId);
1703
+ const totalResult = await request.query(
1704
+ `SELECT COUNT(*) as count FROM ${getTableName({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2`
1705
+ );
1706
+ const total = totalResult.recordset[0]?.count || 0;
1707
+ if (total === 0) {
1708
+ return {
1709
+ pagination: {
1710
+ total: 0,
1711
+ page: pagination.page,
1712
+ perPage: pagination.perPage,
1713
+ hasMore: false
1714
+ },
1715
+ scores: []
1716
+ };
1717
+ }
1718
+ const limit = pagination.perPage + 1;
1719
+ const dataRequest = this.pool.request();
1720
+ dataRequest.input("p1", traceId);
1721
+ dataRequest.input("p2", spanId);
1722
+ dataRequest.input("p3", limit);
1723
+ dataRequest.input("p4", pagination.page * pagination.perPage);
1724
+ const result = await dataRequest.query(
1725
+ `SELECT * FROM ${getTableName({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2 ORDER BY [createdAt] DESC OFFSET @p4 ROWS FETCH NEXT @p3 ROWS ONLY`
1726
+ );
1727
+ return {
1728
+ pagination: {
1729
+ total: Number(total),
1730
+ page: pagination.page,
1731
+ perPage: pagination.perPage,
1732
+ hasMore: result.recordset.length > pagination.perPage
1733
+ },
1734
+ scores: result.recordset.slice(0, pagination.perPage).map((row) => transformScoreRow(row))
1735
+ };
1736
+ } catch (error$1) {
1737
+ throw new error.MastraError(
1738
+ {
1739
+ id: "MASTRA_STORAGE_MSSQL_STORE_GET_SCORES_BY_SPAN_FAILED",
1740
+ domain: error.ErrorDomain.STORAGE,
1741
+ category: error.ErrorCategory.THIRD_PARTY,
1742
+ details: { traceId, spanId }
1743
+ },
1744
+ error$1
1745
+ );
1746
+ }
1747
+ }
1680
1748
  };
1681
1749
  var TracesMSSQL = class extends storage.TracesStorage {
1682
1750
  pool;
@@ -2166,7 +2234,8 @@ var MSSQLStore = class extends storage.MastraStorage {
2166
2234
  resourceWorkingMemory: true,
2167
2235
  hasColumn: true,
2168
2236
  createTable: true,
2169
- deleteMessages: true
2237
+ deleteMessages: true,
2238
+ getScoresBySpan: true
2170
2239
  };
2171
2240
  }
2172
2241
  /** @deprecated use getEvals instead */
@@ -2364,6 +2433,13 @@ var MSSQLStore = class extends storage.MastraStorage {
2364
2433
  pagination: _pagination
2365
2434
  });
2366
2435
  }
2436
+ async getScoresBySpan({
2437
+ traceId,
2438
+ spanId,
2439
+ pagination: _pagination
2440
+ }) {
2441
+ return this.stores.scores.getScoresBySpan({ traceId, spanId, pagination: _pagination });
2442
+ }
2367
2443
  };
2368
2444
 
2369
2445
  exports.MSSQLStore = MSSQLStore;