@mastra/mongodb 1.8.0-alpha.0 → 1.8.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.8.0-alpha.0"};
15
+ version: "1.8.0"};
16
16
  var MongoDBFilterTranslator = class extends BaseFilterTranslator {
17
17
  getSupportedOperators() {
18
18
  return {
@@ -7605,7 +7605,9 @@ function scheduleToDoc(schedule) {
7605
7605
  last_run_id: schedule.lastRunId ?? null,
7606
7606
  created_at: schedule.createdAt,
7607
7607
  updated_at: schedule.updatedAt,
7608
- metadata: schedule.metadata ?? null
7608
+ metadata: schedule.metadata ?? null,
7609
+ owner_type: schedule.ownerType ?? null,
7610
+ owner_id: schedule.ownerId ?? null
7609
7611
  };
7610
7612
  }
7611
7613
  function docToSchedule(doc) {
@@ -7626,27 +7628,37 @@ function docToSchedule(doc) {
7626
7628
  if (doc.last_fire_at != null) schedule.lastFireAt = Number(doc.last_fire_at);
7627
7629
  if (doc.last_run_id != null) schedule.lastRunId = String(doc.last_run_id);
7628
7630
  if (doc.metadata != null) schedule.metadata = doc.metadata;
7631
+ if (doc.owner_type != null) schedule.ownerType = String(doc.owner_type);
7632
+ if (doc.owner_id != null) schedule.ownerId = String(doc.owner_id);
7629
7633
  return schedule;
7630
7634
  }
7631
7635
  function triggerToDoc(trigger) {
7632
7636
  return {
7637
+ id: trigger.id ?? crypto.randomUUID(),
7633
7638
  schedule_id: trigger.scheduleId,
7634
7639
  run_id: trigger.runId,
7635
7640
  scheduled_fire_at: trigger.scheduledFireAt,
7636
7641
  actual_fire_at: trigger.actualFireAt,
7637
- status: trigger.status,
7638
- error: trigger.error ?? null
7642
+ outcome: trigger.outcome,
7643
+ error: trigger.error ?? null,
7644
+ trigger_kind: trigger.triggerKind ?? "schedule-fire",
7645
+ parent_trigger_id: trigger.parentTriggerId ?? null,
7646
+ metadata: trigger.metadata ?? null
7639
7647
  };
7640
7648
  }
7641
7649
  function docToTrigger(doc) {
7642
7650
  const trigger = {
7651
+ id: doc.id != null ? String(doc.id) : void 0,
7643
7652
  scheduleId: String(doc.schedule_id),
7644
- runId: String(doc.run_id),
7653
+ runId: doc.run_id != null ? String(doc.run_id) : null,
7645
7654
  scheduledFireAt: Number(doc.scheduled_fire_at),
7646
7655
  actualFireAt: Number(doc.actual_fire_at),
7647
- status: String(doc.status)
7656
+ outcome: String(doc.outcome),
7657
+ triggerKind: doc.trigger_kind != null ? String(doc.trigger_kind) : "schedule-fire"
7648
7658
  };
7649
7659
  if (doc.error != null) trigger.error = String(doc.error);
7660
+ if (doc.parent_trigger_id != null) trigger.parentTriggerId = String(doc.parent_trigger_id);
7661
+ if (doc.metadata != null) trigger.metadata = doc.metadata;
7650
7662
  return trigger;
7651
7663
  }
7652
7664
  var SchedulesMongoDB = class _SchedulesMongoDB extends SchedulesStorage {
@@ -7673,8 +7685,10 @@ var SchedulesMongoDB = class _SchedulesMongoDB extends SchedulesStorage {
7673
7685
  { collection: TABLE_SCHEDULES, keys: { id: 1 }, options: { unique: true } },
7674
7686
  { collection: TABLE_SCHEDULES, keys: { status: 1, next_fire_at: 1 } },
7675
7687
  { collection: TABLE_SCHEDULES, keys: { "target.workflowId": 1 } },
7688
+ { collection: TABLE_SCHEDULES, keys: { owner_type: 1, owner_id: 1 } },
7689
+ { collection: TABLE_SCHEDULE_TRIGGERS, keys: { id: 1 }, options: { unique: true } },
7676
7690
  { collection: TABLE_SCHEDULE_TRIGGERS, keys: { schedule_id: 1, actual_fire_at: -1 } },
7677
- { collection: TABLE_SCHEDULE_TRIGGERS, keys: { run_id: 1 }, options: { unique: true } }
7691
+ { collection: TABLE_SCHEDULE_TRIGGERS, keys: { parent_trigger_id: 1 } }
7678
7692
  ];
7679
7693
  }
7680
7694
  async createDefaultIndexes() {
@@ -7727,6 +7741,12 @@ var SchedulesMongoDB = class _SchedulesMongoDB extends SchedulesStorage {
7727
7741
  const query = {};
7728
7742
  if (filter?.status) query.status = filter.status;
7729
7743
  if (filter?.workflowId) query["target.workflowId"] = filter.workflowId;
7744
+ if (filter?.ownerType !== void 0) {
7745
+ query.owner_type = filter.ownerType === null ? null : filter.ownerType;
7746
+ }
7747
+ if (filter?.ownerId !== void 0) {
7748
+ query.owner_id = filter.ownerId === null ? null : filter.ownerId;
7749
+ }
7730
7750
  const collection = await this.getSchedulesCollection();
7731
7751
  const docs = await collection.find(query).sort({ created_at: 1 }).toArray();
7732
7752
  return docs.map(docToSchedule);
@@ -7745,6 +7765,8 @@ var SchedulesMongoDB = class _SchedulesMongoDB extends SchedulesStorage {
7745
7765
  if ("nextFireAt" in patch && patch.nextFireAt !== void 0) $set.next_fire_at = patch.nextFireAt;
7746
7766
  if ("target" in patch && patch.target !== void 0) $set.target = patch.target;
7747
7767
  if ("metadata" in patch) $set.metadata = patch.metadata ?? null;
7768
+ if ("ownerType" in patch) $set.owner_type = patch.ownerType ?? null;
7769
+ if ("ownerId" in patch) $set.owner_id = patch.ownerId ?? null;
7748
7770
  $set.updated_at = Date.now();
7749
7771
  const collection = await this.getSchedulesCollection();
7750
7772
  const result = await collection.findOneAndUpdate({ id }, { $set }, { returnDocument: "after" });