@mastra/mssql 0.3.1 → 0.3.2
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +46 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +8 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/storage/domains/memory/index.ts +60 -0
- package/src/storage/index.ts +12 -0
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/mssql
|
|
2
2
|
|
|
3
|
+
## 0.3.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`0f00e17`](https://github.com/mastra-ai/mastra/commit/0f00e172953ccdccadb35ed3d70f5e4d89115869), [`217cd7a`](https://github.com/mastra-ai/mastra/commit/217cd7a4ce171e9a575c41bb8c83300f4db03236), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
|
|
10
|
+
- @mastra/core@0.14.1
|
|
11
|
+
|
|
12
|
+
## 0.3.2-alpha.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#6700](https://github.com/mastra-ai/mastra/pull/6700) [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02) Thanks [@gpanakkal](https://github.com/gpanakkal)! - Add `getMessagesById` method to `MastraStorage` adapters
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`6e7e120`](https://github.com/mastra-ai/mastra/commit/6e7e1207d6e8d8b838f9024f90bd10df1181ba27), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
|
|
19
|
+
- @mastra/core@0.14.1-alpha.0
|
|
20
|
+
|
|
3
21
|
## 0.3.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -590,6 +590,46 @@ var MemoryMSSQL = class extends storage.MemoryStorage {
|
|
|
590
590
|
return [];
|
|
591
591
|
}
|
|
592
592
|
}
|
|
593
|
+
async getMessagesById({
|
|
594
|
+
messageIds,
|
|
595
|
+
format
|
|
596
|
+
}) {
|
|
597
|
+
if (messageIds.length === 0) return [];
|
|
598
|
+
const selectStatement = `SELECT seq_id, id, content, role, type, [createdAt], thread_id AS threadId, resourceId`;
|
|
599
|
+
const orderByStatement = `ORDER BY [seq_id] DESC`;
|
|
600
|
+
try {
|
|
601
|
+
let rows = [];
|
|
602
|
+
let query = `${selectStatement} FROM ${getTableName({ indexName: storage.TABLE_MESSAGES, schemaName: getSchemaName(this.schema) })} WHERE [id] IN (${messageIds.map((_, i) => `@id${i}`).join(", ")})`;
|
|
603
|
+
const request = this.pool.request();
|
|
604
|
+
messageIds.forEach((id, i) => request.input(`id${i}`, id));
|
|
605
|
+
query += ` ${orderByStatement}`;
|
|
606
|
+
const result = await request.query(query);
|
|
607
|
+
const remainingRows = result.recordset || [];
|
|
608
|
+
rows.push(...remainingRows);
|
|
609
|
+
rows.sort((a, b) => {
|
|
610
|
+
const timeDiff = a.seq_id - b.seq_id;
|
|
611
|
+
return timeDiff;
|
|
612
|
+
});
|
|
613
|
+
rows = rows.map(({ seq_id, ...rest }) => rest);
|
|
614
|
+
if (format === `v1`) return this._parseAndFormatMessages(rows, format);
|
|
615
|
+
return this._parseAndFormatMessages(rows, `v2`);
|
|
616
|
+
} catch (error$1) {
|
|
617
|
+
const mastraError = new error.MastraError(
|
|
618
|
+
{
|
|
619
|
+
id: "MASTRA_STORAGE_MSSQL_STORE_GET_MESSAGES_BY_ID_FAILED",
|
|
620
|
+
domain: error.ErrorDomain.STORAGE,
|
|
621
|
+
category: error.ErrorCategory.THIRD_PARTY,
|
|
622
|
+
details: {
|
|
623
|
+
messageIds: JSON.stringify(messageIds)
|
|
624
|
+
}
|
|
625
|
+
},
|
|
626
|
+
error$1
|
|
627
|
+
);
|
|
628
|
+
this.logger?.error?.(mastraError.toString());
|
|
629
|
+
this.logger?.trackException(mastraError);
|
|
630
|
+
return [];
|
|
631
|
+
}
|
|
632
|
+
}
|
|
593
633
|
async getMessagesPaginated(args) {
|
|
594
634
|
const { threadId, selectBy } = args;
|
|
595
635
|
const { page = 0, perPage: perPageInput } = selectBy?.pagination || {};
|
|
@@ -2189,6 +2229,12 @@ var MSSQLStore = class extends storage.MastraStorage {
|
|
|
2189
2229
|
async getMessages(args) {
|
|
2190
2230
|
return this.stores.memory.getMessages(args);
|
|
2191
2231
|
}
|
|
2232
|
+
async getMessagesById({
|
|
2233
|
+
messageIds,
|
|
2234
|
+
format
|
|
2235
|
+
}) {
|
|
2236
|
+
return this.stores.memory.getMessagesById({ messageIds, format });
|
|
2237
|
+
}
|
|
2192
2238
|
async getMessagesPaginated(args) {
|
|
2193
2239
|
return this.stores.memory.getMessagesPaginated(args);
|
|
2194
2240
|
}
|