@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/index.js
CHANGED
|
@@ -220,7 +220,7 @@ var MssqlDB = class extends MastraBase {
|
|
|
220
220
|
indexName: tableName,
|
|
221
221
|
schemaName: getSchemaName$1(this.schemaName)
|
|
222
222
|
});
|
|
223
|
-
return (await this.pool.request().input("limit", sql.Int, limit).input("cutoff", sql.DateTime2, cutoff).query(`DELETE TOP (@limit) FROM ${fullTableName} WHERE [${column}] < @cutoff`)).rowsAffected[0] ?? 0;
|
|
223
|
+
return (await this.pool.request().input("limit", sql.Int, limit).input("cutoff", typeof cutoff === "number" ? sql.BigInt : sql.DateTime2, cutoff).query(`DELETE TOP (@limit) FROM ${fullTableName} WHERE [${column}] < @cutoff`)).rowsAffected[0] ?? 0;
|
|
224
224
|
}
|
|
225
225
|
async clearTable({ tableName }) {
|
|
226
226
|
const fullTableName = getTableName$1({
|
|
@@ -2213,6 +2213,17 @@ var MemoryMSSQL = class MemoryMSSQL extends MemoryStorage {
|
|
|
2213
2213
|
TABLE_MESSAGES,
|
|
2214
2214
|
TABLE_RESOURCES
|
|
2215
2215
|
];
|
|
2216
|
+
/**
|
|
2217
|
+
* Tables `prune()` can clean up. Run fences anchor on `retiredAt` (epoch ms), which stays NULL until the
|
|
2218
|
+
* execution holding the fence settles, so a running execution's fence is
|
|
2219
|
+
* never pruned.
|
|
2220
|
+
*/
|
|
2221
|
+
static retentionTables = { runFences: {
|
|
2222
|
+
table: TABLE_MEMORY_RUN_FENCES,
|
|
2223
|
+
column: "retiredAt",
|
|
2224
|
+
indexed: false,
|
|
2225
|
+
anchorType: "epoch-ms"
|
|
2226
|
+
} };
|
|
2216
2227
|
_parseAndFormatMessages(messages, format) {
|
|
2217
2228
|
const cleanMessages = messages.map((message) => {
|
|
2218
2229
|
if (typeof message.content === "string") try {
|
|
@@ -2360,6 +2371,24 @@ var MemoryMSSQL = class MemoryMSSQL extends MemoryStorage {
|
|
|
2360
2371
|
this.logger?.warn?.(`Failed to create custom index ${indexDef.name}:`, error);
|
|
2361
2372
|
}
|
|
2362
2373
|
}
|
|
2374
|
+
async prune(policies, options) {
|
|
2375
|
+
return executeRetentionPrune({
|
|
2376
|
+
domain: "memory",
|
|
2377
|
+
targets: resolveRetentionTargets({
|
|
2378
|
+
policies,
|
|
2379
|
+
descriptor: MemoryMSSQL.retentionTables,
|
|
2380
|
+
order: ["runFences"]
|
|
2381
|
+
}),
|
|
2382
|
+
options,
|
|
2383
|
+
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
2384
|
+
deleteBatch: (target, cutoff, limit) => this.db.pruneBatch({
|
|
2385
|
+
tableName: target.table,
|
|
2386
|
+
column: target.column,
|
|
2387
|
+
cutoff,
|
|
2388
|
+
limit
|
|
2389
|
+
})
|
|
2390
|
+
});
|
|
2391
|
+
}
|
|
2363
2392
|
async dangerouslyClearAll() {
|
|
2364
2393
|
await this.db.clearTable({ tableName: TABLE_MESSAGES });
|
|
2365
2394
|
await this.db.clearTable({ tableName: TABLE_THREADS });
|
|
@@ -4584,6 +4613,17 @@ var WorkflowsMSSQL = class WorkflowsMSSQL extends WorkflowsStorage {
|
|
|
4584
4613
|
indexes;
|
|
4585
4614
|
/** Tables managed by this domain */
|
|
4586
4615
|
static MANAGED_TABLES = [TABLE_WORKFLOW_SNAPSHOT];
|
|
4616
|
+
/**
|
|
4617
|
+
* Tables `prune()` can clean up. Run ownership rows anchor on `updatedAt` (epoch ms), which every
|
|
4618
|
+
* claim, renewal and release refreshes, so a live execution's row is never
|
|
4619
|
+
* older than its renew interval.
|
|
4620
|
+
*/
|
|
4621
|
+
static retentionTables = { runOwnership: {
|
|
4622
|
+
table: TABLE_WORKFLOW_RUN_OWNERS,
|
|
4623
|
+
column: "updatedAt",
|
|
4624
|
+
indexed: false,
|
|
4625
|
+
anchorType: "epoch-ms"
|
|
4626
|
+
} };
|
|
4587
4627
|
constructor(config) {
|
|
4588
4628
|
super();
|
|
4589
4629
|
const { pool, schemaName, skipDefaultIndexes, indexes, needsConnect } = resolveMssqlConfig(config);
|
|
@@ -4642,6 +4682,24 @@ var WorkflowsMSSQL = class WorkflowsMSSQL extends WorkflowsStorage {
|
|
|
4642
4682
|
this.logger?.warn?.(`Failed to create custom index ${indexDef.name}:`, error);
|
|
4643
4683
|
}
|
|
4644
4684
|
}
|
|
4685
|
+
async prune(policies, options) {
|
|
4686
|
+
return executeRetentionPrune({
|
|
4687
|
+
domain: "workflows",
|
|
4688
|
+
targets: resolveRetentionTargets({
|
|
4689
|
+
policies,
|
|
4690
|
+
descriptor: WorkflowsMSSQL.retentionTables,
|
|
4691
|
+
order: ["runOwnership"]
|
|
4692
|
+
}),
|
|
4693
|
+
options,
|
|
4694
|
+
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
4695
|
+
deleteBatch: (target, cutoff, limit) => this.db.pruneBatch({
|
|
4696
|
+
tableName: target.table,
|
|
4697
|
+
column: target.column,
|
|
4698
|
+
cutoff,
|
|
4699
|
+
limit
|
|
4700
|
+
})
|
|
4701
|
+
});
|
|
4702
|
+
}
|
|
4645
4703
|
async dangerouslyClearAll() {
|
|
4646
4704
|
await this.db.clearTable({ tableName: TABLE_WORKFLOW_SNAPSHOT });
|
|
4647
4705
|
await this.db.clearTable({ tableName: TABLE_WORKFLOW_RUN_OWNERS });
|