@mastra/mysql 0.13.1 → 0.13.2
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 +58 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +58 -0
- package/dist/index.js.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/operations/index.d.ts +1 -1
- package/dist/storage/domains/operations/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 +5 -5
package/dist/index.js
CHANGED
|
@@ -6282,6 +6282,17 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
6282
6282
|
TABLE_MESSAGES,
|
|
6283
6283
|
TABLE_RESOURCES
|
|
6284
6284
|
];
|
|
6285
|
+
/**
|
|
6286
|
+
* Tables `prune()` can clean up. Run fences anchor on `retiredAt` (epoch ms), which stays NULL until the
|
|
6287
|
+
* execution holding the fence settles, so a running execution's fence is
|
|
6288
|
+
* never pruned.
|
|
6289
|
+
*/
|
|
6290
|
+
static retentionTables = { runFences: {
|
|
6291
|
+
table: TABLE_MEMORY_RUN_FENCES,
|
|
6292
|
+
column: "retiredAt",
|
|
6293
|
+
indexed: false,
|
|
6294
|
+
anchorType: "epoch-ms"
|
|
6295
|
+
} };
|
|
6285
6296
|
constructor({ pool, operations, skipDefaultIndexes, indexes }) {
|
|
6286
6297
|
super();
|
|
6287
6298
|
this.pool = pool;
|
|
@@ -6454,6 +6465,24 @@ var MemoryMySQL = class MemoryMySQL extends MemoryStorage {
|
|
|
6454
6465
|
if (!this.#indexes || this.#indexes.length === 0) return;
|
|
6455
6466
|
for (const indexDef of this.#indexes) await this.operations.createIndex(indexDef);
|
|
6456
6467
|
}
|
|
6468
|
+
async prune(policies, options) {
|
|
6469
|
+
return executeRetentionPrune({
|
|
6470
|
+
domain: "memory",
|
|
6471
|
+
targets: resolveRetentionTargets({
|
|
6472
|
+
policies,
|
|
6473
|
+
descriptor: MemoryMySQL.retentionTables,
|
|
6474
|
+
order: ["runFences"]
|
|
6475
|
+
}),
|
|
6476
|
+
options,
|
|
6477
|
+
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
6478
|
+
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
6479
|
+
tableName: target.table,
|
|
6480
|
+
column: target.column,
|
|
6481
|
+
cutoff,
|
|
6482
|
+
limit
|
|
6483
|
+
})
|
|
6484
|
+
});
|
|
6485
|
+
}
|
|
6457
6486
|
async dangerouslyClearAll() {
|
|
6458
6487
|
await this.pool.execute(`DELETE FROM ${formatTableName(TABLE_MESSAGES)}`);
|
|
6459
6488
|
await this.pool.execute(`DELETE FROM ${formatTableName(TABLE_THREADS)}`);
|
|
@@ -11359,6 +11388,17 @@ var WorkflowsMySQL = class WorkflowsMySQL extends WorkflowsStorage {
|
|
|
11359
11388
|
/** Tables managed by this domain */
|
|
11360
11389
|
static MANAGED_TABLES = [TABLE_WORKFLOW_SNAPSHOT];
|
|
11361
11390
|
/**
|
|
11391
|
+
* Tables `prune()` can clean up. Run ownership rows anchor on `updatedAt` (epoch ms), which every
|
|
11392
|
+
* claim, renewal and release refreshes, so a live execution's row is never
|
|
11393
|
+
* older than its renew interval.
|
|
11394
|
+
*/
|
|
11395
|
+
static retentionTables = { runOwnership: {
|
|
11396
|
+
table: TABLE_WORKFLOW_RUN_OWNERS,
|
|
11397
|
+
column: "updatedAt",
|
|
11398
|
+
indexed: false,
|
|
11399
|
+
anchorType: "epoch-ms"
|
|
11400
|
+
} };
|
|
11401
|
+
/**
|
|
11362
11402
|
* Returns default index definitions for the workflows domain tables.
|
|
11363
11403
|
* Currently no default indexes are defined for workflows.
|
|
11364
11404
|
*/
|
|
@@ -11426,6 +11466,24 @@ var WorkflowsMySQL = class WorkflowsMySQL extends WorkflowsStorage {
|
|
|
11426
11466
|
await this.createDefaultIndexes();
|
|
11427
11467
|
await this.createCustomIndexes();
|
|
11428
11468
|
}
|
|
11469
|
+
async prune(policies, options) {
|
|
11470
|
+
return executeRetentionPrune({
|
|
11471
|
+
domain: "workflows",
|
|
11472
|
+
targets: resolveRetentionTargets({
|
|
11473
|
+
policies,
|
|
11474
|
+
descriptor: WorkflowsMySQL.retentionTables,
|
|
11475
|
+
order: ["runOwnership"]
|
|
11476
|
+
}),
|
|
11477
|
+
options,
|
|
11478
|
+
cutoffFor: (target, now) => retentionCutoffMs(target.policy, now),
|
|
11479
|
+
deleteBatch: (target, cutoff, limit) => this.operations.pruneBatch({
|
|
11480
|
+
tableName: target.table,
|
|
11481
|
+
column: target.column,
|
|
11482
|
+
cutoff,
|
|
11483
|
+
limit
|
|
11484
|
+
})
|
|
11485
|
+
});
|
|
11486
|
+
}
|
|
11429
11487
|
async dangerouslyClearAll() {
|
|
11430
11488
|
await this.pool.execute(`DELETE FROM ${formatTableName(TABLE_WORKFLOW_SNAPSHOT)}`);
|
|
11431
11489
|
await this.pool.execute(`DELETE FROM ${RUN_OWNERS_TABLE}`);
|