@mcptoolshop/registry-stats 0.3.1 → 0.4.1

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.ja.md CHANGED
@@ -3,30 +3,35 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
- <img src="assets/logo.png" alt="registry-stats ロゴ" width="280" />
6
+ <img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/registry-stats/readme.png" alt="registry-stats logo" width="400" />
7
7
  </p>
8
8
 
9
- <h1 align="center">@mcptoolshop/registry-stats</h1>
9
+ <p align="center">
10
+ One command. Five registries. All your download stats.
11
+ </p>
10
12
 
11
13
  <p align="center">
12
- 1つのコマンド。5つのレジストリ。すべてのダウンロード統計。
14
+ <a href="https://github.com/mcp-tool-shop-org/registry-stats/actions/workflows/pages.yml"><img src="https://github.com/mcp-tool-shop-org/registry-stats/actions/workflows/pages.yml/badge.svg" alt="CI"></a>
15
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT License"></a>
16
+ <a href="https://www.npmjs.com/package/@mcptoolshop/registry-stats"><img src="https://img.shields.io/npm/v/@mcptoolshop/registry-stats" alt="npm version"></a>
17
+ <a href="https://mcp-tool-shop-org.github.io/registry-stats/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page"></a>
13
18
  </p>
14
19
 
15
20
  <p align="center">
16
- <a href="https://mcp-tool-shop-org.github.io/registry-stats/">ドキュメント</a> &middot;
17
- <a href="#インストール">インストール</a> &middot;
21
+ <a href="https://mcp-tool-shop-org.github.io/registry-stats/">Docs</a> &middot;
22
+ <a href="#install">Install</a> &middot;
18
23
  <a href="#cli">CLI</a> &middot;
19
- <a href="#設定ファイル">設定</a> &middot;
20
- <a href="#プログラマティックapi">API</a> &middot;
21
- <a href="#rest-apiサーバー">RESTサーバー</a> &middot;
22
- <a href="#ライセンス">ライセンス</a>
24
+ <a href="#config-file">Config</a> &middot;
25
+ <a href="#programmatic-api">API</a> &middot;
26
+ <a href="#rest-api-server">REST Server</a> &middot;
27
+ <a href="#license">License</a>
23
28
  </p>
24
29
 
25
30
  ---
26
31
 
27
- npm、PyPI、NuGet、VS Code MarketplaceDocker Hubにパッケージを公開している場合、「今月のダウンロード数は?」という質問に答えるために5つの異なるAPIが必要です。このライブラリは、CLIまたはプログラマティックAPIとして、すべてを1つのインターフェースで提供します。
32
+ もし、npm、PyPI、NuGet、VS Code Marketplace、またはDocker Hubに公開している場合、現在、"今月ダウンロード数は何件ですか?"という質問に答えるために、5つの異なるAPIが必要になります。このライブラリは、それらすべてに対して、CLIまたはプログラムAPIとして、単一のインターフェースを提供します。
28
33
 
29
- 依存関係ゼロ。ネイティブ`fetch()`を使用。Node 18+。
34
+ 依存関係はゼロです。ネイティブの`fetch()`を使用します。Node 18以降が必要です。
30
35
 
31
36
  ## インストール
32
37
 
@@ -34,47 +39,61 @@ npm、PyPI、NuGet、VS Code Marketplace、Docker Hubにパッケージを公開
34
39
  npm install @mcptoolshop/registry-stats
35
40
  ```
36
41
 
37
- ## CLI
42
+ ## CLI (コマンドラインインターフェース)
38
43
 
39
44
  ```bash
40
- # 単一レジストリのクエリ
45
+ # Query a single registry
41
46
  registry-stats express -r npm
47
+ # npm | express
48
+ # month: 283,472,710 week: 67,367,773 day: 11,566,113
42
49
 
43
- # すべてのレジストリを一度にクエリ
50
+ # Query all registries at once
44
51
  registry-stats express
45
52
 
46
- # 月次内訳 + トレンド付き時系列
53
+ # Time series with monthly breakdown + trend
47
54
  registry-stats express -r npm --range 2025-01-01:2025-06-30
55
+ # 2025-01 142,359,021
56
+ # 2025-02 147,522,528
57
+ # ...
58
+ # Total: 448,383,383 Avg/day: 4,982,038 Trend: flat (-0.46%)
48
59
 
