Skip to content

feat: include stats in package detail API response#1479

Open
saurabhjain1592 wants to merge 2 commits intoopenclaw:mainfrom
saurabhjain1592:feat/package-stats-in-api
Open

feat: include stats in package detail API response#1479
saurabhjain1592 wants to merge 2 commits intoopenclaw:mainfrom
saurabhjain1592:feat/package-stats-in-api

Conversation

@saurabhjain1592
Copy link
Copy Markdown

Problem

GET /api/v1/packages/{name} returns package metadata but omits the stats field (downloads, installs, stars, versions), even though:

  • The packages table schema includes stats: packageStatsValidator
  • The list endpoint already returns stats via toPublicPackageListItem
  • The skills API (/api/v1/skills/{slug}) returns stats for skills

This means package/plugin authors have no way to see install or download counts for their packages through the API.

Fix

Two changes:

  1. convex/packages.ts — add stats: pkg.stats to the toPublicPackage() return value (the detail-view mapper that was missing it)
  2. convex/httpApiV1/packagesV1.ts — add stats to the PublicPackageDocLike type so the HTTP layer passes it through

The list endpoint already includes stats, so this brings the detail endpoint to parity.

Before / After

# Before
GET /api/v1/packages/%40axonflow%2Fopenclaw
→ { package: { name, displayName, ... }, owner: { ... } }
# No stats

# After
GET /api/v1/packages/%40axonflow%2Fopenclaw
→ { package: { name, displayName, ..., stats: { downloads, installs, stars, versions } }, owner: { ... } }

Fixes #1478

The toPublicPackage() function maps all package fields to the public
response except stats. The schema has packageStatsValidator (downloads,
installs, stars, versions) and the list endpoint already includes it
via toPublicPackageListItem, but the detail endpoint does not.

Add stats to toPublicPackage() return value and the corresponding
PublicPackageDocLike type in the HTTP API layer.

Fixes openclaw#1478
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 2, 2026

@saurabhjain1592 is attempting to deploy a commit to the Amantus Machina Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 2, 2026

Greptile Summary

This PR adds stats (downloads, installs, stars, versions) to the package detail API response (GET /api/v1/packages/{name}) to bring it to parity with the list endpoint. The fix correctly updates toPublicPackage() in convex/packages.ts and the PublicPackageDocLike type in convex/httpApiV1/packagesV1.ts — however, the PublicPackageDoc return type in packages.ts was not updated to include stats, which will cause a TypeScript compilation error and break npx convex deploy.

  • convex/packages.ts: stats: pkg.stats is added to the object literal returned by toPublicPackage(), but the explicit return type PublicPackageDoc still lacks the stats field — TypeScript's excess-property checking on fresh object literals will reject this and fail compilation.
  • convex/httpApiV1/packagesV1.ts: PublicPackageDocLike is correctly extended with the optional stats field matching the schema shape.

Confidence Score: 1/5

Not safe to merge — the missing stats field on PublicPackageDoc will cause a TypeScript compilation failure.

The intent of the PR is correct and the HTTP layer change is fine, but the PublicPackageDoc type in packages.ts was not updated to include stats. Since the function explicitly declares PublicPackageDoc | null as its return type and TypeScript performs excess-property checks on returned object literals, this will produce a compile-time error that blocks deployment.

convex/packages.ts — the PublicPackageDoc type (lines 165–183) must be updated to include stats: Doc<"packages">["stats"].

Comments Outside Diff (1)

  1. convex/packages.ts, line 165-183 (link)

    P0 PublicPackageDoc return type missing stats field

    toPublicPackage() now returns stats: pkg.stats in its object literal (line 291), but the explicit return type PublicPackageDoc | null (declared here) does not include stats. TypeScript performs excess-property checking on fresh object literals returned from functions with an explicit return type, so this will fail to compile with an error like:

    Object literal may only specify known properties, and 'stats' does not exist in type 'PublicPackageDoc'

    Because the project rules prohibit --typecheck=disable, this will break npx convex deploy.

    Add stats to PublicPackageDoc:

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: convex/packages.ts
    Line: 165-183
    
    Comment:
    **`PublicPackageDoc` return type missing `stats` field**
    
    `toPublicPackage()` now returns `stats: pkg.stats` in its object literal (line 291), but the explicit return type `PublicPackageDoc | null` (declared here) does not include `stats`. TypeScript performs excess-property checking on fresh object literals returned from functions with an explicit return type, so this will fail to compile with an error like:
    
    > Object literal may only specify known properties, and 'stats' does not exist in type 'PublicPackageDoc'
    
    Because the project rules prohibit `--typecheck=disable`, this will break `npx convex deploy`.
    
    Add `stats` to `PublicPackageDoc`:
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: convex/packages.ts
Line: 165-183

Comment:
**`PublicPackageDoc` return type missing `stats` field**

`toPublicPackage()` now returns `stats: pkg.stats` in its object literal (line 291), but the explicit return type `PublicPackageDoc | null` (declared here) does not include `stats`. TypeScript performs excess-property checking on fresh object literals returned from functions with an explicit return type, so this will fail to compile with an error like:

> Object literal may only specify known properties, and 'stats' does not exist in type 'PublicPackageDoc'

Because the project rules prohibit `--typecheck=disable`, this will break `npx convex deploy`.

Add `stats` to `PublicPackageDoc`:

```suggestion
type PublicPackageDoc = {
  _id: Id<"packages">;
  name: string;
  displayName: string;
  family: PackageFamily;
  channel: PackageChannel;
  isOfficial: boolean;
  runtimeId?: string;
  summary?: string;
  tags: Record<string, Id<"packageReleases">>;
  latestReleaseId?: Id<"packageReleases">;
  latestVersion?: string | null;
  compatibility?: Doc<"packages">["compatibility"];
  capabilities?: Doc<"packages">["capabilities"];
  verification?: Doc<"packages">["verification"];
  scanStatus?: Doc<"packages">["scanStatus"];
  stats: Doc<"packages">["stats"];
  createdAt: number;
  updatedAt: number;
};
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat: include stats in package detail AP..." | Re-trigger Greptile

The previous commit added stats to the toPublicPackage return value
but missed the PublicPackageDoc type definition, causing a TypeScript
type mismatch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package/plugin stats not exposed in API or web UI

1 participant