fix(ds-elasticsearch): propagate enableCount option to the underlying model#216
Closed
PMerlet wants to merge 1 commit into
Closed
fix(ds-elasticsearch): propagate enableCount option to the underlying model#216PMerlet wants to merge 1 commit into
PMerlet wants to merge 1 commit into
Conversation
… model The `enableCount` option exposed on `addCollectionFromIndex` and `addCollectionFromTemplate` was never destructured nor forwarded to `ModelElasticsearch`, so it was silently dropped. As a result, consumers setting `enableCount: true` still ended up with a non-countable collection — Forest Admin's UI then has no total to drive pagination and effectively shows only the first page of records. Forward the flag through `addCollectionFromIndex`, `addCollectionFromTemplate` and `introspectTemplate` to the `ModelElasticsearch` constructor, and add tests asserting both the collection-level wiring and the builder propagation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.
Summary
The
enableCountoption exposed onaddCollectionFromIndexandaddCollectionFromTemplatewas documented and typed, but never destructured from the options object — andintrospectTemplatedidn't accept it either. As a result,enableCount: truewas silently dropped, the producedModelElasticsearchhadenableCount === undefined, andElasticsearchCollection's constructor never calledthis.enableCount().Symptom in Forest Admin: collections backed by this datasource appear non-countable in the UI — no
1-15 of Ntotal, and (depending on the frontend version) no next-page control — even when consumers explicitly opt in viaenableCount: true.Changes
src/introspection/builder.ts: destructureenableCountin bothaddCollectionFromIndexandaddCollectionFromTemplate, and forward it toModelElasticsearch/introspectTemplate. Added the option to theElasticsearchDatasourceOptionsBuilderinterface signatures for consistency.src/introspection/template-introspector.ts: acceptenableCountand pass it to bothModelElasticsearchconstructor branches (legacy + index template).test/collection.test.ts: unit-test the wiring — the producedElasticsearchCollection's schema iscountable: trueiff the model hasenableCount = true, otherwisecountable: false.test/introspection/builder.integration.test.ts: integration-test the propagation throughaddCollectionFromTemplate.No public API changes —
enableCountwas already declared onElasticsearchCollectionBase.Test plan
yarn buildpassesyarn lintpassesnpx jest --testPathIgnorePatterns=integration— 102/102 passing (includes 2 new unit tests incollection.test.ts)docker compose up) — locally verified with the new builder integration test; please re-run in CI🤖 Generated with Claude Code
Note
Propagate
enableCountoption toModelElasticsearchin the Elasticsearch datasource builderThe
enableCountflag was accepted byaddCollectionFromIndexandaddCollectionFromTemplatein the builder interface but not forwarded to the underlyingModelElasticsearchconstructor, causing count capability to always be disabled.enableCountfrom options and passes it toModelElasticsearch(via direct construction orintrospectTemplate).enableCountas an optional parameter and forwards it toModelElasticsearchin both index and legacy template branches.Macroscope summarized ec4ae19.