Repository navigation
feat: add GET /catalog for a product picker - #90
Merged
Merged
Conversation
Serves the product catalog from memory, cheap enough to call on every keystroke. q is matched against the name, aliases, vendor and product, ignoring case and treating space, "-", "_", "." and "/" alike; the exact name or alias comes first, then names starting with the text, then vendors and products starting with it, then names containing it. category and limit narrow the list, and total counts what matched. Each entry says where a search by its name looks (sources: nvd, cna) and carries the exact vendor and product pairs, so a client can show where a result will come from rather than hide it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With the catalog (#88) and the search by a catalog name (#89) in place, a client has no way to list the catalog. heretix-management needs it to offer a picker for hand-registered products, instead of asking the user to type a CPE product name.
Changes
GET /api/v1/catalogserves the catalog from memory (no query), so it is cheap enough to call on every keystroke.qis matched against the name, aliases, vendor and product, ignoring case and treating space,-,_,.and/alike (big ip,big_ipand the aliasbigipall findF5 BIG-IP). The exact name or alias comes first, then names starting with the text, then vendors and products starting with it, then names containing it.categoryandlimit(default 50, max 200) narrow the list;totalcounts what matched before the limit.q, every entry by category and name.sources:nvd,cna) and carries the exact vendor and product pairs, so a client can show where a result will come from.searchCatalog/catalogListinginsrc/utils/catalog-search.tsdo the matching and the shaping.docs/api.md, and the endpoint tables inREADME.mdandREADME.ja.md.No schema change; the route sits behind the same API key as the others.
Test plan
vitest(741 unit tests, 7 new),test:integration(98, four new: the API key is required, an entry lists its sources and pairs, found by vendor / alias / changed separators, category and limit withtotal),tsc --noEmit,eslintGET /api/v1/catalog?q=ivantireturnsIvanti Automation