@mastra/pg 1.27.2-alpha.1 → 1.28.0-alpha.3
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 +39 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +39 -20
- 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/vector/sql-builder.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/docs/SKILL.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -482,14 +482,8 @@ function buildDeleteFilterQuery(filter) {
|
|
|
482
482
|
const joined = value.map((f) => {
|
|
483
483
|
const entries = Object.entries(f || {});
|
|
484
484
|
if (entries.length === 0) return "";
|
|
485
|
-
const
|
|
486
|
-
|
|
487
|
-
"$and",
|
|
488
|
-
"$or",
|
|
489
|
-
"$not",
|
|
490
|
-
"$nor"
|
|
491
|
-
].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
|
|
492
|
-
return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
|
|
485
|
+
const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
|
|
486
|
+
return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
|
|
493
487
|
}).join(` ${joinOperator} `);
|
|
494
488
|
const operatorFn = FILTER_OPERATORS[key];
|
|
495
489
|
return operatorFn(joined, 0, value).sql;
|
|
@@ -573,14 +567,8 @@ function buildFilterQuery(filter, minScore, topK) {
|
|
|
573
567
|
const joined = value.map((f) => {
|
|
574
568
|
const entries = Object.entries(f || {});
|
|
575
569
|
if (entries.length === 0) return "";
|
|
576
|
-
const
|
|
577
|
-
|
|
578
|
-
"$and",
|
|
579
|
-
"$or",
|
|
580
|
-
"$not",
|
|
581
|
-
"$nor"
|
|
582
|
-
].includes(firstKey)) return buildCondition(firstKey, firstValue, parentPath);
|
|
583
|
-
return entries.map(([k, v]) => buildCondition(k, v, parentPath)).join(` ${joinOperator} `);
|
|
570
|
+
const branchConditions = entries.map(([k, v]) => buildCondition(k, v, parentPath));
|
|
571
|
+
return branchConditions.length === 1 ? branchConditions[0] : `(${branchConditions.join(" AND ")})`;
|
|
584
572
|
}).join(` ${joinOperator} `);
|
|
585
573
|
const operatorFn = FILTER_OPERATORS[key];
|
|
586
574
|
return operatorFn(joined, 0, value).sql;
|
|
@@ -5048,6 +5036,7 @@ function rowToTask(row) {
|
|
|
5048
5036
|
const startedAt = row.startedAtZ || row.startedAt;
|
|
5049
5037
|
const suspendedAt = row.suspendedAtZ || row.suspendedAt;
|
|
5050
5038
|
const completedAt = row.completedAtZ || row.completedAt;
|
|
5039
|
+
const leaseExpiresAt = row.leaseExpiresAtZ || row.leaseExpiresAt;
|
|
5051
5040
|
return {
|
|
5052
5041
|
id: row.id,
|
|
5053
5042
|
status: row.status,
|
|
@@ -5067,7 +5056,9 @@ function rowToTask(row) {
|
|
|
5067
5056
|
createdAt: createdAt instanceof Date ? createdAt : new Date(createdAt),
|
|
5068
5057
|
startedAt: startedAt ? startedAt instanceof Date ? startedAt : new Date(startedAt) : void 0,
|
|
5069
5058
|
suspendedAt: suspendedAt ? suspendedAt instanceof Date ? suspendedAt : new Date(suspendedAt) : void 0,
|
|
5070
|
-
completedAt: completedAt ? completedAt instanceof Date ? completedAt : new Date(completedAt) : void 0
|
|
5059
|
+
completedAt: completedAt ? completedAt instanceof Date ? completedAt : new Date(completedAt) : void 0,
|
|
5060
|
+
ownerId: row.ownerId ?? void 0,
|
|
5061
|
+
leaseExpiresAt: leaseExpiresAt ? leaseExpiresAt instanceof Date ? leaseExpiresAt : new Date(leaseExpiresAt) : void 0
|
|
5071
5062
|
};
|
|
5072
5063
|
}
|
|
5073
5064
|
var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.BackgroundTasksStorage {
|
|
@@ -5107,7 +5098,12 @@ var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.Bac
|
|
|
5107
5098
|
await this.#db.alterTable({
|
|
5108
5099
|
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
5109
5100
|
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
|
|
5110
|
-
ifNotExists: [
|
|
5101
|
+
ifNotExists: [
|
|
5102
|
+
"suspend_payload",
|
|
5103
|
+
"suspendedAt",
|
|
5104
|
+
"ownerId",
|
|
5105
|
+
"leaseExpiresAt"
|
|
5106
|
+
]
|
|
5111
5107
|
});
|
|
5112
5108
|
await this.createDefaultIndexes();
|
|
5113
5109
|
await this.createCustomIndexes();
|
|
@@ -5237,7 +5233,10 @@ var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.Bac
|
|
|
5237
5233
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
5238
5234
|
suspendedAtZ: task.suspendedAt?.toISOString() ?? null,
|
|
5239
5235
|
completedAt: task.completedAt?.toISOString() ?? null,
|
|
5240
|
-
completedAtZ: task.completedAt?.toISOString() ?? null
|
|
5236
|
+
completedAtZ: task.completedAt?.toISOString() ?? null,
|
|
5237
|
+
ownerId: task.ownerId ?? null,
|
|
5238
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null,
|
|
5239
|
+
leaseExpiresAtZ: task.leaseExpiresAt?.toISOString() ?? null
|
|
5241
5240
|
}
|
|
5242
5241
|
});
|
|
5243
5242
|
}
|
|
@@ -5283,14 +5282,34 @@ var BackgroundTasksPG = class BackgroundTasksPG extends _mastra_core_storage.Bac
|
|
|
5283
5282
|
const val = update.completedAt?.toISOString() ?? null;
|
|
5284
5283
|
params.push(val, val);
|
|
5285
5284
|
}
|
|
5285
|
+
if ("ownerId" in update) {
|
|
5286
|
+
setClauses.push(`"ownerId" = $${paramIdx++}`);
|
|
5287
|
+
params.push(update.ownerId ?? null);
|
|
5288
|
+
}
|
|
5289
|
+
if ("leaseExpiresAt" in update) {
|
|
5290
|
+
setClauses.push(`"leaseExpiresAt" = $${paramIdx++}`);
|
|
5291
|
+
setClauses.push(`"leaseExpiresAtZ" = $${paramIdx++}`);
|
|
5292
|
+
const val = update.leaseExpiresAt?.toISOString() ?? null;
|
|
5293
|
+
params.push(val, val);
|
|
5294
|
+
}
|
|
5286
5295
|
if (setClauses.length === 0) return false;
|
|
5287
5296
|
const table = getTableName$4(getSchemaName$4(this.#schema));
|
|
5288
5297
|
params.push(taskId);
|
|
5289
5298
|
let where = `"id" = $${paramIdx++}`;
|
|
5290
5299
|
if (options?.expectedStatus) {
|
|
5291
|
-
where += ` AND "status" = $${paramIdx}`;
|
|
5300
|
+
where += ` AND "status" = $${paramIdx++}`;
|
|
5292
5301
|
params.push(options.expectedStatus);
|
|
5293
5302
|
}
|
|
5303
|
+
if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) where += ` AND "ownerId" IS NULL`;
|
|
5304
|
+
else {
|
|
5305
|
+
where += ` AND "ownerId" = $${paramIdx++}`;
|
|
5306
|
+
params.push(options.expectedOwnerId);
|
|
5307
|
+
}
|
|
5308
|
+
if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) where += ` AND "leaseExpiresAtZ" IS NULL`;
|
|
5309
|
+
else {
|
|
5310
|
+
where += ` AND "leaseExpiresAtZ" = $${paramIdx++}`;
|
|
5311
|
+
params.push(options.expectedLeaseExpiresAt.toISOString());
|
|
5312
|
+
}
|
|
5294
5313
|
return ((await this.#db.client.query(`UPDATE ${table} SET ${setClauses.join(", ")} WHERE ${where}`, params)).rowCount ?? 0) > 0;
|
|
5295
5314
|
}
|
|
5296
5315
|
async getTask(taskId) {
|