@mastra/libsql 0.13.3 → 0.13.4

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/dist/index.js CHANGED
@@ -1155,6 +1155,42 @@ var MemoryLibSQL = class extends MemoryStorage {
1155
1155
  );
1156
1156
  }
1157
1157
  }
1158
+ async getMessagesById({
1159
+ messageIds,
1160
+ format
1161
+ }) {
1162
+ if (messageIds.length === 0) return [];
1163
+ try {
1164
+ const sql = `
1165
+ SELECT
1166
+ id,
1167
+ content,
1168
+ role,
1169
+ type,
1170
+ "createdAt",
1171
+ thread_id,
1172
+ "resourceId"
1173
+ FROM "${TABLE_MESSAGES}"
1174
+ WHERE id IN (${messageIds.map(() => "?").join(", ")})
1175
+ ORDER BY "createdAt" DESC
1176
+ `;
1177
+ const result = await this.client.execute({ sql, args: messageIds });
1178
+ if (!result.rows) return [];
1179
+ const list = new MessageList().add(result.rows.map(this.parseRow), "memory");
1180
+ if (format === `v1`) return list.get.all.v1();
1181
+ return list.get.all.v2();
1182
+ } catch (error) {
1183
+ throw new MastraError(
1184
+ {
1185
+ id: "LIBSQL_STORE_GET_MESSAGES_BY_ID_FAILED",
1186
+ domain: ErrorDomain.STORAGE,
1187
+ category: ErrorCategory.THIRD_PARTY,
1188
+ details: { messageIds: JSON.stringify(messageIds) }
1189
+ },
1190
+ error
1191
+ );
1192
+ }
1193
+ }
1158
1194
  async getMessagesPaginated(args) {
1159
1195
  const { threadId, format, selectBy } = args;
1160
1196
  const { page = 0, perPage: perPageInput, dateRange } = selectBy?.pagination || {};
@@ -2603,6 +2639,12 @@ var LibSQLStore = class extends MastraStorage {
2603
2639
  }) {
2604
2640
  return this.stores.memory.getMessages({ threadId, selectBy, format });
2605
2641
  }
2642
+ async getMessagesById({
2643
+ messageIds,
2644
+ format
2645
+ }) {
2646
+ return this.stores.memory.getMessagesById({ messageIds, format });
2647
+ }
2606
2648
  async getMessagesPaginated(args) {
2607
2649
  return this.stores.memory.getMessagesPaginated(args);
2608
2650
  }