Prep v1.1.0 - #12
Conversation
Introduce a new interface `PaginateOptions` to define pagination settings, including `pageSize` and `maxPages`, for use in paginating variants.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
All reported issues were addressed across 12 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
- Introduced `relationshipIds` option in `GetMappingsOptions` to allow fetching specific relationship types, defaulting to `['Maps to']`. - Improved `mappings.getIter()` and `getAll()` to handle servers without `meta.pagination`, preventing infinite loops and ensuring correct pagination behavior. - Clamped `pageSize` for `mappings` and `search.semantic` to their respective maximums, preventing errors on oversized requests. - Refactored pagination logic into `derivePagination` and shared it across resources, ensuring consistent handling of missing pagination metadata. - Updated tests to validate new functionality and edge cases related to pagination and relationship IDs.
There was a problem hiding this comment.
1 issue found across 8 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/common/utils/paginate.ts">
<violation number="1" location="src/common/utils/paginate.ts:130">
P2: The mappings iterators get the safe `'single-page'` policy, but the search iterators (`basicIter` / `basicAll` / `semanticIter` / `semanticAll`) still call `derivePagination` with the default `'more-if-page-full'`. Against a deployment that omits `meta.pagination` and ignores `page` — the exact scenario this PR defends against for mappings — a full page will be treated as 'there is more', so the search walk re-fetches and re-yields the same rows forever instead of terminating. The asymmetry is documented (search presumably honors `page`), but it's worth confirming the search servers truly honor `page`/return `meta.pagination` before relying on the default, since the failure mode you just fixed for mappings still exists for search if that assumption is wrong. If you can't guarantee it, consider making the policy explicit at these call sites too.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| page: number, | ||
| pageSize: number, | ||
| actualCount: number, | ||
| policy: MissingMetaPolicy = 'more-if-page-full', |
There was a problem hiding this comment.
P2: The mappings iterators get the safe 'single-page' policy, but the search iterators (basicIter / basicAll / semanticIter / semanticAll) still call derivePagination with the default 'more-if-page-full'. Against a deployment that omits meta.pagination and ignores page — the exact scenario this PR defends against for mappings — a full page will be treated as 'there is more', so the search walk re-fetches and re-yields the same rows forever instead of terminating. The asymmetry is documented (search presumably honors page), but it's worth confirming the search servers truly honor page/return meta.pagination before relying on the default, since the failure mode you just fixed for mappings still exists for search if that assumption is wrong. If you can't guarantee it, consider making the policy explicit at these call sites too.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/common/utils/paginate.ts, line 130:
<comment>The mappings iterators get the safe `'single-page'` policy, but the search iterators (`basicIter` / `basicAll` / `semanticIter` / `semanticAll`) still call `derivePagination` with the default `'more-if-page-full'`. Against a deployment that omits `meta.pagination` and ignores `page` — the exact scenario this PR defends against for mappings — a full page will be treated as 'there is more', so the search walk re-fetches and re-yields the same rows forever instead of terminating. The asymmetry is documented (search presumably honors `page`), but it's worth confirming the search servers truly honor `page`/return `meta.pagination` before relying on the default, since the failure mode you just fixed for mappings still exists for search if that assumption is wrong. If you can't guarantee it, consider making the policy explicit at these call sites too.</comment>
<file context>
@@ -95,6 +95,54 @@ export async function paginateAll<T>(
+ page: number,
+ pageSize: number,
+ actualCount: number,
+ policy: MissingMetaPolicy = 'more-if-page-full',
+) {
+ const fromMeta = response.meta?.pagination;
</file context>
…rch.semanticIter()` and `semanticAll()`. Ensure `pageSize` is clamped to 100 to prevent errors on oversized requests, aligning with endpoint validation.
…ivePagination` to enforce explicit assumptions about endpoint behavior. Update `CHANGELOG` to reflect changes and clarify pagination logic in `search` resources. Enhance tests for `derivePagination` to cover new requirements and edge cases.
- Updated `map-between-vocabularies.ts` to include new methods: `getIter`, `getAll`, and improved handling of `relationshipIds` for value-as-concept mappings. - Added functions to demonstrate fetching all mappings and excluding invalid ones. - Revised README.md in examples to reflect the new capabilities and clarify usage of the mappings API.
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
- Enhanced `map-between-vocabularies.ts` to check for errors when fetching mappings and concepts, providing clearer logging for failed requests. - Updated comments to clarify the behavior of the API and the implications of partial results. - Improved the interface documentation in `mapping.ts` to specify the differences in response fields between `mappings.get` and `mappings.map` endpoints.
Summary by cubic
Adds full pagination to concept mappings with iterators and a new
relationshipIdsfilter, and makes pagination safe and consistent across mappings and search. Updates docs, examples, and type docs to show the right flows and error handling; clamps oversized requests; bumps the SDK to 1.1.0 with shared iterator helpers and a newPaginateOptions.New Features
GetMappingsOptionsextendsPaginationOptions, somappings.get()acceptspage/pageSizeand returnsmeta.pagination(defaultpageSize100; server cap 200).mappings.getIter()andmappings.getAll()to traverse all pages;getIterthrows on a failed page,getAllreturns partial data witherrors.GetMappingsOptions.relationshipIdsto request relationship types (e.g.['Maps to', 'Maps to value']).getIter()/getAll(), full-page walks, Value-as-Concept viarelationshipIds, directionality ('Mapped from'),includeInvalid, error checks vs. partial results, and resolving target codes viaconcepts.get().Mappinginterface docs:mappings.getreturns ids/names (+confidence); vocabulary/code fields are only onmappings.map.Bug Fixes
meta.paginationfor mappings by treating such responses as single-page.pageSizeto endpoint limits:mappingsto 200 andsearch.semanticIter()/semanticAll()to 100, avoiding truncation and 400s.derivePaginationinto shared utils with a required policy: mappings use'single-page'; search uses'more-if-page-full'.PaginateOptionsmoved tosrc/common/interfaces/and remains exported from the package root.Written for commit 7b3ed49. Summary will update on new commits.