Skip to content

feat: repository collections route - #2346

Open
epipav wants to merge 1 commit into
feat/IN-1409from
feat/IN-1410
Open

epipav wants to merge 1 commit into
feat/IN-1409from
feat/IN-1410

Conversation

@epipav

@epipav epipav commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds GET /v1-alpha/repositories/collections?url=<repository url> (IN-1410, epic IN-1146). It returns the public collections that directly contain the repository, as {name, slug, logoUrl}, plus publicCount. It reuses CollectionRef and CollectionMemberships from #2345, so this PR is stacked on it.

  • listRepositoryCollections in src/lib/collections-db.ts matches the repository URL exactly and counts only live collectionsRepositories rows, as the Nuxt route does. A repository that belongs only through a collected project is left out.
  • An unknown repository answers 404. A known repository in no public collection answers 200 with an empty list.
  • url is required and must be non-empty (400 otherwise). A CM database failure answers 503.

Notes

  • Private collections and privateCount come later with the LFID-aware version of the shared query.

Tests

  • tests/collections-repository-collections.test.ts: response shape, 404 against an empty list, url validation, cache header, 503, absence under /v1 and the OpenAPI entry.
  • tests/collections-db.test.ts: the query's public-only filter, exact URL match, direct membership and the unknown or empty results.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:17
@cursor

cursor Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Read-only v1-alpha endpoint with existing collection visibility rules; no auth or write-path changes in this PR.

Overview
Adds GET /v1-alpha/repositories/collections?url=… so clients can list public collections that directly contain a repository (not membership via a collected project only), returning CollectionMemberships (data + publicCount).

listRepositoryCollections in collections-db.ts queries by exact repository URL over live collectionsRepositories rows, mirrors Nuxt semantics: 404 when the repo is unknown, 200 with empty data when the repo exists but has no public collections.

The route validates a required non-empty url query param, maps rows through toCollectionRef, and is covered by DB and HTTP/OpenAPI tests (including cache header and /v1 exclusion).

Reviewed by Cursor Bugbot for commit 532227e. Bugbot is set up for automated code reviews on this repo. Configure here.

Signed-off-by: anilb <epipav@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation matches the described contract and includes comprehensive route and database tests.

Review effort: Balanced
Findings: None

What changed in this PR

Adds the /v1-alpha/repositories/collections endpoint for retrieving public collections containing a repository.

Changes:

  • Adds the validated route and 404 handling.
  • Implements exact-URL, direct-membership database lookup.
  • Covers response, validation, failure, routing, and OpenAPI behavior.
File Description
api/​src/​versions/​v1-alpha/​collections/​repository-collections.ts Defines the endpoint and response mapping.
api/​src/​lib/​collections-db.ts Adds the public collection lookup query.
api/​tests/​collections-repository-collections.test.ts Tests route behavior and OpenAPI output.
api/​tests/​collections-db.test.ts Tests query construction and result semantics.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 1, 2026 12:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Full-module mocks omit exports required by autoloaded sibling routes, causing the affected test suites to fail during app startup.

Review effort: Balanced
Findings: 2 High severity

Open (2)

Comment thread api/src/versions/v1-alpha/collections/repository-collections.ts
Comment thread api/tests/collections-repository-collections.test.ts
@epipav epipav self-assigned this Oct 1, 2026
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.

2 participants