49
- # JSON出力
60
+ # Raw JSON output
50
61
  registry-stats express -r npm --json
51
62
 
52
- # その他のレジストリ
63
+ # Other registries
53
64
  registry-stats requests -r pypi
54
65
  registry-stats Newtonsoft.Json -r nuget
55
66
  registry-stats esbenp.prettier-vscode -r vscode
56
67
  registry-stats library/node -r docker
57
68
 
58
- # 設定ファイルを作成
69
+ # Create a config file
59
70
  registry-stats --init
60
71
 
61
- # 設定から実行追跡パッケージをすべて取得
72
+ # Run with config fetches all tracked packages
62
73
  registry-stats
63
74
 
64
- # レジストリ間の比較
75
+ # Compare across registries
65
76
  registry-stats express --compare
66
-
67
- # CSVまたはチャート用JSONでエクスポート
77
+ # express — comparison
78
+ #
79
+ # Metric npm pypi
80
+ # ─────────────────────────────────
81
+ # Total - -
82
+ # Month 283,472 47,201
83
+ # Week 67,367 11,800
84
+ # Day 11,566 1,686
85
+
86
+ # Export as CSV or chart-friendly JSON
68
87
  registry-stats express -r npm --range 2025-01-01:2025-06-30 --format csv
69
88
  registry-stats express -r npm --range 2025-01-01:2025-06-30 --format chart
70
89
 
71
- # REST APIサーバーを起動
90
+ # Start a REST API server
72
91
  registry-stats serve --port 3000
73
92
  ```
74
93
 
75
94
  ## 設定ファイル
76
95
 
77
- プロジェクトルートに`registry-stats.config.json`を作成します(または`registry-stats --init`を実行):
96
+ プロジェクトのルートディレクトリに`registry-stats.config.json`を作成します(または、`registry-stats --init`を実行します)。
78
97
 
79
98
  ```json
80
99
  {
@@ -95,85 +114,104 @@ registry-stats serve --port 3000
95
114
  }
96
115
  ```
97
116
 
98
- 引数なしで`registry-stats`を実行すると、設定されたすべてのパッケージの統計を取得します。CLIはcwdから上方に設定ファイルを検索します。
117
+ 設定されたすべてのパッケージの統計情報を取得するには、引数なしで`registry-stats`を実行します。CLIは、現在の作業ディレクトリから上位のディレクトリを検索し、最も近い設定ファイルを見つけます。
118
+
119
+ 設定ファイルは、プログラム的に利用することも可能です。
120
+
121
+ ```typescript
122
+ import { loadConfig, defaultConfig, starterConfig } from '@mcptoolshop/registry-stats';
123
+
124
+ const config = loadConfig(); // finds nearest config file, or null
125
+ const defaults = defaultConfig(); // returns default Config object
126
+ const template = starterConfig(); // returns starter JSON string
127
+ ```
99
128
 
100
- ## プログラマティックAPI
129
+ ## プログラムAPI
101
130
 
102
131
  ```typescript
103
132
  import { stats, calc, createCache } from '@mcptoolshop/registry-stats';
104
133
 
105
- // 単一レジストリ
134
+ // Single registry
106
135
  const npm = await stats('npm', 'express');
107
136
  const pypi = await stats('pypi', 'requests');
137
+ const nuget = await stats('nuget', 'Newtonsoft.Json');
138
+ const vscode = await stats('vscode', 'esbenp.prettier-vscode');
139
+ const docker = await stats('docker', 'library/node');
108
140
 
109
- // すべてのレジストリを一度に(Promise.allSettledを使用スローしない)
141
+ // All registries at once (uses Promise.allSettled — never throws)
110
142
  const all = await stats.all('express');
111
143
 
112
- // 一括複数パッケージ、並行数制限(デフォルト: 5
144
+ // Bulkmultiple packages, concurrency-limited (default: 5)
113
145
  const bulk = await stats.bulk('npm', ['express', 'koa', 'fastify']);
114
146
 
115
- // 時系列(npm + pypiのみ)
147
+ // Time series (npm + pypi only)
116
148
  const daily = await stats.range('npm', 'express', '2025-01-01', '2025-06-30');
117
149
 
