@mastra/mssql 0.0.0-fix-writer-workflow-resumestream-20251022161252 → 0.0.0-fix-memory-search-fetch-20251027160505
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 +11 -3
- package/dist/index.cjs +6 -187
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +8 -189
- package/dist/index.js.map +1 -1
- package/dist/storage/index.d.ts +1 -12
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +6 -6
- package/dist/storage/domains/traces/index.d.ts +0 -37
- package/dist/storage/domains/traces/index.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
# @mastra/mssql
|
|
2
2
|
|
|
3
|
-
## 0.0.0-fix-
|
|
3
|
+
## 0.0.0-fix-memory-search-fetch-20251027160505
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Removed old tracing code based on OpenTelemetry ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- Update peer dependencies to match core package version bump (1.0.0) ([#9237](https://github.com/mastra-ai/mastra/pull/9237))
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
6
14
|
|
|
7
|
-
- Updated dependencies [[`
|
|
8
|
-
- @mastra/core@0.0.0-fix-
|
|
15
|
+
- Updated dependencies [[`f743dbb`](https://github.com/mastra-ai/mastra/commit/f743dbb8b40d1627b5c10c0e6fc154f4ebb6e394), [`6c049d9`](https://github.com/mastra-ai/mastra/commit/6c049d94063fdcbd5b81c4912a2bf82a92c9cc0b), [`9e1911d`](https://github.com/mastra-ai/mastra/commit/9e1911db2b4db85e0e768c3f15e0d61e319869f6), [`ebac155`](https://github.com/mastra-ai/mastra/commit/ebac15564a590117db7078233f927a7e28a85106), [`9d819d5`](https://github.com/mastra-ai/mastra/commit/9d819d54b61481639f4008e4694791bddf187edd), [`5df9cce`](https://github.com/mastra-ai/mastra/commit/5df9cce1a753438413f64c11eeef8f845745c2a8), [`c576fc0`](https://github.com/mastra-ai/mastra/commit/c576fc0b100b2085afded91a37c97a0ea0ec09c7), [`57d157f`](https://github.com/mastra-ai/mastra/commit/57d157f0b163a95c3e6c9eae31bdb11d1bfc64f9), [`cfae733`](https://github.com/mastra-ai/mastra/commit/cfae73394f4920635e6c919c8e95ff9a0788e2e5), [`e3dfda7`](https://github.com/mastra-ai/mastra/commit/e3dfda7b11bf3b8c4bb55637028befb5f387fc74), [`f0f8f12`](https://github.com/mastra-ai/mastra/commit/f0f8f125c308f2d0fd36942ef652fd852df7522f), [`d36cfbb`](https://github.com/mastra-ai/mastra/commit/d36cfbbb6565ba5f827883cc9bb648eb14befdc1), [`53d927c`](https://github.com/mastra-ai/mastra/commit/53d927cc6f03bff33655b7e2b788da445a08731d), [`c7f1f7d`](https://github.com/mastra-ai/mastra/commit/c7f1f7d24f61f247f018cc2d1f33bf63212959a7), [`2c4438b`](https://github.com/mastra-ai/mastra/commit/2c4438b87817ab7eed818c7990fef010475af1a3), [`fa8409b`](https://github.com/mastra-ai/mastra/commit/fa8409bc39cfd8ba6643b9db5269b90b22e2a2f7), [`173c535`](https://github.com/mastra-ai/mastra/commit/173c535c0645b0da404fe09f003778f0b0d4e019)]:
|
|
16
|
+
- @mastra/core@0.0.0-fix-memory-search-fetch-20251027160505
|
|
9
17
|
|
|
10
18
|
## 0.4.6
|
|
11
19
|
|
package/dist/index.cjs
CHANGED
|
@@ -200,7 +200,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
200
200
|
}
|
|
201
201
|
async getThreadById({ threadId }) {
|
|
202
202
|
try {
|
|
203
|
-
const
|
|
203
|
+
const sql6 = `SELECT
|
|
204
204
|
id,
|
|
205
205
|
[resourceId],
|
|
206
206
|
title,
|
|
@@ -211,7 +211,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
211
211
|
WHERE id = @threadId`;
|
|
212
212
|
const request = this.pool.request();
|
|
213
213
|
request.input("threadId", threadId);
|
|
214
|
-
const resultSet = await request.query(
|
|
214
|
+
const resultSet = await request.query(sql6);
|
|
215
215
|
const thread = resultSet.recordset[0] || null;
|
|
216
216
|
if (!thread) {
|
|
217
217
|
return null;
|
|
@@ -384,7 +384,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
384
384
|
};
|
|
385
385
|
try {
|
|
386
386
|
const table = getTableName({ indexName: storage.TABLE_THREADS, schemaName: getSchemaName(this.schema) });
|
|
387
|
-
const
|
|
387
|
+
const sql6 = `UPDATE ${table}
|
|
388
388
|
SET title = @title,
|
|
389
389
|
metadata = @metadata,
|
|
390
390
|
[updatedAt] = @updatedAt
|
|
@@ -395,7 +395,7 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
395
395
|
req.input("title", title);
|
|
396
396
|
req.input("metadata", JSON.stringify(mergedMetadata));
|
|
397
397
|
req.input("updatedAt", /* @__PURE__ */ new Date());
|
|
398
|
-
const result = await req.query(
|
|
398
|
+
const result = await req.query(sql6);
|
|
399
399
|
let thread = result.recordset && result.recordset[0];
|
|
400
400
|
if (thread && "seq_id" in thread) {
|
|
401
401
|
const { seq_id, ...rest } = thread;
|
|
@@ -1344,12 +1344,12 @@ ${columns}
|
|
|
1344
1344
|
const keyEntries = Object.entries(keys).map(([key, value]) => [utils.parseSqlIdentifier(key, "column name"), value]);
|
|
1345
1345
|
const conditions = keyEntries.map(([key], i) => `[${key}] = @param${i}`).join(" AND ");
|
|
1346
1346
|
const values = keyEntries.map(([_, value]) => value);
|
|
1347
|
-
const
|
|
1347
|
+
const sql6 = `SELECT * FROM ${getTableName({ indexName: tableName, schemaName: getSchemaName(this.schemaName) })} WHERE ${conditions}`;
|
|
1348
1348
|
const request = this.pool.request();
|
|
1349
1349
|
values.forEach((value, i) => {
|
|
1350
1350
|
request.input(`param${i}`, value);
|
|
1351
1351
|
});
|
|
1352
|
-
const resultSet = await request.query(
|
|
1352
|
+
const resultSet = await request.query(sql6);
|
|
1353
1353
|
const result = resultSet.recordset[0] || null;
|
|
1354
1354
|
if (!result) {
|
|
1355
1355
|
return null;
|
|
@@ -1746,173 +1746,6 @@ var ScoresMSSQL = class extends storage.ScoresStorage {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
1748
|
};
|
|
1749
|
-
var TracesMSSQL = class extends storage.TracesStorage {
|
|
1750
|
-
pool;
|
|
1751
|
-
operations;
|
|
1752
|
-
schema;
|
|
1753
|
-
constructor({
|
|
1754
|
-
pool,
|
|
1755
|
-
operations,
|
|
1756
|
-
schema
|
|
1757
|
-
}) {
|
|
1758
|
-
super();
|
|
1759
|
-
this.pool = pool;
|
|
1760
|
-
this.operations = operations;
|
|
1761
|
-
this.schema = schema;
|
|
1762
|
-
}
|
|
1763
|
-
/** @deprecated use getTracesPaginated instead*/
|
|
1764
|
-
async getTraces(args) {
|
|
1765
|
-
if (args.fromDate || args.toDate) {
|
|
1766
|
-
args.dateRange = {
|
|
1767
|
-
start: args.fromDate,
|
|
1768
|
-
end: args.toDate
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
const result = await this.getTracesPaginated(args);
|
|
1772
|
-
return result.traces;
|
|
1773
|
-
}
|
|
1774
|
-
async getTracesPaginated(args) {
|
|
1775
|
-
const { name, scope, page = 0, perPage: perPageInput, attributes, filters, dateRange } = args;
|
|
1776
|
-
const fromDate = dateRange?.start;
|
|
1777
|
-
const toDate = dateRange?.end;
|
|
1778
|
-
const perPage = perPageInput !== void 0 ? perPageInput : 100;
|
|
1779
|
-
const currentOffset = page * perPage;
|
|
1780
|
-
const paramMap = {};
|
|
1781
|
-
const conditions = [];
|
|
1782
|
-
let paramIndex = 1;
|
|
1783
|
-
if (name) {
|
|
1784
|
-
const paramName = `p${paramIndex++}`;
|
|
1785
|
-
conditions.push(`[name] LIKE @${paramName}`);
|
|
1786
|
-
paramMap[paramName] = `${name}%`;
|
|
1787
|
-
}
|
|
1788
|
-
if (scope) {
|
|
1789
|
-
const paramName = `p${paramIndex++}`;
|
|
1790
|
-
conditions.push(`[scope] = @${paramName}`);
|
|
1791
|
-
paramMap[paramName] = scope;
|
|
1792
|
-
}
|
|
1793
|
-
if (attributes) {
|
|
1794
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
1795
|
-
const parsedKey = utils.parseFieldKey(key);
|
|
1796
|
-
const paramName = `p${paramIndex++}`;
|
|
1797
|
-
conditions.push(`JSON_VALUE([attributes], '$.${parsedKey}') = @${paramName}`);
|
|
1798
|
-
paramMap[paramName] = value;
|
|
1799
|
-
});
|
|
1800
|
-
}
|
|
1801
|
-
if (filters) {
|
|
1802
|
-
Object.entries(filters).forEach(([key, value]) => {
|
|
1803
|
-
const parsedKey = utils.parseFieldKey(key);
|
|
1804
|
-
const paramName = `p${paramIndex++}`;
|
|
1805
|
-
conditions.push(`[${parsedKey}] = @${paramName}`);
|
|
1806
|
-
paramMap[paramName] = value;
|
|
1807
|
-
});
|
|
1808
|
-
}
|
|
1809
|
-
if (fromDate instanceof Date && !isNaN(fromDate.getTime())) {
|
|
1810
|
-
const paramName = `p${paramIndex++}`;
|
|
1811
|
-
conditions.push(`[createdAt] >= @${paramName}`);
|
|
1812
|
-
paramMap[paramName] = fromDate.toISOString();
|
|
1813
|
-
}
|
|
1814
|
-
if (toDate instanceof Date && !isNaN(toDate.getTime())) {
|
|
1815
|
-
const paramName = `p${paramIndex++}`;
|
|
1816
|
-
conditions.push(`[createdAt] <= @${paramName}`);
|
|
1817
|
-
paramMap[paramName] = toDate.toISOString();
|
|
1818
|
-
}
|
|
1819
|
-
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
1820
|
-
const countQuery = `SELECT COUNT(*) as total FROM ${getTableName({ indexName: storage.TABLE_TRACES, schemaName: getSchemaName(this.schema) })} ${whereClause}`;
|
|
1821
|
-
let total = 0;
|
|
1822
|
-
try {
|
|
1823
|
-
const countRequest = this.pool.request();
|
|
1824
|
-
Object.entries(paramMap).forEach(([key, value]) => {
|
|
1825
|
-
if (value instanceof Date) {
|
|
1826
|
-
countRequest.input(key, sql2__default.default.DateTime, value);
|
|
1827
|
-
} else {
|
|
1828
|
-
countRequest.input(key, value);
|
|
1829
|
-
}
|
|
1830
|
-
});
|
|
1831
|
-
const countResult = await countRequest.query(countQuery);
|
|
1832
|
-
total = parseInt(countResult.recordset[0].total, 10);
|
|
1833
|
-
} catch (error$1) {
|
|
1834
|
-
throw new error.MastraError(
|
|
1835
|
-
{
|
|
1836
|
-
id: "MASTRA_STORAGE_MSSQL_STORE_GET_TRACES_PAGINATED_FAILED_TO_RETRIEVE_TOTAL_COUNT",
|
|
1837
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1838
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1839
|
-
details: {
|
|
1840
|
-
name: args.name ?? "",
|
|
1841
|
-
scope: args.scope ?? ""
|
|
1842
|
-
}
|
|
1843
|
-
},
|
|
1844
|
-
error$1
|
|
1845
|
-
);
|
|
1846
|
-
}
|
|
1847
|
-
if (total === 0) {
|
|
1848
|
-
return {
|
|
1849
|
-
traces: [],
|
|
1850
|
-
total: 0,
|
|
1851
|
-
page,
|
|
1852
|
-
perPage,
|
|
1853
|
-
hasMore: false
|
|
1854
|
-
};
|
|
1855
|
-
}
|
|
1856
|
-
const dataQuery = `SELECT * FROM ${getTableName({ indexName: storage.TABLE_TRACES, schemaName: getSchemaName(this.schema) })} ${whereClause} ORDER BY [seq_id] DESC OFFSET @offset ROWS FETCH NEXT @limit ROWS ONLY`;
|
|
1857
|
-
const dataRequest = this.pool.request();
|
|
1858
|
-
Object.entries(paramMap).forEach(([key, value]) => {
|
|
1859
|
-
if (value instanceof Date) {
|
|
1860
|
-
dataRequest.input(key, sql2__default.default.DateTime, value);
|
|
1861
|
-
} else {
|
|
1862
|
-
dataRequest.input(key, value);
|
|
1863
|
-
}
|
|
1864
|
-
});
|
|
1865
|
-
dataRequest.input("offset", currentOffset);
|
|
1866
|
-
dataRequest.input("limit", perPage);
|
|
1867
|
-
try {
|
|
1868
|
-
const rowsResult = await dataRequest.query(dataQuery);
|
|
1869
|
-
const rows = rowsResult.recordset;
|
|
1870
|
-
const traces = rows.map((row) => ({
|
|
1871
|
-
id: row.id,
|
|
1872
|
-
parentSpanId: row.parentSpanId,
|
|
1873
|
-
traceId: row.traceId,
|
|
1874
|
-
name: row.name,
|
|
1875
|
-
scope: row.scope,
|
|
1876
|
-
kind: row.kind,
|
|
1877
|
-
status: JSON.parse(row.status),
|
|
1878
|
-
events: JSON.parse(row.events),
|
|
1879
|
-
links: JSON.parse(row.links),
|
|
1880
|
-
attributes: JSON.parse(row.attributes),
|
|
1881
|
-
startTime: row.startTime,
|
|
1882
|
-
endTime: row.endTime,
|
|
1883
|
-
other: row.other,
|
|
1884
|
-
createdAt: row.createdAt
|
|
1885
|
-
}));
|
|
1886
|
-
return {
|
|
1887
|
-
traces,
|
|
1888
|
-
total,
|
|
1889
|
-
page,
|
|
1890
|
-
perPage,
|
|
1891
|
-
hasMore: currentOffset + traces.length < total
|
|
1892
|
-
};
|
|
1893
|
-
} catch (error$1) {
|
|
1894
|
-
throw new error.MastraError(
|
|
1895
|
-
{
|
|
1896
|
-
id: "MASTRA_STORAGE_MSSQL_STORE_GET_TRACES_PAGINATED_FAILED_TO_RETRIEVE_TRACES",
|
|
1897
|
-
domain: error.ErrorDomain.STORAGE,
|
|
1898
|
-
category: error.ErrorCategory.THIRD_PARTY,
|
|
1899
|
-
details: {
|
|
1900
|
-
name: args.name ?? "",
|
|
1901
|
-
scope: args.scope ?? ""
|
|
1902
|
-
}
|
|
1903
|
-
},
|
|
1904
|
-
error$1
|
|
1905
|
-
);
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
async batchTraceInsert({ records }) {
|
|
1909
|
-
this.logger.debug("Batch inserting traces", { count: records.length });
|
|
1910
|
-
await this.operations.batchInsert({
|
|
1911
|
-
tableName: storage.TABLE_TRACES,
|
|
1912
|
-
records
|
|
1913
|
-
});
|
|
1914
|
-
}
|
|
1915
|
-
};
|
|
1916
1749
|
function parseWorkflowRun(row) {
|
|
1917
1750
|
let parsedSnapshot = row.snapshot;
|
|
1918
1751
|
if (typeof parsedSnapshot === "string") {
|
|
@@ -2179,13 +2012,11 @@ var MSSQLStore = class extends storage.MastraStorage {
|
|
|
2179
2012
|
const legacyEvals = new LegacyEvalsMSSQL({ pool: this.pool, schema: this.schema });
|
|
2180
2013
|
const operations = new StoreOperationsMSSQL({ pool: this.pool, schemaName: this.schema });
|
|
2181
2014
|
const scores = new ScoresMSSQL({ pool: this.pool, operations, schema: this.schema });
|
|
2182
|
-
const traces = new TracesMSSQL({ pool: this.pool, operations, schema: this.schema });
|
|
2183
2015
|
const workflows = new WorkflowsMSSQL({ pool: this.pool, operations, schema: this.schema });
|
|
2184
2016
|
const memory = new MemoryMSSQL({ pool: this.pool, schema: this.schema, operations });
|
|
2185
2017
|
this.stores = {
|
|
2186
2018
|
operations,
|
|
2187
2019
|
scores,
|
|
2188
|
-
traces,
|
|
2189
2020
|
workflows,
|
|
2190
2021
|
legacyEvals,
|
|
2191
2022
|
memory
|
|
@@ -2245,18 +2076,6 @@ var MSSQLStore = class extends storage.MastraStorage {
|
|
|
2245
2076
|
async getEvals(options = {}) {
|
|
2246
2077
|
return this.stores.legacyEvals.getEvals(options);
|
|
2247
2078
|
}
|
|
2248
|
-
/**
|
|
2249
|
-
* @deprecated use getTracesPaginated instead
|
|
2250
|
-
*/
|
|
2251
|
-
async getTraces(args) {
|
|
2252
|
-
return this.stores.traces.getTraces(args);
|
|
2253
|
-
}
|
|
2254
|
-
async getTracesPaginated(args) {
|
|
2255
|
-
return this.stores.traces.getTracesPaginated(args);
|
|
2256
|
-
}
|
|
2257
|
-
async batchTraceInsert({ records }) {
|
|
2258
|
-
return this.stores.traces.batchTraceInsert({ records });
|
|
2259
|
-
}
|
|
2260
2079
|
async createTable({
|
|
2261
2080
|
tableName,
|
|
2262
2081
|
schema
|