@mastra/mssql 0.0.0-fix-thread-list-20251105222841 → 0.0.0-fix-ai-sdk-dependency-20251124104209
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 +298 -4
- package/README.md +18 -9
- package/dist/index.cjs +139 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +140 -91
- 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 +4 -4
- 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/workflows/index.d.ts +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +6 -5
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +9 -7
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,
|
|
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, safelyParseJSON } 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';
|
|
@@ -150,6 +150,18 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
150
150
|
}
|
|
151
151
|
async listThreadsByResourceId(args) {
|
|
152
152
|
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
153
|
+
if (page < 0) {
|
|
154
|
+
throw new MastraError({
|
|
155
|
+
id: "MASTRA_STORAGE_MSSQL_STORE_INVALID_PAGE",
|
|
156
|
+
domain: ErrorDomain.STORAGE,
|
|
157
|
+
category: ErrorCategory.USER,
|
|
158
|
+
text: "Page number must be non-negative",
|
|
159
|
+
details: {
|
|
160
|
+
resourceId,
|
|
161
|
+
page
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
153
165
|
const perPage = normalizePerPage(perPageInput, 100);
|
|
154
166
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
155
167
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
@@ -505,43 +517,59 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
505
517
|
new Error("threadId must be a non-empty string")
|
|
506
518
|
);
|
|
507
519
|
}
|
|
520
|
+
if (page < 0) {
|
|
521
|
+
throw new MastraError({
|
|
522
|
+
id: "MASTRA_STORAGE_MSSQL_STORE_INVALID_PAGE",
|
|
523
|
+
domain: ErrorDomain.STORAGE,
|
|
524
|
+
category: ErrorCategory.USER,
|
|
525
|
+
text: "Page number must be non-negative",
|
|
526
|
+
details: {
|
|
527
|
+
threadId,
|
|
528
|
+
page
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
508
532
|
const perPage = normalizePerPage(perPageInput, 40);
|
|
509
533
|
const { offset, perPage: perPageForResponse } = calculatePagination(page, perPageInput, perPage);
|
|
510
534
|
try {
|
|
511
535
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
512
|
-
const orderByStatement = `ORDER BY [${field}] ${direction}`;
|
|
513
|
-
const selectStatement = `SELECT seq_id, id, content, role, type, [createdAt], thread_id AS threadId, resourceId`;
|
|
536
|
+
const orderByStatement = `ORDER BY [${field}] ${direction}, [seq_id] ${direction}`;
|
|
514
537
|
const tableName = getTableName({ indexName: TABLE_MESSAGES, schemaName: getSchemaName(this.schema) });
|
|
515
|
-
const
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
530
|
-
const whereClause = `WHERE ${conditions.join(" AND ")}`;
|
|
531
|
-
const countQuery = `SELECT COUNT(*) as total FROM ${tableName} ${whereClause}`;
|
|
532
|
-
const countResult = await request.query(countQuery);
|
|
538
|
+
const baseQuery = `SELECT seq_id, id, content, role, type, [createdAt], thread_id AS threadId, resourceId FROM ${tableName}`;
|
|
539
|
+
const filters = {
|
|
540
|
+
thread_id: threadId,
|
|
541
|
+
...resourceId ? { resourceId } : {},
|
|
542
|
+
...buildDateRangeFilter(filter?.dateRange, "createdAt")
|
|
543
|
+
};
|
|
544
|
+
const { sql: actualWhereClause = "", params: whereParams } = prepareWhereClause(
|
|
545
|
+
filters);
|
|
546
|
+
const bindWhereParams = (req) => {
|
|
547
|
+
Object.entries(whereParams).forEach(([paramName, paramValue]) => req.input(paramName, paramValue));
|
|
548
|
+
};
|
|
549
|
+
const countRequest = this.pool.request();
|
|
550
|
+
bindWhereParams(countRequest);
|
|
551
|
+
const countResult = await countRequest.query(`SELECT COUNT(*) as total FROM ${tableName}${actualWhereClause}`);
|
|
533
552
|
const total = parseInt(countResult.recordset[0]?.total, 10) || 0;
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
553
|
+
const fetchBaseMessages = async () => {
|
|
554
|
+
const request = this.pool.request();
|
|
555
|
+
bindWhereParams(request);
|
|
556
|
+
if (perPageInput === false) {
|
|
557
|
+
const result2 = await request.query(`${baseQuery}${actualWhereClause} ${orderByStatement}`);
|
|
558
|
+
return result2.recordset || [];
|
|
559
|
+
}
|
|
560
|
+
request.input("offset", offset);
|
|
561
|
+
request.input("limit", perPage > 2147483647 ? sql2.BigInt : sql2.Int, perPage);
|
|
562
|
+
const result = await request.query(
|
|
563
|
+
`${baseQuery}${actualWhereClause} ${orderByStatement} OFFSET @offset ROWS FETCH NEXT @limit ROWS ONLY`
|
|
564
|
+
);
|
|
565
|
+
return result.recordset || [];
|
|
566
|
+
};
|
|
567
|
+
const baseRows = perPage === 0 ? [] : await fetchBaseMessages();
|
|
568
|
+
const messages = [...baseRows];
|
|
569
|
+
const seqById = /* @__PURE__ */ new Map();
|
|
570
|
+
messages.forEach((msg) => {
|
|
571
|
+
if (typeof msg.seq_id === "number") seqById.set(msg.id, msg.seq_id);
|
|
572
|
+
});
|
|
545
573
|
if (total === 0 && messages.length === 0 && (!include || include.length === 0)) {
|
|
546
574
|
return {
|
|
547
575
|
messages: [],
|
|
@@ -551,28 +579,33 @@ var MemoryMSSQL = class extends MemoryStorage {
|
|
|
551
579
|
hasMore: false
|
|
552
580
|
};
|
|
553
581
|
}
|
|
554
|
-
|
|
555
|
-
|
|
582
|
+
if (include?.length) {
|
|
583
|
+
const messageIds = new Set(messages.map((m) => m.id));
|
|
556
584
|
const includeMessages = await this._getIncludedMessages({ threadId, include });
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
}
|
|
585
|
+
includeMessages?.forEach((msg) => {
|
|
586
|
+
if (!messageIds.has(msg.id)) {
|
|
587
|
+
messages.push(msg);
|
|
588
|
+
messageIds.add(msg.id);
|
|
589
|
+
if (typeof msg.seq_id === "number") seqById.set(msg.id, msg.seq_id);
|
|
563
590
|
}
|
|
564
|
-
}
|
|
591
|
+
});
|
|
565
592
|
}
|
|
566
593
|
const parsed = this._parseAndFormatMessages(messages, "v2");
|
|
567
|
-
|
|
568
|
-
finalMessages =
|
|
569
|
-
const
|
|
570
|
-
const
|
|
571
|
-
|
|
594
|
+
const mult = direction === "ASC" ? 1 : -1;
|
|
595
|
+
const finalMessages = parsed.sort((a, b) => {
|
|
596
|
+
const aVal = field === "createdAt" ? new Date(a.createdAt).getTime() : a[field];
|
|
597
|
+
const bVal = field === "createdAt" ? new Date(b.createdAt).getTime() : b[field];
|
|
598
|
+
if (aVal == null || bVal == null) {
|
|
599
|
+
return aVal == null && bVal == null ? a.id.localeCompare(b.id) : aVal == null ? 1 : -1;
|
|
600
|
+
}
|
|
601
|
+
const diff = (typeof aVal === "number" && typeof bVal === "number" ? aVal - bVal : String(aVal).localeCompare(String(bVal))) * mult;
|
|
602
|
+
if (diff !== 0) return diff;
|
|
603
|
+
const seqA = seqById.get(a.id);
|
|
604
|
+
const seqB = seqById.get(b.id);
|
|
605
|
+
return seqA != null && seqB != null ? (seqA - seqB) * mult : a.id.localeCompare(b.id);
|
|
572
606
|
});
|
|
573
|
-
const
|
|
574
|
-
const
|
|
575
|
-
const hasMore = perPageInput !== false && !allThreadMessagesReturned && offset + perPage < total;
|
|
607
|
+
const returnedThreadMessageCount = finalMessages.filter((m) => m.threadId === threadId).length;
|
|
608
|
+
const hasMore = perPageInput !== false && returnedThreadMessageCount < total && offset + perPage < total;
|
|
576
609
|
return {
|
|
577
610
|
messages: finalMessages,
|
|
578
611
|
total,
|
|
@@ -982,11 +1015,11 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
982
1015
|
endedAt
|
|
983
1016
|
// Note: createdAt/updatedAt will be set by default values
|
|
984
1017
|
};
|
|
985
|
-
return this.operations.insert({ tableName:
|
|
1018
|
+
return this.operations.insert({ tableName: TABLE_SPANS, record });
|
|
986
1019
|
} catch (error) {
|
|
987
1020
|
throw new MastraError(
|
|
988
1021
|
{
|
|
989
|
-
id: "
|
|
1022
|
+
id: "MSSQL_STORE_CREATE_SPAN_FAILED",
|
|
990
1023
|
domain: ErrorDomain.STORAGE,
|
|
991
1024
|
category: ErrorCategory.USER,
|
|
992
1025
|
details: {
|
|
@@ -1000,10 +1033,10 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1000
1033
|
);
|
|
1001
1034
|
}
|
|
1002
1035
|
}
|
|
1003
|
-
async
|
|
1036
|
+
async getTrace(traceId) {
|
|
1004
1037
|
try {
|
|
1005
1038
|
const tableName = getTableName({
|
|
1006
|
-
indexName:
|
|
1039
|
+
indexName: TABLE_SPANS,
|
|
1007
1040
|
schemaName: getSchemaName(this.schema)
|
|
1008
1041
|
});
|
|
1009
1042
|
const request = this.pool.request();
|
|
@@ -1024,7 +1057,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1024
1057
|
traceId,
|
|
1025
1058
|
spans: result.recordset.map(
|
|
1026
1059
|
(span) => transformFromSqlRow({
|
|
1027
|
-
tableName:
|
|
1060
|
+
tableName: TABLE_SPANS,
|
|
1028
1061
|
sqlRow: span
|
|
1029
1062
|
})
|
|
1030
1063
|
)
|
|
@@ -1032,7 +1065,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1032
1065
|
} catch (error) {
|
|
1033
1066
|
throw new MastraError(
|
|
1034
1067
|
{
|
|
1035
|
-
id: "
|
|
1068
|
+
id: "MSSQL_STORE_GET_TRACE_FAILED",
|
|
1036
1069
|
domain: ErrorDomain.STORAGE,
|
|
1037
1070
|
category: ErrorCategory.USER,
|
|
1038
1071
|
details: {
|
|
@@ -1057,14 +1090,14 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1057
1090
|
data.startedAt = data.startedAt.toISOString();
|
|
1058
1091
|
}
|
|
1059
1092
|
await this.operations.update({
|
|
1060
|
-
tableName:
|
|
1093
|
+
tableName: TABLE_SPANS,
|
|
1061
1094
|
keys: { spanId, traceId },
|
|
1062
1095
|
data
|
|
1063
1096
|
});
|
|
1064
1097
|
} catch (error) {
|
|
1065
1098
|
throw new MastraError(
|
|
1066
1099
|
{
|
|
1067
|
-
id: "
|
|
1100
|
+
id: "MSSQL_STORE_UPDATE_SPAN_FAILED",
|
|
1068
1101
|
domain: ErrorDomain.STORAGE,
|
|
1069
1102
|
category: ErrorCategory.USER,
|
|
1070
1103
|
details: {
|
|
@@ -1076,7 +1109,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1076
1109
|
);
|
|
1077
1110
|
}
|
|
1078
1111
|
}
|
|
1079
|
-
async
|
|
1112
|
+
async getTracesPaginated({
|
|
1080
1113
|
filters,
|
|
1081
1114
|
pagination
|
|
1082
1115
|
}) {
|
|
@@ -1101,7 +1134,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1101
1134
|
name = `agent run: '${entityId}'`;
|
|
1102
1135
|
} else {
|
|
1103
1136
|
const error = new MastraError({
|
|
1104
|
-
id: "
|
|
1137
|
+
id: "MSSQL_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1105
1138
|
domain: ErrorDomain.STORAGE,
|
|
1106
1139
|
category: ErrorCategory.USER,
|
|
1107
1140
|
details: {
|
|
@@ -1120,7 +1153,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1120
1153
|
params[entityParam] = name;
|
|
1121
1154
|
}
|
|
1122
1155
|
const tableName = getTableName({
|
|
1123
|
-
indexName:
|
|
1156
|
+
indexName: TABLE_SPANS,
|
|
1124
1157
|
schemaName: getSchemaName(this.schema)
|
|
1125
1158
|
});
|
|
1126
1159
|
try {
|
|
@@ -1154,7 +1187,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1154
1187
|
);
|
|
1155
1188
|
const spans = dataResult.recordset.map(
|
|
1156
1189
|
(row) => transformFromSqlRow({
|
|
1157
|
-
tableName:
|
|
1190
|
+
tableName: TABLE_SPANS,
|
|
1158
1191
|
sqlRow: row
|
|
1159
1192
|
})
|
|
1160
1193
|
);
|
|
@@ -1170,7 +1203,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1170
1203
|
} catch (error) {
|
|
1171
1204
|
throw new MastraError(
|
|
1172
1205
|
{
|
|
1173
|
-
id: "
|
|
1206
|
+
id: "MSSQL_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1174
1207
|
domain: ErrorDomain.STORAGE,
|
|
1175
1208
|
category: ErrorCategory.USER
|
|
1176
1209
|
},
|
|
@@ -1184,7 +1217,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1184
1217
|
}
|
|
1185
1218
|
try {
|
|
1186
1219
|
await this.operations.batchInsert({
|
|
1187
|
-
tableName:
|
|
1220
|
+
tableName: TABLE_SPANS,
|
|
1188
1221
|
records: args.records.map((span) => ({
|
|
1189
1222
|
...span,
|
|
1190
1223
|
startedAt: span.startedAt instanceof Date ? span.startedAt.toISOString() : span.startedAt,
|
|
@@ -1194,7 +1227,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1194
1227
|
} catch (error) {
|
|
1195
1228
|
throw new MastraError(
|
|
1196
1229
|
{
|
|
1197
|
-
id: "
|
|
1230
|
+
id: "MSSQL_STORE_BATCH_CREATE_SPANS_FAILED",
|
|
1198
1231
|
domain: ErrorDomain.STORAGE,
|
|
1199
1232
|
category: ErrorCategory.USER,
|
|
1200
1233
|
details: {
|
|
@@ -1224,13 +1257,13 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1224
1257
|
};
|
|
1225
1258
|
});
|
|
1226
1259
|
await this.operations.batchUpdate({
|
|
1227
|
-
tableName:
|
|
1260
|
+
tableName: TABLE_SPANS,
|
|
1228
1261
|
updates
|
|
1229
1262
|
});
|
|
1230
1263
|
} catch (error) {
|
|
1231
1264
|
throw new MastraError(
|
|
1232
1265
|
{
|
|
1233
|
-
id: "
|
|
1266
|
+
id: "MSSQL_STORE_BATCH_UPDATE_SPANS_FAILED",
|
|
1234
1267
|
domain: ErrorDomain.STORAGE,
|
|
1235
1268
|
category: ErrorCategory.USER,
|
|
1236
1269
|
details: {
|
|
@@ -1241,20 +1274,20 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1241
1274
|
);
|
|
1242
1275
|
}
|
|
1243
1276
|
}
|
|
1244
|
-
async
|
|
1277
|
+
async batchDeleteTraces(args) {
|
|
1245
1278
|
if (!args.traceIds || args.traceIds.length === 0) {
|
|
1246
1279
|
return;
|
|
1247
1280
|
}
|
|
1248
1281
|
try {
|
|
1249
1282
|
const keys = args.traceIds.map((traceId) => ({ traceId }));
|
|
1250
1283
|
await this.operations.batchDelete({
|
|
1251
|
-
tableName:
|
|
1284
|
+
tableName: TABLE_SPANS,
|
|
1252
1285
|
keys
|
|
1253
1286
|
});
|
|
1254
1287
|
} catch (error) {
|
|
1255
1288
|
throw new MastraError(
|
|
1256
1289
|
{
|
|
1257
|
-
id: "
|
|
1290
|
+
id: "MSSQL_STORE_BATCH_DELETE_TRACES_FAILED",
|
|
1258
1291
|
domain: ErrorDomain.STORAGE,
|
|
1259
1292
|
category: ErrorCategory.USER,
|
|
1260
1293
|
details: {
|
|
@@ -1679,6 +1712,20 @@ ${columns}
|
|
|
1679
1712
|
return value ? 1 : 0;
|
|
1680
1713
|
}
|
|
1681
1714
|
if (columnSchema?.type === "jsonb") {
|
|
1715
|
+
if (typeof value === "string") {
|
|
1716
|
+
const trimmed = value.trim();
|
|
1717
|
+
if (trimmed.length > 0) {
|
|
1718
|
+
try {
|
|
1719
|
+
JSON.parse(trimmed);
|
|
1720
|
+
return trimmed;
|
|
1721
|
+
} catch {
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
return JSON.stringify(value);
|
|
1725
|
+
}
|
|
1726
|
+
if (typeof value === "bigint") {
|
|
1727
|
+
return value.toString();
|
|
1728
|
+
}
|
|
1682
1729
|
return JSON.stringify(value);
|
|
1683
1730
|
}
|
|
1684
1731
|
if (typeof value === "object") {
|
|
@@ -2161,22 +2208,22 @@ ${columns}
|
|
|
2161
2208
|
// Spans indexes for optimal trace querying
|
|
2162
2209
|
{
|
|
2163
2210
|
name: `${schemaPrefix}mastra_ai_spans_traceid_startedat_idx`,
|
|
2164
|
-
table:
|
|
2211
|
+
table: TABLE_SPANS,
|
|
2165
2212
|
columns: ["traceId", "startedAt DESC"]
|
|
2166
2213
|
},
|
|
2167
2214
|
{
|
|
2168
2215
|
name: `${schemaPrefix}mastra_ai_spans_parentspanid_startedat_idx`,
|
|
2169
|
-
table:
|
|
2216
|
+
table: TABLE_SPANS,
|
|
2170
2217
|
columns: ["parentSpanId", "startedAt DESC"]
|
|
2171
2218
|
},
|
|
2172
2219
|
{
|
|
2173
2220
|
name: `${schemaPrefix}mastra_ai_spans_name_idx`,
|
|
2174
|
-
table:
|
|
2221
|
+
table: TABLE_SPANS,
|
|
2175
2222
|
columns: ["name"]
|
|
2176
2223
|
},
|
|
2177
2224
|
{
|
|
2178
2225
|
name: `${schemaPrefix}mastra_ai_spans_spantype_startedat_idx`,
|
|
2179
|
-
table:
|
|
2226
|
+
table: TABLE_SPANS,
|
|
2180
2227
|
columns: ["spanType", "startedAt DESC"]
|
|
2181
2228
|
}
|
|
2182
2229
|
];
|
|
@@ -2624,13 +2671,14 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2624
2671
|
snapshot = {
|
|
2625
2672
|
context: {},
|
|
2626
2673
|
activePaths: [],
|
|
2674
|
+
activeStepsPath: {},
|
|
2627
2675
|
timestamp: Date.now(),
|
|
2628
2676
|
suspendedPaths: {},
|
|
2629
2677
|
resumeLabels: {},
|
|
2630
2678
|
serializedStepGraph: [],
|
|
2679
|
+
status: "pending",
|
|
2631
2680
|
value: {},
|
|
2632
2681
|
waitingPaths: {},
|
|
2633
|
-
status: "pending",
|
|
2634
2682
|
runId,
|
|
2635
2683
|
requestContext: {}
|
|
2636
2684
|
};
|
|
@@ -2860,7 +2908,8 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2860
2908
|
toDate,
|
|
2861
2909
|
page,
|
|
2862
2910
|
perPage,
|
|
2863
|
-
resourceId
|
|
2911
|
+
resourceId,
|
|
2912
|
+
status
|
|
2864
2913
|
} = {}) {
|
|
2865
2914
|
try {
|
|
2866
2915
|
const conditions = [];
|
|
@@ -2869,6 +2918,10 @@ var WorkflowsMSSQL = class extends WorkflowsStorage {
|
|
|
2869
2918
|
conditions.push(`[workflow_name] = @workflowName`);
|
|
2870
2919
|
paramMap["workflowName"] = workflowName;
|
|
2871
2920
|
}
|
|
2921
|
+
if (status) {
|
|
2922
|
+
conditions.push(`JSON_VALUE([snapshot], '$.status') = @status`);
|
|
2923
|
+
paramMap["status"] = status;
|
|
2924
|
+
}
|
|
2872
2925
|
if (resourceId) {
|
|
2873
2926
|
const hasResourceId = await this.operations.hasColumn(TABLE_WORKFLOW_SNAPSHOT, "resourceId");
|
|
2874
2927
|
if (hasResourceId) {
|
|
@@ -2937,7 +2990,10 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
2937
2990
|
isConnected = null;
|
|
2938
2991
|
stores;
|
|
2939
2992
|
constructor(config) {
|
|
2940
|
-
|
|
2993
|
+
if (!config.id || typeof config.id !== "string" || config.id.trim() === "") {
|
|
2994
|
+
throw new Error("MSSQLStore: id must be provided and cannot be empty.");
|
|
2995
|
+
}
|
|
2996
|
+
super({ id: config.id, name: "MSSQLStore" });
|
|
2941
2997
|
try {
|
|
2942
2998
|
if ("connectionString" in config) {
|
|
2943
2999
|
if (!config.connectionString || typeof config.connectionString !== "string" || config.connectionString.trim() === "") {
|
|
@@ -3134,15 +3190,8 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3134
3190
|
}) {
|
|
3135
3191
|
return this.stores.workflows.loadWorkflowSnapshot({ workflowName, runId });
|
|
3136
3192
|
}
|
|
3137
|
-
async listWorkflowRuns({
|
|
3138
|
-
|
|
3139
|
-
fromDate,
|
|
3140
|
-
toDate,
|
|
3141
|
-
perPage,
|
|
3142
|
-
page,
|
|
3143
|
-
resourceId
|
|
3144
|
-
} = {}) {
|
|
3145
|
-
return this.stores.workflows.listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId });
|
|
3193
|
+
async listWorkflowRuns(args = {}) {
|
|
3194
|
+
return this.stores.workflows.listWorkflowRuns(args);
|
|
3146
3195
|
}
|
|
3147
3196
|
async getWorkflowRunById({
|
|
3148
3197
|
runId,
|
|
@@ -3192,11 +3241,11 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3192
3241
|
}) {
|
|
3193
3242
|
return this.getObservabilityStore().updateSpan({ spanId, traceId, updates });
|
|
3194
3243
|
}
|
|
3195
|
-
async
|
|
3196
|
-
return this.getObservabilityStore().
|
|
3244
|
+
async getTrace(traceId) {
|
|
3245
|
+
return this.getObservabilityStore().getTrace(traceId);
|
|
3197
3246
|
}
|
|
3198
|
-
async
|
|
3199
|
-
return this.getObservabilityStore().
|
|
3247
|
+
async getTracesPaginated(args) {
|
|
3248
|
+
return this.getObservabilityStore().getTracesPaginated(args);
|
|
3200
3249
|
}
|
|
3201
3250
|
async batchCreateSpans(args) {
|
|
3202
3251
|
return this.getObservabilityStore().batchCreateSpans(args);
|
|
@@ -3204,8 +3253,8 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3204
3253
|
async batchUpdateSpans(args) {
|
|
3205
3254
|
return this.getObservabilityStore().batchUpdateSpans(args);
|
|
3206
3255
|
}
|
|
3207
|
-
async
|
|
3208
|
-
return this.getObservabilityStore().
|
|
3256
|
+
async batchDeleteTraces(args) {
|
|
3257
|
+
return this.getObservabilityStore().batchDeleteTraces(args);
|
|
3209
3258
|
}
|
|
3210
3259
|
/**
|
|
3211
3260
|
* Scorers
|