118
- // 計算
119
- calc.total(daily); // ダウンロード合計
120
- calc.avg(daily); // 日次平均
150
+ // Calculations
151
+ calc.total(daily); // sum of all downloads
152
+ calc.avg(daily); // daily average
153
+ calc.groupTotals(calc.monthly(daily)); // { '2025-01': 134982, ... }
121
154
  calc.trend(daily); // { direction: 'up', changePercent: 8.3 }
122
- calc.movingAvg(daily, 7); // 7日間移動平均
123
- calc.popularity(daily); // 0-100 対数スケールスコア
155
+ calc.movingAvg(daily, 7); // 7-day moving average
156
+ calc.popularity(daily); // 0-100 log-scale score
124
157
 
125
- // エクスポート形式
126
- calc.toCSV(daily); // CSV文字列
127
- calc.toChartData(daily, 'express'); // { labels: [...], datasets: [...] }
158
+ // Export formats
159
+ calc.toCSV(daily); // "date,downloads\n2025-01-01,1234\n..."
160
+ calc.toChartData(daily, 'express'); // { labels: [...], datasets: [{ label, data }] }
128
161
 
129
- // 比較レジストリ間で同じパッケージ
162
+ // Comparisonsame package across registries
130
163
  const comparison = await stats.compare('express');
131
- await stats.compare('express', ['npm', 'pypi']);
164
+ // → { package: 'express', registries: { npm: {...}, pypi: {...} }, fetchedAt: '...' }
165
+ await stats.compare('express', ['npm', 'pypi']); // specific registries only
132
166
 
133
- // キャッシュ(5TTL、インメモリ)
167
+ // Caching (5 min TTL, in-memory)
134
168
  const cache = createCache();
135
- await stats('npm', 'express', { cache });
169
+ await stats('npm', 'express', { cache }); // fetches
170
+ await stats('npm', 'express', { cache }); // cache hit
136
171
  ```
137
172
 
138
- ## レジストリサポート
173
+ ## レジストリのサポート
139
174
 
140
- | レジストリ | パッケージ形式 | 時系列 | 利用可能データ |
141
- |----------|---------------|--------|----------------|
142
- | `npm` | `express`, `@scope/pkg` | あり(549日) | lastDay, lastWeek, lastMonth |
143
- | `pypi` | `requests` | あり(180日) | lastDay, lastWeek, lastMonth, total |
144
- | `nuget` | `Newtonsoft.Json` | なし | total |
145
- | `vscode` | `publisher.extension` | なし | total(インストール数)、ratingtrends |
146
- | `docker` | `namespace/repo` | なし | total(プル数)、stars |
175
+ | レジストリ | パッケージ形式 | 時系列データ | 利用可能なデータ |
176
+ | ---------- | --------------- | ------------- | ---------------- |
177
+ | `npm` | `express`, `@scope/pkg` | はい (549日間) | lastDay (直近1日), lastWeek (直近1週間), lastMonth (直近1ヶ月) |
178
+ | `pypi` | `requests` | はい (180日間) | lastDay (直近1日), lastWeek (直近1週間), lastMonth (直近1ヶ月), total (合計) |
179
+ | `nuget` | `Newtonsoft.Json` | No | total (合計) |
180
+ | `vscode` | `publisher.extension` | No | total (インストール数), rating (評価), trends (傾向) |
181
+ | `docker` | `namespace/repo` | No | total (ダウンロード数), stars (スター数) |
147
182
 
148
183
  ## 組み込みの信頼性
149
184
 
150
- - 429/5xxエラーに対する指数バックオフ付き自動リトライ
151
- - `Retry-After`ヘッダーの尊重
152
- - 一括リクエストの並行数制限
153
- - オプションのTTLキャッシュ(プラグイン可能 — `StatsCache`インターフェースでRedis/ファイルバックエンドを利用可能)
185
+ - 429/5xxエラーが発生した場合、指数関数的なバックオフによる自動再試行
186
+ - `Retry-After`ヘッダーを尊重
187
+ - 大量リクエストに対する同時実行数の制限
188
+ - オプションのTTLキャッシュ (プラグイン可能。`StatsCache`インターフェースを通じて、独自のRedis/ファイルバックエンドを提供)
154
189
 
155
190
  ## REST APIサーバー
156
191
 
157
- マイクロサービスとして実行、または独自のサーバーに組み込み:
192
+ マイクロサービスとして実行するか、独自のサーバーに組み込むことができます。
158
193
 
159
194
  ```bash
