Skip to content

feat(core): wrap platform-core SearchClient (YPE-5746) - #180

Open
Dustin-Kelley wants to merge 5 commits into
mainfrom
ype-5706-search-core-v2
Open

Dustin-Kelley wants to merge 5 commits into
mainfrom
ype-5706-search-core-v2

Conversation

@Dustin-Kelley

@Dustin-Kelley Dustin-Kelley commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Replace placeholder Search HTTP in expo-core with a thin wrap of @youversion/platform-core SearchClient (YPE-5746), same pattern as createHighlightsApi / HighlightsClient.
  • Bump @youversion/platform-core to 2.13.0 (core + ui).
  • Public useSearch + USFM helper; createSearchApi stays internal.
  • Align result types with platform-core: verse hits use id (USFM); query lists are { queries }.
  • Thrown client errors map to existing RN Result kinds (auth / transient / invalid-parameter for Zod).

Contract notes for stacked PRs 182/184

  • Consumers must switch verse hit field referenceid.
  • Suggestions/trending return SearchQueries ({ queries }), not a bare array.
  • nextPageToken / searchInsteadFor may be null from platform-core; treat null like “absent” (especially pagination in useBibleReaderSearch).

Test plan

  • typecheck / lint / build / tests green on this PR. CI run 34980621740: Lint, Typecheck, Build, Test, Locale parity, and Locale JSON guard all succeeded.
  • Export pin: useSearch public, createSearchApi not on the package root.
  • Stack follow-up: update PR 184 Search UI for id + { queries } + null tokens.

Greptile Summary

The PR replaces the placeholder Search implementation with a wrapper around platform-core’s SearchClient and exposes the resulting hook, shared DTO types, and USFM conversion helper.

  • Adds suggested-query, trending-query, verse, and topic search operations with RN Result error mapping.
  • Aligns search response types with platform-core and publicly exports useSearch and bibleReferenceFromUsfm while keeping createSearchApi off the package root.
  • Upgrades @youversion/platform-core to 2.13.0 in the core and UI packages.
  • Completes the prior USFM safety fix by rejecting non-positive or unsafe chapter and verse numbers.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
packages/core/src/search/api.ts Wraps platform-core SearchClient operations and consistently converts thrown errors into the existing RN Result shape.
packages/core/src/search/use-search.ts Exposes a memoized provider-configured Search API while preserving the repository’s hook override test seam.
packages/core/src/search/types.ts Publishes aliases for platform-core search DTOs and defines operation parameters and Result error types.
packages/core/src/search/usfm.ts Converts three-part USFM references while correctly rejecting malformed, non-positive, and unsafe numeric coordinates.
packages/core/src/index.ts Exposes the intended public Search hook, constants, DTO types, and USFM helper without exposing createSearchApi.
pnpm-lock.yaml Resolves the platform-core 2.13.0 upgrade and associated peer-dependency snapshot updates.

Sequence Diagram

sequenceDiagram
  participant Consumer
  participant Hook as useSearch
  participant Wrapper as createSearchApi
  participant Client as SearchClient
  participant API as Search API
  Consumer->>Hook: Request search operation
  Hook->>Wrapper: Provider configuration
  Wrapper->>Client: Invoke shared client method
  Client->>API: Authenticated HTTP request
  API-->>Client: Search DTO or error
  Client-->>Wrapper: Value or thrown error
  Wrapper-->>Consumer: Result success or mapped failure
Loading

Reviews (5): Last reviewed commit: "fix(core): reject unsafe integers in bib..." | Re-trigger Greptile

@Dustin-Kelley
Dustin-Kelley added this pull request to stack #185 September 10, 2026 19:05
@Dustin-Kelley
Dustin-Kelley force-pushed the ype-5706-search-core-v2 branch from e8e5fc0 to c6436b5 Compare September 10, 2026 19:12
@cursor cursor Bot changed the title feat(core): placeholder Search client (YPE-5706) feat(core): wrap platform-core SearchClient (YPE-5746) Sep 15, 2026
@Dustin-Kelley
Dustin-Kelley marked this pull request as ready for review September 15, 2026 14:14
Comment thread packages/core/src/search/usfm.ts
@Dustin-Kelley
Dustin-Kelley force-pushed the ype-5706-search-core-v2 branch 2 times, most recently from 07c133b to aa5d572 Compare September 15, 2026 22:07
Dustin-Kelley and others added 5 commits September 15, 2026 22:27
YPE-5706: temporary Search HTTP in expo-core until platform-core
ships SearchClient. Public hook and types only; wrapper stays internal.

Co-authored-by: Cursor <cursoragent@cursor.com>
YPE-5706: hook must throw when used without YouVersionProvider.
Co-authored-by: Cursor <cursoragent@cursor.com>
Delete the local Search HTTP client and wrap SearchClient from
@youversion/platform-core 2.13.0. Thrown errors map to the existing
RN Result kinds. Verse hits use id. Query lists are { queries }.

Co-authored-by: Dustin Kelley <Dustin-Kelley@users.noreply.github.com>
The USFM tests already pin verse-only three-segment parsing.
The exports tests already pin the public surface.

Co-authored-by: Dustin Kelley <Dustin-Kelley@users.noreply.github.com>
Digit-only USFM chapter and verse segments can parse past
Number.MAX_SAFE_INTEGER. Require a positive safe integer.

Co-authored-by: Dustin Kelley <Dustin-Kelley@users.noreply.github.com>
@cursor
cursor Bot force-pushed the ype-5706-search-core-v2 branch from aa5d572 to 38e2c40 Compare September 15, 2026 22:27
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.

2 participants