@mastra/mssql 0.3.3-alpha.0 → 0.3.6-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 +36 -0
- package/package.json +21 -8
- package/.turbo/turbo-build.log +0 -4
- package/docker-compose.yaml +0 -14
- package/eslint.config.js +0 -6
- package/src/index.ts +0 -2
- package/src/storage/domains/legacy-evals/index.ts +0 -175
- package/src/storage/domains/memory/index.ts +0 -1084
- package/src/storage/domains/operations/index.ts +0 -401
- package/src/storage/domains/scores/index.ts +0 -316
- package/src/storage/domains/traces/index.ts +0 -212
- package/src/storage/domains/utils.ts +0 -12
- package/src/storage/domains/workflows/index.ts +0 -296
- package/src/storage/index.test.ts +0 -2228
- package/src/storage/index.ts +0 -494
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -5
- package/tsup.config.ts +0 -17
- package/vitest.config.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @mastra/mssql
|
|
2
2
|
|
|
3
|
+
## 0.3.6-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7343](https://github.com/mastra-ai/mastra/pull/7343) [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e) Thanks [@LekoArts](https://github.com/LekoArts)! - Update the `package.json` file to include additional fields like `repository`, `homepage` or `files`.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`85ef90b`](https://github.com/mastra-ai/mastra/commit/85ef90bb2cd4ae4df855c7ac175f7d392c55c1bf), [`de3cbc6`](https://github.com/mastra-ai/mastra/commit/de3cbc61079211431bd30487982ea3653517278e)]:
|
|
10
|
+
- @mastra/core@0.15.3-alpha.5
|
|
11
|
+
|
|
12
|
+
## 0.3.5
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`c6113ed`](https://github.com/mastra-ai/mastra/commit/c6113ed7f9df297e130d94436ceee310273d6430) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdpes for @mastra/core
|
|
17
|
+
|
|
18
|
+
- Updated dependencies []:
|
|
19
|
+
- @mastra/core@0.15.2
|
|
20
|
+
|
|
21
|
+
## 0.3.4
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- [`95b2aa9`](https://github.com/mastra-ai/mastra/commit/95b2aa908230919e67efcac0d69005a2d5745298) Thanks [@wardpeet](https://github.com/wardpeet)! - Fix peerdeps @mastra/core
|
|
26
|
+
|
|
27
|
+
- Updated dependencies []:
|
|
28
|
+
- @mastra/core@0.15.1
|
|
29
|
+
|
|
30
|
+
## 0.3.3
|
|
31
|
+
|
|
32
|
+
### Patch Changes
|
|
33
|
+
|
|
34
|
+
- [#6994](https://github.com/mastra-ai/mastra/pull/6994) [`0594a70`](https://github.com/mastra-ai/mastra/commit/0594a70ac948d306c7f38765b171c9535e6c78d4) Thanks [@wardpeet](https://github.com/wardpeet)! - Improve type resolving for storage adapters
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`0778757`](https://github.com/mastra-ai/mastra/commit/07787570e4addbd501522037bd2542c3d9e26822), [`943a7f3`](https://github.com/mastra-ai/mastra/commit/943a7f3dbc6a8ab3f9b7bc7c8a1c5b319c3d7f56), [`bf504a8`](https://github.com/mastra-ai/mastra/commit/bf504a833051f6f321d832cc7d631f3cb86d657b), [`be49354`](https://github.com/mastra-ai/mastra/commit/be493546dca540101923ec700feb31f9a13939f2), [`d591ab3`](https://github.com/mastra-ai/mastra/commit/d591ab3ecc985c1870c0db347f8d7a20f7360536), [`ba82abe`](https://github.com/mastra-ai/mastra/commit/ba82abe76e869316bb5a9c95e8ea3946f3436fae), [`727f7e5`](https://github.com/mastra-ai/mastra/commit/727f7e5086e62e0dfe3356fb6dcd8bcb420af246), [`e6f5046`](https://github.com/mastra-ai/mastra/commit/e6f50467aff317e67e8bd74c485c3fbe2a5a6db1), [`82d9f64`](https://github.com/mastra-ai/mastra/commit/82d9f647fbe4f0177320e7c05073fce88599aa95), [`2e58325`](https://github.com/mastra-ai/mastra/commit/2e58325beb170f5b92f856e27d915cd26917e5e6), [`1191ce9`](https://github.com/mastra-ai/mastra/commit/1191ce946b40ed291e7877a349f8388e3cff7e5c), [`4189486`](https://github.com/mastra-ai/mastra/commit/4189486c6718fda78347bdf4ce4d3fc33b2236e1), [`ca8ec2f`](https://github.com/mastra-ai/mastra/commit/ca8ec2f61884b9dfec5fc0d5f4f29d281ad13c01), [`9613558`](https://github.com/mastra-ai/mastra/commit/9613558e6475f4710e05d1be7553a32ee7bddc20)]:
|
|
37
|
+
- @mastra/core@0.15.0
|
|
38
|
+
|
|
3
39
|
## 0.3.3-alpha.0
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mssql",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6-alpha.0",
|
|
4
4
|
"description": "MSSQL provider for Mastra - db storage capabilities",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
|
-
"license": "
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"mssql": "^
|
|
23
|
+
"mssql": "^11.0.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@microsoft/api-extractor": "^7.52.8",
|
|
@@ -30,13 +30,26 @@
|
|
|
30
30
|
"tsup": "^8.5.0",
|
|
31
31
|
"typescript": "^5.8.3",
|
|
32
32
|
"vitest": "^3.2.4",
|
|
33
|
-
"@internal/lint": "0.0.
|
|
34
|
-
"@
|
|
35
|
-
"@internal/
|
|
36
|
-
"@
|
|
33
|
+
"@internal/lint": "0.0.34",
|
|
34
|
+
"@internal/types-builder": "0.0.9",
|
|
35
|
+
"@internal/storage-test-utils": "0.0.30",
|
|
36
|
+
"@mastra/core": "0.15.3-alpha.5"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@mastra/core": ">=0.13.0-0 <0.
|
|
39
|
+
"@mastra/core": ">=0.13.0-0 <0.16.0-0"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"CHANGELOG.md"
|
|
44
|
+
],
|
|
45
|
+
"homepage": "https://mastra.ai",
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "git+https://github.com/mastra-ai/mastra.git",
|
|
49
|
+
"directory": "stores/mssql"
|
|
50
|
+
},
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/mastra-ai/mastra/issues"
|
|
40
53
|
},
|
|
41
54
|
"scripts": {
|
|
42
55
|
"build": "tsup --silent --config tsup.config.ts",
|
package/.turbo/turbo-build.log
DELETED
package/docker-compose.yaml
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
services:
|
|
2
|
-
mssql:
|
|
3
|
-
image: mcr.microsoft.com/mssql/server:2025-latest
|
|
4
|
-
environment:
|
|
5
|
-
- ACCEPT_EULA=Y
|
|
6
|
-
- SA_PASSWORD=Your_password123
|
|
7
|
-
ports:
|
|
8
|
-
- '1433:1433'
|
|
9
|
-
healthcheck:
|
|
10
|
-
test: ['CMD-SHELL', 'echo > /dev/tcp/localhost/1433']
|
|
11
|
-
interval: 10s
|
|
12
|
-
timeout: 5s
|
|
13
|
-
retries: 10
|
|
14
|
-
start_period: 20s
|
package/eslint.config.js
DELETED
package/src/index.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { ErrorCategory, ErrorDomain, MastraError } from '@mastra/core/error';
|
|
2
|
-
import type { MetricResult } from '@mastra/core/eval';
|
|
3
|
-
import { LegacyEvalsStorage, TABLE_EVALS } from '@mastra/core/storage';
|
|
4
|
-
import type { PaginationArgs, PaginationInfo, EvalRow } from '@mastra/core/storage';
|
|
5
|
-
import sql from 'mssql';
|
|
6
|
-
import { getSchemaName, getTableName } from '../utils';
|
|
7
|
-
|
|
8
|
-
function transformEvalRow(row: Record<string, any>): EvalRow {
|
|
9
|
-
let testInfoValue = null,
|
|
10
|
-
resultValue = null;
|
|
11
|
-
if (row.test_info) {
|
|
12
|
-
try {
|
|
13
|
-
testInfoValue = typeof row.test_info === 'string' ? JSON.parse(row.test_info) : row.test_info;
|
|
14
|
-
} catch {}
|
|
15
|
-
}
|
|
16
|
-
if (row.test_info) {
|
|
17
|
-
try {
|
|
18
|
-
resultValue = typeof row.result === 'string' ? JSON.parse(row.result) : row.result;
|
|
19
|
-
} catch {}
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
agentName: row.agent_name as string,
|
|
23
|
-
input: row.input as string,
|
|
24
|
-
output: row.output as string,
|
|
25
|
-
result: resultValue as MetricResult,
|
|
26
|
-
metricName: row.metric_name as string,
|
|
27
|
-
instructions: row.instructions as string,
|
|
28
|
-
testInfo: testInfoValue,
|
|
29
|
-
globalRunId: row.global_run_id as string,
|
|
30
|
-
runId: row.run_id as string,
|
|
31
|
-
createdAt: row.created_at as string,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class LegacyEvalsMSSQL extends LegacyEvalsStorage {
|
|
36
|
-
private pool: sql.ConnectionPool;
|
|
37
|
-
private schema: string;
|
|
38
|
-
constructor({ pool, schema }: { pool: sql.ConnectionPool; schema: string }) {
|
|
39
|
-
super();
|
|
40
|
-
this.pool = pool;
|
|
41
|
-
this.schema = schema;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** @deprecated use getEvals instead */
|
|
45
|
-
async getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]> {
|
|
46
|
-
try {
|
|
47
|
-
let query = `SELECT * FROM ${getTableName({ indexName: TABLE_EVALS, schemaName: getSchemaName(this.schema) })} WHERE agent_name = @p1`;
|
|
48
|
-
if (type === 'test') {
|
|
49
|
-
query += " AND test_info IS NOT NULL AND JSON_VALUE(test_info, '$.testPath') IS NOT NULL";
|
|
50
|
-
} else if (type === 'live') {
|
|
51
|
-
query += " AND (test_info IS NULL OR JSON_VALUE(test_info, '$.testPath') IS NULL)";
|
|
52
|
-
}
|
|
53
|
-
query += ' ORDER BY created_at DESC';
|
|
54
|
-
|
|
55
|
-
const request = this.pool.request();
|
|
56
|
-
request.input('p1', agentName);
|
|
57
|
-
const result = await request.query(query);
|
|
58
|
-
const rows = result.recordset;
|
|
59
|
-
return typeof transformEvalRow === 'function'
|
|
60
|
-
? (rows?.map((row: any) => transformEvalRow(row)) ?? [])
|
|
61
|
-
: (rows ?? []);
|
|
62
|
-
} catch (error: any) {
|
|
63
|
-
if (error && error.number === 208 && error.message && error.message.includes('Invalid object name')) {
|
|
64
|
-
return [];
|
|
65
|
-
}
|
|
66
|
-
console.error('Failed to get evals for the specified agent: ' + error?.message);
|
|
67
|
-
throw error;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async getEvals(
|
|
72
|
-
options: {
|
|
73
|
-
agentName?: string;
|
|
74
|
-
type?: 'test' | 'live';
|
|
75
|
-
} & PaginationArgs = {},
|
|
76
|
-
): Promise<PaginationInfo & { evals: EvalRow[] }> {
|
|
77
|
-
const { agentName, type, page = 0, perPage = 100, dateRange } = options;
|
|
78
|
-
const fromDate = dateRange?.start;
|
|
79
|
-
const toDate = dateRange?.end;
|
|
80
|
-
|
|
81
|
-
const where: string[] = [];
|
|
82
|
-
const params: Record<string, any> = {};
|
|
83
|
-
|
|
84
|
-
if (agentName) {
|
|
85
|
-
where.push('agent_name = @agentName');
|
|
86
|
-
params['agentName'] = agentName;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
if (type === 'test') {
|
|
90
|
-
where.push("test_info IS NOT NULL AND JSON_VALUE(test_info, '$.testPath') IS NOT NULL");
|
|
91
|
-
} else if (type === 'live') {
|
|
92
|
-
where.push("(test_info IS NULL OR JSON_VALUE(test_info, '$.testPath') IS NULL)");
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (fromDate instanceof Date && !isNaN(fromDate.getTime())) {
|
|
96
|
-
where.push(`[created_at] >= @fromDate`);
|
|
97
|
-
params[`fromDate`] = fromDate.toISOString();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
if (toDate instanceof Date && !isNaN(toDate.getTime())) {
|
|
101
|
-
where.push(`[created_at] <= @toDate`);
|
|
102
|
-
params[`toDate`] = toDate.toISOString();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const whereClause = where.length > 0 ? `WHERE ${where.join(' AND ')}` : '';
|
|
106
|
-
const tableName = getTableName({ indexName: TABLE_EVALS, schemaName: getSchemaName(this.schema) });
|
|
107
|
-
const offset = page * perPage;
|
|
108
|
-
|
|
109
|
-
const countQuery = `SELECT COUNT(*) as total FROM ${tableName} ${whereClause}`;
|
|
110
|
-
const dataQuery = `SELECT * FROM ${tableName} ${whereClause} ORDER BY seq_id DESC OFFSET @offset ROWS FETCH NEXT @perPage ROWS ONLY`;
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const countReq = this.pool.request();
|
|
114
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
115
|
-
if (value instanceof Date) {
|
|
116
|
-
countReq.input(key, sql.DateTime, value);
|
|
117
|
-
} else {
|
|
118
|
-
countReq.input(key, value);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
const countResult = await countReq.query(countQuery);
|
|
122
|
-
const total = countResult.recordset[0]?.total || 0;
|
|
123
|
-
|
|
124
|
-
if (total === 0) {
|
|
125
|
-
return {
|
|
126
|
-
evals: [],
|
|
127
|
-
total: 0,
|
|
128
|
-
page,
|
|
129
|
-
perPage,
|
|
130
|
-
hasMore: false,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const req = this.pool.request();
|
|
135
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
136
|
-
if (value instanceof Date) {
|
|
137
|
-
req.input(key, sql.DateTime, value);
|
|
138
|
-
} else {
|
|
139
|
-
req.input(key, value);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
req.input('offset', offset);
|
|
143
|
-
req.input('perPage', perPage);
|
|
144
|
-
|
|
145
|
-
const result = await req.query(dataQuery);
|
|
146
|
-
const rows = result.recordset;
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
evals: rows?.map(row => transformEvalRow(row)) ?? [],
|
|
150
|
-
total,
|
|
151
|
-
page,
|
|
152
|
-
perPage,
|
|
153
|
-
hasMore: offset + (rows?.length ?? 0) < total,
|
|
154
|
-
};
|
|
155
|
-
} catch (error) {
|
|
156
|
-
const mastraError = new MastraError(
|
|
157
|
-
{
|
|
158
|
-
id: 'MASTRA_STORAGE_MSSQL_STORE_GET_EVALS_FAILED',
|
|
159
|
-
domain: ErrorDomain.STORAGE,
|
|
160
|
-
category: ErrorCategory.THIRD_PARTY,
|
|
161
|
-
details: {
|
|
162
|
-
agentName: agentName || 'all',
|
|
163
|
-
type: type || 'all',
|
|
164
|
-
page,
|
|
165
|
-
perPage,
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
error,
|
|
169
|
-
);
|
|
170
|
-
this.logger?.error?.(mastraError.toString());
|
|
171
|
-
this.logger?.trackException(mastraError);
|
|
172
|
-
throw mastraError;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|