195
+ # CLI
160
196
  registry-stats serve --port 3000
161
197
  ```
162
198
 
163
199
  ```
164
- GET /stats/:package # すべてのレジストリ
165
- GET /stats/:registry/:package # 単一レジストリ
200
+ GET /stats/:package # all registries
201
+ GET /stats/:registry/:package # single registry
166
202
  GET /compare/:package?registries=npm,pypi
167
203
  GET /range/:registry/:package?start=YYYY-MM-DD&end=YYYY-MM-DD&format=json|csv|chart
168
204
  ```
169
205
 
206
+ カスタムサーバーまたはサーバーレス環境でのプログラム的な利用方法。
207
+
170
208
  ```typescript
171
209
  import { createHandler, serve } from '@mcptoolshop/registry-stats';
172
210
 
173
- // クイックスタート
211
+ // Option 1: Quick start
174
212
  serve({ port: 3000 });
175
213
 
176
- // カスタムサーバー
214
+ // Option 2: Bring your own server
177
215
  import { createServer } from 'node:http';
178
216
  const handler = createHandler();
179
217
  createServer(handler).listen(3000);
@@ -202,6 +240,18 @@ registerProvider(cargo);
202
240
  await stats('cargo', 'serde');
203
241
  ```
204
242
 
243
+ ## ウェブサイト
244
+
245
+ ドキュメント/ランディングページは`site/`にあります。
246
+
247
+ - 開発: `npm run site:dev`
248
+ - ビルド: `npm run site:build`
249
+ - プレビュー: `npm run site:preview`
250
+
205
251
  ## ライセンス
206
252
 
207
253
  MIT
254
+
255
+ ---
256
+
257
+ <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>によって作成されました。
package/README.md CHANGED
@@ -3,15 +3,20 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
- <img src="assets/logo.png" alt="registry-stats logo" width="280" />
6
+ <img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/registry-stats/readme.png" alt="registry-stats logo" width="400" />
7
7
  </p>
8
8
 
9
- <h1 align="center">@mcptoolshop/registry-stats</h1>
10
-
11
9
  <p align="center">
12
10
  One command. Five registries. All your download stats.
13
11
  </p>
14
12
 
13
+ <p align="center">
14
+ <a href="https://github.com/mcp-tool-shop-org/registry-stats/actions/workflows/pages.yml"><img src="https://github.com/mcp-tool-shop-org/registry-stats/actions/workflows/pages.yml/badge.svg" alt="CI"></a>
15
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT License"></a>
16
+ <a href="https://www.npmjs.com/package/@mcptoolshop/registry-stats"><img src="https://img.shields.io/npm/v/@mcptoolshop/registry-stats" alt="npm version"></a>
17
+ <a href="https://mcp-tool-shop-org.github.io/registry-stats/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page"></a>
18
+ </p>
19
+
15
20
  <p align="center">
16
21
  <a href="https://mcp-tool-shop-org.github.io/registry-stats/">Docs</a> &middot;
17
22
  <a href="#install">Install</a> &middot;
@@ -246,3 +251,7 @@ Docs / landing page lives in `site/`.
246
251
  ## License
247
252
 
248
253
  MIT
254
+
255
+ ---
256
+
257
+ Built by <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>
package/README.pt-BR.md CHANGED
@@ -3,30 +3,35 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
- <img src="assets/logo.png" alt="logo registry-stats" width="280" />
6
+ <img src="https://raw.githubusercontent.com/mcp-tool-shop-org/brand/main/logos/registry-stats/readme.png" alt="registry-stats logo" width="400" />
7
7
  </p>
8
8
 
9
- <h1 align="center">@mcptoolshop/registry-stats</h1>
9
+ <p align="center">
10
+ One command. Five registries. All your download stats.
11
+ </p>
10
12
 
11
13
  <p align="center">
12
- Um comando. Cinco registros. Todas as suas estatísticas de download.
14
+ <a href="https://github.com/mcp-tool-shop-org/registry-stats/actions/workflows/pages.yml"><img src="https://github.com/mcp-tool-shop-org/registry-stats/actions/workflows/pages.yml/badge.svg" alt="CI"></a>
15
+ <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="MIT License"></a>
16
+ <a href="https://www.npmjs.com/package/@mcptoolshop/registry-stats"><img src="https://img.shields.io/npm/v/@mcptoolshop/registry-stats" alt="npm version"></a>
17
+ <a href="https://mcp-tool-shop-org.github.io/registry-stats/"><img src="https://img.shields.io/badge/Landing_Page-live-blue" alt="Landing Page"></a>
13
18
  </p>
14
19
 
15
20
  <p align="center">
16
21
  <a href="https://mcp-tool-shop-org.github.io/registry-stats/">Docs</a> &middot;
17
- <a href="#instalação">Instalação</a> &middot;
22
+ <a href="#install">Install</a> &middot;
18
23
  <a href="#cli">CLI</a> &middot;
19
- <a href="#arquivo-de-configuração">Configuração</a> &middot;
20
- <a href="#api-programática">API</a> &middot;
21
- <a href="#servidor-rest-api">Servidor REST</a> &middot;
22
- <a href="#licença">Licença</a>
24
+ <a href="#config-file">Config</a> &middot;
25
+ <a href="#programmatic-api">API</a> &middot;
26
+ <a href="#rest-api-server">REST Server</a> &middot;
27
+ <a href="#license">License</a>
23
28
  </p>
24
29
 
25
30
  ---
26
31
 
27
- Se você publica no npm, PyPI, NuGet, VS Code Marketplace ou Docker Hub, atualmente precisa de cinco APIs diferentes para responder "quantos downloads eu tive este mês?" Esta biblioteca oferece uma interface unificada — como CLI ou API programática.
32
+ Se você publica no npm, PyPI, NuGet, VS Code Marketplace ou Docker Hub, atualmente você precisa de cinco APIs diferentes para responder à pergunta "quantos downloads eu obtive este mês?". Esta biblioteca oferece uma única interface para todas elas — como uma interface de linha de comando (CLI) ou uma API programática.
28
33
 
29
- Zero dependências. Usa `fetch()` nativo. Node 18+.
34
+ Sem dependências. Utiliza a função nativa `fetch()`. Node 18+.
30
35
 
31
36
  ## Instalação
32
37
 
@@ -34,47 +39,61 @@ Zero dependências. Usa `fetch()` nativo. Node 18+.
34
39
  npm install @mcptoolshop/registry-stats
35
40
  ```
