feat: Add configurable search filters for deprecated packages and minimum publish time#859
Draft
feat: Add configurable search filters for deprecated packages and minimum publish time#859
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
…time Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add filtering options for deprecated package searches
feat: Add configurable search filters for deprecated packages and minimum publish time
Oct 24, 2025
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.
Overview
Implements search filtering features to align with npm registry behavior, allowing administrators to filter deprecated packages and set minimum publish time requirements for packages to appear in search results.
Motivation
As documented in npm's search documentation:
This PR implements similar functionality for cnpmcore to:
Changes
1. Deprecated Package Filtering
Default Behavior: Deprecated packages are excluded from search results (enabled by default)
Configuration:
The filter excludes packages where the
deprecatedfield exists and is not empty in the latest version, matching npm's behavior.2. Minimum Publish Time Filtering
Default Behavior: No time filtering (packages appear immediately)
Configuration:
Supported time units:
h- hoursd- daysw- weeksImplementation Details
Architecture
The implementation follows the existing DDD architecture:
Configuration Layer:
searchFilterDeprecatedandsearchMinPublishTimetoCnpmcoreConfiginterfaceconfig.default.tswith environment variable supportData Layer:
deprecatedfield toSearchMappingTypeandPackageJSONTypeService Layer:
PackageSearchService._buildFilterQueries(): Constructs Elasticsearch filter array based on configurationPackageSearchService._parseMinPublishTime(): Parses time format strings into Date objectsfilterclauses in the bool queryElasticsearch Query Structure
Filters are applied using Elasticsearch's
filterclause for optimal performance:Test Coverage
Added comprehensive test coverage (5 new test cases):
Documentation
.env.examplewith clear documentation and examplesBreaking Changes
None. All new features are:
Migration Guide
No migration required. To use the new features:
CNPMCORE_CONFIG_SEARCH_FILTER_DEPRECATED=falseCNPMCORE_CONFIG_SEARCH_MIN_PUBLISH_TIME=2w(or desired duration)Fixes #[issue-number]
Original prompt
Fixes #858
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.