@mastra/mongodb 1.9.0 → 1.9.1
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 +34 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-working-memory.md +29 -2
- package/dist/docs/references/docs-rag-retrieval.md +15 -12
- package/dist/docs/references/reference-storage-mongodb.md +4 -1
- package/dist/docs/references/reference-vectors-mongodb.md +1 -1
- package/dist/index.cjs +292 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +293 -3
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/notifications/index.d.ts +24 -0
- package/dist/storage/domains/notifications/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 } from '@lukeed/uuid';
|
|
2
2
|
import { MastraError, ErrorCategory, ErrorDomain } from '@mastra/core/error';
|
|
3
|
-
import { createVectorErrorId, AgentsStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_BACKGROUND_TASKS, BlobStore, TABLE_SKILL_BLOBS, DatasetsStorage, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, ensureDate, safelyParseJSON, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, ExperimentsStorage, MCPClientsStorage, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, MCPServersStorage, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, ObservabilityStorage, TABLE_SPANS, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, SchedulesStorage, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, ScorerDefinitionsStorage, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, TABLE_SCORERS, SkillsStorage, TABLE_SKILLS, TABLE_SKILL_VERSIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, WorkspacesStorage, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, MastraCompositeStore, TraceStatus, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
|
|
3
|
+
import { createVectorErrorId, AgentsStorage, TABLE_AGENTS, TABLE_AGENT_VERSIONS, createStorageErrorId, normalizePerPage, calculatePagination, BackgroundTasksStorage, TABLE_BACKGROUND_TASKS, BlobStore, TABLE_SKILL_BLOBS, DatasetsStorage, TABLE_DATASETS, TABLE_DATASET_ITEMS, TABLE_DATASET_VERSIONS, ensureDate, safelyParseJSON, TABLE_EXPERIMENTS, TABLE_EXPERIMENT_RESULTS, ExperimentsStorage, MCPClientsStorage, TABLE_MCP_CLIENTS, TABLE_MCP_CLIENT_VERSIONS, MCPServersStorage, TABLE_MCP_SERVERS, TABLE_MCP_SERVER_VERSIONS, MemoryStorage, TABLE_THREADS, TABLE_MESSAGES, TABLE_RESOURCES, NotificationsStorage, TABLE_NOTIFICATIONS, ObservabilityStorage, TABLE_SPANS, listTracesArgsSchema, toTraceSpans, PromptBlocksStorage, TABLE_PROMPT_BLOCKS, TABLE_PROMPT_BLOCK_VERSIONS, SchedulesStorage, TABLE_SCHEDULES, TABLE_SCHEDULE_TRIGGERS, ScorerDefinitionsStorage, TABLE_SCORER_DEFINITIONS, TABLE_SCORER_DEFINITION_VERSIONS, ScoresStorage, TABLE_SCORERS, SkillsStorage, TABLE_SKILLS, TABLE_SKILL_VERSIONS, WorkflowsStorage, TABLE_WORKFLOW_SNAPSHOT, WorkspacesStorage, TABLE_WORKSPACES, TABLE_WORKSPACE_VERSIONS, MastraCompositeStore, TraceStatus, transformScoreRow as transformScoreRow$1 } from '@mastra/core/storage';
|
|
4
4
|
import { MastraVector, validateUpsertInput, validateVectorValues } from '@mastra/core/vector';
|
|
5
5
|
import { MongoClient } from 'mongodb';
|
|
6
6
|
import { BaseFilterTranslator } from '@mastra/core/vector/filter';
|
|
@@ -12,7 +12,7 @@ import { saveScorePayloadSchema } from '@mastra/core/evals';
|
|
|
12
12
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
|
-
version: "1.9.
|
|
15
|
+
version: "1.9.1"};
|
|
16
16
|
var MongoDBFilterTranslator = class extends BaseFilterTranslator {
|
|
17
17
|
getSupportedOperators() {
|
|
18
18
|
return {
|
|
@@ -6285,6 +6285,294 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
6285
6285
|
}
|
|
6286
6286
|
}
|
|
6287
6287
|
};
|
|
6288
|
+
var statusTimestamp = (status, now) => {
|
|
6289
|
+
if (status === "delivered") return { deliveredAt: now };
|
|
6290
|
+
if (status === "seen") return { seenAt: now };
|
|
6291
|
+
if (status === "dismissed") return { dismissedAt: now };
|
|
6292
|
+
if (status === "archived") return { archivedAt: now };
|
|
6293
|
+
if (status === "discarded") return { discardedAt: now };
|
|
6294
|
+
return {};
|
|
6295
|
+
};
|
|
6296
|
+
var cloneDate = (value) => value ? new Date(value) : void 0;
|
|
6297
|
+
var cloneValue = (value) => value === void 0 ? void 0 : structuredClone(value);
|
|
6298
|
+
var cloneRecord = (record) => ({
|
|
6299
|
+
...record,
|
|
6300
|
+
createdAt: new Date(record.createdAt),
|
|
6301
|
+
updatedAt: new Date(record.updatedAt),
|
|
6302
|
+
deliveredAt: cloneDate(record.deliveredAt),
|
|
6303
|
+
seenAt: cloneDate(record.seenAt),
|
|
6304
|
+
dismissedAt: cloneDate(record.dismissedAt),
|
|
6305
|
+
archivedAt: cloneDate(record.archivedAt),
|
|
6306
|
+
discardedAt: cloneDate(record.discardedAt),
|
|
6307
|
+
deliverAt: cloneDate(record.deliverAt),
|
|
6308
|
+
summaryAt: cloneDate(record.summaryAt),
|
|
6309
|
+
lastDeliveryAttemptAt: cloneDate(record.lastDeliveryAttemptAt),
|
|
6310
|
+
payload: cloneValue(record.payload),
|
|
6311
|
+
attributes: cloneValue(record.attributes),
|
|
6312
|
+
metadata: cloneValue(record.metadata)
|
|
6313
|
+
});
|
|
6314
|
+
function rowToNotification(row) {
|
|
6315
|
+
return {
|
|
6316
|
+
id: row.id,
|
|
6317
|
+
threadId: row.threadId,
|
|
6318
|
+
source: row.source,
|
|
6319
|
+
kind: row.kind,
|
|
6320
|
+
priority: row.priority,
|
|
6321
|
+
status: row.status,
|
|
6322
|
+
summary: row.summary,
|
|
6323
|
+
payload: row.payload ?? void 0,
|
|
6324
|
+
resourceId: row.resourceId ?? void 0,
|
|
6325
|
+
agentId: row.agentId ?? void 0,
|
|
6326
|
+
sourceId: row.sourceId ?? void 0,
|
|
6327
|
+
dedupeKey: row.dedupeKey ?? void 0,
|
|
6328
|
+
coalesceKey: row.coalesceKey ?? void 0,
|
|
6329
|
+
coalescedCount: Number(row.coalescedCount ?? 1),
|
|
6330
|
+
attributes: row.attributes,
|
|
6331
|
+
createdAt: row.createdAt instanceof Date ? row.createdAt : new Date(row.createdAt),
|
|
6332
|
+
updatedAt: row.updatedAt instanceof Date ? row.updatedAt : new Date(row.updatedAt),
|
|
6333
|
+
deliveredAt: row.deliveredAt ? row.deliveredAt instanceof Date ? row.deliveredAt : new Date(row.deliveredAt) : void 0,
|
|
6334
|
+
seenAt: row.seenAt ? row.seenAt instanceof Date ? row.seenAt : new Date(row.seenAt) : void 0,
|
|
6335
|
+
dismissedAt: row.dismissedAt ? row.dismissedAt instanceof Date ? row.dismissedAt : new Date(row.dismissedAt) : void 0,
|
|
6336
|
+
archivedAt: row.archivedAt ? row.archivedAt instanceof Date ? row.archivedAt : new Date(row.archivedAt) : void 0,
|
|
6337
|
+
discardedAt: row.discardedAt ? row.discardedAt instanceof Date ? row.discardedAt : new Date(row.discardedAt) : void 0,
|
|
6338
|
+
deliverAt: row.deliverAt ? row.deliverAt instanceof Date ? row.deliverAt : new Date(row.deliverAt) : void 0,
|
|
6339
|
+
summaryAt: row.summaryAt ? row.summaryAt instanceof Date ? row.summaryAt : new Date(row.summaryAt) : void 0,
|
|
6340
|
+
deliveryReason: row.deliveryReason ?? void 0,
|
|
6341
|
+
deliveryAttempts: Number(row.deliveryAttempts ?? 0),
|
|
6342
|
+
lastDeliveryAttemptAt: row.lastDeliveryAttemptAt ? row.lastDeliveryAttemptAt instanceof Date ? row.lastDeliveryAttemptAt : new Date(row.lastDeliveryAttemptAt) : void 0,
|
|
6343
|
+
lastDeliveryError: row.lastDeliveryError ?? void 0,
|
|
6344
|
+
deliveredSignalId: row.deliveredSignalId ?? void 0,
|
|
6345
|
+
summarySignalId: row.summarySignalId ?? void 0,
|
|
6346
|
+
metadata: row.metadata ?? void 0
|
|
6347
|
+
};
|
|
6348
|
+
}
|
|
6349
|
+
function recordToDocument(record) {
|
|
6350
|
+
return {
|
|
6351
|
+
...record,
|
|
6352
|
+
payload: record.payload ?? null,
|
|
6353
|
+
resourceId: record.resourceId ?? null,
|
|
6354
|
+
agentId: record.agentId ?? null,
|
|
6355
|
+
sourceId: record.sourceId ?? null,
|
|
6356
|
+
dedupeKey: record.dedupeKey ?? null,
|
|
6357
|
+
coalesceKey: record.coalesceKey ?? null,
|
|
6358
|
+
attributes: record.attributes ?? null,
|
|
6359
|
+
deliveredAt: record.deliveredAt ?? null,
|
|
6360
|
+
seenAt: record.seenAt ?? null,
|
|
6361
|
+
dismissedAt: record.dismissedAt ?? null,
|
|
6362
|
+
archivedAt: record.archivedAt ?? null,
|
|
6363
|
+
discardedAt: record.discardedAt ?? null,
|
|
6364
|
+
deliverAt: record.deliverAt ?? null,
|
|
6365
|
+
summaryAt: record.summaryAt ?? null,
|
|
6366
|
+
deliveryReason: record.deliveryReason ?? null,
|
|
6367
|
+
lastDeliveryAttemptAt: record.lastDeliveryAttemptAt ?? null,
|
|
6368
|
+
lastDeliveryError: record.lastDeliveryError ?? null,
|
|
6369
|
+
deliveredSignalId: record.deliveredSignalId ?? null,
|
|
6370
|
+
summarySignalId: record.summarySignalId ?? null,
|
|
6371
|
+
metadata: record.metadata ?? null
|
|
6372
|
+
};
|
|
6373
|
+
}
|
|
6374
|
+
var NotificationsMongoDB = class _NotificationsMongoDB extends NotificationsStorage {
|
|
6375
|
+
#connector;
|
|
6376
|
+
#skipDefaultIndexes;
|
|
6377
|
+
#indexes;
|
|
6378
|
+
static MANAGED_COLLECTIONS = [TABLE_NOTIFICATIONS];
|
|
6379
|
+
constructor(config) {
|
|
6380
|
+
super();
|
|
6381
|
+
this.#connector = resolveMongoDBConfig(config);
|
|
6382
|
+
this.#skipDefaultIndexes = config.skipDefaultIndexes;
|
|
6383
|
+
this.#indexes = config.indexes?.filter(
|
|
6384
|
+
(idx) => _NotificationsMongoDB.MANAGED_COLLECTIONS.includes(idx.collection)
|
|
6385
|
+
);
|
|
6386
|
+
}
|
|
6387
|
+
async getCollection() {
|
|
6388
|
+
return this.#connector.getCollection(TABLE_NOTIFICATIONS);
|
|
6389
|
+
}
|
|
6390
|
+
async init() {
|
|
6391
|
+
await this.createDefaultIndexes();
|
|
6392
|
+
await this.createCustomIndexes();
|
|
6393
|
+
}
|
|
6394
|
+
getDefaultIndexDefinitions() {
|
|
6395
|
+
return [
|
|
6396
|
+
{ collection: TABLE_NOTIFICATIONS, keys: { threadId: 1, id: 1 }, options: { unique: true } },
|
|
6397
|
+
{ collection: TABLE_NOTIFICATIONS, keys: { threadId: 1, status: 1, updatedAt: -1 } },
|
|
6398
|
+
{
|
|
6399
|
+
collection: TABLE_NOTIFICATIONS,
|
|
6400
|
+
keys: { threadId: 1, source: 1, kind: 1, status: 1, agentId: 1, resourceId: 1, dedupeKey: 1, coalesceKey: 1 }
|
|
6401
|
+
},
|
|
6402
|
+
{ collection: TABLE_NOTIFICATIONS, keys: { status: 1, deliverAt: 1, summaryAt: 1 } }
|
|
6403
|
+
];
|
|
6404
|
+
}
|
|
6405
|
+
async createDefaultIndexes() {
|
|
6406
|
+
if (this.#skipDefaultIndexes) return;
|
|
6407
|
+
for (const indexDef of this.getDefaultIndexDefinitions()) {
|
|
6408
|
+
try {
|
|
6409
|
+
const collection = await this.#connector.getCollection(indexDef.collection);
|
|
6410
|
+
await collection.createIndex(indexDef.keys, indexDef.options);
|
|
6411
|
+
} catch (error) {
|
|
6412
|
+
this.logger?.warn?.(`Failed to create index on ${indexDef.collection}:`, error);
|
|
6413
|
+
}
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6416
|
+
async createCustomIndexes() {
|
|
6417
|
+
if (!this.#indexes || this.#indexes.length === 0) return;
|
|
6418
|
+
for (const indexDef of this.#indexes) {
|
|
6419
|
+
try {
|
|
6420
|
+
const collection = await this.#connector.getCollection(indexDef.collection);
|
|
6421
|
+
await collection.createIndex(indexDef.keys, indexDef.options);
|
|
6422
|
+
} catch (error) {
|
|
6423
|
+
this.logger?.warn?.(`Failed to create custom index on ${indexDef.collection}:`, error);
|
|
6424
|
+
}
|
|
6425
|
+
}
|
|
6426
|
+
}
|
|
6427
|
+
async dangerouslyClearAll() {
|
|
6428
|
+
const collection = await this.getCollection();
|
|
6429
|
+
await collection.deleteMany({});
|
|
6430
|
+
}
|
|
6431
|
+
async createNotification(input) {
|
|
6432
|
+
const existing = await this.findCoalescable(input);
|
|
6433
|
+
const collection = await this.getCollection();
|
|
6434
|
+
if (existing) {
|
|
6435
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
6436
|
+
const attributes = input.attributes ? { ...cloneValue(existing.attributes), ...cloneValue(input.attributes) } : cloneValue(existing.attributes);
|
|
6437
|
+
const metadata = input.metadata ? { ...cloneValue(existing.metadata), ...cloneValue(input.metadata) } : cloneValue(existing.metadata);
|
|
6438
|
+
await collection.updateOne(
|
|
6439
|
+
{ threadId: existing.threadId, id: existing.id },
|
|
6440
|
+
{
|
|
6441
|
+
$set: {
|
|
6442
|
+
summary: input.summary,
|
|
6443
|
+
payload: cloneValue(input.payload ?? existing.payload) ?? null,
|
|
6444
|
+
priority: input.priority ?? existing.priority,
|
|
6445
|
+
attributes: attributes ?? null,
|
|
6446
|
+
updatedAt: now2,
|
|
6447
|
+
deliverAt: input.deliverAt ?? existing.deliverAt ?? null,
|
|
6448
|
+
summaryAt: input.summaryAt ?? existing.summaryAt ?? null,
|
|
6449
|
+
deliveryReason: input.deliveryReason ?? existing.deliveryReason ?? null,
|
|
6450
|
+
metadata: metadata ?? null
|
|
6451
|
+
},
|
|
6452
|
+
$inc: { coalescedCount: 1 }
|
|
6453
|
+
}
|
|
6454
|
+
);
|
|
6455
|
+
const updated = await this.getNotification({ threadId: existing.threadId, id: existing.id });
|
|
6456
|
+
if (!updated) throw new Error(`Notification ${existing.id} was not found for thread ${existing.threadId}`);
|
|
6457
|
+
return updated;
|
|
6458
|
+
}
|
|
6459
|
+
const now = input.createdAt ?? /* @__PURE__ */ new Date();
|
|
6460
|
+
const record = {
|
|
6461
|
+
id: input.id ?? randomUUID(),
|
|
6462
|
+
threadId: input.threadId,
|
|
6463
|
+
source: input.source,
|
|
6464
|
+
kind: input.kind,
|
|
6465
|
+
priority: input.priority ?? "medium",
|
|
6466
|
+
status: "pending",
|
|
6467
|
+
summary: input.summary,
|
|
6468
|
+
payload: cloneValue(input.payload),
|
|
6469
|
+
resourceId: input.resourceId,
|
|
6470
|
+
agentId: input.agentId,
|
|
6471
|
+
sourceId: input.sourceId,
|
|
6472
|
+
dedupeKey: input.dedupeKey,
|
|
6473
|
+
coalesceKey: input.coalesceKey,
|
|
6474
|
+
coalescedCount: 1,
|
|
6475
|
+
attributes: cloneValue(input.attributes),
|
|
6476
|
+
createdAt: now,
|
|
6477
|
+
updatedAt: now,
|
|
6478
|
+
deliverAt: input.deliverAt,
|
|
6479
|
+
summaryAt: input.summaryAt,
|
|
6480
|
+
deliveryReason: input.deliveryReason,
|
|
6481
|
+
deliveryAttempts: 0,
|
|
6482
|
+
metadata: cloneValue(input.metadata)
|
|
6483
|
+
};
|
|
6484
|
+
await collection.insertOne(recordToDocument(record));
|
|
6485
|
+
return cloneRecord(record);
|
|
6486
|
+
}
|
|
6487
|
+
async listNotifications(input) {
|
|
6488
|
+
const filter = { threadId: input.threadId };
|
|
6489
|
+
if (input.status) filter.status = Array.isArray(input.status) ? { $in: input.status } : input.status;
|
|
6490
|
+
if (input.priority) filter.priority = Array.isArray(input.priority) ? { $in: input.priority } : input.priority;
|
|
6491
|
+
if (input.source) filter.source = input.source;
|
|
6492
|
+
if (input.resourceId) filter.resourceId = input.resourceId;
|
|
6493
|
+
if (input.agentId) filter.agentId = input.agentId;
|
|
6494
|
+
if (input.search) {
|
|
6495
|
+
const search = input.search.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6496
|
+
filter.$or = [{ summary: { $regex: search, $options: "i" } }, { kind: { $regex: search, $options: "i" } }];
|
|
6497
|
+
}
|
|
6498
|
+
const collection = await this.getCollection();
|
|
6499
|
+
const cursor = collection.find(filter).sort({ updatedAt: -1 });
|
|
6500
|
+
if (input.limit) cursor.limit(input.limit);
|
|
6501
|
+
const rows = await cursor.toArray();
|
|
6502
|
+
return rows.map((row) => rowToNotification(row));
|
|
6503
|
+
}
|
|
6504
|
+
async listDueNotifications(input) {
|
|
6505
|
+
const filter = {
|
|
6506
|
+
status: "pending",
|
|
6507
|
+
$or: [{ deliverAt: { $ne: null, $lte: input.now } }, { summaryAt: { $ne: null, $lte: input.now } }]
|
|
6508
|
+
};
|
|
6509
|
+
if (input.agentId) filter.agentId = input.agentId;
|
|
6510
|
+
if (input.resourceId) filter.resourceId = input.resourceId;
|
|
6511
|
+
const collection = await this.getCollection();
|
|
6512
|
+
const rows = await collection.find(filter).sort({ updatedAt: 1 }).toArray();
|
|
6513
|
+
const due = rows.map((row) => rowToNotification(row)).sort((a, b) => dueTime(a) - dueTime(b) || a.updatedAt.getTime() - b.updatedAt.getTime());
|
|
6514
|
+
return due.slice(0, input.limit ?? due.length).map(cloneRecord);
|
|
6515
|
+
}
|
|
6516
|
+
async getNotification(input) {
|
|
6517
|
+
const collection = await this.getCollection();
|
|
6518
|
+
const row = await collection.findOne({ threadId: input.threadId, id: input.id });
|
|
6519
|
+
return row ? rowToNotification(row) : null;
|
|
6520
|
+
}
|
|
6521
|
+
async updateNotification(input) {
|
|
6522
|
+
const existing = await this.getNotification({ threadId: input.threadId, id: input.id });
|
|
6523
|
+
if (!existing) {
|
|
6524
|
+
throw new Error(`Notification ${input.id} was not found for thread ${input.threadId}`);
|
|
6525
|
+
}
|
|
6526
|
+
const now = /* @__PURE__ */ new Date();
|
|
6527
|
+
const set = {
|
|
6528
|
+
...input.status ? { status: input.status, ...statusTimestamp(input.status, now) } : {},
|
|
6529
|
+
...input.summary !== void 0 ? { summary: input.summary } : {},
|
|
6530
|
+
...input.payload !== void 0 ? { payload: cloneValue(input.payload) } : {},
|
|
6531
|
+
...input.attributes !== void 0 ? { attributes: cloneValue(input.attributes) } : {},
|
|
6532
|
+
...input.metadata !== void 0 ? { metadata: cloneValue(input.metadata) } : {},
|
|
6533
|
+
...input.deliverAt !== void 0 ? { deliverAt: input.deliverAt } : {},
|
|
6534
|
+
...input.summaryAt !== void 0 ? { summaryAt: input.summaryAt } : {},
|
|
6535
|
+
...input.deliveryReason !== void 0 ? { deliveryReason: input.deliveryReason } : {},
|
|
6536
|
+
...input.deliveryAttempts !== void 0 ? { deliveryAttempts: input.deliveryAttempts } : {},
|
|
6537
|
+
...input.lastDeliveryAttemptAt !== void 0 ? { lastDeliveryAttemptAt: input.lastDeliveryAttemptAt } : {},
|
|
6538
|
+
...input.lastDeliveryError !== void 0 ? { lastDeliveryError: input.lastDeliveryError } : {},
|
|
6539
|
+
...input.deliveredSignalId !== void 0 ? { deliveredSignalId: input.deliveredSignalId } : {},
|
|
6540
|
+
...input.summarySignalId !== void 0 ? { summarySignalId: input.summarySignalId } : {},
|
|
6541
|
+
updatedAt: now
|
|
6542
|
+
};
|
|
6543
|
+
const collection = await this.getCollection();
|
|
6544
|
+
await collection.updateOne({ threadId: input.threadId, id: input.id }, { $set: set });
|
|
6545
|
+
const updated = await this.getNotification({ threadId: input.threadId, id: input.id });
|
|
6546
|
+
if (!updated) throw new Error(`Notification ${input.id} was not found for thread ${input.threadId}`);
|
|
6547
|
+
return updated;
|
|
6548
|
+
}
|
|
6549
|
+
async findCoalescable(input) {
|
|
6550
|
+
if (!input.dedupeKey && !input.coalesceKey) return void 0;
|
|
6551
|
+
const collection = await this.getCollection();
|
|
6552
|
+
const row = await collection.findOne(
|
|
6553
|
+
{
|
|
6554
|
+
threadId: input.threadId,
|
|
6555
|
+
source: input.source,
|
|
6556
|
+
kind: input.kind,
|
|
6557
|
+
status: "pending",
|
|
6558
|
+
agentId: input.agentId ?? null,
|
|
6559
|
+
resourceId: input.resourceId ?? null,
|
|
6560
|
+
$or: [
|
|
6561
|
+
...input.dedupeKey ? [{ dedupeKey: input.dedupeKey }] : [],
|
|
6562
|
+
...input.coalesceKey ? [{ coalesceKey: input.coalesceKey }] : []
|
|
6563
|
+
]
|
|
6564
|
+
},
|
|
6565
|
+
{ sort: { updatedAt: -1 } }
|
|
6566
|
+
);
|
|
6567
|
+
return row ? rowToNotification(row) : void 0;
|
|
6568
|
+
}
|
|
6569
|
+
};
|
|
6570
|
+
var dueTime = (record) => {
|
|
6571
|
+
const deliverAt = record.deliverAt?.getTime();
|
|
6572
|
+
const summaryAt = record.summaryAt?.getTime();
|
|
6573
|
+
if (deliverAt !== void 0 && summaryAt !== void 0) return Math.min(deliverAt, summaryAt);
|
|
6574
|
+
return deliverAt ?? summaryAt ?? Number.POSITIVE_INFINITY;
|
|
6575
|
+
};
|
|
6288
6576
|
var ObservabilityMongoDB = class _ObservabilityMongoDB extends ObservabilityStorage {
|
|
6289
6577
|
#connector;
|
|
6290
6578
|
#skipDefaultIndexes;
|
|
@@ -10349,6 +10637,7 @@ var MongoDBStore = class extends MastraCompositeStore {
|
|
|
10349
10637
|
indexes: config.indexes
|
|
10350
10638
|
};
|
|
10351
10639
|
const memory = new MemoryStorageMongoDB(domainConfig);
|
|
10640
|
+
const notifications = new NotificationsMongoDB(domainConfig);
|
|
10352
10641
|
const scores = new ScoresStorageMongoDB(domainConfig);
|
|
10353
10642
|
const workflows = new WorkflowsStorageMongoDB(domainConfig);
|
|
10354
10643
|
const observability = new ObservabilityMongoDB(domainConfig);
|
|
@@ -10366,6 +10655,7 @@ var MongoDBStore = class extends MastraCompositeStore {
|
|
|
10366
10655
|
const schedules = new SchedulesMongoDB(domainConfig);
|
|
10367
10656
|
this.stores = {
|
|
10368
10657
|
memory,
|
|
10658
|
+
notifications,
|
|
10369
10659
|
scores,
|
|
10370
10660
|
workflows,
|
|
10371
10661
|
observability,
|
|
@@ -10499,6 +10789,6 @@ Example Complex Query:
|
|
|
10499
10789
|
]
|
|
10500
10790
|
}`;
|
|
10501
10791
|
|
|
10502
|
-
export { BackgroundTasksStorageMongoDB, MONGODB_PROMPT, MemoryStorageMongoDB, MongoDBAgentsStorage, MongoDBBlobStore, MongoDBDatasetsStorage, MongoDBExperimentsStorage, MongoDBMCPClientsStorage, MongoDBMCPServersStorage, MongoDBPromptBlocksStorage, MongoDBScorerDefinitionsStorage, MongoDBSkillsStorage, MongoDBStore, MongoDBVector, MongoDBWorkspacesStorage, ObservabilityMongoDB, SchedulesMongoDB, ScoresStorageMongoDB, WorkflowsStorageMongoDB };
|
|
10792
|
+
export { BackgroundTasksStorageMongoDB, MONGODB_PROMPT, MemoryStorageMongoDB, MongoDBAgentsStorage, MongoDBBlobStore, MongoDBDatasetsStorage, MongoDBExperimentsStorage, MongoDBMCPClientsStorage, MongoDBMCPServersStorage, MongoDBPromptBlocksStorage, MongoDBScorerDefinitionsStorage, MongoDBSkillsStorage, MongoDBStore, MongoDBVector, MongoDBWorkspacesStorage, NotificationsMongoDB, ObservabilityMongoDB, SchedulesMongoDB, ScoresStorageMongoDB, WorkflowsStorageMongoDB };
|
|
10503
10793
|
//# sourceMappingURL=index.js.map
|
|
10504
10794
|
//# sourceMappingURL=index.js.map
|