36
41
 
37
- ## CLI
42
+ ## Interface de Linha de Comando (CLI)
38
43
 
39
44
  ```bash
40
- # Consultar um único registro
45
+ # Query a single registry
41
46
  registry-stats express -r npm
47
+ # npm | express
48
+ # month: 283,472,710 week: 67,367,773 day: 11,566,113
42
49
 
43
- # Consultar todos os registros
50
+ # Query all registries at once
44
51
  registry-stats express
45
52
 
46
- # Série temporal com detalhamento mensal + tendência
53
+ # Time series with monthly breakdown + trend
47
54
  registry-stats express -r npm --range 2025-01-01:2025-06-30
55
+ # 2025-01 142,359,021
56
+ # 2025-02 147,522,528
57
+ # ...
58
+ # Total: 448,383,383 Avg/day: 4,982,038 Trend: flat (-0.46%)
48
59
 
49
- # Saída JSON
60
+ # Raw JSON output
50
61
  registry-stats express -r npm --json
51
62
 
52
- # Outros registros
63
+ # Other registries
53
64
  registry-stats requests -r pypi
54
65
  registry-stats Newtonsoft.Json -r nuget
55
66
  registry-stats esbenp.prettier-vscode -r vscode
56
67
  registry-stats library/node -r docker
57
68
 
58
- # Criar arquivo de configuração
69
+ # Create a config file
59
70
  registry-stats --init
60
71
 
61
- # Executar com configuraçãobusca todos os pacotes rastreados
72
+ # Run with configfetches all tracked packages
62
73
  registry-stats
63
74
 
64
- # Comparar entre registros
75
+ # Compare across registries
65
76
  registry-stats express --compare
66
-
67
- # Exportar como CSV ou JSON para gráficos
77
+ # express — comparison
78
+ #
79
+ # Metric npm pypi
80
+ # ─────────────────────────────────
81
+ # Total - -
82
+ # Month 283,472 47,201
83
+ # Week 67,367 11,800
84
+ # Day 11,566 1,686
85
+
86
+ # Export as CSV or chart-friendly JSON
68
87
  registry-stats express -r npm --range 2025-01-01:2025-06-30 --format csv
69
88
  registry-stats express -r npm --range 2025-01-01:2025-06-30 --format chart
70
89
 
71
- # Iniciar servidor REST API
90
+ # Start a REST API server
72
91
  registry-stats serve --port 3000
73
92
  ```
