@mastra/libsql 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/dist/index.js CHANGED
@@ -8928,17 +8928,24 @@ function rowToSchedule(row) {
8928
8928
  if (row.last_run_id != null) schedule.lastRunId = String(row.last_run_id);
8929
8929
  const metadata = parseJson2(row.metadata);
8930
8930
  if (metadata !== void 0) schedule.metadata = metadata;
8931
+ if (row.owner_type != null) schedule.ownerType = String(row.owner_type);
8932
+ if (row.owner_id != null) schedule.ownerId = String(row.owner_id);
8931
8933
  return schedule;
8932
8934
  }
8933
8935
  function rowToTrigger(row) {
8934
8936
  const trigger = {
8937
+ id: row.id != null ? String(row.id) : void 0,
8935
8938
  scheduleId: String(row.schedule_id),
8936
- runId: String(row.run_id),
8939
+ runId: row.run_id != null ? String(row.run_id) : null,
8937
8940
  scheduledFireAt: toNumber(row.scheduled_fire_at),
8938
8941
  actualFireAt: toNumber(row.actual_fire_at),
8939
- status: String(row.status)
8942
+ outcome: String(row.outcome),
8943
+ triggerKind: row.trigger_kind != null ? String(row.trigger_kind) : "schedule-fire"
8940
8944
  };
8941
8945
  if (row.error != null) trigger.error = String(row.error);
8946
+ if (row.parent_trigger_id != null) trigger.parentTriggerId = String(row.parent_trigger_id);
8947
+ const metadata = parseJson2(row.metadata);
8948
+ if (metadata !== void 0) trigger.metadata = metadata;
8942
8949
  return trigger;
8943
8950
  }
8944
8951
  var SchedulesLibSQL = class extends SchedulesStorage {
@@ -8982,7 +8989,9 @@ var SchedulesLibSQL = class extends SchedulesStorage {
8982
8989
  last_run_id: schedule.lastRunId ?? null,
8983
8990
  created_at: schedule.createdAt,
8984
8991
  updated_at: schedule.updatedAt,
8985
- metadata: schedule.metadata ?? null
8992
+ metadata: schedule.metadata ?? null,
8993
+ owner_type: schedule.ownerType ?? null,
8994
+ owner_id: schedule.ownerId ?? null
8986
8995
  }
8987
8996
  });
8988
8997
  return schedule;
@@ -9006,6 +9015,22 @@ var SchedulesLibSQL = class extends SchedulesStorage {
9006
9015
  conditions.push("json_extract(target, '$.workflowId') = ?");
9007
9016
  params.push(filter.workflowId);
9008
9017
  }
9018
+ if (filter?.ownerType !== void 0) {
9019
+ if (filter.ownerType === null) {
9020
+ conditions.push("owner_type IS NULL");
9021
+ } else {
9022
+ conditions.push("owner_type = ?");
9023
+ params.push(filter.ownerType);
9024
+ }
9025
+ }
9026
+ if (filter?.ownerId !== void 0) {
9027
+ if (filter.ownerId === null) {
9028
+ conditions.push("owner_id IS NULL");
9029
+ } else {
9030
+ conditions.push("owner_id = ?");
9031
+ params.push(filter.ownerId);
9032
+ }
9033
+ }
9009
9034
  const where = conditions.length > 0 ? `WHERE ${conditions.join(" AND ")}` : "";
9010
9035
  const result = await this.#client.execute({
9011
9036
  sql: `SELECT ${buildSelectColumns(TABLE_SCHEDULES)} FROM ${TABLE_SCHEDULES} ${where} ORDER BY created_at ASC`,
@@ -9051,6 +9076,14 @@ var SchedulesLibSQL = class extends SchedulesStorage {
9051
9076
  setClauses.push("metadata = jsonb(?)");
9052
9077
  params.push(patch.metadata != null ? JSON.stringify(patch.metadata) : null);
9053
9078
  }
9079
+ if ("ownerType" in patch) {
9080
+ setClauses.push("owner_type = ?");
9081
+ params.push(patch.ownerType ?? null);
9082
+ }
9083
+ if ("ownerId" in patch) {
9084
+ setClauses.push("owner_id = ?");
9085
+ params.push(patch.ownerId ?? null);
9086
+ }
9054
9087
  setClauses.push("updated_at = ?");
9055
9088
  params.push(Date.now());
9056
9089
  params.push(id);
@@ -9087,15 +9120,20 @@ var SchedulesLibSQL = class extends SchedulesStorage {
9087
9120
  });
9088
9121
  }
9089
9122
  async recordTrigger(trigger) {
9123
+ const id = trigger.id ?? crypto.randomUUID();
9090
9124
  await this.#db.insert({
9091
9125
  tableName: TABLE_SCHEDULE_TRIGGERS,
9092
9126
  record: {
9127
+ id,
9093
9128
  schedule_id: trigger.scheduleId,
9094
9129
  run_id: trigger.runId,
9095
9130
  scheduled_fire_at: trigger.scheduledFireAt,
9096
9131
  actual_fire_at: trigger.actualFireAt,
9097
- status: trigger.status,
9098
- error: trigger.error ?? null
9132
+ outcome: trigger.outcome,
9133
+ error: trigger.error ?? null,
9134
+ trigger_kind: trigger.triggerKind ?? "schedule-fire",
9135
+ parent_trigger_id: trigger.parentTriggerId ?? null,
9136
+ metadata: trigger.metadata ?? null
9099
9137
  }
9100
9138
  });
9101
9139
  }