@mastra/pg 1.12.0-alpha.0 → 1.12.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
@@ -4375,10 +4375,10 @@ function rowToTask(row) {
4375
4375
  retryCount: Number(row.retry_count),
4376
4376
  maxRetries: Number(row.max_retries),
4377
4377
  timeoutMs: Number(row.timeout_ms),
4378
- createdAt: row.createdAt instanceof Date ? row.createdAt : new Date(row.createdAt),
4379
- startedAt: row.startedAt ? row.startedAt instanceof Date ? row.startedAt : new Date(row.startedAt) : void 0,
4380
- suspendedAt: row.suspendedAt ? row.suspendedAt instanceof Date ? row.suspendedAt : new Date(row.suspendedAt) : void 0,
4381
- completedAt: row.completedAt ? row.completedAt instanceof Date ? row.completedAt : new Date(row.completedAt) : void 0
4378
+ createdAt: new Date(row.createdAtZ || row.createdAt),
4379
+ startedAt: row.startedAtZ || row.startedAt ? new Date(row.startedAtZ || row.startedAt) : void 0,
4380
+ suspendedAt: row.suspendedAtZ || row.suspendedAt ? new Date(row.suspendedAtZ || row.suspendedAt) : void 0,
4381
+ completedAt: row.completedAtZ || row.completedAt ? new Date(row.completedAtZ || row.completedAt) : void 0
4382
4382
  };
4383
4383
  }
4384
4384
  var BackgroundTasksPG = class _BackgroundTasksPG extends BackgroundTasksStorage {
@@ -4528,15 +4528,21 @@ var BackgroundTasksPG = class _BackgroundTasksPG extends BackgroundTasksStorage
4528
4528
  }
4529
4529
  if ("startedAt" in update) {
4530
4530
  setClauses.push(`"startedAt" = $${paramIdx++}`);
4531
- params.push(update.startedAt?.toISOString() ?? null);
4531
+ setClauses.push(`"startedAtZ" = $${paramIdx++}`);
4532
+ const val = update.startedAt?.toISOString() ?? null;
4533
+ params.push(val, val);
4532
4534
  }
4533
4535
  if ("suspendedAt" in update) {
4534
4536
  setClauses.push(`"suspendedAt" = $${paramIdx++}`);
4535
- params.push(update.suspendedAt?.toISOString() ?? null);
4537
+ setClauses.push(`"suspendedAtZ" = $${paramIdx++}`);
4538
+ const val = update.suspendedAt?.toISOString() ?? null;
4539
+ params.push(val, val);
4536
4540
  }
4537
4541
  if ("completedAt" in update) {
4538
4542
  setClauses.push(`"completedAt" = $${paramIdx++}`);
4539
- params.push(update.completedAt?.toISOString() ?? null);
4543
+ setClauses.push(`"completedAtZ" = $${paramIdx++}`);
4544
+ const val = update.completedAt?.toISOString() ?? null;
4545
+ params.push(val, val);
4540
4546
  }
4541
4547
  if (setClauses.length === 0) return;