74
93
 
75
94
  ## Arquivo de Configuração
76
95
 
77
- Crie um `registry-stats.config.json` na raiz do projeto (ou execute `registry-stats --init`):
96
+ Crie um arquivo `registry-stats.config.json` na raiz do seu projeto (ou execute `registry-stats --init`):
78
97
 
79
98
  ```json
80
99
  {
@@ -95,85 +114,104 @@ Crie um `registry-stats.config.json` na raiz do projeto (ou execute `registry-st
95
114
  }
96
115
  ```
97
116
 
98
- Execute `registry-stats` sem argumentos para obter estatísticas de todos os pacotes configurados. O CLI procura o arquivo de configuração subindo a partir do diretório atual.
117
+ Execute `registry-stats` sem argumentos para obter as estatísticas de todos os pacotes configurados. A CLI procura o arquivo de configuração a partir do diretório atual.
118
+
119
+ A configuração também está disponível programaticamente:
120
+
121
+ ```typescript
122
+ import { loadConfig, defaultConfig, starterConfig } from '@mcptoolshop/registry-stats';
123
+
124
+ const config = loadConfig(); // finds nearest config file, or null
125
+ const defaults = defaultConfig(); // returns default Config object
126
+ const template = starterConfig(); // returns starter JSON string
127
+ ```
99
128
 
100
129
  ## API Programática
101
130
 
102
131
  ```typescript
103
132
  import { stats, calc, createCache } from '@mcptoolshop/registry-stats';
104
133
 
105
- // Registro único
134
+ // Single registry
106
135
  const npm = await stats('npm', 'express');
107
136
  const pypi = await stats('pypi', 'requests');
137
+ const nuget = await stats('nuget', 'Newtonsoft.Json');
138
+ const vscode = await stats('vscode', 'esbenp.prettier-vscode');
139
+ const docker = await stats('docker', 'library/node');
108
140
 
109
- // Todos os registros (usa Promise.allSettled — nunca lança erro)
141
+ // All registries at once (uses Promise.allSettled — never throws)
110
142
  const all = await stats.all('express');
111
143
 
112
- // Em massa múltiplos pacotes, concorrência limitada (padrão: 5)
144
+ // Bulkmultiple packages, concurrency-limited (default: 5)
113
145
  const bulk = await stats.bulk('npm', ['express', 'koa', 'fastify']);
114
146
 
115
- // Série temporal (apenas npm + pypi)
147
+ // Time series (npm + pypi only)
116
148
  const daily = await stats.range('npm', 'express', '2025-01-01', '2025-06-30');
117
149
 
118
- // Cálculos
119
- calc.total(daily); // total de downloads
120
- calc.avg(daily); // média diária
150
+ // Calculations
151
+ calc.total(daily); // sum of all downloads
152
+ calc.avg(daily); // daily average
153
+ calc.groupTotals(calc.monthly(daily)); // { '2025-01': 134982, ... }
121
154
  calc.trend(daily); // { direction: 'up', changePercent: 8.3 }
122
- calc.movingAvg(daily, 7); // média móvel de 7 dias
123
- calc.popularity(daily); // pontuação 0-100 escala logarítmica
155
+ calc.movingAvg(daily, 7); // 7-day moving average
156
+ calc.popularity(daily); // 0-100 log-scale score
124
157
 
125
- // Formatos de exportação
126
- calc.toCSV(daily); // string CSV
127
- calc.toChartData(daily, 'express'); // { labels: [...], datasets: [...] }
158
+ // Export formats
159
+ calc.toCSV(daily); // "date,downloads\n2025-01-01,1234\n..."
160
+ calc.toChartData(daily, 'express'); // { labels: [...], datasets: [{ label, data }] }
128
161
 
129
- // Comparaçãomesmo pacote entre registros
162
+ // Comparisonsame package across registries
130
163
  const comparison = await stats.compare('express');
131
- await stats.compare('express', ['npm', 'pypi']);
164
+ // → { package: 'express', registries: { npm: {...}, pypi: {...} }, fetchedAt: '...' }
165
+ await stats.compare('express', ['npm', 'pypi']); // specific registries only
132
166
 
