Skip to content

Prep v1.1.0 - #12

Merged
alex-omophub merged 6 commits into
mainfrom
develop
Aug 11, 2026
Merged

Prep v1.1.0#12
alex-omophub merged 6 commits into
mainfrom
develop

Conversation

@alex-omophub

@alex-omophub alex-omophub commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary by cubic

Adds full pagination to concept mappings with iterators and a new relationshipIds filter, 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 new PaginateOptions.

  • New Features

    • GetMappingsOptions extends PaginationOptions, so mappings.get() accepts page/pageSize and returns meta.pagination (default pageSize 100; server cap 200).
    • Added mappings.getIter() and mappings.getAll() to traverse all pages; getIter throws on a failed page, getAll returns partial data with errors.
    • GetMappingsOptions.relationshipIds to request relationship types (e.g. ['Maps to', 'Maps to value']).
    • README and examples now cover getIter()/getAll(), full-page walks, Value-as-Concept via relationshipIds, directionality ('Mapped from'), includeInvalid, error checks vs. partial results, and resolving target codes via concepts.get().
    • Clarified Mapping interface docs: mappings.get returns ids/names (+confidence); vocabulary/code fields are only on mappings.map.
  • Bug Fixes

    • Prevented infinite loops on servers that omit meta.pagination for mappings by treating such responses as single-page.
    • Clamped pageSize to endpoint limits: mappings to 200 and search.semanticIter()/semanticAll() to 100, avoiding truncation and 400s.
    • Hoisted derivePagination into shared utils with a required policy: mappings use 'single-page'; search uses 'more-if-page-full'. PaginateOptions moved to src/common/interfaces/ and remains exported from the package root.

Written for commit 7b3ed49. Summary will update on new commits.

Review in cubic

Introduce a new interface `PaginateOptions` to define pagination settings, including `pageSize` and `maxPages`, for use in paginating variants.
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 12 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/mappings/mappings.ts Outdated
Comment thread src/mappings/mappings.ts Outdated
Comment thread src/mappings/mappings.ts Outdated
- 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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/common/utils/paginate.ts Outdated
page: number,
pageSize: number,
actualCount: number,
policy: MissingMetaPolicy = 'more-if-page-full',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

alex-omophub added 3 commits August 11, 2026 23:33
…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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread examples/map-between-vocabularies.ts Outdated
- 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.
@alex-omophub
alex-omophub merged commit af75903 into main Aug 11, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant