@mastra/spanner 1.8.2 → 1.9.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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-storage-retention.md +1 -1
- package/dist/index.cjs +36 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -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/package.json +5 -5
package/dist/docs/SKILL.md
CHANGED
|
@@ -202,7 +202,7 @@ async function retentionTick() {
|
|
|
202
202
|
}
|
|
203
203
|
```
|
|
204
204
|
|
|
205
|
-
You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false
|
|
205
|
+
You can also cancel a long-running prune with an `AbortSignal`: the loop stops between batches and returns partial results with `done: false`. The next run resumes cleanly.
|
|
206
206
|
|
|
207
207
|
## ClickHouse native TTL
|
|
208
208
|
|
package/dist/index.cjs
CHANGED
|
@@ -1860,7 +1860,9 @@ function rowToTask(row) {
|
|
|
1860
1860
|
createdAt: transformed.createdAt instanceof Date ? transformed.createdAt : new Date(transformed.createdAt),
|
|
1861
1861
|
startedAt: transformed.startedAt ? transformed.startedAt instanceof Date ? transformed.startedAt : new Date(transformed.startedAt) : void 0,
|
|
1862
1862
|
suspendedAt: transformed.suspendedAt ? transformed.suspendedAt instanceof Date ? transformed.suspendedAt : new Date(transformed.suspendedAt) : void 0,
|
|
1863
|
-
completedAt: transformed.completedAt ? transformed.completedAt instanceof Date ? transformed.completedAt : new Date(transformed.completedAt) : void 0
|
|
1863
|
+
completedAt: transformed.completedAt ? transformed.completedAt instanceof Date ? transformed.completedAt : new Date(transformed.completedAt) : void 0,
|
|
1864
|
+
ownerId: transformed.ownerId != null ? String(transformed.ownerId) : void 0,
|
|
1865
|
+
leaseExpiresAt: transformed.leaseExpiresAt ? transformed.leaseExpiresAt instanceof Date ? transformed.leaseExpiresAt : new Date(transformed.leaseExpiresAt) : void 0
|
|
1864
1866
|
};
|
|
1865
1867
|
}
|
|
1866
1868
|
var BackgroundTasksSpanner = class BackgroundTasksSpanner extends _mastra_core_storage.BackgroundTasksStorage {
|
|
@@ -1886,6 +1888,16 @@ var BackgroundTasksSpanner = class BackgroundTasksSpanner extends _mastra_core_s
|
|
|
1886
1888
|
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
1887
1889
|
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS]
|
|
1888
1890
|
});
|
|
1891
|
+
await this.db.alterTable({
|
|
1892
|
+
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
1893
|
+
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
|
|
1894
|
+
ifNotExists: [
|
|
1895
|
+
"suspend_payload",
|
|
1896
|
+
"suspendedAt",
|
|
1897
|
+
"ownerId",
|
|
1898
|
+
"leaseExpiresAt"
|
|
1899
|
+
]
|
|
1900
|
+
});
|
|
1889
1901
|
await this.createDefaultIndexes();
|
|
1890
1902
|
await this.createCustomIndexes();
|
|
1891
1903
|
}
|
|
@@ -1964,7 +1976,9 @@ var BackgroundTasksSpanner = class BackgroundTasksSpanner extends _mastra_core_s
|
|
|
1964
1976
|
createdAt: task.createdAt,
|
|
1965
1977
|
startedAt: task.startedAt ?? null,
|
|
1966
1978
|
suspendedAt: task.suspendedAt ?? null,
|
|
1967
|
-
completedAt: task.completedAt ?? null
|
|
1979
|
+
completedAt: task.completedAt ?? null,
|
|
1980
|
+
ownerId: task.ownerId ?? null,
|
|
1981
|
+
leaseExpiresAt: task.leaseExpiresAt ?? null
|
|
1968
1982
|
}
|
|
1969
1983
|
});
|
|
1970
1984
|
}
|
|
@@ -1978,16 +1992,32 @@ var BackgroundTasksSpanner = class BackgroundTasksSpanner extends _mastra_core_s
|
|
|
1978
1992
|
if ("startedAt" in update) data.startedAt = update.startedAt ?? null;
|
|
1979
1993
|
if ("suspendedAt" in update) data.suspendedAt = update.suspendedAt ?? null;
|
|
1980
1994
|
if ("completedAt" in update) data.completedAt = update.completedAt ?? null;
|
|
1995
|
+
if ("ownerId" in update) data.ownerId = update.ownerId ?? null;
|
|
1996
|
+
if ("leaseExpiresAt" in update) data.leaseExpiresAt = update.leaseExpiresAt ?? null;
|
|
1981
1997
|
if (Object.keys(data).length === 0) return false;
|
|
1982
1998
|
const setClauses = Object.keys(data).map((field) => `${quoteIdent(field, "column name")} = @${field}`);
|
|
1983
1999
|
const params = {
|
|
1984
2000
|
...data,
|
|
1985
|
-
id: taskId
|
|
1986
|
-
expectedStatus: options?.expectedStatus
|
|
2001
|
+
id: taskId
|
|
1987
2002
|
};
|
|
1988
|
-
const
|
|
2003
|
+
const predicates = [];
|
|
2004
|
+
if (options?.expectedStatus) {
|
|
2005
|
+
predicates.push("status = @expectedStatus");
|
|
2006
|
+
params.expectedStatus = options.expectedStatus;
|
|
2007
|
+
}
|
|
2008
|
+
if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) predicates.push("ownerId IS NULL");
|
|
2009
|
+
else {
|
|
2010
|
+
predicates.push("ownerId = @expectedOwnerId");
|
|
2011
|
+
params.expectedOwnerId = options.expectedOwnerId;
|
|
2012
|
+
}
|
|
2013
|
+
if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) predicates.push("leaseExpiresAt IS NULL");
|
|
2014
|
+
else {
|
|
2015
|
+
predicates.push("leaseExpiresAt = @expectedLeaseExpiresAt");
|
|
2016
|
+
params.expectedLeaseExpiresAt = options.expectedLeaseExpiresAt;
|
|
2017
|
+
}
|
|
2018
|
+
const predicateSql = predicates.length > 0 ? ` AND ${predicates.join(" AND ")}` : "";
|
|
1989
2019
|
const [rowCount] = await this.database.runUpdate({
|
|
1990
|
-
sql: `UPDATE ${this.tableName()} SET ${setClauses.join(", ")} WHERE id = @id${
|
|
2020
|
+
sql: `UPDATE ${this.tableName()} SET ${setClauses.join(", ")} WHERE id = @id${predicateSql}`,
|
|
1991
2021
|
params
|
|
1992
2022
|
});
|
|
1993
2023
|
return rowCount > 0;
|