verdaccio-stats 0.3.3 → 0.4.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/README.md +5 -2
- package/lib/config.d.ts +19 -66
- package/lib/constants.d.ts +2 -1
- package/lib/index.js +416 -245
- package/lib/index.mjs +396 -226
- package/lib/middlewares/stats.d.ts +2 -0
- package/lib/migrations.d.ts +2 -2
- package/lib/models.d.ts +11 -40
- package/lib/storage/db.d.ts +12 -14
- package/lib/storage/entry.d.ts +5 -0
- package/lib/storage/types.d.ts +27 -0
- package/lib/utils.d.ts +15 -0
- package/package.json +33 -30
package/README.md
CHANGED
|
@@ -54,6 +54,8 @@ middlewares:
|
|
|
54
54
|
iso-week: false # Optional, whether to use ISO week format
|
|
55
55
|
count-downloads: true # Optional, whether to count downloads
|
|
56
56
|
count-manifest-views: true # Optional, whether to count manifest views
|
|
57
|
+
flush-interval: 5s # Optional: flush interval (number ms or duration string). 0 means realtime flush.
|
|
58
|
+
max-pending-entries: 10000 # Optional: flush when pending entry keys reach this size
|
|
57
59
|
```
|
|
58
60
|
|
|
59
61
|
Note: SQLite is the default database type, but for performance reason, it is not recommended for production use. For production, consider using MySQL, PostgreSQL, MariaDB, or MSSQL.
|
|
@@ -70,10 +72,11 @@ Note: SQLite is the default database type, but for performance reason, it is not
|
|
|
70
72
|
| `database.password` | string | | Database password |
|
|
71
73
|
| `database.host` | string | `localhost` | Database host |
|
|
72
74
|
| `database.port` | number | `3306` | Database port |
|
|
73
|
-
| `file` | string | `stats.db` | Path to the file where stats are stored |
|
|
74
75
|
| `iso-week` | boolean | `false` | Whether to use ISO week format |
|
|
75
76
|
| `count-downloads` | boolean | `true` | Whether to count downloads |
|
|
76
77
|
| `count-manifest-views` | boolean | `true` | Whether to count manifest views |
|
|
78
|
+
| `flush-interval` | number or string | `5000` | Flush interval in ms or a duration string (e.g. `5s`, `1m`); `0` = realtime, `<0` disables timer |
|
|
79
|
+
| `max-pending-entries` | number | `10000` | Flush when the number of pending entry keys reaches this threshold |
|
|
77
80
|
|
|
78
81
|
## Usage
|
|
79
82
|
|
|
@@ -82,7 +85,7 @@ After installing and configuring the plugin, it will automatically begin collect
|
|
|
82
85
|
You can view the statistics by visiting the following URL:
|
|
83
86
|
|
|
84
87
|
```
|
|
85
|
-
http://your-registry.com/-/
|
|
88
|
+
http://your-registry.com/-/web/stats
|
|
86
89
|
```
|
|
87
90
|
|
|
88
91
|
## License
|
package/lib/config.d.ts
CHANGED
|
@@ -1,85 +1,35 @@
|
|
|
1
1
|
import type { Config } from "@verdaccio/types";
|
|
2
2
|
import type { Options as SequelizeOptions } from "sequelize";
|
|
3
|
-
import z from "zod";
|
|
4
|
-
declare const statsConfig: z.
|
|
5
|
-
dialect: z.ZodDefault<z.ZodOptional<z.ZodEnum<
|
|
6
|
-
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
declare const statsConfig: z.ZodObject<{
|
|
5
|
+
dialect: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
6
|
+
mariadb: "mariadb";
|
|
7
|
+
mssql: "mssql";
|
|
8
|
+
mysql: "mysql";
|
|
9
|
+
postgres: "postgres";
|
|
10
|
+
sqlite: "sqlite";
|
|
11
|
+
}>>>;
|
|
12
|
+
database: z.ZodUnion<readonly [z.ZodDefault<z.ZodString>, z.ZodObject<{
|
|
7
13
|
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
8
14
|
username: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
9
15
|
password: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
10
16
|
host: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
11
17
|
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
12
|
-
},
|
|
13
|
-
name: string;
|
|
14
|
-
username: string;
|
|
15
|
-
password: string;
|
|
16
|
-
host: string;
|
|
17
|
-
port: number;
|
|
18
|
-
}, {
|
|
19
|
-
name?: string | undefined;
|
|
20
|
-
username?: string | undefined;
|
|
21
|
-
password?: string | undefined;
|
|
22
|
-
host?: string | undefined;
|
|
23
|
-
port?: number | undefined;
|
|
24
|
-
}>]>;
|
|
18
|
+
}, z.core.$strip>]>;
|
|
25
19
|
"iso-week": z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
26
20
|
"count-downloads": z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
27
21
|
"count-manifest-views": z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
name: string;
|
|
32
|
-
username: string;
|
|
33
|
-
password: string;
|
|
34
|
-
host: string;
|
|
35
|
-
port: number;
|
|
36
|
-
};
|
|
37
|
-
"iso-week": boolean;
|
|
38
|
-
"count-downloads": boolean;
|
|
39
|
-
"count-manifest-views": boolean;
|
|
40
|
-
}, {
|
|
41
|
-
dialect?: "mariadb" | "mssql" | "mysql" | "postgres" | "sqlite" | undefined;
|
|
42
|
-
database?: string | {
|
|
43
|
-
name?: string | undefined;
|
|
44
|
-
username?: string | undefined;
|
|
45
|
-
password?: string | undefined;
|
|
46
|
-
host?: string | undefined;
|
|
47
|
-
port?: number | undefined;
|
|
48
|
-
} | undefined;
|
|
49
|
-
"iso-week"?: boolean | undefined;
|
|
50
|
-
"count-downloads"?: boolean | undefined;
|
|
51
|
-
"count-manifest-views"?: boolean | undefined;
|
|
52
|
-
}>, {
|
|
53
|
-
dialect: "mariadb" | "mssql" | "mysql" | "postgres" | "sqlite";
|
|
54
|
-
database: string | {
|
|
55
|
-
name: string;
|
|
56
|
-
username: string;
|
|
57
|
-
password: string;
|
|
58
|
-
host: string;
|
|
59
|
-
port: number;
|
|
60
|
-
};
|
|
61
|
-
"iso-week": boolean;
|
|
62
|
-
"count-downloads": boolean;
|
|
63
|
-
"count-manifest-views": boolean;
|
|
64
|
-
}, {
|
|
65
|
-
dialect?: "mariadb" | "mssql" | "mysql" | "postgres" | "sqlite" | undefined;
|
|
66
|
-
database?: string | {
|
|
67
|
-
name?: string | undefined;
|
|
68
|
-
username?: string | undefined;
|
|
69
|
-
password?: string | undefined;
|
|
70
|
-
host?: string | undefined;
|
|
71
|
-
port?: number | undefined;
|
|
72
|
-
} | undefined;
|
|
73
|
-
"iso-week"?: boolean | undefined;
|
|
74
|
-
"count-downloads"?: boolean | undefined;
|
|
75
|
-
"count-manifest-views"?: boolean | undefined;
|
|
76
|
-
}>;
|
|
22
|
+
"flush-interval": z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>>;
|
|
23
|
+
"max-pending-entries": z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
77
25
|
export interface ConfigHolder {
|
|
78
26
|
countDownloads: boolean;
|
|
79
27
|
countManifestViews: boolean;
|
|
80
28
|
favicon: string;
|
|
29
|
+
flushInterval: number;
|
|
81
30
|
isoWeek: boolean;
|
|
82
31
|
logo?: string;
|
|
32
|
+
maxPendingEntries: number;
|
|
83
33
|
sequelizeOptions: SequelizeOptions;
|
|
84
34
|
title: string;
|
|
85
35
|
}
|
|
@@ -93,6 +43,9 @@ export declare class ParsedPluginConfig implements ConfigHolder {
|
|
|
93
43
|
get countDownloads(): boolean;
|
|
94
44
|
get countManifestViews(): boolean;
|
|
95
45
|
get isoWeek(): boolean;
|
|
46
|
+
get flushInterval(): number;
|
|
47
|
+
get maxPendingEntries(): number;
|
|
48
|
+
get maxPendingKeys(): number;
|
|
96
49
|
get logo(): string | undefined;
|
|
97
50
|
get sequelizeOptions(): SequelizeOptions;
|
|
98
51
|
get title(): string;
|
package/lib/constants.d.ts
CHANGED
|
@@ -17,4 +17,5 @@ export declare const ROUTE_TARBALL_DOWNLOAD = "/:package/-/:filename";
|
|
|
17
17
|
export declare const ROUTE_SCOPED_TARBALL_DOWNLOAD = "/@:scope/:package/-/:filename";
|
|
18
18
|
export declare const ROUTE_MANIFEST_VIEW = "/:package/:version?";
|
|
19
19
|
export declare const ROUTE_SCOPED_MANIFEST_VIEW = "/@:scope/:package/:version?";
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const WEB_PATH = "/-/web/stats";
|
|
21
|
+
export declare const API_BASE_PATH = "/-/stats";
|