@mastra/mongodb 1.6.2 → 1.7.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/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import { saveScorePayloadSchema } from '@mastra/core/evals';
12
12
 
13
13
  // package.json
14
14
  var package_default = {
15
- version: "1.6.2"};
15
+ version: "1.7.0"};
16
16
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
17
17
  getSupportedOperators() {
18
18
  return {
@@ -5264,11 +5264,22 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends MemoryStorage {
5264
5264
  );
5265
5265
  }
5266
5266
  }
5267
- async getObservationalMemoryHistory(threadId, resourceId, limit = 10) {
5267
+ async getObservationalMemoryHistory(threadId, resourceId, limit = 10, options) {
5268
5268
  try {
5269
5269
  const lookupKey = this.getOMKey(threadId, resourceId);
5270
5270
  const collection = await this.getCollection(OM_TABLE);
5271
- const docs = await collection.find({ lookupKey }).sort({ generationCount: -1 }).limit(limit).toArray();
5271
+ const filter = { lookupKey };
5272
+ if (options?.from || options?.to) {
5273
+ const createdAtFilter = {};
5274
+ if (options.from) createdAtFilter["$gte"] = options.from;
5275
+ if (options.to) createdAtFilter["$lte"] = options.to;
5276
+ filter["createdAt"] = createdAtFilter;
5277
+ }
5278
+ let cursor = collection.find(filter).sort({ generationCount: -1 });
5279
+ if (options?.offset != null) {
5280
+ cursor = cursor.skip(options.offset);
5281
+ }
5282
+ const docs = await cursor.limit(limit).toArray();
5272
5283
  return docs.map((doc) => this.parseOMDocument(doc));
5273
5284
  } catch (error) {
5274
5285
  throw new MastraError(
@@ -5694,6 +5705,37 @@ var MemoryStorageMongoDB = class _MemoryStorageMongoDB extends MemoryStorage {
5694
5705
  );
5695
5706
  }
5696
5707
  }
5708
+ async updateObservationalMemoryConfig(input) {
5709
+ try {
5710
+ const collection = await this.getCollection(OM_TABLE);
5711
+ const doc = await collection.findOne({ id: input.id }, { projection: { config: 1 } });
5712
+ if (!doc) {
5713
+ throw new MastraError({
5714
+ id: createStorageErrorId("MONGODB", "UPDATE_OM_CONFIG", "NOT_FOUND"),
5715
+ text: `Observational memory record not found: ${input.id}`,
5716
+ domain: ErrorDomain.STORAGE,
5717
+ category: ErrorCategory.THIRD_PARTY,
5718
+ details: { id: input.id }
5719
+ });
5720
+ }
5721
+ const existing = doc.config ?? {};
5722
+ const merged = this.deepMergeConfig(existing, input.config);
5723
+ await collection.updateOne({ id: input.id }, { $set: { config: merged, updatedAt: /* @__PURE__ */ new Date() } });
5724
+ } catch (error) {
5725
+ if (error instanceof MastraError) {
5726
+ throw error;
5727
+ }
5728
+ throw new MastraError(
5729
+ {
5730
+ id: createStorageErrorId("MONGODB", "UPDATE_OM_CONFIG", "FAILED"),
5731
+ domain: ErrorDomain.STORAGE,
5732
+ category: ErrorCategory.THIRD_PARTY,
5733
+ details: { id: input.id }
5734
+ },
5735
+ error
5736
+ );
5737
+ }
5738
+ }
5697
5739
  // ============================================
5698
5740
  // Async Buffering Methods
5699
5741
  // ============================================