@mastra/mssql 1.0.0-beta.3 → 1.0.0-beta.5
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 +47 -0
- package/dist/index.cjs +79 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +80 -72
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/observability/index.d.ts.map +1 -1
- package/dist/storage/domains/operations/index.d.ts.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +2 -2
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +22 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
2
|
-
import { MastraStorage, StoreOperations, TABLE_WORKFLOW_SNAPSHOT, TABLE_SCHEMAS, TABLE_THREADS, TABLE_MESSAGES, TABLE_TRACES, TABLE_SCORERS, TABLE_SPANS, ScoresStorage, normalizePerPage, calculatePagination, WorkflowsStorage, MemoryStorage, TABLE_RESOURCES, ObservabilityStorage, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
|
|
2
|
+
import { MastraStorage, createStorageErrorId, StoreOperations, TABLE_WORKFLOW_SNAPSHOT, TABLE_SCHEMAS, TABLE_THREADS, TABLE_MESSAGES, TABLE_TRACES, TABLE_SCORERS, TABLE_SPANS, ScoresStorage, normalizePerPage, calculatePagination, WorkflowsStorage, MemoryStorage, TABLE_RESOURCES, ObservabilityStorage, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
|
|
3
3
|
import sql2 from 'mssql';
|
|
4
4
|
import { MessageList } from '@mastra/core/agent';
|
|
5
5
|
import { parseSqlIdentifier } from '@mastra/core/utils';
|
|
@@ -175,7 +175,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
175
175
|
} catch (error) {
|
|
176
176
|
throw new MastraError(
|
|
177
177
|
{
|
|
178
|
-
id: "
|
|
178
|
+
id: createStorageErrorId("MSSQL", "GET_THREAD_BY_ID", "FAILED"),
|
|
179
179
|
domain: ErrorDomain.STORAGE,
|
|
180
180
|
category: ErrorCategory.THIRD_PARTY,
|
|
181
181
|
details: {
|
|
@@ -190,7 +190,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
190
190
|
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
191
191
|
if (page < 0) {
|
|
192
192
|
throw new MastraError({
|
|
193
|
-
id: "
|
|
193
|
+
id: createStorageErrorId("MSSQL", "LIST_THREADS_BY_RESOURCE_ID", "INVALID_PAGE"),
|
|
194
194
|
domain: ErrorDomain.STORAGE,
|
|
195
195
|
category: ErrorCategory.USER,
|
|
196
196
|
text: "Page number must be non-negative",
|
|
@@ -249,7 +249,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
249
249
|
} catch (error) {
|
|
250
250
|
const mastraError = new MastraError(
|
|
251
251
|
{
|
|
252
|
-
id: "
|
|
252
|
+
id: createStorageErrorId("MSSQL", "LIST_THREADS_BY_RESOURCE_ID", "FAILED"),
|
|
253
253
|
domain: ErrorDomain.STORAGE,
|
|
254
254
|
category: ErrorCategory.THIRD_PARTY,
|
|
255
255
|
details: {
|
|
@@ -302,7 +302,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
302
302
|
} catch (error) {
|
|
303
303
|
throw new MastraError(
|
|
304
304
|
{
|
|
305
|
-
id: "
|
|
305
|
+
id: createStorageErrorId("MSSQL", "SAVE_THREAD", "FAILED"),
|
|
306
306
|
domain: ErrorDomain.STORAGE,
|
|
307
307
|
category: ErrorCategory.THIRD_PARTY,
|
|
308
308
|
details: {
|
|
@@ -324,7 +324,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
324
324
|
const existingThread = await this.getThreadById({ threadId: id });
|
|
325
325
|
if (!existingThread) {
|
|
326
326
|
throw new MastraError({
|
|
327
|
-
id: "
|
|
327
|
+
id: createStorageErrorId("MSSQL", "UPDATE_THREAD", "NOT_FOUND"),
|
|
328
328
|
domain: ErrorDomain.STORAGE,
|
|
329
329
|
category: ErrorCategory.USER,
|
|
330
330
|
text: `Thread ${id} not found`,
|
|
@@ -359,7 +359,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
359
359
|
}
|
|
360
360
|
if (!thread) {
|
|
361
361
|
throw new MastraError({
|
|
362
|
-
id: "
|
|
362
|
+
id: createStorageErrorId("MSSQL", "UPDATE_THREAD", "NOT_FOUND"),
|
|
363
363
|
domain: ErrorDomain.STORAGE,
|
|
364
364
|
category: ErrorCategory.USER,
|
|
365
365
|
text: `Thread ${id} not found after update`,
|
|
@@ -378,7 +378,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
378
378
|
} catch (error) {
|
|
379
379
|
throw new MastraError(
|
|
380
380
|
{
|
|
381
|
-
id: "
|
|
381
|
+
id: createStorageErrorId("MSSQL", "UPDATE_THREAD", "FAILED"),
|
|
382
382
|
domain: ErrorDomain.STORAGE,
|
|
383
383
|
category: ErrorCategory.THIRD_PARTY,
|
|
384
384
|
details: {
|
|
@@ -408,7 +408,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
408
408
|
});
|
|
409
409
|
throw new MastraError(
|
|
410
410
|
{
|
|
411
|
-
id: "
|
|
411
|
+
id: createStorageErrorId("MSSQL", "DELETE_THREAD", "FAILED"),
|
|
412
412
|
domain: ErrorDomain.STORAGE,
|
|
413
413
|
category: ErrorCategory.THIRD_PARTY,
|
|
414
414
|
details: {
|
|
@@ -523,7 +523,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
523
523
|
} catch (error) {
|
|
524
524
|
const mastraError = new MastraError(
|
|
525
525
|
{
|
|
526
|
-
id: "
|
|
526
|
+
id: createStorageErrorId("MSSQL", "LIST_MESSAGES_BY_ID", "FAILED"),
|
|
527
527
|
domain: ErrorDomain.STORAGE,
|
|
528
528
|
category: ErrorCategory.THIRD_PARTY,
|
|
529
529
|
details: {
|
|
@@ -543,7 +543,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
543
543
|
if (threadIds.length === 0 || threadIds.some((id) => !id.trim())) {
|
|
544
544
|
throw new MastraError(
|
|
545
545
|
{
|
|
546
|
-
id: "
|
|
546
|
+
id: createStorageErrorId("MSSQL", "LIST_MESSAGES", "INVALID_THREAD_ID"),
|
|
547
547
|
domain: ErrorDomain.STORAGE,
|
|
548
548
|
category: ErrorCategory.THIRD_PARTY,
|
|
549
549
|
details: { threadId: Array.isArray(threadId) ? threadId.join(",") : threadId }
|
|
@@ -553,7 +553,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
553
553
|
}
|
|
554
554
|
if (page < 0) {
|
|
555
555
|
throw new MastraError({
|
|
556
|
-
id: "
|
|
556
|
+
id: createStorageErrorId("MSSQL", "LIST_MESSAGES", "INVALID_PAGE"),
|
|
557
557
|
domain: ErrorDomain.STORAGE,
|
|
558
558
|
category: ErrorCategory.USER,
|
|
559
559
|
text: "Page number must be non-negative",
|
|
@@ -651,7 +651,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
651
651
|
} catch (error) {
|
|
652
652
|
const mastraError = new MastraError(
|
|
653
653
|
{
|
|
654
|
-
id: "
|
|
654
|
+
id: createStorageErrorId("MSSQL", "LIST_MESSAGES", "FAILED"),
|
|
655
655
|
domain: ErrorDomain.STORAGE,
|
|
656
656
|
category: ErrorCategory.THIRD_PARTY,
|
|
657
657
|
details: {
|
|
@@ -677,7 +677,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
677
677
|
const threadId = messages[0]?.threadId;
|
|
678
678
|
if (!threadId) {
|
|
679
679
|
throw new MastraError({
|
|
680
|
-
id: "
|
|
680
|
+
id: createStorageErrorId("MSSQL", "SAVE_MESSAGES", "INVALID_THREAD_ID"),
|
|
681
681
|
domain: ErrorDomain.STORAGE,
|
|
682
682
|
category: ErrorCategory.THIRD_PARTY,
|
|
683
683
|
text: `Thread ID is required`
|
|
@@ -686,7 +686,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
686
686
|
const thread = await this.getThreadById({ threadId });
|
|
687
687
|
if (!thread) {
|
|
688
688
|
throw new MastraError({
|
|
689
|
-
id: "
|
|
689
|
+
id: createStorageErrorId("MSSQL", "SAVE_MESSAGES", "THREAD_NOT_FOUND"),
|
|
690
690
|
domain: ErrorDomain.STORAGE,
|
|
691
691
|
category: ErrorCategory.THIRD_PARTY,
|
|
692
692
|
text: `Thread ${threadId} not found`,
|
|
@@ -759,7 +759,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
759
759
|
} catch (error) {
|
|
760
760
|
throw new MastraError(
|
|
761
761
|
{
|
|
762
|
-
id: "
|
|
762
|
+
id: createStorageErrorId("MSSQL", "SAVE_MESSAGES", "FAILED"),
|
|
763
763
|
domain: ErrorDomain.STORAGE,
|
|
764
764
|
category: ErrorCategory.THIRD_PARTY,
|
|
765
765
|
details: { threadId }
|
|
@@ -850,7 +850,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
850
850
|
await transaction.rollback();
|
|
851
851
|
throw new MastraError(
|
|
852
852
|
{
|
|
853
|
-
id: "
|
|
853
|
+
id: createStorageErrorId("MSSQL", "UPDATE_MESSAGES", "FAILED"),
|
|
854
854
|
domain: ErrorDomain.STORAGE,
|
|
855
855
|
category: ErrorCategory.THIRD_PARTY
|
|
856
856
|
},
|
|
@@ -912,7 +912,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
912
912
|
} catch (error) {
|
|
913
913
|
throw new MastraError(
|
|
914
914
|
{
|
|
915
|
-
id: "
|
|
915
|
+
id: createStorageErrorId("MSSQL", "DELETE_MESSAGES", "FAILED"),
|
|
916
916
|
domain: ErrorDomain.STORAGE,
|
|
917
917
|
category: ErrorCategory.THIRD_PARTY,
|
|
918
918
|
details: { messageIds: messageIds.join(", ") }
|
|
@@ -940,7 +940,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
940
940
|
} catch (error) {
|
|
941
941
|
const mastraError = new MastraError(
|
|
942
942
|
{
|
|
943
|
-
id: "
|
|
943
|
+
id: createStorageErrorId("MSSQL", "GET_RESOURCE_BY_ID", "FAILED"),
|
|
944
944
|
domain: ErrorDomain.STORAGE,
|
|
945
945
|
category: ErrorCategory.THIRD_PARTY,
|
|
946
946
|
details: { resourceId }
|
|
@@ -1007,7 +1007,7 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
1007
1007
|
} catch (error) {
|
|
1008
1008
|
const mastraError = new MastraError(
|
|
1009
1009
|
{
|
|
1010
|
-
id: "
|
|
1010
|
+
id: createStorageErrorId("MSSQL", "UPDATE_RESOURCE", "FAILED"),
|
|
1011
1011
|
domain: ErrorDomain.STORAGE,
|
|
1012
1012
|
category: ErrorCategory.THIRD_PARTY,
|
|
1013
1013
|
details: { resourceId }
|
|
@@ -1054,7 +1054,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1054
1054
|
} catch (error) {
|
|
1055
1055
|
throw new MastraError(
|
|
1056
1056
|
{
|
|
1057
|
-
id: "
|
|
1057
|
+
id: createStorageErrorId("MSSQL", "CREATE_SPAN", "FAILED"),
|
|
1058
1058
|
domain: ErrorDomain.STORAGE,
|
|
1059
1059
|
category: ErrorCategory.USER,
|
|
1060
1060
|
details: {
|
|
@@ -1100,7 +1100,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1100
1100
|
} catch (error) {
|
|
1101
1101
|
throw new MastraError(
|
|
1102
1102
|
{
|
|
1103
|
-
id: "
|
|
1103
|
+
id: createStorageErrorId("MSSQL", "GET_TRACE", "FAILED"),
|
|
1104
1104
|
domain: ErrorDomain.STORAGE,
|
|
1105
1105
|
category: ErrorCategory.USER,
|
|
1106
1106
|
details: {
|
|
@@ -1132,7 +1132,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1132
1132
|
} catch (error) {
|
|
1133
1133
|
throw new MastraError(
|
|
1134
1134
|
{
|
|
1135
|
-
id: "
|
|
1135
|
+
id: createStorageErrorId("MSSQL", "UPDATE_SPAN", "FAILED"),
|
|
1136
1136
|
domain: ErrorDomain.STORAGE,
|
|
1137
1137
|
category: ErrorCategory.USER,
|
|
1138
1138
|
details: {
|
|
@@ -1169,7 +1169,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1169
1169
|
name = `agent run: '${entityId}'`;
|
|
1170
1170
|
} else {
|
|
1171
1171
|
const error = new MastraError({
|
|
1172
|
-
id: "
|
|
1172
|
+
id: createStorageErrorId("MSSQL", "GET_TRACES_PAGINATED", "INVALID_ENTITY_TYPE"),
|
|
1173
1173
|
domain: ErrorDomain.STORAGE,
|
|
1174
1174
|
category: ErrorCategory.USER,
|
|
1175
1175
|
details: {
|
|
@@ -1238,7 +1238,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1238
1238
|
} catch (error) {
|
|
1239
1239
|
throw new MastraError(
|
|
1240
1240
|
{
|
|
1241
|
-
id: "
|
|
1241
|
+
id: createStorageErrorId("MSSQL", "GET_TRACES_PAGINATED", "FAILED"),
|
|
1242
1242
|
domain: ErrorDomain.STORAGE,
|
|
1243
1243
|
category: ErrorCategory.USER
|
|
1244
1244
|
},
|
|
@@ -1262,7 +1262,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1262
1262
|
} catch (error) {
|
|
1263
1263
|
throw new MastraError(
|
|
1264
1264
|
{
|
|
1265
|
-
id: "
|
|
1265
|
+
id: createStorageErrorId("MSSQL", "BATCH_CREATE_SPANS", "FAILED"),
|
|
1266
1266
|
domain: ErrorDomain.STORAGE,
|
|
1267
1267
|
category: ErrorCategory.USER,
|
|
1268
1268
|
details: {
|
|
@@ -1298,7 +1298,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1298
1298
|
} catch (error) {
|
|
1299
1299
|
throw new MastraError(
|
|
1300
1300
|
{
|
|
1301
|
-
id: "
|
|
1301
|
+
id: createStorageErrorId("MSSQL", "BATCH_UPDATE_SPANS", "FAILED"),
|
|
1302
1302
|
domain: ErrorDomain.STORAGE,
|
|
1303
1303
|
category: ErrorCategory.USER,
|
|
1304
1304
|
details: {
|
|
@@ -1322,7 +1322,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1322
1322
|
} catch (error) {
|
|
1323
1323
|
throw new MastraError(
|
|
1324
1324
|
{
|
|
1325
|
-
id: "
|
|
1325
|
+
id: createStorageErrorId("MSSQL", "BATCH_DELETE_TRACES", "FAILED"),
|
|
1326
1326
|
domain: ErrorDomain.STORAGE,
|
|
1327
1327
|
category: ErrorCategory.USER,
|
|
1328
1328
|
details: {
|
|
@@ -1362,7 +1362,7 @@ var StoreOperationsMSSQL = class extends StoreOperations {
|
|
|
1362
1362
|
return "BIT";
|
|
1363
1363
|
default:
|
|
1364
1364
|
throw new MastraError({
|
|
1365
|
-
id: "
|
|
1365
|
+
id: createStorageErrorId("MSSQL", "TYPE", "NOT_SUPPORTED"),
|
|
1366
1366
|
domain: ErrorDomain.STORAGE,
|
|
1367
1367
|
category: ErrorCategory.THIRD_PARTY
|
|
1368
1368
|
});
|
|
@@ -1448,7 +1448,7 @@ var StoreOperationsMSSQL = class extends StoreOperations {
|
|
|
1448
1448
|
} catch (error) {
|
|
1449
1449
|
throw new MastraError(
|
|
1450
1450
|
{
|
|
1451
|
-
id: "
|
|
1451
|
+
id: createStorageErrorId("MSSQL", "INSERT", "FAILED"),
|
|
1452
1452
|
domain: ErrorDomain.STORAGE,
|
|
1453
1453
|
category: ErrorCategory.THIRD_PARTY,
|
|
1454
1454
|
details: {
|
|
@@ -1474,7 +1474,7 @@ var StoreOperationsMSSQL = class extends StoreOperations {
|
|
|
1474
1474
|
} catch (error) {
|
|
1475
1475
|
throw new MastraError(
|
|
1476
1476
|
{
|
|
1477
|
-
id: "
|
|
1477
|
+
id: createStorageErrorId("MSSQL", "CLEAR_TABLE", "FAILED"),
|
|
1478
1478
|
domain: ErrorDomain.STORAGE,
|
|
1479
1479
|
category: ErrorCategory.THIRD_PARTY,
|
|
1480
1480
|
details: {
|
|
@@ -1577,7 +1577,7 @@ ${columns}
|
|
|
1577
1577
|
} catch (error) {
|
|
1578
1578
|
throw new MastraError(
|
|
1579
1579
|
{
|
|
1580
|
-
id: "
|
|
1580
|
+
id: createStorageErrorId("MSSQL", "CREATE_TABLE", "FAILED"),
|
|
1581
1581
|
domain: ErrorDomain.STORAGE,
|
|
1582
1582
|
category: ErrorCategory.THIRD_PARTY,
|
|
1583
1583
|
details: {
|
|
@@ -1637,7 +1637,7 @@ ${columns}
|
|
|
1637
1637
|
} catch (error) {
|
|
1638
1638
|
throw new MastraError(
|
|
1639
1639
|
{
|
|
1640
|
-
id: "
|
|
1640
|
+
id: createStorageErrorId("MSSQL", "ALTER_TABLE", "FAILED"),
|
|
1641
1641
|
domain: ErrorDomain.STORAGE,
|
|
1642
1642
|
category: ErrorCategory.THIRD_PARTY,
|
|
1643
1643
|
details: {
|
|
@@ -1678,7 +1678,7 @@ ${columns}
|
|
|
1678
1678
|
} catch (error) {
|
|
1679
1679
|
throw new MastraError(
|
|
1680
1680
|
{
|
|
1681
|
-
id: "
|
|
1681
|
+
id: createStorageErrorId("MSSQL", "LOAD", "FAILED"),
|
|
1682
1682
|
domain: ErrorDomain.STORAGE,
|
|
1683
1683
|
category: ErrorCategory.THIRD_PARTY,
|
|
1684
1684
|
details: {
|
|
@@ -1701,7 +1701,7 @@ ${columns}
|
|
|
1701
1701
|
await transaction.rollback();
|
|
1702
1702
|
throw new MastraError(
|
|
1703
1703
|
{
|
|
1704
|
-
id: "
|
|
1704
|
+
id: createStorageErrorId("MSSQL", "BATCH_INSERT", "FAILED"),
|
|
1705
1705
|
domain: ErrorDomain.STORAGE,
|
|
1706
1706
|
category: ErrorCategory.THIRD_PARTY,
|
|
1707
1707
|
details: {
|
|
@@ -1720,7 +1720,7 @@ ${columns}
|
|
|
1720
1720
|
} catch (error) {
|
|
1721
1721
|
throw new MastraError(
|
|
1722
1722
|
{
|
|
1723
|
-
id: "
|
|
1723
|
+
id: createStorageErrorId("MSSQL", "DROP_TABLE", "FAILED"),
|
|
1724
1724
|
domain: ErrorDomain.STORAGE,
|
|
1725
1725
|
category: ErrorCategory.THIRD_PARTY,
|
|
1726
1726
|
details: {
|
|
@@ -1806,7 +1806,7 @@ ${columns}
|
|
|
1806
1806
|
try {
|
|
1807
1807
|
if (!data || Object.keys(data).length === 0) {
|
|
1808
1808
|
throw new MastraError({
|
|
1809
|
-
id: "
|
|
1809
|
+
id: createStorageErrorId("MSSQL", "UPDATE", "EMPTY_DATA"),
|
|
1810
1810
|
domain: ErrorDomain.STORAGE,
|
|
1811
1811
|
category: ErrorCategory.USER,
|
|
1812
1812
|
text: "Cannot update with empty data payload"
|
|
@@ -1814,7 +1814,7 @@ ${columns}
|
|
|
1814
1814
|
}
|
|
1815
1815
|
if (!keys || Object.keys(keys).length === 0) {
|
|
1816
1816
|
throw new MastraError({
|
|
1817
|
-
id: "
|
|
1817
|
+
id: createStorageErrorId("MSSQL", "UPDATE", "EMPTY_KEYS"),
|
|
1818
1818
|
domain: ErrorDomain.STORAGE,
|
|
1819
1819
|
category: ErrorCategory.USER,
|
|
1820
1820
|
text: "Cannot update without keys to identify records"
|
|
@@ -1855,7 +1855,7 @@ ${columns}
|
|
|
1855
1855
|
} catch (error) {
|
|
1856
1856
|
throw new MastraError(
|
|
1857
1857
|
{
|
|
1858
|
-
id: "
|
|
1858
|
+
id: createStorageErrorId("MSSQL", "UPDATE", "FAILED"),
|
|
1859
1859
|
domain: ErrorDomain.STORAGE,
|
|
1860
1860
|
category: ErrorCategory.THIRD_PARTY,
|
|
1861
1861
|
details: {
|
|
@@ -1884,7 +1884,7 @@ ${columns}
|
|
|
1884
1884
|
await transaction.rollback();
|
|
1885
1885
|
throw new MastraError(
|
|
1886
1886
|
{
|
|
1887
|
-
id: "
|
|
1887
|
+
id: createStorageErrorId("MSSQL", "BATCH_UPDATE", "FAILED"),
|
|
1888
1888
|
domain: ErrorDomain.STORAGE,
|
|
1889
1889
|
category: ErrorCategory.THIRD_PARTY,
|
|
1890
1890
|
details: {
|
|
@@ -1933,7 +1933,7 @@ ${columns}
|
|
|
1933
1933
|
await transaction.rollback();
|
|
1934
1934
|
throw new MastraError(
|
|
1935
1935
|
{
|
|
1936
|
-
id: "
|
|
1936
|
+
id: createStorageErrorId("MSSQL", "BATCH_DELETE", "FAILED"),
|
|
1937
1937
|
domain: ErrorDomain.STORAGE,
|
|
1938
1938
|
category: ErrorCategory.THIRD_PARTY,
|
|
1939
1939
|
details: {
|
|
@@ -1990,7 +1990,7 @@ ${columns}
|
|
|
1990
1990
|
} catch (error) {
|
|
1991
1991
|
throw new MastraError(
|
|
1992
1992
|
{
|
|
1993
|
-
id: "
|
|
1993
|
+
id: createStorageErrorId("MSSQL", "INDEX_CREATE", "FAILED"),
|
|
1994
1994
|
domain: ErrorDomain.STORAGE,
|
|
1995
1995
|
category: ErrorCategory.THIRD_PARTY,
|
|
1996
1996
|
details: {
|
|
@@ -2026,7 +2026,7 @@ ${columns}
|
|
|
2026
2026
|
if (result.recordset.length > 1) {
|
|
2027
2027
|
const tables = result.recordset.map((r) => r.table_name).join(", ");
|
|
2028
2028
|
throw new MastraError({
|
|
2029
|
-
id: "
|
|
2029
|
+
id: createStorageErrorId("MSSQL", "INDEX", "AMBIGUOUS"),
|
|
2030
2030
|
domain: ErrorDomain.STORAGE,
|
|
2031
2031
|
category: ErrorCategory.USER,
|
|
2032
2032
|
text: `Index "${indexNameSafe}" exists on multiple tables (${tables}) in schema "${schemaName}". Please drop indexes manually or ensure unique index names.`
|
|
@@ -2042,7 +2042,7 @@ ${columns}
|
|
|
2042
2042
|
} catch (error) {
|
|
2043
2043
|
throw new MastraError(
|
|
2044
2044
|
{
|
|
2045
|
-
id: "
|
|
2045
|
+
id: createStorageErrorId("MSSQL", "INDEX_DROP", "FAILED"),
|
|
2046
2046
|
domain: ErrorDomain.STORAGE,
|
|
2047
2047
|
category: ErrorCategory.THIRD_PARTY,
|
|
2048
2048
|
details: {
|
|
@@ -2126,7 +2126,7 @@ ${columns}
|
|
|
2126
2126
|
} catch (error) {
|
|
2127
2127
|
throw new MastraError(
|
|
2128
2128
|
{
|
|
2129
|
-
id: "
|
|
2129
|
+
id: createStorageErrorId("MSSQL", "INDEX_LIST", "FAILED"),
|
|
2130
2130
|
domain: ErrorDomain.STORAGE,
|
|
2131
2131
|
category: ErrorCategory.THIRD_PARTY,
|
|
2132
2132
|
details: tableName ? {
|
|
@@ -2199,7 +2199,7 @@ ${columns}
|
|
|
2199
2199
|
} catch (error) {
|
|
2200
2200
|
throw new MastraError(
|
|
2201
2201
|
{
|
|
2202
|
-
id: "
|
|
2202
|
+
id: createStorageErrorId("MSSQL", "INDEX_DESCRIBE", "FAILED"),
|
|
2203
2203
|
domain: ErrorDomain.STORAGE,
|
|
2204
2204
|
category: ErrorCategory.THIRD_PARTY,
|
|
2205
2205
|
details: {
|
|
@@ -2280,7 +2280,7 @@ ${columns}
|
|
|
2280
2280
|
} catch (error) {
|
|
2281
2281
|
throw new MastraError(
|
|
2282
2282
|
{
|
|
2283
|
-
id: "
|
|
2283
|
+
id: createStorageErrorId("MSSQL", "CREATE_PERFORMANCE_INDEXES", "FAILED"),
|
|
2284
2284
|
domain: ErrorDomain.STORAGE,
|
|
2285
2285
|
category: ErrorCategory.THIRD_PARTY
|
|
2286
2286
|
},
|
|
@@ -2322,7 +2322,7 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
2322
2322
|
} catch (error) {
|
|
2323
2323
|
throw new MastraError(
|
|
2324
2324
|
{
|
|
2325
|
-
id: "
|
|
2325
|
+
id: createStorageErrorId("MSSQL", "GET_SCORE_BY_ID", "FAILED"),
|
|
2326
2326
|
domain: ErrorDomain.STORAGE,
|
|
2327
2327
|
category: ErrorCategory.THIRD_PARTY,
|
|
2328
2328
|
details: { id }
|
|
@@ -2338,15 +2338,23 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
2338
2338
|
} catch (error) {
|
|
2339
2339
|
throw new MastraError(
|
|
2340
2340
|
{
|
|
2341
|
-
id: "
|
|
2341
|
+
id: createStorageErrorId("MSSQL", "SAVE_SCORE", "VALIDATION_FAILED"),
|
|
2342
2342
|
domain: ErrorDomain.STORAGE,
|
|
2343
|
-
category: ErrorCategory.
|
|
2343
|
+
category: ErrorCategory.USER,
|
|
2344
|
+
details: {
|
|
2345
|
+
scorer: score.scorer?.id ?? "unknown",
|
|
2346
|
+
entityId: score.entityId ?? "unknown",
|
|
2347
|
+
entityType: score.entityType ?? "unknown",
|
|
2348
|
+
traceId: score.traceId ?? "",
|
|
2349
|
+
spanId: score.spanId ?? ""
|
|
2350
|
+
}
|
|
2344
2351
|
},
|
|
2345
2352
|
error
|
|
2346
2353
|
);
|
|
2347
2354
|
}
|
|
2348
2355
|
try {
|
|
2349
2356
|
const scoreId = randomUUID();
|
|
2357
|
+
const now = /* @__PURE__ */ new Date();
|
|
2350
2358
|
const {
|
|
2351
2359
|
scorer,
|
|
2352
2360
|
preprocessStepResult,
|
|
@@ -2373,16 +2381,15 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
2373
2381
|
requestContext: requestContext || null,
|
|
2374
2382
|
entity: entity || null,
|
|
2375
2383
|
scorer: scorer || null,
|
|
2376
|
-
createdAt:
|
|
2377
|
-
updatedAt:
|
|
2384
|
+
createdAt: now.toISOString(),
|
|
2385
|
+
updatedAt: now.toISOString()
|
|
2378
2386
|
}
|
|
2379
2387
|
});
|
|
2380
|
-
|
|
2381
|
-
return { score: scoreFromDb };
|
|
2388
|
+
return { score: { ...validatedScore, id: scoreId, createdAt: now, updatedAt: now } };
|
|
2382
2389
|
} catch (error) {
|
|
2383
2390
|
throw new MastraError(
|
|
2384
2391
|
{
|
|
2385
|
-
id: "
|
|
2392
|
+
id: createStorageErrorId("MSSQL", "SAVE_SCORE", "FAILED"),
|
|
2386
2393
|
domain: ErrorDomain.STORAGE,
|
|
2387
2394
|
category: ErrorCategory.THIRD_PARTY
|
|
2388
2395
|
},
|
|
@@ -2460,7 +2467,7 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
2460
2467
|
} catch (error) {
|
|
2461
2468
|
throw new MastraError(
|
|
2462
2469
|
{
|
|
2463
|
-
id: "
|
|
2470
|
+
id: createStorageErrorId("MSSQL", "LIST_SCORES_BY_SCORER_ID", "FAILED"),
|
|
2464
2471
|
domain: ErrorDomain.STORAGE,
|
|
2465
2472
|
category: ErrorCategory.THIRD_PARTY,
|
|
2466
2473
|
details: { scorerId }
|
|
@@ -2515,7 +2522,7 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
2515
2522
|
} catch (error) {
|
|
2516
2523
|
throw new MastraError(
|
|
2517
2524
|
{
|
|
2518
|
-
id: "
|
|
2525
|
+
id: createStorageErrorId("MSSQL", "LIST_SCORES_BY_RUN_ID", "FAILED"),
|
|
2519
2526
|
domain: ErrorDomain.STORAGE,
|
|
2520
2527
|
category: ErrorCategory.THIRD_PARTY,
|
|
2521
2528
|
details: { runId }
|
|
@@ -2573,7 +2580,7 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
2573
2580
|
} catch (error) {
|
|
2574
2581
|
throw new MastraError(
|
|
2575
2582
|
{
|
|
2576
|
-
id: "
|
|
2583
|
+
id: createStorageErrorId("MSSQL", "LIST_SCORES_BY_ENTITY_ID", "FAILED"),
|
|
2577
2584
|
domain: ErrorDomain.STORAGE,
|
|
2578
2585
|
category: ErrorCategory.THIRD_PARTY,
|
|
2579
2586
|
details: { entityId, entityType }
|
|
@@ -2631,7 +2638,7 @@ var ScoresMSSQL = class extends ScoresStorage {
|
|
|
2631
2638
|
} catch (error) {
|
|
2632
2639
|
throw new MastraError(
|
|
2633
2640
|
{
|
|
2634
|
-
id: "
|
|
2641
|
+
id: createStorageErrorId("MSSQL", "LIST_SCORES_BY_SPAN", "FAILED"),
|
|
2635
2642
|
domain: ErrorDomain.STORAGE,
|
|
2636
2643
|
category: ErrorCategory.THIRD_PARTY,
|
|
2637
2644
|
details: { traceId, spanId }
|
|
@@ -2735,7 +2742,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2735
2742
|
}
|
|
2736
2743
|
throw new MastraError(
|
|
2737
2744
|
{
|
|
2738
|
-
id: "
|
|
2745
|
+
id: createStorageErrorId("MSSQL", "UPDATE_WORKFLOW_RESULTS", "FAILED"),
|
|
2739
2746
|
domain: ErrorDomain.STORAGE,
|
|
2740
2747
|
category: ErrorCategory.THIRD_PARTY,
|
|
2741
2748
|
details: {
|
|
@@ -2773,7 +2780,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2773
2780
|
await transaction.rollback();
|
|
2774
2781
|
throw new MastraError(
|
|
2775
2782
|
{
|
|
2776
|
-
id: "
|
|
2783
|
+
id: createStorageErrorId("MSSQL", "UPDATE_WORKFLOW_STATE", "SNAPSHOT_NOT_FOUND"),
|
|
2777
2784
|
domain: ErrorDomain.STORAGE,
|
|
2778
2785
|
category: ErrorCategory.SYSTEM,
|
|
2779
2786
|
details: {
|
|
@@ -2800,9 +2807,10 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2800
2807
|
await transaction.rollback();
|
|
2801
2808
|
} catch {
|
|
2802
2809
|
}
|
|
2810
|
+
if (error instanceof MastraError) throw error;
|
|
2803
2811
|
throw new MastraError(
|
|
2804
2812
|
{
|
|
2805
|
-
id: "
|
|
2813
|
+
id: createStorageErrorId("MSSQL", "UPDATE_WORKFLOW_STATE", "FAILED"),
|
|
2806
2814
|
domain: ErrorDomain.STORAGE,
|
|
2807
2815
|
category: ErrorCategory.THIRD_PARTY,
|
|
2808
2816
|
details: {
|
|
@@ -2843,7 +2851,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2843
2851
|
} catch (error) {
|
|
2844
2852
|
throw new MastraError(
|
|
2845
2853
|
{
|
|
2846
|
-
id: "
|
|
2854
|
+
id: createStorageErrorId("MSSQL", "PERSIST_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
2847
2855
|
domain: ErrorDomain.STORAGE,
|
|
2848
2856
|
category: ErrorCategory.THIRD_PARTY,
|
|
2849
2857
|
details: {
|
|
@@ -2874,7 +2882,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2874
2882
|
} catch (error) {
|
|
2875
2883
|
throw new MastraError(
|
|
2876
2884
|
{
|
|
2877
|
-
id: "
|
|
2885
|
+
id: createStorageErrorId("MSSQL", "LOAD_WORKFLOW_SNAPSHOT", "FAILED"),
|
|
2878
2886
|
domain: ErrorDomain.STORAGE,
|
|
2879
2887
|
category: ErrorCategory.THIRD_PARTY,
|
|
2880
2888
|
details: {
|
|
@@ -2914,7 +2922,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2914
2922
|
} catch (error) {
|
|
2915
2923
|
throw new MastraError(
|
|
2916
2924
|
{
|
|
2917
|
-
id: "
|
|
2925
|
+
id: createStorageErrorId("MSSQL", "GET_WORKFLOW_RUN_BY_ID", "FAILED"),
|
|
2918
2926
|
domain: ErrorDomain.STORAGE,
|
|
2919
2927
|
category: ErrorCategory.THIRD_PARTY,
|
|
2920
2928
|
details: {
|
|
@@ -2994,7 +3002,7 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2994
3002
|
} catch (error) {
|
|
2995
3003
|
throw new MastraError(
|
|
2996
3004
|
{
|
|
2997
|
-
id: "
|
|
3005
|
+
id: createStorageErrorId("MSSQL", "LIST_WORKFLOW_RUNS", "FAILED"),
|
|
2998
3006
|
domain: ErrorDomain.STORAGE,
|
|
2999
3007
|
category: ErrorCategory.THIRD_PARTY,
|
|
3000
3008
|
details: {
|
|
@@ -3017,7 +3025,7 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3017
3025
|
if (!config.id || typeof config.id !== "string" || config.id.trim() === "") {
|
|
3018
3026
|
throw new Error("MSSQLStore: id must be provided and cannot be empty.");
|
|
3019
3027
|
}
|
|
3020
|
-
super({ id: config.id, name: "MSSQLStore" });
|
|
3028
|
+
super({ id: config.id, name: "MSSQLStore", disableInit: config.disableInit });
|
|
3021
3029
|
try {
|
|
3022
3030
|
if ("connectionString" in config) {
|
|
3023
3031
|
if (!config.connectionString || typeof config.connectionString !== "string" || config.connectionString.trim() === "") {
|
|
@@ -3055,7 +3063,7 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3055
3063
|
} catch (e) {
|
|
3056
3064
|
throw new MastraError(
|
|
3057
3065
|
{
|
|
3058
|
-
id: "
|
|
3066
|
+
id: createStorageErrorId("MSSQL", "INITIALIZATION", "FAILED"),
|
|
3059
3067
|
domain: ErrorDomain.STORAGE,
|
|
3060
3068
|
category: ErrorCategory.USER
|
|
3061
3069
|
},
|
|
@@ -3079,7 +3087,7 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3079
3087
|
this.isConnected = null;
|
|
3080
3088
|
throw new MastraError(
|
|
3081
3089
|
{
|
|
3082
|
-
id: "
|
|
3090
|
+
id: createStorageErrorId("MSSQL", "INIT", "FAILED"),
|
|
3083
3091
|
domain: ErrorDomain.STORAGE,
|
|
3084
3092
|
category: ErrorCategory.THIRD_PARTY
|
|
3085
3093
|
},
|
|
@@ -3247,7 +3255,7 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3247
3255
|
getObservabilityStore() {
|
|
3248
3256
|
if (!this.stores.observability) {
|
|
3249
3257
|
throw new MastraError({
|
|
3250
|
-
id: "
|
|
3258
|
+
id: createStorageErrorId("MSSQL", "OBSERVABILITY", "NOT_INITIALIZED"),
|
|
3251
3259
|
domain: ErrorDomain.STORAGE,
|
|
3252
3260
|
category: ErrorCategory.SYSTEM,
|
|
3253
3261
|
text: "Observability storage is not initialized"
|
|
@@ -3301,8 +3309,8 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3301
3309
|
source: _source
|
|
3302
3310
|
});
|
|
3303
3311
|
}
|
|
3304
|
-
async saveScore(
|
|
3305
|
-
return this.stores.scores.saveScore(
|
|
3312
|
+
async saveScore(score) {
|
|
3313
|
+
return this.stores.scores.saveScore(score);
|
|
3306
3314
|
}
|
|
3307
3315
|
async listScoresByRunId({
|
|
3308
3316
|
runId: _runId,
|