@mastra/pg 1.10.0-alpha.0 → 1.10.0-alpha.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @mastra/pg
2
2
 
3
+ ## 1.10.0-alpha.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Extend the schedules storage schema to support owned schedules and richer trigger audit. This is a breaking schema change to `mastra_schedules` and `mastra_schedule_triggers`; scheduled workflows are still in alpha so no compat shim is provided. ([#16166](https://github.com/mastra-ai/mastra/pull/16166))
8
+ - `Schedule` gains optional `ownerType` / `ownerId` so a schedule row can be attributed to an owning subsystem (e.g. an agent that owns a heartbeat schedule). Workflow schedules leave both fields unset.
9
+ - `ScheduleTrigger.status` is renamed to `outcome` and the type is widened to `ScheduleTriggerOutcome` so future outcome values can be added without another rename.
10
+ - `ScheduleTrigger` gains a stable `id` primary key and new `triggerKind`, `parentTriggerId`, and `metadata` fields. `triggerKind` distinguishes `schedule-fire` rows from later `queue-drain` rows (used by upcoming heartbeat work); `parentTriggerId` links related rows; `metadata` carries outcome-specific context.
11
+ - The libsql, pg, and mongodb adapters all add the new columns/indexes. Their `@mastra/core` peer dependency is tightened to `>=1.32.0-0 <2.0.0-0` so installing a new storage adapter against an older core (or vice-versa) surfaces a peer-dependency warning at install time instead of silently writing/reading the wrong field.
12
+ - Scheduler producer, server schemas/handler, and client SDK types are updated to use the new fields. The `triggers` response on `GET /api/schedules/:id/triggers` now returns `outcome` instead of `status`.
13
+ - The bundled Studio (Mastra CLI) is updated to read `outcome` so the schedule detail page keeps polling and rendering publish-failure rows correctly.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`ca28c23`](https://github.com/mastra-ai/mastra/commit/ca28c232a2f18801a6cf20fe053479237b4d4fb0)]:
18
+ - @mastra/core@1.32.0-alpha.3
19
+
3
20
  ## 1.10.0-alpha.0
4
21
 
5
22
  ### Minor Changes
@@ -3,7 +3,7 @@ name: mastra-pg
3
3
  description: Documentation for @mastra/pg. Use when working with @mastra/pg APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/pg"
6
- version: "1.10.0-alpha.0"
6
+ version: "1.10.0-alpha.1"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.10.0-alpha.0",
2
+ "version": "1.10.0-alpha.1",
3
3
  "package": "@mastra/pg",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -11418,17 +11418,24 @@ function rowToSchedule(row) {
11418
11418
  if (row.last_run_id != null) schedule.lastRunId = String(row.last_run_id);
11419
11419
  const metadata = parseJson2(row.metadata);
11420
11420
  if (metadata !== void 0) schedule.metadata = metadata;
11421
+ if (row.owner_type != null) schedule.ownerType = String(row.owner_type);
11422
+ if (row.owner_id != null) schedule.ownerId = String(row.owner_id);
11421
11423
  return schedule;
11422
11424
  }
11423
11425
  function rowToTrigger(row) {
11424
11426
  const trigger = {
11427
+ id: row.id != null ? String(row.id) : void 0,
11425
11428
  scheduleId: String(row.schedule_id),
11426
- runId: String(row.run_id),
11429
+ runId: row.run_id != null ? String(row.run_id) : null,
11427
11430
  scheduledFireAt: toNumber(row.scheduled_fire_at),
11428
11431
  actualFireAt: toNumber(row.actual_fire_at),
11429
- status: String(row.status)
11432
+ outcome: String(row.outcome),
11433
+ triggerKind: row.trigger_kind != null ? String(row.trigger_kind) : "schedule-fire"
11430
11434
  };
11431
11435
  if (row.error != null) trigger.error = String(row.error);
11436
+ if (row.parent_trigger_id != null) trigger.parentTriggerId = String(row.parent_trigger_id);
11437
+ const metadata = parseJson2(row.metadata);
11438
+ if (metadata !== void 0) trigger.metadata = metadata;
11432
11439
  return trigger;
11433
11440
  }
11434
11441
  var SchedulesPG = class extends storage.SchedulesStorage {
@@ -11496,7 +11503,9 @@ var SchedulesPG = class extends storage.SchedulesStorage {
11496
11503
  last_run_id: schedule.lastRunId ?? null,
11497
11504
  created_at: schedule.createdAt,
11498
11505
  updated_at: schedule.updatedAt,
11499
- metadata: schedule.metadata ?? null
11506
+ metadata: schedule.metadata ?? null,
11507
+ owner_type: schedule.ownerType ?? null,
11508
+ owner_id: schedule.ownerId ?? null
11500
11509
  }
11501
11510
  });
