@adonisjs/content 1.4.0 → 1.5.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.
@@ -100,21 +100,29 @@ var OssStatsLoader = class {
100
100
  * ```
101
101
  */
102
102
  async #fetchStats() {
103
- let totalStars = 0;
104
- let totalInstalls = 0;
103
+ const aggregates = [];
105
104
  for (const source of this.#options.sources) {
106
- if (source.type === "github") {
107
- const stars = await aggregateStars({
108
- org: source.org,
109
- ghToken: source.ghToken
105
+ if (typeof source === "function") {
106
+ aggregates.push(await source());
107
+ } else if (source.type === "github") {
108
+ aggregates.push({
109
+ key: "stars",
110
+ count: await aggregateStars({
111
+ org: source.org,
112
+ ghToken: source.ghToken
113
+ })
110
114
  });
111
- totalStars += stars;
112
115
  } else if (source.type === "npm") {
113
- const installs = await aggregateInstalls(source.packages);
114
- totalInstalls += installs;
116
+ aggregates.push({
117
+ key: "installs",
118
+ count: await aggregateInstalls(source.packages)
119
+ });
115
120
  }
116
121
  }
117
- return { stars: totalStars, installs: totalInstalls };
122
+ return aggregates.reduce((result, { key, count }) => {
123
+ result[key] = count;
124
+ return result;
125
+ }, {});
118
126
  }
119
127
  /**
120
128
  * Loads and validates OSS statistics data.
@@ -294,11 +294,14 @@ export type OssStatsOptions = {
294
294
  /** Source type: npm package download statistics */
295
295
  type: 'npm';
296
296
  /** Array of npm packages with their tracking start dates */
297
- packages: [{
297
+ packages: {
298
298
  name: string;
299
299
  startDate: string;
300
- }];
301
- })[];
300
+ }[];
301
+ } | (() => Promise<{
302
+ key: string;
303
+ count: number;
304
+ }>))[];
302
305
  };
303
306
  /**
304
307
  * Type representing the aggregated open source statistics
@@ -308,7 +311,7 @@ export type OssStats = {
308
311
  stars: number;
309
312
  /** Total npm package downloads across all sources */
310
313
  installs: number;
311
- };
314
+ } & Record<string, number>;
312
315
  /**
313
316
  * Represents a GitHub contributor with their profile information and contribution count.
314
317
  * This matches the shape returned by GitHub REST API /contributors endpoint.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adonisjs/content",
3
3
  "description": "Content management for AdonisJS with schema validation, GitHub loaders, and custom queries",
4
- "version": "1.4.0",
4
+ "version": "1.5.0",
5
5
  "engines": {
6
6
  "node": ">=24.0.0"
7
7
  },