@adminforth/auto-remove 1.0.10 → 1.0.11

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.
@@ -0,0 +1,16 @@
1
+ import { AdminForthPlugin } from "adminforth";
2
+ import type { IAdminForth, IHttpServer, AdminForthResource } from "adminforth";
3
+ import type { PluginOptions } from './types.js';
4
+ export default class AutoRemovePlugin extends AdminForthPlugin {
5
+ options: PluginOptions;
6
+ resource?: AdminForthResource;
7
+ timer?: NodeJS.Timeout;
8
+ constructor(options: PluginOptions);
9
+ instanceUniqueRepresentation(pluginOptions: any): string;
10
+ modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource): Promise<void>;
11
+ validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
12
+ private runCleanup;
13
+ private cleanupByCount;
14
+ private cleanupByTime;
15
+ setupEndpoints(server: IHttpServer): void;
16
+ }
@@ -0,0 +1,45 @@
1
+ import { type PluginsCommonOptions } from "adminforth";
2
+ export type AutoRemoveMode = 'count-based' | 'time-based';
3
+ /**
4
+ * count-based 100, 1k, 1kk, 1m
5
+ */
6
+ export type HumanNumber = string;
7
+ /**
8
+ * s
9
+ * min
10
+ * h
11
+ * d
12
+ * w
13
+ * mon
14
+ * y
15
+ */
16
+ export type HumanDuration = string;
17
+ export interface PluginOptions extends PluginsCommonOptions {
18
+ createdAtField: string;
19
+ /**
20
+ * - count-based: Delete items > maxItems
21
+ * - time-based: Delete age > maxAge
22
+ */
23
+ mode: AutoRemoveMode;
24
+ /**
25
+ * for count-based mode (100', '1k', '10k', '1m')
26
+ */
27
+ keepAtLeast?: HumanNumber;
28
+ /**
29
+ * Minimum number of items to always keep in count-based mode.
30
+ * This acts as a safety threshold together with `keepAtLeast`.
31
+ * Example formats: '100', '1k', '10k', '1m'.
32
+ *
33
+ * Validation ensures that minItemsKeep <= keepAtLeast.
34
+ */
35
+ minItemsKeep?: HumanNumber;
36
+ /**
37
+ * Max age of item for time-based mode ('1d', '7d', '1mo', '1y')
38
+ */
39
+ deleteOlderThan?: HumanDuration;
40
+ /**
41
+ * Interval for running cleanup (e.g. '1h', '1d')
42
+ * Default '1d'
43
+ */
44
+ interval?: HumanDuration;
45
+ }
@@ -0,0 +1 @@
1
+ export declare function parseDuration(value: string): number;
@@ -0,0 +1 @@
1
+ export declare function parseHumanNumber(value: string): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/auto-remove",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
package/tsconfig.json CHANGED
@@ -2,6 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include*/
4
4
  "module": "node16", /* Specify what module code is generated. */
5
+ "declaration": true,
5
6
  "outDir": "./dist", /* Specify an output folder for all emitted files. */
6
7
  "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. */
7
8
  "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */