@mastra/lance 0.2.6 → 0.2.7-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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @mastra/lance@0.2.6-alpha.0 build /home/runner/work/mastra/mastra/stores/lance
2
+ > @mastra/lance@0.2.7-alpha.0 build /home/runner/work/mastra/mastra/stores/lance
3
3
  > tsup --silent --config tsup.config.ts
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/lance
2
2
 
3
+ ## 0.2.7-alpha.0
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), [`a5a23d9`](https://github.com/mastra-ai/mastra/commit/a5a23d981920d458dc6078919992a5338931ef02)]:
10
+ - @mastra/core@0.14.1-alpha.0
11
+
3
12
  ## 0.2.6
4
13
 
5
14
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -381,6 +381,20 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
381
381
  );
382
382
  }
383
383
  }
384
+ normalizeMessage(message) {
385
+ const { thread_id, ...rest } = message;
386
+ return {
387
+ ...rest,
388
+ threadId: thread_id,
389
+ content: typeof message.content === "string" ? (() => {
390
+ try {
391
+ return JSON.parse(message.content);
392
+ } catch {
393
+ return message.content;
394
+ }
395
+ })() : message.content
396
+ };
397
+ }
384
398
  async getMessages({
385
399
  threadId,
386
400
  resourceId,
@@ -421,21 +435,7 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
421
435
  allRecords,
422
436
  await getTableSchema({ tableName: storage.TABLE_MESSAGES, client: this.client })
423
437
  );
424
- const normalized = messages.map((msg) => {
425
- const { thread_id, ...rest } = msg;
426
- return {
427
- ...rest,
428
- threadId: thread_id,
429
- content: typeof msg.content === "string" ? (() => {
430
- try {
431
- return JSON.parse(msg.content);
432
- } catch {
433
- return msg.content;
434
- }
435
- })() : msg.content
436
- };
437
- });
438
- const list = new agent.MessageList({ threadId, resourceId }).add(normalized, "memory");
438
+ const list = new agent.MessageList({ threadId, resourceId }).add(messages.map(this.normalizeMessage), "memory");
439
439
  if (format === "v2") return list.get.all.v2();
440
440
  return list.get.all.v1();
441
441
  } catch (error$1) {
@@ -449,6 +449,36 @@ var StoreMemoryLance = class extends storage.MemoryStorage {
449
449
  );
450
450
  }
451
451
  }
452
+ async getMessagesById({
453
+ messageIds,
454
+ format
455
+ }) {
456
+ if (messageIds.length === 0) return [];
457
+ try {
458
+ const table = await this.client.openTable(storage.TABLE_MESSAGES);
459
+ const quotedIds = messageIds.map((id) => `'${id}'`).join(", ");
460
+ const allRecords = await table.query().where(`id IN (${quotedIds})`).toArray();
461
+ const messages = processResultWithTypeConversion(
462
+ allRecords,
463
+ await getTableSchema({ tableName: storage.TABLE_MESSAGES, client: this.client })
464
+ );
465
+ const list = new agent.MessageList().add(messages.map(this.normalizeMessage), "memory");
466
+ if (format === `v1`) return list.get.all.v1();
467
+ return list.get.all.v2();
468
+ } catch (error$1) {
469
+ throw new error.MastraError(
470
+ {
471
+ id: "LANCE_STORE_GET_MESSAGES_BY_ID_FAILED",
472
+ domain: error.ErrorDomain.STORAGE,
473
+ category: error.ErrorCategory.THIRD_PARTY,
474
+ details: {
475
+ messageIds: JSON.stringify(messageIds)
476
+ }
477
+ },
478
+ error$1
479
+ );
480
+ }
481
+ }
452
482
  async saveMessages(args) {
453
483
  try {
454
484
  const { messages, format = "v1" } = args;
@@ -2089,6 +2119,12 @@ var LanceStorage = class _LanceStorage extends storage.MastraStorage {
2089
2119
  }) {
2090
2120
  return this.stores.memory.getMessages({ threadId, resourceId, selectBy, format, threadConfig });
2091
2121
  }
2122
+ async getMessagesById({
2123
+ messageIds,
2124
+ format
2125
+ }) {
2126
+ return this.stores.memory.getMessagesById({ messageIds, format });
2127
+ }
2092
2128
  async saveMessages(args) {
2093
2129
  return this.stores.memory.saveMessages(args);
2094
2130
  }