Merged
Conversation
- Import ADDOK_FILTERS in csv.js - Build geocodeOptions.filters dynamically from ADDOK_FILTERS env var - Replace hardcoded citycode/postcode/type params with generic filter mapping - Update addok-geocode-stream to 0.27.0
Support for addok-cluster 0.11.0 which allows array values for filters.
API changes:
- GET /search and /reverse: Accept multiple values via '+' separator or repeated params
Example: ?citycode=59000+59100 or ?citycode=59000&citycode=59100
- POST /batch: Accept filter values as string with '+' or as array
Example: {filters: {citycode: '59000+59100'}} or {filters: {citycode: ['59000', '59100']}}
- Values are automatically deduplicated and trimmed
Implementation:
- Add parseFilterValues() helper to parse, split, trim and deduplicate filter values
- Update formatParams() to return filter values as arrays
- Add normalizeFilters() in batch.js to process both global and per-request filters
- Update all tests to reflect new array-based filter format
- Add comprehensive tests for multi-value scenarios
Documentation:
- Update README with multi-value syntax examples
- Clarify CSV filter behavior (column names, not values)
- Add batch examples with filters
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for multiple filter values across all API endpoints, maintaining backward compatibility, and updates dependencies to work with addok-cluster 0.11.0 and addok-geocode-stream 0.27.0.
Key changes:
- Filters now accept multiple values using
+separator or repeated parameters (e.g.,?citycode=59000+59100or?citycode=59000&citycode=59100) - CSV endpoint migrated from hardcoded filter parameters to dynamic
filtersobject driven byADDOK_FILTERSenvironment variable - Batch endpoint enhanced to support filters in both global and per-request configurations
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
package.json |
Updated dependencies to addok-cluster 0.11.0 and addok-geocode-stream 0.27.0 |
lib/search.js |
Added parseFilterValues() utility to parse, split, and deduplicate filter values; updated formatParams() to return arrays |
lib/csv.js |
Replaced hardcoded filter parameters with dynamic filters object based on ADDOK_FILTERS |
lib/batch.js |
Added normalizeFilters() function to process filters from both global and per-request params |
test/search.js |
Added comprehensive tests for parseFilterValues() and multi-value filter scenarios |
test/batch.js |
Added tests for batch endpoint with various filter configurations |
README.md |
Updated documentation with multi-value filter syntax examples and CSV filter clarification |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
Add multiple filter values support and adapt to addok-geocode-stream v0.27
This PR adds support for multiple values in filters, compatible with addok-cluster 0.11.0, and adapts the CSV endpoint to the new addok-geocode-stream v0.27.0 API.
🎯 Overview
addok-cluster 0.11.0 introduced the ability to provide multiple values for filters (as arrays of strings). This PR implements this feature across all API endpoints while maintaining backward compatibility.
✨ Features
1. Multiple Filter Values Support
All endpoints now accept multiple values for filters using two syntaxes:
Using
+separator:Using repeated parameters:
Both syntaxes can be combined and will be automatically deduplicated.
2. Batch Endpoint Enhancement
Filters in batch requests now support:
+separator:"citycode": "75001+75002""citycode": ["75001", "75002"]params)Example:
{ "params": { "filters": {"type": "municipality+locality"} }, "requests": [ { "id": "req1", "operation": "geocode", "params": { "q": "lille", "filters": {"citycode": ["59000", "59100"]} } } ] }3. CSV Endpoint Adaptation
Updated to work with addok-geocode-stream v0.27.0:
citycode,postcode,type) to dynamicfiltersobjectADDOK_FILTERSenvironment variable🔧 Implementation Details
New utility function:
parseFilterValues(value): Parses, splits (on+or space), trims, and deduplicates filter valuesModified functions:
formatParams()insearch.js: Now returns filter values as arraysnormalizeFilters()inbatch.js: Processes both global and per-request filtersCSV changes:
ADDOK_FILTERSincsv.jsgeocodeOptions.filtersdynamically from environment configuration✅ Testing
parseFilterValues()behavior (single value, multiple values, arrays, duplicates, whitespace)formatParams()with multiple filter valuessearch.js98%,batch.js100%📚 Documentation
🔄 Breaking Changes
None. The implementation is backward compatible:
📦 Dependencies
addok-geocode-streamfrom^0.26.0to^0.27.0addok-clusterto^0.11.0🎬 Commits
chore(deps): update addok-cluster to 0.11.0Adapt CSV endpoint to new addok-geocode-stream filters APIAdd support for multiple filter valuesReady for review ✅