@mastra/pg 1.10.0-alpha.0 → 1.10.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/CHANGELOG.md +36 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +37 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -5
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/schedules/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -11393,17 +11393,24 @@ function rowToSchedule(row) {
|
|
|
11393
11393
|
if (row.last_run_id != null) schedule.lastRunId = String(row.last_run_id);
|
|
11394
11394
|
const metadata = parseJson2(row.metadata);
|
|
11395
11395
|
if (metadata !== void 0) schedule.metadata = metadata;
|
|
11396
|
+
if (row.owner_type != null) schedule.ownerType = String(row.owner_type);
|
|
11397
|
+
if (row.owner_id != null) schedule.ownerId = String(row.owner_id);
|
|
11396
11398
|
return schedule;
|
|
11397
11399
|
}
|
|
11398
11400
|
function rowToTrigger(row) {
|
|
11399
11401
|
const trigger = {
|
|
11402
|
+
id: row.id != null ? String(row.id) : void 0,
|
|
11400
11403
|
scheduleId: String(row.schedule_id),
|
|
11401
|
-
runId: String(row.run_id),
|
|
11404
|
+
runId: row.run_id != null ? String(row.run_id) : null,
|
|
11402
11405
|
scheduledFireAt: toNumber(row.scheduled_fire_at),
|
|
11403
11406
|
actualFireAt: toNumber(row.actual_fire_at),
|
|
11404
|
-
|
|
11407
|
+
outcome: String(row.outcome),
|
|
11408
|
+
triggerKind: row.trigger_kind != null ? String(row.trigger_kind) : "schedule-fire"
|
|
11405
11409
|
};
|
|
11406
11410
|
if (row.error != null) trigger.error = String(row.error);
|
|
11411
|
+
if (row.parent_trigger_id != null) trigger.parentTriggerId = String(row.parent_trigger_id);
|
|
11412
|
+
const metadata = parseJson2(row.metadata);
|
|
11413
|
+
if (metadata !== void 0) trigger.metadata = metadata;
|
|
11407
11414
|
return trigger;
|
|
11408
11415
|
}
|
|
11409
11416
|
var SchedulesPG = class extends SchedulesStorage {
|
|
@@ -11471,7 +11478,9 @@ var SchedulesPG = class extends SchedulesStorage {
|
|
|
11471
11478
|
last_run_id: schedule.lastRunId ?? null,
|
|
11472
11479
|
created_at: schedule.createdAt,
|
|
11473
11480
|
updated_at: schedule.updatedAt,
|
|
11474
|
-
metadata: schedule.metadata ?? null
|
|
11481
|
+
metadata: schedule.metadata ?? null,
|
|
11482
|
+
owner_type: schedule.ownerType ?? null,
|
|
11483
|
+
owner_id: schedule.ownerId ?? null
|
|
11475
11484
|
}
|
|
11476
11485
|
});
|
|
11477
11486
|
return schedule;
|
|
@@ -11494,6 +11503,22 @@ var SchedulesPG = class extends SchedulesStorage {
|
|
|
11494
11503
|
params.push(filter.workflowId);
|
|
11495
11504
|
conditions.push(`target->>'workflowId' = $${params.length}`);
|
|
11496
11505
|
}
|
|
11506
|
+
if (filter?.ownerType !== void 0) {
|
|
11507
|
+
if (filter.ownerType === null) {
|
|
11508
|
+
conditions.push("owner_type IS NULL");
|
|
11509
|
+
} else {
|
|
11510
|
+
params.push(filter.ownerType);
|
|
11511
|
+
conditions.push(`owner_type = $${params.length}`);
|
|
11512
|
+
}
|
|
11513
|
+
}
|
|
11514
|
+
if (filter?.ownerId !== void 0) {
|
|
11515
|
+
if (filter.ownerId === null) {
|
|
11516
|
+
conditions.push("owner_id IS NULL");
|
|
11517
|
+
} else {
|
|
11518
|
+
params.push(filter.ownerId);
|
|
11519
|
+
conditions.push(`owner_id = $${params.length}`);
|
|
11520
|
+
}
|
|
11521
|
+
}
|
|
11497
11522
|
const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
|
|
11498
11523
|
const rows = await this.#client.manyOrNone(
|
|
11499
11524
|
`SELECT * FROM ${this.#table(TABLE_SCHEDULES)} ${where} ORDER BY created_at ASC`,
|
|
@@ -11529,6 +11554,8 @@ var SchedulesPG = class extends SchedulesStorage {
|
|
|
11529
11554
|
if ("metadata" in patch) {
|
|
11530
11555
|
push("metadata = ?::jsonb", patch.metadata != null ? JSON.stringify(patch.metadata) : null);
|
|
11531
11556
|
}
|
|
11557
|
+
if ("ownerType" in patch) push("owner_type = ?", patch.ownerType ?? null);
|
|
11558
|
+
if ("ownerId" in patch) push("owner_id = ?", patch.ownerId ?? null);
|
|
11532
11559
|
push("updated_at = ?", Date.now());
|
|
11533
11560
|
if (setClauses.length === 1) {
|
|
11534
11561
|
const existing = await this.getSchedule(id);
|
|
@@ -11558,15 +11585,20 @@ var SchedulesPG = class extends SchedulesStorage {
|
|
|
11558
11585
|
await this.#client.none(`DELETE FROM ${this.#table(TABLE_SCHEDULES)} WHERE id = $1`, [id]);
|
|
11559
11586
|
}
|
|
11560
11587
|
async recordTrigger(trigger) {
|
|
11588
|
+
const id = trigger.id ?? crypto.randomUUID();
|
|
11561
11589
|
await this.#db.insert({
|
|
11562
11590
|
tableName: TABLE_SCHEDULE_TRIGGERS,
|
|
11563
11591
|
record: {
|
|
11592
|
+
id,
|
|
11564
11593
|
schedule_id: trigger.scheduleId,
|
|
11565
11594
|
run_id: trigger.runId,
|
|
11566
11595
|
scheduled_fire_at: trigger.scheduledFireAt,
|
|
11567
11596
|
actual_fire_at: trigger.actualFireAt,
|
|
11568
|
-
|
|
11569
|
-
error: trigger.error ?? null
|
|
11597
|
+
outcome: trigger.outcome,
|
|
11598
|
+
error: trigger.error ?? null,
|
|
11599
|
+
trigger_kind: trigger.triggerKind ?? "schedule-fire",
|
|
11600
|
+
parent_trigger_id: trigger.parentTriggerId ?? null,
|
|
11601
|
+
metadata: trigger.metadata ?? null
|
|
11570
11602
|
}
|
|
11571
11603
|
});
|
|
11572
11604
|
}
|