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 3 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 an external API for saved searches. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (3): Last reviewed commit: "fix: validate sourceId ownership before ..." | 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.
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