@mastra/pg 1.27.2-alpha.1 → 1.28.0-alpha.2
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +35 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +35 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/background-tasks/index.d.ts +2 -4
- package/dist/storage/domains/background-tasks/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5024,6 +5024,7 @@ function rowToTask(row) {
|
|
|
5024
5024
|
const startedAt = row.startedAtZ || row.startedAt;
|
|
5025
5025
|
const suspendedAt = row.suspendedAtZ || row.suspendedAt;
|
|
5026
5026
|
const completedAt = row.completedAtZ || row.completedAt;
|
|
5027
|
+
const leaseExpiresAt = row.leaseExpiresAtZ || row.leaseExpiresAt;
|
|
5027
5028
|
return {
|
|
5028
5029
|
id: row.id,
|
|
5029
5030
|
status: row.status,
|
|
@@ -5043,7 +5044,9 @@ function rowToTask(row) {
|
|
|
5043
5044
|
createdAt: createdAt instanceof Date ? createdAt : new Date(createdAt),
|
|
5044
5045
|
startedAt: startedAt ? startedAt instanceof Date ? startedAt : new Date(startedAt) : void 0,
|
|
5045
5046
|
suspendedAt: suspendedAt ? suspendedAt instanceof Date ? suspendedAt : new Date(suspendedAt) : void 0,
|
|
5046
|
-
completedAt: completedAt ? completedAt instanceof Date ? completedAt : new Date(completedAt) : void 0
|
|
5047
|
+
completedAt: completedAt ? completedAt instanceof Date ? completedAt : new Date(completedAt) : void 0,
|
|
5048
|
+
ownerId: row.ownerId ?? void 0,
|
|
5049
|
+
leaseExpiresAt: leaseExpiresAt ? leaseExpiresAt instanceof Date ? leaseExpiresAt : new Date(leaseExpiresAt) : void 0
|
|
5047
5050
|
};
|
|
5048
5051
|
}
|
|
5049
5052
|
var BackgroundTasksPG = class BackgroundTasksPG extends BackgroundTasksStorage {
|
|
@@ -5083,7 +5086,12 @@ var BackgroundTasksPG = class BackgroundTasksPG extends BackgroundTasksStorage {
|
|
|
5083
5086
|
await this.#db.alterTable({
|
|
5084
5087
|
tableName: TABLE_BACKGROUND_TASKS,
|
|
5085
5088
|
schema: TABLE_SCHEMAS[TABLE_BACKGROUND_TASKS],
|
|
5086
|
-
ifNotExists: [
|
|
5089
|
+
ifNotExists: [
|
|
5090
|
+
"suspend_payload",
|
|
5091
|
+
"suspendedAt",
|
|
5092
|
+
"ownerId",
|
|
5093
|
+
"leaseExpiresAt"
|
|
5094
|
+
]
|
|
5087
5095
|
});
|
|
5088
5096
|
await this.createDefaultIndexes();
|
|
5089
5097
|
await this.createCustomIndexes();
|
|
@@ -5213,7 +5221,10 @@ var BackgroundTasksPG = class BackgroundTasksPG extends BackgroundTasksStorage {
|
|
|
5213
5221
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
5214
5222
|
suspendedAtZ: task.suspendedAt?.toISOString() ?? null,
|
|
5215
5223
|
completedAt: task.completedAt?.toISOString() ?? null,
|
|
5216
|
-
completedAtZ: task.completedAt?.toISOString() ?? null
|
|
5224
|
+
completedAtZ: task.completedAt?.toISOString() ?? null,
|
|
5225
|
+
ownerId: task.ownerId ?? null,
|
|
5226
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
|
|
5227
|
+
leaseExpiresAtZ: task.leaseExpiresAt?.toISOString() ?? null
|
|
5217
5228
|
}
|
|
5218
5229
|
});
|
|
5219
5230
|
}
|
|
@@ -5259,14 +5270,34 @@ var BackgroundTasksPG = class BackgroundTasksPG extends BackgroundTasksStorage {
|
|
|
5259
5270
|
const val = update.completedAt?.toISOString() ?? null;
|
|
5260
5271
|
params.push(val, val);
|
|
5261
5272
|
}
|
|
5273
|
+
if ("ownerId" in update) {
|
|
5274
|
+
setClauses.push(`"ownerId" = $${paramIdx++}`);
|
|
5275
|
+
params.push(update.ownerId ?? null);
|
|
5276
|
+
}
|
|
5277
|
+
if ("leaseExpiresAt" in update) {
|
|
5278
|
+
setClauses.push(`"leaseExpiresAt" = $${paramIdx++}`);
|
|
5279
|
+
setClauses.push(`"leaseExpiresAtZ" = $${paramIdx++}`);
|
|
5280
|
+
const val = update.leaseExpiresAt?.toISOString() ?? null;
|
|
5281
|
+
params.push(val, val);
|
|
5282
|
+
}
|
|
5262
5283
|
if (setClauses.length === 0) return false;
|
|
5263
5284
|
const table = getTableName$4(getSchemaName$4(this.#schema));
|
|
5264
5285
|
params.push(taskId);
|
|
5265
5286
|
let where = `"id" = $${paramIdx++}`;
|
|
5266
5287
|
if (options?.expectedStatus) {
|
|
5267
|
-
where += ` AND "status" = $${paramIdx}`;
|
|
5288
|
+
where += ` AND "status" = $${paramIdx++}`;
|
|
5268
5289
|
params.push(options.expectedStatus);
|
|
5269
5290
|
}
|
|
5291
|
+
if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) where += ` AND "ownerId" IS NULL`;
|
|
5292
|
+
else {
|
|
5293
|
+
where += ` AND "ownerId" = $${paramIdx++}`;
|
|
5294
|
+
params.push(options.expectedOwnerId);
|
|
5295
|
+
}
|
|
5296
|
+
if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) where += ` AND "leaseExpiresAtZ" IS NULL`;
|
|
5297
|
+
else {
|
|
5298
|
+
where += ` AND "leaseExpiresAtZ" = $${paramIdx++}`;
|
|
5299
|
+
params.push(options.expectedLeaseExpiresAt.toISOString());
|
|
5300
|
+
}
|
|
5270
5301
|
return ((await this.#db.client.query(`UPDATE ${table} SET ${setClauses.join(", ")} WHERE ${where}`, params)).rowCount ?? 0) > 0;
|
|
5271
5302
|
}
|
|
5272
5303
|
async getTask(taskId) {
|