@mastra/mssql 1.10.3 → 1.10.4-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 +15 -12
- package/dist/index.cjs +59 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +59 -1
- package/dist/index.js.map +1 -1
- package/dist/storage/db/index.d.ts +1 -1
- package/dist/storage/db/index.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +8 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +8 -1
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/docs/SKILL.md
CHANGED
|
@@ -12,18 +12,21 @@ Retention covers **growth tables** only: tables that accumulate rows unbounded a
|
|
|
12
12
|
|
|
13
13
|
Storage adapters use the shared core retention contract for `prune()`, or a database-native mechanism when that better matches the backend.
|
|
14
14
|
|
|
15
|
-
| Adapter
|
|
16
|
-
|
|
|
17
|
-
| libSQL
|
|
18
|
-
| PostgreSQL
|
|
19
|
-
| MongoDB
|
|
20
|
-
| DuckDB
|
|
21
|
-
| MySQL
|
|
22
|
-
| Microsoft SQL Server
|
|
23
|
-
| Oracle Database
|
|
24
|
-
| Amazon Aurora DSQL
|
|
25
|
-
| Google Cloud Spanner
|
|
26
|
-
|
|
|
15
|
+
| Adapter | Mechanism | Retention support |
|
|
16
|
+
| --------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| libSQL | `prune()` | All supported growth domains |
|
|
18
|
+
| PostgreSQL | `prune()` | All supported growth domains. vNext observability drops expired partitions or chunks |
|
|
19
|
+
| MongoDB | `prune()` or native TTL | All supported growth domains. Native TTL indexes are also available |
|
|
20
|
+
| DuckDB | `prune()` | Observability spans, metrics, logs, scores, and feedback |
|
|
21
|
+
| MySQL | `prune()` | Observability spans, durable agent run fencing (`runOwnership`, `runFences`) |
|
|
22
|
+
| Microsoft SQL Server | `prune()` | Observability spans, durable agent run fencing (`runOwnership`, `runFences`) |
|
|
23
|
+
| Oracle Database | `prune()` | Observability spans and logs, durable agent run fencing (`runOwnership`, `runFences`) |
|
|
24
|
+
| Amazon Aurora DSQL | `prune()` | Observability spans, durable agent run fencing (`runOwnership`, `runFences`) |
|
|
25
|
+
| Google Cloud Spanner | `prune()` | Observability spans, plus metrics when metrics storage is enabled. Durable agent run fencing (`runOwnership`, `runFences`) |
|
|
26
|
+
| DynamoDB | `prune()` | Durable agent run fencing (`runOwnership`, `runFences`) |
|
|
27
|
+
| Convex | `prune()` | Durable agent run fencing (`runOwnership`, `runFences`). Redeploy your Convex functions after upgrading |
|
|
28
|
+
| Cloudflare D1 and Durable Objects | `prune()` | Durable agent run fencing (`runOwnership`, `runFences`) |
|
|
29
|
+
| ClickHouse | Native TTL | Observability spans, metrics, logs, scores, and feedback. When all five signals have finite retention, deletion-request records expire after the longest signal retention plus 30 days |
|
|
27
30
|
|
|
28
31
|
## Storage-specific maintenance
|
|
29
32
|
|
package/dist/index.cjs
CHANGED
|
@@ -244,7 +244,7 @@ var MssqlDB = class extends _mastra_core_base.MastraBase {
|
|
|
244
244
|
indexName: tableName,
|
|
245
245
|
schemaName: getSchemaName$1(this.schemaName)
|
|
246
246
|
});
|
|
247
|
-
return (await this.pool.request().input("limit", mssql.default.Int, limit).input("cutoff", mssql.default.DateTime2, cutoff).query(`DELETE TOP (@limit) FROM ${fullTableName} WHERE [${column}] < @cutoff`)).rowsAffected[0] ?? 0;
|
|
247
|
+
return (await this.pool.request().input("limit", mssql.default.Int, limit).input("cutoff", typeof cutoff === "number" ? mssql.default.BigInt : mssql.default.DateTime2, cutoff).query(`DELETE TOP (@limit) FROM ${fullTableName} WHERE [${column}] < @cutoff`)).rowsAffected[0] ?? 0;
|
|
248
248
|
}
|
|
249
249
|
async clearTable({ tableName }) {
|
|
250
250
|
const fullTableName = getTableName$1({
|
|
@@ -2237,6 +2237,17 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2237
2237
|
_mastra_core_storage.TABLE_MESSAGES,
|
|
2238
2238
|
_mastra_core_storage.TABLE_RESOURCES
|
|
2239
2239
|
];
|
|
2240
|
+
/**
|
|
2241
|
+
* Tables `prune()` can clean up. Run fences anchor on `retiredAt` (epoch ms), which stays NULL until the
|
|
2242
|
+
* execution holding the fence settles, so a running execution's fence is
|
|
2243
|
+
* never pruned.
|
|
2244
|
+
*/
|
|
2245
|
+
static retentionTables = { runFences: {
|
|
2246
|
+
table: _mastra_core_storage.TABLE_MEMORY_RUN_FENCES,
|
|
2247
|
+
column: "retiredAt",
|
|
2248
|
+
indexed: false,
|
|
2249
|
+
anchorType: "epoch-ms"
|
|
2250
|
+
} };
|
|
2240
2251
|
_parseAndFormatMessages(messages, format) {
|
|
2241
2252
|
const cleanMessages = messages.map((message) => {
|
|
2242
2253
|
if (typeof message.content === "string") try {
|
|
@@ -2384,6 +2395,24 @@ var MemoryMSSQL = class MemoryMSSQL extends _mastra_core_storage.MemoryStorage {
|
|
|
2384
2395
|
this.logger?.warn?.(`Failed to create custom index ${indexDef.name}:`, error);
|
|
2385
2396
|
}
|
|
2386
2397
|
}
|
|
2398
|
+
async prune(policies, options) {
|
|
2399
|
+
return (0, _mastra_core_storage.executeRetentionPrune)({
|
|
2400
|
+
domain: "memory",
|
|
2401
|
+
targets: (0, _mastra_core_storage.resolveRetentionTargets)({
|
|
2402
|
+
policies,
|
|
2403
|
+
descriptor: MemoryMSSQL.retentionTables,
|
|
2404
|
+
order: ["runFences"]
|
|
2405
|
+
}),
|
|
2406
|
+
options,
|
|
2407
|
+
cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
|
|
2408
|
+
deleteBatch: (target, cutoff, limit) => this.db.pruneBatch({
|
|
2409
|
+
tableName: target.table,
|
|
2410
|
+
column: target.column,
|
|
2411
|
+
cutoff,
|
|
2412
|
+
limit
|
|
2413
|
+
})
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2387
2416
|
async dangerouslyClearAll() {
|
|
2388
2417
|
await this.db.clearTable({ tableName: _mastra_core_storage.TABLE_MESSAGES });
|
|
2389
2418
|
await this.db.clearTable({ tableName: _mastra_core_storage.TABLE_THREADS });
|
|
@@ -4608,6 +4637,17 @@ var WorkflowsMSSQL = class WorkflowsMSSQL extends _mastra_core_storage.Workflows
|
|
|
4608
4637
|
indexes;
|
|
4609
4638
|
/** Tables managed by this domain */
|
|
4610
4639
|
static MANAGED_TABLES = [_mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT];
|
|
4640
|
+
/**
|
|
4641
|
+
* Tables `prune()` can clean up. Run ownership rows anchor on `updatedAt` (epoch ms), which every
|
|
4642
|
+
* claim, renewal and release refreshes, so a live execution's row is never
|
|
4643
|
+
* older than its renew interval.
|
|
4644
|
+
*/
|
|
4645
|
+
static retentionTables = { runOwnership: {
|
|
4646
|
+
table: _mastra_core_storage.TABLE_WORKFLOW_RUN_OWNERS,
|
|
4647
|
+
column: "updatedAt",
|
|
4648
|
+
indexed: false,
|
|
4649
|
+
anchorType: "epoch-ms"
|
|
4650
|
+
} };
|
|
4611
4651
|
constructor(config) {
|
|
4612
4652
|
super();
|
|
4613
4653
|
const { pool, schemaName, skipDefaultIndexes, indexes, needsConnect } = resolveMssqlConfig(config);
|
|
@@ -4666,6 +4706,24 @@ var WorkflowsMSSQL = class WorkflowsMSSQL extends _mastra_core_storage.Workflows
|
|
|
4666
4706
|
this.logger?.warn?.(`Failed to create custom index ${indexDef.name}:`, error);
|
|
4667
4707
|
}
|
|
4668
4708
|
}
|
|
4709
|
+
async prune(policies, options) {
|
|
4710
|
+
return (0, _mastra_core_storage.executeRetentionPrune)({
|
|
4711
|
+
domain: "workflows",
|
|
4712
|
+
targets: (0, _mastra_core_storage.resolveRetentionTargets)({
|
|
4713
|
+
policies,
|
|
4714
|
+
descriptor: WorkflowsMSSQL.retentionTables,
|
|
4715
|
+
order: ["runOwnership"]
|
|
4716
|
+
}),
|
|
4717
|
+
options,
|
|
4718
|
+
cutoffFor: (target, now) => (0, _mastra_core_storage.retentionCutoffMs)(target.policy, now),
|
|
4719
|
+
deleteBatch: (target, cutoff, limit) => this.db.pruneBatch({
|
|
4720
|
+
tableName: target.table,
|
|
4721
|
+
column: target.column,
|
|
4722
|
+
cutoff,
|
|
4723
|
+
limit
|
|
4724
|
+
})
|
|
4725
|
+
});
|
|
4726
|
+
}
|
|
4669
4727
|
async dangerouslyClearAll() {
|
|
4670
4728
|
await this.db.clearTable({ tableName: _mastra_core_storage.TABLE_WORKFLOW_SNAPSHOT });
|
|
4671
4729
|
await this.db.clearTable({ tableName: _mastra_core_storage.TABLE_WORKFLOW_RUN_OWNERS });
|