Skip to content

feat(core): add searchUnified for GET /v1/search-unified - #446

Open
camrun91 wants to merge 14 commits into
mainfrom
caml/ype-6188-search-unified-1037
Open

camrun91 wants to merge 14 commits into
mainfrom
caml/ype-6188-search-unified-1037

Conversation

@camrun91

@camrun91 camrun91 commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Add the live unified-search endpoint to core and React hooks so apps can load top verse references and related topics in one unpaginated request. Existing search methods and the Bible reader flow stay unchanged.

Scope

  • Export searchUnified, SearchClient.searchUnified, useUnifiedSearch, and their public types.
  • Validate request intents, nonempty verse/topic selections, and required response fields. Preserve unknown response intent strings.
  • Include contract tests, usage examples, release changesets, and the measured hooks-barrel size allowance.
  • Defer all Images support and its smoke page to a preserved private follow-up branch.

Verification

  • Forced build, typecheck, lint, 1,042 tests, size, tree-shaking, formatting, and changeset checks pass locally. Two opt-in live tests skipped; contract checks use mocks.
  • Hooks full barrel: 26.94 kB, below the 29.8 kB limit.

Hold merge until Cam authorizes it. YPE-6188 / YPE-6182.

Open in Web Open in Cursor 

RetriggerView in GreptileConfidence Score: 5/5

The reviewed code appears safe to merge, subject to the author’s requested merge hold.

Summary

Adds searchUnified and useUnifiedSearch for one unpaginated snapshot of verse references and related topics.

  • Core search returns verse and topic hits from one request.
  • React apps can load unified search results with a new hook.

Diagram

sequenceDiagram
  participant App
  participant Hook as useUnifiedSearch
  participant Core as SearchClient
  participant API as YouVersion API
  App->>Hook: Query, version, languages, options
  Hook->>Core: searchUnified(...)
  Core->>Core: Validate inputs
  Core->>API: GET /v1/search-unified
  API-->>Core: Verse and topic snapshot
  Core->>Core: Validate and map response
  Core-->>Hook: SearchUnifiedResponse
  Hook-->>App: data, loading, error, refetch
Loading

Reviews (8) · Last reviewed commit: "feat(search): ship unified search withou..." · Reviewed by Greptile

Callers can request verses, topics, and images together. Image hits are id and passageId. Verse and topic hits stay the existing types.
@changeset-bot

changeset-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 70a7489

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-core Minor
@youversion/platform-react-hooks Minor
@youversion/platform-react-ui Minor
vite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Keep the UI barrel aligned with new core runtime exports so
check-public-exports passes.
Measured brotlied barrel is 21.55 kB. Set the limit to measured size
plus ~10% headroom per CONTRIBUTING.
@camrun91
camrun91 marked this pull request as ready for review October 15, 2026 16:57
Comment thread packages/core/src/schemas/search.ts
Comment thread packages/core/src/schemas/search.ts Outdated
Comment thread packages/core/src/schemas/search.ts Outdated
Comment thread packages/core/src/schemas/search.ts Outdated
Comment thread packages/core/src/schemas/search.ts Outdated
Default omitted verses/topics/images wire keys to empty arrays, drop
invalid image hits per item (structural USFM on passage_id), and replace
the runtime field-coverage object with a type-only check.
Use the repo @ts-expect-error pattern for an invalid fields[] value
instead of a typed assertion plus SAFETY comment.
Comment thread packages/core/src/schemas/search.ts Outdated
Use false instead of never in the false branch so Record<..., true>
rejects non-array field mappings.
Dustin-Kelley
Dustin-Kelley previously approved these changes Oct 16, 2026

@Dustin-Kelley Dustin-Kelley left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔥

Wire a vite-react page that calls SearchClient.searchUnified for images
alone or with verses, and renders thin hits plus empty/error states.
Comment thread examples/vite-react/src/pages/SearchUnifiedPage.tsx Outdated
Results was reading the live Fields control, so flipping mode after an
images-only search showed a false empty verses section.

Co-authored-by: cameron.b.llewellyn <cameron.b.llewellyn@gmail.com>
Build on PR446 core search with an additive React hook, image-aware coverage, and documented backend availability. Validate request intents and required response fields without requiring images on the wire.

Amp-Thread-ID: https://ampcode.com/threads/T-01a15a0f-f2cd-72cf-a270-2102b3d073b2
Set the hooks full-barrel budget to measured 27.044 kB plus approximately 10% headroom, following CONTRIBUTING. Leave all narrow-import budgets unchanged.

Amp-Thread-ID: https://ampcode.com/threads/T-01a15a0f-f2cd-72cf-a270-2102b3d073b2
Preserve verse/topic unified search, useUnifiedSearch, and contract validation while deferring Images types, mapping, tests, and smoke page.

Amp-Thread-ID: https://ampcode.com/threads/T-01a15a0f-f2cd-72cf-a270-2102b3d073b2
@cameronapak

cameronapak commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

@camrun91

request: Could you review the unified-search-only scope on this PR? The Images work has been separated because that API is still beta. All exact-head checks are green.

@camrun91

Copy link
Copy Markdown
Collaborator Author

@camrun91

request: Could you review the unified-search-only scope on this PR? The Images work has been separated because that API is still beta. All exact-head checks are green.

Looks like you made the changes in this PR right?

@cameronapak

Copy link
Copy Markdown
Collaborator

@camrun91
request: Could you review the unified-search-only scope on this PR? The Images work has been separated because that API is still beta. All exact-head checks are green.

Looks like you made the changes in this PR right?

Yep to use your existing PR and not re-create it

This branch has not been deployed

No deployments
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.

5 participants