verdaccio-stats 0.2.0 → 0.3.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 +27 -12
- package/lib/config.d.ts +70 -10
- package/lib/constants.d.ts +11 -2
- package/lib/index.js +263 -157
- package/lib/index.mjs +263 -157
- package/lib/middlewares/hooks.d.ts +1 -2
- package/lib/middlewares/stats.d.ts +1 -3
- package/lib/plugin.d.ts +2 -0
- package/lib/storage/db.d.ts +5 -2
- package/lib/utils.d.ts +8 -0
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -29,7 +29,6 @@ npm install --global-style \
|
|
|
29
29
|
mv ./install-here/node_modules/verdaccio-stats/ /path/to/verdaccio/plugins/
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
33
32
|
## Configuration
|
|
34
33
|
|
|
35
34
|
Add the plugin to your Verdaccio config file:
|
|
@@ -38,20 +37,36 @@ Add the plugin to your Verdaccio config file:
|
|
|
38
37
|
middlewares:
|
|
39
38
|
stats:
|
|
40
39
|
enabled: true
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
dialect: sqlite # Optional: sqlite, mysql, postgres, mariadb, mssql (default: sqlite)
|
|
41
|
+
database: stats.db # For SQLite: path to database file
|
|
42
|
+
# For other databases, use object configuration:
|
|
43
|
+
# database:
|
|
44
|
+
# name: verdaccio_stats
|
|
45
|
+
# username: user # Or use VERDACCIO_STATS_USERNAME env var
|
|
46
|
+
# password: pass # Or use VERDACCIO_STATS_PASSWORD env var
|
|
47
|
+
# host: localhost
|
|
48
|
+
# port: 5432
|
|
49
|
+
iso-week: false # Optional, whether to use ISO week format
|
|
50
|
+
count-downloads: true # Optional, whether to count downloads
|
|
51
|
+
count-manifest-views: true # Optional, whether to count manifest views
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
### Configuration Options
|
|
48
55
|
|
|
49
|
-
| Option
|
|
50
|
-
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
56
|
+
| Option | Type | Default | Description |
|
|
57
|
+
| ---------------------- | ---------------- | ----------------- | ----------------------------------------------------------------- |
|
|
58
|
+
| `enabled` | boolean | `true` | Whether the plugin is enabled |
|
|
59
|
+
| `dialect` | string | `sqlite` | Database type (`sqlite`, `mysql`, `postgres`, `mariadb`, `mssql`) |
|
|
60
|
+
| `database` | string or object | `stats.db` | Database configuration |
|
|
61
|
+
| `database.name` | string | `verdaccio_stats` | Database name |
|
|
62
|
+
| `database.username` | string | | Database username |
|
|
63
|
+
| `database.password` | string | | Database password |
|
|
64
|
+
| `database.host` | string | `localhost` | Database host |
|
|
65
|
+
| `database.port` | number | `3306` | Database port |
|
|
66
|
+
| `file` | string | `stats.db` | Path to the file where stats are stored |
|
|
67
|
+
| `iso-week` | boolean | `false` | Whether to use ISO week format |
|
|
68
|
+
| `count-downloads` | boolean | `true` | Whether to count downloads |
|
|
69
|
+
| `count-manifest-views` | boolean | `true` | Whether to count manifest views |
|
|
55
70
|
|
|
56
71
|
## Usage
|
|
57
72
|
|
|
@@ -65,4 +80,4 @@ http://your-registry.com/-/verdaccio/stats/ui
|
|
|
65
80
|
|
|
66
81
|
## License
|
|
67
82
|
|
|
68
|
-
See the [`LICENSE`](LICENSE
|
|
83
|
+
See the [`LICENSE`](LICENSE) file for details.
|
package/lib/config.d.ts
CHANGED
|
@@ -1,17 +1,75 @@
|
|
|
1
1
|
import type { Config } from "@verdaccio/types";
|
|
2
|
+
import type { Options as SequelizeOptions } from "sequelize";
|
|
2
3
|
import z from "zod";
|
|
3
|
-
declare const statsConfig: z.ZodObject<{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
declare const statsConfig: z.ZodEffects<z.ZodObject<{
|
|
5
|
+
dialect: z.ZodDefault<z.ZodOptional<z.ZodEnum<["mariadb", "mssql", "mysql", "postgres", "sqlite"]>>>;
|
|
6
|
+
database: z.ZodUnion<[z.ZodDefault<z.ZodString>, z.ZodObject<{
|
|
7
|
+
name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
8
|
+
username: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
9
|
+
password: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
10
|
+
host: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
11
|
+
port: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
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
|
+
}>]>;
|
|
25
|
+
"iso-week": z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
26
|
+
"count-downloads": z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
27
|
+
"count-manifest-views": z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
28
|
}, "strip", z.ZodTypeAny, {
|
|
9
|
-
|
|
29
|
+
dialect: "mariadb" | "mssql" | "mysql" | "postgres" | "sqlite";
|
|
30
|
+
database: string | {
|
|
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;
|
|
10
49
|
"iso-week"?: boolean | undefined;
|
|
11
50
|
"count-downloads"?: boolean | undefined;
|
|
12
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;
|
|
13
64
|
}, {
|
|
14
|
-
|
|
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;
|
|
15
73
|
"iso-week"?: boolean | undefined;
|
|
16
74
|
"count-downloads"?: boolean | undefined;
|
|
17
75
|
"count-manifest-views"?: boolean | undefined;
|
|
@@ -19,22 +77,24 @@ declare const statsConfig: z.ZodObject<{
|
|
|
19
77
|
export interface ConfigHolder {
|
|
20
78
|
countDownloads: boolean;
|
|
21
79
|
countManifestViews: boolean;
|
|
22
|
-
|
|
80
|
+
favicon: string;
|
|
23
81
|
isoWeek: boolean;
|
|
24
82
|
logo?: string;
|
|
83
|
+
sequelizeOptions: SequelizeOptions;
|
|
25
84
|
title: string;
|
|
26
85
|
}
|
|
27
86
|
export type StatsConfig = z.infer<typeof statsConfig>;
|
|
28
87
|
export declare class ParsedPluginConfig implements ConfigHolder {
|
|
29
|
-
private readonly config;
|
|
30
88
|
private readonly verdaccioConfig;
|
|
89
|
+
readonly favicon: string;
|
|
31
90
|
get configPath(): string;
|
|
32
91
|
get countDownloads(): boolean;
|
|
33
92
|
get countManifestViews(): boolean;
|
|
34
|
-
get file(): string;
|
|
35
93
|
get isoWeek(): boolean;
|
|
36
94
|
get logo(): string | undefined;
|
|
95
|
+
get sequelizeOptions(): SequelizeOptions;
|
|
37
96
|
get title(): string;
|
|
97
|
+
private config;
|
|
38
98
|
constructor(config: StatsConfig, verdaccioConfig: Config);
|
|
39
99
|
}
|
|
40
100
|
export {};
|
package/lib/constants.d.ts
CHANGED
|
@@ -3,9 +3,18 @@ export declare const plugin: {
|
|
|
3
3
|
version: string;
|
|
4
4
|
};
|
|
5
5
|
export declare const pluginKey: string;
|
|
6
|
+
export declare const DIALECTS: readonly ["mariadb", "mssql", "mysql", "postgres", "sqlite"];
|
|
7
|
+
export declare const DEFAULT_DIALECT: (typeof DIALECTS)[number];
|
|
8
|
+
export declare const DEFAULT_SQLITE_STORAGE = "stats.db";
|
|
9
|
+
export declare const DEFAULT_DATABASE_NAME = "verdaccio_stats";
|
|
10
|
+
export declare const DEFAULT_DATABASE_HOST = "localhost";
|
|
11
|
+
export declare const DEFAULT_DATABASE_PORT = 3306;
|
|
6
12
|
export declare const UNIVERSE_PACKAGE_NAME = "**";
|
|
7
13
|
export declare const UNIVERSE_PACKAGE_VERSION = "*";
|
|
8
|
-
export declare const PERIOD_TYPES: readonly ["overall", "
|
|
14
|
+
export declare const PERIOD_TYPES: readonly ["overall", "yearly", "monthly", "weekly", "daily"];
|
|
9
15
|
export declare const PERIOD_VALUE_TOTAL = "total";
|
|
10
|
-
export declare const
|
|
16
|
+
export declare const ROUTE_TARBALL_DOWNLOAD = "/:package/-/:filename";
|
|
17
|
+
export declare const ROUTE_SCOPED_TARBALL_DOWNLOAD = "/@:scope/:package/-/:filename";
|
|
18
|
+
export declare const ROUTE_MANIFEST_VIEW = "/:package/:version?";
|
|
19
|
+
export declare const ROUTE_SCOPED_MANIFEST_VIEW = "/@:scope/:package/:version?";
|
|
11
20
|
export declare const API_BASE_PATH = "/-/verdaccio/stats";
|