feat: add CRUD REST API for saved searches (/api/v2/saved-searches)#2544
feat: add CRUD REST API for saved searches (/api/v2/saved-searches)#2544ankitcharolia wants to merge 4 commits into
Conversation
Adds GET/POST /api/v2/saved-searches and GET/PUT/DELETE /api/v2/saved-searches/:id to the external API. The SavedSearch mongoose model and toExternalJSON() already exist; this PR adds only the missing router and index registration. Closes hyperdxio#2543
|
@ankitcharolia is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
|
Greptile SummaryThis PR adds saved-search CRUD support to the external API. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (4): Last reviewed commit: "Merge branch 'main' into feat/saved-sear..." | Re-trigger Greptile |
Adds a Source.findOne({ _id: sourceId, team: teamId }) check to both
POST and PUT handlers, returning 400 if the source does not exist or
belongs to another team. Also adds test coverage for cross-team and
non-existent sourceId scenarios.
Addresses greptile review comments on unchecked source ownership.
Deep ReviewScope: New external CRUD API for saved searches — Intent: Add team-scoped CRUD endpoints ( 🔴 P0/P1 — must fix
🟡 P2 — recommended
🔵 P3 nitpicks (6)
Reviewers (11): correctness, security, adversarial, testing, maintainability, project-standards, api-contract, reliability, kieran-typescript, agent-native, learnings-researcher. Testing gaps:
Pre-existing / out of scope (not counted in verdict): |
Summary
Adds full CRUD endpoints for saved searches to the external API (
/api/v2/saved-searches), enabling infrastructure-as-code tooling to provision saved searches programmatically.The
SavedSearchmongoose model andtoExternalJSON()method already existed — only the router and its registration were missing.New endpoints:
/api/v2/saved-searches/api/v2/saved-searches/api/v2/saved-searches/:id/api/v2/saved-searches/:id/api/v2/saved-searches/:idScreenshots or video
/api/v2/saved-searches→ 404GET /api/v2/saved-searches→{ data: [...] }How to test on Vercel preview
Steps:
curl -H 'Authorization: Bearer <token>' <preview-url>/api/v2/saved-searches— should return{ "data": [] }name,sourceId, and optionalwhere/whereLanguage/select/orderBy/tagssavedSearchIdReferences
packages/api/src/routers/external-api/v2/connections.tspackages/api/src/routers/external-api/__tests__/savedSearches.test.ts