feat: add customizable pagination and ordering parameter names#316
Merged
feat: add customizable pagination and ordering parameter names#316
Conversation
commit: |
Contributor
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||
Add pageFieldName, perPageFieldName, orderByFieldName, and orderByDirectionFieldName class properties to ListEndpoint. These allow overriding the default query parameter names (page, per_page, order_by, order_by_direction) while maintaining full backward compatibility. Also updates D1ListEndpoint to read options using the custom field names, and changes ListFilters.options to Record<string, unknown> to support arbitrary option key names.
1270c9e to
7187370
Compare
…and test coverage Restore ListFilters.options to a backward-compatible type with named default fields plus an index signature for custom names. Use ListFilters["options"] in D1ListEndpoint instead of raw Record. Add inline comment on the as-any cast in getSchema(). Add D1 integration tests for custom pagination field names, tests for partial field name customization, and document the optionFields getter change in the changeset.
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
Adds 4 new class properties to
ListEndpointthat allow overriding the default query parameter names for pagination and ordering:pageFieldName"page"perPageFieldName"per_page"orderByFieldName"order_by"orderByDirectionFieldName"order_by_direction"This follows the existing pattern of
searchFieldNamewhich was already customizable.Breaking change note
ListFilters.optionstype changed from a specific shape ({ page?: number; per_page?: number; ... }) toRecord<string, unknown>. This is technically a breaking change for TypeScript consumers who relied on the specific property types, but the runtime behavior is identical and existing code accessingoptions.pageetc. will still work (just typed asunknownnow).Example
Changes
src/endpoints/list.ts: Added 4 field name properties, convertedoptionFieldsfrom static array to a getter, updatedgetSchema()to use dynamic field namessrc/endpoints/d1/list.ts: Updatedlist()to read options using the custom field namessrc/endpoints/types.ts: ChangedListFilters.optionstoRecord<string, unknown>to support arbitrary option keys