4542
4548
  const table = getTableName3(getSchemaName3(this.#schema));
@@ -4828,9 +4834,10 @@ var ChannelsPG = class _ChannelsPG extends ChannelsStorage {
4828
4834
  const schemaName = getSchemaName2(this.#schema);
4829
4835
  const tableName = getTableName2({ indexName: TABLE_CHANNEL_INSTALLATIONS, schemaName });
4830
4836
  const now = (/* @__PURE__ */ new Date()).toISOString();
4837
+ const createdAt = installation.createdAt?.toISOString() ?? now;
4831
4838
  await this.#db.client.none(
4832
- `INSERT INTO ${tableName} ("id", "platform", "agentId", "status", "webhookId", "data", "configHash", "error", "createdAt", "updatedAt")
4833
- VALUES ($1, $2, $3, $4, $5, $6::jsonb, $7, $8, $9, $10)
4839
+ `INSERT INTO ${tableName} ("id", "platform", "agentId", "status", "webhookId", "data", "configHash", "error", "createdAt", "createdAtZ", "updatedAt", "updatedAtZ")
4840
+ VALUES ($1, $2, $3, $4, $5, $6::jsonb, $7, $8, $9, $10, $11, $12)
4834
4841
  ON CONFLICT ("id") DO UPDATE SET
4835
4842
  "platform" = EXCLUDED."platform",
4836
4843
  "agentId" = EXCLUDED."agentId",
@@ -4839,7 +4846,8 @@ var ChannelsPG = class _ChannelsPG extends ChannelsStorage {
4839
4846
  "data" = EXCLUDED."data",
4840
4847
  "configHash" = EXCLUDED."configHash",
4841
4848
  "error" = EXCLUDED."error",
4842
- "updatedAt" = EXCLUDED."updatedAt"`,
4849
+ "updatedAt" = EXCLUDED."updatedAt",
4850
+ "updatedAtZ" = EXCLUDED."updatedAtZ"`,
4843
4851
  [
4844
4852
  installation.id,
4845
4853
  installation.platform,
@@ -4849,7 +4857,9 @@ var ChannelsPG = class _ChannelsPG extends ChannelsStorage {
4849
4857
  JSON.stringify(installation.data),
4850
4858
  installation.configHash ?? null,
4851
4859
  installation.error ?? null,
4852
- installation.createdAt?.toISOString() ?? now,
4860
+ createdAt,
4861
+ createdAt,
4862
+ now,
4853
4863
  now
4854
4864
  ]
4855
4865
  );
@@ -4892,13 +4902,15 @@ var ChannelsPG = class _ChannelsPG extends ChannelsStorage {
4892
4902
  async saveConfig(config) {
4893
4903
  const schemaName = getSchemaName2(this.#schema);
4894
4904
  const tableName = getTableName2({ indexName: TABLE_CHANNEL_CONFIG, schemaName });
4905
+ const now = config.updatedAt.toISOString();
4895
4906
  await this.#db.client.none(
4896
- `INSERT INTO ${tableName} ("platform", "data", "updatedAt")
4897
- VALUES ($1, $2::jsonb, $3)
4907
+ `INSERT INTO ${tableName} ("platform", "data", "updatedAt", "updatedAtZ")
4908
+ VALUES ($1, $2::jsonb, $3, $4)
4898
4909
  ON CONFLICT ("platform") DO UPDATE SET
4899
4910
  "data" = EXCLUDED."data",
4900
- "updatedAt" = EXCLUDED."updatedAt"`,
4901
- [config.platform, JSON.stringify(config.data), config.updatedAt.toISOString()]
4911
+ "updatedAt" = EXCLUDED."updatedAt",
4912
+ "updatedAtZ" = EXCLUDED."updatedAtZ"`,
4913
+ [config.platform, JSON.stringify(config.data), now, now]
4902
4914
  );
4903
4915
  }
4904
4916
  async getConfig(platform) {
@@ -4909,7 +4921,7 @@ var ChannelsPG = class _ChannelsPG extends ChannelsStorage {
4909
4921
  return {
4910
4922
  platform: row.platform,
4911
4923
  data: typeof row.data === "string" ? JSON.parse(row.data) : row.data,
4912
- updatedAt: new Date(row.updatedAt)
4924
+ updatedAt: new Date(row.updatedAtZ || row.updatedAt)
4913
4925
  };
4914
4926
  }
4915
4927
  async deleteConfig(platform) {
@@ -4927,8 +4939,8 @@ var ChannelsPG = class _ChannelsPG extends ChannelsStorage {
4927
4939
  data: typeof row.data === "string" ? JSON.parse(row.data) : row.data,
4928
4940
  configHash: row.configHash || void 0,
4929
4941
  error: row.error || void 0,
4930
- createdAt: row.createdAt instanceof Date ? row.createdAt : new Date(row.createdAt),
4931
- updatedAt: row.updatedAt instanceof Date ? row.updatedAt : new Date(row.updatedAt)
4942
+ createdAt: new Date(row.createdAtZ || row.createdAt),
4943
+ updatedAt: new Date(row.updatedAtZ || row.updatedAt)
4932
4944
  };
4933
4945
  }
4934
4946
  };