Skip to content

Commit 54500d0

Browse files
committed
Fix: rename options maxAge to deleteOlderThan and maxItems to keepAtLeast
1 parent 14532ae commit 54500d0

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ export default class AutoRemovePlugin extends AdminForthPlugin {
3838

3939
// Check mode-specific options
4040
if (this.options.mode === 'count-based') {
41-
if (!this.options.maxItems) {
42-
throw new Error('maxItems is required for count-based mode');
41+
if (!this.options.keepAtLeast) {
42+
throw new Error('keepAtLeast is required for count-based mode');
4343
}
44-
if (this.options.minItemsKeep && parseHumanNumber(this.options.minItemsKeep) > parseHumanNumber(this.options.maxItems)) {
44+
if (this.options.minItemsKeep && parseHumanNumber(this.options.minItemsKeep) > parseHumanNumber(this.options.keepAtLeast)) {
4545
throw new Error(
46-
`Option "minItemsKeep" (${this.options.minItemsKeep}) cannot be greater than "maxItems" (${this.options.maxItems}). Please set "minItemsKeep" less than or equal to "maxItems`
46+
`Option "minItemsKeep" (${this.options.minItemsKeep}) cannot be greater than "keepAtLeast" (${this.options.keepAtLeast}). Please set "minItemsKeep" less than or equal to "maxItems`
4747
);
4848
}
4949
}
50-
if (this.options.mode === 'time-based' && !this.options.maxAge) {
51-
throw new Error('maxAge is required for time-based mode');
50+
if (this.options.mode === 'time-based' && !this.options.deleteOlderThan) {
51+
throw new Error('deleteOlderThan is required for time-based mode');
5252
}
5353
}
5454

@@ -65,7 +65,7 @@ export default class AutoRemovePlugin extends AdminForthPlugin {
6565
}
6666

6767
private async cleanupByCount(adminforth: IAdminForth) {
68-
const limit = parseHumanNumber(this.options.maxItems!);
68+
const limit = parseHumanNumber(this.options.keepAtLeast!);
6969
const resource = adminforth.resource(this.resource.resourceId);
7070

7171
const allRecords = await resource.list([], null, null, [Sorts.ASC(this.options.createdAtField)]);
@@ -79,7 +79,7 @@ export default class AutoRemovePlugin extends AdminForthPlugin {
7979
}
8080

8181
private async cleanupByTime(adminforth: IAdminForth) {
82-
const maxAgeMs = parseDuration(this.options.maxAge!);
82+
const maxAgeMs = parseDuration(this.options.deleteOlderThan!);
8383
const threshold = Date.now() - maxAgeMs;
8484
const resource = adminforth.resource(this.resource.resourceId);
8585

types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ export interface PluginOptions {
2828
/**
2929
* for count-based mode (100', '1k', '10k', '1m')
3030
*/
31-
maxItems?: HumanNumber;
31+
keepAtLeast?: HumanNumber;
3232

3333
/**
3434
* For count-based mode, keep at least X items even if they are older than maxItems (100', '1k', '10k', '1m')
3535
*/
3636
minItemsKeep?: HumanNumber;
3737

3838
/**
39-
* Max age of otem for time-based режиму ('1d', '7d', '1mon', '1y')
39+
* Max age of item for time-based mode ('1d', '7d', '1mon', '1y')
4040
*/
41-
maxAge?: HumanDuration;
41+
deleteOlderThan?: HumanDuration;
4242

4343
/**
4444
* Interval for running cleanup (e.g. '1h', '1d')

0 commit comments

Comments
 (0)