133
- // Cache (TTL 5 min, em memória)
167
+ // Caching (5 min TTL, in-memory)
134
168
  const cache = createCache();
135
- await stats('npm', 'express', { cache });
169
+ await stats('npm', 'express', { cache }); // fetches
170
+ await stats('npm', 'express', { cache }); // cache hit
136
171
  ```
137
172
 
138
- ## Suporte de Registros
173
+ ## Suporte a Registros
139
174
 
140
- | Registro | Formato do pacote | Série temporal | Dados disponíveis |
141
- |----------|------------------|----------------|-------------------|
142
- | `npm` | `express`, `@scope/pkg` | Sim (549 dias) | lastDay, lastWeek, lastMonth |
143
- | `pypi` | `requests` | Sim (180 dias) | lastDay, lastWeek, lastMonth, total |
144
- | `nuget` | `Newtonsoft.Json` | Não | total |
145
- | `vscode` | `publisher.extension` | Não | total (instalações), rating, trends |
146
- | `docker` | `namespace/repo` | Não | total (pulls), stars |
175
+ | Registro | Formato do pacote | Séries temporais | Dados disponíveis |
176
+ | ---------- | --------------- | ------------- | ---------------- |
177
+ | `npm` | `express`, `@scope/pkg` | Sim (549 dias) | último dia, última semana, último mês |
178
+ | `pypi` | `requests` | Sim (180 dias) | último dia, última semana, último mês, total |
179
+ | `nuget` | `Newtonsoft.Json` | No | total |
180
+ | `vscode` | `publisher.extension` | No | total (instalações), avaliação, tendências |
181
+ | `docker` | `namespace/repo` | No | total (downloads), estrelas |
147
182
 
148
183
  ## Confiabilidade Integrada
149
184
 
150
- - Retry automático com backoff exponencial em erros 429/5xx
185
+ - Tentativa automática com retrocesso exponencial em caso de erros 429/5xx
151
186
  - Respeita os cabeçalhos `Retry-After`
152
- - Limitação de concorrência para requisições em massa
153
- - Cache TTL opcional (extensíveluse Redis/arquivo via interface `StatsCache`)
187
+ - Limitação de concorrência para solicitações em lote
188
+ - Cache TTL opcional (plugávelutilize seu próprio backend Redis/arquivo através da interface `StatsCache`)
154
189
 
155
- ## Servidor REST API
190
+ ## Servidor de API REST
156
191
 
157
- Execute como microsserviço ou integre ao seu servidor:
192
+ Execute como um microserviço ou incorpore em seu próprio servidor:
158
193
 
159
194
  ```bash
195
+ # CLI
160
196
  registry-stats serve --port 3000
161
197
  ```
162
198
 
163
199
  ```
164
- GET /stats/:package # todos os registros
165
- GET /stats/:registry/:package # registro único
200
+ GET /stats/:package # all registries
201
+ GET /stats/:registry/:package # single registry
166
202
  GET /compare/:package?registries=npm,pypi
167
203
  GET /range/:registry/:package?start=YYYY-MM-DD&end=YYYY-MM-DD&format=json|csv|chart
168
204
  ```
169
205
 
206
+ Uso programático para servidores personalizados ou sem servidor:
207
+
170
208
  ```typescript
171
209
  import { createHandler, serve } from '@mcptoolshop/registry-stats';
172
210
 
173
- // Início rápido
211
+ // Option 1: Quick start
174
212
  serve({ port: 3000 });
175
213
 
176
- // Servidor personalizado
214
+ // Option 2: Bring your own server
177
215
  import { createServer } from 'node:http';
178
216
  const handler = createHandler();
179
217
  createServer(handler).listen(3000);
@@ -202,6 +240,18 @@ registerProvider(cargo);
202
240
  await stats('cargo', 'serde');
203
241
  ```
204
242
 
243
+ ## Website
244
+
245
+ A documentação e a página inicial estão localizadas em `site/`.
246
+
247
+ - Desenvolvimento: `npm run site:dev`
248
+ - Construção: `npm run site:build`
249
+ - Visualização: `npm run site:preview`
250
+
205
251
  ## Licença
206
252
 
207
253
  MIT
254
+
255
+ ---
256
+
257
+ Criado por <a href="https://mcp-tool-shop.github.io/">MCP Tool Shop</a>