Skip to content

feat: search API - #395

Merged
camrun91 merged 4 commits into
mainfrom
cl/ype-5750_search_api
Sep 14, 2026
Merged

camrun91 merged 4 commits into
mainfrom
cl/ype-5750_search_api

Conversation

@camrun91

@camrun91 camrun91 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

This adds the search API for the react SDK it does not implement any of the UI elements. It also adds tests. This is all pointed at the production instance of the search

Greptile Summary

This PR adds a public Platform Search client to the core SDK and targets the production search endpoints.

  • Adds suggested and trending query, verse, and topic search operations.
  • Adds validation, wire-to-SDK response mapping, package exports, documentation, and tests.
  • Adds build entries and a minor changeset for the new public API.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/core/src/schemas/search.ts Defines input validation, production wire schemas, public response types, and wire-to-SDK mappings for all search operations.
packages/core/src/search-queries.ts Implements suggested and trending query requests, including language-range normalization and empty-response handling.
packages/core/src/search-verses.ts Implements validated, paginated verse searches and maps valid USFM references into SDK hit identifiers.
packages/core/src/search-topics.ts Implements unpaginated topic searches and maps snake_case response metadata into the public SDK shape.
packages/core/src/search.ts Adds the SearchClient facade over the tree-shakable search functions.
packages/core/src/index.ts Exposes the new client, standalone operations, options, and structural USFM validator through the package root.
packages/core/tsup.config.ts Adds build entries for the search facade and standalone operations following existing core-module conventions.

Sequence Diagram

sequenceDiagram
  participant Consumer
  participant SearchClient
  participant Validation
  participant ApiClient
  participant SearchAPI as Platform Search API
  Consumer->>SearchClient: Search request
  SearchClient->>Validation: Validate and normalize input
  Validation-->>SearchClient: Parsed parameters
  SearchClient->>ApiClient: "GET /v1/search-*"
  ApiClient->>SearchAPI: HTTPS request
  SearchAPI-->>ApiClient: Search response
  ApiClient-->>SearchClient: Decoded payload
  SearchClient->>Validation: Validate and map wire response
  SearchClient-->>Consumer: SDK response
Loading

Reviews (4): Last reviewed commit: "fix(core): address Search API PR #395 re..." | Re-trigger Greptile

@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cb07a67

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

@camrun91
camrun91 marked this pull request as ready for review September 10, 2026 20:14
@Dustin-Kelley

Copy link
Copy Markdown
Collaborator

suggestion (non-blocking): reuse parseLanguageRanges instead of re-implementing it

searchTopics (packages/core/src/search-topics.ts) repeats the array-wrap + minLength(1) check + parseSearchLanguageRange map that search-queries.ts already added as parseLanguageRanges in this PR. Exporting that helper (or lifting it into schemas/search.ts) keeps range validation in one place — otherwise a future tweak in one file silently leaves the other endpoint behind.

Posted by Claude Code, an AI agent, on behalf of Dustin.

Comment thread packages/core/src/__tests__/search.integration.test.ts Outdated
Comment thread packages/core/src/__tests__/search-topics.test.ts Outdated
Comment thread packages/core/src/__tests__/search-queries.test.ts Outdated
Comment thread packages/core/src/__tests__/search-verses.test.ts Outdated
Replace beforeEach setup with per-test factories per docs/testing.md and consolidate language-range parsing into schemas/search.ts.
@camrun91

Copy link
Copy Markdown
Collaborator Author

done: Lifted parseLanguageRanges into schemas/search.ts and wired both search-queries.ts and search-topics.ts to use it.

Posted by Cursor, an AI agent sent on behalf of Cam.

Comment thread packages/core/src/search-verses.ts
Dustin-Kelley
Dustin-Kelley previously approved these changes Sep 11, 2026
cameronapak
cameronapak previously approved these changes Sep 11, 2026

@cameronapak cameronapak 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.

I'm approving and I had one question and one nit. If this works, wonderful!

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
Document why search keeps a structural USFM check separate from UI
expandPassageId, and that language_ranges use Basic Language Range
grammar rather than full BCP 47.

Co-authored-by: Cameron Llewellyn <cameron.b.llewellyn@gmail.com>

@cameronapak cameronapak 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.

Review

No Jira. Spec is the PR body.

Summary

Standards: 1 must-fix. Spec: 2 must-fix. Primary concern: valid Search API responses can be rejected by the wire schemas.

For Agents
  • CI: passing. Thirteen checks succeeded; coverage badge publication was skipped.
  • Bot review: clear
  • Event: REQUEST_CHANGES
  • HEAD: 1efb127

Written by Code Reviewer bot on behalf of Cam.

Comment thread packages/core/src/schemas/search.ts Outdated
Comment thread packages/core/src/schemas/search.ts Outdated
Comment thread packages/core/src/__tests__/search-queries.test.ts Outdated
Comment thread packages/core/src/schemas/search.ts
Accept JSON null for wire source and user_intent, omitting those fields
on the SDK side. Tighten language-range validation to 1–8 subtags, lowercase
after underscore normalization, and flatten search test describes per
docs/testing.md.

@cameronapak cameronapak 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.

Great work, Cam!!

@camrun91
camrun91 merged commit b3833e4 into main Sep 14, 2026
14 checks passed
@camrun91
camrun91 deleted the cl/ype-5750_search_api branch September 14, 2026 16:08
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.

4 participants