@mastra/mssql 0.0.0-main-test-20251105183450 → 0.0.0-main-test-05-11-2025-2-20251105223343
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 +6 -4
- package/README.md +9 -9
- package/dist/index.cjs +30 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +31 -31
- package/dist/index.js.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/index.d.ts +4 -4
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +6 -6
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';
|
|
@@ -982,11 +982,11 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
982
982
|
endedAt
|
|
983
983
|
// Note: createdAt/updatedAt will be set by default values
|
|
984
984
|
};
|
|
985
|
-
return this.operations.insert({ tableName:
|
|
985
|
+
return this.operations.insert({ tableName: TABLE_SPANS, record });
|
|
986
986
|
} catch (error) {
|
|
987
987
|
throw new MastraError(
|
|
988
988
|
{
|
|
989
|
-
id: "
|
|
989
|
+
id: "MSSQL_STORE_CREATE_SPAN_FAILED",
|
|
990
990
|
domain: ErrorDomain.STORAGE,
|
|
991
991
|
category: ErrorCategory.USER,
|
|
992
992
|
details: {
|
|
@@ -1000,10 +1000,10 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1000
1000
|
);
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
async
|
|
1003
|
+
async getTrace(traceId) {
|
|
1004
1004
|
try {
|
|
1005
1005
|
const tableName = getTableName({
|
|
1006
|
-
indexName:
|
|
1006
|
+
indexName: TABLE_SPANS,
|
|
1007
1007
|
schemaName: getSchemaName(this.schema)
|
|
1008
1008
|
});
|
|
1009
1009
|
const request = this.pool.request();
|
|
@@ -1024,7 +1024,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1024
1024
|
traceId,
|
|
1025
1025
|
spans: result.recordset.map(
|
|
1026
1026
|
(span) => transformFromSqlRow({
|
|
1027
|
-
tableName:
|
|
1027
|
+
tableName: TABLE_SPANS,
|
|
1028
1028
|
sqlRow: span
|
|
1029
1029
|
})
|
|
1030
1030
|
)
|
|
@@ -1032,7 +1032,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1032
1032
|
} catch (error) {
|
|
1033
1033
|
throw new MastraError(
|
|
1034
1034
|
{
|
|
1035
|
-
id: "
|
|
1035
|
+
id: "MSSQL_STORE_GET_TRACE_FAILED",
|
|
1036
1036
|
domain: ErrorDomain.STORAGE,
|
|
1037
1037
|
category: ErrorCategory.USER,
|
|
1038
1038
|
details: {
|
|
@@ -1057,14 +1057,14 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1057
1057
|
data.startedAt = data.startedAt.toISOString();
|
|
1058
1058
|
}
|
|
1059
1059
|
await this.operations.update({
|
|
1060
|
-
tableName:
|
|
1060
|
+
tableName: TABLE_SPANS,
|
|
1061
1061
|
keys: { spanId, traceId },
|
|
1062
1062
|
data
|
|
1063
1063
|
});
|
|
1064
1064
|
} catch (error) {
|
|
1065
1065
|
throw new MastraError(
|
|
1066
1066
|
{
|
|
1067
|
-
id: "
|
|
1067
|
+
id: "MSSQL_STORE_UPDATE_SPAN_FAILED",
|
|
1068
1068
|
domain: ErrorDomain.STORAGE,
|
|
1069
1069
|
category: ErrorCategory.USER,
|
|
1070
1070
|
details: {
|
|
@@ -1076,7 +1076,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1076
1076
|
);
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
|
-
async
|
|
1079
|
+
async getTracesPaginated({
|
|
1080
1080
|
filters,
|
|
1081
1081
|
pagination
|
|
1082
1082
|
}) {
|
|
@@ -1101,7 +1101,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1101
1101
|
name = `agent run: '${entityId}'`;
|
|
1102
1102
|
} else {
|
|
1103
1103
|
const error = new MastraError({
|
|
1104
|
-
id: "
|
|
1104
|
+
id: "MSSQL_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1105
1105
|
domain: ErrorDomain.STORAGE,
|
|
1106
1106
|
category: ErrorCategory.USER,
|
|
1107
1107
|
details: {
|
|
@@ -1120,7 +1120,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1120
1120
|
params[entityParam] = name;
|
|
1121
1121
|
}
|
|
1122
1122
|
const tableName = getTableName({
|
|
1123
|
-
indexName:
|
|
1123
|
+
indexName: TABLE_SPANS,
|
|
1124
1124
|
schemaName: getSchemaName(this.schema)
|
|
1125
1125
|
});
|
|
1126
1126
|
try {
|
|
@@ -1154,7 +1154,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1154
1154
|
);
|
|
1155
1155
|
const spans = dataResult.recordset.map(
|
|
1156
1156
|
(row) => transformFromSqlRow({
|
|
1157
|
-
tableName:
|
|
1157
|
+
tableName: TABLE_SPANS,
|
|
1158
1158
|
sqlRow: row
|
|
1159
1159
|
})
|
|
1160
1160
|
);
|
|
@@ -1170,7 +1170,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1170
1170
|
} catch (error) {
|
|
1171
1171
|
throw new MastraError(
|
|
1172
1172
|
{
|
|
1173
|
-
id: "
|
|
1173
|
+
id: "MSSQL_STORE_GET_TRACES_PAGINATED_FAILED",
|
|
1174
1174
|
domain: ErrorDomain.STORAGE,
|
|
1175
1175
|
category: ErrorCategory.USER
|
|
1176
1176
|
},
|
|
@@ -1184,7 +1184,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1184
1184
|
}
|
|
1185
1185
|
try {
|
|
1186
1186
|
await this.operations.batchInsert({
|
|
1187
|
-
tableName:
|
|
1187
|
+
tableName: TABLE_SPANS,
|
|
1188
1188
|
records: args.records.map((span) => ({
|
|
1189
1189
|
...span,
|
|
1190
1190
|
startedAt: span.startedAt instanceof Date ? span.startedAt.toISOString() : span.startedAt,
|
|
@@ -1194,7 +1194,7 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1194
1194
|
} catch (error) {
|
|
1195
1195
|
throw new MastraError(
|
|
1196
1196
|
{
|
|
1197
|
-
id: "
|
|
1197
|
+
id: "MSSQL_STORE_BATCH_CREATE_SPANS_FAILED",
|
|
1198
1198
|
domain: ErrorDomain.STORAGE,
|
|
1199
1199
|
category: ErrorCategory.USER,
|
|
1200
1200
|
details: {
|
|
@@ -1224,13 +1224,13 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1224
1224
|
};
|
|
1225
1225
|
});
|
|
1226
1226
|
await this.operations.batchUpdate({
|
|
1227
|
-
tableName:
|
|
1227
|
+
tableName: TABLE_SPANS,
|
|
1228
1228
|
updates
|
|
1229
1229
|
});
|
|
1230
1230
|
} catch (error) {
|
|
1231
1231
|
throw new MastraError(
|
|
1232
1232
|
{
|
|
1233
|
-
id: "
|
|
1233
|
+
id: "MSSQL_STORE_BATCH_UPDATE_SPANS_FAILED",
|
|
1234
1234
|
domain: ErrorDomain.STORAGE,
|
|
1235
1235
|
category: ErrorCategory.USER,
|
|
1236
1236
|
details: {
|
|
@@ -1241,20 +1241,20 @@ var ObservabilityMSSQL = class extends ObservabilityStorage {
|
|
|
1241
1241
|
);
|
|
1242
1242
|
}
|
|
1243
1243
|
}
|
|
1244
|
-
async
|
|
1244
|
+
async batchDeleteTraces(args) {
|
|
1245
1245
|
if (!args.traceIds || args.traceIds.length === 0) {
|
|
1246
1246
|
return;
|
|
1247
1247
|
}
|
|
1248
1248
|
try {
|
|
1249
1249
|
const keys = args.traceIds.map((traceId) => ({ traceId }));
|
|
1250
1250
|
await this.operations.batchDelete({
|
|
1251
|
-
tableName:
|
|
1251
|
+
tableName: TABLE_SPANS,
|
|
1252
1252
|
keys
|
|
1253
1253
|
});
|
|
1254
1254
|
} catch (error) {
|
|
1255
1255
|
throw new MastraError(
|
|
1256
1256
|
{
|
|
1257
|
-
id: "
|
|
1257
|
+
id: "MSSQL_STORE_BATCH_DELETE_TRACES_FAILED",
|
|
1258
1258
|
domain: ErrorDomain.STORAGE,
|
|
1259
1259
|
category: ErrorCategory.USER,
|
|
1260
1260
|
details: {
|
|
@@ -2161,22 +2161,22 @@ ${columns}
|
|
|
2161
2161
|
// Spans indexes for optimal trace querying
|
|
2162
2162
|
{
|
|
2163
2163
|
name: `${schemaPrefix}mastra_ai_spans_traceid_startedat_idx`,
|
|
2164
|
-
table:
|
|
2164
|
+
table: TABLE_SPANS,
|
|
2165
2165
|
columns: ["traceId", "startedAt DESC"]
|
|
2166
2166
|
},
|
|
2167
2167
|
{
|
|
2168
2168
|
name: `${schemaPrefix}mastra_ai_spans_parentspanid_startedat_idx`,
|
|
2169
|
-
table:
|
|
2169
|
+
table: TABLE_SPANS,
|
|
2170
2170
|
columns: ["parentSpanId", "startedAt DESC"]
|
|
2171
2171
|
},
|
|
2172
2172
|
{
|
|
2173
2173
|
name: `${schemaPrefix}mastra_ai_spans_name_idx`,
|
|
2174
|
-
table:
|
|
2174
|
+
table: TABLE_SPANS,
|
|
2175
2175
|
columns: ["name"]
|
|
2176
2176
|
},
|
|
2177
2177
|
{
|
|
2178
2178
|
name: `${schemaPrefix}mastra_ai_spans_spantype_startedat_idx`,
|
|
2179
|
-
table:
|
|
2179
|
+
table: TABLE_SPANS,
|
|
2180
2180
|
columns: ["spanType", "startedAt DESC"]
|
|
2181
2181
|
}
|
|
2182
2182
|
];
|
|
@@ -3192,11 +3192,11 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3192
3192
|
}) {
|
|
3193
3193
|
return this.getObservabilityStore().updateSpan({ spanId, traceId, updates });
|
|
3194
3194
|
}
|
|
3195
|
-
async
|
|
3196
|
-
return this.getObservabilityStore().
|
|
3195
|
+
async getTrace(traceId) {
|
|
3196
|
+
return this.getObservabilityStore().getTrace(traceId);
|
|
3197
3197
|
}
|
|
3198
|
-
async
|
|
3199
|
-
return this.getObservabilityStore().
|
|
3198
|
+
async getTracesPaginated(args) {
|
|
3199
|
+
return this.getObservabilityStore().getTracesPaginated(args);
|
|
3200
3200
|
}
|
|
3201
3201
|
async batchCreateSpans(args) {
|
|
3202
3202
|
return this.getObservabilityStore().batchCreateSpans(args);
|
|
@@ -3204,8 +3204,8 @@ var MSSQLStore = class extends MastraStorage {
|
|
|
3204
3204
|
async batchUpdateSpans(args) {
|
|
3205
3205
|
return this.getObservabilityStore().batchUpdateSpans(args);
|
|
3206
3206
|
}
|
|
3207
|
-
async
|
|
3208
|
-
return this.getObservabilityStore().
|
|
3207
|
+
async batchDeleteTraces(args) {
|
|
3208
|
+
return this.getObservabilityStore().batchDeleteTraces(args);
|
|
3209
3209
|
}
|
|
3210
3210
|
/**
|
|
3211
3211
|
* Scorers
|