11502
11511
  return schedule;
@@ -11519,6 +11528,22 @@ var SchedulesPG = class extends storage.SchedulesStorage {
11519
11528
  params.push(filter.workflowId);
11520
11529
  conditions.push(`target->>'workflowId' = $${params.length}`);
11521
11530
  }
11531
+ if (filter?.ownerType !== void 0) {
11532
+ if (filter.ownerType === null) {
11533
+ conditions.push("owner_type IS NULL");
11534
+ } else {
11535
+ params.push(filter.ownerType);
11536
+ conditions.push(`owner_type = $${params.length}`);
11537
+ }
11538
+ }
11539
+ if (filter?.ownerId !== void 0) {
11540
+ if (filter.ownerId === null) {
11541
+ conditions.push("owner_id IS NULL");
11542
+ } else {
11543
+ params.push(filter.ownerId);
11544
+ conditions.push(`owner_id = $${params.length}`);
11545
+ }
11546
+ }
11522
11547
  const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
11523
11548
  const rows = await this.#client.manyOrNone(
11524
11549
  `SELECT * FROM ${this.#table(storage.TABLE_SCHEDULES)} ${where} ORDER BY created_at ASC`,
@@ -11554,6 +11579,8 @@ var SchedulesPG = class extends storage.SchedulesStorage {
11554
11579
  if ("metadata" in patch) {
11555
11580
  push("metadata = ?::jsonb", patch.metadata != null ? JSON.stringify(patch.metadata) : null);
11556
11581
  }
11582
+ if ("ownerType" in patch) push("owner_type = ?", patch.ownerType ?? null);
11583
+ if ("ownerId" in patch) push("owner_id = ?", patch.ownerId ?? null);
11557
11584
  push("updated_at = ?", Date.now());
11558
11585
  if (setClauses.length === 1) {
11559
11586
  const existing = await this.getSchedule(id);
@@ -11583,15 +11610,20 @@ var SchedulesPG = class extends storage.SchedulesStorage {
11583
11610
  await this.#client.none(`DELETE FROM ${this.#table(storage.TABLE_SCHEDULES)} WHERE id = $1`, [id]);
11584
11611
  }
11585
11612
  async recordTrigger(trigger) {
11613
+ const id = trigger.id ?? crypto.randomUUID();
11586
11614
  await this.#db.insert({
11587
11615
  tableName: storage.TABLE_SCHEDULE_TRIGGERS,
11588
11616
  record: {
11617
+ id,
11589
11618
  schedule_id: trigger.scheduleId,
11590
11619
  run_id: trigger.runId,
11591
11620
  scheduled_fire_at: trigger.scheduledFireAt,
11592
11621
  actual_fire_at: trigger.actualFireAt,
11593
- status: trigger.status,
11594
- error: trigger.error ?? null
11622
+ outcome: trigger.outcome,
11623
+ error: trigger.error ?? null,
11624
+ trigger_kind: trigger.triggerKind ?? "schedule-fire",
11625
+ parent_trigger_id: trigger.parentTriggerId ?? null,
11626
+ metadata: trigger.metadata ?? null
11595
11627
  }
11596
11628
  });
11597
11629
  }