@mastra/mssql 1.9.0 → 1.10.0-alpha.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 +9 -7
- package/dist/index.cjs +34 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -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
|
@@ -15,7 +15,7 @@ Storage adapters use the shared core retention contract for `prune()`, or a data
|
|
|
15
15
|
| Adapter | Mechanism | Retention support |
|
|
16
16
|
| -------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
17
|
| libSQL | `prune()` | All supported growth domains |
|
|
18
|
-
| PostgreSQL | `prune()` | All supported growth domains.
|
|
18
|
+
| PostgreSQL | `prune()` | All supported growth domains. vNext observability drops expired partitions or chunks |
|
|
19
19
|
| MongoDB | `prune()` or native TTL | All supported growth domains. Native TTL indexes are also available |
|
|
20
20
|
| DuckDB | `prune()` | Observability spans, metrics, logs, scores, and feedback |
|
|
21
21
|
| MySQL | `prune()` | Observability spans |
|
|
@@ -102,10 +102,10 @@ Each domain specifies its age-prunable tables and the timestamp column that anch
|
|
|
102
102
|
| `memory` | `resources` | `createdAt` | Resource age |
|
|
103
103
|
| `threadState` | `threadState` | `updatedAt` | Inactivity: state for still-active threads survives |
|
|
104
104
|
| `observability` | `spans` | `startedAt` | Span age |
|
|
105
|
-
| `observability` | `metrics` | `timestamp` | Metric event age (
|
|
106
|
-
| `observability` | `logs` | `timestamp` | Log event age (
|
|
107
|
-
| `observability` | `scores` | `timestamp` | Score event age (
|
|
108
|
-
| `observability` | `feedback` | `timestamp` | Feedback event age (
|
|
105
|
+
| `observability` | `metrics` | `timestamp` | Metric event age (vNext only) |
|
|
106
|
+
| `observability` | `logs` | `timestamp` | Log event age (vNext only) |
|
|
107
|
+
| `observability` | `scores` | `timestamp` | Score event age (vNext only) |
|
|
108
|
+
| `observability` | `feedback` | `timestamp` | Feedback event age (vNext only) |
|
|
109
109
|
| `scores` | `scorers` | `createdAt` | Score record age |
|
|
110
110
|
| `workflows` | `workflowSnapshot` | `updatedAt` | Inactivity, suspended or long-running workflows survive |
|
|
111
111
|
| `backgroundTasks` | `backgroundTasks` | `completedAt` | Time since completion, in-flight tasks (`NULL`) are never pruned |
|
|
@@ -122,7 +122,7 @@ Each domain specifies its age-prunable tables and the timestamp column that anch
|
|
|
122
122
|
> - On PostgreSQL, timestamp anchors use the timezone-aware mirror columns (for example `createdAtZ`, `completedAtZ`).
|
|
123
123
|
> - DuckDB observability stores append-only events for all five signals. Its `spans` policy uses the event `timestamp` column rather than `startedAt`.
|
|
124
124
|
> - LibSQL and PostgreSQL support all domains above except `harness`, which PostgreSQL doesn't implement. MongoDB supports all except `threadState` and `harness`. DuckDB, MySQL, Microsoft SQL Server, Oracle Database, Amazon Aurora DSQL, and Google Cloud Spanner currently support retention only in their `observability` domains, with the signal coverage shown in the support matrix.
|
|
125
|
-
> - The
|
|
125
|
+
> - The vNext PostgreSQL observability domain stores signal events in day-partitioned tables (`spans`, `metrics`, `logs`, `scores`, `feedback`). For it, `prune()` drops whole day partitions (or TimescaleDB chunks) that are entirely older than the cutoff instead of deleting rows: effective level of detail is one day, and a partition is only dropped once its entire day is past `maxAge`. `PruneResult.deleted` reports the number of rows in the dropped partitions.
|
|
126
126
|
|
|
127
127
|
## Methods
|
|
128
128
|
|
|
@@ -208,7 +208,9 @@ You can also cancel a long-running prune with an `AbortSignal`: the loop stops b
|
|
|
208
208
|
|
|
209
209
|
ClickHouse observability storage uses native table TTLs instead of `prune()`. Configure retention as days per signal. `init()` applies the TTLs to new and existing tables and skips `ALTER TABLE` statements when the configured TTL is already present.
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
Omitted signals, and signals set to zero or less, get no TTL. When you remove a signal from `retention`, the next `init()` or `applyRetention()` removes that table's TTL. If Mastra can't read the current TTLs from `system.tables`, it applies the configured TTLs and leaves the others unchanged.
|
|
212
|
+
|
|
213
|
+
For deployments that need to update TTL configuration without running the full initialization path, call `applyRetention()` on the vNext observability store:
|
|
212
214
|
|
|
213
215
|
```typescript
|
|
214
216
|
import { ObservabilityStorageClickhouseVNext } from '@mastra/clickhouse'
|
package/dist/index.cjs
CHANGED
|
@@ -1804,7 +1804,9 @@ function rowToTask(row) {
|
|
|
1804
1804
|
createdAt: row.createdAt instanceof Date ? row.createdAt : new Date(row.createdAt),
|
|
1805
1805
|
startedAt: row.startedAt ? row.startedAt instanceof Date ? row.startedAt : new Date(row.startedAt) : void 0,
|
|
1806
1806
|
suspendedAt: row.suspendedAt ? row.suspendedAt instanceof Date ? row.suspendedAt : new Date(row.suspendedAt) : void 0,
|
|
1807
|
-
completedAt: row.completedAt ? row.completedAt instanceof Date ? row.completedAt : new Date(row.completedAt) : void 0
|
|
1807
|
+
completedAt: row.completedAt ? row.completedAt instanceof Date ? row.completedAt : new Date(row.completedAt) : void 0,
|
|
1808
|
+
ownerId: row.ownerId ?? void 0,
|
|
1809
|
+
leaseExpiresAt: row.leaseExpiresAt ? row.leaseExpiresAt instanceof Date ? row.leaseExpiresAt : new Date(row.leaseExpiresAt) : void 0
|
|
1808
1810
|
};
|
|
1809
1811
|
}
|
|
1810
1812
|
var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_storage.BackgroundTasksStorage {
|
|
@@ -1841,7 +1843,12 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
|
|
|
1841
1843
|
await this.db.alterTable({
|
|
1842
1844
|
tableName: _mastra_core_storage.TABLE_BACKGROUND_TASKS,
|
|
1843
1845
|
schema: _mastra_core_storage.TABLE_SCHEMAS[_mastra_core_storage.TABLE_BACKGROUND_TASKS],
|
|
1844
|
-
ifNotExists: [
|
|
1846
|
+
ifNotExists: [
|
|
1847
|
+
"suspend_payload",
|
|
1848
|
+
"suspendedAt",
|
|
1849
|
+
"ownerId",
|
|
1850
|
+
"leaseExpiresAt"
|
|
1851
|
+
]
|
|
1845
1852
|
});
|
|
1846
1853
|
await this.createDefaultIndexes();
|
|
1847
1854
|
await this.createCustomIndexes();
|
|
@@ -1918,7 +1925,9 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
|
|
|
1918
1925
|
createdAt: task.createdAt.toISOString(),
|
|
1919
1926
|
startedAt: task.startedAt?.toISOString() ?? null,
|
|
1920
1927
|
suspendedAt: task.suspendedAt?.toISOString() ?? null,
|
|
1921
|
-
completedAt: task.completedAt?.toISOString() ?? null
|
|
1928
|
+
completedAt: task.completedAt?.toISOString() ?? null,
|
|
1929
|
+
ownerId: task.ownerId ?? null,
|
|
1930
|
+
leaseExpiresAt: task.leaseExpiresAt?.toISOString() ?? null
|
|
1922
1931
|
}
|
|
1923
1932
|
});
|
|
1924
1933
|
}
|
|
@@ -1958,18 +1967,37 @@ var BackgroundTasksMSSQL = class BackgroundTasksMSSQL extends _mastra_core_stora
|
|
|
1958
1967
|
setClauses.push(`[completedAt] = @p${idx}`);
|
|
1959
1968
|
params[`p${idx++}`] = update.completedAt?.toISOString() ?? null;
|
|
1960
1969
|
}
|
|
1970
|
+
if ("ownerId" in update) {
|
|
1971
|
+
setClauses.push(`[ownerId] = @p${idx}`);
|
|
1972
|
+
params[`p${idx++}`] = update.ownerId ?? null;
|
|
1973
|
+
}
|
|
1974
|
+
if ("leaseExpiresAt" in update) {
|
|
1975
|
+
setClauses.push(`[leaseExpiresAt] = @p${idx}`);
|
|
1976
|
+
params[`p${idx++}`] = update.leaseExpiresAt?.toISOString() ?? null;
|
|
1977
|
+
}
|
|
1961
1978
|
if (setClauses.length === 0) return false;
|
|
1962
1979
|
setClauses.push(`[id] = [id]`);
|
|
1963
1980
|
params[`p${idx}`] = taskId;
|
|
1964
1981
|
const taskIdParam = `p${idx++}`;
|
|
1965
|
-
|
|
1982
|
+
const predicates = [];
|
|
1966
1983
|
if (options?.expectedStatus) {
|
|
1967
1984
|
params[`p${idx}`] = options.expectedStatus;
|
|
1968
|
-
|
|
1985
|
+
predicates.push(`[status] = @p${idx++}`);
|
|
1986
|
+
}
|
|
1987
|
+
if (options?.expectedOwnerId !== void 0) if (options.expectedOwnerId === null) predicates.push(`[ownerId] IS NULL`);
|
|
1988
|
+
else {
|
|
1989
|
+
params[`p${idx}`] = options.expectedOwnerId;
|
|
1990
|
+
predicates.push(`[ownerId] = @p${idx++}`);
|
|
1991
|
+
}
|
|
1992
|
+
if (options?.expectedLeaseExpiresAt !== void 0) if (options.expectedLeaseExpiresAt === null) predicates.push(`[leaseExpiresAt] IS NULL`);
|
|
1993
|
+
else {
|
|
1994
|
+
params[`p${idx}`] = options.expectedLeaseExpiresAt.toISOString();
|
|
1995
|
+
predicates.push(`[leaseExpiresAt] = @p${idx++}`);
|
|
1969
1996
|
}
|
|
1997
|
+
const predicateSql = predicates.length > 0 ? ` AND ${predicates.join(" AND ")}` : "";
|
|
1970
1998
|
const request = this.pool.request();
|
|
1971
1999
|
for (const [name, value] of Object.entries(params)) request.input(name, value);
|
|
1972
|
-
return ((await request.query(`UPDATE ${this.tableName()} SET ${setClauses.join(", ")} WHERE [id] = @${taskIdParam}${
|
|
2000
|
+
return ((await request.query(`UPDATE ${this.tableName()} SET ${setClauses.join(", ")} WHERE [id] = @${taskIdParam}${predicateSql}`)).rowsAffected[0] ?? 0) > 0;
|
|
1973
2001
|
}
|
|
1974
2002
|
async getTask(taskId) {
|
|
1975
2003
|
const request = this.pool.request();
|