@mastra/pg 1.27.2-alpha.0 → 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 +42 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +42 -6
- 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/dist/storage/domains/workflows/index.d.ts +1 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -5048,6 +5048,7 @@ function rowToTask(row) {
|
|
|
5048
5048
|
const startedAt = row.startedAtZ || row.startedAt;
|
|
5049
5049
|
const suspendedAt = row.suspendedAtZ || row.suspendedAt;
|
|
5050
5050
|
const completedAt = row.completedAtZ || row.completedAt;
|
|
5051
|
+
const leaseExpiresAt = row.leaseExpiresAtZ || row.leaseExpiresAt;
|
|
5051
5052
|
return {
|
|
5052
5053
|
id: row.id,
|
|
5053
5054
|
status: row.status,
|
|
@@ -5067,7 +5068,9 @@ function rowToTask(row) {
|
|
|
5067
5068
|
createdAt: createdAt instanceof Date ? createdAt : new Date(createdAt),
|
|
5068
5069
|
startedAt: startedAt ? startedAt instanceof Date ? startedAt : new Date(startedAt) : void 0,
|
|
5069
5070
|
suspendedAt: suspendedAt ? suspendedAt instanceof Date ? suspendedAt : new Date(suspendedAt) : void 0,
|
|
5070
|
-
completedAt: completedAt ? completedAt instanceof Date ? completedAt : new Date(completedAt) : void 0
|
|
5071
|
+
completedAt: completedAt ? completedAt instanceof Date ? completedAt : new Date(completedAt) : void 0,
|
|
5072
|
+
ownerId: row.ownerId ?? void 0,
|
|
5073
|
+
leaseExpiresAt: leaseExpiresAt ? leaseExpiresAt instanceof Date ? leaseExpiresAt : new Date(leaseExpiresAt) : void 0
|
|
5071
5074
|
};
|
|
5072
5075
|
}
|
|
5073
5076
|
var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.BackgroundTasksStorage {
|
|
@@ -5107,7 +5110,12 @@ var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.Bac
|
|
|
5107
5110
|
await this.#db.alterTable({
|
|
5108
5111
|
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
5109
5112
|
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
|
|
5110
|
-
ifNotExists: [
|
|
5113
|
+
ifNotExists: [
|
|
5114
|
+
"suspend_payload",
|
|
5115
|
+
"suspendedAt",
|
|
5116
|
+
"ownerId",
|
|
5117
|
+
"leaseExpiresAt"
|
|
5118
|
+
]
|
|
5111
5119
|
});
|
|
5112
5120
|
await this.createDefaultIndexes();
|
|
5113
5121
|
await this.createCustomIndexes();
|
|
@@ -5237,7 +5245,10 @@ var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.Bac
|
|
|
5237
5245
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
5238
5246
|
suspendedAtZ: task.suspendedAt?.toISOString() ?? null,
|
|
5239
5247
|
completedAt: task.completedAt?.toISOString() ?? null,
|
|
5240
|
-
completedAtZ: task.completedAt?.toISOString() ?? null
|
|
5248
|
+
completedAtZ: task.completedAt?.toISOString() ?? null,
|
|
5249
|
+
ownerId: task.ownerId ?? null,
|
|
5250
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
|
|
5251
|
+
leaseExpiresAtZ: task.leaseExpiresAt?.toISOString() ?? null
|
|
5241
5252
|
}
|
|
5242
5253
|
});
|
|
5243
5254
|
}
|
|
@@ -5283,14 +5294,34 @@ var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.Bac
|
|
|
5283
5294
|
const val = update.completedAt?.toISOString() ?? null;
|
|
5284
5295
|
params.push(val, val);
|
|
5285
5296
|
}
|
|
5297
|
+
if ("ownerId" in update) {
|
|
5298
|
+
setClauses.push(`"ownerId" = $${paramIdx++}`);
|
|
5299
|
+
params.push(update.ownerId ?? null);
|
|
5300
|
+
}
|
|
5301
|
+
if ("leaseExpiresAt" in update) {
|
|
5302
|
+
setClauses.push(`"leaseExpiresAt" = $${paramIdx++}`);
|
|
5303
|
+
setClauses.push(`"leaseExpiresAtZ" = $${paramIdx++}`);
|
|
5304
|
+
const val = update.leaseExpiresAt?.toISOString() ?? null;
|
|
5305
|
+
params.push(val, val);
|
|
5306
|
+
}
|
|
5286
5307
|
if (setClauses.length === 0) return false;
|
|
5287
5308
|
const table = getTableName$4(getSchemaName$4(this.#schema));
|
|
5288
5309
|
params.push(taskId);
|
|
5289
5310
|
let where = `"id" = $${paramIdx++}`;
|
|
5290
5311
|
if (options?.expectedStatus) {
|
|
5291
|
-
where += ` AND "status" = $${paramIdx}`;
|
|
5312
|
+
where += ` AND "status" = $${paramIdx++}`;
|
|
5292
5313
|
params.push(options.expectedStatus);
|
|
5293
5314
|
}
|
|
5315
|
+
if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) where += ` AND "ownerId" IS NULL`;
|
|
5316
|
+
else {
|
|
5317
|
+
where += ` AND "ownerId" = $${paramIdx++}`;
|
|
5318
|
+
params.push(options.expectedOwnerId);
|
|
5319
|
+
}
|
|
5320
|
+
if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) where += ` AND "leaseExpiresAtZ" IS NULL`;
|
|
5321
|
+
else {
|
|
5322
|
+
where += ` AND "leaseExpiresAtZ" = $${paramIdx++}`;
|
|
5323
|
+
params.push(options.expectedLeaseExpiresAt.toISOString());
|
|
5324
|
+
}
|
|
5294
5325
|
return ((await this.#db.client.query(`UPDATE ${table} SET ${setClauses.join(", ")} WHERE ${where}`, params)).rowCount ?? 0) > 0;
|
|
5295
5326
|
}
|
|
5296
5327
|
async getTask(taskId) {
|
|
@@ -23031,7 +23062,7 @@ var WorkflowsPG = class WorkflowsPG extends _mastra_core_storage.WorkflowsStorag
|
|
|
23031
23062
|
}, error);
|
|
23032
23063
|
}
|
|
23033
23064
|
}
|
|
23034
|
-
async listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, threadId, status } = {}) {
|
|
23065
|
+
async listWorkflowRuns({ workflowName, fromDate, toDate, perPage, page, resourceId, threadId, status, summary } = {}) {
|
|
23035
23066
|
try {
|
|
23036
23067
|
const conditions = [];
|
|
23037
23068
|
const values = [];
|
|
@@ -23079,8 +23110,13 @@ var WorkflowsPG = class WorkflowsPG extends _mastra_core_storage.WorkflowsStorag
|
|
|
23079
23110
|
}
|
|
23080
23111
|
const normalizedPerPage = usePagination ? (0, _mastra_core_storage.normalizePerPage)(perPage, Number.MAX_SAFE_INTEGER) : 0;
|
|
23081
23112
|
const offset = usePagination ? page * normalizedPerPage : void 0;
|
|
23113
|
+
let selectList = "*";
|
|
23114
|
+
if (summary) {
|
|
23115
|
+
const snapshotJson = await this.#db.getColumnType(_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT, "snapshot") === "jsonb" ? "snapshot" : `regexp_replace(snapshot::text, '\\\\u(0000|[Dd][89A-Fa-f][0-9A-Fa-f]{2})', '', 'g')::jsonb`;
|
|
23116
|
+
selectList = `workflow_name, run_id, "resourceId", "createdAt", "createdAtZ", "updatedAt", "updatedAtZ", jsonb_build_object('status', ${snapshotJson} -> 'status', 'timestamp', ${snapshotJson} -> 'timestamp') AS snapshot`;
|
|
23117
|
+
}
|
|
23082
23118
|
const query = `
|
|
23083
|
-
SELECT
|
|
23119
|
+
SELECT ${selectList} FROM ${getTableName({
|
|
23084
23120
|
indexName: _mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT,
|
|
23085
23121
|
schemaName: getSchemaName(this.#schema)
|
|
23086
23122
|
})}
|