@mastra/mssql 1.4.0-alpha.0 → 1.4.1-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 +48 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-mssql.md +2 -0
- package/dist/index.cjs +43 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -11
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/scores/index.d.ts +9 -5
- package/dist/storage/domains/scores/index.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
# @mastra/mssql
|
|
2
2
|
|
|
3
|
+
## 1.4.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add optional `batchId`, `datasetId`, and `datasetItemId` fields to persisted scores so saved baseline scores can be grouped as one scoring pass and joined back to the dataset items they came from. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
8
|
+
- `scoreTrace()` accepts top-level `batchId`, `datasetId`, and `datasetItemId` when persisting a score for a stored trace.
|
|
9
|
+
- `ScoreRowData` and score save payloads now include nullable `batchId`, `datasetId`, and `datasetItemId`.
|
|
10
|
+
- Built-in stores with explicit score schema or attribute mappings now persist these provenance fields on saved scores.
|
|
11
|
+
- D1, DSQL, MSSQL, and Upstash score stores now apply additive provenance migrations or deterministic score ordering for persisted score reads.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
await scoreTrace({
|
|
15
|
+
storage,
|
|
16
|
+
scorer,
|
|
17
|
+
target: { traceId },
|
|
18
|
+
batchId: 'baseline-batch-1',
|
|
19
|
+
datasetId,
|
|
20
|
+
datasetItemId,
|
|
21
|
+
});
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- Added optional `organizationId` and `projectId` fields to scores for multi-tenant isolation. Scores can now be saved with tenancy metadata and the `listScoresBy*` methods accept a `filters` option to scope results by organization and project. ([#18331](https://github.com/mastra-ai/mastra/pull/18331))
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
await storage.saveScore({ ...score, organizationId: 'org-a', projectId: 'proj-1' });
|
|
28
|
+
|
|
29
|
+
const result = await storage.listScoresByScorerId({
|
|
30
|
+
scorerId,
|
|
31
|
+
filters: { organizationId: 'org-a', projectId: 'proj-1' },
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`projectId` identifies the project scope, separate from `resourceId` which continues to mean the agent memory resource.
|
|
36
|
+
|
|
37
|
+
- Updated dependencies [[`9250acd`](https://github.com/mastra-ai/mastra/commit/9250acd1357f0f1f33d0dcca16f9655084c58eca), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`c64c2a8`](https://github.com/mastra-ai/mastra/commit/c64c2a8503a50252f9ca6b8e8c54cadee31b92a2), [`06e2680`](https://github.com/mastra-ai/mastra/commit/06e26806b51d2cbd858afdc66daa2b86ff3ba64a), [`1240f05`](https://github.com/mastra-ai/mastra/commit/1240f051c8e5371f1c014448bf37b1a1b9a05e47), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`24c10d3`](https://github.com/mastra-ai/mastra/commit/24c10d333e6649ac06075903aeeee13a933db3b3), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748), [`215f9b0`](https://github.com/mastra-ai/mastra/commit/215f9b0f3f3f6fc165edad360582dd4d3d7ea748)]:
|
|
38
|
+
- @mastra/core@1.49.0-alpha.5
|
|
39
|
+
|
|
40
|
+
## 1.4.0
|
|
41
|
+
|
|
42
|
+
### Minor Changes
|
|
43
|
+
|
|
44
|
+
- Random bump ([#18178](https://github.com/mastra-ai/mastra/pull/18178))
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [[`7c0d868`](https://github.com/mastra-ai/mastra/commit/7c0d868d97d0fdbc04c14d0166dbf44d4c5a4a62), [`d9d2273`](https://github.com/mastra-ai/mastra/commit/d9d2273c702690c9a26eab2aebea879701d4355a), [`b04369d`](https://github.com/mastra-ai/mastra/commit/b04369d6b167c698ef103981171a8bf92808e756), [`8f3c262`](https://github.com/mastra-ai/mastra/commit/8f3c262587b335588a02d96b17fd6aca34c885b3)]:
|
|
49
|
+
- @mastra/core@1.45.0
|
|
50
|
+
|
|
3
51
|
## 1.4.0-alpha.0
|
|
4
52
|
|
|
5
53
|
### Minor Changes
|
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -4066,6 +4066,19 @@ function transformScoreRow(row) {
|
|
|
4066
4066
|
convertTimestamps: true
|
|
4067
4067
|
});
|
|
4068
4068
|
}
|
|
4069
|
+
function buildTenancyConditions(filters) {
|
|
4070
|
+
const conditions = [];
|
|
4071
|
+
const params = {};
|
|
4072
|
+
if (filters?.organizationId !== void 0) {
|
|
4073
|
+
conditions.push("[organizationId] = @org");
|
|
4074
|
+
params.org = filters.organizationId;
|
|
4075
|
+
}
|
|
4076
|
+
if (filters?.projectId !== void 0) {
|
|
4077
|
+
conditions.push("[projectId] = @proj");
|
|
4078
|
+
params.proj = filters.projectId;
|
|
4079
|
+
}
|
|
4080
|
+
return { conditions, params };
|
|
4081
|
+
}
|
|
4069
4082
|
var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
4070
4083
|
pool;
|
|
4071
4084
|
db;
|
|
@@ -4235,7 +4248,8 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4235
4248
|
pagination,
|
|
4236
4249
|
entityId,
|
|
4237
4250
|
entityType,
|
|
4238
|
-
source
|
|
4251
|
+
source,
|
|
4252
|
+
filters
|
|
4239
4253
|
}) {
|
|
4240
4254
|
try {
|
|
4241
4255
|
const conditions = ["[scorerId] = @p1"];
|
|
@@ -4256,6 +4270,9 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4256
4270
|
params[`p${paramIndex}`] = source;
|
|
4257
4271
|
paramIndex++;
|
|
4258
4272
|
}
|
|
4273
|
+
const tenancy = buildTenancyConditions(filters);
|
|
4274
|
+
conditions.push(...tenancy.conditions);
|
|
4275
|
+
Object.assign(params, tenancy.params);
|
|
4259
4276
|
const whereClause = conditions.join(" AND ");
|
|
4260
4277
|
const tableName = getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) });
|
|
4261
4278
|
const countRequest = this.pool.request();
|
|
@@ -4286,7 +4303,7 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4286
4303
|
});
|
|
4287
4304
|
dataRequest.input("perPage", limitValue);
|
|
4288
4305
|
dataRequest.input("offset", start);
|
|
4289
|
-
const dataQuery = `SELECT * FROM ${tableName} WHERE ${whereClause} ORDER BY [
|
|
4306
|
+
const dataQuery = `SELECT * FROM ${tableName} WHERE ${whereClause} ORDER BY [seq_id] DESC OFFSET @offset ROWS FETCH NEXT @perPage ROWS ONLY`;
|
|
4290
4307
|
const result = await dataRequest.query(dataQuery);
|
|
4291
4308
|
return {
|
|
4292
4309
|
pagination: {
|
|
@@ -4311,13 +4328,17 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4311
4328
|
}
|
|
4312
4329
|
async listScoresByRunId({
|
|
4313
4330
|
runId,
|
|
4314
|
-
pagination
|
|
4331
|
+
pagination,
|
|
4332
|
+
filters
|
|
4315
4333
|
}) {
|
|
4316
4334
|
try {
|
|
4335
|
+
const tenancy = buildTenancyConditions(filters);
|
|
4336
|
+
const tenancySql = tenancy.conditions.length > 0 ? ` AND ${tenancy.conditions.join(" AND ")}` : "";
|
|
4317
4337
|
const request = this.pool.request();
|
|
4318
4338
|
request.input("p1", runId);
|
|
4339
|
+
Object.entries(tenancy.params).forEach(([key, value]) => request.input(key, value));
|
|
4319
4340
|
const totalResult = await request.query(
|
|
4320
|
-
`SELECT COUNT(*) as count FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [runId] = @p1`
|
|
4341
|
+
`SELECT COUNT(*) as count FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [runId] = @p1${tenancySql}`
|
|
4321
4342
|
);
|
|
4322
4343
|
const total = totalResult.recordset[0]?.count || 0;
|
|
4323
4344
|
const { page, perPage: perPageInput } = pagination;
|
|
@@ -4340,8 +4361,9 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4340
4361
|
dataRequest.input("p1", runId);
|
|
4341
4362
|
dataRequest.input("p2", limitValue);
|
|
4342
4363
|
dataRequest.input("p3", start);
|
|
4364
|
+
Object.entries(tenancy.params).forEach(([key, value]) => dataRequest.input(key, value));
|
|
4343
4365
|
const result = await dataRequest.query(
|
|
4344
|
-
`SELECT * FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [runId] = @p1 ORDER BY [
|
|
4366
|
+
`SELECT * FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [runId] = @p1${tenancySql} ORDER BY [seq_id] DESC OFFSET @p3 ROWS FETCH NEXT @p2 ROWS ONLY`
|
|
4345
4367
|
);
|
|
4346
4368
|
return {
|
|
4347
4369
|
pagination: {
|
|
@@ -4367,14 +4389,18 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4367
4389
|
async listScoresByEntityId({
|
|
4368
4390
|
entityId,
|
|
4369
4391
|
entityType,
|
|
4370
|
-
pagination
|
|
4392
|
+
pagination,
|
|
4393
|
+
filters
|
|
4371
4394
|
}) {
|
|
4372
4395
|
try {
|
|
4396
|
+
const tenancy = buildTenancyConditions(filters);
|
|
4397
|
+
const tenancySql = tenancy.conditions.length > 0 ? ` AND ${tenancy.conditions.join(" AND ")}` : "";
|
|
4373
4398
|
const request = this.pool.request();
|
|
4374
4399
|
request.input("p1", entityId);
|
|
4375
4400
|
request.input("p2", entityType);
|
|
4401
|
+
Object.entries(tenancy.params).forEach(([key, value]) => request.input(key, value));
|
|
4376
4402
|
const totalResult = await request.query(
|
|
4377
|
-
`SELECT COUNT(*) as count FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [entityId] = @p1 AND [entityType] = @p2`
|
|
4403
|
+
`SELECT COUNT(*) as count FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [entityId] = @p1 AND [entityType] = @p2${tenancySql}`
|
|
4378
4404
|
);
|
|
4379
4405
|
const total = totalResult.recordset[0]?.count || 0;
|
|
4380
4406
|
const { page, perPage: perPageInput } = pagination;
|
|
@@ -4398,8 +4424,9 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4398
4424
|
dataRequest.input("p2", entityType);
|
|
4399
4425
|
dataRequest.input("p3", limitValue);
|
|
4400
4426
|
dataRequest.input("p4", start);
|
|
4427
|
+
Object.entries(tenancy.params).forEach(([key, value]) => dataRequest.input(key, value));
|
|
4401
4428
|
const result = await dataRequest.query(
|
|
4402
|
-
`SELECT * FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [entityId] = @p1 AND [entityType] = @p2 ORDER BY [
|
|
4429
|
+
`SELECT * FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [entityId] = @p1 AND [entityType] = @p2${tenancySql} ORDER BY [seq_id] DESC OFFSET @p4 ROWS FETCH NEXT @p3 ROWS ONLY`
|
|
4403
4430
|
);
|
|
4404
4431
|
return {
|
|
4405
4432
|
pagination: {
|
|
@@ -4425,14 +4452,18 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4425
4452
|
async listScoresBySpan({
|
|
4426
4453
|
traceId,
|
|
4427
4454
|
spanId,
|
|
4428
|
-
pagination
|
|
4455
|
+
pagination,
|
|
4456
|
+
filters
|
|
4429
4457
|
}) {
|
|
4430
4458
|
try {
|
|
4459
|
+
const tenancy = buildTenancyConditions(filters);
|
|
4460
|
+
const tenancySql = tenancy.conditions.length > 0 ? ` AND ${tenancy.conditions.join(" AND ")}` : "";
|
|
4431
4461
|
const request = this.pool.request();
|
|
4432
4462
|
request.input("p1", traceId);
|
|
4433
4463
|
request.input("p2", spanId);
|
|
4464
|
+
Object.entries(tenancy.params).forEach(([key, value]) => request.input(key, value));
|
|
4434
4465
|
const totalResult = await request.query(
|
|
4435
|
-
`SELECT COUNT(*) as count FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2`
|
|
4466
|
+
`SELECT COUNT(*) as count FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2${tenancySql}`
|
|
4436
4467
|
);
|
|
4437
4468
|
const total = totalResult.recordset[0]?.count || 0;
|
|
4438
4469
|
const { page, perPage: perPageInput } = pagination;
|
|
@@ -4456,8 +4487,9 @@ var ScoresMSSQL = class _ScoresMSSQL extends storage.ScoresStorage {
|
|
|
4456
4487
|
dataRequest.input("p2", spanId);
|
|
4457
4488
|
dataRequest.input("p3", limitValue);
|
|
4458
4489
|
dataRequest.input("p4", start);
|
|
4490
|
+
Object.entries(tenancy.params).forEach(([key, value]) => dataRequest.input(key, value));
|
|
4459
4491
|
const result = await dataRequest.query(
|
|
4460
|
-
`SELECT * FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2 ORDER BY [
|
|
4492
|
+
`SELECT * FROM ${getTableName2({ indexName: storage.TABLE_SCORERS, schemaName: getSchemaName2(this.schema) })} WHERE [traceId] = @p1 AND [spanId] = @p2${tenancySql} ORDER BY [seq_id] DESC OFFSET @p4 ROWS FETCH NEXT @p3 ROWS ONLY`
|
|
4461
4493
|
);
|
|
4462
4494
|
return {
|
|
4463
4495
|
pagination: {
|